@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
|
|
3
|
-
import * as
|
|
4
|
-
import { Description as
|
|
5
|
-
import { Dialog as
|
|
6
|
-
import { TransitionChild as
|
|
7
|
-
import { cn as
|
|
8
|
-
import { withLabels as
|
|
9
|
-
import { useDarkScope as
|
|
10
|
-
import { useReducedMotion as
|
|
11
|
-
import { lockPage as
|
|
12
|
-
import { useLeaveWatchdog as
|
|
13
|
-
import { sheetDragOutcome as
|
|
14
|
-
import { titleSignature as
|
|
15
|
-
import { useKeyFocus as
|
|
16
|
-
const
|
|
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
|
|
23
|
-
return
|
|
22
|
+
function Lt(c) {
|
|
23
|
+
return c ? "current" in c ? c.current : c : null;
|
|
24
24
|
}
|
|
25
|
-
function
|
|
26
|
-
const
|
|
27
|
-
return
|
|
28
|
-
|
|
29
|
-
}),
|
|
30
|
-
|
|
31
|
-
if (!
|
|
32
|
-
const
|
|
33
|
-
|
|
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
|
|
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
|
|
54
|
-
isOpen:
|
|
55
|
-
onClose:
|
|
56
|
-
onAfterClose:
|
|
57
|
-
title:
|
|
53
|
+
const _t = ({
|
|
54
|
+
isOpen: c,
|
|
55
|
+
onClose: l,
|
|
56
|
+
onAfterClose: p,
|
|
57
|
+
title: m,
|
|
58
58
|
hideTitle: _ = !1,
|
|
59
|
-
description:
|
|
59
|
+
description: S,
|
|
60
60
|
actions: D,
|
|
61
|
-
maxWidth:
|
|
62
|
-
initialFocus:
|
|
61
|
+
maxWidth: x = 560,
|
|
62
|
+
initialFocus: E,
|
|
63
63
|
returnFocus: T,
|
|
64
|
-
busy:
|
|
65
|
-
dragToDismiss:
|
|
66
|
-
contentKey:
|
|
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
|
-
|
|
72
|
-
const K =
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (!
|
|
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) || (
|
|
91
|
+
!e || o && e.contains(o) || (E?.current ?? C.current)?.focus();
|
|
88
92
|
});
|
|
89
93
|
return () => cancelAnimationFrame(t);
|
|
90
|
-
}, [
|
|
91
|
-
const [
|
|
92
|
-
|
|
93
|
-
if (!
|
|
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,
|
|
98
|
-
j(
|
|
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
|
-
}, [
|
|
104
|
-
const a =
|
|
105
|
-
|
|
106
|
-
z.current =
|
|
107
|
-
}, [
|
|
108
|
-
const
|
|
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" ? (
|
|
113
|
-
z.current && !a.current &&
|
|
114
|
-
})) :
|
|
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
|
-
|
|
117
|
-
!
|
|
118
|
-
}, [
|
|
119
|
-
const
|
|
120
|
-
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
|
-
},
|
|
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,
|
|
135
|
+
const o = t.clientX - e.x0, u = t.clientY - e.y0;
|
|
132
136
|
if (e.phase === "pending") {
|
|
133
|
-
if (!
|
|
134
|
-
if (Math.abs(o) > Math.abs(
|
|
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",
|
|
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 =
|
|
146
|
-
},
|
|
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,
|
|
155
|
-
B(
|
|
156
|
-
},
|
|
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
|
-
},
|
|
160
|
-
!
|
|
161
|
-
},
|
|
162
|
-
"--rst-sheet-max-width": typeof
|
|
163
|
-
...
|
|
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__ */
|
|
166
|
-
/* @__PURE__ */ n("span", { ref:
|
|
167
|
-
/* @__PURE__ */
|
|
168
|
-
|
|
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:
|
|
175
|
+
open: s,
|
|
172
176
|
as: "div",
|
|
173
|
-
onClose:
|
|
174
|
-
initialFocus:
|
|
175
|
-
className:
|
|
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
|
-
|
|
185
|
+
nt,
|
|
182
186
|
{
|
|
183
187
|
transition: !0,
|
|
184
188
|
"data-testid": "sheet-backdrop",
|
|
185
|
-
className:
|
|
189
|
+
className: f(
|
|
186
190
|
"rst:fixed rst:inset-0 rst:bg-[var(--roster-backdrop,var(--roster-sheet-backdrop))]",
|
|
187
|
-
|
|
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(
|
|
192
|
-
|
|
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:
|
|
199
|
+
style: tt,
|
|
196
200
|
"data-testid": "sheet-panel",
|
|
197
|
-
className:
|
|
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
|
-
|
|
213
|
+
L ? xt : vt,
|
|
210
214
|
"rst:data-dragging:transition-none",
|
|
211
215
|
V
|
|
212
216
|
),
|
|
213
217
|
children: [
|
|
214
|
-
/* @__PURE__ */
|
|
218
|
+
/* @__PURE__ */ d(
|
|
215
219
|
"div",
|
|
216
220
|
{
|
|
217
221
|
"data-testid": "sheet-drag-zone",
|
|
218
|
-
className:
|
|
219
|
-
onPointerDown:
|
|
220
|
-
onPointerMove:
|
|
221
|
-
onPointerUp:
|
|
222
|
-
onPointerCancel:
|
|
223
|
-
onClickCapture:
|
|
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:
|
|
232
|
+
ref: M,
|
|
229
233
|
"aria-hidden": "true",
|
|
230
234
|
"data-testid": "sheet-handle",
|
|
231
|
-
className:
|
|
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
|
-
|
|
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__ */
|
|
244
|
-
/* @__PURE__ */
|
|
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
|
-
|
|
250
|
+
at,
|
|
247
251
|
{
|
|
248
252
|
as: "h2",
|
|
249
|
-
id:
|
|
253
|
+
id: A,
|
|
250
254
|
ref: P,
|
|
251
255
|
tabIndex: -1,
|
|
252
|
-
className:
|
|
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:
|
|
260
|
+
children: m
|
|
257
261
|
}
|
|
258
262
|
),
|
|
259
|
-
|
|
260
|
-
|
|
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:
|
|
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:
|
|
278
|
+
ref: C,
|
|
275
279
|
type: "button",
|
|
276
|
-
onClick:
|
|
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(
|
|
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:
|
|
293
|
+
ref: N,
|
|
290
294
|
role: "region",
|
|
291
|
-
"aria-labelledby":
|
|
295
|
+
"aria-labelledby": A,
|
|
292
296
|
tabIndex: 0,
|
|
293
297
|
"data-testid": "sheet-content",
|
|
294
|
-
"aria-busy":
|
|
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(
|
|
303
|
+
/* @__PURE__ */ n(Ct, { target: T })
|
|
300
304
|
]
|
|
301
305
|
}
|
|
302
306
|
) }) })
|
|
303
307
|
]
|
|
304
308
|
},
|
|
305
|
-
|
|
309
|
+
w.key
|
|
306
310
|
)
|
|
307
311
|
] });
|
|
308
312
|
};
|
|
309
313
|
export {
|
|
310
|
-
|
|
314
|
+
_t as Sheet
|
|
311
315
|
};
|
package/dist/meta.json
CHANGED