@splunk/react-ui 5.4.0 → 5.6.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 (89) hide show
  1. package/AnchorMenu.d.ts +2 -0
  2. package/AnchorMenu.js +286 -0
  3. package/Badge.d.ts +2 -0
  4. package/Badge.js +154 -0
  5. package/CHANGELOG.md +42 -0
  6. package/Code.js +1097 -500
  7. package/Color.js +142 -141
  8. package/ComboBox.js +6 -5
  9. package/Link.js +74 -44
  10. package/MIGRATION.md +32 -1
  11. package/Menu.js +41 -43
  12. package/Multiselect.js +615 -2156
  13. package/Number.js +3 -3
  14. package/PhoneNumber.d.ts +2 -0
  15. package/PhoneNumber.js +769 -0
  16. package/Popover.js +73 -75
  17. package/RadioList.js +166 -151
  18. package/ResultsMenu.js +27 -29
  19. package/Select.js +179 -1768
  20. package/SelectBase.d.ts +2 -0
  21. package/SelectBase.js +1714 -0
  22. package/Slider.js +358 -302
  23. package/SlidingPanels.js +55 -62
  24. package/Switch.js +42 -27
  25. package/TabBar.js +295 -294
  26. package/TabLayout.js +14 -14
  27. package/Table.js +1087 -1040
  28. package/TransitionOpen.js +65 -58
  29. package/cypress/support/commands.ts +40 -0
  30. package/cypress/support/component.ts +1 -1
  31. package/cypress/support/index.d.ts +22 -0
  32. package/docker-compose.yml +99 -52
  33. package/package.json +9 -5
  34. package/stubs-splunkui.d.ts +0 -86
  35. package/test-runner-jest.config.js +1 -0
  36. package/types/src/AnchorMenu/AnchorMenu.d.ts +36 -0
  37. package/types/src/AnchorMenu/AnchorMenuContext.d.ts +6 -0
  38. package/types/src/AnchorMenu/Item.d.ts +35 -0
  39. package/types/src/AnchorMenu/docs/examples/Basic.d.ts +6 -0
  40. package/types/src/AnchorMenu/index.d.ts +3 -0
  41. package/types/src/Badge/Badge.d.ts +29 -0
  42. package/types/src/Badge/docs/examples/Basic.d.ts +5 -0
  43. package/types/src/Badge/docs/examples/Count.d.ts +6 -0
  44. package/types/src/Badge/docs/examples/CustomColors.d.ts +8 -0
  45. package/types/src/Badge/docs/examples/Icon.d.ts +6 -0
  46. package/types/src/Badge/index.d.ts +2 -0
  47. package/types/src/Code/Code.d.ts +4 -3
  48. package/types/src/Code/index.d.ts +1 -0
  49. package/types/src/Link/Link.d.ts +4 -0
  50. package/types/src/Link/LinkContext.d.ts +14 -0
  51. package/types/src/Link/docs/examples/Visited.d.ts +7 -0
  52. package/types/src/Link/index.d.ts +1 -0
  53. package/types/src/Menu/Item.d.ts +1 -1
  54. package/types/src/Multiselect/Compact.d.ts +8 -1
  55. package/types/src/Multiselect/Multiselect.d.ts +8 -1
  56. package/types/src/PhoneNumber/PhoneNumber.d.ts +139 -0
  57. package/types/src/PhoneNumber/docs/examples/Controlled.d.ts +7 -0
  58. package/types/src/PhoneNumber/docs/examples/DefaultCountry.d.ts +7 -0
  59. package/types/src/PhoneNumber/docs/examples/Disabled.d.ts +6 -0
  60. package/types/src/PhoneNumber/docs/examples/Error.d.ts +6 -0
  61. package/types/src/PhoneNumber/docs/examples/Inline.d.ts +7 -0
  62. package/types/src/PhoneNumber/docs/examples/Uncontrolled.d.ts +7 -0
  63. package/types/src/PhoneNumber/index.d.ts +2 -0
  64. package/types/src/PhoneNumber/utils.d.ts +47 -0
  65. package/types/src/RadioList/Option.d.ts +6 -1
  66. package/types/src/RadioList/docs/examples/Description.d.ts +6 -0
  67. package/types/src/Select/Option.d.ts +8 -3
  68. package/types/src/Select/Select.d.ts +1 -1
  69. package/types/src/{Select → SelectBase}/OptionBase.d.ts +8 -2
  70. package/types/src/{Select → SelectBase}/SelectBase.d.ts +11 -2
  71. package/types/src/SelectBase/index.d.ts +2 -0
  72. package/types/src/Slider/Slider.d.ts +7 -1
  73. package/types/src/Switch/Switch.d.ts +4 -1
  74. package/types/src/Table/Body.d.ts +6 -1
  75. package/types/src/Table/Cell.d.ts +5 -1
  76. package/types/src/Table/Head.d.ts +6 -2
  77. package/types/src/Table/HeadCell.d.ts +5 -1
  78. package/types/src/Table/Row.d.ts +5 -1
  79. package/types/src/Table/Table.d.ts +20 -1
  80. package/types/src/Table/TableContext.d.ts +1 -0
  81. package/types/src/Table/docs/examples/HorizontalOverflowScroll.d.ts +8 -0
  82. package/types/src/Table/docs/examples/PinActionColumn.d.ts +7 -0
  83. package/types/src/TransitionOpen/TransitionOpen.d.ts +3 -1
  84. package/types/src/useResizeObserver/useResizeObserver.d.ts +2 -0
  85. package/types/src/useRovingFocus/useRovingFocus.d.ts +8 -1
  86. package/usePrevious.d.ts +2 -0
  87. package/useResizeObserver.js +59 -92
  88. package/useRovingFocus.js +96 -41
  89. /package/types/src/{Select → SelectBase}/SelectAllOption.d.ts +0 -0
package/Select.js CHANGED
@@ -9,26 +9,26 @@
9
9
  /******/ (() => {
10
10
  /******/ // getDefaultExport function for compatibility with non-harmony modules
11
11
  /******/ e.n = n => {
12
- /******/ var t = n && n.__esModule ?
12
+ /******/ var o = n && n.__esModule ?
13
13
  /******/ () => n["default"]
14
14
  /******/ : () => n
15
15
  /******/;
16
- e.d(t, {
17
- a: t
16
+ e.d(o, {
17
+ a: o
18
18
  });
19
- /******/ return t;
19
+ /******/ return o;
20
20
  /******/ };
21
21
  /******/ })();
22
22
  /******/
23
23
  /******/ /* webpack/runtime/define property getters */
24
24
  /******/ (() => {
25
25
  /******/ // define getter functions for harmony exports
26
- /******/ e.d = (n, t) => {
27
- /******/ for (var r in t) {
28
- /******/ if (e.o(t, r) && !e.o(n, r)) {
29
- /******/ Object.defineProperty(n, r, {
26
+ /******/ e.d = (n, o) => {
27
+ /******/ for (var t in o) {
28
+ /******/ if (e.o(o, t) && !e.o(n, t)) {
29
+ /******/ Object.defineProperty(n, t, {
30
30
  enumerable: true,
31
- get: t[r]
31
+ get: o[t]
32
32
  });
33
33
  /******/ }
34
34
  /******/ }
@@ -61,1851 +61,262 @@
61
61
  e.r(n);
62
62
  // EXPORTS
63
63
  e.d(n, {
64
- Divider: () => /* reexport */ c.Divider,
65
- Heading: () => /* reexport */ c.Heading,
66
- Option: () => /* reexport */ E,
67
- default: () => /* reexport */ Fn
64
+ Divider: () => /* reexport */ i.Divider,
65
+ Heading: () => /* reexport */ i.Heading,
66
+ Option: () => /* reexport */ m,
67
+ default: () => /* reexport */ x
68
68
  });
69
69
  // CONCATENATED MODULE: external "react"
70
- const t = require("react");
71
- var r = e.n(t);
70
+ const o = require("react");
71
+ var t = e.n(o);
72
72
  // CONCATENATED MODULE: external "prop-types"
73
- const l = require("prop-types");
74
- var o = e.n(l);
73
+ const r = require("prop-types");
74
+ var a = e.n(r);
75
+ // CONCATENATED MODULE: external "@splunk/react-ui/SelectBase"
76
+ const i = require("@splunk/react-ui/SelectBase");
77
+ var l = e.n(i);
75
78
  // CONCATENATED MODULE: external "@splunk/react-ui/useControlled"
76
- const a = require("@splunk/react-ui/useControlled");
77
- var i = e.n(a);
79
+ const u = require("@splunk/react-ui/useControlled");
80
+ var c = e.n(u);
78
81
  // CONCATENATED MODULE: external "@splunk/ui-utils/i18n"
79
- const u = require("@splunk/ui-utils/i18n");
80
- // CONCATENATED MODULE: external "@splunk/react-ui/Menu"
81
- const c = require("@splunk/react-ui/Menu");
82
- // CONCATENATED MODULE: ./src/Select/OptionBase.tsx
83
- function s(e) {
84
- "@babel/helpers - typeof";
85
- return s = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
86
- return typeof e;
87
- } : function(e) {
88
- return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
89
- }, s(e);
90
- }
91
- function f() {
92
- return f = Object.assign ? Object.assign.bind() : function(e) {
93
- for (var n = 1; n < arguments.length; n++) {
94
- var t = arguments[n];
95
- for (var r in t) {
96
- ({}).hasOwnProperty.call(t, r) && (e[r] = t[r]);
97
- }
98
- }
99
- return e;
100
- }, f.apply(null, arguments);
101
- }
102
- function d(e, n) {
103
- var t = Object.keys(e);
104
- if (Object.getOwnPropertySymbols) {
105
- var r = Object.getOwnPropertySymbols(e);
106
- n && (r = r.filter((function(n) {
107
- return Object.getOwnPropertyDescriptor(e, n).enumerable;
108
- }))), t.push.apply(t, r);
109
- }
110
- return t;
111
- }
112
- function p(e) {
113
- for (var n = 1; n < arguments.length; n++) {
114
- var t = null != arguments[n] ? arguments[n] : {};
115
- n % 2 ? d(Object(t), !0).forEach((function(n) {
116
- v(e, n, t[n]);
117
- })) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : d(Object(t)).forEach((function(n) {
118
- Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(t, n));
119
- }));
120
- }
121
- return e;
122
- }
123
- function v(e, n, t) {
124
- return (n = b(n)) in e ? Object.defineProperty(e, n, {
125
- value: t,
126
- enumerable: !0,
127
- configurable: !0,
128
- writable: !0
129
- }) : e[n] = t, e;
130
- }
131
- function b(e) {
132
- var n = m(e, "string");
133
- return "symbol" == s(n) ? n : n + "";
134
- }
135
- function m(e, n) {
136
- if ("object" != s(e) || !e) return e;
137
- var t = e[Symbol.toPrimitive];
138
- if (void 0 !== t) {
139
- var r = t.call(e, n || "default");
140
- if ("object" != s(r)) return r;
141
- throw new TypeError("@@toPrimitive must return a primitive value.");
142
- }
143
- return ("string" === n ? String : Number)(e);
144
- }
145
- function y(e, n) {
146
- if (null == e) return {};
147
- var t, r, l = g(e, n);
148
- if (Object.getOwnPropertySymbols) {
149
- var o = Object.getOwnPropertySymbols(e);
150
- for (r = 0; r < o.length; r++) {
151
- t = o[r], -1 === n.indexOf(t) && {}.propertyIsEnumerable.call(e, t) && (l[t] = e[t]);
152
- }
153
- }
154
- return l;
155
- }
156
- function g(e, n) {
157
- if (null == e) return {};
158
- var t = {};
159
- for (var r in e) {
160
- if ({}.hasOwnProperty.call(e, r)) {
161
- if (-1 !== n.indexOf(r)) continue;
162
- t[r] = e[r];
163
- }
164
- }
165
- return t;
166
- }
167
- var h = {
168
- /** @private */
169
- active: o().bool,
170
- children: o().node,
171
- description: o().string,
172
- descriptionPosition: o().oneOf([ "right", "bottom" ]),
173
- disabled: o().bool,
174
- elementRef: o().oneOfType([ o().func, o().object ]),
175
- hidden: o().bool,
176
- icon: o().node,
177
- label: o().string.isRequired,
178
- /**
179
- * @private Passed down from <BaseSelect>
180
- */
181
- multiple: o().bool,
182
- matchRanges: o().arrayOf(o().shape({
183
- start: o().number.isRequired,
184
- end: o().number.isRequired
185
- })),
186
- /** @private */
187
- onClick: o().func,
188
- /** @private */
189
- role: o().oneOf([ "menuitemcheckbox", "option" ]),
190
- /** @private */
191
- selected: o().oneOfType([ o().bool, o().oneOf([ "some" ]) ]),
192
- truncate: o().bool,
193
- value: o().oneOfType([ o().string, o().number, o().bool ]).isRequired
194
- };
195
- /**
196
- * An option within a `Multiselect`.
197
- */ function O(e) {
198
- var n = e.children, l = e.descriptionPosition, o = l === void 0 ? "bottom" : l, a = e.disabled, i = e.elementRef, u = e.icon, s = e.label, d = e.multiple, v = e.onClick, b = e.role, m = b === void 0 ? "option" : b, g = e.value, h = y(e, [ "children", "descriptionPosition", "disabled", "elementRef", "icon", "label", "multiple", "onClick", "role", "value" ]);
199
- // @docs-props-type OptionPropsBase
200
- var O = (0, t.useCallback)((function(e) {
201
- if (!a) {
202
- v === null || v === void 0 ? void 0 : v(e, {
203
- value: g
204
- });
205
- }
206
- }), [ a, v, g ]);
207
- var S = g.toString();
208
- var C = p({
209
- descriptionPosition: o,
210
- disabled: a ? "disabled" : undefined
211
- }, h);
212
-
213
- return r().createElement(c.Item, f({
214
- "data-test-value": g,
215
- "data-test": "option",
216
- elementRef: i
217
- }, C, {
218
- selectable: true,
219
- selectableAppearance: d ? "checkbox" : "checkmark",
220
- startAdornment: u,
221
- onClick: O,
222
- role: m,
223
- value: S
224
- }), n || s);
225
- }
226
- O.propTypes = h;
227
- O.type = c.Item;
228
- // For components to distinguish if their children are Options or Headings/Dividers
229
- /* harmony default export */ const S = O;
82
+ const s = require("@splunk/ui-utils/i18n");
230
83
  // CONCATENATED MODULE: ./src/Select/Option.tsx
231
- function C() {
232
- return C = Object.assign ? Object.assign.bind() : function(e) {
84
+ function d() {
85
+ return d = Object.assign ? Object.assign.bind() : function(e) {
233
86
  for (var n = 1; n < arguments.length; n++) {
234
- var t = arguments[n];
235
- for (var r in t) {
236
- ({}).hasOwnProperty.call(t, r) && (e[r] = t[r]);
87
+ var o = arguments[n];
88
+ for (var t in o) {
89
+ ({}).hasOwnProperty.call(o, t) && (e[t] = o[t]);
237
90
  }
238
91
  }
239
92
  return e;
240
- }, C.apply(null, arguments);
93
+ }, d.apply(null, arguments);
241
94
  }
242
- function w(e, n) {
95
+ function f(e, n) {
243
96
  if (null == e) return {};
244
- var t, r, l = k(e, n);
97
+ var o, t, r = p(e, n);
245
98
  if (Object.getOwnPropertySymbols) {
246
- var o = Object.getOwnPropertySymbols(e);
247
- for (r = 0; r < o.length; r++) {
248
- t = o[r], -1 === n.indexOf(t) && {}.propertyIsEnumerable.call(e, t) && (l[t] = e[t]);
99
+ var a = Object.getOwnPropertySymbols(e);
100
+ for (t = 0; t < a.length; t++) {
101
+ o = a[t], -1 === n.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (r[o] = e[o]);
249
102
  }
250
103
  }
251
- return l;
104
+ return r;
252
105
  }
253
- function k(e, n) {
106
+ function p(e, n) {
254
107
  if (null == e) return {};
255
- var t = {};
256
- for (var r in e) {
257
- if ({}.hasOwnProperty.call(e, r)) {
258
- if (-1 !== n.indexOf(r)) continue;
259
- t[r] = e[r];
108
+ var o = {};
109
+ for (var t in e) {
110
+ if ({}.hasOwnProperty.call(e, t)) {
111
+ if (-1 !== n.indexOf(t)) continue;
112
+ o[t] = e[t];
260
113
  }
261
114
  }
262
- return t;
115
+ return o;
263
116
  }
264
- var x = {
117
+ var v = {
118
+ /** @private */
119
+ active: a().bool,
120
+ children: a().node,
121
+ description: a().string,
122
+ descriptionPosition: a().oneOf([ "right", "bottom" ]),
123
+ disabled: a().bool,
124
+ elementRef: a().oneOfType([ a().func, a().object ]),
265
125
  /** @private */
266
- active: o().bool,
267
- children: o().node,
268
- description: o().string,
269
- descriptionPosition: o().oneOf([ "right", "bottom" ]),
270
- disabled: o().bool,
271
- elementRef: o().oneOfType([ o().func, o().object ]),
272
- hidden: o().bool,
273
- icon: o().node,
274
- label: o().string.isRequired,
275
- matchRanges: o().arrayOf(o().shape({
276
- start: o().number.isRequired,
277
- end: o().number.isRequired
126
+ endAdornment: a().node,
127
+ hidden: a().bool,
128
+ icon: a().node,
129
+ label: a().string.isRequired,
130
+ matchRanges: a().arrayOf(a().shape({
131
+ start: a().number.isRequired,
132
+ end: a().number.isRequired
278
133
  })),
279
134
  /** @private */
280
- onClick: o().func,
135
+ onClick: a().func,
281
136
  /** @private */
282
- role: o().oneOf([ "menuitemcheckbox", "option" ]),
137
+ role: a().oneOf([ "menuitemcheckbox", "option" ]),
283
138
  /** @private */
284
- selected: o().bool,
285
- truncate: o().bool,
286
- value: o().oneOfType([ o().string, o().number, o().bool ]).isRequired
139
+ selected: a().bool,
140
+ truncate: a().bool,
141
+ value: a().oneOfType([ a().string, a().number, a().bool ]).isRequired
287
142
  };
288
143
  /**
289
144
  * An option within a `Select`. Any elements passed to it should be memoized.
290
- */ function j(e) {
291
- var n = e.children, t = e.descriptionPosition, l = t === void 0 ? "bottom" : t, o = e.elementRef, a = e.label, i = w(e, [ "children", "descriptionPosition", "elementRef", "label" ]);
145
+ */ function b(e) {
146
+ var n = e.children, o = e.descriptionPosition, r = o === void 0 ? "bottom" : o, a = e.elementRef, l = e.label, u = f(e, [ "children", "descriptionPosition", "elementRef", "label" ]);
292
147
  // @docs-props-type OptionPropsBase
293
148
 
294
- return r().createElement(S, C({
295
- descriptionPosition: l,
296
- label: a
297
- }, i, {
298
- elementRef: o,
149
+ return t().createElement(i.Option, d({
150
+ descriptionPosition: r,
151
+ label: l
152
+ }, u, {
153
+ elementRef: a,
299
154
  multiple: false
300
- }), n || a);
155
+ }), n || l);
301
156
  }
302
- var P = (0, t.memo)(j);
157
+ var g = (0, o.memo)(b);
303
158
  // @ts-expect-error Need to set propTypes on OptionMemoized so that javascript propType validation will work
304
- P.propTypes = x;
305
- /* harmony default export */ const E = P;
306
- // CONCATENATED MODULE: external "lodash/castArray"
307
- const R = require("lodash/castArray");
308
- var M = e.n(R);
309
- // CONCATENATED MODULE: external "lodash/find"
310
- const A = require("lodash/find");
311
- var T = e.n(A);
312
- // CONCATENATED MODULE: external "lodash/forEachRight"
313
- const I = require("lodash/forEachRight");
314
- var q = e.n(I);
315
- // CONCATENATED MODULE: external "lodash/has"
316
- const L = require("lodash/has");
317
- var D = e.n(L);
318
- // CONCATENATED MODULE: external "lodash/includes"
319
- const _ = require("lodash/includes");
320
- var B = e.n(_);
321
- // CONCATENATED MODULE: external "lodash/memoize"
322
- const N = require("lodash/memoize");
323
- var V = e.n(N);
324
- // CONCATENATED MODULE: external "lodash/pick"
325
- const K = require("lodash/pick");
326
- var F = e.n(K);
327
- // CONCATENATED MODULE: external "lodash/uniq"
328
- const H = require("lodash/uniq");
329
- var z = e.n(H);
330
- // CONCATENATED MODULE: external "lodash/without"
331
- const W = require("lodash/without");
332
- var $ = e.n(W);
333
- // CONCATENATED MODULE: external "@splunk/react-icons/CaretSmallDown"
334
- const X = require("@splunk/react-icons/CaretSmallDown");
335
- var U = e.n(X);
336
- // CONCATENATED MODULE: external "@splunk/react-icons/Magnifier"
337
- const J = require("@splunk/react-icons/Magnifier");
338
- var G = e.n(J);
339
- // CONCATENATED MODULE: external "@splunk/react-ui/Dropdown"
340
- const Q = require("@splunk/react-ui/Dropdown");
341
- var Y = e.n(Q);
342
- // CONCATENATED MODULE: external "@splunk/react-ui/Link"
343
- const Z = require("@splunk/react-ui/Link");
344
- var ee = e.n(Z);
345
- // CONCATENATED MODULE: external "@splunk/react-ui/ResultsMenu"
346
- const ne = require("@splunk/react-ui/ResultsMenu");
347
- var te = e.n(ne);
348
- // CONCATENATED MODULE: external "@splunk/react-ui/ScreenReaderContent"
349
- const re = require("@splunk/react-ui/ScreenReaderContent");
350
- var le = e.n(re);
351
- // CONCATENATED MODULE: external "@splunk/react-ui/Text"
352
- const oe = require("@splunk/react-ui/Text");
353
- var ae = e.n(oe);
354
- // CONCATENATED MODULE: external "@splunk/react-ui/usePrevious"
355
- const ie = require("@splunk/react-ui/usePrevious");
356
- var ue = e.n(ie);
357
- // CONCATENATED MODULE: external "@splunk/ui-utils/filter"
358
- const ce = require("@splunk/ui-utils/filter");
359
- // CONCATENATED MODULE: external "@splunk/ui-utils/id"
360
- const se = require("@splunk/ui-utils/id");
361
- // CONCATENATED MODULE: external "@splunk/ui-utils/scroll"
362
- const fe = require("@splunk/ui-utils/scroll");
363
- // CONCATENATED MODULE: ./src/Select/SelectAllOption.tsx
364
- function de(e) {
365
- "@babel/helpers - typeof";
366
- return de = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
367
- return typeof e;
368
- } : function(e) {
369
- return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
370
- }, de(e);
371
- }
372
- function pe() {
373
- return pe = Object.assign ? Object.assign.bind() : function(e) {
374
- for (var n = 1; n < arguments.length; n++) {
375
- var t = arguments[n];
376
- for (var r in t) {
377
- ({}).hasOwnProperty.call(t, r) && (e[r] = t[r]);
378
- }
379
- }
380
- return e;
381
- }, pe.apply(null, arguments);
382
- }
383
- function ve(e, n) {
384
- if (null == e) return {};
385
- var t, r, l = be(e, n);
386
- if (Object.getOwnPropertySymbols) {
387
- var o = Object.getOwnPropertySymbols(e);
388
- for (r = 0; r < o.length; r++) {
389
- t = o[r], -1 === n.indexOf(t) && {}.propertyIsEnumerable.call(e, t) && (l[t] = e[t]);
390
- }
391
- }
392
- return l;
393
- }
394
- function be(e, n) {
395
- if (null == e) return {};
396
- var t = {};
397
- for (var r in e) {
398
- if ({}.hasOwnProperty.call(e, r)) {
399
- if (-1 !== n.indexOf(r)) continue;
400
- t[r] = e[r];
401
- }
402
- }
403
- return t;
404
- }
405
- function me(e, n) {
406
- var t = Object.keys(e);
407
- if (Object.getOwnPropertySymbols) {
408
- var r = Object.getOwnPropertySymbols(e);
409
- n && (r = r.filter((function(n) {
410
- return Object.getOwnPropertyDescriptor(e, n).enumerable;
411
- }))), t.push.apply(t, r);
412
- }
413
- return t;
414
- }
415
- function ye(e) {
416
- for (var n = 1; n < arguments.length; n++) {
417
- var t = null != arguments[n] ? arguments[n] : {};
418
- n % 2 ? me(Object(t), !0).forEach((function(n) {
419
- ge(e, n, t[n]);
420
- })) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : me(Object(t)).forEach((function(n) {
421
- Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(t, n));
422
- }));
423
- }
424
- return e;
425
- }
426
- function ge(e, n, t) {
427
- return (n = he(n)) in e ? Object.defineProperty(e, n, {
428
- value: t,
429
- enumerable: !0,
430
- configurable: !0,
431
- writable: !0
432
- }) : e[n] = t, e;
433
- }
434
- function he(e) {
435
- var n = Oe(e, "string");
436
- return "symbol" == de(n) ? n : n + "";
437
- }
438
- function Oe(e, n) {
439
- if ("object" != de(e) || !e) return e;
440
- var t = e[Symbol.toPrimitive];
441
- if (void 0 !== t) {
442
- var r = t.call(e, n || "default");
443
- if ("object" != de(r)) return r;
444
- throw new TypeError("@@toPrimitive must return a primitive value.");
445
- }
446
- return ("string" === n ? String : Number)(e);
447
- }
448
- var Se = ye(ye({}, S.propTypes), {}, {
449
- totalCount: o().number,
450
- // unlike OptionBase, there's a default value for this prop
451
- value: o().string
452
- });
453
- function Ce(e) {
454
- var n = e.active, t = e.elementRef, l = e.id, o = e.label, a = e.onClick, i = e.selected, u = e.totalCount, c = e.value, s = c === void 0 ? "selectAll" : c, f = ve(e, [ "active", "elementRef", "id", "label", "onClick", "selected", "totalCount", "value" ]);
455
- // @docs-props-type SelectAllOptionPropsBase
456
- // When toggle is changed the total count is not displayed anymore so the count is now shown in the Select all menu item
457
- var d = u != null ? " (".concat(u === null || u === void 0 ? void 0 : u.toString(), ")") : "";
458
-
459
- return r().createElement(S, pe({
460
- active: n,
461
- elementRef: t,
462
- "aria-keyshortcuts": "Control+A",
463
- "data-test": "select-all",
464
- description: "".concat(d, " Ctrl-a"),
465
- descriptionPosition: "right",
466
- id: l,
467
- key: "selectAll",
468
- multiple: true,
469
- label: o,
470
- onClick: a,
471
- selected: i,
472
- role: "menuitemcheckbox",
473
- value: s
474
- }, f));
475
- }
476
- Ce.propTypes = Se;
477
- /* harmony default export */ const we = Ce;
478
- // CONCATENATED MODULE: external "styled-components"
479
- const ke = require("styled-components");
480
- var xe = e.n(ke);
481
- // CONCATENATED MODULE: external "@splunk/react-ui/Button"
482
- const je = require("@splunk/react-ui/Button");
483
- var Pe = e.n(je);
484
- // CONCATENATED MODULE: external "@splunk/react-ui/Divider"
485
- const Ee = require("@splunk/react-ui/Divider");
486
- var Re = e.n(Ee);
487
- // CONCATENATED MODULE: external "@splunk/themes"
488
- const Me = require("@splunk/themes");
489
- // CONCATENATED MODULE: ./src/Select/SelectBaseStyles.ts
490
- var Ae = xe()(Pe()).withConfig({
491
- displayName: "SelectBaseStyles__StyledButton",
492
- componentId: "sc-16cj7sk-0"
493
- })([ "&[data-inline]{width:", ";}", "" ], (function(e) {
494
- var n = e.$multiple;
495
- return n ? "400px" : "auto";
496
- }), (function(e) {
497
- var n = e.$multiple;
498
- return !n && "flex-grow: 0;";
499
- }));
500
- var Te = xe().span.withConfig({
501
- displayName: "SelectBaseStyles__StyledLinkIcon",
502
- componentId: "sc-16cj7sk-1"
503
- })([ "padding-right:", ";" ], Me.variables.spacingXSmall);
504
- var Ie = xe().span.withConfig({
505
- displayName: "SelectBaseStyles__StyledLinkCaret",
506
- componentId: "sc-16cj7sk-2"
507
- })([ "padding-left:", ";" ], Me.variables.spacingXSmall);
508
- var qe = xe().div.withConfig({
509
- displayName: "SelectBaseStyles__StyledFilter",
510
- componentId: "sc-16cj7sk-3"
511
- })([ "padding:", " ", " ", ";min-width:160px;" ], Me.variables.spacingLarge, Me.variables.spacingLarge, Me.variables.spacingSmall);
512
- var Le = xe().span.withConfig({
513
- displayName: "SelectBaseStyles__StyledCount",
514
- componentId: "sc-16cj7sk-4"
515
- })([ "padding-right:", ";" ], Me.variables.spacingXSmall);
516
- var De = xe()(ee()).withConfig({
517
- displayName: "SelectBaseStyles__StyledControlsLink",
518
- componentId: "sc-16cj7sk-5"
519
- })([ "", ";" ], (function(e) {
520
- var n = e.$disabled;
521
- return n && (0, ke.css)([ "color:", ";" ], Me.variables.contentColorDisabled);
522
- }));
523
- var _e = xe().div.withConfig({
524
- displayName: "SelectBaseStyles__StyledToggleAllControls",
525
- componentId: "sc-16cj7sk-6"
526
- })([ "", ";gap:", ";padding:", " ", " ", ";" ], Me.mixins.reset("flex"), Me.variables.spacingMedium, Me.variables.spacingXSmall, Me.variables.spacingLarge, Me.variables.spacingSmall);
527
- var Be = xe()(Re()).withConfig({
528
- displayName: "SelectBaseStyles__StyledControlsDivider",
529
- componentId: "sc-16cj7sk-7"
530
- })([ "border-color:", ";" ], Me.variables.borderColor);
531
- // CONCATENATED MODULE: ./src/utils/fuzzyMatch.ts
532
- // A utility for matching keyboard characters to list values
533
- var Ne = function e(n, t) {
534
- return n ? n.label.charAt(t).toLowerCase() : "";
535
- };
536
- var Ve = function e(n, t) {
537
- if (!n.length) {
538
- return n;
539
- }
540
- var r = null;
541
- var l = false;
542
- var o = n.filter((function(e) {
543
- var n = Ne(e, t.index);
544
- if (n === t.value) {
545
- l = true;
546
- return true;
547
- }
548
- // If we haven't found a match yet, keep track of the next closest match.
549
- // Secondary matching looks for the closest character of a higher value, and failing that, closest of a lower value.
550
- if (!l) {
551
- var o = Ne(r, t.index);
552
- if (!o) {
553
- r = e;
554
- } else if (n > t.value) {
555
- if (o < t.value) {
556
- r = e;
557
- } else if (o > n) {
558
- r = e;
559
- }
560
- } else if (n > o) {
561
- r = e;
562
- }
563
- }
564
- return false;
565
- }));
566
- return o.length === 0 && r ? [ r ] : o;
567
- };
568
- // CONCATENATED MODULE: ./src/utils/ssrDocument.ts
569
- /* eslint-disable @typescript-eslint/no-empty-function */
570
- var Ke = {
571
- body: {
572
- appendChild: function e() {
573
- return [];
574
- }
575
- },
576
- addEventListener: function e() {},
577
- removeEventListener: function e() {},
578
- activeElement: {
579
- blur: function e() {},
580
- nodeName: ""
581
- },
582
- querySelector: function e() {
583
- return null;
584
- },
585
- querySelectorAll: function e() {
586
- return [];
587
- },
588
- getElementById: function e() {
589
- return null;
590
- },
591
- createEvent: function e() {
592
- return {
593
- initEvent: function e() {}
594
- };
595
- },
596
- createElement: function e() {
597
- return {
598
- children: [],
599
- childNodes: [],
600
- style: {},
601
- setAttribute: function e() {},
602
- getElementsByTagName: function e() {
603
- return [];
604
- }
605
- };
606
- },
607
- createElementNS: function e() {
608
- return {};
609
- },
610
- importNode: function e() {
611
- return null;
612
- },
613
- location: {
614
- hash: "",
615
- host: "",
616
- hostname: "",
617
- href: "",
618
- origin: "",
619
- pathname: "",
620
- protocol: "",
621
- search: ""
622
- }
623
- };
624
- function Fe() {
625
- var e = typeof document !== "undefined" ? document : Ke;
626
- return e;
627
- }
628
- var He = Fe();
629
- /* harmony default export */ const ze = /* unused pure expression or super */ null && He;
630
- // CONCATENATED MODULE: ./src/utils/ssrWindow.ts
631
- /* eslint-disable @typescript-eslint/no-empty-function */
632
- var We = {
633
- document: Ke,
634
- navigator: {
635
- userAgent: ""
636
- },
637
- location: {
638
- hash: "",
639
- host: "",
640
- hostname: "",
641
- href: "",
642
- origin: "",
643
- pathname: "",
644
- protocol: "",
645
- search: ""
646
- },
647
- history: {
648
- replaceState: function e() {},
649
- pushState: function e() {},
650
- go: function e() {},
651
- back: function e() {}
652
- },
653
- CustomEvent: function e() {
654
- return this;
655
- },
656
- addEventListener: function e() {},
657
- removeEventListener: function e() {},
658
- getComputedStyle: function e() {
659
- return {
660
- getPropertyValue: function e() {
661
- return "";
662
- }
663
- };
664
- },
665
- Image: function e() {},
666
- Date: function e() {},
667
- screen: {},
668
- setTimeout: function e() {},
669
- clearTimeout: function e() {},
670
- matchMedia: function e() {
671
- return {};
672
- },
673
- requestAnimationFrame: function e(n) {
674
- if (typeof setTimeout === "undefined") {
675
- n();
676
- return null;
677
- }
678
- return setTimeout(n, 0);
679
- },
680
- cancelAnimationFrame: function e(n) {
681
- if (typeof setTimeout === "undefined") {
682
- return;
683
- }
684
- clearTimeout(n);
685
- }
686
- };
687
- function $e() {
688
- var e = typeof window !== "undefined" ? window : We;
689
- return e;
690
- }
691
- var Xe = $e();
692
- /* harmony default export */ const Ue = /* unused pure expression or super */ null && Xe;
693
- // CONCATENATED MODULE: ./src/utils/updateReactRef.ts
694
- /**
695
- * Updates a React ref. Callback refs and object refs (from `createRef` and `useRef`) are supported.
696
- *
697
- * @param ref - The React callback or object ref. Can be `null` or `undefined`.
698
- * @param current - The new value of the ref.
699
- */
700
- function Je(e, n) {
701
- if (e) {
702
- if (typeof e === "function") {
703
- e(n);
704
- } else {
705
- // the public signature of this util uses React.Ref<T> to mirror the way React types refs.
706
- // the intention here is to signal "we will take care of setting 'current', not you".
707
- e.current = n;
708
- // eslint-disable-line no-param-reassign
709
- }
710
- }
711
- }
712
- // CONCATENATED MODULE: ./src/Select/SelectBase.tsx
713
- function Ge(e) {
714
- return Ze(e) || Ye(e) || rn(e) || Qe();
715
- }
716
- function Qe() {
717
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
718
- }
719
- function Ye(e) {
720
- if ("undefined" != typeof Symbol && null != e[Symbol.iterator] || null != e["@@iterator"]) return Array.from(e);
721
- }
722
- function Ze(e) {
723
- if (Array.isArray(e)) return ln(e);
724
- }
725
- function en() {
726
- return en = Object.assign ? Object.assign.bind() : function(e) {
727
- for (var n = 1; n < arguments.length; n++) {
728
- var t = arguments[n];
729
- for (var r in t) {
730
- ({}).hasOwnProperty.call(t, r) && (e[r] = t[r]);
731
- }
732
- }
733
- return e;
734
- }, en.apply(null, arguments);
735
- }
736
- function nn(e, n) {
737
- return an(e) || on(e, n) || rn(e, n) || tn();
738
- }
739
- function tn() {
740
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
741
- }
742
- function rn(e, n) {
743
- if (e) {
744
- if ("string" == typeof e) return ln(e, n);
745
- var t = {}.toString.call(e).slice(8, -1);
746
- return "Object" === t && e.constructor && (t = e.constructor.name), "Map" === t || "Set" === t ? Array.from(e) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? ln(e, n) : void 0;
747
- }
748
- }
749
- function ln(e, n) {
750
- (null == n || n > e.length) && (n = e.length);
751
- for (var t = 0, r = Array(n); t < n; t++) {
752
- r[t] = e[t];
753
- }
754
- return r;
755
- }
756
- function on(e, n) {
757
- var t = null == e ? null : "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"];
758
- if (null != t) {
759
- var r, l, o, a, i = [], u = !0, c = !1;
760
- try {
761
- if (o = (t = t.call(e)).next, 0 === n) {
762
- if (Object(t) !== t) return;
763
- u = !1;
764
- } else for (;!(u = (r = o.call(t)).done) && (i.push(r.value), i.length !== n); u = !0) {
765
- }
766
- } catch (e) {
767
- c = !0, l = e;
768
- } finally {
769
- try {
770
- if (!u && null != t["return"] && (a = t["return"](), Object(a) !== a)) return;
771
- } finally {
772
- if (c) throw l;
773
- }
774
- }
775
- return i;
776
- }
777
- }
778
- function an(e) {
779
- if (Array.isArray(e)) return e;
780
- }
781
- function un(e, n) {
782
- if (null == e) return {};
783
- var t, r, l = cn(e, n);
784
- if (Object.getOwnPropertySymbols) {
785
- var o = Object.getOwnPropertySymbols(e);
786
- for (r = 0; r < o.length; r++) {
787
- t = o[r], -1 === n.indexOf(t) && {}.propertyIsEnumerable.call(e, t) && (l[t] = e[t]);
788
- }
789
- }
790
- return l;
791
- }
792
- function cn(e, n) {
793
- if (null == e) return {};
794
- var t = {};
795
- for (var r in e) {
796
- if ({}.hasOwnProperty.call(e, r)) {
797
- if (-1 !== n.indexOf(r)) continue;
798
- t[r] = e[r];
799
- }
800
- }
801
- return t;
802
- }
803
- function sn(e) {
804
- "@babel/helpers - typeof";
805
- return sn = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
806
- return typeof e;
807
- } : function(e) {
808
- return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
809
- }, sn(e);
810
- }
811
- function fn(e, n) {
812
- var t = Object.keys(e);
813
- if (Object.getOwnPropertySymbols) {
814
- var r = Object.getOwnPropertySymbols(e);
815
- n && (r = r.filter((function(n) {
816
- return Object.getOwnPropertyDescriptor(e, n).enumerable;
817
- }))), t.push.apply(t, r);
818
- }
819
- return t;
820
- }
821
- function dn(e) {
822
- for (var n = 1; n < arguments.length; n++) {
823
- var t = null != arguments[n] ? arguments[n] : {};
824
- n % 2 ? fn(Object(t), !0).forEach((function(n) {
825
- pn(e, n, t[n]);
826
- })) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : fn(Object(t)).forEach((function(n) {
827
- Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(t, n));
828
- }));
829
- }
830
- return e;
831
- }
832
- function pn(e, n, t) {
833
- return (n = vn(n)) in e ? Object.defineProperty(e, n, {
834
- value: t,
835
- enumerable: !0,
836
- configurable: !0,
837
- writable: !0
838
- }) : e[n] = t, e;
839
- }
840
- function vn(e) {
841
- var n = bn(e, "string");
842
- return "symbol" == sn(n) ? n : n + "";
843
- }
844
- function bn(e, n) {
845
- if ("object" != sn(e) || !e) return e;
846
- var t = e[Symbol.toPrimitive];
847
- if (void 0 !== t) {
848
- var r = t.call(e, n || "default");
849
- if ("object" != sn(r)) return r;
850
- throw new TypeError("@@toPrimitive must return a primitive value.");
851
- }
852
- return ("string" === n ? String : Number)(e);
853
- }
854
- var mn = {
855
- allowKeyMatching: o().bool,
856
- allowNewValues: o().bool,
857
- animateLoading: o().bool,
858
- appearance: o().oneOf([ "default", "link", "subtle" ]),
859
- append: o().bool,
860
- children: o().node,
861
- defaultPlacement: o().oneOf([ "above", "below", "vertical" ]),
862
- defaultValues: o().array,
863
- describedBy: o().string,
864
- disabled: o().bool,
865
- elementRef: o().oneOfType([ o().func, o().object ]),
866
- error: o().bool,
867
- filter: o().oneOf([ false, true, "controlled" ]),
868
- footerMessage: o().node,
869
- inline: o().bool,
870
- inputId: o().string,
871
- inputRef: o().oneOfType([ o().func, o().object ]),
872
- isLoadingOptions: o().bool,
873
- labelledBy: o().string,
874
- labelText: o().string,
875
- loadingMessage: o().node,
876
- menuStyle: o().object,
877
- multiple: o().bool,
878
- name: o().string,
879
- noOptionsMessage: o().node,
880
- onChange: o().func,
881
- onClick: o().func,
882
- onClose: o().func,
883
- onFilterChange: o().func,
884
- onOpen: o().func,
885
- onScroll: o().func,
886
- onScrollBottom: o().func,
887
- /** @private. */
888
- required: o().bool,
889
- placeholder: o().string,
890
- prefixLabel: o().string,
891
- prepend: o().bool,
892
- repositionMode: o().oneOf([ "none", "flip" ]),
893
- selectAllAppearance: o().oneOf([ "buttongroup", "checkbox", "none" ]),
894
- showSelectedValuesFirst: o().oneOf([ "nextOpen", "immediately", "never" ]),
895
- suffixLabel: o().string,
896
- tabConfirmsNewValue: o().bool,
897
- toggle: o().node,
898
- toggleContent: o().oneOf([ "optionChildren", "optionLabel" ]),
899
- values: o().array,
900
- /** @private. */
901
- virtualization: o().number
902
- };
903
- var yn = V()((function(e) {
904
- return [ e ];
905
- }));
906
- // preserve separate widths for single vs. multi mode
907
- var gn = V()((function(e) {
908
- var n = e.anchorWidth, t = e.isMultiple, r = e.maxHeight, l = e.menuStyle;
909
- return t ? dn({
910
- width: Math.max(n !== null && n !== void 0 ? n : 0, 200),
911
- maxHeight: r
912
- }, l) : dn({
913
- minWidth: n !== null && n !== void 0 ? n : undefined,
914
- maxWidth: Math.max(n !== null && n !== void 0 ? n : 0, 300),
915
- maxHeight: r
916
- }, l);
917
- }));
918
- var hn = [ "clickAway", "escapeKey", "offScreen", "tabKey", "toggleClick" ];
919
- function On(e) {
920
- return e && D()(e.props, "value");
921
- }
922
- function Sn(e, n) {
923
- return "".concat(sn(e), "-").concat(e, "-").concat(n);
924
- }
925
- var Cn = [ "append", "error", "prepend" ];
926
- var wn = (0, u._)("No matches");
927
- var kn = (0, u._)("Select...");
928
- var xn = r().createElement(G(), null);
929
- var jn = function e(n) {
930
- var t = n.activeItemId, l = n.filterA11yId, o = n.filterKeyword, a = n.hasChildren, i = n.inputId, c = n.inputRef, s = n.menuListboxId, f = n.multiple, d = n.onClearAll, p = n.onSelectAll, v = n.onTextBlur, b = n.onTextChange, m = n.onTextFocus, y = n.onTextKeyDown, g = n.optionSelection, h = n.placement, O = n.selectAllAppearance, S = n.textHasFocus;
931
- var C = (0, u._)("Select all options".concat(g.current === "all" ? " disabled" : ""));
932
- var w = (0, u._)("Clear all options".concat(g.current === "none" ? " disabled" : ""));
933
- // only visually disable these as opposed to fully disabling to avoid losing keyboard focus - see SUI-2731
934
- var k = r().createElement(_e, {
935
- key: "selectAll"
936
- }, r().createElement(De, {
937
- disabled: g.current === "all",
938
- appearance: "standalone",
939
- "aria-label": C,
940
- onClick: p,
941
- "data-test": "select-all",
942
- tag: "button"
943
- }, o ? (0, u._)("Select all Matches") : (0, u._)("Select all")), r().createElement(De, {
944
- disabled: g.current === "none",
945
- appearance: "standalone",
946
- "aria-label": w,
947
- onClick: d,
948
- "data-test": "clear-all",
949
- tag: "button"
950
- }, o ? (0, u._)("Clear all Matches") : (0, u._)("Clear all")));
951
-
952
- return r().createElement("div", {
953
- key: "controls"
954
- }, l && r().createElement(le(), {
955
- id: l
956
- }, (0, u._)("Type to filter")), h === "above" && r().createElement(Be, null), r().createElement(qe, {
957
- key: "filter",
958
- "data-test": "filter"
959
- }, r().createElement(ae(), {
960
- value: o,
961
- autoCapitalize: "off",
962
- autoComplete: "off",
963
- autoCorrect: "off",
964
- spellCheck: false,
965
- onChange: b,
966
- onKeyDown: y,
967
- onFocus: m,
968
- onBlur: v,
969
- placeholder: (0, u._)("filter"),
970
- role: "combobox",
971
- "aria-expanded": "true",
972
- "aria-controls": s,
973
- "aria-owns": S && a ? t : undefined,
974
- "aria-label": (0, u._)("Filter"),
975
- "aria-autocomplete": "list",
976
- "aria-activedescendant": S && a ? t : undefined,
977
- inputRef: c,
978
- inputId: i,
979
- canClear: true,
980
- startAdornment: xn
981
- })), f && a && O === "buttongroup" && k, h === "below" && r().createElement(Be, null));
982
- };
983
- var Pn = function e(n) {
984
- var t = n.prefixLabel, r = n.label, l = n.suffixLabel;
985
- var o = r;
986
- if (t) {
987
- o = [ "".concat(t, ": ") ].concat(o);
988
- }
989
- if (l) {
990
- o = M()(o).concat(" ".concat(l));
991
- }
992
- return o;
993
- };
994
- var En = r().forwardRef((function(e, n) {
995
- var l = e.appearance, o = l === void 0 ? "default" : l, a = e.append, i = e.children, c = e.currentValues, s = c === void 0 ? [] : c, f = e.describedBy, d = e.disabled, p = e.elementRef, v = e.error, b = e.inline, m = e.labelText, y = e.labelledBy, g = e.multiple, h = e.onClick, O = e.placeholder, S = e.prefixLabel, C = e.prepend, w = e.required, k = e.suffixLabel, x = e.toggle, j = e.toggleContent, P = un(e, [ "appearance", "append", "children", "currentValues", "describedBy", "disabled", "elementRef", "error", "inline", "labelText", "labelledBy", "multiple", "onClick", "placeholder", "prefixLabel", "prepend", "required", "suffixLabel", "toggle", "toggleContent" ]);
996
- var E;
997
- var R;
998
- var M = [];
999
- // Generate buttonLabels
1000
- var A = t.Children.toArray(i);
1001
- var I = s.reduce((function(e, n, t, r) {
1002
- var l = T()(A, (function(e) {
1003
- return On(e) && e.props.value === n;
1004
- }));
1005
- if (l) {
1006
- var o = l.props, a = o.children, i = o.icon, c = o.label;
1007
- var f = j !== "optionLabel" && a ? a : c;
1008
- e.push(f);
1009
- M.push(c);
1010
- // if not in multiple mode, add the icon
1011
- if (!g && s.length === 1) {
1012
- E = i;
1013
- }
1014
- } else if (g) {
1015
- // only add values that don't match an option in "multiple" mode to preserve old behaviour
1016
- e.push(n);
1017
- M.push(n.toString());
1018
- }
1019
- if (t < r.length - 1) {
1020
- e.push((0, u._)(", "));
1021
- M.push((0, u._)(", "));
1022
- }
1023
- return e;
1024
- }), []);
1025
- R = I;
1026
- // only apply prefix / suffix if the label is not empty
1027
- if (R.length > 0) {
1028
- // If there's more than one item selected, read out the selected total
1029
- // rather than reading out each selected item
1030
- M = Pn({
1031
- prefixLabel: S,
1032
- label: R.length > 1 ? [ "".concat(s.length, " items selected") ] : M,
1033
- suffixLabel: k
1034
- });
1035
- R = Pn({
1036
- prefixLabel: S,
1037
- label: R,
1038
- suffixLabel: k
1039
- });
1040
- }
1041
- // single <Select> behaviour is to show the placeholder if all parts of the label
1042
- // are empty strings so we replicate this behaviour here
1043
- if (R.length === 0 || !g && R.every((function(e) {
1044
- return e === "";
1045
- }))) {
1046
- R = yn(O);
1047
- M = R;
1048
- }
1049
- var q = Object.keys(P).includes("aria-labelledby");
1050
- var L = dn({
1051
- "aria-describedby": f,
1052
- "aria-label": y || q ? undefined : "".concat(m ? "".concat(m, ", ") : "").concat(M.join("")),
1053
- // aria-labelledby takes precedence over aria-label, so existence of both is redundant
1054
- "aria-labelledby": y,
1055
- "aria-required": w,
1056
- "data-select-appearance": o,
1057
- append: a,
1058
- prepend: C,
1059
- onClick: h,
1060
- role: "combobox",
1061
- disabled: d ? "disabled" : undefined,
1062
- elementRef: p,
1063
- error: v,
1064
- ref: n
1065
- }, P);
1066
- if (g) {
1067
- L["data-test-values"] = JSON.stringify(s);
1068
- } else {
1069
- var D = nn(s, 1), _ = D[0];
1070
- L["data-test-value"] = _;
1071
- }
1072
- if (x) {
1073
-
1074
- return (0, t.cloneElement)(x, L);
1075
- }
1076
- if (o === "link") {
1077
-
1078
- return r().createElement(ee(), en({
1079
- tag: "button",
1080
- appearance: "standalone"
1081
- }, L, {
1082
- "data-select-appearance": "link"
1083
- }), !!E && r().createElement(Te, null, E), R || O, r().createElement(Ie, null, r().createElement(U(), null)));
1084
- }
1085
- // Using Button's secondary appearance as Select's default appearance.
1086
- var B = o === "default" ? "secondary" : o;
1087
-
1088
- return r().createElement(Ae, en({}, L, {
1089
- $multiple: g,
1090
- appearance: B,
1091
- label: R,
1092
- error: v,
1093
- icon: E,
1094
- inline: b,
1095
- isMenu: true,
1096
- onClick: h
1097
- }, F()(P, Cn)), !!s.length && g && r().createElement(Le, {
1098
- "data-role": "count"
1099
- }, "(", s.length, ")"));
1100
- }));
1101
- function Rn(e) {
1102
- var n = e.allowKeyMatching, l = n === void 0 ? true : n, o = e.animateLoading, a = e.appearance, s = a === void 0 ? "default" : a, f = e.append, d = e.allowNewValues, p = e.children, v = e.defaultPlacement, b = v === void 0 ? "vertical" : v, m = e.defaultValues, y = e.describedBy, g = e.disabled, h = e.elementRef, O = e.error, C = e.filter, w = e.footerMessage, k = e.inline, x = e.inputId, j = e.inputRef, P = e.isLoadingOptions, E = e.labelledBy, R = e.labelText, M = e.loadingMessage, A = e.menuStyle, I = A === void 0 ? {} : A, L = e.multiple, D = e.name, _ = e.noOptionsMessage, N = _ === void 0 ? wn : _, V = e.onChange, K = e.onScroll, F = e.onScrollBottom, H = e.onFilterChange, W = e.onClick, X = e.onClose, U = e.onOpen, J = e.required, G = e.placeholder, Q = G === void 0 ? kn : G, Z = e.prefixLabel, ee = e.prepend, re = e.repositionMode, le = re === void 0 ? "flip" : re, oe = e.selectAllAppearance, ae = oe === void 0 ? "buttongroup" : oe, ie = e.showSelectedValuesFirst, de = e.suffixLabel, pe = e.tabConfirmsNewValue, ve = e.values, be = e.virtualization, me = e.toggle, ye = e.toggleContent, ge = ye === void 0 ? "optionChildren" : ye, he = un(e, [ "allowKeyMatching", "animateLoading", "appearance", "append", "allowNewValues", "children", "defaultPlacement", "defaultValues", "describedBy", "disabled", "elementRef", "error", "filter", "footerMessage", "inline", "inputId", "inputRef", "isLoadingOptions", "labelledBy", "labelText", "loadingMessage", "menuStyle", "multiple", "name", "noOptionsMessage", "onChange", "onScroll", "onScrollBottom", "onFilterChange", "onClick", "onClose", "onOpen", "required", "placeholder", "prefixLabel", "prepend", "repositionMode", "selectAllAppearance", "showSelectedValuesFirst", "suffixLabel", "tabConfirmsNewValue", "values", "virtualization", "toggle", "toggleContent" ]);
1103
- // @docs-props-type SelectBasePropsBase
1104
- var Oe = i()({
1105
- componentName: "SelectBase",
1106
- /* eslint-disable-next-line prefer-rest-params */
1107
- componentProps: arguments[0],
1108
- // see SUI-7028
1109
- defaultValuePropName: "defaultValues",
1110
- valuePropName: "values"
1111
- });
1112
- // states
1113
- var Se = (0, t.useState)((function() {
1114
- return {
1115
- activeItemId: (0, se.createDOMID)("active-item"),
1116
- menuListboxId: (0, se.createDOMID)("menu-listbox")
1117
- };
1118
- })), Ce = nn(Se, 1), ke = Ce[0], xe = ke.activeItemId, je = ke.menuListboxId;
1119
- var Pe = (0, t.useState)(0), Ee = nn(Pe, 2), Re = Ee[0], Me = Ee[1];
1120
- var Ae = (0, t.useState)(""), Te = nn(Ae, 2), Ie = Te[0], qe = Te[1];
1121
- var Le = (0, t.useState)(false), De = nn(Le, 2), _e = De[0], Be = De[1];
1122
- var Ne = (0, t.useState)(false), Ke = nn(Ne, 2), Fe = Ke[0], He = Ke[1];
1123
- var ze = (0, t.useState)([]), We = nn(ze, 2), Xe = We[0], Ue = We[1];
1124
- var Qe = (0, t.useState)(m || []), Ye = nn(Qe, 2), Ze = Ye[0], tn = Ye[1];
1125
- // previous state
1126
- var rn = ue()(Re);
1127
- // refs
1128
- var ln = (0, t.useRef)(null);
1129
- var on = (0, t.useRef)(null);
1130
- var an = (0, t.useRef)(null);
1131
- var cn = (0, t.useRef)([]);
1132
- var sn = (0, t.useRef)([]);
1133
- var fn = (0, t.useRef)(rn);
1134
- var dn = (0, t.useRef)();
1135
- var pn = (0, t.useRef)({});
1136
- var vn = (0, t.useRef)(0);
1137
- var bn = (0, t.useRef)([]);
1138
- var mn = (0, t.useRef)(null);
1139
- var yn = (0, t.useRef)();
1140
- var Cn = (0, t.useRef)(0);
1141
- var xn = (0, t.useRef)("none");
1142
- var Pn = (0, t.useState)(C ? (0, se.createDOMID)("filter") : undefined), Rn = nn(Pn, 1), Mn = Rn[0];
1143
- (0, t.useEffect)((function() {
1144
- if (false) {}
1145
- }), [ s, f, O, ee ]);
1146
- var An = (0, t.useCallback)((function() {
1147
- var e = Oe ? ve : Ze;
1148
- return L || e == null ? e : e.slice(0, 1);
1149
- }), [ Oe, L, ve, Ze ]);
1150
- var Tn = (0, t.useCallback)((function() {
1151
- var e;
1152
- // in non-multiple mode, don't move values to the top of the list
1153
- return L && ie !== "never" ? (e = An()) !== null && e !== void 0 ? e : [] : [];
1154
- }), [ An, L, ie ]);
1155
- var In = (0, t.useCallback)((function(e) {
1156
- var n = Ie;
1157
- Be(true);
1158
- Ue(Tn());
1159
- // SUI-3234: preserve existing behavior difference between <Select> and <Multiselect.Compact>
1160
- if (L) {
1161
- qe("");
1162
- }
1163
- if (n !== Ie) {
1164
- H === null || H === void 0 ? void 0 : H(e, {
1165
- keyword: Ie
1166
- });
1167
- }
1168
- }), [ Ie, Tn, L, H ]);
1169
- (0, t.useEffect)((function() {
1170
- if (_e) {
1171
- U === null || U === void 0 ? void 0 : U();
1172
- if (mn.current && !C) {
1173
- mn.current.focus();
1174
- } else {
1175
- var e;
1176
- Me((e = yn.current) !== null && e !== void 0 ? e : 0);
1177
- }
1178
- }
1179
- }), [ U, _e, Xe, Ie, C ]);
1180
- var qn = (0, t.useCallback)((function() {
1181
- Be(false);
1182
- Me(0);
1183
- fn.current = null;
1184
- X === null || X === void 0 ? void 0 : X();
1185
- }), [ X ]);
1186
- var Ln = (0, t.useCallback)((function(e, n) {
1187
- var t;
1188
- var r = (t = An()) !== null && t !== void 0 ? t : [];
1189
- var l = r.indexOf(n);
1190
- var o;
1191
- if (L) {
1192
- if (l >= 0) {
1193
- o = [].concat(Ge(r.slice(0, l)), Ge(r.slice(l + 1)));
1194
- } else {
1195
- o = r.concat([ n ]);
1196
- }
1197
- } else {
1198
- // non-multiple mode must always have a value
1199
- o = [ n ];
1200
- }
1201
- var a = !Oe;
1202
- if (a) {
1203
- tn(o);
1204
- }
1205
- if (L) {
1206
- // in uncontrolled multiple mode, keep the menu open
1207
- if (a) {
1208
- Be(true);
1209
- }
1210
- } else {
1211
- var i;
1212
- // non-multiple mode only supports a single selection
1213
- // so close the menu once a selection is made
1214
- qn({
1215
- reason: "contentClick"
1216
- });
1217
- (i = ln.current) === null || i === void 0 ? void 0 : i.focus();
1218
- }
1219
- V === null || V === void 0 ? void 0 : V(e, {
1220
- values: o,
1221
- name: D,
1222
- reason: "valueToggle"
1223
- });
1224
- }), [ An, qn, Oe, L, D, V ]);
1225
- var Dn = function e() {
1226
- on.current = null;
1227
- cn.current = [];
1228
- if (an.current) {
1229
- clearTimeout(an.current);
1230
- }
1231
- };
1232
- var _n = (0, t.useCallback)((function(e) {
1233
- var n;
1234
- // this doesn't make sense if we can't select multiple values
1235
- if (!L) {
1236
- return;
1237
- }
1238
- var t = (n = An()) !== null && n !== void 0 ? n : [];
1239
- var l = z()(t.concat(bn.current));
1240
- l = r().Children.toArray(p).filter((function(e) {
1241
- return On(e) && B()(l, e.props.value) && (!e.props.disabled || B()(t, e.props.value));
1242
- })).map((function(e) {
1243
- return e.props.value;
1244
- }));
1245
- if (!Oe) {
1246
- tn(l);
1247
- }
1248
- V === null || V === void 0 ? void 0 : V(e, {
1249
- values: l,
1250
- name: D,
1251
- reason: "selectAll"
1252
- });
1253
- }), [ p, An, Oe, L, D, V ]);
1254
- var Bn = (0, t.useCallback)((function(e) {
1255
- var n;
1256
- // this doesn't make sense if we can't select multiple values
1257
- if (!L) {
1258
- return;
1259
- }
1260
- var t = (n = An()) !== null && n !== void 0 ? n : [];
1261
- var l = $().apply(void 0, [ t ].concat(Ge(bn.current)));
1262
- // this will unselect all selected values unless those values are disabled or hidden by the filter
1263
- var o = r().Children.toArray(p).filter((function(e) {
1264
- return On(e) && (B()(t, e.props.value) && e.props.disabled || B()(l, e.props.value));
1265
- })).map((function(e) {
1266
- return e.props.value;
1267
- }));
1268
- if (!Oe) {
1269
- tn(o);
1270
- }
1271
- V === null || V === void 0 ? void 0 : V(e, {
1272
- values: o,
1273
- name: D,
1274
- reason: "clearAll"
1275
- });
1276
- }), [ p, An, Oe, L, D, V ]);
1277
- var Nn = (0, t.useCallback)((function(e) {
1278
- if (_e && !P) {
1279
- F === null || F === void 0 ? void 0 : F(e);
1280
- }
1281
- }), [ _e, P, F ]);
1282
- var Vn = (0, t.useCallback)((function(e) {
1283
- var n = e.key;
1284
- if (n === "Tab") {
1285
- if (pe && dn.current && vn.current <= 1) {
1286
- e.preventDefault();
1287
- Ln(e, dn.current);
1288
- }
1289
- }
1290
- if (e.shiftKey || e.metaKey || e.ctrlKey) {
1291
- if (n === "a" && (e.ctrlKey || e.metaKey)) {
1292
- // handle control + A
1293
- if (xn.current === "all") {
1294
- Bn(e);
1295
- } else {
1296
- _n(e);
1297
- }
1298
- }
1299
- return;
1300
- }
1301
- if (n === "ArrowDown") {
1302
- e.preventDefault();
1303
- Me(Math.min(Re + 1, ae === "checkbox" ? vn.current : vn.current - 1));
1304
- if (p && F) {
1305
- var r;
1306
- var l = t.Children.toArray(p).length - (2 + ((r = An()) !== null && r !== void 0 ? r : []).length);
1307
- if (Re === l) {
1308
- Nn(e);
1309
- }
1310
- }
1311
- }
1312
- if (n === "ArrowUp") {
1313
- e.preventDefault();
1314
- Me(Math.max(Re - 1, 0));
1315
- }
1316
- if (n === "Enter" && dn.current && _e) {
1317
- if (dn.current === "selectAll") {
1318
- if (xn.current === "all") {
1319
- Bn(e);
1320
- } else {
1321
- _n(e);
1322
- }
1323
- } else {
1324
- e.preventDefault();
1325
- Ln(e, dn.current);
1326
- }
1327
- }
1328
- }), [ Re, p, An, Bn, Nn, _n, F, _e, ae, pe, Ln ]);
1329
- var Kn = (0, t.useCallback)((function(e, n) {
1330
- var t = n.value;
1331
- e.preventDefault();
1332
- if (!_e) {
1333
- return;
1334
- }
1335
- Ln(e, t);
1336
- }), [ _e, Ln ]);
1337
- var Fn = (0, t.useCallback)((function(e, n) {
1338
- var t = e.nativeEvent.key;
1339
- // Checking for a single character to avoid complications from double-byte languages and emojis.
1340
- if (t.length === 1) {
1341
- var r = [];
1342
- var l = {
1343
- index: 0,
1344
- value: t
1345
- };
1346
- if (!on.current) {
1347
- if (t === " ") {
1348
- Dn();
1349
- return;
1350
- }
1351
- r = Ve(sn.current, l);
1352
- } else if (cn.current.length > 1) {
1353
- l.index = on.current.index + 1;
1354
- r = Ve(cn.current, l);
1355
- }
1356
- if (r.length) {
1357
- var o;
1358
- var a = 0;
1359
- // If the active option is a first character match, cycle to the next matching option.
1360
- if (l.index === 0 && r.length > 1) {
1361
- var i = r.indexOf(sn.current[n]);
1362
- if (i >= 0) {
1363
- a = i === r.length - 1 ? 0 : i + 1;
1364
- }
1365
- }
1366
- var u = r[a];
1367
- var c = u.value, s = u.label;
1368
- var f = pn.current[Sn(c, s)];
1369
- f === null || f === void 0 ? void 0 : (o = f.focus) === null || o === void 0 ? void 0 : o.call(f);
1370
- }
1371
- cn.current = r;
1372
- on.current = l;
1373
- if (an.current) {
1374
- clearTimeout(an.current);
1375
- }
1376
- an.current = setTimeout(Dn, 500);
1377
- e.preventDefault();
1378
- e.stopPropagation();
1379
- }
1380
- }), []);
1381
- var Hn = (0, t.useCallback)((function(e, n) {
1382
- var t = n.value;
1383
- qe(t);
1384
- Be(true);
1385
- Me(0);
1386
- H === null || H === void 0 ? void 0 : H(e, {
1387
- keyword: t
1388
- });
1389
- }), [ H ]);
1390
- var zn = (0, t.useCallback)((function() {
1391
- He(true);
1392
- }), []);
1393
- var Wn = (0, t.useCallback)((function() {
1394
- He(false);
1395
- }), []);
1396
- var $n = (0, t.useCallback)((function(e) {
1397
- if (fn.current !== Re) {
1398
- (0, fe.scrollIntoViewIfNeeded)(e);
1399
- }
1400
- }), [ Re ]);
1401
- var Xn = (0, t.useCallback)((function(e, n, t) {
1402
- if (t) {
1403
- mn.current = e;
1404
- }
1405
- if (e == null) {
1406
- delete pn.current[n];
1407
- } else {
1408
- pn.current[n] = e;
1409
- }
1410
- }), [ pn ]);
1411
- var Un = (0, t.useCallback)((function(e) {
1412
- ln.current = e;
1413
- Je(h, e);
1414
- }), [ h, ln ]);
1415
- var Jn = (0, t.useMemo)((function() {
1416
- var e;
1417
- return (e = An()) !== null && e !== void 0 ? e : [];
1418
- }), [ An ]);
1419
- var Gn = t.Children.toArray(p);
1420
- var Qn = Jn.some((function(e) {
1421
- var n = T()(Gn, (function(n) {
1422
- return On(n) && n.props.value === e;
1423
- }));
1424
- return n && !n.props.disabled;
1425
- }));
1426
- var Yn = ie === "immediately" ? Tn() : Xe;
1427
- var Zn = (0, t.useMemo)((function() {
1428
- vn.current = 0;
1429
- yn.current = undefined;
1430
- Cn.current = 0;
1431
- dn.current = undefined;
1432
- sn.current = [];
1433
- var e = function e(n, t) {
1434
- return function(e) {
1435
- return Xn(e, n, t);
1436
- };
1437
- };
1438
- var n;
1439
- var o = 0;
1440
- var a = false;
1441
- // used to avoid overwriting the selected item ref in multiple mode
1442
- var i;
1443
- var s = t.Children.toArray(p).reduce((function(u, s, f) {
1444
- // ignore Headings and Dividers
1445
- if (!On(s)) {
1446
- u.push(s);
1447
- return u;
1448
- }
1449
- var d = s.props, p = d.disabled, v = d.hidden, b = d.label, m = d.value;
1450
- // Find out if the search string exactly matches a value
1451
- if (m === Ie) {
1452
- n = true;
1453
- }
1454
- var y = Jn && Jn.indexOf(m) >= 0;
1455
- var g = !!y && !p && !i;
1456
- var h = l && !L && !C && !P && !F;
1457
- var O = Sn(m, b);
1458
- var S = -1;
1459
- if (h && !p && !v) {
1460
- sn.current.push({
1461
- label: b,
1462
- value: m
1463
- });
1464
- S = sn.current.length - 1;
1465
- }
1466
- // Format the Menu.Item
1467
- var w = (0, t.cloneElement)(s, {
1468
- elementRef: e(O, g),
1469
- key: s.key || f,
1470
- onClick: Kn,
1471
- onKeyDown: h ? function(e) {
1472
- return Fn(e, S);
1473
- } : undefined,
1474
- selected: y,
1475
- multiple: L,
1476
- role: "option"
1477
- });
1478
- if (g) {
1479
- i = true;
1480
- }
1481
- if (Yn && Yn.indexOf(m) >= 0) {
1482
- if (o === 0) {
1483
- u.splice(o, 0, r().createElement(c.Divider, {
1484
- key: "topDivider"
1485
- }));
1486
- a = true;
1487
- }
1488
- u.splice(o, 0, w);
1489
- o += 1;
1490
- } else {
1491
- u.push(w);
1492
- }
1493
- return u;
1494
- }), []);
1495
- // In multiple mode, add missing items
1496
- if (L) {
1497
- q()(Jn, (function(t) {
1498
- var l = T()(s, (function(e) {
1499
- return On(e) && e.props && e.props.value === t;
1500
- }));
1501
- if (!l) {
1502
- if (t === Ie) {
1503
- n = true;
1504
- }
1505
- var i = Yn && Yn.indexOf(t) >= 0;
1506
- var u = Yn.length;
1507
- if (o === 0) {
1508
- s.splice(0, 0, r().createElement(c.Divider, {
1509
- key: "topDivider"
1510
- }));
1511
- o += 1;
1512
- a = true;
1513
- }
1514
- var f = String(t);
1515
- var d = Sn(t, f);
1516
- s.splice(i ? 0 : u + 1, 0, r().createElement(S, {
1517
- elementRef: e(d),
1518
- label: f,
1519
- value: t,
1520
- key: "missing-value-".concat(t),
1521
- onClick: Kn,
1522
- multiple: L,
1523
- selected: true
1524
- }));
1525
- if (i) {
1526
- o += 1;
1527
- }
1528
- }
1529
- }));
1530
- }
1531
- var f = C === "controlled";
1532
- // Filter the items
1533
- var v = (0, ce.stringToKeywords)(Ie);
1534
- s = f ? s : s.filter((function(e) {
1535
- if (On(e)) {
1536
- return (0, ce.testPhrase)(e.props.label, v);
1537
- }
1538
- return true;
1539
- // Keep all headers and non-interactive options
1540
- })).map((function(e) {
1541
- if (!On(e)) {
1542
- return e;
1543
- }
1544
- // highlight matched text
1545
- var n = v && (0, ce.keywordLocations)(e.props.label, v);
1546
-
1547
- return (0, t.cloneElement)(e, {
1548
- matchRanges: n || undefined
1549
- });
1550
- }));
1551
- // Add the option to add the new value
1552
- if (d && !n && Ie) {
1553
- var b = a ? o + 1 : o;
1554
- var m = "".concat(Ie, " (new value)");
1555
- var y = Sn(Ie, m);
1556
- s.splice(b, 0, r().createElement(S, {
1557
- elementRef: e(y),
1558
- label: m,
1559
- value: Ie,
1560
- key: "newValue",
1561
- multiple: L,
1562
- onClick: Kn
1563
- }));
1564
- }
1565
- // When selectAll is a menu item, add an offset so that activeItem accounts for the extra selectAll option.
1566
- var g = ae === "checkbox" && L && s.length > 1 ? 1 : 0;
1567
- var h = true;
1568
- // Highlight the selected Items and remove hidden
1569
- s = s.reduce((function(e, n) {
1570
- // ignore Dividers & Headings
1571
- if (!On(n)) {
1572
- e.push(n);
1573
- return e;
1574
- }
1575
- // Ignore any hidden items
1576
- if (n.props && n.props.hidden) {
1577
- return e;
1578
- }
1579
- if (n.props.selected && !n.props.disabled && yn.current == null) {
1580
- yn.current = vn.current;
1581
- }
1582
- var r = g === Re;
1583
- g += 1;
1584
- vn.current += 1;
1585
- Cn.current += n.props.selected ? 1 : 0;
1586
- if (n.key !== "newValue" && !n.props.disabled && !n.props.selected) {
1587
- h = false;
1588
- }
1589
- if (!r || !Fe) {
1590
- e.push(n);
1591
- return e;
1592
- }
1593
- if (!n.props.disabled) {
1594
- dn.current = n.props.value;
1595
- }
1596
- var l = (0, t.cloneElement)(n, {
1597
- active: r,
1598
- elementRef: $n,
1599
- id: xe
1600
- });
1601
- e.push(l);
1602
- return e;
1603
- }), []);
1604
- xn.current = Cn.current === 0 && "none" || h && "all" || "some";
1605
- // add select all option
1606
- if (ae === "checkbox" && L && vn.current > 0) {
1607
- var O = Re === 0 && !!C;
1608
- var w;
1609
- if (xn.current === "all") {
1610
- if (Ie === "") {
1611
- w = (0, u._)("Clear all");
1612
- } else {
1613
- w = (0, u._)("Clear all matches");
1614
- }
1615
- } else if (Ie === "") {
1616
- w = (0, u._)("Select all");
1617
- } else {
1618
- w = (0, u._)("Select all matches");
1619
- }
1620
- if (O) {
1621
- dn.current = "selectAll";
1622
- }
1623
- s.unshift( r().createElement(we, {
1624
- key: "select-all-option",
1625
- active: O,
1626
- elementRef: $n,
1627
- id: O ? xe : undefined,
1628
- onClick: xn.current === "all" ? Bn : _n,
1629
- label: w,
1630
- selected: xn.current === "all" || xn.current !== "none" && "some",
1631
- totalCount: !!me && Jn.length || undefined,
1632
- tabIndex: C ? -1 : undefined
1633
- }), r().createElement(c.Divider, {
1634
- key: "selectAllDivider"
1635
- }));
1636
- }
1637
- bn.current = s.reduce((function(e, n) {
1638
- if (On(n)) {
1639
- e.push(n.props.value);
1640
- }
1641
- return e;
1642
- }), []);
1643
- return s;
1644
- }), [ Re, xe, l, d, p, Jn, C, Ie, $n, Bn, Kn, Fn, Xn, _n, P, L, Yn, F, ae, Fe, me ]);
1645
- var et = function e(n) {
1646
- var t = n.anchorWidth, l = n.maxHeight, a = n.placement, i = n.toggleId;
1647
- var u = gn({
1648
- anchorWidth: t,
1649
- isMultiple: L,
1650
- maxHeight: l,
1651
- menuStyle: I
1652
- });
1653
- var c = Jn.length > 0 && !Qn && !C ? 0 : undefined;
1654
- var s = {
1655
- "aria-multiselectable": L || undefined,
1656
- childrenStart: !!C && r().createElement(jn, {
1657
- activeItemId: xe,
1658
- filterA11yId: Mn,
1659
- filterKeyword: Ie,
1660
- hasChildren: Zn.some((function(e) {
1661
- return On(e);
1662
- })),
1663
- inputId: x,
1664
- inputRef: j,
1665
- menuListboxId: je,
1666
- multiple: L,
1667
- onClearAll: Bn,
1668
- onSelectAll: _n,
1669
- onTextBlur: Wn,
1670
- onTextChange: Hn,
1671
- onTextFocus: zn,
1672
- onTextKeyDown: Vn,
1673
- optionSelection: xn,
1674
- placement: a,
1675
- selectAllAppearance: ae,
1676
- textHasFocus: Fe
1677
- }),
1678
- focusMode: C ? "never" : undefined,
1679
- isLoading: P,
1680
- labelledBy: "".concat(Mn !== null && Mn !== void 0 ? Mn : "", " ").concat(i !== null && i !== void 0 ? i : "").trim(),
1681
- // NVDA ignores aria-labelledby attribute on popover, but reads it on menu
1682
- menuId: je,
1683
- onScrollBottom: F ? Nn : undefined,
1684
- placement: a !== null && a !== void 0 ? a : undefined,
1685
- noOptionsMessage: N,
1686
- footerMessage: w,
1687
- animateLoading: o,
1688
- loadingMessage: M,
1689
- onScroll: K,
1690
- style: u,
1691
- tabIndex: c
1692
- };
1693
- if (be) {
1694
-
1695
- return r().createElement(ne.VirtualizedResultsMenu, en({
1696
- virtualization: be
1697
- }, s), Zn);
1698
- }
1699
-
1700
- return r().createElement(te(), s, Zn);
1701
- };
1702
- var nt = (0, t.useMemo)((function() {
1703
-
1704
- return r().createElement(En, en({
1705
- appearance: s,
1706
- append: f,
1707
- currentValues: An(),
1708
- "data-test": L ? "multiselect" : "select",
1709
- describedBy: y,
1710
- disabled: g,
1711
- elementRef: Un,
1712
- error: O,
1713
- inline: k,
1714
- labelText: R,
1715
- labelledBy: E,
1716
- multiple: L,
1717
- onClick: W,
1718
- placeholder: Q,
1719
- prefixLabel: Z,
1720
- prepend: ee,
1721
- required: J,
1722
- suffixLabel: de,
1723
- toggle: me,
1724
- toggleContent: ge
1725
- }, he), p);
1726
- }), [ s, f, An, L, y, g, O, Un, k, R, E, W, Q, Z, ee, J, de, me, ge, he, p ]);
1727
-
1728
- return r().createElement(Y(), {
1729
- closeReasons: hn,
1730
- inputId: x,
1731
- "aria-labelledby": Mn,
1732
- toggle: nt,
1733
- onRequestOpen: In,
1734
- onRequestClose: qn,
1735
- open: _e,
1736
- openWithArrowKeys: true,
1737
- repositionMode: le,
1738
- defaultPlacement: b,
1739
- canCoverAnchor: $e().innerHeight < 500,
1740
- retainFocus: false,
1741
- takeFocus: Jn.length === 0 || Jn.length > 0 && !Qn || !!C
1742
- }, et);
1743
- }
1744
- Rn.propTypes = mn;
1745
- Rn.componentType = "SelectBase";
1746
- Rn.Option = S;
1747
- Rn.Divider = c.Divider;
1748
- Rn.Heading = c.Heading;
1749
- /* harmony default export */ const Mn = Rn;
159
+ g.propTypes = v;
160
+ /* harmony default export */ const m = g;
1750
161
  // CONCATENATED MODULE: ./src/utils/useDeprecate.tsx
1751
- var An = "is deprecated and will be removed in the next major version.";
1752
- var Tn = function e(n) {
1753
- var t = n.additionalMessage, r = t === void 0 ? "" : t, l = n.componentName;
162
+ var O = "is deprecated and will be removed in the next major version.";
163
+ var y = function e(n) {
164
+ var o = n.additionalMessage, t = o === void 0 ? "" : o, r = n.componentName;
1754
165
  useEffect((function() {
1755
166
  if (false) {}
1756
- }), [ r, l ]);
167
+ }), [ t, r ]);
1757
168
  };
1758
- var In = function e(n) {
1759
- var t = n.additionalMessage, r = t === void 0 ? "" : t, l = n.componentName, o = n.propName, a = n.propValue;
169
+ var h = function e(n) {
170
+ var o = n.additionalMessage, t = o === void 0 ? "" : o, r = n.componentName, a = n.propName, i = n.propValue;
1760
171
  useEffect((function() {
1761
172
  if (false) {}
1762
- }), [ r, l, o, a ]);
173
+ }), [ t, r, a, i ]);
1763
174
  };
1764
- var qn = function e(n) {
1765
- var r = n.additionalMessage, l = r === void 0 ? "" : r, o = n.componentName, a = n.deprecatedPropValue, i = n.propName, u = n.propValue;
1766
- (0, t.useEffect)((function() {
175
+ var P = function e(n) {
176
+ var t = n.additionalMessage, r = t === void 0 ? "" : t, a = n.componentName, i = n.deprecatedPropValue, l = n.propName, u = n.propValue;
177
+ (0, o.useEffect)((function() {
1767
178
  if (false) {}
1768
- }), [ l, o, i, u, a ]);
179
+ }), [ r, a, l, u, i ]);
1769
180
  };
1770
181
  // CONCATENATED MODULE: ./src/Select/Select.tsx
1771
- function Ln() {
1772
- return Ln = Object.assign ? Object.assign.bind() : function(e) {
182
+ function M() {
183
+ return M = Object.assign ? Object.assign.bind() : function(e) {
1773
184
  for (var n = 1; n < arguments.length; n++) {
1774
- var t = arguments[n];
1775
- for (var r in t) {
1776
- ({}).hasOwnProperty.call(t, r) && (e[r] = t[r]);
185
+ var o = arguments[n];
186
+ for (var t in o) {
187
+ ({}).hasOwnProperty.call(o, t) && (e[t] = o[t]);
1777
188
  }
1778
189
  }
1779
190
  return e;
1780
- }, Ln.apply(null, arguments);
191
+ }, M.apply(null, arguments);
1781
192
  }
1782
- function Dn(e, n) {
193
+ function j(e, n) {
1783
194
  if (null == e) return {};
1784
- var t, r, l = _n(e, n);
195
+ var o, t, r = S(e, n);
1785
196
  if (Object.getOwnPropertySymbols) {
1786
- var o = Object.getOwnPropertySymbols(e);
1787
- for (r = 0; r < o.length; r++) {
1788
- t = o[r], -1 === n.indexOf(t) && {}.propertyIsEnumerable.call(e, t) && (l[t] = e[t]);
197
+ var a = Object.getOwnPropertySymbols(e);
198
+ for (t = 0; t < a.length; t++) {
199
+ o = a[t], -1 === n.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (r[o] = e[o]);
1789
200
  }
1790
201
  }
1791
- return l;
202
+ return r;
1792
203
  }
1793
- function _n(e, n) {
204
+ function S(e, n) {
1794
205
  if (null == e) return {};
1795
- var t = {};
1796
- for (var r in e) {
1797
- if ({}.hasOwnProperty.call(e, r)) {
1798
- if (-1 !== n.indexOf(r)) continue;
1799
- t[r] = e[r];
206
+ var o = {};
207
+ for (var t in e) {
208
+ if ({}.hasOwnProperty.call(e, t)) {
209
+ if (-1 !== n.indexOf(t)) continue;
210
+ o[t] = e[t];
1800
211
  }
1801
212
  }
1802
- return t;
213
+ return o;
1803
214
  }
1804
215
  /** @public */
1805
216
  /** @public */
1806
- /** @public */ var Bn = {
1807
- allowKeyMatching: o().bool,
1808
- animateLoading: o().bool,
1809
- appearance: o().oneOf([ "default", "link", "subtle" ]),
1810
- append: o().bool,
1811
- children: o().node,
1812
- defaultPlacement: o().oneOf([ "above", "below", "vertical" ]),
1813
- defaultValue: o().oneOfType([ o().string, o().number, o().bool ]),
1814
- describedBy: o().string,
1815
- disabled: o().bool,
1816
- elementRef: o().oneOfType([ o().func, o().object ]),
1817
- error: o().bool,
1818
- filter: o().oneOf([ false, true, "controlled" ]),
1819
- footerMessage: o().node,
1820
- inline: o().bool,
1821
- inputId: o().string,
1822
- inputRef: o().oneOfType([ o().func, o().object ]),
1823
- isLoadingOptions: o().bool,
1824
- labelledBy: o().string,
1825
- labelText: o().string,
1826
- loadingMessage: o().node,
1827
- menuStyle: o().object,
1828
- name: o().string,
1829
- noOptionsMessage: o().node,
1830
- onChange: o().func,
1831
- onClose: o().func,
1832
- onFilterChange: o().func,
1833
- onOpen: o().func,
1834
- onScroll: o().func,
1835
- onScrollBottom: o().func,
1836
- placeholder: o().string,
1837
- prefixLabel: o().string,
1838
- prepend: o().bool,
1839
- repositionMode: o().oneOf([ "none", "flip" ]),
1840
- suffixLabel: o().string,
1841
- toggleContent: o().oneOf([ "optionChildren", "optionLabel" ]),
217
+ /** @public */ var w = {
218
+ allowKeyMatching: a().bool,
219
+ animateLoading: a().bool,
220
+ appearance: a().oneOf([ "default", "link", "subtle" ]),
221
+ append: a().bool,
222
+ children: a().node,
223
+ defaultPlacement: a().oneOf([ "above", "below", "vertical" ]),
224
+ defaultValue: a().oneOfType([ a().string, a().number, a().bool ]),
225
+ describedBy: a().string,
226
+ disabled: a().bool,
227
+ elementRef: a().oneOfType([ a().func, a().object ]),
228
+ error: a().bool,
229
+ filter: a().oneOf([ false, true, "controlled" ]),
230
+ footerMessage: a().node,
231
+ inline: a().bool,
232
+ inputId: a().string,
233
+ inputRef: a().oneOfType([ a().func, a().object ]),
234
+ isLoadingOptions: a().bool,
235
+ labelledBy: a().string,
236
+ labelText: a().string,
237
+ loadingMessage: a().node,
238
+ menuStyle: a().object,
239
+ name: a().string,
240
+ noOptionsMessage: a().node,
241
+ onChange: a().func,
242
+ onClose: a().func,
243
+ onFilterChange: a().func,
244
+ onOpen: a().func,
245
+ onScroll: a().func,
246
+ onScrollBottom: a().func,
247
+ placeholder: a().string,
248
+ prefixLabel: a().string,
249
+ prepend: a().bool,
250
+ repositionMode: a().oneOf([ "none", "flip" ]),
251
+ suffixLabel: a().string,
252
+ toggleContent: a().oneOf([ "optionChildren", "optionLabel" ]),
1842
253
  /** @private. */
1843
- toggle: o().node,
1844
- value: o().oneOfType([ o().string, o().number, o().bool ]),
254
+ toggle: a().node,
255
+ value: a().oneOfType([ a().string, a().number, a().bool ]),
1845
256
  /** @private. */
1846
- virtualization: o().number
257
+ virtualization: a().number
1847
258
  };
1848
- var Nn = (0, u._)("No matches");
1849
- var Vn = (0, u._)("Select...");
1850
- function Kn(e) {
1851
- var n = e.allowKeyMatching, l = n === void 0 ? true : n, o = e.appearance, a = o === void 0 ? "default" : o, u = e.defaultPlacement, c = u === void 0 ? "vertical" : u, s = e.defaultValue, f = e.inline, d = f === void 0 ? true : f, p = e.noOptionsMessage, v = p === void 0 ? Nn : p, b = e.onChange, m = e.placeholder, y = m === void 0 ? Vn : m, g = e.toggleContent, h = g === void 0 ? "optionChildren" : g, O = e.value, S = Dn(e, [ "allowKeyMatching", "appearance", "defaultPlacement", "defaultValue", "inline", "noOptionsMessage", "onChange", "placeholder", "toggleContent", "value" ]);
259
+ var C = (0, s._)("No matches");
260
+ var R = (0, s._)("Select...");
261
+ function T(e) {
262
+ var n = e.allowKeyMatching, r = n === void 0 ? true : n, a = e.appearance, i = a === void 0 ? "default" : a, u = e.defaultPlacement, s = u === void 0 ? "vertical" : u, d = e.defaultValue, f = e.inline, p = f === void 0 ? true : f, v = e.noOptionsMessage, b = v === void 0 ? C : v, g = e.onChange, m = e.placeholder, O = m === void 0 ? R : m, y = e.toggleContent, h = y === void 0 ? "optionChildren" : y, S = e.value, w = j(e, [ "allowKeyMatching", "appearance", "defaultPlacement", "defaultValue", "inline", "noOptionsMessage", "onChange", "placeholder", "toggleContent", "value" ]);
1852
263
  // @docs-props-type SelectPropsBase
1853
- qn({
264
+ P({
1854
265
  componentName: "Select",
1855
266
  deprecatedPropValue: "link",
1856
267
  propName: "appearance",
1857
- propValue: a
268
+ propValue: i
1858
269
  });
1859
- var C = i()({
270
+ var T = c()({
1860
271
  componentName: "Select",
1861
272
  /* eslint-disable-next-line prefer-rest-params */
1862
273
  componentProps: arguments[0]
1863
274
  });
1864
- var w = (0, t.useMemo)((function() {
275
+ var x = (0, o.useMemo)((function() {
1865
276
  // wrap defaultValue in an array once to avoid failing <SelectBase>'s defaultValues comparison check
1866
- if (s != null) {
1867
- return [ s ];
277
+ if (d != null) {
278
+ return [ d ];
1868
279
  }
1869
280
  return [];
1870
- }), [ s ]);
281
+ }), [ d ]);
1871
282
  // Converts the provided props into a structure suitable for SelectBase.
1872
- var k = (0, t.useMemo)((function() {
1873
- var e = C ? undefined : w;
1874
- var n = function e(n, t) {
1875
- var r = t.name, l = t.values;
1876
- b === null || b === void 0 ? void 0 : b(n, {
1877
- name: r,
1878
- value: l[0]
283
+ var q = (0, o.useMemo)((function() {
284
+ var e = T ? undefined : x;
285
+ var n = function e(n, o) {
286
+ var t = o.name, r = o.values;
287
+ g === null || g === void 0 ? void 0 : g(n, {
288
+ name: t,
289
+ value: r[0]
1879
290
  });
1880
291
  };
1881
- var t = {
292
+ var o = {
1882
293
  onChange: n
1883
294
  };
1884
- if (C) {
1885
- t.values = O != null ? [ O ] : [];
295
+ if (T) {
296
+ o.values = S != null ? [ S ] : [];
1886
297
  } else if (e != null) {
1887
- t.defaultValues = e;
298
+ o.defaultValues = e;
1888
299
  }
1889
- return t;
1890
- }), [ w, b, C, O ]);
300
+ return o;
301
+ }), [ x, g, T, S ]);
1891
302
 
1892
- return r().createElement(Mn, Ln({
1893
- allowKeyMatching: l,
1894
- appearance: a,
1895
- defaultPlacement: c,
1896
- inline: d,
1897
- noOptionsMessage: v,
1898
- placeholder: y,
303
+ return t().createElement(l(), M({
304
+ allowKeyMatching: r,
305
+ appearance: i,
306
+ defaultPlacement: s,
307
+ inline: p,
308
+ noOptionsMessage: b,
309
+ placeholder: O,
1899
310
  toggleContent: h
1900
- }, S, k, {
311
+ }, w, q, {
1901
312
  multiple: false
1902
313
  }));
1903
314
  }
1904
- Kn.propTypes = Bn;
1905
- Kn.Option = E;
1906
- Kn.Heading = c.Heading;
1907
- Kn.Divider = c.Divider;
1908
- /* harmony default export */ const Fn = Kn;
315
+ T.propTypes = w;
316
+ T.Option = m;
317
+ T.Heading = i.Heading;
318
+ T.Divider = i.Divider;
319
+ /* harmony default export */ const x = T;
1909
320
  // CONCATENATED MODULE: ./src/Select/index.ts
1910
321
  module.exports = n;
1911
322
  /******/})();