@kardalum/plugin-sdk 0.0.0-stage → 0.15.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 +108 -0
- package/LICENSE +202 -0
- package/README.md +70 -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 +99 -0
- package/dist/capabilities.js +363 -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 +93 -0
- package/dist/license-verdict-keys.d.ts +18 -0
- package/dist/license-verdict-keys.js +22 -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 +408 -0
- package/dist/manifest-schema.js +774 -0
- package/dist/manifest.d.ts +546 -0
- package/dist/manifest.js +86 -0
- package/dist/media/media-picker.d.ts +39 -0
- package/dist/media/media-picker.js +438 -0
- package/dist/media/upload-error.d.ts +12 -0
- package/dist/media/upload-error.js +30 -0
- package/dist/plugin-context.d.ts +75 -0
- package/dist/plugin-context.js +70 -0
- package/dist/plugin-screen-context.d.ts +40 -0
- package/dist/plugin-screen-context.js +16 -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 +387 -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 +5 -0
- package/node_modules/@kardalum/api-schemas/dist/api-error.schema.js +6 -0
- package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.d.ts +75 -0
- package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.js +36 -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 +537 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +353 -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 +256 -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 +151 -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 +302 -0
- package/node_modules/@kardalum/api-schemas/dist/core-actions.js +97 -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 +36 -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 +296 -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 +102 -0
- package/node_modules/@kardalum/api-schemas/dist/index.js +58 -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/marketplace-listing-api.schema.d.ts +381 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +197 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +167 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +214 -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 +169 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.js +80 -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 +89 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +134 -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-management-api.schema.d.ts +369 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +393 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +22 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +87 -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 +306 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +328 -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 +90 -0
- package/node_modules/@kardalum/api-schemas/dist/role.schema.js +69 -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/setup-api.schema.d.ts +108 -0
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.js +93 -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 +43 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.js +25 -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 +89 -0
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +68 -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/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 +11 -0
- package/node_modules/@kardalum/plugin-package/dist/index.js +7 -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/sample-content.d.ts +1 -0
- package/node_modules/@kardalum/plugin-package/dist/sample-content.js +17 -0
- package/node_modules/@kardalum/plugin-package/dist/types.d.ts +45 -0
- package/node_modules/@kardalum/plugin-package/dist/types.js +1 -0
- package/node_modules/@kardalum/plugin-package/package.json +49 -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 +86 -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,387 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useId, useRef, useState } from "react";
|
|
3
|
+
import { CROP_EDITOR_ID, CropSettingsSchema, renditionName, renditionShape, THUMBNAIL_EDITOR_ID, ThumbnailSettingsSchema, } from "@kardalum/api-schemas";
|
|
4
|
+
import { Button, cn, Input, PropertyField, usePropertyFieldControl } from "@kardalum/ui";
|
|
5
|
+
import { MediaPicker } from "../media/media-picker.js";
|
|
6
|
+
import { uploadFailureMessage } from "../media/upload-error.js";
|
|
7
|
+
import { usePluginApi, usePluginSettings, usePluginSettingsValue, usePluginValue, } from "../plugin-context.js";
|
|
8
|
+
// downloadUrl is the stable app path for a public item (S186c §1/§3) but
|
|
9
|
+
// carries a freshly minted, short-lived `?token=` for a private one —
|
|
10
|
+
// never persisted; refetch GET /api/media/:id whenever the field's value
|
|
11
|
+
// (media id) changes rather than caching one, so a private item's
|
|
12
|
+
// preview always has a live token.
|
|
13
|
+
//
|
|
14
|
+
// The crop is read from GET /api/media/:id/renditions, and only when the
|
|
15
|
+
// field asks for one. That listing is the renditions of the item's
|
|
16
|
+
// CURRENT version with the version beside them, which is the same
|
|
17
|
+
// question the renderer answers at read time, so what this view names is
|
|
18
|
+
// what the page will really serve. It is a second request, deliberately:
|
|
19
|
+
// the item response says nothing about crops, and naming a file the
|
|
20
|
+
// picture may not have is worse than one more read on a field that has
|
|
21
|
+
// just changed.
|
|
22
|
+
function useMediaPreview(mediaId, rendition) {
|
|
23
|
+
const fetchApi = usePluginApi();
|
|
24
|
+
const [preview, setPreview] = useState(null);
|
|
25
|
+
const [loading, setLoading] = useState(false);
|
|
26
|
+
const [error, setError] = useState(null);
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (!mediaId) {
|
|
29
|
+
setPreview(null);
|
|
30
|
+
setError(null);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
let cancelled = false;
|
|
34
|
+
setLoading(true);
|
|
35
|
+
setError(null);
|
|
36
|
+
const item = fetchApi(`/api/media/${mediaId}`).then(async (response) => {
|
|
37
|
+
if (!response.ok)
|
|
38
|
+
throw new Error(`Failed to load media (${response.status})`);
|
|
39
|
+
return (await response.json());
|
|
40
|
+
});
|
|
41
|
+
// A failed crop read resolves to "unknown" rather than rejecting: the
|
|
42
|
+
// picture is still the picture, and the facts below then name the
|
|
43
|
+
// file's own name, which is what the renderer falls back to anyway.
|
|
44
|
+
// Only the item read can empty this field's preview. What a failure
|
|
45
|
+
// must NOT do is answer the question it failed to ask, which is why
|
|
46
|
+
// "could not ask" and "asked, and there is none" are different states
|
|
47
|
+
// here (see ResolvedCut).
|
|
48
|
+
const cut = rendition === null
|
|
49
|
+
? Promise.resolve({ state: "unknown" })
|
|
50
|
+
: fetchApi(`/api/media/${mediaId}/renditions`)
|
|
51
|
+
.then(async (response) => {
|
|
52
|
+
if (!response.ok)
|
|
53
|
+
return { state: "unknown" };
|
|
54
|
+
const body = (await response.json());
|
|
55
|
+
const found = body.items.find((item) => item.name === rendition);
|
|
56
|
+
return found ? { state: "found", name: found.name, filename: found.filename } : { state: "absent" };
|
|
57
|
+
})
|
|
58
|
+
.catch(() => ({ state: "unknown" }));
|
|
59
|
+
Promise.all([item, cut])
|
|
60
|
+
.then(([body, found]) => {
|
|
61
|
+
if (!cancelled)
|
|
62
|
+
setPreview({ filename: body.filename, downloadUrl: body.downloadUrl, cut: found });
|
|
63
|
+
})
|
|
64
|
+
.catch((err) => {
|
|
65
|
+
if (!cancelled)
|
|
66
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
67
|
+
})
|
|
68
|
+
.finally(() => {
|
|
69
|
+
if (!cancelled)
|
|
70
|
+
setLoading(false);
|
|
71
|
+
});
|
|
72
|
+
return () => {
|
|
73
|
+
cancelled = true;
|
|
74
|
+
};
|
|
75
|
+
}, [mediaId, rendition, fetchApi]);
|
|
76
|
+
return { preview, loading, error };
|
|
77
|
+
}
|
|
78
|
+
// Sized by the caller: the read-only view shows the picture on its own and
|
|
79
|
+
// keeps the size it has always had, while the input view's sits in a card
|
|
80
|
+
// beside the file's name and the controls (approved mockup, screen 4).
|
|
81
|
+
function PreviewImage({ preview, className }) {
|
|
82
|
+
return (_jsx("img", { src: preview.downloadUrl, alt: preview.filename, className: cn("shrink-0 rounded-md border border-border-default object-cover", className) }));
|
|
83
|
+
}
|
|
84
|
+
function ImageThumbnail({ mediaId }) {
|
|
85
|
+
const { preview, loading, error } = useMediaPreview(mediaId, null);
|
|
86
|
+
if (!mediaId)
|
|
87
|
+
return null;
|
|
88
|
+
if (loading)
|
|
89
|
+
return _jsx("p", { className: "text-xs text-text-secondary", children: "Loading\u2026" });
|
|
90
|
+
if (error)
|
|
91
|
+
return _jsx("p", { className: "text-xs text-danger-600", children: error });
|
|
92
|
+
if (!preview)
|
|
93
|
+
return null;
|
|
94
|
+
return _jsx(PreviewImage, { preview: preview, className: "h-24 w-24" });
|
|
95
|
+
}
|
|
96
|
+
/** The setting as a question: a name the field is asking for, or nothing.
|
|
97
|
+
* An empty string is nothing, the same normalisation `resolveMediaUrl`
|
|
98
|
+
* makes on the server, so the two sides cannot disagree about what was
|
|
99
|
+
* asked. */
|
|
100
|
+
function requestedRendition(settings) {
|
|
101
|
+
return typeof settings.rendition === "string" && settings.rendition.length > 0 ? settings.rendition : null;
|
|
102
|
+
}
|
|
103
|
+
// The picture the field holds, named by what the page will actually show
|
|
104
|
+
// (approved mockup, screen 4). With the crop present that is the crop's
|
|
105
|
+
// own filename plus the line saying where it came from; with the crop
|
|
106
|
+
// genuinely missing the file's own name and the drawer's own "full image"
|
|
107
|
+
// marker, so the same fallback reads the same way on both surfaces. With
|
|
108
|
+
// the question unanswered it is the file's own name and nothing else: a
|
|
109
|
+
// marker we cannot stand behind is worse than no marker.
|
|
110
|
+
//
|
|
111
|
+
// THE "3x4 of espresso-bar.jpg" LINE SAYS THE NAME, not the shape the
|
|
112
|
+
// hint below decodes it to. It is there to explain the `_3x4` in the
|
|
113
|
+
// filename on the line directly above it, and a line that explained it as
|
|
114
|
+
// something the filename does not say would not be an explanation.
|
|
115
|
+
//
|
|
116
|
+
// NEITHER LINE SAYS THE CROP FIELD'S OWN CAPTION ("Portrait"), which the
|
|
117
|
+
// mockup shows. That caption lives on a field of a MEDIA document type.
|
|
118
|
+
// Nothing on this surface can reach it: the field's settings store a name
|
|
119
|
+
// and only a name (ImageSettingsSchema), and two media types may each
|
|
120
|
+
// carry a 3:4 crop under different captions, which makes a derived label
|
|
121
|
+
// confidently wrong. The settings view below, which reads those types to
|
|
122
|
+
// fill its select, is the one place in this file where the caption is
|
|
123
|
+
// known at all.
|
|
124
|
+
function PictureFacts({ preview }) {
|
|
125
|
+
const cut = preview.cut;
|
|
126
|
+
return (_jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("span", { className: "block truncate font-mono text-xs text-text-primary", dir: "auto", children: cut.state === "found" ? cut.filename : preview.filename }), cut.state === "found" && (_jsx("span", { className: "block truncate text-xs text-text-tertiary", dir: "auto", children: `${cut.name} of ${preview.filename}` })), cut.state === "absent" && (_jsx("span", { className: "mt-1 inline-block rounded-sm bg-warning-100 px-1 text-xs text-warning-800", children: "full image" }))] }));
|
|
127
|
+
}
|
|
128
|
+
export function ImageInputView() {
|
|
129
|
+
const { value, onChange } = usePluginValue();
|
|
130
|
+
const settings = usePluginSettings();
|
|
131
|
+
const field = usePropertyFieldControl();
|
|
132
|
+
const fetchApi = usePluginApi();
|
|
133
|
+
const [uploading, setUploading] = useState(false);
|
|
134
|
+
const [error, setError] = useState(null);
|
|
135
|
+
const [picking, setPicking] = useState(false);
|
|
136
|
+
const uploadInputRef = useRef(null);
|
|
137
|
+
const hintId = useId();
|
|
138
|
+
const rendition = requestedRendition(settings);
|
|
139
|
+
const { preview, loading, error: previewError } = useMediaPreview(value, rendition);
|
|
140
|
+
// The field's own hint joins whatever the host's PropertyField already
|
|
141
|
+
// pointed the control at, rather than replacing it: the host describes
|
|
142
|
+
// the field, this describes the shape it asks for.
|
|
143
|
+
const describedBy = [field["aria-describedby"], rendition !== null ? hintId : null].filter(Boolean).join(" ") || undefined;
|
|
144
|
+
async function handleFileChange(event) {
|
|
145
|
+
const file = event.target.files?.[0];
|
|
146
|
+
event.target.value = ""; // lets the same file be re-selected later
|
|
147
|
+
if (!file)
|
|
148
|
+
return;
|
|
149
|
+
setError(null);
|
|
150
|
+
// The field's own limit, honoured as a COURTESY and no longer as the
|
|
151
|
+
// rule (S234d Task 8). The rule is the file upload data type's
|
|
152
|
+
// `maxSizeBytes`, kept on the server, because that is where the bytes
|
|
153
|
+
// arrive: this check runs in one browser on one of the several ways
|
|
154
|
+
// into the library, so nothing can depend on it having run. What it
|
|
155
|
+
// buys is that a file this field would refuse anyway never leaves the
|
|
156
|
+
// machine. Both numbers, same as the server's refusal, so a person
|
|
157
|
+
// knows by how much they are over either way.
|
|
158
|
+
if (settings.maxSizeBytes != null && file.size > settings.maxSizeBytes) {
|
|
159
|
+
setError(`File is too large (${file.size} bytes): the configured limit is ${settings.maxSizeBytes} bytes.`);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
setUploading(true);
|
|
163
|
+
try {
|
|
164
|
+
const formData = new FormData();
|
|
165
|
+
formData.append("file", file);
|
|
166
|
+
const response = await fetchApi("/api/media", { method: "POST", body: formData });
|
|
167
|
+
// The server's own sentence, not a status code: it may be refusing
|
|
168
|
+
// these bytes for the file upload type's limit, which this field
|
|
169
|
+
// knows nothing about, and that refusal names the limit and the
|
|
170
|
+
// size (S234d Task 8).
|
|
171
|
+
if (!response.ok)
|
|
172
|
+
throw new Error(await uploadFailureMessage(response));
|
|
173
|
+
const media = (await response.json());
|
|
174
|
+
onChange(media.id);
|
|
175
|
+
}
|
|
176
|
+
catch (err) {
|
|
177
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
178
|
+
}
|
|
179
|
+
finally {
|
|
180
|
+
setUploading(false);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsxs("div", { className: cn("flex items-center gap-3", value && "rounded-md border border-border-default bg-background-subtle p-3"), children: [value &&
|
|
184
|
+
(loading ? (_jsx("p", { className: "text-xs text-text-secondary", children: "Loading\u2026" })) : previewError ? (_jsx("p", { className: "text-xs text-danger-600", children: previewError })) : preview ? (_jsxs(_Fragment, { children: [_jsx(PreviewImage, { preview: preview, className: "h-16 w-16" }), _jsx(PictureFacts, { preview: preview })] })) : null), _jsxs("div", { ...field, role: "group", "aria-describedby": describedBy, className: cn("flex shrink-0 items-center gap-2", value && "ms-auto"), children: [_jsx(Button, { type: "button", variant: "outline", size: "sm", onClick: () => setPicking(true), children: "Choose" }), _jsx(Button, { type: "button", variant: "outline", size: "sm", disabled: uploading, onClick: () => uploadInputRef.current?.click(), children: uploading ? "Uploading…" : "Upload" }), value && (_jsx(Button, { type: "button", variant: "ghost", size: "sm", disabled: uploading, onClick: () => onChange(null), children: "Remove" }))] })] }), _jsx("input", { ref: uploadInputRef, type: "file", className: "hidden", accept: settings.acceptedTypes && settings.acceptedTypes.length > 0 ? settings.acceptedTypes.join(",") : "image/*", "aria-label": "Upload an image", disabled: uploading, onChange: (e) => void handleFileChange(e) }), rendition !== null && (_jsx("p", { id: hintId, className: "text-xs text-text-tertiary", children: `This field asks for the ${renditionShape(rendition)} rendition. An image without one is shown at full size.` })), error && _jsx("p", { className: "text-xs text-danger-600", children: error }), picking && (_jsx(MediaPicker
|
|
185
|
+
// The field stores one media id and has nowhere to put alt text,
|
|
186
|
+
// so a pick commits and the drawer closes in one gesture. Rich
|
|
187
|
+
// text passes true, because there the alt lives on the node.
|
|
188
|
+
, {
|
|
189
|
+
// The field stores one media id and has nowhere to put alt text,
|
|
190
|
+
// so a pick commits and the drawer closes in one gesture. Rich
|
|
191
|
+
// text passes true, because there the alt lives on the node.
|
|
192
|
+
collectAlt: false, acceptedTypes: settings.acceptedTypes, rendition: rendition ?? undefined, onPick: (item) => onChange(item.id), onClose: () => setPicking(false) }))] }));
|
|
193
|
+
}
|
|
194
|
+
// --- The crops a webmaster can choose from (S234d Task 7b) ---------------
|
|
195
|
+
//
|
|
196
|
+
// A media document type declares its crops as FIELDS, and each field's
|
|
197
|
+
// data type holds the settings the crop's name is derived from. So the
|
|
198
|
+
// list of shapes an image field may ask for is those two listings read
|
|
199
|
+
// together: every media type's fields, resolved against the data types,
|
|
200
|
+
// named by `renditionName`, which is the one thing in the product that
|
|
201
|
+
// derives a rendition name.
|
|
202
|
+
//
|
|
203
|
+
// A VIEW FETCHING IS NOT NEW HERE: media-picker.tsx in this same package
|
|
204
|
+
// reads the media library through the host's fetch, and this follows it,
|
|
205
|
+
// including what it does when a read fails (say so verbatim, and go on
|
|
206
|
+
// showing whatever is still true).
|
|
207
|
+
// The listing endpoints' own maximum page size, so the common case is one
|
|
208
|
+
// request each.
|
|
209
|
+
const TYPE_PAGE_LIMIT = 100;
|
|
210
|
+
// How many pages either listing is followed for. Both are cursor
|
|
211
|
+
// paginated and neither offers a kind filter, so the media types have to
|
|
212
|
+
// be found among all of them. The cap is a guard against a cursor that
|
|
213
|
+
// never ends rather than a real ceiling: it is 2000 document types, and a
|
|
214
|
+
// site with more than that has a list this select could not usefully show
|
|
215
|
+
// anyway. Hitting it is REPORTED rather than swallowed (see
|
|
216
|
+
// ListingPages.complete): a list cut short is still a list of real
|
|
217
|
+
// crops, but it cannot be read as the whole set.
|
|
218
|
+
const TYPE_PAGE_CAP = 20;
|
|
219
|
+
const SELECT_CLASS = "h-10 w-full rounded-md border border-border-strong bg-background-elevated px-2 text-sm text-text-primary " +
|
|
220
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-600";
|
|
221
|
+
/** Every page of a cursor-paginated listing, up to the cap above. Both
|
|
222
|
+
* listings are small, admin-only and read once when this view mounts.
|
|
223
|
+
*
|
|
224
|
+
* One function for both because both answer in the same shape:
|
|
225
|
+
* DocumentTypeListResponseSchema and DataTypeListResponseSchema are each
|
|
226
|
+
* `{ items, nextCursor }` over the same `{ cursor, limit }` query. */
|
|
227
|
+
async function readAllPages(fetchApi, path, what) {
|
|
228
|
+
const all = [];
|
|
229
|
+
let cursor = null;
|
|
230
|
+
for (let page = 0; page < TYPE_PAGE_CAP; page += 1) {
|
|
231
|
+
const params = new URLSearchParams();
|
|
232
|
+
params.set("limit", String(TYPE_PAGE_LIMIT));
|
|
233
|
+
if (cursor)
|
|
234
|
+
params.set("cursor", cursor);
|
|
235
|
+
const response = await fetchApi(`${path}?${params.toString()}`);
|
|
236
|
+
if (!response.ok)
|
|
237
|
+
throw new Error(`Failed to load ${what} (${response.status})`);
|
|
238
|
+
const body = (await response.json());
|
|
239
|
+
all.push(...body.items);
|
|
240
|
+
cursor = body.nextCursor;
|
|
241
|
+
if (cursor === null)
|
|
242
|
+
return { items: all, complete: true };
|
|
243
|
+
}
|
|
244
|
+
return { items: all, complete: false };
|
|
245
|
+
}
|
|
246
|
+
/** The rendition name a data type produces, or null when it is not a
|
|
247
|
+
* rendition editor at all or its settings do not parse.
|
|
248
|
+
*
|
|
249
|
+
* The settings go through the same Zod schemas the server validates them
|
|
250
|
+
* with rather than being read member by member, exactly as the admin's
|
|
251
|
+
* Crops tab does it: `renditionName` takes a PARSED settings object, and
|
|
252
|
+
* settings that do not parse are a crop nothing can cut, which is not a
|
|
253
|
+
* shape to offer anyone. */
|
|
254
|
+
function renditionNameOf(dataType) {
|
|
255
|
+
if (dataType.editorId === THUMBNAIL_EDITOR_ID) {
|
|
256
|
+
const settings = ThumbnailSettingsSchema.safeParse(dataType.settings);
|
|
257
|
+
return settings.success ? renditionName({ editorId: THUMBNAIL_EDITOR_ID, settings: settings.data }) : null;
|
|
258
|
+
}
|
|
259
|
+
if (dataType.editorId === CROP_EDITOR_ID) {
|
|
260
|
+
const settings = CropSettingsSchema.safeParse(dataType.settings);
|
|
261
|
+
return settings.success ? renditionName({ editorId: CROP_EDITOR_ID, settings: settings.data }) : null;
|
|
262
|
+
}
|
|
263
|
+
return null;
|
|
264
|
+
}
|
|
265
|
+
/** The crops of every media document type, in the order the types and
|
|
266
|
+
* their fields are declared in. A type with no crop field contributes no
|
|
267
|
+
* group at all rather than an empty one. */
|
|
268
|
+
function collectRenditionChoices(documentTypes, dataTypes) {
|
|
269
|
+
const byId = new Map(dataTypes.map((dataType) => [dataType.id, dataType]));
|
|
270
|
+
const groups = [];
|
|
271
|
+
for (const documentType of documentTypes) {
|
|
272
|
+
if (documentType.kind !== "media")
|
|
273
|
+
continue;
|
|
274
|
+
const choices = [];
|
|
275
|
+
for (const field of documentType.fields) {
|
|
276
|
+
const dataType = byId.get(field.datatypeId);
|
|
277
|
+
if (!dataType)
|
|
278
|
+
continue;
|
|
279
|
+
const name = renditionNameOf(dataType);
|
|
280
|
+
if (name === null)
|
|
281
|
+
continue;
|
|
282
|
+
choices.push({ fieldId: field.id, caption: field.name, name });
|
|
283
|
+
}
|
|
284
|
+
if (choices.length > 0)
|
|
285
|
+
groups.push({ typeId: documentType.id, typeName: documentType.name, choices });
|
|
286
|
+
}
|
|
287
|
+
return groups;
|
|
288
|
+
}
|
|
289
|
+
function useRenditionChoices() {
|
|
290
|
+
const fetchApi = usePluginApi();
|
|
291
|
+
const [groups, setGroups] = useState([]);
|
|
292
|
+
const [loading, setLoading] = useState(true);
|
|
293
|
+
const [error, setError] = useState(null);
|
|
294
|
+
// Both listings have to have been read to the end before an absence
|
|
295
|
+
// from the result means anything. Either one stopping at the cap makes
|
|
296
|
+
// the crops found a SUBSET of the crops declared.
|
|
297
|
+
const [complete, setComplete] = useState(true);
|
|
298
|
+
useEffect(() => {
|
|
299
|
+
let cancelled = false;
|
|
300
|
+
setLoading(true);
|
|
301
|
+
setError(null);
|
|
302
|
+
setComplete(true);
|
|
303
|
+
Promise.all([
|
|
304
|
+
readAllPages(fetchApi, "/api/document-types", "document types"),
|
|
305
|
+
readAllPages(fetchApi, "/api/data-types", "data types"),
|
|
306
|
+
])
|
|
307
|
+
.then(([documentTypes, dataTypes]) => {
|
|
308
|
+
if (cancelled)
|
|
309
|
+
return;
|
|
310
|
+
setGroups(collectRenditionChoices(documentTypes.items, dataTypes.items));
|
|
311
|
+
setComplete(documentTypes.complete && dataTypes.complete);
|
|
312
|
+
})
|
|
313
|
+
.catch((err) => {
|
|
314
|
+
if (!cancelled)
|
|
315
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
316
|
+
})
|
|
317
|
+
.finally(() => {
|
|
318
|
+
if (!cancelled)
|
|
319
|
+
setLoading(false);
|
|
320
|
+
});
|
|
321
|
+
return () => {
|
|
322
|
+
cancelled = true;
|
|
323
|
+
};
|
|
324
|
+
}, [fetchApi]);
|
|
325
|
+
return { groups, loading, error, complete };
|
|
326
|
+
}
|
|
327
|
+
// Rendered by the Data Types editor only — a settings-EDITING view (see
|
|
328
|
+
// TextSettingsView in built-ins.tsx for the same pattern/rationale).
|
|
329
|
+
// acceptedTypes is edited as a comma-separated string (no multi-select
|
|
330
|
+
// widget precedent in this codebase) and parsed to string[] on change.
|
|
331
|
+
//
|
|
332
|
+
// `rendition` IS A SELECT AND NEVER A TEXT BOX. The value is a rendition
|
|
333
|
+
// name a webmaster has never seen: typing "3:4" where the name is "3x4"
|
|
334
|
+
// fails silently, because no rendition answers to that name and the field
|
|
335
|
+
// simply falls back to the full image with nothing to say why. A list of
|
|
336
|
+
// the crops the site actually declares cannot be misspelled.
|
|
337
|
+
export function ImageSettingsView() {
|
|
338
|
+
const { value: settings, onChange } = usePluginSettingsValue();
|
|
339
|
+
const { groups, loading, error, complete } = useRenditionChoices();
|
|
340
|
+
const noticeId = useId();
|
|
341
|
+
const rendition = requestedRendition(settings);
|
|
342
|
+
const listed = groups.some((group) => group.choices.some((choice) => choice.name === rendition));
|
|
343
|
+
// Whether the question has been answered at all. It decides what this
|
|
344
|
+
// view is entitled to say about a stored name it did not find: with
|
|
345
|
+
// both listings read to the end, nothing declares it; with a read
|
|
346
|
+
// failed, still in flight, or stopped at the page cap, we simply do not
|
|
347
|
+
// know yet, because the crop may be declared on a type this view never
|
|
348
|
+
// saw.
|
|
349
|
+
const settled = !loading && error === null && complete;
|
|
350
|
+
// At most one of these is ever showing, so one element carries them all
|
|
351
|
+
// and one id describes the select whichever is up. role="status" is
|
|
352
|
+
// polite and never interrupts; the other two are worth interrupting for
|
|
353
|
+
// (same split as content-list-view.tsx).
|
|
354
|
+
const notice = loading
|
|
355
|
+
? {
|
|
356
|
+
role: "status",
|
|
357
|
+
className: "text-text-tertiary",
|
|
358
|
+
text: "Loading the crops your media types declare…",
|
|
359
|
+
}
|
|
360
|
+
: error !== null
|
|
361
|
+
? // Verbatim, the same convention the media picker follows: a list
|
|
362
|
+
// that came back short for a reason should say the reason.
|
|
363
|
+
{ role: "alert", className: "text-danger-600", text: error }
|
|
364
|
+
: complete
|
|
365
|
+
? null
|
|
366
|
+
: {
|
|
367
|
+
role: "alert",
|
|
368
|
+
className: "text-danger-600",
|
|
369
|
+
text: `Only the first ${TYPE_PAGE_CAP * TYPE_PAGE_LIMIT} types could be read, ` +
|
|
370
|
+
"so a crop declared beyond them is missing from this list.",
|
|
371
|
+
};
|
|
372
|
+
return (_jsxs("div", { className: "flex flex-col gap-4", children: [_jsx(PropertyField, { label: "Accepted file types", htmlFor: "image-settings-accepted-types", helpText: "Comma-separated MIME types, e.g. image/png,image/jpeg. Leave blank to accept any image.", children: _jsx(Input, { id: "image-settings-accepted-types", value: settings.acceptedTypes?.join(",") ?? "", onChange: (e) => {
|
|
373
|
+
const types = e.target.value
|
|
374
|
+
.split(",")
|
|
375
|
+
.map((t) => t.trim())
|
|
376
|
+
.filter((t) => t.length > 0);
|
|
377
|
+
onChange({ ...settings, acceptedTypes: types.length > 0 ? types : undefined });
|
|
378
|
+
} }) }), _jsx(PropertyField, { label: "Max file size (bytes)", htmlFor: "image-settings-max-size", helpText: "e.g. 5000000 for ~5MB. Leave blank for no limit.", children: _jsx(Input, { id: "image-settings-max-size", type: "number", min: 1, value: settings.maxSizeBytes ?? "", onChange: (e) => onChange({ ...settings, maxSizeBytes: e.target.value === "" ? undefined : Number(e.target.value) }) }) }), _jsx(PropertyField, { label: "Crop", htmlFor: "image-settings-rendition", helpText: "The shape this field asks its picture for. A page gets that crop when the picture has one, and the full image when it does not.", children: _jsxs("select", { id: "image-settings-rendition", className: SELECT_CLASS, "aria-describedby": notice ? noticeId : undefined, value: rendition ?? "",
|
|
379
|
+
// The empty option is `rendition: null`, which is how
|
|
380
|
+
// ImageSettingsSchema spells "any picture will do", rather than
|
|
381
|
+
// a missing key or an empty string.
|
|
382
|
+
onChange: (event) => onChange({ ...settings, rendition: event.target.value === "" ? null : event.target.value }), children: [_jsx("option", { value: "", children: "No particular crop" }), rendition !== null && !listed && (_jsx("option", { value: rendition, children: settled ? `${renditionShape(rendition)} (no media type declares this crop)` : renditionShape(rendition) })), groups.map((group) => (_jsx("optgroup", { label: group.typeName, children: group.choices.map((choice) => (_jsx("option", { value: choice.name, children: `${choice.caption} ${renditionShape(choice.name)}` }, choice.fieldId))) }, group.typeId)))] }) }), notice && (_jsx("p", { id: noticeId, role: notice.role, className: cn("text-xs", notice.className), children: notice.text }))] }));
|
|
383
|
+
}
|
|
384
|
+
export function ImageReadOnlyView() {
|
|
385
|
+
const { value } = usePluginValue();
|
|
386
|
+
return _jsx(ImageThumbnail, { mediaId: value });
|
|
387
|
+
}
|