@sereno-ds/ui 0.29.1 → 0.30.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_internal/mergeRefs.d.ts +7 -0
- package/dist/_internal/mergeRefs.js +13 -0
- package/dist/_internal/mergeRefs.js.map +1 -0
- package/dist/forms/AvatarUpload.d.ts +1 -1
- package/dist/forms/AvatarUpload.js +6 -4
- package/dist/forms/AvatarUpload.js.map +1 -1
- package/dist/forms/Checkbox.d.ts +1 -1
- package/dist/forms/Checkbox.js +7 -5
- package/dist/forms/Checkbox.js.map +1 -1
- package/dist/forms/DatePicker.d.ts +14 -2
- package/dist/forms/DatePicker.js +5 -3
- package/dist/forms/DatePicker.js.map +1 -1
- package/dist/forms/DateTimePicker.d.ts +10 -1
- package/dist/forms/DateTimePicker.js +6 -3
- package/dist/forms/DateTimePicker.js.map +1 -1
- package/dist/forms/FileUpload.d.ts +1 -1
- package/dist/forms/FileUpload.js +5 -3
- package/dist/forms/FileUpload.js.map +1 -1
- package/dist/forms/Input.d.ts +1 -1
- package/dist/forms/Input.js +20 -8
- package/dist/forms/Input.js.map +1 -1
- package/dist/forms/Radio.d.ts +1 -1
- package/dist/forms/Radio.js +4 -2
- package/dist/forms/Radio.js.map +1 -1
- package/dist/forms/SearchInput.d.ts +1 -1
- package/dist/forms/SearchInput.js +4 -12
- package/dist/forms/SearchInput.js.map +1 -1
- package/dist/forms/Select.d.ts +11 -1
- package/dist/forms/Select.js +5 -4
- package/dist/forms/Select.js.map +1 -1
- package/dist/forms/Switch.d.ts +9 -1
- package/dist/forms/Switch.js +6 -3
- package/dist/forms/Switch.js.map +1 -1
- package/dist/forms/Textarea.d.ts +1 -1
- package/dist/forms/Textarea.js +16 -6
- package/dist/forms/Textarea.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/forms/DateTimePicker.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\nimport { CalendarGrid } from './_internal/CalendarGrid';\n\nconst TEXT = {\n 'pt-BR': {\n timeLabel: 'Horários disponíveis',\n full: 'Lotado',\n fullInline: 'lotado',\n available: 'Disponível',\n vagas: (booked: number, capacity: number) => `${booked} de ${capacity} vagas`,\n },\n en: {\n timeLabel: 'Available times',\n full: 'Full',\n fullInline: 'full',\n available: 'Available',\n vagas: (booked: number, capacity: number) => `${booked} of ${capacity} spots`,\n },\n} as const;\n\nexport interface TimeSlot {\n value: string;\n /** Hard-blocked — unclickable regardless of `capacity`/`booked`. */\n disabled?: boolean;\n /** Total spots this slot holds — a group session, a class. Omit for a\n * plain 1:1 slot with no capacity tracking (the original contract). */\n capacity?: number;\n /** How many are already booked into it. */\n booked?: number;\n}\n\n/**\n * Month calendar plus available time slots — the heart of the public booking flow.\n * Day names and month names render in pt-BR by default — the real Sereno\n * product always uses it; `locale=\"en\"` exists only for docs/demo purposes.\n *\n * The header navigates: ‹ / › step the month, and the centred title opens a\n * popover to jump straight to a month or year. `year` / `month` set the *initial*\n * view; the component then owns it. Pass `onMonthChange` to react to navigation\n * (e.g. fetch the new month's availability).\n *\n * The day grid uses roving tabindex (SS-228) — only one cell is ever in the\n * Tab order, so Tab enters/leaves it in one stop instead of one per day.\n * Arrow keys move by day/week and cross month boundaries on overflow;\n * Home/End move within the current week row; PageUp/PageDown step the\n * month. An `unavailable` day stays focusable (`aria-disabled`, not the\n * native `disabled` — a disabled button can't receive focus at all) so the\n * cursor can still land on it, just not select it.\n *\n * The calendar body itself (header + day grid) is `./_internal/CalendarGrid`\n * — shared with `DatePicker` (SS-243), which wraps the same grid in a\n * trigger+popover shell instead of this component's always-visible card.\n */\nexport interface DateTimePickerProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {\n /** Initial year. Defaults to the current year. */\n year?: number;\n /** Initial month, 0-indexed. Defaults to the current month. */\n month?: number;\n /** Selected day-of-month. The highlight only shows in the month it was picked\n * in — navigating away and back to a *different* month never re-highlights it. */\n selectedDate?: number;\n /**\n * Slot labels (\"09:00\") or `TimeSlot` objects. A slot with `capacity` set\n * shows \"booked/capacity\" and switches to a full/overbook-warning look\n * once reached (SS-64) — still pickable unless also `disabled`, since a\n * full slot and a *blocked* one are different things: the first is a\n * deliberate \"yes, overbook it\" the caller can still choose to allow.\n */\n times?: (string | TimeSlot)[];\n selectedTime?: string;\n /** Day numbers with no availability — struck through and unclickable. */\n unavailable?: number[];\n onSelectDate?: (day: number) => void;\n onSelectTime?: (time: string) => void;\n /** Fires whenever the visible month changes (arrows or the month/year popover). */\n onMonthChange?: (year: number, month: number) => void;\n /**\n * Extra content under each day number — a count badge, a dot, etc. Return\n * `null` for days with nothing to show. When set, every cell grows to keep the\n * grid even. It's the caller's job to scope this (e.g. future days only).\n */\n renderDay?: (day: number) => React.ReactNode;\n /** Defaults to the `locale`-appropriate label (\"Horários disponíveis\" / \"Available times\"). */\n timeLabel?: string;\n /**\n * The real Sereno product always renders pt-BR — this only exists so the\n * docs showcase can demo an English-speaking consumer without forking the\n * component. Default stays `'pt-BR'`.\n */\n locale?: 'pt-BR' | 'en';\n}\n\nexport function DateTimePicker({\n year,\n month,\n selectedDate,\n times = [],\n selectedTime,\n unavailable = [],\n onSelectDate,\n onSelectTime,\n onMonthChange,\n renderDay,\n timeLabel,\n locale = 'pt-BR',\n style,\n ...rest\n}: DateTimePickerProps) {\n const copy = TEXT[locale];\n const label = timeLabel ?? copy.timeLabel;\n // If any slot in the list tracks capacity, plain slots grow the same\n // two-line layout with a generic \"available\" filler instead of leaving a\n // shorter, blank-looking card next to its neighbors (SS-64 follow-up).\n const anyCapacity = times.some((s) => typeof s === 'object' && s.capacity !== undefined);\n return (\n <div\n {...rest}\n style={sx({\n position: 'relative',\n background: 'var(--bg-surface)',\n border: 'var(--border-width-hairline) solid var(--border-default)',\n borderRadius: 'var(--radius-card)',\n padding: 'var(--space-4)',\n boxShadow: 'var(--shadow-sm)',\n ...style,\n })}\n >\n <CalendarGrid\n year={year}\n month={month}\n selectedDate={selectedDate}\n unavailable={unavailable}\n onSelectDate={onSelectDate}\n onMonthChange={onMonthChange}\n renderDay={renderDay}\n locale={locale}\n />\n {times.length > 0 && (\n <div style={sx({ marginTop: 'var(--space-4)', paddingTop: 'var(--space-4)', borderTop: 'var(--border-width-hairline) solid var(--border-subtle)' })}>\n <div\n style={sx({\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-xs)',\n fontWeight: 'var(--weight-semibold)',\n color: 'var(--text-secondary)',\n letterSpacing: 'var(--tracking-caps)',\n textTransform: 'uppercase',\n marginBottom: 'var(--space-3)',\n })}\n >\n {label}\n </div>\n <div style={sx({ display: 'grid', gridTemplateColumns: 'repeat(auto-fill,minmax(76px,1fr))', gap: 'var(--space-2)' })}>\n {times.map((slot) => {\n const val = typeof slot === 'string' ? slot : slot.value;\n const dis = typeof slot === 'object' && slot.disabled;\n const capacity = typeof slot === 'object' ? slot.capacity : undefined;\n const booked = typeof slot === 'object' ? (slot.booked ?? 0) : 0;\n const hasOwnCapacity = capacity !== undefined;\n // Full ≠ blocked: a full slot is still pickable (a deliberate\n // overbook) unless the caller *also* set `disabled` — that's\n // the actual hard \"no\" (SS-64).\n const full = hasOwnCapacity && booked >= capacity;\n const sel = selectedTime === val;\n // A slot with no capacity of its own still grows the two-line\n // layout when a *sibling* slot tracks capacity, so the row\n // reads consistently instead of one short card among tall ones.\n const showSecondLine = hasOwnCapacity || anyCapacity;\n const secondLine = hasOwnCapacity ? (full ? copy.full : copy.vagas(booked, capacity)) : copy.available;\n return (\n <button\n key={val}\n type=\"button\"\n disabled={dis}\n aria-label={hasOwnCapacity ? `${val} — ${full ? copy.fullInline + ', ' : ''}${copy.vagas(booked, capacity)}` : undefined}\n onClick={() => onSelectTime && onSelectTime(val)}\n className=\"sereno-dtp-time\"\n style={sx({\n height: showSecondLine ? 'auto' : 'var(--control-height-md)',\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 2,\n padding: showSecondLine ? 'var(--space-2) 0' : 0,\n borderRadius: 'var(--radius-control)',\n cursor: dis ? 'not-allowed' : 'pointer',\n border:\n 'var(--border-width-hairline) solid ' +\n (sel ? 'transparent' : full && !dis ? 'var(--interactive-warning)' : 'var(--border-default)'),\n background: sel\n ? 'var(--interactive-accent)'\n : dis\n ? 'var(--interactive-disabled-bg)'\n : full\n ? 'var(--status-warning-bg)'\n : 'var(--bg-surface)',\n color: sel\n ? 'var(--interactive-accent-fg)'\n : dis\n ? 'var(--interactive-disabled-fg)'\n : full\n ? 'var(--status-warning-fg)'\n : 'var(--text-primary)',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n fontWeight: 'var(--weight-semibold)',\n transition: 'var(--transition-control)',\n // Not inline outline:none — see .sereno-dtp-time in styles.css.\n })}\n >\n <span aria-hidden={hasOwnCapacity}>{val}</span>\n {showSecondLine && (\n <span\n aria-hidden={hasOwnCapacity}\n style={sx({\n fontSize: 'var(--text-2xs)',\n fontWeight: 'var(--weight-medium)',\n color: sel ? 'inherit' : full ? 'var(--status-warning-fg)' : 'var(--text-muted)',\n opacity: sel ? 0.85 : 1,\n })}\n >\n {secondLine}\n </span>\n )}\n </button>\n );\n })}\n </div>\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";AAkIM,cA2CU,YA3CV;AA/HN,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAE7B,MAAM,OAAO;AAAA,EACX,SAAS;AAAA,IACP,WAAW;AAAA,IACX,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,OAAO,CAAC,QAAgB,aAAqB,GAAG,MAAM,OAAO,QAAQ;AAAA,EACvE;AAAA,EACA,IAAI;AAAA,IACF,WAAW;AAAA,IACX,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,OAAO,CAAC,QAAgB,aAAqB,GAAG,M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AAAA;AAAA,sBACC,eAAa;AAAA,sBACb,OAAO,GAAG;AAAA,wBACR,UAAU;AAAA,wBACV,YAAY;AAAA,wBACZ,OAAO,MAAM,YAAY,OAAO,6BAA6B;AAAA,wBAC7D,SAAS,MAAM,OAAO;AAAA,sBACxB,CAAC;AAAA,sBAEA;AAAA;AAAA,kBACH;AAAA;AAAA;AAAA,cApDG;AAAA,YAsDP;AAAA,UAEJ,CAAC,GACH;AAAA,WACF;AAAA;AAAA;AAAA,EAEJ;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/forms/DateTimePicker.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\nimport { CalendarGrid } from './_internal/CalendarGrid';\n\nconst TEXT = {\n 'pt-BR': {\n timeLabel: 'Horários disponíveis',\n full: 'Lotado',\n fullInline: 'lotado',\n available: 'Disponível',\n vagas: (booked: number, capacity: number) => `${booked} de ${capacity} vagas`,\n },\n en: {\n timeLabel: 'Available times',\n full: 'Full',\n fullInline: 'full',\n available: 'Available',\n vagas: (booked: number, capacity: number) => `${booked} of ${capacity} spots`,\n },\n} as const;\n\nexport interface TimeSlot {\n value: string;\n /** Hard-blocked — unclickable regardless of `capacity`/`booked`. */\n disabled?: boolean;\n /** Total spots this slot holds — a group session, a class. Omit for a\n * plain 1:1 slot with no capacity tracking (the original contract). */\n capacity?: number;\n /** How many are already booked into it. */\n booked?: number;\n}\n\n/**\n * Month calendar plus available time slots — the heart of the public booking flow.\n * Day names and month names render in pt-BR by default — the real Sereno\n * product always uses it; `locale=\"en\"` exists only for docs/demo purposes.\n *\n * The header navigates: ‹ / › step the month, and the centred title opens a\n * popover to jump straight to a month or year. `year` / `month` set the *initial*\n * view; the component then owns it. Pass `onMonthChange` to react to navigation\n * (e.g. fetch the new month's availability).\n *\n * The day grid uses roving tabindex (SS-228) — only one cell is ever in the\n * Tab order, so Tab enters/leaves it in one stop instead of one per day.\n * Arrow keys move by day/week and cross month boundaries on overflow;\n * Home/End move within the current week row; PageUp/PageDown step the\n * month. An `unavailable` day stays focusable (`aria-disabled`, not the\n * native `disabled` — a disabled button can't receive focus at all) so the\n * cursor can still land on it, just not select it.\n *\n * The calendar body itself (header + day grid) is `./_internal/CalendarGrid`\n * — shared with `DatePicker` (SS-243), which wraps the same grid in a\n * trigger+popover shell instead of this component's always-visible card.\n */\nexport interface DateTimePickerProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {\n /** Initial year. Defaults to the current year. */\n year?: number;\n /** Initial month, 0-indexed. Defaults to the current month. */\n month?: number;\n /** Selected day-of-month. The highlight only shows in the month it was picked\n * in — navigating away and back to a *different* month never re-highlights it. */\n selectedDate?: number;\n /**\n * Slot labels (\"09:00\") or `TimeSlot` objects. A slot with `capacity` set\n * shows \"booked/capacity\" and switches to a full/overbook-warning look\n * once reached (SS-64) — still pickable unless also `disabled`, since a\n * full slot and a *blocked* one are different things: the first is a\n * deliberate \"yes, overbook it\" the caller can still choose to allow.\n */\n times?: (string | TimeSlot)[];\n selectedTime?: string;\n /** Day numbers with no availability — struck through and unclickable. */\n unavailable?: number[];\n onSelectDate?: (day: number) => void;\n onSelectTime?: (time: string) => void;\n /** Fires whenever the visible month changes (arrows or the month/year popover). */\n onMonthChange?: (year: number, month: number) => void;\n /**\n * Extra content under each day number — a count badge, a dot, etc. Return\n * `null` for days with nothing to show. When set, every cell grows to keep the\n * grid even. It's the caller's job to scope this (e.g. future days only).\n */\n renderDay?: (day: number) => React.ReactNode;\n /** Defaults to the `locale`-appropriate label (\"Horários disponíveis\" / \"Available times\"). */\n timeLabel?: string;\n /**\n * The real Sereno product always renders pt-BR — this only exists so the\n * docs showcase can demo an English-speaking consumer without forking the\n * component. Default stays `'pt-BR'`.\n */\n locale?: 'pt-BR' | 'en';\n}\n\n/**\n * `ref` reaches the root `<div>` — plain DOM access (measuring, scrolling\n * into view), not a form value. This isn't a single-value field: the day and\n * the time are two separate, parent-owned selections (`selectedDate` /\n * `selectedTime` + their own `onSelectDate` / `onSelectTime` callbacks), so\n * there's no one \"value\" for `react-hook-form` to register. Register the\n * date and the time as two separate fields at the call site instead (see\n * `DatePicker` for a single-value date field with the same calendar).\n */\nexport const DateTimePicker = React.forwardRef<HTMLDivElement, DateTimePickerProps>(function DateTimePicker(\n {\n year,\n month,\n selectedDate,\n times = [],\n selectedTime,\n unavailable = [],\n onSelectDate,\n onSelectTime,\n onMonthChange,\n renderDay,\n timeLabel,\n locale = 'pt-BR',\n style,\n ...rest\n },\n ref,\n) {\n const copy = TEXT[locale];\n const label = timeLabel ?? copy.timeLabel;\n // If any slot in the list tracks capacity, plain slots grow the same\n // two-line layout with a generic \"available\" filler instead of leaving a\n // shorter, blank-looking card next to its neighbors (SS-64 follow-up).\n const anyCapacity = times.some((s) => typeof s === 'object' && s.capacity !== undefined);\n return (\n <div\n ref={ref}\n {...rest}\n style={sx({\n position: 'relative',\n background: 'var(--bg-surface)',\n border: 'var(--border-width-hairline) solid var(--border-default)',\n borderRadius: 'var(--radius-card)',\n padding: 'var(--space-4)',\n boxShadow: 'var(--shadow-sm)',\n ...style,\n })}\n >\n <CalendarGrid\n year={year}\n month={month}\n selectedDate={selectedDate}\n unavailable={unavailable}\n onSelectDate={onSelectDate}\n onMonthChange={onMonthChange}\n renderDay={renderDay}\n locale={locale}\n />\n {times.length > 0 && (\n <div style={sx({ marginTop: 'var(--space-4)', paddingTop: 'var(--space-4)', borderTop: 'var(--border-width-hairline) solid var(--border-subtle)' })}>\n <div\n style={sx({\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-xs)',\n fontWeight: 'var(--weight-semibold)',\n color: 'var(--text-secondary)',\n letterSpacing: 'var(--tracking-caps)',\n textTransform: 'uppercase',\n marginBottom: 'var(--space-3)',\n })}\n >\n {label}\n </div>\n <div style={sx({ display: 'grid', gridTemplateColumns: 'repeat(auto-fill,minmax(76px,1fr))', gap: 'var(--space-2)' })}>\n {times.map((slot) => {\n const val = typeof slot === 'string' ? slot : slot.value;\n const dis = typeof slot === 'object' && slot.disabled;\n const capacity = typeof slot === 'object' ? slot.capacity : undefined;\n const booked = typeof slot === 'object' ? (slot.booked ?? 0) : 0;\n const hasOwnCapacity = capacity !== undefined;\n // Full ≠ blocked: a full slot is still pickable (a deliberate\n // overbook) unless the caller *also* set `disabled` — that's\n // the actual hard \"no\" (SS-64).\n const full = hasOwnCapacity && booked >= capacity;\n const sel = selectedTime === val;\n // A slot with no capacity of its own still grows the two-line\n // layout when a *sibling* slot tracks capacity, so the row\n // reads consistently instead of one short card among tall ones.\n const showSecondLine = hasOwnCapacity || anyCapacity;\n const secondLine = hasOwnCapacity ? (full ? copy.full : copy.vagas(booked, capacity)) : copy.available;\n return (\n <button\n key={val}\n type=\"button\"\n disabled={dis}\n aria-label={hasOwnCapacity ? `${val} — ${full ? copy.fullInline + ', ' : ''}${copy.vagas(booked, capacity)}` : undefined}\n onClick={() => onSelectTime && onSelectTime(val)}\n className=\"sereno-dtp-time\"\n style={sx({\n height: showSecondLine ? 'auto' : 'var(--control-height-md)',\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 2,\n padding: showSecondLine ? 'var(--space-2) 0' : 0,\n borderRadius: 'var(--radius-control)',\n cursor: dis ? 'not-allowed' : 'pointer',\n border:\n 'var(--border-width-hairline) solid ' +\n (sel ? 'transparent' : full && !dis ? 'var(--interactive-warning)' : 'var(--border-default)'),\n background: sel\n ? 'var(--interactive-accent)'\n : dis\n ? 'var(--interactive-disabled-bg)'\n : full\n ? 'var(--status-warning-bg)'\n : 'var(--bg-surface)',\n color: sel\n ? 'var(--interactive-accent-fg)'\n : dis\n ? 'var(--interactive-disabled-fg)'\n : full\n ? 'var(--status-warning-fg)'\n : 'var(--text-primary)',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n fontWeight: 'var(--weight-semibold)',\n transition: 'var(--transition-control)',\n // Not inline outline:none — see .sereno-dtp-time in styles.css.\n })}\n >\n <span aria-hidden={hasOwnCapacity}>{val}</span>\n {showSecondLine && (\n <span\n aria-hidden={hasOwnCapacity}\n style={sx({\n fontSize: 'var(--text-2xs)',\n fontWeight: 'var(--weight-medium)',\n color: sel ? 'inherit' : full ? 'var(--status-warning-fg)' : 'var(--text-muted)',\n opacity: sel ? 0.85 : 1,\n })}\n >\n {secondLine}\n </span>\n )}\n </button>\n );\n })}\n </div>\n </div>\n )}\n </div>\n );\n});\n\nDateTimePicker.displayName = 'DateTimePicker';\n"],"mappings":";AA+IM,cA2CU,YA3CV;AA7IN,YAAY,WAAW;AACvB,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAE7B,MAAM,OAAO;AAAA,EACX,SAAS;AAAA,IACP,WAAW;AAAA,IACX,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,OAAO,CAAC,QAAgB,aAAqB,GAAG,MAAM,OAAO,QAAQ;AAAA,EACvE;AAAA,EACA,IAAI;AAAA,IACF,WAAW;AAAA,IACX,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,OAAO,CAAC,QAAgB,aAAqB,GAAG,MAAM,OAAO,QAAQ;AAAA,EACvE;AACF;AAmFO,MAAM,iBAAiB,MAAM,WAAgD,SAASA,gBAC3F;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ,CAAC;AAAA,EACT;AAAA,EACA,cAAc,CAAC;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT;AAAA,EACA,GAAG;AACL,GACA,KACA;AACA,QAAM,OAAO,KAAK,MAAM;AACxB,QAAM,QAAQ,aAAa,KAAK;AAIhC,QAAM,cAAc,MAAM,KAAK,CAAC,MAAM,OAAO,MAAM,YAAY,EAAE,aAAa,MAAS;AACvF,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACC,GAAG;AAAA,MACJ,OAAO,GAAG;AAAA,QACR,UAAU;AAA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AAM,OAAO,KAAK,aAAa,OAAO,EAAE,GAAG,KAAK,MAAM,QAAQ,QAAQ,CAAC,KAAK;AAAA,gBAC/G,SAAS,MAAM,gBAAgB,aAAa,GAAG;AAAA,gBAC/C,WAAU;AAAA,gBACV,OAAO,GAAG;AAAA,kBACR,QAAQ,iBAAiB,SAAS;AAAA,kBAClC,SAAS;AAAA,kBACT,eAAe;AAAA,kBACf,YAAY;AAAA,kBACZ,gBAAgB;AAAA,kBAChB,KAAK;AAAA,kBACL,SAAS,iBAAiB,qBAAqB;AAAA,kBAC/C,cAAc;AAAA,kBACd,QAAQ,MAAM,gBAAgB;AAAA,kBAC9B,QACE,yCACC,MAAM,gBAAgB,QAAQ,CAAC,MAAM,+BAA+B;AAAA,kBACvE,YAAY,MACR,8BACA,MACE,mCACA,OACE,6BACA;AAAA,kBACR,OAAO,MACH,iCACA,MACE,mCACA,OACE,6BACA;AAAA,kBACR,YAAY;AAAA,kBACZ,UAAU;AAAA,kBACV,YAAY;AAAA,kBACZ,YAAY;AAAA;AAAA,gBAEd,CAAC;AAAA,gBAED;AAAA,sCAAC,UAAK,eAAa,gBAAiB,eAAI;AAAA,kBACvC,kBACC;AAAA,oBAAC;AAAA;AAAA,sBACC,eAAa;AAAA,sBACb,OAAO,GAAG;AAAA,wBACR,UAAU;AAAA,wBACV,YAAY;AAAA,wBACZ,OAAO,MAAM,YAAY,OAAO,6BAA6B;AAAA,wBAC7D,SAAS,MAAM,OAAO;AAAA,sBACxB,CAAC;AAAA,sBAEA;AAAA;AAAA,kBACH;AAAA;AAAA;AAAA,cApDG;AAAA,YAsDP;AAAA,UAEJ,CAAC,GACH;AAAA,WACF;AAAA;AAAA;AAAA,EAEJ;AAEJ,CAAC;AAED,eAAe,cAAc;","names":["DateTimePicker"]}
|
|
@@ -37,6 +37,6 @@ type FileUploadProps = BaseProps & ({
|
|
|
37
37
|
value?: File[];
|
|
38
38
|
onChange?: (files: File[]) => void;
|
|
39
39
|
});
|
|
40
|
-
declare
|
|
40
|
+
declare const FileUpload: React.ForwardRefExoticComponent<FileUploadProps & React.RefAttributes<HTMLInputElement>>;
|
|
41
41
|
|
|
42
42
|
export { FileUpload, type FileUploadProps };
|
package/dist/forms/FileUpload.js
CHANGED
|
@@ -4,6 +4,7 @@ import * as React from "react";
|
|
|
4
4
|
import { File as FileIcon, FileArchive, FileSpreadsheet, FileText, RefreshCw, Trash2, UploadCloud } from "lucide-react";
|
|
5
5
|
import { sx } from "../_internal/style.js";
|
|
6
6
|
import { Field } from "../_internal/Field.js";
|
|
7
|
+
import { mergeRefs } from "../_internal/mergeRefs.js";
|
|
7
8
|
function matchesAccept(file, accept) {
|
|
8
9
|
if (!accept || accept === "*" || accept === "*/*") return true;
|
|
9
10
|
const name = file.name.toLowerCase();
|
|
@@ -92,7 +93,7 @@ function usePreviewUrl(file) {
|
|
|
92
93
|
function fileKey(f) {
|
|
93
94
|
return `${f.name}:${f.size}:${f.lastModified}`;
|
|
94
95
|
}
|
|
95
|
-
|
|
96
|
+
const FileUpload = React.forwardRef(function FileUpload2(props, forwardedRef) {
|
|
96
97
|
const {
|
|
97
98
|
label,
|
|
98
99
|
hint,
|
|
@@ -261,7 +262,7 @@ function FileUpload(props) {
|
|
|
261
262
|
/* @__PURE__ */ jsx(
|
|
262
263
|
"input",
|
|
263
264
|
{
|
|
264
|
-
ref: inputRef,
|
|
265
|
+
ref: mergeRefs(inputRef, forwardedRef),
|
|
265
266
|
id: rid,
|
|
266
267
|
type: "file",
|
|
267
268
|
accept,
|
|
@@ -307,7 +308,8 @@ function FileUpload(props) {
|
|
|
307
308
|
] })
|
|
308
309
|
] }) : shape === "circle" ? circleZone : boxZone
|
|
309
310
|
] });
|
|
310
|
-
}
|
|
311
|
+
});
|
|
312
|
+
FileUpload.displayName = "FileUpload";
|
|
311
313
|
function MultiRow({ file, disabled, onRemove }) {
|
|
312
314
|
const url = usePreviewUrl(file);
|
|
313
315
|
return /* @__PURE__ */ jsxs(
|
|
@@ -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 /** 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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/forms/FileUpload.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { File as FileIcon, FileArchive, FileSpreadsheet, FileText, RefreshCw, Trash2, UploadCloud, type LucideIcon } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { Field } from '../_internal/Field';\nimport { mergeRefs } from '../_internal/mergeRefs';\n\n/**\n * Pick files — click, keyboard, or drag-and-drop — with a local preview.\n * Image-first (`shape` circle/square thumbnail); other types show an extension\n * chip. No upload happens here: `onChange` hands you the `File`(s); the preview\n * is local. Set `multiple` for a list; `value` then is `File[]`.\n */\ninterface BaseProps {\n label?: string;\n /** Helper text under the field — a good place for the accepted types / size. */\n hint?: string;\n /** Error message; also shown instead of a rejected-file message. */\n error?: string;\n required?: boolean;\n /** `accept` attribute, also enforced on drop. */\n accept?: string;\n /** Max size in MB — files above this are rejected with a message. */\n maxSizeMB?: number;\n /** Thumbnail shape for image previews. `circle` for avatars (single only). */\n shape?: 'circle' | 'square';\n /** Prompt inside the empty drop area. */\n prompt?: string;\n disabled?: boolean;\n id?: string;\n containerStyle?: React.CSSProperties;\n /** Reserve the hint/error row's height even with neither set — stops the\n * field from growing the moment a validation message appears. */\n preserveHelperSpace?: boolean;\n}\n\nexport type FileUploadProps = BaseProps &\n (\n | { multiple?: false; value?: File | string | null; onChange?: (file: File | null) => void }\n | { multiple: true; value?: File[]; onChange?: (files: File[]) => void }\n );\n\nfunction matchesAccept(file: File, accept: string): boolean {\n if (!accept || accept === '*' || accept === '*/*') return true;\n const name = file.name.toLowerCase();\n const type = file.type.toLowerCase();\n return accept\n .split(',')\n .map((t) => t.trim().toLowerCase())\n .some((tok) => {\n if (!tok) return false;\n if (tok.startsWith('.')) return name.endsWith(tok);\n if (tok.endsWith('/*')) return type.startsWith(tok.slice(0, -1));\n return type === tok;\n });\n}\n\nfunction fmtSize(bytes: number): string {\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${Math.round(bytes / 1024)} KB`;\n return `${(bytes / 1048576).toFixed(1)} MB`;\n}\n\n/** File-type glyph + colour, keyed by extension. Images never reach this. */\nconst GLYPHS: Record<string, { Icon: LucideIcon; color: string }> = {\n pdf: { Icon: FileText, color: 'var(--status-error-fg)' },\n doc: { Icon: FileText, color: 'var(--status-info-fg)' },\n docx: { Icon: FileText, color: 'var(--status-info-fg)' },\n rtf: { Icon: FileText, color: 'var(--status-info-fg)' },\n odt: { Icon: FileText, color: 'var(--status-info-fg)' },\n txt: { Icon: FileText, color: 'var(--status-neutral-fg)' },\n md: { Icon: FileText, color: 'var(--status-neutral-fg)' },\n csv: { Icon: FileSpreadsheet, color: 'var(--status-success-fg)' },\n xls: { Icon: FileSpreadsheet, color: 'var(--status-success-fg)' },\n xlsx: { Icon: FileSpreadsheet, color: 'var(--status-success-fg)' },\n ppt: { Icon: FileText, color: 'var(--status-warning-fg)' },\n pptx: { Icon: FileText, color: 'var(--status-warning-fg)' },\n zip: { Icon: FileArchive, color: 'var(--status-warning-fg)' },\n rar: { Icon: FileArchive, color: 'var(--status-warning-fg)' },\n '7z': { Icon: FileArchive, color: 'var(--status-warning-fg)' },\n};\nfunction glyphFor(name: string) {\n return GLYPHS[(name.split('.').pop() || '').toLowerCase()] ?? { Icon: FileIcon, color: 'var(--status-neutral-fg)' };\n}\n\n/** One thumbnail — the image itself, or a colour-coded file-type glyph. */\nfunction Thumb({ url, name, size, shape }: { url: string | null; name: string; size: number; shape: 'circle' | 'square' }) {\n const { Icon, color } = glyphFor(name);\n return (\n <span\n style={sx({\n width: size,\n height: size,\n flex: '0 0 auto',\n borderRadius: shape === 'circle' ? '999px' : 'var(--radius-md)',\n overflow: 'hidden',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n background: url ? 'var(--bg-subtle)' : `color-mix(in srgb, ${color} 12%, var(--bg-surface))`,\n border: '1px solid ' + (url ? 'var(--border-subtle)' : `color-mix(in srgb, ${color} 28%, transparent)`),\n })}\n >\n {url ? (\n // eslint-disable-next-line @next/next/no-img-element\n <img src={url} alt={name} style={sx({ width: '100%', height: '100%', objectFit: 'cover' })} />\n ) : (\n <Icon size={Math.round(size * 0.44)} strokeWidth={1.75} style={{ color }} />\n )}\n </span>\n );\n}\n\nconst actionBtn = {\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 6,\n minHeight: 36,\n padding: '0 12px',\n borderRadius: 'var(--radius-control)',\n border: '1px solid var(--border-default)',\n background: 'var(--bg-surface)',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n fontWeight: 'var(--weight-medium)',\n cursor: 'pointer',\n} as const;\n\n/**\n * A preview URL for a File (object URL) or an existing URL string. The object\n * URL is created *and* revoked inside one effect, so a re-render (or StrictMode's\n * mount/cleanup/mount) never leaves a revoked URL on screen.\n */\nfunction usePreviewUrl(file: File | string | null | undefined): string | null {\n const [url, setUrl] = React.useState<string | null>(typeof file === 'string' ? file : null);\n React.useEffect(() => {\n const isImageFile = file instanceof File && file.type.startsWith('image/');\n const next = isImageFile ? URL.createObjectURL(file) : typeof file === 'string' ? file : null;\n // eslint-disable-next-line react-hooks/set-state-in-effect -- syncing to an external resource (object URL)\n setUrl(next);\n return isImageFile ? () => URL.revokeObjectURL(next as string) : undefined;\n }, [file]);\n return url;\n}\n\n/** A stable-ish key for a File across list reorders. */\nfunction fileKey(f: File): string {\n return `${f.name}:${f.size}:${f.lastModified}`;\n}\n\nexport const FileUpload = React.forwardRef<HTMLInputElement, FileUploadProps>(function FileUpload(props, forwardedRef) {\n const {\n label,\n hint,\n error,\n required,\n accept = 'image/*',\n maxSizeMB = 5,\n shape = 'square',\n prompt,\n disabled,\n id,\n containerStyle,\n preserveHelperSpace,\n } = props;\n const multiple = props.multiple === true;\n\n const inputRef = React.useRef<HTMLInputElement>(null);\n const autoId = React.useId();\n const rid = id || autoId;\n const [rejected, setRejected] = React.useState<string | null>(null);\n const [dragOver, setDragOver] = React.useState(false);\n\n // Uncontrolled fallback — one shape covers both modes internally.\n const [internalOne, setInternalOne] = React.useState<File | null>(null);\n const [internalMany, setInternalMany] = React.useState<File[]>([]);\n const one = props.multiple ? null : props.value !== undefined ? props.value : internalOne;\n const many = props.multiple ? (props.value !== undefined ? props.value : internalMany) : [];\n\n const validate = (f: File): string | null => {\n if (!matchesAccept(f, accept)) return `“${f.name}” isn’t an accepted type.`;\n if (f.size > maxSizeMB * 1048576) return `“${f.name}” is over ${maxSizeMB} MB.`;\n return null;\n };\n\n const ingest = (list: FileList | null) => {\n const files = list ? Array.from(list) : [];\n if (!files.length) return;\n if (multiple) {\n const ok: File[] = [];\n const bad: string[] = [];\n for (const f of files) {\n const err = validate(f);\n if (err) bad.push(f.name);\n else ok.push(f);\n }\n setRejected(bad.length ? `Skipped ${bad.length} file${bad.length > 1 ? 's' : ''} (type or size).` : null);\n const next = [...many, ...ok];\n if (props.value === undefined) setInternalMany(next);\n props.onChange?.(next);\n } else {\n const f = files[0];\n const err = validate(f);\n if (err) {\n setRejected(err);\n return;\n }\n setRejected(null);\n if (props.value === undefined) setInternalOne(f);\n props.onChange?.(f);\n }\n };\n\n const removeAt = (i: number) => {\n const next = many.filter((_, j) => j !== i);\n if (props.value === undefined) setInternalMany(next);\n (props.onChange as ((f: File[]) => void) | undefined)?.(next);\n };\n const clearOne = () => {\n setRejected(null);\n if (inputRef.current) inputRef.current.value = '';\n if (props.value === undefined) setInternalOne(null);\n (props.onChange as ((f: File | null) => void) | undefined)?.(null);\n };\n const openPicker = () => {\n if (!disabled) inputRef.current?.click();\n };\n\n const oneUrl = usePreviewUrl(one);\n\n // A hard `error` (or a rejected single file) puts the field in an error state;\n // a \"skipped N\" note in multiple mode is informational, not an error.\n const invalid = Boolean(error || (rejected && !multiple));\n 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={mergeRefs(inputRef, forwardedRef)}\n id={rid}\n type=\"file\"\n accept={accept}\n multiple={multiple}\n disabled={disabled}\n onChange={(e) => ingest(e.target.files)}\n style={{ display: 'none' }}\n />\n\n {multiple ? (\n <div style={sx({ display: 'flex', flexDirection: 'column', gap: 'var(--space-3)' })}>\n {boxZone}\n {many.length > 0 && (\n <ul style={sx({ listStyle: 'none', margin: 0, padding: 0, display: 'flex', flexDirection: 'column', gap: 'var(--space-2)' })}>\n {many.map((f, i) => (\n <MultiRow key={fileKey(f)} file={f} disabled={disabled} onRemove={() => removeAt(i)} />\n ))}\n </ul>\n )}\n {rejected && <span style={sx({ fontFamily: 'var(--font-body)', fontSize: 'var(--text-xs)', color: 'var(--text-muted)' })}>{rejected}</span>}\n </div>\n ) : one ? (\n <div style={sx({ display: 'flex', alignItems: 'flex-start', gap: 'var(--space-4)' })}>\n <Thumb url={oneUrl} name={typeof one === 'string' ? one.split('/').pop() || one : one.name} size={shape === 'circle' ? 88 : 96} shape={shape} />\n <div style={sx({ flex: 1, minWidth: 0, display: 'flex', flexDirection: 'column', gap: 4 })}>\n <span\n style={sx({\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n color: 'var(--text-primary)',\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n })}\n title={typeof one === 'string' ? one.split('/').pop() || one : one.name}\n >\n {typeof one === 'string' ? one.split('/').pop() || one : one.name}\n </span>\n {one instanceof File && <span style={sx({ fontFamily: 'var(--font-body)', fontSize: 'var(--text-xs)', color: 'var(--text-muted)' })}>{fmtSize(one.size)}</span>}\n {!disabled && (\n <div style={sx({ display: 'flex', gap: 'var(--space-2)', marginTop: 6, flexWrap: 'wrap' })}>\n <button type=\"button\" className=\"ds-affix-btn\" onClick={openPicker} style={{ ...actionBtn, color: 'var(--text-primary)' }}>\n <RefreshCw size={14} strokeWidth={2} /> Replace\n </button>\n <button type=\"button\" className=\"ds-affix-btn\" onClick={clearOne} style={{ ...actionBtn, color: 'var(--interactive-error)' }}>\n <Trash2 size={14} strokeWidth={2} /> Remove\n </button>\n </div>\n )}\n </div>\n </div>\n ) : shape === 'circle' ? (\n circleZone\n ) : (\n boxZone\n )}\n </Field>\n );\n});\n\nFileUpload.displayName = 'FileUpload';\n\nfunction MultiRow({ file, disabled, onRemove }: { file: File; disabled?: boolean; onRemove: () => void }) {\n const url = usePreviewUrl(file);\n return (\n <li\n style={sx({\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-3)',\n padding: 'var(--space-2)',\n borderRadius: 'var(--radius-md)',\n border: '1px solid var(--border-subtle)',\n background: 'var(--bg-surface)',\n })}\n >\n <Thumb url={url} name={file.name} size={44} shape=\"square\" />\n <span style={sx({ flex: 1, minWidth: 0, display: 'flex', flexDirection: 'column', gap: 1 })}>\n <span\n style={sx({\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n color: 'var(--text-primary)',\n minWidth: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n })}\n title={file.name}\n >\n {file.name}\n </span>\n <span style={sx({ fontFamily: 'var(--font-body)', fontSize: 'var(--text-xs)', color: 'var(--text-muted)' })}>{fmtSize(file.size)}</span>\n </span>\n {!disabled && (\n <button\n type=\"button\"\n className=\"ds-affix-btn\"\n aria-label={`Remove ${file.name}`}\n onClick={onRemove}\n style={sx({\n flex: '0 0 auto',\n width: 36,\n height: 36,\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n borderRadius: 'var(--radius-control)',\n border: '1px solid transparent',\n background: 'transparent',\n color: 'var(--interactive-error)',\n cursor: 'pointer',\n })}\n >\n <Trash2 size={16} strokeWidth={1.75} />\n </button>\n )}\n </li>\n );\n}\n"],"mappings":";AA0GQ,cAqJJ,YArJI;AAxGR,YAAY,WAAW;AACvB,SAAS,QAAQ,UAAU,aAAa,iBAAiB,UAAU,WAAW,QAAQ,mBAAoC;AAC1H,SAAS,UAAU;AACnB,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAqC1B,SAAS,cAAc,MAAY,QAAyB;AAC1D,MAAI,CAAC,UAAU,WAAW,OAAO,WAAW,MAAO,QAAO;AAC1D,QAAM,OAAO,KAAK,KAAK,YAAY;AACnC,QAAM,OAAO,KAAK,KAAK,YAAY;AACnC,SAAO,OACJ,MAAM,GAAG,EACT,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,EACjC,KAAK,CAAC,QAAQ;AACb,QAAI,CAAC,IAAK,QAAO;AACjB,QAAI,IAAI,WAAW,GAAG,EAAG,QAAO,KAAK,SAAS,GAAG;AACjD,QAAI,IAAI,SAAS,IAAI,EAAG,QAAO,KAAK,WAAW,IAAI,MAAM,GAAG,EAAE,CAAC;AAC/D,WAAO,SAAS;AAAA,EAClB,CAAC;AACL;AAEA,SAAS,QAAQ,OAAuB;AACtC,MAAI,QAAQ,KAAM,QAAO,GAAG,KAAK;AACjC,MAAI,QAAQ,OAAO,KAAM,QAAO,GAAG,KAAK,MAAM,QAAQ,IAAI,CAAC;AAC3D,SAAO,IAAI,QAAQ,SAAS,QAAQ,CAAC,CAAC;AACxC;AAGA,MAAM,SAA8D;AAAA,EAClE,KAAK,EAAE,MAAM,UAAU,OAAO,yBAAyB;AAAA,EACvD,KAAK,EAAE,MAAM,UAAU,OAAO,wBAAwB;AAAA,EACtD,MAAM,EAAE,MAAM,UAAU,OAAO,wBAAwB;AAAA,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,OAAO;AAAA,cACP,QAAQ;AAAA,YACV,CAAC;AAAA,YAED,8BAAC,UAAO,MAAM,IAAI,aAAa,MAAM;AAAA;AAAA,QACvC;AAAA;AAAA;AAAA,EAEJ;AAEJ;","names":["FileUpload"]}
|
package/dist/forms/Input.d.ts
CHANGED
|
@@ -33,6 +33,6 @@ interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, '
|
|
|
33
33
|
* field from growing the moment a validation message appears. */
|
|
34
34
|
preserveHelperSpace?: boolean;
|
|
35
35
|
}
|
|
36
|
-
declare
|
|
36
|
+
declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
|
|
37
37
|
|
|
38
38
|
export { Input, type InputProps };
|
package/dist/forms/Input.js
CHANGED
|
@@ -6,8 +6,9 @@ import { sx } from "../_internal/style.js";
|
|
|
6
6
|
import { Field } from "../_internal/Field.js";
|
|
7
7
|
import { CharCount } from "../_internal/CharCount.js";
|
|
8
8
|
import { formatMask, MASK_INPUTMODE, MASK_MAXLENGTH } from "../_internal/mask.js";
|
|
9
|
+
import { mergeRefs } from "../_internal/mergeRefs.js";
|
|
9
10
|
const H = { sm: "var(--control-height-sm)", md: "var(--control-height-md)", lg: "var(--control-height-lg)" };
|
|
10
|
-
|
|
11
|
+
const Input = React.forwardRef(function Input2({
|
|
11
12
|
label,
|
|
12
13
|
hint,
|
|
13
14
|
error,
|
|
@@ -25,11 +26,13 @@ function Input({
|
|
|
25
26
|
preserveHelperSpace,
|
|
26
27
|
type,
|
|
27
28
|
onChange,
|
|
29
|
+
onFocus,
|
|
30
|
+
onBlur,
|
|
28
31
|
inputMode,
|
|
29
32
|
maxLength,
|
|
30
33
|
defaultValue,
|
|
31
34
|
...rest
|
|
32
|
-
}) {
|
|
35
|
+
}, ref) {
|
|
33
36
|
const [focus, setFocus] = React.useState(false);
|
|
34
37
|
const [reveal, setReveal] = React.useState(false);
|
|
35
38
|
const inputRef = React.useRef(null);
|
|
@@ -58,6 +61,14 @@ function Input({
|
|
|
58
61
|
if (rest.value === void 0) setUncount(e.currentTarget.value.length);
|
|
59
62
|
onChange?.(e);
|
|
60
63
|
} : onChange;
|
|
64
|
+
const handleFocus = (e) => {
|
|
65
|
+
setFocus(true);
|
|
66
|
+
onFocus?.(e);
|
|
67
|
+
};
|
|
68
|
+
const handleBlur = (e) => {
|
|
69
|
+
setFocus(false);
|
|
70
|
+
onBlur?.(e);
|
|
71
|
+
};
|
|
61
72
|
return /* @__PURE__ */ jsx(
|
|
62
73
|
Field,
|
|
63
74
|
{
|
|
@@ -91,16 +102,16 @@ function Input({
|
|
|
91
102
|
"input",
|
|
92
103
|
{
|
|
93
104
|
id: rid,
|
|
94
|
-
ref: inputRef,
|
|
95
|
-
type: isPassword && reveal ? "text" : type,
|
|
96
105
|
disabled,
|
|
97
|
-
|
|
98
|
-
|
|
106
|
+
...rest,
|
|
107
|
+
ref: mergeRefs(inputRef, ref),
|
|
108
|
+
type: isPassword && reveal ? "text" : type,
|
|
109
|
+
onFocus: handleFocus,
|
|
110
|
+
onBlur: handleBlur,
|
|
99
111
|
onChange: handleChange,
|
|
100
112
|
inputMode: mask ? inputMode ?? MASK_INPUTMODE[mask] ?? "numeric" : inputMode,
|
|
101
113
|
maxLength: mask ? maxLength ?? MASK_MAXLENGTH[mask] : maxLength,
|
|
102
114
|
defaultValue: mask && typeof defaultValue === "string" ? formatMask(mask, defaultValue) : defaultValue,
|
|
103
|
-
...rest,
|
|
104
115
|
style: sx({
|
|
105
116
|
flex: 1,
|
|
106
117
|
minWidth: 0,
|
|
@@ -138,7 +149,8 @@ function Input({
|
|
|
138
149
|
)
|
|
139
150
|
}
|
|
140
151
|
);
|
|
141
|
-
}
|
|
152
|
+
});
|
|
153
|
+
Input.displayName = "Input";
|
|
142
154
|
export {
|
|
143
155
|
Input
|
|
144
156
|
};
|
package/dist/forms/Input.js.map
CHANGED
|
@@ -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 /** 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(--text-sm)' : 'var(--text-base)', lineHeight: 1.2, flex: '0 0 auto' })}>{suffix}</span>\n )\n )}\n </div>\n </Field>\n );\n}\n"],"mappings":";AAgH6B,cAGvB,YAHuB;AA9G7B,YAAY,WAAW;AACvB,SAAS,KAAK,cAAc;AAC5B,SAAS,UAAU;AACnB,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,YAAY,gBAAgB,sBAAqC;AAmC1E,MAAM,IAAI,EAAE,IAAI,4BAA4B,IAAI,4BAA4B,IAAI,2BAA2B;AAEpG,SAAS,M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,gBACJ,OAAO,GAAG;AAAA,kBACR,MAAM;AAAA,kBACN,UAAU;AAAA,kBACV,QAAQ;AAAA,kBACR,SAAS;AAAA;AAAA,kBACT,QAAQ;AAAA,kBACR,SAAS;AAAA,kBACT,YAAY;AAAA,kBACZ,YAAY;AAAA,kBACZ,UAAU,SAAS,OAAO,mBAAmB;AAAA,kBAC7C,YAAY;AAAA;AAAA,kBACZ,OAAO,WAAW,yBAAyB;AAAA,kBAC3C,GAAG;AAAA,gBACL,CAAC;AAAA;AAAA,YACH;AAAA,YACC,aACC;AAAA,cAAC;AAAA;AAAA,gBACC,MAAK;AAAA,gBACL,WAAU;AAAA,gBACV,cAAY,SAAS,kBAAkB;AAAA,gBACvC,gBAAc;AAAA,gBACd,SAAS,MAAM;AACb,4BAAU,CAAC,MAAM,CAAC,CAAC;AACnB,2BAAS,SAAS,MAAM;AAAA,gBAC1B;AAAA,gBAEC,mBAAS,oBAAC,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';\nimport { mergeRefs } from '../_internal/mergeRefs';\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 const Input = React.forwardRef<HTMLInputElement, InputProps>(function Input(\n {\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 onFocus,\n onBlur,\n inputMode,\n maxLength,\n defaultValue,\n ...rest\n },\n ref,\n) {\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 // Composed the same way as `handleChange` above — the focus ring's own\n // onFocus/onBlur must never be silently replaced by a caller's handler\n // (or by react-hook-form's `register()`, which always injects its own\n // onBlur), the way a plain `{...rest}` spread after them would do.\n const handleFocus = (e: React.FocusEvent<HTMLInputElement>) => {\n setFocus(true);\n onFocus?.(e);\n };\n const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {\n setFocus(false);\n onBlur?.(e);\n };\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 disabled={disabled}\n {...rest}\n ref={mergeRefs(inputRef, ref)}\n type={isPassword && reveal ? 'text' : type}\n onFocus={handleFocus}\n onBlur={handleBlur}\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 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\nInput.displayName = 'Input';\n"],"mappings":";AAmI6B,cAGvB,YAHuB;AAjI7B,YAAY,WAAW;AACvB,SAAS,KAAK,cAAc;AAC5B,SAAS,UAAU;AACnB,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,YAAY,gBAAgB,sBAAqC;AAC1E,SAAS,i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-26,6 +26,6 @@ interface RadioProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, '
|
|
|
26
26
|
*/
|
|
27
27
|
preserveHelperSpace?: boolean;
|
|
28
28
|
}
|
|
29
|
-
declare
|
|
29
|
+
declare const Radio: React.ForwardRefExoticComponent<RadioProps & React.RefAttributes<HTMLInputElement>>;
|
|
30
30
|
|
|
31
31
|
export { Radio, type RadioProps };
|
package/dist/forms/Radio.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { sx } from "../_internal/style.js";
|
|
5
|
-
|
|
5
|
+
const Radio = React.forwardRef(function Radio2({ label, description, error, checked, defaultChecked, disabled, size = "md", preserveHelperSpace = false, onChange, style, ...rest }, ref) {
|
|
6
6
|
const [hover, setHover] = React.useState(false);
|
|
7
7
|
const box = size === "sm" ? 16 : 20;
|
|
8
8
|
return /* @__PURE__ */ jsxs(
|
|
@@ -15,6 +15,7 @@ function Radio({ label, description, error, checked, defaultChecked, disabled, s
|
|
|
15
15
|
/* @__PURE__ */ jsx("span", { style: sx({ position: "relative", display: "inline-flex", flex: "0 0 auto", marginTop: size === "sm" ? 3 : 1 }), children: /* @__PURE__ */ jsx(
|
|
16
16
|
"input",
|
|
17
17
|
{
|
|
18
|
+
ref,
|
|
18
19
|
type: "radio",
|
|
19
20
|
checked,
|
|
20
21
|
defaultChecked,
|
|
@@ -55,7 +56,8 @@ function Radio({ label, description, error, checked, defaultChecked, disabled, s
|
|
|
55
56
|
]
|
|
56
57
|
}
|
|
57
58
|
);
|
|
58
|
-
}
|
|
59
|
+
});
|
|
60
|
+
Radio.displayName = "Radio";
|
|
59
61
|
export {
|
|
60
62
|
Radio
|
|
61
63
|
};
|
package/dist/forms/Radio.js.map
CHANGED
|
@@ -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. 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 }
|
|
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. 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 const Radio = React.forwardRef<HTMLInputElement, RadioProps>(function Radio(\n { label, description, error, checked, defaultChecked, disabled, size = 'md', preserveHelperSpace = false, onChange, style, ...rest },\n ref,\n) {\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 ref={ref}\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});\n\nRadio.displayName = 'Radio';"],"mappings":";AA6CQ,cAuBF,YAvBE;AA3CR,YAAY,WAAW;AACvB,SAAS,UAAU;AA6BZ,MAAM,QAAQ,MAAM,WAAyC,SAASA,OAC3E,EAAE,OAAO,aAAa,OAAO,SAAS,gBAAgB,UAAU,OAAO,MAAM,sBAAsB,OAAO,UAAU,OAAO,GAAG,KAAK,GACnI,KACA;AACA,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;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,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,CAAC;AAED,MAAM,cAAc;","names":["Radio"]}
|
|
@@ -18,6 +18,6 @@ interface SearchInputProps extends Omit<InputProps, 'iconLeft' | 'suffix' | 'pre
|
|
|
18
18
|
/** aria-label for the clear button. */
|
|
19
19
|
clearLabel?: string;
|
|
20
20
|
}
|
|
21
|
-
declare
|
|
21
|
+
declare const SearchInput: React.ForwardRefExoticComponent<SearchInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
22
22
|
|
|
23
23
|
export { SearchInput, type SearchInputProps };
|
|
@@ -4,17 +4,7 @@ import * as React from "react";
|
|
|
4
4
|
import { Search, X } from "lucide-react";
|
|
5
5
|
import { sx } from "../_internal/style.js";
|
|
6
6
|
import { Input } from "./Input.js";
|
|
7
|
-
|
|
8
|
-
value,
|
|
9
|
-
defaultValue,
|
|
10
|
-
onValueChange,
|
|
11
|
-
onSearch,
|
|
12
|
-
debounce = 250,
|
|
13
|
-
clearLabel = "Clear search",
|
|
14
|
-
placeholder = "Search\u2026",
|
|
15
|
-
disabled,
|
|
16
|
-
...rest
|
|
17
|
-
}) {
|
|
7
|
+
const SearchInput = React.forwardRef(function SearchInput2({ value, defaultValue, onValueChange, onSearch, debounce = 250, clearLabel = "Clear search", placeholder = "Search\u2026", disabled, ...rest }, ref) {
|
|
18
8
|
const [internal, setInternal] = React.useState(defaultValue ?? "");
|
|
19
9
|
const text = value !== void 0 ? value : internal;
|
|
20
10
|
const timer = React.useRef(void 0);
|
|
@@ -33,6 +23,7 @@ function SearchInput({
|
|
|
33
23
|
return /* @__PURE__ */ jsx(
|
|
34
24
|
Input,
|
|
35
25
|
{
|
|
26
|
+
ref,
|
|
36
27
|
...rest,
|
|
37
28
|
role: "searchbox",
|
|
38
29
|
enterKeyHint: "search",
|
|
@@ -63,7 +54,8 @@ function SearchInput({
|
|
|
63
54
|
) : void 0
|
|
64
55
|
}
|
|
65
56
|
);
|
|
66
|
-
}
|
|
57
|
+
});
|
|
58
|
+
SearchInput.displayName = "SearchInput";
|
|
67
59
|
export {
|
|
68
60
|
SearchInput
|
|
69
61
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/forms/SearchInput.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Search, X } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { Input, type InputProps } from './Input';\n\n/**\n * A search field: `Input` with a leading magnifier, a clear (×) button, and a\n * **debounced** `onSearch`. `Enter` searches immediately; `Esc` clears.\n */\nexport interface SearchInputProps\n extends Omit<InputProps, 'iconLeft' | 'suffix' | 'prefix' | 'type' | 'mask' | 'showCount' | 'value' | 'defaultValue' | 'onChange'> {\n value?: string;\n defaultValue?: string;\n /** Every keystroke and on clear — the plain string. */\n onValueChange?: (value: string) => void;\n /** Debounced (and on `Enter` / clear) — run the actual query here. */\n onSearch?: (value: string) => void;\n /** Debounce for `onSearch`, in ms. */\n debounce?: number;\n /** aria-label for the clear button. */\n clearLabel?: string;\n}\n\nexport function SearchInput(
|
|
1
|
+
{"version":3,"sources":["../../src/forms/SearchInput.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Search, X } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { Input, type InputProps } from './Input';\n\n/**\n * A search field: `Input` with a leading magnifier, a clear (×) button, and a\n * **debounced** `onSearch`. `Enter` searches immediately; `Esc` clears.\n */\nexport interface SearchInputProps\n extends Omit<InputProps, 'iconLeft' | 'suffix' | 'prefix' | 'type' | 'mask' | 'showCount' | 'value' | 'defaultValue' | 'onChange'> {\n value?: string;\n defaultValue?: string;\n /** Every keystroke and on clear — the plain string. */\n onValueChange?: (value: string) => void;\n /** Debounced (and on `Enter` / clear) — run the actual query here. */\n onSearch?: (value: string) => void;\n /** Debounce for `onSearch`, in ms. */\n debounce?: number;\n /** aria-label for the clear button. */\n clearLabel?: string;\n}\n\nexport const SearchInput = React.forwardRef<HTMLInputElement, SearchInputProps>(function SearchInput(\n { value, defaultValue, onValueChange, onSearch, debounce = 250, clearLabel = 'Clear search', placeholder = 'Search…', disabled, ...rest },\n ref,\n) {\n const [internal, setInternal] = React.useState(defaultValue ?? '');\n const text = value !== undefined ? value : internal;\n\n const timer = React.useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n React.useEffect(() => () => clearTimeout(timer.current), []);\n\n const runSearch = (v: string, immediate: boolean) => {\n clearTimeout(timer.current);\n if (immediate) onSearch?.(v);\n else timer.current = setTimeout(() => onSearch?.(v), debounce);\n };\n\n const update = (v: string, immediate = false) => {\n if (value === undefined) setInternal(v);\n onValueChange?.(v);\n runSearch(v, immediate);\n };\n\n const clear = () => update('', true);\n\n return (\n <Input\n ref={ref}\n {...rest}\n role=\"searchbox\"\n enterKeyHint=\"search\"\n autoComplete=\"off\"\n spellCheck={false}\n placeholder={placeholder}\n disabled={disabled}\n value={text}\n onChange={(e) => update(e.currentTarget.value)}\n onKeyDown={(e) => {\n if (e.key === 'Enter') runSearch(e.currentTarget.value, true);\n else if (e.key === 'Escape' && text) {\n e.preventDefault();\n clear();\n }\n }}\n iconLeft={<Search size={16} strokeWidth={1.75} />}\n suffix={\n text && !disabled ? (\n <button\n type=\"button\"\n className=\"ds-affix-btn\"\n aria-label={clearLabel}\n onClick={clear}\n style={sx({ display: 'inline-flex', alignItems: 'center', border: 'none', background: 'transparent', color: 'var(--text-muted)', cursor: 'pointer', padding: 0 })}\n >\n <X size={16} strokeWidth={2} />\n </button>\n ) : undefined\n }\n />\n );\n});\n\nSearchInput.displayName = 'SearchInput';\n"],"mappings":";AAoEgB;AAlEhB,YAAY,WAAW;AACvB,SAAS,QAAQ,SAAS;AAC1B,SAAS,UAAU;AACnB,SAAS,aAA8B;AAoBhC,MAAM,cAAc,MAAM,WAA+C,SAASA,aACvF,EAAE,OAAO,cAAc,eAAe,UAAU,WAAW,KAAK,aAAa,gBAAgB,cAAc,gBAAW,UAAU,GAAG,KAAK,GACxI,KACA;AACA,QAAM,CAAC,UAAU,WAAW,IAAI,MAAM,SAAS,gBAAgB,EAAE;AACjE,QAAM,OAAO,UAAU,SAAY,QAAQ;AAE3C,QAAM,QAAQ,MAAM,OAAkD,MAAS;AAC/E,QAAM,UAAU,MAAM,MAAM,aAAa,MAAM,OAAO,GAAG,CAAC,CAAC;AAE3D,QAAM,YAAY,CAAC,GAAW,cAAuB;AACnD,iBAAa,MAAM,OAAO;AAC1B,QAAI,UAAW,YAAW,CAAC;AAAA,QACtB,OAAM,UAAU,WAAW,MAAM,WAAW,CAAC,GAAG,QAAQ;AAAA,EAC/D;AAEA,QAAM,SAAS,CAAC,GAAW,YAAY,UAAU;AAC/C,QAAI,UAAU,OAAW,aAAY,CAAC;AACtC,oBAAgB,CAAC;AACjB,cAAU,GAAG,SAAS;AAAA,EACxB;AAEA,QAAM,QAAQ,MAAM,OAAO,IAAI,IAAI;AAEnC,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACC,GAAG;AAAA,MACJ,MAAK;AAAA,MACL,cAAa;AAAA,MACb,cAAa;AAAA,MACb,YAAY;AAAA,MACZ;AAAA,MACA;AAAA,MACA,OAAO;AAAA,MACP,UAAU,CAAC,MAAM,OAAO,EAAE,cAAc,KAAK;AAAA,MAC7C,WAAW,CAAC,MAAM;AAChB,YAAI,EAAE,QAAQ,QAAS,WAAU,EAAE,cAAc,OAAO,IAAI;AAAA,iBACnD,EAAE,QAAQ,YAAY,MAAM;AACnC,YAAE,eAAe;AACjB,gBAAM;AAAA,QACR;AAAA,MACF;AAAA,MACA,UAAU,oBAAC,UAAO,MAAM,IAAI,aAAa,MAAM;AAAA,MAC/C,QACE,QAAQ,CAAC,WACP;AAAA,QAAC;AAAA;AAAA,UACC,MAAK;AAAA,UACL,WAAU;AAAA,UACV,cAAY;AAAA,UACZ,SAAS;AAAA,UACT,OAAO,GAAG,EAAE,SAAS,eAAe,YAAY,UAAU,QAAQ,QAAQ,YAAY,eAAe,OAAO,qBAAqB,QAAQ,WAAW,SAAS,EAAE,CAAC;AAAA,UAEhK,8BAAC,KAAE,MAAM,IAAI,aAAa,GAAG;AAAA;AAAA,MAC/B,IACE;AAAA;AAAA,EAER;AAEJ,CAAC;AAED,YAAY,cAAc;","names":["SearchInput"]}
|
package/dist/forms/Select.d.ts
CHANGED
|
@@ -47,6 +47,16 @@ interface SelectProps {
|
|
|
47
47
|
* field from growing the moment a validation message appears. */
|
|
48
48
|
preserveHelperSpace?: boolean;
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
/**
|
|
51
|
+
* `ref` reaches the hidden `<input type="hidden">` that mirrors the selected
|
|
52
|
+
* value (rendered only when `name` is set — pass it, as `register()` does).
|
|
53
|
+
* Enough for `getValues()` / `trigger()` / `setFocus()`, but a plain
|
|
54
|
+
* `{...register(name)}` spread still won't validate on change: this hidden
|
|
55
|
+
* input never dispatches a native `input`/`change` event, and `onValueChange`
|
|
56
|
+
* hands back a plain string, not a `ChangeEvent` — wire it through
|
|
57
|
+
* `Controller`, or call the registered `onChange` yourself from
|
|
58
|
+
* `onValueChange`.
|
|
59
|
+
*/
|
|
60
|
+
declare const Select: React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<HTMLInputElement>>;
|
|
51
61
|
|
|
52
62
|
export { Select, type SelectOption, type SelectProps };
|
package/dist/forms/Select.js
CHANGED
|
@@ -442,7 +442,7 @@ function CustomSelect({
|
|
|
442
442
|
)
|
|
443
443
|
] });
|
|
444
444
|
}
|
|
445
|
-
|
|
445
|
+
const Select = React.forwardRef(function Select2({
|
|
446
446
|
label,
|
|
447
447
|
hint,
|
|
448
448
|
error,
|
|
@@ -459,7 +459,7 @@ function Select({
|
|
|
459
459
|
containerStyle,
|
|
460
460
|
"aria-label": ariaLabel,
|
|
461
461
|
preserveHelperSpace
|
|
462
|
-
}) {
|
|
462
|
+
}, ref) {
|
|
463
463
|
const reactId = React.useId();
|
|
464
464
|
const rid = id || reactId;
|
|
465
465
|
const isControlled = valueProp !== void 0;
|
|
@@ -490,9 +490,10 @@ function Select({
|
|
|
490
490
|
onCommit: commit
|
|
491
491
|
}
|
|
492
492
|
),
|
|
493
|
-
name && /* @__PURE__ */ jsx("input", { type: "hidden", name, value })
|
|
493
|
+
name && /* @__PURE__ */ jsx("input", { ref, type: "hidden", name, value })
|
|
494
494
|
] });
|
|
495
|
-
}
|
|
495
|
+
});
|
|
496
|
+
Select.displayName = "Select";
|
|
496
497
|
export {
|
|
497
498
|
Select
|
|
498
499
|
};
|