@entifix/react-controls 0.23.18 → 0.23.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/i18n/catalog/en.d.ts.map +1 -1
- package/dist/i18n/catalog/en.js +3 -7
- package/dist/i18n/catalog/en.js.map +1 -1
- package/dist/i18n/catalog/es.d.ts +2 -7
- package/dist/i18n/catalog/es.d.ts.map +1 -1
- package/dist/i18n/catalog/es.js +3 -7
- package/dist/i18n/catalog/es.js.map +1 -1
- package/dist/i18n/catalog/index.d.ts +4 -6
- package/dist/i18n/catalog/index.d.ts.map +1 -1
- package/dist/ui/atoms/cell-value/cell-value.d.ts.map +1 -1
- package/dist/ui/atoms/cell-value/cell-value.js +25 -5
- package/dist/ui/atoms/cell-value/cell-value.js.map +1 -1
- package/dist/ui/atoms/cell-value/format-unit.d.ts +9 -0
- package/dist/ui/atoms/cell-value/format-unit.d.ts.map +1 -0
- package/dist/ui/atoms/cell-value/format-unit.js +34 -0
- package/dist/ui/atoms/cell-value/format-unit.js.map +1 -0
- package/dist/ui/molecules/pagination/pagination-links.d.ts +1 -1
- package/dist/ui/molecules/pagination/pagination-links.d.ts.map +1 -1
- package/dist/ui/molecules/pagination/pagination-links.js +6 -1
- package/dist/ui/molecules/pagination/pagination-links.js.map +1 -1
- package/dist/ui/molecules/pagination/pagination.d.ts.map +1 -1
- package/dist/ui/molecules/pagination/pagination.js +2 -1
- package/dist/ui/molecules/pagination/pagination.js.map +1 -1
- 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 +2 -1
- package/dist/ui/organisms/entity-detail-grid/entity-detail-grid.js.map +1 -1
- package/dist/ui/organisms/entity-form/entity-form.d.ts.map +1 -1
- package/dist/ui/organisms/entity-form/entity-form.js +8 -1
- package/dist/ui/organisms/entity-form/entity-form.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/ui/organisms/entity-form/entity-form.tsx"],"sourcesContent":["'use client';\n\nimport {\n cloneEntityDraft,\n describeEntityColumns,\n type Entity,\n type EntityAction,\n type EntityDraft,\n type EntityDraftValue,\n type EntityFieldDescriptor,\n type EntityLinkSource,\n extractMetaEntity,\n isRecordDeletable,\n isRecordWritable,\n type MetaAccessorType,\n readDraftString,\n readLocalizedDraft,\n readRowDrafts,\n type UseCaseDescriptor,\n} from '@entifix/core';\nimport { type ReactNode, useEffect, useId, useRef, useState } from 'react';\n\nimport {\n useEntityNoun,\n useLocalizedDescriptors,\n useT,\n useTranslateKey,\n} from '../../../i18n/index.js';\nimport {\n availableUseCases,\n renderAnchor,\n useCasesForSurface,\n} from '../../actions/index.js';\nimport { useVerbInvoker } from '../../actions/use-verb-invoker.js';\nimport { Alert } from '../../atoms/alert/index.js';\nimport { Button, button } from '../../atoms/button/index.js';\nimport { CellValue, useRecordLabel } from '../../atoms/cell-value/index.js';\nimport { FieldControl } from '../../atoms/field-control/index.js';\nimport { LocalizedFieldControl } from '../../atoms/localized-field-control/index.js';\nimport { Skeleton } from '../../atoms/skeleton/index.js';\nimport { Text } from '../../atoms/text/index.js';\nimport {\n ActionBar,\n type ActionBarItem,\n itemsForUseCases,\n} from '../../molecules/action-bar/index.js';\nimport { Card } from '../../molecules/card/index.js';\nimport { EntityLinkInput } from '../../molecules/entity-link-input/index.js';\nimport { EntityLinkMultiInput } from '../../molecules/entity-link-multi-input/index.js';\nimport { LoadingBoundary } from '../../molecules/loading-boundary/index.js';\nimport { RegionState } from '../../molecules/region-state/index.js';\nimport { Stack } from '../../molecules/stack/index.js';\nimport { cn } from '../../utils/cn.js';\nimport { useLiveUpdates } from '../../utils/live-updates.js';\nimport {\n useFocusOnArrival,\n useFocusOnLoss,\n} from '../../utils/use-focus-on-arrival.js';\nimport { EntityDetailGrid } from '../entity-detail-grid/index.js';\nimport type {\n EntityFormField,\n EntityFormMode,\n EntityFormProps,\n} from './entity-form.types.js';\nimport { readEntityFormFields } from './entity-form-slots.js';\nimport { resolveEntityFormFields } from './use-entity-form-fields.js';\n\n/**\n * The member types a `linkSources` entry can actually produce an editor for.\n *\n * `link` is the obvious one. `string` is here because a foreign key does not\n * have to be a typed relation: when the target lives in **another slice's\n * store**, an `EntityLink` would be an illegal edge and a storage-layer join\n * across a store boundary, so the member is a plain id and the relation exists\n * only in the operator's head — a cross-store reference is an id, never a\n * link. Nothing about the editor cares which of the two it is —\n * `EntityLinkInput` writes `String(target.id)` into the draft either way, and\n * the *only* place `link`-ness still matters is `applyEntityLinks` at submit,\n * which skips a non-`link` descriptor and so leaves the id as the truth.\n *\n * A `scalarCollection` that declares `references` is the to-many form of the\n * same thing: each element is one target's id, and the editor is\n * `EntityLinkMultiInput`, which adds and removes ids by name. Without\n * `references` a list of values names no record, so a source on it is the\n * same wiring mistake as one on a `number`.\n *\n * Everything else is excluded on purpose rather than by omission: a `boolean`,\n * `enum`, `number` or `date` member cannot name another record, so a source\n * pointed at one is a wiring mistake — see {@link assertLinkSourcesAreEditable}.\n */\nconst PICKABLE_TYPES: ReadonlySet<MetaAccessorType> = new Set<MetaAccessorType>(\n ['link', 'string'],\n);\n\n/** A list of ids into another entity: a `scalarCollection` that declares `references`. */\nconst isReferenceList = (field: EntityFieldDescriptor): boolean =>\n field.type === 'scalarCollection' && field.references !== undefined;\n\n/**\n * A form that builds itself from an entity's metadata: fields, labels and value\n * formatting all come from `@accessor()` declarations, so editing a new entity\n * needs no bespoke form. The read/edit toggle is the whole point — the same\n * component shows a record as text or as inputs.\n *\n * Two things layer on top of that default:\n * - **modes** — `read` renders each member through `CellValue`; `edit` renders\n * the matching `FieldControl`. A member in {@link PICKABLE_TYPES} with an\n * entry in `linkSources` gets the full picker instead — a to-one `link`, or a\n * `string` holding a foreign key into another slice's store. Without a source,\n * a relation stays read-only, and a `linkCollection` always does, the to-many\n * editor being a follow-up. A source aimed at a member that can render no\n * picker is a wiring mistake rather than a no-op, and throws.\n * - **slots** — `<EntityField>` children override one field's label, control or\n * read display, or add a computed field.\n *\n * It is presentational: the draft, its errors and the save/delete actions are\n * all props, so the same form hosts on a plain route and inside a workspace tab.\n */\n/** The key the built-in Delete runs under, which no declared verb can take. */\nconst DELETE_KEY = '$delete';\n\n/** Save, from anywhere in the form — the caret in a field included. */\nconst SAVE_SHORTCUT = 'Mod+S';\n/** The footer's declared primary, when it is not Save. */\nconst PRIMARY_SHORTCUT = 'Mod+Enter';\n\nexport function EntityForm<TEntity extends Entity>({\n entityConstructor,\n entity,\n values,\n onFieldChange,\n linkSources,\n onLinkChange,\n mode: modeProp,\n defaultMode,\n onModeChange,\n errors,\n formError,\n onSubmit,\n onDelete,\n deletePolicy = 'confirm',\n embedded = false,\n isLoading = false,\n skeleton = true,\n isSaving = false,\n isPending = false,\n isDeleting = false,\n error,\n onRetry,\n onKeepMine,\n onLoadCurrent,\n backHref,\n renderLink = renderAnchor,\n title,\n metadata,\n isMetadataLoading = false,\n onUseCase,\n verbForms,\n onClone,\n children,\n}: EntityFormProps<TEntity>) {\n const formId = useId();\n const slots = readEntityFormFields<TEntity>(children);\n // The *field* descriptors, which stay local and synchronous — a column is a\n // property of the class every caller holds. Only an action's availability is\n // a property of the caller, which is why that half arrives as `metadata`.\n // A member that presents as nothing (a `revision`) stays in the draft and is\n // never drawn.\n const columnDescriptors = describeEntityColumns(\n entityConstructor,\n entity,\n ).filter(descriptor => descriptor.presentation !== 'none') as Array<\n EntityFormField<TEntity>\n >;\n // Before slots resolve, so an `<EntityField label>` override still wins.\n const described = useLocalizedDescriptors(columnDescriptors);\n const resolved = resolveEntityFormFields(described, slots.fields);\n assertLinkSourcesAreEditable(resolved, linkSources);\n\n // **Form above, table below**, and it is a partition rather than an ordering\n // hint. A grid rendered between two labelled inputs reads as a field, which\n // it is not — it is a second record list — so every owned collection is\n // pulled out of the field stack whatever `order` it declared, and rendered\n // full width beneath it. A composition that named no child has nothing to\n // render and stays where it was, showing its row count as before.\n const fields = resolved.filter(field => !isOwnedCollection(field));\n const ownedCollections = resolved.filter(isOwnedCollection);\n\n /**\n * `true`/omitted → the built-in default, which draws one label+control pair\n * per resolved field; a node → that node; `false` → nothing. The field list\n * comes from the constructor's metadata, not from the record, so it is already\n * complete while the record is still in flight — which is what lets the\n * placeholder match the form it is standing in for.\n */\n const customSkeleton = typeof skeleton === 'boolean' ? undefined : skeleton;\n const showSkeleton = isLoading && skeleton !== false;\n\n const [internalMode, setInternalMode] = useState<EntityFormMode>(\n defaultMode ?? (entity ? 'read' : 'edit'),\n );\n // A stored record outside the states it may be saved in is read, not\n // edited: no field takes input and there is no Save (ADR 0029). The verbs\n // its state allows stay, so the next legal move — a New version — is right\n // there. A create has no state to hold, and absent metadata decides nothing.\n const frozen =\n entity !== undefined &&\n metadata !== undefined &&\n !isRecordWritable(metadata, entity);\n const undeletable =\n entity !== undefined &&\n metadata !== undefined &&\n !isRecordDeletable(metadata, entity);\n const mode = frozen ? 'read' : (modeProp ?? internalMode);\n const editing = mode === 'edit';\n\n const draft: EntityDraft = values ?? {};\n const setField = (name: string, value: EntityDraftValue) =>\n onFieldChange?.(name, value);\n\n const toggleMode = () => {\n const next: EntityFormMode = editing ? 'read' : 'edit';\n setInternalMode(next);\n onModeChange?.(next);\n };\n\n const t = useT();\n const translateKey = useTranslateKey();\n const entityNoun = useEntityNoun();\n const live = useLiveUpdates();\n // A form reached by a write — saved, handed off by a wizard — takes focus on\n // its heading, so it never rests on `<body>` (ADR 0028).\n const heading = useRef<HTMLHeadingElement>(null);\n useFocusOnArrival(heading);\n const busy = isSaving || isPending || isDeleting;\n\n // A draft restored from storage holds relation ids and no instances, so every\n // picker is resolving its target for a moment after mount. Saving inside that\n // window is exactly the case `applyEntityLinks` refuses: an `embedded` member\n // with an id and nothing to inline. Gating the save is the honest answer —\n // the form is still assembling itself, and the wait is one lookup long.\n //\n // Deliberately not narrowed to `embedded` members: a descriptor's\n // serialization is not what makes an in-flight lookup a bad moment to submit,\n // and a form that saves half-resolved is confusing whichever shape it writes.\n const resolvingLinks = Object.values(linkSources ?? {}).some(\n source => source.selected.isLoading,\n );\n\n // Absent metadata keeps the pre-ADR-0026 behaviour, so an un-migrated call\n // site renders exactly as before. Present metadata is authoritative: it is\n // what the service already decided this caller may do.\n const granted = (action: EntityAction) =>\n metadata === undefined || metadata.actions.includes(action);\n // What this caller may do with **this** record: the grant, narrowed by the\n // record's state. Clone asks for the grant alone — what it makes is a create.\n const may = (action: EntityAction) =>\n granted(action) &&\n !(action === 'write' && frozen) &&\n !(action === 'delete' && undeletable);\n\n // A single-record form shows the verbs that act on *this* record. Which cell\n // lands where is `action-surfaces`' business and nobody else's — a\n // `context-dependent` entity verb belongs to a row's overflow menu and a\n // `collection`-bound one to the bulk bar, and resolving that here as well is\n // how the two surfaces drifted apart in the first place.\n //\n // ⚠️ **Only when there is somewhere for them to go.** Every cell these two\n // surfaces render is `binding: 'entity'`, so without an `onUseCase` the\n // button has no handler and clicking it does nothing at all. That is not a\n // hypothetical: `makeEntityCrud` withholds the handler on a create, because\n // there is no record for a verb to act on — and Publish and Unpublish\n // rendered on a new `ProductOffering` and were inert, which reads as a broken\n // feature rather than an inapplicable one.\n //\n // The hooks are called unconditionally and their *results* are gated: React's\n // hook count must stay fixed across renders.\n const declaredHeaderUseCases = useCasesForSurface(\n 'form-header',\n metadata?.useCases,\n verbForms,\n );\n const declaredFooterUseCases = useCasesForSurface(\n 'form-footer',\n metadata?.useCases,\n verbForms,\n );\n // And only the verbs the record's state allows: a shipment awaiting dispatch\n // offers Dispatch, not every move a shipment can ever make.\n const headerUseCases = onUseCase\n ? availableUseCases(declaredHeaderUseCases, entity)\n : [];\n const footerUseCases = onUseCase\n ? availableUseCases(declaredFooterUseCases, entity)\n : [];\n // A verb that moved its record out of the states it applies to unmounts the\n // button the reader just pressed; focus goes to the heading, not `<body>`.\n useFocusOnLoss(\n () => heading.current,\n [\n ...headerUseCases.map(({ key }) => key),\n ...footerUseCases.map(({ key }) => key),\n ...(frozen ? [] : ['save']),\n ].join(' '),\n );\n\n // Every verb on the form, and its own Delete, goes through one invoker: a\n // destructive verb asks, asks for the name, or runs and offers Undo, as it\n // declared — `revoke-sessions` ends every session a user holds.\n const verbs = useVerbInvoker<undefined>({\n run: key => (key === DELETE_KEY ? onDelete?.() : onUseCase?.(key)),\n busy,\n served: metadata?.useCases,\n });\n // What a confirmation names — the object in \"Delete {record}?\" and the text\n // the typed policy asks for — through the one derivation every surface\n // shares: the entity's `labelMember`, resolved if it is a reference.\n const metaEntity = extractMetaEntity(entityConstructor);\n const nameOf = useRecordLabel();\n const recordLabel = nameOf(entityConstructor, draft);\n const invoke = (descriptor: UseCaseDescriptor) =>\n verbs.invoke({\n descriptor,\n target: undefined,\n object: recordLabel,\n count: 1,\n });\n const requestDelete = () => {\n // Undo is the host's to offer: only it can put a deleted record back.\n if (deletePolicy === 'undo') {\n onDelete?.();\n return;\n }\n invoke({\n key: DELETE_KEY,\n binding: 'entity',\n placement: 'determining',\n labelKey: 'controls:form.delete',\n confirm: {\n tone: 'destructive',\n messageKey: 'controls:confirm.deleteMessage',\n },\n reversible: deletePolicy,\n });\n };\n\n const headerItems = itemsForUseCases(\n headerUseCases,\n translateKey,\n invoke,\n busy,\n );\n const footerItems = itemsForUseCases(\n footerUseCases,\n translateKey,\n invoke,\n busy,\n );\n /**\n * A save attempt. Counted, so a refused one moves focus to the error summary\n * once — not again on every keystroke that leaves an error standing.\n */\n const [attempt, setAttempt] = useState(0);\n const save = () => {\n setAttempt(current => current + 1);\n onSubmit?.(draft);\n };\n // A save refused because the record moved on. It is told apart by its code,\n // the one thing a failure decoded in a browser is sure to carry, and it is\n // not a retry: the fields keep what was typed and the person chooses.\n const conflicted = error?.code === 'staleRevision';\n // A save refused because a member declared `unique` holds a value another\n // record has (ADR 0034). The failure names the member's stored key, so it is\n // that field's error — next to what has to change — and not a banner.\n const duplicated =\n error?.code === 'duplicateKey'\n ? fields.find(field => field.key === (error as { key?: string }).key)\n : undefined;\n const fieldErrors =\n duplicated === undefined\n ? errors\n : {\n ...errors,\n [duplicated.name]: t('form.duplicateValue', {\n field: duplicated.label,\n }),\n };\n const conflict = useRef<HTMLDivElement>(null);\n useEffect(() => {\n // Focus moves to the explanation, so a keyboard or screen-reader user is\n // not left on a Save that silently did nothing.\n if (conflicted) conflict.current?.focus();\n }, [conflicted, error]);\n const summary = useRef<HTMLDivElement>(null);\n const summaryId = useId();\n const invalid = editing\n ? fields.filter(field => fieldErrors?.[field.name] !== undefined)\n : [];\n const focusedAttempt = useRef(0);\n useEffect(() => {\n if (attempt === focusedAttempt.current || invalid.length === 0) return;\n focusedAttempt.current = attempt;\n summary.current?.focus();\n }, [attempt, invalid.length]);\n\n // Save is the footer's primary unless the entity declared one of its own — a\n // determining \"Publish\" is what that page is for, and Save steps aside.\n const declaresFooterPrimary = footerItems.some(\n item => item.emphasis === 'primary',\n );\n const footerActions: ActionBarItem[] = [\n ...(may('write')\n ? [\n {\n key: 'save',\n // A pending write waits on the push stream; while that is down\n // it says so, rather than waiting without a word.\n label: isPending\n ? t(live.connection === 'open' ? 'form.pending' : 'live.waiting')\n : isSaving\n ? t('form.saving')\n : t('form.save'),\n emphasis: declaresFooterPrimary\n ? ('default' as const)\n : ('primary' as const),\n disabled: busy || resolvingLinks,\n submit: true,\n shortcut: SAVE_SHORTCUT,\n onSelect: save,\n },\n ]\n : []),\n // The page's main act answers Mod+Enter, unless it declared its own.\n ...footerItems.map(item =>\n item.emphasis === 'primary' && item.shortcut === undefined\n ? { ...item, shortcut: PRIMARY_SHORTCUT }\n : item,\n ),\n // Clone is the CRUD triple's, not a declared verb's: every entity can be\n // copied, so giving it a `@useCase()` would mean declaring the same verb on\n // all 28 of them. It needs `write`, because what it produces is a create.\n ...(onClone && entity && granted('write')\n ? [\n {\n key: 'clone',\n label: t('form.clone'),\n disabled: busy,\n onSelect: () => onClone(cloneEntityDraft(entityConstructor, draft)),\n },\n ]\n : []),\n ...(onDelete && may('delete')\n ? [\n {\n key: 'delete',\n label: isDeleting ? t('form.deleting') : t('form.delete'),\n destructive: true,\n disabled: busy,\n onSelect: requestDelete,\n },\n ]\n : []),\n ];\n\n // A real form while editing, so Enter in a field saves; an embedded one\n // belongs to its host's flow, and a caller who may not write has no Save.\n const asForm = editing && !embedded && may('write');\n const rows = fields.map(field => (\n <FieldRow\n key={field.name}\n field={field}\n entity={entity}\n draft={draft}\n value={readDraftString(draft, field.name)}\n editing={editing}\n error={editing ? fieldErrors?.[field.name] : undefined}\n setField={setField}\n linkSource={linkSources?.[field.name]}\n onLinkChange={onLinkChange}\n id={`${formId}-${field.name}`}\n />\n ));\n\n const body = (\n <Stack gap=\"s\">\n {/* An embedded form brings only its fields: the heading and the action\n row belong to whatever is hosting it — a wizard step sits under the\n wizard's own heading and advances with the wizard's own footer, so\n rendering a second of each is two controls for one job. */}\n {!embedded && (\n <Stack direction=\"row\" gap=\"xs\" align=\"center\">\n <Text\n as=\"h2\"\n ref={heading}\n tabIndex={-1}\n step={1}\n weight=\"semibold\"\n className=\"focus-ring\"\n >\n {/* `entity` is undefined while the record is still in flight, so\n testing it alone made a loading edit form announce itself as\n \"New\" for as long as the fetch took, then relabel when the\n record landed. A form that is loading is never a create. */}\n {title ?? (entity || isLoading ? t('form.details') : t('form.new'))}\n </Text>\n {/* The built-in toggle only appears when the form owns its mode and\n there is a record to view — a create form has nothing to read. */}\n {modeProp === undefined && entity && !frozen && (\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n onClick={toggleMode}\n >\n {editing ? t('form.view') : t('form.edit')}\n </Button>\n )}\n <LoadingBoundary isLoading={isMetadataLoading} lines={0}>\n <>\n {headerItems.length > 0 && (\n <ActionBar surface=\"form-header\" items={headerItems} />\n )}\n {slots.headerActions}\n </>\n </LoadingBoundary>\n </Stack>\n )}\n\n {/* Why the form takes no input, said once at its top as a status rather\n than an error: nothing went wrong, the record has moved on. */}\n {frozen && metadata.readOnlyReasonKey !== undefined && (\n <Alert tone=\"info\" data-testid=\"entity-form-read-only\">\n {translateKey(metadata.readOnlyReasonKey)}\n </Alert>\n )}\n\n {/* One announcement for the form; the shimmer below is aria-hidden. */}\n <span role=\"status\" aria-live=\"polite\" className=\"sr-only\">\n {isLoading ? t('form.loading') : ''}\n </span>\n\n {conflicted && (\n <div\n ref={conflict}\n tabIndex={-1}\n data-testid=\"entity-form-conflict\"\n className=\"rounded-lg focus-ring\"\n >\n <Alert\n tone=\"danger\"\n title={t('form.conflictTitle')}\n action={\n onKeepMine === undefined &&\n onLoadCurrent === undefined ? undefined : (\n <span className=\"flex flex-wrap gap-3xs\">\n {onKeepMine !== undefined && (\n <Button\n type=\"button\"\n variant=\"primary\"\n size=\"sm\"\n onClick={onKeepMine}\n >\n {t('form.conflictKeep')}\n </Button>\n )}\n {onLoadCurrent !== undefined && (\n <Button\n type=\"button\"\n variant=\"secondary\"\n size=\"sm\"\n onClick={onLoadCurrent}\n >\n {t('form.conflictLoad')}\n </Button>\n )}\n </span>\n )\n }\n >\n {t('form.conflictBody')}\n {onKeepMine !== undefined && ` ${t('form.conflictKeepHint')}`}\n </Alert>\n </div>\n )}\n\n <RegionState\n plural={entityNoun(metaEntity, 'plural')}\n error={conflicted || duplicated !== undefined ? undefined : error}\n onRetry={onRetry}\n // Only a load that can be retried leaves an out-of-date record; a\n // failed save leaves what the reader typed, which is current.\n hasStaleData={entity !== undefined && onRetry !== undefined}\n />\n\n {/* A refused save, as one summary of links to what needs fixing: the\n only alert in the form, and where focus goes after the attempt. */}\n {invalid.length > 0 && (\n <div\n ref={summary}\n tabIndex={-1}\n role=\"alert\"\n aria-labelledby={summaryId}\n data-testid=\"entity-form-error-summary\"\n className=\"rounded-lg border-l-4 border-danger bg-danger-subtle px-s py-xs text-step-sm text-content focus-ring\"\n >\n <p id={summaryId} className=\"m-0 font-semibold\">\n {t('form.errorSummary', { count: invalid.length })}\n </p>\n <ul className=\"m-0 ps-s\">\n {invalid.map(field => (\n <li key={field.name}>\n <a\n href={`#${formId}-${field.name}`}\n // The content colour: primary on the danger surface misses\n // 4.5:1.\n className=\"font-medium text-content underline underline-offset-2 focus-ring\"\n onClick={event => {\n event.preventDefault();\n document.getElementById(`${formId}-${field.name}`)?.focus();\n }}\n >\n {fieldErrors?.[field.name]}\n </a>\n </li>\n ))}\n </ul>\n </div>\n )}\n\n {editing && fields.some(field => field.required && !field.readonly) && (\n <Text step={-1} tone=\"muted\">\n {t('form.requiredHint')}\n </Text>\n )}\n\n {/* The placeholder *replaces* the rows rather than sitting above them.\n Rendering both meant a shimmer stacked on a full set of empty fields,\n which is two loading signals for one region and twice the height the\n loaded form settles at. */}\n {showSkeleton\n ? (customSkeleton ??\n fields.map(field => (\n <Stack key={field.name} gap=\"3xs\">\n <Skeleton shape=\"line\" className=\"w-24\" />\n <Skeleton className=\"h-9 w-full\" />\n </Stack>\n )))\n : editing\n ? rows\n : // Read mode is a description list: a label points at nothing\n // when there is no control, and a term and its value is what\n // the pair is.\n rows.length > 0 && (\n <dl className=\"m-0 flex flex-col gap-s\">{rows}</dl>\n )}\n\n {/* The rows the record owns, full width and below every field. Each\n grid is handed the *whole* error map and picks out the keys naming\n its own member, so a record owning two collections needs no\n bookkeeping here. */}\n {ownedCollections.map(field => (\n <EntityDetailGrid\n key={field.name}\n descriptor={field}\n rows={readRowDrafts(draft[field.name])}\n onRowsChange={rows => setField(field.name, rows)}\n errors={editing ? errors : undefined}\n editing={editing}\n isLoading={isLoading}\n skeleton={skeleton}\n />\n ))}\n\n {/* A cross-field rule has no row to sit under, so it sits with the\n actions it blocks. */}\n {editing && formError && (\n <span role=\"alert\" className=\"text-step-sm text-danger\">\n {formError}\n </span>\n )}\n\n {/* A record read because its state allows no save keeps its footer:\n the verbs it does allow — a New version — live there, without Save\n and Delete. A form the reader toggled to View has none. */}\n {(editing || frozen) && !embedded && (\n <Stack direction=\"row\" gap=\"xs\" align=\"center\">\n <ActionBar surface=\"form-footer\" size=\"md\" items={footerActions} />\n {slots.footerActions}\n {/* A link styled as a button, not a button inside a link: the old\n nesting was two interactive elements for one action, and its\n `disabled` stopped nothing, because the anchor around it still\n navigated. While busy the link is inert instead. */}\n {backHref &&\n renderLink({\n href: backHref,\n className: cn(\n button({ variant: 'ghost' }),\n busy && 'pointer-events-none opacity-50',\n ),\n children: t('form.back'),\n intent: { kind: 'back' },\n })}\n </Stack>\n )}\n\n {slots.rest}\n </Stack>\n );\n\n return (\n <Card>\n {asForm ? (\n <form\n noValidate\n // Enter submits through Save, the form's default button, which is\n // disabled while a save is in flight — so a busy form stays put.\n onSubmit={event => {\n event.preventDefault();\n save();\n }}\n >\n {body}\n </form>\n ) : (\n body\n )}\n\n {verbs.dialog}\n </Card>\n );\n}\n\n/**\n * A member the detail grid renders rather than the field stack.\n *\n * The `childType` half is not defensive: a `composition` that declared no child\n * has no columns, so there is nothing for a grid to draw. It keeps its place in\n * the field stack and reads as its row count, which is what it did before this\n * control existed — an honest \"some rows\" rather than an empty table implying\n * there are none.\n */\nfunction isOwnedCollection<TEntity extends Entity>(\n field: EntityFormField<TEntity>,\n): boolean {\n return field.type === 'composition' && field.childType !== undefined;\n}\n\n/**\n * Refuse a `linkSources` entry that names a member no picker can be built for.\n *\n * `FieldRow` asks for {@link PICKABLE_TYPES} before it builds an editor, so a\n * source handed to anything else used to fall through to the read-only display\n * or a plain `FieldControl` with nothing said: the caller wired a picker, no\n * picker appeared, and the field was indistinguishable from one the entity had\n * declared read-only. That is a wiring mistake rather than a state — the entry\n * is dead in *every* shape such a field can render, since an\n * `<EntityField render>` slot is handed the draft and never the source — so it\n * costs the render instead of a warning nobody reads. `useEntityLinkSource`\n * already throws at render for the sibling mistake (a search\n * property the target does not declare `filterable`); this is the same fault\n * caught one level up.\n *\n * Two messages, because the two faults are not the same thing. A\n * `linkCollection` is a member the editor has simply not been built for yet\n * (#26), so the fix is to wait or to point at the to-one you meant. Any other\n * type is a member that can never name another record at all, so the fix is to\n * remove the entry.\n *\n * Here rather than inside `FieldRow`, and that is the whole reason it is a\n * separate pass: a row only reaches its editor branch in **edit** mode, so a\n * per-row check would stay silent on a form that opens in `read` — the default\n * whenever there is a record — and then throw on a click, minutes later. One\n * pass over the registry fires on the first render either way.\n *\n * Against the resolved fields rather than the raw metadata: a slot may drop a\n * member, and a source left behind for a field that no longer renders is not\n * worth a page.\n */\nfunction assertLinkSourcesAreEditable<TEntity extends Entity>(\n fields: Array<EntityFormField<TEntity>>,\n // Same reason as the prop's own declaration: a source's target is another\n // entity entirely and cannot be expressed in terms of `TEntity`.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n linkSources: Record<string, EntityLinkSource<any>> | undefined,\n): void {\n if (linkSources === undefined) return;\n\n const sourced = fields.filter(\n field =>\n linkSources[field.name] !== undefined &&\n !PICKABLE_TYPES.has(field.type) &&\n !isReferenceList(field),\n );\n if (sourced.length === 0) return;\n\n const toMany = sourced\n .filter(field => field.type === 'linkCollection')\n .map(field => field.name);\n if (toMany.length > 0) {\n throw new Error(\n `EntityForm was given a link source for a to-many member: ${toMany.join(', ')}. ` +\n 'A `linkCollection` has no editor yet, so the source can only be dropped ' +\n 'and the field would render read-only with no sign anything was wired. ' +\n 'Remove the entry, or point it at the to-one `link` you meant.',\n );\n }\n\n const owned = sourced\n .filter(field => field.type === 'composition')\n .map(field => field.name);\n if (owned.length > 0) {\n throw new Error(\n `EntityForm was given a link source for an owned collection: ${owned.join(', ')}. ` +\n 'A `composition` is not a reference — its rows have no life outside this ' +\n 'record and are never picked from existing ones, so there is nothing for a ' +\n 'picker to look up. The detail grid is what edits them.',\n );\n }\n\n const unpickable = sourced.map(field => `${field.name} (${field.type})`);\n throw new Error(\n `EntityForm was given a link source for a member that cannot hold one: ${unpickable.join(', ')}. ` +\n 'A picker writes the target’s id into the draft, so the member has to be a ' +\n '`link`, the `string` that carries a foreign key, or a `scalarCollection` ' +\n 'that declares `references`. Remove the entry, or point it at the member ' +\n 'that actually holds the reference.',\n );\n}\n\ninterface FieldRowProps<TEntity extends Entity> {\n field: EntityFormField<TEntity>;\n entity: TEntity | undefined;\n draft: EntityDraft;\n value: string;\n editing: boolean;\n error: string | undefined;\n setField: (name: string, value: EntityDraftValue) => void;\n // The target of a relation is a different entity than the form's own.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n linkSource: EntityLinkSource<any> | undefined;\n onLinkChange:\n ((name: string, entity: Entity | undefined) => void) | undefined;\n id: string;\n}\n\n/**\n * One label + control (or value) row. A `readonly` member renders its read\n * display even in edit mode, and so does a relation with no source; everything\n * else edits through `FieldControl` — or, when a source was supplied for a\n * member in {@link PICKABLE_TYPES}, through `EntityLinkInput`. A boolean edited\n * inline carries its own label, so the row does not add a second one.\n *\n * The source branch sits above the `virtual || isRelation` fallback and below\n * `field.render`, which is what lets a slot still override a picked field.\n */\nfunction FieldRow<TEntity extends Entity>({\n field,\n entity,\n draft,\n value,\n editing,\n error,\n setField,\n linkSource,\n onLinkChange,\n id,\n}: FieldRowProps<TEntity>) {\n const t = useT();\n const errorId = `${id}-error`;\n const readNode: ReactNode = field.readRender ? (\n field.readRender(entity)\n ) : (\n <CellValue\n value={\n entity ? (entity as Record<string, unknown>)[field.name] : undefined\n }\n descriptor={field}\n record={entity as Record<string, unknown> | undefined}\n />\n );\n\n // Members with no editor of their own here: a to-one `link` whose picker was\n // never wired, a `linkCollection` (#26) and a `composition`. All three\n // fall back to the read display, which is honest — a disabled text box\n // holding `[object Object]` is not.\n const isRelation =\n field.type === 'link' ||\n field.type === 'linkCollection' ||\n field.type === 'composition';\n\n let control: ReactNode;\n if (!editing) {\n control = readNode;\n } else if (field.render) {\n control = field.render({ draft, value, setField, id });\n } else if (linkSource && isReferenceList(field)) {\n control = (\n <EntityLinkMultiInput\n descriptor={field}\n value={value}\n source={linkSource}\n id={id}\n disabled={field.readonly}\n onChange={next => setField(field.name, next)}\n />\n );\n } else if (linkSource && PICKABLE_TYPES.has(field.type)) {\n control = (\n <EntityLinkInput\n descriptor={field}\n value={value}\n source={linkSource}\n id={id}\n disabled={field.readonly}\n onSelect={target => {\n setField(field.name, target.id == null ? '' : String(target.id));\n onLinkChange?.(field.name, target);\n }}\n onClear={() => {\n setField(field.name, '');\n onLinkChange?.(field.name, undefined);\n }}\n />\n );\n } else if (field.type === 'localized' && !field.virtual) {\n control = (\n <LocalizedFieldControl\n descriptor={field}\n value={readLocalizedDraft(draft, field.name)}\n onChange={next => setField(field.name, next)}\n id={id}\n />\n );\n } else if (field.virtual || isRelation) {\n // A relation with no source has no input to offer, and a virtual field has\n // no member to edit unless a `render` was supplied — both fall back to the\n // read display.\n control = readNode;\n } else {\n control = (\n <FieldControl\n descriptor={field}\n value={value}\n onChange={next => setField(field.name, next)}\n id={id}\n record={draft}\n aria-invalid={error !== undefined || undefined}\n aria-describedby={error === undefined ? undefined : errorId}\n aria-required={field.required || undefined}\n />\n );\n }\n\n if (!editing)\n return (\n <div className=\"flex flex-col gap-3xs\">\n <dt className=\"text-step-sm text-content-muted\">{field.label}</dt>\n <dd className=\"m-0\">{control}</dd>\n </div>\n );\n\n const ownsLabel = field.type === 'boolean' && !field.render && !field.virtual;\n // Marked before anyone submits, not discovered after.\n const marked = field.required && !field.readonly;\n\n return (\n <Stack gap=\"3xs\">\n {!ownsLabel && (\n // The marker sits beside the label, not in it: the name stays the\n // field's own, and `aria-required` is what says it to a reader.\n <span className=\"flex items-baseline gap-3xs\">\n <label htmlFor={id} className=\"text-step-sm text-content-muted\">\n {field.label}\n </label>\n {marked && (\n <span aria-hidden=\"true\" className=\"text-step-sm text-danger\">\n {t('form.requiredMarker')}\n </span>\n )}\n </span>\n )}\n {control}\n {/* Not an alert of its own: the summary above the fields is the one\n announcement, and this is what the control's description reads. */}\n {error && (\n <span id={errorId} className=\"text-step-sm text-danger\">\n {error}\n </span>\n )}\n </Stack>\n );\n}\n"],"names":["cloneEntityDraft","describeEntityColumns","extractMetaEntity","isRecordDeletable","isRecordWritable","readDraftString","readLocalizedDraft","readRowDrafts","useEffect","useId","useRef","useState","useEntityNoun","useLocalizedDescriptors","useT","useTranslateKey","availableUseCases","renderAnchor","useCasesForSurface","useVerbInvoker","Alert","Button","button","CellValue","useRecordLabel","FieldControl","LocalizedFieldControl","Skeleton","Text","ActionBar","itemsForUseCases","Card","EntityLinkInput","EntityLinkMultiInput","LoadingBoundary","RegionState","Stack","cn","useLiveUpdates","useFocusOnArrival","useFocusOnLoss","EntityDetailGrid","readEntityFormFields","resolveEntityFormFields","PICKABLE_TYPES","Set","isReferenceList","field","type","references","undefined","DELETE_KEY","SAVE_SHORTCUT","PRIMARY_SHORTCUT","EntityForm","entityConstructor","entity","values","onFieldChange","linkSources","onLinkChange","mode","modeProp","defaultMode","onModeChange","errors","formError","onSubmit","onDelete","deletePolicy","embedded","isLoading","skeleton","isSaving","isPending","isDeleting","error","onRetry","onKeepMine","onLoadCurrent","backHref","renderLink","title","metadata","isMetadataLoading","onUseCase","verbForms","onClone","children","formId","slots","columnDescriptors","filter","descriptor","presentation","described","resolved","fields","assertLinkSourcesAreEditable","isOwnedCollection","ownedCollections","customSkeleton","showSkeleton","internalMode","setInternalMode","frozen","undeletable","editing","draft","setField","name","value","toggleMode","next","t","translateKey","entityNoun","live","heading","busy","resolvingLinks","Object","some","source","selected","granted","action","actions","includes","may","declaredHeaderUseCases","useCases","declaredFooterUseCases","headerUseCases","footerUseCases","current","map","key","join","verbs","run","served","metaEntity","nameOf","recordLabel","invoke","target","object","count","requestDelete","binding","placement","labelKey","confirm","tone","messageKey","reversible","headerItems","footerItems","attempt","setAttempt","save","conflicted","code","duplicated","find","fieldErrors","label","conflict","focus","summary","summaryId","invalid","focusedAttempt","length","declaresFooterPrimary","item","emphasis","footerActions","connection","disabled","submit","shortcut","onSelect","destructive","asForm","rows","FieldRow","linkSource","id","body","gap","direction","align","as","ref","tabIndex","step","weight","className","variant","size","onClick","lines","surface","items","headerActions","readOnlyReasonKey","data-testid","span","role","aria-live","div","plural","hasStaleData","aria-labelledby","p","ul","li","a","href","event","document","preventDefault","getElementById","required","readonly","shape","dl","onRowsChange","intent","kind","rest","form","noValidate","dialog","childType","sourced","has","toMany","Error","owned","unpickable","errorId","readNode","readRender","record","isRelation","control","render","onChange","String","onClear","virtual","aria-invalid","aria-describedby","aria-required","dt","dd","ownsLabel","marked","htmlFor","aria-hidden"],"mappings":"AAAA;;;AAEA,SACEA,gBAAgB,EAChBC,qBAAqB,EAOrBC,iBAAiB,EACjBC,iBAAiB,EACjBC,gBAAgB,EAEhBC,eAAe,EACfC,kBAAkB,EAClBC,aAAa,QAER,gBAAgB;AACvB,SAAyBC,SAAS,EAAEC,KAAK,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAE3E,SACEC,aAAa,EACbC,uBAAuB,EACvBC,IAAI,EACJC,eAAe,QACV,yBAAyB;AAChC,SACEC,iBAAiB,EACjBC,YAAY,EACZC,kBAAkB,QACb,yBAAyB;AAChC,SAASC,cAAc,QAAQ,oCAAoC;AACnE,SAASC,KAAK,QAAQ,6BAA6B;AACnD,SAASC,MAAM,EAAEC,MAAM,QAAQ,8BAA8B;AAC7D,SAASC,SAAS,EAAEC,cAAc,QAAQ,kCAAkC;AAC5E,SAASC,YAAY,QAAQ,qCAAqC;AAClE,SAASC,qBAAqB,QAAQ,+CAA+C;AACrF,SAASC,QAAQ,QAAQ,gCAAgC;AACzD,SAASC,IAAI,QAAQ,4BAA4B;AACjD,SACEC,SAAS,EAETC,gBAAgB,QACX,sCAAsC;AAC7C,SAASC,IAAI,QAAQ,gCAAgC;AACrD,SAASC,eAAe,QAAQ,6CAA6C;AAC7E,SAASC,oBAAoB,QAAQ,mDAAmD;AACxF,SAASC,eAAe,QAAQ,4CAA4C;AAC5E,SAASC,WAAW,QAAQ,wCAAwC;AACpE,SAASC,KAAK,QAAQ,iCAAiC;AACvD,SAASC,EAAE,QAAQ,oBAAoB;AACvC,SAASC,cAAc,QAAQ,8BAA8B;AAC7D,SACEC,iBAAiB,EACjBC,cAAc,QACT,sCAAsC;AAC7C,SAASC,gBAAgB,QAAQ,iCAAiC;AAMlE,SAASC,oBAA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J,MAAMwH,KAAK;;oBAEb6F,wBACC,KAACnD;wBAAKqD,eAAY;wBAAO/D,WAAU;kCAChCrF,EAAE;;;;YAKVsI;YAGA5K,uBACC,KAACqI;gBAAKpB,IAAIsD;gBAAS5C,WAAU;0BAC1B3H;;;;AAKX"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/ui/organisms/entity-form/entity-form.tsx"],"sourcesContent":["'use client';\n\nimport {\n cloneEntityDraft,\n describeEntityColumns,\n type Entity,\n type EntityAction,\n type EntityDraft,\n type EntityDraftValue,\n type EntityFieldDescriptor,\n type EntityLinkSource,\n extractMetaEntity,\n isRecordDeletable,\n isRecordWritable,\n type MetaAccessorType,\n readDraftString,\n readLocalizedDraft,\n readRowDrafts,\n type UseCaseDescriptor,\n} from '@entifix/core';\nimport { type ReactNode, useEffect, useId, useRef, useState } from 'react';\n\nimport {\n useEntityNoun,\n useLocalizedDescriptors,\n useT,\n useTranslateKey,\n} from '../../../i18n/index.js';\nimport {\n availableUseCases,\n renderAnchor,\n useCasesForSurface,\n} from '../../actions/index.js';\nimport { useVerbInvoker } from '../../actions/use-verb-invoker.js';\nimport { Alert } from '../../atoms/alert/index.js';\nimport { Button, button } from '../../atoms/button/index.js';\nimport { CellValue, useRecordLabel } from '../../atoms/cell-value/index.js';\nimport { FieldControl } from '../../atoms/field-control/index.js';\nimport { LocalizedFieldControl } from '../../atoms/localized-field-control/index.js';\nimport { Skeleton } from '../../atoms/skeleton/index.js';\nimport { Text } from '../../atoms/text/index.js';\nimport {\n ActionBar,\n type ActionBarItem,\n itemsForUseCases,\n} from '../../molecules/action-bar/index.js';\nimport { Card } from '../../molecules/card/index.js';\nimport { EntityLinkInput } from '../../molecules/entity-link-input/index.js';\nimport { EntityLinkMultiInput } from '../../molecules/entity-link-multi-input/index.js';\nimport { LoadingBoundary } from '../../molecules/loading-boundary/index.js';\nimport { RegionState } from '../../molecules/region-state/index.js';\nimport { Stack } from '../../molecules/stack/index.js';\nimport { cn } from '../../utils/cn.js';\nimport { useLiveUpdates } from '../../utils/live-updates.js';\nimport {\n useFocusOnArrival,\n useFocusOnLoss,\n} from '../../utils/use-focus-on-arrival.js';\nimport { EntityDetailGrid } from '../entity-detail-grid/index.js';\nimport type {\n EntityFormField,\n EntityFormMode,\n EntityFormProps,\n} from './entity-form.types.js';\nimport { readEntityFormFields } from './entity-form-slots.js';\nimport { resolveEntityFormFields } from './use-entity-form-fields.js';\n\n/**\n * The member types a `linkSources` entry can actually produce an editor for.\n *\n * `link` is the obvious one. `string` is here because a foreign key does not\n * have to be a typed relation: when the target lives in **another slice's\n * store**, an `EntityLink` would be an illegal edge and a storage-layer join\n * across a store boundary, so the member is a plain id and the relation exists\n * only in the operator's head — a cross-store reference is an id, never a\n * link. Nothing about the editor cares which of the two it is —\n * `EntityLinkInput` writes `String(target.id)` into the draft either way, and\n * the *only* place `link`-ness still matters is `applyEntityLinks` at submit,\n * which skips a non-`link` descriptor and so leaves the id as the truth.\n *\n * A `scalarCollection` that declares `references` is the to-many form of the\n * same thing: each element is one target's id, and the editor is\n * `EntityLinkMultiInput`, which adds and removes ids by name. Without\n * `references` a list of values names no record, so a source on it is the\n * same wiring mistake as one on a `number`.\n *\n * Everything else is excluded on purpose rather than by omission: a `boolean`,\n * `enum`, `number` or `date` member cannot name another record, so a source\n * pointed at one is a wiring mistake — see {@link assertLinkSourcesAreEditable}.\n */\nconst PICKABLE_TYPES: ReadonlySet<MetaAccessorType> = new Set<MetaAccessorType>(\n ['link', 'string'],\n);\n\n/** A list of ids into another entity: a `scalarCollection` that declares `references`. */\nconst isReferenceList = (field: EntityFieldDescriptor): boolean =>\n field.type === 'scalarCollection' && field.references !== undefined;\n\n/**\n * A form that builds itself from an entity's metadata: fields, labels and value\n * formatting all come from `@accessor()` declarations, so editing a new entity\n * needs no bespoke form. The read/edit toggle is the whole point — the same\n * component shows a record as text or as inputs.\n *\n * Two things layer on top of that default:\n * - **modes** — `read` renders each member through `CellValue`; `edit` renders\n * the matching `FieldControl`. A member in {@link PICKABLE_TYPES} with an\n * entry in `linkSources` gets the full picker instead — a to-one `link`, or a\n * `string` holding a foreign key into another slice's store. Without a source,\n * a relation stays read-only, and a `linkCollection` always does, the to-many\n * editor being a follow-up. A source aimed at a member that can render no\n * picker is a wiring mistake rather than a no-op, and throws.\n * - **slots** — `<EntityField>` children override one field's label, control or\n * read display, or add a computed field.\n *\n * It is presentational: the draft, its errors and the save/delete actions are\n * all props, so the same form hosts on a plain route and inside a workspace tab.\n */\n/** The key the built-in Delete runs under, which no declared verb can take. */\nconst DELETE_KEY = '$delete';\n\n/** Save, from anywhere in the form — the caret in a field included. */\nconst SAVE_SHORTCUT = 'Mod+S';\n/** The footer's declared primary, when it is not Save. */\nconst PRIMARY_SHORTCUT = 'Mod+Enter';\n\nexport function EntityForm<TEntity extends Entity>({\n entityConstructor,\n entity,\n values,\n onFieldChange,\n linkSources,\n onLinkChange,\n mode: modeProp,\n defaultMode,\n onModeChange,\n errors,\n formError,\n onSubmit,\n onDelete,\n deletePolicy = 'confirm',\n embedded = false,\n isLoading = false,\n skeleton = true,\n isSaving = false,\n isPending = false,\n isDeleting = false,\n error,\n onRetry,\n onKeepMine,\n onLoadCurrent,\n backHref,\n renderLink = renderAnchor,\n title,\n metadata,\n isMetadataLoading = false,\n onUseCase,\n verbForms,\n onClone,\n children,\n}: EntityFormProps<TEntity>) {\n const formId = useId();\n const slots = readEntityFormFields<TEntity>(children);\n // The *field* descriptors, which stay local and synchronous — a column is a\n // property of the class every caller holds. Only an action's availability is\n // a property of the caller, which is why that half arrives as `metadata`.\n // A member that presents as nothing (a `revision`) stays in the draft and is\n // never drawn.\n const columnDescriptors = describeEntityColumns(\n entityConstructor,\n entity,\n ).filter(descriptor => descriptor.presentation !== 'none') as Array<\n EntityFormField<TEntity>\n >;\n // Before slots resolve, so an `<EntityField label>` override still wins.\n const described = useLocalizedDescriptors(columnDescriptors);\n const resolved = resolveEntityFormFields(described, slots.fields);\n assertLinkSourcesAreEditable(resolved, linkSources);\n\n // **Form above, table below**, and it is a partition rather than an ordering\n // hint. A grid rendered between two labelled inputs reads as a field, which\n // it is not — it is a second record list — so every owned collection is\n // pulled out of the field stack whatever `order` it declared, and rendered\n // full width beneath it. A composition that named no child has nothing to\n // render and stays where it was, showing its row count as before.\n const fields = resolved.filter(field => !isOwnedCollection(field));\n const ownedCollections = resolved.filter(isOwnedCollection);\n\n /**\n * `true`/omitted → the built-in default, which draws one label+control pair\n * per resolved field; a node → that node; `false` → nothing. The field list\n * comes from the constructor's metadata, not from the record, so it is already\n * complete while the record is still in flight — which is what lets the\n * placeholder match the form it is standing in for.\n */\n const customSkeleton = typeof skeleton === 'boolean' ? undefined : skeleton;\n const showSkeleton = isLoading && skeleton !== false;\n\n const [internalMode, setInternalMode] = useState<EntityFormMode>(\n defaultMode ?? (entity ? 'read' : 'edit'),\n );\n // A stored record outside the states it may be saved in is read, not\n // edited: no field takes input and there is no Save (ADR 0029). The verbs\n // its state allows stay, so the next legal move — a New version — is right\n // there. A create has no state to hold, and absent metadata decides nothing.\n const frozen =\n entity !== undefined &&\n metadata !== undefined &&\n !isRecordWritable(metadata, entity);\n const undeletable =\n entity !== undefined &&\n metadata !== undefined &&\n !isRecordDeletable(metadata, entity);\n const mode = frozen ? 'read' : (modeProp ?? internalMode);\n const editing = mode === 'edit';\n\n const draft: EntityDraft = values ?? {};\n const setField = (name: string, value: EntityDraftValue) =>\n onFieldChange?.(name, value);\n\n const toggleMode = () => {\n const next: EntityFormMode = editing ? 'read' : 'edit';\n setInternalMode(next);\n onModeChange?.(next);\n };\n\n const t = useT();\n const translateKey = useTranslateKey();\n const entityNoun = useEntityNoun();\n const live = useLiveUpdates();\n // A form reached by a write — saved, handed off by a wizard — takes focus on\n // its heading, so it never rests on `<body>` (ADR 0028).\n const heading = useRef<HTMLHeadingElement>(null);\n useFocusOnArrival(heading);\n const busy = isSaving || isPending || isDeleting;\n\n // A draft restored from storage holds relation ids and no instances, so every\n // picker is resolving its target for a moment after mount. Saving inside that\n // window is exactly the case `applyEntityLinks` refuses: an `embedded` member\n // with an id and nothing to inline. Gating the save is the honest answer —\n // the form is still assembling itself, and the wait is one lookup long.\n //\n // Deliberately not narrowed to `embedded` members: a descriptor's\n // serialization is not what makes an in-flight lookup a bad moment to submit,\n // and a form that saves half-resolved is confusing whichever shape it writes.\n const resolvingLinks = Object.values(linkSources ?? {}).some(\n source => source.selected.isLoading,\n );\n\n // Absent metadata keeps the pre-ADR-0026 behaviour, so an un-migrated call\n // site renders exactly as before. Present metadata is authoritative: it is\n // what the service already decided this caller may do.\n const granted = (action: EntityAction) =>\n metadata === undefined || metadata.actions.includes(action);\n // What this caller may do with **this** record: the grant, narrowed by the\n // record's state. Clone asks for the grant alone — what it makes is a create.\n const may = (action: EntityAction) =>\n granted(action) &&\n !(action === 'write' && frozen) &&\n !(action === 'delete' && undeletable);\n\n // A single-record form shows the verbs that act on *this* record. Which cell\n // lands where is `action-surfaces`' business and nobody else's — a\n // `context-dependent` entity verb belongs to a row's overflow menu and a\n // `collection`-bound one to the bulk bar, and resolving that here as well is\n // how the two surfaces drifted apart in the first place.\n //\n // ⚠️ **Only when there is somewhere for them to go.** Every cell these two\n // surfaces render is `binding: 'entity'`, so without an `onUseCase` the\n // button has no handler and clicking it does nothing at all. That is not a\n // hypothetical: `makeEntityCrud` withholds the handler on a create, because\n // there is no record for a verb to act on — and Publish and Unpublish\n // rendered on a new `ProductOffering` and were inert, which reads as a broken\n // feature rather than an inapplicable one.\n //\n // The hooks are called unconditionally and their *results* are gated: React's\n // hook count must stay fixed across renders.\n const declaredHeaderUseCases = useCasesForSurface(\n 'form-header',\n metadata?.useCases,\n verbForms,\n );\n const declaredFooterUseCases = useCasesForSurface(\n 'form-footer',\n metadata?.useCases,\n verbForms,\n );\n // And only the verbs the record's state allows: a shipment awaiting dispatch\n // offers Dispatch, not every move a shipment can ever make.\n const headerUseCases = onUseCase\n ? availableUseCases(declaredHeaderUseCases, entity)\n : [];\n const footerUseCases = onUseCase\n ? availableUseCases(declaredFooterUseCases, entity)\n : [];\n // A verb that moved its record out of the states it applies to unmounts the\n // button the reader just pressed; focus goes to the heading, not `<body>`.\n useFocusOnLoss(\n () => heading.current,\n [\n ...headerUseCases.map(({ key }) => key),\n ...footerUseCases.map(({ key }) => key),\n ...(frozen ? [] : ['save']),\n ].join(' '),\n );\n\n // Every verb on the form, and its own Delete, goes through one invoker: a\n // destructive verb asks, asks for the name, or runs and offers Undo, as it\n // declared — `revoke-sessions` ends every session a user holds.\n const verbs = useVerbInvoker<undefined>({\n run: key => (key === DELETE_KEY ? onDelete?.() : onUseCase?.(key)),\n busy,\n served: metadata?.useCases,\n });\n // What a confirmation names — the object in \"Delete {record}?\" and the text\n // the typed policy asks for — through the one derivation every surface\n // shares: the entity's `labelMember`, resolved if it is a reference.\n const metaEntity = extractMetaEntity(entityConstructor);\n const nameOf = useRecordLabel();\n const recordLabel = nameOf(entityConstructor, draft);\n const invoke = (descriptor: UseCaseDescriptor) =>\n verbs.invoke({\n descriptor,\n target: undefined,\n object: recordLabel,\n count: 1,\n });\n const requestDelete = () => {\n // Undo is the host's to offer: only it can put a deleted record back.\n if (deletePolicy === 'undo') {\n onDelete?.();\n return;\n }\n invoke({\n key: DELETE_KEY,\n binding: 'entity',\n placement: 'determining',\n labelKey: 'controls:form.delete',\n confirm: {\n tone: 'destructive',\n messageKey: 'controls:confirm.deleteMessage',\n },\n reversible: deletePolicy,\n });\n };\n\n const headerItems = itemsForUseCases(\n headerUseCases,\n translateKey,\n invoke,\n busy,\n );\n const footerItems = itemsForUseCases(\n footerUseCases,\n translateKey,\n invoke,\n busy,\n );\n /**\n * A save attempt. Counted, so a refused one moves focus to the error summary\n * once — not again on every keystroke that leaves an error standing.\n */\n const [attempt, setAttempt] = useState(0);\n const save = () => {\n setAttempt(current => current + 1);\n onSubmit?.(draft);\n };\n // A save refused because the record moved on. It is told apart by its code,\n // the one thing a failure decoded in a browser is sure to carry, and it is\n // not a retry: the fields keep what was typed and the person chooses.\n const conflicted = error?.code === 'staleRevision';\n // A save refused because a member declared `unique` holds a value another\n // record has (ADR 0034). The failure names the member's stored key, so it is\n // that field's error — next to what has to change — and not a banner.\n const duplicated =\n error?.code === 'duplicateKey'\n ? fields.find(field => field.key === (error as { key?: string }).key)\n : undefined;\n const fieldErrors =\n duplicated === undefined\n ? errors\n : {\n ...errors,\n [duplicated.name]: t('form.duplicateValue', {\n field: duplicated.label,\n }),\n };\n const conflict = useRef<HTMLDivElement>(null);\n useEffect(() => {\n // Focus moves to the explanation, so a keyboard or screen-reader user is\n // not left on a Save that silently did nothing.\n if (conflicted) conflict.current?.focus();\n }, [conflicted, error]);\n const summary = useRef<HTMLDivElement>(null);\n const summaryId = useId();\n const invalid = editing\n ? fields.filter(field => fieldErrors?.[field.name] !== undefined)\n : [];\n const focusedAttempt = useRef(0);\n useEffect(() => {\n if (attempt === focusedAttempt.current || invalid.length === 0) return;\n focusedAttempt.current = attempt;\n summary.current?.focus();\n }, [attempt, invalid.length]);\n\n // Save is the footer's primary unless the entity declared one of its own — a\n // determining \"Publish\" is what that page is for, and Save steps aside.\n const declaresFooterPrimary = footerItems.some(\n item => item.emphasis === 'primary',\n );\n const footerActions: ActionBarItem[] = [\n ...(may('write')\n ? [\n {\n key: 'save',\n // A pending write waits on the push stream; while that is down\n // it says so, rather than waiting without a word.\n label: isPending\n ? t(live.connection === 'open' ? 'form.pending' : 'live.waiting')\n : isSaving\n ? t('form.saving')\n : t('form.save'),\n emphasis: declaresFooterPrimary\n ? ('default' as const)\n : ('primary' as const),\n disabled: busy || resolvingLinks,\n submit: true,\n shortcut: SAVE_SHORTCUT,\n onSelect: save,\n },\n ]\n : []),\n // The page's main act answers Mod+Enter, unless it declared its own.\n ...footerItems.map(item =>\n item.emphasis === 'primary' && item.shortcut === undefined\n ? { ...item, shortcut: PRIMARY_SHORTCUT }\n : item,\n ),\n // Clone is the CRUD triple's, not a declared verb's: every entity can be\n // copied, so giving it a `@useCase()` would mean declaring the same verb on\n // all 28 of them. It needs `write`, because what it produces is a create.\n ...(onClone && entity && granted('write')\n ? [\n {\n key: 'clone',\n label: t('form.clone'),\n disabled: busy,\n onSelect: () => onClone(cloneEntityDraft(entityConstructor, draft)),\n },\n ]\n : []),\n ...(onDelete && may('delete')\n ? [\n {\n key: 'delete',\n label: isDeleting ? t('form.deleting') : t('form.delete'),\n destructive: true,\n disabled: busy,\n onSelect: requestDelete,\n },\n ]\n : []),\n ];\n\n // A real form while editing, so Enter in a field saves; an embedded one\n // belongs to its host's flow, and a caller who may not write has no Save.\n const asForm = editing && !embedded && may('write');\n // A member drawn only once set is left out of a record being read while it\n // is empty: an order awaiting payment is not thirty dashes. A custom read\n // display decides for itself.\n const shown = editing\n ? fields\n : fields.filter(\n field =>\n field.presentation !== 'whenSet' ||\n field.readRender !== undefined ||\n !isUnset(\n (entity as Record<string, unknown> | undefined)?.[field.name],\n ),\n );\n const rows = shown.map(field => (\n <FieldRow\n key={field.name}\n field={field}\n entity={entity}\n draft={draft}\n value={readDraftString(draft, field.name)}\n editing={editing}\n error={editing ? fieldErrors?.[field.name] : undefined}\n setField={setField}\n linkSource={linkSources?.[field.name]}\n onLinkChange={onLinkChange}\n id={`${formId}-${field.name}`}\n />\n ));\n\n const body = (\n <Stack gap=\"s\">\n {/* An embedded form brings only its fields: the heading and the action\n row belong to whatever is hosting it — a wizard step sits under the\n wizard's own heading and advances with the wizard's own footer, so\n rendering a second of each is two controls for one job. */}\n {!embedded && (\n <Stack direction=\"row\" gap=\"xs\" align=\"center\">\n <Text\n as=\"h2\"\n ref={heading}\n tabIndex={-1}\n step={1}\n weight=\"semibold\"\n className=\"focus-ring\"\n >\n {/* `entity` is undefined while the record is still in flight, so\n testing it alone made a loading edit form announce itself as\n \"New\" for as long as the fetch took, then relabel when the\n record landed. A form that is loading is never a create. */}\n {title ?? (entity || isLoading ? t('form.details') : t('form.new'))}\n </Text>\n {/* The built-in toggle only appears when the form owns its mode and\n there is a record to view — a create form has nothing to read. */}\n {modeProp === undefined && entity && !frozen && (\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n onClick={toggleMode}\n >\n {editing ? t('form.view') : t('form.edit')}\n </Button>\n )}\n <LoadingBoundary isLoading={isMetadataLoading} lines={0}>\n <>\n {headerItems.length > 0 && (\n <ActionBar surface=\"form-header\" items={headerItems} />\n )}\n {slots.headerActions}\n </>\n </LoadingBoundary>\n </Stack>\n )}\n\n {/* Why the form takes no input, said once at its top as a status rather\n than an error: nothing went wrong, the record has moved on. */}\n {frozen && metadata.readOnlyReasonKey !== undefined && (\n <Alert tone=\"info\" data-testid=\"entity-form-read-only\">\n {translateKey(metadata.readOnlyReasonKey)}\n </Alert>\n )}\n\n {/* One announcement for the form; the shimmer below is aria-hidden. */}\n <span role=\"status\" aria-live=\"polite\" className=\"sr-only\">\n {isLoading ? t('form.loading') : ''}\n </span>\n\n {conflicted && (\n <div\n ref={conflict}\n tabIndex={-1}\n data-testid=\"entity-form-conflict\"\n className=\"rounded-lg focus-ring\"\n >\n <Alert\n tone=\"danger\"\n title={t('form.conflictTitle')}\n action={\n onKeepMine === undefined &&\n onLoadCurrent === undefined ? undefined : (\n <span className=\"flex flex-wrap gap-3xs\">\n {onKeepMine !== undefined && (\n <Button\n type=\"button\"\n variant=\"primary\"\n size=\"sm\"\n onClick={onKeepMine}\n >\n {t('form.conflictKeep')}\n </Button>\n )}\n {onLoadCurrent !== undefined && (\n <Button\n type=\"button\"\n variant=\"secondary\"\n size=\"sm\"\n onClick={onLoadCurrent}\n >\n {t('form.conflictLoad')}\n </Button>\n )}\n </span>\n )\n }\n >\n {t('form.conflictBody')}\n {onKeepMine !== undefined && ` ${t('form.conflictKeepHint')}`}\n </Alert>\n </div>\n )}\n\n <RegionState\n plural={entityNoun(metaEntity, 'plural')}\n error={conflicted || duplicated !== undefined ? undefined : error}\n onRetry={onRetry}\n // Only a load that can be retried leaves an out-of-date record; a\n // failed save leaves what the reader typed, which is current.\n hasStaleData={entity !== undefined && onRetry !== undefined}\n />\n\n {/* A refused save, as one summary of links to what needs fixing: the\n only alert in the form, and where focus goes after the attempt. */}\n {invalid.length > 0 && (\n <div\n ref={summary}\n tabIndex={-1}\n role=\"alert\"\n aria-labelledby={summaryId}\n data-testid=\"entity-form-error-summary\"\n className=\"rounded-lg border-l-4 border-danger bg-danger-subtle px-s py-xs text-step-sm text-content focus-ring\"\n >\n <p id={summaryId} className=\"m-0 font-semibold\">\n {t('form.errorSummary', { count: invalid.length })}\n </p>\n <ul className=\"m-0 ps-s\">\n {invalid.map(field => (\n <li key={field.name}>\n <a\n href={`#${formId}-${field.name}`}\n // The content colour: primary on the danger surface misses\n // 4.5:1.\n className=\"font-medium text-content underline underline-offset-2 focus-ring\"\n onClick={event => {\n event.preventDefault();\n document.getElementById(`${formId}-${field.name}`)?.focus();\n }}\n >\n {fieldErrors?.[field.name]}\n </a>\n </li>\n ))}\n </ul>\n </div>\n )}\n\n {editing && fields.some(field => field.required && !field.readonly) && (\n <Text step={-1} tone=\"muted\">\n {t('form.requiredHint')}\n </Text>\n )}\n\n {/* The placeholder *replaces* the rows rather than sitting above them.\n Rendering both meant a shimmer stacked on a full set of empty fields,\n which is two loading signals for one region and twice the height the\n loaded form settles at. */}\n {showSkeleton\n ? (customSkeleton ??\n fields.map(field => (\n <Stack key={field.name} gap=\"3xs\">\n <Skeleton shape=\"line\" className=\"w-24\" />\n <Skeleton className=\"h-9 w-full\" />\n </Stack>\n )))\n : editing\n ? rows\n : // Read mode is a description list: a label points at nothing\n // when there is no control, and a term and its value is what\n // the pair is.\n rows.length > 0 && (\n <dl className=\"m-0 flex flex-col gap-s\">{rows}</dl>\n )}\n\n {/* The rows the record owns, full width and below every field. Each\n grid is handed the *whole* error map and picks out the keys naming\n its own member, so a record owning two collections needs no\n bookkeeping here. */}\n {ownedCollections.map(field => (\n <EntityDetailGrid\n key={field.name}\n descriptor={field}\n rows={readRowDrafts(draft[field.name])}\n onRowsChange={rows => setField(field.name, rows)}\n errors={editing ? errors : undefined}\n editing={editing}\n isLoading={isLoading}\n skeleton={skeleton}\n />\n ))}\n\n {/* A cross-field rule has no row to sit under, so it sits with the\n actions it blocks. */}\n {editing && formError && (\n <span role=\"alert\" className=\"text-step-sm text-danger\">\n {formError}\n </span>\n )}\n\n {/* A record read because its state allows no save keeps its footer:\n the verbs it does allow — a New version — live there, without Save\n and Delete. A form the reader toggled to View has none. */}\n {(editing || frozen) && !embedded && (\n <Stack direction=\"row\" gap=\"xs\" align=\"center\">\n <ActionBar surface=\"form-footer\" size=\"md\" items={footerActions} />\n {slots.footerActions}\n {/* A link styled as a button, not a button inside a link: the old\n nesting was two interactive elements for one action, and its\n `disabled` stopped nothing, because the anchor around it still\n navigated. While busy the link is inert instead. */}\n {backHref &&\n renderLink({\n href: backHref,\n className: cn(\n button({ variant: 'ghost' }),\n busy && 'pointer-events-none opacity-50',\n ),\n children: t('form.back'),\n intent: { kind: 'back' },\n })}\n </Stack>\n )}\n\n {slots.rest}\n </Stack>\n );\n\n return (\n <Card>\n {asForm ? (\n <form\n noValidate\n // Enter submits through Save, the form's default button, which is\n // disabled while a save is in flight — so a busy form stays put.\n onSubmit={event => {\n event.preventDefault();\n save();\n }}\n >\n {body}\n </form>\n ) : (\n body\n )}\n\n {verbs.dialog}\n </Card>\n );\n}\n\n/** Nothing to read: no value, an empty text, or an empty collection. */\nfunction isUnset(value: unknown): boolean {\n return (\n value === undefined ||\n value === null ||\n value === '' ||\n (Array.isArray(value) && value.length === 0)\n );\n}\n\n/**\n * A member the detail grid renders rather than the field stack.\n *\n * The `childType` half is not defensive: a `composition` that declared no child\n * has no columns, so there is nothing for a grid to draw. It keeps its place in\n * the field stack and reads as its row count, which is what it did before this\n * control existed — an honest \"some rows\" rather than an empty table implying\n * there are none.\n */\nfunction isOwnedCollection<TEntity extends Entity>(\n field: EntityFormField<TEntity>,\n): boolean {\n return field.type === 'composition' && field.childType !== undefined;\n}\n\n/**\n * Refuse a `linkSources` entry that names a member no picker can be built for.\n *\n * `FieldRow` asks for {@link PICKABLE_TYPES} before it builds an editor, so a\n * source handed to anything else used to fall through to the read-only display\n * or a plain `FieldControl` with nothing said: the caller wired a picker, no\n * picker appeared, and the field was indistinguishable from one the entity had\n * declared read-only. That is a wiring mistake rather than a state — the entry\n * is dead in *every* shape such a field can render, since an\n * `<EntityField render>` slot is handed the draft and never the source — so it\n * costs the render instead of a warning nobody reads. `useEntityLinkSource`\n * already throws at render for the sibling mistake (a search\n * property the target does not declare `filterable`); this is the same fault\n * caught one level up.\n *\n * Two messages, because the two faults are not the same thing. A\n * `linkCollection` is a member the editor has simply not been built for yet\n * (#26), so the fix is to wait or to point at the to-one you meant. Any other\n * type is a member that can never name another record at all, so the fix is to\n * remove the entry.\n *\n * Here rather than inside `FieldRow`, and that is the whole reason it is a\n * separate pass: a row only reaches its editor branch in **edit** mode, so a\n * per-row check would stay silent on a form that opens in `read` — the default\n * whenever there is a record — and then throw on a click, minutes later. One\n * pass over the registry fires on the first render either way.\n *\n * Against the resolved fields rather than the raw metadata: a slot may drop a\n * member, and a source left behind for a field that no longer renders is not\n * worth a page.\n */\nfunction assertLinkSourcesAreEditable<TEntity extends Entity>(\n fields: Array<EntityFormField<TEntity>>,\n // Same reason as the prop's own declaration: a source's target is another\n // entity entirely and cannot be expressed in terms of `TEntity`.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n linkSources: Record<string, EntityLinkSource<any>> | undefined,\n): void {\n if (linkSources === undefined) return;\n\n const sourced = fields.filter(\n field =>\n linkSources[field.name] !== undefined &&\n !PICKABLE_TYPES.has(field.type) &&\n !isReferenceList(field),\n );\n if (sourced.length === 0) return;\n\n const toMany = sourced\n .filter(field => field.type === 'linkCollection')\n .map(field => field.name);\n if (toMany.length > 0) {\n throw new Error(\n `EntityForm was given a link source for a to-many member: ${toMany.join(', ')}. ` +\n 'A `linkCollection` has no editor yet, so the source can only be dropped ' +\n 'and the field would render read-only with no sign anything was wired. ' +\n 'Remove the entry, or point it at the to-one `link` you meant.',\n );\n }\n\n const owned = sourced\n .filter(field => field.type === 'composition')\n .map(field => field.name);\n if (owned.length > 0) {\n throw new Error(\n `EntityForm was given a link source for an owned collection: ${owned.join(', ')}. ` +\n 'A `composition` is not a reference — its rows have no life outside this ' +\n 'record and are never picked from existing ones, so there is nothing for a ' +\n 'picker to look up. The detail grid is what edits them.',\n );\n }\n\n const unpickable = sourced.map(field => `${field.name} (${field.type})`);\n throw new Error(\n `EntityForm was given a link source for a member that cannot hold one: ${unpickable.join(', ')}. ` +\n 'A picker writes the target’s id into the draft, so the member has to be a ' +\n '`link`, the `string` that carries a foreign key, or a `scalarCollection` ' +\n 'that declares `references`. Remove the entry, or point it at the member ' +\n 'that actually holds the reference.',\n );\n}\n\ninterface FieldRowProps<TEntity extends Entity> {\n field: EntityFormField<TEntity>;\n entity: TEntity | undefined;\n draft: EntityDraft;\n value: string;\n editing: boolean;\n error: string | undefined;\n setField: (name: string, value: EntityDraftValue) => void;\n // The target of a relation is a different entity than the form's own.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n linkSource: EntityLinkSource<any> | undefined;\n onLinkChange:\n ((name: string, entity: Entity | undefined) => void) | undefined;\n id: string;\n}\n\n/**\n * One label + control (or value) row. A `readonly` member renders its read\n * display even in edit mode, and so does a relation with no source; everything\n * else edits through `FieldControl` — or, when a source was supplied for a\n * member in {@link PICKABLE_TYPES}, through `EntityLinkInput`. A boolean edited\n * inline carries its own label, so the row does not add a second one.\n *\n * The source branch sits above the `virtual || isRelation` fallback and below\n * `field.render`, which is what lets a slot still override a picked field.\n */\nfunction FieldRow<TEntity extends Entity>({\n field,\n entity,\n draft,\n value,\n editing,\n error,\n setField,\n linkSource,\n onLinkChange,\n id,\n}: FieldRowProps<TEntity>) {\n const t = useT();\n const errorId = `${id}-error`;\n const readNode: ReactNode = field.readRender ? (\n field.readRender(entity)\n ) : (\n <CellValue\n value={\n entity ? (entity as Record<string, unknown>)[field.name] : undefined\n }\n descriptor={field}\n record={entity as Record<string, unknown> | undefined}\n />\n );\n\n // Members with no editor of their own here: a to-one `link` whose picker was\n // never wired, a `linkCollection` (#26) and a `composition`. All three\n // fall back to the read display, which is honest — a disabled text box\n // holding `[object Object]` is not.\n const isRelation =\n field.type === 'link' ||\n field.type === 'linkCollection' ||\n field.type === 'composition';\n\n let control: ReactNode;\n if (!editing) {\n control = readNode;\n } else if (field.render) {\n control = field.render({ draft, value, setField, id });\n } else if (linkSource && isReferenceList(field)) {\n control = (\n <EntityLinkMultiInput\n descriptor={field}\n value={value}\n source={linkSource}\n id={id}\n disabled={field.readonly}\n onChange={next => setField(field.name, next)}\n />\n );\n } else if (linkSource && PICKABLE_TYPES.has(field.type)) {\n control = (\n <EntityLinkInput\n descriptor={field}\n value={value}\n source={linkSource}\n id={id}\n disabled={field.readonly}\n onSelect={target => {\n setField(field.name, target.id == null ? '' : String(target.id));\n onLinkChange?.(field.name, target);\n }}\n onClear={() => {\n setField(field.name, '');\n onLinkChange?.(field.name, undefined);\n }}\n />\n );\n } else if (field.type === 'localized' && !field.virtual) {\n control = (\n <LocalizedFieldControl\n descriptor={field}\n value={readLocalizedDraft(draft, field.name)}\n onChange={next => setField(field.name, next)}\n id={id}\n />\n );\n } else if (field.virtual || isRelation) {\n // A relation with no source has no input to offer, and a virtual field has\n // no member to edit unless a `render` was supplied — both fall back to the\n // read display.\n control = readNode;\n } else {\n control = (\n <FieldControl\n descriptor={field}\n value={value}\n onChange={next => setField(field.name, next)}\n id={id}\n record={draft}\n aria-invalid={error !== undefined || undefined}\n aria-describedby={error === undefined ? undefined : errorId}\n aria-required={field.required || undefined}\n />\n );\n }\n\n if (!editing)\n return (\n <div className=\"flex flex-col gap-3xs\">\n <dt className=\"text-step-sm text-content-muted\">{field.label}</dt>\n <dd className=\"m-0\">{control}</dd>\n </div>\n );\n\n const ownsLabel = field.type === 'boolean' && !field.render && !field.virtual;\n // Marked before anyone submits, not discovered after.\n const marked = field.required && !field.readonly;\n\n return (\n <Stack gap=\"3xs\">\n {!ownsLabel && (\n // The marker sits beside the label, not in it: the name stays the\n // field's own, and `aria-required` is what says it to a reader.\n <span className=\"flex items-baseline gap-3xs\">\n <label htmlFor={id} className=\"text-step-sm text-content-muted\">\n {field.label}\n </label>\n {marked && (\n <span aria-hidden=\"true\" className=\"text-step-sm text-danger\">\n {t('form.requiredMarker')}\n </span>\n )}\n </span>\n )}\n {control}\n {/* Not an alert of its own: the summary above the fields is the one\n announcement, and this is what the control's description reads. */}\n {error && (\n <span id={errorId} className=\"text-step-sm text-danger\">\n {error}\n </span>\n )}\n </Stack>\n );\n}\n"],"names":["cloneEntityDraft","describeEntityColumns","extractMetaEntity","isRecordDeletable","isRecordWritable","readDraftString","readLocalizedDraft","readRowDrafts","useEffect","useId","useRef","useState","useEntityNoun","useLocalizedDescriptors","useT","useTranslateKey","availableUseCases","renderAnchor","useCasesForSurface","useVerbInvoker","Alert","Button","button","CellValue","useRecordLabel","FieldControl","LocalizedFieldControl","Skeleton","Text","ActionBar","itemsForUseCases","Card","EntityLinkInput","EntityLinkMultiInput","LoadingBoundary","RegionState","Stack","cn","useLiveUpdates","useFocusOnArrival","useFocusOnLoss","EntityDetailGrid","readEntityFormFields","resolveEntityFormFields","PICKABLE_TYPES","Set","isReferenceList","field","type","references","undefined","DELETE_KEY","SAVE_SHORTCUT","PRIMARY_SHORTCUT","EntityForm","entityConstructor","entity","values","onFieldChange","linkSources","onLinkChange","mode","modeProp","defaultMode","onModeChange","errors","formError","onSubmit","onDelete","deletePolicy","embedded","isLoading","skeleton","isSaving","isPending","isDeleting","error","onRetry","onKeepMine","onLoadCurrent","backHref","renderLink","title","metadata","isMetadataLoading","onUseCase","verbForms","onClone","children","formId","slots","columnDescriptors","filter","descriptor","presentation","described","resolved","fields","assertLinkSourcesAreEditable","isOwnedCollection","ownedCollections","customSkeleton","showSkeleton","internalMode","setInternalMode","frozen","undeletable","editing","draft","setField","name","value","toggleMode","next","t","translateKey","entityNoun","live","heading","busy","resolvingLinks","Object","some","source","selected","granted","action","actions","includes","may","declaredHeaderUseCases","useCases","declaredFooterUseCases","headerUseCases","footerUseCases","current","map","key","join","verbs","run","served","metaEntity","nameOf","recordLabel","invoke","target","object","count","requestDelete","binding","placement","labelKey","confirm","tone","messageKey","reversible","headerItems","footerItems","attempt","setAttempt","save","conflicted","code","duplicated","find","fieldErrors","label","conflict","focus","summary","summaryId","invalid","focusedAttempt","length","declaresFooterPrimary","item","emphasis","footerActions","connection","disabled","submit","shortcut","onSelect","destructive","asForm","shown","readRender","isUnset","rows","FieldRow","linkSource","id","body","gap","direction","align","as","ref","tabIndex","step","weight","className","variant","size","onClick","lines","surface","items","headerActions","readOnlyReasonKey","data-testid","span","role","aria-live","div","plural","hasStaleData","aria-labelledby","p","ul","li","a","href","event","document","preventDefault","getElementById","required","readonly","shape","dl","onRowsChange","intent","kind","rest","form","noValidate","dialog","Array","isArray","childType","sourced","has","toMany","Error","owned","unpickable","errorId","readNode","record","isRelation","control","render","onChange","String","onClear","virtual","aria-invalid","aria-describedby","aria-required","dt","dd","ownsLabel","marked","htmlFor","aria-hidden"],"mappings":"AAAA;;;AAEA,SACEA,gBAAgB,EAChBC,qBAAqB,EAOrBC,iBAAiB,EACjBC,iBAAiB,EACjBC,gBAAgB,EAEhBC,eAAe,EACfC,kBAAkB,EAClBC,aAAa,QAER,gBAAgB;AACvB,SAAyBC,SAAS,EAAEC,KAAK,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAE3E,SACEC,aAAa,EACbC,uBAAuB,EACvBC,IAAI,EACJC,eAAe,QACV,yBAAyB;AAChC,SACEC,iBAAiB,EACjBC,YAAY,EACZC,kBAAkB,QACb,yBAAyB;AAChC,SAASC,cAAc,QAAQ,oCAAoC;AACnE,SAASC,KAAK,QAAQ,6BAA6B;AACnD,SAASC,MAAM,EAAEC,MAAM,QAAQ,8BAA8B;AAC7D,SAASC,SAAS,EAAEC,cAAc,QAAQ,kCAAkC;AAC5E,SAASC,YAAY,QAAQ,qCAAqC;AAClE,SA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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.20"
|
|
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.8",
|
|
58
|
-
"@entifix/i18n": "0.23.
|
|
59
|
-
"@entifix/style": "0.23.
|
|
58
|
+
"@entifix/i18n": "0.23.20",
|
|
59
|
+
"@entifix/style": "0.23.20"
|
|
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.20"
|
|
115
115
|
},
|
|
116
116
|
"peerDependenciesMeta": {
|
|
117
117
|
"@entifix/i18n": {
|