@lumx/react 4.4.0 → 4.4.1-alpha.1

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 (4) hide show
  1. package/index.d.ts +61 -51
  2. package/index.js +2314 -2282
  3. package/index.js.map +1 -1
  4. package/package.json +6 -6
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Kind as Kind$1, Size as Size$1, ColorPalette as ColorPalette$1, Emphasis as Emphasis$1, Theme as Theme$1, AspectRatio as AspectRatio$1, ColorVariant, DIALOG_TRANSITION_DURATION, Orientation as Orientation$1, Alignment, NOTIFICATION_TRANSITION_DURATION, TOOLTIP_LONG_PRESS_DELAY, TOOLTIP_HOVER_DELAY } from '@lumx/core/js/constants';
1
+ import { Kind as Kind$1, Size as Size$1, ColorPalette as ColorPalette$1, Emphasis as Emphasis$1, ColorVariant, Theme as Theme$1, AspectRatio as AspectRatio$1, DIALOG_TRANSITION_DURATION, Orientation as Orientation$1, Alignment, NOTIFICATION_TRANSITION_DURATION, TOOLTIP_LONG_PRESS_DELAY, TOOLTIP_HOVER_DELAY } from '@lumx/core/js/constants';
2
2
  export * from '@lumx/core/js/constants';
3
3
  export * from '@lumx/core/js/types';
4
4
  import * as React from 'react';
@@ -20,7 +20,8 @@ import { u as useDisabledStateContext, P as Portal, C as ClickAwayProvider } fro
20
20
  import isEmpty from 'lodash/isEmpty.js';
21
21
  import { getDisabledState } from '@lumx/core/js/utils/disabledState';
22
22
  import { mdiCloseCircle } from '@lumx/icons/esm/close-circle.js';
23
- import memoize from 'lodash/memoize.js';
23
+ import * as ReactDOM from 'react-dom';
24
+ import ReactDOM__default from 'react-dom';
24
25
  import { mdiClose } from '@lumx/icons/esm/close.js';
25
26
  import isFunction from 'lodash/isFunction.js';
26
27
  import { mdiImageBroken } from '@lumx/icons/esm/image-broken.js';
@@ -32,17 +33,17 @@ import castArray from 'lodash/castArray.js';
32
33
  import { mdiDragVertical } from '@lumx/icons/esm/drag-vertical.js';
33
34
  import { mdiChevronDown } from '@lumx/icons/esm/chevron-down.js';
34
35
  import { mdiChevronUp } from '@lumx/icons/esm/chevron-up.js';
35
- import noop from 'lodash/noop.js';
36
+ import noop$1 from 'lodash/noop.js';
36
37
  import pick from 'lodash/pick.js';
37
38
  import isInteger from 'lodash/isInteger.js';
38
39
  import { mdiMagnifyMinusOutline } from '@lumx/icons/esm/magnify-minus-outline.js';
39
40
  import { mdiMagnifyPlusOutline } from '@lumx/icons/esm/magnify-plus-outline.js';
41
+ import memoize from 'lodash/memoize.js';
40
42
  import throttle from 'lodash/throttle.js';
41
43
  import range from 'lodash/range.js';
42
44
  import { mdiPlayCircleOutline } from '@lumx/icons/esm/play-circle-outline.js';
43
45
  import { mdiPauseCircleOutline } from '@lumx/icons/esm/pause-circle-outline.js';
44
46
  import chunk from 'lodash/chunk.js';
45
- import ReactDOM from 'react-dom';
46
47
  import take from 'lodash/take.js';
47
48
  import { mdiRadioboxBlank } from '@lumx/icons/esm/radiobox-blank.js';
48
49
  import { mdiRadioboxMarked } from '@lumx/icons/esm/radiobox-marked.js';
@@ -552,149 +553,6 @@ AutocompleteMultiple.displayName = COMPONENT_NAME$1i;
552
553
  AutocompleteMultiple.className = CLASSNAME$1h;
553
554
  AutocompleteMultiple.defaultProps = DEFAULT_PROPS$18;
554
555
 
555
- /**
556
- * Component display name.
557
- */
558
- const COMPONENT_NAME$1h = 'Avatar';
559
-
560
- /**
561
- * Component default class name and class prefix.
562
- */
563
- const CLASSNAME$1g = 'lumx-avatar';
564
- const {
565
- block: block$13,
566
- element: element$N
567
- } = classNames.bem(CLASSNAME$1g);
568
-
569
- /**
570
- * Component default props.
571
- */
572
- const DEFAULT_PROPS$17 = {
573
- size: Size$1.m
574
- };
575
-
576
- /**
577
- * Avatar component.
578
- *
579
- * @param props Component props.
580
- * @param ref Component ref.
581
- * @return React element.
582
- */
583
- const Avatar = forwardRef((props, ref) => {
584
- const defaultTheme = useTheme() || Theme$1.light;
585
- const {
586
- actions,
587
- alt,
588
- badge,
589
- className,
590
- image,
591
- linkProps,
592
- linkAs,
593
- onClick,
594
- onKeyPress,
595
- size = DEFAULT_PROPS$17.size,
596
- theme = defaultTheme,
597
- thumbnailProps,
598
- ...forwardedProps
599
- } = props;
600
- return /*#__PURE__*/jsxs("div", {
601
- ref: ref,
602
- ...forwardedProps,
603
- className: classNames.join(className, block$13({
604
- [`size-${size}`]: Boolean(size),
605
- [`theme-${theme}`]: Boolean(theme)
606
- })),
607
- children: [/*#__PURE__*/jsx(Thumbnail, {
608
- linkProps: linkProps,
609
- linkAs: linkAs,
610
- className: element$N('thumbnail'),
611
- onClick: onClick,
612
- onKeyPress: onKeyPress,
613
- ...thumbnailProps,
614
- aspectRatio: AspectRatio$1.square,
615
- size: size,
616
- image: image,
617
- alt: alt,
618
- theme: theme
619
- }), actions && /*#__PURE__*/jsx("div", {
620
- className: element$N('actions'),
621
- children: actions
622
- }), badge && /*#__PURE__*/jsx("div", {
623
- className: element$N('badge'),
624
- children: badge
625
- })]
626
- });
627
- });
628
- Avatar.displayName = COMPONENT_NAME$1h;
629
- Avatar.className = CLASSNAME$1g;
630
- Avatar.defaultProps = DEFAULT_PROPS$17;
631
-
632
- /**
633
- * Alignments.
634
- */
635
- const Theme = {
636
- light: 'light',
637
- dark: 'dark'
638
- };
639
- const Size = {
640
- xxs: 'xxs',
641
- xs: 'xs',
642
- s: 's',
643
- m: 'm',
644
- xl: 'xl',
645
- xxl: 'xxl'};
646
- const Orientation = {
647
- horizontal: 'horizontal'};
648
- const Emphasis = {
649
- low: 'low',
650
- high: 'high'
651
- };
652
- /**
653
- * List of typographies that can't be customized.
654
- */
655
- const TypographyInterface = {
656
- overline: 'overline',
657
- caption: 'caption',
658
- body1: 'body1',
659
- body2: 'body2',
660
- subtitle1: 'subtitle1',
661
- subtitle2: 'subtitle2',
662
- title: 'title',
663
- headline: 'headline',
664
- display1: 'display1'
665
- };
666
- /**
667
- * List of all typographies.
668
- */
669
- const Typography = {
670
- ...TypographyInterface};
671
- /**
672
- * All available aspect ratios.
673
- */
674
- const AspectRatio = {
675
- /** Intrinsic content ratio. */
676
- original: 'original'};
677
- /**
678
- * Semantic info about the purpose of the component
679
- */
680
- const Kind = {
681
- info: 'info',
682
- success: 'success',
683
- warning: 'warning',
684
- error: 'error'
685
- };
686
- /**
687
- * See SCSS variable $lumx-color-palette
688
- */
689
- const ColorPalette = {
690
- primary: 'primary',
691
- blue: 'blue',
692
- dark: 'dark',
693
- green: 'green',
694
- yellow: 'yellow',
695
- red: 'red',
696
- light: 'light'};
697
-
698
556
  function getDefaultExportFromCjs (x) {
699
557
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
700
558
  }
@@ -855,7 +713,7 @@ function modifier$1(baseName, modifiers) {
855
713
  * block('button', { active: true, disabled: false }); // 'button button--active'
856
714
  */
857
715
 
858
- function block$12(baseName, modifiersOrAdditionalClasses, additionalClasses) {
716
+ function block$13(baseName, modifiersOrAdditionalClasses, additionalClasses) {
859
717
  let modifiers;
860
718
  let classes;
861
719
  if (Array.isArray(modifiersOrAdditionalClasses)) {
@@ -890,11 +748,11 @@ function block$12(baseName, modifiersOrAdditionalClasses, additionalClasses) {
890
748
  * element('my-button', 'icon', { active: true }); // 'my-button__icon my-button__icon--active'
891
749
  */
892
750
 
893
- function element$M(baseClass, elem, modifiersOrAdditionalClasses, additionalClasses) {
751
+ function element$N(baseClass, elem, modifiersOrAdditionalClasses, additionalClasses) {
894
752
  if (Array.isArray(modifiersOrAdditionalClasses)) {
895
- return block$12(`${baseClass}__${elem}`, modifiersOrAdditionalClasses);
753
+ return block$13(`${baseClass}__${elem}`, modifiersOrAdditionalClasses);
896
754
  }
897
- return block$12(`${baseClass}__${elem}`, modifiersOrAdditionalClasses, additionalClasses);
755
+ return block$13(`${baseClass}__${elem}`, modifiersOrAdditionalClasses, additionalClasses);
898
756
  }
899
757
 
900
758
  /**
@@ -903,15 +761,15 @@ function element$M(baseClass, elem, modifiersOrAdditionalClasses, additionalClas
903
761
  function bem(baseName) {
904
762
  function blockFn(modifiersOrAdditionalClasses, additionalClasses) {
905
763
  if (Array.isArray(modifiersOrAdditionalClasses)) {
906
- return block$12(baseName, modifiersOrAdditionalClasses);
764
+ return block$13(baseName, modifiersOrAdditionalClasses);
907
765
  }
908
- return block$12(baseName, modifiersOrAdditionalClasses, additionalClasses);
766
+ return block$13(baseName, modifiersOrAdditionalClasses, additionalClasses);
909
767
  }
910
768
  function elementFn(elem, modifiersOrAdditionalClasses, additionalClasses) {
911
769
  if (Array.isArray(modifiersOrAdditionalClasses)) {
912
- return element$M(baseName, elem, modifiersOrAdditionalClasses);
770
+ return element$N(baseName, elem, modifiersOrAdditionalClasses);
913
771
  }
914
- return element$M(baseName, elem, modifiersOrAdditionalClasses, additionalClasses);
772
+ return element$N(baseName, elem, modifiersOrAdditionalClasses, additionalClasses);
915
773
  }
916
774
  return {
917
775
  block: blockFn,
@@ -920,73 +778,246 @@ function bem(baseName) {
920
778
  };
921
779
  }
922
780
 
781
+ /**
782
+ * Alignments.
783
+ */
784
+ const Theme = {
785
+ light: 'light',
786
+ dark: 'dark'
787
+ };
788
+ const Size = {
789
+ xxs: 'xxs',
790
+ xs: 'xs',
791
+ s: 's',
792
+ m: 'm',
793
+ xl: 'xl',
794
+ xxl: 'xxl'};
795
+ const Orientation = {
796
+ horizontal: 'horizontal'};
797
+ const Emphasis = {
798
+ low: 'low',
799
+ high: 'high'
800
+ };
801
+ /**
802
+ * List of typographies that can't be customized.
803
+ */
804
+ const TypographyInterface = {
805
+ overline: 'overline',
806
+ caption: 'caption',
807
+ body1: 'body1',
808
+ body2: 'body2',
809
+ subtitle1: 'subtitle1',
810
+ subtitle2: 'subtitle2',
811
+ title: 'title',
812
+ headline: 'headline',
813
+ display1: 'display1'
814
+ };
815
+ /**
816
+ * List of all typographies.
817
+ */
818
+ const Typography = {
819
+ ...TypographyInterface};
820
+ /**
821
+ * All available aspect ratios.
822
+ */
823
+ const AspectRatio = {
824
+ /** Intrinsic content ratio. */
825
+ original: 'original'};
826
+ /**
827
+ * Semantic info about the purpose of the component
828
+ */
829
+ const Kind = {
830
+ info: 'info',
831
+ success: 'success',
832
+ warning: 'warning',
833
+ error: 'error'
834
+ };
835
+ /**
836
+ * See SCSS variable $lumx-color-palette
837
+ */
838
+ const ColorPalette = {
839
+ primary: 'primary',
840
+ blue: 'blue',
841
+ dark: 'dark',
842
+ green: 'green',
843
+ yellow: 'yellow',
844
+ red: 'red',
845
+ light: 'light'};
846
+
923
847
  /**
924
848
  * Component display name.
925
849
  */
926
- const COMPONENT_NAME$1g = 'Badge';
850
+ const COMPONENT_NAME$1h = 'Avatar';
927
851
 
928
852
  /**
929
853
  * Component default class name and class prefix.
930
854
  */
931
- const CLASSNAME$1f = 'lumx-badge';
855
+ const CLASSNAME$1g = 'lumx-avatar';
932
856
  const {
933
- block: block$11
934
- } = bem(CLASSNAME$1f);
857
+ block: block$12,
858
+ element: element$M
859
+ } = bem(CLASSNAME$1g);
935
860
 
936
861
  /**
937
862
  * Component default props.
938
863
  */
939
- const DEFAULT_PROPS$16 = {
940
- color: ColorPalette.primary
864
+ const DEFAULT_PROPS$17 = {
865
+ size: Size.m
941
866
  };
942
867
 
943
868
  /**
944
- * Badge component.
869
+ * Avatar component.
945
870
  *
946
871
  * @param props Component props.
947
- * @return JSX element.
872
+ * @param ref Component ref.
873
+ * @return React element.
948
874
  */
949
- const Badge$1 = props => {
875
+ const Avatar$1 = props => {
950
876
  const {
951
- children,
877
+ actions,
878
+ badge,
952
879
  className,
953
- color = DEFAULT_PROPS$16.color,
880
+ image,
881
+ size = DEFAULT_PROPS$17.size,
882
+ theme,
954
883
  ref,
955
884
  ...forwardedProps
956
885
  } = props;
957
- return /*#__PURE__*/jsx("div", {
886
+ return /*#__PURE__*/jsxs("div", {
958
887
  ref: ref,
959
888
  ...forwardedProps,
960
- className: classnames(className, block$11({
961
- [`color-${color}`]: Boolean(color)
889
+ className: classnames(className, block$12({
890
+ [`size-${size}`]: Boolean(size),
891
+ [`theme-${theme}`]: Boolean(theme)
962
892
  })),
963
- children: children
893
+ children: [image, actions && /*#__PURE__*/jsx("div", {
894
+ className: element$M('actions'),
895
+ children: actions
896
+ }), badge && /*#__PURE__*/jsx("div", {
897
+ className: element$M('badge'),
898
+ children: badge
899
+ })]
964
900
  });
965
901
  };
966
- Badge$1.displayName = COMPONENT_NAME$1g;
967
- Badge$1.className = CLASSNAME$1f;
968
- Badge$1.defaultProps = DEFAULT_PROPS$16;
969
-
970
- /**
971
- * Defines the props of the component.
972
- */
973
902
 
974
903
  /**
975
- * Badge component.
904
+ * Avatar component.
976
905
  *
977
906
  * @param props Component props.
978
907
  * @param ref Component ref.
979
908
  * @return React element.
980
909
  */
981
- const Badge = forwardRef((props, ref) => {
982
- return Badge$1({
983
- ...props,
984
- ref
985
- });
986
- });
987
- Badge.displayName = Badge$1.displayName;
988
- Badge.className = Badge$1.className;
989
- Badge.defaultProps = Badge$1.defaultProps;
910
+ const Avatar = forwardRef((props, ref) => {
911
+ const defaultTheme = useTheme() || Theme$1.light;
912
+ const {
913
+ actions,
914
+ alt,
915
+ badge,
916
+ className,
917
+ image,
918
+ linkProps,
919
+ linkAs,
920
+ onClick,
921
+ onKeyPress,
922
+ size = DEFAULT_PROPS$17.size,
923
+ theme = defaultTheme,
924
+ thumbnailProps,
925
+ ...forwardedProps
926
+ } = props;
927
+ return Avatar$1({
928
+ ...forwardedProps,
929
+ className,
930
+ theme,
931
+ ref,
932
+ actions,
933
+ badge,
934
+ size,
935
+ image: /*#__PURE__*/jsx(Thumbnail, {
936
+ linkProps: linkProps,
937
+ linkAs: linkAs,
938
+ className: element$M('thumbnail'),
939
+ onClick: onClick,
940
+ onKeyPress: onKeyPress,
941
+ ...thumbnailProps,
942
+ aspectRatio: AspectRatio$1.square,
943
+ size: size,
944
+ image: image,
945
+ alt: alt,
946
+ theme: theme
947
+ })
948
+ });
949
+ });
950
+ Avatar.displayName = COMPONENT_NAME$1h;
951
+ Avatar.className = CLASSNAME$1g;
952
+ Avatar.defaultProps = DEFAULT_PROPS$17;
953
+
954
+ /**
955
+ * Component display name.
956
+ */
957
+ const COMPONENT_NAME$1g = 'Badge';
958
+
959
+ /**
960
+ * Component default class name and class prefix.
961
+ */
962
+ const CLASSNAME$1f = 'lumx-badge';
963
+ const {
964
+ block: block$11
965
+ } = bem(CLASSNAME$1f);
966
+
967
+ /**
968
+ * Component default props.
969
+ */
970
+ const DEFAULT_PROPS$16 = {
971
+ color: ColorPalette.primary
972
+ };
973
+
974
+ /**
975
+ * Badge component.
976
+ *
977
+ * @param props Component props.
978
+ * @return JSX element.
979
+ */
980
+ const Badge$1 = props => {
981
+ const {
982
+ children,
983
+ className,
984
+ color = DEFAULT_PROPS$16.color,
985
+ ref,
986
+ ...forwardedProps
987
+ } = props;
988
+ return /*#__PURE__*/jsx("div", {
989
+ ref: ref,
990
+ ...forwardedProps,
991
+ className: classnames(className, block$11({
992
+ [`color-${color}`]: Boolean(color)
993
+ })),
994
+ children: children
995
+ });
996
+ };
997
+ Badge$1.displayName = COMPONENT_NAME$1g;
998
+ Badge$1.className = CLASSNAME$1f;
999
+ Badge$1.defaultProps = DEFAULT_PROPS$16;
1000
+
1001
+ /**
1002
+ * Defines the props of the component.
1003
+ */
1004
+
1005
+ /**
1006
+ * Badge component.
1007
+ *
1008
+ * @param props Component props.
1009
+ * @param ref Component ref.
1010
+ * @return React element.
1011
+ */
1012
+ const Badge = forwardRef((props, ref) => {
1013
+ return Badge$1({
1014
+ ...props,
1015
+ ref
1016
+ });
1017
+ });
1018
+ Badge.displayName = Badge$1.displayName;
1019
+ Badge.className = Badge$1.className;
1020
+ Badge.defaultProps = Badge$1.defaultProps;
990
1021
 
991
1022
  const COMPONENT_NAME$1f = 'BadgeWrapper';
992
1023
  const CLASSNAME$1e = 'lumx-badge-wrapper';
@@ -4052,2117 +4083,2163 @@ function useRestoreFocusOnClose({
4052
4083
  });
4053
4084
  }
4054
4085
 
4055
- var top = 'top';
4056
- var bottom = 'bottom';
4057
- var right = 'right';
4058
- var left = 'left';
4059
- var auto = 'auto';
4060
- var basePlacements = [top, bottom, right, left];
4061
- var start = 'start';
4062
- var end = 'end';
4063
- var clippingParents = 'clippingParents';
4064
- var viewport = 'viewport';
4065
- var popper = 'popper';
4066
- var reference = 'reference';
4067
- var variationPlacements = /*#__PURE__*/basePlacements.reduce(function (acc, placement) {
4068
- return acc.concat([placement + "-" + start, placement + "-" + end]);
4069
- }, []);
4070
- var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) {
4071
- return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
4072
- }, []); // modifiers that need to read the DOM
4073
-
4074
- var beforeRead = 'beforeRead';
4075
- var read = 'read';
4076
- var afterRead = 'afterRead'; // pure-logic modifiers
4077
-
4078
- var beforeMain = 'beforeMain';
4079
- var main = 'main';
4080
- var afterMain = 'afterMain'; // modifier with the purpose to write to the DOM (or write into a framework state)
4081
-
4082
- var beforeWrite = 'beforeWrite';
4083
- var write = 'write';
4084
- var afterWrite = 'afterWrite';
4085
- var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
4086
-
4087
- function getNodeName(element) {
4088
- return element ? (element.nodeName || '').toLowerCase() : null;
4089
- }
4090
-
4091
- /*:: import type { Window } from '../types'; */
4092
-
4093
- /*:: declare function getWindow(node: Node | Window): Window; */
4094
- function getWindow(node) {
4095
- if (node.toString() !== '[object Window]') {
4096
- var ownerDocument = node.ownerDocument;
4097
- return ownerDocument ? ownerDocument.defaultView || window : window;
4098
- }
4086
+ /**
4087
+ * Custom positioning reference element.
4088
+ * @see https://floating-ui.com/docs/virtual-elements
4089
+ */
4099
4090
 
4100
- return node;
4091
+ const sides = ['top', 'right', 'bottom', 'left'];
4092
+ const alignments = ['start', 'end'];
4093
+ const placements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []);
4094
+ const min = Math.min;
4095
+ const max = Math.max;
4096
+ const round = Math.round;
4097
+ const floor = Math.floor;
4098
+ const createCoords = v => ({
4099
+ x: v,
4100
+ y: v
4101
+ });
4102
+ const oppositeSideMap = {
4103
+ left: 'right',
4104
+ right: 'left',
4105
+ bottom: 'top',
4106
+ top: 'bottom'
4107
+ };
4108
+ const oppositeAlignmentMap = {
4109
+ start: 'end',
4110
+ end: 'start'
4111
+ };
4112
+ function clamp$1(start, value, end) {
4113
+ return max(start, min(value, end));
4101
4114
  }
4102
-
4103
- /*:: declare function isElement(node: mixed): boolean %checks(node instanceof
4104
- Element); */
4105
-
4106
- function isElement(node) {
4107
- var OwnElement = getWindow(node).Element;
4108
- return node instanceof OwnElement || node instanceof Element;
4115
+ function evaluate(value, param) {
4116
+ return typeof value === 'function' ? value(param) : value;
4109
4117
  }
4110
- /*:: declare function isHTMLElement(node: mixed): boolean %checks(node instanceof
4111
- HTMLElement); */
4112
-
4113
-
4114
- function isHTMLElement(node) {
4115
- var OwnElement = getWindow(node).HTMLElement;
4116
- return node instanceof OwnElement || node instanceof HTMLElement;
4118
+ function getSide(placement) {
4119
+ return placement.split('-')[0];
4117
4120
  }
4118
- /*:: declare function isShadowRoot(node: mixed): boolean %checks(node instanceof
4119
- ShadowRoot); */
4120
-
4121
-
4122
- function isShadowRoot(node) {
4123
- var OwnElement = getWindow(node).ShadowRoot;
4124
- return node instanceof OwnElement || node instanceof ShadowRoot;
4121
+ function getAlignment(placement) {
4122
+ return placement.split('-')[1];
4125
4123
  }
4126
-
4127
- // and applies them to the HTMLElements such as popper and arrow
4128
-
4129
- function applyStyles(_ref) {
4130
- var state = _ref.state;
4131
- Object.keys(state.elements).forEach(function (name) {
4132
- var style = state.styles[name] || {};
4133
- var attributes = state.attributes[name] || {};
4134
- var element = state.elements[name]; // arrow is optional + virtual elements
4135
-
4136
- if (!isHTMLElement(element) || !getNodeName(element)) {
4137
- return;
4138
- } // Flow doesn't support to extend this property, but it's the most
4139
- // effective way to apply styles to an HTMLElement
4140
- // $FlowFixMe
4141
-
4142
-
4143
- Object.assign(element.style, style);
4144
- Object.keys(attributes).forEach(function (name) {
4145
- var value = attributes[name];
4146
-
4147
- if (value === false) {
4148
- element.removeAttribute(name);
4149
- } else {
4150
- element.setAttribute(name, value === true ? '' : value);
4151
- }
4152
- });
4153
- });
4124
+ function getOppositeAxis(axis) {
4125
+ return axis === 'x' ? 'y' : 'x';
4154
4126
  }
4155
-
4156
- function effect$2(_ref2) {
4157
- var state = _ref2.state;
4158
- var initialStyles = {
4159
- popper: {
4160
- position: state.options.strategy,
4161
- left: '0',
4162
- top: '0',
4163
- margin: '0'
4164
- },
4165
- arrow: {
4166
- position: 'absolute'
4167
- },
4168
- reference: {}
4169
- };
4170
- Object.assign(state.elements.popper.style, initialStyles.popper);
4171
-
4172
- if (state.elements.arrow) {
4173
- Object.assign(state.elements.arrow.style, initialStyles.arrow);
4174
- }
4175
-
4176
- return function () {
4177
- Object.keys(state.elements).forEach(function (name) {
4178
- var element = state.elements[name];
4179
- var attributes = state.attributes[name] || {};
4180
- var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them
4181
-
4182
- var style = styleProperties.reduce(function (style, property) {
4183
- style[property] = '';
4184
- return style;
4185
- }, {}); // arrow is optional + virtual elements
4186
-
4187
- if (!isHTMLElement(element) || !getNodeName(element)) {
4188
- return;
4189
- } // Flow doesn't support to extend this property, but it's the most
4190
- // effective way to apply styles to an HTMLElement
4191
- // $FlowFixMe
4192
-
4193
-
4194
- Object.assign(element.style, style);
4195
- Object.keys(attributes).forEach(function (attribute) {
4196
- element.removeAttribute(attribute);
4197
- });
4198
- });
4199
- };
4200
- } // eslint-disable-next-line import/no-unused-modules
4201
-
4202
-
4203
- var applyStyles$1 = {
4204
- name: 'applyStyles',
4205
- enabled: true,
4206
- phase: 'write',
4207
- fn: applyStyles,
4208
- effect: effect$2,
4209
- requires: ['computeStyles']
4210
- };
4211
-
4212
- function getBasePlacement(placement) {
4213
- return placement.split('-')[0];
4127
+ function getAxisLength(axis) {
4128
+ return axis === 'y' ? 'height' : 'width';
4214
4129
  }
4215
-
4216
- // Returns the layout rect of an element relative to its offsetParent. Layout
4217
- // means it doesn't take into account transforms.
4218
- function getLayoutRect(element) {
4219
- return {
4220
- x: element.offsetLeft,
4221
- y: element.offsetTop,
4222
- width: element.offsetWidth,
4223
- height: element.offsetHeight
4224
- };
4130
+ const yAxisSides = /*#__PURE__*/new Set(['top', 'bottom']);
4131
+ function getSideAxis(placement) {
4132
+ return yAxisSides.has(getSide(placement)) ? 'y' : 'x';
4225
4133
  }
4226
-
4227
- function contains(parent, child) {
4228
- var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method
4229
-
4230
- if (parent.contains(child)) {
4231
- return true;
4232
- } // then fallback to custom implementation with Shadow DOM support
4233
- else if (rootNode && isShadowRoot(rootNode)) {
4234
- var next = child;
4235
-
4236
- do {
4237
- if (next && parent.isSameNode(next)) {
4238
- return true;
4239
- } // $FlowFixMe: need a better way to handle this...
4240
-
4241
-
4242
- next = next.parentNode || next.host;
4243
- } while (next);
4244
- } // Give up, the result is false
4245
-
4246
-
4247
- return false;
4134
+ function getAlignmentAxis(placement) {
4135
+ return getOppositeAxis(getSideAxis(placement));
4248
4136
  }
4249
-
4250
- function getComputedStyle(element) {
4251
- return getWindow(element).getComputedStyle(element);
4137
+ function getAlignmentSides(placement, rects, rtl) {
4138
+ if (rtl === void 0) {
4139
+ rtl = false;
4140
+ }
4141
+ const alignment = getAlignment(placement);
4142
+ const alignmentAxis = getAlignmentAxis(placement);
4143
+ const length = getAxisLength(alignmentAxis);
4144
+ let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
4145
+ if (rects.reference[length] > rects.floating[length]) {
4146
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
4147
+ }
4148
+ return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
4252
4149
  }
4253
-
4254
- function isTableElement(element) {
4255
- return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
4150
+ function getExpandedPlacements(placement) {
4151
+ const oppositePlacement = getOppositePlacement(placement);
4152
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
4256
4153
  }
4257
-
4258
- function getDocumentElement(element) {
4259
- // $FlowFixMe: assume body is always available
4260
- return ((isElement(element) ? element.ownerDocument : element.document) || window.document).documentElement;
4154
+ function getOppositeAlignmentPlacement(placement) {
4155
+ return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
4261
4156
  }
4262
-
4263
- function getParentNode(element) {
4264
- if (getNodeName(element) === 'html') {
4265
- return element;
4157
+ const lrPlacement = ['left', 'right'];
4158
+ const rlPlacement = ['right', 'left'];
4159
+ const tbPlacement = ['top', 'bottom'];
4160
+ const btPlacement = ['bottom', 'top'];
4161
+ function getSideList(side, isStart, rtl) {
4162
+ switch (side) {
4163
+ case 'top':
4164
+ case 'bottom':
4165
+ if (rtl) return isStart ? rlPlacement : lrPlacement;
4166
+ return isStart ? lrPlacement : rlPlacement;
4167
+ case 'left':
4168
+ case 'right':
4169
+ return isStart ? tbPlacement : btPlacement;
4170
+ default:
4171
+ return [];
4266
4172
  }
4267
-
4268
- return (// $FlowFixMe: this is a quicker (but less type safe) way to save quite some bytes from the bundle
4269
- element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
4270
- element.parentNode || // DOM Element detected
4271
- // $FlowFixMe: need a better way to handle this...
4272
- element.host || // ShadowRoot detected
4273
- // $FlowFixMe: HTMLElement is a Node
4274
- getDocumentElement(element) // fallback
4275
-
4276
- );
4277
4173
  }
4278
-
4279
- function getTrueOffsetParent(element) {
4280
- if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
4281
- getComputedStyle(element).position === 'fixed') {
4282
- return null;
4283
- }
4284
-
4285
- var offsetParent = element.offsetParent;
4286
-
4287
- if (offsetParent) {
4288
- var html = getDocumentElement(offsetParent);
4289
-
4290
- if (getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static' && getComputedStyle(html).position !== 'static') {
4291
- return html;
4292
- }
4293
- }
4294
-
4295
- return offsetParent;
4296
- } // `.offsetParent` reports `null` for fixed elements, while absolute elements
4297
- // return the containing block
4298
-
4299
-
4300
- function getContainingBlock(element) {
4301
- var currentNode = getParentNode(element);
4302
-
4303
- while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
4304
- var css = getComputedStyle(currentNode); // This is non-exhaustive but covers the most common CSS properties that
4305
- // create a containing block.
4306
-
4307
- if (css.transform !== 'none' || css.perspective !== 'none' || css.willChange && css.willChange !== 'auto') {
4308
- return currentNode;
4309
- } else {
4310
- currentNode = currentNode.parentNode;
4174
+ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
4175
+ const alignment = getAlignment(placement);
4176
+ let list = getSideList(getSide(placement), direction === 'start', rtl);
4177
+ if (alignment) {
4178
+ list = list.map(side => side + "-" + alignment);
4179
+ if (flipAlignment) {
4180
+ list = list.concat(list.map(getOppositeAlignmentPlacement));
4311
4181
  }
4312
4182
  }
4313
-
4314
- return null;
4315
- } // Gets the closest ancestor positioned element. Handles some edge cases,
4316
- // such as table ancestors and cross browser bugs.
4317
-
4318
-
4319
- function getOffsetParent(element) {
4320
- var window = getWindow(element);
4321
- var offsetParent = getTrueOffsetParent(element);
4322
-
4323
- while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
4324
- offsetParent = getTrueOffsetParent(offsetParent);
4325
- }
4326
-
4327
- if (offsetParent && getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static') {
4328
- return window;
4329
- }
4330
-
4331
- return offsetParent || getContainingBlock(element) || window;
4332
- }
4333
-
4334
- function getMainAxisFromPlacement(placement) {
4335
- return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
4183
+ return list;
4336
4184
  }
4337
-
4338
- function within(min, value, max) {
4339
- return Math.max(min, Math.min(value, max));
4185
+ function getOppositePlacement(placement) {
4186
+ return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
4340
4187
  }
4341
-
4342
- function getFreshSideObject() {
4188
+ function expandPaddingObject(padding) {
4343
4189
  return {
4344
4190
  top: 0,
4345
4191
  right: 0,
4346
4192
  bottom: 0,
4347
- left: 0
4193
+ left: 0,
4194
+ ...padding
4348
4195
  };
4349
4196
  }
4350
-
4351
- function mergePaddingObject(paddingObject) {
4352
- return Object.assign(Object.assign({}, getFreshSideObject()), paddingObject);
4197
+ function getPaddingObject(padding) {
4198
+ return typeof padding !== 'number' ? expandPaddingObject(padding) : {
4199
+ top: padding,
4200
+ right: padding,
4201
+ bottom: padding,
4202
+ left: padding
4203
+ };
4353
4204
  }
4354
-
4355
- function expandToHashMap(value, keys) {
4356
- return keys.reduce(function (hashMap, key) {
4357
- hashMap[key] = value;
4358
- return hashMap;
4359
- }, {});
4205
+ function rectToClientRect(rect) {
4206
+ const {
4207
+ x,
4208
+ y,
4209
+ width,
4210
+ height
4211
+ } = rect;
4212
+ return {
4213
+ width,
4214
+ height,
4215
+ top: y,
4216
+ left: x,
4217
+ right: x + width,
4218
+ bottom: y + height,
4219
+ x,
4220
+ y
4221
+ };
4360
4222
  }
4361
4223
 
4362
- function arrow(_ref) {
4363
- var _state$modifiersData$;
4364
-
4365
- var state = _ref.state,
4366
- name = _ref.name;
4367
- var arrowElement = state.elements.arrow;
4368
- var popperOffsets = state.modifiersData.popperOffsets;
4369
- var basePlacement = getBasePlacement(state.placement);
4370
- var axis = getMainAxisFromPlacement(basePlacement);
4371
- var isVertical = [left, right].indexOf(basePlacement) >= 0;
4372
- var len = isVertical ? 'height' : 'width';
4373
-
4374
- if (!arrowElement || !popperOffsets) {
4375
- return;
4224
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
4225
+ let {
4226
+ reference,
4227
+ floating
4228
+ } = _ref;
4229
+ const sideAxis = getSideAxis(placement);
4230
+ const alignmentAxis = getAlignmentAxis(placement);
4231
+ const alignLength = getAxisLength(alignmentAxis);
4232
+ const side = getSide(placement);
4233
+ const isVertical = sideAxis === 'y';
4234
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
4235
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
4236
+ const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
4237
+ let coords;
4238
+ switch (side) {
4239
+ case 'top':
4240
+ coords = {
4241
+ x: commonX,
4242
+ y: reference.y - floating.height
4243
+ };
4244
+ break;
4245
+ case 'bottom':
4246
+ coords = {
4247
+ x: commonX,
4248
+ y: reference.y + reference.height
4249
+ };
4250
+ break;
4251
+ case 'right':
4252
+ coords = {
4253
+ x: reference.x + reference.width,
4254
+ y: commonY
4255
+ };
4256
+ break;
4257
+ case 'left':
4258
+ coords = {
4259
+ x: reference.x - floating.width,
4260
+ y: commonY
4261
+ };
4262
+ break;
4263
+ default:
4264
+ coords = {
4265
+ x: reference.x,
4266
+ y: reference.y
4267
+ };
4376
4268
  }
4377
-
4378
- var paddingObject = state.modifiersData[name + "#persistent"].padding;
4379
- var arrowRect = getLayoutRect(arrowElement);
4380
- var minProp = axis === 'y' ? top : left;
4381
- var maxProp = axis === 'y' ? bottom : right;
4382
- var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
4383
- var startDiff = popperOffsets[axis] - state.rects.reference[axis];
4384
- var arrowOffsetParent = getOffsetParent(arrowElement);
4385
- var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
4386
- var centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the popper if the center point is
4387
- // outside of the popper bounds
4388
-
4389
- var min = paddingObject[minProp];
4390
- var max = clientSize - arrowRect[len] - paddingObject[maxProp];
4391
- var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
4392
- var offset = within(min, center, max); // Prevents breaking syntax highlighting...
4393
-
4394
- var axisProp = axis;
4395
- state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);
4396
- }
4397
-
4398
- function effect$1(_ref2) {
4399
- var state = _ref2.state,
4400
- options = _ref2.options,
4401
- name = _ref2.name;
4402
- var _options$element = options.element,
4403
- arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element,
4404
- _options$padding = options.padding,
4405
- padding = _options$padding === void 0 ? 0 : _options$padding;
4406
-
4407
- if (arrowElement == null) {
4408
- return;
4409
- } // CSS selector
4410
-
4411
-
4412
- if (typeof arrowElement === 'string') {
4413
- arrowElement = state.elements.popper.querySelector(arrowElement);
4414
-
4415
- if (!arrowElement) {
4416
- return;
4417
- }
4418
- }
4419
-
4420
- if (process.env.NODE_ENV !== "production") {
4421
- if (!isHTMLElement(arrowElement)) {
4422
- console.error(['Popper: "arrow" element must be an HTMLElement (not an SVGElement).', 'To use an SVG arrow, wrap it in an HTMLElement that will be used as', 'the arrow.'].join(' '));
4423
- }
4269
+ switch (getAlignment(placement)) {
4270
+ case 'start':
4271
+ coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
4272
+ break;
4273
+ case 'end':
4274
+ coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
4275
+ break;
4424
4276
  }
4277
+ return coords;
4278
+ }
4425
4279
 
4426
- if (!contains(state.elements.popper, arrowElement)) {
4427
- if (process.env.NODE_ENV !== "production") {
4428
- console.error(['Popper: "arrow" modifier\'s `element` must be a child of the popper', 'element.'].join(' '));
4429
- }
4430
-
4431
- return;
4280
+ /**
4281
+ * Resolves with an object of overflow side offsets that determine how much the
4282
+ * element is overflowing a given clipping boundary on each side.
4283
+ * - positive = overflowing the boundary by that number of pixels
4284
+ * - negative = how many pixels left before it will overflow
4285
+ * - 0 = lies flush with the boundary
4286
+ * @see https://floating-ui.com/docs/detectOverflow
4287
+ */
4288
+ async function detectOverflow(state, options) {
4289
+ var _await$platform$isEle;
4290
+ if (options === void 0) {
4291
+ options = {};
4432
4292
  }
4433
-
4434
- state.elements.arrow = arrowElement;
4435
- state.modifiersData[name + "#persistent"] = {
4436
- padding: mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements))
4293
+ const {
4294
+ x,
4295
+ y,
4296
+ platform,
4297
+ rects,
4298
+ elements,
4299
+ strategy
4300
+ } = state;
4301
+ const {
4302
+ boundary = 'clippingAncestors',
4303
+ rootBoundary = 'viewport',
4304
+ elementContext = 'floating',
4305
+ altBoundary = false,
4306
+ padding = 0
4307
+ } = evaluate(options, state);
4308
+ const paddingObject = getPaddingObject(padding);
4309
+ const altContext = elementContext === 'floating' ? 'reference' : 'floating';
4310
+ const element = elements[altBoundary ? altContext : elementContext];
4311
+ const clippingClientRect = rectToClientRect(await platform.getClippingRect({
4312
+ element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
4313
+ boundary,
4314
+ rootBoundary,
4315
+ strategy
4316
+ }));
4317
+ const rect = elementContext === 'floating' ? {
4318
+ x,
4319
+ y,
4320
+ width: rects.floating.width,
4321
+ height: rects.floating.height
4322
+ } : rects.reference;
4323
+ const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
4324
+ const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
4325
+ x: 1,
4326
+ y: 1
4327
+ } : {
4328
+ x: 1,
4329
+ y: 1
4437
4330
  };
4438
- } // eslint-disable-next-line import/no-unused-modules
4439
-
4440
-
4441
- var arrow$1 = {
4442
- name: 'arrow',
4443
- enabled: true,
4444
- phase: 'main',
4445
- fn: arrow,
4446
- effect: effect$1,
4447
- requires: ['popperOffsets'],
4448
- requiresIfExists: ['preventOverflow']
4449
- };
4450
-
4451
- var unsetSides = {
4452
- top: 'auto',
4453
- right: 'auto',
4454
- bottom: 'auto',
4455
- left: 'auto'
4456
- }; // Round the offsets to the nearest suitable subpixel based on the DPR.
4457
- // Zooming can change the DPR, but it seems to report a value that will
4458
- // cleanly divide the values into the appropriate subpixels.
4459
-
4460
- function roundOffsets(_ref) {
4461
- var x = _ref.x,
4462
- y = _ref.y;
4463
- var win = window;
4464
- var dpr = win.devicePixelRatio || 1;
4331
+ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
4332
+ elements,
4333
+ rect,
4334
+ offsetParent,
4335
+ strategy
4336
+ }) : rect);
4465
4337
  return {
4466
- x: Math.round(x * dpr) / dpr || 0,
4467
- y: Math.round(y * dpr) / dpr || 0
4338
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
4339
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
4340
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
4341
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
4468
4342
  };
4469
4343
  }
4470
4344
 
4471
- function mapToStyles(_ref2) {
4472
- var _Object$assign2;
4473
-
4474
- var popper = _ref2.popper,
4475
- popperRect = _ref2.popperRect,
4476
- placement = _ref2.placement,
4477
- offsets = _ref2.offsets,
4478
- position = _ref2.position,
4479
- gpuAcceleration = _ref2.gpuAcceleration,
4480
- adaptive = _ref2.adaptive;
4481
-
4482
- var _roundOffsets = roundOffsets(offsets),
4483
- x = _roundOffsets.x,
4484
- y = _roundOffsets.y;
4485
-
4486
- var hasX = offsets.hasOwnProperty('x');
4487
- var hasY = offsets.hasOwnProperty('y');
4488
- var sideX = left;
4489
- var sideY = top;
4490
- var win = window;
4491
-
4492
- if (adaptive) {
4493
- var offsetParent = getOffsetParent(popper);
4494
-
4495
- if (offsetParent === getWindow(popper)) {
4496
- offsetParent = getDocumentElement(popper);
4497
- } // $FlowFixMe: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it
4498
-
4499
- /*:: offsetParent = (offsetParent: Element); */
4500
-
4501
-
4502
- if (placement === top) {
4503
- sideY = bottom;
4504
- y -= offsetParent.clientHeight - popperRect.height;
4505
- y *= gpuAcceleration ? 1 : -1;
4506
- }
4507
-
4508
- if (placement === left) {
4509
- sideX = right;
4510
- x -= offsetParent.clientWidth - popperRect.width;
4511
- x *= gpuAcceleration ? 1 : -1;
4345
+ /**
4346
+ * Computes the `x` and `y` coordinates that will place the floating element
4347
+ * next to a given reference element.
4348
+ *
4349
+ * This export does not have any `platform` interface logic. You will need to
4350
+ * write one for the platform you are using Floating UI with.
4351
+ */
4352
+ const computePosition$1 = async (reference, floating, config) => {
4353
+ const {
4354
+ placement = 'bottom',
4355
+ strategy = 'absolute',
4356
+ middleware = [],
4357
+ platform
4358
+ } = config;
4359
+ const validMiddleware = middleware.filter(Boolean);
4360
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
4361
+ let rects = await platform.getElementRects({
4362
+ reference,
4363
+ floating,
4364
+ strategy
4365
+ });
4366
+ let {
4367
+ x,
4368
+ y
4369
+ } = computeCoordsFromPlacement(rects, placement, rtl);
4370
+ let statefulPlacement = placement;
4371
+ let middlewareData = {};
4372
+ let resetCount = 0;
4373
+ for (let i = 0; i < validMiddleware.length; i++) {
4374
+ var _platform$detectOverf;
4375
+ const {
4376
+ name,
4377
+ fn
4378
+ } = validMiddleware[i];
4379
+ const {
4380
+ x: nextX,
4381
+ y: nextY,
4382
+ data,
4383
+ reset
4384
+ } = await fn({
4385
+ x,
4386
+ y,
4387
+ initialPlacement: placement,
4388
+ placement: statefulPlacement,
4389
+ strategy,
4390
+ middlewareData,
4391
+ rects,
4392
+ platform: {
4393
+ ...platform,
4394
+ detectOverflow: (_platform$detectOverf = platform.detectOverflow) != null ? _platform$detectOverf : detectOverflow
4395
+ },
4396
+ elements: {
4397
+ reference,
4398
+ floating
4399
+ }
4400
+ });
4401
+ x = nextX != null ? nextX : x;
4402
+ y = nextY != null ? nextY : y;
4403
+ middlewareData = {
4404
+ ...middlewareData,
4405
+ [name]: {
4406
+ ...middlewareData[name],
4407
+ ...data
4408
+ }
4409
+ };
4410
+ if (reset && resetCount <= 50) {
4411
+ resetCount++;
4412
+ if (typeof reset === 'object') {
4413
+ if (reset.placement) {
4414
+ statefulPlacement = reset.placement;
4415
+ }
4416
+ if (reset.rects) {
4417
+ rects = reset.rects === true ? await platform.getElementRects({
4418
+ reference,
4419
+ floating,
4420
+ strategy
4421
+ }) : reset.rects;
4422
+ }
4423
+ ({
4424
+ x,
4425
+ y
4426
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
4427
+ }
4428
+ i = -1;
4512
4429
  }
4513
4430
  }
4431
+ return {
4432
+ x,
4433
+ y,
4434
+ placement: statefulPlacement,
4435
+ strategy,
4436
+ middlewareData
4437
+ };
4438
+ };
4514
4439
 
4515
- var commonStyles = Object.assign({
4516
- position: position
4517
- }, adaptive && unsetSides);
4518
-
4519
- if (gpuAcceleration) {
4520
- var _Object$assign;
4521
-
4522
- return Object.assign(Object.assign({}, commonStyles), {}, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) < 2 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
4440
+ /**
4441
+ * Provides data to position an inner element of the floating element so that it
4442
+ * appears centered to the reference element.
4443
+ * @see https://floating-ui.com/docs/arrow
4444
+ */
4445
+ const arrow$3 = options => ({
4446
+ name: 'arrow',
4447
+ options,
4448
+ async fn(state) {
4449
+ const {
4450
+ x,
4451
+ y,
4452
+ placement,
4453
+ rects,
4454
+ platform,
4455
+ elements,
4456
+ middlewareData
4457
+ } = state;
4458
+ // Since `element` is required, we don't Partial<> the type.
4459
+ const {
4460
+ element,
4461
+ padding = 0
4462
+ } = evaluate(options, state) || {};
4463
+ if (element == null) {
4464
+ return {};
4465
+ }
4466
+ const paddingObject = getPaddingObject(padding);
4467
+ const coords = {
4468
+ x,
4469
+ y
4470
+ };
4471
+ const axis = getAlignmentAxis(placement);
4472
+ const length = getAxisLength(axis);
4473
+ const arrowDimensions = await platform.getDimensions(element);
4474
+ const isYAxis = axis === 'y';
4475
+ const minProp = isYAxis ? 'top' : 'left';
4476
+ const maxProp = isYAxis ? 'bottom' : 'right';
4477
+ const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
4478
+ const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
4479
+ const startDiff = coords[axis] - rects.reference[axis];
4480
+ const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
4481
+ let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
4482
+
4483
+ // DOM platform can return `window` as the `offsetParent`.
4484
+ if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
4485
+ clientSize = elements.floating[clientProp] || rects.floating[length];
4486
+ }
4487
+ const centerToReference = endDiff / 2 - startDiff / 2;
4488
+
4489
+ // If the padding is large enough that it causes the arrow to no longer be
4490
+ // centered, modify the padding so that it is centered.
4491
+ const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
4492
+ const minPadding = min(paddingObject[minProp], largestPossiblePadding);
4493
+ const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
4494
+
4495
+ // Make sure the arrow doesn't overflow the floating element if the center
4496
+ // point is outside the floating element's bounds.
4497
+ const min$1 = minPadding;
4498
+ const max = clientSize - arrowDimensions[length] - maxPadding;
4499
+ const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
4500
+ const offset = clamp$1(min$1, center, max);
4501
+
4502
+ // If the reference is small enough that the arrow's padding causes it to
4503
+ // to point to nothing for an aligned placement, adjust the offset of the
4504
+ // floating element itself. To ensure `shift()` continues to take action,
4505
+ // a single reset is performed when this is true.
4506
+ const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
4507
+ const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
4508
+ return {
4509
+ [axis]: coords[axis] + alignmentOffset,
4510
+ data: {
4511
+ [axis]: offset,
4512
+ centerOffset: center - offset - alignmentOffset,
4513
+ ...(shouldAddOffset && {
4514
+ alignmentOffset
4515
+ })
4516
+ },
4517
+ reset: shouldAddOffset
4518
+ };
4523
4519
  }
4520
+ });
4524
4521
 
4525
- return Object.assign(Object.assign({}, commonStyles), {}, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
4526
- }
4527
-
4528
- function computeStyles(_ref3) {
4529
- var state = _ref3.state,
4530
- options = _ref3.options;
4531
- var _options$gpuAccelerat = options.gpuAcceleration,
4532
- gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
4533
- _options$adaptive = options.adaptive,
4534
- adaptive = _options$adaptive === void 0 ? true : _options$adaptive;
4535
-
4536
- if (process.env.NODE_ENV !== "production") {
4537
- var transitionProperty = getComputedStyle(state.elements.popper).transitionProperty || '';
4538
-
4539
- if (adaptive && ['transform', 'top', 'right', 'bottom', 'left'].some(function (property) {
4540
- return transitionProperty.indexOf(property) >= 0;
4541
- })) {
4542
- console.warn(['Popper: Detected CSS transitions on at least one of the following', 'CSS properties: "transform", "top", "right", "bottom", "left".', '\n\n', 'Disable the "computeStyles" modifier\'s `adaptive` option to allow', 'for smooth transitions, or remove these properties from the CSS', 'transition declaration on the popper element if only transitioning', 'opacity or background-color for example.', '\n\n', 'We recommend using the popper element as a wrapper around an inner', 'element that can have any CSS property transitioned for animations.'].join(' '));
4522
+ function getPlacementList(alignment, autoAlignment, allowedPlacements) {
4523
+ const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment(placement) !== alignment)] : allowedPlacements.filter(placement => getSide(placement) === placement);
4524
+ return allowedPlacementsSortedByAlignment.filter(placement => {
4525
+ if (alignment) {
4526
+ return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);
4543
4527
  }
4528
+ return true;
4529
+ });
4530
+ }
4531
+ /**
4532
+ * Optimizes the visibility of the floating element by choosing the placement
4533
+ * that has the most space available automatically, without needing to specify a
4534
+ * preferred placement. Alternative to `flip`.
4535
+ * @see https://floating-ui.com/docs/autoPlacement
4536
+ */
4537
+ const autoPlacement$2 = function (options) {
4538
+ if (options === void 0) {
4539
+ options = {};
4544
4540
  }
4541
+ return {
4542
+ name: 'autoPlacement',
4543
+ options,
4544
+ async fn(state) {
4545
+ var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE;
4546
+ const {
4547
+ rects,
4548
+ middlewareData,
4549
+ placement,
4550
+ platform,
4551
+ elements
4552
+ } = state;
4553
+ const {
4554
+ crossAxis = false,
4555
+ alignment,
4556
+ allowedPlacements = placements,
4557
+ autoAlignment = true,
4558
+ ...detectOverflowOptions
4559
+ } = evaluate(options, state);
4560
+ const placements$1 = alignment !== undefined || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;
4561
+ const overflow = await platform.detectOverflow(state, detectOverflowOptions);
4562
+ const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;
4563
+ const currentPlacement = placements$1[currentIndex];
4564
+ if (currentPlacement == null) {
4565
+ return {};
4566
+ }
4567
+ const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
4545
4568
 
4546
- var commonStyles = {
4547
- placement: getBasePlacement(state.placement),
4548
- popper: state.elements.popper,
4549
- popperRect: state.rects.popper,
4550
- gpuAcceleration: gpuAcceleration
4569
+ // Make `computeCoords` start from the right place.
4570
+ if (placement !== currentPlacement) {
4571
+ return {
4572
+ reset: {
4573
+ placement: placements$1[0]
4574
+ }
4575
+ };
4576
+ }
4577
+ const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]];
4578
+ const allOverflows = [...(((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || []), {
4579
+ placement: currentPlacement,
4580
+ overflows: currentOverflows
4581
+ }];
4582
+ const nextPlacement = placements$1[currentIndex + 1];
4583
+
4584
+ // There are more placements to check.
4585
+ if (nextPlacement) {
4586
+ return {
4587
+ data: {
4588
+ index: currentIndex + 1,
4589
+ overflows: allOverflows
4590
+ },
4591
+ reset: {
4592
+ placement: nextPlacement
4593
+ }
4594
+ };
4595
+ }
4596
+ const placementsSortedByMostSpace = allOverflows.map(d => {
4597
+ const alignment = getAlignment(d.placement);
4598
+ return [d.placement, alignment && crossAxis ?
4599
+ // Check along the mainAxis and main crossAxis side.
4600
+ d.overflows.slice(0, 2).reduce((acc, v) => acc + v, 0) :
4601
+ // Check only the mainAxis.
4602
+ d.overflows[0], d.overflows];
4603
+ }).sort((a, b) => a[1] - b[1]);
4604
+ const placementsThatFitOnEachSide = placementsSortedByMostSpace.filter(d => d[2].slice(0,
4605
+ // Aligned placements should not check their opposite crossAxis
4606
+ // side.
4607
+ getAlignment(d[0]) ? 2 : 3).every(v => v <= 0));
4608
+ const resetPlacement = ((_placementsThatFitOnE = placementsThatFitOnEachSide[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0];
4609
+ if (resetPlacement !== placement) {
4610
+ return {
4611
+ data: {
4612
+ index: currentIndex + 1,
4613
+ overflows: allOverflows
4614
+ },
4615
+ reset: {
4616
+ placement: resetPlacement
4617
+ }
4618
+ };
4619
+ }
4620
+ return {};
4621
+ }
4551
4622
  };
4623
+ };
4552
4624
 
4553
- if (state.modifiersData.popperOffsets != null) {
4554
- state.styles.popper = Object.assign(Object.assign({}, state.styles.popper), mapToStyles(Object.assign(Object.assign({}, commonStyles), {}, {
4555
- offsets: state.modifiersData.popperOffsets,
4556
- position: state.options.strategy,
4557
- adaptive: adaptive
4558
- })));
4559
- }
4560
-
4561
- if (state.modifiersData.arrow != null) {
4562
- state.styles.arrow = Object.assign(Object.assign({}, state.styles.arrow), mapToStyles(Object.assign(Object.assign({}, commonStyles), {}, {
4563
- offsets: state.modifiersData.arrow,
4564
- position: 'absolute',
4565
- adaptive: false
4566
- })));
4625
+ /**
4626
+ * Optimizes the visibility of the floating element by flipping the `placement`
4627
+ * in order to keep it in view when the preferred placement(s) will overflow the
4628
+ * clipping boundary. Alternative to `autoPlacement`.
4629
+ * @see https://floating-ui.com/docs/flip
4630
+ */
4631
+ const flip$2 = function (options) {
4632
+ if (options === void 0) {
4633
+ options = {};
4567
4634
  }
4635
+ return {
4636
+ name: 'flip',
4637
+ options,
4638
+ async fn(state) {
4639
+ var _middlewareData$arrow, _middlewareData$flip;
4640
+ const {
4641
+ placement,
4642
+ middlewareData,
4643
+ rects,
4644
+ initialPlacement,
4645
+ platform,
4646
+ elements
4647
+ } = state;
4648
+ const {
4649
+ mainAxis: checkMainAxis = true,
4650
+ crossAxis: checkCrossAxis = true,
4651
+ fallbackPlacements: specifiedFallbackPlacements,
4652
+ fallbackStrategy = 'bestFit',
4653
+ fallbackAxisSideDirection = 'none',
4654
+ flipAlignment = true,
4655
+ ...detectOverflowOptions
4656
+ } = evaluate(options, state);
4657
+
4658
+ // If a reset by the arrow was caused due to an alignment offset being
4659
+ // added, we should skip any logic now since `flip()` has already done its
4660
+ // work.
4661
+ // https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
4662
+ if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
4663
+ return {};
4664
+ }
4665
+ const side = getSide(placement);
4666
+ const initialSideAxis = getSideAxis(initialPlacement);
4667
+ const isBasePlacement = getSide(initialPlacement) === initialPlacement;
4668
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
4669
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
4670
+ const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';
4671
+ if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
4672
+ fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
4673
+ }
4674
+ const placements = [initialPlacement, ...fallbackPlacements];
4675
+ const overflow = await platform.detectOverflow(state, detectOverflowOptions);
4676
+ const overflows = [];
4677
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
4678
+ if (checkMainAxis) {
4679
+ overflows.push(overflow[side]);
4680
+ }
4681
+ if (checkCrossAxis) {
4682
+ const sides = getAlignmentSides(placement, rects, rtl);
4683
+ overflows.push(overflow[sides[0]], overflow[sides[1]]);
4684
+ }
4685
+ overflowsData = [...overflowsData, {
4686
+ placement,
4687
+ overflows
4688
+ }];
4689
+
4690
+ // One or more sides is overflowing.
4691
+ if (!overflows.every(side => side <= 0)) {
4692
+ var _middlewareData$flip2, _overflowsData$filter;
4693
+ const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
4694
+ const nextPlacement = placements[nextIndex];
4695
+ if (nextPlacement) {
4696
+ const ignoreCrossAxisOverflow = checkCrossAxis === 'alignment' ? initialSideAxis !== getSideAxis(nextPlacement) : false;
4697
+ if (!ignoreCrossAxisOverflow ||
4698
+ // We leave the current main axis only if every placement on that axis
4699
+ // overflows the main axis.
4700
+ overflowsData.every(d => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
4701
+ // Try next placement and re-run the lifecycle.
4702
+ return {
4703
+ data: {
4704
+ index: nextIndex,
4705
+ overflows: overflowsData
4706
+ },
4707
+ reset: {
4708
+ placement: nextPlacement
4709
+ }
4710
+ };
4711
+ }
4712
+ }
4568
4713
 
4569
- state.attributes.popper = Object.assign(Object.assign({}, state.attributes.popper), {}, {
4570
- 'data-popper-placement': state.placement
4571
- });
4572
- } // eslint-disable-next-line import/no-unused-modules
4573
-
4574
-
4575
- var computeStyles$1 = {
4576
- name: 'computeStyles',
4577
- enabled: true,
4578
- phase: 'beforeWrite',
4579
- fn: computeStyles,
4580
- data: {}
4714
+ // First, find the candidates that fit on the mainAxis side of overflow,
4715
+ // then find the placement that fits the best on the main crossAxis side.
4716
+ let resetPlacement = (_overflowsData$filter = overflowsData.filter(d => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
4717
+
4718
+ // Otherwise fallback.
4719
+ if (!resetPlacement) {
4720
+ switch (fallbackStrategy) {
4721
+ case 'bestFit':
4722
+ {
4723
+ var _overflowsData$filter2;
4724
+ const placement = (_overflowsData$filter2 = overflowsData.filter(d => {
4725
+ if (hasFallbackAxisSideDirection) {
4726
+ const currentSideAxis = getSideAxis(d.placement);
4727
+ return currentSideAxis === initialSideAxis ||
4728
+ // Create a bias to the `y` side axis due to horizontal
4729
+ // reading directions favoring greater width.
4730
+ currentSideAxis === 'y';
4731
+ }
4732
+ return true;
4733
+ }).map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
4734
+ if (placement) {
4735
+ resetPlacement = placement;
4736
+ }
4737
+ break;
4738
+ }
4739
+ case 'initialPlacement':
4740
+ resetPlacement = initialPlacement;
4741
+ break;
4742
+ }
4743
+ }
4744
+ if (placement !== resetPlacement) {
4745
+ return {
4746
+ reset: {
4747
+ placement: resetPlacement
4748
+ }
4749
+ };
4750
+ }
4751
+ }
4752
+ return {};
4753
+ }
4754
+ };
4581
4755
  };
4582
4756
 
4583
- var passive = {
4584
- passive: true
4585
- };
4757
+ const originSides = /*#__PURE__*/new Set(['left', 'top']);
4586
4758
 
4587
- function effect(_ref) {
4588
- var state = _ref.state,
4589
- instance = _ref.instance,
4590
- options = _ref.options;
4591
- var _options$scroll = options.scroll,
4592
- scroll = _options$scroll === void 0 ? true : _options$scroll,
4593
- _options$resize = options.resize,
4594
- resize = _options$resize === void 0 ? true : _options$resize;
4595
- var window = getWindow(state.elements.popper);
4596
- var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
4759
+ // For type backwards-compatibility, the `OffsetOptions` type was also
4760
+ // Derivable.
4597
4761
 
4598
- if (scroll) {
4599
- scrollParents.forEach(function (scrollParent) {
4600
- scrollParent.addEventListener('scroll', instance.update, passive);
4601
- });
4762
+ async function convertValueToCoords(state, options) {
4763
+ const {
4764
+ placement,
4765
+ platform,
4766
+ elements
4767
+ } = state;
4768
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
4769
+ const side = getSide(placement);
4770
+ const alignment = getAlignment(placement);
4771
+ const isVertical = getSideAxis(placement) === 'y';
4772
+ const mainAxisMulti = originSides.has(side) ? -1 : 1;
4773
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
4774
+ const rawValue = evaluate(options, state);
4775
+
4776
+ // eslint-disable-next-line prefer-const
4777
+ let {
4778
+ mainAxis,
4779
+ crossAxis,
4780
+ alignmentAxis
4781
+ } = typeof rawValue === 'number' ? {
4782
+ mainAxis: rawValue,
4783
+ crossAxis: 0,
4784
+ alignmentAxis: null
4785
+ } : {
4786
+ mainAxis: rawValue.mainAxis || 0,
4787
+ crossAxis: rawValue.crossAxis || 0,
4788
+ alignmentAxis: rawValue.alignmentAxis
4789
+ };
4790
+ if (alignment && typeof alignmentAxis === 'number') {
4791
+ crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
4602
4792
  }
4793
+ return isVertical ? {
4794
+ x: crossAxis * crossAxisMulti,
4795
+ y: mainAxis * mainAxisMulti
4796
+ } : {
4797
+ x: mainAxis * mainAxisMulti,
4798
+ y: crossAxis * crossAxisMulti
4799
+ };
4800
+ }
4603
4801
 
4604
- if (resize) {
4605
- window.addEventListener('resize', instance.update, passive);
4802
+ /**
4803
+ * Modifies the placement by translating the floating element along the
4804
+ * specified axes.
4805
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
4806
+ * object may be passed.
4807
+ * @see https://floating-ui.com/docs/offset
4808
+ */
4809
+ const offset$2 = function (options) {
4810
+ if (options === void 0) {
4811
+ options = 0;
4606
4812
  }
4813
+ return {
4814
+ name: 'offset',
4815
+ options,
4816
+ async fn(state) {
4817
+ var _middlewareData$offse, _middlewareData$arrow;
4818
+ const {
4819
+ x,
4820
+ y,
4821
+ placement,
4822
+ middlewareData
4823
+ } = state;
4824
+ const diffCoords = await convertValueToCoords(state, options);
4825
+
4826
+ // If the placement is the same and the arrow caused an alignment offset
4827
+ // then we don't need to change the positioning coordinates.
4828
+ if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
4829
+ return {};
4830
+ }
4831
+ return {
4832
+ x: x + diffCoords.x,
4833
+ y: y + diffCoords.y,
4834
+ data: {
4835
+ ...diffCoords,
4836
+ placement
4837
+ }
4838
+ };
4839
+ }
4840
+ };
4841
+ };
4607
4842
 
4608
- return function () {
4609
- if (scroll) {
4610
- scrollParents.forEach(function (scrollParent) {
4611
- scrollParent.removeEventListener('scroll', instance.update, passive);
4843
+ /**
4844
+ * Optimizes the visibility of the floating element by shifting it in order to
4845
+ * keep it in view when it will overflow the clipping boundary.
4846
+ * @see https://floating-ui.com/docs/shift
4847
+ */
4848
+ const shift$2 = function (options) {
4849
+ if (options === void 0) {
4850
+ options = {};
4851
+ }
4852
+ return {
4853
+ name: 'shift',
4854
+ options,
4855
+ async fn(state) {
4856
+ const {
4857
+ x,
4858
+ y,
4859
+ placement,
4860
+ platform
4861
+ } = state;
4862
+ const {
4863
+ mainAxis: checkMainAxis = true,
4864
+ crossAxis: checkCrossAxis = false,
4865
+ limiter = {
4866
+ fn: _ref => {
4867
+ let {
4868
+ x,
4869
+ y
4870
+ } = _ref;
4871
+ return {
4872
+ x,
4873
+ y
4874
+ };
4875
+ }
4876
+ },
4877
+ ...detectOverflowOptions
4878
+ } = evaluate(options, state);
4879
+ const coords = {
4880
+ x,
4881
+ y
4882
+ };
4883
+ const overflow = await platform.detectOverflow(state, detectOverflowOptions);
4884
+ const crossAxis = getSideAxis(getSide(placement));
4885
+ const mainAxis = getOppositeAxis(crossAxis);
4886
+ let mainAxisCoord = coords[mainAxis];
4887
+ let crossAxisCoord = coords[crossAxis];
4888
+ if (checkMainAxis) {
4889
+ const minSide = mainAxis === 'y' ? 'top' : 'left';
4890
+ const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
4891
+ const min = mainAxisCoord + overflow[minSide];
4892
+ const max = mainAxisCoord - overflow[maxSide];
4893
+ mainAxisCoord = clamp$1(min, mainAxisCoord, max);
4894
+ }
4895
+ if (checkCrossAxis) {
4896
+ const minSide = crossAxis === 'y' ? 'top' : 'left';
4897
+ const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
4898
+ const min = crossAxisCoord + overflow[minSide];
4899
+ const max = crossAxisCoord - overflow[maxSide];
4900
+ crossAxisCoord = clamp$1(min, crossAxisCoord, max);
4901
+ }
4902
+ const limitedCoords = limiter.fn({
4903
+ ...state,
4904
+ [mainAxis]: mainAxisCoord,
4905
+ [crossAxis]: crossAxisCoord
4612
4906
  });
4907
+ return {
4908
+ ...limitedCoords,
4909
+ data: {
4910
+ x: limitedCoords.x - x,
4911
+ y: limitedCoords.y - y,
4912
+ enabled: {
4913
+ [mainAxis]: checkMainAxis,
4914
+ [crossAxis]: checkCrossAxis
4915
+ }
4916
+ }
4917
+ };
4613
4918
  }
4919
+ };
4920
+ };
4614
4921
 
4615
- if (resize) {
4616
- window.removeEventListener('resize', instance.update, passive);
4922
+ /**
4923
+ * Provides data that allows you to change the size of the floating element —
4924
+ * for instance, prevent it from overflowing the clipping boundary or match the
4925
+ * width of the reference element.
4926
+ * @see https://floating-ui.com/docs/size
4927
+ */
4928
+ const size$2 = function (options) {
4929
+ if (options === void 0) {
4930
+ options = {};
4931
+ }
4932
+ return {
4933
+ name: 'size',
4934
+ options,
4935
+ async fn(state) {
4936
+ var _state$middlewareData, _state$middlewareData2;
4937
+ const {
4938
+ placement,
4939
+ rects,
4940
+ platform,
4941
+ elements
4942
+ } = state;
4943
+ const {
4944
+ apply = () => {},
4945
+ ...detectOverflowOptions
4946
+ } = evaluate(options, state);
4947
+ const overflow = await platform.detectOverflow(state, detectOverflowOptions);
4948
+ const side = getSide(placement);
4949
+ const alignment = getAlignment(placement);
4950
+ const isYAxis = getSideAxis(placement) === 'y';
4951
+ const {
4952
+ width,
4953
+ height
4954
+ } = rects.floating;
4955
+ let heightSide;
4956
+ let widthSide;
4957
+ if (side === 'top' || side === 'bottom') {
4958
+ heightSide = side;
4959
+ widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right';
4960
+ } else {
4961
+ widthSide = side;
4962
+ heightSide = alignment === 'end' ? 'top' : 'bottom';
4963
+ }
4964
+ const maximumClippingHeight = height - overflow.top - overflow.bottom;
4965
+ const maximumClippingWidth = width - overflow.left - overflow.right;
4966
+ const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
4967
+ const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
4968
+ const noShift = !state.middlewareData.shift;
4969
+ let availableHeight = overflowAvailableHeight;
4970
+ let availableWidth = overflowAvailableWidth;
4971
+ if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
4972
+ availableWidth = maximumClippingWidth;
4973
+ }
4974
+ if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
4975
+ availableHeight = maximumClippingHeight;
4976
+ }
4977
+ if (noShift && !alignment) {
4978
+ const xMin = max(overflow.left, 0);
4979
+ const xMax = max(overflow.right, 0);
4980
+ const yMin = max(overflow.top, 0);
4981
+ const yMax = max(overflow.bottom, 0);
4982
+ if (isYAxis) {
4983
+ availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
4984
+ } else {
4985
+ availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
4986
+ }
4987
+ }
4988
+ await apply({
4989
+ ...state,
4990
+ availableWidth,
4991
+ availableHeight
4992
+ });
4993
+ const nextDimensions = await platform.getDimensions(elements.floating);
4994
+ if (width !== nextDimensions.width || height !== nextDimensions.height) {
4995
+ return {
4996
+ reset: {
4997
+ rects: true
4998
+ }
4999
+ };
5000
+ }
5001
+ return {};
4617
5002
  }
4618
5003
  };
4619
- } // eslint-disable-next-line import/no-unused-modules
4620
-
4621
-
4622
- var eventListeners = {
4623
- name: 'eventListeners',
4624
- enabled: true,
4625
- phase: 'write',
4626
- fn: function fn() {},
4627
- effect: effect,
4628
- data: {}
4629
5004
  };
4630
5005
 
4631
- var hash$1 = {
4632
- left: 'right',
4633
- right: 'left',
4634
- bottom: 'top',
4635
- top: 'bottom'
4636
- };
4637
- function getOppositePlacement(placement) {
4638
- return placement.replace(/left|right|bottom|top/g, function (matched) {
4639
- return hash$1[matched];
4640
- });
5006
+ function hasWindow() {
5007
+ return typeof window !== 'undefined';
4641
5008
  }
4642
-
4643
- var hash = {
4644
- start: 'end',
4645
- end: 'start'
4646
- };
4647
- function getOppositeVariationPlacement(placement) {
4648
- return placement.replace(/start|end/g, function (matched) {
4649
- return hash[matched];
4650
- });
5009
+ function getNodeName(node) {
5010
+ if (isNode(node)) {
5011
+ return (node.nodeName || '').toLowerCase();
5012
+ }
5013
+ // Mocked nodes in testing environments may not be instances of Node. By
5014
+ // returning `#document` an infinite loop won't occur.
5015
+ // https://github.com/floating-ui/floating-ui/issues/2317
5016
+ return '#document';
4651
5017
  }
4652
-
4653
- function getBoundingClientRect(element) {
4654
- var rect = element.getBoundingClientRect();
4655
- return {
4656
- width: rect.width,
4657
- height: rect.height,
4658
- top: rect.top,
4659
- right: rect.right,
4660
- bottom: rect.bottom,
4661
- left: rect.left,
4662
- x: rect.left,
4663
- y: rect.top
4664
- };
5018
+ function getWindow(node) {
5019
+ var _node$ownerDocument;
5020
+ return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
4665
5021
  }
4666
-
4667
- function getWindowScroll(node) {
4668
- var win = getWindow(node);
4669
- var scrollLeft = win.pageXOffset;
4670
- var scrollTop = win.pageYOffset;
4671
- return {
4672
- scrollLeft: scrollLeft,
4673
- scrollTop: scrollTop
4674
- };
5022
+ function getDocumentElement(node) {
5023
+ var _ref;
5024
+ return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
4675
5025
  }
4676
-
4677
- function getWindowScrollBarX(element) {
4678
- // If <html> has a CSS width greater than the viewport, then this will be
4679
- // incorrect for RTL.
4680
- // Popper 1 is broken in this case and never had a bug report so let's assume
4681
- // it's not an issue. I don't think anyone ever specifies width on <html>
4682
- // anyway.
4683
- // Browsers where the left scrollbar doesn't cause an issue report `0` for
4684
- // this (e.g. Edge 2019, IE11, Safari)
4685
- return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
4686
- }
4687
-
4688
- function getViewportRect(element) {
4689
- var win = getWindow(element);
4690
- var html = getDocumentElement(element);
4691
- var visualViewport = win.visualViewport;
4692
- var width = html.clientWidth;
4693
- var height = html.clientHeight;
4694
- var x = 0;
4695
- var y = 0; // NB: This isn't supported on iOS <= 12. If the keyboard is open, the popper
4696
- // can be obscured underneath it.
4697
- // Also, `html.clientHeight` adds the bottom bar height in Safari iOS, even
4698
- // if it isn't open, so if this isn't available, the popper will be detected
4699
- // to overflow the bottom of the screen too early.
4700
-
4701
- if (visualViewport) {
4702
- width = visualViewport.width;
4703
- height = visualViewport.height; // Uses Layout Viewport (like Chrome; Safari does not currently)
4704
- // In Chrome, it returns a value very close to 0 (+/-) but contains rounding
4705
- // errors due to floating point numbers, so we need to check precision.
4706
- // Safari returns a number <= 0, usually < -1 when pinch-zoomed
4707
- // Feature detection fails in mobile emulation mode in Chrome.
4708
- // Math.abs(win.innerWidth / visualViewport.scale - visualViewport.width) <
4709
- // 0.001
4710
- // Fallback here: "Not Safari" userAgent
4711
-
4712
- if (!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
4713
- x = visualViewport.offsetLeft;
4714
- y = visualViewport.offsetTop;
5026
+ function isNode(value) {
5027
+ if (!hasWindow()) {
5028
+ return false;
5029
+ }
5030
+ return value instanceof Node || value instanceof getWindow(value).Node;
5031
+ }
5032
+ function isElement(value) {
5033
+ if (!hasWindow()) {
5034
+ return false;
5035
+ }
5036
+ return value instanceof Element || value instanceof getWindow(value).Element;
5037
+ }
5038
+ function isHTMLElement(value) {
5039
+ if (!hasWindow()) {
5040
+ return false;
5041
+ }
5042
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
5043
+ }
5044
+ function isShadowRoot(value) {
5045
+ if (!hasWindow() || typeof ShadowRoot === 'undefined') {
5046
+ return false;
5047
+ }
5048
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
5049
+ }
5050
+ const invalidOverflowDisplayValues = /*#__PURE__*/new Set(['inline', 'contents']);
5051
+ function isOverflowElement(element) {
5052
+ const {
5053
+ overflow,
5054
+ overflowX,
5055
+ overflowY,
5056
+ display
5057
+ } = getComputedStyle$1(element);
5058
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
5059
+ }
5060
+ const tableElements = /*#__PURE__*/new Set(['table', 'td', 'th']);
5061
+ function isTableElement(element) {
5062
+ return tableElements.has(getNodeName(element));
5063
+ }
5064
+ const topLayerSelectors = [':popover-open', ':modal'];
5065
+ function isTopLayer(element) {
5066
+ return topLayerSelectors.some(selector => {
5067
+ try {
5068
+ return element.matches(selector);
5069
+ } catch (_e) {
5070
+ return false;
4715
5071
  }
5072
+ });
5073
+ }
5074
+ const transformProperties = ['transform', 'translate', 'scale', 'rotate', 'perspective'];
5075
+ const willChangeValues = ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'];
5076
+ const containValues = ['paint', 'layout', 'strict', 'content'];
5077
+ function isContainingBlock(elementOrCss) {
5078
+ const webkit = isWebKit();
5079
+ const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
5080
+
5081
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
5082
+ // https://drafts.csswg.org/css-transforms-2/#individual-transforms
5083
+ return transformProperties.some(value => css[value] ? css[value] !== 'none' : false) || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || willChangeValues.some(value => (css.willChange || '').includes(value)) || containValues.some(value => (css.contain || '').includes(value));
5084
+ }
5085
+ function getContainingBlock(element) {
5086
+ let currentNode = getParentNode(element);
5087
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
5088
+ if (isContainingBlock(currentNode)) {
5089
+ return currentNode;
5090
+ } else if (isTopLayer(currentNode)) {
5091
+ return null;
5092
+ }
5093
+ currentNode = getParentNode(currentNode);
4716
5094
  }
4717
-
4718
- return {
4719
- width: width,
4720
- height: height,
4721
- x: x + getWindowScrollBarX(element),
4722
- y: y
4723
- };
5095
+ return null;
4724
5096
  }
4725
-
4726
- // of the `<html>` and `<body>` rect bounds if horizontally scrollable
4727
-
4728
- function getDocumentRect(element) {
4729
- var html = getDocumentElement(element);
4730
- var winScroll = getWindowScroll(element);
4731
- var body = element.ownerDocument.body;
4732
- var width = Math.max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
4733
- var height = Math.max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
4734
- var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
4735
- var y = -winScroll.scrollTop;
4736
-
4737
- if (getComputedStyle(body || html).direction === 'rtl') {
4738
- x += Math.max(html.clientWidth, body ? body.clientWidth : 0) - width;
5097
+ function isWebKit() {
5098
+ if (typeof CSS === 'undefined' || !CSS.supports) return false;
5099
+ return CSS.supports('-webkit-backdrop-filter', 'none');
5100
+ }
5101
+ const lastTraversableNodeNames = /*#__PURE__*/new Set(['html', 'body', '#document']);
5102
+ function isLastTraversableNode(node) {
5103
+ return lastTraversableNodeNames.has(getNodeName(node));
5104
+ }
5105
+ function getComputedStyle$1(element) {
5106
+ return getWindow(element).getComputedStyle(element);
5107
+ }
5108
+ function getNodeScroll(element) {
5109
+ if (isElement(element)) {
5110
+ return {
5111
+ scrollLeft: element.scrollLeft,
5112
+ scrollTop: element.scrollTop
5113
+ };
4739
5114
  }
4740
-
4741
5115
  return {
4742
- width: width,
4743
- height: height,
4744
- x: x,
4745
- y: y
5116
+ scrollLeft: element.scrollX,
5117
+ scrollTop: element.scrollY
4746
5118
  };
4747
5119
  }
4748
-
4749
- function isScrollParent(element) {
4750
- // Firefox wants us to check `-x` and `-y` variations as well
4751
- var _getComputedStyle = getComputedStyle(element),
4752
- overflow = _getComputedStyle.overflow,
4753
- overflowX = _getComputedStyle.overflowX,
4754
- overflowY = _getComputedStyle.overflowY;
4755
-
4756
- return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
5120
+ function getParentNode(node) {
5121
+ if (getNodeName(node) === 'html') {
5122
+ return node;
5123
+ }
5124
+ const result =
5125
+ // Step into the shadow DOM of the parent of a slotted node.
5126
+ node.assignedSlot ||
5127
+ // DOM Element detected.
5128
+ node.parentNode ||
5129
+ // ShadowRoot detected.
5130
+ isShadowRoot(node) && node.host ||
5131
+ // Fallback.
5132
+ getDocumentElement(node);
5133
+ return isShadowRoot(result) ? result.host : result;
4757
5134
  }
4758
-
4759
- function getScrollParent(node) {
4760
- if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
4761
- // $FlowFixMe: assume body is always available
4762
- return node.ownerDocument.body;
5135
+ function getNearestOverflowAncestor(node) {
5136
+ const parentNode = getParentNode(node);
5137
+ if (isLastTraversableNode(parentNode)) {
5138
+ return node.ownerDocument ? node.ownerDocument.body : node.body;
4763
5139
  }
4764
-
4765
- if (isHTMLElement(node) && isScrollParent(node)) {
4766
- return node;
5140
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
5141
+ return parentNode;
4767
5142
  }
4768
-
4769
- return getScrollParent(getParentNode(node));
5143
+ return getNearestOverflowAncestor(parentNode);
4770
5144
  }
4771
-
4772
- /*
4773
- given a DOM element, return the list of all scroll parents, up the list of ancesors
4774
- until we get to the top window object. This list is what we attach scroll listeners
4775
- to, because if any of these parent elements scroll, we'll need to re-calculate the
4776
- reference element's position.
4777
- */
4778
-
4779
- function listScrollParents(element, list) {
5145
+ function getOverflowAncestors(node, list, traverseIframes) {
5146
+ var _node$ownerDocument2;
4780
5147
  if (list === void 0) {
4781
5148
  list = [];
4782
5149
  }
4783
-
4784
- var scrollParent = getScrollParent(element);
4785
- var isBody = getNodeName(scrollParent) === 'body';
4786
- var win = getWindow(scrollParent);
4787
- var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
4788
- var updatedList = list.concat(target);
4789
- return isBody ? updatedList : // $FlowFixMe: isBody tells us target will be an HTMLElement here
4790
- updatedList.concat(listScrollParents(getParentNode(target)));
4791
- }
4792
-
4793
- function rectToClientRect(rect) {
4794
- return Object.assign(Object.assign({}, rect), {}, {
4795
- left: rect.x,
4796
- top: rect.y,
4797
- right: rect.x + rect.width,
4798
- bottom: rect.y + rect.height
4799
- });
4800
- }
4801
-
4802
- function getInnerBoundingClientRect(element) {
4803
- var rect = getBoundingClientRect(element);
4804
- rect.top = rect.top + element.clientTop;
4805
- rect.left = rect.left + element.clientLeft;
4806
- rect.bottom = rect.top + element.clientHeight;
4807
- rect.right = rect.left + element.clientWidth;
4808
- rect.width = element.clientWidth;
4809
- rect.height = element.clientHeight;
4810
- rect.x = rect.left;
4811
- rect.y = rect.top;
4812
- return rect;
4813
- }
4814
-
4815
- function getClientRectFromMixedType(element, clippingParent) {
4816
- return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isHTMLElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
4817
- } // A "clipping parent" is an overflowable container with the characteristic of
4818
- // clipping (or hiding) overflowing elements with a position different from
4819
- // `initial`
4820
-
4821
-
4822
- function getClippingParents(element) {
4823
- var clippingParents = listScrollParents(getParentNode(element));
4824
- var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle(element).position) >= 0;
4825
- var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
4826
-
4827
- if (!isElement(clipperElement)) {
4828
- return [];
4829
- } // $FlowFixMe: https://github.com/facebook/flow/issues/1414
4830
-
4831
-
4832
- return clippingParents.filter(function (clippingParent) {
4833
- return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
4834
- });
4835
- } // Gets the maximum area that the element is visible in due to any number of
4836
- // clipping parents
4837
-
4838
-
4839
- function getClippingRect(element, boundary, rootBoundary) {
4840
- var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
4841
- var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
4842
- var firstClippingParent = clippingParents[0];
4843
- var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
4844
- var rect = getClientRectFromMixedType(element, clippingParent);
4845
- accRect.top = Math.max(rect.top, accRect.top);
4846
- accRect.right = Math.min(rect.right, accRect.right);
4847
- accRect.bottom = Math.min(rect.bottom, accRect.bottom);
4848
- accRect.left = Math.max(rect.left, accRect.left);
4849
- return accRect;
4850
- }, getClientRectFromMixedType(element, firstClippingParent));
4851
- clippingRect.width = clippingRect.right - clippingRect.left;
4852
- clippingRect.height = clippingRect.bottom - clippingRect.top;
4853
- clippingRect.x = clippingRect.left;
4854
- clippingRect.y = clippingRect.top;
4855
- return clippingRect;
5150
+ if (traverseIframes === void 0) {
5151
+ traverseIframes = true;
5152
+ }
5153
+ const scrollableAncestor = getNearestOverflowAncestor(node);
5154
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
5155
+ const win = getWindow(scrollableAncestor);
5156
+ if (isBody) {
5157
+ const frameElement = getFrameElement(win);
5158
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
5159
+ }
5160
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
4856
5161
  }
4857
-
4858
- function getVariation(placement) {
4859
- return placement.split('-')[1];
5162
+ function getFrameElement(win) {
5163
+ return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
4860
5164
  }
4861
5165
 
4862
- function computeOffsets(_ref) {
4863
- var reference = _ref.reference,
4864
- element = _ref.element,
4865
- placement = _ref.placement;
4866
- var basePlacement = placement ? getBasePlacement(placement) : null;
4867
- var variation = placement ? getVariation(placement) : null;
4868
- var commonX = reference.x + reference.width / 2 - element.width / 2;
4869
- var commonY = reference.y + reference.height / 2 - element.height / 2;
4870
- var offsets;
4871
-
4872
- switch (basePlacement) {
4873
- case top:
4874
- offsets = {
4875
- x: commonX,
4876
- y: reference.y - element.height
4877
- };
4878
- break;
4879
-
4880
- case bottom:
4881
- offsets = {
4882
- x: commonX,
4883
- y: reference.y + reference.height
4884
- };
4885
- break;
4886
-
4887
- case right:
4888
- offsets = {
4889
- x: reference.x + reference.width,
4890
- y: commonY
4891
- };
4892
- break;
4893
-
4894
- case left:
4895
- offsets = {
4896
- x: reference.x - element.width,
4897
- y: commonY
4898
- };
4899
- break;
4900
-
4901
- default:
4902
- offsets = {
4903
- x: reference.x,
4904
- y: reference.y
4905
- };
4906
- }
4907
-
4908
- var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
4909
-
4910
- if (mainAxis != null) {
4911
- var len = mainAxis === 'y' ? 'height' : 'width';
4912
-
4913
- switch (variation) {
4914
- case start:
4915
- offsets[mainAxis] = Math.floor(offsets[mainAxis]) - Math.floor(reference[len] / 2 - element[len] / 2);
4916
- break;
4917
-
4918
- case end:
4919
- offsets[mainAxis] = Math.floor(offsets[mainAxis]) + Math.ceil(reference[len] / 2 - element[len] / 2);
4920
- break;
4921
- }
5166
+ function getCssDimensions(element) {
5167
+ const css = getComputedStyle$1(element);
5168
+ // In testing environments, the `width` and `height` properties are empty
5169
+ // strings for SVG elements, returning NaN. Fallback to `0` in this case.
5170
+ let width = parseFloat(css.width) || 0;
5171
+ let height = parseFloat(css.height) || 0;
5172
+ const hasOffset = isHTMLElement(element);
5173
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
5174
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
5175
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
5176
+ if (shouldFallback) {
5177
+ width = offsetWidth;
5178
+ height = offsetHeight;
4922
5179
  }
5180
+ return {
5181
+ width,
5182
+ height,
5183
+ $: shouldFallback
5184
+ };
5185
+ }
4923
5186
 
4924
- return offsets;
5187
+ function unwrapElement(element) {
5188
+ return !isElement(element) ? element.contextElement : element;
4925
5189
  }
4926
5190
 
4927
- function detectOverflow(state, options) {
4928
- if (options === void 0) {
4929
- options = {};
5191
+ function getScale(element) {
5192
+ const domElement = unwrapElement(element);
5193
+ if (!isHTMLElement(domElement)) {
5194
+ return createCoords(1);
4930
5195
  }
5196
+ const rect = domElement.getBoundingClientRect();
5197
+ const {
5198
+ width,
5199
+ height,
5200
+ $
5201
+ } = getCssDimensions(domElement);
5202
+ let x = ($ ? round(rect.width) : rect.width) / width;
5203
+ let y = ($ ? round(rect.height) : rect.height) / height;
4931
5204
 
4932
- var _options = options,
4933
- _options$placement = _options.placement,
4934
- placement = _options$placement === void 0 ? state.placement : _options$placement,
4935
- _options$boundary = _options.boundary,
4936
- boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
4937
- _options$rootBoundary = _options.rootBoundary,
4938
- rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
4939
- _options$elementConte = _options.elementContext,
4940
- elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
4941
- _options$altBoundary = _options.altBoundary,
4942
- altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
4943
- _options$padding = _options.padding,
4944
- padding = _options$padding === void 0 ? 0 : _options$padding;
4945
- var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
4946
- var altContext = elementContext === popper ? reference : popper;
4947
- var referenceElement = state.elements.reference;
4948
- var popperRect = state.rects.popper;
4949
- var element = state.elements[altBoundary ? altContext : elementContext];
4950
- var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
4951
- var referenceClientRect = getBoundingClientRect(referenceElement);
4952
- var popperOffsets = computeOffsets({
4953
- reference: referenceClientRect,
4954
- element: popperRect,
4955
- placement: placement
4956
- });
4957
- var popperClientRect = rectToClientRect(Object.assign(Object.assign({}, popperRect), popperOffsets));
4958
- var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect
4959
- // 0 or negative = within the clipping rect
4960
-
4961
- var overflowOffsets = {
4962
- top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
4963
- bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
4964
- left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
4965
- right: elementClientRect.right - clippingClientRect.right + paddingObject.right
4966
- };
4967
- var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element
4968
-
4969
- if (elementContext === popper && offsetData) {
4970
- var offset = offsetData[placement];
4971
- Object.keys(overflowOffsets).forEach(function (key) {
4972
- var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
4973
- var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
4974
- overflowOffsets[key] += offset[axis] * multiply;
4975
- });
4976
- }
5205
+ // 0, NaN, or Infinity should always fallback to 1.
4977
5206
 
4978
- return overflowOffsets;
5207
+ if (!x || !Number.isFinite(x)) {
5208
+ x = 1;
5209
+ }
5210
+ if (!y || !Number.isFinite(y)) {
5211
+ y = 1;
5212
+ }
5213
+ return {
5214
+ x,
5215
+ y
5216
+ };
4979
5217
  }
4980
5218
 
4981
- /*:: type OverflowsMap = { [ComputedPlacement]: number }; */
4982
-
4983
- /*;; type OverflowsMap = { [key in ComputedPlacement]: number }; */
4984
- function computeAutoPlacement(state, options) {
4985
- if (options === void 0) {
4986
- options = {};
5219
+ const noOffsets = /*#__PURE__*/createCoords(0);
5220
+ function getVisualOffsets(element) {
5221
+ const win = getWindow(element);
5222
+ if (!isWebKit() || !win.visualViewport) {
5223
+ return noOffsets;
4987
5224
  }
4988
-
4989
- var _options = options,
4990
- placement = _options.placement,
4991
- boundary = _options.boundary,
4992
- rootBoundary = _options.rootBoundary,
4993
- padding = _options.padding,
4994
- flipVariations = _options.flipVariations,
4995
- _options$allowedAutoP = _options.allowedAutoPlacements,
4996
- allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP;
4997
- var variation = getVariation(placement);
4998
- var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) {
4999
- return getVariation(placement) === variation;
5000
- }) : basePlacements; // $FlowFixMe
5001
-
5002
- var allowedPlacements = placements$1.filter(function (placement) {
5003
- return allowedAutoPlacements.indexOf(placement) >= 0;
5004
- });
5005
-
5006
- if (allowedPlacements.length === 0) {
5007
- allowedPlacements = placements$1;
5008
-
5009
- if (process.env.NODE_ENV !== "production") {
5010
- console.error(['Popper: The `allowedAutoPlacements` option did not allow any', 'placements. Ensure the `placement` option matches the variation', 'of the allowed placements.', 'For example, "auto" cannot be used to allow "bottom-start".', 'Use "auto-start" instead.'].join(' '));
5011
- }
5012
- } // $FlowFixMe: Flow seems to have problems with two array unions...
5013
-
5014
-
5015
- var overflows = allowedPlacements.reduce(function (acc, placement) {
5016
- acc[placement] = detectOverflow(state, {
5017
- placement: placement,
5018
- boundary: boundary,
5019
- rootBoundary: rootBoundary,
5020
- padding: padding
5021
- })[getBasePlacement(placement)];
5022
- return acc;
5023
- }, {});
5024
- return Object.keys(overflows).sort(function (a, b) {
5025
- return overflows[a] - overflows[b];
5026
- });
5225
+ return {
5226
+ x: win.visualViewport.offsetLeft,
5227
+ y: win.visualViewport.offsetTop
5228
+ };
5027
5229
  }
5028
-
5029
- function getExpandedFallbackPlacements(placement) {
5030
- if (getBasePlacement(placement) === auto) {
5031
- return [];
5230
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
5231
+ if (isFixed === void 0) {
5232
+ isFixed = false;
5032
5233
  }
5033
-
5034
- var oppositePlacement = getOppositePlacement(placement);
5035
- return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];
5234
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
5235
+ return false;
5236
+ }
5237
+ return isFixed;
5036
5238
  }
5037
5239
 
5038
- function flip(_ref) {
5039
- var state = _ref.state,
5040
- options = _ref.options,
5041
- name = _ref.name;
5042
-
5043
- if (state.modifiersData[name]._skip) {
5044
- return;
5240
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
5241
+ if (includeScale === void 0) {
5242
+ includeScale = false;
5045
5243
  }
5046
-
5047
- var _options$mainAxis = options.mainAxis,
5048
- checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
5049
- _options$altAxis = options.altAxis,
5050
- checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis,
5051
- specifiedFallbackPlacements = options.fallbackPlacements,
5052
- padding = options.padding,
5053
- boundary = options.boundary,
5054
- rootBoundary = options.rootBoundary,
5055
- altBoundary = options.altBoundary,
5056
- _options$flipVariatio = options.flipVariations,
5057
- flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio,
5058
- allowedAutoPlacements = options.allowedAutoPlacements;
5059
- var preferredPlacement = state.options.placement;
5060
- var basePlacement = getBasePlacement(preferredPlacement);
5061
- var isBasePlacement = basePlacement === preferredPlacement;
5062
- var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
5063
- var placements = [preferredPlacement].concat(fallbackPlacements).reduce(function (acc, placement) {
5064
- return acc.concat(getBasePlacement(placement) === auto ? computeAutoPlacement(state, {
5065
- placement: placement,
5066
- boundary: boundary,
5067
- rootBoundary: rootBoundary,
5068
- padding: padding,
5069
- flipVariations: flipVariations,
5070
- allowedAutoPlacements: allowedAutoPlacements
5071
- }) : placement);
5072
- }, []);
5073
- var referenceRect = state.rects.reference;
5074
- var popperRect = state.rects.popper;
5075
- var checksMap = new Map();
5076
- var makeFallbackChecks = true;
5077
- var firstFittingPlacement = placements[0];
5078
-
5079
- for (var i = 0; i < placements.length; i++) {
5080
- var placement = placements[i];
5081
-
5082
- var _basePlacement = getBasePlacement(placement);
5083
-
5084
- var isStartVariation = getVariation(placement) === start;
5085
- var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
5086
- var len = isVertical ? 'width' : 'height';
5087
- var overflow = detectOverflow(state, {
5088
- placement: placement,
5089
- boundary: boundary,
5090
- rootBoundary: rootBoundary,
5091
- altBoundary: altBoundary,
5092
- padding: padding
5093
- });
5094
- var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
5095
-
5096
- if (referenceRect[len] > popperRect[len]) {
5097
- mainVariationSide = getOppositePlacement(mainVariationSide);
5098
- }
5099
-
5100
- var altVariationSide = getOppositePlacement(mainVariationSide);
5101
- var checks = [];
5102
-
5103
- if (checkMainAxis) {
5104
- checks.push(overflow[_basePlacement] <= 0);
5105
- }
5106
-
5107
- if (checkAltAxis) {
5108
- checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
5109
- }
5110
-
5111
- if (checks.every(function (check) {
5112
- return check;
5113
- })) {
5114
- firstFittingPlacement = placement;
5115
- makeFallbackChecks = false;
5116
- break;
5117
- }
5118
-
5119
- checksMap.set(placement, checks);
5244
+ if (isFixedStrategy === void 0) {
5245
+ isFixedStrategy = false;
5120
5246
  }
5121
-
5122
- if (makeFallbackChecks) {
5123
- // `2` may be desired in some cases – research later
5124
- var numberOfChecks = flipVariations ? 3 : 1;
5125
-
5126
- var _loop = function _loop(_i) {
5127
- var fittingPlacement = placements.find(function (placement) {
5128
- var checks = checksMap.get(placement);
5129
-
5130
- if (checks) {
5131
- return checks.slice(0, _i).every(function (check) {
5132
- return check;
5133
- });
5134
- }
5135
- });
5136
-
5137
- if (fittingPlacement) {
5138
- firstFittingPlacement = fittingPlacement;
5139
- return "break";
5247
+ const clientRect = element.getBoundingClientRect();
5248
+ const domElement = unwrapElement(element);
5249
+ let scale = createCoords(1);
5250
+ if (includeScale) {
5251
+ if (offsetParent) {
5252
+ if (isElement(offsetParent)) {
5253
+ scale = getScale(offsetParent);
5140
5254
  }
5141
- };
5142
-
5143
- for (var _i = numberOfChecks; _i > 0; _i--) {
5144
- var _ret = _loop(_i);
5145
-
5146
- if (_ret === "break") break;
5255
+ } else {
5256
+ scale = getScale(element);
5257
+ }
5258
+ }
5259
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
5260
+ let x = (clientRect.left + visualOffsets.x) / scale.x;
5261
+ let y = (clientRect.top + visualOffsets.y) / scale.y;
5262
+ let width = clientRect.width / scale.x;
5263
+ let height = clientRect.height / scale.y;
5264
+ if (domElement) {
5265
+ const win = getWindow(domElement);
5266
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
5267
+ let currentWin = win;
5268
+ let currentIFrame = getFrameElement(currentWin);
5269
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
5270
+ const iframeScale = getScale(currentIFrame);
5271
+ const iframeRect = currentIFrame.getBoundingClientRect();
5272
+ const css = getComputedStyle$1(currentIFrame);
5273
+ const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
5274
+ const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
5275
+ x *= iframeScale.x;
5276
+ y *= iframeScale.y;
5277
+ width *= iframeScale.x;
5278
+ height *= iframeScale.y;
5279
+ x += left;
5280
+ y += top;
5281
+ currentWin = getWindow(currentIFrame);
5282
+ currentIFrame = getFrameElement(currentWin);
5147
5283
  }
5148
5284
  }
5285
+ return rectToClientRect({
5286
+ width,
5287
+ height,
5288
+ x,
5289
+ y
5290
+ });
5291
+ }
5149
5292
 
5150
- if (state.placement !== firstFittingPlacement) {
5151
- state.modifiersData[name]._skip = true;
5152
- state.placement = firstFittingPlacement;
5153
- state.reset = true;
5293
+ // If <html> has a CSS width greater than the viewport, then this will be
5294
+ // incorrect for RTL.
5295
+ function getWindowScrollBarX(element, rect) {
5296
+ const leftScroll = getNodeScroll(element).scrollLeft;
5297
+ if (!rect) {
5298
+ return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
5154
5299
  }
5155
- } // eslint-disable-next-line import/no-unused-modules
5300
+ return rect.left + leftScroll;
5301
+ }
5156
5302
 
5303
+ function getHTMLOffset(documentElement, scroll) {
5304
+ const htmlRect = documentElement.getBoundingClientRect();
5305
+ const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
5306
+ const y = htmlRect.top + scroll.scrollTop;
5307
+ return {
5308
+ x,
5309
+ y
5310
+ };
5311
+ }
5157
5312
 
5158
- var flip$1 = {
5159
- name: 'flip',
5160
- enabled: true,
5161
- phase: 'main',
5162
- fn: flip,
5163
- requiresIfExists: ['offset'],
5164
- data: {
5165
- _skip: false
5313
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
5314
+ let {
5315
+ elements,
5316
+ rect,
5317
+ offsetParent,
5318
+ strategy
5319
+ } = _ref;
5320
+ const isFixed = strategy === 'fixed';
5321
+ const documentElement = getDocumentElement(offsetParent);
5322
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
5323
+ if (offsetParent === documentElement || topLayer && isFixed) {
5324
+ return rect;
5166
5325
  }
5167
- };
5168
-
5169
- function getSideOffsets(overflow, rect, preventedOffsets) {
5170
- if (preventedOffsets === void 0) {
5171
- preventedOffsets = {
5172
- x: 0,
5173
- y: 0
5174
- };
5326
+ let scroll = {
5327
+ scrollLeft: 0,
5328
+ scrollTop: 0
5329
+ };
5330
+ let scale = createCoords(1);
5331
+ const offsets = createCoords(0);
5332
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
5333
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
5334
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
5335
+ scroll = getNodeScroll(offsetParent);
5336
+ }
5337
+ if (isHTMLElement(offsetParent)) {
5338
+ const offsetRect = getBoundingClientRect(offsetParent);
5339
+ scale = getScale(offsetParent);
5340
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
5341
+ offsets.y = offsetRect.y + offsetParent.clientTop;
5342
+ }
5175
5343
  }
5176
-
5344
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
5177
5345
  return {
5178
- top: overflow.top - rect.height - preventedOffsets.y,
5179
- right: overflow.right - rect.width + preventedOffsets.x,
5180
- bottom: overflow.bottom - rect.height + preventedOffsets.y,
5181
- left: overflow.left - rect.width - preventedOffsets.x
5346
+ width: rect.width * scale.x,
5347
+ height: rect.height * scale.y,
5348
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
5349
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
5182
5350
  };
5183
5351
  }
5184
5352
 
5185
- function isAnySideFullyClipped(overflow) {
5186
- return [top, right, bottom, left].some(function (side) {
5187
- return overflow[side] >= 0;
5188
- });
5353
+ function getClientRects(element) {
5354
+ return Array.from(element.getClientRects());
5189
5355
  }
5190
5356
 
5191
- function hide(_ref) {
5192
- var state = _ref.state,
5193
- name = _ref.name;
5194
- var referenceRect = state.rects.reference;
5195
- var popperRect = state.rects.popper;
5196
- var preventedOffsets = state.modifiersData.preventOverflow;
5197
- var referenceOverflow = detectOverflow(state, {
5198
- elementContext: 'reference'
5199
- });
5200
- var popperAltOverflow = detectOverflow(state, {
5201
- altBoundary: true
5202
- });
5203
- var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
5204
- var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
5205
- var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
5206
- var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
5207
- state.modifiersData[name] = {
5208
- referenceClippingOffsets: referenceClippingOffsets,
5209
- popperEscapeOffsets: popperEscapeOffsets,
5210
- isReferenceHidden: isReferenceHidden,
5211
- hasPopperEscaped: hasPopperEscaped
5212
- };
5213
- state.attributes.popper = Object.assign(Object.assign({}, state.attributes.popper), {}, {
5214
- 'data-popper-reference-hidden': isReferenceHidden,
5215
- 'data-popper-escaped': hasPopperEscaped
5216
- });
5217
- } // eslint-disable-next-line import/no-unused-modules
5218
-
5219
-
5220
- var hide$1 = {
5221
- name: 'hide',
5222
- enabled: true,
5223
- phase: 'main',
5224
- requiresIfExists: ['preventOverflow'],
5225
- fn: hide
5226
- };
5227
-
5228
- function distanceAndSkiddingToXY(placement, rects, offset) {
5229
- var basePlacement = getBasePlacement(placement);
5230
- var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
5231
-
5232
- var _ref = typeof offset === 'function' ? offset(Object.assign(Object.assign({}, rects), {}, {
5233
- placement: placement
5234
- })) : offset,
5235
- skidding = _ref[0],
5236
- distance = _ref[1];
5237
-
5238
- skidding = skidding || 0;
5239
- distance = (distance || 0) * invertDistance;
5240
- return [left, right].indexOf(basePlacement) >= 0 ? {
5241
- x: distance,
5242
- y: skidding
5243
- } : {
5244
- x: skidding,
5245
- y: distance
5357
+ // Gets the entire size of the scrollable document area, even extending outside
5358
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable.
5359
+ function getDocumentRect(element) {
5360
+ const html = getDocumentElement(element);
5361
+ const scroll = getNodeScroll(element);
5362
+ const body = element.ownerDocument.body;
5363
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
5364
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
5365
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
5366
+ const y = -scroll.scrollTop;
5367
+ if (getComputedStyle$1(body).direction === 'rtl') {
5368
+ x += max(html.clientWidth, body.clientWidth) - width;
5369
+ }
5370
+ return {
5371
+ width,
5372
+ height,
5373
+ x,
5374
+ y
5246
5375
  };
5247
5376
  }
5248
5377
 
5249
- function offset(_ref2) {
5250
- var state = _ref2.state,
5251
- options = _ref2.options,
5252
- name = _ref2.name;
5253
- var _options$offset = options.offset,
5254
- offset = _options$offset === void 0 ? [0, 0] : _options$offset;
5255
- var data = placements.reduce(function (acc, placement) {
5256
- acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
5257
- return acc;
5258
- }, {});
5259
- var _data$state$placement = data[state.placement],
5260
- x = _data$state$placement.x,
5261
- y = _data$state$placement.y;
5262
-
5263
- if (state.modifiersData.popperOffsets != null) {
5264
- state.modifiersData.popperOffsets.x += x;
5265
- state.modifiersData.popperOffsets.y += y;
5378
+ // Safety check: ensure the scrollbar space is reasonable in case this
5379
+ // calculation is affected by unusual styles.
5380
+ // Most scrollbars leave 15-18px of space.
5381
+ const SCROLLBAR_MAX = 25;
5382
+ function getViewportRect(element, strategy) {
5383
+ const win = getWindow(element);
5384
+ const html = getDocumentElement(element);
5385
+ const visualViewport = win.visualViewport;
5386
+ let width = html.clientWidth;
5387
+ let height = html.clientHeight;
5388
+ let x = 0;
5389
+ let y = 0;
5390
+ if (visualViewport) {
5391
+ width = visualViewport.width;
5392
+ height = visualViewport.height;
5393
+ const visualViewportBased = isWebKit();
5394
+ if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
5395
+ x = visualViewport.offsetLeft;
5396
+ y = visualViewport.offsetTop;
5397
+ }
5266
5398
  }
5267
-
5268
- state.modifiersData[name] = data;
5269
- } // eslint-disable-next-line import/no-unused-modules
5270
-
5271
-
5272
- var offset$1 = {
5273
- name: 'offset',
5274
- enabled: true,
5275
- phase: 'main',
5276
- requires: ['popperOffsets'],
5277
- fn: offset
5278
- };
5279
-
5280
- function popperOffsets(_ref) {
5281
- var state = _ref.state,
5282
- name = _ref.name;
5283
- // Offsets are the actual position the popper needs to have to be
5284
- // properly positioned near its reference element
5285
- // This is the most basic placement, and will be adjusted by
5286
- // the modifiers in the next step
5287
- state.modifiersData[name] = computeOffsets({
5288
- reference: state.rects.reference,
5289
- element: state.rects.popper,
5290
- placement: state.placement
5291
- });
5292
- } // eslint-disable-next-line import/no-unused-modules
5293
-
5294
-
5295
- var popperOffsets$1 = {
5296
- name: 'popperOffsets',
5297
- enabled: true,
5298
- phase: 'read',
5299
- fn: popperOffsets,
5300
- data: {}
5301
- };
5302
-
5303
- function getAltAxis(axis) {
5304
- return axis === 'x' ? 'y' : 'x';
5399
+ const windowScrollbarX = getWindowScrollBarX(html);
5400
+ // <html> `overflow: hidden` + `scrollbar-gutter: stable` reduces the
5401
+ // visual width of the <html> but this is not considered in the size
5402
+ // of `html.clientWidth`.
5403
+ if (windowScrollbarX <= 0) {
5404
+ const doc = html.ownerDocument;
5405
+ const body = doc.body;
5406
+ const bodyStyles = getComputedStyle(body);
5407
+ const bodyMarginInline = doc.compatMode === 'CSS1Compat' ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
5408
+ const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
5409
+ if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
5410
+ width -= clippingStableScrollbarWidth;
5411
+ }
5412
+ } else if (windowScrollbarX <= SCROLLBAR_MAX) {
5413
+ // If the <body> scrollbar is on the left, the width needs to be extended
5414
+ // by the scrollbar amount so there isn't extra space on the right.
5415
+ width += windowScrollbarX;
5416
+ }
5417
+ return {
5418
+ width,
5419
+ height,
5420
+ x,
5421
+ y
5422
+ };
5305
5423
  }
5306
5424
 
5307
- function preventOverflow(_ref) {
5308
- var state = _ref.state,
5309
- options = _ref.options,
5310
- name = _ref.name;
5311
- var _options$mainAxis = options.mainAxis,
5312
- checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
5313
- _options$altAxis = options.altAxis,
5314
- checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis,
5315
- boundary = options.boundary,
5316
- rootBoundary = options.rootBoundary,
5317
- altBoundary = options.altBoundary,
5318
- padding = options.padding,
5319
- _options$tether = options.tether,
5320
- tether = _options$tether === void 0 ? true : _options$tether,
5321
- _options$tetherOffset = options.tetherOffset,
5322
- tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
5323
- var overflow = detectOverflow(state, {
5324
- boundary: boundary,
5325
- rootBoundary: rootBoundary,
5326
- padding: padding,
5327
- altBoundary: altBoundary
5328
- });
5329
- var basePlacement = getBasePlacement(state.placement);
5330
- var variation = getVariation(state.placement);
5331
- var isBasePlacement = !variation;
5332
- var mainAxis = getMainAxisFromPlacement(basePlacement);
5333
- var altAxis = getAltAxis(mainAxis);
5334
- var popperOffsets = state.modifiersData.popperOffsets;
5335
- var referenceRect = state.rects.reference;
5336
- var popperRect = state.rects.popper;
5337
- var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign(Object.assign({}, state.rects), {}, {
5338
- placement: state.placement
5339
- })) : tetherOffset;
5340
- var data = {
5341
- x: 0,
5342
- y: 0
5425
+ const absoluteOrFixed = /*#__PURE__*/new Set(['absolute', 'fixed']);
5426
+ // Returns the inner client rect, subtracting scrollbars if present.
5427
+ function getInnerBoundingClientRect(element, strategy) {
5428
+ const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
5429
+ const top = clientRect.top + element.clientTop;
5430
+ const left = clientRect.left + element.clientLeft;
5431
+ const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
5432
+ const width = element.clientWidth * scale.x;
5433
+ const height = element.clientHeight * scale.y;
5434
+ const x = left * scale.x;
5435
+ const y = top * scale.y;
5436
+ return {
5437
+ width,
5438
+ height,
5439
+ x,
5440
+ y
5343
5441
  };
5344
-
5345
- if (!popperOffsets) {
5346
- return;
5347
- }
5348
-
5349
- if (checkMainAxis) {
5350
- var mainSide = mainAxis === 'y' ? top : left;
5351
- var altSide = mainAxis === 'y' ? bottom : right;
5352
- var len = mainAxis === 'y' ? 'height' : 'width';
5353
- var offset = popperOffsets[mainAxis];
5354
- var min = popperOffsets[mainAxis] + overflow[mainSide];
5355
- var max = popperOffsets[mainAxis] - overflow[altSide];
5356
- var additive = tether ? -popperRect[len] / 2 : 0;
5357
- var minLen = variation === start ? referenceRect[len] : popperRect[len];
5358
- var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
5359
- // outside the reference bounds
5360
-
5361
- var arrowElement = state.elements.arrow;
5362
- var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
5363
- width: 0,
5364
- height: 0
5442
+ }
5443
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
5444
+ let rect;
5445
+ if (clippingAncestor === 'viewport') {
5446
+ rect = getViewportRect(element, strategy);
5447
+ } else if (clippingAncestor === 'document') {
5448
+ rect = getDocumentRect(getDocumentElement(element));
5449
+ } else if (isElement(clippingAncestor)) {
5450
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
5451
+ } else {
5452
+ const visualOffsets = getVisualOffsets(element);
5453
+ rect = {
5454
+ x: clippingAncestor.x - visualOffsets.x,
5455
+ y: clippingAncestor.y - visualOffsets.y,
5456
+ width: clippingAncestor.width,
5457
+ height: clippingAncestor.height
5365
5458
  };
5366
- var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject();
5367
- var arrowPaddingMin = arrowPaddingObject[mainSide];
5368
- var arrowPaddingMax = arrowPaddingObject[altSide]; // If the reference length is smaller than the arrow length, we don't want
5369
- // to include its full size in the calculation. If the reference is small
5370
- // and near the edge of a boundary, the popper can overflow even if the
5371
- // reference is not overflowing as well (e.g. virtual elements with no
5372
- // width or height)
5373
-
5374
- var arrowLen = within(0, referenceRect[len], arrowRect[len]);
5375
- var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - tetherOffsetValue : minLen - arrowLen - arrowPaddingMin - tetherOffsetValue;
5376
- var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + tetherOffsetValue : maxLen + arrowLen + arrowPaddingMax + tetherOffsetValue;
5377
- var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
5378
- var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
5379
- var offsetModifierValue = state.modifiersData.offset ? state.modifiersData.offset[state.placement][mainAxis] : 0;
5380
- var tetherMin = popperOffsets[mainAxis] + minOffset - offsetModifierValue - clientOffset;
5381
- var tetherMax = popperOffsets[mainAxis] + maxOffset - offsetModifierValue;
5382
- var preventedOffset = within(tether ? Math.min(min, tetherMin) : min, offset, tether ? Math.max(max, tetherMax) : max);
5383
- popperOffsets[mainAxis] = preventedOffset;
5384
- data[mainAxis] = preventedOffset - offset;
5385
5459
  }
5386
-
5387
- if (checkAltAxis) {
5388
- var _mainSide = mainAxis === 'x' ? top : left;
5389
-
5390
- var _altSide = mainAxis === 'x' ? bottom : right;
5391
-
5392
- var _offset = popperOffsets[altAxis];
5393
-
5394
- var _min = _offset + overflow[_mainSide];
5395
-
5396
- var _max = _offset - overflow[_altSide];
5397
-
5398
- var _preventedOffset = within(_min, _offset, _max);
5399
-
5400
- popperOffsets[altAxis] = _preventedOffset;
5401
- data[altAxis] = _preventedOffset - _offset;
5460
+ return rectToClientRect(rect);
5461
+ }
5462
+ function hasFixedPositionAncestor(element, stopNode) {
5463
+ const parentNode = getParentNode(element);
5464
+ if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
5465
+ return false;
5402
5466
  }
5467
+ return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
5468
+ }
5403
5469
 
5404
- state.modifiersData[name] = data;
5405
- } // eslint-disable-next-line import/no-unused-modules
5406
-
5407
-
5408
- var preventOverflow$1 = {
5409
- name: 'preventOverflow',
5410
- enabled: true,
5411
- phase: 'main',
5412
- fn: preventOverflow,
5413
- requiresIfExists: ['offset']
5414
- };
5470
+ // A "clipping ancestor" is an `overflow` element with the characteristic of
5471
+ // clipping (or hiding) child elements. This returns all clipping ancestors
5472
+ // of the given element up the tree.
5473
+ function getClippingElementAncestors(element, cache) {
5474
+ const cachedResult = cache.get(element);
5475
+ if (cachedResult) {
5476
+ return cachedResult;
5477
+ }
5478
+ let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
5479
+ let currentContainingBlockComputedStyle = null;
5480
+ const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
5481
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
5482
+
5483
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
5484
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
5485
+ const computedStyle = getComputedStyle$1(currentNode);
5486
+ const currentNodeIsContaining = isContainingBlock(currentNode);
5487
+ if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
5488
+ currentContainingBlockComputedStyle = null;
5489
+ }
5490
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && absoluteOrFixed.has(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
5491
+ if (shouldDropCurrentNode) {
5492
+ // Drop non-containing blocks.
5493
+ result = result.filter(ancestor => ancestor !== currentNode);
5494
+ } else {
5495
+ // Record last containing block for next iteration.
5496
+ currentContainingBlockComputedStyle = computedStyle;
5497
+ }
5498
+ currentNode = getParentNode(currentNode);
5499
+ }
5500
+ cache.set(element, result);
5501
+ return result;
5502
+ }
5415
5503
 
5416
- function getHTMLElementScroll(element) {
5504
+ // Gets the maximum area that the element is visible in due to any number of
5505
+ // clipping ancestors.
5506
+ function getClippingRect(_ref) {
5507
+ let {
5508
+ element,
5509
+ boundary,
5510
+ rootBoundary,
5511
+ strategy
5512
+ } = _ref;
5513
+ const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
5514
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
5515
+ const firstClippingAncestor = clippingAncestors[0];
5516
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
5517
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
5518
+ accRect.top = max(rect.top, accRect.top);
5519
+ accRect.right = min(rect.right, accRect.right);
5520
+ accRect.bottom = min(rect.bottom, accRect.bottom);
5521
+ accRect.left = max(rect.left, accRect.left);
5522
+ return accRect;
5523
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
5417
5524
  return {
5418
- scrollLeft: element.scrollLeft,
5419
- scrollTop: element.scrollTop
5525
+ width: clippingRect.right - clippingRect.left,
5526
+ height: clippingRect.bottom - clippingRect.top,
5527
+ x: clippingRect.left,
5528
+ y: clippingRect.top
5420
5529
  };
5421
5530
  }
5422
5531
 
5423
- function getNodeScroll(node) {
5424
- if (node === getWindow(node) || !isHTMLElement(node)) {
5425
- return getWindowScroll(node);
5426
- } else {
5427
- return getHTMLElementScroll(node);
5428
- }
5532
+ function getDimensions(element) {
5533
+ const {
5534
+ width,
5535
+ height
5536
+ } = getCssDimensions(element);
5537
+ return {
5538
+ width,
5539
+ height
5540
+ };
5429
5541
  }
5430
5542
 
5431
- // Composite means it takes into account transforms as well as layout.
5432
-
5433
- function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
5434
- if (isFixed === void 0) {
5435
- isFixed = false;
5436
- }
5437
-
5438
- var documentElement = getDocumentElement(offsetParent);
5439
- var rect = getBoundingClientRect(elementOrVirtualElement);
5440
- var isOffsetParentAnElement = isHTMLElement(offsetParent);
5441
- var scroll = {
5543
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
5544
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
5545
+ const documentElement = getDocumentElement(offsetParent);
5546
+ const isFixed = strategy === 'fixed';
5547
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
5548
+ let scroll = {
5442
5549
  scrollLeft: 0,
5443
5550
  scrollTop: 0
5444
5551
  };
5445
- var offsets = {
5446
- x: 0,
5447
- y: 0
5448
- };
5552
+ const offsets = createCoords(0);
5449
5553
 
5554
+ // If the <body> scrollbar appears on the left (e.g. RTL systems). Use
5555
+ // Firefox with layout.scrollbar.side = 3 in about:config to test this.
5556
+ function setLeftRTLScrollbarOffset() {
5557
+ offsets.x = getWindowScrollBarX(documentElement);
5558
+ }
5450
5559
  if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
5451
- if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078
5452
- isScrollParent(documentElement)) {
5560
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
5453
5561
  scroll = getNodeScroll(offsetParent);
5454
5562
  }
5455
-
5456
- if (isHTMLElement(offsetParent)) {
5457
- offsets = getBoundingClientRect(offsetParent);
5458
- offsets.x += offsetParent.clientLeft;
5459
- offsets.y += offsetParent.clientTop;
5563
+ if (isOffsetParentAnElement) {
5564
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
5565
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
5566
+ offsets.y = offsetRect.y + offsetParent.clientTop;
5460
5567
  } else if (documentElement) {
5461
- offsets.x = getWindowScrollBarX(documentElement);
5568
+ setLeftRTLScrollbarOffset();
5462
5569
  }
5463
5570
  }
5464
-
5571
+ if (isFixed && !isOffsetParentAnElement && documentElement) {
5572
+ setLeftRTLScrollbarOffset();
5573
+ }
5574
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
5575
+ const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
5576
+ const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
5465
5577
  return {
5466
- x: rect.left + scroll.scrollLeft - offsets.x,
5467
- y: rect.top + scroll.scrollTop - offsets.y,
5578
+ x,
5579
+ y,
5468
5580
  width: rect.width,
5469
5581
  height: rect.height
5470
5582
  };
5471
5583
  }
5472
5584
 
5473
- function order(modifiers) {
5474
- var map = new Map();
5475
- var visited = new Set();
5476
- var result = [];
5477
- modifiers.forEach(function (modifier) {
5478
- map.set(modifier.name, modifier);
5479
- }); // On visiting object, check for its dependencies and visit them recursively
5480
-
5481
- function sort(modifier) {
5482
- visited.add(modifier.name);
5483
- var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
5484
- requires.forEach(function (dep) {
5485
- if (!visited.has(dep)) {
5486
- var depModifier = map.get(dep);
5585
+ function isStaticPositioned(element) {
5586
+ return getComputedStyle$1(element).position === 'static';
5587
+ }
5487
5588
 
5488
- if (depModifier) {
5489
- sort(depModifier);
5490
- }
5491
- }
5492
- });
5493
- result.push(modifier);
5589
+ function getTrueOffsetParent(element, polyfill) {
5590
+ if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
5591
+ return null;
5494
5592
  }
5495
-
5496
- modifiers.forEach(function (modifier) {
5497
- if (!visited.has(modifier.name)) {
5498
- // check for visited object
5499
- sort(modifier);
5500
- }
5501
- });
5502
- return result;
5593
+ if (polyfill) {
5594
+ return polyfill(element);
5595
+ }
5596
+ let rawOffsetParent = element.offsetParent;
5597
+
5598
+ // Firefox returns the <html> element as the offsetParent if it's non-static,
5599
+ // while Chrome and Safari return the <body> element. The <body> element must
5600
+ // be used to perform the correct calculations even if the <html> element is
5601
+ // non-static.
5602
+ if (getDocumentElement(element) === rawOffsetParent) {
5603
+ rawOffsetParent = rawOffsetParent.ownerDocument.body;
5604
+ }
5605
+ return rawOffsetParent;
5503
5606
  }
5504
5607
 
5505
- function orderModifiers(modifiers) {
5506
- // order based on dependencies
5507
- var orderedModifiers = order(modifiers); // order based on phase
5508
-
5509
- return modifierPhases.reduce(function (acc, phase) {
5510
- return acc.concat(orderedModifiers.filter(function (modifier) {
5511
- return modifier.phase === phase;
5512
- }));
5513
- }, []);
5608
+ // Gets the closest ancestor positioned element. Handles some edge cases,
5609
+ // such as table ancestors and cross browser bugs.
5610
+ function getOffsetParent(element, polyfill) {
5611
+ const win = getWindow(element);
5612
+ if (isTopLayer(element)) {
5613
+ return win;
5614
+ }
5615
+ if (!isHTMLElement(element)) {
5616
+ let svgOffsetParent = getParentNode(element);
5617
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
5618
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
5619
+ return svgOffsetParent;
5620
+ }
5621
+ svgOffsetParent = getParentNode(svgOffsetParent);
5622
+ }
5623
+ return win;
5624
+ }
5625
+ let offsetParent = getTrueOffsetParent(element, polyfill);
5626
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
5627
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
5628
+ }
5629
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
5630
+ return win;
5631
+ }
5632
+ return offsetParent || getContainingBlock(element) || win;
5514
5633
  }
5515
5634
 
5516
- function debounce(fn) {
5517
- var pending;
5518
- return function () {
5519
- if (!pending) {
5520
- pending = new Promise(function (resolve) {
5521
- Promise.resolve().then(function () {
5522
- pending = undefined;
5523
- resolve(fn());
5524
- });
5525
- });
5635
+ const getElementRects = async function (data) {
5636
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
5637
+ const getDimensionsFn = this.getDimensions;
5638
+ const floatingDimensions = await getDimensionsFn(data.floating);
5639
+ return {
5640
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
5641
+ floating: {
5642
+ x: 0,
5643
+ y: 0,
5644
+ width: floatingDimensions.width,
5645
+ height: floatingDimensions.height
5526
5646
  }
5527
-
5528
- return pending;
5529
5647
  };
5530
- }
5531
-
5532
- function format(str) {
5533
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
5534
- args[_key - 1] = arguments[_key];
5535
- }
5648
+ };
5536
5649
 
5537
- return [].concat(args).reduce(function (p, c) {
5538
- return p.replace(/%s/, c);
5539
- }, str);
5650
+ function isRTL(element) {
5651
+ return getComputedStyle$1(element).direction === 'rtl';
5540
5652
  }
5541
5653
 
5542
- var INVALID_MODIFIER_ERROR = 'Popper: modifier "%s" provided an invalid %s property, expected %s but got %s';
5543
- var MISSING_DEPENDENCY_ERROR = 'Popper: modifier "%s" requires "%s", but "%s" modifier is not available';
5544
- var VALID_PROPERTIES = ['name', 'enabled', 'phase', 'fn', 'effect', 'requires', 'options'];
5545
- function validateModifiers(modifiers) {
5546
- modifiers.forEach(function (modifier) {
5547
- Object.keys(modifier).forEach(function (key) {
5548
- switch (key) {
5549
- case 'name':
5550
- if (typeof modifier.name !== 'string') {
5551
- console.error(format(INVALID_MODIFIER_ERROR, String(modifier.name), '"name"', '"string"', "\"" + String(modifier.name) + "\""));
5552
- }
5553
-
5554
- break;
5555
-
5556
- case 'enabled':
5557
- if (typeof modifier.enabled !== 'boolean') {
5558
- console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"enabled"', '"boolean"', "\"" + String(modifier.enabled) + "\""));
5559
- }
5560
-
5561
- case 'phase':
5562
- if (modifierPhases.indexOf(modifier.phase) < 0) {
5563
- console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"phase"', "either " + modifierPhases.join(', '), "\"" + String(modifier.phase) + "\""));
5564
- }
5565
-
5566
- break;
5567
-
5568
- case 'fn':
5569
- if (typeof modifier.fn !== 'function') {
5570
- console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"fn"', '"function"', "\"" + String(modifier.fn) + "\""));
5571
- }
5572
-
5573
- break;
5574
-
5575
- case 'effect':
5576
- if (typeof modifier.effect !== 'function') {
5577
- console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"effect"', '"function"', "\"" + String(modifier.fn) + "\""));
5578
- }
5579
-
5580
- break;
5581
-
5582
- case 'requires':
5583
- if (!Array.isArray(modifier.requires)) {
5584
- console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requires"', '"array"', "\"" + String(modifier.requires) + "\""));
5585
- }
5586
-
5587
- break;
5588
-
5589
- case 'requiresIfExists':
5590
- if (!Array.isArray(modifier.requiresIfExists)) {
5591
- console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requiresIfExists"', '"array"', "\"" + String(modifier.requiresIfExists) + "\""));
5592
- }
5593
-
5594
- break;
5595
-
5596
- case 'options':
5597
- case 'data':
5598
- break;
5599
-
5600
- default:
5601
- console.error("PopperJS: an invalid property has been provided to the \"" + modifier.name + "\" modifier, valid properties are " + VALID_PROPERTIES.map(function (s) {
5602
- return "\"" + s + "\"";
5603
- }).join(', ') + "; but \"" + key + "\" was provided.");
5604
- }
5605
-
5606
- modifier.requires && modifier.requires.forEach(function (requirement) {
5607
- if (modifiers.find(function (mod) {
5608
- return mod.name === requirement;
5609
- }) == null) {
5610
- console.error(format(MISSING_DEPENDENCY_ERROR, String(modifier.name), requirement, requirement));
5611
- }
5612
- });
5613
- });
5614
- });
5654
+ const platform = {
5655
+ convertOffsetParentRelativeRectToViewportRelativeRect,
5656
+ getDocumentElement,
5657
+ getClippingRect,
5658
+ getOffsetParent,
5659
+ getElementRects,
5660
+ getClientRects,
5661
+ getDimensions,
5662
+ getScale,
5663
+ isElement,
5664
+ isRTL
5665
+ };
5666
+
5667
+ function rectsAreEqual(a, b) {
5668
+ return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
5615
5669
  }
5616
5670
 
5617
- function uniqueBy(arr, fn) {
5618
- var identifiers = new Set();
5619
- return arr.filter(function (item) {
5620
- var identifier = fn(item);
5621
-
5622
- if (!identifiers.has(identifier)) {
5623
- identifiers.add(identifier);
5624
- return true;
5671
+ // https://samthor.au/2021/observing-dom/
5672
+ function observeMove(element, onMove) {
5673
+ let io = null;
5674
+ let timeoutId;
5675
+ const root = getDocumentElement(element);
5676
+ function cleanup() {
5677
+ var _io;
5678
+ clearTimeout(timeoutId);
5679
+ (_io = io) == null || _io.disconnect();
5680
+ io = null;
5681
+ }
5682
+ function refresh(skip, threshold) {
5683
+ if (skip === void 0) {
5684
+ skip = false;
5685
+ }
5686
+ if (threshold === void 0) {
5687
+ threshold = 1;
5688
+ }
5689
+ cleanup();
5690
+ const elementRectForRootMargin = element.getBoundingClientRect();
5691
+ const {
5692
+ left,
5693
+ top,
5694
+ width,
5695
+ height
5696
+ } = elementRectForRootMargin;
5697
+ if (!skip) {
5698
+ onMove();
5699
+ }
5700
+ if (!width || !height) {
5701
+ return;
5702
+ }
5703
+ const insetTop = floor(top);
5704
+ const insetRight = floor(root.clientWidth - (left + width));
5705
+ const insetBottom = floor(root.clientHeight - (top + height));
5706
+ const insetLeft = floor(left);
5707
+ const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
5708
+ const options = {
5709
+ rootMargin,
5710
+ threshold: max(0, min(1, threshold)) || 1
5711
+ };
5712
+ let isFirstUpdate = true;
5713
+ function handleObserve(entries) {
5714
+ const ratio = entries[0].intersectionRatio;
5715
+ if (ratio !== threshold) {
5716
+ if (!isFirstUpdate) {
5717
+ return refresh();
5718
+ }
5719
+ if (!ratio) {
5720
+ // If the reference is clipped, the ratio is 0. Throttle the refresh
5721
+ // to prevent an infinite loop of updates.
5722
+ timeoutId = setTimeout(() => {
5723
+ refresh(false, 1e-7);
5724
+ }, 1000);
5725
+ } else {
5726
+ refresh(false, ratio);
5727
+ }
5728
+ }
5729
+ if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
5730
+ // It's possible that even though the ratio is reported as 1, the
5731
+ // element is not actually fully within the IntersectionObserver's root
5732
+ // area anymore. This can happen under performance constraints. This may
5733
+ // be a bug in the browser's IntersectionObserver implementation. To
5734
+ // work around this, we compare the element's bounding rect now with
5735
+ // what it was at the time we created the IntersectionObserver. If they
5736
+ // are not equal then the element moved, so we refresh.
5737
+ refresh();
5738
+ }
5739
+ isFirstUpdate = false;
5625
5740
  }
5626
- });
5627
- }
5628
-
5629
- function mergeByName(modifiers) {
5630
- var merged = modifiers.reduce(function (merged, current) {
5631
- var existing = merged[current.name];
5632
- merged[current.name] = existing ? Object.assign(Object.assign(Object.assign({}, existing), current), {}, {
5633
- options: Object.assign(Object.assign({}, existing.options), current.options),
5634
- data: Object.assign(Object.assign({}, existing.data), current.data)
5635
- }) : current;
5636
- return merged;
5637
- }, {}); // IE11 does not support Object.values
5638
-
5639
- return Object.keys(merged).map(function (key) {
5640
- return merged[key];
5641
- });
5642
- }
5643
-
5644
- var INVALID_ELEMENT_ERROR = 'Popper: Invalid reference or popper argument provided. They must be either a DOM element or virtual element.';
5645
- var INFINITE_LOOP_ERROR = 'Popper: An infinite loop in the modifiers cycle has been detected! The cycle has been interrupted to prevent a browser crash.';
5646
- var DEFAULT_OPTIONS$1 = {
5647
- placement: 'bottom',
5648
- modifiers: [],
5649
- strategy: 'absolute'
5650
- };
5651
5741
 
5652
- function areValidElements() {
5653
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
5654
- args[_key] = arguments[_key];
5742
+ // Older browsers don't support a `document` as the root and will throw an
5743
+ // error.
5744
+ try {
5745
+ io = new IntersectionObserver(handleObserve, {
5746
+ ...options,
5747
+ // Handle <iframe>s
5748
+ root: root.ownerDocument
5749
+ });
5750
+ } catch (_e) {
5751
+ io = new IntersectionObserver(handleObserve, options);
5752
+ }
5753
+ io.observe(element);
5655
5754
  }
5656
-
5657
- return !args.some(function (element) {
5658
- return !(element && typeof element.getBoundingClientRect === 'function');
5659
- });
5755
+ refresh(true);
5756
+ return cleanup;
5660
5757
  }
5661
5758
 
5662
- function popperGenerator(generatorOptions) {
5663
- if (generatorOptions === void 0) {
5664
- generatorOptions = {};
5759
+ /**
5760
+ * Automatically updates the position of the floating element when necessary.
5761
+ * Should only be called when the floating element is mounted on the DOM or
5762
+ * visible on the screen.
5763
+ * @returns cleanup function that should be invoked when the floating element is
5764
+ * removed from the DOM or hidden from the screen.
5765
+ * @see https://floating-ui.com/docs/autoUpdate
5766
+ */
5767
+ function autoUpdate(reference, floating, update, options) {
5768
+ if (options === void 0) {
5769
+ options = {};
5665
5770
  }
5666
-
5667
- var _generatorOptions = generatorOptions,
5668
- _generatorOptions$def = _generatorOptions.defaultModifiers,
5669
- defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,
5670
- _generatorOptions$def2 = _generatorOptions.defaultOptions,
5671
- defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS$1 : _generatorOptions$def2;
5672
- return function createPopper(reference, popper, options) {
5673
- if (options === void 0) {
5674
- options = defaultOptions;
5771
+ const {
5772
+ ancestorScroll = true,
5773
+ ancestorResize = true,
5774
+ elementResize = typeof ResizeObserver === 'function',
5775
+ layoutShift = typeof IntersectionObserver === 'function',
5776
+ animationFrame = false
5777
+ } = options;
5778
+ const referenceEl = unwrapElement(reference);
5779
+ const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
5780
+ ancestors.forEach(ancestor => {
5781
+ ancestorScroll && ancestor.addEventListener('scroll', update, {
5782
+ passive: true
5783
+ });
5784
+ ancestorResize && ancestor.addEventListener('resize', update);
5785
+ });
5786
+ const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
5787
+ let reobserveFrame = -1;
5788
+ let resizeObserver = null;
5789
+ if (elementResize) {
5790
+ resizeObserver = new ResizeObserver(_ref => {
5791
+ let [firstEntry] = _ref;
5792
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
5793
+ // Prevent update loops when using the `size` middleware.
5794
+ // https://github.com/floating-ui/floating-ui/issues/1740
5795
+ resizeObserver.unobserve(floating);
5796
+ cancelAnimationFrame(reobserveFrame);
5797
+ reobserveFrame = requestAnimationFrame(() => {
5798
+ var _resizeObserver;
5799
+ (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
5800
+ });
5801
+ }
5802
+ update();
5803
+ });
5804
+ if (referenceEl && !animationFrame) {
5805
+ resizeObserver.observe(referenceEl);
5675
5806
  }
5807
+ resizeObserver.observe(floating);
5808
+ }
5809
+ let frameId;
5810
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
5811
+ if (animationFrame) {
5812
+ frameLoop();
5813
+ }
5814
+ function frameLoop() {
5815
+ const nextRefRect = getBoundingClientRect(reference);
5816
+ if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
5817
+ update();
5818
+ }
5819
+ prevRefRect = nextRefRect;
5820
+ frameId = requestAnimationFrame(frameLoop);
5821
+ }
5822
+ update();
5823
+ return () => {
5824
+ var _resizeObserver2;
5825
+ ancestors.forEach(ancestor => {
5826
+ ancestorScroll && ancestor.removeEventListener('scroll', update);
5827
+ ancestorResize && ancestor.removeEventListener('resize', update);
5828
+ });
5829
+ cleanupIo == null || cleanupIo();
5830
+ (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
5831
+ resizeObserver = null;
5832
+ if (animationFrame) {
5833
+ cancelAnimationFrame(frameId);
5834
+ }
5835
+ };
5836
+ }
5676
5837
 
5677
- var state = {
5678
- placement: 'bottom',
5679
- orderedModifiers: [],
5680
- options: Object.assign(Object.assign({}, DEFAULT_OPTIONS$1), defaultOptions),
5681
- modifiersData: {},
5682
- elements: {
5683
- reference: reference,
5684
- popper: popper
5685
- },
5686
- attributes: {},
5687
- styles: {}
5688
- };
5689
- var effectCleanupFns = [];
5690
- var isDestroyed = false;
5691
- var instance = {
5692
- state: state,
5693
- setOptions: function setOptions(options) {
5694
- cleanupModifierEffects();
5695
- state.options = Object.assign(Object.assign(Object.assign({}, defaultOptions), state.options), options);
5696
- state.scrollParents = {
5697
- reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
5698
- popper: listScrollParents(popper)
5699
- }; // Orders the modifiers based on their dependencies and `phase`
5700
- // properties
5701
-
5702
- var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers
5703
-
5704
- state.orderedModifiers = orderedModifiers.filter(function (m) {
5705
- return m.enabled;
5706
- }); // Validate the provided modifiers so that the consumer will get warned
5707
- // if one of the modifiers is invalid for any reason
5708
-
5709
- if (process.env.NODE_ENV !== "production") {
5710
- var modifiers = uniqueBy([].concat(orderedModifiers, state.options.modifiers), function (_ref) {
5711
- var name = _ref.name;
5712
- return name;
5713
- });
5714
- validateModifiers(modifiers);
5715
-
5716
- if (getBasePlacement(state.options.placement) === auto) {
5717
- var flipModifier = state.orderedModifiers.find(function (_ref2) {
5718
- var name = _ref2.name;
5719
- return name === 'flip';
5720
- });
5721
-
5722
- if (!flipModifier) {
5723
- console.error(['Popper: "auto" placements require the "flip" modifier be', 'present and enabled to work.'].join(' '));
5724
- }
5725
- }
5726
-
5727
- var _getComputedStyle = getComputedStyle(popper),
5728
- marginTop = _getComputedStyle.marginTop,
5729
- marginRight = _getComputedStyle.marginRight,
5730
- marginBottom = _getComputedStyle.marginBottom,
5731
- marginLeft = _getComputedStyle.marginLeft; // We no longer take into account `margins` on the popper, and it can
5732
- // cause bugs with positioning, so we'll warn the consumer
5733
-
5838
+ /**
5839
+ * Modifies the placement by translating the floating element along the
5840
+ * specified axes.
5841
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
5842
+ * object may be passed.
5843
+ * @see https://floating-ui.com/docs/offset
5844
+ */
5845
+ const offset$1 = offset$2;
5734
5846
 
5735
- if ([marginTop, marginRight, marginBottom, marginLeft].some(function (margin) {
5736
- return parseFloat(margin);
5737
- })) {
5738
- console.warn(['Popper: CSS "margin" styles cannot be used to apply padding', 'between the popper and its reference element or boundary.', 'To replicate margin, use the `offset` modifier, as well as', 'the `padding` option in the `preventOverflow` and `flip`', 'modifiers.'].join(' '));
5739
- }
5740
- }
5847
+ /**
5848
+ * Optimizes the visibility of the floating element by choosing the placement
5849
+ * that has the most space available automatically, without needing to specify a
5850
+ * preferred placement. Alternative to `flip`.
5851
+ * @see https://floating-ui.com/docs/autoPlacement
5852
+ */
5853
+ const autoPlacement$1 = autoPlacement$2;
5741
5854
 
5742
- runModifierEffects();
5743
- return instance.update();
5744
- },
5745
- // Sync update – it will always be executed, even if not necessary. This
5746
- // is useful for low frequency updates where sync behavior simplifies the
5747
- // logic.
5748
- // For high frequency updates (e.g. `resize` and `scroll` events), always
5749
- // prefer the async Popper#update method
5750
- forceUpdate: function forceUpdate() {
5751
- if (isDestroyed) {
5752
- return;
5753
- }
5855
+ /**
5856
+ * Optimizes the visibility of the floating element by shifting it in order to
5857
+ * keep it in view when it will overflow the clipping boundary.
5858
+ * @see https://floating-ui.com/docs/shift
5859
+ */
5860
+ const shift$1 = shift$2;
5754
5861
 
5755
- var _state$elements = state.elements,
5756
- reference = _state$elements.reference,
5757
- popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements
5758
- // anymore
5862
+ /**
5863
+ * Optimizes the visibility of the floating element by flipping the `placement`
5864
+ * in order to keep it in view when the preferred placement(s) will overflow the
5865
+ * clipping boundary. Alternative to `autoPlacement`.
5866
+ * @see https://floating-ui.com/docs/flip
5867
+ */
5868
+ const flip$1 = flip$2;
5759
5869
 
5760
- if (!areValidElements(reference, popper)) {
5761
- if (process.env.NODE_ENV !== "production") {
5762
- console.error(INVALID_ELEMENT_ERROR);
5763
- }
5870
+ /**
5871
+ * Provides data that allows you to change the size of the floating element —
5872
+ * for instance, prevent it from overflowing the clipping boundary or match the
5873
+ * width of the reference element.
5874
+ * @see https://floating-ui.com/docs/size
5875
+ */
5876
+ const size$1 = size$2;
5764
5877
 
5765
- return;
5766
- } // Store the reference and popper rects to be read by modifiers
5767
-
5768
-
5769
- state.rects = {
5770
- reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),
5771
- popper: getLayoutRect(popper)
5772
- }; // Modifiers have the ability to reset the current update cycle. The
5773
- // most common use case for this is the `flip` modifier changing the
5774
- // placement, which then needs to re-run all the modifiers, because the
5775
- // logic was previously ran for the previous placement and is therefore
5776
- // stale/incorrect
5777
-
5778
- state.reset = false;
5779
- state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier
5780
- // is filled with the initial data specified by the modifier. This means
5781
- // it doesn't persist and is fresh on each update.
5782
- // To ensure persistent data, use `${name}#persistent`
5783
-
5784
- state.orderedModifiers.forEach(function (modifier) {
5785
- return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
5786
- });
5787
- var __debug_loops__ = 0;
5878
+ /**
5879
+ * Provides data to position an inner element of the floating element so that it
5880
+ * appears centered to the reference element.
5881
+ * @see https://floating-ui.com/docs/arrow
5882
+ */
5883
+ const arrow$2 = arrow$3;
5788
5884
 
5789
- for (var index = 0; index < state.orderedModifiers.length; index++) {
5790
- if (process.env.NODE_ENV !== "production") {
5791
- __debug_loops__ += 1;
5885
+ /**
5886
+ * Computes the `x` and `y` coordinates that will place the floating element
5887
+ * next to a given reference element.
5888
+ */
5889
+ const computePosition = (reference, floating, options) => {
5890
+ // This caches the expensive `getClippingElementAncestors` function so that
5891
+ // multiple lifecycle resets re-use the same result. It only lives for a
5892
+ // single call. If other functions become expensive, we can add them as well.
5893
+ const cache = new Map();
5894
+ const mergedOptions = {
5895
+ platform,
5896
+ ...options
5897
+ };
5898
+ const platformWithCache = {
5899
+ ...mergedOptions.platform,
5900
+ _c: cache
5901
+ };
5902
+ return computePosition$1(reference, floating, {
5903
+ ...mergedOptions,
5904
+ platform: platformWithCache
5905
+ });
5906
+ };
5792
5907
 
5793
- if (__debug_loops__ > 100) {
5794
- console.error(INFINITE_LOOP_ERROR);
5795
- break;
5796
- }
5797
- }
5908
+ var isClient = typeof document !== 'undefined';
5798
5909
 
5799
- if (state.reset === true) {
5800
- state.reset = false;
5801
- index = -1;
5802
- continue;
5803
- }
5910
+ var noop = function noop() {};
5911
+ var index = isClient ? useLayoutEffect : noop;
5804
5912
 
5805
- var _state$orderedModifie = state.orderedModifiers[index],
5806
- fn = _state$orderedModifie.fn,
5807
- _state$orderedModifie2 = _state$orderedModifie.options,
5808
- _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,
5809
- name = _state$orderedModifie.name;
5810
-
5811
- if (typeof fn === 'function') {
5812
- state = fn({
5813
- state: state,
5814
- options: _options,
5815
- name: name,
5816
- instance: instance
5817
- }) || state;
5818
- }
5913
+ // Fork of `fast-deep-equal` that only does the comparisons we need and compares
5914
+ // functions
5915
+ function deepEqual(a, b) {
5916
+ if (a === b) {
5917
+ return true;
5918
+ }
5919
+ if (typeof a !== typeof b) {
5920
+ return false;
5921
+ }
5922
+ if (typeof a === 'function' && a.toString() === b.toString()) {
5923
+ return true;
5924
+ }
5925
+ let length;
5926
+ let i;
5927
+ let keys;
5928
+ if (a && b && typeof a === 'object') {
5929
+ if (Array.isArray(a)) {
5930
+ length = a.length;
5931
+ if (length !== b.length) return false;
5932
+ for (i = length; i-- !== 0;) {
5933
+ if (!deepEqual(a[i], b[i])) {
5934
+ return false;
5819
5935
  }
5820
- },
5821
- // Async and optimistically optimized update – it will not be executed if
5822
- // not necessary (debounced to run at most once-per-tick)
5823
- update: debounce(function () {
5824
- return new Promise(function (resolve) {
5825
- instance.forceUpdate();
5826
- resolve(state);
5827
- });
5828
- }),
5829
- destroy: function destroy() {
5830
- cleanupModifierEffects();
5831
- isDestroyed = true;
5832
5936
  }
5833
- };
5834
-
5835
- if (!areValidElements(reference, popper)) {
5836
- if (process.env.NODE_ENV !== "production") {
5837
- console.error(INVALID_ELEMENT_ERROR);
5937
+ return true;
5938
+ }
5939
+ keys = Object.keys(a);
5940
+ length = keys.length;
5941
+ if (length !== Object.keys(b).length) {
5942
+ return false;
5943
+ }
5944
+ for (i = length; i-- !== 0;) {
5945
+ if (!{}.hasOwnProperty.call(b, keys[i])) {
5946
+ return false;
5838
5947
  }
5839
-
5840
- return instance;
5841
5948
  }
5842
-
5843
- instance.setOptions(options).then(function (state) {
5844
- if (!isDestroyed && options.onFirstUpdate) {
5845
- options.onFirstUpdate(state);
5949
+ for (i = length; i-- !== 0;) {
5950
+ const key = keys[i];
5951
+ if (key === '_owner' && a.$$typeof) {
5952
+ continue;
5953
+ }
5954
+ if (!deepEqual(a[key], b[key])) {
5955
+ return false;
5846
5956
  }
5847
- }); // Modifiers have the ability to execute arbitrary code before the first
5848
- // update cycle runs. They will be executed in the same order as the update
5849
- // cycle. This is useful when a modifier adds some persistent data that
5850
- // other modifiers need to use, but the modifier is run after the dependent
5851
- // one.
5852
-
5853
- function runModifierEffects() {
5854
- state.orderedModifiers.forEach(function (_ref3) {
5855
- var name = _ref3.name,
5856
- _ref3$options = _ref3.options,
5857
- options = _ref3$options === void 0 ? {} : _ref3$options,
5858
- effect = _ref3.effect;
5859
-
5860
- if (typeof effect === 'function') {
5861
- var cleanupFn = effect({
5862
- state: state,
5863
- name: name,
5864
- instance: instance,
5865
- options: options
5866
- });
5867
-
5868
- var noopFn = function noopFn() {};
5869
-
5870
- effectCleanupFns.push(cleanupFn || noopFn);
5871
- }
5872
- });
5873
5957
  }
5958
+ return true;
5959
+ }
5960
+ return a !== a && b !== b;
5961
+ }
5874
5962
 
5875
- function cleanupModifierEffects() {
5876
- effectCleanupFns.forEach(function (fn) {
5877
- return fn();
5878
- });
5879
- effectCleanupFns = [];
5880
- }
5963
+ function getDPR(element) {
5964
+ if (typeof window === 'undefined') {
5965
+ return 1;
5966
+ }
5967
+ const win = element.ownerDocument.defaultView || window;
5968
+ return win.devicePixelRatio || 1;
5969
+ }
5881
5970
 
5882
- return instance;
5883
- };
5971
+ function roundByDPR(element, value) {
5972
+ const dpr = getDPR(element);
5973
+ return Math.round(value * dpr) / dpr;
5974
+ }
5975
+
5976
+ function useLatestRef(value) {
5977
+ const ref = React.useRef(value);
5978
+ index(() => {
5979
+ ref.current = value;
5980
+ });
5981
+ return ref;
5884
5982
  }
5885
5983
 
5886
- var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
5887
- var createPopper = /*#__PURE__*/popperGenerator({
5888
- defaultModifiers: defaultModifiers
5889
- }); // eslint-disable-next-line import/no-unused-modules
5890
-
5891
- /**
5892
- * Simple ponyfill for Object.fromEntries
5893
- */
5894
-
5895
- var fromEntries = function fromEntries(entries) {
5896
- return entries.reduce(function (acc, _ref) {
5897
- var key = _ref[0],
5898
- value = _ref[1];
5899
- acc[key] = value;
5900
- return acc;
5901
- }, {});
5902
- };
5903
- /**
5904
- * Small wrapper around `useLayoutEffect` to get rid of the warning on SSR envs
5905
- */
5906
-
5907
- var useIsomorphicLayoutEffect = typeof window !== 'undefined' && window.document && window.document.createElement ? React.useLayoutEffect : React.useEffect;
5908
-
5909
- /* global Map:readonly, Set:readonly, ArrayBuffer:readonly */
5910
-
5911
- var reactFastCompare;
5912
- var hasRequiredReactFastCompare;
5913
-
5914
- function requireReactFastCompare () {
5915
- if (hasRequiredReactFastCompare) return reactFastCompare;
5916
- hasRequiredReactFastCompare = 1;
5917
- var hasElementType = typeof Element !== 'undefined';
5918
- var hasMap = typeof Map === 'function';
5919
- var hasSet = typeof Set === 'function';
5920
- var hasArrayBuffer = typeof ArrayBuffer === 'function' && !!ArrayBuffer.isView;
5921
-
5922
- // Note: We **don't** need `envHasBigInt64Array` in fde es6/index.js
5923
-
5924
- function equal(a, b) {
5925
- // START: fast-deep-equal es6/index.js 3.1.1
5926
- if (a === b) return true;
5927
-
5928
- if (a && b && typeof a == 'object' && typeof b == 'object') {
5929
- if (a.constructor !== b.constructor) return false;
5930
-
5931
- var length, i, keys;
5932
- if (Array.isArray(a)) {
5933
- length = a.length;
5934
- if (length != b.length) return false;
5935
- for (i = length; i-- !== 0;)
5936
- if (!equal(a[i], b[i])) return false;
5937
- return true;
5938
- }
5939
-
5940
- // START: Modifications:
5941
- // 1. Extra `has<Type> &&` helpers in initial condition allow es6 code
5942
- // to co-exist with es5.
5943
- // 2. Replace `for of` with es5 compliant iteration using `for`.
5944
- // Basically, take:
5945
- //
5946
- // ```js
5947
- // for (i of a.entries())
5948
- // if (!b.has(i[0])) return false;
5949
- // ```
5950
- //
5951
- // ... and convert to:
5952
- //
5953
- // ```js
5954
- // it = a.entries();
5955
- // while (!(i = it.next()).done)
5956
- // if (!b.has(i.value[0])) return false;
5957
- // ```
5958
- //
5959
- // **Note**: `i` access switches to `i.value`.
5960
- var it;
5961
- if (hasMap && (a instanceof Map) && (b instanceof Map)) {
5962
- if (a.size !== b.size) return false;
5963
- it = a.entries();
5964
- while (!(i = it.next()).done)
5965
- if (!b.has(i.value[0])) return false;
5966
- it = a.entries();
5967
- while (!(i = it.next()).done)
5968
- if (!equal(i.value[1], b.get(i.value[0]))) return false;
5969
- return true;
5970
- }
5971
-
5972
- if (hasSet && (a instanceof Set) && (b instanceof Set)) {
5973
- if (a.size !== b.size) return false;
5974
- it = a.entries();
5975
- while (!(i = it.next()).done)
5976
- if (!b.has(i.value[0])) return false;
5977
- return true;
5978
- }
5979
- // END: Modifications
5980
-
5981
- if (hasArrayBuffer && ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {
5982
- length = a.length;
5983
- if (length != b.length) return false;
5984
- for (i = length; i-- !== 0;)
5985
- if (a[i] !== b[i]) return false;
5986
- return true;
5987
- }
5988
-
5989
- if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
5990
- if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
5991
- if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
5992
-
5993
- keys = Object.keys(a);
5994
- length = keys.length;
5995
- if (length !== Object.keys(b).length) return false;
5996
-
5997
- for (i = length; i-- !== 0;)
5998
- if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
5999
- // END: fast-deep-equal
6000
-
6001
- // START: react-fast-compare
6002
- // custom handling for DOM elements
6003
- if (hasElementType && a instanceof Element) return false;
6004
-
6005
- // custom handling for React/Preact
6006
- for (i = length; i-- !== 0;) {
6007
- if ((keys[i] === '_owner' || keys[i] === '__v' || keys[i] === '__o') && a.$$typeof) {
6008
- // React-specific: avoid traversing React elements' _owner
6009
- // Preact-specific: avoid traversing Preact elements' __v and __o
6010
- // __v = $_original / $_vnode
6011
- // __o = $_owner
6012
- // These properties contain circular references and are not needed when
6013
- // comparing the actual elements (and not their owners)
6014
- // .$$typeof and ._store on just reasonable markers of elements
6015
-
6016
- continue;
6017
- }
6018
-
6019
- // all other properties should be traversed as usual
6020
- if (!equal(a[keys[i]], b[keys[i]])) return false;
6021
- }
6022
- // END: react-fast-compare
6023
-
6024
- // START: fast-deep-equal
6025
- return true;
6026
- }
6027
-
6028
- return a !== a && b !== b;
6029
- }
6030
- // end fast-deep-equal
6031
-
6032
- reactFastCompare = function isEqual(a, b) {
6033
- try {
6034
- return equal(a, b);
6035
- } catch (error) {
6036
- if (((error.message || '').match(/stack|recursion/i))) {
6037
- // warn on circular references, don't crash
6038
- // browsers give this different errors name and messages:
6039
- // chrome/safari: "RangeError", "Maximum call stack size exceeded"
6040
- // firefox: "InternalError", too much recursion"
6041
- // edge: "Error", "Out of stack space"
6042
- console.warn('react-fast-compare cannot handle circular refs');
6043
- return false;
6044
- }
6045
- // some other error. we should definitely know about these
6046
- throw error;
6047
- }
6048
- };
6049
- return reactFastCompare;
6050
- }
6051
-
6052
- var reactFastCompareExports = requireReactFastCompare();
6053
- var isEqual$1 = /*@__PURE__*/getDefaultExportFromCjs(reactFastCompareExports);
6054
-
6055
- var EMPTY_MODIFIERS = [];
6056
- var usePopper$1 = function usePopper(referenceElement, popperElement, options) {
5984
+ /**
5985
+ * Provides data to position a floating element.
5986
+ * @see https://floating-ui.com/docs/useFloating
5987
+ */
5988
+ function useFloating(options) {
6057
5989
  if (options === void 0) {
6058
5990
  options = {};
6059
5991
  }
6060
-
6061
- var prevOptions = React.useRef(null);
6062
- var optionsWithDefaults = {
6063
- onFirstUpdate: options.onFirstUpdate,
6064
- placement: options.placement || 'bottom',
6065
- strategy: options.strategy || 'absolute',
6066
- modifiers: options.modifiers || EMPTY_MODIFIERS
6067
- };
6068
-
6069
- var _React$useState = React.useState({
6070
- styles: {
6071
- popper: {
6072
- position: optionsWithDefaults.strategy,
6073
- left: '0',
6074
- top: '0'
6075
- }
6076
- },
6077
- attributes: {}
6078
- }),
6079
- state = _React$useState[0],
6080
- setState = _React$useState[1];
6081
-
6082
- var updateStateModifier = React.useMemo(function () {
6083
- return {
6084
- name: 'updateState',
6085
- enabled: true,
6086
- phase: 'write',
6087
- fn: function fn(_ref) {
6088
- var state = _ref.state;
6089
- var elements = Object.keys(state.elements);
6090
- setState({
6091
- styles: fromEntries(elements.map(function (element) {
6092
- return [element, state.styles[element] || {}];
6093
- })),
6094
- attributes: fromEntries(elements.map(function (element) {
6095
- return [element, state.attributes[element]];
6096
- }))
5992
+ const {
5993
+ placement = 'bottom',
5994
+ strategy = 'absolute',
5995
+ middleware = [],
5996
+ platform,
5997
+ elements: {
5998
+ reference: externalReference,
5999
+ floating: externalFloating
6000
+ } = {},
6001
+ transform = true,
6002
+ whileElementsMounted,
6003
+ open
6004
+ } = options;
6005
+ const [data, setData] = React.useState({
6006
+ x: 0,
6007
+ y: 0,
6008
+ strategy,
6009
+ placement,
6010
+ middlewareData: {},
6011
+ isPositioned: false
6012
+ });
6013
+ const [latestMiddleware, setLatestMiddleware] = React.useState(middleware);
6014
+ if (!deepEqual(latestMiddleware, middleware)) {
6015
+ setLatestMiddleware(middleware);
6016
+ }
6017
+ const [_reference, _setReference] = React.useState(null);
6018
+ const [_floating, _setFloating] = React.useState(null);
6019
+ const setReference = React.useCallback(node => {
6020
+ if (node !== referenceRef.current) {
6021
+ referenceRef.current = node;
6022
+ _setReference(node);
6023
+ }
6024
+ }, []);
6025
+ const setFloating = React.useCallback(node => {
6026
+ if (node !== floatingRef.current) {
6027
+ floatingRef.current = node;
6028
+ _setFloating(node);
6029
+ }
6030
+ }, []);
6031
+ const referenceEl = externalReference || _reference;
6032
+ const floatingEl = externalFloating || _floating;
6033
+ const referenceRef = React.useRef(null);
6034
+ const floatingRef = React.useRef(null);
6035
+ const dataRef = React.useRef(data);
6036
+ const hasWhileElementsMounted = whileElementsMounted != null;
6037
+ const whileElementsMountedRef = useLatestRef(whileElementsMounted);
6038
+ const platformRef = useLatestRef(platform);
6039
+ const openRef = useLatestRef(open);
6040
+ const update = React.useCallback(() => {
6041
+ if (!referenceRef.current || !floatingRef.current) {
6042
+ return;
6043
+ }
6044
+ const config = {
6045
+ placement,
6046
+ strategy,
6047
+ middleware: latestMiddleware
6048
+ };
6049
+ if (platformRef.current) {
6050
+ config.platform = platformRef.current;
6051
+ }
6052
+ computePosition(referenceRef.current, floatingRef.current, config).then(data => {
6053
+ const fullData = {
6054
+ ...data,
6055
+ // The floating element's position may be recomputed while it's closed
6056
+ // but still mounted (such as when transitioning out). To ensure
6057
+ // `isPositioned` will be `false` initially on the next open, avoid
6058
+ // setting it to `true` when `open === false` (must be specified).
6059
+ isPositioned: openRef.current !== false
6060
+ };
6061
+ if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
6062
+ dataRef.current = fullData;
6063
+ ReactDOM.flushSync(() => {
6064
+ setData(fullData);
6097
6065
  });
6098
- },
6099
- requires: ['computeStyles']
6066
+ }
6067
+ });
6068
+ }, [latestMiddleware, placement, strategy, platformRef, openRef]);
6069
+ index(() => {
6070
+ if (open === false && dataRef.current.isPositioned) {
6071
+ dataRef.current.isPositioned = false;
6072
+ setData(data => ({
6073
+ ...data,
6074
+ isPositioned: false
6075
+ }));
6076
+ }
6077
+ }, [open]);
6078
+ const isMountedRef = React.useRef(false);
6079
+ index(() => {
6080
+ isMountedRef.current = true;
6081
+ return () => {
6082
+ isMountedRef.current = false;
6100
6083
  };
6101
6084
  }, []);
6102
- var popperOptions = React.useMemo(function () {
6103
- var newOptions = {
6104
- onFirstUpdate: optionsWithDefaults.onFirstUpdate,
6105
- placement: optionsWithDefaults.placement,
6106
- strategy: optionsWithDefaults.strategy,
6107
- modifiers: [].concat(optionsWithDefaults.modifiers, [updateStateModifier, {
6108
- name: 'applyStyles',
6109
- enabled: false
6110
- }])
6085
+ index(() => {
6086
+ if (referenceEl) referenceRef.current = referenceEl;
6087
+ if (floatingEl) floatingRef.current = floatingEl;
6088
+ if (referenceEl && floatingEl) {
6089
+ if (whileElementsMountedRef.current) {
6090
+ return whileElementsMountedRef.current(referenceEl, floatingEl, update);
6091
+ }
6092
+ update();
6093
+ }
6094
+ }, [referenceEl, floatingEl, update, whileElementsMountedRef, hasWhileElementsMounted]);
6095
+ const refs = React.useMemo(() => ({
6096
+ reference: referenceRef,
6097
+ floating: floatingRef,
6098
+ setReference,
6099
+ setFloating
6100
+ }), [setReference, setFloating]);
6101
+ const elements = React.useMemo(() => ({
6102
+ reference: referenceEl,
6103
+ floating: floatingEl
6104
+ }), [referenceEl, floatingEl]);
6105
+ const floatingStyles = React.useMemo(() => {
6106
+ const initialStyles = {
6107
+ position: strategy,
6108
+ left: 0,
6109
+ top: 0
6111
6110
  };
6112
-
6113
- if (isEqual$1(prevOptions.current, newOptions)) {
6114
- return prevOptions.current || newOptions;
6115
- } else {
6116
- prevOptions.current = newOptions;
6117
- return newOptions;
6118
- }
6119
- }, [optionsWithDefaults.onFirstUpdate, optionsWithDefaults.placement, optionsWithDefaults.strategy, optionsWithDefaults.modifiers, updateStateModifier]);
6120
- var popperInstanceRef = React.useRef();
6121
- useIsomorphicLayoutEffect(function () {
6122
- if (popperInstanceRef.current) {
6123
- popperInstanceRef.current.setOptions(popperOptions);
6124
- }
6125
- }, [popperOptions]);
6126
- useIsomorphicLayoutEffect(function () {
6127
- if (referenceElement == null || popperElement == null) {
6128
- return;
6111
+ if (!elements.floating) {
6112
+ return initialStyles;
6129
6113
  }
6130
-
6131
- var createPopper$1 = options.createPopper || createPopper;
6132
- var popperInstance = createPopper$1(referenceElement, popperElement, popperOptions);
6133
- popperInstanceRef.current = popperInstance;
6134
- return function () {
6135
- popperInstance.destroy();
6136
- popperInstanceRef.current = null;
6114
+ const x = roundByDPR(elements.floating, data.x);
6115
+ const y = roundByDPR(elements.floating, data.y);
6116
+ if (transform) {
6117
+ return {
6118
+ ...initialStyles,
6119
+ transform: "translate(" + x + "px, " + y + "px)",
6120
+ ...(getDPR(elements.floating) >= 1.5 && {
6121
+ willChange: 'transform'
6122
+ })
6123
+ };
6124
+ }
6125
+ return {
6126
+ position: strategy,
6127
+ left: x,
6128
+ top: y
6137
6129
  };
6138
- }, [referenceElement, popperElement, options.createPopper]);
6130
+ }, [strategy, transform, elements.floating, data.x, data.y]);
6131
+ return React.useMemo(() => ({
6132
+ ...data,
6133
+ update,
6134
+ refs,
6135
+ elements,
6136
+ floatingStyles
6137
+ }), [data, update, refs, elements, floatingStyles]);
6138
+ }
6139
+
6140
+ /**
6141
+ * Provides data to position an inner element of the floating element so that it
6142
+ * appears centered to the reference element.
6143
+ * This wraps the core `arrow` middleware to allow React refs as the element.
6144
+ * @see https://floating-ui.com/docs/arrow
6145
+ */
6146
+ const arrow$1 = options => {
6147
+ function isRef(value) {
6148
+ return {}.hasOwnProperty.call(value, 'current');
6149
+ }
6139
6150
  return {
6140
- state: popperInstanceRef.current ? popperInstanceRef.current.state : null,
6141
- styles: state.styles,
6142
- attributes: state.attributes,
6143
- update: popperInstanceRef.current ? popperInstanceRef.current.update : null,
6144
- forceUpdate: popperInstanceRef.current ? popperInstanceRef.current.forceUpdate : null
6151
+ name: 'arrow',
6152
+ options,
6153
+ fn(state) {
6154
+ const {
6155
+ element,
6156
+ padding
6157
+ } = typeof options === 'function' ? options(state) : options;
6158
+ if (element && isRef(element)) {
6159
+ if (element.current != null) {
6160
+ return arrow$2({
6161
+ element: element.current,
6162
+ padding
6163
+ }).fn(state);
6164
+ }
6165
+ return {};
6166
+ }
6167
+ if (element) {
6168
+ return arrow$2({
6169
+ element,
6170
+ padding
6171
+ }).fn(state);
6172
+ }
6173
+ return {};
6174
+ }
6145
6175
  };
6146
6176
  };
6147
6177
 
6148
- /** Stub usePopper for use outside of browsers */
6149
- const useStubPopper = (_a, _p, {
6150
- placement
6151
- }) => ({
6152
- attributes: {
6153
- popper: {
6154
- 'data-popper-placement': placement
6155
- }
6156
- },
6157
- styles: {
6158
- popper: {
6159
- transform: 'translate(1, 1)'
6160
- }
6161
- }
6178
+ /**
6179
+ * Modifies the placement by translating the floating element along the
6180
+ * specified axes.
6181
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
6182
+ * object may be passed.
6183
+ * @see https://floating-ui.com/docs/offset
6184
+ */
6185
+ const offset = (options, deps) => ({
6186
+ ...offset$1(options),
6187
+ options: [options, deps]
6162
6188
  });
6163
6189
 
6164
- /** Switch hook implementation between environment */
6165
- const usePopper = IS_BROWSER ? usePopper$1 : useStubPopper;
6190
+ /**
6191
+ * Optimizes the visibility of the floating element by shifting it in order to
6192
+ * keep it in view when it will overflow the clipping boundary.
6193
+ * @see https://floating-ui.com/docs/shift
6194
+ */
6195
+ const shift = (options, deps) => ({
6196
+ ...shift$1(options),
6197
+ options: [options, deps]
6198
+ });
6199
+
6200
+ /**
6201
+ * Optimizes the visibility of the floating element by flipping the `placement`
6202
+ * in order to keep it in view when the preferred placement(s) will overflow the
6203
+ * clipping boundary. Alternative to `autoPlacement`.
6204
+ * @see https://floating-ui.com/docs/flip
6205
+ */
6206
+ const flip = (options, deps) => ({
6207
+ ...flip$1(options),
6208
+ options: [options, deps]
6209
+ });
6210
+
6211
+ /**
6212
+ * Provides data that allows you to change the size of the floating element —
6213
+ * for instance, prevent it from overflowing the clipping boundary or match the
6214
+ * width of the reference element.
6215
+ * @see https://floating-ui.com/docs/size
6216
+ */
6217
+ const size = (options, deps) => ({
6218
+ ...size$1(options),
6219
+ options: [options, deps]
6220
+ });
6221
+
6222
+ /**
6223
+ * Optimizes the visibility of the floating element by choosing the placement
6224
+ * that has the most space available automatically, without needing to specify a
6225
+ * preferred placement. Alternative to `flip`.
6226
+ * @see https://floating-ui.com/docs/autoPlacement
6227
+ */
6228
+ const autoPlacement = (options, deps) => ({
6229
+ ...autoPlacement$1(options),
6230
+ options: [options, deps]
6231
+ });
6232
+
6233
+ /**
6234
+ * Provides data to position an inner element of the floating element so that it
6235
+ * appears centered to the reference element.
6236
+ * This wraps the core `arrow` middleware to allow React refs as the element.
6237
+ * @see https://floating-ui.com/docs/arrow
6238
+ */
6239
+ const arrow = (options, deps) => ({
6240
+ ...arrow$1(options),
6241
+ options: [options, deps]
6242
+ });
6166
6243
 
6167
6244
  /**
6168
6245
  * Different possible placements for the popover.
@@ -6208,81 +6285,30 @@ const ARROW_SIZE$1 = 14;
6208
6285
  */
6209
6286
  const POPOVER_ZINDEX = 9999;
6210
6287
 
6211
- /**
6212
- * Popper js modifier to fit popover min width to the anchor width.
6213
- */
6214
- const sameWidth = memoize(anchorWidthOption => ({
6215
- name: 'sameWidth',
6216
- enabled: true,
6217
- phase: 'beforeWrite',
6218
- requires: ['computeStyles'],
6219
- fn({
6220
- state
6221
- }) {
6222
- // eslint-disable-next-line no-param-reassign
6223
- state.styles.popper[anchorWidthOption] = `${state.rects.reference.width}px`;
6224
- },
6225
- effect({
6226
- state
6227
- }) {
6228
- // eslint-disable-next-line no-param-reassign
6229
- state.elements.popper.style[anchorWidthOption] = `${state.elements.reference.offsetWidth}px`;
6230
- }
6231
- }));
6232
-
6233
- /**
6234
- * Popper js modifier to compute max size of the popover.
6235
- */
6236
- const maxSize = {
6237
- name: 'maxSize',
6238
- enabled: true,
6239
- phase: 'main',
6240
- requiresIfExists: ['offset', 'preventOverflow', 'flip'],
6241
- fn({
6242
- state,
6243
- name,
6244
- options
6245
- }) {
6246
- const overflow = detectOverflow(state, options);
6247
- const {
6248
- y = 0,
6249
- x = 0
6250
- } = state.modifiersData.preventOverflow;
6251
- const {
6252
- width,
6253
- height
6254
- } = state.rects.popper;
6255
- const [basePlacement] = state.placement.split('-');
6256
- const widthProp = basePlacement === 'left' ? 'left' : 'right';
6257
- const heightProp = basePlacement === 'top' ? 'top' : 'bottom';
6258
- // eslint-disable-next-line no-param-reassign
6259
- state.modifiersData[name] = {
6260
- width: width - overflow[widthProp] - x,
6261
- height: height - overflow[heightProp] - y
6262
- };
6263
- }
6264
- };
6265
-
6266
- /**
6267
- * Popper js modifier to apply the max height.
6268
- */
6269
- const applyMaxHeight = {
6270
- name: 'applyMaxHeight',
6271
- enabled: true,
6272
- phase: 'beforeWrite',
6273
- requires: ['maxSize'],
6274
- fn({
6275
- state
6276
- }) {
6277
- const {
6278
- height
6279
- } = state.modifiersData.maxSize;
6280
- // eslint-disable-next-line no-param-reassign
6281
- state.elements.popper.style.maxHeight = `${height - ARROW_SIZE$1}px`;
6282
- }
6283
- };
6288
+ function parseAutoPlacement(placement) {
6289
+ if (placement === 'auto') return {
6290
+ isAuto: true
6291
+ };
6292
+ if (placement === 'auto-start') return {
6293
+ isAuto: true,
6294
+ autoAlignment: 'start'
6295
+ };
6296
+ if (placement === 'auto-end') return {
6297
+ isAuto: true,
6298
+ autoAlignment: 'end'
6299
+ };
6300
+ return {
6301
+ floatingPlacement: placement,
6302
+ isAuto: false
6303
+ };
6304
+ }
6305
+ function parseFitWidth(fitToAnchorWidth) {
6306
+ if (!fitToAnchorWidth) return undefined;
6307
+ if (typeof fitToAnchorWidth === 'string') return fitToAnchorWidth;
6308
+ return FitAnchorWidth.MIN_WIDTH;
6309
+ }
6284
6310
  function usePopoverStyle({
6285
- offset,
6311
+ offset: offset$1,
6286
6312
  hasArrow,
6287
6313
  fitToAnchorWidth,
6288
6314
  fitWithinViewportHeight,
@@ -6294,103 +6320,118 @@ function usePopoverStyle({
6294
6320
  }) {
6295
6321
  const [popperElement, setPopperElement] = useState(null);
6296
6322
  const [arrowElement, setArrowElement] = useState(null);
6297
- const actualOffset = [offset?.along ?? 0, (offset?.away ?? 0) + (hasArrow ? ARROW_SIZE$1 : 0)];
6298
- const modifiers = [{
6299
- name: 'offset',
6300
- options: {
6301
- offset: actualOffset
6302
- }
6303
- }];
6304
- if (hasArrow && arrowElement) {
6305
- modifiers.push({
6306
- name: 'arrow',
6307
- options: {
6308
- element: arrowElement,
6309
- padding: ARROW_SIZE$1 / 2
6310
- }
6311
- });
6312
- }
6313
- if (fitToAnchorWidth) {
6314
- const fitWidth = typeof fitToAnchorWidth === 'string' ? fitToAnchorWidth : FitAnchorWidth.MIN_WIDTH;
6315
- modifiers.push(sameWidth(fitWidth));
6316
- }
6317
- if (fitWithinViewportHeight) {
6318
- modifiers.push({
6319
- ...maxSize,
6320
- options: {
6321
- boundary: boundaryRef?.current
6322
- }
6323
- }, applyMaxHeight);
6324
- }
6325
- if (boundaryRef) {
6326
- modifiers.push({
6327
- name: 'flip',
6328
- options: {
6329
- boundary: boundaryRef.current
6330
- }
6331
- }, {
6332
- name: 'preventOverflow',
6333
- options: {
6334
- boundary: boundaryRef.current
6335
- }
6336
- });
6337
- }
6338
6323
  const {
6339
- styles,
6340
- attributes,
6341
- state,
6342
- update
6343
- } = usePopper(anchorRef.current, popperElement, {
6344
- placement,
6345
- modifiers
6346
- });
6324
+ floatingPlacement,
6325
+ isAuto,
6326
+ autoAlignment
6327
+ } = parseAutoPlacement(placement);
6328
+ const fitWidth = parseFitWidth(fitToAnchorWidth);
6329
+ const boundary = boundaryRef?.current ?? undefined;
6330
+
6331
+ // Build middleware array (order matters: offset → flip/autoPlacement → shift → size → arrow)
6332
+ const middleware = useMemo(() => {
6333
+ const mw = [];
6334
+
6335
+ // Offset middleware
6336
+ const awayOffset = (offset$1?.away ?? 0) + (hasArrow ? ARROW_SIZE$1 : 0);
6337
+ const alongOffset = offset$1?.along ?? 0;
6338
+ mw.push(offset({
6339
+ mainAxis: awayOffset,
6340
+ crossAxis: alongOffset
6341
+ }));
6347
6342
 
6348
- // Auto update popover
6349
- useEffect(() => {
6350
- const {
6351
- current: anchorElement
6352
- } = anchorRef;
6353
- if (!update || !popperElement || !anchorElement || !WINDOW?.ResizeObserver) {
6354
- return undefined;
6355
- }
6356
- let running;
6357
- function updateRateLimited() {
6358
- if (running) return;
6359
- update?.();
6360
- running = setTimeout(() => {
6361
- running = undefined;
6362
- }, 100);
6343
+ // Positioning middlewares
6344
+ if (isAuto) {
6345
+ mw.push(autoPlacement({
6346
+ ...(boundary ? {
6347
+ boundary
6348
+ } : {}),
6349
+ alignment: autoAlignment
6350
+ }));
6351
+ } else {
6352
+ mw.push(flip(boundary ? {
6353
+ boundary
6354
+ } : {}));
6355
+ mw.push(shift(boundary ? {
6356
+ boundary
6357
+ } : {}));
6358
+ }
6359
+
6360
+ // Size middleware
6361
+ if (fitWidth || fitWithinViewportHeight) {
6362
+ mw.push(size({
6363
+ ...(boundary ? {
6364
+ boundary
6365
+ } : {}),
6366
+ apply({
6367
+ availableHeight,
6368
+ rects,
6369
+ elements
6370
+ }) {
6371
+ if (fitWidth) {
6372
+ Object.assign(elements.floating.style, {
6373
+ [fitWidth]: `${rects.reference.width}px`
6374
+ });
6375
+ }
6376
+ if (fitWithinViewportHeight) {
6377
+ // eslint-disable-next-line no-param-reassign
6378
+ elements.floating.style.maxHeight = `${Math.max(0, availableHeight - ARROW_SIZE$1)}px`;
6379
+ }
6380
+ }
6381
+ }));
6363
6382
  }
6364
- updateRateLimited();
6365
6383
 
6366
- // On anchor or popover resize
6367
- const resizeObserver = new ResizeObserver(updateRateLimited);
6368
- resizeObserver.observe(anchorElement);
6369
- resizeObserver.observe(popperElement);
6370
- return () => {
6371
- resizeObserver.disconnect();
6384
+ // Arrow middleware
6385
+ if (hasArrow && arrowElement) {
6386
+ mw.push(arrow({
6387
+ element: arrowElement,
6388
+ padding: ARROW_SIZE$1 / 2
6389
+ }));
6390
+ }
6391
+ return mw;
6392
+ }, [offset$1?.away, offset$1?.along, hasArrow, isAuto, autoAlignment, boundary, fitWidth, fitWithinViewportHeight, arrowElement]);
6393
+ const anchorElement = anchorRef.current;
6394
+ const {
6395
+ floatingStyles,
6396
+ placement: resolvedPlacement,
6397
+ isPositioned,
6398
+ middlewareData
6399
+ } = useFloating({
6400
+ placement: floatingPlacement,
6401
+ whileElementsMounted: autoUpdate,
6402
+ middleware,
6403
+ elements: {
6404
+ reference: anchorElement,
6405
+ floating: popperElement
6406
+ }
6407
+ });
6408
+ const position = resolvedPlacement ?? placement;
6409
+
6410
+ // Compute arrow styles from middleware data
6411
+ const arrowStyles = useMemo(() => {
6412
+ const arrowData = middlewareData.arrow;
6413
+ if (!arrowData) return undefined;
6414
+ return {
6415
+ left: arrowData.x != null ? `${arrowData.x}px` : '',
6416
+ top: arrowData.y != null ? `${arrowData.y}px` : ''
6372
6417
  };
6373
- }, [anchorRef, popperElement, update]);
6374
- const position = state?.placement ?? placement;
6418
+ }, [middlewareData.arrow]);
6419
+
6420
+ // Merge floating styles with user-provided styles and zIndex
6375
6421
  const popoverStyle = useMemo(() => {
6376
- const newStyles = {
6422
+ return {
6377
6423
  ...style,
6378
- ...styles.popper,
6424
+ ...floatingStyles,
6379
6425
  zIndex
6380
6426
  };
6381
- if (fitWithinViewportHeight && !newStyles.maxHeight) {
6382
- newStyles.maxHeight = WINDOW?.innerHeight || DOCUMENT?.documentElement.clientHeight;
6383
- }
6384
- return newStyles;
6385
- }, [style, styles.popper, zIndex, fitWithinViewportHeight]);
6427
+ }, [style, floatingStyles, zIndex]);
6386
6428
  return {
6387
6429
  styles: {
6388
- arrow: styles.arrow,
6430
+ arrow: arrowStyles,
6389
6431
  popover: popoverStyle
6390
6432
  },
6391
- attributes,
6392
- isPositioned: (state?.rects?.popper?.y ?? -1) >= 0,
6393
- position,
6433
+ isPositioned,
6434
+ position: position,
6394
6435
  setArrowElement,
6395
6436
  setPopperElement,
6396
6437
  popperElement
@@ -6454,7 +6495,6 @@ const _InnerPopover = forwardRef((props, ref) => {
6454
6495
  const popoverRef = useRef(null);
6455
6496
  const {
6456
6497
  styles,
6457
- attributes,
6458
6498
  isPositioned,
6459
6499
  position,
6460
6500
  setArrowElement,
@@ -6493,11 +6533,10 @@ const _InnerPopover = forwardRef((props, ref) => {
6493
6533
  className: classNames.join(className, block$Q({
6494
6534
  [`theme-${theme}`]: Boolean(theme),
6495
6535
  [`elevation-${adjustedElevation}`]: Boolean(adjustedElevation),
6496
- [`position-${position}`]: Boolean(position),
6497
- 'is-initializing': !styles.popover?.transform
6536
+ [`position-${position}`]: Boolean(position)
6498
6537
  })),
6499
6538
  style: styles.popover,
6500
- ...attributes.popper,
6539
+ "data-popper-placement": position,
6501
6540
  children: [unmountSentinel, /*#__PURE__*/jsxs(ClickAwayProvider, {
6502
6541
  callback: closeOnClickAway && onClose,
6503
6542
  childrenRefs: clickAwayRefs,
@@ -6993,11 +7032,11 @@ const DEFAULT_PROPS$Q = {
6993
7032
  gap: Size$1.big,
6994
7033
  orientation: Orientation$1.horizontal
6995
7034
  };
6996
- const Figure = noop.bind({});
7035
+ const Figure = noop$1.bind({});
6997
7036
  const isFigure = isComponentType(Figure);
6998
- const Content = noop.bind({});
7037
+ const Content = noop$1.bind({});
6999
7038
  const isContent = isComponentType(Content);
7000
- const Actions = noop.bind({});
7039
+ const Actions = noop$1.bind({});
7001
7040
  const isActions = isComponentType(Actions);
7002
7041
 
7003
7042
  /**
@@ -8272,7 +8311,7 @@ async function startViewTransition({
8272
8311
  const prefersReducedMotion = isReducedMotion();
8273
8312
  const {
8274
8313
  flushSync
8275
- } = ReactDOM;
8314
+ } = ReactDOM__default;
8276
8315
  if (prefersReducedMotion || !start || !flushSync || viewTransitionName && (!viewTransitionName?.source || !viewTransitionName?.target)) {
8277
8316
  // Skip, apply changes without a transition
8278
8317
  changes();
@@ -13618,7 +13657,7 @@ const TabProvider = props => {
13618
13657
  // Escape rendering/useEffect context
13619
13658
  queueMicrotask(() => {
13620
13659
  // Wait for React to commit last state changes (avoid looping state update)
13621
- ReactDOM.flushSync(() => {
13660
+ ReactDOM__default.flushSync(() => {
13622
13661
  onChange(state.activeTabIndex);
13623
13662
  });
13624
13663
  });
@@ -15033,19 +15072,18 @@ const Tooltip = forwardRef((props, ref) => {
15033
15072
  const [popperElement, setPopperElement] = useState(null);
15034
15073
  const [anchorElement, setAnchorElement] = useState(null);
15035
15074
  const {
15036
- styles,
15037
- attributes,
15038
- update
15039
- } = usePopper(anchorElement, popperElement, {
15040
- placement,
15041
- modifiers: [{
15042
- name: 'offset',
15043
- options: {
15044
- offset: [0, ARROW_SIZE]
15045
- }
15046
- }]
15075
+ floatingStyles,
15076
+ placement: resolvedPlacement
15077
+ } = useFloating({
15078
+ placement: placement,
15079
+ whileElementsMounted: autoUpdate,
15080
+ middleware: [offset(ARROW_SIZE)],
15081
+ elements: {
15082
+ reference: anchorElement,
15083
+ floating: popperElement
15084
+ }
15047
15085
  });
15048
- const position = attributes?.popper?.['data-popper-placement'] ?? placement;
15086
+ const position = resolvedPlacement ?? placement;
15049
15087
  const {
15050
15088
  isOpen: isActivated,
15051
15089
  onPopperMount
@@ -15061,11 +15099,6 @@ const Tooltip = forwardRef((props, ref) => {
15061
15099
  label,
15062
15100
  ariaLinkMode: ariaLinkMode
15063
15101
  });
15064
-
15065
- // Update on open
15066
- React__default.useEffect(() => {
15067
- if (isOpen || popperElement) update?.();
15068
- }, [isOpen, update, popperElement]);
15069
15102
  const labelLines = label ? label.split('\n') : [];
15070
15103
  const tooltipRef = useMergeRefs(ref, setPopperElement, onPopperMount);
15071
15104
  return /*#__PURE__*/jsxs(Fragment, {
@@ -15078,14 +15111,13 @@ const Tooltip = forwardRef((props, ref) => {
15078
15111
  id: id,
15079
15112
  role: "tooltip",
15080
15113
  className: classNames.join(className, block$2({
15081
- [`position-${position}`]: Boolean(position),
15082
- 'is-initializing': !styles.popper?.transform
15114
+ [`position-${position}`]: Boolean(position)
15083
15115
  }), isHidden && classNames.visuallyHidden()),
15084
15116
  style: {
15085
- ...(isHidden ? undefined : styles.popper),
15117
+ ...(isHidden ? undefined : floatingStyles),
15086
15118
  zIndex
15087
15119
  },
15088
- ...attributes.popper,
15120
+ "data-popper-placement": position,
15089
15121
  children: [/*#__PURE__*/jsx("div", {
15090
15122
  className: element$2('arrow')
15091
15123
  }), /*#__PURE__*/jsx("div", {