@entifix/react-controls 0.23.6 → 0.23.8
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 +16 -0
- package/dist/i18n/catalog/en.d.ts.map +1 -1
- package/dist/i18n/catalog/en.js +2 -1
- package/dist/i18n/catalog/en.js.map +1 -1
- package/dist/i18n/catalog/es.d.ts +1 -0
- package/dist/i18n/catalog/es.d.ts.map +1 -1
- package/dist/i18n/catalog/es.js +2 -1
- package/dist/i18n/catalog/es.js.map +1 -1
- package/dist/i18n/catalog/index.d.ts +2 -0
- package/dist/i18n/catalog/index.d.ts.map +1 -1
- package/dist/i18n/i18n-context.d.ts.map +1 -1
- package/dist/i18n/i18n-context.js +5 -2
- package/dist/i18n/i18n-context.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/primitives.d.ts +1 -0
- package/dist/primitives.d.ts.map +1 -1
- package/dist/primitives.js +1 -0
- package/dist/primitives.js.map +1 -1
- package/dist/ui/atoms/cell-value/cell-value.d.ts +2 -1
- package/dist/ui/atoms/cell-value/cell-value.d.ts.map +1 -1
- package/dist/ui/atoms/cell-value/cell-value.js +31 -5
- package/dist/ui/atoms/cell-value/cell-value.js.map +1 -1
- package/dist/ui/atoms/field-control/field-control.d.ts +2 -1
- package/dist/ui/atoms/field-control/field-control.d.ts.map +1 -1
- package/dist/ui/atoms/field-control/field-control.js +19 -0
- package/dist/ui/atoms/field-control/field-control.js.map +1 -1
- package/dist/ui/atoms/money/money-input.d.ts +5 -0
- package/dist/ui/atoms/money/money-input.d.ts.map +1 -1
- package/dist/ui/atoms/money/money-input.js +11 -13
- package/dist/ui/atoms/money/money-input.js.map +1 -1
- package/dist/ui/atoms/money/money-math.d.ts +3 -3
- package/dist/ui/atoms/money/money-math.d.ts.map +1 -1
- package/dist/ui/atoms/money/money-math.js +4 -3
- package/dist/ui/atoms/money/money-math.js.map +1 -1
- package/dist/ui/atoms/number-input/quantity-input.d.ts +19 -4
- package/dist/ui/atoms/number-input/quantity-input.d.ts.map +1 -1
- package/dist/ui/atoms/number-input/quantity-input.js +13 -5
- package/dist/ui/atoms/number-input/quantity-input.js.map +1 -1
- package/dist/ui/atoms/number-input/scaled-quantity-input.d.ts +16 -0
- package/dist/ui/atoms/number-input/scaled-quantity-input.d.ts.map +1 -0
- package/dist/ui/atoms/number-input/scaled-quantity-input.js +135 -0
- package/dist/ui/atoms/number-input/scaled-quantity-input.js.map +1 -0
- package/dist/ui/atoms/number-input/step-button.d.ts +3 -0
- package/dist/ui/atoms/number-input/step-button.d.ts.map +1 -0
- package/dist/ui/atoms/number-input/step-button.js +3 -0
- package/dist/ui/atoms/number-input/step-button.js.map +1 -0
- package/dist/ui/atoms/number-input/unparsed.d.ts +10 -0
- package/dist/ui/atoms/number-input/unparsed.d.ts.map +1 -0
- package/dist/ui/atoms/number-input/unparsed.js +10 -0
- package/dist/ui/atoms/number-input/unparsed.js.map +1 -0
- package/dist/ui/atoms/scaled/index.d.ts +5 -0
- package/dist/ui/atoms/scaled/index.d.ts.map +1 -0
- package/dist/ui/atoms/scaled/index.js +6 -0
- package/dist/ui/atoms/scaled/index.js.map +1 -0
- package/dist/ui/atoms/scaled/scaled-input.d.ts +24 -0
- package/dist/ui/atoms/scaled/scaled-input.d.ts.map +1 -0
- package/dist/ui/atoms/scaled/scaled-input.js +98 -0
- package/dist/ui/atoms/scaled/scaled-input.js.map +1 -0
- package/dist/ui/atoms/scaled/scaled-math.d.ts +13 -0
- package/dist/ui/atoms/scaled/scaled-math.d.ts.map +1 -0
- package/dist/ui/atoms/scaled/scaled-math.js +17 -0
- package/dist/ui/atoms/scaled/scaled-math.js.map +1 -0
- package/dist/ui/atoms/scaled/scaled-value.d.ts +14 -0
- package/dist/ui/atoms/scaled/scaled-value.d.ts.map +1 -0
- package/dist/ui/atoms/scaled/scaled-value.js +14 -0
- package/dist/ui/atoms/scaled/scaled-value.js.map +1 -0
- package/dist/ui/atoms/scaled/use-unit-label.d.ts +4 -0
- package/dist/ui/atoms/scaled/use-unit-label.d.ts.map +1 -0
- package/dist/ui/atoms/scaled/use-unit-label.js +11 -0
- package/dist/ui/atoms/scaled/use-unit-label.js.map +1 -0
- package/dist/ui/organisms/entity-detail-grid/entity-detail-grid.d.ts.map +1 -1
- package/dist/ui/organisms/entity-detail-grid/entity-detail-grid.js +1 -1
- package/dist/ui/organisms/entity-detail-grid/entity-detail-grid.js.map +1 -1
- package/dist/ui/organisms/entity-table/entity-table-slots.d.ts +6 -1
- package/dist/ui/organisms/entity-table/entity-table-slots.d.ts.map +1 -1
- package/dist/ui/organisms/entity-table/entity-table-slots.js.map +1 -1
- package/dist/ui/organisms/entity-table/use-entity-table-columns.d.ts.map +1 -1
- package/dist/ui/organisms/entity-table/use-entity-table-columns.js +2 -0
- package/dist/ui/organisms/entity-table/use-entity-table-columns.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/ui/organisms/entity-detail-grid/entity-detail-grid.tsx"],"sourcesContent":["'use client';\n\nimport {\n describeChildColumns,\n editableChildColumns,\n type EntityFieldDescriptor,\n type EntityRowDraft,\n newRowKey,\n parseRowFieldPath,\n ROW_KEY,\n rowFieldPath,\n} from '@entifix/core';\nimport { type KeyboardEvent, useId, useMemo } from 'react';\n\nimport { useLocalizedDescriptors, useT } from '../../../i18n/index.js';\nimport { Button } from '../../atoms/button/index.js';\nimport { CellValue } from '../../atoms/cell-value/index.js';\nimport { FieldControl } from '../../atoms/field-control/index.js';\nimport { Skeleton } from '../../atoms/skeleton/index.js';\nimport {\n Table,\n TableBody,\n TableCell,\n TableHead,\n TableHeaderCell,\n TableMessageRow,\n TableRow,\n} from '../../atoms/table/index.js';\nimport { Stack } from '../../molecules/stack/index.js';\nimport { cn } from '../../utils/cn.js';\nimport type { EntityDetailGridProps } from './entity-detail-grid.types.js';\n\n/** Rows the placeholder stands in for. Enough to read as a grid, not a page. */\nconst SKELETON_ROW_COUNT = 3;\n\n/**\n * The rows a record **owns**, edited in place.\n *\n * A `composition` — an order and its lines — where the rows have no life outside\n * the master and go out in the same write\n *. Not\n * a `linkCollection`, which is association to records that exist on their own\n * and save separately; that editor is still #26.\n *\n * ## Why this is not `EntityTable`\n *\n * `EntityTable` is a *server* listing: pages, RSQL filtering and sorting,\n * column personalization, a selection model and a bulk bar. A detail grid has\n * none of those and cannot have them — its rows are local, unsaved, and\n * unqueryable by construction, since a collection member is never `filterable`.\n * Sharing the organism would mean every one of those features growing a\n * \"detail\" branch. It shares the `Table` **atoms** instead, which is the level\n * the two actually have in common.\n *\n * ## Inline cells, and why Enter is free\n *\n * Each cell is a {@link FieldControl}, the same descriptor→input map the form\n * uses, so a child's `enum` gets a select and its `date` a date input with no\n * code here. `Tab` walks the row natively and crosses into the next; `Enter` on\n * the last row appends and focuses the new row's first cell.\n *\n * That last binding is available only because `EntityForm` renders a `<Card>`\n * with a `<button onClick>` Save rather than a `<form>` — inside a real form,\n * `Enter` in a text input submits, and appending a row would fight the browser\n * for it. Wrapping the form in a `<form>` element later would break this, which\n * is the one thing worth knowing before doing it.\n *\n * ## Errors\n *\n * A cell carries `aria-invalid` and points at its own message; the grid carries\n * **one** summary above it, which is the only `role=\"alert\"` in the component.\n * A live region per cell would announce the whole grid on every keystroke, and\n * a message rendered only in the cell is unreachable when the failing row is\n * scrolled out — the case a long grid always meets.\n */\nexport function EntityDetailGrid({\n descriptor,\n rows,\n onRowsChange,\n errors,\n editing = false,\n isLoading = false,\n skeleton = true,\n footer,\n className,\n}: EntityDetailGridProps) {\n const t = useT();\n const gridId = useId();\n\n const described = useMemo(\n () =>\n descriptor.childType === undefined\n ? []\n : editableChildColumns(describeChildColumns(descriptor.childType)),\n [descriptor.childType],\n );\n const columns = useLocalizedDescriptors(described);\n\n // Only the messages that name *this* member. The form hands over its whole\n // error map so a record with two owned collections needs no bookkeeping at\n // the call site, and a grid that filtered nothing would show the other's.\n const rowErrors = useMemo(\n () => readRowErrors(descriptor.name, errors),\n [descriptor.name, errors],\n );\n\n const showSkeleton = isLoading && skeleton !== false;\n const customSkeleton = typeof skeleton === 'boolean' ? undefined : skeleton;\n // One more than the columns: every row carries its remove control.\n const columnCount = columns.length + (editing ? 1 : 0);\n\n const setRow = (index: number, member: string, value: string) => {\n onRowsChange(\n rows.map((row, position) =>\n position === index ? { ...row, [member]: value } : row,\n ),\n );\n };\n\n const firstColumn = columns[0]?.name;\n\n const appendRow = () => {\n onRowsChange([...rows, seedEmptyRow(columns)]);\n focusCell(gridId, rows.length, firstColumn);\n };\n\n const removeRow = (index: number) => {\n onRowsChange(rows.filter((_row, position) => position !== index));\n // Focus the row that slid into this position, or the one above it when the\n // removed row was last — never nothing, which drops the user to the page.\n focusCell(gridId, Math.min(index, rows.length - 2), firstColumn);\n };\n\n /**\n * `Enter` anywhere in the **last row** appends the next one.\n *\n * Bound to the row rather than to its final cell, which is what it looked\n * like it should be: the last *column* is whatever the child declared last,\n * and a read-only member there renders a disabled input that never receives a\n * key at all — so the binding would exist and be unreachable, on exactly the\n * entities that have a computed column. The row is the unit the user is\n * finishing anyway.\n *\n * Only from a text input: a `<select>` opens on Enter and a checkbox toggles\n * on Space, so taking the key from those would break a control's own\n * behaviour to add a row the user did not ask for. A read-only column needs\n * no test of its own — its input is `disabled`, so it never takes focus and\n * never raises a key here at all.\n */\n const onLastRowKeyDown = (event: KeyboardEvent<HTMLTableRowElement>) => {\n if (event.key !== 'Enter') return;\n if (!(event.target instanceof HTMLInputElement)) return;\n event.preventDefault();\n appendRow();\n };\n\n return (\n <Stack gap=\"2xs\" className={className}>\n <div className=\"flex items-center justify-between gap-s\">\n <span className=\"text-step-sm font-medium text-content-muted\">\n {descriptor.label}\n </span>\n {editing && (\n <Button\n type=\"button\"\n variant=\"secondary\"\n size=\"sm\"\n onClick={appendRow}\n disabled={isLoading}\n >\n {t('detail.addRow')}\n </Button>\n )}\n </div>\n\n {editing && rowErrors.size > 0 && (\n <div role=\"alert\" className=\"text-step-sm text-danger\">\n {t('detail.errorSummary', { count: rowErrors.size })}\n </div>\n )}\n\n <Table aria-label={descriptor.label} aria-busy={isLoading || undefined}>\n <TableHead>\n <TableRow>\n {columns.map(column => (\n <TableHeaderCell\n key={column.name}\n id={`${gridId}-${column.name}`}\n >\n {column.label}\n </TableHeaderCell>\n ))}\n {editing && (\n <TableHeaderCell align=\"end\">\n <span className=\"sr-only\">{t('detail.rowActions')}</span>\n </TableHeaderCell>\n )}\n </TableRow>\n </TableHead>\n\n <TableBody>\n {showSkeleton\n ? (customSkeleton ?? (\n <SkeletonRows\n columns={columns.length}\n extra={editing ? 1 : 0}\n />\n ))\n : rows.map((row, index) => (\n <TableRow\n key={row[ROW_KEY]}\n onKeyDown={\n editing && index === rows.length - 1\n ? onLastRowKeyDown\n : undefined\n }\n >\n {columns.map(column => {\n const error = rowErrors.get(\n rowFieldPath(descriptor.name, index, column.name),\n );\n const cellId = `${gridId}-${index}-${column.name}`;\n return (\n <TableCell key={column.name}>\n {editing ? (\n <FieldControl\n descriptor={column}\n value={row[column.name] ?? ''}\n id={cellId}\n aria-labelledby={`${gridId}-${column.name}`}\n aria-invalid={error !== undefined || undefined}\n aria-describedby={\n error === undefined\n ? undefined\n : `${cellId}-error`\n }\n onChange={next => setRow(index, column.name, next)}\n record={row}\n />\n ) : column.money === undefined ? (\n <span>{row[column.name] ?? ''}</span>\n ) : (\n <CellValue\n value={row[column.name]}\n descriptor={column}\n record={row}\n />\n )}\n {editing && error !== undefined && (\n <span\n id={`${cellId}-error`}\n className=\"mt-3xs block text-step-sm text-danger\"\n >\n {error}\n </span>\n )}\n </TableCell>\n );\n })}\n {editing && (\n <TableCell align=\"end\">\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => removeRow(index)}\n >\n {t('detail.removeRow', { row: index + 1 })}\n </Button>\n </TableCell>\n )}\n </TableRow>\n ))}\n\n {!showSkeleton && rows.length === 0 && (\n <TableMessageRow colSpan={Math.max(columnCount, 1)}>\n {t('detail.empty')}\n </TableMessageRow>\n )}\n </TableBody>\n </Table>\n\n {footer !== undefined && !showSkeleton && (\n <div className={cn('flex justify-end text-step-sm text-content')}>\n {footer(rows)}\n </div>\n )}\n </Stack>\n );\n}\n\n/** The placeholder, shaped like the grid it stands in for. */\nfunction SkeletonRows({ columns, extra }: { columns: number; extra: number }) {\n return (\n <>\n {Array.from({ length: SKELETON_ROW_COUNT }, (_row, index) => (\n <TableRow key={index}>\n {Array.from({ length: columns + extra }, (_cell, cellIndex) => (\n <TableCell key={cellIndex}>\n <Skeleton className=\"h-8 w-full\" />\n </TableCell>\n ))}\n </TableRow>\n ))}\n </>\n );\n}\n\n/**\n * A blank row, seeded with every column the grid edits.\n *\n * Every member is present and empty rather than absent, for the reason a form's\n * seed carries every key: a control handed `undefined` flips from controlled to\n * uncontrolled the moment the user types into it.\n */\nfunction seedEmptyRow(\n columns: readonly EntityFieldDescriptor[],\n): EntityRowDraft {\n const row: EntityRowDraft = { [ROW_KEY]: newRowKey() };\n for (const column of columns) row[column.name] = '';\n return row;\n}\n\n/**\n * Moves focus into a cell after the list changed.\n *\n * By element id rather than through a ref into the `<tbody>`, because the row\n * being focused does not exist yet when this is called — it is the row the\n * caller has just asked React to render. Deferring to a microtask lets that\n * render commit first; `getElementById` then finds the input the same way the\n * cell's own `aria-describedby` does.\n *\n * A row index that names nothing simply focuses nothing, which is the right\n * outcome for removing the only row: there is no cell to land in, and stealing\n * focus somewhere arbitrary is worse than leaving it where the user put it.\n */\nfunction focusCell(gridId: string, index: number, column?: string): void {\n if (column === undefined || index < 0) return;\n\n queueMicrotask(() => {\n document.getElementById(`${gridId}-${index}-${column}`)?.focus();\n });\n}\n\n/** The messages naming a row of `member`, keyed by their full path. */\nfunction readRowErrors(\n member: string,\n errors: Record<string, string> | undefined,\n): Map<string, string> {\n const found = new Map<string, string>();\n if (errors === undefined) return found;\n\n for (const [path, message] of Object.entries(errors)) {\n if (parseRowFieldPath(path)?.member === member) found.set(path, message);\n }\n return found;\n}\n"],"names":["describeChildColumns","editableChildColumns","newRowKey","parseRowFieldPath","ROW_KEY","rowFieldPath","useId","useMemo","useLocalizedDescriptors","useT","Button","CellValue","FieldControl","Skeleton","Table","TableBody","TableCell","TableHead","TableHeaderCell","TableMessageRow","TableRow","Stack","cn","SKELETON_ROW_COUNT","EntityDetailGrid","descriptor","rows","onRowsChange","errors","editing","isLoading","skeleton","footer","className","columns","t","gridId","described","childType","undefined","rowErrors","readRowErrors","name","showSkeleton","customSkeleton","columnCount","length","setRow","index","member","value","map","row","position","firstColumn","appendRow","seedEmptyRow","focusCell","removeRow","filter","_row","Math","min","onLastRowKeyDown","event","key","target","HTMLInputElement","preventDefault","gap","div","span","label","type","variant","size","onClick","disabled","role","count","aria-label","aria-busy","column","id","align","SkeletonRows","extra","onKeyDown","error","get","cellId","aria-labelledby","aria-invalid","aria-describedby","onChange","next","record","money","colSpan","max","Array","from","_cell","cellIndex","queueMicrotask","document","getElementById","focus","found","Map","path","message","Object","entries","set"],"mappings":"AAAA;;;AAEA,SACEA,oBAAoB,EACpBC,oBAAoB,EAGpBC,SAAS,EACTC,iBAAiB,EACjBC,OAAO,EACPC,YAAY,QACP,gBAAgB;AACvB,SAA6BC,KAAK,EAAEC,OAAO,QAAQ,QAAQ;AAE3D,SAASC,uBAAuB,EAAEC,IAAI,QAAQ,yBAAyB;AACvE,SAASC,MAAM,QAAQ,8BAA8B;AACrD,SAASC,SAAS,QAAQ,kCAAkC;AAC5D,SAASC,YAAY,QAAQ,qCAAqC;AAClE,SAASC,QAAQ,QAAQ,gCAAgC;AACzD,SACEC,KAAK,EACLC,SAAS,EACTC,SAAS,EACTC,SAAS,EACTC,eAAe,EACfC,eAAe,EACfC,QAAQ,QACH,6BAA6B;AACpC,SAASC,KAAK,QAAQ,iCAAiC;AACvD,SAASC,EAAE,QAAQ,oBAAoB;AAGvC,8EAA8E,GAC9E,M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,IAAIC,OAAOC,OAAO,CAACrF,QAAS;YAChDzB;QAAJ,IAAIA,EAAAA,qBAAAA,kBAAkB2G,0BAAlB3G,mBAAyB8C,MAAM,MAAKA,QAAQ2D,MAAMM,GAAG,CAACJ,MAAMC;IAClE;IACA,OAAOH;AACT"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/ui/organisms/entity-detail-grid/entity-detail-grid.tsx"],"sourcesContent":["'use client';\n\nimport {\n describeChildColumns,\n editableChildColumns,\n type EntityFieldDescriptor,\n type EntityRowDraft,\n newRowKey,\n parseRowFieldPath,\n ROW_KEY,\n rowFieldPath,\n} from '@entifix/core';\nimport { type KeyboardEvent, useId, useMemo } from 'react';\n\nimport { useLocalizedDescriptors, useT } from '../../../i18n/index.js';\nimport { Button } from '../../atoms/button/index.js';\nimport { CellValue } from '../../atoms/cell-value/index.js';\nimport { FieldControl } from '../../atoms/field-control/index.js';\nimport { Skeleton } from '../../atoms/skeleton/index.js';\nimport {\n Table,\n TableBody,\n TableCell,\n TableHead,\n TableHeaderCell,\n TableMessageRow,\n TableRow,\n} from '../../atoms/table/index.js';\nimport { Stack } from '../../molecules/stack/index.js';\nimport { cn } from '../../utils/cn.js';\nimport type { EntityDetailGridProps } from './entity-detail-grid.types.js';\n\n/** Rows the placeholder stands in for. Enough to read as a grid, not a page. */\nconst SKELETON_ROW_COUNT = 3;\n\n/**\n * The rows a record **owns**, edited in place.\n *\n * A `composition` — an order and its lines — where the rows have no life outside\n * the master and go out in the same write\n *. Not\n * a `linkCollection`, which is association to records that exist on their own\n * and save separately; that editor is still #26.\n *\n * ## Why this is not `EntityTable`\n *\n * `EntityTable` is a *server* listing: pages, RSQL filtering and sorting,\n * column personalization, a selection model and a bulk bar. A detail grid has\n * none of those and cannot have them — its rows are local, unsaved, and\n * unqueryable by construction, since a collection member is never `filterable`.\n * Sharing the organism would mean every one of those features growing a\n * \"detail\" branch. It shares the `Table` **atoms** instead, which is the level\n * the two actually have in common.\n *\n * ## Inline cells, and why Enter is free\n *\n * Each cell is a {@link FieldControl}, the same descriptor→input map the form\n * uses, so a child's `enum` gets a select and its `date` a date input with no\n * code here. `Tab` walks the row natively and crosses into the next; `Enter` on\n * the last row appends and focuses the new row's first cell.\n *\n * That last binding is available only because `EntityForm` renders a `<Card>`\n * with a `<button onClick>` Save rather than a `<form>` — inside a real form,\n * `Enter` in a text input submits, and appending a row would fight the browser\n * for it. Wrapping the form in a `<form>` element later would break this, which\n * is the one thing worth knowing before doing it.\n *\n * ## Errors\n *\n * A cell carries `aria-invalid` and points at its own message; the grid carries\n * **one** summary above it, which is the only `role=\"alert\"` in the component.\n * A live region per cell would announce the whole grid on every keystroke, and\n * a message rendered only in the cell is unreachable when the failing row is\n * scrolled out — the case a long grid always meets.\n */\nexport function EntityDetailGrid({\n descriptor,\n rows,\n onRowsChange,\n errors,\n editing = false,\n isLoading = false,\n skeleton = true,\n footer,\n className,\n}: EntityDetailGridProps) {\n const t = useT();\n const gridId = useId();\n\n const described = useMemo(\n () =>\n descriptor.childType === undefined\n ? []\n : editableChildColumns(describeChildColumns(descriptor.childType)),\n [descriptor.childType],\n );\n const columns = useLocalizedDescriptors(described);\n\n // Only the messages that name *this* member. The form hands over its whole\n // error map so a record with two owned collections needs no bookkeeping at\n // the call site, and a grid that filtered nothing would show the other's.\n const rowErrors = useMemo(\n () => readRowErrors(descriptor.name, errors),\n [descriptor.name, errors],\n );\n\n const showSkeleton = isLoading && skeleton !== false;\n const customSkeleton = typeof skeleton === 'boolean' ? undefined : skeleton;\n // One more than the columns: every row carries its remove control.\n const columnCount = columns.length + (editing ? 1 : 0);\n\n const setRow = (index: number, member: string, value: string) => {\n onRowsChange(\n rows.map((row, position) =>\n position === index ? { ...row, [member]: value } : row,\n ),\n );\n };\n\n const firstColumn = columns[0]?.name;\n\n const appendRow = () => {\n onRowsChange([...rows, seedEmptyRow(columns)]);\n focusCell(gridId, rows.length, firstColumn);\n };\n\n const removeRow = (index: number) => {\n onRowsChange(rows.filter((_row, position) => position !== index));\n // Focus the row that slid into this position, or the one above it when the\n // removed row was last — never nothing, which drops the user to the page.\n focusCell(gridId, Math.min(index, rows.length - 2), firstColumn);\n };\n\n /**\n * `Enter` anywhere in the **last row** appends the next one.\n *\n * Bound to the row rather than to its final cell, which is what it looked\n * like it should be: the last *column* is whatever the child declared last,\n * and a read-only member there renders a disabled input that never receives a\n * key at all — so the binding would exist and be unreachable, on exactly the\n * entities that have a computed column. The row is the unit the user is\n * finishing anyway.\n *\n * Only from a text input: a `<select>` opens on Enter and a checkbox toggles\n * on Space, so taking the key from those would break a control's own\n * behaviour to add a row the user did not ask for. A read-only column needs\n * no test of its own — its input is `disabled`, so it never takes focus and\n * never raises a key here at all.\n */\n const onLastRowKeyDown = (event: KeyboardEvent<HTMLTableRowElement>) => {\n if (event.key !== 'Enter') return;\n if (!(event.target instanceof HTMLInputElement)) return;\n event.preventDefault();\n appendRow();\n };\n\n return (\n <Stack gap=\"2xs\" className={className}>\n <div className=\"flex items-center justify-between gap-s\">\n <span className=\"text-step-sm font-medium text-content-muted\">\n {descriptor.label}\n </span>\n {editing && (\n <Button\n type=\"button\"\n variant=\"secondary\"\n size=\"sm\"\n onClick={appendRow}\n disabled={isLoading}\n >\n {t('detail.addRow')}\n </Button>\n )}\n </div>\n\n {editing && rowErrors.size > 0 && (\n <div role=\"alert\" className=\"text-step-sm text-danger\">\n {t('detail.errorSummary', { count: rowErrors.size })}\n </div>\n )}\n\n <Table aria-label={descriptor.label} aria-busy={isLoading || undefined}>\n <TableHead>\n <TableRow>\n {columns.map(column => (\n <TableHeaderCell\n key={column.name}\n id={`${gridId}-${column.name}`}\n >\n {column.label}\n </TableHeaderCell>\n ))}\n {editing && (\n <TableHeaderCell align=\"end\">\n <span className=\"sr-only\">{t('detail.rowActions')}</span>\n </TableHeaderCell>\n )}\n </TableRow>\n </TableHead>\n\n <TableBody>\n {showSkeleton\n ? (customSkeleton ?? (\n <SkeletonRows\n columns={columns.length}\n extra={editing ? 1 : 0}\n />\n ))\n : rows.map((row, index) => (\n <TableRow\n key={row[ROW_KEY]}\n onKeyDown={\n editing && index === rows.length - 1\n ? onLastRowKeyDown\n : undefined\n }\n >\n {columns.map(column => {\n const error = rowErrors.get(\n rowFieldPath(descriptor.name, index, column.name),\n );\n const cellId = `${gridId}-${index}-${column.name}`;\n return (\n <TableCell key={column.name}>\n {editing ? (\n <FieldControl\n descriptor={column}\n value={row[column.name] ?? ''}\n id={cellId}\n aria-labelledby={`${gridId}-${column.name}`}\n aria-invalid={error !== undefined || undefined}\n aria-describedby={\n error === undefined\n ? undefined\n : `${cellId}-error`\n }\n onChange={next => setRow(index, column.name, next)}\n record={row}\n />\n ) : column.money === undefined &&\n column.scaled === undefined ? (\n <span>{row[column.name] ?? ''}</span>\n ) : (\n <CellValue\n value={row[column.name]}\n descriptor={column}\n record={row}\n />\n )}\n {editing && error !== undefined && (\n <span\n id={`${cellId}-error`}\n className=\"mt-3xs block text-step-sm text-danger\"\n >\n {error}\n </span>\n )}\n </TableCell>\n );\n })}\n {editing && (\n <TableCell align=\"end\">\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => removeRow(index)}\n >\n {t('detail.removeRow', { row: index + 1 })}\n </Button>\n </TableCell>\n )}\n </TableRow>\n ))}\n\n {!showSkeleton && rows.length === 0 && (\n <TableMessageRow colSpan={Math.max(columnCount, 1)}>\n {t('detail.empty')}\n </TableMessageRow>\n )}\n </TableBody>\n </Table>\n\n {footer !== undefined && !showSkeleton && (\n <div className={cn('flex justify-end text-step-sm text-content')}>\n {footer(rows)}\n </div>\n )}\n </Stack>\n );\n}\n\n/** The placeholder, shaped like the grid it stands in for. */\nfunction SkeletonRows({ columns, extra }: { columns: number; extra: number }) {\n return (\n <>\n {Array.from({ length: SKELETON_ROW_COUNT }, (_row, index) => (\n <TableRow key={index}>\n {Array.from({ length: columns + extra }, (_cell, cellIndex) => (\n <TableCell key={cellIndex}>\n <Skeleton className=\"h-8 w-full\" />\n </TableCell>\n ))}\n </TableRow>\n ))}\n </>\n );\n}\n\n/**\n * A blank row, seeded with every column the grid edits.\n *\n * Every member is present and empty rather than absent, for the reason a form's\n * seed carries every key: a control handed `undefined` flips from controlled to\n * uncontrolled the moment the user types into it.\n */\nfunction seedEmptyRow(\n columns: readonly EntityFieldDescriptor[],\n): EntityRowDraft {\n const row: EntityRowDraft = { [ROW_KEY]: newRowKey() };\n for (const column of columns) row[column.name] = '';\n return row;\n}\n\n/**\n * Moves focus into a cell after the list changed.\n *\n * By element id rather than through a ref into the `<tbody>`, because the row\n * being focused does not exist yet when this is called — it is the row the\n * caller has just asked React to render. Deferring to a microtask lets that\n * render commit first; `getElementById` then finds the input the same way the\n * cell's own `aria-describedby` does.\n *\n * A row index that names nothing simply focuses nothing, which is the right\n * outcome for removing the only row: there is no cell to land in, and stealing\n * focus somewhere arbitrary is worse than leaving it where the user put it.\n */\nfunction focusCell(gridId: string, index: number, column?: string): void {\n if (column === undefined || index < 0) return;\n\n queueMicrotask(() => {\n document.getElementById(`${gridId}-${index}-${column}`)?.focus();\n });\n}\n\n/** The messages naming a row of `member`, keyed by their full path. */\nfunction readRowErrors(\n member: string,\n errors: Record<string, string> | undefined,\n): Map<string, string> {\n const found = new Map<string, string>();\n if (errors === undefined) return found;\n\n for (const [path, message] of Object.entries(errors)) {\n if (parseRowFieldPath(path)?.member === member) found.set(path, message);\n }\n return found;\n}\n"],"names":["describeChildColumns","editableChildColumns","newRowKey","parseRowFieldPath","ROW_KEY","rowFieldPath","useId","useMemo","useLocalizedDescriptors","useT","Button","CellValue","FieldControl","Skeleton","Table","TableBody","TableCell","TableHead","TableHeaderCell","TableMessageRow","TableRow","Stack","cn","SKELETON_ROW_COUNT","EntityDetailGrid","descriptor","rows","onRowsChange","errors","editing","isLoading","skeleton","footer","className","columns","t","gridId","described","childType","undefined","rowErrors","readRowErrors","name","showSkeleton","customSkeleton","columnCount","length","setRow","index","member","value","map","row","position","firstColumn","appendRow","seedEmptyRow","focusCell","removeRow","filter","_row","Math","min","onLastRowKeyDown","event","key","target","HTMLInputElement","preventDefault","gap","div","span","label","type","variant","size","onClick","disabled","role","count","aria-label","aria-busy","column","id","align","SkeletonRows","extra","onKeyDown","error","get","cellId","aria-labelledby","aria-invalid","aria-describedby","onChange","next","record","money","scaled","colSpan","max","Array","from","_cell","cellIndex","queueMicrotask","document","getElementById","focus","found","Map","path","message","Object","entries","set"],"mappings":"AAAA;;;AAEA,SACEA,oBAAoB,EACpBC,oBAAoB,EAGpBC,SAAS,EACTC,iBAAiB,EACjBC,OAAO,EACPC,YAAY,QACP,gBAAgB;AACvB,SAA6BC,KAAK,EAAEC,OAAO,QAAQ,QAAQ;AAE3D,SAASC,uBAAuB,EAAEC,IAAI,QAAQ,yBAAyB;AACvE,SAASC,MAAM,QAAQ,8BAA8B;AACrD,SAASC,SAAS,QAAQ,kCAAkC;AAC5D,SAASC,YAAY,QAAQ,qCAAqC;AAClE,SAASC,QAAQ,QAAQ,gCAAgC;AACzD,SACEC,KAAK,EACLC,SAAS,EACTC,SAAS,EACTC,SAAS,EACTC,eAAe,EACfC,eAAe,EACfC,QAAQ,QACH,6BAA6B;AACpC,SAASC,KAAK,QAAQ,iCAAiC;AACvD,SAASC,EAAE,QAAQ,oBAAoB;AAGvC,8EAA8E,GAC9E,MAAMC,qBAAqB;AAE3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCC,GACD,OAAO,SAASC,iBAAiB,EAC/BC,UAAU,EACVC,IAAI,EACJC,YAAY,EACZC,MAAM,EACNC,UAAU,KAAK,EACfC,YAAY,KAAK,EACjBC,WAAW,IAAI,EACfC,MAAM,EACNC,SAAS,EACa;QAkCFC;IAjCpB,MAAMC,IAAI1B;IACV,MAAM2B,SAAS9B;IAEf,MAAM+B,YAAY9B,QAChB,IACEkB,WAAWa,SAAS,KAAKC,YACrB,EAAE,GACFtC,qBAAqBD,qBAAqByB,WAAWa,SAAS,IACpE;QAACb,WAAWa,SAAS;KAAC;I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AQvB;QAAmB,GAAG,CAACqC,MAAMZ,sBACjD,KAAC5B;0BACEiF,MAAMC,IAAI,CAAC;oBAAExD,QAAQZ,UAAUoD;gBAAM,GAAG,CAACiB,OAAOC,0BAC/C,KAACxF;kCACC,cAAA,KAACH;4BAASoB,WAAU;;uBADNuE;eAFLxD;;AAUvB;AAEA;;;;;;CAMC,GACD,SAASQ,aACPtB,OAAyC;IAEzC,MAAMkB,MAAsB;QAAE,CAAChD,QAAQ,EAAEF;IAAY;IACrD,KAAK,MAAMgF,UAAUhD,QAASkB,GAAG,CAAC8B,OAAOxC,IAAI,CAAC,GAAG;IACjD,OAAOU;AACT;AAEA;;;;;;;;;;;;CAYC,GACD,SAASK,UAAUrB,MAAc,EAAEY,KAAa,EAAEkC,MAAe;IAC/D,IAAIA,WAAW3C,aAAaS,QAAQ,GAAG;IAEvCyD,eAAe;YACbC;SAAAA,2BAAAA,SAASC,cAAc,CAAC,GAAGvE,OAAO,CAAC,EAAEY,MAAM,CAAC,EAAEkC,QAAQ,sBAAtDwB,yBAAyDE,KAAK;IAChE;AACF;AAEA,qEAAqE,GACrE,SAASnE,cACPQ,MAAc,EACdrB,MAA0C;IAE1C,MAAMiF,QAAQ,IAAIC;IAClB,IAAIlF,WAAWW,WAAW,OAAOsE;IAEjC,KAAK,MAAM,CAACE,MAAMC,QAAQ,IAAIC,OAAOC,OAAO,CAACtF,QAAS;YAChDzB;QAAJ,IAAIA,EAAAA,qBAAAA,kBAAkB4G,0BAAlB5G,mBAAyB8C,MAAM,MAAKA,QAAQ4D,MAAMM,GAAG,CAACJ,MAAMC;IAClE;IACA,OAAOH;AACT"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Entity, MetaAccessorType, MoneyFormat } from '@entifix/core';
|
|
1
|
+
import type { Entity, MetaAccessorType, MoneyFormat, ScaledFormat } from '@entifix/core';
|
|
2
2
|
import { type ReactNode } from 'react';
|
|
3
3
|
import type { EntityTableColumn } from './entity-table.types.js';
|
|
4
4
|
/**
|
|
@@ -21,6 +21,11 @@ export interface EntityColumnProps<TEntity extends Entity = Entity> {
|
|
|
21
21
|
* the stored number. A computed column has no accessor to declare it on.
|
|
22
22
|
*/
|
|
23
23
|
money?: MoneyFormat;
|
|
24
|
+
/**
|
|
25
|
+
* The column holds a scaled integer: printed as the decimal it stands for,
|
|
26
|
+
* beside its unit. A computed column has no accessor to declare it on.
|
|
27
|
+
*/
|
|
28
|
+
scaled?: ScaledFormat;
|
|
24
29
|
order?: number;
|
|
25
30
|
sortable?: boolean;
|
|
26
31
|
filterable?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-table-slots.d.ts","sourceRoot":"","sources":["../../../../src/ui/organisms/entity-table/entity-table-slots.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"entity-table-slots.d.ts","sourceRoot":"","sources":["../../../../src/ui/organisms/entity-table/entity-table-slots.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,gBAAgB,EAChB,WAAW,EACX,YAAY,EACb,MAAM,eAAe,CAAC;AACvB,OAAO,EAA4B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE;;;;;;GAMG;AAEH,MAAM,WAAW,iBAAiB,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM;IAChE,wEAAwE;IACxE,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,iFAAiF;IACjF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB;;;OAGG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,C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;IACzC,GAAG,CAAC,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACnC,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,0EAA0E;IAC1E,IAAI,EAAE,SAAS,EAAE,CAAC;CACnB;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,SAAS,MAAM,EACzD,QAAQ,EAAE,SAAS,GAClB,gBAAgB,CAAC,OAAO,CAAC,CA4B3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/ui/organisms/entity-table/entity-table-slots.tsx"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../../../../src/ui/organisms/entity-table/entity-table-slots.tsx"],"sourcesContent":["import type {\n Entity,\n MetaAccessorType,\n MoneyFormat,\n ScaledFormat,\n} from '@entifix/core';\nimport { Children, isValidElement, type ReactNode } from 'react';\n\nimport type { EntityTableColumn } from './entity-table.types.js';\n\n/**\n * The declarative customization API. Slots are configuration expressed as JSX:\n * they never render themselves — `EntityTable` reads their props and decides\n * where the configuration applies. That keeps simple tables to a single\n * self-closing tag while complex ones stay declarative instead of drowning in\n * option objects.\n */\n\nexport interface EntityColumnProps<TEntity extends Entity = Entity> {\n /** Accessor name. Unknown names create an extra, entity-less column. */\n field: string;\n label?: string;\n header?: ReactNode;\n type?: MetaAccessorType;\n /** The narrowest the column reads at, in `rem` — what the pivot counts it as. */\n minWidth?: number;\n /**\n * The column holds an amount: printed as `Money` in its currency, never as\n * the stored number. A computed column has no accessor to declare it on.\n */\n money?: MoneyFormat;\n /**\n * The column holds a scaled integer: printed as the decimal it stands for,\n * beside its unit. A computed column has no accessor to declare it on.\n */\n scaled?: ScaledFormat;\n order?: number;\n sortable?: boolean;\n filterable?: boolean;\n render?: (item: TEntity) => ReactNode;\n}\n\n/** Overrides one metadata-derived column, or adds a computed one. */\nexport function EntityColumn<TEntity extends Entity = Entity>(\n _props: EntityColumnProps<TEntity>,\n): ReactNode {\n return null;\n}\n\nexport interface EntityTableHeaderProps<TEntity extends Entity = Entity> {\n /** Replaces the whole header row. Receives the resolved visible columns. */\n render: (columns: Array<EntityTableColumn<TEntity>>) => ReactNode;\n}\n\nexport function EntityTableHeader<TEntity extends Entity = Entity>(\n _props: EntityTableHeaderProps<TEntity>,\n): ReactNode {\n return null;\n}\n\nexport interface EntityTableRowProps<TEntity extends Entity = Entity> {\n /** Replaces the whole body row for every item. */\n render: (\n item: TEntity,\n columns: Array<EntityTableColumn<TEntity>>,\n ) => ReactNode;\n}\n\nexport function EntityTableRow<TEntity extends Entity = Entity>(\n _props: EntityTableRowProps<TEntity>,\n): ReactNode {\n return null;\n}\n\nexport interface EntityTableToolbarProps {\n children?: ReactNode;\n}\n\n/** Extra actions placed alongside the built-in toolbar controls. */\nexport function EntityTableToolbar(_props: EntityTableToolbarProps): ReactNode {\n return null;\n}\n\nexport interface EntityTableSlots<TEntity extends Entity> {\n columns: Array<EntityColumnProps<TEntity>>;\n header?: EntityTableHeaderProps<TEntity>;\n row?: EntityTableRowProps<TEntity>;\n toolbar?: ReactNode;\n /** Children that matched no slot — rendered below the table untouched. */\n rest: ReactNode[];\n}\n\n/**\n * Sorts children into slots.\n *\n * Matching is by component identity rather than by `displayName`: identity\n * survives minification and cannot collide with an unrelated component that\n * happens to share a name.\n */\nexport function readEntityTableSlots<TEntity extends Entity>(\n children: ReactNode,\n): EntityTableSlots<TEntity> {\n const slots: EntityTableSlots<TEntity> = { columns: [], rest: [] };\n\n Children.toArray(children).forEach(child => {\n if (!isValidElement(child)) {\n slots.rest.push(child);\n return;\n }\n\n switch (child.type) {\n case EntityColumn:\n slots.columns.push(child.props as EntityColumnProps<TEntity>);\n break;\n case EntityTableHeader:\n slots.header = child.props as EntityTableHeaderProps<TEntity>;\n break;\n case EntityTableRow:\n slots.row = child.props as EntityTableRowProps<TEntity>;\n break;\n case EntityTableToolbar:\n slots.toolbar = (child.props as EntityTableToolbarProps).children;\n break;\n default:\n slots.rest.push(child);\n }\n });\n\n return slots;\n}\n"],"names":["Children","isValidElement","EntityColumn","_props","EntityTableHeader","EntityTableRow","EntityTableToolbar","readEntityTableSlots","children","slots","columns","rest","toArray","forEach","child","push","type","props","header","row","toolbar"],"mappings":"AAMA,SAASA,QAAQ,EAAEC,cAAc,QAAwB,QAAQ;AAoCjE,mEAAmE,GACnE,OAAO,SAASC,aACdC,MAAkC;IAElC,OAAO;AACT;AAOA,OAAO,SAASC,kBACdD,MAAuC;IAEvC,OAAO;AACT;AAUA,OAAO,SAASE,eACdF,MAAoC;IAEpC,OAAO;AACT;AAMA,kEAAkE,GAClE,OAAO,SAASG,mBAAmBH,MAA+B;IAChE,OAAO;AACT;AAWA;;;;;;CAMC,GACD,OAAO,SAASI,qBACdC,QAAmB;IAEnB,MAAMC,QAAmC;QAAEC,SAAS,EAAE;QAAEC,MAAM,EAAE;IAAC;IAEjEX,SAASY,OAAO,CAACJ,UAAUK,OAAO,CAACC,CAAAA;QACjC,IAAI,eAACb,eAAea,QAAQ;YAC1BL,MAAME,IAAI,CAACI,IAAI,CAACD;YAChB;QACF;QAEA,OAAQA,MAAME,IAAI;YAChB,KAAKd;gBACHO,MAAMC,OAAO,CAACK,IAAI,CAACD,MAAMG,KAAK;gBAC9B;YACF,KAAKb;gBACHK,MAAMS,MAAM,GAAGJ,MAAMG,KAAK;gBAC1B;YACF,KAAKZ;gBACHI,MAAMU,GAAG,GAAGL,MAAMG,KAAK;gBACvB;YACF,KAAKX;gBACHG,MAAMW,OAAO,GAAG,AAACN,MAAMG,KAAK,CAA6BT,QAAQ;gBACjE;YACF;gBACEC,MAAME,IAAI,CAACI,IAAI,CAACD;QACpB;IACF;IAEA,OAAOL;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-entity-table-columns.d.ts","sourceRoot":"","sources":["../../../../src/ui/organisms/entity-table/use-entity-table-columns.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,MAAM,EACX,KAAK,iBAAiB,EACvB,MAAM,eAAe,CAAC;AAKvB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACtF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"use-entity-table-columns.d.ts","sourceRoot":"","sources":["../../../../src/ui/organisms/entity-table/use-entity-table-columns.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,MAAM,EACX,KAAK,iBAAiB,EACvB,MAAM,eAAe,CAAC;AAKvB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACtF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AA4GjE;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,SAAS,MAAM,EAC9D,SAAS,EAAE,KAAK,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,EAC5C,WAAW,EAAE,KAAK,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,EAC9C,eAAe,EAAE,qBAAqB,EACtC,QAAQ,GAAE,SAAS,MAAM,EAAkB,EAC3C,OAAO,UAAQ,GACd;IACD,OAAO,EAAE,KAAK,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC;IAC3C,cAAc,EAAE,KAAK,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC;IAClD,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAaA;AAED,MAAM,WAAW,2BAA2B,CAAC,OAAO,SAAS,MAAM;IACjE,2EAA2E;IAC3E,OAAO,EAAE,KAAK,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC;IAC3C,oCAAoC;IACpC,cAAc,EAAE,KAAK,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC;IAClD,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,eAAe,EAAE,qBAAqB,CAAC;IACvC,kBAAkB,EAAE,CAAC,IAAI,EAAE,qBAAqB,KAAK,IAAI,CAAC;CAC3D;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,SAAS,MAAM,EAC1D,iBAAiB,EAAE,iBAAiB,CAAC,OAAO,CAAC,EAC7C,WAAW,EAAE,KAAK,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,EAC9C,MAAM,EAAE,OAAO,GAAG,SAAS,EAC3B,aAAa,EAAE,MAAM,EACrB,QAAQ,GAAE,SAAS,MAAM,EAAkB,EAC3C,OAAO,UAAQ,GACd,2BAA2B,CAAC,OAAO,CAAC,CAqCtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/ui/organisms/entity-table/use-entity-table-columns.ts"],"sourcesContent":["'use client';\n\nimport {\n describeEntityColumns,\n type Entity,\n type EntityConstructor,\n} from '@entifix/core';\nimport { useMemo } from 'react';\n\nimport { useLocalizedDescriptors } from '../../../i18n/index.js';\nimport { useUiPreference } from '../../../preferences/index.js';\nimport type { ColumnPersonalization } from '../../molecules/column-settings/index.js';\nimport type { EntityTableColumn } from './entity-table.types.js';\nimport type { EntityColumnProps } from './entity-table-slots.js';\n\nconst EMPTY_PERSONALIZATION: ColumnPersonalization = {};\nconst NONE_WITHHELD: readonly string[] = [];\n\n/**\n * Applies `<EntityColumn>` overrides on top of the metadata descriptors, and\n * appends a virtual column for any slot naming a member the entity does not\n * have (a computed column).\n */\nfunction mergeSlots<TEntity extends Entity>(\n descriptors: Array<EntityTableColumn<TEntity>>,\n slotColumns: Array<EntityColumnProps<TEntity>>,\n): Array<EntityTableColumn<TEntity>> {\n const merged = descriptors.map(descriptor => {\n const slot = slotColumns.find(entry => entry.field === descriptor.name);\n if (!slot) return descriptor;\n const { field: _field, ...overrides } = slot;\n return {\n ...descriptor,\n ...Object.fromEntries(\n Object.entries(overrides).filter(([, value]) => value !== undefined),\n ),\n } as EntityTableColumn<TEntity>;\n });\n\n const virtual = slotColumns\n .filter(slot => !descriptors.some(entry => entry.name === slot.field))\n .map<EntityTableColumn<TEntity>>((slot, index) => ({\n name: slot.field,\n key: slot.field,\n label: slot.label ?? slot.field,\n type: slot.type ?? 'string',\n sortable: slot.sortable ?? false,\n filterable: slot.filterable ?? false,\n order: slot.order ?? descriptors.length + index,\n readonly: false,\n required: false,\n linkLabelProperty: 'name',\n linkSearchProperty: 'name',\n linkSerialization: 'id',\n // A slot-only column has no accessor, so there is nothing for a copy to\n // reset — the value is computed from members that are cloned themselves.\n resetOnClone: false,\n ...(slot.minWidth === undefined ? {} : { minWidth: slot.minWidth }),\n ...(slot.money === undefined ? {} : { money: slot.money }),\n header: slot.header,\n render: slot.render,\n virtual: true,\n }));\n\n return [...merged, ...virtual].sort(\n (left, right) => left.order - right.order,\n );\n}\n\n/**\n * Reorders columns per the stored personalization. Names the user never saw\n * (added to the entity after the layout was saved) keep their default position\n * at the end instead of vanishing, and stale names in the stored order are\n * dropped — so a saved layout degrades rather than breaks.\n */\nfunction applyOrder<TEntity extends Entity>(\n columns: Array<EntityTableColumn<TEntity>>,\n order: string[] | undefined,\n): Array<EntityTableColumn<TEntity>> {\n if (!order || order.length === 0) return columns;\n\n const ranked = order\n .map(name => columns.find(column => column.name === name))\n .filter((column): column is EntityTableColumn<TEntity> => !!column);\n const remaining = columns.filter(column => !order.includes(column.name));\n\n return [...ranked, ...remaining];\n}\n\n/**\n * Drops the columns the host withholds from this reader. Not a hidden column\n * the reader can bring back: it is gone from the settings, the filters, the\n * sort choices and the cards. A name that is no column throws, because a\n * withheld column that is still on screen is the failure nobody would notice.\n */\nfunction withhold<TEntity extends Entity>(\n columns: Array<EntityTableColumn<TEntity>>,\n withheld: readonly string[],\n): Array<EntityTableColumn<TEntity>> {\n for (const name of withheld) {\n if (!columns.some(column => column.name === name)) {\n throw new Error(\n `EntityTable was asked to hide \"${name}\", which is not one of its columns. ` +\n 'Name a member the entity declares, or a column a slot adds.',\n );\n }\n }\n return columns.filter(column => !withheld.includes(column.name));\n}\n\n/**\n * Whether a column is the record's own key — the entity's `id`, not a\n * reference to another record's.\n */\nfunction isOwnKey<TEntity extends Entity>(\n column: EntityTableColumn<TEntity>,\n): boolean {\n return column.type === 'id' && column.references === undefined;\n}\n\n/**\n * The whole column pipeline as a pure function — metadata descriptors, then\n * slot overrides, then what the host withholds and the record's own key\n * (unless `showKey`), then the user's stored layout.\n * Kept separate from the hook so the resolution rules can be reasoned about\n * (and tested) without React.\n */\nexport function resolveEntityTableColumns<TEntity extends Entity>(\n described: Array<EntityTableColumn<TEntity>>,\n slotColumns: Array<EntityColumnProps<TEntity>>,\n personalization: ColumnPersonalization,\n withheld: readonly string[] = NONE_WITHHELD,\n showKey = false,\n): {\n columns: Array<EntityTableColumn<TEntity>>;\n visibleColumns: Array<EntityTableColumn<TEntity>>;\n hidden: string[];\n} {\n const kept = withhold(mergeSlots(described, slotColumns), withheld);\n const columns = applyOrder(\n showKey ? kept : kept.filter(column => !isOwnKey(column)),\n personalization.order,\n );\n const hidden = personalization.hidden ?? [];\n\n return {\n columns,\n visibleColumns: columns.filter(column => !hidden.includes(column.name)),\n hidden,\n };\n}\n\nexport interface UseEntityTableColumnsResult<TEntity extends Entity> {\n /** Every column, in the user's order — what the settings popover lists. */\n columns: Array<EntityTableColumn<TEntity>>;\n /** The subset actually rendered. */\n visibleColumns: Array<EntityTableColumn<TEntity>>;\n hidden: string[];\n personalization: ColumnPersonalization;\n setPersonalization: (next: ColumnPersonalization) => void;\n}\n\n/**\n * Resolves the columns a table renders: entity metadata, then slot overrides,\n * then the user's persisted layout.\n */\nexport function useEntityTableColumns<TEntity extends Entity>(\n entityConstructor: EntityConstructor<TEntity>,\n slotColumns: Array<EntityColumnProps<TEntity>>,\n sample: TEntity | undefined,\n preferenceKey: string,\n withheld: readonly string[] = NONE_WITHHELD,\n showKey = false,\n): UseEntityTableColumnsResult<TEntity> {\n const { value: personalization, setValue: setPersonalization } =\n useUiPreference<ColumnPersonalization>(\n preferenceKey,\n EMPTY_PERSONALIZATION,\n );\n\n const metadata = useMemo(\n () =>\n describeEntityColumns(entityConstructor, sample).filter(\n descriptor => descriptor.presentation !== 'none',\n ) as Array<EntityTableColumn<TEntity>>,\n [entityConstructor, sample],\n );\n\n // Before slots merge, so an `<EntityColumn label>` override still wins over\n // the entity's own translated label.\n const described = useLocalizedDescriptors(metadata);\n\n // Not memoized: `slotColumns` is rebuilt from `children` on every render, so\n // any dependency list would miss every time. The work is a few array passes\n // over a handful of columns — cheaper than the comparison would be.\n const { columns, visibleColumns, hidden } = resolveEntityTableColumns(\n described,\n slotColumns,\n personalization,\n withheld,\n showKey,\n );\n\n return {\n columns,\n visibleColumns,\n hidden,\n personalization,\n setPersonalization,\n };\n}\n"],"names":["describeEntityColumns","useMemo","useLocalizedDescriptors","useUiPreference","EMPTY_PERSONALIZATION","NONE_WITHHELD","mergeSlots","descriptors","slotColumns","merged","map","descriptor","slot","find","entry","field","name","_field","overrides","Object","fromEntries","entries","filter","value","undefined","virtual","some","index","key","label","type","sortable","filterable","order","length","readonly","required","linkLabelProperty","linkSearchProperty","linkSerialization","resetOnClone","minWidth","money","header","render","sort","left","right","applyOrder","columns","ranked","column","remaining","includes","withhold","withheld","Error","isOwnKey","references","resolveEntityTableColumns","described","personalization","showKey","kept","hidden","visibleColumns","useEntityTableColumns","entityConstructor","sample","preferenceKey","setValue","setPersonalization","metadata","presentation"],"mappings":"AAAA;;;AAEA,SACEA,qBAAqB,QAGhB,gBAAgB;AACvB,SAASC,OAAO,QAAQ,QAAQ;AAEhC,SAASC,uBAAuB,QAAQ,yBAAyB;AACjE,SAASC,eAAe,QAAQ,gCAAgC;AAKhE,MAAMC,wBAA+C,CAAC;AACtD,MAAMC,gBAAmC,EAAE;AAE3C;;;;CAIC,GACD,SAASC,WACPC,WAA8C,EAC9CC,WAA8C;IAE9C,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ALf,MAAME,OAAOT,SAAShD,WAAWsD,WAAWpD,cAAc+C;IAC1D,MAAMN,UAAUD,WACdc,UAAUC,OAAOA,KAAKzC,MAAM,CAAC6B,CAAAA,SAAU,CAACM,SAASN,UACjDU,gBAAgB5B,KAAK;IAEvB,MAAM+B,UAASH,0BAAAA,gBAAgBG,MAAM,YAAtBH,0BAA0B,EAAE;IAE3C,OAAO;QACLZ;QACAgB,gBAAgBhB,QAAQ3B,MAAM,CAAC6B,CAAAA,SAAU,CAACa,OAAOX,QAAQ,CAACF,OAAOnC,IAAI;QACrEgD;IACF;AACF;AAYA;;;CAGC,GACD,OAAO,SAASE,sBACdC,iBAA6C,EAC7C3D,WAA8C,EAC9C4D,MAA2B,EAC3BC,aAAqB,EACrBd,WAA8BlD,aAAa,EAC3CyD,UAAU,KAAK;IAEf,MAAM,EAAEvC,OAAOsC,eAAe,EAAES,UAAUC,kBAAkB,EAAE,GAC5DpE,gBACEkE,eACAjE;IAGJ,MAAMoE,WAAWvE,QACf,IACED,sBAAsBmE,mBAAmBC,QAAQ9C,MAAM,CACrDX,CAAAA,aAAcA,WAAW8D,YAAY,KAAK,SAE9C;QAACN;QAAmBC;KAAO;IAG7B,4EAA4E;IAC5E,qCAAqC;IACrC,MAAMR,YAAY1D,wBAAwBsE;IAE1C,6EAA6E;IAC7E,4EAA4E;IAC5E,oEAAoE;IACpE,MAAM,EAAEvB,OAAO,EAAEgB,cAAc,EAAED,MAAM,EAAE,GAAGL,0BAC1CC,WACApD,aACAqD,iBACAN,UACAO;IAGF,OAAO;QACLb;QACAgB;QACAD;QACAH;QACAU;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/ui/organisms/entity-table/use-entity-table-columns.ts"],"sourcesContent":["'use client';\n\nimport {\n describeEntityColumns,\n type Entity,\n type EntityConstructor,\n} from '@entifix/core';\nimport { useMemo } from 'react';\n\nimport { useLocalizedDescriptors } from '../../../i18n/index.js';\nimport { useUiPreference } from '../../../preferences/index.js';\nimport type { ColumnPersonalization } from '../../molecules/column-settings/index.js';\nimport type { EntityTableColumn } from './entity-table.types.js';\nimport type { EntityColumnProps } from './entity-table-slots.js';\n\nconst EMPTY_PERSONALIZATION: ColumnPersonalization = {};\nconst NONE_WITHHELD: readonly string[] = [];\n\n/**\n * Applies `<EntityColumn>` overrides on top of the metadata descriptors, and\n * appends a virtual column for any slot naming a member the entity does not\n * have (a computed column).\n */\nfunction mergeSlots<TEntity extends Entity>(\n descriptors: Array<EntityTableColumn<TEntity>>,\n slotColumns: Array<EntityColumnProps<TEntity>>,\n): Array<EntityTableColumn<TEntity>> {\n const merged = descriptors.map(descriptor => {\n const slot = slotColumns.find(entry => entry.field === descriptor.name);\n if (!slot) return descriptor;\n const { field: _field, ...overrides } = slot;\n return {\n ...descriptor,\n ...Object.fromEntries(\n Object.entries(overrides).filter(([, value]) => value !== undefined),\n ),\n } as EntityTableColumn<TEntity>;\n });\n\n const virtual = slotColumns\n .filter(slot => !descriptors.some(entry => entry.name === slot.field))\n .map<EntityTableColumn<TEntity>>((slot, index) => ({\n name: slot.field,\n key: slot.field,\n label: slot.label ?? slot.field,\n type: slot.type ?? 'string',\n sortable: slot.sortable ?? false,\n filterable: slot.filterable ?? false,\n order: slot.order ?? descriptors.length + index,\n readonly: false,\n required: false,\n linkLabelProperty: 'name',\n linkSearchProperty: 'name',\n linkSerialization: 'id',\n // A slot-only column has no accessor, so there is nothing for a copy to\n // reset — the value is computed from members that are cloned themselves.\n resetOnClone: false,\n ...(slot.minWidth === undefined ? {} : { minWidth: slot.minWidth }),\n ...(slot.money === undefined ? {} : { money: slot.money }),\n ...(slot.scaled === undefined ? {} : { scaled: slot.scaled }),\n header: slot.header,\n render: slot.render,\n virtual: true,\n }));\n\n return [...merged, ...virtual].sort(\n (left, right) => left.order - right.order,\n );\n}\n\n/**\n * Reorders columns per the stored personalization. Names the user never saw\n * (added to the entity after the layout was saved) keep their default position\n * at the end instead of vanishing, and stale names in the stored order are\n * dropped — so a saved layout degrades rather than breaks.\n */\nfunction applyOrder<TEntity extends Entity>(\n columns: Array<EntityTableColumn<TEntity>>,\n order: string[] | undefined,\n): Array<EntityTableColumn<TEntity>> {\n if (!order || order.length === 0) return columns;\n\n const ranked = order\n .map(name => columns.find(column => column.name === name))\n .filter((column): column is EntityTableColumn<TEntity> => !!column);\n const remaining = columns.filter(column => !order.includes(column.name));\n\n return [...ranked, ...remaining];\n}\n\n/**\n * Drops the columns the host withholds from this reader. Not a hidden column\n * the reader can bring back: it is gone from the settings, the filters, the\n * sort choices and the cards. A name that is no column throws, because a\n * withheld column that is still on screen is the failure nobody would notice.\n */\nfunction withhold<TEntity extends Entity>(\n columns: Array<EntityTableColumn<TEntity>>,\n withheld: readonly string[],\n): Array<EntityTableColumn<TEntity>> {\n for (const name of withheld) {\n if (!columns.some(column => column.name === name)) {\n throw new Error(\n `EntityTable was asked to hide \"${name}\", which is not one of its columns. ` +\n 'Name a member the entity declares, or a column a slot adds.',\n );\n }\n }\n return columns.filter(column => !withheld.includes(column.name));\n}\n\n/**\n * Whether a column is the record's own key — the entity's `id`, not a\n * reference to another record's.\n */\nfunction isOwnKey<TEntity extends Entity>(\n column: EntityTableColumn<TEntity>,\n): boolean {\n return column.type === 'id' && column.references === undefined;\n}\n\n/**\n * The whole column pipeline as a pure function — metadata descriptors, then\n * slot overrides, then what the host withholds and the record's own key\n * (unless `showKey`), then the user's stored layout.\n * Kept separate from the hook so the resolution rules can be reasoned about\n * (and tested) without React.\n */\nexport function resolveEntityTableColumns<TEntity extends Entity>(\n described: Array<EntityTableColumn<TEntity>>,\n slotColumns: Array<EntityColumnProps<TEntity>>,\n personalization: ColumnPersonalization,\n withheld: readonly string[] = NONE_WITHHELD,\n showKey = false,\n): {\n columns: Array<EntityTableColumn<TEntity>>;\n visibleColumns: Array<EntityTableColumn<TEntity>>;\n hidden: string[];\n} {\n const kept = withhold(mergeSlots(described, slotColumns), withheld);\n const columns = applyOrder(\n showKey ? kept : kept.filter(column => !isOwnKey(column)),\n personalization.order,\n );\n const hidden = personalization.hidden ?? [];\n\n return {\n columns,\n visibleColumns: columns.filter(column => !hidden.includes(column.name)),\n hidden,\n };\n}\n\nexport interface UseEntityTableColumnsResult<TEntity extends Entity> {\n /** Every column, in the user's order — what the settings popover lists. */\n columns: Array<EntityTableColumn<TEntity>>;\n /** The subset actually rendered. */\n visibleColumns: Array<EntityTableColumn<TEntity>>;\n hidden: string[];\n personalization: ColumnPersonalization;\n setPersonalization: (next: ColumnPersonalization) => void;\n}\n\n/**\n * Resolves the columns a table renders: entity metadata, then slot overrides,\n * then the user's persisted layout.\n */\nexport function useEntityTableColumns<TEntity extends Entity>(\n entityConstructor: EntityConstructor<TEntity>,\n slotColumns: Array<EntityColumnProps<TEntity>>,\n sample: TEntity | undefined,\n preferenceKey: string,\n withheld: readonly string[] = NONE_WITHHELD,\n showKey = false,\n): UseEntityTableColumnsResult<TEntity> {\n const { value: personalization, setValue: setPersonalization } =\n useUiPreference<ColumnPersonalization>(\n preferenceKey,\n EMPTY_PERSONALIZATION,\n );\n\n const metadata = useMemo(\n () =>\n describeEntityColumns(entityConstructor, sample).filter(\n descriptor => descriptor.presentation !== 'none',\n ) as Array<EntityTableColumn<TEntity>>,\n [entityConstructor, sample],\n );\n\n // Before slots merge, so an `<EntityColumn label>` override still wins over\n // the entity's own translated label.\n const described = useLocalizedDescriptors(metadata);\n\n // Not memoized: `slotColumns` is rebuilt from `children` on every render, so\n // any dependency list would miss every time. The work is a few array passes\n // over a handful of columns — cheaper than the comparison would be.\n const { columns, visibleColumns, hidden } = resolveEntityTableColumns(\n described,\n slotColumns,\n personalization,\n withheld,\n showKey,\n );\n\n return {\n columns,\n visibleColumns,\n hidden,\n personalization,\n setPersonalization,\n };\n}\n"],"names":["describeEntityColumns","useMemo","useLocalizedDescriptors","useUiPreference","EMPTY_PERSONALIZATION","NONE_WITHHELD","mergeSlots","descriptors","slotColumns","merged","map","descriptor","slot","find","entry","field","name","_field","overrides","Object","fromEntries","entries","filter","value","undefined","virtual","some","index","key","label","type","sortable","filterable","order","length","readonly","required","linkLabelProperty","linkSearchProperty","linkSerialization","resetOnClone","minWidth","money","scaled","header","render","sort","left","right","applyOrder","columns","ranked","column","remaining","includes","withhold","withheld","Error","isOwnKey","references","resolveEntityTableColumns","described","personalization","showKey","kept","hidden","visibleColumns","useEntityTableColumns","entityConstructor","sample","preferenceKey","setValue","setPersonalization","metadata","presentation"],"mappings":"AAAA;;;AAEA,SACEA,qBAAqB,QAGhB,gBAAgB;AACvB,SAASC,OAAO,QAAQ,QAAQ;AAEhC,SAASC,uBAAuB,QAAQ,yBAAyB;AACjE,SAASC,eAAe,QAAQ,gCAAgC;AAKhE,MAAMC,wBAA+C,CAAC;AACtD,MAAMC,gBAAmC,EAAE;AAE3C;;;;CAIC,GACD,SAASC,WACPC,WAA8C,EAC9CC,WAA8C;IAE9C,MAAMC,SAASF,YAAYG,GAAG,CAACC,CAAAA;QAC7B,MAAMC,OAAOJ,YAAYK,IAAI,CAACC,CAAAA,QAASA,MAAMC,KAAK,KAAKJ,WAAWK,IAAI;QACtE,IAAI,CAACJ,MAAM,OAAOD;QAClB,MAAM,EAAEI,OAAOE,MAAM,EAAgB,GAAGL,MAAdM,6CAAcN;;;QACxC,OAAO,aACFD,YACAQ,OAAOC,WAAW,CACnBD,OAAOE,OAAO,CAACH,WAAWI,MAAM,CAAC,CAAC,GAAGC,MAAM,GAAKA,UAAUC;IAGhE;IAEA,MAAMC,UAAUjB,YACbc,MAAM,CAACV,CAAAA,OAAQ,CAACL,YAAYmB,IAAI,CAACZ,CAAAA,QAASA,MAAME,IAAI,KAAKJ,KAAKG,KAAK,GACnEL,GAAG,CAA6B,CAACE,MAAMe;YAG/Bf,aACDA,YACIA,gBACEA,kBACLA;eAP0C;YACjDI,MAAMJ,KAAKG,KAAK;YAChBa,KAAKhB,KAAKG,KAAK;YACfc,KAAK,GAAEjB,cAAAA,KAAKiB,KAAK,YAAVjB,cAAcA,KAAKG,KAAK;YAC/Be,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AAMqE,WAAWxE,QACf,IACED,sBAAsBoE,mBAAmBC,QAAQ/C,MAAM,CACrDX,CAAAA,aAAcA,WAAW+D,YAAY,KAAK,SAE9C;QAACN;QAAmBC;KAAO;IAG7B,4EAA4E;IAC5E,qCAAqC;IACrC,MAAMR,YAAY3D,wBAAwBuE;IAE1C,6EAA6E;IAC7E,4EAA4E;IAC5E,oEAAoE;IACpE,MAAM,EAAEvB,OAAO,EAAEgB,cAAc,EAAED,MAAM,EAAE,GAAGL,0BAC1CC,WACArD,aACAsD,iBACAN,UACAO;IAGF,OAAO;QACLb;QACAgB;QACAD;QACAH;QACAU;IACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@entifix/react-controls",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.8",
|
|
4
4
|
"description": "Entity-agnostic React UI — table, form, filters, wizard, command palette — rendered from entity metadata, plus layout primitives.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@headlessui/react": "^2.2.10",
|
|
20
20
|
"class-variance-authority": "^0.7.1",
|
|
21
21
|
"idb": "^8.0.4",
|
|
22
|
-
"@entifix/core": "0.23.
|
|
22
|
+
"@entifix/core": "0.23.8"
|
|
23
23
|
},
|
|
24
24
|
"exports": {
|
|
25
25
|
"./package.json": "./package.json",
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"react": "19.3.1",
|
|
56
56
|
"react-i18next": "18.0.1",
|
|
57
57
|
"storybook": "^10.6.6",
|
|
58
|
-
"@entifix/i18n": "0.23.
|
|
59
|
-
"@entifix/style": "0.23.
|
|
58
|
+
"@entifix/i18n": "0.23.8",
|
|
59
|
+
"@entifix/style": "0.23.8"
|
|
60
60
|
},
|
|
61
61
|
"nx": {
|
|
62
62
|
"tags": [
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
"i18next": ">=26 <28",
|
|
112
112
|
"react": ">=19 <20",
|
|
113
113
|
"react-i18next": ">=17 <19",
|
|
114
|
-
"@entifix/i18n": "0.23.
|
|
114
|
+
"@entifix/i18n": "0.23.8"
|
|
115
115
|
},
|
|
116
116
|
"peerDependenciesMeta": {
|
|
117
117
|
"@entifix/i18n": {
|