@splunk/react-ui 5.3.0 → 5.4.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 (60) hide show
  1. package/Accordion.js +31 -31
  2. package/Avatar.js +13 -13
  3. package/Breadcrumbs.js +66 -63
  4. package/ButtonSimple.js +52 -52
  5. package/CHANGELOG.md +16 -0
  6. package/CardLayout.js +39 -36
  7. package/Clickable.js +5 -6
  8. package/Code.js +424 -528
  9. package/CollapsiblePanel.js +1 -1
  10. package/Color.js +903 -1025
  11. package/DefinitionList.js +1 -1
  12. package/FormRows.js +13 -11
  13. package/JSONTree.js +682 -1408
  14. package/Link.js +5 -5
  15. package/Markdown.js +9 -5
  16. package/Menu.js +72 -67
  17. package/Multiselect.js +2692 -2780
  18. package/Popover.js +201 -196
  19. package/Resize.js +11 -8
  20. package/ResultsMenu.js +913 -1030
  21. package/ScreenReaderContent.js +86 -130
  22. package/Scroll.js +366 -425
  23. package/Select.js +1741 -1832
  24. package/Slider.js +1 -1
  25. package/SlidingPanels.js +129 -127
  26. package/StepBar.js +123 -97
  27. package/Switch.js +115 -111
  28. package/TabBar.js +10 -10
  29. package/Table.js +1239 -1240
  30. package/TextArea.js +596 -684
  31. package/Tree.js +638 -682
  32. package/package.json +11 -11
  33. package/types/src/Breadcrumbs/Breadcrumbs.d.ts +1 -5
  34. package/types/src/Breadcrumbs/BreadcrumbsContext.d.ts +7 -0
  35. package/types/src/Breadcrumbs/Item.d.ts +1 -1
  36. package/types/src/ButtonSimple/mixin.d.ts +1 -1
  37. package/types/src/JSONTree/JSONTreeItem.d.ts +1 -1
  38. package/types/src/JSONTree/renderTreeItems.d.ts +1 -1
  39. package/types/src/Modal/ModalContext.d.ts +1 -1
  40. package/types/src/Multiselect/Compact.d.ts +2 -2
  41. package/types/src/Multiselect/Normal.d.ts +2 -2
  42. package/types/src/Number/utils.d.ts +1 -1
  43. package/types/src/Popover/getPlacement.d.ts +1 -1
  44. package/types/src/RadioList/Option.d.ts +1 -1
  45. package/types/src/RadioList/RadioListContext.d.ts +1 -1
  46. package/types/src/StepBar/StepBar.d.ts +4 -1
  47. package/types/src/StepBar/StepBarContext.d.ts +1 -0
  48. package/types/src/StepBar/docs/examples/Vertical.d.ts +6 -0
  49. package/types/src/Switch/Switch.d.ts +7 -1
  50. package/types/src/TabBar/Tab.d.ts +3 -1
  51. package/types/src/TabBar/docs/examples/Icons.d.ts +4 -0
  52. package/types/src/TabBar/docs/examples/Tooltips.d.ts +3 -0
  53. package/types/src/TabLayout/Panel.d.ts +2 -0
  54. package/types/src/Table/Head.d.ts +1 -1
  55. package/types/src/Table/Row.d.ts +1 -1
  56. package/types/src/Table/Table.d.ts +1 -0
  57. package/types/src/Tree/TreeContext.d.ts +1 -1
  58. package/useControlled.js +61 -97
  59. package/usePrevious.js +30 -62
  60. package/useResizeObserver.js +95 -127
package/ResultsMenu.js CHANGED
@@ -1,151 +1,34 @@
1
1
  /******/ (() => {
2
2
  // webpackBootstrap
3
3
  /******/ "use strict";
4
- /******/ var e = {
5
- /***/ 6165:
6
- /***/ (e, r, n) => {
7
- // EXPORTS
8
- n.d(r, {
9
- default: () => /* reexport */ b
10
- });
11
- // EXTERNAL MODULE: external "react"
12
- var t = n(9497);
13
- var o = n.n(t);
14
- // EXTERNAL MODULE: external "prop-types"
15
- var a = n(23);
16
- var i = n.n(a);
17
- // EXTERNAL MODULE: external "styled-components"
18
- var l = n(232);
19
- var u = n.n(l);
20
- // EXTERNAL MODULE: external "@splunk/themes"
21
- var c = n(3563);
22
- // CONCATENATED MODULE: ./src/ScreenReaderContent/ScreenReaderContentStyles.ts
23
- var s = u().span.withConfig({
24
- displayName: "ScreenReaderContentStyles__Styled",
25
- componentId: "sc-1lnohwp-0"
26
- })([ "", ";" ], c.mixins.screenReaderContent());
27
- // CONCATENATED MODULE: ./src/ScreenReaderContent/ScreenReaderContent.tsx
28
- function f() {
29
- return f = Object.assign ? Object.assign.bind() : function(e) {
30
- for (var r = 1; r < arguments.length; r++) {
31
- var n = arguments[r];
32
- for (var t in n) {
33
- ({}).hasOwnProperty.call(n, t) && (e[t] = n[t]);
34
- }
35
- }
36
- return e;
37
- }, f.apply(null, arguments);
38
- }
39
- function v(e, r) {
40
- if (null == e) return {};
41
- var n, t, o = d(e, r);
42
- if (Object.getOwnPropertySymbols) {
43
- var a = Object.getOwnPropertySymbols(e);
44
- for (t = 0; t < a.length; t++) {
45
- n = a[t], -1 === r.indexOf(n) && {}.propertyIsEnumerable.call(e, n) && (o[n] = e[n]);
46
- }
47
- }
48
- return o;
49
- }
50
- function d(e, r) {
51
- if (null == e) return {};
52
- var n = {};
53
- for (var t in e) {
54
- if ({}.hasOwnProperty.call(e, t)) {
55
- if (-1 !== r.indexOf(t)) continue;
56
- n[t] = e[t];
57
- }
58
- }
59
- return n;
60
- }
61
- var m = {
62
- children: i().node.isRequired,
63
- elementRef: i().oneOfType([ i().func, i().object ])
64
- };
65
- /**
66
- * The screen reader text is used to wrap content that
67
- * is only accessible through screen readers.
68
- */ function p(e) {
69
- var r = e.children, n = e.elementRef, t = v(e, [ "children", "elementRef" ]);
70
- // @docs-props-type ScreenReaderContentPropsBase
71
-
72
- return o().createElement(s, f({
73
- "data-test": "screen-reader-content",
74
- ref: n
75
- }, t), r);
76
- }
77
- p.propTypes = m;
78
- /* harmony default export */ const b = p;
79
- } // CONCATENATED MODULE: ./src/ScreenReaderContent/index.ts
80
- /***/ ,
81
- /***/ 3563:
82
- /***/ e => {
83
- e.exports = require("@splunk/themes");
84
- /***/ },
85
- /***/ 23:
86
- /***/ e => {
87
- e.exports = require("prop-types");
88
- /***/ },
89
- /***/ 9497:
90
- /***/ e => {
91
- e.exports = require("react");
92
- /***/ },
93
- /***/ 232:
94
- /***/ e => {
95
- e.exports = require("styled-components");
96
- /***/
97
- /******/ }
98
- };
99
- /************************************************************************/
100
- /******/ // The module cache
101
- /******/ var r = {};
102
- /******/
103
- /******/ // The require function
104
- /******/ function n(t) {
105
- /******/ // Check if module is in cache
106
- /******/ var o = r[t];
107
- /******/ if (o !== undefined) {
108
- /******/ return o.exports;
109
- /******/ }
110
- /******/ // Create a new module (and put it into the cache)
111
- /******/ var a = r[t] = {
112
- /******/ // no module.id needed
113
- /******/ // no module.loaded needed
114
- /******/ exports: {}
115
- /******/ };
116
- /******/
117
- /******/ // Execute the module function
118
- /******/ e[t](a, a.exports, n);
119
- /******/
120
- /******/ // Return the exports of the module
121
- /******/ return a.exports;
122
- /******/ }
4
+ /******/ // The require scope
5
+ /******/ var e = {};
123
6
  /******/
124
7
  /************************************************************************/
125
8
  /******/ /* webpack/runtime/compat get default export */
126
9
  /******/ (() => {
127
10
  /******/ // getDefaultExport function for compatibility with non-harmony modules
128
- /******/ n.n = e => {
129
- /******/ var r = e && e.__esModule ?
130
- /******/ () => e["default"]
131
- /******/ : () => e
11
+ /******/ e.n = r => {
12
+ /******/ var n = r && r.__esModule ?
13
+ /******/ () => r["default"]
14
+ /******/ : () => r
132
15
  /******/;
133
- n.d(r, {
134
- a: r
16
+ e.d(n, {
17
+ a: n
135
18
  });
136
- /******/ return r;
19
+ /******/ return n;
137
20
  /******/ };
138
21
  /******/ })();
139
22
  /******/
140
23
  /******/ /* webpack/runtime/define property getters */
141
24
  /******/ (() => {
142
25
  /******/ // define getter functions for harmony exports
143
- /******/ n.d = (e, r) => {
144
- /******/ for (var t in r) {
145
- /******/ if (n.o(r, t) && !n.o(e, t)) {
146
- /******/ Object.defineProperty(e, t, {
26
+ /******/ e.d = (r, n) => {
27
+ /******/ for (var t in n) {
28
+ /******/ if (e.o(n, t) && !e.o(r, t)) {
29
+ /******/ Object.defineProperty(r, t, {
147
30
  enumerable: true,
148
- get: r[t]
31
+ get: n[t]
149
32
  });
150
33
  /******/ }
151
34
  /******/ }
@@ -154,14 +37,14 @@
154
37
  /******/
155
38
  /******/ /* webpack/runtime/hasOwnProperty shorthand */
156
39
  /******/ (() => {
157
- /******/ n.o = (e, r) => Object.prototype.hasOwnProperty.call(e, r)
40
+ /******/ e.o = (e, r) => Object.prototype.hasOwnProperty.call(e, r)
158
41
  /******/;
159
42
  })();
160
43
  /******/
161
44
  /******/ /* webpack/runtime/make namespace object */
162
45
  /******/ (() => {
163
46
  /******/ // define __esModule on exports
164
- /******/ n.r = e => {
47
+ /******/ e.r = e => {
165
48
  /******/ if (typeof Symbol !== "undefined" && Symbol.toStringTag) {
166
49
  /******/ Object.defineProperty(e, Symbol.toStringTag, {
167
50
  value: "Module"
@@ -173,332 +56,331 @@
173
56
  /******/ };
174
57
  /******/ })();
175
58
  /******/
176
- /************************************************************************/ var t = {};
177
- // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
178
- (() => {
179
- // ESM COMPAT FLAG
180
- n.r(t);
181
- // EXPORTS
182
- n.d(t, {
183
- VirtualizedResultsMenu: () => /* reexport */ Re,
184
- default: () => /* reexport */ F
185
- });
186
- // EXTERNAL MODULE: external "react"
187
- var e = n(9497);
188
- var r = n.n(e);
189
- // EXTERNAL MODULE: external "prop-types"
190
- var o = n(23);
191
- var a = n.n(o);
192
- // CONCATENATED MODULE: external "@splunk/react-ui/Divider"
193
- const i = require("@splunk/react-ui/Divider");
194
- var l = n.n(i);
195
- // CONCATENATED MODULE: external "@splunk/react-ui/Menu"
196
- const u = require("@splunk/react-ui/Menu");
197
- var c = n.n(u);
198
- // CONCATENATED MODULE: external "@splunk/ui-utils/i18n"
199
- const s = require("@splunk/ui-utils/i18n");
200
- // EXTERNAL MODULE: external "styled-components"
201
- var f = n(232);
202
- var v = n.n(f);
203
- // CONCATENATED MODULE: external "@splunk/react-ui/WaitSpinner"
204
- const d = require("@splunk/react-ui/WaitSpinner");
205
- var m = n.n(d);
206
- // EXTERNAL MODULE: external "@splunk/themes"
207
- var p = n(3563);
208
- // CONCATENATED MODULE: ./src/ResultsMenu/ResultsMenuStyles.ts
209
- var b = v()(c()).withConfig({
210
- displayName: "ResultsMenuStyles__StyledMenu",
211
- componentId: "avbhl8-0"
212
- })([ "overflow:auto;flex-direction:column;" ]);
213
- var y = v().div.withConfig({
214
- displayName: "ResultsMenuStyles__Styled",
215
- componentId: "avbhl8-1"
216
- })([ "", ";flex-direction:column;max-height:calc(100vh - 20px);border-radius:", ";background-color:", ";& > ", ":not(:first-child){border-start-start-radius:0;border-start-end-radius:0;}& > ", ":not(:last-child){border-end-start-radius:0;border-end-end-radius:0;}" ], p.mixins.reset("flex"), p.variables.borderRadius, p.variables.backgroundColorPopup, b, b);
217
- var g = v().div.withConfig({
218
- displayName: "ResultsMenuStyles__StyledFooter",
219
- componentId: "avbhl8-2"
220
- })([ "padding:", " ", ";color:", ";" ], p.variables.spacingSmall, p.variables.spacingLarge, p.variables.contentColorDefault);
221
- var h = v().li.withConfig({
222
- displayName: "ResultsMenuStyles__StyledLoading",
223
- componentId: "avbhl8-3"
224
- })([ "", ";padding:", " ", ";gap:", ";" ], p.mixins.reset("flex"), p.variables.spacingSmall, p.variables.spacingLarge, p.variables.spacingXSmall);
225
- var S = v()(c().Item).withConfig({
226
- displayName: "ResultsMenuStyles__StyledNoOptions",
227
- componentId: "avbhl8-4"
228
- })([ "&[disabled],&[aria-disabled='true']{color:", ";}" ], p.variables.contentColorDefault);
229
- var E = v()(m()).withConfig({
230
- displayName: "ResultsMenuStyles__StyledWait",
231
- componentId: "avbhl8-5"
232
- })([ "flex:0 0 auto;" ]);
233
- var O = v().div.withConfig({
234
- displayName: "ResultsMenuStyles__StyledLoadingMessage",
235
- componentId: "avbhl8-6"
236
- })([ "flex:1 0 0;color:", ";" ], p.variables.contentColorDefault);
237
- // EXTERNAL MODULE: ./src/ScreenReaderContent/index.ts + 2 modules
238
- var w = n(6165);
239
- // CONCATENATED MODULE: ./src/utils/updateReactRef.ts
240
- /**
59
+ /************************************************************************/ var r = {};
60
+ // ESM COMPAT FLAG
61
+ e.r(r);
62
+ // EXPORTS
63
+ e.d(r, {
64
+ VirtualizedResultsMenu: () => /* reexport */ Re,
65
+ default: () => /* reexport */ B
66
+ });
67
+ // CONCATENATED MODULE: external "react"
68
+ const n = require("react");
69
+ var t = e.n(n);
70
+ // CONCATENATED MODULE: external "prop-types"
71
+ const o = require("prop-types");
72
+ var a = e.n(o);
73
+ // CONCATENATED MODULE: external "@splunk/react-ui/Divider"
74
+ const i = require("@splunk/react-ui/Divider");
75
+ var u = e.n(i);
76
+ // CONCATENATED MODULE: external "@splunk/react-ui/Menu"
77
+ const l = require("@splunk/react-ui/Menu");
78
+ var c = e.n(l);
79
+ // CONCATENATED MODULE: external "@splunk/react-ui/ScreenReaderContent"
80
+ const s = require("@splunk/react-ui/ScreenReaderContent");
81
+ var f = e.n(s);
82
+ // CONCATENATED MODULE: external "@splunk/ui-utils/i18n"
83
+ const d = require("@splunk/ui-utils/i18n");
84
+ // CONCATENATED MODULE: external "styled-components"
85
+ const v = require("styled-components");
86
+ var m = e.n(v);
87
+ // CONCATENATED MODULE: external "@splunk/react-ui/WaitSpinner"
88
+ const b = require("@splunk/react-ui/WaitSpinner");
89
+ var p = e.n(b);
90
+ // CONCATENATED MODULE: external "@splunk/themes"
91
+ const y = require("@splunk/themes");
92
+ // CONCATENATED MODULE: ./src/ResultsMenu/ResultsMenuStyles.ts
93
+ var g = m()(c()).withConfig({
94
+ displayName: "ResultsMenuStyles__StyledMenu",
95
+ componentId: "avbhl8-0"
96
+ })([ "overflow:auto;flex-direction:column;" ]);
97
+ var h = m().div.withConfig({
98
+ displayName: "ResultsMenuStyles__Styled",
99
+ componentId: "avbhl8-1"
100
+ })([ "", ";flex-direction:column;max-height:calc(100vh - 20px);border-radius:", ";background-color:", ";& > ", ":not(:first-child){border-start-start-radius:0;border-start-end-radius:0;}& > ", ":not(:last-child){border-end-start-radius:0;border-end-end-radius:0;}" ], y.mixins.reset("flex"), y.variables.borderRadius, y.variables.backgroundColorPopup, g, g);
101
+ var S = m().div.withConfig({
102
+ displayName: "ResultsMenuStyles__StyledFooter",
103
+ componentId: "avbhl8-2"
104
+ })([ "padding:", " ", ";color:", ";" ], y.variables.spacingSmall, y.variables.spacingLarge, y.variables.contentColorDefault);
105
+ var E = m().li.withConfig({
106
+ displayName: "ResultsMenuStyles__StyledLoading",
107
+ componentId: "avbhl8-3"
108
+ })([ "", ";padding:", " ", ";gap:", ";" ], y.mixins.reset("flex"), y.variables.spacingSmall, y.variables.spacingLarge, y.variables.spacingXSmall);
109
+ var O = m()(c().Item).withConfig({
110
+ displayName: "ResultsMenuStyles__StyledNoOptions",
111
+ componentId: "avbhl8-4"
112
+ })([ "&[disabled],&[aria-disabled='true']{color:", ";}" ], y.variables.contentColorDefault);
113
+ var M = m()(p()).withConfig({
114
+ displayName: "ResultsMenuStyles__StyledWait",
115
+ componentId: "avbhl8-5"
116
+ })([ "flex:0 0 auto;" ]);
117
+ var w = m().div.withConfig({
118
+ displayName: "ResultsMenuStyles__StyledLoadingMessage",
119
+ componentId: "avbhl8-6"
120
+ })([ "flex:1 0 0;color:", ";" ], y.variables.contentColorDefault);
121
+ // CONCATENATED MODULE: ./src/utils/updateReactRef.ts
122
+ /**
241
123
  * Updates a React ref. Callback refs and object refs (from `createRef` and `useRef`) are supported.
242
124
  *
243
125
  * @param ref - The React callback or object ref. Can be `null` or `undefined`.
244
126
  * @param current - The new value of the ref.
245
127
  */
246
- function M(e, r) {
247
- if (e) {
248
- if (typeof e === "function") {
249
- e(r);
250
- } else {
251
- // the public signature of this util uses React.Ref<T> to mirror the way React types refs.
252
- // the intention here is to signal "we will take care of setting 'current', not you".
253
- e.current = r;
128
+ function C(e, r) {
129
+ if (e) {
130
+ if (typeof e === "function") {
131
+ e(r);
132
+ } else {
133
+ // the public signature of this util uses React.Ref<T> to mirror the way React types refs.
134
+ // the intention here is to signal "we will take care of setting 'current', not you".
135
+ e.current = r;
254
136
  // eslint-disable-line no-param-reassign
255
- }
256
- }
137
+ }
257
138
  }
258
- // CONCATENATED MODULE: ./src/ResultsMenu/ResultsMenu.tsx
259
- function C() {
260
- return C = Object.assign ? Object.assign.bind() : function(e) {
261
- for (var r = 1; r < arguments.length; r++) {
262
- var n = arguments[r];
263
- for (var t in n) {
264
- ({}).hasOwnProperty.call(n, t) && (e[t] = n[t]);
265
- }
139
+ }
140
+ // CONCATENATED MODULE: ./src/ResultsMenu/ResultsMenu.tsx
141
+ function k() {
142
+ return k = Object.assign ? Object.assign.bind() : function(e) {
143
+ for (var r = 1; r < arguments.length; r++) {
144
+ var n = arguments[r];
145
+ for (var t in n) {
146
+ ({}).hasOwnProperty.call(n, t) && (e[t] = n[t]);
266
147
  }
267
- return e;
268
- }, C.apply(null, arguments);
269
- }
270
- function j(e, r) {
271
- return P(e) || I(e, r) || R(e, r) || x();
272
- }
273
- function x() {
274
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
275
- }
276
- function R(e, r) {
277
- if (e) {
278
- if ("string" == typeof e) return k(e, r);
279
- var n = {}.toString.call(e).slice(8, -1);
280
- return "Object" === n && e.constructor && (n = e.constructor.name), "Map" === n || "Set" === n ? Array.from(e) : "Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? k(e, r) : void 0;
281
148
  }
149
+ return e;
150
+ }, k.apply(null, arguments);
151
+ }
152
+ function j(e, r) {
153
+ return A(e) || x(e, r) || R(e, r) || I();
154
+ }
155
+ function I() {
156
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
157
+ }
158
+ function R(e, r) {
159
+ if (e) {
160
+ if ("string" == typeof e) return P(e, r);
161
+ var n = {}.toString.call(e).slice(8, -1);
162
+ return "Object" === n && e.constructor && (n = e.constructor.name), "Map" === n || "Set" === n ? Array.from(e) : "Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? P(e, r) : void 0;
282
163
  }
283
- function k(e, r) {
284
- (null == r || r > e.length) && (r = e.length);
285
- for (var n = 0, t = Array(r); n < r; n++) {
286
- t[n] = e[n];
287
- }
288
- return t;
164
+ }
165
+ function P(e, r) {
166
+ (null == r || r > e.length) && (r = e.length);
167
+ for (var n = 0, t = Array(r); n < r; n++) {
168
+ t[n] = e[n];
289
169
  }
290
- function I(e, r) {
291
- var n = null == e ? null : "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"];
292
- if (null != n) {
293
- var t, o, a, i, l = [], u = !0, c = !1;
170
+ return t;
171
+ }
172
+ function x(e, r) {
173
+ var n = null == e ? null : "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"];
174
+ if (null != n) {
175
+ var t, o, a, i, u = [], l = !0, c = !1;
176
+ try {
177
+ if (a = (n = n.call(e)).next, 0 === r) {
178
+ if (Object(n) !== n) return;
179
+ l = !1;
180
+ } else for (;!(l = (t = a.call(n)).done) && (u.push(t.value), u.length !== r); l = !0) {
181
+ }
182
+ } catch (e) {
183
+ c = !0, o = e;
184
+ } finally {
294
185
  try {
295
- if (a = (n = n.call(e)).next, 0 === r) {
296
- if (Object(n) !== n) return;
297
- u = !1;
298
- } else for (;!(u = (t = a.call(n)).done) && (l.push(t.value), l.length !== r); u = !0) {
299
- }
300
- } catch (e) {
301
- c = !0, o = e;
186
+ if (!l && null != n["return"] && (i = n["return"](), Object(i) !== i)) return;
302
187
  } finally {
303
- try {
304
- if (!u && null != n["return"] && (i = n["return"](), Object(i) !== i)) return;
305
- } finally {
306
- if (c) throw o;
307
- }
188
+ if (c) throw o;
308
189
  }
309
- return l;
310
190
  }
191
+ return u;
311
192
  }
312
- function P(e) {
313
- if (Array.isArray(e)) return e;
314
- }
315
- function T(e, r) {
316
- if (null == e) return {};
317
- var n, t, o = A(e, r);
318
- if (Object.getOwnPropertySymbols) {
319
- var a = Object.getOwnPropertySymbols(e);
320
- for (t = 0; t < a.length; t++) {
321
- n = a[t], -1 === r.indexOf(n) && {}.propertyIsEnumerable.call(e, n) && (o[n] = e[n]);
322
- }
193
+ }
194
+ function A(e) {
195
+ if (Array.isArray(e)) return e;
196
+ }
197
+ function T(e, r) {
198
+ if (null == e) return {};
199
+ var n, t, o = L(e, r);
200
+ if (Object.getOwnPropertySymbols) {
201
+ var a = Object.getOwnPropertySymbols(e);
202
+ for (t = 0; t < a.length; t++) {
203
+ n = a[t], -1 === r.indexOf(n) && {}.propertyIsEnumerable.call(e, n) && (o[n] = e[n]);
323
204
  }
324
- return o;
325
205
  }
326
- function A(e, r) {
327
- if (null == e) return {};
328
- var n = {};
329
- for (var t in e) {
330
- if ({}.hasOwnProperty.call(e, t)) {
331
- if (-1 !== r.indexOf(t)) continue;
332
- n[t] = e[t];
333
- }
206
+ return o;
207
+ }
208
+ function L(e, r) {
209
+ if (null == e) return {};
210
+ var n = {};
211
+ for (var t in e) {
212
+ if ({}.hasOwnProperty.call(e, t)) {
213
+ if (-1 !== r.indexOf(t)) continue;
214
+ n[t] = e[t];
334
215
  }
335
- return n;
336
216
  }
337
- var L = {
338
- animateLoading: a().bool,
339
- children: a().node,
340
- childrenStart: a().node,
341
- elementRef: a().oneOfType([ a().func, a().object ]),
342
- focusMode: a().oneOf([ "roving", "normal", "never" ]),
343
- footerMessage: a().node,
344
- isLoading: a().bool,
345
- loadingMessage: a().node,
346
- menuId: a().string,
347
- noOptionsMessage: a().node,
348
- onScroll: a().func,
349
- onScrollBottom: a().func,
350
- placement: a().string
351
- };
352
- var _ = (0, s._)("Loading...");
353
- var q = (0, s._)("No matches");
354
- // The remaining amount of pixels when scrolled from bottom of menu to trigger onScrollBottom().
355
- var N = 400;
356
- var D = 28;
357
- function H(n) {
358
- var t = n.animateLoading, o = n["aria-multiselectable"], a = n.children, i = n.childrenStart, c = n.elementRef, s = n.focusMode, f = n.footerMessage, v = n.isLoading, d = n.labelledBy, m = n.loadingMessage, p = m === void 0 ? _ : m, x = n.menuId, R = n.noOptionsMessage, k = R === void 0 ? q : R, I = n.onScroll, P = n.onScrollBottom, A = n.placement, L = n.style, H = n.tabIndex, F = T(n, [ "animateLoading", "aria-multiselectable", "children", "childrenStart", "elementRef", "focusMode", "footerMessage", "isLoading", "labelledBy", "loadingMessage", "menuId", "noOptionsMessage", "onScroll", "onScrollBottom", "placement", "style", "tabIndex" ]);
359
- // @docs-props-type ResultsMenuPropsBase
360
- var B = (0, e.useState)(undefined), U = j(B, 2), z = U[0], V = U[1];
361
- var K = (0, e.useState)(null), W = j(K, 2), $ = W[0], G = W[1];
362
- var X = (0, e.useState)(null), J = j(X, 2), Q = J[0], Y = J[1];
363
- var Z = (0, e.useState)(0), ee = j(Z, 2), re = ee[0], ne = ee[1];
364
- var te = (0, e.useState)(0), oe = j(te, 2), ae = oe[0], ie = oe[1];
365
- var le = (0, e.useState)(false), ue = j(le, 2), ce = ue[0], se = ue[1];
366
- var fe = (0, e.useCallback)((function(e) {
367
- Y(e);
368
- }), []);
369
- var ve = (0, e.useCallback)((function(e) {
370
- G(e);
371
- M(c, e);
372
- }), [ c ]);
373
- var de = (0, e.useCallback)((function() {
374
- ie(document.documentElement.scrollTop);
375
- }), []);
376
- var me = (0, e.useCallback)((function() {
377
- ie(document.documentElement.scrollTop);
378
- }), []);
379
- var pe = (0, e.useCallback)((function(e) {
380
- // Safety net to ensure window doesn't scroll if menu is scrolled pass the numberOfItemsLoaded at high velocity.
381
- e.stopPropagation();
382
- document.documentElement.scrollTop = ae;
383
- }), [ ae ]);
384
- var be = (0, e.useCallback)((function() {
385
- return !!Q && Q.scrollHeight === Q.offsetHeight;
386
- }), [ Q ]);
387
- var ye = (0, e.useCallback)((function(e) {
388
- if (!ce) {
389
- se(true);
390
- P === null || P === void 0 ? void 0 : P(e);
391
- }
392
- }), [ ce, P ]);
393
- var ge = (0, e.useCallback)((function(e) {
394
- if (P && e.target && Q) {
395
- var r = Q.scrollHeight - Q.offsetHeight - N;
396
- // Adding 1 due to border of menu item.
397
- if (Q.scrollTop + 1 >= r) {
398
- ye(e);
399
- }
400
- }
401
- I === null || I === void 0 ? void 0 : I(e);
402
- }), [ ye, Q, I, P ]);
403
- var he = (0, e.useCallback)((function() {
404
- var r = e.Children.count(a);
405
- // If menu is full length, load more items.
406
- if (be()) {
407
- ye(null);
408
- }
409
- // Avoid triggering this logic if this.state.childrenCount is null
410
- // because that's not a real change in the number of children
411
- // and thus we want to avoid resetting the value of scrollBottomTriggered
412
- if (z != null && r !== z) {
413
- ne(r - (z !== null && z !== void 0 ? z : 0));
414
- se(false);
415
- }
416
- if (r !== z) {
417
- V(r);
418
- }
419
- }), [ be, a, z, ye ]);
420
- (0, e.useEffect)((function() {
421
- if (!$ || !Q) {
422
- return;
423
- }
424
- // If onScrollBottom is defined, determine if it should be triggered.
425
- if (P && a) {
426
- he();
217
+ return n;
218
+ }
219
+ var _ = {
220
+ animateLoading: a().bool,
221
+ children: a().node,
222
+ childrenStart: a().node,
223
+ elementRef: a().oneOfType([ a().func, a().object ]),
224
+ focusMode: a().oneOf([ "roving", "normal", "never" ]),
225
+ footerMessage: a().node,
226
+ isLoading: a().bool,
227
+ loadingMessage: a().node,
228
+ menuId: a().string,
229
+ noOptionsMessage: a().node,
230
+ onScroll: a().func,
231
+ onScrollBottom: a().func,
232
+ placement: a().string
233
+ };
234
+ var q = (0, d._)("Loading...");
235
+ var D = (0, d._)("No matches");
236
+ // The remaining amount of pixels when scrolled from bottom of menu to trigger onScrollBottom().
237
+ var N = 400;
238
+ var H = 28;
239
+ function F(e) {
240
+ var r = e.animateLoading, o = e["aria-multiselectable"], a = e.children, i = e.childrenStart, c = e.elementRef, s = e.focusMode, d = e.footerMessage, v = e.isLoading, m = e.labelledBy, b = e.loadingMessage, p = b === void 0 ? q : b, y = e.menuId, I = e.noOptionsMessage, R = I === void 0 ? D : I, P = e.onScroll, x = e.onScrollBottom, A = e.placement, L = e.style, _ = e.tabIndex, F = T(e, [ "animateLoading", "aria-multiselectable", "children", "childrenStart", "elementRef", "focusMode", "footerMessage", "isLoading", "labelledBy", "loadingMessage", "menuId", "noOptionsMessage", "onScroll", "onScrollBottom", "placement", "style", "tabIndex" ]);
241
+ // @docs-props-type ResultsMenuPropsBase
242
+ var B = (0, n.useState)(undefined), U = j(B, 2), z = U[0], V = U[1];
243
+ var K = (0, n.useState)(null), W = j(K, 2), $ = W[0], G = W[1];
244
+ var X = (0, n.useState)(null), J = j(X, 2), Q = J[0], Y = J[1];
245
+ var Z = (0, n.useState)(0), ee = j(Z, 2), re = ee[0], ne = ee[1];
246
+ var te = (0, n.useState)(0), oe = j(te, 2), ae = oe[0], ie = oe[1];
247
+ var ue = (0, n.useState)(false), le = j(ue, 2), ce = le[0], se = le[1];
248
+ var fe = (0, n.useCallback)((function(e) {
249
+ Y(e);
250
+ }), []);
251
+ var de = (0, n.useCallback)((function(e) {
252
+ G(e);
253
+ C(c, e);
254
+ }), [ c ]);
255
+ var ve = (0, n.useCallback)((function() {
256
+ ie(document.documentElement.scrollTop);
257
+ }), []);
258
+ var me = (0, n.useCallback)((function() {
259
+ ie(document.documentElement.scrollTop);
260
+ }), []);
261
+ var be = (0, n.useCallback)((function(e) {
262
+ // Safety net to ensure window doesn't scroll if menu is scrolled pass the numberOfItemsLoaded at high velocity.
263
+ e.stopPropagation();
264
+ document.documentElement.scrollTop = ae;
265
+ }), [ ae ]);
266
+ var pe = (0, n.useCallback)((function() {
267
+ return !!Q && Q.scrollHeight === Q.offsetHeight;
268
+ }), [ Q ]);
269
+ var ye = (0, n.useCallback)((function(e) {
270
+ if (!ce) {
271
+ se(true);
272
+ x === null || x === void 0 ? void 0 : x(e);
273
+ }
274
+ }), [ ce, x ]);
275
+ var ge = (0, n.useCallback)((function(e) {
276
+ if (x && e.target && Q) {
277
+ var r = Q.scrollHeight - Q.offsetHeight - N;
278
+ // Adding 1 due to border of menu item.
279
+ if (Q.scrollTop + 1 >= r) {
280
+ ye(e);
427
281
  }
428
- }), [ $, Q, a, P, he ]);
429
- // Assumption: that you cannot be filtered if you are a result
430
- var Se = e.Children.toArray(a).filter(e.isValidElement).some((function(e) {
431
- var r = e.type;
432
- return !(r.as === "Divider" && r.filterFirst || (r.as === "Divider" || r.as === "Heading") && (r.filterLast || r.filterConsecutive));
433
- }));
434
- var Ee = be();
435
- var Oe = (0, e.useMemo)((function() {
436
- return {
437
- height: ce ? re * D : 0
438
- };
439
- }), [ ce, re ]);
440
- var we = !Se && !!k && !v;
441
- var Me = (0, e.useCallback)((function() {
442
- return {
443
- role: "listbox",
444
- preventFocus: s === "never"
445
- };
446
- }), [ s ]);
447
- var Ce = (0, e.useCallback)((function() {
448
- var n = !!e.Children.toArray(a).length;
449
- return f && n && r().createElement(r().Fragment, null, A !== "above" && r().createElement(l(), null), r().createElement(g, {
450
- "data-test": "footer-message",
451
- key: "footer"
452
- }, f), A === "above" && r().createElement(l(), null));
453
- }), [ f, a, A ]);
454
-
455
- return r().createElement(y, C({
456
- "data-test": "results-menu",
457
- key: "wrapper",
458
- ref: ve,
459
- onWheel: P ? pe : undefined,
460
- onMouseEnter: P ? de : undefined,
461
- onMouseLeave: P ? me : undefined
462
- }, F, {
463
- style: L
464
- }), A !== "above" && i, A === "above" && Ce(), r().createElement(u.MenuContext.Provider, {
465
- value: Me()
466
- }, r().createElement(b, {
467
- "aria-multiselectable": o,
468
- "aria-labelledby": d,
469
- elementRef: fe,
470
- focusMode: s,
471
- id: x,
472
- key: "menu",
473
- onScroll: ge,
474
- stopScrollPropagation: true,
475
- tabIndex: H
476
- }, we && r().createElement(S, {
477
- "data-test": "no-results-message",
478
- disabled: true
479
- }, k), a, P && !Ee &&
480
-
481
- // Bottom spacer fills in the space of new items being loaded by using the minimum possible height x menuItems.
482
- r().createElement("div", {
483
- "data-test": "results-menu-bottom-spacer",
484
- style: Oe
485
- }), v && r().createElement(h, null, t && r().createElement(E, null), r().createElement(O, null, p)))), r().createElement(w["default"], {
486
- "aria-live": "polite"
487
- }, we && k), A !== "above" && Ce(), A === "above" && i);
488
- }
489
- H.propTypes = L;
490
- /* harmony default export */ const F = H;
491
- // CONCATENATED MODULE: external "lodash/omit"
492
- const B = require("lodash/omit");
493
- var U = n.n(B);
494
- // CONCATENATED MODULE: external "@splunk/ui-utils/focus"
495
- const z = require("@splunk/ui-utils/focus");
496
- // CONCATENATED MODULE: ./src/ResultsMenu/VirtualizedResultsMenu/groupChildren.ts
497
- // Cheap(er than processing potentially thousands of array elements) memoization
498
- var V = {
499
- result: []
500
- };
501
- /**
282
+ }
283
+ P === null || P === void 0 ? void 0 : P(e);
284
+ }), [ ye, Q, P, x ]);
285
+ var he = (0, n.useCallback)((function() {
286
+ var e = n.Children.count(a);
287
+ // If menu is full length, load more items.
288
+ if (pe()) {
289
+ ye(null);
290
+ }
291
+ // Avoid triggering this logic if this.state.childrenCount is null
292
+ // because that's not a real change in the number of children
293
+ // and thus we want to avoid resetting the value of scrollBottomTriggered
294
+ if (z != null && e !== z) {
295
+ ne(e - (z !== null && z !== void 0 ? z : 0));
296
+ se(false);
297
+ }
298
+ if (e !== z) {
299
+ V(e);
300
+ }
301
+ }), [ pe, a, z, ye ]);
302
+ (0, n.useEffect)((function() {
303
+ if (!$ || !Q) {
304
+ return;
305
+ }
306
+ // If onScrollBottom is defined, determine if it should be triggered.
307
+ if (x && a) {
308
+ he();
309
+ }
310
+ }), [ $, Q, a, x, he ]);
311
+ // Assumption: that you cannot be filtered if you are a result
312
+ var Se = n.Children.toArray(a).filter(n.isValidElement).some((function(e) {
313
+ var r = e.type;
314
+ return !(r.as === "Divider" && r.filterFirst || (r.as === "Divider" || r.as === "Heading") && (r.filterLast || r.filterConsecutive));
315
+ }));
316
+ var Ee = pe();
317
+ var Oe = (0, n.useMemo)((function() {
318
+ return {
319
+ height: ce ? re * H : 0
320
+ };
321
+ }), [ ce, re ]);
322
+ var Me = !Se && !!R && !v;
323
+ var we = (0, n.useCallback)((function() {
324
+ return {
325
+ role: "listbox",
326
+ preventFocus: s === "never"
327
+ };
328
+ }), [ s ]);
329
+ var Ce = (0, n.useCallback)((function() {
330
+ var e = !!n.Children.toArray(a).length;
331
+ return d && e && t().createElement(t().Fragment, null, A !== "above" && t().createElement(u(), null), t().createElement(S, {
332
+ "data-test": "footer-message",
333
+ key: "footer"
334
+ }, d), A === "above" && t().createElement(u(), null));
335
+ }), [ d, a, A ]);
336
+
337
+ return t().createElement(h, k({
338
+ "data-test": "results-menu",
339
+ key: "wrapper",
340
+ ref: de,
341
+ onWheel: x ? be : undefined,
342
+ onMouseEnter: x ? ve : undefined,
343
+ onMouseLeave: x ? me : undefined
344
+ }, F, {
345
+ style: L
346
+ }), A !== "above" && i, A === "above" && Ce(), t().createElement(l.MenuContext.Provider, {
347
+ value: we()
348
+ }, t().createElement(g, {
349
+ "aria-multiselectable": o,
350
+ "aria-labelledby": m,
351
+ elementRef: fe,
352
+ focusMode: s,
353
+ id: y,
354
+ key: "menu",
355
+ onScroll: ge,
356
+ stopScrollPropagation: true,
357
+ tabIndex: _
358
+ }, Me && t().createElement(O, {
359
+ "data-test": "no-results-message",
360
+ disabled: true
361
+ }, R), a, x && !Ee &&
362
+
363
+ // Bottom spacer fills in the space of new items being loaded by using the minimum possible height x menuItems.
364
+ t().createElement("div", {
365
+ "data-test": "results-menu-bottom-spacer",
366
+ style: Oe
367
+ }), v && t().createElement(E, null, r && t().createElement(M, null), t().createElement(w, null, p)))), t().createElement(f(), {
368
+ "aria-live": "polite"
369
+ }, Me && R), A !== "above" && Ce(), A === "above" && i);
370
+ }
371
+ F.propTypes = _;
372
+ /* harmony default export */ const B = F;
373
+ // CONCATENATED MODULE: external "lodash/omit"
374
+ const U = require("lodash/omit");
375
+ var z = e.n(U);
376
+ // CONCATENATED MODULE: external "@splunk/ui-utils/focus"
377
+ const V = require("@splunk/ui-utils/focus");
378
+ // CONCATENATED MODULE: ./src/ResultsMenu/VirtualizedResultsMenu/groupChildren.ts
379
+ // Cheap(er than processing potentially thousands of array elements) memoization
380
+ var K = {
381
+ result: []
382
+ };
383
+ /**
502
384
  * Given component children, restructure them into an array of arrays, each of length `groupSize`.
503
385
  *
504
386
  * The last array is not guaranteed to be full, it will have a length in the range `[1, groupSize]`
@@ -512,263 +394,264 @@
512
394
  * @param {number} groupSize The size of each group to be created
513
395
  * @returns A 2d array where each inner-array is a group of size `groupSize` of children
514
396
  * and the order of the `children` received equals the order of the flattened result
515
- */ var K = function r(n, t) {
516
- if (V.children === n && V.groupSize === t) {
517
- return V.result;
518
- }
519
- V.children = n;
520
- V.groupSize = t;
521
- if (t <= 1) {
522
- if (false) {}
523
- // don't break in non-__DEV__ and return one big group
524
- V.result = [ e.Children.toArray(n) ];
525
- } else {
526
- V.result = e.Children.toArray(n).reduce((function(e, r, n) {
527
- var o = Math.floor(n / t);
528
- if (!Array.isArray(e[o])) {
529
- // eslint-disable-next-line no-param-reassign
530
- e[o] = [];
531
- }
532
- e[o].push(r);
533
- return e;
534
- }), []);
397
+ */ var W = function e(r, t) {
398
+ if (K.children === r && K.groupSize === t) {
399
+ return K.result;
400
+ }
401
+ K.children = r;
402
+ K.groupSize = t;
403
+ if (t <= 1) {
404
+ if (false) {}
405
+ // don't break in non-__DEV__ and return one big group
406
+ K.result = [ n.Children.toArray(r) ];
407
+ } else {
408
+ K.result = n.Children.toArray(r).reduce((function(e, r, n) {
409
+ var o = Math.floor(n / t);
410
+ if (!Array.isArray(e[o])) {
411
+ // eslint-disable-next-line no-param-reassign
412
+ e[o] = [];
413
+ }
414
+ e[o].push(r);
415
+ return e;
416
+ }), []);
417
+ }
418
+ return K.result;
419
+ };
420
+ // CONCATENATED MODULE: external "@splunk/ui-utils/id"
421
+ const $ = require("@splunk/ui-utils/id");
422
+ // CONCATENATED MODULE: ./src/ResultsMenu/VirtualizedResultsMenu/VirtualizedItem.ts
423
+ // This wrapper should only be used with Menu.Item/derivatives thereof, so omitting Heading/Divider is fine
424
+ var G = {
425
+ children: a().node,
426
+ onMount: a().func.isRequired,
427
+ onUnmount: a().func.isRequired
428
+ };
429
+ /** @private Used by `VirtualizedResultsMenu` */ var X = t().forwardRef((function(e, r) {
430
+ var t = e.children, o = e.onMount, a = e.onUnmount;
431
+ // @docs-props-type VirtualizedItemPropsBase
432
+ var i = (0, n.useRef)(null);
433
+ (0, n.useEffect)((function() {
434
+ var e = i.current;
435
+ if (e) {
436
+ o(e);
535
437
  }
536
- return V.result;
537
- };
538
- // CONCATENATED MODULE: external "@splunk/ui-utils/id"
539
- const W = require("@splunk/ui-utils/id");
540
- // CONCATENATED MODULE: ./src/ResultsMenu/VirtualizedResultsMenu/VirtualizedItem.ts
541
- // This wrapper should only be used with Menu.Item/derivatives thereof, so omitting Heading/Divider is fine
542
- var $ = {
543
- children: a().node,
544
- onMount: a().func.isRequired,
545
- onUnmount: a().func.isRequired
546
- };
547
- /** @private Used by `VirtualizedResultsMenu` */ var G = r().forwardRef((function(r, n) {
548
- var t = r.children, o = r.onMount, a = r.onUnmount;
549
- // @docs-props-type VirtualizedItemPropsBase
550
- var i = (0, e.useRef)(null);
551
- (0, e.useEffect)((function() {
552
- var e = i.current;
438
+ return function() {
553
439
  if (e) {
554
- o(e);
440
+ a(e);
555
441
  }
556
- return function() {
557
- if (e) {
558
- a(e);
559
- }
560
- };
561
- }), [ o, a ]);
562
- var l = e.Children.only(t);
563
- if (!l) {
564
- if (false) {}
565
- return null;
442
+ };
443
+ }), [ o, a ]);
444
+ var u = n.Children.only(t);
445
+ if (!u) {
446
+ if (false) {}
447
+ return null;
448
+ }
449
+
450
+ return (0, n.cloneElement)(u, {
451
+ elementRef: function e(n) {
452
+ i.current = n;
453
+ C(r, n);
566
454
  }
567
-
568
- return (0, e.cloneElement)(l, {
569
- elementRef: function e(r) {
570
- i.current = r;
571
- M(n, r);
572
- }
573
- });
574
- }));
575
- G.propTypes = $;
576
- G.as = "Item";
577
- // CONCATENATED MODULE: ./src/ResultsMenu/VirtualizedResultsMenu/injectVirtualizedItem.tsx
578
- /**
455
+ });
456
+ }));
457
+ X.propTypes = G;
458
+ X.as = "Item";
459
+ // CONCATENATED MODULE: ./src/ResultsMenu/VirtualizedResultsMenu/injectVirtualizedItem.tsx
460
+ /**
579
461
  * Find the index of an array element which is nearest to targetIndex and is a Menu.Item component
580
462
  * @param {Array} elements An array to search
581
463
  * @param {Number} targetIndex The target index. This is the ideal value to return.
582
464
  * @returns The index in the array of the nearest `Menu.Item` component to `targetIndex`, or -1 if no element is a `Menu.Item` component
583
465
  */
584
- var X = function e(r, n) {
585
- var t = -1;
586
- var o = -1;
587
- r.forEach((function(e, r) {
588
- var a = Math.abs(n - r);
589
- if (t >= 0 && t < a) {
590
- return;
591
- }
592
- if (e.type !== u.Divider && e.type !== u.Heading) {
593
- t = a;
594
- o = r;
595
- }
596
- }));
597
- return o;
598
- };
599
- /**
466
+ var J = function e(r, n) {
467
+ var t = -1;
468
+ var o = -1;
469
+ r.forEach((function(e, r) {
470
+ var a = Math.abs(n - r);
471
+ if (t >= 0 && t < a) {
472
+ return;
473
+ }
474
+ if (e.type !== l.Divider && e.type !== l.Heading) {
475
+ t = a;
476
+ o = r;
477
+ }
478
+ }));
479
+ return o;
480
+ };
481
+ /**
600
482
  * @private Keep the injection of `VirtualizedItem` DRY. Will always replace the middle-most non-divider/heading
601
483
  * with a VirtualizedItem instance.
602
484
  * - If `trackFirstElement` the **FIRST** non-divider/heading item will also be replaced.
603
485
  * - If `trackLastElement` the **LAST** non-divider/heading item will also be replaced.
604
- */ var J = function e(n, t, o) {
605
- var a = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}, i = a.trackFirstElement, l = a.trackLastElement;
606
- if (!Array.isArray(n)) {
607
- return [];
608
- }
609
- var u = X(n, Math.floor(n.length / 2));
610
- var c = i && X(n, 0);
611
- var s = l && X(n, n.length - 1);
612
- return n.map((function(e, n) {
613
- if (n === u || n === c || n === s) {
614
-
615
- return r().createElement(G, {
616
- key: (0, W.createGUID)(),
617
- onMount: t,
618
- onUnmount: o
619
- }, e);
620
- }
621
- return e;
622
- }));
623
- };
624
- // CONCATENATED MODULE: ./src/ResultsMenu/VirtualizedResultsMenu/VirtualizedResultsMenu.tsx
625
- function Q(e) {
626
- "@babel/helpers - typeof";
627
- return Q = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
628
- return typeof e;
629
- } : function(e) {
630
- return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
631
- }, Q(e);
632
- }
633
- function Y() {
634
- return Y = Object.assign ? Object.assign.bind() : function(e) {
635
- for (var r = 1; r < arguments.length; r++) {
636
- var n = arguments[r];
637
- for (var t in n) {
638
- ({}).hasOwnProperty.call(n, t) && (e[t] = n[t]);
639
- }
640
- }
641
- return e;
642
- }, Y.apply(null, arguments);
486
+ */ var Q = function e(r, n, o) {
487
+ var a = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}, i = a.trackFirstElement, u = a.trackLastElement;
488
+ if (!Array.isArray(r)) {
489
+ return [];
643
490
  }
644
- function Z(e) {
645
- return ne(e) || re(e) || ae(e) || ee();
646
- }
647
- function ee() {
648
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
649
- }
650
- function re(e) {
651
- if ("undefined" != typeof Symbol && null != e[Symbol.iterator] || null != e["@@iterator"]) return Array.from(e);
652
- }
653
- function ne(e) {
654
- if (Array.isArray(e)) return ie(e);
655
- }
656
- function te(e, r) {
657
- return ue(e) || le(e, r) || ae(e, r) || oe();
658
- }
659
- function oe() {
660
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
661
- }
662
- function ae(e, r) {
663
- if (e) {
664
- if ("string" == typeof e) return ie(e, r);
665
- var n = {}.toString.call(e).slice(8, -1);
666
- return "Object" === n && e.constructor && (n = e.constructor.name), "Map" === n || "Set" === n ? Array.from(e) : "Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? ie(e, r) : void 0;
491
+ var l = J(r, Math.floor(r.length / 2));
492
+ var c = i && J(r, 0);
493
+ var s = u && J(r, r.length - 1);
494
+ return r.map((function(e, r) {
495
+ if (r === l || r === c || r === s) {
496
+
497
+ return t().createElement(X, {
498
+ key: (0, $.createGUID)(),
499
+ onMount: n,
500
+ onUnmount: o
501
+ }, e);
667
502
  }
668
- }
669
- function ie(e, r) {
670
- (null == r || r > e.length) && (r = e.length);
671
- for (var n = 0, t = Array(r); n < r; n++) {
672
- t[n] = e[n];
673
- }
674
- return t;
675
- }
676
- function le(e, r) {
677
- var n = null == e ? null : "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"];
678
- if (null != n) {
679
- var t, o, a, i, l = [], u = !0, c = !1;
680
- try {
681
- if (a = (n = n.call(e)).next, 0 === r) {
682
- if (Object(n) !== n) return;
683
- u = !1;
684
- } else for (;!(u = (t = a.call(n)).done) && (l.push(t.value), l.length !== r); u = !0) {
685
- }
686
- } catch (e) {
687
- c = !0, o = e;
688
- } finally {
689
- try {
690
- if (!u && null != n["return"] && (i = n["return"](), Object(i) !== i)) return;
691
- } finally {
692
- if (c) throw o;
693
- }
503
+ return e;
504
+ }));
505
+ };
506
+ // CONCATENATED MODULE: ./src/ResultsMenu/VirtualizedResultsMenu/VirtualizedResultsMenu.tsx
507
+ function Y(e) {
508
+ "@babel/helpers - typeof";
509
+ return Y = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
510
+ return typeof e;
511
+ } : function(e) {
512
+ return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
513
+ }, Y(e);
514
+ }
515
+ function Z() {
516
+ return Z = Object.assign ? Object.assign.bind() : function(e) {
517
+ for (var r = 1; r < arguments.length; r++) {
518
+ var n = arguments[r];
519
+ for (var t in n) {
520
+ ({}).hasOwnProperty.call(n, t) && (e[t] = n[t]);
694
521
  }
695
- return l;
696
522
  }
523
+ return e;
524
+ }, Z.apply(null, arguments);
525
+ }
526
+ function ee(e) {
527
+ return te(e) || ne(e) || ie(e) || re();
528
+ }
529
+ function re() {
530
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
531
+ }
532
+ function ne(e) {
533
+ if ("undefined" != typeof Symbol && null != e[Symbol.iterator] || null != e["@@iterator"]) return Array.from(e);
534
+ }
535
+ function te(e) {
536
+ if (Array.isArray(e)) return ue(e);
537
+ }
538
+ function oe(e, r) {
539
+ return ce(e) || le(e, r) || ie(e, r) || ae();
540
+ }
541
+ function ae() {
542
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
543
+ }
544
+ function ie(e, r) {
545
+ if (e) {
546
+ if ("string" == typeof e) return ue(e, r);
547
+ var n = {}.toString.call(e).slice(8, -1);
548
+ return "Object" === n && e.constructor && (n = e.constructor.name), "Map" === n || "Set" === n ? Array.from(e) : "Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? ue(e, r) : void 0;
697
549
  }
698
- function ue(e) {
699
- if (Array.isArray(e)) return e;
550
+ }
551
+ function ue(e, r) {
552
+ (null == r || r > e.length) && (r = e.length);
553
+ for (var n = 0, t = Array(r); n < r; n++) {
554
+ t[n] = e[n];
700
555
  }
701
- function ce(e, r) {
702
- if (null == e) return {};
703
- var n, t, o = se(e, r);
704
- if (Object.getOwnPropertySymbols) {
705
- var a = Object.getOwnPropertySymbols(e);
706
- for (t = 0; t < a.length; t++) {
707
- n = a[t], -1 === r.indexOf(n) && {}.propertyIsEnumerable.call(e, n) && (o[n] = e[n]);
556
+ return t;
557
+ }
558
+ function le(e, r) {
559
+ var n = null == e ? null : "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"];
560
+ if (null != n) {
561
+ var t, o, a, i, u = [], l = !0, c = !1;
562
+ try {
563
+ if (a = (n = n.call(e)).next, 0 === r) {
564
+ if (Object(n) !== n) return;
565
+ l = !1;
566
+ } else for (;!(l = (t = a.call(n)).done) && (u.push(t.value), u.length !== r); l = !0) {
708
567
  }
709
- }
710
- return o;
711
- }
712
- function se(e, r) {
713
- if (null == e) return {};
714
- var n = {};
715
- for (var t in e) {
716
- if ({}.hasOwnProperty.call(e, t)) {
717
- if (-1 !== r.indexOf(t)) continue;
718
- n[t] = e[t];
568
+ } catch (e) {
569
+ c = !0, o = e;
570
+ } finally {
571
+ try {
572
+ if (!l && null != n["return"] && (i = n["return"](), Object(i) !== i)) return;
573
+ } finally {
574
+ if (c) throw o;
719
575
  }
720
576
  }
721
- return n;
577
+ return u;
722
578
  }
723
- function fe(e, r) {
724
- var n = Object.keys(e);
725
- if (Object.getOwnPropertySymbols) {
726
- var t = Object.getOwnPropertySymbols(e);
727
- r && (t = t.filter((function(r) {
728
- return Object.getOwnPropertyDescriptor(e, r).enumerable;
729
- }))), n.push.apply(n, t);
579
+ }
580
+ function ce(e) {
581
+ if (Array.isArray(e)) return e;
582
+ }
583
+ function se(e, r) {
584
+ if (null == e) return {};
585
+ var n, t, o = fe(e, r);
586
+ if (Object.getOwnPropertySymbols) {
587
+ var a = Object.getOwnPropertySymbols(e);
588
+ for (t = 0; t < a.length; t++) {
589
+ n = a[t], -1 === r.indexOf(n) && {}.propertyIsEnumerable.call(e, n) && (o[n] = e[n]);
730
590
  }
731
- return n;
732
591
  }
733
- function ve(e) {
734
- for (var r = 1; r < arguments.length; r++) {
735
- var n = null != arguments[r] ? arguments[r] : {};
736
- r % 2 ? fe(Object(n), !0).forEach((function(r) {
737
- de(e, r, n[r]);
738
- })) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : fe(Object(n)).forEach((function(r) {
739
- Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(n, r));
740
- }));
592
+ return o;
593
+ }
594
+ function fe(e, r) {
595
+ if (null == e) return {};
596
+ var n = {};
597
+ for (var t in e) {
598
+ if ({}.hasOwnProperty.call(e, t)) {
599
+ if (-1 !== r.indexOf(t)) continue;
600
+ n[t] = e[t];
741
601
  }
742
- return e;
743
602
  }
744
- function de(e, r, n) {
745
- return (r = me(r)) in e ? Object.defineProperty(e, r, {
746
- value: n,
747
- enumerable: !0,
748
- configurable: !0,
749
- writable: !0
750
- }) : e[r] = n, e;
603
+ return n;
604
+ }
605
+ function de(e, r) {
606
+ var n = Object.keys(e);
607
+ if (Object.getOwnPropertySymbols) {
608
+ var t = Object.getOwnPropertySymbols(e);
609
+ r && (t = t.filter((function(r) {
610
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
611
+ }))), n.push.apply(n, t);
751
612
  }
752
- function me(e) {
753
- var r = pe(e, "string");
754
- return "symbol" == Q(r) ? r : r + "";
613
+ return n;
614
+ }
615
+ function ve(e) {
616
+ for (var r = 1; r < arguments.length; r++) {
617
+ var n = null != arguments[r] ? arguments[r] : {};
618
+ r % 2 ? de(Object(n), !0).forEach((function(r) {
619
+ me(e, r, n[r]);
620
+ })) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : de(Object(n)).forEach((function(r) {
621
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(n, r));
622
+ }));
755
623
  }
756
- function pe(e, r) {
757
- if ("object" != Q(e) || !e) return e;
758
- var n = e[Symbol.toPrimitive];
759
- if (void 0 !== n) {
760
- var t = n.call(e, r || "default");
761
- if ("object" != Q(t)) return t;
762
- throw new TypeError("@@toPrimitive must return a primitive value.");
763
- }
764
- return ("string" === r ? String : Number)(e);
624
+ return e;
625
+ }
626
+ function me(e, r, n) {
627
+ return (r = be(r)) in e ? Object.defineProperty(e, r, {
628
+ value: n,
629
+ enumerable: !0,
630
+ configurable: !0,
631
+ writable: !0
632
+ }) : e[r] = n, e;
633
+ }
634
+ function be(e) {
635
+ var r = pe(e, "string");
636
+ return "symbol" == Y(r) ? r : r + "";
637
+ }
638
+ function pe(e, r) {
639
+ if ("object" != Y(e) || !e) return e;
640
+ var n = e[Symbol.toPrimitive];
641
+ if (void 0 !== n) {
642
+ var t = n.call(e, r || "default");
643
+ if ("object" != Y(t)) return t;
644
+ throw new TypeError("@@toPrimitive must return a primitive value.");
765
645
  }
766
- // TODO(SUI-5920): add transitions to this component in React 18
767
- var be = ve(ve({}, U()(L, "onDownKeyPress", "onEndKeyPress", "onHomeKeyPress", "onUpKeyPress")), {}, {
768
- virtualization: a().number
769
- });
770
- var ye = [];
771
- /**
646
+ return ("string" === r ? String : Number)(e);
647
+ }
648
+ // eslint-disable-next-line no-relative-imports-of-published -- TODO(SUI-8190): VirtualizedResultsMenu wraps ResultsMenu, using external import creates circular dependency
649
+ // TODO(SUI-5920): add transitions to this component in React 18
650
+ var ye = ve(ve({}, z()(_, "onDownKeyPress", "onEndKeyPress", "onHomeKeyPress", "onUpKeyPress")), {}, {
651
+ virtualization: a().number
652
+ });
653
+ var ge = [];
654
+ /**
772
655
  * A wrapper for `ResultsMenu` which virtualizes the `children`. The received `children` array will be split into **"panes"** each with `virtualization` entries
773
656
  * and, at any given time, 3 or fewer of these panes will be rendered in the DOM.
774
657
  *
@@ -786,396 +669,396 @@
786
669
  * @throws in `__DEV__` when `virtualization` is too small as compared to the menu height (`virtualization` must be greater than the number of visible items in the rendered menu)
787
670
  * @throws in `__DEV__` when `virtualization` is less than or equal to 1 (`virtualization` must be ≥ 2)
788
671
  * @throws in `__DEV__` when `virtualization` is changed during the lifecycle of the `VirtualizedResultsMenu` component
789
- */ function ge(n) {
790
- var t = n.virtualization, o = t === void 0 ? 2 : t, a = n.elementRef, i = n.children, l = n.focusMode, u = l === void 0 ? "normal" : l, c = ce(n, [ "virtualization", "elementRef", "children", "focusMode" ]);
791
- // @docs-props-type VirtualizedResultsMenuPropsBase
792
- var s = (0, e.useRef)(o);
793
- // If a user tries to set virtualization to a value smaller than the number of options
794
- // visible at a given moment then the menu will flicker endlessly. This state is set in
795
- // the IntersectionObserver to fix the issue, but in `__DEV__` an error is thrown.
796
- var f = (0, e.useState)(o), v = te(f, 2), d = v[0], m = v[1];
672
+ */ function he(e) {
673
+ var r = e.virtualization, o = r === void 0 ? 2 : r, a = e.elementRef, i = e.children, u = e.focusMode, l = u === void 0 ? "normal" : u, c = se(e, [ "virtualization", "elementRef", "children", "focusMode" ]);
674
+ // @docs-props-type VirtualizedResultsMenuPropsBase
675
+ var s = (0, n.useRef)(o);
676
+ // If a user tries to set virtualization to a value smaller than the number of options
677
+ // visible at a given moment then the menu will flicker endlessly. This state is set in
678
+ // the IntersectionObserver to fix the issue, but in `__DEV__` an error is thrown.
679
+ var f = (0, n.useState)(o), d = oe(f, 2), v = d[0], m = d[1];
797
680
  // these refs keep track of whether we need to focus the first/last
798
- // element after the next render
799
- var p = (0, e.useRef)(false);
800
- var b = (0, e.useRef)(false);
801
- var y = (0, e.useRef)(i);
802
- // this code makes the "Home" and "End" keys work by injecting
803
- // an elementRef callback function into the first and last item
804
- // that will attempt to focus the first/last item if appropriate
805
- // we need to do this because if we call focus() right after changePane()
806
- // the new pane won't be in the DOM yet, so the wrong element will end up focused
807
- (0, e.useMemo)((function() {
808
- var r = e.Children.toArray(i);
809
- var n = X(r, 0);
810
- var t = X(r, r.length - 1);
811
- y.current = r.map((function(r, o) {
812
- var a = r;
813
- if (o === n) {
814
- a = (0, e.isValidElement)(r) ? (0, e.cloneElement)(r, {
815
- elementRef: function e(r) {
816
- if (p === null || p === void 0 ? void 0 : p.current) {
817
- p.current = false;
818
- r === null || r === void 0 ? void 0 : r.focus();
819
- }
681
+ // element after the next render
682
+ var b = (0, n.useRef)(false);
683
+ var p = (0, n.useRef)(false);
684
+ var y = (0, n.useRef)(i);
685
+ // this code makes the "Home" and "End" keys work by injecting
686
+ // an elementRef callback function into the first and last item
687
+ // that will attempt to focus the first/last item if appropriate
688
+ // we need to do this because if we call focus() right after changePane()
689
+ // the new pane won't be in the DOM yet, so the wrong element will end up focused
690
+ (0, n.useMemo)((function() {
691
+ var e = n.Children.toArray(i);
692
+ var r = J(e, 0);
693
+ var t = J(e, e.length - 1);
694
+ y.current = e.map((function(e, o) {
695
+ var a = e;
696
+ if (o === r) {
697
+ a = (0, n.isValidElement)(e) ? (0, n.cloneElement)(e, {
698
+ elementRef: function e(r) {
699
+ if (b === null || b === void 0 ? void 0 : b.current) {
700
+ b.current = false;
701
+ r === null || r === void 0 ? void 0 : r.focus();
820
702
  }
821
- }) : r;
822
- } else if (o === t) {
823
- a = (0, e.isValidElement)(r) ? (0, e.cloneElement)(r, {
824
- elementRef: function e(r) {
825
- if (b === null || b === void 0 ? void 0 : b.current) {
826
- b.current = false;
827
- r === null || r === void 0 ? void 0 : r.focus();
828
- }
703
+ }
704
+ }) : e;
705
+ } else if (o === t) {
706
+ a = (0, n.isValidElement)(e) ? (0, n.cloneElement)(e, {
707
+ elementRef: function e(r) {
708
+ if (p === null || p === void 0 ? void 0 : p.current) {
709
+ p.current = false;
710
+ r === null || r === void 0 ? void 0 : r.focus();
829
711
  }
830
- }) : r;
831
- }
832
- return a;
833
- }));
834
- }), [ i ]);
835
- var g = y.current;
836
- (0, e.useEffect)((function() {
837
- if (false) {}
838
- }), [ o ]);
839
- // `useRef` will recompute its initial value every render cycle.
840
- // To avoid the array processing we can provide an initialization function to useState and init the ref with the result
841
- var h = (0, e.useState)((function() {
842
- return K(g, d);
843
- })), S = te(h, 1), E = S[0];
712
+ }
713
+ }) : e;
714
+ }
715
+ return a;
716
+ }));
717
+ }), [ i ]);
718
+ var g = y.current;
719
+ (0, n.useEffect)((function() {
720
+ if (false) {}
721
+ }), [ o ]);
722
+ // `useRef` will recompute its initial value every render cycle.
723
+ // To avoid the array processing we can provide an initialization function to useState and init the ref with the result
724
+ var h = (0, n.useState)((function() {
725
+ return W(g, v);
726
+ })), S = oe(h, 1), E = S[0];
844
727
  // NOSONAR
845
- // `windowPanes` is an array of arrays, each of length `virtualization`. Each "pane" is just a subset of
846
- // `children` which will be rendered in a chunk, and at most 3 of these panes will render at any given time.
847
- var O = (0, e.useRef)(E);
848
- var w = (0, e.useRef)(0);
849
- var C = (0, e.useRef)(null);
850
- // An IntersectionObserver is used to detect when pane changes are needed.
851
- // When loadPrevPaneRef or loadNextPaneRef entries intersect the menu, the currentPaneId will be updated.
852
- var j = (0, e.useRef)();
853
- var x = (0, e.useRef)(ye);
854
- var R = (0, e.useRef)(ye);
855
- var k = (0, e.useCallback)((function() {
856
- var e;
857
- var r = O.current, n = r === void 0 ? [] : r;
858
- var t = w.current;
859
- /**
728
+ // `windowPanes` is an array of arrays, each of length `virtualization`. Each "pane" is just a subset of
729
+ // `children` which will be rendered in a chunk, and at most 3 of these panes will render at any given time.
730
+ var O = (0, n.useRef)(E);
731
+ var M = (0, n.useRef)(0);
732
+ var w = (0, n.useRef)(null);
733
+ // An IntersectionObserver is used to detect when pane changes are needed.
734
+ // When loadPrevPaneRef or loadNextPaneRef entries intersect the menu, the currentPaneId will be updated.
735
+ var k = (0, n.useRef)();
736
+ var j = (0, n.useRef)(ge);
737
+ var I = (0, n.useRef)(ge);
738
+ var R = (0, n.useCallback)((function() {
739
+ var e;
740
+ var r = O.current, n = r === void 0 ? [] : r;
741
+ var t = M.current;
742
+ /**
860
743
  * create onMount for an child of the menu which will be used to trigger pane
861
744
  * changes upon intersection with the menu's visible bounds
862
- */ var o = function e(r) {
863
- return function(e) {
864
- var n;
865
- if (!e) {
866
- return;
867
- }
868
- r.current.push(e);
869
- (n = j.current) === null || n === void 0 ? void 0 : n.observe(e);
870
- };
871
- };
872
- /**
873
- * onUnmount to cleanup the operations of `onVirtualizeMount`
874
- */ var a = function e(r) {
745
+ */ var o = function e(r) {
746
+ return function(e) {
875
747
  var n;
876
- if (!r) {
748
+ if (!e) {
877
749
  return;
878
750
  }
879
- var t = R.current.indexOf(r);
880
- if (t >= 0) {
881
- R.current.splice(t, 1);
882
- }
883
- var o = x.current.indexOf(r);
884
- if (o) {
885
- x.current.splice(o, 1);
886
- }
887
- (n = j.current) === null || n === void 0 ? void 0 : n.unobserve(r);
751
+ r.current.push(e);
752
+ (n = k.current) === null || n === void 0 ? void 0 : n.observe(e);
888
753
  };
889
- return [].concat(Z(J(n[t - 1], o(R), a, {
890
- trackFirstElement: true
891
- })), Z((e = n[t]) !== null && e !== void 0 ? e : []), Z(J(n[t + 1], o(x), a, {
892
- trackLastElement: true
893
- })));
894
- }), []);
895
- var I = (0, e.useState)(k), P = te(I, 2), T = P[0], A = P[1];
896
- var L = (0, e.useCallback)((function(e) {
897
- var r = w.current;
898
- w.current = Math.max(0, Math.min(e, O.current.length - 1));
899
- if (r === w.current) {
900
- // no change in current pane
754
+ };
755
+ /**
756
+ * onUnmount to cleanup the operations of `onVirtualizeMount`
757
+ */ var a = function e(r) {
758
+ var n;
759
+ if (!r) {
901
760
  return;
902
761
  }
903
- A(k);
904
- }), [ k ]);
905
- // Link an IntersectionObserver instance with the menu children to be observed
906
- var _ = (0, e.useCallback)((function(e) {
907
- var r;
908
- M(a, e);
909
- C.current = e;
910
- // This is overly defensive and could probably be removed
911
- (r = j.current) === null || r === void 0 ? void 0 : r.disconnect();
912
- if (!e) {
913
- return;
762
+ var t = I.current.indexOf(r);
763
+ if (t >= 0) {
764
+ I.current.splice(t, 1);
914
765
  }
915
- R.current = [];
916
- x.current = [];
917
- // Run the observation flow
918
- j.current = new IntersectionObserver((function(r) {
919
- var n;
920
- var t = w.current;
921
- var o = e.firstElementChild;
922
- if (!!o && o.scrollHeight < e.clientHeight) {
923
- var a;
924
- // If the first element doesn't require a scrollbar then it's likely a filter input
925
- o = (a = o) === null || a === void 0 ? void 0 : a.nextElementSibling;
926
- }
927
- if (((n = o) === null || n === void 0 ? void 0 : n.scrollTop) === 0 && t === 0 && O.current.length > 1 && r.some((function(e) {
928
- return e.isIntersecting;
929
- }))) {
930
- // The menu hasn't scrolled, is on pane 0, and already has an intersection, the `virtualization` prop is too small
931
- m((function(e) {
932
- return e + 10;
933
- }));
934
- if (false) {}
935
- return;
936
- }
937
- var i = false;
938
- r.forEach((function(e) {
939
- if (i || !e.isIntersecting) {
940
- // don't process if the pane changed or the entry isn't intersecting
941
- return;
942
- }
943
- if (R.current.includes(e.target)) {
944
- i = true;
945
- L(t - 1);
946
- } else if (x.current.includes(e.target)) {
947
- i = true;
948
- L(t + 1);
949
- }
766
+ var o = j.current.indexOf(r);
767
+ if (o) {
768
+ j.current.splice(o, 1);
769
+ }
770
+ (n = k.current) === null || n === void 0 ? void 0 : n.unobserve(r);
771
+ };
772
+ return [].concat(ee(Q(n[t - 1], o(I), a, {
773
+ trackFirstElement: true
774
+ })), ee((e = n[t]) !== null && e !== void 0 ? e : []), ee(Q(n[t + 1], o(j), a, {
775
+ trackLastElement: true
776
+ })));
777
+ }), []);
778
+ var P = (0, n.useState)(R), x = oe(P, 2), A = x[0], T = x[1];
779
+ var L = (0, n.useCallback)((function(e) {
780
+ var r = M.current;
781
+ M.current = Math.max(0, Math.min(e, O.current.length - 1));
782
+ if (r === M.current) {
783
+ // no change in current pane
784
+ return;
785
+ }
786
+ T(R);
787
+ }), [ R ]);
788
+ // Link an IntersectionObserver instance with the menu children to be observed
789
+ var _ = (0, n.useCallback)((function(e) {
790
+ var r;
791
+ C(a, e);
792
+ w.current = e;
793
+ // This is overly defensive and could probably be removed
794
+ (r = k.current) === null || r === void 0 ? void 0 : r.disconnect();
795
+ if (!e) {
796
+ return;
797
+ }
798
+ I.current = [];
799
+ j.current = [];
800
+ // Run the observation flow
801
+ k.current = new IntersectionObserver((function(r) {
802
+ var n;
803
+ var t = M.current;
804
+ var o = e.firstElementChild;
805
+ if (!!o && o.scrollHeight < e.clientHeight) {
806
+ var a;
807
+ // If the first element doesn't require a scrollbar then it's likely a filter input
808
+ o = (a = o) === null || a === void 0 ? void 0 : a.nextElementSibling;
809
+ }
810
+ if (((n = o) === null || n === void 0 ? void 0 : n.scrollTop) === 0 && t === 0 && O.current.length > 1 && r.some((function(e) {
811
+ return e.isIntersecting;
812
+ }))) {
813
+ // The menu hasn't scrolled, is on pane 0, and already has an intersection, the `virtualization` prop is too small
814
+ m((function(e) {
815
+ return e + 10;
950
816
  }));
951
- }), {
952
- root: e
953
- });
954
- }), [ a, L ]);
955
- var q = (0, e.useCallback)((function(e) {
956
- var r = C.current;
957
- if (!r) {
817
+ if (false) {}
958
818
  return;
959
819
  }
960
- e.preventDefault();
961
- var n = e.key;
962
- if (n === "Home") {
963
- var t = w.current === 0;
964
- if (t) {
965
- var o;
966
- // if the first pane is already rendered, find the first element and focus it
967
- var a = (0, z.getSortedTabbableElements)(r, {
968
- ignoreTabIndex: true
969
- });
970
- var i = a[0];
971
- i === null || i === void 0 ? void 0 : (o = i.focus) === null || o === void 0 ? void 0 : o.call(i);
972
- } else {
973
- // if it's not rendered, set up focusing it after the next render
974
- p.current = true;
975
- // then call changePane() to trigger the render
976
- L(0);
820
+ var i = false;
821
+ r.forEach((function(e) {
822
+ if (i || !e.isIntersecting) {
823
+ // don't process if the pane changed or the entry isn't intersecting
824
+ return;
977
825
  }
978
- return;
979
- }
980
- var l = O.current.length - 1;
981
- if (n === "End") {
982
- var u = w.current === l;
983
- if (u) {
984
- var c;
985
- // if the last pane is already rendered, find the first element and focus it
986
- var s = (0, z.getSortedTabbableElements)(r, {
987
- ignoreTabIndex: true
988
- });
989
- var f = s[s.length - 1];
990
- f === null || f === void 0 ? void 0 : (c = f.focus) === null || c === void 0 ? void 0 : c.call(f);
991
- } else {
992
- // if it's not rendered, set up focusing it after the next render
993
- b.current = true;
994
- // then call changePane() to trigger the render
995
- L(l);
826
+ if (I.current.includes(e.target)) {
827
+ i = true;
828
+ L(t - 1);
829
+ } else if (j.current.includes(e.target)) {
830
+ i = true;
831
+ L(t + 1);
996
832
  }
997
- return;
998
- }
999
- var v = (0, z.getSortedTabbableElements)(r, {
1000
- ignoreTabIndex: true
1001
- });
1002
- var d = (e === null || e === void 0 ? void 0 : e.target) instanceof Element ? e.target : null;
1003
- var m = r === null || r === void 0 ? void 0 : r.querySelector(":focus");
1004
- var y = d || m;
1005
- var g = y ? v.indexOf(y) : -1;
1006
- (0, z.handleFocus)(n, v, g, {
1007
- enableLoop: false,
1008
- // VirtualizedResultsMenu does not support looping focus
1009
- orientation: "vertical",
1010
- enableTab: false,
1011
- enableHomeEnd: false
1012
- });
1013
- }), [ L ]);
1014
- (0, e.useEffect)((function() {
1015
- m((function(e) {
1016
- if (false) {}
1017
- return o;
1018
833
  }));
1019
- }), [ o ]);
1020
- (0, e.useEffect)((function() {
1021
- O.current = K(g, d);
1022
- A(k);
1023
- }), [ g, d, k ]);
1024
- (0, e.useEffect)((function() {
1025
- return function() {
1026
- var e;
1027
- return (e = j.current) === null || e === void 0 ? void 0 : e.disconnect();
1028
- };
1029
- }), []);
1030
- (0, e.useEffect)((function() {
1031
- if (u === "never") {
1032
- return undefined;
1033
- }
1034
- var e = C.current;
1035
- if (e) {
1036
- e.addEventListener("keydown", q);
834
+ }), {
835
+ root: e
836
+ });
837
+ }), [ a, L ]);
838
+ var q = (0, n.useCallback)((function(e) {
839
+ var r = w.current;
840
+ if (!r) {
841
+ return;
842
+ }
843
+ e.preventDefault();
844
+ var n = e.key;
845
+ if (n === "Home") {
846
+ var t = M.current === 0;
847
+ if (t) {
848
+ var o;
849
+ // if the first pane is already rendered, find the first element and focus it
850
+ var a = (0, V.getSortedTabbableElements)(r, {
851
+ ignoreTabIndex: true
852
+ });
853
+ var i = a[0];
854
+ i === null || i === void 0 ? void 0 : (o = i.focus) === null || o === void 0 ? void 0 : o.call(i);
855
+ } else {
856
+ // if it's not rendered, set up focusing it after the next render
857
+ b.current = true;
858
+ // then call changePane() to trigger the render
859
+ L(0);
1037
860
  }
1038
- return function() {
1039
- e === null || e === void 0 ? void 0 : e.removeEventListener("keydown", q);
1040
- };
1041
- }), [ q, u ]);
1042
-
1043
- return r().createElement(F, Y({
1044
- elementRef: _,
1045
- focusMode: u
1046
- }, c), T);
1047
- }
1048
- ge.propTypes = be;
1049
- // CONCATENATED MODULE: ./src/utils/ssrDocument.ts
1050
- /* eslint-disable @typescript-eslint/no-empty-function */
1051
- var he = {
1052
- body: {
1053
- appendChild: function e() {
1054
- return [];
861
+ return;
862
+ }
863
+ var u = O.current.length - 1;
864
+ if (n === "End") {
865
+ var l = M.current === u;
866
+ if (l) {
867
+ var c;
868
+ // if the last pane is already rendered, find the first element and focus it
869
+ var s = (0, V.getSortedTabbableElements)(r, {
870
+ ignoreTabIndex: true
871
+ });
872
+ var f = s[s.length - 1];
873
+ f === null || f === void 0 ? void 0 : (c = f.focus) === null || c === void 0 ? void 0 : c.call(f);
874
+ } else {
875
+ // if it's not rendered, set up focusing it after the next render
876
+ p.current = true;
877
+ // then call changePane() to trigger the render
878
+ L(u);
1055
879
  }
1056
- },
1057
- addEventListener: function e() {},
1058
- removeEventListener: function e() {},
1059
- activeElement: {
1060
- blur: function e() {},
1061
- nodeName: ""
1062
- },
1063
- querySelector: function e() {
1064
- return null;
1065
- },
1066
- querySelectorAll: function e() {
880
+ return;
881
+ }
882
+ var d = (0, V.getSortedTabbableElements)(r, {
883
+ ignoreTabIndex: true
884
+ });
885
+ var v = (e === null || e === void 0 ? void 0 : e.target) instanceof Element ? e.target : null;
886
+ var m = r === null || r === void 0 ? void 0 : r.querySelector(":focus");
887
+ var y = v || m;
888
+ var g = y ? d.indexOf(y) : -1;
889
+ (0, V.handleFocus)(n, d, g, {
890
+ enableLoop: false,
891
+ // VirtualizedResultsMenu does not support looping focus
892
+ orientation: "vertical",
893
+ enableTab: false,
894
+ enableHomeEnd: false
895
+ });
896
+ }), [ L ]);
897
+ (0, n.useEffect)((function() {
898
+ m((function(e) {
899
+ if (false) {}
900
+ return o;
901
+ }));
902
+ }), [ o ]);
903
+ (0, n.useEffect)((function() {
904
+ O.current = W(g, v);
905
+ T(R);
906
+ }), [ g, v, R ]);
907
+ (0, n.useEffect)((function() {
908
+ return function() {
909
+ var e;
910
+ return (e = k.current) === null || e === void 0 ? void 0 : e.disconnect();
911
+ };
912
+ }), []);
913
+ (0, n.useEffect)((function() {
914
+ if (l === "never") {
915
+ return undefined;
916
+ }
917
+ var e = w.current;
918
+ if (e) {
919
+ e.addEventListener("keydown", q);
920
+ }
921
+ return function() {
922
+ e === null || e === void 0 ? void 0 : e.removeEventListener("keydown", q);
923
+ };
924
+ }), [ q, l ]);
925
+
926
+ return t().createElement(B, Z({
927
+ elementRef: _,
928
+ focusMode: l
929
+ }, c), A);
930
+ }
931
+ he.propTypes = ye;
932
+ // CONCATENATED MODULE: ./src/utils/ssrDocument.ts
933
+ /* eslint-disable @typescript-eslint/no-empty-function */
934
+ var Se = {
935
+ body: {
936
+ appendChild: function e() {
1067
937
  return [];
1068
- },
1069
- getElementById: function e() {
1070
- return null;
1071
- },
1072
- createEvent: function e() {
1073
- return {
1074
- initEvent: function e() {}
1075
- };
1076
- },
1077
- createElement: function e() {
1078
- return {
1079
- children: [],
1080
- childNodes: [],
1081
- style: {},
1082
- setAttribute: function e() {},
1083
- getElementsByTagName: function e() {
1084
- return [];
1085
- }
1086
- };
1087
- },
1088
- createElementNS: function e() {
1089
- return {};
1090
- },
1091
- importNode: function e() {
1092
- return null;
1093
- },
1094
- location: {
1095
- hash: "",
1096
- host: "",
1097
- hostname: "",
1098
- href: "",
1099
- origin: "",
1100
- pathname: "",
1101
- protocol: "",
1102
- search: ""
1103
938
  }
1104
- };
1105
- function Se() {
1106
- var e = typeof document !== "undefined" ? document : he;
1107
- return e;
1108
- }
1109
- var Ee = Se();
1110
- /* harmony default export */ const Oe = /* unused pure expression or super */ null && Ee;
1111
- // CONCATENATED MODULE: ./src/utils/ssrWindow.ts
1112
- /* eslint-disable @typescript-eslint/no-empty-function */
1113
- var we = {
1114
- document: he,
1115
- navigator: {
1116
- userAgent: ""
1117
- },
1118
- location: {
1119
- hash: "",
1120
- host: "",
1121
- hostname: "",
1122
- href: "",
1123
- origin: "",
1124
- pathname: "",
1125
- protocol: "",
1126
- search: ""
1127
- },
1128
- history: {
1129
- replaceState: function e() {},
1130
- pushState: function e() {},
1131
- go: function e() {},
1132
- back: function e() {}
1133
- },
1134
- CustomEvent: function e() {
1135
- return this;
1136
- },
1137
- addEventListener: function e() {},
1138
- removeEventListener: function e() {},
1139
- getComputedStyle: function e() {
1140
- return {
1141
- getPropertyValue: function e() {
1142
- return "";
1143
- }
1144
- };
1145
- },
1146
- Image: function e() {},
1147
- Date: function e() {},
1148
- screen: {},
1149
- setTimeout: function e() {},
1150
- clearTimeout: function e() {},
1151
- matchMedia: function e() {
1152
- return {};
1153
- },
1154
- requestAnimationFrame: function e(r) {
1155
- if (typeof setTimeout === "undefined") {
1156
- r();
1157
- return null;
939
+ },
940
+ addEventListener: function e() {},
941
+ removeEventListener: function e() {},
942
+ activeElement: {
943
+ blur: function e() {},
944
+ nodeName: ""
945
+ },
946
+ querySelector: function e() {
947
+ return null;
948
+ },
949
+ querySelectorAll: function e() {
950
+ return [];
951
+ },
952
+ getElementById: function e() {
953
+ return null;
954
+ },
955
+ createEvent: function e() {
956
+ return {
957
+ initEvent: function e() {}
958
+ };
959
+ },
960
+ createElement: function e() {
961
+ return {
962
+ children: [],
963
+ childNodes: [],
964
+ style: {},
965
+ setAttribute: function e() {},
966
+ getElementsByTagName: function e() {
967
+ return [];
1158
968
  }
1159
- return setTimeout(r, 0);
1160
- },
1161
- cancelAnimationFrame: function e(r) {
1162
- if (typeof setTimeout === "undefined") {
1163
- return;
969
+ };
970
+ },
971
+ createElementNS: function e() {
972
+ return {};
973
+ },
974
+ importNode: function e() {
975
+ return null;
976
+ },
977
+ location: {
978
+ hash: "",
979
+ host: "",
980
+ hostname: "",
981
+ href: "",
982
+ origin: "",
983
+ pathname: "",
984
+ protocol: "",
985
+ search: ""
986
+ }
987
+ };
988
+ function Ee() {
989
+ var e = typeof document !== "undefined" ? document : Se;
990
+ return e;
991
+ }
992
+ var Oe = Ee();
993
+ /* harmony default export */ const Me = /* unused pure expression or super */ null && Oe;
994
+ // CONCATENATED MODULE: ./src/utils/ssrWindow.ts
995
+ /* eslint-disable @typescript-eslint/no-empty-function */
996
+ var we = {
997
+ document: Se,
998
+ navigator: {
999
+ userAgent: ""
1000
+ },
1001
+ location: {
1002
+ hash: "",
1003
+ host: "",
1004
+ hostname: "",
1005
+ href: "",
1006
+ origin: "",
1007
+ pathname: "",
1008
+ protocol: "",
1009
+ search: ""
1010
+ },
1011
+ history: {
1012
+ replaceState: function e() {},
1013
+ pushState: function e() {},
1014
+ go: function e() {},
1015
+ back: function e() {}
1016
+ },
1017
+ CustomEvent: function e() {
1018
+ return this;
1019
+ },
1020
+ addEventListener: function e() {},
1021
+ removeEventListener: function e() {},
1022
+ getComputedStyle: function e() {
1023
+ return {
1024
+ getPropertyValue: function e() {
1025
+ return "";
1164
1026
  }
1165
- clearTimeout(r);
1027
+ };
1028
+ },
1029
+ Image: function e() {},
1030
+ Date: function e() {},
1031
+ screen: {},
1032
+ setTimeout: function e() {},
1033
+ clearTimeout: function e() {},
1034
+ matchMedia: function e() {
1035
+ return {};
1036
+ },
1037
+ requestAnimationFrame: function e(r) {
1038
+ if (typeof setTimeout === "undefined") {
1039
+ r();
1040
+ return null;
1166
1041
  }
1167
- };
1168
- function Me() {
1169
- var e = typeof window !== "undefined" ? window : we;
1170
- return e;
1042
+ return setTimeout(r, 0);
1043
+ },
1044
+ cancelAnimationFrame: function e(r) {
1045
+ if (typeof setTimeout === "undefined") {
1046
+ return;
1047
+ }
1048
+ clearTimeout(r);
1171
1049
  }
1172
- var Ce = Me();
1173
- /* harmony default export */ const je = /* unused pure expression or super */ null && Ce;
1174
- // CONCATENATED MODULE: ./src/ResultsMenu/VirtualizedResultsMenu/index.ts
1175
- // In environments without IntersectionObserver support this should just export ResultsMenu
1176
- var xe = "IntersectionObserver" in Me() ? ge : F;
1177
- /* harmony default export */ const Re = xe;
1178
- }) // CONCATENATED MODULE: ./src/ResultsMenu/index.ts
1179
- ();
1180
- module.exports = t;
1050
+ };
1051
+ function Ce() {
1052
+ var e = typeof window !== "undefined" ? window : we;
1053
+ return e;
1054
+ }
1055
+ var ke = Ce();
1056
+ /* harmony default export */ const je = /* unused pure expression or super */ null && ke;
1057
+ // CONCATENATED MODULE: ./src/ResultsMenu/VirtualizedResultsMenu/index.ts
1058
+ // eslint-disable-next-line no-relative-imports-of-published -- TODO(SUI-8190): VirtualizedResultsMenu wraps ResultsMenu, using external import creates circular dependency
1059
+ // In environments without IntersectionObserver support this should just export ResultsMenu
1060
+ var Ie = "IntersectionObserver" in Ce() ? he : B;
1061
+ /* harmony default export */ const Re = Ie;
1062
+ // CONCATENATED MODULE: ./src/ResultsMenu/index.ts
1063
+ module.exports = r;
1181
1064
  /******/})();