Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

2735 строки
91 KiB

  1. import React, { Component, PureComponent } from 'react';
  2. import memoizeOne from 'memoize-one';
  3. import { jsx } from '@emotion/core';
  4. import { findDOMNode } from 'react-dom';
  5. import { i as isTouchCapable, d as isMobileDevice, e as cleanValue, f as scrollIntoView, h as classNames, n as noop, j as isDocumentElement } from './utils-06b0d5a4.browser.esm.js';
  6. import { c as clearIndicatorCSS, a as containerCSS, b as css, d as dropdownIndicatorCSS, g as groupCSS, e as groupHeadingCSS, i as indicatorsContainerCSS, f as indicatorSeparatorCSS, h as inputCSS, l as loadingIndicatorCSS, j as loadingMessageCSS, m as menuCSS, k as menuListCSS, n as menuPortalCSS, o as multiValueCSS, p as multiValueLabelCSS, q as multiValueRemoveCSS, r as noOptionsMessageCSS, s as optionCSS, t as placeholderCSS, u as css$1, v as valueContainerCSS, M as MenuPlacer, w as defaultComponents, x as exportedEqual } from './index-4322c0ed.browser.esm.js';
  7. import _css from '@emotion/css';
  8. var diacritics = [{
  9. base: 'A',
  10. letters: /[\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F]/g
  11. }, {
  12. base: 'AA',
  13. letters: /[\uA732]/g
  14. }, {
  15. base: 'AE',
  16. letters: /[\u00C6\u01FC\u01E2]/g
  17. }, {
  18. base: 'AO',
  19. letters: /[\uA734]/g
  20. }, {
  21. base: 'AU',
  22. letters: /[\uA736]/g
  23. }, {
  24. base: 'AV',
  25. letters: /[\uA738\uA73A]/g
  26. }, {
  27. base: 'AY',
  28. letters: /[\uA73C]/g
  29. }, {
  30. base: 'B',
  31. letters: /[\u0042\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181]/g
  32. }, {
  33. base: 'C',
  34. letters: /[\u0043\u24B8\uFF23\u0106\u0108\u010A\u010C\u00C7\u1E08\u0187\u023B\uA73E]/g
  35. }, {
  36. base: 'D',
  37. letters: /[\u0044\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018B\u018A\u0189\uA779]/g
  38. }, {
  39. base: 'DZ',
  40. letters: /[\u01F1\u01C4]/g
  41. }, {
  42. base: 'Dz',
  43. letters: /[\u01F2\u01C5]/g
  44. }, {
  45. base: 'E',
  46. letters: /[\u0045\u24BA\uFF25\u00C8\u00C9\u00CA\u1EC0\u1EBE\u1EC4\u1EC2\u1EBC\u0112\u1E14\u1E16\u0114\u0116\u00CB\u1EBA\u011A\u0204\u0206\u1EB8\u1EC6\u0228\u1E1C\u0118\u1E18\u1E1A\u0190\u018E]/g
  47. }, {
  48. base: 'F',
  49. letters: /[\u0046\u24BB\uFF26\u1E1E\u0191\uA77B]/g
  50. }, {
  51. base: 'G',
  52. letters: /[\u0047\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E]/g
  53. }, {
  54. base: 'H',
  55. letters: /[\u0048\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D]/g
  56. }, {
  57. base: 'I',
  58. letters: /[\u0049\u24BE\uFF29\u00CC\u00CD\u00CE\u0128\u012A\u012C\u0130\u00CF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197]/g
  59. }, {
  60. base: 'J',
  61. letters: /[\u004A\u24BF\uFF2A\u0134\u0248]/g
  62. }, {
  63. base: 'K',
  64. letters: /[\u004B\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2]/g
  65. }, {
  66. base: 'L',
  67. letters: /[\u004C\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780]/g
  68. }, {
  69. base: 'LJ',
  70. letters: /[\u01C7]/g
  71. }, {
  72. base: 'Lj',
  73. letters: /[\u01C8]/g
  74. }, {
  75. base: 'M',
  76. letters: /[\u004D\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C]/g
  77. }, {
  78. base: 'N',
  79. letters: /[\u004E\u24C3\uFF2E\u01F8\u0143\u00D1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u0220\u019D\uA790\uA7A4]/g
  80. }, {
  81. base: 'NJ',
  82. letters: /[\u01CA]/g
  83. }, {
  84. base: 'Nj',
  85. letters: /[\u01CB]/g
  86. }, {
  87. base: 'O',
  88. letters: /[\u004F\u24C4\uFF2F\u00D2\u00D3\u00D4\u1ED2\u1ED0\u1ED6\u1ED4\u00D5\u1E4C\u022C\u1E4E\u014C\u1E50\u1E52\u014E\u022E\u0230\u00D6\u022A\u1ECE\u0150\u01D1\u020C\u020E\u01A0\u1EDC\u1EDA\u1EE0\u1EDE\u1EE2\u1ECC\u1ED8\u01EA\u01EC\u00D8\u01FE\u0186\u019F\uA74A\uA74C]/g
  89. }, {
  90. base: 'OI',
  91. letters: /[\u01A2]/g
  92. }, {
  93. base: 'OO',
  94. letters: /[\uA74E]/g
  95. }, {
  96. base: 'OU',
  97. letters: /[\u0222]/g
  98. }, {
  99. base: 'P',
  100. letters: /[\u0050\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754]/g
  101. }, {
  102. base: 'Q',
  103. letters: /[\u0051\u24C6\uFF31\uA756\uA758\u024A]/g
  104. }, {
  105. base: 'R',
  106. letters: /[\u0052\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782]/g
  107. }, {
  108. base: 'S',
  109. letters: /[\u0053\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784]/g
  110. }, {
  111. base: 'T',
  112. letters: /[\u0054\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786]/g
  113. }, {
  114. base: 'TZ',
  115. letters: /[\uA728]/g
  116. }, {
  117. base: 'U',
  118. letters: /[\u0055\u24CA\uFF35\u00D9\u00DA\u00DB\u0168\u1E78\u016A\u1E7A\u016C\u00DC\u01DB\u01D7\u01D5\u01D9\u1EE6\u016E\u0170\u01D3\u0214\u0216\u01AF\u1EEA\u1EE8\u1EEE\u1EEC\u1EF0\u1EE4\u1E72\u0172\u1E76\u1E74\u0244]/g
  119. }, {
  120. base: 'V',
  121. letters: /[\u0056\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245]/g
  122. }, {
  123. base: 'VY',
  124. letters: /[\uA760]/g
  125. }, {
  126. base: 'W',
  127. letters: /[\u0057\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72]/g
  128. }, {
  129. base: 'X',
  130. letters: /[\u0058\u24CD\uFF38\u1E8A\u1E8C]/g
  131. }, {
  132. base: 'Y',
  133. letters: /[\u0059\u24CE\uFF39\u1EF2\u00DD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE]/g
  134. }, {
  135. base: 'Z',
  136. letters: /[\u005A\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762]/g
  137. }, {
  138. base: 'a',
  139. letters: /[\u0061\u24D0\uFF41\u1E9A\u00E0\u00E1\u00E2\u1EA7\u1EA5\u1EAB\u1EA9\u00E3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\u00E4\u01DF\u1EA3\u00E5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250]/g
  140. }, {
  141. base: 'aa',
  142. letters: /[\uA733]/g
  143. }, {
  144. base: 'ae',
  145. letters: /[\u00E6\u01FD\u01E3]/g
  146. }, {
  147. base: 'ao',
  148. letters: /[\uA735]/g
  149. }, {
  150. base: 'au',
  151. letters: /[\uA737]/g
  152. }, {
  153. base: 'av',
  154. letters: /[\uA739\uA73B]/g
  155. }, {
  156. base: 'ay',
  157. letters: /[\uA73D]/g
  158. }, {
  159. base: 'b',
  160. letters: /[\u0062\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253]/g
  161. }, {
  162. base: 'c',
  163. letters: /[\u0063\u24D2\uFF43\u0107\u0109\u010B\u010D\u00E7\u1E09\u0188\u023C\uA73F\u2184]/g
  164. }, {
  165. base: 'd',
  166. letters: /[\u0064\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\uA77A]/g
  167. }, {
  168. base: 'dz',
  169. letters: /[\u01F3\u01C6]/g
  170. }, {
  171. base: 'e',
  172. letters: /[\u0065\u24D4\uFF45\u00E8\u00E9\u00EA\u1EC1\u1EBF\u1EC5\u1EC3\u1EBD\u0113\u1E15\u1E17\u0115\u0117\u00EB\u1EBB\u011B\u0205\u0207\u1EB9\u1EC7\u0229\u1E1D\u0119\u1E19\u1E1B\u0247\u025B\u01DD]/g
  173. }, {
  174. base: 'f',
  175. letters: /[\u0066\u24D5\uFF46\u1E1F\u0192\uA77C]/g
  176. }, {
  177. base: 'g',
  178. letters: /[\u0067\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F]/g
  179. }, {
  180. base: 'h',
  181. letters: /[\u0068\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265]/g
  182. }, {
  183. base: 'hv',
  184. letters: /[\u0195]/g
  185. }, {
  186. base: 'i',
  187. letters: /[\u0069\u24D8\uFF49\u00EC\u00ED\u00EE\u0129\u012B\u012D\u00EF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131]/g
  188. }, {
  189. base: 'j',
  190. letters: /[\u006A\u24D9\uFF4A\u0135\u01F0\u0249]/g
  191. }, {
  192. base: 'k',
  193. letters: /[\u006B\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3]/g
  194. }, {
  195. base: 'l',
  196. letters: /[\u006C\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747]/g
  197. }, {
  198. base: 'lj',
  199. letters: /[\u01C9]/g
  200. }, {
  201. base: 'm',
  202. letters: /[\u006D\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F]/g
  203. }, {
  204. base: 'n',
  205. letters: /[\u006E\u24DD\uFF4E\u01F9\u0144\u00F1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5]/g
  206. }, {
  207. base: 'nj',
  208. letters: /[\u01CC]/g
  209. }, {
  210. base: 'o',
  211. letters: /[\u006F\u24DE\uFF4F\u00F2\u00F3\u00F4\u1ED3\u1ED1\u1ED7\u1ED5\u00F5\u1E4D\u022D\u1E4F\u014D\u1E51\u1E53\u014F\u022F\u0231\u00F6\u022B\u1ECF\u0151\u01D2\u020D\u020F\u01A1\u1EDD\u1EDB\u1EE1\u1EDF\u1EE3\u1ECD\u1ED9\u01EB\u01ED\u00F8\u01FF\u0254\uA74B\uA74D\u0275]/g
  212. }, {
  213. base: 'oi',
  214. letters: /[\u01A3]/g
  215. }, {
  216. base: 'ou',
  217. letters: /[\u0223]/g
  218. }, {
  219. base: 'oo',
  220. letters: /[\uA74F]/g
  221. }, {
  222. base: 'p',
  223. letters: /[\u0070\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755]/g
  224. }, {
  225. base: 'q',
  226. letters: /[\u0071\u24E0\uFF51\u024B\uA757\uA759]/g
  227. }, {
  228. base: 'r',
  229. letters: /[\u0072\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783]/g
  230. }, {
  231. base: 's',
  232. letters: /[\u0073\u24E2\uFF53\u00DF\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B]/g
  233. }, {
  234. base: 't',
  235. letters: /[\u0074\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787]/g
  236. }, {
  237. base: 'tz',
  238. letters: /[\uA729]/g
  239. }, {
  240. base: 'u',
  241. letters: /[\u0075\u24E4\uFF55\u00F9\u00FA\u00FB\u0169\u1E79\u016B\u1E7B\u016D\u00FC\u01DC\u01D8\u01D6\u01DA\u1EE7\u016F\u0171\u01D4\u0215\u0217\u01B0\u1EEB\u1EE9\u1EEF\u1EED\u1EF1\u1EE5\u1E73\u0173\u1E77\u1E75\u0289]/g
  242. }, {
  243. base: 'v',
  244. letters: /[\u0076\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C]/g
  245. }, {
  246. base: 'vy',
  247. letters: /[\uA761]/g
  248. }, {
  249. base: 'w',
  250. letters: /[\u0077\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73]/g
  251. }, {
  252. base: 'x',
  253. letters: /[\u0078\u24E7\uFF58\u1E8B\u1E8D]/g
  254. }, {
  255. base: 'y',
  256. letters: /[\u0079\u24E8\uFF59\u1EF3\u00FD\u0177\u1EF9\u0233\u1E8F\u00FF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF]/g
  257. }, {
  258. base: 'z',
  259. letters: /[\u007A\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763]/g
  260. }];
  261. var stripDiacritics = function stripDiacritics(str) {
  262. for (var i = 0; i < diacritics.length; i++) {
  263. str = str.replace(diacritics[i].letters, diacritics[i].base);
  264. }
  265. return str;
  266. };
  267. function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
  268. var trimString = function trimString(str) {
  269. return str.replace(/^\s+|\s+$/g, '');
  270. };
  271. var defaultStringify = function defaultStringify(option) {
  272. return option.label + " " + option.value;
  273. };
  274. var createFilter = function createFilter(config) {
  275. return function (option, rawInput) {
  276. var _ignoreCase$ignoreAcc = _extends({
  277. ignoreCase: true,
  278. ignoreAccents: true,
  279. stringify: defaultStringify,
  280. trim: true,
  281. matchFrom: 'any'
  282. }, config),
  283. ignoreCase = _ignoreCase$ignoreAcc.ignoreCase,
  284. ignoreAccents = _ignoreCase$ignoreAcc.ignoreAccents,
  285. stringify = _ignoreCase$ignoreAcc.stringify,
  286. trim = _ignoreCase$ignoreAcc.trim,
  287. matchFrom = _ignoreCase$ignoreAcc.matchFrom;
  288. var input = trim ? trimString(rawInput) : rawInput;
  289. var candidate = trim ? trimString(stringify(option)) : stringify(option);
  290. if (ignoreCase) {
  291. input = input.toLowerCase();
  292. candidate = candidate.toLowerCase();
  293. }
  294. if (ignoreAccents) {
  295. input = stripDiacritics(input);
  296. candidate = stripDiacritics(candidate);
  297. }
  298. return matchFrom === 'start' ? candidate.substr(0, input.length) === input : candidate.indexOf(input) > -1;
  299. };
  300. };
  301. function _extends$1() { _extends$1 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1.apply(this, arguments); }
  302. var _ref = process.env.NODE_ENV === "production" ? {
  303. name: "1laao21-a11yText",
  304. 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;"
  305. } : {
  306. name: "1laao21-a11yText",
  307. 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;",
  308. map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkExMXlUZXh0LmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQVFNIiwiZmlsZSI6IkExMXlUZXh0LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8gQGZsb3dcbi8qKiBAanN4IGpzeCAqL1xuaW1wb3J0IHsgdHlwZSBFbGVtZW50Q29uZmlnIH0gZnJvbSAncmVhY3QnO1xuaW1wb3J0IHsganN4IH0gZnJvbSAnQGVtb3Rpb24vY29yZSc7XG5cbi8vIEFzc2lzdGl2ZSB0ZXh0IHRvIGRlc2NyaWJlIHZpc3VhbCBlbGVtZW50cy4gSGlkZGVuIGZvciBzaWdodGVkIHVzZXJzLlxuY29uc3QgQTExeVRleHQgPSAocHJvcHM6IEVsZW1lbnRDb25maWc8J3NwYW4nPikgPT4gKFxuICAgIDxzcGFuXG4gICAgICBjc3M9e3tcbiAgICAgICAgbGFiZWw6ICdhMTF5VGV4dCcsXG4gICAgICAgIHpJbmRleDogOTk5OSxcbiAgICAgICAgYm9yZGVyOiAwLFxuICAgICAgICBjbGlwOiAncmVjdCgxcHgsIDFweCwgMXB4LCAxcHgpJyxcbiAgICAgICAgaGVpZ2h0OiAxLFxuICAgICAgICB3aWR0aDogMSxcbiAgICAgICAgcG9zaXRpb246ICdhYnNvbHV0ZScsXG4gICAgICAgIG92ZXJmbG93OiAnaGlkZGVuJyxcbiAgICAgICAgcGFkZGluZzogMCxcbiAgICAgICAgd2hpdGVTcGFjZTogJ25vd3JhcCcsXG4gICAgICB9fVxuICAgICAgey4uLnByb3BzfVxuICAgIC8+XG4pO1xuXG5leHBvcnQgZGVmYXVsdCBBMTF5VGV4dDtcbiJdfQ== */"
  309. };
  310. var A11yText = function A11yText(props) {
  311. return jsx("span", _extends$1({
  312. css: _ref
  313. }, props));
  314. };
  315. function _extends$2() { _extends$2 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$2.apply(this, arguments); }
  316. function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
  317. function DummyInput(_ref) {
  318. var inProp = _ref.in,
  319. out = _ref.out,
  320. onExited = _ref.onExited,
  321. appear = _ref.appear,
  322. enter = _ref.enter,
  323. exit = _ref.exit,
  324. innerRef = _ref.innerRef,
  325. emotion = _ref.emotion,
  326. props = _objectWithoutPropertiesLoose(_ref, ["in", "out", "onExited", "appear", "enter", "exit", "innerRef", "emotion"]);
  327. return jsx("input", _extends$2({
  328. ref: innerRef
  329. }, props, {
  330. css:
  331. /*#__PURE__*/
  332. _css({
  333. label: 'dummyInput',
  334. // get rid of any default styles
  335. background: 0,
  336. border: 0,
  337. fontSize: 'inherit',
  338. outline: 0,
  339. padding: 0,
  340. // important! without `width` browsers won't allow focus
  341. width: 1,
  342. // remove cursor on desktop
  343. color: 'transparent',
  344. // remove cursor on mobile whilst maintaining "scroll into view" behaviour
  345. left: -100,
  346. opacity: 0,
  347. position: 'relative',
  348. transform: 'scale(0)'
  349. }, process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkR1bW15SW5wdXQuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBbUJNIiwiZmlsZSI6IkR1bW15SW5wdXQuanMiLCJzb3VyY2VzQ29udGVudCI6WyIvLyBAZmxvd1xuLyoqIEBqc3gganN4ICovXG5pbXBvcnQgeyBqc3ggfSBmcm9tICdAZW1vdGlvbi9jb3JlJztcblxuZXhwb3J0IGRlZmF1bHQgZnVuY3Rpb24gRHVtbXlJbnB1dCh7XG4gIGluOiBpblByb3AsXG4gIG91dCxcbiAgb25FeGl0ZWQsXG4gIGFwcGVhcixcbiAgZW50ZXIsXG4gIGV4aXQsXG4gIGlubmVyUmVmLFxuICBlbW90aW9uLFxuICAuLi5wcm9wc1xufTogYW55KSB7XG4gIHJldHVybiAoXG4gICAgPGlucHV0XG4gICAgICByZWY9e2lubmVyUmVmfVxuICAgICAgey4uLnByb3BzfVxuICAgICAgY3NzPXt7XG4gICAgICAgIGxhYmVsOiAnZHVtbXlJbnB1dCcsXG4gICAgICAgIC8vIGdldCByaWQgb2YgYW55IGRlZmF1bHQgc3R5bGVzXG4gICAgICAgIGJhY2tncm91bmQ6IDAsXG4gICAgICAgIGJvcmRlcjogMCxcbiAgICAgICAgZm9udFNpemU6ICdpbmhlcml0JyxcbiAgICAgICAgb3V0bGluZTogMCxcbiAgICAgICAgcGFkZGluZzogMCxcbiAgICAgICAgLy8gaW1wb3J0YW50ISB3aXRob3V0IGB3aWR0aGAgYnJvd3NlcnMgd29uJ3QgYWxsb3cgZm9jdXNcbiAgICAgICAgd2lkdGg6IDEsXG5cbiAgICAgICAgLy8gcmVtb3ZlIGN1cnNvciBvbiBkZXNrdG9wXG4gICAgICAgIGNvbG9yOiAndHJhbnNwYXJlbnQnLFxuXG4gICAgICAgIC8vIHJlbW92ZSBjdXJzb3Igb24gbW9iaWxlIHdoaWxzdCBtYWludGFpbmluZyBcInNjcm9sbCBpbnRvIHZpZXdcIiBiZWhhdmlvdXJcbiAgICAgICAgbGVmdDogLTEwMCxcbiAgICAgICAgb3BhY2l0eTogMCxcbiAgICAgICAgcG9zaXRpb246ICdyZWxhdGl2ZScsXG4gICAgICAgIHRyYW5zZm9ybTogJ3NjYWxlKDApJyxcbiAgICAgIH19XG4gICAgLz5cbiAgKTtcbn1cbiJdfQ== */")
  350. }));
  351. }
  352. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  353. var NodeResolver =
  354. /*#__PURE__*/
  355. function (_Component) {
  356. _inheritsLoose(NodeResolver, _Component);
  357. function NodeResolver() {
  358. return _Component.apply(this, arguments) || this;
  359. }
  360. var _proto = NodeResolver.prototype;
  361. _proto.componentDidMount = function componentDidMount() {
  362. this.props.innerRef(findDOMNode(this));
  363. };
  364. _proto.componentWillUnmount = function componentWillUnmount() {
  365. this.props.innerRef(null);
  366. };
  367. _proto.render = function render() {
  368. return this.props.children;
  369. };
  370. return NodeResolver;
  371. }(Component);
  372. var STYLE_KEYS = ['boxSizing', 'height', 'overflow', 'paddingRight', 'position'];
  373. var LOCK_STYLES = {
  374. boxSizing: 'border-box',
  375. // account for possible declaration `width: 100%;` on body
  376. overflow: 'hidden',
  377. position: 'relative',
  378. height: '100%'
  379. };
  380. function preventTouchMove(e) {
  381. e.preventDefault();
  382. }
  383. function allowTouchMove(e) {
  384. e.stopPropagation();
  385. }
  386. function preventInertiaScroll() {
  387. var top = this.scrollTop;
  388. var totalScroll = this.scrollHeight;
  389. var currentScroll = top + this.offsetHeight;
  390. if (top === 0) {
  391. this.scrollTop = 1;
  392. } else if (currentScroll === totalScroll) {
  393. this.scrollTop = top - 1;
  394. }
  395. } // `ontouchstart` check works on most browsers
  396. // `maxTouchPoints` works on IE10/11 and Surface
  397. function isTouchDevice() {
  398. return 'ontouchstart' in window || navigator.maxTouchPoints;
  399. }
  400. function _inheritsLoose$1(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  401. var canUseDOM = !!( window.document && window.document.createElement);
  402. var activeScrollLocks = 0;
  403. var ScrollLock =
  404. /*#__PURE__*/
  405. function (_Component) {
  406. _inheritsLoose$1(ScrollLock, _Component);
  407. function ScrollLock() {
  408. var _this;
  409. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  410. args[_key] = arguments[_key];
  411. }
  412. _this = _Component.call.apply(_Component, [this].concat(args)) || this;
  413. _this.originalStyles = {};
  414. _this.listenerOptions = {
  415. capture: false,
  416. passive: false
  417. };
  418. return _this;
  419. }
  420. var _proto = ScrollLock.prototype;
  421. _proto.componentDidMount = function componentDidMount() {
  422. var _this2 = this;
  423. if (!canUseDOM) return;
  424. var _this$props = this.props,
  425. accountForScrollbars = _this$props.accountForScrollbars,
  426. touchScrollTarget = _this$props.touchScrollTarget;
  427. var target = document.body;
  428. var targetStyle = target && target.style;
  429. if (accountForScrollbars) {
  430. // store any styles already applied to the body
  431. STYLE_KEYS.forEach(function (key) {
  432. var val = targetStyle && targetStyle[key];
  433. _this2.originalStyles[key] = val;
  434. });
  435. } // apply the lock styles and padding if this is the first scroll lock
  436. if (accountForScrollbars && activeScrollLocks < 1) {
  437. var currentPadding = parseInt(this.originalStyles.paddingRight, 10) || 0;
  438. var clientWidth = document.body ? document.body.clientWidth : 0;
  439. var adjustedPadding = window.innerWidth - clientWidth + currentPadding || 0;
  440. Object.keys(LOCK_STYLES).forEach(function (key) {
  441. var val = LOCK_STYLES[key];
  442. if (targetStyle) {
  443. targetStyle[key] = val;
  444. }
  445. });
  446. if (targetStyle) {
  447. targetStyle.paddingRight = adjustedPadding + "px";
  448. }
  449. } // account for touch devices
  450. if (target && isTouchDevice()) {
  451. // Mobile Safari ignores { overflow: hidden } declaration on the body.
  452. target.addEventListener('touchmove', preventTouchMove, this.listenerOptions); // Allow scroll on provided target
  453. if (touchScrollTarget) {
  454. touchScrollTarget.addEventListener('touchstart', preventInertiaScroll, this.listenerOptions);
  455. touchScrollTarget.addEventListener('touchmove', allowTouchMove, this.listenerOptions);
  456. }
  457. } // increment active scroll locks
  458. activeScrollLocks += 1;
  459. };
  460. _proto.componentWillUnmount = function componentWillUnmount() {
  461. var _this3 = this;
  462. if (!canUseDOM) return;
  463. var _this$props2 = this.props,
  464. accountForScrollbars = _this$props2.accountForScrollbars,
  465. touchScrollTarget = _this$props2.touchScrollTarget;
  466. var target = document.body;
  467. var targetStyle = target && target.style; // safely decrement active scroll locks
  468. activeScrollLocks = Math.max(activeScrollLocks - 1, 0); // reapply original body styles, if any
  469. if (accountForScrollbars && activeScrollLocks < 1) {
  470. STYLE_KEYS.forEach(function (key) {
  471. var val = _this3.originalStyles[key];
  472. if (targetStyle) {
  473. targetStyle[key] = val;
  474. }
  475. });
  476. } // remove touch listeners
  477. if (target && isTouchDevice()) {
  478. target.removeEventListener('touchmove', preventTouchMove, this.listenerOptions);
  479. if (touchScrollTarget) {
  480. touchScrollTarget.removeEventListener('touchstart', preventInertiaScroll, this.listenerOptions);
  481. touchScrollTarget.removeEventListener('touchmove', allowTouchMove, this.listenerOptions);
  482. }
  483. }
  484. };
  485. _proto.render = function render() {
  486. return null;
  487. };
  488. return ScrollLock;
  489. }(Component);
  490. ScrollLock.defaultProps = {
  491. accountForScrollbars: true
  492. };
  493. function _inheritsLoose$2(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  494. var _ref$1 = process.env.NODE_ENV === "production" ? {
  495. name: "1dsbpcp",
  496. styles: "position:fixed;left:0;bottom:0;right:0;top:0;"
  497. } : {
  498. name: "1dsbpcp",
  499. styles: "position:fixed;left:0;bottom:0;right:0;top:0;",
  500. map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIlNjcm9sbEJsb2NrLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQTZEVSIsImZpbGUiOiJTY3JvbGxCbG9jay5qcyIsInNvdXJjZXNDb250ZW50IjpbIi8vIEBmbG93XG4vKiogQGpzeCBqc3ggKi9cbmltcG9ydCB7IFB1cmVDb21wb25lbnQsIHR5cGUgRWxlbWVudCB9IGZyb20gJ3JlYWN0JztcbmltcG9ydCB7IGpzeCB9IGZyb20gJ0BlbW90aW9uL2NvcmUnO1xuaW1wb3J0IE5vZGVSZXNvbHZlciBmcm9tICcuL05vZGVSZXNvbHZlcic7XG5pbXBvcnQgU2Nyb2xsTG9jayBmcm9tICcuL1Njcm9sbExvY2svaW5kZXgnO1xuXG50eXBlIFByb3BzID0ge1xuICBjaGlsZHJlbjogRWxlbWVudDwqPixcbiAgaXNFbmFibGVkOiBib29sZWFuLFxufTtcbnR5cGUgU3RhdGUgPSB7XG4gIHRvdWNoU2Nyb2xsVGFyZ2V0OiBIVE1MRWxlbWVudCB8IG51bGwsXG59O1xuXG4vLyBOT1RFOlxuLy8gV2Ugc2hvdWxkbid0IG5lZWQgdGhpcyBhZnRlciB1cGRhdGluZyB0byBSZWFjdCB2MTYuMy4wLCB3aGljaCBpbnRyb2R1Y2VzOlxuLy8gLSBjcmVhdGVSZWYoKSBodHRwczovL3JlYWN0anMub3JnL2RvY3MvcmVhY3QtYXBpLmh0bWwjcmVhY3RjcmVhdGVyZWZcbi8vIC0gZm9yd2FyZFJlZigpIGh0dHBzOi8vcmVhY3Rqcy5vcmcvZG9jcy9yZWFjdC1hcGkuaHRtbCNyZWFjdGZvcndhcmRyZWZcblxuZXhwb3J0IGRlZmF1bHQgY2xhc3MgU2Nyb2xsQmxvY2sgZXh0ZW5kcyBQdXJlQ29tcG9uZW50PFByb3BzLCBTdGF0ZT4ge1xuICBzdGF0ZSA9IHsgdG91Y2hTY3JvbGxUYXJnZXQ6IG51bGwgfTtcblxuICAvLyBtdXN0IGJlIGluIHN0YXRlIHRvIHRyaWdnZXIgYSByZS1yZW5kZXIsIG9ubHkgcnVucyBvbmNlIHBlciBpbnN0YW5jZVxuICBnZXRTY3JvbGxUYXJnZXQgPSAocmVmOiBIVE1MRWxlbWVudCkgPT4ge1xuICAgIGlmIChyZWYgPT09IHRoaXMuc3RhdGUudG91Y2hTY3JvbGxUYXJnZXQpIHJldHVybjtcbiAgICB0aGlzLnNldFN0YXRlKHsgdG91Y2hTY3JvbGxUYXJnZXQ6IHJlZiB9KTtcbiAgfTtcblxuICAvLyB0aGlzIHdpbGwgY2xvc2UgdGhlIG1lbnUgd2hlbiBhIHVzZXIgY2xpY2tzIG91dHNpZGVcbiAgYmx1clNlbGVjdElucHV0ID0gKCkgPT4ge1xuICAgIGlmIChkb2N1bWVudC5hY3RpdmVFbGVtZW50KSB7XG4gICAgICBkb2N1bWVudC5hY3RpdmVFbGVtZW50LmJsdXIoKTtcbiAgICB9XG4gIH07XG5cbiAgcmVuZGVyKCkge1xuICAgIGNvbnN0IHsgY2hpbGRyZW4sIGlzRW5hYmxlZCB9ID0gdGhpcy5wcm9wcztcbiAgICBjb25zdCB7IHRvdWNoU2Nyb2xsVGFyZ2V0IH0gPSB0aGlzLnN0YXRlO1xuXG4gICAgLy8gYmFpbCBlYXJseSBpZiBub3QgZW5hYmxlZFxuICAgIGlmICghaXNFbmFibGVkKSByZXR1cm4gY2hpbGRyZW47XG5cbiAgICAvKlxuICAgICAqIERpdlxuICAgICAqIC0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLVxuICAgICAqIGJsb2NrcyBzY3JvbGxpbmcgb24gbm9uLWJvZHkgZWxlbWVudHMgYmVoaW5kIHRoZSBtZW51XG5cbiAgICAgKiBOb2RlUmVzb2x2ZXJcbiAgICAgKiAtLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS1cbiAgICAgKiB3ZSBuZWVkIGEgcmVmZXJlbmNlIHRvIHRoZSBzY3JvbGxhYmxlIGVsZW1lbnQgdG8gXCJ1bmxvY2tcIiBzY3JvbGwgb25cbiAgICAgKiBtb2JpbGUgZGV2aWNlc1xuXG4gICAgICogU2Nyb2xsTG9ja1xuICAgICAqIC0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLVxuICAgICAqIGFjdHVhbGx5IGRvZXMgdGhlIHNjcm9sbCBsb2NraW5nXG4gICAgICovXG4gICAgcmV0dXJuIChcbiAgICAgIDxkaXY+XG4gICAgICAgIDxkaXZcbiAgICAgICAgICBvbkNsaWNrPXt0aGlzLmJsdXJTZWxlY3RJbnB1dH1cbiAgICAgICAgICBjc3M9e3sgcG9zaXRpb246ICdmaXhlZCcsIGxlZnQ6IDAsIGJvdHRvbTogMCwgcmlnaHQ6IDAsIHRvcDogMCB9fVxuICAgICAgICAvPlxuICAgICAgICA8Tm9kZVJlc29sdmVyIGlubmVyUmVmPXt0aGlzLmdldFNjcm9sbFRhcmdldH0+e2NoaWxkcmVufTwvTm9kZVJlc29sdmVyPlxuICAgICAgICB7dG91Y2hTY3JvbGxUYXJnZXQgPyAoXG4gICAgICAgICAgPFNjcm9sbExvY2sgdG91Y2hTY3JvbGxUYXJnZXQ9e3RvdWNoU2Nyb2xsVGFyZ2V0fSAvPlxuICAgICAgICApIDogbnVsbH1cbiAgICAgIDwvZGl2PlxuICAgICk7XG4gIH1cbn1cbiJdfQ== */"
  501. };
  502. // NOTE:
  503. // We shouldn't need this after updating to React v16.3.0, which introduces:
  504. // - createRef() https://reactjs.org/docs/react-api.html#reactcreateref
  505. // - forwardRef() https://reactjs.org/docs/react-api.html#reactforwardref
  506. var ScrollBlock =
  507. /*#__PURE__*/
  508. function (_PureComponent) {
  509. _inheritsLoose$2(ScrollBlock, _PureComponent);
  510. function ScrollBlock() {
  511. var _this;
  512. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  513. args[_key] = arguments[_key];
  514. }
  515. _this = _PureComponent.call.apply(_PureComponent, [this].concat(args)) || this;
  516. _this.state = {
  517. touchScrollTarget: null
  518. };
  519. _this.getScrollTarget = function (ref) {
  520. if (ref === _this.state.touchScrollTarget) return;
  521. _this.setState({
  522. touchScrollTarget: ref
  523. });
  524. };
  525. _this.blurSelectInput = function () {
  526. if (document.activeElement) {
  527. document.activeElement.blur();
  528. }
  529. };
  530. return _this;
  531. }
  532. var _proto = ScrollBlock.prototype;
  533. _proto.render = function render() {
  534. var _this$props = this.props,
  535. children = _this$props.children,
  536. isEnabled = _this$props.isEnabled;
  537. var touchScrollTarget = this.state.touchScrollTarget; // bail early if not enabled
  538. if (!isEnabled) return children;
  539. /*
  540. * Div
  541. * ------------------------------
  542. * blocks scrolling on non-body elements behind the menu
  543. * NodeResolver
  544. * ------------------------------
  545. * we need a reference to the scrollable element to "unlock" scroll on
  546. * mobile devices
  547. * ScrollLock
  548. * ------------------------------
  549. * actually does the scroll locking
  550. */
  551. return jsx("div", null, jsx("div", {
  552. onClick: this.blurSelectInput,
  553. css: _ref$1
  554. }), jsx(NodeResolver, {
  555. innerRef: this.getScrollTarget
  556. }, children), touchScrollTarget ? jsx(ScrollLock, {
  557. touchScrollTarget: touchScrollTarget
  558. }) : null);
  559. };
  560. return ScrollBlock;
  561. }(PureComponent);
  562. function _objectWithoutPropertiesLoose$1(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
  563. function _inheritsLoose$3(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  564. var ScrollCaptor =
  565. /*#__PURE__*/
  566. function (_Component) {
  567. _inheritsLoose$3(ScrollCaptor, _Component);
  568. function ScrollCaptor() {
  569. var _this;
  570. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  571. args[_key] = arguments[_key];
  572. }
  573. _this = _Component.call.apply(_Component, [this].concat(args)) || this;
  574. _this.isBottom = false;
  575. _this.isTop = false;
  576. _this.scrollTarget = void 0;
  577. _this.touchStart = void 0;
  578. _this.cancelScroll = function (event) {
  579. event.preventDefault();
  580. event.stopPropagation();
  581. };
  582. _this.handleEventDelta = function (event, delta) {
  583. var _this$props = _this.props,
  584. onBottomArrive = _this$props.onBottomArrive,
  585. onBottomLeave = _this$props.onBottomLeave,
  586. onTopArrive = _this$props.onTopArrive,
  587. onTopLeave = _this$props.onTopLeave;
  588. var _this$scrollTarget = _this.scrollTarget,
  589. scrollTop = _this$scrollTarget.scrollTop,
  590. scrollHeight = _this$scrollTarget.scrollHeight,
  591. clientHeight = _this$scrollTarget.clientHeight;
  592. var target = _this.scrollTarget;
  593. var isDeltaPositive = delta > 0;
  594. var availableScroll = scrollHeight - clientHeight - scrollTop;
  595. var shouldCancelScroll = false; // reset bottom/top flags
  596. if (availableScroll > delta && _this.isBottom) {
  597. if (onBottomLeave) onBottomLeave(event);
  598. _this.isBottom = false;
  599. }
  600. if (isDeltaPositive && _this.isTop) {
  601. if (onTopLeave) onTopLeave(event);
  602. _this.isTop = false;
  603. } // bottom limit
  604. if (isDeltaPositive && delta > availableScroll) {
  605. if (onBottomArrive && !_this.isBottom) {
  606. onBottomArrive(event);
  607. }
  608. target.scrollTop = scrollHeight;
  609. shouldCancelScroll = true;
  610. _this.isBottom = true; // top limit
  611. } else if (!isDeltaPositive && -delta > scrollTop) {
  612. if (onTopArrive && !_this.isTop) {
  613. onTopArrive(event);
  614. }
  615. target.scrollTop = 0;
  616. shouldCancelScroll = true;
  617. _this.isTop = true;
  618. } // cancel scroll
  619. if (shouldCancelScroll) {
  620. _this.cancelScroll(event);
  621. }
  622. };
  623. _this.onWheel = function (event) {
  624. _this.handleEventDelta(event, event.deltaY);
  625. };
  626. _this.onTouchStart = function (event) {
  627. // set touch start so we can calculate touchmove delta
  628. _this.touchStart = event.changedTouches[0].clientY;
  629. };
  630. _this.onTouchMove = function (event) {
  631. var deltaY = _this.touchStart - event.changedTouches[0].clientY;
  632. _this.handleEventDelta(event, deltaY);
  633. };
  634. _this.getScrollTarget = function (ref) {
  635. _this.scrollTarget = ref;
  636. };
  637. return _this;
  638. }
  639. var _proto = ScrollCaptor.prototype;
  640. _proto.componentDidMount = function componentDidMount() {
  641. this.startListening(this.scrollTarget);
  642. };
  643. _proto.componentWillUnmount = function componentWillUnmount() {
  644. this.stopListening(this.scrollTarget);
  645. };
  646. _proto.startListening = function startListening(el) {
  647. // bail early if no element is available to attach to
  648. if (!el) return; // all the if statements are to appease Flow 😢
  649. if (typeof el.addEventListener === 'function') {
  650. el.addEventListener('wheel', this.onWheel, false);
  651. }
  652. if (typeof el.addEventListener === 'function') {
  653. el.addEventListener('touchstart', this.onTouchStart, false);
  654. }
  655. if (typeof el.addEventListener === 'function') {
  656. el.addEventListener('touchmove', this.onTouchMove, false);
  657. }
  658. };
  659. _proto.stopListening = function stopListening(el) {
  660. // all the if statements are to appease Flow 😢
  661. if (typeof el.removeEventListener === 'function') {
  662. el.removeEventListener('wheel', this.onWheel, false);
  663. }
  664. if (typeof el.removeEventListener === 'function') {
  665. el.removeEventListener('touchstart', this.onTouchStart, false);
  666. }
  667. if (typeof el.removeEventListener === 'function') {
  668. el.removeEventListener('touchmove', this.onTouchMove, false);
  669. }
  670. };
  671. _proto.render = function render() {
  672. return React.createElement(NodeResolver, {
  673. innerRef: this.getScrollTarget
  674. }, this.props.children);
  675. };
  676. return ScrollCaptor;
  677. }(Component);
  678. function ScrollCaptorSwitch(_ref) {
  679. var _ref$isEnabled = _ref.isEnabled,
  680. isEnabled = _ref$isEnabled === void 0 ? true : _ref$isEnabled,
  681. props = _objectWithoutPropertiesLoose$1(_ref, ["isEnabled"]);
  682. return isEnabled ? React.createElement(ScrollCaptor, props) : props.children;
  683. }
  684. var instructionsAriaMessage = function instructionsAriaMessage(event, context) {
  685. if (context === void 0) {
  686. context = {};
  687. }
  688. var _context = context,
  689. isSearchable = _context.isSearchable,
  690. isMulti = _context.isMulti,
  691. label = _context.label,
  692. isDisabled = _context.isDisabled;
  693. switch (event) {
  694. case 'menu':
  695. return "Use Up and Down to choose options" + (isDisabled ? '' : ', press Enter to select the currently focused option') + ", press Escape to exit the menu, press Tab to select the option and exit the menu.";
  696. case 'input':
  697. return (label ? label : 'Select') + " is focused " + (isSearchable ? ',type to refine list' : '') + ", press Down to open the menu, " + (isMulti ? ' press left to focus selected values' : '');
  698. case 'value':
  699. return 'Use left and right to toggle between focused values, press Backspace to remove the currently focused value';
  700. }
  701. };
  702. var valueEventAriaMessage = function valueEventAriaMessage(event, context) {
  703. var value = context.value,
  704. isDisabled = context.isDisabled;
  705. if (!value) return;
  706. switch (event) {
  707. case 'deselect-option':
  708. case 'pop-value':
  709. case 'remove-value':
  710. return "option " + value + ", deselected.";
  711. case 'select-option':
  712. return isDisabled ? "option " + value + " is disabled. Select another option." : "option " + value + ", selected.";
  713. }
  714. };
  715. var valueFocusAriaMessage = function valueFocusAriaMessage(_ref) {
  716. var focusedValue = _ref.focusedValue,
  717. getOptionLabel = _ref.getOptionLabel,
  718. selectValue = _ref.selectValue;
  719. return "value " + getOptionLabel(focusedValue) + " focused, " + (selectValue.indexOf(focusedValue) + 1) + " of " + selectValue.length + ".";
  720. };
  721. var optionFocusAriaMessage = function optionFocusAriaMessage(_ref2) {
  722. var focusedOption = _ref2.focusedOption,
  723. getOptionLabel = _ref2.getOptionLabel,
  724. options = _ref2.options;
  725. return "option " + getOptionLabel(focusedOption) + " focused" + (focusedOption.isDisabled ? ' disabled' : '') + ", " + (options.indexOf(focusedOption) + 1) + " of " + options.length + ".";
  726. };
  727. var resultsAriaMessage = function resultsAriaMessage(_ref3) {
  728. var inputValue = _ref3.inputValue,
  729. screenReaderMessage = _ref3.screenReaderMessage;
  730. return "" + screenReaderMessage + (inputValue ? ' for search term ' + inputValue : '') + ".";
  731. };
  732. var formatGroupLabel = function formatGroupLabel(group) {
  733. return group.label;
  734. };
  735. var getOptionLabel = function getOptionLabel(option) {
  736. return option.label;
  737. };
  738. var getOptionValue = function getOptionValue(option) {
  739. return option.value;
  740. };
  741. var isOptionDisabled = function isOptionDisabled(option) {
  742. return !!option.isDisabled;
  743. };
  744. function _extends$3() { _extends$3 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$3.apply(this, arguments); }
  745. var defaultStyles = {
  746. clearIndicator: clearIndicatorCSS,
  747. container: containerCSS,
  748. control: css,
  749. dropdownIndicator: dropdownIndicatorCSS,
  750. group: groupCSS,
  751. groupHeading: groupHeadingCSS,
  752. indicatorsContainer: indicatorsContainerCSS,
  753. indicatorSeparator: indicatorSeparatorCSS,
  754. input: inputCSS,
  755. loadingIndicator: loadingIndicatorCSS,
  756. loadingMessage: loadingMessageCSS,
  757. menu: menuCSS,
  758. menuList: menuListCSS,
  759. menuPortal: menuPortalCSS,
  760. multiValue: multiValueCSS,
  761. multiValueLabel: multiValueLabelCSS,
  762. multiValueRemove: multiValueRemoveCSS,
  763. noOptionsMessage: noOptionsMessageCSS,
  764. option: optionCSS,
  765. placeholder: placeholderCSS,
  766. singleValue: css$1,
  767. valueContainer: valueContainerCSS
  768. }; // Merge Utility
  769. // Allows consumers to extend a base Select with additional styles
  770. function mergeStyles(source, target) {
  771. if (target === void 0) {
  772. target = {};
  773. }
  774. // initialize with source styles
  775. var styles = _extends$3({}, source); // massage in target styles
  776. Object.keys(target).forEach(function (key) {
  777. if (source[key]) {
  778. styles[key] = function (rsCss, props) {
  779. return target[key](source[key](rsCss, props), props);
  780. };
  781. } else {
  782. styles[key] = target[key];
  783. }
  784. });
  785. return styles;
  786. }
  787. var colors = {
  788. primary: '#2684FF',
  789. primary75: '#4C9AFF',
  790. primary50: '#B2D4FF',
  791. primary25: '#DEEBFF',
  792. danger: '#DE350B',
  793. dangerLight: '#FFBDAD',
  794. neutral0: 'hsl(0, 0%, 100%)',
  795. neutral5: 'hsl(0, 0%, 95%)',
  796. neutral10: 'hsl(0, 0%, 90%)',
  797. neutral20: 'hsl(0, 0%, 80%)',
  798. neutral30: 'hsl(0, 0%, 70%)',
  799. neutral40: 'hsl(0, 0%, 60%)',
  800. neutral50: 'hsl(0, 0%, 50%)',
  801. neutral60: 'hsl(0, 0%, 40%)',
  802. neutral70: 'hsl(0, 0%, 30%)',
  803. neutral80: 'hsl(0, 0%, 20%)',
  804. neutral90: 'hsl(0, 0%, 10%)'
  805. };
  806. var borderRadius = 4; // Used to calculate consistent margin/padding on elements
  807. var baseUnit = 4; // The minimum height of the control
  808. var controlHeight = 38; // The amount of space between the control and menu */
  809. var menuGutter = baseUnit * 2;
  810. var spacing = {
  811. baseUnit: baseUnit,
  812. controlHeight: controlHeight,
  813. menuGutter: menuGutter
  814. };
  815. var defaultTheme = {
  816. borderRadius: borderRadius,
  817. colors: colors,
  818. spacing: spacing
  819. };
  820. function _objectWithoutPropertiesLoose$2(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
  821. function _extends$4() { _extends$4 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$4.apply(this, arguments); }
  822. function _inheritsLoose$4(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  823. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  824. var defaultProps = {
  825. backspaceRemovesValue: true,
  826. blurInputOnSelect: isTouchCapable(),
  827. captureMenuScroll: !isTouchCapable(),
  828. closeMenuOnSelect: true,
  829. closeMenuOnScroll: false,
  830. components: {},
  831. controlShouldRenderValue: true,
  832. escapeClearsValue: false,
  833. filterOption: createFilter(),
  834. formatGroupLabel: formatGroupLabel,
  835. getOptionLabel: getOptionLabel,
  836. getOptionValue: getOptionValue,
  837. isDisabled: false,
  838. isLoading: false,
  839. isMulti: false,
  840. isRtl: false,
  841. isSearchable: true,
  842. isOptionDisabled: isOptionDisabled,
  843. loadingMessage: function loadingMessage() {
  844. return 'Loading...';
  845. },
  846. maxMenuHeight: 300,
  847. minMenuHeight: 140,
  848. menuIsOpen: false,
  849. menuPlacement: 'bottom',
  850. menuPosition: 'absolute',
  851. menuShouldBlockScroll: false,
  852. menuShouldScrollIntoView: !isMobileDevice(),
  853. noOptionsMessage: function noOptionsMessage() {
  854. return 'No options';
  855. },
  856. openMenuOnFocus: false,
  857. openMenuOnClick: true,
  858. options: [],
  859. pageSize: 5,
  860. placeholder: 'Select...',
  861. screenReaderStatus: function screenReaderStatus(_ref) {
  862. var count = _ref.count;
  863. return count + " result" + (count !== 1 ? 's' : '') + " available";
  864. },
  865. styles: {},
  866. tabIndex: '0',
  867. tabSelectsValue: true
  868. };
  869. var instanceId = 1;
  870. var Select =
  871. /*#__PURE__*/
  872. function (_Component) {
  873. _inheritsLoose$4(Select, _Component);
  874. // Misc. Instance Properties
  875. // ------------------------------
  876. // TODO
  877. // Refs
  878. // ------------------------------
  879. // Lifecycle
  880. // ------------------------------
  881. function Select(_props) {
  882. var _this;
  883. _this = _Component.call(this, _props) || this;
  884. _this.state = {
  885. ariaLiveSelection: '',
  886. ariaLiveContext: '',
  887. focusedOption: null,
  888. focusedValue: null,
  889. inputIsHidden: false,
  890. isFocused: false,
  891. menuOptions: {
  892. render: [],
  893. focusable: []
  894. },
  895. selectValue: []
  896. };
  897. _this.blockOptionHover = false;
  898. _this.isComposing = false;
  899. _this.clearFocusValueOnUpdate = false;
  900. _this.commonProps = void 0;
  901. _this.components = void 0;
  902. _this.hasGroups = false;
  903. _this.initialTouchX = 0;
  904. _this.initialTouchY = 0;
  905. _this.inputIsHiddenAfterUpdate = void 0;
  906. _this.instancePrefix = '';
  907. _this.openAfterFocus = false;
  908. _this.scrollToFocusedOptionOnUpdate = false;
  909. _this.userIsDragging = void 0;
  910. _this.controlRef = null;
  911. _this.getControlRef = function (ref) {
  912. _this.controlRef = ref;
  913. };
  914. _this.focusedOptionRef = null;
  915. _this.getFocusedOptionRef = function (ref) {
  916. _this.focusedOptionRef = ref;
  917. };
  918. _this.menuListRef = null;
  919. _this.getMenuListRef = function (ref) {
  920. _this.menuListRef = ref;
  921. };
  922. _this.inputRef = null;
  923. _this.getInputRef = function (ref) {
  924. _this.inputRef = ref;
  925. };
  926. _this.cacheComponents = function (components) {
  927. _this.components = defaultComponents({
  928. components: components
  929. });
  930. };
  931. _this.focus = _this.focusInput;
  932. _this.blur = _this.blurInput;
  933. _this.onChange = function (newValue, actionMeta) {
  934. var _this$props = _this.props,
  935. onChange = _this$props.onChange,
  936. name = _this$props.name;
  937. onChange(newValue, _extends$4({}, actionMeta, {
  938. name: name
  939. }));
  940. };
  941. _this.setValue = function (newValue, action, option) {
  942. if (action === void 0) {
  943. action = 'set-value';
  944. }
  945. var _this$props2 = _this.props,
  946. closeMenuOnSelect = _this$props2.closeMenuOnSelect,
  947. isMulti = _this$props2.isMulti;
  948. _this.onInputChange('', {
  949. action: 'set-value'
  950. });
  951. if (closeMenuOnSelect) {
  952. _this.inputIsHiddenAfterUpdate = !isMulti;
  953. _this.onMenuClose();
  954. } // when the select value should change, we should reset focusedValue
  955. _this.clearFocusValueOnUpdate = true;
  956. _this.onChange(newValue, {
  957. action: action,
  958. option: option
  959. });
  960. };
  961. _this.selectOption = function (newValue) {
  962. var _this$props3 = _this.props,
  963. blurInputOnSelect = _this$props3.blurInputOnSelect,
  964. isMulti = _this$props3.isMulti;
  965. var selectValue = _this.state.selectValue;
  966. if (isMulti) {
  967. if (_this.isOptionSelected(newValue, selectValue)) {
  968. var candidate = _this.getOptionValue(newValue);
  969. _this.setValue(selectValue.filter(function (i) {
  970. return _this.getOptionValue(i) !== candidate;
  971. }), 'deselect-option', newValue);
  972. _this.announceAriaLiveSelection({
  973. event: 'deselect-option',
  974. context: {
  975. value: _this.getOptionLabel(newValue)
  976. }
  977. });
  978. } else {
  979. if (!_this.isOptionDisabled(newValue, selectValue)) {
  980. _this.setValue([].concat(selectValue, [newValue]), 'select-option', newValue);
  981. _this.announceAriaLiveSelection({
  982. event: 'select-option',
  983. context: {
  984. value: _this.getOptionLabel(newValue)
  985. }
  986. });
  987. } else {
  988. // announce that option is disabled
  989. _this.announceAriaLiveSelection({
  990. event: 'select-option',
  991. context: {
  992. value: _this.getOptionLabel(newValue),
  993. isDisabled: true
  994. }
  995. });
  996. }
  997. }
  998. } else {
  999. if (!_this.isOptionDisabled(newValue, selectValue)) {
  1000. _this.setValue(newValue, 'select-option');
  1001. _this.announceAriaLiveSelection({
  1002. event: 'select-option',
  1003. context: {
  1004. value: _this.getOptionLabel(newValue)
  1005. }
  1006. });
  1007. } else {
  1008. // announce that option is disabled
  1009. _this.announceAriaLiveSelection({
  1010. event: 'select-option',
  1011. context: {
  1012. value: _this.getOptionLabel(newValue),
  1013. isDisabled: true
  1014. }
  1015. });
  1016. }
  1017. }
  1018. if (blurInputOnSelect) {
  1019. _this.blurInput();
  1020. }
  1021. };
  1022. _this.removeValue = function (removedValue) {
  1023. var selectValue = _this.state.selectValue;
  1024. var candidate = _this.getOptionValue(removedValue);
  1025. var newValue = selectValue.filter(function (i) {
  1026. return _this.getOptionValue(i) !== candidate;
  1027. });
  1028. _this.onChange(newValue.length ? newValue : null, {
  1029. action: 'remove-value',
  1030. removedValue: removedValue
  1031. });
  1032. _this.announceAriaLiveSelection({
  1033. event: 'remove-value',
  1034. context: {
  1035. value: removedValue ? _this.getOptionLabel(removedValue) : ''
  1036. }
  1037. });
  1038. _this.focusInput();
  1039. };
  1040. _this.clearValue = function () {
  1041. var isMulti = _this.props.isMulti;
  1042. _this.onChange(isMulti ? [] : null, {
  1043. action: 'clear'
  1044. });
  1045. };
  1046. _this.popValue = function () {
  1047. var selectValue = _this.state.selectValue;
  1048. var lastSelectedValue = selectValue[selectValue.length - 1];
  1049. var newValue = selectValue.slice(0, selectValue.length - 1);
  1050. _this.announceAriaLiveSelection({
  1051. event: 'pop-value',
  1052. context: {
  1053. value: lastSelectedValue ? _this.getOptionLabel(lastSelectedValue) : ''
  1054. }
  1055. });
  1056. _this.onChange(newValue.length ? newValue : null, {
  1057. action: 'pop-value',
  1058. removedValue: lastSelectedValue
  1059. });
  1060. };
  1061. _this.getOptionLabel = function (data) {
  1062. return _this.props.getOptionLabel(data);
  1063. };
  1064. _this.getOptionValue = function (data) {
  1065. return _this.props.getOptionValue(data);
  1066. };
  1067. _this.getStyles = function (key, props) {
  1068. var base = defaultStyles[key](props);
  1069. base.boxSizing = 'border-box';
  1070. var custom = _this.props.styles[key];
  1071. return custom ? custom(base, props) : base;
  1072. };
  1073. _this.getElementId = function (element) {
  1074. return _this.instancePrefix + "-" + element;
  1075. };
  1076. _this.getActiveDescendentId = function () {
  1077. var menuIsOpen = _this.props.menuIsOpen;
  1078. var _this$state = _this.state,
  1079. menuOptions = _this$state.menuOptions,
  1080. focusedOption = _this$state.focusedOption;
  1081. if (!focusedOption || !menuIsOpen) return undefined;
  1082. var index = menuOptions.focusable.indexOf(focusedOption);
  1083. var option = menuOptions.render[index];
  1084. return option && option.key;
  1085. };
  1086. _this.announceAriaLiveSelection = function (_ref2) {
  1087. var event = _ref2.event,
  1088. context = _ref2.context;
  1089. _this.setState({
  1090. ariaLiveSelection: valueEventAriaMessage(event, context)
  1091. });
  1092. };
  1093. _this.announceAriaLiveContext = function (_ref3) {
  1094. var event = _ref3.event,
  1095. context = _ref3.context;
  1096. _this.setState({
  1097. ariaLiveContext: instructionsAriaMessage(event, _extends$4({}, context, {
  1098. label: _this.props['aria-label']
  1099. }))
  1100. });
  1101. };
  1102. _this.onMenuMouseDown = function (event) {
  1103. if (event.button !== 0) {
  1104. return;
  1105. }
  1106. event.stopPropagation();
  1107. event.preventDefault();
  1108. _this.focusInput();
  1109. };
  1110. _this.onMenuMouseMove = function (event) {
  1111. _this.blockOptionHover = false;
  1112. };
  1113. _this.onControlMouseDown = function (event) {
  1114. var openMenuOnClick = _this.props.openMenuOnClick;
  1115. if (!_this.state.isFocused) {
  1116. if (openMenuOnClick) {
  1117. _this.openAfterFocus = true;
  1118. }
  1119. _this.focusInput();
  1120. } else if (!_this.props.menuIsOpen) {
  1121. if (openMenuOnClick) {
  1122. _this.openMenu('first');
  1123. }
  1124. } else {
  1125. if ( // $FlowFixMe
  1126. event.target.tagName !== 'INPUT' && event.target.tagName !== 'TEXTAREA') {
  1127. _this.onMenuClose();
  1128. }
  1129. }
  1130. if ( // $FlowFixMe
  1131. event.target.tagName !== 'INPUT' && event.target.tagName !== 'TEXTAREA') {
  1132. event.preventDefault();
  1133. }
  1134. };
  1135. _this.onDropdownIndicatorMouseDown = function (event) {
  1136. // ignore mouse events that weren't triggered by the primary button
  1137. if (event && event.type === 'mousedown' && event.button !== 0) {
  1138. return;
  1139. }
  1140. if (_this.props.isDisabled) return;
  1141. var _this$props4 = _this.props,
  1142. isMulti = _this$props4.isMulti,
  1143. menuIsOpen = _this$props4.menuIsOpen;
  1144. _this.focusInput();
  1145. if (menuIsOpen) {
  1146. _this.inputIsHiddenAfterUpdate = !isMulti;
  1147. _this.onMenuClose();
  1148. } else {
  1149. _this.openMenu('first');
  1150. }
  1151. event.preventDefault();
  1152. event.stopPropagation();
  1153. };
  1154. _this.onClearIndicatorMouseDown = function (event) {
  1155. // ignore mouse events that weren't triggered by the primary button
  1156. if (event && event.type === 'mousedown' && event.button !== 0) {
  1157. return;
  1158. }
  1159. _this.clearValue();
  1160. event.stopPropagation();
  1161. _this.openAfterFocus = false;
  1162. if (event.type === 'touchend') {
  1163. _this.focusInput();
  1164. } else {
  1165. setTimeout(function () {
  1166. return _this.focusInput();
  1167. });
  1168. }
  1169. };
  1170. _this.onScroll = function (event) {
  1171. if (typeof _this.props.closeMenuOnScroll === 'boolean') {
  1172. if (event.target instanceof HTMLElement && isDocumentElement(event.target)) {
  1173. _this.props.onMenuClose();
  1174. }
  1175. } else if (typeof _this.props.closeMenuOnScroll === 'function') {
  1176. if (_this.props.closeMenuOnScroll(event)) {
  1177. _this.props.onMenuClose();
  1178. }
  1179. }
  1180. };
  1181. _this.onCompositionStart = function () {
  1182. _this.isComposing = true;
  1183. };
  1184. _this.onCompositionEnd = function () {
  1185. _this.isComposing = false;
  1186. };
  1187. _this.onTouchStart = function (_ref4) {
  1188. var touches = _ref4.touches;
  1189. var touch = touches.item(0);
  1190. if (!touch) {
  1191. return;
  1192. }
  1193. _this.initialTouchX = touch.clientX;
  1194. _this.initialTouchY = touch.clientY;
  1195. _this.userIsDragging = false;
  1196. };
  1197. _this.onTouchMove = function (_ref5) {
  1198. var touches = _ref5.touches;
  1199. var touch = touches.item(0);
  1200. if (!touch) {
  1201. return;
  1202. }
  1203. var deltaX = Math.abs(touch.clientX - _this.initialTouchX);
  1204. var deltaY = Math.abs(touch.clientY - _this.initialTouchY);
  1205. var moveThreshold = 5;
  1206. _this.userIsDragging = deltaX > moveThreshold || deltaY > moveThreshold;
  1207. };
  1208. _this.onTouchEnd = function (event) {
  1209. if (_this.userIsDragging) return; // close the menu if the user taps outside
  1210. // we're checking on event.target here instead of event.currentTarget, because we want to assert information
  1211. // on events on child elements, not the document (which we've attached this handler to).
  1212. if (_this.controlRef && !_this.controlRef.contains(event.target) && _this.menuListRef && !_this.menuListRef.contains(event.target)) {
  1213. _this.blurInput();
  1214. } // reset move vars
  1215. _this.initialTouchX = 0;
  1216. _this.initialTouchY = 0;
  1217. };
  1218. _this.onControlTouchEnd = function (event) {
  1219. if (_this.userIsDragging) return;
  1220. _this.onControlMouseDown(event);
  1221. };
  1222. _this.onClearIndicatorTouchEnd = function (event) {
  1223. if (_this.userIsDragging) return;
  1224. _this.onClearIndicatorMouseDown(event);
  1225. };
  1226. _this.onDropdownIndicatorTouchEnd = function (event) {
  1227. if (_this.userIsDragging) return;
  1228. _this.onDropdownIndicatorMouseDown(event);
  1229. };
  1230. _this.handleInputChange = function (event) {
  1231. var inputValue = event.currentTarget.value;
  1232. _this.inputIsHiddenAfterUpdate = false;
  1233. _this.onInputChange(inputValue, {
  1234. action: 'input-change'
  1235. });
  1236. _this.onMenuOpen();
  1237. };
  1238. _this.onInputFocus = function (event) {
  1239. var _this$props5 = _this.props,
  1240. isSearchable = _this$props5.isSearchable,
  1241. isMulti = _this$props5.isMulti;
  1242. if (_this.props.onFocus) {
  1243. _this.props.onFocus(event);
  1244. }
  1245. _this.inputIsHiddenAfterUpdate = false;
  1246. _this.announceAriaLiveContext({
  1247. event: 'input',
  1248. context: {
  1249. isSearchable: isSearchable,
  1250. isMulti: isMulti
  1251. }
  1252. });
  1253. _this.setState({
  1254. isFocused: true
  1255. });
  1256. if (_this.openAfterFocus || _this.props.openMenuOnFocus) {
  1257. _this.openMenu('first');
  1258. }
  1259. _this.openAfterFocus = false;
  1260. };
  1261. _this.onInputBlur = function (event) {
  1262. if (_this.menuListRef && _this.menuListRef.contains(document.activeElement)) {
  1263. _this.inputRef.focus();
  1264. return;
  1265. }
  1266. if (_this.props.onBlur) {
  1267. _this.props.onBlur(event);
  1268. }
  1269. _this.onInputChange('', {
  1270. action: 'input-blur'
  1271. });
  1272. _this.onMenuClose();
  1273. _this.setState({
  1274. focusedValue: null,
  1275. isFocused: false
  1276. });
  1277. };
  1278. _this.onOptionHover = function (focusedOption) {
  1279. if (_this.blockOptionHover || _this.state.focusedOption === focusedOption) {
  1280. return;
  1281. }
  1282. _this.setState({
  1283. focusedOption: focusedOption
  1284. });
  1285. };
  1286. _this.shouldHideSelectedOptions = function () {
  1287. var _this$props6 = _this.props,
  1288. hideSelectedOptions = _this$props6.hideSelectedOptions,
  1289. isMulti = _this$props6.isMulti;
  1290. if (hideSelectedOptions === undefined) return isMulti;
  1291. return hideSelectedOptions;
  1292. };
  1293. _this.onKeyDown = function (event) {
  1294. var _this$props7 = _this.props,
  1295. isMulti = _this$props7.isMulti,
  1296. backspaceRemovesValue = _this$props7.backspaceRemovesValue,
  1297. escapeClearsValue = _this$props7.escapeClearsValue,
  1298. inputValue = _this$props7.inputValue,
  1299. isClearable = _this$props7.isClearable,
  1300. isDisabled = _this$props7.isDisabled,
  1301. menuIsOpen = _this$props7.menuIsOpen,
  1302. onKeyDown = _this$props7.onKeyDown,
  1303. tabSelectsValue = _this$props7.tabSelectsValue,
  1304. openMenuOnFocus = _this$props7.openMenuOnFocus;
  1305. var _this$state2 = _this.state,
  1306. focusedOption = _this$state2.focusedOption,
  1307. focusedValue = _this$state2.focusedValue,
  1308. selectValue = _this$state2.selectValue;
  1309. if (isDisabled) return;
  1310. if (typeof onKeyDown === 'function') {
  1311. onKeyDown(event);
  1312. if (event.defaultPrevented) {
  1313. return;
  1314. }
  1315. } // Block option hover events when the user has just pressed a key
  1316. _this.blockOptionHover = true;
  1317. switch (event.key) {
  1318. case 'ArrowLeft':
  1319. if (!isMulti || inputValue) return;
  1320. _this.focusValue('previous');
  1321. break;
  1322. case 'ArrowRight':
  1323. if (!isMulti || inputValue) return;
  1324. _this.focusValue('next');
  1325. break;
  1326. case 'Delete':
  1327. case 'Backspace':
  1328. if (inputValue) return;
  1329. if (focusedValue) {
  1330. _this.removeValue(focusedValue);
  1331. } else {
  1332. if (!backspaceRemovesValue) return;
  1333. if (isMulti) {
  1334. _this.popValue();
  1335. } else if (isClearable) {
  1336. _this.clearValue();
  1337. }
  1338. }
  1339. break;
  1340. case 'Tab':
  1341. if (_this.isComposing) return;
  1342. if (event.shiftKey || !menuIsOpen || !tabSelectsValue || !focusedOption || // don't capture the event if the menu opens on focus and the focused
  1343. // option is already selected; it breaks the flow of navigation
  1344. openMenuOnFocus && _this.isOptionSelected(focusedOption, selectValue)) {
  1345. return;
  1346. }
  1347. _this.selectOption(focusedOption);
  1348. break;
  1349. case 'Enter':
  1350. if (event.keyCode === 229) {
  1351. // ignore the keydown event from an Input Method Editor(IME)
  1352. // ref. https://www.w3.org/TR/uievents/#determine-keydown-keyup-keyCode
  1353. break;
  1354. }
  1355. if (menuIsOpen) {
  1356. if (!focusedOption) return;
  1357. if (_this.isComposing) return;
  1358. _this.selectOption(focusedOption);
  1359. break;
  1360. }
  1361. return;
  1362. case 'Escape':
  1363. if (menuIsOpen) {
  1364. _this.inputIsHiddenAfterUpdate = false;
  1365. _this.onInputChange('', {
  1366. action: 'menu-close'
  1367. });
  1368. _this.onMenuClose();
  1369. } else if (isClearable && escapeClearsValue) {
  1370. _this.clearValue();
  1371. }
  1372. break;
  1373. case ' ':
  1374. // space
  1375. if (inputValue) {
  1376. return;
  1377. }
  1378. if (!menuIsOpen) {
  1379. _this.openMenu('first');
  1380. break;
  1381. }
  1382. if (!focusedOption) return;
  1383. _this.selectOption(focusedOption);
  1384. break;
  1385. case 'ArrowUp':
  1386. if (menuIsOpen) {
  1387. _this.focusOption('up');
  1388. } else {
  1389. _this.openMenu('last');
  1390. }
  1391. break;
  1392. case 'ArrowDown':
  1393. if (menuIsOpen) {
  1394. _this.focusOption('down');
  1395. } else {
  1396. _this.openMenu('first');
  1397. }
  1398. break;
  1399. case 'PageUp':
  1400. if (!menuIsOpen) return;
  1401. _this.focusOption('pageup');
  1402. break;
  1403. case 'PageDown':
  1404. if (!menuIsOpen) return;
  1405. _this.focusOption('pagedown');
  1406. break;
  1407. case 'Home':
  1408. if (!menuIsOpen) return;
  1409. _this.focusOption('first');
  1410. break;
  1411. case 'End':
  1412. if (!menuIsOpen) return;
  1413. _this.focusOption('last');
  1414. break;
  1415. default:
  1416. return;
  1417. }
  1418. event.preventDefault();
  1419. };
  1420. _this.buildMenuOptions = function (props, selectValue) {
  1421. var _props$inputValue = props.inputValue,
  1422. inputValue = _props$inputValue === void 0 ? '' : _props$inputValue,
  1423. options = props.options;
  1424. var toOption = function toOption(option, id) {
  1425. var isDisabled = _this.isOptionDisabled(option, selectValue);
  1426. var isSelected = _this.isOptionSelected(option, selectValue);
  1427. var label = _this.getOptionLabel(option);
  1428. var value = _this.getOptionValue(option);
  1429. if (_this.shouldHideSelectedOptions() && isSelected || !_this.filterOption({
  1430. label: label,
  1431. value: value,
  1432. data: option
  1433. }, inputValue)) {
  1434. return;
  1435. }
  1436. var onHover = isDisabled ? undefined : function () {
  1437. return _this.onOptionHover(option);
  1438. };
  1439. var onSelect = isDisabled ? undefined : function () {
  1440. return _this.selectOption(option);
  1441. };
  1442. var optionId = _this.getElementId('option') + "-" + id;
  1443. return {
  1444. innerProps: {
  1445. id: optionId,
  1446. onClick: onSelect,
  1447. onMouseMove: onHover,
  1448. onMouseOver: onHover,
  1449. tabIndex: -1
  1450. },
  1451. data: option,
  1452. isDisabled: isDisabled,
  1453. isSelected: isSelected,
  1454. key: optionId,
  1455. label: label,
  1456. type: 'option',
  1457. value: value
  1458. };
  1459. };
  1460. return options.reduce(function (acc, item, itemIndex) {
  1461. if (item.options) {
  1462. // TODO needs a tidier implementation
  1463. if (!_this.hasGroups) _this.hasGroups = true;
  1464. var items = item.options;
  1465. var children = items.map(function (child, i) {
  1466. var option = toOption(child, itemIndex + "-" + i);
  1467. if (option) acc.focusable.push(child);
  1468. return option;
  1469. }).filter(Boolean);
  1470. if (children.length) {
  1471. var groupId = _this.getElementId('group') + "-" + itemIndex;
  1472. acc.render.push({
  1473. type: 'group',
  1474. key: groupId,
  1475. data: item,
  1476. options: children
  1477. });
  1478. }
  1479. } else {
  1480. var option = toOption(item, "" + itemIndex);
  1481. if (option) {
  1482. acc.render.push(option);
  1483. acc.focusable.push(item);
  1484. }
  1485. }
  1486. return acc;
  1487. }, {
  1488. render: [],
  1489. focusable: []
  1490. });
  1491. };
  1492. var _value = _props.value;
  1493. _this.cacheComponents = memoizeOne(_this.cacheComponents, exportedEqual).bind(_assertThisInitialized(_assertThisInitialized(_this)));
  1494. _this.cacheComponents(_props.components);
  1495. _this.instancePrefix = 'react-select-' + (_this.props.instanceId || ++instanceId);
  1496. var _selectValue = cleanValue(_value);
  1497. _this.buildMenuOptions = memoizeOne(_this.buildMenuOptions, function (newArgs, lastArgs) {
  1498. var _ref6 = newArgs,
  1499. newProps = _ref6[0],
  1500. newSelectValue = _ref6[1];
  1501. var _ref7 = lastArgs,
  1502. lastProps = _ref7[0],
  1503. lastSelectValue = _ref7[1];
  1504. return exportedEqual(newSelectValue, lastSelectValue) && exportedEqual(newProps.inputValue, lastProps.inputValue) && exportedEqual(newProps.options, lastProps.options);
  1505. }).bind(_assertThisInitialized(_assertThisInitialized(_this)));
  1506. var _menuOptions = _props.menuIsOpen ? _this.buildMenuOptions(_props, _selectValue) : {
  1507. render: [],
  1508. focusable: []
  1509. };
  1510. _this.state.menuOptions = _menuOptions;
  1511. _this.state.selectValue = _selectValue;
  1512. return _this;
  1513. }
  1514. var _proto = Select.prototype;
  1515. _proto.componentDidMount = function componentDidMount() {
  1516. this.startListeningComposition();
  1517. this.startListeningToTouch();
  1518. if (this.props.closeMenuOnScroll && document && document.addEventListener) {
  1519. // Listen to all scroll events, and filter them out inside of 'onScroll'
  1520. document.addEventListener('scroll', this.onScroll, true);
  1521. }
  1522. if (this.props.autoFocus) {
  1523. this.focusInput();
  1524. }
  1525. };
  1526. _proto.UNSAFE_componentWillReceiveProps = function UNSAFE_componentWillReceiveProps(nextProps) {
  1527. var _this$props8 = this.props,
  1528. options = _this$props8.options,
  1529. value = _this$props8.value,
  1530. menuIsOpen = _this$props8.menuIsOpen,
  1531. inputValue = _this$props8.inputValue; // re-cache custom components
  1532. this.cacheComponents(nextProps.components); // rebuild the menu options
  1533. if (nextProps.value !== value || nextProps.options !== options || nextProps.menuIsOpen !== menuIsOpen || nextProps.inputValue !== inputValue) {
  1534. var selectValue = cleanValue(nextProps.value);
  1535. var menuOptions = nextProps.menuIsOpen ? this.buildMenuOptions(nextProps, selectValue) : {
  1536. render: [],
  1537. focusable: []
  1538. };
  1539. var focusedValue = this.getNextFocusedValue(selectValue);
  1540. var focusedOption = this.getNextFocusedOption(menuOptions.focusable);
  1541. this.setState({
  1542. menuOptions: menuOptions,
  1543. selectValue: selectValue,
  1544. focusedOption: focusedOption,
  1545. focusedValue: focusedValue
  1546. });
  1547. } // some updates should toggle the state of the input visibility
  1548. if (this.inputIsHiddenAfterUpdate != null) {
  1549. this.setState({
  1550. inputIsHidden: this.inputIsHiddenAfterUpdate
  1551. });
  1552. delete this.inputIsHiddenAfterUpdate;
  1553. }
  1554. };
  1555. _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
  1556. var _this$props9 = this.props,
  1557. isDisabled = _this$props9.isDisabled,
  1558. menuIsOpen = _this$props9.menuIsOpen;
  1559. var isFocused = this.state.isFocused;
  1560. if ( // ensure focus is restored correctly when the control becomes enabled
  1561. isFocused && !isDisabled && prevProps.isDisabled || // ensure focus is on the Input when the menu opens
  1562. isFocused && menuIsOpen && !prevProps.menuIsOpen) {
  1563. this.focusInput();
  1564. } // scroll the focused option into view if necessary
  1565. if (this.menuListRef && this.focusedOptionRef && this.scrollToFocusedOptionOnUpdate) {
  1566. scrollIntoView(this.menuListRef, this.focusedOptionRef);
  1567. this.scrollToFocusedOptionOnUpdate = false;
  1568. }
  1569. };
  1570. _proto.componentWillUnmount = function componentWillUnmount() {
  1571. this.stopListeningComposition();
  1572. this.stopListeningToTouch();
  1573. document.removeEventListener('scroll', this.onScroll, true);
  1574. };
  1575. // ==============================
  1576. // Consumer Handlers
  1577. // ==============================
  1578. _proto.onMenuOpen = function onMenuOpen() {
  1579. this.props.onMenuOpen();
  1580. };
  1581. _proto.onMenuClose = function onMenuClose() {
  1582. var _this$props10 = this.props,
  1583. isSearchable = _this$props10.isSearchable,
  1584. isMulti = _this$props10.isMulti;
  1585. this.announceAriaLiveContext({
  1586. event: 'input',
  1587. context: {
  1588. isSearchable: isSearchable,
  1589. isMulti: isMulti
  1590. }
  1591. });
  1592. this.onInputChange('', {
  1593. action: 'menu-close'
  1594. });
  1595. this.props.onMenuClose();
  1596. };
  1597. _proto.onInputChange = function onInputChange(newValue, actionMeta) {
  1598. this.props.onInputChange(newValue, actionMeta);
  1599. } // ==============================
  1600. // Methods
  1601. // ==============================
  1602. ;
  1603. _proto.focusInput = function focusInput() {
  1604. if (!this.inputRef) return;
  1605. this.inputRef.focus();
  1606. };
  1607. _proto.blurInput = function blurInput() {
  1608. if (!this.inputRef) return;
  1609. this.inputRef.blur();
  1610. } // aliased for consumers
  1611. ;
  1612. _proto.openMenu = function openMenu(focusOption) {
  1613. var _this2 = this;
  1614. var _this$state3 = this.state,
  1615. selectValue = _this$state3.selectValue,
  1616. isFocused = _this$state3.isFocused;
  1617. var menuOptions = this.buildMenuOptions(this.props, selectValue);
  1618. var isMulti = this.props.isMulti;
  1619. var openAtIndex = focusOption === 'first' ? 0 : menuOptions.focusable.length - 1;
  1620. if (!isMulti) {
  1621. var selectedIndex = menuOptions.focusable.indexOf(selectValue[0]);
  1622. if (selectedIndex > -1) {
  1623. openAtIndex = selectedIndex;
  1624. }
  1625. } // only scroll if the menu isn't already open
  1626. this.scrollToFocusedOptionOnUpdate = !(isFocused && this.menuListRef);
  1627. this.inputIsHiddenAfterUpdate = false;
  1628. this.setState({
  1629. menuOptions: menuOptions,
  1630. focusedValue: null,
  1631. focusedOption: menuOptions.focusable[openAtIndex]
  1632. }, function () {
  1633. _this2.onMenuOpen();
  1634. _this2.announceAriaLiveContext({
  1635. event: 'menu'
  1636. });
  1637. });
  1638. };
  1639. _proto.focusValue = function focusValue(direction) {
  1640. var _this$props11 = this.props,
  1641. isMulti = _this$props11.isMulti,
  1642. isSearchable = _this$props11.isSearchable;
  1643. var _this$state4 = this.state,
  1644. selectValue = _this$state4.selectValue,
  1645. focusedValue = _this$state4.focusedValue; // Only multiselects support value focusing
  1646. if (!isMulti) return;
  1647. this.setState({
  1648. focusedOption: null
  1649. });
  1650. var focusedIndex = selectValue.indexOf(focusedValue);
  1651. if (!focusedValue) {
  1652. focusedIndex = -1;
  1653. this.announceAriaLiveContext({
  1654. event: 'value'
  1655. });
  1656. }
  1657. var lastIndex = selectValue.length - 1;
  1658. var nextFocus = -1;
  1659. if (!selectValue.length) return;
  1660. switch (direction) {
  1661. case 'previous':
  1662. if (focusedIndex === 0) {
  1663. // don't cycle from the start to the end
  1664. nextFocus = 0;
  1665. } else if (focusedIndex === -1) {
  1666. // if nothing is focused, focus the last value first
  1667. nextFocus = lastIndex;
  1668. } else {
  1669. nextFocus = focusedIndex - 1;
  1670. }
  1671. break;
  1672. case 'next':
  1673. if (focusedIndex > -1 && focusedIndex < lastIndex) {
  1674. nextFocus = focusedIndex + 1;
  1675. }
  1676. break;
  1677. }
  1678. if (nextFocus === -1) {
  1679. this.announceAriaLiveContext({
  1680. event: 'input',
  1681. context: {
  1682. isSearchable: isSearchable,
  1683. isMulti: isMulti
  1684. }
  1685. });
  1686. }
  1687. this.setState({
  1688. inputIsHidden: nextFocus !== -1,
  1689. focusedValue: selectValue[nextFocus]
  1690. });
  1691. };
  1692. _proto.focusOption = function focusOption(direction) {
  1693. if (direction === void 0) {
  1694. direction = 'first';
  1695. }
  1696. var pageSize = this.props.pageSize;
  1697. var _this$state5 = this.state,
  1698. focusedOption = _this$state5.focusedOption,
  1699. menuOptions = _this$state5.menuOptions;
  1700. var options = menuOptions.focusable;
  1701. if (!options.length) return;
  1702. var nextFocus = 0; // handles 'first'
  1703. var focusedIndex = options.indexOf(focusedOption);
  1704. if (!focusedOption) {
  1705. focusedIndex = -1;
  1706. this.announceAriaLiveContext({
  1707. event: 'menu'
  1708. });
  1709. }
  1710. if (direction === 'up') {
  1711. nextFocus = focusedIndex > 0 ? focusedIndex - 1 : options.length - 1;
  1712. } else if (direction === 'down') {
  1713. nextFocus = (focusedIndex + 1) % options.length;
  1714. } else if (direction === 'pageup') {
  1715. nextFocus = focusedIndex - pageSize;
  1716. if (nextFocus < 0) nextFocus = 0;
  1717. } else if (direction === 'pagedown') {
  1718. nextFocus = focusedIndex + pageSize;
  1719. if (nextFocus > options.length - 1) nextFocus = options.length - 1;
  1720. } else if (direction === 'last') {
  1721. nextFocus = options.length - 1;
  1722. }
  1723. this.scrollToFocusedOptionOnUpdate = true;
  1724. this.setState({
  1725. focusedOption: options[nextFocus],
  1726. focusedValue: null
  1727. });
  1728. this.announceAriaLiveContext({
  1729. event: 'menu',
  1730. context: {
  1731. isDisabled: isOptionDisabled(options[nextFocus])
  1732. }
  1733. });
  1734. };
  1735. // ==============================
  1736. // Getters
  1737. // ==============================
  1738. _proto.getTheme = function getTheme() {
  1739. // Use the default theme if there are no customizations.
  1740. if (!this.props.theme) {
  1741. return defaultTheme;
  1742. } // If the theme prop is a function, assume the function
  1743. // knows how to merge the passed-in default theme with
  1744. // its own modifications.
  1745. if (typeof this.props.theme === 'function') {
  1746. return this.props.theme(defaultTheme);
  1747. } // Otherwise, if a plain theme object was passed in,
  1748. // overlay it with the default theme.
  1749. return _extends$4({}, defaultTheme, this.props.theme);
  1750. };
  1751. _proto.getCommonProps = function getCommonProps() {
  1752. var clearValue = this.clearValue,
  1753. getStyles = this.getStyles,
  1754. setValue = this.setValue,
  1755. selectOption = this.selectOption,
  1756. props = this.props;
  1757. var classNamePrefix = props.classNamePrefix,
  1758. isMulti = props.isMulti,
  1759. isRtl = props.isRtl,
  1760. options = props.options;
  1761. var selectValue = this.state.selectValue;
  1762. var hasValue = this.hasValue();
  1763. var getValue = function getValue() {
  1764. return selectValue;
  1765. };
  1766. var cx = classNames.bind(null, classNamePrefix);
  1767. return {
  1768. cx: cx,
  1769. clearValue: clearValue,
  1770. getStyles: getStyles,
  1771. getValue: getValue,
  1772. hasValue: hasValue,
  1773. isMulti: isMulti,
  1774. isRtl: isRtl,
  1775. options: options,
  1776. selectOption: selectOption,
  1777. setValue: setValue,
  1778. selectProps: props,
  1779. theme: this.getTheme()
  1780. };
  1781. };
  1782. _proto.getNextFocusedValue = function getNextFocusedValue(nextSelectValue) {
  1783. if (this.clearFocusValueOnUpdate) {
  1784. this.clearFocusValueOnUpdate = false;
  1785. return null;
  1786. }
  1787. var _this$state6 = this.state,
  1788. focusedValue = _this$state6.focusedValue,
  1789. lastSelectValue = _this$state6.selectValue;
  1790. var lastFocusedIndex = lastSelectValue.indexOf(focusedValue);
  1791. if (lastFocusedIndex > -1) {
  1792. var nextFocusedIndex = nextSelectValue.indexOf(focusedValue);
  1793. if (nextFocusedIndex > -1) {
  1794. // the focused value is still in the selectValue, return it
  1795. return focusedValue;
  1796. } else if (lastFocusedIndex < nextSelectValue.length) {
  1797. // the focusedValue is not present in the next selectValue array by
  1798. // reference, so return the new value at the same index
  1799. return nextSelectValue[lastFocusedIndex];
  1800. }
  1801. }
  1802. return null;
  1803. };
  1804. _proto.getNextFocusedOption = function getNextFocusedOption(options) {
  1805. var lastFocusedOption = this.state.focusedOption;
  1806. return lastFocusedOption && options.indexOf(lastFocusedOption) > -1 ? lastFocusedOption : options[0];
  1807. };
  1808. _proto.hasValue = function hasValue() {
  1809. var selectValue = this.state.selectValue;
  1810. return selectValue.length > 0;
  1811. };
  1812. _proto.hasOptions = function hasOptions() {
  1813. return !!this.state.menuOptions.render.length;
  1814. };
  1815. _proto.countOptions = function countOptions() {
  1816. return this.state.menuOptions.focusable.length;
  1817. };
  1818. _proto.isClearable = function isClearable() {
  1819. var _this$props12 = this.props,
  1820. isClearable = _this$props12.isClearable,
  1821. isMulti = _this$props12.isMulti; // single select, by default, IS NOT clearable
  1822. // multi select, by default, IS clearable
  1823. if (isClearable === undefined) return isMulti;
  1824. return isClearable;
  1825. };
  1826. _proto.isOptionDisabled = function isOptionDisabled(option, selectValue) {
  1827. return typeof this.props.isOptionDisabled === 'function' ? this.props.isOptionDisabled(option, selectValue) : false;
  1828. };
  1829. _proto.isOptionSelected = function isOptionSelected(option, selectValue) {
  1830. var _this3 = this;
  1831. if (selectValue.indexOf(option) > -1) return true;
  1832. if (typeof this.props.isOptionSelected === 'function') {
  1833. return this.props.isOptionSelected(option, selectValue);
  1834. }
  1835. var candidate = this.getOptionValue(option);
  1836. return selectValue.some(function (i) {
  1837. return _this3.getOptionValue(i) === candidate;
  1838. });
  1839. };
  1840. _proto.filterOption = function filterOption(option, inputValue) {
  1841. return this.props.filterOption ? this.props.filterOption(option, inputValue) : true;
  1842. };
  1843. _proto.formatOptionLabel = function formatOptionLabel(data, context) {
  1844. if (typeof this.props.formatOptionLabel === 'function') {
  1845. var inputValue = this.props.inputValue;
  1846. var selectValue = this.state.selectValue;
  1847. return this.props.formatOptionLabel(data, {
  1848. context: context,
  1849. inputValue: inputValue,
  1850. selectValue: selectValue
  1851. });
  1852. } else {
  1853. return this.getOptionLabel(data);
  1854. }
  1855. };
  1856. _proto.formatGroupLabel = function formatGroupLabel(data) {
  1857. return this.props.formatGroupLabel(data);
  1858. } // ==============================
  1859. // Mouse Handlers
  1860. // ==============================
  1861. ;
  1862. // ==============================
  1863. // Composition Handlers
  1864. // ==============================
  1865. _proto.startListeningComposition = function startListeningComposition() {
  1866. if (document && document.addEventListener) {
  1867. document.addEventListener('compositionstart', this.onCompositionStart, false);
  1868. document.addEventListener('compositionend', this.onCompositionEnd, false);
  1869. }
  1870. };
  1871. _proto.stopListeningComposition = function stopListeningComposition() {
  1872. if (document && document.removeEventListener) {
  1873. document.removeEventListener('compositionstart', this.onCompositionStart);
  1874. document.removeEventListener('compositionend', this.onCompositionEnd);
  1875. }
  1876. };
  1877. // ==============================
  1878. // Touch Handlers
  1879. // ==============================
  1880. _proto.startListeningToTouch = function startListeningToTouch() {
  1881. if (document && document.addEventListener) {
  1882. document.addEventListener('touchstart', this.onTouchStart, false);
  1883. document.addEventListener('touchmove', this.onTouchMove, false);
  1884. document.addEventListener('touchend', this.onTouchEnd, false);
  1885. }
  1886. };
  1887. _proto.stopListeningToTouch = function stopListeningToTouch() {
  1888. if (document && document.removeEventListener) {
  1889. document.removeEventListener('touchstart', this.onTouchStart);
  1890. document.removeEventListener('touchmove', this.onTouchMove);
  1891. document.removeEventListener('touchend', this.onTouchEnd);
  1892. }
  1893. };
  1894. // ==============================
  1895. // Renderers
  1896. // ==============================
  1897. _proto.constructAriaLiveMessage = function constructAriaLiveMessage() {
  1898. var _this$state7 = this.state,
  1899. ariaLiveContext = _this$state7.ariaLiveContext,
  1900. selectValue = _this$state7.selectValue,
  1901. focusedValue = _this$state7.focusedValue,
  1902. focusedOption = _this$state7.focusedOption;
  1903. var _this$props13 = this.props,
  1904. options = _this$props13.options,
  1905. menuIsOpen = _this$props13.menuIsOpen,
  1906. inputValue = _this$props13.inputValue,
  1907. screenReaderStatus = _this$props13.screenReaderStatus; // An aria live message representing the currently focused value in the select.
  1908. var focusedValueMsg = focusedValue ? valueFocusAriaMessage({
  1909. focusedValue: focusedValue,
  1910. getOptionLabel: this.getOptionLabel,
  1911. selectValue: selectValue
  1912. }) : ''; // An aria live message representing the currently focused option in the select.
  1913. var focusedOptionMsg = focusedOption && menuIsOpen ? optionFocusAriaMessage({
  1914. focusedOption: focusedOption,
  1915. getOptionLabel: this.getOptionLabel,
  1916. options: options
  1917. }) : ''; // An aria live message representing the set of focusable results and current searchterm/inputvalue.
  1918. var resultsMsg = resultsAriaMessage({
  1919. inputValue: inputValue,
  1920. screenReaderMessage: screenReaderStatus({
  1921. count: this.countOptions()
  1922. })
  1923. });
  1924. return focusedValueMsg + " " + focusedOptionMsg + " " + resultsMsg + " " + ariaLiveContext;
  1925. };
  1926. _proto.renderInput = function renderInput() {
  1927. var _this$props14 = this.props,
  1928. isDisabled = _this$props14.isDisabled,
  1929. isSearchable = _this$props14.isSearchable,
  1930. inputId = _this$props14.inputId,
  1931. inputValue = _this$props14.inputValue,
  1932. tabIndex = _this$props14.tabIndex;
  1933. var Input = this.components.Input;
  1934. var inputIsHidden = this.state.inputIsHidden;
  1935. var id = inputId || this.getElementId('input'); // aria attributes makes the JSX "noisy", separated for clarity
  1936. var ariaAttributes = {
  1937. 'aria-autocomplete': 'list',
  1938. 'aria-label': this.props['aria-label'],
  1939. 'aria-labelledby': this.props['aria-labelledby']
  1940. };
  1941. if (!isSearchable) {
  1942. // use a dummy input to maintain focus/blur functionality
  1943. return React.createElement(DummyInput, _extends$4({
  1944. id: id,
  1945. innerRef: this.getInputRef,
  1946. onBlur: this.onInputBlur,
  1947. onChange: noop,
  1948. onFocus: this.onInputFocus,
  1949. readOnly: true,
  1950. disabled: isDisabled,
  1951. tabIndex: tabIndex,
  1952. value: ""
  1953. }, ariaAttributes));
  1954. }
  1955. var _this$commonProps = this.commonProps,
  1956. cx = _this$commonProps.cx,
  1957. theme = _this$commonProps.theme,
  1958. selectProps = _this$commonProps.selectProps;
  1959. return React.createElement(Input, _extends$4({
  1960. autoCapitalize: "none",
  1961. autoComplete: "off",
  1962. autoCorrect: "off",
  1963. cx: cx,
  1964. getStyles: this.getStyles,
  1965. id: id,
  1966. innerRef: this.getInputRef,
  1967. isDisabled: isDisabled,
  1968. isHidden: inputIsHidden,
  1969. onBlur: this.onInputBlur,
  1970. onChange: this.handleInputChange,
  1971. onFocus: this.onInputFocus,
  1972. selectProps: selectProps,
  1973. spellCheck: "false",
  1974. tabIndex: tabIndex,
  1975. theme: theme,
  1976. type: "text",
  1977. value: inputValue
  1978. }, ariaAttributes));
  1979. };
  1980. _proto.renderPlaceholderOrValue = function renderPlaceholderOrValue() {
  1981. var _this4 = this;
  1982. var _this$components = this.components,
  1983. MultiValue = _this$components.MultiValue,
  1984. MultiValueContainer = _this$components.MultiValueContainer,
  1985. MultiValueLabel = _this$components.MultiValueLabel,
  1986. MultiValueRemove = _this$components.MultiValueRemove,
  1987. SingleValue = _this$components.SingleValue,
  1988. Placeholder = _this$components.Placeholder;
  1989. var commonProps = this.commonProps;
  1990. var _this$props15 = this.props,
  1991. controlShouldRenderValue = _this$props15.controlShouldRenderValue,
  1992. isDisabled = _this$props15.isDisabled,
  1993. isMulti = _this$props15.isMulti,
  1994. inputValue = _this$props15.inputValue,
  1995. placeholder = _this$props15.placeholder;
  1996. var _this$state8 = this.state,
  1997. selectValue = _this$state8.selectValue,
  1998. focusedValue = _this$state8.focusedValue,
  1999. isFocused = _this$state8.isFocused;
  2000. if (!this.hasValue() || !controlShouldRenderValue) {
  2001. return inputValue ? null : React.createElement(Placeholder, _extends$4({}, commonProps, {
  2002. key: "placeholder",
  2003. isDisabled: isDisabled,
  2004. isFocused: isFocused
  2005. }), placeholder);
  2006. }
  2007. if (isMulti) {
  2008. var selectValues = selectValue.map(function (opt, index) {
  2009. var isOptionFocused = opt === focusedValue;
  2010. return React.createElement(MultiValue, _extends$4({}, commonProps, {
  2011. components: {
  2012. Container: MultiValueContainer,
  2013. Label: MultiValueLabel,
  2014. Remove: MultiValueRemove
  2015. },
  2016. isFocused: isOptionFocused,
  2017. isDisabled: isDisabled,
  2018. key: _this4.getOptionValue(opt),
  2019. index: index,
  2020. removeProps: {
  2021. onClick: function onClick() {
  2022. return _this4.removeValue(opt);
  2023. },
  2024. onTouchEnd: function onTouchEnd() {
  2025. return _this4.removeValue(opt);
  2026. },
  2027. onMouseDown: function onMouseDown(e) {
  2028. e.preventDefault();
  2029. e.stopPropagation();
  2030. }
  2031. },
  2032. data: opt
  2033. }), _this4.formatOptionLabel(opt, 'value'));
  2034. });
  2035. return selectValues;
  2036. }
  2037. if (inputValue) {
  2038. return null;
  2039. }
  2040. var singleValue = selectValue[0];
  2041. return React.createElement(SingleValue, _extends$4({}, commonProps, {
  2042. data: singleValue,
  2043. isDisabled: isDisabled
  2044. }), this.formatOptionLabel(singleValue, 'value'));
  2045. };
  2046. _proto.renderClearIndicator = function renderClearIndicator() {
  2047. var ClearIndicator = this.components.ClearIndicator;
  2048. var commonProps = this.commonProps;
  2049. var _this$props16 = this.props,
  2050. isDisabled = _this$props16.isDisabled,
  2051. isLoading = _this$props16.isLoading;
  2052. var isFocused = this.state.isFocused;
  2053. if (!this.isClearable() || !ClearIndicator || isDisabled || !this.hasValue() || isLoading) {
  2054. return null;
  2055. }
  2056. var innerProps = {
  2057. onMouseDown: this.onClearIndicatorMouseDown,
  2058. onTouchEnd: this.onClearIndicatorTouchEnd,
  2059. 'aria-hidden': 'true'
  2060. };
  2061. return React.createElement(ClearIndicator, _extends$4({}, commonProps, {
  2062. innerProps: innerProps,
  2063. isFocused: isFocused
  2064. }));
  2065. };
  2066. _proto.renderLoadingIndicator = function renderLoadingIndicator() {
  2067. var LoadingIndicator = this.components.LoadingIndicator;
  2068. var commonProps = this.commonProps;
  2069. var _this$props17 = this.props,
  2070. isDisabled = _this$props17.isDisabled,
  2071. isLoading = _this$props17.isLoading;
  2072. var isFocused = this.state.isFocused;
  2073. if (!LoadingIndicator || !isLoading) return null;
  2074. var innerProps = {
  2075. 'aria-hidden': 'true'
  2076. };
  2077. return React.createElement(LoadingIndicator, _extends$4({}, commonProps, {
  2078. innerProps: innerProps,
  2079. isDisabled: isDisabled,
  2080. isFocused: isFocused
  2081. }));
  2082. };
  2083. _proto.renderIndicatorSeparator = function renderIndicatorSeparator() {
  2084. var _this$components2 = this.components,
  2085. DropdownIndicator = _this$components2.DropdownIndicator,
  2086. IndicatorSeparator = _this$components2.IndicatorSeparator; // separator doesn't make sense without the dropdown indicator
  2087. if (!DropdownIndicator || !IndicatorSeparator) return null;
  2088. var commonProps = this.commonProps;
  2089. var isDisabled = this.props.isDisabled;
  2090. var isFocused = this.state.isFocused;
  2091. return React.createElement(IndicatorSeparator, _extends$4({}, commonProps, {
  2092. isDisabled: isDisabled,
  2093. isFocused: isFocused
  2094. }));
  2095. };
  2096. _proto.renderDropdownIndicator = function renderDropdownIndicator() {
  2097. var DropdownIndicator = this.components.DropdownIndicator;
  2098. if (!DropdownIndicator) return null;
  2099. var commonProps = this.commonProps;
  2100. var isDisabled = this.props.isDisabled;
  2101. var isFocused = this.state.isFocused;
  2102. var innerProps = {
  2103. onMouseDown: this.onDropdownIndicatorMouseDown,
  2104. onTouchEnd: this.onDropdownIndicatorTouchEnd,
  2105. 'aria-hidden': 'true'
  2106. };
  2107. return React.createElement(DropdownIndicator, _extends$4({}, commonProps, {
  2108. innerProps: innerProps,
  2109. isDisabled: isDisabled,
  2110. isFocused: isFocused
  2111. }));
  2112. };
  2113. _proto.renderMenu = function renderMenu() {
  2114. var _this5 = this;
  2115. var _this$components3 = this.components,
  2116. Group = _this$components3.Group,
  2117. GroupHeading = _this$components3.GroupHeading,
  2118. Menu = _this$components3.Menu,
  2119. MenuList = _this$components3.MenuList,
  2120. MenuPortal = _this$components3.MenuPortal,
  2121. LoadingMessage = _this$components3.LoadingMessage,
  2122. NoOptionsMessage = _this$components3.NoOptionsMessage,
  2123. Option = _this$components3.Option;
  2124. var commonProps = this.commonProps;
  2125. var _this$state9 = this.state,
  2126. focusedOption = _this$state9.focusedOption,
  2127. menuOptions = _this$state9.menuOptions;
  2128. var _this$props18 = this.props,
  2129. captureMenuScroll = _this$props18.captureMenuScroll,
  2130. inputValue = _this$props18.inputValue,
  2131. isLoading = _this$props18.isLoading,
  2132. loadingMessage = _this$props18.loadingMessage,
  2133. minMenuHeight = _this$props18.minMenuHeight,
  2134. maxMenuHeight = _this$props18.maxMenuHeight,
  2135. menuIsOpen = _this$props18.menuIsOpen,
  2136. menuPlacement = _this$props18.menuPlacement,
  2137. menuPosition = _this$props18.menuPosition,
  2138. menuPortalTarget = _this$props18.menuPortalTarget,
  2139. menuShouldBlockScroll = _this$props18.menuShouldBlockScroll,
  2140. menuShouldScrollIntoView = _this$props18.menuShouldScrollIntoView,
  2141. noOptionsMessage = _this$props18.noOptionsMessage,
  2142. onMenuScrollToTop = _this$props18.onMenuScrollToTop,
  2143. onMenuScrollToBottom = _this$props18.onMenuScrollToBottom;
  2144. if (!menuIsOpen) return null; // TODO: Internal Option Type here
  2145. var render = function render(props) {
  2146. // for performance, the menu options in state aren't changed when the
  2147. // focused option changes so we calculate additional props based on that
  2148. var isFocused = focusedOption === props.data;
  2149. props.innerRef = isFocused ? _this5.getFocusedOptionRef : undefined;
  2150. return React.createElement(Option, _extends$4({}, commonProps, props, {
  2151. isFocused: isFocused
  2152. }), _this5.formatOptionLabel(props.data, 'menu'));
  2153. };
  2154. var menuUI;
  2155. if (this.hasOptions()) {
  2156. menuUI = menuOptions.render.map(function (item) {
  2157. if (item.type === 'group') {
  2158. var type = item.type,
  2159. group = _objectWithoutPropertiesLoose$2(item, ["type"]);
  2160. var headingId = item.key + "-heading";
  2161. return React.createElement(Group, _extends$4({}, commonProps, group, {
  2162. Heading: GroupHeading,
  2163. headingProps: {
  2164. id: headingId
  2165. },
  2166. label: _this5.formatGroupLabel(item.data)
  2167. }), item.options.map(function (option) {
  2168. return render(option);
  2169. }));
  2170. } else if (item.type === 'option') {
  2171. return render(item);
  2172. }
  2173. });
  2174. } else if (isLoading) {
  2175. var message = loadingMessage({
  2176. inputValue: inputValue
  2177. });
  2178. if (message === null) return null;
  2179. menuUI = React.createElement(LoadingMessage, commonProps, message);
  2180. } else {
  2181. var _message = noOptionsMessage({
  2182. inputValue: inputValue
  2183. });
  2184. if (_message === null) return null;
  2185. menuUI = React.createElement(NoOptionsMessage, commonProps, _message);
  2186. }
  2187. var menuPlacementProps = {
  2188. minMenuHeight: minMenuHeight,
  2189. maxMenuHeight: maxMenuHeight,
  2190. menuPlacement: menuPlacement,
  2191. menuPosition: menuPosition,
  2192. menuShouldScrollIntoView: menuShouldScrollIntoView
  2193. };
  2194. var menuElement = React.createElement(MenuPlacer, _extends$4({}, commonProps, menuPlacementProps), function (_ref8) {
  2195. var ref = _ref8.ref,
  2196. _ref8$placerProps = _ref8.placerProps,
  2197. placement = _ref8$placerProps.placement,
  2198. maxHeight = _ref8$placerProps.maxHeight;
  2199. return React.createElement(Menu, _extends$4({}, commonProps, menuPlacementProps, {
  2200. innerRef: ref,
  2201. innerProps: {
  2202. onMouseDown: _this5.onMenuMouseDown,
  2203. onMouseMove: _this5.onMenuMouseMove
  2204. },
  2205. isLoading: isLoading,
  2206. placement: placement
  2207. }), React.createElement(ScrollCaptorSwitch, {
  2208. isEnabled: captureMenuScroll,
  2209. onTopArrive: onMenuScrollToTop,
  2210. onBottomArrive: onMenuScrollToBottom
  2211. }, React.createElement(ScrollBlock, {
  2212. isEnabled: menuShouldBlockScroll
  2213. }, React.createElement(MenuList, _extends$4({}, commonProps, {
  2214. innerRef: _this5.getMenuListRef,
  2215. isLoading: isLoading,
  2216. maxHeight: maxHeight
  2217. }), menuUI))));
  2218. }); // positioning behaviour is almost identical for portalled and fixed,
  2219. // so we use the same component. the actual portalling logic is forked
  2220. // within the component based on `menuPosition`
  2221. return menuPortalTarget || menuPosition === 'fixed' ? React.createElement(MenuPortal, _extends$4({}, commonProps, {
  2222. appendTo: menuPortalTarget,
  2223. controlElement: this.controlRef,
  2224. menuPlacement: menuPlacement,
  2225. menuPosition: menuPosition
  2226. }), menuElement) : menuElement;
  2227. };
  2228. _proto.renderFormField = function renderFormField() {
  2229. var _this6 = this;
  2230. var _this$props19 = this.props,
  2231. delimiter = _this$props19.delimiter,
  2232. isDisabled = _this$props19.isDisabled,
  2233. isMulti = _this$props19.isMulti,
  2234. name = _this$props19.name;
  2235. var selectValue = this.state.selectValue;
  2236. if (!name || isDisabled) return;
  2237. if (isMulti) {
  2238. if (delimiter) {
  2239. var value = selectValue.map(function (opt) {
  2240. return _this6.getOptionValue(opt);
  2241. }).join(delimiter);
  2242. return React.createElement("input", {
  2243. name: name,
  2244. type: "hidden",
  2245. value: value
  2246. });
  2247. } else {
  2248. var input = selectValue.length > 0 ? selectValue.map(function (opt, i) {
  2249. return React.createElement("input", {
  2250. key: "i-" + i,
  2251. name: name,
  2252. type: "hidden",
  2253. value: _this6.getOptionValue(opt)
  2254. });
  2255. }) : React.createElement("input", {
  2256. name: name,
  2257. type: "hidden"
  2258. });
  2259. return React.createElement("div", null, input);
  2260. }
  2261. } else {
  2262. var _value2 = selectValue[0] ? this.getOptionValue(selectValue[0]) : '';
  2263. return React.createElement("input", {
  2264. name: name,
  2265. type: "hidden",
  2266. value: _value2
  2267. });
  2268. }
  2269. };
  2270. _proto.renderLiveRegion = function renderLiveRegion() {
  2271. if (!this.state.isFocused) return null;
  2272. return React.createElement(A11yText, {
  2273. "aria-live": "polite"
  2274. }, React.createElement("p", {
  2275. id: "aria-selection-event"
  2276. }, "\xA0", this.state.ariaLiveSelection), React.createElement("p", {
  2277. id: "aria-context"
  2278. }, "\xA0", this.constructAriaLiveMessage()));
  2279. };
  2280. _proto.render = function render() {
  2281. var _this$components4 = this.components,
  2282. Control = _this$components4.Control,
  2283. IndicatorsContainer = _this$components4.IndicatorsContainer,
  2284. SelectContainer = _this$components4.SelectContainer,
  2285. ValueContainer = _this$components4.ValueContainer;
  2286. var _this$props20 = this.props,
  2287. className = _this$props20.className,
  2288. id = _this$props20.id,
  2289. isDisabled = _this$props20.isDisabled,
  2290. menuIsOpen = _this$props20.menuIsOpen;
  2291. var isFocused = this.state.isFocused;
  2292. var commonProps = this.commonProps = this.getCommonProps();
  2293. return React.createElement(SelectContainer, _extends$4({}, commonProps, {
  2294. className: className,
  2295. innerProps: {
  2296. id: id,
  2297. onKeyDown: this.onKeyDown
  2298. },
  2299. isDisabled: isDisabled,
  2300. isFocused: isFocused
  2301. }), this.renderLiveRegion(), React.createElement(Control, _extends$4({}, commonProps, {
  2302. innerRef: this.getControlRef,
  2303. innerProps: {
  2304. onMouseDown: this.onControlMouseDown,
  2305. onTouchEnd: this.onControlTouchEnd
  2306. },
  2307. isDisabled: isDisabled,
  2308. isFocused: isFocused,
  2309. menuIsOpen: menuIsOpen
  2310. }), React.createElement(ValueContainer, _extends$4({}, commonProps, {
  2311. isDisabled: isDisabled
  2312. }), this.renderPlaceholderOrValue(), this.renderInput()), React.createElement(IndicatorsContainer, _extends$4({}, commonProps, {
  2313. isDisabled: isDisabled
  2314. }), this.renderClearIndicator(), this.renderLoadingIndicator(), this.renderIndicatorSeparator(), this.renderDropdownIndicator())), this.renderMenu(), this.renderFormField());
  2315. };
  2316. return Select;
  2317. }(Component);
  2318. Select.defaultProps = defaultProps;
  2319. export { Select as S, defaultTheme as a, createFilter as c, defaultProps as d, mergeStyles as m };