@splunk/react-ui 5.7.1 → 5.8.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.
Files changed (138) hide show
  1. package/Accordion.js +6 -6
  2. package/Box.js +83 -34
  3. package/CHANGELOG.md +29 -0
  4. package/CollapsiblePanel.js +11 -11
  5. package/ComboBox.js +31 -27
  6. package/ControlGroup.js +92 -91
  7. package/DefinitionList.js +9 -9
  8. package/Drawer.d.ts +2 -0
  9. package/Drawer.js +679 -0
  10. package/DualListbox.js +1 -1
  11. package/JSONTree.js +73 -72
  12. package/Link.js +2 -2
  13. package/MIGRATION.md +10 -0
  14. package/Menu.js +338 -240
  15. package/Modal.js +127 -109
  16. package/Multiselect.js +437 -351
  17. package/Paginator.js +14 -12
  18. package/Popover.js +4 -1
  19. package/README.md +11 -0
  20. package/RadioBar.js +1 -1
  21. package/Search.js +103 -88
  22. package/Select.js +42 -40
  23. package/SelectBase.js +374 -328
  24. package/SidePanel.js +346 -167
  25. package/SlidingPanels.js +11 -11
  26. package/StepBar.js +7 -7
  27. package/Switch.js +5 -5
  28. package/Text.js +24 -24
  29. package/TextArea.js +7 -7
  30. package/TransitionOpen.js +188 -169
  31. package/docs-llm/Accordion.md +267 -0
  32. package/docs-llm/Anchor Menu.md +115 -0
  33. package/docs-llm/Anchor.md +54 -0
  34. package/docs-llm/AnimationToggle.md +254 -0
  35. package/docs-llm/Avatar.md +298 -0
  36. package/docs-llm/Badge.md +212 -0
  37. package/docs-llm/Breadcrumbs.md +306 -0
  38. package/docs-llm/Button Group.md +53 -0
  39. package/docs-llm/Button.md +361 -0
  40. package/docs-llm/Card Layout.md +286 -0
  41. package/docs-llm/Card.md +619 -0
  42. package/docs-llm/Checkbox.md +218 -0
  43. package/docs-llm/Chip.md +291 -0
  44. package/docs-llm/Clickable.md +160 -0
  45. package/docs-llm/Code.md +292 -0
  46. package/docs-llm/Collapsible Panel.md +744 -0
  47. package/docs-llm/Color.md +253 -0
  48. package/docs-llm/Column Layout.md +391 -0
  49. package/docs-llm/Combo Box.md +540 -0
  50. package/docs-llm/Control Group.md +594 -0
  51. package/docs-llm/Date.md +270 -0
  52. package/docs-llm/Definition List.md +278 -0
  53. package/docs-llm/Divider.md +216 -0
  54. package/docs-llm/Drawer.md +414 -0
  55. package/docs-llm/Dropdown.md +472 -0
  56. package/docs-llm/Dual Listbox.md +325 -0
  57. package/docs-llm/File.md +653 -0
  58. package/docs-llm/Form Rows.md +374 -0
  59. package/docs-llm/Heading.md +179 -0
  60. package/docs-llm/Image.md +109 -0
  61. package/docs-llm/JSON Tree.md +260 -0
  62. package/docs-llm/Layer.md +74 -0
  63. package/docs-llm/Layout.md +50 -0
  64. package/docs-llm/Link.md +318 -0
  65. package/docs-llm/List.md +189 -0
  66. package/docs-llm/Markdown.md +179 -0
  67. package/docs-llm/Menu.md +735 -0
  68. package/docs-llm/Message Bar.md +236 -0
  69. package/docs-llm/Message.md +248 -0
  70. package/docs-llm/Modal.md +443 -0
  71. package/docs-llm/Monogram.md +159 -0
  72. package/docs-llm/Multiselect.md +937 -0
  73. package/docs-llm/Number.md +298 -0
  74. package/docs-llm/Paginator.md +395 -0
  75. package/docs-llm/Paragraph.md +148 -0
  76. package/docs-llm/Phone Number.md +254 -0
  77. package/docs-llm/Popover.md +166 -0
  78. package/docs-llm/Progress.md +141 -0
  79. package/docs-llm/Radio Bar.md +303 -0
  80. package/docs-llm/Radio List.md +350 -0
  81. package/docs-llm/Resize.md +362 -0
  82. package/docs-llm/Screen Reader Content.md +73 -0
  83. package/docs-llm/Scroll Container Context.md +155 -0
  84. package/docs-llm/Scroll.md +152 -0
  85. package/docs-llm/Search.md +381 -0
  86. package/docs-llm/Select.md +985 -0
  87. package/docs-llm/Side Panel.md +777 -0
  88. package/docs-llm/Slider.md +339 -0
  89. package/docs-llm/Sliding Panels.md +340 -0
  90. package/docs-llm/Split Button.md +295 -0
  91. package/docs-llm/Static Content.md +90 -0
  92. package/docs-llm/Step Bar.md +292 -0
  93. package/docs-llm/Switch.md +268 -0
  94. package/docs-llm/Tab Bar.md +439 -0
  95. package/docs-llm/Tab Layout.md +398 -0
  96. package/docs-llm/Table.md +2642 -0
  97. package/docs-llm/Text Area.md +253 -0
  98. package/docs-llm/Text.md +339 -0
  99. package/docs-llm/Tooltip.md +325 -0
  100. package/docs-llm/Transition Open.md +406 -0
  101. package/docs-llm/Tree.md +586 -0
  102. package/docs-llm/Typography.md +125 -0
  103. package/docs-llm/Wait Spinner.md +121 -0
  104. package/docs-llm/llms.txt +97 -0
  105. package/package.json +6 -5
  106. package/types/src/Box/Box.d.ts +2 -10
  107. package/types/src/Drawer/Body.d.ts +17 -0
  108. package/types/src/Drawer/Drawer.d.ts +114 -0
  109. package/types/src/Drawer/DrawerContext.d.ts +11 -0
  110. package/types/src/Drawer/Footer.d.ts +25 -0
  111. package/types/src/Drawer/Header.d.ts +41 -0
  112. package/types/src/Drawer/docs/examples/Basic.d.ts +6 -0
  113. package/types/src/Drawer/docs/examples/ContainerPosition.d.ts +7 -0
  114. package/types/src/Drawer/docs/examples/InitialFocus.d.ts +9 -0
  115. package/types/src/Drawer/docs/examples/InlinePosition.d.ts +7 -0
  116. package/types/src/Drawer/docs/examples/PagePosition.d.ts +7 -0
  117. package/types/src/Drawer/index.d.ts +2 -0
  118. package/types/src/JSONTree/JSONTree.d.ts +12 -5
  119. package/types/src/JSONTree/renderTreeItems.d.ts +2 -1
  120. package/types/src/Menu/Item.d.ts +2 -1
  121. package/types/src/Menu/docs/examples/SelectableCheckbox.d.ts +7 -0
  122. package/types/src/Modal/Modal.d.ts +1 -2
  123. package/types/src/Select/Option.d.ts +6 -3
  124. package/types/src/Select/Select.d.ts +8 -5
  125. package/types/src/Select/docs/examples/Dimmed.d.ts +7 -0
  126. package/types/src/SelectBase/OptionBase.d.ts +6 -3
  127. package/types/src/SelectBase/SelectBase.d.ts +8 -3
  128. package/types/src/SidePanel/SidePanel.d.ts +43 -2
  129. package/types/src/SidePanel/docs/examples/DockLayout.d.ts +17 -0
  130. package/types/src/SidePanel/docs/examples/InitialFocus.d.ts +9 -0
  131. package/types/src/TransitionOpen/TransitionOpen.d.ts +29 -4
  132. package/types/src/useKeyPress/index.d.ts +9 -2
  133. package/types/src/useOnClickOutside/index.d.ts +2 -0
  134. package/types/src/useOnClickOutside/useOnClickOutside.d.ts +4 -0
  135. package/useKeyPress.js +23 -18
  136. package/useOnClickOutside.d.ts +2 -0
  137. package/useOnClickOutside.js +79 -0
  138. 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
- * If set to `true`, using `shift + click` or `shift + enter` will expand all descendant nodes
58
- * of the tree at once. A tooltip is added to the expand all / collapse all button to indicate that this feature
59
- * is enabled. Defaults to `true`.
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
- expandChildrenOnShiftKey?: boolean;
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 {};
@@ -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
  */
@@ -19,9 +19,12 @@ interface OptionPropsBase {
19
19
  */
20
20
  descriptionPosition?: 'right' | 'bottom';
21
21
  /**
22
- * If disabled=true, the option is grayed out and cannot be clicked.
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 to toggle.
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
- * If disabled=true, the option is grayed out and cannot be clicked.
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
- /** Disable adding and removing. */
58
- disabled?: boolean;
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 (as a result of setting the html `disabled` attribute).
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
- type SidePanelProps = ComponentProps<SidePanelPropsBase, 'div'>;
68
- declare function SidePanel({ children, dockPosition, elementRef, innerClassName, innerStyle, onAnimationEnd, onRequestClose, open, outerClassName, outerStyle, useLayerForClickAway, ...otherProps }: SidePanelProps): React.JSX.Element;
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
- animation?: 'slideFromTop' | 'slideFromRight' | 'slideFromBottom' | 'slideFromLeft' | 'expandHeight' | 'expandWidth' | 'none';
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<string>;
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
- export declare function useKeyPress(targetKey: KeyboardEventKeys, handler: Handler): void;
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 };
@@ -0,0 +1,2 @@
1
+ export { default } from './useOnClickOutside';
2
+ export * from './useOnClickOutside';
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ type Handler = (event: MouseEvent | TouchEvent) => void;
3
+ declare const useOnClickOutside: <T extends HTMLElement = HTMLElement>(ref: React.RefObject<T>, handler: Handler, enabled?: boolean) => void;
4
+ export default useOnClickOutside;
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, r) => {
12
- /******/ for (var n in r) {
13
- /******/ if (e.o(r, n) && !e.o(t, n)) {
14
- /******/ Object.defineProperty(t, n, {
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[n]
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 */ n
50
+ useKeyPress: () => /* binding */ r
51
51
  });
52
52
  // CONCATENATED MODULE: external "react"
53
- const r = require("react");
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 n(e, t) {
88
- var n = (0, r.useCallback)((function(r) {
89
- if (r.key === e) {
90
- t(r);
91
- r.preventDefault();
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, r.useEffect)((function() {
96
- if (typeof window !== "undefined") {
97
- window.addEventListener("keyup", n);
100
+ (0, n.useEffect)((function() {
101
+ if (typeof window !== "undefined" && i) {
102
+ window.addEventListener(d, f);
98
103
  return function() {
99
- window.removeEventListener("keyup", n);
104
+ window.removeEventListener(d, f);
100
105
  };
101
106
  }
102
- }), [ n ]);
107
+ }), [ i, d, f ]);
103
108
  }
104
- /* harmony default export */ const o = n;
109
+ /* harmony default export */ const o = r;
105
110
  module.exports = t;
106
111
  /******/})();
@@ -0,0 +1,2 @@
1
+ export { default } from './types/src/useOnClickOutside';
2
+ export * from './types/src/useOnClickOutside';
@@ -0,0 +1,79 @@
1
+ /******/ (() => {
2
+ // webpackBootstrap
3
+ /******/ "use strict";
4
+ /******/ // The require scope
5
+ /******/ var e = {};
6
+ /******/
7
+ /************************************************************************/
8
+ /******/ /* webpack/runtime/define property getters */
9
+ /******/ (() => {
10
+ /******/ // define getter functions for harmony exports
11
+ /******/ e.d = (t, r) => {
12
+ /******/ for (var n in r) {
13
+ /******/ if (e.o(r, n) && !e.o(t, n)) {
14
+ /******/ Object.defineProperty(t, n, {
15
+ enumerable: true,
16
+ get: r[n]
17
+ });
18
+ /******/ }
19
+ /******/ }
20
+ /******/ };
21
+ /******/ })();
22
+ /******/
23
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
24
+ /******/ (() => {
25
+ /******/ e.o = (e, t) => Object.prototype.hasOwnProperty.call(e, t)
26
+ /******/;
27
+ })();
28
+ /******/
29
+ /******/ /* webpack/runtime/make namespace object */
30
+ /******/ (() => {
31
+ /******/ // define __esModule on exports
32
+ /******/ e.r = e => {
33
+ /******/ if (typeof Symbol !== "undefined" && Symbol.toStringTag) {
34
+ /******/ Object.defineProperty(e, Symbol.toStringTag, {
35
+ value: "Module"
36
+ });
37
+ /******/ }
38
+ /******/ Object.defineProperty(e, "__esModule", {
39
+ value: true
40
+ });
41
+ /******/ };
42
+ /******/ })();
43
+ /******/
44
+ /************************************************************************/ var t = {};
45
+ // ESM COMPAT FLAG
46
+ e.r(t);
47
+ // EXPORTS
48
+ e.d(t, {
49
+ default: () => /* reexport */ o
50
+ });
51
+ // CONCATENATED MODULE: external "react"
52
+ const r = require("react");
53
+ // CONCATENATED MODULE: ./src/useOnClickOutside/useOnClickOutside.ts
54
+ var n = function e(t, n) {
55
+ var o = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
56
+ (0, r.useEffect)((function() {
57
+ var e = function e(r) {
58
+ if (!t.current || t.current.contains(r.target)) {
59
+ // Click is inside the ref, do nothing
60
+ return;
61
+ }
62
+ // Click is outside the ref, call the handler
63
+ n(r);
64
+ };
65
+ if (o) {
66
+ var r;
67
+ // accessing document in a way that is compatible with SSR
68
+ (r = document) === null || r === void 0 ? void 0 : r.addEventListener("mousedown", e);
69
+ }
70
+ return function() {
71
+ var t;
72
+ (t = document) === null || t === void 0 ? void 0 : t.removeEventListener("mousedown", e);
73
+ };
74
+ }), [ t, n, o ]);
75
+ };
76
+ /* harmony default export */ const o = n;
77
+ // CONCATENATED MODULE: ./src/useOnClickOutside/index.ts
78
+ module.exports = t;
79
+ /******/})();
@@ -1,6 +0,0 @@
1
- import React from 'react';
2
- /**
3
- * @name Row layout
4
- */
5
- declare function Row(): React.JSX.Element;
6
- export default Row;