@lucian-seo/lucian-ui 0.2.0 → 0.2.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/lib/{Input-DzJm1Kv4.js → Input-Bv2FRGIe.js} +2 -2
- package/dist/lib/{Input-DzJm1Kv4.js.map → Input-Bv2FRGIe.js.map} +1 -1
- package/dist/lib/{Pagination-AWL5k5zG.js → Popover-Cq6yhJaK.js} +193 -132
- package/dist/lib/Popover-Cq6yhJaK.js.map +1 -0
- package/dist/lib/{Switch-DyKAqvde.js → Switch-DmKcoBT0.js} +3 -3
- package/dist/lib/Switch-DmKcoBT0.js.map +1 -0
- package/dist/lib/{Tag-Z8PjnJFt.js → Tag-CnNuj4nV.js} +2 -2
- package/dist/lib/{Tag-Z8PjnJFt.js.map → Tag-CnNuj4nV.js.map} +1 -1
- package/dist/lib/{TagInput-CeA0n7ax.js → TagInput-BcSSnJY_.js} +4 -4
- package/dist/lib/{TagInput-CeA0n7ax.js.map → TagInput-BcSSnJY_.js.map} +1 -1
- package/dist/lib/{ToggleButton-r73bokux.js → ToggleButton-CcST9ch9.js} +3 -3
- package/dist/lib/{ToggleButton-r73bokux.js.map → ToggleButton-CcST9ch9.js.map} +1 -1
- package/dist/lib/{Toolbar-DDOaxG3B.js → Toolbar-Cq2wF4Yg.js} +67 -127
- package/dist/lib/Toolbar-Cq2wF4Yg.js.map +1 -0
- package/dist/lib/{Tooltip-BW1-aVDg.js → Tooltip-1flxtzgM.js} +2 -2
- package/dist/lib/{Tooltip-BW1-aVDg.js.map → Tooltip-1flxtzgM.js.map} +1 -1
- package/dist/lib/{VisuallyHidden-DcE0EFpo.js → VisuallyHidden-Bht2-rdy.js} +16 -14
- package/dist/lib/VisuallyHidden-Bht2-rdy.js.map +1 -0
- package/dist/lib/{VoiceControlBar-lMPuJMcF.js → VoiceControlBar-iWzq7jiw.js} +1769 -1505
- package/dist/lib/VoiceControlBar-iWzq7jiw.js.map +1 -0
- package/dist/lib/{Waveform-EahaE6uD.js → Waveform-CtI9GetQ.js} +3 -3
- package/dist/lib/Waveform-CtI9GetQ.js.map +1 -0
- package/dist/lib/components/common/Badge/Badge.d.ts +1 -9
- package/dist/lib/components/common/Glass/Glass.d.ts +1 -3
- package/dist/lib/components/common/index.js +5 -5
- package/dist/lib/components/composed/index.js +3 -3
- package/dist/lib/components/derived/index.js +3 -3
- package/dist/lib/components/extended/DataGrid/DataGrid.clipboard.d.ts +2 -0
- package/dist/lib/components/extended/DataGrid/DataGrid.d.ts +6 -0
- package/dist/lib/components/extended/DataGrid/DataGrid.features.d.ts +2 -0
- package/dist/lib/components/extended/index.js +1 -1
- package/dist/lib/index.js +12 -12
- package/dist/lib/styles.css +1 -1
- package/dist/lib/tokens.css +29 -34
- package/docs/DATAGRID.md +111 -1
- package/package.json +1 -1
- package/dist/lib/Pagination-AWL5k5zG.js.map +0 -1
- package/dist/lib/Switch-DyKAqvde.js.map +0 -1
- package/dist/lib/Toolbar-DDOaxG3B.js.map +0 -1
- package/dist/lib/VisuallyHidden-DcE0EFpo.js.map +0 -1
- package/dist/lib/VoiceControlBar-lMPuJMcF.js.map +0 -1
- package/dist/lib/Waveform-EahaE6uD.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as e, s as t } from "./VisuallyHidden-
|
|
1
|
+
import { a as e, s as t } from "./VisuallyHidden-Bht2-rdy.js";
|
|
2
2
|
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
3
3
|
import { forwardRef as i, useRef as a, useState as o } from "react";
|
|
4
4
|
//#region src/components/common/Avatar/Avatar.tsx
|
|
@@ -90,4 +90,4 @@ var u = i(function({ size: i = "md", invalid: o, disabled: s, readOnly: c, iconS
|
|
|
90
90
|
//#endregion
|
|
91
91
|
export { l as n, s as r, u as t };
|
|
92
92
|
|
|
93
|
-
//# sourceMappingURL=Input-
|
|
93
|
+
//# sourceMappingURL=Input-Bv2FRGIe.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input-DzJm1Kv4.js","names":[],"sources":["../../src/components/common/Avatar/Avatar.tsx","../../src/components/common/Input/Input.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { LucideIcon } from \"lucide-react\";\nimport { Icon } from \"../Icon\";\nimport \"./Avatar.css\";\n\nexport type AvatarSize = \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\";\nexport type AvatarShape = \"circle\" | \"rounded\";\nexport type AvatarStatus = \"online\" | \"away\" | \"busy\" | \"offline\";\n/** One of the seven categorical colours, or `\"auto\"` to take one from the name. */\nexport type AvatarTint = 1 | 2 | 3 | 4 | 5 | 6 | 7 | \"auto\";\n\nexport type AvatarProps = {\n /** The person or thing. Used for the initials, and as the image's alternative text. */\n name: string;\n src?: string;\n size?: AvatarSize;\n shape?: AvatarShape;\n status?: AvatarStatus;\n /** What to draw when there is no image and no name worth reducing to letters. */\n fallbackIcon?: LucideIcon;\n /**\n * A ground colour, so a row of initials is a row of people rather than a row of grey boxes.\n *\n * `\"auto\"` derives it from the name, which is the point: the same person is the same colour\n * on every screen they appear on, without anyone storing a colour. It is decorative in the\n * strict sense — the initials and the name carry the identity, and two people can share a\n * colour without anything being lost.\n */\n tint?: AvatarTint;\n /**\n * The name is already said by whatever holds this avatar.\n *\n * Asked for by `AvatarGroup`, which puts each person's name in the list item itself so\n * that one element owns it. Without this the image's `alt` would say the name a second\n * time and a reader would hear \"김민수 김민수\"; with it the whole avatar leaves the\n * accessibility tree and the group's own text is the only version.\n */\n decorative?: boolean;\n className?: string;\n [key: `data-${string}`]: unknown;\n};\n\n/**\n * Initials from a name, in a way that survives Korean.\n *\n * A Latin name reduces to the first letter of the first and last words — \"Alex Smith\" is AS.\n * A Korean name does not: 김민수 is one word, and its first letter is the family name 김,\n * which is what a Korean reader expects to see. Splitting it further would give ㄱ, which is\n * a jamo and not a letter anyone writes.\n *\n * The rule is therefore: if the name contains Hangul, take its first syllable. Otherwise take\n * the first letter of the first two words.\n */\nexport function initialsOf(name: string): string {\n const trimmed = name.trim();\n if (!trimmed) return \"\";\n if (/[가-힣]/.test(trimmed)) return [...trimmed][0];\n const words = trimmed.split(/\\s+/).filter(Boolean);\n const letters = words.length > 1 ? [words[0], words[words.length - 1]] : [words[0]];\n return letters.map((word) => [...word][0]?.toUpperCase() ?? \"\").join(\"\").slice(0, 2);\n}\n\n/**\n * A number from 1 to 7 for a name, the same one every time.\n *\n * FNV-1a over code points rather than over UTF-16 units: a Hangul syllable is one code point\n * and two units, and hashing the units would spread names by how they happen to be encoded.\n * Seven is not a power of two, so the modulo does not throw away the mixing the hash did.\n */\nexport function tintOf(name: string): 1 | 2 | 3 | 4 | 5 | 6 | 7 {\n let hash = 2166136261;\n for (const character of name.trim()) {\n hash ^= character.codePointAt(0) ?? 0;\n hash = Math.imul(hash, 16777619) >>> 0;\n }\n return ((hash % 7) + 1) as 1 | 2 | 3 | 4 | 5 | 6 | 7;\n}\n\nexport function Avatar({\n name,\n src,\n size = \"md\",\n shape = \"circle\",\n status,\n fallbackIcon,\n tint,\n decorative,\n className,\n ...rest\n}: AvatarProps) {\n /*\n * A broken image is the common case, not the edge one — an avatar URL outlives the file it\n * points at. Falling back on error means the initials appear instead of a torn-page glyph.\n */\n const [failed, setFailed] = useState(false);\n const showImage = Boolean(src) && !failed;\n const initials = initialsOf(name);\n const ground = tint === \"auto\" ? tintOf(name) : tint;\n\n return (\n <span\n {...rest}\n className={`avatar ${className ?? \"\"}`.trim()}\n data-size={size}\n data-shape={shape}\n data-status={status}\n data-tint={ground}\n aria-hidden={decorative || undefined}\n >\n {showImage ? (\n <img\n className=\"avatar__image\"\n src={src}\n alt={decorative ? \"\" : name}\n onError={() => setFailed(true)}\n />\n ) : fallbackIcon ? (\n <Icon\n icon={fallbackIcon}\n size={size === \"xs\" || size === \"sm\" ? \"xs\" : \"sm\"}\n label={decorative ? undefined : name}\n />\n ) : (\n /* The initials are decorative: the name is already on the element that names this\n * avatar, and reading \"AS\" aloud tells a screen-reader user nothing. */\n <span className=\"avatar__initials\" aria-hidden=\"true\">{initials}</span>\n )}\n {status ? <span className=\"avatar__status\" data-status={status} aria-hidden=\"true\" /> : null}\n </span>\n );\n}\n","import { forwardRef, useRef, type ChangeEvent, type FocusEvent, type InputHTMLAttributes, type KeyboardEvent, type ReactNode, type Ref } from \"react\";\nimport type { LucideIcon } from \"lucide-react\";\nimport { Icon } from \"../Icon\";\nimport { useComposedRef } from \"../Glass/refraction\";\nimport \"./Input.css\";\n\nexport type InputSize = \"sm\" | \"md\" | \"lg\";\n\nexport type InputProps = {\n value?: string;\n defaultValue?: string;\n onChange?: (event: ChangeEvent<HTMLInputElement>) => void;\n onKeyDown?: (event: KeyboardEvent<HTMLInputElement>) => void;\n onFocus?: (event: FocusEvent<HTMLInputElement>) => void;\n onBlur?: (event: FocusEvent<HTMLInputElement>) => void;\n /**\n * Reaches the control, not the wrapper.\n *\n * Which is the only useful answer: the wrapper cannot be focused, cannot be read for a\n * value and is not what a form knows about. `SearchInput` uses it to put the reader back\n * in the field after its clear button has removed itself from under them.\n */\n ref?: Ref<HTMLInputElement>;\n type?: InputHTMLAttributes<HTMLInputElement>[\"type\"];\n placeholder?: string;\n size?: InputSize;\n /**\n * The value is not acceptable.\n *\n * Draws the border and sets `aria-invalid`, and does no more than that on purpose: the\n * reason belongs in a message the field owns, which is `Field`'s job. A control that says\n * only \"wrong\" in red is a control that says nothing to a reader who cannot see red.\n */\n invalid?: boolean;\n disabled?: boolean;\n readOnly?: boolean;\n required?: boolean;\n iconStart?: LucideIcon;\n iconEnd?: LucideIcon;\n /**\n * Something that can be pressed, inside the box.\n *\n * Asked for by the derived layer and by nothing else: `SearchInput` needs a clear button\n * inside the field, `PasswordInput` a reveal toggle, `NumberInput` a pair of steppers.\n * All three are *inside* the border rather than beside it, and a component that built its\n * own field to get them would be a second field with a second focus ring, a second set of\n * paddings and a second set of bugs.\n *\n * `iconStart`/`iconEnd` stay separate because an icon is not a control: it takes the muted\n * ink, has no hit area of its own and is never in the tab order.\n */\n slotStart?: ReactNode;\n slotEnd?: ReactNode;\n name?: string;\n id?: string;\n autoComplete?: string;\n /**\n * What the software keyboard and the corrector are allowed to do to what is typed.\n *\n * Asked for by `CouponField`. A coupon code is printed in capitals and typed on whatever\n * the keyboard happened to be in, and on a phone iOS will capitalise the first letter,\n * autocorrect the rest into a word, and underline it in red. Three attributes, and without\n * them the field is one a reader has to fight.\n */\n autoCapitalize?: string;\n autoCorrect?: string;\n spellCheck?: boolean;\n inputMode?: InputHTMLAttributes<HTMLInputElement>[\"inputMode\"];\n /**\n * The control's role, for the rare case where the element is not what it represents.\n *\n * `NumberInput` is the reason: it is a `type=\"text\"` that stands for a spin button, and\n * without this it would have to build its own field to say so.\n */\n role?: string;\n className?: string;\n [key: `data-${string}`]: unknown;\n [key: `aria-${string}`]: unknown;\n};\n\n/**\n * A single line of text.\n *\n * Always a wrapper around the control, whether or not there are icons, so that the box a\n * reader sees and the box the browser focuses are the same element in every case. A version\n * that only wrapped when an icon was present would have two focus rings, two paddings and\n * two sets of bugs.\n */\nexport const Input = forwardRef<HTMLInputElement, InputProps>(function Input({\n size = \"md\",\n invalid,\n disabled,\n readOnly,\n iconStart,\n iconEnd,\n slotStart,\n slotEnd,\n className,\n ...rest\n}: InputProps, ref) {\n const glyph = size === \"lg\" ? \"md\" : \"sm\";\n const control = useRef<HTMLInputElement>(null);\n const hold = useComposedRef(control, ref);\n\n /*\n * No lens here, and the comment this replaces claimed one.\n *\n * A field is not a floating surface. It sits ON one — inside a `Card`, a `Sheet`, a\n * `Glass` pane — and what those set for the controls riding on them is `--fill-solid`\n * and `--fill-backdrop`, which is how `Button` thins with the panel under it. A field\n * that bent its own backdrop would be glass on glass, blurring a surface that is\n * already blurred.\n *\n * It did call `useRefraction`, and drew a map per field that no rule in this component\n * ever read. The contract guard that should have caught a custom property nothing reads\n * could not see the conditional the value was written through; that hole is closed now.\n */\n\n return (\n <span\n className={`input ${className ?? \"\"}`.trim()}\n data-size={size}\n data-invalid={invalid ? \"\" : undefined}\n data-disabled={disabled ? \"\" : undefined}\n data-readonly={readOnly ? \"\" : undefined}\n onClick={event => {\n if (!(event.target as HTMLElement).closest(\".input__slot\")) control.current?.focus();\n }}\n >\n {iconStart ? <Icon icon={iconStart} size={glyph} className=\"input__glyph\" /> : null}\n {slotStart ? <span className=\"input__slot\">{slotStart}</span> : null}\n <input\n /*\n * Before the spread, so a caller's own `aria-invalid` wins.\n *\n * Written after it, this line replaced whatever the caller passed with `undefined`\n * — and `CouponField`, which marks its field from its own error state, silently had\n * no `aria-invalid` at all while its `aria-describedby` pointed at the message. It is\n * the rule `Stack`, `Select` and `Slider` already state: the component's own\n * attributes go before the spread, because a caller who names one has to win.\n */\n aria-invalid={invalid || undefined}\n {...rest}\n ref={hold}\n className=\"input__control\"\n disabled={disabled}\n readOnly={readOnly}\n />\n {iconEnd ? <Icon icon={iconEnd} size={glyph} className=\"input__glyph\" /> : null}\n {slotEnd ? <span className=\"input__slot\">{slotEnd}</span> : null}\n </span>\n );\n});\n"],"mappings":";;;;AAqDA,SAAgB,EAAW,GAAsB;CAC/C,IAAM,IAAU,EAAK,KAAK;CAC1B,IAAI,CAAC,GAAS,OAAO;CACrB,IAAI,QAAQ,KAAK,CAAO,GAAG,OAAO,CAAC,GAAG,CAAO,CAAC,CAAC;CAC/C,IAAM,IAAQ,EAAQ,MAAM,KAAK,CAAC,CAAC,OAAO,OAAO;CAEjD,QADgB,EAAM,SAAS,IAAI,CAAC,EAAM,IAAI,EAAM,EAAM,SAAS,EAAE,IAAI,CAAC,EAAM,EAAE,EAAA,CACnE,KAAK,MAAS,CAAC,GAAG,CAAI,CAAC,CAAC,EAAE,EAAE,YAAY,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC;AACrF;AASA,SAAgB,EAAO,GAAyC;CAC9D,IAAI,IAAO;CACX,KAAK,IAAM,KAAa,EAAK,KAAK,GAEhC,AADA,KAAQ,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AAW,KAAK,KAAA;EAC/B,UAAS,MAAS;GAChB,AAAM,EAAM,OAAuB,QAAQ,cAAc,KAAG,EAAQ,SAAS,MAAM;EACrF;EARF,UAAA;GAUG,IAAY,kBAAC,GAAD;IAAM,MAAM;IAAW,MAAM;IAAO,WAAU;GAAgB,CAAA,IAAI;GAC9E,IAAY,kBAAC,QAAD;IAAM,WAAU;IAAe,UAAA;GAAgB,CAAA,IAAI;GAChE,kBAAC,SAAD;IAUE,gBAAc,KAAW,KAAA;IACzB,GAAI;IACJ,KAAK;IACL,WAAU;IACA;IACA;GACX,CAAA;GACA,IAAU,kBAAC,GAAD;IAAM,MAAM;IAAS,MAAM;IAAO,WAAU;GAAgB,CAAA,IAAI;GAC1E,IAAU,kBAAC,QAAD;IAAM,WAAU;IAAe,UAAA;GAAc,CAAA,IAAI;EACxD;;AAEV,CAAC"}
|
|
1
|
+
{"version":3,"file":"Input-Bv2FRGIe.js","names":[],"sources":["../../src/components/common/Avatar/Avatar.tsx","../../src/components/common/Input/Input.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { LucideIcon } from \"lucide-react\";\nimport { Icon } from \"../Icon\";\nimport \"./Avatar.css\";\n\nexport type AvatarSize = \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\";\nexport type AvatarShape = \"circle\" | \"rounded\";\nexport type AvatarStatus = \"online\" | \"away\" | \"busy\" | \"offline\";\n/** One of the seven categorical colours, or `\"auto\"` to take one from the name. */\nexport type AvatarTint = 1 | 2 | 3 | 4 | 5 | 6 | 7 | \"auto\";\n\nexport type AvatarProps = {\n /** The person or thing. Used for the initials, and as the image's alternative text. */\n name: string;\n src?: string;\n size?: AvatarSize;\n shape?: AvatarShape;\n status?: AvatarStatus;\n /** What to draw when there is no image and no name worth reducing to letters. */\n fallbackIcon?: LucideIcon;\n /**\n * A ground colour, so a row of initials is a row of people rather than a row of grey boxes.\n *\n * `\"auto\"` derives it from the name, which is the point: the same person is the same colour\n * on every screen they appear on, without anyone storing a colour. It is decorative in the\n * strict sense — the initials and the name carry the identity, and two people can share a\n * colour without anything being lost.\n */\n tint?: AvatarTint;\n /**\n * The name is already said by whatever holds this avatar.\n *\n * Asked for by `AvatarGroup`, which puts each person's name in the list item itself so\n * that one element owns it. Without this the image's `alt` would say the name a second\n * time and a reader would hear \"김민수 김민수\"; with it the whole avatar leaves the\n * accessibility tree and the group's own text is the only version.\n */\n decorative?: boolean;\n className?: string;\n [key: `data-${string}`]: unknown;\n};\n\n/**\n * Initials from a name, in a way that survives Korean.\n *\n * A Latin name reduces to the first letter of the first and last words — \"Alex Smith\" is AS.\n * A Korean name does not: 김민수 is one word, and its first letter is the family name 김,\n * which is what a Korean reader expects to see. Splitting it further would give ㄱ, which is\n * a jamo and not a letter anyone writes.\n *\n * The rule is therefore: if the name contains Hangul, take its first syllable. Otherwise take\n * the first letter of the first two words.\n */\nexport function initialsOf(name: string): string {\n const trimmed = name.trim();\n if (!trimmed) return \"\";\n if (/[가-힣]/.test(trimmed)) return [...trimmed][0];\n const words = trimmed.split(/\\s+/).filter(Boolean);\n const letters = words.length > 1 ? [words[0], words[words.length - 1]] : [words[0]];\n return letters.map((word) => [...word][0]?.toUpperCase() ?? \"\").join(\"\").slice(0, 2);\n}\n\n/**\n * A number from 1 to 7 for a name, the same one every time.\n *\n * FNV-1a over code points rather than over UTF-16 units: a Hangul syllable is one code point\n * and two units, and hashing the units would spread names by how they happen to be encoded.\n * Seven is not a power of two, so the modulo does not throw away the mixing the hash did.\n */\nexport function tintOf(name: string): 1 | 2 | 3 | 4 | 5 | 6 | 7 {\n let hash = 2166136261;\n for (const character of name.trim()) {\n hash ^= character.codePointAt(0) ?? 0;\n hash = Math.imul(hash, 16777619) >>> 0;\n }\n return ((hash % 7) + 1) as 1 | 2 | 3 | 4 | 5 | 6 | 7;\n}\n\nexport function Avatar({\n name,\n src,\n size = \"md\",\n shape = \"circle\",\n status,\n fallbackIcon,\n tint,\n decorative,\n className,\n ...rest\n}: AvatarProps) {\n /*\n * A broken image is the common case, not the edge one — an avatar URL outlives the file it\n * points at. Falling back on error means the initials appear instead of a torn-page glyph.\n */\n const [failed, setFailed] = useState(false);\n const showImage = Boolean(src) && !failed;\n const initials = initialsOf(name);\n const ground = tint === \"auto\" ? tintOf(name) : tint;\n\n return (\n <span\n {...rest}\n className={`avatar ${className ?? \"\"}`.trim()}\n data-size={size}\n data-shape={shape}\n data-status={status}\n data-tint={ground}\n aria-hidden={decorative || undefined}\n >\n {showImage ? (\n <img\n className=\"avatar__image\"\n src={src}\n alt={decorative ? \"\" : name}\n onError={() => setFailed(true)}\n />\n ) : fallbackIcon ? (\n <Icon\n icon={fallbackIcon}\n size={size === \"xs\" || size === \"sm\" ? \"xs\" : \"sm\"}\n label={decorative ? undefined : name}\n />\n ) : (\n /* The initials are decorative: the name is already on the element that names this\n * avatar, and reading \"AS\" aloud tells a screen-reader user nothing. */\n <span className=\"avatar__initials\" aria-hidden=\"true\">{initials}</span>\n )}\n {status ? <span className=\"avatar__status\" data-status={status} aria-hidden=\"true\" /> : null}\n </span>\n );\n}\n","import { forwardRef, useRef, type ChangeEvent, type FocusEvent, type InputHTMLAttributes, type KeyboardEvent, type ReactNode, type Ref } from \"react\";\nimport type { LucideIcon } from \"lucide-react\";\nimport { Icon } from \"../Icon\";\nimport { useComposedRef } from \"../Glass/refraction\";\nimport \"./Input.css\";\n\nexport type InputSize = \"sm\" | \"md\" | \"lg\";\n\nexport type InputProps = {\n value?: string;\n defaultValue?: string;\n onChange?: (event: ChangeEvent<HTMLInputElement>) => void;\n onKeyDown?: (event: KeyboardEvent<HTMLInputElement>) => void;\n onFocus?: (event: FocusEvent<HTMLInputElement>) => void;\n onBlur?: (event: FocusEvent<HTMLInputElement>) => void;\n /**\n * Reaches the control, not the wrapper.\n *\n * Which is the only useful answer: the wrapper cannot be focused, cannot be read for a\n * value and is not what a form knows about. `SearchInput` uses it to put the reader back\n * in the field after its clear button has removed itself from under them.\n */\n ref?: Ref<HTMLInputElement>;\n type?: InputHTMLAttributes<HTMLInputElement>[\"type\"];\n placeholder?: string;\n size?: InputSize;\n /**\n * The value is not acceptable.\n *\n * Draws the border and sets `aria-invalid`, and does no more than that on purpose: the\n * reason belongs in a message the field owns, which is `Field`'s job. A control that says\n * only \"wrong\" in red is a control that says nothing to a reader who cannot see red.\n */\n invalid?: boolean;\n disabled?: boolean;\n readOnly?: boolean;\n required?: boolean;\n iconStart?: LucideIcon;\n iconEnd?: LucideIcon;\n /**\n * Something that can be pressed, inside the box.\n *\n * Asked for by the derived layer and by nothing else: `SearchInput` needs a clear button\n * inside the field, `PasswordInput` a reveal toggle, `NumberInput` a pair of steppers.\n * All three are *inside* the border rather than beside it, and a component that built its\n * own field to get them would be a second field with a second focus ring, a second set of\n * paddings and a second set of bugs.\n *\n * `iconStart`/`iconEnd` stay separate because an icon is not a control: it takes the muted\n * ink, has no hit area of its own and is never in the tab order.\n */\n slotStart?: ReactNode;\n slotEnd?: ReactNode;\n name?: string;\n id?: string;\n autoComplete?: string;\n /**\n * What the software keyboard and the corrector are allowed to do to what is typed.\n *\n * Asked for by `CouponField`. A coupon code is printed in capitals and typed on whatever\n * the keyboard happened to be in, and on a phone iOS will capitalise the first letter,\n * autocorrect the rest into a word, and underline it in red. Three attributes, and without\n * them the field is one a reader has to fight.\n */\n autoCapitalize?: string;\n autoCorrect?: string;\n spellCheck?: boolean;\n inputMode?: InputHTMLAttributes<HTMLInputElement>[\"inputMode\"];\n /**\n * The control's role, for the rare case where the element is not what it represents.\n *\n * `NumberInput` is the reason: it is a `type=\"text\"` that stands for a spin button, and\n * without this it would have to build its own field to say so.\n */\n role?: string;\n className?: string;\n [key: `data-${string}`]: unknown;\n [key: `aria-${string}`]: unknown;\n};\n\n/**\n * A single line of text.\n *\n * Always a wrapper around the control, whether or not there are icons, so that the box a\n * reader sees and the box the browser focuses are the same element in every case. A version\n * that only wrapped when an icon was present would have two focus rings, two paddings and\n * two sets of bugs.\n */\nexport const Input = forwardRef<HTMLInputElement, InputProps>(function Input({\n size = \"md\",\n invalid,\n disabled,\n readOnly,\n iconStart,\n iconEnd,\n slotStart,\n slotEnd,\n className,\n ...rest\n}: InputProps, ref) {\n const glyph = size === \"lg\" ? \"md\" : \"sm\";\n const control = useRef<HTMLInputElement>(null);\n const hold = useComposedRef(control, ref);\n\n /*\n * No lens here, and the comment this replaces claimed one.\n *\n * A field is not a floating surface. It sits ON one — inside a `Card`, a `Sheet`, a\n * `Glass` pane — and what those set for the controls riding on them is `--fill-solid`\n * and `--fill-backdrop`, which is how `Button` thins with the panel under it. A field\n * that bent its own backdrop would be glass on glass, blurring a surface that is\n * already blurred.\n *\n * It did call `useRefraction`, and drew a map per field that no rule in this component\n * ever read. The contract guard that should have caught a custom property nothing reads\n * could not see the conditional the value was written through; that hole is closed now.\n */\n\n return (\n <span\n className={`input ${className ?? \"\"}`.trim()}\n data-size={size}\n data-invalid={invalid ? \"\" : undefined}\n data-disabled={disabled ? \"\" : undefined}\n data-readonly={readOnly ? \"\" : undefined}\n onClick={event => {\n if (!(event.target as HTMLElement).closest(\".input__slot\")) control.current?.focus();\n }}\n >\n {iconStart ? <Icon icon={iconStart} size={glyph} className=\"input__glyph\" /> : null}\n {slotStart ? <span className=\"input__slot\">{slotStart}</span> : null}\n <input\n /*\n * Before the spread, so a caller's own `aria-invalid` wins.\n *\n * Written after it, this line replaced whatever the caller passed with `undefined`\n * — and `CouponField`, which marks its field from its own error state, silently had\n * no `aria-invalid` at all while its `aria-describedby` pointed at the message. It is\n * the rule `Stack`, `Select` and `Slider` already state: the component's own\n * attributes go before the spread, because a caller who names one has to win.\n */\n aria-invalid={invalid || undefined}\n {...rest}\n ref={hold}\n className=\"input__control\"\n disabled={disabled}\n readOnly={readOnly}\n />\n {iconEnd ? <Icon icon={iconEnd} size={glyph} className=\"input__glyph\" /> : null}\n {slotEnd ? <span className=\"input__slot\">{slotEnd}</span> : null}\n </span>\n );\n});\n"],"mappings":";;;;AAqDA,SAAgB,EAAW,GAAsB;CAC/C,IA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