1 | (function (global, factory) {
|
2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('react-dom')) :
|
3 | typeof define === 'function' && define.amd ? define(['exports', 'react', 'react-dom'], factory) :
|
4 | (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReactBootstrapTypeahead = {}, global.React, global.ReactDOM));
|
5 | })(this, (function (exports, React, ReactDOM) { 'use strict';
|
6 |
|
7 | function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
8 |
|
9 | function _interopNamespace(e) {
|
10 | if (e && e.__esModule) return e;
|
11 | var n = Object.create(null);
|
12 | if (e) {
|
13 | Object.keys(e).forEach(function (k) {
|
14 | if (k !== 'default') {
|
15 | var d = Object.getOwnPropertyDescriptor(e, k);
|
16 | Object.defineProperty(n, k, d.get ? d : {
|
17 | enumerable: true,
|
18 | get: function () { return e[k]; }
|
19 | });
|
20 | }
|
21 | });
|
22 | }
|
23 | n["default"] = e;
|
24 | return Object.freeze(n);
|
25 | }
|
26 |
|
27 | var React__default = _interopDefaultLegacy(React);
|
28 | var React__namespace = _interopNamespace(React);
|
29 | var ReactDOM__namespace = _interopNamespace(ReactDOM);
|
30 | var ReactDOM__default = _interopDefaultLegacy(ReactDOM);
|
31 |
|
32 | function _iterableToArrayLimit(r, l) {
|
33 | var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
34 | if (null != t) {
|
35 | var e,
|
36 | n,
|
37 | i,
|
38 | u,
|
39 | a = [],
|
40 | f = !0,
|
41 | o = !1;
|
42 | try {
|
43 | if (i = (t = t.call(r)).next, 0 === l) {
|
44 | if (Object(t) !== t) return;
|
45 | f = !1;
|
46 | } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
47 | } catch (r) {
|
48 | o = !0, n = r;
|
49 | } finally {
|
50 | try {
|
51 | if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
52 | } finally {
|
53 | if (o) throw n;
|
54 | }
|
55 | }
|
56 | return a;
|
57 | }
|
58 | }
|
59 | function ownKeys(e, r) {
|
60 | var t = Object.keys(e);
|
61 | if (Object.getOwnPropertySymbols) {
|
62 | var o = Object.getOwnPropertySymbols(e);
|
63 | r && (o = o.filter(function (r) {
|
64 | return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
65 | })), t.push.apply(t, o);
|
66 | }
|
67 | return t;
|
68 | }
|
69 | function _objectSpread2(e) {
|
70 | for (var r = 1; r < arguments.length; r++) {
|
71 | var t = null != arguments[r] ? arguments[r] : {};
|
72 | r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
|
73 | _defineProperty(e, r, t[r]);
|
74 | }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
75 | Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
76 | });
|
77 | }
|
78 | return e;
|
79 | }
|
80 | function _classCallCheck(instance, Constructor) {
|
81 | if (!(instance instanceof Constructor)) {
|
82 | throw new TypeError("Cannot call a class as a function");
|
83 | }
|
84 | }
|
85 | function _defineProperties(target, props) {
|
86 | for (var i = 0; i < props.length; i++) {
|
87 | var descriptor = props[i];
|
88 | descriptor.enumerable = descriptor.enumerable || false;
|
89 | descriptor.configurable = true;
|
90 | if ("value" in descriptor) descriptor.writable = true;
|
91 | Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
92 | }
|
93 | }
|
94 | function _createClass(Constructor, protoProps, staticProps) {
|
95 | if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
96 | if (staticProps) _defineProperties(Constructor, staticProps);
|
97 | Object.defineProperty(Constructor, "prototype", {
|
98 | writable: false
|
99 | });
|
100 | return Constructor;
|
101 | }
|
102 | function _defineProperty(obj, key, value) {
|
103 | key = _toPropertyKey(key);
|
104 | if (key in obj) {
|
105 | Object.defineProperty(obj, key, {
|
106 | value: value,
|
107 | enumerable: true,
|
108 | configurable: true,
|
109 | writable: true
|
110 | });
|
111 | } else {
|
112 | obj[key] = value;
|
113 | }
|
114 | return obj;
|
115 | }
|
116 | function _extends() {
|
117 | _extends = Object.assign ? Object.assign.bind() : function (target) {
|
118 | for (var i = 1; i < arguments.length; i++) {
|
119 | var source = arguments[i];
|
120 | for (var key in source) {
|
121 | if (Object.prototype.hasOwnProperty.call(source, key)) {
|
122 | target[key] = source[key];
|
123 | }
|
124 | }
|
125 | }
|
126 | return target;
|
127 | };
|
128 | return _extends.apply(this, arguments);
|
129 | }
|
130 | function _inherits(subClass, superClass) {
|
131 | if (typeof superClass !== "function" && superClass !== null) {
|
132 | throw new TypeError("Super expression must either be null or a function");
|
133 | }
|
134 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
135 | constructor: {
|
136 | value: subClass,
|
137 | writable: true,
|
138 | configurable: true
|
139 | }
|
140 | });
|
141 | Object.defineProperty(subClass, "prototype", {
|
142 | writable: false
|
143 | });
|
144 | if (superClass) _setPrototypeOf(subClass, superClass);
|
145 | }
|
146 | function _getPrototypeOf(o) {
|
147 | _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
148 | return o.__proto__ || Object.getPrototypeOf(o);
|
149 | };
|
150 | return _getPrototypeOf(o);
|
151 | }
|
152 | function _setPrototypeOf(o, p) {
|
153 | _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
154 | o.__proto__ = p;
|
155 | return o;
|
156 | };
|
157 | return _setPrototypeOf(o, p);
|
158 | }
|
159 | function _isNativeReflectConstruct() {
|
160 | if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
161 | if (Reflect.construct.sham) return false;
|
162 | if (typeof Proxy === "function") return true;
|
163 | try {
|
164 | Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
165 | return true;
|
166 | } catch (e) {
|
167 | return false;
|
168 | }
|
169 | }
|
170 | function _objectWithoutPropertiesLoose(source, excluded) {
|
171 | if (source == null) return {};
|
172 | var target = {};
|
173 | var sourceKeys = Object.keys(source);
|
174 | var key, i;
|
175 | for (i = 0; i < sourceKeys.length; i++) {
|
176 | key = sourceKeys[i];
|
177 | if (excluded.indexOf(key) >= 0) continue;
|
178 | target[key] = source[key];
|
179 | }
|
180 | return target;
|
181 | }
|
182 | function _objectWithoutProperties(source, excluded) {
|
183 | if (source == null) return {};
|
184 | var target = _objectWithoutPropertiesLoose(source, excluded);
|
185 | var key, i;
|
186 | if (Object.getOwnPropertySymbols) {
|
187 | var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
188 | for (i = 0; i < sourceSymbolKeys.length; i++) {
|
189 | key = sourceSymbolKeys[i];
|
190 | if (excluded.indexOf(key) >= 0) continue;
|
191 | if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
192 | target[key] = source[key];
|
193 | }
|
194 | }
|
195 | return target;
|
196 | }
|
197 | function _assertThisInitialized(self) {
|
198 | if (self === void 0) {
|
199 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
200 | }
|
201 | return self;
|
202 | }
|
203 | function _possibleConstructorReturn(self, call) {
|
204 | if (call && (typeof call === "object" || typeof call === "function")) {
|
205 | return call;
|
206 | } else if (call !== void 0) {
|
207 | throw new TypeError("Derived constructors may only return object or undefined");
|
208 | }
|
209 | return _assertThisInitialized(self);
|
210 | }
|
211 | function _createSuper(Derived) {
|
212 | var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
213 | return function _createSuperInternal() {
|
214 | var Super = _getPrototypeOf(Derived),
|
215 | result;
|
216 | if (hasNativeReflectConstruct) {
|
217 | var NewTarget = _getPrototypeOf(this).constructor;
|
218 | result = Reflect.construct(Super, arguments, NewTarget);
|
219 | } else {
|
220 | result = Super.apply(this, arguments);
|
221 | }
|
222 | return _possibleConstructorReturn(this, result);
|
223 | };
|
224 | }
|
225 | function _slicedToArray(arr, i) {
|
226 | return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
227 | }
|
228 | function _arrayWithHoles(arr) {
|
229 | if (Array.isArray(arr)) return arr;
|
230 | }
|
231 | function _unsupportedIterableToArray(o, minLen) {
|
232 | if (!o) return;
|
233 | if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
234 | var n = Object.prototype.toString.call(o).slice(8, -1);
|
235 | if (n === "Object" && o.constructor) n = o.constructor.name;
|
236 | if (n === "Map" || n === "Set") return Array.from(o);
|
237 | if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
238 | }
|
239 | function _arrayLikeToArray(arr, len) {
|
240 | if (len == null || len > arr.length) len = arr.length;
|
241 | for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
242 | return arr2;
|
243 | }
|
244 | function _nonIterableRest() {
|
245 | throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
246 | }
|
247 | function _toPrimitive(input, hint) {
|
248 | if (typeof input !== "object" || input === null) return input;
|
249 | var prim = input[Symbol.toPrimitive];
|
250 | if (prim !== undefined) {
|
251 | var res = prim.call(input, hint || "default");
|
252 | if (typeof res !== "object") return res;
|
253 | throw new TypeError("@@toPrimitive must return a primitive value.");
|
254 | }
|
255 | return (hint === "string" ? String : Number)(input);
|
256 | }
|
257 | function _toPropertyKey(arg) {
|
258 | var key = _toPrimitive(arg, "string");
|
259 | return typeof key === "symbol" ? key : String(key);
|
260 | }
|
261 |
|
262 | var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
263 |
|
264 | |
265 |
|
266 |
|
267 |
|
268 |
|
269 |
|
270 |
|
271 |
|
272 |
|
273 |
|
274 | var FUNC_ERROR_TEXT = 'Expected a function';
|
275 |
|
276 |
|
277 | var NAN = 0 / 0;
|
278 |
|
279 |
|
280 | var symbolTag = '[object Symbol]';
|
281 |
|
282 |
|
283 | var reTrim = /^\s+|\s+$/g;
|
284 |
|
285 |
|
286 | var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
|
287 |
|
288 |
|
289 | var reIsBinary = /^0b[01]+$/i;
|
290 |
|
291 |
|
292 | var reIsOctal = /^0o[0-7]+$/i;
|
293 |
|
294 |
|
295 | var freeParseInt = parseInt;
|
296 |
|
297 |
|
298 | var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
299 |
|
300 |
|
301 | var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
302 |
|
303 |
|
304 | var root = freeGlobal || freeSelf || Function('return this')();
|
305 |
|
306 |
|
307 | var objectProto = Object.prototype;
|
308 |
|
309 | |
310 |
|
311 |
|
312 |
|
313 |
|
314 | var objectToString = objectProto.toString;
|
315 |
|
316 |
|
317 | var nativeMax = Math.max,
|
318 | nativeMin = Math.min;
|
319 |
|
320 | |
321 |
|
322 |
|
323 |
|
324 |
|
325 |
|
326 |
|
327 |
|
328 |
|
329 |
|
330 |
|
331 |
|
332 |
|
333 |
|
334 |
|
335 |
|
336 | var now = function() {
|
337 | return root.Date.now();
|
338 | };
|
339 |
|
340 | |
341 |
|
342 |
|
343 |
|
344 |
|
345 |
|
346 |
|
347 |
|
348 |
|
349 |
|
350 |
|
351 |
|
352 |
|
353 |
|
354 |
|
355 |
|
356 |
|
357 |
|
358 |
|
359 |
|
360 |
|
361 |
|
362 |
|
363 |
|
364 |
|
365 |
|
366 |
|
367 |
|
368 |
|
369 |
|
370 |
|
371 |
|
372 |
|
373 |
|
374 |
|
375 |
|
376 |
|
377 |
|
378 |
|
379 |
|
380 |
|
381 |
|
382 |
|
383 |
|
384 |
|
385 |
|
386 |
|
387 |
|
388 |
|
389 |
|
390 |
|
391 |
|
392 |
|
393 |
|
394 | function debounce$1(func, wait, options) {
|
395 | var lastArgs,
|
396 | lastThis,
|
397 | maxWait,
|
398 | result,
|
399 | timerId,
|
400 | lastCallTime,
|
401 | lastInvokeTime = 0,
|
402 | leading = false,
|
403 | maxing = false,
|
404 | trailing = true;
|
405 |
|
406 | if (typeof func != 'function') {
|
407 | throw new TypeError(FUNC_ERROR_TEXT);
|
408 | }
|
409 | wait = toNumber(wait) || 0;
|
410 | if (isObject(options)) {
|
411 | leading = !!options.leading;
|
412 | maxing = 'maxWait' in options;
|
413 | maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
|
414 | trailing = 'trailing' in options ? !!options.trailing : trailing;
|
415 | }
|
416 |
|
417 | function invokeFunc(time) {
|
418 | var args = lastArgs,
|
419 | thisArg = lastThis;
|
420 |
|
421 | lastArgs = lastThis = undefined;
|
422 | lastInvokeTime = time;
|
423 | result = func.apply(thisArg, args);
|
424 | return result;
|
425 | }
|
426 |
|
427 | function leadingEdge(time) {
|
428 |
|
429 | lastInvokeTime = time;
|
430 |
|
431 | timerId = setTimeout(timerExpired, wait);
|
432 |
|
433 | return leading ? invokeFunc(time) : result;
|
434 | }
|
435 |
|
436 | function remainingWait(time) {
|
437 | var timeSinceLastCall = time - lastCallTime,
|
438 | timeSinceLastInvoke = time - lastInvokeTime,
|
439 | result = wait - timeSinceLastCall;
|
440 |
|
441 | return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
|
442 | }
|
443 |
|
444 | function shouldInvoke(time) {
|
445 | var timeSinceLastCall = time - lastCallTime,
|
446 | timeSinceLastInvoke = time - lastInvokeTime;
|
447 |
|
448 |
|
449 |
|
450 |
|
451 | return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
|
452 | (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
|
453 | }
|
454 |
|
455 | function timerExpired() {
|
456 | var time = now();
|
457 | if (shouldInvoke(time)) {
|
458 | return trailingEdge(time);
|
459 | }
|
460 |
|
461 | timerId = setTimeout(timerExpired, remainingWait(time));
|
462 | }
|
463 |
|
464 | function trailingEdge(time) {
|
465 | timerId = undefined;
|
466 |
|
467 |
|
468 |
|
469 | if (trailing && lastArgs) {
|
470 | return invokeFunc(time);
|
471 | }
|
472 | lastArgs = lastThis = undefined;
|
473 | return result;
|
474 | }
|
475 |
|
476 | function cancel() {
|
477 | if (timerId !== undefined) {
|
478 | clearTimeout(timerId);
|
479 | }
|
480 | lastInvokeTime = 0;
|
481 | lastArgs = lastCallTime = lastThis = timerId = undefined;
|
482 | }
|
483 |
|
484 | function flush() {
|
485 | return timerId === undefined ? result : trailingEdge(now());
|
486 | }
|
487 |
|
488 | function debounced() {
|
489 | var time = now(),
|
490 | isInvoking = shouldInvoke(time);
|
491 |
|
492 | lastArgs = arguments;
|
493 | lastThis = this;
|
494 | lastCallTime = time;
|
495 |
|
496 | if (isInvoking) {
|
497 | if (timerId === undefined) {
|
498 | return leadingEdge(lastCallTime);
|
499 | }
|
500 | if (maxing) {
|
501 |
|
502 | timerId = setTimeout(timerExpired, wait);
|
503 | return invokeFunc(lastCallTime);
|
504 | }
|
505 | }
|
506 | if (timerId === undefined) {
|
507 | timerId = setTimeout(timerExpired, wait);
|
508 | }
|
509 | return result;
|
510 | }
|
511 | debounced.cancel = cancel;
|
512 | debounced.flush = flush;
|
513 | return debounced;
|
514 | }
|
515 |
|
516 | |
517 |
|
518 |
|
519 |
|
520 |
|
521 |
|
522 |
|
523 |
|
524 |
|
525 |
|
526 |
|
527 |
|
528 |
|
529 |
|
530 |
|
531 |
|
532 |
|
533 |
|
534 |
|
535 |
|
536 |
|
537 |
|
538 |
|
539 |
|
540 |
|
541 | function isObject(value) {
|
542 | var type = typeof value;
|
543 | return !!value && (type == 'object' || type == 'function');
|
544 | }
|
545 |
|
546 | |
547 |
|
548 |
|
549 |
|
550 |
|
551 |
|
552 |
|
553 |
|
554 |
|
555 |
|
556 |
|
557 |
|
558 |
|
559 |
|
560 |
|
561 |
|
562 |
|
563 |
|
564 |
|
565 |
|
566 |
|
567 |
|
568 |
|
569 |
|
570 | function isObjectLike(value) {
|
571 | return !!value && typeof value == 'object';
|
572 | }
|
573 |
|
574 | |
575 |
|
576 |
|
577 |
|
578 |
|
579 |
|
580 |
|
581 |
|
582 |
|
583 |
|
584 |
|
585 |
|
586 |
|
587 |
|
588 |
|
589 |
|
590 |
|
591 | function isSymbol(value) {
|
592 | return typeof value == 'symbol' ||
|
593 | (isObjectLike(value) && objectToString.call(value) == symbolTag);
|
594 | }
|
595 |
|
596 | |
597 |
|
598 |
|
599 |
|
600 |
|
601 |
|
602 |
|
603 |
|
604 |
|
605 |
|
606 |
|
607 |
|
608 |
|
609 |
|
610 |
|
611 |
|
612 |
|
613 |
|
614 |
|
615 |
|
616 |
|
617 |
|
618 |
|
619 | function toNumber(value) {
|
620 | if (typeof value == 'number') {
|
621 | return value;
|
622 | }
|
623 | if (isSymbol(value)) {
|
624 | return NAN;
|
625 | }
|
626 | if (isObject(value)) {
|
627 | var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
|
628 | value = isObject(other) ? (other + '') : other;
|
629 | }
|
630 | if (typeof value != 'string') {
|
631 | return value === 0 ? value : +value;
|
632 | }
|
633 | value = value.replace(reTrim, '');
|
634 | var isBinary = reIsBinary.test(value);
|
635 | return (isBinary || reIsOctal.test(value))
|
636 | ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
|
637 | : (reIsBadHex.test(value) ? NAN : +value);
|
638 | }
|
639 |
|
640 | var lodash_debounce = debounce$1;
|
641 |
|
642 | var propTypes$b = {exports: {}};
|
643 |
|
644 | var reactIs = {exports: {}};
|
645 |
|
646 | var reactIs_development = {};
|
647 |
|
648 | |
649 |
|
650 |
|
651 |
|
652 |
|
653 |
|
654 |
|
655 |
|
656 |
|
657 | var hasRequiredReactIs_development;
|
658 |
|
659 | function requireReactIs_development () {
|
660 | if (hasRequiredReactIs_development) return reactIs_development;
|
661 | hasRequiredReactIs_development = 1;
|
662 |
|
663 |
|
664 |
|
665 | {
|
666 | (function() {
|
667 |
|
668 |
|
669 |
|
670 | var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
671 | var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
|
672 | var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
|
673 | var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
|
674 | var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
|
675 | var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
|
676 | var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
677 | var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
|
678 |
|
679 |
|
680 | var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
|
681 | var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
|
682 | var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
683 | var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
|
684 | var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
|
685 | var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
|
686 | var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
|
687 | var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9;
|
688 | var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
|
689 | var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
|
690 | var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
|
691 |
|
692 | function isValidElementType(type) {
|
693 | return typeof type === 'string' || typeof type === 'function' ||
|
694 | type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE);
|
695 | }
|
696 |
|
697 | function typeOf(object) {
|
698 | if (typeof object === 'object' && object !== null) {
|
699 | var $$typeof = object.$$typeof;
|
700 |
|
701 | switch ($$typeof) {
|
702 | case REACT_ELEMENT_TYPE:
|
703 | var type = object.type;
|
704 |
|
705 | switch (type) {
|
706 | case REACT_ASYNC_MODE_TYPE:
|
707 | case REACT_CONCURRENT_MODE_TYPE:
|
708 | case REACT_FRAGMENT_TYPE:
|
709 | case REACT_PROFILER_TYPE:
|
710 | case REACT_STRICT_MODE_TYPE:
|
711 | case REACT_SUSPENSE_TYPE:
|
712 | return type;
|
713 |
|
714 | default:
|
715 | var $$typeofType = type && type.$$typeof;
|
716 |
|
717 | switch ($$typeofType) {
|
718 | case REACT_CONTEXT_TYPE:
|
719 | case REACT_FORWARD_REF_TYPE:
|
720 | case REACT_LAZY_TYPE:
|
721 | case REACT_MEMO_TYPE:
|
722 | case REACT_PROVIDER_TYPE:
|
723 | return $$typeofType;
|
724 |
|
725 | default:
|
726 | return $$typeof;
|
727 | }
|
728 |
|
729 | }
|
730 |
|
731 | case REACT_PORTAL_TYPE:
|
732 | return $$typeof;
|
733 | }
|
734 | }
|
735 |
|
736 | return undefined;
|
737 | }
|
738 |
|
739 | var AsyncMode = REACT_ASYNC_MODE_TYPE;
|
740 | var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
|
741 | var ContextConsumer = REACT_CONTEXT_TYPE;
|
742 | var ContextProvider = REACT_PROVIDER_TYPE;
|
743 | var Element = REACT_ELEMENT_TYPE;
|
744 | var ForwardRef = REACT_FORWARD_REF_TYPE;
|
745 | var Fragment = REACT_FRAGMENT_TYPE;
|
746 | var Lazy = REACT_LAZY_TYPE;
|
747 | var Memo = REACT_MEMO_TYPE;
|
748 | var Portal = REACT_PORTAL_TYPE;
|
749 | var Profiler = REACT_PROFILER_TYPE;
|
750 | var StrictMode = REACT_STRICT_MODE_TYPE;
|
751 | var Suspense = REACT_SUSPENSE_TYPE;
|
752 | var hasWarnedAboutDeprecatedIsAsyncMode = false;
|
753 |
|
754 | function isAsyncMode(object) {
|
755 | {
|
756 | if (!hasWarnedAboutDeprecatedIsAsyncMode) {
|
757 | hasWarnedAboutDeprecatedIsAsyncMode = true;
|
758 |
|
759 | console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
|
760 | }
|
761 | }
|
762 |
|
763 | return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
|
764 | }
|
765 | function isConcurrentMode(object) {
|
766 | return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
|
767 | }
|
768 | function isContextConsumer(object) {
|
769 | return typeOf(object) === REACT_CONTEXT_TYPE;
|
770 | }
|
771 | function isContextProvider(object) {
|
772 | return typeOf(object) === REACT_PROVIDER_TYPE;
|
773 | }
|
774 | function isElement(object) {
|
775 | return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
776 | }
|
777 | function isForwardRef(object) {
|
778 | return typeOf(object) === REACT_FORWARD_REF_TYPE;
|
779 | }
|
780 | function isFragment(object) {
|
781 | return typeOf(object) === REACT_FRAGMENT_TYPE;
|
782 | }
|
783 | function isLazy(object) {
|
784 | return typeOf(object) === REACT_LAZY_TYPE;
|
785 | }
|
786 | function isMemo(object) {
|
787 | return typeOf(object) === REACT_MEMO_TYPE;
|
788 | }
|
789 | function isPortal(object) {
|
790 | return typeOf(object) === REACT_PORTAL_TYPE;
|
791 | }
|
792 | function isProfiler(object) {
|
793 | return typeOf(object) === REACT_PROFILER_TYPE;
|
794 | }
|
795 | function isStrictMode(object) {
|
796 | return typeOf(object) === REACT_STRICT_MODE_TYPE;
|
797 | }
|
798 | function isSuspense(object) {
|
799 | return typeOf(object) === REACT_SUSPENSE_TYPE;
|
800 | }
|
801 |
|
802 | reactIs_development.AsyncMode = AsyncMode;
|
803 | reactIs_development.ConcurrentMode = ConcurrentMode;
|
804 | reactIs_development.ContextConsumer = ContextConsumer;
|
805 | reactIs_development.ContextProvider = ContextProvider;
|
806 | reactIs_development.Element = Element;
|
807 | reactIs_development.ForwardRef = ForwardRef;
|
808 | reactIs_development.Fragment = Fragment;
|
809 | reactIs_development.Lazy = Lazy;
|
810 | reactIs_development.Memo = Memo;
|
811 | reactIs_development.Portal = Portal;
|
812 | reactIs_development.Profiler = Profiler;
|
813 | reactIs_development.StrictMode = StrictMode;
|
814 | reactIs_development.Suspense = Suspense;
|
815 | reactIs_development.isAsyncMode = isAsyncMode;
|
816 | reactIs_development.isConcurrentMode = isConcurrentMode;
|
817 | reactIs_development.isContextConsumer = isContextConsumer;
|
818 | reactIs_development.isContextProvider = isContextProvider;
|
819 | reactIs_development.isElement = isElement;
|
820 | reactIs_development.isForwardRef = isForwardRef;
|
821 | reactIs_development.isFragment = isFragment;
|
822 | reactIs_development.isLazy = isLazy;
|
823 | reactIs_development.isMemo = isMemo;
|
824 | reactIs_development.isPortal = isPortal;
|
825 | reactIs_development.isProfiler = isProfiler;
|
826 | reactIs_development.isStrictMode = isStrictMode;
|
827 | reactIs_development.isSuspense = isSuspense;
|
828 | reactIs_development.isValidElementType = isValidElementType;
|
829 | reactIs_development.typeOf = typeOf;
|
830 | })();
|
831 | }
|
832 | return reactIs_development;
|
833 | }
|
834 |
|
835 | var hasRequiredReactIs;
|
836 |
|
837 | function requireReactIs () {
|
838 | if (hasRequiredReactIs) return reactIs.exports;
|
839 | hasRequiredReactIs = 1;
|
840 | (function (module) {
|
841 |
|
842 | {
|
843 | module.exports = requireReactIs_development();
|
844 | }
|
845 | } (reactIs));
|
846 | return reactIs.exports;
|
847 | }
|
848 |
|
849 | |
850 |
|
851 |
|
852 |
|
853 |
|
854 |
|
855 | var objectAssign;
|
856 | var hasRequiredObjectAssign;
|
857 |
|
858 | function requireObjectAssign () {
|
859 | if (hasRequiredObjectAssign) return objectAssign;
|
860 | hasRequiredObjectAssign = 1;
|
861 |
|
862 | var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
863 | var hasOwnProperty = Object.prototype.hasOwnProperty;
|
864 | var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
865 |
|
866 | function toObject(val) {
|
867 | if (val === null || val === undefined) {
|
868 | throw new TypeError('Object.assign cannot be called with null or undefined');
|
869 | }
|
870 |
|
871 | return Object(val);
|
872 | }
|
873 |
|
874 | function shouldUseNative() {
|
875 | try {
|
876 | if (!Object.assign) {
|
877 | return false;
|
878 | }
|
879 |
|
880 |
|
881 |
|
882 |
|
883 | var test1 = new String('abc');
|
884 | test1[5] = 'de';
|
885 | if (Object.getOwnPropertyNames(test1)[0] === '5') {
|
886 | return false;
|
887 | }
|
888 |
|
889 |
|
890 | var test2 = {};
|
891 | for (var i = 0; i < 10; i++) {
|
892 | test2['_' + String.fromCharCode(i)] = i;
|
893 | }
|
894 | var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
|
895 | return test2[n];
|
896 | });
|
897 | if (order2.join('') !== '0123456789') {
|
898 | return false;
|
899 | }
|
900 |
|
901 |
|
902 | var test3 = {};
|
903 | 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
|
904 | test3[letter] = letter;
|
905 | });
|
906 | if (Object.keys(Object.assign({}, test3)).join('') !==
|
907 | 'abcdefghijklmnopqrst') {
|
908 | return false;
|
909 | }
|
910 |
|
911 | return true;
|
912 | } catch (err) {
|
913 |
|
914 | return false;
|
915 | }
|
916 | }
|
917 |
|
918 | objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
|
919 | var from;
|
920 | var to = toObject(target);
|
921 | var symbols;
|
922 |
|
923 | for (var s = 1; s < arguments.length; s++) {
|
924 | from = Object(arguments[s]);
|
925 |
|
926 | for (var key in from) {
|
927 | if (hasOwnProperty.call(from, key)) {
|
928 | to[key] = from[key];
|
929 | }
|
930 | }
|
931 |
|
932 | if (getOwnPropertySymbols) {
|
933 | symbols = getOwnPropertySymbols(from);
|
934 | for (var i = 0; i < symbols.length; i++) {
|
935 | if (propIsEnumerable.call(from, symbols[i])) {
|
936 | to[symbols[i]] = from[symbols[i]];
|
937 | }
|
938 | }
|
939 | }
|
940 | }
|
941 |
|
942 | return to;
|
943 | };
|
944 | return objectAssign;
|
945 | }
|
946 |
|
947 | |
948 |
|
949 |
|
950 |
|
951 |
|
952 |
|
953 |
|
954 | var ReactPropTypesSecret_1;
|
955 | var hasRequiredReactPropTypesSecret;
|
956 |
|
957 | function requireReactPropTypesSecret () {
|
958 | if (hasRequiredReactPropTypesSecret) return ReactPropTypesSecret_1;
|
959 | hasRequiredReactPropTypesSecret = 1;
|
960 |
|
961 | var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
962 |
|
963 | ReactPropTypesSecret_1 = ReactPropTypesSecret;
|
964 | return ReactPropTypesSecret_1;
|
965 | }
|
966 |
|
967 | var has;
|
968 | var hasRequiredHas;
|
969 |
|
970 | function requireHas () {
|
971 | if (hasRequiredHas) return has;
|
972 | hasRequiredHas = 1;
|
973 | has = Function.call.bind(Object.prototype.hasOwnProperty);
|
974 | return has;
|
975 | }
|
976 |
|
977 | |
978 |
|
979 |
|
980 |
|
981 |
|
982 |
|
983 |
|
984 | var checkPropTypes_1;
|
985 | var hasRequiredCheckPropTypes;
|
986 |
|
987 | function requireCheckPropTypes () {
|
988 | if (hasRequiredCheckPropTypes) return checkPropTypes_1;
|
989 | hasRequiredCheckPropTypes = 1;
|
990 |
|
991 | var printWarning = function() {};
|
992 |
|
993 | {
|
994 | var ReactPropTypesSecret = requireReactPropTypesSecret();
|
995 | var loggedTypeFailures = {};
|
996 | var has = requireHas();
|
997 |
|
998 | printWarning = function(text) {
|
999 | var message = 'Warning: ' + text;
|
1000 | if (typeof console !== 'undefined') {
|
1001 | console.error(message);
|
1002 | }
|
1003 | try {
|
1004 |
|
1005 |
|
1006 |
|
1007 | throw new Error(message);
|
1008 | } catch (x) { }
|
1009 | };
|
1010 | }
|
1011 |
|
1012 | |
1013 |
|
1014 |
|
1015 |
|
1016 |
|
1017 |
|
1018 |
|
1019 |
|
1020 |
|
1021 |
|
1022 |
|
1023 | function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
1024 | {
|
1025 | for (var typeSpecName in typeSpecs) {
|
1026 | if (has(typeSpecs, typeSpecName)) {
|
1027 | var error;
|
1028 |
|
1029 |
|
1030 |
|
1031 | try {
|
1032 |
|
1033 |
|
1034 | if (typeof typeSpecs[typeSpecName] !== 'function') {
|
1035 | var err = Error(
|
1036 | (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
|
1037 | 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' +
|
1038 | 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.'
|
1039 | );
|
1040 | err.name = 'Invariant Violation';
|
1041 | throw err;
|
1042 | }
|
1043 | error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
|
1044 | } catch (ex) {
|
1045 | error = ex;
|
1046 | }
|
1047 | if (error && !(error instanceof Error)) {
|
1048 | printWarning(
|
1049 | (componentName || 'React class') + ': type specification of ' +
|
1050 | location + ' `' + typeSpecName + '` is invalid; the type checker ' +
|
1051 | 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
|
1052 | 'You may have forgotten to pass an argument to the type checker ' +
|
1053 | 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
|
1054 | 'shape all require an argument).'
|
1055 | );
|
1056 | }
|
1057 | if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
1058 |
|
1059 |
|
1060 | loggedTypeFailures[error.message] = true;
|
1061 |
|
1062 | var stack = getStack ? getStack() : '';
|
1063 |
|
1064 | printWarning(
|
1065 | 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
|
1066 | );
|
1067 | }
|
1068 | }
|
1069 | }
|
1070 | }
|
1071 | }
|
1072 |
|
1073 | |
1074 |
|
1075 |
|
1076 |
|
1077 |
|
1078 | checkPropTypes.resetWarningCache = function() {
|
1079 | {
|
1080 | loggedTypeFailures = {};
|
1081 | }
|
1082 | };
|
1083 |
|
1084 | checkPropTypes_1 = checkPropTypes;
|
1085 | return checkPropTypes_1;
|
1086 | }
|
1087 |
|
1088 | |
1089 |
|
1090 |
|
1091 |
|
1092 |
|
1093 |
|
1094 |
|
1095 | var factoryWithTypeCheckers;
|
1096 | var hasRequiredFactoryWithTypeCheckers;
|
1097 |
|
1098 | function requireFactoryWithTypeCheckers () {
|
1099 | if (hasRequiredFactoryWithTypeCheckers) return factoryWithTypeCheckers;
|
1100 | hasRequiredFactoryWithTypeCheckers = 1;
|
1101 |
|
1102 | var ReactIs = requireReactIs();
|
1103 | var assign = requireObjectAssign();
|
1104 |
|
1105 | var ReactPropTypesSecret = requireReactPropTypesSecret();
|
1106 | var has = requireHas();
|
1107 | var checkPropTypes = requireCheckPropTypes();
|
1108 |
|
1109 | var printWarning = function() {};
|
1110 |
|
1111 | {
|
1112 | printWarning = function(text) {
|
1113 | var message = 'Warning: ' + text;
|
1114 | if (typeof console !== 'undefined') {
|
1115 | console.error(message);
|
1116 | }
|
1117 | try {
|
1118 |
|
1119 |
|
1120 |
|
1121 | throw new Error(message);
|
1122 | } catch (x) {}
|
1123 | };
|
1124 | }
|
1125 |
|
1126 | function emptyFunctionThatReturnsNull() {
|
1127 | return null;
|
1128 | }
|
1129 |
|
1130 | factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
|
1131 |
|
1132 | var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
1133 | var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
1134 |
|
1135 | |
1136 |
|
1137 |
|
1138 |
|
1139 |
|
1140 |
|
1141 |
|
1142 |
|
1143 |
|
1144 |
|
1145 |
|
1146 |
|
1147 |
|
1148 |
|
1149 | function getIteratorFn(maybeIterable) {
|
1150 | var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
|
1151 | if (typeof iteratorFn === 'function') {
|
1152 | return iteratorFn;
|
1153 | }
|
1154 | }
|
1155 |
|
1156 | |
1157 |
|
1158 |
|
1159 |
|
1160 |
|
1161 |
|
1162 |
|
1163 |
|
1164 |
|
1165 |
|
1166 |
|
1167 |
|
1168 |
|
1169 |
|
1170 |
|
1171 |
|
1172 |
|
1173 |
|
1174 |
|
1175 |
|
1176 |
|
1177 |
|
1178 |
|
1179 |
|
1180 |
|
1181 |
|
1182 |
|
1183 |
|
1184 |
|
1185 |
|
1186 |
|
1187 |
|
1188 |
|
1189 |
|
1190 |
|
1191 |
|
1192 |
|
1193 |
|
1194 |
|
1195 |
|
1196 |
|
1197 |
|
1198 |
|
1199 |
|
1200 |
|
1201 |
|
1202 |
|
1203 | var ANONYMOUS = '<<anonymous>>';
|
1204 |
|
1205 |
|
1206 |
|
1207 | var ReactPropTypes = {
|
1208 | array: createPrimitiveTypeChecker('array'),
|
1209 | bigint: createPrimitiveTypeChecker('bigint'),
|
1210 | bool: createPrimitiveTypeChecker('boolean'),
|
1211 | func: createPrimitiveTypeChecker('function'),
|
1212 | number: createPrimitiveTypeChecker('number'),
|
1213 | object: createPrimitiveTypeChecker('object'),
|
1214 | string: createPrimitiveTypeChecker('string'),
|
1215 | symbol: createPrimitiveTypeChecker('symbol'),
|
1216 |
|
1217 | any: createAnyTypeChecker(),
|
1218 | arrayOf: createArrayOfTypeChecker,
|
1219 | element: createElementTypeChecker(),
|
1220 | elementType: createElementTypeTypeChecker(),
|
1221 | instanceOf: createInstanceTypeChecker,
|
1222 | node: createNodeChecker(),
|
1223 | objectOf: createObjectOfTypeChecker,
|
1224 | oneOf: createEnumTypeChecker,
|
1225 | oneOfType: createUnionTypeChecker,
|
1226 | shape: createShapeTypeChecker,
|
1227 | exact: createStrictShapeTypeChecker,
|
1228 | };
|
1229 |
|
1230 | |
1231 |
|
1232 |
|
1233 |
|
1234 |
|
1235 | function is(x, y) {
|
1236 |
|
1237 | if (x === y) {
|
1238 |
|
1239 |
|
1240 | return x !== 0 || 1 / x === 1 / y;
|
1241 | } else {
|
1242 |
|
1243 | return x !== x && y !== y;
|
1244 | }
|
1245 | }
|
1246 |
|
1247 |
|
1248 | |
1249 |
|
1250 |
|
1251 |
|
1252 |
|
1253 |
|
1254 |
|
1255 | function PropTypeError(message, data) {
|
1256 | this.message = message;
|
1257 | this.data = data && typeof data === 'object' ? data: {};
|
1258 | this.stack = '';
|
1259 | }
|
1260 |
|
1261 | PropTypeError.prototype = Error.prototype;
|
1262 |
|
1263 | function createChainableTypeChecker(validate) {
|
1264 | {
|
1265 | var manualPropTypeCallCache = {};
|
1266 | var manualPropTypeWarningCount = 0;
|
1267 | }
|
1268 | function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
|
1269 | componentName = componentName || ANONYMOUS;
|
1270 | propFullName = propFullName || propName;
|
1271 |
|
1272 | if (secret !== ReactPropTypesSecret) {
|
1273 | if (throwOnDirectAccess) {
|
1274 |
|
1275 | var err = new Error(
|
1276 | 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
|
1277 | 'Use `PropTypes.checkPropTypes()` to call them. ' +
|
1278 | 'Read more at http://fb.me/use-check-prop-types'
|
1279 | );
|
1280 | err.name = 'Invariant Violation';
|
1281 | throw err;
|
1282 | } else if (typeof console !== 'undefined') {
|
1283 |
|
1284 | var cacheKey = componentName + ':' + propName;
|
1285 | if (
|
1286 | !manualPropTypeCallCache[cacheKey] &&
|
1287 |
|
1288 | manualPropTypeWarningCount < 3
|
1289 | ) {
|
1290 | printWarning(
|
1291 | 'You are manually calling a React.PropTypes validation ' +
|
1292 | 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
|
1293 | 'and will throw in the standalone `prop-types` package. ' +
|
1294 | 'You may be seeing this warning due to a third-party PropTypes ' +
|
1295 | 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'
|
1296 | );
|
1297 | manualPropTypeCallCache[cacheKey] = true;
|
1298 | manualPropTypeWarningCount++;
|
1299 | }
|
1300 | }
|
1301 | }
|
1302 | if (props[propName] == null) {
|
1303 | if (isRequired) {
|
1304 | if (props[propName] === null) {
|
1305 | return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
|
1306 | }
|
1307 | return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
|
1308 | }
|
1309 | return null;
|
1310 | } else {
|
1311 | return validate(props, propName, componentName, location, propFullName);
|
1312 | }
|
1313 | }
|
1314 |
|
1315 | var chainedCheckType = checkType.bind(null, false);
|
1316 | chainedCheckType.isRequired = checkType.bind(null, true);
|
1317 |
|
1318 | return chainedCheckType;
|
1319 | }
|
1320 |
|
1321 | function createPrimitiveTypeChecker(expectedType) {
|
1322 | function validate(props, propName, componentName, location, propFullName, secret) {
|
1323 | var propValue = props[propName];
|
1324 | var propType = getPropType(propValue);
|
1325 | if (propType !== expectedType) {
|
1326 |
|
1327 |
|
1328 |
|
1329 | var preciseType = getPreciseType(propValue);
|
1330 |
|
1331 | return new PropTypeError(
|
1332 | 'Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'),
|
1333 | {expectedType: expectedType}
|
1334 | );
|
1335 | }
|
1336 | return null;
|
1337 | }
|
1338 | return createChainableTypeChecker(validate);
|
1339 | }
|
1340 |
|
1341 | function createAnyTypeChecker() {
|
1342 | return createChainableTypeChecker(emptyFunctionThatReturnsNull);
|
1343 | }
|
1344 |
|
1345 | function createArrayOfTypeChecker(typeChecker) {
|
1346 | function validate(props, propName, componentName, location, propFullName) {
|
1347 | if (typeof typeChecker !== 'function') {
|
1348 | return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
|
1349 | }
|
1350 | var propValue = props[propName];
|
1351 | if (!Array.isArray(propValue)) {
|
1352 | var propType = getPropType(propValue);
|
1353 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
|
1354 | }
|
1355 | for (var i = 0; i < propValue.length; i++) {
|
1356 | var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret);
|
1357 | if (error instanceof Error) {
|
1358 | return error;
|
1359 | }
|
1360 | }
|
1361 | return null;
|
1362 | }
|
1363 | return createChainableTypeChecker(validate);
|
1364 | }
|
1365 |
|
1366 | function createElementTypeChecker() {
|
1367 | function validate(props, propName, componentName, location, propFullName) {
|
1368 | var propValue = props[propName];
|
1369 | if (!isValidElement(propValue)) {
|
1370 | var propType = getPropType(propValue);
|
1371 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
|
1372 | }
|
1373 | return null;
|
1374 | }
|
1375 | return createChainableTypeChecker(validate);
|
1376 | }
|
1377 |
|
1378 | function createElementTypeTypeChecker() {
|
1379 | function validate(props, propName, componentName, location, propFullName) {
|
1380 | var propValue = props[propName];
|
1381 | if (!ReactIs.isValidElementType(propValue)) {
|
1382 | var propType = getPropType(propValue);
|
1383 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));
|
1384 | }
|
1385 | return null;
|
1386 | }
|
1387 | return createChainableTypeChecker(validate);
|
1388 | }
|
1389 |
|
1390 | function createInstanceTypeChecker(expectedClass) {
|
1391 | function validate(props, propName, componentName, location, propFullName) {
|
1392 | if (!(props[propName] instanceof expectedClass)) {
|
1393 | var expectedClassName = expectedClass.name || ANONYMOUS;
|
1394 | var actualClassName = getClassName(props[propName]);
|
1395 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
|
1396 | }
|
1397 | return null;
|
1398 | }
|
1399 | return createChainableTypeChecker(validate);
|
1400 | }
|
1401 |
|
1402 | function createEnumTypeChecker(expectedValues) {
|
1403 | if (!Array.isArray(expectedValues)) {
|
1404 | {
|
1405 | if (arguments.length > 1) {
|
1406 | printWarning(
|
1407 | 'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' +
|
1408 | 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).'
|
1409 | );
|
1410 | } else {
|
1411 | printWarning('Invalid argument supplied to oneOf, expected an array.');
|
1412 | }
|
1413 | }
|
1414 | return emptyFunctionThatReturnsNull;
|
1415 | }
|
1416 |
|
1417 | function validate(props, propName, componentName, location, propFullName) {
|
1418 | var propValue = props[propName];
|
1419 | for (var i = 0; i < expectedValues.length; i++) {
|
1420 | if (is(propValue, expectedValues[i])) {
|
1421 | return null;
|
1422 | }
|
1423 | }
|
1424 |
|
1425 | var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
|
1426 | var type = getPreciseType(value);
|
1427 | if (type === 'symbol') {
|
1428 | return String(value);
|
1429 | }
|
1430 | return value;
|
1431 | });
|
1432 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
|
1433 | }
|
1434 | return createChainableTypeChecker(validate);
|
1435 | }
|
1436 |
|
1437 | function createObjectOfTypeChecker(typeChecker) {
|
1438 | function validate(props, propName, componentName, location, propFullName) {
|
1439 | if (typeof typeChecker !== 'function') {
|
1440 | return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
|
1441 | }
|
1442 | var propValue = props[propName];
|
1443 | var propType = getPropType(propValue);
|
1444 | if (propType !== 'object') {
|
1445 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
|
1446 | }
|
1447 | for (var key in propValue) {
|
1448 | if (has(propValue, key)) {
|
1449 | var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
|
1450 | if (error instanceof Error) {
|
1451 | return error;
|
1452 | }
|
1453 | }
|
1454 | }
|
1455 | return null;
|
1456 | }
|
1457 | return createChainableTypeChecker(validate);
|
1458 | }
|
1459 |
|
1460 | function createUnionTypeChecker(arrayOfTypeCheckers) {
|
1461 | if (!Array.isArray(arrayOfTypeCheckers)) {
|
1462 | printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') ;
|
1463 | return emptyFunctionThatReturnsNull;
|
1464 | }
|
1465 |
|
1466 | for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
1467 | var checker = arrayOfTypeCheckers[i];
|
1468 | if (typeof checker !== 'function') {
|
1469 | printWarning(
|
1470 | 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
|
1471 | 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'
|
1472 | );
|
1473 | return emptyFunctionThatReturnsNull;
|
1474 | }
|
1475 | }
|
1476 |
|
1477 | function validate(props, propName, componentName, location, propFullName) {
|
1478 | var expectedTypes = [];
|
1479 | for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
1480 | var checker = arrayOfTypeCheckers[i];
|
1481 | var checkerResult = checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret);
|
1482 | if (checkerResult == null) {
|
1483 | return null;
|
1484 | }
|
1485 | if (checkerResult.data && has(checkerResult.data, 'expectedType')) {
|
1486 | expectedTypes.push(checkerResult.data.expectedType);
|
1487 | }
|
1488 | }
|
1489 | var expectedTypesMessage = (expectedTypes.length > 0) ? ', expected one of type [' + expectedTypes.join(', ') + ']': '';
|
1490 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`' + expectedTypesMessage + '.'));
|
1491 | }
|
1492 | return createChainableTypeChecker(validate);
|
1493 | }
|
1494 |
|
1495 | function createNodeChecker() {
|
1496 | function validate(props, propName, componentName, location, propFullName) {
|
1497 | if (!isNode(props[propName])) {
|
1498 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
|
1499 | }
|
1500 | return null;
|
1501 | }
|
1502 | return createChainableTypeChecker(validate);
|
1503 | }
|
1504 |
|
1505 | function invalidValidatorError(componentName, location, propFullName, key, type) {
|
1506 | return new PropTypeError(
|
1507 | (componentName || 'React class') + ': ' + location + ' type `' + propFullName + '.' + key + '` is invalid; ' +
|
1508 | 'it must be a function, usually from the `prop-types` package, but received `' + type + '`.'
|
1509 | );
|
1510 | }
|
1511 |
|
1512 | function createShapeTypeChecker(shapeTypes) {
|
1513 | function validate(props, propName, componentName, location, propFullName) {
|
1514 | var propValue = props[propName];
|
1515 | var propType = getPropType(propValue);
|
1516 | if (propType !== 'object') {
|
1517 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
1518 | }
|
1519 | for (var key in shapeTypes) {
|
1520 | var checker = shapeTypes[key];
|
1521 | if (typeof checker !== 'function') {
|
1522 | return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
|
1523 | }
|
1524 | var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
|
1525 | if (error) {
|
1526 | return error;
|
1527 | }
|
1528 | }
|
1529 | return null;
|
1530 | }
|
1531 | return createChainableTypeChecker(validate);
|
1532 | }
|
1533 |
|
1534 | function createStrictShapeTypeChecker(shapeTypes) {
|
1535 | function validate(props, propName, componentName, location, propFullName) {
|
1536 | var propValue = props[propName];
|
1537 | var propType = getPropType(propValue);
|
1538 | if (propType !== 'object') {
|
1539 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
1540 | }
|
1541 |
|
1542 | var allKeys = assign({}, props[propName], shapeTypes);
|
1543 | for (var key in allKeys) {
|
1544 | var checker = shapeTypes[key];
|
1545 | if (has(shapeTypes, key) && typeof checker !== 'function') {
|
1546 | return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
|
1547 | }
|
1548 | if (!checker) {
|
1549 | return new PropTypeError(
|
1550 | 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
|
1551 | '\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
|
1552 | '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
|
1553 | );
|
1554 | }
|
1555 | var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
|
1556 | if (error) {
|
1557 | return error;
|
1558 | }
|
1559 | }
|
1560 | return null;
|
1561 | }
|
1562 |
|
1563 | return createChainableTypeChecker(validate);
|
1564 | }
|
1565 |
|
1566 | function isNode(propValue) {
|
1567 | switch (typeof propValue) {
|
1568 | case 'number':
|
1569 | case 'string':
|
1570 | case 'undefined':
|
1571 | return true;
|
1572 | case 'boolean':
|
1573 | return !propValue;
|
1574 | case 'object':
|
1575 | if (Array.isArray(propValue)) {
|
1576 | return propValue.every(isNode);
|
1577 | }
|
1578 | if (propValue === null || isValidElement(propValue)) {
|
1579 | return true;
|
1580 | }
|
1581 |
|
1582 | var iteratorFn = getIteratorFn(propValue);
|
1583 | if (iteratorFn) {
|
1584 | var iterator = iteratorFn.call(propValue);
|
1585 | var step;
|
1586 | if (iteratorFn !== propValue.entries) {
|
1587 | while (!(step = iterator.next()).done) {
|
1588 | if (!isNode(step.value)) {
|
1589 | return false;
|
1590 | }
|
1591 | }
|
1592 | } else {
|
1593 |
|
1594 | while (!(step = iterator.next()).done) {
|
1595 | var entry = step.value;
|
1596 | if (entry) {
|
1597 | if (!isNode(entry[1])) {
|
1598 | return false;
|
1599 | }
|
1600 | }
|
1601 | }
|
1602 | }
|
1603 | } else {
|
1604 | return false;
|
1605 | }
|
1606 |
|
1607 | return true;
|
1608 | default:
|
1609 | return false;
|
1610 | }
|
1611 | }
|
1612 |
|
1613 | function isSymbol(propType, propValue) {
|
1614 |
|
1615 | if (propType === 'symbol') {
|
1616 | return true;
|
1617 | }
|
1618 |
|
1619 |
|
1620 | if (!propValue) {
|
1621 | return false;
|
1622 | }
|
1623 |
|
1624 |
|
1625 | if (propValue['@@toStringTag'] === 'Symbol') {
|
1626 | return true;
|
1627 | }
|
1628 |
|
1629 |
|
1630 | if (typeof Symbol === 'function' && propValue instanceof Symbol) {
|
1631 | return true;
|
1632 | }
|
1633 |
|
1634 | return false;
|
1635 | }
|
1636 |
|
1637 |
|
1638 | function getPropType(propValue) {
|
1639 | var propType = typeof propValue;
|
1640 | if (Array.isArray(propValue)) {
|
1641 | return 'array';
|
1642 | }
|
1643 | if (propValue instanceof RegExp) {
|
1644 |
|
1645 |
|
1646 |
|
1647 | return 'object';
|
1648 | }
|
1649 | if (isSymbol(propType, propValue)) {
|
1650 | return 'symbol';
|
1651 | }
|
1652 | return propType;
|
1653 | }
|
1654 |
|
1655 |
|
1656 |
|
1657 | function getPreciseType(propValue) {
|
1658 | if (typeof propValue === 'undefined' || propValue === null) {
|
1659 | return '' + propValue;
|
1660 | }
|
1661 | var propType = getPropType(propValue);
|
1662 | if (propType === 'object') {
|
1663 | if (propValue instanceof Date) {
|
1664 | return 'date';
|
1665 | } else if (propValue instanceof RegExp) {
|
1666 | return 'regexp';
|
1667 | }
|
1668 | }
|
1669 | return propType;
|
1670 | }
|
1671 |
|
1672 |
|
1673 |
|
1674 | function getPostfixForTypeWarning(value) {
|
1675 | var type = getPreciseType(value);
|
1676 | switch (type) {
|
1677 | case 'array':
|
1678 | case 'object':
|
1679 | return 'an ' + type;
|
1680 | case 'boolean':
|
1681 | case 'date':
|
1682 | case 'regexp':
|
1683 | return 'a ' + type;
|
1684 | default:
|
1685 | return type;
|
1686 | }
|
1687 | }
|
1688 |
|
1689 |
|
1690 | function getClassName(propValue) {
|
1691 | if (!propValue.constructor || !propValue.constructor.name) {
|
1692 | return ANONYMOUS;
|
1693 | }
|
1694 | return propValue.constructor.name;
|
1695 | }
|
1696 |
|
1697 | ReactPropTypes.checkPropTypes = checkPropTypes;
|
1698 | ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache;
|
1699 | ReactPropTypes.PropTypes = ReactPropTypes;
|
1700 |
|
1701 | return ReactPropTypes;
|
1702 | };
|
1703 | return factoryWithTypeCheckers;
|
1704 | }
|
1705 |
|
1706 | |
1707 |
|
1708 |
|
1709 |
|
1710 |
|
1711 |
|
1712 |
|
1713 | {
|
1714 | var ReactIs = requireReactIs();
|
1715 |
|
1716 |
|
1717 |
|
1718 | var throwOnDirectAccess = true;
|
1719 | propTypes$b.exports = requireFactoryWithTypeCheckers()(ReactIs.isElement, throwOnDirectAccess);
|
1720 | }
|
1721 |
|
1722 | |
1723 |
|
1724 |
|
1725 |
|
1726 |
|
1727 |
|
1728 |
|
1729 |
|
1730 |
|
1731 |
|
1732 |
|
1733 |
|
1734 |
|
1735 |
|
1736 |
|
1737 |
|
1738 | function useForceUpdate() {
|
1739 |
|
1740 |
|
1741 | const [, dispatch] = React.useReducer(state => !state, false);
|
1742 | return dispatch;
|
1743 | }
|
1744 |
|
1745 | |
1746 |
|
1747 |
|
1748 |
|
1749 |
|
1750 |
|
1751 |
|
1752 |
|
1753 |
|
1754 |
|
1755 |
|
1756 |
|
1757 |
|
1758 |
|
1759 |
|
1760 |
|
1761 |
|
1762 | function usePrevious(value) {
|
1763 | const ref = React.useRef(null);
|
1764 | React.useEffect(() => {
|
1765 | ref.current = value;
|
1766 | });
|
1767 | return ref.current;
|
1768 | }
|
1769 |
|
1770 | var ALIGN_VALUES = ['justify', 'left', 'right'];
|
1771 | var DEFAULT_LABELKEY = 'label';
|
1772 | var SIZES = ['lg', 'sm'];
|
1773 |
|
1774 | |
1775 |
|
1776 |
|
1777 |
|
1778 |
|
1779 |
|
1780 |
|
1781 | var invariant = function(condition, format, a, b, c, d, e, f) {
|
1782 | {
|
1783 | if (format === undefined) {
|
1784 | throw new Error('invariant requires an error message argument');
|
1785 | }
|
1786 | }
|
1787 |
|
1788 | if (!condition) {
|
1789 | var error;
|
1790 | if (format === undefined) {
|
1791 | error = new Error(
|
1792 | 'Minified exception occurred; use the non-minified dev environment ' +
|
1793 | 'for the full error message and additional helpful warnings.'
|
1794 | );
|
1795 | } else {
|
1796 | var args = [a, b, c, d, e, f];
|
1797 | var argIndex = 0;
|
1798 | error = new Error(
|
1799 | format.replace(/%s/g, function() { return args[argIndex++]; })
|
1800 | );
|
1801 | error.name = 'Invariant Violation';
|
1802 | }
|
1803 |
|
1804 | error.framesToPop = 1;
|
1805 | throw error;
|
1806 | }
|
1807 | };
|
1808 |
|
1809 | var invariant_1 = invariant;
|
1810 |
|
1811 | function getStringLabelKey(labelKey) {
|
1812 | return typeof labelKey === 'string' ? labelKey : DEFAULT_LABELKEY;
|
1813 | }
|
1814 |
|
1815 | |
1816 |
|
1817 |
|
1818 | function hasOwnProperty(obj, prop) {
|
1819 | return Object.prototype.hasOwnProperty.call(obj, prop);
|
1820 | }
|
1821 |
|
1822 | var idCounter = 0;
|
1823 |
|
1824 |
|
1825 | function isFunction(value) {
|
1826 | return typeof value === 'function';
|
1827 | }
|
1828 | function isString(value) {
|
1829 | return typeof value === 'string';
|
1830 | }
|
1831 | function noop$1() {}
|
1832 | function pick(obj, keys) {
|
1833 |
|
1834 | var result = {};
|
1835 | keys.forEach(function (key) {
|
1836 | result[key] = obj[key];
|
1837 | });
|
1838 | return result;
|
1839 | }
|
1840 | function uniqueId(prefix) {
|
1841 | idCounter += 1;
|
1842 | return (prefix == null ? '' : String(prefix)) + idCounter;
|
1843 | }
|
1844 |
|
1845 | |
1846 |
|
1847 |
|
1848 |
|
1849 |
|
1850 | function getOptionLabel(option, labelKey) {
|
1851 |
|
1852 | if (!isString(option) && (hasOwnProperty(option, 'paginationOption') || hasOwnProperty(option, 'customOption'))) {
|
1853 | return option[getStringLabelKey(labelKey)];
|
1854 | }
|
1855 | var optionLabel;
|
1856 | if (isFunction(labelKey)) {
|
1857 | optionLabel = labelKey(option);
|
1858 | } else if (isString(option)) {
|
1859 | optionLabel = option;
|
1860 | } else {
|
1861 |
|
1862 | optionLabel = option[labelKey];
|
1863 | }
|
1864 | !isString(optionLabel) ? invariant_1(false, 'One or more options does not have a valid label string. Check the ' + '`labelKey` prop to ensure that it matches the correct option key and ' + 'provides a string for filtering and display.') : void 0;
|
1865 | return optionLabel;
|
1866 | }
|
1867 |
|
1868 | function addCustomOption(results, props) {
|
1869 | var allowNew = props.allowNew,
|
1870 | labelKey = props.labelKey,
|
1871 | text = props.text;
|
1872 | if (!allowNew || !text.trim()) {
|
1873 | return false;
|
1874 | }
|
1875 |
|
1876 |
|
1877 |
|
1878 | if (isFunction(allowNew)) {
|
1879 | return allowNew(results, props);
|
1880 | }
|
1881 |
|
1882 |
|
1883 |
|
1884 | return !results.some(function (o) {
|
1885 | return getOptionLabel(o, labelKey) === text;
|
1886 | });
|
1887 | }
|
1888 |
|
1889 |
|
1890 |
|
1891 |
|
1892 |
|
1893 | var fastDeepEqual = function equal(a, b) {
|
1894 | if (a === b) return true;
|
1895 |
|
1896 | if (a && b && typeof a == 'object' && typeof b == 'object') {
|
1897 | if (a.constructor !== b.constructor) return false;
|
1898 |
|
1899 | var length, i, keys;
|
1900 | if (Array.isArray(a)) {
|
1901 | length = a.length;
|
1902 | if (length != b.length) return false;
|
1903 | for (i = length; i-- !== 0;)
|
1904 | if (!equal(a[i], b[i])) return false;
|
1905 | return true;
|
1906 | }
|
1907 |
|
1908 |
|
1909 |
|
1910 | if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
|
1911 | if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
|
1912 | if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
|
1913 |
|
1914 | keys = Object.keys(a);
|
1915 | length = keys.length;
|
1916 | if (length !== Object.keys(b).length) return false;
|
1917 |
|
1918 | for (i = length; i-- !== 0;)
|
1919 | if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
|
1920 |
|
1921 | for (i = length; i-- !== 0;) {
|
1922 | var key = keys[i];
|
1923 |
|
1924 | if (!equal(a[key], b[key])) return false;
|
1925 | }
|
1926 |
|
1927 | return true;
|
1928 | }
|
1929 |
|
1930 |
|
1931 | return a!==a && b!==b;
|
1932 | };
|
1933 |
|
1934 | function getOptionProperty(option, key) {
|
1935 | if (isString(option)) {
|
1936 | return undefined;
|
1937 | }
|
1938 | return option[key];
|
1939 | }
|
1940 |
|
1941 |
|
1942 |
|
1943 | var map = [{
|
1944 | base: 'A',
|
1945 | letters: "A\u24B6\uFF21\xC0\xC1\xC2\u1EA6\u1EA4\u1EAA\u1EA8\xC3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\xC4\u01DE\u1EA2\xC5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F"
|
1946 | }, {
|
1947 | base: 'AA',
|
1948 | letters: "\uA732"
|
1949 | }, {
|
1950 | base: 'AE',
|
1951 | letters: "\xC6\u01FC\u01E2"
|
1952 | }, {
|
1953 | base: 'AO',
|
1954 | letters: "\uA734"
|
1955 | }, {
|
1956 | base: 'AU',
|
1957 | letters: "\uA736"
|
1958 | }, {
|
1959 | base: 'AV',
|
1960 | letters: "\uA738\uA73A"
|
1961 | }, {
|
1962 | base: 'AY',
|
1963 | letters: "\uA73C"
|
1964 | }, {
|
1965 | base: 'B',
|
1966 | letters: "B\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181"
|
1967 | }, {
|
1968 | base: 'C',
|
1969 | letters: "C\u24B8\uFF23\u0106\u0108\u010A\u010C\xC7\u1E08\u0187\u023B\uA73E"
|
1970 | }, {
|
1971 | base: 'D',
|
1972 | letters: "D\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018B\u018A\u0189\uA779\xD0"
|
1973 | }, {
|
1974 | base: 'DZ',
|
1975 | letters: "\u01F1\u01C4"
|
1976 | }, {
|
1977 | base: 'Dz',
|
1978 | letters: "\u01F2\u01C5"
|
1979 | }, {
|
1980 | base: 'E',
|
1981 | letters: "E\u24BA\uFF25\xC8\xC9\xCA\u1EC0\u1EBE\u1EC4\u1EC2\u1EBC\u0112\u1E14\u1E16\u0114\u0116\xCB\u1EBA\u011A\u0204\u0206\u1EB8\u1EC6\u0228\u1E1C\u0118\u1E18\u1E1A\u0190\u018E"
|
1982 | }, {
|
1983 | base: 'F',
|
1984 | letters: "F\u24BB\uFF26\u1E1E\u0191\uA77B"
|
1985 | }, {
|
1986 | base: 'G',
|
1987 | letters: "G\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E"
|
1988 | }, {
|
1989 | base: 'H',
|
1990 | letters: "H\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D"
|
1991 | }, {
|
1992 | base: 'I',
|
1993 | letters: "I\u24BE\uFF29\xCC\xCD\xCE\u0128\u012A\u012C\u0130\xCF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197"
|
1994 | }, {
|
1995 | base: 'J',
|
1996 | letters: "J\u24BF\uFF2A\u0134\u0248"
|
1997 | }, {
|
1998 | base: 'K',
|
1999 | letters: "K\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2"
|
2000 | }, {
|
2001 | base: 'L',
|
2002 | letters: "L\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780"
|
2003 | }, {
|
2004 | base: 'LJ',
|
2005 | letters: "\u01C7"
|
2006 | }, {
|
2007 | base: 'Lj',
|
2008 | letters: "\u01C8"
|
2009 | }, {
|
2010 | base: 'M',
|
2011 | letters: "M\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C"
|
2012 | }, {
|
2013 | base: 'N',
|
2014 | letters: "N\u24C3\uFF2E\u01F8\u0143\xD1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u0220\u019D\uA790\uA7A4"
|
2015 | }, {
|
2016 | base: 'NJ',
|
2017 | letters: "\u01CA"
|
2018 | }, {
|
2019 | base: 'Nj',
|
2020 | letters: "\u01CB"
|
2021 | }, {
|
2022 | base: 'O',
|
2023 | letters: "O\u24C4\uFF2F\xD2\xD3\xD4\u1ED2\u1ED0\u1ED6\u1ED4\xD5\u1E4C\u022C\u1E4E\u014C\u1E50\u1E52\u014E\u022E\u0230\xD6\u022A\u1ECE\u0150\u01D1\u020C\u020E\u01A0\u1EDC\u1EDA\u1EE0\u1EDE\u1EE2\u1ECC\u1ED8\u01EA\u01EC\xD8\u01FE\u0186\u019F\uA74A\uA74C"
|
2024 | }, {
|
2025 | base: 'OI',
|
2026 | letters: "\u01A2"
|
2027 | }, {
|
2028 | base: 'OO',
|
2029 | letters: "\uA74E"
|
2030 | }, {
|
2031 | base: 'OU',
|
2032 | letters: "\u0222"
|
2033 | }, {
|
2034 | base: 'OE',
|
2035 | letters: "\x8C\u0152"
|
2036 | }, {
|
2037 | base: 'oe',
|
2038 | letters: "\x9C\u0153"
|
2039 | }, {
|
2040 | base: 'P',
|
2041 | letters: "P\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754"
|
2042 | }, {
|
2043 | base: 'Q',
|
2044 | letters: "Q\u24C6\uFF31\uA756\uA758\u024A"
|
2045 | }, {
|
2046 | base: 'R',
|
2047 | letters: "R\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782"
|
2048 | }, {
|
2049 | base: 'S',
|
2050 | letters: "S\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784"
|
2051 | }, {
|
2052 | base: 'T',
|
2053 | letters: "T\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786"
|
2054 | }, {
|
2055 | base: 'TZ',
|
2056 | letters: "\uA728"
|
2057 | }, {
|
2058 | base: 'U',
|
2059 | letters: "U\u24CA\uFF35\xD9\xDA\xDB\u0168\u1E78\u016A\u1E7A\u016C\xDC\u01DB\u01D7\u01D5\u01D9\u1EE6\u016E\u0170\u01D3\u0214\u0216\u01AF\u1EEA\u1EE8\u1EEE\u1EEC\u1EF0\u1EE4\u1E72\u0172\u1E76\u1E74\u0244"
|
2060 | }, {
|
2061 | base: 'V',
|
2062 | letters: "V\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245"
|
2063 | }, {
|
2064 | base: 'VY',
|
2065 | letters: "\uA760"
|
2066 | }, {
|
2067 | base: 'W',
|
2068 | letters: "W\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72"
|
2069 | }, {
|
2070 | base: 'X',
|
2071 | letters: "X\u24CD\uFF38\u1E8A\u1E8C"
|
2072 | }, {
|
2073 | base: 'Y',
|
2074 | letters: "Y\u24CE\uFF39\u1EF2\xDD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE"
|
2075 | }, {
|
2076 | base: 'Z',
|
2077 | letters: "Z\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762"
|
2078 | }, {
|
2079 | base: 'a',
|
2080 | letters: "a\u24D0\uFF41\u1E9A\xE0\xE1\xE2\u1EA7\u1EA5\u1EAB\u1EA9\xE3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\xE4\u01DF\u1EA3\xE5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250"
|
2081 | }, {
|
2082 | base: 'aa',
|
2083 | letters: "\uA733"
|
2084 | }, {
|
2085 | base: 'ae',
|
2086 | letters: "\xE6\u01FD\u01E3"
|
2087 | }, {
|
2088 | base: 'ao',
|
2089 | letters: "\uA735"
|
2090 | }, {
|
2091 | base: 'au',
|
2092 | letters: "\uA737"
|
2093 | }, {
|
2094 | base: 'av',
|
2095 | letters: "\uA739\uA73B"
|
2096 | }, {
|
2097 | base: 'ay',
|
2098 | letters: "\uA73D"
|
2099 | }, {
|
2100 | base: 'b',
|
2101 | letters: "b\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253"
|
2102 | }, {
|
2103 | base: 'c',
|
2104 | letters: "c\u24D2\uFF43\u0107\u0109\u010B\u010D\xE7\u1E09\u0188\u023C\uA73F\u2184"
|
2105 | }, {
|
2106 | base: 'd',
|
2107 | letters: "d\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\uA77A"
|
2108 | }, {
|
2109 | base: 'dz',
|
2110 | letters: "\u01F3\u01C6"
|
2111 | }, {
|
2112 | base: 'e',
|
2113 | letters: "e\u24D4\uFF45\xE8\xE9\xEA\u1EC1\u1EBF\u1EC5\u1EC3\u1EBD\u0113\u1E15\u1E17\u0115\u0117\xEB\u1EBB\u011B\u0205\u0207\u1EB9\u1EC7\u0229\u1E1D\u0119\u1E19\u1E1B\u0247\u025B\u01DD"
|
2114 | }, {
|
2115 | base: 'f',
|
2116 | letters: "f\u24D5\uFF46\u1E1F\u0192\uA77C"
|
2117 | }, {
|
2118 | base: 'g',
|
2119 | letters: "g\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F"
|
2120 | }, {
|
2121 | base: 'h',
|
2122 | letters: "h\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265"
|
2123 | }, {
|
2124 | base: 'hv',
|
2125 | letters: "\u0195"
|
2126 | }, {
|
2127 | base: 'i',
|
2128 | letters: "i\u24D8\uFF49\xEC\xED\xEE\u0129\u012B\u012D\xEF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131"
|
2129 | }, {
|
2130 | base: 'j',
|
2131 | letters: "j\u24D9\uFF4A\u0135\u01F0\u0249"
|
2132 | }, {
|
2133 | base: 'k',
|
2134 | letters: "k\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3"
|
2135 | }, {
|
2136 | base: 'l',
|
2137 | letters: "l\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747"
|
2138 | }, {
|
2139 | base: 'lj',
|
2140 | letters: "\u01C9"
|
2141 | }, {
|
2142 | base: 'm',
|
2143 | letters: "m\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F"
|
2144 | }, {
|
2145 | base: 'n',
|
2146 | letters: "n\u24DD\uFF4E\u01F9\u0144\xF1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5"
|
2147 | }, {
|
2148 | base: 'nj',
|
2149 | letters: "\u01CC"
|
2150 | }, {
|
2151 | base: 'o',
|
2152 | letters: "o\u24DE\uFF4F\xF2\xF3\xF4\u1ED3\u1ED1\u1ED7\u1ED5\xF5\u1E4D\u022D\u1E4F\u014D\u1E51\u1E53\u014F\u022F\u0231\xF6\u022B\u1ECF\u0151\u01D2\u020D\u020F\u01A1\u1EDD\u1EDB\u1EE1\u1EDF\u1EE3\u1ECD\u1ED9\u01EB\u01ED\xF8\u01FF\u0254\uA74B\uA74D\u0275"
|
2153 | }, {
|
2154 | base: 'oi',
|
2155 | letters: "\u01A3"
|
2156 | }, {
|
2157 | base: 'ou',
|
2158 | letters: "\u0223"
|
2159 | }, {
|
2160 | base: 'oo',
|
2161 | letters: "\uA74F"
|
2162 | }, {
|
2163 | base: 'p',
|
2164 | letters: "p\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755"
|
2165 | }, {
|
2166 | base: 'q',
|
2167 | letters: "q\u24E0\uFF51\u024B\uA757\uA759"
|
2168 | }, {
|
2169 | base: 'r',
|
2170 | letters: "r\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783"
|
2171 | }, {
|
2172 | base: 's',
|
2173 | letters: "s\u24E2\uFF53\xDF\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B"
|
2174 | }, {
|
2175 | base: 't',
|
2176 | letters: "t\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787"
|
2177 | }, {
|
2178 | base: 'tz',
|
2179 | letters: "\uA729"
|
2180 | }, {
|
2181 | base: 'u',
|
2182 | letters: "u\u24E4\uFF55\xF9\xFA\xFB\u0169\u1E79\u016B\u1E7B\u016D\xFC\u01DC\u01D8\u01D6\u01DA\u1EE7\u016F\u0171\u01D4\u0215\u0217\u01B0\u1EEB\u1EE9\u1EEF\u1EED\u1EF1\u1EE5\u1E73\u0173\u1E77\u1E75\u0289"
|
2183 | }, {
|
2184 | base: 'v',
|
2185 | letters: "v\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C"
|
2186 | }, {
|
2187 | base: 'vy',
|
2188 | letters: "\uA761"
|
2189 | }, {
|
2190 | base: 'w',
|
2191 | letters: "w\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73"
|
2192 | }, {
|
2193 | base: 'x',
|
2194 | letters: "x\u24E7\uFF58\u1E8B\u1E8D"
|
2195 | }, {
|
2196 | base: 'y',
|
2197 | letters: "y\u24E8\uFF59\u1EF3\xFD\u0177\u1EF9\u0233\u1E8F\xFF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF"
|
2198 | }, {
|
2199 | base: 'z',
|
2200 | letters: "z\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763"
|
2201 | }].reduce(function (acc, _ref) {
|
2202 | var base = _ref.base,
|
2203 | letters = _ref.letters;
|
2204 | letters.split('').forEach(function (letter) {
|
2205 | acc[letter] = base;
|
2206 | });
|
2207 | return acc;
|
2208 | }, {});
|
2209 |
|
2210 |
|
2211 | var latin = "\u0300-\u036F";
|
2212 | var japanese = "\u3099\u309A";
|
2213 | function stripDiacritics(str) {
|
2214 | return str.normalize('NFD')
|
2215 |
|
2216 | .replace(new RegExp("[".concat(latin).concat(japanese, "]"), 'g'), '')
|
2217 | .replace(/[^\u0000-\u007E]/g, function (a) {
|
2218 | return map[a] || a;
|
2219 | });
|
2220 | }
|
2221 |
|
2222 | |
2223 |
|
2224 |
|
2225 |
|
2226 |
|
2227 |
|
2228 |
|
2229 | var warning = function() {};
|
2230 |
|
2231 | {
|
2232 | var printWarning = function printWarning(format, args) {
|
2233 | var len = arguments.length;
|
2234 | args = new Array(len > 1 ? len - 1 : 0);
|
2235 | for (var key = 1; key < len; key++) {
|
2236 | args[key - 1] = arguments[key];
|
2237 | }
|
2238 | var argIndex = 0;
|
2239 | var message = 'Warning: ' +
|
2240 | format.replace(/%s/g, function() {
|
2241 | return args[argIndex++];
|
2242 | });
|
2243 | if (typeof console !== 'undefined') {
|
2244 | console.error(message);
|
2245 | }
|
2246 | try {
|
2247 |
|
2248 |
|
2249 |
|
2250 | throw new Error(message);
|
2251 | } catch (x) {}
|
2252 | };
|
2253 |
|
2254 | warning = function(condition, format, args) {
|
2255 | var len = arguments.length;
|
2256 | args = new Array(len > 2 ? len - 2 : 0);
|
2257 | for (var key = 2; key < len; key++) {
|
2258 | args[key - 2] = arguments[key];
|
2259 | }
|
2260 | if (format === undefined) {
|
2261 | throw new Error(
|
2262 | '`warning(condition, format, ...args)` requires a warning ' +
|
2263 | 'message argument'
|
2264 | );
|
2265 | }
|
2266 | if (!condition) {
|
2267 | printWarning.apply(null, [format].concat(args));
|
2268 | }
|
2269 | };
|
2270 | }
|
2271 |
|
2272 | var warning_1 = warning;
|
2273 |
|
2274 | var warned = {};
|
2275 |
|
2276 | |
2277 |
|
2278 |
|
2279 | function warn(falseToWarn, message) {
|
2280 |
|
2281 | if (!falseToWarn && message.indexOf('deprecated') !== -1) {
|
2282 | if (warned[message]) {
|
2283 | return;
|
2284 | }
|
2285 | warned[message] = true;
|
2286 | }
|
2287 | for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
2288 | args[_key - 2] = arguments[_key];
|
2289 | }
|
2290 | warning_1.apply(void 0, [falseToWarn, "[react-bootstrap-typeahead] ".concat(message)].concat(args));
|
2291 | }
|
2292 |
|
2293 | function isMatch(input, string, props) {
|
2294 | var searchStr = input;
|
2295 | var str = string;
|
2296 | if (!props.caseSensitive) {
|
2297 | searchStr = searchStr.toLowerCase();
|
2298 | str = str.toLowerCase();
|
2299 | }
|
2300 | if (props.ignoreDiacritics) {
|
2301 | searchStr = stripDiacritics(searchStr);
|
2302 | str = stripDiacritics(str);
|
2303 | }
|
2304 | return str.indexOf(searchStr) !== -1;
|
2305 | }
|
2306 |
|
2307 | |
2308 |
|
2309 |
|
2310 | function defaultFilterBy(option, props) {
|
2311 | var filterBy = props.filterBy,
|
2312 | labelKey = props.labelKey,
|
2313 | multiple = props.multiple,
|
2314 | selected = props.selected,
|
2315 | text = props.text;
|
2316 |
|
2317 |
|
2318 | if (multiple && selected.some(function (o) {
|
2319 | return fastDeepEqual(o, option);
|
2320 | })) {
|
2321 | return false;
|
2322 | }
|
2323 | if (isFunction(labelKey)) {
|
2324 | return isMatch(text, labelKey(option), props);
|
2325 | }
|
2326 | var fields = filterBy.slice();
|
2327 | if (isString(labelKey)) {
|
2328 |
|
2329 | if (fields.indexOf(labelKey) === -1) {
|
2330 | fields.unshift(labelKey);
|
2331 | }
|
2332 | }
|
2333 | if (isString(option)) {
|
2334 | warn(fields.length <= 1, 'You cannot filter by properties when `option` is a string.');
|
2335 | return isMatch(text, option, props);
|
2336 | }
|
2337 | return fields.some(function (field) {
|
2338 | var value = getOptionProperty(option, field);
|
2339 | if (!isString(value)) {
|
2340 | warn(false, 'Fields passed to `filterBy` should have string values. Value will ' + 'be converted to a string; results may be unexpected.');
|
2341 | value = String(value);
|
2342 | }
|
2343 | return isMatch(text, value, props);
|
2344 | });
|
2345 | }
|
2346 |
|
2347 | |
2348 |
|
2349 |
|
2350 |
|
2351 |
|
2352 |
|
2353 |
|
2354 | function isSelectable(inputNode) {
|
2355 | return inputNode.selectionStart != null;
|
2356 | }
|
2357 |
|
2358 | function defaultSelectHint(e, selectHint) {
|
2359 | var shouldSelectHint = false;
|
2360 | if (e.key === 'ArrowRight') {
|
2361 |
|
2362 |
|
2363 |
|
2364 | shouldSelectHint = isSelectable(e.currentTarget) ? e.currentTarget.selectionStart === e.currentTarget.value.length : true;
|
2365 | }
|
2366 | if (e.key === 'Tab') {
|
2367 |
|
2368 | e.preventDefault();
|
2369 | shouldSelectHint = true;
|
2370 | }
|
2371 | return selectHint ? selectHint(shouldSelectHint, e) : shouldSelectHint;
|
2372 | }
|
2373 |
|
2374 |
|
2375 | function getDisplayName(Component) {
|
2376 | return Component.displayName || Component.name || 'Component';
|
2377 | }
|
2378 |
|
2379 | var CASE_INSENSITIVE = 'i';
|
2380 | var COMBINING_MARKS = /[\u0300-\u036F]/;
|
2381 |
|
2382 | function escapeStringRegexp(str) {
|
2383 | !(typeof str === 'string') ? invariant_1(false, '`escapeStringRegexp` expected a string.') : void 0;
|
2384 |
|
2385 |
|
2386 |
|
2387 |
|
2388 |
|
2389 | return str.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d');
|
2390 | }
|
2391 | function getMatchBounds(subject, str) {
|
2392 | var search = new RegExp(escapeStringRegexp(stripDiacritics(str)), CASE_INSENSITIVE);
|
2393 | var matches = search.exec(stripDiacritics(subject));
|
2394 | if (!matches) {
|
2395 | return null;
|
2396 | }
|
2397 | var start = matches.index;
|
2398 | var matchLength = matches[0].length;
|
2399 |
|
2400 |
|
2401 | if (COMBINING_MARKS.test(subject)) {
|
2402 |
|
2403 |
|
2404 | for (var ii = 0; ii <= start; ii++) {
|
2405 | if (COMBINING_MARKS.test(subject[ii])) {
|
2406 | start += 1;
|
2407 | }
|
2408 | }
|
2409 |
|
2410 |
|
2411 |
|
2412 | for (var _ii = start; _ii <= start + matchLength; _ii++) {
|
2413 | if (COMBINING_MARKS.test(subject[_ii])) {
|
2414 | matchLength += 1;
|
2415 | }
|
2416 | }
|
2417 | }
|
2418 | return {
|
2419 | end: start + matchLength,
|
2420 | start: start
|
2421 | };
|
2422 | }
|
2423 |
|
2424 | function getHintText(_ref) {
|
2425 | var activeIndex = _ref.activeIndex,
|
2426 | initialItem = _ref.initialItem,
|
2427 | isFocused = _ref.isFocused,
|
2428 | isMenuShown = _ref.isMenuShown,
|
2429 | labelKey = _ref.labelKey,
|
2430 | multiple = _ref.multiple,
|
2431 | selected = _ref.selected,
|
2432 | text = _ref.text;
|
2433 |
|
2434 | if (
|
2435 |
|
2436 | !text ||
|
2437 |
|
2438 | !isFocused ||
|
2439 |
|
2440 | !isMenuShown ||
|
2441 |
|
2442 | !initialItem ||
|
2443 |
|
2444 | !isString(initialItem) && hasOwnProperty(initialItem, 'customOption') ||
|
2445 |
|
2446 | activeIndex > -1 ||
|
2447 |
|
2448 | !!selected.length && !multiple) {
|
2449 | return '';
|
2450 | }
|
2451 | var initialItemStr = getOptionLabel(initialItem, labelKey);
|
2452 | var bounds = getMatchBounds(initialItemStr.toLowerCase(), text.toLowerCase());
|
2453 | if (!(bounds && bounds.start === 0)) {
|
2454 | return '';
|
2455 | }
|
2456 |
|
2457 |
|
2458 |
|
2459 | return text + initialItemStr.slice(bounds.end, initialItemStr.length);
|
2460 | }
|
2461 |
|
2462 | var classnames = {exports: {}};
|
2463 |
|
2464 | |
2465 |
|
2466 |
|
2467 |
|
2468 |
|
2469 |
|
2470 | (function (module) {
|
2471 |
|
2472 |
|
2473 | (function () {
|
2474 |
|
2475 | var hasOwn = {}.hasOwnProperty;
|
2476 |
|
2477 | function classNames() {
|
2478 | var classes = [];
|
2479 |
|
2480 | for (var i = 0; i < arguments.length; i++) {
|
2481 | var arg = arguments[i];
|
2482 | if (!arg) continue;
|
2483 |
|
2484 | var argType = typeof arg;
|
2485 |
|
2486 | if (argType === 'string' || argType === 'number') {
|
2487 | classes.push(arg);
|
2488 | } else if (Array.isArray(arg)) {
|
2489 | if (arg.length) {
|
2490 | var inner = classNames.apply(null, arg);
|
2491 | if (inner) {
|
2492 | classes.push(inner);
|
2493 | }
|
2494 | }
|
2495 | } else if (argType === 'object') {
|
2496 | if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
|
2497 | classes.push(arg.toString());
|
2498 | continue;
|
2499 | }
|
2500 |
|
2501 | for (var key in arg) {
|
2502 | if (hasOwn.call(arg, key) && arg[key]) {
|
2503 | classes.push(key);
|
2504 | }
|
2505 | }
|
2506 | }
|
2507 | }
|
2508 |
|
2509 | return classes.join(' ');
|
2510 | }
|
2511 |
|
2512 | if (module.exports) {
|
2513 | classNames.default = classNames;
|
2514 | module.exports = classNames;
|
2515 | } else {
|
2516 | window.classNames = classNames;
|
2517 | }
|
2518 | }());
|
2519 | } (classnames));
|
2520 |
|
2521 | var cx = classnames.exports;
|
2522 |
|
2523 | function getMenuItemId() {
|
2524 | var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
2525 | var position = arguments.length > 1 ? arguments[1] : undefined;
|
2526 | return "".concat(id, "-item-").concat(position);
|
2527 | }
|
2528 |
|
2529 | var _excluded$e = ["activeIndex", "id", "isFocused", "isMenuShown", "multiple", "onClick", "onFocus", "placeholder"];
|
2530 | var getInputProps = function getInputProps(_ref) {
|
2531 | var activeIndex = _ref.activeIndex,
|
2532 | id = _ref.id,
|
2533 | isFocused = _ref.isFocused,
|
2534 | isMenuShown = _ref.isMenuShown,
|
2535 | multiple = _ref.multiple,
|
2536 | onClick = _ref.onClick,
|
2537 | onFocus = _ref.onFocus,
|
2538 | placeholder = _ref.placeholder,
|
2539 | props = _objectWithoutProperties(_ref, _excluded$e);
|
2540 | return function () {
|
2541 | var _cx;
|
2542 | var inputProps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
2543 | var className = hasOwnProperty(inputProps, 'className') ? String(inputProps.className) : undefined;
|
2544 | return _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
2545 |
|
2546 | autoComplete: 'off',
|
2547 | placeholder: placeholder,
|
2548 | type: 'text'
|
2549 | }, inputProps), props), {}, {
|
2550 | 'aria-activedescendant': activeIndex >= 0 ? getMenuItemId(id, activeIndex) : undefined,
|
2551 | 'aria-autocomplete': 'both',
|
2552 | 'aria-expanded': isMenuShown,
|
2553 | 'aria-haspopup': 'listbox',
|
2554 | 'aria-multiselectable': multiple || undefined,
|
2555 | 'aria-owns': isMenuShown ? id : undefined,
|
2556 | className: cx((_cx = {}, _defineProperty(_cx, className || '', !multiple), _defineProperty(_cx, "focus", isFocused), _cx))
|
2557 | }, multiple && {
|
2558 | inputClassName: className
|
2559 | }), {}, {
|
2560 | onClick: onClick,
|
2561 | onFocus: onFocus,
|
2562 | role: 'combobox'
|
2563 | });
|
2564 | };
|
2565 | };
|
2566 |
|
2567 | function getInputText(props) {
|
2568 | var activeItem = props.activeItem,
|
2569 | labelKey = props.labelKey,
|
2570 | multiple = props.multiple,
|
2571 | selected = props.selected,
|
2572 | text = props.text;
|
2573 | if (activeItem) {
|
2574 |
|
2575 | return getOptionLabel(activeItem, labelKey);
|
2576 | }
|
2577 | if (!multiple && selected.length && selected[0]) {
|
2578 | return getOptionLabel(selected[0], labelKey);
|
2579 | }
|
2580 | return text;
|
2581 | }
|
2582 |
|
2583 | function getIsOnlyResult(props) {
|
2584 | var allowNew = props.allowNew,
|
2585 | highlightOnlyResult = props.highlightOnlyResult,
|
2586 | results = props.results;
|
2587 | if (!highlightOnlyResult || allowNew) {
|
2588 | return false;
|
2589 | }
|
2590 | return results.length === 1 && !getOptionProperty(results[0], 'disabled');
|
2591 | }
|
2592 |
|
2593 | |
2594 |
|
2595 |
|
2596 | function getTruncatedOptions(options, maxResults) {
|
2597 | if (!maxResults || maxResults >= options.length) {
|
2598 | return options;
|
2599 | }
|
2600 | return options.slice(0, maxResults);
|
2601 | }
|
2602 |
|
2603 | function isDisabledOption(index, items) {
|
2604 | var option = items[index];
|
2605 | return !!option && !!getOptionProperty(option, 'disabled');
|
2606 | }
|
2607 | function skipDisabledOptions(currentIndex, key, items) {
|
2608 | var newIndex = currentIndex;
|
2609 | while (isDisabledOption(newIndex, items)) {
|
2610 | newIndex += key === 'ArrowUp' ? -1 : 1;
|
2611 | }
|
2612 | return newIndex;
|
2613 | }
|
2614 | function getUpdatedActiveIndex(currentIndex, key, items) {
|
2615 | var newIndex = currentIndex;
|
2616 |
|
2617 |
|
2618 | newIndex += key === 'ArrowUp' ? -1 : 1;
|
2619 |
|
2620 |
|
2621 | newIndex = skipDisabledOptions(newIndex, key, items);
|
2622 |
|
2623 |
|
2624 | if (newIndex === items.length) {
|
2625 | newIndex = -1;
|
2626 | } else if (newIndex === -2) {
|
2627 | newIndex = items.length - 1;
|
2628 |
|
2629 |
|
2630 | newIndex = skipDisabledOptions(newIndex, key, items);
|
2631 | }
|
2632 | return newIndex;
|
2633 | }
|
2634 |
|
2635 | function isShown(_ref) {
|
2636 | var open = _ref.open,
|
2637 | minLength = _ref.minLength,
|
2638 | showMenu = _ref.showMenu,
|
2639 | text = _ref.text;
|
2640 |
|
2641 | if (open || open === false) {
|
2642 | return open;
|
2643 | }
|
2644 | if (text.length < minLength) {
|
2645 | return false;
|
2646 | }
|
2647 | return showMenu;
|
2648 | }
|
2649 |
|
2650 | |
2651 |
|
2652 |
|
2653 |
|
2654 | function preventInputBlur(e) {
|
2655 | e.preventDefault();
|
2656 | }
|
2657 |
|
2658 | function isSizeLarge(size) {
|
2659 | return size === 'lg';
|
2660 | }
|
2661 | function isSizeSmall(size) {
|
2662 | return size === 'sm';
|
2663 | }
|
2664 |
|
2665 | var _excluded$d = ["className", "isInvalid", "isValid", "size"];
|
2666 | |
2667 |
|
2668 |
|
2669 |
|
2670 | function propsWithBsClassName(_ref) {
|
2671 | var className = _ref.className,
|
2672 | isInvalid = _ref.isInvalid,
|
2673 | isValid = _ref.isValid,
|
2674 | size = _ref.size,
|
2675 | props = _objectWithoutProperties(_ref, _excluded$d);
|
2676 | return _objectSpread2(_objectSpread2({}, props), {}, {
|
2677 | className: cx('form-control', 'rbt-input', {
|
2678 | 'form-control-lg': isSizeLarge(size),
|
2679 | 'form-control-sm': isSizeSmall(size),
|
2680 | 'is-invalid': isInvalid,
|
2681 | 'is-valid': isValid
|
2682 | }, className)
|
2683 | });
|
2684 | }
|
2685 |
|
2686 | function validateSelectedPropChange(prevSelected, selected) {
|
2687 | var uncontrolledToControlled = !prevSelected && selected;
|
2688 | var controlledToUncontrolled = prevSelected && !selected;
|
2689 | var from, to, precedent;
|
2690 | if (uncontrolledToControlled) {
|
2691 | from = 'uncontrolled';
|
2692 | to = 'controlled';
|
2693 | precedent = 'an';
|
2694 | } else {
|
2695 | from = 'controlled';
|
2696 | to = 'uncontrolled';
|
2697 | precedent = 'a';
|
2698 | }
|
2699 | var message = "You are changing ".concat(precedent, " ").concat(from, " typeahead to be ").concat(to, ". ") + "Input elements should not switch from ".concat(from, " to ").concat(to, " (or vice versa). ") + 'Decide between using a controlled or uncontrolled element for the ' + 'lifetime of the component.';
|
2700 | warn(!(uncontrolledToControlled || controlledToUncontrolled), message);
|
2701 | }
|
2702 |
|
2703 | var INPUT_PROPS_BLACKLIST = [{
|
2704 | alt: 'onBlur',
|
2705 | prop: 'onBlur'
|
2706 | }, {
|
2707 | alt: 'onInputChange',
|
2708 | prop: 'onChange'
|
2709 | }, {
|
2710 | alt: 'onFocus',
|
2711 | prop: 'onFocus'
|
2712 | }, {
|
2713 | alt: 'onKeyDown',
|
2714 | prop: 'onKeyDown'
|
2715 | }];
|
2716 | var sizeType = propTypes$b.exports.oneOf(SIZES);
|
2717 | |
2718 |
|
2719 |
|
2720 | function checkPropType(validator, callback) {
|
2721 | return function (props, propName, componentName) {
|
2722 | propTypes$b.exports.checkPropTypes(_defineProperty({}, propName, validator), props, 'prop', componentName);
|
2723 | isFunction(callback) && callback(props, propName, componentName);
|
2724 | };
|
2725 | }
|
2726 | function caseSensitiveType(props) {
|
2727 | var caseSensitive = props.caseSensitive,
|
2728 | filterBy = props.filterBy;
|
2729 | warn(!caseSensitive || typeof filterBy !== 'function', 'Your `filterBy` function will override the `caseSensitive` prop.');
|
2730 | }
|
2731 | function defaultInputValueType(props) {
|
2732 | var defaultInputValue = props.defaultInputValue,
|
2733 | defaultSelected = props.defaultSelected,
|
2734 | multiple = props.multiple,
|
2735 | selected = props.selected;
|
2736 | var name = defaultSelected.length ? 'defaultSelected' : 'selected';
|
2737 | warn(!(!multiple && defaultInputValue && (defaultSelected.length || selected && selected.length)), "`defaultInputValue` will be overridden by the value from `".concat(name, "`."));
|
2738 | }
|
2739 | function defaultSelectedType(props) {
|
2740 | var defaultSelected = props.defaultSelected,
|
2741 | multiple = props.multiple;
|
2742 | warn(multiple || defaultSelected.length <= 1, 'You are passing multiple options to the `defaultSelected` prop of a ' + 'Typeahead in single-select mode. The selections will be truncated to a ' + 'single selection.');
|
2743 | }
|
2744 | function highlightOnlyResultType(_ref) {
|
2745 | var allowNew = _ref.allowNew,
|
2746 | highlightOnlyResult = _ref.highlightOnlyResult;
|
2747 | warn(!(highlightOnlyResult && allowNew), '`highlightOnlyResult` will not work with `allowNew`.');
|
2748 | }
|
2749 | function ignoreDiacriticsType(props) {
|
2750 | var filterBy = props.filterBy,
|
2751 | ignoreDiacritics = props.ignoreDiacritics;
|
2752 | warn(ignoreDiacritics || typeof filterBy !== 'function', 'Your `filterBy` function will override the `ignoreDiacritics` prop.');
|
2753 | }
|
2754 | function inputPropsType(_ref2) {
|
2755 | var inputProps = _ref2.inputProps;
|
2756 | if (!(inputProps && Object.prototype.toString.call(inputProps) === '[object Object]')) {
|
2757 | return;
|
2758 | }
|
2759 |
|
2760 |
|
2761 | INPUT_PROPS_BLACKLIST.forEach(function (_ref3) {
|
2762 | var alt = _ref3.alt,
|
2763 | prop = _ref3.prop;
|
2764 | var msg = alt ? " Use the top-level `".concat(alt, "` prop instead.") : null;
|
2765 | warn(!inputProps[prop], "The `".concat(prop, "` property of `inputProps` will be ignored.").concat(msg));
|
2766 | });
|
2767 | }
|
2768 | function isRequiredForA11y(props, propName, componentName) {
|
2769 | warn(props[propName] != null, "The prop `".concat(propName, "` is required to make `").concat(componentName, "` ") + 'accessible for users of assistive technologies such as screen readers.');
|
2770 | }
|
2771 | function labelKeyType(_ref4) {
|
2772 | var allowNew = _ref4.allowNew,
|
2773 | labelKey = _ref4.labelKey;
|
2774 | warn(!(isFunction(labelKey) && allowNew), '`labelKey` must be a string when `allowNew={true}`.');
|
2775 | }
|
2776 | var optionType = propTypes$b.exports.oneOfType([propTypes$b.exports.object, propTypes$b.exports.string]);
|
2777 | function selectedType(_ref5) {
|
2778 | var multiple = _ref5.multiple,
|
2779 | onChange = _ref5.onChange,
|
2780 | selected = _ref5.selected;
|
2781 | warn(multiple || !selected || selected.length <= 1, 'You are passing multiple options to the `selected` prop of a Typeahead ' + 'in single-select mode. This may lead to unexpected behaviors or errors.');
|
2782 | warn(!selected || selected && isFunction(onChange), 'You provided a `selected` prop without an `onChange` handler. If you ' + 'want the typeahead to be uncontrolled, use `defaultSelected`. ' + 'Otherwise, set `onChange`.');
|
2783 | }
|
2784 |
|
2785 | var _excluded$c = ["allowNew", "delay", "emptyLabel", "isLoading", "minLength", "onInputChange", "onSearch", "options", "promptText", "searchText", "useCache"];
|
2786 | var propTypes$a = {
|
2787 | |
2788 |
|
2789 |
|
2790 | delay: propTypes$b.exports.number,
|
2791 | |
2792 |
|
2793 |
|
2794 |
|
2795 | isLoading: propTypes$b.exports.bool.isRequired,
|
2796 | |
2797 |
|
2798 |
|
2799 | minLength: propTypes$b.exports.number,
|
2800 | |
2801 |
|
2802 |
|
2803 | onSearch: propTypes$b.exports.func.isRequired,
|
2804 | |
2805 |
|
2806 |
|
2807 |
|
2808 | options: propTypes$b.exports.arrayOf(optionType),
|
2809 | |
2810 |
|
2811 |
|
2812 | promptText: propTypes$b.exports.node,
|
2813 | |
2814 |
|
2815 |
|
2816 | searchText: propTypes$b.exports.node,
|
2817 | |
2818 |
|
2819 |
|
2820 | useCache: propTypes$b.exports.bool
|
2821 | };
|
2822 | |
2823 |
|
2824 |
|
2825 |
|
2826 |
|
2827 |
|
2828 |
|
2829 |
|
2830 | function useAsync(props) {
|
2831 | var allowNew = props.allowNew,
|
2832 | _props$delay = props.delay,
|
2833 | delay = _props$delay === void 0 ? 200 : _props$delay,
|
2834 | emptyLabel = props.emptyLabel,
|
2835 | isLoading = props.isLoading,
|
2836 | _props$minLength = props.minLength,
|
2837 | minLength = _props$minLength === void 0 ? 2 : _props$minLength,
|
2838 | onInputChange = props.onInputChange,
|
2839 | onSearch = props.onSearch,
|
2840 | _props$options = props.options,
|
2841 | options = _props$options === void 0 ? [] : _props$options,
|
2842 | _props$promptText = props.promptText,
|
2843 | promptText = _props$promptText === void 0 ? 'Type to search...' : _props$promptText,
|
2844 | _props$searchText = props.searchText,
|
2845 | searchText = _props$searchText === void 0 ? 'Searching...' : _props$searchText,
|
2846 | _props$useCache = props.useCache,
|
2847 | useCache = _props$useCache === void 0 ? true : _props$useCache,
|
2848 | otherProps = _objectWithoutProperties(props, _excluded$c);
|
2849 | var cacheRef = React.useRef({});
|
2850 | var handleSearchDebouncedRef = React.useRef(null);
|
2851 | var queryRef = React.useRef(props.defaultInputValue || '');
|
2852 | var forceUpdate = useForceUpdate();
|
2853 | var prevProps = usePrevious(props);
|
2854 | var handleSearch = React.useCallback(function (query) {
|
2855 | queryRef.current = query;
|
2856 | if (!query || minLength && query.length < minLength) {
|
2857 | return;
|
2858 | }
|
2859 |
|
2860 |
|
2861 | if (useCache && cacheRef.current[query]) {
|
2862 |
|
2863 | forceUpdate();
|
2864 | return;
|
2865 | }
|
2866 |
|
2867 |
|
2868 | onSearch(query);
|
2869 | }, [forceUpdate, minLength, onSearch, useCache]);
|
2870 |
|
2871 |
|
2872 | React.useEffect(function () {
|
2873 | handleSearchDebouncedRef.current = lodash_debounce(handleSearch, delay);
|
2874 | return function () {
|
2875 | handleSearchDebouncedRef.current && handleSearchDebouncedRef.current.cancel();
|
2876 | };
|
2877 | }, [delay, handleSearch]);
|
2878 | React.useEffect(function () {
|
2879 |
|
2880 |
|
2881 |
|
2882 | if (!isLoading && prevProps && prevProps.isLoading && useCache) {
|
2883 | cacheRef.current[queryRef.current] = options;
|
2884 | }
|
2885 | });
|
2886 | var getEmptyLabel = function getEmptyLabel() {
|
2887 | if (!queryRef.current.length) {
|
2888 | return promptText;
|
2889 | }
|
2890 | if (isLoading) {
|
2891 | return searchText;
|
2892 | }
|
2893 | return emptyLabel;
|
2894 | };
|
2895 | var handleInputChange = React.useCallback(function (query, e) {
|
2896 | onInputChange && onInputChange(query, e);
|
2897 | handleSearchDebouncedRef.current && handleSearchDebouncedRef.current(query);
|
2898 | }, [onInputChange]);
|
2899 | var cachedQuery = cacheRef.current[queryRef.current];
|
2900 | return _objectSpread2(_objectSpread2({}, otherProps), {}, {
|
2901 |
|
2902 | allowNew: isFunction(allowNew) ? allowNew : allowNew && !isLoading,
|
2903 | emptyLabel: getEmptyLabel(),
|
2904 | isLoading: isLoading,
|
2905 | minLength: minLength,
|
2906 | onInputChange: handleInputChange,
|
2907 | options: useCache && cachedQuery ? cachedQuery : options
|
2908 | });
|
2909 | }
|
2910 |
|
2911 |
|
2912 | function withAsync(Component) {
|
2913 | warn(false, 'Warning: `withAsync` is deprecated and will be removed in the next ' + 'major version. Use `useAsync` instead.');
|
2914 | var AsyncTypeahead = React.forwardRef(function (props, ref) {
|
2915 | return React__default["default"].createElement(Component, _extends({}, props, useAsync(props), {
|
2916 | ref: ref
|
2917 | }));
|
2918 | });
|
2919 | AsyncTypeahead.displayName = "withAsync(".concat(getDisplayName(Component), ")");
|
2920 |
|
2921 | AsyncTypeahead.propTypes = propTypes$a;
|
2922 | return AsyncTypeahead;
|
2923 | }
|
2924 |
|
2925 | var defaultContext = {
|
2926 | activeIndex: -1,
|
2927 | hintText: '',
|
2928 | id: '',
|
2929 | initialItem: null,
|
2930 | inputNode: null,
|
2931 | isOnlyResult: false,
|
2932 | onActiveItemChange: noop$1,
|
2933 | onAdd: noop$1,
|
2934 | onInitialItemChange: noop$1,
|
2935 | onMenuItemClick: noop$1,
|
2936 | setItem: noop$1
|
2937 | };
|
2938 | var TypeaheadContext = React.createContext(defaultContext);
|
2939 | var useTypeaheadContext = function useTypeaheadContext() {
|
2940 | return React.useContext(TypeaheadContext);
|
2941 | };
|
2942 |
|
2943 | var inputPropKeys = ['activeIndex', 'disabled', 'id', 'inputRef', 'isFocused', 'isMenuShown', 'multiple', 'onBlur', 'onChange', 'onClick', 'onFocus', 'onKeyDown', 'placeholder'];
|
2944 | var propKeys = ['activeIndex', 'hideMenu', 'isMenuShown', 'labelKey', 'onClear', 'onHide', 'onRemove', 'results', 'selected', 'text', 'toggleMenu'];
|
2945 | var contextKeys = ['activeIndex', 'id', 'initialItem', 'inputNode', 'onActiveItemChange', 'onAdd', 'onInitialItemChange', 'onMenuItemClick', 'setItem'];
|
2946 | var TypeaheadManager = function TypeaheadManager(props) {
|
2947 | var allowNew = props.allowNew,
|
2948 | children = props.children,
|
2949 | initialItem = props.initialItem,
|
2950 | isMenuShown = props.isMenuShown,
|
2951 | onAdd = props.onAdd,
|
2952 | onInitialItemChange = props.onInitialItemChange,
|
2953 | onKeyDown = props.onKeyDown,
|
2954 | onMenuToggle = props.onMenuToggle,
|
2955 | results = props.results,
|
2956 | selectHint = props.selectHint;
|
2957 | var hintText = getHintText(props);
|
2958 | React.useEffect(function () {
|
2959 |
|
2960 | if (!(allowNew || results.length)) {
|
2961 | onInitialItemChange();
|
2962 | }
|
2963 | });
|
2964 | var isInitialRender = React.useRef(true);
|
2965 | React.useEffect(function () {
|
2966 | if (isInitialRender.current) {
|
2967 | isInitialRender.current = false;
|
2968 | return;
|
2969 | }
|
2970 | onMenuToggle(isMenuShown);
|
2971 | }, [isMenuShown, onMenuToggle]);
|
2972 | var handleKeyDown = function handleKeyDown(e) {
|
2973 | onKeyDown(e);
|
2974 | if (!initialItem) {
|
2975 | return;
|
2976 | }
|
2977 | var addOnlyResult = e.key === 'Enter' && getIsOnlyResult(props);
|
2978 | var shouldSelectHint = hintText && defaultSelectHint(e, selectHint);
|
2979 | if (addOnlyResult || shouldSelectHint) {
|
2980 | onAdd(initialItem);
|
2981 | }
|
2982 | };
|
2983 | var childProps = _objectSpread2(_objectSpread2({}, pick(props, propKeys)), {}, {
|
2984 | getInputProps: getInputProps(_objectSpread2(_objectSpread2({}, pick(props, inputPropKeys)), {}, {
|
2985 | onKeyDown: handleKeyDown,
|
2986 | value: getInputText(props)
|
2987 | }))
|
2988 | });
|
2989 | var contextValue = _objectSpread2(_objectSpread2({}, pick(props, contextKeys)), {}, {
|
2990 | hintText: hintText,
|
2991 | isOnlyResult: getIsOnlyResult(props)
|
2992 | });
|
2993 | return React__default["default"].createElement(TypeaheadContext.Provider, {
|
2994 | value: contextValue
|
2995 | }, isFunction(children) ? children(childProps) : children);
|
2996 | };
|
2997 |
|
2998 | function getInitialState(props) {
|
2999 | var defaultInputValue = props.defaultInputValue,
|
3000 | defaultOpen = props.defaultOpen,
|
3001 | defaultSelected = props.defaultSelected,
|
3002 | maxResults = props.maxResults,
|
3003 | multiple = props.multiple;
|
3004 | var selected = props.selected ? props.selected.slice() : defaultSelected.slice();
|
3005 | var text = defaultInputValue;
|
3006 | if (!multiple && selected.length) {
|
3007 |
|
3008 | text = getOptionLabel(selected[0], props.labelKey);
|
3009 | if (selected.length > 1) {
|
3010 |
|
3011 | selected = selected.slice(0, 1);
|
3012 | }
|
3013 | }
|
3014 | return {
|
3015 | activeIndex: -1,
|
3016 | activeItem: undefined,
|
3017 | initialItem: undefined,
|
3018 | isFocused: false,
|
3019 | selected: selected,
|
3020 | showMenu: defaultOpen,
|
3021 | shownResults: maxResults,
|
3022 | text: text
|
3023 | };
|
3024 | }
|
3025 | function clearTypeahead(state, props) {
|
3026 | return _objectSpread2(_objectSpread2({}, getInitialState(props)), {}, {
|
3027 | isFocused: state.isFocused,
|
3028 | selected: [],
|
3029 | text: ''
|
3030 | });
|
3031 | }
|
3032 | function clickOrFocusInput(state) {
|
3033 | return _objectSpread2(_objectSpread2({}, state), {}, {
|
3034 | isFocused: true,
|
3035 | showMenu: true
|
3036 | });
|
3037 | }
|
3038 | function hideMenu(state, props) {
|
3039 | var _getInitialState = getInitialState(props),
|
3040 | activeIndex = _getInitialState.activeIndex,
|
3041 | activeItem = _getInitialState.activeItem,
|
3042 | initialItem = _getInitialState.initialItem,
|
3043 | shownResults = _getInitialState.shownResults;
|
3044 | return _objectSpread2(_objectSpread2({}, state), {}, {
|
3045 | activeIndex: activeIndex,
|
3046 | activeItem: activeItem,
|
3047 | initialItem: initialItem,
|
3048 | showMenu: false,
|
3049 | shownResults: shownResults
|
3050 | });
|
3051 | }
|
3052 | function toggleMenu(state, props) {
|
3053 | return state.showMenu ? hideMenu(state, props) : _objectSpread2(_objectSpread2({}, state), {}, {
|
3054 | showMenu: true
|
3055 | });
|
3056 | }
|
3057 |
|
3058 | var _excluded$b = ["onChange"];
|
3059 | var propTypes$9 = {
|
3060 | |
3061 |
|
3062 |
|
3063 |
|
3064 |
|
3065 |
|
3066 |
|
3067 |
|
3068 | allowNew: propTypes$b.exports.oneOfType([propTypes$b.exports.bool, propTypes$b.exports.func]),
|
3069 | |
3070 |
|
3071 |
|
3072 | autoFocus: propTypes$b.exports.bool,
|
3073 | |
3074 |
|
3075 |
|
3076 | caseSensitive: checkPropType(propTypes$b.exports.bool, caseSensitiveType),
|
3077 | |
3078 |
|
3079 |
|
3080 | defaultInputValue: checkPropType(propTypes$b.exports.string, defaultInputValueType),
|
3081 | |
3082 |
|
3083 |
|
3084 | defaultOpen: propTypes$b.exports.bool,
|
3085 | |
3086 |
|
3087 |
|
3088 |
|
3089 | defaultSelected: checkPropType(propTypes$b.exports.arrayOf(optionType), defaultSelectedType),
|
3090 | |
3091 |
|
3092 |
|
3093 |
|
3094 | filterBy: propTypes$b.exports.oneOfType([propTypes$b.exports.arrayOf(propTypes$b.exports.string.isRequired), propTypes$b.exports.func]),
|
3095 | |
3096 |
|
3097 |
|
3098 |
|
3099 | highlightOnlyResult: checkPropType(propTypes$b.exports.bool, highlightOnlyResultType),
|
3100 | |
3101 |
|
3102 |
|
3103 |
|
3104 | id: checkPropType(propTypes$b.exports.oneOfType([propTypes$b.exports.number, propTypes$b.exports.string]), isRequiredForA11y),
|
3105 | |
3106 |
|
3107 |
|
3108 | ignoreDiacritics: checkPropType(propTypes$b.exports.bool, ignoreDiacriticsType),
|
3109 | |
3110 |
|
3111 |
|
3112 |
|
3113 | labelKey: checkPropType(propTypes$b.exports.oneOfType([propTypes$b.exports.string, propTypes$b.exports.func]), labelKeyType),
|
3114 | |
3115 |
|
3116 |
|
3117 |
|
3118 |
|
3119 | maxResults: propTypes$b.exports.number,
|
3120 | |
3121 |
|
3122 |
|
3123 | minLength: propTypes$b.exports.number,
|
3124 | |
3125 |
|
3126 |
|
3127 | multiple: propTypes$b.exports.bool,
|
3128 | |
3129 |
|
3130 |
|
3131 | onBlur: propTypes$b.exports.func,
|
3132 | |
3133 |
|
3134 |
|
3135 |
|
3136 | onChange: propTypes$b.exports.func,
|
3137 | |
3138 |
|
3139 |
|
3140 | onFocus: propTypes$b.exports.func,
|
3141 | |
3142 |
|
3143 |
|
3144 |
|
3145 | onInputChange: propTypes$b.exports.func,
|
3146 | |
3147 |
|
3148 |
|
3149 | onKeyDown: propTypes$b.exports.func,
|
3150 | |
3151 |
|
3152 |
|
3153 | onMenuToggle: propTypes$b.exports.func,
|
3154 | |
3155 |
|
3156 |
|
3157 | onPaginate: propTypes$b.exports.func,
|
3158 | |
3159 |
|
3160 |
|
3161 |
|
3162 |
|
3163 | open: propTypes$b.exports.bool,
|
3164 | |
3165 |
|
3166 |
|
3167 |
|
3168 | options: propTypes$b.exports.arrayOf(optionType).isRequired,
|
3169 | |
3170 |
|
3171 |
|
3172 |
|
3173 | paginate: propTypes$b.exports.bool,
|
3174 | |
3175 |
|
3176 |
|
3177 |
|
3178 | selected: checkPropType(propTypes$b.exports.arrayOf(optionType), selectedType)
|
3179 | };
|
3180 | var defaultProps$1 = {
|
3181 | allowNew: false,
|
3182 | autoFocus: false,
|
3183 | caseSensitive: false,
|
3184 | defaultInputValue: '',
|
3185 | defaultOpen: false,
|
3186 | defaultSelected: [],
|
3187 | filterBy: [],
|
3188 | highlightOnlyResult: false,
|
3189 | ignoreDiacritics: true,
|
3190 | labelKey: DEFAULT_LABELKEY,
|
3191 | maxResults: 100,
|
3192 | minLength: 0,
|
3193 | multiple: false,
|
3194 | onBlur: noop$1,
|
3195 | onFocus: noop$1,
|
3196 | onInputChange: noop$1,
|
3197 | onKeyDown: noop$1,
|
3198 | onMenuToggle: noop$1,
|
3199 | onPaginate: noop$1,
|
3200 | paginate: true
|
3201 | };
|
3202 | |
3203 |
|
3204 |
|
3205 |
|
3206 | function triggerInputChange(input, value) {
|
3207 | var inputValue = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value');
|
3208 | inputValue && inputValue.set && inputValue.set.call(input, value);
|
3209 | var e = new Event('input', {
|
3210 | bubbles: true
|
3211 | });
|
3212 | input.dispatchEvent(e);
|
3213 | }
|
3214 | var Typeahead = function (_React$Component) {
|
3215 | _inherits(Typeahead, _React$Component);
|
3216 | var _super = _createSuper(Typeahead);
|
3217 | function Typeahead() {
|
3218 | var _this;
|
3219 | _classCallCheck(this, Typeahead);
|
3220 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
3221 | args[_key] = arguments[_key];
|
3222 | }
|
3223 | _this = _super.call.apply(_super, [this].concat(args));
|
3224 | _defineProperty(_assertThisInitialized(_this), "state", getInitialState(_this.props));
|
3225 | _defineProperty(_assertThisInitialized(_this), "inputNode", null);
|
3226 | _defineProperty(_assertThisInitialized(_this), "isMenuShown", false);
|
3227 |
|
3228 |
|
3229 | _defineProperty(_assertThisInitialized(_this), "items", []);
|
3230 | _defineProperty(_assertThisInitialized(_this), "blur", function () {
|
3231 | _this.inputNode && _this.inputNode.blur();
|
3232 | _this.hideMenu();
|
3233 | });
|
3234 | _defineProperty(_assertThisInitialized(_this), "clear", function () {
|
3235 | _this.setState(clearTypeahead);
|
3236 | });
|
3237 | _defineProperty(_assertThisInitialized(_this), "focus", function () {
|
3238 | _this.inputNode && _this.inputNode.focus();
|
3239 | });
|
3240 | _defineProperty(_assertThisInitialized(_this), "getInput", function () {
|
3241 | return _this.inputNode;
|
3242 | });
|
3243 | _defineProperty(_assertThisInitialized(_this), "inputRef", function (inputNode) {
|
3244 | _this.inputNode = inputNode;
|
3245 | });
|
3246 | _defineProperty(_assertThisInitialized(_this), "setItem", function (item, position) {
|
3247 | _this.items[position] = item;
|
3248 | });
|
3249 | _defineProperty(_assertThisInitialized(_this), "hideMenu", function () {
|
3250 | _this.setState(hideMenu);
|
3251 | });
|
3252 | _defineProperty(_assertThisInitialized(_this), "toggleMenu", function () {
|
3253 | _this.setState(toggleMenu);
|
3254 | });
|
3255 | _defineProperty(_assertThisInitialized(_this), "_handleActiveIndexChange", function (activeIndex) {
|
3256 | _this.setState(function (state) {
|
3257 | return {
|
3258 | activeIndex: activeIndex,
|
3259 | activeItem: activeIndex >= 0 ? state.activeItem : undefined
|
3260 | };
|
3261 | });
|
3262 | });
|
3263 | _defineProperty(_assertThisInitialized(_this), "_handleActiveItemChange", function (activeItem) {
|
3264 |
|
3265 | if (!fastDeepEqual(activeItem, _this.state.activeItem)) {
|
3266 | _this.setState({
|
3267 | activeItem: activeItem
|
3268 | });
|
3269 | }
|
3270 | });
|
3271 | _defineProperty(_assertThisInitialized(_this), "_handleBlur", function (e) {
|
3272 | e.persist();
|
3273 | _this.setState({
|
3274 | isFocused: false
|
3275 | }, function () {
|
3276 | return _this.props.onBlur(e);
|
3277 | });
|
3278 | });
|
3279 | _defineProperty(_assertThisInitialized(_this), "_handleChange", function (selected) {
|
3280 | _this.props.onChange && _this.props.onChange(selected);
|
3281 | });
|
3282 | _defineProperty(_assertThisInitialized(_this), "_handleClear", function () {
|
3283 | _this.inputNode && triggerInputChange(_this.inputNode, '');
|
3284 | _this.setState(clearTypeahead, function () {
|
3285 |
|
3286 |
|
3287 | if (_this.props.multiple) {
|
3288 | _this._handleChange([]);
|
3289 | }
|
3290 | });
|
3291 | });
|
3292 | _defineProperty(_assertThisInitialized(_this), "_handleClick", function (e) {
|
3293 | var _this$props$inputProp;
|
3294 | e.persist();
|
3295 | var onClick = (_this$props$inputProp = _this.props.inputProps) === null || _this$props$inputProp === void 0 ? void 0 : _this$props$inputProp.onClick;
|
3296 | _this.setState(clickOrFocusInput, function () {
|
3297 | return isFunction(onClick) && onClick(e);
|
3298 | });
|
3299 | });
|
3300 | _defineProperty(_assertThisInitialized(_this), "_handleFocus", function (e) {
|
3301 | e.persist();
|
3302 | _this.setState(clickOrFocusInput, function () {
|
3303 | return _this.props.onFocus(e);
|
3304 | });
|
3305 | });
|
3306 | _defineProperty(_assertThisInitialized(_this), "_handleInitialItemChange", function (initialItem) {
|
3307 |
|
3308 | if (!fastDeepEqual(initialItem, _this.state.initialItem)) {
|
3309 | _this.setState({
|
3310 | initialItem: initialItem
|
3311 | });
|
3312 | }
|
3313 | });
|
3314 | _defineProperty(_assertThisInitialized(_this), "_handleInputChange", function (e) {
|
3315 | e.persist();
|
3316 | var text = e.currentTarget.value;
|
3317 | var _this$props = _this.props,
|
3318 | multiple = _this$props.multiple,
|
3319 | onInputChange = _this$props.onInputChange;
|
3320 |
|
3321 |
|
3322 | var shouldClearSelections = _this.state.selected.length && !multiple;
|
3323 | _this.setState(function (state, props) {
|
3324 | var _getInitialState = getInitialState(props),
|
3325 | activeIndex = _getInitialState.activeIndex,
|
3326 | activeItem = _getInitialState.activeItem,
|
3327 | shownResults = _getInitialState.shownResults;
|
3328 | return {
|
3329 | activeIndex: activeIndex,
|
3330 | activeItem: activeItem,
|
3331 | selected: shouldClearSelections ? [] : state.selected,
|
3332 | showMenu: true,
|
3333 | shownResults: shownResults,
|
3334 | text: text
|
3335 | };
|
3336 | }, function () {
|
3337 | onInputChange(text, e);
|
3338 | shouldClearSelections && _this._handleChange([]);
|
3339 | });
|
3340 | });
|
3341 | _defineProperty(_assertThisInitialized(_this), "_handleKeyDown", function (e) {
|
3342 | var activeItem = _this.state.activeItem;
|
3343 |
|
3344 |
|
3345 | if (!_this.isMenuShown) {
|
3346 | if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
|
3347 | _this.setState({
|
3348 | showMenu: true
|
3349 | });
|
3350 | }
|
3351 | _this.props.onKeyDown(e);
|
3352 | return;
|
3353 | }
|
3354 | switch (e.key) {
|
3355 | case 'ArrowUp':
|
3356 | case 'ArrowDown':
|
3357 |
|
3358 | e.preventDefault();
|
3359 | _this._handleActiveIndexChange(getUpdatedActiveIndex(_this.state.activeIndex, e.key, _this.items));
|
3360 | break;
|
3361 | case 'Enter':
|
3362 |
|
3363 | e.preventDefault();
|
3364 | activeItem && _this._handleMenuItemSelect(activeItem, e);
|
3365 | break;
|
3366 | case 'Escape':
|
3367 | case 'Tab':
|
3368 |
|
3369 |
|
3370 | _this.hideMenu();
|
3371 | break;
|
3372 | }
|
3373 | _this.props.onKeyDown(e);
|
3374 | });
|
3375 | _defineProperty(_assertThisInitialized(_this), "_handleMenuItemSelect", function (option, e) {
|
3376 | if (getOptionProperty(option, 'paginationOption')) {
|
3377 | _this._handlePaginate(e);
|
3378 | } else {
|
3379 | _this._handleSelectionAdd(option);
|
3380 | }
|
3381 | });
|
3382 | _defineProperty(_assertThisInitialized(_this), "_handlePaginate", function (e) {
|
3383 | e.persist();
|
3384 | _this.setState(function (state, props) {
|
3385 | return {
|
3386 | shownResults: state.shownResults + props.maxResults
|
3387 | };
|
3388 | }, function () {
|
3389 | return _this.props.onPaginate(e, _this.state.shownResults);
|
3390 | });
|
3391 | });
|
3392 | _defineProperty(_assertThisInitialized(_this), "_handleSelectionAdd", function (option) {
|
3393 | var _this$props2 = _this.props,
|
3394 | multiple = _this$props2.multiple,
|
3395 | labelKey = _this$props2.labelKey;
|
3396 | var selected;
|
3397 | var selection = option;
|
3398 | var text;
|
3399 |
|
3400 |
|
3401 |
|
3402 | if (!isString(selection) && selection.customOption) {
|
3403 | selection = _objectSpread2(_objectSpread2({}, selection), {}, {
|
3404 | id: uniqueId('new-id-')
|
3405 | });
|
3406 | }
|
3407 | if (multiple) {
|
3408 |
|
3409 |
|
3410 | selected = _this.state.selected.concat(selection);
|
3411 | text = '';
|
3412 | } else {
|
3413 |
|
3414 |
|
3415 | selected = [selection];
|
3416 | text = getOptionLabel(selection, labelKey);
|
3417 | }
|
3418 | _this.setState(function (state, props) {
|
3419 | return _objectSpread2(_objectSpread2({}, hideMenu(state, props)), {}, {
|
3420 | initialItem: selection,
|
3421 | selected: selected,
|
3422 | text: text
|
3423 | });
|
3424 | }, function () {
|
3425 | return _this._handleChange(selected);
|
3426 | });
|
3427 | });
|
3428 | _defineProperty(_assertThisInitialized(_this), "_handleSelectionRemove", function (selection) {
|
3429 | var selected = _this.state.selected.filter(function (option) {
|
3430 | return !fastDeepEqual(option, selection);
|
3431 | });
|
3432 |
|
3433 |
|
3434 | _this.focus();
|
3435 | _this.setState(function (state, props) {
|
3436 | return _objectSpread2(_objectSpread2({}, hideMenu(state, props)), {}, {
|
3437 | selected: selected
|
3438 | });
|
3439 | }, function () {
|
3440 | return _this._handleChange(selected);
|
3441 | });
|
3442 | });
|
3443 | return _this;
|
3444 | }
|
3445 | _createClass(Typeahead, [{
|
3446 | key: "componentDidMount",
|
3447 | value: function componentDidMount() {
|
3448 | this.props.autoFocus && this.focus();
|
3449 | }
|
3450 | }, {
|
3451 | key: "componentDidUpdate",
|
3452 | value: function componentDidUpdate(prevProps, prevState) {
|
3453 | var _this$props3 = this.props,
|
3454 | labelKey = _this$props3.labelKey,
|
3455 | multiple = _this$props3.multiple,
|
3456 | selected = _this$props3.selected;
|
3457 | validateSelectedPropChange(selected, prevProps.selected);
|
3458 |
|
3459 |
|
3460 | if (selected && !fastDeepEqual(selected, prevState.selected)) {
|
3461 | this.setState({
|
3462 | selected: selected
|
3463 | });
|
3464 | if (!multiple) {
|
3465 | this.setState({
|
3466 | text: selected.length ? getOptionLabel(selected[0], labelKey) : ''
|
3467 | });
|
3468 | }
|
3469 | }
|
3470 | }
|
3471 | }, {
|
3472 | key: "render",
|
3473 | value: function render() {
|
3474 | var _this$props4 = this.props;
|
3475 | _this$props4.onChange;
|
3476 | var props = _objectWithoutProperties(_this$props4, _excluded$b);
|
3477 | var mergedPropsAndState = _objectSpread2(_objectSpread2({}, props), this.state);
|
3478 | var filterBy = mergedPropsAndState.filterBy,
|
3479 | labelKey = mergedPropsAndState.labelKey,
|
3480 | options = mergedPropsAndState.options,
|
3481 | paginate = mergedPropsAndState.paginate,
|
3482 | shownResults = mergedPropsAndState.shownResults,
|
3483 | text = mergedPropsAndState.text;
|
3484 | this.isMenuShown = isShown(mergedPropsAndState);
|
3485 | this.items = [];
|
3486 |
|
3487 | var results = [];
|
3488 | if (this.isMenuShown) {
|
3489 | var cb = isFunction(filterBy) ? filterBy : defaultFilterBy;
|
3490 | results = options.filter(function (option) {
|
3491 | return cb(option, mergedPropsAndState);
|
3492 | });
|
3493 |
|
3494 |
|
3495 | var shouldPaginate = paginate && results.length > shownResults;
|
3496 |
|
3497 |
|
3498 | results = getTruncatedOptions(results, shownResults);
|
3499 |
|
3500 |
|
3501 | if (addCustomOption(results, mergedPropsAndState)) {
|
3502 | results.push(_defineProperty({
|
3503 | customOption: true
|
3504 | }, getStringLabelKey(labelKey), text));
|
3505 | }
|
3506 |
|
3507 |
|
3508 | if (shouldPaginate) {
|
3509 | var _results$push2;
|
3510 | results.push((_results$push2 = {}, _defineProperty(_results$push2, getStringLabelKey(labelKey), ''), _defineProperty(_results$push2, "paginationOption", true), _results$push2));
|
3511 | }
|
3512 | }
|
3513 | return React__default["default"].createElement(TypeaheadManager, _extends({}, mergedPropsAndState, {
|
3514 | hideMenu: this.hideMenu,
|
3515 | inputNode: this.inputNode,
|
3516 | inputRef: this.inputRef,
|
3517 | isMenuShown: this.isMenuShown,
|
3518 | onActiveItemChange: this._handleActiveItemChange,
|
3519 | onAdd: this._handleSelectionAdd,
|
3520 | onBlur: this._handleBlur,
|
3521 | onChange: this._handleInputChange,
|
3522 | onClear: this._handleClear,
|
3523 | onClick: this._handleClick,
|
3524 | onFocus: this._handleFocus,
|
3525 | onHide: this.hideMenu,
|
3526 | onInitialItemChange: this._handleInitialItemChange,
|
3527 | onKeyDown: this._handleKeyDown,
|
3528 | onMenuItemClick: this._handleMenuItemSelect,
|
3529 | onRemove: this._handleSelectionRemove,
|
3530 | results: results,
|
3531 | setItem: this.setItem,
|
3532 | toggleMenu: this.toggleMenu
|
3533 | }));
|
3534 | }
|
3535 | }]);
|
3536 | return Typeahead;
|
3537 | }(React__default["default"].Component);
|
3538 | _defineProperty(Typeahead, "propTypes", propTypes$9);
|
3539 | _defineProperty(Typeahead, "defaultProps", defaultProps$1);
|
3540 |
|
3541 | var _excluded$a = ["className", "label", "onClick", "onKeyDown", "size"];
|
3542 | var propTypes$8 = {
|
3543 | label: propTypes$b.exports.string,
|
3544 | onClick: propTypes$b.exports.func,
|
3545 | onKeyDown: propTypes$b.exports.func,
|
3546 | size: sizeType
|
3547 | };
|
3548 | |
3549 |
|
3550 |
|
3551 |
|
3552 |
|
3553 | var ClearButton = function ClearButton(_ref) {
|
3554 | var className = _ref.className,
|
3555 | _ref$label = _ref.label,
|
3556 | label = _ref$label === void 0 ? 'Clear' : _ref$label,
|
3557 | _onClick = _ref.onClick,
|
3558 | _onKeyDown = _ref.onKeyDown,
|
3559 | size = _ref.size,
|
3560 | props = _objectWithoutProperties(_ref, _excluded$a);
|
3561 | return React__default["default"].createElement("button", _extends({}, props, {
|
3562 | "aria-label": label,
|
3563 | className: cx('close', 'btn-close', 'rbt-close', {
|
3564 | 'rbt-close-lg': isSizeLarge(size),
|
3565 | 'rbt-close-sm': isSizeSmall(size)
|
3566 | }, className),
|
3567 | onClick: function onClick(e) {
|
3568 | e.stopPropagation();
|
3569 | _onClick && _onClick(e);
|
3570 | },
|
3571 | onKeyDown: function onKeyDown(e) {
|
3572 |
|
3573 | if (e.key === 'Backspace') {
|
3574 | e.preventDefault();
|
3575 | }
|
3576 | _onKeyDown && _onKeyDown(e);
|
3577 | },
|
3578 | type: "button"
|
3579 | }), React__default["default"].createElement("span", {
|
3580 | "aria-hidden": "true",
|
3581 | className: "rbt-close-content"
|
3582 | }, "\xD7"), React__default["default"].createElement("span", {
|
3583 | className: "sr-only visually-hidden"
|
3584 | }, label));
|
3585 | };
|
3586 | ClearButton.propTypes = propTypes$8;
|
3587 |
|
3588 | var propTypes$7 = {
|
3589 | label: propTypes$b.exports.string
|
3590 | };
|
3591 | var Loader = function Loader(_ref) {
|
3592 | var _ref$label = _ref.label,
|
3593 | label = _ref$label === void 0 ? 'Loading...' : _ref$label;
|
3594 | return React__default["default"].createElement("div", {
|
3595 | className: "rbt-loader spinner-border spinner-border-sm",
|
3596 | role: "status"
|
3597 | }, React__default["default"].createElement("span", {
|
3598 | className: "sr-only visually-hidden"
|
3599 | }, label));
|
3600 | };
|
3601 | Loader.propTypes = propTypes$7;
|
3602 |
|
3603 | React__namespace.createContext();
|
3604 | React__namespace.createContext();
|
3605 |
|
3606 | |
3607 |
|
3608 |
|
3609 |
|
3610 | var fromEntries = function fromEntries(entries) {
|
3611 | return entries.reduce(function (acc, _ref) {
|
3612 | var key = _ref[0],
|
3613 | value = _ref[1];
|
3614 | acc[key] = value;
|
3615 | return acc;
|
3616 | }, {});
|
3617 | };
|
3618 | |
3619 |
|
3620 |
|
3621 |
|
3622 | var useIsomorphicLayoutEffect = typeof window !== 'undefined' && window.document && window.document.createElement ? React__namespace.useLayoutEffect : React__namespace.useEffect;
|
3623 |
|
3624 | var top = 'top';
|
3625 | var bottom = 'bottom';
|
3626 | var right = 'right';
|
3627 | var left = 'left';
|
3628 | var auto = 'auto';
|
3629 | var basePlacements = [top, bottom, right, left];
|
3630 | var start = 'start';
|
3631 | var end = 'end';
|
3632 | var clippingParents = 'clippingParents';
|
3633 | var viewport = 'viewport';
|
3634 | var popper = 'popper';
|
3635 | var reference = 'reference';
|
3636 | var variationPlacements = basePlacements.reduce(function (acc, placement) {
|
3637 | return acc.concat([placement + "-" + start, placement + "-" + end]);
|
3638 | }, []);
|
3639 | var placements = [].concat(basePlacements, [auto]).reduce(function (acc, placement) {
|
3640 | return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
|
3641 | }, []);
|
3642 |
|
3643 | var beforeRead = 'beforeRead';
|
3644 | var read = 'read';
|
3645 | var afterRead = 'afterRead';
|
3646 |
|
3647 | var beforeMain = 'beforeMain';
|
3648 | var main = 'main';
|
3649 | var afterMain = 'afterMain';
|
3650 |
|
3651 | var beforeWrite = 'beforeWrite';
|
3652 | var write = 'write';
|
3653 | var afterWrite = 'afterWrite';
|
3654 | var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
|
3655 |
|
3656 | function getNodeName(element) {
|
3657 | return element ? (element.nodeName || '').toLowerCase() : null;
|
3658 | }
|
3659 |
|
3660 | function getWindow(node) {
|
3661 | if (node == null) {
|
3662 | return window;
|
3663 | }
|
3664 |
|
3665 | if (node.toString() !== '[object Window]') {
|
3666 | var ownerDocument = node.ownerDocument;
|
3667 | return ownerDocument ? ownerDocument.defaultView || window : window;
|
3668 | }
|
3669 |
|
3670 | return node;
|
3671 | }
|
3672 |
|
3673 | function isElement(node) {
|
3674 | var OwnElement = getWindow(node).Element;
|
3675 | return node instanceof OwnElement || node instanceof Element;
|
3676 | }
|
3677 |
|
3678 | function isHTMLElement(node) {
|
3679 | var OwnElement = getWindow(node).HTMLElement;
|
3680 | return node instanceof OwnElement || node instanceof HTMLElement;
|
3681 | }
|
3682 |
|
3683 | function isShadowRoot(node) {
|
3684 |
|
3685 | if (typeof ShadowRoot === 'undefined') {
|
3686 | return false;
|
3687 | }
|
3688 |
|
3689 | var OwnElement = getWindow(node).ShadowRoot;
|
3690 | return node instanceof OwnElement || node instanceof ShadowRoot;
|
3691 | }
|
3692 |
|
3693 |
|
3694 |
|
3695 | function applyStyles(_ref) {
|
3696 | var state = _ref.state;
|
3697 | Object.keys(state.elements).forEach(function (name) {
|
3698 | var style = state.styles[name] || {};
|
3699 | var attributes = state.attributes[name] || {};
|
3700 | var element = state.elements[name];
|
3701 |
|
3702 | if (!isHTMLElement(element) || !getNodeName(element)) {
|
3703 | return;
|
3704 | }
|
3705 |
|
3706 |
|
3707 |
|
3708 |
|
3709 | Object.assign(element.style, style);
|
3710 | Object.keys(attributes).forEach(function (name) {
|
3711 | var value = attributes[name];
|
3712 |
|
3713 | if (value === false) {
|
3714 | element.removeAttribute(name);
|
3715 | } else {
|
3716 | element.setAttribute(name, value === true ? '' : value);
|
3717 | }
|
3718 | });
|
3719 | });
|
3720 | }
|
3721 |
|
3722 | function effect$2(_ref2) {
|
3723 | var state = _ref2.state;
|
3724 | var initialStyles = {
|
3725 | popper: {
|
3726 | position: state.options.strategy,
|
3727 | left: '0',
|
3728 | top: '0',
|
3729 | margin: '0'
|
3730 | },
|
3731 | arrow: {
|
3732 | position: 'absolute'
|
3733 | },
|
3734 | reference: {}
|
3735 | };
|
3736 | Object.assign(state.elements.popper.style, initialStyles.popper);
|
3737 | state.styles = initialStyles;
|
3738 |
|
3739 | if (state.elements.arrow) {
|
3740 | Object.assign(state.elements.arrow.style, initialStyles.arrow);
|
3741 | }
|
3742 |
|
3743 | return function () {
|
3744 | Object.keys(state.elements).forEach(function (name) {
|
3745 | var element = state.elements[name];
|
3746 | var attributes = state.attributes[name] || {};
|
3747 | var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]);
|
3748 |
|
3749 | var style = styleProperties.reduce(function (style, property) {
|
3750 | style[property] = '';
|
3751 | return style;
|
3752 | }, {});
|
3753 |
|
3754 | if (!isHTMLElement(element) || !getNodeName(element)) {
|
3755 | return;
|
3756 | }
|
3757 |
|
3758 | Object.assign(element.style, style);
|
3759 | Object.keys(attributes).forEach(function (attribute) {
|
3760 | element.removeAttribute(attribute);
|
3761 | });
|
3762 | });
|
3763 | };
|
3764 | }
|
3765 |
|
3766 |
|
3767 | var applyStyles$1 = {
|
3768 | name: 'applyStyles',
|
3769 | enabled: true,
|
3770 | phase: 'write',
|
3771 | fn: applyStyles,
|
3772 | effect: effect$2,
|
3773 | requires: ['computeStyles']
|
3774 | };
|
3775 |
|
3776 | function getBasePlacement(placement) {
|
3777 | return placement.split('-')[0];
|
3778 | }
|
3779 |
|
3780 | var max = Math.max;
|
3781 | var min = Math.min;
|
3782 | var round = Math.round;
|
3783 |
|
3784 | function getUAString() {
|
3785 | var uaData = navigator.userAgentData;
|
3786 |
|
3787 | if (uaData != null && uaData.brands && Array.isArray(uaData.brands)) {
|
3788 | return uaData.brands.map(function (item) {
|
3789 | return item.brand + "/" + item.version;
|
3790 | }).join(' ');
|
3791 | }
|
3792 |
|
3793 | return navigator.userAgent;
|
3794 | }
|
3795 |
|
3796 | function isLayoutViewport() {
|
3797 | return !/^((?!chrome|android).)*safari/i.test(getUAString());
|
3798 | }
|
3799 |
|
3800 | function getBoundingClientRect(element, includeScale, isFixedStrategy) {
|
3801 | if (includeScale === void 0) {
|
3802 | includeScale = false;
|
3803 | }
|
3804 |
|
3805 | if (isFixedStrategy === void 0) {
|
3806 | isFixedStrategy = false;
|
3807 | }
|
3808 |
|
3809 | var clientRect = element.getBoundingClientRect();
|
3810 | var scaleX = 1;
|
3811 | var scaleY = 1;
|
3812 |
|
3813 | if (includeScale && isHTMLElement(element)) {
|
3814 | scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
|
3815 | scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
|
3816 | }
|
3817 |
|
3818 | var _ref = isElement(element) ? getWindow(element) : window,
|
3819 | visualViewport = _ref.visualViewport;
|
3820 |
|
3821 | var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
|
3822 | var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
|
3823 | var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
|
3824 | var width = clientRect.width / scaleX;
|
3825 | var height = clientRect.height / scaleY;
|
3826 | return {
|
3827 | width: width,
|
3828 | height: height,
|
3829 | top: y,
|
3830 | right: x + width,
|
3831 | bottom: y + height,
|
3832 | left: x,
|
3833 | x: x,
|
3834 | y: y
|
3835 | };
|
3836 | }
|
3837 |
|
3838 |
|
3839 |
|
3840 | function getLayoutRect(element) {
|
3841 | var clientRect = getBoundingClientRect(element);
|
3842 |
|
3843 |
|
3844 | var width = element.offsetWidth;
|
3845 | var height = element.offsetHeight;
|
3846 |
|
3847 | if (Math.abs(clientRect.width - width) <= 1) {
|
3848 | width = clientRect.width;
|
3849 | }
|
3850 |
|
3851 | if (Math.abs(clientRect.height - height) <= 1) {
|
3852 | height = clientRect.height;
|
3853 | }
|
3854 |
|
3855 | return {
|
3856 | x: element.offsetLeft,
|
3857 | y: element.offsetTop,
|
3858 | width: width,
|
3859 | height: height
|
3860 | };
|
3861 | }
|
3862 |
|
3863 | function contains$1(parent, child) {
|
3864 | var rootNode = child.getRootNode && child.getRootNode();
|
3865 |
|
3866 | if (parent.contains(child)) {
|
3867 | return true;
|
3868 | }
|
3869 | else if (rootNode && isShadowRoot(rootNode)) {
|
3870 | var next = child;
|
3871 |
|
3872 | do {
|
3873 | if (next && parent.isSameNode(next)) {
|
3874 | return true;
|
3875 | }
|
3876 |
|
3877 |
|
3878 | next = next.parentNode || next.host;
|
3879 | } while (next);
|
3880 | }
|
3881 |
|
3882 |
|
3883 | return false;
|
3884 | }
|
3885 |
|
3886 | function getComputedStyle$1(element) {
|
3887 | return getWindow(element).getComputedStyle(element);
|
3888 | }
|
3889 |
|
3890 | function isTableElement(element) {
|
3891 | return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
|
3892 | }
|
3893 |
|
3894 | function getDocumentElement(element) {
|
3895 |
|
3896 | return ((isElement(element) ? element.ownerDocument :
|
3897 | element.document) || window.document).documentElement;
|
3898 | }
|
3899 |
|
3900 | function getParentNode(element) {
|
3901 | if (getNodeName(element) === 'html') {
|
3902 | return element;
|
3903 | }
|
3904 |
|
3905 | return (
|
3906 |
|
3907 |
|
3908 | element.assignedSlot ||
|
3909 | element.parentNode || (
|
3910 | isShadowRoot(element) ? element.host : null) ||
|
3911 |
|
3912 | getDocumentElement(element)
|
3913 |
|
3914 | );
|
3915 | }
|
3916 |
|
3917 | function getTrueOffsetParent(element) {
|
3918 | if (!isHTMLElement(element) ||
|
3919 | getComputedStyle$1(element).position === 'fixed') {
|
3920 | return null;
|
3921 | }
|
3922 |
|
3923 | return element.offsetParent;
|
3924 | }
|
3925 |
|
3926 |
|
3927 |
|
3928 | function getContainingBlock(element) {
|
3929 | var isFirefox = /firefox/i.test(getUAString());
|
3930 | var isIE = /Trident/i.test(getUAString());
|
3931 |
|
3932 | if (isIE && isHTMLElement(element)) {
|
3933 |
|
3934 | var elementCss = getComputedStyle$1(element);
|
3935 |
|
3936 | if (elementCss.position === 'fixed') {
|
3937 | return null;
|
3938 | }
|
3939 | }
|
3940 |
|
3941 | var currentNode = getParentNode(element);
|
3942 |
|
3943 | if (isShadowRoot(currentNode)) {
|
3944 | currentNode = currentNode.host;
|
3945 | }
|
3946 |
|
3947 | while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
|
3948 | var css = getComputedStyle$1(currentNode);
|
3949 |
|
3950 |
|
3951 |
|
3952 | if (css.transform !== 'none' || css.perspective !== 'none' || css.contain === 'paint' || ['transform', 'perspective'].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === 'filter' || isFirefox && css.filter && css.filter !== 'none') {
|
3953 | return currentNode;
|
3954 | } else {
|
3955 | currentNode = currentNode.parentNode;
|
3956 | }
|
3957 | }
|
3958 |
|
3959 | return null;
|
3960 | }
|
3961 |
|
3962 |
|
3963 |
|
3964 | function getOffsetParent(element) {
|
3965 | var window = getWindow(element);
|
3966 | var offsetParent = getTrueOffsetParent(element);
|
3967 |
|
3968 | while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === 'static') {
|
3969 | offsetParent = getTrueOffsetParent(offsetParent);
|
3970 | }
|
3971 |
|
3972 | if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle$1(offsetParent).position === 'static')) {
|
3973 | return window;
|
3974 | }
|
3975 |
|
3976 | return offsetParent || getContainingBlock(element) || window;
|
3977 | }
|
3978 |
|
3979 | function getMainAxisFromPlacement(placement) {
|
3980 | return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
|
3981 | }
|
3982 |
|
3983 | function within(min$1, value, max$1) {
|
3984 | return max(min$1, min(value, max$1));
|
3985 | }
|
3986 | function withinMaxClamp(min, value, max) {
|
3987 | var v = within(min, value, max);
|
3988 | return v > max ? max : v;
|
3989 | }
|
3990 |
|
3991 | function getFreshSideObject() {
|
3992 | return {
|
3993 | top: 0,
|
3994 | right: 0,
|
3995 | bottom: 0,
|
3996 | left: 0
|
3997 | };
|
3998 | }
|
3999 |
|
4000 | function mergePaddingObject(paddingObject) {
|
4001 | return Object.assign({}, getFreshSideObject(), paddingObject);
|
4002 | }
|
4003 |
|
4004 | function expandToHashMap(value, keys) {
|
4005 | return keys.reduce(function (hashMap, key) {
|
4006 | hashMap[key] = value;
|
4007 | return hashMap;
|
4008 | }, {});
|
4009 | }
|
4010 |
|
4011 | var toPaddingObject = function toPaddingObject(padding, state) {
|
4012 | padding = typeof padding === 'function' ? padding(Object.assign({}, state.rects, {
|
4013 | placement: state.placement
|
4014 | })) : padding;
|
4015 | return mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
|
4016 | };
|
4017 |
|
4018 | function arrow(_ref) {
|
4019 | var _state$modifiersData$;
|
4020 |
|
4021 | var state = _ref.state,
|
4022 | name = _ref.name,
|
4023 | options = _ref.options;
|
4024 | var arrowElement = state.elements.arrow;
|
4025 | var popperOffsets = state.modifiersData.popperOffsets;
|
4026 | var basePlacement = getBasePlacement(state.placement);
|
4027 | var axis = getMainAxisFromPlacement(basePlacement);
|
4028 | var isVertical = [left, right].indexOf(basePlacement) >= 0;
|
4029 | var len = isVertical ? 'height' : 'width';
|
4030 |
|
4031 | if (!arrowElement || !popperOffsets) {
|
4032 | return;
|
4033 | }
|
4034 |
|
4035 | var paddingObject = toPaddingObject(options.padding, state);
|
4036 | var arrowRect = getLayoutRect(arrowElement);
|
4037 | var minProp = axis === 'y' ? top : left;
|
4038 | var maxProp = axis === 'y' ? bottom : right;
|
4039 | var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
|
4040 | var startDiff = popperOffsets[axis] - state.rects.reference[axis];
|
4041 | var arrowOffsetParent = getOffsetParent(arrowElement);
|
4042 | var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
|
4043 | var centerToReference = endDiff / 2 - startDiff / 2;
|
4044 |
|
4045 |
|
4046 | var min = paddingObject[minProp];
|
4047 | var max = clientSize - arrowRect[len] - paddingObject[maxProp];
|
4048 | var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
|
4049 | var offset = within(min, center, max);
|
4050 |
|
4051 | var axisProp = axis;
|
4052 | state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);
|
4053 | }
|
4054 |
|
4055 | function effect$1(_ref2) {
|
4056 | var state = _ref2.state,
|
4057 | options = _ref2.options;
|
4058 | var _options$element = options.element,
|
4059 | arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element;
|
4060 |
|
4061 | if (arrowElement == null) {
|
4062 | return;
|
4063 | }
|
4064 |
|
4065 |
|
4066 | if (typeof arrowElement === 'string') {
|
4067 | arrowElement = state.elements.popper.querySelector(arrowElement);
|
4068 |
|
4069 | if (!arrowElement) {
|
4070 | return;
|
4071 | }
|
4072 | }
|
4073 |
|
4074 | if (!contains$1(state.elements.popper, arrowElement)) {
|
4075 | return;
|
4076 | }
|
4077 |
|
4078 | state.elements.arrow = arrowElement;
|
4079 | }
|
4080 |
|
4081 |
|
4082 | var arrow$1 = {
|
4083 | name: 'arrow',
|
4084 | enabled: true,
|
4085 | phase: 'main',
|
4086 | fn: arrow,
|
4087 | effect: effect$1,
|
4088 | requires: ['popperOffsets'],
|
4089 | requiresIfExists: ['preventOverflow']
|
4090 | };
|
4091 |
|
4092 | function getVariation(placement) {
|
4093 | return placement.split('-')[1];
|
4094 | }
|
4095 |
|
4096 | var unsetSides = {
|
4097 | top: 'auto',
|
4098 | right: 'auto',
|
4099 | bottom: 'auto',
|
4100 | left: 'auto'
|
4101 | };
|
4102 |
|
4103 |
|
4104 |
|
4105 | function roundOffsetsByDPR(_ref, win) {
|
4106 | var x = _ref.x,
|
4107 | y = _ref.y;
|
4108 | var dpr = win.devicePixelRatio || 1;
|
4109 | return {
|
4110 | x: round(x * dpr) / dpr || 0,
|
4111 | y: round(y * dpr) / dpr || 0
|
4112 | };
|
4113 | }
|
4114 |
|
4115 | function mapToStyles(_ref2) {
|
4116 | var _Object$assign2;
|
4117 |
|
4118 | var popper = _ref2.popper,
|
4119 | popperRect = _ref2.popperRect,
|
4120 | placement = _ref2.placement,
|
4121 | variation = _ref2.variation,
|
4122 | offsets = _ref2.offsets,
|
4123 | position = _ref2.position,
|
4124 | gpuAcceleration = _ref2.gpuAcceleration,
|
4125 | adaptive = _ref2.adaptive,
|
4126 | roundOffsets = _ref2.roundOffsets,
|
4127 | isFixed = _ref2.isFixed;
|
4128 | var _offsets$x = offsets.x,
|
4129 | x = _offsets$x === void 0 ? 0 : _offsets$x,
|
4130 | _offsets$y = offsets.y,
|
4131 | y = _offsets$y === void 0 ? 0 : _offsets$y;
|
4132 |
|
4133 | var _ref3 = typeof roundOffsets === 'function' ? roundOffsets({
|
4134 | x: x,
|
4135 | y: y
|
4136 | }) : {
|
4137 | x: x,
|
4138 | y: y
|
4139 | };
|
4140 |
|
4141 | x = _ref3.x;
|
4142 | y = _ref3.y;
|
4143 | var hasX = offsets.hasOwnProperty('x');
|
4144 | var hasY = offsets.hasOwnProperty('y');
|
4145 | var sideX = left;
|
4146 | var sideY = top;
|
4147 | var win = window;
|
4148 |
|
4149 | if (adaptive) {
|
4150 | var offsetParent = getOffsetParent(popper);
|
4151 | var heightProp = 'clientHeight';
|
4152 | var widthProp = 'clientWidth';
|
4153 |
|
4154 | if (offsetParent === getWindow(popper)) {
|
4155 | offsetParent = getDocumentElement(popper);
|
4156 |
|
4157 | if (getComputedStyle$1(offsetParent).position !== 'static' && position === 'absolute') {
|
4158 | heightProp = 'scrollHeight';
|
4159 | widthProp = 'scrollWidth';
|
4160 | }
|
4161 | }
|
4162 |
|
4163 |
|
4164 | offsetParent = offsetParent;
|
4165 |
|
4166 | if (placement === top || (placement === left || placement === right) && variation === end) {
|
4167 | sideY = bottom;
|
4168 | var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height :
|
4169 | offsetParent[heightProp];
|
4170 | y -= offsetY - popperRect.height;
|
4171 | y *= gpuAcceleration ? 1 : -1;
|
4172 | }
|
4173 |
|
4174 | if (placement === left || (placement === top || placement === bottom) && variation === end) {
|
4175 | sideX = right;
|
4176 | var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width :
|
4177 | offsetParent[widthProp];
|
4178 | x -= offsetX - popperRect.width;
|
4179 | x *= gpuAcceleration ? 1 : -1;
|
4180 | }
|
4181 | }
|
4182 |
|
4183 | var commonStyles = Object.assign({
|
4184 | position: position
|
4185 | }, adaptive && unsetSides);
|
4186 |
|
4187 | var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
|
4188 | x: x,
|
4189 | y: y
|
4190 | }, getWindow(popper)) : {
|
4191 | x: x,
|
4192 | y: y
|
4193 | };
|
4194 |
|
4195 | x = _ref4.x;
|
4196 | y = _ref4.y;
|
4197 |
|
4198 | if (gpuAcceleration) {
|
4199 | var _Object$assign;
|
4200 |
|
4201 | return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
|
4202 | }
|
4203 |
|
4204 | return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
|
4205 | }
|
4206 |
|
4207 | function computeStyles(_ref5) {
|
4208 | var state = _ref5.state,
|
4209 | options = _ref5.options;
|
4210 | var _options$gpuAccelerat = options.gpuAcceleration,
|
4211 | gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
|
4212 | _options$adaptive = options.adaptive,
|
4213 | adaptive = _options$adaptive === void 0 ? true : _options$adaptive,
|
4214 | _options$roundOffsets = options.roundOffsets,
|
4215 | roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
|
4216 | var commonStyles = {
|
4217 | placement: getBasePlacement(state.placement),
|
4218 | variation: getVariation(state.placement),
|
4219 | popper: state.elements.popper,
|
4220 | popperRect: state.rects.popper,
|
4221 | gpuAcceleration: gpuAcceleration,
|
4222 | isFixed: state.options.strategy === 'fixed'
|
4223 | };
|
4224 |
|
4225 | if (state.modifiersData.popperOffsets != null) {
|
4226 | state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
|
4227 | offsets: state.modifiersData.popperOffsets,
|
4228 | position: state.options.strategy,
|
4229 | adaptive: adaptive,
|
4230 | roundOffsets: roundOffsets
|
4231 | })));
|
4232 | }
|
4233 |
|
4234 | if (state.modifiersData.arrow != null) {
|
4235 | state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
|
4236 | offsets: state.modifiersData.arrow,
|
4237 | position: 'absolute',
|
4238 | adaptive: false,
|
4239 | roundOffsets: roundOffsets
|
4240 | })));
|
4241 | }
|
4242 |
|
4243 | state.attributes.popper = Object.assign({}, state.attributes.popper, {
|
4244 | 'data-popper-placement': state.placement
|
4245 | });
|
4246 | }
|
4247 |
|
4248 |
|
4249 | var computeStyles$1 = {
|
4250 | name: 'computeStyles',
|
4251 | enabled: true,
|
4252 | phase: 'beforeWrite',
|
4253 | fn: computeStyles,
|
4254 | data: {}
|
4255 | };
|
4256 |
|
4257 | var passive = {
|
4258 | passive: true
|
4259 | };
|
4260 |
|
4261 | function effect(_ref) {
|
4262 | var state = _ref.state,
|
4263 | instance = _ref.instance,
|
4264 | options = _ref.options;
|
4265 | var _options$scroll = options.scroll,
|
4266 | scroll = _options$scroll === void 0 ? true : _options$scroll,
|
4267 | _options$resize = options.resize,
|
4268 | resize = _options$resize === void 0 ? true : _options$resize;
|
4269 | var window = getWindow(state.elements.popper);
|
4270 | var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
|
4271 |
|
4272 | if (scroll) {
|
4273 | scrollParents.forEach(function (scrollParent) {
|
4274 | scrollParent.addEventListener('scroll', instance.update, passive);
|
4275 | });
|
4276 | }
|
4277 |
|
4278 | if (resize) {
|
4279 | window.addEventListener('resize', instance.update, passive);
|
4280 | }
|
4281 |
|
4282 | return function () {
|
4283 | if (scroll) {
|
4284 | scrollParents.forEach(function (scrollParent) {
|
4285 | scrollParent.removeEventListener('scroll', instance.update, passive);
|
4286 | });
|
4287 | }
|
4288 |
|
4289 | if (resize) {
|
4290 | window.removeEventListener('resize', instance.update, passive);
|
4291 | }
|
4292 | };
|
4293 | }
|
4294 |
|
4295 |
|
4296 | var eventListeners = {
|
4297 | name: 'eventListeners',
|
4298 | enabled: true,
|
4299 | phase: 'write',
|
4300 | fn: function fn() {},
|
4301 | effect: effect,
|
4302 | data: {}
|
4303 | };
|
4304 |
|
4305 | var hash$1 = {
|
4306 | left: 'right',
|
4307 | right: 'left',
|
4308 | bottom: 'top',
|
4309 | top: 'bottom'
|
4310 | };
|
4311 | function getOppositePlacement(placement) {
|
4312 | return placement.replace(/left|right|bottom|top/g, function (matched) {
|
4313 | return hash$1[matched];
|
4314 | });
|
4315 | }
|
4316 |
|
4317 | var hash = {
|
4318 | start: 'end',
|
4319 | end: 'start'
|
4320 | };
|
4321 | function getOppositeVariationPlacement(placement) {
|
4322 | return placement.replace(/start|end/g, function (matched) {
|
4323 | return hash[matched];
|
4324 | });
|
4325 | }
|
4326 |
|
4327 | function getWindowScroll(node) {
|
4328 | var win = getWindow(node);
|
4329 | var scrollLeft = win.pageXOffset;
|
4330 | var scrollTop = win.pageYOffset;
|
4331 | return {
|
4332 | scrollLeft: scrollLeft,
|
4333 | scrollTop: scrollTop
|
4334 | };
|
4335 | }
|
4336 |
|
4337 | function getWindowScrollBarX(element) {
|
4338 |
|
4339 |
|
4340 |
|
4341 |
|
4342 |
|
4343 |
|
4344 |
|
4345 | return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
|
4346 | }
|
4347 |
|
4348 | function getViewportRect(element, strategy) {
|
4349 | var win = getWindow(element);
|
4350 | var html = getDocumentElement(element);
|
4351 | var visualViewport = win.visualViewport;
|
4352 | var width = html.clientWidth;
|
4353 | var height = html.clientHeight;
|
4354 | var x = 0;
|
4355 | var y = 0;
|
4356 |
|
4357 | if (visualViewport) {
|
4358 | width = visualViewport.width;
|
4359 | height = visualViewport.height;
|
4360 | var layoutViewport = isLayoutViewport();
|
4361 |
|
4362 | if (layoutViewport || !layoutViewport && strategy === 'fixed') {
|
4363 | x = visualViewport.offsetLeft;
|
4364 | y = visualViewport.offsetTop;
|
4365 | }
|
4366 | }
|
4367 |
|
4368 | return {
|
4369 | width: width,
|
4370 | height: height,
|
4371 | x: x + getWindowScrollBarX(element),
|
4372 | y: y
|
4373 | };
|
4374 | }
|
4375 |
|
4376 |
|
4377 |
|
4378 | function getDocumentRect(element) {
|
4379 | var _element$ownerDocumen;
|
4380 |
|
4381 | var html = getDocumentElement(element);
|
4382 | var winScroll = getWindowScroll(element);
|
4383 | var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
|
4384 | var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
|
4385 | var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
|
4386 | var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
|
4387 | var y = -winScroll.scrollTop;
|
4388 |
|
4389 | if (getComputedStyle$1(body || html).direction === 'rtl') {
|
4390 | x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
|
4391 | }
|
4392 |
|
4393 | return {
|
4394 | width: width,
|
4395 | height: height,
|
4396 | x: x,
|
4397 | y: y
|
4398 | };
|
4399 | }
|
4400 |
|
4401 | function isScrollParent(element) {
|
4402 |
|
4403 | var _getComputedStyle = getComputedStyle$1(element),
|
4404 | overflow = _getComputedStyle.overflow,
|
4405 | overflowX = _getComputedStyle.overflowX,
|
4406 | overflowY = _getComputedStyle.overflowY;
|
4407 |
|
4408 | return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
|
4409 | }
|
4410 |
|
4411 | function getScrollParent(node) {
|
4412 | if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
|
4413 |
|
4414 | return node.ownerDocument.body;
|
4415 | }
|
4416 |
|
4417 | if (isHTMLElement(node) && isScrollParent(node)) {
|
4418 | return node;
|
4419 | }
|
4420 |
|
4421 | return getScrollParent(getParentNode(node));
|
4422 | }
|
4423 |
|
4424 | |
4425 |
|
4426 |
|
4427 |
|
4428 |
|
4429 |
|
4430 |
|
4431 | function listScrollParents(element, list) {
|
4432 | var _element$ownerDocumen;
|
4433 |
|
4434 | if (list === void 0) {
|
4435 | list = [];
|
4436 | }
|
4437 |
|
4438 | var scrollParent = getScrollParent(element);
|
4439 | var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
|
4440 | var win = getWindow(scrollParent);
|
4441 | var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
|
4442 | var updatedList = list.concat(target);
|
4443 | return isBody ? updatedList :
|
4444 | updatedList.concat(listScrollParents(getParentNode(target)));
|
4445 | }
|
4446 |
|
4447 | function rectToClientRect(rect) {
|
4448 | return Object.assign({}, rect, {
|
4449 | left: rect.x,
|
4450 | top: rect.y,
|
4451 | right: rect.x + rect.width,
|
4452 | bottom: rect.y + rect.height
|
4453 | });
|
4454 | }
|
4455 |
|
4456 | function getInnerBoundingClientRect(element, strategy) {
|
4457 | var rect = getBoundingClientRect(element, false, strategy === 'fixed');
|
4458 | rect.top = rect.top + element.clientTop;
|
4459 | rect.left = rect.left + element.clientLeft;
|
4460 | rect.bottom = rect.top + element.clientHeight;
|
4461 | rect.right = rect.left + element.clientWidth;
|
4462 | rect.width = element.clientWidth;
|
4463 | rect.height = element.clientHeight;
|
4464 | rect.x = rect.left;
|
4465 | rect.y = rect.top;
|
4466 | return rect;
|
4467 | }
|
4468 |
|
4469 | function getClientRectFromMixedType(element, clippingParent, strategy) {
|
4470 | return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
|
4471 | }
|
4472 |
|
4473 |
|
4474 |
|
4475 |
|
4476 | function getClippingParents(element) {
|
4477 | var clippingParents = listScrollParents(getParentNode(element));
|
4478 | var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle$1(element).position) >= 0;
|
4479 | var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
|
4480 |
|
4481 | if (!isElement(clipperElement)) {
|
4482 | return [];
|
4483 | }
|
4484 |
|
4485 |
|
4486 | return clippingParents.filter(function (clippingParent) {
|
4487 | return isElement(clippingParent) && contains$1(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
|
4488 | });
|
4489 | }
|
4490 |
|
4491 |
|
4492 |
|
4493 | function getClippingRect(element, boundary, rootBoundary, strategy) {
|
4494 | var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
|
4495 | var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
|
4496 | var firstClippingParent = clippingParents[0];
|
4497 | var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
|
4498 | var rect = getClientRectFromMixedType(element, clippingParent, strategy);
|
4499 | accRect.top = max(rect.top, accRect.top);
|
4500 | accRect.right = min(rect.right, accRect.right);
|
4501 | accRect.bottom = min(rect.bottom, accRect.bottom);
|
4502 | accRect.left = max(rect.left, accRect.left);
|
4503 | return accRect;
|
4504 | }, getClientRectFromMixedType(element, firstClippingParent, strategy));
|
4505 | clippingRect.width = clippingRect.right - clippingRect.left;
|
4506 | clippingRect.height = clippingRect.bottom - clippingRect.top;
|
4507 | clippingRect.x = clippingRect.left;
|
4508 | clippingRect.y = clippingRect.top;
|
4509 | return clippingRect;
|
4510 | }
|
4511 |
|
4512 | function computeOffsets(_ref) {
|
4513 | var reference = _ref.reference,
|
4514 | element = _ref.element,
|
4515 | placement = _ref.placement;
|
4516 | var basePlacement = placement ? getBasePlacement(placement) : null;
|
4517 | var variation = placement ? getVariation(placement) : null;
|
4518 | var commonX = reference.x + reference.width / 2 - element.width / 2;
|
4519 | var commonY = reference.y + reference.height / 2 - element.height / 2;
|
4520 | var offsets;
|
4521 |
|
4522 | switch (basePlacement) {
|
4523 | case top:
|
4524 | offsets = {
|
4525 | x: commonX,
|
4526 | y: reference.y - element.height
|
4527 | };
|
4528 | break;
|
4529 |
|
4530 | case bottom:
|
4531 | offsets = {
|
4532 | x: commonX,
|
4533 | y: reference.y + reference.height
|
4534 | };
|
4535 | break;
|
4536 |
|
4537 | case right:
|
4538 | offsets = {
|
4539 | x: reference.x + reference.width,
|
4540 | y: commonY
|
4541 | };
|
4542 | break;
|
4543 |
|
4544 | case left:
|
4545 | offsets = {
|
4546 | x: reference.x - element.width,
|
4547 | y: commonY
|
4548 | };
|
4549 | break;
|
4550 |
|
4551 | default:
|
4552 | offsets = {
|
4553 | x: reference.x,
|
4554 | y: reference.y
|
4555 | };
|
4556 | }
|
4557 |
|
4558 | var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
|
4559 |
|
4560 | if (mainAxis != null) {
|
4561 | var len = mainAxis === 'y' ? 'height' : 'width';
|
4562 |
|
4563 | switch (variation) {
|
4564 | case start:
|
4565 | offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
|
4566 | break;
|
4567 |
|
4568 | case end:
|
4569 | offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
|
4570 | break;
|
4571 | }
|
4572 | }
|
4573 |
|
4574 | return offsets;
|
4575 | }
|
4576 |
|
4577 | function detectOverflow(state, options) {
|
4578 | if (options === void 0) {
|
4579 | options = {};
|
4580 | }
|
4581 |
|
4582 | var _options = options,
|
4583 | _options$placement = _options.placement,
|
4584 | placement = _options$placement === void 0 ? state.placement : _options$placement,
|
4585 | _options$strategy = _options.strategy,
|
4586 | strategy = _options$strategy === void 0 ? state.strategy : _options$strategy,
|
4587 | _options$boundary = _options.boundary,
|
4588 | boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
|
4589 | _options$rootBoundary = _options.rootBoundary,
|
4590 | rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
|
4591 | _options$elementConte = _options.elementContext,
|
4592 | elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
|
4593 | _options$altBoundary = _options.altBoundary,
|
4594 | altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
|
4595 | _options$padding = _options.padding,
|
4596 | padding = _options$padding === void 0 ? 0 : _options$padding;
|
4597 | var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
|
4598 | var altContext = elementContext === popper ? reference : popper;
|
4599 | var popperRect = state.rects.popper;
|
4600 | var element = state.elements[altBoundary ? altContext : elementContext];
|
4601 | var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary, strategy);
|
4602 | var referenceClientRect = getBoundingClientRect(state.elements.reference);
|
4603 | var popperOffsets = computeOffsets({
|
4604 | reference: referenceClientRect,
|
4605 | element: popperRect,
|
4606 | strategy: 'absolute',
|
4607 | placement: placement
|
4608 | });
|
4609 | var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets));
|
4610 | var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect;
|
4611 |
|
4612 |
|
4613 | var overflowOffsets = {
|
4614 | top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
|
4615 | bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
|
4616 | left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
|
4617 | right: elementClientRect.right - clippingClientRect.right + paddingObject.right
|
4618 | };
|
4619 | var offsetData = state.modifiersData.offset;
|
4620 |
|
4621 | if (elementContext === popper && offsetData) {
|
4622 | var offset = offsetData[placement];
|
4623 | Object.keys(overflowOffsets).forEach(function (key) {
|
4624 | var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
|
4625 | var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
|
4626 | overflowOffsets[key] += offset[axis] * multiply;
|
4627 | });
|
4628 | }
|
4629 |
|
4630 | return overflowOffsets;
|
4631 | }
|
4632 |
|
4633 | function computeAutoPlacement(state, options) {
|
4634 | if (options === void 0) {
|
4635 | options = {};
|
4636 | }
|
4637 |
|
4638 | var _options = options,
|
4639 | placement = _options.placement,
|
4640 | boundary = _options.boundary,
|
4641 | rootBoundary = _options.rootBoundary,
|
4642 | padding = _options.padding,
|
4643 | flipVariations = _options.flipVariations,
|
4644 | _options$allowedAutoP = _options.allowedAutoPlacements,
|
4645 | allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP;
|
4646 | var variation = getVariation(placement);
|
4647 | var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) {
|
4648 | return getVariation(placement) === variation;
|
4649 | }) : basePlacements;
|
4650 | var allowedPlacements = placements$1.filter(function (placement) {
|
4651 | return allowedAutoPlacements.indexOf(placement) >= 0;
|
4652 | });
|
4653 |
|
4654 | if (allowedPlacements.length === 0) {
|
4655 | allowedPlacements = placements$1;
|
4656 | }
|
4657 |
|
4658 |
|
4659 | var overflows = allowedPlacements.reduce(function (acc, placement) {
|
4660 | acc[placement] = detectOverflow(state, {
|
4661 | placement: placement,
|
4662 | boundary: boundary,
|
4663 | rootBoundary: rootBoundary,
|
4664 | padding: padding
|
4665 | })[getBasePlacement(placement)];
|
4666 | return acc;
|
4667 | }, {});
|
4668 | return Object.keys(overflows).sort(function (a, b) {
|
4669 | return overflows[a] - overflows[b];
|
4670 | });
|
4671 | }
|
4672 |
|
4673 | function getExpandedFallbackPlacements(placement) {
|
4674 | if (getBasePlacement(placement) === auto) {
|
4675 | return [];
|
4676 | }
|
4677 |
|
4678 | var oppositePlacement = getOppositePlacement(placement);
|
4679 | return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];
|
4680 | }
|
4681 |
|
4682 | function flip(_ref) {
|
4683 | var state = _ref.state,
|
4684 | options = _ref.options,
|
4685 | name = _ref.name;
|
4686 |
|
4687 | if (state.modifiersData[name]._skip) {
|
4688 | return;
|
4689 | }
|
4690 |
|
4691 | var _options$mainAxis = options.mainAxis,
|
4692 | checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
|
4693 | _options$altAxis = options.altAxis,
|
4694 | checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis,
|
4695 | specifiedFallbackPlacements = options.fallbackPlacements,
|
4696 | padding = options.padding,
|
4697 | boundary = options.boundary,
|
4698 | rootBoundary = options.rootBoundary,
|
4699 | altBoundary = options.altBoundary,
|
4700 | _options$flipVariatio = options.flipVariations,
|
4701 | flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio,
|
4702 | allowedAutoPlacements = options.allowedAutoPlacements;
|
4703 | var preferredPlacement = state.options.placement;
|
4704 | var basePlacement = getBasePlacement(preferredPlacement);
|
4705 | var isBasePlacement = basePlacement === preferredPlacement;
|
4706 | var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
|
4707 | var placements = [preferredPlacement].concat(fallbackPlacements).reduce(function (acc, placement) {
|
4708 | return acc.concat(getBasePlacement(placement) === auto ? computeAutoPlacement(state, {
|
4709 | placement: placement,
|
4710 | boundary: boundary,
|
4711 | rootBoundary: rootBoundary,
|
4712 | padding: padding,
|
4713 | flipVariations: flipVariations,
|
4714 | allowedAutoPlacements: allowedAutoPlacements
|
4715 | }) : placement);
|
4716 | }, []);
|
4717 | var referenceRect = state.rects.reference;
|
4718 | var popperRect = state.rects.popper;
|
4719 | var checksMap = new Map();
|
4720 | var makeFallbackChecks = true;
|
4721 | var firstFittingPlacement = placements[0];
|
4722 |
|
4723 | for (var i = 0; i < placements.length; i++) {
|
4724 | var placement = placements[i];
|
4725 |
|
4726 | var _basePlacement = getBasePlacement(placement);
|
4727 |
|
4728 | var isStartVariation = getVariation(placement) === start;
|
4729 | var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
|
4730 | var len = isVertical ? 'width' : 'height';
|
4731 | var overflow = detectOverflow(state, {
|
4732 | placement: placement,
|
4733 | boundary: boundary,
|
4734 | rootBoundary: rootBoundary,
|
4735 | altBoundary: altBoundary,
|
4736 | padding: padding
|
4737 | });
|
4738 | var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
|
4739 |
|
4740 | if (referenceRect[len] > popperRect[len]) {
|
4741 | mainVariationSide = getOppositePlacement(mainVariationSide);
|
4742 | }
|
4743 |
|
4744 | var altVariationSide = getOppositePlacement(mainVariationSide);
|
4745 | var checks = [];
|
4746 |
|
4747 | if (checkMainAxis) {
|
4748 | checks.push(overflow[_basePlacement] <= 0);
|
4749 | }
|
4750 |
|
4751 | if (checkAltAxis) {
|
4752 | checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
|
4753 | }
|
4754 |
|
4755 | if (checks.every(function (check) {
|
4756 | return check;
|
4757 | })) {
|
4758 | firstFittingPlacement = placement;
|
4759 | makeFallbackChecks = false;
|
4760 | break;
|
4761 | }
|
4762 |
|
4763 | checksMap.set(placement, checks);
|
4764 | }
|
4765 |
|
4766 | if (makeFallbackChecks) {
|
4767 |
|
4768 | var numberOfChecks = flipVariations ? 3 : 1;
|
4769 |
|
4770 | var _loop = function _loop(_i) {
|
4771 | var fittingPlacement = placements.find(function (placement) {
|
4772 | var checks = checksMap.get(placement);
|
4773 |
|
4774 | if (checks) {
|
4775 | return checks.slice(0, _i).every(function (check) {
|
4776 | return check;
|
4777 | });
|
4778 | }
|
4779 | });
|
4780 |
|
4781 | if (fittingPlacement) {
|
4782 | firstFittingPlacement = fittingPlacement;
|
4783 | return "break";
|
4784 | }
|
4785 | };
|
4786 |
|
4787 | for (var _i = numberOfChecks; _i > 0; _i--) {
|
4788 | var _ret = _loop(_i);
|
4789 |
|
4790 | if (_ret === "break") break;
|
4791 | }
|
4792 | }
|
4793 |
|
4794 | if (state.placement !== firstFittingPlacement) {
|
4795 | state.modifiersData[name]._skip = true;
|
4796 | state.placement = firstFittingPlacement;
|
4797 | state.reset = true;
|
4798 | }
|
4799 | }
|
4800 |
|
4801 |
|
4802 | var flip$1 = {
|
4803 | name: 'flip',
|
4804 | enabled: true,
|
4805 | phase: 'main',
|
4806 | fn: flip,
|
4807 | requiresIfExists: ['offset'],
|
4808 | data: {
|
4809 | _skip: false
|
4810 | }
|
4811 | };
|
4812 |
|
4813 | function getSideOffsets(overflow, rect, preventedOffsets) {
|
4814 | if (preventedOffsets === void 0) {
|
4815 | preventedOffsets = {
|
4816 | x: 0,
|
4817 | y: 0
|
4818 | };
|
4819 | }
|
4820 |
|
4821 | return {
|
4822 | top: overflow.top - rect.height - preventedOffsets.y,
|
4823 | right: overflow.right - rect.width + preventedOffsets.x,
|
4824 | bottom: overflow.bottom - rect.height + preventedOffsets.y,
|
4825 | left: overflow.left - rect.width - preventedOffsets.x
|
4826 | };
|
4827 | }
|
4828 |
|
4829 | function isAnySideFullyClipped(overflow) {
|
4830 | return [top, right, bottom, left].some(function (side) {
|
4831 | return overflow[side] >= 0;
|
4832 | });
|
4833 | }
|
4834 |
|
4835 | function hide(_ref) {
|
4836 | var state = _ref.state,
|
4837 | name = _ref.name;
|
4838 | var referenceRect = state.rects.reference;
|
4839 | var popperRect = state.rects.popper;
|
4840 | var preventedOffsets = state.modifiersData.preventOverflow;
|
4841 | var referenceOverflow = detectOverflow(state, {
|
4842 | elementContext: 'reference'
|
4843 | });
|
4844 | var popperAltOverflow = detectOverflow(state, {
|
4845 | altBoundary: true
|
4846 | });
|
4847 | var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
|
4848 | var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
|
4849 | var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
|
4850 | var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
|
4851 | state.modifiersData[name] = {
|
4852 | referenceClippingOffsets: referenceClippingOffsets,
|
4853 | popperEscapeOffsets: popperEscapeOffsets,
|
4854 | isReferenceHidden: isReferenceHidden,
|
4855 | hasPopperEscaped: hasPopperEscaped
|
4856 | };
|
4857 | state.attributes.popper = Object.assign({}, state.attributes.popper, {
|
4858 | 'data-popper-reference-hidden': isReferenceHidden,
|
4859 | 'data-popper-escaped': hasPopperEscaped
|
4860 | });
|
4861 | }
|
4862 |
|
4863 |
|
4864 | var hide$1 = {
|
4865 | name: 'hide',
|
4866 | enabled: true,
|
4867 | phase: 'main',
|
4868 | requiresIfExists: ['preventOverflow'],
|
4869 | fn: hide
|
4870 | };
|
4871 |
|
4872 | function distanceAndSkiddingToXY(placement, rects, offset) {
|
4873 | var basePlacement = getBasePlacement(placement);
|
4874 | var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
|
4875 |
|
4876 | var _ref = typeof offset === 'function' ? offset(Object.assign({}, rects, {
|
4877 | placement: placement
|
4878 | })) : offset,
|
4879 | skidding = _ref[0],
|
4880 | distance = _ref[1];
|
4881 |
|
4882 | skidding = skidding || 0;
|
4883 | distance = (distance || 0) * invertDistance;
|
4884 | return [left, right].indexOf(basePlacement) >= 0 ? {
|
4885 | x: distance,
|
4886 | y: skidding
|
4887 | } : {
|
4888 | x: skidding,
|
4889 | y: distance
|
4890 | };
|
4891 | }
|
4892 |
|
4893 | function offset(_ref2) {
|
4894 | var state = _ref2.state,
|
4895 | options = _ref2.options,
|
4896 | name = _ref2.name;
|
4897 | var _options$offset = options.offset,
|
4898 | offset = _options$offset === void 0 ? [0, 0] : _options$offset;
|
4899 | var data = placements.reduce(function (acc, placement) {
|
4900 | acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
|
4901 | return acc;
|
4902 | }, {});
|
4903 | var _data$state$placement = data[state.placement],
|
4904 | x = _data$state$placement.x,
|
4905 | y = _data$state$placement.y;
|
4906 |
|
4907 | if (state.modifiersData.popperOffsets != null) {
|
4908 | state.modifiersData.popperOffsets.x += x;
|
4909 | state.modifiersData.popperOffsets.y += y;
|
4910 | }
|
4911 |
|
4912 | state.modifiersData[name] = data;
|
4913 | }
|
4914 |
|
4915 |
|
4916 | var offset$1 = {
|
4917 | name: 'offset',
|
4918 | enabled: true,
|
4919 | phase: 'main',
|
4920 | requires: ['popperOffsets'],
|
4921 | fn: offset
|
4922 | };
|
4923 |
|
4924 | function popperOffsets(_ref) {
|
4925 | var state = _ref.state,
|
4926 | name = _ref.name;
|
4927 |
|
4928 |
|
4929 |
|
4930 |
|
4931 | state.modifiersData[name] = computeOffsets({
|
4932 | reference: state.rects.reference,
|
4933 | element: state.rects.popper,
|
4934 | strategy: 'absolute',
|
4935 | placement: state.placement
|
4936 | });
|
4937 | }
|
4938 |
|
4939 |
|
4940 | var popperOffsets$1 = {
|
4941 | name: 'popperOffsets',
|
4942 | enabled: true,
|
4943 | phase: 'read',
|
4944 | fn: popperOffsets,
|
4945 | data: {}
|
4946 | };
|
4947 |
|
4948 | function getAltAxis(axis) {
|
4949 | return axis === 'x' ? 'y' : 'x';
|
4950 | }
|
4951 |
|
4952 | function preventOverflow(_ref) {
|
4953 | var state = _ref.state,
|
4954 | options = _ref.options,
|
4955 | name = _ref.name;
|
4956 | var _options$mainAxis = options.mainAxis,
|
4957 | checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
|
4958 | _options$altAxis = options.altAxis,
|
4959 | checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis,
|
4960 | boundary = options.boundary,
|
4961 | rootBoundary = options.rootBoundary,
|
4962 | altBoundary = options.altBoundary,
|
4963 | padding = options.padding,
|
4964 | _options$tether = options.tether,
|
4965 | tether = _options$tether === void 0 ? true : _options$tether,
|
4966 | _options$tetherOffset = options.tetherOffset,
|
4967 | tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
|
4968 | var overflow = detectOverflow(state, {
|
4969 | boundary: boundary,
|
4970 | rootBoundary: rootBoundary,
|
4971 | padding: padding,
|
4972 | altBoundary: altBoundary
|
4973 | });
|
4974 | var basePlacement = getBasePlacement(state.placement);
|
4975 | var variation = getVariation(state.placement);
|
4976 | var isBasePlacement = !variation;
|
4977 | var mainAxis = getMainAxisFromPlacement(basePlacement);
|
4978 | var altAxis = getAltAxis(mainAxis);
|
4979 | var popperOffsets = state.modifiersData.popperOffsets;
|
4980 | var referenceRect = state.rects.reference;
|
4981 | var popperRect = state.rects.popper;
|
4982 | var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
|
4983 | placement: state.placement
|
4984 | })) : tetherOffset;
|
4985 | var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? {
|
4986 | mainAxis: tetherOffsetValue,
|
4987 | altAxis: tetherOffsetValue
|
4988 | } : Object.assign({
|
4989 | mainAxis: 0,
|
4990 | altAxis: 0
|
4991 | }, tetherOffsetValue);
|
4992 | var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
|
4993 | var data = {
|
4994 | x: 0,
|
4995 | y: 0
|
4996 | };
|
4997 |
|
4998 | if (!popperOffsets) {
|
4999 | return;
|
5000 | }
|
5001 |
|
5002 | if (checkMainAxis) {
|
5003 | var _offsetModifierState$;
|
5004 |
|
5005 | var mainSide = mainAxis === 'y' ? top : left;
|
5006 | var altSide = mainAxis === 'y' ? bottom : right;
|
5007 | var len = mainAxis === 'y' ? 'height' : 'width';
|
5008 | var offset = popperOffsets[mainAxis];
|
5009 | var min$1 = offset + overflow[mainSide];
|
5010 | var max$1 = offset - overflow[altSide];
|
5011 | var additive = tether ? -popperRect[len] / 2 : 0;
|
5012 | var minLen = variation === start ? referenceRect[len] : popperRect[len];
|
5013 | var maxLen = variation === start ? -popperRect[len] : -referenceRect[len];
|
5014 |
|
5015 |
|
5016 | var arrowElement = state.elements.arrow;
|
5017 | var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
|
5018 | width: 0,
|
5019 | height: 0
|
5020 | };
|
5021 | var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject();
|
5022 | var arrowPaddingMin = arrowPaddingObject[mainSide];
|
5023 | var arrowPaddingMax = arrowPaddingObject[altSide];
|
5024 |
|
5025 |
|
5026 |
|
5027 |
|
5028 |
|
5029 | var arrowLen = within(0, referenceRect[len], arrowRect[len]);
|
5030 | var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
|
5031 | var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
|
5032 | var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
|
5033 | var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
|
5034 | var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
|
5035 | var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;
|
5036 | var tetherMax = offset + maxOffset - offsetModifierValue;
|
5037 | var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
|
5038 | popperOffsets[mainAxis] = preventedOffset;
|
5039 | data[mainAxis] = preventedOffset - offset;
|
5040 | }
|
5041 |
|
5042 | if (checkAltAxis) {
|
5043 | var _offsetModifierState$2;
|
5044 |
|
5045 | var _mainSide = mainAxis === 'x' ? top : left;
|
5046 |
|
5047 | var _altSide = mainAxis === 'x' ? bottom : right;
|
5048 |
|
5049 | var _offset = popperOffsets[altAxis];
|
5050 |
|
5051 | var _len = altAxis === 'y' ? 'height' : 'width';
|
5052 |
|
5053 | var _min = _offset + overflow[_mainSide];
|
5054 |
|
5055 | var _max = _offset - overflow[_altSide];
|
5056 |
|
5057 | var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
|
5058 |
|
5059 | var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
|
5060 |
|
5061 | var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
|
5062 |
|
5063 | var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
|
5064 |
|
5065 | var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
|
5066 |
|
5067 | popperOffsets[altAxis] = _preventedOffset;
|
5068 | data[altAxis] = _preventedOffset - _offset;
|
5069 | }
|
5070 |
|
5071 | state.modifiersData[name] = data;
|
5072 | }
|
5073 |
|
5074 |
|
5075 | var preventOverflow$1 = {
|
5076 | name: 'preventOverflow',
|
5077 | enabled: true,
|
5078 | phase: 'main',
|
5079 | fn: preventOverflow,
|
5080 | requiresIfExists: ['offset']
|
5081 | };
|
5082 |
|
5083 | function getHTMLElementScroll(element) {
|
5084 | return {
|
5085 | scrollLeft: element.scrollLeft,
|
5086 | scrollTop: element.scrollTop
|
5087 | };
|
5088 | }
|
5089 |
|
5090 | function getNodeScroll(node) {
|
5091 | if (node === getWindow(node) || !isHTMLElement(node)) {
|
5092 | return getWindowScroll(node);
|
5093 | } else {
|
5094 | return getHTMLElementScroll(node);
|
5095 | }
|
5096 | }
|
5097 |
|
5098 | function isElementScaled(element) {
|
5099 | var rect = element.getBoundingClientRect();
|
5100 | var scaleX = round(rect.width) / element.offsetWidth || 1;
|
5101 | var scaleY = round(rect.height) / element.offsetHeight || 1;
|
5102 | return scaleX !== 1 || scaleY !== 1;
|
5103 | }
|
5104 |
|
5105 |
|
5106 |
|
5107 | function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
|
5108 | if (isFixed === void 0) {
|
5109 | isFixed = false;
|
5110 | }
|
5111 |
|
5112 | var isOffsetParentAnElement = isHTMLElement(offsetParent);
|
5113 | var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
|
5114 | var documentElement = getDocumentElement(offsetParent);
|
5115 | var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
|
5116 | var scroll = {
|
5117 | scrollLeft: 0,
|
5118 | scrollTop: 0
|
5119 | };
|
5120 | var offsets = {
|
5121 | x: 0,
|
5122 | y: 0
|
5123 | };
|
5124 |
|
5125 | if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
5126 | if (getNodeName(offsetParent) !== 'body' ||
|
5127 | isScrollParent(documentElement)) {
|
5128 | scroll = getNodeScroll(offsetParent);
|
5129 | }
|
5130 |
|
5131 | if (isHTMLElement(offsetParent)) {
|
5132 | offsets = getBoundingClientRect(offsetParent, true);
|
5133 | offsets.x += offsetParent.clientLeft;
|
5134 | offsets.y += offsetParent.clientTop;
|
5135 | } else if (documentElement) {
|
5136 | offsets.x = getWindowScrollBarX(documentElement);
|
5137 | }
|
5138 | }
|
5139 |
|
5140 | return {
|
5141 | x: rect.left + scroll.scrollLeft - offsets.x,
|
5142 | y: rect.top + scroll.scrollTop - offsets.y,
|
5143 | width: rect.width,
|
5144 | height: rect.height
|
5145 | };
|
5146 | }
|
5147 |
|
5148 | function order(modifiers) {
|
5149 | var map = new Map();
|
5150 | var visited = new Set();
|
5151 | var result = [];
|
5152 | modifiers.forEach(function (modifier) {
|
5153 | map.set(modifier.name, modifier);
|
5154 | });
|
5155 |
|
5156 | function sort(modifier) {
|
5157 | visited.add(modifier.name);
|
5158 | var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
|
5159 | requires.forEach(function (dep) {
|
5160 | if (!visited.has(dep)) {
|
5161 | var depModifier = map.get(dep);
|
5162 |
|
5163 | if (depModifier) {
|
5164 | sort(depModifier);
|
5165 | }
|
5166 | }
|
5167 | });
|
5168 | result.push(modifier);
|
5169 | }
|
5170 |
|
5171 | modifiers.forEach(function (modifier) {
|
5172 | if (!visited.has(modifier.name)) {
|
5173 |
|
5174 | sort(modifier);
|
5175 | }
|
5176 | });
|
5177 | return result;
|
5178 | }
|
5179 |
|
5180 | function orderModifiers(modifiers) {
|
5181 |
|
5182 | var orderedModifiers = order(modifiers);
|
5183 |
|
5184 | return modifierPhases.reduce(function (acc, phase) {
|
5185 | return acc.concat(orderedModifiers.filter(function (modifier) {
|
5186 | return modifier.phase === phase;
|
5187 | }));
|
5188 | }, []);
|
5189 | }
|
5190 |
|
5191 | function debounce(fn) {
|
5192 | var pending;
|
5193 | return function () {
|
5194 | if (!pending) {
|
5195 | pending = new Promise(function (resolve) {
|
5196 | Promise.resolve().then(function () {
|
5197 | pending = undefined;
|
5198 | resolve(fn());
|
5199 | });
|
5200 | });
|
5201 | }
|
5202 |
|
5203 | return pending;
|
5204 | };
|
5205 | }
|
5206 |
|
5207 | function mergeByName(modifiers) {
|
5208 | var merged = modifiers.reduce(function (merged, current) {
|
5209 | var existing = merged[current.name];
|
5210 | merged[current.name] = existing ? Object.assign({}, existing, current, {
|
5211 | options: Object.assign({}, existing.options, current.options),
|
5212 | data: Object.assign({}, existing.data, current.data)
|
5213 | }) : current;
|
5214 | return merged;
|
5215 | }, {});
|
5216 |
|
5217 | return Object.keys(merged).map(function (key) {
|
5218 | return merged[key];
|
5219 | });
|
5220 | }
|
5221 |
|
5222 | var DEFAULT_OPTIONS = {
|
5223 | placement: 'bottom',
|
5224 | modifiers: [],
|
5225 | strategy: 'absolute'
|
5226 | };
|
5227 |
|
5228 | function areValidElements() {
|
5229 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
5230 | args[_key] = arguments[_key];
|
5231 | }
|
5232 |
|
5233 | return !args.some(function (element) {
|
5234 | return !(element && typeof element.getBoundingClientRect === 'function');
|
5235 | });
|
5236 | }
|
5237 |
|
5238 | function popperGenerator(generatorOptions) {
|
5239 | if (generatorOptions === void 0) {
|
5240 | generatorOptions = {};
|
5241 | }
|
5242 |
|
5243 | var _generatorOptions = generatorOptions,
|
5244 | _generatorOptions$def = _generatorOptions.defaultModifiers,
|
5245 | defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,
|
5246 | _generatorOptions$def2 = _generatorOptions.defaultOptions,
|
5247 | defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
|
5248 | return function createPopper(reference, popper, options) {
|
5249 | if (options === void 0) {
|
5250 | options = defaultOptions;
|
5251 | }
|
5252 |
|
5253 | var state = {
|
5254 | placement: 'bottom',
|
5255 | orderedModifiers: [],
|
5256 | options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
|
5257 | modifiersData: {},
|
5258 | elements: {
|
5259 | reference: reference,
|
5260 | popper: popper
|
5261 | },
|
5262 | attributes: {},
|
5263 | styles: {}
|
5264 | };
|
5265 | var effectCleanupFns = [];
|
5266 | var isDestroyed = false;
|
5267 | var instance = {
|
5268 | state: state,
|
5269 | setOptions: function setOptions(setOptionsAction) {
|
5270 | var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;
|
5271 | cleanupModifierEffects();
|
5272 | state.options = Object.assign({}, defaultOptions, state.options, options);
|
5273 | state.scrollParents = {
|
5274 | reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
|
5275 | popper: listScrollParents(popper)
|
5276 | };
|
5277 |
|
5278 |
|
5279 | var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers)));
|
5280 |
|
5281 | state.orderedModifiers = orderedModifiers.filter(function (m) {
|
5282 | return m.enabled;
|
5283 | });
|
5284 | runModifierEffects();
|
5285 | return instance.update();
|
5286 | },
|
5287 |
|
5288 |
|
5289 |
|
5290 |
|
5291 |
|
5292 | forceUpdate: function forceUpdate() {
|
5293 | if (isDestroyed) {
|
5294 | return;
|
5295 | }
|
5296 |
|
5297 | var _state$elements = state.elements,
|
5298 | reference = _state$elements.reference,
|
5299 | popper = _state$elements.popper;
|
5300 |
|
5301 |
|
5302 | if (!areValidElements(reference, popper)) {
|
5303 | return;
|
5304 | }
|
5305 |
|
5306 |
|
5307 | state.rects = {
|
5308 | reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),
|
5309 | popper: getLayoutRect(popper)
|
5310 | };
|
5311 |
|
5312 |
|
5313 |
|
5314 |
|
5315 |
|
5316 | state.reset = false;
|
5317 | state.placement = state.options.placement;
|
5318 |
|
5319 |
|
5320 |
|
5321 |
|
5322 | state.orderedModifiers.forEach(function (modifier) {
|
5323 | return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
|
5324 | });
|
5325 |
|
5326 | for (var index = 0; index < state.orderedModifiers.length; index++) {
|
5327 | if (state.reset === true) {
|
5328 | state.reset = false;
|
5329 | index = -1;
|
5330 | continue;
|
5331 | }
|
5332 |
|
5333 | var _state$orderedModifie = state.orderedModifiers[index],
|
5334 | fn = _state$orderedModifie.fn,
|
5335 | _state$orderedModifie2 = _state$orderedModifie.options,
|
5336 | _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,
|
5337 | name = _state$orderedModifie.name;
|
5338 |
|
5339 | if (typeof fn === 'function') {
|
5340 | state = fn({
|
5341 | state: state,
|
5342 | options: _options,
|
5343 | name: name,
|
5344 | instance: instance
|
5345 | }) || state;
|
5346 | }
|
5347 | }
|
5348 | },
|
5349 |
|
5350 |
|
5351 | update: debounce(function () {
|
5352 | return new Promise(function (resolve) {
|
5353 | instance.forceUpdate();
|
5354 | resolve(state);
|
5355 | });
|
5356 | }),
|
5357 | destroy: function destroy() {
|
5358 | cleanupModifierEffects();
|
5359 | isDestroyed = true;
|
5360 | }
|
5361 | };
|
5362 |
|
5363 | if (!areValidElements(reference, popper)) {
|
5364 | return instance;
|
5365 | }
|
5366 |
|
5367 | instance.setOptions(options).then(function (state) {
|
5368 | if (!isDestroyed && options.onFirstUpdate) {
|
5369 | options.onFirstUpdate(state);
|
5370 | }
|
5371 | });
|
5372 |
|
5373 |
|
5374 |
|
5375 |
|
5376 |
|
5377 | function runModifierEffects() {
|
5378 | state.orderedModifiers.forEach(function (_ref) {
|
5379 | var name = _ref.name,
|
5380 | _ref$options = _ref.options,
|
5381 | options = _ref$options === void 0 ? {} : _ref$options,
|
5382 | effect = _ref.effect;
|
5383 |
|
5384 | if (typeof effect === 'function') {
|
5385 | var cleanupFn = effect({
|
5386 | state: state,
|
5387 | name: name,
|
5388 | instance: instance,
|
5389 | options: options
|
5390 | });
|
5391 |
|
5392 | var noopFn = function noopFn() {};
|
5393 |
|
5394 | effectCleanupFns.push(cleanupFn || noopFn);
|
5395 | }
|
5396 | });
|
5397 | }
|
5398 |
|
5399 | function cleanupModifierEffects() {
|
5400 | effectCleanupFns.forEach(function (fn) {
|
5401 | return fn();
|
5402 | });
|
5403 | effectCleanupFns = [];
|
5404 | }
|
5405 |
|
5406 | return instance;
|
5407 | };
|
5408 | }
|
5409 |
|
5410 | var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
|
5411 | var createPopper = popperGenerator({
|
5412 | defaultModifiers: defaultModifiers
|
5413 | });
|
5414 |
|
5415 |
|
5416 |
|
5417 | var hasElementType = typeof Element !== 'undefined';
|
5418 | var hasMap = typeof Map === 'function';
|
5419 | var hasSet = typeof Set === 'function';
|
5420 | var hasArrayBuffer = typeof ArrayBuffer === 'function' && !!ArrayBuffer.isView;
|
5421 |
|
5422 |
|
5423 |
|
5424 | function equal(a, b) {
|
5425 |
|
5426 | if (a === b) return true;
|
5427 |
|
5428 | if (a && b && typeof a == 'object' && typeof b == 'object') {
|
5429 | if (a.constructor !== b.constructor) return false;
|
5430 |
|
5431 | var length, i, keys;
|
5432 | if (Array.isArray(a)) {
|
5433 | length = a.length;
|
5434 | if (length != b.length) return false;
|
5435 | for (i = length; i-- !== 0;)
|
5436 | if (!equal(a[i], b[i])) return false;
|
5437 | return true;
|
5438 | }
|
5439 |
|
5440 |
|
5441 |
|
5442 |
|
5443 |
|
5444 |
|
5445 |
|
5446 |
|
5447 |
|
5448 |
|
5449 |
|
5450 |
|
5451 |
|
5452 |
|
5453 |
|
5454 |
|
5455 |
|
5456 |
|
5457 |
|
5458 |
|
5459 |
|
5460 | var it;
|
5461 | if (hasMap && (a instanceof Map) && (b instanceof Map)) {
|
5462 | if (a.size !== b.size) return false;
|
5463 | it = a.entries();
|
5464 | while (!(i = it.next()).done)
|
5465 | if (!b.has(i.value[0])) return false;
|
5466 | it = a.entries();
|
5467 | while (!(i = it.next()).done)
|
5468 | if (!equal(i.value[1], b.get(i.value[0]))) return false;
|
5469 | return true;
|
5470 | }
|
5471 |
|
5472 | if (hasSet && (a instanceof Set) && (b instanceof Set)) {
|
5473 | if (a.size !== b.size) return false;
|
5474 | it = a.entries();
|
5475 | while (!(i = it.next()).done)
|
5476 | if (!b.has(i.value[0])) return false;
|
5477 | return true;
|
5478 | }
|
5479 |
|
5480 |
|
5481 | if (hasArrayBuffer && ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {
|
5482 | length = a.length;
|
5483 | if (length != b.length) return false;
|
5484 | for (i = length; i-- !== 0;)
|
5485 | if (a[i] !== b[i]) return false;
|
5486 | return true;
|
5487 | }
|
5488 |
|
5489 | if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
|
5490 |
|
5491 |
|
5492 |
|
5493 |
|
5494 | if (a.valueOf !== Object.prototype.valueOf && typeof a.valueOf === 'function' && typeof b.valueOf === 'function') return a.valueOf() === b.valueOf();
|
5495 | if (a.toString !== Object.prototype.toString && typeof a.toString === 'function' && typeof b.toString === 'function') return a.toString() === b.toString();
|
5496 |
|
5497 |
|
5498 | keys = Object.keys(a);
|
5499 | length = keys.length;
|
5500 | if (length !== Object.keys(b).length) return false;
|
5501 |
|
5502 | for (i = length; i-- !== 0;)
|
5503 | if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
|
5504 |
|
5505 |
|
5506 |
|
5507 |
|
5508 | if (hasElementType && a instanceof Element) return false;
|
5509 |
|
5510 |
|
5511 | for (i = length; i-- !== 0;) {
|
5512 | if ((keys[i] === '_owner' || keys[i] === '__v' || keys[i] === '__o') && a.$$typeof) {
|
5513 |
|
5514 |
|
5515 |
|
5516 |
|
5517 |
|
5518 |
|
5519 |
|
5520 |
|
5521 | continue;
|
5522 | }
|
5523 |
|
5524 |
|
5525 | if (!equal(a[keys[i]], b[keys[i]])) return false;
|
5526 | }
|
5527 |
|
5528 |
|
5529 |
|
5530 | return true;
|
5531 | }
|
5532 |
|
5533 | return a !== a && b !== b;
|
5534 | }
|
5535 |
|
5536 |
|
5537 | var reactFastCompare = function isEqual(a, b) {
|
5538 | try {
|
5539 | return equal(a, b);
|
5540 | } catch (error) {
|
5541 | if (((error.message || '').match(/stack|recursion/i))) {
|
5542 |
|
5543 |
|
5544 |
|
5545 |
|
5546 |
|
5547 | console.warn('react-fast-compare cannot handle circular refs');
|
5548 | return false;
|
5549 | }
|
5550 |
|
5551 | throw error;
|
5552 | }
|
5553 | };
|
5554 |
|
5555 | var EMPTY_MODIFIERS = [];
|
5556 | var usePopper = function usePopper(referenceElement, popperElement, options) {
|
5557 | if (options === void 0) {
|
5558 | options = {};
|
5559 | }
|
5560 |
|
5561 | var prevOptions = React__namespace.useRef(null);
|
5562 | var optionsWithDefaults = {
|
5563 | onFirstUpdate: options.onFirstUpdate,
|
5564 | placement: options.placement || 'bottom',
|
5565 | strategy: options.strategy || 'absolute',
|
5566 | modifiers: options.modifiers || EMPTY_MODIFIERS
|
5567 | };
|
5568 |
|
5569 | var _React$useState = React__namespace.useState({
|
5570 | styles: {
|
5571 | popper: {
|
5572 | position: optionsWithDefaults.strategy,
|
5573 | left: '0',
|
5574 | top: '0'
|
5575 | },
|
5576 | arrow: {
|
5577 | position: 'absolute'
|
5578 | }
|
5579 | },
|
5580 | attributes: {}
|
5581 | }),
|
5582 | state = _React$useState[0],
|
5583 | setState = _React$useState[1];
|
5584 |
|
5585 | var updateStateModifier = React__namespace.useMemo(function () {
|
5586 | return {
|
5587 | name: 'updateState',
|
5588 | enabled: true,
|
5589 | phase: 'write',
|
5590 | fn: function fn(_ref) {
|
5591 | var state = _ref.state;
|
5592 | var elements = Object.keys(state.elements);
|
5593 | ReactDOM__namespace.flushSync(function () {
|
5594 | setState({
|
5595 | styles: fromEntries(elements.map(function (element) {
|
5596 | return [element, state.styles[element] || {}];
|
5597 | })),
|
5598 | attributes: fromEntries(elements.map(function (element) {
|
5599 | return [element, state.attributes[element]];
|
5600 | }))
|
5601 | });
|
5602 | });
|
5603 | },
|
5604 | requires: ['computeStyles']
|
5605 | };
|
5606 | }, []);
|
5607 | var popperOptions = React__namespace.useMemo(function () {
|
5608 | var newOptions = {
|
5609 | onFirstUpdate: optionsWithDefaults.onFirstUpdate,
|
5610 | placement: optionsWithDefaults.placement,
|
5611 | strategy: optionsWithDefaults.strategy,
|
5612 | modifiers: [].concat(optionsWithDefaults.modifiers, [updateStateModifier, {
|
5613 | name: 'applyStyles',
|
5614 | enabled: false
|
5615 | }])
|
5616 | };
|
5617 |
|
5618 | if (reactFastCompare(prevOptions.current, newOptions)) {
|
5619 | return prevOptions.current || newOptions;
|
5620 | } else {
|
5621 | prevOptions.current = newOptions;
|
5622 | return newOptions;
|
5623 | }
|
5624 | }, [optionsWithDefaults.onFirstUpdate, optionsWithDefaults.placement, optionsWithDefaults.strategy, optionsWithDefaults.modifiers, updateStateModifier]);
|
5625 | var popperInstanceRef = React__namespace.useRef();
|
5626 | useIsomorphicLayoutEffect(function () {
|
5627 | if (popperInstanceRef.current) {
|
5628 | popperInstanceRef.current.setOptions(popperOptions);
|
5629 | }
|
5630 | }, [popperOptions]);
|
5631 | useIsomorphicLayoutEffect(function () {
|
5632 | if (referenceElement == null || popperElement == null) {
|
5633 | return;
|
5634 | }
|
5635 |
|
5636 | var createPopper$1 = options.createPopper || createPopper;
|
5637 | var popperInstance = createPopper$1(referenceElement, popperElement, popperOptions);
|
5638 | popperInstanceRef.current = popperInstance;
|
5639 | return function () {
|
5640 | popperInstance.destroy();
|
5641 | popperInstanceRef.current = null;
|
5642 | };
|
5643 | }, [referenceElement, popperElement, options.createPopper]);
|
5644 | return {
|
5645 | state: popperInstanceRef.current ? popperInstanceRef.current.state : null,
|
5646 | styles: state.styles,
|
5647 | attributes: state.attributes,
|
5648 | update: popperInstanceRef.current ? popperInstanceRef.current.update : null,
|
5649 | forceUpdate: popperInstanceRef.current ? popperInstanceRef.current.forceUpdate : null
|
5650 | };
|
5651 | };
|
5652 |
|
5653 | var setPopperWidth = {
|
5654 | enabled: true,
|
5655 | fn: function fn(data) {
|
5656 |
|
5657 | data.state.styles.popper.width = "".concat(data.state.rects.reference.width, "px");
|
5658 | },
|
5659 | name: 'setPopperWidth',
|
5660 | phase: 'write'
|
5661 | };
|
5662 | function getModifiers(props) {
|
5663 | var modifiers = [{
|
5664 | enabled: !!props.flip,
|
5665 | name: 'flip'
|
5666 | }];
|
5667 | if (props.align !== 'right' && props.align !== 'left') {
|
5668 | modifiers.push(setPopperWidth);
|
5669 | }
|
5670 | return modifiers;
|
5671 | }
|
5672 | function getPlacement(props) {
|
5673 | var x = props.align === 'right' ? 'end' : 'start';
|
5674 | var y = props.dropup ? 'top' : 'bottom';
|
5675 | return "".concat(y, "-").concat(x);
|
5676 | }
|
5677 | function useOverlay(referenceElement, options) {
|
5678 | var _useState = React.useState(null),
|
5679 | _useState2 = _slicedToArray(_useState, 2),
|
5680 | popperElement = _useState2[0],
|
5681 | attachRef = _useState2[1];
|
5682 | var _usePopper = usePopper(referenceElement, popperElement, {
|
5683 | modifiers: getModifiers(options),
|
5684 | placement: getPlacement(options),
|
5685 | strategy: options.positionFixed ? 'fixed' : 'absolute'
|
5686 | }),
|
5687 | attributes = _usePopper.attributes,
|
5688 | styles = _usePopper.styles,
|
5689 | forceUpdate = _usePopper.forceUpdate;
|
5690 | var refElementHeight = referenceElement === null || referenceElement === void 0 ? void 0 : referenceElement.offsetHeight;
|
5691 |
|
5692 |
|
5693 |
|
5694 | React.useEffect(function () {
|
5695 | forceUpdate && forceUpdate();
|
5696 | }, [refElementHeight]);
|
5697 |
|
5698 | return _objectSpread2(_objectSpread2({}, attributes.popper), {}, {
|
5699 | innerRef: attachRef,
|
5700 | style: styles.popper
|
5701 | });
|
5702 | }
|
5703 |
|
5704 | var _excluded$9 = ["referenceElement", "isMenuShown"];
|
5705 |
|
5706 |
|
5707 |
|
5708 | var SafeElement = typeof Element === 'undefined' ? noop$1 : Element;
|
5709 | var propTypes$6 = {
|
5710 | |
5711 |
|
5712 |
|
5713 |
|
5714 |
|
5715 |
|
5716 | align: propTypes$b.exports.oneOf(ALIGN_VALUES),
|
5717 | children: propTypes$b.exports.func.isRequired,
|
5718 | |
5719 |
|
5720 |
|
5721 | dropup: propTypes$b.exports.bool,
|
5722 | |
5723 |
|
5724 |
|
5725 |
|
5726 | flip: propTypes$b.exports.bool,
|
5727 | isMenuShown: propTypes$b.exports.bool,
|
5728 | positionFixed: propTypes$b.exports.bool,
|
5729 |
|
5730 | referenceElement: propTypes$b.exports.instanceOf(SafeElement)
|
5731 | };
|
5732 | var Overlay = function Overlay(_ref) {
|
5733 | var referenceElement = _ref.referenceElement,
|
5734 | isMenuShown = _ref.isMenuShown,
|
5735 | props = _objectWithoutProperties(_ref, _excluded$9);
|
5736 | var overlayProps = useOverlay(referenceElement, props);
|
5737 | if (!isMenuShown) {
|
5738 | return null;
|
5739 | }
|
5740 | return props.children(overlayProps);
|
5741 | };
|
5742 | Overlay.propTypes = propTypes$6;
|
5743 |
|
5744 |
|
5745 |
|
5746 | |
5747 |
|
5748 |
|
5749 |
|
5750 |
|
5751 |
|
5752 | function contains(context, node) {
|
5753 |
|
5754 |
|
5755 | if (context.contains) return context.contains(node);
|
5756 | if (context.compareDocumentPosition) return context === node || !!(context.compareDocumentPosition(node) & 16);
|
5757 | }
|
5758 |
|
5759 | var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
|
5760 |
|
5761 |
|
5762 | var optionsSupported = false;
|
5763 | var onceSupported = false;
|
5764 |
|
5765 | try {
|
5766 | var options = {
|
5767 | get passive() {
|
5768 | return optionsSupported = true;
|
5769 | },
|
5770 |
|
5771 | get once() {
|
5772 |
|
5773 | return onceSupported = optionsSupported = true;
|
5774 | }
|
5775 |
|
5776 | };
|
5777 |
|
5778 | if (canUseDOM) {
|
5779 | window.addEventListener('test', options, options);
|
5780 | window.removeEventListener('test', options, true);
|
5781 | }
|
5782 | } catch (e) {
|
5783 |
|
5784 | }
|
5785 |
|
5786 | |
5787 |
|
5788 |
|
5789 |
|
5790 |
|
5791 |
|
5792 |
|
5793 |
|
5794 | function addEventListener(node, eventName, handler, options) {
|
5795 | if (options && typeof options !== 'boolean' && !onceSupported) {
|
5796 | var once = options.once,
|
5797 | capture = options.capture;
|
5798 | var wrappedHandler = handler;
|
5799 |
|
5800 | if (!onceSupported && once) {
|
5801 | wrappedHandler = handler.__once || function onceHandler(event) {
|
5802 | this.removeEventListener(eventName, onceHandler, capture);
|
5803 | handler.call(this, event);
|
5804 | };
|
5805 |
|
5806 | handler.__once = wrappedHandler;
|
5807 | }
|
5808 |
|
5809 | node.addEventListener(eventName, wrappedHandler, optionsSupported ? options : capture);
|
5810 | }
|
5811 |
|
5812 | node.addEventListener(eventName, handler, options);
|
5813 | }
|
5814 |
|
5815 | |
5816 |
|
5817 |
|
5818 |
|
5819 |
|
5820 |
|
5821 |
|
5822 |
|
5823 | function removeEventListener(node, eventName, handler, options) {
|
5824 | var capture = options && typeof options !== 'boolean' ? options.capture : options;
|
5825 | node.removeEventListener(eventName, handler, capture);
|
5826 |
|
5827 | if (handler.__once) {
|
5828 | node.removeEventListener(eventName, handler.__once, capture);
|
5829 | }
|
5830 | }
|
5831 |
|
5832 | function listen(node, eventName, handler, options) {
|
5833 | addEventListener(node, eventName, handler, options);
|
5834 | return function () {
|
5835 | removeEventListener(node, eventName, handler, options);
|
5836 | };
|
5837 | }
|
5838 |
|
5839 | |
5840 |
|
5841 |
|
5842 |
|
5843 |
|
5844 |
|
5845 |
|
5846 |
|
5847 |
|
5848 | function useCommittedRef(value) {
|
5849 | const ref = React.useRef(value);
|
5850 | React.useEffect(() => {
|
5851 | ref.current = value;
|
5852 | }, [value]);
|
5853 | return ref;
|
5854 | }
|
5855 |
|
5856 | function useEventCallback(fn) {
|
5857 | const ref = useCommittedRef(fn);
|
5858 | return React.useCallback(function (...args) {
|
5859 | return ref.current && ref.current(...args);
|
5860 | }, [ref]);
|
5861 | }
|
5862 |
|
5863 | |
5864 |
|
5865 |
|
5866 |
|
5867 |
|
5868 | function ownerDocument$1(node) {
|
5869 | return node && node.ownerDocument || document;
|
5870 | }
|
5871 |
|
5872 | function safeFindDOMNode(componentOrElement) {
|
5873 | if (componentOrElement && 'setState' in componentOrElement) {
|
5874 | return ReactDOM__default["default"].findDOMNode(componentOrElement);
|
5875 | }
|
5876 |
|
5877 | return componentOrElement != null ? componentOrElement : null;
|
5878 | }
|
5879 |
|
5880 | var ownerDocument = (function (componentOrElement) {
|
5881 | return ownerDocument$1(safeFindDOMNode(componentOrElement));
|
5882 | });
|
5883 |
|
5884 | var escapeKeyCode = 27;
|
5885 |
|
5886 | var noop = function noop() {};
|
5887 |
|
5888 | function isLeftClickEvent(event) {
|
5889 | return event.button === 0;
|
5890 | }
|
5891 |
|
5892 | function isModifiedEvent(event) {
|
5893 | return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
|
5894 | }
|
5895 |
|
5896 | var getRefTarget = function getRefTarget(ref) {
|
5897 | return ref && ('current' in ref ? ref.current : ref);
|
5898 | };
|
5899 |
|
5900 | |
5901 |
|
5902 |
|
5903 |
|
5904 |
|
5905 |
|
5906 |
|
5907 |
|
5908 |
|
5909 |
|
5910 |
|
5911 |
|
5912 | function useRootClose$1(ref, onRootClose, _temp) {
|
5913 | var _ref = _temp === void 0 ? {} : _temp,
|
5914 | disabled = _ref.disabled,
|
5915 | _ref$clickTrigger = _ref.clickTrigger,
|
5916 | clickTrigger = _ref$clickTrigger === void 0 ? 'click' : _ref$clickTrigger;
|
5917 |
|
5918 | var preventMouseRootCloseRef = React.useRef(false);
|
5919 | var onClose = onRootClose || noop;
|
5920 | var handleMouseCapture = React.useCallback(function (e) {
|
5921 | var _e$composedPath$;
|
5922 |
|
5923 | var currentTarget = getRefTarget(ref);
|
5924 | warning_1(!!currentTarget, 'RootClose captured a close event but does not have a ref to compare it to. ' + 'useRootClose(), should be passed a ref that resolves to a DOM node');
|
5925 | preventMouseRootCloseRef.current = !currentTarget || isModifiedEvent(e) || !isLeftClickEvent(e) || !!contains(currentTarget, (_e$composedPath$ = e.composedPath == null ? void 0 : e.composedPath()[0]) != null ? _e$composedPath$ : e.target);
|
5926 | }, [ref]);
|
5927 | var handleMouse = useEventCallback(function (e) {
|
5928 | if (!preventMouseRootCloseRef.current) {
|
5929 | onClose(e);
|
5930 | }
|
5931 | });
|
5932 | var handleKeyUp = useEventCallback(function (e) {
|
5933 | if (e.keyCode === escapeKeyCode) {
|
5934 | onClose(e);
|
5935 | }
|
5936 | });
|
5937 | React.useEffect(function () {
|
5938 | if (disabled || ref == null) return undefined;
|
5939 |
|
5940 |
|
5941 | var currentEvent = window.event;
|
5942 | var doc = ownerDocument(getRefTarget(ref));
|
5943 |
|
5944 |
|
5945 |
|
5946 | var removeMouseCaptureListener = listen(doc, clickTrigger, handleMouseCapture, true);
|
5947 | var removeMouseListener = listen(doc, clickTrigger, function (e) {
|
5948 |
|
5949 | if (e === currentEvent) {
|
5950 | currentEvent = undefined;
|
5951 | return;
|
5952 | }
|
5953 |
|
5954 | handleMouse(e);
|
5955 | });
|
5956 | var removeKeyupListener = listen(doc, 'keyup', function (e) {
|
5957 |
|
5958 | if (e === currentEvent) {
|
5959 | currentEvent = undefined;
|
5960 | return;
|
5961 | }
|
5962 |
|
5963 | handleKeyUp(e);
|
5964 | });
|
5965 | var mobileSafariHackListeners = [];
|
5966 |
|
5967 | if ('ontouchstart' in doc.documentElement) {
|
5968 | mobileSafariHackListeners = [].slice.call(doc.body.children).map(function (el) {
|
5969 | return listen(el, 'mousemove', noop);
|
5970 | });
|
5971 | }
|
5972 |
|
5973 | return function () {
|
5974 | removeMouseCaptureListener();
|
5975 | removeMouseListener();
|
5976 | removeKeyupListener();
|
5977 | mobileSafariHackListeners.forEach(function (remove) {
|
5978 | return remove();
|
5979 | });
|
5980 | };
|
5981 | }, [ref, disabled, clickTrigger, handleMouseCapture, handleMouse, handleKeyUp]);
|
5982 | }
|
5983 |
|
5984 | function useRootClose(onRootClose, options) {
|
5985 | var rootElementRef = React.useRef(null);
|
5986 | useRootClose$1(rootElementRef.current, onRootClose, options);
|
5987 | return rootElementRef;
|
5988 | }
|
5989 |
|
5990 | var _excluded$8 = ["children", "onRootClose"];
|
5991 | function RootClose(_ref) {
|
5992 | var children = _ref.children,
|
5993 | onRootClose = _ref.onRootClose,
|
5994 | props = _objectWithoutProperties(_ref, _excluded$8);
|
5995 | var rootRef = useRootClose(onRootClose, props);
|
5996 | return children(rootRef);
|
5997 | }
|
5998 |
|
5999 | var _excluded$7 = ["onBlur", "onClick", "onFocus", "onRemove", "option"];
|
6000 | var propTypes$5 = {
|
6001 | onBlur: propTypes$b.exports.func,
|
6002 | onClick: propTypes$b.exports.func,
|
6003 | onFocus: propTypes$b.exports.func,
|
6004 | onRemove: propTypes$b.exports.func,
|
6005 | option: optionType.isRequired
|
6006 | };
|
6007 | function useToken(_ref) {
|
6008 | var onBlur = _ref.onBlur,
|
6009 | onClick = _ref.onClick,
|
6010 | onFocus = _ref.onFocus,
|
6011 | onRemove = _ref.onRemove,
|
6012 | option = _ref.option,
|
6013 | props = _objectWithoutProperties(_ref, _excluded$7);
|
6014 | var _useState = React.useState(false),
|
6015 | _useState2 = _slicedToArray(_useState, 2),
|
6016 | active = _useState2[0],
|
6017 | setActive = _useState2[1];
|
6018 | var _useState3 = React.useState(null),
|
6019 | _useState4 = _slicedToArray(_useState3, 2),
|
6020 | rootElement = _useState4[0],
|
6021 | attachRef = _useState4[1];
|
6022 | var handleBlur = function handleBlur(e) {
|
6023 | setActive(false);
|
6024 | onBlur && onBlur(e);
|
6025 | };
|
6026 | var handleClick = function handleClick(e) {
|
6027 | setActive(true);
|
6028 | onClick && onClick(e);
|
6029 | };
|
6030 | var handleFocus = function handleFocus(e) {
|
6031 | setActive(true);
|
6032 | onFocus && onFocus(e);
|
6033 | };
|
6034 | var handleRemove = function handleRemove() {
|
6035 | onRemove && onRemove(option);
|
6036 | };
|
6037 | var handleKeyDown = function handleKeyDown(e) {
|
6038 | if (e.key === 'Backspace' && active) {
|
6039 |
|
6040 | e.preventDefault();
|
6041 | handleRemove();
|
6042 | }
|
6043 | };
|
6044 | useRootClose$1(rootElement, handleBlur, _objectSpread2(_objectSpread2({}, props), {}, {
|
6045 | disabled: !active
|
6046 | }));
|
6047 | return {
|
6048 | active: active,
|
6049 | onBlur: handleBlur,
|
6050 | onClick: handleClick,
|
6051 | onFocus: handleFocus,
|
6052 | onKeyDown: handleKeyDown,
|
6053 | onRemove: isFunction(onRemove) ? handleRemove : undefined,
|
6054 | ref: attachRef
|
6055 | };
|
6056 | }
|
6057 |
|
6058 |
|
6059 | function withToken(Component) {
|
6060 | warn(false, 'Warning: `withToken` is deprecated and will be removed in the next ' + 'major version. Use `useToken` instead.');
|
6061 | var displayName = "withToken(".concat(getDisplayName(Component), ")");
|
6062 | var WrappedToken = function WrappedToken(props) {
|
6063 | return React__default["default"].createElement(Component, _extends({}, props, useToken(props)));
|
6064 | };
|
6065 | WrappedToken.displayName = displayName;
|
6066 | WrappedToken.propTypes = propTypes$5;
|
6067 | return WrappedToken;
|
6068 | }
|
6069 |
|
6070 | var _excluded$6 = ["active", "children", "className", "onRemove", "tabIndex"],
|
6071 | _excluded2 = ["children", "option", "readOnly"],
|
6072 | _excluded3 = ["ref"];
|
6073 | var InteractiveToken = React.forwardRef(function (_ref, ref) {
|
6074 | var active = _ref.active,
|
6075 | children = _ref.children,
|
6076 | className = _ref.className,
|
6077 | onRemove = _ref.onRemove,
|
6078 | tabIndex = _ref.tabIndex,
|
6079 | props = _objectWithoutProperties(_ref, _excluded$6);
|
6080 | return React__default["default"].createElement("div", _extends({}, props, {
|
6081 | className: cx('rbt-token', 'rbt-token-removeable', {
|
6082 | 'rbt-token-active': !!active
|
6083 | }, className),
|
6084 | ref: ref,
|
6085 | tabIndex: tabIndex || 0
|
6086 | }), children, React__default["default"].createElement(ClearButton, {
|
6087 | className: "rbt-token-remove-button",
|
6088 | label: "Remove",
|
6089 | onClick: onRemove,
|
6090 | tabIndex: -1
|
6091 | }));
|
6092 | });
|
6093 | var StaticToken = function StaticToken(_ref2) {
|
6094 | var children = _ref2.children,
|
6095 | className = _ref2.className,
|
6096 | disabled = _ref2.disabled,
|
6097 | href = _ref2.href;
|
6098 | var classnames = cx('rbt-token', {
|
6099 | 'rbt-token-disabled': disabled
|
6100 | }, className);
|
6101 | if (href && !disabled) {
|
6102 | return React__default["default"].createElement("a", {
|
6103 | className: classnames,
|
6104 | href: href
|
6105 | }, children);
|
6106 | }
|
6107 | return React__default["default"].createElement("div", {
|
6108 | className: classnames
|
6109 | }, children);
|
6110 | };
|
6111 | |
6112 |
|
6113 |
|
6114 |
|
6115 | var Token = function Token(_ref3) {
|
6116 | var children = _ref3.children,
|
6117 | option = _ref3.option,
|
6118 | readOnly = _ref3.readOnly,
|
6119 | props = _objectWithoutProperties(_ref3, _excluded2);
|
6120 | var _useToken = useToken(_objectSpread2(_objectSpread2({}, props), {}, {
|
6121 | option: option
|
6122 | })),
|
6123 | ref = _useToken.ref,
|
6124 | tokenProps = _objectWithoutProperties(_useToken, _excluded3);
|
6125 | var child = React__default["default"].createElement("div", {
|
6126 | className: "rbt-token-label"
|
6127 | }, children);
|
6128 | return !props.disabled && !readOnly && isFunction(tokenProps.onRemove) ? React__default["default"].createElement(InteractiveToken, _extends({}, props, tokenProps, {
|
6129 | ref: ref
|
6130 | }), child) : React__default["default"].createElement(StaticToken, props, child);
|
6131 | };
|
6132 |
|
6133 |
|
6134 |
|
6135 | function interpolateStyle(styles, attr) {
|
6136 | var subattr = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
6137 |
|
6138 | if (subattr) {
|
6139 |
|
6140 | subattr = subattr.replace(subattr[0], subattr[0].toUpperCase());
|
6141 | }
|
6142 | return ['Top', 'Right', 'Bottom', 'Left'].map(function (dir) {
|
6143 | return styles["".concat(attr).concat(dir).concat(subattr)];
|
6144 | }).join(' ');
|
6145 | }
|
6146 | function copyStyles(inputNode, hintNode) {
|
6147 | var inputStyle = window.getComputedStyle(inputNode);
|
6148 |
|
6149 |
|
6150 | hintNode.style.borderStyle = interpolateStyle(inputStyle, 'border', 'style');
|
6151 | hintNode.style.borderWidth = interpolateStyle(inputStyle, 'border', 'width');
|
6152 | hintNode.style.fontSize = inputStyle.fontSize;
|
6153 | hintNode.style.fontWeight = inputStyle.fontWeight;
|
6154 | hintNode.style.height = inputStyle.height;
|
6155 | hintNode.style.lineHeight = inputStyle.lineHeight;
|
6156 | hintNode.style.margin = interpolateStyle(inputStyle, 'margin');
|
6157 | hintNode.style.padding = interpolateStyle(inputStyle, 'padding');
|
6158 |
|
6159 | }
|
6160 |
|
6161 | var useHint = function useHint() {
|
6162 | var _useTypeaheadContext = useTypeaheadContext(),
|
6163 | hintText = _useTypeaheadContext.hintText,
|
6164 | inputNode = _useTypeaheadContext.inputNode;
|
6165 | var hintRef = React.useRef(null);
|
6166 | React.useEffect(function () {
|
6167 | if (inputNode && hintRef.current) {
|
6168 | copyStyles(inputNode, hintRef.current);
|
6169 | }
|
6170 | });
|
6171 | return {
|
6172 | hintRef: hintRef,
|
6173 | hintText: hintText
|
6174 | };
|
6175 | };
|
6176 | var Hint = function Hint(_ref) {
|
6177 | var children = _ref.children,
|
6178 | className = _ref.className;
|
6179 | var _useHint = useHint(),
|
6180 | hintRef = _useHint.hintRef,
|
6181 | hintText = _useHint.hintText;
|
6182 | return React__default["default"].createElement("div", {
|
6183 | className: className,
|
6184 | style: {
|
6185 | display: 'flex',
|
6186 | flex: 1,
|
6187 | height: '100%',
|
6188 | position: 'relative'
|
6189 | }
|
6190 | }, children, React__default["default"].createElement("input", {
|
6191 | "aria-hidden": true,
|
6192 | className: "rbt-input-hint",
|
6193 | ref: hintRef,
|
6194 | readOnly: true,
|
6195 | style: {
|
6196 | backgroundColor: 'transparent',
|
6197 | borderColor: 'transparent',
|
6198 | boxShadow: 'none',
|
6199 | color: 'rgba(0, 0, 0, 0.54)',
|
6200 | left: 0,
|
6201 | pointerEvents: 'none',
|
6202 | position: 'absolute',
|
6203 | top: 0,
|
6204 | width: '100%'
|
6205 | },
|
6206 | tabIndex: -1,
|
6207 | value: hintText
|
6208 | }));
|
6209 | };
|
6210 |
|
6211 | var Input = React.forwardRef(function (props, ref) {
|
6212 | return React__default["default"].createElement("input", _extends({}, props, {
|
6213 | className: cx('rbt-input-main', props.className),
|
6214 | ref: ref
|
6215 | }));
|
6216 | });
|
6217 |
|
6218 | var _excluded$5 = ["children", "className", "inputClassName", "inputRef", "referenceElementRef", "selected"];
|
6219 | function TypeaheadInputMulti(props) {
|
6220 | var wrapperRef = React__default["default"].useRef(null);
|
6221 | var inputElem = React__default["default"].useRef(null);
|
6222 | var _propsWithBsClassName = propsWithBsClassName(props),
|
6223 | children = _propsWithBsClassName.children,
|
6224 | className = _propsWithBsClassName.className,
|
6225 | inputClassName = _propsWithBsClassName.inputClassName;
|
6226 | _propsWithBsClassName.inputRef;
|
6227 | var referenceElementRef = _propsWithBsClassName.referenceElementRef,
|
6228 | selected = _propsWithBsClassName.selected,
|
6229 | rest = _objectWithoutProperties(_propsWithBsClassName, _excluded$5);
|
6230 | function getInputRef(input) {
|
6231 | inputElem.current = input;
|
6232 | props.inputRef(input);
|
6233 | }
|
6234 |
|
6235 | |
6236 |
|
6237 |
|
6238 | function handleContainerClickOrFocus(e) {
|
6239 |
|
6240 | if (props.disabled) {
|
6241 | e.currentTarget.blur();
|
6242 | return;
|
6243 | }
|
6244 | var inputNode = inputElem.current;
|
6245 | if (!inputNode ||
|
6246 |
|
6247 |
|
6248 | e.currentTarget.contains(e.target) && e.currentTarget !== e.target) {
|
6249 | return;
|
6250 | }
|
6251 | if (isSelectable(inputNode)) {
|
6252 |
|
6253 | inputNode.selectionStart = inputNode.value.length;
|
6254 | }
|
6255 | inputNode.focus();
|
6256 | }
|
6257 | function handleKeyDown(e) {
|
6258 | if (e.key === 'Backspace' && selected.length && !props.value) {
|
6259 | var _wrapperRef$current;
|
6260 |
|
6261 | e.preventDefault();
|
6262 |
|
6263 |
|
6264 |
|
6265 |
|
6266 | var wrapperChildren = (_wrapperRef$current = wrapperRef.current) === null || _wrapperRef$current === void 0 ? void 0 : _wrapperRef$current.children;
|
6267 | if (wrapperChildren !== null && wrapperChildren !== void 0 && wrapperChildren.length) {
|
6268 | var lastToken = wrapperChildren[wrapperChildren.length - 2];
|
6269 | lastToken === null || lastToken === void 0 || lastToken.focus();
|
6270 | }
|
6271 | }
|
6272 | props.onKeyDown && props.onKeyDown(e);
|
6273 | }
|
6274 | return React__default["default"].createElement("div", {
|
6275 | className: cx('rbt-input-multi', {
|
6276 | disabled: props.disabled
|
6277 | }, className),
|
6278 | onClick: handleContainerClickOrFocus,
|
6279 | onFocus: handleContainerClickOrFocus,
|
6280 | ref: referenceElementRef,
|
6281 | tabIndex: -1
|
6282 | }, React__default["default"].createElement("div", {
|
6283 | className: "rbt-input-wrapper",
|
6284 | ref: wrapperRef
|
6285 | }, children, React__default["default"].createElement(Hint, null, React__default["default"].createElement(Input, _extends({}, rest, {
|
6286 | className: inputClassName,
|
6287 | onKeyDown: handleKeyDown,
|
6288 | ref: getInputRef,
|
6289 | style: {
|
6290 | backgroundColor: 'transparent',
|
6291 | border: 0,
|
6292 | boxShadow: 'none',
|
6293 | cursor: 'inherit',
|
6294 | outline: 'none',
|
6295 | padding: 0,
|
6296 | width: '100%',
|
6297 | zIndex: 1
|
6298 | }
|
6299 | })))));
|
6300 | }
|
6301 |
|
6302 | var _excluded$4 = ["inputRef", "referenceElementRef"];
|
6303 | var TypeaheadInputSingle = function TypeaheadInputSingle(_ref) {
|
6304 | var inputRef = _ref.inputRef,
|
6305 | referenceElementRef = _ref.referenceElementRef,
|
6306 | props = _objectWithoutProperties(_ref, _excluded$4);
|
6307 | return React__default["default"].createElement(Hint, null, React__default["default"].createElement(Input, _extends({}, propsWithBsClassName(props), {
|
6308 | ref: function ref(node) {
|
6309 | inputRef(node);
|
6310 | referenceElementRef(node);
|
6311 | }
|
6312 | })));
|
6313 | };
|
6314 |
|
6315 | var propTypes$4 = {
|
6316 | children: propTypes$b.exports.string.isRequired,
|
6317 | highlightClassName: propTypes$b.exports.string,
|
6318 | search: propTypes$b.exports.string.isRequired
|
6319 | };
|
6320 | |
6321 |
|
6322 |
|
6323 |
|
6324 |
|
6325 |
|
6326 | var Highlighter = function Highlighter(_ref) {
|
6327 | var children = _ref.children,
|
6328 | _ref$highlightClassNa = _ref.highlightClassName,
|
6329 | highlightClassName = _ref$highlightClassNa === void 0 ? 'rbt-highlight-text' : _ref$highlightClassNa,
|
6330 | search = _ref.search;
|
6331 | if (!search || !children) {
|
6332 | return React__default["default"].createElement(React__default["default"].Fragment, null, children);
|
6333 | }
|
6334 | var matchCount = 0;
|
6335 | var remaining = children;
|
6336 | var highlighterChildren = [];
|
6337 | while (remaining) {
|
6338 | var bounds = getMatchBounds(remaining, search);
|
6339 |
|
6340 |
|
6341 | if (!bounds) {
|
6342 | highlighterChildren.push(remaining);
|
6343 | break;
|
6344 | }
|
6345 |
|
6346 |
|
6347 | var nonMatch = remaining.slice(0, bounds.start);
|
6348 | if (nonMatch) {
|
6349 | highlighterChildren.push(nonMatch);
|
6350 | }
|
6351 |
|
6352 |
|
6353 | var match = remaining.slice(bounds.start, bounds.end);
|
6354 | highlighterChildren.push( React__default["default"].createElement("mark", {
|
6355 | className: highlightClassName,
|
6356 | key: matchCount
|
6357 | }, match));
|
6358 | matchCount += 1;
|
6359 |
|
6360 |
|
6361 | remaining = remaining.slice(bounds.end);
|
6362 | }
|
6363 | return React__default["default"].createElement(React__default["default"].Fragment, null, highlighterChildren);
|
6364 | };
|
6365 | Highlighter.propTypes = propTypes$4;
|
6366 |
|
6367 | const t=t=>"object"==typeof t&&null!=t&&1===t.nodeType,e$1=(t,e)=>(!e||"hidden"!==t)&&("visible"!==t&&"clip"!==t),n=(t,n)=>{if(t.clientHeight<t.scrollHeight||t.clientWidth<t.scrollWidth){const o=getComputedStyle(t,null);return e$1(o.overflowY,n)||e$1(o.overflowX,n)||(t=>{const e=(t=>{if(!t.ownerDocument||!t.ownerDocument.defaultView)return null;try{return t.ownerDocument.defaultView.frameElement}catch(t){return null}})(t);return !!e&&(e.clientHeight<t.scrollHeight||e.clientWidth<t.scrollWidth)})(t)}return !1},o$1=(t,e,n,o,l,r,i,s)=>r<t&&i>e||r>t&&i<e?0:r<=t&&s<=n||i>=e&&s>=n?r-t-o:i>e&&s<n||r<t&&s>n?i-e+l:0,l=t=>{const e=t.parentElement;return null==e?t.getRootNode().host||null:e},r=(e,r)=>{var i,s,d,h;if("undefined"==typeof document)return [];const{scrollMode:c,block:f,inline:u,boundary:a,skipOverflowHiddenElements:g}=r,p="function"==typeof a?a:t=>t!==a;if(!t(e))throw new TypeError("Invalid target");const m=document.scrollingElement||document.documentElement,w=[];let W=e;for(;t(W)&&p(W);){if(W=l(W),W===m){w.push(W);break}null!=W&&W===document.body&&n(W)&&!n(document.documentElement)||null!=W&&n(W,g)&&w.push(W);}const b=null!=(s=null==(i=window.visualViewport)?void 0:i.width)?s:innerWidth,H=null!=(h=null==(d=window.visualViewport)?void 0:d.height)?h:innerHeight,{scrollX:y,scrollY:M}=window,{height:v,width:E,top:x,right:C,bottom:I,left:R}=e.getBoundingClientRect(),{top:T,right:B,bottom:F,left:V}=(t=>{const e=window.getComputedStyle(t);return {top:parseFloat(e.scrollMarginTop)||0,right:parseFloat(e.scrollMarginRight)||0,bottom:parseFloat(e.scrollMarginBottom)||0,left:parseFloat(e.scrollMarginLeft)||0}})(e);let k="start"===f||"nearest"===f?x-T:"end"===f?I+F:x+v/2-T+F,D="center"===u?R+E/2-V+B:"end"===u?C+B:R-V;const L=[];for(let t=0;t<w.length;t++){const e=w[t],{height:n,width:l,top:r,right:i,bottom:s,left:d}=e.getBoundingClientRect();if("if-needed"===c&&x>=0&&R>=0&&I<=H&&C<=b&&x>=r&&I<=s&&R>=d&&C<=i)return L;const h=getComputedStyle(e),a=parseInt(h.borderLeftWidth,10),g=parseInt(h.borderTopWidth,10),p=parseInt(h.borderRightWidth,10),W=parseInt(h.borderBottomWidth,10);let T=0,B=0;const F="offsetWidth"in e?e.offsetWidth-e.clientWidth-a-p:0,V="offsetHeight"in e?e.offsetHeight-e.clientHeight-g-W:0,S="offsetWidth"in e?0===e.offsetWidth?0:l/e.offsetWidth:0,X="offsetHeight"in e?0===e.offsetHeight?0:n/e.offsetHeight:0;if(m===e)T="start"===f?k:"end"===f?k-H:"nearest"===f?o$1(M,M+H,H,g,W,M+k,M+k+v,v):k-H/2,B="start"===u?D:"center"===u?D-b/2:"end"===u?D-b:o$1(y,y+b,b,a,p,y+D,y+D+E,E),T=Math.max(0,T+M),B=Math.max(0,B+y);else {T="start"===f?k-r-g:"end"===f?k-s+W+V:"nearest"===f?o$1(r,s,n,g,W+V,k,k+v,v):k-(r+n/2)+V/2,B="start"===u?D-d-a:"center"===u?D-(d+l/2)+F/2:"end"===u?D-i+p+F:o$1(d,i,l,a,p+F,D,D+E,E);const{scrollLeft:t,scrollTop:h}=e;T=0===X?0:Math.max(0,Math.min(h+T/X,e.scrollHeight-n/X+V)),B=0===S?0:Math.max(0,Math.min(t+B/S,e.scrollWidth-l/S+F)),k+=h-T,D+=t-B;}L.push({el:e,top:T,left:B});}return L};
|
6368 |
|
6369 | const o=t=>!1===t?{block:"end",inline:"nearest"}:(t=>t===Object(t)&&0!==Object.keys(t).length)(t)?t:{block:"start",inline:"nearest"};function e(e,r$1){if(!e.isConnected||!(t=>{let o=t;for(;o&&o.parentNode;){if(o.parentNode===document)return !0;o=o.parentNode instanceof ShadowRoot?o.parentNode.host:o.parentNode;}return !1})(e))return;const n=(t=>{const o=window.getComputedStyle(t);return {top:parseFloat(o.scrollMarginTop)||0,right:parseFloat(o.scrollMarginRight)||0,bottom:parseFloat(o.scrollMarginBottom)||0,left:parseFloat(o.scrollMarginLeft)||0}})(e);if((t=>"object"==typeof t&&"function"==typeof t.behavior)(r$1))return r$1.behavior(r(e,r$1));const l="boolean"==typeof r$1||null==r$1?void 0:r$1.behavior;for(const{el:a,top:i,left:s}of r(e,o(r$1))){const t=i-n.top+n.bottom,o=s-n.left+n.right;a.scroll({top:t,left:o,behavior:l});}}
|
6370 |
|
6371 | var _excluded$3 = ["label", "onClick", "option", "position"];
|
6372 | var propTypes$3 = {
|
6373 | option: optionType.isRequired,
|
6374 | position: propTypes$b.exports.number
|
6375 | };
|
6376 | function useItem(_ref) {
|
6377 | var label = _ref.label,
|
6378 | onClick = _ref.onClick,
|
6379 | option = _ref.option,
|
6380 | position = _ref.position,
|
6381 | props = _objectWithoutProperties(_ref, _excluded$3);
|
6382 | var _useTypeaheadContext = useTypeaheadContext(),
|
6383 | activeIndex = _useTypeaheadContext.activeIndex,
|
6384 | id = _useTypeaheadContext.id,
|
6385 | isOnlyResult = _useTypeaheadContext.isOnlyResult,
|
6386 | onActiveItemChange = _useTypeaheadContext.onActiveItemChange,
|
6387 | onInitialItemChange = _useTypeaheadContext.onInitialItemChange,
|
6388 | onMenuItemClick = _useTypeaheadContext.onMenuItemClick,
|
6389 | setItem = _useTypeaheadContext.setItem;
|
6390 | var itemRef = React.useRef(null);
|
6391 | React.useEffect(function () {
|
6392 | if (position === 0) {
|
6393 | onInitialItemChange(option);
|
6394 | }
|
6395 | });
|
6396 | React.useEffect(function () {
|
6397 | if (position === activeIndex) {
|
6398 | onActiveItemChange(option);
|
6399 |
|
6400 |
|
6401 | var node = itemRef.current;
|
6402 | node && e(node, {
|
6403 | boundary: node.parentNode,
|
6404 | scrollMode: 'if-needed'
|
6405 | });
|
6406 | }
|
6407 | }, [activeIndex, onActiveItemChange, option, position]);
|
6408 | var handleClick = React.useCallback(function (e) {
|
6409 | onMenuItemClick(option, e);
|
6410 | onClick && onClick(e);
|
6411 | }, [onClick, onMenuItemClick, option]);
|
6412 | var active = isOnlyResult || activeIndex === position;
|
6413 |
|
6414 |
|
6415 | setItem(option, position);
|
6416 | return _objectSpread2(_objectSpread2({}, props), {}, {
|
6417 | active: active,
|
6418 | 'aria-label': label,
|
6419 | 'aria-selected': active,
|
6420 | id: getMenuItemId(id, position),
|
6421 | onClick: handleClick,
|
6422 | onMouseDown: preventInputBlur,
|
6423 | ref: itemRef,
|
6424 | role: 'option'
|
6425 | });
|
6426 | }
|
6427 |
|
6428 |
|
6429 | function withItem(Component) {
|
6430 | warn(false, 'Warning: `withItem` is deprecated and will be removed in the next ' + 'major version. Use `useItem` instead.');
|
6431 | var WrappedMenuItem = function WrappedMenuItem(props) {
|
6432 | return React__default["default"].createElement(Component, _extends({}, props, useItem(props)));
|
6433 | };
|
6434 | WrappedMenuItem.displayName = "withItem(".concat(getDisplayName(Component), ")");
|
6435 | WrappedMenuItem.propTypes = propTypes$3;
|
6436 | return WrappedMenuItem;
|
6437 | }
|
6438 |
|
6439 | var _excluded$2 = ["active", "children", "className", "disabled", "onClick"];
|
6440 | var BaseMenuItem = React.forwardRef(function (_ref, ref) {
|
6441 | var active = _ref.active,
|
6442 | children = _ref.children,
|
6443 | className = _ref.className,
|
6444 | disabled = _ref.disabled,
|
6445 | _onClick = _ref.onClick,
|
6446 | props = _objectWithoutProperties(_ref, _excluded$2);
|
6447 | return React__default["default"].createElement("a", _extends({}, props, {
|
6448 | className: cx('dropdown-item', {
|
6449 | active: active,
|
6450 | disabled: disabled
|
6451 | }, className),
|
6452 | href: props.href || '#',
|
6453 | onClick: function onClick(e) {
|
6454 | e.preventDefault();
|
6455 | !disabled && _onClick && _onClick(e);
|
6456 | },
|
6457 | ref: ref
|
6458 | }), children);
|
6459 | });
|
6460 | function MenuItem(props) {
|
6461 | return React__default["default"].createElement(BaseMenuItem, useItem(props));
|
6462 | }
|
6463 |
|
6464 | var _excluded$1 = ["emptyLabel", "innerRef", "maxHeight", "style"];
|
6465 | var MenuDivider = function MenuDivider() {
|
6466 | return React__default["default"].createElement("div", {
|
6467 | className: "dropdown-divider",
|
6468 | role: "separator"
|
6469 | });
|
6470 | };
|
6471 | var MenuHeader = function MenuHeader(props) {
|
6472 | return (
|
6473 |
|
6474 |
|
6475 | React__default["default"].createElement("div", _extends({}, props, {
|
6476 | className: "dropdown-header",
|
6477 | role: "heading"
|
6478 | }))
|
6479 | );
|
6480 | };
|
6481 | var propTypes$2 = {
|
6482 | 'aria-label': propTypes$b.exports.string,
|
6483 | |
6484 |
|
6485 |
|
6486 | emptyLabel: propTypes$b.exports.node,
|
6487 | |
6488 |
|
6489 |
|
6490 | id: checkPropType(propTypes$b.exports.oneOfType([propTypes$b.exports.number, propTypes$b.exports.string]), isRequiredForA11y),
|
6491 | |
6492 |
|
6493 |
|
6494 | maxHeight: propTypes$b.exports.string
|
6495 | };
|
6496 | |
6497 |
|
6498 |
|
6499 | var Menu = function Menu(_ref) {
|
6500 | var _ref$emptyLabel = _ref.emptyLabel,
|
6501 | emptyLabel = _ref$emptyLabel === void 0 ? 'No matches found.' : _ref$emptyLabel,
|
6502 | innerRef = _ref.innerRef,
|
6503 | _ref$maxHeight = _ref.maxHeight,
|
6504 | maxHeight = _ref$maxHeight === void 0 ? '300px' : _ref$maxHeight,
|
6505 | style = _ref.style,
|
6506 | props = _objectWithoutProperties(_ref, _excluded$1);
|
6507 | var children = React.Children.count(props.children) === 0 ? React__default["default"].createElement(BaseMenuItem, {
|
6508 | disabled: true,
|
6509 | role: "option"
|
6510 | }, emptyLabel) : props.children;
|
6511 | return (
|
6512 |
|
6513 |
|
6514 | React__default["default"].createElement("div", _extends({}, props, {
|
6515 | "aria-label": props['aria-label'] || 'menu-options',
|
6516 | className: cx('rbt-menu', 'dropdown-menu', 'show', props.className),
|
6517 | onMouseDown:
|
6518 |
|
6519 | preventInputBlur,
|
6520 | ref: innerRef,
|
6521 | role: "listbox",
|
6522 | style: _objectSpread2(_objectSpread2({}, style), {}, {
|
6523 | display: 'block',
|
6524 | maxHeight: maxHeight,
|
6525 | overflow: 'auto'
|
6526 | })
|
6527 | }), children)
|
6528 |
|
6529 | );
|
6530 | };
|
6531 |
|
6532 | Menu.propTypes = propTypes$2;
|
6533 | Menu.Divider = MenuDivider;
|
6534 | Menu.Header = MenuHeader;
|
6535 |
|
6536 | var _excluded = ["labelKey", "newSelectionPrefix", "options", "paginationText", "renderMenuItemChildren", "text"];
|
6537 | var propTypes$1 = {
|
6538 | |
6539 |
|
6540 |
|
6541 |
|
6542 | newSelectionPrefix: propTypes$b.exports.node,
|
6543 | |
6544 |
|
6545 |
|
6546 | paginationText: propTypes$b.exports.node,
|
6547 | |
6548 |
|
6549 |
|
6550 | renderMenuItemChildren: propTypes$b.exports.func
|
6551 | };
|
6552 | function renderMenuItemChildrenFn(option, props) {
|
6553 | return React__default["default"].createElement(Highlighter, {
|
6554 | search: props.text
|
6555 | }, getOptionLabel(option, props.labelKey));
|
6556 | }
|
6557 | var TypeaheadMenu = function TypeaheadMenu(props) {
|
6558 | var labelKey = props.labelKey,
|
6559 | _props$newSelectionPr = props.newSelectionPrefix,
|
6560 | newSelectionPrefix = _props$newSelectionPr === void 0 ? 'New selection: ' : _props$newSelectionPr,
|
6561 | options = props.options,
|
6562 | _props$paginationText = props.paginationText,
|
6563 | paginationText = _props$paginationText === void 0 ? 'Display additional results...' : _props$paginationText,
|
6564 | _props$renderMenuItem = props.renderMenuItemChildren,
|
6565 | renderMenuItemChildren = _props$renderMenuItem === void 0 ? renderMenuItemChildrenFn : _props$renderMenuItem,
|
6566 | text = props.text,
|
6567 | menuProps = _objectWithoutProperties(props, _excluded);
|
6568 | var renderMenuItem = function renderMenuItem(option, position) {
|
6569 | var label = getOptionLabel(option, labelKey);
|
6570 | var menuItemProps = {
|
6571 | disabled: !!getOptionProperty(option, 'disabled'),
|
6572 | label: label,
|
6573 | option: option,
|
6574 | position: position
|
6575 | };
|
6576 | if (getOptionProperty(option, 'customOption')) {
|
6577 | return React__default["default"].createElement(MenuItem, _extends({}, menuItemProps, {
|
6578 | className: "rbt-menu-custom-option",
|
6579 | key: position,
|
6580 | label: label
|
6581 | }), newSelectionPrefix, React__default["default"].createElement(Highlighter, {
|
6582 | search: text
|
6583 | }, label));
|
6584 | }
|
6585 | if (getOptionProperty(option, 'paginationOption')) {
|
6586 | return React__default["default"].createElement(React__default["default"].Fragment, {
|
6587 | key: "pagination-option-divider"
|
6588 | }, React__default["default"].createElement(Menu.Divider, null), React__default["default"].createElement(MenuItem, _extends({}, menuItemProps, {
|
6589 | className: "rbt-menu-pagination-option",
|
6590 | label:
|
6591 |
|
6592 |
|
6593 | isString(paginationText) ? paginationText : ''
|
6594 | }), paginationText));
|
6595 | }
|
6596 | return React__default["default"].createElement(MenuItem, _extends({}, menuItemProps, {
|
6597 | key: position
|
6598 | }), renderMenuItemChildren(option, props, position));
|
6599 | };
|
6600 | return React__default["default"].createElement(Menu, _extends({}, menuProps, {
|
6601 | key:
|
6602 |
|
6603 |
|
6604 | text
|
6605 | }), options.map(renderMenuItem));
|
6606 | };
|
6607 | TypeaheadMenu.propTypes = propTypes$1;
|
6608 |
|
6609 | var propTypes = {
|
6610 | |
6611 |
|
6612 |
|
6613 | clearButton: propTypes$b.exports.bool,
|
6614 | |
6615 |
|
6616 |
|
6617 |
|
6618 | inputProps: checkPropType(propTypes$b.exports.object, inputPropsType),
|
6619 | |
6620 |
|
6621 |
|
6622 | isInvalid: propTypes$b.exports.bool,
|
6623 | |
6624 |
|
6625 |
|
6626 | isLoading: propTypes$b.exports.bool,
|
6627 | |
6628 |
|
6629 |
|
6630 | isValid: propTypes$b.exports.bool,
|
6631 | |
6632 |
|
6633 |
|
6634 | renderInput: propTypes$b.exports.func,
|
6635 | |
6636 |
|
6637 |
|
6638 | renderMenu: propTypes$b.exports.func,
|
6639 | |
6640 |
|
6641 |
|
6642 | renderToken: propTypes$b.exports.func,
|
6643 | |
6644 |
|
6645 |
|
6646 | size: sizeType
|
6647 | };
|
6648 | var defaultProps = {
|
6649 | isLoading: false
|
6650 | };
|
6651 | var defaultRenderMenu = function defaultRenderMenu(results, menuProps, props) {
|
6652 | return React__default["default"].createElement(TypeaheadMenu, _extends({}, menuProps, {
|
6653 | labelKey: props.labelKey,
|
6654 | options: results,
|
6655 | text: props.text
|
6656 | }));
|
6657 | };
|
6658 | var defaultRenderToken = function defaultRenderToken(option, props, idx) {
|
6659 | return React__default["default"].createElement(Token, {
|
6660 | disabled: props.disabled,
|
6661 | key: idx,
|
6662 | onRemove: props.onRemove,
|
6663 | option: option,
|
6664 | tabIndex: props.tabIndex
|
6665 | }, getOptionLabel(option, props.labelKey));
|
6666 | };
|
6667 | var overlayPropKeys = ['align', 'dropup', 'flip', 'positionFixed'];
|
6668 | function getOverlayProps(props) {
|
6669 | return pick(props, overlayPropKeys);
|
6670 | }
|
6671 | var TypeaheadComponent = function (_React$Component) {
|
6672 | _inherits(TypeaheadComponent, _React$Component);
|
6673 | var _super = _createSuper(TypeaheadComponent);
|
6674 | function TypeaheadComponent() {
|
6675 | var _this;
|
6676 | _classCallCheck(this, TypeaheadComponent);
|
6677 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
6678 | args[_key] = arguments[_key];
|
6679 | }
|
6680 | _this = _super.call.apply(_super, [this].concat(args));
|
6681 | _defineProperty(_assertThisInitialized(_this), "_referenceElement", null);
|
6682 | _defineProperty(_assertThisInitialized(_this), "referenceElementRef", function (referenceElement) {
|
6683 | _this._referenceElement = referenceElement;
|
6684 | });
|
6685 | _defineProperty(_assertThisInitialized(_this), "_renderInput", function (inputProps, props) {
|
6686 | var _this$props = _this.props,
|
6687 | isInvalid = _this$props.isInvalid,
|
6688 | isValid = _this$props.isValid,
|
6689 | multiple = _this$props.multiple,
|
6690 | renderInput = _this$props.renderInput,
|
6691 | renderToken = _this$props.renderToken,
|
6692 | size = _this$props.size;
|
6693 | if (isFunction(renderInput)) {
|
6694 | return renderInput(inputProps, props);
|
6695 | }
|
6696 | var commonProps = _objectSpread2(_objectSpread2({}, inputProps), {}, {
|
6697 | isInvalid: isInvalid,
|
6698 | isValid: isValid,
|
6699 | size: size
|
6700 | });
|
6701 | if (!multiple) {
|
6702 | return React__default["default"].createElement(TypeaheadInputSingle, commonProps);
|
6703 | }
|
6704 | var labelKey = props.labelKey,
|
6705 | onRemove = props.onRemove,
|
6706 | selected = props.selected;
|
6707 | return React__default["default"].createElement(TypeaheadInputMulti, _extends({}, commonProps, {
|
6708 | placeholder: selected.length ? '' : inputProps.placeholder,
|
6709 | selected: selected
|
6710 | }), selected.map(function (option, idx) {
|
6711 | return (renderToken || defaultRenderToken)(option, _objectSpread2(_objectSpread2({}, commonProps), {}, {
|
6712 | labelKey: labelKey,
|
6713 | onRemove: onRemove
|
6714 | }), idx);
|
6715 | }));
|
6716 | });
|
6717 | _defineProperty(_assertThisInitialized(_this), "_renderMenu", function (results, menuProps, props) {
|
6718 | var _this$props2 = _this.props,
|
6719 | emptyLabel = _this$props2.emptyLabel,
|
6720 | id = _this$props2.id,
|
6721 | maxHeight = _this$props2.maxHeight,
|
6722 | newSelectionPrefix = _this$props2.newSelectionPrefix,
|
6723 | paginationText = _this$props2.paginationText,
|
6724 | renderMenu = _this$props2.renderMenu,
|
6725 | renderMenuItemChildren = _this$props2.renderMenuItemChildren;
|
6726 | return (renderMenu || defaultRenderMenu)(results, _objectSpread2(_objectSpread2({}, menuProps), {}, {
|
6727 | emptyLabel: emptyLabel,
|
6728 | id: id,
|
6729 | maxHeight: maxHeight,
|
6730 | newSelectionPrefix: newSelectionPrefix,
|
6731 | paginationText: paginationText,
|
6732 | renderMenuItemChildren: renderMenuItemChildren
|
6733 | }), props);
|
6734 | });
|
6735 | _defineProperty(_assertThisInitialized(_this), "_renderAux", function (_ref) {
|
6736 | var onClear = _ref.onClear,
|
6737 | selected = _ref.selected;
|
6738 | var _this$props3 = _this.props,
|
6739 | clearButton = _this$props3.clearButton,
|
6740 | disabled = _this$props3.disabled,
|
6741 | isLoading = _this$props3.isLoading,
|
6742 | size = _this$props3.size;
|
6743 | var content;
|
6744 | if (isLoading) {
|
6745 | content = React__default["default"].createElement(Loader, null);
|
6746 | } else if (clearButton && !disabled && selected.length) {
|
6747 | content = React__default["default"].createElement(ClearButton, {
|
6748 | onClick: onClear,
|
6749 | onMouseDown: preventInputBlur,
|
6750 | size: size
|
6751 | });
|
6752 | }
|
6753 | return content ? React__default["default"].createElement("div", {
|
6754 | className: cx('rbt-aux', {
|
6755 | 'rbt-aux-lg': isSizeLarge(size)
|
6756 | })
|
6757 | }, content) : null;
|
6758 | });
|
6759 | return _this;
|
6760 | }
|
6761 | _createClass(TypeaheadComponent, [{
|
6762 | key: "render",
|
6763 | value: function render() {
|
6764 | var _this2 = this;
|
6765 | var _this$props4 = this.props,
|
6766 | children = _this$props4.children,
|
6767 | className = _this$props4.className,
|
6768 | instanceRef = _this$props4.instanceRef,
|
6769 | open = _this$props4.open,
|
6770 | options = _this$props4.options,
|
6771 | style = _this$props4.style;
|
6772 | return React__default["default"].createElement(Typeahead, _extends({}, this.props, {
|
6773 | options: options,
|
6774 | ref: instanceRef
|
6775 | }), function (props) {
|
6776 | var hideMenu = props.hideMenu,
|
6777 | isMenuShown = props.isMenuShown,
|
6778 | results = props.results;
|
6779 | var auxContent = _this2._renderAux(props);
|
6780 | return React__default["default"].createElement(RootClose, {
|
6781 | disabled: open || !isMenuShown,
|
6782 | onRootClose: hideMenu
|
6783 | }, function (ref) {
|
6784 | return React__default["default"].createElement("div", {
|
6785 | className: cx('rbt', {
|
6786 | 'has-aux': !!auxContent,
|
6787 | 'is-invalid': _this2.props.isInvalid,
|
6788 | 'is-valid': _this2.props.isValid
|
6789 | }, className),
|
6790 | ref: ref,
|
6791 | style: _objectSpread2(_objectSpread2({}, style), {}, {
|
6792 | outline: 'none',
|
6793 | position: 'relative'
|
6794 | }),
|
6795 | tabIndex: -1
|
6796 | }, _this2._renderInput(_objectSpread2(_objectSpread2({}, props.getInputProps(_this2.props.inputProps)), {}, {
|
6797 | referenceElementRef: _this2.referenceElementRef
|
6798 | }), props), React__default["default"].createElement(Overlay, _extends({}, getOverlayProps(_this2.props), {
|
6799 | isMenuShown: isMenuShown,
|
6800 | referenceElement: _this2._referenceElement
|
6801 | }), function (menuProps) {
|
6802 | return _this2._renderMenu(results, menuProps, props);
|
6803 | }), auxContent, isFunction(children) ? children(props) : children);
|
6804 | });
|
6805 | });
|
6806 | }
|
6807 | }]);
|
6808 | return TypeaheadComponent;
|
6809 | }(React__default["default"].Component);
|
6810 | _defineProperty(TypeaheadComponent, "propTypes", propTypes);
|
6811 | _defineProperty(TypeaheadComponent, "defaultProps", defaultProps);
|
6812 | var TypeaheadComponent$1 = React.forwardRef(function (props, ref) {
|
6813 | return React__default["default"].createElement(TypeaheadComponent, _extends({}, props, {
|
6814 | instanceRef: ref
|
6815 | }));
|
6816 | });
|
6817 |
|
6818 | var AsyncTypeahead = React.forwardRef(function (props, ref) {
|
6819 | return React__default["default"].createElement(TypeaheadComponent$1, _extends({}, useAsync(props), {
|
6820 | ref: ref
|
6821 | }));
|
6822 | });
|
6823 |
|
6824 | exports.AsyncTypeahead = AsyncTypeahead;
|
6825 | exports.BaseMenuItem = BaseMenuItem;
|
6826 | exports.ClearButton = ClearButton;
|
6827 | exports.Highlighter = Highlighter;
|
6828 | exports.Hint = Hint;
|
6829 | exports.Input = Input;
|
6830 | exports.Loader = Loader;
|
6831 | exports.Menu = Menu;
|
6832 | exports.MenuItem = MenuItem;
|
6833 | exports.Token = Token;
|
6834 | exports.Typeahead = TypeaheadComponent$1;
|
6835 | exports.TypeaheadInputMulti = TypeaheadInputMulti;
|
6836 | exports.TypeaheadInputSingle = TypeaheadInputSingle;
|
6837 | exports.TypeaheadMenu = TypeaheadMenu;
|
6838 | exports.TypeaheadRef = Typeahead;
|
6839 | exports.useAsync = useAsync;
|
6840 | exports.useHint = useHint;
|
6841 | exports.useItem = useItem;
|
6842 | exports.useToken = useToken;
|
6843 | exports.withAsync = withAsync;
|
6844 | exports.withItem = withItem;
|
6845 | exports.withToken = withToken;
|
6846 |
|
6847 | Object.defineProperty(exports, '__esModule', { value: true });
|
6848 |
|
6849 | }));
|