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 | var React__default = 'default' in React ? React['default'] : React;
|
8 | ReactDOM = ReactDOM && Object.prototype.hasOwnProperty.call(ReactDOM, 'default') ? ReactDOM['default'] : ReactDOM;
|
9 |
|
10 | function _defineProperty(obj, key, value) {
|
11 | if (key in obj) {
|
12 | Object.defineProperty(obj, key, {
|
13 | value: value,
|
14 | enumerable: true,
|
15 | configurable: true,
|
16 | writable: true
|
17 | });
|
18 | } else {
|
19 | obj[key] = value;
|
20 | }
|
21 |
|
22 | return obj;
|
23 | }
|
24 |
|
25 | function _extends() {
|
26 | _extends = Object.assign || function (target) {
|
27 | for (var i = 1; i < arguments.length; i++) {
|
28 | var source = arguments[i];
|
29 |
|
30 | for (var key in source) {
|
31 | if (Object.prototype.hasOwnProperty.call(source, key)) {
|
32 | target[key] = source[key];
|
33 | }
|
34 | }
|
35 | }
|
36 |
|
37 | return target;
|
38 | };
|
39 |
|
40 | return _extends.apply(this, arguments);
|
41 | }
|
42 |
|
43 | function _inheritsLoose(subClass, superClass) {
|
44 | subClass.prototype = Object.create(superClass.prototype);
|
45 | subClass.prototype.constructor = subClass;
|
46 | subClass.__proto__ = superClass;
|
47 | }
|
48 |
|
49 | function _objectWithoutPropertiesLoose(source, excluded) {
|
50 | if (source == null) return {};
|
51 | var target = {};
|
52 | var sourceKeys = Object.keys(source);
|
53 | var key, i;
|
54 |
|
55 | for (i = 0; i < sourceKeys.length; i++) {
|
56 | key = sourceKeys[i];
|
57 | if (excluded.indexOf(key) >= 0) continue;
|
58 | target[key] = source[key];
|
59 | }
|
60 |
|
61 | return target;
|
62 | }
|
63 |
|
64 | function _assertThisInitialized(self) {
|
65 | if (self === void 0) {
|
66 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
67 | }
|
68 |
|
69 | return self;
|
70 | }
|
71 |
|
72 | var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
73 |
|
74 | function createCommonjsModule(fn, basedir, module) {
|
75 | return module = {
|
76 | path: basedir,
|
77 | exports: {},
|
78 | require: function (path, base) {
|
79 | return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
|
80 | }
|
81 | }, fn(module, module.exports), module.exports;
|
82 | }
|
83 |
|
84 | function commonjsRequire () {
|
85 | throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
|
86 | }
|
87 |
|
88 | |
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 |
|
95 |
|
96 |
|
97 |
|
98 | var FUNC_ERROR_TEXT = 'Expected a function';
|
99 |
|
100 |
|
101 | var NAN = 0 / 0;
|
102 |
|
103 |
|
104 | var symbolTag = '[object Symbol]';
|
105 |
|
106 |
|
107 | var reTrim = /^\s+|\s+$/g;
|
108 |
|
109 |
|
110 | var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
|
111 |
|
112 |
|
113 | var reIsBinary = /^0b[01]+$/i;
|
114 |
|
115 |
|
116 | var reIsOctal = /^0o[0-7]+$/i;
|
117 |
|
118 |
|
119 | var freeParseInt = parseInt;
|
120 |
|
121 |
|
122 | var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
123 |
|
124 |
|
125 | var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
126 |
|
127 |
|
128 | var root = freeGlobal || freeSelf || Function('return this')();
|
129 |
|
130 |
|
131 | var objectProto = Object.prototype;
|
132 |
|
133 | |
134 |
|
135 |
|
136 |
|
137 |
|
138 | var objectToString = objectProto.toString;
|
139 |
|
140 |
|
141 | var nativeMax = Math.max,
|
142 | nativeMin = Math.min;
|
143 |
|
144 | |
145 |
|
146 |
|
147 |
|
148 |
|
149 |
|
150 |
|
151 |
|
152 |
|
153 |
|
154 |
|
155 |
|
156 |
|
157 |
|
158 |
|
159 |
|
160 | var now = function() {
|
161 | return root.Date.now();
|
162 | };
|
163 |
|
164 | |
165 |
|
166 |
|
167 |
|
168 |
|
169 |
|
170 |
|
171 |
|
172 |
|
173 |
|
174 |
|
175 |
|
176 |
|
177 |
|
178 |
|
179 |
|
180 |
|
181 |
|
182 |
|
183 |
|
184 |
|
185 |
|
186 |
|
187 |
|
188 |
|
189 |
|
190 |
|
191 |
|
192 |
|
193 |
|
194 |
|
195 |
|
196 |
|
197 |
|
198 |
|
199 |
|
200 |
|
201 |
|
202 |
|
203 |
|
204 |
|
205 |
|
206 |
|
207 |
|
208 |
|
209 |
|
210 |
|
211 |
|
212 |
|
213 |
|
214 |
|
215 |
|
216 |
|
217 |
|
218 | function debounce(func, wait, options) {
|
219 | var lastArgs,
|
220 | lastThis,
|
221 | maxWait,
|
222 | result,
|
223 | timerId,
|
224 | lastCallTime,
|
225 | lastInvokeTime = 0,
|
226 | leading = false,
|
227 | maxing = false,
|
228 | trailing = true;
|
229 |
|
230 | if (typeof func != 'function') {
|
231 | throw new TypeError(FUNC_ERROR_TEXT);
|
232 | }
|
233 | wait = toNumber(wait) || 0;
|
234 | if (isObject(options)) {
|
235 | leading = !!options.leading;
|
236 | maxing = 'maxWait' in options;
|
237 | maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
|
238 | trailing = 'trailing' in options ? !!options.trailing : trailing;
|
239 | }
|
240 |
|
241 | function invokeFunc(time) {
|
242 | var args = lastArgs,
|
243 | thisArg = lastThis;
|
244 |
|
245 | lastArgs = lastThis = undefined;
|
246 | lastInvokeTime = time;
|
247 | result = func.apply(thisArg, args);
|
248 | return result;
|
249 | }
|
250 |
|
251 | function leadingEdge(time) {
|
252 |
|
253 | lastInvokeTime = time;
|
254 |
|
255 | timerId = setTimeout(timerExpired, wait);
|
256 |
|
257 | return leading ? invokeFunc(time) : result;
|
258 | }
|
259 |
|
260 | function remainingWait(time) {
|
261 | var timeSinceLastCall = time - lastCallTime,
|
262 | timeSinceLastInvoke = time - lastInvokeTime,
|
263 | result = wait - timeSinceLastCall;
|
264 |
|
265 | return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
|
266 | }
|
267 |
|
268 | function shouldInvoke(time) {
|
269 | var timeSinceLastCall = time - lastCallTime,
|
270 | timeSinceLastInvoke = time - lastInvokeTime;
|
271 |
|
272 |
|
273 |
|
274 |
|
275 | return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
|
276 | (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
|
277 | }
|
278 |
|
279 | function timerExpired() {
|
280 | var time = now();
|
281 | if (shouldInvoke(time)) {
|
282 | return trailingEdge(time);
|
283 | }
|
284 |
|
285 | timerId = setTimeout(timerExpired, remainingWait(time));
|
286 | }
|
287 |
|
288 | function trailingEdge(time) {
|
289 | timerId = undefined;
|
290 |
|
291 |
|
292 |
|
293 | if (trailing && lastArgs) {
|
294 | return invokeFunc(time);
|
295 | }
|
296 | lastArgs = lastThis = undefined;
|
297 | return result;
|
298 | }
|
299 |
|
300 | function cancel() {
|
301 | if (timerId !== undefined) {
|
302 | clearTimeout(timerId);
|
303 | }
|
304 | lastInvokeTime = 0;
|
305 | lastArgs = lastCallTime = lastThis = timerId = undefined;
|
306 | }
|
307 |
|
308 | function flush() {
|
309 | return timerId === undefined ? result : trailingEdge(now());
|
310 | }
|
311 |
|
312 | function debounced() {
|
313 | var time = now(),
|
314 | isInvoking = shouldInvoke(time);
|
315 |
|
316 | lastArgs = arguments;
|
317 | lastThis = this;
|
318 | lastCallTime = time;
|
319 |
|
320 | if (isInvoking) {
|
321 | if (timerId === undefined) {
|
322 | return leadingEdge(lastCallTime);
|
323 | }
|
324 | if (maxing) {
|
325 |
|
326 | timerId = setTimeout(timerExpired, wait);
|
327 | return invokeFunc(lastCallTime);
|
328 | }
|
329 | }
|
330 | if (timerId === undefined) {
|
331 | timerId = setTimeout(timerExpired, wait);
|
332 | }
|
333 | return result;
|
334 | }
|
335 | debounced.cancel = cancel;
|
336 | debounced.flush = flush;
|
337 | return debounced;
|
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 | function isObject(value) {
|
366 | var type = typeof value;
|
367 | return !!value && (type == 'object' || type == 'function');
|
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 isObjectLike(value) {
|
395 | return !!value && typeof value == 'object';
|
396 | }
|
397 |
|
398 | |
399 |
|
400 |
|
401 |
|
402 |
|
403 |
|
404 |
|
405 |
|
406 |
|
407 |
|
408 |
|
409 |
|
410 |
|
411 |
|
412 |
|
413 |
|
414 |
|
415 | function isSymbol(value) {
|
416 | return typeof value == 'symbol' ||
|
417 | (isObjectLike(value) && objectToString.call(value) == symbolTag);
|
418 | }
|
419 |
|
420 | |
421 |
|
422 |
|
423 |
|
424 |
|
425 |
|
426 |
|
427 |
|
428 |
|
429 |
|
430 |
|
431 |
|
432 |
|
433 |
|
434 |
|
435 |
|
436 |
|
437 |
|
438 |
|
439 |
|
440 |
|
441 |
|
442 |
|
443 | function toNumber(value) {
|
444 | if (typeof value == 'number') {
|
445 | return value;
|
446 | }
|
447 | if (isSymbol(value)) {
|
448 | return NAN;
|
449 | }
|
450 | if (isObject(value)) {
|
451 | var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
|
452 | value = isObject(other) ? (other + '') : other;
|
453 | }
|
454 | if (typeof value != 'string') {
|
455 | return value === 0 ? value : +value;
|
456 | }
|
457 | value = value.replace(reTrim, '');
|
458 | var isBinary = reIsBinary.test(value);
|
459 | return (isBinary || reIsOctal.test(value))
|
460 | ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
|
461 | : (reIsBadHex.test(value) ? NAN : +value);
|
462 | }
|
463 |
|
464 | var lodash_debounce = debounce;
|
465 |
|
466 | var reactIs_development = createCommonjsModule(function (module, exports) {
|
467 |
|
468 |
|
469 |
|
470 | {
|
471 | (function() {
|
472 |
|
473 |
|
474 |
|
475 | var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
476 | var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
|
477 | var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
|
478 | var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
|
479 | var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
|
480 | var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
|
481 | var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
482 | var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
|
483 |
|
484 |
|
485 | var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
|
486 | var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
|
487 | var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
488 | var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
|
489 | var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
|
490 | var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
|
491 | var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
|
492 | var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9;
|
493 | var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
|
494 | var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
|
495 | var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
|
496 |
|
497 | function isValidElementType(type) {
|
498 | return typeof type === 'string' || typeof type === 'function' ||
|
499 | 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);
|
500 | }
|
501 |
|
502 | function typeOf(object) {
|
503 | if (typeof object === 'object' && object !== null) {
|
504 | var $$typeof = object.$$typeof;
|
505 |
|
506 | switch ($$typeof) {
|
507 | case REACT_ELEMENT_TYPE:
|
508 | var type = object.type;
|
509 |
|
510 | switch (type) {
|
511 | case REACT_ASYNC_MODE_TYPE:
|
512 | case REACT_CONCURRENT_MODE_TYPE:
|
513 | case REACT_FRAGMENT_TYPE:
|
514 | case REACT_PROFILER_TYPE:
|
515 | case REACT_STRICT_MODE_TYPE:
|
516 | case REACT_SUSPENSE_TYPE:
|
517 | return type;
|
518 |
|
519 | default:
|
520 | var $$typeofType = type && type.$$typeof;
|
521 |
|
522 | switch ($$typeofType) {
|
523 | case REACT_CONTEXT_TYPE:
|
524 | case REACT_FORWARD_REF_TYPE:
|
525 | case REACT_LAZY_TYPE:
|
526 | case REACT_MEMO_TYPE:
|
527 | case REACT_PROVIDER_TYPE:
|
528 | return $$typeofType;
|
529 |
|
530 | default:
|
531 | return $$typeof;
|
532 | }
|
533 |
|
534 | }
|
535 |
|
536 | case REACT_PORTAL_TYPE:
|
537 | return $$typeof;
|
538 | }
|
539 | }
|
540 |
|
541 | return undefined;
|
542 | }
|
543 |
|
544 | var AsyncMode = REACT_ASYNC_MODE_TYPE;
|
545 | var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
|
546 | var ContextConsumer = REACT_CONTEXT_TYPE;
|
547 | var ContextProvider = REACT_PROVIDER_TYPE;
|
548 | var Element = REACT_ELEMENT_TYPE;
|
549 | var ForwardRef = REACT_FORWARD_REF_TYPE;
|
550 | var Fragment = REACT_FRAGMENT_TYPE;
|
551 | var Lazy = REACT_LAZY_TYPE;
|
552 | var Memo = REACT_MEMO_TYPE;
|
553 | var Portal = REACT_PORTAL_TYPE;
|
554 | var Profiler = REACT_PROFILER_TYPE;
|
555 | var StrictMode = REACT_STRICT_MODE_TYPE;
|
556 | var Suspense = REACT_SUSPENSE_TYPE;
|
557 | var hasWarnedAboutDeprecatedIsAsyncMode = false;
|
558 |
|
559 | function isAsyncMode(object) {
|
560 | {
|
561 | if (!hasWarnedAboutDeprecatedIsAsyncMode) {
|
562 | hasWarnedAboutDeprecatedIsAsyncMode = true;
|
563 |
|
564 | 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.');
|
565 | }
|
566 | }
|
567 |
|
568 | return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
|
569 | }
|
570 | function isConcurrentMode(object) {
|
571 | return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
|
572 | }
|
573 | function isContextConsumer(object) {
|
574 | return typeOf(object) === REACT_CONTEXT_TYPE;
|
575 | }
|
576 | function isContextProvider(object) {
|
577 | return typeOf(object) === REACT_PROVIDER_TYPE;
|
578 | }
|
579 | function isElement(object) {
|
580 | return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
581 | }
|
582 | function isForwardRef(object) {
|
583 | return typeOf(object) === REACT_FORWARD_REF_TYPE;
|
584 | }
|
585 | function isFragment(object) {
|
586 | return typeOf(object) === REACT_FRAGMENT_TYPE;
|
587 | }
|
588 | function isLazy(object) {
|
589 | return typeOf(object) === REACT_LAZY_TYPE;
|
590 | }
|
591 | function isMemo(object) {
|
592 | return typeOf(object) === REACT_MEMO_TYPE;
|
593 | }
|
594 | function isPortal(object) {
|
595 | return typeOf(object) === REACT_PORTAL_TYPE;
|
596 | }
|
597 | function isProfiler(object) {
|
598 | return typeOf(object) === REACT_PROFILER_TYPE;
|
599 | }
|
600 | function isStrictMode(object) {
|
601 | return typeOf(object) === REACT_STRICT_MODE_TYPE;
|
602 | }
|
603 | function isSuspense(object) {
|
604 | return typeOf(object) === REACT_SUSPENSE_TYPE;
|
605 | }
|
606 |
|
607 | exports.AsyncMode = AsyncMode;
|
608 | exports.ConcurrentMode = ConcurrentMode;
|
609 | exports.ContextConsumer = ContextConsumer;
|
610 | exports.ContextProvider = ContextProvider;
|
611 | exports.Element = Element;
|
612 | exports.ForwardRef = ForwardRef;
|
613 | exports.Fragment = Fragment;
|
614 | exports.Lazy = Lazy;
|
615 | exports.Memo = Memo;
|
616 | exports.Portal = Portal;
|
617 | exports.Profiler = Profiler;
|
618 | exports.StrictMode = StrictMode;
|
619 | exports.Suspense = Suspense;
|
620 | exports.isAsyncMode = isAsyncMode;
|
621 | exports.isConcurrentMode = isConcurrentMode;
|
622 | exports.isContextConsumer = isContextConsumer;
|
623 | exports.isContextProvider = isContextProvider;
|
624 | exports.isElement = isElement;
|
625 | exports.isForwardRef = isForwardRef;
|
626 | exports.isFragment = isFragment;
|
627 | exports.isLazy = isLazy;
|
628 | exports.isMemo = isMemo;
|
629 | exports.isPortal = isPortal;
|
630 | exports.isProfiler = isProfiler;
|
631 | exports.isStrictMode = isStrictMode;
|
632 | exports.isSuspense = isSuspense;
|
633 | exports.isValidElementType = isValidElementType;
|
634 | exports.typeOf = typeOf;
|
635 | })();
|
636 | }
|
637 | });
|
638 |
|
639 | var reactIs = createCommonjsModule(function (module) {
|
640 |
|
641 | {
|
642 | module.exports = reactIs_development;
|
643 | }
|
644 | });
|
645 |
|
646 | |
647 |
|
648 |
|
649 |
|
650 |
|
651 |
|
652 | var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
653 | var hasOwnProperty = Object.prototype.hasOwnProperty;
|
654 | var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
655 |
|
656 | function toObject(val) {
|
657 | if (val === null || val === undefined) {
|
658 | throw new TypeError('Object.assign cannot be called with null or undefined');
|
659 | }
|
660 |
|
661 | return Object(val);
|
662 | }
|
663 |
|
664 | function shouldUseNative() {
|
665 | try {
|
666 | if (!Object.assign) {
|
667 | return false;
|
668 | }
|
669 |
|
670 |
|
671 |
|
672 |
|
673 | var test1 = new String('abc');
|
674 | test1[5] = 'de';
|
675 | if (Object.getOwnPropertyNames(test1)[0] === '5') {
|
676 | return false;
|
677 | }
|
678 |
|
679 |
|
680 | var test2 = {};
|
681 | for (var i = 0; i < 10; i++) {
|
682 | test2['_' + String.fromCharCode(i)] = i;
|
683 | }
|
684 | var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
|
685 | return test2[n];
|
686 | });
|
687 | if (order2.join('') !== '0123456789') {
|
688 | return false;
|
689 | }
|
690 |
|
691 |
|
692 | var test3 = {};
|
693 | 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
|
694 | test3[letter] = letter;
|
695 | });
|
696 | if (Object.keys(Object.assign({}, test3)).join('') !==
|
697 | 'abcdefghijklmnopqrst') {
|
698 | return false;
|
699 | }
|
700 |
|
701 | return true;
|
702 | } catch (err) {
|
703 |
|
704 | return false;
|
705 | }
|
706 | }
|
707 |
|
708 | var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
|
709 | var from;
|
710 | var to = toObject(target);
|
711 | var symbols;
|
712 |
|
713 | for (var s = 1; s < arguments.length; s++) {
|
714 | from = Object(arguments[s]);
|
715 |
|
716 | for (var key in from) {
|
717 | if (hasOwnProperty.call(from, key)) {
|
718 | to[key] = from[key];
|
719 | }
|
720 | }
|
721 |
|
722 | if (getOwnPropertySymbols) {
|
723 | symbols = getOwnPropertySymbols(from);
|
724 | for (var i = 0; i < symbols.length; i++) {
|
725 | if (propIsEnumerable.call(from, symbols[i])) {
|
726 | to[symbols[i]] = from[symbols[i]];
|
727 | }
|
728 | }
|
729 | }
|
730 | }
|
731 |
|
732 | return to;
|
733 | };
|
734 |
|
735 | |
736 |
|
737 |
|
738 |
|
739 |
|
740 |
|
741 |
|
742 | var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
743 |
|
744 | var ReactPropTypesSecret_1 = ReactPropTypesSecret;
|
745 |
|
746 | var printWarning = function() {};
|
747 |
|
748 | {
|
749 | var ReactPropTypesSecret$1 = ReactPropTypesSecret_1;
|
750 | var loggedTypeFailures = {};
|
751 | var has = Function.call.bind(Object.prototype.hasOwnProperty);
|
752 |
|
753 | printWarning = function(text) {
|
754 | var message = 'Warning: ' + text;
|
755 | if (typeof console !== 'undefined') {
|
756 | console.error(message);
|
757 | }
|
758 | try {
|
759 |
|
760 |
|
761 |
|
762 | throw new Error(message);
|
763 | } catch (x) {}
|
764 | };
|
765 | }
|
766 |
|
767 | |
768 |
|
769 |
|
770 |
|
771 |
|
772 |
|
773 |
|
774 |
|
775 |
|
776 |
|
777 |
|
778 | function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
779 | {
|
780 | for (var typeSpecName in typeSpecs) {
|
781 | if (has(typeSpecs, typeSpecName)) {
|
782 | var error;
|
783 |
|
784 |
|
785 |
|
786 | try {
|
787 |
|
788 |
|
789 | if (typeof typeSpecs[typeSpecName] !== 'function') {
|
790 | var err = Error(
|
791 | (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
|
792 | 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
|
793 | );
|
794 | err.name = 'Invariant Violation';
|
795 | throw err;
|
796 | }
|
797 | error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret$1);
|
798 | } catch (ex) {
|
799 | error = ex;
|
800 | }
|
801 | if (error && !(error instanceof Error)) {
|
802 | printWarning(
|
803 | (componentName || 'React class') + ': type specification of ' +
|
804 | location + ' `' + typeSpecName + '` is invalid; the type checker ' +
|
805 | 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
|
806 | 'You may have forgotten to pass an argument to the type checker ' +
|
807 | 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
|
808 | 'shape all require an argument).'
|
809 | );
|
810 | }
|
811 | if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
812 |
|
813 |
|
814 | loggedTypeFailures[error.message] = true;
|
815 |
|
816 | var stack = getStack ? getStack() : '';
|
817 |
|
818 | printWarning(
|
819 | 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
|
820 | );
|
821 | }
|
822 | }
|
823 | }
|
824 | }
|
825 | }
|
826 |
|
827 | |
828 |
|
829 |
|
830 |
|
831 |
|
832 | checkPropTypes.resetWarningCache = function() {
|
833 | {
|
834 | loggedTypeFailures = {};
|
835 | }
|
836 | };
|
837 |
|
838 | var checkPropTypes_1 = checkPropTypes;
|
839 |
|
840 | var has$1 = Function.call.bind(Object.prototype.hasOwnProperty);
|
841 | var printWarning$1 = function() {};
|
842 |
|
843 | {
|
844 | printWarning$1 = function(text) {
|
845 | var message = 'Warning: ' + text;
|
846 | if (typeof console !== 'undefined') {
|
847 | console.error(message);
|
848 | }
|
849 | try {
|
850 |
|
851 |
|
852 |
|
853 | throw new Error(message);
|
854 | } catch (x) {}
|
855 | };
|
856 | }
|
857 |
|
858 | function emptyFunctionThatReturnsNull() {
|
859 | return null;
|
860 | }
|
861 |
|
862 | var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
|
863 |
|
864 | var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
865 | var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
866 |
|
867 | |
868 |
|
869 |
|
870 |
|
871 |
|
872 |
|
873 |
|
874 |
|
875 |
|
876 |
|
877 |
|
878 |
|
879 |
|
880 |
|
881 | function getIteratorFn(maybeIterable) {
|
882 | var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
|
883 | if (typeof iteratorFn === 'function') {
|
884 | return iteratorFn;
|
885 | }
|
886 | }
|
887 |
|
888 | |
889 |
|
890 |
|
891 |
|
892 |
|
893 |
|
894 |
|
895 |
|
896 |
|
897 |
|
898 |
|
899 |
|
900 |
|
901 |
|
902 |
|
903 |
|
904 |
|
905 |
|
906 |
|
907 |
|
908 |
|
909 |
|
910 |
|
911 |
|
912 |
|
913 |
|
914 |
|
915 |
|
916 |
|
917 |
|
918 |
|
919 |
|
920 |
|
921 |
|
922 |
|
923 |
|
924 |
|
925 |
|
926 |
|
927 |
|
928 |
|
929 |
|
930 |
|
931 |
|
932 |
|
933 |
|
934 |
|
935 | var ANONYMOUS = '<<anonymous>>';
|
936 |
|
937 |
|
938 |
|
939 | var ReactPropTypes = {
|
940 | array: createPrimitiveTypeChecker('array'),
|
941 | bool: createPrimitiveTypeChecker('boolean'),
|
942 | func: createPrimitiveTypeChecker('function'),
|
943 | number: createPrimitiveTypeChecker('number'),
|
944 | object: createPrimitiveTypeChecker('object'),
|
945 | string: createPrimitiveTypeChecker('string'),
|
946 | symbol: createPrimitiveTypeChecker('symbol'),
|
947 |
|
948 | any: createAnyTypeChecker(),
|
949 | arrayOf: createArrayOfTypeChecker,
|
950 | element: createElementTypeChecker(),
|
951 | elementType: createElementTypeTypeChecker(),
|
952 | instanceOf: createInstanceTypeChecker,
|
953 | node: createNodeChecker(),
|
954 | objectOf: createObjectOfTypeChecker,
|
955 | oneOf: createEnumTypeChecker,
|
956 | oneOfType: createUnionTypeChecker,
|
957 | shape: createShapeTypeChecker,
|
958 | exact: createStrictShapeTypeChecker,
|
959 | };
|
960 |
|
961 | |
962 |
|
963 |
|
964 |
|
965 |
|
966 | function is(x, y) {
|
967 |
|
968 | if (x === y) {
|
969 |
|
970 |
|
971 | return x !== 0 || 1 / x === 1 / y;
|
972 | } else {
|
973 |
|
974 | return x !== x && y !== y;
|
975 | }
|
976 | }
|
977 |
|
978 |
|
979 | |
980 |
|
981 |
|
982 |
|
983 |
|
984 |
|
985 |
|
986 | function PropTypeError(message) {
|
987 | this.message = message;
|
988 | this.stack = '';
|
989 | }
|
990 |
|
991 | PropTypeError.prototype = Error.prototype;
|
992 |
|
993 | function createChainableTypeChecker(validate) {
|
994 | {
|
995 | var manualPropTypeCallCache = {};
|
996 | var manualPropTypeWarningCount = 0;
|
997 | }
|
998 | function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
|
999 | componentName = componentName || ANONYMOUS;
|
1000 | propFullName = propFullName || propName;
|
1001 |
|
1002 | if (secret !== ReactPropTypesSecret_1) {
|
1003 | if (throwOnDirectAccess) {
|
1004 |
|
1005 | var err = new Error(
|
1006 | 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
|
1007 | 'Use `PropTypes.checkPropTypes()` to call them. ' +
|
1008 | 'Read more at http://fb.me/use-check-prop-types'
|
1009 | );
|
1010 | err.name = 'Invariant Violation';
|
1011 | throw err;
|
1012 | } else if ( typeof console !== 'undefined') {
|
1013 |
|
1014 | var cacheKey = componentName + ':' + propName;
|
1015 | if (
|
1016 | !manualPropTypeCallCache[cacheKey] &&
|
1017 |
|
1018 | manualPropTypeWarningCount < 3
|
1019 | ) {
|
1020 | printWarning$1(
|
1021 | 'You are manually calling a React.PropTypes validation ' +
|
1022 | 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
|
1023 | 'and will throw in the standalone `prop-types` package. ' +
|
1024 | 'You may be seeing this warning due to a third-party PropTypes ' +
|
1025 | 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'
|
1026 | );
|
1027 | manualPropTypeCallCache[cacheKey] = true;
|
1028 | manualPropTypeWarningCount++;
|
1029 | }
|
1030 | }
|
1031 | }
|
1032 | if (props[propName] == null) {
|
1033 | if (isRequired) {
|
1034 | if (props[propName] === null) {
|
1035 | return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
|
1036 | }
|
1037 | return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
|
1038 | }
|
1039 | return null;
|
1040 | } else {
|
1041 | return validate(props, propName, componentName, location, propFullName);
|
1042 | }
|
1043 | }
|
1044 |
|
1045 | var chainedCheckType = checkType.bind(null, false);
|
1046 | chainedCheckType.isRequired = checkType.bind(null, true);
|
1047 |
|
1048 | return chainedCheckType;
|
1049 | }
|
1050 |
|
1051 | function createPrimitiveTypeChecker(expectedType) {
|
1052 | function validate(props, propName, componentName, location, propFullName, secret) {
|
1053 | var propValue = props[propName];
|
1054 | var propType = getPropType(propValue);
|
1055 | if (propType !== expectedType) {
|
1056 |
|
1057 |
|
1058 |
|
1059 | var preciseType = getPreciseType(propValue);
|
1060 |
|
1061 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
|
1062 | }
|
1063 | return null;
|
1064 | }
|
1065 | return createChainableTypeChecker(validate);
|
1066 | }
|
1067 |
|
1068 | function createAnyTypeChecker() {
|
1069 | return createChainableTypeChecker(emptyFunctionThatReturnsNull);
|
1070 | }
|
1071 |
|
1072 | function createArrayOfTypeChecker(typeChecker) {
|
1073 | function validate(props, propName, componentName, location, propFullName) {
|
1074 | if (typeof typeChecker !== 'function') {
|
1075 | return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
|
1076 | }
|
1077 | var propValue = props[propName];
|
1078 | if (!Array.isArray(propValue)) {
|
1079 | var propType = getPropType(propValue);
|
1080 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
|
1081 | }
|
1082 | for (var i = 0; i < propValue.length; i++) {
|
1083 | var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret_1);
|
1084 | if (error instanceof Error) {
|
1085 | return error;
|
1086 | }
|
1087 | }
|
1088 | return null;
|
1089 | }
|
1090 | return createChainableTypeChecker(validate);
|
1091 | }
|
1092 |
|
1093 | function createElementTypeChecker() {
|
1094 | function validate(props, propName, componentName, location, propFullName) {
|
1095 | var propValue = props[propName];
|
1096 | if (!isValidElement(propValue)) {
|
1097 | var propType = getPropType(propValue);
|
1098 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
|
1099 | }
|
1100 | return null;
|
1101 | }
|
1102 | return createChainableTypeChecker(validate);
|
1103 | }
|
1104 |
|
1105 | function createElementTypeTypeChecker() {
|
1106 | function validate(props, propName, componentName, location, propFullName) {
|
1107 | var propValue = props[propName];
|
1108 | if (!reactIs.isValidElementType(propValue)) {
|
1109 | var propType = getPropType(propValue);
|
1110 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));
|
1111 | }
|
1112 | return null;
|
1113 | }
|
1114 | return createChainableTypeChecker(validate);
|
1115 | }
|
1116 |
|
1117 | function createInstanceTypeChecker(expectedClass) {
|
1118 | function validate(props, propName, componentName, location, propFullName) {
|
1119 | if (!(props[propName] instanceof expectedClass)) {
|
1120 | var expectedClassName = expectedClass.name || ANONYMOUS;
|
1121 | var actualClassName = getClassName(props[propName]);
|
1122 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
|
1123 | }
|
1124 | return null;
|
1125 | }
|
1126 | return createChainableTypeChecker(validate);
|
1127 | }
|
1128 |
|
1129 | function createEnumTypeChecker(expectedValues) {
|
1130 | if (!Array.isArray(expectedValues)) {
|
1131 | {
|
1132 | if (arguments.length > 1) {
|
1133 | printWarning$1(
|
1134 | 'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' +
|
1135 | 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).'
|
1136 | );
|
1137 | } else {
|
1138 | printWarning$1('Invalid argument supplied to oneOf, expected an array.');
|
1139 | }
|
1140 | }
|
1141 | return emptyFunctionThatReturnsNull;
|
1142 | }
|
1143 |
|
1144 | function validate(props, propName, componentName, location, propFullName) {
|
1145 | var propValue = props[propName];
|
1146 | for (var i = 0; i < expectedValues.length; i++) {
|
1147 | if (is(propValue, expectedValues[i])) {
|
1148 | return null;
|
1149 | }
|
1150 | }
|
1151 |
|
1152 | var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
|
1153 | var type = getPreciseType(value);
|
1154 | if (type === 'symbol') {
|
1155 | return String(value);
|
1156 | }
|
1157 | return value;
|
1158 | });
|
1159 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
|
1160 | }
|
1161 | return createChainableTypeChecker(validate);
|
1162 | }
|
1163 |
|
1164 | function createObjectOfTypeChecker(typeChecker) {
|
1165 | function validate(props, propName, componentName, location, propFullName) {
|
1166 | if (typeof typeChecker !== 'function') {
|
1167 | return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
|
1168 | }
|
1169 | var propValue = props[propName];
|
1170 | var propType = getPropType(propValue);
|
1171 | if (propType !== 'object') {
|
1172 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
|
1173 | }
|
1174 | for (var key in propValue) {
|
1175 | if (has$1(propValue, key)) {
|
1176 | var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
|
1177 | if (error instanceof Error) {
|
1178 | return error;
|
1179 | }
|
1180 | }
|
1181 | }
|
1182 | return null;
|
1183 | }
|
1184 | return createChainableTypeChecker(validate);
|
1185 | }
|
1186 |
|
1187 | function createUnionTypeChecker(arrayOfTypeCheckers) {
|
1188 | if (!Array.isArray(arrayOfTypeCheckers)) {
|
1189 | printWarning$1('Invalid argument supplied to oneOfType, expected an instance of array.') ;
|
1190 | return emptyFunctionThatReturnsNull;
|
1191 | }
|
1192 |
|
1193 | for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
1194 | var checker = arrayOfTypeCheckers[i];
|
1195 | if (typeof checker !== 'function') {
|
1196 | printWarning$1(
|
1197 | 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
|
1198 | 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'
|
1199 | );
|
1200 | return emptyFunctionThatReturnsNull;
|
1201 | }
|
1202 | }
|
1203 |
|
1204 | function validate(props, propName, componentName, location, propFullName) {
|
1205 | for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
1206 | var checker = arrayOfTypeCheckers[i];
|
1207 | if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret_1) == null) {
|
1208 | return null;
|
1209 | }
|
1210 | }
|
1211 |
|
1212 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
|
1213 | }
|
1214 | return createChainableTypeChecker(validate);
|
1215 | }
|
1216 |
|
1217 | function createNodeChecker() {
|
1218 | function validate(props, propName, componentName, location, propFullName) {
|
1219 | if (!isNode(props[propName])) {
|
1220 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
|
1221 | }
|
1222 | return null;
|
1223 | }
|
1224 | return createChainableTypeChecker(validate);
|
1225 | }
|
1226 |
|
1227 | function createShapeTypeChecker(shapeTypes) {
|
1228 | function validate(props, propName, componentName, location, propFullName) {
|
1229 | var propValue = props[propName];
|
1230 | var propType = getPropType(propValue);
|
1231 | if (propType !== 'object') {
|
1232 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
1233 | }
|
1234 | for (var key in shapeTypes) {
|
1235 | var checker = shapeTypes[key];
|
1236 | if (!checker) {
|
1237 | continue;
|
1238 | }
|
1239 | var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
|
1240 | if (error) {
|
1241 | return error;
|
1242 | }
|
1243 | }
|
1244 | return null;
|
1245 | }
|
1246 | return createChainableTypeChecker(validate);
|
1247 | }
|
1248 |
|
1249 | function createStrictShapeTypeChecker(shapeTypes) {
|
1250 | function validate(props, propName, componentName, location, propFullName) {
|
1251 | var propValue = props[propName];
|
1252 | var propType = getPropType(propValue);
|
1253 | if (propType !== 'object') {
|
1254 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
1255 | }
|
1256 |
|
1257 |
|
1258 | var allKeys = objectAssign({}, props[propName], shapeTypes);
|
1259 | for (var key in allKeys) {
|
1260 | var checker = shapeTypes[key];
|
1261 | if (!checker) {
|
1262 | return new PropTypeError(
|
1263 | 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
|
1264 | '\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
|
1265 | '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
|
1266 | );
|
1267 | }
|
1268 | var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
|
1269 | if (error) {
|
1270 | return error;
|
1271 | }
|
1272 | }
|
1273 | return null;
|
1274 | }
|
1275 |
|
1276 | return createChainableTypeChecker(validate);
|
1277 | }
|
1278 |
|
1279 | function isNode(propValue) {
|
1280 | switch (typeof propValue) {
|
1281 | case 'number':
|
1282 | case 'string':
|
1283 | case 'undefined':
|
1284 | return true;
|
1285 | case 'boolean':
|
1286 | return !propValue;
|
1287 | case 'object':
|
1288 | if (Array.isArray(propValue)) {
|
1289 | return propValue.every(isNode);
|
1290 | }
|
1291 | if (propValue === null || isValidElement(propValue)) {
|
1292 | return true;
|
1293 | }
|
1294 |
|
1295 | var iteratorFn = getIteratorFn(propValue);
|
1296 | if (iteratorFn) {
|
1297 | var iterator = iteratorFn.call(propValue);
|
1298 | var step;
|
1299 | if (iteratorFn !== propValue.entries) {
|
1300 | while (!(step = iterator.next()).done) {
|
1301 | if (!isNode(step.value)) {
|
1302 | return false;
|
1303 | }
|
1304 | }
|
1305 | } else {
|
1306 |
|
1307 | while (!(step = iterator.next()).done) {
|
1308 | var entry = step.value;
|
1309 | if (entry) {
|
1310 | if (!isNode(entry[1])) {
|
1311 | return false;
|
1312 | }
|
1313 | }
|
1314 | }
|
1315 | }
|
1316 | } else {
|
1317 | return false;
|
1318 | }
|
1319 |
|
1320 | return true;
|
1321 | default:
|
1322 | return false;
|
1323 | }
|
1324 | }
|
1325 |
|
1326 | function isSymbol(propType, propValue) {
|
1327 |
|
1328 | if (propType === 'symbol') {
|
1329 | return true;
|
1330 | }
|
1331 |
|
1332 |
|
1333 | if (!propValue) {
|
1334 | return false;
|
1335 | }
|
1336 |
|
1337 |
|
1338 | if (propValue['@@toStringTag'] === 'Symbol') {
|
1339 | return true;
|
1340 | }
|
1341 |
|
1342 |
|
1343 | if (typeof Symbol === 'function' && propValue instanceof Symbol) {
|
1344 | return true;
|
1345 | }
|
1346 |
|
1347 | return false;
|
1348 | }
|
1349 |
|
1350 |
|
1351 | function getPropType(propValue) {
|
1352 | var propType = typeof propValue;
|
1353 | if (Array.isArray(propValue)) {
|
1354 | return 'array';
|
1355 | }
|
1356 | if (propValue instanceof RegExp) {
|
1357 |
|
1358 |
|
1359 |
|
1360 | return 'object';
|
1361 | }
|
1362 | if (isSymbol(propType, propValue)) {
|
1363 | return 'symbol';
|
1364 | }
|
1365 | return propType;
|
1366 | }
|
1367 |
|
1368 |
|
1369 |
|
1370 | function getPreciseType(propValue) {
|
1371 | if (typeof propValue === 'undefined' || propValue === null) {
|
1372 | return '' + propValue;
|
1373 | }
|
1374 | var propType = getPropType(propValue);
|
1375 | if (propType === 'object') {
|
1376 | if (propValue instanceof Date) {
|
1377 | return 'date';
|
1378 | } else if (propValue instanceof RegExp) {
|
1379 | return 'regexp';
|
1380 | }
|
1381 | }
|
1382 | return propType;
|
1383 | }
|
1384 |
|
1385 |
|
1386 |
|
1387 | function getPostfixForTypeWarning(value) {
|
1388 | var type = getPreciseType(value);
|
1389 | switch (type) {
|
1390 | case 'array':
|
1391 | case 'object':
|
1392 | return 'an ' + type;
|
1393 | case 'boolean':
|
1394 | case 'date':
|
1395 | case 'regexp':
|
1396 | return 'a ' + type;
|
1397 | default:
|
1398 | return type;
|
1399 | }
|
1400 | }
|
1401 |
|
1402 |
|
1403 | function getClassName(propValue) {
|
1404 | if (!propValue.constructor || !propValue.constructor.name) {
|
1405 | return ANONYMOUS;
|
1406 | }
|
1407 | return propValue.constructor.name;
|
1408 | }
|
1409 |
|
1410 | ReactPropTypes.checkPropTypes = checkPropTypes_1;
|
1411 | ReactPropTypes.resetWarningCache = checkPropTypes_1.resetWarningCache;
|
1412 | ReactPropTypes.PropTypes = ReactPropTypes;
|
1413 |
|
1414 | return ReactPropTypes;
|
1415 | };
|
1416 |
|
1417 | var propTypes = createCommonjsModule(function (module) {
|
1418 | |
1419 |
|
1420 |
|
1421 |
|
1422 |
|
1423 |
|
1424 |
|
1425 | {
|
1426 | var ReactIs = reactIs;
|
1427 |
|
1428 |
|
1429 |
|
1430 | var throwOnDirectAccess = true;
|
1431 | module.exports = factoryWithTypeCheckers(ReactIs.isElement, throwOnDirectAccess);
|
1432 | }
|
1433 | });
|
1434 |
|
1435 | |
1436 |
|
1437 |
|
1438 |
|
1439 |
|
1440 |
|
1441 |
|
1442 |
|
1443 |
|
1444 |
|
1445 |
|
1446 |
|
1447 |
|
1448 |
|
1449 |
|
1450 |
|
1451 |
|
1452 | function useForceUpdate() {
|
1453 |
|
1454 |
|
1455 | var _useReducer = React.useReducer(function (state) {
|
1456 | return !state;
|
1457 | }, false),
|
1458 | dispatch = _useReducer[1];
|
1459 |
|
1460 | return dispatch;
|
1461 | }
|
1462 |
|
1463 | |
1464 |
|
1465 |
|
1466 |
|
1467 |
|
1468 |
|
1469 |
|
1470 |
|
1471 |
|
1472 |
|
1473 |
|
1474 |
|
1475 |
|
1476 |
|
1477 |
|
1478 |
|
1479 |
|
1480 |
|
1481 | function usePrevious(value) {
|
1482 | var ref = React.useRef(null);
|
1483 | React.useEffect(function () {
|
1484 | ref.current = value;
|
1485 | });
|
1486 | return ref.current;
|
1487 | }
|
1488 |
|
1489 |
|
1490 |
|
1491 |
|
1492 |
|
1493 | var fastDeepEqual = function equal(a, b) {
|
1494 | if (a === b) return true;
|
1495 |
|
1496 | if (a && b && typeof a == 'object' && typeof b == 'object') {
|
1497 | if (a.constructor !== b.constructor) return false;
|
1498 |
|
1499 | var length, i, keys;
|
1500 | if (Array.isArray(a)) {
|
1501 | length = a.length;
|
1502 | if (length != b.length) return false;
|
1503 | for (i = length; i-- !== 0;)
|
1504 | if (!equal(a[i], b[i])) return false;
|
1505 | return true;
|
1506 | }
|
1507 |
|
1508 |
|
1509 |
|
1510 | if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
|
1511 | if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
|
1512 | if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
|
1513 |
|
1514 | keys = Object.keys(a);
|
1515 | length = keys.length;
|
1516 | if (length !== Object.keys(b).length) return false;
|
1517 |
|
1518 | for (i = length; i-- !== 0;)
|
1519 | if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
|
1520 |
|
1521 | for (i = length; i-- !== 0;) {
|
1522 | var key = keys[i];
|
1523 |
|
1524 | if (!equal(a[key], b[key])) return false;
|
1525 | }
|
1526 |
|
1527 | return true;
|
1528 | }
|
1529 |
|
1530 |
|
1531 | return a!==a && b!==b;
|
1532 | };
|
1533 |
|
1534 | |
1535 |
|
1536 |
|
1537 |
|
1538 |
|
1539 |
|
1540 |
|
1541 | var invariant = function(condition, format, a, b, c, d, e, f) {
|
1542 | {
|
1543 | if (format === undefined) {
|
1544 | throw new Error('invariant requires an error message argument');
|
1545 | }
|
1546 | }
|
1547 |
|
1548 | if (!condition) {
|
1549 | var error;
|
1550 | if (format === undefined) {
|
1551 | error = new Error(
|
1552 | 'Minified exception occurred; use the non-minified dev environment ' +
|
1553 | 'for the full error message and additional helpful warnings.'
|
1554 | );
|
1555 | } else {
|
1556 | var args = [a, b, c, d, e, f];
|
1557 | var argIndex = 0;
|
1558 | error = new Error(
|
1559 | format.replace(/%s/g, function() { return args[argIndex++]; })
|
1560 | );
|
1561 | error.name = 'Invariant Violation';
|
1562 | }
|
1563 |
|
1564 | error.framesToPop = 1;
|
1565 | throw error;
|
1566 | }
|
1567 | };
|
1568 |
|
1569 | var invariant_1 = invariant;
|
1570 |
|
1571 | |
1572 |
|
1573 |
|
1574 |
|
1575 | var BACKSPACE = 8;
|
1576 | var TAB = 9;
|
1577 | var RETURN = 13;
|
1578 | var ESC = 27;
|
1579 | var UP = 38;
|
1580 | var RIGHT = 39;
|
1581 | var DOWN = 40;
|
1582 | var DEFAULT_LABELKEY = 'label';
|
1583 | var ALIGN = {
|
1584 | JUSTIFY: 'justify',
|
1585 | LEFT: 'left',
|
1586 | RIGHT: 'right'
|
1587 | };
|
1588 | var SIZE = {
|
1589 | LARGE: 'large',
|
1590 | LG: 'lg',
|
1591 | SM: 'sm',
|
1592 | SMALL: 'small'
|
1593 | };
|
1594 |
|
1595 | function getStringLabelKey(labelKey) {
|
1596 | return typeof labelKey === 'string' ? labelKey : DEFAULT_LABELKEY;
|
1597 | }
|
1598 |
|
1599 | var idCounter = 0;
|
1600 | function head(arr) {
|
1601 | return Array.isArray(arr) && arr.length ? arr[0] : undefined;
|
1602 | }
|
1603 | function isFunction(value) {
|
1604 | return typeof value === 'function';
|
1605 | }
|
1606 | function isString(value) {
|
1607 | return typeof value === 'string';
|
1608 | }
|
1609 | function noop() {}
|
1610 | function pick(obj, keys) {
|
1611 | var result = {};
|
1612 | keys.forEach(function (k) {
|
1613 | if (Object.prototype.hasOwnProperty.call(obj, k)) {
|
1614 | result[k] = obj[k];
|
1615 | }
|
1616 | });
|
1617 | return result;
|
1618 | }
|
1619 | function uniqueId(prefix) {
|
1620 | idCounter += 1;
|
1621 | return (prefix == null ? '' : String(prefix)) + idCounter;
|
1622 | }
|
1623 |
|
1624 | function valuesPolyfill(obj) {
|
1625 | return Object.keys(obj).reduce(function (accum, key) {
|
1626 | if (Object.prototype.propertyIsEnumerable.call(obj, key)) {
|
1627 | accum.push(obj[key]);
|
1628 | }
|
1629 |
|
1630 | return accum;
|
1631 | }, []);
|
1632 | }
|
1633 | function values(obj) {
|
1634 | return isFunction(Object.values) ? Object.values(obj) : valuesPolyfill(obj);
|
1635 | }
|
1636 |
|
1637 | |
1638 |
|
1639 |
|
1640 |
|
1641 |
|
1642 | function getOptionLabel(option, labelKey) {
|
1643 |
|
1644 | if (!isString(option) && (option.paginationOption || option.customOption)) {
|
1645 | return option[getStringLabelKey(labelKey)];
|
1646 | }
|
1647 |
|
1648 | var optionLabel;
|
1649 |
|
1650 | if (isFunction(labelKey)) {
|
1651 | optionLabel = labelKey(option);
|
1652 | } else if (isString(option)) {
|
1653 | optionLabel = option;
|
1654 | } else {
|
1655 |
|
1656 | optionLabel = option[labelKey];
|
1657 | }
|
1658 |
|
1659 | !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;
|
1660 | return optionLabel;
|
1661 | }
|
1662 |
|
1663 | function addCustomOption(results, props) {
|
1664 | var allowNew = props.allowNew,
|
1665 | labelKey = props.labelKey,
|
1666 | text = props.text;
|
1667 |
|
1668 | if (!allowNew || !text.trim()) {
|
1669 | return false;
|
1670 | }
|
1671 |
|
1672 |
|
1673 |
|
1674 | if (typeof allowNew === 'function') {
|
1675 | return allowNew(results, props);
|
1676 | }
|
1677 |
|
1678 |
|
1679 |
|
1680 | return !results.some(function (o) {
|
1681 | return getOptionLabel(o, labelKey) === text;
|
1682 | });
|
1683 | }
|
1684 |
|
1685 | function getOptionProperty(option, key) {
|
1686 | if (isString(option)) {
|
1687 | return undefined;
|
1688 | }
|
1689 |
|
1690 | return option[key];
|
1691 | }
|
1692 |
|
1693 | |
1694 |
|
1695 |
|
1696 |
|
1697 |
|
1698 |
|
1699 |
|
1700 |
|
1701 |
|
1702 |
|
1703 |
|
1704 |
|
1705 |
|
1706 |
|
1707 |
|
1708 |
|
1709 |
|
1710 | var map = [{
|
1711 | base: 'A',
|
1712 | 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"
|
1713 | }, {
|
1714 | base: 'AA',
|
1715 | letters: "\uA732"
|
1716 | }, {
|
1717 | base: 'AE',
|
1718 | letters: "\xC6\u01FC\u01E2"
|
1719 | }, {
|
1720 | base: 'AO',
|
1721 | letters: "\uA734"
|
1722 | }, {
|
1723 | base: 'AU',
|
1724 | letters: "\uA736"
|
1725 | }, {
|
1726 | base: 'AV',
|
1727 | letters: "\uA738\uA73A"
|
1728 | }, {
|
1729 | base: 'AY',
|
1730 | letters: "\uA73C"
|
1731 | }, {
|
1732 | base: 'B',
|
1733 | letters: "B\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181"
|
1734 | }, {
|
1735 | base: 'C',
|
1736 | letters: "C\u24B8\uFF23\u0106\u0108\u010A\u010C\xC7\u1E08\u0187\u023B\uA73E"
|
1737 | }, {
|
1738 | base: 'D',
|
1739 | letters: "D\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018B\u018A\u0189\uA779\xD0"
|
1740 | }, {
|
1741 | base: 'DZ',
|
1742 | letters: "\u01F1\u01C4"
|
1743 | }, {
|
1744 | base: 'Dz',
|
1745 | letters: "\u01F2\u01C5"
|
1746 | }, {
|
1747 | base: 'E',
|
1748 | 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"
|
1749 | }, {
|
1750 | base: 'F',
|
1751 | letters: "F\u24BB\uFF26\u1E1E\u0191\uA77B"
|
1752 | }, {
|
1753 | base: 'G',
|
1754 | letters: "G\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E"
|
1755 | }, {
|
1756 | base: 'H',
|
1757 | letters: "H\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D"
|
1758 | }, {
|
1759 | base: 'I',
|
1760 | letters: "I\u24BE\uFF29\xCC\xCD\xCE\u0128\u012A\u012C\u0130\xCF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197"
|
1761 | }, {
|
1762 | base: 'J',
|
1763 | letters: "J\u24BF\uFF2A\u0134\u0248"
|
1764 | }, {
|
1765 | base: 'K',
|
1766 | letters: "K\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2"
|
1767 | }, {
|
1768 | base: 'L',
|
1769 | letters: "L\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780"
|
1770 | }, {
|
1771 | base: 'LJ',
|
1772 | letters: "\u01C7"
|
1773 | }, {
|
1774 | base: 'Lj',
|
1775 | letters: "\u01C8"
|
1776 | }, {
|
1777 | base: 'M',
|
1778 | letters: "M\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C"
|
1779 | }, {
|
1780 | base: 'N',
|
1781 | letters: "N\u24C3\uFF2E\u01F8\u0143\xD1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u0220\u019D\uA790\uA7A4"
|
1782 | }, {
|
1783 | base: 'NJ',
|
1784 | letters: "\u01CA"
|
1785 | }, {
|
1786 | base: 'Nj',
|
1787 | letters: "\u01CB"
|
1788 | }, {
|
1789 | base: 'O',
|
1790 | 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"
|
1791 | }, {
|
1792 | base: 'OI',
|
1793 | letters: "\u01A2"
|
1794 | }, {
|
1795 | base: 'OO',
|
1796 | letters: "\uA74E"
|
1797 | }, {
|
1798 | base: 'OU',
|
1799 | letters: "\u0222"
|
1800 | }, {
|
1801 | base: 'OE',
|
1802 | letters: "\x8C\u0152"
|
1803 | }, {
|
1804 | base: 'oe',
|
1805 | letters: "\x9C\u0153"
|
1806 | }, {
|
1807 | base: 'P',
|
1808 | letters: "P\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754"
|
1809 | }, {
|
1810 | base: 'Q',
|
1811 | letters: "Q\u24C6\uFF31\uA756\uA758\u024A"
|
1812 | }, {
|
1813 | base: 'R',
|
1814 | letters: "R\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782"
|
1815 | }, {
|
1816 | base: 'S',
|
1817 | letters: "S\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784"
|
1818 | }, {
|
1819 | base: 'T',
|
1820 | letters: "T\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786"
|
1821 | }, {
|
1822 | base: 'TZ',
|
1823 | letters: "\uA728"
|
1824 | }, {
|
1825 | base: 'U',
|
1826 | 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"
|
1827 | }, {
|
1828 | base: 'V',
|
1829 | letters: "V\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245"
|
1830 | }, {
|
1831 | base: 'VY',
|
1832 | letters: "\uA760"
|
1833 | }, {
|
1834 | base: 'W',
|
1835 | letters: "W\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72"
|
1836 | }, {
|
1837 | base: 'X',
|
1838 | letters: "X\u24CD\uFF38\u1E8A\u1E8C"
|
1839 | }, {
|
1840 | base: 'Y',
|
1841 | letters: "Y\u24CE\uFF39\u1EF2\xDD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE"
|
1842 | }, {
|
1843 | base: 'Z',
|
1844 | letters: "Z\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762"
|
1845 | }, {
|
1846 | base: 'a',
|
1847 | 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"
|
1848 | }, {
|
1849 | base: 'aa',
|
1850 | letters: "\uA733"
|
1851 | }, {
|
1852 | base: 'ae',
|
1853 | letters: "\xE6\u01FD\u01E3"
|
1854 | }, {
|
1855 | base: 'ao',
|
1856 | letters: "\uA735"
|
1857 | }, {
|
1858 | base: 'au',
|
1859 | letters: "\uA737"
|
1860 | }, {
|
1861 | base: 'av',
|
1862 | letters: "\uA739\uA73B"
|
1863 | }, {
|
1864 | base: 'ay',
|
1865 | letters: "\uA73D"
|
1866 | }, {
|
1867 | base: 'b',
|
1868 | letters: "b\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253"
|
1869 | }, {
|
1870 | base: 'c',
|
1871 | letters: "c\u24D2\uFF43\u0107\u0109\u010B\u010D\xE7\u1E09\u0188\u023C\uA73F\u2184"
|
1872 | }, {
|
1873 | base: 'd',
|
1874 | letters: "d\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\uA77A"
|
1875 | }, {
|
1876 | base: 'dz',
|
1877 | letters: "\u01F3\u01C6"
|
1878 | }, {
|
1879 | base: 'e',
|
1880 | 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"
|
1881 | }, {
|
1882 | base: 'f',
|
1883 | letters: "f\u24D5\uFF46\u1E1F\u0192\uA77C"
|
1884 | }, {
|
1885 | base: 'g',
|
1886 | letters: "g\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F"
|
1887 | }, {
|
1888 | base: 'h',
|
1889 | letters: "h\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265"
|
1890 | }, {
|
1891 | base: 'hv',
|
1892 | letters: "\u0195"
|
1893 | }, {
|
1894 | base: 'i',
|
1895 | letters: "i\u24D8\uFF49\xEC\xED\xEE\u0129\u012B\u012D\xEF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131"
|
1896 | }, {
|
1897 | base: 'j',
|
1898 | letters: "j\u24D9\uFF4A\u0135\u01F0\u0249"
|
1899 | }, {
|
1900 | base: 'k',
|
1901 | letters: "k\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3"
|
1902 | }, {
|
1903 | base: 'l',
|
1904 | letters: "l\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747"
|
1905 | }, {
|
1906 | base: 'lj',
|
1907 | letters: "\u01C9"
|
1908 | }, {
|
1909 | base: 'm',
|
1910 | letters: "m\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F"
|
1911 | }, {
|
1912 | base: 'n',
|
1913 | letters: "n\u24DD\uFF4E\u01F9\u0144\xF1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5"
|
1914 | }, {
|
1915 | base: 'nj',
|
1916 | letters: "\u01CC"
|
1917 | }, {
|
1918 | base: 'o',
|
1919 | 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"
|
1920 | }, {
|
1921 | base: 'oi',
|
1922 | letters: "\u01A3"
|
1923 | }, {
|
1924 | base: 'ou',
|
1925 | letters: "\u0223"
|
1926 | }, {
|
1927 | base: 'oo',
|
1928 | letters: "\uA74F"
|
1929 | }, {
|
1930 | base: 'p',
|
1931 | letters: "p\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755"
|
1932 | }, {
|
1933 | base: 'q',
|
1934 | letters: "q\u24E0\uFF51\u024B\uA757\uA759"
|
1935 | }, {
|
1936 | base: 'r',
|
1937 | letters: "r\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783"
|
1938 | }, {
|
1939 | base: 's',
|
1940 | letters: "s\u24E2\uFF53\xDF\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B"
|
1941 | }, {
|
1942 | base: 't',
|
1943 | letters: "t\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787"
|
1944 | }, {
|
1945 | base: 'tz',
|
1946 | letters: "\uA729"
|
1947 | }, {
|
1948 | base: 'u',
|
1949 | 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"
|
1950 | }, {
|
1951 | base: 'v',
|
1952 | letters: "v\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C"
|
1953 | }, {
|
1954 | base: 'vy',
|
1955 | letters: "\uA761"
|
1956 | }, {
|
1957 | base: 'w',
|
1958 | letters: "w\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73"
|
1959 | }, {
|
1960 | base: 'x',
|
1961 | letters: "x\u24E7\uFF58\u1E8B\u1E8D"
|
1962 | }, {
|
1963 | base: 'y',
|
1964 | letters: "y\u24E8\uFF59\u1EF3\xFD\u0177\u1EF9\u0233\u1E8F\xFF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF"
|
1965 | }, {
|
1966 | base: 'z',
|
1967 | letters: "z\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763"
|
1968 | }];
|
1969 |
|
1970 |
|
1971 | var diacriticsMap = {};
|
1972 |
|
1973 | for (var ii = 0; ii < map.length; ii++) {
|
1974 | var letters = map[ii].letters;
|
1975 |
|
1976 | for (var jj = 0; jj < letters.length; jj++) {
|
1977 | diacriticsMap[letters[jj]] = map[ii].base;
|
1978 | }
|
1979 | }
|
1980 |
|
1981 |
|
1982 | function stripDiacritics(str) {
|
1983 | return str.replace(/[\u0300-\u036F]/g, '')
|
1984 |
|
1985 |
|
1986 | .replace(/[^\u0000-\u007E]/g, function (a) {
|
1987 | return diacriticsMap[a] || a;
|
1988 | });
|
1989 | }
|
1990 |
|
1991 | |
1992 |
|
1993 |
|
1994 |
|
1995 |
|
1996 |
|
1997 |
|
1998 | var warning = function() {};
|
1999 |
|
2000 | {
|
2001 | var printWarning$2 = function printWarning(format, args) {
|
2002 | var len = arguments.length;
|
2003 | args = new Array(len > 1 ? len - 1 : 0);
|
2004 | for (var key = 1; key < len; key++) {
|
2005 | args[key - 1] = arguments[key];
|
2006 | }
|
2007 | var argIndex = 0;
|
2008 | var message = 'Warning: ' +
|
2009 | format.replace(/%s/g, function() {
|
2010 | return args[argIndex++];
|
2011 | });
|
2012 | if (typeof console !== 'undefined') {
|
2013 | console.error(message);
|
2014 | }
|
2015 | try {
|
2016 |
|
2017 |
|
2018 |
|
2019 | throw new Error(message);
|
2020 | } catch (x) {}
|
2021 | };
|
2022 |
|
2023 | warning = function(condition, format, args) {
|
2024 | var len = arguments.length;
|
2025 | args = new Array(len > 2 ? len - 2 : 0);
|
2026 | for (var key = 2; key < len; key++) {
|
2027 | args[key - 2] = arguments[key];
|
2028 | }
|
2029 | if (format === undefined) {
|
2030 | throw new Error(
|
2031 | '`warning(condition, format, ...args)` requires a warning ' +
|
2032 | 'message argument'
|
2033 | );
|
2034 | }
|
2035 | if (!condition) {
|
2036 | printWarning$2.apply(null, [format].concat(args));
|
2037 | }
|
2038 | };
|
2039 | }
|
2040 |
|
2041 | var warning_1 = warning;
|
2042 |
|
2043 | var warned = {};
|
2044 | |
2045 |
|
2046 |
|
2047 |
|
2048 | function warn(falseToWarn, message) {
|
2049 |
|
2050 | if (!falseToWarn && message.indexOf('deprecated') !== -1) {
|
2051 | if (warned[message]) {
|
2052 | return;
|
2053 | }
|
2054 |
|
2055 | warned[message] = true;
|
2056 | }
|
2057 |
|
2058 | for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
2059 | args[_key - 2] = arguments[_key];
|
2060 | }
|
2061 |
|
2062 | warning_1.apply(void 0, [falseToWarn, "[react-bootstrap-typeahead] " + message].concat(args));
|
2063 | }
|
2064 |
|
2065 | function isMatch(input, string, props) {
|
2066 | var searchStr = input;
|
2067 | var str = string;
|
2068 |
|
2069 | if (!props.caseSensitive) {
|
2070 | searchStr = searchStr.toLowerCase();
|
2071 | str = str.toLowerCase();
|
2072 | }
|
2073 |
|
2074 | if (props.ignoreDiacritics) {
|
2075 | searchStr = stripDiacritics(searchStr);
|
2076 | str = stripDiacritics(str);
|
2077 | }
|
2078 |
|
2079 | return str.indexOf(searchStr) !== -1;
|
2080 | }
|
2081 | |
2082 |
|
2083 |
|
2084 |
|
2085 |
|
2086 | function defaultFilterBy(option, props) {
|
2087 | var filterBy = props.filterBy,
|
2088 | labelKey = props.labelKey,
|
2089 | multiple = props.multiple,
|
2090 | selected = props.selected,
|
2091 | text = props.text;
|
2092 |
|
2093 | if (multiple && selected.some(function (o) {
|
2094 | return fastDeepEqual(o, option);
|
2095 | })) {
|
2096 | return false;
|
2097 | }
|
2098 |
|
2099 | if (isFunction(labelKey) && isMatch(text, labelKey(option), props)) {
|
2100 | return true;
|
2101 | }
|
2102 |
|
2103 | var fields = filterBy.slice();
|
2104 |
|
2105 | if (isString(labelKey)) {
|
2106 |
|
2107 | if (fields.indexOf(labelKey) === -1) {
|
2108 | fields.unshift(labelKey);
|
2109 | }
|
2110 | }
|
2111 |
|
2112 | if (isString(option)) {
|
2113 | warn(fields.length <= 1, 'You cannot filter by properties when `option` is a string.');
|
2114 | return isMatch(text, option, props);
|
2115 | }
|
2116 |
|
2117 | return fields.some(function (field) {
|
2118 | var value = getOptionProperty(option, field);
|
2119 |
|
2120 | if (!isString(value)) {
|
2121 | warn(false, 'Fields passed to `filterBy` should have string values. Value will ' + 'be converted to a string; results may be unexpected.');
|
2122 | value = String(value);
|
2123 | }
|
2124 |
|
2125 | return isMatch(text, value, props);
|
2126 | });
|
2127 | }
|
2128 |
|
2129 | function getDisplayName(Component) {
|
2130 | return Component.displayName || Component.name || 'Component';
|
2131 | }
|
2132 |
|
2133 | var CASE_INSENSITIVE = 'i';
|
2134 | var COMBINING_MARKS = /[\u0300-\u036F]/;
|
2135 |
|
2136 | function escapeStringRegexp(str) {
|
2137 | !(typeof str === 'string') ? invariant_1(false, '`escapeStringRegexp` expected a string.') : void 0;
|
2138 |
|
2139 |
|
2140 |
|
2141 |
|
2142 | return str.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d');
|
2143 | }
|
2144 | function getMatchBounds(subject, str) {
|
2145 | var search = new RegExp(escapeStringRegexp(stripDiacritics(str)), CASE_INSENSITIVE);
|
2146 | var matches = search.exec(stripDiacritics(subject));
|
2147 |
|
2148 | if (!matches) {
|
2149 | return null;
|
2150 | }
|
2151 |
|
2152 | var start = matches.index;
|
2153 | var matchLength = matches[0].length;
|
2154 |
|
2155 | if (COMBINING_MARKS.test(subject)) {
|
2156 |
|
2157 |
|
2158 | for (var ii = 0; ii <= start; ii++) {
|
2159 | if (COMBINING_MARKS.test(subject[ii])) {
|
2160 | start += 1;
|
2161 | }
|
2162 | }
|
2163 |
|
2164 |
|
2165 |
|
2166 | for (var _ii = start; _ii <= start + matchLength; _ii++) {
|
2167 | if (COMBINING_MARKS.test(subject[_ii])) {
|
2168 | matchLength += 1;
|
2169 | }
|
2170 | }
|
2171 | }
|
2172 |
|
2173 | return {
|
2174 | end: start + matchLength,
|
2175 | start: start
|
2176 | };
|
2177 | }
|
2178 |
|
2179 | function getHintText(props) {
|
2180 | var activeIndex = props.activeIndex,
|
2181 | initialItem = props.initialItem,
|
2182 | isFocused = props.isFocused,
|
2183 | isMenuShown = props.isMenuShown,
|
2184 | labelKey = props.labelKey,
|
2185 | multiple = props.multiple,
|
2186 | selected = props.selected,
|
2187 | text = props.text;
|
2188 |
|
2189 | if (
|
2190 | !text ||
|
2191 | !isFocused ||
|
2192 | !isMenuShown ||
|
2193 | !initialItem ||
|
2194 | initialItem.customOption ||
|
2195 | activeIndex > -1 ||
|
2196 | !!selected.length && !multiple) {
|
2197 | return '';
|
2198 | }
|
2199 |
|
2200 | var initialItemStr = getOptionLabel(initialItem, labelKey);
|
2201 | var bounds = getMatchBounds(initialItemStr.toLowerCase(), text.toLowerCase());
|
2202 |
|
2203 | if (!(bounds && bounds.start === 0)) {
|
2204 | return '';
|
2205 | }
|
2206 |
|
2207 |
|
2208 |
|
2209 | return text + initialItemStr.slice(bounds.end, initialItemStr.length);
|
2210 | }
|
2211 |
|
2212 | var classnames = createCommonjsModule(function (module) {
|
2213 | |
2214 |
|
2215 |
|
2216 |
|
2217 |
|
2218 |
|
2219 |
|
2220 | (function () {
|
2221 |
|
2222 | var hasOwn = {}.hasOwnProperty;
|
2223 |
|
2224 | function classNames () {
|
2225 | var classes = [];
|
2226 |
|
2227 | for (var i = 0; i < arguments.length; i++) {
|
2228 | var arg = arguments[i];
|
2229 | if (!arg) continue;
|
2230 |
|
2231 | var argType = typeof arg;
|
2232 |
|
2233 | if (argType === 'string' || argType === 'number') {
|
2234 | classes.push(arg);
|
2235 | } else if (Array.isArray(arg) && arg.length) {
|
2236 | var inner = classNames.apply(null, arg);
|
2237 | if (inner) {
|
2238 | classes.push(inner);
|
2239 | }
|
2240 | } else if (argType === 'object') {
|
2241 | for (var key in arg) {
|
2242 | if (hasOwn.call(arg, key) && arg[key]) {
|
2243 | classes.push(key);
|
2244 | }
|
2245 | }
|
2246 | }
|
2247 | }
|
2248 |
|
2249 | return classes.join(' ');
|
2250 | }
|
2251 |
|
2252 | if ( module.exports) {
|
2253 | classNames.default = classNames;
|
2254 | module.exports = classNames;
|
2255 | } else {
|
2256 | window.classNames = classNames;
|
2257 | }
|
2258 | }());
|
2259 | });
|
2260 |
|
2261 | function getMenuItemId(id, position) {
|
2262 | return (id || '') + "-item-" + position;
|
2263 | }
|
2264 |
|
2265 | var getInputProps = function getInputProps(_ref) {
|
2266 | var activeIndex = _ref.activeIndex,
|
2267 | id = _ref.id,
|
2268 | isFocused = _ref.isFocused,
|
2269 | isMenuShown = _ref.isMenuShown,
|
2270 | multiple = _ref.multiple,
|
2271 | onFocus = _ref.onFocus,
|
2272 | placeholder = _ref.placeholder,
|
2273 | rest = _objectWithoutPropertiesLoose(_ref, ["activeIndex", "id", "isFocused", "isMenuShown", "multiple", "onFocus", "placeholder"]);
|
2274 |
|
2275 | return function (_temp) {
|
2276 | var _cx;
|
2277 |
|
2278 | var _ref2 = _temp === void 0 ? {} : _temp,
|
2279 | className = _ref2.className,
|
2280 | inputProps = _objectWithoutPropertiesLoose(_ref2, ["className"]);
|
2281 |
|
2282 | var props = _extends({
|
2283 |
|
2284 |
|
2285 | autoComplete: 'off',
|
2286 | placeholder: placeholder,
|
2287 | type: 'text'
|
2288 | }, inputProps, rest, {
|
2289 | 'aria-activedescendant': activeIndex >= 0 ? getMenuItemId(id, activeIndex) : undefined,
|
2290 | 'aria-autocomplete': 'both',
|
2291 | 'aria-expanded': isMenuShown,
|
2292 | 'aria-haspopup': 'listbox',
|
2293 | 'aria-owns': isMenuShown ? id : undefined,
|
2294 | className: classnames((_cx = {}, _cx[className || ''] = !multiple, _cx.focus = isFocused, _cx)),
|
2295 |
|
2296 | onClick: onFocus,
|
2297 | onFocus: onFocus,
|
2298 |
|
2299 |
|
2300 | role: 'combobox'
|
2301 |
|
2302 |
|
2303 | });
|
2304 |
|
2305 | if (!multiple) {
|
2306 | return props;
|
2307 | }
|
2308 |
|
2309 | return _extends({}, props, {
|
2310 | 'aria-autocomplete': 'list',
|
2311 | 'aria-expanded': undefined,
|
2312 | inputClassName: className,
|
2313 | role: undefined
|
2314 | });
|
2315 | };
|
2316 | };
|
2317 |
|
2318 | function getInputText(props) {
|
2319 | var activeItem = props.activeItem,
|
2320 | labelKey = props.labelKey,
|
2321 | multiple = props.multiple,
|
2322 | selected = props.selected,
|
2323 | text = props.text;
|
2324 |
|
2325 | if (activeItem) {
|
2326 |
|
2327 | return getOptionLabel(activeItem, labelKey);
|
2328 | }
|
2329 |
|
2330 | var selectedItem = !multiple && !!selected.length && head(selected);
|
2331 |
|
2332 | if (selectedItem) {
|
2333 | return getOptionLabel(selectedItem, labelKey);
|
2334 | }
|
2335 |
|
2336 | return text;
|
2337 | }
|
2338 |
|
2339 | function getIsOnlyResult(props) {
|
2340 | var allowNew = props.allowNew,
|
2341 | highlightOnlyResult = props.highlightOnlyResult,
|
2342 | results = props.results;
|
2343 |
|
2344 | if (!highlightOnlyResult || allowNew) {
|
2345 | return false;
|
2346 | }
|
2347 |
|
2348 | return results.length === 1 && !getOptionProperty(head(results), 'disabled');
|
2349 | }
|
2350 |
|
2351 | |
2352 |
|
2353 |
|
2354 | function getTruncatedOptions(options, maxResults) {
|
2355 | if (!maxResults || maxResults >= options.length) {
|
2356 | return options;
|
2357 | }
|
2358 |
|
2359 | return options.slice(0, maxResults);
|
2360 | }
|
2361 |
|
2362 | function skipDisabledOptions(currentIndex, keyCode, items) {
|
2363 | var newIndex = currentIndex;
|
2364 |
|
2365 | while (items[newIndex] && items[newIndex].disabled) {
|
2366 | newIndex += keyCode === UP ? -1 : 1;
|
2367 | }
|
2368 |
|
2369 | return newIndex;
|
2370 | }
|
2371 |
|
2372 | function getUpdatedActiveIndex(currentIndex, keyCode, items) {
|
2373 | var newIndex = currentIndex;
|
2374 |
|
2375 | newIndex += keyCode === UP ? -1 : 1;
|
2376 |
|
2377 | newIndex = skipDisabledOptions(newIndex, keyCode, items);
|
2378 |
|
2379 | if (newIndex === items.length) {
|
2380 | newIndex = -1;
|
2381 | } else if (newIndex === -2) {
|
2382 | newIndex = items.length - 1;
|
2383 |
|
2384 | newIndex = skipDisabledOptions(newIndex, keyCode, items);
|
2385 | }
|
2386 |
|
2387 | return newIndex;
|
2388 | }
|
2389 |
|
2390 | |
2391 |
|
2392 |
|
2393 |
|
2394 |
|
2395 |
|
2396 |
|
2397 | function isSelectable(inputNode) {
|
2398 | return inputNode.selectionStart != null;
|
2399 | }
|
2400 |
|
2401 | function isShown(props) {
|
2402 | var open = props.open,
|
2403 | minLength = props.minLength,
|
2404 | showMenu = props.showMenu,
|
2405 | text = props.text;
|
2406 |
|
2407 | if (open || open === false) {
|
2408 | return open;
|
2409 | }
|
2410 |
|
2411 | if (text.length < minLength) {
|
2412 | return false;
|
2413 | }
|
2414 |
|
2415 | return showMenu;
|
2416 | }
|
2417 |
|
2418 | |
2419 |
|
2420 |
|
2421 |
|
2422 | function preventInputBlur(e) {
|
2423 | e.preventDefault();
|
2424 | }
|
2425 |
|
2426 | function isSizeLarge(size) {
|
2427 | return size === 'large' || size === 'lg';
|
2428 | }
|
2429 | function isSizeSmall(size) {
|
2430 | return size === 'small' || size === 'sm';
|
2431 | }
|
2432 |
|
2433 | function validateSelectedPropChange(prevSelected, selected) {
|
2434 | var uncontrolledToControlled = !prevSelected && selected;
|
2435 | var controlledToUncontrolled = prevSelected && !selected;
|
2436 | var from, to, precedent;
|
2437 |
|
2438 | if (uncontrolledToControlled) {
|
2439 | from = 'uncontrolled';
|
2440 | to = 'controlled';
|
2441 | precedent = 'an';
|
2442 | } else {
|
2443 | from = 'controlled';
|
2444 | to = 'uncontrolled';
|
2445 | precedent = 'a';
|
2446 | }
|
2447 |
|
2448 | var message = "You are changing " + precedent + " " + from + " typeahead to be " + to + ". " + ("Input elements should not switch from " + from + " to " + to + " (or vice versa). ") + 'Decide between using a controlled or uncontrolled element for the ' + 'lifetime of the component.';
|
2449 | warn(!(uncontrolledToControlled || controlledToUncontrolled), message);
|
2450 | }
|
2451 |
|
2452 | var TypeaheadContext = React.createContext({
|
2453 | activeIndex: -1,
|
2454 | hintText: '',
|
2455 | id: '',
|
2456 | initialItem: null,
|
2457 | inputNode: null,
|
2458 | isOnlyResult: false,
|
2459 | onActiveItemChange: noop,
|
2460 | onAdd: noop,
|
2461 | onInitialItemChange: noop,
|
2462 | onMenuItemClick: noop,
|
2463 | selectHintOnEnter: undefined,
|
2464 | setItem: noop
|
2465 | });
|
2466 | var useTypeaheadContext = function useTypeaheadContext() {
|
2467 | return React.useContext(TypeaheadContext);
|
2468 | };
|
2469 |
|
2470 | var inputPropKeys = ['activeIndex', 'disabled', 'id', 'inputRef', 'isFocused', 'isMenuShown', 'multiple', 'onBlur', 'onChange', 'onFocus', 'onKeyDown', 'placeholder'];
|
2471 | var propKeys = ['activeIndex', 'hideMenu', 'isMenuShown', 'labelKey', 'onClear', 'onHide', 'onRemove', 'results', 'selected', 'text', 'toggleMenu'];
|
2472 | var contextKeys = ['activeIndex', 'id', 'initialItem', 'inputNode', 'onActiveItemChange', 'onAdd', 'onInitialItemChange', 'onMenuItemClick', 'selectHintOnEnter', 'setItem'];
|
2473 |
|
2474 | var TypeaheadManager = function TypeaheadManager(props) {
|
2475 | var allowNew = props.allowNew,
|
2476 | children = props.children,
|
2477 | initialItem = props.initialItem,
|
2478 | isMenuShown = props.isMenuShown,
|
2479 | onAdd = props.onAdd,
|
2480 | onInitialItemChange = props.onInitialItemChange,
|
2481 | onKeyDown = props.onKeyDown,
|
2482 | onMenuToggle = props.onMenuToggle,
|
2483 | results = props.results;
|
2484 | var prevProps = usePrevious(props);
|
2485 | React.useEffect(function () {
|
2486 |
|
2487 | if (!(allowNew || results.length)) {
|
2488 | onInitialItemChange(null);
|
2489 | }
|
2490 | });
|
2491 | React.useEffect(function () {
|
2492 | if (prevProps && prevProps.isMenuShown !== isMenuShown) {
|
2493 | onMenuToggle(isMenuShown);
|
2494 | }
|
2495 | });
|
2496 |
|
2497 | var handleKeyDown = function handleKeyDown(e) {
|
2498 | switch (e.keyCode) {
|
2499 | case RETURN:
|
2500 | if (initialItem && getIsOnlyResult(props)) {
|
2501 | onAdd(initialItem);
|
2502 | }
|
2503 |
|
2504 | break;
|
2505 | }
|
2506 |
|
2507 | onKeyDown(e);
|
2508 | };
|
2509 |
|
2510 | var childProps = _extends({}, pick(props, propKeys), {
|
2511 | getInputProps: getInputProps(_extends({}, pick(props, inputPropKeys), {
|
2512 | onKeyDown: handleKeyDown,
|
2513 | value: getInputText(props)
|
2514 | }))
|
2515 | });
|
2516 |
|
2517 | var contextValue = _extends({}, pick(props, contextKeys), {
|
2518 | hintText: getHintText(props),
|
2519 | isOnlyResult: getIsOnlyResult(props)
|
2520 | });
|
2521 |
|
2522 | return React__default.createElement(TypeaheadContext.Provider, {
|
2523 | value: contextValue
|
2524 | }, children(childProps));
|
2525 | };
|
2526 |
|
2527 | var INPUT_PROPS_BLACKLIST = [{
|
2528 | alt: 'onBlur',
|
2529 | prop: 'onBlur'
|
2530 | }, {
|
2531 | alt: 'onInputChange',
|
2532 | prop: 'onChange'
|
2533 | }, {
|
2534 | alt: 'onFocus',
|
2535 | prop: 'onFocus'
|
2536 | }, {
|
2537 | alt: 'onKeyDown',
|
2538 | prop: 'onKeyDown'
|
2539 | }];
|
2540 | var sizeType = propTypes.oneOf(values(SIZE));
|
2541 | |
2542 |
|
2543 |
|
2544 |
|
2545 | function checkPropType(validator, callback) {
|
2546 | return function (props, propName, componentName) {
|
2547 | var _PropTypes$checkPropT;
|
2548 |
|
2549 | propTypes.checkPropTypes((_PropTypes$checkPropT = {}, _PropTypes$checkPropT[propName] = validator, _PropTypes$checkPropT), props, 'prop', componentName);
|
2550 | isFunction(callback) && callback(props, propName, componentName);
|
2551 | };
|
2552 | }
|
2553 | function caseSensitiveType(props, propName, componentName) {
|
2554 | var caseSensitive = props.caseSensitive,
|
2555 | filterBy = props.filterBy;
|
2556 | warn(!caseSensitive || typeof filterBy !== 'function', 'Your `filterBy` function will override the `caseSensitive` prop.');
|
2557 | }
|
2558 | function deprecated(validator, reason) {
|
2559 | return function (props, propName, componentName) {
|
2560 | var _PropTypes$checkPropT2;
|
2561 |
|
2562 | if (props[propName] != null) {
|
2563 | warn(false, "The `" + propName + "` prop is deprecated. " + reason);
|
2564 | }
|
2565 |
|
2566 | return propTypes.checkPropTypes((_PropTypes$checkPropT2 = {}, _PropTypes$checkPropT2[propName] = validator, _PropTypes$checkPropT2), props, 'prop', componentName);
|
2567 | };
|
2568 | }
|
2569 | function defaultInputValueType(props, propName, componentName) {
|
2570 | var defaultInputValue = props.defaultInputValue,
|
2571 | defaultSelected = props.defaultSelected,
|
2572 | multiple = props.multiple,
|
2573 | selected = props.selected;
|
2574 | var name = defaultSelected.length ? 'defaultSelected' : 'selected';
|
2575 | warn(!(!multiple && defaultInputValue && (defaultSelected.length || selected && selected.length)), "`defaultInputValue` will be overridden by the value from `" + name + "`.");
|
2576 | }
|
2577 | function defaultSelectedType(props, propName, componentName) {
|
2578 | var defaultSelected = props.defaultSelected,
|
2579 | multiple = props.multiple;
|
2580 | 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.');
|
2581 | }
|
2582 | function highlightOnlyResultType(props, propName, componentName) {
|
2583 | var allowNew = props.allowNew,
|
2584 | highlightOnlyResult = props.highlightOnlyResult;
|
2585 | warn(!(highlightOnlyResult && allowNew), '`highlightOnlyResult` will not work with `allowNew`.');
|
2586 | }
|
2587 | function ignoreDiacriticsType(props, propName, componentName) {
|
2588 | var filterBy = props.filterBy,
|
2589 | ignoreDiacritics = props.ignoreDiacritics;
|
2590 | warn(ignoreDiacritics || typeof filterBy !== 'function', 'Your `filterBy` function will override the `ignoreDiacritics` prop.');
|
2591 | }
|
2592 | function inputPropsType(props, propName, componentName) {
|
2593 | var inputProps = props.inputProps;
|
2594 |
|
2595 | if (!(inputProps && Object.prototype.toString.call(inputProps) === '[object Object]')) {
|
2596 | return;
|
2597 | }
|
2598 |
|
2599 |
|
2600 | INPUT_PROPS_BLACKLIST.forEach(function (_ref) {
|
2601 | var alt = _ref.alt,
|
2602 | prop = _ref.prop;
|
2603 | var msg = alt ? " Use the top-level `" + alt + "` prop instead." : null;
|
2604 | warn(!inputProps[prop], "The `" + prop + "` property of `inputProps` will be ignored." + msg);
|
2605 | });
|
2606 | }
|
2607 | function isRequiredForA11y(props, propName, componentName) {
|
2608 | warn(props[propName] != null, "The prop `" + propName + "` is required to make `" + componentName + "` " + 'accessible for users of assistive technologies such as screen readers.');
|
2609 | }
|
2610 | function labelKeyType(props, propName, componentName) {
|
2611 | var allowNew = props.allowNew,
|
2612 | labelKey = props.labelKey;
|
2613 | warn(!(isFunction(labelKey) && allowNew), '`labelKey` must be a string when `allowNew={true}`.');
|
2614 | }
|
2615 | var optionType = propTypes.oneOfType([propTypes.object, propTypes.string]);
|
2616 | function selectedType(props, propName, componentName) {
|
2617 | var multiple = props.multiple,
|
2618 | onChange = props.onChange,
|
2619 | selected = props.selected;
|
2620 | 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.');
|
2621 | 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`.');
|
2622 | }
|
2623 |
|
2624 | var propTypes$1 = {
|
2625 | |
2626 |
|
2627 |
|
2628 |
|
2629 |
|
2630 |
|
2631 |
|
2632 |
|
2633 | allowNew: propTypes.oneOfType([propTypes.bool, propTypes.func]),
|
2634 |
|
2635 | |
2636 |
|
2637 |
|
2638 | autoFocus: propTypes.bool,
|
2639 |
|
2640 | |
2641 |
|
2642 |
|
2643 | caseSensitive: checkPropType(propTypes.bool, caseSensitiveType),
|
2644 |
|
2645 | |
2646 |
|
2647 |
|
2648 | defaultInputValue: checkPropType(propTypes.string, defaultInputValueType),
|
2649 |
|
2650 | |
2651 |
|
2652 |
|
2653 | defaultOpen: propTypes.bool,
|
2654 |
|
2655 | |
2656 |
|
2657 |
|
2658 |
|
2659 | defaultSelected: checkPropType(propTypes.arrayOf(optionType), defaultSelectedType),
|
2660 |
|
2661 | |
2662 |
|
2663 |
|
2664 |
|
2665 | filterBy: propTypes.oneOfType([propTypes.arrayOf(propTypes.string.isRequired), propTypes.func]),
|
2666 |
|
2667 | |
2668 |
|
2669 |
|
2670 |
|
2671 | highlightOnlyResult: checkPropType(propTypes.bool, highlightOnlyResultType),
|
2672 |
|
2673 | |
2674 |
|
2675 |
|
2676 |
|
2677 | id: checkPropType(propTypes.oneOfType([propTypes.number, propTypes.string]), isRequiredForA11y),
|
2678 |
|
2679 | |
2680 |
|
2681 |
|
2682 | ignoreDiacritics: checkPropType(propTypes.bool, ignoreDiacriticsType),
|
2683 |
|
2684 | |
2685 |
|
2686 |
|
2687 |
|
2688 | labelKey: checkPropType(propTypes.oneOfType([propTypes.string, propTypes.func]), labelKeyType),
|
2689 |
|
2690 | |
2691 |
|
2692 |
|
2693 |
|
2694 |
|
2695 | maxResults: propTypes.number,
|
2696 |
|
2697 | |
2698 |
|
2699 |
|
2700 | minLength: propTypes.number,
|
2701 |
|
2702 | |
2703 |
|
2704 |
|
2705 | multiple: propTypes.bool,
|
2706 |
|
2707 | |
2708 |
|
2709 |
|
2710 | onBlur: propTypes.func,
|
2711 |
|
2712 | |
2713 |
|
2714 |
|
2715 |
|
2716 | onChange: propTypes.func,
|
2717 |
|
2718 | |
2719 |
|
2720 |
|
2721 | onFocus: propTypes.func,
|
2722 |
|
2723 | |
2724 |
|
2725 |
|
2726 |
|
2727 | onInputChange: propTypes.func,
|
2728 |
|
2729 | |
2730 |
|
2731 |
|
2732 | onKeyDown: propTypes.func,
|
2733 |
|
2734 | |
2735 |
|
2736 |
|
2737 | onMenuToggle: propTypes.func,
|
2738 |
|
2739 | |
2740 |
|
2741 |
|
2742 | onPaginate: propTypes.func,
|
2743 |
|
2744 | |
2745 |
|
2746 |
|
2747 |
|
2748 |
|
2749 | open: propTypes.bool,
|
2750 |
|
2751 | |
2752 |
|
2753 |
|
2754 |
|
2755 | options: propTypes.arrayOf(optionType).isRequired,
|
2756 |
|
2757 | |
2758 |
|
2759 |
|
2760 |
|
2761 | paginate: propTypes.bool,
|
2762 |
|
2763 | |
2764 |
|
2765 |
|
2766 |
|
2767 | selected: checkPropType(propTypes.arrayOf(optionType), selectedType),
|
2768 |
|
2769 | |
2770 |
|
2771 |
|
2772 | selectHintOnEnter: deprecated(propTypes.bool, 'Use the `shouldSelect` prop on the `Hint` component to define which ' + 'keystrokes can select the hint.')
|
2773 | };
|
2774 | var defaultProps = {
|
2775 | allowNew: false,
|
2776 | autoFocus: false,
|
2777 | caseSensitive: false,
|
2778 | defaultInputValue: '',
|
2779 | defaultOpen: false,
|
2780 | defaultSelected: [],
|
2781 | filterBy: [],
|
2782 | highlightOnlyResult: false,
|
2783 | ignoreDiacritics: true,
|
2784 | labelKey: DEFAULT_LABELKEY,
|
2785 | maxResults: 100,
|
2786 | minLength: 0,
|
2787 | multiple: false,
|
2788 | onBlur: noop,
|
2789 | onFocus: noop,
|
2790 | onInputChange: noop,
|
2791 | onKeyDown: noop,
|
2792 | onMenuToggle: noop,
|
2793 | onPaginate: noop,
|
2794 | paginate: true
|
2795 | };
|
2796 | function getInitialState(props) {
|
2797 | var defaultInputValue = props.defaultInputValue,
|
2798 | defaultOpen = props.defaultOpen,
|
2799 | defaultSelected = props.defaultSelected,
|
2800 | maxResults = props.maxResults,
|
2801 | multiple = props.multiple;
|
2802 | var selected = props.selected ? props.selected.slice() : defaultSelected.slice();
|
2803 | var text = defaultInputValue;
|
2804 |
|
2805 | if (!multiple && selected.length) {
|
2806 |
|
2807 | text = getOptionLabel(head(selected), props.labelKey);
|
2808 |
|
2809 | if (selected.length > 1) {
|
2810 |
|
2811 | selected = selected.slice(0, 1);
|
2812 | }
|
2813 | }
|
2814 |
|
2815 | return {
|
2816 | activeIndex: -1,
|
2817 | activeItem: null,
|
2818 | initialItem: null,
|
2819 | isFocused: false,
|
2820 | selected: selected,
|
2821 | showMenu: defaultOpen,
|
2822 | shownResults: maxResults,
|
2823 | text: text
|
2824 | };
|
2825 | }
|
2826 | function clearTypeahead(state, props) {
|
2827 | return _extends({}, getInitialState(props), {
|
2828 | isFocused: state.isFocused,
|
2829 | selected: [],
|
2830 | text: ''
|
2831 | });
|
2832 | }
|
2833 | function hideMenu(state, props) {
|
2834 | var _getInitialState = getInitialState(props),
|
2835 | activeIndex = _getInitialState.activeIndex,
|
2836 | activeItem = _getInitialState.activeItem,
|
2837 | initialItem = _getInitialState.initialItem,
|
2838 | shownResults = _getInitialState.shownResults;
|
2839 |
|
2840 | return {
|
2841 | activeIndex: activeIndex,
|
2842 | activeItem: activeItem,
|
2843 | initialItem: initialItem,
|
2844 | showMenu: false,
|
2845 | shownResults: shownResults
|
2846 | };
|
2847 | }
|
2848 | function toggleMenu(state, props) {
|
2849 | return state.showMenu ? hideMenu(state, props) : {
|
2850 | showMenu: true
|
2851 | };
|
2852 | }
|
2853 |
|
2854 | var Typeahead = function (_React$Component) {
|
2855 | _inheritsLoose(Typeahead, _React$Component);
|
2856 |
|
2857 | function Typeahead() {
|
2858 | var _this;
|
2859 |
|
2860 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
2861 | args[_key] = arguments[_key];
|
2862 | }
|
2863 |
|
2864 | _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
|
2865 |
|
2866 | _defineProperty(_assertThisInitialized(_this), "state", getInitialState(_this.props));
|
2867 |
|
2868 | _defineProperty(_assertThisInitialized(_this), "inputNode", void 0);
|
2869 |
|
2870 | _defineProperty(_assertThisInitialized(_this), "isMenuShown", false);
|
2871 |
|
2872 | _defineProperty(_assertThisInitialized(_this), "items", []);
|
2873 |
|
2874 | _defineProperty(_assertThisInitialized(_this), "blur", function () {
|
2875 | _this.inputNode && _this.inputNode.blur();
|
2876 |
|
2877 | _this.hideMenu();
|
2878 | });
|
2879 |
|
2880 | _defineProperty(_assertThisInitialized(_this), "clear", function () {
|
2881 | _this.setState(clearTypeahead);
|
2882 | });
|
2883 |
|
2884 | _defineProperty(_assertThisInitialized(_this), "focus", function () {
|
2885 | _this.inputNode && _this.inputNode.focus();
|
2886 | });
|
2887 |
|
2888 | _defineProperty(_assertThisInitialized(_this), "getInput", function () {
|
2889 | return _this.inputNode;
|
2890 | });
|
2891 |
|
2892 | _defineProperty(_assertThisInitialized(_this), "inputRef", function (inputNode) {
|
2893 | _this.inputNode = inputNode;
|
2894 | });
|
2895 |
|
2896 | _defineProperty(_assertThisInitialized(_this), "setItem", function (item, position) {
|
2897 | _this.items[position] = item;
|
2898 | });
|
2899 |
|
2900 | _defineProperty(_assertThisInitialized(_this), "hideMenu", function () {
|
2901 | _this.setState(hideMenu);
|
2902 | });
|
2903 |
|
2904 | _defineProperty(_assertThisInitialized(_this), "toggleMenu", function () {
|
2905 | _this.setState(toggleMenu);
|
2906 | });
|
2907 |
|
2908 | _defineProperty(_assertThisInitialized(_this), "_handleActiveIndexChange", function (activeIndex) {
|
2909 | _this.setState(function (state) {
|
2910 | return {
|
2911 | activeIndex: activeIndex,
|
2912 | activeItem: activeIndex === -1 ? null : state.activeItem
|
2913 | };
|
2914 | });
|
2915 | });
|
2916 |
|
2917 | _defineProperty(_assertThisInitialized(_this), "_handleActiveItemChange", function (activeItem) {
|
2918 |
|
2919 | if (!fastDeepEqual(activeItem, _this.state.activeItem)) {
|
2920 | _this.setState({
|
2921 | activeItem: activeItem
|
2922 | });
|
2923 | }
|
2924 | });
|
2925 |
|
2926 | _defineProperty(_assertThisInitialized(_this), "_handleBlur", function (e) {
|
2927 | e.persist();
|
2928 |
|
2929 | _this.setState({
|
2930 | isFocused: false
|
2931 | }, function () {
|
2932 | return _this.props.onBlur(e);
|
2933 | });
|
2934 | });
|
2935 |
|
2936 | _defineProperty(_assertThisInitialized(_this), "_handleChange", function (selected) {
|
2937 | _this.props.onChange && _this.props.onChange(selected);
|
2938 | });
|
2939 |
|
2940 | _defineProperty(_assertThisInitialized(_this), "_handleClear", function () {
|
2941 | _this.setState(clearTypeahead, function () {
|
2942 | return _this._handleChange([]);
|
2943 | });
|
2944 | });
|
2945 |
|
2946 | _defineProperty(_assertThisInitialized(_this), "_handleFocus", function (e) {
|
2947 | e.persist();
|
2948 |
|
2949 | _this.setState({
|
2950 | isFocused: true,
|
2951 | showMenu: true
|
2952 | }, function () {
|
2953 | return _this.props.onFocus(e);
|
2954 | });
|
2955 | });
|
2956 |
|
2957 | _defineProperty(_assertThisInitialized(_this), "_handleInitialItemChange", function (initialItem) {
|
2958 |
|
2959 | if (!fastDeepEqual(initialItem, _this.state.initialItem)) {
|
2960 | _this.setState({
|
2961 | initialItem: initialItem
|
2962 | });
|
2963 | }
|
2964 | });
|
2965 |
|
2966 | _defineProperty(_assertThisInitialized(_this), "_handleInputChange", function (e) {
|
2967 | e.persist();
|
2968 | var text = e.currentTarget.value;
|
2969 | var _this$props = _this.props,
|
2970 | multiple = _this$props.multiple,
|
2971 | onInputChange = _this$props.onInputChange;
|
2972 |
|
2973 | var shouldClearSelections = _this.state.selected.length && !multiple;
|
2974 |
|
2975 | _this.setState(function (state, props) {
|
2976 | var _getInitialState2 = getInitialState(props),
|
2977 | activeIndex = _getInitialState2.activeIndex,
|
2978 | activeItem = _getInitialState2.activeItem,
|
2979 | shownResults = _getInitialState2.shownResults;
|
2980 |
|
2981 | return {
|
2982 | activeIndex: activeIndex,
|
2983 | activeItem: activeItem,
|
2984 | selected: shouldClearSelections ? [] : state.selected,
|
2985 | showMenu: true,
|
2986 | shownResults: shownResults,
|
2987 | text: text
|
2988 | };
|
2989 | }, function () {
|
2990 | onInputChange(text, e);
|
2991 | shouldClearSelections && _this._handleChange([]);
|
2992 | });
|
2993 | });
|
2994 |
|
2995 | _defineProperty(_assertThisInitialized(_this), "_handleKeyDown", function (e) {
|
2996 | var activeItem = _this.state.activeItem;
|
2997 |
|
2998 | if (!_this.isMenuShown) {
|
2999 | if (e.keyCode === UP || e.keyCode === DOWN) {
|
3000 | _this.setState({
|
3001 | showMenu: true
|
3002 | });
|
3003 | }
|
3004 |
|
3005 | _this.props.onKeyDown(e);
|
3006 |
|
3007 | return;
|
3008 | }
|
3009 |
|
3010 | switch (e.keyCode) {
|
3011 | case UP:
|
3012 | case DOWN:
|
3013 |
|
3014 | e.preventDefault();
|
3015 |
|
3016 | _this._handleActiveIndexChange(getUpdatedActiveIndex(_this.state.activeIndex, e.keyCode, _this.items));
|
3017 |
|
3018 | break;
|
3019 |
|
3020 | case RETURN:
|
3021 |
|
3022 | e.preventDefault();
|
3023 | activeItem && _this._handleMenuItemSelect(activeItem, e);
|
3024 | break;
|
3025 |
|
3026 | case ESC:
|
3027 | case TAB:
|
3028 |
|
3029 |
|
3030 | _this.hideMenu();
|
3031 |
|
3032 | break;
|
3033 | }
|
3034 |
|
3035 | _this.props.onKeyDown(e);
|
3036 | });
|
3037 |
|
3038 | _defineProperty(_assertThisInitialized(_this), "_handleMenuItemSelect", function (option, e) {
|
3039 | if (option.paginationOption) {
|
3040 | _this._handlePaginate(e);
|
3041 | } else {
|
3042 | _this._handleSelectionAdd(option);
|
3043 | }
|
3044 | });
|
3045 |
|
3046 | _defineProperty(_assertThisInitialized(_this), "_handlePaginate", function (e) {
|
3047 | e.persist();
|
3048 |
|
3049 | _this.setState(function (state, props) {
|
3050 | return {
|
3051 | shownResults: state.shownResults + props.maxResults
|
3052 | };
|
3053 | }, function () {
|
3054 | return _this.props.onPaginate(e, _this.state.shownResults);
|
3055 | });
|
3056 | });
|
3057 |
|
3058 | _defineProperty(_assertThisInitialized(_this), "_handleSelectionAdd", function (option) {
|
3059 | var _this$props2 = _this.props,
|
3060 | multiple = _this$props2.multiple,
|
3061 | labelKey = _this$props2.labelKey;
|
3062 | var selected;
|
3063 | var selection = option;
|
3064 | var text;
|
3065 |
|
3066 |
|
3067 | if (!isString(selection) && selection.customOption) {
|
3068 | selection = _extends({}, selection, {
|
3069 | id: uniqueId('new-id-')
|
3070 | });
|
3071 | }
|
3072 |
|
3073 | if (multiple) {
|
3074 |
|
3075 |
|
3076 | selected = _this.state.selected.concat(selection);
|
3077 | text = '';
|
3078 | } else {
|
3079 |
|
3080 |
|
3081 | selected = [selection];
|
3082 | text = getOptionLabel(selection, labelKey);
|
3083 | }
|
3084 |
|
3085 | _this.setState(function (state, props) {
|
3086 | return _extends({}, hideMenu(state, props), {
|
3087 | initialItem: selection,
|
3088 | selected: selected,
|
3089 | text: text
|
3090 | });
|
3091 | }, function () {
|
3092 | return _this._handleChange(selected);
|
3093 | });
|
3094 | });
|
3095 |
|
3096 | _defineProperty(_assertThisInitialized(_this), "_handleSelectionRemove", function (selection) {
|
3097 | var selected = _this.state.selected.filter(function (option) {
|
3098 | return !fastDeepEqual(option, selection);
|
3099 | });
|
3100 |
|
3101 |
|
3102 | _this.focus();
|
3103 |
|
3104 | _this.setState(function (state, props) {
|
3105 | return _extends({}, hideMenu(state, props), {
|
3106 | selected: selected
|
3107 | });
|
3108 | }, function () {
|
3109 | return _this._handleChange(selected);
|
3110 | });
|
3111 | });
|
3112 |
|
3113 | return _this;
|
3114 | }
|
3115 |
|
3116 | var _proto = Typeahead.prototype;
|
3117 |
|
3118 | _proto.componentDidMount = function componentDidMount() {
|
3119 | this.props.autoFocus && this.focus();
|
3120 | };
|
3121 |
|
3122 | _proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
|
3123 | var _this$props3 = this.props,
|
3124 | labelKey = _this$props3.labelKey,
|
3125 | multiple = _this$props3.multiple,
|
3126 | selected = _this$props3.selected;
|
3127 | validateSelectedPropChange(selected, prevProps.selected);
|
3128 |
|
3129 | if (selected && !fastDeepEqual(selected, prevState.selected)) {
|
3130 | this.setState({
|
3131 | selected: selected
|
3132 | });
|
3133 |
|
3134 | if (!multiple) {
|
3135 | this.setState({
|
3136 | text: selected.length ? getOptionLabel(head(selected), labelKey) : ''
|
3137 | });
|
3138 | }
|
3139 | }
|
3140 | };
|
3141 |
|
3142 | _proto.render = function render() {
|
3143 |
|
3144 | var _this$props4 = this.props,
|
3145 | onChange = _this$props4.onChange,
|
3146 | otherProps = _objectWithoutPropertiesLoose(_this$props4, ["onChange"]);
|
3147 |
|
3148 | var mergedPropsAndState = _extends({}, otherProps, this.state);
|
3149 |
|
3150 | var filterBy = mergedPropsAndState.filterBy,
|
3151 | labelKey = mergedPropsAndState.labelKey,
|
3152 | options = mergedPropsAndState.options,
|
3153 | paginate = mergedPropsAndState.paginate,
|
3154 | shownResults = mergedPropsAndState.shownResults,
|
3155 | text = mergedPropsAndState.text;
|
3156 | this.isMenuShown = isShown(mergedPropsAndState);
|
3157 | this.items = [];
|
3158 |
|
3159 | var results = [];
|
3160 |
|
3161 | if (this.isMenuShown) {
|
3162 | var cb = typeof filterBy === 'function' ? filterBy : defaultFilterBy;
|
3163 | results = options.filter(function (option) {
|
3164 | return cb(option, mergedPropsAndState);
|
3165 | });
|
3166 |
|
3167 | var shouldPaginate = paginate && results.length > shownResults;
|
3168 |
|
3169 | results = getTruncatedOptions(results, shownResults);
|
3170 |
|
3171 | if (addCustomOption(results, mergedPropsAndState)) {
|
3172 | var _results$push;
|
3173 |
|
3174 | results.push((_results$push = {
|
3175 | customOption: true
|
3176 | }, _results$push[getStringLabelKey(labelKey)] = text, _results$push));
|
3177 | }
|
3178 |
|
3179 |
|
3180 | if (shouldPaginate) {
|
3181 | var _results$push2;
|
3182 |
|
3183 | results.push((_results$push2 = {}, _results$push2[getStringLabelKey(labelKey)] = '', _results$push2.paginationOption = true, _results$push2));
|
3184 | }
|
3185 | }
|
3186 |
|
3187 | return React__default.createElement(TypeaheadManager, _extends({}, mergedPropsAndState, {
|
3188 | hideMenu: this.hideMenu,
|
3189 | inputNode: this.inputNode,
|
3190 | inputRef: this.inputRef,
|
3191 | isMenuShown: this.isMenuShown,
|
3192 | onActiveItemChange: this._handleActiveItemChange,
|
3193 | onAdd: this._handleSelectionAdd,
|
3194 | onBlur: this._handleBlur,
|
3195 | onChange: this._handleInputChange,
|
3196 | onClear: this._handleClear,
|
3197 | onFocus: this._handleFocus,
|
3198 | onHide: this.hideMenu,
|
3199 | onInitialItemChange: this._handleInitialItemChange,
|
3200 | onKeyDown: this._handleKeyDown,
|
3201 | onMenuItemClick: this._handleMenuItemSelect,
|
3202 | onRemove: this._handleSelectionRemove,
|
3203 | results: results,
|
3204 | setItem: this.setItem,
|
3205 | toggleMenu: this.toggleMenu
|
3206 | }));
|
3207 | };
|
3208 |
|
3209 | return Typeahead;
|
3210 | }(React__default.Component);
|
3211 |
|
3212 | _defineProperty(Typeahead, "propTypes", propTypes$1);
|
3213 |
|
3214 | _defineProperty(Typeahead, "defaultProps", defaultProps);
|
3215 |
|
3216 | var propTypes$2 = {
|
3217 | |
3218 |
|
3219 |
|
3220 | delay: propTypes.number,
|
3221 |
|
3222 | |
3223 |
|
3224 |
|
3225 |
|
3226 | isLoading: propTypes.bool.isRequired,
|
3227 |
|
3228 | |
3229 |
|
3230 |
|
3231 | minLength: propTypes.number,
|
3232 |
|
3233 | |
3234 |
|
3235 |
|
3236 | onSearch: propTypes.func.isRequired,
|
3237 |
|
3238 | |
3239 |
|
3240 |
|
3241 |
|
3242 | options: propTypes.arrayOf(optionType),
|
3243 |
|
3244 | |
3245 |
|
3246 |
|
3247 | promptText: propTypes.node,
|
3248 |
|
3249 | |
3250 |
|
3251 |
|
3252 | searchText: propTypes.node,
|
3253 |
|
3254 | |
3255 |
|
3256 |
|
3257 | useCache: propTypes.bool
|
3258 | };
|
3259 | var defaultProps$1 = {
|
3260 | delay: 200,
|
3261 | minLength: 2,
|
3262 | options: [],
|
3263 | promptText: 'Type to search...',
|
3264 | searchText: 'Searching...',
|
3265 | useCache: true
|
3266 | };
|
3267 |
|
3268 | |
3269 |
|
3270 |
|
3271 |
|
3272 |
|
3273 |
|
3274 |
|
3275 |
|
3276 | function useAsync(props) {
|
3277 | var allowNew = props.allowNew,
|
3278 | delay = props.delay,
|
3279 | emptyLabel = props.emptyLabel,
|
3280 | isLoading = props.isLoading,
|
3281 | minLength = props.minLength,
|
3282 | onInputChange = props.onInputChange,
|
3283 | onSearch = props.onSearch,
|
3284 | options = props.options,
|
3285 | promptText = props.promptText,
|
3286 | searchText = props.searchText,
|
3287 | useCache = props.useCache,
|
3288 | otherProps = _objectWithoutPropertiesLoose(props, ["allowNew", "delay", "emptyLabel", "isLoading", "minLength", "onInputChange", "onSearch", "options", "promptText", "searchText", "useCache"]);
|
3289 |
|
3290 | var cacheRef = React.useRef({});
|
3291 | var handleSearchDebouncedRef = React.useRef();
|
3292 | var queryRef = React.useRef(props.defaultInputValue || '');
|
3293 | var forceUpdate = useForceUpdate();
|
3294 | var prevProps = usePrevious(props);
|
3295 | var handleSearch = React.useCallback(function (query) {
|
3296 | queryRef.current = query;
|
3297 |
|
3298 | if (!query || minLength && query.length < minLength) {
|
3299 | return;
|
3300 | }
|
3301 |
|
3302 |
|
3303 | if (useCache && cacheRef.current[query]) {
|
3304 |
|
3305 | forceUpdate();
|
3306 | return;
|
3307 | }
|
3308 |
|
3309 |
|
3310 | onSearch(query);
|
3311 | }, [forceUpdate, minLength, onSearch, useCache]);
|
3312 |
|
3313 | React.useEffect(function () {
|
3314 | handleSearchDebouncedRef.current = lodash_debounce(handleSearch, delay);
|
3315 | return function () {
|
3316 | handleSearchDebouncedRef.current && handleSearchDebouncedRef.current.cancel();
|
3317 | };
|
3318 | }, [delay, handleSearch]);
|
3319 | React.useEffect(function () {
|
3320 |
|
3321 |
|
3322 |
|
3323 | if (!isLoading && prevProps && prevProps.isLoading && useCache) {
|
3324 | cacheRef.current[queryRef.current] = options;
|
3325 | }
|
3326 | });
|
3327 |
|
3328 | var getEmptyLabel = function getEmptyLabel() {
|
3329 | if (!queryRef.current.length) {
|
3330 | return promptText;
|
3331 | }
|
3332 |
|
3333 | if (isLoading) {
|
3334 | return searchText;
|
3335 | }
|
3336 |
|
3337 | return emptyLabel;
|
3338 | };
|
3339 |
|
3340 | var handleInputChange = React.useCallback(function (query, e) {
|
3341 | onInputChange && onInputChange(query, e);
|
3342 | handleSearchDebouncedRef.current && handleSearchDebouncedRef.current(query);
|
3343 | }, [onInputChange]);
|
3344 | var cachedQuery = cacheRef.current[queryRef.current];
|
3345 | return _extends({}, otherProps, {
|
3346 |
|
3347 | allowNew: isFunction(allowNew) ? allowNew : allowNew && !isLoading,
|
3348 | emptyLabel: getEmptyLabel(),
|
3349 | isLoading: isLoading,
|
3350 | minLength: minLength,
|
3351 | onInputChange: handleInputChange,
|
3352 | options: useCache && cachedQuery ? cachedQuery : options
|
3353 | });
|
3354 | }
|
3355 | function withAsync(Component) {
|
3356 | var AsyncTypeahead = React.forwardRef(function (props, ref) {
|
3357 | return React__default.createElement(Component, _extends({}, useAsync(props), {
|
3358 | ref: ref
|
3359 | }));
|
3360 | });
|
3361 | AsyncTypeahead.displayName = "withAsync(" + getDisplayName(Component) + ")";
|
3362 |
|
3363 | AsyncTypeahead.propTypes = propTypes$2;
|
3364 |
|
3365 | AsyncTypeahead.defaultProps = defaultProps$1;
|
3366 | return AsyncTypeahead;
|
3367 | }
|
3368 | function asyncContainer(Component) {
|
3369 |
|
3370 | warn(false, 'The `asyncContainer` export is deprecated; use `withAsync` instead.');
|
3371 |
|
3372 |
|
3373 | return withAsync(Component);
|
3374 | }
|
3375 |
|
3376 |
|
3377 |
|
3378 |
|
3379 | function contains(context, node) {
|
3380 | if (context.contains) return context.contains(node);
|
3381 | if (context.compareDocumentPosition) return context === node || !!(context.compareDocumentPosition(node) & 16);
|
3382 | }
|
3383 |
|
3384 | var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
|
3385 |
|
3386 |
|
3387 | var optionsSupported = false;
|
3388 | var onceSupported = false;
|
3389 |
|
3390 | try {
|
3391 | var options = {
|
3392 | get passive() {
|
3393 | return optionsSupported = true;
|
3394 | },
|
3395 |
|
3396 | get once() {
|
3397 |
|
3398 | return onceSupported = optionsSupported = true;
|
3399 | }
|
3400 |
|
3401 | };
|
3402 |
|
3403 | if (canUseDOM) {
|
3404 | window.addEventListener('test', options, options);
|
3405 | window.removeEventListener('test', options, true);
|
3406 | }
|
3407 | } catch (e) {
|
3408 |
|
3409 | }
|
3410 |
|
3411 | |
3412 |
|
3413 |
|
3414 | function addEventListener(node, eventName, handler, options) {
|
3415 | if (options && typeof options !== 'boolean' && !onceSupported) {
|
3416 | var once = options.once,
|
3417 | capture = options.capture;
|
3418 | var wrappedHandler = handler;
|
3419 |
|
3420 | if (!onceSupported && once) {
|
3421 | wrappedHandler = handler.__once || function onceHandler(event) {
|
3422 | this.removeEventListener(eventName, onceHandler, capture);
|
3423 | handler.call(this, event);
|
3424 | };
|
3425 |
|
3426 | handler.__once = wrappedHandler;
|
3427 | }
|
3428 |
|
3429 | node.addEventListener(eventName, wrappedHandler, optionsSupported ? options : capture);
|
3430 | }
|
3431 |
|
3432 | node.addEventListener(eventName, handler, options);
|
3433 | }
|
3434 |
|
3435 | function removeEventListener(node, eventName, handler, options) {
|
3436 | var capture = options && typeof options !== 'boolean' ? options.capture : options;
|
3437 | node.removeEventListener(eventName, handler, capture);
|
3438 |
|
3439 | if (handler.__once) {
|
3440 | node.removeEventListener(eventName, handler.__once, capture);
|
3441 | }
|
3442 | }
|
3443 |
|
3444 | function listen(node, eventName, handler, options) {
|
3445 | addEventListener(node, eventName, handler, options);
|
3446 | return function () {
|
3447 | removeEventListener(node, eventName, handler, options);
|
3448 | };
|
3449 | }
|
3450 |
|
3451 | |
3452 |
|
3453 |
|
3454 |
|
3455 |
|
3456 |
|
3457 |
|
3458 |
|
3459 |
|
3460 |
|
3461 | function useCommittedRef(value) {
|
3462 | var ref = React.useRef(value);
|
3463 | React.useEffect(function () {
|
3464 | ref.current = value;
|
3465 | }, [value]);
|
3466 | return ref;
|
3467 | }
|
3468 |
|
3469 | function useEventCallback(fn) {
|
3470 | var ref = useCommittedRef(fn);
|
3471 | return React.useCallback(function () {
|
3472 | return ref.current && ref.current.apply(ref, arguments);
|
3473 | }, [ref]);
|
3474 | }
|
3475 |
|
3476 | function ownerDocument(node) {
|
3477 | return node && node.ownerDocument || document;
|
3478 | }
|
3479 |
|
3480 | function ownerDocument$1 (componentOrElement) {
|
3481 | return ownerDocument(ReactDOM.findDOMNode(componentOrElement));
|
3482 | }
|
3483 |
|
3484 | var escapeKeyCode = 27;
|
3485 |
|
3486 | var noop$1 = function noop() {};
|
3487 |
|
3488 | function isLeftClickEvent(event) {
|
3489 | return event.button === 0;
|
3490 | }
|
3491 |
|
3492 | function isModifiedEvent(event) {
|
3493 | return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
|
3494 | }
|
3495 | |
3496 |
|
3497 |
|
3498 |
|
3499 |
|
3500 |
|
3501 |
|
3502 |
|
3503 |
|
3504 |
|
3505 |
|
3506 |
|
3507 |
|
3508 |
|
3509 | function useRootClose(ref, onRootClose, _temp) {
|
3510 | var _ref = _temp === void 0 ? {} : _temp,
|
3511 | disabled = _ref.disabled,
|
3512 | _ref$clickTrigger = _ref.clickTrigger,
|
3513 | clickTrigger = _ref$clickTrigger === void 0 ? 'click' : _ref$clickTrigger;
|
3514 |
|
3515 | var preventMouseRootCloseRef = React.useRef(false);
|
3516 | var onClose = onRootClose || noop$1;
|
3517 | var handleMouseCapture = React.useCallback(function (e) {
|
3518 | var currentTarget = ref && ('current' in ref ? ref.current : ref);
|
3519 | 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');
|
3520 | preventMouseRootCloseRef.current = !currentTarget || isModifiedEvent(e) || !isLeftClickEvent(e) || contains(currentTarget, e.target);
|
3521 | }, [ref]);
|
3522 | var handleMouse = useEventCallback(function (e) {
|
3523 | if (!preventMouseRootCloseRef.current) {
|
3524 | onClose(e);
|
3525 | }
|
3526 | });
|
3527 | var handleKeyUp = useEventCallback(function (e) {
|
3528 | if (e.keyCode === escapeKeyCode) {
|
3529 | onClose(e);
|
3530 | }
|
3531 | });
|
3532 | React.useEffect(function () {
|
3533 | if (disabled || ref == null) return undefined;
|
3534 | var doc = ownerDocument$1(ref.current);
|
3535 |
|
3536 |
|
3537 |
|
3538 | var removeMouseCaptureListener = listen(doc, clickTrigger, handleMouseCapture, true);
|
3539 | var removeMouseListener = listen(doc, clickTrigger, handleMouse);
|
3540 | var removeKeyupListener = listen(doc, 'keyup', handleKeyUp);
|
3541 | var mobileSafariHackListeners = [];
|
3542 |
|
3543 | if ('ontouchstart' in doc.documentElement) {
|
3544 | mobileSafariHackListeners = [].slice.call(doc.body.children).map(function (el) {
|
3545 | return listen(el, 'mousemove', noop$1);
|
3546 | });
|
3547 | }
|
3548 |
|
3549 | return function () {
|
3550 | removeMouseCaptureListener();
|
3551 | removeMouseListener();
|
3552 | removeKeyupListener();
|
3553 | mobileSafariHackListeners.forEach(function (remove) {
|
3554 | return remove();
|
3555 | });
|
3556 | };
|
3557 | }, [ref, disabled, clickTrigger, handleMouseCapture, handleMouse, handleKeyUp]);
|
3558 | }
|
3559 |
|
3560 | var propTypes$3 = {
|
3561 | label: propTypes.string,
|
3562 | onClick: propTypes.func,
|
3563 | size: sizeType
|
3564 | };
|
3565 | var defaultProps$2 = {
|
3566 | label: 'Clear',
|
3567 | onClick: noop
|
3568 | };
|
3569 |
|
3570 | |
3571 |
|
3572 |
|
3573 |
|
3574 |
|
3575 | var ClearButton = function ClearButton(_ref) {
|
3576 | var className = _ref.className,
|
3577 | label = _ref.label,
|
3578 | _onClick = _ref.onClick,
|
3579 | size = _ref.size,
|
3580 | props = _objectWithoutPropertiesLoose(_ref, ["className", "label", "onClick", "size"]);
|
3581 |
|
3582 | return React__default.createElement("button", _extends({}, props, {
|
3583 | "aria-label": label,
|
3584 | className: classnames('close', 'rbt-close', {
|
3585 | 'rbt-close-lg': isSizeLarge(size)
|
3586 | }, className),
|
3587 | onClick: function onClick(e) {
|
3588 | e.stopPropagation();
|
3589 |
|
3590 | _onClick(e);
|
3591 | },
|
3592 | type: "button"
|
3593 | }), React__default.createElement("span", {
|
3594 | "aria-hidden": "true"
|
3595 | }, "\xD7"), React__default.createElement("span", {
|
3596 | className: "sr-only"
|
3597 | }, label));
|
3598 | };
|
3599 |
|
3600 | ClearButton.propTypes = propTypes$3;
|
3601 | ClearButton.defaultProps = defaultProps$2;
|
3602 |
|
3603 | var propTypes$4 = {
|
3604 | label: propTypes.string
|
3605 | };
|
3606 | var defaultProps$3 = {
|
3607 | label: 'Loading...'
|
3608 | };
|
3609 |
|
3610 | var Loader = function Loader(_ref) {
|
3611 | var label = _ref.label;
|
3612 | return React__default.createElement("div", {
|
3613 | className: "rbt-loader spinner-border spinner-border-sm",
|
3614 | role: "status"
|
3615 | }, React__default.createElement("span", {
|
3616 | className: "sr-only"
|
3617 | }, label));
|
3618 | };
|
3619 |
|
3620 | Loader.propTypes = propTypes$4;
|
3621 | Loader.defaultProps = defaultProps$3;
|
3622 |
|
3623 | function _objectWithoutPropertiesLoose$1(source, excluded) {
|
3624 | if (source == null) return {};
|
3625 | var target = {};
|
3626 | var sourceKeys = Object.keys(source);
|
3627 | var key, i;
|
3628 |
|
3629 | for (i = 0; i < sourceKeys.length; i++) {
|
3630 | key = sourceKeys[i];
|
3631 | if (excluded.indexOf(key) >= 0) continue;
|
3632 | target[key] = source[key];
|
3633 | }
|
3634 |
|
3635 | return target;
|
3636 | }
|
3637 |
|
3638 | var objectWithoutPropertiesLoose = _objectWithoutPropertiesLoose$1;
|
3639 |
|
3640 | var _extends_1 = createCommonjsModule(function (module) {
|
3641 | function _extends() {
|
3642 | module.exports = _extends = Object.assign || function (target) {
|
3643 | for (var i = 1; i < arguments.length; i++) {
|
3644 | var source = arguments[i];
|
3645 |
|
3646 | for (var key in source) {
|
3647 | if (Object.prototype.hasOwnProperty.call(source, key)) {
|
3648 | target[key] = source[key];
|
3649 | }
|
3650 | }
|
3651 | }
|
3652 |
|
3653 | return target;
|
3654 | };
|
3655 |
|
3656 | return _extends.apply(this, arguments);
|
3657 | }
|
3658 |
|
3659 | module.exports = _extends;
|
3660 | });
|
3661 |
|
3662 | function _assertThisInitialized$1(self) {
|
3663 | if (self === void 0) {
|
3664 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
3665 | }
|
3666 |
|
3667 | return self;
|
3668 | }
|
3669 |
|
3670 | var assertThisInitialized = _assertThisInitialized$1;
|
3671 |
|
3672 | function _inheritsLoose$1(subClass, superClass) {
|
3673 | subClass.prototype = Object.create(superClass.prototype);
|
3674 | subClass.prototype.constructor = subClass;
|
3675 | subClass.__proto__ = superClass;
|
3676 | }
|
3677 |
|
3678 | var inheritsLoose = _inheritsLoose$1;
|
3679 |
|
3680 | function _defineProperty$1(obj, key, value) {
|
3681 | if (key in obj) {
|
3682 | Object.defineProperty(obj, key, {
|
3683 | value: value,
|
3684 | enumerable: true,
|
3685 | configurable: true,
|
3686 | writable: true
|
3687 | });
|
3688 | } else {
|
3689 | obj[key] = value;
|
3690 | }
|
3691 |
|
3692 | return obj;
|
3693 | }
|
3694 |
|
3695 | var defineProperty = _defineProperty$1;
|
3696 |
|
3697 | var toStr = Object.prototype.toString;
|
3698 |
|
3699 | var isArguments = function isArguments(value) {
|
3700 | var str = toStr.call(value);
|
3701 | var isArgs = str === '[object Arguments]';
|
3702 | if (!isArgs) {
|
3703 | isArgs = str !== '[object Array]' &&
|
3704 | value !== null &&
|
3705 | typeof value === 'object' &&
|
3706 | typeof value.length === 'number' &&
|
3707 | value.length >= 0 &&
|
3708 | toStr.call(value.callee) === '[object Function]';
|
3709 | }
|
3710 | return isArgs;
|
3711 | };
|
3712 |
|
3713 | var keysShim;
|
3714 | if (!Object.keys) {
|
3715 |
|
3716 | var has$2 = Object.prototype.hasOwnProperty;
|
3717 | var toStr$1 = Object.prototype.toString;
|
3718 | var isArgs = isArguments;
|
3719 | var isEnumerable = Object.prototype.propertyIsEnumerable;
|
3720 | var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString');
|
3721 | var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype');
|
3722 | var dontEnums = [
|
3723 | 'toString',
|
3724 | 'toLocaleString',
|
3725 | 'valueOf',
|
3726 | 'hasOwnProperty',
|
3727 | 'isPrototypeOf',
|
3728 | 'propertyIsEnumerable',
|
3729 | 'constructor'
|
3730 | ];
|
3731 | var equalsConstructorPrototype = function (o) {
|
3732 | var ctor = o.constructor;
|
3733 | return ctor && ctor.prototype === o;
|
3734 | };
|
3735 | var excludedKeys = {
|
3736 | $applicationCache: true,
|
3737 | $console: true,
|
3738 | $external: true,
|
3739 | $frame: true,
|
3740 | $frameElement: true,
|
3741 | $frames: true,
|
3742 | $innerHeight: true,
|
3743 | $innerWidth: true,
|
3744 | $onmozfullscreenchange: true,
|
3745 | $onmozfullscreenerror: true,
|
3746 | $outerHeight: true,
|
3747 | $outerWidth: true,
|
3748 | $pageXOffset: true,
|
3749 | $pageYOffset: true,
|
3750 | $parent: true,
|
3751 | $scrollLeft: true,
|
3752 | $scrollTop: true,
|
3753 | $scrollX: true,
|
3754 | $scrollY: true,
|
3755 | $self: true,
|
3756 | $webkitIndexedDB: true,
|
3757 | $webkitStorageInfo: true,
|
3758 | $window: true
|
3759 | };
|
3760 | var hasAutomationEqualityBug = (function () {
|
3761 |
|
3762 | if (typeof window === 'undefined') { return false; }
|
3763 | for (var k in window) {
|
3764 | try {
|
3765 | if (!excludedKeys['$' + k] && has$2.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
|
3766 | try {
|
3767 | equalsConstructorPrototype(window[k]);
|
3768 | } catch (e) {
|
3769 | return true;
|
3770 | }
|
3771 | }
|
3772 | } catch (e) {
|
3773 | return true;
|
3774 | }
|
3775 | }
|
3776 | return false;
|
3777 | }());
|
3778 | var equalsConstructorPrototypeIfNotBuggy = function (o) {
|
3779 |
|
3780 | if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
|
3781 | return equalsConstructorPrototype(o);
|
3782 | }
|
3783 | try {
|
3784 | return equalsConstructorPrototype(o);
|
3785 | } catch (e) {
|
3786 | return false;
|
3787 | }
|
3788 | };
|
3789 |
|
3790 | keysShim = function keys(object) {
|
3791 | var isObject = object !== null && typeof object === 'object';
|
3792 | var isFunction = toStr$1.call(object) === '[object Function]';
|
3793 | var isArguments = isArgs(object);
|
3794 | var isString = isObject && toStr$1.call(object) === '[object String]';
|
3795 | var theKeys = [];
|
3796 |
|
3797 | if (!isObject && !isFunction && !isArguments) {
|
3798 | throw new TypeError('Object.keys called on a non-object');
|
3799 | }
|
3800 |
|
3801 | var skipProto = hasProtoEnumBug && isFunction;
|
3802 | if (isString && object.length > 0 && !has$2.call(object, 0)) {
|
3803 | for (var i = 0; i < object.length; ++i) {
|
3804 | theKeys.push(String(i));
|
3805 | }
|
3806 | }
|
3807 |
|
3808 | if (isArguments && object.length > 0) {
|
3809 | for (var j = 0; j < object.length; ++j) {
|
3810 | theKeys.push(String(j));
|
3811 | }
|
3812 | } else {
|
3813 | for (var name in object) {
|
3814 | if (!(skipProto && name === 'prototype') && has$2.call(object, name)) {
|
3815 | theKeys.push(String(name));
|
3816 | }
|
3817 | }
|
3818 | }
|
3819 |
|
3820 | if (hasDontEnumBug) {
|
3821 | var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
|
3822 |
|
3823 | for (var k = 0; k < dontEnums.length; ++k) {
|
3824 | if (!(skipConstructor && dontEnums[k] === 'constructor') && has$2.call(object, dontEnums[k])) {
|
3825 | theKeys.push(dontEnums[k]);
|
3826 | }
|
3827 | }
|
3828 | }
|
3829 | return theKeys;
|
3830 | };
|
3831 | }
|
3832 | var implementation = keysShim;
|
3833 |
|
3834 | var slice = Array.prototype.slice;
|
3835 |
|
3836 |
|
3837 | var origKeys = Object.keys;
|
3838 | var keysShim$1 = origKeys ? function keys(o) { return origKeys(o); } : implementation;
|
3839 |
|
3840 | var originalKeys = Object.keys;
|
3841 |
|
3842 | keysShim$1.shim = function shimObjectKeys() {
|
3843 | if (Object.keys) {
|
3844 | var keysWorksWithArguments = (function () {
|
3845 |
|
3846 | var args = Object.keys(arguments);
|
3847 | return args && args.length === arguments.length;
|
3848 | }(1, 2));
|
3849 | if (!keysWorksWithArguments) {
|
3850 | Object.keys = function keys(object) {
|
3851 | if (isArguments(object)) {
|
3852 | return originalKeys(slice.call(object));
|
3853 | }
|
3854 | return originalKeys(object);
|
3855 | };
|
3856 | }
|
3857 | } else {
|
3858 | Object.keys = keysShim$1;
|
3859 | }
|
3860 | return Object.keys || keysShim$1;
|
3861 | };
|
3862 |
|
3863 | var objectKeys = keysShim$1;
|
3864 |
|
3865 | var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
|
3866 | var toStr$2 = Object.prototype.toString;
|
3867 |
|
3868 | var isStandardArguments = function isArguments(value) {
|
3869 | if (hasToStringTag && value && typeof value === 'object' && Symbol.toStringTag in value) {
|
3870 | return false;
|
3871 | }
|
3872 | return toStr$2.call(value) === '[object Arguments]';
|
3873 | };
|
3874 |
|
3875 | var isLegacyArguments = function isArguments(value) {
|
3876 | if (isStandardArguments(value)) {
|
3877 | return true;
|
3878 | }
|
3879 | return value !== null &&
|
3880 | typeof value === 'object' &&
|
3881 | typeof value.length === 'number' &&
|
3882 | value.length >= 0 &&
|
3883 | toStr$2.call(value) !== '[object Array]' &&
|
3884 | toStr$2.call(value.callee) === '[object Function]';
|
3885 | };
|
3886 |
|
3887 | var supportsStandardArguments = (function () {
|
3888 | return isStandardArguments(arguments);
|
3889 | }());
|
3890 |
|
3891 | isStandardArguments.isLegacyArguments = isLegacyArguments;
|
3892 |
|
3893 | var isArguments$1 = supportsStandardArguments ? isStandardArguments : isLegacyArguments;
|
3894 |
|
3895 | var hasSymbols = typeof Symbol === 'function' && typeof Symbol('foo') === 'symbol';
|
3896 |
|
3897 | var toStr$3 = Object.prototype.toString;
|
3898 | var concat = Array.prototype.concat;
|
3899 | var origDefineProperty = Object.defineProperty;
|
3900 |
|
3901 | var isFunction$1 = function (fn) {
|
3902 | return typeof fn === 'function' && toStr$3.call(fn) === '[object Function]';
|
3903 | };
|
3904 |
|
3905 | var arePropertyDescriptorsSupported = function () {
|
3906 | var obj = {};
|
3907 | try {
|
3908 | origDefineProperty(obj, 'x', { enumerable: false, value: obj });
|
3909 |
|
3910 | for (var _ in obj) {
|
3911 | return false;
|
3912 | }
|
3913 | return obj.x === obj;
|
3914 | } catch (e) {
|
3915 | return false;
|
3916 | }
|
3917 | };
|
3918 | var supportsDescriptors = origDefineProperty && arePropertyDescriptorsSupported();
|
3919 |
|
3920 | var defineProperty$1 = function (object, name, value, predicate) {
|
3921 | if (name in object && (!isFunction$1(predicate) || !predicate())) {
|
3922 | return;
|
3923 | }
|
3924 | if (supportsDescriptors) {
|
3925 | origDefineProperty(object, name, {
|
3926 | configurable: true,
|
3927 | enumerable: false,
|
3928 | value: value,
|
3929 | writable: true
|
3930 | });
|
3931 | } else {
|
3932 | object[name] = value;
|
3933 | }
|
3934 | };
|
3935 |
|
3936 | var defineProperties = function (object, map) {
|
3937 | var predicates = arguments.length > 2 ? arguments[2] : {};
|
3938 | var props = objectKeys(map);
|
3939 | if (hasSymbols) {
|
3940 | props = concat.call(props, Object.getOwnPropertySymbols(map));
|
3941 | }
|
3942 | for (var i = 0; i < props.length; i += 1) {
|
3943 | defineProperty$1(object, props[i], map[props[i]], predicates[props[i]]);
|
3944 | }
|
3945 | };
|
3946 |
|
3947 | defineProperties.supportsDescriptors = !!supportsDescriptors;
|
3948 |
|
3949 | var defineProperties_1 = defineProperties;
|
3950 |
|
3951 |
|
3952 |
|
3953 | var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
|
3954 | var slice$1 = Array.prototype.slice;
|
3955 | var toStr$4 = Object.prototype.toString;
|
3956 | var funcType = '[object Function]';
|
3957 |
|
3958 | var implementation$1 = function bind(that) {
|
3959 | var target = this;
|
3960 | if (typeof target !== 'function' || toStr$4.call(target) !== funcType) {
|
3961 | throw new TypeError(ERROR_MESSAGE + target);
|
3962 | }
|
3963 | var args = slice$1.call(arguments, 1);
|
3964 |
|
3965 | var bound;
|
3966 | var binder = function () {
|
3967 | if (this instanceof bound) {
|
3968 | var result = target.apply(
|
3969 | this,
|
3970 | args.concat(slice$1.call(arguments))
|
3971 | );
|
3972 | if (Object(result) === result) {
|
3973 | return result;
|
3974 | }
|
3975 | return this;
|
3976 | } else {
|
3977 | return target.apply(
|
3978 | that,
|
3979 | args.concat(slice$1.call(arguments))
|
3980 | );
|
3981 | }
|
3982 | };
|
3983 |
|
3984 | var boundLength = Math.max(0, target.length - args.length);
|
3985 | var boundArgs = [];
|
3986 | for (var i = 0; i < boundLength; i++) {
|
3987 | boundArgs.push('$' + i);
|
3988 | }
|
3989 |
|
3990 | bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
|
3991 |
|
3992 | if (target.prototype) {
|
3993 | var Empty = function Empty() {};
|
3994 | Empty.prototype = target.prototype;
|
3995 | bound.prototype = new Empty();
|
3996 | Empty.prototype = null;
|
3997 | }
|
3998 |
|
3999 | return bound;
|
4000 | };
|
4001 |
|
4002 | var functionBind = Function.prototype.bind || implementation$1;
|
4003 |
|
4004 |
|
4005 | var shams = function hasSymbols() {
|
4006 | if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; }
|
4007 | if (typeof Symbol.iterator === 'symbol') { return true; }
|
4008 |
|
4009 | var obj = {};
|
4010 | var sym = Symbol('test');
|
4011 | var symObj = Object(sym);
|
4012 | if (typeof sym === 'string') { return false; }
|
4013 |
|
4014 | if (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; }
|
4015 | if (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; }
|
4016 |
|
4017 |
|
4018 |
|
4019 |
|
4020 |
|
4021 |
|
4022 |
|
4023 |
|
4024 |
|
4025 | var symVal = 42;
|
4026 | obj[sym] = symVal;
|
4027 | for (sym in obj) { return false; }
|
4028 | if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; }
|
4029 |
|
4030 | if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; }
|
4031 |
|
4032 | var syms = Object.getOwnPropertySymbols(obj);
|
4033 | if (syms.length !== 1 || syms[0] !== sym) { return false; }
|
4034 |
|
4035 | if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; }
|
4036 |
|
4037 | if (typeof Object.getOwnPropertyDescriptor === 'function') {
|
4038 | var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
|
4039 | if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; }
|
4040 | }
|
4041 |
|
4042 | return true;
|
4043 | };
|
4044 |
|
4045 | var origSymbol = commonjsGlobal.Symbol;
|
4046 |
|
4047 |
|
4048 | var hasSymbols$1 = function hasNativeSymbols() {
|
4049 | if (typeof origSymbol !== 'function') { return false; }
|
4050 | if (typeof Symbol !== 'function') { return false; }
|
4051 | if (typeof origSymbol('foo') !== 'symbol') { return false; }
|
4052 | if (typeof Symbol('bar') !== 'symbol') { return false; }
|
4053 |
|
4054 | return shams();
|
4055 | };
|
4056 |
|
4057 | |
4058 |
|
4059 |
|
4060 |
|
4061 |
|
4062 | var undefined$1;
|
4063 |
|
4064 | var $TypeError = TypeError;
|
4065 |
|
4066 | var $gOPD = Object.getOwnPropertyDescriptor;
|
4067 | if ($gOPD) {
|
4068 | try {
|
4069 | $gOPD({}, '');
|
4070 | } catch (e) {
|
4071 | $gOPD = null;
|
4072 | }
|
4073 | }
|
4074 |
|
4075 | var throwTypeError = function () { throw new $TypeError(); };
|
4076 | var ThrowTypeError = $gOPD
|
4077 | ? (function () {
|
4078 | try {
|
4079 |
|
4080 | arguments.callee;
|
4081 | return throwTypeError;
|
4082 | } catch (calleeThrows) {
|
4083 | try {
|
4084 |
|
4085 | return $gOPD(arguments, 'callee').get;
|
4086 | } catch (gOPDthrows) {
|
4087 | return throwTypeError;
|
4088 | }
|
4089 | }
|
4090 | }())
|
4091 | : throwTypeError;
|
4092 |
|
4093 | var hasSymbols$2 = hasSymbols$1();
|
4094 |
|
4095 | var getProto = Object.getPrototypeOf || function (x) { return x.__proto__; };
|
4096 | var generatorFunction = undefined$1;
|
4097 | var asyncFunction = undefined$1;
|
4098 | var asyncGenFunction = undefined$1;
|
4099 |
|
4100 | var TypedArray = typeof Uint8Array === 'undefined' ? undefined$1 : getProto(Uint8Array);
|
4101 |
|
4102 | var INTRINSICS = {
|
4103 | '%Array%': Array,
|
4104 | '%ArrayBuffer%': typeof ArrayBuffer === 'undefined' ? undefined$1 : ArrayBuffer,
|
4105 | '%ArrayBufferPrototype%': typeof ArrayBuffer === 'undefined' ? undefined$1 : ArrayBuffer.prototype,
|
4106 | '%ArrayIteratorPrototype%': hasSymbols$2 ? getProto([][Symbol.iterator]()) : undefined$1,
|
4107 | '%ArrayPrototype%': Array.prototype,
|
4108 | '%ArrayProto_entries%': Array.prototype.entries,
|
4109 | '%ArrayProto_forEach%': Array.prototype.forEach,
|
4110 | '%ArrayProto_keys%': Array.prototype.keys,
|
4111 | '%ArrayProto_values%': Array.prototype.values,
|
4112 | '%AsyncFromSyncIteratorPrototype%': undefined$1,
|
4113 | '%AsyncFunction%': asyncFunction,
|
4114 | '%AsyncFunctionPrototype%': undefined$1,
|
4115 | '%AsyncGenerator%': undefined$1,
|
4116 | '%AsyncGeneratorFunction%': asyncGenFunction,
|
4117 | '%AsyncGeneratorPrototype%': undefined$1,
|
4118 | '%AsyncIteratorPrototype%': undefined$1,
|
4119 | '%Atomics%': typeof Atomics === 'undefined' ? undefined$1 : Atomics,
|
4120 | '%Boolean%': Boolean,
|
4121 | '%BooleanPrototype%': Boolean.prototype,
|
4122 | '%DataView%': typeof DataView === 'undefined' ? undefined$1 : DataView,
|
4123 | '%DataViewPrototype%': typeof DataView === 'undefined' ? undefined$1 : DataView.prototype,
|
4124 | '%Date%': Date,
|
4125 | '%DatePrototype%': Date.prototype,
|
4126 | '%decodeURI%': decodeURI,
|
4127 | '%decodeURIComponent%': decodeURIComponent,
|
4128 | '%encodeURI%': encodeURI,
|
4129 | '%encodeURIComponent%': encodeURIComponent,
|
4130 | '%Error%': Error,
|
4131 | '%ErrorPrototype%': Error.prototype,
|
4132 | '%eval%': eval,
|
4133 | '%EvalError%': EvalError,
|
4134 | '%EvalErrorPrototype%': EvalError.prototype,
|
4135 | '%Float32Array%': typeof Float32Array === 'undefined' ? undefined$1 : Float32Array,
|
4136 | '%Float32ArrayPrototype%': typeof Float32Array === 'undefined' ? undefined$1 : Float32Array.prototype,
|
4137 | '%Float64Array%': typeof Float64Array === 'undefined' ? undefined$1 : Float64Array,
|
4138 | '%Float64ArrayPrototype%': typeof Float64Array === 'undefined' ? undefined$1 : Float64Array.prototype,
|
4139 | '%Function%': Function,
|
4140 | '%FunctionPrototype%': Function.prototype,
|
4141 | '%Generator%': undefined$1,
|
4142 | '%GeneratorFunction%': generatorFunction,
|
4143 | '%GeneratorPrototype%': undefined$1,
|
4144 | '%Int8Array%': typeof Int8Array === 'undefined' ? undefined$1 : Int8Array,
|
4145 | '%Int8ArrayPrototype%': typeof Int8Array === 'undefined' ? undefined$1 : Int8Array.prototype,
|
4146 | '%Int16Array%': typeof Int16Array === 'undefined' ? undefined$1 : Int16Array,
|
4147 | '%Int16ArrayPrototype%': typeof Int16Array === 'undefined' ? undefined$1 : Int8Array.prototype,
|
4148 | '%Int32Array%': typeof Int32Array === 'undefined' ? undefined$1 : Int32Array,
|
4149 | '%Int32ArrayPrototype%': typeof Int32Array === 'undefined' ? undefined$1 : Int32Array.prototype,
|
4150 | '%isFinite%': isFinite,
|
4151 | '%isNaN%': isNaN,
|
4152 | '%IteratorPrototype%': hasSymbols$2 ? getProto(getProto([][Symbol.iterator]())) : undefined$1,
|
4153 | '%JSON%': typeof JSON === 'object' ? JSON : undefined$1,
|
4154 | '%JSONParse%': typeof JSON === 'object' ? JSON.parse : undefined$1,
|
4155 | '%Map%': typeof Map === 'undefined' ? undefined$1 : Map,
|
4156 | '%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols$2 ? undefined$1 : getProto(new Map()[Symbol.iterator]()),
|
4157 | '%MapPrototype%': typeof Map === 'undefined' ? undefined$1 : Map.prototype,
|
4158 | '%Math%': Math,
|
4159 | '%Number%': Number,
|
4160 | '%NumberPrototype%': Number.prototype,
|
4161 | '%Object%': Object,
|
4162 | '%ObjectPrototype%': Object.prototype,
|
4163 | '%ObjProto_toString%': Object.prototype.toString,
|
4164 | '%ObjProto_valueOf%': Object.prototype.valueOf,
|
4165 | '%parseFloat%': parseFloat,
|
4166 | '%parseInt%': parseInt,
|
4167 | '%Promise%': typeof Promise === 'undefined' ? undefined$1 : Promise,
|
4168 | '%PromisePrototype%': typeof Promise === 'undefined' ? undefined$1 : Promise.prototype,
|
4169 | '%PromiseProto_then%': typeof Promise === 'undefined' ? undefined$1 : Promise.prototype.then,
|
4170 | '%Promise_all%': typeof Promise === 'undefined' ? undefined$1 : Promise.all,
|
4171 | '%Promise_reject%': typeof Promise === 'undefined' ? undefined$1 : Promise.reject,
|
4172 | '%Promise_resolve%': typeof Promise === 'undefined' ? undefined$1 : Promise.resolve,
|
4173 | '%Proxy%': typeof Proxy === 'undefined' ? undefined$1 : Proxy,
|
4174 | '%RangeError%': RangeError,
|
4175 | '%RangeErrorPrototype%': RangeError.prototype,
|
4176 | '%ReferenceError%': ReferenceError,
|
4177 | '%ReferenceErrorPrototype%': ReferenceError.prototype,
|
4178 | '%Reflect%': typeof Reflect === 'undefined' ? undefined$1 : Reflect,
|
4179 | '%RegExp%': RegExp,
|
4180 | '%RegExpPrototype%': RegExp.prototype,
|
4181 | '%Set%': typeof Set === 'undefined' ? undefined$1 : Set,
|
4182 | '%SetIteratorPrototype%': typeof Set === 'undefined' || !hasSymbols$2 ? undefined$1 : getProto(new Set()[Symbol.iterator]()),
|
4183 | '%SetPrototype%': typeof Set === 'undefined' ? undefined$1 : Set.prototype,
|
4184 | '%SharedArrayBuffer%': typeof SharedArrayBuffer === 'undefined' ? undefined$1 : SharedArrayBuffer,
|
4185 | '%SharedArrayBufferPrototype%': typeof SharedArrayBuffer === 'undefined' ? undefined$1 : SharedArrayBuffer.prototype,
|
4186 | '%String%': String,
|
4187 | '%StringIteratorPrototype%': hasSymbols$2 ? getProto(''[Symbol.iterator]()) : undefined$1,
|
4188 | '%StringPrototype%': String.prototype,
|
4189 | '%Symbol%': hasSymbols$2 ? Symbol : undefined$1,
|
4190 | '%SymbolPrototype%': hasSymbols$2 ? Symbol.prototype : undefined$1,
|
4191 | '%SyntaxError%': SyntaxError,
|
4192 | '%SyntaxErrorPrototype%': SyntaxError.prototype,
|
4193 | '%ThrowTypeError%': ThrowTypeError,
|
4194 | '%TypedArray%': TypedArray,
|
4195 | '%TypedArrayPrototype%': TypedArray ? TypedArray.prototype : undefined$1,
|
4196 | '%TypeError%': $TypeError,
|
4197 | '%TypeErrorPrototype%': $TypeError.prototype,
|
4198 | '%Uint8Array%': typeof Uint8Array === 'undefined' ? undefined$1 : Uint8Array,
|
4199 | '%Uint8ArrayPrototype%': typeof Uint8Array === 'undefined' ? undefined$1 : Uint8Array.prototype,
|
4200 | '%Uint8ClampedArray%': typeof Uint8ClampedArray === 'undefined' ? undefined$1 : Uint8ClampedArray,
|
4201 | '%Uint8ClampedArrayPrototype%': typeof Uint8ClampedArray === 'undefined' ? undefined$1 : Uint8ClampedArray.prototype,
|
4202 | '%Uint16Array%': typeof Uint16Array === 'undefined' ? undefined$1 : Uint16Array,
|
4203 | '%Uint16ArrayPrototype%': typeof Uint16Array === 'undefined' ? undefined$1 : Uint16Array.prototype,
|
4204 | '%Uint32Array%': typeof Uint32Array === 'undefined' ? undefined$1 : Uint32Array,
|
4205 | '%Uint32ArrayPrototype%': typeof Uint32Array === 'undefined' ? undefined$1 : Uint32Array.prototype,
|
4206 | '%URIError%': URIError,
|
4207 | '%URIErrorPrototype%': URIError.prototype,
|
4208 | '%WeakMap%': typeof WeakMap === 'undefined' ? undefined$1 : WeakMap,
|
4209 | '%WeakMapPrototype%': typeof WeakMap === 'undefined' ? undefined$1 : WeakMap.prototype,
|
4210 | '%WeakSet%': typeof WeakSet === 'undefined' ? undefined$1 : WeakSet,
|
4211 | '%WeakSetPrototype%': typeof WeakSet === 'undefined' ? undefined$1 : WeakSet.prototype
|
4212 | };
|
4213 |
|
4214 |
|
4215 | var $replace = functionBind.call(Function.call, String.prototype.replace);
|
4216 |
|
4217 |
|
4218 | var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
|
4219 | var reEscapeChar = /\\(\\)?/g;
|
4220 | var stringToPath = function stringToPath(string) {
|
4221 | var result = [];
|
4222 | $replace(string, rePropName, function (match, number, quote, subString) {
|
4223 | result[result.length] = quote ? $replace(subString, reEscapeChar, '$1') : (number || match);
|
4224 | });
|
4225 | return result;
|
4226 | };
|
4227 |
|
4228 |
|
4229 | var getBaseIntrinsic = function getBaseIntrinsic(name, allowMissing) {
|
4230 | if (!(name in INTRINSICS)) {
|
4231 | throw new SyntaxError('intrinsic ' + name + ' does not exist!');
|
4232 | }
|
4233 |
|
4234 |
|
4235 | if (typeof INTRINSICS[name] === 'undefined' && !allowMissing) {
|
4236 | throw new $TypeError('intrinsic ' + name + ' exists, but is not available. Please file an issue!');
|
4237 | }
|
4238 |
|
4239 | return INTRINSICS[name];
|
4240 | };
|
4241 |
|
4242 | var GetIntrinsic = function GetIntrinsic(name, allowMissing) {
|
4243 | if (typeof name !== 'string' || name.length === 0) {
|
4244 | throw new TypeError('intrinsic name must be a non-empty string');
|
4245 | }
|
4246 | if (arguments.length > 1 && typeof allowMissing !== 'boolean') {
|
4247 | throw new TypeError('"allowMissing" argument must be a boolean');
|
4248 | }
|
4249 |
|
4250 | var parts = stringToPath(name);
|
4251 |
|
4252 | var value = getBaseIntrinsic('%' + (parts.length > 0 ? parts[0] : '') + '%', allowMissing);
|
4253 | for (var i = 1; i < parts.length; i += 1) {
|
4254 | if (value != null) {
|
4255 | if ($gOPD && (i + 1) >= parts.length) {
|
4256 | var desc = $gOPD(value, parts[i]);
|
4257 | if (!allowMissing && !(parts[i] in value)) {
|
4258 | throw new $TypeError('base intrinsic for ' + name + ' exists, but the property is not available.');
|
4259 | }
|
4260 | value = desc ? (desc.get || desc.value) : value[parts[i]];
|
4261 | } else {
|
4262 | value = value[parts[i]];
|
4263 | }
|
4264 | }
|
4265 | }
|
4266 | return value;
|
4267 | };
|
4268 |
|
4269 | var $apply = GetIntrinsic('%Function.prototype.apply%');
|
4270 | var $call = GetIntrinsic('%Function.prototype.call%');
|
4271 | var $reflectApply = GetIntrinsic('%Reflect.apply%', true) || functionBind.call($call, $apply);
|
4272 |
|
4273 | var callBind = function callBind() {
|
4274 | return $reflectApply(functionBind, $call, arguments);
|
4275 | };
|
4276 |
|
4277 | var apply = function applyBind() {
|
4278 | return $reflectApply(functionBind, $apply, arguments);
|
4279 | };
|
4280 | callBind.apply = apply;
|
4281 |
|
4282 | var numberIsNaN = function (value) {
|
4283 | return value !== value;
|
4284 | };
|
4285 |
|
4286 | var implementation$2 = function is(a, b) {
|
4287 | if (a === 0 && b === 0) {
|
4288 | return 1 / a === 1 / b;
|
4289 | }
|
4290 | if (a === b) {
|
4291 | return true;
|
4292 | }
|
4293 | if (numberIsNaN(a) && numberIsNaN(b)) {
|
4294 | return true;
|
4295 | }
|
4296 | return false;
|
4297 | };
|
4298 |
|
4299 | var polyfill = function getPolyfill() {
|
4300 | return typeof Object.is === 'function' ? Object.is : implementation$2;
|
4301 | };
|
4302 |
|
4303 | var shim = function shimObjectIs() {
|
4304 | var polyfill$1 = polyfill();
|
4305 | defineProperties_1(Object, { is: polyfill$1 }, {
|
4306 | is: function testObjectIs() {
|
4307 | return Object.is !== polyfill$1;
|
4308 | }
|
4309 | });
|
4310 | return polyfill$1;
|
4311 | };
|
4312 |
|
4313 | var polyfill$1 = callBind(polyfill(), Object);
|
4314 |
|
4315 | defineProperties_1(polyfill$1, {
|
4316 | getPolyfill: polyfill,
|
4317 | implementation: implementation$2,
|
4318 | shim: shim
|
4319 | });
|
4320 |
|
4321 | var objectIs = polyfill$1;
|
4322 |
|
4323 | var hasSymbols$3 = hasSymbols$1();
|
4324 | var hasToStringTag$1 = hasSymbols$3 && typeof Symbol.toStringTag === 'symbol';
|
4325 | var hasOwnProperty$1;
|
4326 | var regexExec;
|
4327 | var isRegexMarker;
|
4328 | var badStringifier;
|
4329 |
|
4330 | if (hasToStringTag$1) {
|
4331 | hasOwnProperty$1 = Function.call.bind(Object.prototype.hasOwnProperty);
|
4332 | regexExec = Function.call.bind(RegExp.prototype.exec);
|
4333 | isRegexMarker = {};
|
4334 |
|
4335 | var throwRegexMarker = function () {
|
4336 | throw isRegexMarker;
|
4337 | };
|
4338 | badStringifier = {
|
4339 | toString: throwRegexMarker,
|
4340 | valueOf: throwRegexMarker
|
4341 | };
|
4342 |
|
4343 | if (typeof Symbol.toPrimitive === 'symbol') {
|
4344 | badStringifier[Symbol.toPrimitive] = throwRegexMarker;
|
4345 | }
|
4346 | }
|
4347 |
|
4348 | var toStr$5 = Object.prototype.toString;
|
4349 | var gOPD = Object.getOwnPropertyDescriptor;
|
4350 | var regexClass = '[object RegExp]';
|
4351 |
|
4352 | var isRegex = hasToStringTag$1
|
4353 |
|
4354 | ? function isRegex(value) {
|
4355 | if (!value || typeof value !== 'object') {
|
4356 | return false;
|
4357 | }
|
4358 |
|
4359 | var descriptor = gOPD(value, 'lastIndex');
|
4360 | var hasLastIndexDataProperty = descriptor && hasOwnProperty$1(descriptor, 'value');
|
4361 | if (!hasLastIndexDataProperty) {
|
4362 | return false;
|
4363 | }
|
4364 |
|
4365 | try {
|
4366 | regexExec(value, badStringifier);
|
4367 | } catch (e) {
|
4368 | return e === isRegexMarker;
|
4369 | }
|
4370 | }
|
4371 | : function isRegex(value) {
|
4372 |
|
4373 | if (!value || (typeof value !== 'object' && typeof value !== 'function')) {
|
4374 | return false;
|
4375 | }
|
4376 |
|
4377 | return toStr$5.call(value) === regexClass;
|
4378 | };
|
4379 |
|
4380 | var $Object = Object;
|
4381 | var $TypeError$1 = TypeError;
|
4382 |
|
4383 | var implementation$3 = function flags() {
|
4384 | if (this != null && this !== $Object(this)) {
|
4385 | throw new $TypeError$1('RegExp.prototype.flags getter called on non-object');
|
4386 | }
|
4387 | var result = '';
|
4388 | if (this.global) {
|
4389 | result += 'g';
|
4390 | }
|
4391 | if (this.ignoreCase) {
|
4392 | result += 'i';
|
4393 | }
|
4394 | if (this.multiline) {
|
4395 | result += 'm';
|
4396 | }
|
4397 | if (this.dotAll) {
|
4398 | result += 's';
|
4399 | }
|
4400 | if (this.unicode) {
|
4401 | result += 'u';
|
4402 | }
|
4403 | if (this.sticky) {
|
4404 | result += 'y';
|
4405 | }
|
4406 | return result;
|
4407 | };
|
4408 |
|
4409 | var supportsDescriptors$1 = defineProperties_1.supportsDescriptors;
|
4410 | var $gOPD$1 = Object.getOwnPropertyDescriptor;
|
4411 | var $TypeError$2 = TypeError;
|
4412 |
|
4413 | var polyfill$2 = function getPolyfill() {
|
4414 | if (!supportsDescriptors$1) {
|
4415 | throw new $TypeError$2('RegExp.prototype.flags requires a true ES5 environment that supports property descriptors');
|
4416 | }
|
4417 | if ((/a/mig).flags === 'gim') {
|
4418 | var descriptor = $gOPD$1(RegExp.prototype, 'flags');
|
4419 | if (descriptor && typeof descriptor.get === 'function' && typeof (/a/).dotAll === 'boolean') {
|
4420 | return descriptor.get;
|
4421 | }
|
4422 | }
|
4423 | return implementation$3;
|
4424 | };
|
4425 |
|
4426 | var supportsDescriptors$2 = defineProperties_1.supportsDescriptors;
|
4427 |
|
4428 | var gOPD$1 = Object.getOwnPropertyDescriptor;
|
4429 | var defineProperty$2 = Object.defineProperty;
|
4430 | var TypeErr = TypeError;
|
4431 | var getProto$1 = Object.getPrototypeOf;
|
4432 | var regex = /a/;
|
4433 |
|
4434 | var shim$1 = function shimFlags() {
|
4435 | if (!supportsDescriptors$2 || !getProto$1) {
|
4436 | throw new TypeErr('RegExp.prototype.flags requires a true ES5 environment that supports property descriptors');
|
4437 | }
|
4438 | var polyfill = polyfill$2();
|
4439 | var proto = getProto$1(regex);
|
4440 | var descriptor = gOPD$1(proto, 'flags');
|
4441 | if (!descriptor || descriptor.get !== polyfill) {
|
4442 | defineProperty$2(proto, 'flags', {
|
4443 | configurable: true,
|
4444 | enumerable: false,
|
4445 | get: polyfill
|
4446 | });
|
4447 | }
|
4448 | return polyfill;
|
4449 | };
|
4450 |
|
4451 | var flagsBound = callBind(implementation$3);
|
4452 |
|
4453 | defineProperties_1(flagsBound, {
|
4454 | getPolyfill: polyfill$2,
|
4455 | implementation: implementation$3,
|
4456 | shim: shim$1
|
4457 | });
|
4458 |
|
4459 | var regexp_prototype_flags = flagsBound;
|
4460 |
|
4461 | var getDay = Date.prototype.getDay;
|
4462 | var tryDateObject = function tryDateGetDayCall(value) {
|
4463 | try {
|
4464 | getDay.call(value);
|
4465 | return true;
|
4466 | } catch (e) {
|
4467 | return false;
|
4468 | }
|
4469 | };
|
4470 |
|
4471 | var toStr$6 = Object.prototype.toString;
|
4472 | var dateClass = '[object Date]';
|
4473 | var hasToStringTag$2 = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
|
4474 |
|
4475 | var isDateObject = function isDateObject(value) {
|
4476 | if (typeof value !== 'object' || value === null) {
|
4477 | return false;
|
4478 | }
|
4479 | return hasToStringTag$2 ? tryDateObject(value) : toStr$6.call(value) === dateClass;
|
4480 | };
|
4481 |
|
4482 | var getTime = Date.prototype.getTime;
|
4483 |
|
4484 | function deepEqual(actual, expected, options) {
|
4485 | var opts = options || {};
|
4486 |
|
4487 |
|
4488 | if (opts.strict ? objectIs(actual, expected) : actual === expected) {
|
4489 | return true;
|
4490 | }
|
4491 |
|
4492 |
|
4493 | if (!actual || !expected || (typeof actual !== 'object' && typeof expected !== 'object')) {
|
4494 | return opts.strict ? objectIs(actual, expected) : actual == expected;
|
4495 | }
|
4496 |
|
4497 | |
4498 |
|
4499 |
|
4500 |
|
4501 |
|
4502 |
|
4503 |
|
4504 |
|
4505 |
|
4506 | return objEquiv(actual, expected, opts);
|
4507 | }
|
4508 |
|
4509 | function isUndefinedOrNull(value) {
|
4510 | return value === null || value === undefined;
|
4511 | }
|
4512 |
|
4513 | function isBuffer(x) {
|
4514 | if (!x || typeof x !== 'object' || typeof x.length !== 'number') {
|
4515 | return false;
|
4516 | }
|
4517 | if (typeof x.copy !== 'function' || typeof x.slice !== 'function') {
|
4518 | return false;
|
4519 | }
|
4520 | if (x.length > 0 && typeof x[0] !== 'number') {
|
4521 | return false;
|
4522 | }
|
4523 | return true;
|
4524 | }
|
4525 |
|
4526 | function objEquiv(a, b, opts) {
|
4527 |
|
4528 | var i, key;
|
4529 | if (typeof a !== typeof b) { return false; }
|
4530 | if (isUndefinedOrNull(a) || isUndefinedOrNull(b)) { return false; }
|
4531 |
|
4532 |
|
4533 | if (a.prototype !== b.prototype) { return false; }
|
4534 |
|
4535 | if (isArguments$1(a) !== isArguments$1(b)) { return false; }
|
4536 |
|
4537 | var aIsRegex = isRegex(a);
|
4538 | var bIsRegex = isRegex(b);
|
4539 | if (aIsRegex !== bIsRegex) { return false; }
|
4540 | if (aIsRegex || bIsRegex) {
|
4541 | return a.source === b.source && regexp_prototype_flags(a) === regexp_prototype_flags(b);
|
4542 | }
|
4543 |
|
4544 | if (isDateObject(a) && isDateObject(b)) {
|
4545 | return getTime.call(a) === getTime.call(b);
|
4546 | }
|
4547 |
|
4548 | var aIsBuffer = isBuffer(a);
|
4549 | var bIsBuffer = isBuffer(b);
|
4550 | if (aIsBuffer !== bIsBuffer) { return false; }
|
4551 | if (aIsBuffer || bIsBuffer) {
|
4552 | if (a.length !== b.length) { return false; }
|
4553 | for (i = 0; i < a.length; i++) {
|
4554 | if (a[i] !== b[i]) { return false; }
|
4555 | }
|
4556 | return true;
|
4557 | }
|
4558 |
|
4559 | if (typeof a !== typeof b) { return false; }
|
4560 |
|
4561 | try {
|
4562 | var ka = objectKeys(a);
|
4563 | var kb = objectKeys(b);
|
4564 | } catch (e) {
|
4565 | return false;
|
4566 | }
|
4567 |
|
4568 | if (ka.length !== kb.length) { return false; }
|
4569 |
|
4570 |
|
4571 | ka.sort();
|
4572 | kb.sort();
|
4573 |
|
4574 | for (i = ka.length - 1; i >= 0; i--) {
|
4575 | if (ka[i] != kb[i]) { return false; }
|
4576 | }
|
4577 |
|
4578 | for (i = ka.length - 1; i >= 0; i--) {
|
4579 | key = ka[i];
|
4580 | if (!deepEqual(a[key], b[key], opts)) { return false; }
|
4581 | }
|
4582 |
|
4583 | return true;
|
4584 | }
|
4585 |
|
4586 | var deepEqual_1 = deepEqual;
|
4587 |
|
4588 | |
4589 |
|
4590 |
|
4591 |
|
4592 |
|
4593 |
|
4594 |
|
4595 |
|
4596 |
|
4597 |
|
4598 |
|
4599 |
|
4600 |
|
4601 |
|
4602 |
|
4603 |
|
4604 |
|
4605 |
|
4606 |
|
4607 |
|
4608 |
|
4609 |
|
4610 |
|
4611 |
|
4612 | var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && typeof navigator !== 'undefined';
|
4613 |
|
4614 | var timeoutDuration = function () {
|
4615 | var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox'];
|
4616 | for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) {
|
4617 | if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) {
|
4618 | return 1;
|
4619 | }
|
4620 | }
|
4621 | return 0;
|
4622 | }();
|
4623 |
|
4624 | function microtaskDebounce(fn) {
|
4625 | var called = false;
|
4626 | return function () {
|
4627 | if (called) {
|
4628 | return;
|
4629 | }
|
4630 | called = true;
|
4631 | window.Promise.resolve().then(function () {
|
4632 | called = false;
|
4633 | fn();
|
4634 | });
|
4635 | };
|
4636 | }
|
4637 |
|
4638 | function taskDebounce(fn) {
|
4639 | var scheduled = false;
|
4640 | return function () {
|
4641 | if (!scheduled) {
|
4642 | scheduled = true;
|
4643 | setTimeout(function () {
|
4644 | scheduled = false;
|
4645 | fn();
|
4646 | }, timeoutDuration);
|
4647 | }
|
4648 | };
|
4649 | }
|
4650 |
|
4651 | var supportsMicroTasks = isBrowser && window.Promise;
|
4652 |
|
4653 | |
4654 |
|
4655 |
|
4656 |
|
4657 |
|
4658 |
|
4659 |
|
4660 |
|
4661 |
|
4662 | var debounce$1 = supportsMicroTasks ? microtaskDebounce : taskDebounce;
|
4663 |
|
4664 | |
4665 |
|
4666 |
|
4667 |
|
4668 |
|
4669 |
|
4670 |
|
4671 | function isFunction$2(functionToCheck) {
|
4672 | var getType = {};
|
4673 | return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
|
4674 | }
|
4675 |
|
4676 | |
4677 |
|
4678 |
|
4679 |
|
4680 |
|
4681 |
|
4682 |
|
4683 | function getStyleComputedProperty(element, property) {
|
4684 | if (element.nodeType !== 1) {
|
4685 | return [];
|
4686 | }
|
4687 |
|
4688 | var window = element.ownerDocument.defaultView;
|
4689 | var css = window.getComputedStyle(element, null);
|
4690 | return property ? css[property] : css;
|
4691 | }
|
4692 |
|
4693 | |
4694 |
|
4695 |
|
4696 |
|
4697 |
|
4698 |
|
4699 |
|
4700 | function getParentNode(element) {
|
4701 | if (element.nodeName === 'HTML') {
|
4702 | return element;
|
4703 | }
|
4704 | return element.parentNode || element.host;
|
4705 | }
|
4706 |
|
4707 | |
4708 |
|
4709 |
|
4710 |
|
4711 |
|
4712 |
|
4713 |
|
4714 | function getScrollParent(element) {
|
4715 |
|
4716 | if (!element) {
|
4717 | return document.body;
|
4718 | }
|
4719 |
|
4720 | switch (element.nodeName) {
|
4721 | case 'HTML':
|
4722 | case 'BODY':
|
4723 | return element.ownerDocument.body;
|
4724 | case '#document':
|
4725 | return element.body;
|
4726 | }
|
4727 |
|
4728 |
|
4729 |
|
4730 | var _getStyleComputedProp = getStyleComputedProperty(element),
|
4731 | overflow = _getStyleComputedProp.overflow,
|
4732 | overflowX = _getStyleComputedProp.overflowX,
|
4733 | overflowY = _getStyleComputedProp.overflowY;
|
4734 |
|
4735 | if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
|
4736 | return element;
|
4737 | }
|
4738 |
|
4739 | return getScrollParent(getParentNode(element));
|
4740 | }
|
4741 |
|
4742 | |
4743 |
|
4744 |
|
4745 |
|
4746 |
|
4747 |
|
4748 |
|
4749 | function getReferenceNode(reference) {
|
4750 | return reference && reference.referenceNode ? reference.referenceNode : reference;
|
4751 | }
|
4752 |
|
4753 | var isIE11 = isBrowser && !!(window.MSInputMethodContext && document.documentMode);
|
4754 | var isIE10 = isBrowser && /MSIE 10/.test(navigator.userAgent);
|
4755 |
|
4756 | |
4757 |
|
4758 |
|
4759 |
|
4760 |
|
4761 |
|
4762 |
|
4763 | function isIE(version) {
|
4764 | if (version === 11) {
|
4765 | return isIE11;
|
4766 | }
|
4767 | if (version === 10) {
|
4768 | return isIE10;
|
4769 | }
|
4770 | return isIE11 || isIE10;
|
4771 | }
|
4772 |
|
4773 | |
4774 |
|
4775 |
|
4776 |
|
4777 |
|
4778 |
|
4779 |
|
4780 | function getOffsetParent(element) {
|
4781 | if (!element) {
|
4782 | return document.documentElement;
|
4783 | }
|
4784 |
|
4785 | var noOffsetParent = isIE(10) ? document.body : null;
|
4786 |
|
4787 |
|
4788 | var offsetParent = element.offsetParent || null;
|
4789 |
|
4790 | while (offsetParent === noOffsetParent && element.nextElementSibling) {
|
4791 | offsetParent = (element = element.nextElementSibling).offsetParent;
|
4792 | }
|
4793 |
|
4794 | var nodeName = offsetParent && offsetParent.nodeName;
|
4795 |
|
4796 | if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {
|
4797 | return element ? element.ownerDocument.documentElement : document.documentElement;
|
4798 | }
|
4799 |
|
4800 |
|
4801 |
|
4802 | if (['TH', 'TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') {
|
4803 | return getOffsetParent(offsetParent);
|
4804 | }
|
4805 |
|
4806 | return offsetParent;
|
4807 | }
|
4808 |
|
4809 | function isOffsetContainer(element) {
|
4810 | var nodeName = element.nodeName;
|
4811 |
|
4812 | if (nodeName === 'BODY') {
|
4813 | return false;
|
4814 | }
|
4815 | return nodeName === 'HTML' || getOffsetParent(element.firstElementChild) === element;
|
4816 | }
|
4817 |
|
4818 | |
4819 |
|
4820 |
|
4821 |
|
4822 |
|
4823 |
|
4824 |
|
4825 | function getRoot(node) {
|
4826 | if (node.parentNode !== null) {
|
4827 | return getRoot(node.parentNode);
|
4828 | }
|
4829 |
|
4830 | return node;
|
4831 | }
|
4832 |
|
4833 | |
4834 |
|
4835 |
|
4836 |
|
4837 |
|
4838 |
|
4839 |
|
4840 |
|
4841 | function findCommonOffsetParent(element1, element2) {
|
4842 |
|
4843 | if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) {
|
4844 | return document.documentElement;
|
4845 | }
|
4846 |
|
4847 |
|
4848 | var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING;
|
4849 | var start = order ? element1 : element2;
|
4850 | var end = order ? element2 : element1;
|
4851 |
|
4852 |
|
4853 | var range = document.createRange();
|
4854 | range.setStart(start, 0);
|
4855 | range.setEnd(end, 0);
|
4856 | var commonAncestorContainer = range.commonAncestorContainer;
|
4857 |
|
4858 |
|
4859 |
|
4860 | if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) {
|
4861 | if (isOffsetContainer(commonAncestorContainer)) {
|
4862 | return commonAncestorContainer;
|
4863 | }
|
4864 |
|
4865 | return getOffsetParent(commonAncestorContainer);
|
4866 | }
|
4867 |
|
4868 |
|
4869 | var element1root = getRoot(element1);
|
4870 | if (element1root.host) {
|
4871 | return findCommonOffsetParent(element1root.host, element2);
|
4872 | } else {
|
4873 | return findCommonOffsetParent(element1, getRoot(element2).host);
|
4874 | }
|
4875 | }
|
4876 |
|
4877 | |
4878 |
|
4879 |
|
4880 |
|
4881 |
|
4882 |
|
4883 |
|
4884 |
|
4885 | function getScroll(element) {
|
4886 | var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top';
|
4887 |
|
4888 | var upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft';
|
4889 | var nodeName = element.nodeName;
|
4890 |
|
4891 | if (nodeName === 'BODY' || nodeName === 'HTML') {
|
4892 | var html = element.ownerDocument.documentElement;
|
4893 | var scrollingElement = element.ownerDocument.scrollingElement || html;
|
4894 | return scrollingElement[upperSide];
|
4895 | }
|
4896 |
|
4897 | return element[upperSide];
|
4898 | }
|
4899 |
|
4900 | |
4901 |
|
4902 |
|
4903 |
|
4904 |
|
4905 |
|
4906 |
|
4907 |
|
4908 |
|
4909 | function includeScroll(rect, element) {
|
4910 | var subtract = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
4911 |
|
4912 | var scrollTop = getScroll(element, 'top');
|
4913 | var scrollLeft = getScroll(element, 'left');
|
4914 | var modifier = subtract ? -1 : 1;
|
4915 | rect.top += scrollTop * modifier;
|
4916 | rect.bottom += scrollTop * modifier;
|
4917 | rect.left += scrollLeft * modifier;
|
4918 | rect.right += scrollLeft * modifier;
|
4919 | return rect;
|
4920 | }
|
4921 |
|
4922 | |
4923 |
|
4924 |
|
4925 |
|
4926 |
|
4927 |
|
4928 |
|
4929 |
|
4930 |
|
4931 |
|
4932 | function getBordersSize(styles, axis) {
|
4933 | var sideA = axis === 'x' ? 'Left' : 'Top';
|
4934 | var sideB = sideA === 'Left' ? 'Right' : 'Bottom';
|
4935 |
|
4936 | return parseFloat(styles['border' + sideA + 'Width']) + parseFloat(styles['border' + sideB + 'Width']);
|
4937 | }
|
4938 |
|
4939 | function getSize(axis, body, html, computedStyle) {
|
4940 | return Math.max(body['offset' + axis], body['scroll' + axis], html['client' + axis], html['offset' + axis], html['scroll' + axis], isIE(10) ? parseInt(html['offset' + axis]) + parseInt(computedStyle['margin' + (axis === 'Height' ? 'Top' : 'Left')]) + parseInt(computedStyle['margin' + (axis === 'Height' ? 'Bottom' : 'Right')]) : 0);
|
4941 | }
|
4942 |
|
4943 | function getWindowSizes(document) {
|
4944 | var body = document.body;
|
4945 | var html = document.documentElement;
|
4946 | var computedStyle = isIE(10) && getComputedStyle(html);
|
4947 |
|
4948 | return {
|
4949 | height: getSize('Height', body, html, computedStyle),
|
4950 | width: getSize('Width', body, html, computedStyle)
|
4951 | };
|
4952 | }
|
4953 |
|
4954 | var classCallCheck = function (instance, Constructor) {
|
4955 | if (!(instance instanceof Constructor)) {
|
4956 | throw new TypeError("Cannot call a class as a function");
|
4957 | }
|
4958 | };
|
4959 |
|
4960 | var createClass = function () {
|
4961 | function defineProperties(target, props) {
|
4962 | for (var i = 0; i < props.length; i++) {
|
4963 | var descriptor = props[i];
|
4964 | descriptor.enumerable = descriptor.enumerable || false;
|
4965 | descriptor.configurable = true;
|
4966 | if ("value" in descriptor) descriptor.writable = true;
|
4967 | Object.defineProperty(target, descriptor.key, descriptor);
|
4968 | }
|
4969 | }
|
4970 |
|
4971 | return function (Constructor, protoProps, staticProps) {
|
4972 | if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
4973 | if (staticProps) defineProperties(Constructor, staticProps);
|
4974 | return Constructor;
|
4975 | };
|
4976 | }();
|
4977 |
|
4978 |
|
4979 |
|
4980 |
|
4981 |
|
4982 | var defineProperty$3 = function (obj, key, value) {
|
4983 | if (key in obj) {
|
4984 | Object.defineProperty(obj, key, {
|
4985 | value: value,
|
4986 | enumerable: true,
|
4987 | configurable: true,
|
4988 | writable: true
|
4989 | });
|
4990 | } else {
|
4991 | obj[key] = value;
|
4992 | }
|
4993 |
|
4994 | return obj;
|
4995 | };
|
4996 |
|
4997 | var _extends$1 = Object.assign || function (target) {
|
4998 | for (var i = 1; i < arguments.length; i++) {
|
4999 | var source = arguments[i];
|
5000 |
|
5001 | for (var key in source) {
|
5002 | if (Object.prototype.hasOwnProperty.call(source, key)) {
|
5003 | target[key] = source[key];
|
5004 | }
|
5005 | }
|
5006 | }
|
5007 |
|
5008 | return target;
|
5009 | };
|
5010 |
|
5011 | |
5012 |
|
5013 |
|
5014 |
|
5015 |
|
5016 |
|
5017 |
|
5018 | function getClientRect(offsets) {
|
5019 | return _extends$1({}, offsets, {
|
5020 | right: offsets.left + offsets.width,
|
5021 | bottom: offsets.top + offsets.height
|
5022 | });
|
5023 | }
|
5024 |
|
5025 | |
5026 |
|
5027 |
|
5028 |
|
5029 |
|
5030 |
|
5031 |
|
5032 | function getBoundingClientRect(element) {
|
5033 | var rect = {};
|
5034 |
|
5035 |
|
5036 |
|
5037 |
|
5038 | try {
|
5039 | if (isIE(10)) {
|
5040 | rect = element.getBoundingClientRect();
|
5041 | var scrollTop = getScroll(element, 'top');
|
5042 | var scrollLeft = getScroll(element, 'left');
|
5043 | rect.top += scrollTop;
|
5044 | rect.left += scrollLeft;
|
5045 | rect.bottom += scrollTop;
|
5046 | rect.right += scrollLeft;
|
5047 | } else {
|
5048 | rect = element.getBoundingClientRect();
|
5049 | }
|
5050 | } catch (e) {}
|
5051 |
|
5052 | var result = {
|
5053 | left: rect.left,
|
5054 | top: rect.top,
|
5055 | width: rect.right - rect.left,
|
5056 | height: rect.bottom - rect.top
|
5057 | };
|
5058 |
|
5059 |
|
5060 | var sizes = element.nodeName === 'HTML' ? getWindowSizes(element.ownerDocument) : {};
|
5061 | var width = sizes.width || element.clientWidth || result.width;
|
5062 | var height = sizes.height || element.clientHeight || result.height;
|
5063 |
|
5064 | var horizScrollbar = element.offsetWidth - width;
|
5065 | var vertScrollbar = element.offsetHeight - height;
|
5066 |
|
5067 |
|
5068 |
|
5069 | if (horizScrollbar || vertScrollbar) {
|
5070 | var styles = getStyleComputedProperty(element);
|
5071 | horizScrollbar -= getBordersSize(styles, 'x');
|
5072 | vertScrollbar -= getBordersSize(styles, 'y');
|
5073 |
|
5074 | result.width -= horizScrollbar;
|
5075 | result.height -= vertScrollbar;
|
5076 | }
|
5077 |
|
5078 | return getClientRect(result);
|
5079 | }
|
5080 |
|
5081 | function getOffsetRectRelativeToArbitraryNode(children, parent) {
|
5082 | var fixedPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
5083 |
|
5084 | var isIE10 = isIE(10);
|
5085 | var isHTML = parent.nodeName === 'HTML';
|
5086 | var childrenRect = getBoundingClientRect(children);
|
5087 | var parentRect = getBoundingClientRect(parent);
|
5088 | var scrollParent = getScrollParent(children);
|
5089 |
|
5090 | var styles = getStyleComputedProperty(parent);
|
5091 | var borderTopWidth = parseFloat(styles.borderTopWidth);
|
5092 | var borderLeftWidth = parseFloat(styles.borderLeftWidth);
|
5093 |
|
5094 |
|
5095 | if (fixedPosition && isHTML) {
|
5096 | parentRect.top = Math.max(parentRect.top, 0);
|
5097 | parentRect.left = Math.max(parentRect.left, 0);
|
5098 | }
|
5099 | var offsets = getClientRect({
|
5100 | top: childrenRect.top - parentRect.top - borderTopWidth,
|
5101 | left: childrenRect.left - parentRect.left - borderLeftWidth,
|
5102 | width: childrenRect.width,
|
5103 | height: childrenRect.height
|
5104 | });
|
5105 | offsets.marginTop = 0;
|
5106 | offsets.marginLeft = 0;
|
5107 |
|
5108 |
|
5109 |
|
5110 |
|
5111 |
|
5112 | if (!isIE10 && isHTML) {
|
5113 | var marginTop = parseFloat(styles.marginTop);
|
5114 | var marginLeft = parseFloat(styles.marginLeft);
|
5115 |
|
5116 | offsets.top -= borderTopWidth - marginTop;
|
5117 | offsets.bottom -= borderTopWidth - marginTop;
|
5118 | offsets.left -= borderLeftWidth - marginLeft;
|
5119 | offsets.right -= borderLeftWidth - marginLeft;
|
5120 |
|
5121 |
|
5122 | offsets.marginTop = marginTop;
|
5123 | offsets.marginLeft = marginLeft;
|
5124 | }
|
5125 |
|
5126 | if (isIE10 && !fixedPosition ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') {
|
5127 | offsets = includeScroll(offsets, parent);
|
5128 | }
|
5129 |
|
5130 | return offsets;
|
5131 | }
|
5132 |
|
5133 | function getViewportOffsetRectRelativeToArtbitraryNode(element) {
|
5134 | var excludeScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
5135 |
|
5136 | var html = element.ownerDocument.documentElement;
|
5137 | var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html);
|
5138 | var width = Math.max(html.clientWidth, window.innerWidth || 0);
|
5139 | var height = Math.max(html.clientHeight, window.innerHeight || 0);
|
5140 |
|
5141 | var scrollTop = !excludeScroll ? getScroll(html) : 0;
|
5142 | var scrollLeft = !excludeScroll ? getScroll(html, 'left') : 0;
|
5143 |
|
5144 | var offset = {
|
5145 | top: scrollTop - relativeOffset.top + relativeOffset.marginTop,
|
5146 | left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft,
|
5147 | width: width,
|
5148 | height: height
|
5149 | };
|
5150 |
|
5151 | return getClientRect(offset);
|
5152 | }
|
5153 |
|
5154 | |
5155 |
|
5156 |
|
5157 |
|
5158 |
|
5159 |
|
5160 |
|
5161 |
|
5162 | function isFixed(element) {
|
5163 | var nodeName = element.nodeName;
|
5164 | if (nodeName === 'BODY' || nodeName === 'HTML') {
|
5165 | return false;
|
5166 | }
|
5167 | if (getStyleComputedProperty(element, 'position') === 'fixed') {
|
5168 | return true;
|
5169 | }
|
5170 | var parentNode = getParentNode(element);
|
5171 | if (!parentNode) {
|
5172 | return false;
|
5173 | }
|
5174 | return isFixed(parentNode);
|
5175 | }
|
5176 |
|
5177 | |
5178 |
|
5179 |
|
5180 |
|
5181 |
|
5182 |
|
5183 |
|
5184 |
|
5185 | function getFixedPositionOffsetParent(element) {
|
5186 |
|
5187 | if (!element || !element.parentElement || isIE()) {
|
5188 | return document.documentElement;
|
5189 | }
|
5190 | var el = element.parentElement;
|
5191 | while (el && getStyleComputedProperty(el, 'transform') === 'none') {
|
5192 | el = el.parentElement;
|
5193 | }
|
5194 | return el || document.documentElement;
|
5195 | }
|
5196 |
|
5197 | |
5198 |
|
5199 |
|
5200 |
|
5201 |
|
5202 |
|
5203 |
|
5204 |
|
5205 |
|
5206 |
|
5207 |
|
5208 | function getBoundaries(popper, reference, padding, boundariesElement) {
|
5209 | var fixedPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
5210 |
|
5211 |
|
5212 |
|
5213 | var boundaries = { top: 0, left: 0 };
|
5214 | var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
|
5215 |
|
5216 |
|
5217 | if (boundariesElement === 'viewport') {
|
5218 | boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition);
|
5219 | } else {
|
5220 |
|
5221 | var boundariesNode = void 0;
|
5222 | if (boundariesElement === 'scrollParent') {
|
5223 | boundariesNode = getScrollParent(getParentNode(reference));
|
5224 | if (boundariesNode.nodeName === 'BODY') {
|
5225 | boundariesNode = popper.ownerDocument.documentElement;
|
5226 | }
|
5227 | } else if (boundariesElement === 'window') {
|
5228 | boundariesNode = popper.ownerDocument.documentElement;
|
5229 | } else {
|
5230 | boundariesNode = boundariesElement;
|
5231 | }
|
5232 |
|
5233 | var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent, fixedPosition);
|
5234 |
|
5235 |
|
5236 | if (boundariesNode.nodeName === 'HTML' && !isFixed(offsetParent)) {
|
5237 | var _getWindowSizes = getWindowSizes(popper.ownerDocument),
|
5238 | height = _getWindowSizes.height,
|
5239 | width = _getWindowSizes.width;
|
5240 |
|
5241 | boundaries.top += offsets.top - offsets.marginTop;
|
5242 | boundaries.bottom = height + offsets.top;
|
5243 | boundaries.left += offsets.left - offsets.marginLeft;
|
5244 | boundaries.right = width + offsets.left;
|
5245 | } else {
|
5246 |
|
5247 | boundaries = offsets;
|
5248 | }
|
5249 | }
|
5250 |
|
5251 |
|
5252 | padding = padding || 0;
|
5253 | var isPaddingNumber = typeof padding === 'number';
|
5254 | boundaries.left += isPaddingNumber ? padding : padding.left || 0;
|
5255 | boundaries.top += isPaddingNumber ? padding : padding.top || 0;
|
5256 | boundaries.right -= isPaddingNumber ? padding : padding.right || 0;
|
5257 | boundaries.bottom -= isPaddingNumber ? padding : padding.bottom || 0;
|
5258 |
|
5259 | return boundaries;
|
5260 | }
|
5261 |
|
5262 | function getArea(_ref) {
|
5263 | var width = _ref.width,
|
5264 | height = _ref.height;
|
5265 |
|
5266 | return width * height;
|
5267 | }
|
5268 |
|
5269 | |
5270 |
|
5271 |
|
5272 |
|
5273 |
|
5274 |
|
5275 |
|
5276 |
|
5277 |
|
5278 | function computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) {
|
5279 | var padding = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
|
5280 |
|
5281 | if (placement.indexOf('auto') === -1) {
|
5282 | return placement;
|
5283 | }
|
5284 |
|
5285 | var boundaries = getBoundaries(popper, reference, padding, boundariesElement);
|
5286 |
|
5287 | var rects = {
|
5288 | top: {
|
5289 | width: boundaries.width,
|
5290 | height: refRect.top - boundaries.top
|
5291 | },
|
5292 | right: {
|
5293 | width: boundaries.right - refRect.right,
|
5294 | height: boundaries.height
|
5295 | },
|
5296 | bottom: {
|
5297 | width: boundaries.width,
|
5298 | height: boundaries.bottom - refRect.bottom
|
5299 | },
|
5300 | left: {
|
5301 | width: refRect.left - boundaries.left,
|
5302 | height: boundaries.height
|
5303 | }
|
5304 | };
|
5305 |
|
5306 | var sortedAreas = Object.keys(rects).map(function (key) {
|
5307 | return _extends$1({
|
5308 | key: key
|
5309 | }, rects[key], {
|
5310 | area: getArea(rects[key])
|
5311 | });
|
5312 | }).sort(function (a, b) {
|
5313 | return b.area - a.area;
|
5314 | });
|
5315 |
|
5316 | var filteredAreas = sortedAreas.filter(function (_ref2) {
|
5317 | var width = _ref2.width,
|
5318 | height = _ref2.height;
|
5319 | return width >= popper.clientWidth && height >= popper.clientHeight;
|
5320 | });
|
5321 |
|
5322 | var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key;
|
5323 |
|
5324 | var variation = placement.split('-')[1];
|
5325 |
|
5326 | return computedPlacement + (variation ? '-' + variation : '');
|
5327 | }
|
5328 |
|
5329 | |
5330 |
|
5331 |
|
5332 |
|
5333 |
|
5334 |
|
5335 |
|
5336 |
|
5337 |
|
5338 |
|
5339 | function getReferenceOffsets(state, popper, reference) {
|
5340 | var fixedPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
5341 |
|
5342 | var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
|
5343 | return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition);
|
5344 | }
|
5345 |
|
5346 | |
5347 |
|
5348 |
|
5349 |
|
5350 |
|
5351 |
|
5352 |
|
5353 | function getOuterSizes(element) {
|
5354 | var window = element.ownerDocument.defaultView;
|
5355 | var styles = window.getComputedStyle(element);
|
5356 | var x = parseFloat(styles.marginTop || 0) + parseFloat(styles.marginBottom || 0);
|
5357 | var y = parseFloat(styles.marginLeft || 0) + parseFloat(styles.marginRight || 0);
|
5358 | var result = {
|
5359 | width: element.offsetWidth + y,
|
5360 | height: element.offsetHeight + x
|
5361 | };
|
5362 | return result;
|
5363 | }
|
5364 |
|
5365 | |
5366 |
|
5367 |
|
5368 |
|
5369 |
|
5370 |
|
5371 |
|
5372 | function getOppositePlacement(placement) {
|
5373 | var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
|
5374 | return placement.replace(/left|right|bottom|top/g, function (matched) {
|
5375 | return hash[matched];
|
5376 | });
|
5377 | }
|
5378 |
|
5379 | |
5380 |
|
5381 |
|
5382 |
|
5383 |
|
5384 |
|
5385 |
|
5386 |
|
5387 |
|
5388 |
|
5389 | function getPopperOffsets(popper, referenceOffsets, placement) {
|
5390 | placement = placement.split('-')[0];
|
5391 |
|
5392 |
|
5393 | var popperRect = getOuterSizes(popper);
|
5394 |
|
5395 |
|
5396 | var popperOffsets = {
|
5397 | width: popperRect.width,
|
5398 | height: popperRect.height
|
5399 | };
|
5400 |
|
5401 |
|
5402 | var isHoriz = ['right', 'left'].indexOf(placement) !== -1;
|
5403 | var mainSide = isHoriz ? 'top' : 'left';
|
5404 | var secondarySide = isHoriz ? 'left' : 'top';
|
5405 | var measurement = isHoriz ? 'height' : 'width';
|
5406 | var secondaryMeasurement = !isHoriz ? 'height' : 'width';
|
5407 |
|
5408 | popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2;
|
5409 | if (placement === secondarySide) {
|
5410 | popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement];
|
5411 | } else {
|
5412 | popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement(secondarySide)];
|
5413 | }
|
5414 |
|
5415 | return popperOffsets;
|
5416 | }
|
5417 |
|
5418 | |
5419 |
|
5420 |
|
5421 |
|
5422 |
|
5423 |
|
5424 |
|
5425 |
|
5426 |
|
5427 | function find(arr, check) {
|
5428 |
|
5429 | if (Array.prototype.find) {
|
5430 | return arr.find(check);
|
5431 | }
|
5432 |
|
5433 |
|
5434 | return arr.filter(check)[0];
|
5435 | }
|
5436 |
|
5437 | |
5438 |
|
5439 |
|
5440 |
|
5441 |
|
5442 |
|
5443 |
|
5444 |
|
5445 |
|
5446 | function findIndex(arr, prop, value) {
|
5447 |
|
5448 | if (Array.prototype.findIndex) {
|
5449 | return arr.findIndex(function (cur) {
|
5450 | return cur[prop] === value;
|
5451 | });
|
5452 | }
|
5453 |
|
5454 |
|
5455 | var match = find(arr, function (obj) {
|
5456 | return obj[prop] === value;
|
5457 | });
|
5458 | return arr.indexOf(match);
|
5459 | }
|
5460 |
|
5461 | |
5462 |
|
5463 |
|
5464 |
|
5465 |
|
5466 |
|
5467 |
|
5468 |
|
5469 |
|
5470 |
|
5471 | function runModifiers(modifiers, data, ends) {
|
5472 | var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends));
|
5473 |
|
5474 | modifiersToRun.forEach(function (modifier) {
|
5475 | if (modifier['function']) {
|
5476 |
|
5477 | console.warn('`modifier.function` is deprecated, use `modifier.fn`!');
|
5478 | }
|
5479 | var fn = modifier['function'] || modifier.fn;
|
5480 | if (modifier.enabled && isFunction$2(fn)) {
|
5481 |
|
5482 |
|
5483 |
|
5484 | data.offsets.popper = getClientRect(data.offsets.popper);
|
5485 | data.offsets.reference = getClientRect(data.offsets.reference);
|
5486 |
|
5487 | data = fn(data, modifier);
|
5488 | }
|
5489 | });
|
5490 |
|
5491 | return data;
|
5492 | }
|
5493 |
|
5494 | |
5495 |
|
5496 |
|
5497 |
|
5498 |
|
5499 |
|
5500 |
|
5501 | function update() {
|
5502 |
|
5503 | if (this.state.isDestroyed) {
|
5504 | return;
|
5505 | }
|
5506 |
|
5507 | var data = {
|
5508 | instance: this,
|
5509 | styles: {},
|
5510 | arrowStyles: {},
|
5511 | attributes: {},
|
5512 | flipped: false,
|
5513 | offsets: {}
|
5514 | };
|
5515 |
|
5516 |
|
5517 | data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference, this.options.positionFixed);
|
5518 |
|
5519 |
|
5520 |
|
5521 |
|
5522 | data.placement = computeAutoPlacement(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding);
|
5523 |
|
5524 |
|
5525 | data.originalPlacement = data.placement;
|
5526 |
|
5527 | data.positionFixed = this.options.positionFixed;
|
5528 |
|
5529 |
|
5530 | data.offsets.popper = getPopperOffsets(this.popper, data.offsets.reference, data.placement);
|
5531 |
|
5532 | data.offsets.popper.position = this.options.positionFixed ? 'fixed' : 'absolute';
|
5533 |
|
5534 |
|
5535 | data = runModifiers(this.modifiers, data);
|
5536 |
|
5537 |
|
5538 |
|
5539 | if (!this.state.isCreated) {
|
5540 | this.state.isCreated = true;
|
5541 | this.options.onCreate(data);
|
5542 | } else {
|
5543 | this.options.onUpdate(data);
|
5544 | }
|
5545 | }
|
5546 |
|
5547 | |
5548 |
|
5549 |
|
5550 |
|
5551 |
|
5552 |
|
5553 | function isModifierEnabled(modifiers, modifierName) {
|
5554 | return modifiers.some(function (_ref) {
|
5555 | var name = _ref.name,
|
5556 | enabled = _ref.enabled;
|
5557 | return enabled && name === modifierName;
|
5558 | });
|
5559 | }
|
5560 |
|
5561 | |
5562 |
|
5563 |
|
5564 |
|
5565 |
|
5566 |
|
5567 |
|
5568 | function getSupportedPropertyName(property) {
|
5569 | var prefixes = [false, 'ms', 'Webkit', 'Moz', 'O'];
|
5570 | var upperProp = property.charAt(0).toUpperCase() + property.slice(1);
|
5571 |
|
5572 | for (var i = 0; i < prefixes.length; i++) {
|
5573 | var prefix = prefixes[i];
|
5574 | var toCheck = prefix ? '' + prefix + upperProp : property;
|
5575 | if (typeof document.body.style[toCheck] !== 'undefined') {
|
5576 | return toCheck;
|
5577 | }
|
5578 | }
|
5579 | return null;
|
5580 | }
|
5581 |
|
5582 | |
5583 |
|
5584 |
|
5585 |
|
5586 |
|
5587 | function destroy() {
|
5588 | this.state.isDestroyed = true;
|
5589 |
|
5590 |
|
5591 | if (isModifierEnabled(this.modifiers, 'applyStyle')) {
|
5592 | this.popper.removeAttribute('x-placement');
|
5593 | this.popper.style.position = '';
|
5594 | this.popper.style.top = '';
|
5595 | this.popper.style.left = '';
|
5596 | this.popper.style.right = '';
|
5597 | this.popper.style.bottom = '';
|
5598 | this.popper.style.willChange = '';
|
5599 | this.popper.style[getSupportedPropertyName('transform')] = '';
|
5600 | }
|
5601 |
|
5602 | this.disableEventListeners();
|
5603 |
|
5604 |
|
5605 |
|
5606 | if (this.options.removeOnDestroy) {
|
5607 | this.popper.parentNode.removeChild(this.popper);
|
5608 | }
|
5609 | return this;
|
5610 | }
|
5611 |
|
5612 | |
5613 |
|
5614 |
|
5615 |
|
5616 |
|
5617 | function getWindow(element) {
|
5618 | var ownerDocument = element.ownerDocument;
|
5619 | return ownerDocument ? ownerDocument.defaultView : window;
|
5620 | }
|
5621 |
|
5622 | function attachToScrollParents(scrollParent, event, callback, scrollParents) {
|
5623 | var isBody = scrollParent.nodeName === 'BODY';
|
5624 | var target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent;
|
5625 | target.addEventListener(event, callback, { passive: true });
|
5626 |
|
5627 | if (!isBody) {
|
5628 | attachToScrollParents(getScrollParent(target.parentNode), event, callback, scrollParents);
|
5629 | }
|
5630 | scrollParents.push(target);
|
5631 | }
|
5632 |
|
5633 | |
5634 |
|
5635 |
|
5636 |
|
5637 |
|
5638 |
|
5639 | function setupEventListeners(reference, options, state, updateBound) {
|
5640 |
|
5641 | state.updateBound = updateBound;
|
5642 | getWindow(reference).addEventListener('resize', state.updateBound, { passive: true });
|
5643 |
|
5644 |
|
5645 | var scrollElement = getScrollParent(reference);
|
5646 | attachToScrollParents(scrollElement, 'scroll', state.updateBound, state.scrollParents);
|
5647 | state.scrollElement = scrollElement;
|
5648 | state.eventsEnabled = true;
|
5649 |
|
5650 | return state;
|
5651 | }
|
5652 |
|
5653 | |
5654 |
|
5655 |
|
5656 |
|
5657 |
|
5658 |
|
5659 | function enableEventListeners() {
|
5660 | if (!this.state.eventsEnabled) {
|
5661 | this.state = setupEventListeners(this.reference, this.options, this.state, this.scheduleUpdate);
|
5662 | }
|
5663 | }
|
5664 |
|
5665 | |
5666 |
|
5667 |
|
5668 |
|
5669 |
|
5670 |
|
5671 | function removeEventListeners(reference, state) {
|
5672 |
|
5673 | getWindow(reference).removeEventListener('resize', state.updateBound);
|
5674 |
|
5675 |
|
5676 | state.scrollParents.forEach(function (target) {
|
5677 | target.removeEventListener('scroll', state.updateBound);
|
5678 | });
|
5679 |
|
5680 |
|
5681 | state.updateBound = null;
|
5682 | state.scrollParents = [];
|
5683 | state.scrollElement = null;
|
5684 | state.eventsEnabled = false;
|
5685 | return state;
|
5686 | }
|
5687 |
|
5688 | |
5689 |
|
5690 |
|
5691 |
|
5692 |
|
5693 |
|
5694 |
|
5695 | function disableEventListeners() {
|
5696 | if (this.state.eventsEnabled) {
|
5697 | cancelAnimationFrame(this.scheduleUpdate);
|
5698 | this.state = removeEventListeners(this.reference, this.state);
|
5699 | }
|
5700 | }
|
5701 |
|
5702 | |
5703 |
|
5704 |
|
5705 |
|
5706 |
|
5707 |
|
5708 |
|
5709 | function isNumeric(n) {
|
5710 | return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
|
5711 | }
|
5712 |
|
5713 | |
5714 |
|
5715 |
|
5716 |
|
5717 |
|
5718 |
|
5719 |
|
5720 |
|
5721 | function setStyles(element, styles) {
|
5722 | Object.keys(styles).forEach(function (prop) {
|
5723 | var unit = '';
|
5724 |
|
5725 | if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && isNumeric(styles[prop])) {
|
5726 | unit = 'px';
|
5727 | }
|
5728 | element.style[prop] = styles[prop] + unit;
|
5729 | });
|
5730 | }
|
5731 |
|
5732 | |
5733 |
|
5734 |
|
5735 |
|
5736 |
|
5737 |
|
5738 |
|
5739 |
|
5740 | function setAttributes(element, attributes) {
|
5741 | Object.keys(attributes).forEach(function (prop) {
|
5742 | var value = attributes[prop];
|
5743 | if (value !== false) {
|
5744 | element.setAttribute(prop, attributes[prop]);
|
5745 | } else {
|
5746 | element.removeAttribute(prop);
|
5747 | }
|
5748 | });
|
5749 | }
|
5750 |
|
5751 | |
5752 |
|
5753 |
|
5754 |
|
5755 |
|
5756 |
|
5757 |
|
5758 |
|
5759 |
|
5760 | function applyStyle(data) {
|
5761 |
|
5762 |
|
5763 |
|
5764 |
|
5765 | setStyles(data.instance.popper, data.styles);
|
5766 |
|
5767 |
|
5768 |
|
5769 | setAttributes(data.instance.popper, data.attributes);
|
5770 |
|
5771 |
|
5772 | if (data.arrowElement && Object.keys(data.arrowStyles).length) {
|
5773 | setStyles(data.arrowElement, data.arrowStyles);
|
5774 | }
|
5775 |
|
5776 | return data;
|
5777 | }
|
5778 |
|
5779 | |
5780 |
|
5781 |
|
5782 |
|
5783 |
|
5784 |
|
5785 |
|
5786 |
|
5787 |
|
5788 |
|
5789 | function applyStyleOnLoad(reference, popper, options, modifierOptions, state) {
|
5790 |
|
5791 | var referenceOffsets = getReferenceOffsets(state, popper, reference, options.positionFixed);
|
5792 |
|
5793 |
|
5794 |
|
5795 |
|
5796 | var placement = computeAutoPlacement(options.placement, referenceOffsets, popper, reference, options.modifiers.flip.boundariesElement, options.modifiers.flip.padding);
|
5797 |
|
5798 | popper.setAttribute('x-placement', placement);
|
5799 |
|
5800 |
|
5801 |
|
5802 | setStyles(popper, { position: options.positionFixed ? 'fixed' : 'absolute' });
|
5803 |
|
5804 | return options;
|
5805 | }
|
5806 |
|
5807 | |
5808 |
|
5809 |
|
5810 |
|
5811 |
|
5812 |
|
5813 |
|
5814 |
|
5815 |
|
5816 |
|
5817 |
|
5818 |
|
5819 |
|
5820 |
|
5821 |
|
5822 |
|
5823 |
|
5824 |
|
5825 |
|
5826 | function getRoundedOffsets(data, shouldRound) {
|
5827 | var _data$offsets = data.offsets,
|
5828 | popper = _data$offsets.popper,
|
5829 | reference = _data$offsets.reference;
|
5830 | var round = Math.round,
|
5831 | floor = Math.floor;
|
5832 |
|
5833 | var noRound = function noRound(v) {
|
5834 | return v;
|
5835 | };
|
5836 |
|
5837 | var referenceWidth = round(reference.width);
|
5838 | var popperWidth = round(popper.width);
|
5839 |
|
5840 | var isVertical = ['left', 'right'].indexOf(data.placement) !== -1;
|
5841 | var isVariation = data.placement.indexOf('-') !== -1;
|
5842 | var sameWidthParity = referenceWidth % 2 === popperWidth % 2;
|
5843 | var bothOddWidth = referenceWidth % 2 === 1 && popperWidth % 2 === 1;
|
5844 |
|
5845 | var horizontalToInteger = !shouldRound ? noRound : isVertical || isVariation || sameWidthParity ? round : floor;
|
5846 | var verticalToInteger = !shouldRound ? noRound : round;
|
5847 |
|
5848 | return {
|
5849 | left: horizontalToInteger(bothOddWidth && !isVariation && shouldRound ? popper.left - 1 : popper.left),
|
5850 | top: verticalToInteger(popper.top),
|
5851 | bottom: verticalToInteger(popper.bottom),
|
5852 | right: horizontalToInteger(popper.right)
|
5853 | };
|
5854 | }
|
5855 |
|
5856 | var isFirefox = isBrowser && /Firefox/i.test(navigator.userAgent);
|
5857 |
|
5858 | |
5859 |
|
5860 |
|
5861 |
|
5862 |
|
5863 |
|
5864 |
|
5865 | function computeStyle(data, options) {
|
5866 | var x = options.x,
|
5867 | y = options.y;
|
5868 | var popper = data.offsets.popper;
|
5869 |
|
5870 |
|
5871 |
|
5872 | var legacyGpuAccelerationOption = find(data.instance.modifiers, function (modifier) {
|
5873 | return modifier.name === 'applyStyle';
|
5874 | }).gpuAcceleration;
|
5875 | if (legacyGpuAccelerationOption !== undefined) {
|
5876 | console.warn('WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!');
|
5877 | }
|
5878 | var gpuAcceleration = legacyGpuAccelerationOption !== undefined ? legacyGpuAccelerationOption : options.gpuAcceleration;
|
5879 |
|
5880 | var offsetParent = getOffsetParent(data.instance.popper);
|
5881 | var offsetParentRect = getBoundingClientRect(offsetParent);
|
5882 |
|
5883 |
|
5884 | var styles = {
|
5885 | position: popper.position
|
5886 | };
|
5887 |
|
5888 | var offsets = getRoundedOffsets(data, window.devicePixelRatio < 2 || !isFirefox);
|
5889 |
|
5890 | var sideA = x === 'bottom' ? 'top' : 'bottom';
|
5891 | var sideB = y === 'right' ? 'left' : 'right';
|
5892 |
|
5893 |
|
5894 |
|
5895 |
|
5896 | var prefixedProperty = getSupportedPropertyName('transform');
|
5897 |
|
5898 |
|
5899 |
|
5900 |
|
5901 |
|
5902 |
|
5903 |
|
5904 |
|
5905 |
|
5906 |
|
5907 | var left = void 0,
|
5908 | top = void 0;
|
5909 | if (sideA === 'bottom') {
|
5910 |
|
5911 |
|
5912 | if (offsetParent.nodeName === 'HTML') {
|
5913 | top = -offsetParent.clientHeight + offsets.bottom;
|
5914 | } else {
|
5915 | top = -offsetParentRect.height + offsets.bottom;
|
5916 | }
|
5917 | } else {
|
5918 | top = offsets.top;
|
5919 | }
|
5920 | if (sideB === 'right') {
|
5921 | if (offsetParent.nodeName === 'HTML') {
|
5922 | left = -offsetParent.clientWidth + offsets.right;
|
5923 | } else {
|
5924 | left = -offsetParentRect.width + offsets.right;
|
5925 | }
|
5926 | } else {
|
5927 | left = offsets.left;
|
5928 | }
|
5929 | if (gpuAcceleration && prefixedProperty) {
|
5930 | styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';
|
5931 | styles[sideA] = 0;
|
5932 | styles[sideB] = 0;
|
5933 | styles.willChange = 'transform';
|
5934 | } else {
|
5935 |
|
5936 | var invertTop = sideA === 'bottom' ? -1 : 1;
|
5937 | var invertLeft = sideB === 'right' ? -1 : 1;
|
5938 | styles[sideA] = top * invertTop;
|
5939 | styles[sideB] = left * invertLeft;
|
5940 | styles.willChange = sideA + ', ' + sideB;
|
5941 | }
|
5942 |
|
5943 |
|
5944 | var attributes = {
|
5945 | 'x-placement': data.placement
|
5946 | };
|
5947 |
|
5948 |
|
5949 | data.attributes = _extends$1({}, attributes, data.attributes);
|
5950 | data.styles = _extends$1({}, styles, data.styles);
|
5951 | data.arrowStyles = _extends$1({}, data.offsets.arrow, data.arrowStyles);
|
5952 |
|
5953 | return data;
|
5954 | }
|
5955 |
|
5956 | |
5957 |
|
5958 |
|
5959 |
|
5960 |
|
5961 |
|
5962 |
|
5963 |
|
5964 |
|
5965 |
|
5966 | function isModifierRequired(modifiers, requestingName, requestedName) {
|
5967 | var requesting = find(modifiers, function (_ref) {
|
5968 | var name = _ref.name;
|
5969 | return name === requestingName;
|
5970 | });
|
5971 |
|
5972 | var isRequired = !!requesting && modifiers.some(function (modifier) {
|
5973 | return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order;
|
5974 | });
|
5975 |
|
5976 | if (!isRequired) {
|
5977 | var _requesting = '`' + requestingName + '`';
|
5978 | var requested = '`' + requestedName + '`';
|
5979 | console.warn(requested + ' modifier is required by ' + _requesting + ' modifier in order to work, be sure to include it before ' + _requesting + '!');
|
5980 | }
|
5981 | return isRequired;
|
5982 | }
|
5983 |
|
5984 | |
5985 |
|
5986 |
|
5987 |
|
5988 |
|
5989 |
|
5990 |
|
5991 | function arrow(data, options) {
|
5992 | var _data$offsets$arrow;
|
5993 |
|
5994 |
|
5995 | if (!isModifierRequired(data.instance.modifiers, 'arrow', 'keepTogether')) {
|
5996 | return data;
|
5997 | }
|
5998 |
|
5999 | var arrowElement = options.element;
|
6000 |
|
6001 |
|
6002 | if (typeof arrowElement === 'string') {
|
6003 | arrowElement = data.instance.popper.querySelector(arrowElement);
|
6004 |
|
6005 |
|
6006 | if (!arrowElement) {
|
6007 | return data;
|
6008 | }
|
6009 | } else {
|
6010 |
|
6011 |
|
6012 | if (!data.instance.popper.contains(arrowElement)) {
|
6013 | console.warn('WARNING: `arrow.element` must be child of its popper element!');
|
6014 | return data;
|
6015 | }
|
6016 | }
|
6017 |
|
6018 | var placement = data.placement.split('-')[0];
|
6019 | var _data$offsets = data.offsets,
|
6020 | popper = _data$offsets.popper,
|
6021 | reference = _data$offsets.reference;
|
6022 |
|
6023 | var isVertical = ['left', 'right'].indexOf(placement) !== -1;
|
6024 |
|
6025 | var len = isVertical ? 'height' : 'width';
|
6026 | var sideCapitalized = isVertical ? 'Top' : 'Left';
|
6027 | var side = sideCapitalized.toLowerCase();
|
6028 | var altSide = isVertical ? 'left' : 'top';
|
6029 | var opSide = isVertical ? 'bottom' : 'right';
|
6030 | var arrowElementSize = getOuterSizes(arrowElement)[len];
|
6031 |
|
6032 |
|
6033 |
|
6034 |
|
6035 |
|
6036 |
|
6037 |
|
6038 | if (reference[opSide] - arrowElementSize < popper[side]) {
|
6039 | data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowElementSize);
|
6040 | }
|
6041 |
|
6042 | if (reference[side] + arrowElementSize > popper[opSide]) {
|
6043 | data.offsets.popper[side] += reference[side] + arrowElementSize - popper[opSide];
|
6044 | }
|
6045 | data.offsets.popper = getClientRect(data.offsets.popper);
|
6046 |
|
6047 |
|
6048 | var center = reference[side] + reference[len] / 2 - arrowElementSize / 2;
|
6049 |
|
6050 |
|
6051 |
|
6052 | var css = getStyleComputedProperty(data.instance.popper);
|
6053 | var popperMarginSide = parseFloat(css['margin' + sideCapitalized]);
|
6054 | var popperBorderSide = parseFloat(css['border' + sideCapitalized + 'Width']);
|
6055 | var sideValue = center - data.offsets.popper[side] - popperMarginSide - popperBorderSide;
|
6056 |
|
6057 |
|
6058 | sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0);
|
6059 |
|
6060 | data.arrowElement = arrowElement;
|
6061 | data.offsets.arrow = (_data$offsets$arrow = {}, defineProperty$3(_data$offsets$arrow, side, Math.round(sideValue)), defineProperty$3(_data$offsets$arrow, altSide, ''), _data$offsets$arrow);
|
6062 |
|
6063 | return data;
|
6064 | }
|
6065 |
|
6066 | |
6067 |
|
6068 |
|
6069 |
|
6070 |
|
6071 |
|
6072 |
|
6073 | function getOppositeVariation(variation) {
|
6074 | if (variation === 'end') {
|
6075 | return 'start';
|
6076 | } else if (variation === 'start') {
|
6077 | return 'end';
|
6078 | }
|
6079 | return variation;
|
6080 | }
|
6081 |
|
6082 | |
6083 |
|
6084 |
|
6085 |
|
6086 |
|
6087 |
|
6088 |
|
6089 |
|
6090 |
|
6091 |
|
6092 |
|
6093 |
|
6094 |
|
6095 |
|
6096 |
|
6097 |
|
6098 |
|
6099 |
|
6100 |
|
6101 |
|
6102 |
|
6103 |
|
6104 |
|
6105 |
|
6106 |
|
6107 |
|
6108 |
|
6109 |
|
6110 |
|
6111 |
|
6112 |
|
6113 | var placements = ['auto-start', 'auto', 'auto-end', 'top-start', 'top', 'top-end', 'right-start', 'right', 'right-end', 'bottom-end', 'bottom', 'bottom-start', 'left-end', 'left', 'left-start'];
|
6114 |
|
6115 |
|
6116 | var validPlacements = placements.slice(3);
|
6117 |
|
6118 | |
6119 |
|
6120 |
|
6121 |
|
6122 |
|
6123 |
|
6124 |
|
6125 |
|
6126 |
|
6127 |
|
6128 | function clockwise(placement) {
|
6129 | var counter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
6130 |
|
6131 | var index = validPlacements.indexOf(placement);
|
6132 | var arr = validPlacements.slice(index + 1).concat(validPlacements.slice(0, index));
|
6133 | return counter ? arr.reverse() : arr;
|
6134 | }
|
6135 |
|
6136 | var BEHAVIORS = {
|
6137 | FLIP: 'flip',
|
6138 | CLOCKWISE: 'clockwise',
|
6139 | COUNTERCLOCKWISE: 'counterclockwise'
|
6140 | };
|
6141 |
|
6142 | |
6143 |
|
6144 |
|
6145 |
|
6146 |
|
6147 |
|
6148 |
|
6149 | function flip(data, options) {
|
6150 |
|
6151 | if (isModifierEnabled(data.instance.modifiers, 'inner')) {
|
6152 | return data;
|
6153 | }
|
6154 |
|
6155 | if (data.flipped && data.placement === data.originalPlacement) {
|
6156 |
|
6157 | return data;
|
6158 | }
|
6159 |
|
6160 | var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, options.boundariesElement, data.positionFixed);
|
6161 |
|
6162 | var placement = data.placement.split('-')[0];
|
6163 | var placementOpposite = getOppositePlacement(placement);
|
6164 | var variation = data.placement.split('-')[1] || '';
|
6165 |
|
6166 | var flipOrder = [];
|
6167 |
|
6168 | switch (options.behavior) {
|
6169 | case BEHAVIORS.FLIP:
|
6170 | flipOrder = [placement, placementOpposite];
|
6171 | break;
|
6172 | case BEHAVIORS.CLOCKWISE:
|
6173 | flipOrder = clockwise(placement);
|
6174 | break;
|
6175 | case BEHAVIORS.COUNTERCLOCKWISE:
|
6176 | flipOrder = clockwise(placement, true);
|
6177 | break;
|
6178 | default:
|
6179 | flipOrder = options.behavior;
|
6180 | }
|
6181 |
|
6182 | flipOrder.forEach(function (step, index) {
|
6183 | if (placement !== step || flipOrder.length === index + 1) {
|
6184 | return data;
|
6185 | }
|
6186 |
|
6187 | placement = data.placement.split('-')[0];
|
6188 | placementOpposite = getOppositePlacement(placement);
|
6189 |
|
6190 | var popperOffsets = data.offsets.popper;
|
6191 | var refOffsets = data.offsets.reference;
|
6192 |
|
6193 |
|
6194 | var floor = Math.floor;
|
6195 | var overlapsRef = placement === 'left' && floor(popperOffsets.right) > floor(refOffsets.left) || placement === 'right' && floor(popperOffsets.left) < floor(refOffsets.right) || placement === 'top' && floor(popperOffsets.bottom) > floor(refOffsets.top) || placement === 'bottom' && floor(popperOffsets.top) < floor(refOffsets.bottom);
|
6196 |
|
6197 | var overflowsLeft = floor(popperOffsets.left) < floor(boundaries.left);
|
6198 | var overflowsRight = floor(popperOffsets.right) > floor(boundaries.right);
|
6199 | var overflowsTop = floor(popperOffsets.top) < floor(boundaries.top);
|
6200 | var overflowsBottom = floor(popperOffsets.bottom) > floor(boundaries.bottom);
|
6201 |
|
6202 | var overflowsBoundaries = placement === 'left' && overflowsLeft || placement === 'right' && overflowsRight || placement === 'top' && overflowsTop || placement === 'bottom' && overflowsBottom;
|
6203 |
|
6204 |
|
6205 | var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
|
6206 |
|
6207 |
|
6208 | var flippedVariationByRef = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom);
|
6209 |
|
6210 |
|
6211 | var flippedVariationByContent = !!options.flipVariationsByContent && (isVertical && variation === 'start' && overflowsRight || isVertical && variation === 'end' && overflowsLeft || !isVertical && variation === 'start' && overflowsBottom || !isVertical && variation === 'end' && overflowsTop);
|
6212 |
|
6213 | var flippedVariation = flippedVariationByRef || flippedVariationByContent;
|
6214 |
|
6215 | if (overlapsRef || overflowsBoundaries || flippedVariation) {
|
6216 |
|
6217 | data.flipped = true;
|
6218 |
|
6219 | if (overlapsRef || overflowsBoundaries) {
|
6220 | placement = flipOrder[index + 1];
|
6221 | }
|
6222 |
|
6223 | if (flippedVariation) {
|
6224 | variation = getOppositeVariation(variation);
|
6225 | }
|
6226 |
|
6227 | data.placement = placement + (variation ? '-' + variation : '');
|
6228 |
|
6229 |
|
6230 |
|
6231 | data.offsets.popper = _extends$1({}, data.offsets.popper, getPopperOffsets(data.instance.popper, data.offsets.reference, data.placement));
|
6232 |
|
6233 | data = runModifiers(data.instance.modifiers, data, 'flip');
|
6234 | }
|
6235 | });
|
6236 | return data;
|
6237 | }
|
6238 |
|
6239 | |
6240 |
|
6241 |
|
6242 |
|
6243 |
|
6244 |
|
6245 |
|
6246 | function keepTogether(data) {
|
6247 | var _data$offsets = data.offsets,
|
6248 | popper = _data$offsets.popper,
|
6249 | reference = _data$offsets.reference;
|
6250 |
|
6251 | var placement = data.placement.split('-')[0];
|
6252 | var floor = Math.floor;
|
6253 | var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
|
6254 | var side = isVertical ? 'right' : 'bottom';
|
6255 | var opSide = isVertical ? 'left' : 'top';
|
6256 | var measurement = isVertical ? 'width' : 'height';
|
6257 |
|
6258 | if (popper[side] < floor(reference[opSide])) {
|
6259 | data.offsets.popper[opSide] = floor(reference[opSide]) - popper[measurement];
|
6260 | }
|
6261 | if (popper[opSide] > floor(reference[side])) {
|
6262 | data.offsets.popper[opSide] = floor(reference[side]);
|
6263 | }
|
6264 |
|
6265 | return data;
|
6266 | }
|
6267 |
|
6268 | |
6269 |
|
6270 |
|
6271 |
|
6272 |
|
6273 |
|
6274 |
|
6275 |
|
6276 |
|
6277 |
|
6278 |
|
6279 |
|
6280 | function toValue(str, measurement, popperOffsets, referenceOffsets) {
|
6281 |
|
6282 | var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/);
|
6283 | var value = +split[1];
|
6284 | var unit = split[2];
|
6285 |
|
6286 |
|
6287 | if (!value) {
|
6288 | return str;
|
6289 | }
|
6290 |
|
6291 | if (unit.indexOf('%') === 0) {
|
6292 | var element = void 0;
|
6293 | switch (unit) {
|
6294 | case '%p':
|
6295 | element = popperOffsets;
|
6296 | break;
|
6297 | case '%':
|
6298 | case '%r':
|
6299 | default:
|
6300 | element = referenceOffsets;
|
6301 | }
|
6302 |
|
6303 | var rect = getClientRect(element);
|
6304 | return rect[measurement] / 100 * value;
|
6305 | } else if (unit === 'vh' || unit === 'vw') {
|
6306 |
|
6307 | var size = void 0;
|
6308 | if (unit === 'vh') {
|
6309 | size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
|
6310 | } else {
|
6311 | size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
|
6312 | }
|
6313 | return size / 100 * value;
|
6314 | } else {
|
6315 |
|
6316 |
|
6317 | return value;
|
6318 | }
|
6319 | }
|
6320 |
|
6321 | |
6322 |
|
6323 |
|
6324 |
|
6325 |
|
6326 |
|
6327 |
|
6328 |
|
6329 |
|
6330 |
|
6331 |
|
6332 | function parseOffset(offset, popperOffsets, referenceOffsets, basePlacement) {
|
6333 | var offsets = [0, 0];
|
6334 |
|
6335 |
|
6336 |
|
6337 |
|
6338 | var useHeight = ['right', 'left'].indexOf(basePlacement) !== -1;
|
6339 |
|
6340 |
|
6341 |
|
6342 | var fragments = offset.split(/(\+|\-)/).map(function (frag) {
|
6343 | return frag.trim();
|
6344 | });
|
6345 |
|
6346 |
|
6347 |
|
6348 | var divider = fragments.indexOf(find(fragments, function (frag) {
|
6349 | return frag.search(/,|\s/) !== -1;
|
6350 | }));
|
6351 |
|
6352 | if (fragments[divider] && fragments[divider].indexOf(',') === -1) {
|
6353 | console.warn('Offsets separated by white space(s) are deprecated, use a comma (,) instead.');
|
6354 | }
|
6355 |
|
6356 |
|
6357 |
|
6358 | var splitRegex = /\s*,\s*|\s+/;
|
6359 | var ops = divider !== -1 ? [fragments.slice(0, divider).concat([fragments[divider].split(splitRegex)[0]]), [fragments[divider].split(splitRegex)[1]].concat(fragments.slice(divider + 1))] : [fragments];
|
6360 |
|
6361 |
|
6362 | ops = ops.map(function (op, index) {
|
6363 |
|
6364 | var measurement = (index === 1 ? !useHeight : useHeight) ? 'height' : 'width';
|
6365 | var mergeWithPrevious = false;
|
6366 | return op
|
6367 |
|
6368 |
|
6369 | .reduce(function (a, b) {
|
6370 | if (a[a.length - 1] === '' && ['+', '-'].indexOf(b) !== -1) {
|
6371 | a[a.length - 1] = b;
|
6372 | mergeWithPrevious = true;
|
6373 | return a;
|
6374 | } else if (mergeWithPrevious) {
|
6375 | a[a.length - 1] += b;
|
6376 | mergeWithPrevious = false;
|
6377 | return a;
|
6378 | } else {
|
6379 | return a.concat(b);
|
6380 | }
|
6381 | }, [])
|
6382 |
|
6383 | .map(function (str) {
|
6384 | return toValue(str, measurement, popperOffsets, referenceOffsets);
|
6385 | });
|
6386 | });
|
6387 |
|
6388 |
|
6389 | ops.forEach(function (op, index) {
|
6390 | op.forEach(function (frag, index2) {
|
6391 | if (isNumeric(frag)) {
|
6392 | offsets[index] += frag * (op[index2 - 1] === '-' ? -1 : 1);
|
6393 | }
|
6394 | });
|
6395 | });
|
6396 | return offsets;
|
6397 | }
|
6398 |
|
6399 | |
6400 |
|
6401 |
|
6402 |
|
6403 |
|
6404 |
|
6405 |
|
6406 |
|
6407 |
|
6408 | function offset(data, _ref) {
|
6409 | var offset = _ref.offset;
|
6410 | var placement = data.placement,
|
6411 | _data$offsets = data.offsets,
|
6412 | popper = _data$offsets.popper,
|
6413 | reference = _data$offsets.reference;
|
6414 |
|
6415 | var basePlacement = placement.split('-')[0];
|
6416 |
|
6417 | var offsets = void 0;
|
6418 | if (isNumeric(+offset)) {
|
6419 | offsets = [+offset, 0];
|
6420 | } else {
|
6421 | offsets = parseOffset(offset, popper, reference, basePlacement);
|
6422 | }
|
6423 |
|
6424 | if (basePlacement === 'left') {
|
6425 | popper.top += offsets[0];
|
6426 | popper.left -= offsets[1];
|
6427 | } else if (basePlacement === 'right') {
|
6428 | popper.top += offsets[0];
|
6429 | popper.left += offsets[1];
|
6430 | } else if (basePlacement === 'top') {
|
6431 | popper.left += offsets[0];
|
6432 | popper.top -= offsets[1];
|
6433 | } else if (basePlacement === 'bottom') {
|
6434 | popper.left += offsets[0];
|
6435 | popper.top += offsets[1];
|
6436 | }
|
6437 |
|
6438 | data.popper = popper;
|
6439 | return data;
|
6440 | }
|
6441 |
|
6442 | |
6443 |
|
6444 |
|
6445 |
|
6446 |
|
6447 |
|
6448 |
|
6449 | function preventOverflow(data, options) {
|
6450 | var boundariesElement = options.boundariesElement || getOffsetParent(data.instance.popper);
|
6451 |
|
6452 |
|
6453 |
|
6454 |
|
6455 | if (data.instance.reference === boundariesElement) {
|
6456 | boundariesElement = getOffsetParent(boundariesElement);
|
6457 | }
|
6458 |
|
6459 |
|
6460 |
|
6461 |
|
6462 | var transformProp = getSupportedPropertyName('transform');
|
6463 | var popperStyles = data.instance.popper.style;
|
6464 | var top = popperStyles.top,
|
6465 | left = popperStyles.left,
|
6466 | transform = popperStyles[transformProp];
|
6467 |
|
6468 | popperStyles.top = '';
|
6469 | popperStyles.left = '';
|
6470 | popperStyles[transformProp] = '';
|
6471 |
|
6472 | var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, boundariesElement, data.positionFixed);
|
6473 |
|
6474 |
|
6475 |
|
6476 | popperStyles.top = top;
|
6477 | popperStyles.left = left;
|
6478 | popperStyles[transformProp] = transform;
|
6479 |
|
6480 | options.boundaries = boundaries;
|
6481 |
|
6482 | var order = options.priority;
|
6483 | var popper = data.offsets.popper;
|
6484 |
|
6485 | var check = {
|
6486 | primary: function primary(placement) {
|
6487 | var value = popper[placement];
|
6488 | if (popper[placement] < boundaries[placement] && !options.escapeWithReference) {
|
6489 | value = Math.max(popper[placement], boundaries[placement]);
|
6490 | }
|
6491 | return defineProperty$3({}, placement, value);
|
6492 | },
|
6493 | secondary: function secondary(placement) {
|
6494 | var mainSide = placement === 'right' ? 'left' : 'top';
|
6495 | var value = popper[mainSide];
|
6496 | if (popper[placement] > boundaries[placement] && !options.escapeWithReference) {
|
6497 | value = Math.min(popper[mainSide], boundaries[placement] - (placement === 'right' ? popper.width : popper.height));
|
6498 | }
|
6499 | return defineProperty$3({}, mainSide, value);
|
6500 | }
|
6501 | };
|
6502 |
|
6503 | order.forEach(function (placement) {
|
6504 | var side = ['left', 'top'].indexOf(placement) !== -1 ? 'primary' : 'secondary';
|
6505 | popper = _extends$1({}, popper, check[side](placement));
|
6506 | });
|
6507 |
|
6508 | data.offsets.popper = popper;
|
6509 |
|
6510 | return data;
|
6511 | }
|
6512 |
|
6513 | |
6514 |
|
6515 |
|
6516 |
|
6517 |
|
6518 |
|
6519 |
|
6520 | function shift(data) {
|
6521 | var placement = data.placement;
|
6522 | var basePlacement = placement.split('-')[0];
|
6523 | var shiftvariation = placement.split('-')[1];
|
6524 |
|
6525 |
|
6526 | if (shiftvariation) {
|
6527 | var _data$offsets = data.offsets,
|
6528 | reference = _data$offsets.reference,
|
6529 | popper = _data$offsets.popper;
|
6530 |
|
6531 | var isVertical = ['bottom', 'top'].indexOf(basePlacement) !== -1;
|
6532 | var side = isVertical ? 'left' : 'top';
|
6533 | var measurement = isVertical ? 'width' : 'height';
|
6534 |
|
6535 | var shiftOffsets = {
|
6536 | start: defineProperty$3({}, side, reference[side]),
|
6537 | end: defineProperty$3({}, side, reference[side] + reference[measurement] - popper[measurement])
|
6538 | };
|
6539 |
|
6540 | data.offsets.popper = _extends$1({}, popper, shiftOffsets[shiftvariation]);
|
6541 | }
|
6542 |
|
6543 | return data;
|
6544 | }
|
6545 |
|
6546 | |
6547 |
|
6548 |
|
6549 |
|
6550 |
|
6551 |
|
6552 |
|
6553 | function hide(data) {
|
6554 | if (!isModifierRequired(data.instance.modifiers, 'hide', 'preventOverflow')) {
|
6555 | return data;
|
6556 | }
|
6557 |
|
6558 | var refRect = data.offsets.reference;
|
6559 | var bound = find(data.instance.modifiers, function (modifier) {
|
6560 | return modifier.name === 'preventOverflow';
|
6561 | }).boundaries;
|
6562 |
|
6563 | if (refRect.bottom < bound.top || refRect.left > bound.right || refRect.top > bound.bottom || refRect.right < bound.left) {
|
6564 |
|
6565 | if (data.hide === true) {
|
6566 | return data;
|
6567 | }
|
6568 |
|
6569 | data.hide = true;
|
6570 | data.attributes['x-out-of-boundaries'] = '';
|
6571 | } else {
|
6572 |
|
6573 | if (data.hide === false) {
|
6574 | return data;
|
6575 | }
|
6576 |
|
6577 | data.hide = false;
|
6578 | data.attributes['x-out-of-boundaries'] = false;
|
6579 | }
|
6580 |
|
6581 | return data;
|
6582 | }
|
6583 |
|
6584 | |
6585 |
|
6586 |
|
6587 |
|
6588 |
|
6589 |
|
6590 |
|
6591 | function inner(data) {
|
6592 | var placement = data.placement;
|
6593 | var basePlacement = placement.split('-')[0];
|
6594 | var _data$offsets = data.offsets,
|
6595 | popper = _data$offsets.popper,
|
6596 | reference = _data$offsets.reference;
|
6597 |
|
6598 | var isHoriz = ['left', 'right'].indexOf(basePlacement) !== -1;
|
6599 |
|
6600 | var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1;
|
6601 |
|
6602 | popper[isHoriz ? 'left' : 'top'] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0);
|
6603 |
|
6604 | data.placement = getOppositePlacement(placement);
|
6605 | data.offsets.popper = getClientRect(popper);
|
6606 |
|
6607 | return data;
|
6608 | }
|
6609 |
|
6610 | |
6611 |
|
6612 |
|
6613 |
|
6614 |
|
6615 |
|
6616 |
|
6617 |
|
6618 |
|
6619 |
|
6620 |
|
6621 |
|
6622 | |
6623 |
|
6624 |
|
6625 |
|
6626 |
|
6627 |
|
6628 |
|
6629 |
|
6630 |
|
6631 | var modifiers = {
|
6632 | |
6633 |
|
6634 |
|
6635 |
|
6636 |
|
6637 |
|
6638 |
|
6639 |
|
6640 | shift: {
|
6641 |
|
6642 | order: 100,
|
6643 |
|
6644 | enabled: true,
|
6645 |
|
6646 | fn: shift
|
6647 | },
|
6648 |
|
6649 | |
6650 |
|
6651 |
|
6652 |
|
6653 |
|
6654 |
|
6655 |
|
6656 |
|
6657 |
|
6658 |
|
6659 |
|
6660 |
|
6661 |
|
6662 |
|
6663 |
|
6664 |
|
6665 |
|
6666 |
|
6667 |
|
6668 |
|
6669 |
|
6670 |
|
6671 |
|
6672 |
|
6673 |
|
6674 |
|
6675 |
|
6676 |
|
6677 |
|
6678 |
|
6679 |
|
6680 |
|
6681 |
|
6682 |
|
6683 |
|
6684 |
|
6685 |
|
6686 |
|
6687 | offset: {
|
6688 |
|
6689 | order: 200,
|
6690 |
|
6691 | enabled: true,
|
6692 |
|
6693 | fn: offset,
|
6694 | |
6695 |
|
6696 |
|
6697 | offset: 0
|
6698 | },
|
6699 |
|
6700 | |
6701 |
|
6702 |
|
6703 |
|
6704 |
|
6705 |
|
6706 |
|
6707 |
|
6708 |
|
6709 |
|
6710 |
|
6711 |
|
6712 |
|
6713 |
|
6714 |
|
6715 |
|
6716 |
|
6717 | preventOverflow: {
|
6718 |
|
6719 | order: 300,
|
6720 |
|
6721 | enabled: true,
|
6722 |
|
6723 | fn: preventOverflow,
|
6724 | |
6725 |
|
6726 |
|
6727 |
|
6728 |
|
6729 | priority: ['left', 'right', 'top', 'bottom'],
|
6730 | |
6731 |
|
6732 |
|
6733 |
|
6734 |
|
6735 |
|
6736 | padding: 5,
|
6737 | |
6738 |
|
6739 |
|
6740 |
|
6741 |
|
6742 | boundariesElement: 'scrollParent'
|
6743 | },
|
6744 |
|
6745 | |
6746 |
|
6747 |
|
6748 |
|
6749 |
|
6750 |
|
6751 |
|
6752 |
|
6753 |
|
6754 | keepTogether: {
|
6755 |
|
6756 | order: 400,
|
6757 |
|
6758 | enabled: true,
|
6759 |
|
6760 | fn: keepTogether
|
6761 | },
|
6762 |
|
6763 | |
6764 |
|
6765 |
|
6766 |
|
6767 |
|
6768 |
|
6769 |
|
6770 |
|
6771 |
|
6772 |
|
6773 | arrow: {
|
6774 |
|
6775 | order: 500,
|
6776 |
|
6777 | enabled: true,
|
6778 |
|
6779 | fn: arrow,
|
6780 |
|
6781 | element: '[x-arrow]'
|
6782 | },
|
6783 |
|
6784 | |
6785 |
|
6786 |
|
6787 |
|
6788 |
|
6789 |
|
6790 |
|
6791 |
|
6792 |
|
6793 |
|
6794 |
|
6795 | flip: {
|
6796 |
|
6797 | order: 600,
|
6798 |
|
6799 | enabled: true,
|
6800 |
|
6801 | fn: flip,
|
6802 | |
6803 |
|
6804 |
|
6805 |
|
6806 |
|
6807 |
|
6808 | behavior: 'flip',
|
6809 | |
6810 |
|
6811 |
|
6812 |
|
6813 | padding: 5,
|
6814 | |
6815 |
|
6816 |
|
6817 |
|
6818 |
|
6819 |
|
6820 | boundariesElement: 'viewport',
|
6821 | |
6822 |
|
6823 |
|
6824 |
|
6825 |
|
6826 |
|
6827 |
|
6828 | flipVariations: false,
|
6829 | |
6830 |
|
6831 |
|
6832 |
|
6833 |
|
6834 |
|
6835 |
|
6836 | flipVariationsByContent: false
|
6837 | },
|
6838 |
|
6839 | |
6840 |
|
6841 |
|
6842 |
|
6843 |
|
6844 |
|
6845 |
|
6846 | inner: {
|
6847 |
|
6848 | order: 700,
|
6849 |
|
6850 | enabled: false,
|
6851 |
|
6852 | fn: inner
|
6853 | },
|
6854 |
|
6855 | |
6856 |
|
6857 |
|
6858 |
|
6859 |
|
6860 |
|
6861 |
|
6862 |
|
6863 |
|
6864 |
|
6865 | hide: {
|
6866 |
|
6867 | order: 800,
|
6868 |
|
6869 | enabled: true,
|
6870 |
|
6871 | fn: hide
|
6872 | },
|
6873 |
|
6874 | |
6875 |
|
6876 |
|
6877 |
|
6878 |
|
6879 |
|
6880 |
|
6881 |
|
6882 |
|
6883 |
|
6884 |
|
6885 |
|
6886 |
|
6887 |
|
6888 |
|
6889 | computeStyle: {
|
6890 |
|
6891 | order: 850,
|
6892 |
|
6893 | enabled: true,
|
6894 |
|
6895 | fn: computeStyle,
|
6896 | |
6897 |
|
6898 |
|
6899 |
|
6900 |
|
6901 | gpuAcceleration: true,
|
6902 | |
6903 |
|
6904 |
|
6905 |
|
6906 |
|
6907 | x: 'bottom',
|
6908 | |
6909 |
|
6910 |
|
6911 |
|
6912 |
|
6913 | y: 'right'
|
6914 | },
|
6915 |
|
6916 | |
6917 |
|
6918 |
|
6919 |
|
6920 |
|
6921 |
|
6922 |
|
6923 |
|
6924 |
|
6925 |
|
6926 |
|
6927 |
|
6928 |
|
6929 |
|
6930 |
|
6931 | applyStyle: {
|
6932 |
|
6933 | order: 900,
|
6934 |
|
6935 | enabled: true,
|
6936 |
|
6937 | fn: applyStyle,
|
6938 |
|
6939 | onLoad: applyStyleOnLoad,
|
6940 | |
6941 |
|
6942 |
|
6943 |
|
6944 |
|
6945 |
|
6946 | gpuAcceleration: undefined
|
6947 | }
|
6948 | };
|
6949 |
|
6950 | |
6951 |
|
6952 |
|
6953 |
|
6954 |
|
6955 |
|
6956 |
|
6957 |
|
6958 |
|
6959 |
|
6960 |
|
6961 |
|
6962 |
|
6963 |
|
6964 |
|
6965 |
|
6966 |
|
6967 |
|
6968 |
|
6969 | |
6970 |
|
6971 |
|
6972 |
|
6973 |
|
6974 |
|
6975 |
|
6976 |
|
6977 |
|
6978 |
|
6979 |
|
6980 |
|
6981 |
|
6982 |
|
6983 |
|
6984 |
|
6985 | var Defaults = {
|
6986 | |
6987 |
|
6988 |
|
6989 |
|
6990 | placement: 'bottom',
|
6991 |
|
6992 | |
6993 |
|
6994 |
|
6995 |
|
6996 | positionFixed: false,
|
6997 |
|
6998 | |
6999 |
|
7000 |
|
7001 |
|
7002 | eventsEnabled: true,
|
7003 |
|
7004 | |
7005 |
|
7006 |
|
7007 |
|
7008 |
|
7009 | removeOnDestroy: false,
|
7010 |
|
7011 | |
7012 |
|
7013 |
|
7014 |
|
7015 |
|
7016 |
|
7017 | onCreate: function onCreate() {},
|
7018 |
|
7019 | |
7020 |
|
7021 |
|
7022 |
|
7023 |
|
7024 |
|
7025 |
|
7026 |
|
7027 | onUpdate: function onUpdate() {},
|
7028 |
|
7029 | |
7030 |
|
7031 |
|
7032 |
|
7033 |
|
7034 | modifiers: modifiers
|
7035 | };
|
7036 |
|
7037 | |
7038 |
|
7039 |
|
7040 |
|
7041 |
|
7042 | |
7043 |
|
7044 |
|
7045 |
|
7046 |
|
7047 |
|
7048 |
|
7049 | var Popper = function () {
|
7050 | |
7051 |
|
7052 |
|
7053 |
|
7054 |
|
7055 |
|
7056 |
|
7057 |
|
7058 | function Popper(reference, popper) {
|
7059 | var _this = this;
|
7060 |
|
7061 | var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
7062 | classCallCheck(this, Popper);
|
7063 |
|
7064 | this.scheduleUpdate = function () {
|
7065 | return requestAnimationFrame(_this.update);
|
7066 | };
|
7067 |
|
7068 |
|
7069 | this.update = debounce$1(this.update.bind(this));
|
7070 |
|
7071 |
|
7072 | this.options = _extends$1({}, Popper.Defaults, options);
|
7073 |
|
7074 |
|
7075 | this.state = {
|
7076 | isDestroyed: false,
|
7077 | isCreated: false,
|
7078 | scrollParents: []
|
7079 | };
|
7080 |
|
7081 |
|
7082 | this.reference = reference && reference.jquery ? reference[0] : reference;
|
7083 | this.popper = popper && popper.jquery ? popper[0] : popper;
|
7084 |
|
7085 |
|
7086 | this.options.modifiers = {};
|
7087 | Object.keys(_extends$1({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) {
|
7088 | _this.options.modifiers[name] = _extends$1({}, Popper.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {});
|
7089 | });
|
7090 |
|
7091 |
|
7092 | this.modifiers = Object.keys(this.options.modifiers).map(function (name) {
|
7093 | return _extends$1({
|
7094 | name: name
|
7095 | }, _this.options.modifiers[name]);
|
7096 | })
|
7097 |
|
7098 | .sort(function (a, b) {
|
7099 | return a.order - b.order;
|
7100 | });
|
7101 |
|
7102 |
|
7103 |
|
7104 |
|
7105 |
|
7106 | this.modifiers.forEach(function (modifierOptions) {
|
7107 | if (modifierOptions.enabled && isFunction$2(modifierOptions.onLoad)) {
|
7108 | modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state);
|
7109 | }
|
7110 | });
|
7111 |
|
7112 |
|
7113 | this.update();
|
7114 |
|
7115 | var eventsEnabled = this.options.eventsEnabled;
|
7116 | if (eventsEnabled) {
|
7117 |
|
7118 | this.enableEventListeners();
|
7119 | }
|
7120 |
|
7121 | this.state.eventsEnabled = eventsEnabled;
|
7122 | }
|
7123 |
|
7124 |
|
7125 |
|
7126 |
|
7127 |
|
7128 | createClass(Popper, [{
|
7129 | key: 'update',
|
7130 | value: function update$$1() {
|
7131 | return update.call(this);
|
7132 | }
|
7133 | }, {
|
7134 | key: 'destroy',
|
7135 | value: function destroy$$1() {
|
7136 | return destroy.call(this);
|
7137 | }
|
7138 | }, {
|
7139 | key: 'enableEventListeners',
|
7140 | value: function enableEventListeners$$1() {
|
7141 | return enableEventListeners.call(this);
|
7142 | }
|
7143 | }, {
|
7144 | key: 'disableEventListeners',
|
7145 | value: function disableEventListeners$$1() {
|
7146 | return disableEventListeners.call(this);
|
7147 | }
|
7148 |
|
7149 | |
7150 |
|
7151 |
|
7152 |
|
7153 |
|
7154 |
|
7155 |
|
7156 | |
7157 |
|
7158 |
|
7159 |
|
7160 |
|
7161 |
|
7162 |
|
7163 |
|
7164 |
|
7165 |
|
7166 |
|
7167 |
|
7168 |
|
7169 |
|
7170 |
|
7171 |
|
7172 |
|
7173 | }]);
|
7174 | return Popper;
|
7175 | }();
|
7176 |
|
7177 | |
7178 |
|
7179 |
|
7180 |
|
7181 |
|
7182 |
|
7183 |
|
7184 |
|
7185 |
|
7186 |
|
7187 |
|
7188 |
|
7189 |
|
7190 |
|
7191 |
|
7192 |
|
7193 |
|
7194 |
|
7195 |
|
7196 |
|
7197 |
|
7198 | Popper.Utils = (typeof window !== 'undefined' ? window : global).PopperUtils;
|
7199 | Popper.placements = placements;
|
7200 | Popper.Defaults = Defaults;
|
7201 |
|
7202 | var key = '__global_unique_id__';
|
7203 |
|
7204 | var gud = function() {
|
7205 | return commonjsGlobal[key] = (commonjsGlobal[key] || 0) + 1;
|
7206 | };
|
7207 |
|
7208 | var implementation$4 = createCommonjsModule(function (module, exports) {
|
7209 |
|
7210 | exports.__esModule = true;
|
7211 |
|
7212 |
|
7213 |
|
7214 | var _react2 = _interopRequireDefault(React__default);
|
7215 |
|
7216 |
|
7217 |
|
7218 | var _propTypes2 = _interopRequireDefault(propTypes);
|
7219 |
|
7220 |
|
7221 |
|
7222 | var _gud2 = _interopRequireDefault(gud);
|
7223 |
|
7224 |
|
7225 |
|
7226 | var _warning2 = _interopRequireDefault(warning_1);
|
7227 |
|
7228 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
7229 |
|
7230 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
7231 |
|
7232 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
7233 |
|
7234 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
7235 |
|
7236 | var MAX_SIGNED_31_BIT_INT = 1073741823;
|
7237 |
|
7238 |
|
7239 |
|
7240 | function objectIs(x, y) {
|
7241 | if (x === y) {
|
7242 | return x !== 0 || 1 / x === 1 / y;
|
7243 | } else {
|
7244 | return x !== x && y !== y;
|
7245 | }
|
7246 | }
|
7247 |
|
7248 | function createEventEmitter(value) {
|
7249 | var handlers = [];
|
7250 | return {
|
7251 | on: function on(handler) {
|
7252 | handlers.push(handler);
|
7253 | },
|
7254 | off: function off(handler) {
|
7255 | handlers = handlers.filter(function (h) {
|
7256 | return h !== handler;
|
7257 | });
|
7258 | },
|
7259 | get: function get() {
|
7260 | return value;
|
7261 | },
|
7262 | set: function set(newValue, changedBits) {
|
7263 | value = newValue;
|
7264 | handlers.forEach(function (handler) {
|
7265 | return handler(value, changedBits);
|
7266 | });
|
7267 | }
|
7268 | };
|
7269 | }
|
7270 |
|
7271 | function onlyChild(children) {
|
7272 | return Array.isArray(children) ? children[0] : children;
|
7273 | }
|
7274 |
|
7275 | function createReactContext(defaultValue, calculateChangedBits) {
|
7276 | var _Provider$childContex, _Consumer$contextType;
|
7277 |
|
7278 | var contextProp = '__create-react-context-' + (0, _gud2.default)() + '__';
|
7279 |
|
7280 | var Provider = function (_Component) {
|
7281 | _inherits(Provider, _Component);
|
7282 |
|
7283 | function Provider() {
|
7284 | var _temp, _this, _ret;
|
7285 |
|
7286 | _classCallCheck(this, Provider);
|
7287 |
|
7288 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
7289 | args[_key] = arguments[_key];
|
7290 | }
|
7291 |
|
7292 | return _ret = (_temp = (_this = _possibleConstructorReturn(this, _Component.call.apply(_Component, [this].concat(args))), _this), _this.emitter = createEventEmitter(_this.props.value), _temp), _possibleConstructorReturn(_this, _ret);
|
7293 | }
|
7294 |
|
7295 | Provider.prototype.getChildContext = function getChildContext() {
|
7296 | var _ref;
|
7297 |
|
7298 | return _ref = {}, _ref[contextProp] = this.emitter, _ref;
|
7299 | };
|
7300 |
|
7301 | Provider.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
|
7302 | if (this.props.value !== nextProps.value) {
|
7303 | var oldValue = this.props.value;
|
7304 | var newValue = nextProps.value;
|
7305 | var changedBits = void 0;
|
7306 |
|
7307 | if (objectIs(oldValue, newValue)) {
|
7308 | changedBits = 0;
|
7309 | } else {
|
7310 | changedBits = typeof calculateChangedBits === 'function' ? calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT;
|
7311 | {
|
7312 | (0, _warning2.default)((changedBits & MAX_SIGNED_31_BIT_INT) === changedBits, 'calculateChangedBits: Expected the return value to be a ' + '31-bit integer. Instead received: %s', changedBits);
|
7313 | }
|
7314 |
|
7315 | changedBits |= 0;
|
7316 |
|
7317 | if (changedBits !== 0) {
|
7318 | this.emitter.set(nextProps.value, changedBits);
|
7319 | }
|
7320 | }
|
7321 | }
|
7322 | };
|
7323 |
|
7324 | Provider.prototype.render = function render() {
|
7325 | return this.props.children;
|
7326 | };
|
7327 |
|
7328 | return Provider;
|
7329 | }(React__default.Component);
|
7330 |
|
7331 | Provider.childContextTypes = (_Provider$childContex = {}, _Provider$childContex[contextProp] = _propTypes2.default.object.isRequired, _Provider$childContex);
|
7332 |
|
7333 | var Consumer = function (_Component2) {
|
7334 | _inherits(Consumer, _Component2);
|
7335 |
|
7336 | function Consumer() {
|
7337 | var _temp2, _this2, _ret2;
|
7338 |
|
7339 | _classCallCheck(this, Consumer);
|
7340 |
|
7341 | for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
7342 | args[_key2] = arguments[_key2];
|
7343 | }
|
7344 |
|
7345 | return _ret2 = (_temp2 = (_this2 = _possibleConstructorReturn(this, _Component2.call.apply(_Component2, [this].concat(args))), _this2), _this2.state = {
|
7346 | value: _this2.getValue()
|
7347 | }, _this2.onUpdate = function (newValue, changedBits) {
|
7348 | var observedBits = _this2.observedBits | 0;
|
7349 | if ((observedBits & changedBits) !== 0) {
|
7350 | _this2.setState({ value: _this2.getValue() });
|
7351 | }
|
7352 | }, _temp2), _possibleConstructorReturn(_this2, _ret2);
|
7353 | }
|
7354 |
|
7355 | Consumer.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
|
7356 | var observedBits = nextProps.observedBits;
|
7357 |
|
7358 | this.observedBits = observedBits === undefined || observedBits === null ? MAX_SIGNED_31_BIT_INT
|
7359 | : observedBits;
|
7360 | };
|
7361 |
|
7362 | Consumer.prototype.componentDidMount = function componentDidMount() {
|
7363 | if (this.context[contextProp]) {
|
7364 | this.context[contextProp].on(this.onUpdate);
|
7365 | }
|
7366 | var observedBits = this.props.observedBits;
|
7367 |
|
7368 | this.observedBits = observedBits === undefined || observedBits === null ? MAX_SIGNED_31_BIT_INT
|
7369 | : observedBits;
|
7370 | };
|
7371 |
|
7372 | Consumer.prototype.componentWillUnmount = function componentWillUnmount() {
|
7373 | if (this.context[contextProp]) {
|
7374 | this.context[contextProp].off(this.onUpdate);
|
7375 | }
|
7376 | };
|
7377 |
|
7378 | Consumer.prototype.getValue = function getValue() {
|
7379 | if (this.context[contextProp]) {
|
7380 | return this.context[contextProp].get();
|
7381 | } else {
|
7382 | return defaultValue;
|
7383 | }
|
7384 | };
|
7385 |
|
7386 | Consumer.prototype.render = function render() {
|
7387 | return onlyChild(this.props.children)(this.state.value);
|
7388 | };
|
7389 |
|
7390 | return Consumer;
|
7391 | }(React__default.Component);
|
7392 |
|
7393 | Consumer.contextTypes = (_Consumer$contextType = {}, _Consumer$contextType[contextProp] = _propTypes2.default.object, _Consumer$contextType);
|
7394 |
|
7395 |
|
7396 | return {
|
7397 | Provider: Provider,
|
7398 | Consumer: Consumer
|
7399 | };
|
7400 | }
|
7401 |
|
7402 | exports.default = createReactContext;
|
7403 | module.exports = exports['default'];
|
7404 | });
|
7405 |
|
7406 | var lib = createCommonjsModule(function (module, exports) {
|
7407 |
|
7408 | exports.__esModule = true;
|
7409 |
|
7410 |
|
7411 |
|
7412 | var _react2 = _interopRequireDefault(React__default);
|
7413 |
|
7414 |
|
7415 |
|
7416 | var _implementation2 = _interopRequireDefault(implementation$4);
|
7417 |
|
7418 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
7419 |
|
7420 | exports.default = _react2.default.createContext || _implementation2.default;
|
7421 | module.exports = exports['default'];
|
7422 | });
|
7423 |
|
7424 | var ManagerReferenceNodeContext = lib();
|
7425 | var ManagerReferenceNodeSetterContext = lib();
|
7426 |
|
7427 | |
7428 |
|
7429 |
|
7430 |
|
7431 | var unwrapArray = function unwrapArray(arg) {
|
7432 | return Array.isArray(arg) ? arg[0] : arg;
|
7433 | };
|
7434 | |
7435 |
|
7436 |
|
7437 |
|
7438 |
|
7439 | var safeInvoke = function safeInvoke(fn) {
|
7440 | if (typeof fn === "function") {
|
7441 | for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
7442 | args[_key - 1] = arguments[_key];
|
7443 | }
|
7444 |
|
7445 | return fn.apply(void 0, args);
|
7446 | }
|
7447 | };
|
7448 | |
7449 |
|
7450 |
|
7451 |
|
7452 |
|
7453 | var shallowEqual = function shallowEqual(objA, objB) {
|
7454 | var aKeys = Object.keys(objA);
|
7455 | var bKeys = Object.keys(objB);
|
7456 |
|
7457 | if (bKeys.length !== aKeys.length) {
|
7458 | return false;
|
7459 | }
|
7460 |
|
7461 | for (var i = 0; i < bKeys.length; i++) {
|
7462 | var key = aKeys[i];
|
7463 |
|
7464 | if (objA[key] !== objB[key]) {
|
7465 | return false;
|
7466 | }
|
7467 | }
|
7468 |
|
7469 | return true;
|
7470 | };
|
7471 | |
7472 |
|
7473 |
|
7474 |
|
7475 | var setRef = function setRef(ref, node) {
|
7476 |
|
7477 | if (typeof ref === "function") {
|
7478 | return safeInvoke(ref, node);
|
7479 | }
|
7480 | else if (ref != null) {
|
7481 | ref.current = node;
|
7482 | }
|
7483 | };
|
7484 |
|
7485 | var initialStyle = {
|
7486 | position: 'absolute',
|
7487 | top: 0,
|
7488 | left: 0,
|
7489 | opacity: 0,
|
7490 | pointerEvents: 'none'
|
7491 | };
|
7492 | var initialArrowStyle = {};
|
7493 | var InnerPopper =
|
7494 |
|
7495 | function (_React$Component) {
|
7496 | inheritsLoose(InnerPopper, _React$Component);
|
7497 |
|
7498 | function InnerPopper() {
|
7499 | var _this;
|
7500 |
|
7501 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
7502 | args[_key] = arguments[_key];
|
7503 | }
|
7504 |
|
7505 | _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
|
7506 |
|
7507 | defineProperty(assertThisInitialized(_this), "state", {
|
7508 | data: undefined,
|
7509 | placement: undefined
|
7510 | });
|
7511 |
|
7512 | defineProperty(assertThisInitialized(_this), "popperInstance", void 0);
|
7513 |
|
7514 | defineProperty(assertThisInitialized(_this), "popperNode", null);
|
7515 |
|
7516 | defineProperty(assertThisInitialized(_this), "arrowNode", null);
|
7517 |
|
7518 | defineProperty(assertThisInitialized(_this), "setPopperNode", function (popperNode) {
|
7519 | if (!popperNode || _this.popperNode === popperNode) return;
|
7520 | setRef(_this.props.innerRef, popperNode);
|
7521 | _this.popperNode = popperNode;
|
7522 |
|
7523 | _this.updatePopperInstance();
|
7524 | });
|
7525 |
|
7526 | defineProperty(assertThisInitialized(_this), "setArrowNode", function (arrowNode) {
|
7527 | _this.arrowNode = arrowNode;
|
7528 | });
|
7529 |
|
7530 | defineProperty(assertThisInitialized(_this), "updateStateModifier", {
|
7531 | enabled: true,
|
7532 | order: 900,
|
7533 | fn: function fn(data) {
|
7534 | var placement = data.placement;
|
7535 |
|
7536 | _this.setState({
|
7537 | data: data,
|
7538 | placement: placement
|
7539 | });
|
7540 |
|
7541 | return data;
|
7542 | }
|
7543 | });
|
7544 |
|
7545 | defineProperty(assertThisInitialized(_this), "getOptions", function () {
|
7546 | return {
|
7547 | placement: _this.props.placement,
|
7548 | eventsEnabled: _this.props.eventsEnabled,
|
7549 | positionFixed: _this.props.positionFixed,
|
7550 | modifiers: _extends_1({}, _this.props.modifiers, {
|
7551 | arrow: _extends_1({}, _this.props.modifiers && _this.props.modifiers.arrow, {
|
7552 | enabled: !!_this.arrowNode,
|
7553 | element: _this.arrowNode
|
7554 | }),
|
7555 | applyStyle: {
|
7556 | enabled: false
|
7557 | },
|
7558 | updateStateModifier: _this.updateStateModifier
|
7559 | })
|
7560 | };
|
7561 | });
|
7562 |
|
7563 | defineProperty(assertThisInitialized(_this), "getPopperStyle", function () {
|
7564 | return !_this.popperNode || !_this.state.data ? initialStyle : _extends_1({
|
7565 | position: _this.state.data.offsets.popper.position
|
7566 | }, _this.state.data.styles);
|
7567 | });
|
7568 |
|
7569 | defineProperty(assertThisInitialized(_this), "getPopperPlacement", function () {
|
7570 | return !_this.state.data ? undefined : _this.state.placement;
|
7571 | });
|
7572 |
|
7573 | defineProperty(assertThisInitialized(_this), "getArrowStyle", function () {
|
7574 | return !_this.arrowNode || !_this.state.data ? initialArrowStyle : _this.state.data.arrowStyles;
|
7575 | });
|
7576 |
|
7577 | defineProperty(assertThisInitialized(_this), "getOutOfBoundariesState", function () {
|
7578 | return _this.state.data ? _this.state.data.hide : undefined;
|
7579 | });
|
7580 |
|
7581 | defineProperty(assertThisInitialized(_this), "destroyPopperInstance", function () {
|
7582 | if (!_this.popperInstance) return;
|
7583 |
|
7584 | _this.popperInstance.destroy();
|
7585 |
|
7586 | _this.popperInstance = null;
|
7587 | });
|
7588 |
|
7589 | defineProperty(assertThisInitialized(_this), "updatePopperInstance", function () {
|
7590 | _this.destroyPopperInstance();
|
7591 |
|
7592 | var _assertThisInitialize = assertThisInitialized(_this),
|
7593 | popperNode = _assertThisInitialize.popperNode;
|
7594 |
|
7595 | var referenceElement = _this.props.referenceElement;
|
7596 | if (!referenceElement || !popperNode) return;
|
7597 | _this.popperInstance = new Popper(referenceElement, popperNode, _this.getOptions());
|
7598 | });
|
7599 |
|
7600 | defineProperty(assertThisInitialized(_this), "scheduleUpdate", function () {
|
7601 | if (_this.popperInstance) {
|
7602 | _this.popperInstance.scheduleUpdate();
|
7603 | }
|
7604 | });
|
7605 |
|
7606 | return _this;
|
7607 | }
|
7608 |
|
7609 | var _proto = InnerPopper.prototype;
|
7610 |
|
7611 | _proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
|
7612 |
|
7613 | if (this.props.placement !== prevProps.placement || this.props.referenceElement !== prevProps.referenceElement || this.props.positionFixed !== prevProps.positionFixed || !deepEqual_1(this.props.modifiers, prevProps.modifiers, {
|
7614 | strict: true
|
7615 | })) {
|
7616 |
|
7617 | {
|
7618 | if (this.props.modifiers !== prevProps.modifiers && this.props.modifiers != null && prevProps.modifiers != null && shallowEqual(this.props.modifiers, prevProps.modifiers)) {
|
7619 | console.warn("'modifiers' prop reference updated even though all values appear the same.\nConsider memoizing the 'modifiers' object to avoid needless rendering.");
|
7620 | }
|
7621 | }
|
7622 |
|
7623 | this.updatePopperInstance();
|
7624 | } else if (this.props.eventsEnabled !== prevProps.eventsEnabled && this.popperInstance) {
|
7625 | this.props.eventsEnabled ? this.popperInstance.enableEventListeners() : this.popperInstance.disableEventListeners();
|
7626 | }
|
7627 |
|
7628 |
|
7629 |
|
7630 |
|
7631 |
|
7632 | if (prevState.placement !== this.state.placement) {
|
7633 | this.scheduleUpdate();
|
7634 | }
|
7635 | };
|
7636 |
|
7637 | _proto.componentWillUnmount = function componentWillUnmount() {
|
7638 | setRef(this.props.innerRef, null);
|
7639 | this.destroyPopperInstance();
|
7640 | };
|
7641 |
|
7642 | _proto.render = function render() {
|
7643 | return unwrapArray(this.props.children)({
|
7644 | ref: this.setPopperNode,
|
7645 | style: this.getPopperStyle(),
|
7646 | placement: this.getPopperPlacement(),
|
7647 | outOfBoundaries: this.getOutOfBoundariesState(),
|
7648 | scheduleUpdate: this.scheduleUpdate,
|
7649 | arrowProps: {
|
7650 | ref: this.setArrowNode,
|
7651 | style: this.getArrowStyle()
|
7652 | }
|
7653 | });
|
7654 | };
|
7655 |
|
7656 | return InnerPopper;
|
7657 | }(React.Component);
|
7658 |
|
7659 | defineProperty(InnerPopper, "defaultProps", {
|
7660 | placement: 'bottom',
|
7661 | eventsEnabled: true,
|
7662 | referenceElement: undefined,
|
7663 | positionFixed: false
|
7664 | });
|
7665 | function Popper$1(_ref) {
|
7666 | var referenceElement = _ref.referenceElement,
|
7667 | props = objectWithoutPropertiesLoose(_ref, ["referenceElement"]);
|
7668 |
|
7669 | return React.createElement(ManagerReferenceNodeContext.Consumer, null, function (referenceNode) {
|
7670 | return React.createElement(InnerPopper, _extends_1({
|
7671 | referenceElement: referenceElement !== undefined ? referenceElement : referenceNode
|
7672 | }, props));
|
7673 | });
|
7674 | }
|
7675 |
|
7676 |
|
7677 |
|
7678 |
|
7679 | var SafeElement = typeof Element === 'undefined' ? function () {} : Element;
|
7680 | var propTypes$5 = {
|
7681 | |
7682 |
|
7683 |
|
7684 |
|
7685 |
|
7686 |
|
7687 | align: propTypes.oneOf(values(ALIGN)),
|
7688 | children: propTypes.func.isRequired,
|
7689 |
|
7690 | |
7691 |
|
7692 |
|
7693 | dropup: propTypes.bool,
|
7694 |
|
7695 | |
7696 |
|
7697 |
|
7698 |
|
7699 | flip: propTypes.bool,
|
7700 | isMenuShown: propTypes.bool,
|
7701 | positionFixed: propTypes.bool,
|
7702 | referenceElement: propTypes.instanceOf(SafeElement)
|
7703 | };
|
7704 | var defaultProps$4 = {
|
7705 | align: ALIGN.JUSTIFY,
|
7706 | dropup: false,
|
7707 | flip: false,
|
7708 | isMenuShown: false,
|
7709 | positionFixed: false
|
7710 | };
|
7711 |
|
7712 | function getModifiers(_ref) {
|
7713 | var align = _ref.align,
|
7714 | flip = _ref.flip;
|
7715 | return {
|
7716 | computeStyles: {
|
7717 | enabled: true,
|
7718 | fn: function fn(_ref2) {
|
7719 | var styles = _ref2.styles,
|
7720 | data = _objectWithoutPropertiesLoose(_ref2, ["styles"]);
|
7721 |
|
7722 | return _extends({}, data, {
|
7723 | styles: _extends({}, styles, {
|
7724 |
|
7725 |
|
7726 |
|
7727 | width: align !== ALIGN.RIGHT && align !== ALIGN.LEFT ?
|
7728 | data.offsets.reference.width : styles.width
|
7729 | })
|
7730 | });
|
7731 | }
|
7732 | },
|
7733 | flip: {
|
7734 | enabled: flip
|
7735 | },
|
7736 | preventOverflow: {
|
7737 | escapeWithReference: true
|
7738 | }
|
7739 | };
|
7740 | }
|
7741 |
|
7742 |
|
7743 | var PLACEMENT = {
|
7744 | bottom: {
|
7745 | end: 'bottom-end',
|
7746 | start: 'bottom-start'
|
7747 | },
|
7748 | top: {
|
7749 | end: 'top-end',
|
7750 | start: 'top-start'
|
7751 | }
|
7752 | };
|
7753 | function getPlacement(_ref3) {
|
7754 | var align = _ref3.align,
|
7755 | dropup = _ref3.dropup;
|
7756 | var x = align === ALIGN.RIGHT ? 'end' : 'start';
|
7757 | var y = dropup ? 'top' : 'bottom';
|
7758 | return PLACEMENT[y][x];
|
7759 | }
|
7760 |
|
7761 | var Overlay = function Overlay(props) {
|
7762 | var children = props.children,
|
7763 | isMenuShown = props.isMenuShown,
|
7764 | positionFixed = props.positionFixed,
|
7765 | referenceElement = props.referenceElement;
|
7766 |
|
7767 | if (!isMenuShown) {
|
7768 | return null;
|
7769 | }
|
7770 |
|
7771 | return React.createElement(Popper$1, {
|
7772 | modifiers: getModifiers(props),
|
7773 | placement: getPlacement(props),
|
7774 | positionFixed: positionFixed,
|
7775 | referenceElement: referenceElement
|
7776 | }, function (_ref4) {
|
7777 | var ref = _ref4.ref,
|
7778 | popperProps = _objectWithoutPropertiesLoose(_ref4, ["ref"]);
|
7779 |
|
7780 | return children(_extends({}, popperProps, {
|
7781 | innerRef: ref,
|
7782 | inputHeight: referenceElement ? referenceElement.offsetHeight : 0
|
7783 | }));
|
7784 | });
|
7785 | };
|
7786 |
|
7787 | Overlay.propTypes = propTypes$5;
|
7788 | Overlay.defaultProps = defaultProps$4;
|
7789 |
|
7790 | var propTypes$6 = {
|
7791 | onBlur: propTypes.func,
|
7792 | onClick: propTypes.func,
|
7793 | onFocus: propTypes.func,
|
7794 | onRemove: propTypes.func,
|
7795 | option: optionType.isRequired
|
7796 | };
|
7797 | var useToken = function useToken(_ref) {
|
7798 | var onBlur = _ref.onBlur,
|
7799 | onClick = _ref.onClick,
|
7800 | onFocus = _ref.onFocus,
|
7801 | onRemove = _ref.onRemove,
|
7802 | option = _ref.option,
|
7803 | props = _objectWithoutPropertiesLoose(_ref, ["onBlur", "onClick", "onFocus", "onRemove", "option"]);
|
7804 |
|
7805 | var _useState = React.useState(false),
|
7806 | active = _useState[0],
|
7807 | setActive = _useState[1];
|
7808 |
|
7809 | var _useState2 = React.useState(null),
|
7810 | rootElement = _useState2[0],
|
7811 | attachRef = _useState2[1];
|
7812 |
|
7813 | var handleActiveChange = function handleActiveChange(e, isActive, callback) {
|
7814 | e.stopPropagation();
|
7815 | setActive(isActive);
|
7816 | typeof callback === 'function' && callback(e);
|
7817 | };
|
7818 |
|
7819 | var handleBlur = function handleBlur(e) {
|
7820 | handleActiveChange(e, false, onBlur);
|
7821 | };
|
7822 |
|
7823 | var handleClick = function handleClick(e) {
|
7824 | handleActiveChange(e, true, onClick);
|
7825 | };
|
7826 |
|
7827 | var handleFocus = function handleFocus(e) {
|
7828 | handleActiveChange(e, true, onFocus);
|
7829 | };
|
7830 |
|
7831 | var handleRemove = function handleRemove() {
|
7832 | onRemove && onRemove(option);
|
7833 | };
|
7834 |
|
7835 | var handleKeyDown = function handleKeyDown(e) {
|
7836 | switch (e.keyCode) {
|
7837 | case BACKSPACE:
|
7838 | if (active) {
|
7839 |
|
7840 |
|
7841 | e.preventDefault();
|
7842 | handleRemove();
|
7843 | }
|
7844 |
|
7845 | break;
|
7846 | }
|
7847 | };
|
7848 |
|
7849 | useRootClose(rootElement, handleBlur, _extends({}, props, {
|
7850 | disabled: !active
|
7851 | }));
|
7852 | return _extends({}, props, {
|
7853 | active: active,
|
7854 | onBlur: handleBlur,
|
7855 | onClick: handleClick,
|
7856 | onFocus: handleFocus,
|
7857 | onKeyDown: handleKeyDown,
|
7858 | onRemove: isFunction(onRemove) ? handleRemove : undefined,
|
7859 | ref: attachRef
|
7860 | });
|
7861 | };
|
7862 | var withToken = function withToken(Component) {
|
7863 | var displayName = "withToken(" + getDisplayName(Component) + ")";
|
7864 |
|
7865 | var WrappedToken = function WrappedToken(props) {
|
7866 | return React__default.createElement(Component, useToken(props));
|
7867 | };
|
7868 |
|
7869 | WrappedToken.displayName = displayName;
|
7870 | WrappedToken.propTypes = propTypes$6;
|
7871 | return WrappedToken;
|
7872 | };
|
7873 | function tokenContainer(Component) {
|
7874 |
|
7875 | warn(false, 'The `tokenContainer` export is deprecated; use `withToken` instead.');
|
7876 |
|
7877 |
|
7878 | return withToken(Component);
|
7879 | }
|
7880 |
|
7881 | var InteractiveToken = React.forwardRef(function (_ref, ref) {
|
7882 | var active = _ref.active,
|
7883 | children = _ref.children,
|
7884 | className = _ref.className,
|
7885 | onRemove = _ref.onRemove,
|
7886 | tabIndex = _ref.tabIndex,
|
7887 | props = _objectWithoutPropertiesLoose(_ref, ["active", "children", "className", "onRemove", "tabIndex"]);
|
7888 |
|
7889 | return React__default.createElement("div", _extends({}, props, {
|
7890 | className: classnames('rbt-token', 'rbt-token-removeable', {
|
7891 | 'rbt-token-active': !!active
|
7892 | }, className),
|
7893 | ref: ref,
|
7894 | tabIndex: tabIndex || 0
|
7895 | }), children, React__default.createElement(ClearButton, {
|
7896 | className: "rbt-token-remove-button",
|
7897 | label: "Remove",
|
7898 | onClick: onRemove,
|
7899 | tabIndex: -1
|
7900 | }));
|
7901 | });
|
7902 |
|
7903 | var StaticToken = function StaticToken(_ref2) {
|
7904 | var children = _ref2.children,
|
7905 | className = _ref2.className,
|
7906 | disabled = _ref2.disabled,
|
7907 | href = _ref2.href;
|
7908 | var classnames$1 = classnames('rbt-token', {
|
7909 | 'rbt-token-disabled': disabled
|
7910 | }, className);
|
7911 |
|
7912 | if (href && !disabled) {
|
7913 | return React__default.createElement("a", {
|
7914 | className: classnames$1,
|
7915 | href: href
|
7916 | }, children);
|
7917 | }
|
7918 |
|
7919 | return React__default.createElement("div", {
|
7920 | className: classnames$1
|
7921 | }, children);
|
7922 | };
|
7923 | |
7924 |
|
7925 |
|
7926 |
|
7927 |
|
7928 |
|
7929 |
|
7930 |
|
7931 | var Token = React.forwardRef(function (props, ref) {
|
7932 | var disabled = props.disabled,
|
7933 | onRemove = props.onRemove,
|
7934 | readOnly = props.readOnly;
|
7935 | return !disabled && !readOnly && isFunction(onRemove) ? React__default.createElement(InteractiveToken, _extends({}, props, {
|
7936 | ref: ref
|
7937 | })) : React__default.createElement(StaticToken, props);
|
7938 | });
|
7939 | var Token$1 = withToken(Token);
|
7940 |
|
7941 |
|
7942 |
|
7943 | function interpolateStyle(styles, attr, subattr) {
|
7944 | if (subattr === void 0) {
|
7945 | subattr = '';
|
7946 | }
|
7947 |
|
7948 |
|
7949 | if (subattr) {
|
7950 |
|
7951 | subattr = subattr.replace(subattr[0], subattr[0].toUpperCase());
|
7952 | }
|
7953 |
|
7954 | return ['Top', 'Right', 'Bottom', 'Left'].map(function (dir) {
|
7955 | return styles[attr + dir + subattr];
|
7956 | }).join(' ');
|
7957 | }
|
7958 |
|
7959 | function copyStyles(inputNode, hintNode) {
|
7960 | if (!inputNode || !hintNode) {
|
7961 | return;
|
7962 | }
|
7963 |
|
7964 | var inputStyle = window.getComputedStyle(inputNode);
|
7965 |
|
7966 |
|
7967 | hintNode.style.borderStyle = interpolateStyle(inputStyle, 'border', 'style');
|
7968 | hintNode.style.borderWidth = interpolateStyle(inputStyle, 'border', 'width');
|
7969 | hintNode.style.fontSize = inputStyle.fontSize;
|
7970 | hintNode.style.height = inputStyle.height;
|
7971 | hintNode.style.lineHeight = inputStyle.lineHeight;
|
7972 | hintNode.style.margin = interpolateStyle(inputStyle, 'margin');
|
7973 | hintNode.style.padding = interpolateStyle(inputStyle, 'padding');
|
7974 |
|
7975 | }
|
7976 |
|
7977 | function defaultShouldSelect(e, state) {
|
7978 | var shouldSelectHint = false;
|
7979 | var currentTarget = e.currentTarget,
|
7980 | keyCode = e.keyCode;
|
7981 |
|
7982 | if (keyCode === RIGHT) {
|
7983 |
|
7984 |
|
7985 |
|
7986 | shouldSelectHint = isSelectable(currentTarget) ? currentTarget.selectionStart === currentTarget.value.length : true;
|
7987 | }
|
7988 |
|
7989 | if (keyCode === TAB) {
|
7990 |
|
7991 | e.preventDefault();
|
7992 | shouldSelectHint = true;
|
7993 | }
|
7994 |
|
7995 | if (keyCode === RETURN) {
|
7996 | shouldSelectHint = !!state.selectHintOnEnter;
|
7997 | }
|
7998 |
|
7999 | return typeof state.shouldSelect === 'function' ? state.shouldSelect(shouldSelectHint, e) : shouldSelectHint;
|
8000 | }
|
8001 | var useHint = function useHint(_ref) {
|
8002 | var children = _ref.children,
|
8003 | shouldSelect = _ref.shouldSelect;
|
8004 | !(React__default.Children.count(children) === 1) ? invariant_1(false, '`useHint` expects one child.') : void 0;
|
8005 |
|
8006 | var _useTypeaheadContext = useTypeaheadContext(),
|
8007 | hintText = _useTypeaheadContext.hintText,
|
8008 | initialItem = _useTypeaheadContext.initialItem,
|
8009 | inputNode = _useTypeaheadContext.inputNode,
|
8010 | onAdd = _useTypeaheadContext.onAdd,
|
8011 | selectHintOnEnter = _useTypeaheadContext.selectHintOnEnter;
|
8012 |
|
8013 | var hintRef = React.useRef(null);
|
8014 |
|
8015 | var onKeyDown = function onKeyDown(e) {
|
8016 | if (hintText && initialItem && defaultShouldSelect(e, {
|
8017 | selectHintOnEnter: selectHintOnEnter,
|
8018 | shouldSelect: shouldSelect
|
8019 | })) {
|
8020 | onAdd(initialItem);
|
8021 | }
|
8022 |
|
8023 | children.props.onKeyDown && children.props.onKeyDown(e);
|
8024 | };
|
8025 |
|
8026 | React.useEffect(function () {
|
8027 | copyStyles(inputNode, hintRef.current);
|
8028 | });
|
8029 | return {
|
8030 | child: React.cloneElement(children, _extends({}, children.props, {
|
8031 | onKeyDown: onKeyDown
|
8032 | })),
|
8033 | hintRef: hintRef,
|
8034 | hintText: hintText
|
8035 | };
|
8036 | };
|
8037 |
|
8038 | var Hint = function Hint(_ref2) {
|
8039 | var className = _ref2.className,
|
8040 | props = _objectWithoutPropertiesLoose(_ref2, ["className"]);
|
8041 |
|
8042 | var _useHint = useHint(props),
|
8043 | child = _useHint.child,
|
8044 | hintRef = _useHint.hintRef,
|
8045 | hintText = _useHint.hintText;
|
8046 |
|
8047 | return React__default.createElement("div", {
|
8048 | className: className,
|
8049 | style: {
|
8050 | display: 'flex',
|
8051 | flex: 1,
|
8052 | height: '100%',
|
8053 | position: 'relative'
|
8054 | }
|
8055 | }, child, React__default.createElement("input", {
|
8056 | "aria-hidden": true,
|
8057 | className: "rbt-input-hint",
|
8058 | ref: hintRef,
|
8059 | readOnly: true,
|
8060 | style: {
|
8061 | backgroundColor: 'transparent',
|
8062 | borderColor: 'transparent',
|
8063 | boxShadow: 'none',
|
8064 | color: 'rgba(0, 0, 0, 0.35)',
|
8065 | left: 0,
|
8066 | pointerEvents: 'none',
|
8067 | position: 'absolute',
|
8068 | top: 0,
|
8069 | width: '100%'
|
8070 | },
|
8071 | tabIndex: -1,
|
8072 | value: hintText
|
8073 | }));
|
8074 | };
|
8075 |
|
8076 | var Input = React__default.forwardRef(function (props, ref) {
|
8077 | return React__default.createElement("input", _extends({}, props, {
|
8078 | className: classnames('rbt-input-main', props.className),
|
8079 | ref: ref
|
8080 | }));
|
8081 | });
|
8082 |
|
8083 | function withClassNames(Component) {
|
8084 |
|
8085 |
|
8086 |
|
8087 | var WrappedComponent = function (_React$Component) {
|
8088 | _inheritsLoose(WrappedComponent, _React$Component);
|
8089 |
|
8090 | function WrappedComponent() {
|
8091 | return _React$Component.apply(this, arguments) || this;
|
8092 | }
|
8093 |
|
8094 | var _proto = WrappedComponent.prototype;
|
8095 |
|
8096 | _proto.render = function render() {
|
8097 | var _this$props = this.props,
|
8098 | className = _this$props.className,
|
8099 | isInvalid = _this$props.isInvalid,
|
8100 | isValid = _this$props.isValid,
|
8101 | size = _this$props.size,
|
8102 | props = _objectWithoutPropertiesLoose(_this$props, ["className", "isInvalid", "isValid", "size"]);
|
8103 |
|
8104 | return React__default.createElement(Component, _extends({}, props, {
|
8105 | className: classnames('form-control', 'rbt-input', {
|
8106 | 'form-control-lg': isSizeLarge(size),
|
8107 | 'form-control-sm': isSizeSmall(size),
|
8108 | 'is-invalid': isInvalid,
|
8109 | 'is-valid': isValid
|
8110 | }, className)
|
8111 | }));
|
8112 | };
|
8113 |
|
8114 | return WrappedComponent;
|
8115 | }(React__default.Component);
|
8116 |
|
8117 | _defineProperty(WrappedComponent, "displayName", "withClassNames(" + getDisplayName(Component) + ")");
|
8118 |
|
8119 | return WrappedComponent;
|
8120 | }
|
8121 |
|
8122 | var TypeaheadInputMulti = function (_React$Component) {
|
8123 | _inheritsLoose(TypeaheadInputMulti, _React$Component);
|
8124 |
|
8125 | function TypeaheadInputMulti() {
|
8126 | var _this;
|
8127 |
|
8128 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
8129 | args[_key] = arguments[_key];
|
8130 | }
|
8131 |
|
8132 | _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
|
8133 |
|
8134 | _defineProperty(_assertThisInitialized(_this), "wrapperRef", React__default.createRef());
|
8135 |
|
8136 | _defineProperty(_assertThisInitialized(_this), "_input", void 0);
|
8137 |
|
8138 | _defineProperty(_assertThisInitialized(_this), "getInputRef", function (input) {
|
8139 | _this._input = input;
|
8140 |
|
8141 | _this.props.inputRef(input);
|
8142 | });
|
8143 |
|
8144 | _defineProperty(_assertThisInitialized(_this), "_handleContainerClickOrFocus", function (e) {
|
8145 |
|
8146 | if (_this.props.disabled) {
|
8147 | e.currentTarget.blur();
|
8148 | return;
|
8149 | }
|
8150 |
|
8151 |
|
8152 | var inputNode = _this._input;
|
8153 |
|
8154 | if (!inputNode) {
|
8155 | return;
|
8156 | }
|
8157 |
|
8158 | if (e.currentTarget !== inputNode && isSelectable(inputNode)) {
|
8159 | inputNode.selectionStart = inputNode.value.length;
|
8160 | }
|
8161 |
|
8162 | inputNode.focus();
|
8163 | });
|
8164 |
|
8165 | _defineProperty(_assertThisInitialized(_this), "_handleKeyDown", function (e) {
|
8166 | var _this$props = _this.props,
|
8167 | onKeyDown = _this$props.onKeyDown,
|
8168 | selected = _this$props.selected,
|
8169 | value = _this$props.value;
|
8170 |
|
8171 | switch (e.keyCode) {
|
8172 | case BACKSPACE:
|
8173 | if (e.currentTarget === _this._input && selected.length && !value) {
|
8174 |
|
8175 | e.preventDefault();
|
8176 |
|
8177 |
|
8178 | if (_this.wrapperRef.current) {
|
8179 | var children = _this.wrapperRef.current.children;
|
8180 | var lastToken = children[children.length - 2];
|
8181 | lastToken && lastToken.focus();
|
8182 | }
|
8183 | }
|
8184 |
|
8185 | break;
|
8186 | }
|
8187 |
|
8188 | onKeyDown(e);
|
8189 | });
|
8190 |
|
8191 | return _this;
|
8192 | }
|
8193 |
|
8194 | var _proto = TypeaheadInputMulti.prototype;
|
8195 |
|
8196 | _proto.render = function render() {
|
8197 | var _this$props2 = this.props,
|
8198 | children = _this$props2.children,
|
8199 | className = _this$props2.className,
|
8200 | inputClassName = _this$props2.inputClassName,
|
8201 | inputRef = _this$props2.inputRef,
|
8202 | placeholder = _this$props2.placeholder,
|
8203 | referenceElementRef = _this$props2.referenceElementRef,
|
8204 | selected = _this$props2.selected,
|
8205 | shouldSelectHint = _this$props2.shouldSelectHint,
|
8206 | props = _objectWithoutPropertiesLoose(_this$props2, ["children", "className", "inputClassName", "inputRef", "placeholder", "referenceElementRef", "selected", "shouldSelectHint"]);
|
8207 |
|
8208 | return React__default.createElement("div", {
|
8209 | className: classnames('rbt-input-multi', className),
|
8210 | disabled: props.disabled,
|
8211 | onClick: this._handleContainerClickOrFocus,
|
8212 | onFocus: this._handleContainerClickOrFocus,
|
8213 | ref: referenceElementRef,
|
8214 | tabIndex: -1
|
8215 | }, React__default.createElement("div", {
|
8216 | className: "rbt-input-wrapper",
|
8217 | ref: this.wrapperRef
|
8218 | }, children, React__default.createElement(Hint, {
|
8219 | shouldSelect: shouldSelectHint
|
8220 | }, React__default.createElement(Input, _extends({}, props, {
|
8221 | className: inputClassName,
|
8222 | onKeyDown: this._handleKeyDown,
|
8223 | placeholder: selected.length ? '' : placeholder,
|
8224 | ref: this.getInputRef,
|
8225 | style: {
|
8226 | backgroundColor: 'transparent',
|
8227 | border: 0,
|
8228 | boxShadow: 'none',
|
8229 | cursor: 'inherit',
|
8230 | outline: 'none',
|
8231 | padding: 0,
|
8232 | width: '100%',
|
8233 | zIndex: 1
|
8234 | }
|
8235 | })))));
|
8236 | };
|
8237 |
|
8238 | return TypeaheadInputMulti;
|
8239 | }(React__default.Component);
|
8240 |
|
8241 | var TypeaheadInputMulti$1 = withClassNames(TypeaheadInputMulti);
|
8242 |
|
8243 | var TypeaheadInputSingle = withClassNames(function (_ref) {
|
8244 | var inputRef = _ref.inputRef,
|
8245 | referenceElementRef = _ref.referenceElementRef,
|
8246 | shouldSelectHint = _ref.shouldSelectHint,
|
8247 | props = _objectWithoutPropertiesLoose(_ref, ["inputRef", "referenceElementRef", "shouldSelectHint"]);
|
8248 |
|
8249 | return React__default.createElement(Hint, {
|
8250 | shouldSelect: shouldSelectHint
|
8251 | }, React__default.createElement(Input, _extends({}, props, {
|
8252 | ref: function ref(node) {
|
8253 | inputRef(node);
|
8254 | referenceElementRef(node);
|
8255 | }
|
8256 | })));
|
8257 | });
|
8258 |
|
8259 | var propTypes$7 = {
|
8260 | children: propTypes.string.isRequired,
|
8261 | highlightClassName: propTypes.string,
|
8262 | search: propTypes.string.isRequired
|
8263 | };
|
8264 | var defaultProps$5 = {
|
8265 | highlightClassName: 'rbt-highlight-text'
|
8266 | };
|
8267 |
|
8268 | |
8269 |
|
8270 |
|
8271 |
|
8272 |
|
8273 |
|
8274 | var Highlighter = function (_React$PureComponent) {
|
8275 | _inheritsLoose(Highlighter, _React$PureComponent);
|
8276 |
|
8277 | function Highlighter() {
|
8278 | return _React$PureComponent.apply(this, arguments) || this;
|
8279 | }
|
8280 |
|
8281 | var _proto = Highlighter.prototype;
|
8282 |
|
8283 | _proto.render = function render() {
|
8284 | var _this$props = this.props,
|
8285 | children = _this$props.children,
|
8286 | highlightClassName = _this$props.highlightClassName,
|
8287 | search = _this$props.search;
|
8288 |
|
8289 | if (!search || !children) {
|
8290 | return children;
|
8291 | }
|
8292 |
|
8293 | var matchCount = 0;
|
8294 | var remaining = children;
|
8295 | var highlighterChildren = [];
|
8296 |
|
8297 | while (remaining) {
|
8298 | var bounds = getMatchBounds(remaining, search);
|
8299 |
|
8300 | if (!bounds) {
|
8301 | highlighterChildren.push(remaining);
|
8302 | break;
|
8303 | }
|
8304 |
|
8305 |
|
8306 | var nonMatch = remaining.slice(0, bounds.start);
|
8307 |
|
8308 | if (nonMatch) {
|
8309 | highlighterChildren.push(nonMatch);
|
8310 | }
|
8311 |
|
8312 |
|
8313 | var match = remaining.slice(bounds.start, bounds.end);
|
8314 | highlighterChildren.push( React__default.createElement("mark", {
|
8315 | className: highlightClassName,
|
8316 | key: matchCount
|
8317 | }, match));
|
8318 | matchCount += 1;
|
8319 |
|
8320 | remaining = remaining.slice(bounds.end);
|
8321 | }
|
8322 |
|
8323 | return highlighterChildren;
|
8324 | };
|
8325 |
|
8326 | return Highlighter;
|
8327 | }(React__default.PureComponent);
|
8328 |
|
8329 | _defineProperty(Highlighter, "propTypes", propTypes$7);
|
8330 |
|
8331 | _defineProperty(Highlighter, "defaultProps", defaultProps$5);
|
8332 |
|
8333 | function isElement(el) {
|
8334 | return el != null && typeof el === 'object' && el.nodeType === 1;
|
8335 | }
|
8336 |
|
8337 | function canOverflow(overflow, skipOverflowHiddenElements) {
|
8338 | if (skipOverflowHiddenElements && overflow === 'hidden') {
|
8339 | return false;
|
8340 | }
|
8341 |
|
8342 | return overflow !== 'visible' && overflow !== 'clip';
|
8343 | }
|
8344 |
|
8345 | function getFrameElement(el) {
|
8346 | if (!el.ownerDocument || !el.ownerDocument.defaultView) {
|
8347 | return null;
|
8348 | }
|
8349 |
|
8350 | try {
|
8351 | return el.ownerDocument.defaultView.frameElement;
|
8352 | } catch (e) {
|
8353 | return null;
|
8354 | }
|
8355 | }
|
8356 |
|
8357 | function isHiddenByFrame(el) {
|
8358 | var frame = getFrameElement(el);
|
8359 |
|
8360 | if (!frame) {
|
8361 | return false;
|
8362 | }
|
8363 |
|
8364 | return frame.clientHeight < el.scrollHeight || frame.clientWidth < el.scrollWidth;
|
8365 | }
|
8366 |
|
8367 | function isScrollable(el, skipOverflowHiddenElements) {
|
8368 | if (el.clientHeight < el.scrollHeight || el.clientWidth < el.scrollWidth) {
|
8369 | var style = getComputedStyle(el, null);
|
8370 | return canOverflow(style.overflowY, skipOverflowHiddenElements) || canOverflow(style.overflowX, skipOverflowHiddenElements) || isHiddenByFrame(el);
|
8371 | }
|
8372 |
|
8373 | return false;
|
8374 | }
|
8375 |
|
8376 | function alignNearest(scrollingEdgeStart, scrollingEdgeEnd, scrollingSize, scrollingBorderStart, scrollingBorderEnd, elementEdgeStart, elementEdgeEnd, elementSize) {
|
8377 | if (elementEdgeStart < scrollingEdgeStart && elementEdgeEnd > scrollingEdgeEnd || elementEdgeStart > scrollingEdgeStart && elementEdgeEnd < scrollingEdgeEnd) {
|
8378 | return 0;
|
8379 | }
|
8380 |
|
8381 | if (elementEdgeStart <= scrollingEdgeStart && elementSize <= scrollingSize || elementEdgeEnd >= scrollingEdgeEnd && elementSize >= scrollingSize) {
|
8382 | return elementEdgeStart - scrollingEdgeStart - scrollingBorderStart;
|
8383 | }
|
8384 |
|
8385 | if (elementEdgeEnd > scrollingEdgeEnd && elementSize < scrollingSize || elementEdgeStart < scrollingEdgeStart && elementSize > scrollingSize) {
|
8386 | return elementEdgeEnd - scrollingEdgeEnd + scrollingBorderEnd;
|
8387 | }
|
8388 |
|
8389 | return 0;
|
8390 | }
|
8391 |
|
8392 | var compute = (function (target, options) {
|
8393 | var scrollMode = options.scrollMode,
|
8394 | block = options.block,
|
8395 | inline = options.inline,
|
8396 | boundary = options.boundary,
|
8397 | skipOverflowHiddenElements = options.skipOverflowHiddenElements;
|
8398 | var checkBoundary = typeof boundary === 'function' ? boundary : function (node) {
|
8399 | return node !== boundary;
|
8400 | };
|
8401 |
|
8402 | if (!isElement(target)) {
|
8403 | throw new TypeError('Invalid target');
|
8404 | }
|
8405 |
|
8406 | var scrollingElement = document.scrollingElement || document.documentElement;
|
8407 | var frames = [];
|
8408 | var cursor = target;
|
8409 |
|
8410 | while (isElement(cursor) && checkBoundary(cursor)) {
|
8411 | cursor = cursor.parentNode;
|
8412 |
|
8413 | if (cursor === scrollingElement) {
|
8414 | frames.push(cursor);
|
8415 | break;
|
8416 | }
|
8417 |
|
8418 | if (cursor === document.body && isScrollable(cursor) && !isScrollable(document.documentElement)) {
|
8419 | continue;
|
8420 | }
|
8421 |
|
8422 | if (isScrollable(cursor, skipOverflowHiddenElements)) {
|
8423 | frames.push(cursor);
|
8424 | }
|
8425 | }
|
8426 |
|
8427 | var viewportWidth = window.visualViewport ? visualViewport.width : innerWidth;
|
8428 | var viewportHeight = window.visualViewport ? visualViewport.height : innerHeight;
|
8429 | var viewportX = window.scrollX || pageXOffset;
|
8430 | var viewportY = window.scrollY || pageYOffset;
|
8431 |
|
8432 | var _target$getBoundingCl = target.getBoundingClientRect(),
|
8433 | targetHeight = _target$getBoundingCl.height,
|
8434 | targetWidth = _target$getBoundingCl.width,
|
8435 | targetTop = _target$getBoundingCl.top,
|
8436 | targetRight = _target$getBoundingCl.right,
|
8437 | targetBottom = _target$getBoundingCl.bottom,
|
8438 | targetLeft = _target$getBoundingCl.left;
|
8439 |
|
8440 | var targetBlock = block === 'start' || block === 'nearest' ? targetTop : block === 'end' ? targetBottom : targetTop + targetHeight / 2;
|
8441 | var targetInline = inline === 'center' ? targetLeft + targetWidth / 2 : inline === 'end' ? targetRight : targetLeft;
|
8442 | var computations = [];
|
8443 |
|
8444 | for (var index = 0; index < frames.length; index++) {
|
8445 | var frame = frames[index];
|
8446 |
|
8447 | var _frame$getBoundingCli = frame.getBoundingClientRect(),
|
8448 | height = _frame$getBoundingCli.height,
|
8449 | width = _frame$getBoundingCli.width,
|
8450 | top = _frame$getBoundingCli.top,
|
8451 | right = _frame$getBoundingCli.right,
|
8452 | bottom = _frame$getBoundingCli.bottom,
|
8453 | left = _frame$getBoundingCli.left;
|
8454 |
|
8455 | if (scrollMode === 'if-needed' && targetTop >= 0 && targetLeft >= 0 && targetBottom <= viewportHeight && targetRight <= viewportWidth && targetTop >= top && targetBottom <= bottom && targetLeft >= left && targetRight <= right) {
|
8456 | return computations;
|
8457 | }
|
8458 |
|
8459 | var frameStyle = getComputedStyle(frame);
|
8460 | var borderLeft = parseInt(frameStyle.borderLeftWidth, 10);
|
8461 | var borderTop = parseInt(frameStyle.borderTopWidth, 10);
|
8462 | var borderRight = parseInt(frameStyle.borderRightWidth, 10);
|
8463 | var borderBottom = parseInt(frameStyle.borderBottomWidth, 10);
|
8464 | var blockScroll = 0;
|
8465 | var inlineScroll = 0;
|
8466 | var scrollbarWidth = 'offsetWidth' in frame ? frame.offsetWidth - frame.clientWidth - borderLeft - borderRight : 0;
|
8467 | var scrollbarHeight = 'offsetHeight' in frame ? frame.offsetHeight - frame.clientHeight - borderTop - borderBottom : 0;
|
8468 |
|
8469 | if (scrollingElement === frame) {
|
8470 | if (block === 'start') {
|
8471 | blockScroll = targetBlock;
|
8472 | } else if (block === 'end') {
|
8473 | blockScroll = targetBlock - viewportHeight;
|
8474 | } else if (block === 'nearest') {
|
8475 | blockScroll = alignNearest(viewportY, viewportY + viewportHeight, viewportHeight, borderTop, borderBottom, viewportY + targetBlock, viewportY + targetBlock + targetHeight, targetHeight);
|
8476 | } else {
|
8477 | blockScroll = targetBlock - viewportHeight / 2;
|
8478 | }
|
8479 |
|
8480 | if (inline === 'start') {
|
8481 | inlineScroll = targetInline;
|
8482 | } else if (inline === 'center') {
|
8483 | inlineScroll = targetInline - viewportWidth / 2;
|
8484 | } else if (inline === 'end') {
|
8485 | inlineScroll = targetInline - viewportWidth;
|
8486 | } else {
|
8487 | inlineScroll = alignNearest(viewportX, viewportX + viewportWidth, viewportWidth, borderLeft, borderRight, viewportX + targetInline, viewportX + targetInline + targetWidth, targetWidth);
|
8488 | }
|
8489 |
|
8490 | blockScroll = Math.max(0, blockScroll + viewportY);
|
8491 | inlineScroll = Math.max(0, inlineScroll + viewportX);
|
8492 | } else {
|
8493 | if (block === 'start') {
|
8494 | blockScroll = targetBlock - top - borderTop;
|
8495 | } else if (block === 'end') {
|
8496 | blockScroll = targetBlock - bottom + borderBottom + scrollbarHeight;
|
8497 | } else if (block === 'nearest') {
|
8498 | blockScroll = alignNearest(top, bottom, height, borderTop, borderBottom + scrollbarHeight, targetBlock, targetBlock + targetHeight, targetHeight);
|
8499 | } else {
|
8500 | blockScroll = targetBlock - (top + height / 2) + scrollbarHeight / 2;
|
8501 | }
|
8502 |
|
8503 | if (inline === 'start') {
|
8504 | inlineScroll = targetInline - left - borderLeft;
|
8505 | } else if (inline === 'center') {
|
8506 | inlineScroll = targetInline - (left + width / 2) + scrollbarWidth / 2;
|
8507 | } else if (inline === 'end') {
|
8508 | inlineScroll = targetInline - right + borderRight + scrollbarWidth;
|
8509 | } else {
|
8510 | inlineScroll = alignNearest(left, right, width, borderLeft, borderRight + scrollbarWidth, targetInline, targetInline + targetWidth, targetWidth);
|
8511 | }
|
8512 |
|
8513 | var scrollLeft = frame.scrollLeft,
|
8514 | scrollTop = frame.scrollTop;
|
8515 | blockScroll = Math.max(0, Math.min(scrollTop + blockScroll, frame.scrollHeight - height + scrollbarHeight));
|
8516 | inlineScroll = Math.max(0, Math.min(scrollLeft + inlineScroll, frame.scrollWidth - width + scrollbarWidth));
|
8517 | targetBlock += scrollTop - blockScroll;
|
8518 | targetInline += scrollLeft - inlineScroll;
|
8519 | }
|
8520 |
|
8521 | computations.push({
|
8522 | el: frame,
|
8523 | top: blockScroll,
|
8524 | left: inlineScroll
|
8525 | });
|
8526 | }
|
8527 |
|
8528 | return computations;
|
8529 | });
|
8530 |
|
8531 | function isOptionsObject(options) {
|
8532 | return options === Object(options) && Object.keys(options).length !== 0;
|
8533 | }
|
8534 |
|
8535 | function defaultBehavior(actions, behavior) {
|
8536 | if (behavior === void 0) {
|
8537 | behavior = 'auto';
|
8538 | }
|
8539 |
|
8540 | var canSmoothScroll = ('scrollBehavior' in document.body.style);
|
8541 | actions.forEach(function (_ref) {
|
8542 | var el = _ref.el,
|
8543 | top = _ref.top,
|
8544 | left = _ref.left;
|
8545 |
|
8546 | if (el.scroll && canSmoothScroll) {
|
8547 | el.scroll({
|
8548 | top: top,
|
8549 | left: left,
|
8550 | behavior: behavior
|
8551 | });
|
8552 | } else {
|
8553 | el.scrollTop = top;
|
8554 | el.scrollLeft = left;
|
8555 | }
|
8556 | });
|
8557 | }
|
8558 |
|
8559 | function getOptions(options) {
|
8560 | if (options === false) {
|
8561 | return {
|
8562 | block: 'end',
|
8563 | inline: 'nearest'
|
8564 | };
|
8565 | }
|
8566 |
|
8567 | if (isOptionsObject(options)) {
|
8568 | return options;
|
8569 | }
|
8570 |
|
8571 | return {
|
8572 | block: 'start',
|
8573 | inline: 'nearest'
|
8574 | };
|
8575 | }
|
8576 |
|
8577 | function scrollIntoView(target, options) {
|
8578 | var targetIsDetached = !target.ownerDocument.documentElement.contains(target);
|
8579 |
|
8580 | if (isOptionsObject(options) && typeof options.behavior === 'function') {
|
8581 | return options.behavior(targetIsDetached ? [] : compute(target, options));
|
8582 | }
|
8583 |
|
8584 | if (targetIsDetached) {
|
8585 | return;
|
8586 | }
|
8587 |
|
8588 | var computeOptions = getOptions(options);
|
8589 | return defaultBehavior(compute(target, computeOptions), computeOptions.behavior);
|
8590 | }
|
8591 |
|
8592 | var propTypes$8 = {
|
8593 | option: optionType.isRequired,
|
8594 | position: propTypes.number
|
8595 | };
|
8596 | var useItem = function useItem(_ref) {
|
8597 | var label = _ref.label,
|
8598 | onClick = _ref.onClick,
|
8599 | option = _ref.option,
|
8600 | position = _ref.position,
|
8601 | props = _objectWithoutPropertiesLoose(_ref, ["label", "onClick", "option", "position"]);
|
8602 |
|
8603 | var _useTypeaheadContext = useTypeaheadContext(),
|
8604 | activeIndex = _useTypeaheadContext.activeIndex,
|
8605 | id = _useTypeaheadContext.id,
|
8606 | isOnlyResult = _useTypeaheadContext.isOnlyResult,
|
8607 | onActiveItemChange = _useTypeaheadContext.onActiveItemChange,
|
8608 | onInitialItemChange = _useTypeaheadContext.onInitialItemChange,
|
8609 | onMenuItemClick = _useTypeaheadContext.onMenuItemClick,
|
8610 | setItem = _useTypeaheadContext.setItem;
|
8611 |
|
8612 | var itemRef = React.useRef(null);
|
8613 | React.useEffect(function () {
|
8614 | if (position === 0) {
|
8615 | onInitialItemChange(option);
|
8616 | }
|
8617 | });
|
8618 | React.useEffect(function () {
|
8619 | if (position === activeIndex) {
|
8620 | onActiveItemChange(option);
|
8621 |
|
8622 | var node = itemRef.current;
|
8623 | node && scrollIntoView(node, {
|
8624 | block: 'nearest',
|
8625 | boundary: node.parentNode,
|
8626 | inline: 'nearest',
|
8627 | scrollMode: 'if-needed'
|
8628 | });
|
8629 | }
|
8630 | });
|
8631 | var handleClick = React.useCallback(function (e) {
|
8632 | onMenuItemClick(option, e);
|
8633 | onClick && onClick(e);
|
8634 | }, [onClick, onMenuItemClick, option]);
|
8635 | var active = isOnlyResult || activeIndex === position;
|
8636 |
|
8637 | setItem(option, position);
|
8638 | return _extends({}, props, {
|
8639 | active: active,
|
8640 | 'aria-label': label,
|
8641 | 'aria-selected': active,
|
8642 | id: getMenuItemId(id, position),
|
8643 | onClick: handleClick,
|
8644 | onMouseDown: preventInputBlur,
|
8645 | ref: itemRef,
|
8646 | role: 'option'
|
8647 | });
|
8648 | };
|
8649 | var withItem = function withItem(Component) {
|
8650 | var displayName = "withItem(" + getDisplayName(Component) + ")";
|
8651 |
|
8652 | var WrappedMenuItem = function WrappedMenuItem(props) {
|
8653 | return React__default.createElement(Component, useItem(props));
|
8654 | };
|
8655 |
|
8656 | WrappedMenuItem.displayName = displayName;
|
8657 | WrappedMenuItem.propTypes = propTypes$8;
|
8658 | return WrappedMenuItem;
|
8659 | };
|
8660 | function menuItemContainer(Component) {
|
8661 |
|
8662 | warn(false, 'The `menuItemContainer` export is deprecated; use `withItem` instead.');
|
8663 |
|
8664 |
|
8665 | return withItem(Component);
|
8666 | }
|
8667 |
|
8668 | var BaseMenuItem = React__default.forwardRef(function (_ref, ref) {
|
8669 | var active = _ref.active,
|
8670 | children = _ref.children,
|
8671 | className = _ref.className,
|
8672 | disabled = _ref.disabled,
|
8673 | _onClick = _ref.onClick,
|
8674 | onMouseDown = _ref.onMouseDown,
|
8675 | props = _objectWithoutPropertiesLoose(_ref, ["active", "children", "className", "disabled", "onClick", "onMouseDown"]);
|
8676 |
|
8677 | return (
|
8678 |
|
8679 |
|
8680 |
|
8681 | React__default.createElement("a", _extends({}, props, {
|
8682 | className: classnames('dropdown-item', {
|
8683 | active: active,
|
8684 | disabled: disabled
|
8685 | }, className),
|
8686 | href: "#",
|
8687 | onClick: function onClick(e) {
|
8688 | e.preventDefault();
|
8689 | !disabled && _onClick && _onClick(e);
|
8690 | },
|
8691 | onMouseDown: onMouseDown,
|
8692 | ref: ref
|
8693 | }), children)
|
8694 |
|
8695 |
|
8696 | );
|
8697 | });
|
8698 | var MenuItem = withItem(BaseMenuItem);
|
8699 |
|
8700 | var MenuDivider = function MenuDivider(props) {
|
8701 | return React__default.createElement("div", {
|
8702 | className: "dropdown-divider",
|
8703 | role: "separator"
|
8704 | });
|
8705 | };
|
8706 |
|
8707 | var MenuHeader = function MenuHeader(props) {
|
8708 | return (
|
8709 |
|
8710 |
|
8711 | React__default.createElement("div", _extends({}, props, {
|
8712 | className: "dropdown-header",
|
8713 | role: "heading"
|
8714 | }))
|
8715 | );
|
8716 | };
|
8717 |
|
8718 | var propTypes$9 = {
|
8719 | 'aria-label': propTypes.string,
|
8720 |
|
8721 | |
8722 |
|
8723 |
|
8724 | emptyLabel: propTypes.node,
|
8725 |
|
8726 | |
8727 |
|
8728 |
|
8729 | id: checkPropType(propTypes.oneOfType([propTypes.number, propTypes.string]), isRequiredForA11y),
|
8730 |
|
8731 | |
8732 |
|
8733 |
|
8734 | maxHeight: propTypes.string
|
8735 | };
|
8736 | var defaultProps$6 = {
|
8737 | 'aria-label': 'menu-options',
|
8738 | emptyLabel: 'No matches found.',
|
8739 | maxHeight: '300px'
|
8740 | };
|
8741 |
|
8742 | |
8743 |
|
8744 |
|
8745 | var Menu = function (_React$Component) {
|
8746 | _inheritsLoose(Menu, _React$Component);
|
8747 |
|
8748 | function Menu() {
|
8749 | return _React$Component.apply(this, arguments) || this;
|
8750 | }
|
8751 |
|
8752 | var _proto = Menu.prototype;
|
8753 |
|
8754 | _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
|
8755 | var _this$props = this.props,
|
8756 | inputHeight = _this$props.inputHeight,
|
8757 | scheduleUpdate = _this$props.scheduleUpdate;
|
8758 |
|
8759 | if (inputHeight !== prevProps.inputHeight) {
|
8760 | scheduleUpdate();
|
8761 | }
|
8762 | };
|
8763 |
|
8764 | _proto.render = function render() {
|
8765 | var _this$props2 = this.props,
|
8766 | children = _this$props2.children,
|
8767 | className = _this$props2.className,
|
8768 | emptyLabel = _this$props2.emptyLabel,
|
8769 | id = _this$props2.id,
|
8770 | innerRef = _this$props2.innerRef,
|
8771 | maxHeight = _this$props2.maxHeight,
|
8772 | style = _this$props2.style,
|
8773 | text = _this$props2.text;
|
8774 | var contents = React.Children.count(children) === 0 ? React__default.createElement(BaseMenuItem, {
|
8775 | disabled: true,
|
8776 | role: "option"
|
8777 | }, emptyLabel) : children;
|
8778 | return React__default.createElement("div", {
|
8779 | "aria-label": this.props['aria-label'],
|
8780 | className: classnames('rbt-menu', 'dropdown-menu', 'show', className),
|
8781 | id: id,
|
8782 | key:
|
8783 |
|
8784 | text,
|
8785 | ref: innerRef,
|
8786 | role: "listbox",
|
8787 | style: _extends({}, style, {
|
8788 | display: 'block',
|
8789 | maxHeight: maxHeight,
|
8790 | overflow: 'auto'
|
8791 | })
|
8792 | }, contents);
|
8793 | };
|
8794 |
|
8795 | return Menu;
|
8796 | }(React__default.Component);
|
8797 |
|
8798 | _defineProperty(Menu, "propTypes", propTypes$9);
|
8799 |
|
8800 | _defineProperty(Menu, "defaultProps", defaultProps$6);
|
8801 |
|
8802 | _defineProperty(Menu, "Divider", MenuDivider);
|
8803 |
|
8804 | _defineProperty(Menu, "Header", MenuHeader);
|
8805 |
|
8806 | var propTypes$a = {
|
8807 | |
8808 |
|
8809 |
|
8810 |
|
8811 | newSelectionPrefix: propTypes.node,
|
8812 |
|
8813 | |
8814 |
|
8815 |
|
8816 | paginationText: propTypes.node,
|
8817 |
|
8818 | |
8819 |
|
8820 |
|
8821 | renderMenuItemChildren: propTypes.func
|
8822 | };
|
8823 | var defaultProps$7 = {
|
8824 | newSelectionPrefix: 'New selection: ',
|
8825 | paginationText: 'Display additional results...',
|
8826 | renderMenuItemChildren: function renderMenuItemChildren(option, props, idx) {
|
8827 | return React__default.createElement(Highlighter, {
|
8828 | search: props.text
|
8829 | }, getOptionLabel(option, props.labelKey));
|
8830 | }
|
8831 | };
|
8832 |
|
8833 | var TypeaheadMenu = function TypeaheadMenu(props) {
|
8834 | var labelKey = props.labelKey,
|
8835 | newSelectionPrefix = props.newSelectionPrefix,
|
8836 | options = props.options,
|
8837 | paginationText = props.paginationText,
|
8838 | renderMenuItemChildren = props.renderMenuItemChildren,
|
8839 | text = props.text,
|
8840 | menuProps = _objectWithoutPropertiesLoose(props, ["labelKey", "newSelectionPrefix", "options", "paginationText", "renderMenuItemChildren", "text"]);
|
8841 |
|
8842 | var renderMenuItem = function renderMenuItem(option, position) {
|
8843 | var label = getOptionLabel(option, labelKey);
|
8844 | var menuItemProps = {
|
8845 | disabled: getOptionProperty(option, 'disabled'),
|
8846 | label: label,
|
8847 | option: option,
|
8848 | position: position
|
8849 | };
|
8850 |
|
8851 | if (option.customOption) {
|
8852 | return React__default.createElement(MenuItem, _extends({}, menuItemProps, {
|
8853 | className: "rbt-menu-custom-option",
|
8854 | key: position,
|
8855 | label: label
|
8856 | }), newSelectionPrefix, React__default.createElement(Highlighter, {
|
8857 | search: text
|
8858 | }, label));
|
8859 | }
|
8860 |
|
8861 | if (option.paginationOption) {
|
8862 | return React__default.createElement(React.Fragment, {
|
8863 | key: "pagination-item"
|
8864 | }, React__default.createElement(Menu.Divider, null), React__default.createElement(MenuItem, _extends({}, menuItemProps, {
|
8865 | className: "rbt-menu-pagination-option",
|
8866 | label: paginationText
|
8867 | }), paginationText));
|
8868 | }
|
8869 |
|
8870 | return React__default.createElement(MenuItem, _extends({}, menuItemProps, {
|
8871 | key: position
|
8872 | }), renderMenuItemChildren(option, props, position));
|
8873 | };
|
8874 |
|
8875 | return (
|
8876 |
|
8877 |
|
8878 | React__default.createElement(Menu, _extends({}, menuProps, {
|
8879 | text: text
|
8880 | }), options.map(renderMenuItem))
|
8881 | );
|
8882 | };
|
8883 |
|
8884 | TypeaheadMenu.propTypes = propTypes$a;
|
8885 | TypeaheadMenu.defaultProps = defaultProps$7;
|
8886 |
|
8887 | var propTypes$b = {
|
8888 | |
8889 |
|
8890 |
|
8891 | clearButton: propTypes.bool,
|
8892 |
|
8893 | |
8894 |
|
8895 |
|
8896 |
|
8897 | inputProps: checkPropType(propTypes.object, inputPropsType),
|
8898 |
|
8899 | |
8900 |
|
8901 |
|
8902 | isInvalid: propTypes.bool,
|
8903 |
|
8904 | |
8905 |
|
8906 |
|
8907 | isLoading: propTypes.bool,
|
8908 |
|
8909 | |
8910 |
|
8911 |
|
8912 | isValid: propTypes.bool,
|
8913 |
|
8914 | |
8915 |
|
8916 |
|
8917 | renderInput: propTypes.func,
|
8918 |
|
8919 | |
8920 |
|
8921 |
|
8922 | renderMenu: propTypes.func,
|
8923 |
|
8924 | |
8925 |
|
8926 |
|
8927 | renderToken: propTypes.func,
|
8928 |
|
8929 | |
8930 |
|
8931 |
|
8932 | size: sizeType
|
8933 | };
|
8934 | var defaultProps$8 = {
|
8935 | clearButton: false,
|
8936 | inputProps: {},
|
8937 | isInvalid: false,
|
8938 | isLoading: false,
|
8939 | isValid: false,
|
8940 | renderMenu: function renderMenu(results, menuProps, props) {
|
8941 | return React__default.createElement(TypeaheadMenu, _extends({}, menuProps, {
|
8942 | labelKey: props.labelKey,
|
8943 | options: results,
|
8944 | text: props.text
|
8945 | }));
|
8946 | },
|
8947 | renderToken: function renderToken(option, props, idx) {
|
8948 | return React__default.createElement(Token$1, {
|
8949 | disabled: props.disabled,
|
8950 | key: idx,
|
8951 | onRemove: props.onRemove,
|
8952 | option: option,
|
8953 | tabIndex: props.tabIndex
|
8954 | }, getOptionLabel(option, props.labelKey));
|
8955 | }
|
8956 | };
|
8957 |
|
8958 | function getOverlayProps(props) {
|
8959 | return pick(props, ['align', 'dropup', 'flip', 'positionFixed']);
|
8960 | }
|
8961 |
|
8962 | var RootClose = function RootClose(_ref) {
|
8963 | var children = _ref.children,
|
8964 | onRootClose = _ref.onRootClose,
|
8965 | props = _objectWithoutPropertiesLoose(_ref, ["children", "onRootClose"]);
|
8966 |
|
8967 | var _useState = React.useState(null),
|
8968 | rootElement = _useState[0],
|
8969 | attachRef = _useState[1];
|
8970 |
|
8971 | useRootClose(rootElement, onRootClose, props);
|
8972 | return children(attachRef);
|
8973 | };
|
8974 |
|
8975 | var TypeaheadComponent = function (_React$Component) {
|
8976 | _inheritsLoose(TypeaheadComponent, _React$Component);
|
8977 |
|
8978 | function TypeaheadComponent() {
|
8979 | var _this;
|
8980 |
|
8981 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
8982 | args[_key] = arguments[_key];
|
8983 | }
|
8984 |
|
8985 | _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
|
8986 |
|
8987 | _defineProperty(_assertThisInitialized(_this), "_referenceElement", void 0);
|
8988 |
|
8989 | _defineProperty(_assertThisInitialized(_this), "referenceElementRef", function (referenceElement) {
|
8990 | _this._referenceElement = referenceElement;
|
8991 | });
|
8992 |
|
8993 | _defineProperty(_assertThisInitialized(_this), "_renderInput", function (inputProps, props) {
|
8994 | var _this$props = _this.props,
|
8995 | isInvalid = _this$props.isInvalid,
|
8996 | isValid = _this$props.isValid,
|
8997 | multiple = _this$props.multiple,
|
8998 | renderInput = _this$props.renderInput,
|
8999 | renderToken = _this$props.renderToken,
|
9000 | size = _this$props.size;
|
9001 |
|
9002 | if (isFunction(renderInput)) {
|
9003 | return renderInput(inputProps, props);
|
9004 | }
|
9005 |
|
9006 | var commonProps = _extends({}, inputProps, {
|
9007 | isInvalid: isInvalid,
|
9008 | isValid: isValid,
|
9009 | size: size
|
9010 | });
|
9011 |
|
9012 | if (!multiple) {
|
9013 | return React__default.createElement(TypeaheadInputSingle, commonProps);
|
9014 | }
|
9015 |
|
9016 | var labelKey = props.labelKey,
|
9017 | onRemove = props.onRemove,
|
9018 | selected = props.selected;
|
9019 | return React__default.createElement(TypeaheadInputMulti$1, _extends({}, commonProps, {
|
9020 | selected: selected
|
9021 | }), selected.map(function (option, idx) {
|
9022 | return renderToken(option, _extends({}, commonProps, {
|
9023 | labelKey: labelKey,
|
9024 | onRemove: onRemove
|
9025 | }), idx);
|
9026 | }));
|
9027 | });
|
9028 |
|
9029 | _defineProperty(_assertThisInitialized(_this), "_renderMenu", function (results, menuProps, props) {
|
9030 | var _this$props2 = _this.props,
|
9031 | emptyLabel = _this$props2.emptyLabel,
|
9032 | id = _this$props2.id,
|
9033 | maxHeight = _this$props2.maxHeight,
|
9034 | newSelectionPrefix = _this$props2.newSelectionPrefix,
|
9035 | paginationText = _this$props2.paginationText,
|
9036 | renderMenu = _this$props2.renderMenu,
|
9037 | renderMenuItemChildren = _this$props2.renderMenuItemChildren;
|
9038 | return renderMenu(results, _extends({}, menuProps, {
|
9039 | emptyLabel: emptyLabel,
|
9040 | id: id,
|
9041 | maxHeight: maxHeight,
|
9042 | newSelectionPrefix: newSelectionPrefix,
|
9043 | paginationText: paginationText,
|
9044 | renderMenuItemChildren: renderMenuItemChildren
|
9045 | }), props);
|
9046 | });
|
9047 |
|
9048 | _defineProperty(_assertThisInitialized(_this), "_renderAux", function (_ref2) {
|
9049 | var onClear = _ref2.onClear,
|
9050 | selected = _ref2.selected;
|
9051 | var _this$props3 = _this.props,
|
9052 | clearButton = _this$props3.clearButton,
|
9053 | disabled = _this$props3.disabled,
|
9054 | isLoading = _this$props3.isLoading,
|
9055 | size = _this$props3.size;
|
9056 | var content;
|
9057 |
|
9058 | if (isLoading) {
|
9059 | content = React__default.createElement(Loader, null);
|
9060 | } else if (clearButton && !disabled && selected.length) {
|
9061 | content = React__default.createElement(ClearButton, {
|
9062 | onClick: onClear,
|
9063 | onFocus: function onFocus(e) {
|
9064 |
|
9065 | e.stopPropagation();
|
9066 | },
|
9067 | onMouseDown: preventInputBlur,
|
9068 | size: size
|
9069 | });
|
9070 | }
|
9071 |
|
9072 | return content ? React__default.createElement("div", {
|
9073 | className: classnames('rbt-aux', {
|
9074 | 'rbt-aux-lg': isSizeLarge(size)
|
9075 | })
|
9076 | }, content) : null;
|
9077 | });
|
9078 |
|
9079 | return _this;
|
9080 | }
|
9081 |
|
9082 | var _proto = TypeaheadComponent.prototype;
|
9083 |
|
9084 | _proto.render = function render() {
|
9085 | var _this2 = this;
|
9086 |
|
9087 | var _this$props4 = this.props,
|
9088 | children = _this$props4.children,
|
9089 | className = _this$props4.className,
|
9090 | instanceRef = _this$props4.instanceRef,
|
9091 | open = _this$props4.open,
|
9092 | options = _this$props4.options,
|
9093 | style = _this$props4.style;
|
9094 | return React__default.createElement(Typeahead, _extends({}, this.props, {
|
9095 | options: options,
|
9096 | ref: instanceRef
|
9097 | }), function (_ref3) {
|
9098 | var getInputProps = _ref3.getInputProps,
|
9099 | props = _objectWithoutPropertiesLoose(_ref3, ["getInputProps"]);
|
9100 |
|
9101 | var hideMenu = props.hideMenu,
|
9102 | isMenuShown = props.isMenuShown,
|
9103 | results = props.results;
|
9104 |
|
9105 | var auxContent = _this2._renderAux(props);
|
9106 |
|
9107 | return React__default.createElement(RootClose, {
|
9108 | disabled: open || !isMenuShown,
|
9109 | onRootClose: hideMenu
|
9110 | }, function (ref) {
|
9111 | return React__default.createElement("div", {
|
9112 | className: classnames('rbt', {
|
9113 | 'has-aux': !!auxContent
|
9114 | }, className),
|
9115 | ref: ref,
|
9116 | style: _extends({}, style, {
|
9117 | outline: 'none',
|
9118 | position: 'relative'
|
9119 | }),
|
9120 | tabIndex: -1
|
9121 | }, _this2._renderInput(_extends({}, getInputProps(_this2.props.inputProps), {
|
9122 | referenceElementRef: _this2.referenceElementRef
|
9123 | }), props), React__default.createElement(Overlay, _extends({}, getOverlayProps(_this2.props), {
|
9124 | isMenuShown: isMenuShown,
|
9125 | referenceElement: _this2._referenceElement
|
9126 | }), function (menuProps) {
|
9127 | return _this2._renderMenu(results, menuProps, props);
|
9128 | }), auxContent, isFunction(children) ? children(props) : children);
|
9129 | });
|
9130 | });
|
9131 | };
|
9132 |
|
9133 | return TypeaheadComponent;
|
9134 | }(React__default.Component);
|
9135 |
|
9136 | _defineProperty(TypeaheadComponent, "propTypes", propTypes$b);
|
9137 |
|
9138 | _defineProperty(TypeaheadComponent, "defaultProps", defaultProps$8);
|
9139 |
|
9140 | var Typeahead$1 = React.forwardRef(function (props, ref) {
|
9141 | return React__default.createElement(TypeaheadComponent, _extends({}, props, {
|
9142 | instanceRef: ref
|
9143 | }));
|
9144 | });
|
9145 |
|
9146 | var AsyncTypeahead = withAsync(Typeahead$1);
|
9147 |
|
9148 | exports.AsyncTypeahead = AsyncTypeahead;
|
9149 | exports.ClearButton = ClearButton;
|
9150 | exports.Highlighter = Highlighter;
|
9151 | exports.Hint = Hint;
|
9152 | exports.Input = Input;
|
9153 | exports.Loader = Loader;
|
9154 | exports.Menu = Menu;
|
9155 | exports.MenuItem = MenuItem;
|
9156 | exports.Token = Token$1;
|
9157 | exports.Typeahead = Typeahead$1;
|
9158 | exports.TypeaheadInputMulti = TypeaheadInputMulti$1;
|
9159 | exports.TypeaheadInputSingle = TypeaheadInputSingle;
|
9160 | exports.TypeaheadMenu = TypeaheadMenu;
|
9161 | exports.asyncContainer = asyncContainer;
|
9162 | exports.menuItemContainer = menuItemContainer;
|
9163 | exports.tokenContainer = tokenContainer;
|
9164 | exports.useAsync = useAsync;
|
9165 | exports.useHint = useHint;
|
9166 | exports.useItem = useItem;
|
9167 | exports.useToken = useToken;
|
9168 | exports.withAsync = withAsync;
|
9169 | exports.withItem = withItem;
|
9170 | exports.withToken = withToken;
|
9171 |
|
9172 | Object.defineProperty(exports, '__esModule', { value: true });
|
9173 |
|
9174 | })));
|