@blakesteve/roster 5.18.0 → 5.19.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.
@@ -1,40 +1,40 @@
1
1
  "use client";
2
- import { jsxs as l, Fragment as Z, jsx as n } from "react/jsx-runtime";
3
- import * as s from "react";
4
- import { Description as O } from "../../../node_modules/@headlessui/react/dist/components/description/description.js";
5
- import { Dialog as tt, DialogBackdrop as et, DialogPanel as rt, DialogTitle as st } from "../../../node_modules/@headlessui/react/dist/components/dialog/dialog.js";
6
- import { TransitionChild as nt } from "../../../node_modules/@headlessui/react/dist/components/transition/transition.js";
7
- import { cn as d } from "../../../lib/utils.js";
8
- import { withLabels as ot } from "../../../lib/labels.js";
9
- import { useDarkScope as at } from "../../../internal/popup.js";
10
- import { useReducedMotion as it } from "../../../internal/motion.js";
11
- import { lockPage as ct } from "../../../internal/page-inert.js";
12
- import { useLeaveWatchdog as ut } from "../../../internal/leave-watchdog.js";
13
- import { sheetDragOutcome as lt, sheetReleaseVelocity as dt, exceedsSheetTapSlop as ft } from "./sheet-drag.js";
14
- import { titleSignature as pt } from "./sheet-title.js";
15
- import { useKeyFocus as mt } from "../../../internal/key-focus.js";
16
- const ht = { close: "Close" }, gt = "rst:transition-transform rst:duration-(--roster-sheet-enter-duration) rst:ease-(--roster-sheet-enter-easing) rst:data-leave:duration-(--roster-sheet-leave-duration) rst:data-leave:ease-(--roster-sheet-leave-easing) rst:data-closed:translate-y-full", yt = "rst:transition-opacity rst:duration-(--roster-sheet-fade-duration) rst:ease-out rst:data-closed:opacity-0", bt = "rst:transition-opacity rst:duration-(--roster-sheet-enter-duration) rst:ease-out rst:data-leave:duration-(--roster-sheet-leave-duration) rst:data-closed:opacity-0", vt = "rst:transition-opacity rst:duration-(--roster-sheet-fade-duration) rst:ease-out rst:data-closed:opacity-0", Y = { slide: 200, fade: 150 }, xt = [
2
+ import { jsxs as d, Fragment as et, jsx as n } from "react/jsx-runtime";
3
+ import * as r from "react";
4
+ import { Description as rt } from "../../../node_modules/@headlessui/react/dist/components/description/description.js";
5
+ import { Dialog as st, DialogBackdrop as nt, DialogPanel as ot, DialogTitle as at } from "../../../node_modules/@headlessui/react/dist/components/dialog/dialog.js";
6
+ import { TransitionChild as it } from "../../../node_modules/@headlessui/react/dist/components/transition/transition.js";
7
+ import { cn as f } from "../../../lib/utils.js";
8
+ import { withLabels as ct } from "../../../lib/labels.js";
9
+ import { useDarkScope as ut } from "../../../internal/popup.js";
10
+ import { useReducedMotion as lt } from "../../../internal/motion.js";
11
+ import { lockPage as dt } from "../../../internal/page-inert.js";
12
+ import { useLeaveWatchdog as ft } from "../../../internal/leave-watchdog.js";
13
+ import { sheetDragOutcome as pt, sheetReleaseVelocity as mt, exceedsSheetTapSlop as ht } from "./sheet-drag.js";
14
+ import { titleSignature as gt } from "./sheet-title.js";
15
+ import { useKeyFocus as yt } from "../../../internal/key-focus.js";
16
+ const bt = { close: "Close" }, vt = "rst:transition-transform rst:duration-(--roster-sheet-enter-duration) rst:ease-(--roster-sheet-enter-easing) rst:data-leave:duration-(--roster-sheet-leave-duration) rst:data-leave:ease-(--roster-sheet-leave-easing) rst:data-closed:translate-y-full", xt = "rst:transition-opacity rst:duration-(--roster-sheet-fade-duration) rst:ease-out rst:data-closed:opacity-0", Et = "rst:transition-opacity rst:duration-(--roster-sheet-enter-duration) rst:ease-out rst:data-leave:duration-(--roster-sheet-leave-duration) rst:data-closed:opacity-0", Rt = "rst:transition-opacity rst:duration-(--roster-sheet-fade-duration) rst:ease-out rst:data-closed:opacity-0", Y = { slide: 200, fade: 150 }, kt = [
17
17
  "input:not([type=checkbox]):not([type=radio]):not([type=button]):not([type=submit]):not([type=reset]):not([type=range]):not([type=color]):not([type=file]):not([type=image])",
18
18
  "textarea",
19
19
  "select",
20
20
  "[contenteditable]:not([contenteditable=false])"
21
21
  ].join(",");
22
- function Et(r) {
23
- return r ? "current" in r ? r.current : r : null;
22
+ function Lt(c) {
23
+ return c ? "current" in c ? c.current : c : null;
24
24
  }
25
- function Rt({ target: r }) {
26
- const u = s.useRef(r), f = s.useRef(!1);
27
- return s.useEffect(() => {
28
- u.current = r;
29
- }), s.useEffect(() => (f.current = !1, () => {
30
- f.current = !0, queueMicrotask(() => {
31
- if (!f.current) return;
32
- const p = Et(u.current);
33
- p?.isConnected && p.focus();
25
+ function Ct({ target: c }) {
26
+ const l = r.useRef(c), p = r.useRef(!1);
27
+ return r.useEffect(() => {
28
+ l.current = c;
29
+ }), r.useEffect(() => (p.current = !1, () => {
30
+ p.current = !0, queueMicrotask(() => {
31
+ if (!p.current) return;
32
+ const m = Lt(l.current);
33
+ m?.isConnected && m.focus();
34
34
  });
35
35
  }), []), null;
36
36
  }
37
- function kt() {
37
+ function Nt() {
38
38
  return /* @__PURE__ */ n(
39
39
  "svg",
40
40
  {
@@ -50,74 +50,78 @@ function kt() {
50
50
  }
51
51
  );
52
52
  }
53
- const Bt = ({
54
- isOpen: r,
55
- onClose: u,
56
- onAfterClose: f,
57
- title: p,
53
+ const _t = ({
54
+ isOpen: c,
55
+ onClose: l,
56
+ onAfterClose: p,
57
+ title: m,
58
58
  hideTitle: _ = !1,
59
- description: N,
59
+ description: S,
60
60
  actions: D,
61
- maxWidth: v = 560,
62
- initialFocus: x,
61
+ maxWidth: x = 560,
62
+ initialFocus: E,
63
63
  returnFocus: T,
64
- busy: m = !1,
65
- dragToDismiss: E = !0,
66
- contentKey: h,
64
+ busy: h = !1,
65
+ dragToDismiss: R = !0,
66
+ contentKey: g,
67
67
  labels: q,
68
68
  className: V,
69
69
  children: $
70
70
  }) => {
71
- mt();
72
- const K = ot(ht, q), { ref: R, inDarkScope: U } = at(), k = it(), I = s.useRef(null), i = s.useRef(null), S = ut(I, i, r, k ? Y.fade : Y.slide, f);
73
- s.useLayoutEffect(() => {
74
- if (r)
75
- return ct(R.current);
76
- }, [r, R]);
77
- const w = s.useRef(null), P = s.useRef(null), L = s.useRef(null), C = s.useRef(null), M = s.useId(), g = pt(p), A = s.useRef({ signature: g, contentKey: h, open: r, busy: m });
78
- s.useEffect(() => {
79
- const t = A.current;
80
- if (A.current = { signature: g, contentKey: h, open: r, busy: m }, !t.open || !r) return;
81
- const e = t.contentKey !== h, o = t.signature !== g && !t.busy;
82
- !e && !o || (P.current?.focus(), C.current && (C.current.scrollTop = 0));
83
- }, [g, h, r, m]), s.useEffect(() => {
84
- if (!r) return;
71
+ yt();
72
+ const K = ct(bt, q), { ref: k, inDarkScope: U } = ut(), L = lt(), [X, G] = r.useState(!1);
73
+ r.useLayoutEffect(() => {
74
+ G(!0);
75
+ }, []);
76
+ const s = c && X, I = r.useRef(null), i = r.useRef(null), w = ft(I, i, s, L ? Y.fade : Y.slide, p);
77
+ r.useLayoutEffect(() => {
78
+ if (s)
79
+ return dt(k.current);
80
+ }, [s, k]);
81
+ const M = r.useRef(null), P = r.useRef(null), C = r.useRef(null), N = r.useRef(null), A = r.useId(), y = gt(m), F = r.useRef({ signature: y, contentKey: g, open: s, busy: h });
82
+ r.useEffect(() => {
83
+ const t = F.current;
84
+ if (F.current = { signature: y, contentKey: g, open: s, busy: h }, !t.open || !s) return;
85
+ const e = t.contentKey !== g, o = t.signature !== y && !t.busy;
86
+ !e && !o || (P.current?.focus(), N.current && (N.current.scrollTop = 0));
87
+ }, [y, g, s, h]), r.useEffect(() => {
88
+ if (!s) return;
85
89
  const t = requestAnimationFrame(() => {
86
90
  const e = i.current, o = document.activeElement;
87
- !e || o && e.contains(o) || (x?.current ?? L.current)?.focus();
91
+ !e || o && e.contains(o) || (E?.current ?? C.current)?.focus();
88
92
  });
89
93
  return () => cancelAnimationFrame(t);
90
- }, [r, x]);
91
- const [F, j] = s.useState(null);
92
- s.useEffect(() => {
93
- if (!r) return;
94
+ }, [s, E]);
95
+ const [O, j] = r.useState(null);
96
+ r.useEffect(() => {
97
+ if (!s) return;
94
98
  const t = window.visualViewport;
95
99
  if (!t) return;
96
100
  const e = () => {
97
- const o = document.activeElement, c = !!o && !!i.current?.contains(o) && o.matches(xt);
98
- j(c ? Math.round(t.height) : null);
101
+ const o = document.activeElement, u = !!o && !!i.current?.contains(o) && o.matches(kt);
102
+ j(u ? Math.round(t.height) : null);
99
103
  };
100
104
  return t.addEventListener("resize", e), document.addEventListener("focusin", e), document.addEventListener("focusout", e), () => {
101
105
  t.removeEventListener("resize", e), document.removeEventListener("focusin", e), document.removeEventListener("focusout", e), j(null);
102
106
  };
103
- }, [r]);
104
- const a = s.useRef(null), y = s.useRef(!1), z = s.useRef(r);
105
- s.useEffect(() => {
106
- z.current = r;
107
- }, [r]);
108
- const b = (t) => {
107
+ }, [s]);
108
+ const a = r.useRef(null), b = r.useRef(!1), z = r.useRef(s);
109
+ r.useEffect(() => {
110
+ z.current = s;
111
+ }, [s]);
112
+ const v = (t) => {
109
113
  i.current?.style.setProperty("--rst-sheet-drag", `${t}px`);
110
114
  }, B = (t) => {
111
115
  const e = i.current;
112
- a.current = null, e && (delete e.dataset.dragging, t === "close" ? (u(), requestAnimationFrame(() => {
113
- z.current && !a.current && b(0);
114
- })) : b(0));
116
+ a.current = null, e && (delete e.dataset.dragging, t === "close" ? (l(), requestAnimationFrame(() => {
117
+ z.current && !a.current && v(0);
118
+ })) : v(0));
115
119
  };
116
- s.useEffect(() => {
117
- !r && a.current && (a.current = null, i.current && delete i.current.dataset.dragging), r && !a.current && b(0);
118
- }, [r]);
119
- const X = (t) => {
120
- a.current || (y.current = !1, !(!E || !r) && (t.pointerType === "mouse" && (t.button !== 0 || !w.current?.contains(t.target)) || (a.current = {
120
+ r.useEffect(() => {
121
+ !s && a.current && (a.current = null, i.current && delete i.current.dataset.dragging), s && !a.current && v(0);
122
+ }, [s]);
123
+ const Q = (t) => {
124
+ a.current || (b.current = !1, !(!R || !s) && (t.pointerType === "mouse" && (t.button !== 0 || !M.current?.contains(t.target)) || (a.current = {
121
125
  pointerId: t.pointerId,
122
126
  x0: t.clientX,
123
127
  y0: t.clientY,
@@ -125,25 +129,25 @@ const Bt = ({
125
129
  phase: "pending",
126
130
  samples: [{ t: t.timeStamp, y: t.clientY }]
127
131
  })));
128
- }, G = (t) => {
132
+ }, H = (t) => {
129
133
  const e = a.current;
130
134
  if (!e || t.pointerId !== e.pointerId) return;
131
- const o = t.clientX - e.x0, c = t.clientY - e.y0;
135
+ const o = t.clientX - e.x0, u = t.clientY - e.y0;
132
136
  if (e.phase === "pending") {
133
- if (!ft(o, c)) return;
134
- if (Math.abs(o) > Math.abs(c)) {
137
+ if (!ht(o, u)) return;
138
+ if (Math.abs(o) > Math.abs(u)) {
135
139
  e.phase = "ignored";
136
140
  return;
137
141
  }
138
- e.phase = "dragging", y.current = !0;
142
+ e.phase = "dragging", b.current = !0;
139
143
  try {
140
144
  t.currentTarget.setPointerCapture(t.pointerId);
141
145
  } catch {
142
146
  }
143
147
  i.current && (i.current.dataset.dragging = "");
144
148
  }
145
- e.phase === "dragging" && (e.dy = c, e.samples.push({ t: t.timeStamp, y: t.clientY }), e.samples.length > 32 && e.samples.shift(), b(Math.max(0, c)));
146
- }, Q = (t) => {
149
+ e.phase === "dragging" && (e.dy = u, e.samples.push({ t: t.timeStamp, y: t.clientY }), e.samples.length > 32 && e.samples.shift(), v(Math.max(0, u)));
150
+ }, J = (t) => {
147
151
  const e = a.current;
148
152
  if (!e || t.pointerId !== e.pointerId) return;
149
153
  if (e.phase !== "dragging") {
@@ -151,50 +155,50 @@ const Bt = ({
151
155
  return;
152
156
  }
153
157
  e.samples.push({ t: t.timeStamp, y: t.clientY });
154
- const o = t.clientY - e.y0, c = i.current?.getBoundingClientRect().height ?? 0;
155
- B(lt(o, c, dt(e.samples)));
156
- }, H = (t) => {
158
+ const o = t.clientY - e.y0, u = i.current?.getBoundingClientRect().height ?? 0;
159
+ B(pt(o, u, mt(e.samples)));
160
+ }, W = (t) => {
157
161
  const e = a.current;
158
162
  !e || t.pointerId !== e.pointerId || (e.phase === "dragging" ? B("stay") : a.current = null);
159
- }, J = (t) => {
160
- !y.current || t.detail === 0 || (y.current = !1, t.preventDefault(), t.stopPropagation());
161
- }, W = {
162
- "--rst-sheet-max-width": typeof v == "number" ? `${v}px` : v,
163
- ...F !== null && { "--rst-sheet-keyboard-cap": `${F}px` }
163
+ }, Z = (t) => {
164
+ !b.current || t.detail === 0 || (b.current = !1, t.preventDefault(), t.stopPropagation());
165
+ }, tt = {
166
+ "--rst-sheet-max-width": typeof x == "number" ? `${x}px` : x,
167
+ ...O !== null && { "--rst-sheet-keyboard-cap": `${O}px` }
164
168
  };
165
- return /* @__PURE__ */ l(Z, { children: [
166
- /* @__PURE__ */ n("span", { ref: R, hidden: !0 }),
167
- /* @__PURE__ */ l(
168
- tt,
169
+ return /* @__PURE__ */ d(et, { children: [
170
+ /* @__PURE__ */ n("span", { ref: k, hidden: !0 }),
171
+ /* @__PURE__ */ d(
172
+ st,
169
173
  {
170
174
  ref: I,
171
- open: r,
175
+ open: s,
172
176
  as: "div",
173
- onClose: u,
174
- initialFocus: x ?? L,
175
- className: d(
177
+ onClose: l,
178
+ initialFocus: E ?? C,
179
+ className: f(
176
180
  "rst:font-ui rst:fixed rst:inset-0 rst:z-50 rst:focus:outline-hidden",
177
181
  U && "dark"
178
182
  ),
179
183
  children: [
180
184
  /* @__PURE__ */ n(
181
- et,
185
+ nt,
182
186
  {
183
187
  transition: !0,
184
188
  "data-testid": "sheet-backdrop",
185
- className: d(
189
+ className: f(
186
190
  "rst:fixed rst:inset-0 rst:bg-[var(--roster-backdrop,var(--roster-sheet-backdrop))]",
187
- k ? vt : bt
191
+ L ? Rt : Et
188
192
  )
189
193
  }
190
194
  ),
191
- /* @__PURE__ */ n("div", { className: "rst:fixed rst:inset-0 rst:flex rst:items-end rst:justify-center", children: /* @__PURE__ */ n(nt, { afterLeave: S.afterLeave, children: /* @__PURE__ */ l(
192
- rt,
195
+ /* @__PURE__ */ n("div", { className: "rst:fixed rst:inset-0 rst:flex rst:items-end rst:justify-center", children: /* @__PURE__ */ n(it, { afterLeave: w.afterLeave, children: /* @__PURE__ */ d(
196
+ ot,
193
197
  {
194
198
  ref: i,
195
- style: W,
199
+ style: tt,
196
200
  "data-testid": "sheet-panel",
197
- className: d(
201
+ className: f(
198
202
  /* 92dvh, or the visual viewport while the keyboard is up,
199
203
  whichever is shorter. */
200
204
  "rst:relative rst:flex rst:max-h-[min(92dvh,var(--rst-sheet-keyboard-cap,92dvh))] rst:w-full rst:flex-col",
@@ -206,62 +210,62 @@ const Bt = ({
206
210
  "rst:[--roster-ring-offset:var(--roster-popover-bg)]",
207
211
  "rst:pb-[env(safe-area-inset-bottom)]",
208
212
  "rst:translate-y-[var(--rst-sheet-drag,0px)]",
209
- k ? yt : gt,
213
+ L ? xt : vt,
210
214
  "rst:data-dragging:transition-none",
211
215
  V
212
216
  ),
213
217
  children: [
214
- /* @__PURE__ */ l(
218
+ /* @__PURE__ */ d(
215
219
  "div",
216
220
  {
217
221
  "data-testid": "sheet-drag-zone",
218
- className: d("rst:shrink-0", E && "rst:touch-none"),
219
- onPointerDown: X,
220
- onPointerMove: G,
221
- onPointerUp: Q,
222
- onPointerCancel: H,
223
- onClickCapture: J,
222
+ className: f("rst:shrink-0", R && "rst:touch-none"),
223
+ onPointerDown: Q,
224
+ onPointerMove: H,
225
+ onPointerUp: J,
226
+ onPointerCancel: W,
227
+ onClickCapture: Z,
224
228
  children: [
225
229
  /* @__PURE__ */ n(
226
230
  "div",
227
231
  {
228
- ref: w,
232
+ ref: M,
229
233
  "aria-hidden": "true",
230
234
  "data-testid": "sheet-handle",
231
- className: d(
235
+ className: f(
232
236
  /* The grip sits near the top edge, where a sheet's grabber
233
237
  is expected, inside a 44px strip. The header below pulls
234
238
  up over the strip's lower part, so a touch there drags
235
239
  too (the header is a drag zone) and a mouse drags from
236
240
  the 32px above it, the full width of the sheet. */
237
241
  "rst:flex rst:h-11 rst:items-start rst:justify-center rst:pt-2",
238
- E && "rst:cursor-grab rst:active:cursor-grabbing"
242
+ R && "rst:cursor-grab rst:active:cursor-grabbing"
239
243
  ),
240
244
  children: /* @__PURE__ */ n("span", { className: "rst:h-1 rst:w-10 rst:rounded-full rst:bg-current rst:opacity-30" })
241
245
  }
242
246
  ),
243
- /* @__PURE__ */ l("div", { className: "rst:-mt-3 rst:flex rst:items-start rst:gap-2 rst:px-5 rst:pb-4", children: [
244
- /* @__PURE__ */ l("div", { className: "rst:min-w-0 rst:flex-1 rst:pt-2", children: [
247
+ /* @__PURE__ */ d("div", { className: "rst:-mt-3 rst:flex rst:items-start rst:gap-2 rst:px-5 rst:pb-4", children: [
248
+ /* @__PURE__ */ d("div", { className: "rst:min-w-0 rst:flex-1 rst:pt-2", children: [
245
249
  /* @__PURE__ */ n(
246
- st,
250
+ at,
247
251
  {
248
252
  as: "h2",
249
- id: M,
253
+ id: A,
250
254
  ref: P,
251
255
  tabIndex: -1,
252
- className: d(
256
+ className: f(
253
257
  "rst:text-lg rst:font-semibold rst:text-inherit rst:focus:outline-hidden",
254
258
  _ && "rst:sr-only"
255
259
  ),
256
- children: p
260
+ children: m
257
261
  }
258
262
  ),
259
- N && /* @__PURE__ */ n(
260
- O,
263
+ S && /* @__PURE__ */ n(
264
+ rt,
261
265
  {
262
266
  as: "p",
263
267
  className: "rst:mt-1 rst:text-sm rst:text-inherit rst:opacity-75",
264
- children: N
268
+ children: S
265
269
  }
266
270
  )
267
271
  ] }),
@@ -271,12 +275,12 @@ const Bt = ({
271
275
  /* @__PURE__ */ n(
272
276
  "button",
273
277
  {
274
- ref: L,
278
+ ref: C,
275
279
  type: "button",
276
- onClick: u,
280
+ onClick: l,
277
281
  "aria-label": K.close,
278
282
  className: "rst:inline-flex rst:size-11 rst:shrink-0 rst:-mr-2 rst:cursor-pointer rst:items-center rst:justify-center rst:rounded-md rst:bg-transparent rst:text-inherit rst:opacity-60 rst:transition-opacity rst:hover:opacity-100 rst:focus:outline-hidden rst:focus-visible:opacity-100 rst:focus-visible:ring-2 rst:focus-visible:ring-ring rst:focus-visible:ring-offset-2 rst:ring-offset-background",
279
- children: /* @__PURE__ */ n(kt, {})
283
+ children: /* @__PURE__ */ n(Nt, {})
280
284
  }
281
285
  )
282
286
  ] })
@@ -286,26 +290,26 @@ const Bt = ({
286
290
  /* @__PURE__ */ n(
287
291
  "div",
288
292
  {
289
- ref: C,
293
+ ref: N,
290
294
  role: "region",
291
- "aria-labelledby": M,
295
+ "aria-labelledby": A,
292
296
  tabIndex: 0,
293
297
  "data-testid": "sheet-content",
294
- "aria-busy": m || void 0,
298
+ "aria-busy": h || void 0,
295
299
  className: "rst:min-h-0 rst:flex-1 rst:overflow-y-auto rst:overscroll-contain rst:px-5 rst:pb-4 rst:focus:outline-hidden rst:ring-inset rst:focus-visible:ring-2 rst:focus-visible:ring-ring",
296
300
  children: $
297
301
  }
298
302
  ),
299
- /* @__PURE__ */ n(Rt, { target: T })
303
+ /* @__PURE__ */ n(Ct, { target: T })
300
304
  ]
301
305
  }
302
306
  ) }) })
303
307
  ]
304
308
  },
305
- S.key
309
+ w.key
306
310
  )
307
311
  ] });
308
312
  };
309
313
  export {
310
- Bt as Sheet
314
+ _t as Sheet
311
315
  };
package/dist/meta.json CHANGED
@@ -1,5 +1,6 @@
1
1
  {
2
- "version": "5.18.0",
3
- "tests": 2701,
4
- "testFiles": 699
2
+ "version": "5.19.1",
3
+ "tests": 2886,
4
+ "testFiles": 223,
5
+ "passedOnRetry": 0
5
6
  }