@sereno-ds/ui 0.25.2 → 0.25.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.
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
4
  import { createPortal } from "react-dom";
5
5
  import { Toast } from "./Toast";
@@ -8,11 +8,22 @@ const ToastContext = React.createContext(null);
8
8
  const EXIT_MS = 180;
9
9
  let seq = 0;
10
10
  const nextId = () => `t${Date.now().toString(36)}-${(seq++).toString(36)}`;
11
+ const srOnlyStyle = {
12
+ position: "absolute",
13
+ width: 1,
14
+ height: 1,
15
+ overflow: "hidden",
16
+ clip: "rect(0 0 0 0)",
17
+ clipPath: "inset(50%)",
18
+ whiteSpace: "nowrap"
19
+ };
11
20
  const norm = (msg) => typeof msg === "string" ? { title: msg } : msg;
12
21
  const timed = (ms) => ms > 0 && Number.isFinite(ms);
13
22
  function ToastProvider({ children, position = "bottom-right", max = 3, duration = 4e3 }) {
14
23
  const [entries, setEntries] = React.useState([]);
15
24
  const [pausedIds, setPausedIds] = React.useState(() => /* @__PURE__ */ new Set());
25
+ const [politeMsg, setPoliteMsg] = React.useState("");
26
+ const [assertiveMsg, setAssertiveMsg] = React.useState("");
16
27
  const [mounted, setMounted] = React.useState(false);
17
28
  React.useEffect(() => setMounted(true), []);
18
29
  const timers = React.useRef(/* @__PURE__ */ new Map());
@@ -67,6 +78,9 @@ function ToastProvider({ children, position = "bottom-right", max = 3, duration
67
78
  (opts) => {
68
79
  const id = nextId();
69
80
  const ms = opts.duration ?? duration;
81
+ const announced = [opts.title, opts.description].filter(Boolean).join(". ");
82
+ if (opts.tone === "error") setAssertiveMsg(announced);
83
+ else setPoliteMsg(announced);
70
84
  setEntries((list) => {
71
85
  const next = [...list, { ...opts, id, ms }];
72
86
  while (next.filter((e) => !e.leaving).length > max) {
@@ -143,6 +157,13 @@ function ToastProvider({ children, position = "bottom-right", max = 3, duration
143
157
  });
144
158
  return /* @__PURE__ */ jsxs(ToastContext.Provider, { value, children: [
145
159
  children,
160
+ mounted && createPortal(
161
+ /* @__PURE__ */ jsxs(Fragment, { children: [
162
+ /* @__PURE__ */ jsx("div", { "aria-live": "polite", "aria-atomic": "true", style: srOnlyStyle, children: politeMsg }),
163
+ /* @__PURE__ */ jsx("div", { "aria-live": "assertive", "aria-atomic": "true", style: srOnlyStyle, children: assertiveMsg })
164
+ ] }),
165
+ document.body
166
+ ),
146
167
  mounted && entries.length > 0 && createPortal(
147
168
  /* @__PURE__ */ jsx("div", { role: "region", "aria-label": "Notifications", style: viewport, children: entries.map((e) => /* @__PURE__ */ jsx(
148
169
  "div",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/feedback/ToastProvider.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { Toast, type ToastProps } from './Toast';\nimport { sx } from '../_internal/style';\n\n/**\n * The toast *system* — a portal viewport plus a queue — layered on top of the\n * presentational `Toast`. Wrap the app once:\n *\n * ```tsx\n * <ToastProvider position=\"bottom-right\">\n * <App />\n * </ToastProvider>\n * ```\n *\n * then fire from anywhere under it:\n *\n * ```tsx\n * const { toast, dismiss } = useToast();\n * toast.success('Booking confirmed', { description: 'The client was notified.' });\n * toast('Link copied'); // neutral, title only\n * const id = toast.info('Syncing…', { duration: 0 }); // sticks until dismiss(id)\n * ```\n *\n * Toasts stack (newest nearest the edge), show a countdown bar, auto-dismiss\n * after `duration`, pause that timer (and the bar) while hovered/focused, and\n * cap at `max` — the oldest drops. Needs the `sereno-toast-*` keyframes from\n * `@sereno-ds/ui/styles.css`.\n */\n\ntype Tone = NonNullable<ToastProps['tone']>;\n\nexport interface ToastOptions {\n title: string;\n description?: string;\n tone?: Tone;\n icon?: React.ReactNode;\n /** Inline control on the right — an \"Undo\" / \"View\" `Button variant=\"link\"`. */\n action?: React.ReactNode;\n /** ms until auto-dismiss. `0` (or `Infinity`) keeps it until dismissed. Defaults to the provider's `duration`. */\n duration?: number;\n}\n\n/** `msg` shorthand: a bare string becomes the `title`; an object is the full options. */\nexport type ToastInput = string | ToastOptions;\n\ntype ToneFn = (msg: ToastInput, opts?: Partial<ToastOptions>) => string;\n\nexport interface ToastApi {\n /** `toast('Saved')` or `toast('Saved', { description, action, duration })`. Neutral tone. */\n (msg: ToastInput, opts?: Partial<ToastOptions>): string;\n success: ToneFn;\n error: ToneFn;\n warning: ToneFn;\n info: ToneFn;\n neutral: ToneFn;\n}\n\nexport interface ToastContextValue {\n toast: ToastApi;\n /** `dismiss(id)` removes one; `dismiss()` clears them all. */\n dismiss: (id?: string) => void;\n}\n\nconst ToastContext = React.createContext<ToastContextValue | null>(null);\n\nexport type ToastPosition =\n | 'bottom-right'\n | 'bottom-left'\n | 'bottom-center'\n | 'top-right'\n | 'top-left'\n | 'top-center';\n\nexport interface ToastProviderProps {\n children: React.ReactNode;\n /** Viewport corner. Default `bottom-right`. */\n position?: ToastPosition;\n /** Most toasts on screen at once; the oldest drops when a new one arrives. Default `3`. */\n max?: number;\n /** Default auto-dismiss, in ms. Default `4000`. */\n duration?: number;\n}\n\ninterface Entry extends ToastOptions {\n id: string;\n /** Resolved auto-dismiss (ms) — `opts.duration ?? provider duration`. `0` / `Infinity` = sticky. */\n ms: number;\n leaving?: boolean;\n}\n\nconst EXIT_MS = 180;\nlet seq = 0;\nconst nextId = () => `t${Date.now().toString(36)}-${(seq++).toString(36)}`;\n\nconst norm = (msg: ToastInput): Partial<ToastOptions> => (typeof msg === 'string' ? { title: msg } : msg);\nconst timed = (ms: number) => ms > 0 && Number.isFinite(ms);\n\nexport function ToastProvider({ children, position = 'bottom-right', max = 3, duration = 4000 }: ToastProviderProps) {\n const [entries, setEntries] = React.useState<Entry[]>([]);\n const [pausedIds, setPausedIds] = React.useState<ReadonlySet<string>>(() => new Set());\n\n const [mounted, setMounted] = React.useState(false);\n // eslint-disable-next-line react-hooks/set-state-in-effect -- portal target is client-only\n React.useEffect(() => setMounted(true), []);\n\n // Per-toast auto-dismiss timers, so hover/focus can pause and resume them.\n const timers = React.useRef(new Map<string, { handle: ReturnType<typeof setTimeout>; endsAt: number; left: number }>());\n\n const forget = React.useCallback((id: string) => {\n setPausedIds((s) => {\n if (!s.has(id)) return s;\n const n = new Set(s);\n n.delete(id);\n return n;\n });\n }, []);\n\n const drop = React.useCallback(\n (id: string) => {\n const t = timers.current.get(id);\n if (t) clearTimeout(t.handle);\n timers.current.delete(id);\n setEntries((list) => list.map((e) => (e.id === id ? { ...e, leaving: true } : e)));\n setTimeout(() => {\n setEntries((list) => list.filter((e) => e.id !== id));\n forget(id);\n }, EXIT_MS);\n },\n [forget],\n );\n\n const arm = React.useCallback(\n (id: string, ms: number) => {\n if (!timed(ms)) return;\n const handle = setTimeout(() => drop(id), ms);\n timers.current.set(id, { handle, endsAt: Date.now() + ms, left: ms });\n },\n [drop],\n );\n\n const pause = React.useCallback((id: string) => {\n const t = timers.current.get(id);\n if (!t) return;\n clearTimeout(t.handle);\n t.left = Math.max(0, t.endsAt - Date.now());\n setPausedIds((s) => (s.has(id) ? s : new Set(s).add(id)));\n }, []);\n\n const resume = React.useCallback(\n (id: string) => {\n const t = timers.current.get(id);\n if (t) {\n t.handle = setTimeout(() => drop(id), t.left);\n t.endsAt = Date.now() + t.left;\n }\n forget(id);\n },\n [drop, forget],\n );\n\n const add = React.useCallback(\n (opts: ToastOptions) => {\n const id = nextId();\n const ms = opts.duration ?? duration;\n setEntries((list) => {\n const next: Entry[] = [...list, { ...opts, id, ms }];\n // Cap: hard-drop the oldest that isn't already leaving.\n while (next.filter((e) => !e.leaving).length > max) {\n const victim = next.find((e) => !e.leaving);\n if (!victim) break;\n const vt = timers.current.get(victim.id);\n if (vt) clearTimeout(vt.handle);\n timers.current.delete(victim.id);\n victim.leaving = true;\n setTimeout(() => {\n setEntries((l) => l.filter((e) => e.id !== victim.id));\n forget(victim.id);\n }, EXIT_MS);\n }\n return next;\n });\n arm(id, ms);\n return id;\n },\n [arm, duration, forget, max],\n );\n\n // Tone-specific methods always paint their tone; bare `toast(...)` respects a\n // `tone` in the message / options and otherwise stays neutral.\n const fire = React.useCallback(\n (msg: ToastInput, opts?: Partial<ToastOptions>, tone?: Tone) =>\n add({ title: '', ...norm(msg), ...opts, ...(tone ? { tone } : {}) } as ToastOptions),\n [add],\n );\n\n /* eslint-disable react-hooks/refs -- `fire` transitively reaches the `timers` ref, but only when a\n consumer invokes toast.*() from an event handler — never during render. `useMemo` just keeps\n the callable API object's identity stable. */\n const toast = React.useMemo<ToastApi>(() => {\n const base = (msg: ToastInput, opts?: Partial<ToastOptions>) => fire(msg, opts);\n const make = (tone: Tone): ToneFn => (msg, opts) => fire(msg, opts, tone);\n return Object.assign(base, {\n success: make('success'),\n error: make('error'),\n warning: make('warning'),\n info: make('info'),\n neutral: make('neutral'),\n }) as ToastApi;\n }, [fire]);\n /* eslint-enable react-hooks/refs */\n\n const dismiss = React.useCallback(\n (id?: string) => {\n if (id) {\n drop(id);\n return;\n }\n entries.forEach((e) => !e.leaving && drop(e.id));\n },\n [drop, entries],\n );\n\n const value = React.useMemo<ToastContextValue>(() => ({ toast, dismiss }), [toast, dismiss]);\n\n // Clear every pending timer on unmount.\n React.useEffect(() => {\n const map = timers.current;\n return () => map.forEach((t) => clearTimeout(t.handle));\n }, []);\n\n const [edge, side] = position.split('-') as ['top' | 'bottom', 'right' | 'left' | 'center'];\n const viewport = sx({\n position: 'fixed',\n zIndex: 1200,\n display: 'flex',\n // Newest nearest the anchored edge: normal flow for bottom, reversed for top.\n flexDirection: edge === 'bottom' ? 'column' : 'column-reverse',\n gap: 'var(--space-3)',\n width: 'min(420px, calc(100vw - var(--space-8)))',\n maxHeight: '100dvh',\n padding: 'var(--space-4)',\n pointerEvents: 'none',\n [edge]: 0,\n // Every toast is full-width of the viewport, so the stack edges line up on\n // any side; `alignItems` only matters if a toast were ever narrower.\n alignItems: 'stretch',\n // An *outer* offset on top of the padding above, not just the padding\n // itself — macOS Safari's overlay scrollbar floats over the page rather\n // than reducing its width, so a left/right edge flush at 0 can end up\n // with the scrollbar painted right where the padding was supposed to be\n // the toast's only clearance from the edge.\n ...(side === 'center' ? { left: '50%', transform: 'translateX(-50%)' } : { [side]: 'var(--space-2)' }),\n });\n\n return (\n <ToastContext.Provider value={value}>\n {children}\n {mounted &&\n entries.length > 0 &&\n createPortal(\n <div role=\"region\" aria-label=\"Notifications\" style={viewport}>\n {entries.map((e) => (\n <div\n key={e.id}\n className=\"sereno-toast-item\"\n data-edge={edge}\n data-leaving={e.leaving ? 'true' : undefined}\n onMouseEnter={() => pause(e.id)}\n onMouseLeave={() => resume(e.id)}\n onFocusCapture={() => pause(e.id)}\n onBlurCapture={() => resume(e.id)}\n style={sx({ pointerEvents: 'auto', width: '100%' })}\n >\n <Toast\n tone={e.tone}\n title={e.title}\n description={e.description}\n icon={e.icon}\n action={e.action}\n role={e.tone === 'error' ? 'alert' : 'status'}\n onClose={() => drop(e.id)}\n progress={timed(e.ms) && !e.leaving ? { ms: e.ms, paused: pausedIds.has(e.id) } : undefined}\n style={{ width: '100%', maxWidth: 'none' }}\n />\n </div>\n ))}\n </div>,\n document.body,\n )}\n </ToastContext.Provider>\n );\n}\n\nexport function useToast(): ToastContextValue {\n const ctx = React.useContext(ToastContext);\n if (!ctx) throw new Error('useToast() must be called inside <ToastProvider>.');\n return ctx;\n}\n"],"mappings":";AAkQI,SAkBY,KAlBZ;AAhQJ,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAC7B,SAAS,aAA8B;AACvC,SAAS,UAAU;AA6DnB,MAAM,eAAe,MAAM,cAAwC,IAAI;AA2BvE,MAAM,UAAU;AAChB,IAAI,MAAM;AACV,MAAM,SAAS,MAAM,IAAI,KAAK,IAAI,EAAE,SAAS,EAAE,CAAC,KAAK,OAAO,SAAS,EAAE,CAAC;AAExE,MAAM,OAAO,CAAC,QAA4C,OAAO,QAA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A;AAAA,cACC,MAAM,EAAE;AAAA,cACR,OAAO,EAAE;AAAA,cACT,aAAa,EAAE;AAAA,cACf,MAAM,EAAE;AAAA,cACR,QAAQ,EAAE;AAAA,cACV,MAAM,EAAE,SAAS,UAAU,UAAU;AAAA,cACrC,SAAS,MAAM,KAAK,EAAE,EAAE;AAAA,cACxB,UAAU,MAAM,EAAE,EAAE,KAAK,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,QAAQ,UAAU,IAAI,EAAE,EAAE,EAAE,IAAI;AAAA,cAClF,OAAO,EAAE,OAAO,QAAQ,UAAU,OAAO;AAAA;AAAA,UAC3C;AAAA;AAAA,QApBK,EAAE;AAAA,MAqBT,CACD,GACH;AAAA,MACA,SAAS;AAAA,IACX;AAAA,KACJ;AAEJ;AAEO,SAAS,WAA8B;AAC5C,QAAM,MAAM,MAAM,WAAW,YAAY;AACzC,MAAI,CAAC,IAAK,OAAM,IAAI,MAAM,mDAAmD;AAC7E,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/feedback/ToastProvider.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { Toast, type ToastProps } from './Toast';\nimport { sx } from '../_internal/style';\n\n/**\n * The toast *system* — a portal viewport plus a queue — layered on top of the\n * presentational `Toast`. Wrap the app once:\n *\n * ```tsx\n * <ToastProvider position=\"bottom-right\">\n * <App />\n * </ToastProvider>\n * ```\n *\n * then fire from anywhere under it:\n *\n * ```tsx\n * const { toast, dismiss } = useToast();\n * toast.success('Booking confirmed', { description: 'The client was notified.' });\n * toast('Link copied'); // neutral, title only\n * const id = toast.info('Syncing…', { duration: 0 }); // sticks until dismiss(id)\n * ```\n *\n * Toasts stack (newest nearest the edge), show a countdown bar, auto-dismiss\n * after `duration`, pause that timer (and the bar) while hovered/focused, and\n * cap at `max` — the oldest drops. Needs the `sereno-toast-*` keyframes from\n * `@sereno-ds/ui/styles.css`.\n */\n\ntype Tone = NonNullable<ToastProps['tone']>;\n\nexport interface ToastOptions {\n title: string;\n description?: string;\n tone?: Tone;\n icon?: React.ReactNode;\n /** Inline control on the right — an \"Undo\" / \"View\" `Button variant=\"link\"`. */\n action?: React.ReactNode;\n /** ms until auto-dismiss. `0` (or `Infinity`) keeps it until dismissed. Defaults to the provider's `duration`. */\n duration?: number;\n}\n\n/** `msg` shorthand: a bare string becomes the `title`; an object is the full options. */\nexport type ToastInput = string | ToastOptions;\n\ntype ToneFn = (msg: ToastInput, opts?: Partial<ToastOptions>) => string;\n\nexport interface ToastApi {\n /** `toast('Saved')` or `toast('Saved', { description, action, duration })`. Neutral tone. */\n (msg: ToastInput, opts?: Partial<ToastOptions>): string;\n success: ToneFn;\n error: ToneFn;\n warning: ToneFn;\n info: ToneFn;\n neutral: ToneFn;\n}\n\nexport interface ToastContextValue {\n toast: ToastApi;\n /** `dismiss(id)` removes one; `dismiss()` clears them all. */\n dismiss: (id?: string) => void;\n}\n\nconst ToastContext = React.createContext<ToastContextValue | null>(null);\n\nexport type ToastPosition =\n | 'bottom-right'\n | 'bottom-left'\n | 'bottom-center'\n | 'top-right'\n | 'top-left'\n | 'top-center';\n\nexport interface ToastProviderProps {\n children: React.ReactNode;\n /** Viewport corner. Default `bottom-right`. */\n position?: ToastPosition;\n /** Most toasts on screen at once; the oldest drops when a new one arrives. Default `3`. */\n max?: number;\n /** Default auto-dismiss, in ms. Default `4000`. */\n duration?: number;\n}\n\ninterface Entry extends ToastOptions {\n id: string;\n /** Resolved auto-dismiss (ms) — `opts.duration ?? provider duration`. `0` / `Infinity` = sticky. */\n ms: number;\n leaving?: boolean;\n}\n\nconst EXIT_MS = 180;\nlet seq = 0;\nconst nextId = () => `t${Date.now().toString(36)}-${(seq++).toString(36)}`;\n\n// Same visually-hidden shape as Table's <caption> (see Table.tsx's srOnlyStyle).\nconst srOnlyStyle: React.CSSProperties = {\n position: 'absolute',\n width: 1,\n height: 1,\n overflow: 'hidden',\n clip: 'rect(0 0 0 0)',\n clipPath: 'inset(50%)',\n whiteSpace: 'nowrap',\n};\n\nconst norm = (msg: ToastInput): Partial<ToastOptions> => (typeof msg === 'string' ? { title: msg } : msg);\nconst timed = (ms: number) => ms > 0 && Number.isFinite(ms);\n\nexport function ToastProvider({ children, position = 'bottom-right', max = 3, duration = 4000 }: ToastProviderProps) {\n const [entries, setEntries] = React.useState<Entry[]>([]);\n const [pausedIds, setPausedIds] = React.useState<ReadonlySet<string>>(() => new Set());\n // A live region announces a *change* to already-present content — a node\n // that mounts fresh with its text already inside it (which is what each\n // visual Toast card below does) is not reliably announced by screen\n // readers, across browsers/AT. So the actual announcement runs through two\n // persistent, visually-hidden regions instead (one polite, one assertive\n // for errors) that stay mounted the whole time `ToastProvider` is, and\n // just get their text replaced on every toast.\n const [politeMsg, setPoliteMsg] = React.useState('');\n const [assertiveMsg, setAssertiveMsg] = React.useState('');\n\n const [mounted, setMounted] = React.useState(false);\n // eslint-disable-next-line react-hooks/set-state-in-effect -- portal target is client-only\n React.useEffect(() => setMounted(true), []);\n\n // Per-toast auto-dismiss timers, so hover/focus can pause and resume them.\n const timers = React.useRef(new Map<string, { handle: ReturnType<typeof setTimeout>; endsAt: number; left: number }>());\n\n const forget = React.useCallback((id: string) => {\n setPausedIds((s) => {\n if (!s.has(id)) return s;\n const n = new Set(s);\n n.delete(id);\n return n;\n });\n }, []);\n\n const drop = React.useCallback(\n (id: string) => {\n const t = timers.current.get(id);\n if (t) clearTimeout(t.handle);\n timers.current.delete(id);\n setEntries((list) => list.map((e) => (e.id === id ? { ...e, leaving: true } : e)));\n setTimeout(() => {\n setEntries((list) => list.filter((e) => e.id !== id));\n forget(id);\n }, EXIT_MS);\n },\n [forget],\n );\n\n const arm = React.useCallback(\n (id: string, ms: number) => {\n if (!timed(ms)) return;\n const handle = setTimeout(() => drop(id), ms);\n timers.current.set(id, { handle, endsAt: Date.now() + ms, left: ms });\n },\n [drop],\n );\n\n const pause = React.useCallback((id: string) => {\n const t = timers.current.get(id);\n if (!t) return;\n clearTimeout(t.handle);\n t.left = Math.max(0, t.endsAt - Date.now());\n setPausedIds((s) => (s.has(id) ? s : new Set(s).add(id)));\n }, []);\n\n const resume = React.useCallback(\n (id: string) => {\n const t = timers.current.get(id);\n if (t) {\n t.handle = setTimeout(() => drop(id), t.left);\n t.endsAt = Date.now() + t.left;\n }\n forget(id);\n },\n [drop, forget],\n );\n\n const add = React.useCallback(\n (opts: ToastOptions) => {\n const id = nextId();\n const ms = opts.duration ?? duration;\n const announced = [opts.title, opts.description].filter(Boolean).join('. ');\n if (opts.tone === 'error') setAssertiveMsg(announced);\n else setPoliteMsg(announced);\n setEntries((list) => {\n const next: Entry[] = [...list, { ...opts, id, ms }];\n // Cap: hard-drop the oldest that isn't already leaving.\n while (next.filter((e) => !e.leaving).length > max) {\n const victim = next.find((e) => !e.leaving);\n if (!victim) break;\n const vt = timers.current.get(victim.id);\n if (vt) clearTimeout(vt.handle);\n timers.current.delete(victim.id);\n victim.leaving = true;\n setTimeout(() => {\n setEntries((l) => l.filter((e) => e.id !== victim.id));\n forget(victim.id);\n }, EXIT_MS);\n }\n return next;\n });\n arm(id, ms);\n return id;\n },\n [arm, duration, forget, max],\n );\n\n // Tone-specific methods always paint their tone; bare `toast(...)` respects a\n // `tone` in the message / options and otherwise stays neutral.\n const fire = React.useCallback(\n (msg: ToastInput, opts?: Partial<ToastOptions>, tone?: Tone) =>\n add({ title: '', ...norm(msg), ...opts, ...(tone ? { tone } : {}) } as ToastOptions),\n [add],\n );\n\n /* eslint-disable react-hooks/refs -- `fire` transitively reaches the `timers` ref, but only when a\n consumer invokes toast.*() from an event handler — never during render. `useMemo` just keeps\n the callable API object's identity stable. */\n const toast = React.useMemo<ToastApi>(() => {\n const base = (msg: ToastInput, opts?: Partial<ToastOptions>) => fire(msg, opts);\n const make = (tone: Tone): ToneFn => (msg, opts) => fire(msg, opts, tone);\n return Object.assign(base, {\n success: make('success'),\n error: make('error'),\n warning: make('warning'),\n info: make('info'),\n neutral: make('neutral'),\n }) as ToastApi;\n }, [fire]);\n /* eslint-enable react-hooks/refs */\n\n const dismiss = React.useCallback(\n (id?: string) => {\n if (id) {\n drop(id);\n return;\n }\n entries.forEach((e) => !e.leaving && drop(e.id));\n },\n [drop, entries],\n );\n\n const value = React.useMemo<ToastContextValue>(() => ({ toast, dismiss }), [toast, dismiss]);\n\n // Clear every pending timer on unmount.\n React.useEffect(() => {\n const map = timers.current;\n return () => map.forEach((t) => clearTimeout(t.handle));\n }, []);\n\n const [edge, side] = position.split('-') as ['top' | 'bottom', 'right' | 'left' | 'center'];\n const viewport = sx({\n position: 'fixed',\n zIndex: 1200,\n display: 'flex',\n // Newest nearest the anchored edge: normal flow for bottom, reversed for top.\n flexDirection: edge === 'bottom' ? 'column' : 'column-reverse',\n gap: 'var(--space-3)',\n width: 'min(420px, calc(100vw - var(--space-8)))',\n maxHeight: '100dvh',\n padding: 'var(--space-4)',\n pointerEvents: 'none',\n [edge]: 0,\n // Every toast is full-width of the viewport, so the stack edges line up on\n // any side; `alignItems` only matters if a toast were ever narrower.\n alignItems: 'stretch',\n // An *outer* offset on top of the padding above, not just the padding\n // itself — macOS Safari's overlay scrollbar floats over the page rather\n // than reducing its width, so a left/right edge flush at 0 can end up\n // with the scrollbar painted right where the padding was supposed to be\n // the toast's only clearance from the edge.\n ...(side === 'center' ? { left: '50%', transform: 'translateX(-50%)' } : { [side]: 'var(--space-2)' }),\n });\n\n return (\n <ToastContext.Provider value={value}>\n {children}\n {mounted &&\n createPortal(\n <>\n <div aria-live=\"polite\" aria-atomic=\"true\" style={srOnlyStyle}>\n {politeMsg}\n </div>\n <div aria-live=\"assertive\" aria-atomic=\"true\" style={srOnlyStyle}>\n {assertiveMsg}\n </div>\n </>,\n document.body,\n )}\n {mounted &&\n entries.length > 0 &&\n createPortal(\n <div role=\"region\" aria-label=\"Notifications\" style={viewport}>\n {entries.map((e) => (\n <div\n key={e.id}\n className=\"sereno-toast-item\"\n data-edge={edge}\n data-leaving={e.leaving ? 'true' : undefined}\n onMouseEnter={() => pause(e.id)}\n onMouseLeave={() => resume(e.id)}\n onFocusCapture={() => pause(e.id)}\n onBlurCapture={() => resume(e.id)}\n style={sx({ pointerEvents: 'auto', width: '100%' })}\n >\n <Toast\n tone={e.tone}\n title={e.title}\n description={e.description}\n icon={e.icon}\n action={e.action}\n role={e.tone === 'error' ? 'alert' : 'status'}\n onClose={() => drop(e.id)}\n progress={timed(e.ms) && !e.leaving ? { ms: e.ms, paused: pausedIds.has(e.id) } : undefined}\n style={{ width: '100%', maxWidth: 'none' }}\n />\n </div>\n ))}\n </div>,\n document.body,\n )}\n </ToastContext.Provider>\n );\n}\n\nexport function useToast(): ToastContextValue {\n const ctx = React.useContext(ToastContext);\n if (!ctx) throw new Error('useToast() must be called inside <ToastProvider>.');\n return ctx;\n}\n"],"mappings":";AA6RU,mBACE,KADF;AA3RV,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAC7B,SAAS,aAA8B;AACvC,SAAS,UAAU;AA6DnB,MAAM,eAAe,MAAM,cAAwC,IAAI;AA2BvE,MAAM,UAAU;AAChB,IAAI,MAAM;AACV,MAAM,SAAS,MAAM,IAAI,KAAK,IAAI,EAAE,SAAS,EAAE,CAAC,KAAK,OAAO,SAAS,EAAE,CAAC;AAGxE,MAAM,cAAmC;AAAA,EACvC,UAAU;AAAA,EACV,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,MAAM;AAAA,EACN,UAAU;AAAA,EACV,YAAY;AACd;AAEA,MAAM,OAAO,CAAC,QAA4C,OAAO,QAAQ,WAAW,EAAE,OAAO,IAAI,IAAI;AACrG,MAAM,QAAQ,CAAC,OAAe,KAAK,KAAK,OAAO,SAAS,EAAE;AAEnD,SAAS,cAAc,EAAE,UAAU,WAAW,gBAAgB,MAAM,GAAG,WAAW,IAAK,GAAuB;AACnH,QAAM,CAAC,SAAS,UAAU,IAAI,MAAM,SAAkB,CAAC,CAAC;AACxD,QAAM,CAAC,WAAW,YA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cAAc,MAAM,OAAO,EAAE,EAAE;AAAA,UAC/B,gBAAgB,MAAM,MAAM,EAAE,EAAE;AAAA,UAChC,eAAe,MAAM,OAAO,EAAE,EAAE;AAAA,UAChC,OAAO,GAAG,EAAE,eAAe,QAAQ,OAAO,OAAO,CAAC;AAAA,UAElD;AAAA,YAAC;AAAA;AAAA,cACC,MAAM,EAAE;AAAA,cACR,OAAO,EAAE;AAAA,cACT,aAAa,EAAE;AAAA,cACf,MAAM,EAAE;AAAA,cACR,QAAQ,EAAE;AAAA,cACV,MAAM,EAAE,SAAS,UAAU,UAAU;AAAA,cACrC,SAAS,MAAM,KAAK,EAAE,EAAE;AAAA,cACxB,UAAU,MAAM,EAAE,EAAE,KAAK,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,QAAQ,UAAU,IAAI,EAAE,EAAE,EAAE,IAAI;AAAA,cAClF,OAAO,EAAE,OAAO,QAAQ,UAAU,OAAO;AAAA;AAAA,UAC3C;AAAA;AAAA,QApBK,EAAE;AAAA,MAqBT,CACD,GACH;AAAA,MACA,SAAS;AAAA,IACX;AAAA,KACJ;AAEJ;AAEO,SAAS,WAA8B;AAC5C,QAAM,MAAM,MAAM,WAAW,YAAY;AACzC,MAAI,CAAC,IAAK,OAAM,IAAI,MAAM,mDAAmD;AAC7E,SAAO;AACT;","names":[]}
@@ -12,6 +12,14 @@ interface TimeSlot {
12
12
  * popover to jump straight to a month or year. `year` / `month` set the *initial*
13
13
  * view; the component then owns it. Pass `onMonthChange` to react to navigation
14
14
  * (e.g. fetch the new month's availability).
15
+ *
16
+ * The day grid uses roving tabindex (SS-228) — only one cell is ever in the
17
+ * Tab order, so Tab enters/leaves it in one stop instead of one per day.
18
+ * Arrow keys move by day/week and cross month boundaries on overflow;
19
+ * Home/End move within the current week row; PageUp/PageDown step the
20
+ * month. An `unavailable` day stays focusable (`aria-disabled`, not the
21
+ * native `disabled` — a disabled button can't receive focus at all) so the
22
+ * cursor can still land on it, just not select it.
15
23
  */
16
24
  interface DateTimePickerProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {
17
25
  /** Initial year. Defaults to the current year. */
@@ -37,6 +37,13 @@ function DateTimePicker({
37
37
  const rootRef = React.useRef(null);
38
38
  const titleRef = React.useRef(null);
39
39
  const popRef = React.useRef(null);
40
+ const gridRef = React.useRef(null);
41
+ const [activeDay, setActiveDay] = React.useState(() => {
42
+ if (selectedDate) return selectedDate;
43
+ const todayIndex = now.getFullYear() * 12 + now.getMonth();
44
+ return todayIndex === initialIndex ? now.getDate() : 1;
45
+ });
46
+ const shouldFocusDayRef = React.useRef(false);
40
47
  const onMonthChangeRef = React.useRef(onMonthChange);
41
48
  React.useEffect(() => {
42
49
  onMonthChangeRef.current = onMonthChange;
@@ -81,6 +88,61 @@ function DateTimePicker({
81
88
  while (cells.length < 42) cells.push(null);
82
89
  const cellH = renderDay ? 48 : 38;
83
90
  const years = Array.from({ length: 12 }, (_, i) => yearBase + i);
91
+ const rovingDay = Math.min(Math.max(1, activeDay), total);
92
+ const onGridKeyDown = (e) => {
93
+ let delta = 0;
94
+ switch (e.key) {
95
+ case "ArrowRight":
96
+ delta = 1;
97
+ break;
98
+ case "ArrowLeft":
99
+ delta = -1;
100
+ break;
101
+ case "ArrowDown":
102
+ delta = 7;
103
+ break;
104
+ case "ArrowUp":
105
+ delta = -7;
106
+ break;
107
+ case "Home": {
108
+ e.preventDefault();
109
+ const row = Math.floor((first + rovingDay - 1) / 7);
110
+ shouldFocusDayRef.current = true;
111
+ setActiveDay(Math.max(1, row * 7 - first + 1));
112
+ return;
113
+ }
114
+ case "End": {
115
+ e.preventDefault();
116
+ const row = Math.floor((first + rovingDay - 1) / 7);
117
+ shouldFocusDayRef.current = true;
118
+ setActiveDay(Math.min(total, row * 7 + 7 - first));
119
+ return;
120
+ }
121
+ case "PageUp":
122
+ e.preventDefault();
123
+ shouldFocusDayRef.current = true;
124
+ setViewIndex((i) => i - 1);
125
+ return;
126
+ case "PageDown":
127
+ e.preventDefault();
128
+ shouldFocusDayRef.current = true;
129
+ setViewIndex((i) => i + 1);
130
+ return;
131
+ default:
132
+ return;
133
+ }
134
+ e.preventDefault();
135
+ const next = new Date(viewYear, viewMonth, rovingDay + delta);
136
+ const nextViewIndex = next.getFullYear() * 12 + next.getMonth();
137
+ shouldFocusDayRef.current = true;
138
+ if (nextViewIndex !== viewIndex) setViewIndex(nextViewIndex);
139
+ setActiveDay(next.getDate());
140
+ };
141
+ React.useLayoutEffect(() => {
142
+ if (!shouldFocusDayRef.current) return;
143
+ shouldFocusDayRef.current = false;
144
+ gridRef.current?.querySelector(`[data-day="${rovingDay}"]`)?.focus();
145
+ }, [viewIndex, rovingDay]);
84
146
  return /* @__PURE__ */ jsxs(
85
147
  "div",
86
148
  {
@@ -293,49 +355,67 @@ function DateTimePicker({
293
355
  },
294
356
  i
295
357
  )) }),
296
- /* @__PURE__ */ jsx("div", { style: sx({ display: "grid", gridTemplateColumns: "repeat(7,1fr)", gap: "var(--space-1)" }), children: cells.map((d, i) => {
297
- if (d === null) return /* @__PURE__ */ jsx("span", { "aria-hidden": true, style: { height: cellH } }, i);
298
- const off = unavailable.includes(d);
299
- const sel = selectedDate === d && viewIndex === selectionIndex;
300
- const extra = renderDay?.(d);
301
- return /* @__PURE__ */ jsxs(
302
- "button",
303
- {
304
- type: "button",
305
- disabled: off,
306
- "aria-pressed": sel,
307
- onClick: () => {
308
- setSelectionIndex(viewIndex);
309
- onSelectDate?.(d);
310
- },
311
- style: sx({
312
- height: cellH,
313
- display: "flex",
314
- flexDirection: "column",
315
- alignItems: "center",
316
- justifyContent: "center",
317
- gap: 1,
318
- borderRadius: "var(--radius-sm)",
319
- border: "none",
320
- padding: 0,
321
- cursor: off ? "not-allowed" : "pointer",
322
- background: sel ? "var(--interactive-primary)" : "transparent",
323
- color: sel ? "var(--interactive-primary-fg)" : off ? "var(--text-disabled)" : "var(--text-primary)",
324
- fontFamily: "var(--font-body)",
325
- fontSize: "var(--text-sm)",
326
- fontWeight: sel ? "var(--weight-bold)" : "var(--weight-medium)",
327
- textDecoration: off ? "line-through" : "none",
328
- transition: "var(--transition-control)",
329
- outline: "none"
330
- }),
331
- children: [
332
- /* @__PURE__ */ jsx("span", { children: d }),
333
- renderDay ? /* @__PURE__ */ jsx("span", { style: sx({ display: "flex", minHeight: 12, lineHeight: 1 }), children: extra }) : null
334
- ]
335
- },
336
- i
337
- );
338
- }) }, viewIndex),
358
+ /* @__PURE__ */ jsx(
359
+ "div",
360
+ {
361
+ ref: gridRef,
362
+ onKeyDown: onGridKeyDown,
363
+ className: "sereno-dtp-days",
364
+ style: sx({ display: "grid", gridTemplateColumns: "repeat(7,1fr)", gap: "var(--space-1)" }),
365
+ children: cells.map((d, i) => {
366
+ if (d === null) return /* @__PURE__ */ jsx("span", { "aria-hidden": true, style: { height: cellH } }, i);
367
+ const off = unavailable.includes(d);
368
+ const sel = selectedDate === d && viewIndex === selectionIndex;
369
+ const extra = renderDay?.(d);
370
+ return /* @__PURE__ */ jsxs(
371
+ "button",
372
+ {
373
+ type: "button",
374
+ "data-day": d,
375
+ "aria-disabled": off || void 0,
376
+ tabIndex: d === rovingDay ? 0 : -1,
377
+ "aria-pressed": sel,
378
+ onClick: () => {
379
+ if (off) return;
380
+ setSelectionIndex(viewIndex);
381
+ setActiveDay(d);
382
+ onSelectDate?.(d);
383
+ },
384
+ style: sx({
385
+ height: cellH,
386
+ display: "flex",
387
+ flexDirection: "column",
388
+ alignItems: "center",
389
+ justifyContent: "center",
390
+ gap: 1,
391
+ borderRadius: "var(--radius-sm)",
392
+ border: "none",
393
+ padding: 0,
394
+ cursor: off ? "not-allowed" : "pointer",
395
+ background: sel ? "var(--interactive-primary)" : "transparent",
396
+ color: sel ? "var(--interactive-primary-fg)" : off ? "var(--text-disabled)" : "var(--text-primary)",
397
+ fontFamily: "var(--font-body)",
398
+ fontSize: "var(--text-sm)",
399
+ fontWeight: sel ? "var(--weight-bold)" : "var(--weight-medium)",
400
+ textDecoration: off ? "line-through" : "none",
401
+ transition: "var(--transition-control)"
402
+ // Not inline outline:none — that would always beat the
403
+ // .sereno-dtp-days:focus-visible rule below no matter what
404
+ // it says (inline style always outranks a class selector).
405
+ // Suppressed as a class rule instead, same specificity as
406
+ // the :focus-visible override that re-enables it.
407
+ }),
408
+ children: [
409
+ /* @__PURE__ */ jsx("span", { children: d }),
410
+ renderDay ? /* @__PURE__ */ jsx("span", { style: sx({ display: "flex", minHeight: 12, lineHeight: 1 }), children: extra }) : null
411
+ ]
412
+ },
413
+ i
414
+ );
415
+ })
416
+ },
417
+ viewIndex
418
+ ),
339
419
  times.length > 0 && /* @__PURE__ */ jsxs("div", { style: sx({ marginTop: "var(--space-4)", paddingTop: "var(--space-4)", borderTop: "var(--border-width-hairline) solid var(--border-subtle)" }), children: [
340
420
  /* @__PURE__ */ jsx(
341
421
  "div",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/forms/DateTimePicker.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { ChevronDown, ChevronLeft, ChevronRight } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { IconButton } from '../core/IconButton';\n\nexport interface TimeSlot {\n value: string;\n disabled?: boolean;\n}\n\n/**\n * Month calendar plus available time slots — the heart of the public booking flow.\n * Day names and month names render in pt-BR.\n *\n * The header navigates: ‹ / › step the month, and the centred title opens a\n * popover to jump straight to a month or year. `year` / `month` set the *initial*\n * view; the component then owns it. Pass `onMonthChange` to react to navigation\n * (e.g. fetch the new month's availability).\n */\nexport interface DateTimePickerProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {\n /** Initial year. Defaults to the current year. */\n year?: number;\n /** Initial month, 0-indexed. Defaults to the current month. */\n month?: number;\n /** Selected day-of-month. The highlight only shows in the month it was picked\n * in — navigating away and back to a *different* month never re-highlights it. */\n selectedDate?: number;\n /** Slot labels (\"09:00\") or objects with `disabled`. */\n times?: (string | TimeSlot)[];\n selectedTime?: string;\n /** Day numbers with no availability — struck through and unclickable. */\n unavailable?: number[];\n onSelectDate?: (day: number) => void;\n onSelectTime?: (time: string) => void;\n /** Fires whenever the visible month changes (arrows or the month/year popover). */\n onMonthChange?: (year: number, month: number) => void;\n /**\n * Extra content under each day number — a count badge, a dot, etc. Return\n * `null` for days with nothing to show. When set, every cell grows to keep the\n * grid even. It's the caller's job to scope this (e.g. future days only).\n */\n renderDay?: (day: number) => React.ReactNode;\n timeLabel?: string;\n}\n\nconst DOW = ['D', 'S', 'T', 'Q', 'Q', 'S', 'S'];\nconst MONTHS = ['janeiro', 'fevereiro', 'março', 'abril', 'maio', 'junho', 'julho', 'agosto', 'setembro', 'outubro', 'novembro', 'dezembro'];\nconst MONTHS_SHORT = ['jan', 'fev', 'mar', 'abr', 'mai', 'jun', 'jul', 'ago', 'set', 'out', 'nov', 'dez'];\n\nfunction daysIn(y: number, m: number): number {\n return new Date(y, m + 1, 0).getDate();\n}\n\nexport function DateTimePicker({\n year,\n month,\n selectedDate,\n times = [],\n selectedTime,\n unavailable = [],\n onSelectDate,\n onSelectTime,\n onMonthChange,\n renderDay,\n timeLabel = 'Horários disponíveis',\n style,\n ...rest\n}: DateTimePickerProps) {\n const now = React.useMemo(() => new Date(), []);\n // One integer for the visible month — `year*12 + month`. Keeps ‹ / › arithmetic\n // (and rapid clicks) correct across year boundaries with no Date() juggling.\n // `year` / `month` are the *initial* view; the component owns it after mount\n // (re-mount with a `key` to force a different start).\n const initialIndex = (year ?? now.getFullYear()) * 12 + (month ?? now.getMonth());\n const [viewIndex, setViewIndex] = React.useState(initialIndex);\n const viewYear = Math.floor(viewIndex / 12);\n const viewMonth = viewIndex % 12;\n // `selectedDate` is only a day number, so remember which month that pick was\n // made in — the highlight shows only there, never on the same day of another\n // month you navigate to.\n const [selectionIndex, setSelectionIndex] = React.useState(initialIndex);\n const [open, setOpen] = React.useState(false);\n const [picker, setPicker] = React.useState<'month' | 'year'>('month');\n const [yearBase, setYearBase] = React.useState(() => (year ?? now.getFullYear()) - 5);\n\n const rootRef = React.useRef<HTMLDivElement>(null);\n const titleRef = React.useRef<HTMLButtonElement>(null);\n const popRef = React.useRef<HTMLDivElement>(null);\n\n // Notify on navigation — never on mount, always with the settled value.\n const onMonthChangeRef = React.useRef(onMonthChange);\n React.useEffect(() => {\n onMonthChangeRef.current = onMonthChange;\n });\n const didMount = React.useRef(false);\n React.useEffect(() => {\n if (!didMount.current) {\n didMount.current = true;\n return;\n }\n onMonthChangeRef.current?.(Math.floor(viewIndex / 12), viewIndex % 12);\n }, [viewIndex]);\n\n // close on outside pointer; move focus into the popover on open\n React.useEffect(() => {\n if (!open) return;\n const onDown = (e: PointerEvent) => {\n if (rootRef.current && !rootRef.current.contains(e.target as Node)) {\n setOpen(false);\n setPicker('month');\n }\n };\n document.addEventListener('pointerdown', onDown, true);\n const id = requestAnimationFrame(() => popRef.current?.focus());\n return () => {\n document.removeEventListener('pointerdown', onDown, true);\n cancelAnimationFrame(id);\n };\n }, [open]);\n\n const closePopover = React.useCallback(() => {\n setOpen(false);\n setPicker('month');\n titleRef.current?.focus();\n }, []);\n const toggleOpen = React.useCallback(() => {\n setOpen((v) => {\n if (v) setPicker('month');\n return !v;\n });\n }, []);\n\n const first = new Date(viewYear, viewMonth, 1).getDay();\n const total = daysIn(viewYear, viewMonth);\n // Always 6 rows (42 cells) so the calendar's height never shifts between\n // months — trailing blanks pad it out and carry the cell height too.\n const cells: (number | null)[] = [...Array(first).fill(null), ...Array.from({ length: total }, (_, i) => i + 1)];\n while (cells.length < 42) cells.push(null);\n const cellH = renderDay ? 48 : 38;\n const years = Array.from({ length: 12 }, (_, i) => yearBase + i);\n\n return (\n <div\n {...rest}\n ref={rootRef}\n style={sx({\n position: 'relative',\n background: 'var(--bg-surface)',\n border: 'var(--border-width-hairline) solid var(--border-default)',\n borderRadius: 'var(--radius-card)',\n padding: 'var(--space-4)',\n boxShadow: 'var(--shadow-sm)',\n ...style,\n })}\n >\n <div\n style={sx({\n position: 'relative',\n display: 'grid',\n gridTemplateColumns: 'auto 1fr auto',\n alignItems: 'center',\n gap: 'var(--space-1)',\n marginBottom: 'var(--space-3)',\n })}\n >\n <IconButton label=\"Mês anterior\" size=\"sm\" onClick={() => setViewIndex((i) => i - 1)}>\n <ChevronLeft size={18} strokeWidth={1.75} />\n </IconButton>\n\n <button\n ref={titleRef}\n type=\"button\"\n className=\"sereno-dtp-title\"\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n onClick={toggleOpen}\n style={sx({\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 4,\n margin: '0 auto',\n padding: '4px 8px',\n border: 'none',\n borderRadius: 'var(--radius-sm)',\n background: 'transparent',\n cursor: 'pointer',\n fontFamily: 'var(--font-display)',\n fontSize: 'var(--text-base)',\n fontWeight: 'var(--weight-bold)',\n color: 'var(--text-primary)',\n textTransform: 'capitalize',\n })}\n >\n {MONTHS[viewMonth]} {viewYear}\n <ChevronDown size={15} strokeWidth={2} style={{ opacity: 0.6 }} />\n </button>\n\n <IconButton label=\"Próximo mês\" size=\"sm\" onClick={() => setViewIndex((i) => i + 1)}>\n <ChevronRight size={18} strokeWidth={1.75} />\n </IconButton>\n\n {open && (\n <div\n ref={popRef}\n role=\"dialog\"\n aria-label=\"Escolher mês e ano\"\n tabIndex={-1}\n onKeyDown={(e) => {\n if (e.key === 'Escape') {\n e.stopPropagation();\n closePopover();\n }\n }}\n className=\"sereno-dtp-pop\"\n style={sx({\n position: 'absolute',\n top: 'calc(100% + 6px)',\n left: '50%',\n transform: 'translateX(-50%)',\n zIndex: 20,\n width: 248,\n maxWidth: 'calc(100vw - 24px)',\n background: 'var(--bg-surface)',\n border: 'var(--border-width-hairline) solid var(--border-default)',\n borderRadius: 'var(--radius-md)',\n boxShadow: 'var(--shadow-lg)',\n padding: 'var(--space-3)',\n outline: 'none',\n })}\n >\n <div\n style={sx({\n display: 'grid',\n gridTemplateColumns: 'auto 1fr auto',\n alignItems: 'center',\n marginBottom: 'var(--space-2)',\n })}\n >\n <IconButton\n label={picker === 'month' ? 'Ano anterior' : 'Anos anteriores'}\n size=\"sm\"\n onClick={() => (picker === 'month' ? setViewIndex((i) => i - 12) : setYearBase((b) => b - 12))}\n >\n <ChevronLeft size={18} strokeWidth={1.75} />\n </IconButton>\n\n {picker === 'month' ? (\n <button\n type=\"button\"\n className=\"sereno-dtp-title\"\n onClick={() => {\n setYearBase(viewYear - 5);\n setPicker('year');\n }}\n style={sx({\n margin: '0 auto',\n padding: '4px 8px',\n border: 'none',\n borderRadius: 'var(--radius-sm)',\n background: 'transparent',\n cursor: 'pointer',\n fontFamily: 'var(--font-display)',\n fontSize: 'var(--text-sm)',\n fontWeight: 'var(--weight-bold)',\n color: 'var(--text-primary)',\n })}\n >\n {viewYear}\n </button>\n ) : (\n <span\n style={sx({\n textAlign: 'center',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n fontWeight: 'var(--weight-semibold)',\n color: 'var(--text-secondary)',\n })}\n >\n {years[0]}–{years[11]}\n </span>\n )}\n\n <IconButton\n label={picker === 'month' ? 'Próximo ano' : 'Próximos anos'}\n size=\"sm\"\n onClick={() => (picker === 'month' ? setViewIndex((i) => i + 12) : setYearBase((b) => b + 12))}\n >\n <ChevronRight size={18} strokeWidth={1.75} />\n </IconButton>\n </div>\n\n <div className=\"sereno-dtp-grid\" style={sx({ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 'var(--space-1)' })}>\n {picker === 'month'\n ? MONTHS_SHORT.map((mo, i) => (\n <button\n key={mo}\n type=\"button\"\n data-current={i === viewMonth || undefined}\n aria-current={i === viewMonth ? 'true' : undefined}\n onClick={() => {\n setViewIndex(viewYear * 12 + i);\n closePopover();\n }}\n >\n {mo}\n </button>\n ))\n : years.map((y) => (\n <button\n key={y}\n type=\"button\"\n data-current={y === viewYear || undefined}\n aria-current={y === viewYear ? 'true' : undefined}\n onClick={() => {\n setViewIndex(y * 12 + viewMonth);\n setPicker('month');\n }}\n >\n {y}\n </button>\n ))}\n </div>\n </div>\n )}\n </div>\n\n <div style={sx({ display: 'grid', gridTemplateColumns: 'repeat(7,1fr)', gap: 'var(--space-1)', marginBottom: 'var(--space-1)' })}>\n {DOW.map((d, i) => (\n <span\n key={i}\n style={sx({\n textAlign: 'center',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-2xs)',\n fontWeight: 'var(--weight-semibold)',\n color: 'var(--text-muted)',\n letterSpacing: 'var(--tracking-caps)',\n })}\n >\n {d}\n </span>\n ))}\n </div>\n {/* keyed on the month so cells remount cleanly — no bg transition when a\n slot morphs from one day to another on navigation. */}\n <div key={viewIndex} style={sx({ display: 'grid', gridTemplateColumns: 'repeat(7,1fr)', gap: 'var(--space-1)' })}>\n {cells.map((d, i) => {\n // Blank cells still take the row height so the 6-row grid can't collapse.\n if (d === null) return <span key={i} aria-hidden style={{ height: cellH }} />;\n const off = unavailable.includes(d);\n const sel = selectedDate === d && viewIndex === selectionIndex;\n const extra = renderDay?.(d);\n return (\n <button\n key={i}\n type=\"button\"\n disabled={off}\n aria-pressed={sel}\n onClick={() => {\n setSelectionIndex(viewIndex);\n onSelectDate?.(d);\n }}\n style={sx({\n height: cellH,\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 1,\n borderRadius: 'var(--radius-sm)',\n border: 'none',\n padding: 0,\n cursor: off ? 'not-allowed' : 'pointer',\n background: sel ? 'var(--interactive-primary)' : 'transparent',\n color: sel ? 'var(--interactive-primary-fg)' : off ? 'var(--text-disabled)' : 'var(--text-primary)',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n fontWeight: sel ? 'var(--weight-bold)' : 'var(--weight-medium)',\n textDecoration: off ? 'line-through' : 'none',\n transition: 'var(--transition-control)',\n outline: 'none',\n })}\n >\n <span>{d}</span>\n {renderDay ? <span style={sx({ display: 'flex', minHeight: 12, lineHeight: 1 })}>{extra}</span> : null}\n </button>\n );\n })}\n </div>\n {times.length > 0 && (\n <div style={sx({ marginTop: 'var(--space-4)', paddingTop: 'var(--space-4)', borderTop: 'var(--border-width-hairline) solid var(--border-subtle)' })}>\n <div\n style={sx({\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-xs)',\n fontWeight: 'var(--weight-semibold)',\n color: 'var(--text-secondary)',\n letterSpacing: 'var(--tracking-caps)',\n textTransform: 'uppercase',\n marginBottom: 'var(--space-3)',\n })}\n >\n {timeLabel}\n </div>\n <div style={sx({ display: 'grid', gridTemplateColumns: 'repeat(auto-fill,minmax(76px,1fr))', gap: 'var(--space-2)' })}>\n {times.map((t) => {\n const val = typeof t === 'string' ? t : t.value;\n const dis = typeof t === 'object' && t.disabled;\n const sel = selectedTime === val;\n return (\n <button\n key={val}\n type=\"button\"\n disabled={dis}\n onClick={() => onSelectTime && onSelectTime(val)}\n style={sx({\n height: 'var(--control-height-md)',\n borderRadius: 'var(--radius-control)',\n cursor: dis ? 'not-allowed' : 'pointer',\n border: 'var(--border-width-hairline) solid ' + (sel ? 'transparent' : 'var(--border-default)'),\n background: sel ? 'var(--interactive-accent)' : dis ? 'var(--interactive-disabled-bg)' : 'var(--bg-surface)',\n color: sel ? 'var(--interactive-accent-fg)' : dis ? 'var(--interactive-disabled-fg)' : 'var(--text-primary)',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n fontWeight: 'var(--weight-semibold)',\n transition: 'var(--transition-control)',\n outline: 'none',\n })}\n >\n {val}\n </button>\n );\n })}\n </div>\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";AAwKU,cAGF,YAHE;AAtKV,YAAY,WAAW;AACvB,SAAS,aAAa,aAAa,oBAAoB;AACvD,SAAS,UAAU;AACnB,SAAS,kBAAkB;AA0C3B,MAAM,MAAM,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,GAAG;AAC9C,MAAM,SAAS,CAAC,WAAW,aAAa,YAAS,SAAS,QAAQ,SAAS,SAAS,UAAU,YAAY,WAAW,YAAY,UAAU;AAC3I,M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C;AAAA;AAAA,gBAEC,MAAK;AAAA,gBACL,UAAU;AAAA,gBACV,SAAS,MAAM,gBAAgB,aAAa,GAAG;AAAA,gBAC/C,OAAO,GAAG;AAAA,kBACR,QAAQ;AAAA,kBACR,cAAc;AAAA,kBACd,QAAQ,MAAM,gBAAgB;AAAA,kBAC9B,QAAQ,yCAAyC,MAAM,gBAAgB;AAAA,kBACvE,YAAY,MAAM,8BAA8B,MAAM,mCAAmC;AAAA,kBACzF,OAAO,MAAM,iCAAiC,MAAM,mCAAmC;AAAA,kBACvF,YAAY;AAAA,kBACZ,UAAU;AAAA,kBACV,YAAY;AAAA,kBACZ,YAAY;AAAA,kBACZ,SAAS;AAAA,gBACX,CAAC;AAAA,gBAEA;AAAA;AAAA,cAlBI;AAAA,YAmBP;AAAA,UAEJ,CAAC,GACH;AAAA,WACF;AAAA;AAAA;AAAA,EAEJ;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/forms/DateTimePicker.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { ChevronDown, ChevronLeft, ChevronRight } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { IconButton } from '../core/IconButton';\n\nexport interface TimeSlot {\n value: string;\n disabled?: boolean;\n}\n\n/**\n * Month calendar plus available time slots — the heart of the public booking flow.\n * Day names and month names render in pt-BR.\n *\n * The header navigates: ‹ / › step the month, and the centred title opens a\n * popover to jump straight to a month or year. `year` / `month` set the *initial*\n * view; the component then owns it. Pass `onMonthChange` to react to navigation\n * (e.g. fetch the new month's availability).\n *\n * The day grid uses roving tabindex (SS-228) — only one cell is ever in the\n * Tab order, so Tab enters/leaves it in one stop instead of one per day.\n * Arrow keys move by day/week and cross month boundaries on overflow;\n * Home/End move within the current week row; PageUp/PageDown step the\n * month. An `unavailable` day stays focusable (`aria-disabled`, not the\n * native `disabled` — a disabled button can't receive focus at all) so the\n * cursor can still land on it, just not select it.\n */\nexport interface DateTimePickerProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {\n /** Initial year. Defaults to the current year. */\n year?: number;\n /** Initial month, 0-indexed. Defaults to the current month. */\n month?: number;\n /** Selected day-of-month. The highlight only shows in the month it was picked\n * in — navigating away and back to a *different* month never re-highlights it. */\n selectedDate?: number;\n /** Slot labels (\"09:00\") or objects with `disabled`. */\n times?: (string | TimeSlot)[];\n selectedTime?: string;\n /** Day numbers with no availability — struck through and unclickable. */\n unavailable?: number[];\n onSelectDate?: (day: number) => void;\n onSelectTime?: (time: string) => void;\n /** Fires whenever the visible month changes (arrows or the month/year popover). */\n onMonthChange?: (year: number, month: number) => void;\n /**\n * Extra content under each day number — a count badge, a dot, etc. Return\n * `null` for days with nothing to show. When set, every cell grows to keep the\n * grid even. It's the caller's job to scope this (e.g. future days only).\n */\n renderDay?: (day: number) => React.ReactNode;\n timeLabel?: string;\n}\n\nconst DOW = ['D', 'S', 'T', 'Q', 'Q', 'S', 'S'];\nconst MONTHS = ['janeiro', 'fevereiro', 'março', 'abril', 'maio', 'junho', 'julho', 'agosto', 'setembro', 'outubro', 'novembro', 'dezembro'];\nconst MONTHS_SHORT = ['jan', 'fev', 'mar', 'abr', 'mai', 'jun', 'jul', 'ago', 'set', 'out', 'nov', 'dez'];\n\nfunction daysIn(y: number, m: number): number {\n return new Date(y, m + 1, 0).getDate();\n}\n\nexport function DateTimePicker({\n year,\n month,\n selectedDate,\n times = [],\n selectedTime,\n unavailable = [],\n onSelectDate,\n onSelectTime,\n onMonthChange,\n renderDay,\n timeLabel = 'Horários disponíveis',\n style,\n ...rest\n}: DateTimePickerProps) {\n const now = React.useMemo(() => new Date(), []);\n // One integer for the visible month — `year*12 + month`. Keeps ‹ / › arithmetic\n // (and rapid clicks) correct across year boundaries with no Date() juggling.\n // `year` / `month` are the *initial* view; the component owns it after mount\n // (re-mount with a `key` to force a different start).\n const initialIndex = (year ?? now.getFullYear()) * 12 + (month ?? now.getMonth());\n const [viewIndex, setViewIndex] = React.useState(initialIndex);\n const viewYear = Math.floor(viewIndex / 12);\n const viewMonth = viewIndex % 12;\n // `selectedDate` is only a day number, so remember which month that pick was\n // made in — the highlight shows only there, never on the same day of another\n // month you navigate to.\n const [selectionIndex, setSelectionIndex] = React.useState(initialIndex);\n const [open, setOpen] = React.useState(false);\n const [picker, setPicker] = React.useState<'month' | 'year'>('month');\n const [yearBase, setYearBase] = React.useState(() => (year ?? now.getFullYear()) - 5);\n\n const rootRef = React.useRef<HTMLDivElement>(null);\n const titleRef = React.useRef<HTMLButtonElement>(null);\n const popRef = React.useRef<HTMLDivElement>(null);\n const gridRef = React.useRef<HTMLDivElement>(null);\n\n // Roving tabindex for the day grid: only one cell is ever in the Tab\n // order (below), so Tab enters/leaves the whole grid in one stop instead\n // of one per day. `activeDay` is the day-of-month that cell represents —\n // clamped to the visible month's length at render (below), since it\n // persists across a month change (‹ / › or an arrow-key crossing) where\n // the same day number may no longer exist (e.g. the 31st, into February).\n const [activeDay, setActiveDay] = React.useState(() => {\n if (selectedDate) return selectedDate;\n const todayIndex = now.getFullYear() * 12 + now.getMonth();\n return todayIndex === initialIndex ? now.getDate() : 1;\n });\n // Set right before a keyboard move changes activeDay/viewIndex; consumed\n // by the layout effect below to focus the new cell once it's in the DOM —\n // never on an unrelated render (a prop change, a re-render from the\n // parent) or the initial mount.\n const shouldFocusDayRef = React.useRef(false);\n\n // Notify on navigation — never on mount, always with the settled value.\n const onMonthChangeRef = React.useRef(onMonthChange);\n React.useEffect(() => {\n onMonthChangeRef.current = onMonthChange;\n });\n const didMount = React.useRef(false);\n React.useEffect(() => {\n if (!didMount.current) {\n didMount.current = true;\n return;\n }\n onMonthChangeRef.current?.(Math.floor(viewIndex / 12), viewIndex % 12);\n }, [viewIndex]);\n\n // close on outside pointer; move focus into the popover on open\n React.useEffect(() => {\n if (!open) return;\n const onDown = (e: PointerEvent) => {\n if (rootRef.current && !rootRef.current.contains(e.target as Node)) {\n setOpen(false);\n setPicker('month');\n }\n };\n document.addEventListener('pointerdown', onDown, true);\n const id = requestAnimationFrame(() => popRef.current?.focus());\n return () => {\n document.removeEventListener('pointerdown', onDown, true);\n cancelAnimationFrame(id);\n };\n }, [open]);\n\n const closePopover = React.useCallback(() => {\n setOpen(false);\n setPicker('month');\n titleRef.current?.focus();\n }, []);\n const toggleOpen = React.useCallback(() => {\n setOpen((v) => {\n if (v) setPicker('month');\n return !v;\n });\n }, []);\n\n const first = new Date(viewYear, viewMonth, 1).getDay();\n const total = daysIn(viewYear, viewMonth);\n // Always 6 rows (42 cells) so the calendar's height never shifts between\n // months — trailing blanks pad it out and carry the cell height too.\n const cells: (number | null)[] = [...Array(first).fill(null), ...Array.from({ length: total }, (_, i) => i + 1)];\n while (cells.length < 42) cells.push(null);\n const cellH = renderDay ? 48 : 38;\n const years = Array.from({ length: 12 }, (_, i) => yearBase + i);\n const rovingDay = Math.min(Math.max(1, activeDay), total);\n\n // Arrow keys move the roving cursor by real calendar days — crossing into\n // the adjacent month's grid when they overflow the visible one, rather\n // than stopping dead at the edge. Home/End stay within the current week\n // row; PageUp/PageDown step the month (reusing the same ‹ / › state\n // change, so onMonthChange fires identically either way).\n const onGridKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n let delta = 0;\n switch (e.key) {\n case 'ArrowRight':\n delta = 1;\n break;\n case 'ArrowLeft':\n delta = -1;\n break;\n case 'ArrowDown':\n delta = 7;\n break;\n case 'ArrowUp':\n delta = -7;\n break;\n case 'Home': {\n e.preventDefault();\n const row = Math.floor((first + rovingDay - 1) / 7);\n shouldFocusDayRef.current = true;\n setActiveDay(Math.max(1, row * 7 - first + 1));\n return;\n }\n case 'End': {\n e.preventDefault();\n const row = Math.floor((first + rovingDay - 1) / 7);\n shouldFocusDayRef.current = true;\n setActiveDay(Math.min(total, row * 7 + 7 - first));\n return;\n }\n case 'PageUp':\n e.preventDefault();\n shouldFocusDayRef.current = true;\n setViewIndex((i) => i - 1);\n return;\n case 'PageDown':\n e.preventDefault();\n shouldFocusDayRef.current = true;\n setViewIndex((i) => i + 1);\n return;\n default:\n return;\n }\n e.preventDefault();\n const next = new Date(viewYear, viewMonth, rovingDay + delta);\n const nextViewIndex = next.getFullYear() * 12 + next.getMonth();\n shouldFocusDayRef.current = true;\n if (nextViewIndex !== viewIndex) setViewIndex(nextViewIndex);\n setActiveDay(next.getDate());\n };\n\n // Runs after the grid above (keyed on viewIndex, so a month change remounts\n // it) has committed the DOM for the new activeDay/viewIndex — only then\n // does the target cell actually exist to focus.\n React.useLayoutEffect(() => {\n if (!shouldFocusDayRef.current) return;\n shouldFocusDayRef.current = false;\n gridRef.current?.querySelector<HTMLButtonElement>(`[data-day=\"${rovingDay}\"]`)?.focus();\n }, [viewIndex, rovingDay]);\n\n return (\n <div\n {...rest}\n ref={rootRef}\n style={sx({\n position: 'relative',\n background: 'var(--bg-surface)',\n border: 'var(--border-width-hairline) solid var(--border-default)',\n borderRadius: 'var(--radius-card)',\n padding: 'var(--space-4)',\n boxShadow: 'var(--shadow-sm)',\n ...style,\n })}\n >\n <div\n style={sx({\n position: 'relative',\n display: 'grid',\n gridTemplateColumns: 'auto 1fr auto',\n alignItems: 'center',\n gap: 'var(--space-1)',\n marginBottom: 'var(--space-3)',\n })}\n >\n <IconButton label=\"Mês anterior\" size=\"sm\" onClick={() => setViewIndex((i) => i - 1)}>\n <ChevronLeft size={18} strokeWidth={1.75} />\n </IconButton>\n\n <button\n ref={titleRef}\n type=\"button\"\n className=\"sereno-dtp-title\"\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n onClick={toggleOpen}\n style={sx({\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 4,\n margin: '0 auto',\n padding: '4px 8px',\n border: 'none',\n borderRadius: 'var(--radius-sm)',\n background: 'transparent',\n cursor: 'pointer',\n fontFamily: 'var(--font-display)',\n fontSize: 'var(--text-base)',\n fontWeight: 'var(--weight-bold)',\n color: 'var(--text-primary)',\n textTransform: 'capitalize',\n })}\n >\n {MONTHS[viewMonth]} {viewYear}\n <ChevronDown size={15} strokeWidth={2} style={{ opacity: 0.6 }} />\n </button>\n\n <IconButton label=\"Próximo mês\" size=\"sm\" onClick={() => setViewIndex((i) => i + 1)}>\n <ChevronRight size={18} strokeWidth={1.75} />\n </IconButton>\n\n {open && (\n <div\n ref={popRef}\n role=\"dialog\"\n aria-label=\"Escolher mês e ano\"\n tabIndex={-1}\n onKeyDown={(e) => {\n if (e.key === 'Escape') {\n e.stopPropagation();\n closePopover();\n }\n }}\n className=\"sereno-dtp-pop\"\n style={sx({\n position: 'absolute',\n top: 'calc(100% + 6px)',\n left: '50%',\n transform: 'translateX(-50%)',\n zIndex: 20,\n width: 248,\n maxWidth: 'calc(100vw - 24px)',\n background: 'var(--bg-surface)',\n border: 'var(--border-width-hairline) solid var(--border-default)',\n borderRadius: 'var(--radius-md)',\n boxShadow: 'var(--shadow-lg)',\n padding: 'var(--space-3)',\n outline: 'none',\n })}\n >\n <div\n style={sx({\n display: 'grid',\n gridTemplateColumns: 'auto 1fr auto',\n alignItems: 'center',\n marginBottom: 'var(--space-2)',\n })}\n >\n <IconButton\n label={picker === 'month' ? 'Ano anterior' : 'Anos anteriores'}\n size=\"sm\"\n onClick={() => (picker === 'month' ? setViewIndex((i) => i - 12) : setYearBase((b) => b - 12))}\n >\n <ChevronLeft size={18} strokeWidth={1.75} />\n </IconButton>\n\n {picker === 'month' ? (\n <button\n type=\"button\"\n className=\"sereno-dtp-title\"\n onClick={() => {\n setYearBase(viewYear - 5);\n setPicker('year');\n }}\n style={sx({\n margin: '0 auto',\n padding: '4px 8px',\n border: 'none',\n borderRadius: 'var(--radius-sm)',\n background: 'transparent',\n cursor: 'pointer',\n fontFamily: 'var(--font-display)',\n fontSize: 'var(--text-sm)',\n fontWeight: 'var(--weight-bold)',\n color: 'var(--text-primary)',\n })}\n >\n {viewYear}\n </button>\n ) : (\n <span\n style={sx({\n textAlign: 'center',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n fontWeight: 'var(--weight-semibold)',\n color: 'var(--text-secondary)',\n })}\n >\n {years[0]}–{years[11]}\n </span>\n )}\n\n <IconButton\n label={picker === 'month' ? 'Próximo ano' : 'Próximos anos'}\n size=\"sm\"\n onClick={() => (picker === 'month' ? setViewIndex((i) => i + 12) : setYearBase((b) => b + 12))}\n >\n <ChevronRight size={18} strokeWidth={1.75} />\n </IconButton>\n </div>\n\n <div className=\"sereno-dtp-grid\" style={sx({ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 'var(--space-1)' })}>\n {picker === 'month'\n ? MONTHS_SHORT.map((mo, i) => (\n <button\n key={mo}\n type=\"button\"\n data-current={i === viewMonth || undefined}\n aria-current={i === viewMonth ? 'true' : undefined}\n onClick={() => {\n setViewIndex(viewYear * 12 + i);\n closePopover();\n }}\n >\n {mo}\n </button>\n ))\n : years.map((y) => (\n <button\n key={y}\n type=\"button\"\n data-current={y === viewYear || undefined}\n aria-current={y === viewYear ? 'true' : undefined}\n onClick={() => {\n setViewIndex(y * 12 + viewMonth);\n setPicker('month');\n }}\n >\n {y}\n </button>\n ))}\n </div>\n </div>\n )}\n </div>\n\n <div style={sx({ display: 'grid', gridTemplateColumns: 'repeat(7,1fr)', gap: 'var(--space-1)', marginBottom: 'var(--space-1)' })}>\n {DOW.map((d, i) => (\n <span\n key={i}\n style={sx({\n textAlign: 'center',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-2xs)',\n fontWeight: 'var(--weight-semibold)',\n color: 'var(--text-muted)',\n letterSpacing: 'var(--tracking-caps)',\n })}\n >\n {d}\n </span>\n ))}\n </div>\n {/* keyed on the month so cells remount cleanly — no bg transition when a\n slot morphs from one day to another on navigation. */}\n <div\n key={viewIndex}\n ref={gridRef}\n onKeyDown={onGridKeyDown}\n className=\"sereno-dtp-days\"\n style={sx({ display: 'grid', gridTemplateColumns: 'repeat(7,1fr)', gap: 'var(--space-1)' })}\n >\n {cells.map((d, i) => {\n // Blank cells still take the row height so the 6-row grid can't collapse.\n if (d === null) return <span key={i} aria-hidden style={{ height: cellH }} />;\n const off = unavailable.includes(d);\n const sel = selectedDate === d && viewIndex === selectionIndex;\n const extra = renderDay?.(d);\n return (\n <button\n key={i}\n type=\"button\"\n data-day={d}\n // Not the native `disabled` — an unavailable day stays a real,\n // focusable stop on the roving cursor (aria-disabled only) so\n // arrow-key navigation can still land on it and the user can\n // tell it exists, matching the WAI-ARIA date-grid pattern. A\n // truly `disabled` button can't receive focus at all, which\n // would make the roving tabindex below silently break.\n aria-disabled={off || undefined}\n tabIndex={d === rovingDay ? 0 : -1}\n aria-pressed={sel}\n onClick={() => {\n if (off) return;\n setSelectionIndex(viewIndex);\n // Keep the roving cursor in sync with a mouse pick too — a\n // click already moves real DOM focus onto this button\n // natively, so without this the *next* arrow press would\n // jump from wherever the keyboard cursor was left instead\n // of from the day the user can see is focused/selected.\n setActiveDay(d);\n onSelectDate?.(d);\n }}\n style={sx({\n height: cellH,\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 1,\n borderRadius: 'var(--radius-sm)',\n border: 'none',\n padding: 0,\n cursor: off ? 'not-allowed' : 'pointer',\n background: sel ? 'var(--interactive-primary)' : 'transparent',\n color: sel ? 'var(--interactive-primary-fg)' : off ? 'var(--text-disabled)' : 'var(--text-primary)',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n fontWeight: sel ? 'var(--weight-bold)' : 'var(--weight-medium)',\n textDecoration: off ? 'line-through' : 'none',\n transition: 'var(--transition-control)',\n // Not inline outline:none — that would always beat the\n // .sereno-dtp-days:focus-visible rule below no matter what\n // it says (inline style always outranks a class selector).\n // Suppressed as a class rule instead, same specificity as\n // the :focus-visible override that re-enables it.\n })}\n >\n <span>{d}</span>\n {renderDay ? <span style={sx({ display: 'flex', minHeight: 12, lineHeight: 1 })}>{extra}</span> : null}\n </button>\n );\n })}\n </div>\n {times.length > 0 && (\n <div style={sx({ marginTop: 'var(--space-4)', paddingTop: 'var(--space-4)', borderTop: 'var(--border-width-hairline) solid var(--border-subtle)' })}>\n <div\n style={sx({\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-xs)',\n fontWeight: 'var(--weight-semibold)',\n color: 'var(--text-secondary)',\n letterSpacing: 'var(--tracking-caps)',\n textTransform: 'uppercase',\n marginBottom: 'var(--space-3)',\n })}\n >\n {timeLabel}\n </div>\n <div style={sx({ display: 'grid', gridTemplateColumns: 'repeat(auto-fill,minmax(76px,1fr))', gap: 'var(--space-2)' })}>\n {times.map((t) => {\n const val = typeof t === 'string' ? t : t.value;\n const dis = typeof t === 'object' && t.disabled;\n const sel = selectedTime === val;\n return (\n <button\n key={val}\n type=\"button\"\n disabled={dis}\n onClick={() => onSelectTime && onSelectTime(val)}\n style={sx({\n height: 'var(--control-height-md)',\n borderRadius: 'var(--radius-control)',\n cursor: dis ? 'not-allowed' : 'pointer',\n border: 'var(--border-width-hairline) solid ' + (sel ? 'transparent' : 'var(--border-default)'),\n background: sel ? 'var(--interactive-accent)' : dis ? 'var(--interactive-disabled-bg)' : 'var(--bg-surface)',\n color: sel ? 'var(--interactive-accent-fg)' : dis ? 'var(--interactive-disabled-fg)' : 'var(--text-primary)',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n fontWeight: 'var(--weight-semibold)',\n transition: 'var(--transition-control)',\n outline: 'none',\n })}\n >\n {val}\n </button>\n );\n })}\n </div>\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";AAmQU,cAGF,YAHE;AAjQV,YAAY,WAAW;AACvB,SAAS,aAAa,aAAa,oBAAoB;AACvD,SAAS,UAAU;AACnB,SAAS,kBAAkB;AAkD3B,MAAM,MAAM,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,GAAG;AAC9C,MAAM,SAAS,CAAC,WAAW,aAAa,YAAS,SAAS,QAAQ,SAAS,SAAS,UAAU,YAAY,WAAW,YAAY,UAAU;AAC3I,MAAM,eAAe,CAAC,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAA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B,WAAW,0DAA0D,CAAC,GAChJ;AAAA;AAAA,YAAC;AAAA;AAAA,cACC,OAAO,GAAG;AAAA,gBACR,YAAY;AAAA,gBACZ,UAAU;AAAA,gBACV,YAAY;AAAA,gBACZ,OAAO;AAAA,gBACP,eAAe;AAAA,gBACf,eAAe;AAAA,gBACf,cAAc;AAAA,cAChB,CAAC;AAAA,cAEA;AAAA;AAAA,UACH;AAAA,UACA,oBAAC,SAAI,OAAO,GAAG,EAAE,SAAS,QAAQ,qBAAqB,sCAAsC,KAAK,iBAAiB,CAAC,GACjH,gBAAM,IAAI,CAAC,MAAM;AAChB,kBAAM,MAAM,OAAO,MAAM,WAAW,IAAI,EAAE;AAC1C,kBAAM,MAAM,OAAO,MAAM,YAAY,EAAE;AACvC,kBAAM,MAAM,iBAAiB;AAC7B,mBACE;AAAA,cAAC;AAAA;AAAA,gBAEC,MAAK;AAAA,gBACL,UAAU;AAAA,gBACV,SAAS,MAAM,gBAAgB,aAAa,GAAG;AAAA,gBAC/C,OAAO,GAAG;AAAA,kBACR,QAAQ;AAAA,kBACR,cAAc;AAAA,kBACd,QAAQ,MAAM,gBAAgB;AAAA,kBAC9B,QAAQ,yCAAyC,MAAM,gBAAgB;AAAA,kBACvE,YAAY,MAAM,8BAA8B,MAAM,mCAAmC;AAAA,kBACzF,OAAO,MAAM,iCAAiC,MAAM,mCAAmC;AAAA,kBACvF,YAAY;AAAA,kBACZ,UAAU;AAAA,kBACV,YAAY;AAAA,kBACZ,YAAY;AAAA,kBACZ,SAAS;AAAA,gBACX,CAAC;AAAA,gBAEA;AAAA;AAAA,cAlBI;AAAA,YAmBP;AAAA,UAEJ,CAAC,GACH;AAAA,WACF;AAAA;AAAA;AAAA,EAEJ;AAEJ;","names":[]}
@@ -5,6 +5,11 @@ import * as React from 'react';
5
5
  * Group by giving every option the same `name`. Visually matched to `Checkbox` — same 20px
6
6
  * box, same hover and label/description rhythm — differing only in the pill radius and dot.
7
7
  * Host must include the `.sereno-radio:checked` rule (see globals.css).
8
+ *
9
+ * Wrap every group in a `<fieldset>` / `<legend>` — `name` alone makes the browser treat
10
+ * the options as one native group (arrow keys move between them, only one can be checked),
11
+ * but without a `<legend>` a screen reader has no accessible name for what the choice is
12
+ * between, only "Online, radio button, 1 of 3" with no context.
8
13
  */
9
14
  interface RadioProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'size'> {
10
15
  label?: string;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/forms/Radio.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\n\n/**\n * Single-choice control for mutually exclusive options (payment method, appointment format).\n * Group by giving every option the same `name`. Visually matched to `Checkbox` — same 20px\n * box, same hover and label/description rhythm — differing only in the pill radius and dot.\n * Host must include the `.sereno-radio:checked` rule (see globals.css).\n */\nexport interface RadioProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'size'> {\n label?: string;\n /** Secondary line under the label. */\n description?: string;\n /** Circle size. `sm` (16px) for dense lists; `md` (20px) everywhere else. Matches `Checkbox`. */\n size?: 'sm' | 'md';\n}\n\nexport function Radio({ label, description, checked, defaultChecked, disabled, size = 'md', onChange, style, ...rest }: RadioProps) {\n const [hover, setHover] = React.useState(false);\n const box = size === 'sm' ? 16 : 20;\n return (\n <label\n onMouseEnter={() => setHover(true)}\n onMouseLeave={() => setHover(false)}\n style={sx({ display: 'flex', gap: 'var(--space-3)', alignItems: 'flex-start', cursor: disabled ? 'not-allowed' : 'pointer', opacity: disabled ? 0.6 : 1, ...style })}\n >\n <span style={sx({ position: 'relative', display: 'inline-flex', flex: '0 0 auto', marginTop: size === 'sm' ? 3 : 1 })}>\n <input\n type=\"radio\"\n checked={checked}\n defaultChecked={defaultChecked}\n disabled={disabled}\n onChange={onChange}\n {...rest}\n data-size={size}\n className=\"sereno-radio\"\n style={sx({\n appearance: 'none',\n width: box,\n height: box,\n margin: 0,\n borderRadius: 'var(--radius-pill)',\n border: 'var(--border-width-emphasis) solid ' + (hover && !disabled ? 'var(--border-brand)' : 'var(--border-strong)'),\n backgroundColor: 'var(--bg-surface)',\n cursor: 'inherit',\n transition: 'var(--transition-control)',\n })}\n />\n </span>\n <span style={sx({ display: 'flex', flexDirection: 'column', gap: 2 })}>\n {label && <span style={sx({ fontFamily: 'var(--font-body)', fontSize: 'var(--text-base)', color: 'var(--text-primary)', lineHeight: 1.35 })}>{label}</span>}\n {description && (\n <span style={sx({ fontFamily: 'var(--font-body)', fontSize: 'var(--text-xs)', color: 'var(--text-muted)', lineHeight: 1.45 })}>{description}</span>\n )}\n </span>\n </label>\n );\n}"],"mappings":";AA6BQ,cAsBF,YAtBE;AA3BR,YAAY,WAAW;AACvB,SAAS,UAAU;AAgBZ,SAAS,MAAM,EAAE,OAAO,aAAa,SAAS,gBAAgB,UAAU,OAAO,MAAM,UAAU,OAAO,GAAG,KAAK,GAAe;AAClI,QAAM,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAS,KAAK;AAC9C,QAAM,MAAM,SAAS,OAAO,KAAK;AACjC,SACE;AAAA,IAAC;AAAA;AAAA,MACC,cAAc,MAAM,SAAS,IAAI;AAAA,MACjC,cAAc,MAAM,SAAS,KAAK;AAAA,MAClC,OAAO,GAAG,EAAE,SAAS,QAAQ,KAAK,kBAAkB,YAAY,cAAc,QAAQ,WAAW,gBAAgB,WAAW,SAAS,WAAW,MAAM,GAAG,GAAG,MAAM,CAAC;AAAA,MAEnK;AAAA,4BAAC,UAAK,OAAO,GAAG,EAAE,UAAU,YAAY,SAAS,eAAe,MAAM,YAAY,WAAW,SAAS,OAAO,IAAI,EAAE,CAAC,GAClH;AAAA,UAAC;AAAA;AAAA,YACC,MAAK;AAAA,YACL;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACC,GAAG;AAAA,YACJ,aAAW;AAAA,YACX,WAAU;AAAA,YACV,OAAO,GAAG;AAAA,cACR,YAAY;AAAA,cACZ,OAAO;AAAA,cACP,QAAQ;AAAA,cACR,QAAQ;AAAA,cACR,cAAc;AAAA,cACd,QAAQ,yCAAyC,SAAS,CAAC,WAAW,wBAAwB;AAAA,cAC9F,iBAAiB;AAAA,cACjB,QAAQ;AAAA,cACR,YAAY;AAAA,YACd,CAAC;AAAA;AAAA,QACH,GACF;AAAA,QACA,qBAAC,UAAK,OAAO,GAAG,EAAE,SAAS,QAAQ,eAAe,UAAU,KAAK,EAAE,CAAC,GACjE;AAAA,mBAAS,oBAAC,UAAK,OAAO,GAAG,EAAE,YAAY,oBAAoB,UAAU,oBAAoB,OAAO,uBAAuB,YAAY,KAAK,CAAC,GAAI,iBAAM;AAAA,UACnJ,eACC,oBAAC,UAAK,OAAO,GAAG,EAAE,YAAY,oBAAoB,UAAU,kBAAkB,OAAO,qBAAqB,YAAY,KAAK,CAAC,GAAI,uBAAY;AAAA,WAEhJ;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/forms/Radio.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\n\n/**\n * Single-choice control for mutually exclusive options (payment method, appointment format).\n * Group by giving every option the same `name`. Visually matched to `Checkbox` — same 20px\n * box, same hover and label/description rhythm — differing only in the pill radius and dot.\n * Host must include the `.sereno-radio:checked` rule (see globals.css).\n *\n * Wrap every group in a `<fieldset>` / `<legend>` — `name` alone makes the browser treat\n * the options as one native group (arrow keys move between them, only one can be checked),\n * but without a `<legend>` a screen reader has no accessible name for what the choice is\n * between, only \"Online, radio button, 1 of 3\" with no context.\n */\nexport interface RadioProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'size'> {\n label?: string;\n /** Secondary line under the label. */\n description?: string;\n /** Circle size. `sm` (16px) for dense lists; `md` (20px) everywhere else. Matches `Checkbox`. */\n size?: 'sm' | 'md';\n}\n\nexport function Radio({ label, description, checked, defaultChecked, disabled, size = 'md', onChange, style, ...rest }: RadioProps) {\n const [hover, setHover] = React.useState(false);\n const box = size === 'sm' ? 16 : 20;\n return (\n <label\n onMouseEnter={() => setHover(true)}\n onMouseLeave={() => setHover(false)}\n style={sx({ display: 'flex', gap: 'var(--space-3)', alignItems: 'flex-start', cursor: disabled ? 'not-allowed' : 'pointer', opacity: disabled ? 0.6 : 1, ...style })}\n >\n <span style={sx({ position: 'relative', display: 'inline-flex', flex: '0 0 auto', marginTop: size === 'sm' ? 3 : 1 })}>\n <input\n type=\"radio\"\n checked={checked}\n defaultChecked={defaultChecked}\n disabled={disabled}\n onChange={onChange}\n {...rest}\n data-size={size}\n className=\"sereno-radio\"\n style={sx({\n appearance: 'none',\n width: box,\n height: box,\n margin: 0,\n borderRadius: 'var(--radius-pill)',\n border: 'var(--border-width-emphasis) solid ' + (hover && !disabled ? 'var(--border-brand)' : 'var(--border-strong)'),\n backgroundColor: 'var(--bg-surface)',\n cursor: 'inherit',\n transition: 'var(--transition-control)',\n })}\n />\n </span>\n <span style={sx({ display: 'flex', flexDirection: 'column', gap: 2 })}>\n {label && <span style={sx({ fontFamily: 'var(--font-body)', fontSize: 'var(--text-base)', color: 'var(--text-primary)', lineHeight: 1.35 })}>{label}</span>}\n {description && (\n <span style={sx({ fontFamily: 'var(--font-body)', fontSize: 'var(--text-xs)', color: 'var(--text-muted)', lineHeight: 1.45 })}>{description}</span>\n )}\n </span>\n </label>\n );\n}"],"mappings":";AAkCQ,cAsBF,YAtBE;AAhCR,YAAY,WAAW;AACvB,SAAS,UAAU;AAqBZ,SAAS,MAAM,EAAE,OAAO,aAAa,SAAS,gBAAgB,UAAU,OAAO,MAAM,UAAU,OAAO,GAAG,KAAK,GAAe;AAClI,QAAM,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAS,KAAK;AAC9C,QAAM,MAAM,SAAS,OAAO,KAAK;AACjC,SACE;AAAA,IAAC;AAAA;AAAA,MACC,cAAc,MAAM,SAAS,IAAI;AAAA,MACjC,cAAc,MAAM,SAAS,KAAK;AAAA,MAClC,OAAO,GAAG,EAAE,SAAS,QAAQ,KAAK,kBAAkB,YAAY,cAAc,QAAQ,WAAW,gBAAgB,WAAW,SAAS,WAAW,MAAM,GAAG,GAAG,MAAM,CAAC;AAAA,MAEnK;AAAA,4BAAC,UAAK,OAAO,GAAG,EAAE,UAAU,YAAY,SAAS,eAAe,MAAM,YAAY,WAAW,SAAS,OAAO,IAAI,EAAE,CAAC,GAClH;AAAA,UAAC;AAAA;AAAA,YACC,MAAK;AAAA,YACL;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACC,GAAG;AAAA,YACJ,aAAW;AAAA,YACX,WAAU;AAAA,YACV,OAAO,GAAG;AAAA,cACR,YAAY;AAAA,cACZ,OAAO;AAAA,cACP,QAAQ;AAAA,cACR,QAAQ;AAAA,cACR,cAAc;AAAA,cACd,QAAQ,yCAAyC,SAAS,CAAC,WAAW,wBAAwB;AAAA,cAC9F,iBAAiB;AAAA,cACjB,QAAQ;AAAA,cACR,YAAY;AAAA,YACd,CAAC;AAAA;AAAA,QACH,GACF;AAAA,QACA,qBAAC,UAAK,OAAO,GAAG,EAAE,SAAS,QAAQ,eAAe,UAAU,KAAK,EAAE,CAAC,GACjE;AAAA,mBAAS,oBAAC,UAAK,OAAO,GAAG,EAAE,YAAY,oBAAoB,UAAU,oBAAoB,OAAO,uBAAuB,YAAY,KAAK,CAAC,GAAI,iBAAM;AAAA,UACnJ,eACC,oBAAC,UAAK,OAAO,GAAG,EAAE,YAAY,oBAAoB,UAAU,kBAAkB,OAAO,qBAAqB,YAAY,KAAK,CAAC,GAAI,uBAAY;AAAA,WAEhJ;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
package/dist/styles.css CHANGED
@@ -250,6 +250,18 @@
250
250
  }
251
251
  .sereno-dtp-grid button:hover { background: var(--interactive-ghost-hover); }
252
252
  .sereno-dtp-grid button:focus-visible { outline: 2px solid var(--border-focus); outline-offset: -2px; }
253
+ /* The day grid's own focus ring (SS-228) — was missing entirely: the day
254
+ button used to set outline:none *inline*, which always wins over a class
255
+ selector regardless of :focus-visible, so the roving-tabindex cursor was
256
+ keyboard-functional but completely invisible. Suppressed here instead —
257
+ same specificity as the :focus-visible rule below, so source order
258
+ decides and the override actually takes. Separate from .sereno-dtp-grid
259
+ on purpose — that class is the month/year popover's mini-grid, whose
260
+ :hover / [data-current] rules don't belong on a day cell (it already has
261
+ its own selected/today styling driven from React state, not CSS
262
+ attribute selectors). */
263
+ .sereno-dtp-days button { outline: none; }
264
+ .sereno-dtp-days button:focus-visible { outline: 2px solid var(--border-focus); outline-offset: -2px; }
253
265
  .sereno-dtp-grid button[data-current] {
254
266
  background: var(--interactive-primary);
255
267
  color: var(--interactive-primary-fg);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sereno-ds/ui",
3
- "version": "0.25.2",
3
+ "version": "0.25.4",
4
4
  "description": "Sereno Design System — React primitives (token-driven, inline styles, no UI base lib).",
5
5
  "license": "MIT",
6
6
  "author": "Sereno",