@sereno-ds/ui 0.36.3 → 0.36.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -12
- package/dist/_internal/Field.d.ts +1 -1
- package/dist/_internal/Field.js +2 -2
- package/dist/_internal/Field.js.map +1 -1
- package/dist/_internal/mask.d.ts +1 -1
- package/dist/_internal/mask.js.map +1 -1
- package/dist/core/Avatar.d.ts +1 -1
- package/dist/core/Avatar.js.map +1 -1
- package/dist/core/Badge.js +1 -1
- package/dist/core/Badge.js.map +1 -1
- package/dist/core/Brand.d.ts +2 -2
- package/dist/core/Brand.js.map +1 -1
- package/dist/core/Button.d.ts +1 -1
- package/dist/core/Button.js.map +1 -1
- package/dist/core/Card.js +1 -1
- package/dist/core/Card.js.map +1 -1
- package/dist/core/IconButton.d.ts +2 -2
- package/dist/core/IconButton.js.map +1 -1
- package/dist/core/Menu.d.ts +5 -5
- package/dist/core/Menu.js.map +1 -1
- package/dist/core/Table.d.ts +7 -7
- package/dist/core/Table.js +1 -1
- package/dist/core/Table.js.map +1 -1
- package/dist/core/Typography.d.ts +3 -3
- package/dist/core/Typography.js +1 -1
- package/dist/core/Typography.js.map +1 -1
- package/dist/feedback/Alert.d.ts +2 -2
- package/dist/feedback/Alert.js.map +1 -1
- package/dist/feedback/Dialog.d.ts +5 -5
- package/dist/feedback/Dialog.js.map +1 -1
- package/dist/feedback/Skeleton.d.ts +1 -1
- package/dist/feedback/Skeleton.js.map +1 -1
- package/dist/feedback/Toast.d.ts +1 -1
- package/dist/feedback/Toast.js.map +1 -1
- package/dist/feedback/ToastProvider.d.ts +3 -3
- package/dist/feedback/ToastProvider.js +1 -1
- package/dist/feedback/ToastProvider.js.map +1 -1
- package/dist/forms/AvatarUpload.d.ts +5 -5
- package/dist/forms/AvatarUpload.js +2 -2
- package/dist/forms/AvatarUpload.js.map +1 -1
- package/dist/forms/Checkbox.d.ts +3 -3
- package/dist/forms/Checkbox.js +1 -1
- package/dist/forms/Checkbox.js.map +1 -1
- package/dist/forms/DatePicker.d.ts +9 -9
- package/dist/forms/DatePicker.js +1 -1
- package/dist/forms/DatePicker.js.map +1 -1
- package/dist/forms/DateTimePicker.d.ts +14 -14
- package/dist/forms/DateTimePicker.js +2 -2
- package/dist/forms/DateTimePicker.js.map +1 -1
- package/dist/forms/FileUpload.d.ts +4 -4
- package/dist/forms/FileUpload.js.map +1 -1
- package/dist/forms/Input.d.ts +1 -1
- package/dist/forms/Input.js +1 -1
- package/dist/forms/Input.js.map +1 -1
- package/dist/forms/Radio.d.ts +5 -5
- package/dist/forms/Radio.js.map +1 -1
- package/dist/forms/SearchInput.d.ts +2 -2
- package/dist/forms/SearchInput.js.map +1 -1
- package/dist/forms/Select.d.ts +9 -9
- package/dist/forms/Select.js.map +1 -1
- package/dist/forms/Switch.d.ts +3 -3
- package/dist/forms/Switch.js.map +1 -1
- package/dist/forms/Textarea.d.ts +1 -1
- package/dist/forms/Textarea.js.map +1 -1
- package/dist/forms/_internal/CalendarGrid.d.ts +6 -6
- package/dist/forms/_internal/CalendarGrid.js +1 -1
- package/dist/forms/_internal/CalendarGrid.js.map +1 -1
- package/dist/forms/_internal/fieldBoxStyle.d.ts +2 -2
- package/dist/forms/_internal/fieldBoxStyle.js +2 -2
- package/dist/forms/_internal/fieldBoxStyle.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/navigation/BottomNav.d.ts +1 -1
- package/dist/navigation/BottomNav.js +1 -1
- package/dist/navigation/BottomNav.js.map +1 -1
- package/dist/navigation/SidebarNav.d.ts +9 -9
- package/dist/navigation/SidebarNav.js +1 -1
- package/dist/navigation/SidebarNav.js.map +1 -1
- package/dist/navigation/Stepper.d.ts +5 -5
- package/dist/navigation/Stepper.js.map +1 -1
- package/dist/navigation/Tabs.d.ts +2 -2
- package/dist/navigation/Tabs.js +11 -11
- package/dist/navigation/Tabs.js.map +1 -1
- package/dist/navigation/TopBar.d.ts +3 -3
- package/dist/navigation/TopBar.js.map +1 -1
- package/dist/styles.css +23 -23
- package/dist/theme/ThemeProvider.d.ts +1 -1
- package/dist/theme/ThemeProvider.js.map +1 -1
- package/package.json +2 -2
package/dist/forms/Radio.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/forms/Radio.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\n\n/**\n * Single-choice control for mutually exclusive options (payment method, appointment format).\n * Group by giving every option the same `name`. Visually matched to `Checkbox`
|
|
1
|
+
{"version":3,"sources":["../../src/forms/Radio.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\n\n/**\n * Single-choice control for mutually exclusive options (payment method, appointment format).\n * Group by giving every option the same `name`. Visually matched to `Checkbox` - same 20px\n * box, same hover and label/description rhythm - differing only in the pill radius and dot.\n * Host must include the `.sereno-radio:checked` rule (see globals.css).\n *\n * Wrap every group in a `<fieldset>` / `<legend>` - `name` alone makes the browser treat\n * the options as one native group (arrow keys move between them, only one can be checked),\n * but without a `<legend>` a screen reader has no accessible name for what the choice is\n * between, only \"Online, radio button, 1 of 3\" with no context.\n */\nexport interface RadioProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'size'> {\n label?: string;\n /** Secondary line under the label. Replaced by `error` when present. */\n description?: string;\n /** Error message - tints the circle and the secondary line red. Replaces `description`. */\n error?: string;\n /** Circle size. `sm` (16px) for dense lists; `md` (20px) everywhere else. Matches `Checkbox`. */\n size?: 'sm' | 'md';\n /**\n * Reserve the description/error row's height even with neither set - keeps\n * the row stable as `error` comes and goes (SS-259, same mechanism as\n * `Input`'s `preserveHelperSpace`). Off by default.\n */\n preserveHelperSpace?: boolean;\n}\n\nexport const Radio = React.forwardRef<HTMLInputElement, RadioProps>(function Radio(\n { label, description, error, checked, defaultChecked, disabled, size = 'md', preserveHelperSpace = false, onChange, style, ...rest },\n ref,\n) {\n const [hover, setHover] = React.useState(false);\n const box = size === 'sm' ? 16 : 20;\n return (\n <label\n onMouseEnter={() => setHover(true)}\n onMouseLeave={() => setHover(false)}\n style={sx({ display: 'flex', gap: 'var(--space-3)', alignItems: 'flex-start', cursor: disabled ? 'not-allowed' : 'pointer', opacity: disabled ? 0.6 : 1, ...style })}\n >\n <span style={sx({ position: 'relative', display: 'inline-flex', flex: '0 0 auto', marginTop: size === 'sm' ? 3 : 1 })}>\n <input\n ref={ref}\n type=\"radio\"\n checked={checked}\n defaultChecked={defaultChecked}\n disabled={disabled}\n onChange={onChange}\n {...rest}\n data-size={size}\n className=\"sereno-radio\"\n style={sx({\n appearance: 'none',\n width: box,\n height: box,\n margin: 0,\n borderRadius: 'var(--radius-pill)',\n border: 'var(--border-width-emphasis) solid ' + (error ? 'var(--interactive-error)' : hover && !disabled ? 'var(--border-brand)' : 'var(--border-strong)'),\n backgroundColor: 'var(--bg-surface)',\n cursor: 'inherit',\n transition: 'var(--transition-control)',\n })}\n />\n </span>\n <span style={sx({ display: 'flex', flexDirection: 'column', gap: 2 })}>\n {label && <span style={sx({ fontFamily: 'var(--font-body)', fontSize: 'var(--text-base)', color: 'var(--text-primary)', lineHeight: 1.35 })}>{label}</span>}\n {(description || error || preserveHelperSpace) && (\n <span\n style={sx({\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-xs)',\n color: error ? 'var(--interactive-error)' : 'var(--text-muted)',\n lineHeight: 1.45,\n minHeight: preserveHelperSpace ? 'calc(var(--text-xs) * 1.45)' : undefined,\n })}\n >\n {error || description}\n </span>\n )}\n </span>\n </label>\n );\n});\n\nRadio.displayName = 'Radio';"],"mappings":";AA6CQ,cAuBF,YAvBE;AA3CR,YAAY,WAAW;AACvB,SAAS,UAAU;AA6BZ,MAAM,QAAQ,MAAM,WAAyC,SAASA,OAC3E,EAAE,OAAO,aAAa,OAAO,SAAS,gBAAgB,UAAU,OAAO,MAAM,sBAAsB,OAAO,UAAU,OAAO,GAAG,KAAK,GACnI,KACA;AACA,QAA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5C,YAAY;AAAA,gBACZ,WAAW,sBAAsB,gCAAgC;AAAA,cACnE,CAAC;AAAA,cAEA,mBAAS;AAAA;AAAA,UACZ;AAAA,WAEJ;AAAA;AAAA;AAAA,EACF;AAEJ,CAAC;AAED,MAAM,cAAc;","names":["Radio"]}
|
|
@@ -9,9 +9,9 @@ import '../_internal/mask.js';
|
|
|
9
9
|
interface SearchInputProps extends Omit<InputProps, 'iconLeft' | 'suffix' | 'prefix' | 'type' | 'mask' | 'showCount' | 'value' | 'defaultValue' | 'onChange'> {
|
|
10
10
|
value?: string;
|
|
11
11
|
defaultValue?: string;
|
|
12
|
-
/** Every keystroke and on clear
|
|
12
|
+
/** Every keystroke and on clear - the plain string. */
|
|
13
13
|
onValueChange?: (value: string) => void;
|
|
14
|
-
/** Debounced (and on `Enter` / clear)
|
|
14
|
+
/** Debounced (and on `Enter` / clear) - run the actual query here. */
|
|
15
15
|
onSearch?: (value: string) => void;
|
|
16
16
|
/** Debounce for `onSearch`, in ms. */
|
|
17
17
|
debounce?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/forms/SearchInput.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Search, X } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { Input, type InputProps } from './Input';\n\n/**\n * A search field: `Input` with a leading magnifier, a clear (×) button, and a\n * **debounced** `onSearch`. `Enter` searches immediately; `Esc` clears.\n */\nexport interface SearchInputProps\n extends Omit<InputProps, 'iconLeft' | 'suffix' | 'prefix' | 'type' | 'mask' | 'showCount' | 'value' | 'defaultValue' | 'onChange'> {\n value?: string;\n defaultValue?: string;\n /** Every keystroke and on clear
|
|
1
|
+
{"version":3,"sources":["../../src/forms/SearchInput.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Search, X } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { Input, type InputProps } from './Input';\n\n/**\n * A search field: `Input` with a leading magnifier, a clear (×) button, and a\n * **debounced** `onSearch`. `Enter` searches immediately; `Esc` clears.\n */\nexport interface SearchInputProps\n extends Omit<InputProps, 'iconLeft' | 'suffix' | 'prefix' | 'type' | 'mask' | 'showCount' | 'value' | 'defaultValue' | 'onChange'> {\n value?: string;\n defaultValue?: string;\n /** Every keystroke and on clear - the plain string. */\n onValueChange?: (value: string) => void;\n /** Debounced (and on `Enter` / clear) - run the actual query here. */\n onSearch?: (value: string) => void;\n /** Debounce for `onSearch`, in ms. */\n debounce?: number;\n /** aria-label for the clear button. */\n clearLabel?: string;\n}\n\nexport const SearchInput = React.forwardRef<HTMLInputElement, SearchInputProps>(function SearchInput(\n { value, defaultValue, onValueChange, onSearch, debounce = 250, clearLabel = 'Clear search', placeholder = 'Search…', disabled, ...rest },\n ref,\n) {\n const [internal, setInternal] = React.useState(defaultValue ?? '');\n const text = value !== undefined ? value : internal;\n\n const timer = React.useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n React.useEffect(() => () => clearTimeout(timer.current), []);\n\n const runSearch = (v: string, immediate: boolean) => {\n clearTimeout(timer.current);\n if (immediate) onSearch?.(v);\n else timer.current = setTimeout(() => onSearch?.(v), debounce);\n };\n\n const update = (v: string, immediate = false) => {\n if (value === undefined) setInternal(v);\n onValueChange?.(v);\n runSearch(v, immediate);\n };\n\n const clear = () => update('', true);\n\n return (\n <Input\n ref={ref}\n {...rest}\n role=\"searchbox\"\n enterKeyHint=\"search\"\n autoComplete=\"off\"\n spellCheck={false}\n placeholder={placeholder}\n disabled={disabled}\n value={text}\n onChange={(e) => update(e.currentTarget.value)}\n onKeyDown={(e) => {\n if (e.key === 'Enter') runSearch(e.currentTarget.value, true);\n else if (e.key === 'Escape' && text) {\n e.preventDefault();\n clear();\n }\n }}\n iconLeft={<Search size={16} strokeWidth={1.75} />}\n suffix={\n text && !disabled ? (\n <button\n type=\"button\"\n className=\"ds-affix-btn\"\n aria-label={clearLabel}\n onClick={clear}\n style={sx({ display: 'inline-flex', alignItems: 'center', border: 'none', background: 'transparent', color: 'var(--text-muted)', cursor: 'pointer', padding: 0 })}\n >\n <X size={16} strokeWidth={2} />\n </button>\n ) : undefined\n }\n />\n );\n});\n\nSearchInput.displayName = 'SearchInput';\n"],"mappings":";AAoEgB;AAlEhB,YAAY,WAAW;AACvB,SAAS,QAAQ,SAAS;AAC1B,SAAS,UAAU;AACnB,SAAS,aAA8B;AAoBhC,MAAM,cAAc,MAAM,WAA+C,SAASA,aACvF,EAAE,OAAO,cAAc,eAAe,UAAU,WAAW,KAAK,aAAa,gBAAgB,cAAc,gBAAW,UAAU,GAAG,KAAK,GACxI,KACA;AACA,QAAM,CAAC,UAAU,WAAW,IAAI,MAAM,SAAS,gBAAgB,EAAE;AACjE,QAAM,OAAO,UAAU,SAAY,QAAQ;AAE3C,QAAM,QAAQ,MAAM,OAAkD,MAAS;AAC/E,QAAM,UAAU,MAAM,MAAM,aAAa,MAAM,OAAO,GAAG,CAAC,CAAC;AAE3D,QAAM,YAAY,CAAC,GAAW,cAAuB;AACnD,iBAAa,MAAM,OAAO;AAC1B,QAAI,UAAW,YAAW,CAAC;AAAA,QACtB,OAAM,UAAU,WAAW,MAAM,WAAW,CAAC,GAAG,QAAQ;AAAA,EAC/D;AAEA,QAAM,SAAS,CAAC,GAAW,YAAY,UAAU;AAC/C,QAAI,UAAU,OAAW,aAAY,CAAC;AACtC,oBAAgB,CAAC;AACjB,cAAU,GAAG,SAAS;AAAA,EACxB;AAEA,QAAM,QAAQ,MAAM,OAAO,IAAI,IAAI;AAEnC,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACC,GAAG;AAAA,MACJ,MAAK;AAAA,MACL,cAAa;AAAA,MACb,cAAa;AAAA,MACb,YAAY;AAAA,MACZ;AAAA,MACA;AAAA,MACA,OAAO;AAAA,MACP,UAAU,CAAC,MAAM,OAAO,EAAE,cAAc,KAAK;AAAA,MAC7C,WAAW,CAAC,MAAM;AAChB,YAAI,EAAE,QAAQ,QAAS,WAAU,EAAE,cAAc,OAAO,IAAI;AAAA,iBACnD,EAAE,QAAQ,YAAY,MAAM;AACnC,YAAE,eAAe;AACjB,gBAAM;AAAA,QACR;AAAA,MACF;AAAA,MACA,UAAU,oBAAC,UAAO,MAAM,IAAI,aAAa,MAAM;AAAA,MAC/C,QACE,QAAQ,CAAC,WACP;AAAA,QAAC;AAAA;AAAA,UACC,MAAK;AAAA,UACL,WAAU;AAAA,UACV,cAAY;AAAA,UACZ,SAAS;AAAA,UACT,OAAO,GAAG,EAAE,SAAS,eAAe,YAAY,UAAU,QAAQ,QAAQ,YAAY,eAAe,OAAO,qBAAqB,QAAQ,WAAW,SAAS,EAAE,CAAC;AAAA,UAEhK,8BAAC,KAAE,MAAM,IAAI,aAAa,GAAG;AAAA;AAAA,MAC/B,IACE;AAAA;AAAA,EAER;AAEJ,CAAC;AAED,YAAY,cAAc;","names":["SearchInput"]}
|
package/dist/forms/Select.d.ts
CHANGED
|
@@ -6,12 +6,12 @@ interface SelectOption {
|
|
|
6
6
|
disabled?: boolean;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
|
-
* Single-choice select
|
|
9
|
+
* Single-choice select - a hand-rolled listbox (token-styled, full keyboard
|
|
10
10
|
* support) so it looks and behaves the same in every browser. On a mouse it's
|
|
11
11
|
* an anchored dropdown; on touch it opens as a bottom sheet with finger-sized
|
|
12
12
|
* rows.
|
|
13
13
|
*
|
|
14
|
-
* Value contract: `value` / `defaultValue` + `onValueChange(value)`
|
|
14
|
+
* Value contract: `value` / `defaultValue` + `onValueChange(value)` - a plain
|
|
15
15
|
* string, not a DOM event.
|
|
16
16
|
*/
|
|
17
17
|
interface SelectProps {
|
|
@@ -30,30 +30,30 @@ interface SelectProps {
|
|
|
30
30
|
/** Uncontrolled initial value. */
|
|
31
31
|
defaultValue?: string;
|
|
32
32
|
onValueChange?: (value: string) => void;
|
|
33
|
-
/** Form field name
|
|
33
|
+
/** Form field name - mirrored to a hidden input so the value can be submitted. */
|
|
34
34
|
name?: string;
|
|
35
35
|
id?: string;
|
|
36
36
|
containerStyle?: React.CSSProperties;
|
|
37
37
|
/**
|
|
38
38
|
* Accessible name for the trigger. Only needed when there's no visible
|
|
39
|
-
* `label` (e.g. a compact row where the context is already clear visually
|
|
40
|
-
*
|
|
39
|
+
* `label` (e.g. a compact row where the context is already clear visually,
|
|
40
|
+
* a day name next to a "start time" / "end time" pair): `Field` only
|
|
41
41
|
* renders a `<label>` when `label` is set, so without either the trigger
|
|
42
42
|
* has no accessible name at all. Takes precedence over `label` if both are
|
|
43
|
-
* set
|
|
43
|
+
* set - don't pass both.
|
|
44
44
|
*/
|
|
45
45
|
'aria-label'?: string;
|
|
46
|
-
/** Reserve the hint/error row's height even with neither set
|
|
46
|
+
/** Reserve the hint/error row's height even with neither set - stops the
|
|
47
47
|
* field from growing the moment a validation message appears. */
|
|
48
48
|
preserveHelperSpace?: boolean;
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
51
|
* `ref` reaches the hidden `<input type="hidden">` that mirrors the selected
|
|
52
|
-
* value (rendered only when `name` is set
|
|
52
|
+
* value (rendered only when `name` is set - pass it, as `register()` does).
|
|
53
53
|
* Enough for `getValues()` / `trigger()` / `setFocus()`, but a plain
|
|
54
54
|
* `{...register(name)}` spread still won't validate on change: this hidden
|
|
55
55
|
* input never dispatches a native `input`/`change` event, and `onValueChange`
|
|
56
|
-
* hands back a plain string, not a `ChangeEvent`
|
|
56
|
+
* hands back a plain string, not a `ChangeEvent` - wire it through
|
|
57
57
|
* `Controller`, or call the registered `onChange` yourself from
|
|
58
58
|
* `onValueChange`.
|
|
59
59
|
*/
|
package/dist/forms/Select.js.map
CHANGED
|
@@ -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 { Check, ChevronDown } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { useIsoLayoutEffect } from '../_internal/useIsoLayoutEffect';\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\nconst OPTION_PAD_Y = { sm: 6, md: 8, lg: 10 } as const;\n\n/** True on touch / pen devices, where the native picker wins. SSR-safe. */\nfunction useCoarsePointer(): boolean {\n return React.useSyncExternalStore(\n (onChange) => {\n const mq = window.matchMedia('(pointer: coarse)');\n mq.addEventListener('change', onChange);\n return () => mq.removeEventListener('change', onChange);\n },\n () => window.matchMedia('(pointer: coarse)').matches,\n () => false,\n );\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 // Two placement strategies, picked once per open:\n // • 'inline' — the common case. A plain `position: absolute` child of the\n // field wrapper. The browser glues it to the field through *any* scroll\n // (page or an inner overflow container) for free — zero JS, zero jitter,\n // never closes on scroll. Only re-flips the side if room runs out.\n // • 'fixed' — used when the field is inside a `position: fixed` container\n // (a Dialog), where an inline child would be clipped by the dialog's\n // overflow. Portalled to <body>, `position: fixed` at the trigger's\n // viewport rect. The dialog itself doesn't scroll, so it stays glued;\n // scrolling the dialog *body* detaches it, and we dismiss then.\n const [place, setPlace] = React.useState<\n | { strategy: 'inline'; above: boolean; maxH: number }\n | { strategy: 'fixed'; above: boolean; maxH: number; top: number; left: number; width: number }\n | null\n >(null);\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 useIsoLayoutEffect(() => {\n if (!open || coarse) return; // the touch sheet needs no anchoring\n const t = triggerRef.current;\n if (!t) return;\n\n const GAP = 6;\n // Non-zero fallback: if the viewport height is unreadable, assume room below\n // rather than flipping the menu up on a bad reading.\n const vh = window.innerHeight || document.documentElement.clientHeight || 900;\n const estH = Math.min(288, options.length * 36 + 8); // rough list height, no DOM\n const evalRoom = () => {\n const r = t.getBoundingClientRect();\n const roomBelow = vh - r.bottom - 8;\n const roomAbove = r.top - 8;\n const above = roomBelow < Math.min(estH, 200) && roomAbove > roomBelow;\n const maxH = Math.max(120, Math.min(288, Math.round((above ? roomAbove : roomBelow) - GAP)));\n return { r, above, maxH };\n };\n\n let fixed = false;\n for (let el: HTMLElement | null = t.parentElement; el && el !== document.body; el = el.parentElement) {\n if (getComputedStyle(el).position === 'fixed') {\n fixed = true;\n break;\n }\n }\n\n if (fixed) {\n const { r, above, maxH } = evalRoom();\n setPlace({ strategy: 'fixed', above, maxH, left: r.left, width: r.width, top: above ? r.top - GAP : r.bottom + GAP });\n const anchorTop = r.top;\n const onScroll = (e: Event) => {\n if (e.target instanceof Node && panelRef.current?.contains(e.target)) return;\n if (Math.abs(t.getBoundingClientRect().top - anchorTop) > 1) setOpen(false);\n };\n const onResize = () => setOpen(false);\n window.addEventListener('scroll', onScroll, true);\n window.addEventListener('resize', onResize);\n return () => {\n window.removeEventListener('scroll', onScroll, true);\n window.removeEventListener('resize', onResize);\n };\n }\n\n // Inline: the menu is a plain absolute child, glued for free. Never reposition\n // or close on scroll — only re-flip the side (rare) and re-cap height on\n // resize.\n const applyFull = () => {\n const { above, maxH } = evalRoom();\n setPlace((prev) =>\n prev?.strategy === 'inline' && prev.above === above && prev.maxH === maxH ? prev : { strategy: 'inline', above, maxH },\n );\n };\n applyFull();\n const onScroll = (e: Event) => {\n if (e.target instanceof Node && panelRef.current?.contains(e.target)) return;\n const { above } = evalRoom();\n setPlace((prev) => (prev?.strategy === 'inline' && prev.above !== above ? { ...prev, above } : prev));\n };\n window.addEventListener('scroll', onScroll, true);\n window.addEventListener('resize', applyFull);\n return () => {\n window.removeEventListener('scroll', onScroll, true);\n window.removeEventListener('resize', applyFull);\n };\n }, [open, coarse, options.length]);\n\n // Close on outside pointerdown (the touch sheet uses its own scrim instead).\n React.useEffect(() => {\n if (!open || coarse) return;\n const onDown = (e: PointerEvent) => {\n const target = e.target as Node;\n if (triggerRef.current?.contains(target) || panelRef.current?.contains(target)) return;\n setOpen(false);\n };\n document.addEventListener('pointerdown', onDown, true);\n return () => document.removeEventListener('pointerdown', onDown, true);\n }, [open, coarse]);\n\n // The touch sheet is a modal surface — lock the page scroll behind it.\n React.useEffect(() => {\n if (!open || !coarse) return;\n const root = document.documentElement;\n const prev = { h: root.style.overflow, b: document.body.style.overflow };\n root.style.overflow = 'hidden';\n document.body.style.overflow = 'hidden';\n return () => {\n root.style.overflow = prev.h;\n document.body.style.overflow = prev.b;\n };\n }, [open, coarse]);\n\n // Keep the active option in view.\n React.useEffect(() => {\n if (!open || activeIndex < 0) return;\n document.getElementById(`${rid}-opt-${activeIndex}`)?.scrollIntoView({ block: 'nearest' });\n }, [open, activeIndex, rid]);\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 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 = coarse ? 12 : OPTION_PAD_Y[size];\n\n const listStyleBase: React.CSSProperties = {\n minWidth: 160,\n overflowY: 'auto',\n margin: 0,\n padding: 'var(--space-1)',\n listStyle: 'none',\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 fontFamily: 'var(--font-body)',\n fontSize: size === 'sm' ? 'var(--text-sm)' : 'var(--text-base)',\n };\n const optionRows = options.map((o, i) => {\n const isSelected = o.value === value;\n const isActive = i === activeIndex;\n return (\n <li\n key={o.value}\n id={`${rid}-opt-${i}`}\n role=\"option\"\n aria-selected={isSelected}\n aria-disabled={o.disabled || undefined}\n onPointerEnter={() => !o.disabled && setActiveIndex(i)}\n onClick={() => choose(i)}\n style={sx({\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n gap: 'var(--space-2)',\n minHeight: coarse ? 44 : undefined,\n padding: `${rowPadY}px var(--space-3)`,\n borderRadius: 'var(--radius-sm)',\n cursor: o.disabled ? 'not-allowed' : 'pointer',\n color: o.disabled ? 'var(--text-disabled)' : 'var(--text-primary)',\n background: isActive && !o.disabled ? 'var(--bg-subtle)' : 'transparent',\n fontWeight: isSelected ? 'var(--weight-semibold)' : 'var(--weight-regular)',\n fontSize: coarse ? 'var(--text-base)' : undefined,\n })}\n >\n <span style={sx({ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' })}>{o.label}</span>\n {isSelected && (\n <span style={sx({ display: 'flex', flex: '0 0 auto', color: 'var(--text-brand)' })}>\n <Check size={coarse ? 18 : 16} strokeWidth={2} />\n </span>\n )}\n </li>\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":";AAwVM,SAuBE,KAvBF;AAtVN,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAC7B,SAAS,OAAO,mBAAmB;AACnC,SAAS,UAAU;AACnB,SAAS,0BAA0B;AACnC,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAmD9B,MAAM,eAAe,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG;AAG5C,SAAS,mBAA4B;AACnC,SAAO,MAAM;AAAA,IACX,CAAC,aAAa;AACZ,YAAM,KAAK,OAAO,WAAW,mBAAmB;AAChD,SAAG,iBAAiB,UAAU,QAAQ;AACtC,aAAO,MAAM,GAAG,oBAAoB,UAAU,QAAQ;AAAA,IACxD;AAAA,IACA,MAAM,OAAO,WAAW,mBAAmB,EAAE;AAAA,IAC7C,MAAM;AAAA,EACR;AACF;AAGA,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,Y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AA,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":["onScroll","Select"]}
|
|
1
|
+
{"version":3,"sources":["../../src/forms/Select.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { Check, ChevronDown } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { useIsoLayoutEffect } from '../_internal/useIsoLayoutEffect';\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\nconst OPTION_PAD_Y = { sm: 6, md: 8, lg: 10 } as const;\n\n/** True on touch / pen devices, where the native picker wins. SSR-safe. */\nfunction useCoarsePointer(): boolean {\n return React.useSyncExternalStore(\n (onChange) => {\n const mq = window.matchMedia('(pointer: coarse)');\n mq.addEventListener('change', onChange);\n return () => mq.removeEventListener('change', onChange);\n },\n () => window.matchMedia('(pointer: coarse)').matches,\n () => false,\n );\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 // Two placement strategies, picked once per open:\n // • 'inline' - the common case. A plain `position: absolute` child of the\n // field wrapper. The browser glues it to the field through *any* scroll\n // (page or an inner overflow container) for free - zero JS, zero jitter,\n // never closes on scroll. Only re-flips the side if room runs out.\n // • 'fixed' - used when the field is inside a `position: fixed` container\n // (a Dialog), where an inline child would be clipped by the dialog's\n // overflow. Portalled to <body>, `position: fixed` at the trigger's\n // viewport rect. The dialog itself doesn't scroll, so it stays glued;\n // scrolling the dialog *body* detaches it, and we dismiss then.\n const [place, setPlace] = React.useState<\n | { strategy: 'inline'; above: boolean; maxH: number }\n | { strategy: 'fixed'; above: boolean; maxH: number; top: number; left: number; width: number }\n | null\n >(null);\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 useIsoLayoutEffect(() => {\n if (!open || coarse) return; // the touch sheet needs no anchoring\n const t = triggerRef.current;\n if (!t) return;\n\n const GAP = 6;\n // Non-zero fallback: if the viewport height is unreadable, assume room below\n // rather than flipping the menu up on a bad reading.\n const vh = window.innerHeight || document.documentElement.clientHeight || 900;\n const estH = Math.min(288, options.length * 36 + 8); // rough list height, no DOM\n const evalRoom = () => {\n const r = t.getBoundingClientRect();\n const roomBelow = vh - r.bottom - 8;\n const roomAbove = r.top - 8;\n const above = roomBelow < Math.min(estH, 200) && roomAbove > roomBelow;\n const maxH = Math.max(120, Math.min(288, Math.round((above ? roomAbove : roomBelow) - GAP)));\n return { r, above, maxH };\n };\n\n let fixed = false;\n for (let el: HTMLElement | null = t.parentElement; el && el !== document.body; el = el.parentElement) {\n if (getComputedStyle(el).position === 'fixed') {\n fixed = true;\n break;\n }\n }\n\n if (fixed) {\n const { r, above, maxH } = evalRoom();\n setPlace({ strategy: 'fixed', above, maxH, left: r.left, width: r.width, top: above ? r.top - GAP : r.bottom + GAP });\n const anchorTop = r.top;\n const onScroll = (e: Event) => {\n if (e.target instanceof Node && panelRef.current?.contains(e.target)) return;\n if (Math.abs(t.getBoundingClientRect().top - anchorTop) > 1) setOpen(false);\n };\n const onResize = () => setOpen(false);\n window.addEventListener('scroll', onScroll, true);\n window.addEventListener('resize', onResize);\n return () => {\n window.removeEventListener('scroll', onScroll, true);\n window.removeEventListener('resize', onResize);\n };\n }\n\n // Inline: the menu is a plain absolute child, glued for free. Never reposition\n // or close on scroll - only re-flip the side (rare) and re-cap height on\n // resize.\n const applyFull = () => {\n const { above, maxH } = evalRoom();\n setPlace((prev) =>\n prev?.strategy === 'inline' && prev.above === above && prev.maxH === maxH ? prev : { strategy: 'inline', above, maxH },\n );\n };\n applyFull();\n const onScroll = (e: Event) => {\n if (e.target instanceof Node && panelRef.current?.contains(e.target)) return;\n const { above } = evalRoom();\n setPlace((prev) => (prev?.strategy === 'inline' && prev.above !== above ? { ...prev, above } : prev));\n };\n window.addEventListener('scroll', onScroll, true);\n window.addEventListener('resize', applyFull);\n return () => {\n window.removeEventListener('scroll', onScroll, true);\n window.removeEventListener('resize', applyFull);\n };\n }, [open, coarse, options.length]);\n\n // Close on outside pointerdown (the touch sheet uses its own scrim instead).\n React.useEffect(() => {\n if (!open || coarse) return;\n const onDown = (e: PointerEvent) => {\n const target = e.target as Node;\n if (triggerRef.current?.contains(target) || panelRef.current?.contains(target)) return;\n setOpen(false);\n };\n document.addEventListener('pointerdown', onDown, true);\n return () => document.removeEventListener('pointerdown', onDown, true);\n }, [open, coarse]);\n\n // The touch sheet is a modal surface - lock the page scroll behind it.\n React.useEffect(() => {\n if (!open || !coarse) return;\n const root = document.documentElement;\n const prev = { h: root.style.overflow, b: document.body.style.overflow };\n root.style.overflow = 'hidden';\n document.body.style.overflow = 'hidden';\n return () => {\n root.style.overflow = prev.h;\n document.body.style.overflow = prev.b;\n };\n }, [open, coarse]);\n\n // Keep the active option in view.\n React.useEffect(() => {\n if (!open || activeIndex < 0) return;\n document.getElementById(`${rid}-opt-${activeIndex}`)?.scrollIntoView({ block: 'nearest' });\n }, [open, activeIndex, rid]);\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 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 = coarse ? 12 : OPTION_PAD_Y[size];\n\n const listStyleBase: React.CSSProperties = {\n minWidth: 160,\n overflowY: 'auto',\n margin: 0,\n padding: 'var(--space-1)',\n listStyle: 'none',\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 fontFamily: 'var(--font-body)',\n fontSize: size === 'sm' ? 'var(--text-sm)' : 'var(--text-base)',\n };\n const optionRows = options.map((o, i) => {\n const isSelected = o.value === value;\n const isActive = i === activeIndex;\n return (\n <li\n key={o.value}\n id={`${rid}-opt-${i}`}\n role=\"option\"\n aria-selected={isSelected}\n aria-disabled={o.disabled || undefined}\n onPointerEnter={() => !o.disabled && setActiveIndex(i)}\n onClick={() => choose(i)}\n style={sx({\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n gap: 'var(--space-2)',\n minHeight: coarse ? 44 : undefined,\n padding: `${rowPadY}px var(--space-3)`,\n borderRadius: 'var(--radius-sm)',\n cursor: o.disabled ? 'not-allowed' : 'pointer',\n color: o.disabled ? 'var(--text-disabled)' : 'var(--text-primary)',\n background: isActive && !o.disabled ? 'var(--bg-subtle)' : 'transparent',\n fontWeight: isSelected ? 'var(--weight-semibold)' : 'var(--weight-regular)',\n fontSize: coarse ? 'var(--text-base)' : undefined,\n })}\n >\n <span style={sx({ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' })}>{o.label}</span>\n {isSelected && (\n <span style={sx({ display: 'flex', flex: '0 0 auto', color: 'var(--text-brand)' })}>\n <Check size={coarse ? 18 : 16} strokeWidth={2} />\n </span>\n )}\n </li>\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":";AAwVM,SAuBE,KAvBF;AAtVN,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAC7B,SAAS,OAAO,mBAAmB;AACnC,SAAS,UAAU;AACnB,SAAS,0BAA0B;AACn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AAAA,MACA,SAAS;AAAA,IACX;AAAA,KACJ;AAEJ;AAYO,MAAM,SAAS,MAAM,WAA0C,SAASC,QAAO;AAAA,EACpF;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU,CAAC;AAAA,EACX;AAAA,EACA,OAAO;AAAA,EACP;AAAA,EACA,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,cAAc;AAAA,EACd;AACF,GAAgB,KAAK;AACnB,QAAM,UAAU,MAAM,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":["onScroll","Select"]}
|
package/dist/forms/Switch.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ interface SwitchProps {
|
|
|
16
16
|
style?: React.CSSProperties;
|
|
17
17
|
/**
|
|
18
18
|
* Accessible name for the `role="switch"` element. Wrapping it in a
|
|
19
|
-
* `<label>` (below) only associates text for *native* labelable controls
|
|
19
|
+
* `<label>` (below) only associates text for *native* labelable controls -
|
|
20
20
|
* a custom ARIA widget still announces with no name at all otherwise (SS-232
|
|
21
21
|
* caught this live via axe: `aria-toggle-field-name`). Defaults to `label`;
|
|
22
22
|
* only pass this separately for a label-less switch (an icon-only row).
|
|
@@ -24,11 +24,11 @@ interface SwitchProps {
|
|
|
24
24
|
'aria-label'?: string;
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
|
-
* `ref` reaches the `<span role="switch">`
|
|
27
|
+
* `ref` reaches the `<span role="switch">` - there's no native form element
|
|
28
28
|
* underneath, so this only gives you `.focus()` (useful for
|
|
29
29
|
* `setFocus()`-on-error), never `.value`/`.checked`. Switch is documented as
|
|
30
30
|
* "never use inside a form that needs Save" already; it isn't a
|
|
31
|
-
* `react-hook-form` `register()` candidate regardless of `ref`
|
|
31
|
+
* `react-hook-form` `register()` candidate regardless of `ref` - use
|
|
32
32
|
* `Controller` if one genuinely needs to live in a saved form.
|
|
33
33
|
*/
|
|
34
34
|
declare const Switch: React.ForwardRefExoticComponent<SwitchProps & React.RefAttributes<HTMLSpanElement>>;
|
package/dist/forms/Switch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/forms/Switch.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\n\n/** Instant-apply toggle for settings rows (agenda online, lembretes, tema). Never use inside a form that needs Save. Host must include the `.sereno-switch` focus rule (see globals.css). */\nexport interface SwitchProps {\n label?: string;\n description?: string;\n checked?: boolean;\n disabled?: boolean;\n /** Track size. `sm` for dense settings lists; `md` is the default. Matches `Checkbox` / `Radio`. */\n size?: 'sm' | 'md';\n onChange?: (e: { target: { checked: boolean } }) => void;\n style?: React.CSSProperties;\n /**\n * Accessible name for the `role=\"switch\"` element. Wrapping it in a\n * `<label>` (below) only associates text for *native* labelable controls
|
|
1
|
+
{"version":3,"sources":["../../src/forms/Switch.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\n\n/** Instant-apply toggle for settings rows (agenda online, lembretes, tema). Never use inside a form that needs Save. Host must include the `.sereno-switch` focus rule (see globals.css). */\nexport interface SwitchProps {\n label?: string;\n description?: string;\n checked?: boolean;\n disabled?: boolean;\n /** Track size. `sm` for dense settings lists; `md` is the default. Matches `Checkbox` / `Radio`. */\n size?: 'sm' | 'md';\n onChange?: (e: { target: { checked: boolean } }) => void;\n style?: React.CSSProperties;\n /**\n * Accessible name for the `role=\"switch\"` element. Wrapping it in a\n * `<label>` (below) only associates text for *native* labelable controls -\n * a custom ARIA widget still announces with no name at all otherwise (SS-232\n * caught this live via axe: `aria-toggle-field-name`). Defaults to `label`;\n * only pass this separately for a label-less switch (an icon-only row).\n */\n 'aria-label'?: string;\n}\n\nconst TRACK = { sm: { w: 36, h: 22, thumb: 16 }, md: { w: 44, h: 26, thumb: 20 } } as const;\n\n/**\n * `ref` reaches the `<span role=\"switch\">` - there's no native form element\n * underneath, so this only gives you `.focus()` (useful for\n * `setFocus()`-on-error), never `.value`/`.checked`. Switch is documented as\n * \"never use inside a form that needs Save\" already; it isn't a\n * `react-hook-form` `register()` candidate regardless of `ref` - use\n * `Controller` if one genuinely needs to live in a saved form.\n */\nexport const Switch = React.forwardRef<HTMLSpanElement, SwitchProps>(function Switch({\n label,\n description,\n checked = false,\n disabled,\n size = 'md',\n onChange,\n style,\n 'aria-label': ariaLabel,\n}: SwitchProps, ref) {\n const t = TRACK[size];\n const toggle = () => {\n if (!disabled && onChange) onChange({ target: { checked: !checked } });\n };\n return (\n <label\n style={sx({\n display: 'flex',\n gap: 'var(--space-3)',\n alignItems: 'center',\n justifyContent: 'space-between',\n cursor: disabled ? 'not-allowed' : 'pointer',\n opacity: disabled ? 0.6 : 1,\n ...style,\n })}\n >\n <span style={sx({ display: 'flex', flexDirection: 'column', gap: 2 })}>\n {label && (\n <span style={sx({ fontFamily: 'var(--font-body)', fontSize: 'var(--text-base)', fontWeight: 'var(--weight-medium)', color: 'var(--text-primary)' })}>{label}</span>\n )}\n {description && (\n <span style={sx({ fontFamily: 'var(--font-body)', fontSize: 'var(--text-xs)', color: 'var(--text-muted)', lineHeight: 1.45 })}>{description}</span>\n )}\n </span>\n <span\n ref={ref}\n role=\"switch\"\n aria-checked={checked}\n aria-label={label ?? ariaLabel}\n aria-disabled={disabled || undefined}\n tabIndex={disabled ? undefined : 0}\n className=\"sereno-switch\"\n onClick={toggle}\n onKeyDown={(e) => {\n if (e.key === ' ' || e.key === 'Enter') {\n e.preventDefault();\n toggle();\n }\n }}\n style={sx({\n position: 'relative',\n width: t.w,\n height: t.h,\n flex: '0 0 auto',\n borderRadius: 'var(--radius-pill)',\n background: checked ? 'var(--interactive-primary)' : 'var(--border-strong)',\n transition: 'background-color var(--duration-normal) var(--ease-standard)',\n })}\n >\n <span\n style={sx({\n position: 'absolute',\n top: 3,\n left: checked ? t.w - t.thumb - 3 : 3,\n width: t.thumb,\n height: t.thumb,\n borderRadius: '999px',\n background: '#fff',\n boxShadow: 'var(--shadow-sm)',\n transition: 'left var(--duration-normal) var(--ease-gentle)',\n })}\n />\n </span>\n </label>\n );\n});\n\nSwitch.displayName = 'Switch';\n"],"mappings":";AA6DM,SAEI,KAFJ;AA3DN,YAAY,WAAW;AACvB,SAAS,UAAU;AAsBnB,MAAM,QAAQ,EAAE,IAAI,EAAE,GAAG,IAAI,GAAG,IAAI,OAAO,GAAG,GAAG,IAAI,EAAE,GAAG,IAAI,GAAG,IAAI,OAAO,GAAG,EAAE;AAU1E,MAAM,SAAS,MAAM,WAAyC,SAASA,QAAO;AAAA,EACnF;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV;AAAA,EACA,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA,cAAc;AAChB,GAAgB,KAAK;AACn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AAC;AAAA,YAED;AAAA,cAAC;AAAA;AAAA,gBACC,OAAO,GAAG;AAAA,kBACR,UAAU;AAAA,kBACV,KAAK;AAAA,kBACL,MAAM,UAAU,EAAE,IAAI,EAAE,QAAQ,IAAI;AAAA,kBACpC,OAAO,EAAE;AAAA,kBACT,QAAQ,EAAE;AAAA,kBACV,cAAc;AAAA,kBACd,YAAY;AAAA,kBACZ,WAAW;AAAA,kBACX,YAAY;AAAA,gBACd,CAAC;AAAA;AAAA,YACH;AAAA;AAAA,QACF;AAAA;AAAA;AAAA,EACF;AAEJ,CAAC;AAED,OAAO,cAAc;","names":["Switch"]}
|
package/dist/forms/Textarea.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ interface TextareaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement
|
|
|
13
13
|
*/
|
|
14
14
|
showCount?: boolean;
|
|
15
15
|
containerStyle?: React.CSSProperties;
|
|
16
|
-
/** Reserve the hint/error row's height even with neither set
|
|
16
|
+
/** Reserve the hint/error row's height even with neither set - stops the
|
|
17
17
|
* field from growing the moment a validation message appears. */
|
|
18
18
|
preserveHelperSpace?: boolean;
|
|
19
19
|
}
|
|
@@ -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
|
|
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,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A,MACA;AAAA,MACA;AAAA,MACA,iBAAe;AAAA,MACf,SAAS;AAAA,MACT,OAAO;AAAA,MACP,SAAS,cAAc,oBAAC,aAAU,OAAc,KAAU,IAAK;AAAA,MAC/D;AAAA,MAEA;AAAA,QAAC;AAAA;AAAA,UACC,IAAI;AAAA,UACJ,KAAK;AAAA,UACL;AAAA,UACA;AAAA,UACC,GAAG;AAAA,UACH,GAAG;AAAA,UACJ,SAAS;AAAA,UACT,QAAQ;AAAA,UACR;AAAA,UACA,OAAO,GAAG;AAAA,YACR,OAAO;AAAA,YACP,SAAS;AAAA,YACT,QAAQ;AAAA,YACR,cAAc;AAAA,YACd,YAAY,WAAW,mCAAmC;AAAA,YAC1D,QAAQ,yCAAyC,QAAQ,6BAA6B,QAAQ,wBAAwB;AAAA,YACtH,WAAW,SAAS,CAAC,QAAQ,sBAAsB;AAAA,YACnD,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"]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* The month calendar body
|
|
4
|
+
* The month calendar body - header (‹ / › month nav + a month/year jump
|
|
5
5
|
* popover) and the day grid with roving-tabindex keyboard navigation
|
|
6
6
|
* (SS-228). Shared by `DateTimePicker` (rendered inline, with an optional
|
|
7
7
|
* time-slot list under it) and `DatePicker` (rendered inside its own
|
|
8
|
-
* trigger+popover shell)
|
|
8
|
+
* trigger+popover shell) - extracted so neither has to duplicate the
|
|
9
9
|
* keyboard-grid math (SS-243). See `DateTimePicker`'s own doc comment for
|
|
10
10
|
* the full behavior description; this component owns exactly the same
|
|
11
11
|
* state and logic it always has, just without the outer card chrome or
|
|
@@ -21,22 +21,22 @@ interface CalendarGridProps {
|
|
|
21
21
|
renderDay?: (day: number) => React.ReactNode;
|
|
22
22
|
/**
|
|
23
23
|
* Day cells are perfect squares (`aspect-ratio`) instead of a fixed pixel
|
|
24
|
-
* height
|
|
24
|
+
* height - `DatePicker` (SS-243) opts into this since its popover can be
|
|
25
25
|
* narrower than `DateTimePicker`'s own card, where a fixed height was
|
|
26
|
-
* already tuned and shipped. Ignored when `renderDay` is set
|
|
26
|
+
* already tuned and shipped. Ignored when `renderDay` is set - that case
|
|
27
27
|
* always needs the extra fixed height for its own content.
|
|
28
28
|
*/
|
|
29
29
|
squareCells?: boolean;
|
|
30
30
|
/**
|
|
31
31
|
* Drop wholly-blank trailing rows instead of always padding to 6 (SS-243)
|
|
32
|
-
*
|
|
32
|
+
* `DateTimePicker` needs the fixed 6 rows so its *always-visible* card
|
|
33
33
|
* never jumps height as you navigate months; `DatePicker`'s popover opens
|
|
34
34
|
* and closes anyway, so a variable height per month reads better than a
|
|
35
35
|
* dead empty row (e.g. a 30-day month starting on Sunday only needs 5).
|
|
36
36
|
*/
|
|
37
37
|
trimEmptyRows?: boolean;
|
|
38
38
|
/**
|
|
39
|
-
* The product itself (Sereno's real booking app) always renders pt-BR
|
|
39
|
+
* The product itself (Sereno's real booking app) always renders pt-BR -
|
|
40
40
|
* this only exists so the docs showcase can demo an English-speaking
|
|
41
41
|
* consumer without forking the component. Default stays `'pt-BR'`.
|
|
42
42
|
*/
|
|
@@ -409,7 +409,7 @@ function CalendarGrid({
|
|
|
409
409
|
fontWeight: sel ? "var(--weight-bold)" : "var(--weight-medium)",
|
|
410
410
|
textDecoration: off ? "line-through" : "none",
|
|
411
411
|
transition: "var(--transition-control)"
|
|
412
|
-
// Not inline outline:none
|
|
412
|
+
// Not inline outline:none - that would always beat the
|
|
413
413
|
// .sereno-dtp-days:focus-visible rule below no matter what
|
|
414
414
|
// it says (inline style always outranks a class selector).
|
|
415
415
|
// Suppressed as a class rule instead, same specificity as
|