magic-pill 9.4.0-rc.2 → 9.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [9.4.0] - 2026-12-05
6
+ The Electron, in beta (`magic-pill/satellites`): electrons, their orbitals and the page's actions around the pill. Also a navbar that folds its label when the pill has no room for it, `--mp-radius`, `PillProgress`, and a sidebar's flag that comes out as a droplet. Nothing to change in your code.
7
+
5
8
  ### Added
6
9
  - `--mp-focus-ring`: the keyboard focus ring's colour on the pill's actions, electrons and orbitals
7
10
  - `--mp-radius`: the pill's corners (half the one-line pill's height by default). Smaller gives a rounded rectangle at any size, a sidebar or a toolbox included; a pill closed to a circle, an electron and its orbitals stay round
@@ -76,7 +79,7 @@
76
79
  - 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
80
  - 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
81
  - 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
82
+ - **Beta:** leaving a page, its actions keep their size as they close to a circle and go into the pill: they turned into a circle in one frame first
80
83
  - **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
84
  - **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
85
  - **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
@@ -89,6 +92,9 @@
89
92
  - **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
93
  - **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
94
  - **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
95
+ - **Beta:** the page's actions going to the other side of the pill (their side changed, or another list) close to a circle at the pill's level first, then go in, as everywhere else: they shrank as a pill, at their own proportions
96
+ - **Beta:** the page's actions in the pill, moving to its other side (`actionsSide`), fold away where they are, the pill shrinking with them, then open on the other side: they vanished at once, then opened there
97
+ - **Beta:** a panel closing: the satellites come out of the pill once, at their spot beside it as it will be. Planned beside the closing panel's height, they came out of its top edge, went back into the pill, and came out again
92
98
 
93
99
  ### Changed
94
100
  - **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
package/README.md CHANGED
@@ -24,13 +24,13 @@ On top of it come ready-made **templates** (a notification, a navbar, a form pan
24
24
  - [X] Anything inside: messages, icons and panels are React content; build your own templates from the same parts
25
25
  - [X] Shape-changing animations (circle ↔ pill ↔ panel) at the pill's real size, notifications that slide into each other, a pill that travels when its placement changes, all respecting reduced motion
26
26
  - [X] Notifications laid out the way the pill is: in one row, in rows, and in a sidebar as cards or as a flag out of its edge
27
- - [X] **Beta:** the Electron, a small round pill that splits out of the main one to keep a background activity (a timer, an upload) in reach anywhere in the app (optional)
27
+ - [X] **Beta:** the Electron, a small round pill that splits out of the main one to keep a background activity (a timer, an upload) in reach anywhere in the app, with its quick actions fanned out around it; and the page's own actions next to the pill (optional)
28
28
  - [X] Forms: fields on native controls, in a panel or in the pill, validated by the browser, and a calendar (optional)
29
29
  - [X] Themes (optional): glass and Liquid Glass, with refraction, a pointer light and adaptive tinting, or a theme of your own from the tokens
30
30
  - [X] Accessible: screen reader announcements, keyboard focus pauses the countdown, focus handling for panels and modals
31
31
  - [X] Works in any React 18+ app, including React Server Components (Next.js App Router), with any router
32
32
  - [X] Styles you can override without `!important`, design tokens, no fonts loaded behind your back
33
- - [X] Tiny: the quick start adds about **20 kB gzipped** to your app (16 kB of JavaScript + 4.4 kB of CSS, minified by your bundler), checked in CI. Unused parts are tree-shaken.
33
+ - [X] Tiny: the quick start adds about **22 kB gzipped** to your app (17.4 kB of JavaScript + 4.6 kB of CSS, minified by your bundler), checked in CI; the Electron's optional entry about 20 kB more. Unused parts are tree-shaken.
34
34
  - [X] Written in TypeScript, zero runtime dependencies
35
35
 
36
36
  ## Installation
@@ -270,7 +270,7 @@ A sidebar's notifications are pills like the others: it turns horizontal for the
270
270
  **A flag** (`notificationLayout="flag"`, `left`/`right` sidebars) leaves the sidebar where it is, usable: the notification comes out of its edge as a pill of its own (`[data-layout="flag"]`), next to the section it's about (`at`), and goes back into it. Pointing at it or focusing it pauses it; the next one slides in it, and it moves to its own section. Its panel opens beside the sidebar, in the middle of the screen. It comes out of the sidebar's edge as a droplet, as an electron does (drawn out small on a neck, growing to its size as it comes free, then showing its content), and goes back into it the same way played backwards: `--mp-duration-split` and `--mp-duration-join` time it, `--mp-ease-split` can pick another curve (`bouncy`, `pop`, `smooth` or any CSS easing), `--mp-goo` how sticky it is (`0`: no neck), `--mp-electron-start` the size it starts at.
271
271
 
272
272
  ## The Electron (beta)
273
- A small round pill that splits out of the host to keep a background activity in reach while the person goes elsewhere in the app: a timer, a call, an upload. It's tucked into the pill on the page that started it, and comes out as a droplet (with the goo, like a sidebar's flag) anywhere else; a tap goes back to that page. **Beta:** it ships in `9.4.0-next` releases, and its API may still change.
273
+ A small round pill that splits out of the host to keep a background activity in reach while the person goes elsewhere in the app: a timer, a call, an upload. It's tucked into the pill on the page that started it, and comes out as a droplet (with the goo, like a sidebar's flag) anywhere else; a tap goes back to that page. **Beta** since 9.4.0: its API may still change in a minor version.
274
274
 
275
275
  It's optional: import `satellites` and give it to the host, with the current path.
276
276
 
@@ -378,6 +378,8 @@ export function InboxPage() {
378
378
 
379
379
  Short of room, the actions turn across first (`"auto"`, or show what fits with `actionsWheel`), then the farthest ones go beside the pill: the last electrons, then the first electron and the actions, the nearer of them last. They slide with the group as it changes (gathered or spread, another one coming or going).
380
380
 
381
+ They go into the host and come out of it as a circle: their icons fade, they close to a circle at the pill's level (a column beside a bottom pill closes down to it), then the circle goes in. Leaving their page, the pill waits for them before it takes the next page's shape; a panel with no room for them beside it waits for them before it opens. Coming out, a circle opens to their pill, then their icons show. Changing sides, they go in and come out on the other side the same way; in the pill, they fold away on one side before they open on the other.
382
+
381
383
  ## The primitive
382
384
  Everything above is built from `<Pill>` and its parts, and you can use them directly. A `<Pill>` you write yourself isn't connected to `pill()`: you control it with props.
383
385
 
@@ -414,6 +416,7 @@ Any other prop (`className`, `aria-label`, `ref`…) goes to the element.
414
416
  - `PillIcon`: the leading icon. Decorative unless you give it a `label`.
415
417
  - `PillDivider`: the thin line after the icon.
416
418
  - `PillMessage`: the message, in the italic serif.
419
+ - `PillProgress`: a progress ring around a value or an icon, in the text colour (`--mp-progress-size`, `--mp-progress-width`).
417
420
  - `PillActions` and `PillAction`: round buttons. `label` is required: it's the accessible name, and it shows on hover, on focus, with `expanded`, or at the `expanded` level. A `PillAction` is a `<button>` with `onClick`, or a link with `href` (through `linkComponent` if you pass one).
418
421
  - `PillPanel` and `PillPanelTrigger`: content shown at the `panel` level, and the action that opens it. The panel takes the focus when it opens, closes on Escape or with its close button (`closeLabel`, `closeIcon`, and `closeExpanded` to always show the label), and gives the focus back to the trigger. `titleAction` goes at the end of the title's row and `footer` before the close button, which is then quieter (an outline, `--mp-close`). **Several panels in one pill:** give each a `name`, and its trigger the same `panel`.
419
422
 
@@ -762,7 +765,7 @@ import { MagicPill, PillOptics } from "magic-pill";
762
765
  - **Safe links:** links only render relative, `http(s):`, `mailto:` and `tel:` URLs. Anything else, such as `javascript:`, renders without a link (with a warning in development). React 18 doesn't block those URLs by itself.
763
766
 
764
767
  ## TypeScript
765
- Everything is typed, and every component's props are exported as `<Component>Props` (`MagicPillProps`, `PillProps`, `PillFormPanelProps`, `PillInputProps`…). The other main types are `NotifyOptions`, `NotifyInput`, `PillController`, `PillPresence`, `PillPlacement`, `PillVariant`, `PillTheme`, `NotificationLayout`, `NavItem`, `LinkComponent` and `SendHandler`.
768
+ Everything is typed, and every component's props are exported as `<Component>Props` (`MagicPillProps`, `PillProps`, `PillFormPanelProps`, `PillInputProps`…). The other main types are `NotifyOptions`, `NotifyInput`, `PillController`, `PillPresence`, `PillPlacement`, `PillVariant`, `PillTheme`, `NotificationLayout`, `NavItem`, `LinkComponent` and `SendHandler`. For the Electron (beta): `ElectronOptions`, `Orbital` and `PillActionItem`, and from `magic-pill/satellites`, `PillSatellites` and the host props' values (`ActionsStyle`, `ActionsSide`, `ElectronSide`…).
766
769
 
767
770
  ## Build your own
768
771
  Maybe what I brought to the table wasn't enough but you like the idea behind it, that's why Magic Pill is under [MIT License](https://www.tldrlegal.com/license/mit-license), which means you can pretty much do whatever you want and build upon my own version of Magic Pill to bring it to new heights or just make it your own.
@@ -809,10 +812,11 @@ Magic Pill is distributed under the [MIT License](https://www.tldrlegal.com/lice
809
812
  ## What's next?
810
813
  | Coming next | Done in 9.x |
811
814
  |-----------|-----------|
812
- | The Electron: a small circle that splits off the pill to keep an activity (a timer, a call, an upload) within reach | A documentation site with live examples |
813
- | Toolbox and carousel indicator templates | Themes: glass, Liquid Glass, your own |
814
- | More layouts for vertical pills | Forms and a calendar |
815
- | Performance presets for the glass | Notification layouts: rows, cards, flags |
816
- | Usage from a CDN | Pills that share a spot line up instead of overlapping |
815
+ | Smoother motion on every device, and a lighter, cleaner core | **Beta:** the Electron, its orbitals and the page's actions |
816
+ | Carousel indicator templates | A documentation site with live examples |
817
+ | More layouts for vertical pills | Themes: glass, Liquid Glass, your own |
818
+ | Performance presets for the glass | Forms and a calendar |
819
+ | Usage from a CDN | Notification layouts: rows, cards, flags |
820
+ | | Pills that share a spot line up instead of overlapping |
817
821
  | | Animated morphing between contents, panels and placements, through the circle |
818
822
  | | Any icon (any React content), actions with `onClick` or `href`, full documentation, tests |
@@ -300,13 +300,16 @@ const MagicPill = (0, react.forwardRef)(function MagicPill({ name = "main", chil
300
300
  avoidPills,
301
301
  actionsLabel
302
302
  } : void 0;
303
- const inside = satellites && satelliteHost ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(satellites.Inside, { host: satelliteHost }) : null;
303
+ const inside = (side) => satellites && satelliteHost ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(satellites.Inside, {
304
+ host: satelliteHost,
305
+ side
306
+ }) : null;
304
307
  const renderScene = (shownScene) => {
305
308
  switch (shownScene.kind) {
306
309
  case "base": return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react.Fragment, { children: [
307
- actionsSide !== "end" && inside,
310
+ inside("start"),
308
311
  lastScenes.current.get(shownScene.key)?.children ?? lastBase.current,
309
- actionsSide === "end" && inside
312
+ inside("end")
310
313
  ] }, shownScene.key);
311
314
  case "idle": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_parts.PillIcon, { children: idleIcon });
312
315
  case "notification": {
@@ -300,13 +300,16 @@ const MagicPill = forwardRef(function MagicPill({ name = "main", children, scene
300
300
  avoidPills,
301
301
  actionsLabel
302
302
  } : void 0;
303
- const inside = satellites && satelliteHost ? /* @__PURE__ */ jsx(satellites.Inside, { host: satelliteHost }) : null;
303
+ const inside = (side) => satellites && satelliteHost ? /* @__PURE__ */ jsx(satellites.Inside, {
304
+ host: satelliteHost,
305
+ side
306
+ }) : null;
304
307
  const renderScene = (shownScene) => {
305
308
  switch (shownScene.kind) {
306
309
  case "base": return /* @__PURE__ */ jsxs(Fragment, { children: [
307
- actionsSide !== "end" && inside,
310
+ inside("start"),
308
311
  lastScenes.current.get(shownScene.key)?.children ?? lastBase.current,
309
- actionsSide === "end" && inside
312
+ inside("end")
310
313
  ] }, shownScene.key);
311
314
  case "idle": return /* @__PURE__ */ jsx(PillIcon, { children: idleIcon });
312
315
  case "notification": {
@@ -398,9 +398,12 @@ const stopInside = (...elements) => {
398
398
  * the pill, they wait for their own pill to go back into it; switching away, their own pill waits
399
399
  * for them to have gone (handoff.ts).
400
400
  */
401
- function InsideActions({ host }) {
401
+ function InsideActions({ host, side }) {
402
402
  const items = useHostActions(host);
403
403
  const handoff = require_handoff.useHandoff(host.store);
404
+ const placeOf = (actionsSide) => actionsSide === "end" ? "end" : "start";
405
+ const here = side ?? placeOf(host.actionsSide);
406
+ const mine = placeOf(host.actionsSide) === here;
404
407
  const inside = host.actionsStyle === "inside";
405
408
  const [style, setStyle] = (0, react.useState)(host.actionsStyle);
406
409
  const [waiting, setWaiting] = (0, react.useState)(false);
@@ -412,7 +415,17 @@ function InsideActions({ host }) {
412
415
  (0, react.useEffect)(() => {
413
416
  if (waiting) setWaiting(false);
414
417
  }, [waiting]);
415
- const wanted = inside && handoff !== "in" && !waits ? items : null;
418
+ const [sideSeen, setSideSeen] = (0, react.useState)(host.actionsSide);
419
+ const [sideWaiting, setSideWaiting] = (0, react.useState)(false);
420
+ const sideWaits = sideSeen !== host.actionsSide ? inside && mine && placeOf(sideSeen) !== here && !!items : sideWaiting;
421
+ if (sideSeen !== host.actionsSide) {
422
+ setSideSeen(host.actionsSide);
423
+ setSideWaiting(sideWaits);
424
+ }
425
+ (0, react.useEffect)(() => {
426
+ if (sideWaiting) setSideWaiting(false);
427
+ }, [sideWaiting]);
428
+ const wanted = inside && mine && handoff !== "in" && handoff !== "side" && !waits && !sideWaits ? items : null;
416
429
  const [shown, setShown] = (0, react.useState)(wanted);
417
430
  if (wanted && wanted !== shown) setShown(wanted);
418
431
  const listed = wanted ?? shown;
@@ -420,12 +433,13 @@ function InsideActions({ host }) {
420
433
  const divider = (0, react.useRef)(null);
421
434
  const store = host.store;
422
435
  const handingOut = leaving && !inside && !!items;
436
+ const movingOver = leaving && inside && !mine && !!items;
423
437
  const open = !!listed && !leaving;
424
438
  const sideOf = () => {
425
439
  const line = divider.current;
426
440
  return {
427
441
  line,
428
- list: (host.actionsSide === "end" ? line?.nextElementSibling : line?.previousElementSibling) ?? null
442
+ list: (here === "end" ? line?.nextElementSibling : line?.previousElementSibling) ?? null
429
443
  };
430
444
  };
431
445
  require_react.useIsomorphicLayoutEffect(() => {
@@ -458,12 +472,13 @@ function InsideActions({ host }) {
458
472
  require_react.useIsomorphicLayoutEffect(() => {
459
473
  if (!leaving) return;
460
474
  if (handingOut) require_handoff.setHandoff(store, "out");
475
+ if (movingOver) require_handoff.setHandoff(store, "side");
461
476
  const { line, list } = sideOf();
462
477
  let cancelled = false;
463
478
  const gone = () => {
464
479
  if (cancelled) return;
465
480
  setShown(null);
466
- if (require_handoff.getHandoff(store) === "out") require_handoff.setHandoff(store, void 0);
481
+ if (require_handoff.getHandoff(store) === "out" || require_handoff.getHandoff(store) === "side") require_handoff.setHandoff(store, void 0);
467
482
  };
468
483
  stopInside(list, line);
469
484
  const animation = list && line ? playInside(list, line, "out") : void 0;
@@ -473,7 +488,7 @@ function InsideActions({ host }) {
473
488
  cancelled = true;
474
489
  stopInside(list, line);
475
490
  list?.style.removeProperty("overflow");
476
- if (require_handoff.getHandoff(store) === "out") require_handoff.setHandoff(store, void 0);
491
+ if (require_handoff.getHandoff(store) === "out" || require_handoff.getHandoff(store) === "side") require_handoff.setHandoff(store, void 0);
477
492
  };
478
493
  }, [leaving]);
479
494
  if (!listed) return null;
@@ -487,7 +502,7 @@ function InsideActions({ host }) {
487
502
  ref: divider,
488
503
  "data-leaving": leaving ? "" : void 0
489
504
  });
490
- return host.actionsSide === "end" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [line, list] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [list, line] });
505
+ return here === "end" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [line, list] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [list, line] });
491
506
  }
492
507
 
493
508
  exports.ActionList = ActionList;
@@ -398,9 +398,12 @@ const stopInside = (...elements) => {
398
398
  * the pill, they wait for their own pill to go back into it; switching away, their own pill waits
399
399
  * for them to have gone (handoff.ts).
400
400
  */
401
- function InsideActions({ host }) {
401
+ function InsideActions({ host, side }) {
402
402
  const items = useHostActions(host);
403
403
  const handoff = useHandoff(host.store);
404
+ const placeOf = (actionsSide) => actionsSide === "end" ? "end" : "start";
405
+ const here = side ?? placeOf(host.actionsSide);
406
+ const mine = placeOf(host.actionsSide) === here;
404
407
  const inside = host.actionsStyle === "inside";
405
408
  const [style, setStyle] = useState(host.actionsStyle);
406
409
  const [waiting, setWaiting] = useState(false);
@@ -412,7 +415,17 @@ function InsideActions({ host }) {
412
415
  useEffect(() => {
413
416
  if (waiting) setWaiting(false);
414
417
  }, [waiting]);
415
- const wanted = inside && handoff !== "in" && !waits ? items : null;
418
+ const [sideSeen, setSideSeen] = useState(host.actionsSide);
419
+ const [sideWaiting, setSideWaiting] = useState(false);
420
+ const sideWaits = sideSeen !== host.actionsSide ? inside && mine && placeOf(sideSeen) !== here && !!items : sideWaiting;
421
+ if (sideSeen !== host.actionsSide) {
422
+ setSideSeen(host.actionsSide);
423
+ setSideWaiting(sideWaits);
424
+ }
425
+ useEffect(() => {
426
+ if (sideWaiting) setSideWaiting(false);
427
+ }, [sideWaiting]);
428
+ const wanted = inside && mine && handoff !== "in" && handoff !== "side" && !waits && !sideWaits ? items : null;
416
429
  const [shown, setShown] = useState(wanted);
417
430
  if (wanted && wanted !== shown) setShown(wanted);
418
431
  const listed = wanted ?? shown;
@@ -420,12 +433,13 @@ function InsideActions({ host }) {
420
433
  const divider = useRef(null);
421
434
  const store = host.store;
422
435
  const handingOut = leaving && !inside && !!items;
436
+ const movingOver = leaving && inside && !mine && !!items;
423
437
  const open = !!listed && !leaving;
424
438
  const sideOf = () => {
425
439
  const line = divider.current;
426
440
  return {
427
441
  line,
428
- list: (host.actionsSide === "end" ? line?.nextElementSibling : line?.previousElementSibling) ?? null
442
+ list: (here === "end" ? line?.nextElementSibling : line?.previousElementSibling) ?? null
429
443
  };
430
444
  };
431
445
  useIsomorphicLayoutEffect(() => {
@@ -458,12 +472,13 @@ function InsideActions({ host }) {
458
472
  useIsomorphicLayoutEffect(() => {
459
473
  if (!leaving) return;
460
474
  if (handingOut) setHandoff(store, "out");
475
+ if (movingOver) setHandoff(store, "side");
461
476
  const { line, list } = sideOf();
462
477
  let cancelled = false;
463
478
  const gone = () => {
464
479
  if (cancelled) return;
465
480
  setShown(null);
466
- if (getHandoff(store) === "out") setHandoff(store, void 0);
481
+ if (getHandoff(store) === "out" || getHandoff(store) === "side") setHandoff(store, void 0);
467
482
  };
468
483
  stopInside(list, line);
469
484
  const animation = list && line ? playInside(list, line, "out") : void 0;
@@ -473,7 +488,7 @@ function InsideActions({ host }) {
473
488
  cancelled = true;
474
489
  stopInside(list, line);
475
490
  list?.style.removeProperty("overflow");
476
- if (getHandoff(store) === "out") setHandoff(store, void 0);
491
+ if (getHandoff(store) === "out" || getHandoff(store) === "side") setHandoff(store, void 0);
477
492
  };
478
493
  }, [leaving]);
479
494
  if (!listed) return null;
@@ -487,7 +502,7 @@ function InsideActions({ host }) {
487
502
  ref: divider,
488
503
  "data-leaving": leaving ? "" : void 0
489
504
  });
490
- return host.actionsSide === "end" ? /* @__PURE__ */ jsxs(Fragment$1, { children: [line, list] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [list, line] });
505
+ return here === "end" ? /* @__PURE__ */ jsxs(Fragment$1, { children: [line, list] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [list, line] });
491
506
  }
492
507
 
493
508
  export { ActionList, InsideActions, useActionsWheel, useHostActions, usePillActions };
@@ -158,6 +158,22 @@ function settlesIn(root) {
158
158
  return left;
159
159
  }
160
160
  /**
161
+ * The host's height once its morph is over (a panel closing, ms after the satellites come out): they're
162
+ * planned beside the host as it will be. From its height as drawn, the ones coming out above a closing
163
+ * panel came out of its top edge, waited there, then went back in and out again at their spot once it
164
+ * had shrunk (round 5, V6).
165
+ */
166
+ function settledHeight(root) {
167
+ for (const animation of root.getAnimations?.() ?? []) {
168
+ if (animation.id !== "mp-morph" || animation.playState !== "running") continue;
169
+ const frames = animation.effect?.getKeyframes?.() ?? [];
170
+ const last = frames[frames.length - 1];
171
+ const height = Number.parseFloat(String(last?.height ?? ""));
172
+ if (Number.isFinite(height) && height > 0) return height;
173
+ }
174
+ return root.offsetHeight;
175
+ }
176
+ /**
161
177
  * Places a satellite, fixed: beside a host at the bottom of the screen, held by its bottom edge as the
162
178
  * host is. Safari's toolbar moves the host as the page scrolls (or as a new page comes): they move
163
179
  * with it at once, with no pass. Held by their top, they stayed where they were, under the address
@@ -443,6 +459,8 @@ function SatellitesLayer({ host }) {
443
459
  const gap = require_measure.toPixels(style.getPropertyValue("--mp-electron-gap"), root, Number.parseFloat(style.columnGap) || 16);
444
460
  const offset = require_measure.toPixels(style.getPropertyValue("--_mp-offset"), root, 24);
445
461
  const out = entries.filter((entry) => entry.presence !== "hidden" && elements.current.get(entry.electron.id));
462
+ const hostHeight = vertical ? root.offsetHeight : settledHeight(root);
463
+ const hostTop = placement.startsWith("bottom") ? root.offsetTop + root.offsetHeight - hostHeight : root.offsetTop;
446
464
  if (animate && !vertical) {
447
465
  hostMin.current = require_room.foldedWidth(root);
448
466
  hostOpen.current = require_room.unfoldedWidth(root);
@@ -475,12 +493,12 @@ function SatellitesLayer({ host }) {
475
493
  },
476
494
  host: squeezed ? alignedBox(root, placement, vertical, style.direction === "rtl", {
477
495
  width: hostMin.current,
478
- height: root.offsetHeight
496
+ height: hostHeight
479
497
  }) : {
480
498
  left: root.offsetLeft,
481
- top: root.offsetTop,
499
+ top: hostTop,
482
500
  width: root.offsetWidth,
483
- height: root.offsetHeight
501
+ height: hostHeight
484
502
  },
485
503
  hostMin: vertical ? void 0 : hostMin.current,
486
504
  placement,
@@ -502,11 +520,11 @@ function SatellitesLayer({ host }) {
502
520
  const canFold = !vertical && open !== void 0 && least !== void 0 && least < open - .5;
503
521
  const openBox = canFold ? alignedBox(root, placement, vertical, rtl, {
504
522
  width: open,
505
- height: root.offsetHeight
523
+ height: hostHeight
506
524
  }) : void 0;
507
525
  const foldedBox = canFold ? alignedBox(root, placement, vertical, rtl, {
508
526
  width: least,
509
- height: root.offsetHeight
527
+ height: hostHeight
510
528
  }) : void 0;
511
529
  const asOpen = canFold ? require_layout.planSatellites({
512
530
  ...input,
@@ -534,7 +552,7 @@ function SatellitesLayer({ host }) {
534
552
  if (whole > 0) {
535
553
  panelBox = alignedBox(root, placement, vertical, rtl, {
536
554
  width: whole,
537
- height: root.offsetHeight
555
+ height: hostHeight
538
556
  });
539
557
  panelPlan = require_layout.planSatellites({
540
558
  ...input,
@@ -579,7 +597,7 @@ function SatellitesLayer({ host }) {
579
597
  actions: actionsInput(detached && !!actions && !!atomElement)
580
598
  }) : layout;
581
599
  if (animate && host.actionsStyle === "inside") {
582
- const track = root.querySelector("[data-mp=\"actions\"][data-inside]");
600
+ const track = root.querySelector("[data-mp=\"actions\"][data-inside]:not([data-leaving])");
583
601
  if (track) {
584
602
  const hostLength = hostOpen.current ?? (hostMin.current !== void 0 ? Math.min(root.offsetWidth, hostMin.current) : void 0);
585
603
  const length = host.actionsWheel ? insideWheelLength(track, root, vertical, mainRoom(vertical, offset) - layout.reserve, hostLength, vertical ? void 0 : require_room.foldedWidth(root, { content: true })) : void 0;
@@ -611,9 +629,9 @@ function SatellitesLayer({ host }) {
611
629
  const spotOf = (box) => `${alongOf(box) < hostAlong ? "before" : "after"} ${rowOf(box)}`;
612
630
  const hostAt = () => ({
613
631
  left: root.offsetLeft + (vertical ? 0 : applied.current.shift),
614
- top: root.offsetTop + (vertical ? applied.current.shift : 0),
632
+ top: hostTop + (vertical ? applied.current.shift : 0),
615
633
  width: root.offsetWidth,
616
- height: root.offsetHeight
634
+ height: hostHeight
617
635
  });
618
636
  const along = !vertical && trip === layout ? plannedHost : void 0;
619
637
  const splitAt = () => along ? {
@@ -793,13 +811,19 @@ function SatellitesLayer({ host }) {
793
811
  duration: 6e4,
794
812
  fill: "forwards"
795
813
  }) : void 0;
796
- rejoin(ACTIONS, atomElement, () => {
814
+ const timings = require_measure.durations(atomElement);
815
+ const closing = require_circle.closingTime(timings);
816
+ rejoining.current.add(ACTIONS);
817
+ drop(root, atomElement, "join", closing, timings.exit, void 0, void 0, 0, require_circle.circleSpot(level));
818
+ require_circle.closeToCircle(atomElement, old?.width ?? atomElement.offsetWidth, old?.height ?? atomElement.offsetHeight, timings.exit, level, timings);
819
+ setTimeout(() => {
820
+ rejoining.current.delete(ACTIONS);
797
821
  hold?.cancel();
798
822
  presences.current.set(ACTIONS, "hidden");
799
823
  spots.current.delete(ACTIONS);
800
824
  setActionsAcross(turnTo);
801
825
  refresh();
802
- });
826
+ }, closing + timings.exit + 20);
803
827
  } else if (animate && atomOut && !settled && !rejoining.current.has(ACTIONS) && !spotHold) setActionsAcross(layout.actionsAcross);
804
828
  const from = turnFrom.current;
805
829
  if (turnPhase.current === "closing" && from) {
@@ -1165,4 +1189,5 @@ function SatellitesLayer({ host }) {
1165
1189
 
1166
1190
  exports.SatellitesLayer = SatellitesLayer;
1167
1191
  exports.drop = drop;
1192
+ exports.settledHeight = settledHeight;
1168
1193
  exports.settlesIn = settlesIn;
@@ -158,6 +158,22 @@ function settlesIn(root) {
158
158
  return left;
159
159
  }
160
160
  /**
161
+ * The host's height once its morph is over (a panel closing, ms after the satellites come out): they're
162
+ * planned beside the host as it will be. From its height as drawn, the ones coming out above a closing
163
+ * panel came out of its top edge, waited there, then went back in and out again at their spot once it
164
+ * had shrunk (round 5, V6).
165
+ */
166
+ function settledHeight(root) {
167
+ for (const animation of root.getAnimations?.() ?? []) {
168
+ if (animation.id !== "mp-morph" || animation.playState !== "running") continue;
169
+ const frames = animation.effect?.getKeyframes?.() ?? [];
170
+ const last = frames[frames.length - 1];
171
+ const height = Number.parseFloat(String(last?.height ?? ""));
172
+ if (Number.isFinite(height) && height > 0) return height;
173
+ }
174
+ return root.offsetHeight;
175
+ }
176
+ /**
161
177
  * Places a satellite, fixed: beside a host at the bottom of the screen, held by its bottom edge as the
162
178
  * host is. Safari's toolbar moves the host as the page scrolls (or as a new page comes): they move
163
179
  * with it at once, with no pass. Held by their top, they stayed where they were, under the address
@@ -443,6 +459,8 @@ function SatellitesLayer({ host }) {
443
459
  const gap = toPixels(style.getPropertyValue("--mp-electron-gap"), root, Number.parseFloat(style.columnGap) || 16);
444
460
  const offset = toPixels(style.getPropertyValue("--_mp-offset"), root, 24);
445
461
  const out = entries.filter((entry) => entry.presence !== "hidden" && elements.current.get(entry.electron.id));
462
+ const hostHeight = vertical ? root.offsetHeight : settledHeight(root);
463
+ const hostTop = placement.startsWith("bottom") ? root.offsetTop + root.offsetHeight - hostHeight : root.offsetTop;
446
464
  if (animate && !vertical) {
447
465
  hostMin.current = foldedWidth(root);
448
466
  hostOpen.current = unfoldedWidth(root);
@@ -475,12 +493,12 @@ function SatellitesLayer({ host }) {
475
493
  },
476
494
  host: squeezed ? alignedBox(root, placement, vertical, style.direction === "rtl", {
477
495
  width: hostMin.current,
478
- height: root.offsetHeight
496
+ height: hostHeight
479
497
  }) : {
480
498
  left: root.offsetLeft,
481
- top: root.offsetTop,
499
+ top: hostTop,
482
500
  width: root.offsetWidth,
483
- height: root.offsetHeight
501
+ height: hostHeight
484
502
  },
485
503
  hostMin: vertical ? void 0 : hostMin.current,
486
504
  placement,
@@ -502,11 +520,11 @@ function SatellitesLayer({ host }) {
502
520
  const canFold = !vertical && open !== void 0 && least !== void 0 && least < open - .5;
503
521
  const openBox = canFold ? alignedBox(root, placement, vertical, rtl, {
504
522
  width: open,
505
- height: root.offsetHeight
523
+ height: hostHeight
506
524
  }) : void 0;
507
525
  const foldedBox = canFold ? alignedBox(root, placement, vertical, rtl, {
508
526
  width: least,
509
- height: root.offsetHeight
527
+ height: hostHeight
510
528
  }) : void 0;
511
529
  const asOpen = canFold ? planSatellites({
512
530
  ...input,
@@ -534,7 +552,7 @@ function SatellitesLayer({ host }) {
534
552
  if (whole > 0) {
535
553
  panelBox = alignedBox(root, placement, vertical, rtl, {
536
554
  width: whole,
537
- height: root.offsetHeight
555
+ height: hostHeight
538
556
  });
539
557
  panelPlan = planSatellites({
540
558
  ...input,
@@ -579,7 +597,7 @@ function SatellitesLayer({ host }) {
579
597
  actions: actionsInput(detached && !!actions && !!atomElement)
580
598
  }) : layout;
581
599
  if (animate && host.actionsStyle === "inside") {
582
- const track = root.querySelector("[data-mp=\"actions\"][data-inside]");
600
+ const track = root.querySelector("[data-mp=\"actions\"][data-inside]:not([data-leaving])");
583
601
  if (track) {
584
602
  const hostLength = hostOpen.current ?? (hostMin.current !== void 0 ? Math.min(root.offsetWidth, hostMin.current) : void 0);
585
603
  const length = host.actionsWheel ? insideWheelLength(track, root, vertical, mainRoom(vertical, offset) - layout.reserve, hostLength, vertical ? void 0 : foldedWidth(root, { content: true })) : void 0;
@@ -611,9 +629,9 @@ function SatellitesLayer({ host }) {
611
629
  const spotOf = (box) => `${alongOf(box) < hostAlong ? "before" : "after"} ${rowOf(box)}`;
612
630
  const hostAt = () => ({
613
631
  left: root.offsetLeft + (vertical ? 0 : applied.current.shift),
614
- top: root.offsetTop + (vertical ? applied.current.shift : 0),
632
+ top: hostTop + (vertical ? applied.current.shift : 0),
615
633
  width: root.offsetWidth,
616
- height: root.offsetHeight
634
+ height: hostHeight
617
635
  });
618
636
  const along = !vertical && trip === layout ? plannedHost : void 0;
619
637
  const splitAt = () => along ? {
@@ -793,13 +811,19 @@ function SatellitesLayer({ host }) {
793
811
  duration: 6e4,
794
812
  fill: "forwards"
795
813
  }) : void 0;
796
- rejoin(ACTIONS, atomElement, () => {
814
+ const timings = durations(atomElement);
815
+ const closing = closingTime(timings);
816
+ rejoining.current.add(ACTIONS);
817
+ drop(root, atomElement, "join", closing, timings.exit, void 0, void 0, 0, circleSpot(level));
818
+ closeToCircle(atomElement, old?.width ?? atomElement.offsetWidth, old?.height ?? atomElement.offsetHeight, timings.exit, level, timings);
819
+ setTimeout(() => {
820
+ rejoining.current.delete(ACTIONS);
797
821
  hold?.cancel();
798
822
  presences.current.set(ACTIONS, "hidden");
799
823
  spots.current.delete(ACTIONS);
800
824
  setActionsAcross(turnTo);
801
825
  refresh();
802
- });
826
+ }, closing + timings.exit + 20);
803
827
  } else if (animate && atomOut && !settled && !rejoining.current.has(ACTIONS) && !spotHold) setActionsAcross(layout.actionsAcross);
804
828
  const from = turnFrom.current;
805
829
  if (turnPhase.current === "closing" && from) {
@@ -1163,4 +1187,4 @@ function SatellitesLayer({ host }) {
1163
1187
  ] });
1164
1188
  }
1165
1189
 
1166
- export { SatellitesLayer, drop, settlesIn };
1190
+ export { SatellitesLayer, drop, settledHeight, settlesIn };
@@ -73,7 +73,9 @@ export interface PillSatellites {
73
73
  host: SatelliteHost;
74
74
  }>;
75
75
  /** The page's actions in the pill itself, after a divider (`actionsStyle="inside"`) */
76
+ /** `side`: which of its two places in the pill this one is (before the content, or after it) */
76
77
  Inside: ComponentType<{
77
78
  host: SatelliteHost;
79
+ side?: "start" | "end";
78
80
  }>;
79
81
  }
@@ -73,7 +73,9 @@ export interface PillSatellites {
73
73
  host: SatelliteHost;
74
74
  }>;
75
75
  /** The page's actions in the pill itself, after a divider (`actionsStyle="inside"`) */
76
+ /** `side`: which of its two places in the pill this one is (before the content, or after it) */
76
77
  Inside: ComponentType<{
77
78
  host: SatelliteHost;
79
+ side?: "start" | "end";
78
80
  }>;
79
81
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magic-pill",
3
- "version": "9.4.0-rc.2",
3
+ "version": "9.4.0",
4
4
  "type": "commonjs",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",