@adam-milo/ui 1.0.22 → 1.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.js +18 -9
- package/dist/index10.cjs +1 -1
- package/dist/index10.js +53 -59
- package/dist/index11.cjs +1 -1
- package/dist/index11.js +50 -104
- package/dist/index12.cjs +1 -1
- package/dist/index12.js +108 -76
- package/dist/index13.cjs +1 -1
- package/dist/index13.js +77 -26
- package/dist/index14.cjs +1 -1
- package/dist/index14.js +22 -462
- package/dist/index15.cjs +1 -1
- package/dist/index15.js +466 -109
- package/dist/index16.cjs +1 -1
- package/dist/index16.js +111 -30
- package/dist/index17.cjs +1 -1
- package/dist/index17.js +42 -12
- package/dist/index18.cjs +1 -0
- package/dist/index18.js +14 -0
- package/dist/index2.cjs +1 -1
- package/dist/index2.js +1 -1
- package/dist/index20.cjs +1 -1
- package/dist/index20.js +20 -299
- package/dist/index21.cjs +1 -1
- package/dist/index21.js +298 -13
- package/dist/index22.cjs +1 -0
- package/dist/index22.js +16 -0
- package/dist/index25.cjs +1 -0
- package/dist/index25.js +1193 -0
- package/dist/index3.cjs +1 -1
- package/dist/index3.js +2 -2
- package/dist/index33.cjs +1 -1
- package/dist/index33.js +7 -19
- package/dist/index36.cjs +1 -0
- package/dist/index36.js +21 -0
- package/dist/index38.cjs +1 -0
- package/dist/index38.js +6 -0
- package/dist/index39.cjs +1 -0
- package/dist/index39.js +11 -0
- package/dist/index4.cjs +1 -1
- package/dist/index4.js +1 -1
- package/dist/index40.cjs +1 -0
- package/dist/index40.js +70 -0
- package/dist/index41.cjs +1 -0
- package/dist/index41.js +39 -0
- package/dist/index42.cjs +1 -0
- package/dist/index42.js +64 -0
- package/dist/index43.cjs +1 -0
- package/dist/index43.js +10 -0
- package/dist/index44.cjs +1 -0
- package/dist/index44.js +212 -0
- package/dist/index45.cjs +1 -0
- package/dist/index45.js +29 -0
- package/dist/index46.cjs +1 -0
- package/dist/index46.js +208 -0
- package/dist/index47.cjs +1 -0
- package/dist/index47.js +14 -0
- package/dist/index48.cjs +1 -0
- package/dist/index48.js +293 -0
- package/dist/index49.cjs +1 -0
- package/dist/index49.js +18 -0
- package/dist/index5.cjs +1 -1
- package/dist/index5.js +1 -1
- package/dist/index50.cjs +1 -0
- package/dist/index50.js +43 -0
- package/dist/index51.cjs +1 -0
- package/dist/index51.js +89 -0
- package/dist/index52.cjs +1 -0
- package/dist/index52.js +14 -0
- package/dist/index53.cjs +1 -0
- package/dist/index53.js +71 -0
- package/dist/index54.cjs +1 -0
- package/dist/index54.js +6 -0
- package/dist/index55.cjs +1 -0
- package/dist/index55.js +14 -0
- package/dist/index56.cjs +1 -0
- package/dist/index56.js +34 -0
- package/dist/index57.cjs +1 -0
- package/dist/index57.js +122 -0
- package/dist/index58.cjs +1 -0
- package/dist/index58.js +11 -0
- package/dist/index59.cjs +1 -0
- package/dist/index59.js +17 -0
- package/dist/index6.cjs +1 -1
- package/dist/index6.js +2 -2
- package/dist/index60.cjs +1 -0
- package/dist/index60.js +297 -0
- package/dist/index61.cjs +1 -0
- package/dist/index61.js +25 -0
- package/dist/index62.cjs +1 -0
- package/dist/index62.js +39 -0
- package/dist/index63.cjs +1 -0
- package/dist/index63.js +625 -0
- package/dist/index64.cjs +1 -0
- package/dist/index64.js +39 -0
- package/dist/index65.cjs +1 -0
- package/dist/index65.js +38 -0
- package/dist/index66.cjs +1 -0
- package/dist/index66.js +7 -0
- package/dist/index67.cjs +1 -0
- package/dist/index67.js +10 -0
- package/dist/index68.cjs +1 -0
- package/dist/index68.js +5 -0
- package/dist/index69.cjs +1 -0
- package/dist/index69.js +35 -0
- package/dist/index7.cjs +1 -1
- package/dist/index7.js +1 -1
- package/dist/index70.cjs +1 -0
- package/dist/index70.js +180 -0
- package/dist/index71.cjs +1 -0
- package/dist/index71.js +21 -0
- package/dist/index72.cjs +1 -0
- package/dist/index72.js +721 -0
- package/dist/index73.cjs +1 -0
- package/dist/index73.js +154 -0
- package/dist/index74.cjs +1 -0
- package/dist/index74.js +173 -0
- package/dist/index75.cjs +1 -0
- package/dist/index75.js +88 -0
- package/dist/index76.cjs +1 -0
- package/dist/index76.js +47 -0
- package/dist/index77.cjs +1 -0
- package/dist/index77.js +13 -0
- package/dist/index78.cjs +1 -0
- package/dist/index78.js +19 -0
- package/dist/index79.cjs +1 -0
- package/dist/index79.js +102 -0
- package/dist/index8.cjs +1 -1
- package/dist/index8.js +1 -1
- package/dist/index80.cjs +1 -0
- package/dist/index80.js +11 -0
- package/dist/index81.cjs +1 -0
- package/dist/index81.js +29 -0
- package/dist/index82.cjs +1 -0
- package/dist/index82.js +16 -0
- package/dist/index83.cjs +1 -0
- package/dist/index83.js +48 -0
- package/dist/index84.cjs +1 -0
- package/dist/index84.js +9 -0
- package/dist/index85.cjs +1 -0
- package/dist/index85.js +37 -0
- package/dist/index9.cjs +1 -1
- package/dist/index9.js +224 -35
- package/dist/src/components/forms/select/Select.component.d.ts +100 -0
- package/dist/src/components/forms/select/Select.component.d.ts.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +2 -1
- package/dist/index19.cjs +0 -1
- package/dist/index19.js +0 -22
- package/dist/index30.cjs +0 -1
- package/dist/index30.js +0 -9
package/dist/index72.js
ADDED
|
@@ -0,0 +1,721 @@
|
|
|
1
|
+
import { evaluate, getSideAxis, getSide, clamp, getOppositePlacement, getExpandedPlacements, getOppositeAxisPlacements, getAlignmentSides, getAlignment, min, max, getPaddingObject, rectToClientRect, getOppositeAxis, getAlignmentAxis, sides, getAxisLength } from "./index73.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
|
+
const computePosition = async (reference, floating, config) => {
|
|
58
|
+
const {
|
|
59
|
+
placement = "bottom",
|
|
60
|
+
strategy = "absolute",
|
|
61
|
+
middleware = [],
|
|
62
|
+
platform
|
|
63
|
+
} = config;
|
|
64
|
+
const validMiddleware = middleware.filter(Boolean);
|
|
65
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
|
|
66
|
+
let rects = await platform.getElementRects({
|
|
67
|
+
reference,
|
|
68
|
+
floating,
|
|
69
|
+
strategy
|
|
70
|
+
});
|
|
71
|
+
let {
|
|
72
|
+
x,
|
|
73
|
+
y
|
|
74
|
+
} = computeCoordsFromPlacement(rects, placement, rtl);
|
|
75
|
+
let statefulPlacement = placement;
|
|
76
|
+
let middlewareData = {};
|
|
77
|
+
let resetCount = 0;
|
|
78
|
+
for (let i = 0; i < validMiddleware.length; i++) {
|
|
79
|
+
const {
|
|
80
|
+
name,
|
|
81
|
+
fn
|
|
82
|
+
} = validMiddleware[i];
|
|
83
|
+
const {
|
|
84
|
+
x: nextX,
|
|
85
|
+
y: nextY,
|
|
86
|
+
data,
|
|
87
|
+
reset
|
|
88
|
+
} = await fn({
|
|
89
|
+
x,
|
|
90
|
+
y,
|
|
91
|
+
initialPlacement: placement,
|
|
92
|
+
placement: statefulPlacement,
|
|
93
|
+
strategy,
|
|
94
|
+
middlewareData,
|
|
95
|
+
rects,
|
|
96
|
+
platform,
|
|
97
|
+
elements: {
|
|
98
|
+
reference,
|
|
99
|
+
floating
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
x = nextX != null ? nextX : x;
|
|
103
|
+
y = nextY != null ? nextY : y;
|
|
104
|
+
middlewareData = {
|
|
105
|
+
...middlewareData,
|
|
106
|
+
[name]: {
|
|
107
|
+
...middlewareData[name],
|
|
108
|
+
...data
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
if (reset && resetCount <= 50) {
|
|
112
|
+
resetCount++;
|
|
113
|
+
if (typeof reset === "object") {
|
|
114
|
+
if (reset.placement) {
|
|
115
|
+
statefulPlacement = reset.placement;
|
|
116
|
+
}
|
|
117
|
+
if (reset.rects) {
|
|
118
|
+
rects = reset.rects === true ? await platform.getElementRects({
|
|
119
|
+
reference,
|
|
120
|
+
floating,
|
|
121
|
+
strategy
|
|
122
|
+
}) : reset.rects;
|
|
123
|
+
}
|
|
124
|
+
({
|
|
125
|
+
x,
|
|
126
|
+
y
|
|
127
|
+
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
128
|
+
}
|
|
129
|
+
i = -1;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
x,
|
|
134
|
+
y,
|
|
135
|
+
placement: statefulPlacement,
|
|
136
|
+
strategy,
|
|
137
|
+
middlewareData
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
async function detectOverflow(state, options) {
|
|
141
|
+
var _await$platform$isEle;
|
|
142
|
+
if (options === void 0) {
|
|
143
|
+
options = {};
|
|
144
|
+
}
|
|
145
|
+
const {
|
|
146
|
+
x,
|
|
147
|
+
y,
|
|
148
|
+
platform,
|
|
149
|
+
rects,
|
|
150
|
+
elements,
|
|
151
|
+
strategy
|
|
152
|
+
} = state;
|
|
153
|
+
const {
|
|
154
|
+
boundary = "clippingAncestors",
|
|
155
|
+
rootBoundary = "viewport",
|
|
156
|
+
elementContext = "floating",
|
|
157
|
+
altBoundary = false,
|
|
158
|
+
padding = 0
|
|
159
|
+
} = evaluate(options, state);
|
|
160
|
+
const paddingObject = getPaddingObject(padding);
|
|
161
|
+
const altContext = elementContext === "floating" ? "reference" : "floating";
|
|
162
|
+
const element = elements[altBoundary ? altContext : elementContext];
|
|
163
|
+
const clippingClientRect = rectToClientRect(await platform.getClippingRect({
|
|
164
|
+
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)),
|
|
165
|
+
boundary,
|
|
166
|
+
rootBoundary,
|
|
167
|
+
strategy
|
|
168
|
+
}));
|
|
169
|
+
const rect = elementContext === "floating" ? {
|
|
170
|
+
x,
|
|
171
|
+
y,
|
|
172
|
+
width: rects.floating.width,
|
|
173
|
+
height: rects.floating.height
|
|
174
|
+
} : rects.reference;
|
|
175
|
+
const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
|
|
176
|
+
const offsetScale = await (platform.isElement == null ? void 0 : platform.isElement(offsetParent)) ? await (platform.getScale == null ? void 0 : platform.getScale(offsetParent)) || {
|
|
177
|
+
x: 1,
|
|
178
|
+
y: 1
|
|
179
|
+
} : {
|
|
180
|
+
x: 1,
|
|
181
|
+
y: 1
|
|
182
|
+
};
|
|
183
|
+
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
184
|
+
elements,
|
|
185
|
+
rect,
|
|
186
|
+
offsetParent,
|
|
187
|
+
strategy
|
|
188
|
+
}) : rect);
|
|
189
|
+
return {
|
|
190
|
+
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
|
191
|
+
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
|
192
|
+
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
|
193
|
+
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
const arrow = (options) => ({
|
|
197
|
+
name: "arrow",
|
|
198
|
+
options,
|
|
199
|
+
async fn(state) {
|
|
200
|
+
const {
|
|
201
|
+
x,
|
|
202
|
+
y,
|
|
203
|
+
placement,
|
|
204
|
+
rects,
|
|
205
|
+
platform,
|
|
206
|
+
elements,
|
|
207
|
+
middlewareData
|
|
208
|
+
} = state;
|
|
209
|
+
const {
|
|
210
|
+
element,
|
|
211
|
+
padding = 0
|
|
212
|
+
} = evaluate(options, state) || {};
|
|
213
|
+
if (element == null) {
|
|
214
|
+
return {};
|
|
215
|
+
}
|
|
216
|
+
const paddingObject = getPaddingObject(padding);
|
|
217
|
+
const coords = {
|
|
218
|
+
x,
|
|
219
|
+
y
|
|
220
|
+
};
|
|
221
|
+
const axis = getAlignmentAxis(placement);
|
|
222
|
+
const length = getAxisLength(axis);
|
|
223
|
+
const arrowDimensions = await platform.getDimensions(element);
|
|
224
|
+
const isYAxis = axis === "y";
|
|
225
|
+
const minProp = isYAxis ? "top" : "left";
|
|
226
|
+
const maxProp = isYAxis ? "bottom" : "right";
|
|
227
|
+
const clientProp = isYAxis ? "clientHeight" : "clientWidth";
|
|
228
|
+
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
|
|
229
|
+
const startDiff = coords[axis] - rects.reference[axis];
|
|
230
|
+
const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
|
|
231
|
+
let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
|
|
232
|
+
if (!clientSize || !await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent))) {
|
|
233
|
+
clientSize = elements.floating[clientProp] || rects.floating[length];
|
|
234
|
+
}
|
|
235
|
+
const centerToReference = endDiff / 2 - startDiff / 2;
|
|
236
|
+
const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
|
|
237
|
+
const minPadding = min(paddingObject[minProp], largestPossiblePadding);
|
|
238
|
+
const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
|
|
239
|
+
const min$1 = minPadding;
|
|
240
|
+
const max2 = clientSize - arrowDimensions[length] - maxPadding;
|
|
241
|
+
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
|
242
|
+
const offset2 = clamp(min$1, center, max2);
|
|
243
|
+
const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset2 && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
|
|
244
|
+
const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max2 : 0;
|
|
245
|
+
return {
|
|
246
|
+
[axis]: coords[axis] + alignmentOffset,
|
|
247
|
+
data: {
|
|
248
|
+
[axis]: offset2,
|
|
249
|
+
centerOffset: center - offset2 - alignmentOffset,
|
|
250
|
+
...shouldAddOffset && {
|
|
251
|
+
alignmentOffset
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
reset: shouldAddOffset
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
const flip = function(options) {
|
|
259
|
+
if (options === void 0) {
|
|
260
|
+
options = {};
|
|
261
|
+
}
|
|
262
|
+
return {
|
|
263
|
+
name: "flip",
|
|
264
|
+
options,
|
|
265
|
+
async fn(state) {
|
|
266
|
+
var _middlewareData$arrow, _middlewareData$flip;
|
|
267
|
+
const {
|
|
268
|
+
placement,
|
|
269
|
+
middlewareData,
|
|
270
|
+
rects,
|
|
271
|
+
initialPlacement,
|
|
272
|
+
platform,
|
|
273
|
+
elements
|
|
274
|
+
} = state;
|
|
275
|
+
const {
|
|
276
|
+
mainAxis: checkMainAxis = true,
|
|
277
|
+
crossAxis: checkCrossAxis = true,
|
|
278
|
+
fallbackPlacements: specifiedFallbackPlacements,
|
|
279
|
+
fallbackStrategy = "bestFit",
|
|
280
|
+
fallbackAxisSideDirection = "none",
|
|
281
|
+
flipAlignment = true,
|
|
282
|
+
...detectOverflowOptions
|
|
283
|
+
} = evaluate(options, state);
|
|
284
|
+
if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
285
|
+
return {};
|
|
286
|
+
}
|
|
287
|
+
const side = getSide(placement);
|
|
288
|
+
const initialSideAxis = getSideAxis(initialPlacement);
|
|
289
|
+
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
290
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
291
|
+
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
292
|
+
const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
|
|
293
|
+
if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
|
|
294
|
+
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
|
295
|
+
}
|
|
296
|
+
const placements = [initialPlacement, ...fallbackPlacements];
|
|
297
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
298
|
+
const overflows = [];
|
|
299
|
+
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
300
|
+
if (checkMainAxis) {
|
|
301
|
+
overflows.push(overflow[side]);
|
|
302
|
+
}
|
|
303
|
+
if (checkCrossAxis) {
|
|
304
|
+
const sides2 = getAlignmentSides(placement, rects, rtl);
|
|
305
|
+
overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
|
|
306
|
+
}
|
|
307
|
+
overflowsData = [...overflowsData, {
|
|
308
|
+
placement,
|
|
309
|
+
overflows
|
|
310
|
+
}];
|
|
311
|
+
if (!overflows.every((side2) => side2 <= 0)) {
|
|
312
|
+
var _middlewareData$flip2, _overflowsData$filter;
|
|
313
|
+
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
|
314
|
+
const nextPlacement = placements[nextIndex];
|
|
315
|
+
if (nextPlacement) {
|
|
316
|
+
const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
|
|
317
|
+
if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
|
|
318
|
+
// overflows the main axis.
|
|
319
|
+
overflowsData.every((d) => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
|
|
320
|
+
return {
|
|
321
|
+
data: {
|
|
322
|
+
index: nextIndex,
|
|
323
|
+
overflows: overflowsData
|
|
324
|
+
},
|
|
325
|
+
reset: {
|
|
326
|
+
placement: nextPlacement
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
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;
|
|
332
|
+
if (!resetPlacement) {
|
|
333
|
+
switch (fallbackStrategy) {
|
|
334
|
+
case "bestFit": {
|
|
335
|
+
var _overflowsData$filter2;
|
|
336
|
+
const placement2 = (_overflowsData$filter2 = overflowsData.filter((d) => {
|
|
337
|
+
if (hasFallbackAxisSideDirection) {
|
|
338
|
+
const currentSideAxis = getSideAxis(d.placement);
|
|
339
|
+
return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
|
|
340
|
+
// reading directions favoring greater width.
|
|
341
|
+
currentSideAxis === "y";
|
|
342
|
+
}
|
|
343
|
+
return true;
|
|
344
|
+
}).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];
|
|
345
|
+
if (placement2) {
|
|
346
|
+
resetPlacement = placement2;
|
|
347
|
+
}
|
|
348
|
+
break;
|
|
349
|
+
}
|
|
350
|
+
case "initialPlacement":
|
|
351
|
+
resetPlacement = initialPlacement;
|
|
352
|
+
break;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
if (placement !== resetPlacement) {
|
|
356
|
+
return {
|
|
357
|
+
reset: {
|
|
358
|
+
placement: resetPlacement
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
return {};
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
};
|
|
367
|
+
function getSideOffsets(overflow, rect) {
|
|
368
|
+
return {
|
|
369
|
+
top: overflow.top - rect.height,
|
|
370
|
+
right: overflow.right - rect.width,
|
|
371
|
+
bottom: overflow.bottom - rect.height,
|
|
372
|
+
left: overflow.left - rect.width
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
function isAnySideFullyClipped(overflow) {
|
|
376
|
+
return sides.some((side) => overflow[side] >= 0);
|
|
377
|
+
}
|
|
378
|
+
const hide = function(options) {
|
|
379
|
+
if (options === void 0) {
|
|
380
|
+
options = {};
|
|
381
|
+
}
|
|
382
|
+
return {
|
|
383
|
+
name: "hide",
|
|
384
|
+
options,
|
|
385
|
+
async fn(state) {
|
|
386
|
+
const {
|
|
387
|
+
rects
|
|
388
|
+
} = state;
|
|
389
|
+
const {
|
|
390
|
+
strategy = "referenceHidden",
|
|
391
|
+
...detectOverflowOptions
|
|
392
|
+
} = evaluate(options, state);
|
|
393
|
+
switch (strategy) {
|
|
394
|
+
case "referenceHidden": {
|
|
395
|
+
const overflow = await detectOverflow(state, {
|
|
396
|
+
...detectOverflowOptions,
|
|
397
|
+
elementContext: "reference"
|
|
398
|
+
});
|
|
399
|
+
const offsets = getSideOffsets(overflow, rects.reference);
|
|
400
|
+
return {
|
|
401
|
+
data: {
|
|
402
|
+
referenceHiddenOffsets: offsets,
|
|
403
|
+
referenceHidden: isAnySideFullyClipped(offsets)
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
case "escaped": {
|
|
408
|
+
const overflow = await detectOverflow(state, {
|
|
409
|
+
...detectOverflowOptions,
|
|
410
|
+
altBoundary: true
|
|
411
|
+
});
|
|
412
|
+
const offsets = getSideOffsets(overflow, rects.floating);
|
|
413
|
+
return {
|
|
414
|
+
data: {
|
|
415
|
+
escapedOffsets: offsets,
|
|
416
|
+
escaped: isAnySideFullyClipped(offsets)
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
default: {
|
|
421
|
+
return {};
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
};
|
|
427
|
+
const originSides = /* @__PURE__ */ new Set(["left", "top"]);
|
|
428
|
+
async function convertValueToCoords(state, options) {
|
|
429
|
+
const {
|
|
430
|
+
placement,
|
|
431
|
+
platform,
|
|
432
|
+
elements
|
|
433
|
+
} = state;
|
|
434
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
435
|
+
const side = getSide(placement);
|
|
436
|
+
const alignment = getAlignment(placement);
|
|
437
|
+
const isVertical = getSideAxis(placement) === "y";
|
|
438
|
+
const mainAxisMulti = originSides.has(side) ? -1 : 1;
|
|
439
|
+
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
440
|
+
const rawValue = evaluate(options, state);
|
|
441
|
+
let {
|
|
442
|
+
mainAxis,
|
|
443
|
+
crossAxis,
|
|
444
|
+
alignmentAxis
|
|
445
|
+
} = typeof rawValue === "number" ? {
|
|
446
|
+
mainAxis: rawValue,
|
|
447
|
+
crossAxis: 0,
|
|
448
|
+
alignmentAxis: null
|
|
449
|
+
} : {
|
|
450
|
+
mainAxis: rawValue.mainAxis || 0,
|
|
451
|
+
crossAxis: rawValue.crossAxis || 0,
|
|
452
|
+
alignmentAxis: rawValue.alignmentAxis
|
|
453
|
+
};
|
|
454
|
+
if (alignment && typeof alignmentAxis === "number") {
|
|
455
|
+
crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
|
|
456
|
+
}
|
|
457
|
+
return isVertical ? {
|
|
458
|
+
x: crossAxis * crossAxisMulti,
|
|
459
|
+
y: mainAxis * mainAxisMulti
|
|
460
|
+
} : {
|
|
461
|
+
x: mainAxis * mainAxisMulti,
|
|
462
|
+
y: crossAxis * crossAxisMulti
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
const offset = function(options) {
|
|
466
|
+
if (options === void 0) {
|
|
467
|
+
options = 0;
|
|
468
|
+
}
|
|
469
|
+
return {
|
|
470
|
+
name: "offset",
|
|
471
|
+
options,
|
|
472
|
+
async fn(state) {
|
|
473
|
+
var _middlewareData$offse, _middlewareData$arrow;
|
|
474
|
+
const {
|
|
475
|
+
x,
|
|
476
|
+
y,
|
|
477
|
+
placement,
|
|
478
|
+
middlewareData
|
|
479
|
+
} = state;
|
|
480
|
+
const diffCoords = await convertValueToCoords(state, options);
|
|
481
|
+
if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
482
|
+
return {};
|
|
483
|
+
}
|
|
484
|
+
return {
|
|
485
|
+
x: x + diffCoords.x,
|
|
486
|
+
y: y + diffCoords.y,
|
|
487
|
+
data: {
|
|
488
|
+
...diffCoords,
|
|
489
|
+
placement
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
};
|
|
494
|
+
};
|
|
495
|
+
const shift = function(options) {
|
|
496
|
+
if (options === void 0) {
|
|
497
|
+
options = {};
|
|
498
|
+
}
|
|
499
|
+
return {
|
|
500
|
+
name: "shift",
|
|
501
|
+
options,
|
|
502
|
+
async fn(state) {
|
|
503
|
+
const {
|
|
504
|
+
x,
|
|
505
|
+
y,
|
|
506
|
+
placement
|
|
507
|
+
} = state;
|
|
508
|
+
const {
|
|
509
|
+
mainAxis: checkMainAxis = true,
|
|
510
|
+
crossAxis: checkCrossAxis = false,
|
|
511
|
+
limiter = {
|
|
512
|
+
fn: (_ref) => {
|
|
513
|
+
let {
|
|
514
|
+
x: x2,
|
|
515
|
+
y: y2
|
|
516
|
+
} = _ref;
|
|
517
|
+
return {
|
|
518
|
+
x: x2,
|
|
519
|
+
y: y2
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
},
|
|
523
|
+
...detectOverflowOptions
|
|
524
|
+
} = evaluate(options, state);
|
|
525
|
+
const coords = {
|
|
526
|
+
x,
|
|
527
|
+
y
|
|
528
|
+
};
|
|
529
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
530
|
+
const crossAxis = getSideAxis(getSide(placement));
|
|
531
|
+
const mainAxis = getOppositeAxis(crossAxis);
|
|
532
|
+
let mainAxisCoord = coords[mainAxis];
|
|
533
|
+
let crossAxisCoord = coords[crossAxis];
|
|
534
|
+
if (checkMainAxis) {
|
|
535
|
+
const minSide = mainAxis === "y" ? "top" : "left";
|
|
536
|
+
const maxSide = mainAxis === "y" ? "bottom" : "right";
|
|
537
|
+
const min2 = mainAxisCoord + overflow[minSide];
|
|
538
|
+
const max2 = mainAxisCoord - overflow[maxSide];
|
|
539
|
+
mainAxisCoord = clamp(min2, mainAxisCoord, max2);
|
|
540
|
+
}
|
|
541
|
+
if (checkCrossAxis) {
|
|
542
|
+
const minSide = crossAxis === "y" ? "top" : "left";
|
|
543
|
+
const maxSide = crossAxis === "y" ? "bottom" : "right";
|
|
544
|
+
const min2 = crossAxisCoord + overflow[minSide];
|
|
545
|
+
const max2 = crossAxisCoord - overflow[maxSide];
|
|
546
|
+
crossAxisCoord = clamp(min2, crossAxisCoord, max2);
|
|
547
|
+
}
|
|
548
|
+
const limitedCoords = limiter.fn({
|
|
549
|
+
...state,
|
|
550
|
+
[mainAxis]: mainAxisCoord,
|
|
551
|
+
[crossAxis]: crossAxisCoord
|
|
552
|
+
});
|
|
553
|
+
return {
|
|
554
|
+
...limitedCoords,
|
|
555
|
+
data: {
|
|
556
|
+
x: limitedCoords.x - x,
|
|
557
|
+
y: limitedCoords.y - y,
|
|
558
|
+
enabled: {
|
|
559
|
+
[mainAxis]: checkMainAxis,
|
|
560
|
+
[crossAxis]: checkCrossAxis
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
};
|
|
566
|
+
};
|
|
567
|
+
const limitShift = function(options) {
|
|
568
|
+
if (options === void 0) {
|
|
569
|
+
options = {};
|
|
570
|
+
}
|
|
571
|
+
return {
|
|
572
|
+
options,
|
|
573
|
+
fn(state) {
|
|
574
|
+
const {
|
|
575
|
+
x,
|
|
576
|
+
y,
|
|
577
|
+
placement,
|
|
578
|
+
rects,
|
|
579
|
+
middlewareData
|
|
580
|
+
} = state;
|
|
581
|
+
const {
|
|
582
|
+
offset: offset2 = 0,
|
|
583
|
+
mainAxis: checkMainAxis = true,
|
|
584
|
+
crossAxis: checkCrossAxis = true
|
|
585
|
+
} = evaluate(options, state);
|
|
586
|
+
const coords = {
|
|
587
|
+
x,
|
|
588
|
+
y
|
|
589
|
+
};
|
|
590
|
+
const crossAxis = getSideAxis(placement);
|
|
591
|
+
const mainAxis = getOppositeAxis(crossAxis);
|
|
592
|
+
let mainAxisCoord = coords[mainAxis];
|
|
593
|
+
let crossAxisCoord = coords[crossAxis];
|
|
594
|
+
const rawOffset = evaluate(offset2, state);
|
|
595
|
+
const computedOffset = typeof rawOffset === "number" ? {
|
|
596
|
+
mainAxis: rawOffset,
|
|
597
|
+
crossAxis: 0
|
|
598
|
+
} : {
|
|
599
|
+
mainAxis: 0,
|
|
600
|
+
crossAxis: 0,
|
|
601
|
+
...rawOffset
|
|
602
|
+
};
|
|
603
|
+
if (checkMainAxis) {
|
|
604
|
+
const len = mainAxis === "y" ? "height" : "width";
|
|
605
|
+
const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
|
|
606
|
+
const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
|
|
607
|
+
if (mainAxisCoord < limitMin) {
|
|
608
|
+
mainAxisCoord = limitMin;
|
|
609
|
+
} else if (mainAxisCoord > limitMax) {
|
|
610
|
+
mainAxisCoord = limitMax;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
if (checkCrossAxis) {
|
|
614
|
+
var _middlewareData$offse, _middlewareData$offse2;
|
|
615
|
+
const len = mainAxis === "y" ? "width" : "height";
|
|
616
|
+
const isOriginSide = originSides.has(getSide(placement));
|
|
617
|
+
const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);
|
|
618
|
+
const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0);
|
|
619
|
+
if (crossAxisCoord < limitMin) {
|
|
620
|
+
crossAxisCoord = limitMin;
|
|
621
|
+
} else if (crossAxisCoord > limitMax) {
|
|
622
|
+
crossAxisCoord = limitMax;
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
return {
|
|
626
|
+
[mainAxis]: mainAxisCoord,
|
|
627
|
+
[crossAxis]: crossAxisCoord
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
};
|
|
631
|
+
};
|
|
632
|
+
const size = function(options) {
|
|
633
|
+
if (options === void 0) {
|
|
634
|
+
options = {};
|
|
635
|
+
}
|
|
636
|
+
return {
|
|
637
|
+
name: "size",
|
|
638
|
+
options,
|
|
639
|
+
async fn(state) {
|
|
640
|
+
var _state$middlewareData, _state$middlewareData2;
|
|
641
|
+
const {
|
|
642
|
+
placement,
|
|
643
|
+
rects,
|
|
644
|
+
platform,
|
|
645
|
+
elements
|
|
646
|
+
} = state;
|
|
647
|
+
const {
|
|
648
|
+
apply = () => {
|
|
649
|
+
},
|
|
650
|
+
...detectOverflowOptions
|
|
651
|
+
} = evaluate(options, state);
|
|
652
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
653
|
+
const side = getSide(placement);
|
|
654
|
+
const alignment = getAlignment(placement);
|
|
655
|
+
const isYAxis = getSideAxis(placement) === "y";
|
|
656
|
+
const {
|
|
657
|
+
width,
|
|
658
|
+
height
|
|
659
|
+
} = rects.floating;
|
|
660
|
+
let heightSide;
|
|
661
|
+
let widthSide;
|
|
662
|
+
if (side === "top" || side === "bottom") {
|
|
663
|
+
heightSide = side;
|
|
664
|
+
widthSide = alignment === (await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
|
|
665
|
+
} else {
|
|
666
|
+
widthSide = side;
|
|
667
|
+
heightSide = alignment === "end" ? "top" : "bottom";
|
|
668
|
+
}
|
|
669
|
+
const maximumClippingHeight = height - overflow.top - overflow.bottom;
|
|
670
|
+
const maximumClippingWidth = width - overflow.left - overflow.right;
|
|
671
|
+
const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
|
|
672
|
+
const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
|
|
673
|
+
const noShift = !state.middlewareData.shift;
|
|
674
|
+
let availableHeight = overflowAvailableHeight;
|
|
675
|
+
let availableWidth = overflowAvailableWidth;
|
|
676
|
+
if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
|
|
677
|
+
availableWidth = maximumClippingWidth;
|
|
678
|
+
}
|
|
679
|
+
if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
|
|
680
|
+
availableHeight = maximumClippingHeight;
|
|
681
|
+
}
|
|
682
|
+
if (noShift && !alignment) {
|
|
683
|
+
const xMin = max(overflow.left, 0);
|
|
684
|
+
const xMax = max(overflow.right, 0);
|
|
685
|
+
const yMin = max(overflow.top, 0);
|
|
686
|
+
const yMax = max(overflow.bottom, 0);
|
|
687
|
+
if (isYAxis) {
|
|
688
|
+
availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
|
|
689
|
+
} else {
|
|
690
|
+
availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
await apply({
|
|
694
|
+
...state,
|
|
695
|
+
availableWidth,
|
|
696
|
+
availableHeight
|
|
697
|
+
});
|
|
698
|
+
const nextDimensions = await platform.getDimensions(elements.floating);
|
|
699
|
+
if (width !== nextDimensions.width || height !== nextDimensions.height) {
|
|
700
|
+
return {
|
|
701
|
+
reset: {
|
|
702
|
+
rects: true
|
|
703
|
+
}
|
|
704
|
+
};
|
|
705
|
+
}
|
|
706
|
+
return {};
|
|
707
|
+
}
|
|
708
|
+
};
|
|
709
|
+
};
|
|
710
|
+
export {
|
|
711
|
+
arrow,
|
|
712
|
+
computePosition,
|
|
713
|
+
detectOverflow,
|
|
714
|
+
flip,
|
|
715
|
+
hide,
|
|
716
|
+
limitShift,
|
|
717
|
+
offset,
|
|
718
|
+
rectToClientRect,
|
|
719
|
+
shift,
|
|
720
|
+
size
|
|
721
|
+
};
|