magic-pill 9.4.0-next.2 → 9.4.0-next.4

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.
Files changed (51) hide show
  1. package/CHANGELOG.md +38 -2
  2. package/README.md +25 -17
  3. package/dist/MagicPill/MagicPill.d.mts +16 -2
  4. package/dist/MagicPill/MagicPill.d.ts +16 -2
  5. package/dist/MagicPill/MagicPill.js +12 -3
  6. package/dist/MagicPill/MagicPill.mjs +12 -3
  7. package/dist/Pill/Pill.js +1 -0
  8. package/dist/Pill/Pill.mjs +1 -0
  9. package/dist/Pill/goo.js +110 -35
  10. package/dist/Pill/goo.mjs +110 -36
  11. package/dist/Pill/modal.js +3 -1
  12. package/dist/Pill/modal.mjs +3 -1
  13. package/dist/Pill/morph.js +64 -10
  14. package/dist/Pill/morph.mjs +64 -11
  15. package/dist/Pill/zone.js +1 -2
  16. package/dist/Pill/zone.mjs +1 -2
  17. package/dist/PillForm/PillForm.js +6 -1
  18. package/dist/PillForm/PillForm.mjs +7 -2
  19. package/dist/PillForm/dates.js +14 -3
  20. package/dist/PillForm/dates.mjs +14 -3
  21. package/dist/PillForm/room.js +46 -0
  22. package/dist/PillForm/room.mjs +46 -0
  23. package/dist/PillNavbar/PillNavbar.js +3 -1
  24. package/dist/PillNavbar/PillNavbar.mjs +4 -2
  25. package/dist/PillNavbar/room.js +99 -24
  26. package/dist/PillNavbar/room.mjs +98 -25
  27. package/dist/PillNotification/PillNotification.js +2 -4
  28. package/dist/PillNotification/PillNotification.mjs +2 -4
  29. package/dist/PillNotification/RowsBody.js +77 -0
  30. package/dist/PillNotification/RowsBody.mjs +77 -0
  31. package/dist/forms.css +14 -0
  32. package/dist/satellites/Actions.js +181 -6
  33. package/dist/satellites/Actions.mjs +182 -7
  34. package/dist/satellites/Orbitals.js +218 -50
  35. package/dist/satellites/Orbitals.mjs +220 -52
  36. package/dist/satellites/Satellites.js +495 -107
  37. package/dist/satellites/Satellites.mjs +498 -111
  38. package/dist/satellites/handoff.js +36 -0
  39. package/dist/satellites/handoff.mjs +34 -0
  40. package/dist/satellites/layout.js +69 -3
  41. package/dist/satellites/layout.mjs +69 -4
  42. package/dist/satellites/measure.js +22 -0
  43. package/dist/satellites/measure.mjs +22 -1
  44. package/dist/satellites/orbits.js +49 -2
  45. package/dist/satellites/orbits.mjs +47 -3
  46. package/dist/satellites/types.d.mts +15 -1
  47. package/dist/satellites/types.d.ts +15 -1
  48. package/dist/satellites.d.mts +2 -2
  49. package/dist/satellites.d.ts +2 -2
  50. package/dist/styles.css +103 -15
  51. package/package.json +1 -1
@@ -187,6 +187,44 @@ const readSize = (element) => ({
187
187
  width: element.offsetWidth,
188
188
  height: element.offsetHeight
189
189
  });
190
+ /**
191
+ * Its size once what's changing inside it has got there: a label folding as a panel closes is still
192
+ * open when the pill measures where it's going (a transition). Measured then on a copy laid out with
193
+ * no transitions, so the pill goes there in one motion, instead of shrinking, then jumping (or
194
+ * settling in a second step) as the label folds.
195
+ */
196
+ function readSettledSize(element) {
197
+ if (!(typeof CSSTransition !== "undefined" && (element.getAnimations?.({ subtree: true }) ?? []).some((animation) => animation instanceof CSSTransition && animation.effect instanceof KeyframeEffect && animation.effect.target !== element)) || element.tagName === "DIALOG") return readSize(element);
198
+ return onCopy(element, readSize, (copy) => {
199
+ const actions = element.querySelectorAll("[data-mp=\"action\"]");
200
+ copy.querySelectorAll("[data-mp=\"action\"]").forEach((action, index) => {
201
+ if (actions[index]?.matches(":hover, :focus-visible")) action.setAttribute("data-pointed", "");
202
+ });
203
+ });
204
+ }
205
+ /**
206
+ * A copy of the pill laid out next to it as it ends up: hidden, with no transitions nor animations
207
+ * (`[data-mp-measure]`), sharing no id or radio group with it. `read` measures it, then it's gone.
208
+ */
209
+ function onCopy(element, read, prepare) {
210
+ const copy = element.cloneNode(true);
211
+ copy.querySelectorAll("[id], [name]").forEach((node) => {
212
+ node.removeAttribute("id");
213
+ node.removeAttribute("name");
214
+ });
215
+ copy.removeAttribute("id");
216
+ copy.setAttribute("data-mp-measure", "");
217
+ copy.inert = true;
218
+ copy.style.visibility = "hidden";
219
+ copy.style.pointerEvents = "none";
220
+ prepare?.(copy);
221
+ element.after(copy);
222
+ try {
223
+ return read(copy);
224
+ } finally {
225
+ copy.remove();
226
+ }
227
+ }
190
228
  /** Stops the pill's animations with this id (and the ones in it). Returns whether anything ran. */
191
229
  function cancel(element, id, subtree) {
192
230
  let cancelled = false;
@@ -442,7 +480,7 @@ function useSizeMorph(rootRef, presence, enabled, lastSize) {
442
480
  const from = stopMorphs(element) || running.current.length > 0 ? current : lastSize.current;
443
481
  running.current.forEach((animation) => animation.cancel());
444
482
  running.current = [];
445
- const to = readSize(element);
483
+ const to = readSettledSize(element);
446
484
  lastSize.current = to;
447
485
  if (!from) return;
448
486
  const panel = readPanel(element);
@@ -476,7 +514,22 @@ function useSizeMorph(rootRef, presence, enabled, lastSize) {
476
514
  if (animations.length === 0) return;
477
515
  running.current = animations;
478
516
  animations[0].finished.then(() => {
479
- if (running.current === animations) running.current = [];
517
+ if (running.current !== animations) return;
518
+ running.current = [];
519
+ const now = readSize(element);
520
+ if (CLOSED.has(presence) || Math.abs(now.width - to.width) <= 1 && Math.abs(now.height - to.height) <= 1) return;
521
+ lastSize.current = now;
522
+ running.current = [element.animate([{
523
+ width: `${to.width}px`,
524
+ height: `${to.height}px`
525
+ }, {
526
+ width: `${now.width}px`,
527
+ height: `${now.height}px`
528
+ }], {
529
+ id: MORPH,
530
+ duration: timings.change,
531
+ easing: "ease-in-out"
532
+ })];
480
533
  }).catch(() => {});
481
534
  }, [
482
535
  rootRef,
@@ -539,14 +592,14 @@ function animateMove(element, from) {
539
592
  duration: fade + change,
540
593
  easing: EASING
541
594
  };
542
- element.animate([{
543
- translate: shift,
544
- ...resized && sized(from)
545
- }, {
546
- translate: "0px 0px",
547
- ...resized && sized(to)
548
- }], options);
549
- if (resized) hold(options);
595
+ element.animate([{ translate: shift }, { translate: "0px 0px" }], {
596
+ ...options,
597
+ composite: "add"
598
+ });
599
+ if (resized) {
600
+ element.animate([sized(from), sized(to)], options);
601
+ hold(options);
602
+ }
550
603
  }
551
604
  /**
552
605
  * Remembers where the pill is just before its placement changes (React calls
@@ -574,6 +627,7 @@ exports.PlacementWatch = PlacementWatch;
574
627
  exports.animateMove = animateMove;
575
628
  exports.cancel = cancel;
576
629
  exports.captureSwap = captureSwap;
630
+ exports.onCopy = onCopy;
577
631
  exports.planExit = planExit;
578
632
  exports.planMorph = planMorph;
579
633
  exports.planSwap = planSwap;
@@ -187,6 +187,44 @@ const readSize = (element) => ({
187
187
  width: element.offsetWidth,
188
188
  height: element.offsetHeight
189
189
  });
190
+ /**
191
+ * Its size once what's changing inside it has got there: a label folding as a panel closes is still
192
+ * open when the pill measures where it's going (a transition). Measured then on a copy laid out with
193
+ * no transitions, so the pill goes there in one motion, instead of shrinking, then jumping (or
194
+ * settling in a second step) as the label folds.
195
+ */
196
+ function readSettledSize(element) {
197
+ if (!(typeof CSSTransition !== "undefined" && (element.getAnimations?.({ subtree: true }) ?? []).some((animation) => animation instanceof CSSTransition && animation.effect instanceof KeyframeEffect && animation.effect.target !== element)) || element.tagName === "DIALOG") return readSize(element);
198
+ return onCopy(element, readSize, (copy) => {
199
+ const actions = element.querySelectorAll("[data-mp=\"action\"]");
200
+ copy.querySelectorAll("[data-mp=\"action\"]").forEach((action, index) => {
201
+ if (actions[index]?.matches(":hover, :focus-visible")) action.setAttribute("data-pointed", "");
202
+ });
203
+ });
204
+ }
205
+ /**
206
+ * A copy of the pill laid out next to it as it ends up: hidden, with no transitions nor animations
207
+ * (`[data-mp-measure]`), sharing no id or radio group with it. `read` measures it, then it's gone.
208
+ */
209
+ function onCopy(element, read, prepare) {
210
+ const copy = element.cloneNode(true);
211
+ copy.querySelectorAll("[id], [name]").forEach((node) => {
212
+ node.removeAttribute("id");
213
+ node.removeAttribute("name");
214
+ });
215
+ copy.removeAttribute("id");
216
+ copy.setAttribute("data-mp-measure", "");
217
+ copy.inert = true;
218
+ copy.style.visibility = "hidden";
219
+ copy.style.pointerEvents = "none";
220
+ prepare?.(copy);
221
+ element.after(copy);
222
+ try {
223
+ return read(copy);
224
+ } finally {
225
+ copy.remove();
226
+ }
227
+ }
190
228
  /** Stops the pill's animations with this id (and the ones in it). Returns whether anything ran. */
191
229
  function cancel(element, id, subtree) {
192
230
  let cancelled = false;
@@ -442,7 +480,7 @@ function useSizeMorph(rootRef, presence, enabled, lastSize) {
442
480
  const from = stopMorphs(element) || running.current.length > 0 ? current : lastSize.current;
443
481
  running.current.forEach((animation) => animation.cancel());
444
482
  running.current = [];
445
- const to = readSize(element);
483
+ const to = readSettledSize(element);
446
484
  lastSize.current = to;
447
485
  if (!from) return;
448
486
  const panel = readPanel(element);
@@ -476,7 +514,22 @@ function useSizeMorph(rootRef, presence, enabled, lastSize) {
476
514
  if (animations.length === 0) return;
477
515
  running.current = animations;
478
516
  animations[0].finished.then(() => {
479
- if (running.current === animations) running.current = [];
517
+ if (running.current !== animations) return;
518
+ running.current = [];
519
+ const now = readSize(element);
520
+ if (CLOSED.has(presence) || Math.abs(now.width - to.width) <= 1 && Math.abs(now.height - to.height) <= 1) return;
521
+ lastSize.current = now;
522
+ running.current = [element.animate([{
523
+ width: `${to.width}px`,
524
+ height: `${to.height}px`
525
+ }, {
526
+ width: `${now.width}px`,
527
+ height: `${now.height}px`
528
+ }], {
529
+ id: MORPH,
530
+ duration: timings.change,
531
+ easing: "ease-in-out"
532
+ })];
480
533
  }).catch(() => {});
481
534
  }, [
482
535
  rootRef,
@@ -539,14 +592,14 @@ function animateMove(element, from) {
539
592
  duration: fade + change,
540
593
  easing: EASING
541
594
  };
542
- element.animate([{
543
- translate: shift,
544
- ...resized && sized(from)
545
- }, {
546
- translate: "0px 0px",
547
- ...resized && sized(to)
548
- }], options);
549
- if (resized) hold(options);
595
+ element.animate([{ translate: shift }, { translate: "0px 0px" }], {
596
+ ...options,
597
+ composite: "add"
598
+ });
599
+ if (resized) {
600
+ element.animate([sized(from), sized(to)], options);
601
+ hold(options);
602
+ }
550
603
  }
551
604
  /**
552
605
  * Remembers where the pill is just before its placement changes (React calls
@@ -565,4 +618,4 @@ var PlacementWatch = class extends Component {
565
618
  }
566
619
  };
567
620
 
568
- export { EASING, EXIT, ExitWatch, MORPH, MOVE, PlacementWatch, animateMove, cancel, captureSwap, planExit, planMorph, planSwap, playSwap, readMorphTimings, useSizeMorph };
621
+ export { EASING, EXIT, ExitWatch, MORPH, MOVE, PlacementWatch, animateMove, cancel, captureSwap, onCopy, planExit, planMorph, planSwap, playSwap, readMorphTimings, useSizeMorph };
package/dist/Pill/zone.js CHANGED
@@ -120,8 +120,7 @@ function useZone(rootRef, zone, presence) {
120
120
  return () => {
121
121
  observer?.disconnect();
122
122
  rungs.splice(rungs.indexOf(rung), 1);
123
- element.style.removeProperty(SHIFTS.x);
124
- element.style.removeProperty(SHIFTS.y);
123
+ element.style.removeProperty(axisOf(zone).shift);
125
124
  arrange(zone, () => travel(element));
126
125
  };
127
126
  }, [rootRef, zone]);
@@ -120,8 +120,7 @@ function useZone(rootRef, zone, presence) {
120
120
  return () => {
121
121
  observer?.disconnect();
122
122
  rungs.splice(rungs.indexOf(rung), 1);
123
- element.style.removeProperty(SHIFTS.x);
124
- element.style.removeProperty(SHIFTS.y);
123
+ element.style.removeProperty(axisOf(zone).shift);
125
124
  arrange(zone, () => travel(element));
126
125
  };
127
126
  }, [rootRef, zone]);
@@ -5,7 +5,9 @@ const require_glyphs = require("./glyphs.js");
5
5
  const require_send = require("./send.js");
6
6
  const require_FormContext = require("./FormContext.js");
7
7
  const require_keyboard = require("./keyboard.js");
8
+ const require_room = require("./room.js");
8
9
  const require_PillContext = require("../Pill/PillContext.js");
10
+ const require_react = require("../utils/react.js");
9
11
  let react_jsx_runtime = require("react/jsx-runtime");
10
12
 
11
13
  // src/PillForm/PillForm.tsx
@@ -24,11 +26,14 @@ const PillForm = (0, react.forwardRef)(function PillForm({ look, layout, errors
24
26
  errors,
25
27
  isBusy
26
28
  ]);
29
+ const formRef = (0, react.useRef)(null);
30
+ require_room.useFormRoom(formRef);
31
+ const refs = (0, react.useMemo)(() => require_react.mergeRefs(ref, formRef), [ref]);
27
32
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_FormContext.FormContext.Provider, {
28
33
  value: context,
29
34
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("form", {
30
35
  ...rest,
31
- ref,
36
+ ref: refs,
32
37
  "data-mp": "form",
33
38
  "data-look": look,
34
39
  "data-failed": sending.failure ? "" : void 0,
@@ -1,11 +1,13 @@
1
1
  "use client";
2
2
 
3
- import { forwardRef, useMemo } from "react";
3
+ import { forwardRef, useMemo, useRef } from "react";
4
4
  import { AlertGlyph } from "./glyphs.mjs";
5
5
  import { useSend } from "./send.mjs";
6
6
  import { FormContext } from "./FormContext.mjs";
7
7
  import { useKeyboard } from "./keyboard.mjs";
8
+ import { useFormRoom } from "./room.mjs";
8
9
  import { useInternalPill } from "../Pill/PillContext.mjs";
10
+ import { mergeRefs } from "../utils/react.mjs";
9
11
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
10
12
 
11
13
  // src/PillForm/PillForm.tsx
@@ -24,11 +26,14 @@ const PillForm = forwardRef(function PillForm({ look, layout, errors = "inline",
24
26
  errors,
25
27
  isBusy
26
28
  ]);
29
+ const formRef = useRef(null);
30
+ useFormRoom(formRef);
31
+ const refs = useMemo(() => mergeRefs(ref, formRef), [ref]);
27
32
  return /* @__PURE__ */ jsx(FormContext.Provider, {
28
33
  value: context,
29
34
  children: /* @__PURE__ */ jsx("form", {
30
35
  ...rest,
31
- ref,
36
+ ref: refs,
32
37
  "data-mp": "form",
33
38
  "data-look": look,
34
39
  "data-failed": sending.failure ? "" : void 0,
@@ -112,7 +112,18 @@ const FORMATS = {
112
112
  timeStyle: "short"
113
113
  }
114
114
  };
115
- /** A value, as it's written there. */
115
+ /**
116
+ * Starts with a capital, as a label does: some languages write their days and
117
+ * months in lowercase ("jeudi 24 décembre", "décembre 2026"), which reads as
118
+ * a broken label once it stands alone in a field or a calendar.
119
+ */
120
+ function asLabel(text, locale) {
121
+ const first = text.codePointAt(0);
122
+ if (first === void 0) return text;
123
+ const letter = String.fromCodePoint(first);
124
+ return letter.toLocaleUpperCase(locale) + text.slice(letter.length);
125
+ }
126
+ /** A value, as it's written there, starting with a capital. */
116
127
  function formatValue(value, type, locale, options) {
117
128
  if (!value) return "";
118
129
  const formatter = new Intl.DateTimeFormat(locale, {
@@ -127,13 +138,13 @@ function formatValue(value, type, locale, options) {
127
138
  if (type === "week") {
128
139
  const monday = parseDay(day);
129
140
  const sunday = parseDay(addDays(day, 6));
130
- return monday && sunday ? formatter.formatRange(monday, sunday) : value;
141
+ return monday && sunday ? asLabel(formatter.formatRange(monday, sunday), locale) : value;
131
142
  }
132
143
  const date = parseDay(day || "2000-01-01");
133
144
  if (!date || !day && type !== "time") return value;
134
145
  const [hours, minutes] = timeOf(value, type).split(":").map(Number);
135
146
  date.setUTCHours(hours || 0, minutes || 0);
136
- return formatter.format(date);
147
+ return asLabel(formatter.format(date), locale);
137
148
  }
138
149
 
139
150
  exports.addDays = addDays;
@@ -112,7 +112,18 @@ const FORMATS = {
112
112
  timeStyle: "short"
113
113
  }
114
114
  };
115
- /** A value, as it's written there. */
115
+ /**
116
+ * Starts with a capital, as a label does: some languages write their days and
117
+ * months in lowercase ("jeudi 24 décembre", "décembre 2026"), which reads as
118
+ * a broken label once it stands alone in a field or a calendar.
119
+ */
120
+ function asLabel(text, locale) {
121
+ const first = text.codePointAt(0);
122
+ if (first === void 0) return text;
123
+ const letter = String.fromCodePoint(first);
124
+ return letter.toLocaleUpperCase(locale) + text.slice(letter.length);
125
+ }
126
+ /** A value, as it's written there, starting with a capital. */
116
127
  function formatValue(value, type, locale, options) {
117
128
  if (!value) return "";
118
129
  const formatter = new Intl.DateTimeFormat(locale, {
@@ -127,13 +138,13 @@ function formatValue(value, type, locale, options) {
127
138
  if (type === "week") {
128
139
  const monday = parseDay(day);
129
140
  const sunday = parseDay(addDays(day, 6));
130
- return monday && sunday ? formatter.formatRange(monday, sunday) : value;
141
+ return monday && sunday ? asLabel(formatter.formatRange(monday, sunday), locale) : value;
131
142
  }
132
143
  const date = parseDay(day || "2000-01-01");
133
144
  if (!date || !day && type !== "time") return value;
134
145
  const [hours, minutes] = timeOf(value, type).split(":").map(Number);
135
146
  date.setUTCHours(hours || 0, minutes || 0);
136
- return formatter.format(date);
147
+ return asLabel(formatter.format(date), locale);
137
148
  }
138
149
 
139
150
  export { addDays, addMonths, dayOf, firstDayOfWeek, formatDay, formatValue, isDayOutside, isOutside, localFirstDay, monthGrid, monthOf, parseDay, timeOf, toValue, today, usesTwelveHours, weekOf };
@@ -0,0 +1,46 @@
1
+ "use client";
2
+
3
+ let react = require("react");
4
+
5
+ // src/PillForm/room.ts
6
+ /** A field narrower than this has no room to type in, in rem */
7
+ const LEAST = 9;
8
+ function useFormRoom(formRef) {
9
+ (0, react.useEffect)(() => {
10
+ const form = formRef.current;
11
+ if (!form || form.parentElement?.getAttribute("data-mp") !== "pill") return;
12
+ let open = 0;
13
+ const update = () => {
14
+ const pill = form.parentElement;
15
+ const field = form.querySelector("[data-mp=\"field\"]");
16
+ const submit = form.querySelector("[data-mp=\"action\"][type=\"submit\"][data-expanded]");
17
+ if (!field || !submit) return form.removeAttribute("data-tight");
18
+ const least = LEAST * (Number.parseFloat(getComputedStyle(document.documentElement).fontSize) || 16);
19
+ const max = Number.parseFloat(getComputedStyle(pill).maxInlineSize);
20
+ let room = Number.isFinite(max) ? max - pill.offsetWidth : Number.POSITIVE_INFINITY;
21
+ const container = pill.parentElement;
22
+ if (pill.dataset.placement === "inline" && container) {
23
+ const style = getComputedStyle(container);
24
+ const inside = container.clientWidth - (Number.parseFloat(style.paddingLeft) || 0) - (Number.parseFloat(style.paddingRight) || 0);
25
+ room = Math.min(room, inside - pill.offsetWidth);
26
+ }
27
+ const could = field.offsetWidth + Math.max(0, room);
28
+ if (!form.hasAttribute("data-tight")) {
29
+ if (could >= least) return;
30
+ open = submit.offsetWidth;
31
+ form.setAttribute("data-tight", "");
32
+ } else if (could - Math.max(0, open - submit.offsetWidth) >= least + 1) form.removeAttribute("data-tight");
33
+ };
34
+ update();
35
+ const sizes = typeof ResizeObserver === "undefined" ? void 0 : new ResizeObserver(update);
36
+ sizes?.observe(form);
37
+ window.addEventListener("resize", update);
38
+ return () => {
39
+ sizes?.disconnect();
40
+ window.removeEventListener("resize", update);
41
+ form.removeAttribute("data-tight");
42
+ };
43
+ }, [formRef]);
44
+ }
45
+
46
+ exports.useFormRoom = useFormRoom;
@@ -0,0 +1,46 @@
1
+ "use client";
2
+
3
+ import { useEffect } from "react";
4
+
5
+ // src/PillForm/room.ts
6
+ /** A field narrower than this has no room to type in, in rem */
7
+ const LEAST = 9;
8
+ function useFormRoom(formRef) {
9
+ useEffect(() => {
10
+ const form = formRef.current;
11
+ if (!form || form.parentElement?.getAttribute("data-mp") !== "pill") return;
12
+ let open = 0;
13
+ const update = () => {
14
+ const pill = form.parentElement;
15
+ const field = form.querySelector("[data-mp=\"field\"]");
16
+ const submit = form.querySelector("[data-mp=\"action\"][type=\"submit\"][data-expanded]");
17
+ if (!field || !submit) return form.removeAttribute("data-tight");
18
+ const least = LEAST * (Number.parseFloat(getComputedStyle(document.documentElement).fontSize) || 16);
19
+ const max = Number.parseFloat(getComputedStyle(pill).maxInlineSize);
20
+ let room = Number.isFinite(max) ? max - pill.offsetWidth : Number.POSITIVE_INFINITY;
21
+ const container = pill.parentElement;
22
+ if (pill.dataset.placement === "inline" && container) {
23
+ const style = getComputedStyle(container);
24
+ const inside = container.clientWidth - (Number.parseFloat(style.paddingLeft) || 0) - (Number.parseFloat(style.paddingRight) || 0);
25
+ room = Math.min(room, inside - pill.offsetWidth);
26
+ }
27
+ const could = field.offsetWidth + Math.max(0, room);
28
+ if (!form.hasAttribute("data-tight")) {
29
+ if (could >= least) return;
30
+ open = submit.offsetWidth;
31
+ form.setAttribute("data-tight", "");
32
+ } else if (could - Math.max(0, open - submit.offsetWidth) >= least + 1) form.removeAttribute("data-tight");
33
+ };
34
+ update();
35
+ const sizes = typeof ResizeObserver === "undefined" ? void 0 : new ResizeObserver(update);
36
+ sizes?.observe(form);
37
+ window.addEventListener("resize", update);
38
+ return () => {
39
+ sizes?.disconnect();
40
+ window.removeEventListener("resize", update);
41
+ form.removeAttribute("data-tight");
42
+ };
43
+ }, [formRef]);
44
+ }
45
+
46
+ export { useFormRoom };
@@ -7,6 +7,7 @@ const require_PillPanel = require("../Pill/PillPanel.js");
7
7
  const require_matchPath = require("./matchPath.js");
8
8
  const require_room = require("./room.js");
9
9
  const require_react = require("../utils/react.js");
10
+ const require_PillContext = require("../Pill/PillContext.js");
10
11
  let react_jsx_runtime = require("react/jsx-runtime");
11
12
 
12
13
  // src/PillNavbar/PillNavbar.tsx
@@ -30,7 +31,8 @@ const isLink = (item) => item.href !== void 0;
30
31
  const PillNavbar = (0, react.forwardRef)(function PillNavbar({ items, pathname, linkComponent, labels = "auto", "aria-label": ariaLabel = "Main", ...rest }, forwardedRef) {
31
32
  const navRef = (0, react.useRef)(null);
32
33
  const ref = (0, react.useMemo)(() => require_react.mergeRefs(navRef, forwardedRef), [forwardedRef]);
33
- require_room.useRoom(navRef, labels);
34
+ const presence = (0, react.useContext)(require_PillContext.PillContext)?.presence;
35
+ require_room.useRoom(navRef, labels, presence);
34
36
  const locationPathname = useLocationPathname(pathname === void 0);
35
37
  const links = items.filter(isLink);
36
38
  const active = links[require_matchPath.findActiveIndex(pathname ?? locationPathname, links)];
@@ -1,12 +1,13 @@
1
1
  "use client";
2
2
 
3
- import { forwardRef, useEffect, useMemo, useRef, useState } from "react";
3
+ import { forwardRef, useContext, useEffect, useMemo, useRef, useState } from "react";
4
4
  import { PillActions } from "../Pill/parts.mjs";
5
5
  import PillAction from "../Pill/PillAction.mjs";
6
6
  import { PillPanelTrigger } from "../Pill/PillPanel.mjs";
7
7
  import { findActiveIndex } from "./matchPath.mjs";
8
8
  import { useRoom } from "./room.mjs";
9
9
  import { mergeRefs } from "../utils/react.mjs";
10
+ import { PillContext } from "../Pill/PillContext.mjs";
10
11
  import { jsx } from "react/jsx-runtime";
11
12
 
12
13
  // src/PillNavbar/PillNavbar.tsx
@@ -30,7 +31,8 @@ const isLink = (item) => item.href !== void 0;
30
31
  const PillNavbar = forwardRef(function PillNavbar({ items, pathname, linkComponent, labels = "auto", "aria-label": ariaLabel = "Main", ...rest }, forwardedRef) {
31
32
  const navRef = useRef(null);
32
33
  const ref = useMemo(() => mergeRefs(navRef, forwardedRef), [forwardedRef]);
33
- useRoom(navRef, labels);
34
+ const presence = useContext(PillContext)?.presence;
35
+ useRoom(navRef, labels, presence);
34
36
  const locationPathname = useLocationPathname(pathname === void 0);
35
37
  const links = items.filter(isLink);
36
38
  const active = links[findActiveIndex(pathname ?? locationPathname, links)];