@entifix/react-controls 0.18.2 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -5
- package/dist/i18n/catalog/en.d.ts.map +1 -1
- package/dist/i18n/catalog/en.js +68 -10
- package/dist/i18n/catalog/en.js.map +1 -1
- package/dist/i18n/catalog/es.d.ts +76 -5
- package/dist/i18n/catalog/es.d.ts.map +1 -1
- package/dist/i18n/catalog/es.js +74 -10
- package/dist/i18n/catalog/es.js.map +1 -1
- package/dist/i18n/catalog/index.d.ts +126 -10
- package/dist/i18n/catalog/index.d.ts.map +1 -1
- package/dist/i18n/entity-labels.d.ts +14 -0
- package/dist/i18n/entity-labels.d.ts.map +1 -1
- package/dist/i18n/entity-labels.js +15 -0
- package/dist/i18n/entity-labels.js.map +1 -1
- package/dist/i18n/i18n-context.js +2 -2
- package/dist/i18n/i18n-context.js.map +1 -1
- package/dist/index.d.ts +13 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -2
- package/dist/index.js.map +1 -1
- package/dist/primitives.d.ts +7 -1
- package/dist/primitives.d.ts.map +1 -1
- package/dist/primitives.js +7 -1
- package/dist/primitives.js.map +1 -1
- package/dist/theme/index.d.ts +1 -0
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +1 -0
- package/dist/theme/index.js.map +1 -1
- package/dist/theme/theme-context.d.ts +35 -7
- package/dist/theme/theme-context.d.ts.map +1 -1
- package/dist/theme/theme-context.js +109 -21
- package/dist/theme/theme-context.js.map +1 -1
- package/dist/theme/theme-cookie.d.ts +9 -0
- package/dist/theme/theme-cookie.d.ts.map +1 -0
- package/dist/theme/theme-cookie.js +8 -0
- package/dist/theme/theme-cookie.js.map +1 -0
- package/dist/theme/theme-script.d.ts +8 -5
- package/dist/theme/theme-script.d.ts.map +1 -1
- package/dist/theme/theme-script.js +24 -10
- package/dist/theme/theme-script.js.map +1 -1
- package/dist/theme/types.d.ts +19 -3
- package/dist/theme/types.d.ts.map +1 -1
- package/dist/theme/types.js.map +1 -1
- package/dist/ui/actions/action-surfaces.d.ts +1 -1
- package/dist/ui/actions/action-surfaces.js +1 -1
- package/dist/ui/actions/action-surfaces.js.map +1 -1
- package/dist/ui/actions/error-actions.d.ts +32 -0
- package/dist/ui/actions/error-actions.d.ts.map +1 -0
- package/dist/ui/actions/error-actions.js +40 -0
- package/dist/ui/actions/error-actions.js.map +1 -0
- package/dist/ui/actions/index.d.ts +2 -0
- package/dist/ui/actions/index.d.ts.map +1 -1
- package/dist/ui/actions/index.js +2 -0
- package/dist/ui/actions/index.js.map +1 -1
- package/dist/ui/actions/shortcut.d.ts +13 -0
- package/dist/ui/actions/shortcut.d.ts.map +1 -0
- package/dist/ui/actions/shortcut.js +18 -0
- package/dist/ui/actions/shortcut.js.map +1 -0
- package/dist/ui/actions/use-verb-invoker.d.ts +50 -0
- package/dist/ui/actions/use-verb-invoker.d.ts.map +1 -0
- package/dist/ui/actions/use-verb-invoker.js +93 -0
- package/dist/ui/actions/use-verb-invoker.js.map +1 -0
- package/dist/ui/atoms/alert/alert-dismiss.d.ts +9 -0
- package/dist/ui/atoms/alert/alert-dismiss.d.ts.map +1 -0
- package/dist/ui/atoms/alert/alert-dismiss.js +28 -0
- package/dist/ui/atoms/alert/alert-dismiss.js.map +1 -0
- package/dist/ui/atoms/alert/alert.d.ts +24 -0
- package/dist/ui/atoms/alert/alert.d.ts.map +1 -0
- package/dist/ui/atoms/alert/alert.js +50 -0
- package/dist/ui/atoms/alert/alert.js.map +1 -0
- package/dist/ui/atoms/alert/index.d.ts +3 -0
- package/dist/ui/atoms/alert/index.d.ts.map +1 -0
- package/dist/ui/atoms/alert/index.js +4 -0
- package/dist/ui/atoms/alert/index.js.map +1 -0
- package/dist/ui/atoms/alert/tone.d.ts +8 -0
- package/dist/ui/atoms/alert/tone.d.ts.map +1 -0
- package/dist/ui/atoms/alert/tone.js +11 -0
- package/dist/ui/atoms/alert/tone.js.map +1 -0
- package/dist/ui/atoms/button/button-recipe.js +1 -1
- package/dist/ui/atoms/button/button-recipe.js.map +1 -1
- package/dist/ui/atoms/button/index.d.ts +1 -0
- package/dist/ui/atoms/button/index.d.ts.map +1 -1
- package/dist/ui/atoms/button/index.js +1 -0
- package/dist/ui/atoms/button/index.js.map +1 -1
- package/dist/ui/atoms/button/submit-button.d.ts +13 -0
- package/dist/ui/atoms/button/submit-button.d.ts.map +1 -0
- package/dist/ui/atoms/button/submit-button.js +29 -0
- package/dist/ui/atoms/button/submit-button.js.map +1 -0
- package/dist/ui/atoms/cell-value/cell-value.d.ts +6 -1
- package/dist/ui/atoms/cell-value/cell-value.d.ts.map +1 -1
- package/dist/ui/atoms/cell-value/cell-value.js +48 -16
- package/dist/ui/atoms/cell-value/cell-value.js.map +1 -1
- package/dist/ui/atoms/field/checkbox.d.ts.map +1 -1
- package/dist/ui/atoms/field/checkbox.js +21 -1
- package/dist/ui/atoms/field/checkbox.js.map +1 -1
- package/dist/ui/atoms/field/field.js +1 -1
- package/dist/ui/atoms/field/field.js.map +1 -1
- package/dist/ui/atoms/field-control/field-control.d.ts +7 -1
- package/dist/ui/atoms/field-control/field-control.d.ts.map +1 -1
- package/dist/ui/atoms/field-control/field-control.js +25 -3
- package/dist/ui/atoms/field-control/field-control.js.map +1 -1
- package/dist/ui/atoms/money/index.d.ts +4 -0
- package/dist/ui/atoms/money/index.d.ts.map +1 -0
- package/dist/ui/atoms/money/index.js +5 -0
- package/dist/ui/atoms/money/index.js.map +1 -0
- package/dist/ui/atoms/money/money-input.d.ts +19 -0
- package/dist/ui/atoms/money/money-input.d.ts.map +1 -0
- package/dist/ui/atoms/money/money-input.js +75 -0
- package/dist/ui/atoms/money/money-input.js.map +1 -0
- package/dist/ui/atoms/money/money-math.d.ts +21 -0
- package/dist/ui/atoms/money/money-math.d.ts.map +1 -0
- package/dist/ui/atoms/money/money-math.js +36 -0
- package/dist/ui/atoms/money/money-math.js.map +1 -0
- package/dist/ui/atoms/money/money.d.ts +19 -0
- package/dist/ui/atoms/money/money.d.ts.map +1 -0
- package/dist/ui/atoms/money/money.js +26 -0
- package/dist/ui/atoms/money/money.js.map +1 -0
- package/dist/ui/atoms/number-input/index.d.ts +3 -0
- package/dist/ui/atoms/number-input/index.d.ts.map +1 -0
- package/dist/ui/atoms/number-input/index.js +4 -0
- package/dist/ui/atoms/number-input/index.js.map +1 -0
- package/dist/ui/atoms/number-input/number-input.d.ts +10 -0
- package/dist/ui/atoms/number-input/number-input.d.ts.map +1 -0
- package/dist/ui/atoms/number-input/number-input.js +23 -0
- package/dist/ui/atoms/number-input/number-input.js.map +1 -0
- package/dist/ui/atoms/number-input/quantity-input.d.ts +29 -0
- package/dist/ui/atoms/number-input/quantity-input.d.ts.map +1 -0
- package/dist/ui/atoms/number-input/quantity-input.js +100 -0
- package/dist/ui/atoms/number-input/quantity-input.js.map +1 -0
- package/dist/ui/atoms/skeleton/skeleton.js +1 -1
- package/dist/ui/atoms/skeleton/skeleton.js.map +1 -1
- package/dist/ui/atoms/status-tag/index.d.ts +2 -0
- package/dist/ui/atoms/status-tag/index.d.ts.map +1 -0
- package/dist/ui/atoms/status-tag/index.js +3 -0
- package/dist/ui/atoms/status-tag/index.js.map +1 -0
- package/dist/ui/atoms/status-tag/status-tag.d.ts +17 -0
- package/dist/ui/atoms/status-tag/status-tag.d.ts.map +1 -0
- package/dist/ui/atoms/status-tag/status-tag.js +37 -0
- package/dist/ui/atoms/status-tag/status-tag.js.map +1 -0
- package/dist/ui/atoms/switch/switch.d.ts.map +1 -1
- package/dist/ui/atoms/switch/switch.js +6 -3
- package/dist/ui/atoms/switch/switch.js.map +1 -1
- package/dist/ui/atoms/table/table.d.ts +12 -3
- package/dist/ui/atoms/table/table.d.ts.map +1 -1
- package/dist/ui/atoms/table/table.js +59 -10
- package/dist/ui/atoms/table/table.js.map +1 -1
- package/dist/ui/atoms/text/text.d.ts +2 -2
- package/dist/ui/atoms/text/text.d.ts.map +1 -1
- package/dist/ui/atoms/text/text.js.map +1 -1
- package/dist/ui/molecules/action-bar/action-bar.d.ts +76 -0
- package/dist/ui/molecules/action-bar/action-bar.d.ts.map +1 -0
- package/dist/ui/molecules/action-bar/action-bar.js +218 -0
- package/dist/ui/molecules/action-bar/action-bar.js.map +1 -0
- package/dist/ui/molecules/action-bar/index.d.ts +2 -0
- package/dist/ui/molecules/action-bar/index.d.ts.map +1 -0
- package/dist/ui/molecules/action-bar/index.js +3 -0
- package/dist/ui/molecules/action-bar/index.js.map +1 -0
- package/dist/ui/molecules/breadcrumbs/breadcrumbs.d.ts +11 -2
- package/dist/ui/molecules/breadcrumbs/breadcrumbs.d.ts.map +1 -1
- package/dist/ui/molecules/breadcrumbs/breadcrumbs.js +9 -7
- package/dist/ui/molecules/breadcrumbs/breadcrumbs.js.map +1 -1
- package/dist/ui/molecules/bulk-action-bar/bulk-action-bar.d.ts.map +1 -1
- package/dist/ui/molecules/bulk-action-bar/bulk-action-bar.js +8 -10
- package/dist/ui/molecules/bulk-action-bar/bulk-action-bar.js.map +1 -1
- package/dist/ui/molecules/bulk-result/bulk-result.d.ts +3 -3
- package/dist/ui/molecules/bulk-result/bulk-result.js +4 -4
- package/dist/ui/molecules/bulk-result/bulk-result.js.map +1 -1
- package/dist/ui/molecules/column-settings/column-settings.js +1 -1
- package/dist/ui/molecules/column-settings/column-settings.js.map +1 -1
- package/dist/ui/molecules/confirm-dialog/confirm-dialog.d.ts +24 -9
- package/dist/ui/molecules/confirm-dialog/confirm-dialog.d.ts.map +1 -1
- package/dist/ui/molecules/confirm-dialog/confirm-dialog.js +38 -13
- package/dist/ui/molecules/confirm-dialog/confirm-dialog.js.map +1 -1
- package/dist/ui/molecules/description-list/description-list.d.ts +17 -0
- package/dist/ui/molecules/description-list/description-list.d.ts.map +1 -0
- package/dist/ui/molecules/description-list/description-list.js +36 -0
- package/dist/ui/molecules/description-list/description-list.js.map +1 -0
- package/dist/ui/molecules/description-list/index.d.ts +2 -0
- package/dist/ui/molecules/description-list/index.d.ts.map +1 -0
- package/dist/ui/molecules/description-list/index.js +3 -0
- package/dist/ui/molecules/description-list/index.js.map +1 -0
- package/dist/ui/molecules/drawer/drawer.js +3 -3
- package/dist/ui/molecules/drawer/drawer.js.map +1 -1
- package/dist/ui/molecules/empty-state/empty-state.d.ts +15 -0
- package/dist/ui/molecules/empty-state/empty-state.d.ts.map +1 -0
- package/dist/ui/molecules/empty-state/empty-state.js +29 -0
- package/dist/ui/molecules/empty-state/empty-state.js.map +1 -0
- package/dist/ui/molecules/empty-state/index.d.ts +2 -0
- package/dist/ui/molecules/empty-state/index.d.ts.map +1 -0
- package/dist/ui/molecules/empty-state/index.js +3 -0
- package/dist/ui/molecules/empty-state/index.js.map +1 -0
- package/dist/ui/molecules/entity-link-input/entity-link-input.d.ts.map +1 -1
- package/dist/ui/molecules/entity-link-input/entity-link-input.js +7 -4
- package/dist/ui/molecules/entity-link-input/entity-link-input.js.map +1 -1
- package/dist/ui/molecules/entity-link-picker/entity-link-picker.js +2 -2
- package/dist/ui/molecules/entity-link-picker/entity-link-picker.js.map +1 -1
- package/dist/ui/molecules/entity-record-card/entity-record-card.d.ts +33 -20
- package/dist/ui/molecules/entity-record-card/entity-record-card.d.ts.map +1 -1
- package/dist/ui/molecules/entity-record-card/entity-record-card.js +53 -20
- package/dist/ui/molecules/entity-record-card/entity-record-card.js.map +1 -1
- package/dist/ui/molecules/filter-builder/filter-builder.d.ts +8 -2
- package/dist/ui/molecules/filter-builder/filter-builder.d.ts.map +1 -1
- package/dist/ui/molecules/filter-builder/filter-builder.js +14 -5
- package/dist/ui/molecules/filter-builder/filter-builder.js.map +1 -1
- package/dist/ui/molecules/filter-chips/filter-chips.d.ts +16 -0
- package/dist/ui/molecules/filter-chips/filter-chips.d.ts.map +1 -0
- package/dist/ui/molecules/filter-chips/filter-chips.js +73 -0
- package/dist/ui/molecules/filter-chips/filter-chips.js.map +1 -0
- package/dist/ui/molecules/filter-chips/index.d.ts +2 -0
- package/dist/ui/molecules/filter-chips/index.d.ts.map +1 -0
- package/dist/ui/molecules/filter-chips/index.js +3 -0
- package/dist/ui/molecules/filter-chips/index.js.map +1 -0
- package/dist/ui/molecules/media-gallery/index.d.ts +2 -0
- package/dist/ui/molecules/media-gallery/index.d.ts.map +1 -0
- package/dist/ui/molecules/media-gallery/index.js +3 -0
- package/dist/ui/molecules/media-gallery/index.js.map +1 -0
- package/dist/ui/molecules/media-gallery/media-gallery.d.ts +31 -0
- package/dist/ui/molecules/media-gallery/media-gallery.d.ts.map +1 -0
- package/dist/ui/molecules/media-gallery/media-gallery.js +64 -0
- package/dist/ui/molecules/media-gallery/media-gallery.js.map +1 -0
- package/dist/ui/molecules/menu/menu.d.ts +11 -1
- package/dist/ui/molecules/menu/menu.d.ts.map +1 -1
- package/dist/ui/molecules/menu/menu.js +68 -6
- package/dist/ui/molecules/menu/menu.js.map +1 -1
- package/dist/ui/molecules/nav-menu/nav-menu.js +4 -4
- package/dist/ui/molecules/nav-menu/nav-menu.js.map +1 -1
- package/dist/ui/molecules/pagination/pagination.d.ts +5 -0
- package/dist/ui/molecules/pagination/pagination.d.ts.map +1 -1
- package/dist/ui/molecules/pagination/pagination.js +35 -18
- package/dist/ui/molecules/pagination/pagination.js.map +1 -1
- package/dist/ui/molecules/region-state/index.d.ts +2 -0
- package/dist/ui/molecules/region-state/index.d.ts.map +1 -0
- package/dist/ui/molecules/region-state/index.js +3 -0
- package/dist/ui/molecules/region-state/index.js.map +1 -0
- package/dist/ui/molecules/region-state/region-state.d.ts +42 -0
- package/dist/ui/molecules/region-state/region-state.d.ts.map +1 -0
- package/dist/ui/molecules/region-state/region-state.js +83 -0
- package/dist/ui/molecules/region-state/region-state.js.map +1 -0
- package/dist/ui/molecules/segmented-nav/segment-classes.d.ts +3 -3
- package/dist/ui/molecules/segmented-nav/segment-classes.d.ts.map +1 -1
- package/dist/ui/molecules/segmented-nav/segment-classes.js +2 -2
- package/dist/ui/molecules/segmented-nav/segment-classes.js.map +1 -1
- package/dist/ui/molecules/segmented-nav/segmented-nav.d.ts +14 -4
- package/dist/ui/molecules/segmented-nav/segmented-nav.d.ts.map +1 -1
- package/dist/ui/molecules/segmented-nav/segmented-nav.js +6 -5
- package/dist/ui/molecules/segmented-nav/segmented-nav.js.map +1 -1
- package/dist/ui/molecules/split-view/split-view.js +3 -3
- package/dist/ui/molecules/split-view/split-view.js.map +1 -1
- package/dist/ui/molecules/tab-strip/tab-strip.d.ts +51 -12
- package/dist/ui/molecules/tab-strip/tab-strip.d.ts.map +1 -1
- package/dist/ui/molecules/tab-strip/tab-strip.js +125 -34
- package/dist/ui/molecules/tab-strip/tab-strip.js.map +1 -1
- package/dist/ui/molecules/table-toolbar/table-toolbar.d.ts +3 -1
- package/dist/ui/molecules/table-toolbar/table-toolbar.d.ts.map +1 -1
- package/dist/ui/molecules/table-toolbar/table-toolbar.js +3 -2
- package/dist/ui/molecules/table-toolbar/table-toolbar.js.map +1 -1
- package/dist/ui/molecules/toast-region/toast-region.d.ts +63 -19
- package/dist/ui/molecules/toast-region/toast-region.d.ts.map +1 -1
- package/dist/ui/molecules/toast-region/toast-region.js +129 -42
- package/dist/ui/molecules/toast-region/toast-region.js.map +1 -1
- package/dist/ui/organisms/command-palette/command-palette.d.ts.map +1 -1
- package/dist/ui/organisms/command-palette/command-palette.js +25 -18
- package/dist/ui/organisms/command-palette/command-palette.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 +8 -3
- package/dist/ui/organisms/entity-detail-grid/entity-detail-grid.js.map +1 -1
- package/dist/ui/organisms/entity-form/entity-form.d.ts +1 -1
- package/dist/ui/organisms/entity-form/entity-form.d.ts.map +1 -1
- package/dist/ui/organisms/entity-form/entity-form.js +325 -215
- package/dist/ui/organisms/entity-form/entity-form.js.map +1 -1
- package/dist/ui/organisms/entity-form/entity-form.types.d.ts +8 -0
- package/dist/ui/organisms/entity-form/entity-form.types.d.ts.map +1 -1
- package/dist/ui/organisms/entity-form/entity-form.types.js.map +1 -1
- package/dist/ui/organisms/entity-table/entity-table.d.ts +1 -1
- package/dist/ui/organisms/entity-table/entity-table.d.ts.map +1 -1
- package/dist/ui/organisms/entity-table/entity-table.js +334 -198
- package/dist/ui/organisms/entity-table/entity-table.js.map +1 -1
- package/dist/ui/organisms/entity-table/entity-table.types.d.ts +19 -4
- package/dist/ui/organisms/entity-table/entity-table.types.d.ts.map +1 -1
- package/dist/ui/organisms/entity-table/entity-table.types.js.map +1 -1
- package/dist/ui/organisms/entity-table/header-sort.d.ts +18 -0
- package/dist/ui/organisms/entity-table/header-sort.d.ts.map +1 -0
- package/dist/ui/organisms/entity-table/header-sort.js +54 -0
- package/dist/ui/organisms/entity-table/header-sort.js.map +1 -0
- package/dist/ui/organisms/entity-table/pivot.d.ts +25 -0
- package/dist/ui/organisms/entity-table/pivot.d.ts.map +1 -0
- package/dist/ui/organisms/entity-table/pivot.js +106 -0
- package/dist/ui/organisms/entity-table/pivot.js.map +1 -0
- package/dist/ui/organisms/entity-table/use-result-announcement.d.ts +13 -0
- package/dist/ui/organisms/entity-table/use-result-announcement.d.ts.map +1 -0
- package/dist/ui/organisms/entity-table/use-result-announcement.js +31 -0
- package/dist/ui/organisms/entity-table/use-result-announcement.js.map +1 -0
- package/dist/ui/organisms/top-bar/live-indicator.d.ts +11 -0
- package/dist/ui/organisms/top-bar/live-indicator.d.ts.map +1 -0
- package/dist/ui/organisms/top-bar/live-indicator.js +46 -0
- package/dist/ui/organisms/top-bar/live-indicator.js.map +1 -0
- package/dist/ui/organisms/top-bar/top-bar.d.ts +11 -2
- package/dist/ui/organisms/top-bar/top-bar.d.ts.map +1 -1
- package/dist/ui/organisms/top-bar/top-bar.js +14 -5
- package/dist/ui/organisms/top-bar/top-bar.js.map +1 -1
- package/dist/ui/organisms/wizard/wizard.d.ts +1 -1
- package/dist/ui/organisms/wizard/wizard.d.ts.map +1 -1
- package/dist/ui/organisms/wizard/wizard.js +7 -1
- package/dist/ui/organisms/wizard/wizard.js.map +1 -1
- package/dist/ui/organisms/wizard/wizard.types.d.ts +8 -0
- package/dist/ui/organisms/wizard/wizard.types.d.ts.map +1 -1
- package/dist/ui/organisms/wizard/wizard.types.js.map +1 -1
- package/dist/ui/utils/live-updates.d.ts +24 -0
- package/dist/ui/utils/live-updates.d.ts.map +1 -0
- package/dist/ui/utils/live-updates.js +20 -0
- package/dist/ui/utils/live-updates.js.map +1 -0
- package/dist/ui/utils/use-focus-on-arrival.d.ts +14 -0
- package/dist/ui/utils/use-focus-on-arrival.d.ts.map +1 -0
- package/dist/ui/utils/use-focus-on-arrival.js +42 -0
- package/dist/ui/utils/use-focus-on-arrival.js.map +1 -0
- package/dist/ui/utils/use-hotkey.d.ts +44 -25
- package/dist/ui/utils/use-hotkey.d.ts.map +1 -1
- package/dist/ui/utils/use-hotkey.js +80 -48
- package/dist/ui/utils/use-hotkey.js.map +1 -1
- package/package.json +5 -5
- package/dist/ui/molecules/split-button/index.d.ts +0 -2
- package/dist/ui/molecules/split-button/index.d.ts.map +0 -1
- package/dist/ui/molecules/split-button/index.js +0 -3
- package/dist/ui/molecules/split-button/index.js.map +0 -1
- package/dist/ui/molecules/split-button/split-button.d.ts +0 -21
- package/dist/ui/molecules/split-button/split-button.d.ts.map +0 -1
- package/dist/ui/molecules/split-button/split-button.js +0 -35
- package/dist/ui/molecules/split-button/split-button.js.map +0 -1
|
@@ -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 EntityLinkSource,\n type MetaAccessorType,\n readDraftString,\n readLocalizedDraft,\n readRowDrafts,\n type UseCaseDescriptor,\n} from '@entifix/core';\nimport { type ReactNode, useId, useState } from 'react';\n\nimport {\n useErrorMessage,\n useLocalizedDescriptors,\n useT,\n useTranslateKey,\n} from '../../../i18n/index.js';\nimport {\n OVERFLOW_GLYPH,\n renderAnchor,\n useCasesForSurface,\n} from '../../actions/index.js';\nimport { Button, button } from '../../atoms/button/index.js';\nimport { CellValue } 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 { Card } from '../../molecules/card/index.js';\nimport { ConfirmDialog } from '../../molecules/confirm-dialog/index.js';\nimport { EntityLinkInput } from '../../molecules/entity-link-input/index.js';\nimport { LoadingBoundary } from '../../molecules/loading-boundary/index.js';\nimport { Menu } from '../../molecules/menu/index.js';\nimport { Stack } from '../../molecules/stack/index.js';\nimport { cn } from '../../utils/cn.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 * 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/**\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/**\n * How many verbs a surface shows before the rest fold into an overflow menu.\n *\n * Four, because that is roughly what fits beside a title at a laptop width\n * without the row wrapping — the same number Fiori's object-page header settles\n * on. It is a layout constant, not a policy: raising it does not grant anything.\n */\nconst VISIBLE_ACTION_LIMIT = 4;\n\n/** A verb waiting on its confirmation — narrowed so `confirm` is not optional. */\ninterface PendingConfirmation {\n key: string;\n labelKey: string;\n confirm: NonNullable<UseCaseDescriptor['confirm']>;\n}\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 embedded = false,\n isLoading = false,\n skeleton = true,\n isSaving = false,\n isPending = false,\n isDeleting = false,\n error,\n backHref,\n renderLink = renderAnchor,\n title,\n metadata,\n isMetadataLoading = false,\n onUseCase,\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 const columnDescriptors = describeEntityColumns(\n entityConstructor,\n entity,\n ) as Array<EntityFormField<TEntity>>;\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 const mode = 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 errorMessage = useErrorMessage();\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 may = (action: EntityAction) =>\n metadata === undefined || metadata.actions.includes(action);\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 );\n const declaredFooterUseCases = useCasesForSurface(\n 'form-footer',\n metadata?.useCases,\n );\n const headerUseCases = onUseCase ? declaredHeaderUseCases : [];\n const footerUseCases = onUseCase ? declaredFooterUseCases : [];\n\n // A descriptor carrying `confirm` must be asked about before it fires;\n // `revoke-sessions` ends every session a user holds. The state holds the\n // confirmation itself rather than the descriptor, so the dialog cannot be\n // opened for a verb that never asked for one.\n const [pending, setPending] = useState<PendingConfirmation | undefined>(\n undefined,\n );\n const invoke = (descriptor: UseCaseDescriptor) => {\n const confirm = descriptor.confirm;\n if (confirm) {\n setPending({\n key: descriptor.key,\n labelKey: descriptor.labelKey,\n confirm,\n });\n return;\n }\n onUseCase?.(descriptor.key);\n };\n\n const useCaseButton = (descriptor: UseCaseDescriptor) => (\n <Button\n key={descriptor.key}\n type=\"button\"\n variant={\n descriptor.confirm?.tone === 'destructive' ? 'destructive' : 'secondary'\n }\n size={descriptor.placement === 'context-independent' ? 'sm' : 'md'}\n disabled={busy}\n onClick={() => invoke(descriptor)}\n >\n {/* A descriptor's labels are *runtime* catalog keys — they never resolve\n at compile time, which is why a host's catalog check is what catches a\n typo here rather than the type system. */}\n {translateKey(descriptor.labelKey)}\n </Button>\n );\n\n const useCaseMenuItem = (descriptor: UseCaseDescriptor) => (\n <Menu.Item\n key={descriptor.key}\n tone={\n descriptor.confirm?.tone === 'destructive' ? 'destructive' : 'neutral'\n }\n disabled={busy}\n onClick={() => invoke(descriptor)}\n >\n {translateKey(descriptor.labelKey)}\n </Menu.Item>\n );\n\n /**\n * Four actions fit a row; twelve do not.\n *\n * So a surface renders its first {@link VISIBLE_ACTION_LIMIT} verbs as\n * buttons and folds the rest behind one overflow trigger, in **declaration\n * order** — the entity's author decided which verbs matter by writing them\n * first, and a rule that sorted by anything else (alphabetical, destructive\n * last) would reorder the row every time a verb was added.\n *\n * The split is only applied when there is something to fold: a fifth action\n * is the point at which a menu is cheaper than a wider row, and a menu\n * holding one entry is strictly worse than the button it replaced.\n */\n const withOverflow = (descriptors: UseCaseDescriptor[]) => {\n if (descriptors.length <= VISIBLE_ACTION_LIMIT) {\n return descriptors.map(useCaseButton);\n }\n\n const visible = descriptors.slice(0, VISIBLE_ACTION_LIMIT);\n const folded = descriptors.slice(VISIBLE_ACTION_LIMIT);\n\n return [\n ...visible.map(useCaseButton),\n <Menu key=\"overflow\">\n <Menu.Trigger aria-label={t('form.moreActions')}>\n {OVERFLOW_GLYPH}\n </Menu.Trigger>\n <Menu.Items>{folded.map(useCaseMenuItem)}</Menu.Items>\n </Menu>,\n ];\n };\n\n return (\n <Card>\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 as=\"h2\" step={1} weight=\"semibold\">\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 ??\n (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 && (\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 {withOverflow(headerUseCases)}\n {slots.headerActions}\n </>\n </LoadingBoundary>\n </Stack>\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 {error && (\n <p\n role=\"alert\"\n data-testid=\"entity-form-error\"\n className=\"rounded-sm border border-danger bg-danger-subtle px-s py-2xs text-step-sm text-danger\"\n >\n {errorMessage(error)}\n </p>\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 : 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 ? errors?.[field.name] : undefined}\n setField={setField}\n linkSource={linkSources?.[field.name]}\n onLinkChange={onLinkChange}\n id={`${formId}-${field.name}`}\n />\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 {editing && !embedded && (\n <Stack direction=\"row\" gap=\"xs\">\n {may('write') && (\n <Button\n type=\"button\"\n onClick={() => onSubmit?.(draft)}\n disabled={busy || resolvingLinks}\n >\n {isPending\n ? t('form.pending')\n : isSaving\n ? t('form.saving')\n : t('form.save')}\n </Button>\n )}\n {onDelete && may('delete') && (\n <Button\n type=\"button\"\n variant=\"secondary\"\n onClick={onDelete}\n disabled={busy}\n >\n {isDeleting ? t('form.deleting') : t('form.delete')}\n </Button>\n )}\n {withOverflow(footerUseCases)}\n {/* Clone is the CRUD triple's, not a declared verb's: every entity\n can be copied, so giving it a `@useCase()` would mean declaring\n the same verb on all 28 of them. It needs `write`, because what\n it produces is a create. */}\n {onClone && entity && may('write') && (\n <Button\n type=\"button\"\n variant=\"secondary\"\n disabled={busy}\n onClick={() =>\n onClone(cloneEntityDraft(entityConstructor, draft))\n }\n >\n {t('form.clone')}\n </Button>\n )}\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 {pending && (\n <ConfirmDialog\n open\n tone={pending.confirm.tone}\n title={translateKey(pending.labelKey)}\n message={translateKey(pending.confirm.messageKey)}\n busy={busy}\n onCancel={() => setPending(undefined)}\n onConfirm={() => {\n const key = pending.key;\n setPending(undefined);\n onUseCase?.(key);\n }}\n />\n )}\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 && !PICKABLE_TYPES.has(field.type),\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` or the `string` that carries a foreign key. Remove the entry, or ' +\n 'point it at the member 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 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 />\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 && 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 />\n );\n }\n\n const ownsLabel =\n editing && field.type === 'boolean' && !field.render && !field.virtual;\n\n return (\n <Stack gap=\"3xs\">\n {!ownsLabel && (\n <label htmlFor={id} className=\"text-step-sm text-content-muted\">\n {field.label}\n </label>\n )}\n {control}\n {error && (\n <span role=\"alert\" className=\"text-step-sm text-danger\">\n {error}\n </span>\n )}\n </Stack>\n );\n}\n"],"names":["cloneEntityDraft","describeEntityColumns","readDraftString","readLocalizedDraft","readRowDrafts","useId","useState","useErrorMessage","useLocalizedDescriptors","useT","useTranslateKey","OVERFLOW_GLYPH","renderAnchor","useCasesForSurface","Button","button","CellValue","FieldControl","LocalizedFieldControl","Skeleton","Text","Card","ConfirmDialog","EntityLinkInput","LoadingBoundary","Menu","Stack","cn","EntityDetailGrid","readEntityFormFields","resolveEntityFormFields","PICKABLE_TYPES","Set","VISIBLE_ACTION_LIMIT","EntityForm","entityConstructor","entity","values","onFieldChange","linkSources","onLinkChange","mode","modeProp","defaultMode","onModeChange","errors","formError","onSubmit","onDelete","embedded","isLoading","skeleton","isSaving","isPending","isDeleting","error","backHref","renderLink","title","metadata","isMetadataLoading","onUseCase","onClone","children","formId","slots","columnDescriptors","described","resolved","fields","assertLinkSourcesAreEditable","filter","field","isOwnedCollection","ownedCollections","customSkeleton","undefined","showSkeleton","internalMode","setInternalMode","editing","draft","setField","name","value","toggleMode","next","t","translateKey","errorMessage","busy","resolvingLinks","Object","some","source","selected","may","action","actions","includes","declaredHeaderUseCases","useCases","declaredFooterUseCases","headerUseCases","footerUseCases","pending","setPending","invoke","descriptor","confirm","key","labelKey","useCaseButton","type","variant","tone","size","placement","disabled","onClick","useCaseMenuItem","Item","withOverflow","descriptors","length","map","visible","slice","folded","Trigger","aria-label","Items","gap","direction","align","as","step","weight","lines","headerActions","span","role","aria-live","className","p","data-testid","shape","FieldRow","linkSource","id","rows","onRowsChange","footerActions","href","intent","kind","rest","open","message","messageKey","onCancel","onConfirm","childType","sourced","has","toMany","Error","join","owned","unpickable","readNode","readRender","isRelation","control","render","readonly","onSelect","target","String","onClear","virtual","onChange","ownsLabel","label","htmlFor"],"mappings":"AAAA;;AAEA,SACEA,gBAAgB,EAChBC,qBAAqB,EAOrBC,eAAe,EACfC,kBAAkB,EAClBC,aAAa,QAER,gBAAgB;AACvB,SAAyBC,KAAK,EAAEC,QAAQ,QA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/F,CAAAA,OAAQJ,SAASV,MAAMW,IAAI,EAAEG;YACvC+D,IAAIA;;IAGV,OAAO,IAAI7E,MAAM4G,OAAO,IAAIR,YAAY;QACtC,2EAA2E;QAC3E,2EAA2E;QAC3E,gBAAgB;QAChBC,UAAUH;IACZ,OAAO;QACLG,wBACE,KAAC5J;YACC2F,YAAYpC;YACZY,OAAOA;YACPiG,UAAU/F,CAAAA,OAAQJ,SAASV,MAAMW,IAAI,EAAEG;YACvC+D,IAAIA;;IAGV;IAEA,MAAMiC,YACJtG,WAAWR,MAAMyC,IAAI,KAAK,aAAa,CAACzC,MAAMsG,MAAM,IAAI,CAACtG,MAAM4G,OAAO;IAExE,qBACE,MAAC1J;QAAM0G,KAAI;;YACR,CAACkD,2BACA,KAACC;gBAAMC,SAASnC;gBAAIN,WAAU;0BAC3BvE,MAAM+G,KAAK;;YAGfV;YACAtH,uBACC,KAACqF;gBAAKC,MAAK;gBAAQE,WAAU;0BAC1BxF;;;;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 EntityLinkSource,\n extractMetaEntity,\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 { renderAnchor, useCasesForSurface } from '../../actions/index.js';\nimport { useVerbInvoker } from '../../actions/use-verb-invoker.js';\nimport { Button, button } from '../../atoms/button/index.js';\nimport { CellValue } 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 { 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 { useFocusOnArrival } 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 * 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/**\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 backHref,\n renderLink = renderAnchor,\n title,\n metadata,\n isMetadataLoading = false,\n onUseCase,\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 const columnDescriptors = describeEntityColumns(\n entityConstructor,\n entity,\n ) as Array<EntityFormField<TEntity>>;\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 const mode = 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 may = (action: EntityAction) =>\n metadata === undefined || metadata.actions.includes(action);\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 );\n const declaredFooterUseCases = useCasesForSurface(\n 'form-footer',\n metadata?.useCases,\n );\n const headerUseCases = onUseCase ? declaredHeaderUseCases : [];\n const footerUseCases = onUseCase ? declaredFooterUseCases : [];\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 record as the reader knows it — its first\n // filled-in field — or, for a record with nothing filled in, the entity.\n const metaEntity = extractMetaEntity(entityConstructor);\n const named = fields.find(\n field => field.type !== 'id' && readDraftString(draft, field.name) !== '',\n );\n const recordLabel =\n named === undefined\n ? entityNoun(metaEntity)\n : readDraftString(draft, named.name);\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 const summary = useRef<HTMLDivElement>(null);\n const summaryId = useId();\n const invalid = editing\n ? fields.filter(field => errors?.[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 && may('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 ? errors?.[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 && (\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 {/* 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 <RegionState\n plural={entityNoun(metaEntity, 'plural')}\n error={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 {errors?.[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 {editing && !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 && !PICKABLE_TYPES.has(field.type),\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` or the `string` that carries a foreign key. Remove the entry, or ' +\n 'point it at the member 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 && 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","readDraftString","readLocalizedDraft","readRowDrafts","useEffect","useId","useRef","useState","useEntityNoun","useLocalizedDescriptors","useT","useTranslateKey","renderAnchor","useCasesForSurface","useVerbInvoker","Button","button","CellValue","FieldControl","LocalizedFieldControl","Skeleton","Text","ActionBar","itemsForUseCases","Card","EntityLinkInput","LoadingBoundary","RegionState","Stack","cn","useLiveUpdates","useFocusOnArrival","EntityDetailGrid","readEntityFormFields","resolveEntityFormFields","PICKABLE_TYPES","Set","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","backHref","renderLink","title","metadata","isMetadataLoading","onUseCase","onClone","children","formId","slots","columnDescriptors","described","resolved","fields","assertLinkSourcesAreEditable","filter","field","isOwnedCollection","ownedCollections","customSkeleton","undefined","showSkeleton","internalMode","setInternalMode","editing","draft","setField","name","value","toggleMode","next","t","translateKey","entityNoun","live","heading","busy","resolvingLinks","Object","some","source","selected","may","action","actions","includes","declaredHeaderUseCases","useCases","declaredFooterUseCases","headerUseCases","footerUseCases","verbs","run","key","served","metaEntity","named","find","type","recordLabel","invoke","descriptor","target","object","count","requestDelete","binding","placement","labelKey","confirm","tone","messageKey","reversible","headerItems","footerItems","attempt","setAttempt","save","current","summary","summaryId","invalid","focusedAttempt","length","focus","declaresFooterPrimary","item","emphasis","footerActions","label","connection","disabled","submit","shortcut","onSelect","map","destructive","asForm","rows","FieldRow","linkSource","id","body","gap","direction","align","as","ref","tabIndex","step","weight","className","variant","size","onClick","lines","surface","items","headerActions","span","role","aria-live","plural","hasStaleData","div","aria-labelledby","data-testid","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","join","owned","unpickable","errorId","readNode","readRender","record","isRelation","control","render","String","onClear","virtual","onChange","aria-invalid","aria-describedby","aria-required","dt","dd","ownsLabel","marked","htmlFor","aria-hidden"],"mappings":"AAAA;;;AAEA,SACEA,gBAAgB,EAChBC,qBAAqB,EAMrBC,iBAAiB,EAEjBC,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,SAASC,YAAY,EAAEC,kBAAkB,QAAQ,yBAAyB;AAC1E,SAASC,cAAc,QAAQ,oCAAoC;AACnE,SAASC,MAAM,EAAEC,MAAM,QAAQ,8BAA8B;AAC7D,SAASC,SAAS,QAAQ,kCAAkC;AAC5D,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,eAAe,QAAQ,4CAA4C;AAC5E,SAASC,WAAW,QAAQ,wCAAwC;AACpE,SAASC,KAAK,QAAQ,iCAAiC;AACvD,SAASC,EAAE,QAAQ,oBAAoB;AACvC,SAASC,cAAc,QAAQ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gE;0BAChE,MAACpD;gBAAKR,WAAU;;kCACd,KAACtB;wBAAMoF,SAASxE;wBAAIU,WAAU;kCAC3B/F,MAAMyE,KAAK;;oBAEbmF,wBACC,KAACrD;wBAAKuD,eAAY;wBAAO/D,WAAU;kCAChChF,EAAE;;;;YAKViI;YAGAlK,uBACC,KAACyH;gBAAKlB,IAAIsD;gBAAS5C,WAAU;0BAC1BjH;;;;AAKX"}
|
|
@@ -83,6 +83,12 @@ export interface EntityFormProps<TEntity extends Entity> {
|
|
|
83
83
|
formError?: string;
|
|
84
84
|
onSubmit?: (draft: EntityDraft) => void;
|
|
85
85
|
onDelete?: () => void;
|
|
86
|
+
/**
|
|
87
|
+
* How the built-in Delete is made safe: `confirm` (the default) asks in an
|
|
88
|
+
* alert dialog, `typed` asks for the record's name first, and `undo` deletes
|
|
89
|
+
* at once — the host offers Undo, since only it can put the record back.
|
|
90
|
+
*/
|
|
91
|
+
deletePolicy?: 'confirm' | 'typed' | 'undo';
|
|
86
92
|
/**
|
|
87
93
|
* What this caller may do with the entity, as served by
|
|
88
94
|
* `GET /api/<entity>/$metadata` and already filtered against the verified
|
|
@@ -147,6 +153,8 @@ export interface EntityFormProps<TEntity extends Entity> {
|
|
|
147
153
|
isDeleting?: boolean;
|
|
148
154
|
/** The failure of the last load/save, shown as an alert. */
|
|
149
155
|
error?: EntifixFailure;
|
|
156
|
+
/** Loads the record again — what a failed load offers as Retry. */
|
|
157
|
+
onRetry?: () => void;
|
|
150
158
|
/** Link to return to, rendered as a `Back` action. Omit to hide it. */
|
|
151
159
|
backHref?: string;
|
|
152
160
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-form.types.d.ts","sourceRoot":"","sources":["../../../../src/ui/organisms/entity-form/entity-form.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,MAAM,EACN,iBAAiB,EACjB,WAAW,EACX,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,sB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D;;;;OAIG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAElE,4EAA4E;IAC5E,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB;sDACkD;IAClD,WAAW,CAAC,EAAE,cAAc,CAAC;IAC7B,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,CAAC;IAE9C,0DAA0D;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACxC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"entity-form.types.d.ts","sourceRoot":"","sources":["../../../../src/ui/organisms/entity-form/entity-form.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,MAAM,EACN,iBAAiB,EACjB,WAAW,EACX,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD,4EAA4E;AAC5E,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,CAAC;AAE7C,0DAA0D;AAC1D,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,WAAW,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAC1D,mEAAmE;IACnE,EAAE,EAAE,MAAM,CAAC;CACZ;AAED;;;GAGG;AACH,MAAM,WAAW,eA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,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB;;;;OAIG;IACH,YAAY,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;IAE5C;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,EAAE,sBAAsB,CAAC;IAClC,6EAA6E;IAC7E,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;;OAIG;IACH,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAElC;;;;;;;;;;OAUG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IAEvC;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,4DAA4D;IAC5D,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,mEAAmE;IACnE,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IAErB,uEAAuE;IACvE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,yDAAyD;IACzD,KAAK,CAAC,EAAE,SAAS,CAAC;IAElB,qDAAqD;IACrD,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/ui/organisms/entity-form/entity-form.types.ts"],"sourcesContent":["import type {\n EntifixFailure,\n Entity,\n EntityConstructor,\n EntityDraft,\n EntityDraftValue,\n EntityFieldDescriptor,\n EntityLinkSource,\n EntityMetadataDocument,\n} from '@entifix/core';\nimport type { ReactNode } from 'react';\n\nimport type { RenderLink } from '../../actions/index.js';\n\n/** Whether the form shows values as text (`read`) or as inputs (`edit`). */\nexport type EntityFormMode = 'read' | 'edit';\n\n/** What a custom edit control for one field is handed. */\nexport interface EntityFieldRenderContext {\n draft: EntityDraft;\n value: string;\n setField: (name: string, value: EntityDraftValue) => void;\n /** The id the field's label points at — put it on your control. */\n id: string;\n}\n\n/**\n * A field as the form finally renders it: the metadata descriptor plus the\n * per-field overrides a caller supplied through an `<EntityField>` slot.\n */\nexport interface EntityFormField<\n TEntity extends Entity,\n> extends EntityFieldDescriptor {\n /** Replaces the default edit control. */\n render?: (context: EntityFieldRenderContext) => ReactNode;\n /** Replaces the default read display. */\n readRender?: (entity: TEntity | undefined) => ReactNode;\n /** True when the field has no backing entity member (slot-only field). */\n virtual?: boolean;\n}\n\nexport interface EntityFormProps<TEntity extends Entity> {\n /** Metadata source. Fields, labels and types derive from its accessors. */\n entityConstructor: EntityConstructor<TEntity>;\n /** The record being viewed/edited. The read display and, in a wrapper, the\n * initial draft both come from it; omit for a create form. */\n entity?: TEntity;\n\n /** The current draft. The form is controlled — a host (the `useEntityForm`\n * hook or a `useState`) owns this and updates it via `onFieldChange`. */\n values?: EntityDraft;\n /**\n * Called when one field changes.\n *\n * The value is a union rather than a string because a `composition`\n * member's is its list of rows — the one member with no lossless string form.\n * Every scalar editor still writes a string, so a host that only edits\n * scalars is unaffected.\n */\n onFieldChange?: (name: string, value: EntityDraftValue) => void;\n\n /**\n * A search/browse source per reference, keyed by accessor name. A `link` field\n * with a source gets the full editor; one without keeps its read-only display,\n * which is what a form that only shows a relation still wants.\n *\n * A **`string`** field with a source gets the same editor, because a foreign\n * key whose target lives in another slice's store cannot be a typed `link` at\n * all and is a plain id member. The editor does not know the\n * difference — it writes the target's id into the draft either way.\n *\n * A key naming any other member throws: `linkCollection` has no editor\n * anywhere yet, and a `boolean`/`enum`/`number`/`date` can never name another\n * record, so the entry could only be dropped — and a dropped source looks\n * exactly like a member the entity declared read-only.\n *\n * A registry rather than a slot per relation: the whole point is that an entity\n * declaring a reference needs no bespoke control. The sources are built by the\n * caller because fetching them is the integration layer's job, and this package\n * cannot reach it.\n */\n // A source's target is another entity entirely, so it cannot be expressed in\n // terms of `TEntity`; the input it feeds is instantiated per field anyway.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n linkSources?: Record<string, EntityLinkSource<any>>;\n /**\n * A relation was set or cleared. The instance travels alongside the id the\n * draft holds, so a host can remember it — an id alone cannot be written as an\n * embedded relation.\n */\n onLinkChange?: (name: string, entity: Entity | undefined) => void;\n\n /** Force a mode. Omit to let the form own it (with the built-in toggle). */\n mode?: EntityFormMode;\n /** Initial mode when uncontrolled. Defaults to `read` with an `entity`, else\n * `edit` (a create form opens ready to type). */\n defaultMode?: EntityFormMode;\n onModeChange?: (mode: EntityFormMode) => void;\n\n /** Per-field validation messages, keyed by field name. */\n errors?: Record<string, string>;\n /**\n * A validation message that belongs to no single field — a rule spanning two\n * of them. Rendered above the actions, since no row can host it.\n */\n formError?: string;\n\n onSubmit?: (draft: EntityDraft) => void;\n onDelete?: () => void;\n\n /**\n * What this caller may do with the entity, as served by\n * `GET /api/<entity>/$metadata` and already filtered against the verified\n * principal.\n *\n * **Optional, and absent means \"as before\".** Without it the form renders Save\n * and Delete exactly as it always has, so a call site that has not migrated is\n * unaffected. This is not a security control — hiding a button protects\n * nothing; the route guard does. It is what stops a screen offering an action\n * the service will refuse.\n */\n metadata?: EntityMetadataDocument;\n /** The document is still in flight; the action row renders as a skeleton. */\n isMetadataLoading?: boolean;\n /**\n * A declared use case was invoked, by its `key`. The form renders the button\n * and asks for confirmation where the descriptor says to; performing the act\n * is the caller's — the browser must never import a use-case class.\n */\n onUseCase?: (key: string) => void;\n\n /**\n * Copies the record into a new draft, dropping the members declared\n * `@accessor({ resetOnClone: true })` and always the id.\n *\n * A prop rather than something the form does by itself, because the *result*\n * of a clone is a navigation — a create form holding the copy — and this\n * package knows no router. The form supplies the cleaned draft\n * (`cloneEntityDraft`); where it lands is the caller's.\n *\n * Absent renders no Clone action.\n */\n onClone?: (draft: EntityDraft) => void;\n\n /**\n * Render the **fields and nothing else** — no heading, no action row.\n *\n * For a form hosted inside something that already owns those controls: a\n * wizard step sits under the wizard's own heading and advances with the\n * wizard's own footer, so a second heading and a Save button beside Siguiente\n * would be two controls for one job, and the Save would commit a partial\n * record mid-flow.\n *\n * Opt-in and defaulted off, so every existing form is untouched.\n */\n embedded?: boolean;\n isLoading?: boolean;\n /**\n * What holds the form's shape while the record is in flight.\n *\n * `true` (the default) renders the built-in placeholder — one label+control\n * pair per resolved field, so the swap to the real rows shifts nothing. A node\n * replaces that default; `false` renders no placeholder at all.\n *\n * The placeholder *replaces* the field rows; it never stacks above them.\n */\n skeleton?: boolean | ReactNode;\n isSaving?: boolean;\n /**\n * A write the server handed to a flow that has not settled yet. The fields\n * keep what was typed, and Save waits, until the flow's outcome arrives.\n */\n isPending?: boolean;\n isDeleting?: boolean;\n /** The failure of the last load/save, shown as an alert. */\n error?: EntifixFailure;\n\n /** Link to return to, rendered as a `Back` action. Omit to hide it. */\n backHref?: string;\n /**\n * Renders the `Back` link. Defaults to a plain anchor, which a client-routed\n * host experiences as a full document load. See {@link RenderLink}.\n */\n renderLink?: RenderLink;\n /** Heading for the card. Defaults to a generic label. */\n title?: ReactNode;\n\n /** Customization slots — see `entity-form-slots`. */\n children?: ReactNode;\n}\n"],"names":[],"mappings":"AAyCA,
|
|
1
|
+
{"version":3,"sources":["../../../../src/ui/organisms/entity-form/entity-form.types.ts"],"sourcesContent":["import type {\n EntifixFailure,\n Entity,\n EntityConstructor,\n EntityDraft,\n EntityDraftValue,\n EntityFieldDescriptor,\n EntityLinkSource,\n EntityMetadataDocument,\n} from '@entifix/core';\nimport type { ReactNode } from 'react';\n\nimport type { RenderLink } from '../../actions/index.js';\n\n/** Whether the form shows values as text (`read`) or as inputs (`edit`). */\nexport type EntityFormMode = 'read' | 'edit';\n\n/** What a custom edit control for one field is handed. */\nexport interface EntityFieldRenderContext {\n draft: EntityDraft;\n value: string;\n setField: (name: string, value: EntityDraftValue) => void;\n /** The id the field's label points at — put it on your control. */\n id: string;\n}\n\n/**\n * A field as the form finally renders it: the metadata descriptor plus the\n * per-field overrides a caller supplied through an `<EntityField>` slot.\n */\nexport interface EntityFormField<\n TEntity extends Entity,\n> extends EntityFieldDescriptor {\n /** Replaces the default edit control. */\n render?: (context: EntityFieldRenderContext) => ReactNode;\n /** Replaces the default read display. */\n readRender?: (entity: TEntity | undefined) => ReactNode;\n /** True when the field has no backing entity member (slot-only field). */\n virtual?: boolean;\n}\n\nexport interface EntityFormProps<TEntity extends Entity> {\n /** Metadata source. Fields, labels and types derive from its accessors. */\n entityConstructor: EntityConstructor<TEntity>;\n /** The record being viewed/edited. The read display and, in a wrapper, the\n * initial draft both come from it; omit for a create form. */\n entity?: TEntity;\n\n /** The current draft. The form is controlled — a host (the `useEntityForm`\n * hook or a `useState`) owns this and updates it via `onFieldChange`. */\n values?: EntityDraft;\n /**\n * Called when one field changes.\n *\n * The value is a union rather than a string because a `composition`\n * member's is its list of rows — the one member with no lossless string form.\n * Every scalar editor still writes a string, so a host that only edits\n * scalars is unaffected.\n */\n onFieldChange?: (name: string, value: EntityDraftValue) => void;\n\n /**\n * A search/browse source per reference, keyed by accessor name. A `link` field\n * with a source gets the full editor; one without keeps its read-only display,\n * which is what a form that only shows a relation still wants.\n *\n * A **`string`** field with a source gets the same editor, because a foreign\n * key whose target lives in another slice's store cannot be a typed `link` at\n * all and is a plain id member. The editor does not know the\n * difference — it writes the target's id into the draft either way.\n *\n * A key naming any other member throws: `linkCollection` has no editor\n * anywhere yet, and a `boolean`/`enum`/`number`/`date` can never name another\n * record, so the entry could only be dropped — and a dropped source looks\n * exactly like a member the entity declared read-only.\n *\n * A registry rather than a slot per relation: the whole point is that an entity\n * declaring a reference needs no bespoke control. The sources are built by the\n * caller because fetching them is the integration layer's job, and this package\n * cannot reach it.\n */\n // A source's target is another entity entirely, so it cannot be expressed in\n // terms of `TEntity`; the input it feeds is instantiated per field anyway.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n linkSources?: Record<string, EntityLinkSource<any>>;\n /**\n * A relation was set or cleared. The instance travels alongside the id the\n * draft holds, so a host can remember it — an id alone cannot be written as an\n * embedded relation.\n */\n onLinkChange?: (name: string, entity: Entity | undefined) => void;\n\n /** Force a mode. Omit to let the form own it (with the built-in toggle). */\n mode?: EntityFormMode;\n /** Initial mode when uncontrolled. Defaults to `read` with an `entity`, else\n * `edit` (a create form opens ready to type). */\n defaultMode?: EntityFormMode;\n onModeChange?: (mode: EntityFormMode) => void;\n\n /** Per-field validation messages, keyed by field name. */\n errors?: Record<string, string>;\n /**\n * A validation message that belongs to no single field — a rule spanning two\n * of them. Rendered above the actions, since no row can host it.\n */\n formError?: string;\n\n onSubmit?: (draft: EntityDraft) => void;\n onDelete?: () => void;\n /**\n * How the built-in Delete is made safe: `confirm` (the default) asks in an\n * alert dialog, `typed` asks for the record's name first, and `undo` deletes\n * at once — the host offers Undo, since only it can put the record back.\n */\n deletePolicy?: 'confirm' | 'typed' | 'undo';\n\n /**\n * What this caller may do with the entity, as served by\n * `GET /api/<entity>/$metadata` and already filtered against the verified\n * principal.\n *\n * **Optional, and absent means \"as before\".** Without it the form renders Save\n * and Delete exactly as it always has, so a call site that has not migrated is\n * unaffected. This is not a security control — hiding a button protects\n * nothing; the route guard does. It is what stops a screen offering an action\n * the service will refuse.\n */\n metadata?: EntityMetadataDocument;\n /** The document is still in flight; the action row renders as a skeleton. */\n isMetadataLoading?: boolean;\n /**\n * A declared use case was invoked, by its `key`. The form renders the button\n * and asks for confirmation where the descriptor says to; performing the act\n * is the caller's — the browser must never import a use-case class.\n */\n onUseCase?: (key: string) => void;\n\n /**\n * Copies the record into a new draft, dropping the members declared\n * `@accessor({ resetOnClone: true })` and always the id.\n *\n * A prop rather than something the form does by itself, because the *result*\n * of a clone is a navigation — a create form holding the copy — and this\n * package knows no router. The form supplies the cleaned draft\n * (`cloneEntityDraft`); where it lands is the caller's.\n *\n * Absent renders no Clone action.\n */\n onClone?: (draft: EntityDraft) => void;\n\n /**\n * Render the **fields and nothing else** — no heading, no action row.\n *\n * For a form hosted inside something that already owns those controls: a\n * wizard step sits under the wizard's own heading and advances with the\n * wizard's own footer, so a second heading and a Save button beside Siguiente\n * would be two controls for one job, and the Save would commit a partial\n * record mid-flow.\n *\n * Opt-in and defaulted off, so every existing form is untouched.\n */\n embedded?: boolean;\n isLoading?: boolean;\n /**\n * What holds the form's shape while the record is in flight.\n *\n * `true` (the default) renders the built-in placeholder — one label+control\n * pair per resolved field, so the swap to the real rows shifts nothing. A node\n * replaces that default; `false` renders no placeholder at all.\n *\n * The placeholder *replaces* the field rows; it never stacks above them.\n */\n skeleton?: boolean | ReactNode;\n isSaving?: boolean;\n /**\n * A write the server handed to a flow that has not settled yet. The fields\n * keep what was typed, and Save waits, until the flow's outcome arrives.\n */\n isPending?: boolean;\n isDeleting?: boolean;\n /** The failure of the last load/save, shown as an alert. */\n error?: EntifixFailure;\n /** Loads the record again — what a failed load offers as Retry. */\n onRetry?: () => void;\n\n /** Link to return to, rendered as a `Back` action. Omit to hide it. */\n backHref?: string;\n /**\n * Renders the `Back` link. Defaults to a plain anchor, which a client-routed\n * host experiences as a full document load. See {@link RenderLink}.\n */\n renderLink?: RenderLink;\n /** Heading for the card. Defaults to a generic label. */\n title?: ReactNode;\n\n /** Customization slots — see `entity-form-slots`. */\n children?: ReactNode;\n}\n"],"names":[],"mappings":"AAyCA,WA4JC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type Entity } from '@entifix/core';
|
|
2
2
|
import type { EntityTableProps } from './entity-table.types.js';
|
|
3
|
-
export declare function EntityTable<TEntity extends Entity>({ entityConstructor, isLoading, skeleton, error, items, totalItems, currentPage, pageSize, onPageChange, onPageSizeChange, hrefFor, newHref, renderLink, onSelect, preferencesKey, showControls, pivotBreakpoint, filtering, sorting, onFilteringChange, onSortingChange, selection, onSelectionChange, metadata, isMetadataLoading, onBulkUseCase, onUseCase, bulkOutcomes, onBulkDismiss, onBulkRetry, isBulkRunning, children, }: EntityTableProps<TEntity>): import("react").JSX.Element;
|
|
3
|
+
export declare function EntityTable<TEntity extends Entity>({ entityConstructor, isLoading, skeleton, error, items, totalItems, currentPage, pageSize, onPageChange, onPageSizeChange, hrefFor, newHref, renderLink, onSelect, preferencesKey, showControls, pivotBreakpoint, filtering, sorting, onFilteringChange, onSortingChange, facets, selection, onSelectionChange, metadata, isMetadataLoading, onBulkUseCase, onUseCase, onRetry, bulkOutcomes, onBulkDismiss, onBulkRetry, isBulkRunning, children, }: EntityTableProps<TEntity>): import("react").JSX.Element;
|
|
4
4
|
//# sourceMappingURL=entity-table.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-table.d.ts","sourceRoot":"","sources":["../../../../src/ui/organisms/entity-table/entity-table.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,MAAM,
|
|
1
|
+
{"version":3,"file":"entity-table.d.ts","sourceRoot":"","sources":["../../../../src/ui/organisms/entity-table/entity-table.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,MAAM,EAYZ,MAAM,eAAe,CAAC;AAgDvB,OAAO,KAAK,EAEV,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AAqDjC,wBAAgB,WAAW,CAAC,OAAO,SAAS,MAAM,EAAE,EAClD,iBAAiB,EACjB,SAAS,EACT,QAAe,EACf,KAAK,EACL,KAAK,EACL,UAAU,EACV,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,gBAAgB,EAChB,OAAO,EACP,OAAO,EACP,UAAyB,EACzB,QAAQ,EACR,cAAc,EACd,YAAmB,EACnB,eAAe,EACf,SAAS,EACT,OAAO,EACP,iBAAiB,EACjB,eAAe,EACf,MAAM,EACN,SAAS,EACT,iBAAiB,EACjB,QAAQ,EACR,iBAAyB,EACzB,aAAa,EACb,SAAS,EACT,OAAO,EACP,YAAY,EACZ,aAAa,EACb,WAAW,EACX,aAAqB,EACrB,QAAQ,GACT,EAAE,gBAAgB,CAAC,OAAO,CAAC,+BA84B3B"}
|