@blakesteve/roster 5.16.0 → 5.18.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.
Files changed (33) hide show
  1. package/README.md +227 -2
  2. package/dist/components/molecules/RadioTileGroup/RadioTileGroup.cjs +1 -0
  3. package/dist/components/molecules/RadioTileGroup/RadioTileGroup.d.ts +101 -0
  4. package/dist/components/molecules/RadioTileGroup/RadioTileGroup.js +142 -0
  5. package/dist/components/molecules/RadioTileGroup/radio-tile-group-variants.cjs +1 -0
  6. package/dist/components/molecules/RadioTileGroup/radio-tile-group-variants.d.ts +49 -0
  7. package/dist/components/molecules/RadioTileGroup/radio-tile-group-variants.js +34 -0
  8. package/dist/components/molecules/StepProgress/StepProgress.cjs +1 -1
  9. package/dist/components/molecules/StepProgress/StepProgress.js +29 -42
  10. package/dist/components/molecules/Timeline/Timeline.cjs +1 -0
  11. package/dist/components/molecules/Timeline/Timeline.d.ts +86 -0
  12. package/dist/components/molecules/Timeline/Timeline.js +217 -0
  13. package/dist/components/organisms/Dialog/Dialog.cjs +1 -1
  14. package/dist/components/organisms/Dialog/Dialog.d.ts +58 -6
  15. package/dist/components/organisms/Dialog/Dialog.js +82 -59
  16. package/dist/components/organisms/Sheet/Sheet.cjs +1 -1
  17. package/dist/components/organisms/Sheet/Sheet.d.ts +2 -1
  18. package/dist/components/organisms/Sheet/Sheet.js +90 -87
  19. package/dist/index.d.ts +3 -0
  20. package/dist/internal/leave-watchdog.cjs +1 -0
  21. package/dist/internal/leave-watchdog.d.ts +62 -0
  22. package/dist/internal/leave-watchdog.js +64 -0
  23. package/dist/internal/step-check.cjs +1 -0
  24. package/dist/internal/step-check.d.ts +2 -0
  25. package/dist/internal/step-check.js +6 -0
  26. package/dist/internal/step-marker.cjs +1 -0
  27. package/dist/internal/step-marker.d.ts +10 -0
  28. package/dist/internal/step-marker.js +12 -0
  29. package/dist/meta.json +3 -3
  30. package/dist/roster.cjs +1 -1
  31. package/dist/roster.css +1 -1
  32. package/dist/roster.js +155 -147
  33. package/package.json +1 -1
@@ -1,16 +1,17 @@
1
1
  "use client";
2
- import { jsxs as t, Fragment as N, jsx as r } from "react/jsx-runtime";
3
- import { useState as _, useLayoutEffect as c, useRef as F, Fragment as d } from "react";
4
- import { FontAwesomeIcon as L } from "../../../node_modules/@fortawesome/react-fontawesome/dist/index.js";
5
- import { faXmark as T } from "../../../node_modules/@fortawesome/free-solid-svg-icons/index.js";
6
- import { cva as a } from "../../../node_modules/class-variance-authority/dist/index.js";
7
- import { cn as s } from "../../../lib/utils.js";
8
- import { withLabels as j } from "../../../lib/labels.js";
9
- import { lockPage as z } from "../../../internal/page-inert.js";
10
- import { useKeyFocus as D } from "../../../internal/key-focus.js";
11
- import { Dialog as V, DialogBackdrop as A, DialogPanel as B, DialogTitle as C } from "../../../node_modules/@headlessui/react/dist/components/dialog/dialog.js";
12
- import { TransitionChild as m } from "../../../node_modules/@headlessui/react/dist/components/transition/transition.js";
13
- const E = /* @__PURE__ */ a(
2
+ import { jsxs as s, Fragment as A, jsx as r } from "react/jsx-runtime";
3
+ import { useState as S, useLayoutEffect as x, useRef as l, Fragment as c } from "react";
4
+ import { FontAwesomeIcon as B } from "../../../node_modules/@fortawesome/react-fontawesome/dist/index.js";
5
+ import { faXmark as C } from "../../../node_modules/@fortawesome/free-solid-svg-icons/index.js";
6
+ import { cva as o } from "../../../node_modules/class-variance-authority/dist/index.js";
7
+ import { cn as t } from "../../../lib/utils.js";
8
+ import { withLabels as M } from "../../../lib/labels.js";
9
+ import { lockPage as P } from "../../../internal/page-inert.js";
10
+ import { useLeaveWatchdog as I } from "../../../internal/leave-watchdog.js";
11
+ import { useKeyFocus as K } from "../../../internal/key-focus.js";
12
+ import { Dialog as O, DialogBackdrop as Q, DialogPanel as h, DialogTitle as k } from "../../../node_modules/@headlessui/react/dist/components/dialog/dialog.js";
13
+ import { TransitionChild as d } from "../../../node_modules/@headlessui/react/dist/components/transition/transition.js";
14
+ const W = /* @__PURE__ */ o(
14
15
  "rst:relative rst:w-full rst:transform rst:overflow-hidden rst:rounded-2xl rst:p-6 rst:text-left rst:align-middle rst:elevation-overlay rst:transition-all rst:border",
15
16
  {
16
17
  variants: {
@@ -79,44 +80,47 @@ const E = /* @__PURE__ */ a(
79
80
  status: "default"
80
81
  }
81
82
  }
82
- ), P = /* @__PURE__ */ a("rst:text-xl rst:font-bold rst:leading-6 rst:text-inherit"), R = /* @__PURE__ */ a("rst:mt-1 rst:text-sm rst:text-inherit rst:opacity-75"), S = /* @__PURE__ */ a(
83
+ ), w = /* @__PURE__ */ o("rst:text-xl rst:font-bold rst:leading-6 rst:text-inherit"), N = /* @__PURE__ */ o("rst:mt-1 rst:text-sm rst:text-inherit rst:opacity-75"), X = /* @__PURE__ */ o(
83
84
  "rst:inline-flex rst:size-11 rst:shrink-0 rst:items-center rst:justify-center rst:-m-3 rst:cursor-pointer rst:rounded-md rst:bg-transparent rst:text-inherit rst:opacity-50 rst:hover:opacity-100 rst:focus:outline-hidden rst:focus-visible:ring-2 rst:focus-visible:ring-ring rst:focus-visible:ring-offset-2 rst:ring-offset-background rst:transition-opacity"
84
- ), I = { close: "Close dialog" }, W = ({
85
- isOpen: f,
86
- onClose: o,
87
- title: p,
88
- description: i,
89
- size: b,
90
- variant: n,
91
- status: g,
85
+ ), $ = { close: "Close dialog" }, q = 200, ir = ({
86
+ isOpen: _,
87
+ onClose: m,
88
+ title: f,
89
+ description: a,
90
+ size: F,
91
+ variant: p,
92
+ status: L,
92
93
  children: u,
93
94
  className: v,
94
- onAfterClose: x,
95
- labels: y
95
+ onAfterClose: T,
96
+ labels: V,
97
+ layout: j = "default",
98
+ titleHidden: g = !1
96
99
  }) => {
97
- D();
98
- const h = j(I, y), [k, w] = _(!1);
99
- c(() => {
100
- w(!0);
100
+ K();
101
+ const z = j === "fullscreen", D = M($, V), [E, R] = S(!1);
102
+ x(() => {
103
+ R(!0);
101
104
  }, []);
102
- const e = f && k, l = F(null);
103
- return c(() => {
105
+ const e = _ && E, b = l(null), i = l(null), n = I(b, i, e, q, T), y = l(null);
106
+ return x(() => {
104
107
  if (e)
105
- return z(l.current);
106
- }, [e]), /* @__PURE__ */ t(N, { children: [
107
- e && /* @__PURE__ */ r("span", { ref: l, hidden: !0 }),
108
- /* @__PURE__ */ t(
109
- V,
108
+ return P(y.current);
109
+ }, [e]), /* @__PURE__ */ s(A, { children: [
110
+ e && /* @__PURE__ */ r("span", { ref: y, hidden: !0 }),
111
+ /* @__PURE__ */ s(
112
+ O,
110
113
  {
114
+ ref: b,
111
115
  open: e,
112
116
  as: "div",
113
- className: "rst:font-ui rst:relative rst:z-50",
114
- onClose: o,
117
+ className: "rst:font-ui rst:fixed rst:inset-0 rst:z-50",
118
+ onClose: m,
115
119
  children: [
116
120
  /* @__PURE__ */ r(
117
- m,
121
+ d,
118
122
  {
119
- as: d,
123
+ as: c,
120
124
  enter: "rst:ease-out rst:duration-300",
121
125
  enterFrom: "rst:opacity-0",
122
126
  enterTo: "rst:opacity-100",
@@ -124,48 +128,66 @@ const E = /* @__PURE__ */ a(
124
128
  leaveFrom: "rst:opacity-100",
125
129
  leaveTo: "rst:opacity-0",
126
130
  children: /* @__PURE__ */ r(
127
- A,
131
+ Q,
128
132
  {
129
- className: s(
133
+ className: t(
130
134
  "rst:fixed rst:inset-0 rst:transition-opacity",
131
- n === "glass" ? "rst:bg-[var(--roster-backdrop,color-mix(in_oklab,oklch(20.8%_0.042_265.755)_40%,transparent))] rst:dark:bg-[var(--roster-backdrop,color-mix(in_oklab,var(--roster-black,#1e1c1a)_60%,transparent))]" : "rst:bg-[var(--roster-backdrop,color-mix(in_oklab,oklch(20.8%_0.042_265.755)_60%,transparent))] rst:dark:bg-[var(--roster-backdrop,color-mix(in_oklab,var(--roster-black,#1e1c1a)_80%,transparent))] rst:backdrop-blur-backdrop"
135
+ p === "glass" ? "rst:bg-[var(--roster-backdrop,color-mix(in_oklab,oklch(20.8%_0.042_265.755)_40%,transparent))] rst:dark:bg-[var(--roster-backdrop,color-mix(in_oklab,var(--roster-black,#1e1c1a)_60%,transparent))]" : "rst:bg-[var(--roster-backdrop,color-mix(in_oklab,oklch(20.8%_0.042_265.755)_60%,transparent))] rst:dark:bg-[var(--roster-backdrop,color-mix(in_oklab,var(--roster-black,#1e1c1a)_80%,transparent))] rst:backdrop-blur-backdrop"
132
136
  )
133
137
  }
134
138
  )
135
139
  }
136
140
  ),
137
- /* @__PURE__ */ r("div", { className: "rst:fixed rst:inset-0 rst:overflow-y-auto", children: /* @__PURE__ */ r("div", { className: "rst:flex rst:min-h-full rst:items-center rst:justify-center rst:p-4 rst:text-center", children: /* @__PURE__ */ r(
138
- m,
141
+ z ? /* @__PURE__ */ r(
142
+ d,
139
143
  {
140
- as: d,
144
+ as: c,
145
+ enter: "rst:ease-out rst:duration-300",
146
+ enterFrom: "rst:opacity-0",
147
+ enterTo: "rst:opacity-100",
148
+ leave: "rst:ease-in rst:duration-200",
149
+ leaveFrom: "rst:opacity-100",
150
+ leaveTo: "rst:opacity-0",
151
+ afterLeave: n.afterLeave,
152
+ children: /* @__PURE__ */ s(h, { ref: i, className: t("rst:fixed rst:inset-0 rst:overflow-y-auto", v), children: [
153
+ /* @__PURE__ */ r(k, { as: "h2", className: g ? "rst:sr-only" : t(w()), children: f }),
154
+ a && /* @__PURE__ */ r("p", { className: t(N()), children: a }),
155
+ u
156
+ ] })
157
+ }
158
+ ) : /* @__PURE__ */ r("div", { className: "rst:fixed rst:inset-0 rst:overflow-y-auto", children: /* @__PURE__ */ r("div", { className: "rst:flex rst:min-h-full rst:items-center rst:justify-center rst:p-4 rst:text-center", children: /* @__PURE__ */ r(
159
+ d,
160
+ {
161
+ as: c,
141
162
  enter: "rst:ease-out rst:duration-300",
142
163
  enterFrom: "rst:opacity-0 rst:scale-95",
143
164
  enterTo: "rst:opacity-100 rst:scale-100",
144
165
  leave: "rst:ease-in rst:duration-200",
145
166
  leaveFrom: "rst:opacity-100 rst:scale-100",
146
167
  leaveTo: "rst:opacity-0 rst:scale-95",
147
- afterLeave: x,
148
- children: /* @__PURE__ */ t(
149
- B,
168
+ afterLeave: n.afterLeave,
169
+ children: /* @__PURE__ */ s(
170
+ h,
150
171
  {
151
- className: s(
152
- E({ size: b, variant: n, status: g }),
172
+ ref: i,
173
+ className: t(
174
+ W({ size: F, variant: p, status: L }),
153
175
  v
154
176
  ),
155
177
  children: [
156
- /* @__PURE__ */ t("div", { className: "rst:flex rst:items-start rst:justify-between", children: [
157
- /* @__PURE__ */ t("div", { children: [
158
- /* @__PURE__ */ r(C, { as: "h2", className: s(P()), children: p }),
159
- i && /* @__PURE__ */ r("p", { className: s(R()), children: i })
178
+ /* @__PURE__ */ s("div", { className: "rst:flex rst:items-start rst:justify-between", children: [
179
+ /* @__PURE__ */ s("div", { children: [
180
+ /* @__PURE__ */ r(k, { as: "h2", className: g ? "rst:sr-only" : t(w()), children: f }),
181
+ a && /* @__PURE__ */ r("p", { className: t(N()), children: a })
160
182
  ] }),
161
183
  /* @__PURE__ */ r("div", { className: "rst:ml-4 rst:flex rst:shrink-0", children: /* @__PURE__ */ r(
162
184
  "button",
163
185
  {
164
186
  type: "button",
165
- onClick: o,
166
- className: s(S()),
167
- "aria-label": h.close,
168
- children: /* @__PURE__ */ r(L, { icon: T, className: "rst:h-5 rst:w-5" })
187
+ onClick: m,
188
+ className: t(X()),
189
+ "aria-label": D.close,
190
+ children: /* @__PURE__ */ r(B, { icon: C, className: "rst:h-5 rst:w-5" })
169
191
  }
170
192
  ) })
171
193
  ] }),
@@ -176,10 +198,11 @@ const E = /* @__PURE__ */ a(
176
198
  }
177
199
  ) }) })
178
200
  ]
179
- }
201
+ },
202
+ n.key
180
203
  )
181
204
  ] });
182
205
  };
183
206
  export {
184
- W as Dialog
207
+ ir as Dialog
185
208
  };
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),Q=require("react"),Z=require("../../../node_modules/@headlessui/react/dist/components/description/description.cjs"),b=require("../../../node_modules/@headlessui/react/dist/components/dialog/dialog.cjs"),W=require("../../../node_modules/@headlessui/react/dist/components/transition/transition.cjs"),f=require("../../../lib/utils.cjs"),O=require("../../../lib/labels.cjs"),tt=require("../../../internal/popup.cjs"),et=require("../../../internal/motion.cjs"),rt=require("../../../internal/page-inert.cjs"),S=require("./sheet-drag.cjs"),st=require("./sheet-title.cjs"),nt=require("../../../internal/key-focus.cjs");function ot(r){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const c in r)if(c!=="default"){const l=Object.getOwnPropertyDescriptor(r,c);Object.defineProperty(i,c,l.get?l:{enumerable:!0,get:()=>r[c]})}}return i.default=r,Object.freeze(i)}const n=ot(Q),at={close:"Close"},it="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",ct="rst:transition-opacity rst:duration-(--roster-sheet-fade-duration) rst:ease-out rst:data-closed:opacity-0",ut="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",lt="rst:transition-opacity rst:duration-(--roster-sheet-fade-duration) rst:ease-out rst:data-closed:opacity-0",dt=["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])","textarea","select","[contenteditable]:not([contenteditable=false])"].join(",");function ft(r){return r?"current"in r?r.current:r:null}function pt({target:r}){const i=n.useRef(r),c=n.useRef(!1);return n.useEffect(()=>{i.current=r}),n.useEffect(()=>(c.current=!1,()=>{c.current=!0,queueMicrotask(()=>{if(!c.current)return;const l=ft(i.current);l?.isConnected&&l.focus()})}),[]),null}function ht(){return s.jsx("svg",{"aria-hidden":"true",focusable:"false",viewBox:"0 0 20 20",className:"rst:h-5 rst:w-5",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:s.jsx("path",{d:"M5 5l10 10M15 5L5 15"})})}const gt=({isOpen:r,onClose:i,onAfterClose:c,title:l,hideTitle:T=!1,description:D,actions:L,maxWidth:x=560,initialFocus:v,returnFocus:_,busy:p=!1,dragToDismiss:j=!0,contentKey:h,labels:z,className:B,children:Y})=>{nt.useKeyFocus();const K=O.withLabels(at,z),{ref:R,inDarkScope:U}=tt.useDarkScope(),N=et.useReducedMotion();n.useLayoutEffect(()=>{if(r)return rt.lockPage(R.current)},[r,R]);const u=n.useRef(null),C=n.useRef(null),I=n.useRef(null),E=n.useRef(null),k=n.useRef(null),q=n.useId(),g=st.titleSignature(l),w=n.useRef({signature:g,contentKey:h,open:r,busy:p});n.useEffect(()=>{const t=w.current;if(w.current={signature:g,contentKey:h,open:r,busy:p},!t.open||!r)return;const e=t.contentKey!==h,o=t.signature!==g&&!t.busy;!e&&!o||(I.current?.focus(),k.current&&(k.current.scrollTop=0))},[g,h,r,p]),n.useEffect(()=>{if(!r)return;const t=requestAnimationFrame(()=>{const e=u.current,o=document.activeElement;!e||o&&e.contains(o)||(v?.current??E.current)?.focus()});return()=>cancelAnimationFrame(t)},[r,v]);const[P,M]=n.useState(null);n.useEffect(()=>{if(!r)return;const t=window.visualViewport;if(!t)return;const e=()=>{const o=document.activeElement,d=!!o&&!!u.current?.contains(o)&&o.matches(dt);M(d?Math.round(t.height):null)};return t.addEventListener("resize",e),document.addEventListener("focusin",e),document.addEventListener("focusout",e),()=>{t.removeEventListener("resize",e),document.removeEventListener("focusin",e),document.removeEventListener("focusout",e),M(null)}},[r]);const a=n.useRef(null),m=n.useRef(!1),A=n.useRef(r);n.useEffect(()=>{A.current=r},[r]);const y=t=>{u.current?.style.setProperty("--rst-sheet-drag",`${t}px`)},F=t=>{const e=u.current;a.current=null,e&&(delete e.dataset.dragging,t==="close"?(i(),requestAnimationFrame(()=>{A.current&&!a.current&&y(0)})):y(0))};n.useEffect(()=>{!r&&a.current&&(a.current=null,u.current&&delete u.current.dataset.dragging),r&&!a.current&&y(0)},[r]);const V=t=>{a.current||(m.current=!1,!(!j||!r)&&(t.pointerType==="mouse"&&(t.button!==0||!C.current?.contains(t.target))||(a.current={pointerId:t.pointerId,x0:t.clientX,y0:t.clientY,dy:0,phase:"pending",samples:[{t:t.timeStamp,y:t.clientY}]})))},X=t=>{const e=a.current;if(!e||t.pointerId!==e.pointerId)return;const o=t.clientX-e.x0,d=t.clientY-e.y0;if(e.phase==="pending"){if(!S.exceedsSheetTapSlop(o,d))return;if(Math.abs(o)>Math.abs(d)){e.phase="ignored";return}e.phase="dragging",m.current=!0;try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}u.current&&(u.current.dataset.dragging="")}e.phase==="dragging"&&(e.dy=d,e.samples.push({t:t.timeStamp,y:t.clientY}),e.samples.length>32&&e.samples.shift(),y(Math.max(0,d)))},$=t=>{const e=a.current;if(!e||t.pointerId!==e.pointerId)return;if(e.phase!=="dragging"){a.current=null;return}e.samples.push({t:t.timeStamp,y:t.clientY});const o=t.clientY-e.y0,d=u.current?.getBoundingClientRect().height??0;F(S.sheetDragOutcome(o,d,S.sheetReleaseVelocity(e.samples)))},G=t=>{const e=a.current;!e||t.pointerId!==e.pointerId||(e.phase==="dragging"?F("stay"):a.current=null)},H=t=>{!m.current||t.detail===0||(m.current=!1,t.preventDefault(),t.stopPropagation())},J={"--rst-sheet-max-width":typeof x=="number"?`${x}px`:x,...P!==null&&{"--rst-sheet-keyboard-cap":`${P}px`}};return s.jsxs(s.Fragment,{children:[s.jsx("span",{ref:R,hidden:!0}),s.jsxs(b.Dialog,{open:r,as:"div",onClose:i,initialFocus:v??E,className:f.cn("rst:font-ui rst:relative rst:z-50 rst:focus:outline-hidden",U&&"dark"),children:[s.jsx(b.DialogBackdrop,{transition:!0,"data-testid":"sheet-backdrop",className:f.cn("rst:fixed rst:inset-0 rst:bg-[var(--roster-backdrop,var(--roster-sheet-backdrop))]",N?lt:ut)}),s.jsx("div",{className:"rst:fixed rst:inset-0 rst:flex rst:items-end rst:justify-center",children:s.jsx(W.TransitionChild,{afterLeave:c,children:s.jsxs(b.DialogPanel,{ref:u,style:J,"data-testid":"sheet-panel",className:f.cn("rst:relative rst:flex rst:max-h-[min(92dvh,var(--rst-sheet-keyboard-cap,92dvh))] rst:w-full rst:flex-col","rst:md:max-w-(--rst-sheet-max-width)","rst:rounded-t-2xl rst:border rst:border-b-0 rst:elevation-overlay","rst:bg-[var(--roster-popover-bg)] rst:border-[var(--roster-popover-border)] rst:text-[var(--roster-popover-text)]","rst:[--roster-ring-offset:var(--roster-popover-bg)]","rst:pb-[env(safe-area-inset-bottom)]","rst:translate-y-[var(--rst-sheet-drag,0px)]",N?ct:it,"rst:data-dragging:transition-none",B),children:[s.jsxs("div",{"data-testid":"sheet-drag-zone",className:f.cn("rst:shrink-0",j&&"rst:touch-none"),onPointerDown:V,onPointerMove:X,onPointerUp:$,onPointerCancel:G,onClickCapture:H,children:[s.jsx("div",{ref:C,"aria-hidden":"true","data-testid":"sheet-handle",className:f.cn("rst:flex rst:h-11 rst:items-start rst:justify-center rst:pt-2",j&&"rst:cursor-grab rst:active:cursor-grabbing"),children:s.jsx("span",{className:"rst:h-1 rst:w-10 rst:rounded-full rst:bg-current rst:opacity-30"})}),s.jsxs("div",{className:"rst:-mt-3 rst:flex rst:items-start rst:gap-2 rst:px-5 rst:pb-4",children:[s.jsxs("div",{className:"rst:min-w-0 rst:flex-1 rst:pt-2",children:[s.jsx(b.DialogTitle,{as:"h2",id:q,ref:I,tabIndex:-1,className:f.cn("rst:text-lg rst:font-semibold rst:text-inherit rst:focus:outline-hidden",T&&"rst:sr-only"),children:l}),D&&s.jsx(Z.Description,{as:"p",className:"rst:mt-1 rst:text-sm rst:text-inherit rst:opacity-75",children:D})]}),L&&s.jsx("div",{className:"rst:flex rst:h-11 rst:shrink-0 rst:items-center rst:gap-1",children:L}),s.jsx("button",{ref:E,type:"button",onClick:i,"aria-label":K.close,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",children:s.jsx(ht,{})})]})]}),s.jsx("div",{ref:k,role:"region","aria-labelledby":q,tabIndex:0,"data-testid":"sheet-content","aria-busy":p||void 0,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",children:Y}),s.jsx(pt,{target:_})]})})})]})]})};exports.Sheet=gt;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),O=require("react"),tt=require("../../../node_modules/@headlessui/react/dist/components/description/description.cjs"),b=require("../../../node_modules/@headlessui/react/dist/components/dialog/dialog.cjs"),et=require("../../../node_modules/@headlessui/react/dist/components/transition/transition.cjs"),f=require("../../../lib/utils.cjs"),rt=require("../../../lib/labels.cjs"),st=require("../../../internal/popup.cjs"),nt=require("../../../internal/motion.cjs"),ot=require("../../../internal/page-inert.cjs"),at=require("../../../internal/leave-watchdog.cjs"),S=require("./sheet-drag.cjs"),it=require("./sheet-title.cjs"),ct=require("../../../internal/key-focus.cjs");function ut(r){const c=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const u in r)if(u!=="default"){const l=Object.getOwnPropertyDescriptor(r,u);Object.defineProperty(c,u,l.get?l:{enumerable:!0,get:()=>r[u]})}}return c.default=r,Object.freeze(c)}const n=ut(O),lt={close:"Close"},dt="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",ft="rst:transition-opacity rst:duration-(--roster-sheet-fade-duration) rst:ease-out rst:data-closed:opacity-0",pt="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",ht="rst:transition-opacity rst:duration-(--roster-sheet-fade-duration) rst:ease-out rst:data-closed:opacity-0",z={slide:200,fade:150},gt=["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])","textarea","select","[contenteditable]:not([contenteditable=false])"].join(",");function mt(r){return r?"current"in r?r.current:r:null}function yt({target:r}){const c=n.useRef(r),u=n.useRef(!1);return n.useEffect(()=>{c.current=r}),n.useEffect(()=>(u.current=!1,()=>{u.current=!0,queueMicrotask(()=>{if(!u.current)return;const l=mt(c.current);l?.isConnected&&l.focus()})}),[]),null}function bt(){return s.jsx("svg",{"aria-hidden":"true",focusable:"false",viewBox:"0 0 20 20",className:"rst:h-5 rst:w-5",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:s.jsx("path",{d:"M5 5l10 10M15 5L5 15"})})}const xt=({isOpen:r,onClose:c,onAfterClose:u,title:l,hideTitle:B=!1,description:D,actions:N,maxWidth:x=560,initialFocus:v,returnFocus:Y,busy:p=!1,dragToDismiss:j=!0,contentKey:h,labels:V,className:K,children:U})=>{ct.useKeyFocus();const X=rt.withLabels(lt,V),{ref:R,inDarkScope:$}=st.useDarkScope(),E=nt.useReducedMotion(),q=n.useRef(null),i=n.useRef(null),C=at.useLeaveWatchdog(q,i,r,E?z.fade:z.slide,u);n.useLayoutEffect(()=>{if(r)return ot.lockPage(R.current)},[r,R]);const I=n.useRef(null),w=n.useRef(null),k=n.useRef(null),L=n.useRef(null),P=n.useId(),g=it.titleSignature(l),M=n.useRef({signature:g,contentKey:h,open:r,busy:p});n.useEffect(()=>{const t=M.current;if(M.current={signature:g,contentKey:h,open:r,busy:p},!t.open||!r)return;const e=t.contentKey!==h,o=t.signature!==g&&!t.busy;!e&&!o||(w.current?.focus(),L.current&&(L.current.scrollTop=0))},[g,h,r,p]),n.useEffect(()=>{if(!r)return;const t=requestAnimationFrame(()=>{const e=i.current,o=document.activeElement;!e||o&&e.contains(o)||(v?.current??k.current)?.focus()});return()=>cancelAnimationFrame(t)},[r,v]);const[A,F]=n.useState(null);n.useEffect(()=>{if(!r)return;const t=window.visualViewport;if(!t)return;const e=()=>{const o=document.activeElement,d=!!o&&!!i.current?.contains(o)&&o.matches(gt);F(d?Math.round(t.height):null)};return t.addEventListener("resize",e),document.addEventListener("focusin",e),document.addEventListener("focusout",e),()=>{t.removeEventListener("resize",e),document.removeEventListener("focusin",e),document.removeEventListener("focusout",e),F(null)}},[r]);const a=n.useRef(null),m=n.useRef(!1),_=n.useRef(r);n.useEffect(()=>{_.current=r},[r]);const y=t=>{i.current?.style.setProperty("--rst-sheet-drag",`${t}px`)},T=t=>{const e=i.current;a.current=null,e&&(delete e.dataset.dragging,t==="close"?(c(),requestAnimationFrame(()=>{_.current&&!a.current&&y(0)})):y(0))};n.useEffect(()=>{!r&&a.current&&(a.current=null,i.current&&delete i.current.dataset.dragging),r&&!a.current&&y(0)},[r]);const G=t=>{a.current||(m.current=!1,!(!j||!r)&&(t.pointerType==="mouse"&&(t.button!==0||!I.current?.contains(t.target))||(a.current={pointerId:t.pointerId,x0:t.clientX,y0:t.clientY,dy:0,phase:"pending",samples:[{t:t.timeStamp,y:t.clientY}]})))},W=t=>{const e=a.current;if(!e||t.pointerId!==e.pointerId)return;const o=t.clientX-e.x0,d=t.clientY-e.y0;if(e.phase==="pending"){if(!S.exceedsSheetTapSlop(o,d))return;if(Math.abs(o)>Math.abs(d)){e.phase="ignored";return}e.phase="dragging",m.current=!0;try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}i.current&&(i.current.dataset.dragging="")}e.phase==="dragging"&&(e.dy=d,e.samples.push({t:t.timeStamp,y:t.clientY}),e.samples.length>32&&e.samples.shift(),y(Math.max(0,d)))},H=t=>{const e=a.current;if(!e||t.pointerId!==e.pointerId)return;if(e.phase!=="dragging"){a.current=null;return}e.samples.push({t:t.timeStamp,y:t.clientY});const o=t.clientY-e.y0,d=i.current?.getBoundingClientRect().height??0;T(S.sheetDragOutcome(o,d,S.sheetReleaseVelocity(e.samples)))},J=t=>{const e=a.current;!e||t.pointerId!==e.pointerId||(e.phase==="dragging"?T("stay"):a.current=null)},Q=t=>{!m.current||t.detail===0||(m.current=!1,t.preventDefault(),t.stopPropagation())},Z={"--rst-sheet-max-width":typeof x=="number"?`${x}px`:x,...A!==null&&{"--rst-sheet-keyboard-cap":`${A}px`}};return s.jsxs(s.Fragment,{children:[s.jsx("span",{ref:R,hidden:!0}),s.jsxs(b.Dialog,{ref:q,open:r,as:"div",onClose:c,initialFocus:v??k,className:f.cn("rst:font-ui rst:fixed rst:inset-0 rst:z-50 rst:focus:outline-hidden",$&&"dark"),children:[s.jsx(b.DialogBackdrop,{transition:!0,"data-testid":"sheet-backdrop",className:f.cn("rst:fixed rst:inset-0 rst:bg-[var(--roster-backdrop,var(--roster-sheet-backdrop))]",E?ht:pt)}),s.jsx("div",{className:"rst:fixed rst:inset-0 rst:flex rst:items-end rst:justify-center",children:s.jsx(et.TransitionChild,{afterLeave:C.afterLeave,children:s.jsxs(b.DialogPanel,{ref:i,style:Z,"data-testid":"sheet-panel",className:f.cn("rst:relative rst:flex rst:max-h-[min(92dvh,var(--rst-sheet-keyboard-cap,92dvh))] rst:w-full rst:flex-col","rst:md:max-w-(--rst-sheet-max-width)","rst:rounded-t-2xl rst:border rst:border-b-0 rst:elevation-overlay","rst:bg-[var(--roster-popover-bg)] rst:border-[var(--roster-popover-border)] rst:text-[var(--roster-popover-text)]","rst:[--roster-ring-offset:var(--roster-popover-bg)]","rst:pb-[env(safe-area-inset-bottom)]","rst:translate-y-[var(--rst-sheet-drag,0px)]",E?ft:dt,"rst:data-dragging:transition-none",K),children:[s.jsxs("div",{"data-testid":"sheet-drag-zone",className:f.cn("rst:shrink-0",j&&"rst:touch-none"),onPointerDown:G,onPointerMove:W,onPointerUp:H,onPointerCancel:J,onClickCapture:Q,children:[s.jsx("div",{ref:I,"aria-hidden":"true","data-testid":"sheet-handle",className:f.cn("rst:flex rst:h-11 rst:items-start rst:justify-center rst:pt-2",j&&"rst:cursor-grab rst:active:cursor-grabbing"),children:s.jsx("span",{className:"rst:h-1 rst:w-10 rst:rounded-full rst:bg-current rst:opacity-30"})}),s.jsxs("div",{className:"rst:-mt-3 rst:flex rst:items-start rst:gap-2 rst:px-5 rst:pb-4",children:[s.jsxs("div",{className:"rst:min-w-0 rst:flex-1 rst:pt-2",children:[s.jsx(b.DialogTitle,{as:"h2",id:P,ref:w,tabIndex:-1,className:f.cn("rst:text-lg rst:font-semibold rst:text-inherit rst:focus:outline-hidden",B&&"rst:sr-only"),children:l}),D&&s.jsx(tt.Description,{as:"p",className:"rst:mt-1 rst:text-sm rst:text-inherit rst:opacity-75",children:D})]}),N&&s.jsx("div",{className:"rst:flex rst:h-11 rst:shrink-0 rst:items-center rst:gap-1",children:N}),s.jsx("button",{ref:k,type:"button",onClick:c,"aria-label":X.close,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",children:s.jsx(bt,{})})]})]}),s.jsx("div",{ref:L,role:"region","aria-labelledby":P,tabIndex:0,"data-testid":"sheet-content","aria-busy":p||void 0,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",children:U}),s.jsx(yt,{target:Y})]})})})]},C.key)]})};exports.Sheet=xt;
@@ -9,7 +9,8 @@ export interface SheetProps {
9
9
  /** Called by Escape, a backdrop click, the close button and a dismissing drag. */
10
10
  onClose: () => void;
11
11
  /**
12
- * Called once the leave transition has finished and the sheet is gone.
12
+ * Called once the leave transition has finished and the sheet is gone,
13
+ * once for each close, a close during the entrance included.
13
14
  *
14
15
  * Clear the sheet's content here rather than in `onClose`. Cleared in
15
16
  * `onClose`, it empties while it is still sliding out.