1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', { value: true });
|
4 |
|
5 | function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
6 |
|
7 | var slicedToArray = require('./slicedToArray-ef426d0f.js');
|
8 | require('./unsupportedIterableToArray-8a00e599.js');
|
9 | var React = require('react');
|
10 | var React__default = _interopDefault(React);
|
11 | require('./_commonjsHelpers-72d386ba.js');
|
12 | require('./index-b0606964.js');
|
13 | var defineProperty$1 = require('./defineProperty-0921a47c.js');
|
14 | var toConsumableArray = require('./toConsumableArray-7f36359f.js');
|
15 | var _styled = require('styled-components');
|
16 | var _styled__default = _interopDefault(_styled);
|
17 | var getPrototypeOf = require('./getPrototypeOf-e2d1e599.js');
|
18 | require('./color.js');
|
19 | var components = require('./components.js');
|
20 | require('./contains-component.js');
|
21 | require('./css.js');
|
22 | require('./dayjs.min-aa59a48e.js');
|
23 | require('./date.js');
|
24 | var miscellaneous = require('./miscellaneous.js');
|
25 | var environment = require('./environment.js');
|
26 | require('./font.js');
|
27 | require('./math-ecfd5d91.js');
|
28 | require('./characters.js');
|
29 | require('./format.js');
|
30 | var keycodes = require('./keycodes.js');
|
31 | require('./url.js');
|
32 | require('./web3.js');
|
33 | var constants = require('./constants.js');
|
34 | require('./breakpoints.js');
|
35 | var springs = require('./springs.js');
|
36 | require('./text-styles.js');
|
37 | require('./theme-dark.js');
|
38 | require('./theme-light.js');
|
39 | var Theme = require('./Theme.js');
|
40 | var _extends$1 = require('./extends-40571110.js');
|
41 | var objectWithoutProperties = require('./objectWithoutProperties-35db8ab0.js');
|
42 | require('./isObject-52908731.js');
|
43 | require('./Viewport-fe2db97a.js');
|
44 | require('./objectWithoutPropertiesLoose-1af20ad0.js');
|
45 | require('react-dom');
|
46 | var web = require('./web-d0294535.js');
|
47 | require('./getDisplayName-7ab6d318.js');
|
48 | require('./index-2b9f03ad.js');
|
49 | var index$1$1 = require('./index-5aaa52c3.js');
|
50 | var RootPortal = require('./RootPortal.js');
|
51 | var proptypes = require('./proptypes-956d3000.js');
|
52 | require('./observe.js');
|
53 | require('./index-904f69cc.js');
|
54 | require('./providers.js');
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 | var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && typeof navigator !== 'undefined';
|
81 |
|
82 | var timeoutDuration = function () {
|
83 | var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox'];
|
84 | for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) {
|
85 | if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) {
|
86 | return 1;
|
87 | }
|
88 | }
|
89 | return 0;
|
90 | }();
|
91 |
|
92 | function microtaskDebounce(fn) {
|
93 | var called = false;
|
94 | return function () {
|
95 | if (called) {
|
96 | return;
|
97 | }
|
98 | called = true;
|
99 | window.Promise.resolve().then(function () {
|
100 | called = false;
|
101 | fn();
|
102 | });
|
103 | };
|
104 | }
|
105 |
|
106 | function taskDebounce(fn) {
|
107 | var scheduled = false;
|
108 | return function () {
|
109 | if (!scheduled) {
|
110 | scheduled = true;
|
111 | setTimeout(function () {
|
112 | scheduled = false;
|
113 | fn();
|
114 | }, timeoutDuration);
|
115 | }
|
116 | };
|
117 | }
|
118 |
|
119 | var supportsMicroTasks = isBrowser && window.Promise;
|
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 |
|
130 | var debounce = supportsMicroTasks ? microtaskDebounce : taskDebounce;
|
131 |
|
132 |
|
133 |
|
134 |
|
135 |
|
136 |
|
137 |
|
138 |
|
139 | function isFunction(functionToCheck) {
|
140 | var getType = {};
|
141 | return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
|
142 | }
|
143 |
|
144 |
|
145 |
|
146 |
|
147 |
|
148 |
|
149 |
|
150 |
|
151 | function getStyleComputedProperty(element, property) {
|
152 | if (element.nodeType !== 1) {
|
153 | return [];
|
154 | }
|
155 |
|
156 | var window = element.ownerDocument.defaultView;
|
157 | var css = window.getComputedStyle(element, null);
|
158 | return property ? css[property] : css;
|
159 | }
|
160 |
|
161 |
|
162 |
|
163 |
|
164 |
|
165 |
|
166 |
|
167 |
|
168 | function getParentNode(element) {
|
169 | if (element.nodeName === 'HTML') {
|
170 | return element;
|
171 | }
|
172 | return element.parentNode || element.host;
|
173 | }
|
174 |
|
175 |
|
176 |
|
177 |
|
178 |
|
179 |
|
180 |
|
181 |
|
182 | function getScrollParent(element) {
|
183 |
|
184 | if (!element) {
|
185 | return document.body;
|
186 | }
|
187 |
|
188 | switch (element.nodeName) {
|
189 | case 'HTML':
|
190 | case 'BODY':
|
191 | return element.ownerDocument.body;
|
192 | case '#document':
|
193 | return element.body;
|
194 | }
|
195 |
|
196 |
|
197 |
|
198 | var _getStyleComputedProp = getStyleComputedProperty(element),
|
199 | overflow = _getStyleComputedProp.overflow,
|
200 | overflowX = _getStyleComputedProp.overflowX,
|
201 | overflowY = _getStyleComputedProp.overflowY;
|
202 |
|
203 | if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
|
204 | return element;
|
205 | }
|
206 |
|
207 | return getScrollParent(getParentNode(element));
|
208 | }
|
209 |
|
210 |
|
211 |
|
212 |
|
213 |
|
214 |
|
215 |
|
216 |
|
217 | function getReferenceNode(reference) {
|
218 | return reference && reference.referenceNode ? reference.referenceNode : reference;
|
219 | }
|
220 |
|
221 | var isIE11 = isBrowser && !!(window.MSInputMethodContext && document.documentMode);
|
222 | var isIE10 = isBrowser && /MSIE 10/.test(navigator.userAgent);
|
223 |
|
224 |
|
225 |
|
226 |
|
227 |
|
228 |
|
229 |
|
230 |
|
231 | function isIE(version) {
|
232 | if (version === 11) {
|
233 | return isIE11;
|
234 | }
|
235 | if (version === 10) {
|
236 | return isIE10;
|
237 | }
|
238 | return isIE11 || isIE10;
|
239 | }
|
240 |
|
241 |
|
242 |
|
243 |
|
244 |
|
245 |
|
246 |
|
247 |
|
248 | function getOffsetParent(element) {
|
249 | if (!element) {
|
250 | return document.documentElement;
|
251 | }
|
252 |
|
253 | var noOffsetParent = isIE(10) ? document.body : null;
|
254 |
|
255 |
|
256 | var offsetParent = element.offsetParent || null;
|
257 |
|
258 | while (offsetParent === noOffsetParent && element.nextElementSibling) {
|
259 | offsetParent = (element = element.nextElementSibling).offsetParent;
|
260 | }
|
261 |
|
262 | var nodeName = offsetParent && offsetParent.nodeName;
|
263 |
|
264 | if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {
|
265 | return element ? element.ownerDocument.documentElement : document.documentElement;
|
266 | }
|
267 |
|
268 |
|
269 |
|
270 | if (['TH', 'TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') {
|
271 | return getOffsetParent(offsetParent);
|
272 | }
|
273 |
|
274 | return offsetParent;
|
275 | }
|
276 |
|
277 | function isOffsetContainer(element) {
|
278 | var nodeName = element.nodeName;
|
279 |
|
280 | if (nodeName === 'BODY') {
|
281 | return false;
|
282 | }
|
283 | return nodeName === 'HTML' || getOffsetParent(element.firstElementChild) === element;
|
284 | }
|
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 |
|
291 |
|
292 |
|
293 | function getRoot(node) {
|
294 | if (node.parentNode !== null) {
|
295 | return getRoot(node.parentNode);
|
296 | }
|
297 |
|
298 | return node;
|
299 | }
|
300 |
|
301 |
|
302 |
|
303 |
|
304 |
|
305 |
|
306 |
|
307 |
|
308 |
|
309 | function findCommonOffsetParent(element1, element2) {
|
310 |
|
311 | if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) {
|
312 | return document.documentElement;
|
313 | }
|
314 |
|
315 |
|
316 | var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING;
|
317 | var start = order ? element1 : element2;
|
318 | var end = order ? element2 : element1;
|
319 |
|
320 |
|
321 | var range = document.createRange();
|
322 | range.setStart(start, 0);
|
323 | range.setEnd(end, 0);
|
324 | var commonAncestorContainer = range.commonAncestorContainer;
|
325 |
|
326 |
|
327 |
|
328 | if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) {
|
329 | if (isOffsetContainer(commonAncestorContainer)) {
|
330 | return commonAncestorContainer;
|
331 | }
|
332 |
|
333 | return getOffsetParent(commonAncestorContainer);
|
334 | }
|
335 |
|
336 |
|
337 | var element1root = getRoot(element1);
|
338 | if (element1root.host) {
|
339 | return findCommonOffsetParent(element1root.host, element2);
|
340 | } else {
|
341 | return findCommonOffsetParent(element1, getRoot(element2).host);
|
342 | }
|
343 | }
|
344 |
|
345 |
|
346 |
|
347 |
|
348 |
|
349 |
|
350 |
|
351 |
|
352 |
|
353 | function getScroll(element) {
|
354 | var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top';
|
355 |
|
356 | var upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft';
|
357 | var nodeName = element.nodeName;
|
358 |
|
359 | if (nodeName === 'BODY' || nodeName === 'HTML') {
|
360 | var html = element.ownerDocument.documentElement;
|
361 | var scrollingElement = element.ownerDocument.scrollingElement || html;
|
362 | return scrollingElement[upperSide];
|
363 | }
|
364 |
|
365 | return element[upperSide];
|
366 | }
|
367 |
|
368 |
|
369 |
|
370 |
|
371 |
|
372 |
|
373 |
|
374 |
|
375 |
|
376 |
|
377 | function includeScroll(rect, element) {
|
378 | var subtract = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
379 |
|
380 | var scrollTop = getScroll(element, 'top');
|
381 | var scrollLeft = getScroll(element, 'left');
|
382 | var modifier = subtract ? -1 : 1;
|
383 | rect.top += scrollTop * modifier;
|
384 | rect.bottom += scrollTop * modifier;
|
385 | rect.left += scrollLeft * modifier;
|
386 | rect.right += scrollLeft * modifier;
|
387 | return rect;
|
388 | }
|
389 |
|
390 |
|
391 |
|
392 |
|
393 |
|
394 |
|
395 |
|
396 |
|
397 |
|
398 |
|
399 |
|
400 | function getBordersSize(styles, axis) {
|
401 | var sideA = axis === 'x' ? 'Left' : 'Top';
|
402 | var sideB = sideA === 'Left' ? 'Right' : 'Bottom';
|
403 |
|
404 | return parseFloat(styles['border' + sideA + 'Width']) + parseFloat(styles['border' + sideB + 'Width']);
|
405 | }
|
406 |
|
407 | function getSize(axis, body, html, computedStyle) {
|
408 | 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);
|
409 | }
|
410 |
|
411 | function getWindowSizes(document) {
|
412 | var body = document.body;
|
413 | var html = document.documentElement;
|
414 | var computedStyle = isIE(10) && getComputedStyle(html);
|
415 |
|
416 | return {
|
417 | height: getSize('Height', body, html, computedStyle),
|
418 | width: getSize('Width', body, html, computedStyle)
|
419 | };
|
420 | }
|
421 |
|
422 | var classCallCheck = function (instance, Constructor) {
|
423 | if (!(instance instanceof Constructor)) {
|
424 | throw new TypeError("Cannot call a class as a function");
|
425 | }
|
426 | };
|
427 |
|
428 | var createClass = function () {
|
429 | function defineProperties(target, props) {
|
430 | for (var i = 0; i < props.length; i++) {
|
431 | var descriptor = props[i];
|
432 | descriptor.enumerable = descriptor.enumerable || false;
|
433 | descriptor.configurable = true;
|
434 | if ("value" in descriptor) descriptor.writable = true;
|
435 | Object.defineProperty(target, descriptor.key, descriptor);
|
436 | }
|
437 | }
|
438 |
|
439 | return function (Constructor, protoProps, staticProps) {
|
440 | if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
441 | if (staticProps) defineProperties(Constructor, staticProps);
|
442 | return Constructor;
|
443 | };
|
444 | }();
|
445 |
|
446 |
|
447 |
|
448 |
|
449 |
|
450 | var defineProperty = function (obj, key, value) {
|
451 | if (key in obj) {
|
452 | Object.defineProperty(obj, key, {
|
453 | value: value,
|
454 | enumerable: true,
|
455 | configurable: true,
|
456 | writable: true
|
457 | });
|
458 | } else {
|
459 | obj[key] = value;
|
460 | }
|
461 |
|
462 | return obj;
|
463 | };
|
464 |
|
465 | var _extends = Object.assign || function (target) {
|
466 | for (var i = 1; i < arguments.length; i++) {
|
467 | var source = arguments[i];
|
468 |
|
469 | for (var key in source) {
|
470 | if (Object.prototype.hasOwnProperty.call(source, key)) {
|
471 | target[key] = source[key];
|
472 | }
|
473 | }
|
474 | }
|
475 |
|
476 | return target;
|
477 | };
|
478 |
|
479 |
|
480 |
|
481 |
|
482 |
|
483 |
|
484 |
|
485 |
|
486 | function getClientRect(offsets) {
|
487 | return _extends({}, offsets, {
|
488 | right: offsets.left + offsets.width,
|
489 | bottom: offsets.top + offsets.height
|
490 | });
|
491 | }
|
492 |
|
493 |
|
494 |
|
495 |
|
496 |
|
497 |
|
498 |
|
499 |
|
500 | function getBoundingClientRect(element) {
|
501 | var rect = {};
|
502 |
|
503 |
|
504 |
|
505 |
|
506 | try {
|
507 | if (isIE(10)) {
|
508 | rect = element.getBoundingClientRect();
|
509 | var scrollTop = getScroll(element, 'top');
|
510 | var scrollLeft = getScroll(element, 'left');
|
511 | rect.top += scrollTop;
|
512 | rect.left += scrollLeft;
|
513 | rect.bottom += scrollTop;
|
514 | rect.right += scrollLeft;
|
515 | } else {
|
516 | rect = element.getBoundingClientRect();
|
517 | }
|
518 | } catch (e) {}
|
519 |
|
520 | var result = {
|
521 | left: rect.left,
|
522 | top: rect.top,
|
523 | width: rect.right - rect.left,
|
524 | height: rect.bottom - rect.top
|
525 | };
|
526 |
|
527 |
|
528 | var sizes = element.nodeName === 'HTML' ? getWindowSizes(element.ownerDocument) : {};
|
529 | var width = sizes.width || element.clientWidth || result.width;
|
530 | var height = sizes.height || element.clientHeight || result.height;
|
531 |
|
532 | var horizScrollbar = element.offsetWidth - width;
|
533 | var vertScrollbar = element.offsetHeight - height;
|
534 |
|
535 |
|
536 |
|
537 | if (horizScrollbar || vertScrollbar) {
|
538 | var styles = getStyleComputedProperty(element);
|
539 | horizScrollbar -= getBordersSize(styles, 'x');
|
540 | vertScrollbar -= getBordersSize(styles, 'y');
|
541 |
|
542 | result.width -= horizScrollbar;
|
543 | result.height -= vertScrollbar;
|
544 | }
|
545 |
|
546 | return getClientRect(result);
|
547 | }
|
548 |
|
549 | function getOffsetRectRelativeToArbitraryNode(children, parent) {
|
550 | var fixedPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
551 |
|
552 | var isIE10 = isIE(10);
|
553 | var isHTML = parent.nodeName === 'HTML';
|
554 | var childrenRect = getBoundingClientRect(children);
|
555 | var parentRect = getBoundingClientRect(parent);
|
556 | var scrollParent = getScrollParent(children);
|
557 |
|
558 | var styles = getStyleComputedProperty(parent);
|
559 | var borderTopWidth = parseFloat(styles.borderTopWidth);
|
560 | var borderLeftWidth = parseFloat(styles.borderLeftWidth);
|
561 |
|
562 |
|
563 | if (fixedPosition && isHTML) {
|
564 | parentRect.top = Math.max(parentRect.top, 0);
|
565 | parentRect.left = Math.max(parentRect.left, 0);
|
566 | }
|
567 | var offsets = getClientRect({
|
568 | top: childrenRect.top - parentRect.top - borderTopWidth,
|
569 | left: childrenRect.left - parentRect.left - borderLeftWidth,
|
570 | width: childrenRect.width,
|
571 | height: childrenRect.height
|
572 | });
|
573 | offsets.marginTop = 0;
|
574 | offsets.marginLeft = 0;
|
575 |
|
576 |
|
577 |
|
578 |
|
579 |
|
580 | if (!isIE10 && isHTML) {
|
581 | var marginTop = parseFloat(styles.marginTop);
|
582 | var marginLeft = parseFloat(styles.marginLeft);
|
583 |
|
584 | offsets.top -= borderTopWidth - marginTop;
|
585 | offsets.bottom -= borderTopWidth - marginTop;
|
586 | offsets.left -= borderLeftWidth - marginLeft;
|
587 | offsets.right -= borderLeftWidth - marginLeft;
|
588 |
|
589 |
|
590 | offsets.marginTop = marginTop;
|
591 | offsets.marginLeft = marginLeft;
|
592 | }
|
593 |
|
594 | if (isIE10 && !fixedPosition ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') {
|
595 | offsets = includeScroll(offsets, parent);
|
596 | }
|
597 |
|
598 | return offsets;
|
599 | }
|
600 |
|
601 | function getViewportOffsetRectRelativeToArtbitraryNode(element) {
|
602 | var excludeScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
603 |
|
604 | var html = element.ownerDocument.documentElement;
|
605 | var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html);
|
606 | var width = Math.max(html.clientWidth, window.innerWidth || 0);
|
607 | var height = Math.max(html.clientHeight, window.innerHeight || 0);
|
608 |
|
609 | var scrollTop = !excludeScroll ? getScroll(html) : 0;
|
610 | var scrollLeft = !excludeScroll ? getScroll(html, 'left') : 0;
|
611 |
|
612 | var offset = {
|
613 | top: scrollTop - relativeOffset.top + relativeOffset.marginTop,
|
614 | left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft,
|
615 | width: width,
|
616 | height: height
|
617 | };
|
618 |
|
619 | return getClientRect(offset);
|
620 | }
|
621 |
|
622 |
|
623 |
|
624 |
|
625 |
|
626 |
|
627 |
|
628 |
|
629 |
|
630 | function isFixed(element) {
|
631 | var nodeName = element.nodeName;
|
632 | if (nodeName === 'BODY' || nodeName === 'HTML') {
|
633 | return false;
|
634 | }
|
635 | if (getStyleComputedProperty(element, 'position') === 'fixed') {
|
636 | return true;
|
637 | }
|
638 | var parentNode = getParentNode(element);
|
639 | if (!parentNode) {
|
640 | return false;
|
641 | }
|
642 | return isFixed(parentNode);
|
643 | }
|
644 |
|
645 |
|
646 |
|
647 |
|
648 |
|
649 |
|
650 |
|
651 |
|
652 |
|
653 | function getFixedPositionOffsetParent(element) {
|
654 |
|
655 | if (!element || !element.parentElement || isIE()) {
|
656 | return document.documentElement;
|
657 | }
|
658 | var el = element.parentElement;
|
659 | while (el && getStyleComputedProperty(el, 'transform') === 'none') {
|
660 | el = el.parentElement;
|
661 | }
|
662 | return el || document.documentElement;
|
663 | }
|
664 |
|
665 |
|
666 |
|
667 |
|
668 |
|
669 |
|
670 |
|
671 |
|
672 |
|
673 |
|
674 |
|
675 |
|
676 | function getBoundaries(popper, reference, padding, boundariesElement) {
|
677 | var fixedPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
678 |
|
679 |
|
680 |
|
681 | var boundaries = { top: 0, left: 0 };
|
682 | var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
|
683 |
|
684 |
|
685 | if (boundariesElement === 'viewport') {
|
686 | boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition);
|
687 | } else {
|
688 |
|
689 | var boundariesNode = void 0;
|
690 | if (boundariesElement === 'scrollParent') {
|
691 | boundariesNode = getScrollParent(getParentNode(reference));
|
692 | if (boundariesNode.nodeName === 'BODY') {
|
693 | boundariesNode = popper.ownerDocument.documentElement;
|
694 | }
|
695 | } else if (boundariesElement === 'window') {
|
696 | boundariesNode = popper.ownerDocument.documentElement;
|
697 | } else {
|
698 | boundariesNode = boundariesElement;
|
699 | }
|
700 |
|
701 | var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent, fixedPosition);
|
702 |
|
703 |
|
704 | if (boundariesNode.nodeName === 'HTML' && !isFixed(offsetParent)) {
|
705 | var _getWindowSizes = getWindowSizes(popper.ownerDocument),
|
706 | height = _getWindowSizes.height,
|
707 | width = _getWindowSizes.width;
|
708 |
|
709 | boundaries.top += offsets.top - offsets.marginTop;
|
710 | boundaries.bottom = height + offsets.top;
|
711 | boundaries.left += offsets.left - offsets.marginLeft;
|
712 | boundaries.right = width + offsets.left;
|
713 | } else {
|
714 |
|
715 | boundaries = offsets;
|
716 | }
|
717 | }
|
718 |
|
719 |
|
720 | padding = padding || 0;
|
721 | var isPaddingNumber = typeof padding === 'number';
|
722 | boundaries.left += isPaddingNumber ? padding : padding.left || 0;
|
723 | boundaries.top += isPaddingNumber ? padding : padding.top || 0;
|
724 | boundaries.right -= isPaddingNumber ? padding : padding.right || 0;
|
725 | boundaries.bottom -= isPaddingNumber ? padding : padding.bottom || 0;
|
726 |
|
727 | return boundaries;
|
728 | }
|
729 |
|
730 | function getArea(_ref) {
|
731 | var width = _ref.width,
|
732 | height = _ref.height;
|
733 |
|
734 | return width * height;
|
735 | }
|
736 |
|
737 |
|
738 |
|
739 |
|
740 |
|
741 |
|
742 |
|
743 |
|
744 |
|
745 |
|
746 | function computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) {
|
747 | var padding = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
|
748 |
|
749 | if (placement.indexOf('auto') === -1) {
|
750 | return placement;
|
751 | }
|
752 |
|
753 | var boundaries = getBoundaries(popper, reference, padding, boundariesElement);
|
754 |
|
755 | var rects = {
|
756 | top: {
|
757 | width: boundaries.width,
|
758 | height: refRect.top - boundaries.top
|
759 | },
|
760 | right: {
|
761 | width: boundaries.right - refRect.right,
|
762 | height: boundaries.height
|
763 | },
|
764 | bottom: {
|
765 | width: boundaries.width,
|
766 | height: boundaries.bottom - refRect.bottom
|
767 | },
|
768 | left: {
|
769 | width: refRect.left - boundaries.left,
|
770 | height: boundaries.height
|
771 | }
|
772 | };
|
773 |
|
774 | var sortedAreas = Object.keys(rects).map(function (key) {
|
775 | return _extends({
|
776 | key: key
|
777 | }, rects[key], {
|
778 | area: getArea(rects[key])
|
779 | });
|
780 | }).sort(function (a, b) {
|
781 | return b.area - a.area;
|
782 | });
|
783 |
|
784 | var filteredAreas = sortedAreas.filter(function (_ref2) {
|
785 | var width = _ref2.width,
|
786 | height = _ref2.height;
|
787 | return width >= popper.clientWidth && height >= popper.clientHeight;
|
788 | });
|
789 |
|
790 | var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key;
|
791 |
|
792 | var variation = placement.split('-')[1];
|
793 |
|
794 | return computedPlacement + (variation ? '-' + variation : '');
|
795 | }
|
796 |
|
797 |
|
798 |
|
799 |
|
800 |
|
801 |
|
802 |
|
803 |
|
804 |
|
805 |
|
806 |
|
807 | function getReferenceOffsets(state, popper, reference) {
|
808 | var fixedPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
809 |
|
810 | var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
|
811 | return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition);
|
812 | }
|
813 |
|
814 |
|
815 |
|
816 |
|
817 |
|
818 |
|
819 |
|
820 |
|
821 | function getOuterSizes(element) {
|
822 | var window = element.ownerDocument.defaultView;
|
823 | var styles = window.getComputedStyle(element);
|
824 | var x = parseFloat(styles.marginTop || 0) + parseFloat(styles.marginBottom || 0);
|
825 | var y = parseFloat(styles.marginLeft || 0) + parseFloat(styles.marginRight || 0);
|
826 | var result = {
|
827 | width: element.offsetWidth + y,
|
828 | height: element.offsetHeight + x
|
829 | };
|
830 | return result;
|
831 | }
|
832 |
|
833 |
|
834 |
|
835 |
|
836 |
|
837 |
|
838 |
|
839 |
|
840 | function getOppositePlacement(placement) {
|
841 | var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
|
842 | return placement.replace(/left|right|bottom|top/g, function (matched) {
|
843 | return hash[matched];
|
844 | });
|
845 | }
|
846 |
|
847 |
|
848 |
|
849 |
|
850 |
|
851 |
|
852 |
|
853 |
|
854 |
|
855 |
|
856 |
|
857 | function getPopperOffsets(popper, referenceOffsets, placement) {
|
858 | placement = placement.split('-')[0];
|
859 |
|
860 |
|
861 | var popperRect = getOuterSizes(popper);
|
862 |
|
863 |
|
864 | var popperOffsets = {
|
865 | width: popperRect.width,
|
866 | height: popperRect.height
|
867 | };
|
868 |
|
869 |
|
870 | var isHoriz = ['right', 'left'].indexOf(placement) !== -1;
|
871 | var mainSide = isHoriz ? 'top' : 'left';
|
872 | var secondarySide = isHoriz ? 'left' : 'top';
|
873 | var measurement = isHoriz ? 'height' : 'width';
|
874 | var secondaryMeasurement = !isHoriz ? 'height' : 'width';
|
875 |
|
876 | popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2;
|
877 | if (placement === secondarySide) {
|
878 | popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement];
|
879 | } else {
|
880 | popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement(secondarySide)];
|
881 | }
|
882 |
|
883 | return popperOffsets;
|
884 | }
|
885 |
|
886 |
|
887 |
|
888 |
|
889 |
|
890 |
|
891 |
|
892 |
|
893 |
|
894 |
|
895 | function find(arr, check) {
|
896 |
|
897 | if (Array.prototype.find) {
|
898 | return arr.find(check);
|
899 | }
|
900 |
|
901 |
|
902 | return arr.filter(check)[0];
|
903 | }
|
904 |
|
905 |
|
906 |
|
907 |
|
908 |
|
909 |
|
910 |
|
911 |
|
912 |
|
913 |
|
914 | function findIndex(arr, prop, value) {
|
915 |
|
916 | if (Array.prototype.findIndex) {
|
917 | return arr.findIndex(function (cur) {
|
918 | return cur[prop] === value;
|
919 | });
|
920 | }
|
921 |
|
922 |
|
923 | var match = find(arr, function (obj) {
|
924 | return obj[prop] === value;
|
925 | });
|
926 | return arr.indexOf(match);
|
927 | }
|
928 |
|
929 |
|
930 |
|
931 |
|
932 |
|
933 |
|
934 |
|
935 |
|
936 |
|
937 |
|
938 |
|
939 | function runModifiers(modifiers, data, ends) {
|
940 | var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends));
|
941 |
|
942 | modifiersToRun.forEach(function (modifier) {
|
943 | if (modifier['function']) {
|
944 |
|
945 | console.warn('`modifier.function` is deprecated, use `modifier.fn`!');
|
946 | }
|
947 | var fn = modifier['function'] || modifier.fn;
|
948 | if (modifier.enabled && isFunction(fn)) {
|
949 |
|
950 |
|
951 |
|
952 | data.offsets.popper = getClientRect(data.offsets.popper);
|
953 | data.offsets.reference = getClientRect(data.offsets.reference);
|
954 |
|
955 | data = fn(data, modifier);
|
956 | }
|
957 | });
|
958 |
|
959 | return data;
|
960 | }
|
961 |
|
962 |
|
963 |
|
964 |
|
965 |
|
966 |
|
967 |
|
968 |
|
969 | function update() {
|
970 |
|
971 | if (this.state.isDestroyed) {
|
972 | return;
|
973 | }
|
974 |
|
975 | var data = {
|
976 | instance: this,
|
977 | styles: {},
|
978 | arrowStyles: {},
|
979 | attributes: {},
|
980 | flipped: false,
|
981 | offsets: {}
|
982 | };
|
983 |
|
984 |
|
985 | data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference, this.options.positionFixed);
|
986 |
|
987 |
|
988 |
|
989 |
|
990 | data.placement = computeAutoPlacement(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding);
|
991 |
|
992 |
|
993 | data.originalPlacement = data.placement;
|
994 |
|
995 | data.positionFixed = this.options.positionFixed;
|
996 |
|
997 |
|
998 | data.offsets.popper = getPopperOffsets(this.popper, data.offsets.reference, data.placement);
|
999 |
|
1000 | data.offsets.popper.position = this.options.positionFixed ? 'fixed' : 'absolute';
|
1001 |
|
1002 |
|
1003 | data = runModifiers(this.modifiers, data);
|
1004 |
|
1005 |
|
1006 |
|
1007 | if (!this.state.isCreated) {
|
1008 | this.state.isCreated = true;
|
1009 | this.options.onCreate(data);
|
1010 | } else {
|
1011 | this.options.onUpdate(data);
|
1012 | }
|
1013 | }
|
1014 |
|
1015 |
|
1016 |
|
1017 |
|
1018 |
|
1019 |
|
1020 |
|
1021 | function isModifierEnabled(modifiers, modifierName) {
|
1022 | return modifiers.some(function (_ref) {
|
1023 | var name = _ref.name,
|
1024 | enabled = _ref.enabled;
|
1025 | return enabled && name === modifierName;
|
1026 | });
|
1027 | }
|
1028 |
|
1029 |
|
1030 |
|
1031 |
|
1032 |
|
1033 |
|
1034 |
|
1035 |
|
1036 | function getSupportedPropertyName(property) {
|
1037 | var prefixes = [false, 'ms', 'Webkit', 'Moz', 'O'];
|
1038 | var upperProp = property.charAt(0).toUpperCase() + property.slice(1);
|
1039 |
|
1040 | for (var i = 0; i < prefixes.length; i++) {
|
1041 | var prefix = prefixes[i];
|
1042 | var toCheck = prefix ? '' + prefix + upperProp : property;
|
1043 | if (typeof document.body.style[toCheck] !== 'undefined') {
|
1044 | return toCheck;
|
1045 | }
|
1046 | }
|
1047 | return null;
|
1048 | }
|
1049 |
|
1050 |
|
1051 |
|
1052 |
|
1053 |
|
1054 |
|
1055 | function destroy() {
|
1056 | this.state.isDestroyed = true;
|
1057 |
|
1058 |
|
1059 | if (isModifierEnabled(this.modifiers, 'applyStyle')) {
|
1060 | this.popper.removeAttribute('x-placement');
|
1061 | this.popper.style.position = '';
|
1062 | this.popper.style.top = '';
|
1063 | this.popper.style.left = '';
|
1064 | this.popper.style.right = '';
|
1065 | this.popper.style.bottom = '';
|
1066 | this.popper.style.willChange = '';
|
1067 | this.popper.style[getSupportedPropertyName('transform')] = '';
|
1068 | }
|
1069 |
|
1070 | this.disableEventListeners();
|
1071 |
|
1072 |
|
1073 |
|
1074 | if (this.options.removeOnDestroy) {
|
1075 | this.popper.parentNode.removeChild(this.popper);
|
1076 | }
|
1077 | return this;
|
1078 | }
|
1079 |
|
1080 |
|
1081 |
|
1082 |
|
1083 |
|
1084 |
|
1085 | function getWindow(element) {
|
1086 | var ownerDocument = element.ownerDocument;
|
1087 | return ownerDocument ? ownerDocument.defaultView : window;
|
1088 | }
|
1089 |
|
1090 | function attachToScrollParents(scrollParent, event, callback, scrollParents) {
|
1091 | var isBody = scrollParent.nodeName === 'BODY';
|
1092 | var target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent;
|
1093 | target.addEventListener(event, callback, { passive: true });
|
1094 |
|
1095 | if (!isBody) {
|
1096 | attachToScrollParents(getScrollParent(target.parentNode), event, callback, scrollParents);
|
1097 | }
|
1098 | scrollParents.push(target);
|
1099 | }
|
1100 |
|
1101 |
|
1102 |
|
1103 |
|
1104 |
|
1105 |
|
1106 |
|
1107 | function setupEventListeners(reference, options, state, updateBound) {
|
1108 |
|
1109 | state.updateBound = updateBound;
|
1110 | getWindow(reference).addEventListener('resize', state.updateBound, { passive: true });
|
1111 |
|
1112 |
|
1113 | var scrollElement = getScrollParent(reference);
|
1114 | attachToScrollParents(scrollElement, 'scroll', state.updateBound, state.scrollParents);
|
1115 | state.scrollElement = scrollElement;
|
1116 | state.eventsEnabled = true;
|
1117 |
|
1118 | return state;
|
1119 | }
|
1120 |
|
1121 |
|
1122 |
|
1123 |
|
1124 |
|
1125 |
|
1126 |
|
1127 | function enableEventListeners() {
|
1128 | if (!this.state.eventsEnabled) {
|
1129 | this.state = setupEventListeners(this.reference, this.options, this.state, this.scheduleUpdate);
|
1130 | }
|
1131 | }
|
1132 |
|
1133 |
|
1134 |
|
1135 |
|
1136 |
|
1137 |
|
1138 |
|
1139 | function removeEventListeners(reference, state) {
|
1140 |
|
1141 | getWindow(reference).removeEventListener('resize', state.updateBound);
|
1142 |
|
1143 |
|
1144 | state.scrollParents.forEach(function (target) {
|
1145 | target.removeEventListener('scroll', state.updateBound);
|
1146 | });
|
1147 |
|
1148 |
|
1149 | state.updateBound = null;
|
1150 | state.scrollParents = [];
|
1151 | state.scrollElement = null;
|
1152 | state.eventsEnabled = false;
|
1153 | return state;
|
1154 | }
|
1155 |
|
1156 |
|
1157 |
|
1158 |
|
1159 |
|
1160 |
|
1161 |
|
1162 |
|
1163 | function disableEventListeners() {
|
1164 | if (this.state.eventsEnabled) {
|
1165 | cancelAnimationFrame(this.scheduleUpdate);
|
1166 | this.state = removeEventListeners(this.reference, this.state);
|
1167 | }
|
1168 | }
|
1169 |
|
1170 |
|
1171 |
|
1172 |
|
1173 |
|
1174 |
|
1175 |
|
1176 |
|
1177 | function isNumeric(n) {
|
1178 | return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
|
1179 | }
|
1180 |
|
1181 |
|
1182 |
|
1183 |
|
1184 |
|
1185 |
|
1186 |
|
1187 |
|
1188 |
|
1189 | function setStyles(element, styles) {
|
1190 | Object.keys(styles).forEach(function (prop) {
|
1191 | var unit = '';
|
1192 |
|
1193 | if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && isNumeric(styles[prop])) {
|
1194 | unit = 'px';
|
1195 | }
|
1196 | element.style[prop] = styles[prop] + unit;
|
1197 | });
|
1198 | }
|
1199 |
|
1200 |
|
1201 |
|
1202 |
|
1203 |
|
1204 |
|
1205 |
|
1206 |
|
1207 |
|
1208 | function setAttributes(element, attributes) {
|
1209 | Object.keys(attributes).forEach(function (prop) {
|
1210 | var value = attributes[prop];
|
1211 | if (value !== false) {
|
1212 | element.setAttribute(prop, attributes[prop]);
|
1213 | } else {
|
1214 | element.removeAttribute(prop);
|
1215 | }
|
1216 | });
|
1217 | }
|
1218 |
|
1219 |
|
1220 |
|
1221 |
|
1222 |
|
1223 |
|
1224 |
|
1225 |
|
1226 |
|
1227 |
|
1228 | function applyStyle(data) {
|
1229 |
|
1230 |
|
1231 |
|
1232 |
|
1233 | setStyles(data.instance.popper, data.styles);
|
1234 |
|
1235 |
|
1236 |
|
1237 | setAttributes(data.instance.popper, data.attributes);
|
1238 |
|
1239 |
|
1240 | if (data.arrowElement && Object.keys(data.arrowStyles).length) {
|
1241 | setStyles(data.arrowElement, data.arrowStyles);
|
1242 | }
|
1243 |
|
1244 | return data;
|
1245 | }
|
1246 |
|
1247 |
|
1248 |
|
1249 |
|
1250 |
|
1251 |
|
1252 |
|
1253 |
|
1254 |
|
1255 |
|
1256 |
|
1257 | function applyStyleOnLoad(reference, popper, options, modifierOptions, state) {
|
1258 |
|
1259 | var referenceOffsets = getReferenceOffsets(state, popper, reference, options.positionFixed);
|
1260 |
|
1261 |
|
1262 |
|
1263 |
|
1264 | var placement = computeAutoPlacement(options.placement, referenceOffsets, popper, reference, options.modifiers.flip.boundariesElement, options.modifiers.flip.padding);
|
1265 |
|
1266 | popper.setAttribute('x-placement', placement);
|
1267 |
|
1268 |
|
1269 |
|
1270 | setStyles(popper, { position: options.positionFixed ? 'fixed' : 'absolute' });
|
1271 |
|
1272 | return options;
|
1273 | }
|
1274 |
|
1275 |
|
1276 |
|
1277 |
|
1278 |
|
1279 |
|
1280 |
|
1281 |
|
1282 |
|
1283 |
|
1284 |
|
1285 |
|
1286 |
|
1287 |
|
1288 |
|
1289 |
|
1290 |
|
1291 |
|
1292 |
|
1293 |
|
1294 | function getRoundedOffsets(data, shouldRound) {
|
1295 | var _data$offsets = data.offsets,
|
1296 | popper = _data$offsets.popper,
|
1297 | reference = _data$offsets.reference;
|
1298 | var round = Math.round,
|
1299 | floor = Math.floor;
|
1300 |
|
1301 | var noRound = function noRound(v) {
|
1302 | return v;
|
1303 | };
|
1304 |
|
1305 | var referenceWidth = round(reference.width);
|
1306 | var popperWidth = round(popper.width);
|
1307 |
|
1308 | var isVertical = ['left', 'right'].indexOf(data.placement) !== -1;
|
1309 | var isVariation = data.placement.indexOf('-') !== -1;
|
1310 | var sameWidthParity = referenceWidth % 2 === popperWidth % 2;
|
1311 | var bothOddWidth = referenceWidth % 2 === 1 && popperWidth % 2 === 1;
|
1312 |
|
1313 | var horizontalToInteger = !shouldRound ? noRound : isVertical || isVariation || sameWidthParity ? round : floor;
|
1314 | var verticalToInteger = !shouldRound ? noRound : round;
|
1315 |
|
1316 | return {
|
1317 | left: horizontalToInteger(bothOddWidth && !isVariation && shouldRound ? popper.left - 1 : popper.left),
|
1318 | top: verticalToInteger(popper.top),
|
1319 | bottom: verticalToInteger(popper.bottom),
|
1320 | right: horizontalToInteger(popper.right)
|
1321 | };
|
1322 | }
|
1323 |
|
1324 | var isFirefox = isBrowser && /Firefox/i.test(navigator.userAgent);
|
1325 |
|
1326 |
|
1327 |
|
1328 |
|
1329 |
|
1330 |
|
1331 |
|
1332 |
|
1333 | function computeStyle(data, options) {
|
1334 | var x = options.x,
|
1335 | y = options.y;
|
1336 | var popper = data.offsets.popper;
|
1337 |
|
1338 |
|
1339 |
|
1340 | var legacyGpuAccelerationOption = find(data.instance.modifiers, function (modifier) {
|
1341 | return modifier.name === 'applyStyle';
|
1342 | }).gpuAcceleration;
|
1343 | if (legacyGpuAccelerationOption !== undefined) {
|
1344 | console.warn('WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!');
|
1345 | }
|
1346 | var gpuAcceleration = legacyGpuAccelerationOption !== undefined ? legacyGpuAccelerationOption : options.gpuAcceleration;
|
1347 |
|
1348 | var offsetParent = getOffsetParent(data.instance.popper);
|
1349 | var offsetParentRect = getBoundingClientRect(offsetParent);
|
1350 |
|
1351 |
|
1352 | var styles = {
|
1353 | position: popper.position
|
1354 | };
|
1355 |
|
1356 | var offsets = getRoundedOffsets(data, window.devicePixelRatio < 2 || !isFirefox);
|
1357 |
|
1358 | var sideA = x === 'bottom' ? 'top' : 'bottom';
|
1359 | var sideB = y === 'right' ? 'left' : 'right';
|
1360 |
|
1361 |
|
1362 |
|
1363 |
|
1364 | var prefixedProperty = getSupportedPropertyName('transform');
|
1365 |
|
1366 |
|
1367 |
|
1368 |
|
1369 |
|
1370 |
|
1371 |
|
1372 |
|
1373 |
|
1374 |
|
1375 | var left = void 0,
|
1376 | top = void 0;
|
1377 | if (sideA === 'bottom') {
|
1378 |
|
1379 |
|
1380 | if (offsetParent.nodeName === 'HTML') {
|
1381 | top = -offsetParent.clientHeight + offsets.bottom;
|
1382 | } else {
|
1383 | top = -offsetParentRect.height + offsets.bottom;
|
1384 | }
|
1385 | } else {
|
1386 | top = offsets.top;
|
1387 | }
|
1388 | if (sideB === 'right') {
|
1389 | if (offsetParent.nodeName === 'HTML') {
|
1390 | left = -offsetParent.clientWidth + offsets.right;
|
1391 | } else {
|
1392 | left = -offsetParentRect.width + offsets.right;
|
1393 | }
|
1394 | } else {
|
1395 | left = offsets.left;
|
1396 | }
|
1397 | if (gpuAcceleration && prefixedProperty) {
|
1398 | styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';
|
1399 | styles[sideA] = 0;
|
1400 | styles[sideB] = 0;
|
1401 | styles.willChange = 'transform';
|
1402 | } else {
|
1403 |
|
1404 | var invertTop = sideA === 'bottom' ? -1 : 1;
|
1405 | var invertLeft = sideB === 'right' ? -1 : 1;
|
1406 | styles[sideA] = top * invertTop;
|
1407 | styles[sideB] = left * invertLeft;
|
1408 | styles.willChange = sideA + ', ' + sideB;
|
1409 | }
|
1410 |
|
1411 |
|
1412 | var attributes = {
|
1413 | 'x-placement': data.placement
|
1414 | };
|
1415 |
|
1416 |
|
1417 | data.attributes = _extends({}, attributes, data.attributes);
|
1418 | data.styles = _extends({}, styles, data.styles);
|
1419 | data.arrowStyles = _extends({}, data.offsets.arrow, data.arrowStyles);
|
1420 |
|
1421 | return data;
|
1422 | }
|
1423 |
|
1424 |
|
1425 |
|
1426 |
|
1427 |
|
1428 |
|
1429 |
|
1430 |
|
1431 |
|
1432 |
|
1433 |
|
1434 | function isModifierRequired(modifiers, requestingName, requestedName) {
|
1435 | var requesting = find(modifiers, function (_ref) {
|
1436 | var name = _ref.name;
|
1437 | return name === requestingName;
|
1438 | });
|
1439 |
|
1440 | var isRequired = !!requesting && modifiers.some(function (modifier) {
|
1441 | return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order;
|
1442 | });
|
1443 |
|
1444 | if (!isRequired) {
|
1445 | var _requesting = '`' + requestingName + '`';
|
1446 | var requested = '`' + requestedName + '`';
|
1447 | console.warn(requested + ' modifier is required by ' + _requesting + ' modifier in order to work, be sure to include it before ' + _requesting + '!');
|
1448 | }
|
1449 | return isRequired;
|
1450 | }
|
1451 |
|
1452 |
|
1453 |
|
1454 |
|
1455 |
|
1456 |
|
1457 |
|
1458 |
|
1459 | function arrow(data, options) {
|
1460 | var _data$offsets$arrow;
|
1461 |
|
1462 |
|
1463 | if (!isModifierRequired(data.instance.modifiers, 'arrow', 'keepTogether')) {
|
1464 | return data;
|
1465 | }
|
1466 |
|
1467 | var arrowElement = options.element;
|
1468 |
|
1469 |
|
1470 | if (typeof arrowElement === 'string') {
|
1471 | arrowElement = data.instance.popper.querySelector(arrowElement);
|
1472 |
|
1473 |
|
1474 | if (!arrowElement) {
|
1475 | return data;
|
1476 | }
|
1477 | } else {
|
1478 |
|
1479 |
|
1480 | if (!data.instance.popper.contains(arrowElement)) {
|
1481 | console.warn('WARNING: `arrow.element` must be child of its popper element!');
|
1482 | return data;
|
1483 | }
|
1484 | }
|
1485 |
|
1486 | var placement = data.placement.split('-')[0];
|
1487 | var _data$offsets = data.offsets,
|
1488 | popper = _data$offsets.popper,
|
1489 | reference = _data$offsets.reference;
|
1490 |
|
1491 | var isVertical = ['left', 'right'].indexOf(placement) !== -1;
|
1492 |
|
1493 | var len = isVertical ? 'height' : 'width';
|
1494 | var sideCapitalized = isVertical ? 'Top' : 'Left';
|
1495 | var side = sideCapitalized.toLowerCase();
|
1496 | var altSide = isVertical ? 'left' : 'top';
|
1497 | var opSide = isVertical ? 'bottom' : 'right';
|
1498 | var arrowElementSize = getOuterSizes(arrowElement)[len];
|
1499 |
|
1500 |
|
1501 |
|
1502 |
|
1503 |
|
1504 |
|
1505 |
|
1506 | if (reference[opSide] - arrowElementSize < popper[side]) {
|
1507 | data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowElementSize);
|
1508 | }
|
1509 |
|
1510 | if (reference[side] + arrowElementSize > popper[opSide]) {
|
1511 | data.offsets.popper[side] += reference[side] + arrowElementSize - popper[opSide];
|
1512 | }
|
1513 | data.offsets.popper = getClientRect(data.offsets.popper);
|
1514 |
|
1515 |
|
1516 | var center = reference[side] + reference[len] / 2 - arrowElementSize / 2;
|
1517 |
|
1518 |
|
1519 |
|
1520 | var css = getStyleComputedProperty(data.instance.popper);
|
1521 | var popperMarginSide = parseFloat(css['margin' + sideCapitalized]);
|
1522 | var popperBorderSide = parseFloat(css['border' + sideCapitalized + 'Width']);
|
1523 | var sideValue = center - data.offsets.popper[side] - popperMarginSide - popperBorderSide;
|
1524 |
|
1525 |
|
1526 | sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0);
|
1527 |
|
1528 | data.arrowElement = arrowElement;
|
1529 | data.offsets.arrow = (_data$offsets$arrow = {}, defineProperty(_data$offsets$arrow, side, Math.round(sideValue)), defineProperty(_data$offsets$arrow, altSide, ''), _data$offsets$arrow);
|
1530 |
|
1531 | return data;
|
1532 | }
|
1533 |
|
1534 |
|
1535 |
|
1536 |
|
1537 |
|
1538 |
|
1539 |
|
1540 |
|
1541 | function getOppositeVariation(variation) {
|
1542 | if (variation === 'end') {
|
1543 | return 'start';
|
1544 | } else if (variation === 'start') {
|
1545 | return 'end';
|
1546 | }
|
1547 | return variation;
|
1548 | }
|
1549 |
|
1550 |
|
1551 |
|
1552 |
|
1553 |
|
1554 |
|
1555 |
|
1556 |
|
1557 |
|
1558 |
|
1559 |
|
1560 |
|
1561 |
|
1562 |
|
1563 |
|
1564 |
|
1565 |
|
1566 |
|
1567 |
|
1568 |
|
1569 |
|
1570 |
|
1571 |
|
1572 |
|
1573 |
|
1574 |
|
1575 |
|
1576 |
|
1577 |
|
1578 |
|
1579 |
|
1580 |
|
1581 | 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'];
|
1582 |
|
1583 |
|
1584 | var validPlacements = placements.slice(3);
|
1585 |
|
1586 |
|
1587 |
|
1588 |
|
1589 |
|
1590 |
|
1591 |
|
1592 |
|
1593 |
|
1594 |
|
1595 |
|
1596 | function clockwise(placement) {
|
1597 | var counter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
1598 |
|
1599 | var index = validPlacements.indexOf(placement);
|
1600 | var arr = validPlacements.slice(index + 1).concat(validPlacements.slice(0, index));
|
1601 | return counter ? arr.reverse() : arr;
|
1602 | }
|
1603 |
|
1604 | var BEHAVIORS = {
|
1605 | FLIP: 'flip',
|
1606 | CLOCKWISE: 'clockwise',
|
1607 | COUNTERCLOCKWISE: 'counterclockwise'
|
1608 | };
|
1609 |
|
1610 |
|
1611 |
|
1612 |
|
1613 |
|
1614 |
|
1615 |
|
1616 |
|
1617 | function flip(data, options) {
|
1618 |
|
1619 | if (isModifierEnabled(data.instance.modifiers, 'inner')) {
|
1620 | return data;
|
1621 | }
|
1622 |
|
1623 | if (data.flipped && data.placement === data.originalPlacement) {
|
1624 |
|
1625 | return data;
|
1626 | }
|
1627 |
|
1628 | var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, options.boundariesElement, data.positionFixed);
|
1629 |
|
1630 | var placement = data.placement.split('-')[0];
|
1631 | var placementOpposite = getOppositePlacement(placement);
|
1632 | var variation = data.placement.split('-')[1] || '';
|
1633 |
|
1634 | var flipOrder = [];
|
1635 |
|
1636 | switch (options.behavior) {
|
1637 | case BEHAVIORS.FLIP:
|
1638 | flipOrder = [placement, placementOpposite];
|
1639 | break;
|
1640 | case BEHAVIORS.CLOCKWISE:
|
1641 | flipOrder = clockwise(placement);
|
1642 | break;
|
1643 | case BEHAVIORS.COUNTERCLOCKWISE:
|
1644 | flipOrder = clockwise(placement, true);
|
1645 | break;
|
1646 | default:
|
1647 | flipOrder = options.behavior;
|
1648 | }
|
1649 |
|
1650 | flipOrder.forEach(function (step, index) {
|
1651 | if (placement !== step || flipOrder.length === index + 1) {
|
1652 | return data;
|
1653 | }
|
1654 |
|
1655 | placement = data.placement.split('-')[0];
|
1656 | placementOpposite = getOppositePlacement(placement);
|
1657 |
|
1658 | var popperOffsets = data.offsets.popper;
|
1659 | var refOffsets = data.offsets.reference;
|
1660 |
|
1661 |
|
1662 | var floor = Math.floor;
|
1663 | 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);
|
1664 |
|
1665 | var overflowsLeft = floor(popperOffsets.left) < floor(boundaries.left);
|
1666 | var overflowsRight = floor(popperOffsets.right) > floor(boundaries.right);
|
1667 | var overflowsTop = floor(popperOffsets.top) < floor(boundaries.top);
|
1668 | var overflowsBottom = floor(popperOffsets.bottom) > floor(boundaries.bottom);
|
1669 |
|
1670 | var overflowsBoundaries = placement === 'left' && overflowsLeft || placement === 'right' && overflowsRight || placement === 'top' && overflowsTop || placement === 'bottom' && overflowsBottom;
|
1671 |
|
1672 |
|
1673 | var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
|
1674 |
|
1675 |
|
1676 | var flippedVariationByRef = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom);
|
1677 |
|
1678 |
|
1679 | var flippedVariationByContent = !!options.flipVariationsByContent && (isVertical && variation === 'start' && overflowsRight || isVertical && variation === 'end' && overflowsLeft || !isVertical && variation === 'start' && overflowsBottom || !isVertical && variation === 'end' && overflowsTop);
|
1680 |
|
1681 | var flippedVariation = flippedVariationByRef || flippedVariationByContent;
|
1682 |
|
1683 | if (overlapsRef || overflowsBoundaries || flippedVariation) {
|
1684 |
|
1685 | data.flipped = true;
|
1686 |
|
1687 | if (overlapsRef || overflowsBoundaries) {
|
1688 | placement = flipOrder[index + 1];
|
1689 | }
|
1690 |
|
1691 | if (flippedVariation) {
|
1692 | variation = getOppositeVariation(variation);
|
1693 | }
|
1694 |
|
1695 | data.placement = placement + (variation ? '-' + variation : '');
|
1696 |
|
1697 |
|
1698 |
|
1699 | data.offsets.popper = _extends({}, data.offsets.popper, getPopperOffsets(data.instance.popper, data.offsets.reference, data.placement));
|
1700 |
|
1701 | data = runModifiers(data.instance.modifiers, data, 'flip');
|
1702 | }
|
1703 | });
|
1704 | return data;
|
1705 | }
|
1706 |
|
1707 |
|
1708 |
|
1709 |
|
1710 |
|
1711 |
|
1712 |
|
1713 |
|
1714 | function keepTogether(data) {
|
1715 | var _data$offsets = data.offsets,
|
1716 | popper = _data$offsets.popper,
|
1717 | reference = _data$offsets.reference;
|
1718 |
|
1719 | var placement = data.placement.split('-')[0];
|
1720 | var floor = Math.floor;
|
1721 | var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
|
1722 | var side = isVertical ? 'right' : 'bottom';
|
1723 | var opSide = isVertical ? 'left' : 'top';
|
1724 | var measurement = isVertical ? 'width' : 'height';
|
1725 |
|
1726 | if (popper[side] < floor(reference[opSide])) {
|
1727 | data.offsets.popper[opSide] = floor(reference[opSide]) - popper[measurement];
|
1728 | }
|
1729 | if (popper[opSide] > floor(reference[side])) {
|
1730 | data.offsets.popper[opSide] = floor(reference[side]);
|
1731 | }
|
1732 |
|
1733 | return data;
|
1734 | }
|
1735 |
|
1736 |
|
1737 |
|
1738 |
|
1739 |
|
1740 |
|
1741 |
|
1742 |
|
1743 |
|
1744 |
|
1745 |
|
1746 |
|
1747 |
|
1748 | function toValue(str, measurement, popperOffsets, referenceOffsets) {
|
1749 |
|
1750 | var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/);
|
1751 | var value = +split[1];
|
1752 | var unit = split[2];
|
1753 |
|
1754 |
|
1755 | if (!value) {
|
1756 | return str;
|
1757 | }
|
1758 |
|
1759 | if (unit.indexOf('%') === 0) {
|
1760 | var element = void 0;
|
1761 | switch (unit) {
|
1762 | case '%p':
|
1763 | element = popperOffsets;
|
1764 | break;
|
1765 | case '%':
|
1766 | case '%r':
|
1767 | default:
|
1768 | element = referenceOffsets;
|
1769 | }
|
1770 |
|
1771 | var rect = getClientRect(element);
|
1772 | return rect[measurement] / 100 * value;
|
1773 | } else if (unit === 'vh' || unit === 'vw') {
|
1774 |
|
1775 | var size = void 0;
|
1776 | if (unit === 'vh') {
|
1777 | size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
|
1778 | } else {
|
1779 | size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
|
1780 | }
|
1781 | return size / 100 * value;
|
1782 | } else {
|
1783 |
|
1784 |
|
1785 | return value;
|
1786 | }
|
1787 | }
|
1788 |
|
1789 |
|
1790 |
|
1791 |
|
1792 |
|
1793 |
|
1794 |
|
1795 |
|
1796 |
|
1797 |
|
1798 |
|
1799 |
|
1800 | function parseOffset(offset, popperOffsets, referenceOffsets, basePlacement) {
|
1801 | var offsets = [0, 0];
|
1802 |
|
1803 |
|
1804 |
|
1805 |
|
1806 | var useHeight = ['right', 'left'].indexOf(basePlacement) !== -1;
|
1807 |
|
1808 |
|
1809 |
|
1810 | var fragments = offset.split(/(\+|\-)/).map(function (frag) {
|
1811 | return frag.trim();
|
1812 | });
|
1813 |
|
1814 |
|
1815 |
|
1816 | var divider = fragments.indexOf(find(fragments, function (frag) {
|
1817 | return frag.search(/,|\s/) !== -1;
|
1818 | }));
|
1819 |
|
1820 | if (fragments[divider] && fragments[divider].indexOf(',') === -1) {
|
1821 | console.warn('Offsets separated by white space(s) are deprecated, use a comma (,) instead.');
|
1822 | }
|
1823 |
|
1824 |
|
1825 |
|
1826 | var splitRegex = /\s*,\s*|\s+/;
|
1827 | 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];
|
1828 |
|
1829 |
|
1830 | ops = ops.map(function (op, index) {
|
1831 |
|
1832 | var measurement = (index === 1 ? !useHeight : useHeight) ? 'height' : 'width';
|
1833 | var mergeWithPrevious = false;
|
1834 | return op
|
1835 |
|
1836 |
|
1837 | .reduce(function (a, b) {
|
1838 | if (a[a.length - 1] === '' && ['+', '-'].indexOf(b) !== -1) {
|
1839 | a[a.length - 1] = b;
|
1840 | mergeWithPrevious = true;
|
1841 | return a;
|
1842 | } else if (mergeWithPrevious) {
|
1843 | a[a.length - 1] += b;
|
1844 | mergeWithPrevious = false;
|
1845 | return a;
|
1846 | } else {
|
1847 | return a.concat(b);
|
1848 | }
|
1849 | }, [])
|
1850 |
|
1851 | .map(function (str) {
|
1852 | return toValue(str, measurement, popperOffsets, referenceOffsets);
|
1853 | });
|
1854 | });
|
1855 |
|
1856 |
|
1857 | ops.forEach(function (op, index) {
|
1858 | op.forEach(function (frag, index2) {
|
1859 | if (isNumeric(frag)) {
|
1860 | offsets[index] += frag * (op[index2 - 1] === '-' ? -1 : 1);
|
1861 | }
|
1862 | });
|
1863 | });
|
1864 | return offsets;
|
1865 | }
|
1866 |
|
1867 |
|
1868 |
|
1869 |
|
1870 |
|
1871 |
|
1872 |
|
1873 |
|
1874 |
|
1875 |
|
1876 | function offset(data, _ref) {
|
1877 | var offset = _ref.offset;
|
1878 | var placement = data.placement,
|
1879 | _data$offsets = data.offsets,
|
1880 | popper = _data$offsets.popper,
|
1881 | reference = _data$offsets.reference;
|
1882 |
|
1883 | var basePlacement = placement.split('-')[0];
|
1884 |
|
1885 | var offsets = void 0;
|
1886 | if (isNumeric(+offset)) {
|
1887 | offsets = [+offset, 0];
|
1888 | } else {
|
1889 | offsets = parseOffset(offset, popper, reference, basePlacement);
|
1890 | }
|
1891 |
|
1892 | if (basePlacement === 'left') {
|
1893 | popper.top += offsets[0];
|
1894 | popper.left -= offsets[1];
|
1895 | } else if (basePlacement === 'right') {
|
1896 | popper.top += offsets[0];
|
1897 | popper.left += offsets[1];
|
1898 | } else if (basePlacement === 'top') {
|
1899 | popper.left += offsets[0];
|
1900 | popper.top -= offsets[1];
|
1901 | } else if (basePlacement === 'bottom') {
|
1902 | popper.left += offsets[0];
|
1903 | popper.top += offsets[1];
|
1904 | }
|
1905 |
|
1906 | data.popper = popper;
|
1907 | return data;
|
1908 | }
|
1909 |
|
1910 |
|
1911 |
|
1912 |
|
1913 |
|
1914 |
|
1915 |
|
1916 |
|
1917 | function preventOverflow(data, options) {
|
1918 | var boundariesElement = options.boundariesElement || getOffsetParent(data.instance.popper);
|
1919 |
|
1920 |
|
1921 |
|
1922 |
|
1923 | if (data.instance.reference === boundariesElement) {
|
1924 | boundariesElement = getOffsetParent(boundariesElement);
|
1925 | }
|
1926 |
|
1927 |
|
1928 |
|
1929 |
|
1930 | var transformProp = getSupportedPropertyName('transform');
|
1931 | var popperStyles = data.instance.popper.style;
|
1932 | var top = popperStyles.top,
|
1933 | left = popperStyles.left,
|
1934 | transform = popperStyles[transformProp];
|
1935 |
|
1936 | popperStyles.top = '';
|
1937 | popperStyles.left = '';
|
1938 | popperStyles[transformProp] = '';
|
1939 |
|
1940 | var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, boundariesElement, data.positionFixed);
|
1941 |
|
1942 |
|
1943 |
|
1944 | popperStyles.top = top;
|
1945 | popperStyles.left = left;
|
1946 | popperStyles[transformProp] = transform;
|
1947 |
|
1948 | options.boundaries = boundaries;
|
1949 |
|
1950 | var order = options.priority;
|
1951 | var popper = data.offsets.popper;
|
1952 |
|
1953 | var check = {
|
1954 | primary: function primary(placement) {
|
1955 | var value = popper[placement];
|
1956 | if (popper[placement] < boundaries[placement] && !options.escapeWithReference) {
|
1957 | value = Math.max(popper[placement], boundaries[placement]);
|
1958 | }
|
1959 | return defineProperty({}, placement, value);
|
1960 | },
|
1961 | secondary: function secondary(placement) {
|
1962 | var mainSide = placement === 'right' ? 'left' : 'top';
|
1963 | var value = popper[mainSide];
|
1964 | if (popper[placement] > boundaries[placement] && !options.escapeWithReference) {
|
1965 | value = Math.min(popper[mainSide], boundaries[placement] - (placement === 'right' ? popper.width : popper.height));
|
1966 | }
|
1967 | return defineProperty({}, mainSide, value);
|
1968 | }
|
1969 | };
|
1970 |
|
1971 | order.forEach(function (placement) {
|
1972 | var side = ['left', 'top'].indexOf(placement) !== -1 ? 'primary' : 'secondary';
|
1973 | popper = _extends({}, popper, check[side](placement));
|
1974 | });
|
1975 |
|
1976 | data.offsets.popper = popper;
|
1977 |
|
1978 | return data;
|
1979 | }
|
1980 |
|
1981 |
|
1982 |
|
1983 |
|
1984 |
|
1985 |
|
1986 |
|
1987 |
|
1988 | function shift(data) {
|
1989 | var placement = data.placement;
|
1990 | var basePlacement = placement.split('-')[0];
|
1991 | var shiftvariation = placement.split('-')[1];
|
1992 |
|
1993 |
|
1994 | if (shiftvariation) {
|
1995 | var _data$offsets = data.offsets,
|
1996 | reference = _data$offsets.reference,
|
1997 | popper = _data$offsets.popper;
|
1998 |
|
1999 | var isVertical = ['bottom', 'top'].indexOf(basePlacement) !== -1;
|
2000 | var side = isVertical ? 'left' : 'top';
|
2001 | var measurement = isVertical ? 'width' : 'height';
|
2002 |
|
2003 | var shiftOffsets = {
|
2004 | start: defineProperty({}, side, reference[side]),
|
2005 | end: defineProperty({}, side, reference[side] + reference[measurement] - popper[measurement])
|
2006 | };
|
2007 |
|
2008 | data.offsets.popper = _extends({}, popper, shiftOffsets[shiftvariation]);
|
2009 | }
|
2010 |
|
2011 | return data;
|
2012 | }
|
2013 |
|
2014 |
|
2015 |
|
2016 |
|
2017 |
|
2018 |
|
2019 |
|
2020 |
|
2021 | function hide(data) {
|
2022 | if (!isModifierRequired(data.instance.modifiers, 'hide', 'preventOverflow')) {
|
2023 | return data;
|
2024 | }
|
2025 |
|
2026 | var refRect = data.offsets.reference;
|
2027 | var bound = find(data.instance.modifiers, function (modifier) {
|
2028 | return modifier.name === 'preventOverflow';
|
2029 | }).boundaries;
|
2030 |
|
2031 | if (refRect.bottom < bound.top || refRect.left > bound.right || refRect.top > bound.bottom || refRect.right < bound.left) {
|
2032 |
|
2033 | if (data.hide === true) {
|
2034 | return data;
|
2035 | }
|
2036 |
|
2037 | data.hide = true;
|
2038 | data.attributes['x-out-of-boundaries'] = '';
|
2039 | } else {
|
2040 |
|
2041 | if (data.hide === false) {
|
2042 | return data;
|
2043 | }
|
2044 |
|
2045 | data.hide = false;
|
2046 | data.attributes['x-out-of-boundaries'] = false;
|
2047 | }
|
2048 |
|
2049 | return data;
|
2050 | }
|
2051 |
|
2052 |
|
2053 |
|
2054 |
|
2055 |
|
2056 |
|
2057 |
|
2058 |
|
2059 | function inner(data) {
|
2060 | var placement = data.placement;
|
2061 | var basePlacement = placement.split('-')[0];
|
2062 | var _data$offsets = data.offsets,
|
2063 | popper = _data$offsets.popper,
|
2064 | reference = _data$offsets.reference;
|
2065 |
|
2066 | var isHoriz = ['left', 'right'].indexOf(basePlacement) !== -1;
|
2067 |
|
2068 | var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1;
|
2069 |
|
2070 | popper[isHoriz ? 'left' : 'top'] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0);
|
2071 |
|
2072 | data.placement = getOppositePlacement(placement);
|
2073 | data.offsets.popper = getClientRect(popper);
|
2074 |
|
2075 | return data;
|
2076 | }
|
2077 |
|
2078 |
|
2079 |
|
2080 |
|
2081 |
|
2082 |
|
2083 |
|
2084 |
|
2085 |
|
2086 |
|
2087 |
|
2088 |
|
2089 |
|
2090 |
|
2091 |
|
2092 |
|
2093 |
|
2094 |
|
2095 |
|
2096 |
|
2097 |
|
2098 |
|
2099 | var modifiers = {
|
2100 | |
2101 |
|
2102 |
|
2103 |
|
2104 |
|
2105 |
|
2106 |
|
2107 |
|
2108 | shift: {
|
2109 |
|
2110 | order: 100,
|
2111 |
|
2112 | enabled: true,
|
2113 |
|
2114 | fn: shift
|
2115 | },
|
2116 |
|
2117 | |
2118 |
|
2119 |
|
2120 |
|
2121 |
|
2122 |
|
2123 |
|
2124 |
|
2125 |
|
2126 |
|
2127 |
|
2128 |
|
2129 |
|
2130 |
|
2131 |
|
2132 |
|
2133 |
|
2134 |
|
2135 |
|
2136 |
|
2137 |
|
2138 |
|
2139 |
|
2140 |
|
2141 |
|
2142 |
|
2143 |
|
2144 |
|
2145 |
|
2146 |
|
2147 |
|
2148 |
|
2149 |
|
2150 |
|
2151 |
|
2152 |
|
2153 |
|
2154 |
|
2155 | offset: {
|
2156 |
|
2157 | order: 200,
|
2158 |
|
2159 | enabled: true,
|
2160 |
|
2161 | fn: offset,
|
2162 | |
2163 |
|
2164 |
|
2165 | offset: 0
|
2166 | },
|
2167 |
|
2168 | |
2169 |
|
2170 |
|
2171 |
|
2172 |
|
2173 |
|
2174 |
|
2175 |
|
2176 |
|
2177 |
|
2178 |
|
2179 |
|
2180 |
|
2181 |
|
2182 |
|
2183 |
|
2184 |
|
2185 | preventOverflow: {
|
2186 |
|
2187 | order: 300,
|
2188 |
|
2189 | enabled: true,
|
2190 |
|
2191 | fn: preventOverflow,
|
2192 | |
2193 |
|
2194 |
|
2195 |
|
2196 |
|
2197 | priority: ['left', 'right', 'top', 'bottom'],
|
2198 | |
2199 |
|
2200 |
|
2201 |
|
2202 |
|
2203 |
|
2204 | padding: 5,
|
2205 | |
2206 |
|
2207 |
|
2208 |
|
2209 |
|
2210 | boundariesElement: 'scrollParent'
|
2211 | },
|
2212 |
|
2213 | |
2214 |
|
2215 |
|
2216 |
|
2217 |
|
2218 |
|
2219 |
|
2220 |
|
2221 |
|
2222 | keepTogether: {
|
2223 |
|
2224 | order: 400,
|
2225 |
|
2226 | enabled: true,
|
2227 |
|
2228 | fn: keepTogether
|
2229 | },
|
2230 |
|
2231 | |
2232 |
|
2233 |
|
2234 |
|
2235 |
|
2236 |
|
2237 |
|
2238 |
|
2239 |
|
2240 |
|
2241 | arrow: {
|
2242 |
|
2243 | order: 500,
|
2244 |
|
2245 | enabled: true,
|
2246 |
|
2247 | fn: arrow,
|
2248 |
|
2249 | element: '[x-arrow]'
|
2250 | },
|
2251 |
|
2252 | |
2253 |
|
2254 |
|
2255 |
|
2256 |
|
2257 |
|
2258 |
|
2259 |
|
2260 |
|
2261 |
|
2262 |
|
2263 | flip: {
|
2264 |
|
2265 | order: 600,
|
2266 |
|
2267 | enabled: true,
|
2268 |
|
2269 | fn: flip,
|
2270 | |
2271 |
|
2272 |
|
2273 |
|
2274 |
|
2275 |
|
2276 | behavior: 'flip',
|
2277 | |
2278 |
|
2279 |
|
2280 |
|
2281 | padding: 5,
|
2282 | |
2283 |
|
2284 |
|
2285 |
|
2286 |
|
2287 |
|
2288 | boundariesElement: 'viewport',
|
2289 | |
2290 |
|
2291 |
|
2292 |
|
2293 |
|
2294 |
|
2295 |
|
2296 | flipVariations: false,
|
2297 | |
2298 |
|
2299 |
|
2300 |
|
2301 |
|
2302 |
|
2303 |
|
2304 | flipVariationsByContent: false
|
2305 | },
|
2306 |
|
2307 | |
2308 |
|
2309 |
|
2310 |
|
2311 |
|
2312 |
|
2313 |
|
2314 | inner: {
|
2315 |
|
2316 | order: 700,
|
2317 |
|
2318 | enabled: false,
|
2319 |
|
2320 | fn: inner
|
2321 | },
|
2322 |
|
2323 | |
2324 |
|
2325 |
|
2326 |
|
2327 |
|
2328 |
|
2329 |
|
2330 |
|
2331 |
|
2332 |
|
2333 | hide: {
|
2334 |
|
2335 | order: 800,
|
2336 |
|
2337 | enabled: true,
|
2338 |
|
2339 | fn: hide
|
2340 | },
|
2341 |
|
2342 | |
2343 |
|
2344 |
|
2345 |
|
2346 |
|
2347 |
|
2348 |
|
2349 |
|
2350 |
|
2351 |
|
2352 |
|
2353 |
|
2354 |
|
2355 |
|
2356 |
|
2357 | computeStyle: {
|
2358 |
|
2359 | order: 850,
|
2360 |
|
2361 | enabled: true,
|
2362 |
|
2363 | fn: computeStyle,
|
2364 | |
2365 |
|
2366 |
|
2367 |
|
2368 |
|
2369 | gpuAcceleration: true,
|
2370 | |
2371 |
|
2372 |
|
2373 |
|
2374 |
|
2375 | x: 'bottom',
|
2376 | |
2377 |
|
2378 |
|
2379 |
|
2380 |
|
2381 | y: 'right'
|
2382 | },
|
2383 |
|
2384 | |
2385 |
|
2386 |
|
2387 |
|
2388 |
|
2389 |
|
2390 |
|
2391 |
|
2392 |
|
2393 |
|
2394 |
|
2395 |
|
2396 |
|
2397 |
|
2398 |
|
2399 | applyStyle: {
|
2400 |
|
2401 | order: 900,
|
2402 |
|
2403 | enabled: true,
|
2404 |
|
2405 | fn: applyStyle,
|
2406 |
|
2407 | onLoad: applyStyleOnLoad,
|
2408 | |
2409 |
|
2410 |
|
2411 |
|
2412 |
|
2413 |
|
2414 | gpuAcceleration: undefined
|
2415 | }
|
2416 | };
|
2417 |
|
2418 |
|
2419 |
|
2420 |
|
2421 |
|
2422 |
|
2423 |
|
2424 |
|
2425 |
|
2426 |
|
2427 |
|
2428 |
|
2429 |
|
2430 |
|
2431 |
|
2432 |
|
2433 |
|
2434 |
|
2435 |
|
2436 |
|
2437 |
|
2438 |
|
2439 |
|
2440 |
|
2441 |
|
2442 |
|
2443 |
|
2444 |
|
2445 |
|
2446 |
|
2447 |
|
2448 |
|
2449 |
|
2450 |
|
2451 |
|
2452 |
|
2453 | var Defaults = {
|
2454 | |
2455 |
|
2456 |
|
2457 |
|
2458 | placement: 'bottom',
|
2459 |
|
2460 | |
2461 |
|
2462 |
|
2463 |
|
2464 | positionFixed: false,
|
2465 |
|
2466 | |
2467 |
|
2468 |
|
2469 |
|
2470 | eventsEnabled: true,
|
2471 |
|
2472 | |
2473 |
|
2474 |
|
2475 |
|
2476 |
|
2477 | removeOnDestroy: false,
|
2478 |
|
2479 | |
2480 |
|
2481 |
|
2482 |
|
2483 |
|
2484 |
|
2485 | onCreate: function onCreate() {},
|
2486 |
|
2487 | |
2488 |
|
2489 |
|
2490 |
|
2491 |
|
2492 |
|
2493 |
|
2494 |
|
2495 | onUpdate: function onUpdate() {},
|
2496 |
|
2497 | |
2498 |
|
2499 |
|
2500 |
|
2501 |
|
2502 | modifiers: modifiers
|
2503 | };
|
2504 |
|
2505 |
|
2506 |
|
2507 |
|
2508 |
|
2509 |
|
2510 |
|
2511 |
|
2512 |
|
2513 |
|
2514 |
|
2515 |
|
2516 |
|
2517 | var Popper = function () {
|
2518 | |
2519 |
|
2520 |
|
2521 |
|
2522 |
|
2523 |
|
2524 |
|
2525 |
|
2526 | function Popper(reference, popper) {
|
2527 | var _this = this;
|
2528 |
|
2529 | var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
2530 | classCallCheck(this, Popper);
|
2531 |
|
2532 | this.scheduleUpdate = function () {
|
2533 | return requestAnimationFrame(_this.update);
|
2534 | };
|
2535 |
|
2536 |
|
2537 | this.update = debounce(this.update.bind(this));
|
2538 |
|
2539 |
|
2540 | this.options = _extends({}, Popper.Defaults, options);
|
2541 |
|
2542 |
|
2543 | this.state = {
|
2544 | isDestroyed: false,
|
2545 | isCreated: false,
|
2546 | scrollParents: []
|
2547 | };
|
2548 |
|
2549 |
|
2550 | this.reference = reference && reference.jquery ? reference[0] : reference;
|
2551 | this.popper = popper && popper.jquery ? popper[0] : popper;
|
2552 |
|
2553 |
|
2554 | this.options.modifiers = {};
|
2555 | Object.keys(_extends({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) {
|
2556 | _this.options.modifiers[name] = _extends({}, Popper.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {});
|
2557 | });
|
2558 |
|
2559 |
|
2560 | this.modifiers = Object.keys(this.options.modifiers).map(function (name) {
|
2561 | return _extends({
|
2562 | name: name
|
2563 | }, _this.options.modifiers[name]);
|
2564 | })
|
2565 |
|
2566 | .sort(function (a, b) {
|
2567 | return a.order - b.order;
|
2568 | });
|
2569 |
|
2570 |
|
2571 |
|
2572 |
|
2573 |
|
2574 | this.modifiers.forEach(function (modifierOptions) {
|
2575 | if (modifierOptions.enabled && isFunction(modifierOptions.onLoad)) {
|
2576 | modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state);
|
2577 | }
|
2578 | });
|
2579 |
|
2580 |
|
2581 | this.update();
|
2582 |
|
2583 | var eventsEnabled = this.options.eventsEnabled;
|
2584 | if (eventsEnabled) {
|
2585 |
|
2586 | this.enableEventListeners();
|
2587 | }
|
2588 |
|
2589 | this.state.eventsEnabled = eventsEnabled;
|
2590 | }
|
2591 |
|
2592 |
|
2593 |
|
2594 |
|
2595 |
|
2596 | createClass(Popper, [{
|
2597 | key: 'update',
|
2598 | value: function update$$1() {
|
2599 | return update.call(this);
|
2600 | }
|
2601 | }, {
|
2602 | key: 'destroy',
|
2603 | value: function destroy$$1() {
|
2604 | return destroy.call(this);
|
2605 | }
|
2606 | }, {
|
2607 | key: 'enableEventListeners',
|
2608 | value: function enableEventListeners$$1() {
|
2609 | return enableEventListeners.call(this);
|
2610 | }
|
2611 | }, {
|
2612 | key: 'disableEventListeners',
|
2613 | value: function disableEventListeners$$1() {
|
2614 | return disableEventListeners.call(this);
|
2615 | }
|
2616 |
|
2617 | |
2618 |
|
2619 |
|
2620 |
|
2621 |
|
2622 |
|
2623 |
|
2624 | |
2625 |
|
2626 |
|
2627 |
|
2628 |
|
2629 |
|
2630 |
|
2631 |
|
2632 |
|
2633 |
|
2634 |
|
2635 |
|
2636 |
|
2637 |
|
2638 |
|
2639 |
|
2640 |
|
2641 | }]);
|
2642 | return Popper;
|
2643 | }();
|
2644 |
|
2645 |
|
2646 |
|
2647 |
|
2648 |
|
2649 |
|
2650 |
|
2651 |
|
2652 |
|
2653 |
|
2654 |
|
2655 |
|
2656 |
|
2657 |
|
2658 |
|
2659 |
|
2660 |
|
2661 |
|
2662 |
|
2663 |
|
2664 |
|
2665 |
|
2666 | Popper.Utils = (typeof window !== 'undefined' ? window : global).PopperUtils;
|
2667 | Popper.placements = placements;
|
2668 | Popper.Defaults = Defaults;
|
2669 |
|
2670 | var _ref3;
|
2671 |
|
2672 | function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
2673 |
|
2674 | function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { defineProperty$1._defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
2675 |
|
2676 | function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = getPrototypeOf._getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = getPrototypeOf._getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return getPrototypeOf._possibleConstructorReturn(this, result); }; }
|
2677 |
|
2678 | function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
2679 |
|
2680 | var _StyledAnimatedDiv = _styled__default(web.extendedAnimated.div).withConfig({
|
2681 | displayName: "Popover___StyledAnimatedDiv",
|
2682 | componentId: "sc-1hohxqp-0"
|
2683 | })(["position:absolute;top:0;left:0;"]);
|
2684 |
|
2685 | var _StyledAnimatedDiv2 = _styled__default(web.extendedAnimated.div).withConfig({
|
2686 | displayName: "Popover___StyledAnimatedDiv2",
|
2687 | componentId: "sc-1hohxqp-1"
|
2688 | })(["background:", ";border:1px solid ", ";border-radius:", "px;filter:drop-shadow(0 4px 4px rgba(0,0,0,0.15));&:focus{outline:0;}overflow-y:auto;"], function (p) {
|
2689 | return p._css;
|
2690 | }, function (p) {
|
2691 | return p._css2;
|
2692 | }, constants.RADIUS);
|
2693 |
|
2694 | var PopoverBase = function (_React$Component) {
|
2695 | getPrototypeOf._inherits(PopoverBase, _React$Component);
|
2696 |
|
2697 | var _super = _createSuper(PopoverBase);
|
2698 |
|
2699 | function PopoverBase() {
|
2700 | var _this;
|
2701 |
|
2702 | getPrototypeOf._classCallCheck(this, PopoverBase);
|
2703 |
|
2704 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
2705 | args[_key] = arguments[_key];
|
2706 | }
|
2707 |
|
2708 | _this = _super.call.apply(_super, [this].concat(args));
|
2709 |
|
2710 | defineProperty$1._defineProperty(getPrototypeOf._assertThisInitialized(_this), "_cardElement", React__default.createRef());
|
2711 |
|
2712 | defineProperty$1._defineProperty(getPrototypeOf._assertThisInitialized(_this), "_popperElement", React__default.createRef());
|
2713 |
|
2714 | defineProperty$1._defineProperty(getPrototypeOf._assertThisInitialized(_this), "_document", null);
|
2715 |
|
2716 | defineProperty$1._defineProperty(getPrototypeOf._assertThisInitialized(_this), "_popper", null);
|
2717 |
|
2718 | defineProperty$1._defineProperty(getPrototypeOf._assertThisInitialized(_this), "handleEscape", function (_ref) {
|
2719 | var keyCode = _ref.keyCode;
|
2720 |
|
2721 | if (keyCode === keycodes.KEY_ESC) {
|
2722 |
|
2723 | _this.props.opener.focus();
|
2724 |
|
2725 | _this.attemptClose();
|
2726 | }
|
2727 | });
|
2728 |
|
2729 | defineProperty$1._defineProperty(getPrototypeOf._assertThisInitialized(_this), "handleBlur", function (event) {
|
2730 | var _this$props = _this.props,
|
2731 | closeOnOpenerFocus = _this$props.closeOnOpenerFocus,
|
2732 | opener = _this$props.opener;
|
2733 | var focusedElement = event.relatedTarget;
|
2734 |
|
2735 |
|
2736 |
|
2737 | if (_this._cardElement.current && _this._cardElement.current.contains(focusedElement) || closeOnOpenerFocus && opener && opener.contains(focusedElement)) {
|
2738 | if (closeOnOpenerFocus && (opener.tagName === 'BUTTON' || opener.tagName === 'INPUT')) {
|
2739 | environment.warn('Popover: using "closeOnOpenerFocus" with a <button> or <input> may lead to bugs due ' + 'to cross-environment focus event handling. ' + 'See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus ' + 'for more information.');
|
2740 | }
|
2741 |
|
2742 | return;
|
2743 | }
|
2744 |
|
2745 |
|
2746 |
|
2747 | if (!focusedElement) {
|
2748 | opener.focus();
|
2749 | }
|
2750 |
|
2751 | _this.attemptClose();
|
2752 | });
|
2753 |
|
2754 | return _this;
|
2755 | }
|
2756 |
|
2757 | getPrototypeOf._createClass(PopoverBase, [{
|
2758 | key: "componentDidMount",
|
2759 | value: function componentDidMount() {
|
2760 | this._document = this._popperElement.current.ownerDocument;
|
2761 |
|
2762 | this._document.addEventListener('keydown', this.handleEscape);
|
2763 |
|
2764 | this.focus();
|
2765 | this.initPopper();
|
2766 | }
|
2767 | }, {
|
2768 | key: "componentWillUnmount",
|
2769 | value: function componentWillUnmount() {
|
2770 | this.destroyPopper();
|
2771 |
|
2772 | this._document.removeEventListener('keydown', this.handleEscape);
|
2773 |
|
2774 | delete this._document;
|
2775 | delete this._popper;
|
2776 | }
|
2777 | }, {
|
2778 | key: "componentDidUpdate",
|
2779 | value: function componentDidUpdate(prevProps, prevState) {
|
2780 | var _this$props2 = this.props,
|
2781 | placement = _this$props2.placement,
|
2782 | children = _this$props2.children,
|
2783 | opener = _this$props2.opener;
|
2784 |
|
2785 | if (prevProps.placement !== placement || prevProps.children !== children || prevProps.opener !== opener) {
|
2786 | this.destroyPopper();
|
2787 | this.initPopper();
|
2788 | }
|
2789 | }
|
2790 | }, {
|
2791 | key: "focus",
|
2792 | value: function focus() {
|
2793 | if (this._cardElement.current) {
|
2794 | this._cardElement.current.focus();
|
2795 | }
|
2796 | }
|
2797 | }, {
|
2798 | key: "getPopperSettings",
|
2799 | value: function getPopperSettings() {
|
2800 | var _this$props3 = this.props,
|
2801 | placement = _this$props3.placement,
|
2802 | rootBoundary = _this$props3.rootBoundary;
|
2803 | var settings = {
|
2804 | placement: placement,
|
2805 | modifiers: {
|
2806 | preventOverflow: {
|
2807 | enabled: true,
|
2808 | padding: 10,
|
2809 | boundariesElement: rootBoundary || 'window'
|
2810 | }
|
2811 | },
|
2812 | positionFixed: false
|
2813 | };
|
2814 |
|
2815 | if (placement !== 'center') {
|
2816 | return settings;
|
2817 | }
|
2818 |
|
2819 | return _objectSpread(_objectSpread({}, settings), {}, {
|
2820 | placement: 'top-start',
|
2821 | modifiers: _objectSpread(_objectSpread({}, settings.modifiers), {}, {
|
2822 | arrow: {
|
2823 | enabled: false
|
2824 | },
|
2825 | flip: {
|
2826 | enabled: false
|
2827 | },
|
2828 | offset: {
|
2829 | enabled: true,
|
2830 | offset: '50% - 50%p, -50%p - 50%'
|
2831 | }
|
2832 | })
|
2833 | });
|
2834 | }
|
2835 | }, {
|
2836 | key: "initPopper",
|
2837 | value: function initPopper() {
|
2838 | var opener = this.props.opener;
|
2839 |
|
2840 | if (!this._popper) {
|
2841 | this._popper = new Popper(opener, this._popperElement.current, this.getPopperSettings());
|
2842 | }
|
2843 | }
|
2844 | }, {
|
2845 | key: "destroyPopper",
|
2846 | value: function destroyPopper() {
|
2847 | if (this._popper) {
|
2848 | this._popper.destroy();
|
2849 |
|
2850 | this._popper = null;
|
2851 | }
|
2852 | }
|
2853 | }, {
|
2854 | key: "attemptClose",
|
2855 | value: function attemptClose() {
|
2856 | var accepted = this.props.onClose();
|
2857 |
|
2858 |
|
2859 | if (accepted === false) {
|
2860 | this.focus();
|
2861 | }
|
2862 | }
|
2863 | }, {
|
2864 | key: "boundaryDimensions",
|
2865 | value: function boundaryDimensions() {
|
2866 | var rootBoundary = this.props.rootBoundary;
|
2867 | var hasWindow = typeof window !== 'undefined';
|
2868 | return rootBoundary ? [rootBoundary.clientWidth, rootBoundary.clientHeight] : [hasWindow ? window.innerWidth : 0, hasWindow ? window.innerHeight : 0];
|
2869 | }
|
2870 | }, {
|
2871 | key: "render",
|
2872 | value: function render() {
|
2873 | var _this$props4 = this.props,
|
2874 | children = _this$props4.children,
|
2875 | theme = _this$props4.theme,
|
2876 | transitionStyles = _this$props4.transitionStyles,
|
2877 | zIndex = _this$props4.zIndex;
|
2878 | var scale = transitionStyles.scale,
|
2879 | opacity = transitionStyles.opacity;
|
2880 |
|
2881 | var _this$boundaryDimensi = this.boundaryDimensions(),
|
2882 | _this$boundaryDimensi2 = slicedToArray._slicedToArray(_this$boundaryDimensi, 2),
|
2883 | maxWidth = _this$boundaryDimensi2[0],
|
2884 | maxHeight = _this$boundaryDimensi2[1];
|
2885 |
|
2886 | return React__default.createElement(_StyledAnimatedDiv, {
|
2887 | ref: this._popperElement,
|
2888 | style: {
|
2889 | zIndex: zIndex
|
2890 | }
|
2891 | }, React__default.createElement(_StyledAnimatedDiv2, _extends$1._extends({
|
2892 | tabIndex: "0",
|
2893 | onBlur: this.handleBlur,
|
2894 | ref: this._cardElement,
|
2895 | style: {
|
2896 | opacity: opacity,
|
2897 | transform: scale.interpolate(function (v) {
|
2898 | return "scale3d(".concat(v, ", ").concat(v, ", 1)");
|
2899 | }),
|
2900 | maxHeight: "".concat(maxHeight - 2 * constants.GU, "px"),
|
2901 | maxWidth: "".concat(maxWidth - 2 * constants.GU, "px")
|
2902 | }
|
2903 | }, components.stylingProps(this), {
|
2904 | _css: theme.surface,
|
2905 | _css2: theme.border
|
2906 | }), children));
|
2907 | }
|
2908 | }]);
|
2909 |
|
2910 | return PopoverBase;
|
2911 | }(React__default.Component);
|
2912 |
|
2913 | defineProperty$1._defineProperty(PopoverBase, "propTypes", {
|
2914 | children: proptypes.PropTypes.node,
|
2915 | closeOnOpenerFocus: proptypes.PropTypes.bool,
|
2916 | onClose: proptypes.PropTypes.func,
|
2917 | opener: proptypes.PropTypes._element,
|
2918 | placement: proptypes.PropTypes.oneOf(
|
2919 |
|
2920 | (_ref3 = ['center']).concat.apply(_ref3, toConsumableArray._toConsumableArray(['auto', 'top', 'right', 'bottom', 'left'].map(function (position) {
|
2921 | return [position, "".concat(position, "-start"), "".concat(position, "-end")];
|
2922 | })))),
|
2923 | rootBoundary: proptypes.PropTypes._element,
|
2924 | theme: proptypes.PropTypes.object,
|
2925 | transitionStyles: proptypes.PropTypes.object,
|
2926 | zIndex: proptypes.PropTypes.number
|
2927 | });
|
2928 |
|
2929 | defineProperty$1._defineProperty(PopoverBase, "defaultProps", {
|
2930 | closeOnOpenerFocus: false,
|
2931 | opener: null,
|
2932 | placement: 'center',
|
2933 | onClose: miscellaneous.noop,
|
2934 | zIndex: 999
|
2935 | });
|
2936 |
|
2937 | function Popover(_ref2) {
|
2938 | var scaleEffect = _ref2.scaleEffect,
|
2939 | visible = _ref2.visible,
|
2940 | props = objectWithoutProperties._objectWithoutProperties(_ref2, ["scaleEffect", "visible"]);
|
2941 |
|
2942 | var theme = Theme.useTheme();
|
2943 | var root = index$1$1.useRoot();
|
2944 | return React__default.createElement(RootPortal.default, null, React__default.createElement(web.Transition, {
|
2945 | items: visible,
|
2946 | config: springs.springs.swift,
|
2947 | from: {
|
2948 | scale: scaleEffect ? 0.9 : 1,
|
2949 | opacity: 0
|
2950 | },
|
2951 | enter: {
|
2952 | scale: 1,
|
2953 | opacity: 1
|
2954 | },
|
2955 | leave: {
|
2956 | scale: scaleEffect ? 0.9 : 1,
|
2957 | opacity: 0
|
2958 | },
|
2959 | native: true
|
2960 | }, function (visible) {
|
2961 | return visible && function (transitionStyles) {
|
2962 | return React__default.createElement(PopoverBase, _extends$1._extends({}, props, {
|
2963 | rootBoundary: root,
|
2964 | theme: theme,
|
2965 | transitionStyles: transitionStyles
|
2966 | }));
|
2967 | };
|
2968 | }));
|
2969 | }
|
2970 |
|
2971 | Popover.propTypes = _objectSpread(_objectSpread({}, PopoverBase.propTypes), {}, {
|
2972 | scaleEffect: proptypes.PropTypes.bool,
|
2973 | visible: proptypes.PropTypes.bool
|
2974 | });
|
2975 | Popover.defaultProps = _objectSpread(_objectSpread({}, PopoverBase.defaultProps), {}, {
|
2976 | scaleEffect: true,
|
2977 | visible: true
|
2978 | });
|
2979 |
|
2980 | exports.default = Popover;
|
2981 |
|