@splunk/react-ui 4.21.0 → 4.22.0

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