@sereno-ds/ui 0.43.0 → 0.44.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.
package/README.md CHANGED
@@ -18,12 +18,12 @@ npm i @sereno-ds/ui @sereno-ds/tokens lucide-react
18
18
 
19
19
  ```ts
20
20
  import '@sereno-ds/tokens/tokens.css'; // the token layer (colors, spacing, dark overrides…)
21
- import '@sereno-ds/ui/styles.css'; // keyframes, structural rules, and the hover / press / focus of Button, IconButton and Card
21
+ import '@sereno-ds/ui/styles.css'; // keyframes, structural rules, and the hover / press / focus of the interactive components
22
22
  ```
23
23
 
24
24
  `tokens.css` **must** come first. Both are side-effect CSS: import them once (a root layout, `_app`, or `main.tsx`), not per-component.
25
25
 
26
- **`styles.css` is required**, not decorative: `Button`, `IconButton`, `Card`, `ActionCard`, the rows of `SidebarNav`, `Checkbox`, `Radio` and the actions of `AvatarUpload` take their hover / press / focus states (and, for the first four, their colours and border) from it. Their values are on the element, the rules that switch between them are in the stylesheet, so without it they render unstyled or with no hover.
26
+ **`styles.css` is required**, not decorative: `Button`, `IconButton`, `Card`, `ActionCard`, the rows and the collapse control of `SidebarNav`, `Checkbox`, `Radio`, the actions of `AvatarUpload` and the text fields (`Input`, `Textarea`, `Select`, `DatePicker`, `Autocomplete`) take their hover / press / focus states (and, for several of them, their colours and border) from it. Their values are on the element, the rules that switch between them are in the stylesheet, so without it they render unstyled, with no hover and no focus ring.
27
27
 
28
28
  #### Restyling a state with plain CSS
29
29
 
@@ -37,6 +37,8 @@ These components carry a class the stylesheet's state rules hang on:
37
37
  | `SidebarNav` items and sub items | `sereno-sidenav-row` | |
38
38
  | `Checkbox`, `Radio` | `sereno-choice` on the row (the `<label>`), `sereno-check` / `sereno-radio` on the box | |
39
39
  | the actions of `AvatarUpload` | `sereno-menuitem` | |
40
+ | the collapse control of `SidebarNav` | `sereno-sidenav-toggle` | |
41
+ | `Input` (its row), `Textarea`, the boxes of `Select`, `DatePicker` and `Autocomplete` | `sereno-field` | `data-active` while a popup is open |
40
42
 
41
43
  The state rules have the specificity of `.sereno-btn:hover` (one class and one pseudo-class), so a rule of yours with the same specificity **that comes later** wins, with no `!important`:
42
44
 
@@ -15,6 +15,7 @@ import { useOutsidePress } from "../_internal/useOutsidePress.js";
15
15
  import { revealInList, useRevealActive } from "../_internal/useRevealActive.js";
16
16
  import { MenuOption, menuListStyle, menuRowPadY, menuSurfaceStyle } from "../_internal/MenuOption.js";
17
17
  import { fieldBoxStyle } from "./_internal/fieldBoxStyle.js";
18
+ import { fieldBoxProps } from "./_internal/fieldFrame.js";
18
19
  const TEXT = {
19
20
  "pt-BR": {
20
21
  placeholder: "Buscar\u2026",
@@ -90,7 +91,6 @@ const Autocomplete = React.forwardRef(function Autocomplete2({
90
91
  const text = draft ?? valueLabel;
91
92
  const query = draft ?? "";
92
93
  const [open, setOpen] = React.useState(false);
93
- const [focused, setFocused] = React.useState(false);
94
94
  const [activeKey, setActiveKey] = React.useState(null);
95
95
  const activeFromOpen = React.useRef(false);
96
96
  const pick = (key) => {
@@ -370,7 +370,8 @@ const Autocomplete = React.forwardRef(function Autocomplete2({
370
370
  e.preventDefault();
371
371
  inputRef.current?.focus();
372
372
  },
373
- style: sx({ ...fieldBoxStyle(size, !!error, focused || open, !!disabled), cursor: disabled ? "not-allowed" : "text" }),
373
+ ...fieldBoxProps(open),
374
+ style: sx({ ...fieldBoxStyle(size, !!error, !!disabled), cursor: disabled ? "not-allowed" : "text" }),
374
375
  children: [
375
376
  /* @__PURE__ */ jsx(
376
377
  "input",
@@ -401,12 +402,10 @@ const Autocomplete = React.forwardRef(function Autocomplete2({
401
402
  onChange,
402
403
  onKeyDown,
403
404
  onFocus: (e) => {
404
- setFocused(true);
405
405
  selectOnClick.current = true;
406
406
  e.currentTarget.select();
407
407
  },
408
408
  onBlur: (e) => {
409
- setFocused(false);
410
409
  if (boxRef.current?.contains(e.relatedTarget)) return;
411
410
  settle();
412
411
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/forms/Autocomplete.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { ChevronDown, X } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { srOnlyStyle } from '../_internal/srOnly';\nimport { Field } from '../_internal/Field';\nimport { fieldA11y } from '../_internal/fieldA11y';\nimport { useIsoLayoutEffect } from '../_internal/useIsoLayoutEffect';\nimport { useLatest } from '../_internal/useLatest';\nimport { useCoarsePointer } from '../_internal/useCoarsePointer';\nimport { useMenuPlacement } from '../_internal/useMenuPlacement';\nimport { useOutsidePress } from '../_internal/useOutsidePress';\nimport { revealInList, useRevealActive } from '../_internal/useRevealActive';\nimport { MenuOption, menuListStyle, menuRowPadY, menuSurfaceStyle } from '../_internal/MenuOption';\nimport { fieldBoxStyle } from './_internal/fieldBoxStyle';\n\nexport interface AutocompleteOption {\n value: string;\n label: string;\n disabled?: boolean;\n}\n\n/** Every string the component says. Defaults come from `locale`; pass `labels` to change some. */\nexport interface AutocompleteLabels {\n /** Placeholder of the text box while nothing is chosen. */\n placeholder: string;\n /** aria-label of the clear (×) button. */\n clear: string;\n /** aria-label of the chevron button while the list is closed. */\n open: string;\n /** aria-label of the chevron button while the list is open. */\n close: string;\n /** What a screen reader hears while `loading` (the list itself shows only a spinner). */\n loading: string;\n /** The row shown when no option is left to show. */\n empty: string;\n /** What a screen reader hears when the list changes size. */\n results: (count: number) => string;\n}\n\nconst TEXT: Record<'pt-BR' | 'en', AutocompleteLabels> = {\n 'pt-BR': {\n placeholder: 'Buscar…',\n clear: 'Limpar seleção',\n open: 'Abrir lista',\n close: 'Fechar lista',\n loading: 'Carregando…',\n empty: 'Nenhum resultado',\n results: (n) => (n === 1 ? '1 resultado' : n + ' resultados'),\n },\n en: {\n placeholder: 'Search…',\n clear: 'Clear selection',\n open: 'Open list',\n close: 'Close list',\n loading: 'Loading…',\n empty: 'No results',\n results: (n) => (n === 1 ? '1 result' : n + ' results'),\n },\n};\n\n/**\n * Single choice from a list you search by typing. Like `Select`, but the box is a text field: type\n * to narrow the list, pick one row, and the value is that row. For a list too long to scroll\n * (past ~12 options), or one the server searches and pages (a thousand clients, fifty at a time).\n *\n * The value is the chosen option itself, `{ value, label }`, and it carries its own label. The\n * box shows `value.label` whether or not that option is in `options` right now, which is what\n * keeps the label when the page it came from is no longer loaded. `options` is only what the list\n * shows. `onValueChange` gives the option (or `null` when cleared), not a string.\n *\n * Two kinds of search, one prop apart:\n * - the default filters `options` itself, as you type (case and accents ignored);\n * - `filter={false}` leaves the list alone and tells you what was typed (`onSearch`, debounced),\n * for a list the server already filtered.\n *\n * It is a text box, not free text: what is typed never becomes the value. Leaving the box puts the\n * chosen label back.\n */\nexport interface AutocompleteProps {\n label?: string;\n hint?: string;\n /** Error message; also turns the control red. */\n error?: string;\n required?: boolean;\n /** What the list shows now. Appending rows while it is open is fine: the list keeps its scroll. */\n options?: AutocompleteOption[];\n /** Controlled value: the chosen option, or `null` for none. */\n value?: AutocompleteOption | null;\n /** Uncontrolled initial value. */\n defaultValue?: AutocompleteOption | null;\n /** The chosen option, or `null` when the value is cleared. */\n onValueChange?: (option: AutocompleteOption | null) => void;\n /**\n * How typing narrows `options`. `true` (default): keep the rows whose label contains the text,\n * ignoring case and accents. `false`: show `options` as they are (the server did the filtering).\n * A function decides per row.\n */\n filter?: boolean | ((option: AutocompleteOption, query: string) => boolean);\n /**\n * The text to search for changed: fired as the user types (after `debounce`) and with `''` once\n * the box goes back to showing the chosen label (pick, clear, leave, Esc). Never with the label\n * itself, so it is safe to run the query here. Use it with `filter={false}`.\n */\n onSearch?: (query: string) => void;\n /** Debounce for `onSearch` while typing, in ms. */\n debounce?: number;\n /** The list is waiting for rows: a spinner under them (or alone), the list marked busy, and a screen reader told. */\n loading?: boolean;\n /**\n * The list was scrolled to within about five rows of its end. Fires once per list size, never\n * while `loading`. Pass it only while there is a next page, so a list that is complete asks for nothing.\n */\n onReachEnd?: () => void;\n /** The list opened or closed. For a list that loads when it opens. */\n onOpenChange?: (open: boolean) => void;\n /** A × button, and an emptied box clears the value. */\n clearable?: boolean;\n /** Shown in muted text while nothing is chosen. Defaults to the `locale` text. */\n placeholder?: string;\n size?: 'sm' | 'md' | 'lg';\n disabled?: boolean;\n /** Form field name - mirrored to a hidden input so the chosen value can be submitted. */\n name?: string;\n id?: string;\n containerStyle?: React.CSSProperties;\n /**\n * Accessible name for the text box. Only needed when there's no visible `label`. Takes\n * precedence over `label` if both are set - don't pass both.\n */\n 'aria-label'?: string;\n /** Reserve the hint/error row's height even with neither set - stops the field from growing\n * the moment a validation message appears. */\n preserveHelperSpace?: boolean;\n /** Language of the built-in texts. */\n locale?: 'pt-BR' | 'en';\n /** Override any built-in text. */\n labels?: Partial<AutocompleteLabels>;\n}\n\n/** How close to the end of the list, in rows, `onReachEnd` fires. */\nconst REACH_ROWS = 5;\n\nconst MARKS = /[̀-ͯ]/g;\nconst plain = (s: string) => s.normalize('NFD').replace(MARKS, '').toLowerCase();\n\nfunction narrow(\n options: AutocompleteOption[],\n filter: AutocompleteProps['filter'],\n query: string,\n): AutocompleteOption[] {\n if (filter === false) return options;\n const q = query.trim();\n if (!q) return options;\n if (typeof filter === 'function') return options.filter((o) => filter(o, query));\n const needle = plain(q);\n return options.filter((o) => plain(o.label).includes(needle));\n}\n\n/**\n * `ref` reaches the hidden `<input type=\"hidden\">` that mirrors the chosen value (rendered only\n * when `name` is set - pass it, as `register()` does), the same as `Select`. A plain\n * `{...register(name)}` spread still won't validate on change: wire it through `Controller`, or\n * call the registered `onChange` yourself from `onValueChange`.\n */\nexport const Autocomplete = React.forwardRef<HTMLInputElement, AutocompleteProps>(function Autocomplete(\n {\n label,\n hint,\n error,\n required,\n options = [],\n value: valueProp,\n defaultValue,\n onValueChange,\n filter = true,\n onSearch,\n debounce = 250,\n loading = false,\n onReachEnd,\n onOpenChange,\n clearable = true,\n placeholder,\n size = 'md',\n disabled,\n name,\n id,\n containerStyle,\n 'aria-label': ariaLabel,\n preserveHelperSpace,\n locale = 'pt-BR',\n labels,\n },\n ref,\n) {\n const reactId = React.useId();\n const rid = id || reactId;\n const listboxId = `${rid}-listbox`;\n const copy: AutocompleteLabels = { ...TEXT[locale], ...labels };\n const coarse = useCoarsePointer();\n\n const inputRef = React.useRef<HTMLInputElement>(null);\n const boxRef = React.useRef<HTMLDivElement>(null);\n const panelRef = React.useRef<HTMLDivElement>(null);\n const listRef = React.useRef<HTMLUListElement>(null);\n\n // ── value: the chosen option, with its own label ──\n const isControlled = valueProp !== undefined;\n const [inner, setInner] = React.useState<AutocompleteOption | null>(defaultValue ?? null);\n const value = isControlled ? valueProp : inner;\n const valueLabel = value?.label ?? '';\n\n // ── the text box: the chosen label, until the user types (`draft`) ──\n const [draft, setDraft] = React.useState<string | null>(null);\n const text = draft ?? valueLabel;\n const query = draft ?? '';\n\n const [open, setOpen] = React.useState(false);\n const [focused, setFocused] = React.useState(false);\n const [activeKey, setActiveKey] = React.useState<string | null>(null);\n // The active row is the chosen one only because the list opened on it, not because the user went\n // there: set by opening, cleared by the first thing the user does to the highlight.\n const activeFromOpen = React.useRef(false);\n const pick = (key: string | null) => {\n activeFromOpen.current = false;\n setActiveKey(key);\n };\n\n const visible = React.useMemo(() => narrow(options, filter, query), [options, filter, query]);\n const activeIndex = activeKey === null ? -1 : visible.findIndex((o) => o.value === activeKey && !o.disabled);\n const activeId = activeIndex >= 0 ? `${rid}-opt-${activeIndex}` : null;\n\n const rows = visible.length;\n const status = loading ? copy.loading : rows === 0 ? copy.empty : null;\n\n // ── open / close, told to the app once per change ──\n const onOpenChangeRef = useLatest(onOpenChange);\n const toldOpen = React.useRef(false);\n React.useEffect(() => {\n if (toldOpen.current === open) return;\n toldOpen.current = open;\n onOpenChangeRef.current?.(open);\n }, [open, onOpenChangeRef]);\n\n // ── search: told to the app when the query changes, debounced while typing ──\n const onSearchRef = useLatest(onSearch);\n const searchTimer = React.useRef<number | undefined>(undefined);\n const toldQuery = React.useRef('');\n React.useEffect(() => () => window.clearTimeout(searchTimer.current), []);\n const search = (q: string, immediate: boolean) => {\n window.clearTimeout(searchTimer.current);\n const run = () => {\n if (q === toldQuery.current) return;\n toldQuery.current = q;\n onSearchRef.current?.(q);\n };\n if (immediate) run();\n else searchTimer.current = window.setTimeout(run, debounce);\n };\n\n /** The box goes back to the chosen label: closes the list, drops what was typed, resets the query. */\n const settle = () => {\n setOpen(false);\n setDraft(null);\n search('', true);\n };\n\n const place = useMenuPlacement({\n open,\n anchorRef: boxRef,\n panelRef,\n itemCount: rows + (status ? 1 : 0),\n onDismiss: () => settle(),\n });\n // The chosen row can arrive after the list opened (a list that loads when it opens, on the page around\n // the chosen row). It is brought into view then, unless the user has already scrolled the list away\n // from the top: a user paging down for the next page is not carried off to a row that just landed.\n useRevealActive(open, activeId, place, revealInList, (el) => !activeFromOpen.current || (el.parentElement?.scrollTop ?? 0) === 0);\n\n // ── pagination: ask for more once the list is near its end ──\n const onReachEndRef = useLatest(onReachEnd);\n const askedFor = React.useRef<string | null>(null);\n // What the list is, for \"once per size\": a new search that happens to return as many rows is a new list.\n const shape = options.length + '|' + (options[0]?.value ?? '') + '|' + (options[options.length - 1]?.value ?? '');\n useIsoLayoutEffect(() => {\n if (!open) {\n askedFor.current = null;\n return;\n }\n const list = listRef.current;\n if (!list || rows === 0) return;\n const check = () => {\n if (loading || !onReachEndRef.current || askedFor.current === shape) return;\n const remaining = list.scrollHeight - list.scrollTop - list.clientHeight;\n if (remaining > (list.scrollHeight / rows) * REACH_ROWS) return;\n askedFor.current = shape;\n onReachEndRef.current();\n };\n check();\n list.addEventListener('scroll', check, { passive: true });\n return () => list.removeEventListener('scroll', check);\n }, [open, loading, shape, place, rows, onReachEndRef]);\n\n // A new search starts at the top.\n const firstValue = options[0]?.value;\n useIsoLayoutEffect(() => {\n if (draft !== null && listRef.current) listRef.current.scrollTop = 0;\n }, [draft, firstValue]);\n\n // iOS keeps the keyboard (and the field) up when you tap on plain page: close on any press outside.\n useOutsidePress(open, [boxRef, panelRef], () => settle());\n\n // ── choosing ──\n const firstEnabledKey = () => visible.find((o) => !o.disabled)?.value ?? null;\n const lastEnabledKey = () => {\n for (let i = rows - 1; i >= 0; i--) if (!visible[i].disabled) return visible[i].value;\n return null;\n };\n const move = (dir: 1 | -1) => {\n let i = activeIndex < 0 ? (dir === 1 ? -1 : rows) : activeIndex;\n for (let step = 0; step < rows; step++) {\n i += dir;\n if (i < 0 || i >= rows) return; // the ends are walls, not a loop: a paged list has no \"wrap\"\n if (!visible[i].disabled) {\n pick(visible[i].value);\n return;\n }\n }\n };\n\n const choose = (o: AutocompleteOption) => {\n if (o.disabled) return;\n if (!isControlled) setInner(o);\n onValueChange?.(o);\n setOpen(false);\n setDraft(null);\n search('', true);\n // On a phone the keyboard goes with the choice.\n if (coarse) inputRef.current?.blur();\n };\n const clear = () => {\n if (value) {\n if (!isControlled) setInner(null);\n onValueChange?.(null);\n }\n setDraft(''); // empty at once, even if the app takes a moment to take the value away\n search('', true);\n inputRef.current?.focus();\n };\n\n const selectedKey = value?.value;\n // Opening starts on the chosen row. If it is not in the list *yet* because the list is empty (it\n // loads when it opens), it stays the active one so it is revealed when it arrives. With rows on screen\n // that do not include it, it is not chased: the list is not moved under the user later.\n const startKey = (fallback: string | null) =>\n selectedKey !== undefined && (rows === 0 || visible.some((o) => o.value === selectedKey)) ? selectedKey : fallback;\n const openFromPointer = () => {\n activeFromOpen.current = true;\n setActiveKey(startKey(null));\n setOpen(true);\n };\n const openFromKey = () => {\n activeFromOpen.current = true;\n setActiveKey(startKey(firstEnabledKey()));\n setOpen(true);\n };\n\n const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const next = e.currentTarget.value;\n setDraft(next);\n // Filtering here, the first match is ready for Enter. A server search has not answered yet:\n // an Enter now would pick a row of the old answer, so nothing is active until the user moves.\n pick(filter === false ? null : narrow(options, filter, next).find((o) => !o.disabled)?.value ?? null);\n setOpen(true);\n if (next === '' && clearable && value) {\n if (!isControlled) setInner(null);\n onValueChange?.(null);\n }\n search(next, false);\n };\n\n const onKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (disabled || e.nativeEvent.isComposing) return; // an IME is still composing the text\n switch (e.key) {\n case 'ArrowDown':\n e.preventDefault();\n if (!open) openFromKey();\n else move(1);\n return;\n case 'ArrowUp':\n e.preventDefault();\n if (!open) openFromKey();\n else move(-1);\n return;\n case 'Home':\n case 'End':\n if (open) {\n e.preventDefault();\n pick(e.key === 'Home' ? firstEnabledKey() : lastEnabledKey());\n }\n return;\n case 'Enter':\n // Closed: let the form have its Enter. Open: it is for the list, never a submit.\n if (open) {\n e.preventDefault();\n if (activeIndex >= 0) choose(visible[activeIndex]);\n }\n return;\n case 'Escape':\n if (open) {\n e.preventDefault();\n // Only the list closes: a Dialog around the field keeps its own Esc for the next press.\n // (`stopImmediate...` too: React may listen on `document`, where the Dialog listens as well.)\n e.stopPropagation();\n e.nativeEvent.stopImmediatePropagation();\n settle();\n }\n return;\n default:\n }\n };\n\n // Select the text on the way in, so typing replaces the label instead of appending to it. The click\n // that gave the focus would put the caret back, hence the second select.\n const selectOnClick = React.useRef(false);\n\n const fieldAria = fieldA11y(rid, { hint, error, required });\n const rowPadY = menuRowPadY(coarse, size);\n const fontSize = size === 'sm' ? 'var(--text-sm)' : 'var(--text-base)';\n const showClear = clearable && !disabled && text !== '';\n\n const list = (\n <div\n ref={panelRef}\n // Keeps the focus in the text box: pressing the list (or its scrollbar) must not blur it.\n onMouseDown={(e) => e.preventDefault()}\n style={sx({\n ...menuSurfaceStyle(size),\n display: 'flex',\n flexDirection: 'column',\n overflow: 'hidden',\n maxHeight: place?.maxH,\n ...(place?.strategy === 'fixed'\n ? {\n position: 'fixed',\n top: place.top,\n left: place.left,\n width: place.width,\n ...(place.above ? { transform: 'translateY(-100%)' } : null),\n zIndex: 1100,\n }\n : {\n position: 'absolute',\n left: 0,\n right: 0,\n ...(place?.above ? { bottom: 'calc(100% + 6px)' } : { top: 'calc(100% + 6px)' }),\n zIndex: 100,\n }),\n })}\n >\n <ul\n ref={listRef}\n id={listboxId}\n role=\"listbox\"\n aria-label={ariaLabel ?? label}\n aria-busy={loading || undefined}\n tabIndex={-1}\n style={sx({\n ...menuListStyle,\n position: 'relative', // so an option's offsetTop is measured from the list\n flex: '1 1 auto',\n minHeight: 0,\n padding: rows ? 'var(--space-1)' : 0,\n overscrollBehavior: 'contain', // don't chain the list's scroll to the page\n })}\n >\n {visible.map((o, i) => (\n <MenuOption\n key={o.value}\n id={`${rid}-opt-${i}`}\n label={o.label}\n selected={o.value === selectedKey}\n active={i === activeIndex}\n disabled={o.disabled}\n coarse={coarse}\n padY={rowPadY}\n // Pointer *move*, not enter: a list that scrolls under a still mouse (the keyboard\n // revealing a row) must not hand the highlight to whatever slid beneath it.\n onPointerMove={() => !o.disabled && pick(o.value)}\n onClick={() => choose(o)}\n />\n ))}\n </ul>\n {status && (\n // Loading is a lone spinner, no text and no rule above it: a screen reader gets the words from the\n // live region below, and this is for the eye. \"No results\" is the same row with words.\n <div\n aria-hidden=\"true\"\n style={sx({\n flex: '0 0 auto',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n minHeight: coarse ? 44 : undefined,\n padding: 'var(--space-3)',\n color: 'var(--text-muted)',\n fontSize: coarse ? 'var(--text-base)' : 'var(--text-sm)',\n })}\n >\n {loading ? (\n <span\n style={sx({\n flex: '0 0 auto',\n width: 18,\n height: 18,\n borderRadius: '999px',\n border: '2px solid var(--border-default)',\n borderTopColor: 'var(--text-brand)',\n animation: 'sereno-spin .7s linear infinite',\n })}\n />\n ) : (\n status\n )}\n </div>\n )}\n </div>\n );\n\n return (\n <Field label={label} hint={hint} error={error} required={required} requiredExposed htmlFor={rid} style={containerStyle} preserveHelperSpace={preserveHelperSpace}>\n <div style={sx({ position: 'relative', width: '100%' })}>\n <div\n ref={boxRef}\n // The padding around the text is part of the field: pressing it puts the caret in the box.\n onMouseDown={(e) => {\n if (e.target === inputRef.current || disabled) return;\n e.preventDefault();\n inputRef.current?.focus();\n }}\n style={sx({ ...fieldBoxStyle(size, !!error, focused || open, !!disabled), cursor: disabled ? 'not-allowed' : 'text' })}\n >\n <input\n ref={inputRef}\n id={rid}\n type=\"text\"\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n aria-autocomplete=\"list\"\n aria-expanded={open}\n aria-controls={open ? listboxId : undefined}\n aria-activedescendant={open && activeId ? activeId : undefined}\n aria-label={ariaLabel}\n {...fieldAria}\n // A text box that looks like a name or an address draws the browser's autofill and the\n // password managers. Best effort: Chrome ignores `autoComplete=\"off\"`, and Bitwarden only\n // honors its attribute when the user turned that option on.\n autoComplete=\"off\"\n autoCorrect=\"off\"\n autoCapitalize=\"off\"\n spellCheck={false}\n enterKeyHint=\"done\"\n data-1p-ignore\n data-lpignore=\"true\"\n data-bwignore=\"true\"\n data-form-type=\"other\"\n disabled={disabled}\n placeholder={placeholder ?? copy.placeholder}\n value={text}\n onChange={onChange}\n onKeyDown={onKeyDown}\n onFocus={(e) => {\n setFocused(true);\n selectOnClick.current = true;\n e.currentTarget.select();\n }}\n onBlur={(e) => {\n setFocused(false);\n if (boxRef.current?.contains(e.relatedTarget as Node | null)) return;\n settle();\n }}\n onClick={(e) => {\n const el = e.currentTarget;\n if (selectOnClick.current && el.selectionStart === el.selectionEnd) el.select();\n selectOnClick.current = false;\n if (!open) openFromPointer();\n }}\n style={sx({\n flex: 1,\n minWidth: 0,\n margin: 0,\n padding: 0, // reset the UA input padding - the box's own padding insets it\n border: 'none',\n outline: 'none',\n background: 'transparent',\n fontFamily: 'var(--font-body)',\n fontSize,\n lineHeight: 1.2,\n textOverflow: 'ellipsis',\n color: disabled ? 'var(--text-disabled)' : 'var(--text-primary)',\n })}\n />\n {showClear && (\n <button\n type=\"button\"\n className=\"ds-affix-btn\"\n tabIndex={-1}\n aria-label={copy.clear}\n onMouseDown={(e) => e.preventDefault()}\n onClick={clear}\n >\n <X size={16} strokeWidth={2} />\n </button>\n )}\n <button\n type=\"button\"\n className=\"ds-affix-btn\"\n tabIndex={-1}\n disabled={disabled}\n aria-label={open ? copy.close : copy.open}\n onMouseDown={(e) => e.preventDefault()}\n onClick={() => {\n inputRef.current?.focus({ preventScroll: true });\n if (open) settle();\n else openFromPointer();\n }}\n style={sx({\n transition: 'transform var(--duration-fast) var(--ease-standard)',\n transform: open ? 'rotate(180deg)' : 'none',\n })}\n >\n <ChevronDown size={16} strokeWidth={1.75} />\n </button>\n </div>\n\n {open && place && place.strategy === 'inline' && list}\n {open && place && place.strategy === 'fixed' && createPortal(list, document.body)}\n\n {/* Always rendered, so the change of its text is what a screen reader announces. */}\n <div role=\"status\" aria-live=\"polite\" style={srOnlyStyle}>\n {open ? (loading ? copy.loading : rows === 0 ? copy.empty : copy.results(rows)) : ''}\n </div>\n </div>\n {name && <input ref={ref} type=\"hidden\" name={name} value={value?.value ?? ''} />}\n </Field>\n );\n});\n\nAutocomplete.displayName = 'Autocomplete';\n"],"mappings":";AAkbI,SA6CM,KA7CN;AAhbJ,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAC7B,SAAS,aAAa,SAAS;AAC/B,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAC5B,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,0BAA0B;AACnC,SAAS,iBAAiB;AAC1B,SAAS,wBAAwB;AACjC,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAChC,SAAS,cAAc,uBAAuB;AAC9C,SAAS,YAAY,eAAe,aAAa,wBAAwB;AACzE,SAAS,qBAAqB;AA0B9B,MAAM,OAAmD;AAAA,EACvD,SAAS;AAAA,IACP,aAAa;AAAA,IACb,OAAO;AAAA,IACP,MAAM;AAAA,IACN,OAAO;AAAA,IACP,SAAS;AAAA,IACT,OAAO;AAAA,IACP,SAAS,CAAC,MAAO,MAAM,IAAI,gBAAgB,IAAI;AAAA,EACjD;AAAA,EACA,IAAI;AAAA,IACF,aAAa;AAAA,IACb,OAAO;AAAA,IACP,MAAM;AA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AAAA;AAAA;AAAA,MACF;AAAA,MAEC,QAAQ,SAAS,MAAM,aAAa,YAAY;AAAA,MAChD,QAAQ,SAAS,MAAM,aAAa,WAAW,aAAa,MAAM,SAAS,IAAI;AAAA,MAGhF,oBAAC,SAAI,MAAK,UAAS,aAAU,UAAS,OAAO,aAC1C,iBAAQ,UAAU,KAAK,UAAU,SAAS,IAAI,KAAK,QAAQ,KAAK,QAAQ,IAAI,IAAK,IACpF;AAAA,OACF;AAAA,IACC,QAAQ,oBAAC,WAAM,KAAU,MAAK,UAAS,MAAY,OAAO,OAAO,SAAS,IAAI;AAAA,KACjF;AAEJ,CAAC;AAED,aAAa,cAAc;","names":["Autocomplete","list"]}
1
+ {"version":3,"sources":["../../src/forms/Autocomplete.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { ChevronDown, X } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { srOnlyStyle } from '../_internal/srOnly';\nimport { Field } from '../_internal/Field';\nimport { fieldA11y } from '../_internal/fieldA11y';\nimport { useIsoLayoutEffect } from '../_internal/useIsoLayoutEffect';\nimport { useLatest } from '../_internal/useLatest';\nimport { useCoarsePointer } from '../_internal/useCoarsePointer';\nimport { useMenuPlacement } from '../_internal/useMenuPlacement';\nimport { useOutsidePress } from '../_internal/useOutsidePress';\nimport { revealInList, useRevealActive } from '../_internal/useRevealActive';\nimport { MenuOption, menuListStyle, menuRowPadY, menuSurfaceStyle } from '../_internal/MenuOption';\nimport { fieldBoxStyle } from './_internal/fieldBoxStyle';\nimport { fieldBoxProps } from './_internal/fieldFrame';\n\nexport interface AutocompleteOption {\n value: string;\n label: string;\n disabled?: boolean;\n}\n\n/** Every string the component says. Defaults come from `locale`; pass `labels` to change some. */\nexport interface AutocompleteLabels {\n /** Placeholder of the text box while nothing is chosen. */\n placeholder: string;\n /** aria-label of the clear (×) button. */\n clear: string;\n /** aria-label of the chevron button while the list is closed. */\n open: string;\n /** aria-label of the chevron button while the list is open. */\n close: string;\n /** What a screen reader hears while `loading` (the list itself shows only a spinner). */\n loading: string;\n /** The row shown when no option is left to show. */\n empty: string;\n /** What a screen reader hears when the list changes size. */\n results: (count: number) => string;\n}\n\nconst TEXT: Record<'pt-BR' | 'en', AutocompleteLabels> = {\n 'pt-BR': {\n placeholder: 'Buscar…',\n clear: 'Limpar seleção',\n open: 'Abrir lista',\n close: 'Fechar lista',\n loading: 'Carregando…',\n empty: 'Nenhum resultado',\n results: (n) => (n === 1 ? '1 resultado' : n + ' resultados'),\n },\n en: {\n placeholder: 'Search…',\n clear: 'Clear selection',\n open: 'Open list',\n close: 'Close list',\n loading: 'Loading…',\n empty: 'No results',\n results: (n) => (n === 1 ? '1 result' : n + ' results'),\n },\n};\n\n/**\n * Single choice from a list you search by typing. Like `Select`, but the box is a text field: type\n * to narrow the list, pick one row, and the value is that row. For a list too long to scroll\n * (past ~12 options), or one the server searches and pages (a thousand clients, fifty at a time).\n *\n * The value is the chosen option itself, `{ value, label }`, and it carries its own label. The\n * box shows `value.label` whether or not that option is in `options` right now, which is what\n * keeps the label when the page it came from is no longer loaded. `options` is only what the list\n * shows. `onValueChange` gives the option (or `null` when cleared), not a string.\n *\n * Two kinds of search, one prop apart:\n * - the default filters `options` itself, as you type (case and accents ignored);\n * - `filter={false}` leaves the list alone and tells you what was typed (`onSearch`, debounced),\n * for a list the server already filtered.\n *\n * It is a text box, not free text: what is typed never becomes the value. Leaving the box puts the\n * chosen label back.\n */\nexport interface AutocompleteProps {\n label?: string;\n hint?: string;\n /** Error message; also turns the control red. */\n error?: string;\n required?: boolean;\n /** What the list shows now. Appending rows while it is open is fine: the list keeps its scroll. */\n options?: AutocompleteOption[];\n /** Controlled value: the chosen option, or `null` for none. */\n value?: AutocompleteOption | null;\n /** Uncontrolled initial value. */\n defaultValue?: AutocompleteOption | null;\n /** The chosen option, or `null` when the value is cleared. */\n onValueChange?: (option: AutocompleteOption | null) => void;\n /**\n * How typing narrows `options`. `true` (default): keep the rows whose label contains the text,\n * ignoring case and accents. `false`: show `options` as they are (the server did the filtering).\n * A function decides per row.\n */\n filter?: boolean | ((option: AutocompleteOption, query: string) => boolean);\n /**\n * The text to search for changed: fired as the user types (after `debounce`) and with `''` once\n * the box goes back to showing the chosen label (pick, clear, leave, Esc). Never with the label\n * itself, so it is safe to run the query here. Use it with `filter={false}`.\n */\n onSearch?: (query: string) => void;\n /** Debounce for `onSearch` while typing, in ms. */\n debounce?: number;\n /** The list is waiting for rows: a spinner under them (or alone), the list marked busy, and a screen reader told. */\n loading?: boolean;\n /**\n * The list was scrolled to within about five rows of its end. Fires once per list size, never\n * while `loading`. Pass it only while there is a next page, so a list that is complete asks for nothing.\n */\n onReachEnd?: () => void;\n /** The list opened or closed. For a list that loads when it opens. */\n onOpenChange?: (open: boolean) => void;\n /** A × button, and an emptied box clears the value. */\n clearable?: boolean;\n /** Shown in muted text while nothing is chosen. Defaults to the `locale` text. */\n placeholder?: string;\n size?: 'sm' | 'md' | 'lg';\n disabled?: boolean;\n /** Form field name - mirrored to a hidden input so the chosen value can be submitted. */\n name?: string;\n id?: string;\n containerStyle?: React.CSSProperties;\n /**\n * Accessible name for the text box. Only needed when there's no visible `label`. Takes\n * precedence over `label` if both are set - don't pass both.\n */\n 'aria-label'?: string;\n /** Reserve the hint/error row's height even with neither set - stops the field from growing\n * the moment a validation message appears. */\n preserveHelperSpace?: boolean;\n /** Language of the built-in texts. */\n locale?: 'pt-BR' | 'en';\n /** Override any built-in text. */\n labels?: Partial<AutocompleteLabels>;\n}\n\n/** How close to the end of the list, in rows, `onReachEnd` fires. */\nconst REACH_ROWS = 5;\n\nconst MARKS = /[̀-ͯ]/g;\nconst plain = (s: string) => s.normalize('NFD').replace(MARKS, '').toLowerCase();\n\nfunction narrow(\n options: AutocompleteOption[],\n filter: AutocompleteProps['filter'],\n query: string,\n): AutocompleteOption[] {\n if (filter === false) return options;\n const q = query.trim();\n if (!q) return options;\n if (typeof filter === 'function') return options.filter((o) => filter(o, query));\n const needle = plain(q);\n return options.filter((o) => plain(o.label).includes(needle));\n}\n\n/**\n * `ref` reaches the hidden `<input type=\"hidden\">` that mirrors the chosen value (rendered only\n * when `name` is set - pass it, as `register()` does), the same as `Select`. A plain\n * `{...register(name)}` spread still won't validate on change: wire it through `Controller`, or\n * call the registered `onChange` yourself from `onValueChange`.\n */\nexport const Autocomplete = React.forwardRef<HTMLInputElement, AutocompleteProps>(function Autocomplete(\n {\n label,\n hint,\n error,\n required,\n options = [],\n value: valueProp,\n defaultValue,\n onValueChange,\n filter = true,\n onSearch,\n debounce = 250,\n loading = false,\n onReachEnd,\n onOpenChange,\n clearable = true,\n placeholder,\n size = 'md',\n disabled,\n name,\n id,\n containerStyle,\n 'aria-label': ariaLabel,\n preserveHelperSpace,\n locale = 'pt-BR',\n labels,\n },\n ref,\n) {\n const reactId = React.useId();\n const rid = id || reactId;\n const listboxId = `${rid}-listbox`;\n const copy: AutocompleteLabels = { ...TEXT[locale], ...labels };\n const coarse = useCoarsePointer();\n\n const inputRef = React.useRef<HTMLInputElement>(null);\n const boxRef = React.useRef<HTMLDivElement>(null);\n const panelRef = React.useRef<HTMLDivElement>(null);\n const listRef = React.useRef<HTMLUListElement>(null);\n\n // ── value: the chosen option, with its own label ──\n const isControlled = valueProp !== undefined;\n const [inner, setInner] = React.useState<AutocompleteOption | null>(defaultValue ?? null);\n const value = isControlled ? valueProp : inner;\n const valueLabel = value?.label ?? '';\n\n // ── the text box: the chosen label, until the user types (`draft`) ──\n const [draft, setDraft] = React.useState<string | null>(null);\n const text = draft ?? valueLabel;\n const query = draft ?? '';\n\n const [open, setOpen] = React.useState(false);\n const [activeKey, setActiveKey] = React.useState<string | null>(null);\n // The active row is the chosen one only because the list opened on it, not because the user went\n // there: set by opening, cleared by the first thing the user does to the highlight.\n const activeFromOpen = React.useRef(false);\n const pick = (key: string | null) => {\n activeFromOpen.current = false;\n setActiveKey(key);\n };\n\n const visible = React.useMemo(() => narrow(options, filter, query), [options, filter, query]);\n const activeIndex = activeKey === null ? -1 : visible.findIndex((o) => o.value === activeKey && !o.disabled);\n const activeId = activeIndex >= 0 ? `${rid}-opt-${activeIndex}` : null;\n\n const rows = visible.length;\n const status = loading ? copy.loading : rows === 0 ? copy.empty : null;\n\n // ── open / close, told to the app once per change ──\n const onOpenChangeRef = useLatest(onOpenChange);\n const toldOpen = React.useRef(false);\n React.useEffect(() => {\n if (toldOpen.current === open) return;\n toldOpen.current = open;\n onOpenChangeRef.current?.(open);\n }, [open, onOpenChangeRef]);\n\n // ── search: told to the app when the query changes, debounced while typing ──\n const onSearchRef = useLatest(onSearch);\n const searchTimer = React.useRef<number | undefined>(undefined);\n const toldQuery = React.useRef('');\n React.useEffect(() => () => window.clearTimeout(searchTimer.current), []);\n const search = (q: string, immediate: boolean) => {\n window.clearTimeout(searchTimer.current);\n const run = () => {\n if (q === toldQuery.current) return;\n toldQuery.current = q;\n onSearchRef.current?.(q);\n };\n if (immediate) run();\n else searchTimer.current = window.setTimeout(run, debounce);\n };\n\n /** The box goes back to the chosen label: closes the list, drops what was typed, resets the query. */\n const settle = () => {\n setOpen(false);\n setDraft(null);\n search('', true);\n };\n\n const place = useMenuPlacement({\n open,\n anchorRef: boxRef,\n panelRef,\n itemCount: rows + (status ? 1 : 0),\n onDismiss: () => settle(),\n });\n // The chosen row can arrive after the list opened (a list that loads when it opens, on the page around\n // the chosen row). It is brought into view then, unless the user has already scrolled the list away\n // from the top: a user paging down for the next page is not carried off to a row that just landed.\n useRevealActive(open, activeId, place, revealInList, (el) => !activeFromOpen.current || (el.parentElement?.scrollTop ?? 0) === 0);\n\n // ── pagination: ask for more once the list is near its end ──\n const onReachEndRef = useLatest(onReachEnd);\n const askedFor = React.useRef<string | null>(null);\n // What the list is, for \"once per size\": a new search that happens to return as many rows is a new list.\n const shape = options.length + '|' + (options[0]?.value ?? '') + '|' + (options[options.length - 1]?.value ?? '');\n useIsoLayoutEffect(() => {\n if (!open) {\n askedFor.current = null;\n return;\n }\n const list = listRef.current;\n if (!list || rows === 0) return;\n const check = () => {\n if (loading || !onReachEndRef.current || askedFor.current === shape) return;\n const remaining = list.scrollHeight - list.scrollTop - list.clientHeight;\n if (remaining > (list.scrollHeight / rows) * REACH_ROWS) return;\n askedFor.current = shape;\n onReachEndRef.current();\n };\n check();\n list.addEventListener('scroll', check, { passive: true });\n return () => list.removeEventListener('scroll', check);\n }, [open, loading, shape, place, rows, onReachEndRef]);\n\n // A new search starts at the top.\n const firstValue = options[0]?.value;\n useIsoLayoutEffect(() => {\n if (draft !== null && listRef.current) listRef.current.scrollTop = 0;\n }, [draft, firstValue]);\n\n // iOS keeps the keyboard (and the field) up when you tap on plain page: close on any press outside.\n useOutsidePress(open, [boxRef, panelRef], () => settle());\n\n // ── choosing ──\n const firstEnabledKey = () => visible.find((o) => !o.disabled)?.value ?? null;\n const lastEnabledKey = () => {\n for (let i = rows - 1; i >= 0; i--) if (!visible[i].disabled) return visible[i].value;\n return null;\n };\n const move = (dir: 1 | -1) => {\n let i = activeIndex < 0 ? (dir === 1 ? -1 : rows) : activeIndex;\n for (let step = 0; step < rows; step++) {\n i += dir;\n if (i < 0 || i >= rows) return; // the ends are walls, not a loop: a paged list has no \"wrap\"\n if (!visible[i].disabled) {\n pick(visible[i].value);\n return;\n }\n }\n };\n\n const choose = (o: AutocompleteOption) => {\n if (o.disabled) return;\n if (!isControlled) setInner(o);\n onValueChange?.(o);\n setOpen(false);\n setDraft(null);\n search('', true);\n // On a phone the keyboard goes with the choice.\n if (coarse) inputRef.current?.blur();\n };\n const clear = () => {\n if (value) {\n if (!isControlled) setInner(null);\n onValueChange?.(null);\n }\n setDraft(''); // empty at once, even if the app takes a moment to take the value away\n search('', true);\n inputRef.current?.focus();\n };\n\n const selectedKey = value?.value;\n // Opening starts on the chosen row. If it is not in the list *yet* because the list is empty (it\n // loads when it opens), it stays the active one so it is revealed when it arrives. With rows on screen\n // that do not include it, it is not chased: the list is not moved under the user later.\n const startKey = (fallback: string | null) =>\n selectedKey !== undefined && (rows === 0 || visible.some((o) => o.value === selectedKey)) ? selectedKey : fallback;\n const openFromPointer = () => {\n activeFromOpen.current = true;\n setActiveKey(startKey(null));\n setOpen(true);\n };\n const openFromKey = () => {\n activeFromOpen.current = true;\n setActiveKey(startKey(firstEnabledKey()));\n setOpen(true);\n };\n\n const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const next = e.currentTarget.value;\n setDraft(next);\n // Filtering here, the first match is ready for Enter. A server search has not answered yet:\n // an Enter now would pick a row of the old answer, so nothing is active until the user moves.\n pick(filter === false ? null : narrow(options, filter, next).find((o) => !o.disabled)?.value ?? null);\n setOpen(true);\n if (next === '' && clearable && value) {\n if (!isControlled) setInner(null);\n onValueChange?.(null);\n }\n search(next, false);\n };\n\n const onKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (disabled || e.nativeEvent.isComposing) return; // an IME is still composing the text\n switch (e.key) {\n case 'ArrowDown':\n e.preventDefault();\n if (!open) openFromKey();\n else move(1);\n return;\n case 'ArrowUp':\n e.preventDefault();\n if (!open) openFromKey();\n else move(-1);\n return;\n case 'Home':\n case 'End':\n if (open) {\n e.preventDefault();\n pick(e.key === 'Home' ? firstEnabledKey() : lastEnabledKey());\n }\n return;\n case 'Enter':\n // Closed: let the form have its Enter. Open: it is for the list, never a submit.\n if (open) {\n e.preventDefault();\n if (activeIndex >= 0) choose(visible[activeIndex]);\n }\n return;\n case 'Escape':\n if (open) {\n e.preventDefault();\n // Only the list closes: a Dialog around the field keeps its own Esc for the next press.\n // (`stopImmediate...` too: React may listen on `document`, where the Dialog listens as well.)\n e.stopPropagation();\n e.nativeEvent.stopImmediatePropagation();\n settle();\n }\n return;\n default:\n }\n };\n\n // Select the text on the way in, so typing replaces the label instead of appending to it. The click\n // that gave the focus would put the caret back, hence the second select.\n const selectOnClick = React.useRef(false);\n\n const fieldAria = fieldA11y(rid, { hint, error, required });\n const rowPadY = menuRowPadY(coarse, size);\n const fontSize = size === 'sm' ? 'var(--text-sm)' : 'var(--text-base)';\n const showClear = clearable && !disabled && text !== '';\n\n const list = (\n <div\n ref={panelRef}\n // Keeps the focus in the text box: pressing the list (or its scrollbar) must not blur it.\n onMouseDown={(e) => e.preventDefault()}\n style={sx({\n ...menuSurfaceStyle(size),\n display: 'flex',\n flexDirection: 'column',\n overflow: 'hidden',\n maxHeight: place?.maxH,\n ...(place?.strategy === 'fixed'\n ? {\n position: 'fixed',\n top: place.top,\n left: place.left,\n width: place.width,\n ...(place.above ? { transform: 'translateY(-100%)' } : null),\n zIndex: 1100,\n }\n : {\n position: 'absolute',\n left: 0,\n right: 0,\n ...(place?.above ? { bottom: 'calc(100% + 6px)' } : { top: 'calc(100% + 6px)' }),\n zIndex: 100,\n }),\n })}\n >\n <ul\n ref={listRef}\n id={listboxId}\n role=\"listbox\"\n aria-label={ariaLabel ?? label}\n aria-busy={loading || undefined}\n tabIndex={-1}\n style={sx({\n ...menuListStyle,\n position: 'relative', // so an option's offsetTop is measured from the list\n flex: '1 1 auto',\n minHeight: 0,\n padding: rows ? 'var(--space-1)' : 0,\n overscrollBehavior: 'contain', // don't chain the list's scroll to the page\n })}\n >\n {visible.map((o, i) => (\n <MenuOption\n key={o.value}\n id={`${rid}-opt-${i}`}\n label={o.label}\n selected={o.value === selectedKey}\n active={i === activeIndex}\n disabled={o.disabled}\n coarse={coarse}\n padY={rowPadY}\n // Pointer *move*, not enter: a list that scrolls under a still mouse (the keyboard\n // revealing a row) must not hand the highlight to whatever slid beneath it.\n onPointerMove={() => !o.disabled && pick(o.value)}\n onClick={() => choose(o)}\n />\n ))}\n </ul>\n {status && (\n // Loading is a lone spinner, no text and no rule above it: a screen reader gets the words from the\n // live region below, and this is for the eye. \"No results\" is the same row with words.\n <div\n aria-hidden=\"true\"\n style={sx({\n flex: '0 0 auto',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n minHeight: coarse ? 44 : undefined,\n padding: 'var(--space-3)',\n color: 'var(--text-muted)',\n fontSize: coarse ? 'var(--text-base)' : 'var(--text-sm)',\n })}\n >\n {loading ? (\n <span\n style={sx({\n flex: '0 0 auto',\n width: 18,\n height: 18,\n borderRadius: '999px',\n border: '2px solid var(--border-default)',\n borderTopColor: 'var(--text-brand)',\n animation: 'sereno-spin .7s linear infinite',\n })}\n />\n ) : (\n status\n )}\n </div>\n )}\n </div>\n );\n\n return (\n <Field label={label} hint={hint} error={error} required={required} requiredExposed htmlFor={rid} style={containerStyle} preserveHelperSpace={preserveHelperSpace}>\n <div style={sx({ position: 'relative', width: '100%' })}>\n <div\n ref={boxRef}\n // The padding around the text is part of the field: pressing it puts the caret in the box.\n onMouseDown={(e) => {\n if (e.target === inputRef.current || disabled) return;\n e.preventDefault();\n inputRef.current?.focus();\n }}\n // The focus ring comes from the `:focus` of the text box (styles.css); only the open list is state here.\n {...fieldBoxProps(open)}\n style={sx({ ...fieldBoxStyle(size, !!error, !!disabled), cursor: disabled ? 'not-allowed' : 'text' })}\n >\n <input\n ref={inputRef}\n id={rid}\n type=\"text\"\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n aria-autocomplete=\"list\"\n aria-expanded={open}\n aria-controls={open ? listboxId : undefined}\n aria-activedescendant={open && activeId ? activeId : undefined}\n aria-label={ariaLabel}\n {...fieldAria}\n // A text box that looks like a name or an address draws the browser's autofill and the\n // password managers. Best effort: Chrome ignores `autoComplete=\"off\"`, and Bitwarden only\n // honors its attribute when the user turned that option on.\n autoComplete=\"off\"\n autoCorrect=\"off\"\n autoCapitalize=\"off\"\n spellCheck={false}\n enterKeyHint=\"done\"\n data-1p-ignore\n data-lpignore=\"true\"\n data-bwignore=\"true\"\n data-form-type=\"other\"\n disabled={disabled}\n placeholder={placeholder ?? copy.placeholder}\n value={text}\n onChange={onChange}\n onKeyDown={onKeyDown}\n onFocus={(e) => {\n selectOnClick.current = true;\n e.currentTarget.select();\n }}\n onBlur={(e) => {\n if (boxRef.current?.contains(e.relatedTarget as Node | null)) return;\n settle();\n }}\n onClick={(e) => {\n const el = e.currentTarget;\n if (selectOnClick.current && el.selectionStart === el.selectionEnd) el.select();\n selectOnClick.current = false;\n if (!open) openFromPointer();\n }}\n style={sx({\n flex: 1,\n minWidth: 0,\n margin: 0,\n padding: 0, // reset the UA input padding - the box's own padding insets it\n border: 'none',\n outline: 'none',\n background: 'transparent',\n fontFamily: 'var(--font-body)',\n fontSize,\n lineHeight: 1.2,\n textOverflow: 'ellipsis',\n color: disabled ? 'var(--text-disabled)' : 'var(--text-primary)',\n })}\n />\n {showClear && (\n <button\n type=\"button\"\n className=\"ds-affix-btn\"\n tabIndex={-1}\n aria-label={copy.clear}\n onMouseDown={(e) => e.preventDefault()}\n onClick={clear}\n >\n <X size={16} strokeWidth={2} />\n </button>\n )}\n <button\n type=\"button\"\n className=\"ds-affix-btn\"\n tabIndex={-1}\n disabled={disabled}\n aria-label={open ? copy.close : copy.open}\n onMouseDown={(e) => e.preventDefault()}\n onClick={() => {\n inputRef.current?.focus({ preventScroll: true });\n if (open) settle();\n else openFromPointer();\n }}\n style={sx({\n transition: 'transform var(--duration-fast) var(--ease-standard)',\n transform: open ? 'rotate(180deg)' : 'none',\n })}\n >\n <ChevronDown size={16} strokeWidth={1.75} />\n </button>\n </div>\n\n {open && place && place.strategy === 'inline' && list}\n {open && place && place.strategy === 'fixed' && createPortal(list, document.body)}\n\n {/* Always rendered, so the change of its text is what a screen reader announces. */}\n <div role=\"status\" aria-live=\"polite\" style={srOnlyStyle}>\n {open ? (loading ? copy.loading : rows === 0 ? copy.empty : copy.results(rows)) : ''}\n </div>\n </div>\n {name && <input ref={ref} type=\"hidden\" name={name} value={value?.value ?? ''} />}\n </Field>\n );\n});\n\nAutocomplete.displayName = 'Autocomplete';\n"],"mappings":";AAkbI,SA6CM,KA7CN;AAhbJ,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAC7B,SAAS,aAAa,SAAS;AAC/B,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAC5B,SAAS,aAAa;AACtB,SAAS,iBAAi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,WAAU;AAAA,gBACV,UAAU;AAAA,gBACV;AAAA,gBACA,cAAY,OAAO,KAAK,QAAQ,KAAK;AAAA,gBACrC,aAAa,CAAC,MAAM,EAAE,eAAe;AAAA,gBACrC,SAAS,MAAM;AACb,2BAAS,SAAS,MAAM,EAAE,eAAe,KAAK,CAAC;AAC/C,sBAAI,KAAM,QAAO;AAAA,sBACZ,iBAAgB;AAAA,gBACvB;AAAA,gBACA,OAAO,GAAG;AAAA,kBACR,YAAY;AAAA,kBACZ,WAAW,OAAO,mBAAmB;AAAA,gBACvC,CAAC;AAAA,gBAED,8BAAC,eAAY,MAAM,IAAI,aAAa,MAAM;AAAA;AAAA,YAC5C;AAAA;AAAA;AAAA,MACF;AAAA,MAEC,QAAQ,SAAS,MAAM,aAAa,YAAY;AAAA,MAChD,QAAQ,SAAS,MAAM,aAAa,WAAW,aAAa,MAAM,SAAS,IAAI;AAAA,MAGhF,oBAAC,SAAI,MAAK,UAAS,aAAU,UAAS,OAAO,aAC1C,iBAAQ,UAAU,KAAK,UAAU,SAAS,IAAI,KAAK,QAAQ,KAAK,QAAQ,IAAI,IAAK,IACpF;AAAA,OACF;AAAA,IACC,QAAQ,oBAAC,WAAM,KAAU,MAAK,UAAS,MAAY,OAAO,OAAO,SAAS,IAAI;AAAA,KACjF;AAEJ,CAAC;AAED,aAAa,cAAc;","names":["Autocomplete","list"]}
@@ -12,6 +12,7 @@ import { useOutsidePress } from "../_internal/useOutsidePress.js";
12
12
  import { CalendarGrid } from "./_internal/CalendarGrid.js";
13
13
  import { parseISODate as parseISO, toISODate as toISO } from "./_internal/calendarRange.js";
14
14
  import { fieldBoxStyle } from "./_internal/fieldBoxStyle.js";
15
+ import { fieldBoxProps } from "./_internal/fieldFrame.js";
15
16
  const TEXT = {
16
17
  "pt-BR": { placeholder: "Selecionar data", dialogLabel: "Escolher data", clearLabel: "Limpar data" },
17
18
  en: { placeholder: "Pick a date", dialogLabel: "Choose a date", clearLabel: "Clear date" }
@@ -188,7 +189,7 @@ const DatePicker = React.forwardRef(function DatePicker2({
188
189
  }
189
190
  );
190
191
  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: [
191
- /* @__PURE__ */ jsxs("div", { ref: boxRef, onKeyDown: onBoxKeyDown, style: fieldBoxStyle(size, !!error, open, disabled), children: [
192
+ /* @__PURE__ */ jsxs("div", { ref: boxRef, onKeyDown: onBoxKeyDown, ...fieldBoxProps(open), style: fieldBoxStyle(size, !!error, disabled), children: [
192
193
  /* @__PURE__ */ jsxs(
193
194
  "button",
194
195
  {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/forms/DatePicker.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { Calendar as CalendarIcon, X } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { Field } from '../_internal/Field';\nimport { fieldA11y } from '../_internal/fieldA11y';\nimport { useIsoLayoutEffect } from '../_internal/useIsoLayoutEffect';\nimport { useMenuPlacement } from '../_internal/useMenuPlacement';\nimport { useOutsidePress } from '../_internal/useOutsidePress';\nimport { CalendarGrid } from './_internal/CalendarGrid';\nimport type { CalendarDayContext, CalendarDayDots } from './_internal/calendarDots';\nimport { parseISODate as parseISO, toISODate as toISO } from './_internal/calendarRange';\nimport { fieldBoxStyle } from './_internal/fieldBoxStyle';\n\nconst TEXT = {\n 'pt-BR': { placeholder: 'Selecionar data', dialogLabel: 'Escolher data', clearLabel: 'Limpar data' },\n en: { placeholder: 'Pick a date', dialogLabel: 'Choose a date', clearLabel: 'Clear date' },\n} as const;\n\n/**\n * The widest a calendar gets once it leaves the field's own width, i.e. when portalled out of a Dialog. Its\n * cells are square, so it is as tall as it is wide: at the width of a wide dialog field it would be a\n * 450px-tall slab that covers the field and half the window. Inline it is untouched (still the field's width).\n */\nconst PORTALLED_MAX_WIDTH = 320;\n\n/** What a keyboard can reach inside `root`, in tab order (the calendar's roving day has `tabindex=\"0\"`, the others `-1`). */\nfunction tabbables(root: HTMLElement | null): HTMLElement[] {\n if (!root) return [];\n return Array.from(root.querySelectorAll<HTMLElement>('button:not(:disabled), [tabindex]')).filter((el) => el.tabIndex >= 0);\n}\n\n/**\n * Imperative handle exposed via `ref` - there's no single native element\n * underneath (the trigger is a `<button>`, the value a plain ISO string in\n * React state), so `ref` can't hand back something `.value`-readable the way\n * a real `<input>` would. `focus()` is real and covers `setFocus()`-on-error;\n * reading the current value still means the `value`/`onChange` props, not the\n * ref. `onChange(value: string)` also isn't a `ChangeEvent`, so a plain\n * `{...register(name)}` spread won't work regardless - use `Controller`.\n */\nexport interface DatePickerHandle {\n focus: () => void;\n}\n\nexport interface DatePickerProps {\n label?: string;\n hint?: string;\n error?: string;\n required?: boolean;\n /** Defaults to the `locale`-appropriate text (\"Selecionar data\" / \"Pick a date\"). */\n placeholder?: string;\n size?: 'sm' | 'md' | 'lg';\n disabled?: boolean;\n /** Controlled value, ISO \"YYYY-MM-DD\". */\n value?: string;\n /** Uncontrolled initial value, ISO \"YYYY-MM-DD\". */\n defaultValue?: string;\n onChange?: (value: string) => void;\n /**\n * Earliest selectable date, ISO \"YYYY-MM-DD\". Every day before it is struck through, and the\n * calendar cannot be navigated to an earlier month or year (the previous-month arrow disables,\n * PageUp and the arrow keys stop at the edge, the month / year popover disables what is out of\n * range). An initial value or month before it opens on `min`'s month.\n */\n min?: string;\n /** Latest selectable date, ISO \"YYYY-MM-DD\". The mirror image of `min`: later days are struck through and later months and years cannot be reached. */\n max?: string;\n /**\n * Fires when the month on screen changes (the arrows, or the month / year popover), with the\n * new year and the 0-indexed month. Not when the popover opens: it opens on the month of the\n * value, or on the current one. Refresh `dayDots` / `renderDay` here.\n */\n onMonthChange?: (year: number, month: number) => void;\n /**\n * Content under each day number (a count, a note), the same as `DateTimePicker`'s. The second\n * argument says whether the day is `selected`, `today` or `unavailable`. When set, the day cells\n * grow taller to hold it.\n */\n renderDay?: (day: number, context: CalendarDayContext) => React.ReactNode;\n /**\n * The days that get a dot under their number, the same as `DateTimePicker`'s: day numbers\n * (`[3, 17]`), or an object keyed by day number for a per-dot `tone` or `label`. Day numbers of\n * the month on screen, so refresh them in `onMonthChange`.\n */\n dayDots?: CalendarDayDots;\n /** What a screen reader says for a dot with no `label` of its own. Defaults to the `locale`-appropriate text. */\n dayDotLabel?: 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\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\n/**\n * Field for picking a single date - no time, no slots (`DateTimePicker`'s\n * job). A text-field-styled trigger showing the selected date opens a\n * popover with the same calendar grid `DateTimePicker` uses (roving\n * tabindex, month/year jump - see `./_internal/CalendarGrid`), so the two\n * share every bit of calendar behavior (SS-243).\n *\n * Value contract matches the rest of the forms package: `value` /\n * `defaultValue` + `onChange(value)`, a plain ISO \"YYYY-MM-DD\" string -\n * drops in wherever `<input type=\"date\">` would go, but themed instead of\n * the browser's own, and in pt-BR by default (the real Sereno product\n * always uses it; `locale=\"en\"` exists only for docs/demo purposes). A\n * clear (×) button appears once a value is set.\n */\nexport const DatePicker = React.forwardRef<DatePickerHandle, DatePickerProps>(function DatePicker(\n {\n label,\n hint,\n error,\n required,\n placeholder,\n size = 'md',\n disabled = false,\n value,\n defaultValue,\n onChange,\n min,\n max,\n onMonthChange,\n renderDay,\n dayDots,\n dayDotLabel,\n id,\n containerStyle,\n clearLabel,\n locale = 'pt-BR',\n preserveHelperSpace,\n },\n ref,\n) {\n const copy = TEXT[locale];\n const [inner, setInner] = React.useState(defaultValue ?? '');\n const iso = value !== undefined ? value : inner;\n const parsed = parseISO(iso);\n const now = React.useMemo(() => new Date(), []);\n\n const [open, setOpen] = React.useState(false);\n // The month currently shown in the popover - resets to the value's month\n // (or today's) every time the popover opens, via the conditional mount\n // below; CalendarGrid itself only takes year/month as its *initial* view.\n const [viewYear, setViewYear] = React.useState(parsed?.year ?? now.getFullYear());\n const [viewMonth, setViewMonth] = React.useState(parsed?.month ?? now.getMonth());\n\n const rootRef = React.useRef<HTMLDivElement>(null);\n const boxRef = React.useRef<HTMLDivElement>(null);\n const popoverRef = React.useRef<HTMLDivElement>(null);\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const generatedId = React.useId();\n const rid = id || generatedId;\n\n React.useImperativeHandle(ref, () => ({ focus: () => triggerRef.current?.focus() }), []);\n\n // Where the calendar sits. Normally a plain `position: absolute` child of\n // `rootRef` (itself `position: relative`) - the same \"inline\" strategy\n // Select's panel uses for its common case, and the same one DateTimePicker's\n // own month/year popover already uses. The browser glues it to the trigger\n // through *any* scroll (page or a nested overflow container) for free - no JS\n // measuring position, no listening for scroll/resize, and critically, it\n // never has to close on scroll the way a `position: fixed` popover computed\n // once would (that was tried first here and didn't hold up - see PR history).\n //\n // The one place that fails is inside a `position: fixed` container (a\n // Dialog): its body scrolls and clips an inline child, cutting the calendar\n // off. There `useMenuPlacement` answers 'fixed' (what Select and\n // Autocomplete already do) and the calendar is portalled to <body> at the\n // field's viewport rect, closing if the field moves. Outside a dialog nothing\n // changes: still inline, still below the field, never flipped (the hook's\n // `above` / `maxH` are not used at all: see `fitTop` for the portalled case).\n // `itemCount` is just the hook's height estimate; a calendar is not a list.\n const place = useMenuPlacement({\n open,\n anchorRef: boxRef,\n panelRef: popoverRef,\n itemCount: 8,\n onDismiss: () => setOpen(false),\n });\n const portalled = open && place?.strategy === 'fixed';\n\n // The hook picks \"below\" or \"above\" from a rough guess at the height, which suits a list capped at 288px but not\n // a calendar (about as tall as it is wide). So once the portalled calendar is on screen it is measured and kept\n // inside the window: under the field if it fits, else above it, else as far up as it needs (over the field rather\n // than cut off). The month changes the row count, hence the dependencies. Runs before paint: no visible jump.\n const [fitTop, setFitTop] = React.useState<number | null>(null);\n useIsoLayoutEffect(() => {\n const popover = popoverRef.current;\n const box = boxRef.current;\n if (!portalled || !popover || !box) return;\n const GAP = 6;\n const EDGE = 8;\n const field = box.getBoundingClientRect();\n const height = popover.offsetHeight;\n const viewport = window.innerHeight || document.documentElement.clientHeight || 900;\n const below = field.bottom + GAP;\n const above = field.top - GAP - height;\n setFitTop(below + height <= viewport - EDGE ? below : above >= EDGE ? above : Math.max(EDGE, viewport - EDGE - height));\n }, [portalled, place, viewYear, viewMonth]);\n\n // A press outside the field closes the calendar. The portalled calendar is outside `rootRef` in the DOM but\n // still part of the field, so both count as inside.\n useOutsidePress(open, [rootRef, popoverRef], () => setOpen(false));\n React.useEffect(() => {\n if (!open) return;\n const onKey = (e: KeyboardEvent) => {\n if (e.key === 'Escape') {\n e.preventDefault(); // handled: a Dialog around the field keeps its own Esc for the next press\n setOpen(false);\n triggerRef.current?.focus();\n }\n };\n document.addEventListener('keydown', onKey, true);\n return () => document.removeEventListener('keydown', onKey, true);\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 // Inline, the calendar follows the field in the DOM, so Tab walks field -> calendar -> next field on its\n // own. Portalled to the end of <body> it does not, so the focus is handed over by hand to keep that order.\n const onBoxKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n if (e.key !== 'Tab' || e.shiftKey || !portalled) return;\n const controls = tabbables(e.currentTarget);\n if (e.target !== controls[controls.length - 1]) return; // not the control the calendar follows\n const first = tabbables(popoverRef.current)[0];\n if (!first) return;\n e.preventDefault();\n first.focus();\n };\n\n const onPopoverKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n if (e.key !== 'Tab') return;\n const controls = tabbables(boxRef.current);\n const field = controls[controls.length - 1]; // the control the calendar follows in the DOM\n const inside = tabbables(e.currentTarget);\n if (e.shiftKey && e.target === inside[0]) {\n e.preventDefault();\n field?.focus();\n } else if (!e.shiftKey && e.target === inside[inside.length - 1]) {\n // Not prevented on purpose: with the focus back on the field the Tab goes on to whatever follows it.\n setOpen(false);\n field?.focus();\n }\n };\n\n // One popover, two positions (see `useMenuPlacement` above): the calendar and its look are the same.\n const renderPopover = (position: React.CSSProperties) => (\n <div\n ref={popoverRef}\n role=\"dialog\"\n aria-label={label || copy.dialogLabel}\n tabIndex={-1}\n onKeyDown={portalled ? onPopoverKeyDown : undefined}\n style={sx({\n ...position,\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 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 min={min}\n max={max}\n onMonthChange={(y, m) => {\n setViewYear(y);\n setViewMonth(m);\n onMonthChange?.(y, m);\n }}\n renderDay={renderDay}\n dayDots={dayDots}\n dayDotLabel={dayDotLabel}\n onSelectDate={commit}\n squareCells\n trimEmptyRows\n locale={locale}\n />\n </div>\n );\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 ref={boxRef} onKeyDown={onBoxKeyDown} style={fieldBoxStyle(size, !!error, open, disabled)}>\n <button\n ref={triggerRef}\n id={rid}\n type=\"button\"\n disabled={disabled}\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n // Ties the trigger to the hint / error line below, so they are read when it takes focus.\n {...fieldA11y(rid, { hint, error })}\n onClick={() => (open ? setOpen(false) : openPopover())}\n style={sx({\n flex: 1,\n minWidth: 0,\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-2)',\n border: 'none',\n background: 'transparent',\n padding: 0,\n font: 'inherit',\n color: 'inherit',\n cursor: 'inherit',\n textAlign: 'left',\n })}\n >\n <CalendarIcon size={16} strokeWidth={1.75} style={{ flex: '0 0 auto', opacity: 0.7 }} />\n <span\n style={sx({\n flex: 1,\n textAlign: 'left',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n color: iso ? 'inherit' : 'var(--text-muted)',\n })}\n >\n {iso ? formatDisplay(iso, locale) : (placeholder ?? copy.placeholder)}\n </span>\n </button>\n {iso && !disabled && (\n <button\n type=\"button\"\n aria-label={clearLabel ?? copy.clearLabel}\n onClick={(e) => {\n e.stopPropagation();\n clear();\n }}\n style={sx({\n flex: '0 0 auto',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n marginRight: -4,\n padding: 4,\n border: 'none',\n borderRadius: 'var(--radius-sm)',\n background: 'transparent',\n color: 'var(--text-muted)',\n cursor: 'pointer',\n })}\n >\n <X size={14} strokeWidth={2} />\n </button>\n )}\n </div>\n\n {open && place?.strategy === 'inline' &&\n renderPopover({ position: 'absolute', top: 'calc(100% + 6px)', left: 0, right: 0, zIndex: 20 })}\n {open && place?.strategy === 'fixed' &&\n createPortal(\n renderPopover({\n position: 'fixed',\n top: fitTop ?? place.top, // `fitTop` is measured (see above); the hook's guess only holds the first, unpainted render\n left: place.left,\n width: Math.min(place.width, PORTALLED_MAX_WIDTH),\n boxSizing: 'border-box',\n zIndex: 1100, // above the Dialog (1000), level with Select / Autocomplete's portalled lists\n }),\n document.body,\n )}\n </div>\n </Field>\n );\n});\n\nDatePicker.displayName = 'DatePicker';\n"],"mappings":";AAmTM,cA6BI,YA7BJ;AAjTN,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAC7B,SAAS,YAAY,cAAc,SAAS;AAC5C,SAAS,UAAU;AACnB,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAChC,SAAS,oBAAoB;AAE7B,SAAS,gBAAgB,UAAU,aAAa,aAAa;AAC7D,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;AAOA,MAAM,sBAAsB;AAG5B,SAAS,UAAU,MAAyC;AAC1D,MAAI,CAAC,KAAM,QAAO,CAAC;AACnB,SAAO,MAAM,KAAK,KAAK,iBAA8B,mCAAmC,CAAC,EAAE,OAAO,CAAC,OAAO,GAAG,YAAY,CAAC;AAC5H;AAyEA,SAAS,cAAc,KAAa,QAAgC;AAClE,QAAM,IAAI,SAAS,GAAG;AACtB,MAAI,CAAC,EAAG,QAAO;AACf,SAAO,IAAI,KAAK,eAAe,WAAW,OAAO,UAAU,SAAS,EAAE,KAAK,WAAW,OAAO,WAAW,MAAM,UAAU,CAAC,EAAE;AAAA,IAC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,SAAS;AAAA,IACX;AAAA,KACJ,GACF;AAEJ,CAAC;AAED,WAAW,cAAc;","names":["DatePicker"]}
1
+ {"version":3,"sources":["../../src/forms/DatePicker.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { Calendar as CalendarIcon, X } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { Field } from '../_internal/Field';\nimport { fieldA11y } from '../_internal/fieldA11y';\nimport { useIsoLayoutEffect } from '../_internal/useIsoLayoutEffect';\nimport { useMenuPlacement } from '../_internal/useMenuPlacement';\nimport { useOutsidePress } from '../_internal/useOutsidePress';\nimport { CalendarGrid } from './_internal/CalendarGrid';\nimport type { CalendarDayContext, CalendarDayDots } from './_internal/calendarDots';\nimport { parseISODate as parseISO, toISODate as toISO } from './_internal/calendarRange';\nimport { fieldBoxStyle } from './_internal/fieldBoxStyle';\nimport { fieldBoxProps } from './_internal/fieldFrame';\n\nconst TEXT = {\n 'pt-BR': { placeholder: 'Selecionar data', dialogLabel: 'Escolher data', clearLabel: 'Limpar data' },\n en: { placeholder: 'Pick a date', dialogLabel: 'Choose a date', clearLabel: 'Clear date' },\n} as const;\n\n/**\n * The widest a calendar gets once it leaves the field's own width, i.e. when portalled out of a Dialog. Its\n * cells are square, so it is as tall as it is wide: at the width of a wide dialog field it would be a\n * 450px-tall slab that covers the field and half the window. Inline it is untouched (still the field's width).\n */\nconst PORTALLED_MAX_WIDTH = 320;\n\n/** What a keyboard can reach inside `root`, in tab order (the calendar's roving day has `tabindex=\"0\"`, the others `-1`). */\nfunction tabbables(root: HTMLElement | null): HTMLElement[] {\n if (!root) return [];\n return Array.from(root.querySelectorAll<HTMLElement>('button:not(:disabled), [tabindex]')).filter((el) => el.tabIndex >= 0);\n}\n\n/**\n * Imperative handle exposed via `ref` - there's no single native element\n * underneath (the trigger is a `<button>`, the value a plain ISO string in\n * React state), so `ref` can't hand back something `.value`-readable the way\n * a real `<input>` would. `focus()` is real and covers `setFocus()`-on-error;\n * reading the current value still means the `value`/`onChange` props, not the\n * ref. `onChange(value: string)` also isn't a `ChangeEvent`, so a plain\n * `{...register(name)}` spread won't work regardless - use `Controller`.\n */\nexport interface DatePickerHandle {\n focus: () => void;\n}\n\nexport interface DatePickerProps {\n label?: string;\n hint?: string;\n error?: string;\n required?: boolean;\n /** Defaults to the `locale`-appropriate text (\"Selecionar data\" / \"Pick a date\"). */\n placeholder?: string;\n size?: 'sm' | 'md' | 'lg';\n disabled?: boolean;\n /** Controlled value, ISO \"YYYY-MM-DD\". */\n value?: string;\n /** Uncontrolled initial value, ISO \"YYYY-MM-DD\". */\n defaultValue?: string;\n onChange?: (value: string) => void;\n /**\n * Earliest selectable date, ISO \"YYYY-MM-DD\". Every day before it is struck through, and the\n * calendar cannot be navigated to an earlier month or year (the previous-month arrow disables,\n * PageUp and the arrow keys stop at the edge, the month / year popover disables what is out of\n * range). An initial value or month before it opens on `min`'s month.\n */\n min?: string;\n /** Latest selectable date, ISO \"YYYY-MM-DD\". The mirror image of `min`: later days are struck through and later months and years cannot be reached. */\n max?: string;\n /**\n * Fires when the month on screen changes (the arrows, or the month / year popover), with the\n * new year and the 0-indexed month. Not when the popover opens: it opens on the month of the\n * value, or on the current one. Refresh `dayDots` / `renderDay` here.\n */\n onMonthChange?: (year: number, month: number) => void;\n /**\n * Content under each day number (a count, a note), the same as `DateTimePicker`'s. The second\n * argument says whether the day is `selected`, `today` or `unavailable`. When set, the day cells\n * grow taller to hold it.\n */\n renderDay?: (day: number, context: CalendarDayContext) => React.ReactNode;\n /**\n * The days that get a dot under their number, the same as `DateTimePicker`'s: day numbers\n * (`[3, 17]`), or an object keyed by day number for a per-dot `tone` or `label`. Day numbers of\n * the month on screen, so refresh them in `onMonthChange`.\n */\n dayDots?: CalendarDayDots;\n /** What a screen reader says for a dot with no `label` of its own. Defaults to the `locale`-appropriate text. */\n dayDotLabel?: 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\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\n/**\n * Field for picking a single date - no time, no slots (`DateTimePicker`'s\n * job). A text-field-styled trigger showing the selected date opens a\n * popover with the same calendar grid `DateTimePicker` uses (roving\n * tabindex, month/year jump - see `./_internal/CalendarGrid`), so the two\n * share every bit of calendar behavior (SS-243).\n *\n * Value contract matches the rest of the forms package: `value` /\n * `defaultValue` + `onChange(value)`, a plain ISO \"YYYY-MM-DD\" string -\n * drops in wherever `<input type=\"date\">` would go, but themed instead of\n * the browser's own, and in pt-BR by default (the real Sereno product\n * always uses it; `locale=\"en\"` exists only for docs/demo purposes). A\n * clear (×) button appears once a value is set.\n */\nexport const DatePicker = React.forwardRef<DatePickerHandle, DatePickerProps>(function DatePicker(\n {\n label,\n hint,\n error,\n required,\n placeholder,\n size = 'md',\n disabled = false,\n value,\n defaultValue,\n onChange,\n min,\n max,\n onMonthChange,\n renderDay,\n dayDots,\n dayDotLabel,\n id,\n containerStyle,\n clearLabel,\n locale = 'pt-BR',\n preserveHelperSpace,\n },\n ref,\n) {\n const copy = TEXT[locale];\n const [inner, setInner] = React.useState(defaultValue ?? '');\n const iso = value !== undefined ? value : inner;\n const parsed = parseISO(iso);\n const now = React.useMemo(() => new Date(), []);\n\n const [open, setOpen] = React.useState(false);\n // The month currently shown in the popover - resets to the value's month\n // (or today's) every time the popover opens, via the conditional mount\n // below; CalendarGrid itself only takes year/month as its *initial* view.\n const [viewYear, setViewYear] = React.useState(parsed?.year ?? now.getFullYear());\n const [viewMonth, setViewMonth] = React.useState(parsed?.month ?? now.getMonth());\n\n const rootRef = React.useRef<HTMLDivElement>(null);\n const boxRef = React.useRef<HTMLDivElement>(null);\n const popoverRef = React.useRef<HTMLDivElement>(null);\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const generatedId = React.useId();\n const rid = id || generatedId;\n\n React.useImperativeHandle(ref, () => ({ focus: () => triggerRef.current?.focus() }), []);\n\n // Where the calendar sits. Normally a plain `position: absolute` child of\n // `rootRef` (itself `position: relative`) - the same \"inline\" strategy\n // Select's panel uses for its common case, and the same one DateTimePicker's\n // own month/year popover already uses. The browser glues it to the trigger\n // through *any* scroll (page or a nested overflow container) for free - no JS\n // measuring position, no listening for scroll/resize, and critically, it\n // never has to close on scroll the way a `position: fixed` popover computed\n // once would (that was tried first here and didn't hold up - see PR history).\n //\n // The one place that fails is inside a `position: fixed` container (a\n // Dialog): its body scrolls and clips an inline child, cutting the calendar\n // off. There `useMenuPlacement` answers 'fixed' (what Select and\n // Autocomplete already do) and the calendar is portalled to <body> at the\n // field's viewport rect, closing if the field moves. Outside a dialog nothing\n // changes: still inline, still below the field, never flipped (the hook's\n // `above` / `maxH` are not used at all: see `fitTop` for the portalled case).\n // `itemCount` is just the hook's height estimate; a calendar is not a list.\n const place = useMenuPlacement({\n open,\n anchorRef: boxRef,\n panelRef: popoverRef,\n itemCount: 8,\n onDismiss: () => setOpen(false),\n });\n const portalled = open && place?.strategy === 'fixed';\n\n // The hook picks \"below\" or \"above\" from a rough guess at the height, which suits a list capped at 288px but not\n // a calendar (about as tall as it is wide). So once the portalled calendar is on screen it is measured and kept\n // inside the window: under the field if it fits, else above it, else as far up as it needs (over the field rather\n // than cut off). The month changes the row count, hence the dependencies. Runs before paint: no visible jump.\n const [fitTop, setFitTop] = React.useState<number | null>(null);\n useIsoLayoutEffect(() => {\n const popover = popoverRef.current;\n const box = boxRef.current;\n if (!portalled || !popover || !box) return;\n const GAP = 6;\n const EDGE = 8;\n const field = box.getBoundingClientRect();\n const height = popover.offsetHeight;\n const viewport = window.innerHeight || document.documentElement.clientHeight || 900;\n const below = field.bottom + GAP;\n const above = field.top - GAP - height;\n setFitTop(below + height <= viewport - EDGE ? below : above >= EDGE ? above : Math.max(EDGE, viewport - EDGE - height));\n }, [portalled, place, viewYear, viewMonth]);\n\n // A press outside the field closes the calendar. The portalled calendar is outside `rootRef` in the DOM but\n // still part of the field, so both count as inside.\n useOutsidePress(open, [rootRef, popoverRef], () => setOpen(false));\n React.useEffect(() => {\n if (!open) return;\n const onKey = (e: KeyboardEvent) => {\n if (e.key === 'Escape') {\n e.preventDefault(); // handled: a Dialog around the field keeps its own Esc for the next press\n setOpen(false);\n triggerRef.current?.focus();\n }\n };\n document.addEventListener('keydown', onKey, true);\n return () => document.removeEventListener('keydown', onKey, true);\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 // Inline, the calendar follows the field in the DOM, so Tab walks field -> calendar -> next field on its\n // own. Portalled to the end of <body> it does not, so the focus is handed over by hand to keep that order.\n const onBoxKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n if (e.key !== 'Tab' || e.shiftKey || !portalled) return;\n const controls = tabbables(e.currentTarget);\n if (e.target !== controls[controls.length - 1]) return; // not the control the calendar follows\n const first = tabbables(popoverRef.current)[0];\n if (!first) return;\n e.preventDefault();\n first.focus();\n };\n\n const onPopoverKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n if (e.key !== 'Tab') return;\n const controls = tabbables(boxRef.current);\n const field = controls[controls.length - 1]; // the control the calendar follows in the DOM\n const inside = tabbables(e.currentTarget);\n if (e.shiftKey && e.target === inside[0]) {\n e.preventDefault();\n field?.focus();\n } else if (!e.shiftKey && e.target === inside[inside.length - 1]) {\n // Not prevented on purpose: with the focus back on the field the Tab goes on to whatever follows it.\n setOpen(false);\n field?.focus();\n }\n };\n\n // One popover, two positions (see `useMenuPlacement` above): the calendar and its look are the same.\n const renderPopover = (position: React.CSSProperties) => (\n <div\n ref={popoverRef}\n role=\"dialog\"\n aria-label={label || copy.dialogLabel}\n tabIndex={-1}\n onKeyDown={portalled ? onPopoverKeyDown : undefined}\n style={sx({\n ...position,\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 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 min={min}\n max={max}\n onMonthChange={(y, m) => {\n setViewYear(y);\n setViewMonth(m);\n onMonthChange?.(y, m);\n }}\n renderDay={renderDay}\n dayDots={dayDots}\n dayDotLabel={dayDotLabel}\n onSelectDate={commit}\n squareCells\n trimEmptyRows\n locale={locale}\n />\n </div>\n );\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 ref={boxRef} onKeyDown={onBoxKeyDown} {...fieldBoxProps(open)} style={fieldBoxStyle(size, !!error, disabled)}>\n <button\n ref={triggerRef}\n id={rid}\n type=\"button\"\n disabled={disabled}\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n // Ties the trigger to the hint / error line below, so they are read when it takes focus.\n {...fieldA11y(rid, { hint, error })}\n onClick={() => (open ? setOpen(false) : openPopover())}\n style={sx({\n flex: 1,\n minWidth: 0,\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-2)',\n border: 'none',\n background: 'transparent',\n padding: 0,\n font: 'inherit',\n color: 'inherit',\n cursor: 'inherit',\n textAlign: 'left',\n })}\n >\n <CalendarIcon size={16} strokeWidth={1.75} style={{ flex: '0 0 auto', opacity: 0.7 }} />\n <span\n style={sx({\n flex: 1,\n textAlign: 'left',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n color: iso ? 'inherit' : 'var(--text-muted)',\n })}\n >\n {iso ? formatDisplay(iso, locale) : (placeholder ?? copy.placeholder)}\n </span>\n </button>\n {iso && !disabled && (\n <button\n type=\"button\"\n aria-label={clearLabel ?? copy.clearLabel}\n onClick={(e) => {\n e.stopPropagation();\n clear();\n }}\n style={sx({\n flex: '0 0 auto',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n marginRight: -4,\n padding: 4,\n border: 'none',\n borderRadius: 'var(--radius-sm)',\n background: 'transparent',\n color: 'var(--text-muted)',\n cursor: 'pointer',\n })}\n >\n <X size={14} strokeWidth={2} />\n </button>\n )}\n </div>\n\n {open && place?.strategy === 'inline' &&\n renderPopover({ position: 'absolute', top: 'calc(100% + 6px)', left: 0, right: 0, zIndex: 20 })}\n {open && place?.strategy === 'fixed' &&\n createPortal(\n renderPopover({\n position: 'fixed',\n top: fitTop ?? place.top, // `fitTop` is measured (see above); the hook's guess only holds the first, unpainted render\n left: place.left,\n width: Math.min(place.width, PORTALLED_MAX_WIDTH),\n boxSizing: 'border-box',\n zIndex: 1100, // above the Dialog (1000), level with Select / Autocomplete's portalled lists\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CAAC;AAAA,gBAEA,gBAAM,cAAc,KAAK,MAAM,IAAK,eAAe,KAAK;AAAA;AAAA,YAC3D;AAAA;AAAA;AAAA,MACF;AAAA,MACC,OAAO,CAAC,YACP;AAAA,QAAC;AAAA;AAAA,UACC,MAAK;AAAA,UACL,cAAY,cAAc,KAAK;AAAA,UAC/B,SAAS,CAAC,MAAM;AACd,cAAE,gBAAgB;AAClB,kBAAM;AAAA,UACR;AAAA,UACA,OAAO,GAAG;AAAA,YACR,MAAM;AAAA,YACN,SAAS;AAAA,YACT,YAAY;AAAA,YACZ,gBAAgB;AAAA,YAChB,aAAa;AAAA,YACb,SAAS;AAAA,YACT,QAAQ;AAAA,YACR,cAAc;AAAA,YACd,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,QAAQ,OAAO,aAAa,YAC3B,cAAc,EAAE,UAAU,YAAY,KAAK,oBAAoB,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,CAAC;AAAA,IAC/F,QAAQ,OAAO,aAAa,WAC3B;AAAA,MACE,cAAc;AAAA,QACZ,UAAU;AAAA,QACV,KAAK,UAAU,MAAM;AAAA;AAAA,QACrB,MAAM,MAAM;AAAA,QACZ,OAAO,KAAK,IAAI,MAAM,OAAO,mBAAmB;AAAA,QAChD,WAAW;AAAA,QACX,QAAQ;AAAA;AAAA,MACV,CAAC;AAAA,MACD,SAAS;AAAA,IACX;AAAA,KACJ,GACF;AAEJ,CAAC;AAED,WAAW,cAAc;","names":["DatePicker"]}
@@ -9,6 +9,7 @@ import { CharCount } from "../_internal/CharCount.js";
9
9
  import { formatMask, MASK_INPUTMODE, MASK_MAXLENGTH } from "../_internal/mask.js";
10
10
  import { mergeRefs } from "../_internal/mergeRefs.js";
11
11
  import { useValueLength } from "../_internal/useValueLength.js";
12
+ import { fieldFrameVars } from "./_internal/fieldFrame.js";
12
13
  const H = { sm: "var(--control-height-sm)", md: "var(--control-height-md)", lg: "var(--control-height-lg)" };
13
14
  const Input = React.forwardRef(function Input2({
14
15
  label,
@@ -28,8 +29,6 @@ const Input = React.forwardRef(function Input2({
28
29
  preserveHelperSpace,
29
30
  type,
30
31
  onChange,
31
- onFocus,
32
- onBlur,
33
32
  inputMode,
34
33
  maxLength,
35
34
  defaultValue,
@@ -38,7 +37,6 @@ const Input = React.forwardRef(function Input2({
38
37
  "aria-required": ariaRequired,
39
38
  ...rest
40
39
  }, ref) {
41
- const [focus, setFocus] = React.useState(false);
42
40
  const [reveal, setReveal] = React.useState(false);
43
41
  const inputRef = React.useRef(null);
44
42
  const autoId = React.useId();
@@ -65,14 +63,6 @@ const Input = React.forwardRef(function Input2({
65
63
  }
66
64
  onChange?.(e);
67
65
  } : onChange;
68
- const handleFocus = (e) => {
69
- setFocus(true);
70
- onFocus?.(e);
71
- };
72
- const handleBlur = (e) => {
73
- setFocus(false);
74
- onBlur?.(e);
75
- };
76
66
  return /* @__PURE__ */ jsx(
77
67
  Field,
78
68
  {
@@ -88,7 +78,9 @@ const Input = React.forwardRef(function Input2({
88
78
  children: /* @__PURE__ */ jsxs(
89
79
  "div",
90
80
  {
81
+ className: "sereno-field",
91
82
  style: sx({
83
+ ...fieldFrameVars(!!error),
92
84
  display: "flex",
93
85
  alignItems: "center",
94
86
  gap: "var(--space-2)",
@@ -96,8 +88,8 @@ const Input = React.forwardRef(function Input2({
96
88
  padding: "0 var(--space-3)",
97
89
  borderRadius: "var(--radius-control)",
98
90
  background: disabled ? "var(--interactive-disabled-bg)" : "var(--bg-surface)",
99
- border: "var(--border-width-hairline) solid " + (error ? "var(--interactive-error)" : focus ? "var(--border-focus)" : "var(--border-default)"),
100
- boxShadow: focus ? error ? "none" : "var(--focus-ring)" : "none",
91
+ borderWidth: "var(--border-width-hairline)",
92
+ borderStyle: "solid",
101
93
  transition: "var(--transition-control)"
102
94
  }),
103
95
  children: [
@@ -112,8 +104,6 @@ const Input = React.forwardRef(function Input2({
112
104
  ...a11y,
113
105
  ref: mergeRefs(inputRef, ref),
114
106
  type: isPassword && reveal ? "text" : type,
115
- onFocus: handleFocus,
116
- onBlur: handleBlur,
117
107
  onChange: handleChange,
118
108
  inputMode: mask ? inputMode ?? MASK_INPUTMODE[mask] ?? "numeric" : inputMode,
119
109
  maxLength: mask ? maxLength ?? MASK_MAXLENGTH[mask] : maxLength,
@@ -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 { fieldA11y } from '../_internal/fieldA11y';\nimport { CharCount } from '../_internal/CharCount';\nimport { formatMask, MASK_INPUTMODE, MASK_MAXLENGTH, type MaskName } from '../_internal/mask';\nimport { mergeRefs } from '../_internal/mergeRefs';\nimport { useValueLength } from '../_internal/useValueLength';\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 'aria-describedby': describedBy,\n 'aria-invalid': invalid,\n 'aria-required': ariaRequired,\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 // Names the hint / error line and flags the error, so a screen reader reads both with the field.\n const a11y = fieldA11y(rid, { hint, error, describedBy, invalid, required, ariaRequired });\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 // Controlled: the count comes from `value`. Uncontrolled: from the element itself, so a\n // value written by code (react-hook-form's `reset()` / `setValue()`, `el.value = …`) counts too.\n const uncount = useValueLength(\n inputRef,\n showCounter && rest.value === undefined,\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 handleChange = mask\n ? (e: React.ChangeEvent<HTMLInputElement>) => {\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 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 requiredExposed\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 {...a11y}\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":";AA2I6B,cAGvB,YAHuB;AAzI7B,YAAY,WAAW;AACvB,SAAS,KAAK,cAAc;AAC5B,SAAS,UAAU;AACnB,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,YAAY,gBAAgB,sBAAqC;AAC1E,SAAS,iBAAiB;AAC1B,SAAS,sBAAsB;AAmC/B,MAAM,IAAI,EAAE,IAAI,4BAA4B,IAAI,4BAA4B,IAAI,2BAA2B;AAEpG,MAAM,QAAQ,MAAM,WAAyC,SAASA,OAC3E;AAAA,EACE;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;A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B,WAAW,WAAW,MAAM,YAAY,IAAI;AAAA,gBAC1F,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,CAAC;AAED,MAAM,cAAc;","names":["Input"]}
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 { fieldA11y } from '../_internal/fieldA11y';\nimport { CharCount } from '../_internal/CharCount';\nimport { formatMask, MASK_INPUTMODE, MASK_MAXLENGTH, type MaskName } from '../_internal/mask';\nimport { mergeRefs } from '../_internal/mergeRefs';\nimport { useValueLength } from '../_internal/useValueLength';\nimport { fieldFrameVars } from './_internal/fieldFrame';\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 inputMode,\n maxLength,\n defaultValue,\n 'aria-describedby': describedBy,\n 'aria-invalid': invalid,\n 'aria-required': ariaRequired,\n ...rest\n },\n ref,\n) {\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 // Names the hint / error line and flags the error, so a screen reader reads both with the field.\n const a11y = fieldA11y(rid, { hint, error, describedBy, invalid, required, ariaRequired });\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 // Controlled: the count comes from `value`. Uncontrolled: from the element itself, so a\n // value written by code (react-hook-form's `reset()` / `setValue()`, `el.value = …`) counts too.\n const uncount = useValueLength(\n inputRef,\n showCounter && rest.value === undefined,\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 handleChange = mask\n ? (e: React.ChangeEvent<HTMLInputElement>) => {\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 onChange?.(e);\n }\n : onChange;\n\n return (\n <Field\n label={label}\n hint={hint}\n error={error}\n required={required}\n requiredExposed\n htmlFor={rid}\n style={containerStyle}\n counter={showCounter ? <CharCount count={count} max={maxLength ?? undefined} /> : undefined}\n preserveHelperSpace={preserveHelperSpace}\n >\n <div\n // The border colour and the focus ring are CSS: the row lights up while its text box has the focus\n // (`.sereno-field` in styles.css, SS-582), so the field keeps no focus state and a caller's\n // `onFocus` / `onBlur` (react-hook-form's `register()` injects one) reaches the `<input>` untouched.\n className=\"sereno-field\"\n style={sx({\n ...fieldFrameVars(!!error),\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 borderWidth: 'var(--border-width-hairline)',\n borderStyle: 'solid',\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 {...a11y}\n ref={mergeRefs(inputRef, ref)}\n type={isPassword && reveal ? 'text' : type}\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":";AA4H6B,cAGvB,YAHuB;AA1H7B,YAAY,WAAW;AACvB,SAAS,KAAK,cAAc;AAC5B,SAAS,UA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AAc,SAAS,SAAS;AAAA,gBACtC,UAAU;AAAA,gBACV,WAAW,OAAO,aAAa,eAAe,IAAI,KAAK,YAAY;AAAA,gBACnE,WAAW,OAAO,aAAa,eAAe,IAAI,IAAI;AAAA,gBACtD,cAAc,QAAQ,OAAO,iBAAiB,WAAW,WAAW,MAAM,YAAY,IAAI;AAAA,gBAC1F,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,CAAC;AAED,MAAM,cAAc;","names":["Input"]}
@@ -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 *\n * A caller's `onKeyDown` runs first, on every key. Calling `preventDefault()` on\n * the event there says it was handled, and the built-in `Enter` / `Esc` are skipped\n * (the same \"handled\" rule a popup's `Esc` follows inside a `Dialog`).\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, onKeyDown, 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 // Composed, not replaced: a plain `{...rest}` spread followed by our own `onKeyDown` used to drop the caller's\n // silently (the same class of bug `Input` and `Textarea` already guard against for onFocus / onBlur / onChange).\n // The caller's runs first and can opt out of the built-in keys with `preventDefault()`.\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n onKeyDown?.(e);\n if (e.defaultPrevented) return;\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\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={handleKeyDown}\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":";AA+EgB;AA7EhB,YAAY,WAAW;AACvB,SAAS,QAAQ,SAAS;AAC1B,SAAS,UAAU;AACnB,SAAS,aAA8B;AAwBhC,MAAM,cAAc,MAAM,WAA+C,SAASA,aACvF,EAAE,OAAO,cAAc,eAAe,UAAU,WAAW,WAAW,KAAK,aAAa,gBAAgB,cAAc,gBAAW,UAAU,GAAG,KAAK,GACnJ,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;AAKnC,QAAM,gBAAgB,CAAC,MAA6C;AAClE,gBAAY,CAAC;AACb,QAAI,EAAE,iBAAkB;AACxB,QAAI,EAAE,QAAQ,QAAS,WAAU,EAAE,cAAc,OAAO,IAAI;AAAA,aACnD,EAAE,QAAQ,YAAY,MAAM;AACnC,QAAE,eAAe;AACjB,YAAM;AAAA,IACR;AAAA,EACF;AAEA,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;AAAA,MACX,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"]}
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 *\n * A caller's `onKeyDown` runs first, on every key. Calling `preventDefault()` on\n * the event there says it was handled, and the built-in `Enter` / `Esc` are skipped\n * (the same \"handled\" rule a popup's `Esc` follows inside a `Dialog`).\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, onKeyDown, 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 // Composed, not replaced: a plain `{...rest}` spread followed by our own `onKeyDown` used to drop the caller's\n // silently (the same class of bug `Input` guards against for `onChange`).\n // The caller's runs first and can opt out of the built-in keys with `preventDefault()`.\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n onKeyDown?.(e);\n if (e.defaultPrevented) return;\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\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={handleKeyDown}\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":";AA+EgB;AA7EhB,YAAY,WAAW;AACvB,SAAS,QAAQ,SAAS;AAC1B,SAAS,UAAU;AACnB,SAAS,aAA8B;AAwBhC,MAAM,cAAc,MAAM,WAA+C,SAASA,aACvF,EAAE,OAAO,cAAc,eAAe,UAAU,WAAW,WAAW,KAAK,aAAa,gBAAgB,cAAc,gBAAW,UAAU,GAAG,KAAK,GACnJ,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;AAKnC,QAAM,gBAAgB,CAAC,MAA6C;AAClE,gBAAY,CAAC;AACb,QAAI,EAAE,iBAAkB;AACxB,QAAI,EAAE,QAAQ,QAAS,WAAU,EAAE,cAAc,OAAO,IAAI;AAAA,aACnD,EAAE,QAAQ,YAAY,MAAM;AACnC,QAAE,eAAe;AACjB,YAAM;AAAA,IACR;AAAA,EACF;AAEA,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;AAAA,MACX,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"]}
@@ -13,6 +13,7 @@ import { MenuOption, menuListStyle, menuRowPadY, menuSurfaceStyle } from "../_in
13
13
  import { Field } from "../_internal/Field.js";
14
14
  import { fieldA11y } from "../_internal/fieldA11y.js";
15
15
  import { fieldBoxStyle } from "./_internal/fieldBoxStyle.js";
16
+ import { fieldBoxProps } from "./_internal/fieldFrame.js";
16
17
  function CustomSelect({
17
18
  rid,
18
19
  label,
@@ -185,7 +186,8 @@ function CustomSelect({
185
186
  else openMenu();
186
187
  },
187
188
  onKeyDown,
188
- style: fieldBoxStyle(size, error, open, !!disabled),
189
+ ...fieldBoxProps(open),
190
+ style: fieldBoxStyle(size, error, !!disabled),
189
191
  children: [
190
192
  /* @__PURE__ */ jsx(
191
193
  "span",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/forms/Select.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { ChevronDown } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { acquireScrollLock } from '../_internal/scrollLock';\nimport { useCoarsePointer } from '../_internal/useCoarsePointer';\nimport { useMenuPlacement } from '../_internal/useMenuPlacement';\nimport { useOutsidePress } from '../_internal/useOutsidePress';\nimport { useRevealActive } from '../_internal/useRevealActive';\nimport { MenuOption, menuListStyle, menuRowPadY, menuSurfaceStyle } from '../_internal/MenuOption';\nimport { Field } from '../_internal/Field';\nimport { fieldA11y } from '../_internal/fieldA11y';\nimport { fieldBoxStyle } from './_internal/fieldBoxStyle';\n\nexport interface SelectOption {\n value: string;\n label: string;\n disabled?: boolean;\n}\n\n/**\n * Single-choice select - a hand-rolled listbox (token-styled, full keyboard\n * support) so it looks and behaves the same in every browser. On a mouse it's\n * an anchored dropdown; on touch it opens as a bottom sheet with finger-sized\n * rows.\n *\n * Value contract: `value` / `defaultValue` + `onValueChange(value)` - a plain\n * string, not a DOM event.\n */\nexport interface SelectProps {\n label?: string;\n hint?: string;\n /** Error message; also turns the control red. */\n error?: string;\n required?: boolean;\n options?: SelectOption[];\n /** Shown in muted text on the trigger when nothing is selected. */\n placeholder?: string;\n size?: 'sm' | 'md' | 'lg';\n disabled?: boolean;\n /** Controlled value. */\n value?: string;\n /** Uncontrolled initial value. */\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n /** Form field name - mirrored to a hidden input so the value can be submitted. */\n name?: string;\n id?: string;\n containerStyle?: React.CSSProperties;\n /**\n * Accessible name for the trigger. Only needed when there's no visible\n * `label` (e.g. a compact row where the context is already clear visually,\n * a day name next to a \"start time\" / \"end time\" pair): `Field` only\n * renders a `<label>` when `label` is set, so without either the trigger\n * has no accessible name at all. Takes precedence over `label` if both are\n * set - don't pass both.\n */\n 'aria-label'?: string;\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\n// ── Custom listbox ──────────────────────────────────────────────────────────\nfunction CustomSelect({\n rid,\n label,\n ariaLabel,\n options,\n value,\n placeholder,\n size,\n error,\n disabled,\n coarse,\n fieldAria,\n onCommit,\n}: {\n rid: string;\n /** The field label - shown as the sheet header on touch so the picker has context. */\n label?: string;\n /** Falls back to `label` when there's no visible one at all. */\n ariaLabel?: string;\n options: SelectOption[];\n value: string;\n placeholder?: string;\n size: NonNullable<SelectProps['size']>;\n error: boolean;\n disabled?: boolean;\n /** Touch: open as a bottom sheet with finger-sized rows instead of a dropdown. */\n coarse: boolean;\n /** `aria-invalid` / `aria-describedby` tying the trigger to the field's hint / error line. */\n fieldAria: ReturnType<typeof fieldA11y>;\n onCommit: (v: string) => void;\n}) {\n const listboxId = `${rid}-listbox`;\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const panelRef = React.useRef<HTMLUListElement>(null);\n const typeahead = React.useRef<{ str: string; timer: number }>({ str: '', timer: 0 });\n // A <label htmlFor> forwards a fully-trusted click to this button (detail:1),\n // indistinguishable from a direct one - but its *pointerdown* landed on the\n // label, not here. So only toggle when the press actually started on the box.\n const pressedAt = React.useRef(0);\n\n const [open, setOpen] = React.useState(false);\n const [activeIndex, setActiveIndex] = React.useState(-1);\n const [mounted, setMounted] = React.useState(false);\n // eslint-disable-next-line react-hooks/set-state-in-effect -- portal target is client-only\n React.useEffect(() => setMounted(true), []);\n // Where the dropdown sits (inline under the field, or portalled to the body inside a Dialog): see\n // `useMenuPlacement`. The touch sheet needs no anchoring.\n const place = useMenuPlacement({\n open,\n disabled: coarse,\n anchorRef: triggerRef,\n panelRef,\n itemCount: options.length,\n onDismiss: () => setOpen(false),\n });\n\n const selectedIndex = options.findIndex((o) => o.value === value);\n const selected = selectedIndex >= 0 ? options[selectedIndex] : undefined;\n\n const firstEnabled = () => options.findIndex((o) => !o.disabled);\n const lastEnabled = () => {\n for (let i = options.length - 1; i >= 0; i--) if (!options[i].disabled) return i;\n return -1;\n };\n const nextEnabled = (from: number, dir: 1 | -1) => {\n let i = from;\n for (let step = 0; step < options.length; step++) {\n i += dir;\n if (i < 0 || i >= options.length) return from;\n if (!options[i].disabled) return i;\n }\n return from;\n };\n\n // Close on outside pointerdown (the touch sheet uses its own scrim instead).\n useOutsidePress(open && !coarse, [triggerRef, panelRef], () => setOpen(false));\n\n // The touch sheet is a modal surface - lock the page scroll behind it. Through the shared lock,\n // so a Select inside a Dialog (two held at once) frees the page whichever lets go first.\n React.useEffect(() => {\n if (!open || !coarse) return;\n return acquireScrollLock();\n }, [open, coarse]);\n\n // Keep the active option in view, the first time the list opens too (SS-568): see `useRevealActive`.\n useRevealActive(open, activeIndex >= 0 ? `${rid}-opt-${activeIndex}` : null, place);\n\n const openMenu = () => {\n if (disabled) return;\n setActiveIndex(selectedIndex >= 0 ? selectedIndex : firstEnabled());\n setOpen(true);\n };\n const closeMenu = (refocus = true) => {\n setOpen(false);\n if (refocus) triggerRef.current?.focus({ preventScroll: true });\n };\n const choose = (i: number) => {\n const o = options[i];\n if (!o || o.disabled) return;\n onCommit(o.value);\n closeMenu();\n };\n\n const onKeyDown = (e: React.KeyboardEvent) => {\n if (disabled) return;\n switch (e.key) {\n case 'ArrowDown':\n e.preventDefault();\n if (!open) return openMenu();\n setActiveIndex((i) => nextEnabled(i < 0 ? -1 : i, 1));\n return;\n case 'ArrowUp':\n e.preventDefault();\n if (!open) return openMenu();\n setActiveIndex((i) => nextEnabled(i < 0 ? options.length : i, -1));\n return;\n case 'Home':\n if (open) {\n e.preventDefault();\n setActiveIndex(firstEnabled());\n }\n return;\n case 'End':\n if (open) {\n e.preventDefault();\n setActiveIndex(lastEnabled());\n }\n return;\n case 'Enter':\n case ' ':\n e.preventDefault();\n if (!open) return openMenu();\n choose(activeIndex);\n return;\n case 'Escape':\n if (open) {\n e.preventDefault();\n // Only the list closes: a Dialog around the field keeps its own Esc for the next press.\n // (`stopImmediate...` too: React may listen on `document`, where the Dialog listens as well.)\n e.stopPropagation();\n e.nativeEvent.stopImmediatePropagation();\n closeMenu();\n }\n return;\n case 'Tab':\n if (open) setOpen(false);\n return;\n default:\n if (e.key.length === 1 && !e.metaKey && !e.ctrlKey && !e.altKey) {\n const ta = typeahead.current;\n ta.str += e.key.toLowerCase();\n window.clearTimeout(ta.timer);\n ta.timer = window.setTimeout(() => (ta.str = ''), 500);\n const match = options.findIndex((o) => !o.disabled && o.label.toLowerCase().startsWith(ta.str));\n if (match >= 0) {\n if (!open) openMenu();\n setActiveIndex(match);\n }\n }\n }\n };\n\n const hasValue = !!selected;\n const rowPadY = menuRowPadY(coarse, size);\n\n const listStyleBase: React.CSSProperties = { ...menuSurfaceStyle(size), ...menuListStyle };\n const optionRows = options.map((o, i) => (\n <MenuOption\n key={o.value}\n id={`${rid}-opt-${i}`}\n label={o.label}\n selected={o.value === value}\n active={i === activeIndex}\n disabled={o.disabled}\n coarse={coarse}\n padY={rowPadY}\n onPointerEnter={() => !o.disabled && setActiveIndex(i)}\n onClick={() => choose(i)}\n />\n ));\n\n return (\n <div style={sx({ position: 'relative', width: '100%' })}>\n <button\n ref={triggerRef}\n type=\"button\"\n id={rid}\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n aria-expanded={open}\n aria-controls={open ? listboxId : undefined}\n aria-activedescendant={open && activeIndex >= 0 ? `${rid}-opt-${activeIndex}` : undefined}\n aria-label={ariaLabel}\n {...fieldAria}\n aria-disabled={disabled || undefined}\n disabled={disabled}\n onPointerDown={() => {\n pressedAt.current = Date.now();\n }}\n onMouseDown={(e) => {\n // Take focus without the browser scrolling us into view.\n e.preventDefault();\n triggerRef.current?.focus({ preventScroll: true });\n }}\n onClick={() => {\n // Only toggle when the press started on this button - a click forwarded\n // from the field <label>, or synthesised by the keyboard, never set\n // pressedAt (keyboard is handled in onKeyDown).\n if (Date.now() - pressedAt.current > 500) return;\n pressedAt.current = 0;\n if (open) closeMenu(false);\n else openMenu();\n }}\n onKeyDown={onKeyDown}\n style={fieldBoxStyle(size, error, open, !!disabled)}\n >\n <span\n style={sx({\n flex: 1,\n minWidth: 0,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n color: hasValue ? 'inherit' : 'var(--text-muted)',\n })}\n >\n {hasValue ? selected!.label : placeholder ?? 'Select…'}\n </span>\n <span\n aria-hidden=\"true\"\n style={sx({\n display: 'flex',\n flex: '0 0 auto',\n color: 'var(--text-muted)',\n transition: 'transform var(--duration-fast) var(--ease-standard)',\n transform: open ? 'rotate(180deg)' : 'none',\n })}\n >\n <ChevronDown size={16} strokeWidth={1.75} />\n </span>\n </button>\n\n {open && mounted && coarse &&\n createPortal(\n <div\n role=\"presentation\"\n onClick={() => closeMenu()}\n style={sx({\n position: 'fixed',\n inset: 0,\n zIndex: 1100,\n display: 'flex',\n alignItems: 'flex-end',\n background: 'var(--bg-overlay)',\n backdropFilter: 'blur(2px)',\n animation: 'sereno-fade-in var(--duration-fast) var(--ease-standard)',\n })}\n >\n <div\n onClick={(e) => e.stopPropagation()}\n style={sx({\n width: '100%',\n maxHeight: '70dvh',\n display: 'flex',\n flexDirection: 'column',\n background: 'var(--bg-surface)',\n borderRadius: 'var(--radius-sheet) var(--radius-sheet) 0 0',\n boxShadow: 'var(--shadow-sheet)',\n paddingBottom: 'env(safe-area-inset-bottom)',\n animation: 'sereno-slide-up var(--duration-sheet) var(--ease-gentle)',\n })}\n >\n {label && (\n <div\n style={sx({\n flex: '0 0 auto',\n padding: 'var(--space-3) var(--space-4)',\n borderBottom: 'var(--border-width-hairline) solid var(--border-subtle)',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-base)',\n fontWeight: 'var(--weight-semibold)',\n letterSpacing: 'var(--tracking-snug)',\n color: 'var(--text-primary)',\n })}\n >\n {label}\n </div>\n )}\n <ul\n ref={panelRef}\n id={listboxId}\n role=\"listbox\"\n aria-label={label}\n tabIndex={-1}\n style={sx({\n ...listStyleBase,\n flex: '1 1 auto',\n minHeight: 0,\n border: 'none',\n borderRadius: 0,\n boxShadow: 'none',\n background: 'transparent',\n padding: 'var(--space-2)',\n overscrollBehavior: 'contain', // don't chain the list's scroll to the page\n })}\n >\n {optionRows}\n </ul>\n </div>\n </div>,\n document.body,\n )}\n {open && !coarse && place && place.strategy === 'inline' && (\n <ul\n ref={panelRef}\n id={listboxId}\n role=\"listbox\"\n tabIndex={-1}\n style={sx({\n ...listStyleBase,\n position: 'absolute',\n left: 0,\n right: 0,\n ...(place.above ? { bottom: 'calc(100% + 6px)' } : { top: 'calc(100% + 6px)' }),\n maxHeight: place.maxH,\n zIndex: 100,\n })}\n >\n {optionRows}\n </ul>\n )}\n {open && !coarse && mounted && place && place.strategy === 'fixed' &&\n createPortal(\n <ul\n ref={panelRef}\n id={listboxId}\n role=\"listbox\"\n tabIndex={-1}\n style={sx({\n ...listStyleBase,\n position: 'fixed',\n top: place.top,\n left: place.left,\n width: place.width,\n ...(place.above ? { transform: 'translateY(-100%)' } : null),\n maxHeight: place.maxH,\n zIndex: 1100,\n })}\n >\n {optionRows}\n </ul>,\n document.body,\n )}\n </div>\n );\n}\n\n/**\n * `ref` reaches the hidden `<input type=\"hidden\">` that mirrors the selected\n * value (rendered only when `name` is set - pass it, as `register()` does).\n * Enough for `getValues()` / `trigger()` / `setFocus()`, but a plain\n * `{...register(name)}` spread still won't validate on change: this hidden\n * input never dispatches a native `input`/`change` event, and `onValueChange`\n * hands back a plain string, not a `ChangeEvent` - wire it through\n * `Controller`, or call the registered `onChange` yourself from\n * `onValueChange`.\n */\nexport const Select = React.forwardRef<HTMLInputElement, SelectProps>(function Select({\n label,\n hint,\n error,\n required,\n options = [],\n placeholder,\n size = 'md',\n disabled,\n value: valueProp,\n defaultValue,\n onValueChange,\n name,\n id,\n containerStyle,\n 'aria-label': ariaLabel,\n preserveHelperSpace,\n}: SelectProps, ref) {\n const reactId = React.useId();\n const rid = id || reactId;\n const isControlled = valueProp !== undefined;\n const [internalValue, setInternalValue] = React.useState(defaultValue ?? '');\n const value = isControlled ? valueProp! : internalValue;\n const coarse = useCoarsePointer();\n\n const commit = React.useCallback(\n (v: string) => {\n if (!isControlled) setInternalValue(v);\n onValueChange?.(v);\n },\n [isControlled, onValueChange],\n );\n\n return (\n <Field label={label} hint={hint} error={error} required={required} requiredExposed htmlFor={rid} style={containerStyle} preserveHelperSpace={preserveHelperSpace}>\n <CustomSelect\n rid={rid}\n label={label}\n ariaLabel={ariaLabel}\n options={options}\n value={value}\n placeholder={placeholder}\n size={size}\n error={!!error}\n disabled={disabled}\n coarse={coarse}\n fieldAria={fieldA11y(rid, { hint, error, required })}\n onCommit={commit}\n />\n {name && <input ref={ref} type=\"hidden\" name={name} value={value} />}\n </Field>\n );\n});\n\nSelect.displayName = 'Select';\n"],"mappings":";AAyOI,cAgBE,YAhBF;AAvOJ,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,SAAS,UAAU;AACnB,SAAS,yBAAyB;AAClC,SAAS,wBAAwB;AACjC,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAChC,SAAS,uBAAuB;AAChC,SAAS,YAAY,eAAe,aAAa,wBAAwB;AACzE,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAoD9B,SAAS,aAAa;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAiBG;AACD,QAAM,YAAY,GAAG,GAAG;AACxB,QAAM,aAAa,MAAM,OAA0B,IAA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,MAAM;AAC5B,QAAM,MAAM,MAAM;AAClB,QAAM,eAAe,cAAc;AACnC,QAAM,CAAC,eAAe,gBAAgB,IAAI,MAAM,SAAS,gBAAgB,EAAE;AAC3E,QAAM,QAAQ,eAAe,YAAa;AAC1C,QAAM,SAAS,iBAAiB;AAEhC,QAAM,SAAS,MAAM;AAAA,IACnB,CAAC,MAAc;AACb,UAAI,CAAC,aAAc,kBAAiB,CAAC;AACrC,sBAAgB,CAAC;AAAA,IACnB;AAAA,IACA,CAAC,cAAc,aAAa;AAAA,EAC9B;AAEA,SACE,qBAAC,SAAM,OAAc,MAAY,OAAc,UAAoB,iBAAe,MAAC,SAAS,KAAK,OAAO,gBAAgB,qBACtH;AAAA;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,OAAO,CAAC,CAAC;AAAA,QACT;AAAA,QACA;AAAA,QACA,WAAW,UAAU,KAAK,EAAE,MAAM,OAAO,SAAS,CAAC;AAAA,QACnD,UAAU;AAAA;AAAA,IACZ;AAAA,IACC,QAAQ,oBAAC,WAAM,KAAU,MAAK,UAAS,MAAY,OAAc;AAAA,KACpE;AAEJ,CAAC;AAED,OAAO,cAAc;","names":["Select"]}
1
+ {"version":3,"sources":["../../src/forms/Select.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { ChevronDown } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { acquireScrollLock } from '../_internal/scrollLock';\nimport { useCoarsePointer } from '../_internal/useCoarsePointer';\nimport { useMenuPlacement } from '../_internal/useMenuPlacement';\nimport { useOutsidePress } from '../_internal/useOutsidePress';\nimport { useRevealActive } from '../_internal/useRevealActive';\nimport { MenuOption, menuListStyle, menuRowPadY, menuSurfaceStyle } from '../_internal/MenuOption';\nimport { Field } from '../_internal/Field';\nimport { fieldA11y } from '../_internal/fieldA11y';\nimport { fieldBoxStyle } from './_internal/fieldBoxStyle';\nimport { fieldBoxProps } from './_internal/fieldFrame';\n\nexport interface SelectOption {\n value: string;\n label: string;\n disabled?: boolean;\n}\n\n/**\n * Single-choice select - a hand-rolled listbox (token-styled, full keyboard\n * support) so it looks and behaves the same in every browser. On a mouse it's\n * an anchored dropdown; on touch it opens as a bottom sheet with finger-sized\n * rows.\n *\n * Value contract: `value` / `defaultValue` + `onValueChange(value)` - a plain\n * string, not a DOM event.\n */\nexport interface SelectProps {\n label?: string;\n hint?: string;\n /** Error message; also turns the control red. */\n error?: string;\n required?: boolean;\n options?: SelectOption[];\n /** Shown in muted text on the trigger when nothing is selected. */\n placeholder?: string;\n size?: 'sm' | 'md' | 'lg';\n disabled?: boolean;\n /** Controlled value. */\n value?: string;\n /** Uncontrolled initial value. */\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n /** Form field name - mirrored to a hidden input so the value can be submitted. */\n name?: string;\n id?: string;\n containerStyle?: React.CSSProperties;\n /**\n * Accessible name for the trigger. Only needed when there's no visible\n * `label` (e.g. a compact row where the context is already clear visually,\n * a day name next to a \"start time\" / \"end time\" pair): `Field` only\n * renders a `<label>` when `label` is set, so without either the trigger\n * has no accessible name at all. Takes precedence over `label` if both are\n * set - don't pass both.\n */\n 'aria-label'?: string;\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\n// ── Custom listbox ──────────────────────────────────────────────────────────\nfunction CustomSelect({\n rid,\n label,\n ariaLabel,\n options,\n value,\n placeholder,\n size,\n error,\n disabled,\n coarse,\n fieldAria,\n onCommit,\n}: {\n rid: string;\n /** The field label - shown as the sheet header on touch so the picker has context. */\n label?: string;\n /** Falls back to `label` when there's no visible one at all. */\n ariaLabel?: string;\n options: SelectOption[];\n value: string;\n placeholder?: string;\n size: NonNullable<SelectProps['size']>;\n error: boolean;\n disabled?: boolean;\n /** Touch: open as a bottom sheet with finger-sized rows instead of a dropdown. */\n coarse: boolean;\n /** `aria-invalid` / `aria-describedby` tying the trigger to the field's hint / error line. */\n fieldAria: ReturnType<typeof fieldA11y>;\n onCommit: (v: string) => void;\n}) {\n const listboxId = `${rid}-listbox`;\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const panelRef = React.useRef<HTMLUListElement>(null);\n const typeahead = React.useRef<{ str: string; timer: number }>({ str: '', timer: 0 });\n // A <label htmlFor> forwards a fully-trusted click to this button (detail:1),\n // indistinguishable from a direct one - but its *pointerdown* landed on the\n // label, not here. So only toggle when the press actually started on the box.\n const pressedAt = React.useRef(0);\n\n const [open, setOpen] = React.useState(false);\n const [activeIndex, setActiveIndex] = React.useState(-1);\n const [mounted, setMounted] = React.useState(false);\n // eslint-disable-next-line react-hooks/set-state-in-effect -- portal target is client-only\n React.useEffect(() => setMounted(true), []);\n // Where the dropdown sits (inline under the field, or portalled to the body inside a Dialog): see\n // `useMenuPlacement`. The touch sheet needs no anchoring.\n const place = useMenuPlacement({\n open,\n disabled: coarse,\n anchorRef: triggerRef,\n panelRef,\n itemCount: options.length,\n onDismiss: () => setOpen(false),\n });\n\n const selectedIndex = options.findIndex((o) => o.value === value);\n const selected = selectedIndex >= 0 ? options[selectedIndex] : undefined;\n\n const firstEnabled = () => options.findIndex((o) => !o.disabled);\n const lastEnabled = () => {\n for (let i = options.length - 1; i >= 0; i--) if (!options[i].disabled) return i;\n return -1;\n };\n const nextEnabled = (from: number, dir: 1 | -1) => {\n let i = from;\n for (let step = 0; step < options.length; step++) {\n i += dir;\n if (i < 0 || i >= options.length) return from;\n if (!options[i].disabled) return i;\n }\n return from;\n };\n\n // Close on outside pointerdown (the touch sheet uses its own scrim instead).\n useOutsidePress(open && !coarse, [triggerRef, panelRef], () => setOpen(false));\n\n // The touch sheet is a modal surface - lock the page scroll behind it. Through the shared lock,\n // so a Select inside a Dialog (two held at once) frees the page whichever lets go first.\n React.useEffect(() => {\n if (!open || !coarse) return;\n return acquireScrollLock();\n }, [open, coarse]);\n\n // Keep the active option in view, the first time the list opens too (SS-568): see `useRevealActive`.\n useRevealActive(open, activeIndex >= 0 ? `${rid}-opt-${activeIndex}` : null, place);\n\n const openMenu = () => {\n if (disabled) return;\n setActiveIndex(selectedIndex >= 0 ? selectedIndex : firstEnabled());\n setOpen(true);\n };\n const closeMenu = (refocus = true) => {\n setOpen(false);\n if (refocus) triggerRef.current?.focus({ preventScroll: true });\n };\n const choose = (i: number) => {\n const o = options[i];\n if (!o || o.disabled) return;\n onCommit(o.value);\n closeMenu();\n };\n\n const onKeyDown = (e: React.KeyboardEvent) => {\n if (disabled) return;\n switch (e.key) {\n case 'ArrowDown':\n e.preventDefault();\n if (!open) return openMenu();\n setActiveIndex((i) => nextEnabled(i < 0 ? -1 : i, 1));\n return;\n case 'ArrowUp':\n e.preventDefault();\n if (!open) return openMenu();\n setActiveIndex((i) => nextEnabled(i < 0 ? options.length : i, -1));\n return;\n case 'Home':\n if (open) {\n e.preventDefault();\n setActiveIndex(firstEnabled());\n }\n return;\n case 'End':\n if (open) {\n e.preventDefault();\n setActiveIndex(lastEnabled());\n }\n return;\n case 'Enter':\n case ' ':\n e.preventDefault();\n if (!open) return openMenu();\n choose(activeIndex);\n return;\n case 'Escape':\n if (open) {\n e.preventDefault();\n // Only the list closes: a Dialog around the field keeps its own Esc for the next press.\n // (`stopImmediate...` too: React may listen on `document`, where the Dialog listens as well.)\n e.stopPropagation();\n e.nativeEvent.stopImmediatePropagation();\n closeMenu();\n }\n return;\n case 'Tab':\n if (open) setOpen(false);\n return;\n default:\n if (e.key.length === 1 && !e.metaKey && !e.ctrlKey && !e.altKey) {\n const ta = typeahead.current;\n ta.str += e.key.toLowerCase();\n window.clearTimeout(ta.timer);\n ta.timer = window.setTimeout(() => (ta.str = ''), 500);\n const match = options.findIndex((o) => !o.disabled && o.label.toLowerCase().startsWith(ta.str));\n if (match >= 0) {\n if (!open) openMenu();\n setActiveIndex(match);\n }\n }\n }\n };\n\n const hasValue = !!selected;\n const rowPadY = menuRowPadY(coarse, size);\n\n const listStyleBase: React.CSSProperties = { ...menuSurfaceStyle(size), ...menuListStyle };\n const optionRows = options.map((o, i) => (\n <MenuOption\n key={o.value}\n id={`${rid}-opt-${i}`}\n label={o.label}\n selected={o.value === value}\n active={i === activeIndex}\n disabled={o.disabled}\n coarse={coarse}\n padY={rowPadY}\n onPointerEnter={() => !o.disabled && setActiveIndex(i)}\n onClick={() => choose(i)}\n />\n ));\n\n return (\n <div style={sx({ position: 'relative', width: '100%' })}>\n <button\n ref={triggerRef}\n type=\"button\"\n id={rid}\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n aria-expanded={open}\n aria-controls={open ? listboxId : undefined}\n aria-activedescendant={open && activeIndex >= 0 ? `${rid}-opt-${activeIndex}` : undefined}\n aria-label={ariaLabel}\n {...fieldAria}\n aria-disabled={disabled || undefined}\n disabled={disabled}\n onPointerDown={() => {\n pressedAt.current = Date.now();\n }}\n onMouseDown={(e) => {\n // Take focus without the browser scrolling us into view.\n e.preventDefault();\n triggerRef.current?.focus({ preventScroll: true });\n }}\n onClick={() => {\n // Only toggle when the press started on this button - a click forwarded\n // from the field <label>, or synthesised by the keyboard, never set\n // pressedAt (keyboard is handled in onKeyDown).\n if (Date.now() - pressedAt.current > 500) return;\n pressedAt.current = 0;\n if (open) closeMenu(false);\n else openMenu();\n }}\n onKeyDown={onKeyDown}\n {...fieldBoxProps(open)}\n style={fieldBoxStyle(size, error, !!disabled)}\n >\n <span\n style={sx({\n flex: 1,\n minWidth: 0,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n color: hasValue ? 'inherit' : 'var(--text-muted)',\n })}\n >\n {hasValue ? selected!.label : placeholder ?? 'Select…'}\n </span>\n <span\n aria-hidden=\"true\"\n style={sx({\n display: 'flex',\n flex: '0 0 auto',\n color: 'var(--text-muted)',\n transition: 'transform var(--duration-fast) var(--ease-standard)',\n transform: open ? 'rotate(180deg)' : 'none',\n })}\n >\n <ChevronDown size={16} strokeWidth={1.75} />\n </span>\n </button>\n\n {open && mounted && coarse &&\n createPortal(\n <div\n role=\"presentation\"\n onClick={() => closeMenu()}\n style={sx({\n position: 'fixed',\n inset: 0,\n zIndex: 1100,\n display: 'flex',\n alignItems: 'flex-end',\n background: 'var(--bg-overlay)',\n backdropFilter: 'blur(2px)',\n animation: 'sereno-fade-in var(--duration-fast) var(--ease-standard)',\n })}\n >\n <div\n onClick={(e) => e.stopPropagation()}\n style={sx({\n width: '100%',\n maxHeight: '70dvh',\n display: 'flex',\n flexDirection: 'column',\n background: 'var(--bg-surface)',\n borderRadius: 'var(--radius-sheet) var(--radius-sheet) 0 0',\n boxShadow: 'var(--shadow-sheet)',\n paddingBottom: 'env(safe-area-inset-bottom)',\n animation: 'sereno-slide-up var(--duration-sheet) var(--ease-gentle)',\n })}\n >\n {label && (\n <div\n style={sx({\n flex: '0 0 auto',\n padding: 'var(--space-3) var(--space-4)',\n borderBottom: 'var(--border-width-hairline) solid var(--border-subtle)',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-base)',\n fontWeight: 'var(--weight-semibold)',\n letterSpacing: 'var(--tracking-snug)',\n color: 'var(--text-primary)',\n })}\n >\n {label}\n </div>\n )}\n <ul\n ref={panelRef}\n id={listboxId}\n role=\"listbox\"\n aria-label={label}\n tabIndex={-1}\n style={sx({\n ...listStyleBase,\n flex: '1 1 auto',\n minHeight: 0,\n border: 'none',\n borderRadius: 0,\n boxShadow: 'none',\n background: 'transparent',\n padding: 'var(--space-2)',\n overscrollBehavior: 'contain', // don't chain the list's scroll to the page\n })}\n >\n {optionRows}\n </ul>\n </div>\n </div>,\n document.body,\n )}\n {open && !coarse && place && place.strategy === 'inline' && (\n <ul\n ref={panelRef}\n id={listboxId}\n role=\"listbox\"\n tabIndex={-1}\n style={sx({\n ...listStyleBase,\n position: 'absolute',\n left: 0,\n right: 0,\n ...(place.above ? { bottom: 'calc(100% + 6px)' } : { top: 'calc(100% + 6px)' }),\n maxHeight: place.maxH,\n zIndex: 100,\n })}\n >\n {optionRows}\n </ul>\n )}\n {open && !coarse && mounted && place && place.strategy === 'fixed' &&\n createPortal(\n <ul\n ref={panelRef}\n id={listboxId}\n role=\"listbox\"\n tabIndex={-1}\n style={sx({\n ...listStyleBase,\n position: 'fixed',\n top: place.top,\n left: place.left,\n width: place.width,\n ...(place.above ? { transform: 'translateY(-100%)' } : null),\n maxHeight: place.maxH,\n zIndex: 1100,\n })}\n >\n {optionRows}\n </ul>,\n document.body,\n )}\n </div>\n );\n}\n\n/**\n * `ref` reaches the hidden `<input type=\"hidden\">` that mirrors the selected\n * value (rendered only when `name` is set - pass it, as `register()` does).\n * Enough for `getValues()` / `trigger()` / `setFocus()`, but a plain\n * `{...register(name)}` spread still won't validate on change: this hidden\n * input never dispatches a native `input`/`change` event, and `onValueChange`\n * hands back a plain string, not a `ChangeEvent` - wire it through\n * `Controller`, or call the registered `onChange` yourself from\n * `onValueChange`.\n */\nexport const Select = React.forwardRef<HTMLInputElement, SelectProps>(function Select({\n label,\n hint,\n error,\n required,\n options = [],\n placeholder,\n size = 'md',\n disabled,\n value: valueProp,\n defaultValue,\n onValueChange,\n name,\n id,\n containerStyle,\n 'aria-label': ariaLabel,\n preserveHelperSpace,\n}: SelectProps, ref) {\n const reactId = React.useId();\n const rid = id || reactId;\n const isControlled = valueProp !== undefined;\n const [internalValue, setInternalValue] = React.useState(defaultValue ?? '');\n const value = isControlled ? valueProp! : internalValue;\n const coarse = useCoarsePointer();\n\n const commit = React.useCallback(\n (v: string) => {\n if (!isControlled) setInternalValue(v);\n onValueChange?.(v);\n },\n [isControlled, onValueChange],\n );\n\n return (\n <Field label={label} hint={hint} error={error} required={required} requiredExposed htmlFor={rid} style={containerStyle} preserveHelperSpace={preserveHelperSpace}>\n <CustomSelect\n rid={rid}\n label={label}\n ariaLabel={ariaLabel}\n options={options}\n value={value}\n placeholder={placeholder}\n size={size}\n error={!!error}\n disabled={disabled}\n coarse={coarse}\n fieldAria={fieldA11y(rid, { hint, error, required })}\n onCommit={commit}\n />\n {name && <input ref={ref} type=\"hidden\" name={name} value={value} />}\n </Field>\n );\n});\n\nSelect.displayName = 'Select';\n"],"mappings":";AA0OI,cAgBE,YAhBF;AAxOJ,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,SAAS,UAAU;AACnB,SAAS,yBAAyB;AAClC,SAAS,wBAAwB;AACjC,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAChC,SAAS,uBAAuB;AAChC,SAAS,YAAY,eAAe,aAAa,wBAAwB;AACzE,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAoD9B,SAAS,aAAa;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAiBG;AACD,QAAM,YAAY,GAAG,GAAG;AACxB,QAAM,aAAa,MAAM,OAA0B,IAAI;AACvD,QAAM,WAAW,MAAM,OAAyB,IAAI;AACpD,QAAM,YAAY,MAAM,OAAuC,EAAE,KAAK,IAAI,OAAO,EAAE,CAAC;AAIpF,QAAM,YAAY,MAAM,OAAO,CAAC;AAEhC,QAAM,CAAC,MAAM,OAAO,IAAI,MAAM,SAAS,KAAK;AAC5C,QAAM,CAAC,aAAa,cAAc,IAAI,MAAM,SAAS,EAAE;AACvD,QAAM,CAAC,SAAS,UAAU,IAAI,MAAM,SAAS,KAAK;AAElD,QAAM,UAAU,MAAM,WAAW,IAAI,GAAG,CAAC,CAAC;AAG1C,QAAM,QAAQ,iBAAiB;AAAA,IAC7B;AAAA,IACA,UAAU;AAAA,IACV,WAAW;AAAA,IACX;AAAA,IACA,WAAW,QAAQ;AAAA,IACnB,WAAW,MAAM,QAAQ,KAAK;AAAA,EAChC,CAAC;AAED,QAAM,gBAAgB,QAAQ,UAAU,CAAC,MAAM,EAA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AO,CAAC,CAAC;AAAA,QACT;AAAA,QACA;AAAA,QACA,WAAW,UAAU,KAAK,EAAE,MAAM,OAAO,SAAS,CAAC;AAAA,QACnD,UAAU;AAAA;AAAA,IACZ;AAAA,IACC,QAAQ,oBAAC,WAAM,KAAU,MAAK,UAAS,MAAY,OAAc;AAAA,KACpE;AAEJ,CAAC;AAED,OAAO,cAAc;","names":["Select"]}
@@ -7,6 +7,7 @@ import { fieldA11y } from "../_internal/fieldA11y.js";
7
7
  import { CharCount } from "../_internal/CharCount.js";
8
8
  import { mergeRefs } from "../_internal/mergeRefs.js";
9
9
  import { useValueLength } from "../_internal/useValueLength.js";
10
+ import { fieldFrameVars } from "./_internal/fieldFrame.js";
10
11
  const Textarea = React.forwardRef(function Textarea2({
11
12
  label,
12
13
  hint,
@@ -19,15 +20,12 @@ const Textarea = React.forwardRef(function Textarea2({
19
20
  id,
20
21
  style,
21
22
  containerStyle,
22
- onChange,
23
- onFocus,
24
- onBlur,
23
+ className,
25
24
  "aria-describedby": describedBy,
26
25
  "aria-invalid": invalid,
27
26
  "aria-required": ariaRequired,
28
27
  ...rest
29
28
  }, ref) {
30
- const [focus, setFocus] = React.useState(false);
31
29
  const textareaRef = React.useRef(null);
32
30
  const setRefs = React.useMemo(() => mergeRefs(textareaRef, ref), [ref]);
33
31
  const autoId = React.useId();
@@ -41,14 +39,6 @@ const Textarea = React.forwardRef(function Textarea2({
41
39
  typeof rest.defaultValue === "string" || typeof rest.defaultValue === "number" ? String(rest.defaultValue).length : 0
42
40
  );
43
41
  const count = rest.value !== void 0 ? String(rest.value ?? "").length : uncount;
44
- const handleFocus = (e) => {
45
- setFocus(true);
46
- onFocus?.(e);
47
- };
48
- const handleBlur = (e) => {
49
- setFocus(false);
50
- onBlur?.(e);
51
- };
52
42
  return /* @__PURE__ */ jsx(
53
43
  Field,
54
44
  {
@@ -70,17 +60,16 @@ const Textarea = React.forwardRef(function Textarea2({
70
60
  disabled,
71
61
  ...rest,
72
62
  ...a11y,
73
- onFocus: handleFocus,
74
- onBlur: handleBlur,
75
- onChange,
63
+ className: ["sereno-field", className].filter(Boolean).join(" "),
76
64
  style: sx({
65
+ ...fieldFrameVars(!!error),
77
66
  width: "100%",
78
67
  padding: "var(--space-3)",
79
68
  resize: "vertical",
80
69
  borderRadius: "var(--radius-control)",
81
70
  background: disabled ? "var(--interactive-disabled-bg)" : "var(--bg-surface)",
82
- border: "var(--border-width-hairline) solid " + (error ? "var(--interactive-error)" : focus ? "var(--border-focus)" : "var(--border-default)"),
83
- boxShadow: focus && !error ? "var(--focus-ring)" : "none",
71
+ borderWidth: "var(--border-width-hairline)",
72
+ borderStyle: "solid",
84
73
  outline: "none",
85
74
  fontFamily: "var(--font-body)",
86
75
  fontSize: "var(--text-base)",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/forms/Textarea.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\nimport { Field } from '../_internal/Field';\nimport { fieldA11y } from '../_internal/fieldA11y';\nimport { CharCount } from '../_internal/CharCount';\nimport { mergeRefs } from '../_internal/mergeRefs';\nimport { useValueLength } from '../_internal/useValueLength';\n\n/** Multi-line field for booking notes and service descriptions. */\nexport interface TextareaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {\n label?: string;\n hint?: string;\n error?: string;\n required?: boolean;\n rows?: number;\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\nexport const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(function Textarea(\n {\n label,\n hint,\n error,\n required,\n rows = 4,\n showCount,\n preserveHelperSpace,\n disabled,\n id,\n style,\n containerStyle,\n onChange,\n onFocus,\n onBlur,\n 'aria-describedby': describedBy,\n 'aria-invalid': invalid,\n 'aria-required': ariaRequired,\n ...rest\n },\n ref,\n) {\n const [focus, setFocus] = React.useState(false);\n const textareaRef = React.useRef<HTMLTextAreaElement>(null);\n // Stable across renders, so a form library's ref callback isn't detached and re-attached each time.\n const setRefs = React.useMemo(() => mergeRefs(textareaRef, ref), [ref]);\n // SSR-stable id (the DS source used Math.random(), which breaks hydration).\n const autoId = React.useId();\n const rid = id || autoId;\n // Names the hint / error line and flags the error, so a screen reader reads both with the field.\n const a11y = fieldA11y(rid, { hint, error, describedBy, invalid, required, ariaRequired });\n\n const max = typeof rest.maxLength === 'number' ? rest.maxLength : undefined;\n const showCounter = Boolean(showCount) || max != null;\n // Controlled: the count comes from `value`. Uncontrolled: from the element itself, so a\n // value written by code (react-hook-form's `reset()` / `setValue()`, `el.value = …`) counts too.\n const uncount = useValueLength(\n textareaRef,\n showCounter && rest.value === undefined,\n typeof rest.defaultValue === 'string' || typeof rest.defaultValue === 'number' ? String(rest.defaultValue).length : 0,\n );\n const count = rest.value !== undefined ? String(rest.value ?? '').length : uncount;\n\n // Destructured (not left in `...rest`) and always re-composed - same\n // reason as `handleChange` above: a caller's own onFocus/onBlur (or\n // react-hook-form's `register()`, which always injects its own onBlur)\n // must never silently replace the focus ring's, the way a plain\n // `{...rest}` spread after them used to.\n const handleFocus = (e: React.FocusEvent<HTMLTextAreaElement>) => {\n setFocus(true);\n onFocus?.(e);\n };\n const handleBlur = (e: React.FocusEvent<HTMLTextAreaElement>) => {\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 requiredExposed\n htmlFor={rid}\n style={containerStyle}\n counter={showCounter ? <CharCount count={count} max={max} /> : undefined}\n preserveHelperSpace={preserveHelperSpace}\n >\n <textarea\n id={rid}\n ref={setRefs}\n rows={rows}\n disabled={disabled}\n {...rest}\n {...a11y}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onChange={onChange}\n style={sx({\n width: '100%',\n padding: 'var(--space-3)',\n resize: 'vertical',\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 ? 'var(--focus-ring)' : 'none',\n outline: 'none',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-base)',\n lineHeight: 'var(--leading-normal)',\n color: disabled ? 'var(--text-disabled)' : 'var(--text-primary)',\n transition: 'var(--transition-control)',\n ...style,\n })}\n />\n </Field>\n );\n});\n\nTextarea.displayName = 'Textarea';"],"mappings":";AA+F6B;AA7F7B,YAAY,WAAW;AACvB,SAAS,UAAU;AACnB,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,sBAAsB;AAoBxB,MAAM,WAAW,MAAM,WAA+C,SAASA,UACpF;AAAA,EACE;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,oBAAoB;AAAA,EACpB,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,EACjB,GAAG;AACL,GACA,KACA;AACA,QAAM,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAS,KAAK;AAC9C,QAAM,cAAc,MAAM,OAA4B,IAAI;AAE1D,QAAM,UAAU,MAAM,QAAQ,MAAM,UAAU,aAAa,GAAG,GAAG,CAAC,GAAG,CAAC;AAEtE,QAAM,SAAS,MAAM,MAAM;AAC3B,QAAM,MAAM,MAAM;AAElB,QAAM,OAAO,UAAU,KAAK,EAAE,MAAM,OAAO,aAAa,SAAS,UAAU,aAAa,CAAC;AAEzF,QAAM,MAAM,OAAO,KAAK,cAAc,WAAW,KAAK,YAAY;AAClE,QAAM,cAAc,QAAQ,S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}
1
+ {"version":3,"sources":["../../src/forms/Textarea.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\nimport { Field } from '../_internal/Field';\nimport { fieldA11y } from '../_internal/fieldA11y';\nimport { CharCount } from '../_internal/CharCount';\nimport { mergeRefs } from '../_internal/mergeRefs';\nimport { useValueLength } from '../_internal/useValueLength';\nimport { fieldFrameVars } from './_internal/fieldFrame';\n\n/** Multi-line field for booking notes and service descriptions. */\nexport interface TextareaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {\n label?: string;\n hint?: string;\n error?: string;\n required?: boolean;\n rows?: number;\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\nexport const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(function Textarea(\n {\n label,\n hint,\n error,\n required,\n rows = 4,\n showCount,\n preserveHelperSpace,\n disabled,\n id,\n style,\n containerStyle,\n className,\n 'aria-describedby': describedBy,\n 'aria-invalid': invalid,\n 'aria-required': ariaRequired,\n ...rest\n },\n ref,\n) {\n const textareaRef = React.useRef<HTMLTextAreaElement>(null);\n // Stable across renders, so a form library's ref callback isn't detached and re-attached each time.\n const setRefs = React.useMemo(() => mergeRefs(textareaRef, ref), [ref]);\n // SSR-stable id (the DS source used Math.random(), which breaks hydration).\n const autoId = React.useId();\n const rid = id || autoId;\n // Names the hint / error line and flags the error, so a screen reader reads both with the field.\n const a11y = fieldA11y(rid, { hint, error, describedBy, invalid, required, ariaRequired });\n\n const max = typeof rest.maxLength === 'number' ? rest.maxLength : undefined;\n const showCounter = Boolean(showCount) || max != null;\n // Controlled: the count comes from `value`. Uncontrolled: from the element itself, so a\n // value written by code (react-hook-form's `reset()` / `setValue()`, `el.value = …`) counts too.\n const uncount = useValueLength(\n textareaRef,\n showCounter && rest.value === undefined,\n typeof rest.defaultValue === 'string' || typeof rest.defaultValue === 'number' ? String(rest.defaultValue).length : 0,\n );\n const count = rest.value !== undefined ? String(rest.value ?? '').length : uncount;\n\n return (\n <Field\n label={label}\n hint={hint}\n error={error}\n required={required}\n requiredExposed\n htmlFor={rid}\n style={containerStyle}\n counter={showCounter ? <CharCount count={count} max={max} /> : undefined}\n preserveHelperSpace={preserveHelperSpace}\n >\n <textarea\n id={rid}\n ref={setRefs}\n rows={rows}\n disabled={disabled}\n {...rest}\n {...a11y}\n // The border colour and the focus ring are CSS (`.sereno-field:focus` in styles.css, SS-582): the field\n // keeps no focus state, and a caller's `onFocus` / `onBlur` (react-hook-form's `register()` injects\n // one) stays in `...rest`, untouched.\n className={['sereno-field', className].filter(Boolean).join(' ')}\n style={sx({\n ...fieldFrameVars(!!error),\n width: '100%',\n padding: 'var(--space-3)',\n resize: 'vertical',\n borderRadius: 'var(--radius-control)',\n background: disabled ? 'var(--interactive-disabled-bg)' : 'var(--bg-surface)',\n borderWidth: 'var(--border-width-hairline)',\n borderStyle: 'solid',\n outline: 'none',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-base)',\n lineHeight: 'var(--leading-normal)',\n color: disabled ? 'var(--text-disabled)' : 'var(--text-primary)',\n transition: 'var(--transition-control)',\n ...style,\n })}\n />\n </Field>\n );\n});\n\nTextarea.displayName = 'Textarea';"],"mappings":";AA+E6B;AA7E7B,YAAY,WAAW;AACvB,SAAS,UAAU;AACnB,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAoBxB,MAAM,WAAW,MAAM,WAA+C,SAASA,UACpF;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAC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AAA,YACd,YAAY,WAAW,mCAAmC;AAAA,YAC1D,aAAa;AAAA,YACb,aAAa;AAAA,YACb,SAAS;AAAA,YACT,YAAY;AAAA,YACZ,UAAU;AAAA,YACV,YAAY;AAAA,YACZ,OAAO,WAAW,yBAAyB;AAAA,YAC3C,YAAY;AAAA,YACZ,GAAG;AAAA,UACL,CAAC;AAAA;AAAA,MACH;AAAA;AAAA,EACF;AAEJ,CAAC;AAED,SAAS,cAAc;","names":["Textarea"]}
@@ -5,10 +5,14 @@ declare const CONTROL_HEIGHT: Record<FieldBoxSize, string>;
5
5
  /**
6
6
  * The bordered field-box chrome shared by any control whose trigger looks
7
7
  * like a text field but opens something else on click - `Select`'s
8
- * `<button role="combobox">`, `DatePicker`'s calendar trigger (SS-243).
8
+ * `<button role="combobox">`, `DatePicker`'s calendar trigger (SS-243),
9
+ * `Autocomplete`'s text box.
9
10
  * Not for `Input`/`Textarea` themselves - those style their own `<input>`/
10
11
  * `<textarea>` directly, with no separate "trigger vs. panel" split.
12
+ *
13
+ * The border colour and the focus ring are not here: the caller spreads `fieldBoxProps(open)` for the class
14
+ * and the open flag, and `styles.css` draws them from the `--sd-*` values this sets (see `fieldFrame.ts`).
11
15
  */
12
- declare function fieldBoxStyle(size: FieldBoxSize, error: boolean, open: boolean, disabled: boolean): CSSProperties;
16
+ declare function fieldBoxStyle(size: FieldBoxSize, error: boolean, disabled: boolean): CSSProperties;
13
17
 
14
18
  export { CONTROL_HEIGHT, type FieldBoxSize, fieldBoxStyle };
@@ -1,12 +1,13 @@
1
1
  import { sx } from "../../_internal/style.js";
2
+ import { fieldFrameVars } from "./fieldFrame.js";
2
3
  const CONTROL_HEIGHT = {
3
4
  sm: "var(--control-height-sm)",
4
5
  md: "var(--control-height-md)",
5
6
  lg: "var(--control-height-lg)"
6
7
  };
7
- function fieldBoxStyle(size, error, open, disabled) {
8
- const active = open && !error;
8
+ function fieldBoxStyle(size, error, disabled) {
9
9
  return sx({
10
+ ...fieldFrameVars(error),
10
11
  display: "flex",
11
12
  alignItems: "center",
12
13
  gap: "var(--space-2)",
@@ -20,8 +21,9 @@ function fieldBoxStyle(size, error, open, disabled) {
20
21
  paddingLeft: "var(--space-3)",
21
22
  borderRadius: "var(--radius-control)",
22
23
  background: disabled ? "var(--interactive-disabled-bg)" : "var(--bg-surface)",
23
- border: "var(--border-width-hairline) solid " + (error ? "var(--interactive-error)" : open ? "var(--border-focus)" : "var(--border-default)"),
24
- boxShadow: active ? "var(--focus-ring)" : "none",
24
+ // Width and style only: the colour is `border-color: var(--sd-bd)` in styles.css, so a state can change it.
25
+ borderWidth: "var(--border-width-hairline)",
26
+ borderStyle: "solid",
25
27
  fontFamily: "var(--font-body)",
26
28
  fontSize: size === "sm" ? "var(--text-sm)" : "var(--text-base)",
27
29
  color: disabled ? "var(--text-disabled)" : "var(--text-primary)",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/forms/_internal/fieldBoxStyle.ts"],"sourcesContent":["import type { CSSProperties } from 'react';\nimport { sx } from '../../_internal/style';\n\nexport type FieldBoxSize = 'sm' | 'md' | 'lg';\n\nexport const CONTROL_HEIGHT: Record<FieldBoxSize, string> = {\n sm: 'var(--control-height-sm)',\n md: 'var(--control-height-md)',\n lg: 'var(--control-height-lg)',\n};\n\n/**\n * The bordered field-box chrome shared by any control whose trigger looks\n * like a text field but opens something else on click - `Select`'s\n * `<button role=\"combobox\">`, `DatePicker`'s calendar trigger (SS-243).\n * Not for `Input`/`Textarea` themselves - those style their own `<input>`/\n * `<textarea>` directly, with no separate \"trigger vs. panel\" split.\n */\nexport function fieldBoxStyle(size: FieldBoxSize, error: boolean, open: boolean, disabled: boolean): CSSProperties {\n const active = open && !error;\n return sx({\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-2)',\n width: '100%',\n height: CONTROL_HEIGHT[size],\n // Longhand (not the `padding` shorthand) so callers can override one side,\n // e.g. NativeSelect's right pad - without React leaving the others blank.\n paddingTop: 0,\n paddingRight: 'var(--space-3)',\n paddingBottom: 0,\n paddingLeft: '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)' : open ? 'var(--border-focus)' : 'var(--border-default)'),\n boxShadow: active ? 'var(--focus-ring)' : 'none',\n fontFamily: 'var(--font-body)',\n fontSize: size === 'sm' ? 'var(--text-sm)' : 'var(--text-base)',\n color: disabled ? 'var(--text-disabled)' : 'var(--text-primary)',\n cursor: disabled ? 'not-allowed' : 'pointer',\n transition: 'var(--transition-control)',\n textAlign: 'left',\n });\n}\n"],"mappings":"AACA,SAAS,UAAU;AAIZ,MAAM,iBAA+C;AAAA,EAC1D,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AASO,SAAS,cAAc,MAAoB,OAAgB,MAAe,UAAkC;AACjH,QAAM,SAAS,QAAQ,CAAC;AACxB,SAAO,GAAG;AAAA,IACR,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,KAAK;AAAA,IACL,OAAO;AAAA,IACP,QAAQ,eAAe,IAAI;AAAA;AAAA;AAAA,IAG3B,YAAY;AAAA,IACZ,cAAc;AAAA,IACd,eAAe;AAAA,IACf,aAAa;AAAA,IACb,cAAc;AAAA,IACd,YAAY,WAAW,mCAAmC;AAAA,IAC1D,QAAQ,yCAAyC,QAAQ,6BAA6B,OAAO,wBAAwB;AAAA,IACrH,WAAW,SAAS,sBAAsB;AAAA,IAC1C,YAAY;AAAA,IACZ,UAAU,SAAS,OAAO,mBAAmB;AAAA,IAC7C,OAAO,WAAW,yBAAyB;AAAA,IAC3C,QAAQ,WAAW,gBAAgB;AAAA,IACnC,YAAY;AAAA,IACZ,WAAW;AAAA,EACb,CAAC;AACH;","names":[]}
1
+ {"version":3,"sources":["../../../src/forms/_internal/fieldBoxStyle.ts"],"sourcesContent":["import type { CSSProperties } from 'react';\nimport { sx } from '../../_internal/style';\nimport { fieldFrameVars } from './fieldFrame';\n\nexport type FieldBoxSize = 'sm' | 'md' | 'lg';\n\nexport const CONTROL_HEIGHT: Record<FieldBoxSize, string> = {\n sm: 'var(--control-height-sm)',\n md: 'var(--control-height-md)',\n lg: 'var(--control-height-lg)',\n};\n\n/**\n * The bordered field-box chrome shared by any control whose trigger looks\n * like a text field but opens something else on click - `Select`'s\n * `<button role=\"combobox\">`, `DatePicker`'s calendar trigger (SS-243),\n * `Autocomplete`'s text box.\n * Not for `Input`/`Textarea` themselves - those style their own `<input>`/\n * `<textarea>` directly, with no separate \"trigger vs. panel\" split.\n *\n * The border colour and the focus ring are not here: the caller spreads `fieldBoxProps(open)` for the class\n * and the open flag, and `styles.css` draws them from the `--sd-*` values this sets (see `fieldFrame.ts`).\n */\nexport function fieldBoxStyle(size: FieldBoxSize, error: boolean, disabled: boolean): CSSProperties {\n return sx({\n ...fieldFrameVars(error),\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-2)',\n width: '100%',\n height: CONTROL_HEIGHT[size],\n // Longhand (not the `padding` shorthand) so callers can override one side,\n // e.g. NativeSelect's right pad - without React leaving the others blank.\n paddingTop: 0,\n paddingRight: 'var(--space-3)',\n paddingBottom: 0,\n paddingLeft: 'var(--space-3)',\n borderRadius: 'var(--radius-control)',\n background: disabled ? 'var(--interactive-disabled-bg)' : 'var(--bg-surface)',\n // Width and style only: the colour is `border-color: var(--sd-bd)` in styles.css, so a state can change it.\n borderWidth: 'var(--border-width-hairline)',\n borderStyle: 'solid',\n fontFamily: 'var(--font-body)',\n fontSize: size === 'sm' ? 'var(--text-sm)' : 'var(--text-base)',\n color: disabled ? 'var(--text-disabled)' : 'var(--text-primary)',\n cursor: disabled ? 'not-allowed' : 'pointer',\n transition: 'var(--transition-control)',\n textAlign: 'left',\n });\n}\n"],"mappings":"AACA,SAAS,UAAU;AACnB,SAAS,sBAAsB;AAIxB,MAAM,iBAA+C;AAAA,EAC1D,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AAaO,SAAS,cAAc,MAAoB,OAAgB,UAAkC;AAClG,SAAO,GAAG;AAAA,IACR,GAAG,eAAe,KAAK;AAAA,IACvB,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,KAAK;AAAA,IACL,OAAO;AAAA,IACP,QAAQ,eAAe,IAAI;AAAA;AAAA;AAAA,IAG3B,YAAY;AAAA,IACZ,cAAc;AAAA,IACd,eAAe;AAAA,IACf,aAAa;AAAA,IACb,cAAc;AAAA,IACd,YAAY,WAAW,mCAAmC;AAAA;AAAA,IAE1D,aAAa;AAAA,IACb,aAAa;AAAA,IACb,YAAY;AAAA,IACZ,UAAU,SAAS,OAAO,mBAAmB;AAAA,IAC7C,OAAO,WAAW,yBAAyB;AAAA,IAC3C,QAAQ,WAAW,gBAAgB;AAAA,IACnC,YAAY;AAAA,IACZ,WAAW;AAAA,EACb,CAAC;AACH;","names":[]}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The frame of a text-like field (the row of `Input`, the `Textarea`, the box of `Select`, `DatePicker` and
3
+ * `Autocomplete`): its border colour and its focus ring are CSS, not component state (SS-582).
4
+ *
5
+ * The component declares the colours as custom properties on the element and the `.sereno-field` rules of
6
+ * `styles.css` switch between them, so a field holds no `focus` state (before: a `useState` and an
7
+ * `onFocus` / `onBlur` pair per instance, re-rendering the field on every focus and blur):
8
+ *
9
+ * - `--sd-bd`: the border colour at rest.
10
+ * - `--sd-bd-active`: the border colour while the field is active (focused, or its popup is open).
11
+ * - `--sd-ring-active`: the `box-shadow` while active.
12
+ *
13
+ * An error keeps its border in both states and has no ring.
14
+ */
15
+ declare function fieldFrameVars(error: boolean): Record<string, string>;
16
+ /**
17
+ * For a box that is active because something is open (a `Select` or `DatePicker` popup, an `Autocomplete`
18
+ * list), not because it has the focus: the class that carries the frame rules, plus `data-active` while open.
19
+ * The focus itself needs nothing from the component, `styles.css` reads it from the `:focus` of the field.
20
+ */
21
+ declare function fieldBoxProps(open: boolean): {
22
+ className: string;
23
+ 'data-active'?: '';
24
+ };
25
+
26
+ export { fieldBoxProps, fieldFrameVars };
@@ -0,0 +1,11 @@
1
+ function fieldFrameVars(error) {
2
+ return error ? { "--sd-bd": "var(--interactive-error)", "--sd-bd-active": "var(--interactive-error)", "--sd-ring-active": "none" } : { "--sd-bd": "var(--border-default)", "--sd-bd-active": "var(--border-focus)", "--sd-ring-active": "var(--focus-ring)" };
3
+ }
4
+ function fieldBoxProps(open) {
5
+ return open ? { className: "sereno-field", "data-active": "" } : { className: "sereno-field" };
6
+ }
7
+ export {
8
+ fieldBoxProps,
9
+ fieldFrameVars
10
+ };
11
+ //# sourceMappingURL=fieldFrame.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/forms/_internal/fieldFrame.ts"],"sourcesContent":["/**\n * The frame of a text-like field (the row of `Input`, the `Textarea`, the box of `Select`, `DatePicker` and\n * `Autocomplete`): its border colour and its focus ring are CSS, not component state (SS-582).\n *\n * The component declares the colours as custom properties on the element and the `.sereno-field` rules of\n * `styles.css` switch between them, so a field holds no `focus` state (before: a `useState` and an\n * `onFocus` / `onBlur` pair per instance, re-rendering the field on every focus and blur):\n *\n * - `--sd-bd`: the border colour at rest.\n * - `--sd-bd-active`: the border colour while the field is active (focused, or its popup is open).\n * - `--sd-ring-active`: the `box-shadow` while active.\n *\n * An error keeps its border in both states and has no ring.\n */\nexport function fieldFrameVars(error: boolean): Record<string, string> {\n return error\n ? { '--sd-bd': 'var(--interactive-error)', '--sd-bd-active': 'var(--interactive-error)', '--sd-ring-active': 'none' }\n : { '--sd-bd': 'var(--border-default)', '--sd-bd-active': 'var(--border-focus)', '--sd-ring-active': 'var(--focus-ring)' };\n}\n\n/**\n * For a box that is active because something is open (a `Select` or `DatePicker` popup, an `Autocomplete`\n * list), not because it has the focus: the class that carries the frame rules, plus `data-active` while open.\n * The focus itself needs nothing from the component, `styles.css` reads it from the `:focus` of the field.\n */\nexport function fieldBoxProps(open: boolean): { className: string; 'data-active'?: '' } {\n return open ? { className: 'sereno-field', 'data-active': '' } : { className: 'sereno-field' };\n}\n"],"mappings":"AAcO,SAAS,eAAe,OAAwC;AACrE,SAAO,QACH,EAAE,WAAW,4BAA4B,kBAAkB,4BAA4B,oBAAoB,OAAO,IAClH,EAAE,WAAW,yBAAyB,kBAAkB,uBAAuB,oBAAoB,oBAAoB;AAC7H;AAOO,SAAS,cAAc,MAA0D;AACtF,SAAO,OAAO,EAAE,WAAW,gBAAgB,eAAe,GAAG,IAAI,EAAE,WAAW,eAAe;AAC/F;","names":[]}
@@ -83,9 +83,16 @@ function SidebarNavRoot({
83
83
  width: 26,
84
84
  height: 26,
85
85
  borderRadius: "999px",
86
- border: "var(--border-width-hairline) solid var(--border-default)",
87
- background: "var(--bg-surface)",
88
- color: "var(--text-secondary)",
86
+ // Fill, ink and border come from the `--sd-*` values (the hover is the `:hover` rule of
87
+ // `.sereno-sidenav-toggle`); set inline they would beat that rule and the hover would never show.
88
+ "--sd-bg": "var(--bg-surface)",
89
+ "--sd-bg-hover": "var(--interactive-secondary-hover)",
90
+ "--sd-fg": "var(--text-secondary)",
91
+ "--sd-fg-hover": "var(--text-primary)",
92
+ "--sd-bd": "var(--border-default)",
93
+ "--sd-bd-hover": "var(--border-strong)",
94
+ borderWidth: "var(--border-width-hairline)",
95
+ borderStyle: "solid",
89
96
  boxShadow: "var(--shadow-sm)",
90
97
  cursor: "pointer",
91
98
  transition: "var(--transition-control)"
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/navigation/SidebarNav.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { ChevronLeft } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { SidebarNavContext, type SidebarNavContextValue } from './_internal/sidebarNavContext';\nimport { Item, Section, SubItem } from './_internal/SidebarNavItems';\n\nexport type { SidebarNavItemProps, SidebarNavSectionProps, SidebarNavSubItemProps } from './_internal/SidebarNavItems';\n\n/**\n * Desktop primary navigation - a **compound component**, the counterpart to\n * `BottomNav`. Grouped sections with dividers, an optional second level per\n * item, and a collapse toggle that drops it to a 72px icon rail.\n *\n * ```tsx\n * <SidebarNav value={view} onChange={setView} header={<Wordmark />}>\n * <SidebarNav.Section label=\"Workspace\">\n * <SidebarNav.Item value=\"agenda\" label=\"Calendar\" icon={<Calendar size={18} />} />\n * <SidebarNav.Item value=\"finance\" label=\"Finance\" icon={<Wallet size={18} />}>\n * <SidebarNav.SubItem value=\"finance:incoming\" label=\"Incoming\" />\n * <SidebarNav.SubItem value=\"finance:payouts\" label=\"Payouts\" count={3} />\n * </SidebarNav.Item>\n * </SidebarNav.Section>\n * </SidebarNav>\n * ```\n *\n * `Item` is not a destination once it has `SubItem` children - it toggles\n * them instead (an inline accordion when expanded, a hover flyout on the\n * collapsed rail).\n */\nexport interface SidebarNavProps extends Omit<React.HTMLAttributes<HTMLElement>, 'onChange'> {\n value?: string;\n onChange?: (value: string) => void;\n /** Controlled collapse (icon-only rail). */\n collapsed?: boolean;\n defaultCollapsed?: boolean;\n onCollapsedChange?: (collapsed: boolean) => void;\n /** Show the collapse toggle in the footer. */\n collapsible?: boolean;\n /** Brand / logo slot at the top. */\n header?: React.ReactNode;\n /** Persistent slot pinned to the bottom (user card, plan nudge). Hidden while collapsed. */\n footer?: React.ReactNode;\n labels?: { expand?: string; collapse?: string };\n /** Component used to render items that carry `href` (e.g. Next's `Link`). Defaults to `'a'`. */\n linkComponent?: React.ElementType;\n /**\n * Disables every `Item` / `SubItem` at once - a gated area, an account that\n * isn't active yet. An item can still opt back in with its own\n * `disabled={false}` (e.g. a \"Help\" link that must stay reachable). Only the\n * destinations are affected: the collapse toggle, `header` and `footer` stay\n * live, since they aren't navigation.\n */\n disabled?: boolean;\n children: React.ReactNode;\n}\n\nconst EXPANDED = 248;\nconst COLLAPSED = 72;\n\nfunction SidebarNavRoot({\n value,\n onChange,\n collapsed: collapsedProp,\n defaultCollapsed = false,\n onCollapsedChange,\n collapsible = true,\n header,\n footer,\n labels,\n linkComponent,\n disabled = false,\n children,\n style,\n ...rest\n}: SidebarNavProps) {\n const [internalCollapsed, setInternalCollapsed] = React.useState(defaultCollapsed);\n const collapsed = collapsedProp ?? internalCollapsed;\n const setCollapsed = (c: boolean) => {\n if (collapsedProp === undefined) setInternalCollapsed(c);\n onCollapsedChange?.(c);\n };\n\n // Custom hover tooltip for the collapsed rail - portalled so the rail's own\n // overflow clipping can't hide it.\n const [mounted, setMounted] = React.useState(false);\n // eslint-disable-next-line react-hooks/set-state-in-effect -- portal target is client-only\n React.useEffect(() => setMounted(true), []);\n const [tip, setTip] = React.useState<{ label: string; top: number; left: number } | null>(null);\n React.useEffect(() => {\n // eslint-disable-next-line react-hooks/set-state-in-effect -- drop a stale tip when the rail expands\n if (!collapsed) setTip(null);\n }, [collapsed]);\n const showTip = (label: string, r: DOMRect) => setTip({ label, top: r.top + r.height / 2, left: r.right + 10 });\n const hideTip = () => setTip(null);\n\n // Single cross-item flyout for the collapsed rail (only one open at a time).\n const [flyoutValue, setFlyoutValue] = React.useState<string | null>(null);\n const flyoutTimer = React.useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const openFlyout = (v: string) => {\n clearTimeout(flyoutTimer.current);\n setFlyoutValue(v);\n };\n const closeFlyoutSoon = () => {\n clearTimeout(flyoutTimer.current);\n flyoutTimer.current = setTimeout(() => setFlyoutValue(null), 140);\n };\n const closeFlyoutNow = () => {\n clearTimeout(flyoutTimer.current);\n setFlyoutValue(null);\n };\n React.useEffect(() => () => clearTimeout(flyoutTimer.current), []);\n React.useEffect(() => {\n // eslint-disable-next-line react-hooks/set-state-in-effect -- drop a stale flyout when the rail expands\n if (!collapsed) setFlyoutValue(null);\n }, [collapsed]);\n\n const select = (v: string) => {\n closeFlyoutNow();\n onChange?.(v);\n };\n\n const ctx: SidebarNavContextValue = { value, disabled, select, collapsed, linkComponent, flyoutValue, openFlyout, closeFlyoutSoon, closeFlyoutNow, showTip, hideTip };\n\n // The collapse control straddles the sidebar's right edge, level with the logo.\n const toggleLabel = collapsed ? labels?.expand ?? 'Expand' : labels?.collapse ?? 'Collapse';\n const toggleBtn = collapsible ? (\n <button\n type=\"button\"\n className=\"sereno-sidenav-btn sereno-sidenav-toggle\"\n aria-label={toggleLabel}\n aria-pressed={collapsed}\n title={toggleLabel}\n onClick={() => setCollapsed(!collapsed)}\n style={sx({\n position: 'absolute',\n top: 'calc(var(--sidenav-header-h, 56px) / 2)',\n right: -13,\n transform: 'translateY(-50%)',\n zIndex: 5,\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n width: 26,\n height: 26,\n borderRadius: '999px',\n border: 'var(--border-width-hairline) solid var(--border-default)',\n background: 'var(--bg-surface)',\n color: 'var(--text-secondary)',\n boxShadow: 'var(--shadow-sm)',\n cursor: 'pointer',\n transition: 'var(--transition-control)',\n })}\n >\n <ChevronLeft\n size={15}\n strokeWidth={2}\n style={{ transition: 'transform var(--duration-normal) var(--ease-out)', transform: collapsed ? 'rotate(180deg)' : 'none' }}\n />\n </button>\n ) : null;\n\n return (\n <SidebarNavContext.Provider value={ctx}>\n <nav\n {...rest}\n className={['sereno-sidenav-root', rest.className].filter(Boolean).join(' ')}\n data-collapsed={collapsed ? '' : undefined}\n style={sx({\n position: 'relative',\n display: 'flex',\n flexDirection: 'column',\n flex: '0 0 auto',\n width: collapsed ? COLLAPSED : EXPANDED,\n height: '100%',\n background: 'var(--bg-surface)',\n borderRight: 'var(--border-width-hairline) solid var(--border-default)',\n transition: 'width var(--duration-normal) var(--ease-out)',\n ...style,\n })}\n >\n {toggleBtn}\n\n {header !== undefined && (\n <div\n style={sx({\n flex: '0 0 auto',\n display: 'flex',\n alignItems: 'center',\n justifyContent: collapsed ? 'center' : 'flex-start',\n height: 'var(--sidenav-header-h, 56px)',\n padding: collapsed ? '0' : '0 var(--space-4)',\n })}\n >\n <div style={sx({ minWidth: 0, overflow: 'hidden', display: 'flex', alignItems: 'center' })}>{header}</div>\n </div>\n )}\n\n <div\n className=\"sereno-sidenav\"\n style={sx({\n flex: 1,\n overflowY: 'auto',\n overflowX: 'hidden',\n padding: 'var(--space-2) var(--space-3)',\n display: 'flex',\n flexDirection: 'column',\n })}\n >\n {children}\n </div>\n\n {footer && !collapsed && (\n <div\n style={sx({\n borderTop: 'var(--border-width-hairline) solid var(--border-subtle)',\n padding: 'var(--space-3)',\n display: 'flex',\n flexDirection: 'column',\n gap: 'var(--space-2)',\n })}\n >\n {footer}\n </div>\n )}\n\n {mounted &&\n tip &&\n createPortal(\n <div\n role=\"tooltip\"\n style={sx({\n position: 'fixed',\n top: tip.top,\n left: tip.left,\n transform: 'translateY(-50%)',\n padding: '5px 9px',\n borderRadius: 'var(--radius-sm)',\n background: 'var(--bg-inverse)',\n color: 'var(--text-inverse)',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-xs)',\n fontWeight: 'var(--weight-medium)',\n lineHeight: 1,\n whiteSpace: 'nowrap',\n boxShadow: 'var(--shadow-md)',\n pointerEvents: 'none',\n zIndex: 1000,\n animation: 'sereno-fade-in var(--duration-fast) var(--ease-out)',\n })}\n >\n <span\n aria-hidden\n style={sx({\n position: 'absolute',\n left: -3,\n top: '50%',\n width: 6,\n height: 6,\n background: 'var(--bg-inverse)',\n transform: 'translateY(-50%) rotate(45deg)',\n borderRadius: 1,\n })}\n />\n {tip.label}\n </div>,\n document.body,\n )}\n </nav>\n </SidebarNavContext.Provider>\n );\n}\n\nexport const SidebarNav = Object.assign(SidebarNavRoot, { Section, Item, SubItem });\n"],"mappings":";AA4JM,cA2EM,YA3EN;AA1JN,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,SAAS,UAAU;AACnB,SAAS,yBAAsD;AAC/D,SAAS,MAAM,SAAS,eAAe;AAoDvC,MAAM,WAAW;AACjB,MAAM,YAAY;AAElB,SAAS,eAAe;AAAA,EACtB;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX,mBAAmB;AAAA,EACnB;AAAA,EACA,cAAc;AAAA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AAY;AAAA,gBACZ,YAAY;AAAA,gBACZ,WAAW;AAAA,gBACX,eAAe;AAAA,gBACf,QAAQ;AAAA,gBACR,WAAW;AAAA,cACb,CAAC;AAAA,cAED;AAAA;AAAA,kBAAC;AAAA;AAAA,oBACC,eAAW;AAAA,oBACX,OAAO,GAAG;AAAA,sBACR,UAAU;AAAA,sBACV,MAAM;AAAA,sBACN,KAAK;AAAA,sBACL,OAAO;AAAA,sBACP,QAAQ;AAAA,sBACR,YAAY;AAAA,sBACZ,WAAW;AAAA,sBACX,cAAc;AAAA,oBAChB,CAAC;AAAA;AAAA,gBACH;AAAA,gBACC,IAAI;AAAA;AAAA;AAAA,UACP;AAAA,UACA,SAAS;AAAA,QACX;AAAA;AAAA;AAAA,EACJ,GACF;AAEJ;AAEO,MAAM,aAAa,OAAO,OAAO,gBAAgB,EAAE,SAAS,MAAM,QAAQ,CAAC;","names":[]}
1
+ {"version":3,"sources":["../../src/navigation/SidebarNav.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { ChevronLeft } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { SidebarNavContext, type SidebarNavContextValue } from './_internal/sidebarNavContext';\nimport { Item, Section, SubItem } from './_internal/SidebarNavItems';\n\nexport type { SidebarNavItemProps, SidebarNavSectionProps, SidebarNavSubItemProps } from './_internal/SidebarNavItems';\n\n/**\n * Desktop primary navigation - a **compound component**, the counterpart to\n * `BottomNav`. Grouped sections with dividers, an optional second level per\n * item, and a collapse toggle that drops it to a 72px icon rail.\n *\n * ```tsx\n * <SidebarNav value={view} onChange={setView} header={<Wordmark />}>\n * <SidebarNav.Section label=\"Workspace\">\n * <SidebarNav.Item value=\"agenda\" label=\"Calendar\" icon={<Calendar size={18} />} />\n * <SidebarNav.Item value=\"finance\" label=\"Finance\" icon={<Wallet size={18} />}>\n * <SidebarNav.SubItem value=\"finance:incoming\" label=\"Incoming\" />\n * <SidebarNav.SubItem value=\"finance:payouts\" label=\"Payouts\" count={3} />\n * </SidebarNav.Item>\n * </SidebarNav.Section>\n * </SidebarNav>\n * ```\n *\n * `Item` is not a destination once it has `SubItem` children - it toggles\n * them instead (an inline accordion when expanded, a hover flyout on the\n * collapsed rail).\n */\nexport interface SidebarNavProps extends Omit<React.HTMLAttributes<HTMLElement>, 'onChange'> {\n value?: string;\n onChange?: (value: string) => void;\n /** Controlled collapse (icon-only rail). */\n collapsed?: boolean;\n defaultCollapsed?: boolean;\n onCollapsedChange?: (collapsed: boolean) => void;\n /** Show the collapse toggle in the footer. */\n collapsible?: boolean;\n /** Brand / logo slot at the top. */\n header?: React.ReactNode;\n /** Persistent slot pinned to the bottom (user card, plan nudge). Hidden while collapsed. */\n footer?: React.ReactNode;\n labels?: { expand?: string; collapse?: string };\n /** Component used to render items that carry `href` (e.g. Next's `Link`). Defaults to `'a'`. */\n linkComponent?: React.ElementType;\n /**\n * Disables every `Item` / `SubItem` at once - a gated area, an account that\n * isn't active yet. An item can still opt back in with its own\n * `disabled={false}` (e.g. a \"Help\" link that must stay reachable). Only the\n * destinations are affected: the collapse toggle, `header` and `footer` stay\n * live, since they aren't navigation.\n */\n disabled?: boolean;\n children: React.ReactNode;\n}\n\nconst EXPANDED = 248;\nconst COLLAPSED = 72;\n\nfunction SidebarNavRoot({\n value,\n onChange,\n collapsed: collapsedProp,\n defaultCollapsed = false,\n onCollapsedChange,\n collapsible = true,\n header,\n footer,\n labels,\n linkComponent,\n disabled = false,\n children,\n style,\n ...rest\n}: SidebarNavProps) {\n const [internalCollapsed, setInternalCollapsed] = React.useState(defaultCollapsed);\n const collapsed = collapsedProp ?? internalCollapsed;\n const setCollapsed = (c: boolean) => {\n if (collapsedProp === undefined) setInternalCollapsed(c);\n onCollapsedChange?.(c);\n };\n\n // Custom hover tooltip for the collapsed rail - portalled so the rail's own\n // overflow clipping can't hide it.\n const [mounted, setMounted] = React.useState(false);\n // eslint-disable-next-line react-hooks/set-state-in-effect -- portal target is client-only\n React.useEffect(() => setMounted(true), []);\n const [tip, setTip] = React.useState<{ label: string; top: number; left: number } | null>(null);\n React.useEffect(() => {\n // eslint-disable-next-line react-hooks/set-state-in-effect -- drop a stale tip when the rail expands\n if (!collapsed) setTip(null);\n }, [collapsed]);\n const showTip = (label: string, r: DOMRect) => setTip({ label, top: r.top + r.height / 2, left: r.right + 10 });\n const hideTip = () => setTip(null);\n\n // Single cross-item flyout for the collapsed rail (only one open at a time).\n const [flyoutValue, setFlyoutValue] = React.useState<string | null>(null);\n const flyoutTimer = React.useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const openFlyout = (v: string) => {\n clearTimeout(flyoutTimer.current);\n setFlyoutValue(v);\n };\n const closeFlyoutSoon = () => {\n clearTimeout(flyoutTimer.current);\n flyoutTimer.current = setTimeout(() => setFlyoutValue(null), 140);\n };\n const closeFlyoutNow = () => {\n clearTimeout(flyoutTimer.current);\n setFlyoutValue(null);\n };\n React.useEffect(() => () => clearTimeout(flyoutTimer.current), []);\n React.useEffect(() => {\n // eslint-disable-next-line react-hooks/set-state-in-effect -- drop a stale flyout when the rail expands\n if (!collapsed) setFlyoutValue(null);\n }, [collapsed]);\n\n const select = (v: string) => {\n closeFlyoutNow();\n onChange?.(v);\n };\n\n const ctx: SidebarNavContextValue = { value, disabled, select, collapsed, linkComponent, flyoutValue, openFlyout, closeFlyoutSoon, closeFlyoutNow, showTip, hideTip };\n\n // The collapse control straddles the sidebar's right edge, level with the logo.\n const toggleLabel = collapsed ? labels?.expand ?? 'Expand' : labels?.collapse ?? 'Collapse';\n const toggleBtn = collapsible ? (\n <button\n type=\"button\"\n className=\"sereno-sidenav-btn sereno-sidenav-toggle\"\n aria-label={toggleLabel}\n aria-pressed={collapsed}\n title={toggleLabel}\n onClick={() => setCollapsed(!collapsed)}\n style={sx({\n position: 'absolute',\n top: 'calc(var(--sidenav-header-h, 56px) / 2)',\n right: -13,\n transform: 'translateY(-50%)',\n zIndex: 5,\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n width: 26,\n height: 26,\n borderRadius: '999px',\n // Fill, ink and border come from the `--sd-*` values (the hover is the `:hover` rule of\n // `.sereno-sidenav-toggle`); set inline they would beat that rule and the hover would never show.\n '--sd-bg': 'var(--bg-surface)',\n '--sd-bg-hover': 'var(--interactive-secondary-hover)',\n '--sd-fg': 'var(--text-secondary)',\n '--sd-fg-hover': 'var(--text-primary)',\n '--sd-bd': 'var(--border-default)',\n '--sd-bd-hover': 'var(--border-strong)',\n borderWidth: 'var(--border-width-hairline)',\n borderStyle: 'solid',\n boxShadow: 'var(--shadow-sm)',\n cursor: 'pointer',\n transition: 'var(--transition-control)',\n })}\n >\n <ChevronLeft\n size={15}\n strokeWidth={2}\n style={{ transition: 'transform var(--duration-normal) var(--ease-out)', transform: collapsed ? 'rotate(180deg)' : 'none' }}\n />\n </button>\n ) : null;\n\n return (\n <SidebarNavContext.Provider value={ctx}>\n <nav\n {...rest}\n className={['sereno-sidenav-root', rest.className].filter(Boolean).join(' ')}\n data-collapsed={collapsed ? '' : undefined}\n style={sx({\n position: 'relative',\n display: 'flex',\n flexDirection: 'column',\n flex: '0 0 auto',\n width: collapsed ? COLLAPSED : EXPANDED,\n height: '100%',\n background: 'var(--bg-surface)',\n borderRight: 'var(--border-width-hairline) solid var(--border-default)',\n transition: 'width var(--duration-normal) var(--ease-out)',\n ...style,\n })}\n >\n {toggleBtn}\n\n {header !== undefined && (\n <div\n style={sx({\n flex: '0 0 auto',\n display: 'flex',\n alignItems: 'center',\n justifyContent: collapsed ? 'center' : 'flex-start',\n height: 'var(--sidenav-header-h, 56px)',\n padding: collapsed ? '0' : '0 var(--space-4)',\n })}\n >\n <div style={sx({ minWidth: 0, overflow: 'hidden', display: 'flex', alignItems: 'center' })}>{header}</div>\n </div>\n )}\n\n <div\n className=\"sereno-sidenav\"\n style={sx({\n flex: 1,\n overflowY: 'auto',\n overflowX: 'hidden',\n padding: 'var(--space-2) var(--space-3)',\n display: 'flex',\n flexDirection: 'column',\n })}\n >\n {children}\n </div>\n\n {footer && !collapsed && (\n <div\n style={sx({\n borderTop: 'var(--border-width-hairline) solid var(--border-subtle)',\n padding: 'var(--space-3)',\n display: 'flex',\n flexDirection: 'column',\n gap: 'var(--space-2)',\n })}\n >\n {footer}\n </div>\n )}\n\n {mounted &&\n tip &&\n createPortal(\n <div\n role=\"tooltip\"\n style={sx({\n position: 'fixed',\n top: tip.top,\n left: tip.left,\n transform: 'translateY(-50%)',\n padding: '5px 9px',\n borderRadius: 'var(--radius-sm)',\n background: 'var(--bg-inverse)',\n color: 'var(--text-inverse)',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-xs)',\n fontWeight: 'var(--weight-medium)',\n lineHeight: 1,\n whiteSpace: 'nowrap',\n boxShadow: 'var(--shadow-md)',\n pointerEvents: 'none',\n zIndex: 1000,\n animation: 'sereno-fade-in var(--duration-fast) var(--ease-out)',\n })}\n >\n <span\n aria-hidden\n style={sx({\n position: 'absolute',\n left: -3,\n top: '50%',\n width: 6,\n height: 6,\n background: 'var(--bg-inverse)',\n transform: 'translateY(-50%) rotate(45deg)',\n borderRadius: 1,\n })}\n />\n {tip.label}\n </div>,\n document.body,\n )}\n </nav>\n </SidebarNavContext.Provider>\n );\n}\n\nexport const SidebarNav = Object.assign(SidebarNavRoot, { Section, Item, SubItem });\n"],"mappings":";AAmKM,cA2EM,YA3EN;AAjKN,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,SAAS,UAAU;AACnB,SAAS,yBAAsD;AAC/D,SAAS,MAAM,SAAS,eAAe;AAoDvC,MAAM,WAAW;AACjB,MAAM,YAAY;AAElB,SAAS,eAAe;AAAA,EACtB;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX,mBAAmB;AAAA,EACnB;AAAA,EACA,cAAc;AAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA,GAAG;AACL,G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ACZ,YAAY;AAAA,gBACZ,YAAY;AAAA,gBACZ,WAAW;AAAA,gBACX,eAAe;AAAA,gBACf,QAAQ;AAAA,gBACR,WAAW;AAAA,cACb,CAAC;AAAA,cAED;AAAA;AAAA,kBAAC;AAAA;AAAA,oBACC,eAAW;AAAA,oBACX,OAAO,GAAG;AAAA,sBACR,UAAU;AAAA,sBACV,MAAM;AAAA,sBACN,KAAK;AAAA,sBACL,OAAO;AAAA,sBACP,QAAQ;AAAA,sBACR,YAAY;AAAA,sBACZ,WAAW;AAAA,sBACX,cAAc;AAAA,oBAChB,CAAC;AAAA;AAAA,gBACH;AAAA,gBACC,IAAI;AAAA;AAAA;AAAA,UACP;AAAA,UACA,SAAS;AAAA,QACX;AAAA;AAAA;AAAA,EACJ,GACF;AAEJ;AAEO,MAAM,aAAa,OAAO,OAAO,gBAAgB,EAAE,SAAS,MAAM,QAAQ,CAAC;","names":[]}
package/dist/styles.css CHANGED
@@ -120,6 +120,24 @@
120
120
  }
121
121
 
122
122
  /* A row of a small menu with only a hover fill (the AvatarUpload actions). */
123
+ /* ── Text fields: border colour and focus ring (SS-582) ─────────────────────────────────
124
+ The frame of `Input` (its row), `Textarea` and the boxes of `Select`, `DatePicker` and `Autocomplete`. The component
125
+ sets three values (`--sd-bd`, `--sd-bd-active`, `--sd-ring-active`, see `forms/_internal/fieldFrame.ts`); the
126
+ frame is "active" while:
127
+ - an `Input` or `Autocomplete` text box inside it has the focus (`:has(> input:focus)`, the direct child, so a
128
+ button in the row, the password eye for one, does not count: the same as when this was `onFocus` / `onBlur`),
129
+ - a `Textarea` has the focus,
130
+ - `data-active` is set, which `Select`, `DatePicker` and `Autocomplete` do while their popup is open.
131
+ Pointer and keyboard focus look the same, as they always did. The `:where()` keeps the active rule at the
132
+ specificity of `.sereno-field` (0,1,0), so an app's own class rule overrides either by coming later. */
133
+ .sereno-field {
134
+ border-color: var(--sd-bd, var(--border-default));
135
+ box-shadow: none;
136
+ }
137
+ .sereno-field:where(textarea:focus, :has(> input:focus), [data-active]) {
138
+ border-color: var(--sd-bd-active, var(--border-focus));
139
+ box-shadow: var(--sd-ring-active, var(--focus-ring));
140
+ }
123
141
  .sereno-menuitem {
124
142
  background: transparent;
125
143
  }
@@ -226,10 +244,19 @@
226
244
  .sereno-sidenav-row:hover {
227
245
  background: var(--sd-bg-hover, var(--sd-bg, transparent));
228
246
  }
247
+ /* The collapse control that straddles the rail's edge: SidebarNav declares its fill, ink and border and their
248
+ hover values (`--sd-bg`, `--sd-fg`, `--sd-bd`, each with `-hover`), as it does for the rows. The hover used to be
249
+ written here on its own, but the same three properties were also set inline on the button, and an inline
250
+ value beats any stylesheet rule, so the hover never showed. */
251
+ .sereno-sidenav-toggle {
252
+ background: var(--sd-bg);
253
+ color: var(--sd-fg);
254
+ border-color: var(--sd-bd);
255
+ }
229
256
  .sereno-sidenav-toggle:hover {
230
- background: var(--interactive-secondary-hover);
231
- color: var(--text-primary);
232
- border-color: var(--border-strong);
257
+ background: var(--sd-bg-hover, var(--sd-bg));
258
+ color: var(--sd-fg-hover, var(--sd-fg));
259
+ border-color: var(--sd-bd-hover, var(--sd-bd));
233
260
  }
234
261
 
235
262
  /* ── In-field affix button ───────────────────────────────────────────────────
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sereno-ds/ui",
3
- "version": "0.43.0",
3
+ "version": "0.44.0",
4
4
  "description": "Sereno Design System: React primitives (token-driven, inline styles, no UI base lib).",
5
5
  "license": "MIT",
6
6
  "author": "Sereno",