@splunk/react-ui 4.21.0 → 4.21.1

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 (83) hide show
  1. package/Accordion.js +425 -325
  2. package/Anchor.js +147 -117
  3. package/Animation.js +142 -94
  4. package/AnimationToggle.js +197 -193
  5. package/Box.js +145 -118
  6. package/Breadcrumbs.js +288 -206
  7. package/Button.js +488 -465
  8. package/ButtonGroup.js +160 -128
  9. package/ButtonSimple.js +543 -462
  10. package/CHANGELOG.md +7 -2
  11. package/Calendar.js +1111 -1001
  12. package/Card.js +771 -598
  13. package/CardLayout.js +205 -147
  14. package/Chip.js +509 -488
  15. package/Clickable.js +414 -352
  16. package/CloseButton.js +165 -142
  17. package/Code.js +1808 -2084
  18. package/Code.js.LICENSE.txt +8 -0
  19. package/CollapsiblePanel.js +586 -519
  20. package/Color.js +1066 -1069
  21. package/ColumnLayout.js +402 -363
  22. package/ComboBox.js +891 -794
  23. package/Concertina.js +997 -802
  24. package/ControlGroup.js +687 -594
  25. package/Date.js +567 -547
  26. package/DefinitionList.js +308 -234
  27. package/Divider.js +149 -118
  28. package/Dropdown.js +459 -416
  29. package/DualListbox.js +1479 -1541
  30. package/EventListener.js +94 -97
  31. package/File.js +1051 -969
  32. package/FormRows.js +883 -696
  33. package/Heading.js +216 -193
  34. package/Image.js +446 -402
  35. package/JSONTree.js +690 -551
  36. package/Layer.js +437 -410
  37. package/Link.js +336 -255
  38. package/List.js +213 -161
  39. package/Markdown.js +509 -487
  40. package/Menu.js +1105 -1056
  41. package/Message.js +475 -441
  42. package/MessageBar.js +387 -373
  43. package/Modal.js +810 -634
  44. package/ModalLayer.js +326 -243
  45. package/Monogram.js +308 -276
  46. package/Multiselect.js +3550 -3364
  47. package/Number.js +729 -687
  48. package/Paginator.js +510 -449
  49. package/Paragraph.js +145 -112
  50. package/Popover.js +1459 -1432
  51. package/Progress.js +301 -246
  52. package/RadioBar.js +610 -527
  53. package/RadioList.js +483 -444
  54. package/Resize.js +530 -489
  55. package/ResultsMenu.js +494 -455
  56. package/ScreenReaderContent.js +142 -111
  57. package/Scroll.js +595 -456
  58. package/ScrollContainerContext.js +197 -206
  59. package/Search.js +744 -650
  60. package/Select.js +2442 -2345
  61. package/SidePanel.js +390 -284
  62. package/Slider.js +669 -676
  63. package/SlidingPanels.js +639 -503
  64. package/SplitButton.js +464 -367
  65. package/StaticContent.js +161 -133
  66. package/StepBar.js +386 -358
  67. package/Switch.js +710 -640
  68. package/TabBar.js +726 -680
  69. package/TabLayout.js +406 -322
  70. package/Table.js +4842 -4616
  71. package/Text.js +1170 -1138
  72. package/TextArea.js +1102 -1090
  73. package/Tooltip.js +624 -581
  74. package/TransitionOpen.js +489 -422
  75. package/Typography.js +176 -153
  76. package/WaitSpinner.js +230 -206
  77. package/package.json +5 -5
  78. package/types/src/JSONTree/JSONTreeContext.d.ts +7 -0
  79. package/types/src/JSONTree/TreeNode.d.ts +5 -0
  80. package/useForceUpdate.js +112 -82
  81. package/useKeyPress.js +74 -71
  82. package/usePrevious.js +65 -65
  83. package/useRovingFocus.js +122 -138
package/Search.js CHANGED
@@ -1,671 +1,765 @@
1
- /******/ (() => { // webpackBootstrap
2
- /******/ "use strict";
3
- /******/ // The require scope
4
- /******/ var __webpack_require__ = {};
5
- /******/
6
- /************************************************************************/
7
- /******/ /* webpack/runtime/compat get default export */
8
- /******/ (() => {
9
- /******/ // getDefaultExport function for compatibility with non-harmony modules
10
- /******/ __webpack_require__.n = (module) => {
11
- /******/ var getter = module && module.__esModule ?
12
- /******/ () => (module['default']) :
13
- /******/ () => (module);
14
- /******/ __webpack_require__.d(getter, { a: getter });
15
- /******/ return getter;
16
- /******/ };
17
- /******/ })();
18
- /******/
19
- /******/ /* webpack/runtime/define property getters */
20
- /******/ (() => {
21
- /******/ // define getter functions for harmony exports
22
- /******/ __webpack_require__.d = (exports, definition) => {
23
- /******/ for(var key in definition) {
24
- /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
25
- /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
26
- /******/ }
27
- /******/ }
28
- /******/ };
29
- /******/ })();
30
- /******/
31
- /******/ /* webpack/runtime/hasOwnProperty shorthand */
32
- /******/ (() => {
33
- /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
34
- /******/ })();
35
- /******/
36
- /******/ /* webpack/runtime/make namespace object */
37
- /******/ (() => {
38
- /******/ // define __esModule on exports
39
- /******/ __webpack_require__.r = (exports) => {
40
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
41
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
42
- /******/ }
43
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
44
- /******/ };
45
- /******/ })();
46
- /******/
47
- /************************************************************************/
48
- var __webpack_exports__ = {};
49
- // ESM COMPAT FLAG
50
- __webpack_require__.r(__webpack_exports__);
51
-
52
- // EXPORTS
53
- __webpack_require__.d(__webpack_exports__, {
54
- Divider: () => (/* reexport */ Menu_namespaceObject.Divider),
55
- Heading: () => (/* reexport */ Menu_namespaceObject.Heading),
56
- Option: () => (/* reexport */ Search_Option),
57
- "default": () => (/* reexport */ Search_Search)
58
- });
59
-
60
- ;// CONCATENATED MODULE: external "react"
61
- const external_react_namespaceObject = require("react");
62
- var external_react_default = /*#__PURE__*/__webpack_require__.n(external_react_namespaceObject);
63
- ;// CONCATENATED MODULE: external "prop-types"
64
- const external_prop_types_namespaceObject = require("prop-types");
65
- var external_prop_types_default = /*#__PURE__*/__webpack_require__.n(external_prop_types_namespaceObject);
66
- ;// CONCATENATED MODULE: external "lodash/extend"
67
- const extend_namespaceObject = require("lodash/extend");
68
- var extend_default = /*#__PURE__*/__webpack_require__.n(extend_namespaceObject);
69
- ;// CONCATENATED MODULE: external "lodash/has"
70
- const has_namespaceObject = require("lodash/has");
71
- var has_default = /*#__PURE__*/__webpack_require__.n(has_namespaceObject);
72
- ;// CONCATENATED MODULE: external "lodash/omit"
73
- const omit_namespaceObject = require("lodash/omit");
74
- var omit_default = /*#__PURE__*/__webpack_require__.n(omit_namespaceObject);
75
- ;// CONCATENATED MODULE: external "lodash/pick"
76
- const pick_namespaceObject = require("lodash/pick");
77
- var pick_default = /*#__PURE__*/__webpack_require__.n(pick_namespaceObject);
78
- ;// CONCATENATED MODULE: external "@splunk/ui-utils/id"
79
- const id_namespaceObject = require("@splunk/ui-utils/id");
80
- ;// CONCATENATED MODULE: external "@splunk/ui-utils/i18n"
81
- const i18n_namespaceObject = require("@splunk/ui-utils/i18n");
82
- ;// CONCATENATED MODULE: external "@splunk/ui-utils/keyboard"
83
- const keyboard_namespaceObject = require("@splunk/ui-utils/keyboard");
84
- ;// CONCATENATED MODULE: external "@splunk/react-ui/Menu"
85
- const Menu_namespaceObject = require("@splunk/react-ui/Menu");
86
- ;// CONCATENATED MODULE: external "@splunk/react-ui/usePrevious"
87
- const usePrevious_namespaceObject = require("@splunk/react-ui/usePrevious");
88
- var usePrevious_default = /*#__PURE__*/__webpack_require__.n(usePrevious_namespaceObject);
89
- ;// CONCATENATED MODULE: external "@splunk/react-ui/Popover"
90
- const Popover_namespaceObject = require("@splunk/react-ui/Popover");
91
- var Popover_default = /*#__PURE__*/__webpack_require__.n(Popover_namespaceObject);
92
- ;// CONCATENATED MODULE: external "@splunk/react-ui/ResultsMenu"
93
- const ResultsMenu_namespaceObject = require("@splunk/react-ui/ResultsMenu");
94
- var ResultsMenu_default = /*#__PURE__*/__webpack_require__.n(ResultsMenu_namespaceObject);
95
- ;// CONCATENATED MODULE: external "@splunk/react-ui/Text"
96
- const Text_namespaceObject = require("@splunk/react-ui/Text");
97
- var Text_default = /*#__PURE__*/__webpack_require__.n(Text_namespaceObject);
98
- ;// CONCATENATED MODULE: ./src/Search/Option.tsx
99
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
100
-
101
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
102
-
103
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
104
-
105
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
106
-
107
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
108
-
109
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
110
-
111
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
112
-
113
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
114
-
115
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
116
-
117
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
118
-
119
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
120
-
121
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
122
-
123
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
124
-
125
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
126
-
127
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
128
-
129
-
130
-
131
-
132
- var propTypes = {
133
- /** @private */
134
- active: (external_prop_types_default()).bool,
135
- description: (external_prop_types_default()).string,
136
- descriptionPosition: external_prop_types_default().oneOf(['right', 'bottom']),
137
- disabled: (external_prop_types_default()).bool,
138
- icon: (external_prop_types_default()).node,
139
- label: (external_prop_types_default()).string,
140
-
141
- /** @private */
142
- onClick: (external_prop_types_default()).func,
143
- truncate: (external_prop_types_default()).bool,
144
- value: (external_prop_types_default()).string.isRequired
145
- };
146
- var defaultProps = {
147
- active: false,
148
- descriptionPosition: 'bottom',
149
- disabled: false,
150
- truncate: false
151
- };
152
-
153
- /**
154
- * An option within a `Search`. This inherits from
155
- * [PureComponent](https://reactjs.org/docs/react-api.html#reactpurecomponent)
156
- * so any elements passed to it must also be pure.
157
- */
158
- var Option = /*#__PURE__*/function (_PureComponent) {
159
- _inherits(Option, _PureComponent);
160
-
161
- var _super = _createSuper(Option);
162
-
163
- function Option() {
164
- var _this;
165
-
166
- _classCallCheck(this, Option);
167
-
168
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
169
- args[_key] = arguments[_key];
1
+ /******/ (() => {
2
+ // webpackBootstrap
3
+ /******/ "use strict";
4
+ /******/ // The require scope
5
+ /******/ var e = {};
6
+ /******/
7
+ /************************************************************************/
8
+ /******/ /* webpack/runtime/compat get default export */
9
+ /******/ (() => {
10
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
11
+ /******/ e.n = r => {
12
+ /******/ var t = r && r.__esModule ?
13
+ /******/ () => r["default"]
14
+ /******/ : () => r
15
+ /******/;
16
+ e.d(t, {
17
+ a: t
18
+ });
19
+ /******/ return t;
20
+ /******/ };
21
+ /******/ })();
22
+ /******/
23
+ /******/ /* webpack/runtime/define property getters */
24
+ /******/ (() => {
25
+ /******/ // define getter functions for harmony exports
26
+ /******/ e.d = (r, t) => {
27
+ /******/ for (var n in t) {
28
+ /******/ if (e.o(t, n) && !e.o(r, n)) {
29
+ /******/ Object.defineProperty(r, n, {
30
+ enumerable: true,
31
+ get: t[n]
32
+ });
33
+ /******/ }
34
+ /******/ }
35
+ /******/ };
36
+ /******/ })();
37
+ /******/
38
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
39
+ /******/ (() => {
40
+ /******/ e.o = (e, r) => Object.prototype.hasOwnProperty.call(e, r)
41
+ /******/;
42
+ })();
43
+ /******/
44
+ /******/ /* webpack/runtime/make namespace object */
45
+ /******/ (() => {
46
+ /******/ // define __esModule on exports
47
+ /******/ e.r = e => {
48
+ /******/ if (typeof Symbol !== "undefined" && Symbol.toStringTag) {
49
+ /******/ Object.defineProperty(e, Symbol.toStringTag, {
50
+ value: "Module"
51
+ });
52
+ /******/ }
53
+ /******/ Object.defineProperty(e, "__esModule", {
54
+ value: true
55
+ });
56
+ /******/ };
57
+ /******/ })();
58
+ /******/
59
+ /************************************************************************/ var r = {};
60
+ // ESM COMPAT FLAG
61
+ e.r(r);
62
+ // EXPORTS
63
+ e.d(r, {
64
+ Divider: () => /* reexport */ g.Divider,
65
+ Heading: () => /* reexport */ g.Heading,
66
+ Option: () => /* reexport */ W,
67
+ default: () => /* reexport */ ue
68
+ });
69
+ // CONCATENATED MODULE: external "react"
70
+ const t = require("react");
71
+ var n = e.n(t);
72
+ // CONCATENATED MODULE: external "prop-types"
73
+ const o = require("prop-types");
74
+ var i = e.n(o);
75
+ // CONCATENATED MODULE: external "lodash/extend"
76
+ const a = require("lodash/extend");
77
+ var u = e.n(a);
78
+ // CONCATENATED MODULE: external "lodash/has"
79
+ const l = require("lodash/has");
80
+ var c = e.n(l);
81
+ // CONCATENATED MODULE: external "lodash/omit"
82
+ const f = require("lodash/omit");
83
+ var s = e.n(f);
84
+ // CONCATENATED MODULE: external "lodash/pick"
85
+ const d = require("lodash/pick");
86
+ var v = e.n(d);
87
+ // CONCATENATED MODULE: external "@splunk/ui-utils/id"
88
+ const p = require("@splunk/ui-utils/id");
89
+ // CONCATENATED MODULE: external "@splunk/ui-utils/i18n"
90
+ const b = require("@splunk/ui-utils/i18n");
91
+ // CONCATENATED MODULE: external "@splunk/ui-utils/keyboard"
92
+ const y = require("@splunk/ui-utils/keyboard");
93
+ // CONCATENATED MODULE: external "@splunk/react-ui/Menu"
94
+ const g = require("@splunk/react-ui/Menu");
95
+ // CONCATENATED MODULE: external "@splunk/react-ui/usePrevious"
96
+ const h = require("@splunk/react-ui/usePrevious");
97
+ var m = e.n(h);
98
+ // CONCATENATED MODULE: external "@splunk/react-ui/Popover"
99
+ const O = require("@splunk/react-ui/Popover");
100
+ var j = e.n(O);
101
+ // CONCATENATED MODULE: external "@splunk/react-ui/ResultsMenu"
102
+ const w = require("@splunk/react-ui/ResultsMenu");
103
+ var S = e.n(w);
104
+ // CONCATENATED MODULE: external "@splunk/react-ui/Text"
105
+ const P = require("@splunk/react-ui/Text");
106
+ var k = e.n(P);
107
+ // CONCATENATED MODULE: ./src/Search/Option.tsx
108
+ function C(e) {
109
+ "@babel/helpers - typeof";
110
+ if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
111
+ C = function e(r) {
112
+ return typeof r;
113
+ };
114
+ } else {
115
+ C = function e(r) {
116
+ return r && typeof Symbol === "function" && r.constructor === Symbol && r !== Symbol.prototype ? "symbol" : typeof r;
117
+ };
118
+ }
119
+ return C(e);
170
120
  }
171
-
172
- _this = _super.call.apply(_super, [this].concat(args));
173
-
174
- _defineProperty(_assertThisInitialized(_this), "item", null);
175
-
176
- _defineProperty(_assertThisInitialized(_this), "handleClick", function (e) {
177
- var _this$props = _this.props,
178
- disabled = _this$props.disabled,
179
- onClick = _this$props.onClick,
180
- value = _this$props.value;
181
-
182
- if (!disabled) {
183
- onClick === null || onClick === void 0 ? void 0 : onClick(e, {
184
- value: value
121
+ function R() {
122
+ R = Object.assign || function(e) {
123
+ for (var r = 1; r < arguments.length; r++) {
124
+ var t = arguments[r];
125
+ for (var n in t) {
126
+ if (Object.prototype.hasOwnProperty.call(t, n)) {
127
+ e[n] = t[n];
128
+ }
129
+ }
130
+ }
131
+ return e;
132
+ };
133
+ return R.apply(this, arguments);
134
+ }
135
+ function M(e, r) {
136
+ if (e == null) return {};
137
+ var t = E(e, r);
138
+ var n, o;
139
+ if (Object.getOwnPropertySymbols) {
140
+ var i = Object.getOwnPropertySymbols(e);
141
+ for (o = 0; o < i.length; o++) {
142
+ n = i[o];
143
+ if (r.indexOf(n) >= 0) continue;
144
+ if (!Object.prototype.propertyIsEnumerable.call(e, n)) continue;
145
+ t[n] = e[n];
146
+ }
147
+ }
148
+ return t;
149
+ }
150
+ function E(e, r) {
151
+ if (e == null) return {};
152
+ var t = {};
153
+ var n = Object.keys(e);
154
+ var o, i;
155
+ for (i = 0; i < n.length; i++) {
156
+ o = n[i];
157
+ if (r.indexOf(o) >= 0) continue;
158
+ t[o] = e[o];
159
+ }
160
+ return t;
161
+ }
162
+ function D(e, r) {
163
+ if (!(e instanceof r)) {
164
+ throw new TypeError("Cannot call a class as a function");
165
+ }
166
+ }
167
+ function q(e, r) {
168
+ for (var t = 0; t < r.length; t++) {
169
+ var n = r[t];
170
+ n.enumerable = n.enumerable || false;
171
+ n.configurable = true;
172
+ if ("value" in n) n.writable = true;
173
+ Object.defineProperty(e, n.key, n);
174
+ }
175
+ }
176
+ function x(e, r, t) {
177
+ if (r) q(e.prototype, r);
178
+ if (t) q(e, t);
179
+ return e;
180
+ }
181
+ function I(e, r) {
182
+ if (typeof r !== "function" && r !== null) {
183
+ throw new TypeError("Super expression must either be null or a function");
184
+ }
185
+ e.prototype = Object.create(r && r.prototype, {
186
+ constructor: {
187
+ value: e,
188
+ writable: true,
189
+ configurable: true
190
+ }
185
191
  });
186
- }
187
- });
188
-
189
- return _this;
190
- }
191
-
192
- _createClass(Option, [{
193
- key: "scrollIntoViewIfNeeded",
194
- value: function scrollIntoViewIfNeeded() {
195
- var _this$item;
196
-
197
- (_this$item = this.item) === null || _this$item === void 0 ? void 0 : _this$item.scrollIntoViewIfNeeded();
192
+ if (r) _(e, r);
198
193
  }
199
- }, {
200
- key: "render",
201
- value: function render() {
202
- var _this2 = this;
203
-
204
- // eslint-disable-next-line no-unused-vars
205
- var _this$props2 = this.props,
206
- value = _this$props2.value,
207
- label = _this$props2.label,
208
- otherProps = _objectWithoutProperties(_this$props2, ["value", "label"]);
209
-
210
- var displayLabel = label === undefined ? value : label;
211
- return /*#__PURE__*/external_react_default().createElement(Menu_namespaceObject.Item, _extends({
212
- ref: function ref(c) {
213
- _this2.item = c;
214
- },
215
- "data-test": "search-option",
216
- "data-test-value": value
217
- }, otherProps, {
218
- onClick: this.handleClick,
219
- role: "option",
220
- "aria-selected": false
221
- }), displayLabel);
194
+ function _(e, r) {
195
+ _ = Object.setPrototypeOf || function e(r, t) {
196
+ r.__proto__ = t;
197
+ return r;
198
+ };
199
+ return _(e, r);
222
200
  }
223
- }]);
224
-
225
- return Option;
226
- }(external_react_namespaceObject.PureComponent);
227
-
228
- _defineProperty(Option, "propTypes", propTypes);
229
-
230
- _defineProperty(Option, "defaultProps", defaultProps);
231
-
232
- _defineProperty(Option, "type", Menu_namespaceObject.Item);
233
-
234
- /* harmony default export */ const Search_Option = (Option);
235
- ;// CONCATENATED MODULE: ./src/utils/updateReactRef.ts
236
- /**
201
+ function A(e) {
202
+ var r = V();
203
+ return function t() {
204
+ var n = L(e), o;
205
+ if (r) {
206
+ var i = L(this).constructor;
207
+ o = Reflect.construct(n, arguments, i);
208
+ } else {
209
+ o = n.apply(this, arguments);
210
+ }
211
+ return T(this, o);
212
+ };
213
+ }
214
+ function T(e, r) {
215
+ if (r && (C(r) === "object" || typeof r === "function")) {
216
+ return r;
217
+ }
218
+ return B(e);
219
+ }
220
+ function B(e) {
221
+ if (e === void 0) {
222
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
223
+ }
224
+ return e;
225
+ }
226
+ function V() {
227
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
228
+ if (Reflect.construct.sham) return false;
229
+ if (typeof Proxy === "function") return true;
230
+ try {
231
+ Date.prototype.toString.call(Reflect.construct(Date, [], (function() {})));
232
+ return true;
233
+ } catch (e) {
234
+ return false;
235
+ }
236
+ }
237
+ function L(e) {
238
+ L = Object.setPrototypeOf ? Object.getPrototypeOf : function e(r) {
239
+ return r.__proto__ || Object.getPrototypeOf(r);
240
+ };
241
+ return L(e);
242
+ }
243
+ function H(e, r, t) {
244
+ if (r in e) {
245
+ Object.defineProperty(e, r, {
246
+ value: t,
247
+ enumerable: true,
248
+ configurable: true,
249
+ writable: true
250
+ });
251
+ } else {
252
+ e[r] = t;
253
+ }
254
+ return e;
255
+ }
256
+ var K = {
257
+ /** @private */
258
+ active: i().bool,
259
+ description: i().string,
260
+ descriptionPosition: i().oneOf([ "right", "bottom" ]),
261
+ disabled: i().bool,
262
+ icon: i().node,
263
+ label: i().string,
264
+ /** @private */
265
+ onClick: i().func,
266
+ truncate: i().bool,
267
+ value: i().string.isRequired
268
+ };
269
+ var N = {
270
+ active: false,
271
+ descriptionPosition: "bottom",
272
+ disabled: false,
273
+ truncate: false
274
+ };
275
+ /**
276
+ * An option within a `Search`. This inherits from
277
+ * [PureComponent](https://reactjs.org/docs/react-api.html#reactpurecomponent)
278
+ * so any elements passed to it must also be pure.
279
+ */ var F = function(e) {
280
+ I(t, e);
281
+ var r = A(t);
282
+ function t() {
283
+ var e;
284
+ D(this, t);
285
+ for (var n = arguments.length, o = new Array(n), i = 0; i < n; i++) {
286
+ o[i] = arguments[i];
287
+ }
288
+ e = r.call.apply(r, [ this ].concat(o));
289
+ H(B(e), "item", null);
290
+ H(B(e), "handleClick", (function(r) {
291
+ var t = e.props, n = t.disabled, o = t.onClick, i = t.value;
292
+ if (!n) {
293
+ o === null || o === void 0 ? void 0 : o(r, {
294
+ value: i
295
+ });
296
+ }
297
+ }));
298
+ return e;
299
+ }
300
+ x(t, [ {
301
+ key: "scrollIntoViewIfNeeded",
302
+ value: function e() {
303
+ var r;
304
+ (r = this.item) === null || r === void 0 ? void 0 : r.scrollIntoViewIfNeeded();
305
+ }
306
+ }, {
307
+ key: "render",
308
+ value: function e() {
309
+ var r = this;
310
+ // eslint-disable-next-line no-unused-vars
311
+ var t = this.props, o = t.value, i = t.label, a = M(t, [ "value", "label" ]);
312
+ var u = i === undefined ? o : i;
313
+
314
+ return n().createElement(g.Item, R({
315
+ ref: function e(t) {
316
+ r.item = t;
317
+ },
318
+ "data-test": "search-option",
319
+ "data-test-value": o
320
+ }, a, {
321
+ onClick: this.handleClick,
322
+ role: "option",
323
+ "aria-selected": false
324
+ }), u);
325
+ }
326
+ } ]);
327
+ return t;
328
+ }(t.PureComponent);
329
+ H(F, "propTypes", K);
330
+ H(F, "defaultProps", N);
331
+ H(F, "type", g.Item);
332
+ /* harmony default export */ const W = F;
333
+ // CONCATENATED MODULE: ./src/utils/updateReactRef.ts
334
+ /**
237
335
  * Updates a React ref. Callback refs and object refs (from `createRef` and `useRef`) are supported.
238
336
  *
239
337
  * @param ref - The React callback or object ref. Can be `null` or `undefined`.
240
338
  * @param current - The new value of the ref.
241
339
  */
242
- function updateReactRef(ref, current) {
243
- if (ref) {
244
- if (typeof ref === 'function') {
245
- ref(current);
246
- } else {
247
- // the public signature of this util uses React.Ref<T> to mirror the way React types refs.
248
- // the intention here is to signal "we will take care of setting 'current', not you".
249
- ref.current = current; // eslint-disable-line no-param-reassign
250
- }
251
- }
252
- }
253
-
254
-
255
- ;// CONCATENATED MODULE: ./src/Search/Search.tsx
256
- function Search_extends() { Search_extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return Search_extends.apply(this, arguments); }
257
-
258
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
259
-
260
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { Search_defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
261
-
262
- function Search_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
263
-
264
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
265
-
266
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
267
-
268
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
269
-
270
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
271
-
272
- function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
273
-
274
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
275
-
276
- function Search_objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = Search_objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
277
-
278
- function Search_objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
279
-
280
-
281
-
282
-
283
-
284
-
285
-
286
-
287
-
288
-
289
-
290
-
291
-
292
-
293
-
294
-
295
-
296
- var Search_propTypes = {
297
- animateLoading: (external_prop_types_default()).bool,
298
- children: (external_prop_types_default()).node,
299
- defaultPlacement: external_prop_types_default().oneOf(['above', 'below', 'vertical']),
300
- defaultValue: (external_prop_types_default()).string,
301
- describedBy: (external_prop_types_default()).string,
302
- disabled: (external_prop_types_default()).bool,
303
- elementRef: external_prop_types_default().oneOfType([(external_prop_types_default()).func, (external_prop_types_default()).object]),
304
- error: (external_prop_types_default()).bool,
305
- footerMessage: (external_prop_types_default()).node,
306
- inline: (external_prop_types_default()).bool,
307
- inputRef: external_prop_types_default().oneOfType([(external_prop_types_default()).func, (external_prop_types_default()).object]),
308
- isLoadingOptions: (external_prop_types_default()).bool,
309
- labelledBy: (external_prop_types_default()).string,
310
- loadingMessage: (external_prop_types_default()).node,
311
- menuStyle: (external_prop_types_default()).object,
312
- name: (external_prop_types_default()).string,
313
- noOptionsMessage: (external_prop_types_default()).node,
314
- onChange: (external_prop_types_default()).func,
315
- onClose: (external_prop_types_default()).func,
316
- onFocus: (external_prop_types_default()).func,
317
- onKeyDown: (external_prop_types_default()).func,
318
- onOpen: (external_prop_types_default()).func,
319
- onScroll: (external_prop_types_default()).func,
320
- placeholder: (external_prop_types_default()).string,
321
- value: (external_prop_types_default()).string
322
- };
323
-
324
- function containsEvent(el, _ref) {
325
- var clientX = _ref.clientX,
326
- clientY = _ref.clientY;
327
-
328
- var _el$getBoundingClient = el.getBoundingClientRect(),
329
- top = _el$getBoundingClient.top,
330
- left = _el$getBoundingClient.left,
331
- bottom = _el$getBoundingClient.bottom,
332
- right = _el$getBoundingClient.right;
333
-
334
- return clientX > left && clientX < right && clientY > top && clientY < bottom;
335
- }
336
-
337
- function Search(_ref2) {
338
- var _ref2$animateLoading = _ref2.animateLoading,
339
- animateLoading = _ref2$animateLoading === void 0 ? false : _ref2$animateLoading,
340
- children = _ref2.children,
341
- defaultPlacement = _ref2.defaultPlacement,
342
- defaultValue = _ref2.defaultValue,
343
- describedBy = _ref2.describedBy,
344
- _ref2$disabled = _ref2.disabled,
345
- disabled = _ref2$disabled === void 0 ? false : _ref2$disabled,
346
- elementRef = _ref2.elementRef,
347
- _ref2$error = _ref2.error,
348
- error = _ref2$error === void 0 ? false : _ref2$error,
349
- footerMessage = _ref2.footerMessage,
350
- _ref2$inline = _ref2.inline,
351
- inline = _ref2$inline === void 0 ? false : _ref2$inline,
352
- inputRef = _ref2.inputRef,
353
- _ref2$isLoadingOption = _ref2.isLoadingOptions,
354
- isLoadingOptions = _ref2$isLoadingOption === void 0 ? false : _ref2$isLoadingOption,
355
- labelledBy = _ref2.labelledBy,
356
- loadingMessage = _ref2.loadingMessage,
357
- _ref2$menuStyle = _ref2.menuStyle,
358
- menuStyle = _ref2$menuStyle === void 0 ? {} : _ref2$menuStyle,
359
- name = _ref2.name,
360
- noOptionsMessage = _ref2.noOptionsMessage,
361
- onChange = _ref2.onChange,
362
- onClose = _ref2.onClose,
363
- onFocus = _ref2.onFocus,
364
- onKeyDown = _ref2.onKeyDown,
365
- onOpen = _ref2.onOpen,
366
- _ref2$placeholder = _ref2.placeholder,
367
- placeholder = _ref2$placeholder === void 0 ? (0,i18n_namespaceObject._)('Search...') : _ref2$placeholder,
368
- propValue = _ref2.value,
369
- otherProps = Search_objectWithoutProperties(_ref2, ["animateLoading", "children", "defaultPlacement", "defaultValue", "describedBy", "disabled", "elementRef", "error", "footerMessage", "inline", "inputRef", "isLoadingOptions", "labelledBy", "loadingMessage", "menuStyle", "name", "noOptionsMessage", "onChange", "onClose", "onFocus", "onKeyDown", "onOpen", "placeholder", "value"]);
370
-
371
- // @docs-props-type SearchPropsBase
372
- // state
373
- var _useState = (0,external_react_namespaceObject.useState)(0),
374
- _useState2 = _slicedToArray(_useState, 2),
375
- activeIndex = _useState2[0],
376
- setActiveIndex = _useState2[1];
377
-
378
- var _useState3 = (0,external_react_namespaceObject.useState)(false),
379
- _useState4 = _slicedToArray(_useState3, 2),
380
- isOpen = _useState4[0],
381
- setIsOpen = _useState4[1];
382
-
383
- var _useState5 = (0,external_react_namespaceObject.useState)(undefined),
384
- _useState6 = _slicedToArray(_useState5, 2),
385
- typedValue = _useState6[0],
386
- setTypedValue = _useState6[1];
387
-
388
- var _useState7 = (0,external_react_namespaceObject.useState)(defaultValue || ''),
389
- _useState8 = _slicedToArray(_useState7, 2),
390
- value = _useState8[0],
391
- setValue = _useState8[1]; // previous state
392
-
393
-
394
- var previousActiveIndexState = usePrevious_default()(activeIndex); // refs
395
-
396
- var anchorRef = (0,external_react_namespaceObject.useRef)(null);
397
- var textRef = (0,external_react_namespaceObject.useRef)(null);
398
- var controlledExternally = (0,external_react_namespaceObject.useRef)(propValue !== undefined && propValue !== null);
399
- var focusCalledInternally = (0,external_react_namespaceObject.useRef)(false);
400
- var options = (0,external_react_namespaceObject.useRef)([]);
401
- var popoverId = (0,external_react_namespaceObject.useRef)((0,id_namespaceObject.createDOMID)('popover'));
402
- var previousActiveIndex = (0,external_react_namespaceObject.useRef)(previousActiveIndexState);
403
- var activeItemId = (0,external_react_namespaceObject.useRef)((0,id_namespaceObject.createDOMID)('active-item'));
404
- var activeValue = (0,external_react_namespaceObject.useRef)(undefined);
405
-
406
- var handleAnchorRef = function handleAnchorRef(el) {
407
- updateReactRef(anchorRef, el);
408
- updateReactRef(elementRef, el);
409
- };
410
-
411
- var handleInputRef = function handleInputRef(el) {
412
- updateReactRef(textRef, el);
413
- updateReactRef(inputRef, el);
414
- };
415
-
416
- var getValue = function getValue() {
417
- return controlledExternally.current ? propValue : value;
418
- };
419
-
420
- var getDisplayValue = function getDisplayValue() {
421
- var currentValue = getValue();
422
- var initialOptions = external_react_namespaceObject.Children.toArray(children).filter(external_react_namespaceObject.isValidElement);
423
- var optionForValue = !typedValue && initialOptions.find(function (option) {
424
- return option.props.label !== undefined && option.props.value === currentValue;
425
- });
426
-
427
- if (optionForValue) {
428
- return optionForValue === null || optionForValue === void 0 ? void 0 : optionForValue.props.label;
340
+ function z(e, r) {
341
+ if (e) {
342
+ if (typeof e === "function") {
343
+ e(r);
344
+ } else {
345
+ // the public signature of this util uses React.Ref<T> to mirror the way React types refs.
346
+ // the intention here is to signal "we will take care of setting 'current', not you".
347
+ e.current = r;
348
+ // eslint-disable-line no-param-reassign
349
+ }
350
+ }
429
351
  }
430
-
431
- return currentValue;
432
- };
433
-
434
- var isMenuValid = function isMenuValid() {
435
- return !!children || isLoadingOptions;
436
- };
437
-
438
- var requestOpen = function requestOpen() {
439
- setIsOpen(true);
440
- setActiveIndex(-1);
441
- onOpen === null || onOpen === void 0 ? void 0 : onOpen();
442
- };
443
-
444
- var requestClose = function requestClose() {
445
- setIsOpen(false);
446
- previousActiveIndex.current = null;
447
- onClose === null || onClose === void 0 ? void 0 : onClose();
448
- };
449
-
450
- var requestFocus = function requestFocus() {
451
- var _textRef$current;
452
-
453
- (_textRef$current = textRef.current) === null || _textRef$current === void 0 ? void 0 : _textRef$current.focus();
454
- };
455
-
456
- var handleInputFocus = function handleInputFocus(e) {
457
- /* SUI-930 On IE 11 this handler is essentially deferred after calling
458
- * this.textInput.focus(). this.focusCalledInternally enables the focus event to be ignored
459
- * when the menu closes. */
460
- if (focusCalledInternally.current) {
461
- focusCalledInternally.current = false;
462
- } else {
463
- requestOpen();
352
+ // CONCATENATED MODULE: ./src/Search/Search.tsx
353
+ function U() {
354
+ U = Object.assign || function(e) {
355
+ for (var r = 1; r < arguments.length; r++) {
356
+ var t = arguments[r];
357
+ for (var n in t) {
358
+ if (Object.prototype.hasOwnProperty.call(t, n)) {
359
+ e[n] = t[n];
360
+ }
361
+ }
362
+ }
363
+ return e;
364
+ };
365
+ return U.apply(this, arguments);
464
366
  }
465
-
466
- onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
467
- };
468
-
469
- var handleChange = function handleChange(e, _ref3) {
470
- var controlValue = _ref3.value;
471
-
472
- if (!controlledExternally.current) {
473
- setValue(controlValue);
367
+ function X(e, r) {
368
+ var t = Object.keys(e);
369
+ if (Object.getOwnPropertySymbols) {
370
+ var n = Object.getOwnPropertySymbols(e);
371
+ if (r) n = n.filter((function(r) {
372
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
373
+ }));
374
+ t.push.apply(t, n);
375
+ }
376
+ return t;
474
377
  }
475
-
476
- setActiveIndex(-1);
477
- setTypedValue(controlValue);
478
- onChange === null || onChange === void 0 ? void 0 : onChange(e, {
479
- value: controlValue,
480
- name: name
481
- });
482
- };
483
-
484
- var handleSelectOption = function handleSelectOption(e, data) {
485
- handleChange(e, _objectSpread({}, data));
486
- focusCalledInternally.current = true;
487
- requestFocus();
488
- requestClose();
489
- };
490
-
491
- var handleInputKeyDown = function handleInputKeyDown(e) {
492
- var numOptions = options.current.length;
493
- var activeOption = activeValue.current;
494
- var eventKeyCode = (0,keyboard_namespaceObject.keycode)(e.nativeEvent);
495
-
496
- if (isOpen) {
497
- switch (eventKeyCode) {
498
- case 'enter':
499
- {
500
- if (activeOption) {
501
- handleSelectOption(e, {
502
- value: activeOption
503
- });
378
+ function Y(e) {
379
+ for (var r = 1; r < arguments.length; r++) {
380
+ var t = arguments[r] != null ? arguments[r] : {};
381
+ if (r % 2) {
382
+ X(Object(t), true).forEach((function(r) {
383
+ $(e, r, t[r]);
384
+ }));
385
+ } else if (Object.getOwnPropertyDescriptors) {
386
+ Object.defineProperties(e, Object.getOwnPropertyDescriptors(t));
387
+ } else {
388
+ X(Object(t)).forEach((function(r) {
389
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
390
+ }));
504
391
  }
505
-
506
- break;
507
- }
508
-
509
- case 'tab':
510
- requestClose();
511
- break;
512
-
513
- case 'down':
514
- setActiveIndex(Math.min(activeIndex + 1, numOptions - 1));
515
- break;
516
-
517
- case 'up':
518
- setActiveIndex(Math.max(activeIndex - 1, 0));
519
- break;
520
-
521
- default: // do nothing
522
-
523
- }
524
- } else if ((0,keyboard_namespaceObject.addsCharacter)(e.nativeEvent) !== false || // Safari 9.0 returns undefined
525
- eventKeyCode === 'enter' || eventKeyCode === 'backspace' || eventKeyCode === 'down' || eventKeyCode === 'up') {
526
- requestOpen();
392
+ }
393
+ return e;
527
394
  }
528
-
529
- onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(e);
530
- };
531
-
532
- var handleInputClick = function handleInputClick() {
533
- if (document.activeElement !== textRef.current) {
534
- focusCalledInternally.current = true;
535
- requestFocus();
395
+ function $(e, r, t) {
396
+ if (r in e) {
397
+ Object.defineProperty(e, r, {
398
+ value: t,
399
+ enumerable: true,
400
+ configurable: true,
401
+ writable: true
402
+ });
403
+ } else {
404
+ e[r] = t;
405
+ }
406
+ return e;
536
407
  }
537
-
538
- if (!isOpen && !disabled) {
539
- requestOpen();
408
+ function G(e, r) {
409
+ return re(e) || ee(e, r) || Q(e, r) || J();
540
410
  }
541
- };
542
-
543
- var handleRequestClose = function handleRequestClose(_ref4) {
544
- var event = _ref4.event,
545
- reason = _ref4.reason;
546
- var shouldClose = reason === 'offScreen' || reason === 'escapeKey' || reason === 'clickAway' && anchorRef.current && !containsEvent(anchorRef.current, event);
547
-
548
- if (shouldClose) {
549
- requestClose();
411
+ function J() {
412
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
550
413
  }
551
- };
552
-
553
- var handleActiveOptionMount = function handleActiveOptionMount(c) {
554
- if (previousActiveIndex.current !== activeIndex) {
555
- c === null || c === void 0 ? void 0 : c.scrollIntoViewIfNeeded();
414
+ function Q(e, r) {
415
+ if (!e) return;
416
+ if (typeof e === "string") return Z(e, r);
417
+ var t = Object.prototype.toString.call(e).slice(8, -1);
418
+ if (t === "Object" && e.constructor) t = e.constructor.name;
419
+ if (t === "Map" || t === "Set") return Array.from(e);
420
+ if (t === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)) return Z(e, r);
556
421
  }
557
- };
558
-
559
- var renderMenu = function renderMenu(_ref5) {
560
- var anchorWidth = _ref5.anchorWidth,
561
- maxHeight = _ref5.maxHeight;
562
- var initialOptions = external_react_namespaceObject.Children.toArray(children).filter(external_react_namespaceObject.isValidElement); // Highlight Active
563
-
564
- activeValue.current = undefined; // Only update the menu options if they are valid and the drodown is open.
565
- // This is necessary to handle the outro animation of the dropdown.
566
-
567
- if (isMenuValid() && isOpen) {
568
- options.current = initialOptions.map(function (option, index) {
569
- if (!has_default()(option.props, 'active')) {
570
- // ignore Headings and Dividers
571
- return option;
422
+ function Z(e, r) {
423
+ if (r == null || r > e.length) r = e.length;
424
+ for (var t = 0, n = new Array(r); t < r; t++) {
425
+ n[t] = e[t];
572
426
  }
573
-
574
- if (index === activeIndex) {
575
- activeValue.current = option.props.value;
576
- return /*#__PURE__*/(0,external_react_namespaceObject.cloneElement)(option, {
577
- ref: handleActiveOptionMount,
578
- id: activeItemId.current,
579
- onClick: handleSelectOption,
580
- active: true
581
- });
427
+ return n;
428
+ }
429
+ function ee(e, r) {
430
+ if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(e))) return;
431
+ var t = [];
432
+ var n = true;
433
+ var o = false;
434
+ var i = undefined;
435
+ try {
436
+ for (var a = e[Symbol.iterator](), u; !(n = (u = a.next()).done); n = true) {
437
+ t.push(u.value);
438
+ if (r && t.length === r) break;
439
+ }
440
+ } catch (e) {
441
+ o = true;
442
+ i = e;
443
+ } finally {
444
+ try {
445
+ if (!n && a["return"] != null) a["return"]();
446
+ } finally {
447
+ if (o) throw i;
448
+ }
582
449
  }
583
-
584
- return /*#__PURE__*/(0,external_react_namespaceObject.cloneElement)(option, {
585
- onClick: handleSelectOption
586
- });
587
- });
450
+ return t;
588
451
  }
589
-
590
- return /*#__PURE__*/external_react_default().createElement((ResultsMenu_default()), Search_extends({
591
- style: extend_default()({
592
- overflow: 'auto',
593
- width: Math.max(anchorWidth !== null && anchorWidth !== void 0 ? anchorWidth : 0, 200)
594
- }, menuStyle),
595
- controlledExternally: true,
596
- maxHeight: maxHeight !== null && maxHeight !== void 0 ? maxHeight : undefined,
597
- isLoading: isLoadingOptions
598
- }, pick_default()(otherProps, 'className', 'onScroll'), {
599
- noOptionsMessage: noOptionsMessage,
600
- footerMessage: footerMessage,
601
- animateLoading: animateLoading,
602
- loadingMessage: loadingMessage
603
- }), options.current);
604
- };
605
-
606
- var currentValue = getValue();
607
- var currentDisplayValue = getDisplayValue();
608
- var popupIsOpen = isOpen && !!anchorRef.current && isMenuValid();
609
- var ariaProps = {
610
- 'aria-activedescendant': activeItemId.current,
611
- 'aria-expanded': popupIsOpen,
612
- 'aria-haspopup': isMenuValid(),
613
- 'aria-controls': popupIsOpen ? popoverId.current : undefined
614
- };
615
-
616
- if (!(labelledBy === null || labelledBy === void 0 ? void 0 : labelledBy.length)) {
617
- ariaProps['aria-label'] = (0,i18n_namespaceObject._)('Value input');
618
- }
619
-
620
- return /*#__PURE__*/external_react_default().createElement((Text_default()), Search_extends({
621
- "data-test": "search"
622
- }, omit_default()(otherProps, 'className', 'onScroll'), {
623
- appearance: "search",
624
- autoCapitalize: "off",
625
- autoComplete: "off",
626
- autoCorrect: "off",
627
- "data-test-popover-id": popoverId.current,
628
- "data-test-label": currentDisplayValue,
629
- "data-test-value": currentValue,
630
- "data-test-open": popupIsOpen,
631
- describedBy: describedBy,
632
- disabled: disabled,
633
- elementRef: handleAnchorRef,
634
- error: error,
635
- inline: inline,
636
- inputRef: handleInputRef,
637
- labelledBy: labelledBy,
638
- name: name,
639
- onFocus: handleInputFocus,
640
- onClick: handleInputClick,
641
- onChange: handleChange,
642
- onKeyDown: handleInputKeyDown,
643
- placeholder: placeholder,
644
- spellCheck: false,
645
- value: currentDisplayValue
646
- }, ariaProps), /*#__PURE__*/external_react_default().createElement((Popover_default()), {
647
- anchor: function () {
648
- return anchorRef.current;
649
- }(),
650
- autoCloseWhenOffScreen: true,
651
- canCoverAnchor: false,
652
- defaultPlacement: defaultPlacement,
653
- id: popoverId.current,
654
- onRequestClose: handleRequestClose,
655
- open: popupIsOpen,
656
- repositionMode: "flip"
657
- }, renderMenu));
658
- }
659
-
660
- Search.propTypes = Search_propTypes;
661
- Search.Option = Search_Option;
662
- Search.Divider = Menu_namespaceObject.Divider;
663
- Search.Heading = Menu_namespaceObject.Heading;
664
- /* harmony default export */ const Search_Search = (Search);
665
-
666
- ;// CONCATENATED MODULE: ./src/Search/index.ts
667
-
668
-
669
- module.exports = __webpack_exports__;
670
- /******/ })()
671
- ;
452
+ function re(e) {
453
+ if (Array.isArray(e)) return e;
454
+ }
455
+ function te(e, r) {
456
+ if (e == null) return {};
457
+ var t = ne(e, r);
458
+ var n, o;
459
+ if (Object.getOwnPropertySymbols) {
460
+ var i = Object.getOwnPropertySymbols(e);
461
+ for (o = 0; o < i.length; o++) {
462
+ n = i[o];
463
+ if (r.indexOf(n) >= 0) continue;
464
+ if (!Object.prototype.propertyIsEnumerable.call(e, n)) continue;
465
+ t[n] = e[n];
466
+ }
467
+ }
468
+ return t;
469
+ }
470
+ function ne(e, r) {
471
+ if (e == null) return {};
472
+ var t = {};
473
+ var n = Object.keys(e);
474
+ var o, i;
475
+ for (i = 0; i < n.length; i++) {
476
+ o = n[i];
477
+ if (r.indexOf(o) >= 0) continue;
478
+ t[o] = e[o];
479
+ }
480
+ return t;
481
+ }
482
+ var oe = {
483
+ animateLoading: i().bool,
484
+ children: i().node,
485
+ defaultPlacement: i().oneOf([ "above", "below", "vertical" ]),
486
+ defaultValue: i().string,
487
+ describedBy: i().string,
488
+ disabled: i().bool,
489
+ elementRef: i().oneOfType([ i().func, i().object ]),
490
+ error: i().bool,
491
+ footerMessage: i().node,
492
+ inline: i().bool,
493
+ inputRef: i().oneOfType([ i().func, i().object ]),
494
+ isLoadingOptions: i().bool,
495
+ labelledBy: i().string,
496
+ loadingMessage: i().node,
497
+ menuStyle: i().object,
498
+ name: i().string,
499
+ noOptionsMessage: i().node,
500
+ onChange: i().func,
501
+ onClose: i().func,
502
+ onFocus: i().func,
503
+ onKeyDown: i().func,
504
+ onOpen: i().func,
505
+ onScroll: i().func,
506
+ placeholder: i().string,
507
+ value: i().string
508
+ };
509
+ function ie(e, r) {
510
+ var t = r.clientX, n = r.clientY;
511
+ var o = e.getBoundingClientRect(), i = o.top, a = o.left, u = o.bottom, l = o.right;
512
+ return t > a && t < l && n > i && n < u;
513
+ }
514
+ function ae(e) {
515
+ var r = e.animateLoading, o = r === void 0 ? false : r, i = e.children, a = e.defaultPlacement, l = e.defaultValue, f = e.describedBy, d = e.disabled, g = d === void 0 ? false : d, h = e.elementRef, O = e.error, w = O === void 0 ? false : O, P = e.footerMessage, C = e.inline, R = C === void 0 ? false : C, M = e.inputRef, E = e.isLoadingOptions, D = E === void 0 ? false : E, q = e.labelledBy, x = e.loadingMessage, I = e.menuStyle, _ = I === void 0 ? {} : I, A = e.name, T = e.noOptionsMessage, B = e.onChange, V = e.onClose, L = e.onFocus, H = e.onKeyDown, K = e.onOpen, N = e.placeholder, F = N === void 0 ? (0,
516
+ b._)("Search...") : N, W = e.value, X = te(e, [ "animateLoading", "children", "defaultPlacement", "defaultValue", "describedBy", "disabled", "elementRef", "error", "footerMessage", "inline", "inputRef", "isLoadingOptions", "labelledBy", "loadingMessage", "menuStyle", "name", "noOptionsMessage", "onChange", "onClose", "onFocus", "onKeyDown", "onOpen", "placeholder", "value" ]);
517
+ // @docs-props-type SearchPropsBase
518
+ // state
519
+ var $ = (0, t.useState)(0), J = G($, 2), Q = J[0], Z = J[1];
520
+ var ee = (0, t.useState)(false), re = G(ee, 2), ne = re[0], oe = re[1];
521
+ var ae = (0, t.useState)(undefined), ue = G(ae, 2), le = ue[0], ce = ue[1];
522
+ var fe = (0, t.useState)(l || ""), se = G(fe, 2), de = se[0], ve = se[1];
523
+ // previous state
524
+ var pe = m()(Q);
525
+ // refs
526
+ var be = (0, t.useRef)(null);
527
+ var ye = (0, t.useRef)(null);
528
+ var ge = (0, t.useRef)(W !== undefined && W !== null);
529
+ var he = (0, t.useRef)(false);
530
+ var me = (0, t.useRef)([]);
531
+ var Oe = (0, t.useRef)((0, p.createDOMID)("popover"));
532
+ var je = (0, t.useRef)(pe);
533
+ var we = (0, t.useRef)((0, p.createDOMID)("active-item"));
534
+ var Se = (0, t.useRef)(undefined);
535
+ var Pe = function e(r) {
536
+ z(be, r);
537
+ z(h, r);
538
+ };
539
+ var ke = function e(r) {
540
+ z(ye, r);
541
+ z(M, r);
542
+ };
543
+ var Ce = function e() {
544
+ return ge.current ? W : de;
545
+ };
546
+ var Re = function e() {
547
+ var r = Ce();
548
+ var n = t.Children.toArray(i).filter(t.isValidElement);
549
+ var o = !le && n.find((function(e) {
550
+ return e.props.label !== undefined && e.props.value === r;
551
+ }));
552
+ if (o) {
553
+ return o === null || o === void 0 ? void 0 : o.props.label;
554
+ }
555
+ return r;
556
+ };
557
+ var Me = function e() {
558
+ return !!i || D;
559
+ };
560
+ var Ee = function e() {
561
+ oe(true);
562
+ Z(-1);
563
+ K === null || K === void 0 ? void 0 : K();
564
+ };
565
+ var De = function e() {
566
+ oe(false);
567
+ je.current = null;
568
+ V === null || V === void 0 ? void 0 : V();
569
+ };
570
+ var qe = function e() {
571
+ var r;
572
+ (r = ye.current) === null || r === void 0 ? void 0 : r.focus();
573
+ };
574
+ var xe = function e(r) {
575
+ /* SUI-930 On IE 11 this handler is essentially deferred after calling
576
+ * this.textInput.focus(). this.focusCalledInternally enables the focus event to be ignored
577
+ * when the menu closes. */
578
+ if (he.current) {
579
+ he.current = false;
580
+ } else {
581
+ Ee();
582
+ }
583
+ L === null || L === void 0 ? void 0 : L(r);
584
+ };
585
+ var Ie = function e(r, t) {
586
+ var n = t.value;
587
+ if (!ge.current) {
588
+ ve(n);
589
+ }
590
+ Z(-1);
591
+ ce(n);
592
+ B === null || B === void 0 ? void 0 : B(r, {
593
+ value: n,
594
+ name: A
595
+ });
596
+ };
597
+ var _e = function e(r, t) {
598
+ Ie(r, Y({}, t));
599
+ he.current = true;
600
+ qe();
601
+ De();
602
+ };
603
+ var Ae = function e(r) {
604
+ var t = me.current.length;
605
+ var n = Se.current;
606
+ var o = (0, y.keycode)(r.nativeEvent);
607
+ if (ne) {
608
+ switch (o) {
609
+ case "enter":
610
+ {
611
+ if (n) {
612
+ _e(r, {
613
+ value: n
614
+ });
615
+ }
616
+ break;
617
+ }
618
+
619
+ case "tab":
620
+ De();
621
+ break;
622
+
623
+ case "down":
624
+ Z(Math.min(Q + 1, t - 1));
625
+ break;
626
+
627
+ case "up":
628
+ Z(Math.max(Q - 1, 0));
629
+ break;
630
+
631
+ default:
632
+ // do nothing
633
+ }
634
+ } else if ((0, y.addsCharacter)(r.nativeEvent) !== false || // Safari 9.0 returns undefined
635
+ o === "enter" || o === "backspace" || o === "down" || o === "up") {
636
+ Ee();
637
+ }
638
+ H === null || H === void 0 ? void 0 : H(r);
639
+ };
640
+ var Te = function e() {
641
+ if (document.activeElement !== ye.current) {
642
+ he.current = true;
643
+ qe();
644
+ }
645
+ if (!ne && !g) {
646
+ Ee();
647
+ }
648
+ };
649
+ var Be = function e(r) {
650
+ var t = r.event, n = r.reason;
651
+ var o = n === "offScreen" || n === "escapeKey" || n === "clickAway" && be.current && !ie(be.current, t);
652
+ if (o) {
653
+ De();
654
+ }
655
+ };
656
+ var Ve = function e(r) {
657
+ if (je.current !== Q) {
658
+ r === null || r === void 0 ? void 0 : r.scrollIntoViewIfNeeded();
659
+ }
660
+ };
661
+ var Le = function e(r) {
662
+ var a = r.anchorWidth, l = r.maxHeight;
663
+ var f = t.Children.toArray(i).filter(t.isValidElement);
664
+ // Highlight Active
665
+ Se.current = undefined;
666
+ // Only update the menu options if they are valid and the drodown is open.
667
+ // This is necessary to handle the outro animation of the dropdown.
668
+ if (Me() && ne) {
669
+ me.current = f.map((function(e, r) {
670
+ if (!c()(e.props, "active")) {
671
+ // ignore Headings and Dividers
672
+ return e;
673
+ }
674
+ if (r === Q) {
675
+ Se.current = e.props.value;
676
+
677
+ return (0, t.cloneElement)(e, {
678
+ ref: Ve,
679
+ id: we.current,
680
+ onClick: _e,
681
+ active: true
682
+ });
683
+ }
684
+
685
+ return (0, t.cloneElement)(e, {
686
+ onClick: _e
687
+ });
688
+ }));
689
+ }
690
+
691
+ return n().createElement(S(), U({
692
+ style: u()({
693
+ overflow: "auto",
694
+ width: Math.max(a !== null && a !== void 0 ? a : 0, 200)
695
+ }, _),
696
+ controlledExternally: true,
697
+ maxHeight: l !== null && l !== void 0 ? l : undefined,
698
+ isLoading: D
699
+ }, v()(X, "className", "onScroll"), {
700
+ noOptionsMessage: T,
701
+ footerMessage: P,
702
+ animateLoading: o,
703
+ loadingMessage: x
704
+ }), me.current);
705
+ };
706
+ var He = Ce();
707
+ var Ke = Re();
708
+ var Ne = ne && !!be.current && Me();
709
+ var Fe = {
710
+ "aria-activedescendant": we.current,
711
+ "aria-expanded": Ne,
712
+ "aria-haspopup": Me(),
713
+ "aria-controls": Ne ? Oe.current : undefined
714
+ };
715
+ if (!(q === null || q === void 0 ? void 0 : q.length)) {
716
+ Fe["aria-label"] = (0, b._)("Value input");
717
+ }
718
+
719
+ return n().createElement(k(), U({
720
+ "data-test": "search"
721
+ }, s()(X, "className", "onScroll"), {
722
+ appearance: "search",
723
+ autoCapitalize: "off",
724
+ autoComplete: "off",
725
+ autoCorrect: "off",
726
+ "data-test-popover-id": Oe.current,
727
+ "data-test-label": Ke,
728
+ "data-test-value": He,
729
+ "data-test-open": Ne,
730
+ describedBy: f,
731
+ disabled: g,
732
+ elementRef: Pe,
733
+ error: w,
734
+ inline: R,
735
+ inputRef: ke,
736
+ labelledBy: q,
737
+ name: A,
738
+ onFocus: xe,
739
+ onClick: Te,
740
+ onChange: Ie,
741
+ onKeyDown: Ae,
742
+ placeholder: F,
743
+ spellCheck: false,
744
+ value: Ke
745
+ }, Fe), n().createElement(j(), {
746
+ anchor: function() {
747
+ return be.current;
748
+ }(),
749
+ autoCloseWhenOffScreen: true,
750
+ canCoverAnchor: false,
751
+ defaultPlacement: a,
752
+ id: Oe.current,
753
+ onRequestClose: Be,
754
+ open: Ne,
755
+ repositionMode: "flip"
756
+ }, Le));
757
+ }
758
+ ae.propTypes = oe;
759
+ ae.Option = W;
760
+ ae.Divider = g.Divider;
761
+ ae.Heading = g.Heading;
762
+ /* harmony default export */ const ue = ae;
763
+ // CONCATENATED MODULE: ./src/Search/index.ts
764
+ module.exports = r;
765
+ /******/})();