2022-11-03 18:52:33 +01:00
|
|
|
/**
|
|
|
|
* Common parameters for both types of popover items: with or without confirmation
|
|
|
|
*/
|
|
|
|
interface PopoverItemBase {
|
|
|
|
/**
|
2022-11-28 22:57:48 +01:00
|
|
|
* Displayed text
|
2022-11-03 18:52:33 +01:00
|
|
|
*/
|
2022-12-14 21:46:36 +01:00
|
|
|
title?: string;
|
2022-11-03 18:52:33 +01:00
|
|
|
|
|
|
|
/**
|
2022-11-28 22:57:48 +01:00
|
|
|
* Item icon to be appeared near a title
|
2022-11-03 18:52:33 +01:00
|
|
|
*/
|
2022-11-28 22:57:48 +01:00
|
|
|
icon?: string;
|
2022-11-03 18:52:33 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Additional displayed text
|
|
|
|
*/
|
|
|
|
secondaryLabel?: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* True if item should be highlighted as active
|
|
|
|
*/
|
|
|
|
isActive?: boolean;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* True if item should be disabled
|
|
|
|
*/
|
|
|
|
isDisabled?: boolean;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* True if popover should close once item is activated
|
|
|
|
*/
|
|
|
|
closeOnActivate?: boolean;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Item name
|
|
|
|
* Used in data attributes needed for cypress tests
|
|
|
|
*/
|
|
|
|
name?: string;
|
|
|
|
|
|
|
|
/**
|
2022-12-01 18:58:58 +01:00
|
|
|
* Defines whether item should toggle on click.
|
|
|
|
* Can be represented as boolean value or a string key.
|
|
|
|
* In case of string, works like radio buttons group and highlights as inactive any other item that has same toggle key value.
|
2022-11-03 18:52:33 +01:00
|
|
|
*/
|
2022-12-01 18:58:58 +01:00
|
|
|
toggle?: boolean | string;
|
2022-11-03 18:52:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Represents popover item with confirmation state configuration
|
|
|
|
*/
|
|
|
|
export interface PopoverItemWithConfirmation extends PopoverItemBase {
|
|
|
|
/**
|
|
|
|
* Popover item parameters that should be applied on item activation.
|
|
|
|
* May be used to ask user for confirmation before executing popover item activation handler.
|
|
|
|
*/
|
2022-12-14 21:46:36 +01:00
|
|
|
confirmation: PopoverItem;
|
2022-11-03 18:52:33 +01:00
|
|
|
|
|
|
|
onActivate?: never;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2024-04-13 19:34:26 +02:00
|
|
|
* Represents popover item without confirmation state configuration
|
2022-11-03 18:52:33 +01:00
|
|
|
*/
|
|
|
|
export interface PopoverItemWithoutConfirmation extends PopoverItemBase {
|
|
|
|
confirmation?: never;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Popover item activation handler
|
|
|
|
*
|
|
|
|
* @param item - activated item
|
|
|
|
* @param event - event that initiated item activation
|
|
|
|
*/
|
|
|
|
onActivate: (item: PopoverItem, event?: PointerEvent) => void;
|
2024-04-13 19:34:26 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Represents popover item with children (nested popover items)
|
|
|
|
*/
|
|
|
|
export interface PopoverItemWithChildren extends PopoverItemBase {
|
|
|
|
confirmation?: never;
|
|
|
|
onActivate?: never;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Items of nested popover that should be open on the current item hover/click (depending on platform)
|
|
|
|
*/
|
|
|
|
children?: {
|
|
|
|
items: PopoverItem[]
|
|
|
|
}
|
2022-11-03 18:52:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Represents single popover item
|
|
|
|
*/
|
2024-04-13 19:34:26 +02:00
|
|
|
export type PopoverItem = PopoverItemWithConfirmation | PopoverItemWithoutConfirmation | PopoverItemWithChildren
|
2022-11-03 18:52:33 +01:00
|
|
|
|