@limetech/lime-elements 36.0.0-next.4 → 36.0.0-next.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/cjs/lime-elements.cjs.js +1 -1
  2. package/dist/cjs/limel-button.cjs.entry.js +2 -2
  3. package/dist/cjs/{limel-color-picker-palette_2.cjs.entry.js → limel-color-picker-palette.cjs.entry.js} +0 -112
  4. package/dist/cjs/limel-dock-button.cjs.entry.js +79 -0
  5. package/dist/cjs/limel-dock.cjs.entry.js +105 -0
  6. package/dist/cjs/{limel-list_3.cjs.entry.js → limel-list_2.cjs.entry.js} +0 -2018
  7. package/dist/cjs/limel-popover_4.cjs.entry.js +239 -0
  8. package/dist/cjs/limel-portal.cjs.entry.js +2024 -0
  9. package/dist/cjs/loader.cjs.js +1 -1
  10. package/dist/collection/collection-manifest.json +2 -0
  11. package/dist/collection/components/button/button.css +3 -0
  12. package/dist/collection/components/button/button.js +1 -2
  13. package/dist/collection/components/dock/dock-button/dock-button.css +71 -0
  14. package/dist/collection/components/dock/dock-button/dock-button.js +187 -0
  15. package/dist/collection/components/dock/dock.css +107 -0
  16. package/dist/collection/components/dock/dock.js +254 -0
  17. package/dist/collection/components/dock/dock.types.js +1 -0
  18. package/dist/esm/lime-elements.js +1 -1
  19. package/dist/esm/limel-button.entry.js +2 -2
  20. package/dist/esm/{limel-color-picker-palette_2.entry.js → limel-color-picker-palette.entry.js} +2 -113
  21. package/dist/esm/limel-dock-button.entry.js +75 -0
  22. package/dist/esm/limel-dock.entry.js +101 -0
  23. package/dist/esm/{limel-list_3.entry.js → limel-list_2.entry.js} +1 -2018
  24. package/dist/esm/limel-popover_4.entry.js +232 -0
  25. package/dist/esm/limel-portal.entry.js +2020 -0
  26. package/dist/esm/loader.js +1 -1
  27. package/dist/lime-elements/lime-elements.esm.js +1 -1
  28. package/dist/lime-elements/p-009de50e.entry.js +1 -0
  29. package/dist/lime-elements/{p-08251941.entry.js → p-19f72dab.entry.js} +1 -1
  30. package/dist/lime-elements/p-1dfccbc5.entry.js +1 -0
  31. package/dist/lime-elements/p-93cd2268.entry.js +1 -0
  32. package/dist/lime-elements/p-b9af1b40.entry.js +1 -0
  33. package/dist/lime-elements/p-bd098a11.entry.js +1 -0
  34. package/dist/lime-elements/p-fabea4b5.entry.js +1 -0
  35. package/dist/types/components/dock/dock-button/dock-button.d.ts +36 -0
  36. package/dist/types/components/dock/dock.d.ts +71 -0
  37. package/dist/types/components/dock/dock.types.d.ts +53 -0
  38. package/dist/types/components.d.ts +108 -0
  39. package/dist/types/interface.d.ts +1 -0
  40. package/package.json +1 -1
  41. package/dist/cjs/limel-popover-surface.cjs.entry.js +0 -32
  42. package/dist/cjs/limel-tooltip_2.cjs.entry.js +0 -102
  43. package/dist/esm/limel-popover-surface.entry.js +0 -28
  44. package/dist/esm/limel-tooltip_2.entry.js +0 -97
  45. package/dist/lime-elements/p-22569fb6.entry.js +0 -1
  46. package/dist/lime-elements/p-2fbfc1ea.entry.js +0 -1
  47. package/dist/lime-elements/p-705334c1.entry.js +0 -1
  48. package/dist/lime-elements/p-87453b45.entry.js +0 -1
@@ -0,0 +1,2024 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-2a28697b.js');
6
+
7
+ var top = 'top';
8
+ var bottom = 'bottom';
9
+ var right = 'right';
10
+ var left = 'left';
11
+ var auto = 'auto';
12
+ var basePlacements = [top, bottom, right, left];
13
+ var start = 'start';
14
+ var end = 'end';
15
+ var clippingParents = 'clippingParents';
16
+ var viewport = 'viewport';
17
+ var popper = 'popper';
18
+ var reference = 'reference';
19
+ var variationPlacements = /*#__PURE__*/basePlacements.reduce(function (acc, placement) {
20
+ return acc.concat([placement + "-" + start, placement + "-" + end]);
21
+ }, []);
22
+ var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) {
23
+ return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
24
+ }, []); // modifiers that need to read the DOM
25
+
26
+ var beforeRead = 'beforeRead';
27
+ var read = 'read';
28
+ var afterRead = 'afterRead'; // pure-logic modifiers
29
+
30
+ var beforeMain = 'beforeMain';
31
+ var main = 'main';
32
+ var afterMain = 'afterMain'; // modifier with the purpose to write to the DOM (or write into a framework state)
33
+
34
+ var beforeWrite = 'beforeWrite';
35
+ var write = 'write';
36
+ var afterWrite = 'afterWrite';
37
+ var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
38
+
39
+ function getNodeName(element) {
40
+ return element ? (element.nodeName || '').toLowerCase() : null;
41
+ }
42
+
43
+ function getWindow(node) {
44
+ if (node == null) {
45
+ return window;
46
+ }
47
+
48
+ if (node.toString() !== '[object Window]') {
49
+ var ownerDocument = node.ownerDocument;
50
+ return ownerDocument ? ownerDocument.defaultView || window : window;
51
+ }
52
+
53
+ return node;
54
+ }
55
+
56
+ function isElement(node) {
57
+ var OwnElement = getWindow(node).Element;
58
+ return node instanceof OwnElement || node instanceof Element;
59
+ }
60
+
61
+ function isHTMLElement(node) {
62
+ var OwnElement = getWindow(node).HTMLElement;
63
+ return node instanceof OwnElement || node instanceof HTMLElement;
64
+ }
65
+
66
+ function isShadowRoot(node) {
67
+ // IE 11 has no ShadowRoot
68
+ if (typeof ShadowRoot === 'undefined') {
69
+ return false;
70
+ }
71
+
72
+ var OwnElement = getWindow(node).ShadowRoot;
73
+ return node instanceof OwnElement || node instanceof ShadowRoot;
74
+ }
75
+
76
+ // and applies them to the HTMLElements such as popper and arrow
77
+
78
+ function applyStyles(_ref) {
79
+ var state = _ref.state;
80
+ Object.keys(state.elements).forEach(function (name) {
81
+ var style = state.styles[name] || {};
82
+ var attributes = state.attributes[name] || {};
83
+ var element = state.elements[name]; // arrow is optional + virtual elements
84
+
85
+ if (!isHTMLElement(element) || !getNodeName(element)) {
86
+ return;
87
+ } // Flow doesn't support to extend this property, but it's the most
88
+ // effective way to apply styles to an HTMLElement
89
+ // $FlowFixMe[cannot-write]
90
+
91
+
92
+ Object.assign(element.style, style);
93
+ Object.keys(attributes).forEach(function (name) {
94
+ var value = attributes[name];
95
+
96
+ if (value === false) {
97
+ element.removeAttribute(name);
98
+ } else {
99
+ element.setAttribute(name, value === true ? '' : value);
100
+ }
101
+ });
102
+ });
103
+ }
104
+
105
+ function effect$2(_ref2) {
106
+ var state = _ref2.state;
107
+ var initialStyles = {
108
+ popper: {
109
+ position: state.options.strategy,
110
+ left: '0',
111
+ top: '0',
112
+ margin: '0'
113
+ },
114
+ arrow: {
115
+ position: 'absolute'
116
+ },
117
+ reference: {}
118
+ };
119
+ Object.assign(state.elements.popper.style, initialStyles.popper);
120
+ state.styles = initialStyles;
121
+
122
+ if (state.elements.arrow) {
123
+ Object.assign(state.elements.arrow.style, initialStyles.arrow);
124
+ }
125
+
126
+ return function () {
127
+ Object.keys(state.elements).forEach(function (name) {
128
+ var element = state.elements[name];
129
+ var attributes = state.attributes[name] || {};
130
+ var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them
131
+
132
+ var style = styleProperties.reduce(function (style, property) {
133
+ style[property] = '';
134
+ return style;
135
+ }, {}); // arrow is optional + virtual elements
136
+
137
+ if (!isHTMLElement(element) || !getNodeName(element)) {
138
+ return;
139
+ }
140
+
141
+ Object.assign(element.style, style);
142
+ Object.keys(attributes).forEach(function (attribute) {
143
+ element.removeAttribute(attribute);
144
+ });
145
+ });
146
+ };
147
+ } // eslint-disable-next-line import/no-unused-modules
148
+
149
+
150
+ const applyStyles$1 = {
151
+ name: 'applyStyles',
152
+ enabled: true,
153
+ phase: 'write',
154
+ fn: applyStyles,
155
+ effect: effect$2,
156
+ requires: ['computeStyles']
157
+ };
158
+
159
+ function getBasePlacement(placement) {
160
+ return placement.split('-')[0];
161
+ }
162
+
163
+ var max = Math.max;
164
+ var min = Math.min;
165
+ var round = Math.round;
166
+
167
+ function getBoundingClientRect(element, includeScale) {
168
+ if (includeScale === void 0) {
169
+ includeScale = false;
170
+ }
171
+
172
+ var rect = element.getBoundingClientRect();
173
+ var scaleX = 1;
174
+ var scaleY = 1;
175
+
176
+ if (isHTMLElement(element) && includeScale) {
177
+ var offsetHeight = element.offsetHeight;
178
+ var offsetWidth = element.offsetWidth; // Do not attempt to divide by 0, otherwise we get `Infinity` as scale
179
+ // Fallback to 1 in case both values are `0`
180
+
181
+ if (offsetWidth > 0) {
182
+ scaleX = round(rect.width) / offsetWidth || 1;
183
+ }
184
+
185
+ if (offsetHeight > 0) {
186
+ scaleY = round(rect.height) / offsetHeight || 1;
187
+ }
188
+ }
189
+
190
+ return {
191
+ width: rect.width / scaleX,
192
+ height: rect.height / scaleY,
193
+ top: rect.top / scaleY,
194
+ right: rect.right / scaleX,
195
+ bottom: rect.bottom / scaleY,
196
+ left: rect.left / scaleX,
197
+ x: rect.left / scaleX,
198
+ y: rect.top / scaleY
199
+ };
200
+ }
201
+
202
+ // means it doesn't take into account transforms.
203
+
204
+ function getLayoutRect(element) {
205
+ var clientRect = getBoundingClientRect(element); // Use the clientRect sizes if it's not been transformed.
206
+ // Fixes https://github.com/popperjs/popper-core/issues/1223
207
+
208
+ var width = element.offsetWidth;
209
+ var height = element.offsetHeight;
210
+
211
+ if (Math.abs(clientRect.width - width) <= 1) {
212
+ width = clientRect.width;
213
+ }
214
+
215
+ if (Math.abs(clientRect.height - height) <= 1) {
216
+ height = clientRect.height;
217
+ }
218
+
219
+ return {
220
+ x: element.offsetLeft,
221
+ y: element.offsetTop,
222
+ width: width,
223
+ height: height
224
+ };
225
+ }
226
+
227
+ function contains(parent, child) {
228
+ var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method
229
+
230
+ if (parent.contains(child)) {
231
+ return true;
232
+ } // then fallback to custom implementation with Shadow DOM support
233
+ else if (rootNode && isShadowRoot(rootNode)) {
234
+ var next = child;
235
+
236
+ do {
237
+ if (next && parent.isSameNode(next)) {
238
+ return true;
239
+ } // $FlowFixMe[prop-missing]: need a better way to handle this...
240
+
241
+
242
+ next = next.parentNode || next.host;
243
+ } while (next);
244
+ } // Give up, the result is false
245
+
246
+
247
+ return false;
248
+ }
249
+
250
+ function getComputedStyle(element) {
251
+ return getWindow(element).getComputedStyle(element);
252
+ }
253
+
254
+ function isTableElement(element) {
255
+ return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
256
+ }
257
+
258
+ function getDocumentElement(element) {
259
+ // $FlowFixMe[incompatible-return]: assume body is always available
260
+ return ((isElement(element) ? element.ownerDocument : // $FlowFixMe[prop-missing]
261
+ element.document) || window.document).documentElement;
262
+ }
263
+
264
+ function getParentNode(element) {
265
+ if (getNodeName(element) === 'html') {
266
+ return element;
267
+ }
268
+
269
+ return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
270
+ // $FlowFixMe[incompatible-return]
271
+ // $FlowFixMe[prop-missing]
272
+ element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
273
+ element.parentNode || ( // DOM Element detected
274
+ isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
275
+ // $FlowFixMe[incompatible-call]: HTMLElement is a Node
276
+ getDocumentElement(element) // fallback
277
+
278
+ );
279
+ }
280
+
281
+ function getTrueOffsetParent(element) {
282
+ if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
283
+ getComputedStyle(element).position === 'fixed') {
284
+ return null;
285
+ }
286
+
287
+ return element.offsetParent;
288
+ } // `.offsetParent` reports `null` for fixed elements, while absolute elements
289
+ // return the containing block
290
+
291
+
292
+ function getContainingBlock(element) {
293
+ var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') !== -1;
294
+ var isIE = navigator.userAgent.indexOf('Trident') !== -1;
295
+
296
+ if (isIE && isHTMLElement(element)) {
297
+ // In IE 9, 10 and 11 fixed elements containing block is always established by the viewport
298
+ var elementCss = getComputedStyle(element);
299
+
300
+ if (elementCss.position === 'fixed') {
301
+ return null;
302
+ }
303
+ }
304
+
305
+ var currentNode = getParentNode(element);
306
+
307
+ if (isShadowRoot(currentNode)) {
308
+ currentNode = currentNode.host;
309
+ }
310
+
311
+ while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
312
+ var css = getComputedStyle(currentNode); // This is non-exhaustive but covers the most common CSS properties that
313
+ // create a containing block.
314
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
315
+
316
+ 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') {
317
+ return currentNode;
318
+ } else {
319
+ currentNode = currentNode.parentNode;
320
+ }
321
+ }
322
+
323
+ return null;
324
+ } // Gets the closest ancestor positioned element. Handles some edge cases,
325
+ // such as table ancestors and cross browser bugs.
326
+
327
+
328
+ function getOffsetParent(element) {
329
+ var window = getWindow(element);
330
+ var offsetParent = getTrueOffsetParent(element);
331
+
332
+ while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
333
+ offsetParent = getTrueOffsetParent(offsetParent);
334
+ }
335
+
336
+ if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static')) {
337
+ return window;
338
+ }
339
+
340
+ return offsetParent || getContainingBlock(element) || window;
341
+ }
342
+
343
+ function getMainAxisFromPlacement(placement) {
344
+ return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
345
+ }
346
+
347
+ function within(min$1, value, max$1) {
348
+ return max(min$1, min(value, max$1));
349
+ }
350
+ function withinMaxClamp(min, value, max) {
351
+ var v = within(min, value, max);
352
+ return v > max ? max : v;
353
+ }
354
+
355
+ function getFreshSideObject() {
356
+ return {
357
+ top: 0,
358
+ right: 0,
359
+ bottom: 0,
360
+ left: 0
361
+ };
362
+ }
363
+
364
+ function mergePaddingObject(paddingObject) {
365
+ return Object.assign({}, getFreshSideObject(), paddingObject);
366
+ }
367
+
368
+ function expandToHashMap(value, keys) {
369
+ return keys.reduce(function (hashMap, key) {
370
+ hashMap[key] = value;
371
+ return hashMap;
372
+ }, {});
373
+ }
374
+
375
+ var toPaddingObject = function toPaddingObject(padding, state) {
376
+ padding = typeof padding === 'function' ? padding(Object.assign({}, state.rects, {
377
+ placement: state.placement
378
+ })) : padding;
379
+ return mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
380
+ };
381
+
382
+ function arrow(_ref) {
383
+ var _state$modifiersData$;
384
+
385
+ var state = _ref.state,
386
+ name = _ref.name,
387
+ options = _ref.options;
388
+ var arrowElement = state.elements.arrow;
389
+ var popperOffsets = state.modifiersData.popperOffsets;
390
+ var basePlacement = getBasePlacement(state.placement);
391
+ var axis = getMainAxisFromPlacement(basePlacement);
392
+ var isVertical = [left, right].indexOf(basePlacement) >= 0;
393
+ var len = isVertical ? 'height' : 'width';
394
+
395
+ if (!arrowElement || !popperOffsets) {
396
+ return;
397
+ }
398
+
399
+ var paddingObject = toPaddingObject(options.padding, state);
400
+ var arrowRect = getLayoutRect(arrowElement);
401
+ var minProp = axis === 'y' ? top : left;
402
+ var maxProp = axis === 'y' ? bottom : right;
403
+ var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
404
+ var startDiff = popperOffsets[axis] - state.rects.reference[axis];
405
+ var arrowOffsetParent = getOffsetParent(arrowElement);
406
+ var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
407
+ var centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the popper if the center point is
408
+ // outside of the popper bounds
409
+
410
+ var min = paddingObject[minProp];
411
+ var max = clientSize - arrowRect[len] - paddingObject[maxProp];
412
+ var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
413
+ var offset = within(min, center, max); // Prevents breaking syntax highlighting...
414
+
415
+ var axisProp = axis;
416
+ state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);
417
+ }
418
+
419
+ function effect$1(_ref2) {
420
+ var state = _ref2.state,
421
+ options = _ref2.options;
422
+ var _options$element = options.element,
423
+ arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element;
424
+
425
+ if (arrowElement == null) {
426
+ return;
427
+ } // CSS selector
428
+
429
+
430
+ if (typeof arrowElement === 'string') {
431
+ arrowElement = state.elements.popper.querySelector(arrowElement);
432
+
433
+ if (!arrowElement) {
434
+ return;
435
+ }
436
+ }
437
+
438
+ if (!contains(state.elements.popper, arrowElement)) {
439
+
440
+ return;
441
+ }
442
+
443
+ state.elements.arrow = arrowElement;
444
+ } // eslint-disable-next-line import/no-unused-modules
445
+
446
+
447
+ const arrow$1 = {
448
+ name: 'arrow',
449
+ enabled: true,
450
+ phase: 'main',
451
+ fn: arrow,
452
+ effect: effect$1,
453
+ requires: ['popperOffsets'],
454
+ requiresIfExists: ['preventOverflow']
455
+ };
456
+
457
+ function getVariation(placement) {
458
+ return placement.split('-')[1];
459
+ }
460
+
461
+ var unsetSides = {
462
+ top: 'auto',
463
+ right: 'auto',
464
+ bottom: 'auto',
465
+ left: 'auto'
466
+ }; // Round the offsets to the nearest suitable subpixel based on the DPR.
467
+ // Zooming can change the DPR, but it seems to report a value that will
468
+ // cleanly divide the values into the appropriate subpixels.
469
+
470
+ function roundOffsetsByDPR(_ref) {
471
+ var x = _ref.x,
472
+ y = _ref.y;
473
+ var win = window;
474
+ var dpr = win.devicePixelRatio || 1;
475
+ return {
476
+ x: round(x * dpr) / dpr || 0,
477
+ y: round(y * dpr) / dpr || 0
478
+ };
479
+ }
480
+
481
+ function mapToStyles(_ref2) {
482
+ var _Object$assign2;
483
+
484
+ var popper = _ref2.popper,
485
+ popperRect = _ref2.popperRect,
486
+ placement = _ref2.placement,
487
+ variation = _ref2.variation,
488
+ offsets = _ref2.offsets,
489
+ position = _ref2.position,
490
+ gpuAcceleration = _ref2.gpuAcceleration,
491
+ adaptive = _ref2.adaptive,
492
+ roundOffsets = _ref2.roundOffsets,
493
+ isFixed = _ref2.isFixed;
494
+ var _offsets$x = offsets.x,
495
+ x = _offsets$x === void 0 ? 0 : _offsets$x,
496
+ _offsets$y = offsets.y,
497
+ y = _offsets$y === void 0 ? 0 : _offsets$y;
498
+
499
+ var _ref3 = typeof roundOffsets === 'function' ? roundOffsets({
500
+ x: x,
501
+ y: y
502
+ }) : {
503
+ x: x,
504
+ y: y
505
+ };
506
+
507
+ x = _ref3.x;
508
+ y = _ref3.y;
509
+ var hasX = offsets.hasOwnProperty('x');
510
+ var hasY = offsets.hasOwnProperty('y');
511
+ var sideX = left;
512
+ var sideY = top;
513
+ var win = window;
514
+
515
+ if (adaptive) {
516
+ var offsetParent = getOffsetParent(popper);
517
+ var heightProp = 'clientHeight';
518
+ var widthProp = 'clientWidth';
519
+
520
+ if (offsetParent === getWindow(popper)) {
521
+ offsetParent = getDocumentElement(popper);
522
+
523
+ if (getComputedStyle(offsetParent).position !== 'static' && position === 'absolute') {
524
+ heightProp = 'scrollHeight';
525
+ widthProp = 'scrollWidth';
526
+ }
527
+ } // $FlowFixMe[incompatible-cast]: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it
528
+
529
+
530
+ offsetParent = offsetParent;
531
+
532
+ if (placement === top || (placement === left || placement === right) && variation === end) {
533
+ sideY = bottom;
534
+ var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height : // $FlowFixMe[prop-missing]
535
+ offsetParent[heightProp];
536
+ y -= offsetY - popperRect.height;
537
+ y *= gpuAcceleration ? 1 : -1;
538
+ }
539
+
540
+ if (placement === left || (placement === top || placement === bottom) && variation === end) {
541
+ sideX = right;
542
+ var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width : // $FlowFixMe[prop-missing]
543
+ offsetParent[widthProp];
544
+ x -= offsetX - popperRect.width;
545
+ x *= gpuAcceleration ? 1 : -1;
546
+ }
547
+ }
548
+
549
+ var commonStyles = Object.assign({
550
+ position: position
551
+ }, adaptive && unsetSides);
552
+
553
+ var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
554
+ x: x,
555
+ y: y
556
+ }) : {
557
+ x: x,
558
+ y: y
559
+ };
560
+
561
+ x = _ref4.x;
562
+ y = _ref4.y;
563
+
564
+ if (gpuAcceleration) {
565
+ var _Object$assign;
566
+
567
+ 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));
568
+ }
569
+
570
+ return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
571
+ }
572
+
573
+ function computeStyles(_ref5) {
574
+ var state = _ref5.state,
575
+ options = _ref5.options;
576
+ var _options$gpuAccelerat = options.gpuAcceleration,
577
+ gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
578
+ _options$adaptive = options.adaptive,
579
+ adaptive = _options$adaptive === void 0 ? true : _options$adaptive,
580
+ _options$roundOffsets = options.roundOffsets,
581
+ roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
582
+
583
+ var commonStyles = {
584
+ placement: getBasePlacement(state.placement),
585
+ variation: getVariation(state.placement),
586
+ popper: state.elements.popper,
587
+ popperRect: state.rects.popper,
588
+ gpuAcceleration: gpuAcceleration,
589
+ isFixed: state.options.strategy === 'fixed'
590
+ };
591
+
592
+ if (state.modifiersData.popperOffsets != null) {
593
+ state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
594
+ offsets: state.modifiersData.popperOffsets,
595
+ position: state.options.strategy,
596
+ adaptive: adaptive,
597
+ roundOffsets: roundOffsets
598
+ })));
599
+ }
600
+
601
+ if (state.modifiersData.arrow != null) {
602
+ state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
603
+ offsets: state.modifiersData.arrow,
604
+ position: 'absolute',
605
+ adaptive: false,
606
+ roundOffsets: roundOffsets
607
+ })));
608
+ }
609
+
610
+ state.attributes.popper = Object.assign({}, state.attributes.popper, {
611
+ 'data-popper-placement': state.placement
612
+ });
613
+ } // eslint-disable-next-line import/no-unused-modules
614
+
615
+
616
+ const computeStyles$1 = {
617
+ name: 'computeStyles',
618
+ enabled: true,
619
+ phase: 'beforeWrite',
620
+ fn: computeStyles,
621
+ data: {}
622
+ };
623
+
624
+ var passive = {
625
+ passive: true
626
+ };
627
+
628
+ function effect(_ref) {
629
+ var state = _ref.state,
630
+ instance = _ref.instance,
631
+ options = _ref.options;
632
+ var _options$scroll = options.scroll,
633
+ scroll = _options$scroll === void 0 ? true : _options$scroll,
634
+ _options$resize = options.resize,
635
+ resize = _options$resize === void 0 ? true : _options$resize;
636
+ var window = getWindow(state.elements.popper);
637
+ var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
638
+
639
+ if (scroll) {
640
+ scrollParents.forEach(function (scrollParent) {
641
+ scrollParent.addEventListener('scroll', instance.update, passive);
642
+ });
643
+ }
644
+
645
+ if (resize) {
646
+ window.addEventListener('resize', instance.update, passive);
647
+ }
648
+
649
+ return function () {
650
+ if (scroll) {
651
+ scrollParents.forEach(function (scrollParent) {
652
+ scrollParent.removeEventListener('scroll', instance.update, passive);
653
+ });
654
+ }
655
+
656
+ if (resize) {
657
+ window.removeEventListener('resize', instance.update, passive);
658
+ }
659
+ };
660
+ } // eslint-disable-next-line import/no-unused-modules
661
+
662
+
663
+ const eventListeners = {
664
+ name: 'eventListeners',
665
+ enabled: true,
666
+ phase: 'write',
667
+ fn: function fn() {},
668
+ effect: effect,
669
+ data: {}
670
+ };
671
+
672
+ var hash$1 = {
673
+ left: 'right',
674
+ right: 'left',
675
+ bottom: 'top',
676
+ top: 'bottom'
677
+ };
678
+ function getOppositePlacement(placement) {
679
+ return placement.replace(/left|right|bottom|top/g, function (matched) {
680
+ return hash$1[matched];
681
+ });
682
+ }
683
+
684
+ var hash = {
685
+ start: 'end',
686
+ end: 'start'
687
+ };
688
+ function getOppositeVariationPlacement(placement) {
689
+ return placement.replace(/start|end/g, function (matched) {
690
+ return hash[matched];
691
+ });
692
+ }
693
+
694
+ function getWindowScroll(node) {
695
+ var win = getWindow(node);
696
+ var scrollLeft = win.pageXOffset;
697
+ var scrollTop = win.pageYOffset;
698
+ return {
699
+ scrollLeft: scrollLeft,
700
+ scrollTop: scrollTop
701
+ };
702
+ }
703
+
704
+ function getWindowScrollBarX(element) {
705
+ // If <html> has a CSS width greater than the viewport, then this will be
706
+ // incorrect for RTL.
707
+ // Popper 1 is broken in this case and never had a bug report so let's assume
708
+ // it's not an issue. I don't think anyone ever specifies width on <html>
709
+ // anyway.
710
+ // Browsers where the left scrollbar doesn't cause an issue report `0` for
711
+ // this (e.g. Edge 2019, IE11, Safari)
712
+ return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
713
+ }
714
+
715
+ function getViewportRect(element) {
716
+ var win = getWindow(element);
717
+ var html = getDocumentElement(element);
718
+ var visualViewport = win.visualViewport;
719
+ var width = html.clientWidth;
720
+ var height = html.clientHeight;
721
+ var x = 0;
722
+ var y = 0; // NB: This isn't supported on iOS <= 12. If the keyboard is open, the popper
723
+ // can be obscured underneath it.
724
+ // Also, `html.clientHeight` adds the bottom bar height in Safari iOS, even
725
+ // if it isn't open, so if this isn't available, the popper will be detected
726
+ // to overflow the bottom of the screen too early.
727
+
728
+ if (visualViewport) {
729
+ width = visualViewport.width;
730
+ height = visualViewport.height; // Uses Layout Viewport (like Chrome; Safari does not currently)
731
+ // In Chrome, it returns a value very close to 0 (+/-) but contains rounding
732
+ // errors due to floating point numbers, so we need to check precision.
733
+ // Safari returns a number <= 0, usually < -1 when pinch-zoomed
734
+ // Feature detection fails in mobile emulation mode in Chrome.
735
+ // Math.abs(win.innerWidth / visualViewport.scale - visualViewport.width) <
736
+ // 0.001
737
+ // Fallback here: "Not Safari" userAgent
738
+
739
+ if (!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
740
+ x = visualViewport.offsetLeft;
741
+ y = visualViewport.offsetTop;
742
+ }
743
+ }
744
+
745
+ return {
746
+ width: width,
747
+ height: height,
748
+ x: x + getWindowScrollBarX(element),
749
+ y: y
750
+ };
751
+ }
752
+
753
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable
754
+
755
+ function getDocumentRect(element) {
756
+ var _element$ownerDocumen;
757
+
758
+ var html = getDocumentElement(element);
759
+ var winScroll = getWindowScroll(element);
760
+ var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
761
+ var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
762
+ var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
763
+ var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
764
+ var y = -winScroll.scrollTop;
765
+
766
+ if (getComputedStyle(body || html).direction === 'rtl') {
767
+ x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
768
+ }
769
+
770
+ return {
771
+ width: width,
772
+ height: height,
773
+ x: x,
774
+ y: y
775
+ };
776
+ }
777
+
778
+ function isScrollParent(element) {
779
+ // Firefox wants us to check `-x` and `-y` variations as well
780
+ var _getComputedStyle = getComputedStyle(element),
781
+ overflow = _getComputedStyle.overflow,
782
+ overflowX = _getComputedStyle.overflowX,
783
+ overflowY = _getComputedStyle.overflowY;
784
+
785
+ return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
786
+ }
787
+
788
+ function getScrollParent(node) {
789
+ if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
790
+ // $FlowFixMe[incompatible-return]: assume body is always available
791
+ return node.ownerDocument.body;
792
+ }
793
+
794
+ if (isHTMLElement(node) && isScrollParent(node)) {
795
+ return node;
796
+ }
797
+
798
+ return getScrollParent(getParentNode(node));
799
+ }
800
+
801
+ /*
802
+ given a DOM element, return the list of all scroll parents, up the list of ancesors
803
+ until we get to the top window object. This list is what we attach scroll listeners
804
+ to, because if any of these parent elements scroll, we'll need to re-calculate the
805
+ reference element's position.
806
+ */
807
+
808
+ function listScrollParents(element, list) {
809
+ var _element$ownerDocumen;
810
+
811
+ if (list === void 0) {
812
+ list = [];
813
+ }
814
+
815
+ var scrollParent = getScrollParent(element);
816
+ var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
817
+ var win = getWindow(scrollParent);
818
+ var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
819
+ var updatedList = list.concat(target);
820
+ return isBody ? updatedList : // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
821
+ updatedList.concat(listScrollParents(getParentNode(target)));
822
+ }
823
+
824
+ function rectToClientRect(rect) {
825
+ return Object.assign({}, rect, {
826
+ left: rect.x,
827
+ top: rect.y,
828
+ right: rect.x + rect.width,
829
+ bottom: rect.y + rect.height
830
+ });
831
+ }
832
+
833
+ function getInnerBoundingClientRect(element) {
834
+ var rect = getBoundingClientRect(element);
835
+ rect.top = rect.top + element.clientTop;
836
+ rect.left = rect.left + element.clientLeft;
837
+ rect.bottom = rect.top + element.clientHeight;
838
+ rect.right = rect.left + element.clientWidth;
839
+ rect.width = element.clientWidth;
840
+ rect.height = element.clientHeight;
841
+ rect.x = rect.left;
842
+ rect.y = rect.top;
843
+ return rect;
844
+ }
845
+
846
+ function getClientRectFromMixedType(element, clippingParent) {
847
+ return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
848
+ } // A "clipping parent" is an overflowable container with the characteristic of
849
+ // clipping (or hiding) overflowing elements with a position different from
850
+ // `initial`
851
+
852
+
853
+ function getClippingParents(element) {
854
+ var clippingParents = listScrollParents(getParentNode(element));
855
+ var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle(element).position) >= 0;
856
+ var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
857
+
858
+ if (!isElement(clipperElement)) {
859
+ return [];
860
+ } // $FlowFixMe[incompatible-return]: https://github.com/facebook/flow/issues/1414
861
+
862
+
863
+ return clippingParents.filter(function (clippingParent) {
864
+ return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
865
+ });
866
+ } // Gets the maximum area that the element is visible in due to any number of
867
+ // clipping parents
868
+
869
+
870
+ function getClippingRect(element, boundary, rootBoundary) {
871
+ var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
872
+ var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
873
+ var firstClippingParent = clippingParents[0];
874
+ var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
875
+ var rect = getClientRectFromMixedType(element, clippingParent);
876
+ accRect.top = max(rect.top, accRect.top);
877
+ accRect.right = min(rect.right, accRect.right);
878
+ accRect.bottom = min(rect.bottom, accRect.bottom);
879
+ accRect.left = max(rect.left, accRect.left);
880
+ return accRect;
881
+ }, getClientRectFromMixedType(element, firstClippingParent));
882
+ clippingRect.width = clippingRect.right - clippingRect.left;
883
+ clippingRect.height = clippingRect.bottom - clippingRect.top;
884
+ clippingRect.x = clippingRect.left;
885
+ clippingRect.y = clippingRect.top;
886
+ return clippingRect;
887
+ }
888
+
889
+ function computeOffsets(_ref) {
890
+ var reference = _ref.reference,
891
+ element = _ref.element,
892
+ placement = _ref.placement;
893
+ var basePlacement = placement ? getBasePlacement(placement) : null;
894
+ var variation = placement ? getVariation(placement) : null;
895
+ var commonX = reference.x + reference.width / 2 - element.width / 2;
896
+ var commonY = reference.y + reference.height / 2 - element.height / 2;
897
+ var offsets;
898
+
899
+ switch (basePlacement) {
900
+ case top:
901
+ offsets = {
902
+ x: commonX,
903
+ y: reference.y - element.height
904
+ };
905
+ break;
906
+
907
+ case bottom:
908
+ offsets = {
909
+ x: commonX,
910
+ y: reference.y + reference.height
911
+ };
912
+ break;
913
+
914
+ case right:
915
+ offsets = {
916
+ x: reference.x + reference.width,
917
+ y: commonY
918
+ };
919
+ break;
920
+
921
+ case left:
922
+ offsets = {
923
+ x: reference.x - element.width,
924
+ y: commonY
925
+ };
926
+ break;
927
+
928
+ default:
929
+ offsets = {
930
+ x: reference.x,
931
+ y: reference.y
932
+ };
933
+ }
934
+
935
+ var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
936
+
937
+ if (mainAxis != null) {
938
+ var len = mainAxis === 'y' ? 'height' : 'width';
939
+
940
+ switch (variation) {
941
+ case start:
942
+ offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
943
+ break;
944
+
945
+ case end:
946
+ offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
947
+ break;
948
+ }
949
+ }
950
+
951
+ return offsets;
952
+ }
953
+
954
+ function detectOverflow(state, options) {
955
+ if (options === void 0) {
956
+ options = {};
957
+ }
958
+
959
+ var _options = options,
960
+ _options$placement = _options.placement,
961
+ placement = _options$placement === void 0 ? state.placement : _options$placement,
962
+ _options$boundary = _options.boundary,
963
+ boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
964
+ _options$rootBoundary = _options.rootBoundary,
965
+ rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
966
+ _options$elementConte = _options.elementContext,
967
+ elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
968
+ _options$altBoundary = _options.altBoundary,
969
+ altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
970
+ _options$padding = _options.padding,
971
+ padding = _options$padding === void 0 ? 0 : _options$padding;
972
+ var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
973
+ var altContext = elementContext === popper ? reference : popper;
974
+ var popperRect = state.rects.popper;
975
+ var element = state.elements[altBoundary ? altContext : elementContext];
976
+ var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
977
+ var referenceClientRect = getBoundingClientRect(state.elements.reference);
978
+ var popperOffsets = computeOffsets({
979
+ reference: referenceClientRect,
980
+ element: popperRect,
981
+ strategy: 'absolute',
982
+ placement: placement
983
+ });
984
+ var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets));
985
+ var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect
986
+ // 0 or negative = within the clipping rect
987
+
988
+ var overflowOffsets = {
989
+ top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
990
+ bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
991
+ left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
992
+ right: elementClientRect.right - clippingClientRect.right + paddingObject.right
993
+ };
994
+ var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element
995
+
996
+ if (elementContext === popper && offsetData) {
997
+ var offset = offsetData[placement];
998
+ Object.keys(overflowOffsets).forEach(function (key) {
999
+ var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
1000
+ var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
1001
+ overflowOffsets[key] += offset[axis] * multiply;
1002
+ });
1003
+ }
1004
+
1005
+ return overflowOffsets;
1006
+ }
1007
+
1008
+ function computeAutoPlacement(state, options) {
1009
+ if (options === void 0) {
1010
+ options = {};
1011
+ }
1012
+
1013
+ var _options = options,
1014
+ placement = _options.placement,
1015
+ boundary = _options.boundary,
1016
+ rootBoundary = _options.rootBoundary,
1017
+ padding = _options.padding,
1018
+ flipVariations = _options.flipVariations,
1019
+ _options$allowedAutoP = _options.allowedAutoPlacements,
1020
+ allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP;
1021
+ var variation = getVariation(placement);
1022
+ var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) {
1023
+ return getVariation(placement) === variation;
1024
+ }) : basePlacements;
1025
+ var allowedPlacements = placements$1.filter(function (placement) {
1026
+ return allowedAutoPlacements.indexOf(placement) >= 0;
1027
+ });
1028
+
1029
+ if (allowedPlacements.length === 0) {
1030
+ allowedPlacements = placements$1;
1031
+ } // $FlowFixMe[incompatible-type]: Flow seems to have problems with two array unions...
1032
+
1033
+
1034
+ var overflows = allowedPlacements.reduce(function (acc, placement) {
1035
+ acc[placement] = detectOverflow(state, {
1036
+ placement: placement,
1037
+ boundary: boundary,
1038
+ rootBoundary: rootBoundary,
1039
+ padding: padding
1040
+ })[getBasePlacement(placement)];
1041
+ return acc;
1042
+ }, {});
1043
+ return Object.keys(overflows).sort(function (a, b) {
1044
+ return overflows[a] - overflows[b];
1045
+ });
1046
+ }
1047
+
1048
+ function getExpandedFallbackPlacements(placement) {
1049
+ if (getBasePlacement(placement) === auto) {
1050
+ return [];
1051
+ }
1052
+
1053
+ var oppositePlacement = getOppositePlacement(placement);
1054
+ return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];
1055
+ }
1056
+
1057
+ function flip(_ref) {
1058
+ var state = _ref.state,
1059
+ options = _ref.options,
1060
+ name = _ref.name;
1061
+
1062
+ if (state.modifiersData[name]._skip) {
1063
+ return;
1064
+ }
1065
+
1066
+ var _options$mainAxis = options.mainAxis,
1067
+ checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
1068
+ _options$altAxis = options.altAxis,
1069
+ checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis,
1070
+ specifiedFallbackPlacements = options.fallbackPlacements,
1071
+ padding = options.padding,
1072
+ boundary = options.boundary,
1073
+ rootBoundary = options.rootBoundary,
1074
+ altBoundary = options.altBoundary,
1075
+ _options$flipVariatio = options.flipVariations,
1076
+ flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio,
1077
+ allowedAutoPlacements = options.allowedAutoPlacements;
1078
+ var preferredPlacement = state.options.placement;
1079
+ var basePlacement = getBasePlacement(preferredPlacement);
1080
+ var isBasePlacement = basePlacement === preferredPlacement;
1081
+ var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
1082
+ var placements = [preferredPlacement].concat(fallbackPlacements).reduce(function (acc, placement) {
1083
+ return acc.concat(getBasePlacement(placement) === auto ? computeAutoPlacement(state, {
1084
+ placement: placement,
1085
+ boundary: boundary,
1086
+ rootBoundary: rootBoundary,
1087
+ padding: padding,
1088
+ flipVariations: flipVariations,
1089
+ allowedAutoPlacements: allowedAutoPlacements
1090
+ }) : placement);
1091
+ }, []);
1092
+ var referenceRect = state.rects.reference;
1093
+ var popperRect = state.rects.popper;
1094
+ var checksMap = new Map();
1095
+ var makeFallbackChecks = true;
1096
+ var firstFittingPlacement = placements[0];
1097
+
1098
+ for (var i = 0; i < placements.length; i++) {
1099
+ var placement = placements[i];
1100
+
1101
+ var _basePlacement = getBasePlacement(placement);
1102
+
1103
+ var isStartVariation = getVariation(placement) === start;
1104
+ var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
1105
+ var len = isVertical ? 'width' : 'height';
1106
+ var overflow = detectOverflow(state, {
1107
+ placement: placement,
1108
+ boundary: boundary,
1109
+ rootBoundary: rootBoundary,
1110
+ altBoundary: altBoundary,
1111
+ padding: padding
1112
+ });
1113
+ var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
1114
+
1115
+ if (referenceRect[len] > popperRect[len]) {
1116
+ mainVariationSide = getOppositePlacement(mainVariationSide);
1117
+ }
1118
+
1119
+ var altVariationSide = getOppositePlacement(mainVariationSide);
1120
+ var checks = [];
1121
+
1122
+ if (checkMainAxis) {
1123
+ checks.push(overflow[_basePlacement] <= 0);
1124
+ }
1125
+
1126
+ if (checkAltAxis) {
1127
+ checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
1128
+ }
1129
+
1130
+ if (checks.every(function (check) {
1131
+ return check;
1132
+ })) {
1133
+ firstFittingPlacement = placement;
1134
+ makeFallbackChecks = false;
1135
+ break;
1136
+ }
1137
+
1138
+ checksMap.set(placement, checks);
1139
+ }
1140
+
1141
+ if (makeFallbackChecks) {
1142
+ // `2` may be desired in some cases – research later
1143
+ var numberOfChecks = flipVariations ? 3 : 1;
1144
+
1145
+ var _loop = function _loop(_i) {
1146
+ var fittingPlacement = placements.find(function (placement) {
1147
+ var checks = checksMap.get(placement);
1148
+
1149
+ if (checks) {
1150
+ return checks.slice(0, _i).every(function (check) {
1151
+ return check;
1152
+ });
1153
+ }
1154
+ });
1155
+
1156
+ if (fittingPlacement) {
1157
+ firstFittingPlacement = fittingPlacement;
1158
+ return "break";
1159
+ }
1160
+ };
1161
+
1162
+ for (var _i = numberOfChecks; _i > 0; _i--) {
1163
+ var _ret = _loop(_i);
1164
+
1165
+ if (_ret === "break") break;
1166
+ }
1167
+ }
1168
+
1169
+ if (state.placement !== firstFittingPlacement) {
1170
+ state.modifiersData[name]._skip = true;
1171
+ state.placement = firstFittingPlacement;
1172
+ state.reset = true;
1173
+ }
1174
+ } // eslint-disable-next-line import/no-unused-modules
1175
+
1176
+
1177
+ const flip$1 = {
1178
+ name: 'flip',
1179
+ enabled: true,
1180
+ phase: 'main',
1181
+ fn: flip,
1182
+ requiresIfExists: ['offset'],
1183
+ data: {
1184
+ _skip: false
1185
+ }
1186
+ };
1187
+
1188
+ function getSideOffsets(overflow, rect, preventedOffsets) {
1189
+ if (preventedOffsets === void 0) {
1190
+ preventedOffsets = {
1191
+ x: 0,
1192
+ y: 0
1193
+ };
1194
+ }
1195
+
1196
+ return {
1197
+ top: overflow.top - rect.height - preventedOffsets.y,
1198
+ right: overflow.right - rect.width + preventedOffsets.x,
1199
+ bottom: overflow.bottom - rect.height + preventedOffsets.y,
1200
+ left: overflow.left - rect.width - preventedOffsets.x
1201
+ };
1202
+ }
1203
+
1204
+ function isAnySideFullyClipped(overflow) {
1205
+ return [top, right, bottom, left].some(function (side) {
1206
+ return overflow[side] >= 0;
1207
+ });
1208
+ }
1209
+
1210
+ function hide(_ref) {
1211
+ var state = _ref.state,
1212
+ name = _ref.name;
1213
+ var referenceRect = state.rects.reference;
1214
+ var popperRect = state.rects.popper;
1215
+ var preventedOffsets = state.modifiersData.preventOverflow;
1216
+ var referenceOverflow = detectOverflow(state, {
1217
+ elementContext: 'reference'
1218
+ });
1219
+ var popperAltOverflow = detectOverflow(state, {
1220
+ altBoundary: true
1221
+ });
1222
+ var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
1223
+ var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
1224
+ var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
1225
+ var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
1226
+ state.modifiersData[name] = {
1227
+ referenceClippingOffsets: referenceClippingOffsets,
1228
+ popperEscapeOffsets: popperEscapeOffsets,
1229
+ isReferenceHidden: isReferenceHidden,
1230
+ hasPopperEscaped: hasPopperEscaped
1231
+ };
1232
+ state.attributes.popper = Object.assign({}, state.attributes.popper, {
1233
+ 'data-popper-reference-hidden': isReferenceHidden,
1234
+ 'data-popper-escaped': hasPopperEscaped
1235
+ });
1236
+ } // eslint-disable-next-line import/no-unused-modules
1237
+
1238
+
1239
+ const hide$1 = {
1240
+ name: 'hide',
1241
+ enabled: true,
1242
+ phase: 'main',
1243
+ requiresIfExists: ['preventOverflow'],
1244
+ fn: hide
1245
+ };
1246
+
1247
+ function distanceAndSkiddingToXY(placement, rects, offset) {
1248
+ var basePlacement = getBasePlacement(placement);
1249
+ var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
1250
+
1251
+ var _ref = typeof offset === 'function' ? offset(Object.assign({}, rects, {
1252
+ placement: placement
1253
+ })) : offset,
1254
+ skidding = _ref[0],
1255
+ distance = _ref[1];
1256
+
1257
+ skidding = skidding || 0;
1258
+ distance = (distance || 0) * invertDistance;
1259
+ return [left, right].indexOf(basePlacement) >= 0 ? {
1260
+ x: distance,
1261
+ y: skidding
1262
+ } : {
1263
+ x: skidding,
1264
+ y: distance
1265
+ };
1266
+ }
1267
+
1268
+ function offset(_ref2) {
1269
+ var state = _ref2.state,
1270
+ options = _ref2.options,
1271
+ name = _ref2.name;
1272
+ var _options$offset = options.offset,
1273
+ offset = _options$offset === void 0 ? [0, 0] : _options$offset;
1274
+ var data = placements.reduce(function (acc, placement) {
1275
+ acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
1276
+ return acc;
1277
+ }, {});
1278
+ var _data$state$placement = data[state.placement],
1279
+ x = _data$state$placement.x,
1280
+ y = _data$state$placement.y;
1281
+
1282
+ if (state.modifiersData.popperOffsets != null) {
1283
+ state.modifiersData.popperOffsets.x += x;
1284
+ state.modifiersData.popperOffsets.y += y;
1285
+ }
1286
+
1287
+ state.modifiersData[name] = data;
1288
+ } // eslint-disable-next-line import/no-unused-modules
1289
+
1290
+
1291
+ const offset$1 = {
1292
+ name: 'offset',
1293
+ enabled: true,
1294
+ phase: 'main',
1295
+ requires: ['popperOffsets'],
1296
+ fn: offset
1297
+ };
1298
+
1299
+ function popperOffsets(_ref) {
1300
+ var state = _ref.state,
1301
+ name = _ref.name;
1302
+ // Offsets are the actual position the popper needs to have to be
1303
+ // properly positioned near its reference element
1304
+ // This is the most basic placement, and will be adjusted by
1305
+ // the modifiers in the next step
1306
+ state.modifiersData[name] = computeOffsets({
1307
+ reference: state.rects.reference,
1308
+ element: state.rects.popper,
1309
+ strategy: 'absolute',
1310
+ placement: state.placement
1311
+ });
1312
+ } // eslint-disable-next-line import/no-unused-modules
1313
+
1314
+
1315
+ const popperOffsets$1 = {
1316
+ name: 'popperOffsets',
1317
+ enabled: true,
1318
+ phase: 'read',
1319
+ fn: popperOffsets,
1320
+ data: {}
1321
+ };
1322
+
1323
+ function getAltAxis(axis) {
1324
+ return axis === 'x' ? 'y' : 'x';
1325
+ }
1326
+
1327
+ function preventOverflow(_ref) {
1328
+ var state = _ref.state,
1329
+ options = _ref.options,
1330
+ name = _ref.name;
1331
+ var _options$mainAxis = options.mainAxis,
1332
+ checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
1333
+ _options$altAxis = options.altAxis,
1334
+ checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis,
1335
+ boundary = options.boundary,
1336
+ rootBoundary = options.rootBoundary,
1337
+ altBoundary = options.altBoundary,
1338
+ padding = options.padding,
1339
+ _options$tether = options.tether,
1340
+ tether = _options$tether === void 0 ? true : _options$tether,
1341
+ _options$tetherOffset = options.tetherOffset,
1342
+ tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
1343
+ var overflow = detectOverflow(state, {
1344
+ boundary: boundary,
1345
+ rootBoundary: rootBoundary,
1346
+ padding: padding,
1347
+ altBoundary: altBoundary
1348
+ });
1349
+ var basePlacement = getBasePlacement(state.placement);
1350
+ var variation = getVariation(state.placement);
1351
+ var isBasePlacement = !variation;
1352
+ var mainAxis = getMainAxisFromPlacement(basePlacement);
1353
+ var altAxis = getAltAxis(mainAxis);
1354
+ var popperOffsets = state.modifiersData.popperOffsets;
1355
+ var referenceRect = state.rects.reference;
1356
+ var popperRect = state.rects.popper;
1357
+ var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
1358
+ placement: state.placement
1359
+ })) : tetherOffset;
1360
+ var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? {
1361
+ mainAxis: tetherOffsetValue,
1362
+ altAxis: tetherOffsetValue
1363
+ } : Object.assign({
1364
+ mainAxis: 0,
1365
+ altAxis: 0
1366
+ }, tetherOffsetValue);
1367
+ var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
1368
+ var data = {
1369
+ x: 0,
1370
+ y: 0
1371
+ };
1372
+
1373
+ if (!popperOffsets) {
1374
+ return;
1375
+ }
1376
+
1377
+ if (checkMainAxis) {
1378
+ var _offsetModifierState$;
1379
+
1380
+ var mainSide = mainAxis === 'y' ? top : left;
1381
+ var altSide = mainAxis === 'y' ? bottom : right;
1382
+ var len = mainAxis === 'y' ? 'height' : 'width';
1383
+ var offset = popperOffsets[mainAxis];
1384
+ var min$1 = offset + overflow[mainSide];
1385
+ var max$1 = offset - overflow[altSide];
1386
+ var additive = tether ? -popperRect[len] / 2 : 0;
1387
+ var minLen = variation === start ? referenceRect[len] : popperRect[len];
1388
+ var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
1389
+ // outside the reference bounds
1390
+
1391
+ var arrowElement = state.elements.arrow;
1392
+ var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
1393
+ width: 0,
1394
+ height: 0
1395
+ };
1396
+ var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject();
1397
+ var arrowPaddingMin = arrowPaddingObject[mainSide];
1398
+ var arrowPaddingMax = arrowPaddingObject[altSide]; // If the reference length is smaller than the arrow length, we don't want
1399
+ // to include its full size in the calculation. If the reference is small
1400
+ // and near the edge of a boundary, the popper can overflow even if the
1401
+ // reference is not overflowing as well (e.g. virtual elements with no
1402
+ // width or height)
1403
+
1404
+ var arrowLen = within(0, referenceRect[len], arrowRect[len]);
1405
+ var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
1406
+ var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
1407
+ var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
1408
+ var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
1409
+ var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
1410
+ var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;
1411
+ var tetherMax = offset + maxOffset - offsetModifierValue;
1412
+ var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
1413
+ popperOffsets[mainAxis] = preventedOffset;
1414
+ data[mainAxis] = preventedOffset - offset;
1415
+ }
1416
+
1417
+ if (checkAltAxis) {
1418
+ var _offsetModifierState$2;
1419
+
1420
+ var _mainSide = mainAxis === 'x' ? top : left;
1421
+
1422
+ var _altSide = mainAxis === 'x' ? bottom : right;
1423
+
1424
+ var _offset = popperOffsets[altAxis];
1425
+
1426
+ var _len = altAxis === 'y' ? 'height' : 'width';
1427
+
1428
+ var _min = _offset + overflow[_mainSide];
1429
+
1430
+ var _max = _offset - overflow[_altSide];
1431
+
1432
+ var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
1433
+
1434
+ var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
1435
+
1436
+ var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
1437
+
1438
+ var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
1439
+
1440
+ var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
1441
+
1442
+ popperOffsets[altAxis] = _preventedOffset;
1443
+ data[altAxis] = _preventedOffset - _offset;
1444
+ }
1445
+
1446
+ state.modifiersData[name] = data;
1447
+ } // eslint-disable-next-line import/no-unused-modules
1448
+
1449
+
1450
+ const preventOverflow$1 = {
1451
+ name: 'preventOverflow',
1452
+ enabled: true,
1453
+ phase: 'main',
1454
+ fn: preventOverflow,
1455
+ requiresIfExists: ['offset']
1456
+ };
1457
+
1458
+ function getHTMLElementScroll(element) {
1459
+ return {
1460
+ scrollLeft: element.scrollLeft,
1461
+ scrollTop: element.scrollTop
1462
+ };
1463
+ }
1464
+
1465
+ function getNodeScroll(node) {
1466
+ if (node === getWindow(node) || !isHTMLElement(node)) {
1467
+ return getWindowScroll(node);
1468
+ } else {
1469
+ return getHTMLElementScroll(node);
1470
+ }
1471
+ }
1472
+
1473
+ function isElementScaled(element) {
1474
+ var rect = element.getBoundingClientRect();
1475
+ var scaleX = round(rect.width) / element.offsetWidth || 1;
1476
+ var scaleY = round(rect.height) / element.offsetHeight || 1;
1477
+ return scaleX !== 1 || scaleY !== 1;
1478
+ } // Returns the composite rect of an element relative to its offsetParent.
1479
+ // Composite means it takes into account transforms as well as layout.
1480
+
1481
+
1482
+ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
1483
+ if (isFixed === void 0) {
1484
+ isFixed = false;
1485
+ }
1486
+
1487
+ var isOffsetParentAnElement = isHTMLElement(offsetParent);
1488
+ var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
1489
+ var documentElement = getDocumentElement(offsetParent);
1490
+ var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled);
1491
+ var scroll = {
1492
+ scrollLeft: 0,
1493
+ scrollTop: 0
1494
+ };
1495
+ var offsets = {
1496
+ x: 0,
1497
+ y: 0
1498
+ };
1499
+
1500
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1501
+ if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078
1502
+ isScrollParent(documentElement)) {
1503
+ scroll = getNodeScroll(offsetParent);
1504
+ }
1505
+
1506
+ if (isHTMLElement(offsetParent)) {
1507
+ offsets = getBoundingClientRect(offsetParent, true);
1508
+ offsets.x += offsetParent.clientLeft;
1509
+ offsets.y += offsetParent.clientTop;
1510
+ } else if (documentElement) {
1511
+ offsets.x = getWindowScrollBarX(documentElement);
1512
+ }
1513
+ }
1514
+
1515
+ return {
1516
+ x: rect.left + scroll.scrollLeft - offsets.x,
1517
+ y: rect.top + scroll.scrollTop - offsets.y,
1518
+ width: rect.width,
1519
+ height: rect.height
1520
+ };
1521
+ }
1522
+
1523
+ function order(modifiers) {
1524
+ var map = new Map();
1525
+ var visited = new Set();
1526
+ var result = [];
1527
+ modifiers.forEach(function (modifier) {
1528
+ map.set(modifier.name, modifier);
1529
+ }); // On visiting object, check for its dependencies and visit them recursively
1530
+
1531
+ function sort(modifier) {
1532
+ visited.add(modifier.name);
1533
+ var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
1534
+ requires.forEach(function (dep) {
1535
+ if (!visited.has(dep)) {
1536
+ var depModifier = map.get(dep);
1537
+
1538
+ if (depModifier) {
1539
+ sort(depModifier);
1540
+ }
1541
+ }
1542
+ });
1543
+ result.push(modifier);
1544
+ }
1545
+
1546
+ modifiers.forEach(function (modifier) {
1547
+ if (!visited.has(modifier.name)) {
1548
+ // check for visited object
1549
+ sort(modifier);
1550
+ }
1551
+ });
1552
+ return result;
1553
+ }
1554
+
1555
+ function orderModifiers(modifiers) {
1556
+ // order based on dependencies
1557
+ var orderedModifiers = order(modifiers); // order based on phase
1558
+
1559
+ return modifierPhases.reduce(function (acc, phase) {
1560
+ return acc.concat(orderedModifiers.filter(function (modifier) {
1561
+ return modifier.phase === phase;
1562
+ }));
1563
+ }, []);
1564
+ }
1565
+
1566
+ function debounce(fn) {
1567
+ var pending;
1568
+ return function () {
1569
+ if (!pending) {
1570
+ pending = new Promise(function (resolve) {
1571
+ Promise.resolve().then(function () {
1572
+ pending = undefined;
1573
+ resolve(fn());
1574
+ });
1575
+ });
1576
+ }
1577
+
1578
+ return pending;
1579
+ };
1580
+ }
1581
+
1582
+ function mergeByName(modifiers) {
1583
+ var merged = modifiers.reduce(function (merged, current) {
1584
+ var existing = merged[current.name];
1585
+ merged[current.name] = existing ? Object.assign({}, existing, current, {
1586
+ options: Object.assign({}, existing.options, current.options),
1587
+ data: Object.assign({}, existing.data, current.data)
1588
+ }) : current;
1589
+ return merged;
1590
+ }, {}); // IE11 does not support Object.values
1591
+
1592
+ return Object.keys(merged).map(function (key) {
1593
+ return merged[key];
1594
+ });
1595
+ }
1596
+
1597
+ var DEFAULT_OPTIONS = {
1598
+ placement: 'bottom',
1599
+ modifiers: [],
1600
+ strategy: 'absolute'
1601
+ };
1602
+
1603
+ function areValidElements() {
1604
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1605
+ args[_key] = arguments[_key];
1606
+ }
1607
+
1608
+ return !args.some(function (element) {
1609
+ return !(element && typeof element.getBoundingClientRect === 'function');
1610
+ });
1611
+ }
1612
+
1613
+ function popperGenerator(generatorOptions) {
1614
+ if (generatorOptions === void 0) {
1615
+ generatorOptions = {};
1616
+ }
1617
+
1618
+ var _generatorOptions = generatorOptions,
1619
+ _generatorOptions$def = _generatorOptions.defaultModifiers,
1620
+ defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,
1621
+ _generatorOptions$def2 = _generatorOptions.defaultOptions,
1622
+ defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
1623
+ return function createPopper(reference, popper, options) {
1624
+ if (options === void 0) {
1625
+ options = defaultOptions;
1626
+ }
1627
+
1628
+ var state = {
1629
+ placement: 'bottom',
1630
+ orderedModifiers: [],
1631
+ options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
1632
+ modifiersData: {},
1633
+ elements: {
1634
+ reference: reference,
1635
+ popper: popper
1636
+ },
1637
+ attributes: {},
1638
+ styles: {}
1639
+ };
1640
+ var effectCleanupFns = [];
1641
+ var isDestroyed = false;
1642
+ var instance = {
1643
+ state: state,
1644
+ setOptions: function setOptions(setOptionsAction) {
1645
+ var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;
1646
+ cleanupModifierEffects();
1647
+ state.options = Object.assign({}, defaultOptions, state.options, options);
1648
+ state.scrollParents = {
1649
+ reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
1650
+ popper: listScrollParents(popper)
1651
+ }; // Orders the modifiers based on their dependencies and `phase`
1652
+ // properties
1653
+
1654
+ var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers
1655
+
1656
+ state.orderedModifiers = orderedModifiers.filter(function (m) {
1657
+ return m.enabled;
1658
+ }); // Validate the provided modifiers so that the consumer will get warned
1659
+
1660
+ runModifierEffects();
1661
+ return instance.update();
1662
+ },
1663
+ // Sync update – it will always be executed, even if not necessary. This
1664
+ // is useful for low frequency updates where sync behavior simplifies the
1665
+ // logic.
1666
+ // For high frequency updates (e.g. `resize` and `scroll` events), always
1667
+ // prefer the async Popper#update method
1668
+ forceUpdate: function forceUpdate() {
1669
+ if (isDestroyed) {
1670
+ return;
1671
+ }
1672
+
1673
+ var _state$elements = state.elements,
1674
+ reference = _state$elements.reference,
1675
+ popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements
1676
+ // anymore
1677
+
1678
+ if (!areValidElements(reference, popper)) {
1679
+
1680
+ return;
1681
+ } // Store the reference and popper rects to be read by modifiers
1682
+
1683
+
1684
+ state.rects = {
1685
+ reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),
1686
+ popper: getLayoutRect(popper)
1687
+ }; // Modifiers have the ability to reset the current update cycle. The
1688
+ // most common use case for this is the `flip` modifier changing the
1689
+ // placement, which then needs to re-run all the modifiers, because the
1690
+ // logic was previously ran for the previous placement and is therefore
1691
+ // stale/incorrect
1692
+
1693
+ state.reset = false;
1694
+ state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier
1695
+ // is filled with the initial data specified by the modifier. This means
1696
+ // it doesn't persist and is fresh on each update.
1697
+ // To ensure persistent data, use `${name}#persistent`
1698
+
1699
+ state.orderedModifiers.forEach(function (modifier) {
1700
+ return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
1701
+ });
1702
+
1703
+ for (var index = 0; index < state.orderedModifiers.length; index++) {
1704
+
1705
+ if (state.reset === true) {
1706
+ state.reset = false;
1707
+ index = -1;
1708
+ continue;
1709
+ }
1710
+
1711
+ var _state$orderedModifie = state.orderedModifiers[index],
1712
+ fn = _state$orderedModifie.fn,
1713
+ _state$orderedModifie2 = _state$orderedModifie.options,
1714
+ _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,
1715
+ name = _state$orderedModifie.name;
1716
+
1717
+ if (typeof fn === 'function') {
1718
+ state = fn({
1719
+ state: state,
1720
+ options: _options,
1721
+ name: name,
1722
+ instance: instance
1723
+ }) || state;
1724
+ }
1725
+ }
1726
+ },
1727
+ // Async and optimistically optimized update – it will not be executed if
1728
+ // not necessary (debounced to run at most once-per-tick)
1729
+ update: debounce(function () {
1730
+ return new Promise(function (resolve) {
1731
+ instance.forceUpdate();
1732
+ resolve(state);
1733
+ });
1734
+ }),
1735
+ destroy: function destroy() {
1736
+ cleanupModifierEffects();
1737
+ isDestroyed = true;
1738
+ }
1739
+ };
1740
+
1741
+ if (!areValidElements(reference, popper)) {
1742
+
1743
+ return instance;
1744
+ }
1745
+
1746
+ instance.setOptions(options).then(function (state) {
1747
+ if (!isDestroyed && options.onFirstUpdate) {
1748
+ options.onFirstUpdate(state);
1749
+ }
1750
+ }); // Modifiers have the ability to execute arbitrary code before the first
1751
+ // update cycle runs. They will be executed in the same order as the update
1752
+ // cycle. This is useful when a modifier adds some persistent data that
1753
+ // other modifiers need to use, but the modifier is run after the dependent
1754
+ // one.
1755
+
1756
+ function runModifierEffects() {
1757
+ state.orderedModifiers.forEach(function (_ref3) {
1758
+ var name = _ref3.name,
1759
+ _ref3$options = _ref3.options,
1760
+ options = _ref3$options === void 0 ? {} : _ref3$options,
1761
+ effect = _ref3.effect;
1762
+
1763
+ if (typeof effect === 'function') {
1764
+ var cleanupFn = effect({
1765
+ state: state,
1766
+ name: name,
1767
+ instance: instance,
1768
+ options: options
1769
+ });
1770
+
1771
+ var noopFn = function noopFn() {};
1772
+
1773
+ effectCleanupFns.push(cleanupFn || noopFn);
1774
+ }
1775
+ });
1776
+ }
1777
+
1778
+ function cleanupModifierEffects() {
1779
+ effectCleanupFns.forEach(function (fn) {
1780
+ return fn();
1781
+ });
1782
+ effectCleanupFns = [];
1783
+ }
1784
+
1785
+ return instance;
1786
+ };
1787
+ }
1788
+
1789
+ var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
1790
+ var createPopper = /*#__PURE__*/popperGenerator({
1791
+ defaultModifiers: defaultModifiers
1792
+ }); // eslint-disable-next-line import/no-unused-modules
1793
+
1794
+ const portalCss = ":host(limel-portal){display:block;position:absolute;top:0;bottom:0;width:100%;pointer-events:none}:host([hidden]){display:none}";
1795
+
1796
+ const Portal = class {
1797
+ constructor(hostRef) {
1798
+ index.registerInstance(this, hostRef);
1799
+ /**
1800
+ * Decides which direction the portal content should open.
1801
+ */
1802
+ this.openDirection = 'bottom';
1803
+ /**
1804
+ * Position of the content.
1805
+ */
1806
+ this.position = 'absolute';
1807
+ /**
1808
+ * Dynamic styling that can be applied to the container holding the content.
1809
+ */
1810
+ this.containerStyle = {};
1811
+ /**
1812
+ * Parent element to move the content to.
1813
+ */
1814
+ this.parent = document.body;
1815
+ /**
1816
+ * Used to make a dropdown have the same width as the trigger, for example
1817
+ * in `limel-picker`.
1818
+ */
1819
+ this.inheritParentWidth = false;
1820
+ /**
1821
+ * True if the content within the portal should be visible.
1822
+ *
1823
+ * If the content is from within a dialog for instance, this can be set to
1824
+ * true from false when the dialog opens to position the content properly.
1825
+ */
1826
+ this.visible = false;
1827
+ this.loaded = false;
1828
+ this.parents = new WeakMap();
1829
+ }
1830
+ onVisible() {
1831
+ if (!this.visible) {
1832
+ this.hideContainer();
1833
+ this.styleContainer();
1834
+ this.destroyPopper();
1835
+ return;
1836
+ }
1837
+ this.styleContainer();
1838
+ this.createPopper();
1839
+ requestAnimationFrame(() => {
1840
+ this.showContainer();
1841
+ });
1842
+ }
1843
+ disconnectedCallback() {
1844
+ this.removeContainer();
1845
+ this.destroyPopper();
1846
+ if (this.observer) {
1847
+ this.observer.unobserve(this.container);
1848
+ }
1849
+ }
1850
+ connectedCallback() {
1851
+ if (!this.loaded) {
1852
+ return;
1853
+ }
1854
+ this.createContainer();
1855
+ this.hideContainer();
1856
+ this.attachContainer();
1857
+ this.styleContainer();
1858
+ if (this.visible) {
1859
+ this.createPopper();
1860
+ this.showContainer();
1861
+ }
1862
+ if ('ResizeObserver' in window) {
1863
+ const observer = new ResizeObserver(() => {
1864
+ if (this.popperInstance) {
1865
+ this.styleContainer();
1866
+ this.popperInstance.update();
1867
+ }
1868
+ });
1869
+ observer.observe(this.container);
1870
+ }
1871
+ }
1872
+ componentDidLoad() {
1873
+ this.loaded = true;
1874
+ this.connectedCallback();
1875
+ }
1876
+ render() {
1877
+ return index.h("slot", null);
1878
+ }
1879
+ createContainer() {
1880
+ const slot = this.host.shadowRoot.querySelector('slot');
1881
+ const content = (slot.assignedElements && slot.assignedElements()) || [];
1882
+ this.container = document.createElement('div');
1883
+ this.container.setAttribute('id', this.containerId);
1884
+ this.container.setAttribute('class', 'limel-portal--container');
1885
+ Object.assign(this.container, {
1886
+ portalSource: this.host,
1887
+ });
1888
+ content.forEach((element) => {
1889
+ this.parents.set(element, element.parentElement);
1890
+ this.container.appendChild(element);
1891
+ });
1892
+ }
1893
+ attachContainer() {
1894
+ this.parent.appendChild(this.container);
1895
+ }
1896
+ removeContainer() {
1897
+ if (!this.container) {
1898
+ return;
1899
+ }
1900
+ Array.from(this.container.children).forEach((element) => {
1901
+ const parent = this.parents.get(element);
1902
+ if (!parent) {
1903
+ return;
1904
+ }
1905
+ parent.appendChild(element);
1906
+ });
1907
+ this.hideContainer();
1908
+ this.container.parentElement.removeChild(this.container);
1909
+ }
1910
+ hideContainer() {
1911
+ this.container.style.opacity = '0';
1912
+ }
1913
+ showContainer() {
1914
+ this.container.style.opacity = '1';
1915
+ }
1916
+ styleContainer() {
1917
+ const hostWidth = this.host.getBoundingClientRect().width;
1918
+ if (this.visible) {
1919
+ this.container.style.display = 'block';
1920
+ }
1921
+ else {
1922
+ this.container.style.display = 'none';
1923
+ }
1924
+ if (this.inheritParentWidth) {
1925
+ const containerWidth = this.getContentWidth(this.container);
1926
+ let width = containerWidth;
1927
+ if (hostWidth > 0) {
1928
+ width = hostWidth;
1929
+ }
1930
+ this.container.style.width = `${width}px`;
1931
+ }
1932
+ this.ensureContainerFitsInViewPort();
1933
+ Object.keys(this.containerStyle).forEach((property) => {
1934
+ this.container.style[property] = this.containerStyle[property];
1935
+ });
1936
+ }
1937
+ getContentWidth(element) {
1938
+ if (!element) {
1939
+ return null;
1940
+ }
1941
+ const width = element.getBoundingClientRect().width;
1942
+ if (width !== 0) {
1943
+ return width;
1944
+ }
1945
+ const elementContent = element.querySelector('*');
1946
+ return this.getContentWidth(elementContent);
1947
+ }
1948
+ createPopper() {
1949
+ const config = this.createPopperConfig();
1950
+ this.popperInstance = createPopper(this.host, this.container, config);
1951
+ }
1952
+ destroyPopper() {
1953
+ var _a;
1954
+ (_a = this.popperInstance) === null || _a === void 0 ? void 0 : _a.destroy();
1955
+ this.popperInstance = null;
1956
+ }
1957
+ createPopperConfig() {
1958
+ const placement = this.getPlacement(this.openDirection);
1959
+ const flipPlacement = this.getFlipPlacement(this.openDirection);
1960
+ return {
1961
+ strategy: this.position,
1962
+ placement: placement,
1963
+ modifiers: [
1964
+ {
1965
+ name: 'flip',
1966
+ options: {
1967
+ fallbackPlacements: [flipPlacement],
1968
+ },
1969
+ },
1970
+ ],
1971
+ };
1972
+ }
1973
+ getPlacement(direction) {
1974
+ const placements = {
1975
+ 'left-start': 'left-start',
1976
+ left: 'left',
1977
+ 'left-end': 'left-end',
1978
+ 'right-start': 'right-start',
1979
+ right: 'right',
1980
+ 'right-end': 'right-end',
1981
+ 'top-start': 'top-start',
1982
+ top: 'top',
1983
+ 'top-end': 'top-end',
1984
+ 'bottom-start': 'bottom-start',
1985
+ bottom: 'bottom',
1986
+ 'bottom-end': 'bottom-end',
1987
+ };
1988
+ return placements[direction];
1989
+ }
1990
+ getFlipPlacement(direction) {
1991
+ const flipPlacements = {
1992
+ 'left-start': 'right-start',
1993
+ left: 'right',
1994
+ 'left-end': 'right-end',
1995
+ 'right-start': 'left-start',
1996
+ right: 'left',
1997
+ 'right-end': 'left-end',
1998
+ 'top-start': 'bottom-start',
1999
+ top: 'bottom',
2000
+ 'top-end': 'bottom-end',
2001
+ 'bottom-start': 'top-start',
2002
+ bottom: 'top',
2003
+ 'bottom-end': 'top-end',
2004
+ };
2005
+ return flipPlacements[direction];
2006
+ }
2007
+ ensureContainerFitsInViewPort() {
2008
+ const viewHeight = Math.max(document.documentElement.clientHeight || 0, window.innerHeight || 0);
2009
+ const { top, bottom } = this.host.getBoundingClientRect();
2010
+ const spaceAboveTopOfSurface = Math.max(top, 0);
2011
+ const spaceBelowTopOfSurface = Math.max(viewHeight - bottom, 0);
2012
+ const extraCosmeticSpace = 16;
2013
+ const maxHeight = Math.max(spaceAboveTopOfSurface, spaceBelowTopOfSurface) -
2014
+ extraCosmeticSpace;
2015
+ this.container.style.maxHeight = `${maxHeight}px`;
2016
+ }
2017
+ get host() { return index.getElement(this); }
2018
+ static get watchers() { return {
2019
+ "visible": ["onVisible"]
2020
+ }; }
2021
+ };
2022
+ Portal.style = portalCss;
2023
+
2024
+ exports.limel_portal = Portal;