@lucian-seo/lucian-ui 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/Input-DzJm1Kv4.js +93 -0
- package/dist/lib/Input-DzJm1Kv4.js.map +1 -0
- package/dist/lib/{Switch-CMllJkGp.js → Switch-DyKAqvde.js} +173 -150
- package/dist/lib/Switch-DyKAqvde.js.map +1 -0
- package/dist/lib/{TagInput-BxbmmLeL.js → TagInput-CeA0n7ax.js} +2 -2
- package/dist/lib/{TagInput-BxbmmLeL.js.map → TagInput-CeA0n7ax.js.map} +1 -1
- package/dist/lib/{ToggleButton-DVmHmemS.js → ToggleButton-r73bokux.js} +4 -4
- package/dist/lib/ToggleButton-r73bokux.js.map +1 -0
- package/dist/lib/{Toolbar-C0Dn66Ry.js → Toolbar-DpCq_HXG.js} +440 -318
- package/dist/lib/Toolbar-DpCq_HXG.js.map +1 -0
- package/dist/lib/{Tooltip-BJSUlXS2.js → Tooltip-BW1-aVDg.js} +2 -2
- package/dist/lib/{Tooltip-BJSUlXS2.js.map → Tooltip-BW1-aVDg.js.map} +1 -1
- package/dist/lib/{VoiceControlBar-CpEz6uxS.js → VoiceControlBar-CZL-k7ym.js} +755 -720
- package/dist/lib/VoiceControlBar-CZL-k7ym.js.map +1 -0
- package/dist/lib/{Waveform-C6OQRKbh.js → Waveform-EahaE6uD.js} +2 -2
- package/dist/lib/{Waveform-C6OQRKbh.js.map → Waveform-EahaE6uD.js.map} +1 -1
- package/dist/lib/components/common/index.js +4 -4
- package/dist/lib/components/composed/Combobox/Combobox.d.ts +10 -8
- package/dist/lib/components/composed/DatePicker/dates.d.ts +2 -0
- package/dist/lib/components/composed/Pagination/Pagination.d.ts +3 -1
- package/dist/lib/components/composed/Tabs/Tabs.d.ts +3 -2
- package/dist/lib/components/composed/Tabs/index.d.ts +1 -1
- package/dist/lib/components/composed/index.js +1 -1
- package/dist/lib/components/derived/index.js +2 -2
- package/dist/lib/components/extended/DataGrid/DataGrid.d.ts +11 -1
- package/dist/lib/components/extended/DataGrid/index.d.ts +1 -1
- package/dist/lib/components/extended/index.js +1 -1
- package/dist/lib/index.js +8 -8
- package/dist/lib/styles.css +1 -1
- package/dist/lib/tokens.css +32 -0
- package/package.json +1 -1
- package/dist/lib/Input-Bv7L1_wj.js +0 -90
- package/dist/lib/Input-Bv7L1_wj.js.map +0 -1
- package/dist/lib/Switch-CMllJkGp.js.map +0 -1
- package/dist/lib/ToggleButton-DVmHmemS.js.map +0 -1
- package/dist/lib/Toolbar-C0Dn66Ry.js.map +0 -1
- package/dist/lib/VoiceControlBar-CpEz6uxS.js.map +0 -1
|
@@ -40,7 +40,7 @@ function c({ children: i, indeterminate: s, size: c = "md", disabled: l, invalid
|
|
|
40
40
|
//#endregion
|
|
41
41
|
//#region src/components/common/Select/listbox.ts
|
|
42
42
|
function l({ rows: e, locked: t, id: n, loop: r = !0 }) {
|
|
43
|
-
let [a, o] = i(0), s = (e) => !!t?.(e), c = e.filter((e) => !s(e)), l = a >= 0 && a < e.length ? a : c.length > 0 ? e.indexOf(c[0]) : -1, u = l >= 0 ? e[l] : void 0, d = (t) => {
|
|
43
|
+
let [a, o] = i(0), s = (e) => !!t?.(e), c = e.filter((e) => !s(e)), l = a >= 0 && a < e.length && !s(e[a]) ? a : c.length > 0 ? e.indexOf(c[0]) : -1, u = l >= 0 ? e[l] : void 0, d = (t) => {
|
|
44
44
|
t < 0 || t >= e.length || o(t);
|
|
45
45
|
}, f = (t) => {
|
|
46
46
|
if (c.length === 0) return;
|
|
@@ -114,4 +114,4 @@ function d({ children: e, content: r, side: i = "top", delay: a = 300, open: o,
|
|
|
114
114
|
//#endregion
|
|
115
115
|
export { c as i, u as n, l as r, d as t };
|
|
116
116
|
|
|
117
|
-
//# sourceMappingURL=Tooltip-
|
|
117
|
+
//# sourceMappingURL=Tooltip-BW1-aVDg.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip-BJSUlXS2.js","names":[],"sources":["../../src/components/common/Checkbox/Checkbox.tsx","../../src/components/common/Select/listbox.ts","../../src/components/common/Skeleton/Skeleton.tsx","../../src/components/common/Tooltip/Tooltip.tsx"],"sourcesContent":["import { useCallback } from \"react\";\nimport type { ChangeEvent, ReactNode } from \"react\";\nimport { Check, Minus } from \"lucide-react\";\nimport { Icon } from \"../Icon\";\nimport \"./Checkbox.css\";\n\nexport type CheckboxSize = \"sm\" | \"md\";\n\nexport type CheckboxProps = {\n children?: ReactNode;\n checked?: boolean;\n defaultChecked?: boolean;\n /**\n * Some of what this box stands for is checked and some is not.\n *\n * A DOM property, not an attribute — there is no `indeterminate=\"\"` in HTML — so it is set\n * through a ref. Every implementation that forgets this ships a box that looks\n * indeterminate and reports itself as unchecked.\n */\n indeterminate?: boolean;\n onChange?: (event: ChangeEvent<HTMLInputElement>) => void;\n size?: CheckboxSize;\n disabled?: boolean;\n invalid?: boolean;\n name?: string;\n value?: string;\n id?: string;\n className?: string;\n [key: `data-${string}`]: unknown;\n [key: `aria-${string}`]: unknown;\n};\n\n/**\n * A real `<input type=\"checkbox\">`, drawn over.\n *\n * The input is present, focusable and in the form; what is hidden is only its appearance.\n * Rebuilding a checkbox out of a `<div role=\"checkbox\">` means rebuilding space-to-toggle,\n * form submission, `:checked`, autofill and the label association, and getting one of them\n * wrong is the usual outcome.\n */\nexport function Checkbox({\n children,\n indeterminate,\n size = \"md\",\n disabled,\n invalid,\n className,\n ...rest\n}: CheckboxProps) {\n const setIndeterminate = useCallback(\n (node: HTMLInputElement | null) => {\n if (node) node.indeterminate = Boolean(indeterminate);\n },\n [indeterminate],\n );\n\n return (\n <label\n className={`checkbox ${className ?? \"\"}`.trim()}\n data-size={size}\n data-disabled={disabled ? \"\" : undefined}\n data-invalid={invalid ? \"\" : undefined}\n >\n <input\n {...rest}\n ref={setIndeterminate}\n type=\"checkbox\"\n className=\"checkbox__input\"\n disabled={disabled}\n aria-invalid={invalid || undefined}\n />\n <span className=\"checkbox__box\" aria-hidden=\"true\">\n <Icon icon={indeterminate ? Minus : Check} size={size === \"sm\" ? \"xs\" : \"sm\"} />\n </span>\n {children ? <span className=\"checkbox__label\">{children}</span> : null}\n </label>\n );\n}\n","import { useState } from \"react\";\n\n/**\n * The list model, made available to any list rather than only to `Select`.\n *\n * Four components walk a list of rows with `aria-activedescendant`: `Select`, `MultiSelect`,\n * `Combobox` and `CommandPalette`. They had four copies of the same contract, and\n * `docs/COMPONENT-AUDIT.md` counted the drift: two wrote the walk as `move()`, one as\n * `step()`, one as a `switch` and the rest as `if` chains. The copies were not merely\n * different. They had stopped agreeing.\n *\n * `CommandPalette` did not skip locked rows at all. An arrow key landed on a disabled\n * command and Enter then refused it, which is a control saying no to the keyboard and yes\n * to the pointer. The other three each carry a comment explaining why that must not happen.\n *\n * `Select` gated `aria-activedescendant` on the SELECTED index while naming the ACTIVE one,\n * so a select whose value matched no option announced nothing as the arrows moved.\n *\n * Both were fixed by there being one model instead of four. That is what this is for: not\n * fewer lines, but one place where the contract can be read and therefore one place where it\n * can be wrong.\n *\n * It lives here, beside `Select`, for the reason `refraction.ts` lives beside `Glass`. A\n * `common/` folder holding only a hook would fail the contract's demo rule, `src/foundation`\n * is not something a component may import, and `Select` is the plainest list of the four.\n *\n * What it does NOT own: whether the list is open, what Enter does, and how a row is drawn.\n * Those are four different things in four components — Enter alone commits a value, toggles\n * one of several, fills a field, or runs a command that cannot be undone — and a hook that\n * took them would be the god-code this audit went looking for.\n */\n\nexport type ListboxOptions<Row> = {\n /** Every row the reader can see, locked ones included. Indices are into this. */\n rows: Row[];\n /** A row the pointer may not choose. The arrows must agree with the pointer about it. */\n locked?: (row: Row) => boolean;\n /** The DOM id of a row, for `aria-activedescendant`. Index-based or value-based, as suits. */\n id: (row: Row, index: number) => string;\n /**\n * Whether the ends join. A palette of verbs wraps: at the bottom the next thing the reader\n * wants is the top, not nothing happening. A `Select` standing in for a native one does\n * not, because the native one does not.\n */\n loop?: boolean;\n};\n\nexport type Listbox<Row> = {\n /** Index into `rows`, or -1 when there is nothing reachable to stand on. */\n active: number;\n activeRow: Row | undefined;\n /** For `aria-activedescendant`. Undefined when nothing is active, never a row that is gone. */\n activeId: string | undefined;\n /** Point at a row by index. Out-of-range and locked rows are refused rather than clamped. */\n setActive: (index: number) => void;\n /** One step in a direction, over reachable rows only. */\n move: (step: number) => void;\n first: () => void;\n last: () => void;\n /**\n * Arrow keys, Home and End. Returns whether it took the event.\n *\n * Enter, Escape, Tab and Backspace are not here. They mean different things in each of the\n * four, and the one that looks shared is the one that is not: Enter commits, toggles, fills\n * and runs.\n */\n took: (event: { key: string; preventDefault: () => void }) => boolean;\n};\n\nexport function useListbox<Row>({ rows, locked, id, loop = true }: ListboxOptions<Row>): Listbox<Row> {\n const [stored, setStored] = useState(0);\n\n const isLocked = (row: Row) => Boolean(locked?.(row));\n const reachable = rows.filter((row) => !isLocked(row));\n\n /*\n * Derived rather than corrected in an effect.\n *\n * Rows come and go while the reader types, and an index kept from the longer list points\n * past the end of the shorter one. An effect that repaired it would render once with\n * `aria-activedescendant` naming a row that is not in the document, which is the frame a\n * screen reader is reading.\n */\n const active = stored >= 0 && stored < rows.length ? stored : reachable.length > 0 ? rows.indexOf(reachable[0]) : -1;\n const activeRow = active >= 0 ? rows[active] : undefined;\n\n const setActive = (index: number) => {\n if (index < 0 || index >= rows.length) return;\n setStored(index);\n };\n\n const move = (step: number) => {\n if (reachable.length === 0) return;\n const here = activeRow === undefined ? -1 : reachable.indexOf(activeRow);\n /*\n * The active row can be a locked one: the pointer is allowed to land anywhere, and the\n * first row of a fresh list may itself be locked. `indexOf` returns -1 for that, and -1\n * walked forwards lands on the first row and backwards on the second from last, which is\n * neither arrow's meaning. Down starts at the top, up starts at the bottom.\n */\n const from = here >= 0 ? here : step > 0 ? -1 : 0;\n const to = from + step;\n const next = loop\n ? (to + reachable.length) % reachable.length\n : Math.max(0, Math.min(reachable.length - 1, to));\n setStored(rows.indexOf(reachable[next]));\n };\n\n /* Nothing to land on means the active row stays where it is. Clearing it here left\n * `aria-activedescendant` pointing at a row Enter then refused to take. */\n const first = () => reachable.length > 0 && setStored(rows.indexOf(reachable[0]));\n const last = () => reachable.length > 0 && setStored(rows.indexOf(reachable[reachable.length - 1]));\n\n const took = (event: { key: string; preventDefault: () => void }) => {\n switch (event.key) {\n case \"ArrowDown\":\n event.preventDefault();\n move(1);\n return true;\n case \"ArrowUp\":\n event.preventDefault();\n move(-1);\n return true;\n case \"Home\":\n event.preventDefault();\n first();\n return true;\n case \"End\":\n event.preventDefault();\n last();\n return true;\n default:\n return false;\n }\n };\n\n return {\n active,\n activeRow,\n activeId: activeRow === undefined ? undefined : id(activeRow, active),\n setActive,\n move,\n first,\n last,\n took,\n };\n}\n","import \"./Skeleton.css\";\n\nexport type SkeletonShape = \"text\" | \"rect\" | \"circle\";\nexport type SkeletonSize = \"sm\" | \"md\" | \"lg\";\n\nexport type SkeletonProps = {\n shape?: SkeletonShape;\n /** Only for `shape=\"text\"`: how many lines of it. One to six. */\n lines?: 1 | 2 | 3 | 4 | 5 | 6;\n /** For `rect` and `circle`, which have no line height to take their size from. */\n size?: SkeletonSize;\n className?: string;\n [key: `data-${string}`]: unknown;\n};\n\n/**\n * The shape of what has not arrived.\n *\n * `aria-hidden`, always, and never a live region. A skeleton is a picture of a layout, and\n * announcing \"loading, loading, loading\" once per placeholder is worse than silence — the\n * thing that should speak is the region the content lands in, once, when it lands.\n *\n * Text skeletons end short on the last line, because a paragraph does. A block of equal bars\n * reads as a table.\n */\nexport function Skeleton({ shape = \"text\", lines = 3, size = \"md\", className, ...rest }: SkeletonProps) {\n if (shape !== \"text\") {\n return (\n <span\n {...rest}\n className={`skeleton ${className ?? \"\"}`.trim()}\n data-shape={shape}\n data-size={size}\n aria-hidden=\"true\"\n />\n );\n }\n\n return (\n <span\n {...rest}\n className={`skeleton ${className ?? \"\"}`.trim()}\n data-shape=\"text\"\n data-lines={lines}\n aria-hidden=\"true\"\n >\n {Array.from({ length: lines }, (_, index) => (\n <span key={index} className=\"skeleton__line\" />\n ))}\n </span>\n );\n}\n","import type { ReactElement, ReactNode } from \"react\";\nimport * as RadixTooltip from \"@radix-ui/react-tooltip\";\nimport \"./Tooltip.css\";\n\nexport type TooltipSide = \"top\" | \"right\" | \"bottom\" | \"left\";\n\nexport type TooltipProps = {\n /** The control this describes. One element, and it must be able to take focus. */\n children: ReactElement;\n /** What it says. Short — a tooltip that needs a paragraph is not a tooltip. */\n content: ReactNode;\n side?: TooltipSide;\n /** Milliseconds before it opens. The first of a run opens after this; the rest are instant. */\n delay?: number;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n className?: string;\n};\n\n/**\n * A short description of a control, on hover and on focus.\n *\n * Built on Radix rather than from scratch, and the reason is WCAG 1.4.13: content that\n * appears on hover has to be dismissible with Escape, hoverable without vanishing, and\n * persistent until it is dismissed or stops being relevant. On top of that a tooltip has to\n * flip at a viewport edge, portal out of any ancestor with `overflow: hidden`, open on\n * keyboard focus as well as hover, and close on touch instead of sticking. Every one of those\n * is a place a hand-rolled tooltip is wrong, and none of them is visible in a screenshot.\n *\n * What this file owns is the appearance, drawn entirely from tokens.\n *\n * A tooltip is never the only place something is said. It cannot be reached by touch and it\n * cannot be selected, so a control whose name exists only in its tooltip has no name on a\n * phone. Use it to add, never to carry.\n */\nexport function Tooltip({\n children,\n content,\n side = \"top\",\n delay = 300,\n open,\n defaultOpen,\n onOpenChange,\n className,\n}: TooltipProps) {\n return (\n <RadixTooltip.Provider delayDuration={delay} skipDelayDuration={200}>\n <RadixTooltip.Root open={open} defaultOpen={defaultOpen} onOpenChange={onOpenChange}>\n <RadixTooltip.Trigger asChild>{children}</RadixTooltip.Trigger>\n <RadixTooltip.Portal>\n <RadixTooltip.Content\n className={`tooltip ${className ?? \"\"}`.trim()}\n side={side}\n sideOffset={6}\n collisionPadding={8}\n >\n {content}\n <RadixTooltip.Arrow className=\"tooltip__arrow\" width={10} height={5} />\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AY;EACZ,aAAW;EACX,eAAY;CACb,CAAA;AAiBP;;;ACfA,SAAgB,EAAQ,EACtB,aACA,YACA,UAAO,OACP,WAAQ,KACR,SACA,gBACA,iBACA,gBACe;CACf,OACE,kBAAC,EAAa,UAAd;EAAuB,eAAe;EAAO,mBAAmB;EAC9D,UAAA,kBAAC,EAAa,MAAd;GAAyB;GAAmB;GAA2B;GAAvE,UAAA,CACE,kBAAC,EAAa,SAAd;IAAsB,SAAA;IAAS;GAA+B,CAAA,GAC9D,kBAAC,EAAa,QAAd,EAAA,UACE,kBAAC,EAAa,SAAd;IACE,WAAW,WAAW,KAAa,KAAK,KAAK;IACvC;IACN,YAAY;IACZ,kBAAkB;IAJpB,UAAA,CAMG,GACD,kBAAC,EAAa,OAAd;KAAoB,WAAU;KAAiB,OAAO;KAAI,QAAQ;IAAI,CAAA,CAClD;GACH,CAAA,EAAA,CAAA,CACJ;;CACE,CAAA;AAE3B"}
|
|
1
|
+
{"version":3,"file":"Tooltip-BW1-aVDg.js","names":[],"sources":["../../src/components/common/Checkbox/Checkbox.tsx","../../src/components/common/Select/listbox.ts","../../src/components/common/Skeleton/Skeleton.tsx","../../src/components/common/Tooltip/Tooltip.tsx"],"sourcesContent":["import { useCallback } from \"react\";\nimport type { ChangeEvent, ReactNode } from \"react\";\nimport { Check, Minus } from \"lucide-react\";\nimport { Icon } from \"../Icon\";\nimport \"./Checkbox.css\";\n\nexport type CheckboxSize = \"sm\" | \"md\";\n\nexport type CheckboxProps = {\n children?: ReactNode;\n checked?: boolean;\n defaultChecked?: boolean;\n /**\n * Some of what this box stands for is checked and some is not.\n *\n * A DOM property, not an attribute — there is no `indeterminate=\"\"` in HTML — so it is set\n * through a ref. Every implementation that forgets this ships a box that looks\n * indeterminate and reports itself as unchecked.\n */\n indeterminate?: boolean;\n onChange?: (event: ChangeEvent<HTMLInputElement>) => void;\n size?: CheckboxSize;\n disabled?: boolean;\n invalid?: boolean;\n name?: string;\n value?: string;\n id?: string;\n className?: string;\n [key: `data-${string}`]: unknown;\n [key: `aria-${string}`]: unknown;\n};\n\n/**\n * A real `<input type=\"checkbox\">`, drawn over.\n *\n * The input is present, focusable and in the form; what is hidden is only its appearance.\n * Rebuilding a checkbox out of a `<div role=\"checkbox\">` means rebuilding space-to-toggle,\n * form submission, `:checked`, autofill and the label association, and getting one of them\n * wrong is the usual outcome.\n */\nexport function Checkbox({\n children,\n indeterminate,\n size = \"md\",\n disabled,\n invalid,\n className,\n ...rest\n}: CheckboxProps) {\n const setIndeterminate = useCallback(\n (node: HTMLInputElement | null) => {\n if (node) node.indeterminate = Boolean(indeterminate);\n },\n [indeterminate],\n );\n\n return (\n <label\n className={`checkbox ${className ?? \"\"}`.trim()}\n data-size={size}\n data-disabled={disabled ? \"\" : undefined}\n data-invalid={invalid ? \"\" : undefined}\n >\n <input\n {...rest}\n ref={setIndeterminate}\n type=\"checkbox\"\n className=\"checkbox__input\"\n disabled={disabled}\n aria-invalid={invalid || undefined}\n />\n <span className=\"checkbox__box\" aria-hidden=\"true\">\n <Icon icon={indeterminate ? Minus : Check} size={size === \"sm\" ? \"xs\" : \"sm\"} />\n </span>\n {children ? <span className=\"checkbox__label\">{children}</span> : null}\n </label>\n );\n}\n","import { useState } from \"react\";\n\n/**\n * The list model, made available to any list rather than only to `Select`.\n *\n * Four components walk a list of rows with `aria-activedescendant`: `Select`, `MultiSelect`,\n * `Combobox` and `CommandPalette`. They had four copies of the same contract, and\n * `docs/COMPONENT-AUDIT.md` counted the drift: two wrote the walk as `move()`, one as\n * `step()`, one as a `switch` and the rest as `if` chains. The copies were not merely\n * different. They had stopped agreeing.\n *\n * `CommandPalette` did not skip locked rows at all. An arrow key landed on a disabled\n * command and Enter then refused it, which is a control saying no to the keyboard and yes\n * to the pointer. The other three each carry a comment explaining why that must not happen.\n *\n * `Select` gated `aria-activedescendant` on the SELECTED index while naming the ACTIVE one,\n * so a select whose value matched no option announced nothing as the arrows moved.\n *\n * Both were fixed by there being one model instead of four. That is what this is for: not\n * fewer lines, but one place where the contract can be read and therefore one place where it\n * can be wrong.\n *\n * It lives here, beside `Select`, for the reason `refraction.ts` lives beside `Glass`. A\n * `common/` folder holding only a hook would fail the contract's demo rule, `src/foundation`\n * is not something a component may import, and `Select` is the plainest list of the four.\n *\n * What it does NOT own: whether the list is open, what Enter does, and how a row is drawn.\n * Those are four different things in four components — Enter alone commits a value, toggles\n * one of several, fills a field, or runs a command that cannot be undone — and a hook that\n * took them would be the god-code this audit went looking for.\n */\n\nexport type ListboxOptions<Row> = {\n /** Every row the reader can see, locked ones included. Indices are into this. */\n rows: Row[];\n /** A row the pointer may not choose. The arrows must agree with the pointer about it. */\n locked?: (row: Row) => boolean;\n /** The DOM id of a row, for `aria-activedescendant`. Index-based or value-based, as suits. */\n id: (row: Row, index: number) => string;\n /**\n * Whether the ends join. A palette of verbs wraps: at the bottom the next thing the reader\n * wants is the top, not nothing happening. A `Select` standing in for a native one does\n * not, because the native one does not.\n */\n loop?: boolean;\n};\n\nexport type Listbox<Row> = {\n /** Index into `rows`, or -1 when there is nothing reachable to stand on. */\n active: number;\n activeRow: Row | undefined;\n /** For `aria-activedescendant`. Undefined when nothing is active, never a row that is gone. */\n activeId: string | undefined;\n /** Point at a row by index. Out-of-range and locked rows are refused rather than clamped. */\n setActive: (index: number) => void;\n /** One step in a direction, over reachable rows only. */\n move: (step: number) => void;\n first: () => void;\n last: () => void;\n /**\n * Arrow keys, Home and End. Returns whether it took the event.\n *\n * Enter, Escape, Tab and Backspace are not here. They mean different things in each of the\n * four, and the one that looks shared is the one that is not: Enter commits, toggles, fills\n * and runs.\n */\n took: (event: { key: string; preventDefault: () => void }) => boolean;\n};\n\nexport function useListbox<Row>({ rows, locked, id, loop = true }: ListboxOptions<Row>): Listbox<Row> {\n const [stored, setStored] = useState(0);\n\n const isLocked = (row: Row) => Boolean(locked?.(row));\n const reachable = rows.filter((row) => !isLocked(row));\n\n /*\n * Derived rather than corrected in an effect.\n *\n * Rows come and go or become locked while the reader types. An index from a longer list points\n * past the end of the shorter one. An effect that repaired it would render once with\n * `aria-activedescendant` naming a row that is not in the document, which is the frame a\n * screen reader is reading.\n */\n const active = stored >= 0 && stored < rows.length && !isLocked(rows[stored])\n ? stored : reachable.length > 0 ? rows.indexOf(reachable[0]) : -1;\n const activeRow = active >= 0 ? rows[active] : undefined;\n\n const setActive = (index: number) => {\n if (index < 0 || index >= rows.length) return;\n setStored(index);\n };\n\n const move = (step: number) => {\n if (reachable.length === 0) return;\n const here = activeRow === undefined ? -1 : reachable.indexOf(activeRow);\n /*\n * The active row can be a locked one: the pointer is allowed to land anywhere, and the\n * first row of a fresh list may itself be locked. `indexOf` returns -1 for that, and -1\n * walked forwards lands on the first row and backwards on the second from last, which is\n * neither arrow's meaning. Down starts at the top, up starts at the bottom.\n */\n const from = here >= 0 ? here : step > 0 ? -1 : 0;\n const to = from + step;\n const next = loop\n ? (to + reachable.length) % reachable.length\n : Math.max(0, Math.min(reachable.length - 1, to));\n setStored(rows.indexOf(reachable[next]));\n };\n\n /* Nothing to land on means the active row stays where it is. Clearing it here left\n * `aria-activedescendant` pointing at a row Enter then refused to take. */\n const first = () => reachable.length > 0 && setStored(rows.indexOf(reachable[0]));\n const last = () => reachable.length > 0 && setStored(rows.indexOf(reachable[reachable.length - 1]));\n\n const took = (event: { key: string; preventDefault: () => void }) => {\n switch (event.key) {\n case \"ArrowDown\":\n event.preventDefault();\n move(1);\n return true;\n case \"ArrowUp\":\n event.preventDefault();\n move(-1);\n return true;\n case \"Home\":\n event.preventDefault();\n first();\n return true;\n case \"End\":\n event.preventDefault();\n last();\n return true;\n default:\n return false;\n }\n };\n\n return {\n active,\n activeRow,\n activeId: activeRow === undefined ? undefined : id(activeRow, active),\n setActive,\n move,\n first,\n last,\n took,\n };\n}\n","import \"./Skeleton.css\";\n\nexport type SkeletonShape = \"text\" | \"rect\" | \"circle\";\nexport type SkeletonSize = \"sm\" | \"md\" | \"lg\";\n\nexport type SkeletonProps = {\n shape?: SkeletonShape;\n /** Only for `shape=\"text\"`: how many lines of it. One to six. */\n lines?: 1 | 2 | 3 | 4 | 5 | 6;\n /** For `rect` and `circle`, which have no line height to take their size from. */\n size?: SkeletonSize;\n className?: string;\n [key: `data-${string}`]: unknown;\n};\n\n/**\n * The shape of what has not arrived.\n *\n * `aria-hidden`, always, and never a live region. A skeleton is a picture of a layout, and\n * announcing \"loading, loading, loading\" once per placeholder is worse than silence — the\n * thing that should speak is the region the content lands in, once, when it lands.\n *\n * Text skeletons end short on the last line, because a paragraph does. A block of equal bars\n * reads as a table.\n */\nexport function Skeleton({ shape = \"text\", lines = 3, size = \"md\", className, ...rest }: SkeletonProps) {\n if (shape !== \"text\") {\n return (\n <span\n {...rest}\n className={`skeleton ${className ?? \"\"}`.trim()}\n data-shape={shape}\n data-size={size}\n aria-hidden=\"true\"\n />\n );\n }\n\n return (\n <span\n {...rest}\n className={`skeleton ${className ?? \"\"}`.trim()}\n data-shape=\"text\"\n data-lines={lines}\n aria-hidden=\"true\"\n >\n {Array.from({ length: lines }, (_, index) => (\n <span key={index} className=\"skeleton__line\" />\n ))}\n </span>\n );\n}\n","import type { ReactElement, ReactNode } from \"react\";\nimport * as RadixTooltip from \"@radix-ui/react-tooltip\";\nimport \"./Tooltip.css\";\n\nexport type TooltipSide = \"top\" | \"right\" | \"bottom\" | \"left\";\n\nexport type TooltipProps = {\n /** The control this describes. One element, and it must be able to take focus. */\n children: ReactElement;\n /** What it says. Short — a tooltip that needs a paragraph is not a tooltip. */\n content: ReactNode;\n side?: TooltipSide;\n /** Milliseconds before it opens. The first of a run opens after this; the rest are instant. */\n delay?: number;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n className?: string;\n};\n\n/**\n * A short description of a control, on hover and on focus.\n *\n * Built on Radix rather than from scratch, and the reason is WCAG 1.4.13: content that\n * appears on hover has to be dismissible with Escape, hoverable without vanishing, and\n * persistent until it is dismissed or stops being relevant. On top of that a tooltip has to\n * flip at a viewport edge, portal out of any ancestor with `overflow: hidden`, open on\n * keyboard focus as well as hover, and close on touch instead of sticking. Every one of those\n * is a place a hand-rolled tooltip is wrong, and none of them is visible in a screenshot.\n *\n * What this file owns is the appearance, drawn entirely from tokens.\n *\n * A tooltip is never the only place something is said. It cannot be reached by touch and it\n * cannot be selected, so a control whose name exists only in its tooltip has no name on a\n * phone. Use it to add, never to carry.\n */\nexport function Tooltip({\n children,\n content,\n side = \"top\",\n delay = 300,\n open,\n defaultOpen,\n onOpenChange,\n className,\n}: TooltipProps) {\n return (\n <RadixTooltip.Provider delayDuration={delay} skipDelayDuration={200}>\n <RadixTooltip.Root open={open} defaultOpen={defaultOpen} onOpenChange={onOpenChange}>\n <RadixTooltip.Trigger asChild>{children}</RadixTooltip.Trigger>\n <RadixTooltip.Portal>\n <RadixTooltip.Content\n className={`tooltip ${className ?? \"\"}`.trim()}\n side={side}\n sideOffset={6}\n collisionPadding={8}\n >\n {content}\n <RadixTooltip.Arrow className=\"tooltip__arrow\" width={10} height={5} />\n </RadixTooltip.Content>\n </RadixTooltip.Portal>\n </RadixTooltip.Root>\n </RadixTooltip.Provider>\n );\n}\n"],"mappings":";;;;;;AAwCA,SAAgB,EAAS,EACvB,aACA,kBACA,UAAO,MACP,aACA,YACA,cACA,GAAG,KACa;CAChB,IAAM,IAAmB,GACtB,MAAkC;EACjC,AAAI,MAAM,EAAK,gBAAgB,EAAQ;CACzC,GACA,CAAC,CAAa,CAChB;CAEA,OACE,kBAAC,SAAD;EACE,WAAW,YAAY,KAAa,KAAK,KAAK;EAC9C,aAAW;EACX,iBAAe,IAAW,KAAK,KAAA;EAC/B,gBAAc,IAAU,KAAK,KAAA;EAJ/B,UAAA;GAME,kBAAC,SAAD;IACE,GAAI;IACJ,KAAK;IACL,MAAK;IACL,WAAU;IACA;IACV,gBAAc,KAAW,KAAA;GAC1B,CAAA;GACD,kBAAC,QAAD;IAAM,WAAU;IAAgB,eAAY;IAC1C,UAAA,kBAAC,GAAD;KAAM,MAAM,IAA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