@riducms/admin 0.2.3 → 0.4.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/THIRD_PARTY_NOTICES.md +60 -37
- package/package.json +29 -15
- package/src/app/admin-core-view-route.svelte +38 -53
- package/src/app/admin-extension-route.svelte +19 -0
- package/src/app/admin-layout.scss +175 -0
- package/src/app/admin-layout.svelte +144 -410
- package/src/app/admin-navigation-progress.svelte +11 -77
- package/src/app/admin-page-title.svelte +17 -85
- package/src/app/admin-page-title.ts +136 -0
- package/src/app/admin-route-error.svelte +24 -0
- package/src/app/admin-router-provider.svelte +34 -0
- package/src/app/admin-router-root.svelte +41 -0
- package/src/app/admin-routes.svelte +56 -19
- package/src/app/loading-boundary.svelte +3 -1
- package/src/app-meta.ts +13 -0
- package/src/app.css +138 -496
- package/src/app.svelte +60 -26
- package/src/components/brand/ridu-logo.svelte +19 -5
- package/src/components/data/list-table.scss +63 -0
- package/src/components/icons/LICENSE.md +24 -0
- package/src/components/icons/chevron.svelte +8 -0
- package/src/components/icons/plus.svelte +12 -0
- package/src/components/icons/search.svelte +12 -0
- package/src/components/icons/x.svelte +8 -0
- package/src/components/json-tree/json-tree-node.svelte +61 -67
- package/src/components/json-tree/json-viewer.scss +153 -0
- package/src/components/json-tree/json-viewer.svelte +57 -96
- package/src/components/ui/banner/banner.scss +28 -0
- package/src/components/ui/banner/banner.svelte +9 -8
- package/src/components/ui/banner/index.ts +1 -5
- package/src/components/ui/code-editor/code-editor.scss +20 -0
- package/src/components/ui/code-editor/code-editor.svelte +71 -0
- package/src/components/ui/code-editor/code-editor.ts +151 -0
- package/src/components/ui/code-editor/code-languages.ts +29 -0
- package/src/components/ui/collapsible-panel/collapsible-panel.scss +38 -0
- package/src/components/ui/collapsible-panel/collapsible-panel.svelte +13 -0
- package/src/components/ui/collapsible-panel/index.ts +1 -0
- package/src/components/ui/combobox/combobox.scss +163 -0
- package/src/components/ui/combobox/index.ts +22 -0
- package/src/components/ui/date-value-control/date-value-calendar.svelte +128 -16
- package/src/components/ui/date-value-control/date-value-control-loader.scss +26 -0
- package/src/components/ui/date-value-control/date-value-control-loader.svelte +35 -13
- package/src/components/ui/date-value-control/date-value-control.scss +223 -0
- package/src/components/ui/date-value-control/date-value-control.svelte +62 -44
- package/src/components/ui/drawer/drawer-depth.ts +8 -0
- package/src/components/ui/dropdown-menu/dropdown-menu-content.svelte +2 -5
- package/src/components/ui/dropdown-menu/dropdown-menu-item.svelte +2 -5
- package/src/components/ui/dropdown-menu/dropdown-menu-separator.svelte +2 -2
- package/src/components/ui/dropdown-menu/dropdown-menu.scss +62 -0
- package/src/components/ui/kbd/kbd.scss +17 -0
- package/src/components/ui/kbd/kbd.svelte +3 -10
- package/src/components/ui/navigation-drawer/navigation-drawer.scss +40 -0
- package/src/components/ui/navigation-drawer/navigation-drawer.svelte +38 -0
- package/src/components/ui/popover/popover-content.svelte +3 -5
- package/src/components/ui/popover/popover.scss +18 -0
- package/src/components/ui/radio-group/index.ts +0 -1
- package/src/components/ui/radio-group/radio-card-item.svelte +7 -12
- package/src/components/ui/radio-group/radio-group.svelte +2 -2
- package/src/components/ui/radio-group/radio.scss +45 -0
- package/src/components/ui/select/select-content.svelte +5 -6
- package/src/components/ui/select/select-item.svelte +8 -8
- package/src/components/ui/select/select-scroll-down-button.svelte +3 -5
- package/src/components/ui/select/select-scroll-up-button.svelte +3 -5
- package/src/components/ui/select/select-trigger.svelte +6 -7
- package/src/components/ui/select/select.scss +126 -0
- package/src/components/ui/sheet/sheet-content.svelte +6 -34
- package/src/components/ui/sheet/sheet-description.svelte +2 -2
- package/src/components/ui/sheet/sheet-overlay.svelte +2 -21
- package/src/components/ui/sheet/sheet-title.svelte +2 -2
- package/src/components/ui/sheet/sheet.scss +221 -0
- package/src/components/ui/skeleton/skeleton.scss +20 -0
- package/src/components/ui/skeleton/skeleton.svelte +4 -16
- package/src/components/ui/sonner/sonner.scss +121 -0
- package/src/components/ui/sonner/sonner.svelte +11 -10
- package/src/components/ui/status-indicator/status-indicator.scss +48 -0
- package/src/components/ui/status-indicator/status-indicator.svelte +14 -14
- package/src/components/ui/tabs/tabs-content.svelte +2 -2
- package/src/components/ui/tabs/tabs-list.svelte +7 -7
- package/src/components/ui/tabs/tabs-trigger.svelte +2 -8
- package/src/components/ui/tabs/tabs.scss +86 -0
- package/src/components/ui/tabs/tabs.svelte +2 -2
- package/src/components/ui/timezone-picker/timezone-picker.svelte +152 -0
- package/src/core/api/admin-client.ts +2 -2
- package/src/core/bootstrap/admin-bootstrap.ts +396 -0
- package/src/core/bootstrap/admin-prepared-state.ts +213 -0
- package/src/core/bootstrap/admin-route-modules.ts +66 -0
- package/src/core/clipboard/copy-feedback.svelte.ts +43 -0
- package/src/core/forms/embedded-fields.ts +4 -8
- package/src/core/forms/field-editor-authoring.ts +8 -0
- package/src/core/forms/field-issue-focus.ts +4 -4
- package/src/core/forms/field-occurrence.ts +4 -7
- package/src/core/forms/form-controller.svelte.ts +14 -21
- package/src/core/forms/form-draft-recovery.ts +17 -4
- package/src/core/forms/form-issue-correlation.ts +13 -13
- package/src/core/forms/form-path.ts +17 -0
- package/src/core/forms/form-schema.ts +12 -43
- package/src/core/forms/form-validation.ts +7 -46
- package/src/core/forms/plugin-field-authoring.ts +6 -2
- package/src/core/forms/plugin-field-write.ts +2 -6
- package/src/core/i18n/admin-i18n.svelte.ts +18 -0
- package/src/core/i18n/format-admin-date-time.ts +19 -0
- package/src/core/i18n/humanize-identifier.ts +5 -0
- package/src/core/i18n/time-zone-label.ts +20 -0
- package/src/core/loaders/admin-view-host.svelte +72 -0
- package/src/core/loaders/admin-view-loader.svelte.ts +90 -0
- package/src/core/notifications/validation-toast.svelte +2 -2
- package/src/core/plugins/field-registry.ts +7 -8
- package/src/core/routing/admin-paths.ts +53 -2
- package/src/core/routing/admin-scroll.svelte.ts +74 -0
- package/src/core/routing/admin-view-selection.ts +78 -0
- package/src/core/runtime/admin-runtime.svelte.ts +131 -135
- package/src/core/schema/field-default.ts +33 -0
- package/src/core/schema/field-localization.ts +15 -0
- package/src/core/schema/read-document-path.ts +11 -0
- package/src/features/account/account-menu.scss +37 -0
- package/src/features/account/account-menu.svelte +115 -0
- package/src/features/{auth → account}/account-navigation.svelte +16 -19
- package/src/features/{auth → account}/account-route.svelte +206 -49
- package/src/features/account/account-security-controller.svelte.ts +159 -0
- package/src/features/{auth → account}/account-security-route.svelte +140 -42
- package/src/features/api-reference/api-reference-code.svelte +114 -0
- package/src/features/api-reference/api-reference-content.svelte +258 -0
- package/src/features/api-reference/api-reference-drawer.scss +74 -0
- package/src/features/api-reference/api-reference-examples.ts +381 -0
- package/src/features/api-reference/api-reference-schema.ts +332 -0
- package/src/features/api-reference/api-reference.scss +190 -0
- package/src/features/api-reference/api-reference.svelte +74 -0
- package/src/features/auth/auth-brand.svelte +5 -3
- package/src/features/auth/auth-field.svelte +92 -0
- package/src/features/auth/auth-frame.svelte +5 -8
- package/src/features/auth/auth.scss +122 -0
- package/src/features/auth/create-first-user-controller.svelte.ts +30 -60
- package/src/features/auth/create-first-user-route.svelte +83 -122
- package/src/features/auth/forgot-password-route.svelte +32 -24
- package/src/features/auth/login-route.svelte +69 -117
- package/src/features/auth/logout-button.scss +34 -0
- package/src/features/auth/logout-button.svelte +52 -0
- package/src/features/auth/request-verification-route.svelte +28 -23
- package/src/features/auth/reset-password-route.svelte +111 -41
- package/src/features/auth/verify-email-route.svelte +52 -15
- package/src/features/bulk-edit/bulk-edit-fields.ts +23 -0
- package/src/features/bulk-edit/bulk-edit.scss +152 -0
- package/src/features/bulk-edit/field-picker.svelte +176 -0
- package/src/features/collections/bulk/bulk-actions.svelte +148 -0
- package/src/features/collections/bulk/bulk-confirmation.svelte +153 -0
- package/src/features/collections/bulk/bulk-editor-loader.svelte +95 -0
- package/src/features/collections/bulk/bulk-editor.svelte +186 -0
- package/src/features/collections/collection-list-cell-values.ts +144 -0
- package/src/features/collections/collection-list-controller.svelte.ts +268 -379
- package/src/features/collections/collection-list-preferences-controller.svelte.ts +54 -40
- package/src/features/collections/collection-list-query.ts +223 -0
- package/src/features/collections/collection-list-results.svelte +205 -329
- package/src/features/collections/collection-list-route.svelte +143 -884
- package/src/features/collections/collection-list.scss +261 -0
- package/src/features/collections/collection-list.svelte.ts +362 -0
- package/src/features/collections/controls/column-picker.svelte +110 -0
- package/src/features/collections/controls/column-pill.svelte +62 -0
- package/src/features/collections/controls/filter-builder.svelte +193 -0
- package/src/features/collections/controls/filter-row.svelte +142 -0
- package/src/features/collections/controls/list-controls.scss +196 -0
- package/src/features/collections/controls/list-options.svelte +203 -0
- package/src/features/collections/controls/list-pagination.scss +78 -0
- package/src/features/collections/controls/list-pagination.svelte +115 -0
- package/src/features/collections/controls/list-toolbar.svelte +132 -0
- package/src/features/collections/controls/sort-heading.scss +52 -0
- package/src/features/collections/controls/sort-heading.svelte +78 -0
- package/src/features/collections/list-columns.ts +43 -0
- package/src/features/collections/list-workspace.ts +155 -54
- package/src/features/dashboard/dashboard-route.svelte +82 -86
- package/src/features/dashboard/dashboard.scss +131 -0
- package/src/features/development/development-tools.svelte +20 -36
- package/src/features/documents/document-action-bar.svelte +438 -0
- package/src/features/documents/document-api-view-loader.svelte +17 -6
- package/src/features/documents/document-api-view.scss +120 -0
- package/src/features/documents/document-api-view.svelte +169 -454
- package/src/features/documents/document-controller.svelte.ts +531 -617
- package/src/features/documents/document-credentials.scss +37 -0
- package/src/features/documents/document-credentials.svelte +72 -0
- package/src/features/documents/{document-route-dirty.ts → document-credentials.ts} +25 -0
- package/src/features/documents/document-field-sections.scss +39 -0
- package/src/features/documents/document-field-sections.svelte +4 -13
- package/src/features/documents/document-loading.scss +24 -0
- package/src/features/documents/document-lock-controller.svelte.ts +187 -0
- package/src/features/documents/document-operation-dialogs.svelte +110 -0
- package/src/features/documents/document-route-loader.svelte +17 -5
- package/src/features/documents/document-route.svelte +305 -811
- package/src/features/documents/document-schedule.scss +127 -0
- package/src/features/documents/document-schedule.svelte +323 -0
- package/src/features/documents/document-title.ts +25 -0
- package/src/features/documents/document.scss +274 -0
- package/src/features/documents/live-preview-panel.scss +117 -0
- package/src/features/documents/live-preview-panel.svelte +167 -168
- package/src/features/documents/live-preview.ts +2 -10
- package/src/features/documents/upload-document-preview-loader.svelte +26 -23
- package/src/features/localization/content-locale-switcher.scss +43 -0
- package/src/features/localization/content-locale-switcher.svelte +24 -17
- package/src/features/navigation/admin-breadcrumbs.scss +56 -0
- package/src/features/navigation/admin-breadcrumbs.svelte +102 -37
- package/src/features/navigation/admin-command-menu.svelte +38 -15
- package/src/features/navigation/admin-navigation.scss +133 -0
- package/src/features/navigation/admin-navigation.svelte +169 -0
- package/src/features/navigation/breadcrumb-context.svelte.ts +15 -0
- package/src/features/navigation/navigation-preference.svelte.ts +70 -0
- package/src/features/reference-browser/reference-browser-editor.svelte +180 -0
- package/src/features/reference-browser/reference-browser-list.scss +113 -0
- package/src/features/reference-browser/reference-browser-list.svelte +370 -0
- package/src/features/reference-browser/reference-browser-loader.svelte +26 -8
- package/src/features/reference-browser/reference-browser-workflow.svelte.ts +336 -239
- package/src/features/reference-browser/reference-browser.scss +217 -0
- package/src/features/reference-browser/reference-browser.svelte +154 -797
- package/src/features/reference-browser/reference-collection-picker.svelte +116 -0
- package/src/features/reference-browser/reference-list-query.ts +35 -0
- package/src/features/uploads/bulk-upload-controller.svelte.ts +604 -0
- package/src/features/uploads/bulk-upload-edit-all.svelte +92 -0
- package/src/features/uploads/bulk-upload-editor.svelte +191 -0
- package/src/features/uploads/bulk-upload-file-picker.svelte +70 -0
- package/src/features/uploads/bulk-upload-remote.svelte +100 -0
- package/src/features/uploads/bulk-upload-route-loader.svelte +54 -0
- package/src/features/uploads/bulk-upload-route.svelte +172 -592
- package/src/features/uploads/bulk-upload-sidebar.svelte +125 -0
- package/src/features/uploads/bulk-upload.scss +526 -0
- package/src/features/uploads/bulk-upload.ts +105 -14
- package/src/features/uploads/crop-surface.ts +150 -0
- package/src/features/uploads/image-editor.svelte +231 -0
- package/src/features/uploads/rendition-preview.svelte +64 -0
- package/src/features/uploads/upload-control.svelte +340 -0
- package/src/features/uploads/upload-document-contracts.ts +30 -0
- package/src/features/uploads/upload-draft.svelte.ts +294 -0
- package/src/features/uploads/upload-metadata-fields.scss +32 -0
- package/src/features/uploads/upload-metadata-fields.svelte +8 -7
- package/src/features/uploads/upload-thumbnail.svelte +47 -0
- package/src/features/uploads/upload.scss +361 -0
- package/src/features/versions/version-comparison.svelte +361 -0
- package/src/features/versions/version-diff-fields.svelte +136 -0
- package/src/features/versions/version-diff.ts +296 -41
- package/src/features/versions/version-history-controller.svelte.ts +311 -0
- package/src/features/versions/version-history-route-loader.svelte +32 -0
- package/src/features/versions/version-history-route.svelte +157 -522
- package/src/features/versions/version-history.scss +444 -0
- package/src/features/versions/version-history.ts +45 -0
- package/src/features/versions/version-table.svelte +91 -0
- package/src/fields/embedded-schema-draft-editor.scss +48 -0
- package/src/fields/embedded-schema-draft-editor.svelte +24 -16
- package/src/fields/field-collapsible.svelte +14 -8
- package/src/fields/field-layout.scss +171 -0
- package/src/fields/field-layout.svelte +3 -5
- package/src/fields/field-renderer.svelte +17 -29
- package/src/fields/field-shell.svelte +1 -1
- package/src/fields/field-tab-layout.svelte +25 -19
- package/src/fields/join/join-field-controller.svelte.ts +513 -0
- package/src/fields/join/join-field-values.ts +111 -0
- package/src/fields/join/join-field.scss +189 -0
- package/src/fields/join/join-field.svelte +164 -332
- package/src/fields/live-validation-feedback.svelte +4 -3
- package/src/fields/local-field-editor.svelte +2 -2
- package/src/fields/nested/block-name-input.svelte +11 -12
- package/src/fields/nested/block-picker.scss +128 -0
- package/src/fields/nested/block-picker.svelte +81 -0
- package/src/fields/nested/block-placeholder.svg +2 -0
- package/src/fields/nested/nested-field.scss +331 -0
- package/src/fields/nested/nested-field.svelte +265 -245
- package/src/fields/nested/sortable-row.svelte +9 -7
- package/src/fields/plugin-field.svelte +4 -6
- package/src/fields/point/point-field.svelte +51 -38
- package/src/fields/primitive-list/primitive-list-field.svelte +63 -19
- package/src/fields/primitive-list/primitive-list.scss +109 -0
- package/src/fields/radio/radio-field.svelte +2 -1
- package/src/fields/relationship/relationship-field-controller.svelte.ts +81 -41
- package/src/fields/relationship/relationship-field.svelte +144 -175
- package/src/fields/relationship/relationship-lookup-controller.svelte.ts +58 -30
- package/src/fields/relationship/relationship-query.ts +2 -10
- package/src/fields/relationship/relationship-quick-picker-controller.svelte.ts +36 -62
- package/src/fields/relationship/relationship-quick-picker.svelte +178 -227
- package/src/fields/relationship/relationship-selection.svelte +120 -0
- package/src/fields/relationship/relationship-value.ts +46 -7
- package/src/fields/relationship/relationship.scss +182 -0
- package/src/fields/scalar/code-field.svelte +101 -0
- package/src/fields/scalar/date-control-value.ts +13 -0
- package/src/fields/scalar/scalar-field.svelte +25 -67
- package/src/fields/select/select-field.svelte +148 -94
- package/src/fields/text/slug-field.scss +28 -0
- package/src/fields/text/slug-field.svelte +19 -15
- package/src/fields/text/text-field.svelte +1 -2
- package/src/fields/ui/ui-field.svelte +7 -4
- package/src/fields/virtual/virtual-field.svelte +2 -5
- package/src/index.ts +1 -2
- package/src/routing.ts +2 -0
- package/src/app/deferred-redirect.svelte +0 -23
- package/src/components/code-block/code-block.svelte +0 -107
- package/src/components/ui/bulk-action-bar/bulk-action-bar.svelte +0 -50
- package/src/components/ui/bulk-action-bar/index.ts +0 -1
- package/src/components/ui/button/index.ts +0 -8
- package/src/components/ui/calendar/calendar-caption.svelte +0 -72
- package/src/components/ui/calendar/calendar-cell.svelte +0 -20
- package/src/components/ui/calendar/calendar-day.svelte +0 -27
- package/src/components/ui/calendar/calendar-grid-row.svelte +0 -13
- package/src/components/ui/calendar/calendar-grid.svelte +0 -17
- package/src/components/ui/calendar/calendar-head-cell.svelte +0 -20
- package/src/components/ui/calendar/calendar-header.svelte +0 -20
- package/src/components/ui/calendar/calendar-heading.svelte +0 -17
- package/src/components/ui/calendar/calendar-month-select.svelte +0 -45
- package/src/components/ui/calendar/calendar-month.svelte +0 -16
- package/src/components/ui/calendar/calendar-months.svelte +0 -20
- package/src/components/ui/calendar/calendar-nav.svelte +0 -20
- package/src/components/ui/calendar/calendar-next-button.svelte +0 -30
- package/src/components/ui/calendar/calendar-prev-button.svelte +0 -30
- package/src/components/ui/calendar/calendar-year-select.svelte +0 -44
- package/src/components/ui/calendar/calendar.svelte +0 -118
- package/src/components/ui/calendar/index.ts +0 -1
- package/src/components/ui/checkbox/checkbox.svelte +0 -35
- package/src/components/ui/checkbox/index.ts +0 -1
- package/src/components/ui/dialog/dialog-close.svelte +0 -11
- package/src/components/ui/dialog/dialog-content.svelte +0 -52
- package/src/components/ui/dialog/dialog-description.svelte +0 -20
- package/src/components/ui/dialog/dialog-footer.svelte +0 -20
- package/src/components/ui/dialog/dialog-header.svelte +0 -20
- package/src/components/ui/dialog/dialog-overlay.svelte +0 -20
- package/src/components/ui/dialog/dialog-title.svelte +0 -17
- package/src/components/ui/dialog/dialog-trigger.svelte +0 -11
- package/src/components/ui/dialog/dialog.svelte +0 -7
- package/src/components/ui/dialog/index.ts +0 -8
- package/src/components/ui/empty-state/empty-state.svelte +0 -34
- package/src/components/ui/empty-state/index.ts +0 -1
- package/src/components/ui/input/index.ts +0 -1
- package/src/components/ui/pagination/index.ts +0 -1
- package/src/components/ui/pagination/pagination.svelte +0 -88
- package/src/components/ui/radio-group/radio-group-item.svelte +0 -17
- package/src/components/ui/slider/index.ts +0 -3
- package/src/components/ui/slider/slider-content.svelte +0 -59
- package/src/components/ui/slider/slider.svelte +0 -35
- package/src/components/ui/table/index.ts +0 -6
- package/src/components/ui/table/table-body.svelte +0 -20
- package/src/components/ui/table/table-cell.svelte +0 -23
- package/src/components/ui/table/table-head.svelte +0 -23
- package/src/components/ui/table/table-header.svelte +0 -20
- package/src/components/ui/table/table-row.svelte +0 -23
- package/src/components/ui/table/table.svelte +0 -22
- package/src/components/ui/textarea/index.ts +0 -1
- package/src/components/ui/tooltip/index.ts +0 -4
- package/src/components/ui/tooltip/tooltip-content.svelte +0 -50
- package/src/components/ui/tooltip/tooltip-provider.svelte +0 -7
- package/src/components/ui/tooltip/tooltip-trigger.svelte +0 -7
- package/src/components/ui/tooltip/tooltip.svelte +0 -7
- package/src/features/auth/account-menu.svelte +0 -159
- package/src/features/auth/account-security-controller.svelte.ts +0 -119
- package/src/features/collections/collection-list-bulk-actions.svelte +0 -143
- package/src/features/collections/collection-list-bulk-editor.svelte +0 -157
- package/src/features/collections/collection-list-filter-popover.svelte +0 -238
- package/src/features/collections/collection-list-workspace-toolbar.svelte +0 -409
- package/src/features/collections/collection-table-skeleton.svelte +0 -44
- package/src/features/documents/document-heading.ts +0 -20
- package/src/features/documents/upload-document-preview.svelte +0 -525
|
@@ -6,11 +6,13 @@
|
|
|
6
6
|
id,
|
|
7
7
|
index,
|
|
8
8
|
disabled = false,
|
|
9
|
+
invalid = false,
|
|
9
10
|
children,
|
|
10
11
|
}: {
|
|
11
12
|
id: string;
|
|
12
13
|
index: number;
|
|
13
14
|
disabled?: boolean;
|
|
15
|
+
invalid?: boolean;
|
|
14
16
|
children: Snippet<[ReturnType<typeof useSortable>]>;
|
|
15
17
|
} = $props();
|
|
16
18
|
const sortable = useSortable({
|
|
@@ -21,12 +23,12 @@
|
|
|
21
23
|
});
|
|
22
24
|
</script>
|
|
23
25
|
|
|
24
|
-
<
|
|
25
|
-
class=
|
|
26
|
-
|
|
27
|
-
sortable.isDragging.current && "opacity-50",
|
|
28
|
-
]}
|
|
26
|
+
<div
|
|
27
|
+
class="ridu-repeated-row-sortable"
|
|
28
|
+
data-dragging={sortable.isDragging.current}
|
|
29
29
|
{@attach sortable.ref}
|
|
30
30
|
>
|
|
31
|
-
{
|
|
32
|
-
|
|
31
|
+
<section class="ridu-repeated-row" data-invalid={invalid}>
|
|
32
|
+
{@render children(sortable)}
|
|
33
|
+
</section>
|
|
34
|
+
</div>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import type { Component } from "svelte";
|
|
3
3
|
import { SvelteMap } from "svelte/reactivity";
|
|
4
4
|
import type {
|
|
5
5
|
EmbeddedSchemaDraft,
|
|
@@ -46,12 +46,9 @@
|
|
|
46
46
|
const Editor = extension.registration.component as Component<
|
|
47
47
|
Omit<PluginFieldProps<unknown, unknown, FieldType>, "config"> & { config?: unknown }
|
|
48
48
|
>;
|
|
49
|
-
|
|
49
|
+
$effect(() => field.destroy);
|
|
50
50
|
const drafts = new SvelteMap<EmbeddedSchemaDraft, HostedSchemaDraft>();
|
|
51
51
|
const draftAliases = new WeakMap<EmbeddedSchemaDraft, EmbeddedSchemaDraft>();
|
|
52
|
-
onDestroy(() => {
|
|
53
|
-
for (const draft of drafts.keys()) draft.discard();
|
|
54
|
-
});
|
|
55
52
|
const authoring: FieldAuthoringHost = {
|
|
56
53
|
schemaForm,
|
|
57
54
|
schemaHeader,
|
|
@@ -90,13 +87,14 @@
|
|
|
90
87
|
get locale() {
|
|
91
88
|
return form.contentLocale;
|
|
92
89
|
},
|
|
90
|
+
canCreateDocument: (collection) => runtime.collectionOperations[collection]?.create === true,
|
|
93
91
|
referenceBrowser: ReferenceBrowser,
|
|
94
92
|
findDocument: (collection, id, signal) =>
|
|
95
93
|
runtime.client.find(collection, id, { signal, locale: form.contentLocale }),
|
|
96
94
|
async requestPlugin<Result>(path: string, body: unknown, signal?: AbortSignal) {
|
|
97
95
|
const owner = extension.owner;
|
|
98
96
|
if (owner === undefined) {
|
|
99
|
-
throw new Error("This field
|
|
97
|
+
throw new Error("This field editor does not have an owning plugin");
|
|
100
98
|
}
|
|
101
99
|
return runtime.client.requestPlugin<Result>(owner, path, body, { signal });
|
|
102
100
|
},
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import "@admin/fields/field-layout.scss";
|
|
2
3
|
import type { SchemaField } from "@riducms/protocol";
|
|
3
|
-
import { fieldControlARIA } from "@riducms/ui";
|
|
4
|
+
import { fieldControlARIA, Input } from "@riducms/ui";
|
|
4
5
|
|
|
5
|
-
import { Input } from "@admin/components/ui/input";
|
|
6
6
|
import type { FormController } from "@admin/core/forms/form-controller.svelte";
|
|
7
7
|
import { getAdminRuntime } from "@admin/core/runtime/admin-runtime.svelte";
|
|
8
|
-
import
|
|
8
|
+
import FieldMessages from "@admin/fields/field-messages.svelte";
|
|
9
9
|
|
|
10
10
|
let { field, form }: { field: SchemaField; form: FormController } = $props();
|
|
11
11
|
const runtime = getAdminRuntime();
|
|
12
|
-
const value = $derived(
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
const value = $derived.by(() => {
|
|
13
|
+
const current = form.get(field.path);
|
|
14
|
+
return Array.isArray(current) ? (current as number[]) : [];
|
|
15
|
+
});
|
|
15
16
|
const issues = $derived(form.issuesFor(field.path));
|
|
16
17
|
const editingBlocked = $derived(field.admin.readOnly === true || form.editingBlocked);
|
|
17
18
|
const controlARIA = $derived(
|
|
@@ -28,35 +29,47 @@
|
|
|
28
29
|
}
|
|
29
30
|
</script>
|
|
30
31
|
|
|
31
|
-
<
|
|
32
|
-
<
|
|
33
|
-
<
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
32
|
+
<div data-field-path={field.path}>
|
|
33
|
+
<FieldMessages controlID={field.id} {issues} description={field.admin.description}>
|
|
34
|
+
<div class="ridu-point-field">
|
|
35
|
+
<label class="ridu-point-field__coordinate">
|
|
36
|
+
<span>
|
|
37
|
+
{field.admin.label} - {runtime.i18n.t("fields:longitude")}
|
|
38
|
+
{#if field.required}
|
|
39
|
+
<span class="ridu-field-required" aria-hidden="true">*</span>
|
|
40
|
+
{/if}
|
|
41
|
+
</span>
|
|
42
|
+
<Input
|
|
43
|
+
id={field.id}
|
|
44
|
+
type="number"
|
|
45
|
+
min="-180"
|
|
46
|
+
max="180"
|
|
47
|
+
step="any"
|
|
48
|
+
value={value[0] ?? ""}
|
|
49
|
+
readonly={editingBlocked}
|
|
50
|
+
{...controlARIA}
|
|
51
|
+
oninput={(event) => setCoordinate(0, event.currentTarget.valueAsNumber)}
|
|
52
|
+
/>
|
|
53
|
+
</label>
|
|
54
|
+
<label class="ridu-point-field__coordinate">
|
|
55
|
+
<span>
|
|
56
|
+
{field.admin.label} - {runtime.i18n.t("fields:latitude")}
|
|
57
|
+
{#if field.required}
|
|
58
|
+
<span class="ridu-field-required" aria-hidden="true">*</span>
|
|
59
|
+
{/if}
|
|
60
|
+
</span>
|
|
61
|
+
<Input
|
|
62
|
+
id={`${field.id}-latitude`}
|
|
63
|
+
type="number"
|
|
64
|
+
min="-90"
|
|
65
|
+
max="90"
|
|
66
|
+
step="any"
|
|
67
|
+
value={value[1] ?? ""}
|
|
68
|
+
readonly={editingBlocked}
|
|
69
|
+
{...controlARIA}
|
|
70
|
+
oninput={(event) => setCoordinate(1, event.currentTarget.valueAsNumber)}
|
|
71
|
+
/>
|
|
72
|
+
</label>
|
|
73
|
+
</div>
|
|
74
|
+
</FieldMessages>
|
|
75
|
+
</div>
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { tick } from "svelte";
|
|
3
3
|
import type { SchemaField } from "@riducms/protocol";
|
|
4
|
-
import { fieldControlARIA } from "@riducms/ui";
|
|
4
|
+
import { fieldControlARIA, Button, Input } from "@riducms/ui";
|
|
5
|
+
import PlusIcon from "~icons/lucide/plus";
|
|
6
|
+
import "@admin/fields/primitive-list/primitive-list.scss";
|
|
5
7
|
import ArrowUpIcon from "~icons/lucide/arrow-up";
|
|
6
8
|
import ArrowDownIcon from "~icons/lucide/arrow-down";
|
|
7
9
|
import XIcon from "~icons/lucide/x";
|
|
8
|
-
|
|
9
|
-
import { Input } from "@admin/components/ui/input";
|
|
10
|
+
|
|
10
11
|
import type { FormController } from "@admin/core/forms/form-controller.svelte";
|
|
11
12
|
import { getAdminI18n } from "@riducms/plugin";
|
|
12
13
|
import FieldShell from "@admin/fields/field-shell.svelte";
|
|
@@ -38,7 +39,7 @@
|
|
|
38
39
|
let container: HTMLDivElement;
|
|
39
40
|
let announcement = $state("");
|
|
40
41
|
// Only DOM identity lives here. The form owns all values, including unfinished numeric input.
|
|
41
|
-
let keys = $state<string[]>([]);
|
|
42
|
+
let keys = $state.raw<string[]>([]);
|
|
42
43
|
const itemKey = (index: number) => keys[index] ?? `initial-${index}`;
|
|
43
44
|
|
|
44
45
|
async function focusItem(index: number) {
|
|
@@ -59,6 +60,20 @@
|
|
|
59
60
|
announcement = i18n.t("fields:listAdded", { number: index + 1 });
|
|
60
61
|
await focusItem(index);
|
|
61
62
|
}
|
|
63
|
+
async function typeNewItem(event: Event) {
|
|
64
|
+
const input = event.currentTarget as HTMLInputElement;
|
|
65
|
+
if (!canAdd || input.value === "") return;
|
|
66
|
+
const index = values.length;
|
|
67
|
+
update(
|
|
68
|
+
[...values, field.type === "number-list" ? primitiveNumberInput(input.value) : input.value],
|
|
69
|
+
[...values.map((_, at) => itemKey(at)), crypto.randomUUID()]
|
|
70
|
+
);
|
|
71
|
+
input.value = "";
|
|
72
|
+
await focusItem(index);
|
|
73
|
+
const item = container.querySelector<HTMLInputElement>(`[data-list-item="${index}"]`);
|
|
74
|
+
item?.setSelectionRange(item.value.length, item.value.length);
|
|
75
|
+
}
|
|
76
|
+
|
|
62
77
|
function edit(index: number, value: string) {
|
|
63
78
|
if (editingBlocked) return;
|
|
64
79
|
const next = [...values];
|
|
@@ -87,6 +102,11 @@
|
|
|
87
102
|
await focusItem(destination);
|
|
88
103
|
}
|
|
89
104
|
function keyboard(event: KeyboardEvent, index: number) {
|
|
105
|
+
if (event.key === "Enter" && !event.isComposing) {
|
|
106
|
+
event.preventDefault();
|
|
107
|
+
container.querySelector<HTMLInputElement>("[data-list-entry]")?.focus();
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
90
110
|
if (!event.altKey || (event.key !== "ArrowUp" && event.key !== "ArrowDown")) return;
|
|
91
111
|
event.preventDefault();
|
|
92
112
|
return move(index, event.key === "ArrowUp" ? -1 : 1);
|
|
@@ -94,21 +114,32 @@
|
|
|
94
114
|
</script>
|
|
95
115
|
|
|
96
116
|
<FieldShell {field} {issues}>
|
|
97
|
-
<div
|
|
98
|
-
|
|
117
|
+
<div
|
|
118
|
+
bind:this={container}
|
|
119
|
+
class="ridu-primitive-list"
|
|
120
|
+
data-invalid={issues.length > 0}
|
|
121
|
+
data-readonly={editingBlocked}
|
|
122
|
+
>
|
|
123
|
+
<p id="{field.id}-count" class="ridu-primitive-list__count">
|
|
99
124
|
{i18n.t("fields:itemCount", { count: values.length })}
|
|
100
125
|
{#if minimum > 0}
|
|
101
|
-
· {i18n.t("fields:minimum", { count: minimum })}
|
|
126
|
+
· {i18n.t("fields:minimum", { count: minimum })}
|
|
127
|
+
{/if}
|
|
102
128
|
{#if field.list?.maxRows}
|
|
103
|
-
· {i18n.t("fields:maximum", { count: field.list.maxRows })}
|
|
129
|
+
· {i18n.t("fields:maximum", { count: field.list.maxRows })}
|
|
130
|
+
{/if}
|
|
104
131
|
</p>
|
|
105
|
-
{#if values.length === 0}
|
|
132
|
+
{#if values.length === 0}
|
|
133
|
+
<p class="ridu-primitive-list__empty">
|
|
106
134
|
{i18n.t("fields:listEmpty")}
|
|
107
|
-
</p>
|
|
108
|
-
|
|
135
|
+
</p>
|
|
136
|
+
{/if}
|
|
137
|
+
<ol class="ridu-primitive-list__items" aria-label={field.admin.label}>
|
|
109
138
|
{#each values as value, index (itemKey(index))}
|
|
110
|
-
<li class="
|
|
139
|
+
<li class="ridu-primitive-list__item">
|
|
111
140
|
<Input
|
|
141
|
+
class="ridu-primitive-list__input"
|
|
142
|
+
style={`width: ${Math.max(1, String(value ?? "").length) + 1}ch`}
|
|
112
143
|
id={index === 0 ? field.id : `${field.id}-item-${itemKey(index)}`}
|
|
113
144
|
data-list-item={index}
|
|
114
145
|
aria-label={i18n.t("fields:listItem", {
|
|
@@ -126,45 +157,58 @@
|
|
|
126
157
|
<Button
|
|
127
158
|
variant="ghost"
|
|
128
159
|
size="icon"
|
|
160
|
+
class="ridu-primitive-list__move"
|
|
129
161
|
aria-label={i18n.t("fields:listMoveUp", { number: index + 1 })}
|
|
130
162
|
disabled={editingBlocked || index === 0}
|
|
131
163
|
onclick={() => move(index, -1)}
|
|
132
164
|
>
|
|
133
|
-
<ArrowUpIcon
|
|
165
|
+
<ArrowUpIcon />
|
|
134
166
|
</Button>
|
|
135
167
|
<Button
|
|
136
168
|
variant="ghost"
|
|
137
169
|
size="icon"
|
|
170
|
+
class="ridu-primitive-list__move"
|
|
138
171
|
aria-label={i18n.t("fields:listMoveDown", { number: index + 1 })}
|
|
139
172
|
disabled={editingBlocked || index === values.length - 1}
|
|
140
173
|
onclick={() => move(index, 1)}
|
|
141
174
|
>
|
|
142
|
-
<ArrowDownIcon
|
|
175
|
+
<ArrowDownIcon />
|
|
143
176
|
</Button>
|
|
144
177
|
<Button
|
|
145
178
|
variant="ghost"
|
|
146
179
|
size="icon"
|
|
180
|
+
class="ridu-primitive-list__remove"
|
|
147
181
|
aria-label={i18n.t("fields:listRemove", { number: index + 1 })}
|
|
148
182
|
disabled={editingBlocked}
|
|
149
183
|
onclick={() => remove(index)}
|
|
150
184
|
>
|
|
151
|
-
<XIcon
|
|
185
|
+
<XIcon />
|
|
152
186
|
</Button>
|
|
153
187
|
</li>
|
|
154
188
|
{/each}
|
|
155
189
|
</ol>
|
|
190
|
+
<input
|
|
191
|
+
class="ridu-primitive-list__entry"
|
|
192
|
+
data-list-entry
|
|
193
|
+
aria-label={`${field.admin.label}: ${i18n.t("fields:listAdd")}`}
|
|
194
|
+
placeholder={field.admin.placeholder}
|
|
195
|
+
disabled={!canAdd}
|
|
196
|
+
autocomplete="off"
|
|
197
|
+
oninput={typeNewItem}
|
|
198
|
+
/>
|
|
156
199
|
<Button
|
|
157
200
|
id={values.length === 0 ? field.id : undefined}
|
|
158
201
|
data-list-add
|
|
159
202
|
aria-label={i18n.t("fields:listAdd")}
|
|
160
203
|
{...controlARIA}
|
|
161
|
-
variant="
|
|
162
|
-
|
|
204
|
+
variant="ghost"
|
|
205
|
+
size="icon-sm"
|
|
206
|
+
class="ridu-primitive-list__add"
|
|
163
207
|
disabled={!canAdd}
|
|
164
208
|
onclick={add}
|
|
165
209
|
>
|
|
166
|
-
|
|
210
|
+
<PlusIcon aria-hidden="true" />
|
|
167
211
|
</Button>
|
|
168
|
-
<p class="
|
|
212
|
+
<p class="ridu-primitive-list__announcement" role="status">{announcement}</p>
|
|
169
213
|
</div>
|
|
170
214
|
</FieldShell>
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
@use "@riducms/ui/styles.scss" as ui;
|
|
2
|
+
|
|
3
|
+
@layer ridu.components {
|
|
4
|
+
.ridu-primitive-list {
|
|
5
|
+
@include ui.control-surface;
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-wrap: wrap;
|
|
8
|
+
align-items: center;
|
|
9
|
+
gap: 4px;
|
|
10
|
+
min-height: 40px;
|
|
11
|
+
padding: 5px 10px;
|
|
12
|
+
&[data-invalid="true"] {
|
|
13
|
+
border-color: var(--control-invalid-border);
|
|
14
|
+
background: var(--control-invalid-surface);
|
|
15
|
+
}
|
|
16
|
+
&[data-readonly="true"] {
|
|
17
|
+
background: var(--control-surface-disabled);
|
|
18
|
+
color: var(--control-disabled-foreground);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
.ridu-primitive-list__items {
|
|
22
|
+
display: contents;
|
|
23
|
+
list-style: none;
|
|
24
|
+
margin: 0;
|
|
25
|
+
padding: 0;
|
|
26
|
+
}
|
|
27
|
+
.ridu-primitive-list__item {
|
|
28
|
+
display: flex;
|
|
29
|
+
align-items: center;
|
|
30
|
+
max-width: 100%;
|
|
31
|
+
gap: 2px;
|
|
32
|
+
padding: 0 3px 0 6px;
|
|
33
|
+
background: var(--background-layer);
|
|
34
|
+
border: 1px solid var(--control-border);
|
|
35
|
+
border-radius: 2px;
|
|
36
|
+
}
|
|
37
|
+
.ridu-primitive-list__input {
|
|
38
|
+
min-width: 2ch;
|
|
39
|
+
max-width: 100%;
|
|
40
|
+
min-height: 24px;
|
|
41
|
+
height: 24px;
|
|
42
|
+
padding: 0;
|
|
43
|
+
border: 0;
|
|
44
|
+
border-radius: 0;
|
|
45
|
+
background: transparent;
|
|
46
|
+
box-shadow: none;
|
|
47
|
+
font: inherit;
|
|
48
|
+
&:focus-visible {
|
|
49
|
+
outline: none;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
.ridu-primitive-list__item:focus-within {
|
|
53
|
+
outline: 1px solid var(--control-border-hover);
|
|
54
|
+
}
|
|
55
|
+
.ridu-primitive-list__entry {
|
|
56
|
+
flex: 1;
|
|
57
|
+
width: 2ch;
|
|
58
|
+
min-width: 2ch;
|
|
59
|
+
padding: 0;
|
|
60
|
+
border: 0;
|
|
61
|
+
outline: none;
|
|
62
|
+
color: inherit;
|
|
63
|
+
font: inherit;
|
|
64
|
+
background: transparent;
|
|
65
|
+
}
|
|
66
|
+
.ridu-primitive-list__empty {
|
|
67
|
+
color: var(--ink-faint);
|
|
68
|
+
margin: 0;
|
|
69
|
+
}
|
|
70
|
+
.ridu-primitive-list__count,
|
|
71
|
+
.ridu-primitive-list__announcement {
|
|
72
|
+
@include ui.visually-hidden;
|
|
73
|
+
}
|
|
74
|
+
.ridu-primitive-list__remove,
|
|
75
|
+
.ridu-primitive-list__add,
|
|
76
|
+
.ridu-primitive-list__move {
|
|
77
|
+
width: 22px;
|
|
78
|
+
height: 24px;
|
|
79
|
+
padding: 0;
|
|
80
|
+
color: var(--foreground-muted);
|
|
81
|
+
svg {
|
|
82
|
+
width: 12px;
|
|
83
|
+
height: 12px;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
.ridu-primitive-list__move {
|
|
87
|
+
position: absolute;
|
|
88
|
+
width: 1px;
|
|
89
|
+
height: 1px;
|
|
90
|
+
overflow: hidden;
|
|
91
|
+
clip-path: inset(50%);
|
|
92
|
+
&:focus-visible {
|
|
93
|
+
position: static;
|
|
94
|
+
width: 22px;
|
|
95
|
+
height: 24px;
|
|
96
|
+
clip-path: none;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
.ridu-primitive-list__remove,
|
|
100
|
+
.ridu-primitive-list__move {
|
|
101
|
+
svg {
|
|
102
|
+
width: 16px;
|
|
103
|
+
height: 16px;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
.ridu-primitive-list__add {
|
|
107
|
+
margin-inline-start: auto;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { RadioCardItem, RadioGroup } from "@admin/components/ui/radio-group";
|
|
6
6
|
import type { FormController } from "@admin/core/forms/form-controller.svelte";
|
|
7
7
|
import FieldShell from "@admin/fields/field-shell.svelte";
|
|
8
|
+
import "@admin/fields/field-layout.scss";
|
|
8
9
|
|
|
9
10
|
let { field, form }: { field: SchemaField; form: FormController } = $props();
|
|
10
11
|
const value = $derived(String(form.get(field.path) ?? ""));
|
|
@@ -20,7 +21,7 @@
|
|
|
20
21
|
<FieldShell {field} {issues}>
|
|
21
22
|
<RadioGroup
|
|
22
23
|
id={field.id}
|
|
23
|
-
class="
|
|
24
|
+
class="ridu-field-radio-options"
|
|
24
25
|
name={field.path}
|
|
25
26
|
{value}
|
|
26
27
|
required={field.required && (!field.dynamicDefault || form.get(field.path) !== undefined)}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { documentLabel } from "@admin/features/documents/document-title";
|
|
1
2
|
import type { SchemaField } from "@riducms/protocol";
|
|
2
3
|
|
|
3
4
|
import type { AdminDocument } from "@admin/core/api/admin-client";
|
|
@@ -7,6 +8,9 @@ import { localizeSchemaCollection } from "@admin/core/i18n/localized-schema";
|
|
|
7
8
|
|
|
8
9
|
import {
|
|
9
10
|
selectedRelationshipIDs,
|
|
11
|
+
relationshipReferences,
|
|
12
|
+
relationshipKey,
|
|
13
|
+
type PolymorphicReference,
|
|
10
14
|
updateRelationshipValue,
|
|
11
15
|
} from "@admin/fields/relationship/relationship-value";
|
|
12
16
|
|
|
@@ -23,6 +27,8 @@ export class RelationshipFieldController {
|
|
|
23
27
|
browserOpen = $state(false);
|
|
24
28
|
initialDocument = $state.raw<AdminDocument>();
|
|
25
29
|
initialDocumentID = $state<string>();
|
|
30
|
+
initialCreate = $state(false);
|
|
31
|
+
initialFile = $state.raw<File>();
|
|
26
32
|
#formRevision = 0;
|
|
27
33
|
|
|
28
34
|
constructor(readonly options: RelationshipFieldControllerOptions) {
|
|
@@ -52,16 +58,16 @@ export class RelationshipFieldController {
|
|
|
52
58
|
});
|
|
53
59
|
|
|
54
60
|
$effect(() => {
|
|
55
|
-
const
|
|
56
|
-
const
|
|
61
|
+
const references = this.references;
|
|
62
|
+
const locale = this.options.form.contentLocale;
|
|
57
63
|
const revision = this.options.runtime.documentRevision;
|
|
58
|
-
if (
|
|
64
|
+
if (references.length === 0) {
|
|
59
65
|
this.documents = {};
|
|
60
66
|
this.hydrationError = undefined;
|
|
61
67
|
return;
|
|
62
68
|
}
|
|
63
69
|
const request = new AbortController();
|
|
64
|
-
this.#hydrateSelected(
|
|
70
|
+
this.#hydrateSelected(references, locale, revision, request.signal);
|
|
65
71
|
return () => request.abort();
|
|
66
72
|
});
|
|
67
73
|
}
|
|
@@ -95,6 +101,48 @@ export class RelationshipFieldController {
|
|
|
95
101
|
: localizeSchemaCollection(collection, this.options.runtime.i18n);
|
|
96
102
|
}
|
|
97
103
|
|
|
104
|
+
get references() {
|
|
105
|
+
return relationshipReferences(
|
|
106
|
+
this.options.form.get(this.options.field.path),
|
|
107
|
+
this.hasMany,
|
|
108
|
+
this.polymorphic,
|
|
109
|
+
this.targets[0]?.collectionSlug ?? ""
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
get selections() {
|
|
114
|
+
return this.references.map((reference) => ({
|
|
115
|
+
...reference,
|
|
116
|
+
key: relationshipKey(reference),
|
|
117
|
+
label: this.label(reference.id, reference.relationTo),
|
|
118
|
+
document: this.documents[relationshipKey(reference)],
|
|
119
|
+
}));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
setReferences = (references: readonly PolymorphicReference[]) => {
|
|
123
|
+
if (this.options.field.admin.readOnly || this.options.form.editingBlocked) return;
|
|
124
|
+
const values = references.map((reference) => (this.polymorphic ? reference : reference.id));
|
|
125
|
+
this.options.form.set(
|
|
126
|
+
this.options.field.path,
|
|
127
|
+
this.hasMany ? values : (values[0] ?? (this.polymorphic ? null : ""))
|
|
128
|
+
);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
removeReference = (reference: PolymorphicReference) => {
|
|
132
|
+
this.setReferences(
|
|
133
|
+
this.references.filter(
|
|
134
|
+
(candidate) => relationshipKey(candidate) !== relationshipKey(reference)
|
|
135
|
+
)
|
|
136
|
+
);
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
move = (from: number, to: number) => {
|
|
140
|
+
const references = [...this.references];
|
|
141
|
+
const [moved] = references.splice(from, 1);
|
|
142
|
+
if (moved) references.splice(to, 0, moved);
|
|
143
|
+
this.setReferences(references);
|
|
144
|
+
};
|
|
145
|
+
|
|
98
146
|
get selectedIDs() {
|
|
99
147
|
return selectedRelationshipIDs(
|
|
100
148
|
this.options.form.get(this.options.field.path),
|
|
@@ -116,32 +164,30 @@ export class RelationshipFieldController {
|
|
|
116
164
|
this.selectedTarget = target;
|
|
117
165
|
};
|
|
118
166
|
|
|
119
|
-
label = (id: string) => {
|
|
120
|
-
const document = this.documents[id];
|
|
167
|
+
label = (id: string, target = this.selectedTarget) => {
|
|
168
|
+
const document = this.documents[relationshipKey({ relationTo: target, id })];
|
|
121
169
|
if (document === undefined) return id;
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
170
|
+
const collection = this.options.runtime.manifest?.collections.find(
|
|
171
|
+
(collection) => collection.slug === target
|
|
172
|
+
);
|
|
173
|
+
if (collection?.capabilities.upload) return String(document.filename ?? id);
|
|
174
|
+
return documentLabel(collection, document);
|
|
125
175
|
};
|
|
126
176
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
mediaURL = (document: AdminDocument | undefined) =>
|
|
137
|
-
typeof document?.url === "string" ? document.url : undefined;
|
|
138
|
-
|
|
139
|
-
isImage = (document: AdminDocument | undefined) =>
|
|
140
|
-
typeof document?.mimeType === "string" && document.mimeType.startsWith("image/");
|
|
141
|
-
|
|
142
|
-
openBrowser = (documentID?: string) => {
|
|
177
|
+
openBrowser = (
|
|
178
|
+
documentID?: string,
|
|
179
|
+
create = false,
|
|
180
|
+
target = this.selectedTarget,
|
|
181
|
+
file?: File
|
|
182
|
+
) => {
|
|
183
|
+
this.selectedTarget = target;
|
|
184
|
+
this.initialFile = file;
|
|
185
|
+
this.initialCreate = create;
|
|
143
186
|
this.initialDocumentID = documentID;
|
|
144
|
-
this.initialDocument =
|
|
187
|
+
this.initialDocument =
|
|
188
|
+
documentID === undefined
|
|
189
|
+
? undefined
|
|
190
|
+
: this.documents[relationshipKey({ relationTo: target, id: documentID })];
|
|
145
191
|
this.browserOpen = true;
|
|
146
192
|
};
|
|
147
193
|
|
|
@@ -152,6 +198,7 @@ export class RelationshipFieldController {
|
|
|
152
198
|
commit = (ids: string[]) => {
|
|
153
199
|
const field = this.options.field;
|
|
154
200
|
const form = this.options.form;
|
|
201
|
+
if (field.admin.readOnly || form.editingBlocked) return;
|
|
155
202
|
form.set(
|
|
156
203
|
field.path,
|
|
157
204
|
updateRelationshipValue(
|
|
@@ -169,16 +216,16 @@ export class RelationshipFieldController {
|
|
|
169
216
|
};
|
|
170
217
|
|
|
171
218
|
async #hydrateSelected(
|
|
172
|
-
|
|
173
|
-
|
|
219
|
+
references: readonly PolymorphicReference[],
|
|
220
|
+
locale: string | undefined,
|
|
174
221
|
revision: number,
|
|
175
222
|
signal: AbortSignal
|
|
176
223
|
) {
|
|
177
224
|
const results = await Promise.allSettled(
|
|
178
|
-
|
|
179
|
-
this.options.runtime.client.find(
|
|
225
|
+
references.map((reference) =>
|
|
226
|
+
this.options.runtime.client.find(reference.relationTo, reference.id, {
|
|
180
227
|
signal,
|
|
181
|
-
locale
|
|
228
|
+
locale,
|
|
182
229
|
})
|
|
183
230
|
)
|
|
184
231
|
);
|
|
@@ -187,8 +234,9 @@ export class RelationshipFieldController {
|
|
|
187
234
|
let failed = false;
|
|
188
235
|
for (let index = 0; index < results.length; index += 1) {
|
|
189
236
|
const result = results[index];
|
|
190
|
-
const
|
|
191
|
-
if (result?.status === "fulfilled" &&
|
|
237
|
+
const reference = references[index];
|
|
238
|
+
if (result?.status === "fulfilled" && reference !== undefined)
|
|
239
|
+
documents[relationshipKey(reference)] = result.value;
|
|
192
240
|
else failed = true;
|
|
193
241
|
}
|
|
194
242
|
this.documents = documents;
|
|
@@ -235,11 +283,3 @@ function relationshipTargets(field: SchemaField) {
|
|
|
235
283
|
}
|
|
236
284
|
return [];
|
|
237
285
|
}
|
|
238
|
-
|
|
239
|
-
function findDisplayField(fields: readonly SchemaField[]) {
|
|
240
|
-
return (
|
|
241
|
-
fields.find((field) => field.name === "title" || field.name === "name") ??
|
|
242
|
-
fields.find((field) => field.type === "text" && field.name !== "email") ??
|
|
243
|
-
fields.find((field) => field.type === "text" || field.type === "email")
|
|
244
|
-
);
|
|
245
|
-
}
|