@splunk/react-ui 5.4.0 → 5.5.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 (76) hide show
  1. package/Badge.js +154 -0
  2. package/CHANGELOG.md +27 -0
  3. package/Code.js +1097 -500
  4. package/Color.js +142 -141
  5. package/ComboBox.js +6 -5
  6. package/Link.js +74 -44
  7. package/MIGRATION.md +32 -1
  8. package/Menu.js +41 -43
  9. package/Multiselect.js +596 -2143
  10. package/Number.js +3 -3
  11. package/PhoneNumber.d.ts +2 -0
  12. package/PhoneNumber.js +769 -0
  13. package/Popover.js +73 -75
  14. package/RadioList.js +166 -151
  15. package/ResultsMenu.js +27 -29
  16. package/Select.js +179 -1768
  17. package/SelectBase.d.ts +2 -0
  18. package/SelectBase.js +1681 -0
  19. package/Slider.js +202 -199
  20. package/SlidingPanels.js +55 -62
  21. package/Switch.js +42 -27
  22. package/TabBar.js +295 -294
  23. package/TabLayout.js +14 -14
  24. package/Table.js +1087 -1040
  25. package/TransitionOpen.js +82 -74
  26. package/docker-compose.yml +99 -52
  27. package/package.json +9 -5
  28. package/stubs-splunkui.d.ts +0 -86
  29. package/test-runner-jest.config.js +1 -0
  30. package/types/src/Badge/Badge.d.ts +29 -0
  31. package/types/src/Badge/docs/examples/Basic.d.ts +5 -0
  32. package/types/src/Badge/docs/examples/Count.d.ts +6 -0
  33. package/types/src/Badge/docs/examples/CustomColors.d.ts +8 -0
  34. package/types/src/Badge/docs/examples/Icon.d.ts +6 -0
  35. package/types/src/Badge/index.d.ts +2 -0
  36. package/types/src/Code/Code.d.ts +4 -3
  37. package/types/src/Code/index.d.ts +1 -0
  38. package/types/src/Link/Link.d.ts +4 -0
  39. package/types/src/Link/LinkContext.d.ts +14 -0
  40. package/types/src/Link/docs/examples/Visited.d.ts +7 -0
  41. package/types/src/Link/index.d.ts +1 -0
  42. package/types/src/Multiselect/Compact.d.ts +1 -1
  43. package/types/src/Multiselect/Multiselect.d.ts +1 -1
  44. package/types/src/PhoneNumber/PhoneNumber.d.ts +139 -0
  45. package/types/src/PhoneNumber/docs/examples/Controlled.d.ts +7 -0
  46. package/types/src/PhoneNumber/docs/examples/DefaultCountry.d.ts +7 -0
  47. package/types/src/PhoneNumber/docs/examples/Disabled.d.ts +6 -0
  48. package/types/src/PhoneNumber/docs/examples/Error.d.ts +6 -0
  49. package/types/src/PhoneNumber/docs/examples/Inline.d.ts +7 -0
  50. package/types/src/PhoneNumber/docs/examples/Uncontrolled.d.ts +7 -0
  51. package/types/src/PhoneNumber/index.d.ts +2 -0
  52. package/types/src/PhoneNumber/utils.d.ts +47 -0
  53. package/types/src/RadioList/Option.d.ts +6 -1
  54. package/types/src/RadioList/docs/examples/Description.d.ts +6 -0
  55. package/types/src/Select/Option.d.ts +8 -3
  56. package/types/src/Select/Select.d.ts +1 -1
  57. package/types/src/{Select → SelectBase}/OptionBase.d.ts +8 -2
  58. package/types/src/{Select → SelectBase}/SelectBase.d.ts +3 -1
  59. package/types/src/SelectBase/index.d.ts +2 -0
  60. package/types/src/Switch/Switch.d.ts +3 -0
  61. package/types/src/Table/Body.d.ts +6 -1
  62. package/types/src/Table/Cell.d.ts +5 -1
  63. package/types/src/Table/Head.d.ts +6 -2
  64. package/types/src/Table/HeadCell.d.ts +5 -1
  65. package/types/src/Table/Row.d.ts +5 -1
  66. package/types/src/Table/Table.d.ts +20 -1
  67. package/types/src/Table/TableContext.d.ts +1 -0
  68. package/types/src/Table/docs/examples/HorizontalOverflowScroll.d.ts +8 -0
  69. package/types/src/Table/docs/examples/PinActionColumn.d.ts +7 -0
  70. package/types/src/TransitionOpen/TransitionOpen.d.ts +3 -1
  71. package/types/src/useResizeObserver/useResizeObserver.d.ts +2 -0
  72. package/types/src/useRovingFocus/useRovingFocus.d.ts +8 -1
  73. package/usePrevious.d.ts +2 -0
  74. package/useResizeObserver.js +59 -92
  75. package/useRovingFocus.js +96 -41
  76. /package/types/src/{Select → SelectBase}/SelectAllOption.d.ts +0 -0
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { TableRequestMoveRowHandler } from '@splunk/react-ui/Table';
3
+ import { PinnedColumnsProp, TableRequestMoveRowHandler } from '@splunk/react-ui/Table';
4
4
  import { ComponentProps } from '../utils/types';
5
5
  /** @public */
6
6
  type RowActionPrimaryClickHandler = (event: React.MouseEvent, data?: any) => void;
@@ -77,6 +77,8 @@ interface RowPropsBase {
77
77
  * An event handler for toggle of the row. resize of columns. The function is passed the event and the `data` prop for this row.
78
78
  */
79
79
  onRequestToggle?: RowRequestToggleHandler;
80
+ /** @private. */
81
+ pinnedColumns?: PinnedColumnsProp;
80
82
  /**
81
83
  * @private. Generally passed by Table rather than added directly. Indicates the column to use as the primary label for each row.
82
84
  */
@@ -128,6 +130,8 @@ declare namespace Row {
128
130
  /** @private. Generally passed by `Table` rather than added directly. */
129
131
  onRequestMoveRow: PropTypes.Requireable<(...args: any[]) => any>;
130
132
  onRequestToggle: PropTypes.Requireable<(...args: any[]) => any>;
133
+ /** @private. */
134
+ pinnedColumns: PropTypes.Requireable<object>;
131
135
  /** @private. Generally passed by `Table` rather than added directly. */
132
136
  primaryColumnIndex: PropTypes.Requireable<number>;
133
137
  rowScreenReaderText: PropTypes.Requireable<string>;
@@ -25,6 +25,10 @@ type TableRequestResizeColumnHandler = (event: React.MouseEvent<HTMLHRElement> |
25
25
  index: number;
26
26
  width: number;
27
27
  }) => void;
28
+ /** @public */
29
+ type PinnedColumnsProp = {
30
+ actions?: boolean;
31
+ };
28
32
  interface TablePropsBase {
29
33
  /**
30
34
  * Adds table-level actions. Not compatible with `onRequestResize`.
@@ -63,6 +67,14 @@ interface TablePropsBase {
63
67
  * the table.
64
68
  */
65
69
  headType?: 'docked' | 'fixed' | 'inline';
70
+ /**
71
+ * Controls how the Table handles horizontal content overflow:
72
+ *
73
+ * * `auto`: The default behavior for overflow. `HeadCell` content will truncate and `Cell` content will wrap.
74
+ * The Table will scroll horizontally when the container's width exceeds the Table's width.
75
+ * * `scroll`: The Table will scroll horizontally. `HeadCell` content will not truncate and `Cell` content will wrap only for word breaks.
76
+ */
77
+ horizontalOverflow?: 'auto' | 'scroll';
66
78
  /**
67
79
  * Style specification for the inner container, which is the scrolling container.
68
80
  */
@@ -79,6 +91,11 @@ interface TablePropsBase {
79
91
  * Style specification for the outer container.
80
92
  */
81
93
  outerStyle?: React.CSSProperties;
94
+ /**
95
+ * Optionally pin the actions column to the end of the table by passing `pinnedColumns={{ actions: true }}.`
96
+ * When using pinned columns `horizontalOverflow` should be set to `scroll`.
97
+ */
98
+ pinnedColumns?: PinnedColumnsProp;
82
99
  /**
83
100
  * Adds a column to the table with an expansion button for each row that has expansion
84
101
  * content. Supported values:
@@ -138,10 +155,12 @@ declare namespace Table {
138
155
  dockScrollBar: PropTypes.Requireable<boolean>;
139
156
  elementRef: PropTypes.Requireable<object>;
140
157
  headType: PropTypes.Requireable<string>;
158
+ horizontalOverflow: PropTypes.Requireable<string>;
141
159
  innerStyle: PropTypes.Requireable<object>;
142
160
  onRequestToggleAllRows: PropTypes.Requireable<(...args: any[]) => any>;
143
161
  onScroll: PropTypes.Requireable<(...args: any[]) => any>;
144
162
  outerStyle: PropTypes.Requireable<object>;
163
+ pinnedColumns: PropTypes.Requireable<object>;
145
164
  primaryColumnIndex: PropTypes.Requireable<number>;
146
165
  rowExpansion: PropTypes.Requireable<string>;
147
166
  rowSelection: PropTypes.Requireable<string>;
@@ -162,4 +181,4 @@ declare namespace Table {
162
181
  }
163
182
  export default Table;
164
183
  export { Body, Caption, Cell, Head, HeadCell, HeadDropdownCell, Row };
165
- export type { CellClickHandler, HeadCellSortHandler, HeadDropdownCellPossibleCloseReason, HeadDropdownCellRequestCloseHandler, HeadDropdownCellRequestOpenHandler, RowActionPrimaryClickHandler, RowActionSecondaryClickHandler, RowClickHandler, RowRequestToggleHandler, TableRequestMoveColumnHandler, TableRequestMoveRowHandler, TableRequestResizeColumnHandler, };
184
+ export type { CellClickHandler, HeadCellSortHandler, HeadDropdownCellPossibleCloseReason, HeadDropdownCellRequestCloseHandler, HeadDropdownCellRequestOpenHandler, RowActionPrimaryClickHandler, RowActionSecondaryClickHandler, RowClickHandler, RowRequestToggleHandler, TableRequestMoveColumnHandler, TableRequestMoveRowHandler, TableRequestResizeColumnHandler, PinnedColumnsProp, };
@@ -1,5 +1,6 @@
1
1
  export interface TableContext {
2
2
  headType?: 'docked' | 'fixed' | 'inline';
3
+ horizontalOverflow?: 'auto' | 'scroll';
3
4
  resizableFillLayout?: boolean;
4
5
  tableContainerWidthWithoutBorders?: number | null;
5
6
  }
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ /**
3
+ * @name Horizontal overflow scroll
4
+ * @description Table handles overflow by horizontally scrolling.
5
+ * Set `horizontalOverflow="scroll"` for `HeadCell` content to not truncate or `Cell` content to wrap for word breaks.
6
+ */
7
+ declare function HorizontalOverflowScroll(): React.JSX.Element;
8
+ export default HorizontalOverflowScroll;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ /**
3
+ * @name Pin action column
4
+ * @description Pins action column to the end of the table.
5
+ */
6
+ declare function PinActionColumn(): React.JSX.Element;
7
+ export default PinActionColumn;
@@ -17,6 +17,7 @@ interface TransitionOpenPropsBase {
17
17
  innerClassName?: string;
18
18
  innerStyle?: React.CSSProperties;
19
19
  onAnimationEnd?: () => void;
20
+ onAnimationStart?: () => void;
20
21
  /** Whether the component is currently open or not. */
21
22
  open?: boolean;
22
23
  /** An additional className to outer container. */
@@ -38,7 +39,7 @@ interface TransitionOpenPropsBase {
38
39
  takeFocus?: boolean;
39
40
  }
40
41
  type TransitionOpenProps = ComponentProps<TransitionOpenPropsBase, 'div'>;
41
- declare function TransitionOpen({ animation, animateOnMount, children, className, elementRef, id, innerClassName, innerStyle, onAnimationEnd, open, outerClassName, outerId, outerStyle, renderChildrenWhenCollapsed, retainFocus, takeFocus: takeFocusProp, ...otherProps }: TransitionOpenProps): React.JSX.Element;
42
+ declare function TransitionOpen({ animation, animateOnMount, children, className, elementRef, id, innerClassName, innerStyle, onAnimationEnd, onAnimationStart, open, outerClassName, outerId, outerStyle, renderChildrenWhenCollapsed, retainFocus, takeFocus: takeFocusProp, ...otherProps }: TransitionOpenProps): React.JSX.Element;
42
43
  declare namespace TransitionOpen {
43
44
  var propTypes: {
44
45
  animation: PropTypes.Requireable<string>;
@@ -50,6 +51,7 @@ declare namespace TransitionOpen {
50
51
  innerClassName: PropTypes.Requireable<string>;
51
52
  innerStyle: PropTypes.Requireable<object>;
52
53
  onAnimationEnd: PropTypes.Requireable<(...args: any[]) => any>;
54
+ onAnimationStart: PropTypes.Requireable<(...args: any[]) => any>;
53
55
  open: PropTypes.Requireable<boolean>;
54
56
  outerClassName: PropTypes.Requireable<string>;
55
57
  outerId: PropTypes.Requireable<string>;
@@ -6,8 +6,10 @@ type Dimensions = {
6
6
  type ResizeHandler = (data: Dimensions) => void;
7
7
  /**
8
8
  * Watches a React ref element for changes in size.
9
+ * Uses useSyncExternalStore for better React 18 concurrent rendering support.
9
10
  *
10
11
  * @param ref - The React ref to observe size changes on
12
+ * @param onResize - Callback function that receives the new dimensions
11
13
  */
12
14
  declare const useResizeObserver: (ref: React.MutableRefObject<HTMLElement | null>, onResize?: ResizeHandler) => Dimensions;
13
15
  export default useResizeObserver;
@@ -1,3 +1,9 @@
1
+ type RovingFocusOptions = {
2
+ enableLoop?: boolean;
3
+ orientation?: 'horizontal' | 'vertical';
4
+ enableTab?: boolean;
5
+ enableHomeEnd?: boolean;
6
+ };
1
7
  /**
2
8
  * This is a private hook not intended for use outside @splunk/react-ui
3
9
  *
@@ -18,10 +24,11 @@
18
24
  * </div>
19
25
  * ```
20
26
  */
21
- declare function useRovingFocus(): {
27
+ declare function useRovingFocus(options?: {}): {
22
28
  ref: (element: HTMLDivElement | null) => void;
23
29
  onBlur: (e: React.FocusEvent) => void;
24
30
  onFocus: (e: React.FocusEvent) => void;
25
31
  onKeyDown: (e: React.KeyboardEvent<HTMLDivElement>) => void;
26
32
  };
27
33
  export default useRovingFocus;
34
+ export type { RovingFocusOptions };
@@ -0,0 +1,2 @@
1
+ export { default } from './types/src/usePrevious';
2
+ export * from './types/src/usePrevious';
@@ -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 = (r, t) => {
12
+ /******/ for (var n in t) {
13
+ /******/ if (e.o(t, n) && !e.o(r, n)) {
14
+ /******/ Object.defineProperty(r, n, {
15
15
  enumerable: true,
16
- get: r[n]
16
+ get: t[n]
17
17
  });
18
18
  /******/ }
19
19
  /******/ }
@@ -22,7 +22,7 @@
22
22
  /******/
23
23
  /******/ /* webpack/runtime/hasOwnProperty shorthand */
24
24
  /******/ (() => {
25
- /******/ e.o = (e, t) => Object.prototype.hasOwnProperty.call(e, t)
25
+ /******/ e.o = (e, r) => Object.prototype.hasOwnProperty.call(e, r)
26
26
  /******/;
27
27
  })();
28
28
  /******/
@@ -41,104 +41,71 @@
41
41
  /******/ };
42
42
  /******/ })();
43
43
  /******/
44
- /************************************************************************/ var t = {};
44
+ /************************************************************************/ var r = {};
45
45
  // ESM COMPAT FLAG
46
- e.r(t);
46
+ e.r(r);
47
47
  // EXPORTS
48
- e.d(t, {
49
- default: () => /* reexport */ c
48
+ e.d(r, {
49
+ default: () => /* reexport */ u
50
50
  });
51
51
  // CONCATENATED MODULE: external "react"
52
- const r = require("react");
52
+ const t = require("react");
53
+ // CONCATENATED MODULE: external "use-sync-external-store/shim"
54
+ const n = require("use-sync-external-store/shim");
53
55
  // CONCATENATED MODULE: ./src/useResizeObserver/useResizeObserver.ts
54
- function n(e, t) {
55
- return a(e) || l(e, t) || o(e, t) || i();
56
- }
57
- function i() {
58
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
59
- }
60
- function o(e, t) {
61
- if (e) {
62
- if ("string" == typeof e) return u(e, t);
63
- var r = {}.toString.call(e).slice(8, -1);
64
- return "Object" === r && e.constructor && (r = e.constructor.name), "Map" === r || "Set" === r ? Array.from(e) : "Arguments" === r || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r) ? u(e, t) : void 0;
65
- }
66
- }
67
- function u(e, t) {
68
- (null == t || t > e.length) && (t = e.length);
69
- for (var r = 0, n = Array(t); r < t; r++) {
70
- n[r] = e[r];
71
- }
72
- return n;
73
- }
74
- function l(e, t) {
75
- var r = null == e ? null : "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"];
76
- if (null != r) {
77
- var n, i, o, u, l = [], a = !0, f = !1;
78
- try {
79
- if (o = (r = r.call(e)).next, 0 === t) {
80
- if (Object(r) !== r) return;
81
- a = !1;
82
- } else for (;!(a = (n = o.call(r)).done) && (l.push(n.value), l.length !== t); a = !0) {
83
- }
84
- } catch (e) {
85
- f = !0, i = e;
86
- } finally {
87
- try {
88
- if (!a && null != r["return"] && (u = r["return"](), Object(u) !== u)) return;
89
- } finally {
90
- if (f) throw i;
91
- }
92
- }
93
- return l;
94
- }
95
- }
96
- function a(e) {
97
- if (Array.isArray(e)) return e;
98
- }
56
+ // This shim is here for React 16 support
57
+ // Cache the server snapshot to avoid creating new objects on every render
58
+ var i = {
59
+ width: 0,
60
+ height: 0
61
+ };
99
62
  /**
100
63
  * Watches a React ref element for changes in size.
64
+ * Uses useSyncExternalStore for better React 18 concurrent rendering support.
101
65
  *
102
66
  * @param ref - The React ref to observe size changes on
103
- */ var f = function e(t, i) {
104
- var o = (0, r.useState)({
67
+ * @param onResize - Callback function that receives the new dimensions
68
+ */ var o = function e(r, o) {
69
+ var u = (0, t.useRef)({
105
70
  width: 0,
106
71
  height: 0
107
- }), u = n(o, 2), l = u[0], a = u[1];
108
- (0, r.useEffect)((function() {
109
- var e = t.current;
110
- if (typeof window !== "undefined" && window.ResizeObserver) {
111
- var r = new ResizeObserver((function(e) {
112
- if (e[0]) {
113
- var r, n;
114
- var o = {
115
- width: (t === null || t === void 0 ? void 0 : (r = t.current) === null || r === void 0 ? void 0 : r.getBoundingClientRect().width) || 0,
116
- height: (t === null || t === void 0 ? void 0 : (n = t.current) === null || n === void 0 ? void 0 : n.getBoundingClientRect().height) || 0
117
- };
118
- a((function(e) {
119
- if (e.height !== o.height || e.width !== o.width) {
120
- i === null || i === void 0 ? void 0 : i(o);
121
- return o;
122
- }
123
- return e;
124
- }));
125
- }
126
- }));
127
- if (e) {
128
- r.observe(e);
129
- }
130
- return function() {
131
- if (e) {
132
- r.unobserve(e);
133
- }
72
+ });
73
+ var d = (0, t.useCallback)((function(e) {
74
+ var t = r.current;
75
+ if (!t || typeof window === "undefined" || !window.ResizeObserver) {
76
+ return function() {};
77
+ // No-op if not in browser or no ResizeObserver support
78
+ }
79
+ var n = function t() {
80
+ var n, i;
81
+ var d = {
82
+ width: (r === null || r === void 0 ? void 0 : (n = r.current) === null || n === void 0 ? void 0 : n.getBoundingClientRect().width) || 0,
83
+ height: (r === null || r === void 0 ? void 0 : (i = r.current) === null || i === void 0 ? void 0 : i.getBoundingClientRect().height) || 0
134
84
  };
135
- }
136
- // Return a no-op function to satisfy consistent-return rule
137
- return function() {};
138
- }), [ i, t ]);
139
- return l;
85
+ if (u.current.width !== d.width || u.current.height !== d.height) {
86
+ u.current = d;
87
+ o === null || o === void 0 ? void 0 : o(d);
88
+ e();
89
+ }
90
+ };
91
+ var i = new ResizeObserver(n);
92
+ i.observe(t);
93
+ // Initial measurement
94
+ n();
95
+ return function() {
96
+ i.disconnect();
97
+ };
98
+ }), [ r, o ]);
99
+ // Use useSyncExternalStore to handle the subscription to ensure proper synchronization with
100
+ // Reacts concurrent rendering, it handles cases where the resize event might be interrupted
101
+ // or batched with other updates
102
+ return (0, n.useSyncExternalStore)(d, (function() {
103
+ return u.current;
104
+ }), (function() {
105
+ return i;
106
+ }));
140
107
  };
141
- /* harmony default export */ const c = f;
108
+ /* harmony default export */ const u = o;
142
109
  // CONCATENATED MODULE: ./src/useResizeObserver/index.ts
143
- module.exports = t;
110
+ module.exports = r;
144
111
  /******/})();
package/useRovingFocus.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 = (r, t) => {
12
+ /******/ for (var n in t) {
13
+ /******/ if (e.o(t, n) && !e.o(r, n)) {
14
+ /******/ Object.defineProperty(r, n, {
15
15
  enumerable: true,
16
- get: r[n]
16
+ get: t[n]
17
17
  });
18
18
  /******/ }
19
19
  /******/ }
@@ -22,7 +22,7 @@
22
22
  /******/
23
23
  /******/ /* webpack/runtime/hasOwnProperty shorthand */
24
24
  /******/ (() => {
25
- /******/ e.o = (e, t) => Object.prototype.hasOwnProperty.call(e, t)
25
+ /******/ e.o = (e, r) => Object.prototype.hasOwnProperty.call(e, r)
26
26
  /******/;
27
27
  })();
28
28
  /******/
@@ -41,19 +41,70 @@
41
41
  /******/ };
42
42
  /******/ })();
43
43
  /******/
44
- /************************************************************************/ var t = {};
44
+ /************************************************************************/ var r = {};
45
45
  // ESM COMPAT FLAG
46
- e.r(t);
46
+ e.r(r);
47
47
  // EXPORTS
48
- e.d(t, {
49
- default: () => /* reexport */ u
48
+ e.d(r, {
49
+ default: () => /* reexport */ s
50
50
  });
51
51
  // CONCATENATED MODULE: external "react"
52
- const r = require("react");
52
+ const t = require("react");
53
53
  // CONCATENATED MODULE: external "@splunk/ui-utils/focus"
54
54
  const n = require("@splunk/ui-utils/focus");
55
55
  // CONCATENATED MODULE: ./src/useRovingFocus/useRovingFocus.tsx
56
- var a = {
56
+ function o(e) {
57
+ "@babel/helpers - typeof";
58
+ return o = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
59
+ return typeof e;
60
+ } : function(e) {
61
+ return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
62
+ }, o(e);
63
+ }
64
+ function u(e, r) {
65
+ var t = Object.keys(e);
66
+ if (Object.getOwnPropertySymbols) {
67
+ var n = Object.getOwnPropertySymbols(e);
68
+ r && (n = n.filter((function(r) {
69
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
70
+ }))), t.push.apply(t, n);
71
+ }
72
+ return t;
73
+ }
74
+ function i(e) {
75
+ for (var r = 1; r < arguments.length; r++) {
76
+ var t = null != arguments[r] ? arguments[r] : {};
77
+ r % 2 ? u(Object(t), !0).forEach((function(r) {
78
+ a(e, r, t[r]);
79
+ })) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : u(Object(t)).forEach((function(r) {
80
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
81
+ }));
82
+ }
83
+ return e;
84
+ }
85
+ function a(e, r, t) {
86
+ return (r = c(r)) in e ? Object.defineProperty(e, r, {
87
+ value: t,
88
+ enumerable: !0,
89
+ configurable: !0,
90
+ writable: !0
91
+ }) : e[r] = t, e;
92
+ }
93
+ function c(e) {
94
+ var r = f(e, "string");
95
+ return "symbol" == o(r) ? r : r + "";
96
+ }
97
+ function f(e, r) {
98
+ if ("object" != o(e) || !e) return e;
99
+ var t = e[Symbol.toPrimitive];
100
+ if (void 0 !== t) {
101
+ var n = t.call(e, r || "default");
102
+ if ("object" != o(n)) return n;
103
+ throw new TypeError("@@toPrimitive must return a primitive value.");
104
+ }
105
+ return ("string" === r ? String : Number)(e);
106
+ }
107
+ var l = {
57
108
  enableLoop: false,
58
109
  orientation: "horizontal",
59
110
  enableTab: false,
@@ -78,48 +129,52 @@
78
129
  * <button type="button">second</button>
79
130
  * </div>
80
131
  * ```
81
- */ function o() {
82
- var e = (0, r.useRef)(0);
83
- var t = (0, r.useRef)([]);
84
- var o = function r(n) {
85
- e.current = n;
86
- t.current.forEach((function(t, r) {
87
- return r === e.current ? t.removeAttribute("tabindex") : t.setAttribute("tabindex", "-1");
132
+ */ function b() {
133
+ var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
134
+ var r = (0, t.useRef)(0);
135
+ var o = (0, t.useRef)([]);
136
+ var u = i(i({}, l), e);
137
+ var a = function e(t) {
138
+ r.current = t;
139
+ o.current.forEach((function(e, t) {
140
+ return t === r.current ? e.removeAttribute("tabindex") : e.setAttribute("tabindex", "-1");
88
141
  }));
89
142
  };
90
- var u = function r(a) {
91
- t.current = a != null ? (0, n.getSortedTabbableElements)(a, {
143
+ var c = function e(t) {
144
+ o.current = t != null ? (0, n.getSortedTabbableElements)(t, {
92
145
  ignoreTabIndex: true
93
146
  }) : [];
94
- o(e.current);
147
+ a(r.current);
95
148
  };
96
- var i = function e(r) {
97
- var n = r.relatedTarget instanceof Element && t.current.includes(r.relatedTarget);
98
- if (!n) {
99
- o(0);
149
+ var f = function e(r) {
150
+ var t = r.relatedTarget instanceof HTMLElement && o.current.includes(r.relatedTarget);
151
+ if (!t) {
152
+ a(0);
100
153
  }
101
154
  };
102
- var c = function e(r) {
103
- var n = r.target instanceof Element ? t.current.indexOf(r.target) : -1;
104
- if (n >= 0) {
105
- o(n);
155
+ var b = function e(r) {
156
+ var t = r.target instanceof HTMLElement ? o.current.indexOf(r.target) : -1;
157
+ if (t >= 0) {
158
+ a(t);
106
159
  }
107
160
  };
108
- var l = function e(r) {
109
- var o = t.current.includes(r.nativeEvent.target);
110
- /* Only apply focus if we are among the navigable items in this container */ if (r.nativeEvent.target instanceof HTMLElement && o) {
111
- var u = t.current.indexOf(r.nativeEvent.target);
112
- (0, n.handleFocus)(r.key, t.current, u, a);
161
+ var s = function e(r) {
162
+ var t = r.nativeEvent.target;
163
+ var i = t instanceof HTMLElement ? o.current.indexOf(t) : -1;
164
+ if (i === -1) {
165
+ return;
113
166
  }
167
+ /* Only apply focus if we are among the navigable items in this container */ (0,
168
+ n.handleFocus)(r.key, o.current, i, u);
114
169
  };
115
170
  return {
116
- ref: u,
117
- onBlur: i,
118
- onFocus: c,
119
- onKeyDown: l
171
+ ref: c,
172
+ onBlur: f,
173
+ onFocus: b,
174
+ onKeyDown: s
120
175
  };
121
176
  }
122
- /* harmony default export */ const u = o;
177
+ /* harmony default export */ const s = b;
123
178
  // CONCATENATED MODULE: ./src/useRovingFocus/index.ts
124
- module.exports = t;
179
+ module.exports = r;
125
180
  /******/})();