@splunk/react-ui 5.7.1 → 5.9.0
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/Accordion.js +6 -6
- package/Anchor.js +2 -1
- package/Box.js +83 -34
- package/CHANGELOG.md +51 -0
- package/Calendar.js +134 -134
- package/Clickable.js +131 -94
- package/CollapsiblePanel.js +175 -137
- package/ComboBox.js +32 -27
- package/ControlGroup.js +92 -91
- package/DefinitionList.js +9 -9
- package/Drawer.d.ts +2 -0
- package/Drawer.js +679 -0
- package/Dropdown.js +27 -18
- package/DualListbox.js +1 -1
- package/File.js +35 -35
- package/JSONTree.js +73 -72
- package/Link.js +2 -2
- package/MIGRATION.md +10 -0
- package/Menu.js +403 -261
- package/Modal.js +263 -252
- package/Monogram.js +2 -2
- package/Multiselect.js +551 -385
- package/Number.js +2 -1
- package/Paginator.js +14 -12
- package/Popover.js +4 -1
- package/README.md +11 -0
- package/RadioBar.js +1 -1
- package/Search.js +111 -95
- package/Select.js +42 -40
- package/SelectBase.js +819 -715
- package/SidePanel.js +346 -167
- package/SlidingPanels.js +11 -11
- package/StepBar.js +7 -7
- package/Switch.js +5 -5
- package/Table.js +116 -119
- package/Text.js +48 -48
- package/TextArea.js +7 -7
- package/TransitionOpen.js +188 -169
- package/docs-llm/Accordion.md +267 -0
- package/docs-llm/Anchor Menu.md +115 -0
- package/docs-llm/Anchor.md +54 -0
- package/docs-llm/AnimationToggle.md +254 -0
- package/docs-llm/Avatar.md +292 -0
- package/docs-llm/Badge.md +212 -0
- package/docs-llm/Breadcrumbs.md +306 -0
- package/docs-llm/Button Group.md +53 -0
- package/docs-llm/Button.md +361 -0
- package/docs-llm/Card Layout.md +286 -0
- package/docs-llm/Card.md +619 -0
- package/docs-llm/Checkbox.md +218 -0
- package/docs-llm/Chip.md +291 -0
- package/docs-llm/Clickable.md +160 -0
- package/docs-llm/Code.md +292 -0
- package/docs-llm/Collapsible Panel.md +744 -0
- package/docs-llm/Color.md +253 -0
- package/docs-llm/Column Layout.md +391 -0
- package/docs-llm/Combo Box.md +540 -0
- package/docs-llm/Control Group.md +594 -0
- package/docs-llm/Date.md +270 -0
- package/docs-llm/Definition List.md +278 -0
- package/docs-llm/Divider.md +216 -0
- package/docs-llm/Drawer.md +414 -0
- package/docs-llm/Dropdown.md +472 -0
- package/docs-llm/Dual Listbox.md +325 -0
- package/docs-llm/File.md +653 -0
- package/docs-llm/Form Rows.md +374 -0
- package/docs-llm/Heading.md +179 -0
- package/docs-llm/Image.md +109 -0
- package/docs-llm/JSON Tree.md +260 -0
- package/docs-llm/Layer.md +74 -0
- package/docs-llm/Layout.md +50 -0
- package/docs-llm/Link.md +318 -0
- package/docs-llm/List.md +189 -0
- package/docs-llm/Markdown.md +179 -0
- package/docs-llm/Menu.md +735 -0
- package/docs-llm/Message Bar.md +236 -0
- package/docs-llm/Message.md +248 -0
- package/docs-llm/Modal.md +443 -0
- package/docs-llm/Monogram.md +159 -0
- package/docs-llm/Multiselect.md +939 -0
- package/docs-llm/Notifications.md +46 -0
- package/docs-llm/Number.md +298 -0
- package/docs-llm/Paginator.md +395 -0
- package/docs-llm/Paragraph.md +148 -0
- package/docs-llm/Phone Number.md +254 -0
- package/docs-llm/Popover.md +166 -0
- package/docs-llm/Progress.md +141 -0
- package/docs-llm/Radio Bar.md +303 -0
- package/docs-llm/Radio List.md +350 -0
- package/docs-llm/Resize.md +362 -0
- package/docs-llm/Screen Reader Content.md +73 -0
- package/docs-llm/Scroll Container Context.md +155 -0
- package/docs-llm/Scroll.md +152 -0
- package/docs-llm/Search.md +381 -0
- package/docs-llm/Select.md +985 -0
- package/docs-llm/Side Panel.md +777 -0
- package/docs-llm/Slider.md +339 -0
- package/docs-llm/Sliding Panels.md +340 -0
- package/docs-llm/Split Button.md +295 -0
- package/docs-llm/Static Content.md +90 -0
- package/docs-llm/Step Bar.md +292 -0
- package/docs-llm/Switch.md +268 -0
- package/docs-llm/Tab Bar.md +439 -0
- package/docs-llm/Tab Layout.md +398 -0
- package/docs-llm/Table.md +2642 -0
- package/docs-llm/Text Area.md +253 -0
- package/docs-llm/Text.md +339 -0
- package/docs-llm/Tooltip.md +325 -0
- package/docs-llm/Transition Open.md +406 -0
- package/docs-llm/Tree.md +591 -0
- package/docs-llm/Typography.md +125 -0
- package/docs-llm/Wait Spinner.md +121 -0
- package/docs-llm/llms.txt +101 -0
- package/package.json +6 -5
- package/types/src/Box/Box.d.ts +2 -10
- package/types/src/Drawer/Body.d.ts +17 -0
- package/types/src/Drawer/Drawer.d.ts +114 -0
- package/types/src/Drawer/DrawerContext.d.ts +11 -0
- package/types/src/Drawer/Footer.d.ts +25 -0
- package/types/src/Drawer/Header.d.ts +41 -0
- package/types/src/Drawer/docs/examples/Basic.d.ts +6 -0
- package/types/src/Drawer/docs/examples/ContainerPosition.d.ts +7 -0
- package/types/src/Drawer/docs/examples/InitialFocus.d.ts +9 -0
- package/types/src/Drawer/docs/examples/InlinePosition.d.ts +7 -0
- package/types/src/Drawer/docs/examples/PagePosition.d.ts +7 -0
- package/types/src/Drawer/index.d.ts +2 -0
- package/types/src/JSONTree/JSONTree.d.ts +12 -5
- package/types/src/JSONTree/renderTreeItems.d.ts +2 -1
- package/types/src/Menu/Item.d.ts +2 -1
- package/types/src/Menu/docs/examples/SelectableCheckbox.d.ts +7 -0
- package/types/src/Modal/Modal.d.ts +1 -2
- package/types/src/Multiselect/Compact.d.ts +8 -3
- package/types/src/Multiselect/Multiselect.d.ts +8 -3
- package/types/src/Multiselect/Normal.d.ts +8 -3
- package/types/src/Multiselect/Option.d.ts +6 -3
- package/types/src/Multiselect/docs/examples/Disabled.d.ts +1 -0
- package/types/src/Select/Option.d.ts +6 -3
- package/types/src/Select/Select.d.ts +8 -5
- package/types/src/Select/docs/examples/Dimmed.d.ts +7 -0
- package/types/src/SelectBase/OptionBase.d.ts +6 -3
- package/types/src/SelectBase/SelectBase.d.ts +8 -3
- package/types/src/SidePanel/SidePanel.d.ts +43 -2
- package/types/src/SidePanel/docs/examples/DockLayout.d.ts +17 -0
- package/types/src/SidePanel/docs/examples/InitialFocus.d.ts +9 -0
- package/types/src/TransitionOpen/TransitionOpen.d.ts +29 -4
- package/types/src/useKeyPress/index.d.ts +9 -2
- package/types/src/useOnClickOutside/index.d.ts +2 -0
- package/types/src/useOnClickOutside/useOnClickOutside.d.ts +4 -0
- package/useKeyPress.js +23 -18
- package/useOnClickOutside.d.ts +2 -0
- package/useOnClickOutside.js +79 -0
- package/types/src/RadioList/docs/examples/Row.d.ts +0 -6
|
@@ -26,6 +26,12 @@ interface JSONTreePropsBase {
|
|
|
26
26
|
* The default is `false`, which expands only the first level of properties.
|
|
27
27
|
*/
|
|
28
28
|
defaultExpanded?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* If set to `true`, using `shift + click` or `shift + enter` will expand all descendant nodes
|
|
31
|
+
* of the tree at once. A tooltip is added to the expand all / collapse all button to indicate that this feature
|
|
32
|
+
* is enabled. Defaults to `true`.
|
|
33
|
+
*/
|
|
34
|
+
expandChildrenOnShiftKey?: boolean;
|
|
29
35
|
/**
|
|
30
36
|
* Number of space characters per level of indentation.
|
|
31
37
|
*/
|
|
@@ -54,17 +60,18 @@ interface JSONTreePropsBase {
|
|
|
54
60
|
*/
|
|
55
61
|
overflow?: 'wrap' | 'scroll';
|
|
56
62
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
63
|
+
* @private
|
|
64
|
+
* Controls how string values in leaf nodes are rendered.
|
|
65
|
+
* - `literal`: renders strings in quotes and respects control characters (new lines, tabs, etc.).
|
|
66
|
+
* - `stringify`: renders strings using `JSON.stringify`, which causes control characters to be escaped.
|
|
60
67
|
*/
|
|
61
|
-
|
|
68
|
+
stringRenderer?: 'literal' | 'stringify';
|
|
62
69
|
}
|
|
63
70
|
type JSONTreeProps = ComponentProps<JSONTreePropsBase, 'code'>;
|
|
64
71
|
/**
|
|
65
72
|
* Used to visualize a JSON string.
|
|
66
73
|
*/
|
|
67
|
-
declare function JSONTree({ elementRef, defaultExpanded, indent, json, onClickKey, onClickValue, overflow, expandChildrenOnShiftKey, ...otherProps }: JSONTreeProps): React.JSX.Element;
|
|
74
|
+
declare function JSONTree({ elementRef, defaultExpanded, indent, json, onClickKey, onClickValue, overflow, expandChildrenOnShiftKey, stringRenderer, ...otherProps }: JSONTreeProps): React.JSX.Element;
|
|
68
75
|
declare namespace JSONTree {
|
|
69
76
|
var propTypes: {
|
|
70
77
|
elementRef: PropTypes.Requireable<object>;
|
|
@@ -13,7 +13,8 @@ type RenderTreeItemsProps = {
|
|
|
13
13
|
overflow?: 'wrap' | 'scroll';
|
|
14
14
|
path?: (string | number)[];
|
|
15
15
|
shift?: boolean;
|
|
16
|
+
stringRenderer?: 'literal' | 'stringify';
|
|
16
17
|
updateShift: ((newShift: boolean) => void) | undefined;
|
|
17
18
|
};
|
|
18
|
-
export declare function renderTreeItems({ baseId, defaultOpen, defaultExpanded, expandChildrenOnShiftKey, indent, indentLevel, obj, onClickKey, onClickValue, overflow, path, shift, updateShift, }: RenderTreeItemsProps): React.JSX.Element | React.JSX.Element[];
|
|
19
|
+
export declare function renderTreeItems({ baseId, defaultOpen, defaultExpanded, expandChildrenOnShiftKey, indent, indentLevel, obj, onClickKey, onClickValue, overflow, path, shift, stringRenderer, updateShift, }: RenderTreeItemsProps): React.JSX.Element | React.JSX.Element[];
|
|
19
20
|
export {};
|
package/types/src/Menu/Item.d.ts
CHANGED
|
@@ -80,6 +80,7 @@ interface ItemPropsBase {
|
|
|
80
80
|
selectable?: boolean;
|
|
81
81
|
/**
|
|
82
82
|
* Specifies the type of selection control to display when `selectable` is enabled.
|
|
83
|
+
* Use `'checkmark'` for single-select menus and `'checkbox'` for multi-select menus.
|
|
83
84
|
*/
|
|
84
85
|
selectableAppearance?: 'checkmark' | 'checkbox';
|
|
85
86
|
/**
|
|
@@ -102,7 +103,7 @@ interface ItemPropsBase {
|
|
|
102
103
|
*/
|
|
103
104
|
to?: string;
|
|
104
105
|
/**
|
|
105
|
-
* When `true`, wrapping is disabled and any additional text is truncated using an ellipsis.
|
|
106
|
+
* When `true`, wrapping is disabled and any additional text is truncated using an ellipsis. A `Tooltip` will render so users can see the full text on hover.
|
|
106
107
|
*/
|
|
107
108
|
truncate?: boolean;
|
|
108
109
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* @name Selectable appearance
|
|
4
|
+
* @description A Menu.Item's selected indicator can appear as a checkmark (default) or a checkbox with the `selectableAppearance` prop. Use a checkmark when only one Item can be selected, and a checkbox when multiple can be selected.
|
|
5
|
+
*/
|
|
6
|
+
declare function SelectableCheckbox(): React.JSX.Element;
|
|
7
|
+
export default SelectableCheckbox;
|
|
@@ -21,7 +21,6 @@ interface ModalPropsBase {
|
|
|
21
21
|
*/
|
|
22
22
|
children?: React.ReactNode;
|
|
23
23
|
/**
|
|
24
|
-
* @private
|
|
25
24
|
* Set to 'true' to enable closing the Modal by clicking outside of it.
|
|
26
25
|
*
|
|
27
26
|
* This behavior should be avoided as it can lead to accidental dismissal of the modal causing data loss or disruption of a user's workflow.
|
|
@@ -50,7 +49,7 @@ interface ModalPropsBase {
|
|
|
50
49
|
* When `Modal` includes this prop, a close button is displayed by default in the `Modal.Header`.
|
|
51
50
|
* To hide the close button, pass the `hideCloseButton` prop to `Modal.Header`.
|
|
52
51
|
*
|
|
53
|
-
* The callback is passed the event and a reason, which is 'escapeKey' or 'clickCloseButton'.
|
|
52
|
+
* The callback is passed the event and a reason, which is 'escapeKey', 'clickAway', or 'clickCloseButton'.
|
|
54
53
|
*
|
|
55
54
|
* Generally, use this callback to toggle the `open` prop.
|
|
56
55
|
*/
|
|
@@ -36,8 +36,13 @@ interface CompactPropsBase {
|
|
|
36
36
|
* ControlGroup's help component.
|
|
37
37
|
*/
|
|
38
38
|
describedBy?: string;
|
|
39
|
-
/**
|
|
40
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Prevents user interaction and adds disabled styling.
|
|
41
|
+
*
|
|
42
|
+
* If set to `dimmed`, the component is able to receive focus.
|
|
43
|
+
* If set to `disabled`, the component is unable to receive focus.
|
|
44
|
+
*/
|
|
45
|
+
disabled?: boolean | 'dimmed' | 'disabled';
|
|
41
46
|
/**
|
|
42
47
|
* A React ref which is set to the DOM element when the component mounts and null when it unmounts.
|
|
43
48
|
*/
|
|
@@ -171,7 +176,7 @@ declare namespace Compact {
|
|
|
171
176
|
defaultPlacement: PropTypes.Requireable<string>;
|
|
172
177
|
defaultValues: PropTypes.Requireable<any[]>;
|
|
173
178
|
describedBy: PropTypes.Requireable<string>;
|
|
174
|
-
disabled: PropTypes.Requireable<boolean
|
|
179
|
+
disabled: PropTypes.Requireable<NonNullable<string | boolean | null | undefined>>;
|
|
175
180
|
elementRef: PropTypes.Requireable<object>;
|
|
176
181
|
error: PropTypes.Requireable<boolean>;
|
|
177
182
|
filter: PropTypes.Requireable<string | boolean>;
|
|
@@ -55,8 +55,13 @@ interface MultiselectPropsBase {
|
|
|
55
55
|
* ControlGroup's help component.
|
|
56
56
|
*/
|
|
57
57
|
describedBy?: string;
|
|
58
|
-
/**
|
|
59
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Prevents user interaction and adds disabled styling.
|
|
60
|
+
*
|
|
61
|
+
* If set to `dimmed`, the component is able to receive focus.
|
|
62
|
+
* If set to `disabled`, the component is unable to receive focus.
|
|
63
|
+
*/
|
|
64
|
+
disabled?: boolean | 'dimmed' | 'disabled';
|
|
60
65
|
/**
|
|
61
66
|
* A React ref which is set to the DOM element when the component mounts, and null when it unmounts.
|
|
62
67
|
*/
|
|
@@ -223,7 +228,7 @@ declare namespace Multiselect {
|
|
|
223
228
|
defaultPlacement: PropTypes.Requireable<string>;
|
|
224
229
|
defaultValues: PropTypes.Requireable<any[]>;
|
|
225
230
|
describedBy: PropTypes.Requireable<string>;
|
|
226
|
-
disabled: PropTypes.Requireable<boolean
|
|
231
|
+
disabled: PropTypes.Requireable<NonNullable<string | boolean | null | undefined>>;
|
|
227
232
|
elementRef: PropTypes.Requireable<object>;
|
|
228
233
|
error: PropTypes.Requireable<boolean>;
|
|
229
234
|
filter: PropTypes.Requireable<string | boolean>;
|
|
@@ -32,8 +32,13 @@ interface NormalPropsBase {
|
|
|
32
32
|
* ControlGroup's help component.
|
|
33
33
|
*/
|
|
34
34
|
describedBy?: string;
|
|
35
|
-
/**
|
|
36
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Prevents user interaction and adds disabled styling.
|
|
37
|
+
*
|
|
38
|
+
* If set to `dimmed`, the component is able to receive focus.
|
|
39
|
+
* If set to `disabled`, the component is unable to receive focus.
|
|
40
|
+
*/
|
|
41
|
+
disabled?: boolean | 'dimmed' | 'disabled';
|
|
37
42
|
/**
|
|
38
43
|
* A React ref which is set to the DOM element when the component mounts and null when it unmounts.
|
|
39
44
|
*/
|
|
@@ -138,7 +143,7 @@ declare namespace Normal {
|
|
|
138
143
|
defaultPlacement: PropTypes.Requireable<string>;
|
|
139
144
|
defaultValues: PropTypes.Requireable<any[]>;
|
|
140
145
|
describedBy: PropTypes.Requireable<string>;
|
|
141
|
-
disabled: PropTypes.Requireable<boolean
|
|
146
|
+
disabled: PropTypes.Requireable<NonNullable<string | boolean | null | undefined>>;
|
|
142
147
|
elementRef: PropTypes.Requireable<object>;
|
|
143
148
|
error: PropTypes.Requireable<boolean>;
|
|
144
149
|
footerMessage: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
@@ -26,9 +26,12 @@ interface OptionPropsBase {
|
|
|
26
26
|
*/
|
|
27
27
|
descriptionPosition?: 'right' | 'bottom';
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
29
|
+
* Prevents user interaction and adds disabled styling.
|
|
30
|
+
*
|
|
31
|
+
* If set to `dimmed`, the component is able to receive focus.
|
|
32
|
+
* If set to `disabled`, the component is unable to receive focus.
|
|
30
33
|
*/
|
|
31
|
-
disabled?: boolean;
|
|
34
|
+
disabled?: boolean | 'dimmed' | 'disabled';
|
|
32
35
|
/**
|
|
33
36
|
* @private Undocumented due to limitations in supporting in compact `Multiselect` (see SUI-8286 notes for more info).
|
|
34
37
|
* A React ref which is set to the DOM element when the component mounts, and null when it unmounts.
|
|
@@ -99,7 +102,7 @@ declare namespace Option {
|
|
|
99
102
|
compact: PropTypes.Requireable<boolean>;
|
|
100
103
|
description: PropTypes.Requireable<string>;
|
|
101
104
|
descriptionPosition: PropTypes.Requireable<string>;
|
|
102
|
-
disabled: PropTypes.Requireable<boolean
|
|
105
|
+
disabled: PropTypes.Requireable<NonNullable<string | boolean | null | undefined>>;
|
|
103
106
|
/**
|
|
104
107
|
* @private Undocumented due to limitations in supporting in compact `Multiselect` (see SUI-8286 notes for more info).
|
|
105
108
|
*/
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
/**
|
|
3
3
|
* @name Disabled
|
|
4
|
+
* @description If you absolutely need to disable a `Multiselect` use `"disabled="dimmed"`. This ensures the `Multiselect` does not respond to events, but can still receive focus to so that users can navigate to the `Multiselect` when using assistive technologies.
|
|
4
5
|
*/
|
|
5
6
|
declare function Disabled(): React.JSX.Element;
|
|
6
7
|
export default Disabled;
|
|
@@ -19,9 +19,12 @@ interface OptionPropsBase {
|
|
|
19
19
|
*/
|
|
20
20
|
descriptionPosition?: 'right' | 'bottom';
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
22
|
+
* Prevents user interaction and adds disabled styling.
|
|
23
|
+
*
|
|
24
|
+
* If set to `dimmed`, the component is able to receive focus.
|
|
25
|
+
* If set to `disabled`, the component is unable to receive focus (as a result of setting the html `disabled` attribute).
|
|
23
26
|
*/
|
|
24
|
-
disabled?: boolean;
|
|
27
|
+
disabled?: boolean | 'dimmed' | 'disabled';
|
|
25
28
|
/**
|
|
26
29
|
* A React ref which is set to the DOM element when the component mounts, and null when it unmounts.
|
|
27
30
|
*/
|
|
@@ -78,7 +81,7 @@ type OptionProps = ComponentProps<OptionPropsBase, 'button'>;
|
|
|
78
81
|
/**
|
|
79
82
|
* An option within a `Select`. Any elements passed to it should be memoized.
|
|
80
83
|
*/
|
|
81
|
-
declare function Option({ children, descriptionPosition, elementRef, label, ...otherProps }: OptionProps): React.JSX.Element;
|
|
84
|
+
declare function Option({ children, descriptionPosition, disabled, elementRef, label, ...otherProps }: OptionProps): React.JSX.Element;
|
|
82
85
|
declare const OptionMemoized: React.MemoExoticComponent<typeof Option>;
|
|
83
86
|
export default OptionMemoized;
|
|
84
87
|
export type { OptionBaseClickHandler, OptionPropsBase };
|
|
@@ -55,9 +55,12 @@ interface SelectPropsBase {
|
|
|
55
55
|
*/
|
|
56
56
|
describedBy?: string;
|
|
57
57
|
/**
|
|
58
|
-
* disabled
|
|
58
|
+
* Prevents user interaction and adds disabled styling.
|
|
59
|
+
*
|
|
60
|
+
* If set to `dimmed`, the component is able to receive focus.
|
|
61
|
+
* If set to `disabled`, the component is unable to receive focus (as a result of setting the html `disabled` attribute).
|
|
59
62
|
*/
|
|
60
|
-
disabled?: boolean;
|
|
63
|
+
disabled?: boolean | 'dimmed' | 'disabled';
|
|
61
64
|
/**
|
|
62
65
|
* A React ref which is set to the DOM element when the component mounts, and null when it unmounts.
|
|
63
66
|
*/
|
|
@@ -187,7 +190,7 @@ interface SelectPropsBaseUncontrolled extends SelectPropsBase {
|
|
|
187
190
|
value?: never;
|
|
188
191
|
}
|
|
189
192
|
type SelectProps = ComponentProps<SelectPropsBaseControlled | SelectPropsBaseUncontrolled, 'button'>;
|
|
190
|
-
declare function Select({ allowKeyMatching, appearance, defaultPlacement, defaultValue, inline, noOptionsMessage, onChange, placeholder, toggleContent, value, ...otherProps }: SelectProps): React.JSX.Element;
|
|
193
|
+
declare function Select({ allowKeyMatching, appearance, defaultPlacement, defaultValue, disabled, inline, noOptionsMessage, onChange, placeholder, toggleContent, value, ...otherProps }: SelectProps): React.JSX.Element;
|
|
191
194
|
declare namespace Select {
|
|
192
195
|
var propTypes: {
|
|
193
196
|
allowKeyMatching: PropTypes.Requireable<boolean>;
|
|
@@ -198,7 +201,7 @@ declare namespace Select {
|
|
|
198
201
|
defaultPlacement: PropTypes.Requireable<string>;
|
|
199
202
|
defaultValue: PropTypes.Requireable<NonNullable<string | number | boolean | null | undefined>>;
|
|
200
203
|
describedBy: PropTypes.Requireable<string>;
|
|
201
|
-
disabled: PropTypes.Requireable<boolean
|
|
204
|
+
disabled: PropTypes.Requireable<NonNullable<string | boolean | null | undefined>>;
|
|
202
205
|
elementRef: PropTypes.Requireable<object>;
|
|
203
206
|
error: PropTypes.Requireable<boolean>;
|
|
204
207
|
filter: PropTypes.Requireable<string | boolean>;
|
|
@@ -231,7 +234,7 @@ declare namespace Select {
|
|
|
231
234
|
/** @private. */
|
|
232
235
|
virtualization: PropTypes.Requireable<number>;
|
|
233
236
|
};
|
|
234
|
-
var Option: React.MemoExoticComponent<({ children, descriptionPosition, elementRef, label, ...otherProps }: import("./Option").OptionPropsBase & Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref" | "css" | keyof import("./Option").OptionPropsBase>) => React.JSX.Element>;
|
|
237
|
+
var Option: React.MemoExoticComponent<({ children, descriptionPosition, disabled, elementRef, label, ...otherProps }: import("./Option").OptionPropsBase & Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref" | "css" | keyof import("./Option").OptionPropsBase>) => React.JSX.Element>;
|
|
235
238
|
var Heading: typeof BaseHeading;
|
|
236
239
|
var Divider: typeof BaseDivider;
|
|
237
240
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* @name Dimmed
|
|
4
|
+
* @description If you absolutely need to disable a Select use a dimmed Select. When the disabled prop is set to "dimmed", the Select does not respond to events but can still receive focus to ensure users can navigate to the Select when using assistive technologies. This also sets aria-disabled to true.
|
|
5
|
+
*/
|
|
6
|
+
declare function Dimmed(): React.JSX.Element;
|
|
7
|
+
export default Dimmed;
|
|
@@ -23,9 +23,12 @@ interface OptionPropsBase {
|
|
|
23
23
|
*/
|
|
24
24
|
descriptionPosition?: 'right' | 'bottom';
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* Prevents user interaction and adds disabled styling.
|
|
27
|
+
*
|
|
28
|
+
* If set to `dimmed`, the component is able to receive focus.
|
|
29
|
+
* If set to `disabled`, the component is unable to receive focus (as a result of setting the html `disabled` attribute).
|
|
27
30
|
*/
|
|
28
|
-
disabled?: boolean;
|
|
31
|
+
disabled?: boolean | 'dimmed' | 'disabled';
|
|
29
32
|
/**
|
|
30
33
|
* A React ref which is set to the DOM element when the component mounts, and null when it unmounts.
|
|
31
34
|
*/
|
|
@@ -94,7 +97,7 @@ declare namespace Option {
|
|
|
94
97
|
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
95
98
|
description: PropTypes.Requireable<string>;
|
|
96
99
|
descriptionPosition: PropTypes.Requireable<string>;
|
|
97
|
-
disabled: PropTypes.Requireable<boolean
|
|
100
|
+
disabled: PropTypes.Requireable<NonNullable<string | boolean | null | undefined>>;
|
|
98
101
|
elementRef: PropTypes.Requireable<object>;
|
|
99
102
|
endAdornment: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
100
103
|
hidden: PropTypes.Requireable<boolean>;
|
|
@@ -54,8 +54,13 @@ interface SelectBasePropsBase {
|
|
|
54
54
|
* ControlGroup's help component.
|
|
55
55
|
*/
|
|
56
56
|
describedBy?: string;
|
|
57
|
-
/**
|
|
58
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Prevents user interaction and adds disabled styling.
|
|
59
|
+
*
|
|
60
|
+
* If set to `dimmed`, the component is able to receive focus.
|
|
61
|
+
* If set to `disabled`, the component is unable to receive focus.
|
|
62
|
+
*/
|
|
63
|
+
disabled?: boolean | 'dimmed' | 'disabled';
|
|
59
64
|
/**
|
|
60
65
|
* A React ref which is set to the DOM element when the component mounts and null when it unmounts.
|
|
61
66
|
*/
|
|
@@ -248,7 +253,7 @@ declare namespace SelectBase {
|
|
|
248
253
|
defaultPlacement: PropTypes.Requireable<string>;
|
|
249
254
|
defaultValues: PropTypes.Requireable<any[]>;
|
|
250
255
|
describedBy: PropTypes.Requireable<string>;
|
|
251
|
-
disabled: PropTypes.Requireable<boolean
|
|
256
|
+
disabled: PropTypes.Requireable<NonNullable<string | boolean | null | undefined>>;
|
|
252
257
|
elementRef: PropTypes.Requireable<object>;
|
|
253
258
|
error: PropTypes.Requireable<boolean>;
|
|
254
259
|
filter: PropTypes.Requireable<string | boolean>;
|
|
@@ -7,8 +7,18 @@ type SidePanelRequestCloseHandler = (data: {
|
|
|
7
7
|
event: React.MouseEvent<HTMLDivElement> | MouseEvent | KeyboardEvent | TouchEvent;
|
|
8
8
|
reason: 'clickAway' | 'escapeKey';
|
|
9
9
|
}) => void;
|
|
10
|
+
type SidePanelInitialFocus = 'first' | 'container' | (React.Component & {
|
|
11
|
+
focus: () => void;
|
|
12
|
+
}) | HTMLElement | null;
|
|
10
13
|
interface SidePanelPropsBase extends TransitionOpenPropsBase {
|
|
11
14
|
children?: React.ReactNode;
|
|
15
|
+
/**
|
|
16
|
+
* The layout mode for the panel.
|
|
17
|
+
* - page: Positions relative to the viewport (default)
|
|
18
|
+
* - container: Positions relative to nearest positioned ancestor
|
|
19
|
+
* - inline: Renders inline allowing content to reflow around the panel
|
|
20
|
+
*/
|
|
21
|
+
dockLayout?: 'page' | 'container' | 'inline';
|
|
12
22
|
/**
|
|
13
23
|
* The position of the Panel on the screen.
|
|
14
24
|
*/
|
|
@@ -17,6 +27,12 @@ interface SidePanelPropsBase extends TransitionOpenPropsBase {
|
|
|
17
27
|
* A React ref which is set to the DOM element when the component mounts and null when it unmounts.
|
|
18
28
|
*/
|
|
19
29
|
elementRef?: React.Ref<HTMLDivElement>;
|
|
30
|
+
/**
|
|
31
|
+
* Allows focus to be set to a component other than the default.
|
|
32
|
+
* Supports `'first'` (first focusable element), `'container'` (the panel itself), or a ref.
|
|
33
|
+
* Note: Panel should be in view on open.
|
|
34
|
+
*/
|
|
35
|
+
initialFocus?: SidePanelInitialFocus;
|
|
20
36
|
/**
|
|
21
37
|
* The inner element can control the width of the side bar when placed left or right and
|
|
22
38
|
* the height when placed top or bottom.
|
|
@@ -32,6 +48,9 @@ interface SidePanelPropsBase extends TransitionOpenPropsBase {
|
|
|
32
48
|
*/
|
|
33
49
|
onAnimationEnd?: () => void;
|
|
34
50
|
/**
|
|
51
|
+
* Only applies to dockLayout=page because other dockLayout modes do not support
|
|
52
|
+
* closing via the escape key or click away.
|
|
53
|
+
*
|
|
35
54
|
* A function that is called when a close event occurs. The callback is passed a
|
|
36
55
|
* reason and the event.
|
|
37
56
|
*
|
|
@@ -59,18 +78,39 @@ interface SidePanelPropsBase extends TransitionOpenPropsBase {
|
|
|
59
78
|
*/
|
|
60
79
|
outerStyle?: React.CSSProperties;
|
|
61
80
|
/**
|
|
81
|
+
* Pass the ref of the invoking element (or other element that follows the logical flow of the application) to automatically move focus
|
|
82
|
+
* to the invoking element on SidePanel close. If using a ref is not possible, you can pass a function that sets focus to the appropriate element.
|
|
83
|
+
* This function will be called when the panel closes.
|
|
84
|
+
*/
|
|
85
|
+
returnFocus?: React.MutableRefObject<(React.Component & {
|
|
86
|
+
focus: () => void;
|
|
87
|
+
}) | HTMLElement | null> | (() => void);
|
|
88
|
+
/**
|
|
89
|
+
* Only applies to dockLayout=page because other dockLayout modes do not support
|
|
90
|
+
* closing via click away.
|
|
91
|
+
*
|
|
62
92
|
* Indicates whether to add an overlay mask on the whole page, blocking other interactions
|
|
63
93
|
* while the Panel is open.
|
|
64
94
|
*/
|
|
65
95
|
useLayerForClickAway?: boolean;
|
|
66
96
|
}
|
|
67
|
-
|
|
68
|
-
|
|
97
|
+
interface SidePanelPageLayoutProps extends SidePanelPropsBase {
|
|
98
|
+
dockLayout?: 'page';
|
|
99
|
+
}
|
|
100
|
+
interface SidePanelNonPageLayoutProps extends SidePanelPropsBase {
|
|
101
|
+
dockLayout: 'container' | 'inline';
|
|
102
|
+
onRequestClose?: never;
|
|
103
|
+
useLayerForClickAway?: never;
|
|
104
|
+
}
|
|
105
|
+
type SidePanelProps = ComponentProps<SidePanelPageLayoutProps | SidePanelNonPageLayoutProps, 'div'>;
|
|
106
|
+
declare function SidePanel({ children, dockLayout, dockPosition, elementRef, initialFocus, innerClassName, innerStyle, onAnimationEnd, onRequestClose, open, outerClassName, outerStyle, returnFocus, useLayerForClickAway, ...otherProps }: SidePanelProps): React.JSX.Element;
|
|
69
107
|
declare namespace SidePanel {
|
|
70
108
|
var propTypes: {
|
|
71
109
|
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
110
|
+
dockLayout: PropTypes.Requireable<string>;
|
|
72
111
|
dockPosition: PropTypes.Requireable<string>;
|
|
73
112
|
elementRef: PropTypes.Requireable<object>;
|
|
113
|
+
initialFocus: PropTypes.Requireable<NonNullable<string | object | null | undefined>>;
|
|
74
114
|
innerClassName: PropTypes.Requireable<string>;
|
|
75
115
|
innerStyle: PropTypes.Requireable<object>;
|
|
76
116
|
onAnimationEnd: PropTypes.Requireable<(...args: any[]) => any>;
|
|
@@ -78,6 +118,7 @@ declare namespace SidePanel {
|
|
|
78
118
|
open: PropTypes.Requireable<boolean>;
|
|
79
119
|
outerClassName: PropTypes.Requireable<string>;
|
|
80
120
|
outerStyle: PropTypes.Requireable<object>;
|
|
121
|
+
returnFocus: PropTypes.Requireable<object>;
|
|
81
122
|
useLayerForClickAway: PropTypes.Requireable<boolean>;
|
|
82
123
|
};
|
|
83
124
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* @name Dock Layout
|
|
4
|
+
* @description The `dockLayout` prop controls how the panel is positioned:
|
|
5
|
+
*
|
|
6
|
+
* - **page**
|
|
7
|
+
* - Positions relative to the viewport.
|
|
8
|
+
* - Overlays all content.
|
|
9
|
+
* - **container**
|
|
10
|
+
* - Positions relative to the nearest positioned ancestor.
|
|
11
|
+
* - Overlays content within that container.
|
|
12
|
+
* - **inline**
|
|
13
|
+
* - Renders inline in the document flow.
|
|
14
|
+
* - Pushes adjacent content aside when opened.
|
|
15
|
+
*/
|
|
16
|
+
declare function DockLayout(): React.JSX.Element;
|
|
17
|
+
export default DockLayout;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* @name Initial focus
|
|
4
|
+
* @description Initial focus can be set to a different element using the `initialFocus` prop.
|
|
5
|
+
* Use `'first'` to focus the first focusable element, `'container'` to focus the panel itself,
|
|
6
|
+
* or pass a ref to a specific element.
|
|
7
|
+
*/
|
|
8
|
+
declare function InitialFocus(): React.JSX.Element;
|
|
9
|
+
export default InitialFocus;
|
|
@@ -1,8 +1,27 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { ComponentProps } from '../utils/types';
|
|
4
|
+
/** @public */
|
|
5
|
+
type AnimationType = 'slideFromTop' | 'slideFromRight' | 'slideFromBottom' | 'slideFromLeft' | 'expandHeight' | 'expandWidth' | 'none';
|
|
6
|
+
/** @public */
|
|
7
|
+
type AnimationOnOpen = {
|
|
8
|
+
open: AnimationType;
|
|
9
|
+
close: 'none';
|
|
10
|
+
};
|
|
11
|
+
/** @public */
|
|
12
|
+
type AnimationOnClose = {
|
|
13
|
+
open: 'none';
|
|
14
|
+
close: AnimationType;
|
|
15
|
+
};
|
|
16
|
+
type AnimationProp = AnimationType | AnimationOnOpen | AnimationOnClose;
|
|
4
17
|
interface TransitionOpenPropsBase {
|
|
5
|
-
|
|
18
|
+
/**
|
|
19
|
+
* The animation to use when opening and closing. Can be:
|
|
20
|
+
* - A string (e.g., 'expandHeight') to animate both open and close
|
|
21
|
+
* - An object with `{ open: AnimationType, close: 'none' }` to animate only when opening
|
|
22
|
+
* - An object with `{ open: 'none', close: AnimationType }` to animate only when closing
|
|
23
|
+
*/
|
|
24
|
+
animation?: AnimationProp;
|
|
6
25
|
animateOnMount?: boolean;
|
|
7
26
|
children?: React.ReactNode;
|
|
8
27
|
/** @private */
|
|
@@ -39,10 +58,16 @@ interface TransitionOpenPropsBase {
|
|
|
39
58
|
takeFocus?: boolean;
|
|
40
59
|
}
|
|
41
60
|
type TransitionOpenProps = ComponentProps<TransitionOpenPropsBase, 'div'>;
|
|
42
|
-
declare function TransitionOpen({ animation, animateOnMount, children, className, elementRef, id, innerClassName, innerStyle, onAnimationEnd, onAnimationStart, open: openProp, outerClassName, outerId, outerStyle, renderChildrenWhenCollapsed, retainFocus, takeFocus: takeFocusProp, ...otherProps }: TransitionOpenProps): React.JSX.Element;
|
|
61
|
+
declare function TransitionOpen({ animation: animationProp, animateOnMount, children, className, elementRef, id, innerClassName, innerStyle, onAnimationEnd, onAnimationStart, open: openProp, outerClassName, outerId, outerStyle, renderChildrenWhenCollapsed, retainFocus, takeFocus: takeFocusProp, ...otherProps }: TransitionOpenProps): React.JSX.Element;
|
|
43
62
|
declare namespace TransitionOpen {
|
|
44
63
|
var propTypes: {
|
|
45
|
-
animation: PropTypes.Requireable<
|
|
64
|
+
animation: PropTypes.Requireable<NonNullable<AnimationType | PropTypes.InferProps<{
|
|
65
|
+
open: PropTypes.Validator<NonNullable<AnimationType>>;
|
|
66
|
+
close: PropTypes.Validator<string>;
|
|
67
|
+
}> | PropTypes.InferProps<{
|
|
68
|
+
open: PropTypes.Validator<string>;
|
|
69
|
+
close: PropTypes.Validator<NonNullable<AnimationType>>;
|
|
70
|
+
}> | null | undefined>>;
|
|
46
71
|
animateOnMount: PropTypes.Requireable<boolean>;
|
|
47
72
|
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
48
73
|
elementRef: PropTypes.Requireable<object>;
|
|
@@ -62,4 +87,4 @@ declare namespace TransitionOpen {
|
|
|
62
87
|
};
|
|
63
88
|
}
|
|
64
89
|
export default TransitionOpen;
|
|
65
|
-
export { TransitionOpenPropsBase };
|
|
90
|
+
export { AnimationType, AnimationOnOpen, AnimationOnClose, TransitionOpenPropsBase };
|
|
@@ -28,10 +28,17 @@
|
|
|
28
28
|
*
|
|
29
29
|
* @param {String} targetKey - The key value to listen to.
|
|
30
30
|
* @param {Function} handler - A function invoked when the target key is pressed.
|
|
31
|
+
* @param {Object} [options] - An options object.
|
|
32
|
+
* @param {Boolean} [options.enabled=true] - Whether to enable the key listener.
|
|
33
|
+
* @param {String} [options.eventType='keyup'] - The keyboard event type to listen to.
|
|
31
34
|
* @public
|
|
32
35
|
*/
|
|
33
36
|
type KeyboardEventKeys = 'Unidentified' | 'Alt' | 'AltGraph' | 'CapsLock' | 'Control' | 'Fn' | 'FnLock' | 'Hyper' | 'Meta' | 'NumLock' | 'ScrollLock' | 'Shift' | 'Super' | 'Symbol' | 'SymbolLock' | 'Enter' | 'Tab' | ' ' | 'ArrowDown' | 'ArrowLeft' | 'ArrowRight' | 'ArrowUp' | 'End' | 'Home' | 'PageDown' | 'PageUp' | 'Backspace' | 'Clear' | 'Copy' | 'CrSel' | 'Cut' | 'Delete' | 'EraseEof' | 'ExSel' | 'Insert' | 'Paste' | 'Redo' | 'Undo' | 'Accept' | 'Again' | 'Attn' | 'Cancel' | 'ContextMenu' | 'Escape' | 'Execute' | 'Find' | 'Finish' | 'Help' | 'Pause' | 'Play' | 'Props' | 'Select' | 'ZoomIn' | 'ZoomOut' | 'BrightnessDown' | 'BrightnessUp' | 'Eject' | 'LogOff' | 'Power' | 'PowerOff' | 'PrintScreen' | 'Hibernate' | 'Standby' | 'WakeUp' | 'AllCandidates' | 'Alphanumeric' | 'CodeInput' | 'Compose' | 'Convert' | 'Dead' | 'FinalMode' | 'GroupFirst' | 'GroupLast' | 'GroupNext' | 'GroupPrevious' | 'ModeChange' | 'NextCandidate' | 'NonConvert' | 'PreviousCandidate' | 'Process' | 'SingleCandidate' | 'HangulMode' | 'HanjaMode' | 'JunjaMode' | 'Eisu' | 'Hankaku' | 'Hiragana' | 'HiraganaKatakana' | 'KanaMode' | 'KanjiMode' | 'Katakana' | 'Romaji' | 'Zenkaku' | 'ZenkakuHanaku' | 'F1' | 'F2' | 'F3' | 'F4' | 'F5' | 'F6' | 'F7' | 'F8' | 'F9' | 'F10' | 'F11' | 'F12' | 'F13' | 'F14' | 'F15' | 'F16' | 'F17' | 'F18' | 'F19' | 'F20' | 'Soft1' | 'Soft2' | 'Soft3' | 'Soft4' | 'AppSwitch' | 'Call' | 'Camera' | 'CameraFocus' | 'EndCall' | 'GoBack' | 'GoHome' | 'HeadsetHook' | 'LastNumberRedial' | 'Notification' | 'MannerMode' | 'VoiceDial' | 'ChannelDown' | 'ChannelUp' | 'MediaFastForward' | 'MediaPause' | 'MediaPlay' | 'MediaPlayPause' | 'MediaRecord' | 'MediaRewind' | 'MediaStop' | 'MediaTrackNext' | 'MediaTrackPrevious' | 'AudioBalanceLeft' | 'AudioBalanceRight' | 'AudioBassDown' | 'AudioBassBoostDown' | 'AudioBassBoostToggle' | 'AudioBassBoostUp' | 'AudioBassUp' | 'AudioFaderFront' | 'AudioFaderRear' | 'AudioSurroundModeNext' | 'AudioTrebleDown' | 'AudioTrebleUp' | 'AudioVolumeDown' | 'AudioVolumeMute' | 'AudioVolumeUp' | 'MicrophoneToggle' | 'MicrophoneVolumeDown' | 'MicrophoneVolumeMute' | 'MicrophoneVolumeUp' | 'TV' | 'TV3DMode' | 'TVAntennaCable' | 'TVAudioDescription' | 'TVAudioDescriptionMixDown' | 'TVAudioDescriptionMixUp' | 'TVContentsMenu' | 'TVDataService' | 'TVInput' | 'TVInputComponent1' | 'TVInputComponent2' | 'TVInputComposite1' | 'TVInputComposite2' | 'TVInputHDMI1' | 'TVInputHDMI2' | 'TVInputHDMI3' | 'TVInputHDMI4' | 'TVInputVGA1' | 'TVMediaContext' | 'TVNetwork' | 'TVNumberEntry' | 'TVPower' | 'TVRadioService' | 'TVSatellite' | 'TVSatelliteBS' | 'TVSatelliteCS' | 'TVSatelliteToggle' | 'TVTerrestrialAnalog' | 'TVTerrestrialDigital' | 'TVTimer' | 'AVRInput' | 'AVRPower' | 'ColorF0Red' | 'ColorF1Green' | 'ColorF2Yellow' | 'ColorF3Blue' | 'ColorF4Grey' | 'ColorF5Brown' | 'ClosedCaptionToggle' | 'Dimmer' | 'DisplaySwap' | 'DVR' | 'Exit' | 'FavoriteClear0' | 'FavoriteClear1' | 'FavoriteClear2' | 'FavoriteClear3' | 'FavoriteRecall0' | 'FavoriteRecall1' | 'FavoriteRecall2' | 'FavoriteRecall3' | 'FavoriteStore0' | 'FavoriteStore1' | 'FavoriteStore2' | 'FavoriteStore3' | 'Guide' | 'GuideNextDay' | 'GuidePreviousDay' | 'Info' | 'InstantReplay' | 'Link' | 'ListProgram' | 'LiveContent' | 'Lock' | 'MediaApps' | 'MediaAudioTrack' | 'MediaLast' | 'MediaSkipBackward' | 'MediaSkipForward' | 'MediaStepBackward' | 'MediaStepForward' | 'MediaTopMenu' | 'NavigateIn' | 'NavigateNext' | 'NavigateOut' | 'NavigatePrevious' | 'NextFavoriteChannel' | 'NextUserProfile' | 'OnDemand' | 'Pairing' | 'PinPDown' | 'PinPMove' | 'PinPToggle' | 'PinPUp' | 'PlaySpeedDown' | 'PlaySpeedReset' | 'PlaySpeedUp' | 'RandomToggle' | 'RcLowBattery' | 'RecordSpeedNext' | 'RfBypass' | 'ScanChannelsToggle' | 'ScreenModeNext' | 'Settings' | 'SplitScreenToggle' | 'STBInput' | 'STBPower' | 'Subtitle' | 'Teletext' | 'VideoModeNext' | 'Wink' | 'ZoomToggle' | 'SpeechCorrectionList' | 'SpeechInputToggle' | 'Close' | 'New' | 'Open' | 'Print' | 'Save' | 'SpellCheck' | 'MailForward' | 'MailReply' | 'MailSend' | 'LaunchCalculator' | 'LaunchCalendar' | 'LaunchContacts' | 'LaunchMail' | 'LaunchMediaPlayer' | 'LaunchMusicPlayer' | 'LaunchMyComputer' | 'LaunchPhone' | 'LaunchScreenSaver' | 'LaunchSpreadsheet' | 'LaunchWebBrowser' | 'LaunchWebCam' | 'LaunchWordProcessor' | 'LaunchApplication1' | 'LaunchApplication2' | 'LaunchApplication3' | 'LaunchApplication4' | 'LaunchApplication5' | 'LaunchApplication6' | 'LaunchApplication7' | 'LaunchApplication8' | 'LaunchApplication9' | 'LaunchApplication10' | 'LaunchApplication11' | 'LaunchApplication12' | 'LaunchApplication13' | 'LaunchApplication14' | 'LaunchApplication15' | 'LaunchApplication16' | 'BrowserBack' | 'BrowserFavorites' | 'BrowserForward' | 'BrowserHome' | 'BrowserRefresh' | 'BrowserSearch' | 'BrowserStop' | 'Decimal' | 'Key11' | 'Key12' | 'Multiply' | 'Add' | 'Clear' | 'Divide' | 'Subtract' | 'Separator' | '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';
|
|
34
37
|
type Handler = (event: Event) => void;
|
|
35
|
-
|
|
38
|
+
interface UseKeyPressOptions {
|
|
39
|
+
enabled?: boolean;
|
|
40
|
+
eventType?: 'keydown' | 'keyup';
|
|
41
|
+
}
|
|
42
|
+
export declare function useKeyPress(targetKey: KeyboardEventKeys, handler: Handler, options?: UseKeyPressOptions): void;
|
|
36
43
|
export default useKeyPress;
|
|
37
|
-
export { Handler, KeyboardEventKeys };
|
|
44
|
+
export { Handler, KeyboardEventKeys, UseKeyPressOptions };
|
package/useKeyPress.js
CHANGED
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
/******/ /* webpack/runtime/define property getters */
|
|
9
9
|
/******/ (() => {
|
|
10
10
|
/******/ // define getter functions for harmony exports
|
|
11
|
-
/******/ e.d = (t,
|
|
12
|
-
/******/ for (var
|
|
13
|
-
/******/ if (e.o(
|
|
14
|
-
/******/ Object.defineProperty(t,
|
|
11
|
+
/******/ e.d = (t, n) => {
|
|
12
|
+
/******/ for (var r in n) {
|
|
13
|
+
/******/ if (e.o(n, r) && !e.o(t, r)) {
|
|
14
|
+
/******/ Object.defineProperty(t, r, {
|
|
15
15
|
enumerable: true,
|
|
16
|
-
get: r
|
|
16
|
+
get: n[r]
|
|
17
17
|
});
|
|
18
18
|
/******/ }
|
|
19
19
|
/******/ }
|
|
@@ -47,10 +47,10 @@
|
|
|
47
47
|
// EXPORTS
|
|
48
48
|
e.d(t, {
|
|
49
49
|
default: () => /* binding */ o,
|
|
50
|
-
useKeyPress: () => /* binding */
|
|
50
|
+
useKeyPress: () => /* binding */ r
|
|
51
51
|
});
|
|
52
52
|
// CONCATENATED MODULE: external "react"
|
|
53
|
-
const
|
|
53
|
+
const n = require("react");
|
|
54
54
|
// CONCATENATED MODULE: ./src/useKeyPress/index.ts
|
|
55
55
|
/**
|
|
56
56
|
* TargetKey is any key available via event.key: [https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key).
|
|
@@ -82,25 +82,30 @@
|
|
|
82
82
|
*
|
|
83
83
|
* @param {String} targetKey - The key value to listen to.
|
|
84
84
|
* @param {Function} handler - A function invoked when the target key is pressed.
|
|
85
|
+
* @param {Object} [options] - An options object.
|
|
86
|
+
* @param {Boolean} [options.enabled=true] - Whether to enable the key listener.
|
|
87
|
+
* @param {String} [options.eventType='keyup'] - The keyboard event type to listen to.
|
|
85
88
|
* @public
|
|
86
89
|
*/
|
|
87
|
-
function
|
|
88
|
-
var
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
function r(e, t) {
|
|
91
|
+
var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
92
|
+
var o = r.enabled, i = o === void 0 ? true : o, u = r.eventType, d = u === void 0 ? "keyup" : u;
|
|
93
|
+
var f = (0, n.useCallback)((function(n) {
|
|
94
|
+
if (n.key === e) {
|
|
95
|
+
t(n);
|
|
96
|
+
n.preventDefault();
|
|
92
97
|
}
|
|
93
98
|
}), [ t, e ]);
|
|
94
99
|
// eslint-disable-next-line consistent-return
|
|
95
|
-
(0,
|
|
96
|
-
if (typeof window !== "undefined") {
|
|
97
|
-
window.addEventListener(
|
|
100
|
+
(0, n.useEffect)((function() {
|
|
101
|
+
if (typeof window !== "undefined" && i) {
|
|
102
|
+
window.addEventListener(d, f);
|
|
98
103
|
return function() {
|
|
99
|
-
window.removeEventListener(
|
|
104
|
+
window.removeEventListener(d, f);
|
|
100
105
|
};
|
|
101
106
|
}
|
|
102
|
-
}), [
|
|
107
|
+
}), [ i, d, f ]);
|
|
103
108
|
}
|
|
104
|
-
/* harmony default export */ const o =
|
|
109
|
+
/* harmony default export */ const o = r;
|
|
105
110
|
module.exports = t;
|
|
106
111
|
/******/})();
|