@lumx/react 3.1.3 → 3.1.4-alpha-popover.0
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.d.ts +7 -3
- package/index.js +1736 -2134
- package/index.js.map +1 -1
- package/package.json +6 -6
- package/src/components/dropdown/Dropdown.tsx +2 -1
- package/src/components/popover/Popover.stories.tsx +46 -119
- package/src/components/popover/Popover.tsx +118 -278
- package/src/components/popover/__snapshots__/Popover.test.tsx.snap +143 -306
- package/src/components/popover/constants.ts +57 -0
- package/src/components/popover/index.ts +2 -0
- package/src/components/popover/usePopoverStyle.tsx +156 -0
- package/src/components/popover-dialog/PopoverDialog.stories.tsx +1 -1
- package/src/components/select/WithSelectContext.tsx +1 -1
- package/src/components/tooltip/Tooltip.stories.tsx +13 -11
- package/src/components/tooltip/Tooltip.tsx +54 -56
- package/src/utils/skipRenderHOC.tsx +16 -0
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 } from 'react-dom';
|
|
13
|
+
import { createPortal, flushSync } 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
|
|
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;
|
|
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,
|
|
3289
3289
|
ForwardRef: ForwardRef,
|
|
3290
3290
|
Fragment: Fragment,
|
|
3291
3291
|
Lazy: Lazy,
|
|
@@ -3739,1418 +3739,1125 @@ const List = Object.assign(InternalList, {
|
|
|
3739
3739
|
useKeyboardListNavigation
|
|
3740
3740
|
});
|
|
3741
3741
|
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) {
|
|
3758
|
-
return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
|
|
3759
|
-
}, []); // modifiers that need to read the DOM
|
|
3760
|
-
|
|
3761
|
-
var beforeRead = 'beforeRead';
|
|
3762
|
-
var read = 'read';
|
|
3763
|
-
var afterRead = 'afterRead'; // pure-logic modifiers
|
|
3764
|
-
|
|
3765
|
-
var beforeMain = 'beforeMain';
|
|
3766
|
-
var main = 'main';
|
|
3767
|
-
var afterMain = 'afterMain'; // modifier with the purpose to write to the DOM (or write into a framework state)
|
|
3768
|
-
|
|
3769
|
-
var beforeWrite = 'beforeWrite';
|
|
3770
|
-
var write = 'write';
|
|
3771
|
-
var afterWrite = 'afterWrite';
|
|
3772
|
-
var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
|
|
3773
|
-
|
|
3774
|
-
function getNodeName(element) {
|
|
3775
|
-
return element ? (element.nodeName || '').toLowerCase() : null;
|
|
3776
|
-
}
|
|
3777
|
-
|
|
3778
|
-
/*:: import type { Window } from '../types'; */
|
|
3779
|
-
|
|
3780
|
-
/*:: declare function getWindow(node: Node | Window): Window; */
|
|
3781
|
-
function getWindow(node) {
|
|
3782
|
-
if (node.toString() !== '[object Window]') {
|
|
3783
|
-
var ownerDocument = node.ownerDocument;
|
|
3784
|
-
return ownerDocument ? ownerDocument.defaultView || window : window;
|
|
3785
|
-
}
|
|
3786
|
-
|
|
3787
|
-
return node;
|
|
3788
|
-
}
|
|
3789
|
-
|
|
3790
|
-
/*:: declare function isElement(node: mixed): boolean %checks(node instanceof
|
|
3791
|
-
Element); */
|
|
3792
|
-
|
|
3793
|
-
function isElement$1(node) {
|
|
3794
|
-
var OwnElement = getWindow(node).Element;
|
|
3795
|
-
return node instanceof OwnElement || node instanceof Element;
|
|
3796
|
-
}
|
|
3797
|
-
/*:: declare function isHTMLElement(node: mixed): boolean %checks(node instanceof
|
|
3798
|
-
HTMLElement); */
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
function isHTMLElement(node) {
|
|
3802
|
-
var OwnElement = getWindow(node).HTMLElement;
|
|
3803
|
-
return node instanceof OwnElement || node instanceof HTMLElement;
|
|
3804
|
-
}
|
|
3805
|
-
/*:: declare function isShadowRoot(node: mixed): boolean %checks(node instanceof
|
|
3806
|
-
ShadowRoot); */
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
function isShadowRoot(node) {
|
|
3810
|
-
var OwnElement = getWindow(node).ShadowRoot;
|
|
3811
|
-
return node instanceof OwnElement || node instanceof ShadowRoot;
|
|
3812
|
-
}
|
|
3813
|
-
|
|
3814
|
-
// and applies them to the HTMLElements such as popper and arrow
|
|
3815
|
-
|
|
3816
|
-
function applyStyles(_ref) {
|
|
3817
|
-
var state = _ref.state;
|
|
3818
|
-
Object.keys(state.elements).forEach(function (name) {
|
|
3819
|
-
var style = state.styles[name] || {};
|
|
3820
|
-
var attributes = state.attributes[name] || {};
|
|
3821
|
-
var element = state.elements[name]; // arrow is optional + virtual elements
|
|
3822
|
-
|
|
3823
|
-
if (!isHTMLElement(element) || !getNodeName(element)) {
|
|
3824
|
-
return;
|
|
3825
|
-
} // Flow doesn't support to extend this property, but it's the most
|
|
3826
|
-
// effective way to apply styles to an HTMLElement
|
|
3827
|
-
// $FlowFixMe
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
Object.assign(element.style, style);
|
|
3831
|
-
Object.keys(attributes).forEach(function (name) {
|
|
3832
|
-
var value = attributes[name];
|
|
3833
|
-
|
|
3834
|
-
if (value === false) {
|
|
3835
|
-
element.removeAttribute(name);
|
|
3836
|
-
} else {
|
|
3837
|
-
element.setAttribute(name, value === true ? '' : value);
|
|
3838
|
-
}
|
|
3839
|
-
});
|
|
3840
|
-
});
|
|
3841
|
-
}
|
|
3842
|
-
|
|
3843
|
-
function effect(_ref2) {
|
|
3844
|
-
var state = _ref2.state;
|
|
3845
|
-
var initialStyles = {
|
|
3846
|
-
popper: {
|
|
3847
|
-
position: state.options.strategy,
|
|
3848
|
-
left: '0',
|
|
3849
|
-
top: '0',
|
|
3850
|
-
margin: '0'
|
|
3851
|
-
},
|
|
3852
|
-
arrow: {
|
|
3853
|
-
position: 'absolute'
|
|
3854
|
-
},
|
|
3855
|
-
reference: {}
|
|
3856
|
-
};
|
|
3857
|
-
Object.assign(state.elements.popper.style, initialStyles.popper);
|
|
3858
|
-
|
|
3859
|
-
if (state.elements.arrow) {
|
|
3860
|
-
Object.assign(state.elements.arrow.style, initialStyles.arrow);
|
|
3861
|
-
}
|
|
3862
|
-
|
|
3863
|
-
return function () {
|
|
3864
|
-
Object.keys(state.elements).forEach(function (name) {
|
|
3865
|
-
var element = state.elements[name];
|
|
3866
|
-
var attributes = state.attributes[name] || {};
|
|
3867
|
-
var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them
|
|
3868
|
-
|
|
3869
|
-
var style = styleProperties.reduce(function (style, property) {
|
|
3870
|
-
style[property] = '';
|
|
3871
|
-
return style;
|
|
3872
|
-
}, {}); // arrow is optional + virtual elements
|
|
3873
|
-
|
|
3874
|
-
if (!isHTMLElement(element) || !getNodeName(element)) {
|
|
3875
|
-
return;
|
|
3876
|
-
} // Flow doesn't support to extend this property, but it's the most
|
|
3877
|
-
// effective way to apply styles to an HTMLElement
|
|
3878
|
-
// $FlowFixMe
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
Object.assign(element.style, style);
|
|
3882
|
-
Object.keys(attributes).forEach(function (attribute) {
|
|
3883
|
-
element.removeAttribute(attribute);
|
|
3884
|
-
});
|
|
3885
|
-
});
|
|
3886
|
-
};
|
|
3887
|
-
} // eslint-disable-next-line import/no-unused-modules
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
var applyStyles$1 = {
|
|
3891
|
-
name: 'applyStyles',
|
|
3892
|
-
enabled: true,
|
|
3893
|
-
phase: 'write',
|
|
3894
|
-
fn: applyStyles,
|
|
3895
|
-
effect: effect,
|
|
3896
|
-
requires: ['computeStyles']
|
|
3897
|
-
};
|
|
3898
|
-
|
|
3899
|
-
function getBasePlacement(placement) {
|
|
3900
|
-
return placement.split('-')[0];
|
|
3901
|
-
}
|
|
3902
|
-
|
|
3903
|
-
// Returns the layout rect of an element relative to its offsetParent. Layout
|
|
3904
|
-
// means it doesn't take into account transforms.
|
|
3905
|
-
function getLayoutRect(element) {
|
|
3906
|
-
return {
|
|
3907
|
-
x: element.offsetLeft,
|
|
3908
|
-
y: element.offsetTop,
|
|
3909
|
-
width: element.offsetWidth,
|
|
3910
|
-
height: element.offsetHeight
|
|
3911
|
-
};
|
|
3912
|
-
}
|
|
3913
|
-
|
|
3914
|
-
function contains(parent, child) {
|
|
3915
|
-
var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method
|
|
3916
|
-
|
|
3917
|
-
if (parent.contains(child)) {
|
|
3918
|
-
return true;
|
|
3919
|
-
} // then fallback to custom implementation with Shadow DOM support
|
|
3920
|
-
else if (rootNode && isShadowRoot(rootNode)) {
|
|
3921
|
-
var next = child;
|
|
3922
|
-
|
|
3923
|
-
do {
|
|
3924
|
-
if (next && parent.isSameNode(next)) {
|
|
3925
|
-
return true;
|
|
3926
|
-
} // $FlowFixMe: need a better way to handle this...
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
next = next.parentNode || next.host;
|
|
3930
|
-
} while (next);
|
|
3931
|
-
} // Give up, the result is false
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
return false;
|
|
3935
|
-
}
|
|
3936
|
-
|
|
3937
|
-
function getComputedStyle(element) {
|
|
3938
|
-
return getWindow(element).getComputedStyle(element);
|
|
3939
|
-
}
|
|
3940
|
-
|
|
3941
|
-
function isTableElement(element) {
|
|
3942
|
-
return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
|
|
3943
|
-
}
|
|
3944
|
-
|
|
3945
|
-
function getDocumentElement(element) {
|
|
3946
|
-
// $FlowFixMe: assume body is always available
|
|
3947
|
-
return ((isElement$1(element) ? element.ownerDocument : element.document) || window.document).documentElement;
|
|
3948
|
-
}
|
|
3949
|
-
|
|
3950
|
-
function getParentNode(element) {
|
|
3951
|
-
if (getNodeName(element) === 'html') {
|
|
3952
|
-
return element;
|
|
3953
|
-
}
|
|
3954
|
-
|
|
3955
|
-
return (// $FlowFixMe: this is a quicker (but less type safe) way to save quite some bytes from the bundle
|
|
3956
|
-
element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
|
|
3957
|
-
element.parentNode || // DOM Element detected
|
|
3958
|
-
// $FlowFixMe: need a better way to handle this...
|
|
3959
|
-
element.host || // ShadowRoot detected
|
|
3960
|
-
// $FlowFixMe: HTMLElement is a Node
|
|
3961
|
-
getDocumentElement(element) // fallback
|
|
3962
|
-
|
|
3963
|
-
);
|
|
3964
|
-
}
|
|
3965
|
-
|
|
3966
|
-
function getTrueOffsetParent(element) {
|
|
3967
|
-
if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
|
|
3968
|
-
getComputedStyle(element).position === 'fixed') {
|
|
3969
|
-
return null;
|
|
3970
|
-
}
|
|
3971
|
-
|
|
3972
|
-
var offsetParent = element.offsetParent;
|
|
3973
|
-
|
|
3974
|
-
if (offsetParent) {
|
|
3975
|
-
var html = getDocumentElement(offsetParent);
|
|
3976
|
-
|
|
3977
|
-
if (getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static' && getComputedStyle(html).position !== 'static') {
|
|
3978
|
-
return html;
|
|
3979
|
-
}
|
|
3980
|
-
}
|
|
3981
|
-
|
|
3982
|
-
return offsetParent;
|
|
3983
|
-
} // `.offsetParent` reports `null` for fixed elements, while absolute elements
|
|
3984
|
-
// return the containing block
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
function getContainingBlock(element) {
|
|
3988
|
-
var currentNode = getParentNode(element);
|
|
3989
|
-
|
|
3990
|
-
while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
|
|
3991
|
-
var css = getComputedStyle(currentNode); // This is non-exhaustive but covers the most common CSS properties that
|
|
3992
|
-
// create a containing block.
|
|
3993
|
-
|
|
3994
|
-
if (css.transform !== 'none' || css.perspective !== 'none' || css.willChange && css.willChange !== 'auto') {
|
|
3995
|
-
return currentNode;
|
|
3996
|
-
} else {
|
|
3997
|
-
currentNode = currentNode.parentNode;
|
|
3998
|
-
}
|
|
3999
|
-
}
|
|
4000
|
-
|
|
4001
|
-
return null;
|
|
4002
|
-
} // Gets the closest ancestor positioned element. Handles some edge cases,
|
|
4003
|
-
// such as table ancestors and cross browser bugs.
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
function getOffsetParent(element) {
|
|
4007
|
-
var window = getWindow(element);
|
|
4008
|
-
var offsetParent = getTrueOffsetParent(element);
|
|
4009
|
-
|
|
4010
|
-
while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
|
|
4011
|
-
offsetParent = getTrueOffsetParent(offsetParent);
|
|
4012
|
-
}
|
|
4013
|
-
|
|
4014
|
-
if (offsetParent && getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static') {
|
|
4015
|
-
return window;
|
|
4016
|
-
}
|
|
4017
|
-
|
|
4018
|
-
return offsetParent || getContainingBlock(element) || window;
|
|
4019
|
-
}
|
|
4020
|
-
|
|
4021
|
-
function getMainAxisFromPlacement(placement) {
|
|
4022
|
-
return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
|
|
4023
|
-
}
|
|
4024
|
-
|
|
4025
|
-
function within(min, value, max) {
|
|
4026
|
-
return Math.max(min, Math.min(value, max));
|
|
4027
|
-
}
|
|
4028
|
-
|
|
4029
|
-
function getFreshSideObject() {
|
|
4030
|
-
return {
|
|
4031
|
-
top: 0,
|
|
4032
|
-
right: 0,
|
|
4033
|
-
bottom: 0,
|
|
4034
|
-
left: 0
|
|
4035
|
-
};
|
|
4036
|
-
}
|
|
4037
|
-
|
|
4038
|
-
function mergePaddingObject(paddingObject) {
|
|
4039
|
-
return Object.assign(Object.assign({}, getFreshSideObject()), paddingObject);
|
|
4040
|
-
}
|
|
4041
|
-
|
|
4042
|
-
function expandToHashMap(value, keys) {
|
|
4043
|
-
return keys.reduce(function (hashMap, key) {
|
|
4044
|
-
hashMap[key] = value;
|
|
4045
|
-
return hashMap;
|
|
4046
|
-
}, {});
|
|
4047
|
-
}
|
|
4048
|
-
|
|
4049
|
-
function arrow(_ref) {
|
|
4050
|
-
var _state$modifiersData$;
|
|
4051
|
-
|
|
4052
|
-
var state = _ref.state,
|
|
4053
|
-
name = _ref.name;
|
|
4054
|
-
var arrowElement = state.elements.arrow;
|
|
4055
|
-
var popperOffsets = state.modifiersData.popperOffsets;
|
|
4056
|
-
var basePlacement = getBasePlacement(state.placement);
|
|
4057
|
-
var axis = getMainAxisFromPlacement(basePlacement);
|
|
4058
|
-
var isVertical = [left, right].indexOf(basePlacement) >= 0;
|
|
4059
|
-
var len = isVertical ? 'height' : 'width';
|
|
4060
|
-
|
|
4061
|
-
if (!arrowElement || !popperOffsets) {
|
|
4062
|
-
return;
|
|
4063
|
-
}
|
|
4064
|
-
|
|
4065
|
-
var paddingObject = state.modifiersData[name + "#persistent"].padding;
|
|
4066
|
-
var arrowRect = getLayoutRect(arrowElement);
|
|
4067
|
-
var minProp = axis === 'y' ? top : left;
|
|
4068
|
-
var maxProp = axis === 'y' ? bottom : right;
|
|
4069
|
-
var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
|
|
4070
|
-
var startDiff = popperOffsets[axis] - state.rects.reference[axis];
|
|
4071
|
-
var arrowOffsetParent = getOffsetParent(arrowElement);
|
|
4072
|
-
var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
|
|
4073
|
-
var centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the popper if the center point is
|
|
4074
|
-
// outside of the popper bounds
|
|
4075
|
-
|
|
4076
|
-
var min = paddingObject[minProp];
|
|
4077
|
-
var max = clientSize - arrowRect[len] - paddingObject[maxProp];
|
|
4078
|
-
var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
|
|
4079
|
-
var offset = within(min, center, max); // Prevents breaking syntax highlighting...
|
|
4080
|
-
|
|
4081
|
-
var axisProp = axis;
|
|
4082
|
-
state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);
|
|
4083
|
-
}
|
|
4084
|
-
|
|
4085
|
-
function effect$1(_ref2) {
|
|
4086
|
-
var state = _ref2.state,
|
|
4087
|
-
options = _ref2.options,
|
|
4088
|
-
name = _ref2.name;
|
|
4089
|
-
var _options$element = options.element,
|
|
4090
|
-
arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element,
|
|
4091
|
-
_options$padding = options.padding,
|
|
4092
|
-
padding = _options$padding === void 0 ? 0 : _options$padding;
|
|
4093
|
-
|
|
4094
|
-
if (arrowElement == null) {
|
|
4095
|
-
return;
|
|
4096
|
-
} // CSS selector
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
if (typeof arrowElement === 'string') {
|
|
4100
|
-
arrowElement = state.elements.popper.querySelector(arrowElement);
|
|
4101
|
-
|
|
4102
|
-
if (!arrowElement) {
|
|
4103
|
-
return;
|
|
4104
|
-
}
|
|
4105
|
-
}
|
|
4106
|
-
|
|
4107
|
-
if (process.env.NODE_ENV !== "production") {
|
|
4108
|
-
if (!isHTMLElement(arrowElement)) {
|
|
4109
|
-
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(' '));
|
|
4110
|
-
}
|
|
4111
|
-
}
|
|
4112
|
-
|
|
4113
|
-
if (!contains(state.elements.popper, arrowElement)) {
|
|
4114
|
-
if (process.env.NODE_ENV !== "production") {
|
|
4115
|
-
console.error(['Popper: "arrow" modifier\'s `element` must be a child of the popper', 'element.'].join(' '));
|
|
4116
|
-
}
|
|
4117
|
-
|
|
4118
|
-
return;
|
|
4119
|
-
}
|
|
4120
|
-
|
|
4121
|
-
state.elements.arrow = arrowElement;
|
|
4122
|
-
state.modifiersData[name + "#persistent"] = {
|
|
4123
|
-
padding: mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements))
|
|
4124
|
-
};
|
|
4125
|
-
} // eslint-disable-next-line import/no-unused-modules
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
var arrow$1 = {
|
|
4129
|
-
name: 'arrow',
|
|
4130
|
-
enabled: true,
|
|
4131
|
-
phase: 'main',
|
|
4132
|
-
fn: arrow,
|
|
4133
|
-
effect: effect$1,
|
|
4134
|
-
requires: ['popperOffsets'],
|
|
4135
|
-
requiresIfExists: ['preventOverflow']
|
|
4136
|
-
};
|
|
4137
|
-
|
|
4138
|
-
var unsetSides = {
|
|
4139
|
-
top: 'auto',
|
|
4140
|
-
right: 'auto',
|
|
4141
|
-
bottom: 'auto',
|
|
4142
|
-
left: 'auto'
|
|
4143
|
-
}; // Round the offsets to the nearest suitable subpixel based on the DPR.
|
|
4144
|
-
// Zooming can change the DPR, but it seems to report a value that will
|
|
4145
|
-
// cleanly divide the values into the appropriate subpixels.
|
|
4146
|
-
|
|
4147
|
-
function roundOffsets(_ref) {
|
|
4148
|
-
var x = _ref.x,
|
|
4149
|
-
y = _ref.y;
|
|
4150
|
-
var win = window;
|
|
4151
|
-
var dpr = win.devicePixelRatio || 1;
|
|
4152
|
-
return {
|
|
4153
|
-
x: Math.round(x * dpr) / dpr || 0,
|
|
4154
|
-
y: Math.round(y * dpr) / dpr || 0
|
|
4155
|
-
};
|
|
4156
|
-
}
|
|
4157
|
-
|
|
4158
|
-
function mapToStyles(_ref2) {
|
|
4159
|
-
var _Object$assign2;
|
|
4160
|
-
|
|
4161
|
-
var popper = _ref2.popper,
|
|
4162
|
-
popperRect = _ref2.popperRect,
|
|
4163
|
-
placement = _ref2.placement,
|
|
4164
|
-
offsets = _ref2.offsets,
|
|
4165
|
-
position = _ref2.position,
|
|
4166
|
-
gpuAcceleration = _ref2.gpuAcceleration,
|
|
4167
|
-
adaptive = _ref2.adaptive;
|
|
4168
|
-
|
|
4169
|
-
var _roundOffsets = roundOffsets(offsets),
|
|
4170
|
-
x = _roundOffsets.x,
|
|
4171
|
-
y = _roundOffsets.y;
|
|
4172
|
-
|
|
4173
|
-
var hasX = offsets.hasOwnProperty('x');
|
|
4174
|
-
var hasY = offsets.hasOwnProperty('y');
|
|
4175
|
-
var sideX = left;
|
|
4176
|
-
var sideY = top;
|
|
4177
|
-
var win = window;
|
|
4178
|
-
|
|
4179
|
-
if (adaptive) {
|
|
4180
|
-
var offsetParent = getOffsetParent(popper);
|
|
4181
|
-
|
|
4182
|
-
if (offsetParent === getWindow(popper)) {
|
|
4183
|
-
offsetParent = getDocumentElement(popper);
|
|
4184
|
-
} // $FlowFixMe: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it
|
|
4185
|
-
|
|
4186
|
-
/*:: offsetParent = (offsetParent: Element); */
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
if (placement === top) {
|
|
4190
|
-
sideY = bottom;
|
|
4191
|
-
y -= offsetParent.clientHeight - popperRect.height;
|
|
4192
|
-
y *= gpuAcceleration ? 1 : -1;
|
|
4193
|
-
}
|
|
4194
|
-
|
|
4195
|
-
if (placement === left) {
|
|
4196
|
-
sideX = right;
|
|
4197
|
-
x -= offsetParent.clientWidth - popperRect.width;
|
|
4198
|
-
x *= gpuAcceleration ? 1 : -1;
|
|
4199
|
-
}
|
|
4200
|
-
}
|
|
4201
|
-
|
|
4202
|
-
var commonStyles = Object.assign({
|
|
4203
|
-
position: position
|
|
4204
|
-
}, adaptive && unsetSides);
|
|
4205
|
-
|
|
4206
|
-
if (gpuAcceleration) {
|
|
4207
|
-
var _Object$assign;
|
|
4208
|
-
|
|
4209
|
-
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));
|
|
4210
|
-
}
|
|
4211
|
-
|
|
4212
|
-
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));
|
|
4213
|
-
}
|
|
4214
|
-
|
|
4215
|
-
function computeStyles(_ref3) {
|
|
4216
|
-
var state = _ref3.state,
|
|
4217
|
-
options = _ref3.options;
|
|
4218
|
-
var _options$gpuAccelerat = options.gpuAcceleration,
|
|
4219
|
-
gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
|
|
4220
|
-
_options$adaptive = options.adaptive,
|
|
4221
|
-
adaptive = _options$adaptive === void 0 ? true : _options$adaptive;
|
|
4222
|
-
|
|
4223
|
-
if (process.env.NODE_ENV !== "production") {
|
|
4224
|
-
var transitionProperty = getComputedStyle(state.elements.popper).transitionProperty || '';
|
|
4225
|
-
|
|
4226
|
-
if (adaptive && ['transform', 'top', 'right', 'bottom', 'left'].some(function (property) {
|
|
4227
|
-
return transitionProperty.indexOf(property) >= 0;
|
|
4228
|
-
})) {
|
|
4229
|
-
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(' '));
|
|
3742
|
+
/**
|
|
3743
|
+
* Hook that allows to control when there is a focus event within a given element, meaning
|
|
3744
|
+
* that any element within the given target will trigger the focus in and focus out events.
|
|
3745
|
+
* @param options - UseFocusWithinOptions
|
|
3746
|
+
*/
|
|
3747
|
+
const useFocusWithin = _ref => {
|
|
3748
|
+
let {
|
|
3749
|
+
element,
|
|
3750
|
+
onFocusIn,
|
|
3751
|
+
onFocusOut
|
|
3752
|
+
} = _ref;
|
|
3753
|
+
useEffect(() => {
|
|
3754
|
+
if (element) {
|
|
3755
|
+
element.addEventListener('focusin', onFocusIn);
|
|
3756
|
+
element.addEventListener('focusout', onFocusOut);
|
|
4230
3757
|
}
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
};
|
|
4239
|
-
|
|
4240
|
-
if (state.modifiersData.popperOffsets != null) {
|
|
4241
|
-
state.styles.popper = Object.assign(Object.assign({}, state.styles.popper), mapToStyles(Object.assign(Object.assign({}, commonStyles), {}, {
|
|
4242
|
-
offsets: state.modifiersData.popperOffsets,
|
|
4243
|
-
position: state.options.strategy,
|
|
4244
|
-
adaptive: adaptive
|
|
4245
|
-
})));
|
|
4246
|
-
}
|
|
4247
|
-
|
|
4248
|
-
if (state.modifiersData.arrow != null) {
|
|
4249
|
-
state.styles.arrow = Object.assign(Object.assign({}, state.styles.arrow), mapToStyles(Object.assign(Object.assign({}, commonStyles), {}, {
|
|
4250
|
-
offsets: state.modifiersData.arrow,
|
|
4251
|
-
position: 'absolute',
|
|
4252
|
-
adaptive: false
|
|
4253
|
-
})));
|
|
4254
|
-
}
|
|
4255
|
-
|
|
4256
|
-
state.attributes.popper = Object.assign(Object.assign({}, state.attributes.popper), {}, {
|
|
4257
|
-
'data-popper-placement': state.placement
|
|
4258
|
-
});
|
|
4259
|
-
} // eslint-disable-next-line import/no-unused-modules
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
var computeStyles$1 = {
|
|
4263
|
-
name: 'computeStyles',
|
|
4264
|
-
enabled: true,
|
|
4265
|
-
phase: 'beforeWrite',
|
|
4266
|
-
fn: computeStyles,
|
|
4267
|
-
data: {}
|
|
4268
|
-
};
|
|
4269
|
-
|
|
4270
|
-
var passive = {
|
|
4271
|
-
passive: true
|
|
3758
|
+
return () => {
|
|
3759
|
+
if (element) {
|
|
3760
|
+
element.removeEventListener('focusin', onFocusIn);
|
|
3761
|
+
element.removeEventListener('focusout', onFocusOut);
|
|
3762
|
+
}
|
|
3763
|
+
};
|
|
3764
|
+
}, [onFocusIn, element, onFocusOut]);
|
|
4272
3765
|
};
|
|
4273
3766
|
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
resize = _options$resize === void 0 ? true : _options$resize;
|
|
4282
|
-
var window = getWindow(state.elements.popper);
|
|
4283
|
-
var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
|
|
4284
|
-
|
|
4285
|
-
if (scroll) {
|
|
4286
|
-
scrollParents.forEach(function (scrollParent) {
|
|
4287
|
-
scrollParent.addEventListener('scroll', instance.update, passive);
|
|
4288
|
-
});
|
|
4289
|
-
}
|
|
4290
|
-
|
|
4291
|
-
if (resize) {
|
|
4292
|
-
window.addEventListener('resize', instance.update, passive);
|
|
4293
|
-
}
|
|
4294
|
-
|
|
4295
|
-
return function () {
|
|
4296
|
-
if (scroll) {
|
|
4297
|
-
scrollParents.forEach(function (scrollParent) {
|
|
4298
|
-
scrollParent.removeEventListener('scroll', instance.update, passive);
|
|
4299
|
-
});
|
|
4300
|
-
}
|
|
4301
|
-
|
|
4302
|
-
if (resize) {
|
|
4303
|
-
window.removeEventListener('resize', instance.update, passive);
|
|
3767
|
+
/**
|
|
3768
|
+
* HOC component skipping render if predicate if falsy
|
|
3769
|
+
*/
|
|
3770
|
+
const skipRenderHOC = (predicate, Component) => {
|
|
3771
|
+
const Wrapper = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
3772
|
+
if (!predicate(props)) {
|
|
3773
|
+
return null;
|
|
4304
3774
|
}
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
var eventListeners = {
|
|
4310
|
-
name: 'eventListeners',
|
|
4311
|
-
enabled: true,
|
|
4312
|
-
phase: 'write',
|
|
4313
|
-
fn: function fn() {},
|
|
4314
|
-
effect: effect$2,
|
|
4315
|
-
data: {}
|
|
4316
|
-
};
|
|
4317
|
-
|
|
4318
|
-
var hash = {
|
|
4319
|
-
left: 'right',
|
|
4320
|
-
right: 'left',
|
|
4321
|
-
bottom: 'top',
|
|
4322
|
-
top: 'bottom'
|
|
4323
|
-
};
|
|
4324
|
-
function getOppositePlacement(placement) {
|
|
4325
|
-
return placement.replace(/left|right|bottom|top/g, function (matched) {
|
|
4326
|
-
return hash[matched];
|
|
3775
|
+
return /*#__PURE__*/React.createElement(Component, _extends({
|
|
3776
|
+
ref: ref
|
|
3777
|
+
}, props));
|
|
4327
3778
|
});
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
var hash$1 = {
|
|
4331
|
-
start: 'end',
|
|
4332
|
-
end: 'start'
|
|
3779
|
+
Wrapper.displayName = Component.displayName;
|
|
3780
|
+
return Wrapper;
|
|
4333
3781
|
};
|
|
4334
|
-
function getOppositeVariationPlacement(placement) {
|
|
4335
|
-
return placement.replace(/start|end/g, function (matched) {
|
|
4336
|
-
return hash$1[matched];
|
|
4337
|
-
});
|
|
4338
|
-
}
|
|
4339
|
-
|
|
4340
|
-
function getBoundingClientRect(element) {
|
|
4341
|
-
var rect = element.getBoundingClientRect();
|
|
4342
|
-
return {
|
|
4343
|
-
width: rect.width,
|
|
4344
|
-
height: rect.height,
|
|
4345
|
-
top: rect.top,
|
|
4346
|
-
right: rect.right,
|
|
4347
|
-
bottom: rect.bottom,
|
|
4348
|
-
left: rect.left,
|
|
4349
|
-
x: rect.left,
|
|
4350
|
-
y: rect.top
|
|
4351
|
-
};
|
|
4352
|
-
}
|
|
4353
3782
|
|
|
4354
|
-
function
|
|
4355
|
-
|
|
4356
|
-
var scrollLeft = win.pageXOffset;
|
|
4357
|
-
var scrollTop = win.pageYOffset;
|
|
4358
|
-
return {
|
|
4359
|
-
scrollLeft: scrollLeft,
|
|
4360
|
-
scrollTop: scrollTop
|
|
4361
|
-
};
|
|
4362
|
-
}
|
|
4363
|
-
|
|
4364
|
-
function getWindowScrollBarX(element) {
|
|
4365
|
-
// If <html> has a CSS width greater than the viewport, then this will be
|
|
4366
|
-
// incorrect for RTL.
|
|
4367
|
-
// Popper 1 is broken in this case and never had a bug report so let's assume
|
|
4368
|
-
// it's not an issue. I don't think anyone ever specifies width on <html>
|
|
4369
|
-
// anyway.
|
|
4370
|
-
// Browsers where the left scrollbar doesn't cause an issue report `0` for
|
|
4371
|
-
// this (e.g. Edge 2019, IE11, Safari)
|
|
4372
|
-
return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
|
|
4373
|
-
}
|
|
4374
|
-
|
|
4375
|
-
function getViewportRect(element) {
|
|
4376
|
-
var win = getWindow(element);
|
|
4377
|
-
var html = getDocumentElement(element);
|
|
4378
|
-
var visualViewport = win.visualViewport;
|
|
4379
|
-
var width = html.clientWidth;
|
|
4380
|
-
var height = html.clientHeight;
|
|
4381
|
-
var x = 0;
|
|
4382
|
-
var y = 0; // NB: This isn't supported on iOS <= 12. If the keyboard is open, the popper
|
|
4383
|
-
// can be obscured underneath it.
|
|
4384
|
-
// Also, `html.clientHeight` adds the bottom bar height in Safari iOS, even
|
|
4385
|
-
// if it isn't open, so if this isn't available, the popper will be detected
|
|
4386
|
-
// to overflow the bottom of the screen too early.
|
|
4387
|
-
|
|
4388
|
-
if (visualViewport) {
|
|
4389
|
-
width = visualViewport.width;
|
|
4390
|
-
height = visualViewport.height; // Uses Layout Viewport (like Chrome; Safari does not currently)
|
|
4391
|
-
// In Chrome, it returns a value very close to 0 (+/-) but contains rounding
|
|
4392
|
-
// errors due to floating point numbers, so we need to check precision.
|
|
4393
|
-
// Safari returns a number <= 0, usually < -1 when pinch-zoomed
|
|
4394
|
-
// Feature detection fails in mobile emulation mode in Chrome.
|
|
4395
|
-
// Math.abs(win.innerWidth / visualViewport.scale - visualViewport.width) <
|
|
4396
|
-
// 0.001
|
|
4397
|
-
// Fallback here: "Not Safari" userAgent
|
|
4398
|
-
|
|
4399
|
-
if (!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
|
|
4400
|
-
x = visualViewport.offsetLeft;
|
|
4401
|
-
y = visualViewport.offsetTop;
|
|
4402
|
-
}
|
|
4403
|
-
}
|
|
4404
|
-
|
|
4405
|
-
return {
|
|
4406
|
-
width: width,
|
|
4407
|
-
height: height,
|
|
4408
|
-
x: x + getWindowScrollBarX(element),
|
|
4409
|
-
y: y
|
|
4410
|
-
};
|
|
4411
|
-
}
|
|
4412
|
-
|
|
4413
|
-
// of the `<html>` and `<body>` rect bounds if horizontally scrollable
|
|
4414
|
-
|
|
4415
|
-
function getDocumentRect(element) {
|
|
4416
|
-
var html = getDocumentElement(element);
|
|
4417
|
-
var winScroll = getWindowScroll(element);
|
|
4418
|
-
var body = element.ownerDocument.body;
|
|
4419
|
-
var width = Math.max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
|
|
4420
|
-
var height = Math.max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
|
|
4421
|
-
var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
|
|
4422
|
-
var y = -winScroll.scrollTop;
|
|
4423
|
-
|
|
4424
|
-
if (getComputedStyle(body || html).direction === 'rtl') {
|
|
4425
|
-
x += Math.max(html.clientWidth, body ? body.clientWidth : 0) - width;
|
|
4426
|
-
}
|
|
4427
|
-
|
|
4428
|
-
return {
|
|
4429
|
-
width: width,
|
|
4430
|
-
height: height,
|
|
4431
|
-
x: x,
|
|
4432
|
-
y: y
|
|
4433
|
-
};
|
|
4434
|
-
}
|
|
4435
|
-
|
|
4436
|
-
function isScrollParent(element) {
|
|
4437
|
-
// Firefox wants us to check `-x` and `-y` variations as well
|
|
4438
|
-
var _getComputedStyle = getComputedStyle(element),
|
|
4439
|
-
overflow = _getComputedStyle.overflow,
|
|
4440
|
-
overflowX = _getComputedStyle.overflowX,
|
|
4441
|
-
overflowY = _getComputedStyle.overflowY;
|
|
4442
|
-
|
|
4443
|
-
return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
|
|
4444
|
-
}
|
|
4445
|
-
|
|
4446
|
-
function getScrollParent(node) {
|
|
4447
|
-
if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
|
|
4448
|
-
// $FlowFixMe: assume body is always available
|
|
4449
|
-
return node.ownerDocument.body;
|
|
4450
|
-
}
|
|
4451
|
-
|
|
4452
|
-
if (isHTMLElement(node) && isScrollParent(node)) {
|
|
4453
|
-
return node;
|
|
4454
|
-
}
|
|
4455
|
-
|
|
4456
|
-
return getScrollParent(getParentNode(node));
|
|
4457
|
-
}
|
|
4458
|
-
|
|
4459
|
-
/*
|
|
4460
|
-
given a DOM element, return the list of all scroll parents, up the list of ancesors
|
|
4461
|
-
until we get to the top window object. This list is what we attach scroll listeners
|
|
4462
|
-
to, because if any of these parent elements scroll, we'll need to re-calculate the
|
|
4463
|
-
reference element's position.
|
|
4464
|
-
*/
|
|
4465
|
-
|
|
4466
|
-
function listScrollParents(element, list) {
|
|
4467
|
-
if (list === void 0) {
|
|
4468
|
-
list = [];
|
|
4469
|
-
}
|
|
4470
|
-
|
|
4471
|
-
var scrollParent = getScrollParent(element);
|
|
4472
|
-
var isBody = getNodeName(scrollParent) === 'body';
|
|
4473
|
-
var win = getWindow(scrollParent);
|
|
4474
|
-
var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
|
|
4475
|
-
var updatedList = list.concat(target);
|
|
4476
|
-
return isBody ? updatedList : // $FlowFixMe: isBody tells us target will be an HTMLElement here
|
|
4477
|
-
updatedList.concat(listScrollParents(getParentNode(target)));
|
|
4478
|
-
}
|
|
4479
|
-
|
|
4480
|
-
function rectToClientRect(rect) {
|
|
4481
|
-
return Object.assign(Object.assign({}, rect), {}, {
|
|
4482
|
-
left: rect.x,
|
|
4483
|
-
top: rect.y,
|
|
4484
|
-
right: rect.x + rect.width,
|
|
4485
|
-
bottom: rect.y + rect.height
|
|
4486
|
-
});
|
|
3783
|
+
function getAlignment(placement) {
|
|
3784
|
+
return placement.split('-')[1];
|
|
4487
3785
|
}
|
|
4488
3786
|
|
|
4489
|
-
function
|
|
4490
|
-
|
|
4491
|
-
rect.top = rect.top + element.clientTop;
|
|
4492
|
-
rect.left = rect.left + element.clientLeft;
|
|
4493
|
-
rect.bottom = rect.top + element.clientHeight;
|
|
4494
|
-
rect.right = rect.left + element.clientWidth;
|
|
4495
|
-
rect.width = element.clientWidth;
|
|
4496
|
-
rect.height = element.clientHeight;
|
|
4497
|
-
rect.x = rect.left;
|
|
4498
|
-
rect.y = rect.top;
|
|
4499
|
-
return rect;
|
|
3787
|
+
function getLengthFromAxis(axis) {
|
|
3788
|
+
return axis === 'y' ? 'height' : 'width';
|
|
4500
3789
|
}
|
|
4501
3790
|
|
|
4502
|
-
function
|
|
4503
|
-
return
|
|
4504
|
-
} // A "clipping parent" is an overflowable container with the characteristic of
|
|
4505
|
-
// clipping (or hiding) overflowing elements with a position different from
|
|
4506
|
-
// `initial`
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
function getClippingParents(element) {
|
|
4510
|
-
var clippingParents = listScrollParents(getParentNode(element));
|
|
4511
|
-
var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle(element).position) >= 0;
|
|
4512
|
-
var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
|
|
4513
|
-
|
|
4514
|
-
if (!isElement$1(clipperElement)) {
|
|
4515
|
-
return [];
|
|
4516
|
-
} // $FlowFixMe: https://github.com/facebook/flow/issues/1414
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
return clippingParents.filter(function (clippingParent) {
|
|
4520
|
-
return isElement$1(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
|
|
4521
|
-
});
|
|
4522
|
-
} // Gets the maximum area that the element is visible in due to any number of
|
|
4523
|
-
// clipping parents
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
function getClippingRect(element, boundary, rootBoundary) {
|
|
4527
|
-
var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
|
|
4528
|
-
var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
|
|
4529
|
-
var firstClippingParent = clippingParents[0];
|
|
4530
|
-
var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
|
|
4531
|
-
var rect = getClientRectFromMixedType(element, clippingParent);
|
|
4532
|
-
accRect.top = Math.max(rect.top, accRect.top);
|
|
4533
|
-
accRect.right = Math.min(rect.right, accRect.right);
|
|
4534
|
-
accRect.bottom = Math.min(rect.bottom, accRect.bottom);
|
|
4535
|
-
accRect.left = Math.max(rect.left, accRect.left);
|
|
4536
|
-
return accRect;
|
|
4537
|
-
}, getClientRectFromMixedType(element, firstClippingParent));
|
|
4538
|
-
clippingRect.width = clippingRect.right - clippingRect.left;
|
|
4539
|
-
clippingRect.height = clippingRect.bottom - clippingRect.top;
|
|
4540
|
-
clippingRect.x = clippingRect.left;
|
|
4541
|
-
clippingRect.y = clippingRect.top;
|
|
4542
|
-
return clippingRect;
|
|
3791
|
+
function getSide(placement) {
|
|
3792
|
+
return placement.split('-')[0];
|
|
4543
3793
|
}
|
|
4544
3794
|
|
|
4545
|
-
function
|
|
4546
|
-
return
|
|
3795
|
+
function getMainAxisFromPlacement(placement) {
|
|
3796
|
+
return ['top', 'bottom'].includes(getSide(placement)) ? 'x' : 'y';
|
|
4547
3797
|
}
|
|
4548
3798
|
|
|
4549
|
-
function
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
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 = {
|
|
4562
3815
|
x: commonX,
|
|
4563
|
-
y: reference.y -
|
|
3816
|
+
y: reference.y - floating.height
|
|
4564
3817
|
};
|
|
4565
3818
|
break;
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
offsets = {
|
|
3819
|
+
case 'bottom':
|
|
3820
|
+
coords = {
|
|
4569
3821
|
x: commonX,
|
|
4570
3822
|
y: reference.y + reference.height
|
|
4571
3823
|
};
|
|
4572
3824
|
break;
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
offsets = {
|
|
3825
|
+
case 'right':
|
|
3826
|
+
coords = {
|
|
4576
3827
|
x: reference.x + reference.width,
|
|
4577
3828
|
y: commonY
|
|
4578
3829
|
};
|
|
4579
3830
|
break;
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
x: reference.x - element.width,
|
|
3831
|
+
case 'left':
|
|
3832
|
+
coords = {
|
|
3833
|
+
x: reference.x - floating.width,
|
|
4584
3834
|
y: commonY
|
|
4585
3835
|
};
|
|
4586
3836
|
break;
|
|
4587
|
-
|
|
4588
3837
|
default:
|
|
4589
|
-
|
|
3838
|
+
coords = {
|
|
4590
3839
|
x: reference.x,
|
|
4591
3840
|
y: reference.y
|
|
4592
3841
|
};
|
|
4593
3842
|
}
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
|
|
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;
|
|
3850
|
+
}
|
|
3851
|
+
return coords;
|
|
3852
|
+
}
|
|
3853
|
+
|
|
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
|
+
}
|
|
3885
|
+
}
|
|
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
|
+
}
|
|
3935
|
+
}
|
|
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;
|
|
4608
3956
|
}
|
|
4609
3957
|
}
|
|
3958
|
+
return {
|
|
3959
|
+
x,
|
|
3960
|
+
y,
|
|
3961
|
+
placement: statefulPlacement,
|
|
3962
|
+
strategy,
|
|
3963
|
+
middlewareData
|
|
3964
|
+
};
|
|
3965
|
+
};
|
|
4610
3966
|
|
|
4611
|
-
|
|
3967
|
+
function expandPaddingObject(padding) {
|
|
3968
|
+
return {
|
|
3969
|
+
top: 0,
|
|
3970
|
+
right: 0,
|
|
3971
|
+
bottom: 0,
|
|
3972
|
+
left: 0,
|
|
3973
|
+
...padding
|
|
3974
|
+
};
|
|
4612
3975
|
}
|
|
4613
3976
|
|
|
4614
|
-
function
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
_options$placement = _options.placement,
|
|
4621
|
-
placement = _options$placement === void 0 ? state.placement : _options$placement,
|
|
4622
|
-
_options$boundary = _options.boundary,
|
|
4623
|
-
boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
|
|
4624
|
-
_options$rootBoundary = _options.rootBoundary,
|
|
4625
|
-
rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
|
|
4626
|
-
_options$elementConte = _options.elementContext,
|
|
4627
|
-
elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
|
|
4628
|
-
_options$altBoundary = _options.altBoundary,
|
|
4629
|
-
altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
|
|
4630
|
-
_options$padding = _options.padding,
|
|
4631
|
-
padding = _options$padding === void 0 ? 0 : _options$padding;
|
|
4632
|
-
var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
|
|
4633
|
-
var altContext = elementContext === popper ? reference : popper;
|
|
4634
|
-
var referenceElement = state.elements.reference;
|
|
4635
|
-
var popperRect = state.rects.popper;
|
|
4636
|
-
var element = state.elements[altBoundary ? altContext : elementContext];
|
|
4637
|
-
var clippingClientRect = getClippingRect(isElement$1(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
|
|
4638
|
-
var referenceClientRect = getBoundingClientRect(referenceElement);
|
|
4639
|
-
var popperOffsets = computeOffsets({
|
|
4640
|
-
reference: referenceClientRect,
|
|
4641
|
-
element: popperRect,
|
|
4642
|
-
strategy: 'absolute',
|
|
4643
|
-
placement: placement
|
|
4644
|
-
});
|
|
4645
|
-
var popperClientRect = rectToClientRect(Object.assign(Object.assign({}, popperRect), popperOffsets));
|
|
4646
|
-
var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect
|
|
4647
|
-
// 0 or negative = within the clipping rect
|
|
4648
|
-
|
|
4649
|
-
var overflowOffsets = {
|
|
4650
|
-
top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
|
|
4651
|
-
bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
|
|
4652
|
-
left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
|
|
4653
|
-
right: elementClientRect.right - clippingClientRect.right + paddingObject.right
|
|
3977
|
+
function getSideObjectFromPadding(padding) {
|
|
3978
|
+
return typeof padding !== 'number' ? expandPaddingObject(padding) : {
|
|
3979
|
+
top: padding,
|
|
3980
|
+
right: padding,
|
|
3981
|
+
bottom: padding,
|
|
3982
|
+
left: padding
|
|
4654
3983
|
};
|
|
4655
|
-
var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element
|
|
4656
|
-
|
|
4657
|
-
if (elementContext === popper && offsetData) {
|
|
4658
|
-
var offset = offsetData[placement];
|
|
4659
|
-
Object.keys(overflowOffsets).forEach(function (key) {
|
|
4660
|
-
var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
|
|
4661
|
-
var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
|
|
4662
|
-
overflowOffsets[key] += offset[axis] * multiply;
|
|
4663
|
-
});
|
|
4664
|
-
}
|
|
4665
|
-
|
|
4666
|
-
return overflowOffsets;
|
|
4667
3984
|
}
|
|
4668
3985
|
|
|
4669
|
-
|
|
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
|
+
};
|
|
3994
|
+
}
|
|
4670
3995
|
|
|
4671
|
-
|
|
4672
|
-
|
|
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;
|
|
4673
4006
|
if (options === void 0) {
|
|
4674
4007
|
options = {};
|
|
4675
4008
|
}
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
|
|
4699
|
-
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
|
|
4709
|
-
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
|
|
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
|
|
4045
|
+
};
|
|
4046
|
+
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
4047
|
+
rect,
|
|
4048
|
+
offsetParent,
|
|
4049
|
+
strategy
|
|
4050
|
+
}) : rect);
|
|
4051
|
+
if (process.env.NODE_ENV !== "production") ;
|
|
4052
|
+
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
|
|
4057
|
+
};
|
|
4715
4058
|
}
|
|
4716
4059
|
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
return [];
|
|
4720
|
-
}
|
|
4060
|
+
const min = Math.min;
|
|
4061
|
+
const max = Math.max;
|
|
4721
4062
|
|
|
4722
|
-
|
|
4723
|
-
return
|
|
4063
|
+
function within(min$1, value, max$1) {
|
|
4064
|
+
return max(min$1, min(value, max$1));
|
|
4724
4065
|
}
|
|
4725
4066
|
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
return acc.concat(getBasePlacement(placement) === auto ? computeAutoPlacement(state, {
|
|
4753
|
-
placement: placement,
|
|
4754
|
-
boundary: boundary,
|
|
4755
|
-
rootBoundary: rootBoundary,
|
|
4756
|
-
padding: padding,
|
|
4757
|
-
flipVariations: flipVariations,
|
|
4758
|
-
allowedAutoPlacements: allowedAutoPlacements
|
|
4759
|
-
}) : placement);
|
|
4760
|
-
}, []);
|
|
4761
|
-
var referenceRect = state.rects.reference;
|
|
4762
|
-
var popperRect = state.rects.popper;
|
|
4763
|
-
var checksMap = new Map();
|
|
4764
|
-
var makeFallbackChecks = true;
|
|
4765
|
-
var firstFittingPlacement = placements[0];
|
|
4766
|
-
|
|
4767
|
-
for (var i = 0; i < placements.length; i++) {
|
|
4768
|
-
var placement = placements[i];
|
|
4769
|
-
|
|
4770
|
-
var _basePlacement = getBasePlacement(placement);
|
|
4771
|
-
|
|
4772
|
-
var isStartVariation = getVariation(placement) === start;
|
|
4773
|
-
var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
|
|
4774
|
-
var len = isVertical ? 'width' : 'height';
|
|
4775
|
-
var overflow = detectOverflow(state, {
|
|
4776
|
-
placement: placement,
|
|
4777
|
-
boundary: boundary,
|
|
4778
|
-
rootBoundary: rootBoundary,
|
|
4779
|
-
altBoundary: altBoundary,
|
|
4780
|
-
padding: padding
|
|
4781
|
-
});
|
|
4782
|
-
var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
|
|
4783
|
-
|
|
4784
|
-
if (referenceRect[len] > popperRect[len]) {
|
|
4785
|
-
mainVariationSide = getOppositePlacement(mainVariationSide);
|
|
4786
|
-
}
|
|
4787
|
-
|
|
4788
|
-
var altVariationSide = getOppositePlacement(mainVariationSide);
|
|
4789
|
-
var checks = [];
|
|
4790
|
-
|
|
4791
|
-
if (checkMainAxis) {
|
|
4792
|
-
checks.push(overflow[_basePlacement] <= 0);
|
|
4793
|
-
}
|
|
4794
|
-
|
|
4795
|
-
if (checkAltAxis) {
|
|
4796
|
-
checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
|
|
4797
|
-
}
|
|
4798
|
-
|
|
4799
|
-
if (checks.every(function (check) {
|
|
4800
|
-
return check;
|
|
4801
|
-
})) {
|
|
4802
|
-
firstFittingPlacement = placement;
|
|
4803
|
-
makeFallbackChecks = false;
|
|
4804
|
-
break;
|
|
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 {};
|
|
4805
4093
|
}
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
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
|
|
4828
4131
|
}
|
|
4829
4132
|
};
|
|
4830
|
-
|
|
4831
|
-
for (var _i = numberOfChecks; _i > 0; _i--) {
|
|
4832
|
-
var _ret = _loop(_i);
|
|
4833
|
-
|
|
4834
|
-
if (_ret === "break") break;
|
|
4835
|
-
}
|
|
4836
|
-
}
|
|
4837
|
-
|
|
4838
|
-
if (state.placement !== firstFittingPlacement) {
|
|
4839
|
-
state.modifiersData[name]._skip = true;
|
|
4840
|
-
state.placement = firstFittingPlacement;
|
|
4841
|
-
state.reset = true;
|
|
4842
4133
|
}
|
|
4843
|
-
}
|
|
4134
|
+
});
|
|
4844
4135
|
|
|
4136
|
+
const sides = ['top', 'right', 'bottom', 'left'];
|
|
4137
|
+
const allPlacements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + "-start", side + "-end"), []);
|
|
4845
4138
|
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
requiresIfExists: ['offset'],
|
|
4852
|
-
data: {
|
|
4853
|
-
_skip: false
|
|
4854
|
-
}
|
|
4139
|
+
const oppositeSideMap = {
|
|
4140
|
+
left: 'right',
|
|
4141
|
+
right: 'left',
|
|
4142
|
+
bottom: 'top',
|
|
4143
|
+
top: 'bottom'
|
|
4855
4144
|
};
|
|
4145
|
+
function getOppositePlacement(placement) {
|
|
4146
|
+
return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
|
|
4147
|
+
}
|
|
4856
4148
|
|
|
4857
|
-
function
|
|
4858
|
-
if (
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
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);
|
|
4863
4159
|
}
|
|
4864
|
-
|
|
4865
4160
|
return {
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
bottom: overflow.bottom - rect.height + preventedOffsets.y,
|
|
4869
|
-
left: overflow.left - rect.width - preventedOffsets.x
|
|
4161
|
+
main: mainAlignmentSide,
|
|
4162
|
+
cross: getOppositePlacement(mainAlignmentSide)
|
|
4870
4163
|
};
|
|
4871
4164
|
}
|
|
4872
4165
|
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4166
|
+
const oppositeAlignmentMap = {
|
|
4167
|
+
start: 'end',
|
|
4168
|
+
end: 'start'
|
|
4169
|
+
};
|
|
4170
|
+
function getOppositeAlignmentPlacement(placement) {
|
|
4171
|
+
return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
|
|
4877
4172
|
}
|
|
4878
4173
|
|
|
4879
|
-
function
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
elementContext: 'reference'
|
|
4887
|
-
});
|
|
4888
|
-
var popperAltOverflow = detectOverflow(state, {
|
|
4889
|
-
altBoundary: true
|
|
4890
|
-
});
|
|
4891
|
-
var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
|
|
4892
|
-
var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
|
|
4893
|
-
var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
|
|
4894
|
-
var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
|
|
4895
|
-
state.modifiersData[name] = {
|
|
4896
|
-
referenceClippingOffsets: referenceClippingOffsets,
|
|
4897
|
-
popperEscapeOffsets: popperEscapeOffsets,
|
|
4898
|
-
isReferenceHidden: isReferenceHidden,
|
|
4899
|
-
hasPopperEscaped: hasPopperEscaped
|
|
4900
|
-
};
|
|
4901
|
-
state.attributes.popper = Object.assign(Object.assign({}, state.attributes.popper), {}, {
|
|
4902
|
-
'data-popper-reference-hidden': isReferenceHidden,
|
|
4903
|
-
'data-popper-escaped': hasPopperEscaped
|
|
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;
|
|
4904
4181
|
});
|
|
4905
|
-
}
|
|
4906
|
-
|
|
4182
|
+
}
|
|
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)));
|
|
4907
4220
|
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
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
|
+
}
|
|
4269
|
+
};
|
|
4914
4270
|
};
|
|
4915
4271
|
|
|
4916
|
-
function
|
|
4917
|
-
|
|
4918
|
-
|
|
4272
|
+
function getExpandedPlacements(placement) {
|
|
4273
|
+
const oppositePlacement = getOppositePlacement(placement);
|
|
4274
|
+
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
4275
|
+
}
|
|
4276
|
+
|
|
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
|
+
}
|
|
4293
|
+
}
|
|
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));
|
|
4301
|
+
}
|
|
4302
|
+
}
|
|
4303
|
+
return list;
|
|
4304
|
+
}
|
|
4919
4305
|
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
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
|
+
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
|
+
}
|
|
4405
|
+
};
|
|
4406
|
+
};
|
|
4925
4407
|
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
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
|
|
4931
4431
|
} : {
|
|
4932
|
-
|
|
4933
|
-
|
|
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;
|
|
4439
|
+
}
|
|
4440
|
+
return isVertical ? {
|
|
4441
|
+
x: crossAxis * crossAxisMulti,
|
|
4442
|
+
y: mainAxis * mainAxisMulti
|
|
4443
|
+
} : {
|
|
4444
|
+
x: mainAxis * mainAxisMulti,
|
|
4445
|
+
y: crossAxis * crossAxisMulti
|
|
4934
4446
|
};
|
|
4935
4447
|
}
|
|
4936
4448
|
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
|
|
4941
|
-
|
|
4942
|
-
|
|
4943
|
-
|
|
4944
|
-
acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
|
|
4945
|
-
return acc;
|
|
4946
|
-
}, {});
|
|
4947
|
-
var _data$state$placement = data[state.placement],
|
|
4948
|
-
x = _data$state$placement.x,
|
|
4949
|
-
y = _data$state$placement.y;
|
|
4950
|
-
|
|
4951
|
-
if (state.modifiersData.popperOffsets != null) {
|
|
4952
|
-
state.modifiersData.popperOffsets.x += x;
|
|
4953
|
-
state.modifiersData.popperOffsets.y += y;
|
|
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;
|
|
4954
4456
|
}
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
// Offsets are the actual position the popper needs to have to be
|
|
4972
|
-
// properly positioned near its reference element
|
|
4973
|
-
// This is the most basic placement, and will be adjusted by
|
|
4974
|
-
// the modifiers in the next step
|
|
4975
|
-
state.modifiersData[name] = computeOffsets({
|
|
4976
|
-
reference: state.rects.reference,
|
|
4977
|
-
element: state.rects.popper,
|
|
4978
|
-
strategy: 'absolute',
|
|
4979
|
-
placement: state.placement
|
|
4980
|
-
});
|
|
4981
|
-
} // eslint-disable-next-line import/no-unused-modules
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
var popperOffsets$1 = {
|
|
4985
|
-
name: 'popperOffsets',
|
|
4986
|
-
enabled: true,
|
|
4987
|
-
phase: 'read',
|
|
4988
|
-
fn: popperOffsets,
|
|
4989
|
-
data: {}
|
|
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
|
+
};
|
|
4990
4473
|
};
|
|
4991
4474
|
|
|
4992
|
-
function
|
|
4475
|
+
function getCrossAxis(axis) {
|
|
4993
4476
|
return axis === 'x' ? 'y' : 'x';
|
|
4994
4477
|
}
|
|
4995
4478
|
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
boundary = options.boundary,
|
|
5005
|
-
rootBoundary = options.rootBoundary,
|
|
5006
|
-
altBoundary = options.altBoundary,
|
|
5007
|
-
padding = options.padding,
|
|
5008
|
-
_options$tether = options.tether,
|
|
5009
|
-
tether = _options$tether === void 0 ? true : _options$tether,
|
|
5010
|
-
_options$tetherOffset = options.tetherOffset,
|
|
5011
|
-
tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
|
|
5012
|
-
var overflow = detectOverflow(state, {
|
|
5013
|
-
boundary: boundary,
|
|
5014
|
-
rootBoundary: rootBoundary,
|
|
5015
|
-
padding: padding,
|
|
5016
|
-
altBoundary: altBoundary
|
|
5017
|
-
});
|
|
5018
|
-
var basePlacement = getBasePlacement(state.placement);
|
|
5019
|
-
var variation = getVariation(state.placement);
|
|
5020
|
-
var isBasePlacement = !variation;
|
|
5021
|
-
var mainAxis = getMainAxisFromPlacement(basePlacement);
|
|
5022
|
-
var altAxis = getAltAxis(mainAxis);
|
|
5023
|
-
var popperOffsets = state.modifiersData.popperOffsets;
|
|
5024
|
-
var referenceRect = state.rects.reference;
|
|
5025
|
-
var popperRect = state.rects.popper;
|
|
5026
|
-
var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign(Object.assign({}, state.rects), {}, {
|
|
5027
|
-
placement: state.placement
|
|
5028
|
-
})) : tetherOffset;
|
|
5029
|
-
var data = {
|
|
5030
|
-
x: 0,
|
|
5031
|
-
y: 0
|
|
5032
|
-
};
|
|
5033
|
-
|
|
5034
|
-
if (!popperOffsets) {
|
|
5035
|
-
return;
|
|
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 = {};
|
|
5036
4487
|
}
|
|
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
|
|
4517
|
+
};
|
|
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
|
+
}
|
|
4548
|
+
};
|
|
4549
|
+
}
|
|
4550
|
+
};
|
|
4551
|
+
};
|
|
5037
4552
|
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
|
|
5048
|
-
// outside the reference bounds
|
|
5049
|
-
|
|
5050
|
-
var arrowElement = state.elements.arrow;
|
|
5051
|
-
var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
|
|
5052
|
-
width: 0,
|
|
5053
|
-
height: 0
|
|
5054
|
-
};
|
|
5055
|
-
var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject();
|
|
5056
|
-
var arrowPaddingMin = arrowPaddingObject[mainSide];
|
|
5057
|
-
var arrowPaddingMax = arrowPaddingObject[altSide]; // If the reference length is smaller than the arrow length, we don't want
|
|
5058
|
-
// to include its full size in the calculation. If the reference is small
|
|
5059
|
-
// and near the edge of a boundary, the popper can overflow even if the
|
|
5060
|
-
// reference is not overflowing as well (e.g. virtual elements with no
|
|
5061
|
-
// width or height)
|
|
5062
|
-
|
|
5063
|
-
var arrowLen = within(0, referenceRect[len], arrowRect[len]);
|
|
5064
|
-
var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - tetherOffsetValue : minLen - arrowLen - arrowPaddingMin - tetherOffsetValue;
|
|
5065
|
-
var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + tetherOffsetValue : maxLen + arrowLen + arrowPaddingMax + tetherOffsetValue;
|
|
5066
|
-
var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
|
|
5067
|
-
var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
|
|
5068
|
-
var offsetModifierValue = state.modifiersData.offset ? state.modifiersData.offset[state.placement][mainAxis] : 0;
|
|
5069
|
-
var tetherMin = popperOffsets[mainAxis] + minOffset - offsetModifierValue - clientOffset;
|
|
5070
|
-
var tetherMax = popperOffsets[mainAxis] + maxOffset - offsetModifierValue;
|
|
5071
|
-
var preventedOffset = within(tether ? Math.min(min, tetherMin) : min, offset, tether ? Math.max(max, tetherMax) : max);
|
|
5072
|
-
popperOffsets[mainAxis] = preventedOffset;
|
|
5073
|
-
data[mainAxis] = preventedOffset - offset;
|
|
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) {
|
|
4560
|
+
if (options === void 0) {
|
|
4561
|
+
options = {};
|
|
5074
4562
|
}
|
|
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
|
+
}
|
|
4611
|
+
};
|
|
4612
|
+
};
|
|
5075
4613
|
|
|
5076
|
-
|
|
5077
|
-
|
|
4614
|
+
function getWindow(node) {
|
|
4615
|
+
var _node$ownerDocument;
|
|
4616
|
+
return ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
4617
|
+
}
|
|
5078
4618
|
|
|
5079
|
-
|
|
4619
|
+
function getComputedStyle$1(element) {
|
|
4620
|
+
return getWindow(element).getComputedStyle(element);
|
|
4621
|
+
}
|
|
5080
4622
|
|
|
5081
|
-
|
|
4623
|
+
function getNodeName(node) {
|
|
4624
|
+
return isNode(node) ? (node.nodeName || '').toLowerCase() : '';
|
|
4625
|
+
}
|
|
5082
4626
|
|
|
5083
|
-
|
|
4627
|
+
let uaString;
|
|
4628
|
+
function getUAString() {
|
|
4629
|
+
if (uaString) {
|
|
4630
|
+
return uaString;
|
|
4631
|
+
}
|
|
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;
|
|
4636
|
+
}
|
|
4637
|
+
return navigator.userAgent;
|
|
4638
|
+
}
|
|
5084
4639
|
|
|
5085
|
-
|
|
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;
|
|
4653
|
+
}
|
|
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
|
+
}
|
|
5086
4694
|
|
|
5087
|
-
|
|
4695
|
+
function isLastTraversableNode(node) {
|
|
4696
|
+
return ['html', 'body', '#document'].includes(getNodeName(node));
|
|
4697
|
+
}
|
|
5088
4698
|
|
|
5089
|
-
|
|
5090
|
-
|
|
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;
|
|
5091
4713
|
}
|
|
4714
|
+
return {
|
|
4715
|
+
width,
|
|
4716
|
+
height,
|
|
4717
|
+
fallback: shouldFallback
|
|
4718
|
+
};
|
|
4719
|
+
}
|
|
5092
4720
|
|
|
5093
|
-
|
|
5094
|
-
|
|
5095
|
-
|
|
4721
|
+
function unwrapElement(element) {
|
|
4722
|
+
return !isElement$1(element) ? element.contextElement : element;
|
|
4723
|
+
}
|
|
5096
4724
|
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
phase: 'main',
|
|
5101
|
-
fn: preventOverflow,
|
|
5102
|
-
requiresIfExists: ['offset']
|
|
4725
|
+
const FALLBACK_SCALE = {
|
|
4726
|
+
x: 1,
|
|
4727
|
+
y: 1
|
|
5103
4728
|
};
|
|
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;
|
|
5104
4742
|
|
|
5105
|
-
|
|
4743
|
+
// 0, NaN, or Infinity should always fallback to 1.
|
|
4744
|
+
|
|
4745
|
+
if (!x || !Number.isFinite(x)) {
|
|
4746
|
+
x = 1;
|
|
4747
|
+
}
|
|
4748
|
+
if (!y || !Number.isFinite(y)) {
|
|
4749
|
+
y = 1;
|
|
4750
|
+
}
|
|
5106
4751
|
return {
|
|
5107
|
-
|
|
5108
|
-
|
|
4752
|
+
x,
|
|
4753
|
+
y
|
|
5109
4754
|
};
|
|
5110
4755
|
}
|
|
5111
4756
|
|
|
5112
|
-
function
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
return getHTMLElementScroll(node);
|
|
4757
|
+
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
|
4758
|
+
var _win$visualViewport, _win$visualViewport2;
|
|
4759
|
+
if (includeScale === void 0) {
|
|
4760
|
+
includeScale = false;
|
|
5117
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
|
+
}
|
|
4801
|
+
}
|
|
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
|
+
};
|
|
5118
4812
|
}
|
|
5119
4813
|
|
|
5120
|
-
|
|
4814
|
+
function getDocumentElement(node) {
|
|
4815
|
+
return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
|
|
4816
|
+
}
|
|
5121
4817
|
|
|
5122
|
-
function
|
|
5123
|
-
if (
|
|
5124
|
-
|
|
4818
|
+
function getNodeScroll(element) {
|
|
4819
|
+
if (isElement$1(element)) {
|
|
4820
|
+
return {
|
|
4821
|
+
scrollLeft: element.scrollLeft,
|
|
4822
|
+
scrollTop: element.scrollTop
|
|
4823
|
+
};
|
|
5125
4824
|
}
|
|
4825
|
+
return {
|
|
4826
|
+
scrollLeft: element.pageXOffset,
|
|
4827
|
+
scrollTop: element.pageYOffset
|
|
4828
|
+
};
|
|
4829
|
+
}
|
|
4830
|
+
|
|
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;
|
|
4835
|
+
}
|
|
5126
4836
|
|
|
5127
|
-
|
|
5128
|
-
|
|
5129
|
-
|
|
5130
|
-
|
|
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 = {
|
|
5131
4842
|
scrollLeft: 0,
|
|
5132
4843
|
scrollTop: 0
|
|
5133
4844
|
};
|
|
5134
|
-
|
|
4845
|
+
const offsets = {
|
|
5135
4846
|
x: 0,
|
|
5136
4847
|
y: 0
|
|
5137
4848
|
};
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078
|
|
5141
|
-
isScrollParent(documentElement)) {
|
|
4849
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
|
|
4850
|
+
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
5142
4851
|
scroll = getNodeScroll(offsetParent);
|
|
5143
4852
|
}
|
|
5144
|
-
|
|
5145
4853
|
if (isHTMLElement(offsetParent)) {
|
|
5146
|
-
|
|
5147
|
-
offsets.x
|
|
5148
|
-
offsets.y
|
|
4854
|
+
const offsetRect = getBoundingClientRect(offsetParent, true);
|
|
4855
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
4856
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
5149
4857
|
} else if (documentElement) {
|
|
5150
4858
|
offsets.x = getWindowScrollBarX(documentElement);
|
|
5151
4859
|
}
|
|
5152
4860
|
}
|
|
5153
|
-
|
|
5154
4861
|
return {
|
|
5155
4862
|
x: rect.left + scroll.scrollLeft - offsets.x,
|
|
5156
4863
|
y: rect.top + scroll.scrollTop - offsets.y,
|
|
@@ -5159,696 +4866,553 @@ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
|
|
|
5159
4866
|
};
|
|
5160
4867
|
}
|
|
5161
4868
|
|
|
5162
|
-
function
|
|
5163
|
-
|
|
5164
|
-
|
|
5165
|
-
var result = [];
|
|
5166
|
-
modifiers.forEach(function (modifier) {
|
|
5167
|
-
map.set(modifier.name, modifier);
|
|
5168
|
-
}); // On visiting object, check for its dependencies and visit them recursively
|
|
5169
|
-
|
|
5170
|
-
function sort(modifier) {
|
|
5171
|
-
visited.add(modifier.name);
|
|
5172
|
-
var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
|
|
5173
|
-
requires.forEach(function (dep) {
|
|
5174
|
-
if (!visited.has(dep)) {
|
|
5175
|
-
var depModifier = map.get(dep);
|
|
5176
|
-
|
|
5177
|
-
if (depModifier) {
|
|
5178
|
-
sort(depModifier);
|
|
5179
|
-
}
|
|
5180
|
-
}
|
|
5181
|
-
});
|
|
5182
|
-
result.push(modifier);
|
|
4869
|
+
function getParentNode(node) {
|
|
4870
|
+
if (getNodeName(node) === 'html') {
|
|
4871
|
+
return node;
|
|
5183
4872
|
}
|
|
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
|
+
}
|
|
5184
4884
|
|
|
5185
|
-
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
|
|
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);
|
|
5189
4898
|
}
|
|
5190
|
-
}
|
|
5191
|
-
return
|
|
4899
|
+
}
|
|
4900
|
+
return null;
|
|
5192
4901
|
}
|
|
5193
4902
|
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
|
|
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
|
+
}
|
|
5197
4916
|
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
return modifier.phase === phase;
|
|
5201
|
-
}));
|
|
5202
|
-
}, []);
|
|
4917
|
+
function getDimensions(element) {
|
|
4918
|
+
return getCssDimensions(element);
|
|
5203
4919
|
}
|
|
5204
4920
|
|
|
5205
|
-
function
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
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);
|
|
5215
4947
|
}
|
|
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
|
+
}
|
|
5216
4959
|
|
|
5217
|
-
|
|
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
|
|
5218
4965
|
};
|
|
5219
4966
|
}
|
|
5220
4967
|
|
|
5221
|
-
function
|
|
5222
|
-
|
|
5223
|
-
|
|
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
|
+
}
|
|
5224
4984
|
}
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
4985
|
+
return {
|
|
4986
|
+
width,
|
|
4987
|
+
height,
|
|
4988
|
+
x,
|
|
4989
|
+
y
|
|
4990
|
+
};
|
|
5229
4991
|
}
|
|
5230
4992
|
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
if (modifierPhases.indexOf(modifier.phase) < 0) {
|
|
5252
|
-
console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"phase"', "either " + modifierPhases.join(', '), "\"" + String(modifier.phase) + "\""));
|
|
5253
|
-
}
|
|
5254
|
-
|
|
5255
|
-
break;
|
|
5256
|
-
|
|
5257
|
-
case 'fn':
|
|
5258
|
-
if (typeof modifier.fn !== 'function') {
|
|
5259
|
-
console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"fn"', '"function"', "\"" + String(modifier.fn) + "\""));
|
|
5260
|
-
}
|
|
5261
|
-
|
|
5262
|
-
break;
|
|
5263
|
-
|
|
5264
|
-
case 'effect':
|
|
5265
|
-
if (typeof modifier.effect !== 'function') {
|
|
5266
|
-
console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"effect"', '"function"', "\"" + String(modifier.fn) + "\""));
|
|
5267
|
-
}
|
|
5268
|
-
|
|
5269
|
-
break;
|
|
5270
|
-
|
|
5271
|
-
case 'requires':
|
|
5272
|
-
if (!Array.isArray(modifier.requires)) {
|
|
5273
|
-
console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requires"', '"array"', "\"" + String(modifier.requires) + "\""));
|
|
5274
|
-
}
|
|
5275
|
-
|
|
5276
|
-
break;
|
|
5277
|
-
|
|
5278
|
-
case 'requiresIfExists':
|
|
5279
|
-
if (!Array.isArray(modifier.requiresIfExists)) {
|
|
5280
|
-
console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requiresIfExists"', '"array"', "\"" + String(modifier.requiresIfExists) + "\""));
|
|
5281
|
-
}
|
|
5282
|
-
|
|
5283
|
-
break;
|
|
5284
|
-
|
|
5285
|
-
case 'options':
|
|
5286
|
-
case 'data':
|
|
5287
|
-
break;
|
|
5288
|
-
|
|
5289
|
-
default:
|
|
5290
|
-
console.error("PopperJS: an invalid property has been provided to the \"" + modifier.name + "\" modifier, valid properties are " + VALID_PROPERTIES.map(function (s) {
|
|
5291
|
-
return "\"" + s + "\"";
|
|
5292
|
-
}).join(', ') + "; but \"" + key + "\" was provided.");
|
|
5293
|
-
}
|
|
5294
|
-
|
|
5295
|
-
modifier.requires && modifier.requires.forEach(function (requirement) {
|
|
5296
|
-
if (modifiers.find(function (mod) {
|
|
5297
|
-
return mod.name === requirement;
|
|
5298
|
-
}) == null) {
|
|
5299
|
-
console.error(format(MISSING_DEPENDENCY_ERROR, String(modifier.name), requirement, requirement));
|
|
5300
|
-
}
|
|
5301
|
-
});
|
|
5302
|
-
});
|
|
5303
|
-
});
|
|
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
|
+
};
|
|
5304
5013
|
}
|
|
5305
5014
|
|
|
5306
|
-
function
|
|
5307
|
-
|
|
5308
|
-
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
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);
|
|
5316
5025
|
}
|
|
5317
5026
|
|
|
5318
|
-
function
|
|
5319
|
-
var
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
});
|
|
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));
|
|
5331
5039
|
}
|
|
5332
5040
|
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
|
|
5343
|
-
|
|
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
|
+
};
|
|
5064
|
+
}
|
|
5065
|
+
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
|
|
5066
|
+
if (clippingAncestor === 'viewport') {
|
|
5067
|
+
return rectToClientRect(getViewportRect(element, strategy));
|
|
5344
5068
|
}
|
|
5345
|
-
|
|
5346
|
-
|
|
5347
|
-
|
|
5348
|
-
|
|
5069
|
+
if (isElement$1(clippingAncestor)) {
|
|
5070
|
+
return getInnerBoundingClientRect(clippingAncestor, strategy);
|
|
5071
|
+
}
|
|
5072
|
+
return rectToClientRect(getDocumentRect(getDocumentElement(element)));
|
|
5349
5073
|
}
|
|
5350
5074
|
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
|
|
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;
|
|
5354
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);
|
|
5101
|
+
}
|
|
5102
|
+
cache.set(element, result);
|
|
5103
|
+
return result;
|
|
5104
|
+
}
|
|
5355
5105
|
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
|
|
5362
|
-
|
|
5363
|
-
|
|
5364
|
-
|
|
5365
|
-
|
|
5366
|
-
|
|
5367
|
-
|
|
5368
|
-
|
|
5369
|
-
|
|
5370
|
-
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
|
|
5375
|
-
|
|
5376
|
-
|
|
5377
|
-
|
|
5378
|
-
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
cleanupModifierEffects();
|
|
5384
|
-
state.options = Object.assign(Object.assign(Object.assign({}, defaultOptions), state.options), options);
|
|
5385
|
-
state.scrollParents = {
|
|
5386
|
-
reference: isElement$1(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
|
|
5387
|
-
popper: listScrollParents(popper)
|
|
5388
|
-
}; // Orders the modifiers based on their dependencies and `phase`
|
|
5389
|
-
// properties
|
|
5390
|
-
|
|
5391
|
-
var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers
|
|
5392
|
-
|
|
5393
|
-
state.orderedModifiers = orderedModifiers.filter(function (m) {
|
|
5394
|
-
return m.enabled;
|
|
5395
|
-
}); // Validate the provided modifiers so that the consumer will get warned
|
|
5396
|
-
// if one of the modifiers is invalid for any reason
|
|
5397
|
-
|
|
5398
|
-
if (process.env.NODE_ENV !== "production") {
|
|
5399
|
-
var modifiers = uniqueBy([].concat(orderedModifiers, state.options.modifiers), function (_ref) {
|
|
5400
|
-
var name = _ref.name;
|
|
5401
|
-
return name;
|
|
5402
|
-
});
|
|
5403
|
-
validateModifiers(modifiers);
|
|
5404
|
-
|
|
5405
|
-
if (getBasePlacement(state.options.placement) === auto) {
|
|
5406
|
-
var flipModifier = state.orderedModifiers.find(function (_ref2) {
|
|
5407
|
-
var name = _ref2.name;
|
|
5408
|
-
return name === 'flip';
|
|
5409
|
-
});
|
|
5410
|
-
|
|
5411
|
-
if (!flipModifier) {
|
|
5412
|
-
console.error(['Popper: "auto" placements require the "flip" modifier be', 'present and enabled to work.'].join(' '));
|
|
5413
|
-
}
|
|
5414
|
-
}
|
|
5415
|
-
|
|
5416
|
-
var _getComputedStyle = getComputedStyle(popper),
|
|
5417
|
-
marginTop = _getComputedStyle.marginTop,
|
|
5418
|
-
marginRight = _getComputedStyle.marginRight,
|
|
5419
|
-
marginBottom = _getComputedStyle.marginBottom,
|
|
5420
|
-
marginLeft = _getComputedStyle.marginLeft; // We no longer take into account `margins` on the popper, and it can
|
|
5421
|
-
// cause bugs with positioning, so we'll warn the consumer
|
|
5422
|
-
|
|
5423
|
-
|
|
5424
|
-
if ([marginTop, marginRight, marginBottom, marginLeft].some(function (margin) {
|
|
5425
|
-
return parseFloat(margin);
|
|
5426
|
-
})) {
|
|
5427
|
-
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(' '));
|
|
5428
|
-
}
|
|
5429
|
-
}
|
|
5430
|
-
|
|
5431
|
-
runModifierEffects();
|
|
5432
|
-
return instance.update();
|
|
5433
|
-
},
|
|
5434
|
-
// Sync update – it will always be executed, even if not necessary. This
|
|
5435
|
-
// is useful for low frequency updates where sync behavior simplifies the
|
|
5436
|
-
// logic.
|
|
5437
|
-
// For high frequency updates (e.g. `resize` and `scroll` events), always
|
|
5438
|
-
// prefer the async Popper#update method
|
|
5439
|
-
forceUpdate: function forceUpdate() {
|
|
5440
|
-
if (isDestroyed) {
|
|
5441
|
-
return;
|
|
5442
|
-
}
|
|
5443
|
-
|
|
5444
|
-
var _state$elements = state.elements,
|
|
5445
|
-
reference = _state$elements.reference,
|
|
5446
|
-
popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements
|
|
5447
|
-
// anymore
|
|
5448
|
-
|
|
5449
|
-
if (!areValidElements(reference, popper)) {
|
|
5450
|
-
if (process.env.NODE_ENV !== "production") {
|
|
5451
|
-
console.error(INVALID_ELEMENT_ERROR);
|
|
5452
|
-
}
|
|
5453
|
-
|
|
5454
|
-
return;
|
|
5455
|
-
} // Store the reference and popper rects to be read by modifiers
|
|
5456
|
-
|
|
5457
|
-
|
|
5458
|
-
state.rects = {
|
|
5459
|
-
reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),
|
|
5460
|
-
popper: getLayoutRect(popper)
|
|
5461
|
-
}; // Modifiers have the ability to reset the current update cycle. The
|
|
5462
|
-
// most common use case for this is the `flip` modifier changing the
|
|
5463
|
-
// placement, which then needs to re-run all the modifiers, because the
|
|
5464
|
-
// logic was previously ran for the previous placement and is therefore
|
|
5465
|
-
// stale/incorrect
|
|
5466
|
-
|
|
5467
|
-
state.reset = false;
|
|
5468
|
-
state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier
|
|
5469
|
-
// is filled with the initial data specified by the modifier. This means
|
|
5470
|
-
// it doesn't persist and is fresh on each update.
|
|
5471
|
-
// To ensure persistent data, use `${name}#persistent`
|
|
5472
|
-
|
|
5473
|
-
state.orderedModifiers.forEach(function (modifier) {
|
|
5474
|
-
return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
|
|
5475
|
-
});
|
|
5476
|
-
var __debug_loops__ = 0;
|
|
5477
|
-
|
|
5478
|
-
for (var index = 0; index < state.orderedModifiers.length; index++) {
|
|
5479
|
-
if (process.env.NODE_ENV !== "production") {
|
|
5480
|
-
__debug_loops__ += 1;
|
|
5481
|
-
|
|
5482
|
-
if (__debug_loops__ > 100) {
|
|
5483
|
-
console.error(INFINITE_LOOP_ERROR);
|
|
5484
|
-
break;
|
|
5485
|
-
}
|
|
5486
|
-
}
|
|
5487
|
-
|
|
5488
|
-
if (state.reset === true) {
|
|
5489
|
-
state.reset = false;
|
|
5490
|
-
index = -1;
|
|
5491
|
-
continue;
|
|
5492
|
-
}
|
|
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
|
+
}
|
|
5493
5133
|
|
|
5494
|
-
|
|
5495
|
-
|
|
5496
|
-
|
|
5497
|
-
|
|
5498
|
-
|
|
5499
|
-
|
|
5500
|
-
|
|
5501
|
-
|
|
5502
|
-
|
|
5503
|
-
|
|
5504
|
-
|
|
5505
|
-
|
|
5506
|
-
|
|
5507
|
-
|
|
5508
|
-
|
|
5509
|
-
|
|
5510
|
-
|
|
5511
|
-
|
|
5512
|
-
|
|
5513
|
-
|
|
5514
|
-
|
|
5515
|
-
|
|
5516
|
-
});
|
|
5517
|
-
}),
|
|
5518
|
-
destroy: function destroy() {
|
|
5519
|
-
cleanupModifierEffects();
|
|
5520
|
-
isDestroyed = true;
|
|
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))
|
|
5521
5156
|
}
|
|
5522
5157
|
};
|
|
5158
|
+
},
|
|
5159
|
+
getClientRects: element => Array.from(element.getClientRects()),
|
|
5160
|
+
isRTL: element => getComputedStyle$1(element).direction === 'rtl'
|
|
5161
|
+
};
|
|
5523
5162
|
|
|
5524
|
-
|
|
5525
|
-
|
|
5526
|
-
|
|
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();
|
|
5527
5191
|
}
|
|
5528
|
-
|
|
5529
|
-
|
|
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);
|
|
5530
5197
|
}
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
function runModifierEffects() {
|
|
5543
|
-
state.orderedModifiers.forEach(function (_ref3) {
|
|
5544
|
-
var name = _ref3.name,
|
|
5545
|
-
_ref3$options = _ref3.options,
|
|
5546
|
-
options = _ref3$options === void 0 ? {} : _ref3$options,
|
|
5547
|
-
effect = _ref3.effect;
|
|
5548
|
-
|
|
5549
|
-
if (typeof effect === 'function') {
|
|
5550
|
-
var cleanupFn = effect({
|
|
5551
|
-
state: state,
|
|
5552
|
-
name: name,
|
|
5553
|
-
instance: instance,
|
|
5554
|
-
options: options
|
|
5555
|
-
});
|
|
5556
|
-
|
|
5557
|
-
var noopFn = function noopFn() {};
|
|
5558
|
-
|
|
5559
|
-
effectCleanupFns.push(cleanupFn || noopFn);
|
|
5560
|
-
}
|
|
5561
|
-
});
|
|
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();
|
|
5562
5209
|
}
|
|
5563
|
-
|
|
5564
|
-
|
|
5565
|
-
|
|
5566
|
-
|
|
5567
|
-
|
|
5568
|
-
|
|
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);
|
|
5569
5224
|
}
|
|
5570
|
-
|
|
5571
|
-
return instance;
|
|
5572
5225
|
};
|
|
5573
5226
|
}
|
|
5574
5227
|
|
|
5575
|
-
var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
|
|
5576
|
-
var createPopper = /*#__PURE__*/popperGenerator({
|
|
5577
|
-
defaultModifiers: defaultModifiers
|
|
5578
|
-
}); // eslint-disable-next-line import/no-unused-modules
|
|
5579
|
-
|
|
5580
5228
|
/**
|
|
5581
|
-
*
|
|
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.
|
|
5582
5232
|
*/
|
|
5583
|
-
|
|
5584
|
-
|
|
5585
|
-
|
|
5586
|
-
|
|
5587
|
-
|
|
5588
|
-
|
|
5589
|
-
|
|
5590
|
-
|
|
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
|
+
});
|
|
5591
5250
|
};
|
|
5592
|
-
/**
|
|
5593
|
-
* Small wrapper around `useLayoutEffect` to get rid of the warning on SSR envs
|
|
5594
|
-
*/
|
|
5595
|
-
|
|
5596
|
-
var useIsomorphicLayoutEffect = typeof window !== 'undefined' && window.document && window.document.createElement ? useLayoutEffect : useEffect;
|
|
5597
|
-
|
|
5598
|
-
/* global Map:readonly, Set:readonly, ArrayBuffer:readonly */
|
|
5599
5251
|
|
|
5600
|
-
var
|
|
5601
|
-
var hasMap = typeof Map === 'function';
|
|
5602
|
-
var hasSet = typeof Set === 'function';
|
|
5603
|
-
var hasArrayBuffer = typeof ArrayBuffer === 'function' && !!ArrayBuffer.isView;
|
|
5252
|
+
var index = typeof document !== 'undefined' ? useLayoutEffect : useEffect;
|
|
5604
5253
|
|
|
5605
|
-
//
|
|
5606
|
-
|
|
5607
|
-
function
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
|
|
5611
|
-
if (
|
|
5612
|
-
|
|
5613
|
-
|
|
5614
|
-
|
|
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') {
|
|
5615
5268
|
if (Array.isArray(a)) {
|
|
5616
5269
|
length = a.length;
|
|
5617
5270
|
if (length != b.length) return false;
|
|
5618
|
-
for (i = length; i-- !== 0;)
|
|
5619
|
-
if (!
|
|
5620
|
-
|
|
5621
|
-
|
|
5622
|
-
|
|
5623
|
-
// START: Modifications:
|
|
5624
|
-
// 1. Extra `has<Type> &&` helpers in initial condition allow es6 code
|
|
5625
|
-
// to co-exist with es5.
|
|
5626
|
-
// 2. Replace `for of` with es5 compliant iteration using `for`.
|
|
5627
|
-
// Basically, take:
|
|
5628
|
-
//
|
|
5629
|
-
// ```js
|
|
5630
|
-
// for (i of a.entries())
|
|
5631
|
-
// if (!b.has(i[0])) return false;
|
|
5632
|
-
// ```
|
|
5633
|
-
//
|
|
5634
|
-
// ... and convert to:
|
|
5635
|
-
//
|
|
5636
|
-
// ```js
|
|
5637
|
-
// it = a.entries();
|
|
5638
|
-
// while (!(i = it.next()).done)
|
|
5639
|
-
// if (!b.has(i.value[0])) return false;
|
|
5640
|
-
// ```
|
|
5641
|
-
//
|
|
5642
|
-
// **Note**: `i` access switches to `i.value`.
|
|
5643
|
-
var it;
|
|
5644
|
-
if (hasMap && (a instanceof Map) && (b instanceof Map)) {
|
|
5645
|
-
if (a.size !== b.size) return false;
|
|
5646
|
-
it = a.entries();
|
|
5647
|
-
while (!(i = it.next()).done)
|
|
5648
|
-
if (!b.has(i.value[0])) return false;
|
|
5649
|
-
it = a.entries();
|
|
5650
|
-
while (!(i = it.next()).done)
|
|
5651
|
-
if (!equal(i.value[1], b.get(i.value[0]))) return false;
|
|
5652
|
-
return true;
|
|
5653
|
-
}
|
|
5654
|
-
|
|
5655
|
-
if (hasSet && (a instanceof Set) && (b instanceof Set)) {
|
|
5656
|
-
if (a.size !== b.size) return false;
|
|
5657
|
-
it = a.entries();
|
|
5658
|
-
while (!(i = it.next()).done)
|
|
5659
|
-
if (!b.has(i.value[0])) return false;
|
|
5660
|
-
return true;
|
|
5661
|
-
}
|
|
5662
|
-
// END: Modifications
|
|
5663
|
-
|
|
5664
|
-
if (hasArrayBuffer && ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {
|
|
5665
|
-
length = a.length;
|
|
5666
|
-
if (length != b.length) return false;
|
|
5667
|
-
for (i = length; i-- !== 0;)
|
|
5668
|
-
if (a[i] !== b[i]) return false;
|
|
5271
|
+
for (i = length; i-- !== 0;) {
|
|
5272
|
+
if (!deepEqual(a[i], b[i])) {
|
|
5273
|
+
return false;
|
|
5274
|
+
}
|
|
5275
|
+
}
|
|
5669
5276
|
return true;
|
|
5670
5277
|
}
|
|
5671
|
-
|
|
5672
|
-
if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
|
|
5673
|
-
if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
|
|
5674
|
-
if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
|
|
5675
|
-
|
|
5676
5278
|
keys = Object.keys(a);
|
|
5677
|
-
length = keys.length;
|
|
5678
|
-
if (length !== Object.keys(b).length)
|
|
5679
|
-
|
|
5680
|
-
|
|
5681
|
-
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
|
|
5682
|
-
// END: fast-deep-equal
|
|
5683
|
-
|
|
5684
|
-
// START: react-fast-compare
|
|
5685
|
-
// custom handling for DOM elements
|
|
5686
|
-
if (hasElementType && a instanceof Element) return false;
|
|
5687
|
-
|
|
5688
|
-
// custom handling for React/Preact
|
|
5279
|
+
length = keys.length;
|
|
5280
|
+
if (length !== Object.keys(b).length) {
|
|
5281
|
+
return false;
|
|
5282
|
+
}
|
|
5689
5283
|
for (i = length; i-- !== 0;) {
|
|
5690
|
-
if ((
|
|
5691
|
-
|
|
5692
|
-
|
|
5693
|
-
|
|
5694
|
-
|
|
5695
|
-
|
|
5696
|
-
|
|
5697
|
-
// .$$typeof and ._store on just reasonable markers of elements
|
|
5698
|
-
|
|
5284
|
+
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) {
|
|
5285
|
+
return false;
|
|
5286
|
+
}
|
|
5287
|
+
}
|
|
5288
|
+
for (i = length; i-- !== 0;) {
|
|
5289
|
+
const key = keys[i];
|
|
5290
|
+
if (key === '_owner' && a.$$typeof) {
|
|
5699
5291
|
continue;
|
|
5700
5292
|
}
|
|
5701
|
-
|
|
5702
|
-
|
|
5703
|
-
|
|
5293
|
+
if (!deepEqual(a[key], b[key])) {
|
|
5294
|
+
return false;
|
|
5295
|
+
}
|
|
5704
5296
|
}
|
|
5705
|
-
// END: react-fast-compare
|
|
5706
|
-
|
|
5707
|
-
// START: fast-deep-equal
|
|
5708
5297
|
return true;
|
|
5709
5298
|
}
|
|
5710
|
-
|
|
5711
5299
|
return a !== a && b !== b;
|
|
5712
5300
|
}
|
|
5713
|
-
// end fast-deep-equal
|
|
5714
5301
|
|
|
5715
|
-
|
|
5716
|
-
|
|
5717
|
-
|
|
5718
|
-
|
|
5719
|
-
|
|
5720
|
-
|
|
5721
|
-
|
|
5722
|
-
// chrome/safari: "RangeError", "Maximum call stack size exceeded"
|
|
5723
|
-
// firefox: "InternalError", too much recursion"
|
|
5724
|
-
// edge: "Error", "Out of stack space"
|
|
5725
|
-
console.warn('react-fast-compare cannot handle circular refs');
|
|
5726
|
-
return false;
|
|
5727
|
-
}
|
|
5728
|
-
// some other error. we should definitely know about these
|
|
5729
|
-
throw error;
|
|
5730
|
-
}
|
|
5731
|
-
};
|
|
5302
|
+
function useLatestRef(value) {
|
|
5303
|
+
const ref = useRef(value);
|
|
5304
|
+
index(() => {
|
|
5305
|
+
ref.current = value;
|
|
5306
|
+
});
|
|
5307
|
+
return ref;
|
|
5308
|
+
}
|
|
5732
5309
|
|
|
5733
|
-
|
|
5734
|
-
var usePopper = function usePopper(referenceElement, popperElement, options) {
|
|
5310
|
+
function useFloating(options) {
|
|
5735
5311
|
if (options === void 0) {
|
|
5736
5312
|
options = {};
|
|
5737
5313
|
}
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
|
|
5747
|
-
|
|
5748
|
-
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
|
|
5752
|
-
|
|
5753
|
-
|
|
5754
|
-
|
|
5755
|
-
|
|
5756
|
-
}
|
|
5757
|
-
|
|
5758
|
-
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
setState({
|
|
5769
|
-
styles: fromEntries(elements.map(function (element) {
|
|
5770
|
-
return [element, state.styles[element] || {}];
|
|
5771
|
-
})),
|
|
5772
|
-
attributes: fromEntries(elements.map(function (element) {
|
|
5773
|
-
return [element, state.attributes[element]];
|
|
5774
|
-
}))
|
|
5775
|
-
});
|
|
5776
|
-
},
|
|
5777
|
-
requires: ['computeStyles']
|
|
5778
|
-
};
|
|
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
|
+
}
|
|
5779
5344
|
}, []);
|
|
5780
|
-
|
|
5781
|
-
|
|
5782
|
-
|
|
5783
|
-
|
|
5784
|
-
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
}])
|
|
5789
|
-
};
|
|
5790
|
-
|
|
5791
|
-
if (reactFastCompare(prevOptions.current, newOptions)) {
|
|
5792
|
-
return prevOptions.current || newOptions;
|
|
5793
|
-
} else {
|
|
5794
|
-
prevOptions.current = newOptions;
|
|
5795
|
-
return newOptions;
|
|
5796
|
-
}
|
|
5797
|
-
}, [optionsWithDefaults.onFirstUpdate, optionsWithDefaults.placement, optionsWithDefaults.strategy, optionsWithDefaults.modifiers, updateStateModifier]);
|
|
5798
|
-
var popperInstanceRef = useRef();
|
|
5799
|
-
useIsomorphicLayoutEffect(function () {
|
|
5800
|
-
if (popperInstanceRef.current) {
|
|
5801
|
-
popperInstanceRef.current.setOptions(popperOptions);
|
|
5802
|
-
}
|
|
5803
|
-
}, [popperOptions]);
|
|
5804
|
-
useIsomorphicLayoutEffect(function () {
|
|
5805
|
-
if (referenceElement == null || popperElement == null) {
|
|
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) {
|
|
5806
5353
|
return;
|
|
5807
5354
|
}
|
|
5808
|
-
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
|
|
5815
|
-
|
|
5816
|
-
|
|
5817
|
-
|
|
5818
|
-
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
|
|
5822
|
-
|
|
5823
|
-
|
|
5824
|
-
};
|
|
5825
|
-
|
|
5826
|
-
|
|
5827
|
-
|
|
5828
|
-
|
|
5829
|
-
|
|
5830
|
-
|
|
5831
|
-
|
|
5832
|
-
let {
|
|
5833
|
-
element,
|
|
5834
|
-
onFocusIn,
|
|
5835
|
-
onFocusOut
|
|
5836
|
-
} = _ref;
|
|
5837
|
-
useEffect(() => {
|
|
5838
|
-
if (element) {
|
|
5839
|
-
element.addEventListener('focusin', onFocusIn);
|
|
5840
|
-
element.addEventListener('focusout', onFocusOut);
|
|
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
|
+
});
|
|
5369
|
+
}
|
|
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
|
+
}));
|
|
5841
5379
|
}
|
|
5380
|
+
}, [open]);
|
|
5381
|
+
const isMountedRef = useRef(false);
|
|
5382
|
+
index(() => {
|
|
5383
|
+
isMountedRef.current = true;
|
|
5842
5384
|
return () => {
|
|
5843
|
-
|
|
5844
|
-
element.removeEventListener('focusin', onFocusIn);
|
|
5845
|
-
element.removeEventListener('focusout', onFocusOut);
|
|
5846
|
-
}
|
|
5385
|
+
isMountedRef.current = false;
|
|
5847
5386
|
};
|
|
5848
|
-
}, [
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
|
|
5387
|
+
}, []);
|
|
5388
|
+
index(() => {
|
|
5389
|
+
if (reference && floating) {
|
|
5390
|
+
if (whileElementsMountedRef.current) {
|
|
5391
|
+
return whileElementsMountedRef.current(reference, floating, update);
|
|
5392
|
+
} else {
|
|
5393
|
+
update();
|
|
5394
|
+
}
|
|
5395
|
+
}
|
|
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
|
+
}
|
|
5852
5416
|
|
|
5853
5417
|
/**
|
|
5854
5418
|
* Different possible placements for the popover.
|
|
@@ -5871,110 +5435,212 @@ const Placement = {
|
|
|
5871
5435
|
LEFT_START: 'left-start'
|
|
5872
5436
|
};
|
|
5873
5437
|
/**
|
|
5874
|
-
*
|
|
5438
|
+
* Popover fit anchor width options.
|
|
5875
5439
|
*/
|
|
5876
|
-
const
|
|
5877
|
-
const AnchorWidthOptions = {
|
|
5440
|
+
const FitAnchorWidth = {
|
|
5878
5441
|
MAX_WIDTH: 'maxWidth',
|
|
5879
5442
|
MIN_WIDTH: 'minWidth',
|
|
5880
5443
|
WIDTH: 'width'
|
|
5881
5444
|
};
|
|
5882
5445
|
/**
|
|
5883
|
-
*
|
|
5446
|
+
* Arrow padding size (in pixel).
|
|
5884
5447
|
*/
|
|
5885
|
-
const
|
|
5448
|
+
const ARROW_PADDING_SIZE = 8;
|
|
5886
5449
|
|
|
5887
5450
|
/**
|
|
5888
|
-
*
|
|
5451
|
+
* Add offset to the popover
|
|
5889
5452
|
*/
|
|
5890
|
-
const
|
|
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
|
+
});
|
|
5891
5465
|
|
|
5892
5466
|
/**
|
|
5893
|
-
*
|
|
5467
|
+
* Place arrow between popover and anchor.
|
|
5894
5468
|
*/
|
|
5895
|
-
const
|
|
5896
|
-
|
|
5897
|
-
|
|
5898
|
-
|
|
5899
|
-
|
|
5900
|
-
|
|
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
|
+
});
|
|
5901
5478
|
|
|
5902
5479
|
/**
|
|
5903
|
-
*
|
|
5480
|
+
* Add style to fit popover width to anchor width.
|
|
5904
5481
|
*/
|
|
5905
|
-
const
|
|
5906
|
-
|
|
5907
|
-
|
|
5908
|
-
phase: 'beforeWrite',
|
|
5909
|
-
requires: ['computeStyles'],
|
|
5910
|
-
fn(_ref) {
|
|
5911
|
-
let {
|
|
5912
|
-
state
|
|
5913
|
-
} = _ref;
|
|
5914
|
-
// eslint-disable-next-line no-param-reassign
|
|
5915
|
-
state.styles.popper[anchorWidthOption] = `${state.rects.reference.width}px`;
|
|
5916
|
-
},
|
|
5917
|
-
effect(_ref2) {
|
|
5918
|
-
let {
|
|
5919
|
-
state
|
|
5920
|
-
} = _ref2;
|
|
5921
|
-
// eslint-disable-next-line no-param-reassign
|
|
5922
|
-
state.elements.popper.style[anchorWidthOption] = `${state.elements.reference.offsetWidth}px`;
|
|
5482
|
+
const configFitToAnchorWidth = memoize(fitToAnchorWidth => {
|
|
5483
|
+
if (!fitToAnchorWidth) {
|
|
5484
|
+
return undefined;
|
|
5923
5485
|
}
|
|
5924
|
-
|
|
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
|
+
});
|
|
5925
5499
|
|
|
5926
5500
|
/**
|
|
5927
|
-
*
|
|
5501
|
+
* Add max-height style to make popover fit within viewport
|
|
5928
5502
|
*/
|
|
5929
|
-
const
|
|
5930
|
-
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
requiresIfExists: ['offset', 'preventOverflow', 'flip'],
|
|
5934
|
-
fn(_ref3) {
|
|
5935
|
-
let {
|
|
5936
|
-
state,
|
|
5937
|
-
name,
|
|
5938
|
-
options
|
|
5939
|
-
} = _ref3;
|
|
5940
|
-
const overflow = detectOverflow(state, options);
|
|
5941
|
-
const {
|
|
5942
|
-
y = 0,
|
|
5943
|
-
x = 0
|
|
5944
|
-
} = state.modifiersData.preventOverflow;
|
|
5945
|
-
const {
|
|
5946
|
-
width,
|
|
5947
|
-
height
|
|
5948
|
-
} = state.rects.popper;
|
|
5949
|
-
const [basePlacement] = state.placement.split('-');
|
|
5950
|
-
const widthProp = basePlacement === 'left' ? 'left' : 'right';
|
|
5951
|
-
const heightProp = basePlacement === 'top' ? 'top' : 'bottom';
|
|
5952
|
-
// eslint-disable-next-line no-param-reassign
|
|
5953
|
-
state.modifiersData[name] = {
|
|
5954
|
-
width: width - overflow[widthProp] - x,
|
|
5955
|
-
height: height - overflow[heightProp] - y
|
|
5956
|
-
};
|
|
5503
|
+
const configFitWithinViewportHeight = memoize(fitWithinViewportHeight => {
|
|
5504
|
+
// Handle fit within viewport height
|
|
5505
|
+
if (!fitWithinViewportHeight) {
|
|
5506
|
+
return undefined;
|
|
5957
5507
|
}
|
|
5958
|
-
|
|
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
|
+
});
|
|
5959
5520
|
|
|
5960
5521
|
/**
|
|
5961
|
-
*
|
|
5522
|
+
* Parse PopoverProps['placement'] into floating-ui placement and alignment.
|
|
5962
5523
|
*/
|
|
5963
|
-
const
|
|
5964
|
-
|
|
5965
|
-
|
|
5966
|
-
|
|
5967
|
-
|
|
5968
|
-
|
|
5969
|
-
|
|
5970
|
-
|
|
5971
|
-
|
|
5972
|
-
|
|
5973
|
-
|
|
5974
|
-
|
|
5975
|
-
|
|
5976
|
-
|
|
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
|
+
});
|
|
5534
|
+
|
|
5535
|
+
/**
|
|
5536
|
+
* Adapt popover placement
|
|
5537
|
+
*/
|
|
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
|
+
})];
|
|
5977
5547
|
}
|
|
5548
|
+
// Auto-placement
|
|
5549
|
+
return [autoPlacement({
|
|
5550
|
+
alignment
|
|
5551
|
+
})];
|
|
5552
|
+
});
|
|
5553
|
+
function usePopoverStyle(_ref3) {
|
|
5554
|
+
var _middlewareData$arrow3, _middlewareData$arrow4;
|
|
5555
|
+
let {
|
|
5556
|
+
offset,
|
|
5557
|
+
hasArrow,
|
|
5558
|
+
fitToAnchorWidth,
|
|
5559
|
+
fitWithinViewportHeight,
|
|
5560
|
+
boundaryRef,
|
|
5561
|
+
anchorRef,
|
|
5562
|
+
placement: rawPlacement
|
|
5563
|
+
} = _ref3;
|
|
5564
|
+
const [arrowElement, setArrowElement] = useState(null);
|
|
5565
|
+
const {
|
|
5566
|
+
alignment,
|
|
5567
|
+
placement
|
|
5568
|
+
} = parsePlacement(rawPlacement);
|
|
5569
|
+
const middleware = [configOffset(offset, hasArrow), configArrow(arrowElement), configFitToAnchorWidth(fitToAnchorWidth), configFitWithinViewportHeight(fitWithinViewportHeight), ...configPlacement(placement, alignment, boundaryRef)].filter(Boolean);
|
|
5570
|
+
const {
|
|
5571
|
+
x,
|
|
5572
|
+
y,
|
|
5573
|
+
strategy,
|
|
5574
|
+
refs,
|
|
5575
|
+
placement: position,
|
|
5576
|
+
middlewareData,
|
|
5577
|
+
isPositioned
|
|
5578
|
+
} = useFloating({
|
|
5579
|
+
placement,
|
|
5580
|
+
middleware,
|
|
5581
|
+
whileElementsMounted: autoUpdate
|
|
5582
|
+
});
|
|
5583
|
+
React.useLayoutEffect(() => {
|
|
5584
|
+
// Update anchor
|
|
5585
|
+
refs.setReference(anchorRef.current);
|
|
5586
|
+
}, [anchorRef, refs]);
|
|
5587
|
+
const popoverStyle = useMemo(() => {
|
|
5588
|
+
const style = {
|
|
5589
|
+
visibility: isPositioned ? undefined : 'hidden',
|
|
5590
|
+
position: strategy,
|
|
5591
|
+
top: y || 0,
|
|
5592
|
+
left: x || 0,
|
|
5593
|
+
width: 'max-content',
|
|
5594
|
+
height: 'max-content'
|
|
5595
|
+
};
|
|
5596
|
+
return style;
|
|
5597
|
+
}, [isPositioned, strategy, y, x]);
|
|
5598
|
+
const [positionSide] = position.split('-');
|
|
5599
|
+
const arrowStyle = useMemo(() => {
|
|
5600
|
+
var _middlewareData$arrow, _middlewareData$arrow2;
|
|
5601
|
+
const horizontal = positionSide === 'left' || positionSide === 'right';
|
|
5602
|
+
return {
|
|
5603
|
+
top: horizontal && (middlewareData === null || middlewareData === void 0 ? void 0 : (_middlewareData$arrow = middlewareData.arrow) === null || _middlewareData$arrow === void 0 ? void 0 : _middlewareData$arrow.y) || undefined,
|
|
5604
|
+
left: !horizontal && (middlewareData === null || middlewareData === void 0 ? void 0 : (_middlewareData$arrow2 = middlewareData.arrow) === null || _middlewareData$arrow2 === void 0 ? void 0 : _middlewareData$arrow2.x) || undefined
|
|
5605
|
+
};
|
|
5606
|
+
}, [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]);
|
|
5607
|
+
return {
|
|
5608
|
+
styles: {
|
|
5609
|
+
popover: popoverStyle,
|
|
5610
|
+
arrow: arrowStyle
|
|
5611
|
+
},
|
|
5612
|
+
isPositioned,
|
|
5613
|
+
position: positionSide,
|
|
5614
|
+
arrowRef: setArrowElement,
|
|
5615
|
+
popoverRef: refs.setFloating,
|
|
5616
|
+
popoverElement: refs.floating.current
|
|
5617
|
+
};
|
|
5618
|
+
}
|
|
5619
|
+
|
|
5620
|
+
const _excluded$m = ["anchorRef", "children", "className", "closeOnClickAway", "closeOnEscape", "elevation", "focusElement", "hasArrow", "isOpen", "onClose", "parentElement", "usePortal", "focusAnchorOnClose", "withFocusTrap", "boundaryRef", "fitToAnchorWidth", "fitWithinViewportHeight", "offset", "placement", "style", "zIndex"];
|
|
5621
|
+
|
|
5622
|
+
/**
|
|
5623
|
+
* Defines the props of the component.
|
|
5624
|
+
*/
|
|
5625
|
+
|
|
5626
|
+
/**
|
|
5627
|
+
* Component display name.
|
|
5628
|
+
*/
|
|
5629
|
+
const COMPONENT_NAME$l = 'Popover';
|
|
5630
|
+
|
|
5631
|
+
/**
|
|
5632
|
+
* Component default class name and class prefix.
|
|
5633
|
+
*/
|
|
5634
|
+
const CLASSNAME$i = getRootClassName(COMPONENT_NAME$l);
|
|
5635
|
+
|
|
5636
|
+
/**
|
|
5637
|
+
* Component default props.
|
|
5638
|
+
*/
|
|
5639
|
+
const DEFAULT_PROPS$g = {
|
|
5640
|
+
elevation: 3,
|
|
5641
|
+
placement: Placement.AUTO,
|
|
5642
|
+
usePortal: true,
|
|
5643
|
+
zIndex: 9999
|
|
5978
5644
|
};
|
|
5979
5645
|
|
|
5980
5646
|
/** Method to render the popover inside a portal if usePortal is true */
|
|
@@ -5989,55 +5655,59 @@ const renderPopover = (children, usePortal) => {
|
|
|
5989
5655
|
* @param ref Component ref.
|
|
5990
5656
|
* @return React element.
|
|
5991
5657
|
*/
|
|
5992
|
-
const Popover =
|
|
5993
|
-
|
|
5994
|
-
|
|
5995
|
-
// Can't render in SSR.
|
|
5996
|
-
return null;
|
|
5997
|
-
}
|
|
5658
|
+
const Popover = skipRenderHOC(
|
|
5659
|
+
// Skip render in SSR
|
|
5660
|
+
() => Boolean(DOCUMENT), /*#__PURE__*/forwardRef((props, ref) => {
|
|
5998
5661
|
const {
|
|
5999
5662
|
anchorRef,
|
|
6000
|
-
boundaryRef,
|
|
6001
5663
|
children,
|
|
6002
5664
|
className,
|
|
6003
5665
|
closeOnClickAway,
|
|
6004
5666
|
closeOnEscape,
|
|
6005
5667
|
elevation,
|
|
6006
|
-
fitToAnchorWidth,
|
|
6007
|
-
fitWithinViewportHeight,
|
|
6008
5668
|
focusElement,
|
|
6009
5669
|
hasArrow,
|
|
6010
5670
|
isOpen,
|
|
6011
|
-
offset,
|
|
6012
5671
|
onClose,
|
|
6013
5672
|
parentElement,
|
|
6014
|
-
placement,
|
|
6015
|
-
style,
|
|
6016
5673
|
usePortal,
|
|
6017
|
-
zIndex,
|
|
6018
5674
|
focusAnchorOnClose = true,
|
|
6019
|
-
withFocusTrap
|
|
5675
|
+
withFocusTrap,
|
|
5676
|
+
boundaryRef,
|
|
5677
|
+
fitToAnchorWidth,
|
|
5678
|
+
fitWithinViewportHeight,
|
|
5679
|
+
offset,
|
|
5680
|
+
placement,
|
|
5681
|
+
style,
|
|
5682
|
+
zIndex
|
|
6020
5683
|
} = props,
|
|
6021
5684
|
forwardedProps = _objectWithoutProperties(props, _excluded$m);
|
|
6022
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
6023
|
-
const [popperElement, setPopperElement] = useState();
|
|
6024
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
6025
|
-
const [arrowElement, setArrowElement] = useState(null);
|
|
6026
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
6027
5685
|
const clickAwayRef = useRef(null);
|
|
6028
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
6029
5686
|
const contentRef = useRef(null);
|
|
5687
|
+
const {
|
|
5688
|
+
styles,
|
|
5689
|
+
isPositioned,
|
|
5690
|
+
position,
|
|
5691
|
+
popoverRef,
|
|
5692
|
+
popoverElement,
|
|
5693
|
+
arrowRef
|
|
5694
|
+
} = usePopoverStyle({
|
|
5695
|
+
offset,
|
|
5696
|
+
hasArrow,
|
|
5697
|
+
fitToAnchorWidth,
|
|
5698
|
+
fitWithinViewportHeight,
|
|
5699
|
+
boundaryRef,
|
|
5700
|
+
anchorRef,
|
|
5701
|
+
placement
|
|
5702
|
+
});
|
|
6030
5703
|
|
|
6031
5704
|
/**
|
|
6032
5705
|
* Track whether the focus is currently set in the
|
|
6033
5706
|
* popover.
|
|
6034
5707
|
* */
|
|
6035
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
6036
5708
|
const isFocusedWithin = useRef(false);
|
|
6037
|
-
|
|
6038
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
6039
5709
|
useFocusWithin({
|
|
6040
|
-
element:
|
|
5710
|
+
element: popoverElement,
|
|
6041
5711
|
onFocusIn: () => {
|
|
6042
5712
|
isFocusedWithin.current = true;
|
|
6043
5713
|
},
|
|
@@ -6047,7 +5717,6 @@ const Popover = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
6047
5717
|
});
|
|
6048
5718
|
|
|
6049
5719
|
/** Action on close */
|
|
6050
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
6051
5720
|
const handleClose = useCallback(() => {
|
|
6052
5721
|
if (!onClose) {
|
|
6053
5722
|
return;
|
|
@@ -6074,104 +5743,31 @@ const Popover = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
6074
5743
|
}
|
|
6075
5744
|
onClose();
|
|
6076
5745
|
}, [anchorRef, focusAnchorOnClose, onClose, parentElement]);
|
|
6077
|
-
const modifiers = [];
|
|
6078
|
-
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)];
|
|
6079
|
-
modifiers.push({
|
|
6080
|
-
name: 'offset',
|
|
6081
|
-
options: {
|
|
6082
|
-
offset: actualOffset
|
|
6083
|
-
}
|
|
6084
|
-
});
|
|
6085
|
-
if (hasArrow && arrowElement) {
|
|
6086
|
-
modifiers.push({
|
|
6087
|
-
name: 'arrow',
|
|
6088
|
-
options: {
|
|
6089
|
-
element: arrowElement,
|
|
6090
|
-
padding: ARROW_SIZE
|
|
6091
|
-
}
|
|
6092
|
-
});
|
|
6093
|
-
}
|
|
6094
|
-
if (fitToAnchorWidth) {
|
|
6095
|
-
const anchorWidthOption = typeof fitToAnchorWidth === 'string' ? fitToAnchorWidth : AnchorWidthOptions.MIN_WIDTH;
|
|
6096
|
-
modifiers.push(sameWidth(anchorWidthOption));
|
|
6097
|
-
}
|
|
6098
|
-
if (fitWithinViewportHeight) {
|
|
6099
|
-
modifiers.push(_objectSpread2(_objectSpread2({}, maxSize), {}, {
|
|
6100
|
-
options: {
|
|
6101
|
-
boundary: boundaryRef === null || boundaryRef === void 0 ? void 0 : boundaryRef.current
|
|
6102
|
-
}
|
|
6103
|
-
}), applyMaxHeight);
|
|
6104
|
-
}
|
|
6105
|
-
if (boundaryRef) {
|
|
6106
|
-
modifiers.push({
|
|
6107
|
-
name: 'flip',
|
|
6108
|
-
options: {
|
|
6109
|
-
boundary: boundaryRef.current
|
|
6110
|
-
}
|
|
6111
|
-
});
|
|
6112
|
-
modifiers.push({
|
|
6113
|
-
name: 'preventOverflow',
|
|
6114
|
-
options: {
|
|
6115
|
-
boundary: boundaryRef.current
|
|
6116
|
-
}
|
|
6117
|
-
});
|
|
6118
|
-
}
|
|
6119
|
-
|
|
6120
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
6121
|
-
const {
|
|
6122
|
-
styles,
|
|
6123
|
-
attributes,
|
|
6124
|
-
state,
|
|
6125
|
-
update
|
|
6126
|
-
} = usePopper(anchorRef.current, popperElement, {
|
|
6127
|
-
placement,
|
|
6128
|
-
modifiers
|
|
6129
|
-
});
|
|
6130
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
6131
|
-
useEffect(() => {
|
|
6132
|
-
update === null || update === void 0 ? void 0 : update();
|
|
6133
|
-
}, [children, update]);
|
|
6134
|
-
const position = (_state$placement = state === null || state === void 0 ? void 0 : state.placement) !== null && _state$placement !== void 0 ? _state$placement : placement;
|
|
6135
|
-
|
|
6136
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
6137
|
-
const popoverStyle = useMemo(() => {
|
|
6138
|
-
const newStyles = _objectSpread2(_objectSpread2(_objectSpread2({}, style), styles.popper), {}, {
|
|
6139
|
-
zIndex
|
|
6140
|
-
});
|
|
6141
|
-
if (fitWithinViewportHeight && !newStyles.maxHeight) {
|
|
6142
|
-
newStyles.maxHeight = (WINDOW === null || WINDOW === void 0 ? void 0 : WINDOW.innerHeight) || (DOCUMENT === null || DOCUMENT === void 0 ? void 0 : DOCUMENT.documentElement.clientHeight);
|
|
6143
|
-
}
|
|
6144
|
-
return newStyles;
|
|
6145
|
-
}, [style, styles.popper, zIndex, fitWithinViewportHeight]);
|
|
6146
|
-
|
|
6147
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
6148
5746
|
useCallbackOnEscape(handleClose, isOpen && closeOnEscape);
|
|
6149
5747
|
|
|
6150
5748
|
/** Only set focus within if the focus trap is disabled as they interfere with one another. */
|
|
6151
|
-
|
|
6152
|
-
useFocus(focusElement === null || focusElement === void 0 ? void 0 : focusElement.current, !withFocusTrap && isOpen && ((_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);
|
|
6153
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
5749
|
+
useFocus(focusElement === null || focusElement === void 0 ? void 0 : focusElement.current, !withFocusTrap && isOpen && isPositioned);
|
|
6154
5750
|
useFocusTrap(withFocusTrap && isOpen && (contentRef === null || contentRef === void 0 ? void 0 : contentRef.current), focusElement === null || focusElement === void 0 ? void 0 : focusElement.current);
|
|
6155
|
-
|
|
6156
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
6157
5751
|
const clickAwayRefs = useRef([clickAwayRef, anchorRef]);
|
|
6158
5752
|
return isOpen ? renderPopover( /*#__PURE__*/React.createElement("div", _extends({}, forwardedProps, {
|
|
6159
|
-
ref: mergeRefs(
|
|
5753
|
+
ref: mergeRefs(popoverRef, ref, clickAwayRef, contentRef),
|
|
6160
5754
|
className: classnames(className, handleBasicClasses({
|
|
6161
5755
|
prefix: CLASSNAME$i,
|
|
6162
5756
|
elevation: Math.min(elevation || 0, 5),
|
|
6163
5757
|
position
|
|
6164
5758
|
})),
|
|
6165
|
-
style:
|
|
6166
|
-
|
|
5759
|
+
style: _objectSpread2(_objectSpread2({}, style), {}, {
|
|
5760
|
+
zIndex
|
|
5761
|
+
}, styles.popover)
|
|
5762
|
+
}), /*#__PURE__*/React.createElement(ClickAwayProvider, {
|
|
6167
5763
|
callback: closeOnClickAway && handleClose,
|
|
6168
5764
|
childrenRefs: clickAwayRefs
|
|
6169
5765
|
}, hasArrow && /*#__PURE__*/React.createElement("div", {
|
|
6170
|
-
ref:
|
|
5766
|
+
ref: arrowRef,
|
|
6171
5767
|
className: `${CLASSNAME$i}__arrow`,
|
|
6172
5768
|
style: styles.arrow
|
|
6173
5769
|
}), children)), usePortal) : null;
|
|
6174
|
-
});
|
|
5770
|
+
}));
|
|
6175
5771
|
Popover.displayName = COMPONENT_NAME$l;
|
|
6176
5772
|
Popover.className = CLASSNAME$i;
|
|
6177
5773
|
Popover.defaultProps = DEFAULT_PROPS$g;
|
|
@@ -10023,16 +9619,16 @@ const PAGINATION_ITEMS_MAX = 5;
|
|
|
10023
9619
|
*/
|
|
10024
9620
|
const PAGINATION_ITEM_SIZE = 12;
|
|
10025
9621
|
|
|
10026
|
-
const DEFAULT_OPTIONS
|
|
9622
|
+
const DEFAULT_OPTIONS = {
|
|
10027
9623
|
activeIndex: 0,
|
|
10028
9624
|
groupBy: 1,
|
|
10029
9625
|
interval: AUTOPLAY_DEFAULT_INTERVAL
|
|
10030
9626
|
};
|
|
10031
9627
|
const useSlideshowControls = _ref => {
|
|
10032
9628
|
let {
|
|
10033
|
-
activeIndex = DEFAULT_OPTIONS
|
|
10034
|
-
groupBy = DEFAULT_OPTIONS
|
|
10035
|
-
interval = DEFAULT_OPTIONS
|
|
9629
|
+
activeIndex = DEFAULT_OPTIONS.activeIndex,
|
|
9630
|
+
groupBy = DEFAULT_OPTIONS.groupBy,
|
|
9631
|
+
interval = DEFAULT_OPTIONS.interval,
|
|
10036
9632
|
autoPlay,
|
|
10037
9633
|
defaultActiveIndex,
|
|
10038
9634
|
onChange,
|
|
@@ -10327,7 +9923,7 @@ const _excluded$13 = ["activeIndex", "autoPlay", "children", "className", "fillH
|
|
|
10327
9923
|
/**
|
|
10328
9924
|
* Component default props.
|
|
10329
9925
|
*/
|
|
10330
|
-
const DEFAULT_PROPS$P = _objectSpread2(_objectSpread2({}, DEFAULT_OPTIONS
|
|
9926
|
+
const DEFAULT_PROPS$P = _objectSpread2(_objectSpread2({}, DEFAULT_OPTIONS), {}, {
|
|
10331
9927
|
theme: Theme.light
|
|
10332
9928
|
});
|
|
10333
9929
|
|
|
@@ -10681,7 +10277,7 @@ InternalSlideshowControls.className = CLASSNAME$$;
|
|
|
10681
10277
|
InternalSlideshowControls.defaultProps = DEFAULT_PROPS$Q;
|
|
10682
10278
|
const SlideshowControls = Object.assign(InternalSlideshowControls, {
|
|
10683
10279
|
useSlideshowControls,
|
|
10684
|
-
useSlideshowControlsDefaultOptions: DEFAULT_OPTIONS
|
|
10280
|
+
useSlideshowControlsDefaultOptions: DEFAULT_OPTIONS
|
|
10685
10281
|
});
|
|
10686
10282
|
|
|
10687
10283
|
const _excluded$16 = ["activeIndex", "id", "className", "theme", "fillHeight", "groupBy", "isAutoPlaying", "toggleAutoPlay", "slidesId", "children", "afterSlides", "hasControls", "slideGroupLabel"];
|
|
@@ -12226,7 +11822,7 @@ const DEFAULT_PROPS$11 = {
|
|
|
12226
11822
|
/**
|
|
12227
11823
|
* Arrow size (in pixel).
|
|
12228
11824
|
*/
|
|
12229
|
-
const ARROW_SIZE
|
|
11825
|
+
const ARROW_SIZE = 8;
|
|
12230
11826
|
|
|
12231
11827
|
/**
|
|
12232
11828
|
* Tooltip component.
|
|
@@ -12235,10 +11831,16 @@ const ARROW_SIZE$1 = 8;
|
|
|
12235
11831
|
* @param ref Component ref.
|
|
12236
11832
|
* @return React element.
|
|
12237
11833
|
*/
|
|
12238
|
-
const Tooltip =
|
|
12239
|
-
|
|
11834
|
+
const Tooltip = skipRenderHOC(
|
|
11835
|
+
// Disable in SSR or without a label.
|
|
11836
|
+
_ref => {
|
|
11837
|
+
let {
|
|
11838
|
+
label
|
|
11839
|
+
} = _ref;
|
|
11840
|
+
return Boolean(DOCUMENT && label);
|
|
11841
|
+
}, /*#__PURE__*/forwardRef((props, ref) => {
|
|
12240
11842
|
const {
|
|
12241
|
-
label,
|
|
11843
|
+
label: l,
|
|
12242
11844
|
children,
|
|
12243
11845
|
className,
|
|
12244
11846
|
delay,
|
|
@@ -12246,30 +11848,26 @@ const Tooltip = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
12246
11848
|
forceOpen
|
|
12247
11849
|
} = props,
|
|
12248
11850
|
forwardedProps = _objectWithoutProperties(props, _excluded$1k);
|
|
12249
|
-
//
|
|
12250
|
-
|
|
12251
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
12252
|
-
}
|
|
11851
|
+
// Cast label as we know it's not empty
|
|
11852
|
+
const label = l;
|
|
12253
11853
|
const id = useMemo(() => `tooltip-${uid()}`, []);
|
|
12254
|
-
const [popperElement, setPopperElement] = useState(null);
|
|
12255
|
-
const [anchorElement, setAnchorElement] = useState(null);
|
|
12256
11854
|
const {
|
|
12257
|
-
|
|
12258
|
-
|
|
12259
|
-
|
|
11855
|
+
x,
|
|
11856
|
+
y,
|
|
11857
|
+
strategy,
|
|
11858
|
+
refs,
|
|
11859
|
+
placement: position
|
|
11860
|
+
} = useFloating({
|
|
12260
11861
|
placement,
|
|
12261
|
-
|
|
12262
|
-
|
|
12263
|
-
|
|
12264
|
-
|
|
12265
|
-
}
|
|
12266
|
-
}]
|
|
11862
|
+
middleware: [offset({
|
|
11863
|
+
mainAxis: ARROW_SIZE
|
|
11864
|
+
})],
|
|
11865
|
+
whileElementsMounted: autoUpdate
|
|
12267
11866
|
});
|
|
12268
|
-
const
|
|
12269
|
-
const
|
|
12270
|
-
const wrappedChildren = useInjectTooltipRef(children, setAnchorElement, isOpen, id);
|
|
11867
|
+
const isOpen = useTooltipOpen(delay, refs.reference.current) || forceOpen;
|
|
11868
|
+
const wrappedChildren = useInjectTooltipRef(children, refs.setReference, isOpen, id);
|
|
12271
11869
|
return /*#__PURE__*/React.createElement(React.Fragment, null, wrappedChildren, isOpen && /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement("div", _extends({
|
|
12272
|
-
ref: mergeRefs(ref,
|
|
11870
|
+
ref: mergeRefs(ref, refs.setFloating)
|
|
12273
11871
|
}, forwardedProps, {
|
|
12274
11872
|
id: id,
|
|
12275
11873
|
role: "tooltip",
|
|
@@ -12278,15 +11876,19 @@ const Tooltip = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
12278
11876
|
prefix: CLASSNAME$1d,
|
|
12279
11877
|
position
|
|
12280
11878
|
})),
|
|
12281
|
-
style:
|
|
12282
|
-
|
|
11879
|
+
style: {
|
|
11880
|
+
position: strategy,
|
|
11881
|
+
top: y || 0,
|
|
11882
|
+
left: x || 0
|
|
11883
|
+
}
|
|
11884
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
12283
11885
|
className: `${CLASSNAME$1d}__arrow`
|
|
12284
11886
|
}), /*#__PURE__*/React.createElement("div", {
|
|
12285
11887
|
className: `${CLASSNAME$1d}__inner`
|
|
12286
11888
|
}, label.indexOf('\n') !== -1 ? label.split('\n').map(sentence => /*#__PURE__*/React.createElement("p", {
|
|
12287
11889
|
key: sentence
|
|
12288
11890
|
}, sentence)) : label)), document.body));
|
|
12289
|
-
});
|
|
11891
|
+
}));
|
|
12290
11892
|
Tooltip.displayName = COMPONENT_NAME$1g;
|
|
12291
11893
|
Tooltip.className = CLASSNAME$1d;
|
|
12292
11894
|
Tooltip.defaultProps = DEFAULT_PROPS$11;
|