@sereno-ds/ui 0.27.0 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/_internal/CharCount.js +1 -1
  2. package/dist/_internal/Field.d.ts +9 -1
  3. package/dist/_internal/Field.js +57 -48
  4. package/dist/_internal/Field.js.map +1 -1
  5. package/dist/core/Avatar.js +1 -1
  6. package/dist/core/Badge.js +1 -1
  7. package/dist/core/Brand.js +1 -1
  8. package/dist/core/Button.js +1 -1
  9. package/dist/core/Card.js +2 -2
  10. package/dist/core/IconButton.js +2 -2
  11. package/dist/core/Menu.js +1 -1
  12. package/dist/core/Table.js +1 -1
  13. package/dist/feedback/Alert.js +1 -1
  14. package/dist/feedback/Dialog.js +1 -1
  15. package/dist/feedback/EmptyState.js +1 -1
  16. package/dist/feedback/Skeleton.js +1 -1
  17. package/dist/feedback/Toast.js +1 -1
  18. package/dist/feedback/ToastProvider.js +2 -2
  19. package/dist/forms/AvatarUpload.d.ts +4 -1
  20. package/dist/forms/AvatarUpload.js +6 -5
  21. package/dist/forms/AvatarUpload.js.map +1 -1
  22. package/dist/forms/Checkbox.d.ts +10 -2
  23. package/dist/forms/Checkbox.js +16 -4
  24. package/dist/forms/Checkbox.js.map +1 -1
  25. package/dist/forms/DatePicker.d.ts +4 -1
  26. package/dist/forms/DatePicker.js +7 -6
  27. package/dist/forms/DatePicker.js.map +1 -1
  28. package/dist/forms/DateTimePicker.js +2 -2
  29. package/dist/forms/FileUpload.d.ts +3 -0
  30. package/dist/forms/FileUpload.js +5 -4
  31. package/dist/forms/FileUpload.js.map +1 -1
  32. package/dist/forms/Input.d.ts +4 -1
  33. package/dist/forms/Input.js +6 -4
  34. package/dist/forms/Input.js.map +1 -1
  35. package/dist/forms/Radio.d.ts +10 -2
  36. package/dist/forms/Radio.js +16 -4
  37. package/dist/forms/Radio.js.map +1 -1
  38. package/dist/forms/SearchInput.js +2 -2
  39. package/dist/forms/Select.d.ts +4 -1
  40. package/dist/forms/Select.js +6 -5
  41. package/dist/forms/Select.js.map +1 -1
  42. package/dist/forms/Switch.js +1 -1
  43. package/dist/forms/Textarea.d.ts +4 -1
  44. package/dist/forms/Textarea.js +5 -4
  45. package/dist/forms/Textarea.js.map +1 -1
  46. package/dist/forms/_internal/CalendarGrid.js +2 -2
  47. package/dist/forms/_internal/fieldBoxStyle.js +1 -1
  48. package/dist/index.js +32 -32
  49. package/dist/navigation/BottomNav.js +1 -1
  50. package/dist/navigation/SidebarNav.js +2 -2
  51. package/dist/navigation/Stepper.js +1 -1
  52. package/dist/navigation/Tabs.js +1 -1
  53. package/dist/navigation/TopBar.js +1 -1
  54. package/dist/theme/ThemeToggle.js +1 -1
  55. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/forms/Checkbox.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\n\n/** Opt-in control for consents and multi-select filters. Host must include the `.sereno-check:checked` and `.sereno-check:indeterminate` rules (see globals.css). */\nexport interface CheckboxProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'size'> {\n label?: string;\n /** Secondary line under the label. */\n description?: string;\n /** Mixed state — some but not all children selected. Visual only; a form still submits it as unchecked. */\n indeterminate?: boolean;\n /** Box size. `sm` (16px) for dense filter lists; `md` (20px) everywhere else. */\n size?: 'sm' | 'md';\n}\n\nexport function Checkbox({ label, description, checked, defaultChecked, disabled, indeterminate, size = 'md', onChange, style, ...rest }: CheckboxProps) {\n const [hover, setHover] = React.useState(false);\n const box = size === 'sm' ? 16 : 20;\n const ref = React.useRef<HTMLInputElement>(null);\n // `indeterminate` is a DOM property, not an attribute — set it imperatively, and\n // re-assert on every render so a `checked` change never leaves it stale.\n React.useEffect(() => {\n if (ref.current) ref.current.indeterminate = Boolean(indeterminate);\n });\n return (\n <label\n onMouseEnter={() => setHover(true)}\n onMouseLeave={() => setHover(false)}\n style={sx({ display: 'flex', gap: 'var(--space-3)', alignItems: 'flex-start', cursor: disabled ? 'not-allowed' : 'pointer', opacity: disabled ? 0.6 : 1, ...style })}\n >\n <span style={sx({ position: 'relative', display: 'inline-flex', flex: '0 0 auto', marginTop: size === 'sm' ? 3 : 1 })}>\n <input\n ref={ref}\n type=\"checkbox\"\n checked={checked}\n defaultChecked={defaultChecked}\n disabled={disabled}\n onChange={onChange}\n {...rest}\n data-size={size}\n className=\"sereno-check\"\n style={sx({\n appearance: 'none',\n width: box,\n height: box,\n margin: 0,\n borderRadius: 'var(--radius-sm)',\n border: 'var(--border-width-emphasis) solid ' + (hover && !disabled ? 'var(--border-brand)' : 'var(--border-strong)'),\n // `backgroundColor`, not `background` — the shorthand would set an inline\n // `background-size: auto` that overrides the `:checked` glyph scaling.\n backgroundColor: 'var(--bg-surface)',\n cursor: 'inherit',\n transition: 'var(--transition-control)',\n })}\n />\n </span>\n <span style={sx({ display: 'flex', flexDirection: 'column', gap: 2 })}>\n {label && <span style={sx({ fontFamily: 'var(--font-body)', fontSize: 'var(--text-base)', color: 'var(--text-primary)', lineHeight: 1.35 })}>{label}</span>}\n {description && (\n <span style={sx({ fontFamily: 'var(--font-body)', fontSize: 'var(--text-xs)', color: 'var(--text-muted)', lineHeight: 1.45 })}>{description}</span>\n )}\n </span>\n </label>\n );\n}"],"mappings":";AAgCQ,cAyBF,YAzBE;AA9BR,YAAY,WAAW;AACvB,SAAS,UAAU;AAaZ,SAAS,SAAS,EAAE,OAAO,aAAa,SAAS,gBAAgB,UAAU,eAAe,OAAO,MAAM,UAAU,OAAO,GAAG,KAAK,GAAkB;AACvJ,QAAM,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAS,KAAK;AAC9C,QAAM,MAAM,SAAS,OAAO,KAAK;AACjC,QAAM,MAAM,MAAM,OAAyB,IAAI;AAG/C,QAAM,UAAU,MAAM;AACpB,QAAI,IAAI,QAAS,KAAI,QAAQ,gBAAgB,QAAQ,aAAa;AAAA,EACpE,CAAC;A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from 'react';\nimport { sx } from '../_internal/style';\n\n/** Opt-in control for consents and multi-select filters. Host must include the `.sereno-check:checked` and `.sereno-check:indeterminate` rules (see globals.css). */\nexport interface CheckboxProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'size'> {\n label?: string;\n /** Secondary line under the label. Replaced by `error` when present. */\n description?: string;\n /** Error message — tints the box and the secondary line red. Replaces `description`. */\n error?: string;\n /** Mixed state — some but not all children selected. Visual only; a form still submits it as unchecked. */\n indeterminate?: boolean;\n /** Box size. `sm` (16px) for dense filter lists; `md` (20px) everywhere else. */\n size?: 'sm' | 'md';\n /**\n * Reserve the description/error row's height even with neither set — keeps\n * the row stable as `error` comes and goes (SS-259, same mechanism as\n * `Input`'s `preserveHelperSpace`). Off by default.\n */\n preserveHelperSpace?: boolean;\n}\n\nexport function Checkbox({ label, description, error, checked, defaultChecked, disabled, indeterminate, size = 'md', preserveHelperSpace = false, onChange, style, ...rest }: CheckboxProps) {\n const [hover, setHover] = React.useState(false);\n const box = size === 'sm' ? 16 : 20;\n const ref = React.useRef<HTMLInputElement>(null);\n // `indeterminate` is a DOM property, not an attribute — set it imperatively, and\n // re-assert on every render so a `checked` change never leaves it stale.\n React.useEffect(() => {\n if (ref.current) ref.current.indeterminate = Boolean(indeterminate);\n });\n return (\n <label\n onMouseEnter={() => setHover(true)}\n onMouseLeave={() => setHover(false)}\n style={sx({ display: 'flex', gap: 'var(--space-3)', alignItems: 'flex-start', cursor: disabled ? 'not-allowed' : 'pointer', opacity: disabled ? 0.6 : 1, ...style })}\n >\n <span style={sx({ position: 'relative', display: 'inline-flex', flex: '0 0 auto', marginTop: size === 'sm' ? 3 : 1 })}>\n <input\n ref={ref}\n type=\"checkbox\"\n checked={checked}\n defaultChecked={defaultChecked}\n disabled={disabled}\n onChange={onChange}\n {...rest}\n data-size={size}\n className=\"sereno-check\"\n style={sx({\n appearance: 'none',\n width: box,\n height: box,\n margin: 0,\n borderRadius: 'var(--radius-sm)',\n border: 'var(--border-width-emphasis) solid ' + (error ? 'var(--interactive-error)' : hover && !disabled ? 'var(--border-brand)' : 'var(--border-strong)'),\n // `backgroundColor`, not `background` — the shorthand would set an inline\n // `background-size: auto` that overrides the `:checked` glyph scaling.\n backgroundColor: 'var(--bg-surface)',\n cursor: 'inherit',\n transition: 'var(--transition-control)',\n })}\n />\n </span>\n <span style={sx({ display: 'flex', flexDirection: 'column', gap: 2 })}>\n {label && <span style={sx({ fontFamily: 'var(--font-body)', fontSize: 'var(--text-base)', color: 'var(--text-primary)', lineHeight: 1.35 })}>{label}</span>}\n {(description || error || preserveHelperSpace) && (\n <span\n style={sx({\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-xs)',\n color: error ? 'var(--interactive-error)' : 'var(--text-muted)',\n lineHeight: 1.45,\n minHeight: preserveHelperSpace ? 'calc(var(--text-xs) * 1.45)' : undefined,\n })}\n >\n {error || description}\n </span>\n )}\n </span>\n </label>\n );\n}"],"mappings":";AAwCQ,cAyBF,YAzBE;AAtCR,YAAY,WAAW;AACvB,SAAS,UAAU;AAqBZ,SAAS,SAAS,EAAE,OAAO,aAAa,OAAO,SAAS,gBAAgB,UAAU,eAAe,OAAO,MAAM,sBAAsB,OAAO,UAAU,OAAO,GAAG,KAAK,GAAkB;AAC3L,QAAM,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAS,KAAK;AAC9C,QAAM,MAAM,SAAS,OAAO,KAAK;AACjC,QAAM,MAAM,MAAM,OAAyB,IAAI;AAG/C,QAAM,UAAU,MAAM;AACpB,QAAI,IAAI,QAAS,KAAI,QAAQ,gBAAgB,QAAQ,aAAa;AAAA,EACpE,CAAC;AACD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,cAAc,MAAM,SAAS,IAAI;AAAA,MACjC,cAAc,MAAM,SAAS,KAAK;AAAA,MAClC,OAAO,GAAG,EAAE,SAAS,QAAQ,KAAK,kBAAkB,YAAY,cAAc,QAAQ,WAAW,gBAAgB,WAAW,SAAS,WAAW,MAAM,GAAG,GAAG,MAAM,CAAC;AAAA,MAEnK;AAAA,4BAAC,UAAK,OAAO,GAAG,EAAE,UAAU,YAAY,SAAS,eAAe,MAAM,YAAY,WAAW,SAAS,OAAO,IAAI,EAAE,CAAC,GAClH;AAAA,UAAC;AAAA;AAAA,YACC;AAAA,YACA,MAAK;AAAA,YACL;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACC,GAAG;AAAA,YACJ,aAAW;AAAA,YACX,WAAU;AAAA,YACV,OAAO,GAAG;AAAA,cACR,YAAY;AAAA,cACZ,OAAO;AAAA,cACP,QAAQ;AAAA,cACR,QAAQ;AAAA,cACR,cAAc;AAAA,cACd,QAAQ,yCAAyC,QAAQ,6BAA6B,SAAS,CAAC,WAAW,wBAAwB;AAAA;AAAA;AAAA,cAGnI,iBAAiB;AAAA,cACjB,QAAQ;AAAA,cACR,YAAY;AAAA,YACd,CAAC;AAAA;AAAA,QACH,GACF;AAAA,QACA,qBAAC,UAAK,OAAO,GAAG,EAAE,SAAS,QAAQ,eAAe,UAAU,KAAK,EAAE,CAAC,GACjE;AAAA,mBAAS,oBAAC,UAAK,OAAO,GAAG,EAAE,YAAY,oBAAoB,UAAU,oBAAoB,OAAO,uBAAuB,YAAY,KAAK,CAAC,GAAI,iBAAM;AAAA,WAClJ,eAAe,SAAS,wBACxB;AAAA,YAAC;AAAA;AAAA,cACC,OAAO,GAAG;AAAA,gBACR,YAAY;AAAA,gBACZ,UAAU;AAAA,gBACV,OAAO,QAAQ,6BAA6B;AAAA,gBAC5C,YAAY;AAAA,gBACZ,WAAW,sBAAsB,gCAAgC;AAAA,cACnE,CAAC;AAAA,cAEA,mBAAS;AAAA;AAAA,UACZ;AAAA,WAEJ;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
@@ -28,6 +28,9 @@ interface DatePickerProps {
28
28
  * component. Default stays `'pt-BR'`.
29
29
  */
30
30
  locale?: 'pt-BR' | 'en';
31
+ /** Reserve the hint/error row's height even with neither set — stops the
32
+ * field from growing the moment a validation message appears. */
33
+ preserveHelperSpace?: boolean;
31
34
  }
32
35
  /**
33
36
  * Field for picking a single date — no time, no slots (`DateTimePicker`'s
@@ -43,6 +46,6 @@ interface DatePickerProps {
43
46
  * always uses it; `locale="en"` exists only for docs/demo purposes). A
44
47
  * clear (×) button appears once a value is set.
45
48
  */
46
- declare function DatePicker({ label, hint, error, required, placeholder, size, disabled, value, defaultValue, onChange, min, max, id, containerStyle, clearLabel, locale, }: DatePickerProps): React.JSX.Element;
49
+ declare function DatePicker({ label, hint, error, required, placeholder, size, disabled, value, defaultValue, onChange, min, max, id, containerStyle, clearLabel, locale, preserveHelperSpace, }: DatePickerProps): React.JSX.Element;
47
50
 
48
51
  export { DatePicker, type DatePickerProps };
@@ -2,10 +2,10 @@
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
4
  import { Calendar as CalendarIcon, X } from "lucide-react";
5
- import { sx } from "../_internal/style";
6
- import { Field } from "../_internal/Field";
7
- import { CalendarGrid } from "./_internal/CalendarGrid";
8
- import { fieldBoxStyle } from "./_internal/fieldBoxStyle";
5
+ import { sx } from "../_internal/style.js";
6
+ import { Field } from "../_internal/Field.js";
7
+ import { CalendarGrid } from "./_internal/CalendarGrid.js";
8
+ import { fieldBoxStyle } from "./_internal/fieldBoxStyle.js";
9
9
  const TEXT = {
10
10
  "pt-BR": { placeholder: "Selecionar data", dialogLabel: "Escolher data", clearLabel: "Limpar data" },
11
11
  en: { placeholder: "Pick a date", dialogLabel: "Choose a date", clearLabel: "Clear date" }
@@ -62,7 +62,8 @@ function DatePicker({
62
62
  id,
63
63
  containerStyle,
64
64
  clearLabel,
65
- locale = "pt-BR"
65
+ locale = "pt-BR",
66
+ preserveHelperSpace
66
67
  }) {
67
68
  const copy = TEXT[locale];
68
69
  const [inner, setInner] = React.useState(defaultValue ?? "");
@@ -115,7 +116,7 @@ function DatePicker({
115
116
  triggerRef.current?.focus();
116
117
  };
117
118
  const unavailable = React.useMemo(() => unavailableForMonth(viewYear, viewMonth, min, max), [viewYear, viewMonth, min, max]);
118
- return /* @__PURE__ */ jsx(Field, { label, hint, error, required, htmlFor: rid, style: containerStyle, children: /* @__PURE__ */ jsxs("div", { ref: rootRef, style: { position: "relative", width: "100%" }, children: [
119
+ return /* @__PURE__ */ jsx(Field, { label, hint, error, required, htmlFor: rid, style: containerStyle, preserveHelperSpace, children: /* @__PURE__ */ jsxs("div", { ref: rootRef, style: { position: "relative", width: "100%" }, children: [
119
120
  /* @__PURE__ */ jsxs("div", { style: fieldBoxStyle(size, !!error, open, disabled), children: [
120
121
  /* @__PURE__ */ jsxs(
121
122
  "button",
@@ -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 { 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\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}\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 function DatePicker({\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}: DatePickerProps) {\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 // 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}>\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 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"],"mappings":";AAyMU,SAuBE,KAvBF;AAvMV,YAAY,WAAW;AACvB,SAAS,YAAY,cAAc,SAAS;AAC5C,SAAS,UAAU;AACnB,SAAS,aAAa;AACtB,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;AAsCA,SAAS,SAAS,KAAqC;AACrD,MAAI,CAAC,IAAK,QAAO;AACjB,QAAM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V,KAAK;AAAA,UACL,MAAM;AAAA,UACN,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,UAKP,UAAU;AAAA,UACV,QAAQ;AAAA,UACR,YAAY;AAAA,UACZ,QAAQ;AAAA,UACR,cAAc;AAAA,UACd,WAAW;AAAA,UACX,SAAS;AAAA,UACT,SAAS;AAAA,QACX,CAAC;AAAA,QAED;AAAA,UAAC;AAAA;AAAA,YACC,MAAM;AAAA,YACN,OAAO;AAAA,YACP,cAAc,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;","names":[]}
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 { 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\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 function DatePicker({\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}: DatePickerProps) {\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 // 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 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"],"mappings":";AA6MU,SAuBE,KAvBF;AA3MV,YAAY,WAAW;AACvB,SAAS,YAAY,cAAc,SAAS;AAC5C,SAAS,UAAU;AACnB,SAAS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,YAAY;AAAA,YACZ,OAAO;AAAA,YACP,QAAQ;AAAA,UACV,CAAC;AAAA,UAED,8BAAC,KAAE,MAAM,IAAI,aAAa,GAAG;AAAA;AAAA,MAC/B;AAAA,OAEJ;AAAA,IAEC,QACC;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL,cAAY,SAAS,KAAK;AAAA,QAC1B,UAAU;AAAA,QACV,OAAO,GAAG;AAAA,UACR,UAAU;AAAA,UACV,KAAK;AAAA,UACL,MAAM;AAAA,UACN,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,UAKP,UAAU;AAAA,UACV,QAAQ;AAAA,UACR,YAAY;AAAA,UACZ,QAAQ;AAAA,UACR,cAAc;AAAA,UACd,WAAW;AAAA,UACX,SAAS;AAAA,UACT,SAAS;AAAA,QACX,CAAC;AAAA,QAED;AAAA,UAAC;AAAA;AAAA,YACC,MAAM;AAAA,YACN,OAAO;AAAA,YACP,cAAc,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;","names":[]}
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
- import { sx } from "../_internal/style";
4
- import { CalendarGrid } from "./_internal/CalendarGrid";
3
+ import { sx } from "../_internal/style.js";
4
+ import { CalendarGrid } from "./_internal/CalendarGrid.js";
5
5
  const TEXT = {
6
6
  "pt-BR": {
7
7
  timeLabel: "Hor\xE1rios dispon\xEDveis",
@@ -24,6 +24,9 @@ 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
28
+ * field from growing the moment a validation message appears. */
29
+ preserveHelperSpace?: boolean;
27
30
  }
28
31
  type FileUploadProps = BaseProps & ({
29
32
  multiple?: false;
@@ -2,8 +2,8 @@
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
4
  import { File as FileIcon, FileArchive, FileSpreadsheet, FileText, RefreshCw, Trash2, UploadCloud } from "lucide-react";
5
- import { sx } from "../_internal/style";
6
- import { Field } from "../_internal/Field";
5
+ import { sx } from "../_internal/style.js";
6
+ import { Field } from "../_internal/Field.js";
7
7
  function matchesAccept(file, accept) {
8
8
  if (!accept || accept === "*" || accept === "*/*") return true;
9
9
  const name = file.name.toLowerCase();
@@ -104,7 +104,8 @@ function FileUpload(props) {
104
104
  prompt,
105
105
  disabled,
106
106
  id,
107
- containerStyle
107
+ containerStyle,
108
+ preserveHelperSpace
108
109
  } = props;
109
110
  const multiple = props.multiple === true;
110
111
  const inputRef = React.useRef(null);
@@ -256,7 +257,7 @@ function FileUpload(props) {
256
257
  ]
257
258
  }
258
259
  );
259
- return /* @__PURE__ */ jsxs(Field, { label, hint, error: error || (multiple ? void 0 : rejected) || void 0, required, htmlFor: rid, style: containerStyle, children: [
260
+ return /* @__PURE__ */ jsxs(Field, { label, hint, error: error || (multiple ? void 0 : rejected) || void 0, required, htmlFor: rid, style: containerStyle, preserveHelperSpace, children: [
260
261
  /* @__PURE__ */ jsx(
261
262
  "input",
262
263
  {
@@ -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';\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}\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 function FileUpload(props: FileUploadProps) {\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 } = 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 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 {...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 {...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={error || (multiple ? undefined : rejected) || undefined} required={required} htmlFor={rid} style={containerStyle}>\n <input\n ref={inputRef}\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} 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\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":";AAsGQ,cAoJJ,YApJI;AApGR,YAAY,WAAW;AACvB,SAAS,QAAQ,UAAU,aAAa,iBAAiB,UAAU,WAAW,QAAQ,mBAAoC;AAC1H,SAAS,UAAU;AACnB,SAAS,aAAa;AAkCtB,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;AAC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;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":[]}
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';\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 function FileUpload(props: FileUploadProps) {\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 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 {...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 {...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={error || (multiple ? undefined : rejected) || undefined} required={required} htmlFor={rid} style={containerStyle} preserveHelperSpace={preserveHelperSpace}>\n <input\n ref={inputRef}\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} 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\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":";AAyGQ,cAqJJ,YArJI;AAvGR,YAAY,WAAW;AACvB,SAAS,QAAQ,UAAU,aAAa,iBAAiB,UAAU,WAAW,QAAQ,mBAAoC;AAC1H,SAAS,UAAU;AACnB,SAAS,aAAa;AAqCtB,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,K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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":[]}
@@ -29,7 +29,10 @@ 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
33
+ * field from growing the moment a validation message appears. */
34
+ preserveHelperSpace?: boolean;
32
35
  }
33
- declare function Input({ label, hint, error, required, size, iconLeft, prefix, suffix, disabled, id, style, containerStyle, mask, showCount, type, onChange, inputMode, maxLength, defaultValue, ...rest }: InputProps): React.JSX.Element;
36
+ declare function Input({ label, hint, error, required, size, iconLeft, prefix, suffix, disabled, id, style, containerStyle, mask, showCount, preserveHelperSpace, type, onChange, inputMode, maxLength, defaultValue, ...rest }: InputProps): React.JSX.Element;
34
37
 
35
38
  export { Input, type InputProps };
@@ -2,10 +2,10 @@
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
4
  import { Eye, EyeOff } from "lucide-react";
5
- import { sx } from "../_internal/style";
6
- import { Field } from "../_internal/Field";
7
- import { CharCount } from "../_internal/CharCount";
8
- import { formatMask, MASK_INPUTMODE, MASK_MAXLENGTH } from "../_internal/mask";
5
+ import { sx } from "../_internal/style.js";
6
+ import { Field } from "../_internal/Field.js";
7
+ import { CharCount } from "../_internal/CharCount.js";
8
+ import { formatMask, MASK_INPUTMODE, MASK_MAXLENGTH } from "../_internal/mask.js";
9
9
  const H = { sm: "var(--control-height-sm)", md: "var(--control-height-md)", lg: "var(--control-height-lg)" };
10
10
  function Input({
11
11
  label,
@@ -22,6 +22,7 @@ function Input({
22
22
  containerStyle,
23
23
  mask,
24
24
  showCount,
25
+ preserveHelperSpace,
25
26
  type,
26
27
  onChange,
27
28
  inputMode,
@@ -67,6 +68,7 @@ function Input({
67
68
  htmlFor: rid,
68
69
  style: containerStyle,
69
70
  counter: showCounter ? /* @__PURE__ */ jsx(CharCount, { count, max: maxLength ?? void 0 }) : void 0,
71
+ preserveHelperSpace,
70
72
  children: /* @__PURE__ */ jsxs(
71
73
  "div",
72
74
  {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/forms/Input.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Eye, EyeOff } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { Field } from '../_internal/Field';\nimport { CharCount } from '../_internal/CharCount';\nimport { formatMask, MASK_INPUTMODE, MASK_MAXLENGTH, type MaskName } from '../_internal/mask';\n\n/**\n * Single-line text field with label, hint and error states.\n */\nexport interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size' | 'prefix'> {\n label?: string;\n /** Helper text under the field. Replaced by `error` when present. */\n hint?: string;\n /** Error message; also turns the border red. */\n error?: string;\n required?: boolean;\n size?: 'sm' | 'md' | 'lg';\n iconLeft?: React.ReactNode;\n /** Leading text adornment (e.g. \"R$\", \"@\", \"+55\"). Not part of the value. */\n prefix?: React.ReactNode;\n /** Trailing text or control (e.g. \"min\", a clear button). Not part of the value. */\n suffix?: React.ReactNode;\n /**\n * Format the value as the user types. A preset (`phone` / `cpf` / `cep` /\n * `currency`) or a custom pattern where `#` is one digit (`(##) #####-####`).\n * Sets `inputMode` and `maxLength` unless you pass your own.\n */\n mask?: MaskName | string;\n /**\n * Show a `n / max` character counter on the hint row. Implied when `maxLength`\n * is set; pass `showCount` on its own for a bare count with no ceiling.\n */\n showCount?: boolean;\n containerStyle?: React.CSSProperties;\n}\n\nconst H = { sm: 'var(--control-height-sm)', md: 'var(--control-height-md)', lg: 'var(--control-height-lg)' } as const;\n\nexport function Input({\n label,\n hint,\n error,\n required,\n size = 'md',\n iconLeft,\n prefix,\n suffix,\n disabled,\n id,\n style,\n containerStyle,\n mask,\n showCount,\n type,\n onChange,\n inputMode,\n maxLength,\n defaultValue,\n ...rest\n}: InputProps) {\n const [focus, setFocus] = React.useState(false);\n const [reveal, setReveal] = React.useState(false);\n const inputRef = React.useRef<HTMLInputElement>(null);\n // SSR-stable id (the DS source used Math.random(), which breaks hydration).\n const autoId = React.useId();\n const rid = id || autoId;\n\n const isPassword = type === 'password';\n const showCounter = Boolean(showCount) || maxLength != null;\n\n const seed = mask && typeof defaultValue === 'string' ? formatMask(mask, defaultValue) : defaultValue;\n const [uncount, setUncount] = React.useState(() =>\n typeof seed === 'string' || typeof seed === 'number' ? String(seed).length : 0,\n );\n const count = rest.value !== undefined ? String(rest.value ?? '').length : uncount;\n\n const needsWrap = Boolean(mask) || showCounter;\n const handleChange = needsWrap\n ? (e: React.ChangeEvent<HTMLInputElement>) => {\n if (mask) {\n const formatted = formatMask(mask, e.currentTarget.value);\n if (formatted !== e.currentTarget.value) {\n const el = e.currentTarget;\n el.value = formatted;\n // keep the caret at the end — the natural spot while typing forward\n try {\n el.setSelectionRange(formatted.length, formatted.length);\n } catch {\n /* type doesn't support selection */\n }\n }\n }\n if (rest.value === undefined) setUncount(e.currentTarget.value.length);\n onChange?.(e);\n }\n : onChange;\n\n return (\n <Field\n label={label}\n hint={hint}\n error={error}\n required={required}\n htmlFor={rid}\n style={containerStyle}\n counter={showCounter ? <CharCount count={count} max={maxLength ?? undefined} /> : undefined}\n >\n <div\n style={sx({\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-2)',\n height: H[size] || H.md,\n padding: '0 var(--space-3)',\n borderRadius: 'var(--radius-control)',\n background: disabled ? 'var(--interactive-disabled-bg)' : 'var(--bg-surface)',\n border: 'var(--border-width-hairline) solid ' + (error ? 'var(--interactive-error)' : focus ? 'var(--border-focus)' : 'var(--border-default)'),\n boxShadow: focus ? (error ? 'none' : 'var(--focus-ring)') : 'none',\n transition: 'var(--transition-control)',\n })}\n >\n {iconLeft && <span style={sx({ display: 'flex', color: 'var(--text-muted)', flex: '0 0 auto' })}>{iconLeft}</span>}\n {prefix && (\n <span style={sx({ display: 'flex', alignItems: 'center', color: 'var(--text-muted)', fontSize: size === 'sm' ? 'var(--text-sm)' : 'var(--text-base)', lineHeight: 1.2, flex: '0 0 auto' })}>{prefix}</span>\n )}\n <input\n id={rid}\n ref={inputRef}\n type={isPassword && reveal ? 'text' : type}\n disabled={disabled}\n onFocus={() => setFocus(true)}\n onBlur={() => setFocus(false)}\n onChange={handleChange}\n inputMode={mask ? inputMode ?? MASK_INPUTMODE[mask] ?? 'numeric' : inputMode}\n maxLength={mask ? maxLength ?? MASK_MAXLENGTH[mask] : maxLength}\n defaultValue={mask && typeof defaultValue === 'string' ? formatMask(mask, defaultValue) : defaultValue}\n {...rest}\n style={sx({\n flex: 1,\n minWidth: 0,\n margin: 0,\n padding: 0, // reset the UA input padding — the row's own padding insets it\n border: 'none',\n outline: 'none',\n background: 'transparent',\n fontFamily: 'var(--font-body)',\n fontSize: size === 'sm' ? 'var(--text-sm)' : 'var(--text-base)',\n lineHeight: 1.2, // match the prefix/suffix line box so baselines align\n color: disabled ? 'var(--text-disabled)' : 'var(--text-primary)',\n ...style,\n })}\n />\n {isPassword ? (\n <button\n type=\"button\"\n className=\"ds-affix-btn\"\n aria-label={reveal ? 'Ocultar senha' : 'Mostrar senha'}\n aria-pressed={reveal}\n onClick={() => {\n setReveal((r) => !r);\n inputRef.current?.focus();\n }}\n >\n {reveal ? <EyeOff size={16} strokeWidth={1.75} /> : <Eye size={16} strokeWidth={1.75} />}\n </button>\n ) : (\n suffix && (\n <span style={sx({ display: 'flex', alignItems: 'center', color: 'var(--text-muted)', fontSize: size === 'sm' ? 'var(--text-sm)' : 'var(--text-base)', lineHeight: 1.2, flex: '0 0 auto' })}>{suffix}</span>\n )\n )}\n </div>\n </Field>\n );\n}\n"],"mappings":";AA4G6B,cAEvB,YAFuB;AA1G7B,YAAY,WAAW;AACvB,SAAS,KAAK,cAAc;AAC5B,SAAS,UAAU;AACnB,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,YAAY,gBAAgB,sBAAqC;AAgC1E,MAAM,IAAI,EAAE,IAAI,4BAA4B,IAAI,4BAA4B,IAAI,2BAA2B;AAEpG,SAAS,MAAM;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAe;AACb,QAAM,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAS,KAAK;AAC9C,QAAM,CAAC,QAAQ,SAAS,IAAI,MAAM,SAAS,KAAK;AAChD,QAAM,WAAW,MAAM,OAAyB,IAAI;AAEpD,QAAM,SAAS,MAAM,MAAM;AAC3B,QAAM,MAAM,MAAM;AAElB,QAAM,aAAa,SAAS;AAC5B,QAAM,cAAc,QAAQ,SAAS,KAAK,aAAa;AAEvD,QAAM,OAAO,QAAQ,OAAO,iB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AC,UAAO,MAAM,IAAI,aAAa,MAAM,IAAK,oBAAC,OAAI,MAAM,IAAI,aAAa,MAAM;AAAA;AAAA,YACxF,IAEA,UACE,oBAAC,UAAK,OAAO,GAAG,EAAE,SAAS,QAAQ,YAAY,UAAU,OAAO,qBAAqB,UAAU,SAAS,OAAO,mBAAmB,oBAAoB,YAAY,KAAK,MAAM,WAAW,CAAC,GAAI,kBAAO;AAAA;AAAA;AAAA,MAG1M;AAAA;AAAA,EACF;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/forms/Input.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Eye, EyeOff } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { Field } from '../_internal/Field';\nimport { CharCount } from '../_internal/CharCount';\nimport { formatMask, MASK_INPUTMODE, MASK_MAXLENGTH, type MaskName } from '../_internal/mask';\n\n/**\n * Single-line text field with label, hint and error states.\n */\nexport interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size' | 'prefix'> {\n label?: string;\n /** Helper text under the field. Replaced by `error` when present. */\n hint?: string;\n /** Error message; also turns the border red. */\n error?: string;\n required?: boolean;\n size?: 'sm' | 'md' | 'lg';\n iconLeft?: React.ReactNode;\n /** Leading text adornment (e.g. \"R$\", \"@\", \"+55\"). Not part of the value. */\n prefix?: React.ReactNode;\n /** Trailing text or control (e.g. \"min\", a clear button). Not part of the value. */\n suffix?: React.ReactNode;\n /**\n * Format the value as the user types. A preset (`phone` / `cpf` / `cep` /\n * `currency`) or a custom pattern where `#` is one digit (`(##) #####-####`).\n * Sets `inputMode` and `maxLength` unless you pass your own.\n */\n mask?: MaskName | string;\n /**\n * Show a `n / max` character counter on the hint row. Implied when `maxLength`\n * is set; pass `showCount` on its own for a bare count with no ceiling.\n */\n showCount?: boolean;\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\nconst H = { sm: 'var(--control-height-sm)', md: 'var(--control-height-md)', lg: 'var(--control-height-lg)' } as const;\n\nexport function Input({\n label,\n hint,\n error,\n required,\n size = 'md',\n iconLeft,\n prefix,\n suffix,\n disabled,\n id,\n style,\n containerStyle,\n mask,\n showCount,\n preserveHelperSpace,\n type,\n onChange,\n inputMode,\n maxLength,\n defaultValue,\n ...rest\n}: InputProps) {\n const [focus, setFocus] = React.useState(false);\n const [reveal, setReveal] = React.useState(false);\n const inputRef = React.useRef<HTMLInputElement>(null);\n // SSR-stable id (the DS source used Math.random(), which breaks hydration).\n const autoId = React.useId();\n const rid = id || autoId;\n\n const isPassword = type === 'password';\n const showCounter = Boolean(showCount) || maxLength != null;\n\n const seed = mask && typeof defaultValue === 'string' ? formatMask(mask, defaultValue) : defaultValue;\n const [uncount, setUncount] = React.useState(() =>\n typeof seed === 'string' || typeof seed === 'number' ? String(seed).length : 0,\n );\n const count = rest.value !== undefined ? String(rest.value ?? '').length : uncount;\n\n const needsWrap = Boolean(mask) || showCounter;\n const handleChange = needsWrap\n ? (e: React.ChangeEvent<HTMLInputElement>) => {\n if (mask) {\n const formatted = formatMask(mask, e.currentTarget.value);\n if (formatted !== e.currentTarget.value) {\n const el = e.currentTarget;\n el.value = formatted;\n // keep the caret at the end — the natural spot while typing forward\n try {\n el.setSelectionRange(formatted.length, formatted.length);\n } catch {\n /* type doesn't support selection */\n }\n }\n }\n if (rest.value === undefined) setUncount(e.currentTarget.value.length);\n onChange?.(e);\n }\n : onChange;\n\n return (\n <Field\n label={label}\n hint={hint}\n error={error}\n required={required}\n htmlFor={rid}\n style={containerStyle}\n counter={showCounter ? <CharCount count={count} max={maxLength ?? undefined} /> : undefined}\n preserveHelperSpace={preserveHelperSpace}\n >\n <div\n style={sx({\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-2)',\n height: H[size] || H.md,\n padding: '0 var(--space-3)',\n borderRadius: 'var(--radius-control)',\n background: disabled ? 'var(--interactive-disabled-bg)' : 'var(--bg-surface)',\n border: 'var(--border-width-hairline) solid ' + (error ? 'var(--interactive-error)' : focus ? 'var(--border-focus)' : 'var(--border-default)'),\n boxShadow: focus ? (error ? 'none' : 'var(--focus-ring)') : 'none',\n transition: 'var(--transition-control)',\n })}\n >\n {iconLeft && <span style={sx({ display: 'flex', color: 'var(--text-muted)', flex: '0 0 auto' })}>{iconLeft}</span>}\n {prefix && (\n <span style={sx({ display: 'flex', alignItems: 'center', color: 'var(--text-muted)', fontSize: size === 'sm' ? 'var(--text-sm)' : 'var(--text-base)', lineHeight: 1.2, flex: '0 0 auto' })}>{prefix}</span>\n )}\n <input\n id={rid}\n ref={inputRef}\n type={isPassword && reveal ? 'text' : type}\n disabled={disabled}\n onFocus={() => setFocus(true)}\n onBlur={() => setFocus(false)}\n onChange={handleChange}\n inputMode={mask ? inputMode ?? MASK_INPUTMODE[mask] ?? 'numeric' : inputMode}\n maxLength={mask ? maxLength ?? MASK_MAXLENGTH[mask] : maxLength}\n defaultValue={mask && typeof defaultValue === 'string' ? formatMask(mask, defaultValue) : defaultValue}\n {...rest}\n style={sx({\n flex: 1,\n minWidth: 0,\n margin: 0,\n padding: 0, // reset the UA input padding — the row's own padding insets it\n border: 'none',\n outline: 'none',\n background: 'transparent',\n fontFamily: 'var(--font-body)',\n fontSize: size === 'sm' ? 'var(--text-sm)' : 'var(--text-base)',\n lineHeight: 1.2, // match the prefix/suffix line box so baselines align\n color: disabled ? 'var(--text-disabled)' : 'var(--text-primary)',\n ...style,\n })}\n />\n {isPassword ? (\n <button\n type=\"button\"\n className=\"ds-affix-btn\"\n aria-label={reveal ? 'Ocultar senha' : 'Mostrar senha'}\n aria-pressed={reveal}\n onClick={() => {\n setReveal((r) => !r);\n inputRef.current?.focus();\n }}\n >\n {reveal ? <EyeOff size={16} strokeWidth={1.75} /> : <Eye size={16} strokeWidth={1.75} />}\n </button>\n ) : (\n suffix && (\n <span style={sx({ display: 'flex', alignItems: 'center', color: 'var(--text-muted)', fontSize: size === 'sm' ? 'var(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[]}
@@ -13,11 +13,19 @@ import * as React from 'react';
13
13
  */
14
14
  interface RadioProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'size'> {
15
15
  label?: string;
16
- /** Secondary line under the label. */
16
+ /** Secondary line under the label. Replaced by `error` when present. */
17
17
  description?: string;
18
+ /** Error message — tints the circle and the secondary line red. Replaces `description`. */
19
+ error?: string;
18
20
  /** Circle size. `sm` (16px) for dense lists; `md` (20px) everywhere else. Matches `Checkbox`. */
19
21
  size?: 'sm' | 'md';
22
+ /**
23
+ * Reserve the description/error row's height even with neither set — keeps
24
+ * the row stable as `error` comes and goes (SS-259, same mechanism as
25
+ * `Input`'s `preserveHelperSpace`). Off by default.
26
+ */
27
+ preserveHelperSpace?: boolean;
20
28
  }
21
- declare function Radio({ label, description, checked, defaultChecked, disabled, size, onChange, style, ...rest }: RadioProps): React.JSX.Element;
29
+ declare function Radio({ label, description, error, checked, defaultChecked, disabled, size, preserveHelperSpace, onChange, style, ...rest }: RadioProps): React.JSX.Element;
22
30
 
23
31
  export { Radio, type RadioProps };
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
- import { sx } from "../_internal/style";
5
- function Radio({ label, description, checked, defaultChecked, disabled, size = "md", onChange, style, ...rest }) {
4
+ import { sx } from "../_internal/style.js";
5
+ function Radio({ label, description, error, checked, defaultChecked, disabled, size = "md", preserveHelperSpace = false, onChange, style, ...rest }) {
6
6
  const [hover, setHover] = React.useState(false);
7
7
  const box = size === "sm" ? 16 : 20;
8
8
  return /* @__PURE__ */ jsxs(
@@ -29,7 +29,7 @@ function Radio({ label, description, checked, defaultChecked, disabled, size = "
29
29
  height: box,
30
30
  margin: 0,
31
31
  borderRadius: "var(--radius-pill)",
32
- border: "var(--border-width-emphasis) solid " + (hover && !disabled ? "var(--border-brand)" : "var(--border-strong)"),
32
+ border: "var(--border-width-emphasis) solid " + (error ? "var(--interactive-error)" : hover && !disabled ? "var(--border-brand)" : "var(--border-strong)"),
33
33
  backgroundColor: "var(--bg-surface)",
34
34
  cursor: "inherit",
35
35
  transition: "var(--transition-control)"
@@ -38,7 +38,19 @@ function Radio({ label, description, checked, defaultChecked, disabled, size = "
38
38
  ) }),
39
39
  /* @__PURE__ */ jsxs("span", { style: sx({ display: "flex", flexDirection: "column", gap: 2 }), children: [
40
40
  label && /* @__PURE__ */ jsx("span", { style: sx({ fontFamily: "var(--font-body)", fontSize: "var(--text-base)", color: "var(--text-primary)", lineHeight: 1.35 }), children: label }),
41
- description && /* @__PURE__ */ jsx("span", { style: sx({ fontFamily: "var(--font-body)", fontSize: "var(--text-xs)", color: "var(--text-muted)", lineHeight: 1.45 }), children: description })
41
+ (description || error || preserveHelperSpace) && /* @__PURE__ */ jsx(
42
+ "span",
43
+ {
44
+ style: sx({
45
+ fontFamily: "var(--font-body)",
46
+ fontSize: "var(--text-xs)",
47
+ color: error ? "var(--interactive-error)" : "var(--text-muted)",
48
+ lineHeight: 1.45,
49
+ minHeight: preserveHelperSpace ? "calc(var(--text-xs) * 1.45)" : void 0
50
+ }),
51
+ children: error || description
52
+ }
53
+ )
42
54
  ] })
43
55
  ]
44
56
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/forms/Radio.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\n\n/**\n * Single-choice control for mutually exclusive options (payment method, appointment format).\n * Group by giving every option the same `name`. Visually matched to `Checkbox` — same 20px\n * box, same hover and label/description rhythm — differing only in the pill radius and dot.\n * Host must include the `.sereno-radio:checked` rule (see globals.css).\n *\n * Wrap every group in a `<fieldset>` / `<legend>` — `name` alone makes the browser treat\n * the options as one native group (arrow keys move between them, only one can be checked),\n * but without a `<legend>` a screen reader has no accessible name for what the choice is\n * between, only \"Online, radio button, 1 of 3\" with no context.\n */\nexport interface RadioProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'size'> {\n label?: string;\n /** Secondary line under the label. */\n description?: string;\n /** Circle size. `sm` (16px) for dense lists; `md` (20px) everywhere else. Matches `Checkbox`. */\n size?: 'sm' | 'md';\n}\n\nexport function Radio({ label, description, checked, defaultChecked, disabled, size = 'md', onChange, style, ...rest }: RadioProps) {\n const [hover, setHover] = React.useState(false);\n const box = size === 'sm' ? 16 : 20;\n return (\n <label\n onMouseEnter={() => setHover(true)}\n onMouseLeave={() => setHover(false)}\n style={sx({ display: 'flex', gap: 'var(--space-3)', alignItems: 'flex-start', cursor: disabled ? 'not-allowed' : 'pointer', opacity: disabled ? 0.6 : 1, ...style })}\n >\n <span style={sx({ position: 'relative', display: 'inline-flex', flex: '0 0 auto', marginTop: size === 'sm' ? 3 : 1 })}>\n <input\n type=\"radio\"\n checked={checked}\n defaultChecked={defaultChecked}\n disabled={disabled}\n onChange={onChange}\n {...rest}\n data-size={size}\n className=\"sereno-radio\"\n style={sx({\n appearance: 'none',\n width: box,\n height: box,\n margin: 0,\n borderRadius: 'var(--radius-pill)',\n border: 'var(--border-width-emphasis) solid ' + (hover && !disabled ? 'var(--border-brand)' : 'var(--border-strong)'),\n backgroundColor: 'var(--bg-surface)',\n cursor: 'inherit',\n transition: 'var(--transition-control)',\n })}\n />\n </span>\n <span style={sx({ display: 'flex', flexDirection: 'column', gap: 2 })}>\n {label && <span style={sx({ fontFamily: 'var(--font-body)', fontSize: 'var(--text-base)', color: 'var(--text-primary)', lineHeight: 1.35 })}>{label}</span>}\n {description && (\n <span style={sx({ fontFamily: 'var(--font-body)', fontSize: 'var(--text-xs)', color: 'var(--text-muted)', lineHeight: 1.45 })}>{description}</span>\n )}\n </span>\n </label>\n );\n}"],"mappings":";AAkCQ,cAsBF,YAtBE;AAhCR,YAAY,WAAW;AACvB,SAAS,UAAU;AAqBZ,SAAS,MAAM,EAAE,OAAO,aAAa,SAAS,gBAAgB,UAAU,OAAO,MAAM,UAAU,OAAO,GAAG,KAAK,GAAe;AAClI,QAAM,CAAC,OAAO,QAAQ,IAA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io.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\n\n/**\n * Single-choice control for mutually exclusive options (payment method, appointment format).\n * Group by giving every option the same `name`. Visually matched to `Checkbox` — same 20px\n * box, same hover and label/description rhythm — differing only in the pill radius and dot.\n * Host must include the `.sereno-radio:checked` rule (see globals.css).\n *\n * Wrap every group in a `<fieldset>` / `<legend>` — `name` alone makes the browser treat\n * the options as one native group (arrow keys move between them, only one can be checked),\n * but without a `<legend>` a screen reader has no accessible name for what the choice is\n * between, only \"Online, radio button, 1 of 3\" with no context.\n */\nexport interface RadioProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'size'> {\n label?: string;\n /** Secondary line under the label. Replaced by `error` when present. */\n description?: string;\n /** Error message — tints the circle and the secondary line red. Replaces `description`. */\n error?: string;\n /** Circle size. `sm` (16px) for dense lists; `md` (20px) everywhere else. Matches `Checkbox`. */\n size?: 'sm' | 'md';\n /**\n * Reserve the description/error row's height even with neither set — keeps\n * the row stable as `error` comes and goes (SS-259, same mechanism as\n * `Input`'s `preserveHelperSpace`). Off by default.\n */\n preserveHelperSpace?: boolean;\n}\n\nexport function Radio({ label, description, error, checked, defaultChecked, disabled, size = 'md', preserveHelperSpace = false, onChange, style, ...rest }: RadioProps) {\n const [hover, setHover] = React.useState(false);\n const box = size === 'sm' ? 16 : 20;\n return (\n <label\n onMouseEnter={() => setHover(true)}\n onMouseLeave={() => setHover(false)}\n style={sx({ display: 'flex', gap: 'var(--space-3)', alignItems: 'flex-start', cursor: disabled ? 'not-allowed' : 'pointer', opacity: disabled ? 0.6 : 1, ...style })}\n >\n <span style={sx({ position: 'relative', display: 'inline-flex', flex: '0 0 auto', marginTop: size === 'sm' ? 3 : 1 })}>\n <input\n type=\"radio\"\n checked={checked}\n defaultChecked={defaultChecked}\n disabled={disabled}\n onChange={onChange}\n {...rest}\n data-size={size}\n className=\"sereno-radio\"\n style={sx({\n appearance: 'none',\n width: box,\n height: box,\n margin: 0,\n borderRadius: 'var(--radius-pill)',\n border: 'var(--border-width-emphasis) solid ' + (error ? 'var(--interactive-error)' : hover && !disabled ? 'var(--border-brand)' : 'var(--border-strong)'),\n backgroundColor: 'var(--bg-surface)',\n cursor: 'inherit',\n transition: 'var(--transition-control)',\n })}\n />\n </span>\n <span style={sx({ display: 'flex', flexDirection: 'column', gap: 2 })}>\n {label && <span style={sx({ fontFamily: 'var(--font-body)', fontSize: 'var(--text-base)', color: 'var(--text-primary)', lineHeight: 1.35 })}>{label}</span>}\n {(description || error || preserveHelperSpace) && (\n <span\n style={sx({\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-xs)',\n color: error ? 'var(--interactive-error)' : 'var(--text-muted)',\n lineHeight: 1.45,\n minHeight: preserveHelperSpace ? 'calc(var(--text-xs) * 1.45)' : undefined,\n })}\n >\n {error || description}\n </span>\n )}\n </span>\n </label>\n );\n}"],"mappings":";AA0CQ,cAsBF,YAtBE;AAxCR,YAAY,WAAW;AACvB,SAAS,UAAU;AA6BZ,SAAS,MAAM,EAAE,OAAO,aAAa,OAAO,SAAS,gBAAgB,UAAU,OAAO,MAAM,sBAAsB,OAAO,UAAU,OAAO,GAAG,KAAK,GAAe;AACtK,QAAM,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAS,KAAK;AAC9C,QAAM,MAAM,SAAS,OAAO,KAAK;AACjC,SACE;AAAA,IAAC;AAAA;AAAA,MACC,cAAc,MAAM,SAAS,IAAI;AAAA,MACjC,cAAc,MAAM,SAAS,KAAK;AAAA,MAClC,OAAO,GAAG,EAAE,SAAS,QAAQ,KAAK,kBAAkB,YAAY,cAAc,QAAQ,WAAW,gBAAgB,WAAW,SAAS,WAAW,MAAM,GAAG,GAAG,MAAM,CAAC;AAAA,MAEnK;AAAA,4BAAC,UAAK,OAAO,GAAG,EAAE,UAAU,YAAY,SAAS,eAAe,MAAM,YAAY,WAAW,SAAS,OAAO,IAAI,EAAE,CAAC,GAClH;AAAA,UAAC;AAAA;AAAA,YACC,MAAK;AAAA,YACL;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACC,GAAG;AAAA,YACJ,aAAW;AAAA,YACX,WAAU;AAAA,YACV,OAAO,GAAG;AAAA,cACR,YAAY;AAAA,cACZ,OAAO;AAAA,cACP,QAAQ;AAAA,cACR,QAAQ;AAAA,cACR,cAAc;AAAA,cACd,QAAQ,yCAAyC,QAAQ,6BAA6B,SAAS,CAAC,WAAW,wBAAwB;AAAA,cACnI,iBAAiB;AAAA,cACjB,QAAQ;AAAA,cACR,YAAY;AAAA,YACd,CAAC;AAAA;AAAA,QACH,GACF;AAAA,QACA,qBAAC,UAAK,OAAO,GAAG,EAAE,SAAS,QAAQ,eAAe,UAAU,KAAK,EAAE,CAAC,GACjE;AAAA,mBAAS,oBAAC,UAAK,OAAO,GAAG,EAAE,YAAY,oBAAoB,UAAU,oBAAoB,OAAO,uBAAuB,YAAY,KAAK,CAAC,GAAI,iBAAM;AAAA,WAClJ,eAAe,SAAS,wBACxB;AAAA,YAAC;AAAA;AAAA,cACC,OAAO,GAAG;AAAA,gBACR,YAAY;AAAA,gBACZ,UAAU;AAAA,gBACV,OAAO,QAAQ,6BAA6B;AAAA,gBAC5C,YAAY;AAAA,gBACZ,WAAW,sBAAsB,gCAAgC;AAAA,cACnE,CAAC;AAAA,cAEA,mBAAS;AAAA;AAAA,UACZ;AAAA,WAEJ;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
@@ -2,8 +2,8 @@
2
2
  import { jsx } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
4
  import { Search, X } from "lucide-react";
5
- import { sx } from "../_internal/style";
6
- import { Input } from "./Input";
5
+ import { sx } from "../_internal/style.js";
6
+ import { Input } from "./Input.js";
7
7
  function SearchInput({
8
8
  value,
9
9
  defaultValue,
@@ -43,7 +43,10 @@ interface SelectProps {
43
43
  * set — don't pass both.
44
44
  */
45
45
  'aria-label'?: string;
46
+ /** Reserve the hint/error row's height even with neither set — stops the
47
+ * field from growing the moment a validation message appears. */
48
+ preserveHelperSpace?: boolean;
46
49
  }
47
- declare function Select({ label, hint, error, required, options, placeholder, size, disabled, value: valueProp, defaultValue, onValueChange, name, id, containerStyle, 'aria-label': ariaLabel, }: SelectProps): React.JSX.Element;
50
+ declare function Select({ label, hint, error, required, options, placeholder, size, disabled, value: valueProp, defaultValue, onValueChange, name, id, containerStyle, 'aria-label': ariaLabel, preserveHelperSpace, }: SelectProps): React.JSX.Element;
48
51
 
49
52
  export { Select, type SelectOption, type SelectProps };