@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
@@ -498,2021 +498,4 @@ const MenuSurface = class {
498
498
  };
499
499
  MenuSurface.style = menuSurfaceCss;
500
500
 
501
- var top = 'top';
502
- var bottom = 'bottom';
503
- var right = 'right';
504
- var left = 'left';
505
- var auto = 'auto';
506
- var basePlacements = [top, bottom, right, left];
507
- var start = 'start';
508
- var end = 'end';
509
- var clippingParents = 'clippingParents';
510
- var viewport = 'viewport';
511
- var popper = 'popper';
512
- var reference = 'reference';
513
- var variationPlacements = /*#__PURE__*/basePlacements.reduce(function (acc, placement) {
514
- return acc.concat([placement + "-" + start, placement + "-" + end]);
515
- }, []);
516
- var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) {
517
- return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
518
- }, []); // modifiers that need to read the DOM
519
-
520
- var beforeRead = 'beforeRead';
521
- var read = 'read';
522
- var afterRead = 'afterRead'; // pure-logic modifiers
523
-
524
- var beforeMain = 'beforeMain';
525
- var main = 'main';
526
- var afterMain = 'afterMain'; // modifier with the purpose to write to the DOM (or write into a framework state)
527
-
528
- var beforeWrite = 'beforeWrite';
529
- var write = 'write';
530
- var afterWrite = 'afterWrite';
531
- var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
532
-
533
- function getNodeName(element) {
534
- return element ? (element.nodeName || '').toLowerCase() : null;
535
- }
536
-
537
- function getWindow(node) {
538
- if (node == null) {
539
- return window;
540
- }
541
-
542
- if (node.toString() !== '[object Window]') {
543
- var ownerDocument = node.ownerDocument;
544
- return ownerDocument ? ownerDocument.defaultView || window : window;
545
- }
546
-
547
- return node;
548
- }
549
-
550
- function isElement(node) {
551
- var OwnElement = getWindow(node).Element;
552
- return node instanceof OwnElement || node instanceof Element;
553
- }
554
-
555
- function isHTMLElement(node) {
556
- var OwnElement = getWindow(node).HTMLElement;
557
- return node instanceof OwnElement || node instanceof HTMLElement;
558
- }
559
-
560
- function isShadowRoot(node) {
561
- // IE 11 has no ShadowRoot
562
- if (typeof ShadowRoot === 'undefined') {
563
- return false;
564
- }
565
-
566
- var OwnElement = getWindow(node).ShadowRoot;
567
- return node instanceof OwnElement || node instanceof ShadowRoot;
568
- }
569
-
570
- // and applies them to the HTMLElements such as popper and arrow
571
-
572
- function applyStyles(_ref) {
573
- var state = _ref.state;
574
- Object.keys(state.elements).forEach(function (name) {
575
- var style = state.styles[name] || {};
576
- var attributes = state.attributes[name] || {};
577
- var element = state.elements[name]; // arrow is optional + virtual elements
578
-
579
- if (!isHTMLElement(element) || !getNodeName(element)) {
580
- return;
581
- } // Flow doesn't support to extend this property, but it's the most
582
- // effective way to apply styles to an HTMLElement
583
- // $FlowFixMe[cannot-write]
584
-
585
-
586
- Object.assign(element.style, style);
587
- Object.keys(attributes).forEach(function (name) {
588
- var value = attributes[name];
589
-
590
- if (value === false) {
591
- element.removeAttribute(name);
592
- } else {
593
- element.setAttribute(name, value === true ? '' : value);
594
- }
595
- });
596
- });
597
- }
598
-
599
- function effect$2(_ref2) {
600
- var state = _ref2.state;
601
- var initialStyles = {
602
- popper: {
603
- position: state.options.strategy,
604
- left: '0',
605
- top: '0',
606
- margin: '0'
607
- },
608
- arrow: {
609
- position: 'absolute'
610
- },
611
- reference: {}
612
- };
613
- Object.assign(state.elements.popper.style, initialStyles.popper);
614
- state.styles = initialStyles;
615
-
616
- if (state.elements.arrow) {
617
- Object.assign(state.elements.arrow.style, initialStyles.arrow);
618
- }
619
-
620
- return function () {
621
- Object.keys(state.elements).forEach(function (name) {
622
- var element = state.elements[name];
623
- var attributes = state.attributes[name] || {};
624
- var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them
625
-
626
- var style = styleProperties.reduce(function (style, property) {
627
- style[property] = '';
628
- return style;
629
- }, {}); // arrow is optional + virtual elements
630
-
631
- if (!isHTMLElement(element) || !getNodeName(element)) {
632
- return;
633
- }
634
-
635
- Object.assign(element.style, style);
636
- Object.keys(attributes).forEach(function (attribute) {
637
- element.removeAttribute(attribute);
638
- });
639
- });
640
- };
641
- } // eslint-disable-next-line import/no-unused-modules
642
-
643
-
644
- const applyStyles$1 = {
645
- name: 'applyStyles',
646
- enabled: true,
647
- phase: 'write',
648
- fn: applyStyles,
649
- effect: effect$2,
650
- requires: ['computeStyles']
651
- };
652
-
653
- function getBasePlacement(placement) {
654
- return placement.split('-')[0];
655
- }
656
-
657
- var max = Math.max;
658
- var min = Math.min;
659
- var round = Math.round;
660
-
661
- function getBoundingClientRect(element, includeScale) {
662
- if (includeScale === void 0) {
663
- includeScale = false;
664
- }
665
-
666
- var rect = element.getBoundingClientRect();
667
- var scaleX = 1;
668
- var scaleY = 1;
669
-
670
- if (isHTMLElement(element) && includeScale) {
671
- var offsetHeight = element.offsetHeight;
672
- var offsetWidth = element.offsetWidth; // Do not attempt to divide by 0, otherwise we get `Infinity` as scale
673
- // Fallback to 1 in case both values are `0`
674
-
675
- if (offsetWidth > 0) {
676
- scaleX = round(rect.width) / offsetWidth || 1;
677
- }
678
-
679
- if (offsetHeight > 0) {
680
- scaleY = round(rect.height) / offsetHeight || 1;
681
- }
682
- }
683
-
684
- return {
685
- width: rect.width / scaleX,
686
- height: rect.height / scaleY,
687
- top: rect.top / scaleY,
688
- right: rect.right / scaleX,
689
- bottom: rect.bottom / scaleY,
690
- left: rect.left / scaleX,
691
- x: rect.left / scaleX,
692
- y: rect.top / scaleY
693
- };
694
- }
695
-
696
- // means it doesn't take into account transforms.
697
-
698
- function getLayoutRect(element) {
699
- var clientRect = getBoundingClientRect(element); // Use the clientRect sizes if it's not been transformed.
700
- // Fixes https://github.com/popperjs/popper-core/issues/1223
701
-
702
- var width = element.offsetWidth;
703
- var height = element.offsetHeight;
704
-
705
- if (Math.abs(clientRect.width - width) <= 1) {
706
- width = clientRect.width;
707
- }
708
-
709
- if (Math.abs(clientRect.height - height) <= 1) {
710
- height = clientRect.height;
711
- }
712
-
713
- return {
714
- x: element.offsetLeft,
715
- y: element.offsetTop,
716
- width: width,
717
- height: height
718
- };
719
- }
720
-
721
- function contains(parent, child) {
722
- var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method
723
-
724
- if (parent.contains(child)) {
725
- return true;
726
- } // then fallback to custom implementation with Shadow DOM support
727
- else if (rootNode && isShadowRoot(rootNode)) {
728
- var next = child;
729
-
730
- do {
731
- if (next && parent.isSameNode(next)) {
732
- return true;
733
- } // $FlowFixMe[prop-missing]: need a better way to handle this...
734
-
735
-
736
- next = next.parentNode || next.host;
737
- } while (next);
738
- } // Give up, the result is false
739
-
740
-
741
- return false;
742
- }
743
-
744
- function getComputedStyle(element) {
745
- return getWindow(element).getComputedStyle(element);
746
- }
747
-
748
- function isTableElement(element) {
749
- return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
750
- }
751
-
752
- function getDocumentElement(element) {
753
- // $FlowFixMe[incompatible-return]: assume body is always available
754
- return ((isElement(element) ? element.ownerDocument : // $FlowFixMe[prop-missing]
755
- element.document) || window.document).documentElement;
756
- }
757
-
758
- function getParentNode(element) {
759
- if (getNodeName(element) === 'html') {
760
- return element;
761
- }
762
-
763
- return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
764
- // $FlowFixMe[incompatible-return]
765
- // $FlowFixMe[prop-missing]
766
- element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
767
- element.parentNode || ( // DOM Element detected
768
- isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
769
- // $FlowFixMe[incompatible-call]: HTMLElement is a Node
770
- getDocumentElement(element) // fallback
771
-
772
- );
773
- }
774
-
775
- function getTrueOffsetParent(element) {
776
- if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
777
- getComputedStyle(element).position === 'fixed') {
778
- return null;
779
- }
780
-
781
- return element.offsetParent;
782
- } // `.offsetParent` reports `null` for fixed elements, while absolute elements
783
- // return the containing block
784
-
785
-
786
- function getContainingBlock(element) {
787
- var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') !== -1;
788
- var isIE = navigator.userAgent.indexOf('Trident') !== -1;
789
-
790
- if (isIE && isHTMLElement(element)) {
791
- // In IE 9, 10 and 11 fixed elements containing block is always established by the viewport
792
- var elementCss = getComputedStyle(element);
793
-
794
- if (elementCss.position === 'fixed') {
795
- return null;
796
- }
797
- }
798
-
799
- var currentNode = getParentNode(element);
800
-
801
- if (isShadowRoot(currentNode)) {
802
- currentNode = currentNode.host;
803
- }
804
-
805
- while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
806
- var css = getComputedStyle(currentNode); // This is non-exhaustive but covers the most common CSS properties that
807
- // create a containing block.
808
- // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
809
-
810
- 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') {
811
- return currentNode;
812
- } else {
813
- currentNode = currentNode.parentNode;
814
- }
815
- }
816
-
817
- return null;
818
- } // Gets the closest ancestor positioned element. Handles some edge cases,
819
- // such as table ancestors and cross browser bugs.
820
-
821
-
822
- function getOffsetParent(element) {
823
- var window = getWindow(element);
824
- var offsetParent = getTrueOffsetParent(element);
825
-
826
- while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
827
- offsetParent = getTrueOffsetParent(offsetParent);
828
- }
829
-
830
- if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static')) {
831
- return window;
832
- }
833
-
834
- return offsetParent || getContainingBlock(element) || window;
835
- }
836
-
837
- function getMainAxisFromPlacement(placement) {
838
- return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
839
- }
840
-
841
- function within(min$1, value, max$1) {
842
- return max(min$1, min(value, max$1));
843
- }
844
- function withinMaxClamp(min, value, max) {
845
- var v = within(min, value, max);
846
- return v > max ? max : v;
847
- }
848
-
849
- function getFreshSideObject() {
850
- return {
851
- top: 0,
852
- right: 0,
853
- bottom: 0,
854
- left: 0
855
- };
856
- }
857
-
858
- function mergePaddingObject(paddingObject) {
859
- return Object.assign({}, getFreshSideObject(), paddingObject);
860
- }
861
-
862
- function expandToHashMap(value, keys) {
863
- return keys.reduce(function (hashMap, key) {
864
- hashMap[key] = value;
865
- return hashMap;
866
- }, {});
867
- }
868
-
869
- var toPaddingObject = function toPaddingObject(padding, state) {
870
- padding = typeof padding === 'function' ? padding(Object.assign({}, state.rects, {
871
- placement: state.placement
872
- })) : padding;
873
- return mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
874
- };
875
-
876
- function arrow(_ref) {
877
- var _state$modifiersData$;
878
-
879
- var state = _ref.state,
880
- name = _ref.name,
881
- options = _ref.options;
882
- var arrowElement = state.elements.arrow;
883
- var popperOffsets = state.modifiersData.popperOffsets;
884
- var basePlacement = getBasePlacement(state.placement);
885
- var axis = getMainAxisFromPlacement(basePlacement);
886
- var isVertical = [left, right].indexOf(basePlacement) >= 0;
887
- var len = isVertical ? 'height' : 'width';
888
-
889
- if (!arrowElement || !popperOffsets) {
890
- return;
891
- }
892
-
893
- var paddingObject = toPaddingObject(options.padding, state);
894
- var arrowRect = getLayoutRect(arrowElement);
895
- var minProp = axis === 'y' ? top : left;
896
- var maxProp = axis === 'y' ? bottom : right;
897
- var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
898
- var startDiff = popperOffsets[axis] - state.rects.reference[axis];
899
- var arrowOffsetParent = getOffsetParent(arrowElement);
900
- var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
901
- var centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the popper if the center point is
902
- // outside of the popper bounds
903
-
904
- var min = paddingObject[minProp];
905
- var max = clientSize - arrowRect[len] - paddingObject[maxProp];
906
- var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
907
- var offset = within(min, center, max); // Prevents breaking syntax highlighting...
908
-
909
- var axisProp = axis;
910
- state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);
911
- }
912
-
913
- function effect$1(_ref2) {
914
- var state = _ref2.state,
915
- options = _ref2.options;
916
- var _options$element = options.element,
917
- arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element;
918
-
919
- if (arrowElement == null) {
920
- return;
921
- } // CSS selector
922
-
923
-
924
- if (typeof arrowElement === 'string') {
925
- arrowElement = state.elements.popper.querySelector(arrowElement);
926
-
927
- if (!arrowElement) {
928
- return;
929
- }
930
- }
931
-
932
- if (!contains(state.elements.popper, arrowElement)) {
933
-
934
- return;
935
- }
936
-
937
- state.elements.arrow = arrowElement;
938
- } // eslint-disable-next-line import/no-unused-modules
939
-
940
-
941
- const arrow$1 = {
942
- name: 'arrow',
943
- enabled: true,
944
- phase: 'main',
945
- fn: arrow,
946
- effect: effect$1,
947
- requires: ['popperOffsets'],
948
- requiresIfExists: ['preventOverflow']
949
- };
950
-
951
- function getVariation(placement) {
952
- return placement.split('-')[1];
953
- }
954
-
955
- var unsetSides = {
956
- top: 'auto',
957
- right: 'auto',
958
- bottom: 'auto',
959
- left: 'auto'
960
- }; // Round the offsets to the nearest suitable subpixel based on the DPR.
961
- // Zooming can change the DPR, but it seems to report a value that will
962
- // cleanly divide the values into the appropriate subpixels.
963
-
964
- function roundOffsetsByDPR(_ref) {
965
- var x = _ref.x,
966
- y = _ref.y;
967
- var win = window;
968
- var dpr = win.devicePixelRatio || 1;
969
- return {
970
- x: round(x * dpr) / dpr || 0,
971
- y: round(y * dpr) / dpr || 0
972
- };
973
- }
974
-
975
- function mapToStyles(_ref2) {
976
- var _Object$assign2;
977
-
978
- var popper = _ref2.popper,
979
- popperRect = _ref2.popperRect,
980
- placement = _ref2.placement,
981
- variation = _ref2.variation,
982
- offsets = _ref2.offsets,
983
- position = _ref2.position,
984
- gpuAcceleration = _ref2.gpuAcceleration,
985
- adaptive = _ref2.adaptive,
986
- roundOffsets = _ref2.roundOffsets,
987
- isFixed = _ref2.isFixed;
988
- var _offsets$x = offsets.x,
989
- x = _offsets$x === void 0 ? 0 : _offsets$x,
990
- _offsets$y = offsets.y,
991
- y = _offsets$y === void 0 ? 0 : _offsets$y;
992
-
993
- var _ref3 = typeof roundOffsets === 'function' ? roundOffsets({
994
- x: x,
995
- y: y
996
- }) : {
997
- x: x,
998
- y: y
999
- };
1000
-
1001
- x = _ref3.x;
1002
- y = _ref3.y;
1003
- var hasX = offsets.hasOwnProperty('x');
1004
- var hasY = offsets.hasOwnProperty('y');
1005
- var sideX = left;
1006
- var sideY = top;
1007
- var win = window;
1008
-
1009
- if (adaptive) {
1010
- var offsetParent = getOffsetParent(popper);
1011
- var heightProp = 'clientHeight';
1012
- var widthProp = 'clientWidth';
1013
-
1014
- if (offsetParent === getWindow(popper)) {
1015
- offsetParent = getDocumentElement(popper);
1016
-
1017
- if (getComputedStyle(offsetParent).position !== 'static' && position === 'absolute') {
1018
- heightProp = 'scrollHeight';
1019
- widthProp = 'scrollWidth';
1020
- }
1021
- } // $FlowFixMe[incompatible-cast]: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it
1022
-
1023
-
1024
- offsetParent = offsetParent;
1025
-
1026
- if (placement === top || (placement === left || placement === right) && variation === end) {
1027
- sideY = bottom;
1028
- var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height : // $FlowFixMe[prop-missing]
1029
- offsetParent[heightProp];
1030
- y -= offsetY - popperRect.height;
1031
- y *= gpuAcceleration ? 1 : -1;
1032
- }
1033
-
1034
- if (placement === left || (placement === top || placement === bottom) && variation === end) {
1035
- sideX = right;
1036
- var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width : // $FlowFixMe[prop-missing]
1037
- offsetParent[widthProp];
1038
- x -= offsetX - popperRect.width;
1039
- x *= gpuAcceleration ? 1 : -1;
1040
- }
1041
- }
1042
-
1043
- var commonStyles = Object.assign({
1044
- position: position
1045
- }, adaptive && unsetSides);
1046
-
1047
- var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
1048
- x: x,
1049
- y: y
1050
- }) : {
1051
- x: x,
1052
- y: y
1053
- };
1054
-
1055
- x = _ref4.x;
1056
- y = _ref4.y;
1057
-
1058
- if (gpuAcceleration) {
1059
- var _Object$assign;
1060
-
1061
- 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));
1062
- }
1063
-
1064
- return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
1065
- }
1066
-
1067
- function computeStyles(_ref5) {
1068
- var state = _ref5.state,
1069
- options = _ref5.options;
1070
- var _options$gpuAccelerat = options.gpuAcceleration,
1071
- gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
1072
- _options$adaptive = options.adaptive,
1073
- adaptive = _options$adaptive === void 0 ? true : _options$adaptive,
1074
- _options$roundOffsets = options.roundOffsets,
1075
- roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
1076
-
1077
- var commonStyles = {
1078
- placement: getBasePlacement(state.placement),
1079
- variation: getVariation(state.placement),
1080
- popper: state.elements.popper,
1081
- popperRect: state.rects.popper,
1082
- gpuAcceleration: gpuAcceleration,
1083
- isFixed: state.options.strategy === 'fixed'
1084
- };
1085
-
1086
- if (state.modifiersData.popperOffsets != null) {
1087
- state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
1088
- offsets: state.modifiersData.popperOffsets,
1089
- position: state.options.strategy,
1090
- adaptive: adaptive,
1091
- roundOffsets: roundOffsets
1092
- })));
1093
- }
1094
-
1095
- if (state.modifiersData.arrow != null) {
1096
- state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
1097
- offsets: state.modifiersData.arrow,
1098
- position: 'absolute',
1099
- adaptive: false,
1100
- roundOffsets: roundOffsets
1101
- })));
1102
- }
1103
-
1104
- state.attributes.popper = Object.assign({}, state.attributes.popper, {
1105
- 'data-popper-placement': state.placement
1106
- });
1107
- } // eslint-disable-next-line import/no-unused-modules
1108
-
1109
-
1110
- const computeStyles$1 = {
1111
- name: 'computeStyles',
1112
- enabled: true,
1113
- phase: 'beforeWrite',
1114
- fn: computeStyles,
1115
- data: {}
1116
- };
1117
-
1118
- var passive = {
1119
- passive: true
1120
- };
1121
-
1122
- function effect(_ref) {
1123
- var state = _ref.state,
1124
- instance = _ref.instance,
1125
- options = _ref.options;
1126
- var _options$scroll = options.scroll,
1127
- scroll = _options$scroll === void 0 ? true : _options$scroll,
1128
- _options$resize = options.resize,
1129
- resize = _options$resize === void 0 ? true : _options$resize;
1130
- var window = getWindow(state.elements.popper);
1131
- var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
1132
-
1133
- if (scroll) {
1134
- scrollParents.forEach(function (scrollParent) {
1135
- scrollParent.addEventListener('scroll', instance.update, passive);
1136
- });
1137
- }
1138
-
1139
- if (resize) {
1140
- window.addEventListener('resize', instance.update, passive);
1141
- }
1142
-
1143
- return function () {
1144
- if (scroll) {
1145
- scrollParents.forEach(function (scrollParent) {
1146
- scrollParent.removeEventListener('scroll', instance.update, passive);
1147
- });
1148
- }
1149
-
1150
- if (resize) {
1151
- window.removeEventListener('resize', instance.update, passive);
1152
- }
1153
- };
1154
- } // eslint-disable-next-line import/no-unused-modules
1155
-
1156
-
1157
- const eventListeners = {
1158
- name: 'eventListeners',
1159
- enabled: true,
1160
- phase: 'write',
1161
- fn: function fn() {},
1162
- effect: effect,
1163
- data: {}
1164
- };
1165
-
1166
- var hash$1 = {
1167
- left: 'right',
1168
- right: 'left',
1169
- bottom: 'top',
1170
- top: 'bottom'
1171
- };
1172
- function getOppositePlacement(placement) {
1173
- return placement.replace(/left|right|bottom|top/g, function (matched) {
1174
- return hash$1[matched];
1175
- });
1176
- }
1177
-
1178
- var hash = {
1179
- start: 'end',
1180
- end: 'start'
1181
- };
1182
- function getOppositeVariationPlacement(placement) {
1183
- return placement.replace(/start|end/g, function (matched) {
1184
- return hash[matched];
1185
- });
1186
- }
1187
-
1188
- function getWindowScroll(node) {
1189
- var win = getWindow(node);
1190
- var scrollLeft = win.pageXOffset;
1191
- var scrollTop = win.pageYOffset;
1192
- return {
1193
- scrollLeft: scrollLeft,
1194
- scrollTop: scrollTop
1195
- };
1196
- }
1197
-
1198
- function getWindowScrollBarX(element) {
1199
- // If <html> has a CSS width greater than the viewport, then this will be
1200
- // incorrect for RTL.
1201
- // Popper 1 is broken in this case and never had a bug report so let's assume
1202
- // it's not an issue. I don't think anyone ever specifies width on <html>
1203
- // anyway.
1204
- // Browsers where the left scrollbar doesn't cause an issue report `0` for
1205
- // this (e.g. Edge 2019, IE11, Safari)
1206
- return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
1207
- }
1208
-
1209
- function getViewportRect(element) {
1210
- var win = getWindow(element);
1211
- var html = getDocumentElement(element);
1212
- var visualViewport = win.visualViewport;
1213
- var width = html.clientWidth;
1214
- var height = html.clientHeight;
1215
- var x = 0;
1216
- var y = 0; // NB: This isn't supported on iOS <= 12. If the keyboard is open, the popper
1217
- // can be obscured underneath it.
1218
- // Also, `html.clientHeight` adds the bottom bar height in Safari iOS, even
1219
- // if it isn't open, so if this isn't available, the popper will be detected
1220
- // to overflow the bottom of the screen too early.
1221
-
1222
- if (visualViewport) {
1223
- width = visualViewport.width;
1224
- height = visualViewport.height; // Uses Layout Viewport (like Chrome; Safari does not currently)
1225
- // In Chrome, it returns a value very close to 0 (+/-) but contains rounding
1226
- // errors due to floating point numbers, so we need to check precision.
1227
- // Safari returns a number <= 0, usually < -1 when pinch-zoomed
1228
- // Feature detection fails in mobile emulation mode in Chrome.
1229
- // Math.abs(win.innerWidth / visualViewport.scale - visualViewport.width) <
1230
- // 0.001
1231
- // Fallback here: "Not Safari" userAgent
1232
-
1233
- if (!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
1234
- x = visualViewport.offsetLeft;
1235
- y = visualViewport.offsetTop;
1236
- }
1237
- }
1238
-
1239
- return {
1240
- width: width,
1241
- height: height,
1242
- x: x + getWindowScrollBarX(element),
1243
- y: y
1244
- };
1245
- }
1246
-
1247
- // of the `<html>` and `<body>` rect bounds if horizontally scrollable
1248
-
1249
- function getDocumentRect(element) {
1250
- var _element$ownerDocumen;
1251
-
1252
- var html = getDocumentElement(element);
1253
- var winScroll = getWindowScroll(element);
1254
- var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
1255
- var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
1256
- var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
1257
- var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
1258
- var y = -winScroll.scrollTop;
1259
-
1260
- if (getComputedStyle(body || html).direction === 'rtl') {
1261
- x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
1262
- }
1263
-
1264
- return {
1265
- width: width,
1266
- height: height,
1267
- x: x,
1268
- y: y
1269
- };
1270
- }
1271
-
1272
- function isScrollParent(element) {
1273
- // Firefox wants us to check `-x` and `-y` variations as well
1274
- var _getComputedStyle = getComputedStyle(element),
1275
- overflow = _getComputedStyle.overflow,
1276
- overflowX = _getComputedStyle.overflowX,
1277
- overflowY = _getComputedStyle.overflowY;
1278
-
1279
- return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
1280
- }
1281
-
1282
- function getScrollParent(node) {
1283
- if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
1284
- // $FlowFixMe[incompatible-return]: assume body is always available
1285
- return node.ownerDocument.body;
1286
- }
1287
-
1288
- if (isHTMLElement(node) && isScrollParent(node)) {
1289
- return node;
1290
- }
1291
-
1292
- return getScrollParent(getParentNode(node));
1293
- }
1294
-
1295
- /*
1296
- given a DOM element, return the list of all scroll parents, up the list of ancesors
1297
- until we get to the top window object. This list is what we attach scroll listeners
1298
- to, because if any of these parent elements scroll, we'll need to re-calculate the
1299
- reference element's position.
1300
- */
1301
-
1302
- function listScrollParents(element, list) {
1303
- var _element$ownerDocumen;
1304
-
1305
- if (list === void 0) {
1306
- list = [];
1307
- }
1308
-
1309
- var scrollParent = getScrollParent(element);
1310
- var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
1311
- var win = getWindow(scrollParent);
1312
- var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
1313
- var updatedList = list.concat(target);
1314
- return isBody ? updatedList : // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
1315
- updatedList.concat(listScrollParents(getParentNode(target)));
1316
- }
1317
-
1318
- function rectToClientRect(rect) {
1319
- return Object.assign({}, rect, {
1320
- left: rect.x,
1321
- top: rect.y,
1322
- right: rect.x + rect.width,
1323
- bottom: rect.y + rect.height
1324
- });
1325
- }
1326
-
1327
- function getInnerBoundingClientRect(element) {
1328
- var rect = getBoundingClientRect(element);
1329
- rect.top = rect.top + element.clientTop;
1330
- rect.left = rect.left + element.clientLeft;
1331
- rect.bottom = rect.top + element.clientHeight;
1332
- rect.right = rect.left + element.clientWidth;
1333
- rect.width = element.clientWidth;
1334
- rect.height = element.clientHeight;
1335
- rect.x = rect.left;
1336
- rect.y = rect.top;
1337
- return rect;
1338
- }
1339
-
1340
- function getClientRectFromMixedType(element, clippingParent) {
1341
- return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
1342
- } // A "clipping parent" is an overflowable container with the characteristic of
1343
- // clipping (or hiding) overflowing elements with a position different from
1344
- // `initial`
1345
-
1346
-
1347
- function getClippingParents(element) {
1348
- var clippingParents = listScrollParents(getParentNode(element));
1349
- var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle(element).position) >= 0;
1350
- var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
1351
-
1352
- if (!isElement(clipperElement)) {
1353
- return [];
1354
- } // $FlowFixMe[incompatible-return]: https://github.com/facebook/flow/issues/1414
1355
-
1356
-
1357
- return clippingParents.filter(function (clippingParent) {
1358
- return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
1359
- });
1360
- } // Gets the maximum area that the element is visible in due to any number of
1361
- // clipping parents
1362
-
1363
-
1364
- function getClippingRect(element, boundary, rootBoundary) {
1365
- var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
1366
- var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
1367
- var firstClippingParent = clippingParents[0];
1368
- var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
1369
- var rect = getClientRectFromMixedType(element, clippingParent);
1370
- accRect.top = max(rect.top, accRect.top);
1371
- accRect.right = min(rect.right, accRect.right);
1372
- accRect.bottom = min(rect.bottom, accRect.bottom);
1373
- accRect.left = max(rect.left, accRect.left);
1374
- return accRect;
1375
- }, getClientRectFromMixedType(element, firstClippingParent));
1376
- clippingRect.width = clippingRect.right - clippingRect.left;
1377
- clippingRect.height = clippingRect.bottom - clippingRect.top;
1378
- clippingRect.x = clippingRect.left;
1379
- clippingRect.y = clippingRect.top;
1380
- return clippingRect;
1381
- }
1382
-
1383
- function computeOffsets(_ref) {
1384
- var reference = _ref.reference,
1385
- element = _ref.element,
1386
- placement = _ref.placement;
1387
- var basePlacement = placement ? getBasePlacement(placement) : null;
1388
- var variation = placement ? getVariation(placement) : null;
1389
- var commonX = reference.x + reference.width / 2 - element.width / 2;
1390
- var commonY = reference.y + reference.height / 2 - element.height / 2;
1391
- var offsets;
1392
-
1393
- switch (basePlacement) {
1394
- case top:
1395
- offsets = {
1396
- x: commonX,
1397
- y: reference.y - element.height
1398
- };
1399
- break;
1400
-
1401
- case bottom:
1402
- offsets = {
1403
- x: commonX,
1404
- y: reference.y + reference.height
1405
- };
1406
- break;
1407
-
1408
- case right:
1409
- offsets = {
1410
- x: reference.x + reference.width,
1411
- y: commonY
1412
- };
1413
- break;
1414
-
1415
- case left:
1416
- offsets = {
1417
- x: reference.x - element.width,
1418
- y: commonY
1419
- };
1420
- break;
1421
-
1422
- default:
1423
- offsets = {
1424
- x: reference.x,
1425
- y: reference.y
1426
- };
1427
- }
1428
-
1429
- var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
1430
-
1431
- if (mainAxis != null) {
1432
- var len = mainAxis === 'y' ? 'height' : 'width';
1433
-
1434
- switch (variation) {
1435
- case start:
1436
- offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
1437
- break;
1438
-
1439
- case end:
1440
- offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
1441
- break;
1442
- }
1443
- }
1444
-
1445
- return offsets;
1446
- }
1447
-
1448
- function detectOverflow(state, options) {
1449
- if (options === void 0) {
1450
- options = {};
1451
- }
1452
-
1453
- var _options = options,
1454
- _options$placement = _options.placement,
1455
- placement = _options$placement === void 0 ? state.placement : _options$placement,
1456
- _options$boundary = _options.boundary,
1457
- boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
1458
- _options$rootBoundary = _options.rootBoundary,
1459
- rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
1460
- _options$elementConte = _options.elementContext,
1461
- elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
1462
- _options$altBoundary = _options.altBoundary,
1463
- altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
1464
- _options$padding = _options.padding,
1465
- padding = _options$padding === void 0 ? 0 : _options$padding;
1466
- var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
1467
- var altContext = elementContext === popper ? reference : popper;
1468
- var popperRect = state.rects.popper;
1469
- var element = state.elements[altBoundary ? altContext : elementContext];
1470
- var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
1471
- var referenceClientRect = getBoundingClientRect(state.elements.reference);
1472
- var popperOffsets = computeOffsets({
1473
- reference: referenceClientRect,
1474
- element: popperRect,
1475
- strategy: 'absolute',
1476
- placement: placement
1477
- });
1478
- var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets));
1479
- var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect
1480
- // 0 or negative = within the clipping rect
1481
-
1482
- var overflowOffsets = {
1483
- top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
1484
- bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
1485
- left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
1486
- right: elementClientRect.right - clippingClientRect.right + paddingObject.right
1487
- };
1488
- var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element
1489
-
1490
- if (elementContext === popper && offsetData) {
1491
- var offset = offsetData[placement];
1492
- Object.keys(overflowOffsets).forEach(function (key) {
1493
- var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
1494
- var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
1495
- overflowOffsets[key] += offset[axis] * multiply;
1496
- });
1497
- }
1498
-
1499
- return overflowOffsets;
1500
- }
1501
-
1502
- function computeAutoPlacement(state, options) {
1503
- if (options === void 0) {
1504
- options = {};
1505
- }
1506
-
1507
- var _options = options,
1508
- placement = _options.placement,
1509
- boundary = _options.boundary,
1510
- rootBoundary = _options.rootBoundary,
1511
- padding = _options.padding,
1512
- flipVariations = _options.flipVariations,
1513
- _options$allowedAutoP = _options.allowedAutoPlacements,
1514
- allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP;
1515
- var variation = getVariation(placement);
1516
- var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) {
1517
- return getVariation(placement) === variation;
1518
- }) : basePlacements;
1519
- var allowedPlacements = placements$1.filter(function (placement) {
1520
- return allowedAutoPlacements.indexOf(placement) >= 0;
1521
- });
1522
-
1523
- if (allowedPlacements.length === 0) {
1524
- allowedPlacements = placements$1;
1525
- } // $FlowFixMe[incompatible-type]: Flow seems to have problems with two array unions...
1526
-
1527
-
1528
- var overflows = allowedPlacements.reduce(function (acc, placement) {
1529
- acc[placement] = detectOverflow(state, {
1530
- placement: placement,
1531
- boundary: boundary,
1532
- rootBoundary: rootBoundary,
1533
- padding: padding
1534
- })[getBasePlacement(placement)];
1535
- return acc;
1536
- }, {});
1537
- return Object.keys(overflows).sort(function (a, b) {
1538
- return overflows[a] - overflows[b];
1539
- });
1540
- }
1541
-
1542
- function getExpandedFallbackPlacements(placement) {
1543
- if (getBasePlacement(placement) === auto) {
1544
- return [];
1545
- }
1546
-
1547
- var oppositePlacement = getOppositePlacement(placement);
1548
- return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];
1549
- }
1550
-
1551
- function flip(_ref) {
1552
- var state = _ref.state,
1553
- options = _ref.options,
1554
- name = _ref.name;
1555
-
1556
- if (state.modifiersData[name]._skip) {
1557
- return;
1558
- }
1559
-
1560
- var _options$mainAxis = options.mainAxis,
1561
- checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
1562
- _options$altAxis = options.altAxis,
1563
- checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis,
1564
- specifiedFallbackPlacements = options.fallbackPlacements,
1565
- padding = options.padding,
1566
- boundary = options.boundary,
1567
- rootBoundary = options.rootBoundary,
1568
- altBoundary = options.altBoundary,
1569
- _options$flipVariatio = options.flipVariations,
1570
- flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio,
1571
- allowedAutoPlacements = options.allowedAutoPlacements;
1572
- var preferredPlacement = state.options.placement;
1573
- var basePlacement = getBasePlacement(preferredPlacement);
1574
- var isBasePlacement = basePlacement === preferredPlacement;
1575
- var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
1576
- var placements = [preferredPlacement].concat(fallbackPlacements).reduce(function (acc, placement) {
1577
- return acc.concat(getBasePlacement(placement) === auto ? computeAutoPlacement(state, {
1578
- placement: placement,
1579
- boundary: boundary,
1580
- rootBoundary: rootBoundary,
1581
- padding: padding,
1582
- flipVariations: flipVariations,
1583
- allowedAutoPlacements: allowedAutoPlacements
1584
- }) : placement);
1585
- }, []);
1586
- var referenceRect = state.rects.reference;
1587
- var popperRect = state.rects.popper;
1588
- var checksMap = new Map();
1589
- var makeFallbackChecks = true;
1590
- var firstFittingPlacement = placements[0];
1591
-
1592
- for (var i = 0; i < placements.length; i++) {
1593
- var placement = placements[i];
1594
-
1595
- var _basePlacement = getBasePlacement(placement);
1596
-
1597
- var isStartVariation = getVariation(placement) === start;
1598
- var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
1599
- var len = isVertical ? 'width' : 'height';
1600
- var overflow = detectOverflow(state, {
1601
- placement: placement,
1602
- boundary: boundary,
1603
- rootBoundary: rootBoundary,
1604
- altBoundary: altBoundary,
1605
- padding: padding
1606
- });
1607
- var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
1608
-
1609
- if (referenceRect[len] > popperRect[len]) {
1610
- mainVariationSide = getOppositePlacement(mainVariationSide);
1611
- }
1612
-
1613
- var altVariationSide = getOppositePlacement(mainVariationSide);
1614
- var checks = [];
1615
-
1616
- if (checkMainAxis) {
1617
- checks.push(overflow[_basePlacement] <= 0);
1618
- }
1619
-
1620
- if (checkAltAxis) {
1621
- checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
1622
- }
1623
-
1624
- if (checks.every(function (check) {
1625
- return check;
1626
- })) {
1627
- firstFittingPlacement = placement;
1628
- makeFallbackChecks = false;
1629
- break;
1630
- }
1631
-
1632
- checksMap.set(placement, checks);
1633
- }
1634
-
1635
- if (makeFallbackChecks) {
1636
- // `2` may be desired in some cases – research later
1637
- var numberOfChecks = flipVariations ? 3 : 1;
1638
-
1639
- var _loop = function _loop(_i) {
1640
- var fittingPlacement = placements.find(function (placement) {
1641
- var checks = checksMap.get(placement);
1642
-
1643
- if (checks) {
1644
- return checks.slice(0, _i).every(function (check) {
1645
- return check;
1646
- });
1647
- }
1648
- });
1649
-
1650
- if (fittingPlacement) {
1651
- firstFittingPlacement = fittingPlacement;
1652
- return "break";
1653
- }
1654
- };
1655
-
1656
- for (var _i = numberOfChecks; _i > 0; _i--) {
1657
- var _ret = _loop(_i);
1658
-
1659
- if (_ret === "break") break;
1660
- }
1661
- }
1662
-
1663
- if (state.placement !== firstFittingPlacement) {
1664
- state.modifiersData[name]._skip = true;
1665
- state.placement = firstFittingPlacement;
1666
- state.reset = true;
1667
- }
1668
- } // eslint-disable-next-line import/no-unused-modules
1669
-
1670
-
1671
- const flip$1 = {
1672
- name: 'flip',
1673
- enabled: true,
1674
- phase: 'main',
1675
- fn: flip,
1676
- requiresIfExists: ['offset'],
1677
- data: {
1678
- _skip: false
1679
- }
1680
- };
1681
-
1682
- function getSideOffsets(overflow, rect, preventedOffsets) {
1683
- if (preventedOffsets === void 0) {
1684
- preventedOffsets = {
1685
- x: 0,
1686
- y: 0
1687
- };
1688
- }
1689
-
1690
- return {
1691
- top: overflow.top - rect.height - preventedOffsets.y,
1692
- right: overflow.right - rect.width + preventedOffsets.x,
1693
- bottom: overflow.bottom - rect.height + preventedOffsets.y,
1694
- left: overflow.left - rect.width - preventedOffsets.x
1695
- };
1696
- }
1697
-
1698
- function isAnySideFullyClipped(overflow) {
1699
- return [top, right, bottom, left].some(function (side) {
1700
- return overflow[side] >= 0;
1701
- });
1702
- }
1703
-
1704
- function hide(_ref) {
1705
- var state = _ref.state,
1706
- name = _ref.name;
1707
- var referenceRect = state.rects.reference;
1708
- var popperRect = state.rects.popper;
1709
- var preventedOffsets = state.modifiersData.preventOverflow;
1710
- var referenceOverflow = detectOverflow(state, {
1711
- elementContext: 'reference'
1712
- });
1713
- var popperAltOverflow = detectOverflow(state, {
1714
- altBoundary: true
1715
- });
1716
- var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
1717
- var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
1718
- var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
1719
- var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
1720
- state.modifiersData[name] = {
1721
- referenceClippingOffsets: referenceClippingOffsets,
1722
- popperEscapeOffsets: popperEscapeOffsets,
1723
- isReferenceHidden: isReferenceHidden,
1724
- hasPopperEscaped: hasPopperEscaped
1725
- };
1726
- state.attributes.popper = Object.assign({}, state.attributes.popper, {
1727
- 'data-popper-reference-hidden': isReferenceHidden,
1728
- 'data-popper-escaped': hasPopperEscaped
1729
- });
1730
- } // eslint-disable-next-line import/no-unused-modules
1731
-
1732
-
1733
- const hide$1 = {
1734
- name: 'hide',
1735
- enabled: true,
1736
- phase: 'main',
1737
- requiresIfExists: ['preventOverflow'],
1738
- fn: hide
1739
- };
1740
-
1741
- function distanceAndSkiddingToXY(placement, rects, offset) {
1742
- var basePlacement = getBasePlacement(placement);
1743
- var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
1744
-
1745
- var _ref = typeof offset === 'function' ? offset(Object.assign({}, rects, {
1746
- placement: placement
1747
- })) : offset,
1748
- skidding = _ref[0],
1749
- distance = _ref[1];
1750
-
1751
- skidding = skidding || 0;
1752
- distance = (distance || 0) * invertDistance;
1753
- return [left, right].indexOf(basePlacement) >= 0 ? {
1754
- x: distance,
1755
- y: skidding
1756
- } : {
1757
- x: skidding,
1758
- y: distance
1759
- };
1760
- }
1761
-
1762
- function offset(_ref2) {
1763
- var state = _ref2.state,
1764
- options = _ref2.options,
1765
- name = _ref2.name;
1766
- var _options$offset = options.offset,
1767
- offset = _options$offset === void 0 ? [0, 0] : _options$offset;
1768
- var data = placements.reduce(function (acc, placement) {
1769
- acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
1770
- return acc;
1771
- }, {});
1772
- var _data$state$placement = data[state.placement],
1773
- x = _data$state$placement.x,
1774
- y = _data$state$placement.y;
1775
-
1776
- if (state.modifiersData.popperOffsets != null) {
1777
- state.modifiersData.popperOffsets.x += x;
1778
- state.modifiersData.popperOffsets.y += y;
1779
- }
1780
-
1781
- state.modifiersData[name] = data;
1782
- } // eslint-disable-next-line import/no-unused-modules
1783
-
1784
-
1785
- const offset$1 = {
1786
- name: 'offset',
1787
- enabled: true,
1788
- phase: 'main',
1789
- requires: ['popperOffsets'],
1790
- fn: offset
1791
- };
1792
-
1793
- function popperOffsets(_ref) {
1794
- var state = _ref.state,
1795
- name = _ref.name;
1796
- // Offsets are the actual position the popper needs to have to be
1797
- // properly positioned near its reference element
1798
- // This is the most basic placement, and will be adjusted by
1799
- // the modifiers in the next step
1800
- state.modifiersData[name] = computeOffsets({
1801
- reference: state.rects.reference,
1802
- element: state.rects.popper,
1803
- strategy: 'absolute',
1804
- placement: state.placement
1805
- });
1806
- } // eslint-disable-next-line import/no-unused-modules
1807
-
1808
-
1809
- const popperOffsets$1 = {
1810
- name: 'popperOffsets',
1811
- enabled: true,
1812
- phase: 'read',
1813
- fn: popperOffsets,
1814
- data: {}
1815
- };
1816
-
1817
- function getAltAxis(axis) {
1818
- return axis === 'x' ? 'y' : 'x';
1819
- }
1820
-
1821
- function preventOverflow(_ref) {
1822
- var state = _ref.state,
1823
- options = _ref.options,
1824
- name = _ref.name;
1825
- var _options$mainAxis = options.mainAxis,
1826
- checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
1827
- _options$altAxis = options.altAxis,
1828
- checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis,
1829
- boundary = options.boundary,
1830
- rootBoundary = options.rootBoundary,
1831
- altBoundary = options.altBoundary,
1832
- padding = options.padding,
1833
- _options$tether = options.tether,
1834
- tether = _options$tether === void 0 ? true : _options$tether,
1835
- _options$tetherOffset = options.tetherOffset,
1836
- tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
1837
- var overflow = detectOverflow(state, {
1838
- boundary: boundary,
1839
- rootBoundary: rootBoundary,
1840
- padding: padding,
1841
- altBoundary: altBoundary
1842
- });
1843
- var basePlacement = getBasePlacement(state.placement);
1844
- var variation = getVariation(state.placement);
1845
- var isBasePlacement = !variation;
1846
- var mainAxis = getMainAxisFromPlacement(basePlacement);
1847
- var altAxis = getAltAxis(mainAxis);
1848
- var popperOffsets = state.modifiersData.popperOffsets;
1849
- var referenceRect = state.rects.reference;
1850
- var popperRect = state.rects.popper;
1851
- var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
1852
- placement: state.placement
1853
- })) : tetherOffset;
1854
- var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? {
1855
- mainAxis: tetherOffsetValue,
1856
- altAxis: tetherOffsetValue
1857
- } : Object.assign({
1858
- mainAxis: 0,
1859
- altAxis: 0
1860
- }, tetherOffsetValue);
1861
- var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
1862
- var data = {
1863
- x: 0,
1864
- y: 0
1865
- };
1866
-
1867
- if (!popperOffsets) {
1868
- return;
1869
- }
1870
-
1871
- if (checkMainAxis) {
1872
- var _offsetModifierState$;
1873
-
1874
- var mainSide = mainAxis === 'y' ? top : left;
1875
- var altSide = mainAxis === 'y' ? bottom : right;
1876
- var len = mainAxis === 'y' ? 'height' : 'width';
1877
- var offset = popperOffsets[mainAxis];
1878
- var min$1 = offset + overflow[mainSide];
1879
- var max$1 = offset - overflow[altSide];
1880
- var additive = tether ? -popperRect[len] / 2 : 0;
1881
- var minLen = variation === start ? referenceRect[len] : popperRect[len];
1882
- var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
1883
- // outside the reference bounds
1884
-
1885
- var arrowElement = state.elements.arrow;
1886
- var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
1887
- width: 0,
1888
- height: 0
1889
- };
1890
- var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject();
1891
- var arrowPaddingMin = arrowPaddingObject[mainSide];
1892
- var arrowPaddingMax = arrowPaddingObject[altSide]; // If the reference length is smaller than the arrow length, we don't want
1893
- // to include its full size in the calculation. If the reference is small
1894
- // and near the edge of a boundary, the popper can overflow even if the
1895
- // reference is not overflowing as well (e.g. virtual elements with no
1896
- // width or height)
1897
-
1898
- var arrowLen = within(0, referenceRect[len], arrowRect[len]);
1899
- var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
1900
- var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
1901
- var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
1902
- var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
1903
- var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
1904
- var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;
1905
- var tetherMax = offset + maxOffset - offsetModifierValue;
1906
- var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
1907
- popperOffsets[mainAxis] = preventedOffset;
1908
- data[mainAxis] = preventedOffset - offset;
1909
- }
1910
-
1911
- if (checkAltAxis) {
1912
- var _offsetModifierState$2;
1913
-
1914
- var _mainSide = mainAxis === 'x' ? top : left;
1915
-
1916
- var _altSide = mainAxis === 'x' ? bottom : right;
1917
-
1918
- var _offset = popperOffsets[altAxis];
1919
-
1920
- var _len = altAxis === 'y' ? 'height' : 'width';
1921
-
1922
- var _min = _offset + overflow[_mainSide];
1923
-
1924
- var _max = _offset - overflow[_altSide];
1925
-
1926
- var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
1927
-
1928
- var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
1929
-
1930
- var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
1931
-
1932
- var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
1933
-
1934
- var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
1935
-
1936
- popperOffsets[altAxis] = _preventedOffset;
1937
- data[altAxis] = _preventedOffset - _offset;
1938
- }
1939
-
1940
- state.modifiersData[name] = data;
1941
- } // eslint-disable-next-line import/no-unused-modules
1942
-
1943
-
1944
- const preventOverflow$1 = {
1945
- name: 'preventOverflow',
1946
- enabled: true,
1947
- phase: 'main',
1948
- fn: preventOverflow,
1949
- requiresIfExists: ['offset']
1950
- };
1951
-
1952
- function getHTMLElementScroll(element) {
1953
- return {
1954
- scrollLeft: element.scrollLeft,
1955
- scrollTop: element.scrollTop
1956
- };
1957
- }
1958
-
1959
- function getNodeScroll(node) {
1960
- if (node === getWindow(node) || !isHTMLElement(node)) {
1961
- return getWindowScroll(node);
1962
- } else {
1963
- return getHTMLElementScroll(node);
1964
- }
1965
- }
1966
-
1967
- function isElementScaled(element) {
1968
- var rect = element.getBoundingClientRect();
1969
- var scaleX = round(rect.width) / element.offsetWidth || 1;
1970
- var scaleY = round(rect.height) / element.offsetHeight || 1;
1971
- return scaleX !== 1 || scaleY !== 1;
1972
- } // Returns the composite rect of an element relative to its offsetParent.
1973
- // Composite means it takes into account transforms as well as layout.
1974
-
1975
-
1976
- function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
1977
- if (isFixed === void 0) {
1978
- isFixed = false;
1979
- }
1980
-
1981
- var isOffsetParentAnElement = isHTMLElement(offsetParent);
1982
- var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
1983
- var documentElement = getDocumentElement(offsetParent);
1984
- var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled);
1985
- var scroll = {
1986
- scrollLeft: 0,
1987
- scrollTop: 0
1988
- };
1989
- var offsets = {
1990
- x: 0,
1991
- y: 0
1992
- };
1993
-
1994
- if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1995
- if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078
1996
- isScrollParent(documentElement)) {
1997
- scroll = getNodeScroll(offsetParent);
1998
- }
1999
-
2000
- if (isHTMLElement(offsetParent)) {
2001
- offsets = getBoundingClientRect(offsetParent, true);
2002
- offsets.x += offsetParent.clientLeft;
2003
- offsets.y += offsetParent.clientTop;
2004
- } else if (documentElement) {
2005
- offsets.x = getWindowScrollBarX(documentElement);
2006
- }
2007
- }
2008
-
2009
- return {
2010
- x: rect.left + scroll.scrollLeft - offsets.x,
2011
- y: rect.top + scroll.scrollTop - offsets.y,
2012
- width: rect.width,
2013
- height: rect.height
2014
- };
2015
- }
2016
-
2017
- function order(modifiers) {
2018
- var map = new Map();
2019
- var visited = new Set();
2020
- var result = [];
2021
- modifiers.forEach(function (modifier) {
2022
- map.set(modifier.name, modifier);
2023
- }); // On visiting object, check for its dependencies and visit them recursively
2024
-
2025
- function sort(modifier) {
2026
- visited.add(modifier.name);
2027
- var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
2028
- requires.forEach(function (dep) {
2029
- if (!visited.has(dep)) {
2030
- var depModifier = map.get(dep);
2031
-
2032
- if (depModifier) {
2033
- sort(depModifier);
2034
- }
2035
- }
2036
- });
2037
- result.push(modifier);
2038
- }
2039
-
2040
- modifiers.forEach(function (modifier) {
2041
- if (!visited.has(modifier.name)) {
2042
- // check for visited object
2043
- sort(modifier);
2044
- }
2045
- });
2046
- return result;
2047
- }
2048
-
2049
- function orderModifiers(modifiers) {
2050
- // order based on dependencies
2051
- var orderedModifiers = order(modifiers); // order based on phase
2052
-
2053
- return modifierPhases.reduce(function (acc, phase) {
2054
- return acc.concat(orderedModifiers.filter(function (modifier) {
2055
- return modifier.phase === phase;
2056
- }));
2057
- }, []);
2058
- }
2059
-
2060
- function debounce(fn) {
2061
- var pending;
2062
- return function () {
2063
- if (!pending) {
2064
- pending = new Promise(function (resolve) {
2065
- Promise.resolve().then(function () {
2066
- pending = undefined;
2067
- resolve(fn());
2068
- });
2069
- });
2070
- }
2071
-
2072
- return pending;
2073
- };
2074
- }
2075
-
2076
- function mergeByName(modifiers) {
2077
- var merged = modifiers.reduce(function (merged, current) {
2078
- var existing = merged[current.name];
2079
- merged[current.name] = existing ? Object.assign({}, existing, current, {
2080
- options: Object.assign({}, existing.options, current.options),
2081
- data: Object.assign({}, existing.data, current.data)
2082
- }) : current;
2083
- return merged;
2084
- }, {}); // IE11 does not support Object.values
2085
-
2086
- return Object.keys(merged).map(function (key) {
2087
- return merged[key];
2088
- });
2089
- }
2090
-
2091
- var DEFAULT_OPTIONS = {
2092
- placement: 'bottom',
2093
- modifiers: [],
2094
- strategy: 'absolute'
2095
- };
2096
-
2097
- function areValidElements() {
2098
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2099
- args[_key] = arguments[_key];
2100
- }
2101
-
2102
- return !args.some(function (element) {
2103
- return !(element && typeof element.getBoundingClientRect === 'function');
2104
- });
2105
- }
2106
-
2107
- function popperGenerator(generatorOptions) {
2108
- if (generatorOptions === void 0) {
2109
- generatorOptions = {};
2110
- }
2111
-
2112
- var _generatorOptions = generatorOptions,
2113
- _generatorOptions$def = _generatorOptions.defaultModifiers,
2114
- defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,
2115
- _generatorOptions$def2 = _generatorOptions.defaultOptions,
2116
- defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
2117
- return function createPopper(reference, popper, options) {
2118
- if (options === void 0) {
2119
- options = defaultOptions;
2120
- }
2121
-
2122
- var state = {
2123
- placement: 'bottom',
2124
- orderedModifiers: [],
2125
- options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
2126
- modifiersData: {},
2127
- elements: {
2128
- reference: reference,
2129
- popper: popper
2130
- },
2131
- attributes: {},
2132
- styles: {}
2133
- };
2134
- var effectCleanupFns = [];
2135
- var isDestroyed = false;
2136
- var instance = {
2137
- state: state,
2138
- setOptions: function setOptions(setOptionsAction) {
2139
- var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;
2140
- cleanupModifierEffects();
2141
- state.options = Object.assign({}, defaultOptions, state.options, options);
2142
- state.scrollParents = {
2143
- reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
2144
- popper: listScrollParents(popper)
2145
- }; // Orders the modifiers based on their dependencies and `phase`
2146
- // properties
2147
-
2148
- var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers
2149
-
2150
- state.orderedModifiers = orderedModifiers.filter(function (m) {
2151
- return m.enabled;
2152
- }); // Validate the provided modifiers so that the consumer will get warned
2153
-
2154
- runModifierEffects();
2155
- return instance.update();
2156
- },
2157
- // Sync update – it will always be executed, even if not necessary. This
2158
- // is useful for low frequency updates where sync behavior simplifies the
2159
- // logic.
2160
- // For high frequency updates (e.g. `resize` and `scroll` events), always
2161
- // prefer the async Popper#update method
2162
- forceUpdate: function forceUpdate() {
2163
- if (isDestroyed) {
2164
- return;
2165
- }
2166
-
2167
- var _state$elements = state.elements,
2168
- reference = _state$elements.reference,
2169
- popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements
2170
- // anymore
2171
-
2172
- if (!areValidElements(reference, popper)) {
2173
-
2174
- return;
2175
- } // Store the reference and popper rects to be read by modifiers
2176
-
2177
-
2178
- state.rects = {
2179
- reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),
2180
- popper: getLayoutRect(popper)
2181
- }; // Modifiers have the ability to reset the current update cycle. The
2182
- // most common use case for this is the `flip` modifier changing the
2183
- // placement, which then needs to re-run all the modifiers, because the
2184
- // logic was previously ran for the previous placement and is therefore
2185
- // stale/incorrect
2186
-
2187
- state.reset = false;
2188
- state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier
2189
- // is filled with the initial data specified by the modifier. This means
2190
- // it doesn't persist and is fresh on each update.
2191
- // To ensure persistent data, use `${name}#persistent`
2192
-
2193
- state.orderedModifiers.forEach(function (modifier) {
2194
- return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
2195
- });
2196
-
2197
- for (var index = 0; index < state.orderedModifiers.length; index++) {
2198
-
2199
- if (state.reset === true) {
2200
- state.reset = false;
2201
- index = -1;
2202
- continue;
2203
- }
2204
-
2205
- var _state$orderedModifie = state.orderedModifiers[index],
2206
- fn = _state$orderedModifie.fn,
2207
- _state$orderedModifie2 = _state$orderedModifie.options,
2208
- _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,
2209
- name = _state$orderedModifie.name;
2210
-
2211
- if (typeof fn === 'function') {
2212
- state = fn({
2213
- state: state,
2214
- options: _options,
2215
- name: name,
2216
- instance: instance
2217
- }) || state;
2218
- }
2219
- }
2220
- },
2221
- // Async and optimistically optimized update – it will not be executed if
2222
- // not necessary (debounced to run at most once-per-tick)
2223
- update: debounce(function () {
2224
- return new Promise(function (resolve) {
2225
- instance.forceUpdate();
2226
- resolve(state);
2227
- });
2228
- }),
2229
- destroy: function destroy() {
2230
- cleanupModifierEffects();
2231
- isDestroyed = true;
2232
- }
2233
- };
2234
-
2235
- if (!areValidElements(reference, popper)) {
2236
-
2237
- return instance;
2238
- }
2239
-
2240
- instance.setOptions(options).then(function (state) {
2241
- if (!isDestroyed && options.onFirstUpdate) {
2242
- options.onFirstUpdate(state);
2243
- }
2244
- }); // Modifiers have the ability to execute arbitrary code before the first
2245
- // update cycle runs. They will be executed in the same order as the update
2246
- // cycle. This is useful when a modifier adds some persistent data that
2247
- // other modifiers need to use, but the modifier is run after the dependent
2248
- // one.
2249
-
2250
- function runModifierEffects() {
2251
- state.orderedModifiers.forEach(function (_ref3) {
2252
- var name = _ref3.name,
2253
- _ref3$options = _ref3.options,
2254
- options = _ref3$options === void 0 ? {} : _ref3$options,
2255
- effect = _ref3.effect;
2256
-
2257
- if (typeof effect === 'function') {
2258
- var cleanupFn = effect({
2259
- state: state,
2260
- name: name,
2261
- instance: instance,
2262
- options: options
2263
- });
2264
-
2265
- var noopFn = function noopFn() {};
2266
-
2267
- effectCleanupFns.push(cleanupFn || noopFn);
2268
- }
2269
- });
2270
- }
2271
-
2272
- function cleanupModifierEffects() {
2273
- effectCleanupFns.forEach(function (fn) {
2274
- return fn();
2275
- });
2276
- effectCleanupFns = [];
2277
- }
2278
-
2279
- return instance;
2280
- };
2281
- }
2282
-
2283
- var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
2284
- var createPopper = /*#__PURE__*/popperGenerator({
2285
- defaultModifiers: defaultModifiers
2286
- }); // eslint-disable-next-line import/no-unused-modules
2287
-
2288
- const portalCss = ":host(limel-portal){display:block;position:absolute;top:0;bottom:0;width:100%;pointer-events:none}:host([hidden]){display:none}";
2289
-
2290
- const Portal = class {
2291
- constructor(hostRef) {
2292
- registerInstance(this, hostRef);
2293
- /**
2294
- * Decides which direction the portal content should open.
2295
- */
2296
- this.openDirection = 'bottom';
2297
- /**
2298
- * Position of the content.
2299
- */
2300
- this.position = 'absolute';
2301
- /**
2302
- * Dynamic styling that can be applied to the container holding the content.
2303
- */
2304
- this.containerStyle = {};
2305
- /**
2306
- * Parent element to move the content to.
2307
- */
2308
- this.parent = document.body;
2309
- /**
2310
- * Used to make a dropdown have the same width as the trigger, for example
2311
- * in `limel-picker`.
2312
- */
2313
- this.inheritParentWidth = false;
2314
- /**
2315
- * True if the content within the portal should be visible.
2316
- *
2317
- * If the content is from within a dialog for instance, this can be set to
2318
- * true from false when the dialog opens to position the content properly.
2319
- */
2320
- this.visible = false;
2321
- this.loaded = false;
2322
- this.parents = new WeakMap();
2323
- }
2324
- onVisible() {
2325
- if (!this.visible) {
2326
- this.hideContainer();
2327
- this.styleContainer();
2328
- this.destroyPopper();
2329
- return;
2330
- }
2331
- this.styleContainer();
2332
- this.createPopper();
2333
- requestAnimationFrame(() => {
2334
- this.showContainer();
2335
- });
2336
- }
2337
- disconnectedCallback() {
2338
- this.removeContainer();
2339
- this.destroyPopper();
2340
- if (this.observer) {
2341
- this.observer.unobserve(this.container);
2342
- }
2343
- }
2344
- connectedCallback() {
2345
- if (!this.loaded) {
2346
- return;
2347
- }
2348
- this.createContainer();
2349
- this.hideContainer();
2350
- this.attachContainer();
2351
- this.styleContainer();
2352
- if (this.visible) {
2353
- this.createPopper();
2354
- this.showContainer();
2355
- }
2356
- if ('ResizeObserver' in window) {
2357
- const observer = new ResizeObserver(() => {
2358
- if (this.popperInstance) {
2359
- this.styleContainer();
2360
- this.popperInstance.update();
2361
- }
2362
- });
2363
- observer.observe(this.container);
2364
- }
2365
- }
2366
- componentDidLoad() {
2367
- this.loaded = true;
2368
- this.connectedCallback();
2369
- }
2370
- render() {
2371
- return h("slot", null);
2372
- }
2373
- createContainer() {
2374
- const slot = this.host.shadowRoot.querySelector('slot');
2375
- const content = (slot.assignedElements && slot.assignedElements()) || [];
2376
- this.container = document.createElement('div');
2377
- this.container.setAttribute('id', this.containerId);
2378
- this.container.setAttribute('class', 'limel-portal--container');
2379
- Object.assign(this.container, {
2380
- portalSource: this.host,
2381
- });
2382
- content.forEach((element) => {
2383
- this.parents.set(element, element.parentElement);
2384
- this.container.appendChild(element);
2385
- });
2386
- }
2387
- attachContainer() {
2388
- this.parent.appendChild(this.container);
2389
- }
2390
- removeContainer() {
2391
- if (!this.container) {
2392
- return;
2393
- }
2394
- Array.from(this.container.children).forEach((element) => {
2395
- const parent = this.parents.get(element);
2396
- if (!parent) {
2397
- return;
2398
- }
2399
- parent.appendChild(element);
2400
- });
2401
- this.hideContainer();
2402
- this.container.parentElement.removeChild(this.container);
2403
- }
2404
- hideContainer() {
2405
- this.container.style.opacity = '0';
2406
- }
2407
- showContainer() {
2408
- this.container.style.opacity = '1';
2409
- }
2410
- styleContainer() {
2411
- const hostWidth = this.host.getBoundingClientRect().width;
2412
- if (this.visible) {
2413
- this.container.style.display = 'block';
2414
- }
2415
- else {
2416
- this.container.style.display = 'none';
2417
- }
2418
- if (this.inheritParentWidth) {
2419
- const containerWidth = this.getContentWidth(this.container);
2420
- let width = containerWidth;
2421
- if (hostWidth > 0) {
2422
- width = hostWidth;
2423
- }
2424
- this.container.style.width = `${width}px`;
2425
- }
2426
- this.ensureContainerFitsInViewPort();
2427
- Object.keys(this.containerStyle).forEach((property) => {
2428
- this.container.style[property] = this.containerStyle[property];
2429
- });
2430
- }
2431
- getContentWidth(element) {
2432
- if (!element) {
2433
- return null;
2434
- }
2435
- const width = element.getBoundingClientRect().width;
2436
- if (width !== 0) {
2437
- return width;
2438
- }
2439
- const elementContent = element.querySelector('*');
2440
- return this.getContentWidth(elementContent);
2441
- }
2442
- createPopper() {
2443
- const config = this.createPopperConfig();
2444
- this.popperInstance = createPopper(this.host, this.container, config);
2445
- }
2446
- destroyPopper() {
2447
- var _a;
2448
- (_a = this.popperInstance) === null || _a === void 0 ? void 0 : _a.destroy();
2449
- this.popperInstance = null;
2450
- }
2451
- createPopperConfig() {
2452
- const placement = this.getPlacement(this.openDirection);
2453
- const flipPlacement = this.getFlipPlacement(this.openDirection);
2454
- return {
2455
- strategy: this.position,
2456
- placement: placement,
2457
- modifiers: [
2458
- {
2459
- name: 'flip',
2460
- options: {
2461
- fallbackPlacements: [flipPlacement],
2462
- },
2463
- },
2464
- ],
2465
- };
2466
- }
2467
- getPlacement(direction) {
2468
- const placements = {
2469
- 'left-start': 'left-start',
2470
- left: 'left',
2471
- 'left-end': 'left-end',
2472
- 'right-start': 'right-start',
2473
- right: 'right',
2474
- 'right-end': 'right-end',
2475
- 'top-start': 'top-start',
2476
- top: 'top',
2477
- 'top-end': 'top-end',
2478
- 'bottom-start': 'bottom-start',
2479
- bottom: 'bottom',
2480
- 'bottom-end': 'bottom-end',
2481
- };
2482
- return placements[direction];
2483
- }
2484
- getFlipPlacement(direction) {
2485
- const flipPlacements = {
2486
- 'left-start': 'right-start',
2487
- left: 'right',
2488
- 'left-end': 'right-end',
2489
- 'right-start': 'left-start',
2490
- right: 'left',
2491
- 'right-end': 'left-end',
2492
- 'top-start': 'bottom-start',
2493
- top: 'bottom',
2494
- 'top-end': 'bottom-end',
2495
- 'bottom-start': 'top-start',
2496
- bottom: 'top',
2497
- 'bottom-end': 'top-end',
2498
- };
2499
- return flipPlacements[direction];
2500
- }
2501
- ensureContainerFitsInViewPort() {
2502
- const viewHeight = Math.max(document.documentElement.clientHeight || 0, window.innerHeight || 0);
2503
- const { top, bottom } = this.host.getBoundingClientRect();
2504
- const spaceAboveTopOfSurface = Math.max(top, 0);
2505
- const spaceBelowTopOfSurface = Math.max(viewHeight - bottom, 0);
2506
- const extraCosmeticSpace = 16;
2507
- const maxHeight = Math.max(spaceAboveTopOfSurface, spaceBelowTopOfSurface) -
2508
- extraCosmeticSpace;
2509
- this.container.style.maxHeight = `${maxHeight}px`;
2510
- }
2511
- get host() { return getElement(this); }
2512
- static get watchers() { return {
2513
- "visible": ["onVisible"]
2514
- }; }
2515
- };
2516
- Portal.style = portalCss;
2517
-
2518
- export { List as limel_list, MenuSurface as limel_menu_surface, Portal as limel_portal };
501
+ export { List as limel_list, MenuSurface as limel_menu_surface };