@adaptive-ds/solid-ui 0.11.0 → 0.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +219 -0
- package/dist/demo_pages/LinkBlock.js +1 -1
- package/dist/demo_pages/generateDemoRoutes.js +3 -3
- package/dist/generate_demo_list/generateDemoList.js +1 -1
- package/dist/generate_demo_list/parts/formatGeneratedCodeFile.d.ts +1 -1
- package/dist/generate_demo_list/parts/formatGeneratedCodeFile.js +1 -1
- package/dist/input/check/CheckBoolean.js +1 -1
- package/dist/input/check/CheckBooleanSingle.js +1 -1
- package/dist/input/check/CheckMultiple.js +1 -1
- package/dist/input/check/CheckSingle.js +1 -1
- package/dist/input/check/Checkbox.js +1 -1
- package/dist/input/fieldset/Fieldset.js +1 -1
- package/dist/input/input/Input.js +1 -1
- package/dist/input/input/InputDatalist.js +2 -2
- package/dist/input/label/Label.js +1 -1
- package/dist/input/label/LabelAsterix.js +1 -1
- package/dist/input/label/LabelPseudo.js +1 -1
- package/dist/input/label/LabelWithInfo.js +1 -1
- package/dist/input/label/LabelWithSubtitle.js +1 -1
- package/dist/input/number/NumberInputS.js +2 -2
- package/dist/input/select/SelectMultiple.js +1 -1
- package/dist/input/select/SelectSingleNative.js +1 -1
- package/dist/input/switch/SwitchSingle.js +1 -1
- package/dist/input/textarea/Textarea.js +1 -1
- package/dist/interactive/button/Button.js +1 -1
- package/dist/interactive/button/ButtonIcon1.js +1 -1
- package/dist/interactive/button/ButtonIconOnly.js +1 -1
- package/dist/interactive/details/Details.js +1 -1
- package/dist/interactive/dialog/CorvuDialog.js +1 -1
- package/dist/interactive/dialog/CorvuDialogIcon.js +1 -1
- package/dist/interactive/layout/SidebarLayout.js +1 -1
- package/dist/interactive/link/LinkButton.js +1 -1
- package/dist/interactive/link/LinkButtonIconOnly.js +1 -1
- package/dist/interactive/link/LinkText.js +1 -1
- package/dist/interactive/list/BulletLinks.js +1 -1
- package/dist/interactive/tabs/TabsTop.js +1 -1
- package/dist/interactive/theme/themeSignal.js +1 -1
- package/dist/interactive/toast/Toast.js +1 -1
- package/dist/interactive/toast/Toaster.js +1 -1
- package/dist/interactive/toggle/ToggleButtonIconOnly.js +1 -1
- package/dist/node_modules/@adaptive-ds/utils/dist/bun/runCmdAsync.js +45 -0
- package/dist/node_modules/@adaptive-ds/utils/dist/bun/runCmdAsync.js.map +1 -0
- package/dist/node_modules/@adaptive-ds/utils/dist/int/safeParseInt.js +10 -0
- package/dist/node_modules/@adaptive-ds/utils/dist/int/safeParseInt.js.map +1 -0
- package/dist/node_modules/@adaptive-ds/utils/dist/json/jsonStringifyPretty.js +7 -0
- package/dist/node_modules/@adaptive-ds/utils/dist/json/jsonStringifyPretty.js.map +1 -0
- package/dist/node_modules/@adaptive-ds/utils/dist/obj/objectEntries.js +5 -0
- package/dist/node_modules/@adaptive-ds/utils/dist/obj/objectEntries.js.map +1 -0
- package/dist/node_modules/@adaptive-ds/utils/dist/obj/objectKeys.js +5 -0
- package/dist/node_modules/@adaptive-ds/utils/dist/obj/objectKeys.js.map +1 -0
- package/dist/node_modules/@adaptive-ds/utils/dist/ran/generateId12.js +9 -0
- package/dist/node_modules/@adaptive-ds/utils/dist/ran/generateId12.js.map +1 -0
- package/dist/node_modules/@adaptive-ds/utils/dist/ran/generateReadableId.js +29 -0
- package/dist/node_modules/@adaptive-ds/utils/dist/ran/generateReadableId.js.map +1 -0
- package/dist/node_modules/@adaptive-ds/utils/dist/ran/urlAlphabet32.js +5 -0
- package/dist/node_modules/@adaptive-ds/utils/dist/ran/urlAlphabet32.js.map +1 -0
- package/dist/node_modules/@corvu/dialog/dist/index.js +537 -0
- package/dist/node_modules/@corvu/dialog/dist/index.js.map +1 -0
- package/dist/node_modules/@corvu/popover/dist/index.js +267 -0
- package/dist/node_modules/@corvu/popover/dist/index.js.map +1 -0
- package/dist/node_modules/@corvu/popover/node_modules/@corvu/utils/dist/chunk/74BWZKBI.js +7 -0
- package/dist/node_modules/@corvu/popover/node_modules/@corvu/utils/dist/chunk/74BWZKBI.js.map +1 -0
- package/dist/node_modules/@corvu/popover/node_modules/@corvu/utils/dist/chunk/NVYXOAAC.js +22 -0
- package/dist/node_modules/@corvu/popover/node_modules/@corvu/utils/dist/chunk/NVYXOAAC.js.map +1 -0
- package/dist/node_modules/@corvu/popover/node_modules/@corvu/utils/dist/chunk/U42ECMND.js +16 -0
- package/dist/node_modules/@corvu/popover/node_modules/@corvu/utils/dist/chunk/U42ECMND.js.map +1 -0
- package/dist/node_modules/@corvu/popover/node_modules/@corvu/utils/dist/chunk/UKBPAEF5.js +23 -0
- package/dist/node_modules/@corvu/popover/node_modules/@corvu/utils/dist/chunk/UKBPAEF5.js.map +1 -0
- package/dist/node_modules/@corvu/popover/node_modules/@corvu/utils/dist/chunk/WR7IK7QK.js +41 -0
- package/dist/node_modules/@corvu/popover/node_modules/@corvu/utils/dist/chunk/WR7IK7QK.js.map +1 -0
- package/dist/node_modules/@corvu/popover/node_modules/@corvu/utils/dist/components/FloatingArrow.js +72 -0
- package/dist/node_modules/@corvu/popover/node_modules/@corvu/utils/dist/components/FloatingArrow.js.map +1 -0
- package/dist/node_modules/@corvu/popover/node_modules/@corvu/utils/dist/create/floating.js +132 -0
- package/dist/node_modules/@corvu/popover/node_modules/@corvu/utils/dist/create/floating.js.map +1 -0
- package/dist/node_modules/@corvu/popover/node_modules/@corvu/utils/dist/create/keyedContext.js +20 -0
- package/dist/node_modules/@corvu/popover/node_modules/@corvu/utils/dist/create/keyedContext.js.map +1 -0
- package/dist/node_modules/@corvu/popover/node_modules/@corvu/utils/dist/create/once.js +18 -0
- package/dist/node_modules/@corvu/popover/node_modules/@corvu/utils/dist/create/once.js.map +1 -0
- package/dist/node_modules/@corvu/utils/dist/chunk/74BWZKBI.js +18 -0
- package/dist/node_modules/@corvu/utils/dist/chunk/74BWZKBI.js.map +1 -0
- package/dist/node_modules/@corvu/utils/dist/chunk/GZJAOTUE.js +45 -0
- package/dist/node_modules/@corvu/utils/dist/chunk/GZJAOTUE.js.map +1 -0
- package/dist/node_modules/@corvu/utils/dist/chunk/U42ECMND.js +20 -0
- package/dist/node_modules/@corvu/utils/dist/chunk/U42ECMND.js.map +1 -0
- package/dist/node_modules/@corvu/utils/dist/chunk/UKBPAEF5.js +52 -0
- package/dist/node_modules/@corvu/utils/dist/chunk/UKBPAEF5.js.map +1 -0
- package/dist/node_modules/@corvu/utils/dist/chunk/XJFCWSNS.js +11 -0
- package/dist/node_modules/@corvu/utils/dist/chunk/XJFCWSNS.js.map +1 -0
- package/dist/node_modules/@corvu/utils/dist/create/controllableSignal.js +29 -0
- package/dist/node_modules/@corvu/utils/dist/create/controllableSignal.js.map +1 -0
- package/dist/node_modules/@corvu/utils/dist/create/keyedContext.js +20 -0
- package/dist/node_modules/@corvu/utils/dist/create/keyedContext.js.map +1 -0
- package/dist/node_modules/@corvu/utils/dist/create/once.js +18 -0
- package/dist/node_modules/@corvu/utils/dist/create/once.js.map +1 -0
- package/dist/node_modules/@corvu/utils/dist/create/register.js +22 -0
- package/dist/node_modules/@corvu/utils/dist/create/register.js.map +1 -0
- package/dist/node_modules/@corvu/utils/dist/create/style.js +51 -0
- package/dist/node_modules/@corvu/utils/dist/create/style.js.map +1 -0
- package/dist/node_modules/@corvu/utils/dist/scroll/index.js +39 -0
- package/dist/node_modules/@corvu/utils/dist/scroll/index.js.map +1 -0
- package/dist/node_modules/@floating-ui/core/dist/floating-ui.core.js +878 -0
- package/dist/node_modules/@floating-ui/core/dist/floating-ui.core.js.map +1 -0
- package/dist/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +628 -0
- package/dist/node_modules/@floating-ui/dom/dist/floating-ui.dom.js.map +1 -0
- package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +174 -0
- package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js.map +1 -0
- package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +159 -0
- package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.js.map +1 -0
- package/dist/node_modules/image-size/dist/index.js +942 -0
- package/dist/node_modules/image-size/dist/index.js.map +1 -0
- package/dist/node_modules/solid-dismissible/dist/index.js +253 -0
- package/dist/node_modules/solid-dismissible/dist/index.js.map +1 -0
- package/dist/node_modules/solid-focus-trap/dist/index.js +164 -0
- package/dist/node_modules/solid-focus-trap/dist/index.js.map +1 -0
- package/dist/node_modules/solid-presence/dist/index.js +73 -0
- package/dist/node_modules/solid-presence/dist/index.js.map +1 -0
- package/dist/node_modules/solid-prevent-scroll/dist/index.js +160 -0
- package/dist/node_modules/solid-prevent-scroll/dist/index.js.map +1 -0
- package/dist/static/badge/Badge.js +1 -1
- package/dist/static/container/CardWrapper.js +1 -1
- package/dist/static/dev/TailwindIndicator.js +1 -1
- package/dist/static/grid/FeatureGridSection.js +1 -1
- package/dist/static/icon/Icon.js +1 -1
- package/dist/static/icon/IconGoogle.js +1 -1
- package/dist/static/icons/iconApple.d.ts +2 -0
- package/dist/static/icons/iconApple.d.ts.map +1 -0
- package/dist/static/icons/iconApple.js +5 -0
- package/dist/static/icons/iconApple.js.map +1 -0
- package/dist/static/icons/iconGooglePlay.d.ts +2 -0
- package/dist/static/icons/iconGooglePlay.d.ts.map +1 -0
- package/dist/static/icons/iconGooglePlay.js +5 -0
- package/dist/static/icons/iconGooglePlay.js.map +1 -0
- package/dist/static/img/Img.js +1 -1
- package/dist/static/lists/BlackBulletPoint.js +1 -1
- package/dist/static/lists/BlueBulletPoint.js +1 -1
- package/dist/static/loaders/LoaderShuffle4Dots.js +1 -1
- package/dist/static/loaders/LoaderShuffle9Squares.js +1 -1
- package/dist/static/loaders/LoaderSpin4Square.js +1 -1
- package/dist/static/loaders/LoadingPage.js +1 -1
- package/dist/static/logo/LogoImageText.js +1 -1
- package/dist/static/page/PageWrapper.js +1 -1
- package/dist/static/pages/ErrorPage.js +1 -1
- package/dist/static/pages/SuccessPage.js +1 -1
- package/dist/static/separator/SeparatorOr.js +1 -1
- package/dist/static/separator/SeparatorWithText.js +1 -1
- package/dist/static/timeline/Timeline.js +1 -1
- package/dist/table/Table.js +1 -1
- package/dist/table/table1/Table1D.js +1 -1
- package/dist/table/table1/Table1M.js +1 -1
- package/dist/table/table1/Table1MEntry.js +1 -1
- package/dist/table/table2/Table2D.js +1 -1
- package/dist/table/table2/Table2M.js +1 -1
- package/dist/table/table2/Table2MEntry.js +1 -1
- package/package.json +16 -18
|
@@ -0,0 +1,878 @@
|
|
|
1
|
+
import { evaluate, getSideAxis, getSide, clamp, getPaddingObject, getAlignmentAxis, getAlignment, getOppositePlacement, getExpandedPlacements, getOppositeAxisPlacements, getAlignmentSides, min, max, placements, rectToClientRect, getOppositeAxis, getAxisLength, getOppositeAlignmentPlacement, sides } from "../../utils/dist/floating-ui.utils.js";
|
|
2
|
+
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
3
|
+
let {
|
|
4
|
+
reference,
|
|
5
|
+
floating
|
|
6
|
+
} = _ref;
|
|
7
|
+
const sideAxis = getSideAxis(placement);
|
|
8
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
9
|
+
const alignLength = getAxisLength(alignmentAxis);
|
|
10
|
+
const side = getSide(placement);
|
|
11
|
+
const isVertical = sideAxis === "y";
|
|
12
|
+
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
13
|
+
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
14
|
+
const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
|
|
15
|
+
let coords;
|
|
16
|
+
switch (side) {
|
|
17
|
+
case "top":
|
|
18
|
+
coords = {
|
|
19
|
+
x: commonX,
|
|
20
|
+
y: reference.y - floating.height
|
|
21
|
+
};
|
|
22
|
+
break;
|
|
23
|
+
case "bottom":
|
|
24
|
+
coords = {
|
|
25
|
+
x: commonX,
|
|
26
|
+
y: reference.y + reference.height
|
|
27
|
+
};
|
|
28
|
+
break;
|
|
29
|
+
case "right":
|
|
30
|
+
coords = {
|
|
31
|
+
x: reference.x + reference.width,
|
|
32
|
+
y: commonY
|
|
33
|
+
};
|
|
34
|
+
break;
|
|
35
|
+
case "left":
|
|
36
|
+
coords = {
|
|
37
|
+
x: reference.x - floating.width,
|
|
38
|
+
y: commonY
|
|
39
|
+
};
|
|
40
|
+
break;
|
|
41
|
+
default:
|
|
42
|
+
coords = {
|
|
43
|
+
x: reference.x,
|
|
44
|
+
y: reference.y
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
switch (getAlignment(placement)) {
|
|
48
|
+
case "start":
|
|
49
|
+
coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
50
|
+
break;
|
|
51
|
+
case "end":
|
|
52
|
+
coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
return coords;
|
|
56
|
+
}
|
|
57
|
+
async function detectOverflow(state, options) {
|
|
58
|
+
var _await$platform$isEle;
|
|
59
|
+
if (options === void 0) {
|
|
60
|
+
options = {};
|
|
61
|
+
}
|
|
62
|
+
const {
|
|
63
|
+
x,
|
|
64
|
+
y,
|
|
65
|
+
platform,
|
|
66
|
+
rects,
|
|
67
|
+
elements,
|
|
68
|
+
strategy
|
|
69
|
+
} = state;
|
|
70
|
+
const {
|
|
71
|
+
boundary = "clippingAncestors",
|
|
72
|
+
rootBoundary = "viewport",
|
|
73
|
+
elementContext = "floating",
|
|
74
|
+
altBoundary = false,
|
|
75
|
+
padding = 0
|
|
76
|
+
} = evaluate(options, state);
|
|
77
|
+
const paddingObject = getPaddingObject(padding);
|
|
78
|
+
const altContext = elementContext === "floating" ? "reference" : "floating";
|
|
79
|
+
const element = elements[altBoundary ? altContext : elementContext];
|
|
80
|
+
const clippingClientRect = rectToClientRect(await platform.getClippingRect({
|
|
81
|
+
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)),
|
|
82
|
+
boundary,
|
|
83
|
+
rootBoundary,
|
|
84
|
+
strategy
|
|
85
|
+
}));
|
|
86
|
+
const rect = elementContext === "floating" ? {
|
|
87
|
+
x,
|
|
88
|
+
y,
|
|
89
|
+
width: rects.floating.width,
|
|
90
|
+
height: rects.floating.height
|
|
91
|
+
} : rects.reference;
|
|
92
|
+
const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
|
|
93
|
+
const offsetScale = await (platform.isElement == null ? void 0 : platform.isElement(offsetParent)) ? await (platform.getScale == null ? void 0 : platform.getScale(offsetParent)) || {
|
|
94
|
+
x: 1,
|
|
95
|
+
y: 1
|
|
96
|
+
} : {
|
|
97
|
+
x: 1,
|
|
98
|
+
y: 1
|
|
99
|
+
};
|
|
100
|
+
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
101
|
+
elements,
|
|
102
|
+
rect,
|
|
103
|
+
offsetParent,
|
|
104
|
+
strategy
|
|
105
|
+
}) : rect);
|
|
106
|
+
return {
|
|
107
|
+
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
|
108
|
+
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
|
109
|
+
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
|
110
|
+
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
const computePosition = async (reference, floating, config) => {
|
|
114
|
+
const {
|
|
115
|
+
placement = "bottom",
|
|
116
|
+
strategy = "absolute",
|
|
117
|
+
middleware = [],
|
|
118
|
+
platform
|
|
119
|
+
} = config;
|
|
120
|
+
const validMiddleware = middleware.filter(Boolean);
|
|
121
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
|
|
122
|
+
let rects = await platform.getElementRects({
|
|
123
|
+
reference,
|
|
124
|
+
floating,
|
|
125
|
+
strategy
|
|
126
|
+
});
|
|
127
|
+
let {
|
|
128
|
+
x,
|
|
129
|
+
y
|
|
130
|
+
} = computeCoordsFromPlacement(rects, placement, rtl);
|
|
131
|
+
let statefulPlacement = placement;
|
|
132
|
+
let middlewareData = {};
|
|
133
|
+
let resetCount = 0;
|
|
134
|
+
for (let i = 0; i < validMiddleware.length; i++) {
|
|
135
|
+
var _platform$detectOverf;
|
|
136
|
+
const {
|
|
137
|
+
name,
|
|
138
|
+
fn
|
|
139
|
+
} = validMiddleware[i];
|
|
140
|
+
const {
|
|
141
|
+
x: nextX,
|
|
142
|
+
y: nextY,
|
|
143
|
+
data,
|
|
144
|
+
reset
|
|
145
|
+
} = await fn({
|
|
146
|
+
x,
|
|
147
|
+
y,
|
|
148
|
+
initialPlacement: placement,
|
|
149
|
+
placement: statefulPlacement,
|
|
150
|
+
strategy,
|
|
151
|
+
middlewareData,
|
|
152
|
+
rects,
|
|
153
|
+
platform: {
|
|
154
|
+
...platform,
|
|
155
|
+
detectOverflow: (_platform$detectOverf = platform.detectOverflow) != null ? _platform$detectOverf : detectOverflow
|
|
156
|
+
},
|
|
157
|
+
elements: {
|
|
158
|
+
reference,
|
|
159
|
+
floating
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
x = nextX != null ? nextX : x;
|
|
163
|
+
y = nextY != null ? nextY : y;
|
|
164
|
+
middlewareData = {
|
|
165
|
+
...middlewareData,
|
|
166
|
+
[name]: {
|
|
167
|
+
...middlewareData[name],
|
|
168
|
+
...data
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
if (reset && resetCount <= 50) {
|
|
172
|
+
resetCount++;
|
|
173
|
+
if (typeof reset === "object") {
|
|
174
|
+
if (reset.placement) {
|
|
175
|
+
statefulPlacement = reset.placement;
|
|
176
|
+
}
|
|
177
|
+
if (reset.rects) {
|
|
178
|
+
rects = reset.rects === true ? await platform.getElementRects({
|
|
179
|
+
reference,
|
|
180
|
+
floating,
|
|
181
|
+
strategy
|
|
182
|
+
}) : reset.rects;
|
|
183
|
+
}
|
|
184
|
+
({
|
|
185
|
+
x,
|
|
186
|
+
y
|
|
187
|
+
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
188
|
+
}
|
|
189
|
+
i = -1;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return {
|
|
193
|
+
x,
|
|
194
|
+
y,
|
|
195
|
+
placement: statefulPlacement,
|
|
196
|
+
strategy,
|
|
197
|
+
middlewareData
|
|
198
|
+
};
|
|
199
|
+
};
|
|
200
|
+
const arrow = (options) => ({
|
|
201
|
+
name: "arrow",
|
|
202
|
+
options,
|
|
203
|
+
async fn(state) {
|
|
204
|
+
const {
|
|
205
|
+
x,
|
|
206
|
+
y,
|
|
207
|
+
placement,
|
|
208
|
+
rects,
|
|
209
|
+
platform,
|
|
210
|
+
elements,
|
|
211
|
+
middlewareData
|
|
212
|
+
} = state;
|
|
213
|
+
const {
|
|
214
|
+
element,
|
|
215
|
+
padding = 0
|
|
216
|
+
} = evaluate(options, state) || {};
|
|
217
|
+
if (element == null) {
|
|
218
|
+
return {};
|
|
219
|
+
}
|
|
220
|
+
const paddingObject = getPaddingObject(padding);
|
|
221
|
+
const coords = {
|
|
222
|
+
x,
|
|
223
|
+
y
|
|
224
|
+
};
|
|
225
|
+
const axis = getAlignmentAxis(placement);
|
|
226
|
+
const length = getAxisLength(axis);
|
|
227
|
+
const arrowDimensions = await platform.getDimensions(element);
|
|
228
|
+
const isYAxis = axis === "y";
|
|
229
|
+
const minProp = isYAxis ? "top" : "left";
|
|
230
|
+
const maxProp = isYAxis ? "bottom" : "right";
|
|
231
|
+
const clientProp = isYAxis ? "clientHeight" : "clientWidth";
|
|
232
|
+
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
|
|
233
|
+
const startDiff = coords[axis] - rects.reference[axis];
|
|
234
|
+
const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
|
|
235
|
+
let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
|
|
236
|
+
if (!clientSize || !await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent))) {
|
|
237
|
+
clientSize = elements.floating[clientProp] || rects.floating[length];
|
|
238
|
+
}
|
|
239
|
+
const centerToReference = endDiff / 2 - startDiff / 2;
|
|
240
|
+
const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
|
|
241
|
+
const minPadding = min(paddingObject[minProp], largestPossiblePadding);
|
|
242
|
+
const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
|
|
243
|
+
const min$1 = minPadding;
|
|
244
|
+
const max2 = clientSize - arrowDimensions[length] - maxPadding;
|
|
245
|
+
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
|
246
|
+
const offset2 = clamp(min$1, center, max2);
|
|
247
|
+
const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset2 && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
|
|
248
|
+
const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max2 : 0;
|
|
249
|
+
return {
|
|
250
|
+
[axis]: coords[axis] + alignmentOffset,
|
|
251
|
+
data: {
|
|
252
|
+
[axis]: offset2,
|
|
253
|
+
centerOffset: center - offset2 - alignmentOffset,
|
|
254
|
+
...shouldAddOffset && {
|
|
255
|
+
alignmentOffset
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
reset: shouldAddOffset
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
function getPlacementList(alignment, autoAlignment, allowedPlacements) {
|
|
263
|
+
const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter((placement) => getAlignment(placement) === alignment), ...allowedPlacements.filter((placement) => getAlignment(placement) !== alignment)] : allowedPlacements.filter((placement) => getSide(placement) === placement);
|
|
264
|
+
return allowedPlacementsSortedByAlignment.filter((placement) => {
|
|
265
|
+
if (alignment) {
|
|
266
|
+
return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);
|
|
267
|
+
}
|
|
268
|
+
return true;
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
const autoPlacement = function(options) {
|
|
272
|
+
if (options === void 0) {
|
|
273
|
+
options = {};
|
|
274
|
+
}
|
|
275
|
+
return {
|
|
276
|
+
name: "autoPlacement",
|
|
277
|
+
options,
|
|
278
|
+
async fn(state) {
|
|
279
|
+
var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE;
|
|
280
|
+
const {
|
|
281
|
+
rects,
|
|
282
|
+
middlewareData,
|
|
283
|
+
placement,
|
|
284
|
+
platform,
|
|
285
|
+
elements
|
|
286
|
+
} = state;
|
|
287
|
+
const {
|
|
288
|
+
crossAxis = false,
|
|
289
|
+
alignment,
|
|
290
|
+
allowedPlacements = placements,
|
|
291
|
+
autoAlignment = true,
|
|
292
|
+
...detectOverflowOptions
|
|
293
|
+
} = evaluate(options, state);
|
|
294
|
+
const placements$1 = alignment !== void 0 || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;
|
|
295
|
+
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
|
296
|
+
const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;
|
|
297
|
+
const currentPlacement = placements$1[currentIndex];
|
|
298
|
+
if (currentPlacement == null) {
|
|
299
|
+
return {};
|
|
300
|
+
}
|
|
301
|
+
const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
|
|
302
|
+
if (placement !== currentPlacement) {
|
|
303
|
+
return {
|
|
304
|
+
reset: {
|
|
305
|
+
placement: placements$1[0]
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]];
|
|
310
|
+
const allOverflows = [...((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || [], {
|
|
311
|
+
placement: currentPlacement,
|
|
312
|
+
overflows: currentOverflows
|
|
313
|
+
}];
|
|
314
|
+
const nextPlacement = placements$1[currentIndex + 1];
|
|
315
|
+
if (nextPlacement) {
|
|
316
|
+
return {
|
|
317
|
+
data: {
|
|
318
|
+
index: currentIndex + 1,
|
|
319
|
+
overflows: allOverflows
|
|
320
|
+
},
|
|
321
|
+
reset: {
|
|
322
|
+
placement: nextPlacement
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
const placementsSortedByMostSpace = allOverflows.map((d) => {
|
|
327
|
+
const alignment2 = getAlignment(d.placement);
|
|
328
|
+
return [d.placement, alignment2 && crossAxis ? (
|
|
329
|
+
// Check along the mainAxis and main crossAxis side.
|
|
330
|
+
d.overflows.slice(0, 2).reduce((acc, v) => acc + v, 0)
|
|
331
|
+
) : (
|
|
332
|
+
// Check only the mainAxis.
|
|
333
|
+
d.overflows[0]
|
|
334
|
+
), d.overflows];
|
|
335
|
+
}).sort((a, b) => a[1] - b[1]);
|
|
336
|
+
const placementsThatFitOnEachSide = placementsSortedByMostSpace.filter((d) => d[2].slice(
|
|
337
|
+
0,
|
|
338
|
+
// Aligned placements should not check their opposite crossAxis
|
|
339
|
+
// side.
|
|
340
|
+
getAlignment(d[0]) ? 2 : 3
|
|
341
|
+
).every((v) => v <= 0));
|
|
342
|
+
const resetPlacement = ((_placementsThatFitOnE = placementsThatFitOnEachSide[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0];
|
|
343
|
+
if (resetPlacement !== placement) {
|
|
344
|
+
return {
|
|
345
|
+
data: {
|
|
346
|
+
index: currentIndex + 1,
|
|
347
|
+
overflows: allOverflows
|
|
348
|
+
},
|
|
349
|
+
reset: {
|
|
350
|
+
placement: resetPlacement
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
return {};
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
};
|
|
358
|
+
const flip = function(options) {
|
|
359
|
+
if (options === void 0) {
|
|
360
|
+
options = {};
|
|
361
|
+
}
|
|
362
|
+
return {
|
|
363
|
+
name: "flip",
|
|
364
|
+
options,
|
|
365
|
+
async fn(state) {
|
|
366
|
+
var _middlewareData$arrow, _middlewareData$flip;
|
|
367
|
+
const {
|
|
368
|
+
placement,
|
|
369
|
+
middlewareData,
|
|
370
|
+
rects,
|
|
371
|
+
initialPlacement,
|
|
372
|
+
platform,
|
|
373
|
+
elements
|
|
374
|
+
} = state;
|
|
375
|
+
const {
|
|
376
|
+
mainAxis: checkMainAxis = true,
|
|
377
|
+
crossAxis: checkCrossAxis = true,
|
|
378
|
+
fallbackPlacements: specifiedFallbackPlacements,
|
|
379
|
+
fallbackStrategy = "bestFit",
|
|
380
|
+
fallbackAxisSideDirection = "none",
|
|
381
|
+
flipAlignment = true,
|
|
382
|
+
...detectOverflowOptions
|
|
383
|
+
} = evaluate(options, state);
|
|
384
|
+
if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
385
|
+
return {};
|
|
386
|
+
}
|
|
387
|
+
const side = getSide(placement);
|
|
388
|
+
const initialSideAxis = getSideAxis(initialPlacement);
|
|
389
|
+
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
390
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
391
|
+
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
392
|
+
const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
|
|
393
|
+
if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
|
|
394
|
+
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
|
395
|
+
}
|
|
396
|
+
const placements2 = [initialPlacement, ...fallbackPlacements];
|
|
397
|
+
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
|
398
|
+
const overflows = [];
|
|
399
|
+
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
400
|
+
if (checkMainAxis) {
|
|
401
|
+
overflows.push(overflow[side]);
|
|
402
|
+
}
|
|
403
|
+
if (checkCrossAxis) {
|
|
404
|
+
const sides2 = getAlignmentSides(placement, rects, rtl);
|
|
405
|
+
overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
|
|
406
|
+
}
|
|
407
|
+
overflowsData = [...overflowsData, {
|
|
408
|
+
placement,
|
|
409
|
+
overflows
|
|
410
|
+
}];
|
|
411
|
+
if (!overflows.every((side2) => side2 <= 0)) {
|
|
412
|
+
var _middlewareData$flip2, _overflowsData$filter;
|
|
413
|
+
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
|
414
|
+
const nextPlacement = placements2[nextIndex];
|
|
415
|
+
if (nextPlacement) {
|
|
416
|
+
const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
|
|
417
|
+
if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
|
|
418
|
+
// overflows the main axis.
|
|
419
|
+
overflowsData.every((d) => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
|
|
420
|
+
return {
|
|
421
|
+
data: {
|
|
422
|
+
index: nextIndex,
|
|
423
|
+
overflows: overflowsData
|
|
424
|
+
},
|
|
425
|
+
reset: {
|
|
426
|
+
placement: nextPlacement
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
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;
|
|
432
|
+
if (!resetPlacement) {
|
|
433
|
+
switch (fallbackStrategy) {
|
|
434
|
+
case "bestFit": {
|
|
435
|
+
var _overflowsData$filter2;
|
|
436
|
+
const placement2 = (_overflowsData$filter2 = overflowsData.filter((d) => {
|
|
437
|
+
if (hasFallbackAxisSideDirection) {
|
|
438
|
+
const currentSideAxis = getSideAxis(d.placement);
|
|
439
|
+
return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
|
|
440
|
+
// reading directions favoring greater width.
|
|
441
|
+
currentSideAxis === "y";
|
|
442
|
+
}
|
|
443
|
+
return true;
|
|
444
|
+
}).map((d) => [d.placement, d.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
|
|
445
|
+
if (placement2) {
|
|
446
|
+
resetPlacement = placement2;
|
|
447
|
+
}
|
|
448
|
+
break;
|
|
449
|
+
}
|
|
450
|
+
case "initialPlacement":
|
|
451
|
+
resetPlacement = initialPlacement;
|
|
452
|
+
break;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
if (placement !== resetPlacement) {
|
|
456
|
+
return {
|
|
457
|
+
reset: {
|
|
458
|
+
placement: resetPlacement
|
|
459
|
+
}
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
return {};
|
|
464
|
+
}
|
|
465
|
+
};
|
|
466
|
+
};
|
|
467
|
+
function getSideOffsets(overflow, rect) {
|
|
468
|
+
return {
|
|
469
|
+
top: overflow.top - rect.height,
|
|
470
|
+
right: overflow.right - rect.width,
|
|
471
|
+
bottom: overflow.bottom - rect.height,
|
|
472
|
+
left: overflow.left - rect.width
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
function isAnySideFullyClipped(overflow) {
|
|
476
|
+
return sides.some((side) => overflow[side] >= 0);
|
|
477
|
+
}
|
|
478
|
+
const hide = function(options) {
|
|
479
|
+
if (options === void 0) {
|
|
480
|
+
options = {};
|
|
481
|
+
}
|
|
482
|
+
return {
|
|
483
|
+
name: "hide",
|
|
484
|
+
options,
|
|
485
|
+
async fn(state) {
|
|
486
|
+
const {
|
|
487
|
+
rects,
|
|
488
|
+
platform
|
|
489
|
+
} = state;
|
|
490
|
+
const {
|
|
491
|
+
strategy = "referenceHidden",
|
|
492
|
+
...detectOverflowOptions
|
|
493
|
+
} = evaluate(options, state);
|
|
494
|
+
switch (strategy) {
|
|
495
|
+
case "referenceHidden": {
|
|
496
|
+
const overflow = await platform.detectOverflow(state, {
|
|
497
|
+
...detectOverflowOptions,
|
|
498
|
+
elementContext: "reference"
|
|
499
|
+
});
|
|
500
|
+
const offsets = getSideOffsets(overflow, rects.reference);
|
|
501
|
+
return {
|
|
502
|
+
data: {
|
|
503
|
+
referenceHiddenOffsets: offsets,
|
|
504
|
+
referenceHidden: isAnySideFullyClipped(offsets)
|
|
505
|
+
}
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
case "escaped": {
|
|
509
|
+
const overflow = await platform.detectOverflow(state, {
|
|
510
|
+
...detectOverflowOptions,
|
|
511
|
+
altBoundary: true
|
|
512
|
+
});
|
|
513
|
+
const offsets = getSideOffsets(overflow, rects.floating);
|
|
514
|
+
return {
|
|
515
|
+
data: {
|
|
516
|
+
escapedOffsets: offsets,
|
|
517
|
+
escaped: isAnySideFullyClipped(offsets)
|
|
518
|
+
}
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
default: {
|
|
522
|
+
return {};
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
};
|
|
527
|
+
};
|
|
528
|
+
function getBoundingRect(rects) {
|
|
529
|
+
const minX = min(...rects.map((rect) => rect.left));
|
|
530
|
+
const minY = min(...rects.map((rect) => rect.top));
|
|
531
|
+
const maxX = max(...rects.map((rect) => rect.right));
|
|
532
|
+
const maxY = max(...rects.map((rect) => rect.bottom));
|
|
533
|
+
return {
|
|
534
|
+
x: minX,
|
|
535
|
+
y: minY,
|
|
536
|
+
width: maxX - minX,
|
|
537
|
+
height: maxY - minY
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
function getRectsByLine(rects) {
|
|
541
|
+
const sortedRects = rects.slice().sort((a, b) => a.y - b.y);
|
|
542
|
+
const groups = [];
|
|
543
|
+
let prevRect = null;
|
|
544
|
+
for (let i = 0; i < sortedRects.length; i++) {
|
|
545
|
+
const rect = sortedRects[i];
|
|
546
|
+
if (!prevRect || rect.y - prevRect.y > prevRect.height / 2) {
|
|
547
|
+
groups.push([rect]);
|
|
548
|
+
} else {
|
|
549
|
+
groups[groups.length - 1].push(rect);
|
|
550
|
+
}
|
|
551
|
+
prevRect = rect;
|
|
552
|
+
}
|
|
553
|
+
return groups.map((rect) => rectToClientRect(getBoundingRect(rect)));
|
|
554
|
+
}
|
|
555
|
+
const inline = function(options) {
|
|
556
|
+
if (options === void 0) {
|
|
557
|
+
options = {};
|
|
558
|
+
}
|
|
559
|
+
return {
|
|
560
|
+
name: "inline",
|
|
561
|
+
options,
|
|
562
|
+
async fn(state) {
|
|
563
|
+
const {
|
|
564
|
+
placement,
|
|
565
|
+
elements,
|
|
566
|
+
rects,
|
|
567
|
+
platform,
|
|
568
|
+
strategy
|
|
569
|
+
} = state;
|
|
570
|
+
const {
|
|
571
|
+
padding = 2,
|
|
572
|
+
x,
|
|
573
|
+
y
|
|
574
|
+
} = evaluate(options, state);
|
|
575
|
+
const nativeClientRects = Array.from(await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference)) || []);
|
|
576
|
+
const clientRects = getRectsByLine(nativeClientRects);
|
|
577
|
+
const fallback = rectToClientRect(getBoundingRect(nativeClientRects));
|
|
578
|
+
const paddingObject = getPaddingObject(padding);
|
|
579
|
+
function getBoundingClientRect() {
|
|
580
|
+
if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {
|
|
581
|
+
return clientRects.find((rect) => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom) || fallback;
|
|
582
|
+
}
|
|
583
|
+
if (clientRects.length >= 2) {
|
|
584
|
+
if (getSideAxis(placement) === "y") {
|
|
585
|
+
const firstRect = clientRects[0];
|
|
586
|
+
const lastRect = clientRects[clientRects.length - 1];
|
|
587
|
+
const isTop = getSide(placement) === "top";
|
|
588
|
+
const top2 = firstRect.top;
|
|
589
|
+
const bottom2 = lastRect.bottom;
|
|
590
|
+
const left2 = isTop ? firstRect.left : lastRect.left;
|
|
591
|
+
const right2 = isTop ? firstRect.right : lastRect.right;
|
|
592
|
+
const width2 = right2 - left2;
|
|
593
|
+
const height2 = bottom2 - top2;
|
|
594
|
+
return {
|
|
595
|
+
top: top2,
|
|
596
|
+
bottom: bottom2,
|
|
597
|
+
left: left2,
|
|
598
|
+
right: right2,
|
|
599
|
+
width: width2,
|
|
600
|
+
height: height2,
|
|
601
|
+
x: left2,
|
|
602
|
+
y: top2
|
|
603
|
+
};
|
|
604
|
+
}
|
|
605
|
+
const isLeftSide = getSide(placement) === "left";
|
|
606
|
+
const maxRight = max(...clientRects.map((rect) => rect.right));
|
|
607
|
+
const minLeft = min(...clientRects.map((rect) => rect.left));
|
|
608
|
+
const measureRects = clientRects.filter((rect) => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
|
|
609
|
+
const top = measureRects[0].top;
|
|
610
|
+
const bottom = measureRects[measureRects.length - 1].bottom;
|
|
611
|
+
const left = minLeft;
|
|
612
|
+
const right = maxRight;
|
|
613
|
+
const width = right - left;
|
|
614
|
+
const height = bottom - top;
|
|
615
|
+
return {
|
|
616
|
+
top,
|
|
617
|
+
bottom,
|
|
618
|
+
left,
|
|
619
|
+
right,
|
|
620
|
+
width,
|
|
621
|
+
height,
|
|
622
|
+
x: left,
|
|
623
|
+
y: top
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
return fallback;
|
|
627
|
+
}
|
|
628
|
+
const resetRects = await platform.getElementRects({
|
|
629
|
+
reference: {
|
|
630
|
+
getBoundingClientRect
|
|
631
|
+
},
|
|
632
|
+
floating: elements.floating,
|
|
633
|
+
strategy
|
|
634
|
+
});
|
|
635
|
+
if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) {
|
|
636
|
+
return {
|
|
637
|
+
reset: {
|
|
638
|
+
rects: resetRects
|
|
639
|
+
}
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
return {};
|
|
643
|
+
}
|
|
644
|
+
};
|
|
645
|
+
};
|
|
646
|
+
const originSides = /* @__PURE__ */ new Set(["left", "top"]);
|
|
647
|
+
async function convertValueToCoords(state, options) {
|
|
648
|
+
const {
|
|
649
|
+
placement,
|
|
650
|
+
platform,
|
|
651
|
+
elements
|
|
652
|
+
} = state;
|
|
653
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
654
|
+
const side = getSide(placement);
|
|
655
|
+
const alignment = getAlignment(placement);
|
|
656
|
+
const isVertical = getSideAxis(placement) === "y";
|
|
657
|
+
const mainAxisMulti = originSides.has(side) ? -1 : 1;
|
|
658
|
+
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
659
|
+
const rawValue = evaluate(options, state);
|
|
660
|
+
let {
|
|
661
|
+
mainAxis,
|
|
662
|
+
crossAxis,
|
|
663
|
+
alignmentAxis
|
|
664
|
+
} = typeof rawValue === "number" ? {
|
|
665
|
+
mainAxis: rawValue,
|
|
666
|
+
crossAxis: 0,
|
|
667
|
+
alignmentAxis: null
|
|
668
|
+
} : {
|
|
669
|
+
mainAxis: rawValue.mainAxis || 0,
|
|
670
|
+
crossAxis: rawValue.crossAxis || 0,
|
|
671
|
+
alignmentAxis: rawValue.alignmentAxis
|
|
672
|
+
};
|
|
673
|
+
if (alignment && typeof alignmentAxis === "number") {
|
|
674
|
+
crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
|
|
675
|
+
}
|
|
676
|
+
return isVertical ? {
|
|
677
|
+
x: crossAxis * crossAxisMulti,
|
|
678
|
+
y: mainAxis * mainAxisMulti
|
|
679
|
+
} : {
|
|
680
|
+
x: mainAxis * mainAxisMulti,
|
|
681
|
+
y: crossAxis * crossAxisMulti
|
|
682
|
+
};
|
|
683
|
+
}
|
|
684
|
+
const offset = function(options) {
|
|
685
|
+
if (options === void 0) {
|
|
686
|
+
options = 0;
|
|
687
|
+
}
|
|
688
|
+
return {
|
|
689
|
+
name: "offset",
|
|
690
|
+
options,
|
|
691
|
+
async fn(state) {
|
|
692
|
+
var _middlewareData$offse, _middlewareData$arrow;
|
|
693
|
+
const {
|
|
694
|
+
x,
|
|
695
|
+
y,
|
|
696
|
+
placement,
|
|
697
|
+
middlewareData
|
|
698
|
+
} = state;
|
|
699
|
+
const diffCoords = await convertValueToCoords(state, options);
|
|
700
|
+
if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
701
|
+
return {};
|
|
702
|
+
}
|
|
703
|
+
return {
|
|
704
|
+
x: x + diffCoords.x,
|
|
705
|
+
y: y + diffCoords.y,
|
|
706
|
+
data: {
|
|
707
|
+
...diffCoords,
|
|
708
|
+
placement
|
|
709
|
+
}
|
|
710
|
+
};
|
|
711
|
+
}
|
|
712
|
+
};
|
|
713
|
+
};
|
|
714
|
+
const shift = function(options) {
|
|
715
|
+
if (options === void 0) {
|
|
716
|
+
options = {};
|
|
717
|
+
}
|
|
718
|
+
return {
|
|
719
|
+
name: "shift",
|
|
720
|
+
options,
|
|
721
|
+
async fn(state) {
|
|
722
|
+
const {
|
|
723
|
+
x,
|
|
724
|
+
y,
|
|
725
|
+
placement,
|
|
726
|
+
platform
|
|
727
|
+
} = state;
|
|
728
|
+
const {
|
|
729
|
+
mainAxis: checkMainAxis = true,
|
|
730
|
+
crossAxis: checkCrossAxis = false,
|
|
731
|
+
limiter = {
|
|
732
|
+
fn: (_ref) => {
|
|
733
|
+
let {
|
|
734
|
+
x: x2,
|
|
735
|
+
y: y2
|
|
736
|
+
} = _ref;
|
|
737
|
+
return {
|
|
738
|
+
x: x2,
|
|
739
|
+
y: y2
|
|
740
|
+
};
|
|
741
|
+
}
|
|
742
|
+
},
|
|
743
|
+
...detectOverflowOptions
|
|
744
|
+
} = evaluate(options, state);
|
|
745
|
+
const coords = {
|
|
746
|
+
x,
|
|
747
|
+
y
|
|
748
|
+
};
|
|
749
|
+
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
|
750
|
+
const crossAxis = getSideAxis(getSide(placement));
|
|
751
|
+
const mainAxis = getOppositeAxis(crossAxis);
|
|
752
|
+
let mainAxisCoord = coords[mainAxis];
|
|
753
|
+
let crossAxisCoord = coords[crossAxis];
|
|
754
|
+
if (checkMainAxis) {
|
|
755
|
+
const minSide = mainAxis === "y" ? "top" : "left";
|
|
756
|
+
const maxSide = mainAxis === "y" ? "bottom" : "right";
|
|
757
|
+
const min2 = mainAxisCoord + overflow[minSide];
|
|
758
|
+
const max2 = mainAxisCoord - overflow[maxSide];
|
|
759
|
+
mainAxisCoord = clamp(min2, mainAxisCoord, max2);
|
|
760
|
+
}
|
|
761
|
+
if (checkCrossAxis) {
|
|
762
|
+
const minSide = crossAxis === "y" ? "top" : "left";
|
|
763
|
+
const maxSide = crossAxis === "y" ? "bottom" : "right";
|
|
764
|
+
const min2 = crossAxisCoord + overflow[minSide];
|
|
765
|
+
const max2 = crossAxisCoord - overflow[maxSide];
|
|
766
|
+
crossAxisCoord = clamp(min2, crossAxisCoord, max2);
|
|
767
|
+
}
|
|
768
|
+
const limitedCoords = limiter.fn({
|
|
769
|
+
...state,
|
|
770
|
+
[mainAxis]: mainAxisCoord,
|
|
771
|
+
[crossAxis]: crossAxisCoord
|
|
772
|
+
});
|
|
773
|
+
return {
|
|
774
|
+
...limitedCoords,
|
|
775
|
+
data: {
|
|
776
|
+
x: limitedCoords.x - x,
|
|
777
|
+
y: limitedCoords.y - y,
|
|
778
|
+
enabled: {
|
|
779
|
+
[mainAxis]: checkMainAxis,
|
|
780
|
+
[crossAxis]: checkCrossAxis
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
};
|
|
784
|
+
}
|
|
785
|
+
};
|
|
786
|
+
};
|
|
787
|
+
const size = function(options) {
|
|
788
|
+
if (options === void 0) {
|
|
789
|
+
options = {};
|
|
790
|
+
}
|
|
791
|
+
return {
|
|
792
|
+
name: "size",
|
|
793
|
+
options,
|
|
794
|
+
async fn(state) {
|
|
795
|
+
var _state$middlewareData, _state$middlewareData2;
|
|
796
|
+
const {
|
|
797
|
+
placement,
|
|
798
|
+
rects,
|
|
799
|
+
platform,
|
|
800
|
+
elements
|
|
801
|
+
} = state;
|
|
802
|
+
const {
|
|
803
|
+
apply = () => {
|
|
804
|
+
},
|
|
805
|
+
...detectOverflowOptions
|
|
806
|
+
} = evaluate(options, state);
|
|
807
|
+
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
|
808
|
+
const side = getSide(placement);
|
|
809
|
+
const alignment = getAlignment(placement);
|
|
810
|
+
const isYAxis = getSideAxis(placement) === "y";
|
|
811
|
+
const {
|
|
812
|
+
width,
|
|
813
|
+
height
|
|
814
|
+
} = rects.floating;
|
|
815
|
+
let heightSide;
|
|
816
|
+
let widthSide;
|
|
817
|
+
if (side === "top" || side === "bottom") {
|
|
818
|
+
heightSide = side;
|
|
819
|
+
widthSide = alignment === (await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
|
|
820
|
+
} else {
|
|
821
|
+
widthSide = side;
|
|
822
|
+
heightSide = alignment === "end" ? "top" : "bottom";
|
|
823
|
+
}
|
|
824
|
+
const maximumClippingHeight = height - overflow.top - overflow.bottom;
|
|
825
|
+
const maximumClippingWidth = width - overflow.left - overflow.right;
|
|
826
|
+
const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
|
|
827
|
+
const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
|
|
828
|
+
const noShift = !state.middlewareData.shift;
|
|
829
|
+
let availableHeight = overflowAvailableHeight;
|
|
830
|
+
let availableWidth = overflowAvailableWidth;
|
|
831
|
+
if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
|
|
832
|
+
availableWidth = maximumClippingWidth;
|
|
833
|
+
}
|
|
834
|
+
if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
|
|
835
|
+
availableHeight = maximumClippingHeight;
|
|
836
|
+
}
|
|
837
|
+
if (noShift && !alignment) {
|
|
838
|
+
const xMin = max(overflow.left, 0);
|
|
839
|
+
const xMax = max(overflow.right, 0);
|
|
840
|
+
const yMin = max(overflow.top, 0);
|
|
841
|
+
const yMax = max(overflow.bottom, 0);
|
|
842
|
+
if (isYAxis) {
|
|
843
|
+
availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
|
|
844
|
+
} else {
|
|
845
|
+
availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
await apply({
|
|
849
|
+
...state,
|
|
850
|
+
availableWidth,
|
|
851
|
+
availableHeight
|
|
852
|
+
});
|
|
853
|
+
const nextDimensions = await platform.getDimensions(elements.floating);
|
|
854
|
+
if (width !== nextDimensions.width || height !== nextDimensions.height) {
|
|
855
|
+
return {
|
|
856
|
+
reset: {
|
|
857
|
+
rects: true
|
|
858
|
+
}
|
|
859
|
+
};
|
|
860
|
+
}
|
|
861
|
+
return {};
|
|
862
|
+
}
|
|
863
|
+
};
|
|
864
|
+
};
|
|
865
|
+
export {
|
|
866
|
+
arrow,
|
|
867
|
+
autoPlacement,
|
|
868
|
+
computePosition,
|
|
869
|
+
detectOverflow,
|
|
870
|
+
flip,
|
|
871
|
+
hide,
|
|
872
|
+
inline,
|
|
873
|
+
offset,
|
|
874
|
+
rectToClientRect,
|
|
875
|
+
shift,
|
|
876
|
+
size
|
|
877
|
+
};
|
|
878
|
+
//# sourceMappingURL=floating-ui.core.js.map
|