@riducms/admin 0.2.2 → 0.3.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 +27 -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 +121 -124
- 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 +157 -0
- package/src/features/{auth → account}/account-security-route.svelte +140 -42
- package/src/features/api-reference/api-reference-code.svelte +64 -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 +20 -51
- package/src/features/auth/create-first-user-route.svelte +83 -122
- package/src/features/auth/forgot-password-route.svelte +31 -23
- package/src/features/auth/login-route.svelte +68 -116
- 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 +27 -22
- package/src/features/auth/reset-password-route.svelte +108 -41
- package/src/features/auth/verify-email-route.svelte +49 -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 +526 -613
- 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 +335 -236
- 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 +132 -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
|
@@ -1,32 +1,103 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { mapBlockTypes, type SchemaField } from "@riducms/protocol";
|
|
2
2
|
|
|
3
|
-
import { initialFormValues } from "@admin/core/forms/form-schema";
|
|
3
|
+
import { cloneFormValue, initialFormValues, type FormValues } from "@admin/core/forms/form-schema";
|
|
4
|
+
import { isUploadMetadataField } from "@admin/features/uploads/upload-document-contracts";
|
|
4
5
|
|
|
5
|
-
export function
|
|
6
|
-
return fields.filter(
|
|
6
|
+
export function bulkUploadDocumentFields(fields: readonly SchemaField[]) {
|
|
7
|
+
return fields.filter((field) => !isUploadMetadataField(field.name));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function bulkUploadBulkEditFields(fields: readonly SchemaField[]) {
|
|
11
|
+
return bulkUploadDocumentFields(fields).filter(
|
|
7
12
|
(field) =>
|
|
8
13
|
field.category === "scalar" &&
|
|
9
14
|
field.admin.readOnly !== true &&
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
field.admin.hidden !== true &&
|
|
16
|
+
field.admin.condition === undefined &&
|
|
17
|
+
!field.unique &&
|
|
18
|
+
field.type !== "json" &&
|
|
19
|
+
field.type !== "text-list" &&
|
|
20
|
+
field.type !== "number-list"
|
|
13
21
|
);
|
|
14
22
|
}
|
|
15
23
|
|
|
24
|
+
/** Give concurrent document renderers unique DOM IDs without changing form paths or access paths. */
|
|
25
|
+
export function bulkUploadRenderFields(fields: readonly SchemaField[], scope: string) {
|
|
26
|
+
return fields.map((field) => scopeRenderField(field, scope));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function scopeRenderField(field: SchemaField, scope: string): SchemaField {
|
|
30
|
+
return {
|
|
31
|
+
...field,
|
|
32
|
+
id: `${field.id}-${scope}`,
|
|
33
|
+
admin: {
|
|
34
|
+
...field.admin,
|
|
35
|
+
...(field.admin.row === undefined
|
|
36
|
+
? {}
|
|
37
|
+
: { row: { ...field.admin.row, id: `${field.admin.row.id}-${scope}` } }),
|
|
38
|
+
...(field.admin.collapsible === undefined
|
|
39
|
+
? {}
|
|
40
|
+
: {
|
|
41
|
+
collapsible: {
|
|
42
|
+
...field.admin.collapsible,
|
|
43
|
+
id: `${field.admin.collapsible.id}-${scope}`,
|
|
44
|
+
},
|
|
45
|
+
}),
|
|
46
|
+
...(field.admin.tabGroup === undefined
|
|
47
|
+
? {}
|
|
48
|
+
: {
|
|
49
|
+
tabGroup: {
|
|
50
|
+
...field.admin.tabGroup,
|
|
51
|
+
id: `${field.admin.tabGroup.id}-${scope}`,
|
|
52
|
+
},
|
|
53
|
+
}),
|
|
54
|
+
},
|
|
55
|
+
...(field.nested === undefined
|
|
56
|
+
? {}
|
|
57
|
+
: {
|
|
58
|
+
nested: {
|
|
59
|
+
...field.nested,
|
|
60
|
+
fields: field.nested.fields.map((child) => scopeRenderField(child, scope)),
|
|
61
|
+
},
|
|
62
|
+
}),
|
|
63
|
+
...(field.blocks === undefined
|
|
64
|
+
? {}
|
|
65
|
+
: {
|
|
66
|
+
blocks: mapBlockTypes(field.blocks, (block) => ({
|
|
67
|
+
...block,
|
|
68
|
+
fields: block.fields.map((child) => scopeRenderField(child, scope)),
|
|
69
|
+
})),
|
|
70
|
+
}),
|
|
71
|
+
...(field.plugin?.embeddedTrees === undefined
|
|
72
|
+
? {}
|
|
73
|
+
: {
|
|
74
|
+
plugin: {
|
|
75
|
+
...field.plugin,
|
|
76
|
+
embeddedTrees: field.plugin.embeddedTrees.map((tree) => ({
|
|
77
|
+
...tree,
|
|
78
|
+
cases: tree.cases.map((branch) =>
|
|
79
|
+
mapBlockTypes(branch, (block) => ({
|
|
80
|
+
...block,
|
|
81
|
+
fields: block.fields.map((child) => scopeRenderField(child, scope)),
|
|
82
|
+
}))
|
|
83
|
+
),
|
|
84
|
+
})),
|
|
85
|
+
},
|
|
86
|
+
}),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
16
90
|
export function initialBulkUploadValues(
|
|
17
91
|
filename: string,
|
|
18
92
|
fields: readonly SchemaField[],
|
|
19
93
|
useAsTitle: string | undefined
|
|
20
|
-
) {
|
|
94
|
+
): FormValues {
|
|
21
95
|
const stem = filename
|
|
22
96
|
.replace(/\.[^.]+$/, "")
|
|
23
97
|
.replaceAll(/[-_]+/g, " ")
|
|
24
98
|
.trim();
|
|
25
|
-
const
|
|
26
|
-
const values: Record<string, string> = {};
|
|
99
|
+
const values = initialFormValues(fields);
|
|
27
100
|
for (const field of fields) {
|
|
28
|
-
const defaultValue = defaults[field.name];
|
|
29
|
-
values[field.name] = typeof defaultValue === "string" ? defaultValue : "";
|
|
30
101
|
if (field.name === "alt" || (field.required && field.name === useAsTitle)) {
|
|
31
102
|
values[field.name] = stem;
|
|
32
103
|
}
|
|
@@ -34,6 +105,26 @@ export function initialBulkUploadValues(
|
|
|
34
105
|
return values;
|
|
35
106
|
}
|
|
36
107
|
|
|
37
|
-
export function
|
|
38
|
-
|
|
108
|
+
export function applyBulkUploadValues(
|
|
109
|
+
target: { set(path: string, value: unknown): void },
|
|
110
|
+
fields: readonly SchemaField[],
|
|
111
|
+
values: Readonly<FormValues>
|
|
112
|
+
) {
|
|
113
|
+
for (const field of fields) {
|
|
114
|
+
if (Object.hasOwn(values, field.name))
|
|
115
|
+
target.set(field.path, cloneFormValue(values[field.name]));
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function bulkUploadFileIdentity(file: File) {
|
|
120
|
+
return `${file.name}\u0000${file.size}\u0000${file.lastModified}`;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export function bulkUploadRemoteFilename(value: string) {
|
|
124
|
+
try {
|
|
125
|
+
const filename = new URL(value).pathname.split("/").filter(Boolean).at(-1);
|
|
126
|
+
return filename === undefined ? "remote-upload" : decodeURIComponent(filename);
|
|
127
|
+
} catch {
|
|
128
|
+
return "remote-upload";
|
|
129
|
+
}
|
|
39
130
|
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import CropperCanvas from "@cropper/element-canvas";
|
|
2
|
+
import CropperSelection from "@cropper/element-selection";
|
|
3
|
+
import CropperHandle from "@cropper/element-handle";
|
|
4
|
+
import type { UploadImageEdit } from "@riducms/protocol";
|
|
5
|
+
import type { UploadSource } from "@admin/features/uploads/upload-draft.svelte";
|
|
6
|
+
|
|
7
|
+
const directions = ["n", "ne", "e", "se", "s", "sw", "w", "nw"] as const;
|
|
8
|
+
const arrows: Record<string, [number, number]> = {
|
|
9
|
+
ArrowLeft: [-1, 0],
|
|
10
|
+
ArrowRight: [1, 0],
|
|
11
|
+
ArrowUp: [0, -1],
|
|
12
|
+
ArrowDown: [0, 1],
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/** Owns only the crop interaction DOM. Document state and image bytes stay outside Cropper. */
|
|
16
|
+
export function mountCropSurface(
|
|
17
|
+
host: HTMLElement,
|
|
18
|
+
source: UploadSource,
|
|
19
|
+
options: {
|
|
20
|
+
getEdit: () => UploadImageEdit;
|
|
21
|
+
onchange: (edit: UploadImageEdit) => void;
|
|
22
|
+
label: (action: string) => string;
|
|
23
|
+
}
|
|
24
|
+
) {
|
|
25
|
+
CropperCanvas.$define();
|
|
26
|
+
CropperSelection.$define();
|
|
27
|
+
CropperHandle.$define();
|
|
28
|
+
|
|
29
|
+
const canvas = new CropperCanvas();
|
|
30
|
+
canvas.className = "ridu-crop-canvas";
|
|
31
|
+
canvas.style.aspectRatio = `${source.width} / ${source.height}`;
|
|
32
|
+
const image = new Image();
|
|
33
|
+
image.src = source.url;
|
|
34
|
+
image.alt = "";
|
|
35
|
+
image.draggable = false;
|
|
36
|
+
const draw = new CropperHandle();
|
|
37
|
+
draw.action = "select";
|
|
38
|
+
draw.plain = true;
|
|
39
|
+
const selection = new CropperSelection();
|
|
40
|
+
selection.className = "ridu-crop-selection";
|
|
41
|
+
selection.movable = true;
|
|
42
|
+
selection.resizable = true;
|
|
43
|
+
selection.precise = true;
|
|
44
|
+
// Cropper's keyboard option installs document-wide Delete/arrow handlers.
|
|
45
|
+
// Scope accessible keyboard interaction to our focused, labelled handles instead.
|
|
46
|
+
selection.keyboard = false;
|
|
47
|
+
|
|
48
|
+
for (const direction of ["move", ...directions]) {
|
|
49
|
+
const handle = new CropperHandle();
|
|
50
|
+
handle.action = direction === "move" ? "move" : `${direction}-resize`;
|
|
51
|
+
handle.plain = direction === "move";
|
|
52
|
+
handle.tabIndex = 0;
|
|
53
|
+
handle.setAttribute("role", "button");
|
|
54
|
+
handle.setAttribute("aria-label", options.label(direction));
|
|
55
|
+
handle.themeColor = "var(--ink-strong)";
|
|
56
|
+
if (direction !== "move") {
|
|
57
|
+
// Cropper centers resize targets outside the selection, but its canvas clips them at image edges.
|
|
58
|
+
if (direction.includes("n")) handle.style.top = "0";
|
|
59
|
+
if (direction.includes("s")) handle.style.bottom = "0";
|
|
60
|
+
if (direction.includes("e")) handle.style.right = "0";
|
|
61
|
+
if (direction.includes("w")) handle.style.left = "0";
|
|
62
|
+
// Full-edge targets overlap the corners; diagonal targets must win the pointer hit test.
|
|
63
|
+
if (direction.length === 2) handle.style.zIndex = "1";
|
|
64
|
+
}
|
|
65
|
+
selection.append(handle);
|
|
66
|
+
}
|
|
67
|
+
canvas.append(image, draw, selection);
|
|
68
|
+
host.append(canvas);
|
|
69
|
+
for (const handle of selection.children) {
|
|
70
|
+
if (handle instanceof CropperHandle && handle.action !== "move") {
|
|
71
|
+
handle.$addStyles(
|
|
72
|
+
":host::after { width: 7px; height: 7px; border: 1px solid var(--ink-strong); background: var(--background); }"
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
let synchronizing = false;
|
|
78
|
+
const sync = () => {
|
|
79
|
+
const edit = options.getEdit();
|
|
80
|
+
if (!canvas.clientWidth || !canvas.clientHeight) return;
|
|
81
|
+
synchronizing = true;
|
|
82
|
+
selection.$change(
|
|
83
|
+
(edit.cropX / 100) * canvas.clientWidth,
|
|
84
|
+
(edit.cropY / 100) * canvas.clientHeight,
|
|
85
|
+
((edit.cropWidth || 100) / 100) * canvas.clientWidth,
|
|
86
|
+
((edit.cropHeight || 100) / 100) * canvas.clientHeight
|
|
87
|
+
);
|
|
88
|
+
synchronizing = false;
|
|
89
|
+
};
|
|
90
|
+
const change = (event: Event) => {
|
|
91
|
+
if (!(event instanceof CustomEvent) || synchronizing) return;
|
|
92
|
+
const rect: { x: number; y: number; width: number; height: number } = event.detail;
|
|
93
|
+
const width = canvas.clientWidth,
|
|
94
|
+
height = canvas.clientHeight;
|
|
95
|
+
if (
|
|
96
|
+
!width ||
|
|
97
|
+
!height ||
|
|
98
|
+
rect.x < -0.01 ||
|
|
99
|
+
rect.y < -0.01 ||
|
|
100
|
+
rect.x + rect.width > width + 0.01 ||
|
|
101
|
+
rect.y + rect.height > height + 0.01 ||
|
|
102
|
+
rect.width < width / source.width ||
|
|
103
|
+
rect.height < height / source.height
|
|
104
|
+
) {
|
|
105
|
+
event.preventDefault();
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const next = {
|
|
109
|
+
...options.getEdit(),
|
|
110
|
+
cropX: Math.max(0, (rect.x / width) * 100),
|
|
111
|
+
cropY: Math.max(0, (rect.y / height) * 100),
|
|
112
|
+
cropWidth: (rect.width / width) * 100,
|
|
113
|
+
cropHeight: (rect.height / height) * 100,
|
|
114
|
+
};
|
|
115
|
+
const previous = options.getEdit();
|
|
116
|
+
if (
|
|
117
|
+
["cropX", "cropY", "cropWidth", "cropHeight"].some(
|
|
118
|
+
(name) =>
|
|
119
|
+
Math.abs(next[name as keyof UploadImageEdit] - previous[name as keyof UploadImageEdit]) >
|
|
120
|
+
0.00001
|
|
121
|
+
)
|
|
122
|
+
)
|
|
123
|
+
options.onchange(next);
|
|
124
|
+
};
|
|
125
|
+
const keydown = (event: KeyboardEvent) => {
|
|
126
|
+
if (!(event.target instanceof CropperHandle)) return;
|
|
127
|
+
const offset = arrows[event.key];
|
|
128
|
+
if (!offset) return;
|
|
129
|
+
event.preventDefault();
|
|
130
|
+
const x = ((offset[0] * canvas.clientWidth) / source.width) * (event.shiftKey ? 10 : 1);
|
|
131
|
+
const y = ((offset[1] * canvas.clientHeight) / source.height) * (event.shiftKey ? 10 : 1);
|
|
132
|
+
if (event.target.action === "move") selection.$move(x, y);
|
|
133
|
+
else selection.$resize(event.target.action, x, y);
|
|
134
|
+
};
|
|
135
|
+
selection.addEventListener("change", change);
|
|
136
|
+
canvas.addEventListener("keydown", keydown);
|
|
137
|
+
const resize = new ResizeObserver(sync);
|
|
138
|
+
resize.observe(canvas);
|
|
139
|
+
sync();
|
|
140
|
+
|
|
141
|
+
return {
|
|
142
|
+
sync,
|
|
143
|
+
dispose() {
|
|
144
|
+
resize.disconnect();
|
|
145
|
+
selection.removeEventListener("change", change);
|
|
146
|
+
canvas.removeEventListener("keydown", keydown);
|
|
147
|
+
canvas.remove();
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { untrack } from "svelte";
|
|
3
|
+
import { Button, Input } from "@riducms/ui";
|
|
4
|
+
import { getAdminI18n } from "@riducms/plugin";
|
|
5
|
+
import type { UploadImageEdit } from "@riducms/protocol";
|
|
6
|
+
import type { UploadSource } from "@admin/features/uploads/upload-draft.svelte";
|
|
7
|
+
import { mountCropSurface } from "@admin/features/uploads/crop-surface";
|
|
8
|
+
|
|
9
|
+
let {
|
|
10
|
+
source,
|
|
11
|
+
initial,
|
|
12
|
+
onapply,
|
|
13
|
+
oncancel,
|
|
14
|
+
}: {
|
|
15
|
+
source: UploadSource;
|
|
16
|
+
initial: UploadImageEdit;
|
|
17
|
+
onapply: (edit: UploadImageEdit) => void;
|
|
18
|
+
oncancel: () => void;
|
|
19
|
+
} = $props();
|
|
20
|
+
const i18n = getAdminI18n();
|
|
21
|
+
const instructionsID = $props.id();
|
|
22
|
+
// Each mounted editor is an isolated session; Cancel leaves its parent draft untouched.
|
|
23
|
+
// svelte-ignore state_referenced_locally
|
|
24
|
+
let edit = $state({ ...initial });
|
|
25
|
+
let surface: HTMLDivElement;
|
|
26
|
+
const width = $derived(Math.round(((edit.cropWidth || 100) / 100) * source.width));
|
|
27
|
+
const height = $derived(Math.round(((edit.cropHeight || 100) / 100) * source.height));
|
|
28
|
+
|
|
29
|
+
function attachCrop(node: HTMLElement) {
|
|
30
|
+
const currentSource = source;
|
|
31
|
+
const adapter = untrack(() =>
|
|
32
|
+
mountCropSurface(node, currentSource, {
|
|
33
|
+
getEdit: () => edit,
|
|
34
|
+
onchange: (next) => {
|
|
35
|
+
edit = constrainFocal(next);
|
|
36
|
+
},
|
|
37
|
+
label: (direction) => i18n.t("uploads:cropHandle", { direction }),
|
|
38
|
+
})
|
|
39
|
+
);
|
|
40
|
+
$effect(() => {
|
|
41
|
+
// The adapter is an external DOM system. Numeric inputs and resets synchronize it here.
|
|
42
|
+
edit.cropX;
|
|
43
|
+
edit.cropY;
|
|
44
|
+
edit.cropWidth;
|
|
45
|
+
edit.cropHeight;
|
|
46
|
+
adapter.sync();
|
|
47
|
+
});
|
|
48
|
+
return () => adapter.dispose();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function constrainFocal(next: UploadImageEdit) {
|
|
52
|
+
return {
|
|
53
|
+
...next,
|
|
54
|
+
focalX: Math.max(next.cropX, Math.min(next.cropX + (next.cropWidth || 100), next.focalX)),
|
|
55
|
+
focalY: Math.max(next.cropY, Math.min(next.cropY + (next.cropHeight || 100), next.focalY)),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function setFocal(x: number, y: number) {
|
|
60
|
+
if (Number.isFinite(x) && Number.isFinite(y))
|
|
61
|
+
edit = constrainFocal({ ...edit, focalX: x, focalY: y });
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function resize(axis: "width" | "height", value: number | undefined) {
|
|
65
|
+
if (value === undefined || !Number.isFinite(value)) return;
|
|
66
|
+
if (!edit.cropWidth) {
|
|
67
|
+
edit.cropWidth = 100;
|
|
68
|
+
edit.cropHeight = 100;
|
|
69
|
+
}
|
|
70
|
+
if (axis === "width")
|
|
71
|
+
edit.cropWidth = Math.min(100 - edit.cropX, (Math.max(1, value) / source.width) * 100);
|
|
72
|
+
else edit.cropHeight = Math.min(100 - edit.cropY, (Math.max(1, value) / source.height) * 100);
|
|
73
|
+
edit = constrainFocal(edit);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function focalPointer(event: PointerEvent) {
|
|
77
|
+
event.preventDefault();
|
|
78
|
+
event.stopPropagation();
|
|
79
|
+
if (!(event.currentTarget instanceof HTMLButtonElement)) return;
|
|
80
|
+
const button = event.currentTarget;
|
|
81
|
+
if (event.type === "pointerdown") button.setPointerCapture(event.pointerId);
|
|
82
|
+
if (!button.hasPointerCapture(event.pointerId)) return;
|
|
83
|
+
const bounds = surface.getBoundingClientRect();
|
|
84
|
+
setFocal(
|
|
85
|
+
((event.clientX - bounds.left) / bounds.width) * 100,
|
|
86
|
+
((event.clientY - bounds.top) / bounds.height) * 100
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function focalKey(event: KeyboardEvent) {
|
|
91
|
+
const step = event.shiftKey ? 10 : 1;
|
|
92
|
+
if (event.key === "ArrowLeft") edit.focalX = Math.max(0, edit.focalX - step);
|
|
93
|
+
else if (event.key === "ArrowRight") edit.focalX = Math.min(100, edit.focalX + step);
|
|
94
|
+
else if (event.key === "ArrowUp") edit.focalY = Math.max(0, edit.focalY - step);
|
|
95
|
+
else if (event.key === "ArrowDown") edit.focalY = Math.min(100, edit.focalY + step);
|
|
96
|
+
else if (event.key === "Enter" || event.key === " ") {
|
|
97
|
+
edit.focalX = 50;
|
|
98
|
+
edit.focalY = 50;
|
|
99
|
+
} else return;
|
|
100
|
+
edit = constrainFocal(edit);
|
|
101
|
+
event.preventDefault();
|
|
102
|
+
}
|
|
103
|
+
</script>
|
|
104
|
+
|
|
105
|
+
<div class="ridu-image-editor-actions">
|
|
106
|
+
<Button variant="outline" onclick={oncancel}>{i18n.t("general:cancel")}</Button>
|
|
107
|
+
<Button onclick={() => onapply({ ...edit })}>{i18n.t("uploads:applyImageEdit")}</Button>
|
|
108
|
+
</div>
|
|
109
|
+
|
|
110
|
+
<p class="ridu-upload-description" role="status" aria-live="polite" aria-atomic="true">
|
|
111
|
+
{i18n.t("uploads:cropPosition", {
|
|
112
|
+
width,
|
|
113
|
+
height,
|
|
114
|
+
x: Math.round((edit.cropX * source.width) / 100),
|
|
115
|
+
y: Math.round((edit.cropY * source.height) / 100),
|
|
116
|
+
})}
|
|
117
|
+
{i18n.t("uploads:focalPosition", {
|
|
118
|
+
x: `${Math.round(edit.focalX)}%`,
|
|
119
|
+
y: `${Math.round(edit.focalY)}%`,
|
|
120
|
+
})}
|
|
121
|
+
</p>
|
|
122
|
+
|
|
123
|
+
<div class="ridu-image-editor">
|
|
124
|
+
<div class="ridu-image-editor-preview">
|
|
125
|
+
<div class="ridu-crop-surface" bind:this={surface}>
|
|
126
|
+
<div {@attach attachCrop}></div>
|
|
127
|
+
<button
|
|
128
|
+
type="button"
|
|
129
|
+
class="ridu-focal-point"
|
|
130
|
+
style:left={`${edit.focalX}%`}
|
|
131
|
+
style:top={`${edit.focalY}%`}
|
|
132
|
+
aria-label={i18n.t("uploads:focalPoint")}
|
|
133
|
+
aria-describedby={instructionsID}
|
|
134
|
+
onpointerdown={focalPointer}
|
|
135
|
+
onpointermove={focalPointer}
|
|
136
|
+
onkeydown={focalKey}
|
|
137
|
+
>
|
|
138
|
+
+
|
|
139
|
+
</button>
|
|
140
|
+
</div>
|
|
141
|
+
</div>
|
|
142
|
+
|
|
143
|
+
<div class="ridu-image-editor-controls">
|
|
144
|
+
<section>
|
|
145
|
+
<header>
|
|
146
|
+
<h3>{i18n.t("uploads:crop")}</h3>
|
|
147
|
+
<Button
|
|
148
|
+
size="xs"
|
|
149
|
+
variant="ghost"
|
|
150
|
+
onclick={() => {
|
|
151
|
+
edit = { ...edit, cropX: 0, cropY: 0, cropWidth: 0, cropHeight: 0 };
|
|
152
|
+
}}
|
|
153
|
+
>
|
|
154
|
+
{i18n.t("uploads:reset")}
|
|
155
|
+
</Button>
|
|
156
|
+
</header>
|
|
157
|
+
<p>{i18n.t("uploads:cropDescription")}</p>
|
|
158
|
+
<div class="ridu-image-editor-pair">
|
|
159
|
+
<label>
|
|
160
|
+
{i18n.t("uploads:widthPixels")}<Input
|
|
161
|
+
type="number"
|
|
162
|
+
min="1"
|
|
163
|
+
max={source.width}
|
|
164
|
+
bind:value={
|
|
165
|
+
() => width,
|
|
166
|
+
(value) => resize("width", value === undefined ? undefined : Number(value))
|
|
167
|
+
}
|
|
168
|
+
/>
|
|
169
|
+
</label>
|
|
170
|
+
<label>
|
|
171
|
+
{i18n.t("uploads:heightPixels")}<Input
|
|
172
|
+
type="number"
|
|
173
|
+
min="1"
|
|
174
|
+
max={source.height}
|
|
175
|
+
bind:value={
|
|
176
|
+
() => height,
|
|
177
|
+
(value) => resize("height", value === undefined ? undefined : Number(value))
|
|
178
|
+
}
|
|
179
|
+
/>
|
|
180
|
+
</label>
|
|
181
|
+
</div>
|
|
182
|
+
</section>
|
|
183
|
+
|
|
184
|
+
<section>
|
|
185
|
+
<header>
|
|
186
|
+
<h3>{i18n.t("uploads:focalPoint")}</h3>
|
|
187
|
+
<Button
|
|
188
|
+
size="xs"
|
|
189
|
+
variant="ghost"
|
|
190
|
+
onclick={() => {
|
|
191
|
+
setFocal(50, 50);
|
|
192
|
+
}}
|
|
193
|
+
>
|
|
194
|
+
{i18n.t("uploads:reset")}
|
|
195
|
+
</Button>
|
|
196
|
+
</header>
|
|
197
|
+
<p>{i18n.t("uploads:focalPointDescription")}</p>
|
|
198
|
+
<p class="ridu-upload-description" id={instructionsID}>
|
|
199
|
+
{i18n.t("uploads:focalKeyboardInstructions")}
|
|
200
|
+
</p>
|
|
201
|
+
<div class="ridu-image-editor-pair">
|
|
202
|
+
<label>
|
|
203
|
+
X %<Input
|
|
204
|
+
type="number"
|
|
205
|
+
min="0"
|
|
206
|
+
max="100"
|
|
207
|
+
bind:value={
|
|
208
|
+
() => Math.round(edit.focalX),
|
|
209
|
+
(value) => {
|
|
210
|
+
if (value !== undefined) setFocal(Number(value), edit.focalY);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
/>
|
|
214
|
+
</label>
|
|
215
|
+
<label>
|
|
216
|
+
Y %<Input
|
|
217
|
+
type="number"
|
|
218
|
+
min="0"
|
|
219
|
+
max="100"
|
|
220
|
+
bind:value={
|
|
221
|
+
() => Math.round(edit.focalY),
|
|
222
|
+
(value) => {
|
|
223
|
+
if (value !== undefined) setFocal(edit.focalX, Number(value));
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
/>
|
|
227
|
+
</label>
|
|
228
|
+
</div>
|
|
229
|
+
</section>
|
|
230
|
+
</div>
|
|
231
|
+
</div>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getAdminI18n } from "@riducms/plugin";
|
|
3
|
+
import type { AdminDocument } from "@admin/core/api/admin-client";
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
renditions,
|
|
7
|
+
document,
|
|
8
|
+
}: {
|
|
9
|
+
renditions: [string, Record<string, unknown>][];
|
|
10
|
+
document: AdminDocument;
|
|
11
|
+
} = $props();
|
|
12
|
+
const i18n = getAdminI18n();
|
|
13
|
+
let selected = $state(0);
|
|
14
|
+
const current = $derived(renditions[selected] ?? renditions[0]);
|
|
15
|
+
|
|
16
|
+
function filename(rendition: Record<string, unknown>) {
|
|
17
|
+
return String(
|
|
18
|
+
rendition.filename ??
|
|
19
|
+
String(rendition.objectKey ?? "")
|
|
20
|
+
.split("/")
|
|
21
|
+
.at(-1) ??
|
|
22
|
+
document.filename
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function metadata(rendition: Record<string, unknown>) {
|
|
27
|
+
return `${i18n.formatNumber(Number(rendition.filesize ?? 0) / 1024, { maximumFractionDigits: 0 })}KB · ${rendition.width} × ${rendition.height} · ${rendition.mimeType}`;
|
|
28
|
+
}
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
{#if current}
|
|
32
|
+
<div class="ridu-upload-renditions">
|
|
33
|
+
<section class="ridu-rendition-preview" aria-label={current[0]}>
|
|
34
|
+
<header>
|
|
35
|
+
<p>{current[0]}</p>
|
|
36
|
+
<a href={String(current[1].url)} target="_blank" rel="noreferrer">
|
|
37
|
+
{filename(current[1])}
|
|
38
|
+
</a>
|
|
39
|
+
<p>{metadata(current[1])}</p>
|
|
40
|
+
</header>
|
|
41
|
+
<div class="ridu-rendition-image">
|
|
42
|
+
<img src={String(current[1].url)} alt={String(document.alt ?? current[0])} />
|
|
43
|
+
</div>
|
|
44
|
+
</section>
|
|
45
|
+
|
|
46
|
+
<div class="ridu-rendition-list" aria-label={i18n.t("uploads:imageSizes")}>
|
|
47
|
+
{#each renditions as [name, rendition], index (name)}
|
|
48
|
+
<button
|
|
49
|
+
type="button"
|
|
50
|
+
class="ridu-rendition-option"
|
|
51
|
+
aria-pressed={selected === index}
|
|
52
|
+
onclick={() => (selected = index)}
|
|
53
|
+
>
|
|
54
|
+
<img src={String(rendition.url)} alt="" />
|
|
55
|
+
<span>
|
|
56
|
+
<span class="ridu-rendition-label">{name}</span>
|
|
57
|
+
<strong>{filename(rendition)}</strong>
|
|
58
|
+
<span class="ridu-rendition-label">{metadata(rendition)}</span>
|
|
59
|
+
</span>
|
|
60
|
+
</button>
|
|
61
|
+
{/each}
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
{/if}
|