@lumx/react 3.1.4-alpha-popover.1 → 3.1.4-alpha-popover.2

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.
package/index.js CHANGED
@@ -10,7 +10,7 @@ import range from 'lodash/range';
10
10
  import { extendMoment } from 'moment-range';
11
11
  import last from 'lodash/last';
12
12
  import pull from 'lodash/pull';
13
- import { createPortal, flushSync } from 'react-dom';
13
+ import { createPortal } from 'react-dom';
14
14
  import concat from 'lodash/concat';
15
15
  import dropRight from 'lodash/dropRight';
16
16
  import partition from 'lodash/partition';
@@ -3275,7 +3275,7 @@ ListItem.defaultProps = DEFAULT_PROPS$e;
3275
3275
  */
3276
3276
  var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.async_mode"):60111,m=b?Symbol.for("react.concurrent_mode"):60111,n=b?Symbol.for("react.forward_ref"):60112,p=b?Symbol.for("react.suspense"):60113,q=b?
3277
3277
  Symbol.for("react.suspense_list"):60120,r=b?Symbol.for("react.memo"):60115,t=b?Symbol.for("react.lazy"):60116,v=b?Symbol.for("react.block"):60121,w=b?Symbol.for("react.fundamental"):60117,x=b?Symbol.for("react.responder"):60118,y=b?Symbol.for("react.scope"):60119;
3278
- function z(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case t:case r:case h:return a;default:return u}}case d:return u}}}function A(a){return z(a)===m}var AsyncMode=l;var ConcurrentMode=m;var ContextConsumer=k;var ContextProvider=h;var Element=c;var ForwardRef=n;var Fragment=e;var Lazy=t;var Memo=r;var Portal=d;
3278
+ function z(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case t:case r:case h:return a;default:return u}}case d:return u}}}function A(a){return z(a)===m}var AsyncMode=l;var ConcurrentMode=m;var ContextConsumer=k;var ContextProvider=h;var Element$1=c;var ForwardRef=n;var Fragment=e;var Lazy=t;var Memo=r;var Portal=d;
3279
3279
  var Profiler=g;var StrictMode=f;var Suspense=p;var isAsyncMode=function(a){return A(a)||z(a)===l};var isConcurrentMode=A;var isContextConsumer=function(a){return z(a)===k};var isContextProvider=function(a){return z(a)===h};var isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===c};var isForwardRef=function(a){return z(a)===n};var isFragment=function(a){return z(a)===e};var isLazy=function(a){return z(a)===t};
3280
3280
  var isMemo=function(a){return z(a)===r};var isPortal=function(a){return z(a)===d};var isProfiler=function(a){return z(a)===g};var isStrictMode=function(a){return z(a)===f};var isSuspense=function(a){return z(a)===p};
3281
3281
  var isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f||a===p||a===q||"object"===typeof a&&null!==a&&(a.$$typeof===t||a.$$typeof===r||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n||a.$$typeof===w||a.$$typeof===x||a.$$typeof===y||a.$$typeof===v)};var typeOf=z;
@@ -3285,7 +3285,7 @@ var reactIs_production_min = {
3285
3285
  ConcurrentMode: ConcurrentMode,
3286
3286
  ContextConsumer: ContextConsumer,
3287
3287
  ContextProvider: ContextProvider,
3288
- Element: Element,
3288
+ Element: Element$1,
3289
3289
  ForwardRef: ForwardRef,
3290
3290
  Fragment: Fragment,
3291
3291
  Lazy: Lazy,
@@ -3765,11 +3765,12 @@ const useFocusWithin = _ref => {
3765
3765
  };
3766
3766
 
3767
3767
  /**
3768
- * HOC component skipping render if predicate if falsy
3768
+ * HOC component wrapping a component to skip render if predicate return falsy
3769
3769
  */
3770
- const skipRenderHOC = (predicate, Component) => {
3770
+ const skipRender = (predicate, Component) => {
3771
3771
  const Wrapper = /*#__PURE__*/React.forwardRef((props, ref) => {
3772
- if (!predicate(props)) {
3772
+ if (!DOCUMENT) {
3773
+ // Can't render in SSR.
3773
3774
  return null;
3774
3775
  }
3775
3776
  return /*#__PURE__*/React.createElement(Component, _extends({
@@ -3780,1084 +3781,1436 @@ const skipRenderHOC = (predicate, Component) => {
3780
3781
  return Wrapper;
3781
3782
  };
3782
3783
 
3783
- function getAlignment(placement) {
3784
- return placement.split('-')[1];
3784
+ /**
3785
+ * Simple ponyfill for Object.fromEntries
3786
+ */
3787
+
3788
+ var fromEntries = function fromEntries(entries) {
3789
+ return entries.reduce(function (acc, _ref) {
3790
+ var key = _ref[0],
3791
+ value = _ref[1];
3792
+ acc[key] = value;
3793
+ return acc;
3794
+ }, {});
3795
+ };
3796
+ /**
3797
+ * Small wrapper around `useLayoutEffect` to get rid of the warning on SSR envs
3798
+ */
3799
+
3800
+ var useIsomorphicLayoutEffect = typeof window !== 'undefined' && window.document && window.document.createElement ? useLayoutEffect : useEffect;
3801
+
3802
+ var top = 'top';
3803
+ var bottom = 'bottom';
3804
+ var right = 'right';
3805
+ var left = 'left';
3806
+ var auto = 'auto';
3807
+ var basePlacements = [top, bottom, right, left];
3808
+ var start = 'start';
3809
+ var end = 'end';
3810
+ var clippingParents = 'clippingParents';
3811
+ var viewport = 'viewport';
3812
+ var popper = 'popper';
3813
+ var reference = 'reference';
3814
+ var variationPlacements = /*#__PURE__*/basePlacements.reduce(function (acc, placement) {
3815
+ return acc.concat([placement + "-" + start, placement + "-" + end]);
3816
+ }, []);
3817
+ var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) {
3818
+ return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
3819
+ }, []); // modifiers that need to read the DOM
3820
+
3821
+ var beforeRead = 'beforeRead';
3822
+ var read = 'read';
3823
+ var afterRead = 'afterRead'; // pure-logic modifiers
3824
+
3825
+ var beforeMain = 'beforeMain';
3826
+ var main = 'main';
3827
+ var afterMain = 'afterMain'; // modifier with the purpose to write to the DOM (or write into a framework state)
3828
+
3829
+ var beforeWrite = 'beforeWrite';
3830
+ var write = 'write';
3831
+ var afterWrite = 'afterWrite';
3832
+ var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
3833
+
3834
+ function getNodeName(element) {
3835
+ return element ? (element.nodeName || '').toLowerCase() : null;
3785
3836
  }
3786
3837
 
3787
- function getLengthFromAxis(axis) {
3788
- return axis === 'y' ? 'height' : 'width';
3838
+ /*:: import type { Window } from '../types'; */
3839
+
3840
+ /*:: declare function getWindow(node: Node | Window): Window; */
3841
+ function getWindow(node) {
3842
+ if (node.toString() !== '[object Window]') {
3843
+ var ownerDocument = node.ownerDocument;
3844
+ return ownerDocument ? ownerDocument.defaultView || window : window;
3845
+ }
3846
+
3847
+ return node;
3789
3848
  }
3790
3849
 
3791
- function getSide(placement) {
3792
- return placement.split('-')[0];
3850
+ /*:: declare function isElement(node: mixed): boolean %checks(node instanceof
3851
+ Element); */
3852
+
3853
+ function isElement$1(node) {
3854
+ var OwnElement = getWindow(node).Element;
3855
+ return node instanceof OwnElement || node instanceof Element;
3793
3856
  }
3857
+ /*:: declare function isHTMLElement(node: mixed): boolean %checks(node instanceof
3858
+ HTMLElement); */
3794
3859
 
3795
- function getMainAxisFromPlacement(placement) {
3796
- return ['top', 'bottom'].includes(getSide(placement)) ? 'x' : 'y';
3860
+
3861
+ function isHTMLElement(node) {
3862
+ var OwnElement = getWindow(node).HTMLElement;
3863
+ return node instanceof OwnElement || node instanceof HTMLElement;
3797
3864
  }
3865
+ /*:: declare function isShadowRoot(node: mixed): boolean %checks(node instanceof
3866
+ ShadowRoot); */
3798
3867
 
3799
- function computeCoordsFromPlacement(_ref, placement, rtl) {
3800
- let {
3801
- reference,
3802
- floating
3803
- } = _ref;
3804
- const commonX = reference.x + reference.width / 2 - floating.width / 2;
3805
- const commonY = reference.y + reference.height / 2 - floating.height / 2;
3806
- const mainAxis = getMainAxisFromPlacement(placement);
3807
- const length = getLengthFromAxis(mainAxis);
3808
- const commonAlign = reference[length] / 2 - floating[length] / 2;
3809
- const side = getSide(placement);
3810
- const isVertical = mainAxis === 'x';
3811
- let coords;
3812
- switch (side) {
3813
- case 'top':
3814
- coords = {
3815
- x: commonX,
3816
- y: reference.y - floating.height
3817
- };
3818
- break;
3819
- case 'bottom':
3820
- coords = {
3821
- x: commonX,
3822
- y: reference.y + reference.height
3823
- };
3824
- break;
3825
- case 'right':
3826
- coords = {
3827
- x: reference.x + reference.width,
3828
- y: commonY
3829
- };
3830
- break;
3831
- case 'left':
3832
- coords = {
3833
- x: reference.x - floating.width,
3834
- y: commonY
3835
- };
3836
- break;
3837
- default:
3838
- coords = {
3839
- x: reference.x,
3840
- y: reference.y
3841
- };
3868
+
3869
+ function isShadowRoot(node) {
3870
+ var OwnElement = getWindow(node).ShadowRoot;
3871
+ return node instanceof OwnElement || node instanceof ShadowRoot;
3872
+ }
3873
+
3874
+ // and applies them to the HTMLElements such as popper and arrow
3875
+
3876
+ function applyStyles(_ref) {
3877
+ var state = _ref.state;
3878
+ Object.keys(state.elements).forEach(function (name) {
3879
+ var style = state.styles[name] || {};
3880
+ var attributes = state.attributes[name] || {};
3881
+ var element = state.elements[name]; // arrow is optional + virtual elements
3882
+
3883
+ if (!isHTMLElement(element) || !getNodeName(element)) {
3884
+ return;
3885
+ } // Flow doesn't support to extend this property, but it's the most
3886
+ // effective way to apply styles to an HTMLElement
3887
+ // $FlowFixMe
3888
+
3889
+
3890
+ Object.assign(element.style, style);
3891
+ Object.keys(attributes).forEach(function (name) {
3892
+ var value = attributes[name];
3893
+
3894
+ if (value === false) {
3895
+ element.removeAttribute(name);
3896
+ } else {
3897
+ element.setAttribute(name, value === true ? '' : value);
3898
+ }
3899
+ });
3900
+ });
3901
+ }
3902
+
3903
+ function effect(_ref2) {
3904
+ var state = _ref2.state;
3905
+ var initialStyles = {
3906
+ popper: {
3907
+ position: state.options.strategy,
3908
+ left: '0',
3909
+ top: '0',
3910
+ margin: '0'
3911
+ },
3912
+ arrow: {
3913
+ position: 'absolute'
3914
+ },
3915
+ reference: {}
3916
+ };
3917
+ Object.assign(state.elements.popper.style, initialStyles.popper);
3918
+
3919
+ if (state.elements.arrow) {
3920
+ Object.assign(state.elements.arrow.style, initialStyles.arrow);
3842
3921
  }
3843
- switch (getAlignment(placement)) {
3844
- case 'start':
3845
- coords[mainAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
3846
- break;
3847
- case 'end':
3848
- coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
3849
- break;
3922
+
3923
+ return function () {
3924
+ Object.keys(state.elements).forEach(function (name) {
3925
+ var element = state.elements[name];
3926
+ var attributes = state.attributes[name] || {};
3927
+ var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them
3928
+
3929
+ var style = styleProperties.reduce(function (style, property) {
3930
+ style[property] = '';
3931
+ return style;
3932
+ }, {}); // arrow is optional + virtual elements
3933
+
3934
+ if (!isHTMLElement(element) || !getNodeName(element)) {
3935
+ return;
3936
+ } // Flow doesn't support to extend this property, but it's the most
3937
+ // effective way to apply styles to an HTMLElement
3938
+ // $FlowFixMe
3939
+
3940
+
3941
+ Object.assign(element.style, style);
3942
+ Object.keys(attributes).forEach(function (attribute) {
3943
+ element.removeAttribute(attribute);
3944
+ });
3945
+ });
3946
+ };
3947
+ } // eslint-disable-next-line import/no-unused-modules
3948
+
3949
+
3950
+ var applyStyles$1 = {
3951
+ name: 'applyStyles',
3952
+ enabled: true,
3953
+ phase: 'write',
3954
+ fn: applyStyles,
3955
+ effect: effect,
3956
+ requires: ['computeStyles']
3957
+ };
3958
+
3959
+ function getBasePlacement(placement) {
3960
+ return placement.split('-')[0];
3961
+ }
3962
+
3963
+ // Returns the layout rect of an element relative to its offsetParent. Layout
3964
+ // means it doesn't take into account transforms.
3965
+ function getLayoutRect(element) {
3966
+ return {
3967
+ x: element.offsetLeft,
3968
+ y: element.offsetTop,
3969
+ width: element.offsetWidth,
3970
+ height: element.offsetHeight
3971
+ };
3972
+ }
3973
+
3974
+ function contains(parent, child) {
3975
+ var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method
3976
+
3977
+ if (parent.contains(child)) {
3978
+ return true;
3979
+ } // then fallback to custom implementation with Shadow DOM support
3980
+ else if (rootNode && isShadowRoot(rootNode)) {
3981
+ var next = child;
3982
+
3983
+ do {
3984
+ if (next && parent.isSameNode(next)) {
3985
+ return true;
3986
+ } // $FlowFixMe: need a better way to handle this...
3987
+
3988
+
3989
+ next = next.parentNode || next.host;
3990
+ } while (next);
3991
+ } // Give up, the result is false
3992
+
3993
+
3994
+ return false;
3995
+ }
3996
+
3997
+ function getComputedStyle(element) {
3998
+ return getWindow(element).getComputedStyle(element);
3999
+ }
4000
+
4001
+ function isTableElement(element) {
4002
+ return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
4003
+ }
4004
+
4005
+ function getDocumentElement(element) {
4006
+ // $FlowFixMe: assume body is always available
4007
+ return ((isElement$1(element) ? element.ownerDocument : element.document) || window.document).documentElement;
4008
+ }
4009
+
4010
+ function getParentNode(element) {
4011
+ if (getNodeName(element) === 'html') {
4012
+ return element;
3850
4013
  }
3851
- return coords;
4014
+
4015
+ return (// $FlowFixMe: this is a quicker (but less type safe) way to save quite some bytes from the bundle
4016
+ element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
4017
+ element.parentNode || // DOM Element detected
4018
+ // $FlowFixMe: need a better way to handle this...
4019
+ element.host || // ShadowRoot detected
4020
+ // $FlowFixMe: HTMLElement is a Node
4021
+ getDocumentElement(element) // fallback
4022
+
4023
+ );
3852
4024
  }
3853
4025
 
3854
- /**
3855
- * Computes the `x` and `y` coordinates that will place the floating element
3856
- * next to a reference element when it is given a certain positioning strategy.
3857
- *
3858
- * This export does not have any `platform` interface logic. You will need to
3859
- * write one for the platform you are using Floating UI with.
3860
- */
3861
- const computePosition = async (reference, floating, config) => {
3862
- const {
3863
- placement = 'bottom',
3864
- strategy = 'absolute',
3865
- middleware = [],
3866
- platform
3867
- } = config;
3868
- const validMiddleware = middleware.filter(Boolean);
3869
- const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
3870
- if (process.env.NODE_ENV !== "production") {
3871
- if (platform == null) {
3872
- console.error(['Floating UI: `platform` property was not passed to config. If you', 'want to use Floating UI on the web, install @floating-ui/dom', 'instead of the /core package. Otherwise, you can create your own', '`platform`: https://floating-ui.com/docs/platform'].join(' '));
3873
- }
3874
- if (validMiddleware.filter(_ref => {
3875
- let {
3876
- name
3877
- } = _ref;
3878
- return name === 'autoPlacement' || name === 'flip';
3879
- }).length > 1) {
3880
- throw new Error(['Floating UI: duplicate `flip` and/or `autoPlacement` middleware', 'detected. This will lead to an infinite loop. Ensure only one of', 'either has been passed to the `middleware` array.'].join(' '));
3881
- }
3882
- if (!reference || !floating) {
3883
- console.error(['Floating UI: The reference and/or floating element was not defined', 'when `computePosition()` was called. Ensure that both elements have', 'been created and can be measured.'].join(' '));
3884
- }
4026
+ function getTrueOffsetParent(element) {
4027
+ if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
4028
+ getComputedStyle(element).position === 'fixed') {
4029
+ return null;
3885
4030
  }
3886
- let rects = await platform.getElementRects({
3887
- reference,
3888
- floating,
3889
- strategy
3890
- });
3891
- let {
3892
- x,
3893
- y
3894
- } = computeCoordsFromPlacement(rects, placement, rtl);
3895
- let statefulPlacement = placement;
3896
- let middlewareData = {};
3897
- let resetCount = 0;
3898
- for (let i = 0; i < validMiddleware.length; i++) {
3899
- const {
3900
- name,
3901
- fn
3902
- } = validMiddleware[i];
3903
- const {
3904
- x: nextX,
3905
- y: nextY,
3906
- data,
3907
- reset
3908
- } = await fn({
3909
- x,
3910
- y,
3911
- initialPlacement: placement,
3912
- placement: statefulPlacement,
3913
- strategy,
3914
- middlewareData,
3915
- rects,
3916
- platform,
3917
- elements: {
3918
- reference,
3919
- floating
3920
- }
3921
- });
3922
- x = nextX != null ? nextX : x;
3923
- y = nextY != null ? nextY : y;
3924
- middlewareData = {
3925
- ...middlewareData,
3926
- [name]: {
3927
- ...middlewareData[name],
3928
- ...data
3929
- }
3930
- };
3931
- if (process.env.NODE_ENV !== "production") {
3932
- if (resetCount > 50) {
3933
- console.warn(['Floating UI: The middleware lifecycle appears to be running in an', 'infinite loop. This is usually caused by a `reset` continually', 'being returned without a break condition.'].join(' '));
3934
- }
4031
+
4032
+ var offsetParent = element.offsetParent;
4033
+
4034
+ if (offsetParent) {
4035
+ var html = getDocumentElement(offsetParent);
4036
+
4037
+ if (getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static' && getComputedStyle(html).position !== 'static') {
4038
+ return html;
3935
4039
  }
3936
- if (reset && resetCount <= 50) {
3937
- resetCount++;
3938
- if (typeof reset === 'object') {
3939
- if (reset.placement) {
3940
- statefulPlacement = reset.placement;
3941
- }
3942
- if (reset.rects) {
3943
- rects = reset.rects === true ? await platform.getElementRects({
3944
- reference,
3945
- floating,
3946
- strategy
3947
- }) : reset.rects;
3948
- }
3949
- ({
3950
- x,
3951
- y
3952
- } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
3953
- }
3954
- i = -1;
3955
- continue;
4040
+ }
4041
+
4042
+ return offsetParent;
4043
+ } // `.offsetParent` reports `null` for fixed elements, while absolute elements
4044
+ // return the containing block
4045
+
4046
+
4047
+ function getContainingBlock(element) {
4048
+ var currentNode = getParentNode(element);
4049
+
4050
+ while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
4051
+ var css = getComputedStyle(currentNode); // This is non-exhaustive but covers the most common CSS properties that
4052
+ // create a containing block.
4053
+
4054
+ if (css.transform !== 'none' || css.perspective !== 'none' || css.willChange && css.willChange !== 'auto') {
4055
+ return currentNode;
4056
+ } else {
4057
+ currentNode = currentNode.parentNode;
3956
4058
  }
3957
4059
  }
3958
- return {
3959
- x,
3960
- y,
3961
- placement: statefulPlacement,
3962
- strategy,
3963
- middlewareData
3964
- };
3965
- };
3966
4060
 
3967
- function expandPaddingObject(padding) {
4061
+ return null;
4062
+ } // Gets the closest ancestor positioned element. Handles some edge cases,
4063
+ // such as table ancestors and cross browser bugs.
4064
+
4065
+
4066
+ function getOffsetParent(element) {
4067
+ var window = getWindow(element);
4068
+ var offsetParent = getTrueOffsetParent(element);
4069
+
4070
+ while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
4071
+ offsetParent = getTrueOffsetParent(offsetParent);
4072
+ }
4073
+
4074
+ if (offsetParent && getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static') {
4075
+ return window;
4076
+ }
4077
+
4078
+ return offsetParent || getContainingBlock(element) || window;
4079
+ }
4080
+
4081
+ function getMainAxisFromPlacement(placement) {
4082
+ return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
4083
+ }
4084
+
4085
+ function within(min, value, max) {
4086
+ return Math.max(min, Math.min(value, max));
4087
+ }
4088
+
4089
+ function getFreshSideObject() {
3968
4090
  return {
3969
4091
  top: 0,
3970
4092
  right: 0,
3971
4093
  bottom: 0,
3972
- left: 0,
3973
- ...padding
4094
+ left: 0
3974
4095
  };
3975
4096
  }
3976
4097
 
3977
- function getSideObjectFromPadding(padding) {
3978
- return typeof padding !== 'number' ? expandPaddingObject(padding) : {
3979
- top: padding,
3980
- right: padding,
3981
- bottom: padding,
3982
- left: padding
3983
- };
4098
+ function mergePaddingObject(paddingObject) {
4099
+ return Object.assign(Object.assign({}, getFreshSideObject()), paddingObject);
3984
4100
  }
3985
4101
 
3986
- function rectToClientRect(rect) {
3987
- return {
3988
- ...rect,
3989
- top: rect.y,
3990
- left: rect.x,
3991
- right: rect.x + rect.width,
3992
- bottom: rect.y + rect.height
3993
- };
4102
+ function expandToHashMap(value, keys) {
4103
+ return keys.reduce(function (hashMap, key) {
4104
+ hashMap[key] = value;
4105
+ return hashMap;
4106
+ }, {});
3994
4107
  }
3995
4108
 
3996
- /**
3997
- * Resolves with an object of overflow side offsets that determine how much the
3998
- * element is overflowing a given clipping boundary.
3999
- * - positive = overflowing the boundary by that number of pixels
4000
- * - negative = how many pixels left before it will overflow
4001
- * - 0 = lies flush with the boundary
4002
- * @see https://floating-ui.com/docs/detectOverflow
4003
- */
4004
- async function detectOverflow(middlewareArguments, options) {
4005
- var _await$platform$isEle;
4006
- if (options === void 0) {
4007
- options = {};
4109
+ function arrow(_ref) {
4110
+ var _state$modifiersData$;
4111
+
4112
+ var state = _ref.state,
4113
+ name = _ref.name;
4114
+ var arrowElement = state.elements.arrow;
4115
+ var popperOffsets = state.modifiersData.popperOffsets;
4116
+ var basePlacement = getBasePlacement(state.placement);
4117
+ var axis = getMainAxisFromPlacement(basePlacement);
4118
+ var isVertical = [left, right].indexOf(basePlacement) >= 0;
4119
+ var len = isVertical ? 'height' : 'width';
4120
+
4121
+ if (!arrowElement || !popperOffsets) {
4122
+ return;
4008
4123
  }
4009
- const {
4010
- x,
4011
- y,
4012
- platform,
4013
- rects,
4014
- elements,
4015
- strategy
4016
- } = middlewareArguments;
4017
- const {
4018
- boundary = 'clippingAncestors',
4019
- rootBoundary = 'viewport',
4020
- elementContext = 'floating',
4021
- altBoundary = false,
4022
- padding = 0
4023
- } = options;
4024
- const paddingObject = getSideObjectFromPadding(padding);
4025
- const altContext = elementContext === 'floating' ? 'reference' : 'floating';
4026
- const element = elements[altBoundary ? altContext : elementContext];
4027
- const clippingClientRect = rectToClientRect(await platform.getClippingRect({
4028
- 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))),
4029
- boundary,
4030
- rootBoundary,
4031
- strategy
4032
- }));
4033
- const rect = elementContext === 'floating' ? {
4034
- ...rects.floating,
4035
- x,
4036
- y
4037
- } : rects.reference;
4038
- const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
4039
- const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
4040
- x: 1,
4041
- y: 1
4042
- } : {
4043
- x: 1,
4044
- y: 1
4124
+
4125
+ var paddingObject = state.modifiersData[name + "#persistent"].padding;
4126
+ var arrowRect = getLayoutRect(arrowElement);
4127
+ var minProp = axis === 'y' ? top : left;
4128
+ var maxProp = axis === 'y' ? bottom : right;
4129
+ var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
4130
+ var startDiff = popperOffsets[axis] - state.rects.reference[axis];
4131
+ var arrowOffsetParent = getOffsetParent(arrowElement);
4132
+ var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
4133
+ var centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the popper if the center point is
4134
+ // outside of the popper bounds
4135
+
4136
+ var min = paddingObject[minProp];
4137
+ var max = clientSize - arrowRect[len] - paddingObject[maxProp];
4138
+ var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
4139
+ var offset = within(min, center, max); // Prevents breaking syntax highlighting...
4140
+
4141
+ var axisProp = axis;
4142
+ state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);
4143
+ }
4144
+
4145
+ function effect$1(_ref2) {
4146
+ var state = _ref2.state,
4147
+ options = _ref2.options,
4148
+ name = _ref2.name;
4149
+ var _options$element = options.element,
4150
+ arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element,
4151
+ _options$padding = options.padding,
4152
+ padding = _options$padding === void 0 ? 0 : _options$padding;
4153
+
4154
+ if (arrowElement == null) {
4155
+ return;
4156
+ } // CSS selector
4157
+
4158
+
4159
+ if (typeof arrowElement === 'string') {
4160
+ arrowElement = state.elements.popper.querySelector(arrowElement);
4161
+
4162
+ if (!arrowElement) {
4163
+ return;
4164
+ }
4165
+ }
4166
+
4167
+ if (process.env.NODE_ENV !== "production") {
4168
+ if (!isHTMLElement(arrowElement)) {
4169
+ 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(' '));
4170
+ }
4171
+ }
4172
+
4173
+ if (!contains(state.elements.popper, arrowElement)) {
4174
+ if (process.env.NODE_ENV !== "production") {
4175
+ console.error(['Popper: "arrow" modifier\'s `element` must be a child of the popper', 'element.'].join(' '));
4176
+ }
4177
+
4178
+ return;
4179
+ }
4180
+
4181
+ state.elements.arrow = arrowElement;
4182
+ state.modifiersData[name + "#persistent"] = {
4183
+ padding: mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements))
4045
4184
  };
4046
- const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
4047
- rect,
4048
- offsetParent,
4049
- strategy
4050
- }) : rect);
4051
- if (process.env.NODE_ENV !== "production") ;
4185
+ } // eslint-disable-next-line import/no-unused-modules
4186
+
4187
+
4188
+ var arrow$1 = {
4189
+ name: 'arrow',
4190
+ enabled: true,
4191
+ phase: 'main',
4192
+ fn: arrow,
4193
+ effect: effect$1,
4194
+ requires: ['popperOffsets'],
4195
+ requiresIfExists: ['preventOverflow']
4196
+ };
4197
+
4198
+ var unsetSides = {
4199
+ top: 'auto',
4200
+ right: 'auto',
4201
+ bottom: 'auto',
4202
+ left: 'auto'
4203
+ }; // Round the offsets to the nearest suitable subpixel based on the DPR.
4204
+ // Zooming can change the DPR, but it seems to report a value that will
4205
+ // cleanly divide the values into the appropriate subpixels.
4206
+
4207
+ function roundOffsets(_ref) {
4208
+ var x = _ref.x,
4209
+ y = _ref.y;
4210
+ var win = window;
4211
+ var dpr = win.devicePixelRatio || 1;
4052
4212
  return {
4053
- top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
4054
- bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
4055
- left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
4056
- right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
4213
+ x: Math.round(x * dpr) / dpr || 0,
4214
+ y: Math.round(y * dpr) / dpr || 0
4057
4215
  };
4058
4216
  }
4059
4217
 
4060
- const min = Math.min;
4061
- const max = Math.max;
4218
+ function mapToStyles(_ref2) {
4219
+ var _Object$assign2;
4220
+
4221
+ var popper = _ref2.popper,
4222
+ popperRect = _ref2.popperRect,
4223
+ placement = _ref2.placement,
4224
+ offsets = _ref2.offsets,
4225
+ position = _ref2.position,
4226
+ gpuAcceleration = _ref2.gpuAcceleration,
4227
+ adaptive = _ref2.adaptive;
4228
+
4229
+ var _roundOffsets = roundOffsets(offsets),
4230
+ x = _roundOffsets.x,
4231
+ y = _roundOffsets.y;
4232
+
4233
+ var hasX = offsets.hasOwnProperty('x');
4234
+ var hasY = offsets.hasOwnProperty('y');
4235
+ var sideX = left;
4236
+ var sideY = top;
4237
+ var win = window;
4238
+
4239
+ if (adaptive) {
4240
+ var offsetParent = getOffsetParent(popper);
4241
+
4242
+ if (offsetParent === getWindow(popper)) {
4243
+ offsetParent = getDocumentElement(popper);
4244
+ } // $FlowFixMe: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it
4245
+
4246
+ /*:: offsetParent = (offsetParent: Element); */
4062
4247
 
4063
- function within(min$1, value, max$1) {
4064
- return max(min$1, min(value, max$1));
4248
+
4249
+ if (placement === top) {
4250
+ sideY = bottom;
4251
+ y -= offsetParent.clientHeight - popperRect.height;
4252
+ y *= gpuAcceleration ? 1 : -1;
4253
+ }
4254
+
4255
+ if (placement === left) {
4256
+ sideX = right;
4257
+ x -= offsetParent.clientWidth - popperRect.width;
4258
+ x *= gpuAcceleration ? 1 : -1;
4259
+ }
4260
+ }
4261
+
4262
+ var commonStyles = Object.assign({
4263
+ position: position
4264
+ }, adaptive && unsetSides);
4265
+
4266
+ if (gpuAcceleration) {
4267
+ var _Object$assign;
4268
+
4269
+ 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));
4270
+ }
4271
+
4272
+ 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));
4065
4273
  }
4066
4274
 
4067
- /**
4068
- * Positions an inner element of the floating element such that it is centered
4069
- * to the reference element.
4070
- * @see https://floating-ui.com/docs/arrow
4071
- */
4072
- const arrow = options => ({
4073
- name: 'arrow',
4074
- options,
4075
- async fn(middlewareArguments) {
4076
- // Since `element` is required, we don't Partial<> the type.
4077
- const {
4078
- element,
4079
- padding = 0
4080
- } = options || {};
4081
- const {
4082
- x,
4083
- y,
4084
- placement,
4085
- rects,
4086
- platform
4087
- } = middlewareArguments;
4088
- if (element == null) {
4089
- if (process.env.NODE_ENV !== "production") {
4090
- console.warn('Floating UI: No `element` was passed to the `arrow` middleware.');
4091
- }
4092
- return {};
4275
+ function computeStyles(_ref3) {
4276
+ var state = _ref3.state,
4277
+ options = _ref3.options;
4278
+ var _options$gpuAccelerat = options.gpuAcceleration,
4279
+ gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
4280
+ _options$adaptive = options.adaptive,
4281
+ adaptive = _options$adaptive === void 0 ? true : _options$adaptive;
4282
+
4283
+ if (process.env.NODE_ENV !== "production") {
4284
+ var transitionProperty = getComputedStyle(state.elements.popper).transitionProperty || '';
4285
+
4286
+ if (adaptive && ['transform', 'top', 'right', 'bottom', 'left'].some(function (property) {
4287
+ return transitionProperty.indexOf(property) >= 0;
4288
+ })) {
4289
+ 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(' '));
4093
4290
  }
4094
- const paddingObject = getSideObjectFromPadding(padding);
4095
- const coords = {
4096
- x,
4097
- y
4098
- };
4099
- const axis = getMainAxisFromPlacement(placement);
4100
- const length = getLengthFromAxis(axis);
4101
- const arrowDimensions = await platform.getDimensions(element);
4102
- const minProp = axis === 'y' ? 'top' : 'left';
4103
- const maxProp = axis === 'y' ? 'bottom' : 'right';
4104
- const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
4105
- const startDiff = coords[axis] - rects.reference[axis];
4106
- const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
4107
- let clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
4108
- if (clientSize === 0) {
4109
- clientSize = rects.floating[length];
4110
- }
4111
- const centerToReference = endDiff / 2 - startDiff / 2;
4112
-
4113
- // Make sure the arrow doesn't overflow the floating element if the center
4114
- // point is outside the floating element's bounds.
4115
- const min = paddingObject[minProp];
4116
- const max = clientSize - arrowDimensions[length] - paddingObject[maxProp];
4117
- const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
4118
- const offset = within(min, center, max);
4119
-
4120
- // If the reference is small enough that the arrow's padding causes it to
4121
- // to point to nothing for an aligned placement, adjust the offset of the
4122
- // floating element itself. This stops `shift()` from taking action, but can
4123
- // be worked around by calling it again after the `arrow()` if desired.
4124
- const shouldAddOffset = getAlignment(placement) != null && center != offset && rects.reference[length] / 2 - (center < min ? paddingObject[minProp] : paddingObject[maxProp]) - arrowDimensions[length] / 2 < 0;
4125
- const alignmentOffset = shouldAddOffset ? center < min ? min - center : max - center : 0;
4126
- return {
4127
- [axis]: coords[axis] - alignmentOffset,
4128
- data: {
4129
- [axis]: offset,
4130
- centerOffset: center - offset
4131
- }
4132
- };
4133
4291
  }
4134
- });
4135
4292
 
4136
- const sides = ['top', 'right', 'bottom', 'left'];
4137
- const allPlacements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + "-start", side + "-end"), []);
4293
+ var commonStyles = {
4294
+ placement: getBasePlacement(state.placement),
4295
+ popper: state.elements.popper,
4296
+ popperRect: state.rects.popper,
4297
+ gpuAcceleration: gpuAcceleration
4298
+ };
4299
+
4300
+ if (state.modifiersData.popperOffsets != null) {
4301
+ state.styles.popper = Object.assign(Object.assign({}, state.styles.popper), mapToStyles(Object.assign(Object.assign({}, commonStyles), {}, {
4302
+ offsets: state.modifiersData.popperOffsets,
4303
+ position: state.options.strategy,
4304
+ adaptive: adaptive
4305
+ })));
4306
+ }
4307
+
4308
+ if (state.modifiersData.arrow != null) {
4309
+ state.styles.arrow = Object.assign(Object.assign({}, state.styles.arrow), mapToStyles(Object.assign(Object.assign({}, commonStyles), {}, {
4310
+ offsets: state.modifiersData.arrow,
4311
+ position: 'absolute',
4312
+ adaptive: false
4313
+ })));
4314
+ }
4315
+
4316
+ state.attributes.popper = Object.assign(Object.assign({}, state.attributes.popper), {}, {
4317
+ 'data-popper-placement': state.placement
4318
+ });
4319
+ } // eslint-disable-next-line import/no-unused-modules
4320
+
4321
+
4322
+ var computeStyles$1 = {
4323
+ name: 'computeStyles',
4324
+ enabled: true,
4325
+ phase: 'beforeWrite',
4326
+ fn: computeStyles,
4327
+ data: {}
4328
+ };
4329
+
4330
+ var passive = {
4331
+ passive: true
4332
+ };
4333
+
4334
+ function effect$2(_ref) {
4335
+ var state = _ref.state,
4336
+ instance = _ref.instance,
4337
+ options = _ref.options;
4338
+ var _options$scroll = options.scroll,
4339
+ scroll = _options$scroll === void 0 ? true : _options$scroll,
4340
+ _options$resize = options.resize,
4341
+ resize = _options$resize === void 0 ? true : _options$resize;
4342
+ var window = getWindow(state.elements.popper);
4343
+ var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
4344
+
4345
+ if (scroll) {
4346
+ scrollParents.forEach(function (scrollParent) {
4347
+ scrollParent.addEventListener('scroll', instance.update, passive);
4348
+ });
4349
+ }
4350
+
4351
+ if (resize) {
4352
+ window.addEventListener('resize', instance.update, passive);
4353
+ }
4354
+
4355
+ return function () {
4356
+ if (scroll) {
4357
+ scrollParents.forEach(function (scrollParent) {
4358
+ scrollParent.removeEventListener('scroll', instance.update, passive);
4359
+ });
4360
+ }
4361
+
4362
+ if (resize) {
4363
+ window.removeEventListener('resize', instance.update, passive);
4364
+ }
4365
+ };
4366
+ } // eslint-disable-next-line import/no-unused-modules
4367
+
4138
4368
 
4139
- const oppositeSideMap = {
4369
+ var eventListeners = {
4370
+ name: 'eventListeners',
4371
+ enabled: true,
4372
+ phase: 'write',
4373
+ fn: function fn() {},
4374
+ effect: effect$2,
4375
+ data: {}
4376
+ };
4377
+
4378
+ var hash = {
4140
4379
  left: 'right',
4141
4380
  right: 'left',
4142
4381
  bottom: 'top',
4143
4382
  top: 'bottom'
4144
4383
  };
4145
4384
  function getOppositePlacement(placement) {
4146
- return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
4147
- }
4148
-
4149
- function getAlignmentSides(placement, rects, rtl) {
4150
- if (rtl === void 0) {
4151
- rtl = false;
4152
- }
4153
- const alignment = getAlignment(placement);
4154
- const mainAxis = getMainAxisFromPlacement(placement);
4155
- const length = getLengthFromAxis(mainAxis);
4156
- let mainAlignmentSide = mainAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
4157
- if (rects.reference[length] > rects.floating[length]) {
4158
- mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
4159
- }
4160
- return {
4161
- main: mainAlignmentSide,
4162
- cross: getOppositePlacement(mainAlignmentSide)
4163
- };
4385
+ return placement.replace(/left|right|bottom|top/g, function (matched) {
4386
+ return hash[matched];
4387
+ });
4164
4388
  }
4165
4389
 
4166
- const oppositeAlignmentMap = {
4390
+ var hash$1 = {
4167
4391
  start: 'end',
4168
4392
  end: 'start'
4169
4393
  };
4170
- function getOppositeAlignmentPlacement(placement) {
4171
- return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
4172
- }
4173
-
4174
- function getPlacementList(alignment, autoAlignment, allowedPlacements) {
4175
- const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment(placement) !== alignment)] : allowedPlacements.filter(placement => getSide(placement) === placement);
4176
- return allowedPlacementsSortedByAlignment.filter(placement => {
4177
- if (alignment) {
4178
- return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);
4179
- }
4180
- return true;
4394
+ function getOppositeVariationPlacement(placement) {
4395
+ return placement.replace(/start|end/g, function (matched) {
4396
+ return hash$1[matched];
4181
4397
  });
4182
4398
  }
4183
- /**
4184
- * Automatically chooses the `placement` which has the most space available.
4185
- * @see https://floating-ui.com/docs/autoPlacement
4186
- */
4187
- const autoPlacement = function (options) {
4188
- if (options === void 0) {
4189
- options = {};
4190
- }
4191
- return {
4192
- name: 'autoPlacement',
4193
- options,
4194
- async fn(middlewareArguments) {
4195
- var _middlewareData$autoP, _middlewareData$autoP2, _placementsSortedByLe;
4196
- const {
4197
- rects,
4198
- middlewareData,
4199
- placement,
4200
- platform,
4201
- elements
4202
- } = middlewareArguments;
4203
- const {
4204
- alignment,
4205
- allowedPlacements = allPlacements,
4206
- autoAlignment = true,
4207
- ...detectOverflowOptions
4208
- } = options;
4209
- const placements = alignment !== undefined || allowedPlacements === allPlacements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;
4210
- const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
4211
- const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;
4212
- const currentPlacement = placements[currentIndex];
4213
- if (currentPlacement == null) {
4214
- return {};
4215
- }
4216
- const {
4217
- main,
4218
- cross
4219
- } = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
4220
4399
 
4221
- // Make `computeCoords` start from the right place.
4222
- if (placement !== currentPlacement) {
4223
- return {
4224
- reset: {
4225
- placement: placements[0]
4226
- }
4227
- };
4228
- }
4229
- const currentOverflows = [overflow[getSide(currentPlacement)], overflow[main], overflow[cross]];
4230
- const allOverflows = [...(((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || []), {
4231
- placement: currentPlacement,
4232
- overflows: currentOverflows
4233
- }];
4234
- const nextPlacement = placements[currentIndex + 1];
4235
-
4236
- // There are more placements to check.
4237
- if (nextPlacement) {
4238
- return {
4239
- data: {
4240
- index: currentIndex + 1,
4241
- overflows: allOverflows
4242
- },
4243
- reset: {
4244
- placement: nextPlacement
4245
- }
4246
- };
4247
- }
4248
- const placementsSortedByLeastOverflow = allOverflows.slice().sort((a, b) => a.overflows[0] - b.overflows[0]);
4249
- const placementThatFitsOnAllSides = (_placementsSortedByLe = placementsSortedByLeastOverflow.find(_ref => {
4250
- let {
4251
- overflows
4252
- } = _ref;
4253
- return overflows.every(overflow => overflow <= 0);
4254
- })) == null ? void 0 : _placementsSortedByLe.placement;
4255
- const resetPlacement = placementThatFitsOnAllSides || placementsSortedByLeastOverflow[0].placement;
4256
- if (resetPlacement !== placement) {
4257
- return {
4258
- data: {
4259
- index: currentIndex + 1,
4260
- overflows: allOverflows
4261
- },
4262
- reset: {
4263
- placement: resetPlacement
4264
- }
4265
- };
4266
- }
4267
- return {};
4268
- }
4400
+ function getBoundingClientRect(element) {
4401
+ var rect = element.getBoundingClientRect();
4402
+ return {
4403
+ width: rect.width,
4404
+ height: rect.height,
4405
+ top: rect.top,
4406
+ right: rect.right,
4407
+ bottom: rect.bottom,
4408
+ left: rect.left,
4409
+ x: rect.left,
4410
+ y: rect.top
4269
4411
  };
4270
- };
4412
+ }
4271
4413
 
4272
- function getExpandedPlacements(placement) {
4273
- const oppositePlacement = getOppositePlacement(placement);
4274
- return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
4414
+ function getWindowScroll(node) {
4415
+ var win = getWindow(node);
4416
+ var scrollLeft = win.pageXOffset;
4417
+ var scrollTop = win.pageYOffset;
4418
+ return {
4419
+ scrollLeft: scrollLeft,
4420
+ scrollTop: scrollTop
4421
+ };
4275
4422
  }
4276
4423
 
4277
- function getSideList(side, isStart, rtl) {
4278
- const lr = ['left', 'right'];
4279
- const rl = ['right', 'left'];
4280
- const tb = ['top', 'bottom'];
4281
- const bt = ['bottom', 'top'];
4282
- switch (side) {
4283
- case 'top':
4284
- case 'bottom':
4285
- if (rtl) return isStart ? rl : lr;
4286
- return isStart ? lr : rl;
4287
- case 'left':
4288
- case 'right':
4289
- return isStart ? tb : bt;
4290
- default:
4291
- return [];
4292
- }
4424
+ function getWindowScrollBarX(element) {
4425
+ // If <html> has a CSS width greater than the viewport, then this will be
4426
+ // incorrect for RTL.
4427
+ // Popper 1 is broken in this case and never had a bug report so let's assume
4428
+ // it's not an issue. I don't think anyone ever specifies width on <html>
4429
+ // anyway.
4430
+ // Browsers where the left scrollbar doesn't cause an issue report `0` for
4431
+ // this (e.g. Edge 2019, IE11, Safari)
4432
+ return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
4293
4433
  }
4294
- function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
4295
- const alignment = getAlignment(placement);
4296
- let list = getSideList(getSide(placement), direction === 'start', rtl);
4297
- if (alignment) {
4298
- list = list.map(side => side + "-" + alignment);
4299
- if (flipAlignment) {
4300
- list = list.concat(list.map(getOppositeAlignmentPlacement));
4434
+
4435
+ function getViewportRect(element) {
4436
+ var win = getWindow(element);
4437
+ var html = getDocumentElement(element);
4438
+ var visualViewport = win.visualViewport;
4439
+ var width = html.clientWidth;
4440
+ var height = html.clientHeight;
4441
+ var x = 0;
4442
+ var y = 0; // NB: This isn't supported on iOS <= 12. If the keyboard is open, the popper
4443
+ // can be obscured underneath it.
4444
+ // Also, `html.clientHeight` adds the bottom bar height in Safari iOS, even
4445
+ // if it isn't open, so if this isn't available, the popper will be detected
4446
+ // to overflow the bottom of the screen too early.
4447
+
4448
+ if (visualViewport) {
4449
+ width = visualViewport.width;
4450
+ height = visualViewport.height; // Uses Layout Viewport (like Chrome; Safari does not currently)
4451
+ // In Chrome, it returns a value very close to 0 (+/-) but contains rounding
4452
+ // errors due to floating point numbers, so we need to check precision.
4453
+ // Safari returns a number <= 0, usually < -1 when pinch-zoomed
4454
+ // Feature detection fails in mobile emulation mode in Chrome.
4455
+ // Math.abs(win.innerWidth / visualViewport.scale - visualViewport.width) <
4456
+ // 0.001
4457
+ // Fallback here: "Not Safari" userAgent
4458
+
4459
+ if (!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
4460
+ x = visualViewport.offsetLeft;
4461
+ y = visualViewport.offsetTop;
4301
4462
  }
4302
4463
  }
4303
- return list;
4304
- }
4305
4464
 
4306
- /**
4307
- * Changes the placement of the floating element to one that will fit if the
4308
- * initially specified `placement` does not.
4309
- * @see https://floating-ui.com/docs/flip
4310
- */
4311
- const flip = function (options) {
4312
- if (options === void 0) {
4313
- options = {};
4314
- }
4315
4465
  return {
4316
- name: 'flip',
4317
- options,
4318
- async fn(middlewareArguments) {
4319
- var _middlewareData$flip;
4320
- const {
4321
- placement,
4322
- middlewareData,
4323
- rects,
4324
- initialPlacement,
4325
- platform,
4326
- elements
4327
- } = middlewareArguments;
4328
- const {
4329
- mainAxis: checkMainAxis = true,
4330
- crossAxis: checkCrossAxis = true,
4331
- fallbackPlacements: specifiedFallbackPlacements,
4332
- fallbackStrategy = 'bestFit',
4333
- fallbackAxisSideDirection = 'none',
4334
- flipAlignment = true,
4335
- ...detectOverflowOptions
4336
- } = options;
4337
- const side = getSide(placement);
4338
- const isBasePlacement = getSide(initialPlacement) === initialPlacement;
4339
- const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
4340
- const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
4341
- if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== 'none') {
4342
- fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
4343
- }
4344
- const placements = [initialPlacement, ...fallbackPlacements];
4345
- const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
4346
- const overflows = [];
4347
- let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
4348
- if (checkMainAxis) {
4349
- overflows.push(overflow[side]);
4350
- }
4351
- if (checkCrossAxis) {
4352
- const {
4353
- main,
4354
- cross
4355
- } = getAlignmentSides(placement, rects, rtl);
4356
- overflows.push(overflow[main], overflow[cross]);
4357
- }
4358
- overflowsData = [...overflowsData, {
4359
- placement,
4360
- overflows
4361
- }];
4362
-
4363
- // One or more sides is overflowing.
4364
- if (!overflows.every(side => side <= 0)) {
4365
- var _middlewareData$flip2;
4366
- const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
4367
- const nextPlacement = placements[nextIndex];
4368
- if (nextPlacement) {
4369
- // Try next placement and re-run the lifecycle.
4370
- return {
4371
- data: {
4372
- index: nextIndex,
4373
- overflows: overflowsData
4374
- },
4375
- reset: {
4376
- placement: nextPlacement
4377
- }
4378
- };
4379
- }
4380
- let resetPlacement = 'bottom';
4381
- switch (fallbackStrategy) {
4382
- case 'bestFit':
4383
- {
4384
- var _overflowsData$map$so;
4385
- const placement = (_overflowsData$map$so = overflowsData.map(d => [d, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$map$so[0].placement;
4386
- if (placement) {
4387
- resetPlacement = placement;
4388
- }
4389
- break;
4390
- }
4391
- case 'initialPlacement':
4392
- resetPlacement = initialPlacement;
4393
- break;
4394
- }
4395
- if (placement !== resetPlacement) {
4396
- return {
4397
- reset: {
4398
- placement: resetPlacement
4399
- }
4400
- };
4401
- }
4402
- }
4403
- return {};
4404
- }
4466
+ width: width,
4467
+ height: height,
4468
+ x: x + getWindowScrollBarX(element),
4469
+ y: y
4405
4470
  };
4406
- };
4471
+ }
4407
4472
 
4408
- async function convertValueToCoords(middlewareArguments, value) {
4409
- const {
4410
- placement,
4411
- platform,
4412
- elements
4413
- } = middlewareArguments;
4414
- const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
4415
- const side = getSide(placement);
4416
- const alignment = getAlignment(placement);
4417
- const isVertical = getMainAxisFromPlacement(placement) === 'x';
4418
- const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
4419
- const crossAxisMulti = rtl && isVertical ? -1 : 1;
4420
- const rawValue = typeof value === 'function' ? value(middlewareArguments) : value;
4421
-
4422
- // eslint-disable-next-line prefer-const
4423
- let {
4424
- mainAxis,
4425
- crossAxis,
4426
- alignmentAxis
4427
- } = typeof rawValue === 'number' ? {
4428
- mainAxis: rawValue,
4429
- crossAxis: 0,
4430
- alignmentAxis: null
4431
- } : {
4432
- mainAxis: 0,
4433
- crossAxis: 0,
4434
- alignmentAxis: null,
4435
- ...rawValue
4436
- };
4437
- if (alignment && typeof alignmentAxis === 'number') {
4438
- crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
4473
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable
4474
+
4475
+ function getDocumentRect(element) {
4476
+ var html = getDocumentElement(element);
4477
+ var winScroll = getWindowScroll(element);
4478
+ var body = element.ownerDocument.body;
4479
+ var width = Math.max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
4480
+ var height = Math.max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
4481
+ var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
4482
+ var y = -winScroll.scrollTop;
4483
+
4484
+ if (getComputedStyle(body || html).direction === 'rtl') {
4485
+ x += Math.max(html.clientWidth, body ? body.clientWidth : 0) - width;
4439
4486
  }
4440
- return isVertical ? {
4441
- x: crossAxis * crossAxisMulti,
4442
- y: mainAxis * mainAxisMulti
4443
- } : {
4444
- x: mainAxis * mainAxisMulti,
4445
- y: crossAxis * crossAxisMulti
4487
+
4488
+ return {
4489
+ width: width,
4490
+ height: height,
4491
+ x: x,
4492
+ y: y
4446
4493
  };
4447
4494
  }
4448
4495
 
4449
- /**
4450
- * Displaces the floating element from its reference element.
4451
- * @see https://floating-ui.com/docs/offset
4452
- */
4453
- const offset = function (value) {
4454
- if (value === void 0) {
4455
- value = 0;
4496
+ function isScrollParent(element) {
4497
+ // Firefox wants us to check `-x` and `-y` variations as well
4498
+ var _getComputedStyle = getComputedStyle(element),
4499
+ overflow = _getComputedStyle.overflow,
4500
+ overflowX = _getComputedStyle.overflowX,
4501
+ overflowY = _getComputedStyle.overflowY;
4502
+
4503
+ return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
4504
+ }
4505
+
4506
+ function getScrollParent(node) {
4507
+ if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
4508
+ // $FlowFixMe: assume body is always available
4509
+ return node.ownerDocument.body;
4456
4510
  }
4457
- return {
4458
- name: 'offset',
4459
- options: value,
4460
- async fn(middlewareArguments) {
4461
- const {
4462
- x,
4463
- y
4464
- } = middlewareArguments;
4465
- const diffCoords = await convertValueToCoords(middlewareArguments, value);
4466
- return {
4467
- x: x + diffCoords.x,
4468
- y: y + diffCoords.y,
4469
- data: diffCoords
4470
- };
4471
- }
4472
- };
4473
- };
4474
4511
 
4475
- function getCrossAxis(axis) {
4476
- return axis === 'x' ? 'y' : 'x';
4512
+ if (isHTMLElement(node) && isScrollParent(node)) {
4513
+ return node;
4514
+ }
4515
+
4516
+ return getScrollParent(getParentNode(node));
4477
4517
  }
4478
4518
 
4479
- /**
4480
- * Shifts the floating element in order to keep it in view when it will overflow
4481
- * a clipping boundary.
4482
- * @see https://floating-ui.com/docs/shift
4483
- */
4484
- const shift = function (options) {
4485
- if (options === void 0) {
4486
- options = {};
4519
+ /*
4520
+ given a DOM element, return the list of all scroll parents, up the list of ancesors
4521
+ until we get to the top window object. This list is what we attach scroll listeners
4522
+ to, because if any of these parent elements scroll, we'll need to re-calculate the
4523
+ reference element's position.
4524
+ */
4525
+
4526
+ function listScrollParents(element, list) {
4527
+ if (list === void 0) {
4528
+ list = [];
4487
4529
  }
4488
- return {
4489
- name: 'shift',
4490
- options,
4491
- async fn(middlewareArguments) {
4492
- const {
4493
- x,
4494
- y,
4495
- placement
4496
- } = middlewareArguments;
4497
- const {
4498
- mainAxis: checkMainAxis = true,
4499
- crossAxis: checkCrossAxis = false,
4500
- limiter = {
4501
- fn: _ref => {
4502
- let {
4503
- x,
4504
- y
4505
- } = _ref;
4506
- return {
4507
- x,
4508
- y
4509
- };
4510
- }
4511
- },
4512
- ...detectOverflowOptions
4513
- } = options;
4514
- const coords = {
4515
- x,
4516
- y
4530
+
4531
+ var scrollParent = getScrollParent(element);
4532
+ var isBody = getNodeName(scrollParent) === 'body';
4533
+ var win = getWindow(scrollParent);
4534
+ var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
4535
+ var updatedList = list.concat(target);
4536
+ return isBody ? updatedList : // $FlowFixMe: isBody tells us target will be an HTMLElement here
4537
+ updatedList.concat(listScrollParents(getParentNode(target)));
4538
+ }
4539
+
4540
+ function rectToClientRect(rect) {
4541
+ return Object.assign(Object.assign({}, rect), {}, {
4542
+ left: rect.x,
4543
+ top: rect.y,
4544
+ right: rect.x + rect.width,
4545
+ bottom: rect.y + rect.height
4546
+ });
4547
+ }
4548
+
4549
+ function getInnerBoundingClientRect(element) {
4550
+ var rect = getBoundingClientRect(element);
4551
+ rect.top = rect.top + element.clientTop;
4552
+ rect.left = rect.left + element.clientLeft;
4553
+ rect.bottom = rect.top + element.clientHeight;
4554
+ rect.right = rect.left + element.clientWidth;
4555
+ rect.width = element.clientWidth;
4556
+ rect.height = element.clientHeight;
4557
+ rect.x = rect.left;
4558
+ rect.y = rect.top;
4559
+ return rect;
4560
+ }
4561
+
4562
+ function getClientRectFromMixedType(element, clippingParent) {
4563
+ return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isHTMLElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
4564
+ } // A "clipping parent" is an overflowable container with the characteristic of
4565
+ // clipping (or hiding) overflowing elements with a position different from
4566
+ // `initial`
4567
+
4568
+
4569
+ function getClippingParents(element) {
4570
+ var clippingParents = listScrollParents(getParentNode(element));
4571
+ var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle(element).position) >= 0;
4572
+ var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
4573
+
4574
+ if (!isElement$1(clipperElement)) {
4575
+ return [];
4576
+ } // $FlowFixMe: https://github.com/facebook/flow/issues/1414
4577
+
4578
+
4579
+ return clippingParents.filter(function (clippingParent) {
4580
+ return isElement$1(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
4581
+ });
4582
+ } // Gets the maximum area that the element is visible in due to any number of
4583
+ // clipping parents
4584
+
4585
+
4586
+ function getClippingRect(element, boundary, rootBoundary) {
4587
+ var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
4588
+ var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
4589
+ var firstClippingParent = clippingParents[0];
4590
+ var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
4591
+ var rect = getClientRectFromMixedType(element, clippingParent);
4592
+ accRect.top = Math.max(rect.top, accRect.top);
4593
+ accRect.right = Math.min(rect.right, accRect.right);
4594
+ accRect.bottom = Math.min(rect.bottom, accRect.bottom);
4595
+ accRect.left = Math.max(rect.left, accRect.left);
4596
+ return accRect;
4597
+ }, getClientRectFromMixedType(element, firstClippingParent));
4598
+ clippingRect.width = clippingRect.right - clippingRect.left;
4599
+ clippingRect.height = clippingRect.bottom - clippingRect.top;
4600
+ clippingRect.x = clippingRect.left;
4601
+ clippingRect.y = clippingRect.top;
4602
+ return clippingRect;
4603
+ }
4604
+
4605
+ function getVariation(placement) {
4606
+ return placement.split('-')[1];
4607
+ }
4608
+
4609
+ function computeOffsets(_ref) {
4610
+ var reference = _ref.reference,
4611
+ element = _ref.element,
4612
+ placement = _ref.placement;
4613
+ var basePlacement = placement ? getBasePlacement(placement) : null;
4614
+ var variation = placement ? getVariation(placement) : null;
4615
+ var commonX = reference.x + reference.width / 2 - element.width / 2;
4616
+ var commonY = reference.y + reference.height / 2 - element.height / 2;
4617
+ var offsets;
4618
+
4619
+ switch (basePlacement) {
4620
+ case top:
4621
+ offsets = {
4622
+ x: commonX,
4623
+ y: reference.y - element.height
4517
4624
  };
4518
- const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
4519
- const mainAxis = getMainAxisFromPlacement(getSide(placement));
4520
- const crossAxis = getCrossAxis(mainAxis);
4521
- let mainAxisCoord = coords[mainAxis];
4522
- let crossAxisCoord = coords[crossAxis];
4523
- if (checkMainAxis) {
4524
- const minSide = mainAxis === 'y' ? 'top' : 'left';
4525
- const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
4526
- const min = mainAxisCoord + overflow[minSide];
4527
- const max = mainAxisCoord - overflow[maxSide];
4528
- mainAxisCoord = within(min, mainAxisCoord, max);
4529
- }
4530
- if (checkCrossAxis) {
4531
- const minSide = crossAxis === 'y' ? 'top' : 'left';
4532
- const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
4533
- const min = crossAxisCoord + overflow[minSide];
4534
- const max = crossAxisCoord - overflow[maxSide];
4535
- crossAxisCoord = within(min, crossAxisCoord, max);
4536
- }
4537
- const limitedCoords = limiter.fn({
4538
- ...middlewareArguments,
4539
- [mainAxis]: mainAxisCoord,
4540
- [crossAxis]: crossAxisCoord
4541
- });
4542
- return {
4543
- ...limitedCoords,
4544
- data: {
4545
- x: limitedCoords.x - x,
4546
- y: limitedCoords.y - y
4547
- }
4625
+ break;
4626
+
4627
+ case bottom:
4628
+ offsets = {
4629
+ x: commonX,
4630
+ y: reference.y + reference.height
4548
4631
  };
4632
+ break;
4633
+
4634
+ case right:
4635
+ offsets = {
4636
+ x: reference.x + reference.width,
4637
+ y: commonY
4638
+ };
4639
+ break;
4640
+
4641
+ case left:
4642
+ offsets = {
4643
+ x: reference.x - element.width,
4644
+ y: commonY
4645
+ };
4646
+ break;
4647
+
4648
+ default:
4649
+ offsets = {
4650
+ x: reference.x,
4651
+ y: reference.y
4652
+ };
4653
+ }
4654
+
4655
+ var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
4656
+
4657
+ if (mainAxis != null) {
4658
+ var len = mainAxis === 'y' ? 'height' : 'width';
4659
+
4660
+ switch (variation) {
4661
+ case start:
4662
+ offsets[mainAxis] = Math.floor(offsets[mainAxis]) - Math.floor(reference[len] / 2 - element[len] / 2);
4663
+ break;
4664
+
4665
+ case end:
4666
+ offsets[mainAxis] = Math.floor(offsets[mainAxis]) + Math.ceil(reference[len] / 2 - element[len] / 2);
4667
+ break;
4549
4668
  }
4550
- };
4551
- };
4669
+ }
4552
4670
 
4553
- /**
4554
- * Provides data to change the size of the floating element. For instance,
4555
- * prevent it from overflowing its clipping boundary or match the width of the
4556
- * reference element.
4557
- * @see https://floating-ui.com/docs/size
4558
- */
4559
- const size = function (options) {
4671
+ return offsets;
4672
+ }
4673
+
4674
+ function detectOverflow(state, options) {
4560
4675
  if (options === void 0) {
4561
4676
  options = {};
4562
4677
  }
4563
- return {
4564
- name: 'size',
4565
- options,
4566
- async fn(middlewareArguments) {
4567
- const {
4568
- placement,
4569
- rects,
4570
- platform,
4571
- elements
4572
- } = middlewareArguments;
4573
- const {
4574
- apply = () => {},
4575
- ...detectOverflowOptions
4576
- } = options;
4577
- const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
4578
- const side = getSide(placement);
4579
- const alignment = getAlignment(placement);
4580
- let heightSide;
4581
- let widthSide;
4582
- if (side === 'top' || side === 'bottom') {
4583
- heightSide = side;
4584
- widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right';
4585
- } else {
4586
- widthSide = side;
4587
- heightSide = alignment === 'end' ? 'top' : 'bottom';
4588
- }
4589
- const xMin = max(overflow.left, 0);
4590
- const xMax = max(overflow.right, 0);
4591
- const yMin = max(overflow.top, 0);
4592
- const yMax = max(overflow.bottom, 0);
4593
- const dimensions = {
4594
- availableHeight: rects.floating.height - (['left', 'right'].includes(placement) ? 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom)) : overflow[heightSide]),
4595
- availableWidth: rects.floating.width - (['top', 'bottom'].includes(placement) ? 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right)) : overflow[widthSide])
4596
- };
4597
- await apply({
4598
- ...middlewareArguments,
4599
- ...dimensions
4600
- });
4601
- const nextDimensions = await platform.getDimensions(elements.floating);
4602
- if (rects.floating.width !== nextDimensions.width || rects.floating.height !== nextDimensions.height) {
4603
- return {
4604
- reset: {
4605
- rects: true
4606
- }
4607
- };
4608
- }
4609
- return {};
4610
- }
4678
+
4679
+ var _options = options,
4680
+ _options$placement = _options.placement,
4681
+ placement = _options$placement === void 0 ? state.placement : _options$placement,
4682
+ _options$boundary = _options.boundary,
4683
+ boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
4684
+ _options$rootBoundary = _options.rootBoundary,
4685
+ rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
4686
+ _options$elementConte = _options.elementContext,
4687
+ elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
4688
+ _options$altBoundary = _options.altBoundary,
4689
+ altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
4690
+ _options$padding = _options.padding,
4691
+ padding = _options$padding === void 0 ? 0 : _options$padding;
4692
+ var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
4693
+ var altContext = elementContext === popper ? reference : popper;
4694
+ var referenceElement = state.elements.reference;
4695
+ var popperRect = state.rects.popper;
4696
+ var element = state.elements[altBoundary ? altContext : elementContext];
4697
+ var clippingClientRect = getClippingRect(isElement$1(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
4698
+ var referenceClientRect = getBoundingClientRect(referenceElement);
4699
+ var popperOffsets = computeOffsets({
4700
+ reference: referenceClientRect,
4701
+ element: popperRect,
4702
+ strategy: 'absolute',
4703
+ placement: placement
4704
+ });
4705
+ var popperClientRect = rectToClientRect(Object.assign(Object.assign({}, popperRect), popperOffsets));
4706
+ var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect
4707
+ // 0 or negative = within the clipping rect
4708
+
4709
+ var overflowOffsets = {
4710
+ top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
4711
+ bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
4712
+ left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
4713
+ right: elementClientRect.right - clippingClientRect.right + paddingObject.right
4611
4714
  };
4612
- };
4715
+ var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element
4716
+
4717
+ if (elementContext === popper && offsetData) {
4718
+ var offset = offsetData[placement];
4719
+ Object.keys(overflowOffsets).forEach(function (key) {
4720
+ var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
4721
+ var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
4722
+ overflowOffsets[key] += offset[axis] * multiply;
4723
+ });
4724
+ }
4613
4725
 
4614
- function getWindow(node) {
4615
- var _node$ownerDocument;
4616
- return ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
4726
+ return overflowOffsets;
4617
4727
  }
4618
4728
 
4619
- function getComputedStyle$1(element) {
4620
- return getWindow(element).getComputedStyle(element);
4729
+ /*:: type OverflowsMap = { [ComputedPlacement]: number }; */
4730
+
4731
+ /*;; type OverflowsMap = { [key in ComputedPlacement]: number }; */
4732
+ function computeAutoPlacement(state, options) {
4733
+ if (options === void 0) {
4734
+ options = {};
4735
+ }
4736
+
4737
+ var _options = options,
4738
+ placement = _options.placement,
4739
+ boundary = _options.boundary,
4740
+ rootBoundary = _options.rootBoundary,
4741
+ padding = _options.padding,
4742
+ flipVariations = _options.flipVariations,
4743
+ _options$allowedAutoP = _options.allowedAutoPlacements,
4744
+ allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP;
4745
+ var variation = getVariation(placement);
4746
+ var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) {
4747
+ return getVariation(placement) === variation;
4748
+ }) : basePlacements; // $FlowFixMe
4749
+
4750
+ var allowedPlacements = placements$1.filter(function (placement) {
4751
+ return allowedAutoPlacements.indexOf(placement) >= 0;
4752
+ });
4753
+
4754
+ if (allowedPlacements.length === 0) {
4755
+ allowedPlacements = placements$1;
4756
+
4757
+ if (process.env.NODE_ENV !== "production") {
4758
+ 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(' '));
4759
+ }
4760
+ } // $FlowFixMe: Flow seems to have problems with two array unions...
4761
+
4762
+
4763
+ var overflows = allowedPlacements.reduce(function (acc, placement) {
4764
+ acc[placement] = detectOverflow(state, {
4765
+ placement: placement,
4766
+ boundary: boundary,
4767
+ rootBoundary: rootBoundary,
4768
+ padding: padding
4769
+ })[getBasePlacement(placement)];
4770
+ return acc;
4771
+ }, {});
4772
+ return Object.keys(overflows).sort(function (a, b) {
4773
+ return overflows[a] - overflows[b];
4774
+ });
4621
4775
  }
4622
4776
 
4623
- function getNodeName(node) {
4624
- return isNode(node) ? (node.nodeName || '').toLowerCase() : '';
4777
+ function getExpandedFallbackPlacements(placement) {
4778
+ if (getBasePlacement(placement) === auto) {
4779
+ return [];
4780
+ }
4781
+
4782
+ var oppositePlacement = getOppositePlacement(placement);
4783
+ return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];
4625
4784
  }
4626
4785
 
4627
- let uaString;
4628
- function getUAString() {
4629
- if (uaString) {
4630
- return uaString;
4786
+ function flip(_ref) {
4787
+ var state = _ref.state,
4788
+ options = _ref.options,
4789
+ name = _ref.name;
4790
+
4791
+ if (state.modifiersData[name]._skip) {
4792
+ return;
4631
4793
  }
4632
- const uaData = navigator.userAgentData;
4633
- if (uaData && Array.isArray(uaData.brands)) {
4634
- uaString = uaData.brands.map(item => item.brand + "/" + item.version).join(' ');
4635
- return uaString;
4794
+
4795
+ var _options$mainAxis = options.mainAxis,
4796
+ checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
4797
+ _options$altAxis = options.altAxis,
4798
+ checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis,
4799
+ specifiedFallbackPlacements = options.fallbackPlacements,
4800
+ padding = options.padding,
4801
+ boundary = options.boundary,
4802
+ rootBoundary = options.rootBoundary,
4803
+ altBoundary = options.altBoundary,
4804
+ _options$flipVariatio = options.flipVariations,
4805
+ flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio,
4806
+ allowedAutoPlacements = options.allowedAutoPlacements;
4807
+ var preferredPlacement = state.options.placement;
4808
+ var basePlacement = getBasePlacement(preferredPlacement);
4809
+ var isBasePlacement = basePlacement === preferredPlacement;
4810
+ var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
4811
+ var placements = [preferredPlacement].concat(fallbackPlacements).reduce(function (acc, placement) {
4812
+ return acc.concat(getBasePlacement(placement) === auto ? computeAutoPlacement(state, {
4813
+ placement: placement,
4814
+ boundary: boundary,
4815
+ rootBoundary: rootBoundary,
4816
+ padding: padding,
4817
+ flipVariations: flipVariations,
4818
+ allowedAutoPlacements: allowedAutoPlacements
4819
+ }) : placement);
4820
+ }, []);
4821
+ var referenceRect = state.rects.reference;
4822
+ var popperRect = state.rects.popper;
4823
+ var checksMap = new Map();
4824
+ var makeFallbackChecks = true;
4825
+ var firstFittingPlacement = placements[0];
4826
+
4827
+ for (var i = 0; i < placements.length; i++) {
4828
+ var placement = placements[i];
4829
+
4830
+ var _basePlacement = getBasePlacement(placement);
4831
+
4832
+ var isStartVariation = getVariation(placement) === start;
4833
+ var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
4834
+ var len = isVertical ? 'width' : 'height';
4835
+ var overflow = detectOverflow(state, {
4836
+ placement: placement,
4837
+ boundary: boundary,
4838
+ rootBoundary: rootBoundary,
4839
+ altBoundary: altBoundary,
4840
+ padding: padding
4841
+ });
4842
+ var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
4843
+
4844
+ if (referenceRect[len] > popperRect[len]) {
4845
+ mainVariationSide = getOppositePlacement(mainVariationSide);
4846
+ }
4847
+
4848
+ var altVariationSide = getOppositePlacement(mainVariationSide);
4849
+ var checks = [];
4850
+
4851
+ if (checkMainAxis) {
4852
+ checks.push(overflow[_basePlacement] <= 0);
4853
+ }
4854
+
4855
+ if (checkAltAxis) {
4856
+ checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
4857
+ }
4858
+
4859
+ if (checks.every(function (check) {
4860
+ return check;
4861
+ })) {
4862
+ firstFittingPlacement = placement;
4863
+ makeFallbackChecks = false;
4864
+ break;
4865
+ }
4866
+
4867
+ checksMap.set(placement, checks);
4636
4868
  }
4637
- return navigator.userAgent;
4638
- }
4639
4869
 
4640
- function isHTMLElement(value) {
4641
- return value instanceof getWindow(value).HTMLElement;
4642
- }
4643
- function isElement$1(value) {
4644
- return value instanceof getWindow(value).Element;
4645
- }
4646
- function isNode(value) {
4647
- return value instanceof getWindow(value).Node;
4648
- }
4649
- function isShadowRoot(node) {
4650
- // Browsers without `ShadowRoot` support
4651
- if (typeof ShadowRoot === 'undefined') {
4652
- return false;
4870
+ if (makeFallbackChecks) {
4871
+ // `2` may be desired in some cases – research later
4872
+ var numberOfChecks = flipVariations ? 3 : 1;
4873
+
4874
+ var _loop = function _loop(_i) {
4875
+ var fittingPlacement = placements.find(function (placement) {
4876
+ var checks = checksMap.get(placement);
4877
+
4878
+ if (checks) {
4879
+ return checks.slice(0, _i).every(function (check) {
4880
+ return check;
4881
+ });
4882
+ }
4883
+ });
4884
+
4885
+ if (fittingPlacement) {
4886
+ firstFittingPlacement = fittingPlacement;
4887
+ return "break";
4888
+ }
4889
+ };
4890
+
4891
+ for (var _i = numberOfChecks; _i > 0; _i--) {
4892
+ var _ret = _loop(_i);
4893
+
4894
+ if (_ret === "break") break;
4895
+ }
4653
4896
  }
4654
- const OwnElement = getWindow(node).ShadowRoot;
4655
- return node instanceof OwnElement || node instanceof ShadowRoot;
4656
- }
4657
- function isOverflowElement(element) {
4658
- const {
4659
- overflow,
4660
- overflowX,
4661
- overflowY,
4662
- display
4663
- } = getComputedStyle$1(element);
4664
- return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
4665
- }
4666
- function isTableElement(element) {
4667
- return ['table', 'td', 'th'].includes(getNodeName(element));
4668
- }
4669
- function isContainingBlock(element) {
4670
- // TODO: Try and use feature detection here instead
4671
- const isFirefox = /firefox/i.test(getUAString());
4672
- const css = getComputedStyle$1(element);
4673
- const backdropFilter = css.backdropFilter || css.WebkitBackdropFilter;
4674
-
4675
- // This is non-exhaustive but covers the most common CSS properties that
4676
- // create a containing block.
4677
- // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
4678
- return css.transform !== 'none' || css.perspective !== 'none' || (backdropFilter ? backdropFilter !== 'none' : false) || isFirefox && css.willChange === 'filter' || isFirefox && (css.filter ? css.filter !== 'none' : false) || ['transform', 'perspective'].some(value => css.willChange.includes(value)) || ['paint', 'layout', 'strict', 'content'].some(
4679
- // TS 4.1 compat
4680
- value => {
4681
- const contain = css.contain;
4682
- return contain != null ? contain.includes(value) : false;
4683
- });
4684
- }
4685
- function isLayoutViewport() {
4686
- // Not Safari
4687
- return !/^((?!chrome|android).)*safari/i.test(getUAString());
4688
- // Feature detection for this fails in various ways
4689
- // • Always-visible scrollbar or not
4690
- // • Width of <html>, etc.
4691
- // const vV = win.visualViewport;
4692
- // return vV ? Math.abs(win.innerWidth / vV.scale - vV.width) < 0.5 : true;
4693
- }
4694
4897
 
4695
- function isLastTraversableNode(node) {
4696
- return ['html', 'body', '#document'].includes(getNodeName(node));
4697
- }
4898
+ if (state.placement !== firstFittingPlacement) {
4899
+ state.modifiersData[name]._skip = true;
4900
+ state.placement = firstFittingPlacement;
4901
+ state.reset = true;
4902
+ }
4903
+ } // eslint-disable-next-line import/no-unused-modules
4904
+
4905
+
4906
+ var flip$1 = {
4907
+ name: 'flip',
4908
+ enabled: true,
4909
+ phase: 'main',
4910
+ fn: flip,
4911
+ requiresIfExists: ['offset'],
4912
+ data: {
4913
+ _skip: false
4914
+ }
4915
+ };
4698
4916
 
4699
- const min$1 = Math.min;
4700
- const max$1 = Math.max;
4701
- const round = Math.round;
4702
-
4703
- function getCssDimensions(element) {
4704
- const css = getComputedStyle$1(element);
4705
- let width = parseFloat(css.width);
4706
- let height = parseFloat(css.height);
4707
- const offsetWidth = element.offsetWidth;
4708
- const offsetHeight = element.offsetHeight;
4709
- const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
4710
- if (shouldFallback) {
4711
- width = offsetWidth;
4712
- height = offsetHeight;
4917
+ function getSideOffsets(overflow, rect, preventedOffsets) {
4918
+ if (preventedOffsets === void 0) {
4919
+ preventedOffsets = {
4920
+ x: 0,
4921
+ y: 0
4922
+ };
4713
4923
  }
4924
+
4714
4925
  return {
4715
- width,
4716
- height,
4717
- fallback: shouldFallback
4926
+ top: overflow.top - rect.height - preventedOffsets.y,
4927
+ right: overflow.right - rect.width + preventedOffsets.x,
4928
+ bottom: overflow.bottom - rect.height + preventedOffsets.y,
4929
+ left: overflow.left - rect.width - preventedOffsets.x
4718
4930
  };
4719
4931
  }
4720
4932
 
4721
- function unwrapElement(element) {
4722
- return !isElement$1(element) ? element.contextElement : element;
4933
+ function isAnySideFullyClipped(overflow) {
4934
+ return [top, right, bottom, left].some(function (side) {
4935
+ return overflow[side] >= 0;
4936
+ });
4723
4937
  }
4724
4938
 
4725
- const FALLBACK_SCALE = {
4726
- x: 1,
4727
- y: 1
4939
+ function hide(_ref) {
4940
+ var state = _ref.state,
4941
+ name = _ref.name;
4942
+ var referenceRect = state.rects.reference;
4943
+ var popperRect = state.rects.popper;
4944
+ var preventedOffsets = state.modifiersData.preventOverflow;
4945
+ var referenceOverflow = detectOverflow(state, {
4946
+ elementContext: 'reference'
4947
+ });
4948
+ var popperAltOverflow = detectOverflow(state, {
4949
+ altBoundary: true
4950
+ });
4951
+ var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
4952
+ var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
4953
+ var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
4954
+ var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
4955
+ state.modifiersData[name] = {
4956
+ referenceClippingOffsets: referenceClippingOffsets,
4957
+ popperEscapeOffsets: popperEscapeOffsets,
4958
+ isReferenceHidden: isReferenceHidden,
4959
+ hasPopperEscaped: hasPopperEscaped
4960
+ };
4961
+ state.attributes.popper = Object.assign(Object.assign({}, state.attributes.popper), {}, {
4962
+ 'data-popper-reference-hidden': isReferenceHidden,
4963
+ 'data-popper-escaped': hasPopperEscaped
4964
+ });
4965
+ } // eslint-disable-next-line import/no-unused-modules
4966
+
4967
+
4968
+ var hide$1 = {
4969
+ name: 'hide',
4970
+ enabled: true,
4971
+ phase: 'main',
4972
+ requiresIfExists: ['preventOverflow'],
4973
+ fn: hide
4728
4974
  };
4729
- function getScale(element) {
4730
- const domElement = unwrapElement(element);
4731
- if (!isHTMLElement(domElement)) {
4732
- return FALLBACK_SCALE;
4733
- }
4734
- const rect = domElement.getBoundingClientRect();
4735
- const {
4736
- width,
4737
- height,
4738
- fallback
4739
- } = getCssDimensions(domElement);
4740
- let x = (fallback ? round(rect.width) : rect.width) / width;
4741
- let y = (fallback ? round(rect.height) : rect.height) / height;
4742
4975
 
4743
- // 0, NaN, or Infinity should always fallback to 1.
4976
+ function distanceAndSkiddingToXY(placement, rects, offset) {
4977
+ var basePlacement = getBasePlacement(placement);
4978
+ var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
4744
4979
 
4745
- if (!x || !Number.isFinite(x)) {
4746
- x = 1;
4747
- }
4748
- if (!y || !Number.isFinite(y)) {
4749
- y = 1;
4750
- }
4751
- return {
4752
- x,
4753
- y
4980
+ var _ref = typeof offset === 'function' ? offset(Object.assign(Object.assign({}, rects), {}, {
4981
+ placement: placement
4982
+ })) : offset,
4983
+ skidding = _ref[0],
4984
+ distance = _ref[1];
4985
+
4986
+ skidding = skidding || 0;
4987
+ distance = (distance || 0) * invertDistance;
4988
+ return [left, right].indexOf(basePlacement) >= 0 ? {
4989
+ x: distance,
4990
+ y: skidding
4991
+ } : {
4992
+ x: skidding,
4993
+ y: distance
4754
4994
  };
4755
4995
  }
4756
4996
 
4757
- function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
4758
- var _win$visualViewport, _win$visualViewport2;
4759
- if (includeScale === void 0) {
4760
- includeScale = false;
4761
- }
4762
- if (isFixedStrategy === void 0) {
4763
- isFixedStrategy = false;
4764
- }
4765
- const clientRect = element.getBoundingClientRect();
4766
- const domElement = unwrapElement(element);
4767
- let scale = FALLBACK_SCALE;
4768
- if (includeScale) {
4769
- if (offsetParent) {
4770
- if (isElement$1(offsetParent)) {
4771
- scale = getScale(offsetParent);
4772
- }
4773
- } else {
4774
- scale = getScale(element);
4775
- }
4776
- }
4777
- const win = domElement ? getWindow(domElement) : window;
4778
- const addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
4779
- let x = (clientRect.left + (addVisualOffsets ? ((_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) || 0 : 0)) / scale.x;
4780
- let y = (clientRect.top + (addVisualOffsets ? ((_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) || 0 : 0)) / scale.y;
4781
- let width = clientRect.width / scale.x;
4782
- let height = clientRect.height / scale.y;
4783
- if (domElement) {
4784
- const win = getWindow(domElement);
4785
- const offsetWin = offsetParent && isElement$1(offsetParent) ? getWindow(offsetParent) : offsetParent;
4786
- let currentIFrame = win.frameElement;
4787
- while (currentIFrame && offsetParent && offsetWin !== win) {
4788
- const iframeScale = getScale(currentIFrame);
4789
- const iframeRect = currentIFrame.getBoundingClientRect();
4790
- const css = getComputedStyle(currentIFrame);
4791
- iframeRect.x += (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
4792
- iframeRect.y += (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
4793
- x *= iframeScale.x;
4794
- y *= iframeScale.y;
4795
- width *= iframeScale.x;
4796
- height *= iframeScale.y;
4797
- x += iframeRect.x;
4798
- y += iframeRect.y;
4799
- currentIFrame = getWindow(currentIFrame).frameElement;
4800
- }
4997
+ function offset(_ref2) {
4998
+ var state = _ref2.state,
4999
+ options = _ref2.options,
5000
+ name = _ref2.name;
5001
+ var _options$offset = options.offset,
5002
+ offset = _options$offset === void 0 ? [0, 0] : _options$offset;
5003
+ var data = placements.reduce(function (acc, placement) {
5004
+ acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
5005
+ return acc;
5006
+ }, {});
5007
+ var _data$state$placement = data[state.placement],
5008
+ x = _data$state$placement.x,
5009
+ y = _data$state$placement.y;
5010
+
5011
+ if (state.modifiersData.popperOffsets != null) {
5012
+ state.modifiersData.popperOffsets.x += x;
5013
+ state.modifiersData.popperOffsets.y += y;
4801
5014
  }
4802
- return {
4803
- width,
4804
- height,
4805
- top: y,
4806
- right: x + width,
4807
- bottom: y + height,
4808
- left: x,
4809
- x,
4810
- y
4811
- };
4812
- }
4813
5015
 
4814
- function getDocumentElement(node) {
4815
- return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
5016
+ state.modifiersData[name] = data;
5017
+ } // eslint-disable-next-line import/no-unused-modules
5018
+
5019
+
5020
+ var offset$1 = {
5021
+ name: 'offset',
5022
+ enabled: true,
5023
+ phase: 'main',
5024
+ requires: ['popperOffsets'],
5025
+ fn: offset
5026
+ };
5027
+
5028
+ function popperOffsets(_ref) {
5029
+ var state = _ref.state,
5030
+ name = _ref.name;
5031
+ // Offsets are the actual position the popper needs to have to be
5032
+ // properly positioned near its reference element
5033
+ // This is the most basic placement, and will be adjusted by
5034
+ // the modifiers in the next step
5035
+ state.modifiersData[name] = computeOffsets({
5036
+ reference: state.rects.reference,
5037
+ element: state.rects.popper,
5038
+ strategy: 'absolute',
5039
+ placement: state.placement
5040
+ });
5041
+ } // eslint-disable-next-line import/no-unused-modules
5042
+
5043
+
5044
+ var popperOffsets$1 = {
5045
+ name: 'popperOffsets',
5046
+ enabled: true,
5047
+ phase: 'read',
5048
+ fn: popperOffsets,
5049
+ data: {}
5050
+ };
5051
+
5052
+ function getAltAxis(axis) {
5053
+ return axis === 'x' ? 'y' : 'x';
4816
5054
  }
4817
5055
 
4818
- function getNodeScroll(element) {
4819
- if (isElement$1(element)) {
4820
- return {
4821
- scrollLeft: element.scrollLeft,
4822
- scrollTop: element.scrollTop
5056
+ function preventOverflow(_ref) {
5057
+ var state = _ref.state,
5058
+ options = _ref.options,
5059
+ name = _ref.name;
5060
+ var _options$mainAxis = options.mainAxis,
5061
+ checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
5062
+ _options$altAxis = options.altAxis,
5063
+ checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis,
5064
+ boundary = options.boundary,
5065
+ rootBoundary = options.rootBoundary,
5066
+ altBoundary = options.altBoundary,
5067
+ padding = options.padding,
5068
+ _options$tether = options.tether,
5069
+ tether = _options$tether === void 0 ? true : _options$tether,
5070
+ _options$tetherOffset = options.tetherOffset,
5071
+ tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
5072
+ var overflow = detectOverflow(state, {
5073
+ boundary: boundary,
5074
+ rootBoundary: rootBoundary,
5075
+ padding: padding,
5076
+ altBoundary: altBoundary
5077
+ });
5078
+ var basePlacement = getBasePlacement(state.placement);
5079
+ var variation = getVariation(state.placement);
5080
+ var isBasePlacement = !variation;
5081
+ var mainAxis = getMainAxisFromPlacement(basePlacement);
5082
+ var altAxis = getAltAxis(mainAxis);
5083
+ var popperOffsets = state.modifiersData.popperOffsets;
5084
+ var referenceRect = state.rects.reference;
5085
+ var popperRect = state.rects.popper;
5086
+ var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign(Object.assign({}, state.rects), {}, {
5087
+ placement: state.placement
5088
+ })) : tetherOffset;
5089
+ var data = {
5090
+ x: 0,
5091
+ y: 0
5092
+ };
5093
+
5094
+ if (!popperOffsets) {
5095
+ return;
5096
+ }
5097
+
5098
+ if (checkMainAxis) {
5099
+ var mainSide = mainAxis === 'y' ? top : left;
5100
+ var altSide = mainAxis === 'y' ? bottom : right;
5101
+ var len = mainAxis === 'y' ? 'height' : 'width';
5102
+ var offset = popperOffsets[mainAxis];
5103
+ var min = popperOffsets[mainAxis] + overflow[mainSide];
5104
+ var max = popperOffsets[mainAxis] - overflow[altSide];
5105
+ var additive = tether ? -popperRect[len] / 2 : 0;
5106
+ var minLen = variation === start ? referenceRect[len] : popperRect[len];
5107
+ var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
5108
+ // outside the reference bounds
5109
+
5110
+ var arrowElement = state.elements.arrow;
5111
+ var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
5112
+ width: 0,
5113
+ height: 0
4823
5114
  };
5115
+ var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject();
5116
+ var arrowPaddingMin = arrowPaddingObject[mainSide];
5117
+ var arrowPaddingMax = arrowPaddingObject[altSide]; // If the reference length is smaller than the arrow length, we don't want
5118
+ // to include its full size in the calculation. If the reference is small
5119
+ // and near the edge of a boundary, the popper can overflow even if the
5120
+ // reference is not overflowing as well (e.g. virtual elements with no
5121
+ // width or height)
5122
+
5123
+ var arrowLen = within(0, referenceRect[len], arrowRect[len]);
5124
+ var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - tetherOffsetValue : minLen - arrowLen - arrowPaddingMin - tetherOffsetValue;
5125
+ var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + tetherOffsetValue : maxLen + arrowLen + arrowPaddingMax + tetherOffsetValue;
5126
+ var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
5127
+ var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
5128
+ var offsetModifierValue = state.modifiersData.offset ? state.modifiersData.offset[state.placement][mainAxis] : 0;
5129
+ var tetherMin = popperOffsets[mainAxis] + minOffset - offsetModifierValue - clientOffset;
5130
+ var tetherMax = popperOffsets[mainAxis] + maxOffset - offsetModifierValue;
5131
+ var preventedOffset = within(tether ? Math.min(min, tetherMin) : min, offset, tether ? Math.max(max, tetherMax) : max);
5132
+ popperOffsets[mainAxis] = preventedOffset;
5133
+ data[mainAxis] = preventedOffset - offset;
5134
+ }
5135
+
5136
+ if (checkAltAxis) {
5137
+ var _mainSide = mainAxis === 'x' ? top : left;
5138
+
5139
+ var _altSide = mainAxis === 'x' ? bottom : right;
5140
+
5141
+ var _offset = popperOffsets[altAxis];
5142
+
5143
+ var _min = _offset + overflow[_mainSide];
5144
+
5145
+ var _max = _offset - overflow[_altSide];
5146
+
5147
+ var _preventedOffset = within(_min, _offset, _max);
5148
+
5149
+ popperOffsets[altAxis] = _preventedOffset;
5150
+ data[altAxis] = _preventedOffset - _offset;
4824
5151
  }
5152
+
5153
+ state.modifiersData[name] = data;
5154
+ } // eslint-disable-next-line import/no-unused-modules
5155
+
5156
+
5157
+ var preventOverflow$1 = {
5158
+ name: 'preventOverflow',
5159
+ enabled: true,
5160
+ phase: 'main',
5161
+ fn: preventOverflow,
5162
+ requiresIfExists: ['offset']
5163
+ };
5164
+
5165
+ function getHTMLElementScroll(element) {
4825
5166
  return {
4826
- scrollLeft: element.pageXOffset,
4827
- scrollTop: element.pageYOffset
5167
+ scrollLeft: element.scrollLeft,
5168
+ scrollTop: element.scrollTop
4828
5169
  };
4829
5170
  }
4830
5171
 
4831
- function getWindowScrollBarX(element) {
4832
- // If <html> has a CSS width greater than the viewport, then this will be
4833
- // incorrect for RTL.
4834
- return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
5172
+ function getNodeScroll(node) {
5173
+ if (node === getWindow(node) || !isHTMLElement(node)) {
5174
+ return getWindowScroll(node);
5175
+ } else {
5176
+ return getHTMLElementScroll(node);
5177
+ }
4835
5178
  }
4836
5179
 
4837
- function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
4838
- const isOffsetParentAnElement = isHTMLElement(offsetParent);
4839
- const documentElement = getDocumentElement(offsetParent);
4840
- const rect = getBoundingClientRect(element, true, strategy === 'fixed', offsetParent);
4841
- let scroll = {
5180
+ // Composite means it takes into account transforms as well as layout.
5181
+
5182
+ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
5183
+ if (isFixed === void 0) {
5184
+ isFixed = false;
5185
+ }
5186
+
5187
+ var documentElement = getDocumentElement(offsetParent);
5188
+ var rect = getBoundingClientRect(elementOrVirtualElement);
5189
+ var isOffsetParentAnElement = isHTMLElement(offsetParent);
5190
+ var scroll = {
4842
5191
  scrollLeft: 0,
4843
5192
  scrollTop: 0
4844
5193
  };
4845
- const offsets = {
5194
+ var offsets = {
4846
5195
  x: 0,
4847
5196
  y: 0
4848
5197
  };
4849
- if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
4850
- if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
5198
+
5199
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
5200
+ if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078
5201
+ isScrollParent(documentElement)) {
4851
5202
  scroll = getNodeScroll(offsetParent);
4852
5203
  }
5204
+
4853
5205
  if (isHTMLElement(offsetParent)) {
4854
- const offsetRect = getBoundingClientRect(offsetParent, true);
4855
- offsets.x = offsetRect.x + offsetParent.clientLeft;
4856
- offsets.y = offsetRect.y + offsetParent.clientTop;
5206
+ offsets = getBoundingClientRect(offsetParent);
5207
+ offsets.x += offsetParent.clientLeft;
5208
+ offsets.y += offsetParent.clientTop;
4857
5209
  } else if (documentElement) {
4858
5210
  offsets.x = getWindowScrollBarX(documentElement);
4859
5211
  }
4860
5212
  }
5213
+
4861
5214
  return {
4862
5215
  x: rect.left + scroll.scrollLeft - offsets.x,
4863
5216
  y: rect.top + scroll.scrollTop - offsets.y,
@@ -4866,553 +5219,651 @@ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
4866
5219
  };
4867
5220
  }
4868
5221
 
4869
- function getParentNode(node) {
4870
- if (getNodeName(node) === 'html') {
4871
- return node;
5222
+ function order(modifiers) {
5223
+ var map = new Map();
5224
+ var visited = new Set();
5225
+ var result = [];
5226
+ modifiers.forEach(function (modifier) {
5227
+ map.set(modifier.name, modifier);
5228
+ }); // On visiting object, check for its dependencies and visit them recursively
5229
+
5230
+ function sort(modifier) {
5231
+ visited.add(modifier.name);
5232
+ var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
5233
+ requires.forEach(function (dep) {
5234
+ if (!visited.has(dep)) {
5235
+ var depModifier = map.get(dep);
5236
+
5237
+ if (depModifier) {
5238
+ sort(depModifier);
5239
+ }
5240
+ }
5241
+ });
5242
+ result.push(modifier);
4872
5243
  }
4873
- const result =
4874
- // Step into the shadow DOM of the parent of a slotted node
4875
- node.assignedSlot ||
4876
- // DOM Element detected
4877
- node.parentNode || (
4878
- // ShadowRoot detected
4879
- isShadowRoot(node) ? node.host : null) ||
4880
- // Fallback
4881
- getDocumentElement(node);
4882
- return isShadowRoot(result) ? result.host : result;
4883
- }
4884
5244
 
4885
- function getTrueOffsetParent(element) {
4886
- if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
4887
- return null;
4888
- }
4889
- return element.offsetParent;
4890
- }
4891
- function getContainingBlock(element) {
4892
- let currentNode = getParentNode(element);
4893
- while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
4894
- if (isContainingBlock(currentNode)) {
4895
- return currentNode;
4896
- } else {
4897
- currentNode = getParentNode(currentNode);
5245
+ modifiers.forEach(function (modifier) {
5246
+ if (!visited.has(modifier.name)) {
5247
+ // check for visited object
5248
+ sort(modifier);
4898
5249
  }
4899
- }
4900
- return null;
5250
+ });
5251
+ return result;
4901
5252
  }
4902
5253
 
4903
- // Gets the closest ancestor positioned element. Handles some edge cases,
4904
- // such as table ancestors and cross browser bugs.
4905
- function getOffsetParent(element) {
4906
- const window = getWindow(element);
4907
- let offsetParent = getTrueOffsetParent(element);
4908
- while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === 'static') {
4909
- offsetParent = getTrueOffsetParent(offsetParent);
4910
- }
4911
- if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle$1(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
4912
- return window;
4913
- }
4914
- return offsetParent || getContainingBlock(element) || window;
4915
- }
5254
+ function orderModifiers(modifiers) {
5255
+ // order based on dependencies
5256
+ var orderedModifiers = order(modifiers); // order based on phase
4916
5257
 
4917
- function getDimensions(element) {
4918
- return getCssDimensions(element);
5258
+ return modifierPhases.reduce(function (acc, phase) {
5259
+ return acc.concat(orderedModifiers.filter(function (modifier) {
5260
+ return modifier.phase === phase;
5261
+ }));
5262
+ }, []);
4919
5263
  }
4920
5264
 
4921
- function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
4922
- let {
4923
- rect,
4924
- offsetParent,
4925
- strategy
4926
- } = _ref;
4927
- const isOffsetParentAnElement = isHTMLElement(offsetParent);
4928
- const documentElement = getDocumentElement(offsetParent);
4929
- if (offsetParent === documentElement) {
4930
- return rect;
4931
- }
4932
- let scroll = {
4933
- scrollLeft: 0,
4934
- scrollTop: 0
4935
- };
4936
- let scale = {
4937
- x: 1,
4938
- y: 1
4939
- };
4940
- const offsets = {
4941
- x: 0,
4942
- y: 0
4943
- };
4944
- if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
4945
- if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
4946
- scroll = getNodeScroll(offsetParent);
5265
+ function debounce(fn) {
5266
+ var pending;
5267
+ return function () {
5268
+ if (!pending) {
5269
+ pending = new Promise(function (resolve) {
5270
+ Promise.resolve().then(function () {
5271
+ pending = undefined;
5272
+ resolve(fn());
5273
+ });
5274
+ });
4947
5275
  }
4948
- if (isHTMLElement(offsetParent)) {
4949
- const offsetRect = getBoundingClientRect(offsetParent);
4950
- scale = getScale(offsetParent);
4951
- offsets.x = offsetRect.x + offsetParent.clientLeft;
4952
- offsets.y = offsetRect.y + offsetParent.clientTop;
4953
- }
4954
- // This doesn't appear to need to be negated.
4955
- // else if (documentElement) {
4956
- // offsets.x = getWindowScrollBarX(documentElement);
4957
- // }
4958
- }
4959
5276
 
4960
- return {
4961
- width: rect.width * scale.x,
4962
- height: rect.height * scale.y,
4963
- x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x,
4964
- y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y
5277
+ return pending;
4965
5278
  };
4966
5279
  }
4967
5280
 
4968
- function getViewportRect(element, strategy) {
4969
- const win = getWindow(element);
4970
- const html = getDocumentElement(element);
4971
- const visualViewport = win.visualViewport;
4972
- let width = html.clientWidth;
4973
- let height = html.clientHeight;
4974
- let x = 0;
4975
- let y = 0;
4976
- if (visualViewport) {
4977
- width = visualViewport.width;
4978
- height = visualViewport.height;
4979
- const layoutViewport = isLayoutViewport();
4980
- if (layoutViewport || !layoutViewport && strategy === 'fixed') {
4981
- x = visualViewport.offsetLeft;
4982
- y = visualViewport.offsetTop;
4983
- }
5281
+ function format(str) {
5282
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
5283
+ args[_key - 1] = arguments[_key];
4984
5284
  }
4985
- return {
4986
- width,
4987
- height,
4988
- x,
4989
- y
4990
- };
4991
- }
4992
5285
 
4993
- // Gets the entire size of the scrollable document area, even extending outside
4994
- // of the `<html>` and `<body>` rect bounds if horizontally scrollable
4995
- function getDocumentRect(element) {
4996
- var _element$ownerDocumen;
4997
- const html = getDocumentElement(element);
4998
- const scroll = getNodeScroll(element);
4999
- const body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
5000
- const width = max$1(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
5001
- const height = max$1(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
5002
- let x = -scroll.scrollLeft + getWindowScrollBarX(element);
5003
- const y = -scroll.scrollTop;
5004
- if (getComputedStyle$1(body || html).direction === 'rtl') {
5005
- x += max$1(html.clientWidth, body ? body.clientWidth : 0) - width;
5006
- }
5007
- return {
5008
- width,
5009
- height,
5010
- x,
5011
- y
5012
- };
5286
+ return [].concat(args).reduce(function (p, c) {
5287
+ return p.replace(/%s/, c);
5288
+ }, str);
5013
5289
  }
5014
5290
 
5015
- function getNearestOverflowAncestor(node) {
5016
- const parentNode = getParentNode(node);
5017
- if (isLastTraversableNode(parentNode)) {
5018
- // @ts-ignore assume body is always available
5019
- return node.ownerDocument.body;
5020
- }
5021
- if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
5022
- return parentNode;
5023
- }
5024
- return getNearestOverflowAncestor(parentNode);
5291
+ var INVALID_MODIFIER_ERROR = 'Popper: modifier "%s" provided an invalid %s property, expected %s but got %s';
5292
+ var MISSING_DEPENDENCY_ERROR = 'Popper: modifier "%s" requires "%s", but "%s" modifier is not available';
5293
+ var VALID_PROPERTIES = ['name', 'enabled', 'phase', 'fn', 'effect', 'requires', 'options'];
5294
+ function validateModifiers(modifiers) {
5295
+ modifiers.forEach(function (modifier) {
5296
+ Object.keys(modifier).forEach(function (key) {
5297
+ switch (key) {
5298
+ case 'name':
5299
+ if (typeof modifier.name !== 'string') {
5300
+ console.error(format(INVALID_MODIFIER_ERROR, String(modifier.name), '"name"', '"string"', "\"" + String(modifier.name) + "\""));
5301
+ }
5302
+
5303
+ break;
5304
+
5305
+ case 'enabled':
5306
+ if (typeof modifier.enabled !== 'boolean') {
5307
+ console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"enabled"', '"boolean"', "\"" + String(modifier.enabled) + "\""));
5308
+ }
5309
+
5310
+ case 'phase':
5311
+ if (modifierPhases.indexOf(modifier.phase) < 0) {
5312
+ console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"phase"', "either " + modifierPhases.join(', '), "\"" + String(modifier.phase) + "\""));
5313
+ }
5314
+
5315
+ break;
5316
+
5317
+ case 'fn':
5318
+ if (typeof modifier.fn !== 'function') {
5319
+ console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"fn"', '"function"', "\"" + String(modifier.fn) + "\""));
5320
+ }
5321
+
5322
+ break;
5323
+
5324
+ case 'effect':
5325
+ if (typeof modifier.effect !== 'function') {
5326
+ console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"effect"', '"function"', "\"" + String(modifier.fn) + "\""));
5327
+ }
5328
+
5329
+ break;
5330
+
5331
+ case 'requires':
5332
+ if (!Array.isArray(modifier.requires)) {
5333
+ console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requires"', '"array"', "\"" + String(modifier.requires) + "\""));
5334
+ }
5335
+
5336
+ break;
5337
+
5338
+ case 'requiresIfExists':
5339
+ if (!Array.isArray(modifier.requiresIfExists)) {
5340
+ console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requiresIfExists"', '"array"', "\"" + String(modifier.requiresIfExists) + "\""));
5341
+ }
5342
+
5343
+ break;
5344
+
5345
+ case 'options':
5346
+ case 'data':
5347
+ break;
5348
+
5349
+ default:
5350
+ console.error("PopperJS: an invalid property has been provided to the \"" + modifier.name + "\" modifier, valid properties are " + VALID_PROPERTIES.map(function (s) {
5351
+ return "\"" + s + "\"";
5352
+ }).join(', ') + "; but \"" + key + "\" was provided.");
5353
+ }
5354
+
5355
+ modifier.requires && modifier.requires.forEach(function (requirement) {
5356
+ if (modifiers.find(function (mod) {
5357
+ return mod.name === requirement;
5358
+ }) == null) {
5359
+ console.error(format(MISSING_DEPENDENCY_ERROR, String(modifier.name), requirement, requirement));
5360
+ }
5361
+ });
5362
+ });
5363
+ });
5025
5364
  }
5026
5365
 
5027
- function getOverflowAncestors(node, list) {
5028
- var _node$ownerDocument;
5029
- if (list === void 0) {
5030
- list = [];
5031
- }
5032
- const scrollableAncestor = getNearestOverflowAncestor(node);
5033
- const isBody = scrollableAncestor === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);
5034
- const win = getWindow(scrollableAncestor);
5035
- if (isBody) {
5036
- return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []);
5037
- }
5038
- return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor));
5366
+ function uniqueBy(arr, fn) {
5367
+ var identifiers = new Set();
5368
+ return arr.filter(function (item) {
5369
+ var identifier = fn(item);
5370
+
5371
+ if (!identifiers.has(identifier)) {
5372
+ identifiers.add(identifier);
5373
+ return true;
5374
+ }
5375
+ });
5039
5376
  }
5040
5377
 
5041
- // Returns the inner client rect, subtracting scrollbars if present
5042
- function getInnerBoundingClientRect(element, strategy) {
5043
- const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
5044
- const top = clientRect.top + element.clientTop;
5045
- const left = clientRect.left + element.clientLeft;
5046
- const scale = isHTMLElement(element) ? getScale(element) : {
5047
- x: 1,
5048
- y: 1
5049
- };
5050
- const width = element.clientWidth * scale.x;
5051
- const height = element.clientHeight * scale.y;
5052
- const x = left * scale.x;
5053
- const y = top * scale.y;
5054
- return {
5055
- top: y,
5056
- left: x,
5057
- right: x + width,
5058
- bottom: y + height,
5059
- x,
5060
- y,
5061
- width,
5062
- height
5063
- };
5378
+ function mergeByName(modifiers) {
5379
+ var merged = modifiers.reduce(function (merged, current) {
5380
+ var existing = merged[current.name];
5381
+ merged[current.name] = existing ? Object.assign(Object.assign(Object.assign({}, existing), current), {}, {
5382
+ options: Object.assign(Object.assign({}, existing.options), current.options),
5383
+ data: Object.assign(Object.assign({}, existing.data), current.data)
5384
+ }) : current;
5385
+ return merged;
5386
+ }, {}); // IE11 does not support Object.values
5387
+
5388
+ return Object.keys(merged).map(function (key) {
5389
+ return merged[key];
5390
+ });
5064
5391
  }
5065
- function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
5066
- if (clippingAncestor === 'viewport') {
5067
- return rectToClientRect(getViewportRect(element, strategy));
5068
- }
5069
- if (isElement$1(clippingAncestor)) {
5070
- return getInnerBoundingClientRect(clippingAncestor, strategy);
5392
+
5393
+ var INVALID_ELEMENT_ERROR = 'Popper: Invalid reference or popper argument provided. They must be either a DOM element or virtual element.';
5394
+ 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.';
5395
+ var DEFAULT_OPTIONS = {
5396
+ placement: 'bottom',
5397
+ modifiers: [],
5398
+ strategy: 'absolute'
5399
+ };
5400
+
5401
+ function areValidElements() {
5402
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
5403
+ args[_key] = arguments[_key];
5071
5404
  }
5072
- return rectToClientRect(getDocumentRect(getDocumentElement(element)));
5405
+
5406
+ return !args.some(function (element) {
5407
+ return !(element && typeof element.getBoundingClientRect === 'function');
5408
+ });
5073
5409
  }
5074
5410
 
5075
- // A "clipping ancestor" is an `overflow` element with the characteristic of
5076
- // clipping (or hiding) child elements. This returns all clipping ancestors
5077
- // of the given element up the tree.
5078
- function getClippingElementAncestors(element, cache) {
5079
- const cachedResult = cache.get(element);
5080
- if (cachedResult) {
5081
- return cachedResult;
5082
- }
5083
- let result = getOverflowAncestors(element).filter(el => isElement$1(el) && getNodeName(el) !== 'body');
5084
- let currentContainingBlockComputedStyle = null;
5085
- const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
5086
- let currentNode = elementIsFixed ? getParentNode(element) : element;
5087
-
5088
- // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
5089
- while (isElement$1(currentNode) && !isLastTraversableNode(currentNode)) {
5090
- const computedStyle = getComputedStyle$1(currentNode);
5091
- const containingBlock = isContainingBlock(currentNode);
5092
- const shouldDropCurrentNode = elementIsFixed ? !containingBlock && !currentContainingBlockComputedStyle : !containingBlock && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && ['absolute', 'fixed'].includes(currentContainingBlockComputedStyle.position);
5093
- if (shouldDropCurrentNode) {
5094
- // Drop non-containing blocks
5095
- result = result.filter(ancestor => ancestor !== currentNode);
5096
- } else {
5097
- // Record last containing block for next iteration
5098
- currentContainingBlockComputedStyle = computedStyle;
5099
- }
5100
- currentNode = getParentNode(currentNode);
5411
+ function popperGenerator(generatorOptions) {
5412
+ if (generatorOptions === void 0) {
5413
+ generatorOptions = {};
5101
5414
  }
5102
- cache.set(element, result);
5103
- return result;
5104
- }
5105
5415
 
5106
- // Gets the maximum area that the element is visible in due to any number of
5107
- // clipping ancestors
5108
- function getClippingRect(_ref) {
5109
- let {
5110
- element,
5111
- boundary,
5112
- rootBoundary,
5113
- strategy
5114
- } = _ref;
5115
- const elementClippingAncestors = boundary === 'clippingAncestors' ? getClippingElementAncestors(element, this._c) : [].concat(boundary);
5116
- const clippingAncestors = [...elementClippingAncestors, rootBoundary];
5117
- const firstClippingAncestor = clippingAncestors[0];
5118
- const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
5119
- const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
5120
- accRect.top = max$1(rect.top, accRect.top);
5121
- accRect.right = min$1(rect.right, accRect.right);
5122
- accRect.bottom = min$1(rect.bottom, accRect.bottom);
5123
- accRect.left = max$1(rect.left, accRect.left);
5124
- return accRect;
5125
- }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
5126
- return {
5127
- width: clippingRect.right - clippingRect.left,
5128
- height: clippingRect.bottom - clippingRect.top,
5129
- x: clippingRect.left,
5130
- y: clippingRect.top
5131
- };
5132
- }
5416
+ var _generatorOptions = generatorOptions,
5417
+ _generatorOptions$def = _generatorOptions.defaultModifiers,
5418
+ defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,
5419
+ _generatorOptions$def2 = _generatorOptions.defaultOptions,
5420
+ defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
5421
+ return function createPopper(reference, popper, options) {
5422
+ if (options === void 0) {
5423
+ options = defaultOptions;
5424
+ }
5425
+
5426
+ var state = {
5427
+ placement: 'bottom',
5428
+ orderedModifiers: [],
5429
+ options: Object.assign(Object.assign({}, DEFAULT_OPTIONS), defaultOptions),
5430
+ modifiersData: {},
5431
+ elements: {
5432
+ reference: reference,
5433
+ popper: popper
5434
+ },
5435
+ attributes: {},
5436
+ styles: {}
5437
+ };
5438
+ var effectCleanupFns = [];
5439
+ var isDestroyed = false;
5440
+ var instance = {
5441
+ state: state,
5442
+ setOptions: function setOptions(options) {
5443
+ cleanupModifierEffects();
5444
+ state.options = Object.assign(Object.assign(Object.assign({}, defaultOptions), state.options), options);
5445
+ state.scrollParents = {
5446
+ reference: isElement$1(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
5447
+ popper: listScrollParents(popper)
5448
+ }; // Orders the modifiers based on their dependencies and `phase`
5449
+ // properties
5450
+
5451
+ var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers
5452
+
5453
+ state.orderedModifiers = orderedModifiers.filter(function (m) {
5454
+ return m.enabled;
5455
+ }); // Validate the provided modifiers so that the consumer will get warned
5456
+ // if one of the modifiers is invalid for any reason
5457
+
5458
+ if (process.env.NODE_ENV !== "production") {
5459
+ var modifiers = uniqueBy([].concat(orderedModifiers, state.options.modifiers), function (_ref) {
5460
+ var name = _ref.name;
5461
+ return name;
5462
+ });
5463
+ validateModifiers(modifiers);
5464
+
5465
+ if (getBasePlacement(state.options.placement) === auto) {
5466
+ var flipModifier = state.orderedModifiers.find(function (_ref2) {
5467
+ var name = _ref2.name;
5468
+ return name === 'flip';
5469
+ });
5470
+
5471
+ if (!flipModifier) {
5472
+ console.error(['Popper: "auto" placements require the "flip" modifier be', 'present and enabled to work.'].join(' '));
5473
+ }
5474
+ }
5475
+
5476
+ var _getComputedStyle = getComputedStyle(popper),
5477
+ marginTop = _getComputedStyle.marginTop,
5478
+ marginRight = _getComputedStyle.marginRight,
5479
+ marginBottom = _getComputedStyle.marginBottom,
5480
+ marginLeft = _getComputedStyle.marginLeft; // We no longer take into account `margins` on the popper, and it can
5481
+ // cause bugs with positioning, so we'll warn the consumer
5482
+
5483
+
5484
+ if ([marginTop, marginRight, marginBottom, marginLeft].some(function (margin) {
5485
+ return parseFloat(margin);
5486
+ })) {
5487
+ 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(' '));
5488
+ }
5489
+ }
5490
+
5491
+ runModifierEffects();
5492
+ return instance.update();
5493
+ },
5494
+ // Sync update – it will always be executed, even if not necessary. This
5495
+ // is useful for low frequency updates where sync behavior simplifies the
5496
+ // logic.
5497
+ // For high frequency updates (e.g. `resize` and `scroll` events), always
5498
+ // prefer the async Popper#update method
5499
+ forceUpdate: function forceUpdate() {
5500
+ if (isDestroyed) {
5501
+ return;
5502
+ }
5503
+
5504
+ var _state$elements = state.elements,
5505
+ reference = _state$elements.reference,
5506
+ popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements
5507
+ // anymore
5508
+
5509
+ if (!areValidElements(reference, popper)) {
5510
+ if (process.env.NODE_ENV !== "production") {
5511
+ console.error(INVALID_ELEMENT_ERROR);
5512
+ }
5513
+
5514
+ return;
5515
+ } // Store the reference and popper rects to be read by modifiers
5516
+
5517
+
5518
+ state.rects = {
5519
+ reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),
5520
+ popper: getLayoutRect(popper)
5521
+ }; // Modifiers have the ability to reset the current update cycle. The
5522
+ // most common use case for this is the `flip` modifier changing the
5523
+ // placement, which then needs to re-run all the modifiers, because the
5524
+ // logic was previously ran for the previous placement and is therefore
5525
+ // stale/incorrect
5526
+
5527
+ state.reset = false;
5528
+ state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier
5529
+ // is filled with the initial data specified by the modifier. This means
5530
+ // it doesn't persist and is fresh on each update.
5531
+ // To ensure persistent data, use `${name}#persistent`
5133
5532
 
5134
- const platform = {
5135
- getClippingRect,
5136
- convertOffsetParentRelativeRectToViewportRelativeRect,
5137
- isElement: isElement$1,
5138
- getDimensions,
5139
- getOffsetParent,
5140
- getDocumentElement,
5141
- getScale,
5142
- async getElementRects(_ref) {
5143
- let {
5144
- reference,
5145
- floating,
5146
- strategy
5147
- } = _ref;
5148
- const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
5149
- const getDimensionsFn = this.getDimensions;
5150
- return {
5151
- reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
5152
- floating: {
5153
- x: 0,
5154
- y: 0,
5155
- ...(await getDimensionsFn(floating))
5533
+ state.orderedModifiers.forEach(function (modifier) {
5534
+ return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
5535
+ });
5536
+ var __debug_loops__ = 0;
5537
+
5538
+ for (var index = 0; index < state.orderedModifiers.length; index++) {
5539
+ if (process.env.NODE_ENV !== "production") {
5540
+ __debug_loops__ += 1;
5541
+
5542
+ if (__debug_loops__ > 100) {
5543
+ console.error(INFINITE_LOOP_ERROR);
5544
+ break;
5545
+ }
5546
+ }
5547
+
5548
+ if (state.reset === true) {
5549
+ state.reset = false;
5550
+ index = -1;
5551
+ continue;
5552
+ }
5553
+
5554
+ var _state$orderedModifie = state.orderedModifiers[index],
5555
+ fn = _state$orderedModifie.fn,
5556
+ _state$orderedModifie2 = _state$orderedModifie.options,
5557
+ _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,
5558
+ name = _state$orderedModifie.name;
5559
+
5560
+ if (typeof fn === 'function') {
5561
+ state = fn({
5562
+ state: state,
5563
+ options: _options,
5564
+ name: name,
5565
+ instance: instance
5566
+ }) || state;
5567
+ }
5568
+ }
5569
+ },
5570
+ // Async and optimistically optimized update – it will not be executed if
5571
+ // not necessary (debounced to run at most once-per-tick)
5572
+ update: debounce(function () {
5573
+ return new Promise(function (resolve) {
5574
+ instance.forceUpdate();
5575
+ resolve(state);
5576
+ });
5577
+ }),
5578
+ destroy: function destroy() {
5579
+ cleanupModifierEffects();
5580
+ isDestroyed = true;
5156
5581
  }
5157
5582
  };
5158
- },
5159
- getClientRects: element => Array.from(element.getClientRects()),
5160
- isRTL: element => getComputedStyle$1(element).direction === 'rtl'
5161
- };
5162
5583
 
5163
- /**
5164
- * Automatically updates the position of the floating element when necessary.
5165
- * @see https://floating-ui.com/docs/autoUpdate
5166
- */
5167
- function autoUpdate(reference, floating, update, options) {
5168
- if (options === void 0) {
5169
- options = {};
5170
- }
5171
- const {
5172
- ancestorScroll: _ancestorScroll = true,
5173
- ancestorResize = true,
5174
- elementResize = true,
5175
- animationFrame = false
5176
- } = options;
5177
- const ancestorScroll = _ancestorScroll && !animationFrame;
5178
- const ancestors = ancestorScroll || ancestorResize ? [...(isElement$1(reference) ? getOverflowAncestors(reference) : reference.contextElement ? getOverflowAncestors(reference.contextElement) : []), ...getOverflowAncestors(floating)] : [];
5179
- ancestors.forEach(ancestor => {
5180
- ancestorScroll && ancestor.addEventListener('scroll', update, {
5181
- passive: true
5182
- });
5183
- ancestorResize && ancestor.addEventListener('resize', update);
5184
- });
5185
- let observer = null;
5186
- if (elementResize) {
5187
- let initialUpdate = true;
5188
- observer = new ResizeObserver(() => {
5189
- if (!initialUpdate) {
5190
- update();
5584
+ if (!areValidElements(reference, popper)) {
5585
+ if (process.env.NODE_ENV !== "production") {
5586
+ console.error(INVALID_ELEMENT_ERROR);
5191
5587
  }
5192
- initialUpdate = false;
5193
- });
5194
- isElement$1(reference) && !animationFrame && observer.observe(reference);
5195
- if (!isElement$1(reference) && reference.contextElement && !animationFrame) {
5196
- observer.observe(reference.contextElement);
5588
+
5589
+ return instance;
5197
5590
  }
5198
- observer.observe(floating);
5199
- }
5200
- let frameId;
5201
- let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
5202
- if (animationFrame) {
5203
- frameLoop();
5204
- }
5205
- function frameLoop() {
5206
- const nextRefRect = getBoundingClientRect(reference);
5207
- if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
5208
- update();
5591
+
5592
+ instance.setOptions(options).then(function (state) {
5593
+ if (!isDestroyed && options.onFirstUpdate) {
5594
+ options.onFirstUpdate(state);
5595
+ }
5596
+ }); // Modifiers have the ability to execute arbitrary code before the first
5597
+ // update cycle runs. They will be executed in the same order as the update
5598
+ // cycle. This is useful when a modifier adds some persistent data that
5599
+ // other modifiers need to use, but the modifier is run after the dependent
5600
+ // one.
5601
+
5602
+ function runModifierEffects() {
5603
+ state.orderedModifiers.forEach(function (_ref3) {
5604
+ var name = _ref3.name,
5605
+ _ref3$options = _ref3.options,
5606
+ options = _ref3$options === void 0 ? {} : _ref3$options,
5607
+ effect = _ref3.effect;
5608
+
5609
+ if (typeof effect === 'function') {
5610
+ var cleanupFn = effect({
5611
+ state: state,
5612
+ name: name,
5613
+ instance: instance,
5614
+ options: options
5615
+ });
5616
+
5617
+ var noopFn = function noopFn() {};
5618
+
5619
+ effectCleanupFns.push(cleanupFn || noopFn);
5620
+ }
5621
+ });
5209
5622
  }
5210
- prevRefRect = nextRefRect;
5211
- frameId = requestAnimationFrame(frameLoop);
5212
- }
5213
- update();
5214
- return () => {
5215
- var _observer;
5216
- ancestors.forEach(ancestor => {
5217
- ancestorScroll && ancestor.removeEventListener('scroll', update);
5218
- ancestorResize && ancestor.removeEventListener('resize', update);
5219
- });
5220
- (_observer = observer) == null ? void 0 : _observer.disconnect();
5221
- observer = null;
5222
- if (animationFrame) {
5223
- cancelAnimationFrame(frameId);
5623
+
5624
+ function cleanupModifierEffects() {
5625
+ effectCleanupFns.forEach(function (fn) {
5626
+ return fn();
5627
+ });
5628
+ effectCleanupFns = [];
5224
5629
  }
5630
+
5631
+ return instance;
5225
5632
  };
5226
5633
  }
5227
5634
 
5228
- /**
5229
- * Computes the `x` and `y` coordinates that will place the floating element
5230
- * next to a reference element when it is given a certain CSS positioning
5231
- * strategy.
5232
- */
5233
- const computePosition$1 = (reference, floating, options) => {
5234
- // This caches the expensive `getClippingElementAncestors` function so that
5235
- // multiple lifecycle resets re-use the same result. It only lives for a
5236
- // single call. If other functions become expensive, we can add them as well.
5237
- const cache = new Map();
5238
- const mergedOptions = {
5239
- platform,
5240
- ...options
5241
- };
5242
- const platformWithCache = {
5243
- ...mergedOptions.platform,
5244
- _c: cache
5245
- };
5246
- return computePosition(reference, floating, {
5247
- ...mergedOptions,
5248
- platform: platformWithCache
5249
- });
5250
- };
5635
+ var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
5636
+ var createPopper = /*#__PURE__*/popperGenerator({
5637
+ defaultModifiers: defaultModifiers
5638
+ }); // eslint-disable-next-line import/no-unused-modules
5251
5639
 
5252
- var index = typeof document !== 'undefined' ? useLayoutEffect : useEffect;
5640
+ /* global Map:readonly, Set:readonly, ArrayBuffer:readonly */
5253
5641
 
5254
- // Fork of `fast-deep-equal` that only does the comparisons we need and compares
5255
- // functions
5256
- function deepEqual(a, b) {
5257
- if (a === b) {
5258
- return true;
5259
- }
5260
- if (typeof a !== typeof b) {
5261
- return false;
5262
- }
5263
- if (typeof a === 'function' && a.toString() === b.toString()) {
5264
- return true;
5265
- }
5266
- let length, i, keys;
5267
- if (a && b && typeof a == 'object') {
5642
+ var hasElementType = typeof Element !== 'undefined';
5643
+ var hasMap = typeof Map === 'function';
5644
+ var hasSet = typeof Set === 'function';
5645
+ var hasArrayBuffer = typeof ArrayBuffer === 'function' && !!ArrayBuffer.isView;
5646
+
5647
+ // Note: We **don't** need `envHasBigInt64Array` in fde es6/index.js
5648
+
5649
+ function equal(a, b) {
5650
+ // START: fast-deep-equal es6/index.js 3.1.1
5651
+ if (a === b) return true;
5652
+
5653
+ if (a && b && typeof a == 'object' && typeof b == 'object') {
5654
+ if (a.constructor !== b.constructor) return false;
5655
+
5656
+ var length, i, keys;
5268
5657
  if (Array.isArray(a)) {
5269
5658
  length = a.length;
5270
5659
  if (length != b.length) return false;
5271
- for (i = length; i-- !== 0;) {
5272
- if (!deepEqual(a[i], b[i])) {
5273
- return false;
5274
- }
5275
- }
5660
+ for (i = length; i-- !== 0;)
5661
+ if (!equal(a[i], b[i])) return false;
5276
5662
  return true;
5277
5663
  }
5278
- keys = Object.keys(a);
5279
- length = keys.length;
5280
- if (length !== Object.keys(b).length) {
5281
- return false;
5664
+
5665
+ // START: Modifications:
5666
+ // 1. Extra `has<Type> &&` helpers in initial condition allow es6 code
5667
+ // to co-exist with es5.
5668
+ // 2. Replace `for of` with es5 compliant iteration using `for`.
5669
+ // Basically, take:
5670
+ //
5671
+ // ```js
5672
+ // for (i of a.entries())
5673
+ // if (!b.has(i[0])) return false;
5674
+ // ```
5675
+ //
5676
+ // ... and convert to:
5677
+ //
5678
+ // ```js
5679
+ // it = a.entries();
5680
+ // while (!(i = it.next()).done)
5681
+ // if (!b.has(i.value[0])) return false;
5682
+ // ```
5683
+ //
5684
+ // **Note**: `i` access switches to `i.value`.
5685
+ var it;
5686
+ if (hasMap && (a instanceof Map) && (b instanceof Map)) {
5687
+ if (a.size !== b.size) return false;
5688
+ it = a.entries();
5689
+ while (!(i = it.next()).done)
5690
+ if (!b.has(i.value[0])) return false;
5691
+ it = a.entries();
5692
+ while (!(i = it.next()).done)
5693
+ if (!equal(i.value[1], b.get(i.value[0]))) return false;
5694
+ return true;
5282
5695
  }
5283
- for (i = length; i-- !== 0;) {
5284
- if (!Object.prototype.hasOwnProperty.call(b, keys[i])) {
5285
- return false;
5286
- }
5696
+
5697
+ if (hasSet && (a instanceof Set) && (b instanceof Set)) {
5698
+ if (a.size !== b.size) return false;
5699
+ it = a.entries();
5700
+ while (!(i = it.next()).done)
5701
+ if (!b.has(i.value[0])) return false;
5702
+ return true;
5703
+ }
5704
+ // END: Modifications
5705
+
5706
+ if (hasArrayBuffer && ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {
5707
+ length = a.length;
5708
+ if (length != b.length) return false;
5709
+ for (i = length; i-- !== 0;)
5710
+ if (a[i] !== b[i]) return false;
5711
+ return true;
5287
5712
  }
5713
+
5714
+ if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
5715
+ if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
5716
+ if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
5717
+
5718
+ keys = Object.keys(a);
5719
+ length = keys.length;
5720
+ if (length !== Object.keys(b).length) return false;
5721
+
5722
+ for (i = length; i-- !== 0;)
5723
+ if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
5724
+ // END: fast-deep-equal
5725
+
5726
+ // START: react-fast-compare
5727
+ // custom handling for DOM elements
5728
+ if (hasElementType && a instanceof Element) return false;
5729
+
5730
+ // custom handling for React/Preact
5288
5731
  for (i = length; i-- !== 0;) {
5289
- const key = keys[i];
5290
- if (key === '_owner' && a.$$typeof) {
5732
+ if ((keys[i] === '_owner' || keys[i] === '__v' || keys[i] === '__o') && a.$$typeof) {
5733
+ // React-specific: avoid traversing React elements' _owner
5734
+ // Preact-specific: avoid traversing Preact elements' __v and __o
5735
+ // __v = $_original / $_vnode
5736
+ // __o = $_owner
5737
+ // These properties contain circular references and are not needed when
5738
+ // comparing the actual elements (and not their owners)
5739
+ // .$$typeof and ._store on just reasonable markers of elements
5740
+
5291
5741
  continue;
5292
5742
  }
5293
- if (!deepEqual(a[key], b[key])) {
5294
- return false;
5295
- }
5743
+
5744
+ // all other properties should be traversed as usual
5745
+ if (!equal(a[keys[i]], b[keys[i]])) return false;
5296
5746
  }
5747
+ // END: react-fast-compare
5748
+
5749
+ // START: fast-deep-equal
5297
5750
  return true;
5298
5751
  }
5752
+
5299
5753
  return a !== a && b !== b;
5300
5754
  }
5755
+ // end fast-deep-equal
5301
5756
 
5302
- function useLatestRef(value) {
5303
- const ref = useRef(value);
5304
- index(() => {
5305
- ref.current = value;
5306
- });
5307
- return ref;
5308
- }
5757
+ var reactFastCompare = function isEqual(a, b) {
5758
+ try {
5759
+ return equal(a, b);
5760
+ } catch (error) {
5761
+ if (((error.message || '').match(/stack|recursion/i))) {
5762
+ // warn on circular references, don't crash
5763
+ // browsers give this different errors name and messages:
5764
+ // chrome/safari: "RangeError", "Maximum call stack size exceeded"
5765
+ // firefox: "InternalError", too much recursion"
5766
+ // edge: "Error", "Out of stack space"
5767
+ console.warn('react-fast-compare cannot handle circular refs');
5768
+ return false;
5769
+ }
5770
+ // some other error. we should definitely know about these
5771
+ throw error;
5772
+ }
5773
+ };
5309
5774
 
5310
- function useFloating(options) {
5775
+ var EMPTY_MODIFIERS = [];
5776
+ var usePopper = function usePopper(referenceElement, popperElement, options) {
5311
5777
  if (options === void 0) {
5312
5778
  options = {};
5313
5779
  }
5314
- const {
5315
- placement = 'bottom',
5316
- strategy = 'absolute',
5317
- middleware = [],
5318
- whileElementsMounted,
5319
- open
5320
- } = options;
5321
- const [data, setData] = useState({
5322
- x: null,
5323
- y: null,
5324
- strategy,
5325
- placement,
5326
- middlewareData: {},
5327
- isPositioned: false
5328
- });
5329
- const [latestMiddleware, setLatestMiddleware] = useState(middleware);
5330
- if (!deepEqual(latestMiddleware, middleware)) {
5331
- setLatestMiddleware(middleware);
5332
- }
5333
- const referenceRef = useRef(null);
5334
- const floatingRef = useRef(null);
5335
- const dataRef = useRef(data);
5336
- const whileElementsMountedRef = useLatestRef(whileElementsMounted);
5337
- const [reference, _setReference] = useState(null);
5338
- const [floating, _setFloating] = useState(null);
5339
- const setReference = useCallback(node => {
5340
- if (referenceRef.current !== node) {
5341
- referenceRef.current = node;
5342
- _setReference(node);
5343
- }
5344
- }, []);
5345
- const setFloating = useCallback(node => {
5346
- if (floatingRef.current !== node) {
5347
- floatingRef.current = node;
5348
- _setFloating(node);
5349
- }
5350
- }, []);
5351
- const update = useCallback(() => {
5352
- if (!referenceRef.current || !floatingRef.current) {
5353
- return;
5354
- }
5355
- computePosition$1(referenceRef.current, floatingRef.current, {
5356
- middleware: latestMiddleware,
5357
- placement,
5358
- strategy
5359
- }).then(data => {
5360
- const fullData = {
5361
- ...data,
5362
- isPositioned: true
5363
- };
5364
- if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
5365
- dataRef.current = fullData;
5366
- flushSync(() => {
5367
- setData(fullData);
5368
- });
5780
+
5781
+ var prevOptions = useRef(null);
5782
+ var optionsWithDefaults = {
5783
+ onFirstUpdate: options.onFirstUpdate,
5784
+ placement: options.placement || 'bottom',
5785
+ strategy: options.strategy || 'absolute',
5786
+ modifiers: options.modifiers || EMPTY_MODIFIERS
5787
+ };
5788
+
5789
+ var _React$useState = useState({
5790
+ styles: {
5791
+ popper: {
5792
+ position: optionsWithDefaults.strategy,
5793
+ left: '0',
5794
+ top: '0'
5369
5795
  }
5370
- });
5371
- }, [latestMiddleware, placement, strategy]);
5372
- index(() => {
5373
- if (open === false && dataRef.current.isPositioned) {
5374
- dataRef.current.isPositioned = false;
5375
- setData(data => ({
5376
- ...data,
5377
- isPositioned: false
5378
- }));
5379
- }
5380
- }, [open]);
5381
- const isMountedRef = useRef(false);
5382
- index(() => {
5383
- isMountedRef.current = true;
5384
- return () => {
5385
- isMountedRef.current = false;
5796
+ },
5797
+ attributes: {}
5798
+ }),
5799
+ state = _React$useState[0],
5800
+ setState = _React$useState[1];
5801
+
5802
+ var updateStateModifier = useMemo(function () {
5803
+ return {
5804
+ name: 'updateState',
5805
+ enabled: true,
5806
+ phase: 'write',
5807
+ fn: function fn(_ref) {
5808
+ var state = _ref.state;
5809
+ var elements = Object.keys(state.elements);
5810
+ setState({
5811
+ styles: fromEntries(elements.map(function (element) {
5812
+ return [element, state.styles[element] || {}];
5813
+ })),
5814
+ attributes: fromEntries(elements.map(function (element) {
5815
+ return [element, state.attributes[element]];
5816
+ }))
5817
+ });
5818
+ },
5819
+ requires: ['computeStyles']
5386
5820
  };
5387
5821
  }, []);
5388
- index(() => {
5389
- if (reference && floating) {
5390
- if (whileElementsMountedRef.current) {
5391
- return whileElementsMountedRef.current(reference, floating, update);
5392
- } else {
5393
- update();
5394
- }
5822
+ var popperOptions = useMemo(function () {
5823
+ var newOptions = {
5824
+ onFirstUpdate: optionsWithDefaults.onFirstUpdate,
5825
+ placement: optionsWithDefaults.placement,
5826
+ strategy: optionsWithDefaults.strategy,
5827
+ modifiers: [].concat(optionsWithDefaults.modifiers, [updateStateModifier, {
5828
+ name: 'applyStyles',
5829
+ enabled: false
5830
+ }])
5831
+ };
5832
+
5833
+ if (reactFastCompare(prevOptions.current, newOptions)) {
5834
+ return prevOptions.current || newOptions;
5835
+ } else {
5836
+ prevOptions.current = newOptions;
5837
+ return newOptions;
5838
+ }
5839
+ }, [optionsWithDefaults.onFirstUpdate, optionsWithDefaults.placement, optionsWithDefaults.strategy, optionsWithDefaults.modifiers, updateStateModifier]);
5840
+ var popperInstanceRef = useRef();
5841
+ useIsomorphicLayoutEffect(function () {
5842
+ if (popperInstanceRef.current) {
5843
+ popperInstanceRef.current.setOptions(popperOptions);
5844
+ }
5845
+ }, [popperOptions]);
5846
+ useIsomorphicLayoutEffect(function () {
5847
+ if (referenceElement == null || popperElement == null) {
5848
+ return;
5395
5849
  }
5396
- }, [reference, floating, update, whileElementsMountedRef]);
5397
- const refs = useMemo(() => ({
5398
- reference: referenceRef,
5399
- floating: floatingRef,
5400
- setReference,
5401
- setFloating
5402
- }), [setReference, setFloating]);
5403
- const elements = useMemo(() => ({
5404
- reference,
5405
- floating
5406
- }), [reference, floating]);
5407
- return useMemo(() => ({
5408
- ...data,
5409
- update,
5410
- refs,
5411
- elements,
5412
- reference: setReference,
5413
- floating: setFloating
5414
- }), [data, update, refs, elements, setReference, setFloating]);
5415
- }
5850
+
5851
+ var createPopper$1 = options.createPopper || createPopper;
5852
+ var popperInstance = createPopper$1(referenceElement, popperElement, popperOptions);
5853
+ popperInstanceRef.current = popperInstance;
5854
+ return function () {
5855
+ popperInstance.destroy();
5856
+ popperInstanceRef.current = null;
5857
+ };
5858
+ }, [referenceElement, popperElement, options.createPopper]);
5859
+ return {
5860
+ state: popperInstanceRef.current ? popperInstanceRef.current.state : null,
5861
+ styles: state.styles,
5862
+ attributes: state.attributes,
5863
+ update: popperInstanceRef.current ? popperInstanceRef.current.update : null,
5864
+ forceUpdate: popperInstanceRef.current ? popperInstanceRef.current.forceUpdate : null
5865
+ };
5866
+ };
5416
5867
 
5417
5868
  /**
5418
5869
  * Different possible placements for the popover.
@@ -5443,115 +5894,89 @@ const FitAnchorWidth = {
5443
5894
  WIDTH: 'width'
5444
5895
  };
5445
5896
  /**
5446
- * Arrow padding size (in pixel).
5447
- */
5448
- const ARROW_PADDING_SIZE = 8;
5449
-
5450
- /**
5451
- * Add offset to the popover
5452
- */
5453
- const configOffset = memoize((offset$1, hasArrow) => {
5454
- var _offset$away, _offset$along;
5455
- const mainAxis = ((_offset$away = offset$1 === null || offset$1 === void 0 ? void 0 : offset$1.away) !== null && _offset$away !== void 0 ? _offset$away : 0) + (hasArrow ? ARROW_PADDING_SIZE : 0);
5456
- const crossAxis = (_offset$along = offset$1 === null || offset$1 === void 0 ? void 0 : offset$1.along) !== null && _offset$along !== void 0 ? _offset$along : 0;
5457
- if (!(mainAxis || crossAxis)) {
5458
- return undefined;
5459
- }
5460
- return offset({
5461
- mainAxis,
5462
- crossAxis
5463
- });
5464
- });
5465
-
5466
- /**
5467
- * Place arrow between popover and anchor.
5897
+ * Arrow size (in pixel).
5468
5898
  */
5469
- const configArrow = memoize(arrowElement => {
5470
- if (!arrowElement) {
5471
- return undefined;
5472
- }
5473
- return arrow({
5474
- element: arrowElement,
5475
- padding: ARROW_PADDING_SIZE
5476
- });
5477
- });
5899
+ const ARROW_SIZE = 8;
5478
5900
 
5479
5901
  /**
5480
- * Add style to fit popover width to anchor width.
5902
+ * Popper js modifier to fit popover min width to the anchor width.
5481
5903
  */
5482
- const configFitToAnchorWidth = memoize(fitToAnchorWidth => {
5483
- if (!fitToAnchorWidth) {
5484
- return undefined;
5904
+ const sameWidth = memoize(anchorWidthOption => ({
5905
+ name: 'sameWidth',
5906
+ enabled: true,
5907
+ phase: 'beforeWrite',
5908
+ requires: ['computeStyles'],
5909
+ fn(_ref) {
5910
+ let {
5911
+ state
5912
+ } = _ref;
5913
+ // eslint-disable-next-line no-param-reassign
5914
+ state.styles.popper[anchorWidthOption] = `${state.rects.reference.width}px`;
5915
+ },
5916
+ effect(_ref2) {
5917
+ let {
5918
+ state
5919
+ } = _ref2;
5920
+ // eslint-disable-next-line no-param-reassign
5921
+ state.elements.popper.style[anchorWidthOption] = `${state.elements.reference.offsetWidth}px`;
5485
5922
  }
5486
- const fitWidth = typeof fitToAnchorWidth === 'string' ? fitToAnchorWidth : FitAnchorWidth.MIN_WIDTH;
5487
- return size({
5488
- apply(_ref) {
5489
- let {
5490
- rects,
5491
- elements
5492
- } = _ref;
5493
- Object.assign(elements.floating.style, {
5494
- [fitWidth]: `${rects.reference.width}px`
5495
- });
5496
- }
5497
- });
5498
- });
5923
+ }));
5499
5924
 
5500
5925
  /**
5501
- * Add max-height style to make popover fit within viewport
5926
+ * Popper js modifier to compute max size of the popover.
5502
5927
  */
5503
- const configFitWithinViewportHeight = memoize(fitWithinViewportHeight => {
5504
- // Handle fit within viewport height
5505
- if (!fitWithinViewportHeight) {
5506
- return undefined;
5928
+ const maxSize = {
5929
+ name: 'maxSize',
5930
+ enabled: true,
5931
+ phase: 'main',
5932
+ requiresIfExists: ['offset', 'preventOverflow', 'flip'],
5933
+ fn(_ref3) {
5934
+ let {
5935
+ state,
5936
+ name,
5937
+ options
5938
+ } = _ref3;
5939
+ const overflow = detectOverflow(state, options);
5940
+ const {
5941
+ y = 0,
5942
+ x = 0
5943
+ } = state.modifiersData.preventOverflow;
5944
+ const {
5945
+ width,
5946
+ height
5947
+ } = state.rects.popper;
5948
+ const [basePlacement] = state.placement.split('-');
5949
+ const widthProp = basePlacement === 'left' ? 'left' : 'right';
5950
+ const heightProp = basePlacement === 'top' ? 'top' : 'bottom';
5951
+ // eslint-disable-next-line no-param-reassign
5952
+ state.modifiersData[name] = {
5953
+ width: width - overflow[widthProp] - x,
5954
+ height: height - overflow[heightProp] - y
5955
+ };
5507
5956
  }
5508
- return size({
5509
- apply(_ref2) {
5510
- let {
5511
- availableHeight,
5512
- elements
5513
- } = _ref2;
5514
- Object.assign(elements.floating.style, {
5515
- maxHeight: `${availableHeight - ARROW_PADDING_SIZE}px`
5516
- });
5517
- }
5518
- });
5519
- });
5520
-
5521
- /**
5522
- * Parse PopoverProps['placement'] into floating-ui placement and alignment.
5523
- */
5524
- const parsePlacement = memoize(rawPlacement => {
5525
- const [rawSide, rawAlignment] = (rawPlacement === null || rawPlacement === void 0 ? void 0 : rawPlacement.split('-')) || [];
5526
- const alignment = rawAlignment;
5527
- let placement = rawSide === 'auto' ? undefined : rawSide;
5528
- if (placement && alignment) placement += `-${alignment}`;
5529
- return {
5530
- alignment,
5531
- placement
5532
- };
5533
- });
5957
+ };
5534
5958
 
5535
5959
  /**
5536
- * Adapt popover placement
5960
+ * Popper js modifier to apply the max height.
5537
5961
  */
5538
- const configPlacement = memoize((placement, alignment, boundaryRef) => {
5539
- const boundary = (boundaryRef === null || boundaryRef === void 0 ? void 0 : boundaryRef.current) || undefined;
5540
- if (boundary || placement) {
5541
- // Standard placement (with boundary if provided)
5542
- return [flip({
5543
- boundary
5544
- }), shift({
5545
- boundary
5546
- })];
5962
+ const applyMaxHeight = {
5963
+ name: 'applyMaxHeight',
5964
+ enabled: true,
5965
+ phase: 'beforeWrite',
5966
+ requires: ['maxSize'],
5967
+ fn(_ref4) {
5968
+ let {
5969
+ state
5970
+ } = _ref4;
5971
+ const {
5972
+ height
5973
+ } = state.modifiersData.maxSize;
5974
+ // eslint-disable-next-line no-param-reassign
5975
+ state.elements.popper.style.maxHeight = `${height - ARROW_SIZE}px`;
5547
5976
  }
5548
- // Auto-placement
5549
- return [autoPlacement({
5550
- alignment
5551
- })];
5552
- });
5553
- function usePopoverStyle(_ref3) {
5554
- var _middlewareData$arrow3, _middlewareData$arrow4;
5977
+ };
5978
+ function usePopoverStyle(_ref5) {
5979
+ var _offset$along, _offset$away, _state$placement, _state$rects$popper$y, _state$rects, _state$rects$popper;
5555
5980
  let {
5556
5981
  offset,
5557
5982
  hasArrow,
@@ -5559,75 +5984,103 @@ function usePopoverStyle(_ref3) {
5559
5984
  fitWithinViewportHeight,
5560
5985
  boundaryRef,
5561
5986
  anchorRef,
5562
- placement: rawPlacement
5563
- } = _ref3;
5987
+ children,
5988
+ placement,
5989
+ style,
5990
+ zIndex
5991
+ } = _ref5;
5564
5992
  if (navigator.userAgent.includes('jsdom')) {
5565
- // Skip all logic
5993
+ // Skip all logic; we don't need popover positioning in jsdom.
5566
5994
  return {
5567
5995
  styles: {},
5996
+ attributes: {},
5568
5997
  isPositioned: true,
5569
- popoverElement: null
5998
+ popperElement: null
5570
5999
  };
5571
6000
  }
5572
6001
 
5573
6002
  // eslint-disable-next-line react-hooks/rules-of-hooks
5574
- const [arrowElement, setArrowElement] = React.useState(null);
5575
- const {
5576
- alignment,
5577
- placement
5578
- } = parsePlacement(rawPlacement);
5579
- const middleware = [configOffset(offset, hasArrow), configArrow(arrowElement), configFitToAnchorWidth(fitToAnchorWidth), configFitWithinViewportHeight(fitWithinViewportHeight), ...configPlacement(placement, alignment, boundaryRef)].filter(Boolean);
6003
+ const [popperElement, setPopperElement] = useState(null);
6004
+ // eslint-disable-next-line react-hooks/rules-of-hooks
6005
+ const [arrowElement, setArrowElement] = useState(null);
6006
+ const actualOffset = [(_offset$along = offset === null || offset === void 0 ? void 0 : offset.along) !== null && _offset$along !== void 0 ? _offset$along : 0, ((_offset$away = offset === null || offset === void 0 ? void 0 : offset.away) !== null && _offset$away !== void 0 ? _offset$away : 0) + (hasArrow ? ARROW_SIZE : 0)];
6007
+ const modifiers = [{
6008
+ name: 'offset',
6009
+ options: {
6010
+ offset: actualOffset
6011
+ }
6012
+ }];
6013
+ if (hasArrow && arrowElement) {
6014
+ modifiers.push({
6015
+ name: 'arrow',
6016
+ options: {
6017
+ element: arrowElement,
6018
+ padding: ARROW_SIZE
6019
+ }
6020
+ });
6021
+ }
6022
+ if (fitToAnchorWidth) {
6023
+ const fitWidth = typeof fitToAnchorWidth === 'string' ? fitToAnchorWidth : FitAnchorWidth.MIN_WIDTH;
6024
+ modifiers.push(sameWidth(fitWidth));
6025
+ }
6026
+ if (fitWithinViewportHeight) {
6027
+ modifiers.push(_objectSpread2(_objectSpread2({}, maxSize), {}, {
6028
+ options: {
6029
+ boundary: boundaryRef === null || boundaryRef === void 0 ? void 0 : boundaryRef.current
6030
+ }
6031
+ }), applyMaxHeight);
6032
+ }
6033
+ if (boundaryRef) {
6034
+ modifiers.push({
6035
+ name: 'flip',
6036
+ options: {
6037
+ boundary: boundaryRef.current
6038
+ }
6039
+ }, {
6040
+ name: 'preventOverflow',
6041
+ options: {
6042
+ boundary: boundaryRef.current
6043
+ }
6044
+ });
6045
+ }
5580
6046
 
5581
6047
  // eslint-disable-next-line react-hooks/rules-of-hooks
5582
6048
  const {
5583
- x,
5584
- y,
5585
- strategy,
5586
- refs,
5587
- placement: position,
5588
- middlewareData,
5589
- isPositioned
5590
- } = useFloating({
6049
+ styles,
6050
+ attributes,
6051
+ state,
6052
+ update
6053
+ } = usePopper(anchorRef.current, popperElement, {
5591
6054
  placement,
5592
- middleware,
5593
- whileElementsMounted: autoUpdate
6055
+ modifiers
5594
6056
  });
5595
6057
  // eslint-disable-next-line react-hooks/rules-of-hooks
5596
- React.useLayoutEffect(() => {
5597
- // Update anchor
5598
- refs.setReference(anchorRef.current);
5599
- }, [anchorRef, refs]);
6058
+ useEffect(() => {
6059
+ update === null || update === void 0 ? void 0 : update();
6060
+ }, [children, update]);
6061
+ const position = (_state$placement = state === null || state === void 0 ? void 0 : state.placement) !== null && _state$placement !== void 0 ? _state$placement : placement;
5600
6062
 
5601
6063
  // eslint-disable-next-line react-hooks/rules-of-hooks
5602
- const popoverStyle = React.useMemo(() => {
5603
- const style = {
5604
- visibility: isPositioned ? undefined : 'hidden',
5605
- position: strategy,
5606
- top: y || 0,
5607
- left: x || 0
5608
- };
5609
- return style;
5610
- }, [isPositioned, strategy, y, x]);
5611
- const [positionSide] = position.split('-');
5612
- // eslint-disable-next-line react-hooks/rules-of-hooks
5613
- const arrowStyle = React.useMemo(() => {
5614
- var _middlewareData$arrow, _middlewareData$arrow2;
5615
- const horizontal = positionSide === 'left' || positionSide === 'right';
5616
- return {
5617
- top: horizontal && (middlewareData === null || middlewareData === void 0 ? void 0 : (_middlewareData$arrow = middlewareData.arrow) === null || _middlewareData$arrow === void 0 ? void 0 : _middlewareData$arrow.y) || undefined,
5618
- left: !horizontal && (middlewareData === null || middlewareData === void 0 ? void 0 : (_middlewareData$arrow2 = middlewareData.arrow) === null || _middlewareData$arrow2 === void 0 ? void 0 : _middlewareData$arrow2.x) || undefined
5619
- };
5620
- }, [middlewareData === null || middlewareData === void 0 ? void 0 : (_middlewareData$arrow3 = middlewareData.arrow) === null || _middlewareData$arrow3 === void 0 ? void 0 : _middlewareData$arrow3.x, middlewareData === null || middlewareData === void 0 ? void 0 : (_middlewareData$arrow4 = middlewareData.arrow) === null || _middlewareData$arrow4 === void 0 ? void 0 : _middlewareData$arrow4.y, positionSide]);
6064
+ const popoverStyle = useMemo(() => {
6065
+ const newStyles = _objectSpread2(_objectSpread2(_objectSpread2({}, style), styles.popper), {}, {
6066
+ zIndex
6067
+ });
6068
+ if (fitWithinViewportHeight && !newStyles.maxHeight) {
6069
+ newStyles.maxHeight = (WINDOW === null || WINDOW === void 0 ? void 0 : WINDOW.innerHeight) || (DOCUMENT === null || DOCUMENT === void 0 ? void 0 : DOCUMENT.documentElement.clientHeight);
6070
+ }
6071
+ return newStyles;
6072
+ }, [style, styles.popper, zIndex, fitWithinViewportHeight]);
5621
6073
  return {
5622
6074
  styles: {
5623
- popover: popoverStyle,
5624
- arrow: arrowStyle
6075
+ arrow: styles.arrow,
6076
+ popover: popoverStyle
5625
6077
  },
5626
- isPositioned,
5627
- position: positionSide,
5628
- arrowRef: setArrowElement,
5629
- popoverRef: refs.setFloating,
5630
- popoverElement: refs.floating.current
6078
+ attributes,
6079
+ isPositioned: ((_state$rects$popper$y = state === null || state === void 0 ? void 0 : (_state$rects = state.rects) === null || _state$rects === void 0 ? void 0 : (_state$rects$popper = _state$rects.popper) === null || _state$rects$popper === void 0 ? void 0 : _state$rects$popper.y) !== null && _state$rects$popper$y !== void 0 ? _state$rects$popper$y : -1) >= 0,
6080
+ position,
6081
+ setArrowElement,
6082
+ setPopperElement,
6083
+ popperElement
5631
6084
  };
5632
6085
  }
5633
6086
 
@@ -5662,16 +6115,8 @@ const renderPopover = (children, usePortal) => {
5662
6115
  return usePortal ? /*#__PURE__*/createPortal(children, document.body) : children;
5663
6116
  };
5664
6117
 
5665
- /**
5666
- * Popover component.
5667
- *
5668
- * @param props Component props.
5669
- * @param ref Component ref.
5670
- * @return React element.
5671
- */
5672
- const Popover = skipRenderHOC(
5673
- // Skip render in SSR
5674
- () => Boolean(DOCUMENT), /*#__PURE__*/forwardRef((props, ref) => {
6118
+ // Inner component (must be wrapped before export)
6119
+ const _InnerPopover = /*#__PURE__*/forwardRef((props, ref) => {
5675
6120
  const {
5676
6121
  anchorRef,
5677
6122
  children,
@@ -5700,11 +6145,12 @@ const Popover = skipRenderHOC(
5700
6145
  const contentRef = useRef(null);
5701
6146
  const {
5702
6147
  styles,
6148
+ attributes,
5703
6149
  isPositioned,
5704
6150
  position,
5705
- popoverRef,
5706
- popoverElement,
5707
- arrowRef
6151
+ setArrowElement,
6152
+ setPopperElement,
6153
+ popperElement
5708
6154
  } = usePopoverStyle({
5709
6155
  offset,
5710
6156
  hasArrow,
@@ -5712,7 +6158,10 @@ const Popover = skipRenderHOC(
5712
6158
  fitWithinViewportHeight,
5713
6159
  boundaryRef,
5714
6160
  anchorRef,
5715
- placement
6161
+ children,
6162
+ placement,
6163
+ style,
6164
+ zIndex
5716
6165
  });
5717
6166
 
5718
6167
  /**
@@ -5721,7 +6170,7 @@ const Popover = skipRenderHOC(
5721
6170
  * */
5722
6171
  const isFocusedWithin = useRef(false);
5723
6172
  useFocusWithin({
5724
- element: popoverElement,
6173
+ element: popperElement || null,
5725
6174
  onFocusIn: () => {
5726
6175
  isFocusedWithin.current = true;
5727
6176
  },
@@ -5764,24 +6213,34 @@ const Popover = skipRenderHOC(
5764
6213
  useFocusTrap(withFocusTrap && isOpen && (contentRef === null || contentRef === void 0 ? void 0 : contentRef.current), focusElement === null || focusElement === void 0 ? void 0 : focusElement.current);
5765
6214
  const clickAwayRefs = useRef([clickAwayRef, anchorRef]);
5766
6215
  return isOpen ? renderPopover( /*#__PURE__*/React.createElement("div", _extends({}, forwardedProps, {
5767
- ref: mergeRefs(popoverRef, ref, clickAwayRef, contentRef),
6216
+ ref: mergeRefs(setPopperElement, ref, clickAwayRef, contentRef),
5768
6217
  className: classnames(className, handleBasicClasses({
5769
6218
  prefix: CLASSNAME$i,
5770
6219
  elevation: Math.min(elevation || 0, 5),
5771
6220
  position
5772
6221
  })),
5773
- style: _objectSpread2(_objectSpread2({}, style), {}, {
5774
- zIndex
5775
- }, styles.popover)
5776
- }), /*#__PURE__*/React.createElement(ClickAwayProvider, {
6222
+ style: styles.popover
6223
+ }, attributes.popper), /*#__PURE__*/React.createElement(ClickAwayProvider, {
5777
6224
  callback: closeOnClickAway && handleClose,
5778
6225
  childrenRefs: clickAwayRefs
5779
6226
  }, hasArrow && /*#__PURE__*/React.createElement("div", {
5780
- ref: arrowRef,
6227
+ ref: setArrowElement,
5781
6228
  className: `${CLASSNAME$i}__arrow`,
5782
6229
  style: styles.arrow
5783
6230
  }), children)), usePortal) : null;
5784
- }));
6231
+ });
6232
+ _InnerPopover.displayName = COMPONENT_NAME$l;
6233
+
6234
+ /**
6235
+ * Popover component.
6236
+ *
6237
+ * @param props Component props.
6238
+ * @param ref Component ref.
6239
+ * @return React element.
6240
+ */
6241
+ const Popover = skipRender(
6242
+ // Skip render in SSR
6243
+ () => Boolean(DOCUMENT), _InnerPopover);
5785
6244
  Popover.displayName = COMPONENT_NAME$l;
5786
6245
  Popover.className = CLASSNAME$i;
5787
6246
  Popover.defaultProps = DEFAULT_PROPS$g;
@@ -9633,16 +10092,16 @@ const PAGINATION_ITEMS_MAX = 5;
9633
10092
  */
9634
10093
  const PAGINATION_ITEM_SIZE = 12;
9635
10094
 
9636
- const DEFAULT_OPTIONS = {
10095
+ const DEFAULT_OPTIONS$1 = {
9637
10096
  activeIndex: 0,
9638
10097
  groupBy: 1,
9639
10098
  interval: AUTOPLAY_DEFAULT_INTERVAL
9640
10099
  };
9641
10100
  const useSlideshowControls = _ref => {
9642
10101
  let {
9643
- activeIndex = DEFAULT_OPTIONS.activeIndex,
9644
- groupBy = DEFAULT_OPTIONS.groupBy,
9645
- interval = DEFAULT_OPTIONS.interval,
10102
+ activeIndex = DEFAULT_OPTIONS$1.activeIndex,
10103
+ groupBy = DEFAULT_OPTIONS$1.groupBy,
10104
+ interval = DEFAULT_OPTIONS$1.interval,
9646
10105
  autoPlay,
9647
10106
  defaultActiveIndex,
9648
10107
  onChange,
@@ -9937,7 +10396,7 @@ const _excluded$13 = ["activeIndex", "autoPlay", "children", "className", "fillH
9937
10396
  /**
9938
10397
  * Component default props.
9939
10398
  */
9940
- const DEFAULT_PROPS$P = _objectSpread2(_objectSpread2({}, DEFAULT_OPTIONS), {}, {
10399
+ const DEFAULT_PROPS$P = _objectSpread2(_objectSpread2({}, DEFAULT_OPTIONS$1), {}, {
9941
10400
  theme: Theme.light
9942
10401
  });
9943
10402
 
@@ -10291,7 +10750,7 @@ InternalSlideshowControls.className = CLASSNAME$$;
10291
10750
  InternalSlideshowControls.defaultProps = DEFAULT_PROPS$Q;
10292
10751
  const SlideshowControls = Object.assign(InternalSlideshowControls, {
10293
10752
  useSlideshowControls,
10294
- useSlideshowControlsDefaultOptions: DEFAULT_OPTIONS
10753
+ useSlideshowControlsDefaultOptions: DEFAULT_OPTIONS$1
10295
10754
  });
10296
10755
 
10297
10756
  const _excluded$16 = ["activeIndex", "id", "className", "theme", "fillHeight", "groupBy", "isAutoPlaying", "toggleAutoPlay", "slidesId", "children", "afterSlides", "hasControls", "slideGroupLabel"];
@@ -11836,7 +12295,7 @@ const DEFAULT_PROPS$11 = {
11836
12295
  /**
11837
12296
  * Arrow size (in pixel).
11838
12297
  */
11839
- const ARROW_SIZE = 8;
12298
+ const ARROW_SIZE$1 = 8;
11840
12299
 
11841
12300
  /**
11842
12301
  * Tooltip component.
@@ -11845,16 +12304,10 @@ const ARROW_SIZE = 8;
11845
12304
  * @param ref Component ref.
11846
12305
  * @return React element.
11847
12306
  */
11848
- const Tooltip = skipRenderHOC(
11849
- // Disable in SSR or without a label.
11850
- _ref => {
11851
- let {
11852
- label
11853
- } = _ref;
11854
- return Boolean(DOCUMENT && label);
11855
- }, /*#__PURE__*/forwardRef((props, ref) => {
12307
+ const Tooltip = /*#__PURE__*/forwardRef((props, ref) => {
12308
+ var _attributes$popper$da, _attributes$popper;
11856
12309
  const {
11857
- label: l,
12310
+ label,
11858
12311
  children,
11859
12312
  className,
11860
12313
  delay,
@@ -11862,26 +12315,30 @@ _ref => {
11862
12315
  forceOpen
11863
12316
  } = props,
11864
12317
  forwardedProps = _objectWithoutProperties(props, _excluded$1k);
11865
- // Cast label as we know it's not empty
11866
- const label = l;
12318
+ // Disable in SSR or without a label.
12319
+ if (!DOCUMENT || !label) {
12320
+ return /*#__PURE__*/React.createElement(React.Fragment, null, children);
12321
+ }
11867
12322
  const id = useMemo(() => `tooltip-${uid()}`, []);
12323
+ const [popperElement, setPopperElement] = useState(null);
12324
+ const [anchorElement, setAnchorElement] = useState(null);
11868
12325
  const {
11869
- x,
11870
- y,
11871
- strategy,
11872
- refs,
11873
- placement: position
11874
- } = useFloating({
12326
+ styles,
12327
+ attributes
12328
+ } = usePopper(anchorElement, popperElement, {
11875
12329
  placement,
11876
- middleware: [offset({
11877
- mainAxis: ARROW_SIZE
11878
- })],
11879
- whileElementsMounted: autoUpdate
12330
+ modifiers: [{
12331
+ name: 'offset',
12332
+ options: {
12333
+ offset: [0, ARROW_SIZE$1]
12334
+ }
12335
+ }]
11880
12336
  });
11881
- const isOpen = useTooltipOpen(delay, refs.reference.current) || forceOpen;
11882
- const wrappedChildren = useInjectTooltipRef(children, refs.setReference, isOpen, id);
12337
+ const position = (_attributes$popper$da = attributes === null || attributes === void 0 ? void 0 : (_attributes$popper = attributes.popper) === null || _attributes$popper === void 0 ? void 0 : _attributes$popper['data-popper-placement']) !== null && _attributes$popper$da !== void 0 ? _attributes$popper$da : placement;
12338
+ const isOpen = useTooltipOpen(delay, anchorElement) || forceOpen;
12339
+ const wrappedChildren = useInjectTooltipRef(children, setAnchorElement, isOpen, id);
11883
12340
  return /*#__PURE__*/React.createElement(React.Fragment, null, wrappedChildren, isOpen && /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement("div", _extends({
11884
- ref: mergeRefs(ref, refs.setFloating)
12341
+ ref: mergeRefs(ref, setPopperElement)
11885
12342
  }, forwardedProps, {
11886
12343
  id: id,
11887
12344
  role: "tooltip",
@@ -11890,19 +12347,15 @@ _ref => {
11890
12347
  prefix: CLASSNAME$1d,
11891
12348
  position
11892
12349
  })),
11893
- style: {
11894
- position: strategy,
11895
- top: y || 0,
11896
- left: x || 0
11897
- }
11898
- }), /*#__PURE__*/React.createElement("div", {
12350
+ style: styles.popper
12351
+ }, attributes.popper), /*#__PURE__*/React.createElement("div", {
11899
12352
  className: `${CLASSNAME$1d}__arrow`
11900
12353
  }), /*#__PURE__*/React.createElement("div", {
11901
12354
  className: `${CLASSNAME$1d}__inner`
11902
12355
  }, label.indexOf('\n') !== -1 ? label.split('\n').map(sentence => /*#__PURE__*/React.createElement("p", {
11903
12356
  key: sentence
11904
12357
  }, sentence)) : label)), document.body));
11905
- }));
12358
+ });
11906
12359
  Tooltip.displayName = COMPONENT_NAME$1g;
11907
12360
  Tooltip.className = CLASSNAME$1d;
11908
12361
  Tooltip.defaultProps = DEFAULT_PROPS$11;