magic-pill 9.4.0-next.5 → 9.4.0-rc.1

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 CHANGED
@@ -75,6 +75,16 @@
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
78
88
 
79
89
  ### Changed
80
90
  - **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
@@ -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
- else if (!isOpen && wasOpen) {
30
- const active = document.activeElement;
31
- if (!active || active === document.body || rootRef.current?.contains(active)) panelTriggerRef.current?.focus(require_inputModality.getInputModality() === "pointer" ? { focusVisible: false } : void 0);
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,
@@ -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
- else if (!isOpen && wasOpen) {
30
- const active = document.activeElement;
31
- if (!active || active === document.body || rootRef.current?.contains(active)) panelTriggerRef.current?.focus(getInputModality() === "pointer" ? { focusVisible: false } : void 0);
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
- if (Math.abs(dx) / (anchor.width / 2 + moving.width / 2) >= Math.abs(dy) / (anchor.height / 2 + moving.height / 2)) {
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: anchorX + sign * anchor.width / 2 - sign * moving.width * scale / 2 - movingX,
71
- y: 0,
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: 0,
78
- y: anchorY + sign * anchor.height / 2 - sign * moving.height * scale / 2 - movingY,
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 out = drawn.get(element) ?? {
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") element.animate([
542
- { opacity: shown },
543
- {
544
- opacity: shown,
545
- offset: .85
546
- },
547
- { opacity: 0 }
548
- ], {
549
- ...options,
550
- easing: "linear"
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
- if (Math.abs(dx) / (anchor.width / 2 + moving.width / 2) >= Math.abs(dy) / (anchor.height / 2 + moving.height / 2)) {
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: anchorX + sign * anchor.width / 2 - sign * moving.width * scale / 2 - movingX,
71
- y: 0,
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: 0,
78
- y: anchorY + sign * anchor.height / 2 - sign * moving.height * scale / 2 - movingY,
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 out = drawn.get(element) ?? {
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") element.animate([
542
- { opacity: shown },
543
- {
544
- opacity: shown,
545
- offset: .85
546
- },
547
- { opacity: 0 }
548
- ], {
549
- ...options,
550
- easing: "linear"
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 },
@@ -440,6 +440,44 @@ function readPanel(pill) {
440
440
  };
441
441
  }
442
442
  /**
443
+ * A panel opening, held at its start (`holdOpening`) while what makes room for it moves out of the
444
+ * way (an electron going into the pill, magic-pill/satellites), then played again (`replayOpening`)
445
+ * to the size it has once that room is free: one motion. It opened part way as the electron went
446
+ * in, then widened again once it was in (A36).
447
+ */
448
+ function holdOpening(element) {
449
+ let held = false;
450
+ for (const animation of element.getAnimations?.({ subtree: true }) ?? []) {
451
+ if (animation.id !== "mp-morph") continue;
452
+ animation.pause();
453
+ animation.currentTime = 0;
454
+ held = true;
455
+ }
456
+ return held;
457
+ }
458
+ /** The opening `holdOpening` held, from where it's held to the pill's size now. Whether one was held. */
459
+ function replayOpening(element) {
460
+ if ((element.getAnimations?.({ subtree: true }) ?? []).filter((animation) => animation.id === "mp-morph" && animation.playState === "paused").length === 0) return false;
461
+ const from = readSize(element);
462
+ cancel(element, MORPH, true);
463
+ if (require_timing.prefersReducedMotion()) return true;
464
+ const to = readSettledSize(element);
465
+ const panel = readPanel(element);
466
+ const plan = planMorph(from, to, "compact", "panel", readMorphTimings(element), panel?.box);
467
+ if (!plan) return true;
468
+ const options = {
469
+ ...plan.options,
470
+ id: MORPH
471
+ };
472
+ element.animate(plan.pill, options);
473
+ if (plan.panel && panel) {
474
+ panel.element.animate(plan.panel, options);
475
+ const footer = panel.element.querySelector("[data-mp=\"panel-footer\"]");
476
+ if (footer) footer.animate([{ position: "relative" }, { position: "relative" }], options);
477
+ }
478
+ return true;
479
+ }
480
+ /**
443
481
  * Animates the pill's size on each presence change. Off for `unstyled` pills,
444
482
  * with reduced motion, and where the Web Animations API is missing.
445
483
  */
@@ -627,10 +665,12 @@ exports.PlacementWatch = PlacementWatch;
627
665
  exports.animateMove = animateMove;
628
666
  exports.cancel = cancel;
629
667
  exports.captureSwap = captureSwap;
668
+ exports.holdOpening = holdOpening;
630
669
  exports.onCopy = onCopy;
631
670
  exports.planExit = planExit;
632
671
  exports.planMorph = planMorph;
633
672
  exports.planSwap = planSwap;
634
673
  exports.playSwap = playSwap;
635
674
  exports.readMorphTimings = readMorphTimings;
675
+ exports.replayOpening = replayOpening;
636
676
  exports.useSizeMorph = useSizeMorph;
@@ -440,6 +440,44 @@ function readPanel(pill) {
440
440
  };
441
441
  }
442
442
  /**
443
+ * A panel opening, held at its start (`holdOpening`) while what makes room for it moves out of the
444
+ * way (an electron going into the pill, magic-pill/satellites), then played again (`replayOpening`)
445
+ * to the size it has once that room is free: one motion. It opened part way as the electron went
446
+ * in, then widened again once it was in (A36).
447
+ */
448
+ function holdOpening(element) {
449
+ let held = false;
450
+ for (const animation of element.getAnimations?.({ subtree: true }) ?? []) {
451
+ if (animation.id !== "mp-morph") continue;
452
+ animation.pause();
453
+ animation.currentTime = 0;
454
+ held = true;
455
+ }
456
+ return held;
457
+ }
458
+ /** The opening `holdOpening` held, from where it's held to the pill's size now. Whether one was held. */
459
+ function replayOpening(element) {
460
+ if ((element.getAnimations?.({ subtree: true }) ?? []).filter((animation) => animation.id === "mp-morph" && animation.playState === "paused").length === 0) return false;
461
+ const from = readSize(element);
462
+ cancel(element, MORPH, true);
463
+ if (prefersReducedMotion()) return true;
464
+ const to = readSettledSize(element);
465
+ const panel = readPanel(element);
466
+ const plan = planMorph(from, to, "compact", "panel", readMorphTimings(element), panel?.box);
467
+ if (!plan) return true;
468
+ const options = {
469
+ ...plan.options,
470
+ id: MORPH
471
+ };
472
+ element.animate(plan.pill, options);
473
+ if (plan.panel && panel) {
474
+ panel.element.animate(plan.panel, options);
475
+ const footer = panel.element.querySelector("[data-mp=\"panel-footer\"]");
476
+ if (footer) footer.animate([{ position: "relative" }, { position: "relative" }], options);
477
+ }
478
+ return true;
479
+ }
480
+ /**
443
481
  * Animates the pill's size on each presence change. Off for `unstyled` pills,
444
482
  * with reduced motion, and where the Web Animations API is missing.
445
483
  */
@@ -618,4 +656,4 @@ var PlacementWatch = class extends Component {
618
656
  }
619
657
  };
620
658
 
621
- export { EASING, EXIT, ExitWatch, MORPH, MOVE, PlacementWatch, animateMove, cancel, captureSwap, onCopy, planExit, planMorph, planSwap, playSwap, readMorphTimings, useSizeMorph };
659
+ export { EASING, EXIT, ExitWatch, MORPH, MOVE, PlacementWatch, animateMove, cancel, captureSwap, holdOpening, onCopy, planExit, planMorph, planSwap, playSwap, readMorphTimings, replayOpening, useSizeMorph };
@@ -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.offsetWidth;
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.offsetWidth;
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,
@@ -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;
@@ -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
- &[data-tight] [data-mp="action"][type="submit"][data-expanded]:not(:focus-visible) {
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 && !inside);
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,60 @@ 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: wheel !== void 0 ? { "--_mp-wheel-length": `${wheel}px` } : void 0,
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
+ require_react.useIsomorphicLayoutEffect(() => {
204
+ const row = track.current;
205
+ if (!row) return;
206
+ const vertical = getComputedStyle(row).flexDirection.startsWith("column");
207
+ const now = vertical ? row.offsetHeight : row.offsetWidth;
208
+ const before = length.current;
209
+ length.current = now;
210
+ if (!resizes || before === void 0 || Math.abs(before - now) < .5) return;
211
+ const pill = row.closest("[data-mp=\"pill\"]");
212
+ if (!pill || typeof row.animate !== "function" || require_timing.prefersReducedMotion()) return;
213
+ if ((row.getAnimations?.() ?? []).some((animation) => animation.id === INSIDE)) return;
214
+ const { change } = require_morph.readMorphTimings(pill);
215
+ if (change <= 0) return;
216
+ const size = vertical ? "height" : "width";
217
+ const bounds = vertical ? {
218
+ minHeight: "0px",
219
+ maxHeight: "none"
220
+ } : {
221
+ minWidth: "0px",
222
+ maxWidth: "none"
223
+ };
224
+ row.style.overflow = "clip";
225
+ const resize = row.animate([{
226
+ ...bounds,
227
+ [size]: `${before}px`
228
+ }, {
229
+ ...bounds,
230
+ [size]: `${now}px`
231
+ }], {
232
+ id: INSIDE,
233
+ duration: change,
234
+ easing: "ease-in-out"
235
+ });
236
+ const done = () => row.style.removeProperty("overflow");
237
+ resize.finished.then(done, done);
238
+ }, [items]);
239
+ }
240
+ /**
191
241
  * The actions gone from the list, for a moment: the pill shrinks to the new list over them (it clips
192
242
  * them), then they go, fading as it ends. They used to vanish at once, the pill shrinking after.
193
243
  * Only for the pill of actions, not cut short by a wheel (`keep`): a wheel's row scrolls.
@@ -384,7 +434,11 @@ function InsideActions({ host }) {
384
434
  line.animate([closed.divider, closed.divider], hold);
385
435
  const frame = requestAnimationFrame(() => {
386
436
  stopInside(list, line);
387
- playInside(list, line, "in");
437
+ const timing = playInside(list, line, "in")?.effect?.getTiming();
438
+ if (timing && typeof timing.duration === "number") {
439
+ const { fade, change } = require_morph.readMorphTimings(pill);
440
+ require_measure.slideInStep(pill, timing.duration, change / (fade + change));
441
+ }
388
442
  });
389
443
  return () => {
390
444
  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 && !inside);
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,60 @@ 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: wheel !== void 0 ? { "--_mp-wheel-length": `${wheel}px` } : void 0,
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
+ useIsomorphicLayoutEffect(() => {
204
+ const row = track.current;
205
+ if (!row) return;
206
+ const vertical = getComputedStyle(row).flexDirection.startsWith("column");
207
+ const now = vertical ? row.offsetHeight : row.offsetWidth;
208
+ const before = length.current;
209
+ length.current = now;
210
+ if (!resizes || before === void 0 || Math.abs(before - now) < .5) return;
211
+ const pill = row.closest("[data-mp=\"pill\"]");
212
+ if (!pill || typeof row.animate !== "function" || prefersReducedMotion()) return;
213
+ if ((row.getAnimations?.() ?? []).some((animation) => animation.id === INSIDE)) return;
214
+ const { change } = readMorphTimings(pill);
215
+ if (change <= 0) return;
216
+ const size = vertical ? "height" : "width";
217
+ const bounds = vertical ? {
218
+ minHeight: "0px",
219
+ maxHeight: "none"
220
+ } : {
221
+ minWidth: "0px",
222
+ maxWidth: "none"
223
+ };
224
+ row.style.overflow = "clip";
225
+ const resize = row.animate([{
226
+ ...bounds,
227
+ [size]: `${before}px`
228
+ }, {
229
+ ...bounds,
230
+ [size]: `${now}px`
231
+ }], {
232
+ id: INSIDE,
233
+ duration: change,
234
+ easing: "ease-in-out"
235
+ });
236
+ const done = () => row.style.removeProperty("overflow");
237
+ resize.finished.then(done, done);
238
+ }, [items]);
239
+ }
240
+ /**
191
241
  * The actions gone from the list, for a moment: the pill shrinks to the new list over them (it clips
192
242
  * them), then they go, fading as it ends. They used to vanish at once, the pill shrinking after.
193
243
  * Only for the pill of actions, not cut short by a wheel (`keep`): a wheel's row scrolls.
@@ -384,7 +434,11 @@ function InsideActions({ host }) {
384
434
  line.animate([closed.divider, closed.divider], hold);
385
435
  const frame = requestAnimationFrame(() => {
386
436
  stopInside(list, line);
387
- playInside(list, line, "in");
437
+ const timing = playInside(list, line, "in")?.effect?.getTiming();
438
+ if (timing && typeof timing.duration === "number") {
439
+ const { fade, change } = readMorphTimings(pill);
440
+ slideInStep(pill, timing.duration, change / (fade + change));
441
+ }
388
442
  });
389
443
  return () => {
390
444
  cancelAnimationFrame(frame);
@@ -24,7 +24,8 @@ const ELECTRON_STYLE = {
24
24
  zIndex: "calc(var(--mp-z-index, 50) - 1)",
25
25
  margin: 0
26
26
  };
27
- const SHIFT = "mp-satellite-shift";
27
+ /** The page's actions held at the size they had while they go into the host (another list laid out already) */
28
+ const HOLD_SIZE = "mp-satellite-hold";
28
29
  /** The room the satellites take beside a horizontal host, as planned (`--_mp-shift-x` applies it, maybe later) */
29
30
  const PLANNED_ROOM = "--_mp-room-x";
30
31
  /** The page's actions' entry among the satellites' presences */
@@ -387,6 +388,7 @@ function SatellitesLayer({ host }) {
387
388
  const [inPanel, setInPanel] = (0, react.useState)(false);
388
389
  if (inPanel && !host.panel) setInPanel(false);
389
390
  const panelTucked = inPanel && host.panel;
391
+ const panelHeld = (0, react.useRef)(false);
390
392
  const comingOut = detached && !!actions && !tucked && !panelTucked && (waits || handoff === "out");
391
393
  const actionsPresence = detached && actions && !tucked && !panelTucked && !waits && handoff !== "out" ? turnPhase.current ? "rest" : "compact" : "hidden";
392
394
  const goingIn = (0, react.useRef)(false);
@@ -664,7 +666,7 @@ function SatellitesLayer({ host }) {
664
666
  },
665
667
  { translate: "0px 0px" }
666
668
  ], {
667
- id: SHIFT,
669
+ id: require_measure.SHIFT,
668
670
  duration: fade + change,
669
671
  easing: "ease-in-out",
670
672
  composite: "add"
@@ -676,7 +678,7 @@ function SatellitesLayer({ host }) {
676
678
  duration: glide
677
679
  };
678
680
  root.animate([{ translate: `${was.x - now.x}px ${was.y - now.y}px` }, { translate: "0px 0px" }], {
679
- id: SHIFT,
681
+ id: require_measure.SHIFT,
680
682
  duration: glide,
681
683
  easing: "ease-in-out",
682
684
  composite: "add"
@@ -701,8 +703,11 @@ function SatellitesLayer({ host }) {
701
703
  const before = root.offsetWidth;
702
704
  root.style.removeProperty("--_mp-shift-x");
703
705
  const after = root.offsetWidth;
704
- if (moving && host.panel && Math.abs(after - before) > .5) root.animate([{ inlineSize: `${before}px` }, { inlineSize: `${after}px` }], {
705
- id: SHIFT,
706
+ if (panelHeld.current) {
707
+ panelHeld.current = false;
708
+ require_morph.replayOpening(root);
709
+ } else if (moving && host.panel && Math.abs(after - before) > .5) root.animate([{ inlineSize: `${before}px` }, { inlineSize: `${after}px` }], {
710
+ id: require_measure.SHIFT,
706
711
  duration: timings.change,
707
712
  easing: "ease-in-out"
708
713
  });
@@ -754,7 +759,21 @@ function SatellitesLayer({ host }) {
754
759
  }, fade + change + 20);
755
760
  } else if (animate && atomOut && was === "compact" && (!settled || moved) && !reduced && !rejoining.current.has(ACTIONS) && !spotHold) {
756
761
  const turnTo = layout.actionsAcross;
762
+ const old = atomPlaced.current;
763
+ const hold = old && typeof atomElement.animate === "function" ? atomElement.animate([0, 1].map(() => ({
764
+ width: `${old.width}px`,
765
+ height: `${old.height}px`,
766
+ minWidth: "0px",
767
+ maxWidth: "none",
768
+ minHeight: "0px",
769
+ maxHeight: "none"
770
+ })), {
771
+ id: HOLD_SIZE,
772
+ duration: 6e4,
773
+ fill: "forwards"
774
+ }) : void 0;
757
775
  rejoin(ACTIONS, atomElement, () => {
776
+ hold?.cancel();
758
777
  presences.current.set(ACTIONS, "hidden");
759
778
  spots.current.delete(ACTIONS);
760
779
  setActionsAcross(turnTo);
@@ -765,7 +784,15 @@ function SatellitesLayer({ host }) {
765
784
  if (turnPhase.current === "closing" && from) {
766
785
  const width = atomElement.offsetWidth;
767
786
  const height = atomElement.offsetHeight;
768
- place(atomElement, vertical ? placement === "right" ? from.left + from.width - width : from.left : from.left + from.width / 2 - width / 2, vertical ? from.top + from.height / 2 - height / 2 : placement.startsWith("bottom") ? from.top + from.height - height : from.top, height, byBottom);
787
+ const left = vertical ? placement === "right" ? from.left + from.width - width : from.left : from.left + from.width / 2 - width / 2;
788
+ const top = vertical ? from.top + from.height / 2 - height / 2 : placement.startsWith("bottom") ? from.top + from.height - height : from.top;
789
+ place(atomElement, left, top, height, byBottom);
790
+ atomPlaced.current = {
791
+ left,
792
+ top,
793
+ width,
794
+ height
795
+ };
769
796
  }
770
797
  if (animate && atomOut && actionsBox.current) {
771
798
  const { wheel } = actionsBox.current;
@@ -805,7 +832,7 @@ function SatellitesLayer({ host }) {
805
832
  turnPhase.current = null;
806
833
  if (moving && Number.isFinite(from.left) && Number.isFinite(from.top) && (Math.abs(from.left - left) > .5 || Math.abs(from.top - top) > .5)) {
807
834
  atomElement.animate([{ translate: `${from.left - left}px ${from.top - top}px` }, { translate: "0px 0px" }], {
808
- id: SHIFT,
835
+ id: require_measure.SHIFT,
809
836
  duration: timings.change,
810
837
  easing: "ease-in-out",
811
838
  composite: "add"
@@ -829,7 +856,7 @@ function SatellitesLayer({ host }) {
829
856
  width: `${width}px`,
830
857
  height: `${height}px`
831
858
  }], {
832
- id: SHIFT,
859
+ id: require_measure.SHIFT,
833
860
  duration: glide,
834
861
  easing: "ease-in-out"
835
862
  });
@@ -859,7 +886,7 @@ function SatellitesLayer({ host }) {
859
886
  to: vertical ? top : left
860
887
  });
861
888
  atomElement.animate([{ translate: `${shift.x}px ${shift.y}px` }, { translate: "0px 0px" }], {
862
- id: SHIFT,
889
+ id: require_measure.SHIFT,
863
890
  duration: glide,
864
891
  easing: "ease-in-out",
865
892
  composite: "add"
@@ -868,25 +895,28 @@ function SatellitesLayer({ host }) {
868
895
  }
869
896
  } else if (animate && !atomOut && (was === "compact" || was === "rest")) {
870
897
  const { fade, exit } = require_measure.durations(atomElement);
871
- const { width: heldWidth, height: heldHeight } = atomElement.getBoundingClientRect();
872
- const holdSize = () => {
898
+ const heldWidth = atomElement.offsetWidth;
899
+ const heldHeight = atomElement.offsetHeight;
900
+ const holdSize = (duration) => {
873
901
  if (reduced || typeof atomElement.animate !== "function" || heldWidth <= 0) return;
874
902
  const size = {
875
903
  width: `${heldWidth}px`,
876
904
  height: `${heldHeight}px`,
877
905
  minWidth: "0px",
878
- maxWidth: "none"
906
+ maxWidth: "none",
907
+ minHeight: "0px",
908
+ maxHeight: "none"
879
909
  };
880
910
  atomElement.animate([size, size], {
881
911
  id: require_goo.SPLIT,
882
- duration: fade + exit,
912
+ duration,
883
913
  fill: "forwards"
884
914
  });
885
915
  };
886
916
  if (styleChanged && host.actionsStyle === "inside" && goingIn.current) {
887
917
  require_handoff.setHandoff(host.store, "in");
888
918
  drop(root, atomElement, "join", fade, exit);
889
- holdSize();
919
+ holdSize(fade + exit);
890
920
  setTimeout(() => {
891
921
  goingIn.current = false;
892
922
  require_handoff.setHandoff(host.store, void 0);
@@ -894,8 +924,9 @@ function SatellitesLayer({ host }) {
894
924
  }, fade + exit + 20);
895
925
  } else if (tucked) bud(root, atomElement, "join", 0, Math.max(exit, fade + require_measure.durations(atomElement).change), hostCentre());
896
926
  else {
897
- drop(root, atomElement, "join", fade, exit);
898
- holdSize();
927
+ drop(root, atomElement, "join", 0, exit);
928
+ holdSize(exit);
929
+ presences.current.set(ACTIONS, "hidden");
899
930
  }
900
931
  spots.current.delete(ACTIONS);
901
932
  }
@@ -935,7 +966,7 @@ function SatellitesLayer({ host }) {
935
966
  const placed = Number.isFinite(from.left) && Number.isFinite(from.top);
936
967
  if (!animate) {
937
968
  if (changedRow && placed && !reduced && typeof element.animate === "function") element.animate([{ translate: `${from.left - box.left}px ${from.top - box.top}px` }, { translate: "0px 0px" }], {
938
- id: SHIFT,
969
+ id: require_measure.SHIFT,
939
970
  duration: timings.change,
940
971
  easing: "ease-in-out",
941
972
  composite: "add"
@@ -955,7 +986,7 @@ function SatellitesLayer({ host }) {
955
986
  to: vertical ? box.top : box.left
956
987
  });
957
988
  element.animate([{ translate: `${from.left - box.left}px ${from.top - box.top}px` }, { translate: "0px 0px" }], {
958
- id: SHIFT,
989
+ id: require_measure.SHIFT,
959
990
  duration: glide,
960
991
  easing: "ease-in-out",
961
992
  composite: "add"
@@ -970,6 +1001,18 @@ function SatellitesLayer({ host }) {
970
1001
  }
971
1002
  }));
972
1003
  if (passing.size > 1) require_goo.playNecks([...passing], timings.change);
1004
+ if (animate && moving && panelTucked && !panelHeld.current && entries.some((entry) => presences.current.get(entry.electron.id) === "compact")) {
1005
+ if (require_morph.holdOpening(root)) {
1006
+ panelHeld.current = true;
1007
+ const { fade, exit } = require_measure.durations(root);
1008
+ setTimeout(() => {
1009
+ if (!panelHeld.current) return;
1010
+ panelHeld.current = false;
1011
+ require_morph.replayOpening(root);
1012
+ }, fade + exit + 200);
1013
+ }
1014
+ }
1015
+ if (!host.panel) panelHeld.current = false;
973
1016
  if (animate && !holding) {
974
1017
  for (const entry of entries) {
975
1018
  const element = elements.current.get(entry.electron.id);
@@ -3,7 +3,7 @@
3
3
  import { useEffect, useReducer, useRef, useState, useSyncExternalStore } from "react";
4
4
  import Pill from "../Pill/Pill.mjs";
5
5
  import { DROPLET, SPLIT, atEdgeOf, atPoint, playNecks, playOrbit } from "../Pill/goo.mjs";
6
- import { MORPH, MOVE, cancel } from "../Pill/morph.mjs";
6
+ import { MORPH, MOVE, cancel, holdOpening, replayOpening } from "../Pill/morph.mjs";
7
7
  import { PillProgress } from "../Pill/PillProgress.mjs";
8
8
  import { findActiveIndex } from "../PillNavbar/matchPath.mjs";
9
9
  import { foldedWidth, openSize, unfoldedWidth } from "../PillNavbar/room.mjs";
@@ -13,7 +13,7 @@ import { prefersReducedMotion } from "../utils/timing.mjs";
13
13
  import { VISUALLY_HIDDEN } from "../utils/visuallyHidden.mjs";
14
14
  import { planSatellites } from "./layout.mjs";
15
15
  import { setHandoff, useHandoff } from "./handoff.mjs";
16
- import { durations, otherPills, toPixels } from "./measure.mjs";
16
+ import { SHIFT, durations, otherPills, toPixels } from "./measure.mjs";
17
17
  import { Orbitals } from "./Orbitals.mjs";
18
18
  import { ActionList, useHostActions } from "./Actions.mjs";
19
19
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
@@ -24,7 +24,8 @@ const ELECTRON_STYLE = {
24
24
  zIndex: "calc(var(--mp-z-index, 50) - 1)",
25
25
  margin: 0
26
26
  };
27
- const SHIFT = "mp-satellite-shift";
27
+ /** The page's actions held at the size they had while they go into the host (another list laid out already) */
28
+ const HOLD_SIZE = "mp-satellite-hold";
28
29
  /** The room the satellites take beside a horizontal host, as planned (`--_mp-shift-x` applies it, maybe later) */
29
30
  const PLANNED_ROOM = "--_mp-room-x";
30
31
  /** The page's actions' entry among the satellites' presences */
@@ -387,6 +388,7 @@ function SatellitesLayer({ host }) {
387
388
  const [inPanel, setInPanel] = useState(false);
388
389
  if (inPanel && !host.panel) setInPanel(false);
389
390
  const panelTucked = inPanel && host.panel;
391
+ const panelHeld = useRef(false);
390
392
  const comingOut = detached && !!actions && !tucked && !panelTucked && (waits || handoff === "out");
391
393
  const actionsPresence = detached && actions && !tucked && !panelTucked && !waits && handoff !== "out" ? turnPhase.current ? "rest" : "compact" : "hidden";
392
394
  const goingIn = useRef(false);
@@ -701,7 +703,10 @@ function SatellitesLayer({ host }) {
701
703
  const before = root.offsetWidth;
702
704
  root.style.removeProperty("--_mp-shift-x");
703
705
  const after = root.offsetWidth;
704
- if (moving && host.panel && Math.abs(after - before) > .5) root.animate([{ inlineSize: `${before}px` }, { inlineSize: `${after}px` }], {
706
+ if (panelHeld.current) {
707
+ panelHeld.current = false;
708
+ replayOpening(root);
709
+ } else if (moving && host.panel && Math.abs(after - before) > .5) root.animate([{ inlineSize: `${before}px` }, { inlineSize: `${after}px` }], {
705
710
  id: SHIFT,
706
711
  duration: timings.change,
707
712
  easing: "ease-in-out"
@@ -754,7 +759,21 @@ function SatellitesLayer({ host }) {
754
759
  }, fade + change + 20);
755
760
  } else if (animate && atomOut && was === "compact" && (!settled || moved) && !reduced && !rejoining.current.has(ACTIONS) && !spotHold) {
756
761
  const turnTo = layout.actionsAcross;
762
+ const old = atomPlaced.current;
763
+ const hold = old && typeof atomElement.animate === "function" ? atomElement.animate([0, 1].map(() => ({
764
+ width: `${old.width}px`,
765
+ height: `${old.height}px`,
766
+ minWidth: "0px",
767
+ maxWidth: "none",
768
+ minHeight: "0px",
769
+ maxHeight: "none"
770
+ })), {
771
+ id: HOLD_SIZE,
772
+ duration: 6e4,
773
+ fill: "forwards"
774
+ }) : void 0;
757
775
  rejoin(ACTIONS, atomElement, () => {
776
+ hold?.cancel();
758
777
  presences.current.set(ACTIONS, "hidden");
759
778
  spots.current.delete(ACTIONS);
760
779
  setActionsAcross(turnTo);
@@ -765,7 +784,15 @@ function SatellitesLayer({ host }) {
765
784
  if (turnPhase.current === "closing" && from) {
766
785
  const width = atomElement.offsetWidth;
767
786
  const height = atomElement.offsetHeight;
768
- place(atomElement, vertical ? placement === "right" ? from.left + from.width - width : from.left : from.left + from.width / 2 - width / 2, vertical ? from.top + from.height / 2 - height / 2 : placement.startsWith("bottom") ? from.top + from.height - height : from.top, height, byBottom);
787
+ const left = vertical ? placement === "right" ? from.left + from.width - width : from.left : from.left + from.width / 2 - width / 2;
788
+ const top = vertical ? from.top + from.height / 2 - height / 2 : placement.startsWith("bottom") ? from.top + from.height - height : from.top;
789
+ place(atomElement, left, top, height, byBottom);
790
+ atomPlaced.current = {
791
+ left,
792
+ top,
793
+ width,
794
+ height
795
+ };
769
796
  }
770
797
  if (animate && atomOut && actionsBox.current) {
771
798
  const { wheel } = actionsBox.current;
@@ -868,25 +895,28 @@ function SatellitesLayer({ host }) {
868
895
  }
869
896
  } else if (animate && !atomOut && (was === "compact" || was === "rest")) {
870
897
  const { fade, exit } = durations(atomElement);
871
- const { width: heldWidth, height: heldHeight } = atomElement.getBoundingClientRect();
872
- const holdSize = () => {
898
+ const heldWidth = atomElement.offsetWidth;
899
+ const heldHeight = atomElement.offsetHeight;
900
+ const holdSize = (duration) => {
873
901
  if (reduced || typeof atomElement.animate !== "function" || heldWidth <= 0) return;
874
902
  const size = {
875
903
  width: `${heldWidth}px`,
876
904
  height: `${heldHeight}px`,
877
905
  minWidth: "0px",
878
- maxWidth: "none"
906
+ maxWidth: "none",
907
+ minHeight: "0px",
908
+ maxHeight: "none"
879
909
  };
880
910
  atomElement.animate([size, size], {
881
911
  id: SPLIT,
882
- duration: fade + exit,
912
+ duration,
883
913
  fill: "forwards"
884
914
  });
885
915
  };
886
916
  if (styleChanged && host.actionsStyle === "inside" && goingIn.current) {
887
917
  setHandoff(host.store, "in");
888
918
  drop(root, atomElement, "join", fade, exit);
889
- holdSize();
919
+ holdSize(fade + exit);
890
920
  setTimeout(() => {
891
921
  goingIn.current = false;
892
922
  setHandoff(host.store, void 0);
@@ -894,8 +924,9 @@ function SatellitesLayer({ host }) {
894
924
  }, fade + exit + 20);
895
925
  } else if (tucked) bud(root, atomElement, "join", 0, Math.max(exit, fade + durations(atomElement).change), hostCentre());
896
926
  else {
897
- drop(root, atomElement, "join", fade, exit);
898
- holdSize();
927
+ drop(root, atomElement, "join", 0, exit);
928
+ holdSize(exit);
929
+ presences.current.set(ACTIONS, "hidden");
899
930
  }
900
931
  spots.current.delete(ACTIONS);
901
932
  }
@@ -970,6 +1001,18 @@ function SatellitesLayer({ host }) {
970
1001
  }
971
1002
  }));
972
1003
  if (passing.size > 1) playNecks([...passing], timings.change);
1004
+ if (animate && moving && panelTucked && !panelHeld.current && entries.some((entry) => presences.current.get(entry.electron.id) === "compact")) {
1005
+ if (holdOpening(root)) {
1006
+ panelHeld.current = true;
1007
+ const { fade, exit } = durations(root);
1008
+ setTimeout(() => {
1009
+ if (!panelHeld.current) return;
1010
+ panelHeld.current = false;
1011
+ replayOpening(root);
1012
+ }, fade + exit + 200);
1013
+ }
1014
+ }
1015
+ if (!host.panel) panelHeld.current = false;
973
1016
  if (animate && !holding) {
974
1017
  for (const entry of entries) {
975
1018
  const element = elements.current.get(entry.electron.id);
@@ -10,6 +10,37 @@ function toPixels(value, element, fallback) {
10
10
  if (match[2] === "em") return amount * (Number.parseFloat(getComputedStyle(element).fontSize) || 16);
11
11
  return amount;
12
12
  }
13
+ /** A satellite's slide along the host's edge, and the host's own as the group re-centres (Satellites.tsx) */
14
+ const SHIFT = "mp-satellite-shift";
15
+ /**
16
+ * Puts the slides that have just started (the host's, and the satellites' beside it: begun less than
17
+ * `fresh` ms ago) on the curve of something that resizes the host and starts now: moving all the way
18
+ * from their first keyframe to their last by `reached` of `duration`, then still. The page's actions
19
+ * opening in the pill (Actions.tsx) start a frame after the slide the group plans for them, and grow
20
+ * on their own curve: the host's far edge went in by 25 px and back, its slide ahead of its growth.
21
+ */
22
+ function slideInStep(host, duration, reached, fresh = 100) {
23
+ const elements = [host, ...document.querySelectorAll("[data-mp=\"pill\"][data-satellite]")];
24
+ for (const element of elements) for (const animation of element.getAnimations?.() ?? []) {
25
+ if (animation.id !== "mp-satellite-shift" || animation.playState !== "running" || Number(animation.currentTime ?? 0) > fresh) continue;
26
+ const effect = animation.effect;
27
+ const frames = effect?.getKeyframes?.();
28
+ if (!effect || !frames || frames.length < 2) continue;
29
+ const first = frames[0].translate;
30
+ const last = frames[frames.length - 1].translate;
31
+ if (first === void 0 || last === void 0) continue;
32
+ effect.setKeyframes([
33
+ { translate: first },
34
+ {
35
+ translate: last,
36
+ offset: reached
37
+ },
38
+ { translate: last }
39
+ ]);
40
+ effect.updateTiming({ duration });
41
+ animation.currentTime = 0;
42
+ }
43
+ }
13
44
  /** A pill's timings, as the stylesheet sets them for it. */
14
45
  function durations(element) {
15
46
  const style = getComputedStyle(element);
@@ -42,6 +73,8 @@ function otherPills(root) {
42
73
  return boxes;
43
74
  }
44
75
 
76
+ exports.SHIFT = SHIFT;
45
77
  exports.durations = durations;
46
78
  exports.otherPills = otherPills;
79
+ exports.slideInStep = slideInStep;
47
80
  exports.toPixels = toPixels;
@@ -10,6 +10,37 @@ function toPixels(value, element, fallback) {
10
10
  if (match[2] === "em") return amount * (Number.parseFloat(getComputedStyle(element).fontSize) || 16);
11
11
  return amount;
12
12
  }
13
+ /** A satellite's slide along the host's edge, and the host's own as the group re-centres (Satellites.tsx) */
14
+ const SHIFT = "mp-satellite-shift";
15
+ /**
16
+ * Puts the slides that have just started (the host's, and the satellites' beside it: begun less than
17
+ * `fresh` ms ago) on the curve of something that resizes the host and starts now: moving all the way
18
+ * from their first keyframe to their last by `reached` of `duration`, then still. The page's actions
19
+ * opening in the pill (Actions.tsx) start a frame after the slide the group plans for them, and grow
20
+ * on their own curve: the host's far edge went in by 25 px and back, its slide ahead of its growth.
21
+ */
22
+ function slideInStep(host, duration, reached, fresh = 100) {
23
+ const elements = [host, ...document.querySelectorAll("[data-mp=\"pill\"][data-satellite]")];
24
+ for (const element of elements) for (const animation of element.getAnimations?.() ?? []) {
25
+ if (animation.id !== "mp-satellite-shift" || animation.playState !== "running" || Number(animation.currentTime ?? 0) > fresh) continue;
26
+ const effect = animation.effect;
27
+ const frames = effect?.getKeyframes?.();
28
+ if (!effect || !frames || frames.length < 2) continue;
29
+ const first = frames[0].translate;
30
+ const last = frames[frames.length - 1].translate;
31
+ if (first === void 0 || last === void 0) continue;
32
+ effect.setKeyframes([
33
+ { translate: first },
34
+ {
35
+ translate: last,
36
+ offset: reached
37
+ },
38
+ { translate: last }
39
+ ]);
40
+ effect.updateTiming({ duration });
41
+ animation.currentTime = 0;
42
+ }
43
+ }
13
44
  /** A pill's timings, as the stylesheet sets them for it. */
14
45
  function durations(element) {
15
46
  const style = getComputedStyle(element);
@@ -42,4 +73,4 @@ function otherPills(root) {
42
73
  return boxes;
43
74
  }
44
75
 
45
- export { durations, otherPills, toPixels };
76
+ export { SHIFT, durations, otherPills, slideInStep, toPixels };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magic-pill",
3
- "version": "9.4.0-next.5",
3
+ "version": "9.4.0-rc.1",
4
4
  "type": "commonjs",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",