ivt 0.3.3 → 0.3.5
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/dist/accordion/index.mjs +19 -1
- package/dist/accordion/index.mjs.map +1 -1
- package/dist/alert/index.mjs +43 -1
- package/dist/alert/index.mjs.map +1 -1
- package/dist/alert-dialog/index.mjs +260 -1
- package/dist/alert-dialog/index.mjs.map +1 -1
- package/dist/avatar/index.mjs +164 -1
- package/dist/avatar/index.mjs.map +1 -1
- package/dist/badge/index.mjs +6 -1
- package/dist/badge/index.mjs.map +1 -1
- package/dist/base/index.mjs +760 -1
- package/dist/base/index.mjs.map +1 -1
- package/dist/button/index.mjs +6 -1
- package/dist/button/index.mjs.map +1 -1
- package/dist/calendar/index.mjs +11 -1
- package/dist/calendar/index.mjs.map +1 -1
- package/dist/card/index.mjs +55 -1
- package/dist/card/index.mjs.map +1 -1
- package/dist/chart/index.mjs +16696 -1
- package/dist/chart/index.mjs.map +1 -1
- package/dist/checkbox/index.mjs +223 -1
- package/dist/checkbox/index.mjs.map +1 -1
- package/dist/chunks/_commonjsHelpers-DKISyIRi.mjs +6 -0
- package/dist/chunks/_commonjsHelpers-DKISyIRi.mjs.map +1 -0
- package/dist/chunks/accordion-CK9Ucbko.mjs +455 -0
- package/dist/chunks/{accordion-CdshDFZC.mjs.map → accordion-CK9Ucbko.mjs.map} +1 -1
- package/dist/chunks/badge-CT_hmjd2.mjs +57 -0
- package/dist/chunks/{badge-BYqshEmA.mjs.map → badge-CT_hmjd2.mjs.map} +1 -1
- package/dist/chunks/bundle-mjs-CS-QKnOm.mjs +4491 -0
- package/dist/chunks/{bundle-mjs-9BXytT_r.mjs.map → bundle-mjs-CS-QKnOm.mjs.map} +1 -1
- package/dist/chunks/button-BHeYV17S.mjs +47 -0
- package/dist/chunks/{button-DrFZXJ7z.mjs.map → button-BHeYV17S.mjs.map} +1 -1
- package/dist/chunks/calendar-CU6HdJET.mjs +7106 -0
- package/dist/chunks/calendar-CU6HdJET.mjs.map +1 -0
- package/dist/chunks/check-B3pXhibW.mjs +15 -0
- package/dist/chunks/{check-CimnOyD7.mjs.map → check-B3pXhibW.mjs.map} +1 -1
- package/dist/chunks/chevron-down-BV5gvmUW.mjs +15 -0
- package/dist/chunks/{chevron-down-D3fvbjxE.mjs.map → chevron-down-BV5gvmUW.mjs.map} +1 -1
- package/dist/chunks/chevron-left-BjGcH2KQ.mjs +15 -0
- package/dist/chunks/{chevron-left-CrN7DlXg.mjs.map → chevron-left-BjGcH2KQ.mjs.map} +1 -1
- package/dist/chunks/chevron-right-DmZu0xvo.mjs +15 -0
- package/dist/chunks/{chevron-right-BMSCuDGK.mjs.map → chevron-right-DmZu0xvo.mjs.map} +1 -1
- package/dist/chunks/chevrons-up-down-COuCmfU7.mjs +22 -0
- package/dist/chunks/{chevrons-up-down-DBgvRkZm.mjs.map → chevrons-up-down-COuCmfU7.mjs.map} +1 -1
- package/dist/chunks/circle-BKsPjIbw.mjs +17 -0
- package/dist/chunks/{circle-CGqt18Bd.mjs.map → circle-BKsPjIbw.mjs.map} +1 -1
- package/dist/chunks/command-CUWr3X1X.mjs +611 -0
- package/dist/chunks/command-CUWr3X1X.mjs.map +1 -0
- package/dist/chunks/createLucideIcon-BSP_Jxu-.mjs +60 -0
- package/dist/chunks/{createLucideIcon-L-tld2uc.mjs.map → createLucideIcon-BSP_Jxu-.mjs.map} +1 -1
- package/dist/chunks/dialog-zZCazow7.mjs +80 -0
- package/dist/chunks/{dialog-36eqHzT3.mjs.map → dialog-zZCazow7.mjs.map} +1 -1
- package/dist/chunks/hover-card-C6WPsacG.mjs +274 -0
- package/dist/chunks/{hover-card-Cnd58du6.mjs.map → hover-card-C6WPsacG.mjs.map} +1 -1
- package/dist/chunks/index-3XcV7C7l.mjs +324 -0
- package/dist/chunks/{index-DUNcuWJE.mjs.map → index-3XcV7C7l.mjs.map} +1 -1
- package/dist/chunks/index-B1VVz0MP.mjs +266 -0
- package/dist/chunks/index-B1VVz0MP.mjs.map +1 -0
- package/dist/chunks/index-BFDafXar.mjs +2370 -0
- package/dist/chunks/index-BFDafXar.mjs.map +1 -0
- package/dist/chunks/index-BF_TaONY.mjs +859 -0
- package/dist/chunks/{index-DZHMFdr0.mjs.map → index-BF_TaONY.mjs.map} +1 -1
- package/dist/chunks/index-BOOPeiVs.mjs +34 -0
- package/dist/chunks/{index-D2sZp5OP.mjs.map → index-BOOPeiVs.mjs.map} +1 -1
- package/dist/chunks/index-BYijxgZz.mjs +12 -0
- package/dist/chunks/index-BYijxgZz.mjs.map +1 -0
- package/dist/chunks/index-BZyzz9k8.mjs +40 -0
- package/dist/chunks/index-BZyzz9k8.mjs.map +1 -0
- package/dist/chunks/index-Bgiaprdv.mjs +7 -0
- package/dist/chunks/{index-CLtWFQL5.mjs.map → index-Bgiaprdv.mjs.map} +1 -1
- package/dist/chunks/index-Bl6nVRXe.mjs +110 -0
- package/dist/chunks/{index-CCcl327A.mjs.map → index-Bl6nVRXe.mjs.map} +1 -1
- package/dist/chunks/index-BwQDLVf8.mjs +151 -0
- package/dist/chunks/index-BwQDLVf8.mjs.map +1 -0
- package/dist/chunks/index-CHyZo-Tj.mjs +1210 -0
- package/dist/chunks/index-CHyZo-Tj.mjs.map +1 -0
- package/dist/chunks/index-CZ7Wntp7.mjs +21 -0
- package/dist/chunks/index-CZ7Wntp7.mjs.map +1 -0
- package/dist/chunks/index-D1yPZAOL.mjs +13 -0
- package/dist/chunks/{index-CXszXOf_.mjs.map → index-D1yPZAOL.mjs.map} +1 -1
- package/dist/chunks/index-DIBl7n6R.mjs +145 -0
- package/dist/chunks/index-DIBl7n6R.mjs.map +1 -0
- package/dist/chunks/index-DRk0bB4A.mjs +216 -0
- package/dist/chunks/{index-LvOFIVGz.mjs.map → index-DRk0bB4A.mjs.map} +1 -1
- package/dist/chunks/index-DUFr75Kc.mjs +77 -0
- package/dist/chunks/{index-CybgQKpz.mjs.map → index-DUFr75Kc.mjs.map} +1 -1
- package/dist/chunks/index-DrnQ43fz.mjs +18 -0
- package/dist/chunks/{index-CRxQlsb9.mjs.map → index-DrnQ43fz.mjs.map} +1 -1
- package/dist/chunks/index-Dulm0stf.mjs +12 -0
- package/dist/chunks/{index-CU_y1XAz.mjs.map → index-Dulm0stf.mjs.map} +1 -1
- package/dist/chunks/index-fWnSEyU5.mjs +50 -0
- package/dist/chunks/{index-w9bxia3O.mjs.map → index-fWnSEyU5.mjs.map} +1 -1
- package/dist/chunks/index-tNc5GmLL.mjs +51 -0
- package/dist/chunks/{index-vmPXTidH.mjs.map → index-tNc5GmLL.mjs.map} +1 -1
- package/dist/chunks/input-D9-FhnGc.mjs +14 -0
- package/dist/chunks/{input-85UFztMJ.mjs.map → input-D9-FhnGc.mjs.map} +1 -1
- package/dist/chunks/label-CiJcd2F9.mjs +32 -0
- package/dist/chunks/{label-CICFzZIt.mjs.map → label-CiJcd2F9.mjs.map} +1 -1
- package/dist/chunks/pagination-SOhqOW7I.mjs +106 -0
- package/dist/chunks/{pagination-CReDQes6.mjs.map → pagination-SOhqOW7I.mjs.map} +1 -1
- package/dist/chunks/popover-WlYXFyUl.mjs +308 -0
- package/dist/chunks/{popover-Cn2ZTvKd.mjs.map → popover-WlYXFyUl.mjs.map} +1 -1
- package/dist/chunks/progress-DdBZJTQG.mjs +99 -0
- package/dist/chunks/{progress-CSxQH6-f.mjs.map → progress-DdBZJTQG.mjs.map} +1 -1
- package/dist/chunks/scroll-area-B2wNbBRR.mjs +791 -0
- package/dist/chunks/scroll-area-B2wNbBRR.mjs.map +1 -0
- package/dist/chunks/select-COGYOg3A.mjs +104 -0
- package/dist/chunks/{select-BR6_N_Yo.mjs.map → select-COGYOg3A.mjs.map} +1 -1
- package/dist/chunks/separator-D6Y96f4g.mjs +48 -0
- package/dist/chunks/{separator-BB6-E9Z1.mjs.map → separator-D6Y96f4g.mjs.map} +1 -1
- package/dist/chunks/skeleton-CRfBAk8U.mjs +13 -0
- package/dist/chunks/{skeleton-XPWWiaac.mjs.map → skeleton-CRfBAk8U.mjs.map} +1 -1
- package/dist/chunks/sortable-tiuZWf3S.mjs +4221 -0
- package/dist/chunks/sortable-tiuZWf3S.mjs.map +1 -0
- package/dist/chunks/table-BlTF56Yn.mjs +62 -0
- package/dist/chunks/{table-LQIHzPHi.mjs.map → table-BlTF56Yn.mjs.map} +1 -1
- package/dist/chunks/toggle-D5tCYA7L.mjs +65 -0
- package/dist/chunks/{toggle-Co72WXGd.mjs.map → toggle-D5tCYA7L.mjs.map} +1 -1
- package/dist/chunks/tooltip-BpTMPR5Q.mjs +596 -0
- package/dist/chunks/{tooltip-qX2HjdJP.mjs.map → tooltip-BpTMPR5Q.mjs.map} +1 -1
- package/dist/chunks/tslib.es6-O3UsmxNe.mjs +61 -0
- package/dist/chunks/{tslib.es6-cMGqxriw.mjs.map → tslib.es6-O3UsmxNe.mjs.map} +1 -1
- package/dist/chunks/utils-tbIgc9YG.mjs +42 -0
- package/dist/chunks/utils-tbIgc9YG.mjs.map +1 -0
- package/dist/chunks/x-5oL4uC6I.mjs +22 -0
- package/dist/chunks/{x-BNLl0E-E.mjs.map → x-5oL4uC6I.mjs.map} +1 -1
- package/dist/combobox/index.mjs +65 -1
- package/dist/combobox/index.mjs.map +1 -1
- package/dist/command/index.mjs +23 -1
- package/dist/command/index.mjs.map +1 -1
- package/dist/data-table/index.mjs +673 -1
- package/dist/data-table/index.mjs.map +1 -1
- package/dist/dialog/index.mjs +22 -1
- package/dist/dialog/index.mjs.map +1 -1
- package/dist/dropdown-menu/index.mjs +438 -1
- package/dist/dropdown-menu/index.mjs.map +1 -1
- package/dist/dropzone/index.mjs +7839 -1
- package/dist/dropzone/index.mjs.map +1 -1
- package/dist/form/index.mjs +649 -1
- package/dist/form/index.mjs.map +1 -1
- package/dist/hover-card/index.mjs +18 -1
- package/dist/hover-card/index.mjs.map +1 -1
- package/dist/icon/index.mjs +317 -1
- package/dist/icon/index.mjs.map +1 -1
- package/dist/index.css +1 -1
- package/dist/input/index.mjs +4 -1
- package/dist/input/index.mjs.map +1 -1
- package/dist/ivt.css +1 -1
- package/dist/label/index.mjs +8 -1
- package/dist/label/index.mjs.map +1 -1
- package/dist/menubar/index.mjs +583 -1
- package/dist/menubar/index.mjs.map +1 -1
- package/dist/multi-select/index.mjs +297 -1
- package/dist/multi-select/index.mjs.map +1 -1
- package/dist/pagination/index.mjs +10 -1
- package/dist/pagination/index.mjs.map +1 -1
- package/dist/popover/index.mjs +21 -1
- package/dist/popover/index.mjs.map +1 -1
- package/dist/progress/index.mjs +9 -1
- package/dist/progress/index.mjs.map +1 -1
- package/dist/radio-group/index.mjs +267 -1
- package/dist/radio-group/index.mjs.map +1 -1
- package/dist/scroll-area/index.mjs +15 -1
- package/dist/scroll-area/index.mjs.map +1 -1
- package/dist/select/index.mjs +8 -1
- package/dist/select/index.mjs.map +1 -1
- package/dist/separator/index.mjs +8 -1
- package/dist/separator/index.mjs.map +1 -1
- package/dist/sheet/index.mjs +96 -1
- package/dist/sheet/index.mjs.map +1 -1
- package/dist/skeleton/index.mjs +4 -1
- package/dist/skeleton/index.mjs.map +1 -1
- package/dist/sonner/index.mjs +1140 -1
- package/dist/sonner/index.mjs.map +1 -1
- package/dist/sortable/index.mjs +8 -1
- package/dist/sortable/index.mjs.map +1 -1
- package/dist/table/index.mjs +4 -1
- package/dist/table/index.mjs.map +1 -1
- package/dist/tabs/index.mjs +193 -1
- package/dist/tabs/index.mjs.map +1 -1
- package/dist/textarea/index.mjs +13 -1
- package/dist/textarea/index.mjs.map +1 -1
- package/dist/toast/index.mjs +705 -1
- package/dist/toast/index.mjs.map +1 -1
- package/dist/toggle/index.mjs +12 -1
- package/dist/toggle/index.mjs.map +1 -1
- package/dist/toggle-group/index.mjs +219 -1
- package/dist/toggle-group/index.mjs.map +1 -1
- package/dist/tooltip/index.mjs +20 -1
- package/dist/tooltip/index.mjs.map +1 -1
- package/package.json +6 -5
- package/dist/chunks/_commonjsHelpers-6qLFzZa5.mjs +0 -2
- package/dist/chunks/_commonjsHelpers-6qLFzZa5.mjs.map +0 -1
- package/dist/chunks/accordion-CdshDFZC.mjs +0 -2
- package/dist/chunks/badge-BYqshEmA.mjs +0 -2
- package/dist/chunks/bundle-mjs-9BXytT_r.mjs +0 -2
- package/dist/chunks/button-DrFZXJ7z.mjs +0 -2
- package/dist/chunks/calendar-BY6t8wdJ.mjs +0 -2
- package/dist/chunks/calendar-BY6t8wdJ.mjs.map +0 -1
- package/dist/chunks/check-CimnOyD7.mjs +0 -2
- package/dist/chunks/chevron-down-D3fvbjxE.mjs +0 -2
- package/dist/chunks/chevron-left-CrN7DlXg.mjs +0 -2
- package/dist/chunks/chevron-right-BMSCuDGK.mjs +0 -2
- package/dist/chunks/chevrons-up-down-DBgvRkZm.mjs +0 -2
- package/dist/chunks/circle-CGqt18Bd.mjs +0 -2
- package/dist/chunks/command-C6ON-ciq.mjs +0 -2
- package/dist/chunks/command-C6ON-ciq.mjs.map +0 -1
- package/dist/chunks/createLucideIcon-L-tld2uc.mjs +0 -2
- package/dist/chunks/dialog-36eqHzT3.mjs +0 -2
- package/dist/chunks/hover-card-Cnd58du6.mjs +0 -2
- package/dist/chunks/index-B4QsDzeM.mjs +0 -2
- package/dist/chunks/index-B4QsDzeM.mjs.map +0 -1
- package/dist/chunks/index-BdpYc58_.mjs +0 -2
- package/dist/chunks/index-BdpYc58_.mjs.map +0 -1
- package/dist/chunks/index-CCcl327A.mjs +0 -2
- package/dist/chunks/index-CLtWFQL5.mjs +0 -2
- package/dist/chunks/index-COvW87ew.mjs +0 -2
- package/dist/chunks/index-COvW87ew.mjs.map +0 -1
- package/dist/chunks/index-CRxQlsb9.mjs +0 -2
- package/dist/chunks/index-CU_y1XAz.mjs +0 -2
- package/dist/chunks/index-CXszXOf_.mjs +0 -2
- package/dist/chunks/index-CdJCOoFA.mjs +0 -2
- package/dist/chunks/index-CdJCOoFA.mjs.map +0 -1
- package/dist/chunks/index-Cpq7N5Ej.mjs +0 -2
- package/dist/chunks/index-Cpq7N5Ej.mjs.map +0 -1
- package/dist/chunks/index-CybgQKpz.mjs +0 -2
- package/dist/chunks/index-D2sZp5OP.mjs +0 -2
- package/dist/chunks/index-DOyt-JEx.mjs +0 -2
- package/dist/chunks/index-DOyt-JEx.mjs.map +0 -1
- package/dist/chunks/index-DUNcuWJE.mjs +0 -2
- package/dist/chunks/index-DZHMFdr0.mjs +0 -2
- package/dist/chunks/index-LvOFIVGz.mjs +0 -2
- package/dist/chunks/index-lvPXnk5F.mjs +0 -2
- package/dist/chunks/index-lvPXnk5F.mjs.map +0 -1
- package/dist/chunks/index-vmPXTidH.mjs +0 -2
- package/dist/chunks/index-w9bxia3O.mjs +0 -2
- package/dist/chunks/index-xew3kygQ.mjs +0 -2
- package/dist/chunks/index-xew3kygQ.mjs.map +0 -1
- package/dist/chunks/input-85UFztMJ.mjs +0 -2
- package/dist/chunks/label-CICFzZIt.mjs +0 -2
- package/dist/chunks/pagination-CReDQes6.mjs +0 -2
- package/dist/chunks/popover-Cn2ZTvKd.mjs +0 -2
- package/dist/chunks/progress-CSxQH6-f.mjs +0 -2
- package/dist/chunks/scroll-area-CvCz7cL_.mjs +0 -2
- package/dist/chunks/scroll-area-CvCz7cL_.mjs.map +0 -1
- package/dist/chunks/select-BR6_N_Yo.mjs +0 -2
- package/dist/chunks/separator-BB6-E9Z1.mjs +0 -2
- package/dist/chunks/skeleton-XPWWiaac.mjs +0 -2
- package/dist/chunks/sortable-CqPFGn8Q.mjs +0 -2
- package/dist/chunks/sortable-CqPFGn8Q.mjs.map +0 -1
- package/dist/chunks/table-LQIHzPHi.mjs +0 -2
- package/dist/chunks/toggle-Co72WXGd.mjs +0 -2
- package/dist/chunks/tooltip-qX2HjdJP.mjs +0 -2
- package/dist/chunks/tslib.es6-cMGqxriw.mjs +0 -2
- package/dist/chunks/utils-BctauAA9.mjs +0 -2
- package/dist/chunks/utils-BctauAA9.mjs.map +0 -1
- package/dist/chunks/x-BNLl0E-E.mjs +0 -2
@@ -0,0 +1,2370 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import { useLayoutEffect } from 'react';
|
3
|
+
import * as ReactDOM from 'react-dom';
|
4
|
+
import { P as Primitive } from './index-fWnSEyU5.mjs';
|
5
|
+
import { jsx } from 'react/jsx-runtime';
|
6
|
+
import { u as useComposedRefs } from './index-BZyzz9k8.mjs';
|
7
|
+
import { c as createContextScope } from './index-Bl6nVRXe.mjs';
|
8
|
+
import { u as useCallbackRef } from './index-D1yPZAOL.mjs';
|
9
|
+
import { u as useLayoutEffect2 } from './index-Bgiaprdv.mjs';
|
10
|
+
import { u as useSize } from './index-tNc5GmLL.mjs';
|
11
|
+
|
12
|
+
/**
|
13
|
+
* Custom positioning reference element.
|
14
|
+
* @see https://floating-ui.com/docs/virtual-elements
|
15
|
+
*/ const sides = [
|
16
|
+
'top',
|
17
|
+
'right',
|
18
|
+
'bottom',
|
19
|
+
'left'
|
20
|
+
];
|
21
|
+
const min = Math.min;
|
22
|
+
const max = Math.max;
|
23
|
+
const round = Math.round;
|
24
|
+
const floor = Math.floor;
|
25
|
+
const createCoords = (v)=>({
|
26
|
+
x: v,
|
27
|
+
y: v
|
28
|
+
});
|
29
|
+
const oppositeSideMap = {
|
30
|
+
left: 'right',
|
31
|
+
right: 'left',
|
32
|
+
bottom: 'top',
|
33
|
+
top: 'bottom'
|
34
|
+
};
|
35
|
+
const oppositeAlignmentMap = {
|
36
|
+
start: 'end',
|
37
|
+
end: 'start'
|
38
|
+
};
|
39
|
+
function clamp(start, value, end) {
|
40
|
+
return max(start, min(value, end));
|
41
|
+
}
|
42
|
+
function evaluate(value, param) {
|
43
|
+
return typeof value === 'function' ? value(param) : value;
|
44
|
+
}
|
45
|
+
function getSide(placement) {
|
46
|
+
return placement.split('-')[0];
|
47
|
+
}
|
48
|
+
function getAlignment(placement) {
|
49
|
+
return placement.split('-')[1];
|
50
|
+
}
|
51
|
+
function getOppositeAxis(axis) {
|
52
|
+
return axis === 'x' ? 'y' : 'x';
|
53
|
+
}
|
54
|
+
function getAxisLength(axis) {
|
55
|
+
return axis === 'y' ? 'height' : 'width';
|
56
|
+
}
|
57
|
+
const yAxisSides = /*#__PURE__*/ new Set([
|
58
|
+
'top',
|
59
|
+
'bottom'
|
60
|
+
]);
|
61
|
+
function getSideAxis(placement) {
|
62
|
+
return yAxisSides.has(getSide(placement)) ? 'y' : 'x';
|
63
|
+
}
|
64
|
+
function getAlignmentAxis(placement) {
|
65
|
+
return getOppositeAxis(getSideAxis(placement));
|
66
|
+
}
|
67
|
+
function getAlignmentSides(placement, rects, rtl) {
|
68
|
+
if (rtl === void 0) {
|
69
|
+
rtl = false;
|
70
|
+
}
|
71
|
+
const alignment = getAlignment(placement);
|
72
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
73
|
+
const length = getAxisLength(alignmentAxis);
|
74
|
+
let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
|
75
|
+
if (rects.reference[length] > rects.floating[length]) {
|
76
|
+
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
77
|
+
}
|
78
|
+
return [
|
79
|
+
mainAlignmentSide,
|
80
|
+
getOppositePlacement(mainAlignmentSide)
|
81
|
+
];
|
82
|
+
}
|
83
|
+
function getExpandedPlacements(placement) {
|
84
|
+
const oppositePlacement = getOppositePlacement(placement);
|
85
|
+
return [
|
86
|
+
getOppositeAlignmentPlacement(placement),
|
87
|
+
oppositePlacement,
|
88
|
+
getOppositeAlignmentPlacement(oppositePlacement)
|
89
|
+
];
|
90
|
+
}
|
91
|
+
function getOppositeAlignmentPlacement(placement) {
|
92
|
+
return placement.replace(/start|end/g, (alignment)=>oppositeAlignmentMap[alignment]);
|
93
|
+
}
|
94
|
+
const lrPlacement = [
|
95
|
+
'left',
|
96
|
+
'right'
|
97
|
+
];
|
98
|
+
const rlPlacement = [
|
99
|
+
'right',
|
100
|
+
'left'
|
101
|
+
];
|
102
|
+
const tbPlacement = [
|
103
|
+
'top',
|
104
|
+
'bottom'
|
105
|
+
];
|
106
|
+
const btPlacement = [
|
107
|
+
'bottom',
|
108
|
+
'top'
|
109
|
+
];
|
110
|
+
function getSideList(side, isStart, rtl) {
|
111
|
+
switch(side){
|
112
|
+
case 'top':
|
113
|
+
case 'bottom':
|
114
|
+
if (rtl) return isStart ? rlPlacement : lrPlacement;
|
115
|
+
return isStart ? lrPlacement : rlPlacement;
|
116
|
+
case 'left':
|
117
|
+
case 'right':
|
118
|
+
return isStart ? tbPlacement : btPlacement;
|
119
|
+
default:
|
120
|
+
return [];
|
121
|
+
}
|
122
|
+
}
|
123
|
+
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
124
|
+
const alignment = getAlignment(placement);
|
125
|
+
let list = getSideList(getSide(placement), direction === 'start', rtl);
|
126
|
+
if (alignment) {
|
127
|
+
list = list.map((side)=>side + "-" + alignment);
|
128
|
+
if (flipAlignment) {
|
129
|
+
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
130
|
+
}
|
131
|
+
}
|
132
|
+
return list;
|
133
|
+
}
|
134
|
+
function getOppositePlacement(placement) {
|
135
|
+
return placement.replace(/left|right|bottom|top/g, (side)=>oppositeSideMap[side]);
|
136
|
+
}
|
137
|
+
function expandPaddingObject(padding) {
|
138
|
+
return {
|
139
|
+
top: 0,
|
140
|
+
right: 0,
|
141
|
+
bottom: 0,
|
142
|
+
left: 0,
|
143
|
+
...padding
|
144
|
+
};
|
145
|
+
}
|
146
|
+
function getPaddingObject(padding) {
|
147
|
+
return typeof padding !== 'number' ? expandPaddingObject(padding) : {
|
148
|
+
top: padding,
|
149
|
+
right: padding,
|
150
|
+
bottom: padding,
|
151
|
+
left: padding
|
152
|
+
};
|
153
|
+
}
|
154
|
+
function rectToClientRect(rect) {
|
155
|
+
const { x, y, width, height } = rect;
|
156
|
+
return {
|
157
|
+
width,
|
158
|
+
height,
|
159
|
+
top: y,
|
160
|
+
left: x,
|
161
|
+
right: x + width,
|
162
|
+
bottom: y + height,
|
163
|
+
x,
|
164
|
+
y
|
165
|
+
};
|
166
|
+
}
|
167
|
+
|
168
|
+
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
169
|
+
let { reference, floating } = _ref;
|
170
|
+
const sideAxis = getSideAxis(placement);
|
171
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
172
|
+
const alignLength = getAxisLength(alignmentAxis);
|
173
|
+
const side = getSide(placement);
|
174
|
+
const isVertical = sideAxis === 'y';
|
175
|
+
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
176
|
+
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
177
|
+
const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
|
178
|
+
let coords;
|
179
|
+
switch(side){
|
180
|
+
case 'top':
|
181
|
+
coords = {
|
182
|
+
x: commonX,
|
183
|
+
y: reference.y - floating.height
|
184
|
+
};
|
185
|
+
break;
|
186
|
+
case 'bottom':
|
187
|
+
coords = {
|
188
|
+
x: commonX,
|
189
|
+
y: reference.y + reference.height
|
190
|
+
};
|
191
|
+
break;
|
192
|
+
case 'right':
|
193
|
+
coords = {
|
194
|
+
x: reference.x + reference.width,
|
195
|
+
y: commonY
|
196
|
+
};
|
197
|
+
break;
|
198
|
+
case 'left':
|
199
|
+
coords = {
|
200
|
+
x: reference.x - floating.width,
|
201
|
+
y: commonY
|
202
|
+
};
|
203
|
+
break;
|
204
|
+
default:
|
205
|
+
coords = {
|
206
|
+
x: reference.x,
|
207
|
+
y: reference.y
|
208
|
+
};
|
209
|
+
}
|
210
|
+
switch(getAlignment(placement)){
|
211
|
+
case 'start':
|
212
|
+
coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
213
|
+
break;
|
214
|
+
case 'end':
|
215
|
+
coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
216
|
+
break;
|
217
|
+
}
|
218
|
+
return coords;
|
219
|
+
}
|
220
|
+
/**
|
221
|
+
* Computes the `x` and `y` coordinates that will place the floating element
|
222
|
+
* next to a given reference element.
|
223
|
+
*
|
224
|
+
* This export does not have any `platform` interface logic. You will need to
|
225
|
+
* write one for the platform you are using Floating UI with.
|
226
|
+
*/ const computePosition$1 = async (reference, floating, config)=>{
|
227
|
+
const { placement = 'bottom', strategy = 'absolute', middleware = [], platform } = config;
|
228
|
+
const validMiddleware = middleware.filter(Boolean);
|
229
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
|
230
|
+
let rects = await platform.getElementRects({
|
231
|
+
reference,
|
232
|
+
floating,
|
233
|
+
strategy
|
234
|
+
});
|
235
|
+
let { x, y } = computeCoordsFromPlacement(rects, placement, rtl);
|
236
|
+
let statefulPlacement = placement;
|
237
|
+
let middlewareData = {};
|
238
|
+
let resetCount = 0;
|
239
|
+
for(let i = 0; i < validMiddleware.length; i++){
|
240
|
+
const { name, fn } = validMiddleware[i];
|
241
|
+
const { x: nextX, y: nextY, data, reset } = await fn({
|
242
|
+
x,
|
243
|
+
y,
|
244
|
+
initialPlacement: placement,
|
245
|
+
placement: statefulPlacement,
|
246
|
+
strategy,
|
247
|
+
middlewareData,
|
248
|
+
rects,
|
249
|
+
platform,
|
250
|
+
elements: {
|
251
|
+
reference,
|
252
|
+
floating
|
253
|
+
}
|
254
|
+
});
|
255
|
+
x = nextX != null ? nextX : x;
|
256
|
+
y = nextY != null ? nextY : y;
|
257
|
+
middlewareData = {
|
258
|
+
...middlewareData,
|
259
|
+
[name]: {
|
260
|
+
...middlewareData[name],
|
261
|
+
...data
|
262
|
+
}
|
263
|
+
};
|
264
|
+
if (reset && resetCount <= 50) {
|
265
|
+
resetCount++;
|
266
|
+
if (typeof reset === 'object') {
|
267
|
+
if (reset.placement) {
|
268
|
+
statefulPlacement = reset.placement;
|
269
|
+
}
|
270
|
+
if (reset.rects) {
|
271
|
+
rects = reset.rects === true ? await platform.getElementRects({
|
272
|
+
reference,
|
273
|
+
floating,
|
274
|
+
strategy
|
275
|
+
}) : reset.rects;
|
276
|
+
}
|
277
|
+
({ x, y } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
278
|
+
}
|
279
|
+
i = -1;
|
280
|
+
}
|
281
|
+
}
|
282
|
+
return {
|
283
|
+
x,
|
284
|
+
y,
|
285
|
+
placement: statefulPlacement,
|
286
|
+
strategy,
|
287
|
+
middlewareData
|
288
|
+
};
|
289
|
+
};
|
290
|
+
/**
|
291
|
+
* Resolves with an object of overflow side offsets that determine how much the
|
292
|
+
* element is overflowing a given clipping boundary on each side.
|
293
|
+
* - positive = overflowing the boundary by that number of pixels
|
294
|
+
* - negative = how many pixels left before it will overflow
|
295
|
+
* - 0 = lies flush with the boundary
|
296
|
+
* @see https://floating-ui.com/docs/detectOverflow
|
297
|
+
*/ async function detectOverflow(state, options) {
|
298
|
+
var _await$platform$isEle;
|
299
|
+
if (options === void 0) {
|
300
|
+
options = {};
|
301
|
+
}
|
302
|
+
const { x, y, platform, rects, elements, strategy } = state;
|
303
|
+
const { boundary = 'clippingAncestors', rootBoundary = 'viewport', elementContext = 'floating', altBoundary = false, padding = 0 } = evaluate(options, state);
|
304
|
+
const paddingObject = getPaddingObject(padding);
|
305
|
+
const altContext = elementContext === 'floating' ? 'reference' : 'floating';
|
306
|
+
const element = elements[altBoundary ? altContext : elementContext];
|
307
|
+
const clippingClientRect = rectToClientRect(await platform.getClippingRect({
|
308
|
+
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)),
|
309
|
+
boundary,
|
310
|
+
rootBoundary,
|
311
|
+
strategy
|
312
|
+
}));
|
313
|
+
const rect = elementContext === 'floating' ? {
|
314
|
+
x,
|
315
|
+
y,
|
316
|
+
width: rects.floating.width,
|
317
|
+
height: rects.floating.height
|
318
|
+
} : rects.reference;
|
319
|
+
const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
|
320
|
+
const offsetScale = await (platform.isElement == null ? void 0 : platform.isElement(offsetParent)) ? await (platform.getScale == null ? void 0 : platform.getScale(offsetParent)) || {
|
321
|
+
x: 1,
|
322
|
+
y: 1
|
323
|
+
} : {
|
324
|
+
x: 1,
|
325
|
+
y: 1
|
326
|
+
};
|
327
|
+
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
328
|
+
elements,
|
329
|
+
rect,
|
330
|
+
offsetParent,
|
331
|
+
strategy
|
332
|
+
}) : rect);
|
333
|
+
return {
|
334
|
+
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
335
|
+
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
336
|
+
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
337
|
+
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
338
|
+
};
|
339
|
+
}
|
340
|
+
/**
|
341
|
+
* Provides data to position an inner element of the floating element so that it
|
342
|
+
* appears centered to the reference element.
|
343
|
+
* @see https://floating-ui.com/docs/arrow
|
344
|
+
*/ const arrow$3 = (options)=>({
|
345
|
+
name: 'arrow',
|
346
|
+
options,
|
347
|
+
async fn (state) {
|
348
|
+
const { x, y, placement, rects, platform, elements, middlewareData } = state;
|
349
|
+
// Since `element` is required, we don't Partial<> the type.
|
350
|
+
const { element, padding = 0 } = evaluate(options, state) || {};
|
351
|
+
if (element == null) {
|
352
|
+
return {};
|
353
|
+
}
|
354
|
+
const paddingObject = getPaddingObject(padding);
|
355
|
+
const coords = {
|
356
|
+
x,
|
357
|
+
y
|
358
|
+
};
|
359
|
+
const axis = getAlignmentAxis(placement);
|
360
|
+
const length = getAxisLength(axis);
|
361
|
+
const arrowDimensions = await platform.getDimensions(element);
|
362
|
+
const isYAxis = axis === 'y';
|
363
|
+
const minProp = isYAxis ? 'top' : 'left';
|
364
|
+
const maxProp = isYAxis ? 'bottom' : 'right';
|
365
|
+
const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
|
366
|
+
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
|
367
|
+
const startDiff = coords[axis] - rects.reference[axis];
|
368
|
+
const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
|
369
|
+
let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
|
370
|
+
// DOM platform can return `window` as the `offsetParent`.
|
371
|
+
if (!clientSize || !await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent))) {
|
372
|
+
clientSize = elements.floating[clientProp] || rects.floating[length];
|
373
|
+
}
|
374
|
+
const centerToReference = endDiff / 2 - startDiff / 2;
|
375
|
+
// If the padding is large enough that it causes the arrow to no longer be
|
376
|
+
// centered, modify the padding so that it is centered.
|
377
|
+
const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
|
378
|
+
const minPadding = min(paddingObject[minProp], largestPossiblePadding);
|
379
|
+
const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
|
380
|
+
// Make sure the arrow doesn't overflow the floating element if the center
|
381
|
+
// point is outside the floating element's bounds.
|
382
|
+
const min$1 = minPadding;
|
383
|
+
const max = clientSize - arrowDimensions[length] - maxPadding;
|
384
|
+
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
385
|
+
const offset = clamp(min$1, center, max);
|
386
|
+
// If the reference is small enough that the arrow's padding causes it to
|
387
|
+
// to point to nothing for an aligned placement, adjust the offset of the
|
388
|
+
// floating element itself. To ensure `shift()` continues to take action,
|
389
|
+
// a single reset is performed when this is true.
|
390
|
+
const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
|
391
|
+
const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
|
392
|
+
return {
|
393
|
+
[axis]: coords[axis] + alignmentOffset,
|
394
|
+
data: {
|
395
|
+
[axis]: offset,
|
396
|
+
centerOffset: center - offset - alignmentOffset,
|
397
|
+
...shouldAddOffset && {
|
398
|
+
alignmentOffset
|
399
|
+
}
|
400
|
+
},
|
401
|
+
reset: shouldAddOffset
|
402
|
+
};
|
403
|
+
}
|
404
|
+
});
|
405
|
+
/**
|
406
|
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
407
|
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
408
|
+
* clipping boundary. Alternative to `autoPlacement`.
|
409
|
+
* @see https://floating-ui.com/docs/flip
|
410
|
+
*/ const flip$2 = function(options) {
|
411
|
+
if (options === void 0) {
|
412
|
+
options = {};
|
413
|
+
}
|
414
|
+
return {
|
415
|
+
name: 'flip',
|
416
|
+
options,
|
417
|
+
async fn (state) {
|
418
|
+
var _middlewareData$arrow, _middlewareData$flip;
|
419
|
+
const { placement, middlewareData, rects, initialPlacement, platform, elements } = state;
|
420
|
+
const { mainAxis: checkMainAxis = true, crossAxis: checkCrossAxis = true, fallbackPlacements: specifiedFallbackPlacements, fallbackStrategy = 'bestFit', fallbackAxisSideDirection = 'none', flipAlignment = true, ...detectOverflowOptions } = evaluate(options, state);
|
421
|
+
// If a reset by the arrow was caused due to an alignment offset being
|
422
|
+
// added, we should skip any logic now since `flip()` has already done its
|
423
|
+
// work.
|
424
|
+
// https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
|
425
|
+
if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
426
|
+
return {};
|
427
|
+
}
|
428
|
+
const side = getSide(placement);
|
429
|
+
const initialSideAxis = getSideAxis(initialPlacement);
|
430
|
+
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
431
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
432
|
+
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [
|
433
|
+
getOppositePlacement(initialPlacement)
|
434
|
+
] : getExpandedPlacements(initialPlacement));
|
435
|
+
const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';
|
436
|
+
if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
|
437
|
+
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
438
|
+
}
|
439
|
+
const placements = [
|
440
|
+
initialPlacement,
|
441
|
+
...fallbackPlacements
|
442
|
+
];
|
443
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
444
|
+
const overflows = [];
|
445
|
+
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
446
|
+
if (checkMainAxis) {
|
447
|
+
overflows.push(overflow[side]);
|
448
|
+
}
|
449
|
+
if (checkCrossAxis) {
|
450
|
+
const sides = getAlignmentSides(placement, rects, rtl);
|
451
|
+
overflows.push(overflow[sides[0]], overflow[sides[1]]);
|
452
|
+
}
|
453
|
+
overflowsData = [
|
454
|
+
...overflowsData,
|
455
|
+
{
|
456
|
+
placement,
|
457
|
+
overflows
|
458
|
+
}
|
459
|
+
];
|
460
|
+
// One or more sides is overflowing.
|
461
|
+
if (!overflows.every((side)=>side <= 0)) {
|
462
|
+
var _middlewareData$flip2, _overflowsData$filter;
|
463
|
+
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
464
|
+
const nextPlacement = placements[nextIndex];
|
465
|
+
if (nextPlacement) {
|
466
|
+
const ignoreCrossAxisOverflow = checkCrossAxis === 'alignment' ? initialSideAxis !== getSideAxis(nextPlacement) : false;
|
467
|
+
if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
|
468
|
+
// overflows the main axis.
|
469
|
+
overflowsData.every((d)=>getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
|
470
|
+
// Try next placement and re-run the lifecycle.
|
471
|
+
return {
|
472
|
+
data: {
|
473
|
+
index: nextIndex,
|
474
|
+
overflows: overflowsData
|
475
|
+
},
|
476
|
+
reset: {
|
477
|
+
placement: nextPlacement
|
478
|
+
}
|
479
|
+
};
|
480
|
+
}
|
481
|
+
}
|
482
|
+
// First, find the candidates that fit on the mainAxis side of overflow,
|
483
|
+
// then find the placement that fits the best on the main crossAxis side.
|
484
|
+
let resetPlacement = (_overflowsData$filter = overflowsData.filter((d)=>d.overflows[0] <= 0).sort((a, b)=>a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
|
485
|
+
// Otherwise fallback.
|
486
|
+
if (!resetPlacement) {
|
487
|
+
switch(fallbackStrategy){
|
488
|
+
case 'bestFit':
|
489
|
+
{
|
490
|
+
var _overflowsData$filter2;
|
491
|
+
const placement = (_overflowsData$filter2 = overflowsData.filter((d)=>{
|
492
|
+
if (hasFallbackAxisSideDirection) {
|
493
|
+
const currentSideAxis = getSideAxis(d.placement);
|
494
|
+
return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
|
495
|
+
// reading directions favoring greater width.
|
496
|
+
currentSideAxis === 'y';
|
497
|
+
}
|
498
|
+
return true;
|
499
|
+
}).map((d)=>[
|
500
|
+
d.placement,
|
501
|
+
d.overflows.filter((overflow)=>overflow > 0).reduce((acc, overflow)=>acc + overflow, 0)
|
502
|
+
]).sort((a, b)=>a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
|
503
|
+
if (placement) {
|
504
|
+
resetPlacement = placement;
|
505
|
+
}
|
506
|
+
break;
|
507
|
+
}
|
508
|
+
case 'initialPlacement':
|
509
|
+
resetPlacement = initialPlacement;
|
510
|
+
break;
|
511
|
+
}
|
512
|
+
}
|
513
|
+
if (placement !== resetPlacement) {
|
514
|
+
return {
|
515
|
+
reset: {
|
516
|
+
placement: resetPlacement
|
517
|
+
}
|
518
|
+
};
|
519
|
+
}
|
520
|
+
}
|
521
|
+
return {};
|
522
|
+
}
|
523
|
+
};
|
524
|
+
};
|
525
|
+
function getSideOffsets(overflow, rect) {
|
526
|
+
return {
|
527
|
+
top: overflow.top - rect.height,
|
528
|
+
right: overflow.right - rect.width,
|
529
|
+
bottom: overflow.bottom - rect.height,
|
530
|
+
left: overflow.left - rect.width
|
531
|
+
};
|
532
|
+
}
|
533
|
+
function isAnySideFullyClipped(overflow) {
|
534
|
+
return sides.some((side)=>overflow[side] >= 0);
|
535
|
+
}
|
536
|
+
/**
|
537
|
+
* Provides data to hide the floating element in applicable situations, such as
|
538
|
+
* when it is not in the same clipping context as the reference element.
|
539
|
+
* @see https://floating-ui.com/docs/hide
|
540
|
+
*/ const hide$2 = function(options) {
|
541
|
+
if (options === void 0) {
|
542
|
+
options = {};
|
543
|
+
}
|
544
|
+
return {
|
545
|
+
name: 'hide',
|
546
|
+
options,
|
547
|
+
async fn (state) {
|
548
|
+
const { rects } = state;
|
549
|
+
const { strategy = 'referenceHidden', ...detectOverflowOptions } = evaluate(options, state);
|
550
|
+
switch(strategy){
|
551
|
+
case 'referenceHidden':
|
552
|
+
{
|
553
|
+
const overflow = await detectOverflow(state, {
|
554
|
+
...detectOverflowOptions,
|
555
|
+
elementContext: 'reference'
|
556
|
+
});
|
557
|
+
const offsets = getSideOffsets(overflow, rects.reference);
|
558
|
+
return {
|
559
|
+
data: {
|
560
|
+
referenceHiddenOffsets: offsets,
|
561
|
+
referenceHidden: isAnySideFullyClipped(offsets)
|
562
|
+
}
|
563
|
+
};
|
564
|
+
}
|
565
|
+
case 'escaped':
|
566
|
+
{
|
567
|
+
const overflow = await detectOverflow(state, {
|
568
|
+
...detectOverflowOptions,
|
569
|
+
altBoundary: true
|
570
|
+
});
|
571
|
+
const offsets = getSideOffsets(overflow, rects.floating);
|
572
|
+
return {
|
573
|
+
data: {
|
574
|
+
escapedOffsets: offsets,
|
575
|
+
escaped: isAnySideFullyClipped(offsets)
|
576
|
+
}
|
577
|
+
};
|
578
|
+
}
|
579
|
+
default:
|
580
|
+
{
|
581
|
+
return {};
|
582
|
+
}
|
583
|
+
}
|
584
|
+
}
|
585
|
+
};
|
586
|
+
};
|
587
|
+
const originSides = /*#__PURE__*/ new Set([
|
588
|
+
'left',
|
589
|
+
'top'
|
590
|
+
]);
|
591
|
+
// For type backwards-compatibility, the `OffsetOptions` type was also
|
592
|
+
// Derivable.
|
593
|
+
async function convertValueToCoords(state, options) {
|
594
|
+
const { placement, platform, elements } = state;
|
595
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
596
|
+
const side = getSide(placement);
|
597
|
+
const alignment = getAlignment(placement);
|
598
|
+
const isVertical = getSideAxis(placement) === 'y';
|
599
|
+
const mainAxisMulti = originSides.has(side) ? -1 : 1;
|
600
|
+
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
601
|
+
const rawValue = evaluate(options, state);
|
602
|
+
// eslint-disable-next-line prefer-const
|
603
|
+
let { mainAxis, crossAxis, alignmentAxis } = typeof rawValue === 'number' ? {
|
604
|
+
mainAxis: rawValue,
|
605
|
+
crossAxis: 0,
|
606
|
+
alignmentAxis: null
|
607
|
+
} : {
|
608
|
+
mainAxis: rawValue.mainAxis || 0,
|
609
|
+
crossAxis: rawValue.crossAxis || 0,
|
610
|
+
alignmentAxis: rawValue.alignmentAxis
|
611
|
+
};
|
612
|
+
if (alignment && typeof alignmentAxis === 'number') {
|
613
|
+
crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
|
614
|
+
}
|
615
|
+
return isVertical ? {
|
616
|
+
x: crossAxis * crossAxisMulti,
|
617
|
+
y: mainAxis * mainAxisMulti
|
618
|
+
} : {
|
619
|
+
x: mainAxis * mainAxisMulti,
|
620
|
+
y: crossAxis * crossAxisMulti
|
621
|
+
};
|
622
|
+
}
|
623
|
+
/**
|
624
|
+
* Modifies the placement by translating the floating element along the
|
625
|
+
* specified axes.
|
626
|
+
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
627
|
+
* object may be passed.
|
628
|
+
* @see https://floating-ui.com/docs/offset
|
629
|
+
*/ const offset$2 = function(options) {
|
630
|
+
if (options === void 0) {
|
631
|
+
options = 0;
|
632
|
+
}
|
633
|
+
return {
|
634
|
+
name: 'offset',
|
635
|
+
options,
|
636
|
+
async fn (state) {
|
637
|
+
var _middlewareData$offse, _middlewareData$arrow;
|
638
|
+
const { x, y, placement, middlewareData } = state;
|
639
|
+
const diffCoords = await convertValueToCoords(state, options);
|
640
|
+
// If the placement is the same and the arrow caused an alignment offset
|
641
|
+
// then we don't need to change the positioning coordinates.
|
642
|
+
if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
643
|
+
return {};
|
644
|
+
}
|
645
|
+
return {
|
646
|
+
x: x + diffCoords.x,
|
647
|
+
y: y + diffCoords.y,
|
648
|
+
data: {
|
649
|
+
...diffCoords,
|
650
|
+
placement
|
651
|
+
}
|
652
|
+
};
|
653
|
+
}
|
654
|
+
};
|
655
|
+
};
|
656
|
+
/**
|
657
|
+
* Optimizes the visibility of the floating element by shifting it in order to
|
658
|
+
* keep it in view when it will overflow the clipping boundary.
|
659
|
+
* @see https://floating-ui.com/docs/shift
|
660
|
+
*/ const shift$2 = function(options) {
|
661
|
+
if (options === void 0) {
|
662
|
+
options = {};
|
663
|
+
}
|
664
|
+
return {
|
665
|
+
name: 'shift',
|
666
|
+
options,
|
667
|
+
async fn (state) {
|
668
|
+
const { x, y, placement } = state;
|
669
|
+
const { mainAxis: checkMainAxis = true, crossAxis: checkCrossAxis = false, limiter = {
|
670
|
+
fn: (_ref)=>{
|
671
|
+
let { x, y } = _ref;
|
672
|
+
return {
|
673
|
+
x,
|
674
|
+
y
|
675
|
+
};
|
676
|
+
}
|
677
|
+
}, ...detectOverflowOptions } = evaluate(options, state);
|
678
|
+
const coords = {
|
679
|
+
x,
|
680
|
+
y
|
681
|
+
};
|
682
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
683
|
+
const crossAxis = getSideAxis(getSide(placement));
|
684
|
+
const mainAxis = getOppositeAxis(crossAxis);
|
685
|
+
let mainAxisCoord = coords[mainAxis];
|
686
|
+
let crossAxisCoord = coords[crossAxis];
|
687
|
+
if (checkMainAxis) {
|
688
|
+
const minSide = mainAxis === 'y' ? 'top' : 'left';
|
689
|
+
const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
|
690
|
+
const min = mainAxisCoord + overflow[minSide];
|
691
|
+
const max = mainAxisCoord - overflow[maxSide];
|
692
|
+
mainAxisCoord = clamp(min, mainAxisCoord, max);
|
693
|
+
}
|
694
|
+
if (checkCrossAxis) {
|
695
|
+
const minSide = crossAxis === 'y' ? 'top' : 'left';
|
696
|
+
const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
|
697
|
+
const min = crossAxisCoord + overflow[minSide];
|
698
|
+
const max = crossAxisCoord - overflow[maxSide];
|
699
|
+
crossAxisCoord = clamp(min, crossAxisCoord, max);
|
700
|
+
}
|
701
|
+
const limitedCoords = limiter.fn({
|
702
|
+
...state,
|
703
|
+
[mainAxis]: mainAxisCoord,
|
704
|
+
[crossAxis]: crossAxisCoord
|
705
|
+
});
|
706
|
+
return {
|
707
|
+
...limitedCoords,
|
708
|
+
data: {
|
709
|
+
x: limitedCoords.x - x,
|
710
|
+
y: limitedCoords.y - y,
|
711
|
+
enabled: {
|
712
|
+
[mainAxis]: checkMainAxis,
|
713
|
+
[crossAxis]: checkCrossAxis
|
714
|
+
}
|
715
|
+
}
|
716
|
+
};
|
717
|
+
}
|
718
|
+
};
|
719
|
+
};
|
720
|
+
/**
|
721
|
+
* Built-in `limiter` that will stop `shift()` at a certain point.
|
722
|
+
*/ const limitShift$2 = function(options) {
|
723
|
+
if (options === void 0) {
|
724
|
+
options = {};
|
725
|
+
}
|
726
|
+
return {
|
727
|
+
options,
|
728
|
+
fn (state) {
|
729
|
+
const { x, y, placement, rects, middlewareData } = state;
|
730
|
+
const { offset = 0, mainAxis: checkMainAxis = true, crossAxis: checkCrossAxis = true } = evaluate(options, state);
|
731
|
+
const coords = {
|
732
|
+
x,
|
733
|
+
y
|
734
|
+
};
|
735
|
+
const crossAxis = getSideAxis(placement);
|
736
|
+
const mainAxis = getOppositeAxis(crossAxis);
|
737
|
+
let mainAxisCoord = coords[mainAxis];
|
738
|
+
let crossAxisCoord = coords[crossAxis];
|
739
|
+
const rawOffset = evaluate(offset, state);
|
740
|
+
const computedOffset = typeof rawOffset === 'number' ? {
|
741
|
+
mainAxis: rawOffset,
|
742
|
+
crossAxis: 0
|
743
|
+
} : {
|
744
|
+
mainAxis: 0,
|
745
|
+
crossAxis: 0,
|
746
|
+
...rawOffset
|
747
|
+
};
|
748
|
+
if (checkMainAxis) {
|
749
|
+
const len = mainAxis === 'y' ? 'height' : 'width';
|
750
|
+
const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
|
751
|
+
const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
|
752
|
+
if (mainAxisCoord < limitMin) {
|
753
|
+
mainAxisCoord = limitMin;
|
754
|
+
} else if (mainAxisCoord > limitMax) {
|
755
|
+
mainAxisCoord = limitMax;
|
756
|
+
}
|
757
|
+
}
|
758
|
+
if (checkCrossAxis) {
|
759
|
+
var _middlewareData$offse, _middlewareData$offse2;
|
760
|
+
const len = mainAxis === 'y' ? 'width' : 'height';
|
761
|
+
const isOriginSide = originSides.has(getSide(placement));
|
762
|
+
const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);
|
763
|
+
const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0);
|
764
|
+
if (crossAxisCoord < limitMin) {
|
765
|
+
crossAxisCoord = limitMin;
|
766
|
+
} else if (crossAxisCoord > limitMax) {
|
767
|
+
crossAxisCoord = limitMax;
|
768
|
+
}
|
769
|
+
}
|
770
|
+
return {
|
771
|
+
[mainAxis]: mainAxisCoord,
|
772
|
+
[crossAxis]: crossAxisCoord
|
773
|
+
};
|
774
|
+
}
|
775
|
+
};
|
776
|
+
};
|
777
|
+
/**
|
778
|
+
* Provides data that allows you to change the size of the floating element —
|
779
|
+
* for instance, prevent it from overflowing the clipping boundary or match the
|
780
|
+
* width of the reference element.
|
781
|
+
* @see https://floating-ui.com/docs/size
|
782
|
+
*/ const size$2 = function(options) {
|
783
|
+
if (options === void 0) {
|
784
|
+
options = {};
|
785
|
+
}
|
786
|
+
return {
|
787
|
+
name: 'size',
|
788
|
+
options,
|
789
|
+
async fn (state) {
|
790
|
+
var _state$middlewareData, _state$middlewareData2;
|
791
|
+
const { placement, rects, platform, elements } = state;
|
792
|
+
const { apply = ()=>{}, ...detectOverflowOptions } = evaluate(options, state);
|
793
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
794
|
+
const side = getSide(placement);
|
795
|
+
const alignment = getAlignment(placement);
|
796
|
+
const isYAxis = getSideAxis(placement) === 'y';
|
797
|
+
const { width, height } = rects.floating;
|
798
|
+
let heightSide;
|
799
|
+
let widthSide;
|
800
|
+
if (side === 'top' || side === 'bottom') {
|
801
|
+
heightSide = side;
|
802
|
+
widthSide = alignment === (await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)) ? 'start' : 'end') ? 'left' : 'right';
|
803
|
+
} else {
|
804
|
+
widthSide = side;
|
805
|
+
heightSide = alignment === 'end' ? 'top' : 'bottom';
|
806
|
+
}
|
807
|
+
const maximumClippingHeight = height - overflow.top - overflow.bottom;
|
808
|
+
const maximumClippingWidth = width - overflow.left - overflow.right;
|
809
|
+
const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
|
810
|
+
const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
|
811
|
+
const noShift = !state.middlewareData.shift;
|
812
|
+
let availableHeight = overflowAvailableHeight;
|
813
|
+
let availableWidth = overflowAvailableWidth;
|
814
|
+
if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
|
815
|
+
availableWidth = maximumClippingWidth;
|
816
|
+
}
|
817
|
+
if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
|
818
|
+
availableHeight = maximumClippingHeight;
|
819
|
+
}
|
820
|
+
if (noShift && !alignment) {
|
821
|
+
const xMin = max(overflow.left, 0);
|
822
|
+
const xMax = max(overflow.right, 0);
|
823
|
+
const yMin = max(overflow.top, 0);
|
824
|
+
const yMax = max(overflow.bottom, 0);
|
825
|
+
if (isYAxis) {
|
826
|
+
availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
|
827
|
+
} else {
|
828
|
+
availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
|
829
|
+
}
|
830
|
+
}
|
831
|
+
await apply({
|
832
|
+
...state,
|
833
|
+
availableWidth,
|
834
|
+
availableHeight
|
835
|
+
});
|
836
|
+
const nextDimensions = await platform.getDimensions(elements.floating);
|
837
|
+
if (width !== nextDimensions.width || height !== nextDimensions.height) {
|
838
|
+
return {
|
839
|
+
reset: {
|
840
|
+
rects: true
|
841
|
+
}
|
842
|
+
};
|
843
|
+
}
|
844
|
+
return {};
|
845
|
+
}
|
846
|
+
};
|
847
|
+
};
|
848
|
+
|
849
|
+
function hasWindow() {
|
850
|
+
return typeof window !== 'undefined';
|
851
|
+
}
|
852
|
+
function getNodeName(node) {
|
853
|
+
if (isNode(node)) {
|
854
|
+
return (node.nodeName || '').toLowerCase();
|
855
|
+
}
|
856
|
+
// Mocked nodes in testing environments may not be instances of Node. By
|
857
|
+
// returning `#document` an infinite loop won't occur.
|
858
|
+
// https://github.com/floating-ui/floating-ui/issues/2317
|
859
|
+
return '#document';
|
860
|
+
}
|
861
|
+
function getWindow(node) {
|
862
|
+
var _node$ownerDocument;
|
863
|
+
return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
864
|
+
}
|
865
|
+
function getDocumentElement(node) {
|
866
|
+
var _ref;
|
867
|
+
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
868
|
+
}
|
869
|
+
function isNode(value) {
|
870
|
+
if (!hasWindow()) {
|
871
|
+
return false;
|
872
|
+
}
|
873
|
+
return value instanceof Node || value instanceof getWindow(value).Node;
|
874
|
+
}
|
875
|
+
function isElement(value) {
|
876
|
+
if (!hasWindow()) {
|
877
|
+
return false;
|
878
|
+
}
|
879
|
+
return value instanceof Element || value instanceof getWindow(value).Element;
|
880
|
+
}
|
881
|
+
function isHTMLElement(value) {
|
882
|
+
if (!hasWindow()) {
|
883
|
+
return false;
|
884
|
+
}
|
885
|
+
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
886
|
+
}
|
887
|
+
function isShadowRoot(value) {
|
888
|
+
if (!hasWindow() || typeof ShadowRoot === 'undefined') {
|
889
|
+
return false;
|
890
|
+
}
|
891
|
+
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
892
|
+
}
|
893
|
+
const invalidOverflowDisplayValues = /*#__PURE__*/ new Set([
|
894
|
+
'inline',
|
895
|
+
'contents'
|
896
|
+
]);
|
897
|
+
function isOverflowElement(element) {
|
898
|
+
const { overflow, overflowX, overflowY, display } = getComputedStyle$1(element);
|
899
|
+
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
|
900
|
+
}
|
901
|
+
const tableElements = /*#__PURE__*/ new Set([
|
902
|
+
'table',
|
903
|
+
'td',
|
904
|
+
'th'
|
905
|
+
]);
|
906
|
+
function isTableElement(element) {
|
907
|
+
return tableElements.has(getNodeName(element));
|
908
|
+
}
|
909
|
+
const topLayerSelectors = [
|
910
|
+
':popover-open',
|
911
|
+
':modal'
|
912
|
+
];
|
913
|
+
function isTopLayer(element) {
|
914
|
+
return topLayerSelectors.some((selector)=>{
|
915
|
+
try {
|
916
|
+
return element.matches(selector);
|
917
|
+
} catch (_e) {
|
918
|
+
return false;
|
919
|
+
}
|
920
|
+
});
|
921
|
+
}
|
922
|
+
const transformProperties = [
|
923
|
+
'transform',
|
924
|
+
'translate',
|
925
|
+
'scale',
|
926
|
+
'rotate',
|
927
|
+
'perspective'
|
928
|
+
];
|
929
|
+
const willChangeValues = [
|
930
|
+
'transform',
|
931
|
+
'translate',
|
932
|
+
'scale',
|
933
|
+
'rotate',
|
934
|
+
'perspective',
|
935
|
+
'filter'
|
936
|
+
];
|
937
|
+
const containValues = [
|
938
|
+
'paint',
|
939
|
+
'layout',
|
940
|
+
'strict',
|
941
|
+
'content'
|
942
|
+
];
|
943
|
+
function isContainingBlock(elementOrCss) {
|
944
|
+
const webkit = isWebKit();
|
945
|
+
const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
|
946
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
947
|
+
// https://drafts.csswg.org/css-transforms-2/#individual-transforms
|
948
|
+
return transformProperties.some((value)=>css[value] ? css[value] !== 'none' : false) || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || willChangeValues.some((value)=>(css.willChange || '').includes(value)) || containValues.some((value)=>(css.contain || '').includes(value));
|
949
|
+
}
|
950
|
+
function getContainingBlock(element) {
|
951
|
+
let currentNode = getParentNode(element);
|
952
|
+
while(isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)){
|
953
|
+
if (isContainingBlock(currentNode)) {
|
954
|
+
return currentNode;
|
955
|
+
} else if (isTopLayer(currentNode)) {
|
956
|
+
return null;
|
957
|
+
}
|
958
|
+
currentNode = getParentNode(currentNode);
|
959
|
+
}
|
960
|
+
return null;
|
961
|
+
}
|
962
|
+
function isWebKit() {
|
963
|
+
if (typeof CSS === 'undefined' || !CSS.supports) return false;
|
964
|
+
return CSS.supports('-webkit-backdrop-filter', 'none');
|
965
|
+
}
|
966
|
+
const lastTraversableNodeNames = /*#__PURE__*/ new Set([
|
967
|
+
'html',
|
968
|
+
'body',
|
969
|
+
'#document'
|
970
|
+
]);
|
971
|
+
function isLastTraversableNode(node) {
|
972
|
+
return lastTraversableNodeNames.has(getNodeName(node));
|
973
|
+
}
|
974
|
+
function getComputedStyle$1(element) {
|
975
|
+
return getWindow(element).getComputedStyle(element);
|
976
|
+
}
|
977
|
+
function getNodeScroll(element) {
|
978
|
+
if (isElement(element)) {
|
979
|
+
return {
|
980
|
+
scrollLeft: element.scrollLeft,
|
981
|
+
scrollTop: element.scrollTop
|
982
|
+
};
|
983
|
+
}
|
984
|
+
return {
|
985
|
+
scrollLeft: element.scrollX,
|
986
|
+
scrollTop: element.scrollY
|
987
|
+
};
|
988
|
+
}
|
989
|
+
function getParentNode(node) {
|
990
|
+
if (getNodeName(node) === 'html') {
|
991
|
+
return node;
|
992
|
+
}
|
993
|
+
const result = // Step into the shadow DOM of the parent of a slotted node.
|
994
|
+
node.assignedSlot || // DOM Element detected.
|
995
|
+
node.parentNode || // ShadowRoot detected.
|
996
|
+
isShadowRoot(node) && node.host || // Fallback.
|
997
|
+
getDocumentElement(node);
|
998
|
+
return isShadowRoot(result) ? result.host : result;
|
999
|
+
}
|
1000
|
+
function getNearestOverflowAncestor(node) {
|
1001
|
+
const parentNode = getParentNode(node);
|
1002
|
+
if (isLastTraversableNode(parentNode)) {
|
1003
|
+
return node.ownerDocument ? node.ownerDocument.body : node.body;
|
1004
|
+
}
|
1005
|
+
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
1006
|
+
return parentNode;
|
1007
|
+
}
|
1008
|
+
return getNearestOverflowAncestor(parentNode);
|
1009
|
+
}
|
1010
|
+
function getOverflowAncestors(node, list, traverseIframes) {
|
1011
|
+
var _node$ownerDocument2;
|
1012
|
+
if (list === void 0) {
|
1013
|
+
list = [];
|
1014
|
+
}
|
1015
|
+
if (traverseIframes === void 0) {
|
1016
|
+
traverseIframes = true;
|
1017
|
+
}
|
1018
|
+
const scrollableAncestor = getNearestOverflowAncestor(node);
|
1019
|
+
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
1020
|
+
const win = getWindow(scrollableAncestor);
|
1021
|
+
if (isBody) {
|
1022
|
+
const frameElement = getFrameElement(win);
|
1023
|
+
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
|
1024
|
+
}
|
1025
|
+
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
1026
|
+
}
|
1027
|
+
function getFrameElement(win) {
|
1028
|
+
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
1029
|
+
}
|
1030
|
+
|
1031
|
+
function getCssDimensions(element) {
|
1032
|
+
const css = getComputedStyle$1(element);
|
1033
|
+
// In testing environments, the `width` and `height` properties are empty
|
1034
|
+
// strings for SVG elements, returning NaN. Fallback to `0` in this case.
|
1035
|
+
let width = parseFloat(css.width) || 0;
|
1036
|
+
let height = parseFloat(css.height) || 0;
|
1037
|
+
const hasOffset = isHTMLElement(element);
|
1038
|
+
const offsetWidth = hasOffset ? element.offsetWidth : width;
|
1039
|
+
const offsetHeight = hasOffset ? element.offsetHeight : height;
|
1040
|
+
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
|
1041
|
+
if (shouldFallback) {
|
1042
|
+
width = offsetWidth;
|
1043
|
+
height = offsetHeight;
|
1044
|
+
}
|
1045
|
+
return {
|
1046
|
+
width,
|
1047
|
+
height,
|
1048
|
+
$: shouldFallback
|
1049
|
+
};
|
1050
|
+
}
|
1051
|
+
function unwrapElement(element) {
|
1052
|
+
return !isElement(element) ? element.contextElement : element;
|
1053
|
+
}
|
1054
|
+
function getScale(element) {
|
1055
|
+
const domElement = unwrapElement(element);
|
1056
|
+
if (!isHTMLElement(domElement)) {
|
1057
|
+
return createCoords(1);
|
1058
|
+
}
|
1059
|
+
const rect = domElement.getBoundingClientRect();
|
1060
|
+
const { width, height, $ } = getCssDimensions(domElement);
|
1061
|
+
let x = ($ ? round(rect.width) : rect.width) / width;
|
1062
|
+
let y = ($ ? round(rect.height) : rect.height) / height;
|
1063
|
+
// 0, NaN, or Infinity should always fallback to 1.
|
1064
|
+
if (!x || !Number.isFinite(x)) {
|
1065
|
+
x = 1;
|
1066
|
+
}
|
1067
|
+
if (!y || !Number.isFinite(y)) {
|
1068
|
+
y = 1;
|
1069
|
+
}
|
1070
|
+
return {
|
1071
|
+
x,
|
1072
|
+
y
|
1073
|
+
};
|
1074
|
+
}
|
1075
|
+
const noOffsets = /*#__PURE__*/ createCoords(0);
|
1076
|
+
function getVisualOffsets(element) {
|
1077
|
+
const win = getWindow(element);
|
1078
|
+
if (!isWebKit() || !win.visualViewport) {
|
1079
|
+
return noOffsets;
|
1080
|
+
}
|
1081
|
+
return {
|
1082
|
+
x: win.visualViewport.offsetLeft,
|
1083
|
+
y: win.visualViewport.offsetTop
|
1084
|
+
};
|
1085
|
+
}
|
1086
|
+
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
|
1087
|
+
if (isFixed === void 0) {
|
1088
|
+
isFixed = false;
|
1089
|
+
}
|
1090
|
+
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
|
1091
|
+
return false;
|
1092
|
+
}
|
1093
|
+
return isFixed;
|
1094
|
+
}
|
1095
|
+
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
1096
|
+
if (includeScale === void 0) {
|
1097
|
+
includeScale = false;
|
1098
|
+
}
|
1099
|
+
if (isFixedStrategy === void 0) {
|
1100
|
+
isFixedStrategy = false;
|
1101
|
+
}
|
1102
|
+
const clientRect = element.getBoundingClientRect();
|
1103
|
+
const domElement = unwrapElement(element);
|
1104
|
+
let scale = createCoords(1);
|
1105
|
+
if (includeScale) {
|
1106
|
+
if (offsetParent) {
|
1107
|
+
if (isElement(offsetParent)) {
|
1108
|
+
scale = getScale(offsetParent);
|
1109
|
+
}
|
1110
|
+
} else {
|
1111
|
+
scale = getScale(element);
|
1112
|
+
}
|
1113
|
+
}
|
1114
|
+
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
|
1115
|
+
let x = (clientRect.left + visualOffsets.x) / scale.x;
|
1116
|
+
let y = (clientRect.top + visualOffsets.y) / scale.y;
|
1117
|
+
let width = clientRect.width / scale.x;
|
1118
|
+
let height = clientRect.height / scale.y;
|
1119
|
+
if (domElement) {
|
1120
|
+
const win = getWindow(domElement);
|
1121
|
+
const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
|
1122
|
+
let currentWin = win;
|
1123
|
+
let currentIFrame = getFrameElement(currentWin);
|
1124
|
+
while(currentIFrame && offsetParent && offsetWin !== currentWin){
|
1125
|
+
const iframeScale = getScale(currentIFrame);
|
1126
|
+
const iframeRect = currentIFrame.getBoundingClientRect();
|
1127
|
+
const css = getComputedStyle$1(currentIFrame);
|
1128
|
+
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
1129
|
+
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
1130
|
+
x *= iframeScale.x;
|
1131
|
+
y *= iframeScale.y;
|
1132
|
+
width *= iframeScale.x;
|
1133
|
+
height *= iframeScale.y;
|
1134
|
+
x += left;
|
1135
|
+
y += top;
|
1136
|
+
currentWin = getWindow(currentIFrame);
|
1137
|
+
currentIFrame = getFrameElement(currentWin);
|
1138
|
+
}
|
1139
|
+
}
|
1140
|
+
return rectToClientRect({
|
1141
|
+
width,
|
1142
|
+
height,
|
1143
|
+
x,
|
1144
|
+
y
|
1145
|
+
});
|
1146
|
+
}
|
1147
|
+
// If <html> has a CSS width greater than the viewport, then this will be
|
1148
|
+
// incorrect for RTL.
|
1149
|
+
function getWindowScrollBarX(element, rect) {
|
1150
|
+
const leftScroll = getNodeScroll(element).scrollLeft;
|
1151
|
+
if (!rect) {
|
1152
|
+
return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
|
1153
|
+
}
|
1154
|
+
return rect.left + leftScroll;
|
1155
|
+
}
|
1156
|
+
function getHTMLOffset(documentElement, scroll) {
|
1157
|
+
const htmlRect = documentElement.getBoundingClientRect();
|
1158
|
+
const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
|
1159
|
+
const y = htmlRect.top + scroll.scrollTop;
|
1160
|
+
return {
|
1161
|
+
x,
|
1162
|
+
y
|
1163
|
+
};
|
1164
|
+
}
|
1165
|
+
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
1166
|
+
let { elements, rect, offsetParent, strategy } = _ref;
|
1167
|
+
const isFixed = strategy === 'fixed';
|
1168
|
+
const documentElement = getDocumentElement(offsetParent);
|
1169
|
+
const topLayer = elements ? isTopLayer(elements.floating) : false;
|
1170
|
+
if (offsetParent === documentElement || topLayer && isFixed) {
|
1171
|
+
return rect;
|
1172
|
+
}
|
1173
|
+
let scroll = {
|
1174
|
+
scrollLeft: 0,
|
1175
|
+
scrollTop: 0
|
1176
|
+
};
|
1177
|
+
let scale = createCoords(1);
|
1178
|
+
const offsets = createCoords(0);
|
1179
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
1180
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
1181
|
+
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
1182
|
+
scroll = getNodeScroll(offsetParent);
|
1183
|
+
}
|
1184
|
+
if (isHTMLElement(offsetParent)) {
|
1185
|
+
const offsetRect = getBoundingClientRect(offsetParent);
|
1186
|
+
scale = getScale(offsetParent);
|
1187
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
1188
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
1189
|
+
}
|
1190
|
+
}
|
1191
|
+
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
1192
|
+
return {
|
1193
|
+
width: rect.width * scale.x,
|
1194
|
+
height: rect.height * scale.y,
|
1195
|
+
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
|
1196
|
+
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
|
1197
|
+
};
|
1198
|
+
}
|
1199
|
+
function getClientRects(element) {
|
1200
|
+
return Array.from(element.getClientRects());
|
1201
|
+
}
|
1202
|
+
// Gets the entire size of the scrollable document area, even extending outside
|
1203
|
+
// of the `<html>` and `<body>` rect bounds if horizontally scrollable.
|
1204
|
+
function getDocumentRect(element) {
|
1205
|
+
const html = getDocumentElement(element);
|
1206
|
+
const scroll = getNodeScroll(element);
|
1207
|
+
const body = element.ownerDocument.body;
|
1208
|
+
const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
|
1209
|
+
const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
|
1210
|
+
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
1211
|
+
const y = -scroll.scrollTop;
|
1212
|
+
if (getComputedStyle$1(body).direction === 'rtl') {
|
1213
|
+
x += max(html.clientWidth, body.clientWidth) - width;
|
1214
|
+
}
|
1215
|
+
return {
|
1216
|
+
width,
|
1217
|
+
height,
|
1218
|
+
x,
|
1219
|
+
y
|
1220
|
+
};
|
1221
|
+
}
|
1222
|
+
// Safety check: ensure the scrollbar space is reasonable in case this
|
1223
|
+
// calculation is affected by unusual styles.
|
1224
|
+
// Most scrollbars leave 15-18px of space.
|
1225
|
+
const SCROLLBAR_MAX = 25;
|
1226
|
+
function getViewportRect(element, strategy) {
|
1227
|
+
const win = getWindow(element);
|
1228
|
+
const html = getDocumentElement(element);
|
1229
|
+
const visualViewport = win.visualViewport;
|
1230
|
+
let width = html.clientWidth;
|
1231
|
+
let height = html.clientHeight;
|
1232
|
+
let x = 0;
|
1233
|
+
let y = 0;
|
1234
|
+
if (visualViewport) {
|
1235
|
+
width = visualViewport.width;
|
1236
|
+
height = visualViewport.height;
|
1237
|
+
const visualViewportBased = isWebKit();
|
1238
|
+
if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
|
1239
|
+
x = visualViewport.offsetLeft;
|
1240
|
+
y = visualViewport.offsetTop;
|
1241
|
+
}
|
1242
|
+
}
|
1243
|
+
const windowScrollbarX = getWindowScrollBarX(html);
|
1244
|
+
// <html> `overflow: hidden` + `scrollbar-gutter: stable` reduces the
|
1245
|
+
// visual width of the <html> but this is not considered in the size
|
1246
|
+
// of `html.clientWidth`.
|
1247
|
+
if (windowScrollbarX <= 0) {
|
1248
|
+
const doc = html.ownerDocument;
|
1249
|
+
const body = doc.body;
|
1250
|
+
const bodyStyles = getComputedStyle(body);
|
1251
|
+
const bodyMarginInline = doc.compatMode === 'CSS1Compat' ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
|
1252
|
+
const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
|
1253
|
+
if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
|
1254
|
+
width -= clippingStableScrollbarWidth;
|
1255
|
+
}
|
1256
|
+
} else if (windowScrollbarX <= SCROLLBAR_MAX) {
|
1257
|
+
// If the <body> scrollbar is on the left, the width needs to be extended
|
1258
|
+
// by the scrollbar amount so there isn't extra space on the right.
|
1259
|
+
width += windowScrollbarX;
|
1260
|
+
}
|
1261
|
+
return {
|
1262
|
+
width,
|
1263
|
+
height,
|
1264
|
+
x,
|
1265
|
+
y
|
1266
|
+
};
|
1267
|
+
}
|
1268
|
+
const absoluteOrFixed = /*#__PURE__*/ new Set([
|
1269
|
+
'absolute',
|
1270
|
+
'fixed'
|
1271
|
+
]);
|
1272
|
+
// Returns the inner client rect, subtracting scrollbars if present.
|
1273
|
+
function getInnerBoundingClientRect(element, strategy) {
|
1274
|
+
const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
|
1275
|
+
const top = clientRect.top + element.clientTop;
|
1276
|
+
const left = clientRect.left + element.clientLeft;
|
1277
|
+
const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
|
1278
|
+
const width = element.clientWidth * scale.x;
|
1279
|
+
const height = element.clientHeight * scale.y;
|
1280
|
+
const x = left * scale.x;
|
1281
|
+
const y = top * scale.y;
|
1282
|
+
return {
|
1283
|
+
width,
|
1284
|
+
height,
|
1285
|
+
x,
|
1286
|
+
y
|
1287
|
+
};
|
1288
|
+
}
|
1289
|
+
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
|
1290
|
+
let rect;
|
1291
|
+
if (clippingAncestor === 'viewport') {
|
1292
|
+
rect = getViewportRect(element, strategy);
|
1293
|
+
} else if (clippingAncestor === 'document') {
|
1294
|
+
rect = getDocumentRect(getDocumentElement(element));
|
1295
|
+
} else if (isElement(clippingAncestor)) {
|
1296
|
+
rect = getInnerBoundingClientRect(clippingAncestor, strategy);
|
1297
|
+
} else {
|
1298
|
+
const visualOffsets = getVisualOffsets(element);
|
1299
|
+
rect = {
|
1300
|
+
x: clippingAncestor.x - visualOffsets.x,
|
1301
|
+
y: clippingAncestor.y - visualOffsets.y,
|
1302
|
+
width: clippingAncestor.width,
|
1303
|
+
height: clippingAncestor.height
|
1304
|
+
};
|
1305
|
+
}
|
1306
|
+
return rectToClientRect(rect);
|
1307
|
+
}
|
1308
|
+
function hasFixedPositionAncestor(element, stopNode) {
|
1309
|
+
const parentNode = getParentNode(element);
|
1310
|
+
if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
|
1311
|
+
return false;
|
1312
|
+
}
|
1313
|
+
return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
|
1314
|
+
}
|
1315
|
+
// A "clipping ancestor" is an `overflow` element with the characteristic of
|
1316
|
+
// clipping (or hiding) child elements. This returns all clipping ancestors
|
1317
|
+
// of the given element up the tree.
|
1318
|
+
function getClippingElementAncestors(element, cache) {
|
1319
|
+
const cachedResult = cache.get(element);
|
1320
|
+
if (cachedResult) {
|
1321
|
+
return cachedResult;
|
1322
|
+
}
|
1323
|
+
let result = getOverflowAncestors(element, [], false).filter((el)=>isElement(el) && getNodeName(el) !== 'body');
|
1324
|
+
let currentContainingBlockComputedStyle = null;
|
1325
|
+
const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
|
1326
|
+
let currentNode = elementIsFixed ? getParentNode(element) : element;
|
1327
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
1328
|
+
while(isElement(currentNode) && !isLastTraversableNode(currentNode)){
|
1329
|
+
const computedStyle = getComputedStyle$1(currentNode);
|
1330
|
+
const currentNodeIsContaining = isContainingBlock(currentNode);
|
1331
|
+
if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
|
1332
|
+
currentContainingBlockComputedStyle = null;
|
1333
|
+
}
|
1334
|
+
const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && absoluteOrFixed.has(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
|
1335
|
+
if (shouldDropCurrentNode) {
|
1336
|
+
// Drop non-containing blocks.
|
1337
|
+
result = result.filter((ancestor)=>ancestor !== currentNode);
|
1338
|
+
} else {
|
1339
|
+
// Record last containing block for next iteration.
|
1340
|
+
currentContainingBlockComputedStyle = computedStyle;
|
1341
|
+
}
|
1342
|
+
currentNode = getParentNode(currentNode);
|
1343
|
+
}
|
1344
|
+
cache.set(element, result);
|
1345
|
+
return result;
|
1346
|
+
}
|
1347
|
+
// Gets the maximum area that the element is visible in due to any number of
|
1348
|
+
// clipping ancestors.
|
1349
|
+
function getClippingRect(_ref) {
|
1350
|
+
let { element, boundary, rootBoundary, strategy } = _ref;
|
1351
|
+
const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
1352
|
+
const clippingAncestors = [
|
1353
|
+
...elementClippingAncestors,
|
1354
|
+
rootBoundary
|
1355
|
+
];
|
1356
|
+
const firstClippingAncestor = clippingAncestors[0];
|
1357
|
+
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor)=>{
|
1358
|
+
const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
|
1359
|
+
accRect.top = max(rect.top, accRect.top);
|
1360
|
+
accRect.right = min(rect.right, accRect.right);
|
1361
|
+
accRect.bottom = min(rect.bottom, accRect.bottom);
|
1362
|
+
accRect.left = max(rect.left, accRect.left);
|
1363
|
+
return accRect;
|
1364
|
+
}, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
|
1365
|
+
return {
|
1366
|
+
width: clippingRect.right - clippingRect.left,
|
1367
|
+
height: clippingRect.bottom - clippingRect.top,
|
1368
|
+
x: clippingRect.left,
|
1369
|
+
y: clippingRect.top
|
1370
|
+
};
|
1371
|
+
}
|
1372
|
+
function getDimensions(element) {
|
1373
|
+
const { width, height } = getCssDimensions(element);
|
1374
|
+
return {
|
1375
|
+
width,
|
1376
|
+
height
|
1377
|
+
};
|
1378
|
+
}
|
1379
|
+
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
1380
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
1381
|
+
const documentElement = getDocumentElement(offsetParent);
|
1382
|
+
const isFixed = strategy === 'fixed';
|
1383
|
+
const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
|
1384
|
+
let scroll = {
|
1385
|
+
scrollLeft: 0,
|
1386
|
+
scrollTop: 0
|
1387
|
+
};
|
1388
|
+
const offsets = createCoords(0);
|
1389
|
+
// If the <body> scrollbar appears on the left (e.g. RTL systems). Use
|
1390
|
+
// Firefox with layout.scrollbar.side = 3 in about:config to test this.
|
1391
|
+
function setLeftRTLScrollbarOffset() {
|
1392
|
+
offsets.x = getWindowScrollBarX(documentElement);
|
1393
|
+
}
|
1394
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
1395
|
+
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
1396
|
+
scroll = getNodeScroll(offsetParent);
|
1397
|
+
}
|
1398
|
+
if (isOffsetParentAnElement) {
|
1399
|
+
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
|
1400
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
1401
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
1402
|
+
} else if (documentElement) {
|
1403
|
+
setLeftRTLScrollbarOffset();
|
1404
|
+
}
|
1405
|
+
}
|
1406
|
+
if (isFixed && !isOffsetParentAnElement && documentElement) {
|
1407
|
+
setLeftRTLScrollbarOffset();
|
1408
|
+
}
|
1409
|
+
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
1410
|
+
const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
|
1411
|
+
const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
|
1412
|
+
return {
|
1413
|
+
x,
|
1414
|
+
y,
|
1415
|
+
width: rect.width,
|
1416
|
+
height: rect.height
|
1417
|
+
};
|
1418
|
+
}
|
1419
|
+
function isStaticPositioned(element) {
|
1420
|
+
return getComputedStyle$1(element).position === 'static';
|
1421
|
+
}
|
1422
|
+
function getTrueOffsetParent(element, polyfill) {
|
1423
|
+
if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
|
1424
|
+
return null;
|
1425
|
+
}
|
1426
|
+
if (polyfill) {
|
1427
|
+
return polyfill(element);
|
1428
|
+
}
|
1429
|
+
let rawOffsetParent = element.offsetParent;
|
1430
|
+
// Firefox returns the <html> element as the offsetParent if it's non-static,
|
1431
|
+
// while Chrome and Safari return the <body> element. The <body> element must
|
1432
|
+
// be used to perform the correct calculations even if the <html> element is
|
1433
|
+
// non-static.
|
1434
|
+
if (getDocumentElement(element) === rawOffsetParent) {
|
1435
|
+
rawOffsetParent = rawOffsetParent.ownerDocument.body;
|
1436
|
+
}
|
1437
|
+
return rawOffsetParent;
|
1438
|
+
}
|
1439
|
+
// Gets the closest ancestor positioned element. Handles some edge cases,
|
1440
|
+
// such as table ancestors and cross browser bugs.
|
1441
|
+
function getOffsetParent(element, polyfill) {
|
1442
|
+
const win = getWindow(element);
|
1443
|
+
if (isTopLayer(element)) {
|
1444
|
+
return win;
|
1445
|
+
}
|
1446
|
+
if (!isHTMLElement(element)) {
|
1447
|
+
let svgOffsetParent = getParentNode(element);
|
1448
|
+
while(svgOffsetParent && !isLastTraversableNode(svgOffsetParent)){
|
1449
|
+
if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
|
1450
|
+
return svgOffsetParent;
|
1451
|
+
}
|
1452
|
+
svgOffsetParent = getParentNode(svgOffsetParent);
|
1453
|
+
}
|
1454
|
+
return win;
|
1455
|
+
}
|
1456
|
+
let offsetParent = getTrueOffsetParent(element, polyfill);
|
1457
|
+
while(offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)){
|
1458
|
+
offsetParent = getTrueOffsetParent(offsetParent, polyfill);
|
1459
|
+
}
|
1460
|
+
if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
|
1461
|
+
return win;
|
1462
|
+
}
|
1463
|
+
return offsetParent || getContainingBlock(element) || win;
|
1464
|
+
}
|
1465
|
+
const getElementRects = async function(data) {
|
1466
|
+
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
1467
|
+
const getDimensionsFn = this.getDimensions;
|
1468
|
+
const floatingDimensions = await getDimensionsFn(data.floating);
|
1469
|
+
return {
|
1470
|
+
reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
|
1471
|
+
floating: {
|
1472
|
+
x: 0,
|
1473
|
+
y: 0,
|
1474
|
+
width: floatingDimensions.width,
|
1475
|
+
height: floatingDimensions.height
|
1476
|
+
}
|
1477
|
+
};
|
1478
|
+
};
|
1479
|
+
function isRTL(element) {
|
1480
|
+
return getComputedStyle$1(element).direction === 'rtl';
|
1481
|
+
}
|
1482
|
+
const platform = {
|
1483
|
+
convertOffsetParentRelativeRectToViewportRelativeRect,
|
1484
|
+
getDocumentElement,
|
1485
|
+
getClippingRect,
|
1486
|
+
getOffsetParent,
|
1487
|
+
getElementRects,
|
1488
|
+
getClientRects,
|
1489
|
+
getDimensions,
|
1490
|
+
getScale,
|
1491
|
+
isElement,
|
1492
|
+
isRTL
|
1493
|
+
};
|
1494
|
+
function rectsAreEqual(a, b) {
|
1495
|
+
return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
|
1496
|
+
}
|
1497
|
+
// https://samthor.au/2021/observing-dom/
|
1498
|
+
function observeMove(element, onMove) {
|
1499
|
+
let io = null;
|
1500
|
+
let timeoutId;
|
1501
|
+
const root = getDocumentElement(element);
|
1502
|
+
function cleanup() {
|
1503
|
+
var _io;
|
1504
|
+
clearTimeout(timeoutId);
|
1505
|
+
(_io = io) == null || _io.disconnect();
|
1506
|
+
io = null;
|
1507
|
+
}
|
1508
|
+
function refresh(skip, threshold) {
|
1509
|
+
if (skip === void 0) {
|
1510
|
+
skip = false;
|
1511
|
+
}
|
1512
|
+
if (threshold === void 0) {
|
1513
|
+
threshold = 1;
|
1514
|
+
}
|
1515
|
+
cleanup();
|
1516
|
+
const elementRectForRootMargin = element.getBoundingClientRect();
|
1517
|
+
const { left, top, width, height } = elementRectForRootMargin;
|
1518
|
+
if (!skip) {
|
1519
|
+
onMove();
|
1520
|
+
}
|
1521
|
+
if (!width || !height) {
|
1522
|
+
return;
|
1523
|
+
}
|
1524
|
+
const insetTop = floor(top);
|
1525
|
+
const insetRight = floor(root.clientWidth - (left + width));
|
1526
|
+
const insetBottom = floor(root.clientHeight - (top + height));
|
1527
|
+
const insetLeft = floor(left);
|
1528
|
+
const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
|
1529
|
+
const options = {
|
1530
|
+
rootMargin,
|
1531
|
+
threshold: max(0, min(1, threshold)) || 1
|
1532
|
+
};
|
1533
|
+
let isFirstUpdate = true;
|
1534
|
+
function handleObserve(entries) {
|
1535
|
+
const ratio = entries[0].intersectionRatio;
|
1536
|
+
if (ratio !== threshold) {
|
1537
|
+
if (!isFirstUpdate) {
|
1538
|
+
return refresh();
|
1539
|
+
}
|
1540
|
+
if (!ratio) {
|
1541
|
+
// If the reference is clipped, the ratio is 0. Throttle the refresh
|
1542
|
+
// to prevent an infinite loop of updates.
|
1543
|
+
timeoutId = setTimeout(()=>{
|
1544
|
+
refresh(false, 1e-7);
|
1545
|
+
}, 1000);
|
1546
|
+
} else {
|
1547
|
+
refresh(false, ratio);
|
1548
|
+
}
|
1549
|
+
}
|
1550
|
+
if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
|
1551
|
+
// It's possible that even though the ratio is reported as 1, the
|
1552
|
+
// element is not actually fully within the IntersectionObserver's root
|
1553
|
+
// area anymore. This can happen under performance constraints. This may
|
1554
|
+
// be a bug in the browser's IntersectionObserver implementation. To
|
1555
|
+
// work around this, we compare the element's bounding rect now with
|
1556
|
+
// what it was at the time we created the IntersectionObserver. If they
|
1557
|
+
// are not equal then the element moved, so we refresh.
|
1558
|
+
refresh();
|
1559
|
+
}
|
1560
|
+
isFirstUpdate = false;
|
1561
|
+
}
|
1562
|
+
// Older browsers don't support a `document` as the root and will throw an
|
1563
|
+
// error.
|
1564
|
+
try {
|
1565
|
+
io = new IntersectionObserver(handleObserve, {
|
1566
|
+
...options,
|
1567
|
+
// Handle <iframe>s
|
1568
|
+
root: root.ownerDocument
|
1569
|
+
});
|
1570
|
+
} catch (_e) {
|
1571
|
+
io = new IntersectionObserver(handleObserve, options);
|
1572
|
+
}
|
1573
|
+
io.observe(element);
|
1574
|
+
}
|
1575
|
+
refresh(true);
|
1576
|
+
return cleanup;
|
1577
|
+
}
|
1578
|
+
/**
|
1579
|
+
* Automatically updates the position of the floating element when necessary.
|
1580
|
+
* Should only be called when the floating element is mounted on the DOM or
|
1581
|
+
* visible on the screen.
|
1582
|
+
* @returns cleanup function that should be invoked when the floating element is
|
1583
|
+
* removed from the DOM or hidden from the screen.
|
1584
|
+
* @see https://floating-ui.com/docs/autoUpdate
|
1585
|
+
*/ function autoUpdate(reference, floating, update, options) {
|
1586
|
+
if (options === void 0) {
|
1587
|
+
options = {};
|
1588
|
+
}
|
1589
|
+
const { ancestorScroll = true, ancestorResize = true, elementResize = typeof ResizeObserver === 'function', layoutShift = typeof IntersectionObserver === 'function', animationFrame = false } = options;
|
1590
|
+
const referenceEl = unwrapElement(reference);
|
1591
|
+
const ancestors = ancestorScroll || ancestorResize ? [
|
1592
|
+
...referenceEl ? getOverflowAncestors(referenceEl) : [],
|
1593
|
+
...getOverflowAncestors(floating)
|
1594
|
+
] : [];
|
1595
|
+
ancestors.forEach((ancestor)=>{
|
1596
|
+
ancestorScroll && ancestor.addEventListener('scroll', update, {
|
1597
|
+
passive: true
|
1598
|
+
});
|
1599
|
+
ancestorResize && ancestor.addEventListener('resize', update);
|
1600
|
+
});
|
1601
|
+
const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
|
1602
|
+
let reobserveFrame = -1;
|
1603
|
+
let resizeObserver = null;
|
1604
|
+
if (elementResize) {
|
1605
|
+
resizeObserver = new ResizeObserver((_ref)=>{
|
1606
|
+
let [firstEntry] = _ref;
|
1607
|
+
if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
|
1608
|
+
// Prevent update loops when using the `size` middleware.
|
1609
|
+
// https://github.com/floating-ui/floating-ui/issues/1740
|
1610
|
+
resizeObserver.unobserve(floating);
|
1611
|
+
cancelAnimationFrame(reobserveFrame);
|
1612
|
+
reobserveFrame = requestAnimationFrame(()=>{
|
1613
|
+
var _resizeObserver;
|
1614
|
+
(_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
|
1615
|
+
});
|
1616
|
+
}
|
1617
|
+
update();
|
1618
|
+
});
|
1619
|
+
if (referenceEl && !animationFrame) {
|
1620
|
+
resizeObserver.observe(referenceEl);
|
1621
|
+
}
|
1622
|
+
resizeObserver.observe(floating);
|
1623
|
+
}
|
1624
|
+
let frameId;
|
1625
|
+
let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
|
1626
|
+
if (animationFrame) {
|
1627
|
+
frameLoop();
|
1628
|
+
}
|
1629
|
+
function frameLoop() {
|
1630
|
+
const nextRefRect = getBoundingClientRect(reference);
|
1631
|
+
if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
|
1632
|
+
update();
|
1633
|
+
}
|
1634
|
+
prevRefRect = nextRefRect;
|
1635
|
+
frameId = requestAnimationFrame(frameLoop);
|
1636
|
+
}
|
1637
|
+
update();
|
1638
|
+
return ()=>{
|
1639
|
+
var _resizeObserver2;
|
1640
|
+
ancestors.forEach((ancestor)=>{
|
1641
|
+
ancestorScroll && ancestor.removeEventListener('scroll', update);
|
1642
|
+
ancestorResize && ancestor.removeEventListener('resize', update);
|
1643
|
+
});
|
1644
|
+
cleanupIo == null || cleanupIo();
|
1645
|
+
(_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
|
1646
|
+
resizeObserver = null;
|
1647
|
+
if (animationFrame) {
|
1648
|
+
cancelAnimationFrame(frameId);
|
1649
|
+
}
|
1650
|
+
};
|
1651
|
+
}
|
1652
|
+
/**
|
1653
|
+
* Modifies the placement by translating the floating element along the
|
1654
|
+
* specified axes.
|
1655
|
+
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
1656
|
+
* object may be passed.
|
1657
|
+
* @see https://floating-ui.com/docs/offset
|
1658
|
+
*/ const offset$1 = offset$2;
|
1659
|
+
/**
|
1660
|
+
* Optimizes the visibility of the floating element by shifting it in order to
|
1661
|
+
* keep it in view when it will overflow the clipping boundary.
|
1662
|
+
* @see https://floating-ui.com/docs/shift
|
1663
|
+
*/ const shift$1 = shift$2;
|
1664
|
+
/**
|
1665
|
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
1666
|
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
1667
|
+
* clipping boundary. Alternative to `autoPlacement`.
|
1668
|
+
* @see https://floating-ui.com/docs/flip
|
1669
|
+
*/ const flip$1 = flip$2;
|
1670
|
+
/**
|
1671
|
+
* Provides data that allows you to change the size of the floating element —
|
1672
|
+
* for instance, prevent it from overflowing the clipping boundary or match the
|
1673
|
+
* width of the reference element.
|
1674
|
+
* @see https://floating-ui.com/docs/size
|
1675
|
+
*/ const size$1 = size$2;
|
1676
|
+
/**
|
1677
|
+
* Provides data to hide the floating element in applicable situations, such as
|
1678
|
+
* when it is not in the same clipping context as the reference element.
|
1679
|
+
* @see https://floating-ui.com/docs/hide
|
1680
|
+
*/ const hide$1 = hide$2;
|
1681
|
+
/**
|
1682
|
+
* Provides data to position an inner element of the floating element so that it
|
1683
|
+
* appears centered to the reference element.
|
1684
|
+
* @see https://floating-ui.com/docs/arrow
|
1685
|
+
*/ const arrow$2 = arrow$3;
|
1686
|
+
/**
|
1687
|
+
* Built-in `limiter` that will stop `shift()` at a certain point.
|
1688
|
+
*/ const limitShift$1 = limitShift$2;
|
1689
|
+
/**
|
1690
|
+
* Computes the `x` and `y` coordinates that will place the floating element
|
1691
|
+
* next to a given reference element.
|
1692
|
+
*/ const computePosition = (reference, floating, options)=>{
|
1693
|
+
// This caches the expensive `getClippingElementAncestors` function so that
|
1694
|
+
// multiple lifecycle resets re-use the same result. It only lives for a
|
1695
|
+
// single call. If other functions become expensive, we can add them as well.
|
1696
|
+
const cache = new Map();
|
1697
|
+
const mergedOptions = {
|
1698
|
+
platform,
|
1699
|
+
...options
|
1700
|
+
};
|
1701
|
+
const platformWithCache = {
|
1702
|
+
...mergedOptions.platform,
|
1703
|
+
_c: cache
|
1704
|
+
};
|
1705
|
+
return computePosition$1(reference, floating, {
|
1706
|
+
...mergedOptions,
|
1707
|
+
platform: platformWithCache
|
1708
|
+
});
|
1709
|
+
};
|
1710
|
+
|
1711
|
+
var isClient = typeof document !== 'undefined';
|
1712
|
+
var noop = function noop() {};
|
1713
|
+
var index = isClient ? useLayoutEffect : noop;
|
1714
|
+
// Fork of `fast-deep-equal` that only does the comparisons we need and compares
|
1715
|
+
// functions
|
1716
|
+
function deepEqual(a, b) {
|
1717
|
+
if (a === b) {
|
1718
|
+
return true;
|
1719
|
+
}
|
1720
|
+
if (typeof a !== typeof b) {
|
1721
|
+
return false;
|
1722
|
+
}
|
1723
|
+
if (typeof a === 'function' && a.toString() === b.toString()) {
|
1724
|
+
return true;
|
1725
|
+
}
|
1726
|
+
let length;
|
1727
|
+
let i;
|
1728
|
+
let keys;
|
1729
|
+
if (a && b && typeof a === 'object') {
|
1730
|
+
if (Array.isArray(a)) {
|
1731
|
+
length = a.length;
|
1732
|
+
if (length !== b.length) return false;
|
1733
|
+
for(i = length; i-- !== 0;){
|
1734
|
+
if (!deepEqual(a[i], b[i])) {
|
1735
|
+
return false;
|
1736
|
+
}
|
1737
|
+
}
|
1738
|
+
return true;
|
1739
|
+
}
|
1740
|
+
keys = Object.keys(a);
|
1741
|
+
length = keys.length;
|
1742
|
+
if (length !== Object.keys(b).length) {
|
1743
|
+
return false;
|
1744
|
+
}
|
1745
|
+
for(i = length; i-- !== 0;){
|
1746
|
+
if (!({}).hasOwnProperty.call(b, keys[i])) {
|
1747
|
+
return false;
|
1748
|
+
}
|
1749
|
+
}
|
1750
|
+
for(i = length; i-- !== 0;){
|
1751
|
+
const key = keys[i];
|
1752
|
+
if (key === '_owner' && a.$$typeof) {
|
1753
|
+
continue;
|
1754
|
+
}
|
1755
|
+
if (!deepEqual(a[key], b[key])) {
|
1756
|
+
return false;
|
1757
|
+
}
|
1758
|
+
}
|
1759
|
+
return true;
|
1760
|
+
}
|
1761
|
+
return a !== a && b !== b;
|
1762
|
+
}
|
1763
|
+
function getDPR(element) {
|
1764
|
+
if (typeof window === 'undefined') {
|
1765
|
+
return 1;
|
1766
|
+
}
|
1767
|
+
const win = element.ownerDocument.defaultView || window;
|
1768
|
+
return win.devicePixelRatio || 1;
|
1769
|
+
}
|
1770
|
+
function roundByDPR(element, value) {
|
1771
|
+
const dpr = getDPR(element);
|
1772
|
+
return Math.round(value * dpr) / dpr;
|
1773
|
+
}
|
1774
|
+
function useLatestRef(value) {
|
1775
|
+
const ref = React.useRef(value);
|
1776
|
+
index(()=>{
|
1777
|
+
ref.current = value;
|
1778
|
+
});
|
1779
|
+
return ref;
|
1780
|
+
}
|
1781
|
+
/**
|
1782
|
+
* Provides data to position a floating element.
|
1783
|
+
* @see https://floating-ui.com/docs/useFloating
|
1784
|
+
*/ function useFloating(options) {
|
1785
|
+
if (options === void 0) {
|
1786
|
+
options = {};
|
1787
|
+
}
|
1788
|
+
const { placement = 'bottom', strategy = 'absolute', middleware = [], platform, elements: { reference: externalReference, floating: externalFloating } = {}, transform = true, whileElementsMounted, open } = options;
|
1789
|
+
const [data, setData] = React.useState({
|
1790
|
+
x: 0,
|
1791
|
+
y: 0,
|
1792
|
+
strategy,
|
1793
|
+
placement,
|
1794
|
+
middlewareData: {},
|
1795
|
+
isPositioned: false
|
1796
|
+
});
|
1797
|
+
const [latestMiddleware, setLatestMiddleware] = React.useState(middleware);
|
1798
|
+
if (!deepEqual(latestMiddleware, middleware)) {
|
1799
|
+
setLatestMiddleware(middleware);
|
1800
|
+
}
|
1801
|
+
const [_reference, _setReference] = React.useState(null);
|
1802
|
+
const [_floating, _setFloating] = React.useState(null);
|
1803
|
+
const setReference = React.useCallback((node)=>{
|
1804
|
+
if (node !== referenceRef.current) {
|
1805
|
+
referenceRef.current = node;
|
1806
|
+
_setReference(node);
|
1807
|
+
}
|
1808
|
+
}, []);
|
1809
|
+
const setFloating = React.useCallback((node)=>{
|
1810
|
+
if (node !== floatingRef.current) {
|
1811
|
+
floatingRef.current = node;
|
1812
|
+
_setFloating(node);
|
1813
|
+
}
|
1814
|
+
}, []);
|
1815
|
+
const referenceEl = externalReference || _reference;
|
1816
|
+
const floatingEl = externalFloating || _floating;
|
1817
|
+
const referenceRef = React.useRef(null);
|
1818
|
+
const floatingRef = React.useRef(null);
|
1819
|
+
const dataRef = React.useRef(data);
|
1820
|
+
const hasWhileElementsMounted = whileElementsMounted != null;
|
1821
|
+
const whileElementsMountedRef = useLatestRef(whileElementsMounted);
|
1822
|
+
const platformRef = useLatestRef(platform);
|
1823
|
+
const openRef = useLatestRef(open);
|
1824
|
+
const update = React.useCallback(()=>{
|
1825
|
+
if (!referenceRef.current || !floatingRef.current) {
|
1826
|
+
return;
|
1827
|
+
}
|
1828
|
+
const config = {
|
1829
|
+
placement,
|
1830
|
+
strategy,
|
1831
|
+
middleware: latestMiddleware
|
1832
|
+
};
|
1833
|
+
if (platformRef.current) {
|
1834
|
+
config.platform = platformRef.current;
|
1835
|
+
}
|
1836
|
+
computePosition(referenceRef.current, floatingRef.current, config).then((data)=>{
|
1837
|
+
const fullData = {
|
1838
|
+
...data,
|
1839
|
+
// The floating element's position may be recomputed while it's closed
|
1840
|
+
// but still mounted (such as when transitioning out). To ensure
|
1841
|
+
// `isPositioned` will be `false` initially on the next open, avoid
|
1842
|
+
// setting it to `true` when `open === false` (must be specified).
|
1843
|
+
isPositioned: openRef.current !== false
|
1844
|
+
};
|
1845
|
+
if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
|
1846
|
+
dataRef.current = fullData;
|
1847
|
+
ReactDOM.flushSync(()=>{
|
1848
|
+
setData(fullData);
|
1849
|
+
});
|
1850
|
+
}
|
1851
|
+
});
|
1852
|
+
}, [
|
1853
|
+
latestMiddleware,
|
1854
|
+
placement,
|
1855
|
+
strategy,
|
1856
|
+
platformRef,
|
1857
|
+
openRef
|
1858
|
+
]);
|
1859
|
+
index(()=>{
|
1860
|
+
if (open === false && dataRef.current.isPositioned) {
|
1861
|
+
dataRef.current.isPositioned = false;
|
1862
|
+
setData((data)=>({
|
1863
|
+
...data,
|
1864
|
+
isPositioned: false
|
1865
|
+
}));
|
1866
|
+
}
|
1867
|
+
}, [
|
1868
|
+
open
|
1869
|
+
]);
|
1870
|
+
const isMountedRef = React.useRef(false);
|
1871
|
+
index(()=>{
|
1872
|
+
isMountedRef.current = true;
|
1873
|
+
return ()=>{
|
1874
|
+
isMountedRef.current = false;
|
1875
|
+
};
|
1876
|
+
}, []);
|
1877
|
+
index(()=>{
|
1878
|
+
if (referenceEl) referenceRef.current = referenceEl;
|
1879
|
+
if (floatingEl) floatingRef.current = floatingEl;
|
1880
|
+
if (referenceEl && floatingEl) {
|
1881
|
+
if (whileElementsMountedRef.current) {
|
1882
|
+
return whileElementsMountedRef.current(referenceEl, floatingEl, update);
|
1883
|
+
}
|
1884
|
+
update();
|
1885
|
+
}
|
1886
|
+
}, [
|
1887
|
+
referenceEl,
|
1888
|
+
floatingEl,
|
1889
|
+
update,
|
1890
|
+
whileElementsMountedRef,
|
1891
|
+
hasWhileElementsMounted
|
1892
|
+
]);
|
1893
|
+
const refs = React.useMemo(()=>({
|
1894
|
+
reference: referenceRef,
|
1895
|
+
floating: floatingRef,
|
1896
|
+
setReference,
|
1897
|
+
setFloating
|
1898
|
+
}), [
|
1899
|
+
setReference,
|
1900
|
+
setFloating
|
1901
|
+
]);
|
1902
|
+
const elements = React.useMemo(()=>({
|
1903
|
+
reference: referenceEl,
|
1904
|
+
floating: floatingEl
|
1905
|
+
}), [
|
1906
|
+
referenceEl,
|
1907
|
+
floatingEl
|
1908
|
+
]);
|
1909
|
+
const floatingStyles = React.useMemo(()=>{
|
1910
|
+
const initialStyles = {
|
1911
|
+
position: strategy,
|
1912
|
+
left: 0,
|
1913
|
+
top: 0
|
1914
|
+
};
|
1915
|
+
if (!elements.floating) {
|
1916
|
+
return initialStyles;
|
1917
|
+
}
|
1918
|
+
const x = roundByDPR(elements.floating, data.x);
|
1919
|
+
const y = roundByDPR(elements.floating, data.y);
|
1920
|
+
if (transform) {
|
1921
|
+
return {
|
1922
|
+
...initialStyles,
|
1923
|
+
transform: "translate(" + x + "px, " + y + "px)",
|
1924
|
+
...getDPR(elements.floating) >= 1.5 && {
|
1925
|
+
willChange: 'transform'
|
1926
|
+
}
|
1927
|
+
};
|
1928
|
+
}
|
1929
|
+
return {
|
1930
|
+
position: strategy,
|
1931
|
+
left: x,
|
1932
|
+
top: y
|
1933
|
+
};
|
1934
|
+
}, [
|
1935
|
+
strategy,
|
1936
|
+
transform,
|
1937
|
+
elements.floating,
|
1938
|
+
data.x,
|
1939
|
+
data.y
|
1940
|
+
]);
|
1941
|
+
return React.useMemo(()=>({
|
1942
|
+
...data,
|
1943
|
+
update,
|
1944
|
+
refs,
|
1945
|
+
elements,
|
1946
|
+
floatingStyles
|
1947
|
+
}), [
|
1948
|
+
data,
|
1949
|
+
update,
|
1950
|
+
refs,
|
1951
|
+
elements,
|
1952
|
+
floatingStyles
|
1953
|
+
]);
|
1954
|
+
}
|
1955
|
+
/**
|
1956
|
+
* Provides data to position an inner element of the floating element so that it
|
1957
|
+
* appears centered to the reference element.
|
1958
|
+
* This wraps the core `arrow` middleware to allow React refs as the element.
|
1959
|
+
* @see https://floating-ui.com/docs/arrow
|
1960
|
+
*/ const arrow$1 = (options)=>{
|
1961
|
+
function isRef(value) {
|
1962
|
+
return ({}).hasOwnProperty.call(value, 'current');
|
1963
|
+
}
|
1964
|
+
return {
|
1965
|
+
name: 'arrow',
|
1966
|
+
options,
|
1967
|
+
fn (state) {
|
1968
|
+
const { element, padding } = typeof options === 'function' ? options(state) : options;
|
1969
|
+
if (element && isRef(element)) {
|
1970
|
+
if (element.current != null) {
|
1971
|
+
return arrow$2({
|
1972
|
+
element: element.current,
|
1973
|
+
padding
|
1974
|
+
}).fn(state);
|
1975
|
+
}
|
1976
|
+
return {};
|
1977
|
+
}
|
1978
|
+
if (element) {
|
1979
|
+
return arrow$2({
|
1980
|
+
element,
|
1981
|
+
padding
|
1982
|
+
}).fn(state);
|
1983
|
+
}
|
1984
|
+
return {};
|
1985
|
+
}
|
1986
|
+
};
|
1987
|
+
};
|
1988
|
+
/**
|
1989
|
+
* Modifies the placement by translating the floating element along the
|
1990
|
+
* specified axes.
|
1991
|
+
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
1992
|
+
* object may be passed.
|
1993
|
+
* @see https://floating-ui.com/docs/offset
|
1994
|
+
*/ const offset = (options, deps)=>({
|
1995
|
+
...offset$1(options),
|
1996
|
+
options: [
|
1997
|
+
options,
|
1998
|
+
deps
|
1999
|
+
]
|
2000
|
+
});
|
2001
|
+
/**
|
2002
|
+
* Optimizes the visibility of the floating element by shifting it in order to
|
2003
|
+
* keep it in view when it will overflow the clipping boundary.
|
2004
|
+
* @see https://floating-ui.com/docs/shift
|
2005
|
+
*/ const shift = (options, deps)=>({
|
2006
|
+
...shift$1(options),
|
2007
|
+
options: [
|
2008
|
+
options,
|
2009
|
+
deps
|
2010
|
+
]
|
2011
|
+
});
|
2012
|
+
/**
|
2013
|
+
* Built-in `limiter` that will stop `shift()` at a certain point.
|
2014
|
+
*/ const limitShift = (options, deps)=>({
|
2015
|
+
...limitShift$1(options),
|
2016
|
+
options: [
|
2017
|
+
options,
|
2018
|
+
deps
|
2019
|
+
]
|
2020
|
+
});
|
2021
|
+
/**
|
2022
|
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
2023
|
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
2024
|
+
* clipping boundary. Alternative to `autoPlacement`.
|
2025
|
+
* @see https://floating-ui.com/docs/flip
|
2026
|
+
*/ const flip = (options, deps)=>({
|
2027
|
+
...flip$1(options),
|
2028
|
+
options: [
|
2029
|
+
options,
|
2030
|
+
deps
|
2031
|
+
]
|
2032
|
+
});
|
2033
|
+
/**
|
2034
|
+
* Provides data that allows you to change the size of the floating element —
|
2035
|
+
* for instance, prevent it from overflowing the clipping boundary or match the
|
2036
|
+
* width of the reference element.
|
2037
|
+
* @see https://floating-ui.com/docs/size
|
2038
|
+
*/ const size = (options, deps)=>({
|
2039
|
+
...size$1(options),
|
2040
|
+
options: [
|
2041
|
+
options,
|
2042
|
+
deps
|
2043
|
+
]
|
2044
|
+
});
|
2045
|
+
/**
|
2046
|
+
* Provides data to hide the floating element in applicable situations, such as
|
2047
|
+
* when it is not in the same clipping context as the reference element.
|
2048
|
+
* @see https://floating-ui.com/docs/hide
|
2049
|
+
*/ const hide = (options, deps)=>({
|
2050
|
+
...hide$1(options),
|
2051
|
+
options: [
|
2052
|
+
options,
|
2053
|
+
deps
|
2054
|
+
]
|
2055
|
+
});
|
2056
|
+
/**
|
2057
|
+
* Provides data to position an inner element of the floating element so that it
|
2058
|
+
* appears centered to the reference element.
|
2059
|
+
* This wraps the core `arrow` middleware to allow React refs as the element.
|
2060
|
+
* @see https://floating-ui.com/docs/arrow
|
2061
|
+
*/ const arrow = (options, deps)=>({
|
2062
|
+
...arrow$1(options),
|
2063
|
+
options: [
|
2064
|
+
options,
|
2065
|
+
deps
|
2066
|
+
]
|
2067
|
+
});
|
2068
|
+
|
2069
|
+
// src/arrow.tsx
|
2070
|
+
var NAME = "Arrow";
|
2071
|
+
var Arrow$1 = React.forwardRef((props, forwardedRef)=>{
|
2072
|
+
const { children, width = 10, height = 5, ...arrowProps } = props;
|
2073
|
+
return /* @__PURE__ */ jsx(Primitive.svg, {
|
2074
|
+
...arrowProps,
|
2075
|
+
ref: forwardedRef,
|
2076
|
+
width,
|
2077
|
+
height,
|
2078
|
+
viewBox: "0 0 30 10",
|
2079
|
+
preserveAspectRatio: "none",
|
2080
|
+
children: props.asChild ? children : /* @__PURE__ */ jsx("polygon", {
|
2081
|
+
points: "0,0 30,0 15,10"
|
2082
|
+
})
|
2083
|
+
});
|
2084
|
+
});
|
2085
|
+
Arrow$1.displayName = NAME;
|
2086
|
+
var Root = Arrow$1;
|
2087
|
+
|
2088
|
+
var POPPER_NAME = "Popper";
|
2089
|
+
var [createPopperContext, createPopperScope] = createContextScope(POPPER_NAME);
|
2090
|
+
var [PopperProvider, usePopperContext] = createPopperContext(POPPER_NAME);
|
2091
|
+
var Popper = (props)=>{
|
2092
|
+
const { __scopePopper, children } = props;
|
2093
|
+
const [anchor, setAnchor] = React.useState(null);
|
2094
|
+
return /* @__PURE__ */ jsx(PopperProvider, {
|
2095
|
+
scope: __scopePopper,
|
2096
|
+
anchor,
|
2097
|
+
onAnchorChange: setAnchor,
|
2098
|
+
children
|
2099
|
+
});
|
2100
|
+
};
|
2101
|
+
Popper.displayName = POPPER_NAME;
|
2102
|
+
var ANCHOR_NAME = "PopperAnchor";
|
2103
|
+
var PopperAnchor = React.forwardRef((props, forwardedRef)=>{
|
2104
|
+
const { __scopePopper, virtualRef, ...anchorProps } = props;
|
2105
|
+
const context = usePopperContext(ANCHOR_NAME, __scopePopper);
|
2106
|
+
const ref = React.useRef(null);
|
2107
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
2108
|
+
const anchorRef = React.useRef(null);
|
2109
|
+
React.useEffect(()=>{
|
2110
|
+
const previousAnchor = anchorRef.current;
|
2111
|
+
anchorRef.current = virtualRef?.current || ref.current;
|
2112
|
+
if (previousAnchor !== anchorRef.current) {
|
2113
|
+
context.onAnchorChange(anchorRef.current);
|
2114
|
+
}
|
2115
|
+
});
|
2116
|
+
return virtualRef ? null : /* @__PURE__ */ jsx(Primitive.div, {
|
2117
|
+
...anchorProps,
|
2118
|
+
ref: composedRefs
|
2119
|
+
});
|
2120
|
+
});
|
2121
|
+
PopperAnchor.displayName = ANCHOR_NAME;
|
2122
|
+
var CONTENT_NAME = "PopperContent";
|
2123
|
+
var [PopperContentProvider, useContentContext] = createPopperContext(CONTENT_NAME);
|
2124
|
+
var PopperContent = React.forwardRef((props, forwardedRef)=>{
|
2125
|
+
const { __scopePopper, side = "bottom", sideOffset = 0, align = "center", alignOffset = 0, arrowPadding = 0, avoidCollisions = true, collisionBoundary = [], collisionPadding: collisionPaddingProp = 0, sticky = "partial", hideWhenDetached = false, updatePositionStrategy = "optimized", onPlaced, ...contentProps } = props;
|
2126
|
+
const context = usePopperContext(CONTENT_NAME, __scopePopper);
|
2127
|
+
const [content, setContent] = React.useState(null);
|
2128
|
+
const composedRefs = useComposedRefs(forwardedRef, (node)=>setContent(node));
|
2129
|
+
const [arrow$1, setArrow] = React.useState(null);
|
2130
|
+
const arrowSize = useSize(arrow$1);
|
2131
|
+
const arrowWidth = arrowSize?.width ?? 0;
|
2132
|
+
const arrowHeight = arrowSize?.height ?? 0;
|
2133
|
+
const desiredPlacement = side + (align !== "center" ? "-" + align : "");
|
2134
|
+
const collisionPadding = typeof collisionPaddingProp === "number" ? collisionPaddingProp : {
|
2135
|
+
top: 0,
|
2136
|
+
right: 0,
|
2137
|
+
bottom: 0,
|
2138
|
+
left: 0,
|
2139
|
+
...collisionPaddingProp
|
2140
|
+
};
|
2141
|
+
const boundary = Array.isArray(collisionBoundary) ? collisionBoundary : [
|
2142
|
+
collisionBoundary
|
2143
|
+
];
|
2144
|
+
const hasExplicitBoundaries = boundary.length > 0;
|
2145
|
+
const detectOverflowOptions = {
|
2146
|
+
padding: collisionPadding,
|
2147
|
+
boundary: boundary.filter(isNotNull),
|
2148
|
+
// with `strategy: 'fixed'`, this is the only way to get it to respect boundaries
|
2149
|
+
altBoundary: hasExplicitBoundaries
|
2150
|
+
};
|
2151
|
+
const { refs, floatingStyles, placement, isPositioned, middlewareData } = useFloating({
|
2152
|
+
// default to `fixed` strategy so users don't have to pick and we also avoid focus scroll issues
|
2153
|
+
strategy: "fixed",
|
2154
|
+
placement: desiredPlacement,
|
2155
|
+
whileElementsMounted: (...args)=>{
|
2156
|
+
const cleanup = autoUpdate(...args, {
|
2157
|
+
animationFrame: updatePositionStrategy === "always"
|
2158
|
+
});
|
2159
|
+
return cleanup;
|
2160
|
+
},
|
2161
|
+
elements: {
|
2162
|
+
reference: context.anchor
|
2163
|
+
},
|
2164
|
+
middleware: [
|
2165
|
+
offset({
|
2166
|
+
mainAxis: sideOffset + arrowHeight,
|
2167
|
+
alignmentAxis: alignOffset
|
2168
|
+
}),
|
2169
|
+
avoidCollisions && shift({
|
2170
|
+
mainAxis: true,
|
2171
|
+
crossAxis: false,
|
2172
|
+
limiter: sticky === "partial" ? limitShift() : void 0,
|
2173
|
+
...detectOverflowOptions
|
2174
|
+
}),
|
2175
|
+
avoidCollisions && flip({
|
2176
|
+
...detectOverflowOptions
|
2177
|
+
}),
|
2178
|
+
size({
|
2179
|
+
...detectOverflowOptions,
|
2180
|
+
apply: ({ elements, rects, availableWidth, availableHeight })=>{
|
2181
|
+
const { width: anchorWidth, height: anchorHeight } = rects.reference;
|
2182
|
+
const contentStyle = elements.floating.style;
|
2183
|
+
contentStyle.setProperty("--radix-popper-available-width", `${availableWidth}px`);
|
2184
|
+
contentStyle.setProperty("--radix-popper-available-height", `${availableHeight}px`);
|
2185
|
+
contentStyle.setProperty("--radix-popper-anchor-width", `${anchorWidth}px`);
|
2186
|
+
contentStyle.setProperty("--radix-popper-anchor-height", `${anchorHeight}px`);
|
2187
|
+
}
|
2188
|
+
}),
|
2189
|
+
arrow$1 && arrow({
|
2190
|
+
element: arrow$1,
|
2191
|
+
padding: arrowPadding
|
2192
|
+
}),
|
2193
|
+
transformOrigin({
|
2194
|
+
arrowWidth,
|
2195
|
+
arrowHeight
|
2196
|
+
}),
|
2197
|
+
hideWhenDetached && hide({
|
2198
|
+
strategy: "referenceHidden",
|
2199
|
+
...detectOverflowOptions
|
2200
|
+
})
|
2201
|
+
]
|
2202
|
+
});
|
2203
|
+
const [placedSide, placedAlign] = getSideAndAlignFromPlacement(placement);
|
2204
|
+
const handlePlaced = useCallbackRef(onPlaced);
|
2205
|
+
useLayoutEffect2(()=>{
|
2206
|
+
if (isPositioned) {
|
2207
|
+
handlePlaced?.();
|
2208
|
+
}
|
2209
|
+
}, [
|
2210
|
+
isPositioned,
|
2211
|
+
handlePlaced
|
2212
|
+
]);
|
2213
|
+
const arrowX = middlewareData.arrow?.x;
|
2214
|
+
const arrowY = middlewareData.arrow?.y;
|
2215
|
+
const cannotCenterArrow = middlewareData.arrow?.centerOffset !== 0;
|
2216
|
+
const [contentZIndex, setContentZIndex] = React.useState();
|
2217
|
+
useLayoutEffect2(()=>{
|
2218
|
+
if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
|
2219
|
+
}, [
|
2220
|
+
content
|
2221
|
+
]);
|
2222
|
+
return /* @__PURE__ */ jsx("div", {
|
2223
|
+
ref: refs.setFloating,
|
2224
|
+
"data-radix-popper-content-wrapper": "",
|
2225
|
+
style: {
|
2226
|
+
...floatingStyles,
|
2227
|
+
transform: isPositioned ? floatingStyles.transform : "translate(0, -200%)",
|
2228
|
+
// keep off the page when measuring
|
2229
|
+
minWidth: "max-content",
|
2230
|
+
zIndex: contentZIndex,
|
2231
|
+
["--radix-popper-transform-origin"]: [
|
2232
|
+
middlewareData.transformOrigin?.x,
|
2233
|
+
middlewareData.transformOrigin?.y
|
2234
|
+
].join(" "),
|
2235
|
+
// hide the content if using the hide middleware and should be hidden
|
2236
|
+
// set visibility to hidden and disable pointer events so the UI behaves
|
2237
|
+
// as if the PopperContent isn't there at all
|
2238
|
+
...middlewareData.hide?.referenceHidden && {
|
2239
|
+
visibility: "hidden",
|
2240
|
+
pointerEvents: "none"
|
2241
|
+
}
|
2242
|
+
},
|
2243
|
+
dir: props.dir,
|
2244
|
+
children: /* @__PURE__ */ jsx(PopperContentProvider, {
|
2245
|
+
scope: __scopePopper,
|
2246
|
+
placedSide,
|
2247
|
+
onArrowChange: setArrow,
|
2248
|
+
arrowX,
|
2249
|
+
arrowY,
|
2250
|
+
shouldHideArrow: cannotCenterArrow,
|
2251
|
+
children: /* @__PURE__ */ jsx(Primitive.div, {
|
2252
|
+
"data-side": placedSide,
|
2253
|
+
"data-align": placedAlign,
|
2254
|
+
...contentProps,
|
2255
|
+
ref: composedRefs,
|
2256
|
+
style: {
|
2257
|
+
...contentProps.style,
|
2258
|
+
// if the PopperContent hasn't been placed yet (not all measurements done)
|
2259
|
+
// we prevent animations so that users's animation don't kick in too early referring wrong sides
|
2260
|
+
animation: !isPositioned ? "none" : void 0
|
2261
|
+
}
|
2262
|
+
})
|
2263
|
+
})
|
2264
|
+
});
|
2265
|
+
});
|
2266
|
+
PopperContent.displayName = CONTENT_NAME;
|
2267
|
+
var ARROW_NAME = "PopperArrow";
|
2268
|
+
var OPPOSITE_SIDE = {
|
2269
|
+
top: "bottom",
|
2270
|
+
right: "left",
|
2271
|
+
bottom: "top",
|
2272
|
+
left: "right"
|
2273
|
+
};
|
2274
|
+
var PopperArrow = React.forwardRef(function PopperArrow2(props, forwardedRef) {
|
2275
|
+
const { __scopePopper, ...arrowProps } = props;
|
2276
|
+
const contentContext = useContentContext(ARROW_NAME, __scopePopper);
|
2277
|
+
const baseSide = OPPOSITE_SIDE[contentContext.placedSide];
|
2278
|
+
return(// we have to use an extra wrapper because `ResizeObserver` (used by `useSize`)
|
2279
|
+
// doesn't report size as we'd expect on SVG elements.
|
2280
|
+
// it reports their bounding box which is effectively the largest path inside the SVG.
|
2281
|
+
/* @__PURE__ */ jsx("span", {
|
2282
|
+
ref: contentContext.onArrowChange,
|
2283
|
+
style: {
|
2284
|
+
position: "absolute",
|
2285
|
+
left: contentContext.arrowX,
|
2286
|
+
top: contentContext.arrowY,
|
2287
|
+
[baseSide]: 0,
|
2288
|
+
transformOrigin: {
|
2289
|
+
top: "",
|
2290
|
+
right: "0 0",
|
2291
|
+
bottom: "center 0",
|
2292
|
+
left: "100% 0"
|
2293
|
+
}[contentContext.placedSide],
|
2294
|
+
transform: {
|
2295
|
+
top: "translateY(100%)",
|
2296
|
+
right: "translateY(50%) rotate(90deg) translateX(-50%)",
|
2297
|
+
bottom: `rotate(180deg)`,
|
2298
|
+
left: "translateY(50%) rotate(-90deg) translateX(50%)"
|
2299
|
+
}[contentContext.placedSide],
|
2300
|
+
visibility: contentContext.shouldHideArrow ? "hidden" : void 0
|
2301
|
+
},
|
2302
|
+
children: /* @__PURE__ */ jsx(Root, {
|
2303
|
+
...arrowProps,
|
2304
|
+
ref: forwardedRef,
|
2305
|
+
style: {
|
2306
|
+
...arrowProps.style,
|
2307
|
+
// ensures the element can be measured correctly (mostly for if SVG)
|
2308
|
+
display: "block"
|
2309
|
+
}
|
2310
|
+
})
|
2311
|
+
}));
|
2312
|
+
});
|
2313
|
+
PopperArrow.displayName = ARROW_NAME;
|
2314
|
+
function isNotNull(value) {
|
2315
|
+
return value !== null;
|
2316
|
+
}
|
2317
|
+
var transformOrigin = (options)=>({
|
2318
|
+
name: "transformOrigin",
|
2319
|
+
options,
|
2320
|
+
fn (data) {
|
2321
|
+
const { placement, rects, middlewareData } = data;
|
2322
|
+
const cannotCenterArrow = middlewareData.arrow?.centerOffset !== 0;
|
2323
|
+
const isArrowHidden = cannotCenterArrow;
|
2324
|
+
const arrowWidth = isArrowHidden ? 0 : options.arrowWidth;
|
2325
|
+
const arrowHeight = isArrowHidden ? 0 : options.arrowHeight;
|
2326
|
+
const [placedSide, placedAlign] = getSideAndAlignFromPlacement(placement);
|
2327
|
+
const noArrowAlign = {
|
2328
|
+
start: "0%",
|
2329
|
+
center: "50%",
|
2330
|
+
end: "100%"
|
2331
|
+
}[placedAlign];
|
2332
|
+
const arrowXCenter = (middlewareData.arrow?.x ?? 0) + arrowWidth / 2;
|
2333
|
+
const arrowYCenter = (middlewareData.arrow?.y ?? 0) + arrowHeight / 2;
|
2334
|
+
let x = "";
|
2335
|
+
let y = "";
|
2336
|
+
if (placedSide === "bottom") {
|
2337
|
+
x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
|
2338
|
+
y = `${-arrowHeight}px`;
|
2339
|
+
} else if (placedSide === "top") {
|
2340
|
+
x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
|
2341
|
+
y = `${rects.floating.height + arrowHeight}px`;
|
2342
|
+
} else if (placedSide === "right") {
|
2343
|
+
x = `${-arrowHeight}px`;
|
2344
|
+
y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
|
2345
|
+
} else if (placedSide === "left") {
|
2346
|
+
x = `${rects.floating.width + arrowHeight}px`;
|
2347
|
+
y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
|
2348
|
+
}
|
2349
|
+
return {
|
2350
|
+
data: {
|
2351
|
+
x,
|
2352
|
+
y
|
2353
|
+
}
|
2354
|
+
};
|
2355
|
+
}
|
2356
|
+
});
|
2357
|
+
function getSideAndAlignFromPlacement(placement) {
|
2358
|
+
const [side, align = "center"] = placement.split("-");
|
2359
|
+
return [
|
2360
|
+
side,
|
2361
|
+
align
|
2362
|
+
];
|
2363
|
+
}
|
2364
|
+
var Root2 = Popper;
|
2365
|
+
var Anchor = PopperAnchor;
|
2366
|
+
var Content = PopperContent;
|
2367
|
+
var Arrow = PopperArrow;
|
2368
|
+
|
2369
|
+
export { Anchor as A, Content as C, Root2 as R, Arrow as a, createPopperScope as c };
|
2370
|
+
//# sourceMappingURL=index-BFDafXar.mjs.map
|