UNPKG

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