@kardalum/plugin-sdk 0.0.0-stage → 0.16.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/CHANGELOG.md +118 -0
- package/LICENSE +202 -0
- package/README.md +80 -2
- package/dist/admin-section-registry.d.ts +34 -0
- package/dist/admin-section-registry.js +49 -0
- package/dist/built-in-serializers.d.ts +3 -0
- package/dist/built-in-serializers.js +18 -0
- package/dist/built-in-settings-schemas.d.ts +14 -0
- package/dist/built-in-settings-schemas.js +225 -0
- package/dist/built-in-value-schemas.d.ts +4 -0
- package/dist/built-in-value-schemas.js +47 -0
- package/dist/built-ins.d.ts +1 -0
- package/dist/built-ins.js +257 -0
- package/dist/capabilities.d.ts +29 -0
- package/dist/capabilities.js +67 -0
- package/dist/data-type-plugin.d.ts +28 -0
- package/dist/data-type-plugin.js +1 -0
- package/dist/datatype-validation.d.ts +26 -0
- package/dist/datatype-validation.js +110 -0
- package/dist/datatypes-entry.d.ts +4 -0
- package/dist/datatypes-entry.js +18 -0
- package/dist/define-plugin.d.ts +25 -0
- package/dist/define-plugin.js +51 -0
- package/dist/entitlement-entry.d.ts +5 -0
- package/dist/entitlement-entry.js +24 -0
- package/dist/entitlement-gate.d.ts +36 -0
- package/dist/entitlement-gate.js +201 -0
- package/dist/entitlement-types.d.ts +39 -0
- package/dist/entitlement-types.js +1 -0
- package/dist/entitlement.d.ts +57 -0
- package/dist/entitlement.js +170 -0
- package/dist/host-entry.d.ts +1 -0
- package/dist/host-entry.js +11 -0
- package/dist/icon-name.d.ts +1 -0
- package/dist/icon-name.js +1 -0
- package/dist/icons.d.ts +2 -0
- package/dist/icons.js +10 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +94 -0
- package/dist/license-verdict-keys.d.ts +18 -0
- package/dist/license-verdict-keys.js +26 -0
- package/dist/local-host.d.ts +3 -0
- package/dist/local-host.js +38 -0
- package/dist/manifest-entry.d.ts +8 -0
- package/dist/manifest-entry.js +13 -0
- package/dist/manifest-schema.d.ts +476 -0
- package/dist/manifest-schema.js +823 -0
- package/dist/manifest.d.ts +611 -0
- package/dist/manifest.js +86 -0
- package/dist/media/media-picker.d.ts +39 -0
- package/dist/media/media-picker.js +447 -0
- package/dist/media/upload-error.d.ts +12 -0
- package/dist/media/upload-error.js +30 -0
- package/dist/plugin-context.d.ts +82 -0
- package/dist/plugin-context.js +77 -0
- package/dist/plugin-screen-context.d.ts +71 -0
- package/dist/plugin-screen-context.js +41 -0
- package/dist/read-all-pages.d.ts +23 -0
- package/dist/read-all-pages.js +30 -0
- package/dist/register-built-ins.d.ts +1 -0
- package/dist/register-built-ins.js +41 -0
- package/dist/registry.d.ts +4 -0
- package/dist/registry.js +17 -0
- package/dist/rendition-eligibility.d.ts +24 -0
- package/dist/rendition-eligibility.js +40 -0
- package/dist/richtext/block-panel.d.ts +27 -0
- package/dist/richtext/block-panel.js +232 -0
- package/dist/richtext/extensions.d.ts +19 -0
- package/dist/richtext/extensions.js +56 -0
- package/dist/richtext/insert-menu.d.ts +24 -0
- package/dist/richtext/insert-menu.js +142 -0
- package/dist/richtext/kardalum-block.d.ts +33 -0
- package/dist/richtext/kardalum-block.js +282 -0
- package/dist/richtext/style-listbox.d.ts +10 -0
- package/dist/richtext/style-listbox.js +69 -0
- package/dist/richtext/text-style-class.d.ts +18 -0
- package/dist/richtext/text-style-class.js +36 -0
- package/dist/simple-storage-value-provider.d.ts +9 -0
- package/dist/simple-storage-value-provider.js +96 -0
- package/dist/structured-storage-types.d.ts +61 -0
- package/dist/structured-storage-types.js +11 -0
- package/dist/tailwind.d.ts +1 -0
- package/dist/tailwind.js +5 -0
- package/dist/tokens/system-dark.css +75 -0
- package/dist/tokens/tokens.css +239 -0
- package/dist/tokens/tokens.json +212 -0
- package/dist/tokens.d.ts +1 -0
- package/dist/tokens.js +11 -0
- package/dist/ui-entry.d.ts +5 -0
- package/dist/ui-entry.js +42 -0
- package/dist/views/content-list-preview.d.ts +1 -0
- package/dist/views/content-list-preview.js +14 -0
- package/dist/views/content-list-settings-view.d.ts +1 -0
- package/dist/views/content-list-settings-view.js +97 -0
- package/dist/views/content-list-view.d.ts +19 -0
- package/dist/views/content-list-view.js +248 -0
- package/dist/views/crop-view.d.ts +55 -0
- package/dist/views/crop-view.js +161 -0
- package/dist/views/date-range-view.d.ts +6 -0
- package/dist/views/date-range-view.js +55 -0
- package/dist/views/file-upload-view.d.ts +43 -0
- package/dist/views/file-upload-view.js +104 -0
- package/dist/views/html-code-editor.d.ts +10 -0
- package/dist/views/html-code-editor.js +101 -0
- package/dist/views/html-view.d.ts +3 -0
- package/dist/views/html-view.js +53 -0
- package/dist/views/image-view.d.ts +3 -0
- package/dist/views/image-view.js +372 -0
- package/dist/views/rich-text-view.d.ts +2 -0
- package/dist/views/rich-text-view.js +429 -0
- package/node_modules/@kardalum/api-schemas/LICENSE +202 -0
- package/node_modules/@kardalum/api-schemas/README.md +56 -0
- package/node_modules/@kardalum/api-schemas/dist/action.schema.d.ts +30 -0
- package/node_modules/@kardalum/api-schemas/dist/action.schema.js +88 -0
- package/node_modules/@kardalum/api-schemas/dist/api-error.schema.d.ts +17 -0
- package/node_modules/@kardalum/api-schemas/dist/api-error.schema.js +25 -0
- package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.d.ts +93 -0
- package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.js +88 -0
- package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.d.ts +89 -0
- package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.js +60 -0
- package/node_modules/@kardalum/api-schemas/dist/asset.schema.d.ts +24 -0
- package/node_modules/@kardalum/api-schemas/dist/asset.schema.js +47 -0
- package/node_modules/@kardalum/api-schemas/dist/auth.schema.d.ts +38 -0
- package/node_modules/@kardalum/api-schemas/dist/auth.schema.js +38 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.d.ts +542 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +357 -0
- package/node_modules/@kardalum/api-schemas/dist/content-list.schema.d.ts +158 -0
- package/node_modules/@kardalum/api-schemas/dist/content-list.schema.js +139 -0
- package/node_modules/@kardalum/api-schemas/dist/content-path.d.ts +125 -0
- package/node_modules/@kardalum/api-schemas/dist/content-path.js +260 -0
- package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.d.ts +20 -0
- package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.js +23 -0
- package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.d.ts +152 -0
- package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.js +82 -0
- package/node_modules/@kardalum/api-schemas/dist/content-version.schema.d.ts +18 -0
- package/node_modules/@kardalum/api-schemas/dist/content-version.schema.js +22 -0
- package/node_modules/@kardalum/api-schemas/dist/content.schema.d.ts +17 -0
- package/node_modules/@kardalum/api-schemas/dist/content.schema.js +20 -0
- package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +352 -0
- package/node_modules/@kardalum/api-schemas/dist/core-actions.js +133 -0
- package/node_modules/@kardalum/api-schemas/dist/culture-direction.d.ts +1 -0
- package/node_modules/@kardalum/api-schemas/dist/culture-direction.js +9 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.d.ts +37 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.js +32 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.d.ts +9 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.js +32 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.d.ts +298 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +138 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type.schema.d.ts +121 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type.schema.js +147 -0
- package/node_modules/@kardalum/api-schemas/dist/health.schema.d.ts +6 -0
- package/node_modules/@kardalum/api-schemas/dist/health.schema.js +5 -0
- package/node_modules/@kardalum/api-schemas/dist/html-entities.d.ts +4 -0
- package/node_modules/@kardalum/api-schemas/dist/html-entities.js +250 -0
- package/node_modules/@kardalum/api-schemas/dist/index.d.ts +113 -0
- package/node_modules/@kardalum/api-schemas/dist/index.js +64 -0
- package/node_modules/@kardalum/api-schemas/dist/licensing.schema.d.ts +15 -0
- package/node_modules/@kardalum/api-schemas/dist/licensing.schema.js +14 -0
- package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.d.ts +73 -0
- package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.js +104 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +682 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +269 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +177 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +222 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-api.schema.d.ts +77 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-api.schema.js +53 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-use.d.ts +75 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-use.js +117 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference.d.ts +27 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference.js +279 -0
- package/node_modules/@kardalum/api-schemas/dist/media-rendition.schema.d.ts +74 -0
- package/node_modules/@kardalum/api-schemas/dist/media-rendition.schema.js +157 -0
- package/node_modules/@kardalum/api-schemas/dist/media.schema.d.ts +80 -0
- package/node_modules/@kardalum/api-schemas/dist/media.schema.js +156 -0
- package/node_modules/@kardalum/api-schemas/dist/nav.schema.d.ts +23 -0
- package/node_modules/@kardalum/api-schemas/dist/nav.schema.js +55 -0
- package/node_modules/@kardalum/api-schemas/dist/node-access.schema.d.ts +846 -0
- package/node_modules/@kardalum/api-schemas/dist/node-access.schema.js +356 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.d.ts +20 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.js +27 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +249 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.js +84 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-text.d.ts +65 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-text.js +889 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.d.ts +172 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +196 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.d.ts +31 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.js +38 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.d.ts +69 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.js +59 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install.d.ts +585 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install.js +536 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-locales.d.ts +75 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-locales.js +213 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +391 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +413 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +29 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +100 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.d.ts +44 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.js +162 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.d.ts +31 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.js +25 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.d.ts +15 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.js +24 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.d.ts +314 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +338 -0
- package/node_modules/@kardalum/api-schemas/dist/render-editing.d.ts +79 -0
- package/node_modules/@kardalum/api-schemas/dist/render-editing.js +50 -0
- package/node_modules/@kardalum/api-schemas/dist/render-settings-api.schema.d.ts +9 -0
- package/node_modules/@kardalum/api-schemas/dist/render-settings-api.schema.js +13 -0
- package/node_modules/@kardalum/api-schemas/dist/reserved-slugs.d.ts +2 -0
- package/node_modules/@kardalum/api-schemas/dist/reserved-slugs.js +16 -0
- package/node_modules/@kardalum/api-schemas/dist/role.schema.d.ts +96 -0
- package/node_modules/@kardalum/api-schemas/dist/role.schema.js +75 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content-outcome.schema.d.ts +17 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content-outcome.schema.js +27 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.d.ts +35 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.js +79 -0
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +138 -0
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.js +105 -0
- package/node_modules/@kardalum/api-schemas/dist/sites.schema.d.ts +243 -0
- package/node_modules/@kardalum/api-schemas/dist/sites.schema.js +296 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +47 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.js +27 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.d.ts +30 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.js +19 -0
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.d.ts +112 -0
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +74 -0
- package/node_modules/@kardalum/api-schemas/dist/template.schema.d.ts +41 -0
- package/node_modules/@kardalum/api-schemas/dist/template.schema.js +39 -0
- package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.d.ts +21 -0
- package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.js +14 -0
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +97 -0
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +73 -0
- package/node_modules/@kardalum/api-schemas/package.json +35 -0
- package/node_modules/@kardalum/design-tokens/LICENSE +202 -0
- package/node_modules/@kardalum/design-tokens/README.md +29 -0
- package/node_modules/@kardalum/design-tokens/dist/build-css.d.ts +32 -0
- package/node_modules/@kardalum/design-tokens/dist/build-css.js +88 -0
- package/node_modules/@kardalum/design-tokens/dist/generate.d.ts +1 -0
- package/node_modules/@kardalum/design-tokens/dist/generate.js +18 -0
- package/node_modules/@kardalum/design-tokens/dist/index.d.ts +6 -0
- package/node_modules/@kardalum/design-tokens/dist/index.js +4 -0
- package/node_modules/@kardalum/design-tokens/dist/system-dark.css +75 -0
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +33 -0
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.js +54 -0
- package/node_modules/@kardalum/design-tokens/dist/theme-css.d.ts +12 -0
- package/node_modules/@kardalum/design-tokens/dist/theme-css.js +42 -0
- package/node_modules/@kardalum/design-tokens/dist/theme-types.d.ts +43 -0
- package/node_modules/@kardalum/design-tokens/dist/theme-types.js +1 -0
- package/node_modules/@kardalum/design-tokens/dist/themes/dark.d.ts +13 -0
- package/node_modules/@kardalum/design-tokens/dist/themes/dark.js +120 -0
- package/node_modules/@kardalum/design-tokens/dist/themes/index.d.ts +5 -0
- package/node_modules/@kardalum/design-tokens/dist/themes/index.js +4 -0
- package/node_modules/@kardalum/design-tokens/dist/themes/light.d.ts +9 -0
- package/node_modules/@kardalum/design-tokens/dist/themes/light.js +13 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.css +239 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.d.ts +25 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.js +276 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.json +212 -0
- package/node_modules/@kardalum/design-tokens/dist/types.d.ts +91 -0
- package/node_modules/@kardalum/design-tokens/dist/types.js +5 -0
- package/node_modules/@kardalum/design-tokens/package.json +42 -0
- package/node_modules/@kardalum/plugin-package/LICENSE +202 -0
- package/node_modules/@kardalum/plugin-package/README.md +71 -0
- package/node_modules/@kardalum/plugin-package/dist/build-reference.d.ts +111 -0
- package/node_modules/@kardalum/plugin-package/dist/build-reference.js +61 -0
- package/node_modules/@kardalum/plugin-package/dist/capabilities.d.ts +103 -0
- package/node_modules/@kardalum/plugin-package/dist/capabilities.js +351 -0
- package/node_modules/@kardalum/plugin-package/dist/docs-contract.d.ts +50 -0
- package/node_modules/@kardalum/plugin-package/dist/docs-contract.js +659 -0
- package/node_modules/@kardalum/plugin-package/dist/envelope.d.ts +19 -0
- package/node_modules/@kardalum/plugin-package/dist/envelope.js +104 -0
- package/node_modules/@kardalum/plugin-package/dist/extract.d.ts +37 -0
- package/node_modules/@kardalum/plugin-package/dist/extract.js +199 -0
- package/node_modules/@kardalum/plugin-package/dist/hash.d.ts +17 -0
- package/node_modules/@kardalum/plugin-package/dist/hash.js +69 -0
- package/node_modules/@kardalum/plugin-package/dist/index.d.ts +13 -0
- package/node_modules/@kardalum/plugin-package/dist/index.js +8 -0
- package/node_modules/@kardalum/plugin-package/dist/license-verdict.d.ts +185 -0
- package/node_modules/@kardalum/plugin-package/dist/license-verdict.js +236 -0
- package/node_modules/@kardalum/plugin-package/dist/package-contract.d.ts +50 -0
- package/node_modules/@kardalum/plugin-package/dist/package-contract.js +115 -0
- package/node_modules/@kardalum/plugin-package/dist/reference-entry.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/reference-entry.js +6 -0
- package/node_modules/@kardalum/plugin-package/dist/sample-content.d.ts +20 -0
- package/node_modules/@kardalum/plugin-package/dist/sample-content.js +57 -0
- package/node_modules/@kardalum/plugin-package/dist/types.d.ts +43 -0
- package/node_modules/@kardalum/plugin-package/dist/types.js +15 -0
- package/node_modules/@kardalum/plugin-package/package.json +54 -0
- package/node_modules/@kardalum/ui/LICENSE +202 -0
- package/node_modules/@kardalum/ui/README.md +35 -0
- package/node_modules/@kardalum/ui/dist/components/alert-dialog.d.ts +14 -0
- package/node_modules/@kardalum/ui/dist/components/alert-dialog.js +38 -0
- package/node_modules/@kardalum/ui/dist/components/badge.d.ts +9 -0
- package/node_modules/@kardalum/ui/dist/components/badge.js +30 -0
- package/node_modules/@kardalum/ui/dist/components/button.d.ts +11 -0
- package/node_modules/@kardalum/ui/dist/components/button.js +37 -0
- package/node_modules/@kardalum/ui/dist/components/checkbox.d.ts +5 -0
- package/node_modules/@kardalum/ui/dist/components/checkbox.js +7 -0
- package/node_modules/@kardalum/ui/dist/components/dialog.d.ts +17 -0
- package/node_modules/@kardalum/ui/dist/components/dialog.js +48 -0
- package/node_modules/@kardalum/ui/dist/components/dropdown-menu.d.ts +18 -0
- package/node_modules/@kardalum/ui/dist/components/dropdown-menu.js +53 -0
- package/node_modules/@kardalum/ui/dist/components/empty-state.d.ts +30 -0
- package/node_modules/@kardalum/ui/dist/components/empty-state.js +9 -0
- package/node_modules/@kardalum/ui/dist/components/input.d.ts +4 -0
- package/node_modules/@kardalum/ui/dist/components/input.js +6 -0
- package/node_modules/@kardalum/ui/dist/components/panel.d.ts +5 -0
- package/node_modules/@kardalum/ui/dist/components/panel.js +6 -0
- package/node_modules/@kardalum/ui/dist/components/property-field.d.ts +19 -0
- package/node_modules/@kardalum/ui/dist/components/property-field.js +89 -0
- package/node_modules/@kardalum/ui/dist/components/sheet.d.ts +17 -0
- package/node_modules/@kardalum/ui/dist/components/sheet.js +55 -0
- package/node_modules/@kardalum/ui/dist/components/skeleton.d.ts +3 -0
- package/node_modules/@kardalum/ui/dist/components/skeleton.js +9 -0
- package/node_modules/@kardalum/ui/dist/components/switch.d.ts +5 -0
- package/node_modules/@kardalum/ui/dist/components/switch.js +7 -0
- package/node_modules/@kardalum/ui/dist/components/tab-strip.d.ts +34 -0
- package/node_modules/@kardalum/ui/dist/components/tab-strip.js +72 -0
- package/node_modules/@kardalum/ui/dist/components/toast.d.ts +18 -0
- package/node_modules/@kardalum/ui/dist/components/toast.js +42 -0
- package/node_modules/@kardalum/ui/dist/components/toaster.d.ts +12 -0
- package/node_modules/@kardalum/ui/dist/components/toaster.js +11 -0
- package/node_modules/@kardalum/ui/dist/components/use-toast.d.ts +17 -0
- package/node_modules/@kardalum/ui/dist/components/use-toast.js +62 -0
- package/node_modules/@kardalum/ui/dist/index.d.ts +18 -0
- package/node_modules/@kardalum/ui/dist/index.js +18 -0
- package/node_modules/@kardalum/ui/dist/lib/cn.d.ts +2 -0
- package/node_modules/@kardalum/ui/dist/lib/cn.js +5 -0
- package/node_modules/@kardalum/ui/package.json +63 -0
- package/package.json +146 -4
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId, useState } from "react";
|
|
3
|
+
import { CONTENT_LIST_PROPERTIES, } from "@kardalum/api-schemas";
|
|
4
|
+
import { Button, Input } from "@kardalum/ui";
|
|
5
|
+
import { useContentHost, usePluginSettingsValue } from "../plugin-context.js";
|
|
6
|
+
import { CONTENT_LIST_PROPERTY_LABELS, contentListColumnKey, findFieldInTypes, resolveContentListColumns, } from "./content-list-view.js";
|
|
7
|
+
// The Content List datatype's column picker (S232). Rendered by the Data
|
|
8
|
+
// Types editor only, so it takes the settings-EDITING hook
|
|
9
|
+
// (usePluginSettingsValue), the same split every other built-in settings
|
|
10
|
+
// view follows. Plain English strings, like the rest of this package.
|
|
11
|
+
const PROPERTY_PREFIX = "property:";
|
|
12
|
+
const FIELD_PREFIX = "field:";
|
|
13
|
+
const SELECT_CLASS = "h-10 rounded-md border border-border-strong bg-background-elevated px-2 text-sm text-text-primary " +
|
|
14
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-600";
|
|
15
|
+
export function ContentListSettingsView() {
|
|
16
|
+
const { value: settings, onChange } = usePluginSettingsValue();
|
|
17
|
+
const host = useContentHost();
|
|
18
|
+
const addId = useId();
|
|
19
|
+
const aliasId = useId();
|
|
20
|
+
const labelIdPrefix = useId();
|
|
21
|
+
const [alias, setAlias] = useState("");
|
|
22
|
+
const columns = resolveContentListColumns(settings);
|
|
23
|
+
const documentTypes = host?.documentTypes;
|
|
24
|
+
const chosenProperties = new Set(columns.flatMap((column) => (column.kind === "property" ? [column.property] : [])));
|
|
25
|
+
const chosenFieldIds = new Set(columns.flatMap((column) => (column.kind === "field" ? [column.fieldId] : [])));
|
|
26
|
+
const availableProperties = CONTENT_LIST_PROPERTIES.filter((property) => !chosenProperties.has(property));
|
|
27
|
+
function commit(next) {
|
|
28
|
+
onChange({ ...settings, columns: next });
|
|
29
|
+
}
|
|
30
|
+
function addField(fieldId) {
|
|
31
|
+
const trimmed = fieldId.trim();
|
|
32
|
+
// A second column for the same alias would render the same value
|
|
33
|
+
// twice under two headers, so it is simply not added.
|
|
34
|
+
if (trimmed === "" || chosenFieldIds.has(trimmed))
|
|
35
|
+
return;
|
|
36
|
+
commit([...columns, { kind: "field", fieldId: trimmed }]);
|
|
37
|
+
}
|
|
38
|
+
function handlePick(raw) {
|
|
39
|
+
if (raw.startsWith(PROPERTY_PREFIX)) {
|
|
40
|
+
const property = raw.slice(PROPERTY_PREFIX.length);
|
|
41
|
+
if (chosenProperties.has(property))
|
|
42
|
+
return;
|
|
43
|
+
commit([...columns, { kind: "property", property }]);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (raw.startsWith(FIELD_PREFIX))
|
|
47
|
+
addField(raw.slice(FIELD_PREFIX.length));
|
|
48
|
+
}
|
|
49
|
+
function move(index, delta) {
|
|
50
|
+
const target = index + delta;
|
|
51
|
+
if (target < 0 || target >= columns.length)
|
|
52
|
+
return;
|
|
53
|
+
const next = [...columns];
|
|
54
|
+
const [moved] = next.splice(index, 1);
|
|
55
|
+
next.splice(target, 0, moved);
|
|
56
|
+
commit(next);
|
|
57
|
+
}
|
|
58
|
+
function remove(index) {
|
|
59
|
+
// ContentListSettingsSchema requires at least one column, and
|
|
60
|
+
// resolveContentListColumns would silently substitute the defaults for
|
|
61
|
+
// an empty list, so the last column is not removable: the floor is
|
|
62
|
+
// enforced here rather than left to a later parse failure.
|
|
63
|
+
if (columns.length <= 1)
|
|
64
|
+
return;
|
|
65
|
+
commit(columns.filter((_, position) => position !== index));
|
|
66
|
+
}
|
|
67
|
+
function setLabel(index, raw) {
|
|
68
|
+
commit(columns.map((column, position) => {
|
|
69
|
+
if (position !== index || column.kind !== "field")
|
|
70
|
+
return column;
|
|
71
|
+
// No `label: undefined` key: the stored settings should say
|
|
72
|
+
// "no override", not "an override that is nothing".
|
|
73
|
+
if (raw === "")
|
|
74
|
+
return { kind: "field", fieldId: column.fieldId };
|
|
75
|
+
return { kind: "field", fieldId: column.fieldId, label: raw };
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
78
|
+
// Every row carries the same three buttons, so "Move up" on its own is
|
|
79
|
+
// three identical names in a list of columns: which one moves is only
|
|
80
|
+
// legible from the row a sighted user can see it in. Each button says
|
|
81
|
+
// the column it acts on, as the row itself names it.
|
|
82
|
+
function label(column) {
|
|
83
|
+
if (column.kind === "property")
|
|
84
|
+
return CONTENT_LIST_PROPERTY_LABELS[column.property];
|
|
85
|
+
const found = findFieldInTypes(column.fieldId, documentTypes);
|
|
86
|
+
return found ? `${column.fieldId} (${found.typeName}: ${found.fieldName})` : column.fieldId;
|
|
87
|
+
}
|
|
88
|
+
return (_jsxs("div", { className: "flex flex-col gap-4", children: [_jsx("ul", { className: "flex flex-col gap-2", children: columns.map((column, index) => (_jsxs("li", { className: "flex flex-wrap items-end gap-2 rounded-md border border-border-default p-2", children: [_jsx("span", { className: "text-sm text-text-primary", children: label(column) }), column.kind === "field" && (_jsxs("div", { className: "flex flex-col gap-1", children: [_jsx("label", { htmlFor: `${labelIdPrefix}-${index}`, className: "text-xs font-medium text-text-secondary", children: "Label" }), _jsx(Input, { id: `${labelIdPrefix}-${index}`, value: column.label ?? "", onChange: (event) => setLabel(index, event.target.value) })] })), _jsxs("div", { className: "flex items-center gap-1 ms-auto", children: [_jsx(Button, { type: "button", variant: "ghost", size: "sm", "aria-label": `Move up ${label(column)}`, disabled: index === 0, onClick: () => move(index, -1), children: "Move up" }), _jsx(Button, { type: "button", variant: "ghost", size: "sm", "aria-label": `Move down ${label(column)}`, disabled: index === columns.length - 1, onClick: () => move(index, 1), children: "Move down" }), _jsx(Button, { type: "button", variant: "ghost", size: "sm", "aria-label": `Remove ${label(column)}`, disabled: columns.length <= 1, onClick: () => remove(index), children: "Remove" })] })] }, contentListColumnKey(column)))) }), _jsxs("div", { className: "flex flex-col gap-1", children: [_jsx("label", { htmlFor: addId, className: "text-xs font-medium text-text-secondary", children: "Add column" }), _jsxs("select", { id: addId, value: "", className: SELECT_CLASS, onChange: (event) => handlePick(event.target.value), children: [_jsx("option", { value: "", children: "Choose a column" }), availableProperties.length > 0 && (_jsx("optgroup", { label: "Properties", children: availableProperties.map((property) => (_jsx("option", { value: `${PROPERTY_PREFIX}${property}`, children: CONTENT_LIST_PROPERTY_LABELS[property] }, property))) })), (documentTypes ?? []).map((documentType) => {
|
|
89
|
+
const fields = documentType.fields.filter((field) => !chosenFieldIds.has(field.id));
|
|
90
|
+
if (fields.length === 0)
|
|
91
|
+
return null;
|
|
92
|
+
return (_jsx("optgroup", { label: documentType.name, children: fields.map((field) => (_jsx("option", { value: `${FIELD_PREFIX}${field.id}`, children: `${field.name} (${field.id})` }, field.id))) }, documentType.id));
|
|
93
|
+
})] })] }), _jsxs("div", { className: "flex flex-wrap items-end gap-2", children: [_jsxs("div", { className: "flex flex-col gap-1", children: [_jsx("label", { htmlFor: aliasId, className: "text-xs font-medium text-text-secondary", children: "Other alias" }), _jsx(Input, { id: aliasId, value: alias, onChange: (event) => setAlias(event.target.value) })] }), _jsx(Button, { type: "button", variant: "outline", onClick: () => {
|
|
94
|
+
addField(alias);
|
|
95
|
+
setAlias("");
|
|
96
|
+
}, children: "Add" })] })] }));
|
|
97
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CONTENT_LIST_PROPERTIES, type ContentListColumn, type ContentListSettings } from "@kardalum/api-schemas";
|
|
2
|
+
import { type ContentHostDocumentType } from "../plugin-context.js";
|
|
3
|
+
export type ContentListProperty = (typeof CONTENT_LIST_PROPERTIES)[number];
|
|
4
|
+
/** Column headers for the six built-in row properties. */
|
|
5
|
+
export declare const CONTENT_LIST_PROPERTY_LABELS: Readonly<Record<ContentListProperty, string>>;
|
|
6
|
+
export declare const CONTENT_LIST_HEADER_CELL_CLASS = "border-b border-border-default px-2 py-2 text-start text-xs font-medium text-text-secondary";
|
|
7
|
+
/** A stable React key (and a settings identity) for one column. */
|
|
8
|
+
export declare function contentListColumnKey(column: ContentListColumn): string;
|
|
9
|
+
/** The field's name on the first page document type that declares it. */
|
|
10
|
+
export declare function findFieldInTypes(fieldId: string, documentTypes: ContentHostDocumentType[] | undefined): {
|
|
11
|
+
typeName: string;
|
|
12
|
+
fieldName: string;
|
|
13
|
+
} | null;
|
|
14
|
+
/** The header text for a column: an explicit label wins, then the field's
|
|
15
|
+
* own name where a document type declares it, then the raw alias. */
|
|
16
|
+
export declare function contentListColumnHeader(column: ContentListColumn, documentTypes: ContentHostDocumentType[] | undefined): string;
|
|
17
|
+
export declare function resolveContentListColumns(settings: Partial<ContentListSettings>): ContentListColumn[];
|
|
18
|
+
export declare function ContentListInputView(): import("react").JSX.Element;
|
|
19
|
+
export declare function ContentListReadOnlyView(): import("react").JSX.Element;
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { CONTENT_LIST_DEFAULT_SETTINGS, } from "@kardalum/api-schemas";
|
|
4
|
+
import { Badge, Button, Input } from "@kardalum/ui";
|
|
5
|
+
import { Lock } from "lucide-react";
|
|
6
|
+
import { MANAGE_API, useContentHost, usePluginApi, usePluginSettings, } from "../plugin-context.js";
|
|
7
|
+
/** Column headers for the six built-in row properties. */
|
|
8
|
+
export const CONTENT_LIST_PROPERTY_LABELS = {
|
|
9
|
+
name: "Name",
|
|
10
|
+
id: "Id",
|
|
11
|
+
url: "URL",
|
|
12
|
+
status: "Status",
|
|
13
|
+
updatedAt: "Updated",
|
|
14
|
+
publishedAt: "Published",
|
|
15
|
+
};
|
|
16
|
+
const STATUS_LABELS = {
|
|
17
|
+
draft: "Draft",
|
|
18
|
+
published: "Published",
|
|
19
|
+
changes: "Changes not published",
|
|
20
|
+
};
|
|
21
|
+
const STATUS_VARIANTS = {
|
|
22
|
+
draft: "neutral",
|
|
23
|
+
published: "success",
|
|
24
|
+
changes: "warning",
|
|
25
|
+
};
|
|
26
|
+
const PAGE_SIZE = 25;
|
|
27
|
+
const SEARCH_DEBOUNCE_MS = 300;
|
|
28
|
+
const LOAD_ERROR = "Could not load the children.";
|
|
29
|
+
// S278b (D1, D14): what a locked row says. A row the person may not read
|
|
30
|
+
// arrives with `fields: {}` (its name, url and status stay), so its field
|
|
31
|
+
// cells say so instead of rendering as empty.
|
|
32
|
+
const RESTRICTED_FOR_YOU = "Restricted for you";
|
|
33
|
+
const RESTRICTED_CELL = "Restricted";
|
|
34
|
+
/** D1: a restriction refused one of the row's actions. A refusal by the
|
|
35
|
+
* role is not the page's doing, so it lights no lock. */
|
|
36
|
+
function isRestrictedForYou(row) {
|
|
37
|
+
return Object.values(row.access?.denied ?? {}).some((denial) => denial?.reason === "not-granted");
|
|
38
|
+
}
|
|
39
|
+
function LockMark() {
|
|
40
|
+
return (_jsx("span", { role: "img", "aria-label": RESTRICTED_FOR_YOU, className: "inline-flex shrink-0 text-text-tertiary", children: _jsx(Lock, { "aria-hidden": "true", className: "size-3" }) }));
|
|
41
|
+
}
|
|
42
|
+
// The row's own keyboard stop: the name is the only control in a row, so
|
|
43
|
+
// it carries the focus ring the row would otherwise need.
|
|
44
|
+
const NAME_BUTTON_CLASS = "text-start text-sm font-medium text-primary-600 hover:underline " +
|
|
45
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-600";
|
|
46
|
+
export const CONTENT_LIST_HEADER_CELL_CLASS = "border-b border-border-default px-2 py-2 text-start text-xs font-medium text-text-secondary";
|
|
47
|
+
/** A stable React key (and a settings identity) for one column. */
|
|
48
|
+
export function contentListColumnKey(column) {
|
|
49
|
+
return column.kind === "property" ? `property:${column.property}` : `field:${column.fieldId}`;
|
|
50
|
+
}
|
|
51
|
+
/** The field's name on the first page document type that declares it. */
|
|
52
|
+
export function findFieldInTypes(fieldId, documentTypes) {
|
|
53
|
+
for (const documentType of documentTypes ?? []) {
|
|
54
|
+
const field = documentType.fields.find((candidate) => candidate.id === fieldId);
|
|
55
|
+
if (field)
|
|
56
|
+
return { typeName: documentType.name, fieldName: field.name };
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
/** The header text for a column: an explicit label wins, then the field's
|
|
61
|
+
* own name where a document type declares it, then the raw alias. */
|
|
62
|
+
export function contentListColumnHeader(column, documentTypes) {
|
|
63
|
+
if (column.kind === "property")
|
|
64
|
+
return CONTENT_LIST_PROPERTY_LABELS[column.property];
|
|
65
|
+
if (column.label)
|
|
66
|
+
return column.label;
|
|
67
|
+
return findFieldInTypes(column.fieldId, documentTypes)?.fieldName ?? column.fieldId;
|
|
68
|
+
}
|
|
69
|
+
// A DataTypeConfig stores `settings: {}` until a webmaster opens the
|
|
70
|
+
// settings view (see TEXT_DEFAULT_SETTINGS), so "no columns" reaches the
|
|
71
|
+
// view as a real, expected state and means "the defaults", not "an empty
|
|
72
|
+
// table".
|
|
73
|
+
export function resolveContentListColumns(settings) {
|
|
74
|
+
return settings.columns && settings.columns.length > 0 ? settings.columns : CONTENT_LIST_DEFAULT_SETTINGS.columns;
|
|
75
|
+
}
|
|
76
|
+
function renderFieldValue(value) {
|
|
77
|
+
if (value === undefined || value === null)
|
|
78
|
+
return null;
|
|
79
|
+
if (typeof value === "string")
|
|
80
|
+
return _jsx("span", { dir: "auto", children: value });
|
|
81
|
+
if (typeof value === "number")
|
|
82
|
+
return _jsx("span", { dir: "auto", children: String(value) });
|
|
83
|
+
if (typeof value === "boolean")
|
|
84
|
+
return value ? "Yes" : "No";
|
|
85
|
+
if (typeof value !== "object")
|
|
86
|
+
return "Value";
|
|
87
|
+
const candidate = value;
|
|
88
|
+
// A TipTap/ProseMirror document. Deliberately named rather than
|
|
89
|
+
// flattened to text: a list cell is not where a body is read, and a
|
|
90
|
+
// partial flattening would misrepresent what the field holds.
|
|
91
|
+
if (candidate["type"] === "doc")
|
|
92
|
+
return "Rich text";
|
|
93
|
+
if (candidate["type"] === undefined && (candidate["mediaId"] !== undefined || candidate["id"] !== undefined)) {
|
|
94
|
+
return "Image";
|
|
95
|
+
}
|
|
96
|
+
// The built-in date range's real member names (built-in-value-schemas.ts
|
|
97
|
+
// and date-range-view.tsx), not from/to.
|
|
98
|
+
if (candidate["start"] !== undefined || candidate["end"] !== undefined)
|
|
99
|
+
return "Date range";
|
|
100
|
+
return "Value";
|
|
101
|
+
}
|
|
102
|
+
// A stored timestamp can be malformed (a hand-edited row, an import), and
|
|
103
|
+
// a list cell is not the place to take the whole editing screen down over
|
|
104
|
+
// it: an unreadable date renders as nothing.
|
|
105
|
+
function formatDate(formatter, iso) {
|
|
106
|
+
if (!iso)
|
|
107
|
+
return "";
|
|
108
|
+
const parsed = new Date(iso);
|
|
109
|
+
if (Number.isNaN(parsed.getTime()))
|
|
110
|
+
return "";
|
|
111
|
+
return formatter.format(parsed);
|
|
112
|
+
}
|
|
113
|
+
function ContentListTable({ canCreate = false }) {
|
|
114
|
+
const host = useContentHost();
|
|
115
|
+
const fetchApi = usePluginApi();
|
|
116
|
+
const settings = usePluginSettings();
|
|
117
|
+
const searchId = useId();
|
|
118
|
+
const columns = useMemo(() => resolveContentListColumns(settings), [settings]);
|
|
119
|
+
// Only the aliases the configured columns actually show, so the
|
|
120
|
+
// response stays bounded by the table rather than the whole document.
|
|
121
|
+
const fieldsParam = useMemo(() => columns.flatMap((column) => (column.kind === "field" ? [column.fieldId] : [])).join(","), [columns]);
|
|
122
|
+
const [items, setItems] = useState([]);
|
|
123
|
+
const [nextCursor, setNextCursor] = useState(null);
|
|
124
|
+
const [loading, setLoading] = useState(false);
|
|
125
|
+
const [error, setError] = useState(null);
|
|
126
|
+
const [search, setSearch] = useState("");
|
|
127
|
+
const [appliedSearch, setAppliedSearch] = useState("");
|
|
128
|
+
// The cursor the failed request asked for, so Retry asks for THAT page
|
|
129
|
+
// again instead of silently throwing away the rows already on screen and
|
|
130
|
+
// starting over. null is the first page, which is also what a failed
|
|
131
|
+
// first page should retry.
|
|
132
|
+
const [failedCursor, setFailedCursor] = useState(null);
|
|
133
|
+
// Set when Load more is clicked, to the row index the first appended row
|
|
134
|
+
// will land on. Load more can be the last page, in which case the button
|
|
135
|
+
// unmounts and focus would fall to the body.
|
|
136
|
+
const focusRowIndex = useRef(null);
|
|
137
|
+
const bodyRef = useRef(null);
|
|
138
|
+
// One check answers both "is there a page?" and "can I navigate?": the
|
|
139
|
+
// host's two branches keep the id and the navigations together.
|
|
140
|
+
const page = host?.page ?? null;
|
|
141
|
+
const nodeId = page?.nodeId ?? null;
|
|
142
|
+
const requestId = useRef(0);
|
|
143
|
+
useEffect(() => {
|
|
144
|
+
const timer = setTimeout(() => setAppliedSearch(search.trim()), SEARCH_DEBOUNCE_MS);
|
|
145
|
+
return () => clearTimeout(timer);
|
|
146
|
+
}, [search]);
|
|
147
|
+
const load = useCallback(async (cursor) => {
|
|
148
|
+
if (!nodeId)
|
|
149
|
+
return;
|
|
150
|
+
// Guards against an out-of-order response overwriting a newer one
|
|
151
|
+
// (a slow first page landing after a fast filtered page).
|
|
152
|
+
const id = ++requestId.current;
|
|
153
|
+
setLoading(true);
|
|
154
|
+
setError(null);
|
|
155
|
+
try {
|
|
156
|
+
const params = new URLSearchParams({ limit: String(PAGE_SIZE) });
|
|
157
|
+
if (fieldsParam)
|
|
158
|
+
params.set("fields", fieldsParam);
|
|
159
|
+
if (appliedSearch)
|
|
160
|
+
params.set("name", appliedSearch);
|
|
161
|
+
if (cursor)
|
|
162
|
+
params.set("cursor", cursor);
|
|
163
|
+
const response = await fetchApi(`${MANAGE_API}/content/${nodeId}/list?${params.toString()}`);
|
|
164
|
+
if (!response.ok)
|
|
165
|
+
throw new Error(`Request failed (${response.status})`);
|
|
166
|
+
const body = (await response.json());
|
|
167
|
+
if (id !== requestId.current)
|
|
168
|
+
return;
|
|
169
|
+
setItems((previous) => (cursor ? [...previous, ...body.items] : body.items));
|
|
170
|
+
setNextCursor(body.nextCursor);
|
|
171
|
+
}
|
|
172
|
+
catch {
|
|
173
|
+
if (id !== requestId.current)
|
|
174
|
+
return;
|
|
175
|
+
setError(LOAD_ERROR);
|
|
176
|
+
setFailedCursor(cursor);
|
|
177
|
+
setNextCursor(null);
|
|
178
|
+
focusRowIndex.current = null;
|
|
179
|
+
}
|
|
180
|
+
finally {
|
|
181
|
+
if (id === requestId.current)
|
|
182
|
+
setLoading(false);
|
|
183
|
+
}
|
|
184
|
+
}, [appliedSearch, fetchApi, fieldsParam, nodeId]);
|
|
185
|
+
// `load` changes identity whenever the filter does, which is what makes
|
|
186
|
+
// a changed search term restart from the first page: a cursor minted
|
|
187
|
+
// against the unfiltered list points into a different result set and is
|
|
188
|
+
// never reused across a filter change.
|
|
189
|
+
useEffect(() => {
|
|
190
|
+
void load(null);
|
|
191
|
+
}, [load]);
|
|
192
|
+
// After an append, the first NEW row's name button takes focus, so a
|
|
193
|
+
// keyboard user lands on what they just asked for rather than on the
|
|
194
|
+
// body when the last page removes the Load more button. A table whose
|
|
195
|
+
// columns do not include the name has no button to move to, and focus
|
|
196
|
+
// is left alone.
|
|
197
|
+
useEffect(() => {
|
|
198
|
+
const index = focusRowIndex.current;
|
|
199
|
+
if (index === null || items.length <= index)
|
|
200
|
+
return;
|
|
201
|
+
focusRowIndex.current = null;
|
|
202
|
+
bodyRef.current?.querySelectorAll("tr")[index]?.querySelector("button")?.focus();
|
|
203
|
+
}, [items]);
|
|
204
|
+
const dateFormat = useMemo(() => new Intl.DateTimeFormat(undefined, { dateStyle: "medium" }), []);
|
|
205
|
+
// A host with no page (the Data Types editor, which hosts this
|
|
206
|
+
// context only for its document types) is the same state as no host at
|
|
207
|
+
// all as far as a table of children goes.
|
|
208
|
+
if (!host || page === null) {
|
|
209
|
+
return _jsx("p", { className: "text-sm text-text-secondary", children: "Shown on a page's editing screen." });
|
|
210
|
+
}
|
|
211
|
+
// `page` is passed in rather than closed over: it is narrowed to a real
|
|
212
|
+
// page by the guard above, and TypeScript does not carry that narrowing
|
|
213
|
+
// into a nested function.
|
|
214
|
+
function renderCell(row, column, page) {
|
|
215
|
+
// D14: a row the person may not read is listed, locked and not
|
|
216
|
+
// openable; its fields were withheld, which is not the same as empty.
|
|
217
|
+
// A server from before S276 sent no flags: its rows are all readable.
|
|
218
|
+
const readable = row.access?.read !== false;
|
|
219
|
+
if (column.kind === "field") {
|
|
220
|
+
return readable ? (renderFieldValue(row.fields[column.fieldId])) : (_jsx("span", { className: "text-text-tertiary", children: RESTRICTED_CELL }));
|
|
221
|
+
}
|
|
222
|
+
switch (column.property) {
|
|
223
|
+
case "name":
|
|
224
|
+
return (_jsxs("span", { className: "inline-flex items-center gap-2", children: [readable ? (_jsx("button", { type: "button", dir: "auto", className: NAME_BUTTON_CLASS, onClick: () => page.openContent(row.id), children: row.name })) : (_jsx("span", { dir: "auto", className: "text-sm text-text-tertiary", children: row.name })), isRestrictedForYou(row) && _jsx(LockMark, {})] }));
|
|
225
|
+
case "id":
|
|
226
|
+
return _jsx("span", { className: "font-mono text-xs text-text-secondary", children: row.id });
|
|
227
|
+
case "url":
|
|
228
|
+
return _jsx("span", { dir: "auto", children: row.url });
|
|
229
|
+
case "status":
|
|
230
|
+
return _jsx(Badge, { variant: STATUS_VARIANTS[row.status], children: STATUS_LABELS[row.status] });
|
|
231
|
+
case "updatedAt":
|
|
232
|
+
return formatDate(dateFormat, row.updatedAt);
|
|
233
|
+
case "publishedAt":
|
|
234
|
+
return formatDate(dateFormat, row.publishedAt);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
const documentTypes = host.documentTypes;
|
|
238
|
+
return (_jsxs("div", { className: "flex flex-col gap-3", children: [_jsxs("div", { className: "flex flex-wrap items-end gap-3", children: [_jsxs("div", { className: "flex flex-col gap-1", children: [_jsx("label", { htmlFor: searchId, className: "text-xs font-medium text-text-secondary", children: "Search by name" }), _jsx(Input, { id: searchId, value: search, onChange: (event) => setSearch(event.target.value) })] }), canCreate && (_jsx(Button, { type: "button", className: "ms-auto", onClick: () => page.createChild(page.nodeId), children: "New" }))] }), error && (_jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx("p", { role: "alert", className: "text-sm text-danger-600", children: error }), _jsx(Button, { type: "button", variant: "outline", size: "sm", onClick: () => void load(failedCursor), children: "Retry" })] })), items.length > 0 && (_jsxs("table", { className: "w-full border-collapse text-sm text-text-primary", children: [_jsx("caption", { className: "sr-only", children: "Children" }), _jsx("thead", { children: _jsx("tr", { children: columns.map((column) => (_jsx("th", { scope: "col", className: CONTENT_LIST_HEADER_CELL_CLASS, children: contentListColumnHeader(column, documentTypes) }, contentListColumnKey(column)))) }) }), _jsx("tbody", { ref: bodyRef, children: items.map((row) => (_jsx("tr", { children: columns.map((column) => (_jsx("td", { className: "border-b border-border-subtle px-2 py-2 align-top", children: renderCell(row, column, page) }, contentListColumnKey(column)))) }, row.id))) })] })), loading && (_jsx("p", { role: "status", className: "text-sm text-text-secondary", children: "Loading\u2026" })), !loading && !error && items.length === 0 && (_jsx("p", { role: "status", className: "text-sm text-text-secondary", children: appliedSearch ? "Nothing matches." : "No children yet." })), nextCursor !== null && (_jsx(Button, { type: "button", variant: "outline", size: "sm", className: "self-start", disabled: loading, onClick: () => {
|
|
239
|
+
focusRowIndex.current = items.length;
|
|
240
|
+
void load(nextCursor);
|
|
241
|
+
}, children: "Load more" }))] }));
|
|
242
|
+
}
|
|
243
|
+
export function ContentListInputView() {
|
|
244
|
+
return _jsx(ContentListTable, { canCreate: true });
|
|
245
|
+
}
|
|
246
|
+
export function ContentListReadOnlyView() {
|
|
247
|
+
return _jsx(ContentListTable, {});
|
|
248
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export { RENDITION_INELIGIBLE_TYPES, isRenditionIneligible } from "../rendition-eligibility.js";
|
|
3
|
+
/**
|
|
4
|
+
* The Cut control, supplied by the host for the same reason the file
|
|
5
|
+
* upload's Replace is: cutting needs a media item, a cropper dialog and an
|
|
6
|
+
* i18n instance to name the button in, and all three live in the admin UI.
|
|
7
|
+
* A host that supplies no handler gets no control, rather than one that
|
|
8
|
+
* would throw when pressed.
|
|
9
|
+
*/
|
|
10
|
+
export interface MediaRenditionCut {
|
|
11
|
+
/** Opens the host's cropper. Nothing is cut or uploaded here. */
|
|
12
|
+
onCut: () => void;
|
|
13
|
+
/**
|
|
14
|
+
* The control's visible label, from the host. The one kind of string in
|
|
15
|
+
* this package that is not hardcoded English (see built-ins.tsx's
|
|
16
|
+
* TextSettingsView for why the rest are): the host already has to be
|
|
17
|
+
* involved for the control to exist, and it has the translation this
|
|
18
|
+
* package cannot reach. Required, so this package never needs an English
|
|
19
|
+
* default for a string only the host can say.
|
|
20
|
+
*/
|
|
21
|
+
label: string;
|
|
22
|
+
/** A cut is in flight: the control does not respond. */
|
|
23
|
+
busy: boolean;
|
|
24
|
+
}
|
|
25
|
+
/** What a rendition field learns about where it is being rendered. */
|
|
26
|
+
export interface MediaRenditionHost {
|
|
27
|
+
/**
|
|
28
|
+
* The media type of the file this field would be cut FROM, or null when
|
|
29
|
+
* the host has no file to name. Passed down rather than read off
|
|
30
|
+
* MediaFileProvider so a host can mount a Crops tab without also
|
|
31
|
+
* mounting the file field's context.
|
|
32
|
+
*/
|
|
33
|
+
sourceMimeType: string | null;
|
|
34
|
+
/** The whole control, or nothing at all. */
|
|
35
|
+
cut: MediaRenditionCut | null;
|
|
36
|
+
}
|
|
37
|
+
export interface MediaRenditionProviderProps {
|
|
38
|
+
sourceMimeType: string | null;
|
|
39
|
+
/**
|
|
40
|
+
* Omitted by any host with nowhere to cut, and then no control renders.
|
|
41
|
+
* One object rather than a handler, a label and a busy flag side by
|
|
42
|
+
* side, so `label` is required at the type level: a host that offers the
|
|
43
|
+
* control cannot forget to name it.
|
|
44
|
+
*/
|
|
45
|
+
cut?: MediaRenditionCut;
|
|
46
|
+
children: ReactNode;
|
|
47
|
+
}
|
|
48
|
+
export declare function MediaRenditionProvider({ sourceMimeType, cut, children }: MediaRenditionProviderProps): import("react").JSX.Element;
|
|
49
|
+
export declare function useMediaRendition(): MediaRenditionHost | null;
|
|
50
|
+
export declare function CropInputView(): import("react").JSX.Element;
|
|
51
|
+
export declare function CropReadOnlyView(): import("react").JSX.Element;
|
|
52
|
+
export declare function ThumbnailInputView(): import("react").JSX.Element;
|
|
53
|
+
export declare function ThumbnailReadOnlyView(): import("react").JSX.Element;
|
|
54
|
+
export declare function CropSettingsView(): import("react").JSX.Element;
|
|
55
|
+
export declare function ThumbnailSettingsView(): import("react").JSX.Element;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useState } from "react";
|
|
3
|
+
import { CROP_EDITOR_ID, CropSettingsSchema, THUMBNAIL_EDITOR_ID, ThumbnailSettingsSchema, renditionName, } from "@kardalum/api-schemas";
|
|
4
|
+
import { Button, Input, PropertyField } from "@kardalum/ui";
|
|
5
|
+
import { usePluginSettings, usePluginSettingsValue, usePluginValue } from "../plugin-context.js";
|
|
6
|
+
import { isRenditionIneligible } from "../rendition-eligibility.js";
|
|
7
|
+
// S234c: the crop and thumbnail editors' field views. A media document
|
|
8
|
+
// type carries one field per rendition it wants, and this is the tile the
|
|
9
|
+
// admin renders for each of them.
|
|
10
|
+
//
|
|
11
|
+
// What is here and what is not. These views show what the field IS (its
|
|
12
|
+
// ratio, the suffix its rendition is filed under, whether this version has
|
|
13
|
+
// been cut) and hand the one action back to the host. The cropper dialog,
|
|
14
|
+
// the canvas cut and the Crops tab that arranges the tiles all live in the
|
|
15
|
+
// admin, because they need the media item's versions and its API, neither
|
|
16
|
+
// of which this package has.
|
|
17
|
+
//
|
|
18
|
+
// Unlike the file upload editor (file-upload-view.tsx), a crop field DOES
|
|
19
|
+
// store a value: the rectangle it last cut, as fractions of the source
|
|
20
|
+
// (spec section 7). So these views read usePluginValue() like an ordinary
|
|
21
|
+
// built-in. What they take from the host context below is only what the
|
|
22
|
+
// field cannot know: which file the item holds, and whether there is
|
|
23
|
+
// anywhere to cut it.
|
|
24
|
+
//
|
|
25
|
+
// A thumbnail is the other half of that split: it is automatic, cut
|
|
26
|
+
// whenever bytes arrive, so its field stores nothing and its tile offers
|
|
27
|
+
// no action at all.
|
|
28
|
+
// The set and the question live in ../rendition-eligibility.js, which has
|
|
29
|
+
// no React in it, because the SERVER refuses the same formats at the cut
|
|
30
|
+
// route and must be able to read them without importing this file. They
|
|
31
|
+
// are re-exported here so every browser-side caller still reaches them
|
|
32
|
+
// where the crop view lives.
|
|
33
|
+
export { RENDITION_INELIGIBLE_TYPES, isRenditionIneligible } from "../rendition-eligibility.js";
|
|
34
|
+
// Null outside a provider, the same non-throwing shape useContentHost()
|
|
35
|
+
// uses and for the same reason: the Data Types editor and the document
|
|
36
|
+
// type builder's field preview render these views where no media item
|
|
37
|
+
// exists, which is a real state and not a host wiring bug.
|
|
38
|
+
const MediaRenditionContext = createContext(null);
|
|
39
|
+
// The context value is rebuilt on every render rather than memoized, the
|
|
40
|
+
// same trade MediaFileProvider makes: both members are things the host
|
|
41
|
+
// owns and re-renders with, and the only consumers are the four views
|
|
42
|
+
// below, which re-render with the host regardless.
|
|
43
|
+
export function MediaRenditionProvider({ sourceMimeType, cut, children }) {
|
|
44
|
+
return (_jsx(MediaRenditionContext.Provider, { value: { sourceMimeType, cut: cut ?? null }, children: children }));
|
|
45
|
+
}
|
|
46
|
+
export function useMediaRendition() {
|
|
47
|
+
return useContext(MediaRenditionContext);
|
|
48
|
+
}
|
|
49
|
+
// A rectangle is fractions of the source, so a whole number of percent is
|
|
50
|
+
// the readable form of it. Rounded, and never presented as the pixel size
|
|
51
|
+
// of the result: that depends on the source, which this view has not seen.
|
|
52
|
+
function percent(fraction) {
|
|
53
|
+
return `${Math.round(fraction * 100)}%`;
|
|
54
|
+
}
|
|
55
|
+
// Shared by the input and read-only views. `actionable` is the only
|
|
56
|
+
// difference between them, exactly as in file-upload-view.tsx: read-only
|
|
57
|
+
// means read-only, however willing the host is.
|
|
58
|
+
function CropDisplay({ actionable }) {
|
|
59
|
+
const settings = usePluginSettings();
|
|
60
|
+
const { value } = usePluginValue();
|
|
61
|
+
const host = useMediaRendition();
|
|
62
|
+
// The builder's field preview mounts every view with an unset value
|
|
63
|
+
// (field-row.tsx's FieldPreview), so undefined and null are one state
|
|
64
|
+
// here: this field holds no rectangle.
|
|
65
|
+
const rect = value ?? null;
|
|
66
|
+
const uncuttable = host !== null && isRenditionIneligible(host.sourceMimeType);
|
|
67
|
+
const cut = actionable && !uncuttable ? (host?.cut ?? null) : null;
|
|
68
|
+
// A presence check, not a validity one. `renditionName` reads the ratio
|
|
69
|
+
// straight off the settings, so a row with no ratio at all would throw
|
|
70
|
+
// inside it; a row with a ratio nothing can cut is a different problem,
|
|
71
|
+
// and one this view is not the place to catch.
|
|
72
|
+
const ratio = settings.ratio;
|
|
73
|
+
const status = uncuttable
|
|
74
|
+
? "This format cannot be cut."
|
|
75
|
+
: rect === null
|
|
76
|
+
? "Not cut yet."
|
|
77
|
+
: `Cut from a region ${percent(rect.w)} wide and ${percent(rect.h)} tall.`;
|
|
78
|
+
return (_jsxs("div", { className: "flex flex-col gap-1 text-sm text-text-primary", children: [ratio ? (_jsxs("p", { className: "font-medium", children: ["Ratio ", _jsx("span", { className: "font-mono", children: ratio })] })) : (_jsx("p", { className: "font-medium", children: "No ratio set." })), ratio ? (_jsxs("p", { className: "text-xs text-text-secondary", children: ["Saves as the", " ", _jsx("span", { className: "font-mono", children: renditionName({
|
|
79
|
+
editorId: CROP_EDITOR_ID,
|
|
80
|
+
settings: { ratio, maxWidth: settings.maxWidth ?? null },
|
|
81
|
+
}) }), " ", "rendition."] })) : null, settings.maxWidth != null ? (_jsxs("p", { className: "text-xs text-text-secondary", children: ["At most ", settings.maxWidth, " px wide."] })) : null, _jsx("p", { className: "text-xs text-text-secondary", children: status }), cut ? (_jsx("div", { className: "mt-2 flex items-center gap-2", children: _jsx(Button, { type: "button", variant: "outline", size: "sm", disabled: cut.busy, onClick: cut.onCut, children: cut.label }) })) : null] }));
|
|
82
|
+
}
|
|
83
|
+
export function CropInputView() {
|
|
84
|
+
return _jsx(CropDisplay, { actionable: true });
|
|
85
|
+
}
|
|
86
|
+
export function CropReadOnlyView() {
|
|
87
|
+
return _jsx(CropDisplay, { actionable: false });
|
|
88
|
+
}
|
|
89
|
+
// One display for all three thumbnail slots: there is nothing to press on
|
|
90
|
+
// any of them, so input and read-only are the same tile.
|
|
91
|
+
function ThumbnailDisplay() {
|
|
92
|
+
const settings = usePluginSettings();
|
|
93
|
+
const host = useMediaRendition();
|
|
94
|
+
const longestEdge = settings.longestEdge;
|
|
95
|
+
if (host !== null && isRenditionIneligible(host.sourceMimeType)) {
|
|
96
|
+
return _jsx("p", { className: "text-xs text-text-secondary", children: "This format cannot be cut." });
|
|
97
|
+
}
|
|
98
|
+
return (_jsxs("div", { className: "flex flex-col gap-1 text-sm text-text-primary", children: [_jsx("p", { className: "font-medium", children: "Automatic" }), longestEdge != null ? (_jsxs(_Fragment, { children: [_jsxs("p", { className: "text-xs text-text-secondary", children: ["Longest edge ", longestEdge, " px."] }), _jsxs("p", { className: "text-xs text-text-secondary", children: ["Saves as the", " ", _jsx("span", { className: "font-mono", children: renditionName({ editorId: THUMBNAIL_EDITOR_ID, settings: { longestEdge } }) }), " ", "rendition."] })] })) : null] }));
|
|
99
|
+
}
|
|
100
|
+
export function ThumbnailInputView() {
|
|
101
|
+
return _jsx(ThumbnailDisplay, {});
|
|
102
|
+
}
|
|
103
|
+
export function ThumbnailReadOnlyView() {
|
|
104
|
+
return _jsx(ThumbnailDisplay, {});
|
|
105
|
+
}
|
|
106
|
+
// Rendered by the Data Types editor only, so both settings views below
|
|
107
|
+
// take the settings-EDITING hook (usePluginSettingsValue), the split every
|
|
108
|
+
// other built-in follows.
|
|
109
|
+
//
|
|
110
|
+
// Both keep the text being typed in local state rather than writing every
|
|
111
|
+
// keystroke into the settings object. CropSettings and ThumbnailSettings
|
|
112
|
+
// have no optional member, so a half-typed ratio or a longest edge of "4"
|
|
113
|
+
// on its way to "480" is not a value the row may hold: the settings object
|
|
114
|
+
// is what gets saved, and the server validates it against the JSON Schema
|
|
115
|
+
// mirror of these same Zod schemas (built-in-settings-schemas.ts).
|
|
116
|
+
export function CropSettingsView() {
|
|
117
|
+
const { value: settings, onChange } = usePluginSettingsValue();
|
|
118
|
+
const [ratio, setRatio] = useState(settings.ratio ?? "");
|
|
119
|
+
const [maxWidth, setMaxWidth] = useState(settings.maxWidth == null ? "" : String(settings.maxWidth));
|
|
120
|
+
// The whole object, parsed by the schema that owns the shape, and
|
|
121
|
+
// committed only when it parses. `parsed.data` rather than a spread of
|
|
122
|
+
// the old settings: the mirror refuses unknown properties, so carrying
|
|
123
|
+
// one forward would make the row unsaveable.
|
|
124
|
+
function commit(nextRatio, nextMaxWidth) {
|
|
125
|
+
const parsed = CropSettingsSchema.safeParse({
|
|
126
|
+
ratio: nextRatio,
|
|
127
|
+
maxWidth: nextMaxWidth === "" ? null : Number(nextMaxWidth),
|
|
128
|
+
});
|
|
129
|
+
if (parsed.success)
|
|
130
|
+
onChange(parsed.data);
|
|
131
|
+
}
|
|
132
|
+
const ratioError = ratio === "" || CropSettingsSchema.shape.ratio.safeParse(ratio).success
|
|
133
|
+
? undefined
|
|
134
|
+
: "A ratio looks like 3:4, with no leading zeros.";
|
|
135
|
+
const maxWidthError = maxWidth === "" || CropSettingsSchema.shape.maxWidth.safeParse(Number(maxWidth)).success
|
|
136
|
+
? undefined
|
|
137
|
+
: "A maximum width is a whole number of pixels, at least 1.";
|
|
138
|
+
return (_jsxs("div", { className: "flex flex-col gap-4", children: [_jsx(PropertyField, { label: "Ratio", htmlFor: "crop-settings-ratio", required: true, requiredText: "Required", helpText: "The shape the cropper locks to, width first, such as 3:4.", error: ratioError, children: _jsx(Input, { id: "crop-settings-ratio", value: ratio, onChange: (e) => {
|
|
139
|
+
setRatio(e.target.value);
|
|
140
|
+
commit(e.target.value, maxWidth);
|
|
141
|
+
} }) }), _jsx(PropertyField, { label: "Maximum width", htmlFor: "crop-settings-max-width", helpText: "A ceiling in pixels. Leave blank for none: the cut then keeps the source region's own resolution, and it never enlarges.", error: maxWidthError, children: _jsx(Input, { id: "crop-settings-max-width", type: "number", min: 1, value: maxWidth, onChange: (e) => {
|
|
142
|
+
setMaxWidth(e.target.value);
|
|
143
|
+
commit(ratio, e.target.value);
|
|
144
|
+
} }) })] }));
|
|
145
|
+
}
|
|
146
|
+
export function ThumbnailSettingsView() {
|
|
147
|
+
const { value: settings, onChange } = usePluginSettingsValue();
|
|
148
|
+
const [longestEdge, setLongestEdge] = useState(settings.longestEdge == null ? "" : String(settings.longestEdge));
|
|
149
|
+
function commit(next) {
|
|
150
|
+
const parsed = ThumbnailSettingsSchema.safeParse({ longestEdge: Number(next) });
|
|
151
|
+
if (parsed.success)
|
|
152
|
+
onChange(parsed.data);
|
|
153
|
+
}
|
|
154
|
+
const longestEdgeError = longestEdge === "" || ThumbnailSettingsSchema.safeParse({ longestEdge: Number(longestEdge) }).success
|
|
155
|
+
? undefined
|
|
156
|
+
: "A longest edge is a whole number of pixels, at least 1.";
|
|
157
|
+
return (_jsx("div", { className: "flex flex-col gap-4", children: _jsx(PropertyField, { label: "Longest edge", htmlFor: "thumbnail-settings-longest-edge", required: true, requiredText: "Required", helpText: "The thumbnail's longer side in pixels. The shorter side follows the source's own shape.", error: longestEdgeError, children: _jsx(Input, { id: "thumbnail-settings-longest-edge", type: "number", min: 1, value: longestEdge, onChange: (e) => {
|
|
158
|
+
setLongestEdge(e.target.value);
|
|
159
|
+
commit(e.target.value);
|
|
160
|
+
} }) }) }));
|
|
161
|
+
}
|