@splunk/react-ui 5.0.0-beta.2 → 5.0.0-beta.4

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 (187) hide show
  1. package/Accordion.js +185 -243
  2. package/Animation.js +2 -2
  3. package/Button.js +4 -4
  4. package/ButtonGroup.js +10 -11
  5. package/ButtonSimple.js +48 -42
  6. package/CHANGELOG.md +26 -0
  7. package/CHANGELOG.v5.mdx +81 -0
  8. package/Calendar.js +352 -469
  9. package/Card.js +178 -321
  10. package/Chip.js +154 -296
  11. package/Clickable.js +30 -30
  12. package/Code.js +64 -49
  13. package/Color.js +546 -462
  14. package/ComboBox.js +575 -767
  15. package/Date.js +144 -136
  16. package/Divider.js +29 -26
  17. package/DualListbox.js +441 -444
  18. package/File.js +707 -981
  19. package/FormRows.js +260 -286
  20. package/Image.js +124 -251
  21. package/JSONTree.js +129 -129
  22. package/Layout.d.ts +2 -0
  23. package/Link.js +12 -12
  24. package/MIGRATION.mdx +22 -1
  25. package/MIGRATION.v5.mdx +12 -1
  26. package/Menu.js +76 -76
  27. package/Message.js +77 -100
  28. package/MessageBar.js +141 -251
  29. package/Modal.js +42 -40
  30. package/ModalLayer.js +12 -12
  31. package/Multiselect.js +1989 -2362
  32. package/NonInteractiveCheckbox.js +30 -118
  33. package/Number.js +75 -73
  34. package/Popover.js +348 -350
  35. package/Progress.js +1 -1
  36. package/RadioBar.js +136 -136
  37. package/Resize.js +62 -65
  38. package/Scroll.js +2 -2
  39. package/Select.js +281 -283
  40. package/SidePanel.js +53 -55
  41. package/Slider.js +370 -364
  42. package/SlidingPanels.js +100 -102
  43. package/SplitButton.js +170 -343
  44. package/StaticContent.js +15 -13
  45. package/StepBar.js +61 -60
  46. package/Switch.js +150 -164
  47. package/TabBar.js +544 -417
  48. package/Table.js +1711 -1540
  49. package/Text.js +28 -26
  50. package/TextArea.js +26 -26
  51. package/Tooltip.js +416 -562
  52. package/TransitionOpen.js +179 -158
  53. package/Tree.d.ts +2 -0
  54. package/WaitSpinner.js +1 -1
  55. package/package.json +7 -9
  56. package/types/src/Accordion/Accordion.d.ts +14 -21
  57. package/types/src/Accordion/AccordionContext.d.ts +0 -1
  58. package/types/src/Animation/Animation.d.ts +2 -3
  59. package/types/src/AnimationToggle/docs/examples/Provider.d.ts +2 -2
  60. package/types/src/AnimationToggle/docs/examples/ToggleComponent.d.ts +2 -2
  61. package/types/src/AnimationToggle/useAnimationToggle.d.ts +1 -1
  62. package/types/src/Button/Button.d.ts +2 -2
  63. package/types/src/ButtonGroup/ButtonGroupContext.d.ts +0 -1
  64. package/types/src/ButtonSimple/ButtonSimple.d.ts +1 -3
  65. package/types/src/ButtonSimple/mixin.d.ts +1 -1
  66. package/types/src/Calendar/Calendar.d.ts +2 -2
  67. package/types/src/Calendar/{DateTable.d.ts → DateGrid.d.ts} +9 -9
  68. package/types/src/Calendar/Day.d.ts +8 -4
  69. package/types/src/Card/Card.d.ts +27 -14
  70. package/types/src/CardLayout/CardLayoutContext.d.ts +0 -1
  71. package/types/src/CardLayout/docs/examples/Interactive.d.ts +2 -2
  72. package/types/src/Clickable/Clickable.d.ts +1 -1
  73. package/types/src/CollapsiblePanel/SingleOpenPanelGroupContext.d.ts +0 -1
  74. package/types/src/Color/Color.d.ts +3 -3
  75. package/types/src/Color/ColorInput.d.ts +27 -0
  76. package/types/src/Color/Palette.d.ts +11 -18
  77. package/types/src/Color/Swatch.d.ts +3 -1
  78. package/types/src/ComboBox/ComboBox.d.ts +46 -50
  79. package/types/src/ComboBox/Option.d.ts +34 -18
  80. package/types/src/ControlGroup/docs/examples/CustomizedLabelTarget.d.ts +2 -2
  81. package/types/src/Date/Date.d.ts +3 -2
  82. package/types/src/Date/docs/examples/Controlled.d.ts +2 -2
  83. package/types/src/Date/docs/examples/HighlightToday.d.ts +2 -2
  84. package/types/src/DefinitionList/DefinitionListContext.d.ts +0 -1
  85. package/types/src/Divider/Divider.d.ts +14 -6
  86. package/types/src/Divider/docs/examples/Appearance.d.ts +3 -0
  87. package/types/src/DualListbox/DualListbox.d.ts +5 -1
  88. package/types/src/File/File.d.ts +6 -6
  89. package/types/src/File/FileContext.d.ts +0 -1
  90. package/types/src/File/Item.d.ts +11 -3
  91. package/types/src/File/ItemIcon.d.ts +7 -0
  92. package/types/src/File/docs/examples/Disabled.d.ts +2 -2
  93. package/types/src/File/docs/examples/DropAnywhere.d.ts +2 -2
  94. package/types/src/File/docs/examples/Multi.d.ts +2 -2
  95. package/types/src/File/docs/examples/Single.d.ts +2 -2
  96. package/types/src/FormRows/FormRows.d.ts +8 -8
  97. package/types/src/FormRows/FormRowsContext.d.ts +1 -2
  98. package/types/src/FormRows/Row.d.ts +2 -2
  99. package/types/src/FormRows/RowInternal.d.ts +1 -1
  100. package/types/src/FormRows/SortableRow.d.ts +3 -3
  101. package/types/src/FormRows/docs/examples/Basic.d.ts +2 -2
  102. package/types/src/FormRows/docs/examples/Header.d.ts +2 -2
  103. package/types/src/FormRows/docs/examples/Menu.d.ts +2 -2
  104. package/types/src/FormRows/docs/examples/ReorderOnly.d.ts +2 -2
  105. package/types/src/Image/Image.d.ts +1 -4
  106. package/types/src/JSONTree/docs/examples/Events.d.ts +2 -2
  107. package/types/src/Layout/Layout.d.ts +1 -0
  108. package/types/src/Link/icons/External.d.ts +1 -2
  109. package/types/src/Menu/Divider.d.ts +1 -1
  110. package/types/src/Menu/MenuContext.d.ts +0 -1
  111. package/types/src/MessageBar/MessageBar.d.ts +5 -1
  112. package/types/src/Modal/ModalContext.d.ts +0 -1
  113. package/types/src/Multiselect/Compact.d.ts +49 -21
  114. package/types/src/Multiselect/Multiselect.d.ts +73 -30
  115. package/types/src/Multiselect/Normal.d.ts +46 -57
  116. package/types/src/Multiselect/Option.d.ts +42 -18
  117. package/types/src/Multiselect/docs/examples/Children.d.ts +2 -2
  118. package/types/src/Multiselect/docs/examples/Controlled.d.ts +2 -2
  119. package/types/src/Multiselect/docs/examples/CustomizeSelected.d.ts +2 -2
  120. package/types/src/Multiselect/docs/examples/Disabled.d.ts +2 -2
  121. package/types/src/Multiselect/docs/examples/Error.d.ts +2 -2
  122. package/types/src/Multiselect/docs/examples/Fetching.d.ts +2 -2
  123. package/types/src/Multiselect/docs/examples/LoadMoreOnScrollBottom.d.ts +2 -2
  124. package/types/src/Multiselect/docs/examples/NewValues.d.ts +2 -2
  125. package/types/src/Multiselect/docs/examples/TabInput.d.ts +2 -2
  126. package/types/src/NonInteractiveCheckbox/NonInteractiveCheckbox.d.ts +9 -8
  127. package/types/src/Number/Number.d.ts +1 -0
  128. package/types/src/Number/docs/examples/Basic.d.ts +2 -2
  129. package/types/src/Number/docs/examples/Limits.d.ts +2 -2
  130. package/types/src/Number/docs/examples/Locale.d.ts +2 -2
  131. package/types/src/Popover/Popover.d.ts +1 -1
  132. package/types/src/Popover/PopoverMenuContext.d.ts +0 -1
  133. package/types/src/RadioBar/RadioBar.d.ts +1 -1
  134. package/types/src/RadioBar/RadioBarContext.d.ts +0 -1
  135. package/types/src/RadioList/RadioListContext.d.ts +0 -1
  136. package/types/src/Scroll/Inner.d.ts +1 -1
  137. package/types/src/Scroll/docs/examples/Controlled.d.ts +2 -2
  138. package/types/src/Search/Search.d.ts +2 -2
  139. package/types/src/Select/SelectBase.d.ts +2 -2
  140. package/types/src/SidePanel/SidePanel.d.ts +8 -3
  141. package/types/src/Slider/Slider.d.ts +1 -1
  142. package/types/src/Slider/docs/examples/Controlled.d.ts +2 -2
  143. package/types/src/Slider/docs/examples/CustomLabels.d.ts +2 -2
  144. package/types/src/Slider/getStepMarksBackground.d.ts +8 -0
  145. package/types/src/SlidingPanels/Panel.d.ts +2 -2
  146. package/types/src/SlidingPanels/SlidingPanels.d.ts +2 -2
  147. package/types/src/SlidingPanels/docs/examples/Basic.d.ts +2 -2
  148. package/types/src/SlidingPanels/docs/examples/Dropdown.d.ts +2 -2
  149. package/types/src/SplitButton/Item.d.ts +34 -20
  150. package/types/src/SplitButton/SplitButton.d.ts +4 -1
  151. package/types/src/StaticContent/StaticContent.d.ts +3 -1
  152. package/types/src/StepBar/Step.d.ts +1 -1
  153. package/types/src/StepBar/StepBar.d.ts +1 -1
  154. package/types/src/StepBar/StepBarContext.d.ts +0 -1
  155. package/types/src/Switch/Switch.d.ts +1 -9
  156. package/types/src/Switch/docs/examples/Basic.d.ts +2 -2
  157. package/types/src/Switch/docs/examples/Disabled.d.ts +2 -2
  158. package/types/src/TabBar/Tab.d.ts +12 -5
  159. package/types/src/TabBar/TabBar.d.ts +4 -3
  160. package/types/src/TabBar/TabBarContext.d.ts +7 -2
  161. package/types/src/Table/Head.d.ts +4 -15
  162. package/types/src/Table/HeadCell.d.ts +23 -25
  163. package/types/src/Table/HeadDropdownCell.d.ts +23 -26
  164. package/types/src/Table/HeadInner.d.ts +4 -10
  165. package/types/src/Table/Row.d.ts +6 -6
  166. package/types/src/Table/Table.d.ts +3 -8
  167. package/types/src/Table/TableContext.d.ts +0 -1
  168. package/types/src/Table/Toggle.d.ts +1 -1
  169. package/types/src/Text/Text.d.ts +5 -1
  170. package/types/src/Tooltip/Tooltip.d.ts +26 -58
  171. package/types/src/Tooltip/docs/examples/Controlled.d.ts +2 -2
  172. package/types/src/TransitionOpen/TransitionOpen.d.ts +6 -1
  173. package/types/src/Tree/TreeContext.d.ts +0 -1
  174. package/types/src/useForceUpdate/useForceUpdate.d.ts +0 -1
  175. package/types/src/useResizeObserver/useResizeObserver.d.ts +2 -1
  176. package/types/src/utils/types.d.ts +2 -3
  177. package/useResizeObserver.js +26 -19
  178. package/types/src/File/Icon.d.ts +0 -3
  179. package/types/src/File/IconCloud.d.ts +0 -3
  180. package/types/src/File/PaperClip.d.ts +0 -3
  181. package/types/src/File/Retry.d.ts +0 -2
  182. package/types/src/File/Trash.d.ts +0 -3
  183. package/types/src/FormRows/icons/FormRowsPlusIcon.d.ts +0 -3
  184. package/types/src/Image/icons/Cross.d.ts +0 -3
  185. package/types/src/Multiselect/docs/examples/CompactSelectAll.d.ts +0 -3
  186. package/types/src/Table/docs/examples/prisma/DockedHeaderScrollbar.d.ts +0 -3
  187. package/types/src/Tooltip/InfoIcon.d.ts +0 -4
package/ComboBox.js CHANGED
@@ -8,27 +8,27 @@
8
8
  /******/ /* webpack/runtime/compat get default export */
9
9
  /******/ (() => {
10
10
  /******/ // getDefaultExport function for compatibility with non-harmony modules
11
- /******/ e.n = t => {
12
- /******/ var n = t && t.__esModule ?
13
- /******/ () => t["default"]
14
- /******/ : () => t
11
+ /******/ e.n = n => {
12
+ /******/ var r = n && n.__esModule ?
13
+ /******/ () => n["default"]
14
+ /******/ : () => n
15
15
  /******/;
16
- e.d(n, {
17
- a: n
16
+ e.d(r, {
17
+ a: r
18
18
  });
19
- /******/ return n;
19
+ /******/ return r;
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 = (t, n) => {
27
- /******/ for (var o in n) {
28
- /******/ if (e.o(n, o) && !e.o(t, o)) {
29
- /******/ Object.defineProperty(t, o, {
26
+ /******/ e.d = (n, r) => {
27
+ /******/ for (var t in r) {
28
+ /******/ if (e.o(r, t) && !e.o(n, t)) {
29
+ /******/ Object.defineProperty(n, t, {
30
30
  enumerable: true,
31
- get: n[o]
31
+ get: r[t]
32
32
  });
33
33
  /******/ }
34
34
  /******/ }
@@ -37,7 +37,7 @@
37
37
  /******/
38
38
  /******/ /* webpack/runtime/hasOwnProperty shorthand */
39
39
  /******/ (() => {
40
- /******/ e.o = (e, t) => Object.prototype.hasOwnProperty.call(e, t)
40
+ /******/ e.o = (e, n) => Object.prototype.hasOwnProperty.call(e, n)
41
41
  /******/;
42
42
  })();
43
43
  /******/
@@ -56,855 +56,663 @@
56
56
  /******/ };
57
57
  /******/ })();
58
58
  /******/
59
- /************************************************************************/ var t = {};
59
+ /************************************************************************/ var n = {};
60
60
  // ESM COMPAT FLAG
61
- e.r(t);
61
+ e.r(n);
62
62
  // EXPORTS
63
- e.d(t, {
64
- Divider: () => /* reexport */ S.Divider,
65
- Heading: () => /* reexport */ S.Heading,
66
- Option: () => /* reexport */ J,
67
- default: () => /* reexport */ Oe
63
+ e.d(n, {
64
+ Divider: () => /* reexport */ d.Divider,
65
+ Heading: () => /* reexport */ d.Heading,
66
+ Option: () => /* reexport */ D,
67
+ default: () => /* reexport */ re
68
68
  });
69
69
  // CONCATENATED MODULE: external "react"
70
- const n = require("react");
71
- var o = e.n(n);
70
+ const r = require("react");
71
+ var t = e.n(r);
72
72
  // CONCATENATED MODULE: external "prop-types"
73
- const r = require("prop-types");
74
- var i = e.n(r);
73
+ const o = require("prop-types");
74
+ var a = e.n(o);
75
75
  // CONCATENATED MODULE: external "lodash/extend"
76
- const a = require("lodash/extend");
77
- var l = e.n(a);
78
- // CONCATENATED MODULE: external "lodash/has"
79
- const u = require("lodash/has");
80
- var c = e.n(u);
76
+ const i = require("lodash/extend");
77
+ var l = e.n(i);
81
78
  // CONCATENATED MODULE: external "lodash/memoize"
82
- const s = require("lodash/memoize");
83
- var p = e.n(s);
84
- // CONCATENATED MODULE: external "lodash/omit"
85
- const f = require("lodash/omit");
86
- var d = e.n(f);
87
- // CONCATENATED MODULE: external "lodash/pick"
88
- const v = require("lodash/pick");
89
- var b = e.n(v);
79
+ const u = require("lodash/memoize");
80
+ var c = e.n(u);
90
81
  // CONCATENATED MODULE: external "lodash/some"
91
- const h = require("lodash/some");
92
- var y = e.n(h);
93
- // CONCATENATED MODULE: external "@splunk/ui-utils/filter"
94
- const m = require("@splunk/ui-utils/filter");
95
- // CONCATENATED MODULE: external "@splunk/ui-utils/id"
96
- const g = require("@splunk/ui-utils/id");
97
- // CONCATENATED MODULE: external "@splunk/ui-utils/i18n"
98
- const O = require("@splunk/ui-utils/i18n");
99
- // CONCATENATED MODULE: external "@splunk/ui-utils/keyboard"
100
- const w = require("@splunk/ui-utils/keyboard");
82
+ const s = require("lodash/some");
83
+ var f = e.n(s);
101
84
  // CONCATENATED MODULE: external "@splunk/react-ui/Menu"
102
- const S = require("@splunk/react-ui/Menu");
85
+ const d = require("@splunk/react-ui/Menu");
103
86
  // CONCATENATED MODULE: external "@splunk/react-ui/Popover"
104
- const P = require("@splunk/react-ui/Popover");
105
- var j = e.n(P);
87
+ const p = require("@splunk/react-ui/Popover");
88
+ var v = e.n(p);
106
89
  // CONCATENATED MODULE: external "@splunk/react-ui/ResultsMenu"
107
- const I = require("@splunk/react-ui/ResultsMenu");
108
- var C = e.n(I);
90
+ const b = require("@splunk/react-ui/ResultsMenu");
91
+ var m = e.n(b);
109
92
  // CONCATENATED MODULE: external "@splunk/react-ui/Text"
110
- const k = require("@splunk/react-ui/Text");
111
- var x = e.n(k);
112
- // CONCATENATED MODULE: ./src/utils/scrollIntoViewIfNeeded.ts
113
- // A utility that attempts to move an element into view by scrolling it's derived parent.
114
- var R = function e(t) {
115
- if (!t) {
116
- return;
117
- }
118
- var n = t.offsetParent;
119
- if (!n) {
120
- return;
121
- }
122
- // Below the bottom of the container.
123
- if (n.scrollTop + n.clientHeight < t.offsetTop + t.clientHeight) {
124
- n.scrollTop = t.offsetTop + t.clientHeight - n.clientHeight;
125
- // Above the top of the container.
126
- } else if (n.scrollTop > t.offsetTop) {
127
- n.scrollTop = t.offsetTop;
93
+ const y = require("@splunk/react-ui/Text");
94
+ var g = e.n(y);
95
+ // CONCATENATED MODULE: external "@splunk/react-ui/useControlled"
96
+ const h = require("@splunk/react-ui/useControlled");
97
+ var O = e.n(h);
98
+ // CONCATENATED MODULE: external "@splunk/react-ui/usePrevious"
99
+ const S = require("@splunk/react-ui/usePrevious");
100
+ var C = e.n(S);
101
+ // CONCATENATED MODULE: external "@splunk/ui-utils/filter"
102
+ const k = require("@splunk/ui-utils/filter");
103
+ // CONCATENATED MODULE: external "@splunk/ui-utils/i18n"
104
+ const P = require("@splunk/ui-utils/i18n");
105
+ // CONCATENATED MODULE: external "@splunk/ui-utils/id"
106
+ const w = require("@splunk/ui-utils/id");
107
+ // CONCATENATED MODULE: external "@splunk/ui-utils/keyboard"
108
+ const j = require("@splunk/ui-utils/keyboard");
109
+ // CONCATENATED MODULE: ./src/utils/updateReactRef.ts
110
+ /**
111
+ * Updates a React ref. Callback refs and object refs (from `createRef` and `useRef`) are supported.
112
+ *
113
+ * @param ref - The React callback or object ref. Can be `null` or `undefined`.
114
+ * @param current - The new value of the ref.
115
+ */
116
+ function R(e, n) {
117
+ if (e) {
118
+ if (typeof e === "function") {
119
+ e(n);
120
+ } else {
121
+ // the public signature of this util uses React.Ref<T> to mirror the way React types refs.
122
+ // the intention here is to signal "we will take care of setting 'current', not you".
123
+ e.current = n;
124
+ // eslint-disable-line no-param-reassign
125
+ }
128
126
  }
129
- };
130
- // CONCATENATED MODULE: ./src/ComboBox/Option.tsx
131
- function E(e) {
132
- "@babel/helpers - typeof";
133
- return E = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
134
- return typeof e;
135
- } : function(e) {
136
- return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
137
- }, E(e);
138
127
  }
128
+ // CONCATENATED MODULE: ./src/ComboBox/Option.tsx
139
129
  function M() {
140
130
  return M = Object.assign ? Object.assign.bind() : function(e) {
141
- for (var t = 1; t < arguments.length; t++) {
142
- var n = arguments[t];
143
- for (var o in n) {
144
- ({}).hasOwnProperty.call(n, o) && (e[o] = n[o]);
131
+ for (var n = 1; n < arguments.length; n++) {
132
+ var r = arguments[n];
133
+ for (var t in r) {
134
+ ({}).hasOwnProperty.call(r, t) && (e[t] = r[t]);
145
135
  }
146
136
  }
147
137
  return e;
148
138
  }, M.apply(null, arguments);
149
139
  }
150
- function V(e, t) {
140
+ function q(e, n) {
151
141
  if (null == e) return {};
152
- var n, o, r = T(e, t);
142
+ var r, t, o = E(e, n);
153
143
  if (Object.getOwnPropertySymbols) {
154
- var i = Object.getOwnPropertySymbols(e);
155
- for (o = 0; o < i.length; o++) {
156
- n = i[o], t.includes(n) || {}.propertyIsEnumerable.call(e, n) && (r[n] = e[n]);
144
+ var a = Object.getOwnPropertySymbols(e);
145
+ for (t = 0; t < a.length; t++) {
146
+ r = a[t], n.includes(r) || {}.propertyIsEnumerable.call(e, r) && (o[r] = e[r]);
157
147
  }
158
148
  }
159
- return r;
149
+ return o;
160
150
  }
161
- function T(e, t) {
151
+ function E(e, n) {
162
152
  if (null == e) return {};
163
- var n = {};
164
- for (var o in e) {
165
- if ({}.hasOwnProperty.call(e, o)) {
166
- if (t.includes(o)) continue;
167
- n[o] = e[o];
153
+ var r = {};
154
+ for (var t in e) {
155
+ if ({}.hasOwnProperty.call(e, t)) {
156
+ if (n.includes(t)) continue;
157
+ r[t] = e[t];
168
158
  }
169
159
  }
170
- return n;
171
- }
172
- function D(e, t) {
173
- if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function");
174
- }
175
- function q(e, t) {
176
- for (var n = 0; n < t.length; n++) {
177
- var o = t[n];
178
- o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0),
179
- Object.defineProperty(e, W(o.key), o);
180
- }
181
- }
182
- function _(e, t, n) {
183
- return t && q(e.prototype, t), n && q(e, n), Object.defineProperty(e, "prototype", {
184
- writable: !1
185
- }), e;
186
- }
187
- function B(e, t) {
188
- if ("function" != typeof t && null !== t) throw new TypeError("Super expression must either be null or a function");
189
- e.prototype = Object.create(t && t.prototype, {
190
- constructor: {
191
- value: e,
192
- writable: !0,
193
- configurable: !0
194
- }
195
- }), Object.defineProperty(e, "prototype", {
196
- writable: !1
197
- }), t && A(e, t);
198
- }
199
- function A(e, t) {
200
- return A = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(e, t) {
201
- return e.__proto__ = t, e;
202
- }, A(e, t);
203
- }
204
- function H(e) {
205
- var t = K();
206
- return function() {
207
- var n, o = N(e);
208
- if (t) {
209
- var r = N(this).constructor;
210
- n = Reflect.construct(o, arguments, r);
211
- } else n = o.apply(this, arguments);
212
- return L(this, n);
213
- };
214
- }
215
- function L(e, t) {
216
- if (t && ("object" == E(t) || "function" == typeof t)) return t;
217
- if (void 0 !== t) throw new TypeError("Derived constructors may only return object or undefined");
218
- return F(e);
219
- }
220
- function F(e) {
221
- if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
222
- return e;
223
- }
224
- function K() {
225
- try {
226
- var e = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], (function() {})));
227
- } catch (e) {}
228
- return (K = function t() {
229
- return !!e;
230
- })();
231
- }
232
- function N(e) {
233
- return N = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(e) {
234
- return e.__proto__ || Object.getPrototypeOf(e);
235
- }, N(e);
236
- }
237
- function z(e, t, n) {
238
- return (t = W(t)) in e ? Object.defineProperty(e, t, {
239
- value: n,
240
- enumerable: !0,
241
- configurable: !0,
242
- writable: !0
243
- }) : e[t] = n, e;
244
- }
245
- function W(e) {
246
- var t = U(e, "string");
247
- return "symbol" == E(t) ? t : t + "";
248
- }
249
- function U(e, t) {
250
- if ("object" != E(e) || !e) return e;
251
- var n = e[Symbol.toPrimitive];
252
- if (void 0 !== n) {
253
- var o = n.call(e, t || "default");
254
- if ("object" != E(o)) return o;
255
- throw new TypeError("@@toPrimitive must return a primitive value.");
256
- }
257
- return ("string" === t ? String : Number)(e);
160
+ return r;
258
161
  }
259
- var X = {
162
+ var T = {
260
163
  /** @private */
261
- active: i().bool,
262
- description: i().string,
263
- descriptionPosition: i().oneOf([ "right", "bottom" ]),
264
- disabled: i().bool,
265
- icon: i().node,
266
- label: i().string,
267
- matchRanges: i().arrayOf(i().shape({
268
- start: i().number.isRequired,
269
- end: i().number.isRequired
164
+ active: a().bool,
165
+ description: a().string,
166
+ descriptionPosition: a().oneOf([ "right", "bottom" ]),
167
+ disabled: a().bool,
168
+ elementRef: a().oneOfType([ a().func, a().object ]),
169
+ icon: a().node,
170
+ label: a().string,
171
+ matchRanges: a().arrayOf(a().shape({
172
+ start: a().number.isRequired,
173
+ end: a().number.isRequired
270
174
  })),
271
175
  /** @private */
272
- onClick: i().func,
273
- truncate: i().bool,
274
- value: i().string.isRequired
275
- };
276
- var Y = {
277
- active: false,
278
- descriptionPosition: "bottom",
279
- disabled: false,
280
- truncate: false
176
+ onClick: a().func,
177
+ truncate: a().bool,
178
+ value: a().string.isRequired
281
179
  };
282
180
  /**
283
- * An option within a `ComboBox`. This inherits from
284
- * [PureComponent](https://reactjs.org/docs/react-api.html#reactpurecomponent)
285
- * so any elements passed to it must also be pure.
286
- */ var G = function(e) {
287
- B(n, e);
288
- var t = H(n);
289
- function n() {
290
- var e;
291
- D(this, n);
292
- for (var r = arguments.length, i = new Array(r), a = 0; a < r; a++) {
293
- i[a] = arguments[a];
181
+ * An option within a `ComboBox`.
182
+ */ function B(e) {
183
+ var n = e.active, o = e.description, a = e.descriptionPosition, i = a === void 0 ? "bottom" : a, l = e.disabled, u = e.elementRef, c = e.icon, s = e.label, f = e.matchRanges, p = e.onClick, v = e.truncate, b = e.value, m = q(e, [ "active", "description", "descriptionPosition", "disabled", "elementRef", "icon", "label", "matchRanges", "onClick", "truncate", "value" ]);
184
+ // @docs-props-type OptionPropsBase
185
+ var y = (0, r.useCallback)((function(e) {
186
+ if (!l) {
187
+ p === null || p === void 0 ? void 0 : p(e, {
188
+ value: b
189
+ });
294
190
  }
295
- e = t.call.apply(t, [ this ].concat(i));
296
- z(F(e), "itemRef", o().createRef());
297
- z(F(e), "handleClick", (function(t) {
298
- var n = e.props, o = n.disabled, r = n.onClick, i = n.value;
299
- if (!o) {
300
- r === null || r === void 0 ? void 0 : r(t, {
301
- value: i
302
- });
303
- }
304
- }));
305
- return e;
191
+ }), [ l, p, b ]);
192
+ var g = (0, r.useCallback)((function(e) {
193
+ R(u, e);
194
+ }), [ u ]);
195
+ var h = s === undefined ? b : s;
196
+
197
+ return t().createElement(d.Item, M({
198
+ active: n,
199
+ "data-test": "option",
200
+ "data-test-value": b,
201
+ description: o,
202
+ descriptionPosition: i,
203
+ disabled: l,
204
+ elementRef: g,
205
+ startAdornment: c,
206
+ matchRanges: f,
207
+ onClick: y,
208
+ truncate: v
209
+ }, m, {
210
+ role: "option"
211
+ }), h);
212
+ }
213
+ B.propTypes = T;
214
+ B.as = "Item";
215
+ /* harmony default export */ const D = B;
216
+ // CONCATENATED MODULE: ./src/utils/scrollIntoViewIfNeeded.ts
217
+ // A utility that attempts to move an element into view by scrolling it's derived parent.
218
+ var x = function e(n) {
219
+ if (!n) {
220
+ return;
306
221
  }
307
- // @docs-props-type OptionPropsBase
308
- _(n, [ {
309
- key: "scrollIntoViewIfNeeded",
310
- // eslint-disable-next-line react/no-unused-class-component-methods
311
- value: function e() {
312
- R(this.itemRef.current);
313
- }
314
- }, {
315
- key: "render",
316
- value: function e() {
317
- // eslint-disable-next-line no-unused-vars
318
- var t = this.props, n = t.value, r = t.label, i = V(t, [ "value", "label" ]);
319
- var a = r === undefined ? n : r;
320
-
321
- return o().createElement(S.Item, M({
322
- elementRef: this.itemRef,
323
- "data-test": "option",
324
- "data-test-value": n
325
- }, i, {
326
- onClick: this.handleClick,
327
- role: "option"
328
- }), a);
329
- }
330
- } ]);
331
- return n;
332
- }(n.PureComponent);
333
- z(G, "propTypes", X);
334
- z(G, "defaultProps", Y);
335
- /* harmony default export */ const J = G;
336
- // CONCATENATED MODULE: ./src/utils/updateReactRef.ts
337
- /**
338
- * Updates a React ref. Callback refs and object refs (from `createRef` and `useRef`) are supported.
339
- *
340
- * @param ref - The React callback or object ref. Can be `null` or `undefined`.
341
- * @param current - The new value of the ref.
342
- */
343
- function Q(e, t) {
344
- if (e) {
345
- if (typeof e === "function") {
346
- e(t);
347
- } else {
348
- // the public signature of this util uses React.Ref<T> to mirror the way React types refs.
349
- // the intention here is to signal "we will take care of setting 'current', not you".
350
- e.current = t;
351
- // eslint-disable-line no-param-reassign
352
- }
222
+ var r = n.offsetParent;
223
+ if (!r) {
224
+ return;
353
225
  }
354
- }
226
+ // Below the bottom of the container.
227
+ if (r.scrollTop + r.clientHeight < n.offsetTop + n.clientHeight) {
228
+ r.scrollTop = n.offsetTop + n.clientHeight - r.clientHeight;
229
+ // Above the top of the container.
230
+ } else if (r.scrollTop > n.offsetTop) {
231
+ r.scrollTop = n.offsetTop;
232
+ }
233
+ };
355
234
  // CONCATENATED MODULE: ./src/ComboBox/ComboBox.tsx
356
- function Z(e) {
235
+ function I(e) {
357
236
  "@babel/helpers - typeof";
358
- return Z = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
237
+ return I = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
359
238
  return typeof e;
360
239
  } : function(e) {
361
240
  return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
362
- }, Z(e);
363
- }
364
- function $() {
365
- return $ = Object.assign ? Object.assign.bind() : function(e) {
366
- for (var t = 1; t < arguments.length; t++) {
367
- var n = arguments[t];
368
- for (var o in n) {
369
- ({}).hasOwnProperty.call(n, o) && (e[o] = n[o]);
241
+ }, I(e);
242
+ }
243
+ function A() {
244
+ return A = Object.assign ? Object.assign.bind() : function(e) {
245
+ for (var n = 1; n < arguments.length; n++) {
246
+ var r = arguments[n];
247
+ for (var t in r) {
248
+ ({}).hasOwnProperty.call(r, t) && (e[t] = r[t]);
370
249
  }
371
250
  }
372
251
  return e;
373
- }, $.apply(null, arguments);
252
+ }, A.apply(null, arguments);
374
253
  }
375
- function ee(e, t) {
376
- var n = Object.keys(e);
254
+ function H(e, n) {
255
+ var r = Object.keys(e);
377
256
  if (Object.getOwnPropertySymbols) {
378
- var o = Object.getOwnPropertySymbols(e);
379
- t && (o = o.filter((function(t) {
380
- return Object.getOwnPropertyDescriptor(e, t).enumerable;
381
- }))), n.push.apply(n, o);
257
+ var t = Object.getOwnPropertySymbols(e);
258
+ n && (t = t.filter((function(n) {
259
+ return Object.getOwnPropertyDescriptor(e, n).enumerable;
260
+ }))), r.push.apply(r, t);
382
261
  }
383
- return n;
262
+ return r;
384
263
  }
385
- function te(e) {
386
- for (var t = 1; t < arguments.length; t++) {
387
- var n = null != arguments[t] ? arguments[t] : {};
388
- t % 2 ? ee(Object(n), !0).forEach((function(t) {
389
- fe(e, t, n[t]);
390
- })) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : ee(Object(n)).forEach((function(t) {
391
- Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(n, t));
264
+ function L(e) {
265
+ for (var n = 1; n < arguments.length; n++) {
266
+ var r = null != arguments[n] ? arguments[n] : {};
267
+ n % 2 ? H(Object(r), !0).forEach((function(n) {
268
+ z(e, n, r[n]);
269
+ })) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : H(Object(r)).forEach((function(n) {
270
+ Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(r, n));
392
271
  }));
393
272
  }
394
273
  return e;
395
274
  }
396
- function ne(e, t) {
397
- if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function");
275
+ function z(e, n, r) {
276
+ return (n = F(n)) in e ? Object.defineProperty(e, n, {
277
+ value: r,
278
+ enumerable: !0,
279
+ configurable: !0,
280
+ writable: !0
281
+ }) : e[n] = r, e;
398
282
  }
399
- function oe(e, t) {
400
- for (var n = 0; n < t.length; n++) {
401
- var o = t[n];
402
- o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0),
403
- Object.defineProperty(e, de(o.key), o);
283
+ function F(e) {
284
+ var n = V(e, "string");
285
+ return "symbol" == I(n) ? n : n + "";
286
+ }
287
+ function V(e, n) {
288
+ if ("object" != I(e) || !e) return e;
289
+ var r = e[Symbol.toPrimitive];
290
+ if (void 0 !== r) {
291
+ var t = r.call(e, n || "default");
292
+ if ("object" != I(t)) return t;
293
+ throw new TypeError("@@toPrimitive must return a primitive value.");
404
294
  }
295
+ return ("string" === n ? String : Number)(e);
405
296
  }
406
- function re(e, t, n) {
407
- return t && oe(e.prototype, t), n && oe(e, n), Object.defineProperty(e, "prototype", {
408
- writable: !1
409
- }), e;
297
+ function K(e, n) {
298
+ return X(e) || U(e, n) || W(e, n) || _();
410
299
  }
411
- function ie(e, t) {
412
- if ("function" != typeof t && null !== t) throw new TypeError("Super expression must either be null or a function");
413
- e.prototype = Object.create(t && t.prototype, {
414
- constructor: {
415
- value: e,
416
- writable: !0,
417
- configurable: !0
418
- }
419
- }), Object.defineProperty(e, "prototype", {
420
- writable: !1
421
- }), t && ae(e, t);
422
- }
423
- function ae(e, t) {
424
- return ae = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(e, t) {
425
- return e.__proto__ = t, e;
426
- }, ae(e, t);
427
- }
428
- function le(e) {
429
- var t = se();
430
- return function() {
431
- var n, o = pe(e);
432
- if (t) {
433
- var r = pe(this).constructor;
434
- n = Reflect.construct(o, arguments, r);
435
- } else n = o.apply(this, arguments);
436
- return ue(this, n);
437
- };
438
- }
439
- function ue(e, t) {
440
- if (t && ("object" == Z(t) || "function" == typeof t)) return t;
441
- if (void 0 !== t) throw new TypeError("Derived constructors may only return object or undefined");
442
- return ce(e);
443
- }
444
- function ce(e) {
445
- if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
446
- return e;
300
+ function _() {
301
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
447
302
  }
448
- function se() {
449
- try {
450
- var e = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], (function() {})));
451
- } catch (e) {}
452
- return (se = function t() {
453
- return !!e;
454
- })();
303
+ function W(e, n) {
304
+ if (e) {
305
+ if ("string" == typeof e) return N(e, n);
306
+ var r = {}.toString.call(e).slice(8, -1);
307
+ return "Object" === r && e.constructor && (r = e.constructor.name), "Map" === r || "Set" === r ? Array.from(e) : "Arguments" === r || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r) ? N(e, n) : void 0;
308
+ }
455
309
  }
456
- function pe(e) {
457
- return pe = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(e) {
458
- return e.__proto__ || Object.getPrototypeOf(e);
459
- }, pe(e);
310
+ function N(e, n) {
311
+ (null == n || n > e.length) && (n = e.length);
312
+ for (var r = 0, t = Array(n); r < n; r++) {
313
+ t[r] = e[r];
314
+ }
315
+ return t;
316
+ }
317
+ function U(e, n) {
318
+ var r = null == e ? null : "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"];
319
+ if (null != r) {
320
+ var t, o, a, i, l = [], u = !0, c = !1;
321
+ try {
322
+ if (a = (r = r.call(e)).next, 0 === n) {
323
+ if (Object(r) !== r) return;
324
+ u = !1;
325
+ } else for (;!(u = (t = a.call(r)).done) && (l.push(t.value), l.length !== n); u = !0) {
326
+ }
327
+ } catch (e) {
328
+ c = !0, o = e;
329
+ } finally {
330
+ try {
331
+ if (!u && null != r["return"] && (i = r["return"](), Object(i) !== i)) return;
332
+ } finally {
333
+ if (c) throw o;
334
+ }
335
+ }
336
+ return l;
337
+ }
460
338
  }
461
- function fe(e, t, n) {
462
- return (t = de(t)) in e ? Object.defineProperty(e, t, {
463
- value: n,
464
- enumerable: !0,
465
- configurable: !0,
466
- writable: !0
467
- }) : e[t] = n, e;
339
+ function X(e) {
340
+ if (Array.isArray(e)) return e;
468
341
  }
469
- function de(e) {
470
- var t = ve(e, "string");
471
- return "symbol" == Z(t) ? t : t + "";
342
+ function Y(e, n) {
343
+ if (null == e) return {};
344
+ var r, t, o = $(e, n);
345
+ if (Object.getOwnPropertySymbols) {
346
+ var a = Object.getOwnPropertySymbols(e);
347
+ for (t = 0; t < a.length; t++) {
348
+ r = a[t], n.includes(r) || {}.propertyIsEnumerable.call(e, r) && (o[r] = e[r]);
349
+ }
350
+ }
351
+ return o;
472
352
  }
473
- function ve(e, t) {
474
- if ("object" != Z(e) || !e) return e;
475
- var n = e[Symbol.toPrimitive];
476
- if (void 0 !== n) {
477
- var o = n.call(e, t || "default");
478
- if ("object" != Z(o)) return o;
479
- throw new TypeError("@@toPrimitive must return a primitive value.");
353
+ function $(e, n) {
354
+ if (null == e) return {};
355
+ var r = {};
356
+ for (var t in e) {
357
+ if ({}.hasOwnProperty.call(e, t)) {
358
+ if (n.includes(t)) continue;
359
+ r[t] = e[t];
360
+ }
480
361
  }
481
- return ("string" === t ? String : Number)(e);
362
+ return r;
482
363
  }
483
364
  /** @public */
484
365
  /** @public */
485
366
  /** @public */
486
- /** @public */ var be = {
487
- animateLoading: i().bool,
488
- append: i().bool,
489
- children: i().node,
490
- controlledFilter: i().bool,
491
- defaultPlacement: i().oneOf([ "above", "below", "vertical" ]),
492
- defaultValue: i().string,
493
- describedBy: i().string,
494
- disabled: i().bool,
495
- elementRef: i().oneOfType([ i().func, i().object ]),
496
- error: i().bool,
497
- footerMessage: i().node,
498
- inline: i().bool,
499
- inputId: i().string,
500
- inputRef: i().oneOfType([ i().func, i().object ]),
501
- isLoadingOptions: i().bool,
502
- labelledBy: i().string,
503
- loadingMessage: i().node,
504
- menuStyle: i().object,
505
- name: i().string,
506
- noOptionsMessage: i().node,
507
- onBlur: i().func,
508
- onChange: i().func,
509
- onClose: i().func,
510
- onFocus: i().func,
511
- onKeyDown: i().func,
512
- onOpen: i().func,
513
- onScroll: i().func,
514
- onScrollBottom: i().func,
515
- onSelect: i().func,
516
- placeholder: i().string,
517
- prepend: i().bool,
518
- value: i().string,
367
+ /** @public */ var G = {
368
+ animateLoading: a().bool,
369
+ append: a().bool,
370
+ children: a().node,
371
+ controlledFilter: a().bool,
372
+ defaultPlacement: a().oneOf([ "above", "below", "vertical" ]),
373
+ defaultValue: a().string,
374
+ describedBy: a().string,
375
+ disabled: a().bool,
376
+ elementRef: a().oneOfType([ a().func, a().object ]),
377
+ error: a().bool,
378
+ footerMessage: a().node,
379
+ inline: a().bool,
380
+ inputId: a().string,
381
+ inputRef: a().oneOfType([ a().func, a().object ]),
382
+ isLoadingOptions: a().bool,
383
+ labelledBy: a().string,
384
+ loadingMessage: a().node,
385
+ menuStyle: a().object,
386
+ name: a().string,
387
+ noOptionsMessage: a().node,
388
+ onBlur: a().func,
389
+ onChange: a().func,
390
+ onClose: a().func,
391
+ onFocus: a().func,
392
+ onKeyDown: a().func,
393
+ onOpen: a().func,
394
+ onScroll: a().func,
395
+ onScrollBottom: a().func,
396
+ onSelect: a().func,
397
+ placeholder: a().string,
398
+ prepend: a().bool,
399
+ value: a().string,
519
400
  /** @private. */
520
- virtualization: i().number
521
- };
522
- var he = {
523
- animateLoading: false,
524
- controlledFilter: false,
525
- defaultPlacement: "vertical",
526
- disabled: false,
527
- error: false,
528
- inline: false,
529
- isLoadingOptions: false,
530
- menuStyle: {},
531
- placeholder: (0, O._)("Select...")
401
+ virtualization: a().number
532
402
  };
533
- function ye(e, t) {
534
- var n = t.clientX, o = t.clientY;
535
- var r = e.getBoundingClientRect(), i = r.top, a = r.left, l = r.bottom, u = r.right;
536
- return n > a && n < u && o > i && o < l;
403
+ function J(e, n) {
404
+ var r = n.clientX, t = n.clientY;
405
+ var o = e.getBoundingClientRect(), a = o.top, i = o.left, l = o.bottom, u = o.right;
406
+ return r > i && r < u && t > a && t < l;
537
407
  }
538
- var me = p()((function(e) {
539
- var t = e.anchorWidth, n = e.maxHeight, o = e.menuStyle;
408
+ var Q = c()((function(e) {
409
+ var n = e.anchorWidth, r = e.maxHeight, t = e.menuStyle;
540
410
  return l()({
541
- maxHeight: n,
411
+ maxHeight: r,
542
412
  overflow: "auto",
543
- width: Math.max(t !== null && t !== void 0 ? t : 0, 200)
544
- }, o);
413
+ width: Math.max(n !== null && n !== void 0 ? n : 0, 200)
414
+ }, t);
545
415
  }));
416
+ var Z = {};
417
+ var ee = (0, P._)("Select...");
546
418
  /**
547
419
  * `ComboBox` allows the user to select a predefined string or enter a new value. Unlike `Select`
548
420
  * and `Multiselect`, `Option` value must always be a string.
549
- */ var ge = function(e) {
550
- ie(r, e);
551
- var t = le(r);
421
+ */ function ne(e) {
422
+ var n = e.animateLoading, o = e.append, a = e.children, i = e.controlledFilter, l = e.defaultPlacement, u = l === void 0 ? "vertical" : l, c = e.defaultValue, s = e.describedBy, d = e.disabled, p = e.elementRef, y = e.error, h = e.footerMessage, S = e.inline, M = e.inputId, q = e.inputRef, E = e.isLoadingOptions, T = e.labelledBy, B = e.loadingMessage, I = e.menuStyle, H = I === void 0 ? Z : I, z = e.name, F = e.noOptionsMessage, V = e.onBlur, _ = e.onChange, W = e.onClose, N = e.onFocus, U = e.onKeyDown, X = e.onOpen, $ = e.onScroll, G = e.onScrollBottom, ne = e.onSelect, re = e.placeholder, te = re === void 0 ? ee : re, oe = e.prepend, ae = e.value, ie = e.virtualization, le = Y(e, [ "animateLoading", "append", "children", "controlledFilter", "defaultPlacement", "defaultValue", "describedBy", "disabled", "elementRef", "error", "footerMessage", "inline", "inputId", "inputRef", "isLoadingOptions", "labelledBy", "loadingMessage", "menuStyle", "name", "noOptionsMessage", "onBlur", "onChange", "onClose", "onFocus", "onKeyDown", "onOpen", "onScroll", "onScrollBottom", "onSelect", "placeholder", "prepend", "value", "virtualization" ]);
552
423
  // @docs-props-type ComboBoxPropsBase
553
- function r(e) {
554
- var i;
555
- ne(this, r);
556
- i = t.call(this, e);
557
- fe(ce(i), "activeItemId", void 0);
558
- fe(ce(i), "activeValue", void 0);
559
- fe(ce(i), "availableOptionCount", 0);
560
- fe(ce(i), "controlledExternally", void 0);
561
- fe(ce(i), "options", void 0);
562
- fe(ce(i), "popoverId", void 0);
563
- fe(ce(i), "previousActiveIndex", null);
564
- fe(ce(i), "textInput", null);
565
- fe(ce(i), "handleInputMount", (function(e) {
566
- i.textInput = e;
567
- Q(i.props.inputRef, e);
424
+ var ue = O()({
425
+ componentName: "ComboBox",
426
+ /* eslint-disable-next-line prefer-rest-params */
427
+ componentProps: arguments[0]
428
+ });
429
+ var ce = (0, r.useState)(0), se = K(ce, 2), fe = se[0], de = se[1];
430
+ var pe = (0, r.useState)(null), ve = K(pe, 2), be = ve[0], me = ve[1];
431
+ var ye = (0, r.useState)(false), ge = K(ye, 2), he = ge[0], Oe = ge[1];
432
+ var Se = (0, r.useState)(null), Ce = K(Se, 2), ke = Ce[0], Pe = Ce[1];
433
+ var we = (0, r.useState)(), je = K(we, 2), Re = je[0], Me = je[1];
434
+ var qe = (0, r.useState)(c || ""), Ee = K(qe, 2), Te = Ee[0], Be = Ee[1];
435
+ var De = C()(fe);
436
+ var xe = (0, r.useRef)();
437
+ var Ie = (0, r.useRef)(0);
438
+ var Ae = (0, r.useRef)(De);
439
+ var He = (0, w.createDOMID)("popover");
440
+ var Le = (0, w.createDOMID)("active-item");
441
+ var ze = (0, r.useCallback)((function() {
442
+ Oe(false);
443
+ Ae.current = null;
444
+ W === null || W === void 0 ? void 0 : W();
445
+ }), [ W ]);
446
+ var Fe = (0, r.useCallback)((function() {
447
+ if (!he) {
448
+ Oe(true);
449
+ de(0);
450
+ X === null || X === void 0 ? void 0 : X();
451
+ }
452
+ }), [ he, X ]);
453
+ var Ve = (0, r.useCallback)((function() {
454
+ return ue ? ae : Te;
455
+ }), [ ue, ae, Te ]);
456
+ var Ke = (0, r.useCallback)((function() {
457
+ var e = Ve();
458
+ var n = r.Children.toArray(a).filter(r.isValidElement);
459
+ var t = !Re && n.find((function(n) {
460
+ return n.props.label !== undefined && n.props.value === e;
568
461
  }));
569
- fe(ce(i), "handleAnchorMount", (function(e) {
570
- i.setState({
571
- anchor: e
572
- });
573
- Q(i.props.elementRef, e);
462
+ if (t) {
463
+ return t === null || t === void 0 ? void 0 : t.props.label;
464
+ }
465
+ return e;
466
+ }), [ a, Ve, Re ]);
467
+ var _e = (0, r.useCallback)((function(e) {
468
+ Pe(e);
469
+ R(q, e);
470
+ }), [ q ]);
471
+ var We = (0, r.useCallback)((function(e) {
472
+ me(e);
473
+ R(p, e);
474
+ }), [ p ]);
475
+ var Ne = (0, r.useCallback)((function(e) {
476
+ if (Ae.current !== fe) {
477
+ x(e);
478
+ }
479
+ }), [ fe, Ae ]);
480
+ var Ue = (0, r.useCallback)((function(e, n) {
481
+ Fe();
482
+ N === null || N === void 0 ? void 0 : N(e, n);
483
+ }), [ N, Fe ]);
484
+ var Xe = (0, r.useCallback)((function(e, n) {
485
+ var r = n.value, t = n.selectedOption;
486
+ e.stopPropagation();
487
+ var o = t ? undefined : r;
488
+ de(0);
489
+ Me(o);
490
+ if (!ue) {
491
+ Be(r);
492
+ }
493
+ _ === null || _ === void 0 ? void 0 : _(e, {
494
+ value: r,
495
+ name: z
496
+ });
497
+ }), [ ue, z, _ ]);
498
+ var Ye = (0, r.useCallback)((function(e, n) {
499
+ Xe(e, L(L({}, n), {}, {
500
+ selectedOption: true
574
501
  }));
575
- fe(ce(i), "handleActiveOptionMount", (function(e) {
576
- if (i.previousActiveIndex !== i.state.activeIndex) {
577
- e === null || e === void 0 ? void 0 : e.scrollIntoViewIfNeeded();
502
+ ke === null || ke === void 0 ? void 0 : ke.focus();
503
+ ze();
504
+ }), [ ze, Xe, ke ]);
505
+ var $e = (0, r.useCallback)((function(e) {
506
+ e.stopPropagation();
507
+ if (!d) {
508
+ Fe();
509
+ }
510
+ }), [ d, Fe ]);
511
+ var Ge = (0, r.useCallback)((function(e) {
512
+ var n = e.event, r = e.reason;
513
+ var t = r === "offScreen" || r === "escapeKey" || r === "clickAway" && be && !J(be, n);
514
+ if (t) {
515
+ ze();
516
+ }
517
+ }), [ be, ze ]);
518
+ var Je = (0, r.useCallback)((function(e) {
519
+ if (he && !E) {
520
+ G === null || G === void 0 ? void 0 : G(e);
521
+ }
522
+ }), [ E, he, G ]);
523
+ var Qe = (0, r.useMemo)((function() {
524
+ var e = Ve();
525
+ var n = r.Children.toArray(a).filter(r.isValidElement);
526
+ var o = f()(n, (function(n) {
527
+ if (n.props.label === undefined) {
528
+ return n.props.value === e;
578
529
  }
579
- }));
580
- fe(ce(i), "handleInputFocus", (function(e, t) {
581
- var n, o;
582
- i.open();
583
- (n = (o = i.props).onFocus) === null || n === void 0 ? void 0 : n.call(o, e, t);
584
- }));
585
- fe(ce(i), "handleChange", (function(e, t) {
586
- var n, o;
587
- var r = t.value, a = t.selectedOption;
588
- e.stopPropagation();
589
- var l = i.props.name;
590
- var u = a ? undefined : r;
591
- if (i.isControlled()) {
592
- i.setState({
593
- activeIndex: 0,
594
- typedValue: u
595
- });
596
- } else {
597
- i.setState({
598
- value: r,
599
- activeIndex: 0,
600
- typedValue: u
601
- });
530
+ if (n.props.label !== undefined && Re !== undefined) {
531
+ return n.props.label === e;
602
532
  }
603
- (n = (o = i.props).onChange) === null || n === void 0 ? void 0 : n.call(o, e, {
604
- value: r,
605
- name: l
606
- });
533
+ return n.props.value === e;
607
534
  }));
608
- fe(ce(i), "handleSelectOption", (function(e, t) {
609
- i.handleChange(e, te(te({}, t), {}, {
610
- selectedOption: true
535
+ if (!o && e) {
536
+ n.unshift( t().createElement(D, {
537
+ description: (0, P._)("(New value)"),
538
+ descriptionPosition: "right",
539
+ key: "currentValueOption",
540
+ value: e,
541
+ "data-test-current-value-option": e
611
542
  }));
612
- i.focus();
613
- i.close();
614
- }));
615
- fe(ce(i), "handleInputKeyDown", (function(e) {
616
- var t = i.props, o = t.children, r = t.onKeyDown, a = t.onScrollBottom;
617
- var l = i.availableOptionCount;
618
- var u = i.activeValue;
619
- var c = (0, w.keycode)(e.nativeEvent);
620
- if (i.state.open) {
621
- switch (c) {
622
- case "enter":
623
- {
624
- if (u) {
625
- i.handleSelectOption(e, {
626
- value: u
627
- });
628
- }
629
- break;
630
- }
631
-
632
- case "tab":
633
- i.close();
634
- break;
635
-
636
- case "down":
637
- i.setState((function(e) {
638
- return {
639
- activeIndex: Math.min(e.activeIndex + 1, l - 1)
640
- };
641
- }));
642
- if (o && a) {
643
- var s = n.Children.count(o) - 2;
644
- if (i.state.activeIndex === s) {
645
- i.handleScrollBottom(e);
646
- }
647
- }
648
- break;
649
-
650
- case "up":
651
- i.setState((function(e) {
652
- return {
653
- activeIndex: Math.max(e.activeIndex - 1, 0)
654
- };
655
- }));
656
- break;
657
-
658
- default:
659
- // do nothing
660
- }
661
- } else if ((0, w.addsCharacter)(e.nativeEvent) !== false ||
662
- // Safari 9.0 returns undefined
663
- c === "enter" || c === "backspace" || c === "down" || c === "up") {
664
- i.open();
665
- }
666
- r === null || r === void 0 ? void 0 : r(e);
667
- }));
668
- fe(ce(i), "handleInputClick", (function(e) {
669
- e.stopPropagation();
670
- if (!i.state.open && !i.props.disabled) {
671
- i.open();
672
- }
673
- }));
674
- fe(ce(i), "handleRequestClose", (function(e) {
675
- var t = e.event, n = e.reason;
676
- var o = n === "offScreen" || n === "escapeKey" || n === "clickAway" && i.state.anchor && !ye(i.state.anchor, t);
677
- if (o) {
678
- i.close();
543
+ }
544
+ // Highlight Active
545
+ Ie.current = 0;
546
+ xe.current = undefined;
547
+ var l = (0, k.stringToKeywords)(Re ? e : Ke());
548
+ return (i ? n : n.filter((function(e) {
549
+ if (e.props.label !== undefined) {
550
+ return (0, k.testPhrase)(e.props.label, l);
679
551
  }
680
- }));
681
- fe(ce(i), "handleScrollBottom", (function(e) {
682
- if (i.state.open && !i.props.isLoadingOptions) {
683
- var t, n;
684
- (t = (n = i.props).onScrollBottom) === null || t === void 0 ? void 0 : t.call(n, e);
552
+ if (e.props.value !== undefined) {
553
+ return (0, k.testPhrase)(e.props.value, l);
685
554
  }
686
- }));
687
- fe(ce(i), "prepareOptions", (function() {
688
- var e = i.props, t = e.children, r = e.controlledFilter;
689
- var a = i.state, l = a.activeIndex, u = a.typedValue;
690
- var s = i.getValue();
691
- var p = n.Children.toArray(t).filter(n.isValidElement);
692
- var f = y()(p, (function(e) {
693
- if (e.type === S.Heading) {
694
- return false;
695
- }
696
- if (e.props.label === undefined) {
697
- return e.props.value === s;
698
- }
699
- if (e.props.label !== undefined && u !== undefined) {
700
- return e.props.label === s;
701
- }
702
- return e.props.value === s;
703
- }));
704
- if (!f && s) {
705
- p.unshift( o().createElement(J, {
706
- description: (0, O._)("(New value)"),
707
- descriptionPosition: "right",
708
- key: "currentValueOption",
709
- value: s,
710
- "data-test-current-value-option": s
711
- }));
712
- }
713
- // Highlight Active
714
- i.availableOptionCount = 0;
715
- i.activeValue = undefined;
716
- var d = (0, m.stringToKeywords)(u ? s : i.getDisplayValue());
717
- i.options = (r ? p : p.filter((function(e) {
718
- if (e.props.label !== undefined) {
719
- return (0, m.testPhrase)(e.props.label, d);
720
- }
721
- if (e.props.value !== undefined) {
722
- return (0, m.testPhrase)(e.props.value, d);
723
- }
724
- return true;
555
+ return true;
725
556
  // Keep all headers and non-interactive options
726
- }))).map((function(e, t) {
727
- if (!c()(e.props, "active")) {
728
- // ignore Headings and Dividers
729
- return e;
730
- }
731
- var o = i.availableOptionCount === l;
732
- i.availableOptionCount += 1;
733
- var a = e.props.label !== undefined ? e.props.label : e.props.value;
734
- var u = e.props.matchRanges;
735
- var p = !r && s && (f || t > 0) ? (0, m.keywordLocations)(a, d) || undefined : undefined;
736
- if (o) {
737
- if (!e.props.disabled) {
738
- i.activeValue = e.props.value;
739
- }
740
-
741
- return (0, n.cloneElement)(e, {
742
- ref: i.handleActiveOptionMount,
743
- id: i.activeItemId,
744
- onClick: i.handleSelectOption,
745
- matchRanges: u || p,
746
- active: true
747
- });
557
+ }))).map((function(n, t) {
558
+ if (n.type.as !== "Item") {
559
+ // ignore non-Option items such as Headings and Dividers
560
+ return n;
561
+ }
562
+ var a = Ie.current === fe;
563
+ Ie.current += 1;
564
+ var u = n.props.label !== undefined ? n.props.label : n.props.value;
565
+ var c = n.props.matchRanges;
566
+ var s = !i && e && (o || t > 0) ? (0, k.keywordLocations)(u, l) || undefined : undefined;
567
+ if (a) {
568
+ if (!n.props.disabled) {
569
+ xe.current = n.props.value;
748
570
  }
749
571
 
750
- return (0, n.cloneElement)(e, {
751
- onClick: i.handleSelectOption,
752
- matchRanges: u || p
572
+ return (0, r.cloneElement)(n, {
573
+ elementRef: Ne,
574
+ id: Le,
575
+ onClick: Ye,
576
+ matchRanges: c || s,
577
+ active: true
753
578
  });
754
- }));
755
- }));
756
- fe(ce(i), "renderMenu", (function(e) {
757
- var t = e.anchorWidth, n = e.maxHeight;
758
- var r = i.props, a = r.isLoadingOptions, l = r.menuStyle, u = r.onScrollBottom, c = r.virtualization;
759
- var s = me({
760
- anchorWidth: t,
761
- maxHeight: n,
762
- menuStyle: l
763
- });
764
- var p = te({
765
- style: s,
766
- controlledExternally: true,
767
- onScrollBottom: u ? i.handleScrollBottom : undefined,
768
- isLoading: a
769
- }, b()(i.props, "className", "noOptionsMessage", "footerMessage", "animateLoading", "loadingMessage", "onScroll"));
770
- if (c) {
771
-
772
- return o().createElement(I.VirtualizedResultsMenu, $({
773
- virtualization: c
774
- }, p), i.options);
775
579
  }
776
580
 
777
- return o().createElement(C(), p, i.options);
581
+ return (0, r.cloneElement)(n, {
582
+ onClick: Ye,
583
+ matchRanges: c || s
584
+ });
778
585
  }));
779
- i.state = {
780
- activeIndex: 0,
781
- anchor: null,
782
- typedValue: undefined,
783
- open: false,
784
- value: e.defaultValue || ""
785
- };
786
- i.controlledExternally = c()(e, "value");
787
- i.popoverId = (0, g.createDOMID)("popover");
788
- i.activeItemId = (0, g.createDOMID)("active-item");
789
- if (false) {}
790
- if (false) {}
791
- return i;
792
- }
793
- re(r, [ {
794
- key: "componentDidUpdate",
795
- value: function e(t, n) {
796
- if (false) {}
797
- this.previousActiveIndex = n.activeIndex;
798
- }
799
- }, {
800
- key: "getValue",
801
- value: function e() {
802
- return this.isControlled() ? this.props.value : this.state.value;
803
- }
804
- }, {
805
- key: "getDisplayValue",
806
- value: function e() {
807
- var t = this.getValue();
808
- var o = this.state.typedValue;
809
- var r = n.Children.toArray(this.props.children).filter(n.isValidElement);
810
- var i = !o && r.find((function(e) {
811
- return e.props.label !== undefined && e.props.value === t;
812
- }));
813
- if (i) {
814
- return i === null || i === void 0 ? void 0 : i.props.label;
815
- }
816
- return t;
817
- }
818
- }, {
819
- key: "open",
820
- value: function e() {
821
- var t = this;
822
- this.setState({
823
- open: true,
824
- activeIndex: 0
825
- }, (function() {
826
- var e, n;
827
- (e = (n = t.props).onOpen) === null || e === void 0 ? void 0 : e.call(n);
828
- }));
829
- }
830
- }, {
831
- key: "close",
832
- value: function e() {
833
- var t = this;
834
- this.setState({
835
- open: false
836
- }, (function() {
837
- var e, n;
838
- t.previousActiveIndex = null;
839
- (e = (n = t.props).onClose) === null || e === void 0 ? void 0 : e.call(n);
840
- }));
841
- }
842
- /**
843
- * Focus the `ComboBox`.
844
- */ }, {
845
- key: "focus",
846
- value: function e() {
847
- var t;
848
- (t = this.textInput) === null || t === void 0 ? void 0 : t.focus();
849
- }
850
- }, {
851
- key: "isControlled",
852
- value: function e() {
853
- return this.controlledExternally;
586
+ }), [ fe, Le, a, i, Ke, Ve, Ne, Ye, Re ]);
587
+ var Ze = (0, r.useCallback)((function(e) {
588
+ var n = Ie.current;
589
+ var t = xe.current;
590
+ var o = (0, j.keycode)(e.nativeEvent);
591
+ if (he) {
592
+ switch (o) {
593
+ case "enter":
594
+ {
595
+ if (t) {
596
+ Ye(e, {
597
+ value: t
598
+ });
599
+ }
600
+ break;
601
+ }
602
+
603
+ case "tab":
604
+ ze();
605
+ break;
606
+
607
+ case "down":
608
+ de((function(e) {
609
+ return Math.min(e + 1, n - 1);
610
+ }));
611
+ if (a && G) {
612
+ var i = r.Children.count(a) - 2;
613
+ if (fe === i) {
614
+ Je(e);
615
+ }
616
+ }
617
+ break;
618
+
619
+ case "up":
620
+ de((function(e) {
621
+ return Math.max(e - 1, 0);
622
+ }));
623
+ break;
624
+
625
+ default:
626
+ // do nothing
627
+ }
628
+ } else if ((0, j.addsCharacter)(e.nativeEvent) !== false ||
629
+ // Safari 9.0 returns undefined
630
+ o === "enter" || o === "backspace" || o === "down" || o === "up") {
631
+ Fe();
854
632
  }
855
- }, {
856
- key: "render",
857
- value: function e() {
858
- var t = this.props, n = t.defaultPlacement, r = t.inputId;
859
- var i = this.state, a = i.anchor, l = i.open;
860
- var u = this.getValue();
861
- var c = this.getDisplayValue();
862
- this.prepareOptions();
633
+ U === null || U === void 0 ? void 0 : U(e);
634
+ }), [ fe, a, ze, Je, Ye, he, U, G, Fe ]);
635
+ var en = Ve();
636
+ var nn = Ke();
637
+ var rn = function e(r) {
638
+ var o = r.anchorWidth, a = r.maxHeight;
639
+ var i = Q({
640
+ anchorWidth: o,
641
+ maxHeight: a,
642
+ menuStyle: H
643
+ });
644
+ var l = {
645
+ animateLoading: n,
646
+ controlledExternally: ue,
647
+ footerMessage: h,
648
+ isLoading: E,
649
+ loadingMessage: B,
650
+ noOptionsMessage: F,
651
+ onScroll: $,
652
+ onScrollBottom: G ? Je : undefined,
653
+ style: i
654
+ };
655
+ if (ie) {
863
656
 
864
- return o().createElement(x(), $({
865
- autoCapitalize: "off",
866
- autoComplete: "off",
867
- autoCorrect: "off",
868
- spellCheck: false,
869
- canClear: true,
870
- "data-test": "combo-box"
871
- }, d()(this.props, "animateLoading", "className", "controlledFilter", "defaultValue", "footerMessage", "inputId", "isLoadingOptions", "loadingMessage", "menuStyle", "noOptionsMessage", "onClose", "onOpen", "onScroll", "onScrollBottom", "spellCheck"), {
872
- "data-test-popover-id": this.popoverId,
873
- "data-test-label": c,
874
- "data-test-value": u,
875
- "data-test-open": l && !!a,
876
- onFocus: this.handleInputFocus,
877
- onClick: this.handleInputClick,
878
- onChange: this.handleChange,
879
- onKeyDown: this.handleInputKeyDown,
880
- inputId: r,
881
- inputRef: this.handleInputMount,
882
- elementRef: this.handleAnchorMount,
883
- role: "combobox",
884
- value: c,
885
- "aria-activedescendant": this.state.open && Array.isArray(this.options) && this.options.length > 0 ? this.activeItemId : undefined,
886
- "aria-expanded": l,
887
- "aria-controls": l ? this.popoverId : undefined
888
- }), o().createElement(j(), {
889
- anchor: a,
890
- autoCloseWhenOffScreen: true,
891
- canCoverAnchor: false,
892
- defaultPlacement: n,
893
- id: this.popoverId,
894
- onRequestClose: this.handleRequestClose,
895
- open: l && !!a,
896
- repositionMode: "flip"
897
- }, this.renderMenu));
657
+ return t().createElement(b.VirtualizedResultsMenu, A({
658
+ virtualization: ie
659
+ }, l), Qe);
898
660
  }
899
- } ]);
900
- return r;
901
- }(n.Component);
902
- fe(ge, "propTypes", be);
903
- fe(ge, "defaultProps", he);
904
- fe(ge, "Option", J);
905
- fe(ge, "Divider", S.Divider);
906
- fe(ge, "Heading", S.Heading);
907
- /* harmony default export */ const Oe = ge;
661
+
662
+ return t().createElement(m(), l, Qe);
663
+ };
664
+
665
+ return t().createElement(g(), A({
666
+ append: o,
667
+ "aria-activedescendant": he && Array.isArray(Qe) && Qe.length > 0 ? Le : undefined,
668
+ "aria-expanded": he,
669
+ "aria-controls": he ? He : undefined,
670
+ autoCapitalize: "off",
671
+ autoComplete: "off",
672
+ autoCorrect: "off",
673
+ canClear: true,
674
+ "data-test": "combo-box",
675
+ "data-test-popover-id": He,
676
+ "data-test-label": nn,
677
+ "data-test-value": en,
678
+ "data-test-open": he && !!be,
679
+ describedBy: s,
680
+ disabled: d,
681
+ elementRef: We,
682
+ error: y,
683
+ inline: S,
684
+ inputId: M,
685
+ inputRef: _e,
686
+ labelledBy: T,
687
+ name: z,
688
+ onBlur: V,
689
+ onFocus: Ue,
690
+ onChange: Xe,
691
+ onClick: $e,
692
+ onKeyDown: Ze,
693
+ onSelect: ne,
694
+ placeholder: te,
695
+ prepend: oe,
696
+ role: "combobox",
697
+ value: nn
698
+ }, le, {
699
+ spellCheck: false
700
+ }), t().createElement(v(), {
701
+ anchor: be,
702
+ autoCloseWhenOffScreen: true,
703
+ canCoverAnchor: false,
704
+ defaultPlacement: u,
705
+ id: He,
706
+ onRequestClose: Ge,
707
+ open: he && !!be,
708
+ repositionMode: "flip"
709
+ }, rn));
710
+ }
711
+ ne.Divider = d.Divider;
712
+ ne.Heading = d.Heading;
713
+ ne.Option = D;
714
+ ne.propTypes = G;
715
+ /* harmony default export */ const re = ne;
908
716
  // CONCATENATED MODULE: ./src/ComboBox/index.ts
909
- module.exports = t;
717
+ module.exports = n;
910
718
  /******/})();