magic-pill 9.4.0-next.5 → 9.4.0-rc.2
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 +20 -2
- package/dist/MagicPill/MagicPill.mjs +21 -3
- package/dist/Pill/PillPanel.js +8 -4
- package/dist/Pill/PillPanel.mjs +9 -5
- package/dist/Pill/goo.js +26 -17
- package/dist/Pill/goo.mjs +26 -17
- package/dist/PillForm/PillSubmit.js +2 -1
- package/dist/PillForm/PillSubmit.mjs +2 -1
- package/dist/PillForm/room.js +1 -0
- package/dist/PillForm/room.mjs +1 -0
- package/dist/forms.css +16 -2
- package/dist/satellites/Actions.js +66 -3
- package/dist/satellites/Actions.mjs +66 -3
- package/dist/satellites/Satellites.js +85 -40
- package/dist/satellites/Satellites.mjs +78 -33
- package/dist/satellites/circle.js +165 -0
- package/dist/satellites/circle.mjs +161 -0
- package/dist/satellites/measure.js +33 -0
- package/dist/satellites/measure.mjs +32 -1
- package/dist/satellites/types.d.mts +5 -0
- package/dist/satellites/types.d.ts +5 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -75,6 +75,20 @@
|
|
|
75
75
|
- A navbar's current label no longer folds while the pill is a circle on its way to another placement: the pill opened at its new place with the label folded, and grew by it with a jump once open
|
|
76
76
|
- An electron (or the page's actions) going back into the pill as the group gathers again goes to the pill's end where it now is, instead of where it was when it set off: it ended inside the pill, over its last item, with a doubled shadow at its end
|
|
77
77
|
- With electrons or actions out, a pill changing placement goes there through the circle in one movement, from and to any placement: it used to jump across the screen as it closed (to or from the top and bottom, the start and end placements, between the bottom and a side), laid out for its new placement while still at its old one. Next to another pill of the same side, it no longer flashes aside as it sets off
|
|
78
|
+
- A satellite going into the pill (or coming out of it) does so inside the pill: the page's actions standing upright beside it went in level with their own middle, above the pill, by the electron, and came out there too
|
|
79
|
+
- **Beta:** leaving a page, its actions go into the pill at once, with the electrons, at their size until they're in: they stood still while an electron went in, turned into a circle in one frame, and only then went in
|
|
80
|
+
- **Beta:** a satellite told to go back in while it's still coming out goes in from where it's drawn: the page's actions, switched into the pill as they came out, went in as a dot off to the side of the pill, showing where they had waited
|
|
81
|
+
- **Beta:** the page's actions opening in the pill: the pill re-centres in step with them, so its far end (and an electron beside it) moves once, by the difference. Its slide ran ahead of its growth: its far end went 25 px in, then back
|
|
82
|
+
- **Beta:** the page's actions in the pill resize their row for another list (two, then four), the pill and the satellites following, and a shorter list shrinks over the ones leaving before they go, as their own pill does: it changed in one frame
|
|
83
|
+
- **Beta:** the page's actions going to the other side of the pill with another list go into the pill at the size they had, and come out on the other side at their new size: they took the new size at once where they were, over the pill
|
|
84
|
+
- **Beta:** the page's actions turning from a column to a row slide to their spot from the circle they closed to: once a circle, they went back up to the column's top and slid down again
|
|
85
|
+
- **Beta:** a panel opening with no room for the electrons beside it waits for them to go into the pill, then opens to its full length in one motion: it opened part way as they went in, then widened again once they were in
|
|
86
|
+
- A panel closing gives the focus back to its trigger before the pill measures the size it closes to, so it closes in one motion with the label the focus opens: it closed without it, then grew again as the label opened (an electron beside it went in, then out again)
|
|
87
|
+
- A form in the pill itself, short of room, gives its submit button's live label ("Adding you…") the room while it's sent, and the field takes it back once it's done or refused, in one resize each way: the label was folded and cut, then squeezed as it opened
|
|
88
|
+
- **Beta:** a panel opening while the electrons go into the pill for it (no room for them beside it) waits for them with the pill as it was, then opens as it always does: it showed its panel in the small pill while they went in
|
|
89
|
+
- **Beta:** the page's actions in a row of their own above or below the pill (`actionsSide="beside"`) resize for another list from the end lined up with the pill: their new size jumped in at once
|
|
90
|
+
- **Beta:** the page's actions in the pill, cut short by their wheel, no longer grow for a moment the first time another list comes: their row resized from the length it had before the wheel cut it, then shrank back
|
|
91
|
+
- **Beta:** the page's actions switched into the pill, left behind by a page change, or going in for a panel that has no room for them beside it, close to a circle where they stand, then go in as one (the pill waits for them before it takes the next page's shape, and the panel before it opens); switched out, or back on their page, they come out as a circle and open to their pill, then their content shows. The circle is at the pill's level: a column of actions beside a bottom pill closes down to it and goes in from there. They went in as a small pill, at their own proportions
|
|
78
92
|
|
|
79
93
|
### Changed
|
|
80
94
|
- **Beta:** `actionsWheel` is on by default for the page's actions in the pill (`actionsStyle="inside"`): short of room, they show what fits next to the navbar and turn the rest in their wheel; `false` shows them all. Still off by default for a pill of their own
|
|
@@ -252,6 +252,23 @@ const MagicPill = (0, react.forwardRef)(function MagicPill({ name = "main", chil
|
|
|
252
252
|
presence: next
|
|
253
253
|
});
|
|
254
254
|
};
|
|
255
|
+
const wantsPanel = displayed.presence === "panel";
|
|
256
|
+
const [panelGate, setPanelGate] = (0, react.useState)(wantsPanel ? "open" : "closed");
|
|
257
|
+
if (satellites && wantsPanel && panelGate === "closed") setPanelGate("pending");
|
|
258
|
+
if (!wantsPanel && panelGate !== "closed") setPanelGate("closed");
|
|
259
|
+
const satellitesHoldPanel = (0, react.useRef)(false);
|
|
260
|
+
const holdPanel = (0, react.useCallback)((hold) => {
|
|
261
|
+
satellitesHoldPanel.current = hold;
|
|
262
|
+
if (!hold) setPanelGate((gate) => gate === "closed" ? gate : "open");
|
|
263
|
+
}, []);
|
|
264
|
+
require_react.useIsomorphicLayoutEffect(() => {
|
|
265
|
+
if (panelGate === "pending") setPanelGate(satellitesHoldPanel.current ? "waiting" : "open");
|
|
266
|
+
}, [panelGate]);
|
|
267
|
+
const shownBeforePanel = (0, react.useRef)(displayed.presence === "panel" ? "compact" : displayed.presence);
|
|
268
|
+
const pillPresence = satellites && wantsPanel && panelGate !== "open" ? shownBeforePanel.current : displayed.presence;
|
|
269
|
+
require_react.useIsomorphicLayoutEffect(() => {
|
|
270
|
+
if (pillPresence !== "panel") shownBeforePanel.current = pillPresence;
|
|
271
|
+
}, [pillPresence]);
|
|
255
272
|
const satelliteHost = satellites ? {
|
|
256
273
|
name,
|
|
257
274
|
store,
|
|
@@ -260,7 +277,8 @@ const MagicPill = (0, react.forwardRef)(function MagicPill({ name = "main", chil
|
|
|
260
277
|
vertical: isVertical,
|
|
261
278
|
pathname,
|
|
262
279
|
notifying: target.kind === "notification" || displayed.scene.kind === "notification" || hasBase && !require_choreography.isOpen(displayed.presence),
|
|
263
|
-
panel:
|
|
280
|
+
panel: wantsPanel,
|
|
281
|
+
holdPanel,
|
|
264
282
|
linkComponent,
|
|
265
283
|
variant,
|
|
266
284
|
theme: rest.theme,
|
|
@@ -330,7 +348,7 @@ const MagicPill = (0, react.forwardRef)(function MagicPill({ name = "main", chil
|
|
|
330
348
|
"--_mp-sidebar-width": `${sidebarWidth.current}px`
|
|
331
349
|
} : rest.style,
|
|
332
350
|
variant: sceneVariant,
|
|
333
|
-
presence:
|
|
351
|
+
presence: pillPresence,
|
|
334
352
|
onPresenceChange: presenceHandler(displayedRef, setDisplayed),
|
|
335
353
|
onPointerEnter: (event) => {
|
|
336
354
|
onPointerEnter?.(event);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { Fragment, forwardRef, useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { Fragment, forwardRef, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
4
4
|
import Pill from "../Pill/Pill.mjs";
|
|
5
5
|
import { PillIcon } from "../Pill/parts.mjs";
|
|
6
6
|
import { NotificationContent } from "../PillNotification/PillNotification.mjs";
|
|
@@ -252,6 +252,23 @@ const MagicPill = forwardRef(function MagicPill({ name = "main", children, scene
|
|
|
252
252
|
presence: next
|
|
253
253
|
});
|
|
254
254
|
};
|
|
255
|
+
const wantsPanel = displayed.presence === "panel";
|
|
256
|
+
const [panelGate, setPanelGate] = useState(wantsPanel ? "open" : "closed");
|
|
257
|
+
if (satellites && wantsPanel && panelGate === "closed") setPanelGate("pending");
|
|
258
|
+
if (!wantsPanel && panelGate !== "closed") setPanelGate("closed");
|
|
259
|
+
const satellitesHoldPanel = useRef(false);
|
|
260
|
+
const holdPanel = useCallback((hold) => {
|
|
261
|
+
satellitesHoldPanel.current = hold;
|
|
262
|
+
if (!hold) setPanelGate((gate) => gate === "closed" ? gate : "open");
|
|
263
|
+
}, []);
|
|
264
|
+
useIsomorphicLayoutEffect(() => {
|
|
265
|
+
if (panelGate === "pending") setPanelGate(satellitesHoldPanel.current ? "waiting" : "open");
|
|
266
|
+
}, [panelGate]);
|
|
267
|
+
const shownBeforePanel = useRef(displayed.presence === "panel" ? "compact" : displayed.presence);
|
|
268
|
+
const pillPresence = satellites && wantsPanel && panelGate !== "open" ? shownBeforePanel.current : displayed.presence;
|
|
269
|
+
useIsomorphicLayoutEffect(() => {
|
|
270
|
+
if (pillPresence !== "panel") shownBeforePanel.current = pillPresence;
|
|
271
|
+
}, [pillPresence]);
|
|
255
272
|
const satelliteHost = satellites ? {
|
|
256
273
|
name,
|
|
257
274
|
store,
|
|
@@ -260,7 +277,8 @@ const MagicPill = forwardRef(function MagicPill({ name = "main", children, scene
|
|
|
260
277
|
vertical: isVertical,
|
|
261
278
|
pathname,
|
|
262
279
|
notifying: target.kind === "notification" || displayed.scene.kind === "notification" || hasBase && !isOpen(displayed.presence),
|
|
263
|
-
panel:
|
|
280
|
+
panel: wantsPanel,
|
|
281
|
+
holdPanel,
|
|
264
282
|
linkComponent,
|
|
265
283
|
variant,
|
|
266
284
|
theme: rest.theme,
|
|
@@ -330,7 +348,7 @@ const MagicPill = forwardRef(function MagicPill({ name = "main", children, scene
|
|
|
330
348
|
"--_mp-sidebar-width": `${sidebarWidth.current}px`
|
|
331
349
|
} : rest.style,
|
|
332
350
|
variant: sceneVariant,
|
|
333
|
-
presence:
|
|
351
|
+
presence: pillPresence,
|
|
334
352
|
onPresenceChange: presenceHandler(displayedRef, setDisplayed),
|
|
335
353
|
onPointerEnter: (event) => {
|
|
336
354
|
onPointerEnter?.(event);
|
package/dist/Pill/PillPanel.js
CHANGED
|
@@ -21,15 +21,19 @@ const PillPanel = (0, react.forwardRef)(function PillPanel({ name, title, titleA
|
|
|
21
21
|
const panelRef = (0, react.useRef)(null);
|
|
22
22
|
const ref = (0, react.useMemo)(() => require_react.mergeRefs(panelRef, forwardedRef), [forwardedRef]);
|
|
23
23
|
const wasOpenRef = (0, react.useRef)(isOpen);
|
|
24
|
+
const wasShownRef = (0, react.useRef)(isOpen);
|
|
24
25
|
(0, react.useEffect)(require_inputModality.trackInputModality, []);
|
|
25
26
|
(0, react.useEffect)(() => {
|
|
26
27
|
const wasOpen = wasOpenRef.current;
|
|
27
28
|
wasOpenRef.current = isOpen;
|
|
28
29
|
if (isOpen && !wasOpen) panelRef.current?.focus({ preventScroll: true });
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
}, [isOpen]);
|
|
31
|
+
require_react.useIsomorphicLayoutEffect(() => {
|
|
32
|
+
const wasShown = wasShownRef.current;
|
|
33
|
+
wasShownRef.current = isOpen;
|
|
34
|
+
if (isOpen || !wasShown) return;
|
|
35
|
+
const active = document.activeElement;
|
|
36
|
+
if (!active || active === document.body || rootRef.current?.contains(active)) panelTriggerRef.current?.focus(require_inputModality.getInputModality() === "pointer" ? { focusVisible: false } : void 0);
|
|
33
37
|
}, [
|
|
34
38
|
isOpen,
|
|
35
39
|
panelTriggerRef,
|
package/dist/Pill/PillPanel.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import PillAction from "./PillAction.mjs";
|
|
|
5
5
|
import { useInternalPill } from "./PillContext.mjs";
|
|
6
6
|
import CloseIcon from "../icons/CloseIcon.mjs";
|
|
7
7
|
import { getInputModality, trackInputModality } from "../utils/inputModality.mjs";
|
|
8
|
-
import { mergeRefs } from "../utils/react.mjs";
|
|
8
|
+
import { mergeRefs, useIsomorphicLayoutEffect } from "../utils/react.mjs";
|
|
9
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
10
|
|
|
11
11
|
// src/Pill/PillPanel.tsx
|
|
@@ -21,15 +21,19 @@ const PillPanel = forwardRef(function PillPanel({ name, title, titleAction, foot
|
|
|
21
21
|
const panelRef = useRef(null);
|
|
22
22
|
const ref = useMemo(() => mergeRefs(panelRef, forwardedRef), [forwardedRef]);
|
|
23
23
|
const wasOpenRef = useRef(isOpen);
|
|
24
|
+
const wasShownRef = useRef(isOpen);
|
|
24
25
|
useEffect(trackInputModality, []);
|
|
25
26
|
useEffect(() => {
|
|
26
27
|
const wasOpen = wasOpenRef.current;
|
|
27
28
|
wasOpenRef.current = isOpen;
|
|
28
29
|
if (isOpen && !wasOpen) panelRef.current?.focus({ preventScroll: true });
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
}, [isOpen]);
|
|
31
|
+
useIsomorphicLayoutEffect(() => {
|
|
32
|
+
const wasShown = wasShownRef.current;
|
|
33
|
+
wasShownRef.current = isOpen;
|
|
34
|
+
if (isOpen || !wasShown) return;
|
|
35
|
+
const active = document.activeElement;
|
|
36
|
+
if (!active || active === document.body || rootRef.current?.contains(active)) panelTriggerRef.current?.focus(getInputModality() === "pointer" ? { focusVisible: false } : void 0);
|
|
33
37
|
}, [
|
|
34
38
|
isOpen,
|
|
35
39
|
panelTriggerRef,
|
package/dist/Pill/goo.js
CHANGED
|
@@ -64,18 +64,23 @@ function tuckedOffset(anchor, moving, start = 1) {
|
|
|
64
64
|
if (!fits(moving.width, anchor.width)) scale = Math.min(scale, anchor.width / moving.width);
|
|
65
65
|
if (!fits(moving.height, anchor.height)) scale = Math.min(scale, anchor.height / moving.height);
|
|
66
66
|
scale = Math.max(.1, scale);
|
|
67
|
-
|
|
67
|
+
const sideways = Math.abs(dx) / (anchor.width / 2 + moving.width / 2) >= Math.abs(dy) / (anchor.height / 2 + moving.height / 2);
|
|
68
|
+
const within = (centre, start, room, size) => size >= room ? start + room / 2 : Math.min(Math.max(centre, start + size / 2), start + room - size / 2);
|
|
69
|
+
if (sideways) {
|
|
68
70
|
const sign = Math.sign(dx) || 1;
|
|
71
|
+
const edge = anchorX + sign * anchor.width / 2;
|
|
72
|
+
const y = within(movingY, anchor.top, anchor.height, moving.height * scale) - movingY;
|
|
69
73
|
return {
|
|
70
|
-
x:
|
|
71
|
-
y
|
|
74
|
+
x: edge - sign * moving.width * scale / 2 - movingX,
|
|
75
|
+
y,
|
|
72
76
|
scale
|
|
73
77
|
};
|
|
74
78
|
}
|
|
75
79
|
const sign = Math.sign(dy) || 1;
|
|
80
|
+
const edge = anchorY + sign * anchor.height / 2;
|
|
76
81
|
return {
|
|
77
|
-
x:
|
|
78
|
-
y:
|
|
82
|
+
x: within(movingX, anchor.left, anchor.width, moving.width * scale) - movingX,
|
|
83
|
+
y: edge - sign * moving.height * scale / 2 - movingY,
|
|
79
84
|
scale
|
|
80
85
|
};
|
|
81
86
|
}
|
|
@@ -489,7 +494,8 @@ function playOrbit(electron, items, kind, timing) {
|
|
|
489
494
|
scale: String(start.scale),
|
|
490
495
|
opacity: opaque ? shown : 0
|
|
491
496
|
};
|
|
492
|
-
const
|
|
497
|
+
const here = drawn.get(element);
|
|
498
|
+
const out = here ?? {
|
|
493
499
|
translate: "0px 0px",
|
|
494
500
|
scale: end === "none" ? "1" : end,
|
|
495
501
|
opacity: shown
|
|
@@ -538,17 +544,20 @@ function playOrbit(electron, items, kind, timing) {
|
|
|
538
544
|
...options,
|
|
539
545
|
easing: "linear"
|
|
540
546
|
});
|
|
541
|
-
else if (kind === "close")
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
opacity:
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
547
|
+
else if (kind === "close") {
|
|
548
|
+
const seen = here ? Math.min(here.opacity, shown) : shown;
|
|
549
|
+
element.animate([
|
|
550
|
+
{ opacity: seen },
|
|
551
|
+
{
|
|
552
|
+
opacity: seen,
|
|
553
|
+
offset: .85
|
|
554
|
+
},
|
|
555
|
+
{ opacity: 0 }
|
|
556
|
+
], {
|
|
557
|
+
...options,
|
|
558
|
+
easing: "linear"
|
|
559
|
+
});
|
|
560
|
+
}
|
|
552
561
|
if (droplet) {
|
|
553
562
|
const content = kind === "open" ? [
|
|
554
563
|
{ opacity: 0 },
|
package/dist/Pill/goo.mjs
CHANGED
|
@@ -64,18 +64,23 @@ function tuckedOffset(anchor, moving, start = 1) {
|
|
|
64
64
|
if (!fits(moving.width, anchor.width)) scale = Math.min(scale, anchor.width / moving.width);
|
|
65
65
|
if (!fits(moving.height, anchor.height)) scale = Math.min(scale, anchor.height / moving.height);
|
|
66
66
|
scale = Math.max(.1, scale);
|
|
67
|
-
|
|
67
|
+
const sideways = Math.abs(dx) / (anchor.width / 2 + moving.width / 2) >= Math.abs(dy) / (anchor.height / 2 + moving.height / 2);
|
|
68
|
+
const within = (centre, start, room, size) => size >= room ? start + room / 2 : Math.min(Math.max(centre, start + size / 2), start + room - size / 2);
|
|
69
|
+
if (sideways) {
|
|
68
70
|
const sign = Math.sign(dx) || 1;
|
|
71
|
+
const edge = anchorX + sign * anchor.width / 2;
|
|
72
|
+
const y = within(movingY, anchor.top, anchor.height, moving.height * scale) - movingY;
|
|
69
73
|
return {
|
|
70
|
-
x:
|
|
71
|
-
y
|
|
74
|
+
x: edge - sign * moving.width * scale / 2 - movingX,
|
|
75
|
+
y,
|
|
72
76
|
scale
|
|
73
77
|
};
|
|
74
78
|
}
|
|
75
79
|
const sign = Math.sign(dy) || 1;
|
|
80
|
+
const edge = anchorY + sign * anchor.height / 2;
|
|
76
81
|
return {
|
|
77
|
-
x:
|
|
78
|
-
y:
|
|
82
|
+
x: within(movingX, anchor.left, anchor.width, moving.width * scale) - movingX,
|
|
83
|
+
y: edge - sign * moving.height * scale / 2 - movingY,
|
|
79
84
|
scale
|
|
80
85
|
};
|
|
81
86
|
}
|
|
@@ -489,7 +494,8 @@ function playOrbit(electron, items, kind, timing) {
|
|
|
489
494
|
scale: String(start.scale),
|
|
490
495
|
opacity: opaque ? shown : 0
|
|
491
496
|
};
|
|
492
|
-
const
|
|
497
|
+
const here = drawn.get(element);
|
|
498
|
+
const out = here ?? {
|
|
493
499
|
translate: "0px 0px",
|
|
494
500
|
scale: end === "none" ? "1" : end,
|
|
495
501
|
opacity: shown
|
|
@@ -538,17 +544,20 @@ function playOrbit(electron, items, kind, timing) {
|
|
|
538
544
|
...options,
|
|
539
545
|
easing: "linear"
|
|
540
546
|
});
|
|
541
|
-
else if (kind === "close")
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
opacity:
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
547
|
+
else if (kind === "close") {
|
|
548
|
+
const seen = here ? Math.min(here.opacity, shown) : shown;
|
|
549
|
+
element.animate([
|
|
550
|
+
{ opacity: seen },
|
|
551
|
+
{
|
|
552
|
+
opacity: seen,
|
|
553
|
+
offset: .85
|
|
554
|
+
},
|
|
555
|
+
{ opacity: 0 }
|
|
556
|
+
], {
|
|
557
|
+
...options,
|
|
558
|
+
easing: "linear"
|
|
559
|
+
});
|
|
560
|
+
}
|
|
552
561
|
if (droplet) {
|
|
553
562
|
const content = kind === "open" ? [
|
|
554
563
|
{ opacity: 0 },
|
|
@@ -37,13 +37,14 @@ function useLabelMorph(buttonRef, label) {
|
|
|
37
37
|
const text = buttonRef.current?.querySelector("[data-mp=\"label\"] > span");
|
|
38
38
|
if (!text) return;
|
|
39
39
|
text.getAnimations?.().forEach((animation) => animation.cancel());
|
|
40
|
-
const width = text.
|
|
40
|
+
const width = text.scrollWidth;
|
|
41
41
|
const from = previous.current;
|
|
42
42
|
previous.current = {
|
|
43
43
|
label,
|
|
44
44
|
width
|
|
45
45
|
};
|
|
46
46
|
if (!from || from.label === label || !from.width || !text.animate || require_timing.prefersReducedMotion()) return;
|
|
47
|
+
if (text.parentElement && getComputedStyle(text.parentElement).opacity !== "1") return;
|
|
47
48
|
text.animate([{
|
|
48
49
|
width: `${from.width}px`,
|
|
49
50
|
opacity: 0,
|
|
@@ -37,13 +37,14 @@ function useLabelMorph(buttonRef, label) {
|
|
|
37
37
|
const text = buttonRef.current?.querySelector("[data-mp=\"label\"] > span");
|
|
38
38
|
if (!text) return;
|
|
39
39
|
text.getAnimations?.().forEach((animation) => animation.cancel());
|
|
40
|
-
const width = text.
|
|
40
|
+
const width = text.scrollWidth;
|
|
41
41
|
const from = previous.current;
|
|
42
42
|
previous.current = {
|
|
43
43
|
label,
|
|
44
44
|
width
|
|
45
45
|
};
|
|
46
46
|
if (!from || from.label === label || !from.width || !text.animate || prefersReducedMotion()) return;
|
|
47
|
+
if (text.parentElement && getComputedStyle(text.parentElement).opacity !== "1") return;
|
|
47
48
|
text.animate([{
|
|
48
49
|
width: `${from.width}px`,
|
|
49
50
|
opacity: 0,
|
package/dist/PillForm/room.js
CHANGED
|
@@ -15,6 +15,7 @@ function useFormRoom(formRef) {
|
|
|
15
15
|
const field = form.querySelector("[data-mp=\"field\"]");
|
|
16
16
|
const submit = form.querySelector("[data-mp=\"action\"][type=\"submit\"][data-expanded]");
|
|
17
17
|
if (!field || !submit) return form.removeAttribute("data-tight");
|
|
18
|
+
if (form.getAttribute("aria-busy") === "true") return;
|
|
18
19
|
const least = LEAST * (Number.parseFloat(getComputedStyle(document.documentElement).fontSize) || 16);
|
|
19
20
|
const max = Number.parseFloat(getComputedStyle(pill).maxInlineSize);
|
|
20
21
|
let room = Number.isFinite(max) ? max - pill.offsetWidth : Number.POSITIVE_INFINITY;
|
package/dist/PillForm/room.mjs
CHANGED
|
@@ -15,6 +15,7 @@ function useFormRoom(formRef) {
|
|
|
15
15
|
const field = form.querySelector("[data-mp=\"field\"]");
|
|
16
16
|
const submit = form.querySelector("[data-mp=\"action\"][type=\"submit\"][data-expanded]");
|
|
17
17
|
if (!field || !submit) return form.removeAttribute("data-tight");
|
|
18
|
+
if (form.getAttribute("aria-busy") === "true") return;
|
|
18
19
|
const least = LEAST * (Number.parseFloat(getComputedStyle(document.documentElement).fontSize) || 16);
|
|
19
20
|
const max = Number.parseFloat(getComputedStyle(pill).maxInlineSize);
|
|
20
21
|
let room = Number.isFinite(max) ? max - pill.offsetWidth : Number.POSITIVE_INFINITY;
|
package/dist/forms.css
CHANGED
|
@@ -246,9 +246,23 @@
|
|
|
246
246
|
inline-size: 15rem;
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
+
/* Its label isn't cut short: the field gives the room (B16: squeezed
|
|
250
|
+
with it, the live label shrank as it opened, then jumped) */
|
|
251
|
+
& [data-mp="action"][type="submit"] {
|
|
252
|
+
flex-shrink: 0;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/* Being sent, it can give it all: what it holds goes with it, rather
|
|
256
|
+
than showing past its edge (it's read-only meanwhile) */
|
|
257
|
+
&[aria-busy="true"] [data-mp="field"] {
|
|
258
|
+
overflow: clip;
|
|
259
|
+
}
|
|
260
|
+
|
|
249
261
|
/* Short of room (PillForm/room.ts): the button folds its label, still
|
|
250
|
-
its name; the field keeps room to type in
|
|
251
|
-
|
|
262
|
+
its name; the field keeps room to type in. Not while it's being sent:
|
|
263
|
+
its live label ("Adding you…") says what's happening then, and the
|
|
264
|
+
field, read-only, yields it the room (B16) */
|
|
265
|
+
&[data-tight]:not([aria-busy="true"]) [data-mp="action"][type="submit"][data-expanded]:not(:focus-visible) {
|
|
252
266
|
& [data-mp="action-body"] {
|
|
253
267
|
padding-inline-end: calc((var(--_mp-action-size) - 1.25rem) / 2);
|
|
254
268
|
}
|
|
@@ -8,6 +8,7 @@ const require_store = require("../store/store.js");
|
|
|
8
8
|
const require_react = require("../utils/react.js");
|
|
9
9
|
const require_timing = require("../utils/timing.js");
|
|
10
10
|
const require_handoff = require("./handoff.js");
|
|
11
|
+
const require_measure = require("./measure.js");
|
|
11
12
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
12
13
|
|
|
13
14
|
// src/satellites/Actions.tsx
|
|
@@ -146,7 +147,8 @@ function useActionsWheel(track) {
|
|
|
146
147
|
function ActionList({ items, host, wheel, inside, leaving }) {
|
|
147
148
|
const track = (0, react.useRef)(null);
|
|
148
149
|
useActionsWheel(track);
|
|
149
|
-
const gone = useGoneActions(items, track, wheel === void 0
|
|
150
|
+
const gone = useGoneActions(items, track, wheel === void 0);
|
|
151
|
+
useInsideResize(items, track, !!inside && wheel === void 0 && !leaving);
|
|
150
152
|
const draw = (item, spot) => {
|
|
151
153
|
const key = keyOf(item);
|
|
152
154
|
const leavingProps = spot ? {
|
|
@@ -182,12 +184,69 @@ function ActionList({ items, host, wheel, inside, leaving }) {
|
|
|
182
184
|
"data-inside": inside ? "" : void 0,
|
|
183
185
|
"data-leaving": leaving ? "" : void 0,
|
|
184
186
|
"data-wheel": wheel !== void 0 ? "" : void 0,
|
|
185
|
-
style:
|
|
187
|
+
style: {
|
|
188
|
+
...wheel !== void 0 ? { "--_mp-wheel-length": `${wheel}px` } : {},
|
|
189
|
+
...inside ? { position: "relative" } : {}
|
|
190
|
+
},
|
|
186
191
|
children: [items.map((item) => draw(item)), gone.map(({ item, spot }) => draw(item, spot))]
|
|
187
192
|
});
|
|
188
193
|
}
|
|
189
194
|
const keyOf = (item) => item.id ?? item.label;
|
|
190
195
|
/**
|
|
196
|
+
* In the pill itself, another list (two actions, then four): their row resizes from one list's length
|
|
197
|
+
* to the other, the pill following it at each frame (and the satellites the pill, over the same
|
|
198
|
+
* time), and a shorter list shrinks over the ones leaving (useGoneActions). It changed in one frame
|
|
199
|
+
* (B13). Not while they open or fold away (playInside), nor cut short by a wheel (its row scrolls).
|
|
200
|
+
*/
|
|
201
|
+
function useInsideResize(items, track, resizes) {
|
|
202
|
+
const length = (0, react.useRef)(void 0);
|
|
203
|
+
(0, react.useEffect)(() => {
|
|
204
|
+
const row = track.current;
|
|
205
|
+
if (!row || typeof ResizeObserver === "undefined") return;
|
|
206
|
+
const observer = new ResizeObserver(() => {
|
|
207
|
+
length.current = getComputedStyle(row).flexDirection.startsWith("column") ? row.offsetHeight : row.offsetWidth;
|
|
208
|
+
});
|
|
209
|
+
observer.observe(row);
|
|
210
|
+
return () => observer.disconnect();
|
|
211
|
+
}, [track]);
|
|
212
|
+
require_react.useIsomorphicLayoutEffect(() => {
|
|
213
|
+
const row = track.current;
|
|
214
|
+
if (!row) return;
|
|
215
|
+
const vertical = getComputedStyle(row).flexDirection.startsWith("column");
|
|
216
|
+
const now = vertical ? row.offsetHeight : row.offsetWidth;
|
|
217
|
+
const before = length.current;
|
|
218
|
+
length.current = now;
|
|
219
|
+
if (!resizes || before === void 0 || Math.abs(before - now) < .5) return;
|
|
220
|
+
const pill = row.closest("[data-mp=\"pill\"]");
|
|
221
|
+
if (!pill || typeof row.animate !== "function" || require_timing.prefersReducedMotion()) return;
|
|
222
|
+
if ((row.getAnimations?.() ?? []).some((animation) => animation.id === INSIDE)) return;
|
|
223
|
+
const { change } = require_morph.readMorphTimings(pill);
|
|
224
|
+
if (change <= 0) return;
|
|
225
|
+
const size = vertical ? "height" : "width";
|
|
226
|
+
const bounds = vertical ? {
|
|
227
|
+
minHeight: "0px",
|
|
228
|
+
maxHeight: "none"
|
|
229
|
+
} : {
|
|
230
|
+
minWidth: "0px",
|
|
231
|
+
maxWidth: "none"
|
|
232
|
+
};
|
|
233
|
+
row.style.overflow = "clip";
|
|
234
|
+
const resize = row.animate([{
|
|
235
|
+
...bounds,
|
|
236
|
+
[size]: `${before}px`
|
|
237
|
+
}, {
|
|
238
|
+
...bounds,
|
|
239
|
+
[size]: `${now}px`
|
|
240
|
+
}], {
|
|
241
|
+
id: INSIDE,
|
|
242
|
+
duration: change,
|
|
243
|
+
easing: "ease-in-out"
|
|
244
|
+
});
|
|
245
|
+
const done = () => row.style.removeProperty("overflow");
|
|
246
|
+
resize.finished.then(done, done);
|
|
247
|
+
}, [items]);
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
191
250
|
* The actions gone from the list, for a moment: the pill shrinks to the new list over them (it clips
|
|
192
251
|
* them), then they go, fading as it ends. They used to vanish at once, the pill shrinking after.
|
|
193
252
|
* Only for the pill of actions, not cut short by a wheel (`keep`): a wheel's row scrolls.
|
|
@@ -384,7 +443,11 @@ function InsideActions({ host }) {
|
|
|
384
443
|
line.animate([closed.divider, closed.divider], hold);
|
|
385
444
|
const frame = requestAnimationFrame(() => {
|
|
386
445
|
stopInside(list, line);
|
|
387
|
-
playInside(list, line, "in");
|
|
446
|
+
const timing = playInside(list, line, "in")?.effect?.getTiming();
|
|
447
|
+
if (timing && typeof timing.duration === "number") {
|
|
448
|
+
const { fade, change } = require_morph.readMorphTimings(pill);
|
|
449
|
+
require_measure.slideInStep(pill, timing.duration, change / (fade + change));
|
|
450
|
+
}
|
|
388
451
|
});
|
|
389
452
|
return () => {
|
|
390
453
|
cancelAnimationFrame(frame);
|
|
@@ -8,6 +8,7 @@ import { getStore } from "../store/store.mjs";
|
|
|
8
8
|
import { useIsomorphicLayoutEffect } from "../utils/react.mjs";
|
|
9
9
|
import { prefersReducedMotion } from "../utils/timing.mjs";
|
|
10
10
|
import { getHandoff, setHandoff, useHandoff } from "./handoff.mjs";
|
|
11
|
+
import { slideInStep } from "./measure.mjs";
|
|
11
12
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
12
13
|
|
|
13
14
|
// src/satellites/Actions.tsx
|
|
@@ -146,7 +147,8 @@ function useActionsWheel(track) {
|
|
|
146
147
|
function ActionList({ items, host, wheel, inside, leaving }) {
|
|
147
148
|
const track = useRef(null);
|
|
148
149
|
useActionsWheel(track);
|
|
149
|
-
const gone = useGoneActions(items, track, wheel === void 0
|
|
150
|
+
const gone = useGoneActions(items, track, wheel === void 0);
|
|
151
|
+
useInsideResize(items, track, !!inside && wheel === void 0 && !leaving);
|
|
150
152
|
const draw = (item, spot) => {
|
|
151
153
|
const key = keyOf(item);
|
|
152
154
|
const leavingProps = spot ? {
|
|
@@ -182,12 +184,69 @@ function ActionList({ items, host, wheel, inside, leaving }) {
|
|
|
182
184
|
"data-inside": inside ? "" : void 0,
|
|
183
185
|
"data-leaving": leaving ? "" : void 0,
|
|
184
186
|
"data-wheel": wheel !== void 0 ? "" : void 0,
|
|
185
|
-
style:
|
|
187
|
+
style: {
|
|
188
|
+
...wheel !== void 0 ? { "--_mp-wheel-length": `${wheel}px` } : {},
|
|
189
|
+
...inside ? { position: "relative" } : {}
|
|
190
|
+
},
|
|
186
191
|
children: [items.map((item) => draw(item)), gone.map(({ item, spot }) => draw(item, spot))]
|
|
187
192
|
});
|
|
188
193
|
}
|
|
189
194
|
const keyOf = (item) => item.id ?? item.label;
|
|
190
195
|
/**
|
|
196
|
+
* In the pill itself, another list (two actions, then four): their row resizes from one list's length
|
|
197
|
+
* to the other, the pill following it at each frame (and the satellites the pill, over the same
|
|
198
|
+
* time), and a shorter list shrinks over the ones leaving (useGoneActions). It changed in one frame
|
|
199
|
+
* (B13). Not while they open or fold away (playInside), nor cut short by a wheel (its row scrolls).
|
|
200
|
+
*/
|
|
201
|
+
function useInsideResize(items, track, resizes) {
|
|
202
|
+
const length = useRef(void 0);
|
|
203
|
+
useEffect(() => {
|
|
204
|
+
const row = track.current;
|
|
205
|
+
if (!row || typeof ResizeObserver === "undefined") return;
|
|
206
|
+
const observer = new ResizeObserver(() => {
|
|
207
|
+
length.current = getComputedStyle(row).flexDirection.startsWith("column") ? row.offsetHeight : row.offsetWidth;
|
|
208
|
+
});
|
|
209
|
+
observer.observe(row);
|
|
210
|
+
return () => observer.disconnect();
|
|
211
|
+
}, [track]);
|
|
212
|
+
useIsomorphicLayoutEffect(() => {
|
|
213
|
+
const row = track.current;
|
|
214
|
+
if (!row) return;
|
|
215
|
+
const vertical = getComputedStyle(row).flexDirection.startsWith("column");
|
|
216
|
+
const now = vertical ? row.offsetHeight : row.offsetWidth;
|
|
217
|
+
const before = length.current;
|
|
218
|
+
length.current = now;
|
|
219
|
+
if (!resizes || before === void 0 || Math.abs(before - now) < .5) return;
|
|
220
|
+
const pill = row.closest("[data-mp=\"pill\"]");
|
|
221
|
+
if (!pill || typeof row.animate !== "function" || prefersReducedMotion()) return;
|
|
222
|
+
if ((row.getAnimations?.() ?? []).some((animation) => animation.id === INSIDE)) return;
|
|
223
|
+
const { change } = readMorphTimings(pill);
|
|
224
|
+
if (change <= 0) return;
|
|
225
|
+
const size = vertical ? "height" : "width";
|
|
226
|
+
const bounds = vertical ? {
|
|
227
|
+
minHeight: "0px",
|
|
228
|
+
maxHeight: "none"
|
|
229
|
+
} : {
|
|
230
|
+
minWidth: "0px",
|
|
231
|
+
maxWidth: "none"
|
|
232
|
+
};
|
|
233
|
+
row.style.overflow = "clip";
|
|
234
|
+
const resize = row.animate([{
|
|
235
|
+
...bounds,
|
|
236
|
+
[size]: `${before}px`
|
|
237
|
+
}, {
|
|
238
|
+
...bounds,
|
|
239
|
+
[size]: `${now}px`
|
|
240
|
+
}], {
|
|
241
|
+
id: INSIDE,
|
|
242
|
+
duration: change,
|
|
243
|
+
easing: "ease-in-out"
|
|
244
|
+
});
|
|
245
|
+
const done = () => row.style.removeProperty("overflow");
|
|
246
|
+
resize.finished.then(done, done);
|
|
247
|
+
}, [items]);
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
191
250
|
* The actions gone from the list, for a moment: the pill shrinks to the new list over them (it clips
|
|
192
251
|
* them), then they go, fading as it ends. They used to vanish at once, the pill shrinking after.
|
|
193
252
|
* Only for the pill of actions, not cut short by a wheel (`keep`): a wheel's row scrolls.
|
|
@@ -384,7 +443,11 @@ function InsideActions({ host }) {
|
|
|
384
443
|
line.animate([closed.divider, closed.divider], hold);
|
|
385
444
|
const frame = requestAnimationFrame(() => {
|
|
386
445
|
stopInside(list, line);
|
|
387
|
-
playInside(list, line, "in");
|
|
446
|
+
const timing = playInside(list, line, "in")?.effect?.getTiming();
|
|
447
|
+
if (timing && typeof timing.duration === "number") {
|
|
448
|
+
const { fade, change } = readMorphTimings(pill);
|
|
449
|
+
slideInStep(pill, timing.duration, change / (fade + change));
|
|
450
|
+
}
|
|
388
451
|
});
|
|
389
452
|
return () => {
|
|
390
453
|
cancelAnimationFrame(frame);
|