1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', { value: true });
|
4 |
|
5 | var top = 'top';
|
6 | var bottom = 'bottom';
|
7 | var right = 'right';
|
8 | var left = 'left';
|
9 | var auto = 'auto';
|
10 | var basePlacements = [top, bottom, right, left];
|
11 | var start = 'start';
|
12 | var end = 'end';
|
13 | var clippingParents = 'clippingParents';
|
14 | var viewport = 'viewport';
|
15 | var popper = 'popper';
|
16 | var reference = 'reference';
|
17 | var variationPlacements = basePlacements.reduce(function (acc, placement) {
|
18 | return acc.concat([placement + "-" + start, placement + "-" + end]);
|
19 | }, []);
|
20 | var placements = [].concat(basePlacements, [auto]).reduce(function (acc, placement) {
|
21 | return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
|
22 | }, []);
|
23 |
|
24 | var beforeRead = 'beforeRead';
|
25 | var read = 'read';
|
26 | var afterRead = 'afterRead';
|
27 |
|
28 | var beforeMain = 'beforeMain';
|
29 | var main = 'main';
|
30 | var afterMain = 'afterMain';
|
31 |
|
32 | var beforeWrite = 'beforeWrite';
|
33 | var write = 'write';
|
34 | var afterWrite = 'afterWrite';
|
35 | var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
|
36 |
|
37 | function getBasePlacement(placement) {
|
38 | return placement.split('-')[0];
|
39 | }
|
40 |
|
41 | function getWindow(node) {
|
42 | if (node == null) {
|
43 | return window;
|
44 | }
|
45 |
|
46 | if (node.toString() !== '[object Window]') {
|
47 | var ownerDocument = node.ownerDocument;
|
48 | return ownerDocument ? ownerDocument.defaultView || window : window;
|
49 | }
|
50 |
|
51 | return node;
|
52 | }
|
53 |
|
54 | function isElement(node) {
|
55 | var OwnElement = getWindow(node).Element;
|
56 | return node instanceof OwnElement || node instanceof Element;
|
57 | }
|
58 |
|
59 | function isHTMLElement(node) {
|
60 | var OwnElement = getWindow(node).HTMLElement;
|
61 | return node instanceof OwnElement || node instanceof HTMLElement;
|
62 | }
|
63 |
|
64 | function isShadowRoot(node) {
|
65 |
|
66 | if (typeof ShadowRoot === 'undefined') {
|
67 | return false;
|
68 | }
|
69 |
|
70 | var OwnElement = getWindow(node).ShadowRoot;
|
71 | return node instanceof OwnElement || node instanceof ShadowRoot;
|
72 | }
|
73 |
|
74 | var max = Math.max;
|
75 | var min = Math.min;
|
76 | var round = Math.round;
|
77 |
|
78 | function getUAString() {
|
79 | var uaData = navigator.userAgentData;
|
80 |
|
81 | if (uaData != null && uaData.brands) {
|
82 | return uaData.brands.map(function (item) {
|
83 | return item.brand + "/" + item.version;
|
84 | }).join(' ');
|
85 | }
|
86 |
|
87 | return navigator.userAgent;
|
88 | }
|
89 |
|
90 | function isLayoutViewport() {
|
91 | return !/^((?!chrome|android).)*safari/i.test(getUAString());
|
92 | }
|
93 |
|
94 | function getBoundingClientRect(element, includeScale, isFixedStrategy) {
|
95 | if (includeScale === void 0) {
|
96 | includeScale = false;
|
97 | }
|
98 |
|
99 | if (isFixedStrategy === void 0) {
|
100 | isFixedStrategy = false;
|
101 | }
|
102 |
|
103 | var clientRect = element.getBoundingClientRect();
|
104 | var scaleX = 1;
|
105 | var scaleY = 1;
|
106 |
|
107 | if (includeScale && isHTMLElement(element)) {
|
108 | scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
|
109 | scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
|
110 | }
|
111 |
|
112 | var _ref = isElement(element) ? getWindow(element) : window,
|
113 | visualViewport = _ref.visualViewport;
|
114 |
|
115 | var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
|
116 | var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
|
117 | var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
|
118 | var width = clientRect.width / scaleX;
|
119 | var height = clientRect.height / scaleY;
|
120 | return {
|
121 | width: width,
|
122 | height: height,
|
123 | top: y,
|
124 | right: x + width,
|
125 | bottom: y + height,
|
126 | left: x,
|
127 | x: x,
|
128 | y: y
|
129 | };
|
130 | }
|
131 |
|
132 |
|
133 |
|
134 | function getLayoutRect(element) {
|
135 | var clientRect = getBoundingClientRect(element);
|
136 |
|
137 |
|
138 | var width = element.offsetWidth;
|
139 | var height = element.offsetHeight;
|
140 |
|
141 | if (Math.abs(clientRect.width - width) <= 1) {
|
142 | width = clientRect.width;
|
143 | }
|
144 |
|
145 | if (Math.abs(clientRect.height - height) <= 1) {
|
146 | height = clientRect.height;
|
147 | }
|
148 |
|
149 | return {
|
150 | x: element.offsetLeft,
|
151 | y: element.offsetTop,
|
152 | width: width,
|
153 | height: height
|
154 | };
|
155 | }
|
156 |
|
157 | function contains(parent, child) {
|
158 | var rootNode = child.getRootNode && child.getRootNode();
|
159 |
|
160 | if (parent.contains(child)) {
|
161 | return true;
|
162 | }
|
163 | else if (rootNode && isShadowRoot(rootNode)) {
|
164 | var next = child;
|
165 |
|
166 | do {
|
167 | if (next && parent.isSameNode(next)) {
|
168 | return true;
|
169 | }
|
170 |
|
171 |
|
172 | next = next.parentNode || next.host;
|
173 | } while (next);
|
174 | }
|
175 |
|
176 |
|
177 | return false;
|
178 | }
|
179 |
|
180 | function getNodeName(element) {
|
181 | return element ? (element.nodeName || '').toLowerCase() : null;
|
182 | }
|
183 |
|
184 | function getComputedStyle(element) {
|
185 | return getWindow(element).getComputedStyle(element);
|
186 | }
|
187 |
|
188 | function isTableElement(element) {
|
189 | return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
|
190 | }
|
191 |
|
192 | function getDocumentElement(element) {
|
193 |
|
194 | return ((isElement(element) ? element.ownerDocument :
|
195 | element.document) || window.document).documentElement;
|
196 | }
|
197 |
|
198 | function getParentNode(element) {
|
199 | if (getNodeName(element) === 'html') {
|
200 | return element;
|
201 | }
|
202 |
|
203 | return (
|
204 |
|
205 |
|
206 | element.assignedSlot ||
|
207 | element.parentNode || (
|
208 | isShadowRoot(element) ? element.host : null) ||
|
209 |
|
210 | getDocumentElement(element)
|
211 |
|
212 | );
|
213 | }
|
214 |
|
215 | function getTrueOffsetParent(element) {
|
216 | if (!isHTMLElement(element) ||
|
217 | getComputedStyle(element).position === 'fixed') {
|
218 | return null;
|
219 | }
|
220 |
|
221 | return element.offsetParent;
|
222 | }
|
223 |
|
224 |
|
225 |
|
226 | function getContainingBlock(element) {
|
227 | var isFirefox = /firefox/i.test(getUAString());
|
228 | var isIE = /Trident/i.test(getUAString());
|
229 |
|
230 | if (isIE && isHTMLElement(element)) {
|
231 |
|
232 | var elementCss = getComputedStyle(element);
|
233 |
|
234 | if (elementCss.position === 'fixed') {
|
235 | return null;
|
236 | }
|
237 | }
|
238 |
|
239 | var currentNode = getParentNode(element);
|
240 |
|
241 | if (isShadowRoot(currentNode)) {
|
242 | currentNode = currentNode.host;
|
243 | }
|
244 |
|
245 | while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
|
246 | var css = getComputedStyle(currentNode);
|
247 |
|
248 |
|
249 |
|
250 | if (css.transform !== 'none' || css.perspective !== 'none' || css.contain === 'paint' || ['transform', 'perspective'].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === 'filter' || isFirefox && css.filter && css.filter !== 'none') {
|
251 | return currentNode;
|
252 | } else {
|
253 | currentNode = currentNode.parentNode;
|
254 | }
|
255 | }
|
256 |
|
257 | return null;
|
258 | }
|
259 |
|
260 |
|
261 |
|
262 | function getOffsetParent(element) {
|
263 | var window = getWindow(element);
|
264 | var offsetParent = getTrueOffsetParent(element);
|
265 |
|
266 | while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
|
267 | offsetParent = getTrueOffsetParent(offsetParent);
|
268 | }
|
269 |
|
270 | if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static')) {
|
271 | return window;
|
272 | }
|
273 |
|
274 | return offsetParent || getContainingBlock(element) || window;
|
275 | }
|
276 |
|
277 | function getMainAxisFromPlacement(placement) {
|
278 | return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
|
279 | }
|
280 |
|
281 | function within(min$1, value, max$1) {
|
282 | return max(min$1, min(value, max$1));
|
283 | }
|
284 | function withinMaxClamp(min, value, max) {
|
285 | var v = within(min, value, max);
|
286 | return v > max ? max : v;
|
287 | }
|
288 |
|
289 | function getFreshSideObject() {
|
290 | return {
|
291 | top: 0,
|
292 | right: 0,
|
293 | bottom: 0,
|
294 | left: 0
|
295 | };
|
296 | }
|
297 |
|
298 | function mergePaddingObject(paddingObject) {
|
299 | return Object.assign({}, getFreshSideObject(), paddingObject);
|
300 | }
|
301 |
|
302 | function expandToHashMap(value, keys) {
|
303 | return keys.reduce(function (hashMap, key) {
|
304 | hashMap[key] = value;
|
305 | return hashMap;
|
306 | }, {});
|
307 | }
|
308 |
|
309 | var toPaddingObject = function toPaddingObject(padding, state) {
|
310 | padding = typeof padding === 'function' ? padding(Object.assign({}, state.rects, {
|
311 | placement: state.placement
|
312 | })) : padding;
|
313 | return mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
|
314 | };
|
315 |
|
316 | function arrow(_ref) {
|
317 | var _state$modifiersData$;
|
318 |
|
319 | var state = _ref.state,
|
320 | name = _ref.name,
|
321 | options = _ref.options;
|
322 | var arrowElement = state.elements.arrow;
|
323 | var popperOffsets = state.modifiersData.popperOffsets;
|
324 | var basePlacement = getBasePlacement(state.placement);
|
325 | var axis = getMainAxisFromPlacement(basePlacement);
|
326 | var isVertical = [left, right].indexOf(basePlacement) >= 0;
|
327 | var len = isVertical ? 'height' : 'width';
|
328 |
|
329 | if (!arrowElement || !popperOffsets) {
|
330 | return;
|
331 | }
|
332 |
|
333 | var paddingObject = toPaddingObject(options.padding, state);
|
334 | var arrowRect = getLayoutRect(arrowElement);
|
335 | var minProp = axis === 'y' ? top : left;
|
336 | var maxProp = axis === 'y' ? bottom : right;
|
337 | var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
|
338 | var startDiff = popperOffsets[axis] - state.rects.reference[axis];
|
339 | var arrowOffsetParent = getOffsetParent(arrowElement);
|
340 | var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
|
341 | var centerToReference = endDiff / 2 - startDiff / 2;
|
342 |
|
343 |
|
344 | var min = paddingObject[minProp];
|
345 | var max = clientSize - arrowRect[len] - paddingObject[maxProp];
|
346 | var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
|
347 | var offset = within(min, center, max);
|
348 |
|
349 | var axisProp = axis;
|
350 | state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);
|
351 | }
|
352 |
|
353 | function effect$1(_ref2) {
|
354 | var state = _ref2.state,
|
355 | options = _ref2.options;
|
356 | var _options$element = options.element,
|
357 | arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element;
|
358 |
|
359 | if (arrowElement == null) {
|
360 | return;
|
361 | }
|
362 |
|
363 |
|
364 | if (typeof arrowElement === 'string') {
|
365 | arrowElement = state.elements.popper.querySelector(arrowElement);
|
366 |
|
367 | if (!arrowElement) {
|
368 | return;
|
369 | }
|
370 | }
|
371 |
|
372 | if (process.env.NODE_ENV !== "production") {
|
373 | if (!isHTMLElement(arrowElement)) {
|
374 | console.error(['Popper: "arrow" element must be an HTMLElement (not an SVGElement).', 'To use an SVG arrow, wrap it in an HTMLElement that will be used as', 'the arrow.'].join(' '));
|
375 | }
|
376 | }
|
377 |
|
378 | if (!contains(state.elements.popper, arrowElement)) {
|
379 | if (process.env.NODE_ENV !== "production") {
|
380 | console.error(['Popper: "arrow" modifier\'s `element` must be a child of the popper', 'element.'].join(' '));
|
381 | }
|
382 |
|
383 | return;
|
384 | }
|
385 |
|
386 | state.elements.arrow = arrowElement;
|
387 | }
|
388 |
|
389 |
|
390 | var arrow$1 = {
|
391 | name: 'arrow',
|
392 | enabled: true,
|
393 | phase: 'main',
|
394 | fn: arrow,
|
395 | effect: effect$1,
|
396 | requires: ['popperOffsets'],
|
397 | requiresIfExists: ['preventOverflow']
|
398 | };
|
399 |
|
400 | function getVariation(placement) {
|
401 | return placement.split('-')[1];
|
402 | }
|
403 |
|
404 | var unsetSides = {
|
405 | top: 'auto',
|
406 | right: 'auto',
|
407 | bottom: 'auto',
|
408 | left: 'auto'
|
409 | };
|
410 |
|
411 |
|
412 |
|
413 | function roundOffsetsByDPR(_ref) {
|
414 | var x = _ref.x,
|
415 | y = _ref.y;
|
416 | var win = window;
|
417 | var dpr = win.devicePixelRatio || 1;
|
418 | return {
|
419 | x: round(x * dpr) / dpr || 0,
|
420 | y: round(y * dpr) / dpr || 0
|
421 | };
|
422 | }
|
423 |
|
424 | function mapToStyles(_ref2) {
|
425 | var _Object$assign2;
|
426 |
|
427 | var popper = _ref2.popper,
|
428 | popperRect = _ref2.popperRect,
|
429 | placement = _ref2.placement,
|
430 | variation = _ref2.variation,
|
431 | offsets = _ref2.offsets,
|
432 | position = _ref2.position,
|
433 | gpuAcceleration = _ref2.gpuAcceleration,
|
434 | adaptive = _ref2.adaptive,
|
435 | roundOffsets = _ref2.roundOffsets,
|
436 | isFixed = _ref2.isFixed;
|
437 | var _offsets$x = offsets.x,
|
438 | x = _offsets$x === void 0 ? 0 : _offsets$x,
|
439 | _offsets$y = offsets.y,
|
440 | y = _offsets$y === void 0 ? 0 : _offsets$y;
|
441 |
|
442 | var _ref3 = typeof roundOffsets === 'function' ? roundOffsets({
|
443 | x: x,
|
444 | y: y
|
445 | }) : {
|
446 | x: x,
|
447 | y: y
|
448 | };
|
449 |
|
450 | x = _ref3.x;
|
451 | y = _ref3.y;
|
452 | var hasX = offsets.hasOwnProperty('x');
|
453 | var hasY = offsets.hasOwnProperty('y');
|
454 | var sideX = left;
|
455 | var sideY = top;
|
456 | var win = window;
|
457 |
|
458 | if (adaptive) {
|
459 | var offsetParent = getOffsetParent(popper);
|
460 | var heightProp = 'clientHeight';
|
461 | var widthProp = 'clientWidth';
|
462 |
|
463 | if (offsetParent === getWindow(popper)) {
|
464 | offsetParent = getDocumentElement(popper);
|
465 |
|
466 | if (getComputedStyle(offsetParent).position !== 'static' && position === 'absolute') {
|
467 | heightProp = 'scrollHeight';
|
468 | widthProp = 'scrollWidth';
|
469 | }
|
470 | }
|
471 |
|
472 |
|
473 | offsetParent = offsetParent;
|
474 |
|
475 | if (placement === top || (placement === left || placement === right) && variation === end) {
|
476 | sideY = bottom;
|
477 | var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height :
|
478 | offsetParent[heightProp];
|
479 | y -= offsetY - popperRect.height;
|
480 | y *= gpuAcceleration ? 1 : -1;
|
481 | }
|
482 |
|
483 | if (placement === left || (placement === top || placement === bottom) && variation === end) {
|
484 | sideX = right;
|
485 | var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width :
|
486 | offsetParent[widthProp];
|
487 | x -= offsetX - popperRect.width;
|
488 | x *= gpuAcceleration ? 1 : -1;
|
489 | }
|
490 | }
|
491 |
|
492 | var commonStyles = Object.assign({
|
493 | position: position
|
494 | }, adaptive && unsetSides);
|
495 |
|
496 | var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
|
497 | x: x,
|
498 | y: y
|
499 | }) : {
|
500 | x: x,
|
501 | y: y
|
502 | };
|
503 |
|
504 | x = _ref4.x;
|
505 | y = _ref4.y;
|
506 |
|
507 | if (gpuAcceleration) {
|
508 | var _Object$assign;
|
509 |
|
510 | return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
|
511 | }
|
512 |
|
513 | return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
|
514 | }
|
515 |
|
516 | function computeStyles(_ref5) {
|
517 | var state = _ref5.state,
|
518 | options = _ref5.options;
|
519 | var _options$gpuAccelerat = options.gpuAcceleration,
|
520 | gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
|
521 | _options$adaptive = options.adaptive,
|
522 | adaptive = _options$adaptive === void 0 ? true : _options$adaptive,
|
523 | _options$roundOffsets = options.roundOffsets,
|
524 | roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
|
525 |
|
526 | if (process.env.NODE_ENV !== "production") {
|
527 | var transitionProperty = getComputedStyle(state.elements.popper).transitionProperty || '';
|
528 |
|
529 | if (adaptive && ['transform', 'top', 'right', 'bottom', 'left'].some(function (property) {
|
530 | return transitionProperty.indexOf(property) >= 0;
|
531 | })) {
|
532 | console.warn(['Popper: Detected CSS transitions on at least one of the following', 'CSS properties: "transform", "top", "right", "bottom", "left".', '\n\n', 'Disable the "computeStyles" modifier\'s `adaptive` option to allow', 'for smooth transitions, or remove these properties from the CSS', 'transition declaration on the popper element if only transitioning', 'opacity or background-color for example.', '\n\n', 'We recommend using the popper element as a wrapper around an inner', 'element that can have any CSS property transitioned for animations.'].join(' '));
|
533 | }
|
534 | }
|
535 |
|
536 | var commonStyles = {
|
537 | placement: getBasePlacement(state.placement),
|
538 | variation: getVariation(state.placement),
|
539 | popper: state.elements.popper,
|
540 | popperRect: state.rects.popper,
|
541 | gpuAcceleration: gpuAcceleration,
|
542 | isFixed: state.options.strategy === 'fixed'
|
543 | };
|
544 |
|
545 | if (state.modifiersData.popperOffsets != null) {
|
546 | state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
|
547 | offsets: state.modifiersData.popperOffsets,
|
548 | position: state.options.strategy,
|
549 | adaptive: adaptive,
|
550 | roundOffsets: roundOffsets
|
551 | })));
|
552 | }
|
553 |
|
554 | if (state.modifiersData.arrow != null) {
|
555 | state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
|
556 | offsets: state.modifiersData.arrow,
|
557 | position: 'absolute',
|
558 | adaptive: false,
|
559 | roundOffsets: roundOffsets
|
560 | })));
|
561 | }
|
562 |
|
563 | state.attributes.popper = Object.assign({}, state.attributes.popper, {
|
564 | 'data-popper-placement': state.placement
|
565 | });
|
566 | }
|
567 |
|
568 |
|
569 | var computeStyles$1 = {
|
570 | name: 'computeStyles',
|
571 | enabled: true,
|
572 | phase: 'beforeWrite',
|
573 | fn: computeStyles,
|
574 | data: {}
|
575 | };
|
576 |
|
577 | var passive = {
|
578 | passive: true
|
579 | };
|
580 |
|
581 | function effect(_ref) {
|
582 | var state = _ref.state,
|
583 | instance = _ref.instance,
|
584 | options = _ref.options;
|
585 | var _options$scroll = options.scroll,
|
586 | scroll = _options$scroll === void 0 ? true : _options$scroll,
|
587 | _options$resize = options.resize,
|
588 | resize = _options$resize === void 0 ? true : _options$resize;
|
589 | var window = getWindow(state.elements.popper);
|
590 | var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
|
591 |
|
592 | if (scroll) {
|
593 | scrollParents.forEach(function (scrollParent) {
|
594 | scrollParent.addEventListener('scroll', instance.update, passive);
|
595 | });
|
596 | }
|
597 |
|
598 | if (resize) {
|
599 | window.addEventListener('resize', instance.update, passive);
|
600 | }
|
601 |
|
602 | return function () {
|
603 | if (scroll) {
|
604 | scrollParents.forEach(function (scrollParent) {
|
605 | scrollParent.removeEventListener('scroll', instance.update, passive);
|
606 | });
|
607 | }
|
608 |
|
609 | if (resize) {
|
610 | window.removeEventListener('resize', instance.update, passive);
|
611 | }
|
612 | };
|
613 | }
|
614 |
|
615 |
|
616 | var eventListeners = {
|
617 | name: 'eventListeners',
|
618 | enabled: true,
|
619 | phase: 'write',
|
620 | fn: function fn() {},
|
621 | effect: effect,
|
622 | data: {}
|
623 | };
|
624 |
|
625 | var hash$1 = {
|
626 | left: 'right',
|
627 | right: 'left',
|
628 | bottom: 'top',
|
629 | top: 'bottom'
|
630 | };
|
631 | function getOppositePlacement(placement) {
|
632 | return placement.replace(/left|right|bottom|top/g, function (matched) {
|
633 | return hash$1[matched];
|
634 | });
|
635 | }
|
636 |
|
637 | var hash = {
|
638 | start: 'end',
|
639 | end: 'start'
|
640 | };
|
641 | function getOppositeVariationPlacement(placement) {
|
642 | return placement.replace(/start|end/g, function (matched) {
|
643 | return hash[matched];
|
644 | });
|
645 | }
|
646 |
|
647 | function getWindowScroll(node) {
|
648 | var win = getWindow(node);
|
649 | var scrollLeft = win.pageXOffset;
|
650 | var scrollTop = win.pageYOffset;
|
651 | return {
|
652 | scrollLeft: scrollLeft,
|
653 | scrollTop: scrollTop
|
654 | };
|
655 | }
|
656 |
|
657 | function getWindowScrollBarX(element) {
|
658 |
|
659 |
|
660 |
|
661 |
|
662 |
|
663 |
|
664 |
|
665 | return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
|
666 | }
|
667 |
|
668 | function getViewportRect(element, strategy) {
|
669 | var win = getWindow(element);
|
670 | var html = getDocumentElement(element);
|
671 | var visualViewport = win.visualViewport;
|
672 | var width = html.clientWidth;
|
673 | var height = html.clientHeight;
|
674 | var x = 0;
|
675 | var y = 0;
|
676 |
|
677 | if (visualViewport) {
|
678 | width = visualViewport.width;
|
679 | height = visualViewport.height;
|
680 | var layoutViewport = isLayoutViewport();
|
681 |
|
682 | if (layoutViewport || !layoutViewport && strategy === 'fixed') {
|
683 | x = visualViewport.offsetLeft;
|
684 | y = visualViewport.offsetTop;
|
685 | }
|
686 | }
|
687 |
|
688 | return {
|
689 | width: width,
|
690 | height: height,
|
691 | x: x + getWindowScrollBarX(element),
|
692 | y: y
|
693 | };
|
694 | }
|
695 |
|
696 |
|
697 |
|
698 | function getDocumentRect(element) {
|
699 | var _element$ownerDocumen;
|
700 |
|
701 | var html = getDocumentElement(element);
|
702 | var winScroll = getWindowScroll(element);
|
703 | var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
|
704 | var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
|
705 | var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
|
706 | var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
|
707 | var y = -winScroll.scrollTop;
|
708 |
|
709 | if (getComputedStyle(body || html).direction === 'rtl') {
|
710 | x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
|
711 | }
|
712 |
|
713 | return {
|
714 | width: width,
|
715 | height: height,
|
716 | x: x,
|
717 | y: y
|
718 | };
|
719 | }
|
720 |
|
721 | function isScrollParent(element) {
|
722 |
|
723 | var _getComputedStyle = getComputedStyle(element),
|
724 | overflow = _getComputedStyle.overflow,
|
725 | overflowX = _getComputedStyle.overflowX,
|
726 | overflowY = _getComputedStyle.overflowY;
|
727 |
|
728 | return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
|
729 | }
|
730 |
|
731 | function getScrollParent(node) {
|
732 | if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
|
733 |
|
734 | return node.ownerDocument.body;
|
735 | }
|
736 |
|
737 | if (isHTMLElement(node) && isScrollParent(node)) {
|
738 | return node;
|
739 | }
|
740 |
|
741 | return getScrollParent(getParentNode(node));
|
742 | }
|
743 |
|
744 |
|
745 |
|
746 |
|
747 |
|
748 |
|
749 |
|
750 |
|
751 | function listScrollParents(element, list) {
|
752 | var _element$ownerDocumen;
|
753 |
|
754 | if (list === void 0) {
|
755 | list = [];
|
756 | }
|
757 |
|
758 | var scrollParent = getScrollParent(element);
|
759 | var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
|
760 | var win = getWindow(scrollParent);
|
761 | var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
|
762 | var updatedList = list.concat(target);
|
763 | return isBody ? updatedList :
|
764 | updatedList.concat(listScrollParents(getParentNode(target)));
|
765 | }
|
766 |
|
767 | function rectToClientRect(rect) {
|
768 | return Object.assign({}, rect, {
|
769 | left: rect.x,
|
770 | top: rect.y,
|
771 | right: rect.x + rect.width,
|
772 | bottom: rect.y + rect.height
|
773 | });
|
774 | }
|
775 |
|
776 | function getInnerBoundingClientRect(element, strategy) {
|
777 | var rect = getBoundingClientRect(element, false, strategy === 'fixed');
|
778 | rect.top = rect.top + element.clientTop;
|
779 | rect.left = rect.left + element.clientLeft;
|
780 | rect.bottom = rect.top + element.clientHeight;
|
781 | rect.right = rect.left + element.clientWidth;
|
782 | rect.width = element.clientWidth;
|
783 | rect.height = element.clientHeight;
|
784 | rect.x = rect.left;
|
785 | rect.y = rect.top;
|
786 | return rect;
|
787 | }
|
788 |
|
789 | function getClientRectFromMixedType(element, clippingParent, strategy) {
|
790 | return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
|
791 | }
|
792 |
|
793 |
|
794 |
|
795 |
|
796 | function getClippingParents(element) {
|
797 | var clippingParents = listScrollParents(getParentNode(element));
|
798 | var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle(element).position) >= 0;
|
799 | var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
|
800 |
|
801 | if (!isElement(clipperElement)) {
|
802 | return [];
|
803 | }
|
804 |
|
805 |
|
806 | return clippingParents.filter(function (clippingParent) {
|
807 | return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
|
808 | });
|
809 | }
|
810 |
|
811 |
|
812 |
|
813 | function getClippingRect(element, boundary, rootBoundary, strategy) {
|
814 | var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
|
815 | var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
|
816 | var firstClippingParent = clippingParents[0];
|
817 | var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
|
818 | var rect = getClientRectFromMixedType(element, clippingParent, strategy);
|
819 | accRect.top = max(rect.top, accRect.top);
|
820 | accRect.right = min(rect.right, accRect.right);
|
821 | accRect.bottom = min(rect.bottom, accRect.bottom);
|
822 | accRect.left = max(rect.left, accRect.left);
|
823 | return accRect;
|
824 | }, getClientRectFromMixedType(element, firstClippingParent, strategy));
|
825 | clippingRect.width = clippingRect.right - clippingRect.left;
|
826 | clippingRect.height = clippingRect.bottom - clippingRect.top;
|
827 | clippingRect.x = clippingRect.left;
|
828 | clippingRect.y = clippingRect.top;
|
829 | return clippingRect;
|
830 | }
|
831 |
|
832 | function computeOffsets(_ref) {
|
833 | var reference = _ref.reference,
|
834 | element = _ref.element,
|
835 | placement = _ref.placement;
|
836 | var basePlacement = placement ? getBasePlacement(placement) : null;
|
837 | var variation = placement ? getVariation(placement) : null;
|
838 | var commonX = reference.x + reference.width / 2 - element.width / 2;
|
839 | var commonY = reference.y + reference.height / 2 - element.height / 2;
|
840 | var offsets;
|
841 |
|
842 | switch (basePlacement) {
|
843 | case top:
|
844 | offsets = {
|
845 | x: commonX,
|
846 | y: reference.y - element.height
|
847 | };
|
848 | break;
|
849 |
|
850 | case bottom:
|
851 | offsets = {
|
852 | x: commonX,
|
853 | y: reference.y + reference.height
|
854 | };
|
855 | break;
|
856 |
|
857 | case right:
|
858 | offsets = {
|
859 | x: reference.x + reference.width,
|
860 | y: commonY
|
861 | };
|
862 | break;
|
863 |
|
864 | case left:
|
865 | offsets = {
|
866 | x: reference.x - element.width,
|
867 | y: commonY
|
868 | };
|
869 | break;
|
870 |
|
871 | default:
|
872 | offsets = {
|
873 | x: reference.x,
|
874 | y: reference.y
|
875 | };
|
876 | }
|
877 |
|
878 | var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
|
879 |
|
880 | if (mainAxis != null) {
|
881 | var len = mainAxis === 'y' ? 'height' : 'width';
|
882 |
|
883 | switch (variation) {
|
884 | case start:
|
885 | offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
|
886 | break;
|
887 |
|
888 | case end:
|
889 | offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
|
890 | break;
|
891 | }
|
892 | }
|
893 |
|
894 | return offsets;
|
895 | }
|
896 |
|
897 | function detectOverflow(state, options) {
|
898 | if (options === void 0) {
|
899 | options = {};
|
900 | }
|
901 |
|
902 | var _options = options,
|
903 | _options$placement = _options.placement,
|
904 | placement = _options$placement === void 0 ? state.placement : _options$placement,
|
905 | _options$strategy = _options.strategy,
|
906 | strategy = _options$strategy === void 0 ? state.strategy : _options$strategy,
|
907 | _options$boundary = _options.boundary,
|
908 | boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
|
909 | _options$rootBoundary = _options.rootBoundary,
|
910 | rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
|
911 | _options$elementConte = _options.elementContext,
|
912 | elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
|
913 | _options$altBoundary = _options.altBoundary,
|
914 | altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
|
915 | _options$padding = _options.padding,
|
916 | padding = _options$padding === void 0 ? 0 : _options$padding;
|
917 | var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
|
918 | var altContext = elementContext === popper ? reference : popper;
|
919 | var popperRect = state.rects.popper;
|
920 | var element = state.elements[altBoundary ? altContext : elementContext];
|
921 | var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary, strategy);
|
922 | var referenceClientRect = getBoundingClientRect(state.elements.reference);
|
923 | var popperOffsets = computeOffsets({
|
924 | reference: referenceClientRect,
|
925 | element: popperRect,
|
926 | strategy: 'absolute',
|
927 | placement: placement
|
928 | });
|
929 | var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets));
|
930 | var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect;
|
931 |
|
932 |
|
933 | var overflowOffsets = {
|
934 | top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
|
935 | bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
|
936 | left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
|
937 | right: elementClientRect.right - clippingClientRect.right + paddingObject.right
|
938 | };
|
939 | var offsetData = state.modifiersData.offset;
|
940 |
|
941 | if (elementContext === popper && offsetData) {
|
942 | var offset = offsetData[placement];
|
943 | Object.keys(overflowOffsets).forEach(function (key) {
|
944 | var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
|
945 | var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
|
946 | overflowOffsets[key] += offset[axis] * multiply;
|
947 | });
|
948 | }
|
949 |
|
950 | return overflowOffsets;
|
951 | }
|
952 |
|
953 | function computeAutoPlacement(state, options) {
|
954 | if (options === void 0) {
|
955 | options = {};
|
956 | }
|
957 |
|
958 | var _options = options,
|
959 | placement = _options.placement,
|
960 | boundary = _options.boundary,
|
961 | rootBoundary = _options.rootBoundary,
|
962 | padding = _options.padding,
|
963 | flipVariations = _options.flipVariations,
|
964 | _options$allowedAutoP = _options.allowedAutoPlacements,
|
965 | allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP;
|
966 | var variation = getVariation(placement);
|
967 | var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) {
|
968 | return getVariation(placement) === variation;
|
969 | }) : basePlacements;
|
970 | var allowedPlacements = placements$1.filter(function (placement) {
|
971 | return allowedAutoPlacements.indexOf(placement) >= 0;
|
972 | });
|
973 |
|
974 | if (allowedPlacements.length === 0) {
|
975 | allowedPlacements = placements$1;
|
976 |
|
977 | if (process.env.NODE_ENV !== "production") {
|
978 | console.error(['Popper: The `allowedAutoPlacements` option did not allow any', 'placements. Ensure the `placement` option matches the variation', 'of the allowed placements.', 'For example, "auto" cannot be used to allow "bottom-start".', 'Use "auto-start" instead.'].join(' '));
|
979 | }
|
980 | }
|
981 |
|
982 |
|
983 | var overflows = allowedPlacements.reduce(function (acc, placement) {
|
984 | acc[placement] = detectOverflow(state, {
|
985 | placement: placement,
|
986 | boundary: boundary,
|
987 | rootBoundary: rootBoundary,
|
988 | padding: padding
|
989 | })[getBasePlacement(placement)];
|
990 | return acc;
|
991 | }, {});
|
992 | return Object.keys(overflows).sort(function (a, b) {
|
993 | return overflows[a] - overflows[b];
|
994 | });
|
995 | }
|
996 |
|
997 | function getExpandedFallbackPlacements(placement) {
|
998 | if (getBasePlacement(placement) === auto) {
|
999 | return [];
|
1000 | }
|
1001 |
|
1002 | var oppositePlacement = getOppositePlacement(placement);
|
1003 | return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];
|
1004 | }
|
1005 |
|
1006 | function flip(_ref) {
|
1007 | var state = _ref.state,
|
1008 | options = _ref.options,
|
1009 | name = _ref.name;
|
1010 |
|
1011 | if (state.modifiersData[name]._skip) {
|
1012 | return;
|
1013 | }
|
1014 |
|
1015 | var _options$mainAxis = options.mainAxis,
|
1016 | checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
|
1017 | _options$altAxis = options.altAxis,
|
1018 | checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis,
|
1019 | specifiedFallbackPlacements = options.fallbackPlacements,
|
1020 | padding = options.padding,
|
1021 | boundary = options.boundary,
|
1022 | rootBoundary = options.rootBoundary,
|
1023 | altBoundary = options.altBoundary,
|
1024 | _options$flipVariatio = options.flipVariations,
|
1025 | flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio,
|
1026 | allowedAutoPlacements = options.allowedAutoPlacements;
|
1027 | var preferredPlacement = state.options.placement;
|
1028 | var basePlacement = getBasePlacement(preferredPlacement);
|
1029 | var isBasePlacement = basePlacement === preferredPlacement;
|
1030 | var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
|
1031 | var placements = [preferredPlacement].concat(fallbackPlacements).reduce(function (acc, placement) {
|
1032 | return acc.concat(getBasePlacement(placement) === auto ? computeAutoPlacement(state, {
|
1033 | placement: placement,
|
1034 | boundary: boundary,
|
1035 | rootBoundary: rootBoundary,
|
1036 | padding: padding,
|
1037 | flipVariations: flipVariations,
|
1038 | allowedAutoPlacements: allowedAutoPlacements
|
1039 | }) : placement);
|
1040 | }, []);
|
1041 | var referenceRect = state.rects.reference;
|
1042 | var popperRect = state.rects.popper;
|
1043 | var checksMap = new Map();
|
1044 | var makeFallbackChecks = true;
|
1045 | var firstFittingPlacement = placements[0];
|
1046 |
|
1047 | for (var i = 0; i < placements.length; i++) {
|
1048 | var placement = placements[i];
|
1049 |
|
1050 | var _basePlacement = getBasePlacement(placement);
|
1051 |
|
1052 | var isStartVariation = getVariation(placement) === start;
|
1053 | var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
|
1054 | var len = isVertical ? 'width' : 'height';
|
1055 | var overflow = detectOverflow(state, {
|
1056 | placement: placement,
|
1057 | boundary: boundary,
|
1058 | rootBoundary: rootBoundary,
|
1059 | altBoundary: altBoundary,
|
1060 | padding: padding
|
1061 | });
|
1062 | var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
|
1063 |
|
1064 | if (referenceRect[len] > popperRect[len]) {
|
1065 | mainVariationSide = getOppositePlacement(mainVariationSide);
|
1066 | }
|
1067 |
|
1068 | var altVariationSide = getOppositePlacement(mainVariationSide);
|
1069 | var checks = [];
|
1070 |
|
1071 | if (checkMainAxis) {
|
1072 | checks.push(overflow[_basePlacement] <= 0);
|
1073 | }
|
1074 |
|
1075 | if (checkAltAxis) {
|
1076 | checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
|
1077 | }
|
1078 |
|
1079 | if (checks.every(function (check) {
|
1080 | return check;
|
1081 | })) {
|
1082 | firstFittingPlacement = placement;
|
1083 | makeFallbackChecks = false;
|
1084 | break;
|
1085 | }
|
1086 |
|
1087 | checksMap.set(placement, checks);
|
1088 | }
|
1089 |
|
1090 | if (makeFallbackChecks) {
|
1091 |
|
1092 | var numberOfChecks = flipVariations ? 3 : 1;
|
1093 |
|
1094 | var _loop = function _loop(_i) {
|
1095 | var fittingPlacement = placements.find(function (placement) {
|
1096 | var checks = checksMap.get(placement);
|
1097 |
|
1098 | if (checks) {
|
1099 | return checks.slice(0, _i).every(function (check) {
|
1100 | return check;
|
1101 | });
|
1102 | }
|
1103 | });
|
1104 |
|
1105 | if (fittingPlacement) {
|
1106 | firstFittingPlacement = fittingPlacement;
|
1107 | return "break";
|
1108 | }
|
1109 | };
|
1110 |
|
1111 | for (var _i = numberOfChecks; _i > 0; _i--) {
|
1112 | var _ret = _loop(_i);
|
1113 |
|
1114 | if (_ret === "break") break;
|
1115 | }
|
1116 | }
|
1117 |
|
1118 | if (state.placement !== firstFittingPlacement) {
|
1119 | state.modifiersData[name]._skip = true;
|
1120 | state.placement = firstFittingPlacement;
|
1121 | state.reset = true;
|
1122 | }
|
1123 | }
|
1124 |
|
1125 |
|
1126 | var flip$1 = {
|
1127 | name: 'flip',
|
1128 | enabled: true,
|
1129 | phase: 'main',
|
1130 | fn: flip,
|
1131 | requiresIfExists: ['offset'],
|
1132 | data: {
|
1133 | _skip: false
|
1134 | }
|
1135 | };
|
1136 |
|
1137 | function getSideOffsets(overflow, rect, preventedOffsets) {
|
1138 | if (preventedOffsets === void 0) {
|
1139 | preventedOffsets = {
|
1140 | x: 0,
|
1141 | y: 0
|
1142 | };
|
1143 | }
|
1144 |
|
1145 | return {
|
1146 | top: overflow.top - rect.height - preventedOffsets.y,
|
1147 | right: overflow.right - rect.width + preventedOffsets.x,
|
1148 | bottom: overflow.bottom - rect.height + preventedOffsets.y,
|
1149 | left: overflow.left - rect.width - preventedOffsets.x
|
1150 | };
|
1151 | }
|
1152 |
|
1153 | function isAnySideFullyClipped(overflow) {
|
1154 | return [top, right, bottom, left].some(function (side) {
|
1155 | return overflow[side] >= 0;
|
1156 | });
|
1157 | }
|
1158 |
|
1159 | function hide(_ref) {
|
1160 | var state = _ref.state,
|
1161 | name = _ref.name;
|
1162 | var referenceRect = state.rects.reference;
|
1163 | var popperRect = state.rects.popper;
|
1164 | var preventedOffsets = state.modifiersData.preventOverflow;
|
1165 | var referenceOverflow = detectOverflow(state, {
|
1166 | elementContext: 'reference'
|
1167 | });
|
1168 | var popperAltOverflow = detectOverflow(state, {
|
1169 | altBoundary: true
|
1170 | });
|
1171 | var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
|
1172 | var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
|
1173 | var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
|
1174 | var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
|
1175 | state.modifiersData[name] = {
|
1176 | referenceClippingOffsets: referenceClippingOffsets,
|
1177 | popperEscapeOffsets: popperEscapeOffsets,
|
1178 | isReferenceHidden: isReferenceHidden,
|
1179 | hasPopperEscaped: hasPopperEscaped
|
1180 | };
|
1181 | state.attributes.popper = Object.assign({}, state.attributes.popper, {
|
1182 | 'data-popper-reference-hidden': isReferenceHidden,
|
1183 | 'data-popper-escaped': hasPopperEscaped
|
1184 | });
|
1185 | }
|
1186 |
|
1187 |
|
1188 | var hide$1 = {
|
1189 | name: 'hide',
|
1190 | enabled: true,
|
1191 | phase: 'main',
|
1192 | requiresIfExists: ['preventOverflow'],
|
1193 | fn: hide
|
1194 | };
|
1195 |
|
1196 | function distanceAndSkiddingToXY(placement, rects, offset) {
|
1197 | var basePlacement = getBasePlacement(placement);
|
1198 | var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
|
1199 |
|
1200 | var _ref = typeof offset === 'function' ? offset(Object.assign({}, rects, {
|
1201 | placement: placement
|
1202 | })) : offset,
|
1203 | skidding = _ref[0],
|
1204 | distance = _ref[1];
|
1205 |
|
1206 | skidding = skidding || 0;
|
1207 | distance = (distance || 0) * invertDistance;
|
1208 | return [left, right].indexOf(basePlacement) >= 0 ? {
|
1209 | x: distance,
|
1210 | y: skidding
|
1211 | } : {
|
1212 | x: skidding,
|
1213 | y: distance
|
1214 | };
|
1215 | }
|
1216 |
|
1217 | function offset(_ref2) {
|
1218 | var state = _ref2.state,
|
1219 | options = _ref2.options,
|
1220 | name = _ref2.name;
|
1221 | var _options$offset = options.offset,
|
1222 | offset = _options$offset === void 0 ? [0, 0] : _options$offset;
|
1223 | var data = placements.reduce(function (acc, placement) {
|
1224 | acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
|
1225 | return acc;
|
1226 | }, {});
|
1227 | var _data$state$placement = data[state.placement],
|
1228 | x = _data$state$placement.x,
|
1229 | y = _data$state$placement.y;
|
1230 |
|
1231 | if (state.modifiersData.popperOffsets != null) {
|
1232 | state.modifiersData.popperOffsets.x += x;
|
1233 | state.modifiersData.popperOffsets.y += y;
|
1234 | }
|
1235 |
|
1236 | state.modifiersData[name] = data;
|
1237 | }
|
1238 |
|
1239 |
|
1240 | var offset$1 = {
|
1241 | name: 'offset',
|
1242 | enabled: true,
|
1243 | phase: 'main',
|
1244 | requires: ['popperOffsets'],
|
1245 | fn: offset
|
1246 | };
|
1247 |
|
1248 | function popperOffsets(_ref) {
|
1249 | var state = _ref.state,
|
1250 | name = _ref.name;
|
1251 |
|
1252 |
|
1253 |
|
1254 |
|
1255 | state.modifiersData[name] = computeOffsets({
|
1256 | reference: state.rects.reference,
|
1257 | element: state.rects.popper,
|
1258 | strategy: 'absolute',
|
1259 | placement: state.placement
|
1260 | });
|
1261 | }
|
1262 |
|
1263 |
|
1264 | var popperOffsets$1 = {
|
1265 | name: 'popperOffsets',
|
1266 | enabled: true,
|
1267 | phase: 'read',
|
1268 | fn: popperOffsets,
|
1269 | data: {}
|
1270 | };
|
1271 |
|
1272 | function getAltAxis(axis) {
|
1273 | return axis === 'x' ? 'y' : 'x';
|
1274 | }
|
1275 |
|
1276 | function preventOverflow(_ref) {
|
1277 | var state = _ref.state,
|
1278 | options = _ref.options,
|
1279 | name = _ref.name;
|
1280 | var _options$mainAxis = options.mainAxis,
|
1281 | checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
|
1282 | _options$altAxis = options.altAxis,
|
1283 | checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis,
|
1284 | boundary = options.boundary,
|
1285 | rootBoundary = options.rootBoundary,
|
1286 | altBoundary = options.altBoundary,
|
1287 | padding = options.padding,
|
1288 | _options$tether = options.tether,
|
1289 | tether = _options$tether === void 0 ? true : _options$tether,
|
1290 | _options$tetherOffset = options.tetherOffset,
|
1291 | tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
|
1292 | var overflow = detectOverflow(state, {
|
1293 | boundary: boundary,
|
1294 | rootBoundary: rootBoundary,
|
1295 | padding: padding,
|
1296 | altBoundary: altBoundary
|
1297 | });
|
1298 | var basePlacement = getBasePlacement(state.placement);
|
1299 | var variation = getVariation(state.placement);
|
1300 | var isBasePlacement = !variation;
|
1301 | var mainAxis = getMainAxisFromPlacement(basePlacement);
|
1302 | var altAxis = getAltAxis(mainAxis);
|
1303 | var popperOffsets = state.modifiersData.popperOffsets;
|
1304 | var referenceRect = state.rects.reference;
|
1305 | var popperRect = state.rects.popper;
|
1306 | var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
|
1307 | placement: state.placement
|
1308 | })) : tetherOffset;
|
1309 | var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? {
|
1310 | mainAxis: tetherOffsetValue,
|
1311 | altAxis: tetherOffsetValue
|
1312 | } : Object.assign({
|
1313 | mainAxis: 0,
|
1314 | altAxis: 0
|
1315 | }, tetherOffsetValue);
|
1316 | var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
|
1317 | var data = {
|
1318 | x: 0,
|
1319 | y: 0
|
1320 | };
|
1321 |
|
1322 | if (!popperOffsets) {
|
1323 | return;
|
1324 | }
|
1325 |
|
1326 | if (checkMainAxis) {
|
1327 | var _offsetModifierState$;
|
1328 |
|
1329 | var mainSide = mainAxis === 'y' ? top : left;
|
1330 | var altSide = mainAxis === 'y' ? bottom : right;
|
1331 | var len = mainAxis === 'y' ? 'height' : 'width';
|
1332 | var offset = popperOffsets[mainAxis];
|
1333 | var min$1 = offset + overflow[mainSide];
|
1334 | var max$1 = offset - overflow[altSide];
|
1335 | var additive = tether ? -popperRect[len] / 2 : 0;
|
1336 | var minLen = variation === start ? referenceRect[len] : popperRect[len];
|
1337 | var maxLen = variation === start ? -popperRect[len] : -referenceRect[len];
|
1338 |
|
1339 |
|
1340 | var arrowElement = state.elements.arrow;
|
1341 | var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
|
1342 | width: 0,
|
1343 | height: 0
|
1344 | };
|
1345 | var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject();
|
1346 | var arrowPaddingMin = arrowPaddingObject[mainSide];
|
1347 | var arrowPaddingMax = arrowPaddingObject[altSide];
|
1348 |
|
1349 |
|
1350 |
|
1351 |
|
1352 |
|
1353 | var arrowLen = within(0, referenceRect[len], arrowRect[len]);
|
1354 | var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
|
1355 | var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
|
1356 | var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
|
1357 | var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
|
1358 | var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
|
1359 | var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;
|
1360 | var tetherMax = offset + maxOffset - offsetModifierValue;
|
1361 | var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
|
1362 | popperOffsets[mainAxis] = preventedOffset;
|
1363 | data[mainAxis] = preventedOffset - offset;
|
1364 | }
|
1365 |
|
1366 | if (checkAltAxis) {
|
1367 | var _offsetModifierState$2;
|
1368 |
|
1369 | var _mainSide = mainAxis === 'x' ? top : left;
|
1370 |
|
1371 | var _altSide = mainAxis === 'x' ? bottom : right;
|
1372 |
|
1373 | var _offset = popperOffsets[altAxis];
|
1374 |
|
1375 | var _len = altAxis === 'y' ? 'height' : 'width';
|
1376 |
|
1377 | var _min = _offset + overflow[_mainSide];
|
1378 |
|
1379 | var _max = _offset - overflow[_altSide];
|
1380 |
|
1381 | var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
|
1382 |
|
1383 | var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
|
1384 |
|
1385 | var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
|
1386 |
|
1387 | var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
|
1388 |
|
1389 | var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
|
1390 |
|
1391 | popperOffsets[altAxis] = _preventedOffset;
|
1392 | data[altAxis] = _preventedOffset - _offset;
|
1393 | }
|
1394 |
|
1395 | state.modifiersData[name] = data;
|
1396 | }
|
1397 |
|
1398 |
|
1399 | var preventOverflow$1 = {
|
1400 | name: 'preventOverflow',
|
1401 | enabled: true,
|
1402 | phase: 'main',
|
1403 | fn: preventOverflow,
|
1404 | requiresIfExists: ['offset']
|
1405 | };
|
1406 |
|
1407 | function getHTMLElementScroll(element) {
|
1408 | return {
|
1409 | scrollLeft: element.scrollLeft,
|
1410 | scrollTop: element.scrollTop
|
1411 | };
|
1412 | }
|
1413 |
|
1414 | function getNodeScroll(node) {
|
1415 | if (node === getWindow(node) || !isHTMLElement(node)) {
|
1416 | return getWindowScroll(node);
|
1417 | } else {
|
1418 | return getHTMLElementScroll(node);
|
1419 | }
|
1420 | }
|
1421 |
|
1422 | function isElementScaled(element) {
|
1423 | var rect = element.getBoundingClientRect();
|
1424 | var scaleX = round(rect.width) / element.offsetWidth || 1;
|
1425 | var scaleY = round(rect.height) / element.offsetHeight || 1;
|
1426 | return scaleX !== 1 || scaleY !== 1;
|
1427 | }
|
1428 |
|
1429 |
|
1430 |
|
1431 | function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
|
1432 | if (isFixed === void 0) {
|
1433 | isFixed = false;
|
1434 | }
|
1435 |
|
1436 | var isOffsetParentAnElement = isHTMLElement(offsetParent);
|
1437 | var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
|
1438 | var documentElement = getDocumentElement(offsetParent);
|
1439 | var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
|
1440 | var scroll = {
|
1441 | scrollLeft: 0,
|
1442 | scrollTop: 0
|
1443 | };
|
1444 | var offsets = {
|
1445 | x: 0,
|
1446 | y: 0
|
1447 | };
|
1448 |
|
1449 | if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
1450 | if (getNodeName(offsetParent) !== 'body' ||
|
1451 | isScrollParent(documentElement)) {
|
1452 | scroll = getNodeScroll(offsetParent);
|
1453 | }
|
1454 |
|
1455 | if (isHTMLElement(offsetParent)) {
|
1456 | offsets = getBoundingClientRect(offsetParent, true);
|
1457 | offsets.x += offsetParent.clientLeft;
|
1458 | offsets.y += offsetParent.clientTop;
|
1459 | } else if (documentElement) {
|
1460 | offsets.x = getWindowScrollBarX(documentElement);
|
1461 | }
|
1462 | }
|
1463 |
|
1464 | return {
|
1465 | x: rect.left + scroll.scrollLeft - offsets.x,
|
1466 | y: rect.top + scroll.scrollTop - offsets.y,
|
1467 | width: rect.width,
|
1468 | height: rect.height
|
1469 | };
|
1470 | }
|
1471 |
|
1472 | function order(modifiers) {
|
1473 | var map = new Map();
|
1474 | var visited = new Set();
|
1475 | var result = [];
|
1476 | modifiers.forEach(function (modifier) {
|
1477 | map.set(modifier.name, modifier);
|
1478 | });
|
1479 |
|
1480 | function sort(modifier) {
|
1481 | visited.add(modifier.name);
|
1482 | var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
|
1483 | requires.forEach(function (dep) {
|
1484 | if (!visited.has(dep)) {
|
1485 | var depModifier = map.get(dep);
|
1486 |
|
1487 | if (depModifier) {
|
1488 | sort(depModifier);
|
1489 | }
|
1490 | }
|
1491 | });
|
1492 | result.push(modifier);
|
1493 | }
|
1494 |
|
1495 | modifiers.forEach(function (modifier) {
|
1496 | if (!visited.has(modifier.name)) {
|
1497 |
|
1498 | sort(modifier);
|
1499 | }
|
1500 | });
|
1501 | return result;
|
1502 | }
|
1503 |
|
1504 | function orderModifiers(modifiers) {
|
1505 |
|
1506 | var orderedModifiers = order(modifiers);
|
1507 |
|
1508 | return modifierPhases.reduce(function (acc, phase) {
|
1509 | return acc.concat(orderedModifiers.filter(function (modifier) {
|
1510 | return modifier.phase === phase;
|
1511 | }));
|
1512 | }, []);
|
1513 | }
|
1514 |
|
1515 | function debounce(fn) {
|
1516 | var pending;
|
1517 | return function () {
|
1518 | if (!pending) {
|
1519 | pending = new Promise(function (resolve) {
|
1520 | Promise.resolve().then(function () {
|
1521 | pending = undefined;
|
1522 | resolve(fn());
|
1523 | });
|
1524 | });
|
1525 | }
|
1526 |
|
1527 | return pending;
|
1528 | };
|
1529 | }
|
1530 |
|
1531 | function format(str) {
|
1532 | for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
1533 | args[_key - 1] = arguments[_key];
|
1534 | }
|
1535 |
|
1536 | return [].concat(args).reduce(function (p, c) {
|
1537 | return p.replace(/%s/, c);
|
1538 | }, str);
|
1539 | }
|
1540 |
|
1541 | var INVALID_MODIFIER_ERROR = 'Popper: modifier "%s" provided an invalid %s property, expected %s but got %s';
|
1542 | var MISSING_DEPENDENCY_ERROR = 'Popper: modifier "%s" requires "%s", but "%s" modifier is not available';
|
1543 | var VALID_PROPERTIES = ['name', 'enabled', 'phase', 'fn', 'effect', 'requires', 'options'];
|
1544 | function validateModifiers(modifiers) {
|
1545 | modifiers.forEach(function (modifier) {
|
1546 | [].concat(Object.keys(modifier), VALID_PROPERTIES)
|
1547 | .filter(function (value, index, self) {
|
1548 | return self.indexOf(value) === index;
|
1549 | }).forEach(function (key) {
|
1550 | switch (key) {
|
1551 | case 'name':
|
1552 | if (typeof modifier.name !== 'string') {
|
1553 | console.error(format(INVALID_MODIFIER_ERROR, String(modifier.name), '"name"', '"string"', "\"" + String(modifier.name) + "\""));
|
1554 | }
|
1555 |
|
1556 | break;
|
1557 |
|
1558 | case 'enabled':
|
1559 | if (typeof modifier.enabled !== 'boolean') {
|
1560 | console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"enabled"', '"boolean"', "\"" + String(modifier.enabled) + "\""));
|
1561 | }
|
1562 |
|
1563 | break;
|
1564 |
|
1565 | case 'phase':
|
1566 | if (modifierPhases.indexOf(modifier.phase) < 0) {
|
1567 | console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"phase"', "either " + modifierPhases.join(', '), "\"" + String(modifier.phase) + "\""));
|
1568 | }
|
1569 |
|
1570 | break;
|
1571 |
|
1572 | case 'fn':
|
1573 | if (typeof modifier.fn !== 'function') {
|
1574 | console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"fn"', '"function"', "\"" + String(modifier.fn) + "\""));
|
1575 | }
|
1576 |
|
1577 | break;
|
1578 |
|
1579 | case 'effect':
|
1580 | if (modifier.effect != null && typeof modifier.effect !== 'function') {
|
1581 | console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"effect"', '"function"', "\"" + String(modifier.fn) + "\""));
|
1582 | }
|
1583 |
|
1584 | break;
|
1585 |
|
1586 | case 'requires':
|
1587 | if (modifier.requires != null && !Array.isArray(modifier.requires)) {
|
1588 | console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requires"', '"array"', "\"" + String(modifier.requires) + "\""));
|
1589 | }
|
1590 |
|
1591 | break;
|
1592 |
|
1593 | case 'requiresIfExists':
|
1594 | if (!Array.isArray(modifier.requiresIfExists)) {
|
1595 | console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requiresIfExists"', '"array"', "\"" + String(modifier.requiresIfExists) + "\""));
|
1596 | }
|
1597 |
|
1598 | break;
|
1599 |
|
1600 | case 'options':
|
1601 | case 'data':
|
1602 | break;
|
1603 |
|
1604 | default:
|
1605 | console.error("PopperJS: an invalid property has been provided to the \"" + modifier.name + "\" modifier, valid properties are " + VALID_PROPERTIES.map(function (s) {
|
1606 | return "\"" + s + "\"";
|
1607 | }).join(', ') + "; but \"" + key + "\" was provided.");
|
1608 | }
|
1609 |
|
1610 | modifier.requires && modifier.requires.forEach(function (requirement) {
|
1611 | if (modifiers.find(function (mod) {
|
1612 | return mod.name === requirement;
|
1613 | }) == null) {
|
1614 | console.error(format(MISSING_DEPENDENCY_ERROR, String(modifier.name), requirement, requirement));
|
1615 | }
|
1616 | });
|
1617 | });
|
1618 | });
|
1619 | }
|
1620 |
|
1621 | function uniqueBy(arr, fn) {
|
1622 | var identifiers = new Set();
|
1623 | return arr.filter(function (item) {
|
1624 | var identifier = fn(item);
|
1625 |
|
1626 | if (!identifiers.has(identifier)) {
|
1627 | identifiers.add(identifier);
|
1628 | return true;
|
1629 | }
|
1630 | });
|
1631 | }
|
1632 |
|
1633 | function mergeByName(modifiers) {
|
1634 | var merged = modifiers.reduce(function (merged, current) {
|
1635 | var existing = merged[current.name];
|
1636 | merged[current.name] = existing ? Object.assign({}, existing, current, {
|
1637 | options: Object.assign({}, existing.options, current.options),
|
1638 | data: Object.assign({}, existing.data, current.data)
|
1639 | }) : current;
|
1640 | return merged;
|
1641 | }, {});
|
1642 |
|
1643 | return Object.keys(merged).map(function (key) {
|
1644 | return merged[key];
|
1645 | });
|
1646 | }
|
1647 |
|
1648 | var INVALID_ELEMENT_ERROR = 'Popper: Invalid reference or popper argument provided. They must be either a DOM element or virtual element.';
|
1649 | var INFINITE_LOOP_ERROR = 'Popper: An infinite loop in the modifiers cycle has been detected! The cycle has been interrupted to prevent a browser crash.';
|
1650 | var DEFAULT_OPTIONS = {
|
1651 | placement: 'bottom',
|
1652 | modifiers: [],
|
1653 | strategy: 'absolute'
|
1654 | };
|
1655 |
|
1656 | function areValidElements() {
|
1657 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
1658 | args[_key] = arguments[_key];
|
1659 | }
|
1660 |
|
1661 | return !args.some(function (element) {
|
1662 | return !(element && typeof element.getBoundingClientRect === 'function');
|
1663 | });
|
1664 | }
|
1665 |
|
1666 | function popperGenerator(generatorOptions) {
|
1667 | if (generatorOptions === void 0) {
|
1668 | generatorOptions = {};
|
1669 | }
|
1670 |
|
1671 | var _generatorOptions = generatorOptions,
|
1672 | _generatorOptions$def = _generatorOptions.defaultModifiers,
|
1673 | defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,
|
1674 | _generatorOptions$def2 = _generatorOptions.defaultOptions,
|
1675 | defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
|
1676 | return function createPopper(reference, popper, options) {
|
1677 | if (options === void 0) {
|
1678 | options = defaultOptions;
|
1679 | }
|
1680 |
|
1681 | var state = {
|
1682 | placement: 'bottom',
|
1683 | orderedModifiers: [],
|
1684 | options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
|
1685 | modifiersData: {},
|
1686 | elements: {
|
1687 | reference: reference,
|
1688 | popper: popper
|
1689 | },
|
1690 | attributes: {},
|
1691 | styles: {}
|
1692 | };
|
1693 | var effectCleanupFns = [];
|
1694 | var isDestroyed = false;
|
1695 | var instance = {
|
1696 | state: state,
|
1697 | setOptions: function setOptions(setOptionsAction) {
|
1698 | var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;
|
1699 | cleanupModifierEffects();
|
1700 | state.options = Object.assign({}, defaultOptions, state.options, options);
|
1701 | state.scrollParents = {
|
1702 | reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
|
1703 | popper: listScrollParents(popper)
|
1704 | };
|
1705 |
|
1706 |
|
1707 | var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers)));
|
1708 |
|
1709 | state.orderedModifiers = orderedModifiers.filter(function (m) {
|
1710 | return m.enabled;
|
1711 | });
|
1712 |
|
1713 |
|
1714 | if (process.env.NODE_ENV !== "production") {
|
1715 | var modifiers = uniqueBy([].concat(orderedModifiers, state.options.modifiers), function (_ref) {
|
1716 | var name = _ref.name;
|
1717 | return name;
|
1718 | });
|
1719 | validateModifiers(modifiers);
|
1720 |
|
1721 | if (getBasePlacement(state.options.placement) === auto) {
|
1722 | var flipModifier = state.orderedModifiers.find(function (_ref2) {
|
1723 | var name = _ref2.name;
|
1724 | return name === 'flip';
|
1725 | });
|
1726 |
|
1727 | if (!flipModifier) {
|
1728 | console.error(['Popper: "auto" placements require the "flip" modifier be', 'present and enabled to work.'].join(' '));
|
1729 | }
|
1730 | }
|
1731 |
|
1732 | var _getComputedStyle = getComputedStyle(popper),
|
1733 | marginTop = _getComputedStyle.marginTop,
|
1734 | marginRight = _getComputedStyle.marginRight,
|
1735 | marginBottom = _getComputedStyle.marginBottom,
|
1736 | marginLeft = _getComputedStyle.marginLeft;
|
1737 |
|
1738 |
|
1739 |
|
1740 | if ([marginTop, marginRight, marginBottom, marginLeft].some(function (margin) {
|
1741 | return parseFloat(margin);
|
1742 | })) {
|
1743 | console.warn(['Popper: CSS "margin" styles cannot be used to apply padding', 'between the popper and its reference element or boundary.', 'To replicate margin, use the `offset` modifier, as well as', 'the `padding` option in the `preventOverflow` and `flip`', 'modifiers.'].join(' '));
|
1744 | }
|
1745 | }
|
1746 |
|
1747 | runModifierEffects();
|
1748 | return instance.update();
|
1749 | },
|
1750 |
|
1751 |
|
1752 |
|
1753 |
|
1754 |
|
1755 | forceUpdate: function forceUpdate() {
|
1756 | if (isDestroyed) {
|
1757 | return;
|
1758 | }
|
1759 |
|
1760 | var _state$elements = state.elements,
|
1761 | reference = _state$elements.reference,
|
1762 | popper = _state$elements.popper;
|
1763 |
|
1764 |
|
1765 | if (!areValidElements(reference, popper)) {
|
1766 | if (process.env.NODE_ENV !== "production") {
|
1767 | console.error(INVALID_ELEMENT_ERROR);
|
1768 | }
|
1769 |
|
1770 | return;
|
1771 | }
|
1772 |
|
1773 |
|
1774 | state.rects = {
|
1775 | reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),
|
1776 | popper: getLayoutRect(popper)
|
1777 | };
|
1778 |
|
1779 |
|
1780 |
|
1781 |
|
1782 |
|
1783 | state.reset = false;
|
1784 | state.placement = state.options.placement;
|
1785 |
|
1786 |
|
1787 |
|
1788 |
|
1789 | state.orderedModifiers.forEach(function (modifier) {
|
1790 | return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
|
1791 | });
|
1792 | var __debug_loops__ = 0;
|
1793 |
|
1794 | for (var index = 0; index < state.orderedModifiers.length; index++) {
|
1795 | if (process.env.NODE_ENV !== "production") {
|
1796 | __debug_loops__ += 1;
|
1797 |
|
1798 | if (__debug_loops__ > 100) {
|
1799 | console.error(INFINITE_LOOP_ERROR);
|
1800 | break;
|
1801 | }
|
1802 | }
|
1803 |
|
1804 | if (state.reset === true) {
|
1805 | state.reset = false;
|
1806 | index = -1;
|
1807 | continue;
|
1808 | }
|
1809 |
|
1810 | var _state$orderedModifie = state.orderedModifiers[index],
|
1811 | fn = _state$orderedModifie.fn,
|
1812 | _state$orderedModifie2 = _state$orderedModifie.options,
|
1813 | _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,
|
1814 | name = _state$orderedModifie.name;
|
1815 |
|
1816 | if (typeof fn === 'function') {
|
1817 | state = fn({
|
1818 | state: state,
|
1819 | options: _options,
|
1820 | name: name,
|
1821 | instance: instance
|
1822 | }) || state;
|
1823 | }
|
1824 | }
|
1825 | },
|
1826 |
|
1827 |
|
1828 | update: debounce(function () {
|
1829 | return new Promise(function (resolve) {
|
1830 | instance.forceUpdate();
|
1831 | resolve(state);
|
1832 | });
|
1833 | }),
|
1834 | destroy: function destroy() {
|
1835 | cleanupModifierEffects();
|
1836 | isDestroyed = true;
|
1837 | }
|
1838 | };
|
1839 |
|
1840 | if (!areValidElements(reference, popper)) {
|
1841 | if (process.env.NODE_ENV !== "production") {
|
1842 | console.error(INVALID_ELEMENT_ERROR);
|
1843 | }
|
1844 |
|
1845 | return instance;
|
1846 | }
|
1847 |
|
1848 | instance.setOptions(options).then(function (state) {
|
1849 | if (!isDestroyed && options.onFirstUpdate) {
|
1850 | options.onFirstUpdate(state);
|
1851 | }
|
1852 | });
|
1853 |
|
1854 |
|
1855 |
|
1856 |
|
1857 |
|
1858 | function runModifierEffects() {
|
1859 | state.orderedModifiers.forEach(function (_ref3) {
|
1860 | var name = _ref3.name,
|
1861 | _ref3$options = _ref3.options,
|
1862 | options = _ref3$options === void 0 ? {} : _ref3$options,
|
1863 | effect = _ref3.effect;
|
1864 |
|
1865 | if (typeof effect === 'function') {
|
1866 | var cleanupFn = effect({
|
1867 | state: state,
|
1868 | name: name,
|
1869 | instance: instance,
|
1870 | options: options
|
1871 | });
|
1872 |
|
1873 | var noopFn = function noopFn() {};
|
1874 |
|
1875 | effectCleanupFns.push(cleanupFn || noopFn);
|
1876 | }
|
1877 | });
|
1878 | }
|
1879 |
|
1880 | function cleanupModifierEffects() {
|
1881 | effectCleanupFns.forEach(function (fn) {
|
1882 | return fn();
|
1883 | });
|
1884 | effectCleanupFns = [];
|
1885 | }
|
1886 |
|
1887 | return instance;
|
1888 | };
|
1889 | }
|
1890 |
|
1891 |
|
1892 |
|
1893 | const createPopper = popperGenerator({
|
1894 | defaultModifiers: [
|
1895 | hide$1,
|
1896 | popperOffsets$1,
|
1897 | computeStyles$1,
|
1898 | eventListeners,
|
1899 | offset$1,
|
1900 | flip$1,
|
1901 | preventOverflow$1,
|
1902 | arrow$1,
|
1903 | ],
|
1904 | });
|
1905 |
|
1906 | exports.createPopper = createPopper;
|
1907 | exports.placements = placements;
|