@eifi1/ui-kit 0.23.0 → 0.24.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/README.md +6 -6
- package/dist/chart.d.ts +2 -4
- package/dist/components/amount-input.d.ts +16 -9
- package/dist/components/amount-input.js +13 -11
- package/dist/components/amount-input.js.map +1 -1
- package/dist/components/autocomplete.d.ts +5 -0
- package/dist/components/autocomplete.js +39 -37
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/button-group.d.ts +2 -4
- package/dist/components/calculator.d.ts +2 -4
- package/dist/components/column-mapper.d.ts +62 -9
- package/dist/components/column-mapper.js +85 -49
- package/dist/components/column-mapper.js.map +1 -1
- package/dist/components/combobox.d.ts +33 -1
- package/dist/components/combobox.js +8 -2
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/confirm-dialog.d.ts +2 -4
- package/dist/components/copy-button.d.ts +2 -4
- package/dist/components/danger-confirm.d.ts +2 -4
- package/dist/components/danger-confirm.js +52 -5
- package/dist/components/danger-confirm.js.map +1 -1
- package/dist/components/entity-combobox.d.ts +13 -1
- package/dist/components/entity-combobox.js +13 -4
- package/dist/components/entity-combobox.js.map +1 -1
- package/dist/components/facing-pair.d.ts +2 -4
- package/dist/components/file-button.d.ts +2 -4
- package/dist/components/file-dropzone.d.ts +2 -4
- package/dist/components/form-actions.d.ts +1 -3
- package/dist/components/form-actions.js +15 -1
- package/dist/components/form-actions.js.map +1 -1
- package/dist/components/iban-input.d.ts +2 -4
- package/dist/components/language-select.d.ts +2 -4
- package/dist/components/money-field.d.ts +2 -4
- package/dist/components/multi-entity-combobox.d.ts +5 -1
- package/dist/components/multi-entity-combobox.js +11 -3
- package/dist/components/multi-entity-combobox.js.map +1 -1
- package/dist/components/number-field.d.ts +2 -4
- package/dist/components/number-input.d.ts +2 -4
- package/dist/components/numpad-sheet.d.ts +2 -4
- package/dist/components/phone-input.d.ts +2 -4
- package/dist/components/series-chart.d.ts +2 -4
- package/dist/components/settings-fields.d.ts +2 -4
- package/dist/components/share-card.d.ts +1 -3
- package/dist/components/text-link.d.ts +1 -3
- package/dist/components/time-input.d.ts +2 -4
- package/dist/components/ui.d.ts +2 -4
- package/dist/components/ui.js +55 -17
- package/dist/components/ui.js.map +1 -1
- package/dist/feedback/feedback-attachment.d.ts +66 -1
- package/dist/feedback/feedback-attachment.js +32 -12
- package/dist/feedback/feedback-attachment.js.map +1 -1
- package/dist/feedback/feedback-dialog.d.ts +66 -1
- package/dist/feedback/feedback-inbox.d.ts +67 -253
- package/dist/feedback/feedback-thread.d.ts +1 -3
- package/dist/feedback/feedback-thread.js +8 -2
- package/dist/feedback/feedback-thread.js.map +1 -1
- package/dist/{feedback-BxeQVzwq.d.ts → feedback-DOwPu-Il.d.ts} +878 -18
- package/dist/feedback.d.ts +2 -4
- package/dist/hooks/use-file-drop.d.ts +2 -4
- package/dist/i18n/defaults.d.ts +2 -4
- package/dist/i18n/german.d.ts +2 -4
- package/dist/i18n/kit-labels.d.ts +1 -3
- package/dist/i18n/languages.d.ts +2 -4
- package/dist/i18n/locales/de-CH.d.ts +2 -4
- package/dist/i18n/locales/en.d.ts +2 -4
- package/dist/i18n/locales/es.d.ts +2 -4
- package/dist/i18n/locales/fr.d.ts +2 -4
- package/dist/i18n/locales/hu.d.ts +2 -4
- package/dist/i18n/locales/it.d.ts +2 -4
- package/dist/i18n/locales/zh.d.ts +2 -4
- package/dist/i18n/review.d.ts +2 -4
- package/dist/index.d.ts +2 -4
- package/dist/lib/strip-fade.d.ts +2 -2
- package/dist/lib/strip-fade.js.map +1 -1
- package/dist/rhf/fields.d.ts +59 -8
- package/dist/rhf/fields.js +61 -3
- package/dist/rhf/fields.js.map +1 -1
- package/dist/rhf/form.d.ts +2 -4
- package/dist/rhf.d.ts +3 -5
- package/dist/rhf.js.map +1 -1
- package/dist/shell/app-shell.d.ts +1 -3
- package/dist/shell/top-bar-brand.d.ts +2 -4
- package/dist/shell.d.ts +1 -3
- package/dist/wizard/stepper-nav.d.ts +2 -4
- package/dist/wizard.d.ts +2 -4
- package/package.json +1 -1
- package/src/components/amount-input.tsx +37 -20
- package/src/components/autocomplete.tsx +16 -5
- package/src/components/column-mapper.tsx +181 -79
- package/src/components/combobox.tsx +41 -3
- package/src/components/danger-confirm.tsx +193 -22
- package/src/components/entity-combobox.tsx +28 -5
- package/src/components/form-actions.tsx +20 -1
- package/src/components/multi-entity-combobox.tsx +16 -3
- package/src/components/ui.tsx +107 -0
- package/src/feedback/feedback-attachment.tsx +65 -12
- package/src/feedback/feedback-thread.tsx +66 -6
- package/src/lib/strip-fade.ts +2 -2
- package/src/rhf/fields.tsx +167 -6
- package/src/rhf.ts +1 -1
- package/dist/feedback-attachment-fGAzZPf0.d.ts +0 -469
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/column-mapper.tsx"],"sourcesContent":["import { useEffect, useEffectEvent, useState } from \"react\";\nimport type { ChangeEvent, DragEvent, ReactNode } from \"react\";\nimport { Upload } from \"lucide-react\";\n\nimport { useKitLabels, useKitLocale } from \"../i18n/kit-labels\";\nimport { cn } from \"../lib/cn\";\nimport {\n assignColumnRole,\n guessMapping,\n missingRoles,\n readMappedTable,\n readTextFile,\n roleOfColumn,\n} from \"../lib/column-mapping\";\nimport type {\n ColumnMapperResult,\n ColumnMapping,\n ColumnRole,\n} from \"../lib/column-mapping\";\nimport { parseTextTable } from \"../lib/table-text\";\nimport type { TableSeparator, TextTable } from \"../lib/table-text\";\nimport { AlertBanner } from \"./alert-banner\";\nimport { Checkbox } from \"./checkbox\";\nimport { Disclosure } from \"./disclosure\";\nimport { FileButton, useFilePicker } from \"./file-button\";\nimport {\n Table,\n TableBody,\n TableCell,\n TableHead,\n TableHeaderCell,\n TableRow,\n} from \"./table\";\nimport { Select, Textarea } from \"./ui\";\n\n/**\n * A table pasted, dropped or chosen as a file, and which of its columns plays which\n * part — Kurvenschmiede's columns input and keksdose's bank-file mapping step, once.\n *\n * Kurvenschmiede (`features/control/columns-input.tsx` + `csv.ts`) reads a recorder's\n * export into a playground signal (time, value) and a comparison (time, setpoint,\n * actual): a textarea, a file button, a parse, a select per role, and a line that says\n * which decimal convention was assumed and how many lines were skipped. keksdose\n * (`import-map-step.tsx`) shows a bank's CSV as a table with a role select on every\n * column's header, the file's real values under it, ignored columns dimmed, and what\n * the import still needs named under it. Same problem, two hand-built answers.\n *\n * Two layers, so both shapes fit:\n *\n * * {@link ColumnMapper} — the whole single panel: paste, drop or choose → parse\n * ({@link parseTextTable}: separator, decimal convention, header line, all stated\n * back) → preview with a role per column → `onChange(result)`. Kurvenschmiede's.\n * * {@link ColumnRoleTable} — the preview with the role selects alone, controlled, over\n * rows the caller already has. keksdose's map step, whose rows come from its server's\n * sniff (encodings, quoted multi-line cells, skipped title rows) and whose mapping\n * lives in the wizard's state between steps.\n *\n * The rules under both are headless in `lib/column-mapping.ts`: a role moves rather\n * than doubling up, what is missing is named, and the rows a numeric role cannot read\n * are reported by line number rather than dropped.\n */\n\n// ── Labels ────────────────────────────────────────────────────────────────────\n\nexport interface ColumnMapperLabels {\n /** The paste box's label. */\n paste: string;\n /** The caption under the paste box. */\n pasteHint: string;\n /** The file button. */\n chooseFile: string;\n /** A chosen or dropped file whose bytes could not be read at all. */\n readError: (name: string) => string;\n /** The checkbox that says whether the first line names the columns. */\n headerRow: string;\n /** What was read: so many columns and rows. */\n summary: (columns: number, rows: number) => string;\n /** The separator that was assumed. */\n separatorSemicolon: string;\n separatorComma: string;\n separatorTab: string;\n separatorSpace: string;\n /** The decimal convention that was assumed — with an example, because \"decimal\n * comma\" alone is a term, and `1,5` is something a reader recognises. */\n decimalComma: string;\n decimalPoint: string;\n /** The title over the lines that could not be read. */\n unreadCount: (count: number) => string;\n /** One of them. */\n unreadLine: (line: number) => string;\n /** Past the first hundred listed. */\n unreadMore: (count: number) => string;\n /** The text has content, and none of it is a row. */\n noRows: string;\n /** The preview table's name. */\n table: string;\n /** A column the table names no header for. */\n columnN: (n: number) => string;\n /** The role select on a column's header — its accessible name. */\n roleOf: (column: string) => string;\n /** The role select's \"no role\" option. */\n ignore: string;\n /** A required role in the select. */\n requiredRole: (role: string) => string;\n /** Under the preview, when it shows fewer rows than were read. */\n previewOf: (shown: number, total: number) => string;\n /** A required group's roles, already joined as a list with \"or\". */\n oneOf: (roles: string) => string;\n /** What the table still needs, already joined as a list with \"and\". */\n missing: (roles: string) => string;\n}\n\nexport const DEFAULT_COLUMN_MAPPER_LABELS: ColumnMapperLabels = {\n paste: \"Paste a table\",\n pasteHint:\n \"Copy the rows out of a spreadsheet and paste them here, or drop a CSV or text file.\",\n chooseFile: \"Choose a file\",\n readError: (name) => `“${name}” could not be read`,\n headerRow: \"The first line names the columns\",\n summary: (columns, rows) =>\n `${columns} ${columns === 1 ? \"column\" : \"columns\"}, ${rows} ${rows === 1 ? \"row\" : \"rows\"}`,\n separatorSemicolon: \"separated by semicolons\",\n separatorComma: \"separated by commas\",\n separatorTab: \"separated by tabs\",\n separatorSpace: \"separated by spaces\",\n decimalComma: \"decimal comma (1,5)\",\n decimalPoint: \"decimal point (1.5)\",\n unreadCount: (count) =>\n count === 1\n ? \"1 line could not be read\"\n : `${count} lines could not be read`,\n unreadLine: (line) => `Line ${line} could not be read`,\n unreadMore: (count) => `…and ${count} more`,\n noRows: \"No line of this text reads as a row of the table.\",\n table: \"Columns and their roles\",\n columnN: (n) => `Column ${n}`,\n roleOf: (column) => `What does column “${column}” hold?`,\n ignore: \"Ignore\",\n requiredRole: (role) => `${role} (required)`,\n previewOf: (shown, total) =>\n shown === 1\n ? `The first of ${total} rows`\n : `The first ${shown} of ${total} rows`,\n oneOf: (roles) => `either ${roles}`,\n missing: (roles) => `Still needed: ${roles}.`,\n};\n\nconst SEPARATOR_LABEL: Record<\n TableSeparator,\n \"separatorSemicolon\" | \"separatorComma\" | \"separatorTab\" | \"separatorSpace\"\n> = {\n \";\": \"separatorSemicolon\",\n \",\": \"separatorComma\",\n \"\\t\": \"separatorTab\",\n \" \": \"separatorSpace\",\n};\n\n/** How many unread lines are listed before \"…and N more\". */\nconst UNREAD_LISTED = 100;\n\n/** A file a table is likely to be in. Extensions only, so a refusal reads \"Only .csv,\n * .tsv, … files\" rather than a list of MIME types; the parse is the real check. */\nconst DEFAULT_ACCEPT = \".csv,.tsv,.txt,.dat,.asc\";\n\nfunction formatList(\n items: string[],\n type: \"conjunction\" | \"disjunction\",\n locale: string | undefined,\n): string {\n try {\n return new Intl.ListFormat(locale, { type, style: \"long\" }).format(items);\n } catch {\n return items.join(\", \");\n }\n}\n\n// ── ColumnRoleTable ───────────────────────────────────────────────────────────\n\nexport interface ColumnRoleTableProps<\n R extends string,\n M extends ColumnMapping<R> = ColumnMapping<R>,\n> {\n /** The columns' names — the file's header line — or `null` for a table without one\n * (each column is then \"Column 1\", \"Column 2\", …). */\n header: readonly string[] | null;\n /** The rows to preview, as text. Only the first {@link previewRows} are drawn. */\n rows: readonly (readonly string[])[];\n /** How many columns. Default: the header's length or the widest previewed row. */\n width?: number;\n /** The parts a column can play. */\n roles: readonly ColumnRole<R>[];\n /** Role → column. Any object with the roles as nullable number fields — keksdose's\n * `CsvMapping` as it stands; the other fields are handed back untouched. */\n mapping: M;\n /** The next mapping, with the picked role moved onto its column. */\n onMappingChange: (next: M) => void;\n /** Default 5. */\n previewRows?: number;\n /** How many rows the table has in all, for \"The first 5 of 120 rows\". Default:\n * `rows.length`. */\n totalRows?: number;\n /** Every role select disabled — keksdose locks them while a re-sniff replaces the\n * table they point into. */\n disabled?: boolean;\n labels?: Partial<ColumnMapperLabels>;\n className?: string;\n}\n\n/**\n * A table's first rows, with a role select on every column's header.\n *\n * keksdose's mapping step (dev#462: \"make it more table like, where the table columns\n * can be chosen from the input and the column data changes with the chosen column\n * header\"): the file IS the form. The file's own column name sits on top, verbatim —\n * it is how the reader recognises the column; under it the role, picked in place;\n * under that the column's real values, so a column that is one off shows up here and\n * not after the import. A column with no role says \"Ignore\" and its values are dimmed:\n * the state that most needs to be visible in a twelve-column bank export.\n *\n * Picking a role another column holds MOVES it ({@link assignColumnRole}). Required\n * roles say so in the list, and what the table still needs is named under it — a\n * required group as \"either Amount, Debit or Credit\".\n *\n * The table scrolls sideways inside its own box (the kit {@link Table}'s wrapper, a\n * named, keyboard-reachable region while it overflows), so a wide export never widens\n * the page at 390px.\n */\nexport function ColumnRoleTable<\n R extends string,\n M extends ColumnMapping<R> = ColumnMapping<R>,\n>({\n header,\n rows,\n width: widthProp,\n roles,\n mapping,\n onMappingChange,\n previewRows = 5,\n totalRows,\n disabled,\n labels: labelsProp,\n className,\n}: ColumnRoleTableProps<R, M>) {\n const labels: ColumnMapperLabels = useKitLabels(\n \"columnMapper\",\n DEFAULT_COLUMN_MAPPER_LABELS,\n labelsProp,\n );\n const locale = useKitLocale();\n const shown = rows.slice(0, previewRows);\n const width =\n widthProp ??\n shown.reduce(\n (widest, row) => Math.max(widest, row.length),\n header?.length ?? 0,\n );\n const columns = Array.from({ length: width }, (_, index) => index);\n const total = totalRows ?? rows.length;\n const nameOf = (column: number) =>\n header?.[column] || labels.columnN(column + 1);\n const labelOf = (value: R) =>\n roles.find((role) => role.value === value)?.label ?? value;\n const gaps = missingRoles(roles, mapping, width).map((gap) =>\n gap.length === 1\n ? labelOf(gap[0])\n : labels.oneOf(formatList(gap.map(labelOf), \"disjunction\", locale)),\n );\n\n return (\n <div\n className={cn(\"min-w-0 space-y-1.5\", className)}\n data-slot=\"column-role-table\"\n >\n <Table density=\"compact\" framed aria-label={labels.table}>\n <TableHead>\n <TableRow>\n {columns.map((column) => {\n const role = roleOfColumn(roles, mapping, column);\n const name = nameOf(column);\n return (\n <TableHeaderCell\n key={column}\n scope=\"col\"\n className=\"min-w-36 py-2 align-top\"\n >\n <span className=\"block max-w-56 truncate pb-1 text-[11px] font-normal text-[var(--text-muted)]\">\n {name}\n </span>\n <Select\n size=\"sm\"\n className=\"w-full\"\n aria-label={labels.roleOf(name)}\n value={role ?? \"\"}\n disabled={disabled}\n onChange={(event) =>\n onMappingChange(\n assignColumnRole(\n roles,\n mapping,\n column,\n event.target.value === \"\"\n ? null\n : (event.target.value as R),\n ),\n )\n }\n >\n <option value=\"\">{labels.ignore}</option>\n {roles.map((option) => (\n <option key={option.value} value={option.value}>\n {option.required === true\n ? labels.requiredRole(option.label)\n : option.label}\n </option>\n ))}\n </Select>\n </TableHeaderCell>\n );\n })}\n </TableRow>\n </TableHead>\n <TableBody>\n {shown.map((row, index) => (\n <TableRow key={index}>\n {columns.map((column) => (\n <TableCell\n key={column}\n data-ignored={\n roleOfColumn(roles, mapping, column) === null || undefined\n }\n className={cn(\n \"font-mono whitespace-nowrap\",\n // Dimmed, not hidden: its values are what tell you whether ignoring\n // it was right.\n roleOfColumn(roles, mapping, column) === null &&\n \"text-[var(--text-muted)]\",\n )}\n >\n <span className=\"block max-w-56 truncate\">\n {row[column] ?? \"\"}\n </span>\n </TableCell>\n ))}\n </TableRow>\n ))}\n </TableBody>\n </Table>\n {total > shown.length && (\n <p className=\"text-xs text-[var(--text-muted)]\">\n {labels.previewOf(shown.length, total)}\n </p>\n )}\n {gaps.length > 0 && (\n <AlertBanner tone=\"warning\" variant=\"inline\" size=\"sm\" block>\n {labels.missing(formatList(gaps, \"conjunction\", locale))}\n </AlertBanner>\n )}\n </div>\n );\n}\n\n// ── ColumnMapper ──────────────────────────────────────────────────────────────\n\nexport interface ColumnMapperProps<R extends string> {\n /** The parts the columns play — translated labels, which are required, which must\n * be numbers. See {@link ColumnRole}. */\n roles: readonly ColumnRole<R>[];\n /**\n * The table read through the current mapping, on every change: the text, the header\n * checkbox, a role. `null` while there is no table at all (an empty box). Use it when\n * `result.complete`; until then `result.missing` says what is not placed yet.\n *\n * The rows are strings. A numeric role's cells are guaranteed to read with\n * `tableNumber(cell, result.decimalComma)`; anything else is the caller's to convert.\n */\n onChange: (result: ColumnMapperResult<R> | null) => void;\n /** The paste box's label. Default: `labels.paste`. */\n label?: ReactNode;\n /** The caption under the paste box. Default: `labels.pasteHint`. */\n hint?: ReactNode;\n /** What the file dialog offers, and what a drop is checked against. Default:\n * `.csv,.tsv,.txt,.dat,.asc`. */\n accept?: string;\n /** The largest file taken, in bytes. Default: no limit. */\n maxSize?: number;\n /** Text to start with. `onChange` is called with its result once, on mount. */\n defaultText?: string;\n /** Rows in the preview. Default 5. */\n previewRows?: number;\n /** The first mapping for a new table. Default {@link guessMapping}: a column named\n * like a role gets it, and the required roles left over take the free columns in\n * order. */\n guess?: (table: TextTable) => ColumnMapping<R>;\n disabled?: boolean;\n labels?: Partial<ColumnMapperLabels>;\n className?: string;\n}\n\ninterface MapperState<R extends string> {\n text: string;\n /** The reader's answer to \"does the first line name the columns\", or `null` for\n * the parse's own. */\n header: boolean | null;\n table: TextTable;\n mapping: ColumnMapping<R>;\n}\n\nconst hasFiles = (event: DragEvent) =>\n Array.from(event.dataTransfer?.types ?? []).includes(\"Files\");\n\n/**\n * Paste, drop or choose a table, see what it was read as, and say which column is\n * which — Kurvenschmiede's playground signal and comparison input as one kit part.\n *\n * Everything the parse assumed is stated, because a guess the reader cannot see is a\n * guess they cannot correct: the shape it found, the separator, the decimal\n * convention (\"decimal comma (1,5)\"), and every line it could not read, by number and\n * with its text. The header line is a checkbox, since the detection is a guess either\n * way and toggling it does not move a column (the mapping is kept, keksdose's\n * `keepRoles`). A new file is a new table and is mapped afresh; typing that changes the\n * column count re-guesses, because the old indexes point at nothing.\n *\n * A file can be chosen, dropped on the button, or dropped on the paste box — which,\n * left to the browser, would open the file in place of the page. It is read as UTF-8,\n * or as Windows-1252 when it is not UTF-8 ({@link readTextFile}).\n *\n * A two-step wizard that keeps the drop and the mapping apart (keksdose's) uses the\n * parts: {@link parseTextTable} or its own server's sniff, then {@link ColumnRoleTable},\n * then {@link readMappedTable}.\n */\nexport function ColumnMapper<R extends string>({\n roles,\n onChange,\n label,\n hint,\n accept = DEFAULT_ACCEPT,\n maxSize,\n defaultText = \"\",\n previewRows = 5,\n guess,\n disabled = false,\n labels: labelsProp,\n className,\n}: ColumnMapperProps<R>) {\n const labels: ColumnMapperLabels = useKitLabels(\n \"columnMapper\",\n DEFAULT_COLUMN_MAPPER_LABELS,\n labelsProp,\n );\n const firstMapping = (table: TextTable) =>\n guess ? guess(table) : guessMapping(roles, table.header, table.width);\n const [state, setState] = useState<MapperState<R>>(() => {\n const table = parseTextTable(defaultText);\n return {\n text: defaultText,\n header: null,\n table,\n mapping: firstMapping(table),\n };\n });\n const [reading, setReading] = useState(false);\n const [refusal, setRefusal] = useState<string | null>(null);\n const [dragOver, setDragOver] = useState(false);\n\n // What is drawn and what is handed over are the same computation. Not memoised: a\n // caller writes `roles={[…]}` inline, so a memo keyed on them would miss every time,\n // and the read is one pass over rows that are already split.\n const result = readMappedTable(state.table, roles, state.mapping);\n\n const commit = (next: MapperState<R>) => {\n setState(next);\n onChange(\n next.table.width === 0\n ? null\n : readMappedTable(next.table, roles, next.mapping),\n );\n };\n\n /** New text. `fresh` (a file): the reader's header answer and the mapping start over. */\n const take = (text: string, fresh: boolean) => {\n const header = fresh ? null : state.header;\n const table = parseTextTable(text, header === null ? {} : { header });\n const keep =\n !fresh && table.width === state.table.width && state.table.width > 0;\n commit({\n text,\n header,\n table,\n mapping: keep ? state.mapping : firstMapping(table),\n });\n };\n\n const load = (file: File) => {\n setRefusal(null);\n setReading(true);\n void readTextFile(file)\n .then(\n (text) => take(text, true),\n // Only the read: an error thrown by the caller's onChange is not the file's.\n () => setRefusal(labels.readError(file.name)),\n )\n .finally(() => setReading(false));\n };\n\n const refuse = (rejections: { message: string }[]) =>\n setRefusal(rejections[0]?.message ?? null);\n\n // A file dropped on the paste box. The same screening as the button's.\n const drop = useFilePicker({\n accept,\n maxSize,\n disabled,\n onFiles: ([file]) => load(file),\n onReject: refuse,\n });\n\n const seeded = useEffectEvent(() => {\n if (state.table.width > 0) onChange(result);\n });\n useEffect(() => {\n seeded();\n }, []);\n\n const { table } = state;\n const separator = labels[SEPARATOR_LABEL[table.separator]];\n const unread = result.unread;\n\n return (\n <div\n className={cn(\"min-w-0 space-y-3\", className)}\n data-slot=\"column-mapper\"\n >\n <Textarea\n label={label ?? labels.paste}\n hint={hint ?? labels.pasteHint}\n rows={5}\n wrap=\"off\"\n spellCheck={false}\n autoCapitalize=\"off\"\n autoCorrect=\"off\"\n value={state.text}\n disabled={disabled}\n className={cn(\n \"font-mono text-xs\",\n dragOver && \"rounded-md ring-2 ring-[var(--brand)]\",\n )}\n data-drag-over={dragOver || undefined}\n onChange={(event: ChangeEvent<HTMLTextAreaElement>) => {\n setRefusal(null);\n take(event.target.value, false);\n }}\n onDragEnter={(event) => {\n if (!hasFiles(event)) return;\n event.preventDefault();\n if (!disabled) setDragOver(true);\n }}\n onDragOver={(event) => {\n if (!hasFiles(event)) return;\n // Cancelled for every file drag: an uncancelled one makes the browser open\n // the file in place of the page.\n event.preventDefault();\n event.dataTransfer.dropEffect = disabled ? \"none\" : \"copy\";\n }}\n onDragLeave={() => setDragOver(false)}\n onDrop={(event) => {\n if (!hasFiles(event)) return;\n event.preventDefault();\n setDragOver(false);\n drop.take(event.dataTransfer.files);\n }}\n />\n {drop.element}\n\n <div className=\"flex flex-wrap items-center gap-x-4 gap-y-2\">\n <FileButton\n variant=\"secondary\"\n accept={accept}\n maxSize={maxSize}\n droppable\n pending={reading}\n disabled={disabled}\n onFiles={([file]) => load(file)}\n onReject={refuse}\n >\n <Upload className=\"size-4\" aria-hidden />\n {labels.chooseFile}\n </FileButton>\n {table.width > 0 && (\n <Checkbox\n label={labels.headerRow}\n checked={table.header !== null}\n disabled={disabled}\n onCheckedChange={(checked) => {\n const next = parseTextTable(state.text, { header: checked });\n // Same text, same split: the columns are where they were, and so are the\n // roles on them.\n commit({ ...state, header: checked, table: next });\n }}\n />\n )}\n </div>\n\n {refusal && (\n <AlertBanner tone=\"danger\" variant=\"inline\" size=\"sm\" block>\n {refusal}\n </AlertBanner>\n )}\n\n {table.width > 0 && (\n <>\n <p\n className=\"text-xs text-[var(--text-secondary)]\"\n data-slot=\"column-mapper-summary\"\n >\n {[\n labels.summary(table.width, result.rows.length),\n separator,\n table.decimalComma ? labels.decimalComma : labels.decimalPoint,\n ].join(\" · \")}\n </p>\n {result.rows.length === 0 && (\n <AlertBanner tone=\"warning\" variant=\"inline\" size=\"sm\" block>\n {labels.noRows}\n </AlertBanner>\n )}\n <ColumnRoleTable\n header={table.header}\n rows={result.rows}\n width={table.width}\n roles={roles}\n mapping={state.mapping}\n onMappingChange={(mapping) => commit({ ...state, mapping })}\n previewRows={previewRows}\n disabled={disabled}\n labels={labelsProp}\n />\n {unread.length > 0 && (\n <Disclosure\n variant=\"bare\"\n title={labels.unreadCount(unread.length)}\n data-slot=\"column-mapper-unread\"\n >\n <ul className=\"space-y-1 text-xs\">\n {unread.slice(0, UNREAD_LISTED).map((line) => (\n <li key={line.line} className=\"min-w-0\">\n <span className=\"block text-[var(--text-secondary)]\">\n {labels.unreadLine(line.line)}\n </span>\n <code className=\"block truncate font-mono text-[var(--text-muted)]\">\n {line.text}\n </code>\n </li>\n ))}\n {unread.length > UNREAD_LISTED && (\n <li className=\"text-[var(--text-muted)]\">\n {labels.unreadMore(unread.length - UNREAD_LISTED)}\n </li>\n )}\n </ul>\n </Disclosure>\n )}\n </>\n )}\n </div>\n );\n}\n"],"mappings":";AA6RkB,SAoUV,UApUU,KAGA,YAHA;AA7RlB,SAAS,WAAW,gBAAgB,gBAAgB;AAEpD,SAAS,cAAc;AAEvB,SAAS,cAAc,oBAAoB;AAC3C,SAAS,UAAU;AACnB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAMP,SAAS,sBAAsB;AAE/B,SAAS,mBAAmB;AAC5B,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAC3B,SAAS,YAAY,qBAAqB;AAC1C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,QAAQ,gBAAgB;AA+E1B,M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,QAAG,WAAU,4BACX,iBAAO,WAAW,OAAO,SAAS,aAAa,GAClD;AAAA,iBAEJ;AAAA;AAAA,UACF;AAAA,WAEJ;AAAA;AAAA;AAAA,EAEJ;AAEJ;","names":["table"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/column-mapper.tsx"],"sourcesContent":["import { useCallback, useEffect, useEffectEvent, useRef, useState } from \"react\";\nimport type { ChangeEvent, DragEvent, HTMLAttributes, ReactNode } from \"react\";\nimport { Upload } from \"lucide-react\";\n\nimport { useKitLabels, useKitLocale } from \"../i18n/kit-labels\";\nimport { cn } from \"../lib/cn\";\nimport {\n assignColumnRole,\n guessMapping,\n missingRoles,\n readMappedTable,\n readTextFile,\n roleOfColumn,\n} from \"../lib/column-mapping\";\nimport type {\n ColumnMapperResult,\n ColumnMapping,\n ColumnRole,\n} from \"../lib/column-mapping\";\nimport { scrollIntoStrip, useStripFade } from \"../lib/strip-fade\";\nimport { parseTextTable } from \"../lib/table-text\";\nimport type { TableSeparator, TextTable } from \"../lib/table-text\";\nimport { AlertBanner } from \"./alert-banner\";\nimport { Checkbox } from \"./checkbox\";\nimport { Disclosure } from \"./disclosure\";\nimport { FileButton, useFilePicker } from \"./file-button\";\nimport {\n Table,\n TableBody,\n TableCell,\n TableHead,\n TableHeaderCell,\n TableRow,\n} from \"./table\";\nimport { Select, Textarea } from \"./ui\";\n\n/**\n * A table pasted, dropped or chosen as a file, and which of its columns plays which\n * part — Kurvenschmiede's columns input and keksdose's bank-file mapping step, once.\n *\n * Kurvenschmiede (`features/control/columns-input.tsx` + `csv.ts`) reads a recorder's\n * export into a playground signal (time, value) and a comparison (time, setpoint,\n * actual): a textarea, a file button, a parse, a select per role, and a line that says\n * which decimal convention was assumed and how many lines were skipped. keksdose\n * (`import-map-step.tsx`) shows a bank's CSV as a table with a role select on every\n * column's header, the file's real values under it, ignored columns dimmed, and what\n * the import still needs named under it. Same problem, two hand-built answers.\n *\n * Two layers, so both shapes fit:\n *\n * * {@link ColumnMapper} — the whole single panel: paste, drop or choose → parse\n * ({@link parseTextTable}: separator, decimal convention, header line, all stated\n * back) → preview with a role per column → `onChange(result)`. Kurvenschmiede's.\n * * {@link ColumnRoleTable} — the preview with the role selects alone, controlled, over\n * rows the caller already has. keksdose's map step, whose rows come from its server's\n * sniff (encodings, quoted multi-line cells, skipped title rows) and whose mapping\n * lives in the wizard's state between steps.\n *\n * The rules under both are headless in `lib/column-mapping.ts`: a role moves rather\n * than doubling up, what is missing is named, and the rows a numeric role cannot read\n * are reported by line number rather than dropped.\n */\n\n// ── Labels ────────────────────────────────────────────────────────────────────\n\nexport interface ColumnMapperLabels {\n /** The paste box's label. */\n paste: string;\n /** The caption under the paste box. */\n pasteHint: string;\n /** The file button. */\n chooseFile: string;\n /** A chosen or dropped file whose bytes could not be read at all. */\n readError: (name: string) => string;\n /** The checkbox that says whether the first line names the columns. */\n headerRow: string;\n /** What was read: so many columns and rows. */\n summary: (columns: number, rows: number) => string;\n /** The separator that was assumed. */\n separatorSemicolon: string;\n separatorComma: string;\n separatorTab: string;\n separatorSpace: string;\n /** The decimal convention that was assumed — with an example, because \"decimal\n * comma\" alone is a term, and `1,5` is something a reader recognises. */\n decimalComma: string;\n decimalPoint: string;\n /** The title over the lines that could not be read. */\n unreadCount: (count: number) => string;\n /** One of them. */\n unreadLine: (line: number) => string;\n /** Past the first hundred listed. */\n unreadMore: (count: number) => string;\n /** The text has content, and none of it is a row. */\n noRows: string;\n /** The preview table's name. */\n table: string;\n /** A column the table names no header for. */\n columnN: (n: number) => string;\n /** The role select on a column's header — its accessible name. */\n roleOf: (column: string) => string;\n /** The role select's \"no role\" option. */\n ignore: string;\n /** A required role in the select — only while some role is NOT required: when\n * every one is, the mark tells no role from another (0.24, Kurvenschmiede). */\n requiredRole: (role: string) => string;\n /** Under the preview, when it shows fewer rows than were read. */\n previewOf: (shown: number, total: number) => string;\n /** A required group's roles, already joined as a list with \"or\". */\n oneOf: (roles: string) => string;\n /** What the table still needs, already joined as a list with \"and\". */\n missing: (roles: string) => string;\n}\n\nexport const DEFAULT_COLUMN_MAPPER_LABELS: ColumnMapperLabels = {\n paste: \"Paste a table\",\n pasteHint:\n \"Copy the rows out of a spreadsheet and paste them here, or drop a CSV or text file.\",\n chooseFile: \"Choose a file\",\n readError: (name) => `“${name}” could not be read`,\n headerRow: \"The first line names the columns\",\n summary: (columns, rows) =>\n `${columns} ${columns === 1 ? \"column\" : \"columns\"}, ${rows} ${rows === 1 ? \"row\" : \"rows\"}`,\n separatorSemicolon: \"separated by semicolons\",\n separatorComma: \"separated by commas\",\n separatorTab: \"separated by tabs\",\n separatorSpace: \"separated by spaces\",\n decimalComma: \"decimal comma (1,5)\",\n decimalPoint: \"decimal point (1.5)\",\n unreadCount: (count) =>\n count === 1\n ? \"1 line could not be read\"\n : `${count} lines could not be read`,\n unreadLine: (line) => `Line ${line} could not be read`,\n unreadMore: (count) => `…and ${count} more`,\n noRows: \"No line of this text reads as a row of the table.\",\n table: \"Columns and their roles\",\n columnN: (n) => `Column ${n}`,\n roleOf: (column) => `What does column “${column}” hold?`,\n ignore: \"Ignore\",\n requiredRole: (role) => `${role} (required)`,\n previewOf: (shown, total) =>\n shown === 1\n ? `The first of ${total} rows`\n : `The first ${shown} of ${total} rows`,\n oneOf: (roles) => `either ${roles}`,\n missing: (roles) => `Still needed: ${roles}.`,\n};\n\nconst SEPARATOR_LABEL: Record<\n TableSeparator,\n \"separatorSemicolon\" | \"separatorComma\" | \"separatorTab\" | \"separatorSpace\"\n> = {\n \";\": \"separatorSemicolon\",\n \",\": \"separatorComma\",\n \"\\t\": \"separatorTab\",\n \" \": \"separatorSpace\",\n};\n\n/** How many unread lines are listed before \"…and N more\". */\nconst UNREAD_LISTED = 100;\n\n/** A file a table is likely to be in. Extensions only, so a refusal reads \"Only .csv,\n * .tsv, … files\" rather than a list of MIME types; the parse is the real check. */\nconst DEFAULT_ACCEPT = \".csv,.tsv,.txt,.dat,.asc\";\n\nfunction formatList(\n items: string[],\n type: \"conjunction\" | \"disjunction\",\n locale: string | undefined,\n): string {\n try {\n return new Intl.ListFormat(locale, { type, style: \"long\" }).format(items);\n } catch {\n return items.join(\", \");\n }\n}\n\n// ── ColumnRoleTable ───────────────────────────────────────────────────────────\n\n/** A `data-*` attribute, typed so `{ \"data-private\": \"\" }` needs no cast. */\ntype DataAttributes = { [key: `data-${string}`]: string | number | boolean | undefined };\n\n/**\n * What {@link ColumnRoleTableProps.bodyProps} puts on the preview's `<tbody>`: `data-*`\n * hooks, an `id`, a class, a style.\n */\nexport type ColumnRoleTableBodyProps = Omit<\n HTMLAttributes<HTMLTableSectionElement>,\n \"children\" | \"dangerouslySetInnerHTML\"\n> &\n DataAttributes;\n\n/**\n * What {@link ColumnRoleTableProps.rowProps} returns for one preview row's `<tr>` —\n * the same shape as LineItems' `LineItemsRowProps`, on a table row.\n */\nexport type ColumnRoleTableRowProps = Omit<\n HTMLAttributes<HTMLTableRowElement>,\n \"children\" | \"dangerouslySetInnerHTML\"\n> &\n DataAttributes;\n\nexport interface ColumnRoleTableProps<\n R extends string,\n M extends ColumnMapping<R> = ColumnMapping<R>,\n> {\n /** The columns' names — the file's header line — or `null` for a table without one\n * (each column is then \"Column 1\", \"Column 2\", …). */\n header: readonly string[] | null;\n /** The rows to preview, as text. Only the first {@link previewRows} are drawn. */\n rows: readonly (readonly string[])[];\n /** How many columns. Default: the header's length or the widest previewed row. */\n width?: number;\n /** The parts a column can play. */\n roles: readonly ColumnRole<R>[];\n /** Role → column. Any object with the roles as nullable number fields — keksdose's\n * `CsvMapping` as it stands; the other fields are handed back untouched. */\n mapping: M;\n /** The next mapping, with the picked role moved onto its column. */\n onMappingChange: (next: M) => void;\n /** Default 5. */\n previewRows?: number;\n /** How many rows the table has in all, for \"The first 5 of 120 rows\". Default:\n * `rows.length`. */\n totalRows?: number;\n /** Every role select disabled — keksdose locks them while a re-sniff replaces the\n * table they point into. */\n disabled?: boolean;\n /**\n * Extra attributes for the preview's `<tbody>` (0.24) — keksdose: the sample rows are\n * the user's own bank data (payees, memos, amounts), and its demo mode blurs exactly\n * that through `.demo-mode [data-private]` (#336). With nowhere to put the attribute,\n * its map step reached into the table with a `useLayoutEffect` that set it on the\n * `<tbody>` after every commit; `bodyProps={{ \"data-private\": \"\" }}` declares it.\n * There is deliberately no head counterpart: the column names and the role selects\n * are what such a mode is there to show.\n *\n * Spread on the kit `TableBody`; a `className` is added to its own.\n */\n bodyProps?: ColumnRoleTableBodyProps;\n /**\n * Extra attributes for one preview row's `<tr>`, from its cells and its index in the\n * preview (0.24) — the contract of LineItems' `rowProps` (keksdose K20), on a table:\n * `data-*` hooks (a per-row `data-private`, a test id), an `id`, a class. Called for\n * the rows drawn, the first {@link previewRows}. The row has no attributes of its own\n * to protect; a `className` is added after its classes.\n */\n rowProps?: (row: readonly string[], index: number) => ColumnRoleTableRowProps | undefined;\n labels?: Partial<ColumnMapperLabels>;\n className?: string;\n}\n\n/**\n * A table's first rows, with a role select on every column's header.\n *\n * keksdose's mapping step (dev#462: \"make it more table like, where the table columns\n * can be chosen from the input and the column data changes with the chosen column\n * header\"): the file IS the form. The file's own column name sits on top, verbatim —\n * it is how the reader recognises the column; under it the role, picked in place;\n * under that the column's real values, so a column that is one off shows up here and\n * not after the import. A column with no role says \"Ignore\" and its values are dimmed:\n * the state that most needs to be visible in a twelve-column bank export.\n *\n * Picking a role another column holds MOVES it ({@link assignColumnRole}). What the\n * table still needs is named under it — a required group as \"either Amount, Debit or\n * Credit\". Required roles say \"(required)\" in the list only where some role is not\n * (0.24): Kurvenschmiede's roles are all required, so the mark told no option from\n * another, and on a phone it cut the role's own name short (\"Zeit (s) (erforderl…\")\n * — the part of the option the reader has to read. The \"Still needed\" line already\n * says what is missing; a mark that distinguishes nothing is only noise.\n *\n * The table scrolls sideways inside its own box (the kit {@link Table}'s wrapper, a\n * named, keyboard-reachable region while it overflows), so a wide export never widens\n * the page at 390px. An edge with columns behind it fades out (0.24, Kurvenschmiede:\n * on a phone the fourth column's select sat off-screen and nothing said there was more\n * to the right; phone scrollbars are overlays that show only while you drag). It is\n * the kit Tabs strip's measured fade: drawn only while something is hidden on that\n * side, so a table that fits is painted as before; both ends once scrolled into the\n * middle; the reading direction's own in RTL; never animated, so there is nothing for\n * reduced motion to turn off; and a `mask-image`, which changes no layout and needs no\n * background colour to fade to. A role select focused behind the fade is scrolled\n * clear of it.\n */\nexport function ColumnRoleTable<\n R extends string,\n M extends ColumnMapping<R> = ColumnMapping<R>,\n>({\n header,\n rows,\n width: widthProp,\n roles,\n mapping,\n onMappingChange,\n previewRows = 5,\n totalRows,\n disabled,\n bodyProps,\n rowProps,\n labels: labelsProp,\n className,\n}: ColumnRoleTableProps<R, M>) {\n const labels: ColumnMapperLabels = useKitLabels(\n \"columnMapper\",\n DEFAULT_COLUMN_MAPPER_LABELS,\n labelsProp,\n );\n const locale = useKitLocale();\n const shown = rows.slice(0, previewRows);\n const width =\n widthProp ??\n shown.reduce(\n (widest, row) => Math.max(widest, row.length),\n header?.length ?? 0,\n );\n const columns = Array.from({ length: width }, (_, index) => index);\n const total = totalRows ?? rows.length;\n const nameOf = (column: number) =>\n header?.[column] || labels.columnN(column + 1);\n const labelOf = (value: R) =>\n roles.find((role) => role.value === value)?.label ?? value;\n const gaps = missingRoles(roles, mapping, width).map((gap) =>\n gap.length === 1\n ? labelOf(gap[0])\n : labels.oneOf(formatList(gap.map(labelOf), \"disjunction\", locale)),\n );\n // \"(required)\" only where it tells one option from another.\n const markRequired = roles.some((role) => role.required !== true);\n\n // The Table's own scroll wrapper — the `<table>`'s parent — is what overflows; the\n // fade is measured on it and drawn on the box round it, which has the same edges.\n const scroller = useRef<HTMLElement | null>(null);\n const tableRef = useCallback((table: HTMLTableElement | null) => {\n scroller.current = table?.parentElement ?? null;\n }, []);\n const fade = useStripFade(scroller);\n\n return (\n <div\n className={cn(\"min-w-0 space-y-1.5\", className)}\n data-slot=\"column-role-table\"\n >\n <div\n data-slot=\"column-role-table-scroll\"\n // In reading-direction terms (\"start\", \"end\", \"both\"), for a caller's styling.\n data-overflow={fade.overflow}\n style={\n fade.mask\n ? { maskImage: fade.mask, WebkitMaskImage: fade.mask }\n : undefined\n }\n >\n <Table\n ref={tableRef}\n density=\"compact\"\n framed\n aria-label={labels.table}\n >\n <TableHead>\n <TableRow>\n {columns.map((column) => {\n const role = roleOfColumn(roles, mapping, column);\n const name = nameOf(column);\n return (\n <TableHeaderCell\n key={column}\n scope=\"col\"\n className=\"min-w-36 py-2 align-top\"\n >\n <span className=\"block max-w-56 truncate pb-1 text-[11px] font-normal text-[var(--text-muted)]\">\n {name}\n </span>\n <Select\n size=\"sm\"\n className=\"w-full\"\n aria-label={labels.roleOf(name)}\n value={role ?? \"\"}\n disabled={disabled}\n // Focus brings a select behind the fade clear of it — the browser's\n // own scroll stops at the edge, under the fade.\n onFocus={(event) => {\n const cell = event.currentTarget.closest(\"th\");\n if (scroller.current && cell)\n scrollIntoStrip(scroller.current, cell);\n }}\n onChange={(event) =>\n onMappingChange(\n assignColumnRole(\n roles,\n mapping,\n column,\n event.target.value === \"\"\n ? null\n : (event.target.value as R),\n ),\n )\n }\n >\n <option value=\"\">{labels.ignore}</option>\n {roles.map((option) => (\n <option key={option.value} value={option.value}>\n {option.required === true && markRequired\n ? labels.requiredRole(option.label)\n : option.label}\n </option>\n ))}\n </Select>\n </TableHeaderCell>\n );\n })}\n </TableRow>\n </TableHead>\n <TableBody {...bodyProps}>\n {shown.map((row, index) => (\n <TableRow {...rowProps?.(row, index)} key={index}>\n {columns.map((column) => (\n <TableCell\n key={column}\n data-ignored={\n roleOfColumn(roles, mapping, column) === null || undefined\n }\n className={cn(\n \"font-mono whitespace-nowrap\",\n // Dimmed, not hidden: its values are what tell you whether ignoring\n // it was right.\n roleOfColumn(roles, mapping, column) === null &&\n \"text-[var(--text-muted)]\",\n )}\n >\n <span className=\"block max-w-56 truncate\">\n {row[column] ?? \"\"}\n </span>\n </TableCell>\n ))}\n </TableRow>\n ))}\n </TableBody>\n </Table>\n </div>\n {total > shown.length && (\n <p className=\"text-xs text-[var(--text-muted)]\">\n {labels.previewOf(shown.length, total)}\n </p>\n )}\n {gaps.length > 0 && (\n <AlertBanner tone=\"warning\" variant=\"inline\" size=\"sm\" block>\n {labels.missing(formatList(gaps, \"conjunction\", locale))}\n </AlertBanner>\n )}\n </div>\n );\n}\n\n// ── ColumnMapper ──────────────────────────────────────────────────────────────\n\nexport interface ColumnMapperProps<R extends string> {\n /** The parts the columns play — translated labels, which are required, which must\n * be numbers. See {@link ColumnRole}. */\n roles: readonly ColumnRole<R>[];\n /**\n * The table read through the current mapping, on every change: the text, the header\n * checkbox, a role. `null` while there is no table at all (an empty box). Use it when\n * `result.complete`; until then `result.missing` says what is not placed yet.\n *\n * The rows are strings. A numeric role's cells are guaranteed to read with\n * `tableNumber(cell, result.decimalComma)`; anything else is the caller's to convert.\n */\n onChange: (result: ColumnMapperResult<R> | null) => void;\n /** The paste box's label. Default: `labels.paste`. */\n label?: ReactNode;\n /** The caption under the paste box. Default: `labels.pasteHint`. */\n hint?: ReactNode;\n /** What the file dialog offers, and what a drop is checked against. Default:\n * `.csv,.tsv,.txt,.dat,.asc`. */\n accept?: string;\n /** The largest file taken, in bytes. Default: no limit. */\n maxSize?: number;\n /** Text to start with. `onChange` is called with its result once, on mount. */\n defaultText?: string;\n /** Rows in the preview. Default 5. */\n previewRows?: number;\n /** The first mapping for a new table. Default {@link guessMapping}: a column named\n * like a role gets it, and the required roles left over take the free columns in\n * order. */\n guess?: (table: TextTable) => ColumnMapping<R>;\n disabled?: boolean;\n /** The preview table's `<tbody>` attributes — {@link ColumnRoleTableProps.bodyProps}\n * (0.24): `{ \"data-private\": \"\" }` for a table of someone's own data. */\n bodyProps?: ColumnRoleTableBodyProps;\n /** One preview row's `<tr>` attributes — {@link ColumnRoleTableProps.rowProps}\n * (0.24). `row` is the row as read, `index` its place in the preview. */\n rowProps?: (row: readonly string[], index: number) => ColumnRoleTableRowProps | undefined;\n labels?: Partial<ColumnMapperLabels>;\n className?: string;\n}\n\ninterface MapperState<R extends string> {\n text: string;\n /** The reader's answer to \"does the first line name the columns\", or `null` for\n * the parse's own. */\n header: boolean | null;\n table: TextTable;\n mapping: ColumnMapping<R>;\n}\n\nconst hasFiles = (event: DragEvent) =>\n Array.from(event.dataTransfer?.types ?? []).includes(\"Files\");\n\n/**\n * Paste, drop or choose a table, see what it was read as, and say which column is\n * which — Kurvenschmiede's playground signal and comparison input as one kit part.\n *\n * Everything the parse assumed is stated, because a guess the reader cannot see is a\n * guess they cannot correct: the shape it found, the separator, the decimal\n * convention (\"decimal comma (1,5)\"), and every line it could not read, by number and\n * with its text. The header line is a checkbox, since the detection is a guess either\n * way and toggling it does not move a column (the mapping is kept, keksdose's\n * `keepRoles`). A new file is a new table and is mapped afresh; typing that changes the\n * column count re-guesses, because the old indexes point at nothing.\n *\n * A file can be chosen, dropped on the button, or dropped on the paste box — which,\n * left to the browser, would open the file in place of the page. It is read as UTF-8,\n * or as Windows-1252 when it is not UTF-8 ({@link readTextFile}).\n *\n * A two-step wizard that keeps the drop and the mapping apart (keksdose's) uses the\n * parts: {@link parseTextTable} or its own server's sniff, then {@link ColumnRoleTable},\n * then {@link readMappedTable}.\n */\nexport function ColumnMapper<R extends string>({\n roles,\n onChange,\n label,\n hint,\n accept = DEFAULT_ACCEPT,\n maxSize,\n defaultText = \"\",\n previewRows = 5,\n guess,\n disabled = false,\n bodyProps,\n rowProps,\n labels: labelsProp,\n className,\n}: ColumnMapperProps<R>) {\n const labels: ColumnMapperLabels = useKitLabels(\n \"columnMapper\",\n DEFAULT_COLUMN_MAPPER_LABELS,\n labelsProp,\n );\n const firstMapping = (table: TextTable) =>\n guess ? guess(table) : guessMapping(roles, table.header, table.width);\n const [state, setState] = useState<MapperState<R>>(() => {\n const table = parseTextTable(defaultText);\n return {\n text: defaultText,\n header: null,\n table,\n mapping: firstMapping(table),\n };\n });\n const [reading, setReading] = useState(false);\n const [refusal, setRefusal] = useState<string | null>(null);\n const [dragOver, setDragOver] = useState(false);\n\n // What is drawn and what is handed over are the same computation. Not memoised: a\n // caller writes `roles={[…]}` inline, so a memo keyed on them would miss every time,\n // and the read is one pass over rows that are already split.\n const result = readMappedTable(state.table, roles, state.mapping);\n\n const commit = (next: MapperState<R>) => {\n setState(next);\n onChange(\n next.table.width === 0\n ? null\n : readMappedTable(next.table, roles, next.mapping),\n );\n };\n\n /** New text. `fresh` (a file): the reader's header answer and the mapping start over. */\n const take = (text: string, fresh: boolean) => {\n const header = fresh ? null : state.header;\n const table = parseTextTable(text, header === null ? {} : { header });\n const keep =\n !fresh && table.width === state.table.width && state.table.width > 0;\n commit({\n text,\n header,\n table,\n mapping: keep ? state.mapping : firstMapping(table),\n });\n };\n\n const load = (file: File) => {\n setRefusal(null);\n setReading(true);\n void readTextFile(file)\n .then(\n (text) => take(text, true),\n // Only the read: an error thrown by the caller's onChange is not the file's.\n () => setRefusal(labels.readError(file.name)),\n )\n .finally(() => setReading(false));\n };\n\n const refuse = (rejections: { message: string }[]) =>\n setRefusal(rejections[0]?.message ?? null);\n\n // A file dropped on the paste box. The same screening as the button's.\n const drop = useFilePicker({\n accept,\n maxSize,\n disabled,\n onFiles: ([file]) => load(file),\n onReject: refuse,\n });\n\n const seeded = useEffectEvent(() => {\n if (state.table.width > 0) onChange(result);\n });\n useEffect(() => {\n seeded();\n }, []);\n\n const { table } = state;\n const separator = labels[SEPARATOR_LABEL[table.separator]];\n const unread = result.unread;\n\n return (\n <div\n className={cn(\"min-w-0 space-y-3\", className)}\n data-slot=\"column-mapper\"\n >\n <Textarea\n label={label ?? labels.paste}\n hint={hint ?? labels.pasteHint}\n rows={5}\n wrap=\"off\"\n spellCheck={false}\n autoCapitalize=\"off\"\n autoCorrect=\"off\"\n value={state.text}\n disabled={disabled}\n className={cn(\n \"font-mono text-xs\",\n dragOver && \"rounded-md ring-2 ring-[var(--brand)]\",\n )}\n data-drag-over={dragOver || undefined}\n onChange={(event: ChangeEvent<HTMLTextAreaElement>) => {\n setRefusal(null);\n take(event.target.value, false);\n }}\n onDragEnter={(event) => {\n if (!hasFiles(event)) return;\n event.preventDefault();\n if (!disabled) setDragOver(true);\n }}\n onDragOver={(event) => {\n if (!hasFiles(event)) return;\n // Cancelled for every file drag: an uncancelled one makes the browser open\n // the file in place of the page.\n event.preventDefault();\n event.dataTransfer.dropEffect = disabled ? \"none\" : \"copy\";\n }}\n onDragLeave={() => setDragOver(false)}\n onDrop={(event) => {\n if (!hasFiles(event)) return;\n event.preventDefault();\n setDragOver(false);\n drop.take(event.dataTransfer.files);\n }}\n />\n {drop.element}\n\n <div className=\"flex flex-wrap items-center gap-x-4 gap-y-2\">\n <FileButton\n variant=\"secondary\"\n accept={accept}\n maxSize={maxSize}\n droppable\n pending={reading}\n disabled={disabled}\n onFiles={([file]) => load(file)}\n onReject={refuse}\n >\n <Upload className=\"size-4\" aria-hidden />\n {labels.chooseFile}\n </FileButton>\n {table.width > 0 && (\n <Checkbox\n label={labels.headerRow}\n checked={table.header !== null}\n disabled={disabled}\n onCheckedChange={(checked) => {\n const next = parseTextTable(state.text, { header: checked });\n // Same text, same split: the columns are where they were, and so are the\n // roles on them.\n commit({ ...state, header: checked, table: next });\n }}\n />\n )}\n </div>\n\n {refusal && (\n <AlertBanner tone=\"danger\" variant=\"inline\" size=\"sm\" block>\n {refusal}\n </AlertBanner>\n )}\n\n {table.width > 0 && (\n <>\n <p\n className=\"text-xs text-[var(--text-secondary)]\"\n data-slot=\"column-mapper-summary\"\n >\n {[\n labels.summary(table.width, result.rows.length),\n separator,\n table.decimalComma ? labels.decimalComma : labels.decimalPoint,\n ].join(\" · \")}\n </p>\n {result.rows.length === 0 && (\n <AlertBanner tone=\"warning\" variant=\"inline\" size=\"sm\" block>\n {labels.noRows}\n </AlertBanner>\n )}\n <ColumnRoleTable\n header={table.header}\n rows={result.rows}\n width={table.width}\n roles={roles}\n mapping={state.mapping}\n onMappingChange={(mapping) => commit({ ...state, mapping })}\n previewRows={previewRows}\n disabled={disabled}\n bodyProps={bodyProps}\n rowProps={rowProps}\n labels={labelsProp}\n />\n {unread.length > 0 && (\n <Disclosure\n variant=\"bare\"\n title={labels.unreadCount(unread.length)}\n data-slot=\"column-mapper-unread\"\n >\n <ul className=\"space-y-1 text-xs\">\n {unread.slice(0, UNREAD_LISTED).map((line) => (\n <li key={line.line} className=\"min-w-0\">\n <span className=\"block text-[var(--text-secondary)]\">\n {labels.unreadLine(line.line)}\n </span>\n <code className=\"block truncate font-mono text-[var(--text-muted)]\">\n {line.text}\n </code>\n </li>\n ))}\n {unread.length > UNREAD_LISTED && (\n <li className=\"text-[var(--text-muted)]\">\n {labels.unreadMore(unread.length - UNREAD_LISTED)}\n </li>\n )}\n </ul>\n </Disclosure>\n )}\n </>\n )}\n </div>\n );\n}\n"],"mappings":";AAiXoB,SAoVZ,UApVY,KAGA,YAHA;AA6CN;AA9Zd,SAAS,aAAa,WAAW,gBAAgB,QAAQ,gBAAgB;AAEzE,SAAS,cAAc;AAEvB,SAAS,cAAc,oBAAoB;AAC3C,SAAS,UAAU;AACnB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAMP,SAAS,iBAAiB,oBAAoB;AAC9C,SAAS,sBAAsB;AAE/B,SAAS,mBAAmB;AAC5B,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAC3B,SAAS,YAAY,qBAAqB;AAC1C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,QAAQ,gBAAgB;AAgF1B,MAAM,+BAAmD;AAAA,EAC9D,OAAO;AAAA,EACP,WACE;AAAA,EACF,YAAY;AAAA,EACZ,WAAW,CAAC,SAAS,SAAI,IAAI;AAAA,EAC7B,WAAW;AAAA,EACX,SAAS,CAAC,SAAS,SACjB,GAAG,OAAO,IAAI,YAAY,IAAI,WAAW,SAAS,KAAK,IAAI,IAAI,SAAS,IAAI,QAAQ,MA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AA,cAC1D;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA,QAAQ;AAAA;AAAA,UACV;AAAA,UACC,OAAO,SAAS,KACf;AAAA,YAAC;AAAA;AAAA,cACC,SAAQ;AAAA,cACR,OAAO,OAAO,YAAY,OAAO,MAAM;AAAA,cACvC,aAAU;AAAA,cAEV,+BAAC,QAAG,WAAU,qBACX;AAAA,uBAAO,MAAM,GAAG,aAAa,EAAE,IAAI,CAAC,SACnC,qBAAC,QAAmB,WAAU,WAC5B;AAAA,sCAAC,UAAK,WAAU,sCACb,iBAAO,WAAW,KAAK,IAAI,GAC9B;AAAA,kBACA,oBAAC,UAAK,WAAU,qDACb,eAAK,MACR;AAAA,qBANO,KAAK,IAOd,CACD;AAAA,gBACA,OAAO,SAAS,iBACf,oBAAC,QAAG,WAAU,4BACX,iBAAO,WAAW,OAAO,SAAS,aAAa,GAClD;AAAA,iBAEJ;AAAA;AAAA,UACF;AAAA,WAEJ;AAAA;AAAA;AAAA,EAEJ;AAEJ;","names":["table"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
2
|
+
import { ComponentPropsWithoutRef, ReactNode, Ref } from 'react';
|
|
3
3
|
import { ComboClearValue, ComboOption } from './combobox-core.js';
|
|
4
4
|
import '../hooks/use-anchored-rect.js';
|
|
5
5
|
import '../hooks/use-anchored-panel.js';
|
|
@@ -90,6 +90,14 @@ interface ComboboxProps extends Omit<ComponentPropsWithoutRef<"div">, "id" | "on
|
|
|
90
90
|
maxSuggestions?: number;
|
|
91
91
|
searchPlaceholder?: string;
|
|
92
92
|
closeLabel?: string;
|
|
93
|
+
/**
|
|
94
|
+
* The phone sheet's heading — and, as a string, the dialog's accessible name — for a
|
|
95
|
+
* field whose label is drawn by someone else: a form's `FormLabel` above it,
|
|
96
|
+
* which `RhfTextCombobox` hands over here (0.24). Default: `label`. Without either, the
|
|
97
|
+
* full-screen sheet opened untitled and unnamed, the one screen on a phone that has to
|
|
98
|
+
* say what it is asking for (live #200).
|
|
99
|
+
*/
|
|
100
|
+
sheetTitle?: ReactNode;
|
|
93
101
|
/**
|
|
94
102
|
* Label for the row that COMMITS a value the list does not contain — e.g.
|
|
95
103
|
* `(v) => \`Add "${v}" as payee\``. Supplying it turns the free text into
|
|
@@ -106,6 +114,15 @@ interface ComboboxProps extends Omit<ComponentPropsWithoutRef<"div">, "id" | "on
|
|
|
106
114
|
* values are all supposed to already exist.
|
|
107
115
|
*/
|
|
108
116
|
createLabel?: (value: string) => string;
|
|
117
|
+
/**
|
|
118
|
+
* The `<input>` — the control a reader types in and the one focus belongs on — as a
|
|
119
|
+
* React 19 ref prop, the way {@link CountrySelect} takes its trigger's (0.24, kastlan:
|
|
120
|
+
* react-hook-form's focus-on-error calls `focus()` on whatever `field.ref` is handed,
|
|
121
|
+
* and a combobox with no ref inside a hand-wired `RhfField` gave it nothing, so a
|
|
122
|
+
* failed submit could not take the user to it). Not the wrapper: a ref is for focus,
|
|
123
|
+
* measurement and selection, and all three are the input's. `RhfTextCombobox` passes it.
|
|
124
|
+
*/
|
|
125
|
+
ref?: Ref<HTMLInputElement>;
|
|
109
126
|
}
|
|
110
127
|
/**
|
|
111
128
|
* Free-text combobox that looks like the shared {@link Select} (same FIELD_BASE
|
|
@@ -154,6 +171,11 @@ interface InlineEntityComboboxProps<V extends string | number, C extends ComboCl
|
|
|
154
171
|
* list simply does not open. Default: `combobox.noResults` from the provider. */
|
|
155
172
|
emptyLabel?: string;
|
|
156
173
|
closeLabel?: string;
|
|
174
|
+
/** The phone sheet's heading (and, as a string, its accessible name) for a field
|
|
175
|
+
* whose label is drawn by someone else — a form's `FormLabel`;
|
|
176
|
+
* `RhfInlineEntityCombobox` hands its label over here (0.24). Default: `label`.
|
|
177
|
+
* See {@link Combobox}'s `sheetTitle`. */
|
|
178
|
+
sheetTitle?: ReactNode;
|
|
157
179
|
/** Offer a clear "×" in place of the chevron whenever something is selected.
|
|
158
180
|
*
|
|
159
181
|
* Emptying the text already clears (see {@link reconcile}), and on a desktop that
|
|
@@ -230,6 +252,16 @@ interface InlineEntityComboboxProps<V extends string | number, C extends ComboCl
|
|
|
230
252
|
* `commit`: a locked field opens no list at all.
|
|
231
253
|
*/
|
|
232
254
|
createCommit?: boolean;
|
|
255
|
+
/**
|
|
256
|
+
* The `<input>` — the focusable control, the one a reader types in — as a React 19
|
|
257
|
+
* ref prop (0.24, kastlan). Its account picker is this component inside an
|
|
258
|
+
* `RhfField` render, and react-hook-form's focus-on-error calls `focus()` on whatever
|
|
259
|
+
* `field.ref` is handed: with no ref there was nothing to hand it, so a line-item form
|
|
260
|
+
* whose account was missing failed its submit and left the caret where it was. Pass
|
|
261
|
+
* `field.ref` here, or use `RhfInlineEntityCombobox`, which does. The wrapper is not
|
|
262
|
+
* reachable this way — focus and selection are the input's. See {@link Combobox}'s `ref`.
|
|
263
|
+
*/
|
|
264
|
+
ref?: Ref<HTMLInputElement>;
|
|
233
265
|
}
|
|
234
266
|
/**
|
|
235
267
|
* The id-keyed sibling of {@link Combobox}: identical anatomy (a real text input
|
|
@@ -90,6 +90,7 @@ function Combobox(props) {
|
|
|
90
90
|
maxSuggestions,
|
|
91
91
|
searchPlaceholder,
|
|
92
92
|
closeLabel,
|
|
93
|
+
sheetTitle,
|
|
93
94
|
createLabel,
|
|
94
95
|
invalid,
|
|
95
96
|
error,
|
|
@@ -101,6 +102,7 @@ function Combobox(props) {
|
|
|
101
102
|
autoFocus,
|
|
102
103
|
onBlur,
|
|
103
104
|
onSubmit,
|
|
105
|
+
ref,
|
|
104
106
|
"aria-label": ariaLabel,
|
|
105
107
|
// Off `rest` and onto the <input>, which is the combobox a reader meets: `Field`'s
|
|
106
108
|
// render-prop spreads `{ id, aria-describedby, aria-invalid, aria-required }`, and
|
|
@@ -199,6 +201,7 @@ function Combobox(props) {
|
|
|
199
201
|
/* @__PURE__ */ jsx(
|
|
200
202
|
"input",
|
|
201
203
|
{
|
|
204
|
+
ref,
|
|
202
205
|
id: fieldId,
|
|
203
206
|
value,
|
|
204
207
|
placeholder,
|
|
@@ -296,7 +299,7 @@ function Combobox(props) {
|
|
|
296
299
|
{
|
|
297
300
|
open: open && !inert,
|
|
298
301
|
onClose: () => setOpen(false),
|
|
299
|
-
title: label,
|
|
302
|
+
title: sheetTitle ?? label,
|
|
300
303
|
query: value,
|
|
301
304
|
onQueryChange: (v) => {
|
|
302
305
|
onChange(v);
|
|
@@ -428,6 +431,7 @@ function InlineEntityCombobox(props) {
|
|
|
428
431
|
searchPlaceholder,
|
|
429
432
|
emptyLabel,
|
|
430
433
|
closeLabel,
|
|
434
|
+
sheetTitle,
|
|
431
435
|
clearable,
|
|
432
436
|
clearLabel,
|
|
433
437
|
disabledReason,
|
|
@@ -439,6 +443,7 @@ function InlineEntityCombobox(props) {
|
|
|
439
443
|
invalid,
|
|
440
444
|
error,
|
|
441
445
|
hint,
|
|
446
|
+
ref,
|
|
442
447
|
"aria-label": ariaLabel,
|
|
443
448
|
// Off `rest` and onto the <input>, which is the combobox a reader meets: `Field`'s
|
|
444
449
|
// render-prop spreads `{ id, aria-describedby, aria-invalid, aria-required }`, and
|
|
@@ -580,6 +585,7 @@ function InlineEntityCombobox(props) {
|
|
|
580
585
|
/* @__PURE__ */ jsx(
|
|
581
586
|
"input",
|
|
582
587
|
{
|
|
588
|
+
ref,
|
|
583
589
|
id: fieldId,
|
|
584
590
|
value: shown,
|
|
585
591
|
placeholder,
|
|
@@ -690,7 +696,7 @@ function InlineEntityCombobox(props) {
|
|
|
690
696
|
{
|
|
691
697
|
open: open && !inert,
|
|
692
698
|
onClose: reconcile,
|
|
693
|
-
title: label,
|
|
699
|
+
title: sheetTitle ?? label,
|
|
694
700
|
query: sheetQuery,
|
|
695
701
|
onQueryChange: (v) => {
|
|
696
702
|
setSheetQuery(v);
|