@openfin/ui-library 0.12.0-alpha.1678479800 → 0.12.0-alpha.1678913049
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/elements/DropdownMenu/dropdownMenu.d.ts +5 -5
- package/dist/components/elements/DropdownMenu/index.d.ts +1 -0
- package/dist/components/elements/DropdownMenu/menu.d.ts +57 -0
- package/dist/components/elements/DropdownMenu/{dropdownOptionTitle.d.ts → optionTitle.d.ts} +2 -2
- package/dist/components/system/ThemeProvider/lib/constants.d.ts +1 -0
- package/dist/components/system/ThemeProvider/lib/palette.d.ts +1 -0
- package/dist/hooks/useDropdownKeyboardNavigation.d.ts +16 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +40 -69
- package/package.json +4 -1
- package/dist/components/elements/DropdownMenu/dropdownOptionsMenu.d.ts +0 -24
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { FC, ReactNode } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { MenuOption } from './menu';
|
|
3
3
|
export interface DropdownMenuProps {
|
|
4
4
|
label?: string;
|
|
5
|
-
selected?:
|
|
6
|
-
options?:
|
|
7
|
-
onChange: (value:
|
|
5
|
+
selected?: MenuOption;
|
|
6
|
+
options?: MenuOption[][];
|
|
7
|
+
onChange: (value: MenuOption) => void;
|
|
8
8
|
onOptionHover?: (value?: unknown) => void;
|
|
9
9
|
placeholder?: string;
|
|
10
|
-
renderLabel?: (option:
|
|
10
|
+
renderLabel?: (option: MenuOption, isOpen: boolean, onClick: () => void) => ReactNode;
|
|
11
11
|
fitContent?: boolean;
|
|
12
12
|
}
|
|
13
13
|
export declare const DropdownMenu: FC<DropdownMenuProps>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface MenuOption {
|
|
3
|
+
title: string;
|
|
4
|
+
value: unknown;
|
|
5
|
+
iconUrl?: string;
|
|
6
|
+
overrideOnClick?: (value?: MenuOption) => void;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The properties for the Menu component.
|
|
10
|
+
*/
|
|
11
|
+
export interface MenuProps {
|
|
12
|
+
/**
|
|
13
|
+
* An array of options to be displayed in the menu. The outer array represents the rows of the menu, while the inner arrays represent the columns.
|
|
14
|
+
*/
|
|
15
|
+
options: MenuOption[][];
|
|
16
|
+
/**
|
|
17
|
+
* The currently selected option in the menu.
|
|
18
|
+
*/
|
|
19
|
+
selected?: MenuOption;
|
|
20
|
+
/**
|
|
21
|
+
* The ID of the DropdownMenu component associated with this Menu.
|
|
22
|
+
*/
|
|
23
|
+
dropdownMenuId: string;
|
|
24
|
+
/**
|
|
25
|
+
* A function to be called to close the menu.
|
|
26
|
+
*/
|
|
27
|
+
handleExpandMenu: () => void;
|
|
28
|
+
/**
|
|
29
|
+
* A function to be called when an option in the menu is hovered over.
|
|
30
|
+
*/
|
|
31
|
+
onOptionHover?: (value?: unknown) => void;
|
|
32
|
+
/**
|
|
33
|
+
* A function to be called when an option in the menu is selected/clicked.
|
|
34
|
+
*/
|
|
35
|
+
onChange: (value: MenuOption) => void;
|
|
36
|
+
/**
|
|
37
|
+
* Whether the width of the menu should fit its contents
|
|
38
|
+
*/
|
|
39
|
+
fitContent?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* The width of the menu, as a CSS string, default to 100% of the parent container.
|
|
42
|
+
*/
|
|
43
|
+
width?: string;
|
|
44
|
+
/**
|
|
45
|
+
* The height of the menu, as a CSS string.
|
|
46
|
+
*/
|
|
47
|
+
height?: string;
|
|
48
|
+
/**
|
|
49
|
+
* The text to be displayed as the header of the menu.
|
|
50
|
+
*/
|
|
51
|
+
header?: string;
|
|
52
|
+
/**
|
|
53
|
+
* The currently focused option in the menu.
|
|
54
|
+
*/
|
|
55
|
+
focusedOption: MenuOption;
|
|
56
|
+
}
|
|
57
|
+
export declare const Menu: React.FC<MenuProps>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
2
|
import { TextProps } from '../../typography/Text';
|
|
3
|
-
interface
|
|
3
|
+
interface OptionTitleProps extends Omit<TextProps, 'children'> {
|
|
4
4
|
children?: string;
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
7
|
* A single line of Text that will overflow with ellipsis. When overflown mousing over the text will display a tooltip with the text content.
|
|
8
8
|
*/
|
|
9
|
-
export declare const
|
|
9
|
+
export declare const OptionTitle: FC<OptionTitleProps>;
|
|
10
10
|
/**
|
|
11
11
|
* Checks if a element's content is overflown.
|
|
12
12
|
*/
|
|
@@ -15,6 +15,7 @@ export declare const Color: {
|
|
|
15
15
|
readonly lightGray5: "#C9CBD2";
|
|
16
16
|
readonly neutralGray: "#7D808A";
|
|
17
17
|
readonly neutralGray80: "rgba(125,128,138,0.8)";
|
|
18
|
+
readonly silverGray: "#C0C1C2";
|
|
18
19
|
readonly darkGray1: "#53565F";
|
|
19
20
|
readonly darkGray2: "#383A40";
|
|
20
21
|
readonly darkGray3: "#2F3136";
|
|
@@ -30,6 +30,7 @@ export declare const Palette: {
|
|
|
30
30
|
readonly textDefault: "textDefault";
|
|
31
31
|
readonly textHelp: "textHelp";
|
|
32
32
|
readonly textInactive: "textInactive";
|
|
33
|
+
readonly borderNeutral: "borderNeutral";
|
|
33
34
|
readonly contentBackground1: "contentBackground1";
|
|
34
35
|
readonly contentBackground2: "contentBackground2";
|
|
35
36
|
readonly contentBackground3: "contentBackground3";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { KeyboardEvent } from 'react';
|
|
2
|
+
import { MenuOption } from '../components/elements/DropdownMenu';
|
|
3
|
+
/**
|
|
4
|
+
* Hook that handles keyboard navigation and type-to-select functionality of a dropdown menu and returns the focused option.
|
|
5
|
+
*
|
|
6
|
+
* @param {MenuOption[][]} options - An array of dropdown options, with each nested array representing a row of options.
|
|
7
|
+
* @param {MenuOption} selected - The currently selected dropdown option.
|
|
8
|
+
* @param {boolean} expandMenu - Whether the dropdown menu is expanded or not.
|
|
9
|
+
* @param {(toggle?: boolean) => void} handleExpandMenu - Function to handle toggling the dropdown menu.
|
|
10
|
+
* @param {(value: MenuOption) => void} onChange - Function to handle changing the selected option.
|
|
11
|
+
* @returns {{ focusedOption: MenuOption, handleKeyDown: (event: KeyboardEvent<HTMLDivElement>) => void }} - The currently focused option and a function to handle keydown events.
|
|
12
|
+
*/
|
|
13
|
+
export declare const useDropdownKeyboardNavigation: (options: MenuOption[][], selected: MenuOption | undefined, expandMenu: boolean, handleExpandMenu: (toggle?: boolean) => void, onChange: (value: MenuOption) => void) => {
|
|
14
|
+
focusedOption: MenuOption;
|
|
15
|
+
handleKeyDown: (event: KeyboardEvent<HTMLDivElement>) => void;
|
|
16
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -25,5 +25,6 @@ export * from './components/typography/Text';
|
|
|
25
25
|
export * from './hooks/useColorScheme';
|
|
26
26
|
export * from './hooks/useMediaQuery';
|
|
27
27
|
export * from './hooks/usePrevious';
|
|
28
|
+
export * from './hooks/useDropdownKeyboardNavigation';
|
|
28
29
|
export * as StoryHelpers from './storybookHelpers';
|
|
29
30
|
export * from './lib/whenFin';
|