@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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Waveform-EahaE6uD.js","names":[],"sources":["../../src/components/common/Badge/Badge.tsx","../../src/components/common/Progress/Progress.tsx","../../src/components/common/Radio/Radio.tsx","../../src/components/common/Select/Select.tsx","../../src/components/common/Textarea/Textarea.tsx","../../src/components/common/Waveform/Waveform.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport type { LucideIcon } from \"lucide-react\";\nimport { Icon } from \"../Icon\";\nimport \"./Badge.css\";\n\nexport type BadgeVariant = \"solid\" | \"soft\" | \"outline\";\nexport type BadgeTone = \"neutral\" | \"accent\" | \"success\" | \"warning\" | \"danger\";\nexport type BadgeSize = \"sm\" | \"md\";\nexport type BadgeShape = \"rounded\" | \"pill\";\n\nexport type BadgeProps = {\n children: ReactNode;\n variant?: BadgeVariant;\n tone?: BadgeTone;\n size?: BadgeSize;\n /**\n * 기본은 pill입니다.\n *\n * 배지는 글자 한둘짜리 작은 상자라 모서리 4px이 거의 안 보입니다. 그래서 그 자리에 무엇이\n * 있는지가 「글자 옆의 색깔」로만 읽혔습니다. 알약 모양은 상자의 경계를 스스로 말합니다.\n * 참조 구현(Mantine)도 같은 이유로 pill입니다.\n *\n * `rounded`(4px)는 배지가 표의 칸이나 카드 모서리에 붙어 그 각을 따라야 할 때 씁니다.\n */\n shape?: BadgeShape;\n /** A dot before the label, for a state that a reader scans for rather than reads. */\n dot?: boolean;\n icon?: LucideIcon;\n className?: string;\n [key: `data-${string}`]: unknown;\n};\n\n/**\n * A small piece of state, said in a word.\n *\n * The tone is never the only carrier: the label says the state, and the colour agrees with\n * it. A badge that means \"failed\" because it is red and says nothing is a badge that means\n * nothing to a reader who cannot separate red from green — about one man in twelve.\n */\nexport function Badge({\n children,\n variant = \"soft\",\n tone = \"neutral\",\n size = \"md\",\n shape = \"pill\",\n dot,\n icon,\n className,\n ...rest\n}: BadgeProps) {\n return (\n <span\n {...rest}\n className={`badge ${className ?? \"\"}`.trim()}\n data-variant={variant}\n data-tone={tone}\n data-size={size}\n data-shape={shape}\n >\n {dot ? <span className=\"badge__dot\" aria-hidden=\"true\" /> : null}\n {icon ? <Icon icon={icon} size={size === \"sm\" ? \"xs\" : \"sm\"} /> : null}\n <span className=\"badge__label\">{children}</span>\n </span>\n );\n}\n","import \"./Progress.css\";\n\nexport type ProgressSize = \"sm\" | \"md\";\nexport type ProgressTone = \"accent\" | \"success\" | \"warning\" | \"danger\";\n\nexport type ProgressProps = {\n /**\n * How far along, 0 to `max`. Omitted means the work has no measurable end, which is a\n * different statement and gets a different bar.\n */\n value?: number;\n max?: number;\n size?: ProgressSize;\n tone?: ProgressTone;\n /** What is progressing. A bar with no name is a bar nobody can ask about. */\n label: string;\n className?: string;\n [key: `data-${string}`]: unknown;\n};\n\n/**\n * How far along something is, or that it is going at all.\n *\n * A native `<progress>`, and that is the whole design. The fill's width is data — the one\n * value a component genuinely cannot put in a stylesheet — and every way of expressing it in\n * CSS goes through a `style` attribute, which outranks the adopter, the theme and the\n * stylesheet. `<progress value=\"40\">` puts it in an attribute where it belongs, and brings\n * `role=\"progressbar\"` and the value announcement with it.\n *\n * Omitting `value` makes it indeterminate, in the element's own vocabulary, and `:indeterminate`\n * is what the stylesheet keys the travelling stripe off.\n */\nexport function Progress({\n value,\n max = 100,\n size = \"md\",\n tone = \"accent\",\n label,\n className,\n ...rest\n}: ProgressProps) {\n return (\n <progress\n {...rest}\n className={`progress ${className ?? \"\"}`.trim()}\n data-size={size}\n data-tone={tone}\n value={value}\n max={max}\n aria-label={label}\n />\n );\n}\n","import type { ChangeEvent, ReactNode } from \"react\";\nimport \"./Radio.css\";\n\nexport type RadioSize = \"sm\" | \"md\";\n\nexport type RadioProps = {\n children?: ReactNode;\n /**\n * The group this choice belongs to.\n *\n * Required, and required for a reason: radios with no shared name are not a group. They\n * look like one, they behave like a row of checkboxes, and a screen reader announces each\n * as \"1 of 1\". The browser builds the group from the name.\n */\n name: string;\n value: string;\n checked?: boolean;\n defaultChecked?: boolean;\n onChange?: (event: ChangeEvent<HTMLInputElement>) => void;\n size?: RadioSize;\n disabled?: boolean;\n invalid?: boolean;\n id?: string;\n /**\n * Where Tab enters the group, for the group that has to overrule the browser.\n *\n * The browser gives a radio group one tab stop and puts it on the checked radio. The\n * earlier note here said that a *disabled* checked radio leaves the group with no stop at\n * all — measured, and Chromium does not do that: it moves the stop to the first enabled\n * radio on its own, so the group is still reachable. Both of this repository's test\n * projects are Chromium, and nothing in it sets this prop.\n *\n * It stays as the escape hatch for an adopter on an engine that does strand the group.\n * Nothing else has any business setting it.\n */\n tabIndex?: number;\n className?: string;\n [key: `data-${string}`]: unknown;\n [key: `aria-${string}`]: unknown;\n};\n\n/**\n * One of several, and only one.\n *\n * A real `<input type=\"radio\">`, so arrow keys move within the group and skip past it on Tab\n * — which is the behaviour a reader expects and the behaviour that is hardest to rebuild.\n */\nexport function Radio({\n children,\n size = \"md\",\n disabled,\n invalid,\n className,\n ...rest\n}: RadioProps) {\n return (\n <label\n className={`radio ${className ?? \"\"}`.trim()}\n data-size={size}\n data-disabled={disabled ? \"\" : undefined}\n data-invalid={invalid ? \"\" : undefined}\n >\n <input\n {...rest}\n type=\"radio\"\n className=\"radio__input\"\n disabled={disabled}\n aria-invalid={invalid || undefined}\n />\n <span className=\"radio__dot\" aria-hidden=\"true\" />\n {children ? <span className=\"radio__label\">{children}</span> : null}\n </label>\n );\n}\n","import { Children, isValidElement, useEffect, useId, useMemo, useRef, useState } from \"react\";\nimport type { ChangeEvent, KeyboardEvent, ReactElement, ReactNode } from \"react\";\nimport * as RadixPopover from \"@radix-ui/react-popover\";\nimport { Check, ChevronDown } from \"lucide-react\";\nimport { Icon } from \"../Icon\";\nimport { useListbox } from \"./listbox\";\nimport \"./Select.css\";\n\nexport type SelectSize = \"sm\" | \"md\" | \"lg\";\n\nexport type SelectProps = {\n /** `<option>` elements, the same as a native select takes. See the note on why. */\n children: ReactNode;\n value?: string;\n defaultValue?: string;\n onChange?: (event: ChangeEvent<HTMLSelectElement>) => void;\n size?: SelectSize;\n invalid?: boolean;\n disabled?: boolean;\n required?: boolean;\n /**\n * The token a browser fills this from — `country`, `cc-exp-month`, `address-level1`.\n *\n * Asked for by `AddressForm`. A select is as fillable as a text field and is left out of\n * autofill more often than any other control, which is how a form that fills five fields in\n * one press leaves the sixth blank.\n */\n autoComplete?: string;\n name?: string;\n id?: string;\n className?: string;\n [key: `data-${string}`]: unknown;\n [key: `aria-${string}`]: unknown;\n};\n\ntype Choice = { value: string; label: string; disabled?: boolean };\n\n/** The `<option>` children, read as data. Anything that is not an option is skipped. */\nfunction choices(children: ReactNode): Choice[] {\n return Children.toArray(children)\n .filter((child): child is ReactElement<{ value?: string; disabled?: boolean; children?: ReactNode }> =>\n isValidElement(child) && child.type === \"option\")\n .map((option) => ({\n value: String(option.props.value ?? Children.toArray(option.props.children).join(\"\")),\n label: Children.toArray(option.props.children).join(\"\"),\n disabled: option.props.disabled,\n }));\n}\n\n/**\n * A closed list, drawn here rather than by the operating system.\n *\n * **It used to be a bare native `<select>`, and the list it opened was the platform's.** That\n * is defensible on its own — the wheel on iOS is genuinely good, and the system's keyboard\n * search comes free. It is not defensible next to `Combobox`, which draws its own list from\n * the same tokens: the same product then had two dropdowns that looked nothing alike, and one\n * of them looked different again on every operating system it ran on. Consistency is the\n * thing a design system is for.\n *\n * **The native element is still here, and it is still the form's field.** It is hidden and\n * out of the tab order, but it holds the value, carries `name`, `required` and\n * `autoComplete`, submits with the form and takes the browser's autofill. Choosing an option\n * writes to it through the prototype's own setter and dispatches a real `change`, so `onChange`\n * fires exactly as it did before — which is why every call site and every spec kept working\n * when this was rewritten.\n *\n * **What replaced it is the `Combobox` pattern with the typing taken out.** A button that\n * reports `combobox`, a listbox in a popover, `aria-activedescendant` walking the options, and\n * type-ahead — because losing the system's keyboard search is the one real cost of drawing\n * the list, and a closed list of forty is unusable without it.\n */\nexport function Select({\n children,\n value,\n defaultValue,\n onChange,\n size = \"md\",\n invalid,\n disabled,\n required,\n autoComplete,\n name,\n id,\n className,\n ...rest\n}: SelectProps) {\n const options = useMemo(() => choices(children), [children]);\n const field = useRef<HTMLSelectElement>(null);\n const listId = useId();\n const optionId = (index: number) => `${listId}-${index}`;\n\n /*\n * The native element is the value's home whether or not the caller controls it, so this\n * mirror exists only so the trigger can render a label. It follows the element rather than\n * leading it — every path that changes the value goes through the element first.\n */\n const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue ?? options[0]?.value ?? \"\");\n const shown = value ?? uncontrolledValue;\n useEffect(() => {\n if (value === undefined && field.current) setUncontrolledValue(field.current.value);\n }, [value, options]);\n useEffect(() => {\n const form = field.current?.form;\n if (!form || value !== undefined) return;\n let pending: ReturnType<typeof setTimeout> | undefined;\n const reset = () => {\n clearTimeout(pending);\n // Read after the native reset default action has completed.\n pending = setTimeout(() => {\n if (field.current) setUncontrolledValue(field.current.value);\n }, 0);\n };\n form.addEventListener(\"reset\", reset);\n return () => { form.removeEventListener(\"reset\", reset); clearTimeout(pending); };\n }, [value]);\n\n const [open, setOpen] = useState(false);\n const search = useRef({ text: \"\", at: 0 });\n\n /* No wrap: this stands in for a native select, and a native select does not wrap. */\n const rows = useListbox({\n rows: options,\n locked: (option) => Boolean(option.disabled),\n id: (_option, index) => optionId(index),\n loop: false,\n });\n const { active, setActive } = rows;\n\n const current = options.findIndex((one) => one.value === shown);\n const label = current >= 0 ? options[current].label : \"\";\n\n /*\n * Written through the prototype's setter, then a real `change` event.\n *\n * React installs its own `value` setter on the instance, and assigning to it directly\n * updates the DOM without React noticing — the next render puts the old value back. Going\n * through the prototype and dispatching is the path React's own change handling listens on,\n * so a controlled caller gets its `onChange` and an uncontrolled one keeps the element's\n * state. It is the same trick a test harness uses to type into a controlled input.\n */\n const commit = (next: string) => {\n const node = field.current;\n if (!node || next === shown) return close();\n const setter = Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype, \"value\")?.set;\n setter?.call(node, next);\n node.dispatchEvent(new Event(\"change\", { bubbles: true }));\n if (value === undefined) setUncontrolledValue(next);\n close();\n };\n\n const close = () => {\n setOpen(false);\n search.current = { text: \"\", at: 0 };\n };\n\n /** The first choosable option after `from` whose label starts with `text`, wrapping once. */\n const seek = (text: string, from: number) => {\n for (let step = 1; step <= options.length; step += 1) {\n const index = (from + step) % options.length;\n const option = options[index];\n if (!option.disabled && option.label.toLowerCase().startsWith(text)) return index;\n }\n return -1;\n };\n\n const onKeyDown = (event: KeyboardEvent<HTMLButtonElement>) => {\n if (disabled) return;\n const usable = options.filter((one) => !one.disabled);\n if (usable.length === 0) return;\n\n /*\n * Open, the keys walk the list. Closed, Home and End take a value outright, which is what\n * a native select does and what the form's field still is.\n *\n * The walk itself is `useListbox`. It skips what the pointer cannot reach: a click handler\n * that refuses a disabled option and an arrow key that lands on one anyway is a control\n * saying no to the mouse and yes to the keyboard.\n */\n /** Closed only: the first choosable option from `to`, travelling in `delta`, taken. */\n const jump = (to: number, delta: number) => {\n for (let index = to; index >= 0 && index < options.length; index += delta) {\n if (!options[index].disabled) return commit(options[index].value);\n }\n };\n\n switch (event.key) {\n case \"ArrowDown\":\n event.preventDefault();\n if (!open) return setOpen(true);\n return rows.move(1);\n case \"ArrowUp\":\n event.preventDefault();\n if (!open) return setOpen(true);\n return rows.move(-1);\n case \"Home\":\n event.preventDefault();\n return open ? rows.first() : jump(0, 1);\n case \"End\":\n event.preventDefault();\n return open ? rows.last() : jump(options.length - 1, -1);\n case \"Enter\":\n case \" \": {\n event.preventDefault();\n if (!open) return setOpen(true);\n const option = rows.activeRow;\n if (!option || option.disabled) return;\n return commit(option.value);\n }\n case \"Escape\":\n if (open) {\n event.preventDefault();\n close();\n }\n return;\n case \"Tab\":\n if (open) close();\n return;\n default:\n break;\n }\n\n /*\n * Type-ahead, which is the one thing the platform's list gave away for free. A closed\n * list of forty countries that can only be walked one arrow at a time is a list nobody\n * walks. Repeating the same letter steps through the options that start with it; anything\n * else within a second extends the search.\n */\n if (event.key.length !== 1 || event.metaKey || event.ctrlKey || event.altKey) return;\n const now = Date.now();\n const stale = now - search.current.at > 1000;\n const typed = event.key.toLowerCase();\n const text = stale || search.current.text === typed ? typed : search.current.text + typed;\n search.current = { text, at: now };\n const from = search.current.text === typed && !stale ? (open ? active : current) : (open ? active : current) - 1;\n const found = seek(text, from);\n if (found < 0) return;\n event.preventDefault();\n if (open) setActive(found);\n else commit(options[found].value);\n };\n\n return (\n <RadixPopover.Root\n open={open && !disabled}\n onOpenChange={(next) => (next ? setActive(Math.max(0, current)) : close(), setOpen(next))}\n >\n <span\n className={`select ${className ?? \"\"}`.trim()}\n data-size={size}\n data-invalid={invalid ? \"\" : undefined}\n data-disabled={disabled ? \"\" : undefined}\n data-open={open ? \"\" : undefined}\n >\n {/*\n * The form's field. Hidden from sight and from the tab order, present for everything\n * else: the submitted value, `required`, `autoComplete`, and the browser's autofill.\n */}\n <select\n ref={field}\n className=\"select__field\"\n name={name}\n required={required}\n autoComplete={autoComplete}\n disabled={disabled}\n value={value}\n defaultValue={value === undefined ? defaultValue : undefined}\n onChange={(event) => {\n if (value === undefined) setUncontrolledValue(event.target.value);\n onChange?.(event);\n }}\n tabIndex={-1}\n aria-hidden=\"true\"\n >\n {children}\n </select>\n\n <RadixPopover.Anchor asChild>\n <button\n /* Before the spread, not after: a caller that names this part — `AddressForm`\n * labels its country and region selects — has to win, and writing it afterwards\n * silently replaced their name with this one. */\n data-part=\"control\"\n {...rest}\n type=\"button\"\n id={id}\n className=\"select__control\"\n role=\"combobox\"\n aria-controls={listId}\n aria-expanded={open}\n aria-activedescendant={open ? rows.activeId : undefined}\n aria-invalid={invalid || undefined}\n aria-required={required || undefined}\n /* `aria-disabled`, not `disabled`: the rule `Button` set. A control that leaves\n * the tab order takes the reader standing on it with it. */\n aria-disabled={disabled || undefined}\n onClick={() => !disabled && setOpen((was) => !was)}\n onKeyDown={onKeyDown}\n >\n <span className=\"select__value\">{label}</span>\n <Icon\n icon={ChevronDown}\n size={size === \"lg\" ? \"md\" : \"sm\"}\n className=\"select__chevron\"\n aria-hidden=\"true\"\n />\n </button>\n </RadixPopover.Anchor>\n\n <RadixPopover.Portal>\n <RadixPopover.Content\n className=\"select__panel\"\n data-size={size}\n side=\"bottom\"\n align=\"start\"\n sideOffset={4}\n collisionPadding={12}\n /* The focus stays on the trigger, because the trigger is what type-ahead is\n * listening on. `aria-activedescendant` is what walks the list. */\n onOpenAutoFocus={(event) => event.preventDefault()}\n onCloseAutoFocus={(event) => event.preventDefault()}\n >\n <ul className=\"select__list\" id={listId} role=\"listbox\" aria-label={label}>\n {options.map((option, index) => (\n <li\n key={option.value}\n id={optionId(index)}\n className=\"select__option\"\n role=\"option\"\n aria-selected={option.value === shown}\n aria-disabled={option.disabled || undefined}\n data-active={index === active ? \"\" : undefined}\n data-part={`option-${option.value}`}\n onMouseDown={(event) => {\n event.preventDefault();\n if (!option.disabled) commit(option.value);\n }}\n onMouseEnter={() => setActive(index)}\n >\n <span className=\"select__mark\" aria-hidden=\"true\">\n {option.value === shown ? <Icon icon={Check} size=\"xs\" /> : null}\n </span>\n <span className=\"select__option-label\">{option.label}</span>\n </li>\n ))}\n </ul>\n </RadixPopover.Content>\n </RadixPopover.Portal>\n </span>\n </RadixPopover.Root>\n );\n}\n","import type { ChangeEvent } from \"react\";\nimport \"./Textarea.css\";\n\nexport type TextareaSize = \"sm\" | \"md\" | \"lg\";\nexport type TextareaResize = \"none\" | \"vertical\";\n\nexport type TextareaProps = {\n value?: string;\n defaultValue?: string;\n onChange?: (event: ChangeEvent<HTMLTextAreaElement>) => void;\n placeholder?: string;\n rows?: number;\n size?: TextareaSize;\n /**\n * `vertical` by default, and never `horizontal` or `both`.\n *\n * A field that can be dragged wider than its column pushes the layout around it, and the\n * reader who did it cannot always see what they broke. Taller is safe; wider is not.\n */\n resize?: TextareaResize;\n invalid?: boolean;\n disabled?: boolean;\n readOnly?: boolean;\n required?: boolean;\n name?: string;\n id?: string;\n className?: string;\n [key: `data-${string}`]: unknown;\n [key: `aria-${string}`]: unknown;\n};\n\nexport function Textarea({\n size = \"md\",\n resize = \"vertical\",\n invalid,\n disabled,\n readOnly,\n rows = 4,\n className,\n ...rest\n}: TextareaProps) {\n return (\n <span\n className={`textarea ${className ?? \"\"}`.trim()}\n data-size={size}\n data-resize={resize}\n data-invalid={invalid ? \"\" : undefined}\n data-disabled={disabled ? \"\" : undefined}\n data-readonly={readOnly ? \"\" : undefined}\n >\n <textarea\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 className=\"textarea__control\"\n rows={rows}\n disabled={disabled}\n readOnly={readOnly}\n />\n </span>\n );\n}\n","import type { CSSProperties } from \"react\";\nimport { VisuallyHidden } from \"../VisuallyHidden\";\nimport \"./Waveform.css\";\n\nexport type WaveformState = \"idle\" | \"listening\" | \"thinking\" | \"speaking\";\n/**\n * The geometry, and only the geometry.\n *\n * `docs/음성-특화-컴포넌트.md` names five — bar, grid, radial, wave, aura — and the previous\n * line of work built all five as one component sharing one array of values, with the shape\n * differing in CSS alone. That is right, and it is why this is a `variant` rather than five\n * exports: five files whose helpers are byte-identical copies is a permutation, not a library.\n *\n * `aura` is the one not here. A glow that swells says the level and nothing else — no\n * sequence, no detail, no count — and the plan's rule for this kind of thing is that an effect\n * carries a fact or it does not exist. Behind an orb it is the host's background, not a meter.\n */\nexport type WaveformVariant = \"bar\" | \"line\" | \"grid\" | \"radial\";\nexport type WaveformSize = \"sm\" | \"md\" | \"lg\";\n\nexport type WaveformProps = {\n state: WaveformState;\n /**\n * Amplitudes, 0 to 1, oldest first.\n *\n * Read in `listening` and `speaking` and ignored everywhere else — see the note. Anything\n * outside 0..1 is clamped rather than trusted: an analyser that returns 1.4 for one frame\n * would otherwise draw a bar out of the box.\n */\n levels?: number[];\n /** What this is a picture of. \"마이크 입력\", \"에이전트 음성\". */\n label: string;\n /**\n * How long the current state has lasted. \"0:04\", \"1분 12초\".\n *\n * The second of `thinking`'s three channels, and the one that survives a screenshot. Two\n * seconds and sixty seconds look identical in any loop, so a loop on its own postpones the\n * moment of doubt rather than removing it.\n */\n elapsed?: string;\n variant?: WaveformVariant;\n size?: WaveformSize;\n className?: string;\n [key: `data-${string}`]: unknown;\n};\n\n/** How many bars are drawn when there is nothing to draw from. */\nconst RESTING = 5;\nconst SAID: Record<WaveformState, string> = {\n idle: \"대기 중\",\n listening: \"듣는 중\",\n thinking: \"생각하는 중\",\n speaking: \"말하는 중\",\n};\n\n/**\n * What the microphone is hearing, or what the agent is doing instead.\n *\n * **Amplitude is read in two states and invented in none.** `listening` and `speaking` have a\n * signal; `idle` and `thinking` do not, and a component that animated them from a random walk\n * would be drawing sound that is not there — which is the one thing a level meter must never\n * do. The two silent states have shapes of their own instead.\n *\n * **`thinking` carries three channels and only one of them moves.** The sweep is the\n * animation; the elapsed time and the state word are text. That matters because the moment\n * this component exists for — the silence while a model reasons — is exactly when a reader\n * starts wondering whether the thing has crashed, and the two of the three channels that\n * survive a screenshot, `prefers-reduced-motion`, and a screen reader are the ones that answer\n * them.\n *\n * **It does not own the stream.** No `getUserMedia`, no `AudioContext`, no analyser. Levels\n * arrive as numbers and the state arrives as a word — inferring one from the other is how a\n * meter starts calling a cough \"speaking\".\n *\n * **The shape is drawn in element attributes.** `Progress` settled this for one value: the\n * geometry that comes from data goes where a stylesheet cannot be outranked by it. Here it is\n * `height`, `y` and `points` on SVG children, so the size stays CSS's and only the shape is\n * the data's.\n */\nexport function Waveform({\n state,\n levels,\n label,\n elapsed,\n variant = \"bar\",\n size = \"md\",\n className,\n ...rest\n}: WaveformProps) {\n /*\n * The resting shape, and it is not silence drawn as zero.\n *\n * A meter flat against the floor reads as \"broken\" rather than as \"nothing to hear\", so the\n * two states with no signal draw a short, even row — the same thing a hardware meter does\n * when it is on and idle.\n */\n const heard = state === \"listening\" || state === \"speaking\";\n const values = heard && levels?.length\n ? levels.map((level) => Math.min(1, Math.max(0, level)))\n : Array.from({ length: RESTING }, () => 0.25);\n\n const step = 100 / values.length;\n\n return (\n <div\n {...rest}\n className={`waveform ${className ?? \"\"}`.trim()}\n data-state={state}\n data-variant={variant}\n data-size={size}\n >\n {/*\n * `aria-hidden` on the drawing and the words beside it, rather than a label on the SVG.\n * A live region that re-read a moving meter would say nothing a reader can use and\n * would never stop saying it.\n */}\n {variant === \"line\" ? (\n /*\n * A line is a continuous trace and SVG is the only thing that draws one, so here the\n * geometry is an element attribute — the answer `Progress` settled for a value that\n * comes from data. Stretching the box stretches the trace, which is what a trace does.\n */\n <svg\n className=\"waveform__draw\"\n viewBox=\"0 0 100 100\"\n preserveAspectRatio=\"none\"\n aria-hidden=\"true\"\n data-part=\"draw\"\n >\n {/*\n * The line crosses the middle between samples, which is what a waveform is: the sign\n * alternates and the amplitude is the distance from the centre. Drawing only the\n * upper half would be an envelope, and an envelope of a voice looks like a mountain\n * range rather than a sound.\n */}\n <polyline\n className=\"waveform__line\"\n points={values\n .map((level, index) => {\n const away = level * 45 * (index % 2 === 0 ? -1 : 1);\n return `${index * step + step / 2},${50 + away}`;\n })\n .join(\" \")}\n data-part=\"line\"\n />\n </svg>\n ) : (\n /*\n * Bars are boxes, and boxes are CSS's.\n *\n * The first version drew them in the same stretched `viewBox` as the line, and that is\n * wrong for a bar in a way a screenshot at one width hides: `preserveAspectRatio: none`\n * scales x and y by different amounts, so a bar's *thickness* and the radius of its\n * ends change with how wide the box happens to be. A meter's bars are the same three\n * pixels across in a phone composer and in a full-screen call; only how many fit\n * changes. Two millimetres of rounded end is not a thing that should depend on a\n * container query nobody wrote.\n *\n * So the height is the datum and everything else is a token. One custom property, the\n * same name on every bar, declared once in this component's stylesheet — which is the\n * third place a value may go and what the contract guard checks for.\n */\n <div\n className=\"waveform__draw\"\n aria-hidden=\"true\"\n data-part=\"draw\"\n /*\n * `--waveform-count` is only for `radial`, which needs to know how many bars there\n * are to space them around a circle. The other shapes lay themselves out and never\n * read it.\n */\n style={{ \"--waveform-count\": values.length } as CSSProperties}\n >\n {values.map((level, index) => (\n <span\n className=\"waveform__bar\"\n key={index}\n style={{ \"--waveform-level\": level, \"--waveform-index\": index } as CSSProperties}\n data-part=\"bar\"\n />\n ))}\n </div>\n )}\n\n {/*\n * The state in words, and the elapsed time next to it. Two of `thinking`'s three\n * channels, and the two that are still there when nothing is moving.\n */}\n <p className=\"waveform__said\" data-part=\"said\">\n <span className=\"waveform__word\">{SAID[state]}</span>\n {elapsed ? <span className=\"waveform__elapsed\">{elapsed}</span> : null}\n <VisuallyHidden>{` — ${label}`}</VisuallyHidden>\n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