@ariakit/core 0.1.5 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +56 -0
- package/cjs/__chunks/{LBTLD2RB.cjs → CNODBYSG.cjs} +2 -2
- package/cjs/__chunks/RD3S4VKY.cjs +60 -0
- package/cjs/combobox/combobox-store.cjs +2 -2
- package/cjs/composite/composite-overflow-store.cjs +2 -2
- package/cjs/hovercard/hovercard-store.cjs +3 -3
- package/cjs/hovercard/hovercard-store.d.ts +3 -2
- package/cjs/menu/menu-store.cjs +3 -3
- package/cjs/popover/popover-store.cjs +2 -2
- package/cjs/popover/popover-store.d.ts +8 -89
- package/cjs/select/select-store.cjs +2 -2
- package/cjs/tooltip/tooltip-store.cjs +21 -68
- package/cjs/tooltip/tooltip-store.d.ts +20 -15
- package/cjs/tsconfig.build.tsbuildinfo +1 -1
- package/esm/__chunks/{AHZW5LR4.js → 3BAGFTL5.js} +1 -1
- package/esm/__chunks/Z5IDQSMV.js +60 -0
- package/esm/combobox/combobox-store.js +1 -1
- package/esm/composite/composite-overflow-store.js +1 -1
- package/esm/hovercard/hovercard-store.d.ts +3 -2
- package/esm/hovercard/hovercard-store.js +2 -2
- package/esm/menu/menu-store.js +2 -2
- package/esm/popover/popover-store.d.ts +8 -89
- package/esm/popover/popover-store.js +1 -1
- package/esm/select/select-store.js +1 -1
- package/esm/tooltip/tooltip-store.d.ts +20 -15
- package/esm/tooltip/tooltip-store.js +22 -69
- package/esm/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/cjs/__chunks/SDBF6KIY.cjs +0 -1491
- package/esm/__chunks/CUW3E24J.js +0 -1491
package/esm/__chunks/CUW3E24J.js
DELETED
|
@@ -1,1491 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createDialogStore
|
|
3
|
-
} from "./MNNKHNLW.js";
|
|
4
|
-
import {
|
|
5
|
-
createStore,
|
|
6
|
-
mergeStore
|
|
7
|
-
} from "./BOKMNDR7.js";
|
|
8
|
-
import {
|
|
9
|
-
defaultValue
|
|
10
|
-
} from "./NWU4GBZ6.js";
|
|
11
|
-
import {
|
|
12
|
-
__objRest,
|
|
13
|
-
__spreadProps,
|
|
14
|
-
__spreadValues
|
|
15
|
-
} from "./4BKCJXBM.js";
|
|
16
|
-
|
|
17
|
-
// ../../node_modules/@floating-ui/core/dist/floating-ui.core.mjs
|
|
18
|
-
function getAlignment(placement) {
|
|
19
|
-
return placement.split("-")[1];
|
|
20
|
-
}
|
|
21
|
-
function getLengthFromAxis(axis) {
|
|
22
|
-
return axis === "y" ? "height" : "width";
|
|
23
|
-
}
|
|
24
|
-
function getSide(placement) {
|
|
25
|
-
return placement.split("-")[0];
|
|
26
|
-
}
|
|
27
|
-
function getMainAxisFromPlacement(placement) {
|
|
28
|
-
return ["top", "bottom"].includes(getSide(placement)) ? "x" : "y";
|
|
29
|
-
}
|
|
30
|
-
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
31
|
-
let {
|
|
32
|
-
reference,
|
|
33
|
-
floating
|
|
34
|
-
} = _ref;
|
|
35
|
-
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
36
|
-
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
37
|
-
const mainAxis = getMainAxisFromPlacement(placement);
|
|
38
|
-
const length = getLengthFromAxis(mainAxis);
|
|
39
|
-
const commonAlign = reference[length] / 2 - floating[length] / 2;
|
|
40
|
-
const side = getSide(placement);
|
|
41
|
-
const isVertical = mainAxis === "x";
|
|
42
|
-
let coords;
|
|
43
|
-
switch (side) {
|
|
44
|
-
case "top":
|
|
45
|
-
coords = {
|
|
46
|
-
x: commonX,
|
|
47
|
-
y: reference.y - floating.height
|
|
48
|
-
};
|
|
49
|
-
break;
|
|
50
|
-
case "bottom":
|
|
51
|
-
coords = {
|
|
52
|
-
x: commonX,
|
|
53
|
-
y: reference.y + reference.height
|
|
54
|
-
};
|
|
55
|
-
break;
|
|
56
|
-
case "right":
|
|
57
|
-
coords = {
|
|
58
|
-
x: reference.x + reference.width,
|
|
59
|
-
y: commonY
|
|
60
|
-
};
|
|
61
|
-
break;
|
|
62
|
-
case "left":
|
|
63
|
-
coords = {
|
|
64
|
-
x: reference.x - floating.width,
|
|
65
|
-
y: commonY
|
|
66
|
-
};
|
|
67
|
-
break;
|
|
68
|
-
default:
|
|
69
|
-
coords = {
|
|
70
|
-
x: reference.x,
|
|
71
|
-
y: reference.y
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
switch (getAlignment(placement)) {
|
|
75
|
-
case "start":
|
|
76
|
-
coords[mainAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
77
|
-
break;
|
|
78
|
-
case "end":
|
|
79
|
-
coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
80
|
-
break;
|
|
81
|
-
}
|
|
82
|
-
return coords;
|
|
83
|
-
}
|
|
84
|
-
var computePosition = async (reference, floating, config) => {
|
|
85
|
-
const {
|
|
86
|
-
placement = "bottom",
|
|
87
|
-
strategy = "absolute",
|
|
88
|
-
middleware = [],
|
|
89
|
-
platform: platform2
|
|
90
|
-
} = config;
|
|
91
|
-
const validMiddleware = middleware.filter(Boolean);
|
|
92
|
-
const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating));
|
|
93
|
-
let rects = await platform2.getElementRects({
|
|
94
|
-
reference,
|
|
95
|
-
floating,
|
|
96
|
-
strategy
|
|
97
|
-
});
|
|
98
|
-
let {
|
|
99
|
-
x,
|
|
100
|
-
y
|
|
101
|
-
} = computeCoordsFromPlacement(rects, placement, rtl);
|
|
102
|
-
let statefulPlacement = placement;
|
|
103
|
-
let middlewareData = {};
|
|
104
|
-
let resetCount = 0;
|
|
105
|
-
for (let i = 0; i < validMiddleware.length; i++) {
|
|
106
|
-
const {
|
|
107
|
-
name,
|
|
108
|
-
fn
|
|
109
|
-
} = validMiddleware[i];
|
|
110
|
-
const {
|
|
111
|
-
x: nextX,
|
|
112
|
-
y: nextY,
|
|
113
|
-
data,
|
|
114
|
-
reset
|
|
115
|
-
} = await fn({
|
|
116
|
-
x,
|
|
117
|
-
y,
|
|
118
|
-
initialPlacement: placement,
|
|
119
|
-
placement: statefulPlacement,
|
|
120
|
-
strategy,
|
|
121
|
-
middlewareData,
|
|
122
|
-
rects,
|
|
123
|
-
platform: platform2,
|
|
124
|
-
elements: {
|
|
125
|
-
reference,
|
|
126
|
-
floating
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
x = nextX != null ? nextX : x;
|
|
130
|
-
y = nextY != null ? nextY : y;
|
|
131
|
-
middlewareData = __spreadProps(__spreadValues({}, middlewareData), {
|
|
132
|
-
[name]: __spreadValues(__spreadValues({}, middlewareData[name]), data)
|
|
133
|
-
});
|
|
134
|
-
if (reset && resetCount <= 50) {
|
|
135
|
-
resetCount++;
|
|
136
|
-
if (typeof reset === "object") {
|
|
137
|
-
if (reset.placement) {
|
|
138
|
-
statefulPlacement = reset.placement;
|
|
139
|
-
}
|
|
140
|
-
if (reset.rects) {
|
|
141
|
-
rects = reset.rects === true ? await platform2.getElementRects({
|
|
142
|
-
reference,
|
|
143
|
-
floating,
|
|
144
|
-
strategy
|
|
145
|
-
}) : reset.rects;
|
|
146
|
-
}
|
|
147
|
-
({
|
|
148
|
-
x,
|
|
149
|
-
y
|
|
150
|
-
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
151
|
-
}
|
|
152
|
-
i = -1;
|
|
153
|
-
continue;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
return {
|
|
157
|
-
x,
|
|
158
|
-
y,
|
|
159
|
-
placement: statefulPlacement,
|
|
160
|
-
strategy,
|
|
161
|
-
middlewareData
|
|
162
|
-
};
|
|
163
|
-
};
|
|
164
|
-
function expandPaddingObject(padding) {
|
|
165
|
-
return __spreadValues({
|
|
166
|
-
top: 0,
|
|
167
|
-
right: 0,
|
|
168
|
-
bottom: 0,
|
|
169
|
-
left: 0
|
|
170
|
-
}, padding);
|
|
171
|
-
}
|
|
172
|
-
function getSideObjectFromPadding(padding) {
|
|
173
|
-
return typeof padding !== "number" ? expandPaddingObject(padding) : {
|
|
174
|
-
top: padding,
|
|
175
|
-
right: padding,
|
|
176
|
-
bottom: padding,
|
|
177
|
-
left: padding
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
function rectToClientRect(rect) {
|
|
181
|
-
return __spreadProps(__spreadValues({}, rect), {
|
|
182
|
-
top: rect.y,
|
|
183
|
-
left: rect.x,
|
|
184
|
-
right: rect.x + rect.width,
|
|
185
|
-
bottom: rect.y + rect.height
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
async function detectOverflow(state, options) {
|
|
189
|
-
var _await$platform$isEle;
|
|
190
|
-
if (options === void 0) {
|
|
191
|
-
options = {};
|
|
192
|
-
}
|
|
193
|
-
const {
|
|
194
|
-
x,
|
|
195
|
-
y,
|
|
196
|
-
platform: platform2,
|
|
197
|
-
rects,
|
|
198
|
-
elements,
|
|
199
|
-
strategy
|
|
200
|
-
} = state;
|
|
201
|
-
const {
|
|
202
|
-
boundary = "clippingAncestors",
|
|
203
|
-
rootBoundary = "viewport",
|
|
204
|
-
elementContext = "floating",
|
|
205
|
-
altBoundary = false,
|
|
206
|
-
padding = 0
|
|
207
|
-
} = options;
|
|
208
|
-
const paddingObject = getSideObjectFromPadding(padding);
|
|
209
|
-
const altContext = elementContext === "floating" ? "reference" : "floating";
|
|
210
|
-
const element = elements[altBoundary ? altContext : elementContext];
|
|
211
|
-
const clippingClientRect = rectToClientRect(await platform2.getClippingRect({
|
|
212
|
-
element: ((_await$platform$isEle = await (platform2.isElement == null ? void 0 : platform2.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform2.getDocumentElement == null ? void 0 : platform2.getDocumentElement(elements.floating)),
|
|
213
|
-
boundary,
|
|
214
|
-
rootBoundary,
|
|
215
|
-
strategy
|
|
216
|
-
}));
|
|
217
|
-
const rect = elementContext === "floating" ? __spreadProps(__spreadValues({}, rects.floating), {
|
|
218
|
-
x,
|
|
219
|
-
y
|
|
220
|
-
}) : rects.reference;
|
|
221
|
-
const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating));
|
|
222
|
-
const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || {
|
|
223
|
-
x: 1,
|
|
224
|
-
y: 1
|
|
225
|
-
} : {
|
|
226
|
-
x: 1,
|
|
227
|
-
y: 1
|
|
228
|
-
};
|
|
229
|
-
const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
230
|
-
rect,
|
|
231
|
-
offsetParent,
|
|
232
|
-
strategy
|
|
233
|
-
}) : rect);
|
|
234
|
-
return {
|
|
235
|
-
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
|
236
|
-
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
|
237
|
-
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
|
238
|
-
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
var min = Math.min;
|
|
242
|
-
var max = Math.max;
|
|
243
|
-
function within(min$1, value, max$1) {
|
|
244
|
-
return max(min$1, min(value, max$1));
|
|
245
|
-
}
|
|
246
|
-
var arrow = (options) => ({
|
|
247
|
-
name: "arrow",
|
|
248
|
-
options,
|
|
249
|
-
async fn(state) {
|
|
250
|
-
const {
|
|
251
|
-
element,
|
|
252
|
-
padding = 0
|
|
253
|
-
} = options || {};
|
|
254
|
-
const {
|
|
255
|
-
x,
|
|
256
|
-
y,
|
|
257
|
-
placement,
|
|
258
|
-
rects,
|
|
259
|
-
platform: platform2,
|
|
260
|
-
elements
|
|
261
|
-
} = state;
|
|
262
|
-
if (element == null) {
|
|
263
|
-
return {};
|
|
264
|
-
}
|
|
265
|
-
const paddingObject = getSideObjectFromPadding(padding);
|
|
266
|
-
const coords = {
|
|
267
|
-
x,
|
|
268
|
-
y
|
|
269
|
-
};
|
|
270
|
-
const axis = getMainAxisFromPlacement(placement);
|
|
271
|
-
const length = getLengthFromAxis(axis);
|
|
272
|
-
const arrowDimensions = await platform2.getDimensions(element);
|
|
273
|
-
const isYAxis = axis === "y";
|
|
274
|
-
const minProp = isYAxis ? "top" : "left";
|
|
275
|
-
const maxProp = isYAxis ? "bottom" : "right";
|
|
276
|
-
const clientProp = isYAxis ? "clientHeight" : "clientWidth";
|
|
277
|
-
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
|
|
278
|
-
const startDiff = coords[axis] - rects.reference[axis];
|
|
279
|
-
const arrowOffsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(element));
|
|
280
|
-
let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
|
|
281
|
-
if (!clientSize || !await (platform2.isElement == null ? void 0 : platform2.isElement(arrowOffsetParent))) {
|
|
282
|
-
clientSize = elements.floating[clientProp] || rects.floating[length];
|
|
283
|
-
}
|
|
284
|
-
const centerToReference = endDiff / 2 - startDiff / 2;
|
|
285
|
-
const min3 = paddingObject[minProp];
|
|
286
|
-
const max3 = clientSize - arrowDimensions[length] - paddingObject[maxProp];
|
|
287
|
-
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
|
288
|
-
const offset2 = within(min3, center, max3);
|
|
289
|
-
const shouldAddOffset = getAlignment(placement) != null && center != offset2 && rects.reference[length] / 2 - (center < min3 ? paddingObject[minProp] : paddingObject[maxProp]) - arrowDimensions[length] / 2 < 0;
|
|
290
|
-
const alignmentOffset = shouldAddOffset ? center < min3 ? min3 - center : max3 - center : 0;
|
|
291
|
-
return {
|
|
292
|
-
[axis]: coords[axis] - alignmentOffset,
|
|
293
|
-
data: {
|
|
294
|
-
[axis]: offset2,
|
|
295
|
-
centerOffset: center - offset2
|
|
296
|
-
}
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
});
|
|
300
|
-
var oppositeSideMap = {
|
|
301
|
-
left: "right",
|
|
302
|
-
right: "left",
|
|
303
|
-
bottom: "top",
|
|
304
|
-
top: "bottom"
|
|
305
|
-
};
|
|
306
|
-
function getOppositePlacement(placement) {
|
|
307
|
-
return placement.replace(/left|right|bottom|top/g, (side) => oppositeSideMap[side]);
|
|
308
|
-
}
|
|
309
|
-
function getAlignmentSides(placement, rects, rtl) {
|
|
310
|
-
if (rtl === void 0) {
|
|
311
|
-
rtl = false;
|
|
312
|
-
}
|
|
313
|
-
const alignment = getAlignment(placement);
|
|
314
|
-
const mainAxis = getMainAxisFromPlacement(placement);
|
|
315
|
-
const length = getLengthFromAxis(mainAxis);
|
|
316
|
-
let mainAlignmentSide = mainAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
|
|
317
|
-
if (rects.reference[length] > rects.floating[length]) {
|
|
318
|
-
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
319
|
-
}
|
|
320
|
-
return {
|
|
321
|
-
main: mainAlignmentSide,
|
|
322
|
-
cross: getOppositePlacement(mainAlignmentSide)
|
|
323
|
-
};
|
|
324
|
-
}
|
|
325
|
-
var oppositeAlignmentMap = {
|
|
326
|
-
start: "end",
|
|
327
|
-
end: "start"
|
|
328
|
-
};
|
|
329
|
-
function getOppositeAlignmentPlacement(placement) {
|
|
330
|
-
return placement.replace(/start|end/g, (alignment) => oppositeAlignmentMap[alignment]);
|
|
331
|
-
}
|
|
332
|
-
function getExpandedPlacements(placement) {
|
|
333
|
-
const oppositePlacement = getOppositePlacement(placement);
|
|
334
|
-
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
335
|
-
}
|
|
336
|
-
function getSideList(side, isStart, rtl) {
|
|
337
|
-
const lr = ["left", "right"];
|
|
338
|
-
const rl = ["right", "left"];
|
|
339
|
-
const tb = ["top", "bottom"];
|
|
340
|
-
const bt = ["bottom", "top"];
|
|
341
|
-
switch (side) {
|
|
342
|
-
case "top":
|
|
343
|
-
case "bottom":
|
|
344
|
-
if (rtl)
|
|
345
|
-
return isStart ? rl : lr;
|
|
346
|
-
return isStart ? lr : rl;
|
|
347
|
-
case "left":
|
|
348
|
-
case "right":
|
|
349
|
-
return isStart ? tb : bt;
|
|
350
|
-
default:
|
|
351
|
-
return [];
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
|
355
|
-
const alignment = getAlignment(placement);
|
|
356
|
-
let list = getSideList(getSide(placement), direction === "start", rtl);
|
|
357
|
-
if (alignment) {
|
|
358
|
-
list = list.map((side) => side + "-" + alignment);
|
|
359
|
-
if (flipAlignment) {
|
|
360
|
-
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
return list;
|
|
364
|
-
}
|
|
365
|
-
var flip = function(options) {
|
|
366
|
-
if (options === void 0) {
|
|
367
|
-
options = {};
|
|
368
|
-
}
|
|
369
|
-
return {
|
|
370
|
-
name: "flip",
|
|
371
|
-
options,
|
|
372
|
-
async fn(state) {
|
|
373
|
-
var _middlewareData$flip;
|
|
374
|
-
const {
|
|
375
|
-
placement,
|
|
376
|
-
middlewareData,
|
|
377
|
-
rects,
|
|
378
|
-
initialPlacement,
|
|
379
|
-
platform: platform2,
|
|
380
|
-
elements
|
|
381
|
-
} = state;
|
|
382
|
-
const _a = options, {
|
|
383
|
-
mainAxis: checkMainAxis = true,
|
|
384
|
-
crossAxis: checkCrossAxis = true,
|
|
385
|
-
fallbackPlacements: specifiedFallbackPlacements,
|
|
386
|
-
fallbackStrategy = "bestFit",
|
|
387
|
-
fallbackAxisSideDirection = "none",
|
|
388
|
-
flipAlignment = true
|
|
389
|
-
} = _a, detectOverflowOptions = __objRest(_a, [
|
|
390
|
-
"mainAxis",
|
|
391
|
-
"crossAxis",
|
|
392
|
-
"fallbackPlacements",
|
|
393
|
-
"fallbackStrategy",
|
|
394
|
-
"fallbackAxisSideDirection",
|
|
395
|
-
"flipAlignment"
|
|
396
|
-
]);
|
|
397
|
-
const side = getSide(placement);
|
|
398
|
-
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
399
|
-
const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
|
|
400
|
-
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
401
|
-
if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== "none") {
|
|
402
|
-
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
|
403
|
-
}
|
|
404
|
-
const placements = [initialPlacement, ...fallbackPlacements];
|
|
405
|
-
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
406
|
-
const overflows = [];
|
|
407
|
-
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
408
|
-
if (checkMainAxis) {
|
|
409
|
-
overflows.push(overflow[side]);
|
|
410
|
-
}
|
|
411
|
-
if (checkCrossAxis) {
|
|
412
|
-
const {
|
|
413
|
-
main,
|
|
414
|
-
cross
|
|
415
|
-
} = getAlignmentSides(placement, rects, rtl);
|
|
416
|
-
overflows.push(overflow[main], overflow[cross]);
|
|
417
|
-
}
|
|
418
|
-
overflowsData = [...overflowsData, {
|
|
419
|
-
placement,
|
|
420
|
-
overflows
|
|
421
|
-
}];
|
|
422
|
-
if (!overflows.every((side2) => side2 <= 0)) {
|
|
423
|
-
var _middlewareData$flip2, _overflowsData$filter;
|
|
424
|
-
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
|
425
|
-
const nextPlacement = placements[nextIndex];
|
|
426
|
-
if (nextPlacement) {
|
|
427
|
-
return {
|
|
428
|
-
data: {
|
|
429
|
-
index: nextIndex,
|
|
430
|
-
overflows: overflowsData
|
|
431
|
-
},
|
|
432
|
-
reset: {
|
|
433
|
-
placement: nextPlacement
|
|
434
|
-
}
|
|
435
|
-
};
|
|
436
|
-
}
|
|
437
|
-
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;
|
|
438
|
-
if (!resetPlacement) {
|
|
439
|
-
switch (fallbackStrategy) {
|
|
440
|
-
case "bestFit": {
|
|
441
|
-
var _overflowsData$map$so;
|
|
442
|
-
const placement2 = (_overflowsData$map$so = overflowsData.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$map$so[0];
|
|
443
|
-
if (placement2) {
|
|
444
|
-
resetPlacement = placement2;
|
|
445
|
-
}
|
|
446
|
-
break;
|
|
447
|
-
}
|
|
448
|
-
case "initialPlacement":
|
|
449
|
-
resetPlacement = initialPlacement;
|
|
450
|
-
break;
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
if (placement !== resetPlacement) {
|
|
454
|
-
return {
|
|
455
|
-
reset: {
|
|
456
|
-
placement: resetPlacement
|
|
457
|
-
}
|
|
458
|
-
};
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
return {};
|
|
462
|
-
}
|
|
463
|
-
};
|
|
464
|
-
};
|
|
465
|
-
async function convertValueToCoords(state, value) {
|
|
466
|
-
const {
|
|
467
|
-
placement,
|
|
468
|
-
platform: platform2,
|
|
469
|
-
elements
|
|
470
|
-
} = state;
|
|
471
|
-
const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
|
|
472
|
-
const side = getSide(placement);
|
|
473
|
-
const alignment = getAlignment(placement);
|
|
474
|
-
const isVertical = getMainAxisFromPlacement(placement) === "x";
|
|
475
|
-
const mainAxisMulti = ["left", "top"].includes(side) ? -1 : 1;
|
|
476
|
-
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
477
|
-
const rawValue = typeof value === "function" ? value(state) : value;
|
|
478
|
-
let {
|
|
479
|
-
mainAxis,
|
|
480
|
-
crossAxis,
|
|
481
|
-
alignmentAxis
|
|
482
|
-
} = typeof rawValue === "number" ? {
|
|
483
|
-
mainAxis: rawValue,
|
|
484
|
-
crossAxis: 0,
|
|
485
|
-
alignmentAxis: null
|
|
486
|
-
} : __spreadValues({
|
|
487
|
-
mainAxis: 0,
|
|
488
|
-
crossAxis: 0,
|
|
489
|
-
alignmentAxis: null
|
|
490
|
-
}, rawValue);
|
|
491
|
-
if (alignment && typeof alignmentAxis === "number") {
|
|
492
|
-
crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
|
|
493
|
-
}
|
|
494
|
-
return isVertical ? {
|
|
495
|
-
x: crossAxis * crossAxisMulti,
|
|
496
|
-
y: mainAxis * mainAxisMulti
|
|
497
|
-
} : {
|
|
498
|
-
x: mainAxis * mainAxisMulti,
|
|
499
|
-
y: crossAxis * crossAxisMulti
|
|
500
|
-
};
|
|
501
|
-
}
|
|
502
|
-
var offset = function(value) {
|
|
503
|
-
if (value === void 0) {
|
|
504
|
-
value = 0;
|
|
505
|
-
}
|
|
506
|
-
return {
|
|
507
|
-
name: "offset",
|
|
508
|
-
options: value,
|
|
509
|
-
async fn(state) {
|
|
510
|
-
const {
|
|
511
|
-
x,
|
|
512
|
-
y
|
|
513
|
-
} = state;
|
|
514
|
-
const diffCoords = await convertValueToCoords(state, value);
|
|
515
|
-
return {
|
|
516
|
-
x: x + diffCoords.x,
|
|
517
|
-
y: y + diffCoords.y,
|
|
518
|
-
data: diffCoords
|
|
519
|
-
};
|
|
520
|
-
}
|
|
521
|
-
};
|
|
522
|
-
};
|
|
523
|
-
function getCrossAxis(axis) {
|
|
524
|
-
return axis === "x" ? "y" : "x";
|
|
525
|
-
}
|
|
526
|
-
var shift = function(options) {
|
|
527
|
-
if (options === void 0) {
|
|
528
|
-
options = {};
|
|
529
|
-
}
|
|
530
|
-
return {
|
|
531
|
-
name: "shift",
|
|
532
|
-
options,
|
|
533
|
-
async fn(state) {
|
|
534
|
-
const {
|
|
535
|
-
x,
|
|
536
|
-
y,
|
|
537
|
-
placement
|
|
538
|
-
} = state;
|
|
539
|
-
const _a = options, {
|
|
540
|
-
mainAxis: checkMainAxis = true,
|
|
541
|
-
crossAxis: checkCrossAxis = false,
|
|
542
|
-
limiter = {
|
|
543
|
-
fn: (_ref) => {
|
|
544
|
-
let {
|
|
545
|
-
x: x2,
|
|
546
|
-
y: y2
|
|
547
|
-
} = _ref;
|
|
548
|
-
return {
|
|
549
|
-
x: x2,
|
|
550
|
-
y: y2
|
|
551
|
-
};
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
} = _a, detectOverflowOptions = __objRest(_a, [
|
|
555
|
-
"mainAxis",
|
|
556
|
-
"crossAxis",
|
|
557
|
-
"limiter"
|
|
558
|
-
]);
|
|
559
|
-
const coords = {
|
|
560
|
-
x,
|
|
561
|
-
y
|
|
562
|
-
};
|
|
563
|
-
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
564
|
-
const mainAxis = getMainAxisFromPlacement(getSide(placement));
|
|
565
|
-
const crossAxis = getCrossAxis(mainAxis);
|
|
566
|
-
let mainAxisCoord = coords[mainAxis];
|
|
567
|
-
let crossAxisCoord = coords[crossAxis];
|
|
568
|
-
if (checkMainAxis) {
|
|
569
|
-
const minSide = mainAxis === "y" ? "top" : "left";
|
|
570
|
-
const maxSide = mainAxis === "y" ? "bottom" : "right";
|
|
571
|
-
const min3 = mainAxisCoord + overflow[minSide];
|
|
572
|
-
const max3 = mainAxisCoord - overflow[maxSide];
|
|
573
|
-
mainAxisCoord = within(min3, mainAxisCoord, max3);
|
|
574
|
-
}
|
|
575
|
-
if (checkCrossAxis) {
|
|
576
|
-
const minSide = crossAxis === "y" ? "top" : "left";
|
|
577
|
-
const maxSide = crossAxis === "y" ? "bottom" : "right";
|
|
578
|
-
const min3 = crossAxisCoord + overflow[minSide];
|
|
579
|
-
const max3 = crossAxisCoord - overflow[maxSide];
|
|
580
|
-
crossAxisCoord = within(min3, crossAxisCoord, max3);
|
|
581
|
-
}
|
|
582
|
-
const limitedCoords = limiter.fn(__spreadProps(__spreadValues({}, state), {
|
|
583
|
-
[mainAxis]: mainAxisCoord,
|
|
584
|
-
[crossAxis]: crossAxisCoord
|
|
585
|
-
}));
|
|
586
|
-
return __spreadProps(__spreadValues({}, limitedCoords), {
|
|
587
|
-
data: {
|
|
588
|
-
x: limitedCoords.x - x,
|
|
589
|
-
y: limitedCoords.y - y
|
|
590
|
-
}
|
|
591
|
-
});
|
|
592
|
-
}
|
|
593
|
-
};
|
|
594
|
-
};
|
|
595
|
-
var size = function(options) {
|
|
596
|
-
if (options === void 0) {
|
|
597
|
-
options = {};
|
|
598
|
-
}
|
|
599
|
-
return {
|
|
600
|
-
name: "size",
|
|
601
|
-
options,
|
|
602
|
-
async fn(state) {
|
|
603
|
-
const {
|
|
604
|
-
placement,
|
|
605
|
-
rects,
|
|
606
|
-
platform: platform2,
|
|
607
|
-
elements
|
|
608
|
-
} = state;
|
|
609
|
-
const _a = options, {
|
|
610
|
-
apply = () => {
|
|
611
|
-
}
|
|
612
|
-
} = _a, detectOverflowOptions = __objRest(_a, [
|
|
613
|
-
"apply"
|
|
614
|
-
]);
|
|
615
|
-
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
616
|
-
const side = getSide(placement);
|
|
617
|
-
const alignment = getAlignment(placement);
|
|
618
|
-
const axis = getMainAxisFromPlacement(placement);
|
|
619
|
-
const isXAxis = axis === "x";
|
|
620
|
-
const {
|
|
621
|
-
width,
|
|
622
|
-
height
|
|
623
|
-
} = rects.floating;
|
|
624
|
-
let heightSide;
|
|
625
|
-
let widthSide;
|
|
626
|
-
if (side === "top" || side === "bottom") {
|
|
627
|
-
heightSide = side;
|
|
628
|
-
widthSide = alignment === (await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
|
|
629
|
-
} else {
|
|
630
|
-
widthSide = side;
|
|
631
|
-
heightSide = alignment === "end" ? "top" : "bottom";
|
|
632
|
-
}
|
|
633
|
-
const overflowAvailableHeight = height - overflow[heightSide];
|
|
634
|
-
const overflowAvailableWidth = width - overflow[widthSide];
|
|
635
|
-
const noShift = !state.middlewareData.shift;
|
|
636
|
-
let availableHeight = overflowAvailableHeight;
|
|
637
|
-
let availableWidth = overflowAvailableWidth;
|
|
638
|
-
if (isXAxis) {
|
|
639
|
-
const maximumClippingWidth = width - overflow.left - overflow.right;
|
|
640
|
-
availableWidth = alignment || noShift ? min(overflowAvailableWidth, maximumClippingWidth) : maximumClippingWidth;
|
|
641
|
-
} else {
|
|
642
|
-
const maximumClippingHeight = height - overflow.top - overflow.bottom;
|
|
643
|
-
availableHeight = alignment || noShift ? min(overflowAvailableHeight, maximumClippingHeight) : maximumClippingHeight;
|
|
644
|
-
}
|
|
645
|
-
if (noShift && !alignment) {
|
|
646
|
-
const xMin = max(overflow.left, 0);
|
|
647
|
-
const xMax = max(overflow.right, 0);
|
|
648
|
-
const yMin = max(overflow.top, 0);
|
|
649
|
-
const yMax = max(overflow.bottom, 0);
|
|
650
|
-
if (isXAxis) {
|
|
651
|
-
availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
|
|
652
|
-
} else {
|
|
653
|
-
availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
await apply(__spreadProps(__spreadValues({}, state), {
|
|
657
|
-
availableWidth,
|
|
658
|
-
availableHeight
|
|
659
|
-
}));
|
|
660
|
-
const nextDimensions = await platform2.getDimensions(elements.floating);
|
|
661
|
-
if (width !== nextDimensions.width || height !== nextDimensions.height) {
|
|
662
|
-
return {
|
|
663
|
-
reset: {
|
|
664
|
-
rects: true
|
|
665
|
-
}
|
|
666
|
-
};
|
|
667
|
-
}
|
|
668
|
-
return {};
|
|
669
|
-
}
|
|
670
|
-
};
|
|
671
|
-
};
|
|
672
|
-
|
|
673
|
-
// ../../node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
|
|
674
|
-
function getWindow(node) {
|
|
675
|
-
var _node$ownerDocument;
|
|
676
|
-
return ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
677
|
-
}
|
|
678
|
-
function getComputedStyle$1(element) {
|
|
679
|
-
return getWindow(element).getComputedStyle(element);
|
|
680
|
-
}
|
|
681
|
-
function isNode(value) {
|
|
682
|
-
return value instanceof getWindow(value).Node;
|
|
683
|
-
}
|
|
684
|
-
function getNodeName(node) {
|
|
685
|
-
return isNode(node) ? (node.nodeName || "").toLowerCase() : "";
|
|
686
|
-
}
|
|
687
|
-
var uaString;
|
|
688
|
-
function getUAString() {
|
|
689
|
-
if (uaString) {
|
|
690
|
-
return uaString;
|
|
691
|
-
}
|
|
692
|
-
const uaData = navigator.userAgentData;
|
|
693
|
-
if (uaData && Array.isArray(uaData.brands)) {
|
|
694
|
-
uaString = uaData.brands.map((item) => item.brand + "/" + item.version).join(" ");
|
|
695
|
-
return uaString;
|
|
696
|
-
}
|
|
697
|
-
return navigator.userAgent;
|
|
698
|
-
}
|
|
699
|
-
function isHTMLElement(value) {
|
|
700
|
-
return value instanceof getWindow(value).HTMLElement;
|
|
701
|
-
}
|
|
702
|
-
function isElement(value) {
|
|
703
|
-
return value instanceof getWindow(value).Element;
|
|
704
|
-
}
|
|
705
|
-
function isShadowRoot(node) {
|
|
706
|
-
if (typeof ShadowRoot === "undefined") {
|
|
707
|
-
return false;
|
|
708
|
-
}
|
|
709
|
-
const OwnElement = getWindow(node).ShadowRoot;
|
|
710
|
-
return node instanceof OwnElement || node instanceof ShadowRoot;
|
|
711
|
-
}
|
|
712
|
-
function isOverflowElement(element) {
|
|
713
|
-
const {
|
|
714
|
-
overflow,
|
|
715
|
-
overflowX,
|
|
716
|
-
overflowY,
|
|
717
|
-
display
|
|
718
|
-
} = getComputedStyle$1(element);
|
|
719
|
-
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !["inline", "contents"].includes(display);
|
|
720
|
-
}
|
|
721
|
-
function isTableElement(element) {
|
|
722
|
-
return ["table", "td", "th"].includes(getNodeName(element));
|
|
723
|
-
}
|
|
724
|
-
function isContainingBlock(element) {
|
|
725
|
-
const isFirefox = /firefox/i.test(getUAString());
|
|
726
|
-
const css = getComputedStyle$1(element);
|
|
727
|
-
const backdropFilter = css.backdropFilter || css.WebkitBackdropFilter;
|
|
728
|
-
return css.transform !== "none" || css.perspective !== "none" || (backdropFilter ? backdropFilter !== "none" : false) || isFirefox && css.willChange === "filter" || isFirefox && (css.filter ? css.filter !== "none" : false) || ["transform", "perspective"].some((value) => css.willChange.includes(value)) || ["paint", "layout", "strict", "content"].some((value) => {
|
|
729
|
-
const contain = css.contain;
|
|
730
|
-
return contain != null ? contain.includes(value) : false;
|
|
731
|
-
});
|
|
732
|
-
}
|
|
733
|
-
function isClientRectVisualViewportBased() {
|
|
734
|
-
return /^((?!chrome|android).)*safari/i.test(getUAString());
|
|
735
|
-
}
|
|
736
|
-
function isLastTraversableNode(node) {
|
|
737
|
-
return ["html", "body", "#document"].includes(getNodeName(node));
|
|
738
|
-
}
|
|
739
|
-
var min2 = Math.min;
|
|
740
|
-
var max2 = Math.max;
|
|
741
|
-
var round = Math.round;
|
|
742
|
-
function getCssDimensions(element) {
|
|
743
|
-
const css = getComputedStyle$1(element);
|
|
744
|
-
let width = parseFloat(css.width);
|
|
745
|
-
let height = parseFloat(css.height);
|
|
746
|
-
const hasOffset = isHTMLElement(element);
|
|
747
|
-
const offsetWidth = hasOffset ? element.offsetWidth : width;
|
|
748
|
-
const offsetHeight = hasOffset ? element.offsetHeight : height;
|
|
749
|
-
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
|
|
750
|
-
if (shouldFallback) {
|
|
751
|
-
width = offsetWidth;
|
|
752
|
-
height = offsetHeight;
|
|
753
|
-
}
|
|
754
|
-
return {
|
|
755
|
-
width,
|
|
756
|
-
height,
|
|
757
|
-
fallback: shouldFallback
|
|
758
|
-
};
|
|
759
|
-
}
|
|
760
|
-
function unwrapElement(element) {
|
|
761
|
-
return !isElement(element) ? element.contextElement : element;
|
|
762
|
-
}
|
|
763
|
-
var FALLBACK_SCALE = {
|
|
764
|
-
x: 1,
|
|
765
|
-
y: 1
|
|
766
|
-
};
|
|
767
|
-
function getScale(element) {
|
|
768
|
-
const domElement = unwrapElement(element);
|
|
769
|
-
if (!isHTMLElement(domElement)) {
|
|
770
|
-
return FALLBACK_SCALE;
|
|
771
|
-
}
|
|
772
|
-
const rect = domElement.getBoundingClientRect();
|
|
773
|
-
const {
|
|
774
|
-
width,
|
|
775
|
-
height,
|
|
776
|
-
fallback
|
|
777
|
-
} = getCssDimensions(domElement);
|
|
778
|
-
let x = (fallback ? round(rect.width) : rect.width) / width;
|
|
779
|
-
let y = (fallback ? round(rect.height) : rect.height) / height;
|
|
780
|
-
if (!x || !Number.isFinite(x)) {
|
|
781
|
-
x = 1;
|
|
782
|
-
}
|
|
783
|
-
if (!y || !Number.isFinite(y)) {
|
|
784
|
-
y = 1;
|
|
785
|
-
}
|
|
786
|
-
return {
|
|
787
|
-
x,
|
|
788
|
-
y
|
|
789
|
-
};
|
|
790
|
-
}
|
|
791
|
-
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
|
792
|
-
var _win$visualViewport, _win$visualViewport2;
|
|
793
|
-
if (includeScale === void 0) {
|
|
794
|
-
includeScale = false;
|
|
795
|
-
}
|
|
796
|
-
if (isFixedStrategy === void 0) {
|
|
797
|
-
isFixedStrategy = false;
|
|
798
|
-
}
|
|
799
|
-
const clientRect = element.getBoundingClientRect();
|
|
800
|
-
const domElement = unwrapElement(element);
|
|
801
|
-
let scale = FALLBACK_SCALE;
|
|
802
|
-
if (includeScale) {
|
|
803
|
-
if (offsetParent) {
|
|
804
|
-
if (isElement(offsetParent)) {
|
|
805
|
-
scale = getScale(offsetParent);
|
|
806
|
-
}
|
|
807
|
-
} else {
|
|
808
|
-
scale = getScale(element);
|
|
809
|
-
}
|
|
810
|
-
}
|
|
811
|
-
const win = domElement ? getWindow(domElement) : window;
|
|
812
|
-
const addVisualOffsets = isClientRectVisualViewportBased() && isFixedStrategy;
|
|
813
|
-
let x = (clientRect.left + (addVisualOffsets ? ((_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) || 0 : 0)) / scale.x;
|
|
814
|
-
let y = (clientRect.top + (addVisualOffsets ? ((_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) || 0 : 0)) / scale.y;
|
|
815
|
-
let width = clientRect.width / scale.x;
|
|
816
|
-
let height = clientRect.height / scale.y;
|
|
817
|
-
if (domElement) {
|
|
818
|
-
const win2 = getWindow(domElement);
|
|
819
|
-
const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
|
|
820
|
-
let currentIFrame = win2.frameElement;
|
|
821
|
-
while (currentIFrame && offsetParent && offsetWin !== win2) {
|
|
822
|
-
const iframeScale = getScale(currentIFrame);
|
|
823
|
-
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
824
|
-
const css = getComputedStyle(currentIFrame);
|
|
825
|
-
iframeRect.x += (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
|
826
|
-
iframeRect.y += (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
|
827
|
-
x *= iframeScale.x;
|
|
828
|
-
y *= iframeScale.y;
|
|
829
|
-
width *= iframeScale.x;
|
|
830
|
-
height *= iframeScale.y;
|
|
831
|
-
x += iframeRect.x;
|
|
832
|
-
y += iframeRect.y;
|
|
833
|
-
currentIFrame = getWindow(currentIFrame).frameElement;
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
return rectToClientRect({
|
|
837
|
-
width,
|
|
838
|
-
height,
|
|
839
|
-
x,
|
|
840
|
-
y
|
|
841
|
-
});
|
|
842
|
-
}
|
|
843
|
-
function getDocumentElement(node) {
|
|
844
|
-
return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
|
|
845
|
-
}
|
|
846
|
-
function getNodeScroll(element) {
|
|
847
|
-
if (isElement(element)) {
|
|
848
|
-
return {
|
|
849
|
-
scrollLeft: element.scrollLeft,
|
|
850
|
-
scrollTop: element.scrollTop
|
|
851
|
-
};
|
|
852
|
-
}
|
|
853
|
-
return {
|
|
854
|
-
scrollLeft: element.pageXOffset,
|
|
855
|
-
scrollTop: element.pageYOffset
|
|
856
|
-
};
|
|
857
|
-
}
|
|
858
|
-
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
859
|
-
let {
|
|
860
|
-
rect,
|
|
861
|
-
offsetParent,
|
|
862
|
-
strategy
|
|
863
|
-
} = _ref;
|
|
864
|
-
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
865
|
-
const documentElement = getDocumentElement(offsetParent);
|
|
866
|
-
if (offsetParent === documentElement) {
|
|
867
|
-
return rect;
|
|
868
|
-
}
|
|
869
|
-
let scroll = {
|
|
870
|
-
scrollLeft: 0,
|
|
871
|
-
scrollTop: 0
|
|
872
|
-
};
|
|
873
|
-
let scale = {
|
|
874
|
-
x: 1,
|
|
875
|
-
y: 1
|
|
876
|
-
};
|
|
877
|
-
const offsets = {
|
|
878
|
-
x: 0,
|
|
879
|
-
y: 0
|
|
880
|
-
};
|
|
881
|
-
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== "fixed") {
|
|
882
|
-
if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
|
|
883
|
-
scroll = getNodeScroll(offsetParent);
|
|
884
|
-
}
|
|
885
|
-
if (isHTMLElement(offsetParent)) {
|
|
886
|
-
const offsetRect = getBoundingClientRect(offsetParent);
|
|
887
|
-
scale = getScale(offsetParent);
|
|
888
|
-
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
889
|
-
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
890
|
-
}
|
|
891
|
-
}
|
|
892
|
-
return {
|
|
893
|
-
width: rect.width * scale.x,
|
|
894
|
-
height: rect.height * scale.y,
|
|
895
|
-
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x,
|
|
896
|
-
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y
|
|
897
|
-
};
|
|
898
|
-
}
|
|
899
|
-
function getWindowScrollBarX(element) {
|
|
900
|
-
return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
|
|
901
|
-
}
|
|
902
|
-
function getDocumentRect(element) {
|
|
903
|
-
const html = getDocumentElement(element);
|
|
904
|
-
const scroll = getNodeScroll(element);
|
|
905
|
-
const body = element.ownerDocument.body;
|
|
906
|
-
const width = max2(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
|
|
907
|
-
const height = max2(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
|
|
908
|
-
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
|
909
|
-
const y = -scroll.scrollTop;
|
|
910
|
-
if (getComputedStyle$1(body).direction === "rtl") {
|
|
911
|
-
x += max2(html.clientWidth, body.clientWidth) - width;
|
|
912
|
-
}
|
|
913
|
-
return {
|
|
914
|
-
width,
|
|
915
|
-
height,
|
|
916
|
-
x,
|
|
917
|
-
y
|
|
918
|
-
};
|
|
919
|
-
}
|
|
920
|
-
function getParentNode(node) {
|
|
921
|
-
if (getNodeName(node) === "html") {
|
|
922
|
-
return node;
|
|
923
|
-
}
|
|
924
|
-
const result = (
|
|
925
|
-
// Step into the shadow DOM of the parent of a slotted node.
|
|
926
|
-
node.assignedSlot || // DOM Element detected.
|
|
927
|
-
node.parentNode || // ShadowRoot detected.
|
|
928
|
-
isShadowRoot(node) && node.host || // Fallback.
|
|
929
|
-
getDocumentElement(node)
|
|
930
|
-
);
|
|
931
|
-
return isShadowRoot(result) ? result.host : result;
|
|
932
|
-
}
|
|
933
|
-
function getNearestOverflowAncestor(node) {
|
|
934
|
-
const parentNode = getParentNode(node);
|
|
935
|
-
if (isLastTraversableNode(parentNode)) {
|
|
936
|
-
return parentNode.ownerDocument.body;
|
|
937
|
-
}
|
|
938
|
-
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
|
939
|
-
return parentNode;
|
|
940
|
-
}
|
|
941
|
-
return getNearestOverflowAncestor(parentNode);
|
|
942
|
-
}
|
|
943
|
-
function getOverflowAncestors(node, list) {
|
|
944
|
-
var _node$ownerDocument;
|
|
945
|
-
if (list === void 0) {
|
|
946
|
-
list = [];
|
|
947
|
-
}
|
|
948
|
-
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
949
|
-
const isBody = scrollableAncestor === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);
|
|
950
|
-
const win = getWindow(scrollableAncestor);
|
|
951
|
-
if (isBody) {
|
|
952
|
-
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []);
|
|
953
|
-
}
|
|
954
|
-
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor));
|
|
955
|
-
}
|
|
956
|
-
function getViewportRect(element, strategy) {
|
|
957
|
-
const win = getWindow(element);
|
|
958
|
-
const html = getDocumentElement(element);
|
|
959
|
-
const visualViewport = win.visualViewport;
|
|
960
|
-
let width = html.clientWidth;
|
|
961
|
-
let height = html.clientHeight;
|
|
962
|
-
let x = 0;
|
|
963
|
-
let y = 0;
|
|
964
|
-
if (visualViewport) {
|
|
965
|
-
width = visualViewport.width;
|
|
966
|
-
height = visualViewport.height;
|
|
967
|
-
const visualViewportBased = isClientRectVisualViewportBased();
|
|
968
|
-
if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
|
|
969
|
-
x = visualViewport.offsetLeft;
|
|
970
|
-
y = visualViewport.offsetTop;
|
|
971
|
-
}
|
|
972
|
-
}
|
|
973
|
-
return {
|
|
974
|
-
width,
|
|
975
|
-
height,
|
|
976
|
-
x,
|
|
977
|
-
y
|
|
978
|
-
};
|
|
979
|
-
}
|
|
980
|
-
function getInnerBoundingClientRect(element, strategy) {
|
|
981
|
-
const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
|
|
982
|
-
const top = clientRect.top + element.clientTop;
|
|
983
|
-
const left = clientRect.left + element.clientLeft;
|
|
984
|
-
const scale = isHTMLElement(element) ? getScale(element) : {
|
|
985
|
-
x: 1,
|
|
986
|
-
y: 1
|
|
987
|
-
};
|
|
988
|
-
const width = element.clientWidth * scale.x;
|
|
989
|
-
const height = element.clientHeight * scale.y;
|
|
990
|
-
const x = left * scale.x;
|
|
991
|
-
const y = top * scale.y;
|
|
992
|
-
return {
|
|
993
|
-
width,
|
|
994
|
-
height,
|
|
995
|
-
x,
|
|
996
|
-
y
|
|
997
|
-
};
|
|
998
|
-
}
|
|
999
|
-
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
|
|
1000
|
-
let rect;
|
|
1001
|
-
if (clippingAncestor === "viewport") {
|
|
1002
|
-
rect = getViewportRect(element, strategy);
|
|
1003
|
-
} else if (clippingAncestor === "document") {
|
|
1004
|
-
rect = getDocumentRect(getDocumentElement(element));
|
|
1005
|
-
} else if (isElement(clippingAncestor)) {
|
|
1006
|
-
rect = getInnerBoundingClientRect(clippingAncestor, strategy);
|
|
1007
|
-
} else {
|
|
1008
|
-
const mutableRect = __spreadValues({}, clippingAncestor);
|
|
1009
|
-
if (isClientRectVisualViewportBased()) {
|
|
1010
|
-
var _win$visualViewport, _win$visualViewport2;
|
|
1011
|
-
const win = getWindow(element);
|
|
1012
|
-
mutableRect.x -= ((_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) || 0;
|
|
1013
|
-
mutableRect.y -= ((_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) || 0;
|
|
1014
|
-
}
|
|
1015
|
-
rect = mutableRect;
|
|
1016
|
-
}
|
|
1017
|
-
return rectToClientRect(rect);
|
|
1018
|
-
}
|
|
1019
|
-
function getClippingElementAncestors(element, cache) {
|
|
1020
|
-
const cachedResult = cache.get(element);
|
|
1021
|
-
if (cachedResult) {
|
|
1022
|
-
return cachedResult;
|
|
1023
|
-
}
|
|
1024
|
-
let result = getOverflowAncestors(element).filter((el) => isElement(el) && getNodeName(el) !== "body");
|
|
1025
|
-
let currentContainingBlockComputedStyle = null;
|
|
1026
|
-
const elementIsFixed = getComputedStyle$1(element).position === "fixed";
|
|
1027
|
-
let currentNode = elementIsFixed ? getParentNode(element) : element;
|
|
1028
|
-
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
1029
|
-
const computedStyle = getComputedStyle$1(currentNode);
|
|
1030
|
-
const containingBlock = isContainingBlock(currentNode);
|
|
1031
|
-
if (computedStyle.position === "fixed") {
|
|
1032
|
-
currentContainingBlockComputedStyle = null;
|
|
1033
|
-
}
|
|
1034
|
-
const shouldDropCurrentNode = elementIsFixed ? !containingBlock && !currentContainingBlockComputedStyle : !containingBlock && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && ["absolute", "fixed"].includes(currentContainingBlockComputedStyle.position);
|
|
1035
|
-
if (shouldDropCurrentNode) {
|
|
1036
|
-
result = result.filter((ancestor) => ancestor !== currentNode);
|
|
1037
|
-
} else {
|
|
1038
|
-
currentContainingBlockComputedStyle = computedStyle;
|
|
1039
|
-
}
|
|
1040
|
-
currentNode = getParentNode(currentNode);
|
|
1041
|
-
}
|
|
1042
|
-
cache.set(element, result);
|
|
1043
|
-
return result;
|
|
1044
|
-
}
|
|
1045
|
-
function getClippingRect(_ref) {
|
|
1046
|
-
let {
|
|
1047
|
-
element,
|
|
1048
|
-
boundary,
|
|
1049
|
-
rootBoundary,
|
|
1050
|
-
strategy
|
|
1051
|
-
} = _ref;
|
|
1052
|
-
const elementClippingAncestors = boundary === "clippingAncestors" ? getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
|
1053
|
-
const clippingAncestors = [...elementClippingAncestors, rootBoundary];
|
|
1054
|
-
const firstClippingAncestor = clippingAncestors[0];
|
|
1055
|
-
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
|
|
1056
|
-
const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
|
|
1057
|
-
accRect.top = max2(rect.top, accRect.top);
|
|
1058
|
-
accRect.right = min2(rect.right, accRect.right);
|
|
1059
|
-
accRect.bottom = min2(rect.bottom, accRect.bottom);
|
|
1060
|
-
accRect.left = max2(rect.left, accRect.left);
|
|
1061
|
-
return accRect;
|
|
1062
|
-
}, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
|
|
1063
|
-
return {
|
|
1064
|
-
width: clippingRect.right - clippingRect.left,
|
|
1065
|
-
height: clippingRect.bottom - clippingRect.top,
|
|
1066
|
-
x: clippingRect.left,
|
|
1067
|
-
y: clippingRect.top
|
|
1068
|
-
};
|
|
1069
|
-
}
|
|
1070
|
-
function getDimensions(element) {
|
|
1071
|
-
return getCssDimensions(element);
|
|
1072
|
-
}
|
|
1073
|
-
function getTrueOffsetParent(element, polyfill) {
|
|
1074
|
-
if (!isHTMLElement(element) || getComputedStyle$1(element).position === "fixed") {
|
|
1075
|
-
return null;
|
|
1076
|
-
}
|
|
1077
|
-
if (polyfill) {
|
|
1078
|
-
return polyfill(element);
|
|
1079
|
-
}
|
|
1080
|
-
return element.offsetParent;
|
|
1081
|
-
}
|
|
1082
|
-
function getContainingBlock(element) {
|
|
1083
|
-
let currentNode = getParentNode(element);
|
|
1084
|
-
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
1085
|
-
if (isContainingBlock(currentNode)) {
|
|
1086
|
-
return currentNode;
|
|
1087
|
-
} else {
|
|
1088
|
-
currentNode = getParentNode(currentNode);
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
-
return null;
|
|
1092
|
-
}
|
|
1093
|
-
function getOffsetParent(element, polyfill) {
|
|
1094
|
-
const window2 = getWindow(element);
|
|
1095
|
-
if (!isHTMLElement(element)) {
|
|
1096
|
-
return window2;
|
|
1097
|
-
}
|
|
1098
|
-
let offsetParent = getTrueOffsetParent(element, polyfill);
|
|
1099
|
-
while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === "static") {
|
|
1100
|
-
offsetParent = getTrueOffsetParent(offsetParent, polyfill);
|
|
1101
|
-
}
|
|
1102
|
-
if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle$1(offsetParent).position === "static" && !isContainingBlock(offsetParent))) {
|
|
1103
|
-
return window2;
|
|
1104
|
-
}
|
|
1105
|
-
return offsetParent || getContainingBlock(element) || window2;
|
|
1106
|
-
}
|
|
1107
|
-
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
1108
|
-
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
1109
|
-
const documentElement = getDocumentElement(offsetParent);
|
|
1110
|
-
const rect = getBoundingClientRect(element, true, strategy === "fixed", offsetParent);
|
|
1111
|
-
let scroll = {
|
|
1112
|
-
scrollLeft: 0,
|
|
1113
|
-
scrollTop: 0
|
|
1114
|
-
};
|
|
1115
|
-
const offsets = {
|
|
1116
|
-
x: 0,
|
|
1117
|
-
y: 0
|
|
1118
|
-
};
|
|
1119
|
-
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== "fixed") {
|
|
1120
|
-
if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
|
|
1121
|
-
scroll = getNodeScroll(offsetParent);
|
|
1122
|
-
}
|
|
1123
|
-
if (isHTMLElement(offsetParent)) {
|
|
1124
|
-
const offsetRect = getBoundingClientRect(offsetParent, true);
|
|
1125
|
-
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1126
|
-
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1127
|
-
} else if (documentElement) {
|
|
1128
|
-
offsets.x = getWindowScrollBarX(documentElement);
|
|
1129
|
-
}
|
|
1130
|
-
}
|
|
1131
|
-
return {
|
|
1132
|
-
x: rect.left + scroll.scrollLeft - offsets.x,
|
|
1133
|
-
y: rect.top + scroll.scrollTop - offsets.y,
|
|
1134
|
-
width: rect.width,
|
|
1135
|
-
height: rect.height
|
|
1136
|
-
};
|
|
1137
|
-
}
|
|
1138
|
-
var platform = {
|
|
1139
|
-
getClippingRect,
|
|
1140
|
-
convertOffsetParentRelativeRectToViewportRelativeRect,
|
|
1141
|
-
isElement,
|
|
1142
|
-
getDimensions,
|
|
1143
|
-
getOffsetParent,
|
|
1144
|
-
getDocumentElement,
|
|
1145
|
-
getScale,
|
|
1146
|
-
async getElementRects(_ref) {
|
|
1147
|
-
let {
|
|
1148
|
-
reference,
|
|
1149
|
-
floating,
|
|
1150
|
-
strategy
|
|
1151
|
-
} = _ref;
|
|
1152
|
-
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
1153
|
-
const getDimensionsFn = this.getDimensions;
|
|
1154
|
-
return {
|
|
1155
|
-
reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
|
|
1156
|
-
floating: __spreadValues({
|
|
1157
|
-
x: 0,
|
|
1158
|
-
y: 0
|
|
1159
|
-
}, await getDimensionsFn(floating))
|
|
1160
|
-
};
|
|
1161
|
-
},
|
|
1162
|
-
getClientRects: (element) => Array.from(element.getClientRects()),
|
|
1163
|
-
isRTL: (element) => getComputedStyle$1(element).direction === "rtl"
|
|
1164
|
-
};
|
|
1165
|
-
function autoUpdate(reference, floating, update, options) {
|
|
1166
|
-
if (options === void 0) {
|
|
1167
|
-
options = {};
|
|
1168
|
-
}
|
|
1169
|
-
const {
|
|
1170
|
-
ancestorScroll: _ancestorScroll = true,
|
|
1171
|
-
ancestorResize = true,
|
|
1172
|
-
elementResize = true,
|
|
1173
|
-
animationFrame = false
|
|
1174
|
-
} = options;
|
|
1175
|
-
const ancestorScroll = _ancestorScroll && !animationFrame;
|
|
1176
|
-
const ancestors = ancestorScroll || ancestorResize ? [...isElement(reference) ? getOverflowAncestors(reference) : reference.contextElement ? getOverflowAncestors(reference.contextElement) : [], ...getOverflowAncestors(floating)] : [];
|
|
1177
|
-
ancestors.forEach((ancestor) => {
|
|
1178
|
-
ancestorScroll && ancestor.addEventListener("scroll", update, {
|
|
1179
|
-
passive: true
|
|
1180
|
-
});
|
|
1181
|
-
ancestorResize && ancestor.addEventListener("resize", update);
|
|
1182
|
-
});
|
|
1183
|
-
let observer = null;
|
|
1184
|
-
if (elementResize) {
|
|
1185
|
-
observer = new ResizeObserver(() => {
|
|
1186
|
-
update();
|
|
1187
|
-
});
|
|
1188
|
-
isElement(reference) && !animationFrame && observer.observe(reference);
|
|
1189
|
-
if (!isElement(reference) && reference.contextElement && !animationFrame) {
|
|
1190
|
-
observer.observe(reference.contextElement);
|
|
1191
|
-
}
|
|
1192
|
-
observer.observe(floating);
|
|
1193
|
-
}
|
|
1194
|
-
let frameId;
|
|
1195
|
-
let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
|
|
1196
|
-
if (animationFrame) {
|
|
1197
|
-
frameLoop();
|
|
1198
|
-
}
|
|
1199
|
-
function frameLoop() {
|
|
1200
|
-
const nextRefRect = getBoundingClientRect(reference);
|
|
1201
|
-
if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
|
|
1202
|
-
update();
|
|
1203
|
-
}
|
|
1204
|
-
prevRefRect = nextRefRect;
|
|
1205
|
-
frameId = requestAnimationFrame(frameLoop);
|
|
1206
|
-
}
|
|
1207
|
-
update();
|
|
1208
|
-
return () => {
|
|
1209
|
-
var _observer;
|
|
1210
|
-
ancestors.forEach((ancestor) => {
|
|
1211
|
-
ancestorScroll && ancestor.removeEventListener("scroll", update);
|
|
1212
|
-
ancestorResize && ancestor.removeEventListener("resize", update);
|
|
1213
|
-
});
|
|
1214
|
-
(_observer = observer) == null ? void 0 : _observer.disconnect();
|
|
1215
|
-
observer = null;
|
|
1216
|
-
if (animationFrame) {
|
|
1217
|
-
cancelAnimationFrame(frameId);
|
|
1218
|
-
}
|
|
1219
|
-
};
|
|
1220
|
-
}
|
|
1221
|
-
var computePosition2 = (reference, floating, options) => {
|
|
1222
|
-
const cache = /* @__PURE__ */ new Map();
|
|
1223
|
-
const mergedOptions = __spreadValues({
|
|
1224
|
-
platform
|
|
1225
|
-
}, options);
|
|
1226
|
-
const platformWithCache = __spreadProps(__spreadValues({}, mergedOptions.platform), {
|
|
1227
|
-
_c: cache
|
|
1228
|
-
});
|
|
1229
|
-
return computePosition(reference, floating, __spreadProps(__spreadValues({}, mergedOptions), {
|
|
1230
|
-
platform: platformWithCache
|
|
1231
|
-
}));
|
|
1232
|
-
};
|
|
1233
|
-
|
|
1234
|
-
// src/popover/popover-store.ts
|
|
1235
|
-
var middlewares = { arrow, flip, offset, shift, size };
|
|
1236
|
-
function createDOMRect(x = 0, y = 0, width = 0, height = 0) {
|
|
1237
|
-
if (typeof DOMRect === "function") {
|
|
1238
|
-
return new DOMRect(x, y, width, height);
|
|
1239
|
-
}
|
|
1240
|
-
const rect = {
|
|
1241
|
-
x,
|
|
1242
|
-
y,
|
|
1243
|
-
width,
|
|
1244
|
-
height,
|
|
1245
|
-
top: y,
|
|
1246
|
-
right: x + width,
|
|
1247
|
-
bottom: y + height,
|
|
1248
|
-
left: x
|
|
1249
|
-
};
|
|
1250
|
-
return __spreadProps(__spreadValues({}, rect), { toJSON: () => rect });
|
|
1251
|
-
}
|
|
1252
|
-
function getDOMRect(anchorRect) {
|
|
1253
|
-
if (!anchorRect)
|
|
1254
|
-
return createDOMRect();
|
|
1255
|
-
const { x, y, width, height } = anchorRect;
|
|
1256
|
-
return createDOMRect(x, y, width, height);
|
|
1257
|
-
}
|
|
1258
|
-
function getAnchorElement(anchorElement, getAnchorRect) {
|
|
1259
|
-
const contextElement = anchorElement || void 0;
|
|
1260
|
-
return {
|
|
1261
|
-
contextElement,
|
|
1262
|
-
getBoundingClientRect: () => {
|
|
1263
|
-
const anchor = anchorElement;
|
|
1264
|
-
const anchorRect = getAnchorRect == null ? void 0 : getAnchorRect(anchor);
|
|
1265
|
-
if (anchorRect || !anchor) {
|
|
1266
|
-
return getDOMRect(anchorRect);
|
|
1267
|
-
}
|
|
1268
|
-
return anchor.getBoundingClientRect();
|
|
1269
|
-
}
|
|
1270
|
-
};
|
|
1271
|
-
}
|
|
1272
|
-
function isValidPlacement(flip2) {
|
|
1273
|
-
return /^(?:top|bottom|left|right)(?:-(?:start|end))?$/.test(flip2);
|
|
1274
|
-
}
|
|
1275
|
-
function createPopoverStore(_a = {}) {
|
|
1276
|
-
var _b = _a, {
|
|
1277
|
-
getAnchorRect,
|
|
1278
|
-
renderCallback,
|
|
1279
|
-
popover: otherPopover
|
|
1280
|
-
} = _b, props = __objRest(_b, [
|
|
1281
|
-
"getAnchorRect",
|
|
1282
|
-
"renderCallback",
|
|
1283
|
-
"popover"
|
|
1284
|
-
]);
|
|
1285
|
-
const store = mergeStore(
|
|
1286
|
-
props.store,
|
|
1287
|
-
otherPopover == null ? void 0 : otherPopover.omit(
|
|
1288
|
-
"arrowElement",
|
|
1289
|
-
"anchorElement",
|
|
1290
|
-
"contentElement",
|
|
1291
|
-
"popoverElement",
|
|
1292
|
-
"disclosureElement"
|
|
1293
|
-
)
|
|
1294
|
-
);
|
|
1295
|
-
const syncState = store == null ? void 0 : store.getState();
|
|
1296
|
-
const rendered = createStore({ rendered: [] });
|
|
1297
|
-
const dialog = createDialogStore(__spreadProps(__spreadValues({}, props), { store }));
|
|
1298
|
-
const placement = defaultValue(
|
|
1299
|
-
props.placement,
|
|
1300
|
-
syncState == null ? void 0 : syncState.placement,
|
|
1301
|
-
"bottom"
|
|
1302
|
-
);
|
|
1303
|
-
const initialState = __spreadProps(__spreadValues({}, dialog.getState()), {
|
|
1304
|
-
placement,
|
|
1305
|
-
currentPlacement: placement,
|
|
1306
|
-
fixed: defaultValue(props.fixed, syncState == null ? void 0 : syncState.fixed, false),
|
|
1307
|
-
gutter: defaultValue(props.gutter, syncState == null ? void 0 : syncState.gutter),
|
|
1308
|
-
flip: defaultValue(props.flip, syncState == null ? void 0 : syncState.flip, true),
|
|
1309
|
-
shift: defaultValue(props.shift, syncState == null ? void 0 : syncState.shift, 0),
|
|
1310
|
-
slide: defaultValue(props.slide, syncState == null ? void 0 : syncState.slide, true),
|
|
1311
|
-
overlap: defaultValue(props.overlap, syncState == null ? void 0 : syncState.overlap, false),
|
|
1312
|
-
sameWidth: defaultValue(props.sameWidth, syncState == null ? void 0 : syncState.sameWidth, false),
|
|
1313
|
-
fitViewport: defaultValue(props.fitViewport, syncState == null ? void 0 : syncState.fitViewport, false),
|
|
1314
|
-
arrowPadding: defaultValue(props.arrowPadding, syncState == null ? void 0 : syncState.arrowPadding, 4),
|
|
1315
|
-
overflowPadding: defaultValue(
|
|
1316
|
-
props.overflowPadding,
|
|
1317
|
-
syncState == null ? void 0 : syncState.overflowPadding,
|
|
1318
|
-
8
|
|
1319
|
-
),
|
|
1320
|
-
anchorElement: defaultValue(syncState == null ? void 0 : syncState.anchorElement, null),
|
|
1321
|
-
popoverElement: defaultValue(syncState == null ? void 0 : syncState.popoverElement, null),
|
|
1322
|
-
arrowElement: defaultValue(syncState == null ? void 0 : syncState.arrowElement, null)
|
|
1323
|
-
});
|
|
1324
|
-
const popover = createStore(initialState, dialog, store);
|
|
1325
|
-
const setCurrentPlacement = (placement2) => {
|
|
1326
|
-
popover.setState("currentPlacement", placement2);
|
|
1327
|
-
};
|
|
1328
|
-
popover.setup(
|
|
1329
|
-
() => rendered.sync(
|
|
1330
|
-
() => popover.syncBatch(
|
|
1331
|
-
(state) => {
|
|
1332
|
-
var _a2;
|
|
1333
|
-
if (!((_a2 = state.contentElement) == null ? void 0 : _a2.isConnected))
|
|
1334
|
-
return;
|
|
1335
|
-
const popover2 = state.popoverElement;
|
|
1336
|
-
if (!popover2)
|
|
1337
|
-
return;
|
|
1338
|
-
const anchor = getAnchorElement(state.anchorElement, getAnchorRect);
|
|
1339
|
-
popover2.style.setProperty(
|
|
1340
|
-
"--popover-overflow-padding",
|
|
1341
|
-
`${state.overflowPadding}px`
|
|
1342
|
-
);
|
|
1343
|
-
const defaultRenderCallback = () => {
|
|
1344
|
-
const update = async () => {
|
|
1345
|
-
if (!state.mounted)
|
|
1346
|
-
return;
|
|
1347
|
-
const arrow2 = state.arrowElement;
|
|
1348
|
-
const middleware = [
|
|
1349
|
-
// https://floating-ui.com/docs/offset
|
|
1350
|
-
middlewares.offset(({ placement: placement2 }) => {
|
|
1351
|
-
var _a3;
|
|
1352
|
-
const arrowOffset = ((arrow2 == null ? void 0 : arrow2.clientHeight) || 0) / 2;
|
|
1353
|
-
const finalGutter = typeof state.gutter === "number" ? state.gutter + arrowOffset : (_a3 = state.gutter) != null ? _a3 : arrowOffset;
|
|
1354
|
-
const hasAlignment = !!placement2.split("-")[1];
|
|
1355
|
-
return {
|
|
1356
|
-
crossAxis: !hasAlignment ? state.shift : void 0,
|
|
1357
|
-
mainAxis: finalGutter,
|
|
1358
|
-
alignmentAxis: state.shift
|
|
1359
|
-
};
|
|
1360
|
-
})
|
|
1361
|
-
];
|
|
1362
|
-
if (state.flip !== false) {
|
|
1363
|
-
const fallbackPlacements = typeof state.flip === "string" ? state.flip.split(" ") : void 0;
|
|
1364
|
-
if (fallbackPlacements !== void 0 && !fallbackPlacements.every(isValidPlacement)) {
|
|
1365
|
-
throw new Error(
|
|
1366
|
-
"`flip` expects a spaced-delimited list of placements"
|
|
1367
|
-
);
|
|
1368
|
-
}
|
|
1369
|
-
middleware.push(
|
|
1370
|
-
middlewares.flip({
|
|
1371
|
-
padding: state.overflowPadding,
|
|
1372
|
-
fallbackPlacements
|
|
1373
|
-
})
|
|
1374
|
-
);
|
|
1375
|
-
}
|
|
1376
|
-
if (state.slide || state.overlap) {
|
|
1377
|
-
middleware.push(
|
|
1378
|
-
middlewares.shift({
|
|
1379
|
-
mainAxis: state.slide,
|
|
1380
|
-
crossAxis: state.overlap,
|
|
1381
|
-
padding: state.overflowPadding
|
|
1382
|
-
})
|
|
1383
|
-
);
|
|
1384
|
-
}
|
|
1385
|
-
middleware.push(
|
|
1386
|
-
middlewares.size({
|
|
1387
|
-
padding: state.overflowPadding,
|
|
1388
|
-
apply({ availableWidth, availableHeight, rects }) {
|
|
1389
|
-
const referenceWidth = Math.round(rects.reference.width);
|
|
1390
|
-
availableWidth = Math.floor(availableWidth);
|
|
1391
|
-
availableHeight = Math.floor(availableHeight);
|
|
1392
|
-
popover2.style.setProperty(
|
|
1393
|
-
"--popover-anchor-width",
|
|
1394
|
-
`${referenceWidth}px`
|
|
1395
|
-
);
|
|
1396
|
-
popover2.style.setProperty(
|
|
1397
|
-
"--popover-available-width",
|
|
1398
|
-
`${availableWidth}px`
|
|
1399
|
-
);
|
|
1400
|
-
popover2.style.setProperty(
|
|
1401
|
-
"--popover-available-height",
|
|
1402
|
-
`${availableHeight}px`
|
|
1403
|
-
);
|
|
1404
|
-
if (state.sameWidth) {
|
|
1405
|
-
popover2.style.width = `${referenceWidth}px`;
|
|
1406
|
-
}
|
|
1407
|
-
if (state.fitViewport) {
|
|
1408
|
-
popover2.style.maxWidth = `${availableWidth}px`;
|
|
1409
|
-
popover2.style.maxHeight = `${availableHeight}px`;
|
|
1410
|
-
}
|
|
1411
|
-
}
|
|
1412
|
-
})
|
|
1413
|
-
);
|
|
1414
|
-
if (arrow2) {
|
|
1415
|
-
middleware.push(
|
|
1416
|
-
middlewares.arrow({
|
|
1417
|
-
element: arrow2,
|
|
1418
|
-
padding: state.arrowPadding
|
|
1419
|
-
})
|
|
1420
|
-
);
|
|
1421
|
-
}
|
|
1422
|
-
const pos = await computePosition2(anchor, popover2, {
|
|
1423
|
-
placement: state.placement,
|
|
1424
|
-
strategy: state.fixed ? "fixed" : "absolute",
|
|
1425
|
-
middleware
|
|
1426
|
-
});
|
|
1427
|
-
setCurrentPlacement(pos.placement);
|
|
1428
|
-
const x = Math.round(pos.x);
|
|
1429
|
-
const y = Math.round(pos.y);
|
|
1430
|
-
Object.assign(popover2.style, {
|
|
1431
|
-
top: "0",
|
|
1432
|
-
left: "0",
|
|
1433
|
-
transform: `translate3d(${x}px, ${y}px, 0)`
|
|
1434
|
-
});
|
|
1435
|
-
if (arrow2 && pos.middlewareData.arrow) {
|
|
1436
|
-
const { x: arrowX, y: arrowY } = pos.middlewareData.arrow;
|
|
1437
|
-
const dir = pos.placement.split("-")[0];
|
|
1438
|
-
Object.assign(arrow2.style, {
|
|
1439
|
-
left: arrowX != null ? `${arrowX}px` : "",
|
|
1440
|
-
top: arrowY != null ? `${arrowY}px` : "",
|
|
1441
|
-
[dir]: "100%"
|
|
1442
|
-
});
|
|
1443
|
-
}
|
|
1444
|
-
};
|
|
1445
|
-
return autoUpdate(anchor, popover2, update, {
|
|
1446
|
-
// JSDOM doesn't support ResizeObserver
|
|
1447
|
-
elementResize: typeof ResizeObserver === "function"
|
|
1448
|
-
});
|
|
1449
|
-
};
|
|
1450
|
-
if (renderCallback) {
|
|
1451
|
-
return renderCallback(__spreadProps(__spreadValues({}, state), {
|
|
1452
|
-
setPlacement: setCurrentPlacement,
|
|
1453
|
-
defaultRenderCallback
|
|
1454
|
-
}));
|
|
1455
|
-
}
|
|
1456
|
-
return defaultRenderCallback();
|
|
1457
|
-
},
|
|
1458
|
-
[
|
|
1459
|
-
"anchorElement",
|
|
1460
|
-
"popoverElement",
|
|
1461
|
-
"arrowElement",
|
|
1462
|
-
"contentElement",
|
|
1463
|
-
"gutter",
|
|
1464
|
-
"mounted",
|
|
1465
|
-
"shift",
|
|
1466
|
-
"overlap",
|
|
1467
|
-
"flip",
|
|
1468
|
-
"overflowPadding",
|
|
1469
|
-
"slide",
|
|
1470
|
-
"sameWidth",
|
|
1471
|
-
"fitViewport",
|
|
1472
|
-
"arrowPadding",
|
|
1473
|
-
"placement",
|
|
1474
|
-
"fixed"
|
|
1475
|
-
]
|
|
1476
|
-
)
|
|
1477
|
-
)
|
|
1478
|
-
);
|
|
1479
|
-
return __spreadProps(__spreadValues(__spreadValues({}, dialog), popover), {
|
|
1480
|
-
setAnchorElement: (element) => popover.setState("anchorElement", element),
|
|
1481
|
-
setPopoverElement: (element) => popover.setState("popoverElement", element),
|
|
1482
|
-
setArrowElement: (element) => popover.setState("arrowElement", element),
|
|
1483
|
-
render: () => rendered.setState("rendered", []),
|
|
1484
|
-
getAnchorRect,
|
|
1485
|
-
renderCallback
|
|
1486
|
-
});
|
|
1487
|
-
}
|
|
1488
|
-
|
|
1489
|
-
export {
|
|
1490
|
-
createPopoverStore
|
|
1491
|
-
};
|