@openfin/ui-library 0.24.0 → 0.25.0-alpha.1716474081
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/controls/CustomContextMenu/CustomContextMenu.d.ts +79 -0
- package/dist/components/controls/CustomContextMenu/MenuItems/CustomContextMenuItem.d.ts +14 -0
- package/dist/components/controls/CustomContextMenu/MenuItems/NormalCustomContextMenuItem.d.ts +11 -0
- package/dist/components/controls/CustomContextMenu/MenuItems/RootMenuHeader.d.ts +5 -0
- package/dist/components/controls/CustomContextMenu/MenuItems/SeparatorCustomContextMenuItem.d.ts +2 -0
- package/dist/components/controls/CustomContextMenu/MenuItems/SubmenuHeaderCustomContextMenuItem.d.ts +8 -0
- package/dist/components/controls/CustomContextMenu/index.d.ts +1 -0
- package/dist/components/controls/CustomContextMenu/useContextMenuKeyboardNavigation.d.ts +17 -0
- package/dist/components/controls/CustomContextMenu/useContextMenuKeyboardNavigation.test.d.ts +1 -0
- package/dist/components/controls/CustomContextMenu/useContextMenuNavigation.d.ts +21 -0
- package/dist/components/controls/CustomContextMenu/useContextMenuNavigation.test.d.ts +1 -0
- package/dist/components/controls/CustomContextMenu/useResizeContextMenu.d.ts +14 -0
- package/dist/components/controls/CustomContextMenu/useResizeContextMenu.test.d.ts +1 -0
- package/dist/components/controls/CustomContextMenu/utils.d.ts +3 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +157 -48
- package/package.json +2 -1
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
export declare const CONTEXT_MENU_FRAME_ID = "context_menu_frame", ACTIVE_CONTEXT_MENU_CLASS = "active_context_menu", BASE_CONTEXT_MENU = "base_context_menu", PRIOR_CONTEXT_MENU_CLASS = "previous_context_menu", CONTEXT_MENU_ANIMATION_DURATION = 200;
|
|
3
|
+
export type CustomContextMenuData = {
|
|
4
|
+
type: string;
|
|
5
|
+
option?: string;
|
|
6
|
+
};
|
|
7
|
+
export type CustomContextMenuTemplate = {
|
|
8
|
+
/**
|
|
9
|
+
* Can be `normal`, `separator`, `submenu`, or `checkbox`.
|
|
10
|
+
* Defaults to 'normal' unless a 'submenu' key exists
|
|
11
|
+
*/
|
|
12
|
+
type?: 'normal' | 'separator' | 'submenu' | 'checkbox';
|
|
13
|
+
/**
|
|
14
|
+
* The text to show on the menu item.
|
|
15
|
+
* Must be unique within context menu.
|
|
16
|
+
* Should be left undefined for type: 'separator'
|
|
17
|
+
*/
|
|
18
|
+
label?: string;
|
|
19
|
+
/**
|
|
20
|
+
* If false, the menu item will be greyed out and unclickable.
|
|
21
|
+
*/
|
|
22
|
+
enabled?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* If false, the menu item will be entirely hidden.
|
|
25
|
+
*/
|
|
26
|
+
visible?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Should only be specified for `checkbox` type menu items.
|
|
29
|
+
*/
|
|
30
|
+
checked?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Should be specified for `submenu` type menu items. If `submenu` is specified,
|
|
33
|
+
* the `type: 'submenu'` can be omitted.
|
|
34
|
+
*/
|
|
35
|
+
submenu?: CustomContextMenuTemplate[];
|
|
36
|
+
/**
|
|
37
|
+
* Data to be returned if the user selects the element. Must be serializable
|
|
38
|
+
*/
|
|
39
|
+
data?: CustomContextMenuData;
|
|
40
|
+
/**
|
|
41
|
+
* Image Data URI with image dimensions inferred from the encoded string
|
|
42
|
+
*/
|
|
43
|
+
icon?: string;
|
|
44
|
+
};
|
|
45
|
+
export type CustomContextMenuProps = {
|
|
46
|
+
/**
|
|
47
|
+
* The menu template to render.
|
|
48
|
+
*/
|
|
49
|
+
menuTemplate: CustomContextMenuTemplate[];
|
|
50
|
+
/**
|
|
51
|
+
* Callback for when a menu item is clicked.
|
|
52
|
+
*/
|
|
53
|
+
onClick: (data: CustomContextMenuData) => void;
|
|
54
|
+
/**
|
|
55
|
+
* Optional Icon to be displayed in root menu header
|
|
56
|
+
*/
|
|
57
|
+
icon?: ReactNode;
|
|
58
|
+
/**
|
|
59
|
+
* Optional callback used for when the menu is resized. This is used for custom animations when the menu is resized.
|
|
60
|
+
*/
|
|
61
|
+
onMenuResize?: (height: number, width: number) => void;
|
|
62
|
+
/**
|
|
63
|
+
* Optional callback used for when the context menu is opened. This is used for custom animations when the menu is opened.
|
|
64
|
+
*/
|
|
65
|
+
onContextMenuReady?: () => void;
|
|
66
|
+
/**
|
|
67
|
+
* Optional boolean used to determine whether to apply border radius. When true, no border radius is applied.
|
|
68
|
+
* When false, a border radius of 10px is applied to match the rounded corners on MacOS windows. Defaults to true.
|
|
69
|
+
*/
|
|
70
|
+
isWindows?: boolean;
|
|
71
|
+
};
|
|
72
|
+
export type SubmenulessMenuItemTemplate = Omit<CustomContextMenuTemplate, 'submenu'> & {
|
|
73
|
+
hasSubMenu: boolean;
|
|
74
|
+
};
|
|
75
|
+
export interface SubMenuNavigationTemplate {
|
|
76
|
+
parentLabel: string;
|
|
77
|
+
menuTemplate: SubmenulessMenuItemTemplate[];
|
|
78
|
+
}
|
|
79
|
+
export declare const CustomContextMenu: FC<CustomContextMenuProps>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type CustomContextMenuItemData = {
|
|
2
|
+
icon?: string;
|
|
3
|
+
label?: string;
|
|
4
|
+
type?: 'normal' | 'separator' | 'submenuHeader' | 'submenu' | 'checkbox';
|
|
5
|
+
enabled?: boolean;
|
|
6
|
+
checked?: boolean;
|
|
7
|
+
submenu?: boolean;
|
|
8
|
+
showShouldHomeButton?: boolean;
|
|
9
|
+
onClick?: () => void;
|
|
10
|
+
onClose?: () => void;
|
|
11
|
+
onBack?: () => void;
|
|
12
|
+
selected?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare const CustomContextMenuItem: ({ type, icon, label, enabled, checked, submenu, showShouldHomeButton, onClick, onClose, onBack, selected, }: CustomContextMenuItemData) => JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type NormalCustomContextMenuItemProps = {
|
|
2
|
+
type?: 'checkbox' | 'normal';
|
|
3
|
+
label?: string;
|
|
4
|
+
icon?: string;
|
|
5
|
+
enabled?: boolean;
|
|
6
|
+
checked?: boolean;
|
|
7
|
+
submenu?: boolean;
|
|
8
|
+
onClick?: () => void;
|
|
9
|
+
selected?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare const NormalCustomContextMenuItem: ({ type, label, enabled, checked, submenu, onClick, selected, }: NormalCustomContextMenuItemProps) => JSX.Element;
|
package/dist/components/controls/CustomContextMenu/MenuItems/SubmenuHeaderCustomContextMenuItem.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type SubmenuHeaderCustomContextMenuItemProps = {
|
|
2
|
+
label?: string;
|
|
3
|
+
showShouldHomeButton?: boolean;
|
|
4
|
+
onClose?: () => void;
|
|
5
|
+
onBack?: () => void;
|
|
6
|
+
selected?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare const SubmenuHeaderCustomContextMenuItem: ({ label, showShouldHomeButton, onClose, onBack, selected, }: SubmenuHeaderCustomContextMenuItemProps) => JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CustomContextMenu';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CustomContextMenuData, SubmenulessMenuItemTemplate } from './CustomContextMenu';
|
|
3
|
+
/**
|
|
4
|
+
* Custom hook to handle keyboard navigation for a context menu. Provides handlers for various keyboard events and sets up/tears down event listeners.
|
|
5
|
+
*
|
|
6
|
+
* @param { SubmenulessMenuItemTemplate[] } menuOptions - Array of menu items without submenus.
|
|
7
|
+
* @param { string[] } menuLabelStack - Stack of menu labels representing the current path in the context menu.
|
|
8
|
+
* @param { string } activeMenuLabel - Label of the currently active menu.
|
|
9
|
+
* @param { number } selectedIndex - Index of the currently selected menu item.
|
|
10
|
+
* @param { React.Dispatch<React.SetStateAction<number>> } setSelectedIndex - setState function to update the selected index.
|
|
11
|
+
* @param { (data: CustomContextMenuData) => void } onClick - Callback function to handle click events on menu items.
|
|
12
|
+
* @param { (submenuLabel: string) => void } handleNavigateToSubmenu - Function to navigate to a submenu.
|
|
13
|
+
* @param { (submenuLabel: string) => void } handleBackToParentMenu - Function to navigate back to the parent menu.
|
|
14
|
+
* @param { () => void } handleNavigateToBase - Function to navigate back to the base menu.
|
|
15
|
+
* @returns { void }
|
|
16
|
+
*/
|
|
17
|
+
export declare const useContextMenuKeyboardNavigation: (menuOptions: SubmenulessMenuItemTemplate[], menuLabelStack: string[], activeMenuLabel: string, selectedIndex: number, setSelectedIndex: React.Dispatch<React.SetStateAction<number>>, onClick: (data: CustomContextMenuData) => void, handleNavigateToSubmenu: (submenuLabel: string) => void, handleBackToParentMenu: (submenuLabel: string) => void, handleNavigateToBase: () => void) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SubMenuNavigationTemplate } from './CustomContextMenu';
|
|
3
|
+
/**
|
|
4
|
+
* Custom hook to handle context menu navigation. Return 3 handler functions.
|
|
5
|
+
*
|
|
6
|
+
* @param { number } transitionSpeed - speed of context menu transition when navigating between submenus.
|
|
7
|
+
* @param { React.Dispatch<React.SetStateAction<number>> } setTransitionSpeed - setState function to update the transition speed.
|
|
8
|
+
* @param { string[] } menuLabelStack - stack of menu labels representing the current path in the context menu.
|
|
9
|
+
* @param { React.Dispatch<React.SetStateAction<string[]>> } setMenuLabelStack - setState function to update the menu label stack.
|
|
10
|
+
* @param { string | undefined } activeMenuLabel - label of the currently active menu.
|
|
11
|
+
* @param { React.Dispatch<React.SetStateAction<string | undefined>> } setActiveMenuLabel - setState function to update the active menu label.
|
|
12
|
+
* @param { React.Dispatch<React.SetStateAction<number>> } setSelectedIndex - setState function to update the selected index.
|
|
13
|
+
* @param { SubMenuNavigationTemplate[] } menuCollection - array of all menus.
|
|
14
|
+
* @param @optional { (height: number, width: number) => void } onMenuResize - function to handle menu resize behavior.
|
|
15
|
+
* @returns { { handleNavigateToSubmenu: (parentLabel: string) => void, handleNavigateBackToParent: () => Promise<void>, handleNavigateToBase: () => void } }
|
|
16
|
+
*/
|
|
17
|
+
export declare const useContextMenuNavigation: (transitionSpeed: number, setTransitionSpeed: React.Dispatch<React.SetStateAction<number>>, menuLabelStack: string[], setMenuLabelStack: React.Dispatch<React.SetStateAction<string[]>>, activeMenuLabel: string | undefined, setActiveMenuLabel: React.Dispatch<React.SetStateAction<string | undefined>>, setSelectedIndex: React.Dispatch<React.SetStateAction<number>>, menuCollection: SubMenuNavigationTemplate[], onMenuResize?: ((height: number, width: number) => void) | undefined) => {
|
|
18
|
+
handleNavigateToSubmenu: (parentLabel: string) => void;
|
|
19
|
+
handleNavigateBackToParent: (submenuLabel: string) => void;
|
|
20
|
+
handleNavigateToBase: () => void;
|
|
21
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Custom hook to resize the context menu frame to fit the active context menu.
|
|
4
|
+
*
|
|
5
|
+
* @param activeMenuLabel - label of the currently active menu.
|
|
6
|
+
* @param setActiveMenuWidth - setState function to update the width of the active menu.
|
|
7
|
+
* @returns { { resizeContextMenuFrameToActiveMenu: () => { height: number, width: number } } }
|
|
8
|
+
*/
|
|
9
|
+
export declare const useResizeContextMenu: (activeMenuLabel: string | undefined, setActiveMenuWidth: React.Dispatch<React.SetStateAction<number>>) => {
|
|
10
|
+
resizeContextMenuFrameToActiveMenu: () => {
|
|
11
|
+
height: number;
|
|
12
|
+
width: number;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { CustomContextMenuTemplate, SubMenuNavigationTemplate } from './CustomContextMenu';
|
|
2
|
+
export declare const getClassName: (parentLabel: string, activeMenuLabel: string | undefined, menuStack: string[]) => "" | "active_context_menu" | "previous_context_menu";
|
|
3
|
+
export declare const getMenuNavigationOrder: (template: CustomContextMenuTemplate[]) => SubMenuNavigationTemplate[];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './components/controls/Button';
|
|
2
2
|
export * from './components/controls/CollapsibleCard';
|
|
3
|
+
export * from './components/controls/CustomContextMenu';
|
|
3
4
|
export * from './components/controls/ExpandableButton';
|
|
4
5
|
export * from './components/controls/Toggle';
|
|
5
6
|
export * from './components/elements/Badge';
|