magic-pill 9.4.0-next.2 → 9.4.0-next.4
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 +38 -2
- package/README.md +25 -17
- package/dist/MagicPill/MagicPill.d.mts +16 -2
- package/dist/MagicPill/MagicPill.d.ts +16 -2
- package/dist/MagicPill/MagicPill.js +12 -3
- package/dist/MagicPill/MagicPill.mjs +12 -3
- package/dist/Pill/Pill.js +1 -0
- package/dist/Pill/Pill.mjs +1 -0
- package/dist/Pill/goo.js +110 -35
- package/dist/Pill/goo.mjs +110 -36
- package/dist/Pill/modal.js +3 -1
- package/dist/Pill/modal.mjs +3 -1
- package/dist/Pill/morph.js +64 -10
- package/dist/Pill/morph.mjs +64 -11
- package/dist/Pill/zone.js +1 -2
- package/dist/Pill/zone.mjs +1 -2
- package/dist/PillForm/PillForm.js +6 -1
- package/dist/PillForm/PillForm.mjs +7 -2
- package/dist/PillForm/dates.js +14 -3
- package/dist/PillForm/dates.mjs +14 -3
- package/dist/PillForm/room.js +46 -0
- package/dist/PillForm/room.mjs +46 -0
- package/dist/PillNavbar/PillNavbar.js +3 -1
- package/dist/PillNavbar/PillNavbar.mjs +4 -2
- package/dist/PillNavbar/room.js +99 -24
- package/dist/PillNavbar/room.mjs +98 -25
- package/dist/PillNotification/PillNotification.js +2 -4
- package/dist/PillNotification/PillNotification.mjs +2 -4
- package/dist/PillNotification/RowsBody.js +77 -0
- package/dist/PillNotification/RowsBody.mjs +77 -0
- package/dist/forms.css +14 -0
- package/dist/satellites/Actions.js +181 -6
- package/dist/satellites/Actions.mjs +182 -7
- package/dist/satellites/Orbitals.js +218 -50
- package/dist/satellites/Orbitals.mjs +220 -52
- package/dist/satellites/Satellites.js +495 -107
- package/dist/satellites/Satellites.mjs +498 -111
- package/dist/satellites/handoff.js +36 -0
- package/dist/satellites/handoff.mjs +34 -0
- package/dist/satellites/layout.js +69 -3
- package/dist/satellites/layout.mjs +69 -4
- package/dist/satellites/measure.js +22 -0
- package/dist/satellites/measure.mjs +22 -1
- package/dist/satellites/orbits.js +49 -2
- package/dist/satellites/orbits.mjs +47 -3
- package/dist/satellites/types.d.mts +15 -1
- package/dist/satellites/types.d.ts +15 -1
- package/dist/satellites.d.mts +2 -2
- package/dist/satellites.d.ts +2 -2
- package/dist/styles.css +103 -15
- package/package.json +1 -1
|
@@ -12,6 +12,7 @@ const require_react = require("../utils/react.js");
|
|
|
12
12
|
const require_timing = require("../utils/timing.js");
|
|
13
13
|
const require_visuallyHidden = require("../utils/visuallyHidden.js");
|
|
14
14
|
const require_layout = require("./layout.js");
|
|
15
|
+
const require_handoff = require("./handoff.js");
|
|
15
16
|
const require_measure = require("./measure.js");
|
|
16
17
|
const require_Orbitals = require("./Orbitals.js");
|
|
17
18
|
const require_Actions = require("./Actions.js");
|
|
@@ -20,21 +21,24 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
20
21
|
// src/satellites/Satellites.tsx
|
|
21
22
|
const ELECTRON_STYLE = {
|
|
22
23
|
position: "fixed",
|
|
23
|
-
zIndex: "var(--mp-z-index, 50)",
|
|
24
|
+
zIndex: "calc(var(--mp-z-index, 50) - 1)",
|
|
24
25
|
margin: 0
|
|
25
26
|
};
|
|
26
27
|
const SHIFT = "mp-satellite-shift";
|
|
28
|
+
/** The room the satellites take beside a horizontal host, as planned (`--_mp-shift-x` applies it, maybe later) */
|
|
29
|
+
const PLANNED_ROOM = "--_mp-room-x";
|
|
27
30
|
/** The page's actions' entry among the satellites' presences */
|
|
28
31
|
const ACTIONS = "\0actions";
|
|
29
32
|
const SIDE_PLACEMENTS = /* @__PURE__ */ new Set(["left", "right"]);
|
|
30
33
|
/**
|
|
31
34
|
* The page's actions' box along the pill, whichever way their pill runs now
|
|
32
35
|
* and even while its size animates: laid out on a hidden copy, turned along,
|
|
33
|
-
* with all of them (not cut short by a wheel).
|
|
36
|
+
* open, with all of them (not cut short by a wheel).
|
|
34
37
|
*/
|
|
35
38
|
function alongBox(atom, vertical) {
|
|
36
39
|
const copy = atom.cloneNode(true);
|
|
37
40
|
copy.setAttribute("data-orientation", vertical ? "vertical" : "horizontal");
|
|
41
|
+
if (copy.dataset.presence === "rest") copy.dataset.presence = "compact";
|
|
38
42
|
copy.removeAttribute("id");
|
|
39
43
|
copy.inert = true;
|
|
40
44
|
copy.style.visibility = "hidden";
|
|
@@ -54,6 +58,7 @@ function alongBox(atom, vertical) {
|
|
|
54
58
|
return {
|
|
55
59
|
width,
|
|
56
60
|
height,
|
|
61
|
+
vertical,
|
|
57
62
|
wheel: {
|
|
58
63
|
count: actions.length,
|
|
59
64
|
first: length - Math.max(0, actions.length - 1) * step,
|
|
@@ -66,28 +71,81 @@ function alongBox(atom, vertical) {
|
|
|
66
71
|
* Out of the anchor (or back into it) with the goo, drawing itself the whole
|
|
67
72
|
* way, as the orbitals do: from inside it at its nearest edge by default.
|
|
68
73
|
*/
|
|
74
|
+
/** Out of the anchor from a point inside it, or back into it there (seen the whole way: `opaque`). */
|
|
69
75
|
const bud = (anchor, element, kind, delay, duration, from, opaque = false) => require_goo.playOrbit(anchor, [{
|
|
70
76
|
element,
|
|
71
77
|
delay,
|
|
72
|
-
from
|
|
78
|
+
from,
|
|
73
79
|
opaque
|
|
74
80
|
}], kind === "split" ? "open" : "close", { duration });
|
|
81
|
+
/**
|
|
82
|
+
* How long the screen (or the host) stays the same size before the satellites decide again: a drag
|
|
83
|
+
* of the window's edge sends one event per frame. Was 200 ms: a pause you could feel once you let go
|
|
84
|
+
*/
|
|
85
|
+
const SETTLED = 120;
|
|
86
|
+
/** A host's slide longer than this (px) can run against a droplet's way out (see drop) */
|
|
87
|
+
const AGAINST = 24;
|
|
88
|
+
/**
|
|
89
|
+
* Out of the anchor's edge as a droplet, growing to its size and then showing its content, or back
|
|
90
|
+
* into it the same way played backwards. `at`: where the anchor is going, if it's moving; `slide`:
|
|
91
|
+
* how it gets there, which a droplet coming out follows while it's still attached (from its edge
|
|
92
|
+
* where it is to its edge where it goes), or it would come out where the anchor no longer is.
|
|
93
|
+
*/
|
|
94
|
+
function drop(anchor, element, kind, delay, duration, at, slide) {
|
|
95
|
+
const from = require_goo.atEdgeOf(anchor, at, require_goo.DROPLET);
|
|
96
|
+
const moves = !!slide && kind === "split" && !require_timing.prefersReducedMotion() && typeof element.animate === "function";
|
|
97
|
+
if (moves && slide && Math.hypot(slide.x, slide.y) > AGAINST) {
|
|
98
|
+
for (const animation of element.getAnimations?.() ?? []) if (animation.id === "mp-split") animation.cancel();
|
|
99
|
+
const out = from(element.getBoundingClientRect(), element);
|
|
100
|
+
if (out.x * slide.x + out.y * slide.y < 0) {
|
|
101
|
+
const wait = delay + slide.duration;
|
|
102
|
+
const stop = require_goo.playOrbit(anchor, [{
|
|
103
|
+
element,
|
|
104
|
+
delay: wait,
|
|
105
|
+
from,
|
|
106
|
+
droplet: true
|
|
107
|
+
}], "open", { duration });
|
|
108
|
+
element.animate([{ opacity: 0 }, { opacity: 0 }], {
|
|
109
|
+
id: require_goo.SPLIT,
|
|
110
|
+
duration: wait
|
|
111
|
+
});
|
|
112
|
+
return stop;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const stop = require_goo.playOrbit(anchor, [{
|
|
116
|
+
element,
|
|
117
|
+
delay,
|
|
118
|
+
from,
|
|
119
|
+
droplet: true
|
|
120
|
+
}], kind === "split" ? "open" : "close", { duration });
|
|
121
|
+
if (moves && slide) element.animate([{ translate: `${slide.x}px ${slide.y}px` }, { translate: "0px 0px" }], {
|
|
122
|
+
id: require_goo.SPLIT,
|
|
123
|
+
duration: slide.duration,
|
|
124
|
+
easing: "ease-in-out",
|
|
125
|
+
composite: "add"
|
|
126
|
+
});
|
|
127
|
+
return stop;
|
|
128
|
+
}
|
|
75
129
|
/** The screen's length along the host's edge, less its offsets. */
|
|
76
130
|
const mainRoom = (vertical, offset) => (vertical ? window.innerHeight : document.documentElement.clientWidth || window.innerWidth) - offset * 2;
|
|
77
131
|
/**
|
|
78
132
|
* The length of the page's actions inside the pill when they must be cut
|
|
79
|
-
* short to leave it `room` (undefined: all of them fit). `
|
|
80
|
-
* the host
|
|
133
|
+
* short to leave it `room` (undefined: all of them fit). `length`: how long
|
|
134
|
+
* the host is, its actions as they are now, with its navbar's current page's
|
|
135
|
+
* label open when it folds by itself: the navbar keeps its room first, and
|
|
136
|
+
* the actions show what fits, the rest in their wheel.
|
|
81
137
|
*/
|
|
82
|
-
function insideWheelLength(track, root, vertical, room,
|
|
138
|
+
function insideWheelLength(track, root, vertical, room, length, folded) {
|
|
83
139
|
const actions = [...track.children];
|
|
84
140
|
if (actions.length < 2) return void 0;
|
|
85
141
|
const along = (element) => vertical ? element.offsetTop : element.offsetLeft;
|
|
86
142
|
const action = vertical ? actions[0].offsetHeight : actions[0].offsetWidth;
|
|
87
143
|
const step = Math.abs(along(actions[1]) - along(actions[0]));
|
|
88
144
|
const all = action + (actions.length - 1) * step;
|
|
89
|
-
const now =
|
|
90
|
-
const
|
|
145
|
+
const now = track.hasAttribute("data-wheel") ? Number.parseFloat(track.style.getPropertyValue("--_mp-wheel-length")) || all : all;
|
|
146
|
+
const leftWith = (host) => room - (host - now);
|
|
147
|
+
const open = vertical ? root.offsetHeight : length ?? root.offsetWidth;
|
|
148
|
+
const left = !vertical && folded !== void 0 && leftWith(open) < action ? leftWith(Math.min(open, folded)) : leftWith(open);
|
|
91
149
|
if (left >= all - .5 || step <= 0) return void 0;
|
|
92
150
|
return action + (Math.max(1, Math.min(actions.length, 1 + Math.floor((left - action) / step))) - 1) * step;
|
|
93
151
|
}
|
|
@@ -98,6 +156,46 @@ const nextTo = (a, b, gap) => {
|
|
|
98
156
|
return sideBySide || stacked;
|
|
99
157
|
};
|
|
100
158
|
/** What an electron shows: the ring and its value or icon, the value alone, or the app's own. */
|
|
159
|
+
/**
|
|
160
|
+
* The host's box at another size than it has now, from where it is by its placement's alignment
|
|
161
|
+
* (centred, or kept at its start or its end; against its side of the screen across it).
|
|
162
|
+
*/
|
|
163
|
+
function alignedBox(root, placement, vertical, rtl, { width, height }) {
|
|
164
|
+
const box = {
|
|
165
|
+
left: root.offsetLeft,
|
|
166
|
+
top: root.offsetTop,
|
|
167
|
+
width: root.offsetWidth,
|
|
168
|
+
height: root.offsetHeight
|
|
169
|
+
};
|
|
170
|
+
const along = (start, size, open, align) => align === "start" ? start : align === "end" ? start + size - open : start + size / 2 - open / 2;
|
|
171
|
+
if (vertical) return {
|
|
172
|
+
left: placement === "right" ? box.left + box.width - width : box.left,
|
|
173
|
+
top: along(box.top, box.height, height, "centre"),
|
|
174
|
+
width,
|
|
175
|
+
height
|
|
176
|
+
};
|
|
177
|
+
const edge = placement.endsWith("-start") ? "start" : placement.endsWith("-end") ? "end" : "centre";
|
|
178
|
+
const aligned = edge === "centre" ? edge : edge === "end" !== rtl ? "end" : "start";
|
|
179
|
+
const top = placement.startsWith("bottom") ? box.top + box.height - height : box.top;
|
|
180
|
+
return {
|
|
181
|
+
left: along(box.left, box.width, width, aligned),
|
|
182
|
+
top,
|
|
183
|
+
width,
|
|
184
|
+
height
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* The host as it will be open, for the satellites' plan on its way to another placement: a circle
|
|
189
|
+
* then, or growing again (72 px wide, everything would seem to fit beside it): its size open, on a
|
|
190
|
+
* copy, where it opens.
|
|
191
|
+
*/
|
|
192
|
+
function openHost(root, placement, vertical, rtl, folded) {
|
|
193
|
+
const host = alignedBox(root, placement, vertical, rtl, require_room.openSize(root));
|
|
194
|
+
return vertical ? { host } : {
|
|
195
|
+
host,
|
|
196
|
+
hostMin: folded ?? require_room.foldedWidth(root)
|
|
197
|
+
};
|
|
198
|
+
}
|
|
101
199
|
function ElectronContent({ electron }) {
|
|
102
200
|
const { input } = electron;
|
|
103
201
|
if (input.render) return input.render();
|
|
@@ -154,11 +252,13 @@ function SatellitesLayer({ host }) {
|
|
|
154
252
|
leaving: true
|
|
155
253
|
});
|
|
156
254
|
const [travelling, setTravelling] = (0, react.useState)(false);
|
|
255
|
+
const afterTrip = (0, react.useRef)(false);
|
|
157
256
|
const spot = `${host.placement} ${host.vertical}`;
|
|
158
257
|
const lastSpot = (0, react.useRef)(spot);
|
|
159
258
|
require_react.useIsomorphicLayoutEffect(() => {
|
|
160
259
|
if (lastSpot.current === spot) return;
|
|
161
260
|
lastSpot.current = spot;
|
|
261
|
+
afterTrip.current = "trip";
|
|
162
262
|
setTravelling(true);
|
|
163
263
|
}, [spot]);
|
|
164
264
|
(0, react.useEffect)(() => {
|
|
@@ -180,6 +280,20 @@ function SatellitesLayer({ host }) {
|
|
|
180
280
|
clearTimeout(fallback);
|
|
181
281
|
};
|
|
182
282
|
}, [travelling, host.rootRef]);
|
|
283
|
+
const shownPlacement = (root) => root.dataset.placement ?? host.placement;
|
|
284
|
+
const [placement, setPlacement] = (0, react.useState)(host.placement);
|
|
285
|
+
require_react.useIsomorphicLayoutEffect(() => {
|
|
286
|
+
const root = host.rootRef.current;
|
|
287
|
+
if (!root) return;
|
|
288
|
+
const read = () => setPlacement(shownPlacement(root));
|
|
289
|
+
read();
|
|
290
|
+
const watch = new MutationObserver(read);
|
|
291
|
+
watch.observe(root, {
|
|
292
|
+
attributes: true,
|
|
293
|
+
attributeFilter: ["data-placement"]
|
|
294
|
+
});
|
|
295
|
+
return () => watch.disconnect();
|
|
296
|
+
}, [host.rootRef, host.placement]);
|
|
183
297
|
const wanted = host.notifying && !host.keepElectronsOut || travelling;
|
|
184
298
|
const wasTucked = (0, react.useRef)(wanted);
|
|
185
299
|
const holding = (0, react.useRef)(false);
|
|
@@ -190,6 +304,7 @@ function SatellitesLayer({ host }) {
|
|
|
190
304
|
if (wanted || !holding.current) return;
|
|
191
305
|
const release = () => {
|
|
192
306
|
holding.current = false;
|
|
307
|
+
if (afterTrip.current) afterTrip.current = "ending";
|
|
193
308
|
refresh();
|
|
194
309
|
};
|
|
195
310
|
const morphs = (root?.getAnimations?.() ?? []).filter((animation) => animation.id === require_morph.MORPH);
|
|
@@ -207,21 +322,35 @@ function SatellitesLayer({ host }) {
|
|
|
207
322
|
const lastActions = (0, react.useRef)(null);
|
|
208
323
|
if (actions) lastActions.current = actions;
|
|
209
324
|
const detached = host.actionsStyle === "detached";
|
|
210
|
-
const
|
|
325
|
+
const turnPhase = (0, react.useRef)(null);
|
|
326
|
+
const turnFrom = (0, react.useRef)(null);
|
|
327
|
+
const presences = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
328
|
+
const handoff = require_handoff.useHandoff(host.store);
|
|
329
|
+
const [style, setStyle] = (0, react.useState)(host.actionsStyle);
|
|
330
|
+
const [leavingPill, setLeavingPill] = (0, react.useState)(false);
|
|
331
|
+
const waits = style !== host.actionsStyle ? detached && style === "inside" && !!actions : leavingPill;
|
|
332
|
+
if (style !== host.actionsStyle) {
|
|
333
|
+
setStyle(host.actionsStyle);
|
|
334
|
+
setLeavingPill(waits);
|
|
335
|
+
}
|
|
336
|
+
(0, react.useEffect)(() => {
|
|
337
|
+
if (leavingPill) setLeavingPill(false);
|
|
338
|
+
}, [leavingPill]);
|
|
339
|
+
const actionsPresence = detached && actions && !tucked && !waits && handoff !== "out" ? turnPhase.current ? "rest" : "compact" : "hidden";
|
|
211
340
|
const goingIn = (0, react.useRef)(false);
|
|
212
341
|
const wasDetached = (0, react.useRef)(detached);
|
|
213
|
-
if (wasDetached.current && !detached && actions) goingIn.current =
|
|
342
|
+
if (wasDetached.current && !detached && actions) goingIn.current = presences.current.get(ACTIONS) === "compact";
|
|
214
343
|
if (detached) goingIn.current = false;
|
|
215
344
|
wasDetached.current = detached;
|
|
216
|
-
const shownActions = detached || goingIn.current ? actions ?? lastActions.current : null;
|
|
345
|
+
const shownActions = detached && !waits && handoff !== "out" || goingIn.current ? actions ?? lastActions.current : null;
|
|
217
346
|
const atom = (0, react.useRef)(null);
|
|
218
347
|
const [actionsAcross, setActionsAcross] = (0, react.useState)(false);
|
|
219
348
|
const [wheelLength, setWheelLength] = (0, react.useState)(void 0);
|
|
220
349
|
const actionsBox = (0, react.useRef)(null);
|
|
221
350
|
const across = (0, react.useRef)(actionsAcross);
|
|
222
351
|
across.current = actionsAcross;
|
|
223
|
-
const presenceOf = ({ electron, leaving }) => {
|
|
224
|
-
if (leaving ||
|
|
352
|
+
const presenceOf = ({ electron, leaving }, tuck = tucked) => {
|
|
353
|
+
if (leaving || tuck) return "hidden";
|
|
225
354
|
return electron.input.hideOnOrigin !== false && electron.origin !== void 0 && require_matchPath.findActiveIndex(host.pathname, [{ href: electron.origin }]) === 0 ? "hidden" : "compact";
|
|
226
355
|
};
|
|
227
356
|
const entries = [...shown.current.values()].map((entry) => ({
|
|
@@ -229,73 +358,122 @@ function SatellitesLayer({ host }) {
|
|
|
229
358
|
presence: presenceOf(entry)
|
|
230
359
|
}));
|
|
231
360
|
const elements = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
232
|
-
const presences = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
233
361
|
const applied = (0, react.useRef)({
|
|
234
362
|
shift: 0,
|
|
235
|
-
reserve: 0
|
|
363
|
+
reserve: 0,
|
|
364
|
+
vertical: false
|
|
236
365
|
});
|
|
237
366
|
const hostMin = (0, react.useRef)(void 0);
|
|
367
|
+
const hostOpen = (0, react.useRef)(void 0);
|
|
238
368
|
const rows = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
239
369
|
const spots = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
240
370
|
const rejoining = (0, react.useRef)(/* @__PURE__ */ new Set());
|
|
241
371
|
const splitNext = (0, react.useRef)(/* @__PURE__ */ new Set());
|
|
242
|
-
const
|
|
372
|
+
const atomPlaced = (0, react.useRef)(null);
|
|
243
373
|
const lastStyle = (0, react.useRef)(host.actionsStyle);
|
|
374
|
+
const foldingSince = (0, react.useRef)(void 0);
|
|
375
|
+
const tripHost = (0, react.useRef)(null);
|
|
244
376
|
const arrange = (0, react.useRef)(() => {});
|
|
245
377
|
arrange.current = (animate) => {
|
|
246
378
|
const root = host.rootRef.current;
|
|
247
379
|
if (!root) return;
|
|
248
|
-
const
|
|
380
|
+
const placement = shownPlacement(root);
|
|
381
|
+
const vertical = SIDE_PLACEMENTS.has(placement);
|
|
249
382
|
const style = getComputedStyle(root);
|
|
250
383
|
const gap = require_measure.toPixels(style.getPropertyValue("--mp-electron-gap"), root, Number.parseFloat(style.columnGap) || 16);
|
|
251
384
|
const offset = require_measure.toPixels(style.getPropertyValue("--_mp-offset"), root, 24);
|
|
252
385
|
const out = entries.filter((entry) => entry.presence !== "hidden" && elements.current.get(entry.electron.id));
|
|
253
|
-
if (animate && !vertical)
|
|
386
|
+
if (animate && !vertical) {
|
|
387
|
+
hostMin.current = require_room.foldedWidth(root);
|
|
388
|
+
hostOpen.current = require_room.unfoldedWidth(root);
|
|
389
|
+
}
|
|
254
390
|
const atomElement = atom.current;
|
|
255
391
|
const atomOut = actionsPresence !== "hidden" && atomElement;
|
|
256
392
|
if (atomOut && (animate || !actionsBox.current)) actionsBox.current = alongBox(atomElement, vertical);
|
|
257
393
|
const turn = host.actionsOrientation === "auto" ? "auto" : host.actionsOrientation === "vertical" === vertical ? "along" : "across";
|
|
258
|
-
const
|
|
394
|
+
const sized = (list) => list.map(({ electron }) => {
|
|
395
|
+
const element = elements.current.get(electron.id);
|
|
396
|
+
return {
|
|
397
|
+
id: electron.id,
|
|
398
|
+
width: element.offsetWidth || 72,
|
|
399
|
+
height: element.offsetHeight || 72
|
|
400
|
+
};
|
|
401
|
+
});
|
|
402
|
+
const otherAxis = !!actionsBox.current && actionsBox.current.vertical !== vertical;
|
|
403
|
+
const actionsInput = (shown) => shown && actionsBox.current ? {
|
|
404
|
+
width: otherAxis ? actionsBox.current.height : actionsBox.current.width,
|
|
405
|
+
height: otherAxis ? actionsBox.current.width : actionsBox.current.height,
|
|
406
|
+
side: host.actionsSide,
|
|
407
|
+
turn,
|
|
408
|
+
...host.actionsWheel ? { wheel: actionsBox.current.wheel } : {}
|
|
409
|
+
} : void 0;
|
|
410
|
+
const squeezed = !vertical && hostMin.current !== void 0 && root.offsetWidth < hostMin.current - .5;
|
|
411
|
+
const input = {
|
|
259
412
|
viewport: {
|
|
260
413
|
width: document.documentElement.clientWidth || window.innerWidth,
|
|
261
414
|
height: window.innerHeight
|
|
262
415
|
},
|
|
263
|
-
host: {
|
|
416
|
+
host: squeezed ? alignedBox(root, placement, vertical, style.direction === "rtl", {
|
|
417
|
+
width: hostMin.current,
|
|
418
|
+
height: root.offsetHeight
|
|
419
|
+
}) : {
|
|
264
420
|
left: root.offsetLeft,
|
|
265
421
|
top: root.offsetTop,
|
|
266
422
|
width: root.offsetWidth,
|
|
267
423
|
height: root.offsetHeight
|
|
268
424
|
},
|
|
269
425
|
hostMin: vertical ? void 0 : hostMin.current,
|
|
270
|
-
placement
|
|
426
|
+
placement,
|
|
271
427
|
vertical,
|
|
272
428
|
rtl: style.direction === "rtl",
|
|
273
|
-
electrons: out
|
|
274
|
-
|
|
275
|
-
return {
|
|
276
|
-
id: electron.id,
|
|
277
|
-
width: element.offsetWidth || 72,
|
|
278
|
-
height: element.offsetHeight || 72
|
|
279
|
-
};
|
|
280
|
-
}),
|
|
281
|
-
actions: atomOut && actionsBox.current ? {
|
|
282
|
-
width: actionsBox.current.width,
|
|
283
|
-
height: actionsBox.current.height,
|
|
284
|
-
side: host.actionsSide,
|
|
285
|
-
turn,
|
|
286
|
-
...host.actionsWheel ? { wheel: actionsBox.current.wheel } : {}
|
|
287
|
-
} : void 0,
|
|
429
|
+
electrons: sized(out),
|
|
430
|
+
actions: actionsInput(!!atomOut),
|
|
288
431
|
nearest: host.nearestToPill,
|
|
289
432
|
side: host.electronSide,
|
|
290
433
|
line: host.electronLine,
|
|
291
434
|
arrange: host.arrange,
|
|
292
435
|
gap,
|
|
293
|
-
offset
|
|
294
|
-
|
|
436
|
+
offset,
|
|
437
|
+
obstacles: host.avoidPills ? require_measure.otherPills(root) : void 0
|
|
438
|
+
};
|
|
439
|
+
const rtl = style.direction === "rtl";
|
|
440
|
+
const open = hostOpen.current;
|
|
441
|
+
const least = hostMin.current;
|
|
442
|
+
const canFold = !vertical && open !== void 0 && least !== void 0 && least < open - .5;
|
|
443
|
+
const asOpen = canFold ? require_layout.planSatellites({
|
|
444
|
+
...input,
|
|
445
|
+
host: alignedBox(root, placement, vertical, rtl, {
|
|
446
|
+
width: open,
|
|
447
|
+
height: root.offsetHeight
|
|
448
|
+
}),
|
|
449
|
+
hostMin: void 0
|
|
450
|
+
}) : void 0;
|
|
451
|
+
const asFolded = canFold ? require_layout.planSatellites({
|
|
452
|
+
...input,
|
|
453
|
+
host: alignedBox(root, placement, vertical, rtl, {
|
|
454
|
+
width: least,
|
|
455
|
+
height: root.offsetHeight
|
|
456
|
+
})
|
|
457
|
+
}) : void 0;
|
|
458
|
+
const fitsOpen = !!asOpen && open + asOpen.reserve <= input.viewport.width - offset * 2 + .5 && asOpen.movedBeside.length <= asFolded.movedBeside.length && (!asOpen.actionsAcross || asFolded.actionsAcross) && (asOpen.actionsShown ?? 1e400) >= (asFolded.actionsShown ?? 1e400);
|
|
459
|
+
const layout = !canFold ? require_layout.planSatellites(input) : fitsOpen ? asOpen : asFolded;
|
|
460
|
+
if (!tucked && afterTrip.current === "ending") afterTrip.current = false;
|
|
461
|
+
const tripInputs = `${placement} ${input.viewport.width}x${input.viewport.height}`;
|
|
462
|
+
if (afterTrip.current && (animate || tripHost.current?.inputs !== tripInputs)) tripHost.current = {
|
|
463
|
+
inputs: tripInputs,
|
|
464
|
+
value: openHost(root, placement, vertical, style.direction === "rtl", animate ? hostMin.current : void 0)
|
|
465
|
+
};
|
|
466
|
+
const trip = afterTrip.current ? require_layout.planSatellites({
|
|
467
|
+
...input,
|
|
468
|
+
...tripHost.current.value,
|
|
469
|
+
electrons: sized(entries.filter((entry) => presenceOf(entry, false) !== "hidden" && elements.current.get(entry.electron.id))),
|
|
470
|
+
actions: actionsInput(detached && !!actions && !!atomElement)
|
|
471
|
+
}) : layout;
|
|
295
472
|
if (animate && host.actionsStyle === "inside") {
|
|
296
473
|
const track = root.querySelector("[data-mp=\"actions\"][data-inside]");
|
|
297
474
|
if (track) {
|
|
298
|
-
const
|
|
475
|
+
const hostLength = hostOpen.current ?? (hostMin.current !== void 0 ? Math.min(root.offsetWidth, hostMin.current) : void 0);
|
|
476
|
+
const length = host.actionsWheel ? insideWheelLength(track, root, vertical, mainRoom(vertical, offset) - layout.reserve, hostLength, vertical ? void 0 : require_room.foldedWidth(root, { content: true })) : void 0;
|
|
299
477
|
if (length === void 0) {
|
|
300
478
|
track.removeAttribute("data-wheel");
|
|
301
479
|
track.style.removeProperty("--_mp-wheel-length");
|
|
@@ -311,60 +489,116 @@ function SatellitesLayer({ host }) {
|
|
|
311
489
|
const boxes = layout.boxes;
|
|
312
490
|
const hostAlong = (vertical ? root.offsetTop : root.offsetLeft) + layout.shift + (vertical ? root.offsetHeight : root.offsetWidth) / 2;
|
|
313
491
|
const alongOf = (box) => vertical ? box.top + box.height / 2 : box.left + box.width / 2;
|
|
314
|
-
const
|
|
492
|
+
const outer = placement.startsWith("bottom") || placement === "right";
|
|
493
|
+
const hostCross = vertical ? root.offsetLeft : root.offsetTop;
|
|
494
|
+
const hostThick = vertical ? root.offsetWidth : root.offsetHeight;
|
|
495
|
+
const rowOf = (box) => {
|
|
496
|
+
const start = vertical ? box.left : box.top;
|
|
497
|
+
const thick = vertical ? box.width : box.height;
|
|
498
|
+
return Math.round(outer ? hostCross + hostThick - (start + thick) : start - hostCross);
|
|
499
|
+
};
|
|
500
|
+
const spotOf = (box) => `${alongOf(box) < hostAlong ? "before" : "after"} ${rowOf(box)}`;
|
|
501
|
+
const hostAt = () => ({
|
|
502
|
+
left: root.offsetLeft + (vertical ? 0 : applied.current.shift),
|
|
503
|
+
top: root.offsetTop + (vertical ? applied.current.shift : 0),
|
|
504
|
+
width: root.offsetWidth,
|
|
505
|
+
height: root.offsetHeight
|
|
506
|
+
});
|
|
315
507
|
const hostCentre = () => vertical ? require_goo.atPoint(root.offsetLeft + root.offsetWidth / 2, hostAlong) : require_goo.atPoint(hostAlong, root.offsetTop + root.offsetHeight / 2);
|
|
316
508
|
const changing = (id, box) => !!box && presences.current.get(id) === "compact" && spots.current.has(id) && spots.current.get(id) !== spotOf(box);
|
|
317
509
|
const turning = !!atomElement && !!atomOut && layout.actionsAcross !== across.current && presences.current.get(ACTIONS) === "compact";
|
|
318
510
|
const holding = animate && !reduced && (out.some(({ electron }) => !rejoining.current.has(electron.id) && changing(electron.id, boxes[electron.id])) || !!atomOut && !rejoining.current.has(ACTIONS) && (turning || changing(ACTIONS, boxes.actions))) || rejoining.current.size > 0;
|
|
319
511
|
const previous = applied.current;
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
512
|
+
const settling = holding || !animate && previous.placement !== void 0 && previous.placement !== placement;
|
|
513
|
+
const vector = (shift, onSide) => onSide ? {
|
|
514
|
+
x: 0,
|
|
515
|
+
y: shift
|
|
516
|
+
} : {
|
|
517
|
+
x: shift,
|
|
518
|
+
y: 0
|
|
519
|
+
};
|
|
520
|
+
const was = vector(previous.shift, previous.vertical);
|
|
521
|
+
const now = vector(trip.shift, vertical);
|
|
522
|
+
const hostSlide = vertical ? now.y - was.y : now.x - was.x;
|
|
523
|
+
let slide;
|
|
524
|
+
if (!settling && (Math.abs(was.x - now.x) > .5 || Math.abs(was.y - now.y) > .5)) {
|
|
525
|
+
if (trip.shift) root.style.setProperty("translate", `${now.x}px ${now.y}px`);
|
|
323
526
|
else root.style.removeProperty("translate");
|
|
324
|
-
if (moving)
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
527
|
+
if (moving) {
|
|
528
|
+
slide = {
|
|
529
|
+
x: was.x - now.x,
|
|
530
|
+
y: was.y - now.y,
|
|
531
|
+
duration: timings.change
|
|
532
|
+
};
|
|
533
|
+
root.animate([{ translate: `${was.x - now.x}px ${was.y - now.y}px` }, { translate: "0px 0px" }], {
|
|
534
|
+
id: SHIFT,
|
|
535
|
+
duration: timings.change,
|
|
536
|
+
easing: "ease-in-out",
|
|
537
|
+
composite: "add"
|
|
538
|
+
});
|
|
539
|
+
}
|
|
330
540
|
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
541
|
+
const reserve = vertical ? 0 : trip.reserve;
|
|
542
|
+
const room = root.style.getPropertyValue("--_mp-shift-x");
|
|
543
|
+
if (!settling) {
|
|
544
|
+
if (reserve) root.style.setProperty(PLANNED_ROOM, `${reserve}px`);
|
|
545
|
+
else root.style.removeProperty(PLANNED_ROOM);
|
|
546
|
+
const folding = reserve > (Number.parseFloat(room) || 0) && layout === asFolded && (placement === "top" || placement === "bottom") && root.offsetWidth > input.viewport.width - offset * 2 - reserve + .5;
|
|
547
|
+
if (!folding) foldingSince.current = void 0;
|
|
548
|
+
else if (foldingSince.current === void 0) {
|
|
549
|
+
foldingSince.current = performance.now();
|
|
550
|
+
const wait = timings.change * 2;
|
|
551
|
+
setTimeout(() => arrange.current(false), wait + 20);
|
|
552
|
+
}
|
|
553
|
+
const waits = folding && performance.now() - foldingSince.current < timings.change * 2;
|
|
554
|
+
if (reserve && !waits && room !== `${reserve}px`) root.style.setProperty("--_mp-shift-x", `${reserve}px`);
|
|
555
|
+
else if (!reserve && previous.reserve && room === `${previous.reserve}px`) root.style.removeProperty("--_mp-shift-x");
|
|
556
|
+
applied.current = {
|
|
557
|
+
shift: trip.shift,
|
|
558
|
+
reserve,
|
|
559
|
+
vertical,
|
|
560
|
+
placement
|
|
561
|
+
};
|
|
334
562
|
}
|
|
335
|
-
if (!holding) applied.current = {
|
|
336
|
-
shift: layout.shift,
|
|
337
|
-
reserve: layout.reserve
|
|
338
|
-
};
|
|
339
563
|
const rejoin = (id, element, then) => {
|
|
340
564
|
rejoining.current.add(id);
|
|
341
565
|
const { exit } = require_measure.durations(element);
|
|
342
|
-
|
|
566
|
+
drop(root, element, "join", 0, exit);
|
|
343
567
|
setTimeout(() => {
|
|
344
568
|
rejoining.current.delete(id);
|
|
345
569
|
then();
|
|
346
570
|
}, exit + 20);
|
|
347
571
|
};
|
|
348
572
|
const styleChanged = lastStyle.current !== host.actionsStyle;
|
|
349
|
-
if (animate)
|
|
350
|
-
const track = host.actionsStyle === "inside" ? root.querySelector("[data-mp=\"actions\"][data-inside]") : null;
|
|
351
|
-
if (track) {
|
|
352
|
-
const hostLeft = root.offsetLeft + (vertical ? 0 : layout.shift);
|
|
353
|
-
const hostTop = root.offsetTop + (vertical ? layout.shift : 0);
|
|
354
|
-
insideSpot.current = {
|
|
355
|
-
x: hostLeft + track.offsetLeft + track.offsetWidth / 2,
|
|
356
|
-
y: hostTop + track.offsetTop + track.offsetHeight / 2
|
|
357
|
-
};
|
|
358
|
-
}
|
|
359
|
-
lastStyle.current = host.actionsStyle;
|
|
360
|
-
}
|
|
573
|
+
if (animate) lastStyle.current = host.actionsStyle;
|
|
361
574
|
const slides = [];
|
|
362
575
|
if (atomElement) {
|
|
363
576
|
const was = presences.current.get(ACTIONS);
|
|
364
577
|
const box = boxes.actions;
|
|
365
578
|
const settled = layout.actionsAcross === across.current;
|
|
366
579
|
const moved = !!box && spots.current.has(ACTIONS) && spots.current.get(ACTIONS) !== spotOf(box);
|
|
367
|
-
|
|
580
|
+
const sideChanged = moved && spots.current.get(ACTIONS).split(" ")[0] !== spotOf(box).split(" ")[0];
|
|
581
|
+
if (animate && atomOut && was === "compact" && !settled && !sideChanged && !reduced && !rejoining.current.has(ACTIONS)) {
|
|
582
|
+
const turnTo = layout.actionsAcross;
|
|
583
|
+
const { fade, change } = require_measure.durations(atomElement);
|
|
584
|
+
turnFrom.current = atomPlaced.current ?? {
|
|
585
|
+
left: Number.parseFloat(atomElement.style.left),
|
|
586
|
+
top: Number.parseFloat(atomElement.style.top),
|
|
587
|
+
width: atomElement.offsetWidth,
|
|
588
|
+
height: atomElement.offsetHeight
|
|
589
|
+
};
|
|
590
|
+
turnPhase.current = "closing";
|
|
591
|
+
rejoining.current.add(ACTIONS);
|
|
592
|
+
refresh();
|
|
593
|
+
setTimeout(() => {
|
|
594
|
+
rejoining.current.delete(ACTIONS);
|
|
595
|
+
spots.current.delete(ACTIONS);
|
|
596
|
+
turnFrom.current = null;
|
|
597
|
+
turnPhase.current = "turned";
|
|
598
|
+
setActionsAcross(turnTo);
|
|
599
|
+
refresh();
|
|
600
|
+
}, fade + change + 20);
|
|
601
|
+
} else if (animate && atomOut && was === "compact" && (!settled || moved) && !reduced && !rejoining.current.has(ACTIONS)) {
|
|
368
602
|
const turnTo = layout.actionsAcross;
|
|
369
603
|
rejoin(ACTIONS, atomElement, () => {
|
|
370
604
|
presences.current.set(ACTIONS, "hidden");
|
|
@@ -373,12 +607,21 @@ function SatellitesLayer({ host }) {
|
|
|
373
607
|
refresh();
|
|
374
608
|
});
|
|
375
609
|
} else if (animate && atomOut && !settled && !rejoining.current.has(ACTIONS)) setActionsAcross(layout.actionsAcross);
|
|
610
|
+
const from = turnFrom.current;
|
|
611
|
+
if (turnPhase.current === "closing" && from) {
|
|
612
|
+
const width = atomElement.offsetWidth;
|
|
613
|
+
const height = atomElement.offsetHeight;
|
|
614
|
+
const left = vertical ? placement === "right" ? from.left + from.width - width : from.left : from.left + from.width / 2 - width / 2;
|
|
615
|
+
const top = vertical ? from.top + from.height / 2 - height / 2 : placement.startsWith("bottom") ? from.top + from.height - height : from.top;
|
|
616
|
+
atomElement.style.left = `${left}px`;
|
|
617
|
+
atomElement.style.top = `${top}px`;
|
|
618
|
+
}
|
|
376
619
|
if (animate && atomOut && actionsBox.current) {
|
|
377
620
|
const { wheel } = actionsBox.current;
|
|
378
621
|
const length = layout.actionsShown !== void 0 ? wheel.action + (layout.actionsShown - 1) * wheel.step : void 0;
|
|
379
622
|
if (length !== wheelLength) setWheelLength(length);
|
|
380
623
|
}
|
|
381
|
-
if (box && atomOut && settled && !rejoining.current.has(ACTIONS) && !holding) {
|
|
624
|
+
if (box && atomOut && settled && !rejoining.current.has(ACTIONS) && !holding && (animate || !moved) && turnPhase.current !== "closing") {
|
|
382
625
|
const before = alongOf(box) < hostAlong;
|
|
383
626
|
const width = atomElement.offsetWidth || box.width;
|
|
384
627
|
const height = atomElement.offsetHeight || box.height;
|
|
@@ -386,24 +629,96 @@ function SatellitesLayer({ host }) {
|
|
|
386
629
|
left: Number.parseFloat(atomElement.style.left),
|
|
387
630
|
top: Number.parseFloat(atomElement.style.top)
|
|
388
631
|
};
|
|
389
|
-
const left =
|
|
390
|
-
const top = vertical
|
|
632
|
+
const left = vertical ? placement === "right" ? box.left + box.width - width : box.left : before ? box.left + box.width - width : box.left;
|
|
633
|
+
const top = vertical ? before ? box.top + box.height - height : box.top : placement.startsWith("bottom") ? box.top + box.height - height : box.top;
|
|
391
634
|
atomElement.style.left = `${left}px`;
|
|
392
635
|
atomElement.style.top = `${top}px`;
|
|
393
636
|
spots.current.set(ACTIONS, spotOf(box));
|
|
394
|
-
|
|
395
|
-
|
|
637
|
+
const placedLast = atomPlaced.current;
|
|
638
|
+
const facing = (at) => vertical ? before ? at.top + at.height : at.top : before ? at.left + at.width : at.left;
|
|
639
|
+
const withHost = !!placedLast && (Math.abs(placedLast.width - width) > .5 || Math.abs(placedLast.height - height) > .5) && Math.abs(facing({
|
|
640
|
+
left,
|
|
641
|
+
top,
|
|
642
|
+
width,
|
|
643
|
+
height
|
|
644
|
+
}) - facing(placedLast) - hostSlide) <= 1;
|
|
645
|
+
atomPlaced.current = {
|
|
646
|
+
left,
|
|
647
|
+
top,
|
|
648
|
+
width,
|
|
649
|
+
height
|
|
650
|
+
};
|
|
651
|
+
if (turnPhase.current === "sliding") {} else if (animate && turnPhase.current === "turned") {
|
|
652
|
+
turnPhase.current = null;
|
|
653
|
+
if (moving && Number.isFinite(from.left) && Number.isFinite(from.top) && (Math.abs(from.left - left) > .5 || Math.abs(from.top - top) > .5)) {
|
|
654
|
+
atomElement.animate([{ translate: `${from.left - left}px ${from.top - top}px` }, { translate: "0px 0px" }], {
|
|
655
|
+
id: SHIFT,
|
|
656
|
+
duration: timings.change,
|
|
657
|
+
easing: "ease-in-out",
|
|
658
|
+
composite: "add"
|
|
659
|
+
});
|
|
660
|
+
turnPhase.current = "sliding";
|
|
661
|
+
setTimeout(() => {
|
|
662
|
+
turnPhase.current = null;
|
|
663
|
+
refresh();
|
|
664
|
+
}, timings.change);
|
|
665
|
+
} else refresh();
|
|
666
|
+
} else if (animate && (was === void 0 || was === "hidden")) {
|
|
396
667
|
require_morph.cancel(atomElement, require_morph.MORPH, true);
|
|
397
668
|
require_morph.cancel(atomElement, require_morph.MOVE);
|
|
398
|
-
|
|
399
|
-
} else if (moving && was === "compact" && Number.isFinite(from.left) && Number.isFinite(from.top)) {
|
|
400
|
-
|
|
669
|
+
drop(root, atomElement, "split", 0, require_measure.durations(atomElement).enter, hostAt, slide);
|
|
670
|
+
} else if (moving && was === "compact" && !withHost && Number.isFinite(from.left) && Number.isFinite(from.top) && Math.hypot(from.left - left, from.top - top) > gap) {
|
|
671
|
+
atomElement.style.left = `${from.left}px`;
|
|
672
|
+
atomElement.style.top = `${from.top}px`;
|
|
673
|
+
turnFrom.current = {
|
|
674
|
+
left: from.left,
|
|
675
|
+
top: from.top,
|
|
676
|
+
width,
|
|
677
|
+
height
|
|
678
|
+
};
|
|
679
|
+
turnPhase.current = "closing";
|
|
680
|
+
const { fade, change } = require_measure.durations(atomElement);
|
|
681
|
+
setTimeout(() => {
|
|
682
|
+
turnFrom.current = null;
|
|
683
|
+
turnPhase.current = "turned";
|
|
684
|
+
refresh();
|
|
685
|
+
}, fade + change + 20);
|
|
686
|
+
refresh();
|
|
687
|
+
} else if (moving && (was === "compact" || was === "rest") && Number.isFinite(from.left) && Number.isFinite(from.top)) {
|
|
688
|
+
if (withHost && placedLast) atomElement.animate([{
|
|
689
|
+
width: `${placedLast.width}px`,
|
|
690
|
+
height: `${placedLast.height}px`
|
|
691
|
+
}, {
|
|
692
|
+
width: `${width}px`,
|
|
693
|
+
height: `${height}px`
|
|
694
|
+
}], {
|
|
695
|
+
id: SHIFT,
|
|
696
|
+
duration: timings.change,
|
|
697
|
+
easing: "ease-in-out"
|
|
698
|
+
});
|
|
699
|
+
const along = withHost ? facing(placedLast) - facing({
|
|
700
|
+
left,
|
|
701
|
+
top,
|
|
702
|
+
width,
|
|
703
|
+
height
|
|
704
|
+
}) : 0;
|
|
705
|
+
const shift = withHost ? vertical ? {
|
|
706
|
+
x: 0,
|
|
707
|
+
y: along
|
|
708
|
+
} : {
|
|
709
|
+
x: along,
|
|
710
|
+
y: 0
|
|
711
|
+
} : {
|
|
712
|
+
x: from.left - left,
|
|
713
|
+
y: from.top - top
|
|
714
|
+
};
|
|
715
|
+
if (Math.abs(shift.x) > .5 || Math.abs(shift.y) > .5) {
|
|
401
716
|
slides.push({
|
|
402
717
|
element: atomElement,
|
|
403
|
-
from: vertical ?
|
|
718
|
+
from: vertical ? top + shift.y : left + shift.x,
|
|
404
719
|
to: vertical ? top : left
|
|
405
720
|
});
|
|
406
|
-
atomElement.animate([{ translate: `${
|
|
721
|
+
atomElement.animate([{ translate: `${shift.x}px ${shift.y}px` }, { translate: "0px 0px" }], {
|
|
407
722
|
id: SHIFT,
|
|
408
723
|
duration: timings.change,
|
|
409
724
|
easing: "ease-in-out",
|
|
@@ -411,24 +726,24 @@ function SatellitesLayer({ host }) {
|
|
|
411
726
|
});
|
|
412
727
|
}
|
|
413
728
|
}
|
|
414
|
-
} else if (animate && !atomOut && was === "compact") {
|
|
729
|
+
} else if (animate && !atomOut && (was === "compact" || was === "rest")) {
|
|
415
730
|
const { fade, exit } = require_measure.durations(atomElement);
|
|
416
|
-
if (styleChanged && host.actionsStyle === "inside" &&
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
bud(root, atomElement, "join", 0, exit, require_goo.atPoint(insideSpot.current.x, insideSpot.current.y, 1), true);
|
|
731
|
+
if (styleChanged && host.actionsStyle === "inside" && goingIn.current) {
|
|
732
|
+
require_handoff.setHandoff(host.store, "in");
|
|
733
|
+
drop(root, atomElement, "join", fade, exit, hostAt);
|
|
420
734
|
setTimeout(() => {
|
|
421
|
-
for (const child of atomElement.children) child.style.removeProperty("opacity");
|
|
422
735
|
goingIn.current = false;
|
|
736
|
+
require_handoff.setHandoff(host.store, void 0);
|
|
423
737
|
refresh();
|
|
424
|
-
}, exit + 20);
|
|
738
|
+
}, fade + exit + 20);
|
|
425
739
|
} else if (tucked) bud(root, atomElement, "join", 0, Math.max(exit, fade + require_measure.durations(atomElement).change), hostCentre());
|
|
426
|
-
else
|
|
740
|
+
else drop(root, atomElement, "join", fade, exit, hostAt);
|
|
427
741
|
spots.current.delete(ACTIONS);
|
|
428
742
|
}
|
|
429
743
|
if (animate && !rejoining.current.has(ACTIONS) && !holding && (settled || !atomOut)) presences.current.set(ACTIONS, actionsPresence);
|
|
430
744
|
}
|
|
431
|
-
const crossOf =
|
|
745
|
+
const crossOf = rowOf;
|
|
746
|
+
const hopping = /* @__PURE__ */ new Set();
|
|
432
747
|
out.forEach(({ electron }, index) => {
|
|
433
748
|
const element = elements.current.get(electron.id);
|
|
434
749
|
const box = boxes[electron.id];
|
|
@@ -438,7 +753,7 @@ function SatellitesLayer({ host }) {
|
|
|
438
753
|
element.style.left = `${box.left}px`;
|
|
439
754
|
element.style.top = `${box.top}px`;
|
|
440
755
|
rows.current.set(electron.id, String(crossOf(box)));
|
|
441
|
-
|
|
756
|
+
drop(root, element, "split", 0, require_measure.durations(element).enter, hostAt, slide);
|
|
442
757
|
return;
|
|
443
758
|
}
|
|
444
759
|
const moved = was === "compact" && spots.current.has(electron.id) && spots.current.get(electron.id) !== spotOf(box);
|
|
@@ -450,7 +765,7 @@ function SatellitesLayer({ host }) {
|
|
|
450
765
|
});
|
|
451
766
|
return;
|
|
452
767
|
}
|
|
453
|
-
if (holding) return;
|
|
768
|
+
if (holding || moved && !animate) return;
|
|
454
769
|
spots.current.set(electron.id, spotOf(box));
|
|
455
770
|
const from = {
|
|
456
771
|
left: Number.parseFloat(element.style.left),
|
|
@@ -474,8 +789,65 @@ function SatellitesLayer({ host }) {
|
|
|
474
789
|
if (was === void 0 || was === "hidden") {
|
|
475
790
|
const before = out[index - 1];
|
|
476
791
|
const neighbour = before ? elements.current.get(before.electron.id) : void 0;
|
|
477
|
-
const anchor = neighbour && before && nextTo(boxes[before.electron.id], box, gap) ? neighbour : root;
|
|
478
|
-
|
|
792
|
+
const anchor = neighbour && before && !hopping.has(before.electron.id) && nextTo(boxes[before.electron.id], box, gap) ? neighbour : root;
|
|
793
|
+
if (anchor === root) drop(root, element, "split", 0, require_measure.durations(element).enter, hostAt, slide);
|
|
794
|
+
else drop(anchor, element, "split", 0, require_measure.durations(element).enter);
|
|
795
|
+
} else if (moving && placed && Math.hypot(from.left - box.left, from.top - box.top) > gap && !reduced) {
|
|
796
|
+
hopping.add(electron.id);
|
|
797
|
+
const { fade, change } = require_measure.durations(element);
|
|
798
|
+
const options = {
|
|
799
|
+
id: SHIFT,
|
|
800
|
+
duration: fade * 2 + change
|
|
801
|
+
};
|
|
802
|
+
const at = `${from.left - box.left}px ${from.top - box.top}px`;
|
|
803
|
+
element.animate([
|
|
804
|
+
{
|
|
805
|
+
translate: at,
|
|
806
|
+
easing: "ease-in-out"
|
|
807
|
+
},
|
|
808
|
+
{
|
|
809
|
+
translate: at,
|
|
810
|
+
offset: .3,
|
|
811
|
+
easing: "ease-in-out"
|
|
812
|
+
},
|
|
813
|
+
{
|
|
814
|
+
translate: "0px 0px",
|
|
815
|
+
offset: .7
|
|
816
|
+
},
|
|
817
|
+
{ translate: "0px 0px" }
|
|
818
|
+
], {
|
|
819
|
+
...options,
|
|
820
|
+
composite: "add"
|
|
821
|
+
});
|
|
822
|
+
element.animate([
|
|
823
|
+
{
|
|
824
|
+
scale: 1,
|
|
825
|
+
easing: "ease-in"
|
|
826
|
+
},
|
|
827
|
+
{
|
|
828
|
+
scale: require_goo.DROPLET * 2,
|
|
829
|
+
offset: .3
|
|
830
|
+
},
|
|
831
|
+
{
|
|
832
|
+
scale: require_goo.DROPLET * 2,
|
|
833
|
+
offset: .7,
|
|
834
|
+
easing: "ease-out"
|
|
835
|
+
},
|
|
836
|
+
{ scale: 1 }
|
|
837
|
+
], options);
|
|
838
|
+
const content = [
|
|
839
|
+
{ opacity: 1 },
|
|
840
|
+
{
|
|
841
|
+
opacity: 0,
|
|
842
|
+
offset: .2
|
|
843
|
+
},
|
|
844
|
+
{
|
|
845
|
+
opacity: 0,
|
|
846
|
+
offset: .8
|
|
847
|
+
},
|
|
848
|
+
{ opacity: 1 }
|
|
849
|
+
];
|
|
850
|
+
for (const child of element.children) child.animate(content, options);
|
|
479
851
|
} else if (moving && placed && (Math.abs(from.left - box.left) > .5 || Math.abs(from.top - box.top) > .5)) {
|
|
480
852
|
slides.push({
|
|
481
853
|
element,
|
|
@@ -506,8 +878,8 @@ function SatellitesLayer({ host }) {
|
|
|
506
878
|
spots.current.delete(entry.electron.id);
|
|
507
879
|
if (ending === "pop") continue;
|
|
508
880
|
const { fade, change, exit } = require_measure.durations(element);
|
|
509
|
-
if (tucked
|
|
510
|
-
else
|
|
881
|
+
if (tucked) bud(root, element, "join", 0, Math.max(exit, fade + change), hostCentre());
|
|
882
|
+
else drop(root, element, "join", fade, exit, hostAt);
|
|
511
883
|
}
|
|
512
884
|
for (const entry of entries) presences.current.set(entry.electron.id, entry.presence);
|
|
513
885
|
}
|
|
@@ -520,7 +892,7 @@ function SatellitesLayer({ host }) {
|
|
|
520
892
|
const follow = () => {
|
|
521
893
|
arrange.current(false);
|
|
522
894
|
clearTimeout(settle);
|
|
523
|
-
settle = setTimeout(() => arrange.current(true),
|
|
895
|
+
settle = setTimeout(() => arrange.current(true), SETTLED);
|
|
524
896
|
};
|
|
525
897
|
const observer = typeof ResizeObserver === "undefined" ? void 0 : new ResizeObserver(follow);
|
|
526
898
|
observer?.observe(root);
|
|
@@ -530,18 +902,28 @@ function SatellitesLayer({ host }) {
|
|
|
530
902
|
clearTimeout(settle);
|
|
531
903
|
observer?.disconnect();
|
|
532
904
|
window.removeEventListener("resize", follow);
|
|
533
|
-
root.style.removeProperty("translate");
|
|
534
|
-
if (!SIDE_PLACEMENTS.has(host.placement)) root.style.removeProperty("--_mp-shift-x");
|
|
535
|
-
applied.current = {
|
|
536
|
-
shift: 0,
|
|
537
|
-
reserve: 0
|
|
538
|
-
};
|
|
539
905
|
};
|
|
540
906
|
}, [
|
|
541
907
|
host.rootRef,
|
|
542
|
-
|
|
908
|
+
placement,
|
|
543
909
|
!!shownActions
|
|
544
910
|
]);
|
|
911
|
+
(0, react.useEffect)(() => {
|
|
912
|
+
const root = host.rootRef.current;
|
|
913
|
+
return () => {
|
|
914
|
+
if (!root) return;
|
|
915
|
+
root.style.removeProperty("translate");
|
|
916
|
+
const { reserve } = applied.current;
|
|
917
|
+
if (reserve && root.style.getPropertyValue("--_mp-shift-x") === `${reserve}px`) root.style.removeProperty("--_mp-shift-x");
|
|
918
|
+
root.style.removeProperty(PLANNED_ROOM);
|
|
919
|
+
require_handoff.setHandoff(host.store, void 0);
|
|
920
|
+
applied.current = {
|
|
921
|
+
shift: 0,
|
|
922
|
+
reserve: 0,
|
|
923
|
+
vertical: false
|
|
924
|
+
};
|
|
925
|
+
};
|
|
926
|
+
}, [host.rootRef]);
|
|
545
927
|
const leavingIds = entries.filter((entry) => entry.leaving).map((entry) => entry.electron.id);
|
|
546
928
|
(0, react.useEffect)(() => {
|
|
547
929
|
if (leavingIds.length === 0) return;
|
|
@@ -587,7 +969,10 @@ function SatellitesLayer({ host }) {
|
|
|
587
969
|
presence,
|
|
588
970
|
"data-satellite": "electron",
|
|
589
971
|
"data-ending": leaving && ending === "pop" ? "pop" : void 0,
|
|
590
|
-
style:
|
|
972
|
+
style: host.tokens ? {
|
|
973
|
+
...host.tokens,
|
|
974
|
+
...ELECTRON_STYLE
|
|
975
|
+
} : ELECTRON_STYLE,
|
|
591
976
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ElectronBody, {
|
|
592
977
|
electron,
|
|
593
978
|
host
|
|
@@ -603,11 +988,13 @@ function SatellitesLayer({ host }) {
|
|
|
603
988
|
variant: host.variant,
|
|
604
989
|
orientation: host.vertical !== actionsAcross ? "vertical" : "horizontal",
|
|
605
990
|
presence: actionsPresence,
|
|
606
|
-
scene: shownActions.map((item) => item.id ?? item.label).join("\n"),
|
|
607
991
|
role: "group",
|
|
608
992
|
"aria-label": host.actionsLabel,
|
|
609
993
|
"data-satellite": "actions",
|
|
610
|
-
style:
|
|
994
|
+
style: host.tokens ? {
|
|
995
|
+
...host.tokens,
|
|
996
|
+
...ELECTRON_STYLE
|
|
997
|
+
} : ELECTRON_STYLE,
|
|
611
998
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Actions.ActionList, {
|
|
612
999
|
items: shownActions,
|
|
613
1000
|
host,
|
|
@@ -631,4 +1018,5 @@ function SatellitesLayer({ host }) {
|
|
|
631
1018
|
] });
|
|
632
1019
|
}
|
|
633
1020
|
|
|
634
|
-
exports.SatellitesLayer = SatellitesLayer;
|
|
1021
|
+
exports.SatellitesLayer = SatellitesLayer;
|
|
1022
|
+
exports.drop = drop;
|