@eightshift/ui-components 4.0.0 → 5.0.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 (144) hide show
  1. package/package.json +101 -101
  2. package/dist/Button-CvzGKGCo.js +0 -185
  3. package/dist/Collection-ddre1L5v.js +0 -2332
  4. package/dist/Color-MV5kBVXr.js +0 -2452
  5. package/dist/ColorSwatch-BqQfVu4L.js +0 -64
  6. package/dist/ComboBox-jQ-dk95U.js +0 -1906
  7. package/dist/Dialog-DX1aiYyE.js +0 -2300
  8. package/dist/FieldError-52GVSGgC.js +0 -42
  9. package/dist/FocusScope-Cri5BFRz.js +0 -831
  10. package/dist/Form-Cq3fu75_.js +0 -5
  11. package/dist/Group-_emcIVxI.js +0 -48
  12. package/dist/Heading-B2153VXe.js +0 -16
  13. package/dist/Hidden-rE6uR-lr.js +0 -41
  14. package/dist/Input-BxpFEIXV.js +0 -133
  15. package/dist/Label-icmbmNdI.js +0 -17
  16. package/dist/List-BYNHbol3.js +0 -593
  17. package/dist/ListBox-mJ4nQaL7.js +0 -581
  18. package/dist/NumberFormatter-DA8u1Ot7.js +0 -140
  19. package/dist/OverlayArrow-BB0CWwdq.js +0 -629
  20. package/dist/RSPContexts-2lR5GG9p.js +0 -14
  21. package/dist/Select-aab027f3.esm--EmXjiL3.js +0 -2469
  22. package/dist/Separator-D9moUgP8.js +0 -322
  23. package/dist/Slider-rz2XRMGm.js +0 -853
  24. package/dist/Text-DVSAPY-K.js +0 -16
  25. package/dist/VisuallyHidden-f9zX67a_.js +0 -48
  26. package/dist/_commonjsHelpers-CUmg6egw.js +0 -6
  27. package/dist/assets/index.css +0 -37
  28. package/dist/assets/style-admin.css +0 -5255
  29. package/dist/assets/style-editor.css +0 -5255
  30. package/dist/assets/style.css +0 -5261
  31. package/dist/assets/wp-font-enhancements.css +0 -8
  32. package/dist/assets/wp-ui-enhancements.css +0 -299
  33. package/dist/components/animated-visibility/animated-visibility.js +0 -105
  34. package/dist/components/base-control/base-control.js +0 -86
  35. package/dist/components/breakpoint-preview/breakpoint-preview.js +0 -161
  36. package/dist/components/button/button.js +0 -387
  37. package/dist/components/checkbox/checkbox.js +0 -320
  38. package/dist/components/color-pickers/color-picker.js +0 -272
  39. package/dist/components/color-pickers/color-swatch.js +0 -58
  40. package/dist/components/color-pickers/gradient-editor.js +0 -534
  41. package/dist/components/color-pickers/solid-color-picker.js +0 -1567
  42. package/dist/components/component-toggle/component-toggle.js +0 -158
  43. package/dist/components/container-panel/container-panel.js +0 -131
  44. package/dist/components/draggable/draggable-context.js +0 -5
  45. package/dist/components/draggable/draggable-handle.js +0 -46
  46. package/dist/components/draggable/draggable.js +0 -6207
  47. package/dist/components/draggable-list/draggable-list-context.js +0 -5
  48. package/dist/components/draggable-list/draggable-list-item.js +0 -77
  49. package/dist/components/draggable-list/draggable-list.js +0 -151
  50. package/dist/components/expandable/expandable.js +0 -342
  51. package/dist/components/index.js +0 -137
  52. package/dist/components/input-field/input-field.js +0 -231
  53. package/dist/components/item-collection/item-collection.js +0 -59
  54. package/dist/components/layout/hstack.js +0 -30
  55. package/dist/components/layout/vstack.js +0 -30
  56. package/dist/components/link-input/link-input.js +0 -293
  57. package/dist/components/matrix-align/matrix-align.js +0 -134
  58. package/dist/components/menu/menu.js +0 -285
  59. package/dist/components/modal/modal.js +0 -305
  60. package/dist/components/notice/notice.js +0 -123
  61. package/dist/components/number-picker/number-picker.js +0 -292
  62. package/dist/components/option-select/option-select.js +0 -264
  63. package/dist/components/options-panel/options-panel.js +0 -158
  64. package/dist/components/placeholders/file-placeholder.js +0 -42
  65. package/dist/components/placeholders/image-placeholder.js +0 -88
  66. package/dist/components/placeholders/media-placeholder.js +0 -63
  67. package/dist/components/popover/popover.js +0 -207
  68. package/dist/components/radio/radio.js +0 -579
  69. package/dist/components/repeater/repeater-context.js +0 -5
  70. package/dist/components/repeater/repeater-item.js +0 -119
  71. package/dist/components/repeater/repeater.js +0 -280
  72. package/dist/components/responsive/mini-responsive.js +0 -498
  73. package/dist/components/responsive/responsive-legacy.js +0 -343
  74. package/dist/components/responsive/responsive.js +0 -580
  75. package/dist/components/responsive-preview/responsive-preview.js +0 -123
  76. package/dist/components/rich-label/rich-label.js +0 -66
  77. package/dist/components/select/async-multi-select.js +0 -157
  78. package/dist/components/select/async-single-select.js +0 -137
  79. package/dist/components/select/custom-select-default-components.js +0 -38
  80. package/dist/components/select/multi-select-components.js +0 -8
  81. package/dist/components/select/multi-select.js +0 -151
  82. package/dist/components/select/react-select-component-wrappers.js +0 -90
  83. package/dist/components/select/shared.js +0 -26
  84. package/dist/components/select/single-select.js +0 -131
  85. package/dist/components/select/styles.js +0 -49
  86. package/dist/components/select/v2/async-select.js +0 -297
  87. package/dist/components/select/v2/shared.js +0 -24
  88. package/dist/components/select/v2/single-select.js +0 -990
  89. package/dist/components/slider/column-config-slider.js +0 -210
  90. package/dist/components/slider/slider.js +0 -343
  91. package/dist/components/slider/utils.js +0 -84
  92. package/dist/components/spacer/spacer.js +0 -97
  93. package/dist/components/tabs/tabs.js +0 -702
  94. package/dist/components/toggle/switch.js +0 -155
  95. package/dist/components/toggle/toggle.js +0 -64
  96. package/dist/components/toggle-button/toggle-button.js +0 -324
  97. package/dist/components/tooltip/tooltip.js +0 -525
  98. package/dist/context-D2KUdwNL.js +0 -92
  99. package/dist/default-i18n-CT_oS1Fy.js +0 -922
  100. package/dist/filterDOMProps-EDDcM64A.js +0 -28
  101. package/dist/icons/block-icon.js +0 -42
  102. package/dist/icons/generic-color-swatch.js +0 -113
  103. package/dist/icons/icons.js +0 -30371
  104. package/dist/icons/index.js +0 -11
  105. package/dist/icons/jsx-svg.js +0 -50
  106. package/dist/index-641ee5b8.esm-BPz6U6sJ.js +0 -3137
  107. package/dist/index-BKGQ6jGS.js +0 -44
  108. package/dist/index-BYHhzLf-.js +0 -444
  109. package/dist/index.js +0 -139
  110. package/dist/lite-DVmmD_-j.js +0 -7
  111. package/dist/modifiers.esm-BuJQPI1X.js +0 -31
  112. package/dist/multi-select-components-BlZZoNXC.js +0 -3744
  113. package/dist/number-GajL10e1.js +0 -36
  114. package/dist/react-jsx-parser.min-DZCiis5V.js +0 -11753
  115. package/dist/react-select-async.esm-CwUoej5h.js +0 -107
  116. package/dist/react-select.esm-DcwYxadV.js +0 -15
  117. package/dist/style-admin.js +0 -1
  118. package/dist/style-editor.js +0 -1
  119. package/dist/style.js +0 -1
  120. package/dist/textSelection-0UUS8Yfg.js +0 -46
  121. package/dist/useButton-BpOKDWEN.js +0 -71
  122. package/dist/useEvent-B0b-6KBr.js +0 -23
  123. package/dist/useFocusRing-CV5l3lf6.js +0 -107
  124. package/dist/useFormReset-C5OggHsw.js +0 -22
  125. package/dist/useFormValidation-DhDNSjws.js +0 -224
  126. package/dist/useHover-DwDr6ozG.js +0 -900
  127. package/dist/useLabel-D7HkNEHT.js +0 -27
  128. package/dist/useLabels-D8cxd1Z8.js +0 -23
  129. package/dist/useListState-UGlN5-7P.js +0 -161
  130. package/dist/useLocalizedStringFormatter-CFP1YZWQ.js +0 -121
  131. package/dist/useNumberField-CEAj7Mrj.js +0 -1204
  132. package/dist/useNumberFormatter-321rAb4J.js +0 -13
  133. package/dist/usePress-DNW8qpY6.js +0 -664
  134. package/dist/useSingleSelectListState-DC0wWTUM.js +0 -38
  135. package/dist/useToggle-BrpmSOB-.js +0 -59
  136. package/dist/useToggleState-CmQX3SoX.js +0 -19
  137. package/dist/utilities/array-helpers.js +0 -56
  138. package/dist/utilities/debounce-throttle.js +0 -123
  139. package/dist/utilities/es-dash.js +0 -376
  140. package/dist/utilities/index.js +0 -27
  141. package/dist/utilities/text-helpers.js +0 -136
  142. package/dist/utils-DkCSC521.js +0 -370
  143. package/dist/wp/wp-font-enhancements.js +0 -1
  144. package/dist/wp/wp-ui-enhancements.js +0 -1
@@ -1,2469 +0,0 @@
1
- import { a as _objectWithoutProperties, b as _slicedToArray, d as _objectSpread2, t as toPropertyKey, f as _typeof, g as _arrayLikeToArray, i as _unsupportedIterableToArray, m as multiValueAsValue, s as singleValueAsValue, v as valueTernary, j as classNames, k as valueContainerCSS, l as css, p as placeholderCSS, o as optionCSS, n as noOptionsMessageCSS, q as multiValueRemoveCSS, r as multiValueLabelCSS, u as multiValueCSS, w as menuPortalCSS, x as menuListCSS, y as menuCSS, z as loadingMessageCSS, A as loadingIndicatorCSS, B as inputCSS, C as indicatorSeparatorCSS, D as indicatorsContainerCSS, E as groupHeadingCSS, F as groupCSS, G as dropdownIndicatorCSS, H as css$1, I as containerCSS, J as clearIndicatorCSS, K as defaultComponents, L as isDocumentElement, M as cleanValue, N as notNullish, O as isMobileDevice, P as isTouchCapable, Q as scrollIntoView, _ as _extends, R as noop, S as MenuPlacer, T as removeProps, U as jsx, V as css$2, W as supportsPassiveEvents } from "./index-641ee5b8.esm-BPz6U6sJ.js";
2
- import * as React from "react";
3
- import { useState, useCallback, Component, Fragment, useMemo, useRef, useEffect } from "react";
4
- var _excluded$1 = ["defaultInputValue", "defaultMenuIsOpen", "defaultValue", "inputValue", "menuIsOpen", "onChange", "onInputChange", "onMenuClose", "onMenuOpen", "value"];
5
- function useStateManager(_ref3) {
6
- var _ref$defaultInputValu = _ref3.defaultInputValue, defaultInputValue = _ref$defaultInputValu === void 0 ? "" : _ref$defaultInputValu, _ref$defaultMenuIsOpe = _ref3.defaultMenuIsOpen, defaultMenuIsOpen = _ref$defaultMenuIsOpe === void 0 ? false : _ref$defaultMenuIsOpe, _ref$defaultValue = _ref3.defaultValue, defaultValue = _ref$defaultValue === void 0 ? null : _ref$defaultValue, propsInputValue = _ref3.inputValue, propsMenuIsOpen = _ref3.menuIsOpen, propsOnChange = _ref3.onChange, propsOnInputChange = _ref3.onInputChange, propsOnMenuClose = _ref3.onMenuClose, propsOnMenuOpen = _ref3.onMenuOpen, propsValue = _ref3.value, restSelectProps = _objectWithoutProperties(_ref3, _excluded$1);
7
- var _useState = useState(propsInputValue !== void 0 ? propsInputValue : defaultInputValue), _useState2 = _slicedToArray(_useState, 2), stateInputValue = _useState2[0], setStateInputValue = _useState2[1];
8
- var _useState3 = useState(propsMenuIsOpen !== void 0 ? propsMenuIsOpen : defaultMenuIsOpen), _useState4 = _slicedToArray(_useState3, 2), stateMenuIsOpen = _useState4[0], setStateMenuIsOpen = _useState4[1];
9
- var _useState5 = useState(propsValue !== void 0 ? propsValue : defaultValue), _useState6 = _slicedToArray(_useState5, 2), stateValue = _useState6[0], setStateValue = _useState6[1];
10
- var onChange2 = useCallback(function(value2, actionMeta) {
11
- if (typeof propsOnChange === "function") {
12
- propsOnChange(value2, actionMeta);
13
- }
14
- setStateValue(value2);
15
- }, [propsOnChange]);
16
- var onInputChange = useCallback(function(value2, actionMeta) {
17
- var newValue;
18
- if (typeof propsOnInputChange === "function") {
19
- newValue = propsOnInputChange(value2, actionMeta);
20
- }
21
- setStateInputValue(newValue !== void 0 ? newValue : value2);
22
- }, [propsOnInputChange]);
23
- var onMenuOpen = useCallback(function() {
24
- if (typeof propsOnMenuOpen === "function") {
25
- propsOnMenuOpen();
26
- }
27
- setStateMenuIsOpen(true);
28
- }, [propsOnMenuOpen]);
29
- var onMenuClose = useCallback(function() {
30
- if (typeof propsOnMenuClose === "function") {
31
- propsOnMenuClose();
32
- }
33
- setStateMenuIsOpen(false);
34
- }, [propsOnMenuClose]);
35
- var inputValue = propsInputValue !== void 0 ? propsInputValue : stateInputValue;
36
- var menuIsOpen = propsMenuIsOpen !== void 0 ? propsMenuIsOpen : stateMenuIsOpen;
37
- var value = propsValue !== void 0 ? propsValue : stateValue;
38
- return _objectSpread2(_objectSpread2({}, restSelectProps), {}, {
39
- inputValue,
40
- menuIsOpen,
41
- onChange: onChange2,
42
- onInputChange,
43
- onMenuClose,
44
- onMenuOpen,
45
- value
46
- });
47
- }
48
- function _classCallCheck(a, n) {
49
- if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
50
- }
51
- function _defineProperties(e, r) {
52
- for (var t = 0; t < r.length; t++) {
53
- var o = r[t];
54
- o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, toPropertyKey(o.key), o);
55
- }
56
- }
57
- function _createClass(e, r, t) {
58
- return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
59
- writable: false
60
- }), e;
61
- }
62
- function _setPrototypeOf(t, e) {
63
- return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(t2, e2) {
64
- return t2.__proto__ = e2, t2;
65
- }, _setPrototypeOf(t, e);
66
- }
67
- function _inherits(t, e) {
68
- if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
69
- t.prototype = Object.create(e && e.prototype, {
70
- constructor: {
71
- value: t,
72
- writable: true,
73
- configurable: true
74
- }
75
- }), Object.defineProperty(t, "prototype", {
76
- writable: false
77
- }), e && _setPrototypeOf(t, e);
78
- }
79
- function _getPrototypeOf(t) {
80
- return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(t2) {
81
- return t2.__proto__ || Object.getPrototypeOf(t2);
82
- }, _getPrototypeOf(t);
83
- }
84
- function _isNativeReflectConstruct() {
85
- try {
86
- var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
87
- }));
88
- } catch (t2) {
89
- }
90
- return (_isNativeReflectConstruct = function _isNativeReflectConstruct2() {
91
- return !!t;
92
- })();
93
- }
94
- function _assertThisInitialized(e) {
95
- if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
96
- return e;
97
- }
98
- function _possibleConstructorReturn(t, e) {
99
- if (e && ("object" == _typeof(e) || "function" == typeof e)) return e;
100
- if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
101
- return _assertThisInitialized(t);
102
- }
103
- function _createSuper(t) {
104
- var r = _isNativeReflectConstruct();
105
- return function() {
106
- var e, o = _getPrototypeOf(t);
107
- if (r) {
108
- var s = _getPrototypeOf(this).constructor;
109
- e = Reflect.construct(o, arguments, s);
110
- } else e = o.apply(this, arguments);
111
- return _possibleConstructorReturn(this, e);
112
- };
113
- }
114
- function _arrayWithoutHoles(r) {
115
- if (Array.isArray(r)) return _arrayLikeToArray(r);
116
- }
117
- function _iterableToArray(r) {
118
- if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
119
- }
120
- function _nonIterableSpread() {
121
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
122
- }
123
- function _toConsumableArray(r) {
124
- return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
125
- }
126
- var safeIsNaN = Number.isNaN || function ponyfill(value) {
127
- return typeof value === "number" && value !== value;
128
- };
129
- function isEqual(first, second) {
130
- if (first === second) {
131
- return true;
132
- }
133
- if (safeIsNaN(first) && safeIsNaN(second)) {
134
- return true;
135
- }
136
- return false;
137
- }
138
- function areInputsEqual(newInputs, lastInputs) {
139
- if (newInputs.length !== lastInputs.length) {
140
- return false;
141
- }
142
- for (var i = 0; i < newInputs.length; i++) {
143
- if (!isEqual(newInputs[i], lastInputs[i])) {
144
- return false;
145
- }
146
- }
147
- return true;
148
- }
149
- function memoizeOne(resultFn, isEqual2) {
150
- if (isEqual2 === void 0) {
151
- isEqual2 = areInputsEqual;
152
- }
153
- var cache = null;
154
- function memoized() {
155
- var newArgs = [];
156
- for (var _i = 0; _i < arguments.length; _i++) {
157
- newArgs[_i] = arguments[_i];
158
- }
159
- if (cache && cache.lastThis === this && isEqual2(newArgs, cache.lastArgs)) {
160
- return cache.lastResult;
161
- }
162
- var lastResult = resultFn.apply(this, newArgs);
163
- cache = {
164
- lastResult,
165
- lastArgs: newArgs,
166
- lastThis: this
167
- };
168
- return lastResult;
169
- }
170
- memoized.clear = function clear() {
171
- cache = null;
172
- };
173
- return memoized;
174
- }
175
- function _EMOTION_STRINGIFIED_CSS_ERROR__$2() {
176
- return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop).";
177
- }
178
- var _ref = process.env.NODE_ENV === "production" ? {
179
- name: "7pg0cj-a11yText",
180
- styles: "label:a11yText;z-index:9999;border:0;clip:rect(1px, 1px, 1px, 1px);height:1px;width:1px;position:absolute;overflow:hidden;padding:0;white-space:nowrap"
181
- } : {
182
- name: "1f43avz-a11yText-A11yText",
183
- styles: "label:a11yText;z-index:9999;border:0;clip:rect(1px, 1px, 1px, 1px);height:1px;width:1px;position:absolute;overflow:hidden;padding:0;white-space:nowrap;label:A11yText;",
184
- map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkExMXlUZXh0LnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFPSSIsImZpbGUiOiJBMTF5VGV4dC50c3giLCJzb3VyY2VzQ29udGVudCI6WyIvKiogQGpzeCBqc3ggKi9cbmltcG9ydCB7IEpTWCB9IGZyb20gJ3JlYWN0JztcbmltcG9ydCB7IGpzeCB9IGZyb20gJ0BlbW90aW9uL3JlYWN0JztcblxuLy8gQXNzaXN0aXZlIHRleHQgdG8gZGVzY3JpYmUgdmlzdWFsIGVsZW1lbnRzLiBIaWRkZW4gZm9yIHNpZ2h0ZWQgdXNlcnMuXG5jb25zdCBBMTF5VGV4dCA9IChwcm9wczogSlNYLkludHJpbnNpY0VsZW1lbnRzWydzcGFuJ10pID0+IChcbiAgPHNwYW5cbiAgICBjc3M9e3tcbiAgICAgIGxhYmVsOiAnYTExeVRleHQnLFxuICAgICAgekluZGV4OiA5OTk5LFxuICAgICAgYm9yZGVyOiAwLFxuICAgICAgY2xpcDogJ3JlY3QoMXB4LCAxcHgsIDFweCwgMXB4KScsXG4gICAgICBoZWlnaHQ6IDEsXG4gICAgICB3aWR0aDogMSxcbiAgICAgIHBvc2l0aW9uOiAnYWJzb2x1dGUnLFxuICAgICAgb3ZlcmZsb3c6ICdoaWRkZW4nLFxuICAgICAgcGFkZGluZzogMCxcbiAgICAgIHdoaXRlU3BhY2U6ICdub3dyYXAnLFxuICAgIH19XG4gICAgey4uLnByb3BzfVxuICAvPlxuKTtcblxuZXhwb3J0IGRlZmF1bHQgQTExeVRleHQ7XG4iXX0= */",
185
- toString: _EMOTION_STRINGIFIED_CSS_ERROR__$2
186
- };
187
- var A11yText = function A11yText2(props) {
188
- return jsx("span", _extends({
189
- css: _ref
190
- }, props));
191
- };
192
- var A11yText$1 = A11yText;
193
- var defaultAriaLiveMessages = {
194
- guidance: function guidance(props) {
195
- var isSearchable = props.isSearchable, isMulti = props.isMulti, tabSelectsValue = props.tabSelectsValue, context = props.context, isInitialFocus = props.isInitialFocus;
196
- switch (context) {
197
- case "menu":
198
- return "Use Up and Down to choose options, press Enter to select the currently focused option, press Escape to exit the menu".concat(tabSelectsValue ? ", press Tab to select the option and exit the menu" : "", ".");
199
- case "input":
200
- return isInitialFocus ? "".concat(props["aria-label"] || "Select", " is focused ").concat(isSearchable ? ",type to refine list" : "", ", press Down to open the menu, ").concat(isMulti ? " press left to focus selected values" : "") : "";
201
- case "value":
202
- return "Use left and right to toggle between focused values, press Backspace to remove the currently focused value";
203
- default:
204
- return "";
205
- }
206
- },
207
- onChange: function onChange(props) {
208
- var action = props.action, _props$label = props.label, label = _props$label === void 0 ? "" : _props$label, labels = props.labels, isDisabled = props.isDisabled;
209
- switch (action) {
210
- case "deselect-option":
211
- case "pop-value":
212
- case "remove-value":
213
- return "option ".concat(label, ", deselected.");
214
- case "clear":
215
- return "All selected options have been cleared.";
216
- case "initial-input-focus":
217
- return "option".concat(labels.length > 1 ? "s" : "", " ").concat(labels.join(","), ", selected.");
218
- case "select-option":
219
- return isDisabled ? "option ".concat(label, " is disabled. Select another option.") : "option ".concat(label, ", selected.");
220
- default:
221
- return "";
222
- }
223
- },
224
- onFocus: function onFocus(props) {
225
- var context = props.context, focused = props.focused, options = props.options, _props$label2 = props.label, label = _props$label2 === void 0 ? "" : _props$label2, selectValue = props.selectValue, isDisabled = props.isDisabled, isSelected = props.isSelected, isAppleDevice2 = props.isAppleDevice;
226
- var getArrayIndex = function getArrayIndex2(arr, item) {
227
- return arr && arr.length ? "".concat(arr.indexOf(item) + 1, " of ").concat(arr.length) : "";
228
- };
229
- if (context === "value" && selectValue) {
230
- return "value ".concat(label, " focused, ").concat(getArrayIndex(selectValue, focused), ".");
231
- }
232
- if (context === "menu" && isAppleDevice2) {
233
- var disabled = isDisabled ? " disabled" : "";
234
- var status = "".concat(isSelected ? " selected" : "").concat(disabled);
235
- return "".concat(label).concat(status, ", ").concat(getArrayIndex(options, focused), ".");
236
- }
237
- return "";
238
- },
239
- onFilter: function onFilter(props) {
240
- var inputValue = props.inputValue, resultsMessage = props.resultsMessage;
241
- return "".concat(resultsMessage).concat(inputValue ? " for search term " + inputValue : "", ".");
242
- }
243
- };
244
- var LiveRegion = function LiveRegion2(props) {
245
- var ariaSelection = props.ariaSelection, focusedOption = props.focusedOption, focusedValue = props.focusedValue, focusableOptions = props.focusableOptions, isFocused = props.isFocused, selectValue = props.selectValue, selectProps = props.selectProps, id = props.id, isAppleDevice2 = props.isAppleDevice;
246
- var ariaLiveMessages = selectProps.ariaLiveMessages, getOptionLabel4 = selectProps.getOptionLabel, inputValue = selectProps.inputValue, isMulti = selectProps.isMulti, isOptionDisabled3 = selectProps.isOptionDisabled, isSearchable = selectProps.isSearchable, menuIsOpen = selectProps.menuIsOpen, options = selectProps.options, screenReaderStatus2 = selectProps.screenReaderStatus, tabSelectsValue = selectProps.tabSelectsValue, isLoading = selectProps.isLoading;
247
- var ariaLabel = selectProps["aria-label"];
248
- var ariaLive = selectProps["aria-live"];
249
- var messages = useMemo(function() {
250
- return _objectSpread2(_objectSpread2({}, defaultAriaLiveMessages), ariaLiveMessages || {});
251
- }, [ariaLiveMessages]);
252
- var ariaSelected = useMemo(function() {
253
- var message = "";
254
- if (ariaSelection && messages.onChange) {
255
- var option = ariaSelection.option, selectedOptions = ariaSelection.options, removedValue = ariaSelection.removedValue, removedValues = ariaSelection.removedValues, value = ariaSelection.value;
256
- var asOption = function asOption2(val) {
257
- return !Array.isArray(val) ? val : null;
258
- };
259
- var selected = removedValue || option || asOption(value);
260
- var label = selected ? getOptionLabel4(selected) : "";
261
- var multiSelected = selectedOptions || removedValues || void 0;
262
- var labels = multiSelected ? multiSelected.map(getOptionLabel4) : [];
263
- var onChangeProps = _objectSpread2({
264
- // multiSelected items are usually items that have already been selected
265
- // or set by the user as a default value so we assume they are not disabled
266
- isDisabled: selected && isOptionDisabled3(selected, selectValue),
267
- label,
268
- labels
269
- }, ariaSelection);
270
- message = messages.onChange(onChangeProps);
271
- }
272
- return message;
273
- }, [ariaSelection, messages, isOptionDisabled3, selectValue, getOptionLabel4]);
274
- var ariaFocused = useMemo(function() {
275
- var focusMsg = "";
276
- var focused = focusedOption || focusedValue;
277
- var isSelected = !!(focusedOption && selectValue && selectValue.includes(focusedOption));
278
- if (focused && messages.onFocus) {
279
- var onFocusProps = {
280
- focused,
281
- label: getOptionLabel4(focused),
282
- isDisabled: isOptionDisabled3(focused, selectValue),
283
- isSelected,
284
- options: focusableOptions,
285
- context: focused === focusedOption ? "menu" : "value",
286
- selectValue,
287
- isAppleDevice: isAppleDevice2
288
- };
289
- focusMsg = messages.onFocus(onFocusProps);
290
- }
291
- return focusMsg;
292
- }, [focusedOption, focusedValue, getOptionLabel4, isOptionDisabled3, messages, focusableOptions, selectValue, isAppleDevice2]);
293
- var ariaResults = useMemo(function() {
294
- var resultsMsg = "";
295
- if (menuIsOpen && options.length && !isLoading && messages.onFilter) {
296
- var resultsMessage = screenReaderStatus2({
297
- count: focusableOptions.length
298
- });
299
- resultsMsg = messages.onFilter({
300
- inputValue,
301
- resultsMessage
302
- });
303
- }
304
- return resultsMsg;
305
- }, [focusableOptions, inputValue, menuIsOpen, messages, options, screenReaderStatus2, isLoading]);
306
- var isInitialFocus = (ariaSelection === null || ariaSelection === void 0 ? void 0 : ariaSelection.action) === "initial-input-focus";
307
- var ariaGuidance = useMemo(function() {
308
- var guidanceMsg = "";
309
- if (messages.guidance) {
310
- var context = focusedValue ? "value" : menuIsOpen ? "menu" : "input";
311
- guidanceMsg = messages.guidance({
312
- "aria-label": ariaLabel,
313
- context,
314
- isDisabled: focusedOption && isOptionDisabled3(focusedOption, selectValue),
315
- isMulti,
316
- isSearchable,
317
- tabSelectsValue,
318
- isInitialFocus
319
- });
320
- }
321
- return guidanceMsg;
322
- }, [ariaLabel, focusedOption, focusedValue, isMulti, isOptionDisabled3, isSearchable, menuIsOpen, messages, selectValue, tabSelectsValue, isInitialFocus]);
323
- var ScreenReaderText = jsx(Fragment, null, jsx("span", {
324
- id: "aria-selection"
325
- }, ariaSelected), jsx("span", {
326
- id: "aria-focused"
327
- }, ariaFocused), jsx("span", {
328
- id: "aria-results"
329
- }, ariaResults), jsx("span", {
330
- id: "aria-guidance"
331
- }, ariaGuidance));
332
- return jsx(Fragment, null, jsx(A11yText$1, {
333
- id
334
- }, isInitialFocus && ScreenReaderText), jsx(A11yText$1, {
335
- "aria-live": ariaLive,
336
- "aria-atomic": "false",
337
- "aria-relevant": "additions text",
338
- role: "log"
339
- }, isFocused && !isInitialFocus && ScreenReaderText));
340
- };
341
- var LiveRegion$1 = LiveRegion;
342
- var diacritics = [{
343
- base: "A",
344
- letters: "AⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢÅǺǍȀȂẠẬẶḀĄȺⱯ"
345
- }, {
346
- base: "AA",
347
- letters: "Ꜳ"
348
- }, {
349
- base: "AE",
350
- letters: "ÆǼǢ"
351
- }, {
352
- base: "AO",
353
- letters: "Ꜵ"
354
- }, {
355
- base: "AU",
356
- letters: "Ꜷ"
357
- }, {
358
- base: "AV",
359
- letters: "ꜸꜺ"
360
- }, {
361
- base: "AY",
362
- letters: "Ꜽ"
363
- }, {
364
- base: "B",
365
- letters: "BⒷBḂḄḆɃƂƁ"
366
- }, {
367
- base: "C",
368
- letters: "CⒸCĆĈĊČÇḈƇȻꜾ"
369
- }, {
370
- base: "D",
371
- letters: "DⒹDḊĎḌḐḒḎĐƋƊƉꝹ"
372
- }, {
373
- base: "DZ",
374
- letters: "DZDŽ"
375
- }, {
376
- base: "Dz",
377
- letters: "DzDž"
378
- }, {
379
- base: "E",
380
- letters: "EⒺEÈÉÊỀẾỄỂẼĒḔḖĔĖËẺĚȄȆẸỆȨḜĘḘḚƐƎ"
381
- }, {
382
- base: "F",
383
- letters: "FⒻFḞƑꝻ"
384
- }, {
385
- base: "G",
386
- letters: "GⒼGǴĜḠĞĠǦĢǤƓꞠꝽꝾ"
387
- }, {
388
- base: "H",
389
- letters: "HⒽHĤḢḦȞḤḨḪĦⱧⱵꞍ"
390
- }, {
391
- base: "I",
392
- letters: "IⒾIÌÍÎĨĪĬİÏḮỈǏȈȊỊĮḬƗ"
393
- }, {
394
- base: "J",
395
- letters: "JⒿJĴɈ"
396
- }, {
397
- base: "K",
398
- letters: "KⓀKḰǨḲĶḴƘⱩꝀꝂꝄꞢ"
399
- }, {
400
- base: "L",
401
- letters: "LⓁLĿĹĽḶḸĻḼḺŁȽⱢⱠꝈꝆꞀ"
402
- }, {
403
- base: "LJ",
404
- letters: "LJ"
405
- }, {
406
- base: "Lj",
407
- letters: "Lj"
408
- }, {
409
- base: "M",
410
- letters: "MⓂMḾṀṂⱮƜ"
411
- }, {
412
- base: "N",
413
- letters: "NⓃNǸŃÑṄŇṆŅṊṈȠƝꞐꞤ"
414
- }, {
415
- base: "NJ",
416
- letters: "NJ"
417
- }, {
418
- base: "Nj",
419
- letters: "Nj"
420
- }, {
421
- base: "O",
422
- letters: "OⓄOÒÓÔỒỐỖỔÕṌȬṎŌṐṒŎȮȰÖȪỎŐǑȌȎƠỜỚỠỞỢỌỘǪǬØǾƆƟꝊꝌ"
423
- }, {
424
- base: "OI",
425
- letters: "Ƣ"
426
- }, {
427
- base: "OO",
428
- letters: "Ꝏ"
429
- }, {
430
- base: "OU",
431
- letters: "Ȣ"
432
- }, {
433
- base: "P",
434
- letters: "PⓅPṔṖƤⱣꝐꝒꝔ"
435
- }, {
436
- base: "Q",
437
- letters: "QⓆQꝖꝘɊ"
438
- }, {
439
- base: "R",
440
- letters: "RⓇRŔṘŘȐȒṚṜŖṞɌⱤꝚꞦꞂ"
441
- }, {
442
- base: "S",
443
- letters: "SⓈSẞŚṤŜṠŠṦṢṨȘŞⱾꞨꞄ"
444
- }, {
445
- base: "T",
446
- letters: "TⓉTṪŤṬȚŢṰṮŦƬƮȾꞆ"
447
- }, {
448
- base: "TZ",
449
- letters: "Ꜩ"
450
- }, {
451
- base: "U",
452
- letters: "UⓊUÙÚÛŨṸŪṺŬÜǛǗǕǙỦŮŰǓȔȖƯỪỨỮỬỰỤṲŲṶṴɄ"
453
- }, {
454
- base: "V",
455
- letters: "VⓋVṼṾƲꝞɅ"
456
- }, {
457
- base: "VY",
458
- letters: "Ꝡ"
459
- }, {
460
- base: "W",
461
- letters: "WⓌWẀẂŴẆẄẈⱲ"
462
- }, {
463
- base: "X",
464
- letters: "XⓍXẊẌ"
465
- }, {
466
- base: "Y",
467
- letters: "YⓎYỲÝŶỸȲẎŸỶỴƳɎỾ"
468
- }, {
469
- base: "Z",
470
- letters: "ZⓏZŹẐŻŽẒẔƵȤⱿⱫꝢ"
471
- }, {
472
- base: "a",
473
- letters: "aⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁąⱥɐ"
474
- }, {
475
- base: "aa",
476
- letters: "ꜳ"
477
- }, {
478
- base: "ae",
479
- letters: "æǽǣ"
480
- }, {
481
- base: "ao",
482
- letters: "ꜵ"
483
- }, {
484
- base: "au",
485
- letters: "ꜷ"
486
- }, {
487
- base: "av",
488
- letters: "ꜹꜻ"
489
- }, {
490
- base: "ay",
491
- letters: "ꜽ"
492
- }, {
493
- base: "b",
494
- letters: "bⓑbḃḅḇƀƃɓ"
495
- }, {
496
- base: "c",
497
- letters: "cⓒcćĉċčçḉƈȼꜿↄ"
498
- }, {
499
- base: "d",
500
- letters: "dⓓdḋďḍḑḓḏđƌɖɗꝺ"
501
- }, {
502
- base: "dz",
503
- letters: "dzdž"
504
- }, {
505
- base: "e",
506
- letters: "eⓔeèéêềếễểẽēḕḗĕėëẻěȅȇẹệȩḝęḙḛɇɛǝ"
507
- }, {
508
- base: "f",
509
- letters: "fⓕfḟƒꝼ"
510
- }, {
511
- base: "g",
512
- letters: "gⓖgǵĝḡğġǧģǥɠꞡᵹꝿ"
513
- }, {
514
- base: "h",
515
- letters: "hⓗhĥḣḧȟḥḩḫẖħⱨⱶɥ"
516
- }, {
517
- base: "hv",
518
- letters: "ƕ"
519
- }, {
520
- base: "i",
521
- letters: "iⓘiìíîĩīĭïḯỉǐȉȋịįḭɨı"
522
- }, {
523
- base: "j",
524
- letters: "jⓙjĵǰɉ"
525
- }, {
526
- base: "k",
527
- letters: "kⓚkḱǩḳķḵƙⱪꝁꝃꝅꞣ"
528
- }, {
529
- base: "l",
530
- letters: "lⓛlŀĺľḷḹļḽḻſłƚɫⱡꝉꞁꝇ"
531
- }, {
532
- base: "lj",
533
- letters: "lj"
534
- }, {
535
- base: "m",
536
- letters: "mⓜmḿṁṃɱɯ"
537
- }, {
538
- base: "n",
539
- letters: "nⓝnǹńñṅňṇņṋṉƞɲʼnꞑꞥ"
540
- }, {
541
- base: "nj",
542
- letters: "nj"
543
- }, {
544
- base: "o",
545
- letters: "oⓞoòóôồốỗổõṍȭṏōṑṓŏȯȱöȫỏőǒȍȏơờớỡởợọộǫǭøǿɔꝋꝍɵ"
546
- }, {
547
- base: "oi",
548
- letters: "ƣ"
549
- }, {
550
- base: "ou",
551
- letters: "ȣ"
552
- }, {
553
- base: "oo",
554
- letters: "ꝏ"
555
- }, {
556
- base: "p",
557
- letters: "pⓟpṕṗƥᵽꝑꝓꝕ"
558
- }, {
559
- base: "q",
560
- letters: "qⓠqɋꝗꝙ"
561
- }, {
562
- base: "r",
563
- letters: "rⓡrŕṙřȑȓṛṝŗṟɍɽꝛꞧꞃ"
564
- }, {
565
- base: "s",
566
- letters: "sⓢsßśṥŝṡšṧṣṩșşȿꞩꞅẛ"
567
- }, {
568
- base: "t",
569
- letters: "tⓣtṫẗťṭțţṱṯŧƭʈⱦꞇ"
570
- }, {
571
- base: "tz",
572
- letters: "ꜩ"
573
- }, {
574
- base: "u",
575
- letters: "uⓤuùúûũṹūṻŭüǜǘǖǚủůűǔȕȗưừứữửựụṳųṷṵʉ"
576
- }, {
577
- base: "v",
578
- letters: "vⓥvṽṿʋꝟʌ"
579
- }, {
580
- base: "vy",
581
- letters: "ꝡ"
582
- }, {
583
- base: "w",
584
- letters: "wⓦwẁẃŵẇẅẘẉⱳ"
585
- }, {
586
- base: "x",
587
- letters: "xⓧxẋẍ"
588
- }, {
589
- base: "y",
590
- letters: "yⓨyỳýŷỹȳẏÿỷẙỵƴɏỿ"
591
- }, {
592
- base: "z",
593
- letters: "zⓩzźẑżžẓẕƶȥɀⱬꝣ"
594
- }];
595
- var anyDiacritic = new RegExp("[" + diacritics.map(function(d) {
596
- return d.letters;
597
- }).join("") + "]", "g");
598
- var diacriticToBase = {};
599
- for (var i = 0; i < diacritics.length; i++) {
600
- var diacritic = diacritics[i];
601
- for (var j = 0; j < diacritic.letters.length; j++) {
602
- diacriticToBase[diacritic.letters[j]] = diacritic.base;
603
- }
604
- }
605
- var stripDiacritics = function stripDiacritics2(str) {
606
- return str.replace(anyDiacritic, function(match) {
607
- return diacriticToBase[match];
608
- });
609
- };
610
- var memoizedStripDiacriticsForInput = memoizeOne(stripDiacritics);
611
- var trimString = function trimString2(str) {
612
- return str.replace(/^\s+|\s+$/g, "");
613
- };
614
- var defaultStringify = function defaultStringify2(option) {
615
- return "".concat(option.label, " ").concat(option.value);
616
- };
617
- var createFilter = function createFilter2(config) {
618
- return function(option, rawInput) {
619
- if (option.data.__isNew__) return true;
620
- var _ignoreCase$ignoreAcc = _objectSpread2({
621
- ignoreCase: true,
622
- ignoreAccents: true,
623
- stringify: defaultStringify,
624
- trim: true,
625
- matchFrom: "any"
626
- }, config), ignoreCase = _ignoreCase$ignoreAcc.ignoreCase, ignoreAccents = _ignoreCase$ignoreAcc.ignoreAccents, stringify = _ignoreCase$ignoreAcc.stringify, trim = _ignoreCase$ignoreAcc.trim, matchFrom = _ignoreCase$ignoreAcc.matchFrom;
627
- var input = trim ? trimString(rawInput) : rawInput;
628
- var candidate = trim ? trimString(stringify(option)) : stringify(option);
629
- if (ignoreCase) {
630
- input = input.toLowerCase();
631
- candidate = candidate.toLowerCase();
632
- }
633
- if (ignoreAccents) {
634
- input = memoizedStripDiacriticsForInput(input);
635
- candidate = stripDiacritics(candidate);
636
- }
637
- return matchFrom === "start" ? candidate.substr(0, input.length) === input : candidate.indexOf(input) > -1;
638
- };
639
- };
640
- var _excluded = ["innerRef"];
641
- function DummyInput(_ref3) {
642
- var innerRef = _ref3.innerRef, props = _objectWithoutProperties(_ref3, _excluded);
643
- var filteredProps = removeProps(props, "onExited", "in", "enter", "exit", "appear");
644
- return jsx("input", _extends({
645
- ref: innerRef
646
- }, filteredProps, {
647
- css: /* @__PURE__ */ css$2({
648
- label: "dummyInput",
649
- // get rid of any default styles
650
- background: 0,
651
- border: 0,
652
- // important! this hides the flashing cursor
653
- caretColor: "transparent",
654
- fontSize: "inherit",
655
- gridArea: "1 / 1 / 2 / 3",
656
- outline: 0,
657
- padding: 0,
658
- // important! without `width` browsers won't allow focus
659
- width: 1,
660
- // remove cursor on desktop
661
- color: "transparent",
662
- // remove cursor on mobile whilst maintaining "scroll into view" behaviour
663
- left: -100,
664
- opacity: 0,
665
- position: "relative",
666
- transform: "scale(.01)"
667
- }, process.env.NODE_ENV === "production" ? "" : ";label:DummyInput;", process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkR1bW15SW5wdXQudHN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQXlCTSIsImZpbGUiOiJEdW1teUlucHV0LnRzeCIsInNvdXJjZXNDb250ZW50IjpbIi8qKiBAanN4IGpzeCAqL1xuaW1wb3J0IHsgSlNYLCBSZWYgfSBmcm9tICdyZWFjdCc7XG5pbXBvcnQgeyBqc3ggfSBmcm9tICdAZW1vdGlvbi9yZWFjdCc7XG5pbXBvcnQgeyByZW1vdmVQcm9wcyB9IGZyb20gJy4uL3V0aWxzJztcblxuZXhwb3J0IGRlZmF1bHQgZnVuY3Rpb24gRHVtbXlJbnB1dCh7XG4gIGlubmVyUmVmLFxuICAuLi5wcm9wc1xufTogSlNYLkludHJpbnNpY0VsZW1lbnRzWydpbnB1dCddICYge1xuICByZWFkb25seSBpbm5lclJlZjogUmVmPEhUTUxJbnB1dEVsZW1lbnQ+O1xufSkge1xuICAvLyBSZW1vdmUgYW5pbWF0aW9uIHByb3BzIG5vdCBtZWFudCBmb3IgSFRNTCBlbGVtZW50c1xuICBjb25zdCBmaWx0ZXJlZFByb3BzID0gcmVtb3ZlUHJvcHMoXG4gICAgcHJvcHMsXG4gICAgJ29uRXhpdGVkJyxcbiAgICAnaW4nLFxuICAgICdlbnRlcicsXG4gICAgJ2V4aXQnLFxuICAgICdhcHBlYXInXG4gICk7XG5cbiAgcmV0dXJuIChcbiAgICA8aW5wdXRcbiAgICAgIHJlZj17aW5uZXJSZWZ9XG4gICAgICB7Li4uZmlsdGVyZWRQcm9wc31cbiAgICAgIGNzcz17e1xuICAgICAgICBsYWJlbDogJ2R1bW15SW5wdXQnLFxuICAgICAgICAvLyBnZXQgcmlkIG9mIGFueSBkZWZhdWx0IHN0eWxlc1xuICAgICAgICBiYWNrZ3JvdW5kOiAwLFxuICAgICAgICBib3JkZXI6IDAsXG4gICAgICAgIC8vIGltcG9ydGFudCEgdGhpcyBoaWRlcyB0aGUgZmxhc2hpbmcgY3Vyc29yXG4gICAgICAgIGNhcmV0Q29sb3I6ICd0cmFuc3BhcmVudCcsXG4gICAgICAgIGZvbnRTaXplOiAnaW5oZXJpdCcsXG4gICAgICAgIGdyaWRBcmVhOiAnMSAvIDEgLyAyIC8gMycsXG4gICAgICAgIG91dGxpbmU6IDAsXG4gICAgICAgIHBhZGRpbmc6IDAsXG4gICAgICAgIC8vIGltcG9ydGFudCEgd2l0aG91dCBgd2lkdGhgIGJyb3dzZXJzIHdvbid0IGFsbG93IGZvY3VzXG4gICAgICAgIHdpZHRoOiAxLFxuXG4gICAgICAgIC8vIHJlbW92ZSBjdXJzb3Igb24gZGVza3RvcFxuICAgICAgICBjb2xvcjogJ3RyYW5zcGFyZW50JyxcblxuICAgICAgICAvLyByZW1vdmUgY3Vyc29yIG9uIG1vYmlsZSB3aGlsc3QgbWFpbnRhaW5pbmcgXCJzY3JvbGwgaW50byB2aWV3XCIgYmVoYXZpb3VyXG4gICAgICAgIGxlZnQ6IC0xMDAsXG4gICAgICAgIG9wYWNpdHk6IDAsXG4gICAgICAgIHBvc2l0aW9uOiAncmVsYXRpdmUnLFxuICAgICAgICB0cmFuc2Zvcm06ICdzY2FsZSguMDEpJyxcbiAgICAgIH19XG4gICAgLz5cbiAgKTtcbn1cbiJdfQ== */")
668
- }));
669
- }
670
- var cancelScroll = function cancelScroll2(event) {
671
- if (event.cancelable) event.preventDefault();
672
- event.stopPropagation();
673
- };
674
- function useScrollCapture(_ref3) {
675
- var isEnabled = _ref3.isEnabled, onBottomArrive = _ref3.onBottomArrive, onBottomLeave = _ref3.onBottomLeave, onTopArrive = _ref3.onTopArrive, onTopLeave = _ref3.onTopLeave;
676
- var isBottom = useRef(false);
677
- var isTop = useRef(false);
678
- var touchStart = useRef(0);
679
- var scrollTarget = useRef(null);
680
- var handleEventDelta = useCallback(function(event, delta) {
681
- if (scrollTarget.current === null) return;
682
- var _scrollTarget$current = scrollTarget.current, scrollTop = _scrollTarget$current.scrollTop, scrollHeight = _scrollTarget$current.scrollHeight, clientHeight = _scrollTarget$current.clientHeight;
683
- var target = scrollTarget.current;
684
- var isDeltaPositive = delta > 0;
685
- var availableScroll = scrollHeight - clientHeight - scrollTop;
686
- var shouldCancelScroll = false;
687
- if (availableScroll > delta && isBottom.current) {
688
- if (onBottomLeave) onBottomLeave(event);
689
- isBottom.current = false;
690
- }
691
- if (isDeltaPositive && isTop.current) {
692
- if (onTopLeave) onTopLeave(event);
693
- isTop.current = false;
694
- }
695
- if (isDeltaPositive && delta > availableScroll) {
696
- if (onBottomArrive && !isBottom.current) {
697
- onBottomArrive(event);
698
- }
699
- target.scrollTop = scrollHeight;
700
- shouldCancelScroll = true;
701
- isBottom.current = true;
702
- } else if (!isDeltaPositive && -delta > scrollTop) {
703
- if (onTopArrive && !isTop.current) {
704
- onTopArrive(event);
705
- }
706
- target.scrollTop = 0;
707
- shouldCancelScroll = true;
708
- isTop.current = true;
709
- }
710
- if (shouldCancelScroll) {
711
- cancelScroll(event);
712
- }
713
- }, [onBottomArrive, onBottomLeave, onTopArrive, onTopLeave]);
714
- var onWheel = useCallback(function(event) {
715
- handleEventDelta(event, event.deltaY);
716
- }, [handleEventDelta]);
717
- var onTouchStart = useCallback(function(event) {
718
- touchStart.current = event.changedTouches[0].clientY;
719
- }, []);
720
- var onTouchMove = useCallback(function(event) {
721
- var deltaY = touchStart.current - event.changedTouches[0].clientY;
722
- handleEventDelta(event, deltaY);
723
- }, [handleEventDelta]);
724
- var startListening = useCallback(function(el) {
725
- if (!el) return;
726
- var notPassive = supportsPassiveEvents ? {
727
- passive: false
728
- } : false;
729
- el.addEventListener("wheel", onWheel, notPassive);
730
- el.addEventListener("touchstart", onTouchStart, notPassive);
731
- el.addEventListener("touchmove", onTouchMove, notPassive);
732
- }, [onTouchMove, onTouchStart, onWheel]);
733
- var stopListening = useCallback(function(el) {
734
- if (!el) return;
735
- el.removeEventListener("wheel", onWheel, false);
736
- el.removeEventListener("touchstart", onTouchStart, false);
737
- el.removeEventListener("touchmove", onTouchMove, false);
738
- }, [onTouchMove, onTouchStart, onWheel]);
739
- useEffect(function() {
740
- if (!isEnabled) return;
741
- var element = scrollTarget.current;
742
- startListening(element);
743
- return function() {
744
- stopListening(element);
745
- };
746
- }, [isEnabled, startListening, stopListening]);
747
- return function(element) {
748
- scrollTarget.current = element;
749
- };
750
- }
751
- var STYLE_KEYS = ["boxSizing", "height", "overflow", "paddingRight", "position"];
752
- var LOCK_STYLES = {
753
- boxSizing: "border-box",
754
- // account for possible declaration `width: 100%;` on body
755
- overflow: "hidden",
756
- position: "relative",
757
- height: "100%"
758
- };
759
- function preventTouchMove(e) {
760
- if (e.cancelable) e.preventDefault();
761
- }
762
- function allowTouchMove(e) {
763
- e.stopPropagation();
764
- }
765
- function preventInertiaScroll() {
766
- var top = this.scrollTop;
767
- var totalScroll = this.scrollHeight;
768
- var currentScroll = top + this.offsetHeight;
769
- if (top === 0) {
770
- this.scrollTop = 1;
771
- } else if (currentScroll === totalScroll) {
772
- this.scrollTop = top - 1;
773
- }
774
- }
775
- function isTouchDevice() {
776
- return "ontouchstart" in window || navigator.maxTouchPoints;
777
- }
778
- var canUseDOM = !!(typeof window !== "undefined" && window.document && window.document.createElement);
779
- var activeScrollLocks = 0;
780
- var listenerOptions = {
781
- capture: false,
782
- passive: false
783
- };
784
- function useScrollLock(_ref3) {
785
- var isEnabled = _ref3.isEnabled, _ref$accountForScroll = _ref3.accountForScrollbars, accountForScrollbars = _ref$accountForScroll === void 0 ? true : _ref$accountForScroll;
786
- var originalStyles = useRef({});
787
- var scrollTarget = useRef(null);
788
- var addScrollLock = useCallback(function(touchScrollTarget) {
789
- if (!canUseDOM) return;
790
- var target = document.body;
791
- var targetStyle = target && target.style;
792
- if (accountForScrollbars) {
793
- STYLE_KEYS.forEach(function(key) {
794
- var val = targetStyle && targetStyle[key];
795
- originalStyles.current[key] = val;
796
- });
797
- }
798
- if (accountForScrollbars && activeScrollLocks < 1) {
799
- var currentPadding = parseInt(originalStyles.current.paddingRight, 10) || 0;
800
- var clientWidth = document.body ? document.body.clientWidth : 0;
801
- var adjustedPadding = window.innerWidth - clientWidth + currentPadding || 0;
802
- Object.keys(LOCK_STYLES).forEach(function(key) {
803
- var val = LOCK_STYLES[key];
804
- if (targetStyle) {
805
- targetStyle[key] = val;
806
- }
807
- });
808
- if (targetStyle) {
809
- targetStyle.paddingRight = "".concat(adjustedPadding, "px");
810
- }
811
- }
812
- if (target && isTouchDevice()) {
813
- target.addEventListener("touchmove", preventTouchMove, listenerOptions);
814
- if (touchScrollTarget) {
815
- touchScrollTarget.addEventListener("touchstart", preventInertiaScroll, listenerOptions);
816
- touchScrollTarget.addEventListener("touchmove", allowTouchMove, listenerOptions);
817
- }
818
- }
819
- activeScrollLocks += 1;
820
- }, [accountForScrollbars]);
821
- var removeScrollLock = useCallback(function(touchScrollTarget) {
822
- if (!canUseDOM) return;
823
- var target = document.body;
824
- var targetStyle = target && target.style;
825
- activeScrollLocks = Math.max(activeScrollLocks - 1, 0);
826
- if (accountForScrollbars && activeScrollLocks < 1) {
827
- STYLE_KEYS.forEach(function(key) {
828
- var val = originalStyles.current[key];
829
- if (targetStyle) {
830
- targetStyle[key] = val;
831
- }
832
- });
833
- }
834
- if (target && isTouchDevice()) {
835
- target.removeEventListener("touchmove", preventTouchMove, listenerOptions);
836
- if (touchScrollTarget) {
837
- touchScrollTarget.removeEventListener("touchstart", preventInertiaScroll, listenerOptions);
838
- touchScrollTarget.removeEventListener("touchmove", allowTouchMove, listenerOptions);
839
- }
840
- }
841
- }, [accountForScrollbars]);
842
- useEffect(function() {
843
- if (!isEnabled) return;
844
- var element = scrollTarget.current;
845
- addScrollLock(element);
846
- return function() {
847
- removeScrollLock(element);
848
- };
849
- }, [isEnabled, addScrollLock, removeScrollLock]);
850
- return function(element) {
851
- scrollTarget.current = element;
852
- };
853
- }
854
- function _EMOTION_STRINGIFIED_CSS_ERROR__$1() {
855
- return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop).";
856
- }
857
- var blurSelectInput = function blurSelectInput2(event) {
858
- var element = event.target;
859
- return element.ownerDocument.activeElement && element.ownerDocument.activeElement.blur();
860
- };
861
- var _ref2$1 = process.env.NODE_ENV === "production" ? {
862
- name: "1kfdb0e",
863
- styles: "position:fixed;left:0;bottom:0;right:0;top:0"
864
- } : {
865
- name: "bp8cua-ScrollManager",
866
- styles: "position:fixed;left:0;bottom:0;right:0;top:0;label:ScrollManager;",
867
- map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIlNjcm9sbE1hbmFnZXIudHN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQW9EVSIsImZpbGUiOiJTY3JvbGxNYW5hZ2VyLnRzeCIsInNvdXJjZXNDb250ZW50IjpbIi8qKiBAanN4IGpzeCAqL1xuaW1wb3J0IHsganN4IH0gZnJvbSAnQGVtb3Rpb24vcmVhY3QnO1xuaW1wb3J0IHsgRnJhZ21lbnQsIFJlYWN0RWxlbWVudCwgUmVmQ2FsbGJhY2ssIE1vdXNlRXZlbnQgfSBmcm9tICdyZWFjdCc7XG5pbXBvcnQgdXNlU2Nyb2xsQ2FwdHVyZSBmcm9tICcuL3VzZVNjcm9sbENhcHR1cmUnO1xuaW1wb3J0IHVzZVNjcm9sbExvY2sgZnJvbSAnLi91c2VTY3JvbGxMb2NrJztcblxuaW50ZXJmYWNlIFByb3BzIHtcbiAgcmVhZG9ubHkgY2hpbGRyZW46IChyZWY6IFJlZkNhbGxiYWNrPEhUTUxFbGVtZW50PikgPT4gUmVhY3RFbGVtZW50O1xuICByZWFkb25seSBsb2NrRW5hYmxlZDogYm9vbGVhbjtcbiAgcmVhZG9ubHkgY2FwdHVyZUVuYWJsZWQ6IGJvb2xlYW47XG4gIHJlYWRvbmx5IG9uQm90dG9tQXJyaXZlPzogKGV2ZW50OiBXaGVlbEV2ZW50IHwgVG91Y2hFdmVudCkgPT4gdm9pZDtcbiAgcmVhZG9ubHkgb25Cb3R0b21MZWF2ZT86IChldmVudDogV2hlZWxFdmVudCB8IFRvdWNoRXZlbnQpID0+IHZvaWQ7XG4gIHJlYWRvbmx5IG9uVG9wQXJyaXZlPzogKGV2ZW50OiBXaGVlbEV2ZW50IHwgVG91Y2hFdmVudCkgPT4gdm9pZDtcbiAgcmVhZG9ubHkgb25Ub3BMZWF2ZT86IChldmVudDogV2hlZWxFdmVudCB8IFRvdWNoRXZlbnQpID0+IHZvaWQ7XG59XG5cbmNvbnN0IGJsdXJTZWxlY3RJbnB1dCA9IChldmVudDogTW91c2VFdmVudDxIVE1MRGl2RWxlbWVudD4pID0+IHtcbiAgY29uc3QgZWxlbWVudCA9IGV2ZW50LnRhcmdldCBhcyBIVE1MRGl2RWxlbWVudDtcbiAgcmV0dXJuIChcbiAgICBlbGVtZW50Lm93bmVyRG9jdW1lbnQuYWN0aXZlRWxlbWVudCAmJlxuICAgIChlbGVtZW50Lm93bmVyRG9jdW1lbnQuYWN0aXZlRWxlbWVudCBhcyBIVE1MRWxlbWVudCkuYmx1cigpXG4gICk7XG59O1xuXG5leHBvcnQgZGVmYXVsdCBmdW5jdGlvbiBTY3JvbGxNYW5hZ2VyKHtcbiAgY2hpbGRyZW4sXG4gIGxvY2tFbmFibGVkLFxuICBjYXB0dXJlRW5hYmxlZCA9IHRydWUsXG4gIG9uQm90dG9tQXJyaXZlLFxuICBvbkJvdHRvbUxlYXZlLFxuICBvblRvcEFycml2ZSxcbiAgb25Ub3BMZWF2ZSxcbn06IFByb3BzKSB7XG4gIGNvbnN0IHNldFNjcm9sbENhcHR1cmVUYXJnZXQgPSB1c2VTY3JvbGxDYXB0dXJlKHtcbiAgICBpc0VuYWJsZWQ6IGNhcHR1cmVFbmFibGVkLFxuICAgIG9uQm90dG9tQXJyaXZlLFxuICAgIG9uQm90dG9tTGVhdmUsXG4gICAgb25Ub3BBcnJpdmUsXG4gICAgb25Ub3BMZWF2ZSxcbiAgfSk7XG4gIGNvbnN0IHNldFNjcm9sbExvY2tUYXJnZXQgPSB1c2VTY3JvbGxMb2NrKHsgaXNFbmFibGVkOiBsb2NrRW5hYmxlZCB9KTtcblxuICBjb25zdCB0YXJnZXRSZWY6IFJlZkNhbGxiYWNrPEhUTUxFbGVtZW50PiA9IChlbGVtZW50KSA9PiB7XG4gICAgc2V0U2Nyb2xsQ2FwdHVyZVRhcmdldChlbGVtZW50KTtcbiAgICBzZXRTY3JvbGxMb2NrVGFyZ2V0KGVsZW1lbnQpO1xuICB9O1xuXG4gIHJldHVybiAoXG4gICAgPEZyYWdtZW50PlxuICAgICAge2xvY2tFbmFibGVkICYmIChcbiAgICAgICAgPGRpdlxuICAgICAgICAgIG9uQ2xpY2s9e2JsdXJTZWxlY3RJbnB1dH1cbiAgICAgICAgICBjc3M9e3sgcG9zaXRpb246ICdmaXhlZCcsIGxlZnQ6IDAsIGJvdHRvbTogMCwgcmlnaHQ6IDAsIHRvcDogMCB9fVxuICAgICAgICAvPlxuICAgICAgKX1cbiAgICAgIHtjaGlsZHJlbih0YXJnZXRSZWYpfVxuICAgIDwvRnJhZ21lbnQ+XG4gICk7XG59XG4iXX0= */",
868
- toString: _EMOTION_STRINGIFIED_CSS_ERROR__$1
869
- };
870
- function ScrollManager(_ref3) {
871
- var children = _ref3.children, lockEnabled = _ref3.lockEnabled, _ref$captureEnabled = _ref3.captureEnabled, captureEnabled = _ref$captureEnabled === void 0 ? true : _ref$captureEnabled, onBottomArrive = _ref3.onBottomArrive, onBottomLeave = _ref3.onBottomLeave, onTopArrive = _ref3.onTopArrive, onTopLeave = _ref3.onTopLeave;
872
- var setScrollCaptureTarget = useScrollCapture({
873
- isEnabled: captureEnabled,
874
- onBottomArrive,
875
- onBottomLeave,
876
- onTopArrive,
877
- onTopLeave
878
- });
879
- var setScrollLockTarget = useScrollLock({
880
- isEnabled: lockEnabled
881
- });
882
- var targetRef = function targetRef2(element) {
883
- setScrollCaptureTarget(element);
884
- setScrollLockTarget(element);
885
- };
886
- return jsx(Fragment, null, lockEnabled && jsx("div", {
887
- onClick: blurSelectInput,
888
- css: _ref2$1
889
- }), children(targetRef));
890
- }
891
- function _EMOTION_STRINGIFIED_CSS_ERROR__() {
892
- return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop).";
893
- }
894
- var _ref2 = process.env.NODE_ENV === "production" ? {
895
- name: "1a0ro4n-requiredInput",
896
- styles: "label:requiredInput;opacity:0;pointer-events:none;position:absolute;bottom:0;left:0;right:0;width:100%"
897
- } : {
898
- name: "5kkxb2-requiredInput-RequiredInput",
899
- styles: "label:requiredInput;opacity:0;pointer-events:none;position:absolute;bottom:0;left:0;right:0;width:100%;label:RequiredInput;",
900
- map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIlJlcXVpcmVkSW5wdXQudHN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQWNJIiwiZmlsZSI6IlJlcXVpcmVkSW5wdXQudHN4Iiwic291cmNlc0NvbnRlbnQiOlsiLyoqIEBqc3gganN4ICovXG5pbXBvcnQgeyBGb2N1c0V2ZW50SGFuZGxlciwgRnVuY3Rpb25Db21wb25lbnQgfSBmcm9tICdyZWFjdCc7XG5pbXBvcnQgeyBqc3ggfSBmcm9tICdAZW1vdGlvbi9yZWFjdCc7XG5cbmNvbnN0IFJlcXVpcmVkSW5wdXQ6IEZ1bmN0aW9uQ29tcG9uZW50PHtcbiAgcmVhZG9ubHkgbmFtZT86IHN0cmluZztcbiAgcmVhZG9ubHkgb25Gb2N1czogRm9jdXNFdmVudEhhbmRsZXI8SFRNTElucHV0RWxlbWVudD47XG59PiA9ICh7IG5hbWUsIG9uRm9jdXMgfSkgPT4gKFxuICA8aW5wdXRcbiAgICByZXF1aXJlZFxuICAgIG5hbWU9e25hbWV9XG4gICAgdGFiSW5kZXg9ey0xfVxuICAgIGFyaWEtaGlkZGVuPVwidHJ1ZVwiXG4gICAgb25Gb2N1cz17b25Gb2N1c31cbiAgICBjc3M9e3tcbiAgICAgIGxhYmVsOiAncmVxdWlyZWRJbnB1dCcsXG4gICAgICBvcGFjaXR5OiAwLFxuICAgICAgcG9pbnRlckV2ZW50czogJ25vbmUnLFxuICAgICAgcG9zaXRpb246ICdhYnNvbHV0ZScsXG4gICAgICBib3R0b206IDAsXG4gICAgICBsZWZ0OiAwLFxuICAgICAgcmlnaHQ6IDAsXG4gICAgICB3aWR0aDogJzEwMCUnLFxuICAgIH19XG4gICAgLy8gUHJldmVudCBgU3dpdGNoaW5nIGZyb20gdW5jb250cm9sbGVkIHRvIGNvbnRyb2xsZWRgIGVycm9yXG4gICAgdmFsdWU9XCJcIlxuICAgIG9uQ2hhbmdlPXsoKSA9PiB7fX1cbiAgLz5cbik7XG5cbmV4cG9ydCBkZWZhdWx0IFJlcXVpcmVkSW5wdXQ7XG4iXX0= */",
901
- toString: _EMOTION_STRINGIFIED_CSS_ERROR__
902
- };
903
- var RequiredInput = function RequiredInput2(_ref3) {
904
- var name = _ref3.name, onFocus2 = _ref3.onFocus;
905
- return jsx("input", {
906
- required: true,
907
- name,
908
- tabIndex: -1,
909
- "aria-hidden": "true",
910
- onFocus: onFocus2,
911
- css: _ref2,
912
- value: "",
913
- onChange: function onChange2() {
914
- }
915
- });
916
- };
917
- var RequiredInput$1 = RequiredInput;
918
- function testPlatform(re) {
919
- var _window$navigator$use;
920
- return typeof window !== "undefined" && window.navigator != null ? re.test(((_window$navigator$use = window.navigator["userAgentData"]) === null || _window$navigator$use === void 0 ? void 0 : _window$navigator$use.platform) || window.navigator.platform) : false;
921
- }
922
- function isIPhone() {
923
- return testPlatform(/^iPhone/i);
924
- }
925
- function isMac() {
926
- return testPlatform(/^Mac/i);
927
- }
928
- function isIPad() {
929
- return testPlatform(/^iPad/i) || // iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.
930
- isMac() && navigator.maxTouchPoints > 1;
931
- }
932
- function isIOS() {
933
- return isIPhone() || isIPad();
934
- }
935
- function isAppleDevice() {
936
- return isMac() || isIOS();
937
- }
938
- var formatGroupLabel = function formatGroupLabel2(group) {
939
- return group.label;
940
- };
941
- var getOptionLabel$1 = function getOptionLabel(option) {
942
- return option.label;
943
- };
944
- var getOptionValue$1 = function getOptionValue(option) {
945
- return option.value;
946
- };
947
- var isOptionDisabled = function isOptionDisabled2(option) {
948
- return !!option.isDisabled;
949
- };
950
- var defaultStyles = {
951
- clearIndicator: clearIndicatorCSS,
952
- container: containerCSS,
953
- control: css$1,
954
- dropdownIndicator: dropdownIndicatorCSS,
955
- group: groupCSS,
956
- groupHeading: groupHeadingCSS,
957
- indicatorsContainer: indicatorsContainerCSS,
958
- indicatorSeparator: indicatorSeparatorCSS,
959
- input: inputCSS,
960
- loadingIndicator: loadingIndicatorCSS,
961
- loadingMessage: loadingMessageCSS,
962
- menu: menuCSS,
963
- menuList: menuListCSS,
964
- menuPortal: menuPortalCSS,
965
- multiValue: multiValueCSS,
966
- multiValueLabel: multiValueLabelCSS,
967
- multiValueRemove: multiValueRemoveCSS,
968
- noOptionsMessage: noOptionsMessageCSS,
969
- option: optionCSS,
970
- placeholder: placeholderCSS,
971
- singleValue: css,
972
- valueContainer: valueContainerCSS
973
- };
974
- var colors = {
975
- primary: "#2684FF",
976
- primary75: "#4C9AFF",
977
- primary50: "#B2D4FF",
978
- primary25: "#DEEBFF",
979
- danger: "#DE350B",
980
- dangerLight: "#FFBDAD",
981
- neutral0: "hsl(0, 0%, 100%)",
982
- neutral5: "hsl(0, 0%, 95%)",
983
- neutral10: "hsl(0, 0%, 90%)",
984
- neutral20: "hsl(0, 0%, 80%)",
985
- neutral30: "hsl(0, 0%, 70%)",
986
- neutral40: "hsl(0, 0%, 60%)",
987
- neutral50: "hsl(0, 0%, 50%)",
988
- neutral60: "hsl(0, 0%, 40%)",
989
- neutral70: "hsl(0, 0%, 30%)",
990
- neutral80: "hsl(0, 0%, 20%)",
991
- neutral90: "hsl(0, 0%, 10%)"
992
- };
993
- var borderRadius = 4;
994
- var baseUnit = 4;
995
- var controlHeight = 38;
996
- var menuGutter = baseUnit * 2;
997
- var spacing = {
998
- baseUnit,
999
- controlHeight,
1000
- menuGutter
1001
- };
1002
- var defaultTheme = {
1003
- borderRadius,
1004
- colors,
1005
- spacing
1006
- };
1007
- var defaultProps = {
1008
- "aria-live": "polite",
1009
- backspaceRemovesValue: true,
1010
- blurInputOnSelect: isTouchCapable(),
1011
- captureMenuScroll: !isTouchCapable(),
1012
- classNames: {},
1013
- closeMenuOnSelect: true,
1014
- closeMenuOnScroll: false,
1015
- components: {},
1016
- controlShouldRenderValue: true,
1017
- escapeClearsValue: false,
1018
- filterOption: createFilter(),
1019
- formatGroupLabel,
1020
- getOptionLabel: getOptionLabel$1,
1021
- getOptionValue: getOptionValue$1,
1022
- isDisabled: false,
1023
- isLoading: false,
1024
- isMulti: false,
1025
- isRtl: false,
1026
- isSearchable: true,
1027
- isOptionDisabled,
1028
- loadingMessage: function loadingMessage() {
1029
- return "Loading...";
1030
- },
1031
- maxMenuHeight: 300,
1032
- minMenuHeight: 140,
1033
- menuIsOpen: false,
1034
- menuPlacement: "bottom",
1035
- menuPosition: "absolute",
1036
- menuShouldBlockScroll: false,
1037
- menuShouldScrollIntoView: !isMobileDevice(),
1038
- noOptionsMessage: function noOptionsMessage() {
1039
- return "No options";
1040
- },
1041
- openMenuOnFocus: false,
1042
- openMenuOnClick: true,
1043
- options: [],
1044
- pageSize: 5,
1045
- placeholder: "Select...",
1046
- screenReaderStatus: function screenReaderStatus(_ref3) {
1047
- var count = _ref3.count;
1048
- return "".concat(count, " result").concat(count !== 1 ? "s" : "", " available");
1049
- },
1050
- styles: {},
1051
- tabIndex: 0,
1052
- tabSelectsValue: true,
1053
- unstyled: false
1054
- };
1055
- function toCategorizedOption(props, option, selectValue, index) {
1056
- var isDisabled = _isOptionDisabled(props, option, selectValue);
1057
- var isSelected = _isOptionSelected(props, option, selectValue);
1058
- var label = getOptionLabel2(props, option);
1059
- var value = getOptionValue2(props, option);
1060
- return {
1061
- type: "option",
1062
- data: option,
1063
- isDisabled,
1064
- isSelected,
1065
- label,
1066
- value,
1067
- index
1068
- };
1069
- }
1070
- function buildCategorizedOptions(props, selectValue) {
1071
- return props.options.map(function(groupOrOption, groupOrOptionIndex) {
1072
- if ("options" in groupOrOption) {
1073
- var categorizedOptions = groupOrOption.options.map(function(option, optionIndex) {
1074
- return toCategorizedOption(props, option, selectValue, optionIndex);
1075
- }).filter(function(categorizedOption2) {
1076
- return isFocusable(props, categorizedOption2);
1077
- });
1078
- return categorizedOptions.length > 0 ? {
1079
- type: "group",
1080
- data: groupOrOption,
1081
- options: categorizedOptions,
1082
- index: groupOrOptionIndex
1083
- } : void 0;
1084
- }
1085
- var categorizedOption = toCategorizedOption(props, groupOrOption, selectValue, groupOrOptionIndex);
1086
- return isFocusable(props, categorizedOption) ? categorizedOption : void 0;
1087
- }).filter(notNullish);
1088
- }
1089
- function buildFocusableOptionsFromCategorizedOptions(categorizedOptions) {
1090
- return categorizedOptions.reduce(function(optionsAccumulator, categorizedOption) {
1091
- if (categorizedOption.type === "group") {
1092
- optionsAccumulator.push.apply(optionsAccumulator, _toConsumableArray(categorizedOption.options.map(function(option) {
1093
- return option.data;
1094
- })));
1095
- } else {
1096
- optionsAccumulator.push(categorizedOption.data);
1097
- }
1098
- return optionsAccumulator;
1099
- }, []);
1100
- }
1101
- function buildFocusableOptionsWithIds(categorizedOptions, optionId) {
1102
- return categorizedOptions.reduce(function(optionsAccumulator, categorizedOption) {
1103
- if (categorizedOption.type === "group") {
1104
- optionsAccumulator.push.apply(optionsAccumulator, _toConsumableArray(categorizedOption.options.map(function(option) {
1105
- return {
1106
- data: option.data,
1107
- id: "".concat(optionId, "-").concat(categorizedOption.index, "-").concat(option.index)
1108
- };
1109
- })));
1110
- } else {
1111
- optionsAccumulator.push({
1112
- data: categorizedOption.data,
1113
- id: "".concat(optionId, "-").concat(categorizedOption.index)
1114
- });
1115
- }
1116
- return optionsAccumulator;
1117
- }, []);
1118
- }
1119
- function buildFocusableOptions(props, selectValue) {
1120
- return buildFocusableOptionsFromCategorizedOptions(buildCategorizedOptions(props, selectValue));
1121
- }
1122
- function isFocusable(props, categorizedOption) {
1123
- var _props$inputValue = props.inputValue, inputValue = _props$inputValue === void 0 ? "" : _props$inputValue;
1124
- var data = categorizedOption.data, isSelected = categorizedOption.isSelected, label = categorizedOption.label, value = categorizedOption.value;
1125
- return (!shouldHideSelectedOptions(props) || !isSelected) && _filterOption(props, {
1126
- label,
1127
- value,
1128
- data
1129
- }, inputValue);
1130
- }
1131
- function getNextFocusedValue(state, nextSelectValue) {
1132
- var focusedValue = state.focusedValue, lastSelectValue = state.selectValue;
1133
- var lastFocusedIndex = lastSelectValue.indexOf(focusedValue);
1134
- if (lastFocusedIndex > -1) {
1135
- var nextFocusedIndex = nextSelectValue.indexOf(focusedValue);
1136
- if (nextFocusedIndex > -1) {
1137
- return focusedValue;
1138
- } else if (lastFocusedIndex < nextSelectValue.length) {
1139
- return nextSelectValue[lastFocusedIndex];
1140
- }
1141
- }
1142
- return null;
1143
- }
1144
- function getNextFocusedOption(state, options) {
1145
- var lastFocusedOption = state.focusedOption;
1146
- return lastFocusedOption && options.indexOf(lastFocusedOption) > -1 ? lastFocusedOption : options[0];
1147
- }
1148
- var getFocusedOptionId = function getFocusedOptionId2(focusableOptionsWithIds, focusedOption) {
1149
- var _focusableOptionsWith;
1150
- var focusedOptionId = (_focusableOptionsWith = focusableOptionsWithIds.find(function(option) {
1151
- return option.data === focusedOption;
1152
- })) === null || _focusableOptionsWith === void 0 ? void 0 : _focusableOptionsWith.id;
1153
- return focusedOptionId || null;
1154
- };
1155
- var getOptionLabel2 = function getOptionLabel3(props, data) {
1156
- return props.getOptionLabel(data);
1157
- };
1158
- var getOptionValue2 = function getOptionValue3(props, data) {
1159
- return props.getOptionValue(data);
1160
- };
1161
- function _isOptionDisabled(props, option, selectValue) {
1162
- return typeof props.isOptionDisabled === "function" ? props.isOptionDisabled(option, selectValue) : false;
1163
- }
1164
- function _isOptionSelected(props, option, selectValue) {
1165
- if (selectValue.indexOf(option) > -1) return true;
1166
- if (typeof props.isOptionSelected === "function") {
1167
- return props.isOptionSelected(option, selectValue);
1168
- }
1169
- var candidate = getOptionValue2(props, option);
1170
- return selectValue.some(function(i) {
1171
- return getOptionValue2(props, i) === candidate;
1172
- });
1173
- }
1174
- function _filterOption(props, option, inputValue) {
1175
- return props.filterOption ? props.filterOption(option, inputValue) : true;
1176
- }
1177
- var shouldHideSelectedOptions = function shouldHideSelectedOptions2(props) {
1178
- var hideSelectedOptions = props.hideSelectedOptions, isMulti = props.isMulti;
1179
- if (hideSelectedOptions === void 0) return isMulti;
1180
- return hideSelectedOptions;
1181
- };
1182
- var instanceId = 1;
1183
- var Select = /* @__PURE__ */ function(_Component) {
1184
- _inherits(Select2, _Component);
1185
- var _super = _createSuper(Select2);
1186
- function Select2(_props) {
1187
- var _this;
1188
- _classCallCheck(this, Select2);
1189
- _this = _super.call(this, _props);
1190
- _this.state = {
1191
- ariaSelection: null,
1192
- focusedOption: null,
1193
- focusedOptionId: null,
1194
- focusableOptionsWithIds: [],
1195
- focusedValue: null,
1196
- inputIsHidden: false,
1197
- isFocused: false,
1198
- selectValue: [],
1199
- clearFocusValueOnUpdate: false,
1200
- prevWasFocused: false,
1201
- inputIsHiddenAfterUpdate: void 0,
1202
- prevProps: void 0,
1203
- instancePrefix: ""
1204
- };
1205
- _this.blockOptionHover = false;
1206
- _this.isComposing = false;
1207
- _this.commonProps = void 0;
1208
- _this.initialTouchX = 0;
1209
- _this.initialTouchY = 0;
1210
- _this.openAfterFocus = false;
1211
- _this.scrollToFocusedOptionOnUpdate = false;
1212
- _this.userIsDragging = void 0;
1213
- _this.isAppleDevice = isAppleDevice();
1214
- _this.controlRef = null;
1215
- _this.getControlRef = function(ref) {
1216
- _this.controlRef = ref;
1217
- };
1218
- _this.focusedOptionRef = null;
1219
- _this.getFocusedOptionRef = function(ref) {
1220
- _this.focusedOptionRef = ref;
1221
- };
1222
- _this.menuListRef = null;
1223
- _this.getMenuListRef = function(ref) {
1224
- _this.menuListRef = ref;
1225
- };
1226
- _this.inputRef = null;
1227
- _this.getInputRef = function(ref) {
1228
- _this.inputRef = ref;
1229
- };
1230
- _this.focus = _this.focusInput;
1231
- _this.blur = _this.blurInput;
1232
- _this.onChange = function(newValue, actionMeta) {
1233
- var _this$props = _this.props, onChange2 = _this$props.onChange, name = _this$props.name;
1234
- actionMeta.name = name;
1235
- _this.ariaOnChange(newValue, actionMeta);
1236
- onChange2(newValue, actionMeta);
1237
- };
1238
- _this.setValue = function(newValue, action, option) {
1239
- var _this$props2 = _this.props, closeMenuOnSelect = _this$props2.closeMenuOnSelect, isMulti = _this$props2.isMulti, inputValue = _this$props2.inputValue;
1240
- _this.onInputChange("", {
1241
- action: "set-value",
1242
- prevInputValue: inputValue
1243
- });
1244
- if (closeMenuOnSelect) {
1245
- _this.setState({
1246
- inputIsHiddenAfterUpdate: !isMulti
1247
- });
1248
- _this.onMenuClose();
1249
- }
1250
- _this.setState({
1251
- clearFocusValueOnUpdate: true
1252
- });
1253
- _this.onChange(newValue, {
1254
- action,
1255
- option
1256
- });
1257
- };
1258
- _this.selectOption = function(newValue) {
1259
- var _this$props3 = _this.props, blurInputOnSelect = _this$props3.blurInputOnSelect, isMulti = _this$props3.isMulti, name = _this$props3.name;
1260
- var selectValue = _this.state.selectValue;
1261
- var deselected = isMulti && _this.isOptionSelected(newValue, selectValue);
1262
- var isDisabled = _this.isOptionDisabled(newValue, selectValue);
1263
- if (deselected) {
1264
- var candidate = _this.getOptionValue(newValue);
1265
- _this.setValue(multiValueAsValue(selectValue.filter(function(i) {
1266
- return _this.getOptionValue(i) !== candidate;
1267
- })), "deselect-option", newValue);
1268
- } else if (!isDisabled) {
1269
- if (isMulti) {
1270
- _this.setValue(multiValueAsValue([].concat(_toConsumableArray(selectValue), [newValue])), "select-option", newValue);
1271
- } else {
1272
- _this.setValue(singleValueAsValue(newValue), "select-option");
1273
- }
1274
- } else {
1275
- _this.ariaOnChange(singleValueAsValue(newValue), {
1276
- action: "select-option",
1277
- option: newValue,
1278
- name
1279
- });
1280
- return;
1281
- }
1282
- if (blurInputOnSelect) {
1283
- _this.blurInput();
1284
- }
1285
- };
1286
- _this.removeValue = function(removedValue) {
1287
- var isMulti = _this.props.isMulti;
1288
- var selectValue = _this.state.selectValue;
1289
- var candidate = _this.getOptionValue(removedValue);
1290
- var newValueArray = selectValue.filter(function(i) {
1291
- return _this.getOptionValue(i) !== candidate;
1292
- });
1293
- var newValue = valueTernary(isMulti, newValueArray, newValueArray[0] || null);
1294
- _this.onChange(newValue, {
1295
- action: "remove-value",
1296
- removedValue
1297
- });
1298
- _this.focusInput();
1299
- };
1300
- _this.clearValue = function() {
1301
- var selectValue = _this.state.selectValue;
1302
- _this.onChange(valueTernary(_this.props.isMulti, [], null), {
1303
- action: "clear",
1304
- removedValues: selectValue
1305
- });
1306
- };
1307
- _this.popValue = function() {
1308
- var isMulti = _this.props.isMulti;
1309
- var selectValue = _this.state.selectValue;
1310
- var lastSelectedValue = selectValue[selectValue.length - 1];
1311
- var newValueArray = selectValue.slice(0, selectValue.length - 1);
1312
- var newValue = valueTernary(isMulti, newValueArray, newValueArray[0] || null);
1313
- if (lastSelectedValue) {
1314
- _this.onChange(newValue, {
1315
- action: "pop-value",
1316
- removedValue: lastSelectedValue
1317
- });
1318
- }
1319
- };
1320
- _this.getFocusedOptionId = function(focusedOption) {
1321
- return getFocusedOptionId(_this.state.focusableOptionsWithIds, focusedOption);
1322
- };
1323
- _this.getFocusableOptionsWithIds = function() {
1324
- return buildFocusableOptionsWithIds(buildCategorizedOptions(_this.props, _this.state.selectValue), _this.getElementId("option"));
1325
- };
1326
- _this.getValue = function() {
1327
- return _this.state.selectValue;
1328
- };
1329
- _this.cx = function() {
1330
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1331
- args[_key] = arguments[_key];
1332
- }
1333
- return classNames.apply(void 0, [_this.props.classNamePrefix].concat(args));
1334
- };
1335
- _this.getOptionLabel = function(data) {
1336
- return getOptionLabel2(_this.props, data);
1337
- };
1338
- _this.getOptionValue = function(data) {
1339
- return getOptionValue2(_this.props, data);
1340
- };
1341
- _this.getStyles = function(key, props) {
1342
- var unstyled = _this.props.unstyled;
1343
- var base = defaultStyles[key](props, unstyled);
1344
- base.boxSizing = "border-box";
1345
- var custom = _this.props.styles[key];
1346
- return custom ? custom(base, props) : base;
1347
- };
1348
- _this.getClassNames = function(key, props) {
1349
- var _this$props$className, _this$props$className2;
1350
- return (_this$props$className = (_this$props$className2 = _this.props.classNames)[key]) === null || _this$props$className === void 0 ? void 0 : _this$props$className.call(_this$props$className2, props);
1351
- };
1352
- _this.getElementId = function(element) {
1353
- return "".concat(_this.state.instancePrefix, "-").concat(element);
1354
- };
1355
- _this.getComponents = function() {
1356
- return defaultComponents(_this.props);
1357
- };
1358
- _this.buildCategorizedOptions = function() {
1359
- return buildCategorizedOptions(_this.props, _this.state.selectValue);
1360
- };
1361
- _this.getCategorizedOptions = function() {
1362
- return _this.props.menuIsOpen ? _this.buildCategorizedOptions() : [];
1363
- };
1364
- _this.buildFocusableOptions = function() {
1365
- return buildFocusableOptionsFromCategorizedOptions(_this.buildCategorizedOptions());
1366
- };
1367
- _this.getFocusableOptions = function() {
1368
- return _this.props.menuIsOpen ? _this.buildFocusableOptions() : [];
1369
- };
1370
- _this.ariaOnChange = function(value, actionMeta) {
1371
- _this.setState({
1372
- ariaSelection: _objectSpread2({
1373
- value
1374
- }, actionMeta)
1375
- });
1376
- };
1377
- _this.onMenuMouseDown = function(event) {
1378
- if (event.button !== 0) {
1379
- return;
1380
- }
1381
- event.stopPropagation();
1382
- event.preventDefault();
1383
- _this.focusInput();
1384
- };
1385
- _this.onMenuMouseMove = function(event) {
1386
- _this.blockOptionHover = false;
1387
- };
1388
- _this.onControlMouseDown = function(event) {
1389
- if (event.defaultPrevented) {
1390
- return;
1391
- }
1392
- var openMenuOnClick = _this.props.openMenuOnClick;
1393
- if (!_this.state.isFocused) {
1394
- if (openMenuOnClick) {
1395
- _this.openAfterFocus = true;
1396
- }
1397
- _this.focusInput();
1398
- } else if (!_this.props.menuIsOpen) {
1399
- if (openMenuOnClick) {
1400
- _this.openMenu("first");
1401
- }
1402
- } else {
1403
- if (event.target.tagName !== "INPUT" && event.target.tagName !== "TEXTAREA") {
1404
- _this.onMenuClose();
1405
- }
1406
- }
1407
- if (event.target.tagName !== "INPUT" && event.target.tagName !== "TEXTAREA") {
1408
- event.preventDefault();
1409
- }
1410
- };
1411
- _this.onDropdownIndicatorMouseDown = function(event) {
1412
- if (event && event.type === "mousedown" && event.button !== 0) {
1413
- return;
1414
- }
1415
- if (_this.props.isDisabled) return;
1416
- var _this$props4 = _this.props, isMulti = _this$props4.isMulti, menuIsOpen = _this$props4.menuIsOpen;
1417
- _this.focusInput();
1418
- if (menuIsOpen) {
1419
- _this.setState({
1420
- inputIsHiddenAfterUpdate: !isMulti
1421
- });
1422
- _this.onMenuClose();
1423
- } else {
1424
- _this.openMenu("first");
1425
- }
1426
- event.preventDefault();
1427
- };
1428
- _this.onClearIndicatorMouseDown = function(event) {
1429
- if (event && event.type === "mousedown" && event.button !== 0) {
1430
- return;
1431
- }
1432
- _this.clearValue();
1433
- event.preventDefault();
1434
- _this.openAfterFocus = false;
1435
- if (event.type === "touchend") {
1436
- _this.focusInput();
1437
- } else {
1438
- setTimeout(function() {
1439
- return _this.focusInput();
1440
- });
1441
- }
1442
- };
1443
- _this.onScroll = function(event) {
1444
- if (typeof _this.props.closeMenuOnScroll === "boolean") {
1445
- if (event.target instanceof HTMLElement && isDocumentElement(event.target)) {
1446
- _this.props.onMenuClose();
1447
- }
1448
- } else if (typeof _this.props.closeMenuOnScroll === "function") {
1449
- if (_this.props.closeMenuOnScroll(event)) {
1450
- _this.props.onMenuClose();
1451
- }
1452
- }
1453
- };
1454
- _this.onCompositionStart = function() {
1455
- _this.isComposing = true;
1456
- };
1457
- _this.onCompositionEnd = function() {
1458
- _this.isComposing = false;
1459
- };
1460
- _this.onTouchStart = function(_ref22) {
1461
- var touches = _ref22.touches;
1462
- var touch = touches && touches.item(0);
1463
- if (!touch) {
1464
- return;
1465
- }
1466
- _this.initialTouchX = touch.clientX;
1467
- _this.initialTouchY = touch.clientY;
1468
- _this.userIsDragging = false;
1469
- };
1470
- _this.onTouchMove = function(_ref3) {
1471
- var touches = _ref3.touches;
1472
- var touch = touches && touches.item(0);
1473
- if (!touch) {
1474
- return;
1475
- }
1476
- var deltaX = Math.abs(touch.clientX - _this.initialTouchX);
1477
- var deltaY = Math.abs(touch.clientY - _this.initialTouchY);
1478
- var moveThreshold = 5;
1479
- _this.userIsDragging = deltaX > moveThreshold || deltaY > moveThreshold;
1480
- };
1481
- _this.onTouchEnd = function(event) {
1482
- if (_this.userIsDragging) return;
1483
- if (_this.controlRef && !_this.controlRef.contains(event.target) && _this.menuListRef && !_this.menuListRef.contains(event.target)) {
1484
- _this.blurInput();
1485
- }
1486
- _this.initialTouchX = 0;
1487
- _this.initialTouchY = 0;
1488
- };
1489
- _this.onControlTouchEnd = function(event) {
1490
- if (_this.userIsDragging) return;
1491
- _this.onControlMouseDown(event);
1492
- };
1493
- _this.onClearIndicatorTouchEnd = function(event) {
1494
- if (_this.userIsDragging) return;
1495
- _this.onClearIndicatorMouseDown(event);
1496
- };
1497
- _this.onDropdownIndicatorTouchEnd = function(event) {
1498
- if (_this.userIsDragging) return;
1499
- _this.onDropdownIndicatorMouseDown(event);
1500
- };
1501
- _this.handleInputChange = function(event) {
1502
- var prevInputValue = _this.props.inputValue;
1503
- var inputValue = event.currentTarget.value;
1504
- _this.setState({
1505
- inputIsHiddenAfterUpdate: false
1506
- });
1507
- _this.onInputChange(inputValue, {
1508
- action: "input-change",
1509
- prevInputValue
1510
- });
1511
- if (!_this.props.menuIsOpen) {
1512
- _this.onMenuOpen();
1513
- }
1514
- };
1515
- _this.onInputFocus = function(event) {
1516
- if (_this.props.onFocus) {
1517
- _this.props.onFocus(event);
1518
- }
1519
- _this.setState({
1520
- inputIsHiddenAfterUpdate: false,
1521
- isFocused: true
1522
- });
1523
- if (_this.openAfterFocus || _this.props.openMenuOnFocus) {
1524
- _this.openMenu("first");
1525
- }
1526
- _this.openAfterFocus = false;
1527
- };
1528
- _this.onInputBlur = function(event) {
1529
- var prevInputValue = _this.props.inputValue;
1530
- if (_this.menuListRef && _this.menuListRef.contains(document.activeElement)) {
1531
- _this.inputRef.focus();
1532
- return;
1533
- }
1534
- if (_this.props.onBlur) {
1535
- _this.props.onBlur(event);
1536
- }
1537
- _this.onInputChange("", {
1538
- action: "input-blur",
1539
- prevInputValue
1540
- });
1541
- _this.onMenuClose();
1542
- _this.setState({
1543
- focusedValue: null,
1544
- isFocused: false
1545
- });
1546
- };
1547
- _this.onOptionHover = function(focusedOption) {
1548
- if (_this.blockOptionHover || _this.state.focusedOption === focusedOption) {
1549
- return;
1550
- }
1551
- var options = _this.getFocusableOptions();
1552
- var focusedOptionIndex = options.indexOf(focusedOption);
1553
- _this.setState({
1554
- focusedOption,
1555
- focusedOptionId: focusedOptionIndex > -1 ? _this.getFocusedOptionId(focusedOption) : null
1556
- });
1557
- };
1558
- _this.shouldHideSelectedOptions = function() {
1559
- return shouldHideSelectedOptions(_this.props);
1560
- };
1561
- _this.onValueInputFocus = function(e) {
1562
- e.preventDefault();
1563
- e.stopPropagation();
1564
- _this.focus();
1565
- };
1566
- _this.onKeyDown = function(event) {
1567
- var _this$props5 = _this.props, isMulti = _this$props5.isMulti, backspaceRemovesValue = _this$props5.backspaceRemovesValue, escapeClearsValue = _this$props5.escapeClearsValue, inputValue = _this$props5.inputValue, isClearable = _this$props5.isClearable, isDisabled = _this$props5.isDisabled, menuIsOpen = _this$props5.menuIsOpen, onKeyDown = _this$props5.onKeyDown, tabSelectsValue = _this$props5.tabSelectsValue, openMenuOnFocus = _this$props5.openMenuOnFocus;
1568
- var _this$state = _this.state, focusedOption = _this$state.focusedOption, focusedValue = _this$state.focusedValue, selectValue = _this$state.selectValue;
1569
- if (isDisabled) return;
1570
- if (typeof onKeyDown === "function") {
1571
- onKeyDown(event);
1572
- if (event.defaultPrevented) {
1573
- return;
1574
- }
1575
- }
1576
- _this.blockOptionHover = true;
1577
- switch (event.key) {
1578
- case "ArrowLeft":
1579
- if (!isMulti || inputValue) return;
1580
- _this.focusValue("previous");
1581
- break;
1582
- case "ArrowRight":
1583
- if (!isMulti || inputValue) return;
1584
- _this.focusValue("next");
1585
- break;
1586
- case "Delete":
1587
- case "Backspace":
1588
- if (inputValue) return;
1589
- if (focusedValue) {
1590
- _this.removeValue(focusedValue);
1591
- } else {
1592
- if (!backspaceRemovesValue) return;
1593
- if (isMulti) {
1594
- _this.popValue();
1595
- } else if (isClearable) {
1596
- _this.clearValue();
1597
- }
1598
- }
1599
- break;
1600
- case "Tab":
1601
- if (_this.isComposing) return;
1602
- if (event.shiftKey || !menuIsOpen || !tabSelectsValue || !focusedOption || // don't capture the event if the menu opens on focus and the focused
1603
- // option is already selected; it breaks the flow of navigation
1604
- openMenuOnFocus && _this.isOptionSelected(focusedOption, selectValue)) {
1605
- return;
1606
- }
1607
- _this.selectOption(focusedOption);
1608
- break;
1609
- case "Enter":
1610
- if (event.keyCode === 229) {
1611
- break;
1612
- }
1613
- if (menuIsOpen) {
1614
- if (!focusedOption) return;
1615
- if (_this.isComposing) return;
1616
- _this.selectOption(focusedOption);
1617
- break;
1618
- }
1619
- return;
1620
- case "Escape":
1621
- if (menuIsOpen) {
1622
- _this.setState({
1623
- inputIsHiddenAfterUpdate: false
1624
- });
1625
- _this.onInputChange("", {
1626
- action: "menu-close",
1627
- prevInputValue: inputValue
1628
- });
1629
- _this.onMenuClose();
1630
- } else if (isClearable && escapeClearsValue) {
1631
- _this.clearValue();
1632
- }
1633
- break;
1634
- case " ":
1635
- if (inputValue) {
1636
- return;
1637
- }
1638
- if (!menuIsOpen) {
1639
- _this.openMenu("first");
1640
- break;
1641
- }
1642
- if (!focusedOption) return;
1643
- _this.selectOption(focusedOption);
1644
- break;
1645
- case "ArrowUp":
1646
- if (menuIsOpen) {
1647
- _this.focusOption("up");
1648
- } else {
1649
- _this.openMenu("last");
1650
- }
1651
- break;
1652
- case "ArrowDown":
1653
- if (menuIsOpen) {
1654
- _this.focusOption("down");
1655
- } else {
1656
- _this.openMenu("first");
1657
- }
1658
- break;
1659
- case "PageUp":
1660
- if (!menuIsOpen) return;
1661
- _this.focusOption("pageup");
1662
- break;
1663
- case "PageDown":
1664
- if (!menuIsOpen) return;
1665
- _this.focusOption("pagedown");
1666
- break;
1667
- case "Home":
1668
- if (!menuIsOpen) return;
1669
- _this.focusOption("first");
1670
- break;
1671
- case "End":
1672
- if (!menuIsOpen) return;
1673
- _this.focusOption("last");
1674
- break;
1675
- default:
1676
- return;
1677
- }
1678
- event.preventDefault();
1679
- };
1680
- _this.state.instancePrefix = "react-select-" + (_this.props.instanceId || ++instanceId);
1681
- _this.state.selectValue = cleanValue(_props.value);
1682
- if (_props.menuIsOpen && _this.state.selectValue.length) {
1683
- var focusableOptionsWithIds = _this.getFocusableOptionsWithIds();
1684
- var focusableOptions = _this.buildFocusableOptions();
1685
- var optionIndex = focusableOptions.indexOf(_this.state.selectValue[0]);
1686
- _this.state.focusableOptionsWithIds = focusableOptionsWithIds;
1687
- _this.state.focusedOption = focusableOptions[optionIndex];
1688
- _this.state.focusedOptionId = getFocusedOptionId(focusableOptionsWithIds, focusableOptions[optionIndex]);
1689
- }
1690
- return _this;
1691
- }
1692
- _createClass(Select2, [{
1693
- key: "componentDidMount",
1694
- value: function componentDidMount() {
1695
- this.startListeningComposition();
1696
- this.startListeningToTouch();
1697
- if (this.props.closeMenuOnScroll && document && document.addEventListener) {
1698
- document.addEventListener("scroll", this.onScroll, true);
1699
- }
1700
- if (this.props.autoFocus) {
1701
- this.focusInput();
1702
- }
1703
- if (this.props.menuIsOpen && this.state.focusedOption && this.menuListRef && this.focusedOptionRef) {
1704
- scrollIntoView(this.menuListRef, this.focusedOptionRef);
1705
- }
1706
- }
1707
- }, {
1708
- key: "componentDidUpdate",
1709
- value: function componentDidUpdate(prevProps) {
1710
- var _this$props6 = this.props, isDisabled = _this$props6.isDisabled, menuIsOpen = _this$props6.menuIsOpen;
1711
- var isFocused = this.state.isFocused;
1712
- if (
1713
- // ensure focus is restored correctly when the control becomes enabled
1714
- isFocused && !isDisabled && prevProps.isDisabled || // ensure focus is on the Input when the menu opens
1715
- isFocused && menuIsOpen && !prevProps.menuIsOpen
1716
- ) {
1717
- this.focusInput();
1718
- }
1719
- if (isFocused && isDisabled && !prevProps.isDisabled) {
1720
- this.setState({
1721
- isFocused: false
1722
- }, this.onMenuClose);
1723
- } else if (!isFocused && !isDisabled && prevProps.isDisabled && this.inputRef === document.activeElement) {
1724
- this.setState({
1725
- isFocused: true
1726
- });
1727
- }
1728
- if (this.menuListRef && this.focusedOptionRef && this.scrollToFocusedOptionOnUpdate) {
1729
- scrollIntoView(this.menuListRef, this.focusedOptionRef);
1730
- this.scrollToFocusedOptionOnUpdate = false;
1731
- }
1732
- }
1733
- }, {
1734
- key: "componentWillUnmount",
1735
- value: function componentWillUnmount() {
1736
- this.stopListeningComposition();
1737
- this.stopListeningToTouch();
1738
- document.removeEventListener("scroll", this.onScroll, true);
1739
- }
1740
- // ==============================
1741
- // Consumer Handlers
1742
- // ==============================
1743
- }, {
1744
- key: "onMenuOpen",
1745
- value: function onMenuOpen() {
1746
- this.props.onMenuOpen();
1747
- }
1748
- }, {
1749
- key: "onMenuClose",
1750
- value: function onMenuClose() {
1751
- this.onInputChange("", {
1752
- action: "menu-close",
1753
- prevInputValue: this.props.inputValue
1754
- });
1755
- this.props.onMenuClose();
1756
- }
1757
- }, {
1758
- key: "onInputChange",
1759
- value: function onInputChange(newValue, actionMeta) {
1760
- this.props.onInputChange(newValue, actionMeta);
1761
- }
1762
- // ==============================
1763
- // Methods
1764
- // ==============================
1765
- }, {
1766
- key: "focusInput",
1767
- value: function focusInput() {
1768
- if (!this.inputRef) return;
1769
- this.inputRef.focus();
1770
- }
1771
- }, {
1772
- key: "blurInput",
1773
- value: function blurInput() {
1774
- if (!this.inputRef) return;
1775
- this.inputRef.blur();
1776
- }
1777
- // aliased for consumers
1778
- }, {
1779
- key: "openMenu",
1780
- value: function openMenu(focusOption) {
1781
- var _this2 = this;
1782
- var _this$state2 = this.state, selectValue = _this$state2.selectValue, isFocused = _this$state2.isFocused;
1783
- var focusableOptions = this.buildFocusableOptions();
1784
- var openAtIndex = focusOption === "first" ? 0 : focusableOptions.length - 1;
1785
- if (!this.props.isMulti) {
1786
- var selectedIndex = focusableOptions.indexOf(selectValue[0]);
1787
- if (selectedIndex > -1) {
1788
- openAtIndex = selectedIndex;
1789
- }
1790
- }
1791
- this.scrollToFocusedOptionOnUpdate = !(isFocused && this.menuListRef);
1792
- this.setState({
1793
- inputIsHiddenAfterUpdate: false,
1794
- focusedValue: null,
1795
- focusedOption: focusableOptions[openAtIndex],
1796
- focusedOptionId: this.getFocusedOptionId(focusableOptions[openAtIndex])
1797
- }, function() {
1798
- return _this2.onMenuOpen();
1799
- });
1800
- }
1801
- }, {
1802
- key: "focusValue",
1803
- value: function focusValue(direction) {
1804
- var _this$state3 = this.state, selectValue = _this$state3.selectValue, focusedValue = _this$state3.focusedValue;
1805
- if (!this.props.isMulti) return;
1806
- this.setState({
1807
- focusedOption: null
1808
- });
1809
- var focusedIndex = selectValue.indexOf(focusedValue);
1810
- if (!focusedValue) {
1811
- focusedIndex = -1;
1812
- }
1813
- var lastIndex = selectValue.length - 1;
1814
- var nextFocus = -1;
1815
- if (!selectValue.length) return;
1816
- switch (direction) {
1817
- case "previous":
1818
- if (focusedIndex === 0) {
1819
- nextFocus = 0;
1820
- } else if (focusedIndex === -1) {
1821
- nextFocus = lastIndex;
1822
- } else {
1823
- nextFocus = focusedIndex - 1;
1824
- }
1825
- break;
1826
- case "next":
1827
- if (focusedIndex > -1 && focusedIndex < lastIndex) {
1828
- nextFocus = focusedIndex + 1;
1829
- }
1830
- break;
1831
- }
1832
- this.setState({
1833
- inputIsHidden: nextFocus !== -1,
1834
- focusedValue: selectValue[nextFocus]
1835
- });
1836
- }
1837
- }, {
1838
- key: "focusOption",
1839
- value: function focusOption() {
1840
- var direction = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "first";
1841
- var pageSize = this.props.pageSize;
1842
- var focusedOption = this.state.focusedOption;
1843
- var options = this.getFocusableOptions();
1844
- if (!options.length) return;
1845
- var nextFocus = 0;
1846
- var focusedIndex = options.indexOf(focusedOption);
1847
- if (!focusedOption) {
1848
- focusedIndex = -1;
1849
- }
1850
- if (direction === "up") {
1851
- nextFocus = focusedIndex > 0 ? focusedIndex - 1 : options.length - 1;
1852
- } else if (direction === "down") {
1853
- nextFocus = (focusedIndex + 1) % options.length;
1854
- } else if (direction === "pageup") {
1855
- nextFocus = focusedIndex - pageSize;
1856
- if (nextFocus < 0) nextFocus = 0;
1857
- } else if (direction === "pagedown") {
1858
- nextFocus = focusedIndex + pageSize;
1859
- if (nextFocus > options.length - 1) nextFocus = options.length - 1;
1860
- } else if (direction === "last") {
1861
- nextFocus = options.length - 1;
1862
- }
1863
- this.scrollToFocusedOptionOnUpdate = true;
1864
- this.setState({
1865
- focusedOption: options[nextFocus],
1866
- focusedValue: null,
1867
- focusedOptionId: this.getFocusedOptionId(options[nextFocus])
1868
- });
1869
- }
1870
- }, {
1871
- key: "getTheme",
1872
- value: (
1873
- // ==============================
1874
- // Getters
1875
- // ==============================
1876
- function getTheme() {
1877
- if (!this.props.theme) {
1878
- return defaultTheme;
1879
- }
1880
- if (typeof this.props.theme === "function") {
1881
- return this.props.theme(defaultTheme);
1882
- }
1883
- return _objectSpread2(_objectSpread2({}, defaultTheme), this.props.theme);
1884
- }
1885
- )
1886
- }, {
1887
- key: "getCommonProps",
1888
- value: function getCommonProps() {
1889
- var clearValue = this.clearValue, cx = this.cx, getStyles = this.getStyles, getClassNames = this.getClassNames, getValue = this.getValue, selectOption = this.selectOption, setValue = this.setValue, props = this.props;
1890
- var isMulti = props.isMulti, isRtl = props.isRtl, options = props.options;
1891
- var hasValue = this.hasValue();
1892
- return {
1893
- clearValue,
1894
- cx,
1895
- getStyles,
1896
- getClassNames,
1897
- getValue,
1898
- hasValue,
1899
- isMulti,
1900
- isRtl,
1901
- options,
1902
- selectOption,
1903
- selectProps: props,
1904
- setValue,
1905
- theme: this.getTheme()
1906
- };
1907
- }
1908
- }, {
1909
- key: "hasValue",
1910
- value: function hasValue() {
1911
- var selectValue = this.state.selectValue;
1912
- return selectValue.length > 0;
1913
- }
1914
- }, {
1915
- key: "hasOptions",
1916
- value: function hasOptions() {
1917
- return !!this.getFocusableOptions().length;
1918
- }
1919
- }, {
1920
- key: "isClearable",
1921
- value: function isClearable() {
1922
- var _this$props7 = this.props, isClearable2 = _this$props7.isClearable, isMulti = _this$props7.isMulti;
1923
- if (isClearable2 === void 0) return isMulti;
1924
- return isClearable2;
1925
- }
1926
- }, {
1927
- key: "isOptionDisabled",
1928
- value: function isOptionDisabled3(option, selectValue) {
1929
- return _isOptionDisabled(this.props, option, selectValue);
1930
- }
1931
- }, {
1932
- key: "isOptionSelected",
1933
- value: function isOptionSelected(option, selectValue) {
1934
- return _isOptionSelected(this.props, option, selectValue);
1935
- }
1936
- }, {
1937
- key: "filterOption",
1938
- value: function filterOption(option, inputValue) {
1939
- return _filterOption(this.props, option, inputValue);
1940
- }
1941
- }, {
1942
- key: "formatOptionLabel",
1943
- value: function formatOptionLabel(data, context) {
1944
- if (typeof this.props.formatOptionLabel === "function") {
1945
- var _inputValue = this.props.inputValue;
1946
- var _selectValue = this.state.selectValue;
1947
- return this.props.formatOptionLabel(data, {
1948
- context,
1949
- inputValue: _inputValue,
1950
- selectValue: _selectValue
1951
- });
1952
- } else {
1953
- return this.getOptionLabel(data);
1954
- }
1955
- }
1956
- }, {
1957
- key: "formatGroupLabel",
1958
- value: function formatGroupLabel3(data) {
1959
- return this.props.formatGroupLabel(data);
1960
- }
1961
- // ==============================
1962
- // Mouse Handlers
1963
- // ==============================
1964
- }, {
1965
- key: "startListeningComposition",
1966
- value: (
1967
- // ==============================
1968
- // Composition Handlers
1969
- // ==============================
1970
- function startListeningComposition() {
1971
- if (document && document.addEventListener) {
1972
- document.addEventListener("compositionstart", this.onCompositionStart, false);
1973
- document.addEventListener("compositionend", this.onCompositionEnd, false);
1974
- }
1975
- }
1976
- )
1977
- }, {
1978
- key: "stopListeningComposition",
1979
- value: function stopListeningComposition() {
1980
- if (document && document.removeEventListener) {
1981
- document.removeEventListener("compositionstart", this.onCompositionStart);
1982
- document.removeEventListener("compositionend", this.onCompositionEnd);
1983
- }
1984
- }
1985
- }, {
1986
- key: "startListeningToTouch",
1987
- value: (
1988
- // ==============================
1989
- // Touch Handlers
1990
- // ==============================
1991
- function startListeningToTouch() {
1992
- if (document && document.addEventListener) {
1993
- document.addEventListener("touchstart", this.onTouchStart, false);
1994
- document.addEventListener("touchmove", this.onTouchMove, false);
1995
- document.addEventListener("touchend", this.onTouchEnd, false);
1996
- }
1997
- }
1998
- )
1999
- }, {
2000
- key: "stopListeningToTouch",
2001
- value: function stopListeningToTouch() {
2002
- if (document && document.removeEventListener) {
2003
- document.removeEventListener("touchstart", this.onTouchStart);
2004
- document.removeEventListener("touchmove", this.onTouchMove);
2005
- document.removeEventListener("touchend", this.onTouchEnd);
2006
- }
2007
- }
2008
- }, {
2009
- key: "renderInput",
2010
- value: (
2011
- // ==============================
2012
- // Renderers
2013
- // ==============================
2014
- function renderInput() {
2015
- var _this$props8 = this.props, isDisabled = _this$props8.isDisabled, isSearchable = _this$props8.isSearchable, inputId = _this$props8.inputId, inputValue = _this$props8.inputValue, tabIndex = _this$props8.tabIndex, form = _this$props8.form, menuIsOpen = _this$props8.menuIsOpen, required = _this$props8.required;
2016
- var _this$getComponents = this.getComponents(), Input = _this$getComponents.Input;
2017
- var _this$state4 = this.state, inputIsHidden = _this$state4.inputIsHidden, ariaSelection = _this$state4.ariaSelection;
2018
- var commonProps = this.commonProps;
2019
- var id = inputId || this.getElementId("input");
2020
- var ariaAttributes = _objectSpread2(_objectSpread2(_objectSpread2({
2021
- "aria-autocomplete": "list",
2022
- "aria-expanded": menuIsOpen,
2023
- "aria-haspopup": true,
2024
- "aria-errormessage": this.props["aria-errormessage"],
2025
- "aria-invalid": this.props["aria-invalid"],
2026
- "aria-label": this.props["aria-label"],
2027
- "aria-labelledby": this.props["aria-labelledby"],
2028
- "aria-required": required,
2029
- role: "combobox",
2030
- "aria-activedescendant": this.isAppleDevice ? void 0 : this.state.focusedOptionId || ""
2031
- }, menuIsOpen && {
2032
- "aria-controls": this.getElementId("listbox")
2033
- }), !isSearchable && {
2034
- "aria-readonly": true
2035
- }), this.hasValue() ? (ariaSelection === null || ariaSelection === void 0 ? void 0 : ariaSelection.action) === "initial-input-focus" && {
2036
- "aria-describedby": this.getElementId("live-region")
2037
- } : {
2038
- "aria-describedby": this.getElementId("placeholder")
2039
- });
2040
- if (!isSearchable) {
2041
- return /* @__PURE__ */ React.createElement(DummyInput, _extends({
2042
- id,
2043
- innerRef: this.getInputRef,
2044
- onBlur: this.onInputBlur,
2045
- onChange: noop,
2046
- onFocus: this.onInputFocus,
2047
- disabled: isDisabled,
2048
- tabIndex,
2049
- inputMode: "none",
2050
- form,
2051
- value: ""
2052
- }, ariaAttributes));
2053
- }
2054
- return /* @__PURE__ */ React.createElement(Input, _extends({}, commonProps, {
2055
- autoCapitalize: "none",
2056
- autoComplete: "off",
2057
- autoCorrect: "off",
2058
- id,
2059
- innerRef: this.getInputRef,
2060
- isDisabled,
2061
- isHidden: inputIsHidden,
2062
- onBlur: this.onInputBlur,
2063
- onChange: this.handleInputChange,
2064
- onFocus: this.onInputFocus,
2065
- spellCheck: "false",
2066
- tabIndex,
2067
- form,
2068
- type: "text",
2069
- value: inputValue
2070
- }, ariaAttributes));
2071
- }
2072
- )
2073
- }, {
2074
- key: "renderPlaceholderOrValue",
2075
- value: function renderPlaceholderOrValue() {
2076
- var _this3 = this;
2077
- var _this$getComponents2 = this.getComponents(), MultiValue = _this$getComponents2.MultiValue, MultiValueContainer = _this$getComponents2.MultiValueContainer, MultiValueLabel = _this$getComponents2.MultiValueLabel, MultiValueRemove = _this$getComponents2.MultiValueRemove, SingleValue = _this$getComponents2.SingleValue, Placeholder = _this$getComponents2.Placeholder;
2078
- var commonProps = this.commonProps;
2079
- var _this$props9 = this.props, controlShouldRenderValue = _this$props9.controlShouldRenderValue, isDisabled = _this$props9.isDisabled, isMulti = _this$props9.isMulti, inputValue = _this$props9.inputValue, placeholder = _this$props9.placeholder;
2080
- var _this$state5 = this.state, selectValue = _this$state5.selectValue, focusedValue = _this$state5.focusedValue, isFocused = _this$state5.isFocused;
2081
- if (!this.hasValue() || !controlShouldRenderValue) {
2082
- return inputValue ? null : /* @__PURE__ */ React.createElement(Placeholder, _extends({}, commonProps, {
2083
- key: "placeholder",
2084
- isDisabled,
2085
- isFocused,
2086
- innerProps: {
2087
- id: this.getElementId("placeholder")
2088
- }
2089
- }), placeholder);
2090
- }
2091
- if (isMulti) {
2092
- return selectValue.map(function(opt, index) {
2093
- var isOptionFocused = opt === focusedValue;
2094
- var key = "".concat(_this3.getOptionLabel(opt), "-").concat(_this3.getOptionValue(opt));
2095
- return /* @__PURE__ */ React.createElement(MultiValue, _extends({}, commonProps, {
2096
- components: {
2097
- Container: MultiValueContainer,
2098
- Label: MultiValueLabel,
2099
- Remove: MultiValueRemove
2100
- },
2101
- isFocused: isOptionFocused,
2102
- isDisabled,
2103
- key,
2104
- index,
2105
- removeProps: {
2106
- onClick: function onClick() {
2107
- return _this3.removeValue(opt);
2108
- },
2109
- onTouchEnd: function onTouchEnd() {
2110
- return _this3.removeValue(opt);
2111
- },
2112
- onMouseDown: function onMouseDown(e) {
2113
- e.preventDefault();
2114
- }
2115
- },
2116
- data: opt
2117
- }), _this3.formatOptionLabel(opt, "value"));
2118
- });
2119
- }
2120
- if (inputValue) {
2121
- return null;
2122
- }
2123
- var singleValue = selectValue[0];
2124
- return /* @__PURE__ */ React.createElement(SingleValue, _extends({}, commonProps, {
2125
- data: singleValue,
2126
- isDisabled
2127
- }), this.formatOptionLabel(singleValue, "value"));
2128
- }
2129
- }, {
2130
- key: "renderClearIndicator",
2131
- value: function renderClearIndicator() {
2132
- var _this$getComponents3 = this.getComponents(), ClearIndicator = _this$getComponents3.ClearIndicator;
2133
- var commonProps = this.commonProps;
2134
- var _this$props10 = this.props, isDisabled = _this$props10.isDisabled, isLoading = _this$props10.isLoading;
2135
- var isFocused = this.state.isFocused;
2136
- if (!this.isClearable() || !ClearIndicator || isDisabled || !this.hasValue() || isLoading) {
2137
- return null;
2138
- }
2139
- var innerProps = {
2140
- onMouseDown: this.onClearIndicatorMouseDown,
2141
- onTouchEnd: this.onClearIndicatorTouchEnd,
2142
- "aria-hidden": "true"
2143
- };
2144
- return /* @__PURE__ */ React.createElement(ClearIndicator, _extends({}, commonProps, {
2145
- innerProps,
2146
- isFocused
2147
- }));
2148
- }
2149
- }, {
2150
- key: "renderLoadingIndicator",
2151
- value: function renderLoadingIndicator() {
2152
- var _this$getComponents4 = this.getComponents(), LoadingIndicator = _this$getComponents4.LoadingIndicator;
2153
- var commonProps = this.commonProps;
2154
- var _this$props11 = this.props, isDisabled = _this$props11.isDisabled, isLoading = _this$props11.isLoading;
2155
- var isFocused = this.state.isFocused;
2156
- if (!LoadingIndicator || !isLoading) return null;
2157
- var innerProps = {
2158
- "aria-hidden": "true"
2159
- };
2160
- return /* @__PURE__ */ React.createElement(LoadingIndicator, _extends({}, commonProps, {
2161
- innerProps,
2162
- isDisabled,
2163
- isFocused
2164
- }));
2165
- }
2166
- }, {
2167
- key: "renderIndicatorSeparator",
2168
- value: function renderIndicatorSeparator() {
2169
- var _this$getComponents5 = this.getComponents(), DropdownIndicator = _this$getComponents5.DropdownIndicator, IndicatorSeparator = _this$getComponents5.IndicatorSeparator;
2170
- if (!DropdownIndicator || !IndicatorSeparator) return null;
2171
- var commonProps = this.commonProps;
2172
- var isDisabled = this.props.isDisabled;
2173
- var isFocused = this.state.isFocused;
2174
- return /* @__PURE__ */ React.createElement(IndicatorSeparator, _extends({}, commonProps, {
2175
- isDisabled,
2176
- isFocused
2177
- }));
2178
- }
2179
- }, {
2180
- key: "renderDropdownIndicator",
2181
- value: function renderDropdownIndicator() {
2182
- var _this$getComponents6 = this.getComponents(), DropdownIndicator = _this$getComponents6.DropdownIndicator;
2183
- if (!DropdownIndicator) return null;
2184
- var commonProps = this.commonProps;
2185
- var isDisabled = this.props.isDisabled;
2186
- var isFocused = this.state.isFocused;
2187
- var innerProps = {
2188
- onMouseDown: this.onDropdownIndicatorMouseDown,
2189
- onTouchEnd: this.onDropdownIndicatorTouchEnd,
2190
- "aria-hidden": "true"
2191
- };
2192
- return /* @__PURE__ */ React.createElement(DropdownIndicator, _extends({}, commonProps, {
2193
- innerProps,
2194
- isDisabled,
2195
- isFocused
2196
- }));
2197
- }
2198
- }, {
2199
- key: "renderMenu",
2200
- value: function renderMenu() {
2201
- var _this4 = this;
2202
- var _this$getComponents7 = this.getComponents(), Group = _this$getComponents7.Group, GroupHeading = _this$getComponents7.GroupHeading, Menu = _this$getComponents7.Menu, MenuList = _this$getComponents7.MenuList, MenuPortal = _this$getComponents7.MenuPortal, LoadingMessage = _this$getComponents7.LoadingMessage, NoOptionsMessage = _this$getComponents7.NoOptionsMessage, Option = _this$getComponents7.Option;
2203
- var commonProps = this.commonProps;
2204
- var focusedOption = this.state.focusedOption;
2205
- var _this$props12 = this.props, captureMenuScroll = _this$props12.captureMenuScroll, inputValue = _this$props12.inputValue, isLoading = _this$props12.isLoading, loadingMessage2 = _this$props12.loadingMessage, minMenuHeight = _this$props12.minMenuHeight, maxMenuHeight = _this$props12.maxMenuHeight, menuIsOpen = _this$props12.menuIsOpen, menuPlacement = _this$props12.menuPlacement, menuPosition = _this$props12.menuPosition, menuPortalTarget = _this$props12.menuPortalTarget, menuShouldBlockScroll = _this$props12.menuShouldBlockScroll, menuShouldScrollIntoView = _this$props12.menuShouldScrollIntoView, noOptionsMessage2 = _this$props12.noOptionsMessage, onMenuScrollToTop = _this$props12.onMenuScrollToTop, onMenuScrollToBottom = _this$props12.onMenuScrollToBottom;
2206
- if (!menuIsOpen) return null;
2207
- var render = function render2(props, id) {
2208
- var type = props.type, data = props.data, isDisabled = props.isDisabled, isSelected = props.isSelected, label = props.label, value = props.value;
2209
- var isFocused = focusedOption === data;
2210
- var onHover = isDisabled ? void 0 : function() {
2211
- return _this4.onOptionHover(data);
2212
- };
2213
- var onSelect = isDisabled ? void 0 : function() {
2214
- return _this4.selectOption(data);
2215
- };
2216
- var optionId = "".concat(_this4.getElementId("option"), "-").concat(id);
2217
- var innerProps = {
2218
- id: optionId,
2219
- onClick: onSelect,
2220
- onMouseMove: onHover,
2221
- onMouseOver: onHover,
2222
- tabIndex: -1,
2223
- role: "option",
2224
- "aria-selected": _this4.isAppleDevice ? void 0 : isSelected
2225
- // is not supported on Apple devices
2226
- };
2227
- return /* @__PURE__ */ React.createElement(Option, _extends({}, commonProps, {
2228
- innerProps,
2229
- data,
2230
- isDisabled,
2231
- isSelected,
2232
- key: optionId,
2233
- label,
2234
- type,
2235
- value,
2236
- isFocused,
2237
- innerRef: isFocused ? _this4.getFocusedOptionRef : void 0
2238
- }), _this4.formatOptionLabel(props.data, "menu"));
2239
- };
2240
- var menuUI;
2241
- if (this.hasOptions()) {
2242
- menuUI = this.getCategorizedOptions().map(function(item) {
2243
- if (item.type === "group") {
2244
- var _data = item.data, options = item.options, groupIndex = item.index;
2245
- var groupId = "".concat(_this4.getElementId("group"), "-").concat(groupIndex);
2246
- var headingId = "".concat(groupId, "-heading");
2247
- return /* @__PURE__ */ React.createElement(Group, _extends({}, commonProps, {
2248
- key: groupId,
2249
- data: _data,
2250
- options,
2251
- Heading: GroupHeading,
2252
- headingProps: {
2253
- id: headingId,
2254
- data: item.data
2255
- },
2256
- label: _this4.formatGroupLabel(item.data)
2257
- }), item.options.map(function(option) {
2258
- return render(option, "".concat(groupIndex, "-").concat(option.index));
2259
- }));
2260
- } else if (item.type === "option") {
2261
- return render(item, "".concat(item.index));
2262
- }
2263
- });
2264
- } else if (isLoading) {
2265
- var message = loadingMessage2({
2266
- inputValue
2267
- });
2268
- if (message === null) return null;
2269
- menuUI = /* @__PURE__ */ React.createElement(LoadingMessage, commonProps, message);
2270
- } else {
2271
- var _message = noOptionsMessage2({
2272
- inputValue
2273
- });
2274
- if (_message === null) return null;
2275
- menuUI = /* @__PURE__ */ React.createElement(NoOptionsMessage, commonProps, _message);
2276
- }
2277
- var menuPlacementProps = {
2278
- minMenuHeight,
2279
- maxMenuHeight,
2280
- menuPlacement,
2281
- menuPosition,
2282
- menuShouldScrollIntoView
2283
- };
2284
- var menuElement = /* @__PURE__ */ React.createElement(MenuPlacer, _extends({}, commonProps, menuPlacementProps), function(_ref4) {
2285
- var ref = _ref4.ref, _ref4$placerProps = _ref4.placerProps, placement = _ref4$placerProps.placement, maxHeight = _ref4$placerProps.maxHeight;
2286
- return /* @__PURE__ */ React.createElement(Menu, _extends({}, commonProps, menuPlacementProps, {
2287
- innerRef: ref,
2288
- innerProps: {
2289
- onMouseDown: _this4.onMenuMouseDown,
2290
- onMouseMove: _this4.onMenuMouseMove
2291
- },
2292
- isLoading,
2293
- placement
2294
- }), /* @__PURE__ */ React.createElement(ScrollManager, {
2295
- captureEnabled: captureMenuScroll,
2296
- onTopArrive: onMenuScrollToTop,
2297
- onBottomArrive: onMenuScrollToBottom,
2298
- lockEnabled: menuShouldBlockScroll
2299
- }, function(scrollTargetRef) {
2300
- return /* @__PURE__ */ React.createElement(MenuList, _extends({}, commonProps, {
2301
- innerRef: function innerRef(instance) {
2302
- _this4.getMenuListRef(instance);
2303
- scrollTargetRef(instance);
2304
- },
2305
- innerProps: {
2306
- role: "listbox",
2307
- "aria-multiselectable": commonProps.isMulti,
2308
- id: _this4.getElementId("listbox")
2309
- },
2310
- isLoading,
2311
- maxHeight,
2312
- focusedOption
2313
- }), menuUI);
2314
- }));
2315
- });
2316
- return menuPortalTarget || menuPosition === "fixed" ? /* @__PURE__ */ React.createElement(MenuPortal, _extends({}, commonProps, {
2317
- appendTo: menuPortalTarget,
2318
- controlElement: this.controlRef,
2319
- menuPlacement,
2320
- menuPosition
2321
- }), menuElement) : menuElement;
2322
- }
2323
- }, {
2324
- key: "renderFormField",
2325
- value: function renderFormField() {
2326
- var _this5 = this;
2327
- var _this$props13 = this.props, delimiter = _this$props13.delimiter, isDisabled = _this$props13.isDisabled, isMulti = _this$props13.isMulti, name = _this$props13.name, required = _this$props13.required;
2328
- var selectValue = this.state.selectValue;
2329
- if (required && !this.hasValue() && !isDisabled) {
2330
- return /* @__PURE__ */ React.createElement(RequiredInput$1, {
2331
- name,
2332
- onFocus: this.onValueInputFocus
2333
- });
2334
- }
2335
- if (!name || isDisabled) return;
2336
- if (isMulti) {
2337
- if (delimiter) {
2338
- var value = selectValue.map(function(opt) {
2339
- return _this5.getOptionValue(opt);
2340
- }).join(delimiter);
2341
- return /* @__PURE__ */ React.createElement("input", {
2342
- name,
2343
- type: "hidden",
2344
- value
2345
- });
2346
- } else {
2347
- var input = selectValue.length > 0 ? selectValue.map(function(opt, i) {
2348
- return /* @__PURE__ */ React.createElement("input", {
2349
- key: "i-".concat(i),
2350
- name,
2351
- type: "hidden",
2352
- value: _this5.getOptionValue(opt)
2353
- });
2354
- }) : /* @__PURE__ */ React.createElement("input", {
2355
- name,
2356
- type: "hidden",
2357
- value: ""
2358
- });
2359
- return /* @__PURE__ */ React.createElement("div", null, input);
2360
- }
2361
- } else {
2362
- var _value = selectValue[0] ? this.getOptionValue(selectValue[0]) : "";
2363
- return /* @__PURE__ */ React.createElement("input", {
2364
- name,
2365
- type: "hidden",
2366
- value: _value
2367
- });
2368
- }
2369
- }
2370
- }, {
2371
- key: "renderLiveRegion",
2372
- value: function renderLiveRegion() {
2373
- var commonProps = this.commonProps;
2374
- var _this$state6 = this.state, ariaSelection = _this$state6.ariaSelection, focusedOption = _this$state6.focusedOption, focusedValue = _this$state6.focusedValue, isFocused = _this$state6.isFocused, selectValue = _this$state6.selectValue;
2375
- var focusableOptions = this.getFocusableOptions();
2376
- return /* @__PURE__ */ React.createElement(LiveRegion$1, _extends({}, commonProps, {
2377
- id: this.getElementId("live-region"),
2378
- ariaSelection,
2379
- focusedOption,
2380
- focusedValue,
2381
- isFocused,
2382
- selectValue,
2383
- focusableOptions,
2384
- isAppleDevice: this.isAppleDevice
2385
- }));
2386
- }
2387
- }, {
2388
- key: "render",
2389
- value: function render() {
2390
- var _this$getComponents8 = this.getComponents(), Control = _this$getComponents8.Control, IndicatorsContainer = _this$getComponents8.IndicatorsContainer, SelectContainer = _this$getComponents8.SelectContainer, ValueContainer = _this$getComponents8.ValueContainer;
2391
- var _this$props14 = this.props, className = _this$props14.className, id = _this$props14.id, isDisabled = _this$props14.isDisabled, menuIsOpen = _this$props14.menuIsOpen;
2392
- var isFocused = this.state.isFocused;
2393
- var commonProps = this.commonProps = this.getCommonProps();
2394
- return /* @__PURE__ */ React.createElement(SelectContainer, _extends({}, commonProps, {
2395
- className,
2396
- innerProps: {
2397
- id,
2398
- onKeyDown: this.onKeyDown
2399
- },
2400
- isDisabled,
2401
- isFocused
2402
- }), this.renderLiveRegion(), /* @__PURE__ */ React.createElement(Control, _extends({}, commonProps, {
2403
- innerRef: this.getControlRef,
2404
- innerProps: {
2405
- onMouseDown: this.onControlMouseDown,
2406
- onTouchEnd: this.onControlTouchEnd
2407
- },
2408
- isDisabled,
2409
- isFocused,
2410
- menuIsOpen
2411
- }), /* @__PURE__ */ React.createElement(ValueContainer, _extends({}, commonProps, {
2412
- isDisabled
2413
- }), this.renderPlaceholderOrValue(), this.renderInput()), /* @__PURE__ */ React.createElement(IndicatorsContainer, _extends({}, commonProps, {
2414
- isDisabled
2415
- }), this.renderClearIndicator(), this.renderLoadingIndicator(), this.renderIndicatorSeparator(), this.renderDropdownIndicator())), this.renderMenu(), this.renderFormField());
2416
- }
2417
- }], [{
2418
- key: "getDerivedStateFromProps",
2419
- value: function getDerivedStateFromProps(props, state) {
2420
- var prevProps = state.prevProps, clearFocusValueOnUpdate = state.clearFocusValueOnUpdate, inputIsHiddenAfterUpdate = state.inputIsHiddenAfterUpdate, ariaSelection = state.ariaSelection, isFocused = state.isFocused, prevWasFocused = state.prevWasFocused, instancePrefix = state.instancePrefix;
2421
- var options = props.options, value = props.value, menuIsOpen = props.menuIsOpen, inputValue = props.inputValue, isMulti = props.isMulti;
2422
- var selectValue = cleanValue(value);
2423
- var newMenuOptionsState = {};
2424
- if (prevProps && (value !== prevProps.value || options !== prevProps.options || menuIsOpen !== prevProps.menuIsOpen || inputValue !== prevProps.inputValue)) {
2425
- var focusableOptions = menuIsOpen ? buildFocusableOptions(props, selectValue) : [];
2426
- var focusableOptionsWithIds = menuIsOpen ? buildFocusableOptionsWithIds(buildCategorizedOptions(props, selectValue), "".concat(instancePrefix, "-option")) : [];
2427
- var focusedValue = clearFocusValueOnUpdate ? getNextFocusedValue(state, selectValue) : null;
2428
- var focusedOption = getNextFocusedOption(state, focusableOptions);
2429
- var focusedOptionId = getFocusedOptionId(focusableOptionsWithIds, focusedOption);
2430
- newMenuOptionsState = {
2431
- selectValue,
2432
- focusedOption,
2433
- focusedOptionId,
2434
- focusableOptionsWithIds,
2435
- focusedValue,
2436
- clearFocusValueOnUpdate: false
2437
- };
2438
- }
2439
- var newInputIsHiddenState = inputIsHiddenAfterUpdate != null && props !== prevProps ? {
2440
- inputIsHidden: inputIsHiddenAfterUpdate,
2441
- inputIsHiddenAfterUpdate: void 0
2442
- } : {};
2443
- var newAriaSelection = ariaSelection;
2444
- var hasKeptFocus = isFocused && prevWasFocused;
2445
- if (isFocused && !hasKeptFocus) {
2446
- newAriaSelection = {
2447
- value: valueTernary(isMulti, selectValue, selectValue[0] || null),
2448
- options: selectValue,
2449
- action: "initial-input-focus"
2450
- };
2451
- hasKeptFocus = !prevWasFocused;
2452
- }
2453
- if ((ariaSelection === null || ariaSelection === void 0 ? void 0 : ariaSelection.action) === "initial-input-focus") {
2454
- newAriaSelection = null;
2455
- }
2456
- return _objectSpread2(_objectSpread2(_objectSpread2({}, newMenuOptionsState), newInputIsHiddenState), {}, {
2457
- prevProps: props,
2458
- ariaSelection: newAriaSelection,
2459
- prevWasFocused: hasKeptFocus
2460
- });
2461
- }
2462
- }]);
2463
- return Select2;
2464
- }(Component);
2465
- Select.defaultProps = defaultProps;
2466
- export {
2467
- Select as S,
2468
- useStateManager as u
2469
- };