actual-css 0.6.0 → 0.8.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 +214 -1
- package/README.md +13 -11
- package/components.json +668 -0
- package/dist/actual.css +166 -37
- package/dist/actual.full.css +1005 -550
- package/dist/actual.full.js +1 -1
- package/dist/actual.full.min.css +1 -1
- package/dist/actual.js +1 -1
- package/dist/actual.min.css +1 -1
- package/docs/design-notes/accessibility-decisions.md +33 -0
- package/docs/design-notes/browser-support.md +82 -25
- package/docs/design-notes/column-layout.md +3 -3
- package/docs/design-notes/css-anchor.md +75 -21
- package/docs/design-notes/enhancement-contract.md +14 -6
- package/docs/design-notes/grid.md +4 -4
- package/docs/design-notes/naming.md +6 -1
- package/docs/design-notes/platform-alignment.md +99 -2
- package/docs/design-notes/popover-manual-poc.md +328 -0
- package/docs/design-notes/surface-reparenting.md +131 -0
- package/docs/design-notes/tooltip-coordinate-space.md +132 -0
- package/docs/design-notes/widget-primitives.md +9 -6
- package/docs/pages/components/accordion.md +41 -2
- package/docs/pages/components/alert.md +80 -30
- package/docs/pages/components/app-navigation.md +6 -0
- package/docs/pages/components/avatar.md +6 -6
- package/docs/pages/components/badge.md +101 -16
- package/docs/pages/components/button.md +16 -8
- package/docs/pages/components/card.md +10 -10
- package/docs/pages/components/dialog.md +16 -6
- package/docs/pages/components/fab.md +4 -3
- package/docs/pages/components/list.md +42 -4
- package/docs/pages/components/navbar.md +17 -1
- package/docs/pages/components/pagination.md +2 -2
- package/docs/pages/components/steps.md +19 -0
- package/docs/pages/components/table.md +3 -2
- package/docs/pages/enhancements/flyout.md +144 -24
- package/docs/pages/enhancements/overview.md +25 -0
- package/docs/pages/enhancements/status-bar.md +20 -0
- package/docs/pages/enhancements/tabs.md +45 -37
- package/docs/pages/enhancements/tooltip.md +40 -2
- package/docs/pages/examples/overview.md +38 -5
- package/docs/pages/forms/choice-cards.md +6 -2
- package/docs/pages/forms/combobox.md +1 -1
- package/docs/pages/forms/floating-field.md +4 -3
- package/docs/pages/forms/joined-controls.md +22 -0
- package/docs/pages/forms/otp.md +2 -1
- package/docs/pages/forms/overview.md +1 -1
- package/docs/pages/forms/states-and-sizes.md +16 -18
- package/docs/pages/forms/sticky-actions.md +2 -2
- package/docs/pages/forms/switch.md +1 -1
- package/docs/pages/foundations/philosophy.md +67 -22
- package/docs/pages/foundations/theming.md +10 -2
- package/docs/pages/foundations/tokens.md +118 -21
- package/docs/pages/foundations/typography.md +35 -14
- package/docs/pages/guides/introduction.md +11 -9
- package/docs/pages/guides/progressive-enhancement.md +136 -49
- package/docs/pages/guides/tailwind.md +3 -2
- package/docs/pages/layout/media.md +1 -1
- package/docs/pages/layout/overview.md +11 -1
- package/docs/pages/layout/scroll-snap.md +3 -3
- package/docs/pages/layout/stack.md +17 -9
- package/docs/pages/patterns/icon-input.md +4 -2
- package/docs/pages/patterns/icon-slot.md +2 -0
- package/docs/pages/patterns/intent-nesting.md +1 -1
- package/docs/pages/utilities/overview.md +23 -2
- package/docs/pages/utilities/sizing-wrapping.md +1 -1
- package/docs/pages/utilities/spacing.md +10 -8
- package/llms.txt +2 -1
- package/package.json +19 -8
- package/{scripts/reserved-classes.json → reserved-classes.json} +4 -6
- package/src/css/components/accordion.css +42 -3
- package/src/css/components/alert.css +25 -13
- package/src/css/components/app-nav.css +18 -8
- package/src/css/components/avatar.css +13 -1
- package/src/css/components/badge.css +78 -12
- package/src/css/components/breadcrumb.css +2 -3
- package/src/css/components/button.css +9 -16
- package/src/css/components/card.css +9 -2
- package/src/css/components/chat.css +1 -0
- package/src/css/components/data-list.css +1 -1
- package/src/css/components/drawer.css +79 -25
- package/src/css/components/fab.css +0 -6
- package/src/css/components/flyout.css +46 -63
- package/src/css/components/index.css +0 -1
- package/src/css/components/indicator.css +21 -0
- package/src/css/components/join.css +7 -0
- package/src/css/components/key.css +10 -0
- package/src/css/components/list.css +40 -4
- package/src/css/components/menu.css +18 -11
- package/src/css/components/modal.css +48 -33
- package/src/css/components/navbar.css +37 -4
- package/src/css/components/pagination.css +1 -0
- package/src/css/components/spinner.css +6 -6
- package/src/css/components/status-bar.css +0 -5
- package/src/css/components/steps.css +45 -59
- package/src/css/components/tab.css +29 -9
- package/src/css/components/table.css +5 -5
- package/src/css/components/tooltip.css +45 -13
- package/src/css/core/base.css +23 -1
- package/src/css/core/intents.css +17 -6
- package/src/css/core/theme.css +27 -0
- package/src/css/core/tokens.css +35 -15
- package/src/css/core/variants.css +64 -15
- package/src/css/forms/choice-card.css +4 -4
- package/src/css/forms/choice.css +6 -3
- package/src/css/forms/control.css +2 -1
- package/src/css/forms/floating-field.css +3 -3
- package/src/css/forms/form.css +4 -3
- package/src/css/forms/input-icon.css +20 -14
- package/src/css/forms/native.css +6 -1
- package/src/css/forms/otp.css +9 -1
- package/src/css/forms/range.css +2 -0
- package/src/css/forms/select.css +29 -9
- package/src/css/forms/switch.css +19 -5
- package/src/css/layout/app-layout.css +1 -1
- package/src/css/layout/grid.css +50 -76
- package/src/css/layout/scroll-snap.css +11 -7
- package/src/css/layout/scroller.css +3 -4
- package/src/css/layout/stack.css +2 -2
- package/src/css/typography/fluid.css +4 -3
- package/src/css/typography/prose.css +6 -5
- package/src/css/utilities/base.css +2 -1
- package/src/css/utilities/extra.css +20 -17
- package/src/js/context-menu.js +27 -26
- package/src/js/dialog.js +2 -1
- package/src/js/dismiss.js +5 -0
- package/src/js/enhance.js +34 -2
- package/src/js/enhancement-loader.js +36 -43
- package/src/js/events.js +0 -3
- package/src/js/filter.js +0 -1
- package/src/js/floating-space.js +42 -0
- package/src/js/flyout.js +9 -44
- package/src/js/focus-group.js +7 -0
- package/src/js/focus.js +6 -0
- package/src/js/menu.js +10 -1
- package/src/js/selectors.js +5 -9
- package/src/js/status.js +44 -7
- package/src/js/surface.js +106 -132
- package/src/js/tab.js +6 -1
- package/src/js/tooltip.js +152 -53
- package/src/js/validation.js +1 -1
- package/src/css/components/surface.css +0 -49
- package/src/js/floating.js +0 -432
package/src/js/floating.js
DELETED
|
@@ -1,432 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Compact positioning engine for menus, tooltips, and popovers.
|
|
3
|
-
*
|
|
4
|
-
* Core math ported from Floating UI. autoUpdate() batches scroll, resize,
|
|
5
|
-
* and element-resize callbacks per ownerDocument so each document owns its
|
|
6
|
-
* own listener set — no global import-time side effects.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/* ── Placement parsing ────────────────────────────────── */
|
|
10
|
-
|
|
11
|
-
function getSide(p) {
|
|
12
|
-
return p.split("-")[0];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function getAlignment(p) {
|
|
16
|
-
return p.split("-")[1] || null;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function getMainAxis(p) {
|
|
20
|
-
return ["top", "bottom"].includes(getSide(p)) ? "x" : "y";
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function flipSide(s) {
|
|
24
|
-
if (s === "top") return "bottom";
|
|
25
|
-
if (s === "bottom") return "top";
|
|
26
|
-
if (s === "left") return "right";
|
|
27
|
-
if (s === "right") return "left";
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/* ── Coordinate math ──────────────────────────────────── */
|
|
31
|
-
|
|
32
|
-
function computeCoords(reference, floating, placement, rtl) {
|
|
33
|
-
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
34
|
-
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
35
|
-
const mainAxis = getMainAxis(placement);
|
|
36
|
-
const commonAlign =
|
|
37
|
-
reference[mainAxis === "x" ? "width" : "height"] / 2 -
|
|
38
|
-
floating[mainAxis === "x" ? "width" : "height"] / 2;
|
|
39
|
-
const side = getSide(placement);
|
|
40
|
-
|
|
41
|
-
let coords;
|
|
42
|
-
switch (side) {
|
|
43
|
-
case "top":
|
|
44
|
-
coords = { x: commonX, y: reference.y - floating.height };
|
|
45
|
-
break;
|
|
46
|
-
case "bottom":
|
|
47
|
-
coords = { x: commonX, y: reference.y + reference.height };
|
|
48
|
-
break;
|
|
49
|
-
case "right":
|
|
50
|
-
coords = { x: reference.x + reference.width, y: commonY };
|
|
51
|
-
break;
|
|
52
|
-
case "left":
|
|
53
|
-
coords = { x: reference.x - floating.width, y: commonY };
|
|
54
|
-
break;
|
|
55
|
-
default:
|
|
56
|
-
coords = { x: reference.x, y: reference.y };
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const align = getAlignment(placement);
|
|
60
|
-
const isVertical = mainAxis === "x";
|
|
61
|
-
if (align === "start") coords[mainAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
62
|
-
if (align === "end") coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
63
|
-
|
|
64
|
-
return coords;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function applyOffset(coords, side, offset) {
|
|
68
|
-
switch (side) {
|
|
69
|
-
case "top":
|
|
70
|
-
coords.y -= offset;
|
|
71
|
-
break;
|
|
72
|
-
case "bottom":
|
|
73
|
-
coords.y += offset;
|
|
74
|
-
break;
|
|
75
|
-
case "left":
|
|
76
|
-
coords.x -= offset;
|
|
77
|
-
break;
|
|
78
|
-
case "right":
|
|
79
|
-
coords.x += offset;
|
|
80
|
-
break;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function getInlineOverflow(coords, floating, minX, maxX) {
|
|
85
|
-
return Math.max(minX - coords.x, 0) + Math.max(coords.x + floating.width - maxX, 0);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function toBoundary(rect) {
|
|
89
|
-
return {
|
|
90
|
-
x: rect.x,
|
|
91
|
-
y: rect.y,
|
|
92
|
-
width: rect.width,
|
|
93
|
-
height: rect.height,
|
|
94
|
-
right: rect.x + rect.width,
|
|
95
|
-
bottom: rect.y + rect.height,
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const supportsDirSelector = typeof CSS !== "undefined" && CSS.supports("selector(:dir(rtl))");
|
|
100
|
-
|
|
101
|
-
function isRTL(el) {
|
|
102
|
-
if (el.dir === "rtl") return true;
|
|
103
|
-
if (el.dir === "ltr") return false;
|
|
104
|
-
if (supportsDirSelector) return el.matches(":dir(rtl)");
|
|
105
|
-
const style = el.ownerDocument?.defaultView?.getComputedStyle?.(el);
|
|
106
|
-
return style?.direction === "rtl";
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function getDocEl(doc) {
|
|
110
|
-
return doc.documentElement;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function toNumber(value) {
|
|
114
|
-
const number = Number.parseFloat(value);
|
|
115
|
-
return Number.isFinite(number) ? number : 0;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const STABLE_SCROLLBAR_MAX_WIDTH = 25;
|
|
119
|
-
const NARROW_INLINE_FLIP_FALLBACK = 128;
|
|
120
|
-
|
|
121
|
-
function getViewportBoundary(doc) {
|
|
122
|
-
const win = doc.defaultView || window;
|
|
123
|
-
const docEl = getDocEl(doc);
|
|
124
|
-
const visualViewport = win.visualViewport;
|
|
125
|
-
const x = visualViewport?.offsetLeft || 0;
|
|
126
|
-
const y = visualViewport?.offsetTop || 0;
|
|
127
|
-
let width = visualViewport?.width || docEl.clientWidth || win.innerWidth;
|
|
128
|
-
const height = visualViewport?.height || docEl.clientHeight || win.innerHeight;
|
|
129
|
-
|
|
130
|
-
const body = doc.body;
|
|
131
|
-
if (body?.clientWidth > 0) {
|
|
132
|
-
const bodyStyle = win.getComputedStyle?.(body);
|
|
133
|
-
const bodyMargin =
|
|
134
|
-
doc.compatMode === "CSS1Compat"
|
|
135
|
-
? toNumber(bodyStyle?.marginLeft) + toNumber(bodyStyle?.marginRight)
|
|
136
|
-
: 0;
|
|
137
|
-
const stableScrollbar = Math.abs(docEl.clientWidth - body.clientWidth - bodyMargin);
|
|
138
|
-
if (stableScrollbar <= STABLE_SCROLLBAR_MAX_WIDTH) {
|
|
139
|
-
width -= stableScrollbar;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return toBoundary({ x, y, width, height });
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function getBoundary(ref, opts) {
|
|
147
|
-
if (!opts.scope) return getViewportBoundary(ref.ownerDocument);
|
|
148
|
-
const rect = opts.scope.getBoundingClientRect();
|
|
149
|
-
return toBoundary({
|
|
150
|
-
x: rect.x,
|
|
151
|
-
y: rect.y,
|
|
152
|
-
width: rect.width,
|
|
153
|
-
height: rect.height,
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
function isOutsideBoundary(rect, boundary) {
|
|
158
|
-
return (
|
|
159
|
-
rect.right < boundary.x ||
|
|
160
|
-
rect.left > boundary.right ||
|
|
161
|
-
rect.bottom < boundary.y ||
|
|
162
|
-
rect.top > boundary.bottom
|
|
163
|
-
);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function getAvailableHeight(refRect, side, boundary, distance, padding) {
|
|
167
|
-
if (side === "top") {
|
|
168
|
-
return Math.max(0, refRect.top - boundary.y - distance - padding);
|
|
169
|
-
}
|
|
170
|
-
if (side === "bottom") {
|
|
171
|
-
return Math.max(0, boundary.bottom - refRect.bottom - distance - padding);
|
|
172
|
-
}
|
|
173
|
-
return Math.max(0, boundary.height - padding * 2);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
function isVisible(el) {
|
|
177
|
-
if (el.hidden) return false;
|
|
178
|
-
if (typeof el.checkVisibility === "function") return el.checkVisibility();
|
|
179
|
-
return el.getClientRects().length > 0;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
function getFloatingSize(float) {
|
|
183
|
-
const rect = float.getBoundingClientRect();
|
|
184
|
-
return {
|
|
185
|
-
width: float.offsetWidth || rect.width,
|
|
186
|
-
height: float.offsetHeight || rect.height,
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/* ── Per-document batched callbacks ────────────────────── */
|
|
191
|
-
|
|
192
|
-
const trackers = new WeakMap();
|
|
193
|
-
|
|
194
|
-
function createTracker(doc) {
|
|
195
|
-
const win = doc.defaultView;
|
|
196
|
-
const ResizeObserver = win?.ResizeObserver;
|
|
197
|
-
|
|
198
|
-
const entries = new Map();
|
|
199
|
-
let resizeObserver = null;
|
|
200
|
-
let tick = false;
|
|
201
|
-
const pending = new Map();
|
|
202
|
-
|
|
203
|
-
function getResizeObserver() {
|
|
204
|
-
if (resizeObserver || !ResizeObserver) return resizeObserver;
|
|
205
|
-
|
|
206
|
-
resizeObserver = new ResizeObserver((entries, observer) => {
|
|
207
|
-
for (const entry of entries) {
|
|
208
|
-
observer.unobserve(entry.target);
|
|
209
|
-
rafNotify("element-resize", entry);
|
|
210
|
-
win.requestAnimationFrame(() => {
|
|
211
|
-
if (tracker.entries.has(entry.target)) observer.observe(entry.target);
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
return resizeObserver;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
function rafNotify(type, source) {
|
|
219
|
-
for (const element of entries.keys()) {
|
|
220
|
-
let notifications = pending.get(element);
|
|
221
|
-
if (!notifications) {
|
|
222
|
-
notifications = new Map();
|
|
223
|
-
pending.set(element, notifications);
|
|
224
|
-
}
|
|
225
|
-
let notification = notifications.get(type);
|
|
226
|
-
if (!notification) {
|
|
227
|
-
notification = { targets: new Set(), timeStamp: 0 };
|
|
228
|
-
notifications.set(type, notification);
|
|
229
|
-
}
|
|
230
|
-
if (source?.target) notification.targets.add(source.target);
|
|
231
|
-
notification.timeStamp = Math.max(notification.timeStamp, source?.timeStamp || 0);
|
|
232
|
-
}
|
|
233
|
-
if (!tick) {
|
|
234
|
-
win.requestAnimationFrame(() => {
|
|
235
|
-
const notifications = [...pending];
|
|
236
|
-
pending.clear();
|
|
237
|
-
for (const [element, types] of notifications) {
|
|
238
|
-
const cb = entries.get(element);
|
|
239
|
-
if (!cb || !element.isConnected) continue;
|
|
240
|
-
for (const [pendingType, detail] of types) {
|
|
241
|
-
cb({ type: pendingType, ...detail });
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
tick = false;
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
tick = true;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
doc.addEventListener("scroll", (e) => rafNotify(e.type, e), {
|
|
251
|
-
passive: true,
|
|
252
|
-
capture: true,
|
|
253
|
-
});
|
|
254
|
-
win.addEventListener("resize", (e) => rafNotify("resize", e), { passive: true });
|
|
255
|
-
|
|
256
|
-
const tracker = {
|
|
257
|
-
entries,
|
|
258
|
-
add(element, callback) {
|
|
259
|
-
entries.set(element, callback);
|
|
260
|
-
getResizeObserver()?.observe(element);
|
|
261
|
-
return () => {
|
|
262
|
-
entries.delete(element);
|
|
263
|
-
pending.delete(element);
|
|
264
|
-
resizeObserver?.unobserve(element);
|
|
265
|
-
};
|
|
266
|
-
},
|
|
267
|
-
};
|
|
268
|
-
|
|
269
|
-
return tracker;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
function trackerFor(element) {
|
|
273
|
-
const doc = element.ownerDocument;
|
|
274
|
-
let tracker = trackers.get(doc);
|
|
275
|
-
if (!tracker) {
|
|
276
|
-
tracker = createTracker(doc);
|
|
277
|
-
trackers.set(doc, tracker);
|
|
278
|
-
}
|
|
279
|
-
return tracker;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
export function autoUpdate(element, callback) {
|
|
283
|
-
return trackerFor(element).add(element, callback);
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
/* ── Positioning ──────────────────────────────────────── */
|
|
287
|
-
|
|
288
|
-
export function reposition(ref, float, opts = {}) {
|
|
289
|
-
if (!isVisible(float)) return false;
|
|
290
|
-
|
|
291
|
-
const placement = opts.placement || "bottom-start";
|
|
292
|
-
const distance = opts.distance || 0;
|
|
293
|
-
const flip = opts.flip !== false;
|
|
294
|
-
const shift = opts.shift !== false;
|
|
295
|
-
const shiftPad = opts.shiftPadding ?? 4;
|
|
296
|
-
const rtl = isRTL(ref);
|
|
297
|
-
|
|
298
|
-
const rects = ref.getClientRects();
|
|
299
|
-
const refRect = placement.startsWith("bottom") ? rects[rects.length - 1] : rects[0];
|
|
300
|
-
if (!refRect) return false;
|
|
301
|
-
|
|
302
|
-
const boundary = getBoundary(ref, opts);
|
|
303
|
-
if (isOutsideBoundary(refRect, boundary)) return false;
|
|
304
|
-
|
|
305
|
-
const floatRect = getFloatingSize(float);
|
|
306
|
-
const sx = boundary.x;
|
|
307
|
-
const sy = boundary.y;
|
|
308
|
-
const cw = boundary.right;
|
|
309
|
-
const ch = boundary.bottom;
|
|
310
|
-
|
|
311
|
-
let side = getSide(placement);
|
|
312
|
-
const align = getAlignment(placement);
|
|
313
|
-
let axis = getMainAxis(placement);
|
|
314
|
-
let current = placement;
|
|
315
|
-
let coords = computeCoords(refRect, floatRect, current, rtl);
|
|
316
|
-
applyOffset(coords, side, distance);
|
|
317
|
-
|
|
318
|
-
if (flip) {
|
|
319
|
-
const cx = Math.ceil(coords.x);
|
|
320
|
-
const cy = Math.ceil(coords.y);
|
|
321
|
-
|
|
322
|
-
if (
|
|
323
|
-
(axis === "x" && (cy < sy || cy + floatRect.height >= ch)) ||
|
|
324
|
-
(axis === "y" && (cx < sx || cx + floatRect.width >= cw))
|
|
325
|
-
) {
|
|
326
|
-
side = flipSide(side);
|
|
327
|
-
current = align ? `${side}-${align}` : side;
|
|
328
|
-
coords = computeCoords(refRect, floatRect, current, rtl);
|
|
329
|
-
applyOffset(coords, side, distance);
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
if (
|
|
333
|
-
axis === "y" &&
|
|
334
|
-
(coords.x < sx || coords.x + floatRect.width > cw) &&
|
|
335
|
-
boundary.width - floatRect.width < NARROW_INLINE_FLIP_FALLBACK
|
|
336
|
-
) {
|
|
337
|
-
side = "top";
|
|
338
|
-
axis = "x";
|
|
339
|
-
current = align ? `${side}-${align}` : side;
|
|
340
|
-
coords = computeCoords(refRect, floatRect, current, rtl);
|
|
341
|
-
applyOffset(coords, side, distance);
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
if (axis === "x" && shift && getAlignment(current)) {
|
|
346
|
-
const minX = sx + shiftPad;
|
|
347
|
-
const maxX = cw - shiftPad;
|
|
348
|
-
const currentOverflow = getInlineOverflow(coords, floatRect, minX, maxX);
|
|
349
|
-
|
|
350
|
-
if (currentOverflow > 0) {
|
|
351
|
-
const nextAlign = getAlignment(current) === "end" ? "start" : "end";
|
|
352
|
-
const candidatePlacement = `${side}-${nextAlign}`;
|
|
353
|
-
const candidate = computeCoords(refRect, floatRect, candidatePlacement, rtl);
|
|
354
|
-
applyOffset(candidate, side, distance);
|
|
355
|
-
|
|
356
|
-
if (getInlineOverflow(candidate, floatRect, minX, maxX) < currentOverflow) {
|
|
357
|
-
current = candidatePlacement;
|
|
358
|
-
coords = candidate;
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
let p = 50;
|
|
364
|
-
if (shift || floatRect.width > refRect.width) {
|
|
365
|
-
const minX = sx + shiftPad;
|
|
366
|
-
const maxX = cw - floatRect.width - shiftPad;
|
|
367
|
-
|
|
368
|
-
if (coords.x < minX) {
|
|
369
|
-
const total = minX - coords.x;
|
|
370
|
-
coords.x = minX;
|
|
371
|
-
p = 50 - (total / floatRect.width) * 100;
|
|
372
|
-
} else if (coords.x > maxX) {
|
|
373
|
-
const total = maxX - coords.x;
|
|
374
|
-
coords.x = Math.max(sx, maxX);
|
|
375
|
-
p = 50 + (total / floatRect.width) * 100;
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
let py = 50;
|
|
380
|
-
if (axis === "y" && (shift || floatRect.height > refRect.height)) {
|
|
381
|
-
const minY = sy + shiftPad;
|
|
382
|
-
const maxY = ch - floatRect.height - shiftPad;
|
|
383
|
-
|
|
384
|
-
if (coords.y < minY) {
|
|
385
|
-
const total = minY - coords.y;
|
|
386
|
-
coords.y = minY;
|
|
387
|
-
py = 50 - (total / floatRect.height) * 100;
|
|
388
|
-
} else if (coords.y > maxY) {
|
|
389
|
-
const total = maxY - coords.y;
|
|
390
|
-
coords.y = Math.max(sy, maxY);
|
|
391
|
-
py = 50 + (total / floatRect.height) * 100;
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
const availableHeight = getAvailableHeight(refRect, side, boundary, distance, shiftPad);
|
|
396
|
-
float.style.setProperty("--arrow-x", `${p}%`);
|
|
397
|
-
float.style.setProperty("--arrow-y", `${py}%`);
|
|
398
|
-
float.style.setProperty("--available-height", `${availableHeight}px`);
|
|
399
|
-
float.dataset.placement = current;
|
|
400
|
-
Object.assign(float.style, {
|
|
401
|
-
left: `${coords.x}px`,
|
|
402
|
-
top: `${coords.y}px`,
|
|
403
|
-
});
|
|
404
|
-
|
|
405
|
-
return true;
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
export function repositionAt(x, y, float, opts = {}) {
|
|
409
|
-
const doc = float.ownerDocument;
|
|
410
|
-
const docEl = doc.documentElement;
|
|
411
|
-
const win = doc.defaultView || window;
|
|
412
|
-
const direction = doc.dir || docEl?.dir || win.getComputedStyle?.(docEl).direction || "";
|
|
413
|
-
const ref = {
|
|
414
|
-
ownerDocument: doc,
|
|
415
|
-
dir: direction,
|
|
416
|
-
matches: (selector) => selector === ":dir(rtl)" && direction === "rtl",
|
|
417
|
-
getClientRects: () => [
|
|
418
|
-
{
|
|
419
|
-
x,
|
|
420
|
-
y,
|
|
421
|
-
left: x,
|
|
422
|
-
top: y,
|
|
423
|
-
right: x,
|
|
424
|
-
bottom: y,
|
|
425
|
-
width: 0,
|
|
426
|
-
height: 0,
|
|
427
|
-
},
|
|
428
|
-
],
|
|
429
|
-
};
|
|
430
|
-
|
|
431
|
-
return reposition(ref, float, opts);
|
|
432
|
-
}
|