magic-pill 9.4.0-rc.1 → 9.4.0-rc.3

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
@@ -76,7 +76,7 @@
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
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
79
+ - **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
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
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
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
@@ -85,6 +85,13 @@
85
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
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
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
92
+ - **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
93
+ - **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
94
+ - **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
88
95
 
89
96
  ### Changed
90
97
  - **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: displayed.presence === "panel",
280
+ panel: wantsPanel,
281
+ holdPanel,
264
282
  linkComponent,
265
283
  variant,
266
284
  theme: rest.theme,
@@ -282,13 +300,16 @@ const MagicPill = (0, react.forwardRef)(function MagicPill({ name = "main", chil
282
300
  avoidPills,
283
301
  actionsLabel
284
302
  } : void 0;
285
- 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;
286
307
  const renderScene = (shownScene) => {
287
308
  switch (shownScene.kind) {
288
309
  case "base": return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react.Fragment, { children: [
289
- actionsSide !== "end" && inside,
310
+ inside("start"),
290
311
  lastScenes.current.get(shownScene.key)?.children ?? lastBase.current,
291
- actionsSide === "end" && inside
312
+ inside("end")
292
313
  ] }, shownScene.key);
293
314
  case "idle": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_parts.PillIcon, { children: idleIcon });
294
315
  case "notification": {
@@ -330,7 +351,7 @@ const MagicPill = (0, react.forwardRef)(function MagicPill({ name = "main", chil
330
351
  "--_mp-sidebar-width": `${sidebarWidth.current}px`
331
352
  } : rest.style,
332
353
  variant: sceneVariant,
333
- presence: displayed.presence,
354
+ presence: pillPresence,
334
355
  onPresenceChange: presenceHandler(displayedRef, setDisplayed),
335
356
  onPointerEnter: (event) => {
336
357
  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: displayed.presence === "panel",
280
+ panel: wantsPanel,
281
+ holdPanel,
264
282
  linkComponent,
265
283
  variant,
266
284
  theme: rest.theme,
@@ -282,13 +300,16 @@ const MagicPill = forwardRef(function MagicPill({ name = "main", children, scene
282
300
  avoidPills,
283
301
  actionsLabel
284
302
  } : void 0;
285
- 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;
286
307
  const renderScene = (shownScene) => {
287
308
  switch (shownScene.kind) {
288
309
  case "base": return /* @__PURE__ */ jsxs(Fragment, { children: [
289
- actionsSide !== "end" && inside,
310
+ inside("start"),
290
311
  lastScenes.current.get(shownScene.key)?.children ?? lastBase.current,
291
- actionsSide === "end" && inside
312
+ inside("end")
292
313
  ] }, shownScene.key);
293
314
  case "idle": return /* @__PURE__ */ jsx(PillIcon, { children: idleIcon });
294
315
  case "notification": {
@@ -330,7 +351,7 @@ const MagicPill = forwardRef(function MagicPill({ name = "main", children, scene
330
351
  "--_mp-sidebar-width": `${sidebarWidth.current}px`
331
352
  } : rest.style,
332
353
  variant: sceneVariant,
333
- presence: displayed.presence,
354
+ presence: pillPresence,
334
355
  onPresenceChange: presenceHandler(displayedRef, setDisplayed),
335
356
  onPointerEnter: (event) => {
336
357
  onPointerEnter?.(event);
@@ -440,44 +440,6 @@ 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
- /**
481
443
  * Animates the pill's size on each presence change. Off for `unstyled` pills,
482
444
  * with reduced motion, and where the Web Animations API is missing.
483
445
  */
@@ -665,12 +627,10 @@ exports.PlacementWatch = PlacementWatch;
665
627
  exports.animateMove = animateMove;
666
628
  exports.cancel = cancel;
667
629
  exports.captureSwap = captureSwap;
668
- exports.holdOpening = holdOpening;
669
630
  exports.onCopy = onCopy;
670
631
  exports.planExit = planExit;
671
632
  exports.planMorph = planMorph;
672
633
  exports.planSwap = planSwap;
673
634
  exports.playSwap = playSwap;
674
635
  exports.readMorphTimings = readMorphTimings;
675
- exports.replayOpening = replayOpening;
676
636
  exports.useSizeMorph = useSizeMorph;
@@ -440,44 +440,6 @@ 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
- /**
481
443
  * Animates the pill's size on each presence change. Off for `unstyled` pills,
482
444
  * with reduced motion, and where the Web Animations API is missing.
483
445
  */
@@ -656,4 +618,4 @@ var PlacementWatch = class extends Component {
656
618
  }
657
619
  };
658
620
 
659
- export { EASING, EXIT, ExitWatch, MORPH, MOVE, PlacementWatch, animateMove, cancel, captureSwap, holdOpening, onCopy, planExit, planMorph, planSwap, playSwap, readMorphTimings, replayOpening, useSizeMorph };
621
+ export { EASING, EXIT, ExitWatch, MORPH, MOVE, PlacementWatch, animateMove, cancel, captureSwap, onCopy, planExit, planMorph, planSwap, playSwap, readMorphTimings, useSizeMorph };
@@ -200,6 +200,15 @@ const keyOf = (item) => item.id ?? item.label;
200
200
  */
201
201
  function useInsideResize(items, track, resizes) {
202
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]);
203
212
  require_react.useIsomorphicLayoutEffect(() => {
204
213
  const row = track.current;
205
214
  if (!row) return;
@@ -389,9 +398,12 @@ const stopInside = (...elements) => {
389
398
  * the pill, they wait for their own pill to go back into it; switching away, their own pill waits
390
399
  * for them to have gone (handoff.ts).
391
400
  */
392
- function InsideActions({ host }) {
401
+ function InsideActions({ host, side }) {
393
402
  const items = useHostActions(host);
394
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;
395
407
  const inside = host.actionsStyle === "inside";
396
408
  const [style, setStyle] = (0, react.useState)(host.actionsStyle);
397
409
  const [waiting, setWaiting] = (0, react.useState)(false);
@@ -403,7 +415,17 @@ function InsideActions({ host }) {
403
415
  (0, react.useEffect)(() => {
404
416
  if (waiting) setWaiting(false);
405
417
  }, [waiting]);
406
- 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;
407
429
  const [shown, setShown] = (0, react.useState)(wanted);
408
430
  if (wanted && wanted !== shown) setShown(wanted);
409
431
  const listed = wanted ?? shown;
@@ -411,12 +433,13 @@ function InsideActions({ host }) {
411
433
  const divider = (0, react.useRef)(null);
412
434
  const store = host.store;
413
435
  const handingOut = leaving && !inside && !!items;
436
+ const movingOver = leaving && inside && !mine && !!items;
414
437
  const open = !!listed && !leaving;
415
438
  const sideOf = () => {
416
439
  const line = divider.current;
417
440
  return {
418
441
  line,
419
- list: (host.actionsSide === "end" ? line?.nextElementSibling : line?.previousElementSibling) ?? null
442
+ list: (here === "end" ? line?.nextElementSibling : line?.previousElementSibling) ?? null
420
443
  };
421
444
  };
422
445
  require_react.useIsomorphicLayoutEffect(() => {
@@ -449,12 +472,13 @@ function InsideActions({ host }) {
449
472
  require_react.useIsomorphicLayoutEffect(() => {
450
473
  if (!leaving) return;
451
474
  if (handingOut) require_handoff.setHandoff(store, "out");
475
+ if (movingOver) require_handoff.setHandoff(store, "side");
452
476
  const { line, list } = sideOf();
453
477
  let cancelled = false;
454
478
  const gone = () => {
455
479
  if (cancelled) return;
456
480
  setShown(null);
457
- 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);
458
482
  };
459
483
  stopInside(list, line);
460
484
  const animation = list && line ? playInside(list, line, "out") : void 0;
@@ -464,7 +488,7 @@ function InsideActions({ host }) {
464
488
  cancelled = true;
465
489
  stopInside(list, line);
466
490
  list?.style.removeProperty("overflow");
467
- 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);
468
492
  };
469
493
  }, [leaving]);
470
494
  if (!listed) return null;
@@ -478,7 +502,7 @@ function InsideActions({ host }) {
478
502
  ref: divider,
479
503
  "data-leaving": leaving ? "" : void 0
480
504
  });
481
- 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] });
482
506
  }
483
507
 
484
508
  exports.ActionList = ActionList;
@@ -200,6 +200,15 @@ const keyOf = (item) => item.id ?? item.label;
200
200
  */
201
201
  function useInsideResize(items, track, resizes) {
202
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]);
203
212
  useIsomorphicLayoutEffect(() => {
204
213
  const row = track.current;
205
214
  if (!row) return;
@@ -389,9 +398,12 @@ const stopInside = (...elements) => {
389
398
  * the pill, they wait for their own pill to go back into it; switching away, their own pill waits
390
399
  * for them to have gone (handoff.ts).
391
400
  */
392
- function InsideActions({ host }) {
401
+ function InsideActions({ host, side }) {
393
402
  const items = useHostActions(host);
394
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;
395
407
  const inside = host.actionsStyle === "inside";
396
408
  const [style, setStyle] = useState(host.actionsStyle);
397
409
  const [waiting, setWaiting] = useState(false);
@@ -403,7 +415,17 @@ function InsideActions({ host }) {
403
415
  useEffect(() => {
404
416
  if (waiting) setWaiting(false);
405
417
  }, [waiting]);
406
- 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;
407
429
  const [shown, setShown] = useState(wanted);
408
430
  if (wanted && wanted !== shown) setShown(wanted);
409
431
  const listed = wanted ?? shown;
@@ -411,12 +433,13 @@ function InsideActions({ host }) {
411
433
  const divider = useRef(null);
412
434
  const store = host.store;
413
435
  const handingOut = leaving && !inside && !!items;
436
+ const movingOver = leaving && inside && !mine && !!items;
414
437
  const open = !!listed && !leaving;
415
438
  const sideOf = () => {
416
439
  const line = divider.current;
417
440
  return {
418
441
  line,
419
- list: (host.actionsSide === "end" ? line?.nextElementSibling : line?.previousElementSibling) ?? null
442
+ list: (here === "end" ? line?.nextElementSibling : line?.previousElementSibling) ?? null
420
443
  };
421
444
  };
422
445
  useIsomorphicLayoutEffect(() => {
@@ -449,12 +472,13 @@ function InsideActions({ host }) {
449
472
  useIsomorphicLayoutEffect(() => {
450
473
  if (!leaving) return;
451
474
  if (handingOut) setHandoff(store, "out");
475
+ if (movingOver) setHandoff(store, "side");
452
476
  const { line, list } = sideOf();
453
477
  let cancelled = false;
454
478
  const gone = () => {
455
479
  if (cancelled) return;
456
480
  setShown(null);
457
- if (getHandoff(store) === "out") setHandoff(store, void 0);
481
+ if (getHandoff(store) === "out" || getHandoff(store) === "side") setHandoff(store, void 0);
458
482
  };
459
483
  stopInside(list, line);
460
484
  const animation = list && line ? playInside(list, line, "out") : void 0;
@@ -464,7 +488,7 @@ function InsideActions({ host }) {
464
488
  cancelled = true;
465
489
  stopInside(list, line);
466
490
  list?.style.removeProperty("overflow");
467
- if (getHandoff(store) === "out") setHandoff(store, void 0);
491
+ if (getHandoff(store) === "out" || getHandoff(store) === "side") setHandoff(store, void 0);
468
492
  };
469
493
  }, [leaving]);
470
494
  if (!listed) return null;
@@ -478,7 +502,7 @@ function InsideActions({ host }) {
478
502
  ref: divider,
479
503
  "data-leaving": leaving ? "" : void 0
480
504
  });
481
- 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] });
482
506
  }
483
507
 
484
508
  export { ActionList, InsideActions, useActionsWheel, useHostActions, usePillActions };