1 | 'use strict';
|
2 |
|
3 | var _extends = require('@babel/runtime/helpers/extends');
|
4 | var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
5 | var _classCallCheck = require('@babel/runtime/helpers/classCallCheck');
|
6 | var _createClass = require('@babel/runtime/helpers/createClass');
|
7 | var _inherits = require('@babel/runtime/helpers/inherits');
|
8 | var _createSuper = require('@babel/runtime/helpers/createSuper');
|
9 | var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
10 | var React = require('react');
|
11 | var index = require('./index-d1cb43f3.cjs.dev.js');
|
12 | var react = require('@emotion/react');
|
13 | var memoizeOne = require('memoize-one');
|
14 | var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
15 |
|
16 | function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
17 |
|
18 | function _interopNamespace(e) {
|
19 | if (e && e.__esModule) return e;
|
20 | var n = Object.create(null);
|
21 | if (e) {
|
22 | Object.keys(e).forEach(function (k) {
|
23 | if (k !== 'default') {
|
24 | var d = Object.getOwnPropertyDescriptor(e, k);
|
25 | Object.defineProperty(n, k, d.get ? d : {
|
26 | enumerable: true,
|
27 | get: function () { return e[k]; }
|
28 | });
|
29 | }
|
30 | });
|
31 | }
|
32 | n["default"] = e;
|
33 | return Object.freeze(n);
|
34 | }
|
35 |
|
36 | var React__namespace = _interopNamespace(React);
|
37 | var memoizeOne__default = _interopDefault(memoizeOne);
|
38 |
|
39 | function _EMOTION_STRINGIFIED_CSS_ERROR__$2() { 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)."; }
|
40 |
|
41 |
|
42 | var _ref = process.env.NODE_ENV === "production" ? {
|
43 | name: "7pg0cj-a11yText",
|
44 | 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"
|
45 | } : {
|
46 | name: "1f43avz-a11yText-A11yText",
|
47 | 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;",
|
48 | map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkExMXlUZXh0LnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFNSSIsImZpbGUiOiJBMTF5VGV4dC50c3giLCJzb3VyY2VzQ29udGVudCI6WyIvKiogQGpzeCBqc3ggKi9cbmltcG9ydCB7IGpzeCB9IGZyb20gJ0BlbW90aW9uL3JlYWN0JztcblxuLy8gQXNzaXN0aXZlIHRleHQgdG8gZGVzY3JpYmUgdmlzdWFsIGVsZW1lbnRzLiBIaWRkZW4gZm9yIHNpZ2h0ZWQgdXNlcnMuXG5jb25zdCBBMTF5VGV4dCA9IChwcm9wczogSlNYLkludHJpbnNpY0VsZW1lbnRzWydzcGFuJ10pID0+IChcbiAgPHNwYW5cbiAgICBjc3M9e3tcbiAgICAgIGxhYmVsOiAnYTExeVRleHQnLFxuICAgICAgekluZGV4OiA5OTk5LFxuICAgICAgYm9yZGVyOiAwLFxuICAgICAgY2xpcDogJ3JlY3QoMXB4LCAxcHgsIDFweCwgMXB4KScsXG4gICAgICBoZWlnaHQ6IDEsXG4gICAgICB3aWR0aDogMSxcbiAgICAgIHBvc2l0aW9uOiAnYWJzb2x1dGUnLFxuICAgICAgb3ZlcmZsb3c6ICdoaWRkZW4nLFxuICAgICAgcGFkZGluZzogMCxcbiAgICAgIHdoaXRlU3BhY2U6ICdub3dyYXAnLFxuICAgIH19XG4gICAgey4uLnByb3BzfVxuICAvPlxuKTtcblxuZXhwb3J0IGRlZmF1bHQgQTExeVRleHQ7XG4iXX0= */",
|
49 | toString: _EMOTION_STRINGIFIED_CSS_ERROR__$2
|
50 | };
|
51 | var A11yText = function A11yText(props) {
|
52 | return react.jsx("span", _extends({
|
53 | css: _ref
|
54 | }, props));
|
55 | };
|
56 | var A11yText$1 = A11yText;
|
57 |
|
58 | var defaultAriaLiveMessages = {
|
59 | guidance: function guidance(props) {
|
60 | var isSearchable = props.isSearchable,
|
61 | isMulti = props.isMulti,
|
62 | tabSelectsValue = props.tabSelectsValue,
|
63 | context = props.context,
|
64 | isInitialFocus = props.isInitialFocus;
|
65 | switch (context) {
|
66 | case 'menu':
|
67 | 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' : '', ".");
|
68 | case 'input':
|
69 | 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' : '') : '';
|
70 | case 'value':
|
71 | return 'Use left and right to toggle between focused values, press Backspace to remove the currently focused value';
|
72 | default:
|
73 | return '';
|
74 | }
|
75 | },
|
76 | onChange: function onChange(props) {
|
77 | var action = props.action,
|
78 | _props$label = props.label,
|
79 | label = _props$label === void 0 ? '' : _props$label,
|
80 | labels = props.labels,
|
81 | isDisabled = props.isDisabled;
|
82 | switch (action) {
|
83 | case 'deselect-option':
|
84 | case 'pop-value':
|
85 | case 'remove-value':
|
86 | return "option ".concat(label, ", deselected.");
|
87 | case 'clear':
|
88 | return 'All selected options have been cleared.';
|
89 | case 'initial-input-focus':
|
90 | return "option".concat(labels.length > 1 ? 's' : '', " ").concat(labels.join(','), ", selected.");
|
91 | case 'select-option':
|
92 | return isDisabled ? "option ".concat(label, " is disabled. Select another option.") : "option ".concat(label, ", selected.");
|
93 | default:
|
94 | return '';
|
95 | }
|
96 | },
|
97 | onFocus: function onFocus(props) {
|
98 | var context = props.context,
|
99 | focused = props.focused,
|
100 | options = props.options,
|
101 | _props$label2 = props.label,
|
102 | label = _props$label2 === void 0 ? '' : _props$label2,
|
103 | selectValue = props.selectValue,
|
104 | isDisabled = props.isDisabled,
|
105 | isSelected = props.isSelected,
|
106 | isAppleDevice = props.isAppleDevice;
|
107 | var getArrayIndex = function getArrayIndex(arr, item) {
|
108 | return arr && arr.length ? "".concat(arr.indexOf(item) + 1, " of ").concat(arr.length) : '';
|
109 | };
|
110 | if (context === 'value' && selectValue) {
|
111 | return "value ".concat(label, " focused, ").concat(getArrayIndex(selectValue, focused), ".");
|
112 | }
|
113 | if (context === 'menu' && isAppleDevice) {
|
114 | var disabled = isDisabled ? ' disabled' : '';
|
115 | var status = "".concat(isSelected ? ' selected' : '').concat(disabled);
|
116 | return "".concat(label).concat(status, ", ").concat(getArrayIndex(options, focused), ".");
|
117 | }
|
118 | return '';
|
119 | },
|
120 | onFilter: function onFilter(props) {
|
121 | var inputValue = props.inputValue,
|
122 | resultsMessage = props.resultsMessage;
|
123 | return "".concat(resultsMessage).concat(inputValue ? ' for search term ' + inputValue : '', ".");
|
124 | }
|
125 | };
|
126 |
|
127 | var LiveRegion = function LiveRegion(props) {
|
128 | var ariaSelection = props.ariaSelection,
|
129 | focusedOption = props.focusedOption,
|
130 | focusedValue = props.focusedValue,
|
131 | focusableOptions = props.focusableOptions,
|
132 | isFocused = props.isFocused,
|
133 | selectValue = props.selectValue,
|
134 | selectProps = props.selectProps,
|
135 | id = props.id,
|
136 | isAppleDevice = props.isAppleDevice;
|
137 | var ariaLiveMessages = selectProps.ariaLiveMessages,
|
138 | getOptionLabel = selectProps.getOptionLabel,
|
139 | inputValue = selectProps.inputValue,
|
140 | isMulti = selectProps.isMulti,
|
141 | isOptionDisabled = selectProps.isOptionDisabled,
|
142 | isSearchable = selectProps.isSearchable,
|
143 | menuIsOpen = selectProps.menuIsOpen,
|
144 | options = selectProps.options,
|
145 | screenReaderStatus = selectProps.screenReaderStatus,
|
146 | tabSelectsValue = selectProps.tabSelectsValue,
|
147 | isLoading = selectProps.isLoading;
|
148 | var ariaLabel = selectProps['aria-label'];
|
149 | var ariaLive = selectProps['aria-live'];
|
150 |
|
151 |
|
152 | var messages = React.useMemo(function () {
|
153 | return _objectSpread(_objectSpread({}, defaultAriaLiveMessages), ariaLiveMessages || {});
|
154 | }, [ariaLiveMessages]);
|
155 |
|
156 |
|
157 | var ariaSelected = React.useMemo(function () {
|
158 | var message = '';
|
159 | if (ariaSelection && messages.onChange) {
|
160 | var option = ariaSelection.option,
|
161 | selectedOptions = ariaSelection.options,
|
162 | removedValue = ariaSelection.removedValue,
|
163 | removedValues = ariaSelection.removedValues,
|
164 | value = ariaSelection.value;
|
165 |
|
166 | var asOption = function asOption(val) {
|
167 | return !Array.isArray(val) ? val : null;
|
168 | };
|
169 |
|
170 |
|
171 | var selected = removedValue || option || asOption(value);
|
172 | var label = selected ? getOptionLabel(selected) : '';
|
173 |
|
174 |
|
175 | var multiSelected = selectedOptions || removedValues || undefined;
|
176 | var labels = multiSelected ? multiSelected.map(getOptionLabel) : [];
|
177 | var onChangeProps = _objectSpread({
|
178 |
|
179 |
|
180 | isDisabled: selected && isOptionDisabled(selected, selectValue),
|
181 | label: label,
|
182 | labels: labels
|
183 | }, ariaSelection);
|
184 | message = messages.onChange(onChangeProps);
|
185 | }
|
186 | return message;
|
187 | }, [ariaSelection, messages, isOptionDisabled, selectValue, getOptionLabel]);
|
188 | var ariaFocused = React.useMemo(function () {
|
189 | var focusMsg = '';
|
190 | var focused = focusedOption || focusedValue;
|
191 | var isSelected = !!(focusedOption && selectValue && selectValue.includes(focusedOption));
|
192 | if (focused && messages.onFocus) {
|
193 | var onFocusProps = {
|
194 | focused: focused,
|
195 | label: getOptionLabel(focused),
|
196 | isDisabled: isOptionDisabled(focused, selectValue),
|
197 | isSelected: isSelected,
|
198 | options: focusableOptions,
|
199 | context: focused === focusedOption ? 'menu' : 'value',
|
200 | selectValue: selectValue,
|
201 | isAppleDevice: isAppleDevice
|
202 | };
|
203 | focusMsg = messages.onFocus(onFocusProps);
|
204 | }
|
205 | return focusMsg;
|
206 | }, [focusedOption, focusedValue, getOptionLabel, isOptionDisabled, messages, focusableOptions, selectValue, isAppleDevice]);
|
207 | var ariaResults = React.useMemo(function () {
|
208 | var resultsMsg = '';
|
209 | if (menuIsOpen && options.length && !isLoading && messages.onFilter) {
|
210 | var resultsMessage = screenReaderStatus({
|
211 | count: focusableOptions.length
|
212 | });
|
213 | resultsMsg = messages.onFilter({
|
214 | inputValue: inputValue,
|
215 | resultsMessage: resultsMessage
|
216 | });
|
217 | }
|
218 | return resultsMsg;
|
219 | }, [focusableOptions, inputValue, menuIsOpen, messages, options, screenReaderStatus, isLoading]);
|
220 | var isInitialFocus = (ariaSelection === null || ariaSelection === void 0 ? void 0 : ariaSelection.action) === 'initial-input-focus';
|
221 | var ariaGuidance = React.useMemo(function () {
|
222 | var guidanceMsg = '';
|
223 | if (messages.guidance) {
|
224 | var context = focusedValue ? 'value' : menuIsOpen ? 'menu' : 'input';
|
225 | guidanceMsg = messages.guidance({
|
226 | 'aria-label': ariaLabel,
|
227 | context: context,
|
228 | isDisabled: focusedOption && isOptionDisabled(focusedOption, selectValue),
|
229 | isMulti: isMulti,
|
230 | isSearchable: isSearchable,
|
231 | tabSelectsValue: tabSelectsValue,
|
232 | isInitialFocus: isInitialFocus
|
233 | });
|
234 | }
|
235 | return guidanceMsg;
|
236 | }, [ariaLabel, focusedOption, focusedValue, isMulti, isOptionDisabled, isSearchable, menuIsOpen, messages, selectValue, tabSelectsValue, isInitialFocus]);
|
237 | var ScreenReaderText = react.jsx(React.Fragment, null, react.jsx("span", {
|
238 | id: "aria-selection"
|
239 | }, ariaSelected), react.jsx("span", {
|
240 | id: "aria-focused"
|
241 | }, ariaFocused), react.jsx("span", {
|
242 | id: "aria-results"
|
243 | }, ariaResults), react.jsx("span", {
|
244 | id: "aria-guidance"
|
245 | }, ariaGuidance));
|
246 | return react.jsx(React.Fragment, null, react.jsx(A11yText$1, {
|
247 | id: id
|
248 | }, isInitialFocus && ScreenReaderText), react.jsx(A11yText$1, {
|
249 | "aria-live": ariaLive,
|
250 | "aria-atomic": "false",
|
251 | "aria-relevant": "additions text",
|
252 | role: "log"
|
253 | }, isFocused && !isInitialFocus && ScreenReaderText));
|
254 | };
|
255 | var LiveRegion$1 = LiveRegion;
|
256 |
|
257 | var diacritics = [{
|
258 | base: 'A',
|
259 | letters: "A\u24B6\uFF21\xC0\xC1\xC2\u1EA6\u1EA4\u1EAA\u1EA8\xC3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\xC4\u01DE\u1EA2\xC5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F"
|
260 | }, {
|
261 | base: 'AA',
|
262 | letters: "\uA732"
|
263 | }, {
|
264 | base: 'AE',
|
265 | letters: "\xC6\u01FC\u01E2"
|
266 | }, {
|
267 | base: 'AO',
|
268 | letters: "\uA734"
|
269 | }, {
|
270 | base: 'AU',
|
271 | letters: "\uA736"
|
272 | }, {
|
273 | base: 'AV',
|
274 | letters: "\uA738\uA73A"
|
275 | }, {
|
276 | base: 'AY',
|
277 | letters: "\uA73C"
|
278 | }, {
|
279 | base: 'B',
|
280 | letters: "B\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181"
|
281 | }, {
|
282 | base: 'C',
|
283 | letters: "C\u24B8\uFF23\u0106\u0108\u010A\u010C\xC7\u1E08\u0187\u023B\uA73E"
|
284 | }, {
|
285 | base: 'D',
|
286 | letters: "D\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018B\u018A\u0189\uA779"
|
287 | }, {
|
288 | base: 'DZ',
|
289 | letters: "\u01F1\u01C4"
|
290 | }, {
|
291 | base: 'Dz',
|
292 | letters: "\u01F2\u01C5"
|
293 | }, {
|
294 | base: 'E',
|
295 | letters: "E\u24BA\uFF25\xC8\xC9\xCA\u1EC0\u1EBE\u1EC4\u1EC2\u1EBC\u0112\u1E14\u1E16\u0114\u0116\xCB\u1EBA\u011A\u0204\u0206\u1EB8\u1EC6\u0228\u1E1C\u0118\u1E18\u1E1A\u0190\u018E"
|
296 | }, {
|
297 | base: 'F',
|
298 | letters: "F\u24BB\uFF26\u1E1E\u0191\uA77B"
|
299 | }, {
|
300 | base: 'G',
|
301 | letters: "G\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E"
|
302 | }, {
|
303 | base: 'H',
|
304 | letters: "H\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D"
|
305 | }, {
|
306 | base: 'I',
|
307 | letters: "I\u24BE\uFF29\xCC\xCD\xCE\u0128\u012A\u012C\u0130\xCF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197"
|
308 | }, {
|
309 | base: 'J',
|
310 | letters: "J\u24BF\uFF2A\u0134\u0248"
|
311 | }, {
|
312 | base: 'K',
|
313 | letters: "K\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2"
|
314 | }, {
|
315 | base: 'L',
|
316 | letters: "L\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780"
|
317 | }, {
|
318 | base: 'LJ',
|
319 | letters: "\u01C7"
|
320 | }, {
|
321 | base: 'Lj',
|
322 | letters: "\u01C8"
|
323 | }, {
|
324 | base: 'M',
|
325 | letters: "M\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C"
|
326 | }, {
|
327 | base: 'N',
|
328 | letters: "N\u24C3\uFF2E\u01F8\u0143\xD1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u0220\u019D\uA790\uA7A4"
|
329 | }, {
|
330 | base: 'NJ',
|
331 | letters: "\u01CA"
|
332 | }, {
|
333 | base: 'Nj',
|
334 | letters: "\u01CB"
|
335 | }, {
|
336 | base: 'O',
|
337 | letters: "O\u24C4\uFF2F\xD2\xD3\xD4\u1ED2\u1ED0\u1ED6\u1ED4\xD5\u1E4C\u022C\u1E4E\u014C\u1E50\u1E52\u014E\u022E\u0230\xD6\u022A\u1ECE\u0150\u01D1\u020C\u020E\u01A0\u1EDC\u1EDA\u1EE0\u1EDE\u1EE2\u1ECC\u1ED8\u01EA\u01EC\xD8\u01FE\u0186\u019F\uA74A\uA74C"
|
338 | }, {
|
339 | base: 'OI',
|
340 | letters: "\u01A2"
|
341 | }, {
|
342 | base: 'OO',
|
343 | letters: "\uA74E"
|
344 | }, {
|
345 | base: 'OU',
|
346 | letters: "\u0222"
|
347 | }, {
|
348 | base: 'P',
|
349 | letters: "P\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754"
|
350 | }, {
|
351 | base: 'Q',
|
352 | letters: "Q\u24C6\uFF31\uA756\uA758\u024A"
|
353 | }, {
|
354 | base: 'R',
|
355 | letters: "R\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782"
|
356 | }, {
|
357 | base: 'S',
|
358 | letters: "S\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784"
|
359 | }, {
|
360 | base: 'T',
|
361 | letters: "T\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786"
|
362 | }, {
|
363 | base: 'TZ',
|
364 | letters: "\uA728"
|
365 | }, {
|
366 | base: 'U',
|
367 | letters: "U\u24CA\uFF35\xD9\xDA\xDB\u0168\u1E78\u016A\u1E7A\u016C\xDC\u01DB\u01D7\u01D5\u01D9\u1EE6\u016E\u0170\u01D3\u0214\u0216\u01AF\u1EEA\u1EE8\u1EEE\u1EEC\u1EF0\u1EE4\u1E72\u0172\u1E76\u1E74\u0244"
|
368 | }, {
|
369 | base: 'V',
|
370 | letters: "V\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245"
|
371 | }, {
|
372 | base: 'VY',
|
373 | letters: "\uA760"
|
374 | }, {
|
375 | base: 'W',
|
376 | letters: "W\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72"
|
377 | }, {
|
378 | base: 'X',
|
379 | letters: "X\u24CD\uFF38\u1E8A\u1E8C"
|
380 | }, {
|
381 | base: 'Y',
|
382 | letters: "Y\u24CE\uFF39\u1EF2\xDD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE"
|
383 | }, {
|
384 | base: 'Z',
|
385 | letters: "Z\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762"
|
386 | }, {
|
387 | base: 'a',
|
388 | letters: "a\u24D0\uFF41\u1E9A\xE0\xE1\xE2\u1EA7\u1EA5\u1EAB\u1EA9\xE3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\xE4\u01DF\u1EA3\xE5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250"
|
389 | }, {
|
390 | base: 'aa',
|
391 | letters: "\uA733"
|
392 | }, {
|
393 | base: 'ae',
|
394 | letters: "\xE6\u01FD\u01E3"
|
395 | }, {
|
396 | base: 'ao',
|
397 | letters: "\uA735"
|
398 | }, {
|
399 | base: 'au',
|
400 | letters: "\uA737"
|
401 | }, {
|
402 | base: 'av',
|
403 | letters: "\uA739\uA73B"
|
404 | }, {
|
405 | base: 'ay',
|
406 | letters: "\uA73D"
|
407 | }, {
|
408 | base: 'b',
|
409 | letters: "b\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253"
|
410 | }, {
|
411 | base: 'c',
|
412 | letters: "c\u24D2\uFF43\u0107\u0109\u010B\u010D\xE7\u1E09\u0188\u023C\uA73F\u2184"
|
413 | }, {
|
414 | base: 'd',
|
415 | letters: "d\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\uA77A"
|
416 | }, {
|
417 | base: 'dz',
|
418 | letters: "\u01F3\u01C6"
|
419 | }, {
|
420 | base: 'e',
|
421 | letters: "e\u24D4\uFF45\xE8\xE9\xEA\u1EC1\u1EBF\u1EC5\u1EC3\u1EBD\u0113\u1E15\u1E17\u0115\u0117\xEB\u1EBB\u011B\u0205\u0207\u1EB9\u1EC7\u0229\u1E1D\u0119\u1E19\u1E1B\u0247\u025B\u01DD"
|
422 | }, {
|
423 | base: 'f',
|
424 | letters: "f\u24D5\uFF46\u1E1F\u0192\uA77C"
|
425 | }, {
|
426 | base: 'g',
|
427 | letters: "g\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F"
|
428 | }, {
|
429 | base: 'h',
|
430 | letters: "h\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265"
|
431 | }, {
|
432 | base: 'hv',
|
433 | letters: "\u0195"
|
434 | }, {
|
435 | base: 'i',
|
436 | letters: "i\u24D8\uFF49\xEC\xED\xEE\u0129\u012B\u012D\xEF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131"
|
437 | }, {
|
438 | base: 'j',
|
439 | letters: "j\u24D9\uFF4A\u0135\u01F0\u0249"
|
440 | }, {
|
441 | base: 'k',
|
442 | letters: "k\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3"
|
443 | }, {
|
444 | base: 'l',
|
445 | letters: "l\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747"
|
446 | }, {
|
447 | base: 'lj',
|
448 | letters: "\u01C9"
|
449 | }, {
|
450 | base: 'm',
|
451 | letters: "m\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F"
|
452 | }, {
|
453 | base: 'n',
|
454 | letters: "n\u24DD\uFF4E\u01F9\u0144\xF1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5"
|
455 | }, {
|
456 | base: 'nj',
|
457 | letters: "\u01CC"
|
458 | }, {
|
459 | base: 'o',
|
460 | letters: "o\u24DE\uFF4F\xF2\xF3\xF4\u1ED3\u1ED1\u1ED7\u1ED5\xF5\u1E4D\u022D\u1E4F\u014D\u1E51\u1E53\u014F\u022F\u0231\xF6\u022B\u1ECF\u0151\u01D2\u020D\u020F\u01A1\u1EDD\u1EDB\u1EE1\u1EDF\u1EE3\u1ECD\u1ED9\u01EB\u01ED\xF8\u01FF\u0254\uA74B\uA74D\u0275"
|
461 | }, {
|
462 | base: 'oi',
|
463 | letters: "\u01A3"
|
464 | }, {
|
465 | base: 'ou',
|
466 | letters: "\u0223"
|
467 | }, {
|
468 | base: 'oo',
|
469 | letters: "\uA74F"
|
470 | }, {
|
471 | base: 'p',
|
472 | letters: "p\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755"
|
473 | }, {
|
474 | base: 'q',
|
475 | letters: "q\u24E0\uFF51\u024B\uA757\uA759"
|
476 | }, {
|
477 | base: 'r',
|
478 | letters: "r\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783"
|
479 | }, {
|
480 | base: 's',
|
481 | letters: "s\u24E2\uFF53\xDF\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B"
|
482 | }, {
|
483 | base: 't',
|
484 | letters: "t\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787"
|
485 | }, {
|
486 | base: 'tz',
|
487 | letters: "\uA729"
|
488 | }, {
|
489 | base: 'u',
|
490 | letters: "u\u24E4\uFF55\xF9\xFA\xFB\u0169\u1E79\u016B\u1E7B\u016D\xFC\u01DC\u01D8\u01D6\u01DA\u1EE7\u016F\u0171\u01D4\u0215\u0217\u01B0\u1EEB\u1EE9\u1EEF\u1EED\u1EF1\u1EE5\u1E73\u0173\u1E77\u1E75\u0289"
|
491 | }, {
|
492 | base: 'v',
|
493 | letters: "v\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C"
|
494 | }, {
|
495 | base: 'vy',
|
496 | letters: "\uA761"
|
497 | }, {
|
498 | base: 'w',
|
499 | letters: "w\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73"
|
500 | }, {
|
501 | base: 'x',
|
502 | letters: "x\u24E7\uFF58\u1E8B\u1E8D"
|
503 | }, {
|
504 | base: 'y',
|
505 | letters: "y\u24E8\uFF59\u1EF3\xFD\u0177\u1EF9\u0233\u1E8F\xFF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF"
|
506 | }, {
|
507 | base: 'z',
|
508 | letters: "z\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763"
|
509 | }];
|
510 | var anyDiacritic = new RegExp('[' + diacritics.map(function (d) {
|
511 | return d.letters;
|
512 | }).join('') + ']', 'g');
|
513 | var diacriticToBase = {};
|
514 | for (var i = 0; i < diacritics.length; i++) {
|
515 | var diacritic = diacritics[i];
|
516 | for (var j = 0; j < diacritic.letters.length; j++) {
|
517 | diacriticToBase[diacritic.letters[j]] = diacritic.base;
|
518 | }
|
519 | }
|
520 | var stripDiacritics = function stripDiacritics(str) {
|
521 | return str.replace(anyDiacritic, function (match) {
|
522 | return diacriticToBase[match];
|
523 | });
|
524 | };
|
525 |
|
526 | var memoizedStripDiacriticsForInput = memoizeOne__default["default"](stripDiacritics);
|
527 | var trimString = function trimString(str) {
|
528 | return str.replace(/^\s+|\s+$/g, '');
|
529 | };
|
530 | var defaultStringify = function defaultStringify(option) {
|
531 | return "".concat(option.label, " ").concat(option.value);
|
532 | };
|
533 | var createFilter = function createFilter(config) {
|
534 | return function (option, rawInput) {
|
535 |
|
536 | if (option.data.__isNew__) return true;
|
537 | var _ignoreCase$ignoreAcc = _objectSpread({
|
538 | ignoreCase: true,
|
539 | ignoreAccents: true,
|
540 | stringify: defaultStringify,
|
541 | trim: true,
|
542 | matchFrom: 'any'
|
543 | }, config),
|
544 | ignoreCase = _ignoreCase$ignoreAcc.ignoreCase,
|
545 | ignoreAccents = _ignoreCase$ignoreAcc.ignoreAccents,
|
546 | stringify = _ignoreCase$ignoreAcc.stringify,
|
547 | trim = _ignoreCase$ignoreAcc.trim,
|
548 | matchFrom = _ignoreCase$ignoreAcc.matchFrom;
|
549 | var input = trim ? trimString(rawInput) : rawInput;
|
550 | var candidate = trim ? trimString(stringify(option)) : stringify(option);
|
551 | if (ignoreCase) {
|
552 | input = input.toLowerCase();
|
553 | candidate = candidate.toLowerCase();
|
554 | }
|
555 | if (ignoreAccents) {
|
556 | input = memoizedStripDiacriticsForInput(input);
|
557 | candidate = stripDiacritics(candidate);
|
558 | }
|
559 | return matchFrom === 'start' ? candidate.substr(0, input.length) === input : candidate.indexOf(input) > -1;
|
560 | };
|
561 | };
|
562 |
|
563 | var _excluded = ["innerRef"];
|
564 | function DummyInput(_ref) {
|
565 | var innerRef = _ref.innerRef,
|
566 | props = _objectWithoutProperties(_ref, _excluded);
|
567 |
|
568 | var filteredProps = index.removeProps(props, 'onExited', 'in', 'enter', 'exit', 'appear');
|
569 | return react.jsx("input", _extends({
|
570 | ref: innerRef
|
571 | }, filteredProps, {
|
572 | css: react.css({
|
573 | label: 'dummyInput',
|
574 |
|
575 | background: 0,
|
576 | border: 0,
|
577 |
|
578 | caretColor: 'transparent',
|
579 | fontSize: 'inherit',
|
580 | gridArea: '1 / 1 / 2 / 3',
|
581 | outline: 0,
|
582 | padding: 0,
|
583 |
|
584 | width: 1,
|
585 |
|
586 | color: 'transparent',
|
587 |
|
588 | left: -100,
|
589 | opacity: 0,
|
590 | position: 'relative',
|
591 | transform: 'scale(.01)'
|
592 | }, process.env.NODE_ENV === "production" ? "" : ";label:DummyInput;", process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkR1bW15SW5wdXQudHN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQXlCTSIsImZpbGUiOiJEdW1teUlucHV0LnRzeCIsInNvdXJjZXNDb250ZW50IjpbIi8qKiBAanN4IGpzeCAqL1xuaW1wb3J0IHsgUmVmIH0gZnJvbSAncmVhY3QnO1xuaW1wb3J0IHsganN4IH0gZnJvbSAnQGVtb3Rpb24vcmVhY3QnO1xuaW1wb3J0IHsgcmVtb3ZlUHJvcHMgfSBmcm9tICcuLi91dGlscyc7XG5cbmV4cG9ydCBkZWZhdWx0IGZ1bmN0aW9uIER1bW15SW5wdXQoe1xuICBpbm5lclJlZixcbiAgLi4ucHJvcHNcbn06IEpTWC5JbnRyaW5zaWNFbGVtZW50c1snaW5wdXQnXSAmIHtcbiAgcmVhZG9ubHkgaW5uZXJSZWY6IFJlZjxIVE1MSW5wdXRFbGVtZW50Pjtcbn0pIHtcbiAgLy8gUmVtb3ZlIGFuaW1hdGlvbiBwcm9wcyBub3QgbWVhbnQgZm9yIEhUTUwgZWxlbWVudHNcbiAgY29uc3QgZmlsdGVyZWRQcm9wcyA9IHJlbW92ZVByb3BzKFxuICAgIHByb3BzLFxuICAgICdvbkV4aXRlZCcsXG4gICAgJ2luJyxcbiAgICAnZW50ZXInLFxuICAgICdleGl0JyxcbiAgICAnYXBwZWFyJ1xuICApO1xuXG4gIHJldHVybiAoXG4gICAgPGlucHV0XG4gICAgICByZWY9e2lubmVyUmVmfVxuICAgICAgey4uLmZpbHRlcmVkUHJvcHN9XG4gICAgICBjc3M9e3tcbiAgICAgICAgbGFiZWw6ICdkdW1teUlucHV0JyxcbiAgICAgICAgLy8gZ2V0IHJpZCBvZiBhbnkgZGVmYXVsdCBzdHlsZXNcbiAgICAgICAgYmFja2dyb3VuZDogMCxcbiAgICAgICAgYm9yZGVyOiAwLFxuICAgICAgICAvLyBpbXBvcnRhbnQhIHRoaXMgaGlkZXMgdGhlIGZsYXNoaW5nIGN1cnNvclxuICAgICAgICBjYXJldENvbG9yOiAndHJhbnNwYXJlbnQnLFxuICAgICAgICBmb250U2l6ZTogJ2luaGVyaXQnLFxuICAgICAgICBncmlkQXJlYTogJzEgLyAxIC8gMiAvIDMnLFxuICAgICAgICBvdXRsaW5lOiAwLFxuICAgICAgICBwYWRkaW5nOiAwLFxuICAgICAgICAvLyBpbXBvcnRhbnQhIHdpdGhvdXQgYHdpZHRoYCBicm93c2VycyB3b24ndCBhbGxvdyBmb2N1c1xuICAgICAgICB3aWR0aDogMSxcblxuICAgICAgICAvLyByZW1vdmUgY3Vyc29yIG9uIGRlc2t0b3BcbiAgICAgICAgY29sb3I6ICd0cmFuc3BhcmVudCcsXG5cbiAgICAgICAgLy8gcmVtb3ZlIGN1cnNvciBvbiBtb2JpbGUgd2hpbHN0IG1haW50YWluaW5nIFwic2Nyb2xsIGludG8gdmlld1wiIGJlaGF2aW91clxuICAgICAgICBsZWZ0OiAtMTAwLFxuICAgICAgICBvcGFjaXR5OiAwLFxuICAgICAgICBwb3NpdGlvbjogJ3JlbGF0aXZlJyxcbiAgICAgICAgdHJhbnNmb3JtOiAnc2NhbGUoLjAxKScsXG4gICAgICB9fVxuICAgIC8+XG4gICk7XG59XG4iXX0= */")
|
593 | }));
|
594 | }
|
595 |
|
596 | var cancelScroll = function cancelScroll(event) {
|
597 | if (event.cancelable) event.preventDefault();
|
598 | event.stopPropagation();
|
599 | };
|
600 | function useScrollCapture(_ref) {
|
601 | var isEnabled = _ref.isEnabled,
|
602 | onBottomArrive = _ref.onBottomArrive,
|
603 | onBottomLeave = _ref.onBottomLeave,
|
604 | onTopArrive = _ref.onTopArrive,
|
605 | onTopLeave = _ref.onTopLeave;
|
606 | var isBottom = React.useRef(false);
|
607 | var isTop = React.useRef(false);
|
608 | var touchStart = React.useRef(0);
|
609 | var scrollTarget = React.useRef(null);
|
610 | var handleEventDelta = React.useCallback(function (event, delta) {
|
611 | if (scrollTarget.current === null) return;
|
612 | var _scrollTarget$current = scrollTarget.current,
|
613 | scrollTop = _scrollTarget$current.scrollTop,
|
614 | scrollHeight = _scrollTarget$current.scrollHeight,
|
615 | clientHeight = _scrollTarget$current.clientHeight;
|
616 | var target = scrollTarget.current;
|
617 | var isDeltaPositive = delta > 0;
|
618 | var availableScroll = scrollHeight - clientHeight - scrollTop;
|
619 | var shouldCancelScroll = false;
|
620 |
|
621 |
|
622 | if (availableScroll > delta && isBottom.current) {
|
623 | if (onBottomLeave) onBottomLeave(event);
|
624 | isBottom.current = false;
|
625 | }
|
626 | if (isDeltaPositive && isTop.current) {
|
627 | if (onTopLeave) onTopLeave(event);
|
628 | isTop.current = false;
|
629 | }
|
630 |
|
631 |
|
632 | if (isDeltaPositive && delta > availableScroll) {
|
633 | if (onBottomArrive && !isBottom.current) {
|
634 | onBottomArrive(event);
|
635 | }
|
636 | target.scrollTop = scrollHeight;
|
637 | shouldCancelScroll = true;
|
638 | isBottom.current = true;
|
639 |
|
640 |
|
641 | } else if (!isDeltaPositive && -delta > scrollTop) {
|
642 | if (onTopArrive && !isTop.current) {
|
643 | onTopArrive(event);
|
644 | }
|
645 | target.scrollTop = 0;
|
646 | shouldCancelScroll = true;
|
647 | isTop.current = true;
|
648 | }
|
649 |
|
650 |
|
651 | if (shouldCancelScroll) {
|
652 | cancelScroll(event);
|
653 | }
|
654 | }, [onBottomArrive, onBottomLeave, onTopArrive, onTopLeave]);
|
655 | var onWheel = React.useCallback(function (event) {
|
656 | handleEventDelta(event, event.deltaY);
|
657 | }, [handleEventDelta]);
|
658 | var onTouchStart = React.useCallback(function (event) {
|
659 |
|
660 | touchStart.current = event.changedTouches[0].clientY;
|
661 | }, []);
|
662 | var onTouchMove = React.useCallback(function (event) {
|
663 | var deltaY = touchStart.current - event.changedTouches[0].clientY;
|
664 | handleEventDelta(event, deltaY);
|
665 | }, [handleEventDelta]);
|
666 | var startListening = React.useCallback(function (el) {
|
667 |
|
668 | if (!el) return;
|
669 | var notPassive = index.supportsPassiveEvents ? {
|
670 | passive: false
|
671 | } : false;
|
672 | el.addEventListener('wheel', onWheel, notPassive);
|
673 | el.addEventListener('touchstart', onTouchStart, notPassive);
|
674 | el.addEventListener('touchmove', onTouchMove, notPassive);
|
675 | }, [onTouchMove, onTouchStart, onWheel]);
|
676 | var stopListening = React.useCallback(function (el) {
|
677 |
|
678 | if (!el) return;
|
679 | el.removeEventListener('wheel', onWheel, false);
|
680 | el.removeEventListener('touchstart', onTouchStart, false);
|
681 | el.removeEventListener('touchmove', onTouchMove, false);
|
682 | }, [onTouchMove, onTouchStart, onWheel]);
|
683 | React.useEffect(function () {
|
684 | if (!isEnabled) return;
|
685 | var element = scrollTarget.current;
|
686 | startListening(element);
|
687 | return function () {
|
688 | stopListening(element);
|
689 | };
|
690 | }, [isEnabled, startListening, stopListening]);
|
691 | return function (element) {
|
692 | scrollTarget.current = element;
|
693 | };
|
694 | }
|
695 |
|
696 | var STYLE_KEYS = ['boxSizing', 'height', 'overflow', 'paddingRight', 'position'];
|
697 | var LOCK_STYLES = {
|
698 | boxSizing: 'border-box',
|
699 |
|
700 | overflow: 'hidden',
|
701 | position: 'relative',
|
702 | height: '100%'
|
703 | };
|
704 | function preventTouchMove(e) {
|
705 | e.preventDefault();
|
706 | }
|
707 | function allowTouchMove(e) {
|
708 | e.stopPropagation();
|
709 | }
|
710 | function preventInertiaScroll() {
|
711 | var top = this.scrollTop;
|
712 | var totalScroll = this.scrollHeight;
|
713 | var currentScroll = top + this.offsetHeight;
|
714 | if (top === 0) {
|
715 | this.scrollTop = 1;
|
716 | } else if (currentScroll === totalScroll) {
|
717 | this.scrollTop = top - 1;
|
718 | }
|
719 | }
|
720 |
|
721 |
|
722 |
|
723 | function isTouchDevice() {
|
724 | return 'ontouchstart' in window || navigator.maxTouchPoints;
|
725 | }
|
726 | var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
|
727 | var activeScrollLocks = 0;
|
728 | var listenerOptions = {
|
729 | capture: false,
|
730 | passive: false
|
731 | };
|
732 | function useScrollLock(_ref) {
|
733 | var isEnabled = _ref.isEnabled,
|
734 | _ref$accountForScroll = _ref.accountForScrollbars,
|
735 | accountForScrollbars = _ref$accountForScroll === void 0 ? true : _ref$accountForScroll;
|
736 | var originalStyles = React.useRef({});
|
737 | var scrollTarget = React.useRef(null);
|
738 | var addScrollLock = React.useCallback(function (touchScrollTarget) {
|
739 | if (!canUseDOM) return;
|
740 | var target = document.body;
|
741 | var targetStyle = target && target.style;
|
742 | if (accountForScrollbars) {
|
743 |
|
744 | STYLE_KEYS.forEach(function (key) {
|
745 | var val = targetStyle && targetStyle[key];
|
746 | originalStyles.current[key] = val;
|
747 | });
|
748 | }
|
749 |
|
750 |
|
751 | if (accountForScrollbars && activeScrollLocks < 1) {
|
752 | var currentPadding = parseInt(originalStyles.current.paddingRight, 10) || 0;
|
753 | var clientWidth = document.body ? document.body.clientWidth : 0;
|
754 | var adjustedPadding = window.innerWidth - clientWidth + currentPadding || 0;
|
755 | Object.keys(LOCK_STYLES).forEach(function (key) {
|
756 | var val = LOCK_STYLES[key];
|
757 | if (targetStyle) {
|
758 | targetStyle[key] = val;
|
759 | }
|
760 | });
|
761 | if (targetStyle) {
|
762 | targetStyle.paddingRight = "".concat(adjustedPadding, "px");
|
763 | }
|
764 | }
|
765 |
|
766 |
|
767 | if (target && isTouchDevice()) {
|
768 |
|
769 | target.addEventListener('touchmove', preventTouchMove, listenerOptions);
|
770 |
|
771 |
|
772 | if (touchScrollTarget) {
|
773 | touchScrollTarget.addEventListener('touchstart', preventInertiaScroll, listenerOptions);
|
774 | touchScrollTarget.addEventListener('touchmove', allowTouchMove, listenerOptions);
|
775 | }
|
776 | }
|
777 |
|
778 |
|
779 | activeScrollLocks += 1;
|
780 | }, [accountForScrollbars]);
|
781 | var removeScrollLock = React.useCallback(function (touchScrollTarget) {
|
782 | if (!canUseDOM) return;
|
783 | var target = document.body;
|
784 | var targetStyle = target && target.style;
|
785 |
|
786 |
|
787 | activeScrollLocks = Math.max(activeScrollLocks - 1, 0);
|
788 |
|
789 |
|
790 | if (accountForScrollbars && activeScrollLocks < 1) {
|
791 | STYLE_KEYS.forEach(function (key) {
|
792 | var val = originalStyles.current[key];
|
793 | if (targetStyle) {
|
794 | targetStyle[key] = val;
|
795 | }
|
796 | });
|
797 | }
|
798 |
|
799 |
|
800 | if (target && isTouchDevice()) {
|
801 | target.removeEventListener('touchmove', preventTouchMove, listenerOptions);
|
802 | if (touchScrollTarget) {
|
803 | touchScrollTarget.removeEventListener('touchstart', preventInertiaScroll, listenerOptions);
|
804 | touchScrollTarget.removeEventListener('touchmove', allowTouchMove, listenerOptions);
|
805 | }
|
806 | }
|
807 | }, [accountForScrollbars]);
|
808 | React.useEffect(function () {
|
809 | if (!isEnabled) return;
|
810 | var element = scrollTarget.current;
|
811 | addScrollLock(element);
|
812 | return function () {
|
813 | removeScrollLock(element);
|
814 | };
|
815 | }, [isEnabled, addScrollLock, removeScrollLock]);
|
816 | return function (element) {
|
817 | scrollTarget.current = element;
|
818 | };
|
819 | }
|
820 |
|
821 | function _EMOTION_STRINGIFIED_CSS_ERROR__$1() { 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)."; }
|
822 | var blurSelectInput = function blurSelectInput(event) {
|
823 | var element = event.target;
|
824 | return element.ownerDocument.activeElement && element.ownerDocument.activeElement.blur();
|
825 | };
|
826 | var _ref2$1 = process.env.NODE_ENV === "production" ? {
|
827 | name: "1kfdb0e",
|
828 | styles: "position:fixed;left:0;bottom:0;right:0;top:0"
|
829 | } : {
|
830 | name: "bp8cua-ScrollManager",
|
831 | styles: "position:fixed;left:0;bottom:0;right:0;top:0;label:ScrollManager;",
|
832 | map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIlNjcm9sbE1hbmFnZXIudHN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQW9EVSIsImZpbGUiOiJTY3JvbGxNYW5hZ2VyLnRzeCIsInNvdXJjZXNDb250ZW50IjpbIi8qKiBAanN4IGpzeCAqL1xuaW1wb3J0IHsganN4IH0gZnJvbSAnQGVtb3Rpb24vcmVhY3QnO1xuaW1wb3J0IHsgRnJhZ21lbnQsIFJlYWN0RWxlbWVudCwgUmVmQ2FsbGJhY2ssIE1vdXNlRXZlbnQgfSBmcm9tICdyZWFjdCc7XG5pbXBvcnQgdXNlU2Nyb2xsQ2FwdHVyZSBmcm9tICcuL3VzZVNjcm9sbENhcHR1cmUnO1xuaW1wb3J0IHVzZVNjcm9sbExvY2sgZnJvbSAnLi91c2VTY3JvbGxMb2NrJztcblxuaW50ZXJmYWNlIFByb3BzIHtcbiAgcmVhZG9ubHkgY2hpbGRyZW46IChyZWY6IFJlZkNhbGxiYWNrPEhUTUxFbGVtZW50PikgPT4gUmVhY3RFbGVtZW50O1xuICByZWFkb25seSBsb2NrRW5hYmxlZDogYm9vbGVhbjtcbiAgcmVhZG9ubHkgY2FwdHVyZUVuYWJsZWQ6IGJvb2xlYW47XG4gIHJlYWRvbmx5IG9uQm90dG9tQXJyaXZlPzogKGV2ZW50OiBXaGVlbEV2ZW50IHwgVG91Y2hFdmVudCkgPT4gdm9pZDtcbiAgcmVhZG9ubHkgb25Cb3R0b21MZWF2ZT86IChldmVudDogV2hlZWxFdmVudCB8IFRvdWNoRXZlbnQpID0+IHZvaWQ7XG4gIHJlYWRvbmx5IG9uVG9wQXJyaXZlPzogKGV2ZW50OiBXaGVlbEV2ZW50IHwgVG91Y2hFdmVudCkgPT4gdm9pZDtcbiAgcmVhZG9ubHkgb25Ub3BMZWF2ZT86IChldmVudDogV2hlZWxFdmVudCB8IFRvdWNoRXZlbnQpID0+IHZvaWQ7XG59XG5cbmNvbnN0IGJsdXJTZWxlY3RJbnB1dCA9IChldmVudDogTW91c2VFdmVudDxIVE1MRGl2RWxlbWVudD4pID0+IHtcbiAgY29uc3QgZWxlbWVudCA9IGV2ZW50LnRhcmdldCBhcyBIVE1MRGl2RWxlbWVudDtcbiAgcmV0dXJuIChcbiAgICBlbGVtZW50Lm93bmVyRG9jdW1lbnQuYWN0aXZlRWxlbWVudCAmJlxuICAgIChlbGVtZW50Lm93bmVyRG9jdW1lbnQuYWN0aXZlRWxlbWVudCBhcyBIVE1MRWxlbWVudCkuYmx1cigpXG4gICk7XG59O1xuXG5leHBvcnQgZGVmYXVsdCBmdW5jdGlvbiBTY3JvbGxNYW5hZ2VyKHtcbiAgY2hpbGRyZW4sXG4gIGxvY2tFbmFibGVkLFxuICBjYXB0dXJlRW5hYmxlZCA9IHRydWUsXG4gIG9uQm90dG9tQXJyaXZlLFxuICBvbkJvdHRvbUxlYXZlLFxuICBvblRvcEFycml2ZSxcbiAgb25Ub3BMZWF2ZSxcbn06IFByb3BzKSB7XG4gIGNvbnN0IHNldFNjcm9sbENhcHR1cmVUYXJnZXQgPSB1c2VTY3JvbGxDYXB0dXJlKHtcbiAgICBpc0VuYWJsZWQ6IGNhcHR1cmVFbmFibGVkLFxuICAgIG9uQm90dG9tQXJyaXZlLFxuICAgIG9uQm90dG9tTGVhdmUsXG4gICAgb25Ub3BBcnJpdmUsXG4gICAgb25Ub3BMZWF2ZSxcbiAgfSk7XG4gIGNvbnN0IHNldFNjcm9sbExvY2tUYXJnZXQgPSB1c2VTY3JvbGxMb2NrKHsgaXNFbmFibGVkOiBsb2NrRW5hYmxlZCB9KTtcblxuICBjb25zdCB0YXJnZXRSZWY6IFJlZkNhbGxiYWNrPEhUTUxFbGVtZW50PiA9IChlbGVtZW50KSA9PiB7XG4gICAgc2V0U2Nyb2xsQ2FwdHVyZVRhcmdldChlbGVtZW50KTtcbiAgICBzZXRTY3JvbGxMb2NrVGFyZ2V0KGVsZW1lbnQpO1xuICB9O1xuXG4gIHJldHVybiAoXG4gICAgPEZyYWdtZW50PlxuICAgICAge2xvY2tFbmFibGVkICYmIChcbiAgICAgICAgPGRpdlxuICAgICAgICAgIG9uQ2xpY2s9e2JsdXJTZWxlY3RJbnB1dH1cbiAgICAgICAgICBjc3M9e3sgcG9zaXRpb246ICdmaXhlZCcsIGxlZnQ6IDAsIGJvdHRvbTogMCwgcmlnaHQ6IDAsIHRvcDogMCB9fVxuICAgICAgICAvPlxuICAgICAgKX1cbiAgICAgIHtjaGlsZHJlbih0YXJnZXRSZWYpfVxuICAgIDwvRnJhZ21lbnQ+XG4gICk7XG59XG4iXX0= */",
|
833 | toString: _EMOTION_STRINGIFIED_CSS_ERROR__$1
|
834 | };
|
835 | function ScrollManager(_ref) {
|
836 | var children = _ref.children,
|
837 | lockEnabled = _ref.lockEnabled,
|
838 | _ref$captureEnabled = _ref.captureEnabled,
|
839 | captureEnabled = _ref$captureEnabled === void 0 ? true : _ref$captureEnabled,
|
840 | onBottomArrive = _ref.onBottomArrive,
|
841 | onBottomLeave = _ref.onBottomLeave,
|
842 | onTopArrive = _ref.onTopArrive,
|
843 | onTopLeave = _ref.onTopLeave;
|
844 | var setScrollCaptureTarget = useScrollCapture({
|
845 | isEnabled: captureEnabled,
|
846 | onBottomArrive: onBottomArrive,
|
847 | onBottomLeave: onBottomLeave,
|
848 | onTopArrive: onTopArrive,
|
849 | onTopLeave: onTopLeave
|
850 | });
|
851 | var setScrollLockTarget = useScrollLock({
|
852 | isEnabled: lockEnabled
|
853 | });
|
854 | var targetRef = function targetRef(element) {
|
855 | setScrollCaptureTarget(element);
|
856 | setScrollLockTarget(element);
|
857 | };
|
858 | return react.jsx(React.Fragment, null, lockEnabled && react.jsx("div", {
|
859 | onClick: blurSelectInput,
|
860 | css: _ref2$1
|
861 | }), children(targetRef));
|
862 | }
|
863 |
|
864 | function _EMOTION_STRINGIFIED_CSS_ERROR__() { 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)."; }
|
865 | var _ref2 = process.env.NODE_ENV === "production" ? {
|
866 | name: "1a0ro4n-requiredInput",
|
867 | styles: "label:requiredInput;opacity:0;pointer-events:none;position:absolute;bottom:0;left:0;right:0;width:100%"
|
868 | } : {
|
869 | name: "5kkxb2-requiredInput-RequiredInput",
|
870 | styles: "label:requiredInput;opacity:0;pointer-events:none;position:absolute;bottom:0;left:0;right:0;width:100%;label:RequiredInput;",
|
871 | map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIlJlcXVpcmVkSW5wdXQudHN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQWNJIiwiZmlsZSI6IlJlcXVpcmVkSW5wdXQudHN4Iiwic291cmNlc0NvbnRlbnQiOlsiLyoqIEBqc3gganN4ICovXG5pbXBvcnQgeyBGb2N1c0V2ZW50SGFuZGxlciwgRnVuY3Rpb25Db21wb25lbnQgfSBmcm9tICdyZWFjdCc7XG5pbXBvcnQgeyBqc3ggfSBmcm9tICdAZW1vdGlvbi9yZWFjdCc7XG5cbmNvbnN0IFJlcXVpcmVkSW5wdXQ6IEZ1bmN0aW9uQ29tcG9uZW50PHtcbiAgcmVhZG9ubHkgbmFtZT86IHN0cmluZztcbiAgcmVhZG9ubHkgb25Gb2N1czogRm9jdXNFdmVudEhhbmRsZXI8SFRNTElucHV0RWxlbWVudD47XG59PiA9ICh7IG5hbWUsIG9uRm9jdXMgfSkgPT4gKFxuICA8aW5wdXRcbiAgICByZXF1aXJlZFxuICAgIG5hbWU9e25hbWV9XG4gICAgdGFiSW5kZXg9ey0xfVxuICAgIGFyaWEtaGlkZGVuPVwidHJ1ZVwiXG4gICAgb25Gb2N1cz17b25Gb2N1c31cbiAgICBjc3M9e3tcbiAgICAgIGxhYmVsOiAncmVxdWlyZWRJbnB1dCcsXG4gICAgICBvcGFjaXR5OiAwLFxuICAgICAgcG9pbnRlckV2ZW50czogJ25vbmUnLFxuICAgICAgcG9zaXRpb246ICdhYnNvbHV0ZScsXG4gICAgICBib3R0b206IDAsXG4gICAgICBsZWZ0OiAwLFxuICAgICAgcmlnaHQ6IDAsXG4gICAgICB3aWR0aDogJzEwMCUnLFxuICAgIH19XG4gICAgLy8gUHJldmVudCBgU3dpdGNoaW5nIGZyb20gdW5jb250cm9sbGVkIHRvIGNvbnRyb2xsZWRgIGVycm9yXG4gICAgdmFsdWU9XCJcIlxuICAgIG9uQ2hhbmdlPXsoKSA9PiB7fX1cbiAgLz5cbik7XG5cbmV4cG9ydCBkZWZhdWx0IFJlcXVpcmVkSW5wdXQ7XG4iXX0= */",
|
872 | toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
873 | };
|
874 | var RequiredInput = function RequiredInput(_ref) {
|
875 | var name = _ref.name,
|
876 | onFocus = _ref.onFocus;
|
877 | return react.jsx("input", {
|
878 | required: true,
|
879 | name: name,
|
880 | tabIndex: -1,
|
881 | "aria-hidden": "true",
|
882 | onFocus: onFocus,
|
883 | css: _ref2
|
884 |
|
885 | ,
|
886 | value: "",
|
887 | onChange: function onChange() {}
|
888 | });
|
889 | };
|
890 | var RequiredInput$1 = RequiredInput;
|
891 |
|
892 |
|
893 |
|
894 | function testPlatform(re) {
|
895 | var _window$navigator$use;
|
896 | 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;
|
897 | }
|
898 | function isIPhone() {
|
899 | return testPlatform(/^iPhone/i);
|
900 | }
|
901 | function isMac() {
|
902 | return testPlatform(/^Mac/i);
|
903 | }
|
904 | function isIPad() {
|
905 | return testPlatform(/^iPad/i) ||
|
906 |
|
907 | isMac() && navigator.maxTouchPoints > 1;
|
908 | }
|
909 | function isIOS() {
|
910 | return isIPhone() || isIPad();
|
911 | }
|
912 | function isAppleDevice() {
|
913 | return isMac() || isIOS();
|
914 | }
|
915 |
|
916 | var formatGroupLabel = function formatGroupLabel(group) {
|
917 | return group.label;
|
918 | };
|
919 | var getOptionLabel$1 = function getOptionLabel(option) {
|
920 | return option.label;
|
921 | };
|
922 | var getOptionValue$1 = function getOptionValue(option) {
|
923 | return option.value;
|
924 | };
|
925 | var isOptionDisabled = function isOptionDisabled(option) {
|
926 | return !!option.isDisabled;
|
927 | };
|
928 |
|
929 | var defaultStyles = {
|
930 | clearIndicator: index.clearIndicatorCSS,
|
931 | container: index.containerCSS,
|
932 | control: index.css,
|
933 | dropdownIndicator: index.dropdownIndicatorCSS,
|
934 | group: index.groupCSS,
|
935 | groupHeading: index.groupHeadingCSS,
|
936 | indicatorsContainer: index.indicatorsContainerCSS,
|
937 | indicatorSeparator: index.indicatorSeparatorCSS,
|
938 | input: index.inputCSS,
|
939 | loadingIndicator: index.loadingIndicatorCSS,
|
940 | loadingMessage: index.loadingMessageCSS,
|
941 | menu: index.menuCSS,
|
942 | menuList: index.menuListCSS,
|
943 | menuPortal: index.menuPortalCSS,
|
944 | multiValue: index.multiValueCSS,
|
945 | multiValueLabel: index.multiValueLabelCSS,
|
946 | multiValueRemove: index.multiValueRemoveCSS,
|
947 | noOptionsMessage: index.noOptionsMessageCSS,
|
948 | option: index.optionCSS,
|
949 | placeholder: index.placeholderCSS,
|
950 | singleValue: index.css$1,
|
951 | valueContainer: index.valueContainerCSS
|
952 | };
|
953 |
|
954 |
|
955 |
|
956 | function mergeStyles(source) {
|
957 | var target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
958 |
|
959 | var styles = _objectSpread({}, source);
|
960 |
|
961 |
|
962 | Object.keys(target).forEach(function (keyAsString) {
|
963 | var key = keyAsString;
|
964 | if (source[key]) {
|
965 | styles[key] = function (rsCss, props) {
|
966 | return target[key](source[key](rsCss, props), props);
|
967 | };
|
968 | } else {
|
969 | styles[key] = target[key];
|
970 | }
|
971 | });
|
972 | return styles;
|
973 | }
|
974 |
|
975 | var colors = {
|
976 | primary: '#2684FF',
|
977 | primary75: '#4C9AFF',
|
978 | primary50: '#B2D4FF',
|
979 | primary25: '#DEEBFF',
|
980 | danger: '#DE350B',
|
981 | dangerLight: '#FFBDAD',
|
982 | neutral0: 'hsl(0, 0%, 100%)',
|
983 | neutral5: 'hsl(0, 0%, 95%)',
|
984 | neutral10: 'hsl(0, 0%, 90%)',
|
985 | neutral20: 'hsl(0, 0%, 80%)',
|
986 | neutral30: 'hsl(0, 0%, 70%)',
|
987 | neutral40: 'hsl(0, 0%, 60%)',
|
988 | neutral50: 'hsl(0, 0%, 50%)',
|
989 | neutral60: 'hsl(0, 0%, 40%)',
|
990 | neutral70: 'hsl(0, 0%, 30%)',
|
991 | neutral80: 'hsl(0, 0%, 20%)',
|
992 | neutral90: 'hsl(0, 0%, 10%)'
|
993 | };
|
994 | var borderRadius = 4;
|
995 |
|
996 | var baseUnit = 4;
|
997 |
|
998 | var controlHeight = 38;
|
999 |
|
1000 | var menuGutter = baseUnit * 2;
|
1001 | var spacing = {
|
1002 | baseUnit: baseUnit,
|
1003 | controlHeight: controlHeight,
|
1004 | menuGutter: menuGutter
|
1005 | };
|
1006 | var defaultTheme = {
|
1007 | borderRadius: borderRadius,
|
1008 | colors: colors,
|
1009 | spacing: spacing
|
1010 | };
|
1011 |
|
1012 | var defaultProps = {
|
1013 | 'aria-live': 'polite',
|
1014 | backspaceRemovesValue: true,
|
1015 | blurInputOnSelect: index.isTouchCapable(),
|
1016 | captureMenuScroll: !index.isTouchCapable(),
|
1017 | classNames: {},
|
1018 | closeMenuOnSelect: true,
|
1019 | closeMenuOnScroll: false,
|
1020 | components: {},
|
1021 | controlShouldRenderValue: true,
|
1022 | escapeClearsValue: false,
|
1023 | filterOption: createFilter(),
|
1024 | formatGroupLabel: formatGroupLabel,
|
1025 | getOptionLabel: getOptionLabel$1,
|
1026 | getOptionValue: getOptionValue$1,
|
1027 | isDisabled: false,
|
1028 | isLoading: false,
|
1029 | isMulti: false,
|
1030 | isRtl: false,
|
1031 | isSearchable: true,
|
1032 | isOptionDisabled: isOptionDisabled,
|
1033 | loadingMessage: function loadingMessage() {
|
1034 | return 'Loading...';
|
1035 | },
|
1036 | maxMenuHeight: 300,
|
1037 | minMenuHeight: 140,
|
1038 | menuIsOpen: false,
|
1039 | menuPlacement: 'bottom',
|
1040 | menuPosition: 'absolute',
|
1041 | menuShouldBlockScroll: false,
|
1042 | menuShouldScrollIntoView: !index.isMobileDevice(),
|
1043 | noOptionsMessage: function noOptionsMessage() {
|
1044 | return 'No options';
|
1045 | },
|
1046 | openMenuOnFocus: false,
|
1047 | openMenuOnClick: true,
|
1048 | options: [],
|
1049 | pageSize: 5,
|
1050 | placeholder: 'Select...',
|
1051 | screenReaderStatus: function screenReaderStatus(_ref) {
|
1052 | var count = _ref.count;
|
1053 | return "".concat(count, " result").concat(count !== 1 ? 's' : '', " available");
|
1054 | },
|
1055 | styles: {},
|
1056 | tabIndex: 0,
|
1057 | tabSelectsValue: true,
|
1058 | unstyled: false
|
1059 | };
|
1060 | function toCategorizedOption(props, option, selectValue, index) {
|
1061 | var isDisabled = _isOptionDisabled(props, option, selectValue);
|
1062 | var isSelected = _isOptionSelected(props, option, selectValue);
|
1063 | var label = getOptionLabel(props, option);
|
1064 | var value = getOptionValue(props, option);
|
1065 | return {
|
1066 | type: 'option',
|
1067 | data: option,
|
1068 | isDisabled: isDisabled,
|
1069 | isSelected: isSelected,
|
1070 | label: label,
|
1071 | value: value,
|
1072 | index: index
|
1073 | };
|
1074 | }
|
1075 | function buildCategorizedOptions(props, selectValue) {
|
1076 | return props.options.map(function (groupOrOption, groupOrOptionIndex) {
|
1077 | if ('options' in groupOrOption) {
|
1078 | var categorizedOptions = groupOrOption.options.map(function (option, optionIndex) {
|
1079 | return toCategorizedOption(props, option, selectValue, optionIndex);
|
1080 | }).filter(function (categorizedOption) {
|
1081 | return isFocusable(props, categorizedOption);
|
1082 | });
|
1083 | return categorizedOptions.length > 0 ? {
|
1084 | type: 'group',
|
1085 | data: groupOrOption,
|
1086 | options: categorizedOptions,
|
1087 | index: groupOrOptionIndex
|
1088 | } : undefined;
|
1089 | }
|
1090 | var categorizedOption = toCategorizedOption(props, groupOrOption, selectValue, groupOrOptionIndex);
|
1091 | return isFocusable(props, categorizedOption) ? categorizedOption : undefined;
|
1092 | }).filter(index.notNullish);
|
1093 | }
|
1094 | function buildFocusableOptionsFromCategorizedOptions(categorizedOptions) {
|
1095 | return categorizedOptions.reduce(function (optionsAccumulator, categorizedOption) {
|
1096 | if (categorizedOption.type === 'group') {
|
1097 | optionsAccumulator.push.apply(optionsAccumulator, _toConsumableArray(categorizedOption.options.map(function (option) {
|
1098 | return option.data;
|
1099 | })));
|
1100 | } else {
|
1101 | optionsAccumulator.push(categorizedOption.data);
|
1102 | }
|
1103 | return optionsAccumulator;
|
1104 | }, []);
|
1105 | }
|
1106 | function buildFocusableOptionsWithIds(categorizedOptions, optionId) {
|
1107 | return categorizedOptions.reduce(function (optionsAccumulator, categorizedOption) {
|
1108 | if (categorizedOption.type === 'group') {
|
1109 | optionsAccumulator.push.apply(optionsAccumulator, _toConsumableArray(categorizedOption.options.map(function (option) {
|
1110 | return {
|
1111 | data: option.data,
|
1112 | id: "".concat(optionId, "-").concat(categorizedOption.index, "-").concat(option.index)
|
1113 | };
|
1114 | })));
|
1115 | } else {
|
1116 | optionsAccumulator.push({
|
1117 | data: categorizedOption.data,
|
1118 | id: "".concat(optionId, "-").concat(categorizedOption.index)
|
1119 | });
|
1120 | }
|
1121 | return optionsAccumulator;
|
1122 | }, []);
|
1123 | }
|
1124 | function buildFocusableOptions(props, selectValue) {
|
1125 | return buildFocusableOptionsFromCategorizedOptions(buildCategorizedOptions(props, selectValue));
|
1126 | }
|
1127 | function isFocusable(props, categorizedOption) {
|
1128 | var _props$inputValue = props.inputValue,
|
1129 | inputValue = _props$inputValue === void 0 ? '' : _props$inputValue;
|
1130 | var data = categorizedOption.data,
|
1131 | isSelected = categorizedOption.isSelected,
|
1132 | label = categorizedOption.label,
|
1133 | value = categorizedOption.value;
|
1134 | return (!shouldHideSelectedOptions(props) || !isSelected) && _filterOption(props, {
|
1135 | label: label,
|
1136 | value: value,
|
1137 | data: data
|
1138 | }, inputValue);
|
1139 | }
|
1140 | function getNextFocusedValue(state, nextSelectValue) {
|
1141 | var focusedValue = state.focusedValue,
|
1142 | lastSelectValue = state.selectValue;
|
1143 | var lastFocusedIndex = lastSelectValue.indexOf(focusedValue);
|
1144 | if (lastFocusedIndex > -1) {
|
1145 | var nextFocusedIndex = nextSelectValue.indexOf(focusedValue);
|
1146 | if (nextFocusedIndex > -1) {
|
1147 |
|
1148 | return focusedValue;
|
1149 | } else if (lastFocusedIndex < nextSelectValue.length) {
|
1150 |
|
1151 |
|
1152 | return nextSelectValue[lastFocusedIndex];
|
1153 | }
|
1154 | }
|
1155 | return null;
|
1156 | }
|
1157 | function getNextFocusedOption(state, options) {
|
1158 | var lastFocusedOption = state.focusedOption;
|
1159 | return lastFocusedOption && options.indexOf(lastFocusedOption) > -1 ? lastFocusedOption : options[0];
|
1160 | }
|
1161 | var getFocusedOptionId = function getFocusedOptionId(focusableOptionsWithIds, focusedOption) {
|
1162 | var _focusableOptionsWith;
|
1163 | var focusedOptionId = (_focusableOptionsWith = focusableOptionsWithIds.find(function (option) {
|
1164 | return option.data === focusedOption;
|
1165 | })) === null || _focusableOptionsWith === void 0 ? void 0 : _focusableOptionsWith.id;
|
1166 | return focusedOptionId || null;
|
1167 | };
|
1168 | var getOptionLabel = function getOptionLabel(props, data) {
|
1169 | return props.getOptionLabel(data);
|
1170 | };
|
1171 | var getOptionValue = function getOptionValue(props, data) {
|
1172 | return props.getOptionValue(data);
|
1173 | };
|
1174 | function _isOptionDisabled(props, option, selectValue) {
|
1175 | return typeof props.isOptionDisabled === 'function' ? props.isOptionDisabled(option, selectValue) : false;
|
1176 | }
|
1177 | function _isOptionSelected(props, option, selectValue) {
|
1178 | if (selectValue.indexOf(option) > -1) return true;
|
1179 | if (typeof props.isOptionSelected === 'function') {
|
1180 | return props.isOptionSelected(option, selectValue);
|
1181 | }
|
1182 | var candidate = getOptionValue(props, option);
|
1183 | return selectValue.some(function (i) {
|
1184 | return getOptionValue(props, i) === candidate;
|
1185 | });
|
1186 | }
|
1187 | function _filterOption(props, option, inputValue) {
|
1188 | return props.filterOption ? props.filterOption(option, inputValue) : true;
|
1189 | }
|
1190 | var shouldHideSelectedOptions = function shouldHideSelectedOptions(props) {
|
1191 | var hideSelectedOptions = props.hideSelectedOptions,
|
1192 | isMulti = props.isMulti;
|
1193 | if (hideSelectedOptions === undefined) return isMulti;
|
1194 | return hideSelectedOptions;
|
1195 | };
|
1196 | var instanceId = 1;
|
1197 | var Select = function (_Component) {
|
1198 | _inherits(Select, _Component);
|
1199 | var _super = _createSuper(Select);
|
1200 |
|
1201 |
|
1202 |
|
1203 |
|
1204 |
|
1205 |
|
1206 |
|
1207 |
|
1208 |
|
1209 |
|
1210 |
|
1211 | function Select(_props) {
|
1212 | var _this;
|
1213 | _classCallCheck(this, Select);
|
1214 | _this = _super.call(this, _props);
|
1215 | _this.state = {
|
1216 | ariaSelection: null,
|
1217 | focusedOption: null,
|
1218 | focusedOptionId: null,
|
1219 | focusableOptionsWithIds: [],
|
1220 | focusedValue: null,
|
1221 | inputIsHidden: false,
|
1222 | isFocused: false,
|
1223 | selectValue: [],
|
1224 | clearFocusValueOnUpdate: false,
|
1225 | prevWasFocused: false,
|
1226 | inputIsHiddenAfterUpdate: undefined,
|
1227 | prevProps: undefined,
|
1228 | instancePrefix: ''
|
1229 | };
|
1230 | _this.blockOptionHover = false;
|
1231 | _this.isComposing = false;
|
1232 | _this.commonProps = void 0;
|
1233 | _this.initialTouchX = 0;
|
1234 | _this.initialTouchY = 0;
|
1235 | _this.openAfterFocus = false;
|
1236 | _this.scrollToFocusedOptionOnUpdate = false;
|
1237 | _this.userIsDragging = void 0;
|
1238 | _this.isAppleDevice = isAppleDevice();
|
1239 | _this.controlRef = null;
|
1240 | _this.getControlRef = function (ref) {
|
1241 | _this.controlRef = ref;
|
1242 | };
|
1243 | _this.focusedOptionRef = null;
|
1244 | _this.getFocusedOptionRef = function (ref) {
|
1245 | _this.focusedOptionRef = ref;
|
1246 | };
|
1247 | _this.menuListRef = null;
|
1248 | _this.getMenuListRef = function (ref) {
|
1249 | _this.menuListRef = ref;
|
1250 | };
|
1251 | _this.inputRef = null;
|
1252 | _this.getInputRef = function (ref) {
|
1253 | _this.inputRef = ref;
|
1254 | };
|
1255 | _this.focus = _this.focusInput;
|
1256 | _this.blur = _this.blurInput;
|
1257 | _this.onChange = function (newValue, actionMeta) {
|
1258 | var _this$props = _this.props,
|
1259 | onChange = _this$props.onChange,
|
1260 | name = _this$props.name;
|
1261 | actionMeta.name = name;
|
1262 | _this.ariaOnChange(newValue, actionMeta);
|
1263 | onChange(newValue, actionMeta);
|
1264 | };
|
1265 | _this.setValue = function (newValue, action, option) {
|
1266 | var _this$props2 = _this.props,
|
1267 | closeMenuOnSelect = _this$props2.closeMenuOnSelect,
|
1268 | isMulti = _this$props2.isMulti,
|
1269 | inputValue = _this$props2.inputValue;
|
1270 | _this.onInputChange('', {
|
1271 | action: 'set-value',
|
1272 | prevInputValue: inputValue
|
1273 | });
|
1274 | if (closeMenuOnSelect) {
|
1275 | _this.setState({
|
1276 | inputIsHiddenAfterUpdate: !isMulti
|
1277 | });
|
1278 | _this.onMenuClose();
|
1279 | }
|
1280 |
|
1281 | _this.setState({
|
1282 | clearFocusValueOnUpdate: true
|
1283 | });
|
1284 | _this.onChange(newValue, {
|
1285 | action: action,
|
1286 | option: option
|
1287 | });
|
1288 | };
|
1289 | _this.selectOption = function (newValue) {
|
1290 | var _this$props3 = _this.props,
|
1291 | blurInputOnSelect = _this$props3.blurInputOnSelect,
|
1292 | isMulti = _this$props3.isMulti,
|
1293 | name = _this$props3.name;
|
1294 | var selectValue = _this.state.selectValue;
|
1295 | var deselected = isMulti && _this.isOptionSelected(newValue, selectValue);
|
1296 | var isDisabled = _this.isOptionDisabled(newValue, selectValue);
|
1297 | if (deselected) {
|
1298 | var candidate = _this.getOptionValue(newValue);
|
1299 | _this.setValue(index.multiValueAsValue(selectValue.filter(function (i) {
|
1300 | return _this.getOptionValue(i) !== candidate;
|
1301 | })), 'deselect-option', newValue);
|
1302 | } else if (!isDisabled) {
|
1303 |
|
1304 | if (isMulti) {
|
1305 | _this.setValue(index.multiValueAsValue([].concat(_toConsumableArray(selectValue), [newValue])), 'select-option', newValue);
|
1306 | } else {
|
1307 | _this.setValue(index.singleValueAsValue(newValue), 'select-option');
|
1308 | }
|
1309 | } else {
|
1310 | _this.ariaOnChange(index.singleValueAsValue(newValue), {
|
1311 | action: 'select-option',
|
1312 | option: newValue,
|
1313 | name: name
|
1314 | });
|
1315 | return;
|
1316 | }
|
1317 | if (blurInputOnSelect) {
|
1318 | _this.blurInput();
|
1319 | }
|
1320 | };
|
1321 | _this.removeValue = function (removedValue) {
|
1322 | var isMulti = _this.props.isMulti;
|
1323 | var selectValue = _this.state.selectValue;
|
1324 | var candidate = _this.getOptionValue(removedValue);
|
1325 | var newValueArray = selectValue.filter(function (i) {
|
1326 | return _this.getOptionValue(i) !== candidate;
|
1327 | });
|
1328 | var newValue = index.valueTernary(isMulti, newValueArray, newValueArray[0] || null);
|
1329 | _this.onChange(newValue, {
|
1330 | action: 'remove-value',
|
1331 | removedValue: removedValue
|
1332 | });
|
1333 | _this.focusInput();
|
1334 | };
|
1335 | _this.clearValue = function () {
|
1336 | var selectValue = _this.state.selectValue;
|
1337 | _this.onChange(index.valueTernary(_this.props.isMulti, [], null), {
|
1338 | action: 'clear',
|
1339 | removedValues: selectValue
|
1340 | });
|
1341 | };
|
1342 | _this.popValue = function () {
|
1343 | var isMulti = _this.props.isMulti;
|
1344 | var selectValue = _this.state.selectValue;
|
1345 | var lastSelectedValue = selectValue[selectValue.length - 1];
|
1346 | var newValueArray = selectValue.slice(0, selectValue.length - 1);
|
1347 | var newValue = index.valueTernary(isMulti, newValueArray, newValueArray[0] || null);
|
1348 | _this.onChange(newValue, {
|
1349 | action: 'pop-value',
|
1350 | removedValue: lastSelectedValue
|
1351 | });
|
1352 | };
|
1353 | _this.getFocusedOptionId = function (focusedOption) {
|
1354 | return getFocusedOptionId(_this.state.focusableOptionsWithIds, focusedOption);
|
1355 | };
|
1356 | _this.getFocusableOptionsWithIds = function () {
|
1357 | return buildFocusableOptionsWithIds(buildCategorizedOptions(_this.props, _this.state.selectValue), _this.getElementId('option'));
|
1358 | };
|
1359 | _this.getValue = function () {
|
1360 | return _this.state.selectValue;
|
1361 | };
|
1362 | _this.cx = function () {
|
1363 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
1364 | args[_key] = arguments[_key];
|
1365 | }
|
1366 | return index.classNames.apply(void 0, [_this.props.classNamePrefix].concat(args));
|
1367 | };
|
1368 | _this.getOptionLabel = function (data) {
|
1369 | return getOptionLabel(_this.props, data);
|
1370 | };
|
1371 | _this.getOptionValue = function (data) {
|
1372 | return getOptionValue(_this.props, data);
|
1373 | };
|
1374 | _this.getStyles = function (key, props) {
|
1375 | var unstyled = _this.props.unstyled;
|
1376 | var base = defaultStyles[key](props, unstyled);
|
1377 | base.boxSizing = 'border-box';
|
1378 | var custom = _this.props.styles[key];
|
1379 | return custom ? custom(base, props) : base;
|
1380 | };
|
1381 | _this.getClassNames = function (key, props) {
|
1382 | var _this$props$className, _this$props$className2;
|
1383 | 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);
|
1384 | };
|
1385 | _this.getElementId = function (element) {
|
1386 | return "".concat(_this.state.instancePrefix, "-").concat(element);
|
1387 | };
|
1388 | _this.getComponents = function () {
|
1389 | return index.defaultComponents(_this.props);
|
1390 | };
|
1391 | _this.buildCategorizedOptions = function () {
|
1392 | return buildCategorizedOptions(_this.props, _this.state.selectValue);
|
1393 | };
|
1394 | _this.getCategorizedOptions = function () {
|
1395 | return _this.props.menuIsOpen ? _this.buildCategorizedOptions() : [];
|
1396 | };
|
1397 | _this.buildFocusableOptions = function () {
|
1398 | return buildFocusableOptionsFromCategorizedOptions(_this.buildCategorizedOptions());
|
1399 | };
|
1400 | _this.getFocusableOptions = function () {
|
1401 | return _this.props.menuIsOpen ? _this.buildFocusableOptions() : [];
|
1402 | };
|
1403 | _this.ariaOnChange = function (value, actionMeta) {
|
1404 | _this.setState({
|
1405 | ariaSelection: _objectSpread({
|
1406 | value: value
|
1407 | }, actionMeta)
|
1408 | });
|
1409 | };
|
1410 | _this.onMenuMouseDown = function (event) {
|
1411 | if (event.button !== 0) {
|
1412 | return;
|
1413 | }
|
1414 | event.stopPropagation();
|
1415 | event.preventDefault();
|
1416 | _this.focusInput();
|
1417 | };
|
1418 | _this.onMenuMouseMove = function (event) {
|
1419 | _this.blockOptionHover = false;
|
1420 | };
|
1421 | _this.onControlMouseDown = function (event) {
|
1422 |
|
1423 | if (event.defaultPrevented) {
|
1424 | return;
|
1425 | }
|
1426 | var openMenuOnClick = _this.props.openMenuOnClick;
|
1427 | if (!_this.state.isFocused) {
|
1428 | if (openMenuOnClick) {
|
1429 | _this.openAfterFocus = true;
|
1430 | }
|
1431 | _this.focusInput();
|
1432 | } else if (!_this.props.menuIsOpen) {
|
1433 | if (openMenuOnClick) {
|
1434 | _this.openMenu('first');
|
1435 | }
|
1436 | } else {
|
1437 | if (event.target.tagName !== 'INPUT' && event.target.tagName !== 'TEXTAREA') {
|
1438 | _this.onMenuClose();
|
1439 | }
|
1440 | }
|
1441 | if (event.target.tagName !== 'INPUT' && event.target.tagName !== 'TEXTAREA') {
|
1442 | event.preventDefault();
|
1443 | }
|
1444 | };
|
1445 | _this.onDropdownIndicatorMouseDown = function (event) {
|
1446 |
|
1447 | if (event && event.type === 'mousedown' && event.button !== 0) {
|
1448 | return;
|
1449 | }
|
1450 | if (_this.props.isDisabled) return;
|
1451 | var _this$props4 = _this.props,
|
1452 | isMulti = _this$props4.isMulti,
|
1453 | menuIsOpen = _this$props4.menuIsOpen;
|
1454 | _this.focusInput();
|
1455 | if (menuIsOpen) {
|
1456 | _this.setState({
|
1457 | inputIsHiddenAfterUpdate: !isMulti
|
1458 | });
|
1459 | _this.onMenuClose();
|
1460 | } else {
|
1461 | _this.openMenu('first');
|
1462 | }
|
1463 | event.preventDefault();
|
1464 | };
|
1465 | _this.onClearIndicatorMouseDown = function (event) {
|
1466 |
|
1467 | if (event && event.type === 'mousedown' && event.button !== 0) {
|
1468 | return;
|
1469 | }
|
1470 | _this.clearValue();
|
1471 | event.preventDefault();
|
1472 | _this.openAfterFocus = false;
|
1473 | if (event.type === 'touchend') {
|
1474 | _this.focusInput();
|
1475 | } else {
|
1476 | setTimeout(function () {
|
1477 | return _this.focusInput();
|
1478 | });
|
1479 | }
|
1480 | };
|
1481 | _this.onScroll = function (event) {
|
1482 | if (typeof _this.props.closeMenuOnScroll === 'boolean') {
|
1483 | if (event.target instanceof HTMLElement && index.isDocumentElement(event.target)) {
|
1484 | _this.props.onMenuClose();
|
1485 | }
|
1486 | } else if (typeof _this.props.closeMenuOnScroll === 'function') {
|
1487 | if (_this.props.closeMenuOnScroll(event)) {
|
1488 | _this.props.onMenuClose();
|
1489 | }
|
1490 | }
|
1491 | };
|
1492 | _this.onCompositionStart = function () {
|
1493 | _this.isComposing = true;
|
1494 | };
|
1495 | _this.onCompositionEnd = function () {
|
1496 | _this.isComposing = false;
|
1497 | };
|
1498 | _this.onTouchStart = function (_ref2) {
|
1499 | var touches = _ref2.touches;
|
1500 | var touch = touches && touches.item(0);
|
1501 | if (!touch) {
|
1502 | return;
|
1503 | }
|
1504 | _this.initialTouchX = touch.clientX;
|
1505 | _this.initialTouchY = touch.clientY;
|
1506 | _this.userIsDragging = false;
|
1507 | };
|
1508 | _this.onTouchMove = function (_ref3) {
|
1509 | var touches = _ref3.touches;
|
1510 | var touch = touches && touches.item(0);
|
1511 | if (!touch) {
|
1512 | return;
|
1513 | }
|
1514 | var deltaX = Math.abs(touch.clientX - _this.initialTouchX);
|
1515 | var deltaY = Math.abs(touch.clientY - _this.initialTouchY);
|
1516 | var moveThreshold = 5;
|
1517 | _this.userIsDragging = deltaX > moveThreshold || deltaY > moveThreshold;
|
1518 | };
|
1519 | _this.onTouchEnd = function (event) {
|
1520 | if (_this.userIsDragging) return;
|
1521 |
|
1522 |
|
1523 |
|
1524 |
|
1525 | if (_this.controlRef && !_this.controlRef.contains(event.target) && _this.menuListRef && !_this.menuListRef.contains(event.target)) {
|
1526 | _this.blurInput();
|
1527 | }
|
1528 |
|
1529 |
|
1530 | _this.initialTouchX = 0;
|
1531 | _this.initialTouchY = 0;
|
1532 | };
|
1533 | _this.onControlTouchEnd = function (event) {
|
1534 | if (_this.userIsDragging) return;
|
1535 | _this.onControlMouseDown(event);
|
1536 | };
|
1537 | _this.onClearIndicatorTouchEnd = function (event) {
|
1538 | if (_this.userIsDragging) return;
|
1539 | _this.onClearIndicatorMouseDown(event);
|
1540 | };
|
1541 | _this.onDropdownIndicatorTouchEnd = function (event) {
|
1542 | if (_this.userIsDragging) return;
|
1543 | _this.onDropdownIndicatorMouseDown(event);
|
1544 | };
|
1545 | _this.handleInputChange = function (event) {
|
1546 | var prevInputValue = _this.props.inputValue;
|
1547 | var inputValue = event.currentTarget.value;
|
1548 | _this.setState({
|
1549 | inputIsHiddenAfterUpdate: false
|
1550 | });
|
1551 | _this.onInputChange(inputValue, {
|
1552 | action: 'input-change',
|
1553 | prevInputValue: prevInputValue
|
1554 | });
|
1555 | if (!_this.props.menuIsOpen) {
|
1556 | _this.onMenuOpen();
|
1557 | }
|
1558 | };
|
1559 | _this.onInputFocus = function (event) {
|
1560 | if (_this.props.onFocus) {
|
1561 | _this.props.onFocus(event);
|
1562 | }
|
1563 | _this.setState({
|
1564 | inputIsHiddenAfterUpdate: false,
|
1565 | isFocused: true
|
1566 | });
|
1567 | if (_this.openAfterFocus || _this.props.openMenuOnFocus) {
|
1568 | _this.openMenu('first');
|
1569 | }
|
1570 | _this.openAfterFocus = false;
|
1571 | };
|
1572 | _this.onInputBlur = function (event) {
|
1573 | var prevInputValue = _this.props.inputValue;
|
1574 | if (_this.menuListRef && _this.menuListRef.contains(document.activeElement)) {
|
1575 | _this.inputRef.focus();
|
1576 | return;
|
1577 | }
|
1578 | if (_this.props.onBlur) {
|
1579 | _this.props.onBlur(event);
|
1580 | }
|
1581 | _this.onInputChange('', {
|
1582 | action: 'input-blur',
|
1583 | prevInputValue: prevInputValue
|
1584 | });
|
1585 | _this.onMenuClose();
|
1586 | _this.setState({
|
1587 | focusedValue: null,
|
1588 | isFocused: false
|
1589 | });
|
1590 | };
|
1591 | _this.onOptionHover = function (focusedOption) {
|
1592 | if (_this.blockOptionHover || _this.state.focusedOption === focusedOption) {
|
1593 | return;
|
1594 | }
|
1595 | var options = _this.getFocusableOptions();
|
1596 | var focusedOptionIndex = options.indexOf(focusedOption);
|
1597 | _this.setState({
|
1598 | focusedOption: focusedOption,
|
1599 | focusedOptionId: focusedOptionIndex > -1 ? _this.getFocusedOptionId(focusedOption) : null
|
1600 | });
|
1601 | };
|
1602 | _this.shouldHideSelectedOptions = function () {
|
1603 | return shouldHideSelectedOptions(_this.props);
|
1604 | };
|
1605 | _this.onValueInputFocus = function (e) {
|
1606 | e.preventDefault();
|
1607 | e.stopPropagation();
|
1608 | _this.focus();
|
1609 | };
|
1610 | _this.onKeyDown = function (event) {
|
1611 | var _this$props5 = _this.props,
|
1612 | isMulti = _this$props5.isMulti,
|
1613 | backspaceRemovesValue = _this$props5.backspaceRemovesValue,
|
1614 | escapeClearsValue = _this$props5.escapeClearsValue,
|
1615 | inputValue = _this$props5.inputValue,
|
1616 | isClearable = _this$props5.isClearable,
|
1617 | isDisabled = _this$props5.isDisabled,
|
1618 | menuIsOpen = _this$props5.menuIsOpen,
|
1619 | onKeyDown = _this$props5.onKeyDown,
|
1620 | tabSelectsValue = _this$props5.tabSelectsValue,
|
1621 | openMenuOnFocus = _this$props5.openMenuOnFocus;
|
1622 | var _this$state = _this.state,
|
1623 | focusedOption = _this$state.focusedOption,
|
1624 | focusedValue = _this$state.focusedValue,
|
1625 | selectValue = _this$state.selectValue;
|
1626 | if (isDisabled) return;
|
1627 | if (typeof onKeyDown === 'function') {
|
1628 | onKeyDown(event);
|
1629 | if (event.defaultPrevented) {
|
1630 | return;
|
1631 | }
|
1632 | }
|
1633 |
|
1634 |
|
1635 | _this.blockOptionHover = true;
|
1636 | switch (event.key) {
|
1637 | case 'ArrowLeft':
|
1638 | if (!isMulti || inputValue) return;
|
1639 | _this.focusValue('previous');
|
1640 | break;
|
1641 | case 'ArrowRight':
|
1642 | if (!isMulti || inputValue) return;
|
1643 | _this.focusValue('next');
|
1644 | break;
|
1645 | case 'Delete':
|
1646 | case 'Backspace':
|
1647 | if (inputValue) return;
|
1648 | if (focusedValue) {
|
1649 | _this.removeValue(focusedValue);
|
1650 | } else {
|
1651 | if (!backspaceRemovesValue) return;
|
1652 | if (isMulti) {
|
1653 | _this.popValue();
|
1654 | } else if (isClearable) {
|
1655 | _this.clearValue();
|
1656 | }
|
1657 | }
|
1658 | break;
|
1659 | case 'Tab':
|
1660 | if (_this.isComposing) return;
|
1661 | if (event.shiftKey || !menuIsOpen || !tabSelectsValue || !focusedOption ||
|
1662 |
|
1663 |
|
1664 | openMenuOnFocus && _this.isOptionSelected(focusedOption, selectValue)) {
|
1665 | return;
|
1666 | }
|
1667 | _this.selectOption(focusedOption);
|
1668 | break;
|
1669 | case 'Enter':
|
1670 | if (event.keyCode === 229) {
|
1671 |
|
1672 |
|
1673 | break;
|
1674 | }
|
1675 | if (menuIsOpen) {
|
1676 | if (!focusedOption) return;
|
1677 | if (_this.isComposing) return;
|
1678 | _this.selectOption(focusedOption);
|
1679 | break;
|
1680 | }
|
1681 | return;
|
1682 | case 'Escape':
|
1683 | if (menuIsOpen) {
|
1684 | _this.setState({
|
1685 | inputIsHiddenAfterUpdate: false
|
1686 | });
|
1687 | _this.onInputChange('', {
|
1688 | action: 'menu-close',
|
1689 | prevInputValue: inputValue
|
1690 | });
|
1691 | _this.onMenuClose();
|
1692 | } else if (isClearable && escapeClearsValue) {
|
1693 | _this.clearValue();
|
1694 | }
|
1695 | break;
|
1696 | case ' ':
|
1697 |
|
1698 | if (inputValue) {
|
1699 | return;
|
1700 | }
|
1701 | if (!menuIsOpen) {
|
1702 | _this.openMenu('first');
|
1703 | break;
|
1704 | }
|
1705 | if (!focusedOption) return;
|
1706 | _this.selectOption(focusedOption);
|
1707 | break;
|
1708 | case 'ArrowUp':
|
1709 | if (menuIsOpen) {
|
1710 | _this.focusOption('up');
|
1711 | } else {
|
1712 | _this.openMenu('last');
|
1713 | }
|
1714 | break;
|
1715 | case 'ArrowDown':
|
1716 | if (menuIsOpen) {
|
1717 | _this.focusOption('down');
|
1718 | } else {
|
1719 | _this.openMenu('first');
|
1720 | }
|
1721 | break;
|
1722 | case 'PageUp':
|
1723 | if (!menuIsOpen) return;
|
1724 | _this.focusOption('pageup');
|
1725 | break;
|
1726 | case 'PageDown':
|
1727 | if (!menuIsOpen) return;
|
1728 | _this.focusOption('pagedown');
|
1729 | break;
|
1730 | case 'Home':
|
1731 | if (!menuIsOpen) return;
|
1732 | _this.focusOption('first');
|
1733 | break;
|
1734 | case 'End':
|
1735 | if (!menuIsOpen) return;
|
1736 | _this.focusOption('last');
|
1737 | break;
|
1738 | default:
|
1739 | return;
|
1740 | }
|
1741 | event.preventDefault();
|
1742 | };
|
1743 | _this.state.instancePrefix = 'react-select-' + (_this.props.instanceId || ++instanceId);
|
1744 | _this.state.selectValue = index.cleanValue(_props.value);
|
1745 |
|
1746 | if (_props.menuIsOpen && _this.state.selectValue.length) {
|
1747 | var focusableOptionsWithIds = _this.getFocusableOptionsWithIds();
|
1748 | var focusableOptions = _this.buildFocusableOptions();
|
1749 | var optionIndex = focusableOptions.indexOf(_this.state.selectValue[0]);
|
1750 | _this.state.focusableOptionsWithIds = focusableOptionsWithIds;
|
1751 | _this.state.focusedOption = focusableOptions[optionIndex];
|
1752 | _this.state.focusedOptionId = getFocusedOptionId(focusableOptionsWithIds, focusableOptions[optionIndex]);
|
1753 | }
|
1754 | return _this;
|
1755 | }
|
1756 | _createClass(Select, [{
|
1757 | key: "componentDidMount",
|
1758 | value: function componentDidMount() {
|
1759 | this.startListeningComposition();
|
1760 | this.startListeningToTouch();
|
1761 | if (this.props.closeMenuOnScroll && document && document.addEventListener) {
|
1762 |
|
1763 | document.addEventListener('scroll', this.onScroll, true);
|
1764 | }
|
1765 | if (this.props.autoFocus) {
|
1766 | this.focusInput();
|
1767 | }
|
1768 |
|
1769 |
|
1770 | if (this.props.menuIsOpen && this.state.focusedOption && this.menuListRef && this.focusedOptionRef) {
|
1771 | index.scrollIntoView(this.menuListRef, this.focusedOptionRef);
|
1772 | }
|
1773 | }
|
1774 | }, {
|
1775 | key: "componentDidUpdate",
|
1776 | value: function componentDidUpdate(prevProps) {
|
1777 | var _this$props6 = this.props,
|
1778 | isDisabled = _this$props6.isDisabled,
|
1779 | menuIsOpen = _this$props6.menuIsOpen;
|
1780 | var isFocused = this.state.isFocused;
|
1781 | if (
|
1782 |
|
1783 | isFocused && !isDisabled && prevProps.isDisabled ||
|
1784 |
|
1785 | isFocused && menuIsOpen && !prevProps.menuIsOpen) {
|
1786 | this.focusInput();
|
1787 | }
|
1788 | if (isFocused && isDisabled && !prevProps.isDisabled) {
|
1789 |
|
1790 |
|
1791 | this.setState({
|
1792 | isFocused: false
|
1793 | }, this.onMenuClose);
|
1794 | } else if (!isFocused && !isDisabled && prevProps.isDisabled && this.inputRef === document.activeElement) {
|
1795 |
|
1796 |
|
1797 | this.setState({
|
1798 | isFocused: true
|
1799 | });
|
1800 | }
|
1801 |
|
1802 |
|
1803 | if (this.menuListRef && this.focusedOptionRef && this.scrollToFocusedOptionOnUpdate) {
|
1804 | index.scrollIntoView(this.menuListRef, this.focusedOptionRef);
|
1805 | this.scrollToFocusedOptionOnUpdate = false;
|
1806 | }
|
1807 | }
|
1808 | }, {
|
1809 | key: "componentWillUnmount",
|
1810 | value: function componentWillUnmount() {
|
1811 | this.stopListeningComposition();
|
1812 | this.stopListeningToTouch();
|
1813 | document.removeEventListener('scroll', this.onScroll, true);
|
1814 | }
|
1815 |
|
1816 |
|
1817 |
|
1818 |
|
1819 | }, {
|
1820 | key: "onMenuOpen",
|
1821 | value: function onMenuOpen() {
|
1822 | this.props.onMenuOpen();
|
1823 | }
|
1824 | }, {
|
1825 | key: "onMenuClose",
|
1826 | value: function onMenuClose() {
|
1827 | this.onInputChange('', {
|
1828 | action: 'menu-close',
|
1829 | prevInputValue: this.props.inputValue
|
1830 | });
|
1831 | this.props.onMenuClose();
|
1832 | }
|
1833 | }, {
|
1834 | key: "onInputChange",
|
1835 | value: function onInputChange(newValue, actionMeta) {
|
1836 | this.props.onInputChange(newValue, actionMeta);
|
1837 | }
|
1838 |
|
1839 |
|
1840 |
|
1841 |
|
1842 | }, {
|
1843 | key: "focusInput",
|
1844 | value: function focusInput() {
|
1845 | if (!this.inputRef) return;
|
1846 | this.inputRef.focus();
|
1847 | }
|
1848 | }, {
|
1849 | key: "blurInput",
|
1850 | value: function blurInput() {
|
1851 | if (!this.inputRef) return;
|
1852 | this.inputRef.blur();
|
1853 | }
|
1854 |
|
1855 |
|
1856 | }, {
|
1857 | key: "openMenu",
|
1858 | value: function openMenu(focusOption) {
|
1859 | var _this2 = this;
|
1860 | var _this$state2 = this.state,
|
1861 | selectValue = _this$state2.selectValue,
|
1862 | isFocused = _this$state2.isFocused;
|
1863 | var focusableOptions = this.buildFocusableOptions();
|
1864 | var openAtIndex = focusOption === 'first' ? 0 : focusableOptions.length - 1;
|
1865 | if (!this.props.isMulti) {
|
1866 | var selectedIndex = focusableOptions.indexOf(selectValue[0]);
|
1867 | if (selectedIndex > -1) {
|
1868 | openAtIndex = selectedIndex;
|
1869 | }
|
1870 | }
|
1871 |
|
1872 |
|
1873 | this.scrollToFocusedOptionOnUpdate = !(isFocused && this.menuListRef);
|
1874 | this.setState({
|
1875 | inputIsHiddenAfterUpdate: false,
|
1876 | focusedValue: null,
|
1877 | focusedOption: focusableOptions[openAtIndex],
|
1878 | focusedOptionId: this.getFocusedOptionId(focusableOptions[openAtIndex])
|
1879 | }, function () {
|
1880 | return _this2.onMenuOpen();
|
1881 | });
|
1882 | }
|
1883 | }, {
|
1884 | key: "focusValue",
|
1885 | value: function focusValue(direction) {
|
1886 | var _this$state3 = this.state,
|
1887 | selectValue = _this$state3.selectValue,
|
1888 | focusedValue = _this$state3.focusedValue;
|
1889 |
|
1890 |
|
1891 | if (!this.props.isMulti) return;
|
1892 | this.setState({
|
1893 | focusedOption: null
|
1894 | });
|
1895 | var focusedIndex = selectValue.indexOf(focusedValue);
|
1896 | if (!focusedValue) {
|
1897 | focusedIndex = -1;
|
1898 | }
|
1899 | var lastIndex = selectValue.length - 1;
|
1900 | var nextFocus = -1;
|
1901 | if (!selectValue.length) return;
|
1902 | switch (direction) {
|
1903 | case 'previous':
|
1904 | if (focusedIndex === 0) {
|
1905 |
|
1906 | nextFocus = 0;
|
1907 | } else if (focusedIndex === -1) {
|
1908 |
|
1909 | nextFocus = lastIndex;
|
1910 | } else {
|
1911 | nextFocus = focusedIndex - 1;
|
1912 | }
|
1913 | break;
|
1914 | case 'next':
|
1915 | if (focusedIndex > -1 && focusedIndex < lastIndex) {
|
1916 | nextFocus = focusedIndex + 1;
|
1917 | }
|
1918 | break;
|
1919 | }
|
1920 | this.setState({
|
1921 | inputIsHidden: nextFocus !== -1,
|
1922 | focusedValue: selectValue[nextFocus]
|
1923 | });
|
1924 | }
|
1925 | }, {
|
1926 | key: "focusOption",
|
1927 | value: function focusOption() {
|
1928 | var direction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'first';
|
1929 | var pageSize = this.props.pageSize;
|
1930 | var focusedOption = this.state.focusedOption;
|
1931 | var options = this.getFocusableOptions();
|
1932 | if (!options.length) return;
|
1933 | var nextFocus = 0;
|
1934 | var focusedIndex = options.indexOf(focusedOption);
|
1935 | if (!focusedOption) {
|
1936 | focusedIndex = -1;
|
1937 | }
|
1938 | if (direction === 'up') {
|
1939 | nextFocus = focusedIndex > 0 ? focusedIndex - 1 : options.length - 1;
|
1940 | } else if (direction === 'down') {
|
1941 | nextFocus = (focusedIndex + 1) % options.length;
|
1942 | } else if (direction === 'pageup') {
|
1943 | nextFocus = focusedIndex - pageSize;
|
1944 | if (nextFocus < 0) nextFocus = 0;
|
1945 | } else if (direction === 'pagedown') {
|
1946 | nextFocus = focusedIndex + pageSize;
|
1947 | if (nextFocus > options.length - 1) nextFocus = options.length - 1;
|
1948 | } else if (direction === 'last') {
|
1949 | nextFocus = options.length - 1;
|
1950 | }
|
1951 | this.scrollToFocusedOptionOnUpdate = true;
|
1952 | this.setState({
|
1953 | focusedOption: options[nextFocus],
|
1954 | focusedValue: null,
|
1955 | focusedOptionId: this.getFocusedOptionId(options[nextFocus])
|
1956 | });
|
1957 | }
|
1958 | }, {
|
1959 | key: "getTheme",
|
1960 | value:
|
1961 |
|
1962 |
|
1963 |
|
1964 |
|
1965 | function getTheme() {
|
1966 |
|
1967 | if (!this.props.theme) {
|
1968 | return defaultTheme;
|
1969 | }
|
1970 |
|
1971 |
|
1972 |
|
1973 | if (typeof this.props.theme === 'function') {
|
1974 | return this.props.theme(defaultTheme);
|
1975 | }
|
1976 |
|
1977 |
|
1978 | return _objectSpread(_objectSpread({}, defaultTheme), this.props.theme);
|
1979 | }
|
1980 | }, {
|
1981 | key: "getCommonProps",
|
1982 | value: function getCommonProps() {
|
1983 | var clearValue = this.clearValue,
|
1984 | cx = this.cx,
|
1985 | getStyles = this.getStyles,
|
1986 | getClassNames = this.getClassNames,
|
1987 | getValue = this.getValue,
|
1988 | selectOption = this.selectOption,
|
1989 | setValue = this.setValue,
|
1990 | props = this.props;
|
1991 | var isMulti = props.isMulti,
|
1992 | isRtl = props.isRtl,
|
1993 | options = props.options;
|
1994 | var hasValue = this.hasValue();
|
1995 | return {
|
1996 | clearValue: clearValue,
|
1997 | cx: cx,
|
1998 | getStyles: getStyles,
|
1999 | getClassNames: getClassNames,
|
2000 | getValue: getValue,
|
2001 | hasValue: hasValue,
|
2002 | isMulti: isMulti,
|
2003 | isRtl: isRtl,
|
2004 | options: options,
|
2005 | selectOption: selectOption,
|
2006 | selectProps: props,
|
2007 | setValue: setValue,
|
2008 | theme: this.getTheme()
|
2009 | };
|
2010 | }
|
2011 | }, {
|
2012 | key: "hasValue",
|
2013 | value: function hasValue() {
|
2014 | var selectValue = this.state.selectValue;
|
2015 | return selectValue.length > 0;
|
2016 | }
|
2017 | }, {
|
2018 | key: "hasOptions",
|
2019 | value: function hasOptions() {
|
2020 | return !!this.getFocusableOptions().length;
|
2021 | }
|
2022 | }, {
|
2023 | key: "isClearable",
|
2024 | value: function isClearable() {
|
2025 | var _this$props7 = this.props,
|
2026 | isClearable = _this$props7.isClearable,
|
2027 | isMulti = _this$props7.isMulti;
|
2028 |
|
2029 |
|
2030 |
|
2031 | if (isClearable === undefined) return isMulti;
|
2032 | return isClearable;
|
2033 | }
|
2034 | }, {
|
2035 | key: "isOptionDisabled",
|
2036 | value: function isOptionDisabled(option, selectValue) {
|
2037 | return _isOptionDisabled(this.props, option, selectValue);
|
2038 | }
|
2039 | }, {
|
2040 | key: "isOptionSelected",
|
2041 | value: function isOptionSelected(option, selectValue) {
|
2042 | return _isOptionSelected(this.props, option, selectValue);
|
2043 | }
|
2044 | }, {
|
2045 | key: "filterOption",
|
2046 | value: function filterOption(option, inputValue) {
|
2047 | return _filterOption(this.props, option, inputValue);
|
2048 | }
|
2049 | }, {
|
2050 | key: "formatOptionLabel",
|
2051 | value: function formatOptionLabel(data, context) {
|
2052 | if (typeof this.props.formatOptionLabel === 'function') {
|
2053 | var _inputValue = this.props.inputValue;
|
2054 | var _selectValue = this.state.selectValue;
|
2055 | return this.props.formatOptionLabel(data, {
|
2056 | context: context,
|
2057 | inputValue: _inputValue,
|
2058 | selectValue: _selectValue
|
2059 | });
|
2060 | } else {
|
2061 | return this.getOptionLabel(data);
|
2062 | }
|
2063 | }
|
2064 | }, {
|
2065 | key: "formatGroupLabel",
|
2066 | value: function formatGroupLabel(data) {
|
2067 | return this.props.formatGroupLabel(data);
|
2068 | }
|
2069 |
|
2070 |
|
2071 |
|
2072 |
|
2073 | }, {
|
2074 | key: "startListeningComposition",
|
2075 | value:
|
2076 |
|
2077 |
|
2078 |
|
2079 |
|
2080 | function startListeningComposition() {
|
2081 | if (document && document.addEventListener) {
|
2082 | document.addEventListener('compositionstart', this.onCompositionStart, false);
|
2083 | document.addEventListener('compositionend', this.onCompositionEnd, false);
|
2084 | }
|
2085 | }
|
2086 | }, {
|
2087 | key: "stopListeningComposition",
|
2088 | value: function stopListeningComposition() {
|
2089 | if (document && document.removeEventListener) {
|
2090 | document.removeEventListener('compositionstart', this.onCompositionStart);
|
2091 | document.removeEventListener('compositionend', this.onCompositionEnd);
|
2092 | }
|
2093 | }
|
2094 | }, {
|
2095 | key: "startListeningToTouch",
|
2096 | value:
|
2097 |
|
2098 |
|
2099 |
|
2100 |
|
2101 | function startListeningToTouch() {
|
2102 | if (document && document.addEventListener) {
|
2103 | document.addEventListener('touchstart', this.onTouchStart, false);
|
2104 | document.addEventListener('touchmove', this.onTouchMove, false);
|
2105 | document.addEventListener('touchend', this.onTouchEnd, false);
|
2106 | }
|
2107 | }
|
2108 | }, {
|
2109 | key: "stopListeningToTouch",
|
2110 | value: function stopListeningToTouch() {
|
2111 | if (document && document.removeEventListener) {
|
2112 | document.removeEventListener('touchstart', this.onTouchStart);
|
2113 | document.removeEventListener('touchmove', this.onTouchMove);
|
2114 | document.removeEventListener('touchend', this.onTouchEnd);
|
2115 | }
|
2116 | }
|
2117 | }, {
|
2118 | key: "renderInput",
|
2119 | value:
|
2120 |
|
2121 |
|
2122 |
|
2123 | function renderInput() {
|
2124 | var _this$props8 = this.props,
|
2125 | isDisabled = _this$props8.isDisabled,
|
2126 | isSearchable = _this$props8.isSearchable,
|
2127 | inputId = _this$props8.inputId,
|
2128 | inputValue = _this$props8.inputValue,
|
2129 | tabIndex = _this$props8.tabIndex,
|
2130 | form = _this$props8.form,
|
2131 | menuIsOpen = _this$props8.menuIsOpen,
|
2132 | required = _this$props8.required;
|
2133 | var _this$getComponents = this.getComponents(),
|
2134 | Input = _this$getComponents.Input;
|
2135 | var _this$state4 = this.state,
|
2136 | inputIsHidden = _this$state4.inputIsHidden,
|
2137 | ariaSelection = _this$state4.ariaSelection;
|
2138 | var commonProps = this.commonProps;
|
2139 | var id = inputId || this.getElementId('input');
|
2140 |
|
2141 |
|
2142 | var ariaAttributes = _objectSpread(_objectSpread(_objectSpread({
|
2143 | 'aria-autocomplete': 'list',
|
2144 | 'aria-expanded': menuIsOpen,
|
2145 | 'aria-haspopup': true,
|
2146 | 'aria-errormessage': this.props['aria-errormessage'],
|
2147 | 'aria-invalid': this.props['aria-invalid'],
|
2148 | 'aria-label': this.props['aria-label'],
|
2149 | 'aria-labelledby': this.props['aria-labelledby'],
|
2150 | 'aria-required': required,
|
2151 | role: 'combobox',
|
2152 | 'aria-activedescendant': this.isAppleDevice ? undefined : this.state.focusedOptionId || ''
|
2153 | }, menuIsOpen && {
|
2154 | 'aria-controls': this.getElementId('listbox')
|
2155 | }), !isSearchable && {
|
2156 | 'aria-readonly': true
|
2157 | }), this.hasValue() ? (ariaSelection === null || ariaSelection === void 0 ? void 0 : ariaSelection.action) === 'initial-input-focus' && {
|
2158 | 'aria-describedby': this.getElementId('live-region')
|
2159 | } : {
|
2160 | 'aria-describedby': this.getElementId('placeholder')
|
2161 | });
|
2162 | if (!isSearchable) {
|
2163 |
|
2164 | return React__namespace.createElement(DummyInput, _extends({
|
2165 | id: id,
|
2166 | innerRef: this.getInputRef,
|
2167 | onBlur: this.onInputBlur,
|
2168 | onChange: index.noop,
|
2169 | onFocus: this.onInputFocus,
|
2170 | disabled: isDisabled,
|
2171 | tabIndex: tabIndex,
|
2172 | inputMode: "none",
|
2173 | form: form,
|
2174 | value: ""
|
2175 | }, ariaAttributes));
|
2176 | }
|
2177 | return React__namespace.createElement(Input, _extends({}, commonProps, {
|
2178 | autoCapitalize: "none",
|
2179 | autoComplete: "off",
|
2180 | autoCorrect: "off",
|
2181 | id: id,
|
2182 | innerRef: this.getInputRef,
|
2183 | isDisabled: isDisabled,
|
2184 | isHidden: inputIsHidden,
|
2185 | onBlur: this.onInputBlur,
|
2186 | onChange: this.handleInputChange,
|
2187 | onFocus: this.onInputFocus,
|
2188 | spellCheck: "false",
|
2189 | tabIndex: tabIndex,
|
2190 | form: form,
|
2191 | type: "text",
|
2192 | value: inputValue
|
2193 | }, ariaAttributes));
|
2194 | }
|
2195 | }, {
|
2196 | key: "renderPlaceholderOrValue",
|
2197 | value: function renderPlaceholderOrValue() {
|
2198 | var _this3 = this;
|
2199 | var _this$getComponents2 = this.getComponents(),
|
2200 | MultiValue = _this$getComponents2.MultiValue,
|
2201 | MultiValueContainer = _this$getComponents2.MultiValueContainer,
|
2202 | MultiValueLabel = _this$getComponents2.MultiValueLabel,
|
2203 | MultiValueRemove = _this$getComponents2.MultiValueRemove,
|
2204 | SingleValue = _this$getComponents2.SingleValue,
|
2205 | Placeholder = _this$getComponents2.Placeholder;
|
2206 | var commonProps = this.commonProps;
|
2207 | var _this$props9 = this.props,
|
2208 | controlShouldRenderValue = _this$props9.controlShouldRenderValue,
|
2209 | isDisabled = _this$props9.isDisabled,
|
2210 | isMulti = _this$props9.isMulti,
|
2211 | inputValue = _this$props9.inputValue,
|
2212 | placeholder = _this$props9.placeholder;
|
2213 | var _this$state5 = this.state,
|
2214 | selectValue = _this$state5.selectValue,
|
2215 | focusedValue = _this$state5.focusedValue,
|
2216 | isFocused = _this$state5.isFocused;
|
2217 | if (!this.hasValue() || !controlShouldRenderValue) {
|
2218 | return inputValue ? null : React__namespace.createElement(Placeholder, _extends({}, commonProps, {
|
2219 | key: "placeholder",
|
2220 | isDisabled: isDisabled,
|
2221 | isFocused: isFocused,
|
2222 | innerProps: {
|
2223 | id: this.getElementId('placeholder')
|
2224 | }
|
2225 | }), placeholder);
|
2226 | }
|
2227 | if (isMulti) {
|
2228 | return selectValue.map(function (opt, index) {
|
2229 | var isOptionFocused = opt === focusedValue;
|
2230 | var key = "".concat(_this3.getOptionLabel(opt), "-").concat(_this3.getOptionValue(opt));
|
2231 | return React__namespace.createElement(MultiValue, _extends({}, commonProps, {
|
2232 | components: {
|
2233 | Container: MultiValueContainer,
|
2234 | Label: MultiValueLabel,
|
2235 | Remove: MultiValueRemove
|
2236 | },
|
2237 | isFocused: isOptionFocused,
|
2238 | isDisabled: isDisabled,
|
2239 | key: key,
|
2240 | index: index,
|
2241 | removeProps: {
|
2242 | onClick: function onClick() {
|
2243 | return _this3.removeValue(opt);
|
2244 | },
|
2245 | onTouchEnd: function onTouchEnd() {
|
2246 | return _this3.removeValue(opt);
|
2247 | },
|
2248 | onMouseDown: function onMouseDown(e) {
|
2249 | e.preventDefault();
|
2250 | }
|
2251 | },
|
2252 | data: opt
|
2253 | }), _this3.formatOptionLabel(opt, 'value'));
|
2254 | });
|
2255 | }
|
2256 | if (inputValue) {
|
2257 | return null;
|
2258 | }
|
2259 | var singleValue = selectValue[0];
|
2260 | return React__namespace.createElement(SingleValue, _extends({}, commonProps, {
|
2261 | data: singleValue,
|
2262 | isDisabled: isDisabled
|
2263 | }), this.formatOptionLabel(singleValue, 'value'));
|
2264 | }
|
2265 | }, {
|
2266 | key: "renderClearIndicator",
|
2267 | value: function renderClearIndicator() {
|
2268 | var _this$getComponents3 = this.getComponents(),
|
2269 | ClearIndicator = _this$getComponents3.ClearIndicator;
|
2270 | var commonProps = this.commonProps;
|
2271 | var _this$props10 = this.props,
|
2272 | isDisabled = _this$props10.isDisabled,
|
2273 | isLoading = _this$props10.isLoading;
|
2274 | var isFocused = this.state.isFocused;
|
2275 | if (!this.isClearable() || !ClearIndicator || isDisabled || !this.hasValue() || isLoading) {
|
2276 | return null;
|
2277 | }
|
2278 | var innerProps = {
|
2279 | onMouseDown: this.onClearIndicatorMouseDown,
|
2280 | onTouchEnd: this.onClearIndicatorTouchEnd,
|
2281 | 'aria-hidden': 'true'
|
2282 | };
|
2283 | return React__namespace.createElement(ClearIndicator, _extends({}, commonProps, {
|
2284 | innerProps: innerProps,
|
2285 | isFocused: isFocused
|
2286 | }));
|
2287 | }
|
2288 | }, {
|
2289 | key: "renderLoadingIndicator",
|
2290 | value: function renderLoadingIndicator() {
|
2291 | var _this$getComponents4 = this.getComponents(),
|
2292 | LoadingIndicator = _this$getComponents4.LoadingIndicator;
|
2293 | var commonProps = this.commonProps;
|
2294 | var _this$props11 = this.props,
|
2295 | isDisabled = _this$props11.isDisabled,
|
2296 | isLoading = _this$props11.isLoading;
|
2297 | var isFocused = this.state.isFocused;
|
2298 | if (!LoadingIndicator || !isLoading) return null;
|
2299 | var innerProps = {
|
2300 | 'aria-hidden': 'true'
|
2301 | };
|
2302 | return React__namespace.createElement(LoadingIndicator, _extends({}, commonProps, {
|
2303 | innerProps: innerProps,
|
2304 | isDisabled: isDisabled,
|
2305 | isFocused: isFocused
|
2306 | }));
|
2307 | }
|
2308 | }, {
|
2309 | key: "renderIndicatorSeparator",
|
2310 | value: function renderIndicatorSeparator() {
|
2311 | var _this$getComponents5 = this.getComponents(),
|
2312 | DropdownIndicator = _this$getComponents5.DropdownIndicator,
|
2313 | IndicatorSeparator = _this$getComponents5.IndicatorSeparator;
|
2314 |
|
2315 |
|
2316 | if (!DropdownIndicator || !IndicatorSeparator) return null;
|
2317 | var commonProps = this.commonProps;
|
2318 | var isDisabled = this.props.isDisabled;
|
2319 | var isFocused = this.state.isFocused;
|
2320 | return React__namespace.createElement(IndicatorSeparator, _extends({}, commonProps, {
|
2321 | isDisabled: isDisabled,
|
2322 | isFocused: isFocused
|
2323 | }));
|
2324 | }
|
2325 | }, {
|
2326 | key: "renderDropdownIndicator",
|
2327 | value: function renderDropdownIndicator() {
|
2328 | var _this$getComponents6 = this.getComponents(),
|
2329 | DropdownIndicator = _this$getComponents6.DropdownIndicator;
|
2330 | if (!DropdownIndicator) return null;
|
2331 | var commonProps = this.commonProps;
|
2332 | var isDisabled = this.props.isDisabled;
|
2333 | var isFocused = this.state.isFocused;
|
2334 | var innerProps = {
|
2335 | onMouseDown: this.onDropdownIndicatorMouseDown,
|
2336 | onTouchEnd: this.onDropdownIndicatorTouchEnd,
|
2337 | 'aria-hidden': 'true'
|
2338 | };
|
2339 | return React__namespace.createElement(DropdownIndicator, _extends({}, commonProps, {
|
2340 | innerProps: innerProps,
|
2341 | isDisabled: isDisabled,
|
2342 | isFocused: isFocused
|
2343 | }));
|
2344 | }
|
2345 | }, {
|
2346 | key: "renderMenu",
|
2347 | value: function renderMenu() {
|
2348 | var _this4 = this;
|
2349 | var _this$getComponents7 = this.getComponents(),
|
2350 | Group = _this$getComponents7.Group,
|
2351 | GroupHeading = _this$getComponents7.GroupHeading,
|
2352 | Menu = _this$getComponents7.Menu,
|
2353 | MenuList = _this$getComponents7.MenuList,
|
2354 | MenuPortal = _this$getComponents7.MenuPortal,
|
2355 | LoadingMessage = _this$getComponents7.LoadingMessage,
|
2356 | NoOptionsMessage = _this$getComponents7.NoOptionsMessage,
|
2357 | Option = _this$getComponents7.Option;
|
2358 | var commonProps = this.commonProps;
|
2359 | var focusedOption = this.state.focusedOption;
|
2360 | var _this$props12 = this.props,
|
2361 | captureMenuScroll = _this$props12.captureMenuScroll,
|
2362 | inputValue = _this$props12.inputValue,
|
2363 | isLoading = _this$props12.isLoading,
|
2364 | loadingMessage = _this$props12.loadingMessage,
|
2365 | minMenuHeight = _this$props12.minMenuHeight,
|
2366 | maxMenuHeight = _this$props12.maxMenuHeight,
|
2367 | menuIsOpen = _this$props12.menuIsOpen,
|
2368 | menuPlacement = _this$props12.menuPlacement,
|
2369 | menuPosition = _this$props12.menuPosition,
|
2370 | menuPortalTarget = _this$props12.menuPortalTarget,
|
2371 | menuShouldBlockScroll = _this$props12.menuShouldBlockScroll,
|
2372 | menuShouldScrollIntoView = _this$props12.menuShouldScrollIntoView,
|
2373 | noOptionsMessage = _this$props12.noOptionsMessage,
|
2374 | onMenuScrollToTop = _this$props12.onMenuScrollToTop,
|
2375 | onMenuScrollToBottom = _this$props12.onMenuScrollToBottom;
|
2376 | if (!menuIsOpen) return null;
|
2377 |
|
2378 |
|
2379 | var render = function render(props, id) {
|
2380 | var type = props.type,
|
2381 | data = props.data,
|
2382 | isDisabled = props.isDisabled,
|
2383 | isSelected = props.isSelected,
|
2384 | label = props.label,
|
2385 | value = props.value;
|
2386 | var isFocused = focusedOption === data;
|
2387 | var onHover = isDisabled ? undefined : function () {
|
2388 | return _this4.onOptionHover(data);
|
2389 | };
|
2390 | var onSelect = isDisabled ? undefined : function () {
|
2391 | return _this4.selectOption(data);
|
2392 | };
|
2393 | var optionId = "".concat(_this4.getElementId('option'), "-").concat(id);
|
2394 | var innerProps = {
|
2395 | id: optionId,
|
2396 | onClick: onSelect,
|
2397 | onMouseMove: onHover,
|
2398 | onMouseOver: onHover,
|
2399 | tabIndex: -1,
|
2400 | role: 'option',
|
2401 | 'aria-selected': _this4.isAppleDevice ? undefined : isSelected
|
2402 | };
|
2403 |
|
2404 | return React__namespace.createElement(Option, _extends({}, commonProps, {
|
2405 | innerProps: innerProps,
|
2406 | data: data,
|
2407 | isDisabled: isDisabled,
|
2408 | isSelected: isSelected,
|
2409 | key: optionId,
|
2410 | label: label,
|
2411 | type: type,
|
2412 | value: value,
|
2413 | isFocused: isFocused,
|
2414 | innerRef: isFocused ? _this4.getFocusedOptionRef : undefined
|
2415 | }), _this4.formatOptionLabel(props.data, 'menu'));
|
2416 | };
|
2417 | var menuUI;
|
2418 | if (this.hasOptions()) {
|
2419 | menuUI = this.getCategorizedOptions().map(function (item) {
|
2420 | if (item.type === 'group') {
|
2421 | var _data = item.data,
|
2422 | options = item.options,
|
2423 | groupIndex = item.index;
|
2424 | var groupId = "".concat(_this4.getElementId('group'), "-").concat(groupIndex);
|
2425 | var headingId = "".concat(groupId, "-heading");
|
2426 | return React__namespace.createElement(Group, _extends({}, commonProps, {
|
2427 | key: groupId,
|
2428 | data: _data,
|
2429 | options: options,
|
2430 | Heading: GroupHeading,
|
2431 | headingProps: {
|
2432 | id: headingId,
|
2433 | data: item.data
|
2434 | },
|
2435 | label: _this4.formatGroupLabel(item.data)
|
2436 | }), item.options.map(function (option) {
|
2437 | return render(option, "".concat(groupIndex, "-").concat(option.index));
|
2438 | }));
|
2439 | } else if (item.type === 'option') {
|
2440 | return render(item, "".concat(item.index));
|
2441 | }
|
2442 | });
|
2443 | } else if (isLoading) {
|
2444 | var message = loadingMessage({
|
2445 | inputValue: inputValue
|
2446 | });
|
2447 | if (message === null) return null;
|
2448 | menuUI = React__namespace.createElement(LoadingMessage, commonProps, message);
|
2449 | } else {
|
2450 | var _message = noOptionsMessage({
|
2451 | inputValue: inputValue
|
2452 | });
|
2453 | if (_message === null) return null;
|
2454 | menuUI = React__namespace.createElement(NoOptionsMessage, commonProps, _message);
|
2455 | }
|
2456 | var menuPlacementProps = {
|
2457 | minMenuHeight: minMenuHeight,
|
2458 | maxMenuHeight: maxMenuHeight,
|
2459 | menuPlacement: menuPlacement,
|
2460 | menuPosition: menuPosition,
|
2461 | menuShouldScrollIntoView: menuShouldScrollIntoView
|
2462 | };
|
2463 | var menuElement = React__namespace.createElement(index.MenuPlacer, _extends({}, commonProps, menuPlacementProps), function (_ref4) {
|
2464 | var ref = _ref4.ref,
|
2465 | _ref4$placerProps = _ref4.placerProps,
|
2466 | placement = _ref4$placerProps.placement,
|
2467 | maxHeight = _ref4$placerProps.maxHeight;
|
2468 | return React__namespace.createElement(Menu, _extends({}, commonProps, menuPlacementProps, {
|
2469 | innerRef: ref,
|
2470 | innerProps: {
|
2471 | onMouseDown: _this4.onMenuMouseDown,
|
2472 | onMouseMove: _this4.onMenuMouseMove
|
2473 | },
|
2474 | isLoading: isLoading,
|
2475 | placement: placement
|
2476 | }), React__namespace.createElement(ScrollManager, {
|
2477 | captureEnabled: captureMenuScroll,
|
2478 | onTopArrive: onMenuScrollToTop,
|
2479 | onBottomArrive: onMenuScrollToBottom,
|
2480 | lockEnabled: menuShouldBlockScroll
|
2481 | }, function (scrollTargetRef) {
|
2482 | return React__namespace.createElement(MenuList, _extends({}, commonProps, {
|
2483 | innerRef: function innerRef(instance) {
|
2484 | _this4.getMenuListRef(instance);
|
2485 | scrollTargetRef(instance);
|
2486 | },
|
2487 | innerProps: {
|
2488 | role: 'listbox',
|
2489 | 'aria-multiselectable': commonProps.isMulti,
|
2490 | id: _this4.getElementId('listbox')
|
2491 | },
|
2492 | isLoading: isLoading,
|
2493 | maxHeight: maxHeight,
|
2494 | focusedOption: focusedOption
|
2495 | }), menuUI);
|
2496 | }));
|
2497 | });
|
2498 |
|
2499 |
|
2500 |
|
2501 |
|
2502 | return menuPortalTarget || menuPosition === 'fixed' ? React__namespace.createElement(MenuPortal, _extends({}, commonProps, {
|
2503 | appendTo: menuPortalTarget,
|
2504 | controlElement: this.controlRef,
|
2505 | menuPlacement: menuPlacement,
|
2506 | menuPosition: menuPosition
|
2507 | }), menuElement) : menuElement;
|
2508 | }
|
2509 | }, {
|
2510 | key: "renderFormField",
|
2511 | value: function renderFormField() {
|
2512 | var _this5 = this;
|
2513 | var _this$props13 = this.props,
|
2514 | delimiter = _this$props13.delimiter,
|
2515 | isDisabled = _this$props13.isDisabled,
|
2516 | isMulti = _this$props13.isMulti,
|
2517 | name = _this$props13.name,
|
2518 | required = _this$props13.required;
|
2519 | var selectValue = this.state.selectValue;
|
2520 | if (required && !this.hasValue() && !isDisabled) {
|
2521 | return React__namespace.createElement(RequiredInput$1, {
|
2522 | name: name,
|
2523 | onFocus: this.onValueInputFocus
|
2524 | });
|
2525 | }
|
2526 | if (!name || isDisabled) return;
|
2527 | if (isMulti) {
|
2528 | if (delimiter) {
|
2529 | var value = selectValue.map(function (opt) {
|
2530 | return _this5.getOptionValue(opt);
|
2531 | }).join(delimiter);
|
2532 | return React__namespace.createElement("input", {
|
2533 | name: name,
|
2534 | type: "hidden",
|
2535 | value: value
|
2536 | });
|
2537 | } else {
|
2538 | var input = selectValue.length > 0 ? selectValue.map(function (opt, i) {
|
2539 | return React__namespace.createElement("input", {
|
2540 | key: "i-".concat(i),
|
2541 | name: name,
|
2542 | type: "hidden",
|
2543 | value: _this5.getOptionValue(opt)
|
2544 | });
|
2545 | }) : React__namespace.createElement("input", {
|
2546 | name: name,
|
2547 | type: "hidden",
|
2548 | value: ""
|
2549 | });
|
2550 | return React__namespace.createElement("div", null, input);
|
2551 | }
|
2552 | } else {
|
2553 | var _value = selectValue[0] ? this.getOptionValue(selectValue[0]) : '';
|
2554 | return React__namespace.createElement("input", {
|
2555 | name: name,
|
2556 | type: "hidden",
|
2557 | value: _value
|
2558 | });
|
2559 | }
|
2560 | }
|
2561 | }, {
|
2562 | key: "renderLiveRegion",
|
2563 | value: function renderLiveRegion() {
|
2564 | var commonProps = this.commonProps;
|
2565 | var _this$state6 = this.state,
|
2566 | ariaSelection = _this$state6.ariaSelection,
|
2567 | focusedOption = _this$state6.focusedOption,
|
2568 | focusedValue = _this$state6.focusedValue,
|
2569 | isFocused = _this$state6.isFocused,
|
2570 | selectValue = _this$state6.selectValue;
|
2571 | var focusableOptions = this.getFocusableOptions();
|
2572 | return React__namespace.createElement(LiveRegion$1, _extends({}, commonProps, {
|
2573 | id: this.getElementId('live-region'),
|
2574 | ariaSelection: ariaSelection,
|
2575 | focusedOption: focusedOption,
|
2576 | focusedValue: focusedValue,
|
2577 | isFocused: isFocused,
|
2578 | selectValue: selectValue,
|
2579 | focusableOptions: focusableOptions,
|
2580 | isAppleDevice: this.isAppleDevice
|
2581 | }));
|
2582 | }
|
2583 | }, {
|
2584 | key: "render",
|
2585 | value: function render() {
|
2586 | var _this$getComponents8 = this.getComponents(),
|
2587 | Control = _this$getComponents8.Control,
|
2588 | IndicatorsContainer = _this$getComponents8.IndicatorsContainer,
|
2589 | SelectContainer = _this$getComponents8.SelectContainer,
|
2590 | ValueContainer = _this$getComponents8.ValueContainer;
|
2591 | var _this$props14 = this.props,
|
2592 | className = _this$props14.className,
|
2593 | id = _this$props14.id,
|
2594 | isDisabled = _this$props14.isDisabled,
|
2595 | menuIsOpen = _this$props14.menuIsOpen;
|
2596 | var isFocused = this.state.isFocused;
|
2597 | var commonProps = this.commonProps = this.getCommonProps();
|
2598 | return React__namespace.createElement(SelectContainer, _extends({}, commonProps, {
|
2599 | className: className,
|
2600 | innerProps: {
|
2601 | id: id,
|
2602 | onKeyDown: this.onKeyDown
|
2603 | },
|
2604 | isDisabled: isDisabled,
|
2605 | isFocused: isFocused
|
2606 | }), this.renderLiveRegion(), React__namespace.createElement(Control, _extends({}, commonProps, {
|
2607 | innerRef: this.getControlRef,
|
2608 | innerProps: {
|
2609 | onMouseDown: this.onControlMouseDown,
|
2610 | onTouchEnd: this.onControlTouchEnd
|
2611 | },
|
2612 | isDisabled: isDisabled,
|
2613 | isFocused: isFocused,
|
2614 | menuIsOpen: menuIsOpen
|
2615 | }), React__namespace.createElement(ValueContainer, _extends({}, commonProps, {
|
2616 | isDisabled: isDisabled
|
2617 | }), this.renderPlaceholderOrValue(), this.renderInput()), React__namespace.createElement(IndicatorsContainer, _extends({}, commonProps, {
|
2618 | isDisabled: isDisabled
|
2619 | }), this.renderClearIndicator(), this.renderLoadingIndicator(), this.renderIndicatorSeparator(), this.renderDropdownIndicator())), this.renderMenu(), this.renderFormField());
|
2620 | }
|
2621 | }], [{
|
2622 | key: "getDerivedStateFromProps",
|
2623 | value: function getDerivedStateFromProps(props, state) {
|
2624 | var prevProps = state.prevProps,
|
2625 | clearFocusValueOnUpdate = state.clearFocusValueOnUpdate,
|
2626 | inputIsHiddenAfterUpdate = state.inputIsHiddenAfterUpdate,
|
2627 | ariaSelection = state.ariaSelection,
|
2628 | isFocused = state.isFocused,
|
2629 | prevWasFocused = state.prevWasFocused,
|
2630 | instancePrefix = state.instancePrefix;
|
2631 | var options = props.options,
|
2632 | value = props.value,
|
2633 | menuIsOpen = props.menuIsOpen,
|
2634 | inputValue = props.inputValue,
|
2635 | isMulti = props.isMulti;
|
2636 | var selectValue = index.cleanValue(value);
|
2637 | var newMenuOptionsState = {};
|
2638 | if (prevProps && (value !== prevProps.value || options !== prevProps.options || menuIsOpen !== prevProps.menuIsOpen || inputValue !== prevProps.inputValue)) {
|
2639 | var focusableOptions = menuIsOpen ? buildFocusableOptions(props, selectValue) : [];
|
2640 | var focusableOptionsWithIds = menuIsOpen ? buildFocusableOptionsWithIds(buildCategorizedOptions(props, selectValue), "".concat(instancePrefix, "-option")) : [];
|
2641 | var focusedValue = clearFocusValueOnUpdate ? getNextFocusedValue(state, selectValue) : null;
|
2642 | var focusedOption = getNextFocusedOption(state, focusableOptions);
|
2643 | var focusedOptionId = getFocusedOptionId(focusableOptionsWithIds, focusedOption);
|
2644 | newMenuOptionsState = {
|
2645 | selectValue: selectValue,
|
2646 | focusedOption: focusedOption,
|
2647 | focusedOptionId: focusedOptionId,
|
2648 | focusableOptionsWithIds: focusableOptionsWithIds,
|
2649 | focusedValue: focusedValue,
|
2650 | clearFocusValueOnUpdate: false
|
2651 | };
|
2652 | }
|
2653 |
|
2654 | var newInputIsHiddenState = inputIsHiddenAfterUpdate != null && props !== prevProps ? {
|
2655 | inputIsHidden: inputIsHiddenAfterUpdate,
|
2656 | inputIsHiddenAfterUpdate: undefined
|
2657 | } : {};
|
2658 | var newAriaSelection = ariaSelection;
|
2659 | var hasKeptFocus = isFocused && prevWasFocused;
|
2660 | if (isFocused && !hasKeptFocus) {
|
2661 |
|
2662 |
|
2663 | newAriaSelection = {
|
2664 | value: index.valueTernary(isMulti, selectValue, selectValue[0] || null),
|
2665 | options: selectValue,
|
2666 | action: 'initial-input-focus'
|
2667 | };
|
2668 | hasKeptFocus = !prevWasFocused;
|
2669 | }
|
2670 |
|
2671 |
|
2672 |
|
2673 | if ((ariaSelection === null || ariaSelection === void 0 ? void 0 : ariaSelection.action) === 'initial-input-focus') {
|
2674 | newAriaSelection = null;
|
2675 | }
|
2676 | return _objectSpread(_objectSpread(_objectSpread({}, newMenuOptionsState), newInputIsHiddenState), {}, {
|
2677 | prevProps: props,
|
2678 | ariaSelection: newAriaSelection,
|
2679 | prevWasFocused: hasKeptFocus
|
2680 | });
|
2681 | }
|
2682 | }]);
|
2683 | return Select;
|
2684 | }(React.Component);
|
2685 | Select.defaultProps = defaultProps;
|
2686 |
|
2687 | exports.Select = Select;
|
2688 | exports.createFilter = createFilter;
|
2689 | exports.defaultProps = defaultProps;
|
2690 | exports.defaultTheme = defaultTheme;
|
2691 | exports.getOptionLabel = getOptionLabel$1;
|
2692 | exports.getOptionValue = getOptionValue$1;
|
2693 | exports.mergeStyles = mergeStyles;
|