@sereno-ds/ui 0.36.2 → 0.36.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/README.md +12 -12
  2. package/dist/_internal/Field.d.ts +8 -2
  3. package/dist/_internal/Field.js +6 -5
  4. package/dist/_internal/Field.js.map +1 -1
  5. package/dist/_internal/fieldA11y.d.ts +21 -4
  6. package/dist/_internal/fieldA11y.js +7 -2
  7. package/dist/_internal/fieldA11y.js.map +1 -1
  8. package/dist/_internal/mask.d.ts +1 -1
  9. package/dist/_internal/mask.js.map +1 -1
  10. package/dist/core/Avatar.d.ts +1 -1
  11. package/dist/core/Avatar.js.map +1 -1
  12. package/dist/core/Badge.js +1 -1
  13. package/dist/core/Badge.js.map +1 -1
  14. package/dist/core/Brand.d.ts +2 -2
  15. package/dist/core/Brand.js.map +1 -1
  16. package/dist/core/Button.d.ts +1 -1
  17. package/dist/core/Button.js.map +1 -1
  18. package/dist/core/Card.js +1 -1
  19. package/dist/core/Card.js.map +1 -1
  20. package/dist/core/IconButton.d.ts +2 -2
  21. package/dist/core/IconButton.js.map +1 -1
  22. package/dist/core/Menu.d.ts +5 -5
  23. package/dist/core/Menu.js.map +1 -1
  24. package/dist/core/Table.d.ts +7 -7
  25. package/dist/core/Table.js +1 -1
  26. package/dist/core/Table.js.map +1 -1
  27. package/dist/core/Typography.d.ts +3 -3
  28. package/dist/core/Typography.js +1 -1
  29. package/dist/core/Typography.js.map +1 -1
  30. package/dist/feedback/Alert.d.ts +2 -2
  31. package/dist/feedback/Alert.js.map +1 -1
  32. package/dist/feedback/Dialog.d.ts +5 -5
  33. package/dist/feedback/Dialog.js.map +1 -1
  34. package/dist/feedback/Skeleton.d.ts +1 -1
  35. package/dist/feedback/Skeleton.js.map +1 -1
  36. package/dist/feedback/Toast.d.ts +1 -1
  37. package/dist/feedback/Toast.js.map +1 -1
  38. package/dist/feedback/ToastProvider.d.ts +3 -3
  39. package/dist/feedback/ToastProvider.js +1 -1
  40. package/dist/feedback/ToastProvider.js.map +1 -1
  41. package/dist/forms/AvatarUpload.d.ts +5 -5
  42. package/dist/forms/AvatarUpload.js +2 -2
  43. package/dist/forms/AvatarUpload.js.map +1 -1
  44. package/dist/forms/Checkbox.d.ts +3 -3
  45. package/dist/forms/Checkbox.js +1 -1
  46. package/dist/forms/Checkbox.js.map +1 -1
  47. package/dist/forms/DatePicker.d.ts +9 -9
  48. package/dist/forms/DatePicker.js +1 -1
  49. package/dist/forms/DatePicker.js.map +1 -1
  50. package/dist/forms/DateTimePicker.d.ts +14 -14
  51. package/dist/forms/DateTimePicker.js +2 -2
  52. package/dist/forms/DateTimePicker.js.map +1 -1
  53. package/dist/forms/FileUpload.d.ts +4 -4
  54. package/dist/forms/FileUpload.js +7 -3
  55. package/dist/forms/FileUpload.js.map +1 -1
  56. package/dist/forms/Input.d.ts +1 -1
  57. package/dist/forms/Input.js +4 -2
  58. package/dist/forms/Input.js.map +1 -1
  59. package/dist/forms/Radio.d.ts +5 -5
  60. package/dist/forms/Radio.js.map +1 -1
  61. package/dist/forms/SearchInput.d.ts +2 -2
  62. package/dist/forms/SearchInput.js.map +1 -1
  63. package/dist/forms/Select.d.ts +9 -9
  64. package/dist/forms/Select.js +2 -2
  65. package/dist/forms/Select.js.map +1 -1
  66. package/dist/forms/Switch.d.ts +3 -3
  67. package/dist/forms/Switch.js.map +1 -1
  68. package/dist/forms/Textarea.d.ts +1 -1
  69. package/dist/forms/Textarea.js +3 -1
  70. package/dist/forms/Textarea.js.map +1 -1
  71. package/dist/forms/_internal/CalendarGrid.d.ts +6 -6
  72. package/dist/forms/_internal/CalendarGrid.js +1 -1
  73. package/dist/forms/_internal/CalendarGrid.js.map +1 -1
  74. package/dist/forms/_internal/fieldBoxStyle.d.ts +2 -2
  75. package/dist/forms/_internal/fieldBoxStyle.js +2 -2
  76. package/dist/forms/_internal/fieldBoxStyle.js.map +1 -1
  77. package/dist/index.js.map +1 -1
  78. package/dist/navigation/BottomNav.d.ts +1 -1
  79. package/dist/navigation/BottomNav.js +1 -1
  80. package/dist/navigation/BottomNav.js.map +1 -1
  81. package/dist/navigation/SidebarNav.d.ts +9 -9
  82. package/dist/navigation/SidebarNav.js +1 -1
  83. package/dist/navigation/SidebarNav.js.map +1 -1
  84. package/dist/navigation/Stepper.d.ts +5 -5
  85. package/dist/navigation/Stepper.js.map +1 -1
  86. package/dist/navigation/Tabs.d.ts +2 -2
  87. package/dist/navigation/Tabs.js +11 -11
  88. package/dist/navigation/Tabs.js.map +1 -1
  89. package/dist/navigation/TopBar.d.ts +3 -3
  90. package/dist/navigation/TopBar.js.map +1 -1
  91. package/dist/styles.css +23 -23
  92. package/dist/theme/ThemeProvider.d.ts +1 -1
  93. package/dist/theme/ThemeProvider.js.map +1 -1
  94. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/forms/DatePicker.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Calendar as CalendarIcon, X } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { Field } from '../_internal/Field';\nimport { fieldA11y } from '../_internal/fieldA11y';\nimport { CalendarGrid } from './_internal/CalendarGrid';\nimport { fieldBoxStyle } from './_internal/fieldBoxStyle';\n\nconst TEXT = {\n 'pt-BR': { placeholder: 'Selecionar data', dialogLabel: 'Escolher data', clearLabel: 'Limpar data' },\n en: { placeholder: 'Pick a date', dialogLabel: 'Choose a date', clearLabel: 'Clear date' },\n} as const;\n\n/**\n * Imperative handle exposed via `ref` — there's no single native element\n * underneath (the trigger is a `<button>`, the value a plain ISO string in\n * React state), so `ref` can't hand back something `.value`-readable the way\n * a real `<input>` would. `focus()` is real and covers `setFocus()`-on-error;\n * reading the current value still means the `value`/`onChange` props, not the\n * ref. `onChange(value: string)` also isn't a `ChangeEvent`, so a plain\n * `{...register(name)}` spread won't work regardless — use `Controller`.\n */\nexport interface DatePickerHandle {\n focus: () => void;\n}\n\nexport interface DatePickerProps {\n label?: string;\n hint?: string;\n error?: string;\n required?: boolean;\n /** Defaults to the `locale`-appropriate text (\"Selecionar data\" / \"Pick a date\"). */\n placeholder?: string;\n size?: 'sm' | 'md' | 'lg';\n disabled?: boolean;\n /** Controlled value, ISO \"YYYY-MM-DD\". */\n value?: string;\n /** Uncontrolled initial value, ISO \"YYYY-MM-DD\". */\n defaultValue?: string;\n onChange?: (value: string) => void;\n /** Earliest selectable date, ISO \"YYYY-MM-DD\" — every day before it is unavailable. */\n min?: string;\n /** Latest selectable date, ISO \"YYYY-MM-DD\" — every day after it is unavailable. */\n max?: string;\n id?: string;\n containerStyle?: React.CSSProperties;\n /** aria-label for the clear (×) button. Defaults to the `locale`-appropriate text. */\n clearLabel?: string;\n /**\n * The real Sereno product always renders pt-BR — this only exists so the\n * docs showcase can demo an English-speaking consumer without forking the\n * component. Default stays `'pt-BR'`.\n */\n locale?: 'pt-BR' | 'en';\n /** Reserve the hint/error row's height even with neither set — stops the\n * field from growing the moment a validation message appears. */\n preserveHelperSpace?: boolean;\n}\n\ninterface YMD {\n year: number;\n month: number;\n day: number;\n}\n\nfunction parseISO(iso: string | undefined): YMD | null {\n if (!iso) return null;\n const m = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(iso);\n if (!m) return null;\n return { year: Number(m[1]), month: Number(m[2]) - 1, day: Number(m[3]) };\n}\n\nfunction toISO(year: number, month: number, day: number): string {\n return `${String(year).padStart(4, '0')}-${String(month + 1).padStart(2, '0')}-${String(day).padStart(2, '0')}`;\n}\n\nfunction formatDisplay(iso: string, locale: 'pt-BR' | 'en'): string {\n const d = parseISO(iso);\n if (!d) return iso;\n return new Intl.DateTimeFormat(locale === 'en' ? 'en-US' : 'pt-BR', { day: '2-digit', month: '2-digit', year: 'numeric' }).format(\n new Date(d.year, d.month, d.day),\n );\n}\n\nfunction daysIn(year: number, month: number): number {\n return new Date(year, month + 1, 0).getDate();\n}\n\n/** Every day of (year, month) that falls before `min` or after `max`. */\nfunction unavailableForMonth(year: number, month: number, min?: string, max?: string): number[] {\n if (!min && !max) return [];\n const minD = parseISO(min);\n const maxD = parseISO(max);\n const out: number[] = [];\n const total = daysIn(year, month);\n for (let day = 1; day <= total; day++) {\n if (minD && year * 372 + month * 31 + day < minD.year * 372 + minD.month * 31 + minD.day) {\n out.push(day);\n continue;\n }\n if (maxD && year * 372 + month * 31 + day > maxD.year * 372 + maxD.month * 31 + maxD.day) {\n out.push(day);\n }\n }\n return out;\n}\n\n/**\n * Field for picking a single date — no time, no slots (`DateTimePicker`'s\n * job). A text-field-styled trigger showing the selected date opens a\n * popover with the same calendar grid `DateTimePicker` uses (roving\n * tabindex, month/year jump — see `./_internal/CalendarGrid`), so the two\n * share every bit of calendar behavior (SS-243).\n *\n * Value contract matches the rest of the forms package: `value` /\n * `defaultValue` + `onChange(value)`, a plain ISO \"YYYY-MM-DD\" string —\n * drops in wherever `<input type=\"date\">` would go, but themed instead of\n * the browser's own, and in pt-BR by default (the real Sereno product\n * always uses it; `locale=\"en\"` exists only for docs/demo purposes). A\n * clear (×) button appears once a value is set.\n */\nexport const DatePicker = React.forwardRef<DatePickerHandle, DatePickerProps>(function DatePicker(\n {\n label,\n hint,\n error,\n required,\n placeholder,\n size = 'md',\n disabled = false,\n value,\n defaultValue,\n onChange,\n min,\n max,\n id,\n containerStyle,\n clearLabel,\n locale = 'pt-BR',\n preserveHelperSpace,\n },\n ref,\n) {\n const copy = TEXT[locale];\n const [inner, setInner] = React.useState(defaultValue ?? '');\n const iso = value !== undefined ? value : inner;\n const parsed = parseISO(iso);\n const now = React.useMemo(() => new Date(), []);\n\n const [open, setOpen] = React.useState(false);\n // The month currently shown in the popover — resets to the value's month\n // (or today's) every time the popover opens, via the conditional mount\n // below; CalendarGrid itself only takes year/month as its *initial* view.\n const [viewYear, setViewYear] = React.useState(parsed?.year ?? now.getFullYear());\n const [viewMonth, setViewMonth] = React.useState(parsed?.month ?? now.getMonth());\n\n const rootRef = React.useRef<HTMLDivElement>(null);\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const generatedId = React.useId();\n const rid = id || generatedId;\n\n React.useImperativeHandle(ref, () => ({ focus: () => triggerRef.current?.focus() }), []);\n\n // A plain `position: absolute` child of `rootRef` (itself `position:\n // relative`) — the same \"inline\" strategy Select's panel uses for its\n // common case, and the same one DateTimePicker's own month/year popover\n // already uses. The browser glues it to the trigger through *any* scroll\n // (page or a nested overflow container) for free — no JS measuring\n // position, no listening for scroll/resize, and critically, it never has\n // to close on scroll the way a `position: fixed` popover computed once\n // would (that was tried first here and didn't hold up — see PR history).\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 }\n };\n const onKey = (e: KeyboardEvent) => {\n if (e.key === 'Escape') {\n setOpen(false);\n triggerRef.current?.focus();\n }\n };\n document.addEventListener('pointerdown', onDown, true);\n document.addEventListener('keydown', onKey, true);\n return () => {\n document.removeEventListener('pointerdown', onDown, true);\n document.removeEventListener('keydown', onKey, true);\n };\n }, [open]);\n\n const openPopover = () => {\n if (disabled) return;\n setViewYear(parsed?.year ?? now.getFullYear());\n setViewMonth(parsed?.month ?? now.getMonth());\n setOpen(true);\n };\n\n const commit = (day: number) => {\n const next = toISO(viewYear, viewMonth, day);\n if (value === undefined) setInner(next);\n onChange?.(next);\n setOpen(false);\n triggerRef.current?.focus();\n };\n\n const clear = () => {\n if (value === undefined) setInner('');\n onChange?.('');\n triggerRef.current?.focus();\n };\n\n const unavailable = React.useMemo(() => unavailableForMonth(viewYear, viewMonth, min, max), [viewYear, viewMonth, min, max]);\n\n return (\n <Field label={label} hint={hint} error={error} required={required} htmlFor={rid} style={containerStyle} preserveHelperSpace={preserveHelperSpace}>\n <div ref={rootRef} style={{ position: 'relative', width: '100%' }}>\n {/* The bordered box lives on this wrapper `div`, not on a `<button>`\n — the open-trigger and the clear (×) button are real, independent\n sibling buttons inside it, since a button can't nest another. */}\n <div style={fieldBoxStyle(size, !!error, open, disabled)}>\n <button\n ref={triggerRef}\n id={rid}\n type=\"button\"\n disabled={disabled}\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n // Ties the trigger to the hint / error line below, so they are read when it takes focus.\n {...fieldA11y(rid, { hint, error })}\n onClick={() => (open ? setOpen(false) : openPopover())}\n style={sx({\n flex: 1,\n minWidth: 0,\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-2)',\n border: 'none',\n background: 'transparent',\n padding: 0,\n font: 'inherit',\n color: 'inherit',\n cursor: 'inherit',\n textAlign: 'left',\n })}\n >\n <CalendarIcon size={16} strokeWidth={1.75} style={{ flex: '0 0 auto', opacity: 0.7 }} />\n <span\n style={sx({\n flex: 1,\n textAlign: 'left',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n color: iso ? 'inherit' : 'var(--text-muted)',\n })}\n >\n {iso ? formatDisplay(iso, locale) : (placeholder ?? copy.placeholder)}\n </span>\n </button>\n {iso && !disabled && (\n <button\n type=\"button\"\n aria-label={clearLabel ?? copy.clearLabel}\n onClick={(e) => {\n e.stopPropagation();\n clear();\n }}\n style={sx({\n flex: '0 0 auto',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n marginRight: -4,\n padding: 4,\n border: 'none',\n borderRadius: 'var(--radius-sm)',\n background: 'transparent',\n color: 'var(--text-muted)',\n cursor: 'pointer',\n })}\n >\n <X size={14} strokeWidth={2} />\n </button>\n )}\n </div>\n\n {open && (\n <div\n role=\"dialog\"\n aria-label={label || copy.dialogLabel}\n tabIndex={-1}\n style={sx({\n position: 'absolute',\n top: 'calc(100% + 6px)',\n left: 0,\n right: 0,\n // The 7-column grid needs some floor width to stay readable —\n // a narrow field (e.g. a compact \"Data\" next to \"Motivo\")\n // would otherwise squeeze it. `left`/`right: 0` already\n // matches the trigger's own width for anything wider.\n minWidth: 272,\n zIndex: 20,\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 <CalendarGrid\n year={viewYear}\n month={viewMonth}\n selectedDate={parsed && parsed.year === viewYear && parsed.month === viewMonth ? parsed.day : undefined}\n unavailable={unavailable}\n onMonthChange={(y, m) => {\n setViewYear(y);\n setViewMonth(m);\n }}\n onSelectDate={commit}\n squareCells\n trimEmptyRows\n locale={locale}\n />\n </div>\n )}\n </div>\n </Field>\n );\n});\n\nDatePicker.displayName = 'DatePicker';\n"],"mappings":";AAgOU,SAyBE,KAzBF;AA9NV,YAAY,WAAW;AACvB,SAAS,YAAY,cAAc,SAAS;AAC5C,SAAS,UAAU;AACnB,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAE9B,MAAM,OAAO;AAAA,EACX,SAAS,EAAE,aAAa,mBAAmB,aAAa,iBAAiB,YAAY,cAAc;AAAA,EACnG,IAAI,EAAE,aAAa,eAAe,aAAa,iBAAiB,YAAY,aAAa;AAC3F;AAsDA,SAAS,SAAS,KAAqC;AACrD,MAAI,CAAC,IAAK,QAAO;AACjB,QAAM,IAAI,4BAA4B,KAAK,GAAG;AAC9C,MAAI,CAAC,EAAG,QAAO;AACf,SAAO,EAAE,MAAM,OAAO,EAAE,CAAC,CAAC,GAAG,OAAO,OAAO,EAAE,CAAC,CAAC,IAAI,GAAG,KAAK,OAAO,EAAE,CAAC,CAAC,EAAE;AAC1E;AAEA,SAAS,MAAM,MAAc,OAAe,KAAqB;AAC/D,SAAO,GAAG,OAAO,IAAI,EAAE,SAAS,GAAG,GAAG,CAAC,IAAI,OAAO,QAAQ,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC,IAAI,OAAO,GAAG,EAAE,SAAS,GAAG,GAAG,CAAC;AAC/G;AAEA,SAAS,cAAc,KAAa,QAAgC;AAClE,QAAM,IAAI,SAAS,GAAG;AACtB,MAAI,CAAC,EAAG,Q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,UAAU,OAAO,SAAS,YAAY,OAAO,UAAU,YAAY,OAAO,MAAM;AAAA,YAC9F;AAAA,YACA,eAAe,CAAC,GAAG,MAAM;AACvB,0BAAY,CAAC;AACb,2BAAa,CAAC;AAAA,YAChB;AAAA,YACA,cAAc;AAAA,YACd,aAAW;AAAA,YACX,eAAa;AAAA,YACb;AAAA;AAAA,QACF;AAAA;AAAA,IACF;AAAA,KAEJ,GACF;AAEJ,CAAC;AAED,WAAW,cAAc;","names":["DatePicker"]}
1
+ {"version":3,"sources":["../../src/forms/DatePicker.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Calendar as CalendarIcon, X } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { Field } from '../_internal/Field';\nimport { fieldA11y } from '../_internal/fieldA11y';\nimport { CalendarGrid } from './_internal/CalendarGrid';\nimport { fieldBoxStyle } from './_internal/fieldBoxStyle';\n\nconst TEXT = {\n 'pt-BR': { placeholder: 'Selecionar data', dialogLabel: 'Escolher data', clearLabel: 'Limpar data' },\n en: { placeholder: 'Pick a date', dialogLabel: 'Choose a date', clearLabel: 'Clear date' },\n} as const;\n\n/**\n * Imperative handle exposed via `ref` - there's no single native element\n * underneath (the trigger is a `<button>`, the value a plain ISO string in\n * React state), so `ref` can't hand back something `.value`-readable the way\n * a real `<input>` would. `focus()` is real and covers `setFocus()`-on-error;\n * reading the current value still means the `value`/`onChange` props, not the\n * ref. `onChange(value: string)` also isn't a `ChangeEvent`, so a plain\n * `{...register(name)}` spread won't work regardless - use `Controller`.\n */\nexport interface DatePickerHandle {\n focus: () => void;\n}\n\nexport interface DatePickerProps {\n label?: string;\n hint?: string;\n error?: string;\n required?: boolean;\n /** Defaults to the `locale`-appropriate text (\"Selecionar data\" / \"Pick a date\"). */\n placeholder?: string;\n size?: 'sm' | 'md' | 'lg';\n disabled?: boolean;\n /** Controlled value, ISO \"YYYY-MM-DD\". */\n value?: string;\n /** Uncontrolled initial value, ISO \"YYYY-MM-DD\". */\n defaultValue?: string;\n onChange?: (value: string) => void;\n /** Earliest selectable date, ISO \"YYYY-MM-DD\" - every day before it is unavailable. */\n min?: string;\n /** Latest selectable date, ISO \"YYYY-MM-DD\" - every day after it is unavailable. */\n max?: string;\n id?: string;\n containerStyle?: React.CSSProperties;\n /** aria-label for the clear (×) button. Defaults to the `locale`-appropriate text. */\n clearLabel?: string;\n /**\n * The real Sereno product always renders pt-BR - this only exists so the\n * docs showcase can demo an English-speaking consumer without forking the\n * component. Default stays `'pt-BR'`.\n */\n locale?: 'pt-BR' | 'en';\n /** Reserve the hint/error row's height even with neither set - stops the\n * field from growing the moment a validation message appears. */\n preserveHelperSpace?: boolean;\n}\n\ninterface YMD {\n year: number;\n month: number;\n day: number;\n}\n\nfunction parseISO(iso: string | undefined): YMD | null {\n if (!iso) return null;\n const m = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(iso);\n if (!m) return null;\n return { year: Number(m[1]), month: Number(m[2]) - 1, day: Number(m[3]) };\n}\n\nfunction toISO(year: number, month: number, day: number): string {\n return `${String(year).padStart(4, '0')}-${String(month + 1).padStart(2, '0')}-${String(day).padStart(2, '0')}`;\n}\n\nfunction formatDisplay(iso: string, locale: 'pt-BR' | 'en'): string {\n const d = parseISO(iso);\n if (!d) return iso;\n return new Intl.DateTimeFormat(locale === 'en' ? 'en-US' : 'pt-BR', { day: '2-digit', month: '2-digit', year: 'numeric' }).format(\n new Date(d.year, d.month, d.day),\n );\n}\n\nfunction daysIn(year: number, month: number): number {\n return new Date(year, month + 1, 0).getDate();\n}\n\n/** Every day of (year, month) that falls before `min` or after `max`. */\nfunction unavailableForMonth(year: number, month: number, min?: string, max?: string): number[] {\n if (!min && !max) return [];\n const minD = parseISO(min);\n const maxD = parseISO(max);\n const out: number[] = [];\n const total = daysIn(year, month);\n for (let day = 1; day <= total; day++) {\n if (minD && year * 372 + month * 31 + day < minD.year * 372 + minD.month * 31 + minD.day) {\n out.push(day);\n continue;\n }\n if (maxD && year * 372 + month * 31 + day > maxD.year * 372 + maxD.month * 31 + maxD.day) {\n out.push(day);\n }\n }\n return out;\n}\n\n/**\n * Field for picking a single date - no time, no slots (`DateTimePicker`'s\n * job). A text-field-styled trigger showing the selected date opens a\n * popover with the same calendar grid `DateTimePicker` uses (roving\n * tabindex, month/year jump - see `./_internal/CalendarGrid`), so the two\n * share every bit of calendar behavior (SS-243).\n *\n * Value contract matches the rest of the forms package: `value` /\n * `defaultValue` + `onChange(value)`, a plain ISO \"YYYY-MM-DD\" string -\n * drops in wherever `<input type=\"date\">` would go, but themed instead of\n * the browser's own, and in pt-BR by default (the real Sereno product\n * always uses it; `locale=\"en\"` exists only for docs/demo purposes). A\n * clear (×) button appears once a value is set.\n */\nexport const DatePicker = React.forwardRef<DatePickerHandle, DatePickerProps>(function DatePicker(\n {\n label,\n hint,\n error,\n required,\n placeholder,\n size = 'md',\n disabled = false,\n value,\n defaultValue,\n onChange,\n min,\n max,\n id,\n containerStyle,\n clearLabel,\n locale = 'pt-BR',\n preserveHelperSpace,\n },\n ref,\n) {\n const copy = TEXT[locale];\n const [inner, setInner] = React.useState(defaultValue ?? '');\n const iso = value !== undefined ? value : inner;\n const parsed = parseISO(iso);\n const now = React.useMemo(() => new Date(), []);\n\n const [open, setOpen] = React.useState(false);\n // The month currently shown in the popover - resets to the value's month\n // (or today's) every time the popover opens, via the conditional mount\n // below; CalendarGrid itself only takes year/month as its *initial* view.\n const [viewYear, setViewYear] = React.useState(parsed?.year ?? now.getFullYear());\n const [viewMonth, setViewMonth] = React.useState(parsed?.month ?? now.getMonth());\n\n const rootRef = React.useRef<HTMLDivElement>(null);\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const generatedId = React.useId();\n const rid = id || generatedId;\n\n React.useImperativeHandle(ref, () => ({ focus: () => triggerRef.current?.focus() }), []);\n\n // A plain `position: absolute` child of `rootRef` (itself `position:\n // relative`) - the same \"inline\" strategy Select's panel uses for its\n // common case, and the same one DateTimePicker's own month/year popover\n // already uses. The browser glues it to the trigger through *any* scroll\n // (page or a nested overflow container) for free - no JS measuring\n // position, no listening for scroll/resize, and critically, it never has\n // to close on scroll the way a `position: fixed` popover computed once\n // would (that was tried first here and didn't hold up - see PR history).\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 }\n };\n const onKey = (e: KeyboardEvent) => {\n if (e.key === 'Escape') {\n setOpen(false);\n triggerRef.current?.focus();\n }\n };\n document.addEventListener('pointerdown', onDown, true);\n document.addEventListener('keydown', onKey, true);\n return () => {\n document.removeEventListener('pointerdown', onDown, true);\n document.removeEventListener('keydown', onKey, true);\n };\n }, [open]);\n\n const openPopover = () => {\n if (disabled) return;\n setViewYear(parsed?.year ?? now.getFullYear());\n setViewMonth(parsed?.month ?? now.getMonth());\n setOpen(true);\n };\n\n const commit = (day: number) => {\n const next = toISO(viewYear, viewMonth, day);\n if (value === undefined) setInner(next);\n onChange?.(next);\n setOpen(false);\n triggerRef.current?.focus();\n };\n\n const clear = () => {\n if (value === undefined) setInner('');\n onChange?.('');\n triggerRef.current?.focus();\n };\n\n const unavailable = React.useMemo(() => unavailableForMonth(viewYear, viewMonth, min, max), [viewYear, viewMonth, min, max]);\n\n return (\n <Field label={label} hint={hint} error={error} required={required} htmlFor={rid} style={containerStyle} preserveHelperSpace={preserveHelperSpace}>\n <div ref={rootRef} style={{ position: 'relative', width: '100%' }}>\n {/* The bordered box lives on this wrapper `div`, not on a `<button>`\n - the open-trigger and the clear (×) button are real, independent\n sibling buttons inside it, since a button can't nest another. */}\n <div style={fieldBoxStyle(size, !!error, open, disabled)}>\n <button\n ref={triggerRef}\n id={rid}\n type=\"button\"\n disabled={disabled}\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n // Ties the trigger to the hint / error line below, so they are read when it takes focus.\n {...fieldA11y(rid, { hint, error })}\n onClick={() => (open ? setOpen(false) : openPopover())}\n style={sx({\n flex: 1,\n minWidth: 0,\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-2)',\n border: 'none',\n background: 'transparent',\n padding: 0,\n font: 'inherit',\n color: 'inherit',\n cursor: 'inherit',\n textAlign: 'left',\n })}\n >\n <CalendarIcon size={16} strokeWidth={1.75} style={{ flex: '0 0 auto', opacity: 0.7 }} />\n <span\n style={sx({\n flex: 1,\n textAlign: 'left',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n color: iso ? 'inherit' : 'var(--text-muted)',\n })}\n >\n {iso ? formatDisplay(iso, locale) : (placeholder ?? copy.placeholder)}\n </span>\n </button>\n {iso && !disabled && (\n <button\n type=\"button\"\n aria-label={clearLabel ?? copy.clearLabel}\n onClick={(e) => {\n e.stopPropagation();\n clear();\n }}\n style={sx({\n flex: '0 0 auto',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n marginRight: -4,\n padding: 4,\n border: 'none',\n borderRadius: 'var(--radius-sm)',\n background: 'transparent',\n color: 'var(--text-muted)',\n cursor: 'pointer',\n })}\n >\n <X size={14} strokeWidth={2} />\n </button>\n )}\n </div>\n\n {open && (\n <div\n role=\"dialog\"\n aria-label={label || copy.dialogLabel}\n tabIndex={-1}\n style={sx({\n position: 'absolute',\n top: 'calc(100% + 6px)',\n left: 0,\n right: 0,\n // The 7-column grid needs some floor width to stay readable -\n // a narrow field (e.g. a compact \"Data\" next to \"Motivo\")\n // would otherwise squeeze it. `left`/`right: 0` already\n // matches the trigger's own width for anything wider.\n minWidth: 272,\n zIndex: 20,\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 <CalendarGrid\n year={viewYear}\n month={viewMonth}\n selectedDate={parsed && parsed.year === viewYear && parsed.month === viewMonth ? parsed.day : undefined}\n unavailable={unavailable}\n onMonthChange={(y, m) => {\n setViewYear(y);\n setViewMon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AAAA,QACF;AAAA;AAAA,IACF;AAAA,KAEJ,GACF;AAEJ,CAAC;AAED,WAAW,cAAc;","names":["DatePicker"]}
@@ -2,17 +2,17 @@ import * as React from 'react';
2
2
 
3
3
  interface TimeSlot {
4
4
  value: string;
5
- /** Hard-blocked — unclickable regardless of `capacity`/`booked`. */
5
+ /** Hard-blocked - unclickable regardless of `capacity`/`booked`. */
6
6
  disabled?: boolean;
7
- /** Total spots this slot holds — a group session, a class. Omit for a
7
+ /** Total spots this slot holds - a group session, a class. Omit for a
8
8
  * plain 1:1 slot with no capacity tracking (the original contract). */
9
9
  capacity?: number;
10
10
  /** How many are already booked into it. */
11
11
  booked?: number;
12
12
  }
13
13
  /**
14
- * Month calendar plus available time slots — the heart of the public booking flow.
15
- * Day names and month names render in pt-BR by default — the real Sereno
14
+ * Month calendar plus available time slots - the heart of the public booking flow.
15
+ * Day names and month names render in pt-BR by default - the real Sereno
16
16
  * product always uses it; `locale="en"` exists only for docs/demo purposes.
17
17
  *
18
18
  * The header navigates: ‹ / › step the month, and the centred title opens a
@@ -20,16 +20,16 @@ interface TimeSlot {
20
20
  * view; the component then owns it. Pass `onMonthChange` to react to navigation
21
21
  * (e.g. fetch the new month's availability).
22
22
  *
23
- * The day grid uses roving tabindex (SS-228) — only one cell is ever in the
23
+ * The day grid uses roving tabindex (SS-228) - only one cell is ever in the
24
24
  * Tab order, so Tab enters/leaves it in one stop instead of one per day.
25
25
  * Arrow keys move by day/week and cross month boundaries on overflow;
26
26
  * Home/End move within the current week row; PageUp/PageDown step the
27
27
  * month. An `unavailable` day stays focusable (`aria-disabled`, not the
28
- * native `disabled` — a disabled button can't receive focus at all) so the
28
+ * native `disabled` - a disabled button can't receive focus at all) so the
29
29
  * cursor can still land on it, just not select it.
30
30
  *
31
- * The calendar body itself (header + day grid) is `./_internal/CalendarGrid`
32
- * — shared with `DatePicker` (SS-243), which wraps the same grid in a
31
+ * The calendar body itself (header + day grid) is `./_internal/CalendarGrid`,
32
+ * shared with `DatePicker` (SS-243), which wraps the same grid in a
33
33
  * trigger+popover shell instead of this component's always-visible card.
34
34
  */
35
35
  interface DateTimePickerProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {
@@ -38,25 +38,25 @@ interface DateTimePickerProps extends Omit<React.HTMLAttributes<HTMLDivElement>,
38
38
  /** Initial month, 0-indexed. Defaults to the current month. */
39
39
  month?: number;
40
40
  /** Selected day-of-month. The highlight only shows in the month it was picked
41
- * in — navigating away and back to a *different* month never re-highlights it. */
41
+ * in - navigating away and back to a *different* month never re-highlights it. */
42
42
  selectedDate?: number;
43
43
  /**
44
44
  * Slot labels ("09:00") or `TimeSlot` objects. A slot with `capacity` set
45
45
  * shows "booked/capacity" and switches to a full/overbook-warning look
46
- * once reached (SS-64) — still pickable unless also `disabled`, since a
46
+ * once reached (SS-64) - still pickable unless also `disabled`, since a
47
47
  * full slot and a *blocked* one are different things: the first is a
48
48
  * deliberate "yes, overbook it" the caller can still choose to allow.
49
49
  */
50
50
  times?: (string | TimeSlot)[];
51
51
  selectedTime?: string;
52
- /** Day numbers with no availability — struck through and unclickable. */
52
+ /** Day numbers with no availability - struck through and unclickable. */
53
53
  unavailable?: number[];
54
54
  onSelectDate?: (day: number) => void;
55
55
  onSelectTime?: (time: string) => void;
56
56
  /** Fires whenever the visible month changes (arrows or the month/year popover). */
57
57
  onMonthChange?: (year: number, month: number) => void;
58
58
  /**
59
- * Extra content under each day number — a count badge, a dot, etc. Return
59
+ * Extra content under each day number - a count badge, a dot, etc. Return
60
60
  * `null` for days with nothing to show. When set, every cell grows to keep the
61
61
  * grid even. It's the caller's job to scope this (e.g. future days only).
62
62
  */
@@ -64,14 +64,14 @@ interface DateTimePickerProps extends Omit<React.HTMLAttributes<HTMLDivElement>,
64
64
  /** Defaults to the `locale`-appropriate label ("Horários disponíveis" / "Available times"). */
65
65
  timeLabel?: string;
66
66
  /**
67
- * The real Sereno product always renders pt-BR — this only exists so the
67
+ * The real Sereno product always renders pt-BR - this only exists so the
68
68
  * docs showcase can demo an English-speaking consumer without forking the
69
69
  * component. Default stays `'pt-BR'`.
70
70
  */
71
71
  locale?: 'pt-BR' | 'en';
72
72
  }
73
73
  /**
74
- * `ref` reaches the root `<div>` — plain DOM access (measuring, scrolling
74
+ * `ref` reaches the root `<div>` - plain DOM access (measuring, scrolling
75
75
  * into view), not a form value. This isn't a single-value field: the day and
76
76
  * the time are two separate, parent-owned selections (`selectedDate` /
77
77
  * `selectedTime` + their own `onSelectDate` / `onSelectTime` callbacks), so
@@ -97,7 +97,7 @@ const DateTimePicker = React.forwardRef(function DateTimePicker2({
97
97
  {
98
98
  type: "button",
99
99
  disabled: dis,
100
- "aria-label": hasOwnCapacity ? `${val} \u2014 ${full ? copy.fullInline + ", " : ""}${copy.vagas(booked, capacity)}` : void 0,
100
+ "aria-label": hasOwnCapacity ? `${val}, ${full ? copy.fullInline + ", " : ""}${copy.vagas(booked, capacity)}` : void 0,
101
101
  onClick: () => onSelectTime && onSelectTime(val),
102
102
  className: "sereno-dtp-time",
103
103
  style: sx({
@@ -117,7 +117,7 @@ const DateTimePicker = React.forwardRef(function DateTimePicker2({
117
117
  fontSize: "var(--text-sm)",
118
118
  fontWeight: "var(--weight-semibold)",
119
119
  transition: "var(--transition-control)"
120
- // Not inline outline:none — see .sereno-dtp-time in styles.css.
120
+ // Not inline outline:none - see .sereno-dtp-time in styles.css.
121
121
  }),
122
122
  children: [
123
123
  /* @__PURE__ */ jsx("span", { "aria-hidden": hasOwnCapacity, children: val }),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/forms/DateTimePicker.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\nimport { CalendarGrid } from './_internal/CalendarGrid';\n\nconst TEXT = {\n 'pt-BR': {\n timeLabel: 'Horários disponíveis',\n full: 'Lotado',\n fullInline: 'lotado',\n available: 'Disponível',\n vagas: (booked: number, capacity: number) => `${booked} de ${capacity} vagas`,\n },\n en: {\n timeLabel: 'Available times',\n full: 'Full',\n fullInline: 'full',\n available: 'Available',\n vagas: (booked: number, capacity: number) => `${booked} of ${capacity} spots`,\n },\n} as const;\n\nexport interface TimeSlot {\n value: string;\n /** Hard-blocked — unclickable regardless of `capacity`/`booked`. */\n disabled?: boolean;\n /** Total spots this slot holds — a group session, a class. Omit for a\n * plain 1:1 slot with no capacity tracking (the original contract). */\n capacity?: number;\n /** How many are already booked into it. */\n booked?: number;\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 by default — the real Sereno\n * product always uses it; `locale=\"en\"` exists only for docs/demo purposes.\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 *\n * The calendar body itself (header + day grid) is `./_internal/CalendarGrid`\n * — shared with `DatePicker` (SS-243), which wraps the same grid in a\n * trigger+popover shell instead of this component's always-visible card.\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 /**\n * Slot labels (\"09:00\") or `TimeSlot` objects. A slot with `capacity` set\n * shows \"booked/capacity\" and switches to a full/overbook-warning look\n * once reached (SS-64) — still pickable unless also `disabled`, since a\n * full slot and a *blocked* one are different things: the first is a\n * deliberate \"yes, overbook it\" the caller can still choose to allow.\n */\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 /** Defaults to the `locale`-appropriate label (\"Horários disponíveis\" / \"Available times\"). */\n timeLabel?: string;\n /**\n * The real Sereno product always renders pt-BR — this only exists so the\n * docs showcase can demo an English-speaking consumer without forking the\n * component. Default stays `'pt-BR'`.\n */\n locale?: 'pt-BR' | 'en';\n}\n\n/**\n * `ref` reaches the root `<div>` — plain DOM access (measuring, scrolling\n * into view), not a form value. This isn't a single-value field: the day and\n * the time are two separate, parent-owned selections (`selectedDate` /\n * `selectedTime` + their own `onSelectDate` / `onSelectTime` callbacks), so\n * there's no one \"value\" for `react-hook-form` to register. Register the\n * date and the time as two separate fields at the call site instead (see\n * `DatePicker` for a single-value date field with the same calendar).\n */\nexport const DateTimePicker = React.forwardRef<HTMLDivElement, DateTimePickerProps>(function DateTimePicker(\n {\n year,\n month,\n selectedDate,\n times = [],\n selectedTime,\n unavailable = [],\n onSelectDate,\n onSelectTime,\n onMonthChange,\n renderDay,\n timeLabel,\n locale = 'pt-BR',\n style,\n ...rest\n },\n ref,\n) {\n const copy = TEXT[locale];\n const label = timeLabel ?? copy.timeLabel;\n // If any slot in the list tracks capacity, plain slots grow the same\n // two-line layout with a generic \"available\" filler instead of leaving a\n // shorter, blank-looking card next to its neighbors (SS-64 follow-up).\n const anyCapacity = times.some((s) => typeof s === 'object' && s.capacity !== undefined);\n return (\n <div\n ref={ref}\n {...rest}\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 <CalendarGrid\n year={year}\n month={month}\n selectedDate={selectedDate}\n unavailable={unavailable}\n onSelectDate={onSelectDate}\n onMonthChange={onMonthChange}\n renderDay={renderDay}\n locale={locale}\n />\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 {label}\n </div>\n <div style={sx({ display: 'grid', gridTemplateColumns: 'repeat(auto-fill,minmax(76px,1fr))', gap: 'var(--space-2)' })}>\n {times.map((slot) => {\n const val = typeof slot === 'string' ? slot : slot.value;\n const dis = typeof slot === 'object' && slot.disabled;\n const capacity = typeof slot === 'object' ? slot.capacity : undefined;\n const booked = typeof slot === 'object' ? (slot.booked ?? 0) : 0;\n const hasOwnCapacity = capacity !== undefined;\n // Full ≠ blocked: a full slot is still pickable (a deliberate\n // overbook) unless the caller *also* set `disabled` — that's\n // the actual hard \"no\" (SS-64).\n const full = hasOwnCapacity && booked >= capacity;\n const sel = selectedTime === val;\n // A slot with no capacity of its own still grows the two-line\n // layout when a *sibling* slot tracks capacity, so the row\n // reads consistently instead of one short card among tall ones.\n const showSecondLine = hasOwnCapacity || anyCapacity;\n const secondLine = hasOwnCapacity ? (full ? copy.full : copy.vagas(booked, capacity)) : copy.available;\n return (\n <button\n key={val}\n type=\"button\"\n disabled={dis}\n aria-label={hasOwnCapacity ? `${val} — ${full ? copy.fullInline + ', ' : ''}${copy.vagas(booked, capacity)}` : undefined}\n onClick={() => onSelectTime && onSelectTime(val)}\n className=\"sereno-dtp-time\"\n style={sx({\n height: showSecondLine ? 'auto' : 'var(--control-height-md)',\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 2,\n padding: showSecondLine ? 'var(--space-2) 0' : 0,\n borderRadius: 'var(--radius-control)',\n cursor: dis ? 'not-allowed' : 'pointer',\n border:\n 'var(--border-width-hairline) solid ' +\n (sel ? 'transparent' : full && !dis ? 'var(--interactive-warning)' : 'var(--border-default)'),\n background: sel\n ? 'var(--interactive-accent)'\n : dis\n ? 'var(--interactive-disabled-bg)'\n : full\n ? 'var(--status-warning-bg)'\n : 'var(--bg-surface)',\n color: sel\n ? 'var(--interactive-accent-fg)'\n : dis\n ? 'var(--interactive-disabled-fg)'\n : full\n ? 'var(--status-warning-fg)'\n : 'var(--text-primary)',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n fontWeight: 'var(--weight-semibold)',\n transition: 'var(--transition-control)',\n // Not inline outline:none — see .sereno-dtp-time in styles.css.\n })}\n >\n <span aria-hidden={hasOwnCapacity}>{val}</span>\n {showSecondLine && (\n <span\n aria-hidden={hasOwnCapacity}\n style={sx({\n fontSize: 'var(--text-2xs)',\n fontWeight: 'var(--weight-medium)',\n color: sel ? 'inherit' : full ? 'var(--status-warning-fg)' : 'var(--text-muted)',\n opacity: sel ? 0.85 : 1,\n })}\n >\n {secondLine}\n </span>\n )}\n </button>\n );\n })}\n </div>\n </div>\n )}\n </div>\n );\n});\n\nDateTimePicker.displayName = 'DateTimePicker';\n"],"mappings":";AA+IM,cA2CU,YA3CV;AA7IN,YAAY,WAAW;AACvB,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAE7B,MAAM,OAAO;AAAA,EACX,SAAS;AAAA,IACP,WAAW;AAAA,IACX,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,OAAO,CAAC,QAAgB,aAAqB,GAAG,MAAM,OAAO,QAAQ;AAAA,EACvE;AAAA,EACA,IAAI;AAAA,IACF,WAAW;AAAA,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;AAAA,kBACZ,YAAY;AAAA;AAAA,gBAEd,CAAC;AAAA,gBAED;AAAA,sCAAC,UAAK,eAAa,gBAAiB,eAAI;AAAA,kBACvC,kBACC;AAAA,oBAAC;AAAA;AAAA,sBACC,eAAa;AAAA,sBACb,OAAO,GAAG;AAAA,wBACR,UAAU;AAAA,wBACV,YAAY;AAAA,wBACZ,OAAO,MAAM,YAAY,OAAO,6BAA6B;AAAA,wBAC7D,SAAS,MAAM,OAAO;AAAA,sBACxB,CAAC;AAAA,sBAEA;AAAA;AAAA,kBACH;AAAA;AAAA;AAAA,cApDG;AAAA,YAsDP;AAAA,UAEJ,CAAC,GACH;AAAA,WACF;AAAA;AAAA;AAAA,EAEJ;AAEJ,CAAC;AAED,eAAe,cAAc;","names":["DateTimePicker"]}
1
+ {"version":3,"sources":["../../src/forms/DateTimePicker.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\nimport { CalendarGrid } from './_internal/CalendarGrid';\n\nconst TEXT = {\n 'pt-BR': {\n timeLabel: 'Horários disponíveis',\n full: 'Lotado',\n fullInline: 'lotado',\n available: 'Disponível',\n vagas: (booked: number, capacity: number) => `${booked} de ${capacity} vagas`,\n },\n en: {\n timeLabel: 'Available times',\n full: 'Full',\n fullInline: 'full',\n available: 'Available',\n vagas: (booked: number, capacity: number) => `${booked} of ${capacity} spots`,\n },\n} as const;\n\nexport interface TimeSlot {\n value: string;\n /** Hard-blocked - unclickable regardless of `capacity`/`booked`. */\n disabled?: boolean;\n /** Total spots this slot holds - a group session, a class. Omit for a\n * plain 1:1 slot with no capacity tracking (the original contract). */\n capacity?: number;\n /** How many are already booked into it. */\n booked?: number;\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 by default - the real Sereno\n * product always uses it; `locale=\"en\"` exists only for docs/demo purposes.\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 *\n * The calendar body itself (header + day grid) is `./_internal/CalendarGrid`,\n * shared with `DatePicker` (SS-243), which wraps the same grid in a\n * trigger+popover shell instead of this component's always-visible card.\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 /**\n * Slot labels (\"09:00\") or `TimeSlot` objects. A slot with `capacity` set\n * shows \"booked/capacity\" and switches to a full/overbook-warning look\n * once reached (SS-64) - still pickable unless also `disabled`, since a\n * full slot and a *blocked* one are different things: the first is a\n * deliberate \"yes, overbook it\" the caller can still choose to allow.\n */\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 /** Defaults to the `locale`-appropriate label (\"Horários disponíveis\" / \"Available times\"). */\n timeLabel?: string;\n /**\n * The real Sereno product always renders pt-BR - this only exists so the\n * docs showcase can demo an English-speaking consumer without forking the\n * component. Default stays `'pt-BR'`.\n */\n locale?: 'pt-BR' | 'en';\n}\n\n/**\n * `ref` reaches the root `<div>` - plain DOM access (measuring, scrolling\n * into view), not a form value. This isn't a single-value field: the day and\n * the time are two separate, parent-owned selections (`selectedDate` /\n * `selectedTime` + their own `onSelectDate` / `onSelectTime` callbacks), so\n * there's no one \"value\" for `react-hook-form` to register. Register the\n * date and the time as two separate fields at the call site instead (see\n * `DatePicker` for a single-value date field with the same calendar).\n */\nexport const DateTimePicker = React.forwardRef<HTMLDivElement, DateTimePickerProps>(function DateTimePicker(\n {\n year,\n month,\n selectedDate,\n times = [],\n selectedTime,\n unavailable = [],\n onSelectDate,\n onSelectTime,\n onMonthChange,\n renderDay,\n timeLabel,\n locale = 'pt-BR',\n style,\n ...rest\n },\n ref,\n) {\n const copy = TEXT[locale];\n const label = timeLabel ?? copy.timeLabel;\n // If any slot in the list tracks capacity, plain slots grow the same\n // two-line layout with a generic \"available\" filler instead of leaving a\n // shorter, blank-looking card next to its neighbors (SS-64 follow-up).\n const anyCapacity = times.some((s) => typeof s === 'object' && s.capacity !== undefined);\n return (\n <div\n ref={ref}\n {...rest}\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 <CalendarGrid\n year={year}\n month={month}\n selectedDate={selectedDate}\n unavailable={unavailable}\n onSelectDate={onSelectDate}\n onMonthChange={onMonthChange}\n renderDay={renderDay}\n locale={locale}\n />\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 {label}\n </div>\n <div style={sx({ display: 'grid', gridTemplateColumns: 'repeat(auto-fill,minmax(76px,1fr))', gap: 'var(--space-2)' })}>\n {times.map((slot) => {\n const val = typeof slot === 'string' ? slot : slot.value;\n const dis = typeof slot === 'object' && slot.disabled;\n const capacity = typeof slot === 'object' ? slot.capacity : undefined;\n const booked = typeof slot === 'object' ? (slot.booked ?? 0) : 0;\n const hasOwnCapacity = capacity !== undefined;\n // Full ≠ blocked: a full slot is still pickable (a deliberate\n // overbook) unless the caller *also* set `disabled` - that's\n // the actual hard \"no\" (SS-64).\n const full = hasOwnCapacity && booked >= capacity;\n const sel = selectedTime === val;\n // A slot with no capacity of its own still grows the two-line\n // layout when a *sibling* slot tracks capacity, so the row\n // reads consistently instead of one short card among tall ones.\n const showSecondLine = hasOwnCapacity || anyCapacity;\n const secondLine = hasOwnCapacity ? (full ? copy.full : copy.vagas(booked, capacity)) : copy.available;\n return (\n <button\n key={val}\n type=\"button\"\n disabled={dis}\n aria-label={hasOwnCapacity ? `${val}, ${full ? copy.fullInline + ', ' : ''}${copy.vagas(booked, capacity)}` : undefined}\n onClick={() => onSelectTime && onSelectTime(val)}\n className=\"sereno-dtp-time\"\n style={sx({\n height: showSecondLine ? 'auto' : 'var(--control-height-md)',\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 2,\n padding: showSecondLine ? 'var(--space-2) 0' : 0,\n borderRadius: 'var(--radius-control)',\n cursor: dis ? 'not-allowed' : 'pointer',\n border:\n 'var(--border-width-hairline) solid ' +\n (sel ? 'transparent' : full && !dis ? 'var(--interactive-warning)' : 'var(--border-default)'),\n background: sel\n ? 'var(--interactive-accent)'\n : dis\n ? 'var(--interactive-disabled-bg)'\n : full\n ? 'var(--status-warning-bg)'\n : 'var(--bg-surface)',\n color: sel\n ? 'var(--interactive-accent-fg)'\n : dis\n ? 'var(--interactive-disabled-fg)'\n : full\n ? 'var(--status-warning-fg)'\n : 'var(--text-primary)',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n fontWeight: 'var(--weight-semibold)',\n transition: 'var(--transition-control)',\n // Not inline outline:none - see .sereno-dtp-time in styles.css.\n })}\n >\n <span aria-hidden={hasOwnCapacity}>{val}</span>\n {showSecondLine && (\n <span\n aria-hidden={hasOwnCapacity}\n style={sx({\n fontSize: 'var(--text-2xs)',\n fontWeight: 'var(--weight-medium)',\n color: sel ? 'inherit' : full ? 'var(--status-warning-fg)' : 'var(--text-muted)',\n opacity: sel ? 0.85 : 1,\n })}\n >\n {secondLine}\n </span>\n )}\n </button>\n );\n })}\n </div>\n </div>\n )}\n </div>\n );\n});\n\nDateTimePicker.displayName = 'DateTimePicker';\n"],"mappings":";AA+IM,cA2CU,YA3CV;AA7IN,YAAY,WAAW;AACvB,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAE7B,MAAM,OAAO;AAAA,EACX,SAAS;AAAA,IACP,WAAW;AAAA,IACX,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,OAAO,CAAC,QAAgB,aAAqB,GAAG,MAAM,OAAO,QAAQ;AAAA,EACvE;AAAA,EACA,IAAI;AAAA,IACF,WAAW;AAAA,IACX,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,OAAO,CAAC,QAAgB,aAAqB,GAAG,MAAM,OAAO,QAAQ;AAAA,EACvE;AACF;AAmFO,MAAM,iBAAiB,MAAM,WAAgD,SAASA,gBAC3F;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ,CAAC;AAAA,EACT;AAAA,EACA,cAAc,CAAC;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT;AAAA,EACA,GAAG;AACL,GACA,KACA;AACA,QAAM,OAAO,KAAK,MAAM;AACxB,QAAM,QAAQ,aAAa,KAAK;AAIhC,QAAM,cAAc,MAAM,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,cAAc;","names":["DateTimePicker"]}
@@ -1,21 +1,21 @@
1
1
  import * as React from 'react';
2
2
 
3
3
  /**
4
- * Pick files — click, keyboard, or drag-and-drop — with a local preview.
4
+ * Pick files - click, keyboard, or drag-and-drop - with a local preview.
5
5
  * Image-first (`shape` circle/square thumbnail); other types show an extension
6
6
  * chip. No upload happens here: `onChange` hands you the `File`(s); the preview
7
7
  * is local. Set `multiple` for a list; `value` then is `File[]`.
8
8
  */
9
9
  interface BaseProps {
10
10
  label?: string;
11
- /** Helper text under the field — a good place for the accepted types / size. */
11
+ /** Helper text under the field - a good place for the accepted types / size. */
12
12
  hint?: string;
13
13
  /** Error message; also shown instead of a rejected-file message. */
14
14
  error?: string;
15
15
  required?: boolean;
16
16
  /** `accept` attribute, also enforced on drop. */
17
17
  accept?: string;
18
- /** Max size in MB — files above this are rejected with a message. */
18
+ /** Max size in MB - files above this are rejected with a message. */
19
19
  maxSizeMB?: number;
20
20
  /** Thumbnail shape for image previews. `circle` for avatars (single only). */
21
21
  shape?: 'circle' | 'square';
@@ -24,7 +24,7 @@ interface BaseProps {
24
24
  disabled?: boolean;
25
25
  id?: string;
26
26
  containerStyle?: React.CSSProperties;
27
- /** Reserve the hint/error row's height even with neither set — stops the
27
+ /** Reserve the hint/error row's height even with neither set - stops the
28
28
  * field from growing the moment a validation message appears. */
29
29
  preserveHelperSpace?: boolean;
30
30
  }
@@ -4,7 +4,7 @@ import * as React from "react";
4
4
  import { File as FileIcon, FileArchive, FileSpreadsheet, FileText, RefreshCw, Trash2, UploadCloud } from "lucide-react";
5
5
  import { sx } from "../_internal/style.js";
6
6
  import { Field } from "../_internal/Field.js";
7
- import { fieldA11y } from "../_internal/fieldA11y.js";
7
+ import { fieldA11y, fieldLabelId } from "../_internal/fieldA11y.js";
8
8
  import { mergeRefs } from "../_internal/mergeRefs.js";
9
9
  function matchesAccept(file, accept) {
10
10
  if (!accept || accept === "*" || accept === "*/*") return true;
@@ -169,6 +169,8 @@ const FileUpload = React.forwardRef(function FileUpload2(props, forwardedRef) {
169
169
  const invalid = Boolean(error || rejected && !multiple);
170
170
  const shownError = error || (multiple ? void 0 : rejected) || void 0;
171
171
  const a11y = fieldA11y(rid, { hint, error: shownError });
172
+ const promptId = `${rid}-prompt`;
173
+ const zoneName = label ? { "aria-labelledby": `${fieldLabelId(rid)} ${promptId}` } : null;
172
174
  const edge = dragOver ? "var(--border-brand)" : invalid ? "var(--interactive-error)" : "var(--border-default)";
173
175
  const usePrompt = prompt ?? (multiple ? "Drag files here, or click to choose" : "Drag a file here, or click to choose");
174
176
  const dragProps = disabled ? {} : {
@@ -191,6 +193,7 @@ const FileUpload = React.forwardRef(function FileUpload2(props, forwardedRef) {
191
193
  disabled,
192
194
  onClick: openPicker,
193
195
  ...a11y,
196
+ ...zoneName,
194
197
  ...dragProps,
195
198
  style: sx({
196
199
  display: "flex",
@@ -226,7 +229,7 @@ const FileUpload = React.forwardRef(function FileUpload2(props, forwardedRef) {
226
229
  children: /* @__PURE__ */ jsx(UploadCloud, { size: 24, strokeWidth: 1.75 })
227
230
  }
228
231
  ),
229
- /* @__PURE__ */ jsx("span", { style: sx({ fontSize: "var(--text-sm)", fontWeight: "var(--weight-medium)", color: "var(--text-primary)" }), children: usePrompt })
232
+ /* @__PURE__ */ jsx("span", { id: promptId, style: sx({ fontSize: "var(--text-sm)", fontWeight: "var(--weight-medium)", color: "var(--text-primary)" }), children: usePrompt })
230
233
  ]
231
234
  }
232
235
  );
@@ -238,6 +241,7 @@ const FileUpload = React.forwardRef(function FileUpload2(props, forwardedRef) {
238
241
  disabled,
239
242
  onClick: openPicker,
240
243
  ...a11y,
244
+ ...zoneName,
241
245
  ...dragProps,
242
246
  style: sx({
243
247
  display: "flex",
@@ -259,7 +263,7 @@ const FileUpload = React.forwardRef(function FileUpload2(props, forwardedRef) {
259
263
  }),
260
264
  children: [
261
265
  /* @__PURE__ */ jsx(UploadCloud, { size: 22, strokeWidth: 1.75, style: { color: dragOver ? "var(--text-brand)" : "var(--text-muted)" } }),
262
- /* @__PURE__ */ jsx("span", { style: sx({ fontSize: "var(--text-sm)", color: "var(--text-secondary)", lineHeight: 1.4 }), children: usePrompt })
266
+ /* @__PURE__ */ jsx("span", { id: promptId, style: sx({ fontSize: "var(--text-sm)", color: "var(--text-secondary)", lineHeight: 1.4 }), children: usePrompt })
263
267
  ]
264
268
  }
265
269
  );
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/forms/FileUpload.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { File as FileIcon, FileArchive, FileSpreadsheet, FileText, RefreshCw, Trash2, UploadCloud, type LucideIcon } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { Field } from '../_internal/Field';\nimport { fieldA11y } from '../_internal/fieldA11y';\nimport { mergeRefs } from '../_internal/mergeRefs';\n\n/**\n * Pick files — click, keyboard, or drag-and-drop — with a local preview.\n * Image-first (`shape` circle/square thumbnail); other types show an extension\n * chip. No upload happens here: `onChange` hands you the `File`(s); the preview\n * is local. Set `multiple` for a list; `value` then is `File[]`.\n */\ninterface BaseProps {\n label?: string;\n /** Helper text under the field — a good place for the accepted types / size. */\n hint?: string;\n /** Error message; also shown instead of a rejected-file message. */\n error?: string;\n required?: boolean;\n /** `accept` attribute, also enforced on drop. */\n accept?: string;\n /** Max size in MB — files above this are rejected with a message. */\n maxSizeMB?: number;\n /** Thumbnail shape for image previews. `circle` for avatars (single only). */\n shape?: 'circle' | 'square';\n /** Prompt inside the empty drop area. */\n prompt?: string;\n disabled?: boolean;\n id?: string;\n containerStyle?: React.CSSProperties;\n /** Reserve the hint/error row's height even with neither set — stops the\n * field from growing the moment a validation message appears. */\n preserveHelperSpace?: boolean;\n}\n\nexport type FileUploadProps = BaseProps &\n (\n | { multiple?: false; value?: File | string | null; onChange?: (file: File | null) => void }\n | { multiple: true; value?: File[]; onChange?: (files: File[]) => void }\n );\n\nfunction matchesAccept(file: File, accept: string): boolean {\n if (!accept || accept === '*' || accept === '*/*') return true;\n const name = file.name.toLowerCase();\n const type = file.type.toLowerCase();\n return accept\n .split(',')\n .map((t) => t.trim().toLowerCase())\n .some((tok) => {\n if (!tok) return false;\n if (tok.startsWith('.')) return name.endsWith(tok);\n if (tok.endsWith('/*')) return type.startsWith(tok.slice(0, -1));\n return type === tok;\n });\n}\n\nfunction fmtSize(bytes: number): string {\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${Math.round(bytes / 1024)} KB`;\n return `${(bytes / 1048576).toFixed(1)} MB`;\n}\n\n/** File-type glyph + colour, keyed by extension. Images never reach this. */\nconst GLYPHS: Record<string, { Icon: LucideIcon; color: string }> = {\n pdf: { Icon: FileText, color: 'var(--status-error-fg)' },\n doc: { Icon: FileText, color: 'var(--status-info-fg)' },\n docx: { Icon: FileText, color: 'var(--status-info-fg)' },\n rtf: { Icon: FileText, color: 'var(--status-info-fg)' },\n odt: { Icon: FileText, color: 'var(--status-info-fg)' },\n txt: { Icon: FileText, color: 'var(--status-neutral-fg)' },\n md: { Icon: FileText, color: 'var(--status-neutral-fg)' },\n csv: { Icon: FileSpreadsheet, color: 'var(--status-success-fg)' },\n xls: { Icon: FileSpreadsheet, color: 'var(--status-success-fg)' },\n xlsx: { Icon: FileSpreadsheet, color: 'var(--status-success-fg)' },\n ppt: { Icon: FileText, color: 'var(--status-warning-fg)' },\n pptx: { Icon: FileText, color: 'var(--status-warning-fg)' },\n zip: { Icon: FileArchive, color: 'var(--status-warning-fg)' },\n rar: { Icon: FileArchive, color: 'var(--status-warning-fg)' },\n '7z': { Icon: FileArchive, color: 'var(--status-warning-fg)' },\n};\nfunction glyphFor(name: string) {\n return GLYPHS[(name.split('.').pop() || '').toLowerCase()] ?? { Icon: FileIcon, color: 'var(--status-neutral-fg)' };\n}\n\n/** One thumbnail — the image itself, or a colour-coded file-type glyph. */\nfunction Thumb({ url, name, size, shape }: { url: string | null; name: string; size: number; shape: 'circle' | 'square' }) {\n const { Icon, color } = glyphFor(name);\n return (\n <span\n style={sx({\n width: size,\n height: size,\n flex: '0 0 auto',\n borderRadius: shape === 'circle' ? '999px' : 'var(--radius-md)',\n overflow: 'hidden',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n background: url ? 'var(--bg-subtle)' : `color-mix(in srgb, ${color} 12%, var(--bg-surface))`,\n border: '1px solid ' + (url ? 'var(--border-subtle)' : `color-mix(in srgb, ${color} 28%, transparent)`),\n })}\n >\n {url ? (\n // eslint-disable-next-line @next/next/no-img-element\n <img src={url} alt={name} style={sx({ width: '100%', height: '100%', objectFit: 'cover' })} />\n ) : (\n <Icon size={Math.round(size * 0.44)} strokeWidth={1.75} style={{ color }} />\n )}\n </span>\n );\n}\n\nconst actionBtn = {\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 6,\n minHeight: 36,\n padding: '0 12px',\n borderRadius: 'var(--radius-control)',\n border: '1px solid var(--border-default)',\n background: 'var(--bg-surface)',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n fontWeight: 'var(--weight-medium)',\n cursor: 'pointer',\n} as const;\n\n/**\n * A preview URL for a File (object URL) or an existing URL string. The object\n * URL is created *and* revoked inside one effect, so a re-render (or StrictMode's\n * mount/cleanup/mount) never leaves a revoked URL on screen.\n */\nfunction usePreviewUrl(file: File | string | null | undefined): string | null {\n const [url, setUrl] = React.useState<string | null>(typeof file === 'string' ? file : null);\n React.useEffect(() => {\n const isImageFile = file instanceof File && file.type.startsWith('image/');\n const next = isImageFile ? URL.createObjectURL(file) : typeof file === 'string' ? file : null;\n // eslint-disable-next-line react-hooks/set-state-in-effect -- syncing to an external resource (object URL)\n setUrl(next);\n return isImageFile ? () => URL.revokeObjectURL(next as string) : undefined;\n }, [file]);\n return url;\n}\n\n/** A stable-ish key for a File across list reorders. */\nfunction fileKey(f: File): string {\n return `${f.name}:${f.size}:${f.lastModified}`;\n}\n\nexport const FileUpload = React.forwardRef<HTMLInputElement, FileUploadProps>(function FileUpload(props, forwardedRef) {\n const {\n label,\n hint,\n error,\n required,\n accept = 'image/*',\n maxSizeMB = 5,\n shape = 'square',\n prompt,\n disabled,\n id,\n containerStyle,\n preserveHelperSpace,\n } = props;\n const multiple = props.multiple === true;\n\n const inputRef = React.useRef<HTMLInputElement>(null);\n const autoId = React.useId();\n const rid = id || autoId;\n const [rejected, setRejected] = React.useState<string | null>(null);\n const [dragOver, setDragOver] = React.useState(false);\n\n // Uncontrolled fallback — one shape covers both modes internally.\n const [internalOne, setInternalOne] = React.useState<File | null>(null);\n const [internalMany, setInternalMany] = React.useState<File[]>([]);\n const one = props.multiple ? null : props.value !== undefined ? props.value : internalOne;\n const many = props.multiple ? (props.value !== undefined ? props.value : internalMany) : [];\n\n const validate = (f: File): string | null => {\n if (!matchesAccept(f, accept)) return `“${f.name}” isn’t an accepted type.`;\n if (f.size > maxSizeMB * 1048576) return `“${f.name}” is over ${maxSizeMB} MB.`;\n return null;\n };\n\n const ingest = (list: FileList | null) => {\n const files = list ? Array.from(list) : [];\n if (!files.length) return;\n if (multiple) {\n const ok: File[] = [];\n const bad: string[] = [];\n for (const f of files) {\n const err = validate(f);\n if (err) bad.push(f.name);\n else ok.push(f);\n }\n setRejected(bad.length ? `Skipped ${bad.length} file${bad.length > 1 ? 's' : ''} (type or size).` : null);\n const next = [...many, ...ok];\n if (props.value === undefined) setInternalMany(next);\n props.onChange?.(next);\n } else {\n const f = files[0];\n const err = validate(f);\n if (err) {\n setRejected(err);\n return;\n }\n setRejected(null);\n if (props.value === undefined) setInternalOne(f);\n props.onChange?.(f);\n }\n };\n\n const removeAt = (i: number) => {\n const next = many.filter((_, j) => j !== i);\n if (props.value === undefined) setInternalMany(next);\n (props.onChange as ((f: File[]) => void) | undefined)?.(next);\n };\n const clearOne = () => {\n setRejected(null);\n if (inputRef.current) inputRef.current.value = '';\n if (props.value === undefined) setInternalOne(null);\n (props.onChange as ((f: File | null) => void) | undefined)?.(null);\n };\n const openPicker = () => {\n if (!disabled) inputRef.current?.click();\n };\n\n const oneUrl = usePreviewUrl(one);\n\n // A hard `error` (or a rejected single file) puts the field in an error state;\n // a \"skipped N\" note in multiple mode is informational, not an error.\n const invalid = Boolean(error || (rejected && !multiple));\n // What `Field` shows as the error: the consumer's, or a rejected single file's. The skipped-files\n // note of `multiple` is informational, so it is not one.\n const shownError = error || (multiple ? undefined : rejected) || undefined;\n // The hidden `<input type=\"file\">` is out of the accessibility tree, so the controls that take\n // focus carry these: the drop zone, and Replace once a file is chosen.\n const a11y = fieldA11y(rid, { hint, error: shownError });\n const edge = dragOver ? 'var(--border-brand)' : invalid ? 'var(--interactive-error)' : 'var(--border-default)';\n const usePrompt = prompt ?? (multiple ? 'Drag files here, or click to choose' : 'Drag a file here, or click to choose');\n\n const dragProps = disabled\n ? {}\n : {\n onDragOver: (e: React.DragEvent) => {\n e.preventDefault();\n setDragOver(true);\n },\n onDragLeave: () => setDragOver(false),\n onDrop: (e: React.DragEvent) => {\n e.preventDefault();\n setDragOver(false);\n ingest(e.dataTransfer.files);\n },\n };\n\n // ---- the drop zone (shown when empty in single mode, always in multiple) ----\n const circleZone = (\n <button\n type=\"button\"\n className=\"ds-affix-btn\"\n disabled={disabled}\n onClick={openPicker}\n {...a11y}\n {...dragProps}\n style={sx({\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'flex-start',\n gap: 'var(--space-4)',\n width: '100%',\n padding: 0,\n border: 'none',\n background: 'transparent',\n fontFamily: 'var(--font-body)',\n textAlign: 'left',\n cursor: disabled ? 'not-allowed' : 'pointer',\n opacity: disabled ? 0.6 : 1,\n })}\n >\n <span\n style={sx({\n width: 96,\n height: 96,\n flex: '0 0 auto',\n borderRadius: '999px',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n color: dragOver ? 'var(--text-brand)' : 'var(--text-muted)',\n border: '1.5px dashed ' + edge,\n background: dragOver ? 'color-mix(in srgb, var(--interactive-primary) 5%, transparent)' : 'transparent',\n transition: 'var(--transition-control)',\n })}\n >\n <UploadCloud size={24} strokeWidth={1.75} />\n </span>\n <span style={sx({ fontSize: 'var(--text-sm)', fontWeight: 'var(--weight-medium)', color: 'var(--text-primary)' })}>{usePrompt}</span>\n </button>\n );\n\n const boxZone = (\n <button\n type=\"button\"\n className=\"ds-affix-btn\"\n disabled={disabled}\n onClick={openPicker}\n {...a11y}\n {...dragProps}\n style={sx({\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 'var(--space-2)',\n width: '100%',\n boxSizing: 'border-box',\n padding: 'var(--space-6) var(--space-4)',\n borderRadius: 'var(--radius-lg)',\n border: '1.5px dashed ' + edge,\n background: dragOver ? 'color-mix(in srgb, var(--interactive-primary) 5%, var(--bg-surface))' : 'var(--bg-surface)',\n fontFamily: 'var(--font-body)',\n textAlign: 'center',\n cursor: disabled ? 'not-allowed' : 'pointer',\n opacity: disabled ? 0.6 : 1,\n transition: 'var(--transition-control)',\n })}\n >\n <UploadCloud size={22} strokeWidth={1.75} style={{ color: dragOver ? 'var(--text-brand)' : 'var(--text-muted)' }} />\n <span style={sx({ fontSize: 'var(--text-sm)', color: 'var(--text-secondary)', lineHeight: 1.4 })}>{usePrompt}</span>\n </button>\n );\n\n return (\n <Field label={label} hint={hint} error={shownError} required={required} htmlFor={rid} style={containerStyle} preserveHelperSpace={preserveHelperSpace}>\n <input\n ref={mergeRefs(inputRef, forwardedRef)}\n id={rid}\n type=\"file\"\n accept={accept}\n multiple={multiple}\n disabled={disabled}\n onChange={(e) => ingest(e.target.files)}\n style={{ display: 'none' }}\n />\n\n {multiple ? (\n <div style={sx({ display: 'flex', flexDirection: 'column', gap: 'var(--space-3)' })}>\n {boxZone}\n {many.length > 0 && (\n <ul style={sx({ listStyle: 'none', margin: 0, padding: 0, display: 'flex', flexDirection: 'column', gap: 'var(--space-2)' })}>\n {many.map((f, i) => (\n <MultiRow key={fileKey(f)} file={f} disabled={disabled} onRemove={() => removeAt(i)} />\n ))}\n </ul>\n )}\n {rejected && <span style={sx({ fontFamily: 'var(--font-body)', fontSize: 'var(--text-xs)', color: 'var(--text-muted)' })}>{rejected}</span>}\n </div>\n ) : one ? (\n <div style={sx({ display: 'flex', alignItems: 'flex-start', gap: 'var(--space-4)' })}>\n <Thumb url={oneUrl} name={typeof one === 'string' ? one.split('/').pop() || one : one.name} size={shape === 'circle' ? 88 : 96} shape={shape} />\n <div style={sx({ flex: 1, minWidth: 0, display: 'flex', flexDirection: 'column', gap: 4 })}>\n <span\n style={sx({\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n color: 'var(--text-primary)',\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n })}\n title={typeof one === 'string' ? one.split('/').pop() || one : one.name}\n >\n {typeof one === 'string' ? one.split('/').pop() || one : one.name}\n </span>\n {one instanceof File && <span style={sx({ fontFamily: 'var(--font-body)', fontSize: 'var(--text-xs)', color: 'var(--text-muted)' })}>{fmtSize(one.size)}</span>}\n {!disabled && (\n <div style={sx({ display: 'flex', gap: 'var(--space-2)', marginTop: 6, flexWrap: 'wrap' })}>\n <button type=\"button\" className=\"ds-affix-btn\" onClick={openPicker} {...a11y} style={{ ...actionBtn, color: 'var(--text-primary)' }}>\n <RefreshCw size={14} strokeWidth={2} /> Replace\n </button>\n <button type=\"button\" className=\"ds-affix-btn\" onClick={clearOne} style={{ ...actionBtn, color: 'var(--interactive-error)' }}>\n <Trash2 size={14} strokeWidth={2} /> Remove\n </button>\n </div>\n )}\n </div>\n </div>\n ) : shape === 'circle' ? (\n circleZone\n ) : (\n boxZone\n )}\n </Field>\n );\n});\n\nFileUpload.displayName = 'FileUpload';\n\nfunction MultiRow({ file, disabled, onRemove }: { file: File; disabled?: boolean; onRemove: () => void }) {\n const url = usePreviewUrl(file);\n return (\n <li\n style={sx({\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-3)',\n padding: 'var(--space-2)',\n borderRadius: 'var(--radius-md)',\n border: '1px solid var(--border-subtle)',\n background: 'var(--bg-surface)',\n })}\n >\n <Thumb url={url} name={file.name} size={44} shape=\"square\" />\n <span style={sx({ flex: 1, minWidth: 0, display: 'flex', flexDirection: 'column', gap: 1 })}>\n <span\n style={sx({\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n color: 'var(--text-primary)',\n minWidth: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n })}\n title={file.name}\n >\n {file.name}\n </span>\n <span style={sx({ fontFamily: 'var(--font-body)', fontSize: 'var(--text-xs)', color: 'var(--text-muted)' })}>{fmtSize(file.size)}</span>\n </span>\n {!disabled && (\n <button\n type=\"button\"\n className=\"ds-affix-btn\"\n aria-label={`Remove ${file.name}`}\n onClick={onRemove}\n style={sx({\n flex: '0 0 auto',\n width: 36,\n height: 36,\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n borderRadius: 'var(--radius-control)',\n border: '1px solid transparent',\n background: 'transparent',\n color: 'var(--interactive-error)',\n cursor: 'pointer',\n })}\n >\n <Trash2 size={16} strokeWidth={1.75} />\n </button>\n )}\n </li>\n );\n}\n"],"mappings":";AA2GQ,cA2JJ,YA3JI;AAzGR,YAAY,WAAW;AACvB,SAAS,QAAQ,UAAU,aAAa,iBAAiB,UAAU,WAAW,QAAQ,mBAAoC;AAC1H,SAAS,UAAU;AACnB,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAqC1B,SAAS,cAAc,MAAY,QAAyB;AAC1D,MAAI,CAAC,UAAU,WAAW,OAAO,WAAW,MAAO,QAAO;AAC1D,QAAM,OAAO,KAAK,KAAK,YAAY;AACnC,QAAM,OAAO,KAAK,KAAK,YAAY;AACnC,SAAO,OACJ,MAAM,GAAG,EACT,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,EACjC,KAAK,CAAC,QAAQ;AACb,QAAI,CAAC,IAAK,QAAO;AACjB,QAAI,IAAI,WAAW,GAA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AY;AAAA,gBACZ,UAAU;AAAA,gBACV,OAAO;AAAA,gBACP,UAAU;AAAA,gBACV,UAAU;AAAA,gBACV,YAAY;AAAA,gBACZ,UAAU;AAAA,gBACV,cAAc;AAAA,cAChB,CAAC;AAAA,cACD,OAAO,KAAK;AAAA,cAEX,eAAK;AAAA;AAAA,UACR;AAAA,UACA,oBAAC,UAAK,OAAO,GAAG,EAAE,YAAY,oBAAoB,UAAU,kBAAkB,OAAO,oBAAoB,CAAC,GAAI,kBAAQ,KAAK,IAAI,GAAE;AAAA,WACnI;AAAA,QACC,CAAC,YACA;AAAA,UAAC;AAAA;AAAA,YACC,MAAK;AAAA,YACL,WAAU;AAAA,YACV,cAAY,UAAU,KAAK,IAAI;AAAA,YAC/B,SAAS;AAAA,YACT,OAAO,GAAG;AAAA,cACR,MAAM;AAAA,cACN,OAAO;AAAA,cACP,QAAQ;AAAA,cACR,SAAS;AAAA,cACT,YAAY;AAAA,cACZ,gBAAgB;AAAA,cAChB,cAAc;AAAA,cACd,QAAQ;AAAA,cACR,YAAY;AAAA,cACZ,OAAO;AAAA,cACP,QAAQ;AAAA,YACV,CAAC;AAAA,YAED,8BAAC,UAAO,MAAM,IAAI,aAAa,MAAM;AAAA;AAAA,QACvC;AAAA;AAAA;AAAA,EAEJ;AAEJ;","names":["FileUpload"]}
1
+ {"version":3,"sources":["../../src/forms/FileUpload.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { File as FileIcon, FileArchive, FileSpreadsheet, FileText, RefreshCw, Trash2, UploadCloud, type LucideIcon } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { Field } from '../_internal/Field';\nimport { fieldA11y, fieldLabelId } from '../_internal/fieldA11y';\nimport { mergeRefs } from '../_internal/mergeRefs';\n\n/**\n * Pick files - click, keyboard, or drag-and-drop - with a local preview.\n * Image-first (`shape` circle/square thumbnail); other types show an extension\n * chip. No upload happens here: `onChange` hands you the `File`(s); the preview\n * is local. Set `multiple` for a list; `value` then is `File[]`.\n */\ninterface BaseProps {\n label?: string;\n /** Helper text under the field - a good place for the accepted types / size. */\n hint?: string;\n /** Error message; also shown instead of a rejected-file message. */\n error?: string;\n required?: boolean;\n /** `accept` attribute, also enforced on drop. */\n accept?: string;\n /** Max size in MB - files above this are rejected with a message. */\n maxSizeMB?: number;\n /** Thumbnail shape for image previews. `circle` for avatars (single only). */\n shape?: 'circle' | 'square';\n /** Prompt inside the empty drop area. */\n prompt?: string;\n disabled?: boolean;\n id?: string;\n containerStyle?: React.CSSProperties;\n /** Reserve the hint/error row's height even with neither set - stops the\n * field from growing the moment a validation message appears. */\n preserveHelperSpace?: boolean;\n}\n\nexport type FileUploadProps = BaseProps &\n (\n | { multiple?: false; value?: File | string | null; onChange?: (file: File | null) => void }\n | { multiple: true; value?: File[]; onChange?: (files: File[]) => void }\n );\n\nfunction matchesAccept(file: File, accept: string): boolean {\n if (!accept || accept === '*' || accept === '*/*') return true;\n const name = file.name.toLowerCase();\n const type = file.type.toLowerCase();\n return accept\n .split(',')\n .map((t) => t.trim().toLowerCase())\n .some((tok) => {\n if (!tok) return false;\n if (tok.startsWith('.')) return name.endsWith(tok);\n if (tok.endsWith('/*')) return type.startsWith(tok.slice(0, -1));\n return type === tok;\n });\n}\n\nfunction fmtSize(bytes: number): string {\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${Math.round(bytes / 1024)} KB`;\n return `${(bytes / 1048576).toFixed(1)} MB`;\n}\n\n/** File-type glyph + colour, keyed by extension. Images never reach this. */\nconst GLYPHS: Record<string, { Icon: LucideIcon; color: string }> = {\n pdf: { Icon: FileText, color: 'var(--status-error-fg)' },\n doc: { Icon: FileText, color: 'var(--status-info-fg)' },\n docx: { Icon: FileText, color: 'var(--status-info-fg)' },\n rtf: { Icon: FileText, color: 'var(--status-info-fg)' },\n odt: { Icon: FileText, color: 'var(--status-info-fg)' },\n txt: { Icon: FileText, color: 'var(--status-neutral-fg)' },\n md: { Icon: FileText, color: 'var(--status-neutral-fg)' },\n csv: { Icon: FileSpreadsheet, color: 'var(--status-success-fg)' },\n xls: { Icon: FileSpreadsheet, color: 'var(--status-success-fg)' },\n xlsx: { Icon: FileSpreadsheet, color: 'var(--status-success-fg)' },\n ppt: { Icon: FileText, color: 'var(--status-warning-fg)' },\n pptx: { Icon: FileText, color: 'var(--status-warning-fg)' },\n zip: { Icon: FileArchive, color: 'var(--status-warning-fg)' },\n rar: { Icon: FileArchive, color: 'var(--status-warning-fg)' },\n '7z': { Icon: FileArchive, color: 'var(--status-warning-fg)' },\n};\nfunction glyphFor(name: string) {\n return GLYPHS[(name.split('.').pop() || '').toLowerCase()] ?? { Icon: FileIcon, color: 'var(--status-neutral-fg)' };\n}\n\n/** One thumbnail - the image itself, or a colour-coded file-type glyph. */\nfunction Thumb({ url, name, size, shape }: { url: string | null; name: string; size: number; shape: 'circle' | 'square' }) {\n const { Icon, color } = glyphFor(name);\n return (\n <span\n style={sx({\n width: size,\n height: size,\n flex: '0 0 auto',\n borderRadius: shape === 'circle' ? '999px' : 'var(--radius-md)',\n overflow: 'hidden',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n background: url ? 'var(--bg-subtle)' : `color-mix(in srgb, ${color} 12%, var(--bg-surface))`,\n border: '1px solid ' + (url ? 'var(--border-subtle)' : `color-mix(in srgb, ${color} 28%, transparent)`),\n })}\n >\n {url ? (\n // eslint-disable-next-line @next/next/no-img-element\n <img src={url} alt={name} style={sx({ width: '100%', height: '100%', objectFit: 'cover' })} />\n ) : (\n <Icon size={Math.round(size * 0.44)} strokeWidth={1.75} style={{ color }} />\n )}\n </span>\n );\n}\n\nconst actionBtn = {\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 6,\n minHeight: 36,\n padding: '0 12px',\n borderRadius: 'var(--radius-control)',\n border: '1px solid var(--border-default)',\n background: 'var(--bg-surface)',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n fontWeight: 'var(--weight-medium)',\n cursor: 'pointer',\n} as const;\n\n/**\n * A preview URL for a File (object URL) or an existing URL string. The object\n * URL is created *and* revoked inside one effect, so a re-render (or StrictMode's\n * mount/cleanup/mount) never leaves a revoked URL on screen.\n */\nfunction usePreviewUrl(file: File | string | null | undefined): string | null {\n const [url, setUrl] = React.useState<string | null>(typeof file === 'string' ? file : null);\n React.useEffect(() => {\n const isImageFile = file instanceof File && file.type.startsWith('image/');\n const next = isImageFile ? URL.createObjectURL(file) : typeof file === 'string' ? file : null;\n // eslint-disable-next-line react-hooks/set-state-in-effect -- syncing to an external resource (object URL)\n setUrl(next);\n return isImageFile ? () => URL.revokeObjectURL(next as string) : undefined;\n }, [file]);\n return url;\n}\n\n/** A stable-ish key for a File across list reorders. */\nfunction fileKey(f: File): string {\n return `${f.name}:${f.size}:${f.lastModified}`;\n}\n\nexport const FileUpload = React.forwardRef<HTMLInputElement, FileUploadProps>(function FileUpload(props, forwardedRef) {\n const {\n label,\n hint,\n error,\n required,\n accept = 'image/*',\n maxSizeMB = 5,\n shape = 'square',\n prompt,\n disabled,\n id,\n containerStyle,\n preserveHelperSpace,\n } = props;\n const multiple = props.multiple === true;\n\n const inputRef = React.useRef<HTMLInputElement>(null);\n const autoId = React.useId();\n const rid = id || autoId;\n const [rejected, setRejected] = React.useState<string | null>(null);\n const [dragOver, setDragOver] = React.useState(false);\n\n // Uncontrolled fallback - one shape covers both modes internally.\n const [internalOne, setInternalOne] = React.useState<File | null>(null);\n const [internalMany, setInternalMany] = React.useState<File[]>([]);\n const one = props.multiple ? null : props.value !== undefined ? props.value : internalOne;\n const many = props.multiple ? (props.value !== undefined ? props.value : internalMany) : [];\n\n const validate = (f: File): string | null => {\n if (!matchesAccept(f, accept)) return `“${f.name}” isn’t an accepted type.`;\n if (f.size > maxSizeMB * 1048576) return `“${f.name}” is over ${maxSizeMB} MB.`;\n return null;\n };\n\n const ingest = (list: FileList | null) => {\n const files = list ? Array.from(list) : [];\n if (!files.length) return;\n if (multiple) {\n const ok: File[] = [];\n const bad: string[] = [];\n for (const f of files) {\n const err = validate(f);\n if (err) bad.push(f.name);\n else ok.push(f);\n }\n setRejected(bad.length ? `Skipped ${bad.length} file${bad.length > 1 ? 's' : ''} (type or size).` : null);\n const next = [...many, ...ok];\n if (props.value === undefined) setInternalMany(next);\n props.onChange?.(next);\n } else {\n const f = files[0];\n const err = validate(f);\n if (err) {\n setRejected(err);\n return;\n }\n setRejected(null);\n if (props.value === undefined) setInternalOne(f);\n props.onChange?.(f);\n }\n };\n\n const removeAt = (i: number) => {\n const next = many.filter((_, j) => j !== i);\n if (props.value === undefined) setInternalMany(next);\n (props.onChange as ((f: File[]) => void) | undefined)?.(next);\n };\n const clearOne = () => {\n setRejected(null);\n if (inputRef.current) inputRef.current.value = '';\n if (props.value === undefined) setInternalOne(null);\n (props.onChange as ((f: File | null) => void) | undefined)?.(null);\n };\n const openPicker = () => {\n if (!disabled) inputRef.current?.click();\n };\n\n const oneUrl = usePreviewUrl(one);\n\n // A hard `error` (or a rejected single file) puts the field in an error state;\n // a \"skipped N\" note in multiple mode is informational, not an error.\n const invalid = Boolean(error || (rejected && !multiple));\n // What `Field` shows as the error: the consumer's, or a rejected single file's. The skipped-files\n // note of `multiple` is informational, so it is not one.\n const shownError = error || (multiple ? undefined : rejected) || undefined;\n // The hidden `<input type=\"file\">` is out of the accessibility tree, so the controls that take\n // focus carry these: the drop zone, and Replace once a file is chosen.\n const a11y = fieldA11y(rid, { hint, error: shownError });\n // The field `<label for>` points at that hidden input too, so it does not name the drop zone: do it\n // here, label first, then the prompt the zone already read.\n const promptId = `${rid}-prompt`;\n const zoneName = label ? { 'aria-labelledby': `${fieldLabelId(rid)} ${promptId}` } : null;\n const edge = dragOver ? 'var(--border-brand)' : invalid ? 'var(--interactive-error)' : 'var(--border-default)';\n const usePrompt = prompt ?? (multiple ? 'Drag files here, or click to choose' : 'Drag a file here, or click to choose');\n\n const dragProps = disabled\n ? {}\n : {\n onDragOver: (e: React.DragEvent) => {\n e.preventDefault();\n setDragOver(true);\n },\n onDragLeave: () => setDragOver(false),\n onDrop: (e: React.DragEvent) => {\n e.preventDefault();\n setDragOver(false);\n ingest(e.dataTransfer.files);\n },\n };\n\n // ---- the drop zone (shown when empty in single mode, always in multiple) ----\n const circleZone = (\n <button\n type=\"button\"\n className=\"ds-affix-btn\"\n disabled={disabled}\n onClick={openPicker}\n {...a11y}\n {...zoneName}\n {...dragProps}\n style={sx({\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'flex-start',\n gap: 'var(--space-4)',\n width: '100%',\n padding: 0,\n border: 'none',\n background: 'transparent',\n fontFamily: 'var(--font-body)',\n textAlign: 'left',\n cursor: disabled ? 'not-allowed' : 'pointer',\n opacity: disabled ? 0.6 : 1,\n })}\n >\n <span\n style={sx({\n width: 96,\n height: 96,\n flex: '0 0 auto',\n borderRadius: '999px',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n color: dragOver ? 'var(--text-brand)' : 'var(--text-muted)',\n border: '1.5px dashed ' + edge,\n background: dragOver ? 'color-mix(in srgb, var(--interactive-primary) 5%, transparent)' : 'transparent',\n transition: 'var(--transition-control)',\n })}\n >\n <UploadCloud size={24} strokeWidth={1.75} />\n </span>\n <span id={promptId} style={sx({ fontSize: 'var(--text-sm)', fontWeight: 'var(--weight-medium)', color: 'var(--text-primary)' })}>{usePrompt}</span>\n </button>\n );\n\n const boxZone = (\n <button\n type=\"button\"\n className=\"ds-affix-btn\"\n disabled={disabled}\n onClick={openPicker}\n {...a11y}\n {...zoneName}\n {...dragProps}\n style={sx({\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 'var(--space-2)',\n width: '100%',\n boxSizing: 'border-box',\n padding: 'var(--space-6) var(--space-4)',\n borderRadius: 'var(--radius-lg)',\n border: '1.5px dashed ' + edge,\n background: dragOver ? 'color-mix(in srgb, var(--interactive-primary) 5%, var(--bg-surface))' : 'var(--bg-surface)',\n fontFamily: 'var(--font-body)',\n textAlign: 'center',\n cursor: disabled ? 'not-allowed' : 'pointer',\n opacity: disabled ? 0.6 : 1,\n transition: 'var(--transition-control)',\n })}\n >\n <UploadCloud size={22} strokeWidth={1.75} style={{ color: dragOver ? 'var(--text-brand)' : 'var(--text-muted)' }} />\n <span id={promptId} style={sx({ fontSize: 'var(--text-sm)', color: 'var(--text-secondary)', lineHeight: 1.4 })}>{usePrompt}</span>\n </button>\n );\n\n return (\n <Field label={label} hint={hint} error={shownError} required={required} htmlFor={rid} style={containerStyle} preserveHelperSpace={preserveHelperSpace}>\n <input\n ref={mergeRefs(inputRef, forwardedRef)}\n id={rid}\n type=\"file\"\n accept={accept}\n multiple={multiple}\n disabled={disabled}\n onChange={(e) => ingest(e.target.files)}\n style={{ display: 'none' }}\n />\n\n {multiple ? (\n <div style={sx({ display: 'flex', flexDirection: 'column', gap: 'var(--space-3)' })}>\n {boxZone}\n {many.length > 0 && (\n <ul style={sx({ listStyle: 'none', margin: 0, padding: 0, display: 'flex', flexDirection: 'column', gap: 'var(--space-2)' })}>\n {many.map((f, i) => (\n <MultiRow key={fileKey(f)} file={f} disabled={disabled} onRemove={() => removeAt(i)} />\n ))}\n </ul>\n )}\n {rejected && <span style={sx({ fontFamily: 'var(--font-body)', fontSize: 'var(--text-xs)', color: 'var(--text-muted)' })}>{rejected}</span>}\n </div>\n ) : one ? (\n <div style={sx({ display: 'flex', alignItems: 'flex-start', gap: 'var(--space-4)' })}>\n <Thumb url={oneUrl} name={typeof one === 'string' ? one.split('/').pop() || one : one.name} size={shape === 'circle' ? 88 : 96} shape={shape} />\n <div style={sx({ flex: 1, minWidth: 0, display: 'flex', flexDirection: 'column', gap: 4 })}>\n <span\n style={sx({\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n color: 'var(--text-primary)',\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n })}\n title={typeof one === 'string' ? one.split('/').pop() || one : one.name}\n >\n {typeof one === 'string' ? one.split('/').pop() || one : one.name}\n </span>\n {one instanceof File && <span style={sx({ fontFamily: 'var(--font-body)', fontSize: 'var(--text-xs)', color: 'var(--text-muted)' })}>{fmtSize(one.size)}</span>}\n {!disabled && (\n <div style={sx({ display: 'flex', gap: 'var(--space-2)', marginTop: 6, flexWrap: 'wrap' })}>\n <button type=\"button\" className=\"ds-affix-btn\" onClick={openPicker} {...a11y} style={{ ...actionBtn, color: 'var(--text-primary)' }}>\n <RefreshCw size={14} strokeWidth={2} /> Replace\n </button>\n <button type=\"button\" className=\"ds-affix-btn\" onClick={clearOne} style={{ ...actionBtn, color: 'var(--interactive-error)' }}>\n <Trash2 size={14} strokeWidth={2} /> Remove\n </button>\n </div>\n )}\n </div>\n </div>\n ) : shape === 'circle' ? (\n circleZone\n ) : (\n boxZone\n )}\n </Field>\n );\n});\n\nFileUpload.displayName = 'FileUpload';\n\nfunction MultiRow({ file, disabled, onRemove }: { file: File; disabled?: boolean; onRemove: () => void }) {\n const url = usePreviewUrl(file);\n return (\n <li\n style={sx({\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-3)',\n padding: 'var(--space-2)',\n borderRadius: 'var(--radius-md)',\n border: '1px solid var(--border-subtle)',\n background: 'var(--bg-surface)',\n })}\n >\n <Thumb url={url} name={file.name} size={44} shape=\"square\" />\n <span style={sx({ flex: 1, minWidth: 0, display: 'flex', flexDirection: 'column', gap: 1 })}>\n <span\n style={sx({\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n color: 'var(--text-primary)',\n minWidth: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n })}\n title={file.name}\n >\n {file.name}\n </span>\n <span style={sx({ fontFamily: 'var(--font-body)', fontSize: 'var(--text-xs)', color: 'var(--text-muted)' })}>{fmtSize(file.size)}</span>\n </span>\n {!disabled && (\n <button\n type=\"button\"\n className=\"ds-affix-btn\"\n aria-label={`Remove ${file.name}`}\n onClick={onRemove}\n style={sx({\n flex: '0 0 auto',\n width: 36,\n height: 36,\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n borderRadius: 'var(--radius-control)',\n border: '1px solid transparent',\n background: 'transparent',\n color: 'var(--interactive-error)',\n cursor: 'pointer',\n })}\n >\n <Trash2 size={16} strokeWidth={1.75} />\n </button>\n )}\n </li>\n );\n}\n"],"mappings":";AA2GQ,cA+JJ,YA/JI;AAzGR,YAAY,WAAW;AACvB,SAAS,QAAQ,UAAU,aAAa,iBAAiB,UAAU,WAAW,QAAQ,mBAAoC;AAC1H,SAAS,UAAU;AACnB,SAAS,aAAa;AACtB,SAAS,WAAW,oBAAoB;AACxC,SAAS,iBAAiB;AAqC1B,SAAS,cAAc,MAAY,QAAyB;AAC1D,MAAI,CAAC,UAAU,WAAW,OAAO,WAAW,MAAO,QAAO;AAC1D,QAAM,OAAO,KAAK,KAAK,YAAY;AACnC,QAAM,OAAO,KAAK,KAAK,YAAY;AACnC,SAAO,OACJ,MAAM,GAAG,EACT,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,EACjC,KAAK,CAAC,QAAQ;AACb,QAAI,CAAC,IAAK,QAAO;AACjB,QAAI,IAAI,WAAW,GAAG,EAAG,QAAO,KAAK,SAAS,GAAG;AACjD,QAAI,IAAI,SAAS,IAAI,EAAG,QAAO,KAAK,WAAW,IAAI,MAAM,GAAG,EAAE,CAAC;AAC/D,WAAO,SAAS;AAAA,EAClB,CAAC;AACL;AAEA,SAAS,QAAQ,OAAuB;AACtC,MAAI,QAAQ,KAAM,QAAO,GAAG,KAAK;AACjC,MAAI,QAAQ,OAAO,KAAM,QAAO,GAAG,KAAK,MAAM,QAAQ,IAAI,CAAC;AAC3D,SAAO,IAAI,QAAQ,SAAS,QAAQ,CAAC,CAAC;AACxC;AAGA,MAAM,SAA8D;AAAA,EAClE,KAAK,EAAE,MAAM,UAAU,OAAO,yBAAyB;AAAA,EACvD,KAAK,EAAE,MAAM,UAAU,OA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oB,CAAC,GAAI,kBAAQ,KAAK,IAAI,GAAE;AAAA,WACnI;AAAA,QACC,CAAC,YACA;AAAA,UAAC;AAAA;AAAA,YACC,MAAK;AAAA,YACL,WAAU;AAAA,YACV,cAAY,UAAU,KAAK,IAAI;AAAA,YAC/B,SAAS;AAAA,YACT,OAAO,GAAG;AAAA,cACR,MAAM;AAAA,cACN,OAAO;AAAA,cACP,QAAQ;AAAA,cACR,SAAS;AAAA,cACT,YAAY;AAAA,cACZ,gBAAgB;AAAA,cAChB,cAAc;AAAA,cACd,QAAQ;AAAA,cACR,YAAY;AAAA,cACZ,OAAO;AAAA,cACP,QAAQ;AAAA,YACV,CAAC;AAAA,YAED,8BAAC,UAAO,MAAM,IAAI,aAAa,MAAM;AAAA;AAAA,QACvC;AAAA;AAAA;AAAA,EAEJ;AAEJ;","names":["FileUpload"]}
@@ -29,7 +29,7 @@ interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, '
29
29
  */
30
30
  showCount?: boolean;
31
31
  containerStyle?: React.CSSProperties;
32
- /** Reserve the hint/error row's height even with neither set — stops the
32
+ /** Reserve the hint/error row's height even with neither set - stops the
33
33
  * field from growing the moment a validation message appears. */
34
34
  preserveHelperSpace?: boolean;
35
35
  }
@@ -35,6 +35,7 @@ const Input = React.forwardRef(function Input2({
35
35
  defaultValue,
36
36
  "aria-describedby": describedBy,
37
37
  "aria-invalid": invalid,
38
+ "aria-required": ariaRequired,
38
39
  ...rest
39
40
  }, ref) {
40
41
  const [focus, setFocus] = React.useState(false);
@@ -42,7 +43,7 @@ const Input = React.forwardRef(function Input2({
42
43
  const inputRef = React.useRef(null);
43
44
  const autoId = React.useId();
44
45
  const rid = id || autoId;
45
- const a11y = fieldA11y(rid, { hint, error, describedBy, invalid });
46
+ const a11y = fieldA11y(rid, { hint, error, describedBy, invalid, required, ariaRequired });
46
47
  const isPassword = type === "password";
47
48
  const showCounter = Boolean(showCount) || maxLength != null;
48
49
  const seed = mask && typeof defaultValue === "string" ? formatMask(mask, defaultValue) : defaultValue;
@@ -79,6 +80,7 @@ const Input = React.forwardRef(function Input2({
79
80
  hint,
80
81
  error,
81
82
  required,
83
+ requiredExposed: true,
82
84
  htmlFor: rid,
83
85
  style: containerStyle,
84
86
  counter: showCounter ? /* @__PURE__ */ jsx(CharCount, { count, max: maxLength ?? void 0 }) : void 0,
@@ -121,7 +123,7 @@ const Input = React.forwardRef(function Input2({
121
123
  minWidth: 0,
122
124
  margin: 0,
123
125
  padding: 0,
124
- // reset the UA input padding — the row's own padding insets it
126
+ // reset the UA input padding - the row's own padding insets it
125
127
  border: "none",
126
128
  outline: "none",
127
129
  background: "transparent",