@eifi1/ui-kit 0.21.0 → 0.22.0
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/chart.d.ts +10 -8
- package/dist/components/account-chips.d.ts +10 -3
- package/dist/components/account-chips.js +5 -2
- package/dist/components/account-chips.js.map +1 -1
- package/dist/components/account-settings.d.ts +33 -2
- package/dist/components/account-settings.js +43 -21
- package/dist/components/account-settings.js.map +1 -1
- package/dist/components/amount-input.d.ts +27 -8
- package/dist/components/amount-input.js +15 -28
- package/dist/components/amount-input.js.map +1 -1
- package/dist/components/autocomplete.d.ts +8 -0
- package/dist/components/autocomplete.js +9 -4
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/button-group.d.ts +10 -8
- package/dist/components/calculator.d.ts +10 -8
- package/dist/components/checkbox-group.d.ts +104 -0
- package/dist/components/checkbox-group.js +111 -0
- package/dist/components/checkbox-group.js.map +1 -0
- package/dist/components/checkbox.d.ts +19 -0
- package/dist/components/checkbox.js +30 -7
- package/dist/components/checkbox.js.map +1 -1
- package/dist/components/chip.d.ts +18 -0
- package/dist/components/chip.js +47 -10
- package/dist/components/chip.js.map +1 -1
- package/dist/components/combobox.d.ts +13 -2
- package/dist/components/combobox.js +17 -8
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/confirm-dialog.d.ts +66 -161
- package/dist/components/copy-button.d.ts +10 -8
- package/dist/components/country-select.d.ts +124 -0
- package/dist/components/country-select.js +237 -0
- package/dist/components/country-select.js.map +1 -0
- package/dist/components/currency-select.d.ts +17 -1
- package/dist/components/currency-select.js +56 -23
- package/dist/components/currency-select.js.map +1 -1
- package/dist/components/danger-confirm.d.ts +66 -166
- package/dist/components/danger-confirm.js +133 -49
- package/dist/components/danger-confirm.js.map +1 -1
- package/dist/components/data-table-cells.d.ts +1 -2
- package/dist/components/data-table-filter-popover.d.ts +1 -2
- package/dist/components/data-table-filters.d.ts +1 -2
- package/dist/components/data-table-labels.d.ts +4 -97
- package/dist/components/data-table-labels.js +9 -1
- package/dist/components/data-table-labels.js.map +1 -1
- package/dist/components/data-table-pagination.d.ts +3 -1
- package/dist/components/data-table.d.ts +1 -2
- package/dist/components/data-table.js +98 -3
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/date-picker.d.ts +25 -5
- package/dist/components/date-picker.js +110 -59
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/entity-combobox.d.ts +8 -1
- package/dist/components/entity-combobox.js +9 -4
- package/dist/components/entity-combobox.js.map +1 -1
- package/dist/components/facing-pair.d.ts +10 -8
- package/dist/components/field-anatomy.d.ts +95 -0
- package/dist/components/field-anatomy.js +84 -0
- package/dist/components/field-anatomy.js.map +1 -0
- package/dist/components/field-parts.d.ts +114 -0
- package/dist/components/field-parts.js +72 -0
- package/dist/components/field-parts.js.map +1 -0
- package/dist/components/file-button.d.ts +10 -8
- package/dist/components/file-button.js +13 -3
- package/dist/components/file-button.js.map +1 -1
- package/dist/components/file-dropzone.d.ts +32 -9
- package/dist/components/file-dropzone.js +57 -34
- package/dist/components/file-dropzone.js.map +1 -1
- package/dist/components/form-actions.d.ts +10 -8
- package/dist/components/form-actions.js +61 -3
- package/dist/components/form-actions.js.map +1 -1
- package/dist/components/iban-input.d.ts +66 -0
- package/dist/components/iban-input.js +125 -0
- package/dist/components/iban-input.js.map +1 -0
- package/dist/components/icon-picker.d.ts +12 -2
- package/dist/components/icon-picker.js +9 -2
- package/dist/components/icon-picker.js.map +1 -1
- package/dist/components/inline-edit-field.d.ts +167 -0
- package/dist/components/inline-edit-field.js +293 -0
- package/dist/components/inline-edit-field.js.map +1 -0
- package/dist/components/language-select.d.ts +127 -0
- package/dist/components/language-select.js +18 -0
- package/dist/components/language-select.js.map +1 -0
- package/dist/components/line-items.d.ts +25 -3
- package/dist/components/line-items.js +55 -46
- package/dist/components/line-items.js.map +1 -1
- package/dist/components/list.d.ts +25 -0
- package/dist/components/list.js +16 -5
- package/dist/components/list.js.map +1 -1
- package/dist/components/money-field.d.ts +20 -8
- package/dist/components/money-field.js.map +1 -1
- package/dist/components/month-picker.d.ts +52 -4
- package/dist/components/month-picker.js +290 -86
- package/dist/components/month-picker.js.map +1 -1
- package/dist/components/multi-select.d.ts +8 -1
- package/dist/components/multi-select.js +9 -4
- package/dist/components/multi-select.js.map +1 -1
- package/dist/components/number-field.d.ts +25 -13
- package/dist/components/number-field.js +6 -20
- package/dist/components/number-field.js.map +1 -1
- package/dist/components/number-input.d.ts +70 -13
- package/dist/components/number-input.js +90 -38
- package/dist/components/number-input.js.map +1 -1
- package/dist/components/numpad-sheet.d.ts +10 -8
- package/dist/components/one-time-code-input.d.ts +100 -0
- package/dist/components/one-time-code-input.js +137 -0
- package/dist/components/one-time-code-input.js.map +1 -0
- package/dist/components/phone-input.d.ts +66 -0
- package/dist/components/phone-input.js +171 -0
- package/dist/components/phone-input.js.map +1 -0
- package/dist/components/series-chart.d.ts +10 -8
- package/dist/components/settings-fields.d.ts +10 -8
- package/dist/components/share-card.d.ts +8 -6
- package/dist/components/sign-chip.d.ts +66 -0
- package/dist/components/sign-chip.js +39 -0
- package/dist/components/sign-chip.js.map +1 -0
- package/dist/components/swatch-picker.d.ts +27 -2
- package/dist/components/swatch-picker.js +73 -31
- package/dist/components/swatch-picker.js.map +1 -1
- package/dist/components/switch.d.ts +19 -0
- package/dist/components/switch.js +24 -6
- package/dist/components/switch.js.map +1 -1
- package/dist/components/text-link.d.ts +10 -8
- package/dist/components/tile-radio.d.ts +68 -13
- package/dist/components/tile-radio.js +3 -3
- package/dist/components/tile-radio.js.map +1 -1
- package/dist/components/time-input.d.ts +15 -9
- package/dist/components/time-input.js.map +1 -1
- package/dist/components/toggle-group.d.ts +47 -1
- package/dist/components/toggle-group.js +110 -69
- package/dist/components/toggle-group.js.map +1 -1
- package/dist/components/ui.d.ts +10 -8
- package/dist/components/ui.js +280 -78
- package/dist/components/ui.js.map +1 -1
- package/dist/components/use-table-state.d.ts +1 -2
- package/dist/{data-table-3mi2R3so.d.ts → data-table-labels-B7OdnM0S.d.ts} +140 -3
- package/dist/data-table.d.ts +1 -2
- package/dist/data-table.js +2 -1
- package/dist/data-table.js.map +1 -1
- package/dist/feedback/feedback-attachment.d.ts +1 -1
- package/dist/feedback/feedback-attachment.js +210 -3
- package/dist/feedback/feedback-attachment.js.map +1 -1
- package/dist/feedback/feedback-dialog.d.ts +1 -1
- package/dist/feedback/feedback-dialog.js.map +1 -1
- package/dist/feedback/feedback-inbox.d.ts +1 -1
- package/dist/feedback/feedback-thread.d.ts +37 -3
- package/dist/feedback/feedback-thread.js +38 -9
- package/dist/feedback/feedback-thread.js.map +1 -1
- package/dist/{feedback-attachment-WFiXJ8We.d.ts → feedback-attachment-NhUm7Zga.d.ts} +70 -5
- package/dist/feedback.d.ts +2 -2
- package/dist/hooks/use-file-drop.d.ts +10 -8
- package/dist/i18n/defaults.d.ts +10 -8
- package/dist/i18n/defaults.js +17 -2
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/german.d.ts +10 -8
- package/dist/i18n/german.js +50 -5
- package/dist/i18n/german.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +10 -8
- package/dist/i18n/kit-labels.js +8 -2
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/languages.d.ts +10 -8
- package/dist/i18n/locales/de-CH.d.ts +10 -8
- package/dist/i18n/locales/en.d.ts +10 -8
- package/dist/i18n/locales/en.js +9 -0
- package/dist/i18n/locales/en.js.map +1 -1
- package/dist/i18n/locales/es.d.ts +10 -8
- package/dist/i18n/locales/es.js +48 -5
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts +10 -8
- package/dist/i18n/locales/fr.js +48 -5
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.d.ts +10 -8
- package/dist/i18n/locales/hu.js +49 -5
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.d.ts +10 -8
- package/dist/i18n/locales/it.js +49 -5
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.d.ts +10 -8
- package/dist/i18n/locales/zh.js +48 -5
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/i18n/review.d.ts +10 -8
- package/dist/i18n/review.js +8 -1
- package/dist/i18n/review.js.map +1 -1
- package/dist/index.d.ts +17 -10
- package/dist/index.js +57 -2
- package/dist/index.js.map +1 -1
- package/dist/{kit-labels-D1J2_jyD.d.ts → kit-labels-R8mIAc9N.d.ts} +811 -8
- package/dist/lib/countries.d.ts +43 -0
- package/dist/lib/countries.js +39 -0
- package/dist/lib/countries.js.map +1 -0
- package/dist/lib/decimal-marks.d.ts +46 -0
- package/dist/lib/decimal-marks.js +40 -0
- package/dist/lib/decimal-marks.js.map +1 -0
- package/dist/lib/iban.d.ts +98 -0
- package/dist/lib/iban.js +154 -0
- package/dist/lib/iban.js.map +1 -0
- package/dist/lib/isin.d.ts +30 -0
- package/dist/lib/isin.js +36 -0
- package/dist/lib/isin.js.map +1 -0
- package/dist/lib/phone.d.ts +69 -0
- package/dist/lib/phone.js +121 -0
- package/dist/lib/phone.js.map +1 -0
- package/dist/rhf/fields.d.ts +148 -11
- package/dist/rhf/fields.js +332 -3
- package/dist/rhf/fields.js.map +1 -1
- package/dist/rhf/form.d.ts +10 -8
- package/dist/rhf.d.ts +13 -9
- package/dist/rhf.js.map +1 -1
- package/dist/shell/app-shell.d.ts +10 -8
- package/dist/shell/top-bar-brand.d.ts +10 -8
- package/dist/shell.d.ts +10 -8
- package/dist/tour/tour.js +20 -24
- package/dist/tour/tour.js.map +1 -1
- package/dist/wizard/stepper-nav.d.ts +10 -8
- package/dist/wizard.d.ts +10 -8
- package/package.json +1 -1
- package/src/components/account-chips.tsx +17 -3
- package/src/components/account-settings.tsx +92 -26
- package/src/components/amount-input.tsx +49 -56
- package/src/components/autocomplete.tsx +133 -110
- package/src/components/checkbox-group.tsx +229 -0
- package/src/components/checkbox.tsx +72 -8
- package/src/components/chip.tsx +80 -10
- package/src/components/combobox.tsx +292 -253
- package/src/components/country-select.tsx +443 -0
- package/src/components/currency-select.tsx +109 -33
- package/src/components/danger-confirm.tsx +345 -77
- package/src/components/data-table-labels.ts +16 -1
- package/src/components/data-table.tsx +175 -6
- package/src/components/date-picker.tsx +173 -62
- package/src/components/entity-combobox.tsx +107 -87
- package/src/components/field-anatomy.tsx +190 -0
- package/src/components/field-parts.tsx +184 -0
- package/src/components/file-button.tsx +36 -3
- package/src/components/file-dropzone.tsx +106 -38
- package/src/components/form-actions.tsx +115 -2
- package/src/components/iban-input.tsx +231 -0
- package/src/components/icon-picker.tsx +26 -4
- package/src/components/inline-edit-field.tsx +533 -0
- package/src/components/language-select.tsx +78 -0
- package/src/components/line-items.tsx +35 -2
- package/src/components/list.tsx +55 -6
- package/src/components/money-field.tsx +10 -0
- package/src/components/month-picker.tsx +399 -63
- package/src/components/multi-select.tsx +80 -58
- package/src/components/number-field.tsx +28 -46
- package/src/components/number-input.tsx +210 -43
- package/src/components/one-time-code-input.tsx +288 -0
- package/src/components/phone-input.tsx +299 -0
- package/src/components/sign-chip.tsx +103 -0
- package/src/components/swatch-picker.tsx +118 -30
- package/src/components/switch.tsx +58 -7
- package/src/components/tile-radio.tsx +71 -16
- package/src/components/time-input.tsx +8 -1
- package/src/components/toggle-group.tsx +206 -73
- package/src/components/ui.tsx +472 -105
- package/src/data-table.ts +2 -1
- package/src/feedback/feedback-attachment.tsx +313 -9
- package/src/feedback/feedback-dialog.tsx +2 -0
- package/src/feedback/feedback-thread.tsx +66 -5
- package/src/i18n/defaults.ts +16 -1
- package/src/i18n/german.ts +47 -0
- package/src/i18n/kit-labels.tsx +78 -2
- package/src/i18n/locales/en.ts +10 -0
- package/src/i18n/locales/es.ts +46 -0
- package/src/i18n/locales/fr.ts +45 -0
- package/src/i18n/locales/hu.ts +46 -0
- package/src/i18n/locales/it.ts +47 -0
- package/src/i18n/locales/zh.ts +44 -0
- package/src/i18n/review.ts +7 -0
- package/src/index.ts +53 -3
- package/src/lib/countries.ts +91 -0
- package/src/lib/decimal-marks.ts +99 -0
- package/src/lib/iban.ts +171 -0
- package/src/lib/isin.ts +62 -0
- package/src/lib/phone.ts +211 -0
- package/src/rhf/fields.tsx +606 -9
- package/src/rhf.ts +2 -1
- package/src/tour/tour.tsx +66 -28
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/inline-edit-field.tsx"],"sourcesContent":["import { useEffect, useId, useRef, useState } from \"react\";\nimport type { FocusEvent, InputHTMLAttributes, KeyboardEvent, ReactNode } from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { useAnnounce } from \"../hooks/use-announce\";\nimport { useKitLabels } from \"../i18n/kit-labels\";\nimport { Input, Spinner } from \"./ui\";\nimport { Tooltip } from \"./tooltip\";\nimport { useCommitReason } from \"./write-lock\";\n\n/**\n * Every string {@link InlineEditField} says on its own behalf — the `inlineEdit`\n * namespace of `<UiKitProvider labels>`, overridable per instance through `labels`.\n */\nexport interface InlineEditLabels {\n /** The display button's tooltip and description — what pressing it does. Receives\n * the field's `label` (\"Budget name\" → \"Edit Budget name\"). */\n edit: (label: string) => string;\n /** Shown (and spoken) when `onCommit` rejects and no `formatError` says better. */\n failed: string;\n /** What the display shows for an empty value, when no `placeholder` is given. */\n empty: string;\n}\n\nexport const DEFAULT_INLINE_EDIT_LABELS: InlineEditLabels = {\n edit: (label) => `Edit ${label}`,\n failed: \"The change could not be saved.\",\n empty: \"Empty\",\n};\n\n/** What an `editor` render prop is handed: the draft and the means to end the edit. */\nexport interface InlineEditorProps<T> {\n /** The draft — seeded from `value` each time the editor opens. */\n value: T;\n /** Replace the draft (every keystroke). */\n onChange: (next: T) => void;\n /**\n * End the edit and save. Without an argument it saves the draft; WITH one it saves\n * that — for an editor whose own commit hands over a resolved value (`NumberInput`'s\n * `onCommit` gives \"1050\" for a typed \"1100-50\"). Called twice (the editor's own\n * Enter, then the field's), the second call does nothing.\n */\n commit: (next?: T) => void;\n /** End the edit and drop the draft — what Escape does. */\n cancel: () => void;\n /** The save is in flight: make the control read-only (not disabled — it has focus). */\n pending: boolean;\n /** The field's `label`, for the control's accessible name. */\n label: string;\n /** The last save failed and the draft has not been touched since. */\n invalid: boolean;\n /** The id of the failure message while there is one, for `aria-describedby`. */\n describedBy: string | undefined;\n /** The four above as attributes — spread them on a kit field that takes the DOM\n * spelling: `<AmountInput {...p.inputProps} … />`. */\n inputProps: {\n \"aria-label\": string;\n \"aria-invalid\": true | undefined;\n \"aria-describedby\": string | undefined;\n readOnly: boolean;\n };\n}\n\ninterface InlineEditFieldBaseProps<T> {\n /** The saved value — what the display shows, and what the editor opens on. */\n value: T;\n /**\n * Save `next`. Return a promise and the field waits: the editor stays open and\n * read-only with a spinner until it settles, closes when it resolves, and STAYS OPEN\n * with the failure under it when it rejects (or throws) — the typed value is kept for\n * a retry. Not called when the draft equals `value` (see `isEqual`): opening the\n * editor and leaving it unchanged is not a write.\n */\n onCommit: (next: T) => void | Promise<unknown>;\n /** What the value is (\"Budget name\", \"Assigned\") — the editor's accessible name and\n * the subject of the display's \"Edit …\" description. Not drawn: inline, the row or\n * the column header is the visible label. */\n label: string;\n /** The value as the display shows it — a formatted amount, a date. Default: the\n * value as text. */\n display?: (value: T) => ReactNode;\n /** Whether the draft is unchanged, so leaving the editor is not a write. Default\n * `Object.is`. keksdose compares assigned amounts as NUMBERS — \"1100\" is the\n * server's \"1100.0000\". */\n isEqual?: (a: T, b: T) => boolean;\n /** What the display shows for an empty value (`\"\"`, `null`, an empty `display`).\n * Default `labels.empty`. */\n placeholder?: ReactNode;\n /** `\"end\"` for a figure in a right-aligned money column. Default `\"start\"`. */\n align?: \"start\" | \"end\";\n /** Look, do not touch — a guest's view: the value as plain text, no button. */\n readOnly?: boolean;\n /**\n * Why it cannot be edited now — the write lock's sentence, a closed period. The\n * value stays a BUTTON (focusable, `aria-disabled`) with the reason in the kit\n * Tooltip and its description; it opens no editor. An editor that is open when the\n * reason arrives closes, its draft dropped: a field you can type into must be one\n * whose value can be saved (keksdose dev#496).\n */\n disabledReason?: ReactNode;\n /** This field COMMITS — under a locked {@link WriteLockProvider} it takes the\n * `disabledReason` path with the lock's reason (which wins over its own). No\n * provider, or an unlocked one: no effect. */\n commit?: boolean;\n /** The value is the user's own data: `data-private` on the display and the editor,\n * so the app's demo-mode blur covers both. */\n redact?: boolean;\n /** Turns a rejection into words. Default `labels.failed`. */\n formatError?: (error: unknown) => ReactNode;\n /** Controlled open state — a row's swipe action that opens the editor from outside\n * (keksdose's assigned cell). Left out, the field keeps its own. */\n editing?: boolean;\n /** Called with the next open state: on open, on a save that resolved, on cancel. */\n onEditingChange?: (editing: boolean) => void;\n /** Attributes for the DEFAULT text editor's `<input>` — `maxLength`, `inputMode`,\n * `autoComplete`. Ignored with `editor`. */\n inputProps?: Omit<InputHTMLAttributes<HTMLInputElement>, \"value\" | \"defaultValue\" | \"onChange\" | \"type\">;\n /** Classes for the root. */\n className?: string;\n labels?: Partial<InlineEditLabels>;\n}\n\ntype EditorRender<T> = (props: InlineEditorProps<T>) => ReactNode;\n\n/**\n * The editor. Optional for a string value — the kit's `Input`, compact — and\n * REQUIRED for anything else, since only the caller knows how to edit a number or an\n * amount. Render a kit field from the props it is handed:\n *\n * ```tsx\n * editor={(p) => (\n * <NumberInput calculator={false} ariaLabel={p.label} value={p.value} onChange={p.onChange}\n * onCommit={p.commit} aria-invalid={p.invalid || undefined} aria-describedby={p.describedBy} />\n * )}\n * ```\n *\n * The field itself handles Enter (save), Escape (cancel) and focus leaving the editor\n * (save) around whatever is rendered — a key the editor has already handled\n * (`preventDefault`, as a listbox does for its Enter) is left to it. Focus counts as\n * \"inside\" across a portal, so a picker or a phone keypad the editor opens does not\n * end the edit.\n */\nexport type InlineEditFieldProps<T = string> = InlineEditFieldBaseProps<T> &\n ([T] extends [string] ? { editor?: EditorRender<T> } : { editor: EditorRender<T> });\n\nfunction hasContent(node: ReactNode): boolean {\n return node !== undefined && node !== null && node !== false && node !== \"\";\n}\n\n/** Calls the `editor` render prop as a component of its own: the props it is handed\n * close over the field's refs, and a render prop called in the field's own render\n * would read like a ref read during render. Module-level, so the type is stable and\n * the editor never remounts. */\nfunction RenderEditor<T>({ render, ...props }: InlineEditorProps<T> & { render: EditorRender<T> }) {\n return render(props);\n}\n\n/** `onCommit`'s result, if it is a promise. */\nfunction asPromise(result: unknown): Promise<unknown> | null {\n return result && typeof (result as Promise<unknown>).then === \"function\" ? (result as Promise<unknown>) : null;\n}\n\n/**\n * A value that edits in place: a quiet button showing the value; click it (or Enter\n * on it) and it becomes a field; Enter or leaving the field saves, Escape cancels\n * (keksdose K9).\n *\n * keksdose has three of them by hand — the budget's assigned cell (budget-cells.tsx),\n * the invoice line's value cells (invoice-lines-table.tsx `EditableCell`) and the\n * budget rename (budgets-page.tsx, an `Input` + Save + Cancel with no Escape) — and\n * each had to learn the same rules:\n *\n * - **The display's accessible name is the VALUE.** A cell named \"Edit\" reads a table\n * of \"edit, edit, edit\"; the action is the description instead (\"Edit Assigned\"),\n * in the kit Tooltip on hover and focus.\n * - **An unchanged draft is not a write.** Opening the editor and leaving it was a PUT\n * in keksdose until `isEqual` compared numbers, and on a sealed budget an outbox row\n * for a change nobody made.\n * - **A failed save keeps the editor.** The typed value is the user's work; the\n * failure is shown under it (attached with `aria-describedby`, and spoken), and the\n * next keystroke clears it. Escape still drops the draft.\n * - **Locked means a disabled BUTTON, not a disabled field** (keksdose dev#496): at\n * rest a real row shows this button, so a locked page shows the same, with the\n * reason — never a field that takes keys it cannot save.\n *\n * Inside a {@link DataTable} cell it needs nothing extra: the table already leaves a\n * click or a key on a control of the cell to that control. Focus returns to the value\n * after Enter or Escape; after a save that came from focus leaving, it stays where the\n * user put it.\n *\n * ```tsx\n * <InlineEditField label={t(\"budgets.name\")} value={budget.name}\n * onCommit={(name) => rename.mutateAsync({ id: budget.id, name })} inputProps={{ maxLength: 120 }} />\n * ```\n */\nexport function InlineEditField<T = string>(props: InlineEditFieldProps<T>) {\n const {\n value,\n onCommit,\n label,\n display,\n isEqual = Object.is,\n placeholder,\n align = \"start\",\n readOnly = false,\n disabledReason: ownDisabledReason,\n commit,\n redact = false,\n formatError,\n editing: editingProp,\n onEditingChange,\n inputProps,\n className,\n labels: labelsProp,\n } = props;\n const editor = props.editor as EditorRender<T> | undefined;\n const labels = useKitLabels(\"inlineEdit\", DEFAULT_INLINE_EDIT_LABELS, labelsProp);\n const disabledReason = useCommitReason(commit, ownDisabledReason);\n const locked = hasContent(disabledReason);\n\n const [openState, setOpenState] = useState(false);\n const open = editingProp ?? openState;\n // Locked (or read-only) wins over an open flag: a stale `editing` must never bring a\n // live commit-on-blur field back on a page that cannot save it.\n const editing = open && !locked && !readOnly;\n const [draft, setDraft] = useState<T>(value);\n const [pending, setPending] = useState(false);\n const [failure, setFailure] = useState<ReactNode>(null);\n const failed = hasContent(failure);\n\n const errorId = useId();\n const reasonId = useId();\n const displayRef = useRef<HTMLButtonElement>(null);\n const editorRef = useRef<HTMLDivElement>(null);\n const alert = useAnnounce({ politeness: \"assertive\" });\n\n // One edit ends once: Enter in a NumberInput commits through its own `onCommit` and\n // then reaches the field's Enter; a save that closes the editor unmounts the focused\n // control, which some browsers answer with a blur. The second ending is a no-op.\n const ended = useRef(false);\n const blurTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n const mounted = useRef(true);\n // The latest draft for the deferred blur check, which runs after a render.\n const draftRef = useRef(draft);\n useEffect(() => {\n draftRef.current = draft;\n });\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n if (blurTimer.current) clearTimeout(blurTimer.current);\n };\n }, []);\n\n // Seed the draft when the editor opens — from wherever the open came (the button, a\n // controlled `editing`). During render, like DangerConfirm's wipe, so no frame shows\n // the editor holding the previous edit's text.\n const [wasEditing, setWasEditing] = useState(editing);\n if (wasEditing !== editing) {\n setWasEditing(editing);\n if (editing) {\n setDraft(value);\n setFailure(null);\n setPending(false);\n }\n }\n // An open editor that a lock (or `readOnly`) took away is closed for good, not\n // merely hidden until the lock lifts.\n if (openState && !editing && editingProp === undefined) setOpenState(false);\n\n // Focus follows the edit: into the editor when it opens, back to the value when it\n // closes — but only if focus went down with the editor (Enter, Escape, a save that\n // resolved under it). A save that came from focus LEAVING keeps focus where it went.\n const prevEditing = useRef(editing);\n useEffect(() => {\n const changed = prevEditing.current !== editing;\n prevEditing.current = editing;\n if (!changed) return;\n if (editing) {\n // A fresh edit, which may end once. Here rather than in the seed above: a ref is\n // not written during render, and no event can end the edit before this runs.\n ended.current = false;\n const control = editorRef.current?.querySelector<HTMLElement>(\n \"input:not([type=hidden]), textarea, select, [contenteditable='true'], [tabindex]:not([tabindex='-1']), button\",\n );\n control?.focus();\n if (control instanceof HTMLInputElement || control instanceof HTMLTextAreaElement) control.select();\n return;\n }\n // However it closed — a save, Escape, a lock taking it away — a blur check still\n // queued from the editor has nothing left to save.\n ended.current = true;\n if (blurTimer.current) clearTimeout(blurTimer.current);\n blurTimer.current = null;\n const lost = document.activeElement === null || document.activeElement === document.body;\n if (lost) displayRef.current?.focus();\n }, [editing]);\n\n const setOpen = (next: boolean) => {\n if (editingProp === undefined) setOpenState(next);\n onEditingChange?.(next);\n };\n\n const fail = (caught: unknown) => {\n ended.current = false;\n const message = formatError ? formatError(caught) : labels.failed;\n setFailure(hasContent(message) ? message : labels.failed);\n alert.announce(typeof message === \"string\" && message !== \"\" ? message : labels.failed);\n // Focus back into the editor if the failure left it nowhere (a pending field that\n // the browser let go of); never pulled back from somewhere the user went.\n const active = document.activeElement;\n if (active === null || active === document.body) {\n editorRef.current?.querySelector<HTMLElement>(\"input, textarea, select, [tabindex]\")?.focus();\n }\n };\n\n const save = (next: T = draftRef.current) => {\n if (!editing || ended.current || pending) return;\n ended.current = true;\n if (next !== draftRef.current) setDraft(next);\n if (isEqual(next, value)) {\n setOpen(false);\n return;\n }\n let result: unknown;\n try {\n result = onCommit(next);\n } catch (caught) {\n fail(caught);\n return;\n }\n const promise = asPromise(result);\n if (!promise) {\n setOpen(false);\n return;\n }\n setPending(true);\n setFailure(null);\n promise.then(\n () => {\n if (!mounted.current) return;\n setPending(false);\n setOpen(false);\n },\n (caught: unknown) => {\n if (!mounted.current) return;\n setPending(false);\n fail(caught);\n },\n );\n };\n\n const cancel = () => {\n // A request that has left cannot be called back; Escape waits for it.\n if (!editing || pending) return;\n ended.current = true;\n setOpen(false);\n };\n\n const change = (next: T) => {\n if (pending) return;\n setDraft(next);\n // Now, not after the render: a blur check scheduled before that render reads it.\n draftRef.current = next;\n // The failure described the draft that was sent; once edited it describes nothing\n // on screen, and the next save (or blur) is a fresh attempt.\n setFailure(null);\n };\n\n const onKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {\n if (e.defaultPrevented) return;\n if (e.key === \"Escape\") {\n // Ours, not the dialog's or the popover's around the field.\n e.preventDefault();\n e.stopPropagation();\n cancel();\n return;\n }\n // Not mid-composition: Enter there picks the IME's candidate (Japanese, Chinese).\n if (e.key === \"Enter\" && !e.nativeEvent.isComposing && !e.shiftKey) {\n e.preventDefault();\n save();\n }\n };\n\n // Leaving the editor saves. Deferred one task, and cancelled by any focus that lands\n // back inside: React reports focus moves through PORTALS to the component tree, so a\n // calculator popover or a phone keypad the editor opened counts as inside, which a\n // DOM `contains` check would get wrong. A failure on screen holds the editor: the\n // user is looking at why, and moving away is not a retry.\n const onBlur = (e: FocusEvent<HTMLDivElement>) => {\n if (e.currentTarget.contains(e.relatedTarget as Node | null)) return;\n if (blurTimer.current) clearTimeout(blurTimer.current);\n blurTimer.current = setTimeout(() => {\n blurTimer.current = null;\n if (!mounted.current || failed) return;\n save();\n }, 0);\n };\n const onFocus = () => {\n if (blurTimer.current) clearTimeout(blurTimer.current);\n blurTimer.current = null;\n };\n\n const private_ = redact ? { \"data-private\": true } : undefined;\n const shown = display ? display(value) : value === null || value === undefined ? \"\" : String(value);\n const content = hasContent(shown) ? (\n shown\n ) : (\n <span className=\"text-[var(--text-muted)]\">{placeholder ?? labels.empty}</span>\n );\n const alignClass = align === \"end\" ? \"text-end\" : \"text-start\";\n\n let body: ReactNode;\n if (readOnly) {\n body = (\n <span {...private_} className={cn(\"block min-w-0 truncate\", alignClass)}>\n {content}\n </span>\n );\n } else if (editing) {\n const describedBy = failed ? errorId : undefined;\n const editorProps: InlineEditorProps<T> = {\n value: draft,\n onChange: change,\n commit: save,\n cancel,\n pending,\n label,\n invalid: failed,\n describedBy,\n inputProps: {\n \"aria-label\": label,\n \"aria-invalid\": failed || undefined,\n \"aria-describedby\": describedBy,\n readOnly: pending,\n },\n };\n body = (\n // A wrapper for the keys and the focus, not a control: the keys belong to the\n // field inside it, which is what has focus.\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions -- see above\n <div\n ref={editorRef}\n {...private_}\n onKeyDown={onKeyDown}\n onBlur={onBlur}\n onFocus={onFocus}\n aria-busy={pending || undefined}\n className=\"min-w-0\"\n >\n <div className=\"flex min-w-0 items-center gap-1.5\">\n <div className=\"min-w-0 flex-1\">\n {editor ? (\n <RenderEditor render={editor} {...editorProps} />\n ) : (\n <Input\n {...inputProps}\n {...editorProps.inputProps}\n value={String(draft ?? \"\")}\n onChange={(e) => change(e.target.value as unknown as T)}\n className={cn(\"px-2 py-1\", alignClass, inputProps?.className)}\n />\n )}\n </div>\n {/* Decorative: `aria-busy` on the wrapper says it. */}\n {pending && <Spinner label={null} className=\"size-4 shrink-0\" />}\n </div>\n {failed && (\n <p id={errorId} className=\"mt-1 text-[11px] leading-tight text-[var(--danger)]\">\n {failure}\n </p>\n )}\n </div>\n );\n } else if (locked) {\n // Button's `disabledReason` path, spelled out for a button that must look like\n // the value rather than like a Button: focusable, `aria-disabled`, every\n // activation swallowed, the reason in the kit Tooltip and in a `hidden` copy that\n // describes it. The button in a FRAGMENT so the Tooltip does not add the bubble as\n // a second description of the same sentence.\n body = (\n <Tooltip label={disabledReason} className=\"flex w-full min-w-0\">\n <>\n <button\n ref={displayRef}\n type=\"button\"\n {...private_}\n aria-disabled\n aria-describedby={reasonId}\n onClick={(e) => e.preventDefault()}\n className={cn(\n \"block w-full min-w-0 cursor-not-allowed truncate rounded-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--brand)]\",\n alignClass,\n )}\n >\n {content}\n </button>\n <span id={reasonId} hidden>\n {disabledReason}\n </span>\n </>\n </Tooltip>\n );\n } else {\n body = (\n // Lazy: a table of these mounts no bubble until one is hovered or focused, and\n // the closed bubble's text is in no ancestor's accessible name.\n <Tooltip label={labels.edit(label)} lazy className=\"flex w-full min-w-0\">\n <button\n ref={displayRef}\n type=\"button\"\n {...private_}\n onClick={() => setOpen(true)}\n className={cn(\n \"block w-full min-w-0 truncate rounded-sm underline-offset-2 hover:underline focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--brand)]\",\n alignClass,\n )}\n >\n {content}\n </button>\n </Tooltip>\n );\n }\n\n return (\n <div className={cn(\"min-w-0\", className)} data-editing={editing || undefined}>\n {body}\n {/* Always mounted: a live region that mounts with its message is usually missed. */}\n <span {...alert.regionProps} />\n </div>\n );\n}\n"],"mappings":";AAyZI,SA0EI,UA1EJ,KA0CI,YA1CJ;AAzZJ,SAAS,WAAW,OAAO,QAAQ,gBAAgB;AAEnD,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,OAAO,eAAe;AAC/B,SAAS,eAAe;AACxB,SAAS,uBAAuB;AAgBzB,MAAM,6BAA+C;AAAA,EAC1D,MAAM,CAAC,UAAU,QAAQ,KAAK;AAAA,EAC9B,QAAQ;AAAA,EACR,OAAO;AACT;AAqHA,SAAS,WAAW,MAA0B;AAC5C,SAAO,SAAS,UAAa,SAAS,QAAQ,SAAS,SAAS,SAAS;AAC3E;AAMA,SAAS,aAAgB,EAAE,QAAQ,GAAG,MAAM,GAAuD;AACjG,SAAO,OAAO,KAAK;AACrB;AAGA,SAAS,UAAU,QAA0C;AAC3D,SAAO,UAAU,OAAQ,OAA4B,SAAS,aAAc,SAA8B;AAC5G;AAmCO,SAAS,gBAA4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AEJ;","names":[]}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { KitLanguageCode, KitLanguage } from '../i18n/languages.js';
|
|
3
|
+
import { bg as SelectProps } from '../kit-labels-R8mIAc9N.js';
|
|
4
|
+
import '../shell/topbar-controls.js';
|
|
5
|
+
import '../theme/palette-presets.js';
|
|
6
|
+
import '../theme/chart-palette.js';
|
|
7
|
+
import '../theme/theme-store.js';
|
|
8
|
+
import 'zustand/middleware';
|
|
9
|
+
import 'zustand';
|
|
10
|
+
import '../data-table-labels-B7OdnM0S.js';
|
|
11
|
+
import './data-table-sort.js';
|
|
12
|
+
import './swipeable-row.js';
|
|
13
|
+
import './mini-calendar.js';
|
|
14
|
+
import './calendar-heatmap.js';
|
|
15
|
+
import './popover.js';
|
|
16
|
+
import './chip.js';
|
|
17
|
+
import 'lucide-react';
|
|
18
|
+
import './field-sync.js';
|
|
19
|
+
import './tooltip.js';
|
|
20
|
+
import '../hooks/use-anchored-rect.js';
|
|
21
|
+
import '../lib/clipping.js';
|
|
22
|
+
import '../wizard/types.js';
|
|
23
|
+
import '../tour/tour.js';
|
|
24
|
+
import '../search/command-palette.js';
|
|
25
|
+
import '../search/global-search.js';
|
|
26
|
+
import '../search/search-index.js';
|
|
27
|
+
import './month-picker.js';
|
|
28
|
+
import './page-contents.js';
|
|
29
|
+
import './series-chart-labels.js';
|
|
30
|
+
import './pie-chart-labels.js';
|
|
31
|
+
import './sparkline.js';
|
|
32
|
+
import './stat-tile.js';
|
|
33
|
+
import './signature-pad.js';
|
|
34
|
+
import './password-strength.js';
|
|
35
|
+
import './swatch-picker.js';
|
|
36
|
+
import './tile-radio.js';
|
|
37
|
+
import './icon-picker.js';
|
|
38
|
+
import './dialog-frame.js';
|
|
39
|
+
import './modal.js';
|
|
40
|
+
import '../hooks/use-search-param-state.js';
|
|
41
|
+
import './measured-grid.js';
|
|
42
|
+
import '../feedback-attachment-NhUm7Zga.js';
|
|
43
|
+
import '../feedback/feedback-thread.js';
|
|
44
|
+
import '../feedback/feedback-inbox.js';
|
|
45
|
+
import './account-settings-labels.js';
|
|
46
|
+
import './floating-panel.js';
|
|
47
|
+
import './bulk-action-bar.js';
|
|
48
|
+
import './list.js';
|
|
49
|
+
import './signed-amount.js';
|
|
50
|
+
import './breadcrumbs.js';
|
|
51
|
+
import './toast.js';
|
|
52
|
+
import './description-list.js';
|
|
53
|
+
import './line-items.js';
|
|
54
|
+
import './progress-bar.js';
|
|
55
|
+
import './error-boundary.js';
|
|
56
|
+
import './authed-image.js';
|
|
57
|
+
import '../hooks/use-authed-src.js';
|
|
58
|
+
import './image-grid.js';
|
|
59
|
+
import './lightbox.js';
|
|
60
|
+
import './write-lock.js';
|
|
61
|
+
import './legal.js';
|
|
62
|
+
import './account-chips.js';
|
|
63
|
+
import '../lib/format.js';
|
|
64
|
+
import './reauth-dialog.js';
|
|
65
|
+
import './server-wake.js';
|
|
66
|
+
import '../lib/server-wake.js';
|
|
67
|
+
import './translation-review-labels.js';
|
|
68
|
+
import '../lib/translation-review.js';
|
|
69
|
+
import './country-select.js';
|
|
70
|
+
import './inline-edit-field.js';
|
|
71
|
+
import '../lib/iban.js';
|
|
72
|
+
import '../lib/phone.js';
|
|
73
|
+
import './sign-chip.js';
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* A language as a FORM FIELD: one of the codes an app offers, picked in a form beside
|
|
77
|
+
* other fields — label, hint and error like every kit field, controlled, submitted with
|
|
78
|
+
* the rest.
|
|
79
|
+
*
|
|
80
|
+
* Kurvenschmiede's admin invites people by mail, and the invitation goes out in a
|
|
81
|
+
* language the admin picks, because the invitee has no account yet to say theirs
|
|
82
|
+
* (allowlist-panel.tsx: a `Select` with an `<option>` per language, spelled out by
|
|
83
|
+
* hand). Neither language control the kit had fits there: `LanguageMenu` is the top
|
|
84
|
+
* bar's switcher for the reader's OWN language, a flag in a hover menu that changes the
|
|
85
|
+
* page the moment it is picked; `LanguageSetting` is the settings row for the same
|
|
86
|
+
* thing and takes ready-made `{ code, label }` rows. This one is for a language that
|
|
87
|
+
* belongs to something else — an invitation, a mail template, a customer's
|
|
88
|
+
* correspondence — and takes only the CODES: the names come from the kit's registry
|
|
89
|
+
* ({@link languageOptions}), the same "Deutsch", "Français", "简体中文" the switcher shows.
|
|
90
|
+
*
|
|
91
|
+
* Every {@link Select} prop passes through (`label`, `hint`, `error`, `required`,
|
|
92
|
+
* `disabled`, `size`, `name`, `id`, `data-*`); only `value`, `onChange` and the options
|
|
93
|
+
* are this component's.
|
|
94
|
+
*
|
|
95
|
+
* WHAT IT SHOWS FOR `value`. The offered code that answers it, by
|
|
96
|
+
* {@link resolveLanguage}'s rule: so i18next's `resolvedLanguage` can be handed in as it
|
|
97
|
+
* comes, and a stored `de` or `de-AT` shows as the one German, `de-CH`. A value that
|
|
98
|
+
* answers to none of the codes shows the fallback `resolveLanguage` would pick (`de-CH`
|
|
99
|
+
* when offered, else the first code) — where a bare native select would show its first
|
|
100
|
+
* option and say nothing. Either way the field does not write the resolved code back:
|
|
101
|
+
* `onChange` fires when the person picks, as on any field. Keep `value` one of `codes`
|
|
102
|
+
* (resolve it once, where the state starts) and what is shown is what is submitted.
|
|
103
|
+
*
|
|
104
|
+
* Each name is marked with its own language (`lang`), so a screen reader says
|
|
105
|
+
* "Français" in French rather than spelling it in the page's voice. A caller's
|
|
106
|
+
* `optionLabel` (English names for a team-facing list) is in the page's language, and
|
|
107
|
+
* goes unmarked.
|
|
108
|
+
*/
|
|
109
|
+
interface LanguageSelectProps extends Omit<SelectProps, "value" | "onChange" | "children" | "multiple"> {
|
|
110
|
+
/** The chosen language: one of `codes` — or any tag, shown as the code it resolves to. */
|
|
111
|
+
value: string;
|
|
112
|
+
/** The picked code — always one of `codes`. */
|
|
113
|
+
onChange: (code: KitLanguageCode) => void;
|
|
114
|
+
/** The languages to offer, in the order to list them. Default: all seven
|
|
115
|
+
* ({@link KIT_LANGUAGES}' order, alphabetical by native name). */
|
|
116
|
+
codes?: readonly KitLanguageCode[];
|
|
117
|
+
/**
|
|
118
|
+
* The text of each option. Default: the language's name in itself — the right name
|
|
119
|
+
* for a reader looking for theirs, and for an admin choosing what an invitee reads.
|
|
120
|
+
* `(language) => language.englishName` for a list read by a team rather than by the
|
|
121
|
+
* language's readers (a reviewer grant), or the app's own words for a code.
|
|
122
|
+
*/
|
|
123
|
+
optionLabel?: (language: KitLanguage) => string;
|
|
124
|
+
}
|
|
125
|
+
declare const LanguageSelect: react.ForwardRefExoticComponent<LanguageSelectProps & react.RefAttributes<HTMLSelectElement>>;
|
|
126
|
+
|
|
127
|
+
export { LanguageSelect, type LanguageSelectProps };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import { KIT_LANGUAGES, languageOptions, resolveLanguage } from "../i18n/languages.js";
|
|
5
|
+
import { Select } from "./ui.js";
|
|
6
|
+
const ALL_CODES = KIT_LANGUAGES.map((language) => language.code);
|
|
7
|
+
const LanguageSelect = forwardRef(function LanguageSelect2({ value, onChange, codes = ALL_CODES, optionLabel, ...rest }, ref) {
|
|
8
|
+
const shown = resolveLanguage([value], codes);
|
|
9
|
+
return /* @__PURE__ */ jsx(Select, { ...rest, ref, value: shown, onChange: (e) => onChange(e.target.value), children: languageOptions(codes).map((option) => {
|
|
10
|
+
const language = KIT_LANGUAGES.find((entry) => entry.code === option.code);
|
|
11
|
+
return /* @__PURE__ */ jsx("option", { value: option.code, lang: optionLabel ? void 0 : language.formatLocale, children: optionLabel ? optionLabel(language) : option.label }, option.code);
|
|
12
|
+
}) });
|
|
13
|
+
});
|
|
14
|
+
LanguageSelect.displayName = "LanguageSelect";
|
|
15
|
+
export {
|
|
16
|
+
LanguageSelect
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=language-select.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/language-select.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport { KIT_LANGUAGES, languageOptions, resolveLanguage } from \"../i18n/languages\";\nimport type { KitLanguage, KitLanguageCode } from \"../i18n/languages\";\nimport { Select } from \"./ui\";\nimport type { SelectProps } from \"./ui\";\n\n/**\n * A language as a FORM FIELD: one of the codes an app offers, picked in a form beside\n * other fields — label, hint and error like every kit field, controlled, submitted with\n * the rest.\n *\n * Kurvenschmiede's admin invites people by mail, and the invitation goes out in a\n * language the admin picks, because the invitee has no account yet to say theirs\n * (allowlist-panel.tsx: a `Select` with an `<option>` per language, spelled out by\n * hand). Neither language control the kit had fits there: `LanguageMenu` is the top\n * bar's switcher for the reader's OWN language, a flag in a hover menu that changes the\n * page the moment it is picked; `LanguageSetting` is the settings row for the same\n * thing and takes ready-made `{ code, label }` rows. This one is for a language that\n * belongs to something else — an invitation, a mail template, a customer's\n * correspondence — and takes only the CODES: the names come from the kit's registry\n * ({@link languageOptions}), the same \"Deutsch\", \"Français\", \"简体中文\" the switcher shows.\n *\n * Every {@link Select} prop passes through (`label`, `hint`, `error`, `required`,\n * `disabled`, `size`, `name`, `id`, `data-*`); only `value`, `onChange` and the options\n * are this component's.\n *\n * WHAT IT SHOWS FOR `value`. The offered code that answers it, by\n * {@link resolveLanguage}'s rule: so i18next's `resolvedLanguage` can be handed in as it\n * comes, and a stored `de` or `de-AT` shows as the one German, `de-CH`. A value that\n * answers to none of the codes shows the fallback `resolveLanguage` would pick (`de-CH`\n * when offered, else the first code) — where a bare native select would show its first\n * option and say nothing. Either way the field does not write the resolved code back:\n * `onChange` fires when the person picks, as on any field. Keep `value` one of `codes`\n * (resolve it once, where the state starts) and what is shown is what is submitted.\n *\n * Each name is marked with its own language (`lang`), so a screen reader says\n * \"Français\" in French rather than spelling it in the page's voice. A caller's\n * `optionLabel` (English names for a team-facing list) is in the page's language, and\n * goes unmarked.\n */\nexport interface LanguageSelectProps extends Omit<SelectProps, \"value\" | \"onChange\" | \"children\" | \"multiple\"> {\n /** The chosen language: one of `codes` — or any tag, shown as the code it resolves to. */\n value: string;\n /** The picked code — always one of `codes`. */\n onChange: (code: KitLanguageCode) => void;\n /** The languages to offer, in the order to list them. Default: all seven\n * ({@link KIT_LANGUAGES}' order, alphabetical by native name). */\n codes?: readonly KitLanguageCode[];\n /**\n * The text of each option. Default: the language's name in itself — the right name\n * for a reader looking for theirs, and for an admin choosing what an invitee reads.\n * `(language) => language.englishName` for a list read by a team rather than by the\n * language's readers (a reviewer grant), or the app's own words for a code.\n */\n optionLabel?: (language: KitLanguage) => string;\n}\n\nconst ALL_CODES: readonly KitLanguageCode[] = KIT_LANGUAGES.map((language) => language.code);\n\nexport const LanguageSelect = forwardRef<HTMLSelectElement, LanguageSelectProps>(function LanguageSelect(\n { value, onChange, codes = ALL_CODES, optionLabel, ...rest },\n ref,\n) {\n const shown = resolveLanguage([value], codes);\n return (\n <Select {...rest} ref={ref} value={shown} onChange={(e) => onChange(e.target.value as KitLanguageCode)}>\n {languageOptions(codes).map((option) => {\n const language = KIT_LANGUAGES.find((entry) => entry.code === option.code)!;\n return (\n <option key={option.code} value={option.code} lang={optionLabel ? undefined : language.formatLocale}>\n {optionLabel ? optionLabel(language) : option.label}\n </option>\n );\n })}\n </Select>\n );\n});\nLanguageSelect.displayName = \"LanguageSelect\";\n"],"mappings":";AAqEU;AArEV,SAAS,kBAAkB;AAC3B,SAAS,eAAe,iBAAiB,uBAAuB;AAEhE,SAAS,cAAc;AAsDvB,MAAM,YAAwC,cAAc,IAAI,CAAC,aAAa,SAAS,IAAI;AAEpF,MAAM,iBAAiB,WAAmD,SAASA,gBACxF,EAAE,OAAO,UAAU,QAAQ,WAAW,aAAa,GAAG,KAAK,GAC3D,KACA;AACA,QAAM,QAAQ,gBAAgB,CAAC,KAAK,GAAG,KAAK;AAC5C,SACE,oBAAC,UAAQ,GAAG,MAAM,KAAU,OAAO,OAAO,UAAU,CAAC,MAAM,SAAS,EAAE,OAAO,KAAwB,GAClG,0BAAgB,KAAK,EAAE,IAAI,CAAC,WAAW;AACtC,UAAM,WAAW,cAAc,KAAK,CAAC,UAAU,MAAM,SAAS,OAAO,IAAI;AACzE,WACE,oBAAC,YAAyB,OAAO,OAAO,MAAM,MAAM,cAAc,SAAY,SAAS,cACpF,wBAAc,YAAY,QAAQ,IAAI,OAAO,SADnC,OAAO,IAEpB;AAAA,EAEJ,CAAC,GACH;AAEJ,CAAC;AACD,eAAe,cAAc;","names":["LanguageSelect"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { ComponentPropsWithoutRef, ReactNode, Key } from 'react';
|
|
2
|
+
import { ComponentPropsWithoutRef, ReactNode, Key, HTMLAttributes } from 'react';
|
|
3
3
|
|
|
4
4
|
/** The words {@link LineItems} renders on its own behalf. Row numbers are 1-based. */
|
|
5
5
|
interface LineItemsLabels {
|
|
@@ -97,6 +97,14 @@ interface LineItemsColumn<T> {
|
|
|
97
97
|
narrowSpan?: 1 | 2;
|
|
98
98
|
render: (ctx: LineItemCellContext<T>) => ReactNode;
|
|
99
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* What {@link LineItemsProps.rowProps} returns for one row: `data-*` hooks, an `id`, a
|
|
102
|
+
* class, handlers. A `data-*` attribute is typed so `{ "data-tour": "rule-condition" }`
|
|
103
|
+
* needs no cast.
|
|
104
|
+
*/
|
|
105
|
+
type LineItemsRowProps = Omit<HTMLAttributes<HTMLDivElement>, "children" | "dangerouslySetInnerHTML" | "role"> & {
|
|
106
|
+
[key: `data-${string}`]: string | number | boolean | undefined;
|
|
107
|
+
};
|
|
100
108
|
interface LineItemsProps<T> extends Omit<ComponentPropsWithoutRef<"div">, "children"> {
|
|
101
109
|
items: readonly T[];
|
|
102
110
|
columns: readonly LineItemsColumn<T>[];
|
|
@@ -155,6 +163,20 @@ interface LineItemsProps<T> extends Omit<ComponentPropsWithoutRef<"div">, "child
|
|
|
155
163
|
removeAlign?: LineItemsRemoveAlign;
|
|
156
164
|
/** Disables add and remove (the fields are the caller's to disable). */
|
|
157
165
|
disabled?: boolean;
|
|
166
|
+
/**
|
|
167
|
+
* Extra attributes for one row's element (the `role="group"` that holds its fields) —
|
|
168
|
+
* keksdose K20: its rule editor's tour points at the first condition row with
|
|
169
|
+
* `[data-tour="rule-condition"]` (dev#495), and with nowhere to put the anchor on the
|
|
170
|
+
* row it wrapped a cell's field in a `span` instead, which the spotlight then drew
|
|
171
|
+
* around one field rather than the row. Test ids the same way.
|
|
172
|
+
*
|
|
173
|
+
* MERGED under the list's own, which win: `role`, the group's `aria-label` (that is
|
|
174
|
+
* {@link rowLabel}'s) and `data-line-items-row` stay the list's — the row's name and
|
|
175
|
+
* the hook its focus handling finds rows by. `className` is added after the row's
|
|
176
|
+
* own classes, `style` is passed through, and an `onKeyDown` runs BEFORE the row's
|
|
177
|
+
* Ctrl/⌘+Enter "add a row" (call `preventDefault()` to keep that from happening).
|
|
178
|
+
*/
|
|
179
|
+
rowProps?: (item: T, index: number) => LineItemsRowProps | undefined;
|
|
158
180
|
labels?: Partial<LineItemsLabels>;
|
|
159
181
|
}
|
|
160
182
|
/**
|
|
@@ -184,6 +206,6 @@ interface LineItemsProps<T> extends Omit<ComponentPropsWithoutRef<"div">, "child
|
|
|
184
206
|
* the row that took its place (else the add button). Ctrl/⌘+Enter in any row adds a
|
|
185
207
|
* row.
|
|
186
208
|
*/
|
|
187
|
-
declare function LineItems<T>({ items, columns, getKey, onAdd, onRemove, minItems, maxItems, confirmRemove, addLabel, rowLabel, totals, totalsLabel, empty, error, summary, fieldLabels, narrowColumns, removePlacement, removeAlign: removeAlignProp, disabled, labels: labelsProp, className, style, ...rest }: LineItemsProps<T>): react.JSX.Element;
|
|
209
|
+
declare function LineItems<T>({ items, columns, getKey, onAdd, onRemove, minItems, maxItems, confirmRemove, addLabel, rowLabel, totals, totalsLabel, empty, error, summary, fieldLabels, narrowColumns, removePlacement, removeAlign: removeAlignProp, disabled, rowProps, labels: labelsProp, className, style, ...rest }: LineItemsProps<T>): react.JSX.Element;
|
|
188
210
|
|
|
189
|
-
export { DEFAULT_LINE_ITEMS_LABELS, type LineItemCellContext, LineItems, type LineItemsColumn, type LineItemsFieldLabels, type LineItemsLabels, type LineItemsProps, type LineItemsRemoveAlign, type LineItemsRemovePlacement, type LineItemsSummary, type LineItemsSummaryTone };
|
|
211
|
+
export { DEFAULT_LINE_ITEMS_LABELS, type LineItemCellContext, LineItems, type LineItemsColumn, type LineItemsFieldLabels, type LineItemsLabels, type LineItemsProps, type LineItemsRemoveAlign, type LineItemsRemovePlacement, type LineItemsRowProps, type LineItemsSummary, type LineItemsSummaryTone };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { createElement } from "react";
|
|
3
4
|
import { useCallback, useLayoutEffect, useRef, useState } from "react";
|
|
4
5
|
import { Plus, Trash2 } from "lucide-react";
|
|
5
6
|
import { cn } from "../lib/cn.js";
|
|
@@ -60,6 +61,7 @@ function LineItems({
|
|
|
60
61
|
removePlacement = "row",
|
|
61
62
|
removeAlign: removeAlignProp,
|
|
62
63
|
disabled = false,
|
|
64
|
+
rowProps,
|
|
63
65
|
labels: labelsProp,
|
|
64
66
|
className,
|
|
65
67
|
style,
|
|
@@ -187,71 +189,78 @@ function LineItems({
|
|
|
187
189
|
items.map((item, index) => {
|
|
188
190
|
const row = index + 1;
|
|
189
191
|
const isConfirming = confirming === index;
|
|
192
|
+
const extra = rowProps?.(item, index);
|
|
190
193
|
return (
|
|
191
194
|
// The row's Ctrl/⌘+Enter is a shortcut for the add button, which is itself
|
|
192
195
|
// reachable by Tab; the group only listens for it bubbling from its fields.
|
|
193
196
|
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
|
|
194
|
-
/* @__PURE__ */
|
|
197
|
+
/* @__PURE__ */ createElement(
|
|
195
198
|
"div",
|
|
196
199
|
{
|
|
200
|
+
...extra,
|
|
201
|
+
key: getKey(item, index),
|
|
197
202
|
ref: (el) => {
|
|
198
203
|
rowRefs.current[index] = el;
|
|
199
204
|
},
|
|
200
205
|
role: "group",
|
|
201
206
|
"aria-label": rowLabel ? rowLabel(index, item) : labels.row(row),
|
|
202
207
|
"data-line-items-row": "",
|
|
203
|
-
onKeyDown:
|
|
208
|
+
onKeyDown: (e) => {
|
|
209
|
+
if (extra?.onKeyDown) {
|
|
210
|
+
extra.onKeyDown(e);
|
|
211
|
+
if (e.defaultPrevented) return;
|
|
212
|
+
}
|
|
213
|
+
onRowKeyDown(e);
|
|
214
|
+
},
|
|
204
215
|
className: cn(
|
|
205
216
|
"grid grid-cols-1 gap-2 @lg:grid-cols-[var(--line-items-cols)] @lg:items-start",
|
|
206
217
|
// Two short fields to a row of the card — from 18rem, where two fields
|
|
207
218
|
// still fit a figure each; on anything narrower they stack after all.
|
|
208
219
|
pairs && "@2xs:grid-cols-2",
|
|
209
220
|
// Stacked, each row is a card of its own so the rows stay apart.
|
|
210
|
-
"@max-lg:rounded-md @max-lg:border @max-lg:border-[var(--border)] @max-lg:p-3"
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
columns.map((column) => {
|
|
214
|
-
const floating = floats(column);
|
|
215
|
-
const isLast = inline && column === lastColumn;
|
|
216
|
-
const span = pairs && column.narrowSpan === 2 && "@2xs:col-span-2 @lg:col-span-1";
|
|
217
|
-
const cell = /* @__PURE__ */ jsxs(
|
|
218
|
-
"div",
|
|
219
|
-
{
|
|
220
|
-
className: cn(
|
|
221
|
-
"min-w-0 space-y-1 @lg:space-y-0",
|
|
222
|
-
// The wide grid places every cell in its own track again.
|
|
223
|
-
isLast ? "flex-1" : span
|
|
224
|
-
),
|
|
225
|
-
children: [
|
|
226
|
-
!floating && /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "block text-xs font-medium text-[var(--text-muted)] @lg:hidden", children: column.header }),
|
|
227
|
-
column.render({
|
|
228
|
-
item,
|
|
229
|
-
index,
|
|
230
|
-
label: labels.cell(columnName(column), row),
|
|
231
|
-
fieldLabel: floating ? columnName(column) : void 0
|
|
232
|
-
})
|
|
233
|
-
]
|
|
234
|
-
},
|
|
235
|
-
column.key
|
|
236
|
-
);
|
|
237
|
-
if (!isLast) return cell;
|
|
238
|
-
return /* @__PURE__ */ jsxs(
|
|
239
|
-
"div",
|
|
240
|
-
{
|
|
241
|
-
"data-line-items-inline": "",
|
|
242
|
-
className: cn("flex min-w-0 gap-2 @lg:contents", floating ? "items-center" : "items-end", span),
|
|
243
|
-
children: [
|
|
244
|
-
cell,
|
|
245
|
-
removeCell(index, row, isConfirming)
|
|
246
|
-
]
|
|
247
|
-
},
|
|
248
|
-
column.key
|
|
249
|
-
);
|
|
250
|
-
}),
|
|
251
|
-
onRemove && !inline && removeCell(index, row, isConfirming)
|
|
252
|
-
]
|
|
221
|
+
"@max-lg:rounded-md @max-lg:border @max-lg:border-[var(--border)] @max-lg:p-3",
|
|
222
|
+
extra?.className
|
|
223
|
+
)
|
|
253
224
|
},
|
|
254
|
-
|
|
225
|
+
columns.map((column) => {
|
|
226
|
+
const floating = floats(column);
|
|
227
|
+
const isLast = inline && column === lastColumn;
|
|
228
|
+
const span = pairs && column.narrowSpan === 2 && "@2xs:col-span-2 @lg:col-span-1";
|
|
229
|
+
const cell = /* @__PURE__ */ jsxs(
|
|
230
|
+
"div",
|
|
231
|
+
{
|
|
232
|
+
className: cn(
|
|
233
|
+
"min-w-0 space-y-1 @lg:space-y-0",
|
|
234
|
+
// The wide grid places every cell in its own track again.
|
|
235
|
+
isLast ? "flex-1" : span
|
|
236
|
+
),
|
|
237
|
+
children: [
|
|
238
|
+
!floating && /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "block text-xs font-medium text-[var(--text-muted)] @lg:hidden", children: column.header }),
|
|
239
|
+
column.render({
|
|
240
|
+
item,
|
|
241
|
+
index,
|
|
242
|
+
label: labels.cell(columnName(column), row),
|
|
243
|
+
fieldLabel: floating ? columnName(column) : void 0
|
|
244
|
+
})
|
|
245
|
+
]
|
|
246
|
+
},
|
|
247
|
+
column.key
|
|
248
|
+
);
|
|
249
|
+
if (!isLast) return cell;
|
|
250
|
+
return /* @__PURE__ */ jsxs(
|
|
251
|
+
"div",
|
|
252
|
+
{
|
|
253
|
+
"data-line-items-inline": "",
|
|
254
|
+
className: cn("flex min-w-0 gap-2 @lg:contents", floating ? "items-center" : "items-end", span),
|
|
255
|
+
children: [
|
|
256
|
+
cell,
|
|
257
|
+
removeCell(index, row, isConfirming)
|
|
258
|
+
]
|
|
259
|
+
},
|
|
260
|
+
column.key
|
|
261
|
+
);
|
|
262
|
+
}),
|
|
263
|
+
onRemove && !inline && removeCell(index, row, isConfirming)
|
|
255
264
|
)
|
|
256
265
|
);
|
|
257
266
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/line-items.tsx"],"sourcesContent":["import { useCallback, useLayoutEffect, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, CSSProperties, KeyboardEvent, Key, ReactNode } from \"react\";\nimport { Plus, Trash2 } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { useKitLabels } from \"../i18n/kit-labels\";\nimport { Button, IconButton } from \"./ui\";\n\n/** The words {@link LineItems} renders on its own behalf. Row numbers are 1-based. */\nexport interface LineItemsLabels {\n /** The dashed add button. */\n add: string;\n /** The remove button's name for one row. */\n remove: (row: number) => string;\n /** Its name while it waits for the second press (`confirmRemove`). */\n confirmRemove: (row: number) => string;\n /** A row's group name, when the caller gives no `rowLabel`. */\n row: (row: number) => string;\n /** The name a cell's field should carry: the column, and which row. */\n cell: (column: string, row: number) => string;\n /** The totals row's label, and its group name. */\n totals: string;\n}\n\nexport const DEFAULT_LINE_ITEMS_LABELS: LineItemsLabels = {\n add: \"Add row\",\n remove: (row) => `Remove row ${row}`,\n confirmRemove: (row) => `Remove row ${row}? Press again to confirm`,\n row: (row) => `Row ${row}`,\n cell: (column, row) => `${column}, row ${row}`,\n totals: \"Total\",\n};\n\n/** What a column's `render` receives for one row. */\nexport interface LineItemCellContext<T> {\n item: T;\n /** 0-based. */\n index: number;\n /** The accessible name for the cell's field — \"Debit, row 2\". The header is\n * hidden from assistive tech (each row repeats it), so the field has to carry it:\n * `<Input aria-label={label} … />`. */\n label: string;\n /** The column's own name (\"Debit\") for the field's VISIBLE label — set only when the\n * cell's labels are `\"floating\"` (see {@link LineItemsProps.fieldLabels}), so one\n * render serves both modes: `<Input label={fieldLabel} aria-label={label} … />`.\n * Undefined there, the Input stays a bare compact control; set, it floats \"Debit\"\n * while `aria-label` still says which row. */\n fieldLabel?: string;\n}\n\n/** How a cell's field is labelled. `aria`: the field is a bare control named by\n * `aria-label`, under a header row (stacked: a small copy of the header over it).\n * `floating`: the field shows its own floating label ({@link LineItemCellContext.fieldLabel}),\n * so the list draws no header for it. */\nexport type LineItemsFieldLabels = \"aria\" | \"floating\";\n\n/** The colour of a {@link LineItemsSummary}'s value — a verdict (`success` /\n * `danger`), quiet (`muted`), or the money pair (`income` / `expense`, the colours\n * `SignedAmount` draws a figure in) for a remainder that reads as the row it settles. */\nexport type LineItemsSummaryTone = \"neutral\" | \"success\" | \"danger\" | \"muted\" | \"income\" | \"expense\";\n\n/**\n * A line under the lines that says where they stand — a split's remainder (\"Left to\n * assign CHF 0.00\", green at zero, red otherwise, muted while the total is not known\n * yet), with an optional action that settles it (\"Set amount to total\").\n */\nexport interface LineItemsSummary {\n label: ReactNode;\n value?: ReactNode;\n /** The value's colour. Default `neutral`. The label stays neutral: the colour is a\n * second signal, never the only one — the value and label carry the meaning.\n * With no `value` the line is a state on its own (\"Waiting for the total\"), and\n * the tone colours the label instead — `muted` quiets the whole line. */\n tone?: LineItemsSummaryTone;\n /** Beside the value: a chip or badge that names the state (\"Balanced\" next to a\n * journal entry's zero difference). */\n status?: ReactNode;\n /** A small button at the end of the line. Disabled along with the list's\n * `disabled`. `variant`: `secondary` (default) is a boxed button; `link` a muted\n * text link, for an action that is an aside rather than the way to settle it. */\n action?: { label: ReactNode; onClick: () => void; disabled?: boolean; variant?: \"secondary\" | \"link\" };\n}\n\n/** Where a row's remove button sits. `row` (default): stacked, a row of the card to\n * itself (paired, the whole width); wide, its own track. `inline`: stacked, beside\n * the row's last field (\"category + amount\" over \"memo + delete\"); wide, unchanged. */\nexport type LineItemsRemovePlacement = \"row\" | \"inline\";\n\n/** How the remove button sits in the height of a wide row: at its top, centred, or at\n * its foot. */\nexport type LineItemsRemoveAlign = \"start\" | \"center\" | \"end\";\n\nexport interface LineItemsColumn<T> {\n /** Stable id: the React key, and the key into `totals`. */\n key: string;\n /** The column header (and the small label over the cell once the rows stack). */\n header: ReactNode;\n /** The column's name for {@link LineItemCellContext.label}, when `header` is not a\n * string. */\n label?: string;\n /** The grid track once the rows are wide enough to be a table. Default\n * `minmax(0,1fr)`; `\"7rem\"` for an amount. */\n width?: string;\n /** `end` for figures: the header and the totals cell end-align with the field. */\n align?: \"start\" | \"end\";\n /** This column's labelling, over the list's {@link LineItemsProps.fieldLabels} — a\n * read-only \"Sum\" cell in a floating list keeps its header with `\"aria\"`. */\n fieldLabels?: LineItemsFieldLabels;\n /** With {@link LineItemsProps.narrowColumns} `2`: `2` gives the cell a whole row of\n * the stacked card (a description), where short fields pair up two to a row.\n * Default `1`. No effect on the wide grid. */\n narrowSpan?: 1 | 2;\n render: (ctx: LineItemCellContext<T>) => ReactNode;\n}\n\nexport interface LineItemsProps<T> extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n items: readonly T[];\n columns: readonly LineItemsColumn<T>[];\n /** The row's React key. Default: the item's `id` (react-hook-form's `useFieldArray`\n * `fields` carry one), else its index. */\n getKey?: (item: T, index: number) => Key;\n /** Append a row. Omitted: no add button. The first field of the new row is focused. */\n onAdd?: () => void;\n /** Remove the row at `index`. Omitted: no remove buttons. */\n onRemove?: (index: number) => void;\n /** Remove is disabled at or below this many rows (a journal entry needs two).\n * Default 0. */\n minItems?: number;\n /** Add is disabled at this many rows. */\n maxItems?: number;\n /**\n * Ask before a row goes:\n * - `true`: the remove button asks for a second press — it fills red and its name\n * becomes `lineItems.confirmRemove`; Escape, or leaving it, calls it off.\n * - a function: called with the row, and the row goes only if it answers `true`\n * (`(item, i) => confirm({ title: … , tone: \"danger\" })` with `useConfirm`).\n */\n confirmRemove?: boolean | ((item: T, index: number) => boolean | Promise<boolean>);\n /** The add button's text. Default `lineItems.add`. */\n addLabel?: ReactNode;\n /** A row's group name (\"Line 2\"). Default `lineItems.row`. */\n rowLabel?: (index: number, item: T) => string;\n /** A totals row under the lines, one entry per column `key`. The first column\n * without an entry carries {@link totalsLabel}. Omitted: no totals row. */\n totals?: Partial<Record<string, ReactNode>>;\n /** Default `lineItems.totals`, \"Total\". */\n totalsLabel?: ReactNode;\n /** Shown in place of the rows when there are none. */\n empty?: ReactNode;\n /** A message about the list as a whole (\"The entry does not balance\"). */\n error?: ReactNode;\n /** A line under the lines and totals — the remainder of a split, say. See\n * {@link LineItemsSummary}. */\n summary?: LineItemsSummary;\n /** How the cells' fields are labelled. Default `aria` (compact bare controls under a\n * header row); `floating` hands each cell its column's name as\n * {@link LineItemCellContext.fieldLabel} for a visible floating label, and drops the\n * header for those columns. A column's own `fieldLabels` wins. */\n fieldLabels?: LineItemsFieldLabels;\n /** Stacked (a narrow pane), how many fields share a row of a line's card: `2` pairs\n * them up (a column's `narrowSpan={2}` takes a whole row), once the pane is wide\n * enough for two fields (18rem); narrower still, one. Default `1`. */\n narrowColumns?: 1 | 2;\n /** Stacked, where the remove button goes: a row of its own (`row`, default) or\n * beside the last field (`inline`). See {@link LineItemsRemovePlacement}. */\n removePlacement?: LineItemsRemovePlacement;\n /** On the wide grid, the remove button's place in the row's height. Default `start`\n * — or `center` when a column floats its label (`fieldLabels=\"floating\"`): a\n * floating field is taller than the button, and centred is level with its control.\n * A field that shows a message under itself grows the row; pin `start` then. */\n removeAlign?: LineItemsRemoveAlign;\n /** Disables add and remove (the fields are the caller's to disable). */\n disabled?: boolean;\n labels?: Partial<LineItemsLabels>;\n}\n\nconst REMOVE_TRACK = \"2.25rem\";\nconst SUMMARY_TONE: Record<LineItemsSummaryTone, string> = {\n neutral: \"text-[var(--text-primary)]\",\n success: \"text-[var(--success)]\",\n danger: \"text-[var(--danger)]\",\n muted: \"text-[var(--text-muted)]\",\n // SignedAmount's money palette (toneTextClass \"income\" / \"expense\").\n income: \"text-[var(--money-income)]\",\n expense: \"text-[var(--money-expense)]\",\n};\nconst REMOVE_ALIGN: Record<LineItemsRemoveAlign, string> = {\n start: \"@lg:self-start\",\n center: \"@lg:self-center\",\n end: \"@lg:self-end\",\n};\nconst FOCUSABLE =\n \"input:not([disabled]):not([type=hidden]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex]:not([tabindex='-1'])\";\n\nfunction defaultKey(item: unknown, index: number): Key {\n if (typeof item === \"object\" && item !== null && \"id\" in item) {\n const id = (item as { id: unknown }).id;\n if (typeof id === \"string\" || typeof id === \"number\") return id;\n }\n return index;\n}\n\nfunction hasContent(node: ReactNode): boolean {\n return node !== undefined && node !== null && node !== false && node !== \"\";\n}\n\ntype PendingFocus = { kind: \"added\" } | { kind: \"removed\"; index: number };\n\n/**\n * An editable list of lines — journal entry lines, lease components, invoice\n * positions, budget rows: column headers, a row of fields per item, a remove button\n * per row, a dashed \"add\" button under them, and an optional totals row.\n *\n * Presentation only: the rows are the caller's `items` and the fields are the\n * caller's, rendered per column. So it works over plain state —\n *\n * ```tsx\n * <LineItems items={lines} columns={cols} onAdd={() => setLines([...lines, blank()])}\n * onRemove={(i) => setLines(lines.filter((_, j) => j !== i))} minItems={2} />\n * ```\n *\n * — and over react-hook-form's `useFieldArray` alike (`items={fields}`, `onAdd={() =>\n * append(blank())}`, `onRemove={remove}`), for which `@eifi1/ui-kit/rhf` has\n * `RhfLineItems`.\n *\n * On a wide pane the rows are a grid under the headers; on a narrow one (a container\n * query, so a dialog stacks where it is cramped) each row stacks its fields, each\n * under a small copy of its header. The headers are `aria-hidden`: every row is a\n * named group and every field is named by `render`'s `label` (\"Debit, row 2\"), which\n * is what a screen reader needs — a header row it would read once, out of context.\n *\n * Keyboard: after Add, focus lands in the new row's first field; after a remove, on\n * the row that took its place (else the add button). Ctrl/⌘+Enter in any row adds a\n * row.\n */\nexport function LineItems<T>({\n items,\n columns,\n getKey = defaultKey,\n onAdd,\n onRemove,\n minItems = 0,\n maxItems,\n confirmRemove,\n addLabel,\n rowLabel,\n totals,\n totalsLabel,\n empty,\n error,\n summary,\n fieldLabels = \"aria\",\n narrowColumns = 1,\n removePlacement = \"row\",\n removeAlign: removeAlignProp,\n disabled = false,\n labels: labelsProp,\n className,\n style,\n ...rest\n}: LineItemsProps<T>) {\n const labels = useKitLabels(\"lineItems\", DEFAULT_LINE_ITEMS_LABELS, labelsProp);\n const rowRefs = useRef<Array<HTMLDivElement | null>>([]);\n const addRef = useRef<HTMLButtonElement>(null);\n const pendingFocus = useRef<PendingFocus | null>(null);\n const [confirmingAt, setConfirming] = useState<number | null>(null);\n // A confirm waiting on a row that has since gone is void.\n const confirming = confirmingAt !== null && confirmingAt < items.length ? confirmingAt : null;\n\n const tracks = [...columns.map((c) => c.width ?? \"minmax(0,1fr)\"), ...(onRemove ? [REMOVE_TRACK] : [])];\n const gridStyle = { \"--line-items-cols\": tracks.join(\" \") } as CSSProperties;\n const canAdd = Boolean(onAdd) && !disabled && (maxItems === undefined || items.length < maxItems);\n const canRemove = Boolean(onRemove) && !disabled && items.length > minItems;\n const hasError = hasContent(error);\n\n\n // Focus after the list has re-rendered with the new rows — a layout effect, so the\n // caret is where it belongs before paint.\n useLayoutEffect(() => {\n const pending = pendingFocus.current;\n if (!pending) return;\n pendingFocus.current = null;\n if (pending.kind === \"added\") {\n const row = rowRefs.current[items.length - 1];\n row?.querySelector<HTMLElement>(FOCUSABLE)?.focus();\n return;\n }\n const row = rowRefs.current[Math.min(pending.index, items.length - 1)];\n const target =\n row?.querySelector<HTMLElement>(\"[data-line-items-remove]:not([disabled])\") ??\n row?.querySelector<HTMLElement>(FOCUSABLE) ??\n addRef.current;\n target?.focus();\n }, [items.length]);\n\n const add = useCallback(() => {\n if (!canAdd || !onAdd) return;\n pendingFocus.current = { kind: \"added\" };\n onAdd();\n }, [canAdd, onAdd]);\n\n const removeAt = async (index: number) => {\n if (!canRemove || !onRemove) return;\n if (confirmRemove === true && confirming !== index) {\n setConfirming(index);\n return;\n }\n if (typeof confirmRemove === \"function\") {\n const ok = await confirmRemove(items[index], index);\n if (!ok) return;\n }\n setConfirming(null);\n pendingFocus.current = { kind: \"removed\", index };\n onRemove(index);\n };\n\n const onRowKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {\n if (e.key === \"Enter\" && (e.ctrlKey || e.metaKey) && canAdd) {\n e.preventDefault();\n add();\n }\n };\n\n const columnName = (column: LineItemsColumn<T>) =>\n column.label ?? (typeof column.header === \"string\" ? column.header : column.key);\n const floats = (column: LineItemsColumn<T>) => (column.fieldLabels ?? fieldLabels) === \"floating\";\n // A header row only for the columns that still need one: with every field floating\n // its own label, a row of headers would say each name twice.\n const showHeader = columns.some((c) => !floats(c));\n const pairs = narrowColumns === 2;\n const removeAlign = removeAlignProp ?? (columns.some(floats) ? \"center\" : \"start\");\n const inline = removePlacement === \"inline\" && Boolean(onRemove) && columns.length > 0;\n const lastColumn = columns[columns.length - 1];\n\n const headerCell = (column: LineItemsColumn<T>) => (\n <span\n key={column.key}\n className={cn(\n \"min-w-0 truncate text-xs font-medium text-[var(--text-muted)]\",\n column.align === \"end\" && \"text-end\",\n )}\n >\n {floats(column) ? null : column.header}\n </span>\n );\n\n const removeCell = (index: number, row: number, isConfirming: boolean) => (\n <div\n data-line-items-remove-cell=\"\"\n className={cn(\n \"flex justify-end @lg:justify-center\",\n REMOVE_ALIGN[removeAlign],\n // Paired, the remove button keeps a row of its own at the card's end rather\n // than squeezing in beside the last field — unless asked to go `inline`.\n inline ? \"shrink-0\" : pairs && \"@2xs:col-span-2 @lg:col-span-1\",\n )}\n >\n <IconButton\n type=\"button\"\n data-line-items-remove=\"\"\n variant={isConfirming ? \"danger\" : \"ghost\"}\n tone={isConfirming ? undefined : \"danger\"}\n label={isConfirming ? labels.confirmRemove(row) : labels.remove(row)}\n disabled={!canRemove}\n onClick={() => void removeAt(index)}\n onBlur={() => {\n if (isConfirming) setConfirming(null);\n }}\n onKeyDown={(e) => {\n if (e.key === \"Escape\" && isConfirming) {\n e.stopPropagation();\n setConfirming(null);\n }\n }}\n >\n <Trash2 />\n </IconButton>\n </div>\n );\n\n const showTotals = totals !== undefined;\n const summaryTone = summary?.tone ?? \"neutral\";\n const summaryHasValue = hasContent(summary?.value);\n const labelColumn = showTotals ? columns.find((c) => !hasContent(totals[c.key]))?.key : undefined;\n\n return (\n <div\n data-slot=\"line-items\"\n {...rest}\n style={{ ...gridStyle, ...style }}\n className={cn(\"@container space-y-2\", className)}\n >\n {showHeader && (\n <div aria-hidden className=\"hidden gap-2 @lg:grid @lg:grid-cols-[var(--line-items-cols)]\">\n {columns.map(headerCell)}\n {onRemove && <span />}\n </div>\n )}\n\n {items.length === 0 && hasContent(empty) && (\n <div className=\"rounded-md border border-dashed border-[var(--border)] px-3 py-4 text-center text-sm text-[var(--text-muted)]\">\n {empty}\n </div>\n )}\n\n {items.map((item, index) => {\n const row = index + 1;\n const isConfirming = confirming === index;\n return (\n // The row's Ctrl/⌘+Enter is a shortcut for the add button, which is itself\n // reachable by Tab; the group only listens for it bubbling from its fields.\n // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions\n <div\n key={getKey(item, index)}\n ref={(el) => {\n rowRefs.current[index] = el;\n }}\n role=\"group\"\n aria-label={rowLabel ? rowLabel(index, item) : labels.row(row)}\n data-line-items-row=\"\"\n onKeyDown={onRowKeyDown}\n className={cn(\n \"grid grid-cols-1 gap-2 @lg:grid-cols-[var(--line-items-cols)] @lg:items-start\",\n // Two short fields to a row of the card — from 18rem, where two fields\n // still fit a figure each; on anything narrower they stack after all.\n pairs && \"@2xs:grid-cols-2\",\n // Stacked, each row is a card of its own so the rows stay apart.\n \"@max-lg:rounded-md @max-lg:border @max-lg:border-[var(--border)] @max-lg:p-3\",\n )}\n >\n {columns.map((column) => {\n const floating = floats(column);\n const isLast = inline && column === lastColumn;\n const span = pairs && column.narrowSpan === 2 && \"@2xs:col-span-2 @lg:col-span-1\";\n const cell = (\n <div\n key={column.key}\n className={cn(\n \"min-w-0 space-y-1 @lg:space-y-0\",\n // The wide grid places every cell in its own track again.\n isLast ? \"flex-1\" : span,\n )}\n >\n {!floating && (\n <span aria-hidden className=\"block text-xs font-medium text-[var(--text-muted)] @lg:hidden\">\n {column.header}\n </span>\n )}\n {column.render({\n item,\n index,\n label: labels.cell(columnName(column), row),\n fieldLabel: floating ? columnName(column) : undefined,\n })}\n </div>\n );\n if (!isLast) return cell;\n // Inline, the last field and the remove button share one cell of the\n // card; on the wide grid the wrapper dissolves (`contents`) and each is a\n // track of its own again. Level with the field's control: its foot under\n // a header copy, its middle when it floats its own label.\n return (\n <div\n key={column.key}\n data-line-items-inline=\"\"\n className={cn(\"flex min-w-0 gap-2 @lg:contents\", floating ? \"items-center\" : \"items-end\", span)}\n >\n {cell}\n {removeCell(index, row, isConfirming)}\n </div>\n );\n })}\n {onRemove && !inline && removeCell(index, row, isConfirming)}\n </div>\n );\n })}\n\n {showTotals && (\n <div\n role=\"group\"\n aria-label={typeof totalsLabel === \"string\" ? totalsLabel : labels.totals}\n data-line-items-totals=\"\"\n className=\"grid grid-cols-1 gap-2 border-t border-[var(--border)] pt-2 text-sm font-semibold tabular-nums text-[var(--text-primary)] @lg:grid-cols-[var(--line-items-cols)]\"\n >\n {columns.map((column) => {\n const value = totals[column.key];\n if (column.key === labelColumn) {\n return (\n <span key={column.key} className=\"min-w-0\">\n {totalsLabel ?? labels.totals}\n </span>\n );\n }\n return (\n <span\n key={column.key}\n className={cn(\n \"min-w-0\",\n column.align === \"end\" && \"@lg:text-end\",\n // Stacked, a column with no total takes no line.\n !hasContent(value) && \"@max-lg:hidden\",\n )}\n >\n {hasContent(value) && (\n <span className=\"flex justify-between gap-2 @lg:block\">\n <span aria-hidden className=\"font-normal text-[var(--text-muted)] @lg:hidden\">\n {column.header}\n </span>\n {value}\n </span>\n )}\n </span>\n );\n })}\n {onRemove && <span className=\"@max-lg:hidden\" />}\n </div>\n )}\n\n {summary && (\n <div\n data-line-items-summary=\"\"\n className=\"flex flex-wrap items-center gap-x-3 gap-y-1 text-sm text-[var(--text-primary)]\"\n >\n {/* With no value the line is a state of its own, and the label takes the\n tone — the only place left to carry it. */}\n <span\n data-tone={summaryHasValue ? undefined : summaryTone}\n className={cn(\"min-w-0\", !summaryHasValue && SUMMARY_TONE[summaryTone])}\n >\n {summary.label}\n </span>\n {summaryHasValue && (\n <span data-tone={summaryTone} className={cn(\"font-semibold tabular-nums\", SUMMARY_TONE[summaryTone])}>\n {summary.value}\n </span>\n )}\n {hasContent(summary.status) && (\n <span data-line-items-summary-status=\"\" className=\"inline-flex\">\n {summary.status}\n </span>\n )}\n {summary.action && (\n <Button\n type=\"button\"\n variant={summary.action.variant === \"link\" ? \"link\" : \"secondary\"}\n tone={summary.action.variant === \"link\" ? \"muted\" : undefined}\n size=\"sm\"\n className=\"ms-auto\"\n disabled={disabled || summary.action.disabled}\n onClick={summary.action.onClick}\n >\n {summary.action.label}\n </Button>\n )}\n </div>\n )}\n\n {hasError && (\n <p className=\"text-[11px] leading-tight text-[var(--danger)]\">\n {error}\n </p>\n )}\n\n {onAdd && (\n <Button\n ref={addRef}\n type=\"button\"\n variant=\"secondary\"\n className=\"w-full border-dashed\"\n disabled={!canAdd}\n onClick={add}\n >\n <Plus aria-hidden className=\"size-4\" />\n {addLabel ?? labels.add}\n </Button>\n )}\n </div>\n );\n}\n"],"mappings":";AA8UI,cA0DI,YA1DJ;AA9UJ,SAAS,aAAa,iBAAiB,QAAQ,gBAAgB;AAE/D,SAAS,MAAM,cAAc;AAC7B,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAC7B,SAAS,QAAQ,k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A;AAAA,kBACC,MAAK;AAAA,kBACL,SAAS,QAAQ,OAAO,YAAY,SAAS,SAAS;AAAA,kBACtD,MAAM,QAAQ,OAAO,YAAY,SAAS,UAAU;AAAA,kBACpD,MAAK;AAAA,kBACL,WAAU;AAAA,kBACV,UAAU,YAAY,QAAQ,OAAO;AAAA,kBACrC,SAAS,QAAQ,OAAO;AAAA,kBAEvB,kBAAQ,OAAO;AAAA;AAAA,cAClB;AAAA;AAAA;AAAA,QAEJ;AAAA,QAGD,YACC,oBAAC,OAAE,WAAU,kDACV,iBACH;AAAA,QAGD,SACC;AAAA,UAAC;AAAA;AAAA,YACC,KAAK;AAAA,YACL,MAAK;AAAA,YACL,SAAQ;AAAA,YACR,WAAU;AAAA,YACV,UAAU,CAAC;AAAA,YACX,SAAS;AAAA,YAET;AAAA,kCAAC,QAAK,eAAW,MAAC,WAAU,UAAS;AAAA,cACpC,YAAY,OAAO;AAAA;AAAA;AAAA,QACtB;AAAA;AAAA;AAAA,EAEJ;AAEJ;","names":["row"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/line-items.tsx"],"sourcesContent":["import { useCallback, useLayoutEffect, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, CSSProperties, HTMLAttributes, KeyboardEvent, Key, ReactNode } from \"react\";\nimport { Plus, Trash2 } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { useKitLabels } from \"../i18n/kit-labels\";\nimport { Button, IconButton } from \"./ui\";\n\n/** The words {@link LineItems} renders on its own behalf. Row numbers are 1-based. */\nexport interface LineItemsLabels {\n /** The dashed add button. */\n add: string;\n /** The remove button's name for one row. */\n remove: (row: number) => string;\n /** Its name while it waits for the second press (`confirmRemove`). */\n confirmRemove: (row: number) => string;\n /** A row's group name, when the caller gives no `rowLabel`. */\n row: (row: number) => string;\n /** The name a cell's field should carry: the column, and which row. */\n cell: (column: string, row: number) => string;\n /** The totals row's label, and its group name. */\n totals: string;\n}\n\nexport const DEFAULT_LINE_ITEMS_LABELS: LineItemsLabels = {\n add: \"Add row\",\n remove: (row) => `Remove row ${row}`,\n confirmRemove: (row) => `Remove row ${row}? Press again to confirm`,\n row: (row) => `Row ${row}`,\n cell: (column, row) => `${column}, row ${row}`,\n totals: \"Total\",\n};\n\n/** What a column's `render` receives for one row. */\nexport interface LineItemCellContext<T> {\n item: T;\n /** 0-based. */\n index: number;\n /** The accessible name for the cell's field — \"Debit, row 2\". The header is\n * hidden from assistive tech (each row repeats it), so the field has to carry it:\n * `<Input aria-label={label} … />`. */\n label: string;\n /** The column's own name (\"Debit\") for the field's VISIBLE label — set only when the\n * cell's labels are `\"floating\"` (see {@link LineItemsProps.fieldLabels}), so one\n * render serves both modes: `<Input label={fieldLabel} aria-label={label} … />`.\n * Undefined there, the Input stays a bare compact control; set, it floats \"Debit\"\n * while `aria-label` still says which row. */\n fieldLabel?: string;\n}\n\n/** How a cell's field is labelled. `aria`: the field is a bare control named by\n * `aria-label`, under a header row (stacked: a small copy of the header over it).\n * `floating`: the field shows its own floating label ({@link LineItemCellContext.fieldLabel}),\n * so the list draws no header for it. */\nexport type LineItemsFieldLabels = \"aria\" | \"floating\";\n\n/** The colour of a {@link LineItemsSummary}'s value — a verdict (`success` /\n * `danger`), quiet (`muted`), or the money pair (`income` / `expense`, the colours\n * `SignedAmount` draws a figure in) for a remainder that reads as the row it settles. */\nexport type LineItemsSummaryTone = \"neutral\" | \"success\" | \"danger\" | \"muted\" | \"income\" | \"expense\";\n\n/**\n * A line under the lines that says where they stand — a split's remainder (\"Left to\n * assign CHF 0.00\", green at zero, red otherwise, muted while the total is not known\n * yet), with an optional action that settles it (\"Set amount to total\").\n */\nexport interface LineItemsSummary {\n label: ReactNode;\n value?: ReactNode;\n /** The value's colour. Default `neutral`. The label stays neutral: the colour is a\n * second signal, never the only one — the value and label carry the meaning.\n * With no `value` the line is a state on its own (\"Waiting for the total\"), and\n * the tone colours the label instead — `muted` quiets the whole line. */\n tone?: LineItemsSummaryTone;\n /** Beside the value: a chip or badge that names the state (\"Balanced\" next to a\n * journal entry's zero difference). */\n status?: ReactNode;\n /** A small button at the end of the line. Disabled along with the list's\n * `disabled`. `variant`: `secondary` (default) is a boxed button; `link` a muted\n * text link, for an action that is an aside rather than the way to settle it. */\n action?: { label: ReactNode; onClick: () => void; disabled?: boolean; variant?: \"secondary\" | \"link\" };\n}\n\n/** Where a row's remove button sits. `row` (default): stacked, a row of the card to\n * itself (paired, the whole width); wide, its own track. `inline`: stacked, beside\n * the row's last field (\"category + amount\" over \"memo + delete\"); wide, unchanged. */\nexport type LineItemsRemovePlacement = \"row\" | \"inline\";\n\n/** How the remove button sits in the height of a wide row: at its top, centred, or at\n * its foot. */\nexport type LineItemsRemoveAlign = \"start\" | \"center\" | \"end\";\n\nexport interface LineItemsColumn<T> {\n /** Stable id: the React key, and the key into `totals`. */\n key: string;\n /** The column header (and the small label over the cell once the rows stack). */\n header: ReactNode;\n /** The column's name for {@link LineItemCellContext.label}, when `header` is not a\n * string. */\n label?: string;\n /** The grid track once the rows are wide enough to be a table. Default\n * `minmax(0,1fr)`; `\"7rem\"` for an amount. */\n width?: string;\n /** `end` for figures: the header and the totals cell end-align with the field. */\n align?: \"start\" | \"end\";\n /** This column's labelling, over the list's {@link LineItemsProps.fieldLabels} — a\n * read-only \"Sum\" cell in a floating list keeps its header with `\"aria\"`. */\n fieldLabels?: LineItemsFieldLabels;\n /** With {@link LineItemsProps.narrowColumns} `2`: `2` gives the cell a whole row of\n * the stacked card (a description), where short fields pair up two to a row.\n * Default `1`. No effect on the wide grid. */\n narrowSpan?: 1 | 2;\n render: (ctx: LineItemCellContext<T>) => ReactNode;\n}\n\n/**\n * What {@link LineItemsProps.rowProps} returns for one row: `data-*` hooks, an `id`, a\n * class, handlers. A `data-*` attribute is typed so `{ \"data-tour\": \"rule-condition\" }`\n * needs no cast.\n */\nexport type LineItemsRowProps = Omit<HTMLAttributes<HTMLDivElement>, \"children\" | \"dangerouslySetInnerHTML\" | \"role\"> & {\n [key: `data-${string}`]: string | number | boolean | undefined;\n};\n\nexport interface LineItemsProps<T> extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n items: readonly T[];\n columns: readonly LineItemsColumn<T>[];\n /** The row's React key. Default: the item's `id` (react-hook-form's `useFieldArray`\n * `fields` carry one), else its index. */\n getKey?: (item: T, index: number) => Key;\n /** Append a row. Omitted: no add button. The first field of the new row is focused. */\n onAdd?: () => void;\n /** Remove the row at `index`. Omitted: no remove buttons. */\n onRemove?: (index: number) => void;\n /** Remove is disabled at or below this many rows (a journal entry needs two).\n * Default 0. */\n minItems?: number;\n /** Add is disabled at this many rows. */\n maxItems?: number;\n /**\n * Ask before a row goes:\n * - `true`: the remove button asks for a second press — it fills red and its name\n * becomes `lineItems.confirmRemove`; Escape, or leaving it, calls it off.\n * - a function: called with the row, and the row goes only if it answers `true`\n * (`(item, i) => confirm({ title: … , tone: \"danger\" })` with `useConfirm`).\n */\n confirmRemove?: boolean | ((item: T, index: number) => boolean | Promise<boolean>);\n /** The add button's text. Default `lineItems.add`. */\n addLabel?: ReactNode;\n /** A row's group name (\"Line 2\"). Default `lineItems.row`. */\n rowLabel?: (index: number, item: T) => string;\n /** A totals row under the lines, one entry per column `key`. The first column\n * without an entry carries {@link totalsLabel}. Omitted: no totals row. */\n totals?: Partial<Record<string, ReactNode>>;\n /** Default `lineItems.totals`, \"Total\". */\n totalsLabel?: ReactNode;\n /** Shown in place of the rows when there are none. */\n empty?: ReactNode;\n /** A message about the list as a whole (\"The entry does not balance\"). */\n error?: ReactNode;\n /** A line under the lines and totals — the remainder of a split, say. See\n * {@link LineItemsSummary}. */\n summary?: LineItemsSummary;\n /** How the cells' fields are labelled. Default `aria` (compact bare controls under a\n * header row); `floating` hands each cell its column's name as\n * {@link LineItemCellContext.fieldLabel} for a visible floating label, and drops the\n * header for those columns. A column's own `fieldLabels` wins. */\n fieldLabels?: LineItemsFieldLabels;\n /** Stacked (a narrow pane), how many fields share a row of a line's card: `2` pairs\n * them up (a column's `narrowSpan={2}` takes a whole row), once the pane is wide\n * enough for two fields (18rem); narrower still, one. Default `1`. */\n narrowColumns?: 1 | 2;\n /** Stacked, where the remove button goes: a row of its own (`row`, default) or\n * beside the last field (`inline`). See {@link LineItemsRemovePlacement}. */\n removePlacement?: LineItemsRemovePlacement;\n /** On the wide grid, the remove button's place in the row's height. Default `start`\n * — or `center` when a column floats its label (`fieldLabels=\"floating\"`): a\n * floating field is taller than the button, and centred is level with its control.\n * A field that shows a message under itself grows the row; pin `start` then. */\n removeAlign?: LineItemsRemoveAlign;\n /** Disables add and remove (the fields are the caller's to disable). */\n disabled?: boolean;\n /**\n * Extra attributes for one row's element (the `role=\"group\"` that holds its fields) —\n * keksdose K20: its rule editor's tour points at the first condition row with\n * `[data-tour=\"rule-condition\"]` (dev#495), and with nowhere to put the anchor on the\n * row it wrapped a cell's field in a `span` instead, which the spotlight then drew\n * around one field rather than the row. Test ids the same way.\n *\n * MERGED under the list's own, which win: `role`, the group's `aria-label` (that is\n * {@link rowLabel}'s) and `data-line-items-row` stay the list's — the row's name and\n * the hook its focus handling finds rows by. `className` is added after the row's\n * own classes, `style` is passed through, and an `onKeyDown` runs BEFORE the row's\n * Ctrl/⌘+Enter \"add a row\" (call `preventDefault()` to keep that from happening).\n */\n rowProps?: (item: T, index: number) => LineItemsRowProps | undefined;\n labels?: Partial<LineItemsLabels>;\n}\n\nconst REMOVE_TRACK = \"2.25rem\";\nconst SUMMARY_TONE: Record<LineItemsSummaryTone, string> = {\n neutral: \"text-[var(--text-primary)]\",\n success: \"text-[var(--success)]\",\n danger: \"text-[var(--danger)]\",\n muted: \"text-[var(--text-muted)]\",\n // SignedAmount's money palette (toneTextClass \"income\" / \"expense\").\n income: \"text-[var(--money-income)]\",\n expense: \"text-[var(--money-expense)]\",\n};\nconst REMOVE_ALIGN: Record<LineItemsRemoveAlign, string> = {\n start: \"@lg:self-start\",\n center: \"@lg:self-center\",\n end: \"@lg:self-end\",\n};\nconst FOCUSABLE =\n \"input:not([disabled]):not([type=hidden]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex]:not([tabindex='-1'])\";\n\nfunction defaultKey(item: unknown, index: number): Key {\n if (typeof item === \"object\" && item !== null && \"id\" in item) {\n const id = (item as { id: unknown }).id;\n if (typeof id === \"string\" || typeof id === \"number\") return id;\n }\n return index;\n}\n\nfunction hasContent(node: ReactNode): boolean {\n return node !== undefined && node !== null && node !== false && node !== \"\";\n}\n\ntype PendingFocus = { kind: \"added\" } | { kind: \"removed\"; index: number };\n\n/**\n * An editable list of lines — journal entry lines, lease components, invoice\n * positions, budget rows: column headers, a row of fields per item, a remove button\n * per row, a dashed \"add\" button under them, and an optional totals row.\n *\n * Presentation only: the rows are the caller's `items` and the fields are the\n * caller's, rendered per column. So it works over plain state —\n *\n * ```tsx\n * <LineItems items={lines} columns={cols} onAdd={() => setLines([...lines, blank()])}\n * onRemove={(i) => setLines(lines.filter((_, j) => j !== i))} minItems={2} />\n * ```\n *\n * — and over react-hook-form's `useFieldArray` alike (`items={fields}`, `onAdd={() =>\n * append(blank())}`, `onRemove={remove}`), for which `@eifi1/ui-kit/rhf` has\n * `RhfLineItems`.\n *\n * On a wide pane the rows are a grid under the headers; on a narrow one (a container\n * query, so a dialog stacks where it is cramped) each row stacks its fields, each\n * under a small copy of its header. The headers are `aria-hidden`: every row is a\n * named group and every field is named by `render`'s `label` (\"Debit, row 2\"), which\n * is what a screen reader needs — a header row it would read once, out of context.\n *\n * Keyboard: after Add, focus lands in the new row's first field; after a remove, on\n * the row that took its place (else the add button). Ctrl/⌘+Enter in any row adds a\n * row.\n */\nexport function LineItems<T>({\n items,\n columns,\n getKey = defaultKey,\n onAdd,\n onRemove,\n minItems = 0,\n maxItems,\n confirmRemove,\n addLabel,\n rowLabel,\n totals,\n totalsLabel,\n empty,\n error,\n summary,\n fieldLabels = \"aria\",\n narrowColumns = 1,\n removePlacement = \"row\",\n removeAlign: removeAlignProp,\n disabled = false,\n rowProps,\n labels: labelsProp,\n className,\n style,\n ...rest\n}: LineItemsProps<T>) {\n const labels = useKitLabels(\"lineItems\", DEFAULT_LINE_ITEMS_LABELS, labelsProp);\n const rowRefs = useRef<Array<HTMLDivElement | null>>([]);\n const addRef = useRef<HTMLButtonElement>(null);\n const pendingFocus = useRef<PendingFocus | null>(null);\n const [confirmingAt, setConfirming] = useState<number | null>(null);\n // A confirm waiting on a row that has since gone is void.\n const confirming = confirmingAt !== null && confirmingAt < items.length ? confirmingAt : null;\n\n const tracks = [...columns.map((c) => c.width ?? \"minmax(0,1fr)\"), ...(onRemove ? [REMOVE_TRACK] : [])];\n const gridStyle = { \"--line-items-cols\": tracks.join(\" \") } as CSSProperties;\n const canAdd = Boolean(onAdd) && !disabled && (maxItems === undefined || items.length < maxItems);\n const canRemove = Boolean(onRemove) && !disabled && items.length > minItems;\n const hasError = hasContent(error);\n\n\n // Focus after the list has re-rendered with the new rows — a layout effect, so the\n // caret is where it belongs before paint.\n useLayoutEffect(() => {\n const pending = pendingFocus.current;\n if (!pending) return;\n pendingFocus.current = null;\n if (pending.kind === \"added\") {\n const row = rowRefs.current[items.length - 1];\n row?.querySelector<HTMLElement>(FOCUSABLE)?.focus();\n return;\n }\n const row = rowRefs.current[Math.min(pending.index, items.length - 1)];\n const target =\n row?.querySelector<HTMLElement>(\"[data-line-items-remove]:not([disabled])\") ??\n row?.querySelector<HTMLElement>(FOCUSABLE) ??\n addRef.current;\n target?.focus();\n }, [items.length]);\n\n const add = useCallback(() => {\n if (!canAdd || !onAdd) return;\n pendingFocus.current = { kind: \"added\" };\n onAdd();\n }, [canAdd, onAdd]);\n\n const removeAt = async (index: number) => {\n if (!canRemove || !onRemove) return;\n if (confirmRemove === true && confirming !== index) {\n setConfirming(index);\n return;\n }\n if (typeof confirmRemove === \"function\") {\n const ok = await confirmRemove(items[index], index);\n if (!ok) return;\n }\n setConfirming(null);\n pendingFocus.current = { kind: \"removed\", index };\n onRemove(index);\n };\n\n const onRowKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {\n if (e.key === \"Enter\" && (e.ctrlKey || e.metaKey) && canAdd) {\n e.preventDefault();\n add();\n }\n };\n\n const columnName = (column: LineItemsColumn<T>) =>\n column.label ?? (typeof column.header === \"string\" ? column.header : column.key);\n const floats = (column: LineItemsColumn<T>) => (column.fieldLabels ?? fieldLabels) === \"floating\";\n // A header row only for the columns that still need one: with every field floating\n // its own label, a row of headers would say each name twice.\n const showHeader = columns.some((c) => !floats(c));\n const pairs = narrowColumns === 2;\n const removeAlign = removeAlignProp ?? (columns.some(floats) ? \"center\" : \"start\");\n const inline = removePlacement === \"inline\" && Boolean(onRemove) && columns.length > 0;\n const lastColumn = columns[columns.length - 1];\n\n const headerCell = (column: LineItemsColumn<T>) => (\n <span\n key={column.key}\n className={cn(\n \"min-w-0 truncate text-xs font-medium text-[var(--text-muted)]\",\n column.align === \"end\" && \"text-end\",\n )}\n >\n {floats(column) ? null : column.header}\n </span>\n );\n\n const removeCell = (index: number, row: number, isConfirming: boolean) => (\n <div\n data-line-items-remove-cell=\"\"\n className={cn(\n \"flex justify-end @lg:justify-center\",\n REMOVE_ALIGN[removeAlign],\n // Paired, the remove button keeps a row of its own at the card's end rather\n // than squeezing in beside the last field — unless asked to go `inline`.\n inline ? \"shrink-0\" : pairs && \"@2xs:col-span-2 @lg:col-span-1\",\n )}\n >\n <IconButton\n type=\"button\"\n data-line-items-remove=\"\"\n variant={isConfirming ? \"danger\" : \"ghost\"}\n tone={isConfirming ? undefined : \"danger\"}\n label={isConfirming ? labels.confirmRemove(row) : labels.remove(row)}\n disabled={!canRemove}\n onClick={() => void removeAt(index)}\n onBlur={() => {\n if (isConfirming) setConfirming(null);\n }}\n onKeyDown={(e) => {\n if (e.key === \"Escape\" && isConfirming) {\n e.stopPropagation();\n setConfirming(null);\n }\n }}\n >\n <Trash2 />\n </IconButton>\n </div>\n );\n\n const showTotals = totals !== undefined;\n const summaryTone = summary?.tone ?? \"neutral\";\n const summaryHasValue = hasContent(summary?.value);\n const labelColumn = showTotals ? columns.find((c) => !hasContent(totals[c.key]))?.key : undefined;\n\n return (\n <div\n data-slot=\"line-items\"\n {...rest}\n style={{ ...gridStyle, ...style }}\n className={cn(\"@container space-y-2\", className)}\n >\n {showHeader && (\n <div aria-hidden className=\"hidden gap-2 @lg:grid @lg:grid-cols-[var(--line-items-cols)]\">\n {columns.map(headerCell)}\n {onRemove && <span />}\n </div>\n )}\n\n {items.length === 0 && hasContent(empty) && (\n <div className=\"rounded-md border border-dashed border-[var(--border)] px-3 py-4 text-center text-sm text-[var(--text-muted)]\">\n {empty}\n </div>\n )}\n\n {items.map((item, index) => {\n const row = index + 1;\n const isConfirming = confirming === index;\n const extra = rowProps?.(item, index);\n return (\n // The row's Ctrl/⌘+Enter is a shortcut for the add button, which is itself\n // reachable by Tab; the group only listens for it bubbling from its fields.\n // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions\n <div\n {...extra}\n key={getKey(item, index)}\n ref={(el) => {\n rowRefs.current[index] = el;\n }}\n role=\"group\"\n aria-label={rowLabel ? rowLabel(index, item) : labels.row(row)}\n data-line-items-row=\"\"\n onKeyDown={(e) => {\n if (extra?.onKeyDown) {\n extra.onKeyDown(e);\n if (e.defaultPrevented) return;\n }\n onRowKeyDown(e);\n }}\n className={cn(\n \"grid grid-cols-1 gap-2 @lg:grid-cols-[var(--line-items-cols)] @lg:items-start\",\n // Two short fields to a row of the card — from 18rem, where two fields\n // still fit a figure each; on anything narrower they stack after all.\n pairs && \"@2xs:grid-cols-2\",\n // Stacked, each row is a card of its own so the rows stay apart.\n \"@max-lg:rounded-md @max-lg:border @max-lg:border-[var(--border)] @max-lg:p-3\",\n extra?.className,\n )}\n >\n {columns.map((column) => {\n const floating = floats(column);\n const isLast = inline && column === lastColumn;\n const span = pairs && column.narrowSpan === 2 && \"@2xs:col-span-2 @lg:col-span-1\";\n const cell = (\n <div\n key={column.key}\n className={cn(\n \"min-w-0 space-y-1 @lg:space-y-0\",\n // The wide grid places every cell in its own track again.\n isLast ? \"flex-1\" : span,\n )}\n >\n {!floating && (\n <span aria-hidden className=\"block text-xs font-medium text-[var(--text-muted)] @lg:hidden\">\n {column.header}\n </span>\n )}\n {column.render({\n item,\n index,\n label: labels.cell(columnName(column), row),\n fieldLabel: floating ? columnName(column) : undefined,\n })}\n </div>\n );\n if (!isLast) return cell;\n // Inline, the last field and the remove button share one cell of the\n // card; on the wide grid the wrapper dissolves (`contents`) and each is a\n // track of its own again. Level with the field's control: its foot under\n // a header copy, its middle when it floats its own label.\n return (\n <div\n key={column.key}\n data-line-items-inline=\"\"\n className={cn(\"flex min-w-0 gap-2 @lg:contents\", floating ? \"items-center\" : \"items-end\", span)}\n >\n {cell}\n {removeCell(index, row, isConfirming)}\n </div>\n );\n })}\n {onRemove && !inline && removeCell(index, row, isConfirming)}\n </div>\n );\n })}\n\n {showTotals && (\n <div\n role=\"group\"\n aria-label={typeof totalsLabel === \"string\" ? totalsLabel : labels.totals}\n data-line-items-totals=\"\"\n className=\"grid grid-cols-1 gap-2 border-t border-[var(--border)] pt-2 text-sm font-semibold tabular-nums text-[var(--text-primary)] @lg:grid-cols-[var(--line-items-cols)]\"\n >\n {columns.map((column) => {\n const value = totals[column.key];\n if (column.key === labelColumn) {\n return (\n <span key={column.key} className=\"min-w-0\">\n {totalsLabel ?? labels.totals}\n </span>\n );\n }\n return (\n <span\n key={column.key}\n className={cn(\n \"min-w-0\",\n column.align === \"end\" && \"@lg:text-end\",\n // Stacked, a column with no total takes no line.\n !hasContent(value) && \"@max-lg:hidden\",\n )}\n >\n {hasContent(value) && (\n <span className=\"flex justify-between gap-2 @lg:block\">\n <span aria-hidden className=\"font-normal text-[var(--text-muted)] @lg:hidden\">\n {column.header}\n </span>\n {value}\n </span>\n )}\n </span>\n );\n })}\n {onRemove && <span className=\"@max-lg:hidden\" />}\n </div>\n )}\n\n {summary && (\n <div\n data-line-items-summary=\"\"\n className=\"flex flex-wrap items-center gap-x-3 gap-y-1 text-sm text-[var(--text-primary)]\"\n >\n {/* With no value the line is a state of its own, and the label takes the\n tone — the only place left to carry it. */}\n <span\n data-tone={summaryHasValue ? undefined : summaryTone}\n className={cn(\"min-w-0\", !summaryHasValue && SUMMARY_TONE[summaryTone])}\n >\n {summary.label}\n </span>\n {summaryHasValue && (\n <span data-tone={summaryTone} className={cn(\"font-semibold tabular-nums\", SUMMARY_TONE[summaryTone])}>\n {summary.value}\n </span>\n )}\n {hasContent(summary.status) && (\n <span data-line-items-summary-status=\"\" className=\"inline-flex\">\n {summary.status}\n </span>\n )}\n {summary.action && (\n <Button\n type=\"button\"\n variant={summary.action.variant === \"link\" ? \"link\" : \"secondary\"}\n tone={summary.action.variant === \"link\" ? \"muted\" : undefined}\n size=\"sm\"\n className=\"ms-auto\"\n disabled={disabled || summary.action.disabled}\n onClick={summary.action.onClick}\n >\n {summary.action.label}\n </Button>\n )}\n </div>\n )}\n\n {hasError && (\n <p className=\"text-[11px] leading-tight text-[var(--danger)]\">\n {error}\n </p>\n )}\n\n {onAdd && (\n <Button\n ref={addRef}\n type=\"button\"\n variant=\"secondary\"\n className=\"w-full border-dashed\"\n disabled={!canAdd}\n onClick={add}\n >\n <Plus aria-hidden className=\"size-4\" />\n {addLabel ?? labels.add}\n </Button>\n )}\n </div>\n );\n}\n"],"mappings":";AAsWI,cA0DI,YA1DJ;AA8EM;AApbV,SAAS,aAAa,iBAAiB,QAAQ,gBAAgB;AAE/D,SAAS,MAAM,cAAc;AAC7B,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAC7B,SAAS,QAAQ,kBAAkB;AAkB5B,MAAM,4BAA6C;AAAA,EACxD,KAAK;AAAA,EACL,QAAQ,CAAC,QAAQ,cAAc,GAAG;AAAA,EAClC,eAAe,CAAC,QAAQ,cAAc,GAAG;AAAA,EACzC,KAAK,CAAC,QAAQ,OAAO,GAAG;AAAA,EACxB,MAAM,CAAC,QAAQ,QAAQ,GAAG,MAAM,SAAS,GAAG;AAAA,EAC5C,QAAQ;AACV;AAwKA,MAAM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