@sereno-ds/ui 0.33.1 → 0.33.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_internal/useIsoLayoutEffect.d.ts +7 -0
- package/dist/_internal/useIsoLayoutEffect.js +6 -0
- package/dist/_internal/useIsoLayoutEffect.js.map +1 -0
- package/dist/_internal/useValueLength.d.ts +25 -0
- package/dist/_internal/useValueLength.js +72 -0
- package/dist/_internal/useValueLength.js.map +1 -0
- package/dist/forms/Input.js +13 -14
- package/dist/forms/Input.js.map +1 -1
- package/dist/forms/Select.js +1 -1
- package/dist/forms/Select.js.map +1 -1
- package/dist/forms/Textarea.js +10 -8
- package/dist/forms/Textarea.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/_internal/useIsoLayoutEffect.ts"],"sourcesContent":["import * as React from 'react';\n\n/** `useLayoutEffect` in the browser, `useEffect` on the server (React 18 warns\n * about the former during SSR). */\nexport const useIsoLayoutEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;\n"],"mappings":"AAAA,YAAY,WAAW;AAIhB,MAAM,qBAAqB,OAAO,WAAW,cAAc,MAAM,kBAAkB,MAAM;","names":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
type TextField = HTMLInputElement | HTMLTextAreaElement;
|
|
4
|
+
/**
|
|
5
|
+
* Length of an uncontrolled text field's value, read from the element itself, for
|
|
6
|
+
* the `n / max` counter of `Input` and `Textarea`.
|
|
7
|
+
*
|
|
8
|
+
* `onChange` only fires for typing. A form library (react-hook-form's `register()`
|
|
9
|
+
* on mount, `reset()`, `setValue()`) or plain code writes `el.value = …` straight
|
|
10
|
+
* to the DOM instead: no event, and no prop to render from. So the count is
|
|
11
|
+
* derived from the element and kept fresh three ways, none of them polling:
|
|
12
|
+
*
|
|
13
|
+
* - after every render (a changed `defaultValue`, or anything else that re-renders);
|
|
14
|
+
* - the `input` / `change` events (typing, autofill) and the form's `reset` (native `form.reset()`);
|
|
15
|
+
* - a wrapper on the element's own `value` setter, the only way to see a write that
|
|
16
|
+
* fires no event and causes no render. It calls straight through to the setter it
|
|
17
|
+
* found (React's tracker included) and is taken off again on cleanup.
|
|
18
|
+
*
|
|
19
|
+
* Pass `enabled: false` for a controlled field (its count comes from `value`) or one
|
|
20
|
+
* with no counter; nothing is attached then. `initial` is the count to render before
|
|
21
|
+
* the element exists (SSR, first paint).
|
|
22
|
+
*/
|
|
23
|
+
declare function useValueLength(ref: React.RefObject<TextField | null>, enabled: boolean, initial: number): number;
|
|
24
|
+
|
|
25
|
+
export { useValueLength };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useIsoLayoutEffect } from "./useIsoLayoutEffect.js";
|
|
3
|
+
function valueDescriptor(el) {
|
|
4
|
+
for (let o = el; o; o = Object.getPrototypeOf(o)) {
|
|
5
|
+
const d = Object.getOwnPropertyDescriptor(o, "value");
|
|
6
|
+
if (d) return d;
|
|
7
|
+
}
|
|
8
|
+
return void 0;
|
|
9
|
+
}
|
|
10
|
+
function useValueLength(ref, enabled, initial) {
|
|
11
|
+
const [length, setLength] = React.useState(initial);
|
|
12
|
+
useIsoLayoutEffect(() => {
|
|
13
|
+
const el = ref.current;
|
|
14
|
+
if (enabled && el && el.value.length !== length) setLength(el.value.length);
|
|
15
|
+
});
|
|
16
|
+
useIsoLayoutEffect(() => {
|
|
17
|
+
const el = ref.current;
|
|
18
|
+
if (!enabled || !el) return;
|
|
19
|
+
let live = true;
|
|
20
|
+
let timer;
|
|
21
|
+
const sync = () => {
|
|
22
|
+
if (live) setLength(el.value.length);
|
|
23
|
+
};
|
|
24
|
+
const onReset = () => {
|
|
25
|
+
clearTimeout(timer);
|
|
26
|
+
timer = setTimeout(sync, 0);
|
|
27
|
+
};
|
|
28
|
+
el.addEventListener("input", sync);
|
|
29
|
+
el.addEventListener("change", sync);
|
|
30
|
+
const form = el.form;
|
|
31
|
+
form?.addEventListener("reset", onReset);
|
|
32
|
+
const own = Object.getOwnPropertyDescriptor(el, "value");
|
|
33
|
+
const base = own ?? valueDescriptor(el);
|
|
34
|
+
let unwrap;
|
|
35
|
+
if (base?.get && base.set) {
|
|
36
|
+
const { get, set } = base;
|
|
37
|
+
const wrapper = {
|
|
38
|
+
configurable: true,
|
|
39
|
+
enumerable: base.enumerable,
|
|
40
|
+
get() {
|
|
41
|
+
return get.call(this);
|
|
42
|
+
},
|
|
43
|
+
set(next) {
|
|
44
|
+
set.call(this, next);
|
|
45
|
+
sync();
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
try {
|
|
49
|
+
Object.defineProperty(el, "value", wrapper);
|
|
50
|
+
unwrap = () => {
|
|
51
|
+
if (Object.getOwnPropertyDescriptor(el, "value")?.set !== wrapper.set) return;
|
|
52
|
+
if (own) Object.defineProperty(el, "value", own);
|
|
53
|
+
else Reflect.deleteProperty(el, "value");
|
|
54
|
+
};
|
|
55
|
+
} catch {
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return () => {
|
|
59
|
+
live = false;
|
|
60
|
+
clearTimeout(timer);
|
|
61
|
+
el.removeEventListener("input", sync);
|
|
62
|
+
el.removeEventListener("change", sync);
|
|
63
|
+
form?.removeEventListener("reset", onReset);
|
|
64
|
+
unwrap?.();
|
|
65
|
+
};
|
|
66
|
+
}, [ref, enabled]);
|
|
67
|
+
return length;
|
|
68
|
+
}
|
|
69
|
+
export {
|
|
70
|
+
useValueLength
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=useValueLength.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/_internal/useValueLength.ts"],"sourcesContent":["import * as React from 'react';\nimport { useIsoLayoutEffect } from './useIsoLayoutEffect';\n\ntype TextField = HTMLInputElement | HTMLTextAreaElement;\n\n/** The descriptor `el.value` resolves to today: the element's own (React's value\n * tracker installs one on every input) or the one on its prototype chain. */\nfunction valueDescriptor(el: TextField): PropertyDescriptor | undefined {\n for (let o: object | null = el; o; o = Object.getPrototypeOf(o)) {\n const d = Object.getOwnPropertyDescriptor(o, 'value');\n if (d) return d;\n }\n return undefined;\n}\n\n/**\n * Length of an uncontrolled text field's value, read from the element itself, for\n * the `n / max` counter of `Input` and `Textarea`.\n *\n * `onChange` only fires for typing. A form library (react-hook-form's `register()`\n * on mount, `reset()`, `setValue()`) or plain code writes `el.value = …` straight\n * to the DOM instead: no event, and no prop to render from. So the count is\n * derived from the element and kept fresh three ways, none of them polling:\n *\n * - after every render (a changed `defaultValue`, or anything else that re-renders);\n * - the `input` / `change` events (typing, autofill) and the form's `reset` (native `form.reset()`);\n * - a wrapper on the element's own `value` setter, the only way to see a write that\n * fires no event and causes no render. It calls straight through to the setter it\n * found (React's tracker included) and is taken off again on cleanup.\n *\n * Pass `enabled: false` for a controlled field (its count comes from `value`) or one\n * with no counter; nothing is attached then. `initial` is the count to render before\n * the element exists (SSR, first paint).\n */\nexport function useValueLength(ref: React.RefObject<TextField | null>, enabled: boolean, initial: number): number {\n const [length, setLength] = React.useState(initial);\n\n // Every render: a cheap read that only sets state when the count really differs.\n useIsoLayoutEffect(() => {\n const el = ref.current;\n // An uncontrolled field's value lives in the DOM, not in React: this is where it is read back.\n if (enabled && el && el.value.length !== length) setLength(el.value.length);\n });\n\n useIsoLayoutEffect(() => {\n const el = ref.current;\n if (!enabled || !el) return;\n\n let live = true;\n let timer: ReturnType<typeof setTimeout> | undefined;\n const sync = () => {\n if (live) setLength(el.value.length);\n };\n // A native reset restores the value only after its event has been dispatched.\n const onReset = () => {\n clearTimeout(timer);\n timer = setTimeout(sync, 0);\n };\n\n el.addEventListener('input', sync);\n el.addEventListener('change', sync);\n const form = el.form;\n form?.addEventListener('reset', onReset);\n\n const own = Object.getOwnPropertyDescriptor(el, 'value');\n const base = own ?? valueDescriptor(el);\n let unwrap: (() => void) | undefined;\n if (base?.get && base.set) {\n const { get, set } = base;\n const wrapper: PropertyDescriptor = {\n configurable: true,\n enumerable: base.enumerable,\n get(this: TextField) {\n return get.call(this);\n },\n set(this: TextField, next: string) {\n set.call(this, next);\n sync();\n },\n };\n try {\n Object.defineProperty(el, 'value', wrapper);\n unwrap = () => {\n // Something may have wrapped ours since (a test library, say): leave the\n // chain intact then, `live` already makes ours inert.\n if (Object.getOwnPropertyDescriptor(el, 'value')?.set !== wrapper.set) return;\n if (own) Object.defineProperty(el, 'value', own);\n else Reflect.deleteProperty(el, 'value');\n };\n } catch {\n /* a non-configurable own `value`: fall back to the events above */\n }\n }\n\n return () => {\n live = false;\n clearTimeout(timer);\n el.removeEventListener('input', sync);\n el.removeEventListener('change', sync);\n form?.removeEventListener('reset', onReset);\n unwrap?.();\n };\n }, [ref, enabled]);\n\n return length;\n}\n"],"mappings":"AAAA,YAAY,WAAW;AACvB,SAAS,0BAA0B;AAMnC,SAAS,gBAAgB,IAA+C;AACtE,WAAS,IAAmB,IAAI,GAAG,IAAI,OAAO,eAAe,CAAC,GAAG;AAC/D,UAAM,IAAI,OAAO,yBAAyB,GAAG,OAAO;AACpD,QAAI,EAAG,QAAO;AAAA,EAChB;AACA,SAAO;AACT;AAqBO,SAAS,eAAe,KAAwC,SAAkB,SAAyB;AAChH,QAAM,CAAC,QAAQ,SAAS,IAAI,MAAM,SAAS,OAAO;AAGlD,qBAAmB,MAAM;AACvB,UAAM,KAAK,IAAI;AAEf,QAAI,WAAW,MAAM,GAAG,MAAM,WAAW,OAAQ,WAAU,GAAG,MAAM,MAAM;AAAA,EAC5E,CAAC;AAED,qBAAmB,MAAM;AACvB,UAAM,KAAK,IAAI;AACf,QAAI,CAAC,WAAW,CAAC,GAAI;AAErB,QAAI,OAAO;AACX,QAAI;AACJ,UAAM,OAAO,MAAM;AACjB,UAAI,KAAM,WAAU,GAAG,MAAM,MAAM;AAAA,IACrC;AAEA,UAAM,UAAU,MAAM;AACpB,mBAAa,KAAK;AAClB,cAAQ,WAAW,MAAM,CAAC;AAAA,IAC5B;AAEA,OAAG,iBAAiB,SAAS,IAAI;AACjC,OAAG,iBAAiB,UAAU,IAAI;AAClC,UAAM,OAAO,GAAG;AAChB,UAAM,iBAAiB,SAAS,OAAO;AAEvC,UAAM,MAAM,OAAO,yBAAyB,IAAI,OAAO;AACvD,UAAM,OAAO,OAAO,gBAAgB,EAAE;AACtC,QAAI;AACJ,QAAI,MAAM,OAAO,KAAK,KAAK;AACzB,YAAM,EAAE,KAAK,IAAI,IAAI;AACrB,YAAM,UAA8B;AAAA,QAClC,cAAc;AAAA,QACd,YAAY,KAAK;AAAA,QACjB,MAAqB;AACnB,iBAAO,IAAI,KAAK,IAAI;AAAA,QACtB;AAAA,QACA,IAAqB,MAAc;AACjC,cAAI,KAAK,MAAM,IAAI;AACnB,eAAK;AAAA,QACP;AAAA,MACF;AACA,UAAI;AACF,eAAO,eAAe,IAAI,SAAS,OAAO;AAC1C,iBAAS,MAAM;AAGb,cAAI,OAAO,yBAAyB,IAAI,OAAO,GAAG,QAAQ,QAAQ,IAAK;AACvE,cAAI,IAAK,QAAO,eAAe,IAAI,SAAS,GAAG;AAAA,cAC1C,SAAQ,eAAe,IAAI,OAAO;AAAA,QACzC;AAAA,MACF,QAAQ;AAAA,MAER;AAAA,IACF;AAEA,WAAO,MAAM;AACX,aAAO;AACP,mBAAa,KAAK;AAClB,SAAG,oBAAoB,SAAS,IAAI;AACpC,SAAG,oBAAoB,UAAU,IAAI;AACrC,YAAM,oBAAoB,SAAS,OAAO;AAC1C,eAAS;AAAA,IACX;AAAA,EACF,GAAG,CAAC,KAAK,OAAO,CAAC;AAEjB,SAAO;AACT;","names":[]}
|
package/dist/forms/Input.js
CHANGED
|
@@ -7,6 +7,7 @@ import { Field } from "../_internal/Field.js";
|
|
|
7
7
|
import { CharCount } from "../_internal/CharCount.js";
|
|
8
8
|
import { formatMask, MASK_INPUTMODE, MASK_MAXLENGTH } from "../_internal/mask.js";
|
|
9
9
|
import { mergeRefs } from "../_internal/mergeRefs.js";
|
|
10
|
+
import { useValueLength } from "../_internal/useValueLength.js";
|
|
10
11
|
const H = { sm: "var(--control-height-sm)", md: "var(--control-height-md)", lg: "var(--control-height-lg)" };
|
|
11
12
|
const Input = React.forwardRef(function Input2({
|
|
12
13
|
label,
|
|
@@ -41,24 +42,22 @@ const Input = React.forwardRef(function Input2({
|
|
|
41
42
|
const isPassword = type === "password";
|
|
42
43
|
const showCounter = Boolean(showCount) || maxLength != null;
|
|
43
44
|
const seed = mask && typeof defaultValue === "string" ? formatMask(mask, defaultValue) : defaultValue;
|
|
44
|
-
const
|
|
45
|
-
|
|
45
|
+
const uncount = useValueLength(
|
|
46
|
+
inputRef,
|
|
47
|
+
showCounter && rest.value === void 0,
|
|
48
|
+
typeof seed === "string" || typeof seed === "number" ? String(seed).length : 0
|
|
46
49
|
);
|
|
47
50
|
const count = rest.value !== void 0 ? String(rest.value ?? "").length : uncount;
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
if (
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
el.
|
|
55
|
-
|
|
56
|
-
el.setSelectionRange(formatted.length, formatted.length);
|
|
57
|
-
} catch {
|
|
58
|
-
}
|
|
51
|
+
const handleChange = mask ? (e) => {
|
|
52
|
+
const formatted = formatMask(mask, e.currentTarget.value);
|
|
53
|
+
if (formatted !== e.currentTarget.value) {
|
|
54
|
+
const el = e.currentTarget;
|
|
55
|
+
el.value = formatted;
|
|
56
|
+
try {
|
|
57
|
+
el.setSelectionRange(formatted.length, formatted.length);
|
|
58
|
+
} catch {
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
if (rest.value === void 0) setUncount(e.currentTarget.value.length);
|
|
62
61
|
onChange?.(e);
|
|
63
62
|
} : onChange;
|
|
64
63
|
const handleFocus = (e) => {
|
package/dist/forms/Input.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/forms/Input.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Eye, EyeOff } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { Field } from '../_internal/Field';\nimport { CharCount } from '../_internal/CharCount';\nimport { formatMask, MASK_INPUTMODE, MASK_MAXLENGTH, type MaskName } from '../_internal/mask';\nimport { mergeRefs } from '../_internal/mergeRefs';\n\n/**\n * Single-line text field with label, hint and error states.\n */\nexport interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size' | 'prefix'> {\n label?: string;\n /** Helper text under the field. Replaced by `error` when present. */\n hint?: string;\n /** Error message; also turns the border red. */\n error?: string;\n required?: boolean;\n size?: 'sm' | 'md' | 'lg';\n iconLeft?: React.ReactNode;\n /** Leading text adornment (e.g. \"R$\", \"@\", \"+55\"). Not part of the value. */\n prefix?: React.ReactNode;\n /** Trailing text or control (e.g. \"min\", a clear button). Not part of the value. */\n suffix?: React.ReactNode;\n /**\n * Format the value as the user types. A preset (`phone` / `cpf` / `cep` /\n * `currency`) or a custom pattern where `#` is one digit (`(##) #####-####`).\n * Sets `inputMode` and `maxLength` unless you pass your own.\n */\n mask?: MaskName | string;\n /**\n * Show a `n / max` character counter on the hint row. Implied when `maxLength`\n * is set; pass `showCount` on its own for a bare count with no ceiling.\n */\n showCount?: boolean;\n containerStyle?: React.CSSProperties;\n /** Reserve the hint/error row's height even with neither set — stops the\n * field from growing the moment a validation message appears. */\n preserveHelperSpace?: boolean;\n}\n\nconst H = { sm: 'var(--control-height-sm)', md: 'var(--control-height-md)', lg: 'var(--control-height-lg)' } as const;\n\nexport const Input = React.forwardRef<HTMLInputElement, InputProps>(function Input(\n {\n label,\n hint,\n error,\n required,\n size = 'md',\n iconLeft,\n prefix,\n suffix,\n disabled,\n id,\n style,\n containerStyle,\n mask,\n showCount,\n preserveHelperSpace,\n type,\n onChange,\n onFocus,\n onBlur,\n inputMode,\n maxLength,\n defaultValue,\n ...rest\n },\n ref,\n) {\n const [focus, setFocus] = React.useState(false);\n const [reveal, setReveal] = React.useState(false);\n const inputRef = React.useRef<HTMLInputElement>(null);\n // SSR-stable id (the DS source used Math.random(), which breaks hydration).\n const autoId = React.useId();\n const rid = id || autoId;\n\n const isPassword = type === 'password';\n const showCounter = Boolean(showCount) || maxLength != null;\n\n const seed = mask && typeof defaultValue === 'string' ? formatMask(mask, defaultValue) : defaultValue;\n const [uncount, setUncount] = React.useState(() =>\n typeof seed === 'string' || typeof seed === 'number' ? String(seed).length : 0,\n );\n const count = rest.value !== undefined ? String(rest.value ?? '').length : uncount;\n\n const needsWrap = Boolean(mask) || showCounter;\n const handleChange = needsWrap\n ? (e: React.ChangeEvent<HTMLInputElement>) => {\n if (mask) {\n const formatted = formatMask(mask, e.currentTarget.value);\n if (formatted !== e.currentTarget.value) {\n const el = e.currentTarget;\n el.value = formatted;\n // keep the caret at the end — the natural spot while typing forward\n try {\n el.setSelectionRange(formatted.length, formatted.length);\n } catch {\n /* type doesn't support selection */\n }\n }\n }\n if (rest.value === undefined) setUncount(e.currentTarget.value.length);\n onChange?.(e);\n }\n : onChange;\n\n // Composed the same way as `handleChange` above — the focus ring's own\n // onFocus/onBlur must never be silently replaced by a caller's handler\n // (or by react-hook-form's `register()`, which always injects its own\n // onBlur), the way a plain `{...rest}` spread after them would do.\n const handleFocus = (e: React.FocusEvent<HTMLInputElement>) => {\n setFocus(true);\n onFocus?.(e);\n };\n const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {\n setFocus(false);\n onBlur?.(e);\n };\n\n return (\n <Field\n label={label}\n hint={hint}\n error={error}\n required={required}\n htmlFor={rid}\n style={containerStyle}\n counter={showCounter ? <CharCount count={count} max={maxLength ?? undefined} /> : undefined}\n preserveHelperSpace={preserveHelperSpace}\n >\n <div\n style={sx({\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-2)',\n height: H[size] || H.md,\n padding: '0 var(--space-3)',\n borderRadius: 'var(--radius-control)',\n background: disabled ? 'var(--interactive-disabled-bg)' : 'var(--bg-surface)',\n border: 'var(--border-width-hairline) solid ' + (error ? 'var(--interactive-error)' : focus ? 'var(--border-focus)' : 'var(--border-default)'),\n boxShadow: focus ? (error ? 'none' : 'var(--focus-ring)') : 'none',\n transition: 'var(--transition-control)',\n })}\n >\n {iconLeft && <span style={sx({ display: 'flex', color: 'var(--text-muted)', flex: '0 0 auto' })}>{iconLeft}</span>}\n {prefix && (\n <span style={sx({ display: 'flex', alignItems: 'center', color: 'var(--text-muted)', fontSize: size === 'sm' ? 'var(--text-sm)' : 'var(--text-base)', lineHeight: 1.2, flex: '0 0 auto' })}>{prefix}</span>\n )}\n <input\n id={rid}\n disabled={disabled}\n {...rest}\n ref={mergeRefs(inputRef, ref)}\n type={isPassword && reveal ? 'text' : type}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onChange={handleChange}\n inputMode={mask ? inputMode ?? MASK_INPUTMODE[mask] ?? 'numeric' : inputMode}\n maxLength={mask ? maxLength ?? MASK_MAXLENGTH[mask] : maxLength}\n defaultValue={mask && typeof defaultValue === 'string' ? formatMask(mask, defaultValue) : defaultValue}\n style={sx({\n flex: 1,\n minWidth: 0,\n margin: 0,\n padding: 0, // reset the UA input padding — the row's own padding insets it\n border: 'none',\n outline: 'none',\n background: 'transparent',\n fontFamily: 'var(--font-body)',\n fontSize: size === 'sm' ? 'var(--text-sm)' : 'var(--text-base)',\n lineHeight: 1.2, // match the prefix/suffix line box so baselines align\n color: disabled ? 'var(--text-disabled)' : 'var(--text-primary)',\n ...style,\n })}\n />\n {isPassword ? (\n <button\n type=\"button\"\n className=\"ds-affix-btn\"\n aria-label={reveal ? 'Ocultar senha' : 'Mostrar senha'}\n aria-pressed={reveal}\n onClick={() => {\n setReveal((r) => !r);\n inputRef.current?.focus();\n }}\n >\n {reveal ? <EyeOff size={16} strokeWidth={1.75} /> : <Eye size={16} strokeWidth={1.75} />}\n </button>\n ) : (\n suffix && (\n <span style={sx({ display: 'flex', alignItems: 'center', color: 'var(--text-muted)', fontSize: size === 'sm' ? 'var(--text-sm)' : 'var(--text-base)', lineHeight: 1.2, flex: '0 0 auto' })}>{suffix}</span>\n )\n )}\n </div>\n </Field>\n );\n});\n\nInput.displayName = 'Input';\n"],"mappings":";AAmI6B,cAGvB,YAHuB;AAjI7B,YAAY,WAAW;AACvB,SAAS,KAAK,cAAc;AAC5B,SAAS,UAAU;AACnB,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,YAAY,gBAAgB,sBAAqC;AAC1E,SAAS,iBAAiB;AAmC1B,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;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GACA,KACA;AACA,QAAM,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAS,KAAK;AAC9C,QAAM,CAAC,QAAQ,SAAS,IAAI,MAAM,SAAS,KAAK;AAChD,QAAM,WAAW,MAAM,OAAyB,IAAI;AAEpD,QAAM,SAAS,MAAM,MAAM;AAC3B,QAAM,MAAM,MAAM;AAElB,QAAM,aAAa,SAAS;AAC5B,QAAM,cAAc,QAAQ,SAAS,KAAK,aAAa;AAEvD,QAAM,OAAO,QAAQ,OAAO,iBAAiB,WAAW,WAAW,MAAM,YAAY,IAAI;AACzF,QAAM,CAAC,SAAS,UAAU,IAAI,MAAM;AAAA,IAAS,MAC3C,OAAO,SAAS,YAAY,OAAO,SAAS,WAAW,OAAO,IAAI,EAAE,SAAS;AAAA,EAC/E;AACA,QAAM,QAAQ,KAAK,UAAU,SAAY,OAAO,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,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 { 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 ...rest\n },\n ref,\n) {\n const [focus, setFocus] = React.useState(false);\n const [reveal, setReveal] = React.useState(false);\n const inputRef = React.useRef<HTMLInputElement>(null);\n // SSR-stable id (the DS source used Math.random(), which breaks hydration).\n const autoId = React.useId();\n const rid = id || autoId;\n\n const isPassword = type === 'password';\n const showCounter = Boolean(showCount) || maxLength != null;\n\n const seed = mask && typeof defaultValue === 'string' ? formatMask(mask, defaultValue) : defaultValue;\n // 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 htmlFor={rid}\n style={containerStyle}\n counter={showCounter ? <CharCount count={count} max={maxLength ?? undefined} /> : undefined}\n preserveHelperSpace={preserveHelperSpace}\n >\n <div\n style={sx({\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-2)',\n height: H[size] || H.md,\n padding: '0 var(--space-3)',\n borderRadius: 'var(--radius-control)',\n background: disabled ? 'var(--interactive-disabled-bg)' : 'var(--bg-surface)',\n border: 'var(--border-width-hairline) solid ' + (error ? 'var(--interactive-error)' : focus ? 'var(--border-focus)' : 'var(--border-default)'),\n boxShadow: focus ? (error ? 'none' : 'var(--focus-ring)') : 'none',\n transition: 'var(--transition-control)',\n })}\n >\n {iconLeft && <span style={sx({ display: 'flex', color: 'var(--text-muted)', flex: '0 0 auto' })}>{iconLeft}</span>}\n {prefix && (\n <span style={sx({ display: 'flex', alignItems: 'center', color: 'var(--text-muted)', fontSize: size === 'sm' ? 'var(--text-sm)' : 'var(--text-base)', lineHeight: 1.2, flex: '0 0 auto' })}>{prefix}</span>\n )}\n <input\n id={rid}\n disabled={disabled}\n {...rest}\n ref={mergeRefs(inputRef, ref)}\n type={isPassword && reveal ? 'text' : type}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onChange={handleChange}\n inputMode={mask ? inputMode ?? MASK_INPUTMODE[mask] ?? 'numeric' : inputMode}\n maxLength={mask ? maxLength ?? MASK_MAXLENGTH[mask] : maxLength}\n defaultValue={mask && typeof defaultValue === 'string' ? formatMask(mask, defaultValue) : defaultValue}\n style={sx({\n flex: 1,\n minWidth: 0,\n margin: 0,\n padding: 0, // reset the UA input padding — the row's own padding insets it\n border: 'none',\n outline: 'none',\n background: 'transparent',\n fontFamily: 'var(--font-body)',\n fontSize: size === 'sm' ? 'var(--text-sm)' : 'var(--text-base)',\n lineHeight: 1.2, // match the prefix/suffix line box so baselines align\n color: disabled ? 'var(--text-disabled)' : 'var(--text-primary)',\n ...style,\n })}\n />\n {isPassword ? (\n <button\n type=\"button\"\n className=\"ds-affix-btn\"\n aria-label={reveal ? 'Ocultar senha' : 'Mostrar senha'}\n aria-pressed={reveal}\n onClick={() => {\n setReveal((r) => !r);\n inputRef.current?.focus();\n }}\n >\n {reveal ? <EyeOff size={16} strokeWidth={1.75} /> : <Eye size={16} strokeWidth={1.75} />}\n </button>\n ) : (\n suffix && (\n <span style={sx({ display: 'flex', alignItems: 'center', color: 'var(--text-muted)', fontSize: size === 'sm' ? 'var(--text-sm)' : 'var(--text-base)', lineHeight: 1.2, flex: '0 0 auto' })}>{suffix}</span>\n )\n )}\n </div>\n </Field>\n );\n});\n\nInput.displayName = 'Input';\n"],"mappings":";AAoI6B,cAGvB,YAHuB;AAlI7B,YAAY,WAAW;AACvB,SAAS,KAAK,cAAc;AAC5B,SAAS,UAAU;AACnB,SAAS,aAAa;AACtB,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;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GACA,KACA;AACA,QAAM,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAS,KAAK;AAC9C,QAAM,CAAC,QAAQ,SAAS,IAAI,MAAM,SAAS,KAAK;AAChD,QAAM,WAAW,MAAM,OAAy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C,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"]}
|
package/dist/forms/Select.js
CHANGED
|
@@ -4,10 +4,10 @@ import * as React from "react";
|
|
|
4
4
|
import { createPortal } from "react-dom";
|
|
5
5
|
import { Check, ChevronDown } from "lucide-react";
|
|
6
6
|
import { sx } from "../_internal/style.js";
|
|
7
|
+
import { useIsoLayoutEffect } from "../_internal/useIsoLayoutEffect.js";
|
|
7
8
|
import { Field } from "../_internal/Field.js";
|
|
8
9
|
import { fieldBoxStyle } from "./_internal/fieldBoxStyle.js";
|
|
9
10
|
const OPTION_PAD_Y = { sm: 6, md: 8, lg: 10 };
|
|
10
|
-
const useIsoLayoutEffect = typeof window !== "undefined" ? React.useLayoutEffect : React.useEffect;
|
|
11
11
|
function useCoarsePointer() {
|
|
12
12
|
return React.useSyncExternalStore(
|
|
13
13
|
(onChange) => {
|
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 { Field } from '../_internal/Field';\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\nconst useIsoLayoutEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;\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 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 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 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} 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 onCommit={commit}\n />\n {name && <input ref={ref} type=\"hidden\" name={name} value={value} />}\n </Field>\n );\n});\n\nSelect.displayName = 'Select';\n"],"mappings":";AAqVM,SAuBE,KAvBF;AAnVN,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAC7B,SAAS,OAAO,mBAAmB;AACnC,SAAS,UAAU;AACnB,SAAS,aAAa;AACtB,SAAS,qBAAqB;AAmD9B,MAAM,eAAe,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG;AAE5C,MAAM,qBAAqB,OAAO,WAAW,cAAc,MAAM,kBAAkB,MAAM;AAGzF,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;AACF,GAeG;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,Q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;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,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 { 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 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 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 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} 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 onCommit={commit}\n />\n {name && <input ref={ref} type=\"hidden\" name={name} value={value} />}\n </Field>\n );\n});\n\nSelect.displayName = 'Select';\n"],"mappings":";AAoVM,SAuBE,KAvBF;AAlVN,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAC7B,SAAS,OAAO,mBAAmB;AACnC,SAAS,UAAU;AACnB,SAAS,0BAA0B;AACnC,SAAS,aAAa;AACtB,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,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,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,SAAS,KAAK,OAAO,gBAAgB,qBACtG;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,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/Textarea.js
CHANGED
|
@@ -4,20 +4,22 @@ import * as React from "react";
|
|
|
4
4
|
import { sx } from "../_internal/style.js";
|
|
5
5
|
import { Field } from "../_internal/Field.js";
|
|
6
6
|
import { CharCount } from "../_internal/CharCount.js";
|
|
7
|
+
import { mergeRefs } from "../_internal/mergeRefs.js";
|
|
8
|
+
import { useValueLength } from "../_internal/useValueLength.js";
|
|
7
9
|
const Textarea = React.forwardRef(function Textarea2({ label, hint, error, required, rows = 4, showCount, preserveHelperSpace, disabled, id, style, containerStyle, onChange, onFocus, onBlur, ...rest }, ref) {
|
|
8
10
|
const [focus, setFocus] = React.useState(false);
|
|
11
|
+
const textareaRef = React.useRef(null);
|
|
12
|
+
const setRefs = React.useMemo(() => mergeRefs(textareaRef, ref), [ref]);
|
|
9
13
|
const autoId = React.useId();
|
|
10
14
|
const rid = id || autoId;
|
|
11
15
|
const max = typeof rest.maxLength === "number" ? rest.maxLength : void 0;
|
|
12
16
|
const showCounter = Boolean(showCount) || max != null;
|
|
13
|
-
const
|
|
14
|
-
|
|
17
|
+
const uncount = useValueLength(
|
|
18
|
+
textareaRef,
|
|
19
|
+
showCounter && rest.value === void 0,
|
|
20
|
+
typeof rest.defaultValue === "string" || typeof rest.defaultValue === "number" ? String(rest.defaultValue).length : 0
|
|
15
21
|
);
|
|
16
22
|
const count = rest.value !== void 0 ? String(rest.value ?? "").length : uncount;
|
|
17
|
-
const handleChange = showCounter ? (e) => {
|
|
18
|
-
if (rest.value === void 0) setUncount(e.currentTarget.value.length);
|
|
19
|
-
onChange?.(e);
|
|
20
|
-
} : onChange;
|
|
21
23
|
const handleFocus = (e) => {
|
|
22
24
|
setFocus(true);
|
|
23
25
|
onFocus?.(e);
|
|
@@ -41,13 +43,13 @@ const Textarea = React.forwardRef(function Textarea2({ label, hint, error, requi
|
|
|
41
43
|
"textarea",
|
|
42
44
|
{
|
|
43
45
|
id: rid,
|
|
44
|
-
ref,
|
|
46
|
+
ref: setRefs,
|
|
45
47
|
rows,
|
|
46
48
|
disabled,
|
|
47
49
|
...rest,
|
|
48
50
|
onFocus: handleFocus,
|
|
49
51
|
onBlur: handleBlur,
|
|
50
|
-
onChange
|
|
52
|
+
onChange,
|
|
51
53
|
style: sx({
|
|
52
54
|
width: "100%",
|
|
53
55
|
padding: "var(--space-3)",
|
|
@@ -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 { CharCount } from '../_internal/CharCount';\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 { label, hint, error, required, rows = 4, showCount, preserveHelperSpace, disabled, id, style, containerStyle, onChange, onFocus, onBlur, ...rest },\n ref,\n) {\n const [focus, setFocus] = React.useState(false);\n // SSR-stable id (the DS source used Math.random(), which breaks hydration).\n const autoId = React.useId();\n const rid = id || autoId;\n\n const max = typeof rest.maxLength === 'number' ? rest.maxLength : undefined;\n const showCounter = Boolean(showCount) || max != null;\n
|
|
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 { 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 { label, hint, error, required, rows = 4, showCount, preserveHelperSpace, disabled, id, style, containerStyle, onChange, onFocus, onBlur, ...rest },\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\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 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 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":";AAwE6B;AAtE7B,YAAY,WAAW;AACvB,SAAS,UAAU;AACnB,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,sBAAsB;AAoBxB,MAAM,WAAW,MAAM,WAA+C,SAASA,UACpF,EAAE,OAAO,MAAM,OAAO,UAAU,OAAO,GAAG,WAAW,qBAAqB,UAAU,IAAI,OAAO,gBAAgB,UAAU,SAAS,QAAQ,GAAG,KAAK,GAClJ,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,MAAM,OAAO,KAAK,cAAc,WAAW,KAAK,YAAY;AAClE,QAAM,cAAc,QAAQ,SAAS,KAAK,OAAO;AAGjD,QAAM,UAAU;AAAA,IACd;AAAA,IACA,eAAe,KAAK,UAAU;AAAA,IAC9B,OAAO,KAAK,iBAAiB,YAAY,OAAO,KAAK,iBAAiB,WAAW,OAAO,KAAK,YAAY,EAAE,SAAS;AAAA,EACtH;AACA,QAAM,QAAQ,KAAK,UAAU,SAAY,OAAO,KAAK,SAAS,EAAE,EAAE,SAAS;AAO3E,QAAM,cAAc,CAAC,MAA6C;AAChE,aAAS,IAAI;AACb,cAAU,CAAC;AAAA,EACb;AACA,QAAM,aAAa,CAAC,MAA6C;AAC/D,aAAS,KAAK;AACd,aAAS,CAAC;AAAA,EACZ;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAS;AAAA,MACT,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