magic-pill 9.4.0-next.4 → 9.4.0-next.5
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 +14 -0
- package/dist/MagicPill/MagicPill.js +1 -0
- package/dist/MagicPill/MagicPill.mjs +1 -0
- package/dist/Pill/goo.js +30 -9
- package/dist/Pill/goo.mjs +30 -9
- package/dist/PillNavbar/room.js +2 -1
- package/dist/PillNavbar/room.mjs +2 -1
- package/dist/PillNotification/RowsBody.js +1 -1
- package/dist/PillNotification/RowsBody.mjs +1 -1
- package/dist/satellites/Actions.js +89 -11
- package/dist/satellites/Actions.mjs +89 -11
- package/dist/satellites/Orbitals.js +1 -1
- package/dist/satellites/Orbitals.mjs +1 -1
- package/dist/satellites/Satellites.js +252 -151
- package/dist/satellites/Satellites.mjs +251 -151
- package/dist/satellites/types.d.mts +2 -0
- package/dist/satellites/types.d.ts +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -17,6 +17,20 @@
|
|
|
17
17
|
- The split's tokens, for a sidebar's flag: `--mp-duration-split` and `--mp-duration-join` (the enter and exit durations by default), `--mp-ease-split` (`bouncy`, the default, `pop`, `smooth` or any CSS easing), `--mp-goo` (`12`; `0` for no neck) and `--mp-electron-start` (`0.15`, a droplet)
|
|
18
18
|
|
|
19
19
|
### Fixed
|
|
20
|
+
- A notification in rows whose message just fits on one line keeps it there: its body took the message's width rounded to the pixel, a hair short, and the message wrapped into two short lines in a box as wide as the one line (a sidebar's notification)
|
|
21
|
+
- A flag's goo has less to draw at every frame: the sidebar's shape under it is cut short around the flag, instead of the sidebar's full height that the filter could still run over, clipped or not (Safari)
|
|
22
|
+
- A sidebar's flag no longer wraps its text as it comes out: out of the sidebar as a circle, its message faded in squeezed to nothing, a word a line, before the flag opened to its width
|
|
23
|
+
- From a longer list of the page's actions to a shorter one (four to two), their pill shrinks over the ones leaving, then they go. They used to vanish at once, the pill shrinking after
|
|
24
|
+
- The page's actions no longer flicker as they go from one list to another (two actions to four, and back): for a frame, they sat by their other edge, as long as the size difference
|
|
25
|
+
- The goo between pills fades with them: orbitals fading into their electron (and an upload going back into its pill) drew their necks to each other at full strength, left over for a moment once they had gone
|
|
26
|
+
- An electron's orbitals close once, from where they are: closed while still coming out (the page scrolling, the pointer leaving), they used to jump to their spots first; asked to close again while closing (the pointer moving, a tap away), they started over and sprang back out each time
|
|
27
|
+
- Beside a pill at the bottom of the screen, the satellites are held by their bottom edge, as the pill is: Safari's toolbar moving the pill (scrolling, a new page coming) moves them with it at once. They stayed where they were, under the address bar, until the next pass, then caught up
|
|
28
|
+
- The page's actions switched into the pill go into it at their size, shrinking only as the droplet, and the pill then grows to hold them, the satellites that stay out waiting and then moving once (an electron no longer changes spot twice, planned from the pill before they had opened in it). Switched out, the pill folds them away in step with its slide, its far edge staying put, and they come out of it once it has settled: it used to slide over an electron beside it, and the electron moved twice
|
|
29
|
+
- Opening a panel next to the satellites: they go beside the panel, sliding along as it opens, or, when the room they take would cut it short (on a phone), into the pill, and the panel then takes that room, centred. They used to be placed beside the navbar under the panel, and the panel covered them
|
|
30
|
+
- The satellites slide along their side whenever they move in their row (the group gathering or spreading, the pill resizing, Safari's toolbar): they used to go down to a circle or a droplet and back past a few pixels, as if they were leaving
|
|
31
|
+
- A satellite going back into the pill (an electron on its own page, the page's actions hidden) goes into it where it is: the pill and the other satellites wait, and move once it's in. The pill used to open its label and slide at once, over it, and it shrank behind the pill
|
|
32
|
+
- A satellite coming out of a pill that's still changing size (its navbar folding its label for it, on a phone) waits for the pill to settle and comes out of its edge then, with the goo: it used to come out at once under the pill still long, and grow on its own once the pill had shrunk away
|
|
33
|
+
- A navbar's label opened by the pointer or the keyboard no longer covers the satellites: the electrons and the page's actions make room as it grows and come back as it closes, the group staying centred (with `labels="auto"` they were planned from the pill with its current page's label only, and it grew over them). They also keep their gap at rest: the pill with its label open measured its end padding twice, 7 px too far on each side
|
|
20
34
|
- An electron coming out next to a navbar that folds its label for it (`labels="auto"`, on a phone) stays in the pill's row again, the label folding as the electron grows out of it: the pill used to jump shorter before the electron was there (its room capped it before the label had folded), and since the satellites plan from the pill open or folded, an electron that would fit beside the folded pill went above it instead
|
|
21
35
|
- Switching the page's actions into the pill (`actionsStyle`) no longer shows them twice: their own pill goes back into the host as when they hide, then they open in the pill. Out of it, they fold away in the pill before their own pill comes out of it, from the pill's edge (it showed at full size at once). In the pill, they open out of nothing as they come and fold away before they go, the pill following its content: it used to jump to its new length at once, and the navbar takes their room back as they fold away
|
|
22
36
|
- An electron's orbitals follow it while they're out: when it moves with the pill (on a phone, Safari's toolbar folding as the page scrolls; the group re-centring), they stayed where they had opened, apart from it, and went back in towards where it had been. They move with it at every frame, on the same arc, their opening or closing going on
|
|
@@ -260,6 +260,7 @@ const MagicPill = (0, react.forwardRef)(function MagicPill({ name = "main", chil
|
|
|
260
260
|
vertical: isVertical,
|
|
261
261
|
pathname,
|
|
262
262
|
notifying: target.kind === "notification" || displayed.scene.kind === "notification" || hasBase && !require_choreography.isOpen(displayed.presence),
|
|
263
|
+
panel: displayed.presence === "panel",
|
|
263
264
|
linkComponent,
|
|
264
265
|
variant,
|
|
265
266
|
theme: rest.theme,
|
|
@@ -260,6 +260,7 @@ const MagicPill = forwardRef(function MagicPill({ name = "main", children, scene
|
|
|
260
260
|
vertical: isVertical,
|
|
261
261
|
pathname,
|
|
262
262
|
notifying: target.kind === "notification" || displayed.scene.kind === "notification" || hasBase && !isOpen(displayed.presence),
|
|
263
|
+
panel: displayed.presence === "panel",
|
|
263
264
|
linkComponent,
|
|
264
265
|
variant,
|
|
265
266
|
theme: rest.theme,
|
package/dist/Pill/goo.js
CHANGED
|
@@ -208,14 +208,20 @@ function placeAll(overlay, pills, radii, margin) {
|
|
|
208
208
|
root.transform = `translate(${left}px, ${top}px)`;
|
|
209
209
|
root.width = `${right - left}px`;
|
|
210
210
|
root.height = `${bottom - top}px`;
|
|
211
|
-
const put = (shape, rect, element, radius) => {
|
|
211
|
+
const put = (shape, rect, element, radius, cut = false) => {
|
|
212
212
|
const scale = element.offsetWidth > 0 ? rect.width / element.offsetWidth : 1;
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
213
|
+
const corner = Math.min(radius * scale, rect.width / 2, rect.height / 2);
|
|
214
|
+
const spare = cut ? margin + corner : Number.POSITIVE_INFINITY;
|
|
215
|
+
const x = Math.max(rect.left, left - spare);
|
|
216
|
+
const y = Math.max(rect.top, top - spare);
|
|
217
|
+
const width = Math.max(0, Math.min(rect.right, right + spare) - x);
|
|
218
|
+
const height = Math.max(0, Math.min(rect.bottom, bottom + spare) - y);
|
|
219
|
+
shape.style.width = `${width}px`;
|
|
220
|
+
shape.style.height = `${height}px`;
|
|
221
|
+
shape.style.transform = `translate(${x - left}px, ${y - top}px)`;
|
|
222
|
+
shape.style.borderRadius = `${corner}px`;
|
|
217
223
|
};
|
|
218
|
-
put(overlay.anchor, a, pills.anchor, radii.anchor);
|
|
224
|
+
put(overlay.anchor, a, pills.anchor, radii.anchor, true);
|
|
219
225
|
put(overlay.moving, m, pills.moving, radii.moving);
|
|
220
226
|
}
|
|
221
227
|
const OWN_LOOK = {
|
|
@@ -334,7 +340,11 @@ function playSplit(anchor, moving, kind, timing) {
|
|
|
334
340
|
easing: POP
|
|
335
341
|
});
|
|
336
342
|
}
|
|
337
|
-
const
|
|
343
|
+
const circle = kind === "split" && ["rest", "hidden"].includes(moving.dataset.presence ?? "");
|
|
344
|
+
const content = [...moving.children].filter((child) => {
|
|
345
|
+
const part = child.getAttribute("data-mp") ?? "";
|
|
346
|
+
return !["panel", "outgoing"].includes(part) && (!circle || part === "icon");
|
|
347
|
+
});
|
|
338
348
|
const total = timing.duration + fade;
|
|
339
349
|
for (const child of content) if (kind === "split") child.animate([
|
|
340
350
|
{ opacity: 0 },
|
|
@@ -434,6 +444,16 @@ const budding = /* @__PURE__ */ new WeakMap();
|
|
|
434
444
|
* electron out of its host or out of the one next to it, the page's actions.
|
|
435
445
|
*/
|
|
436
446
|
function playOrbit(electron, items, kind, timing) {
|
|
447
|
+
const drawn = /* @__PURE__ */ new Map();
|
|
448
|
+
for (const { element } of items) {
|
|
449
|
+
if (kind !== "close" || !(element.getAnimations?.() ?? []).some((animation) => animation.id === "mp-split" && animation.playState === "running")) continue;
|
|
450
|
+
const now = getComputedStyle(element);
|
|
451
|
+
drawn.set(element, {
|
|
452
|
+
translate: !now.translate || now.translate === "none" ? "0px 0px" : now.translate,
|
|
453
|
+
scale: !now.scale || now.scale === "none" ? "1" : now.scale,
|
|
454
|
+
opacity: Number.parseFloat(now.opacity) || 0
|
|
455
|
+
});
|
|
456
|
+
}
|
|
437
457
|
for (const { element } of items) {
|
|
438
458
|
budding.get(element)?.();
|
|
439
459
|
for (const animation of element.getAnimations?.({ subtree: true }) ?? []) if (animation.id === "mp-split") animation.cancel();
|
|
@@ -469,7 +489,7 @@ function playOrbit(electron, items, kind, timing) {
|
|
|
469
489
|
scale: String(start.scale),
|
|
470
490
|
opacity: opaque ? shown : 0
|
|
471
491
|
};
|
|
472
|
-
const out = {
|
|
492
|
+
const out = drawn.get(element) ?? {
|
|
473
493
|
translate: "0px 0px",
|
|
474
494
|
scale: end === "none" ? "1" : end,
|
|
475
495
|
opacity: shown
|
|
@@ -493,7 +513,7 @@ function playOrbit(electron, items, kind, timing) {
|
|
|
493
513
|
id: SPLIT,
|
|
494
514
|
duration: timing.duration,
|
|
495
515
|
delay,
|
|
496
|
-
fill: kind === "open" ? "backwards" : "
|
|
516
|
+
fill: kind === "open" ? "backwards" : "both"
|
|
497
517
|
};
|
|
498
518
|
const ends = (kind === "open" ? [inside, out] : [out, inside]).map(({ translate, scale }) => ({
|
|
499
519
|
translate,
|
|
@@ -628,6 +648,7 @@ function playNecks(pills, duration) {
|
|
|
628
648
|
shape.height = `${rect.height}px`;
|
|
629
649
|
shape.transform = `translate(${rect.left - left}px, ${rect.top - top}px)`;
|
|
630
650
|
shape.borderRadius = `${Math.min(radii[index] * scale, rect.width / 2, rect.height / 2)}px`;
|
|
651
|
+
shape.opacity = getComputedStyle(pills[index]).opacity;
|
|
631
652
|
});
|
|
632
653
|
blur.setAttribute("stdDeviation", (goo * gooAmount(Math.min(1, elapsed / longest))).toFixed(2));
|
|
633
654
|
if (elapsed >= longest) return stop();
|
package/dist/Pill/goo.mjs
CHANGED
|
@@ -208,14 +208,20 @@ function placeAll(overlay, pills, radii, margin) {
|
|
|
208
208
|
root.transform = `translate(${left}px, ${top}px)`;
|
|
209
209
|
root.width = `${right - left}px`;
|
|
210
210
|
root.height = `${bottom - top}px`;
|
|
211
|
-
const put = (shape, rect, element, radius) => {
|
|
211
|
+
const put = (shape, rect, element, radius, cut = false) => {
|
|
212
212
|
const scale = element.offsetWidth > 0 ? rect.width / element.offsetWidth : 1;
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
213
|
+
const corner = Math.min(radius * scale, rect.width / 2, rect.height / 2);
|
|
214
|
+
const spare = cut ? margin + corner : Number.POSITIVE_INFINITY;
|
|
215
|
+
const x = Math.max(rect.left, left - spare);
|
|
216
|
+
const y = Math.max(rect.top, top - spare);
|
|
217
|
+
const width = Math.max(0, Math.min(rect.right, right + spare) - x);
|
|
218
|
+
const height = Math.max(0, Math.min(rect.bottom, bottom + spare) - y);
|
|
219
|
+
shape.style.width = `${width}px`;
|
|
220
|
+
shape.style.height = `${height}px`;
|
|
221
|
+
shape.style.transform = `translate(${x - left}px, ${y - top}px)`;
|
|
222
|
+
shape.style.borderRadius = `${corner}px`;
|
|
217
223
|
};
|
|
218
|
-
put(overlay.anchor, a, pills.anchor, radii.anchor);
|
|
224
|
+
put(overlay.anchor, a, pills.anchor, radii.anchor, true);
|
|
219
225
|
put(overlay.moving, m, pills.moving, radii.moving);
|
|
220
226
|
}
|
|
221
227
|
const OWN_LOOK = {
|
|
@@ -334,7 +340,11 @@ function playSplit(anchor, moving, kind, timing) {
|
|
|
334
340
|
easing: POP
|
|
335
341
|
});
|
|
336
342
|
}
|
|
337
|
-
const
|
|
343
|
+
const circle = kind === "split" && ["rest", "hidden"].includes(moving.dataset.presence ?? "");
|
|
344
|
+
const content = [...moving.children].filter((child) => {
|
|
345
|
+
const part = child.getAttribute("data-mp") ?? "";
|
|
346
|
+
return !["panel", "outgoing"].includes(part) && (!circle || part === "icon");
|
|
347
|
+
});
|
|
338
348
|
const total = timing.duration + fade;
|
|
339
349
|
for (const child of content) if (kind === "split") child.animate([
|
|
340
350
|
{ opacity: 0 },
|
|
@@ -434,6 +444,16 @@ const budding = /* @__PURE__ */ new WeakMap();
|
|
|
434
444
|
* electron out of its host or out of the one next to it, the page's actions.
|
|
435
445
|
*/
|
|
436
446
|
function playOrbit(electron, items, kind, timing) {
|
|
447
|
+
const drawn = /* @__PURE__ */ new Map();
|
|
448
|
+
for (const { element } of items) {
|
|
449
|
+
if (kind !== "close" || !(element.getAnimations?.() ?? []).some((animation) => animation.id === "mp-split" && animation.playState === "running")) continue;
|
|
450
|
+
const now = getComputedStyle(element);
|
|
451
|
+
drawn.set(element, {
|
|
452
|
+
translate: !now.translate || now.translate === "none" ? "0px 0px" : now.translate,
|
|
453
|
+
scale: !now.scale || now.scale === "none" ? "1" : now.scale,
|
|
454
|
+
opacity: Number.parseFloat(now.opacity) || 0
|
|
455
|
+
});
|
|
456
|
+
}
|
|
437
457
|
for (const { element } of items) {
|
|
438
458
|
budding.get(element)?.();
|
|
439
459
|
for (const animation of element.getAnimations?.({ subtree: true }) ?? []) if (animation.id === "mp-split") animation.cancel();
|
|
@@ -469,7 +489,7 @@ function playOrbit(electron, items, kind, timing) {
|
|
|
469
489
|
scale: String(start.scale),
|
|
470
490
|
opacity: opaque ? shown : 0
|
|
471
491
|
};
|
|
472
|
-
const out = {
|
|
492
|
+
const out = drawn.get(element) ?? {
|
|
473
493
|
translate: "0px 0px",
|
|
474
494
|
scale: end === "none" ? "1" : end,
|
|
475
495
|
opacity: shown
|
|
@@ -493,7 +513,7 @@ function playOrbit(electron, items, kind, timing) {
|
|
|
493
513
|
id: SPLIT,
|
|
494
514
|
duration: timing.duration,
|
|
495
515
|
delay,
|
|
496
|
-
fill: kind === "open" ? "backwards" : "
|
|
516
|
+
fill: kind === "open" ? "backwards" : "both"
|
|
497
517
|
};
|
|
498
518
|
const ends = (kind === "open" ? [inside, out] : [out, inside]).map(({ translate, scale }) => ({
|
|
499
519
|
translate,
|
|
@@ -628,6 +648,7 @@ function playNecks(pills, duration) {
|
|
|
628
648
|
shape.height = `${rect.height}px`;
|
|
629
649
|
shape.transform = `translate(${rect.left - left}px, ${rect.top - top}px)`;
|
|
630
650
|
shape.borderRadius = `${Math.min(radii[index] * scale, rect.width / 2, rect.height / 2)}px`;
|
|
651
|
+
shape.opacity = getComputedStyle(pills[index]).opacity;
|
|
631
652
|
});
|
|
632
653
|
blur.setAttribute("stdDeviation", (goo * gooAmount(Math.min(1, elapsed / longest))).toFixed(2));
|
|
633
654
|
if (elapsed >= longest) return stop();
|
package/dist/PillNavbar/room.js
CHANGED
|
@@ -81,7 +81,8 @@ function unfoldedWidth(pill) {
|
|
|
81
81
|
if (!navbar || navbar.dataset.labels !== "auto") return void 0;
|
|
82
82
|
const { copy } = layOutCopy(pill, (copied) => copied.removeAttribute("data-folded"), true);
|
|
83
83
|
const style = getComputedStyle(copy);
|
|
84
|
-
const
|
|
84
|
+
const overflows = copy.scrollWidth > copy.clientWidth + .5;
|
|
85
|
+
const width = Math.max(copy.offsetWidth, overflows ? copy.scrollWidth + (Number.parseFloat(style.paddingRight) || 0) : 0);
|
|
85
86
|
copy.remove();
|
|
86
87
|
return width;
|
|
87
88
|
}
|
package/dist/PillNavbar/room.mjs
CHANGED
|
@@ -81,7 +81,8 @@ function unfoldedWidth(pill) {
|
|
|
81
81
|
if (!navbar || navbar.dataset.labels !== "auto") return void 0;
|
|
82
82
|
const { copy } = layOutCopy(pill, (copied) => copied.removeAttribute("data-folded"), true);
|
|
83
83
|
const style = getComputedStyle(copy);
|
|
84
|
-
const
|
|
84
|
+
const overflows = copy.scrollWidth > copy.clientWidth + .5;
|
|
85
|
+
const width = Math.max(copy.offsetWidth, overflows ? copy.scrollWidth + (Number.parseFloat(style.paddingRight) || 0) : 0);
|
|
85
86
|
copy.remove();
|
|
86
87
|
return width;
|
|
87
88
|
}
|
|
@@ -41,7 +41,7 @@ function measure(body) {
|
|
|
41
41
|
const parts = [...actions.children].map((child) => child.getBoundingClientRect());
|
|
42
42
|
if (parts.length > 0) {
|
|
43
43
|
const content = Math.max(...parts.map((part) => part.right)) - Math.min(...parts.map((part) => part.left));
|
|
44
|
-
result.body = Math.ceil(Math.max(message.
|
|
44
|
+
result.body = Math.ceil(Math.max(message.getBoundingClientRect().width, content - under));
|
|
45
45
|
}
|
|
46
46
|
return result;
|
|
47
47
|
}, open);
|
|
@@ -41,7 +41,7 @@ function measure(body) {
|
|
|
41
41
|
const parts = [...actions.children].map((child) => child.getBoundingClientRect());
|
|
42
42
|
if (parts.length > 0) {
|
|
43
43
|
const content = Math.max(...parts.map((part) => part.right)) - Math.min(...parts.map((part) => part.left));
|
|
44
|
-
result.body = Math.ceil(Math.max(message.
|
|
44
|
+
result.body = Math.ceil(Math.max(message.getBoundingClientRect().width, content - under));
|
|
45
45
|
}
|
|
46
46
|
return result;
|
|
47
47
|
}, open);
|
|
@@ -146,27 +146,105 @@ function useActionsWheel(track) {
|
|
|
146
146
|
function ActionList({ items, host, wheel, inside, leaving }) {
|
|
147
147
|
const track = (0, react.useRef)(null);
|
|
148
148
|
useActionsWheel(track);
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
149
|
+
const gone = useGoneActions(items, track, wheel === void 0 && !inside);
|
|
150
|
+
const draw = (item, spot) => {
|
|
151
|
+
const key = keyOf(item);
|
|
152
|
+
const leavingProps = spot ? {
|
|
153
|
+
"data-action-leaving": "",
|
|
154
|
+
"aria-hidden": true,
|
|
155
|
+
tabIndex: -1,
|
|
156
|
+
style: {
|
|
157
|
+
position: "absolute",
|
|
158
|
+
left: spot.left,
|
|
159
|
+
top: spot.top,
|
|
160
|
+
margin: 0,
|
|
161
|
+
pointerEvents: "none"
|
|
162
|
+
}
|
|
163
|
+
} : {};
|
|
164
|
+
return item.href !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PillAction, {
|
|
156
165
|
icon: item.icon,
|
|
157
166
|
label: item.label,
|
|
158
167
|
expanded: item.expanded,
|
|
159
168
|
href: item.href,
|
|
160
169
|
linkComponent: host.linkComponent,
|
|
161
|
-
onClick: item.onClick
|
|
162
|
-
|
|
170
|
+
onClick: item.onClick,
|
|
171
|
+
...leavingProps
|
|
172
|
+
}, key) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PillAction, {
|
|
163
173
|
icon: item.icon,
|
|
164
174
|
label: item.label,
|
|
165
175
|
expanded: item.expanded,
|
|
166
|
-
onClick: item.onClick
|
|
167
|
-
|
|
176
|
+
onClick: item.onClick,
|
|
177
|
+
...leavingProps
|
|
178
|
+
}, key);
|
|
179
|
+
};
|
|
180
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_parts.PillActions, {
|
|
181
|
+
ref: track,
|
|
182
|
+
"data-inside": inside ? "" : void 0,
|
|
183
|
+
"data-leaving": leaving ? "" : void 0,
|
|
184
|
+
"data-wheel": wheel !== void 0 ? "" : void 0,
|
|
185
|
+
style: wheel !== void 0 ? { "--_mp-wheel-length": `${wheel}px` } : void 0,
|
|
186
|
+
children: [items.map((item) => draw(item)), gone.map(({ item, spot }) => draw(item, spot))]
|
|
168
187
|
});
|
|
169
188
|
}
|
|
189
|
+
const keyOf = (item) => item.id ?? item.label;
|
|
190
|
+
/**
|
|
191
|
+
* The actions gone from the list, for a moment: the pill shrinks to the new list over them (it clips
|
|
192
|
+
* them), then they go, fading as it ends. They used to vanish at once, the pill shrinking after.
|
|
193
|
+
* Only for the pill of actions, not cut short by a wheel (`keep`): a wheel's row scrolls.
|
|
194
|
+
*/
|
|
195
|
+
function useGoneActions(items, track, keep) {
|
|
196
|
+
const spots = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
197
|
+
const [shown, setShown] = (0, react.useState)(items);
|
|
198
|
+
const [gone, setGone] = (0, react.useState)([]);
|
|
199
|
+
if (items !== shown) {
|
|
200
|
+
const now = new Set(items.map(keyOf));
|
|
201
|
+
const leaving = keep ? shown.filter((item) => !now.has(keyOf(item)) && spots.current.has(keyOf(item))).map((item) => ({
|
|
202
|
+
item,
|
|
203
|
+
spot: spots.current.get(keyOf(item))
|
|
204
|
+
})) : [];
|
|
205
|
+
setShown(items);
|
|
206
|
+
if (leaving.length > 0 || gone.length > 0) setGone([...gone.filter(({ item }) => !now.has(keyOf(item)) && !leaving.some((one) => keyOf(one.item) === keyOf(item))), ...leaving]);
|
|
207
|
+
}
|
|
208
|
+
require_react.useIsomorphicLayoutEffect(() => {
|
|
209
|
+
const row = track.current;
|
|
210
|
+
if (!row) return;
|
|
211
|
+
const drawn = [...row.children].filter((child) => !child.hasAttribute("data-action-leaving"));
|
|
212
|
+
spots.current = new Map(items.flatMap((item, index) => drawn[index] ? [[keyOf(item), {
|
|
213
|
+
left: drawn[index].offsetLeft,
|
|
214
|
+
top: drawn[index].offsetTop
|
|
215
|
+
}]] : []));
|
|
216
|
+
});
|
|
217
|
+
const goneKeys = gone.map(({ item }) => keyOf(item)).join("\n");
|
|
218
|
+
(0, react.useEffect)(() => {
|
|
219
|
+
const row = track.current;
|
|
220
|
+
if (!row || gone.length === 0) return;
|
|
221
|
+
const leaving = [...row.querySelectorAll(":scope > [data-action-leaving]")];
|
|
222
|
+
const pill = row.closest("[data-mp=\"pill\"]") ?? row;
|
|
223
|
+
const { change } = require_morph.readMorphTimings(pill);
|
|
224
|
+
if (require_timing.prefersReducedMotion() || change <= 0 || leaving.some((element) => typeof element.animate !== "function")) {
|
|
225
|
+
setGone([]);
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
const fades = leaving.map((element) => element.animate([
|
|
229
|
+
{ opacity: 1 },
|
|
230
|
+
{
|
|
231
|
+
opacity: 1,
|
|
232
|
+
offset: .6
|
|
233
|
+
},
|
|
234
|
+
{ opacity: 0 }
|
|
235
|
+
], {
|
|
236
|
+
duration: change,
|
|
237
|
+
easing: "linear",
|
|
238
|
+
fill: "forwards"
|
|
239
|
+
}));
|
|
240
|
+
const timer = setTimeout(() => setGone([]), change);
|
|
241
|
+
return () => {
|
|
242
|
+
clearTimeout(timer);
|
|
243
|
+
fades.forEach((fade) => fade.cancel());
|
|
244
|
+
};
|
|
245
|
+
}, [goneKeys]);
|
|
246
|
+
return gone;
|
|
247
|
+
}
|
|
170
248
|
/** The actions in the pill opening or folding away (playInside), or held closed until they open */
|
|
171
249
|
const INSIDE = "mp-inside-actions";
|
|
172
250
|
/** Their row and its divider with nothing of them left: no length, no gap on either side of the divider */
|
|
@@ -146,27 +146,105 @@ function useActionsWheel(track) {
|
|
|
146
146
|
function ActionList({ items, host, wheel, inside, leaving }) {
|
|
147
147
|
const track = useRef(null);
|
|
148
148
|
useActionsWheel(track);
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
149
|
+
const gone = useGoneActions(items, track, wheel === void 0 && !inside);
|
|
150
|
+
const draw = (item, spot) => {
|
|
151
|
+
const key = keyOf(item);
|
|
152
|
+
const leavingProps = spot ? {
|
|
153
|
+
"data-action-leaving": "",
|
|
154
|
+
"aria-hidden": true,
|
|
155
|
+
tabIndex: -1,
|
|
156
|
+
style: {
|
|
157
|
+
position: "absolute",
|
|
158
|
+
left: spot.left,
|
|
159
|
+
top: spot.top,
|
|
160
|
+
margin: 0,
|
|
161
|
+
pointerEvents: "none"
|
|
162
|
+
}
|
|
163
|
+
} : {};
|
|
164
|
+
return item.href !== void 0 ? /* @__PURE__ */ jsx(PillAction, {
|
|
156
165
|
icon: item.icon,
|
|
157
166
|
label: item.label,
|
|
158
167
|
expanded: item.expanded,
|
|
159
168
|
href: item.href,
|
|
160
169
|
linkComponent: host.linkComponent,
|
|
161
|
-
onClick: item.onClick
|
|
162
|
-
|
|
170
|
+
onClick: item.onClick,
|
|
171
|
+
...leavingProps
|
|
172
|
+
}, key) : /* @__PURE__ */ jsx(PillAction, {
|
|
163
173
|
icon: item.icon,
|
|
164
174
|
label: item.label,
|
|
165
175
|
expanded: item.expanded,
|
|
166
|
-
onClick: item.onClick
|
|
167
|
-
|
|
176
|
+
onClick: item.onClick,
|
|
177
|
+
...leavingProps
|
|
178
|
+
}, key);
|
|
179
|
+
};
|
|
180
|
+
return /* @__PURE__ */ jsxs(PillActions, {
|
|
181
|
+
ref: track,
|
|
182
|
+
"data-inside": inside ? "" : void 0,
|
|
183
|
+
"data-leaving": leaving ? "" : void 0,
|
|
184
|
+
"data-wheel": wheel !== void 0 ? "" : void 0,
|
|
185
|
+
style: wheel !== void 0 ? { "--_mp-wheel-length": `${wheel}px` } : void 0,
|
|
186
|
+
children: [items.map((item) => draw(item)), gone.map(({ item, spot }) => draw(item, spot))]
|
|
168
187
|
});
|
|
169
188
|
}
|
|
189
|
+
const keyOf = (item) => item.id ?? item.label;
|
|
190
|
+
/**
|
|
191
|
+
* The actions gone from the list, for a moment: the pill shrinks to the new list over them (it clips
|
|
192
|
+
* them), then they go, fading as it ends. They used to vanish at once, the pill shrinking after.
|
|
193
|
+
* Only for the pill of actions, not cut short by a wheel (`keep`): a wheel's row scrolls.
|
|
194
|
+
*/
|
|
195
|
+
function useGoneActions(items, track, keep) {
|
|
196
|
+
const spots = useRef(/* @__PURE__ */ new Map());
|
|
197
|
+
const [shown, setShown] = useState(items);
|
|
198
|
+
const [gone, setGone] = useState([]);
|
|
199
|
+
if (items !== shown) {
|
|
200
|
+
const now = new Set(items.map(keyOf));
|
|
201
|
+
const leaving = keep ? shown.filter((item) => !now.has(keyOf(item)) && spots.current.has(keyOf(item))).map((item) => ({
|
|
202
|
+
item,
|
|
203
|
+
spot: spots.current.get(keyOf(item))
|
|
204
|
+
})) : [];
|
|
205
|
+
setShown(items);
|
|
206
|
+
if (leaving.length > 0 || gone.length > 0) setGone([...gone.filter(({ item }) => !now.has(keyOf(item)) && !leaving.some((one) => keyOf(one.item) === keyOf(item))), ...leaving]);
|
|
207
|
+
}
|
|
208
|
+
useIsomorphicLayoutEffect(() => {
|
|
209
|
+
const row = track.current;
|
|
210
|
+
if (!row) return;
|
|
211
|
+
const drawn = [...row.children].filter((child) => !child.hasAttribute("data-action-leaving"));
|
|
212
|
+
spots.current = new Map(items.flatMap((item, index) => drawn[index] ? [[keyOf(item), {
|
|
213
|
+
left: drawn[index].offsetLeft,
|
|
214
|
+
top: drawn[index].offsetTop
|
|
215
|
+
}]] : []));
|
|
216
|
+
});
|
|
217
|
+
const goneKeys = gone.map(({ item }) => keyOf(item)).join("\n");
|
|
218
|
+
useEffect(() => {
|
|
219
|
+
const row = track.current;
|
|
220
|
+
if (!row || gone.length === 0) return;
|
|
221
|
+
const leaving = [...row.querySelectorAll(":scope > [data-action-leaving]")];
|
|
222
|
+
const pill = row.closest("[data-mp=\"pill\"]") ?? row;
|
|
223
|
+
const { change } = readMorphTimings(pill);
|
|
224
|
+
if (prefersReducedMotion() || change <= 0 || leaving.some((element) => typeof element.animate !== "function")) {
|
|
225
|
+
setGone([]);
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
const fades = leaving.map((element) => element.animate([
|
|
229
|
+
{ opacity: 1 },
|
|
230
|
+
{
|
|
231
|
+
opacity: 1,
|
|
232
|
+
offset: .6
|
|
233
|
+
},
|
|
234
|
+
{ opacity: 0 }
|
|
235
|
+
], {
|
|
236
|
+
duration: change,
|
|
237
|
+
easing: "linear",
|
|
238
|
+
fill: "forwards"
|
|
239
|
+
}));
|
|
240
|
+
const timer = setTimeout(() => setGone([]), change);
|
|
241
|
+
return () => {
|
|
242
|
+
clearTimeout(timer);
|
|
243
|
+
fades.forEach((fade) => fade.cancel());
|
|
244
|
+
};
|
|
245
|
+
}, [goneKeys]);
|
|
246
|
+
return gone;
|
|
247
|
+
}
|
|
170
248
|
/** The actions in the pill opening or folding away (playInside), or held closed until they open */
|
|
171
249
|
const INSIDE = "mp-inside-actions";
|
|
172
250
|
/** Their row and its divider with nothing of them left: no length, no gap on either side of the divider */
|
|
@@ -284,7 +284,7 @@ function Orbitals({ electron, getElement, host, out }) {
|
|
|
284
284
|
setShown(items.map(() => true));
|
|
285
285
|
};
|
|
286
286
|
const close = (quick = false) => {
|
|
287
|
-
if (!ring) return;
|
|
287
|
+
if (!ring || closing.current) return;
|
|
288
288
|
clearTimers();
|
|
289
289
|
setHot(-1);
|
|
290
290
|
closing.current = true;
|
|
@@ -284,7 +284,7 @@ function Orbitals({ electron, getElement, host, out }) {
|
|
|
284
284
|
setShown(items.map(() => true));
|
|
285
285
|
};
|
|
286
286
|
const close = (quick = false) => {
|
|
287
|
-
if (!ring) return;
|
|
287
|
+
if (!ring || closing.current) return;
|
|
288
288
|
clearTimers();
|
|
289
289
|
setHot(-1);
|
|
290
290
|
closing.current = true;
|