@kardalum/plugin-sdk 0.18.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +253 -0
- package/README.md +20 -1
- package/dist/admin-section-registry.d.ts +16 -1
- package/dist/admin-section-registry.js +23 -0
- package/dist/assets/asset-picker.js +3 -3
- package/dist/built-in-editor-ids.d.ts +1 -1
- package/dist/built-in-editor-ids.js +2 -20
- package/dist/built-in-serializers.js +1 -1
- package/dist/built-in-settings-schemas.d.ts +10 -0
- package/dist/built-in-settings-schemas.js +90 -4
- package/dist/built-in-value-schemas.js +35 -0
- package/dist/built-ins.js +48 -17
- package/dist/capabilities.d.ts +11 -1
- package/dist/capabilities.js +55 -3
- package/dist/cli.d.ts +66 -0
- package/dist/cli.js +22 -0
- package/dist/content-library.d.ts +85 -0
- package/dist/content-library.js +15 -0
- package/dist/content-picker/page-picker-sheet.d.ts +13 -0
- package/dist/content-picker/page-picker-sheet.js +105 -0
- package/dist/content-picker/page-tree.d.ts +25 -0
- package/dist/content-picker/page-tree.js +132 -0
- package/dist/data-type-plugin.d.ts +9 -3
- package/dist/datatype-validation.d.ts +6 -11
- package/dist/datatype-validation.js +141 -3
- package/dist/define-plugin.d.ts +4 -4
- package/dist/define-plugin.js +5 -5
- package/dist/entitlement-entry.d.ts +1 -1
- package/dist/entitlement-entry.js +1 -1
- package/dist/entitlement-gate.d.ts +14 -0
- package/dist/entitlement-gate.js +64 -7
- package/dist/entitlement-plan.d.ts +6 -0
- package/dist/entitlement-plan.js +10 -0
- package/dist/entitlement-types.d.ts +36 -12
- package/dist/entitlement.d.ts +31 -4
- package/dist/entitlement.js +58 -17
- package/dist/hook-entry.d.ts +5 -0
- package/dist/hook-entry.js +30 -0
- package/dist/host-entry.d.ts +1 -1
- package/dist/host-entry.js +1 -1
- package/dist/index.d.ts +38 -4
- package/dist/index.js +54 -3
- package/dist/mail.d.ts +30 -0
- package/dist/mail.js +1 -0
- package/dist/manifest-entry.d.ts +29 -4
- package/dist/manifest-entry.js +39 -2
- package/dist/manifest-schema.d.ts +443 -29
- package/dist/manifest-schema.js +292 -24
- package/dist/manifest.d.ts +450 -51
- package/dist/manifest.js +1 -1
- package/dist/media/media-picker.js +33 -20
- package/dist/media/upload-error.d.ts +5 -1
- package/dist/media/upload-error.js +14 -2
- package/dist/media-library.d.ts +32 -0
- package/dist/media-library.js +15 -0
- package/dist/nested-field-host.d.ts +76 -0
- package/dist/nested-field-host.js +90 -0
- package/dist/notify.d.ts +12 -4
- package/dist/notify.js +1 -1
- package/dist/outbound.d.ts +47 -0
- package/dist/outbound.js +1 -0
- package/dist/plugin-context.d.ts +5 -0
- package/dist/plugin-context.js +3 -3
- package/dist/plugin-screen-context.d.ts +112 -0
- package/dist/plugin-screen-context.js +26 -0
- package/dist/providers.d.ts +268 -0
- package/dist/providers.js +74 -0
- package/dist/read-all-pages.d.ts +5 -0
- package/dist/read-all-pages.js +3 -2
- package/dist/register-built-ins.js +6 -6
- package/dist/registry.js +1 -1
- package/dist/richtext/block-panel.js +12 -7
- package/dist/richtext/extensions.js +7 -7
- package/dist/richtext/insert-menu.js +12 -9
- package/dist/richtext/style-listbox.js +7 -5
- package/dist/richtext/text-style-class.js +1 -1
- package/dist/sdk-strings.d.ts +285 -0
- package/dist/sdk-strings.js +347 -0
- package/dist/sealing.d.ts +14 -0
- package/dist/sealing.js +1 -0
- package/dist/simple-storage-value-provider.js +27 -27
- package/dist/structured-storage-types.d.ts +309 -9
- package/dist/structured-storage-types.js +2 -2
- package/dist/text-entry.d.ts +1 -0
- package/dist/text-entry.js +6 -0
- package/dist/tokens/tailwind-theme.css +5 -0
- package/dist/tokens/tokens.css +15 -3
- package/dist/tokens/tokens.json +8 -3
- package/dist/ui-entry.js +3 -3
- package/dist/views/asset-view.js +6 -3
- package/dist/views/content-list-preview.js +3 -1
- package/dist/views/content-list-settings-view.js +11 -7
- package/dist/views/content-list-view.d.ts +5 -3
- package/dist/views/content-list-view.js +38 -34
- package/dist/views/content-picker-view.d.ts +3 -0
- package/dist/views/content-picker-view.js +143 -0
- package/dist/views/crop-view.d.ts +4 -6
- package/dist/views/crop-view.js +22 -13
- package/dist/views/date-range-view.js +9 -6
- package/dist/views/file-upload-view.d.ts +5 -7
- package/dist/views/file-upload-view.js +16 -7
- package/dist/views/group-view.d.ts +8 -0
- package/dist/views/group-view.js +123 -0
- package/dist/views/html-code-editor.js +2 -2
- package/dist/views/html-view.js +12 -11
- package/dist/views/image-view.js +40 -22
- package/dist/views/link-view.d.ts +3 -0
- package/dist/views/link-view.js +150 -0
- package/dist/views/options-list-view.d.ts +3 -0
- package/dist/views/options-list-view.js +104 -0
- package/dist/views/repeatable-list-view.d.ts +3 -0
- package/dist/views/repeatable-list-view.js +113 -0
- package/dist/views/rich-text-view.js +32 -16
- package/dist/views/suggest-key.d.ts +17 -0
- package/dist/views/suggest-key.js +55 -0
- package/node_modules/@kardalum/api-schemas/dist/ai-connections.schema.d.ts +215 -0
- package/node_modules/@kardalum/api-schemas/dist/ai-connections.schema.js +179 -0
- package/node_modules/@kardalum/api-schemas/dist/ai-context.schema.d.ts +12 -0
- package/node_modules/@kardalum/api-schemas/dist/ai-context.schema.js +10 -0
- package/node_modules/@kardalum/api-schemas/dist/api-error.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.d.ts +10 -0
- package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.js +5 -0
- package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/audit-api.schema.d.ts +7 -1
- package/node_modules/@kardalum/api-schemas/dist/audit-api.schema.js +4 -2
- package/node_modules/@kardalum/api-schemas/dist/auth.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/built-in-editor-ids.d.ts +1 -0
- package/node_modules/@kardalum/api-schemas/dist/built-in-editor-ids.js +27 -0
- package/node_modules/@kardalum/api-schemas/dist/capability-detail.d.ts +65 -0
- package/node_modules/@kardalum/api-schemas/dist/capability-detail.js +126 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.d.ts +116 -3
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +71 -18
- package/node_modules/@kardalum/api-schemas/dist/content-list.schema.d.ts +57 -2
- package/node_modules/@kardalum/api-schemas/dist/content-list.schema.js +137 -0
- package/node_modules/@kardalum/api-schemas/dist/content-path.d.ts +1 -1
- package/node_modules/@kardalum/api-schemas/dist/content-path.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/content-search.schema.d.ts +50 -0
- package/node_modules/@kardalum/api-schemas/dist/content-search.schema.js +42 -0
- package/node_modules/@kardalum/api-schemas/dist/content-summary.schema.d.ts +37 -0
- package/node_modules/@kardalum/api-schemas/dist/content-summary.schema.js +19 -0
- package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.js +3 -3
- package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/content-unpublish.schema.d.ts +23 -0
- package/node_modules/@kardalum/api-schemas/dist/content-unpublish.schema.js +13 -0
- package/node_modules/@kardalum/api-schemas/dist/content.schema.d.ts +3 -0
- package/node_modules/@kardalum/api-schemas/dist/content.schema.js +10 -0
- package/node_modules/@kardalum/api-schemas/dist/contract-cancel.schema.d.ts +41 -0
- package/node_modules/@kardalum/api-schemas/dist/contract-cancel.schema.js +86 -0
- package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +10 -5
- package/node_modules/@kardalum/api-schemas/dist/core-actions.js +7 -4
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.d.ts +25 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.js +9 -1
- package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.js +4 -4
- package/node_modules/@kardalum/api-schemas/dist/data-type-issue.d.ts +35 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-issue.js +60 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.d.ts +267 -12
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +54 -8
- package/node_modules/@kardalum/api-schemas/dist/document-type.schema.d.ts +24 -6
- package/node_modules/@kardalum/api-schemas/dist/document-type.schema.js +98 -13
- package/node_modules/@kardalum/api-schemas/dist/form-protection.d.ts +23 -0
- package/node_modules/@kardalum/api-schemas/dist/form-protection.js +12 -0
- package/node_modules/@kardalum/api-schemas/dist/graphql-limits.d.ts +12 -0
- package/node_modules/@kardalum/api-schemas/dist/graphql-limits.js +14 -0
- package/node_modules/@kardalum/api-schemas/dist/held-embed-words.d.ts +23 -0
- package/node_modules/@kardalum/api-schemas/dist/held-embed-words.js +70 -0
- package/node_modules/@kardalum/api-schemas/dist/index.d.ts +122 -43
- package/node_modules/@kardalum/api-schemas/dist/index.js +92 -27
- package/node_modules/@kardalum/api-schemas/dist/install-sign-in-switched-off.schema.d.ts +9 -0
- package/node_modules/@kardalum/api-schemas/dist/install-sign-in-switched-off.schema.js +9 -0
- package/node_modules/@kardalum/api-schemas/dist/legal-anchors.d.ts +8 -0
- package/node_modules/@kardalum/api-schemas/dist/legal-anchors.js +9 -0
- package/node_modules/@kardalum/api-schemas/dist/licensing.schema.d.ts +63 -0
- package/node_modules/@kardalum/api-schemas/dist/licensing.schema.js +54 -0
- package/node_modules/@kardalum/api-schemas/dist/listing-categories.schema.d.ts +46 -0
- package/node_modules/@kardalum/api-schemas/dist/listing-categories.schema.js +52 -0
- package/node_modules/@kardalum/api-schemas/dist/mail-rules.d.ts +224 -0
- package/node_modules/@kardalum/api-schemas/dist/mail-rules.js +404 -0
- package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.d.ts +8 -0
- package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.js +4 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-leaks.schema.d.ts +145 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-leaks.schema.js +154 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +359 -8
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +85 -11
- package/node_modules/@kardalum/api-schemas/dist/marketplace-package-api.schema.d.ts +15 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-package-api.schema.js +14 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-payouts.schema.d.ts +131 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-payouts.schema.js +272 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-profile.schema.d.ts +84 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-profile.schema.js +138 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-revocation.schema.d.ts +20 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-revocation.schema.js +49 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-sites.schema.d.ts +211 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-sites.schema.js +424 -0
- package/node_modules/@kardalum/api-schemas/dist/mcp-plugins.schema.d.ts +78 -0
- package/node_modules/@kardalum/api-schemas/dist/mcp-plugins.schema.js +27 -0
- package/node_modules/@kardalum/api-schemas/dist/mcp-tool-inputs.schema.d.ts +70 -0
- package/node_modules/@kardalum/api-schemas/dist/mcp-tool-inputs.schema.js +43 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +22 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +22 -10
- package/node_modules/@kardalum/api-schemas/dist/media-move.schema.d.ts +75 -0
- package/node_modules/@kardalum/api-schemas/dist/media-move.schema.js +53 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-api.schema.d.ts +2 -2
- package/node_modules/@kardalum/api-schemas/dist/media-reference.d.ts +2 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference.js +55 -0
- package/node_modules/@kardalum/api-schemas/dist/media.schema.d.ts +1 -0
- package/node_modules/@kardalum/api-schemas/dist/media.schema.js +9 -5
- package/node_modules/@kardalum/api-schemas/dist/nested-fields.schema.d.ts +204 -0
- package/node_modules/@kardalum/api-schemas/dist/nested-fields.schema.js +370 -0
- package/node_modules/@kardalum/api-schemas/dist/nested-validation.d.ts +53 -0
- package/node_modules/@kardalum/api-schemas/dist/nested-validation.js +284 -0
- package/node_modules/@kardalum/api-schemas/dist/news.schema.d.ts +5 -5
- package/node_modules/@kardalum/api-schemas/dist/node-access.schema.d.ts +1 -2
- package/node_modules/@kardalum/api-schemas/dist/node-access.schema.js +1 -2
- package/node_modules/@kardalum/api-schemas/dist/notification-kinds.d.ts +145 -0
- package/node_modules/@kardalum/api-schemas/dist/notification-kinds.js +177 -0
- package/node_modules/@kardalum/api-schemas/dist/notification.schema.d.ts +258 -7
- package/node_modules/@kardalum/api-schemas/dist/notification.schema.js +96 -5
- package/node_modules/@kardalum/api-schemas/dist/page-address.d.ts +10 -0
- package/node_modules/@kardalum/api-schemas/dist/page-address.js +7 -0
- package/node_modules/@kardalum/api-schemas/dist/password-reset.schema.d.ts +34 -0
- package/node_modules/@kardalum/api-schemas/dist/password-reset.schema.js +60 -0
- package/node_modules/@kardalum/api-schemas/dist/plan-editor.schema.d.ts +28 -3
- package/node_modules/@kardalum/api-schemas/dist/plan-editor.schema.js +55 -8
- package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.d.ts +12 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.js +13 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-caller.d.ts +23 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-caller.js +16 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-cli-commands.d.ts +76 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-cli-commands.js +316 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-content-access.d.ts +42 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-content-access.js +74 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-data-type-configs.d.ts +31 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-data-type-configs.js +131 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +26 -2
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-text.js +1 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.d.ts +26 -2
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +13 -5
- package/node_modules/@kardalum/api-schemas/dist/plugin-document-types.d.ts +228 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-document-types.js +41 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-durable-hooks.d.ts +26 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-durable-hooks.js +55 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-editor-extensions.d.ts +40 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-editor-extensions.js +124 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-field-info.d.ts +41 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-field-info.js +51 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-graphql-fields.d.ts +32 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-graphql-fields.js +102 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-held-embeds.d.ts +107 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-held-embeds.js +213 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-https-origin.d.ts +5 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-https-origin.js +21 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.d.ts +4 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.js +3 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.d.ts +44 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.js +38 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-install.d.ts +237 -2
- package/node_modules/@kardalum/api-schemas/dist/plugin-install.js +205 -6
- package/node_modules/@kardalum/api-schemas/dist/plugin-labels.d.ts +26 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-labels.js +29 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-locales.d.ts +32 -8
- package/node_modules/@kardalum/api-schemas/dist/plugin-locales.js +120 -14
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +357 -4
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +279 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +16 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +34 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-ai.d.ts +40 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-ai.js +139 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.d.ts +22 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.js +31 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-media-access.d.ts +25 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-media-access.js +43 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-outbound.d.ts +107 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-outbound.js +150 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-package-build.schema.d.ts +5 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-package-build.schema.js +7 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-providers.d.ts +310 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-providers.js +430 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-read-only.schema.d.ts +4 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-read-only.schema.js +2 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-sealed-values.d.ts +45 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-sealed-values.js +99 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-secrets.d.ts +68 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-secrets.js +114 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-settings.d.ts +342 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-settings.js +400 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-site-extensions.d.ts +180 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-site-extensions.js +612 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.d.ts +7 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.js +50 -7
- package/node_modules/@kardalum/api-schemas/dist/plugin-tasks.d.ts +45 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-tasks.js +197 -0
- package/node_modules/@kardalum/api-schemas/dist/plural-rules.d.ts +9 -0
- package/node_modules/@kardalum/api-schemas/dist/plural-rules.js +41 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.d.ts +41 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +100 -12
- package/node_modules/@kardalum/api-schemas/dist/refund-request.schema.d.ts +189 -0
- package/node_modules/@kardalum/api-schemas/dist/refund-request.schema.js +164 -0
- package/node_modules/@kardalum/api-schemas/dist/render-editing.d.ts +4 -4
- package/node_modules/@kardalum/api-schemas/dist/render-editing.js +4 -4
- package/node_modules/@kardalum/api-schemas/dist/render-settings-api.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/revenue-view.schema.js +7 -3
- package/node_modules/@kardalum/api-schemas/dist/rich-text-shape.d.ts +6 -0
- package/node_modules/@kardalum/api-schemas/dist/rich-text-shape.js +82 -0
- package/node_modules/@kardalum/api-schemas/dist/rich-text-text.d.ts +66 -0
- package/node_modules/@kardalum/api-schemas/dist/rich-text-text.js +497 -0
- package/node_modules/@kardalum/api-schemas/dist/sale-conditions.schema.d.ts +82 -0
- package/node_modules/@kardalum/api-schemas/dist/sale-conditions.schema.js +99 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.d.ts +13 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.js +28 -0
- package/node_modules/@kardalum/api-schemas/dist/sandbox-attach.schema.d.ts +91 -1
- package/node_modules/@kardalum/api-schemas/dist/server-settings-api.schema.d.ts +289 -0
- package/node_modules/@kardalum/api-schemas/dist/server-settings-api.schema.js +205 -0
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +121 -0
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.js +51 -10
- package/node_modules/@kardalum/api-schemas/dist/sign-in.schema.d.ts +384 -0
- package/node_modules/@kardalum/api-schemas/dist/sign-in.schema.js +616 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +3 -3
- package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.d.ts +1 -1
- package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/structured-duplicate-key.d.ts +13 -0
- package/node_modules/@kardalum/api-schemas/dist/structured-duplicate-key.js +26 -0
- package/node_modules/@kardalum/api-schemas/dist/structured-fields.schema.d.ts +66 -0
- package/node_modules/@kardalum/api-schemas/dist/structured-fields.schema.js +160 -0
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/template.schema.d.ts +1 -0
- package/node_modules/@kardalum/api-schemas/dist/template.schema.js +3 -0
- package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.d.ts +1 -1
- package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/transaction-rolled-back.d.ts +13 -0
- package/node_modules/@kardalum/api-schemas/dist/transaction-rolled-back.js +29 -0
- package/node_modules/@kardalum/api-schemas/dist/trash-purge.schema.d.ts +13 -0
- package/node_modules/@kardalum/api-schemas/dist/trash-purge.schema.js +6 -0
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +58 -1
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +35 -4
- package/node_modules/@kardalum/api-schemas/dist/vendor-service.schema.d.ts +5 -1
- package/node_modules/@kardalum/api-schemas/dist/vendor-service.schema.js +4 -3
- package/node_modules/@kardalum/api-schemas/package.json +1 -0
- package/node_modules/@kardalum/design-tokens/dist/build-css.d.ts +1 -1
- package/node_modules/@kardalum/design-tokens/dist/build-css.js +8 -2
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.css +5 -0
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +1 -1
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.js +3 -3
- package/node_modules/@kardalum/design-tokens/dist/theme-css.d.ts +2 -2
- package/node_modules/@kardalum/design-tokens/dist/theme-css.js +2 -2
- package/node_modules/@kardalum/design-tokens/dist/theme-types.d.ts +2 -2
- package/node_modules/@kardalum/design-tokens/dist/themes/dark.d.ts +3 -3
- package/node_modules/@kardalum/design-tokens/dist/themes/dark.js +3 -3
- package/node_modules/@kardalum/design-tokens/dist/themes/light.d.ts +1 -1
- package/node_modules/@kardalum/design-tokens/dist/themes/light.js +1 -1
- package/node_modules/@kardalum/design-tokens/dist/tokens.css +15 -3
- package/node_modules/@kardalum/design-tokens/dist/tokens.d.ts +4 -4
- package/node_modules/@kardalum/design-tokens/dist/tokens.js +17 -8
- package/node_modules/@kardalum/design-tokens/dist/tokens.json +8 -3
- package/node_modules/@kardalum/design-tokens/dist/types.d.ts +2 -2
- package/node_modules/@kardalum/design-tokens/dist/types.js +1 -1
- package/node_modules/@kardalum/plugin-package/dist/build-reference.d.ts +21 -2
- package/node_modules/@kardalum/plugin-package/dist/build-reference.js +8 -2
- package/node_modules/@kardalum/plugin-package/dist/capabilities.d.ts +17 -10
- package/node_modules/@kardalum/plugin-package/dist/capabilities.js +355 -22
- package/node_modules/@kardalum/plugin-package/dist/client-bundle.d.ts +1 -1
- package/node_modules/@kardalum/plugin-package/dist/client-bundle.js +2 -0
- package/node_modules/@kardalum/plugin-package/dist/cms-range.d.ts +17 -0
- package/node_modules/@kardalum/plugin-package/dist/cms-range.js +353 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/ai-declarations.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/ai-declarations.js +26 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/archive-names.d.ts +1 -1
- package/node_modules/@kardalum/plugin-package/dist/delivery/archive-names.js +3 -2
- package/node_modules/@kardalum/plugin-package/dist/delivery/content-access.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/content-access.js +34 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.js +2 -2
- package/node_modules/@kardalum/plugin-package/dist/delivery/editor-extensions.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/editor-extensions.js +27 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/graphql-fields.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/graphql-fields.js +22 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/index.d.ts +1 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/index.js +1 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/label-languages.js +47 -5
- package/node_modules/@kardalum/plugin-package/dist/delivery/licence-check.d.ts +27 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/licence-check.js +95 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/locales.js +9 -4
- package/node_modules/@kardalum/plugin-package/dist/delivery/plugin-settings.d.ts +3 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/plugin-settings.js +68 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/providers.d.ts +3 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/providers.js +298 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/registry.js +27 -5
- package/node_modules/@kardalum/plugin-package/dist/delivery/sample-content.js +91 -2
- package/node_modules/@kardalum/plugin-package/dist/delivery/server-powers.d.ts +6 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/server-powers.js +140 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/site-extensions.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/site-extensions.js +36 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/templates.d.ts +1 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/templates.js +21 -1
- package/node_modules/@kardalum/plugin-package/dist/delivery/types.d.ts +10 -0
- package/node_modules/@kardalum/plugin-package/dist/envelope.d.ts +2 -2
- package/node_modules/@kardalum/plugin-package/dist/envelope.js +2 -2
- package/node_modules/@kardalum/plugin-package/dist/extract.d.ts +3 -3
- package/node_modules/@kardalum/plugin-package/dist/extract.js +9 -9
- package/node_modules/@kardalum/plugin-package/dist/hash.d.ts +1 -1
- package/node_modules/@kardalum/plugin-package/dist/hash.js +1 -1
- package/node_modules/@kardalum/plugin-package/dist/index.d.ts +4 -2
- package/node_modules/@kardalum/plugin-package/dist/index.js +2 -1
- package/node_modules/@kardalum/plugin-package/dist/license-verdict.d.ts +75 -0
- package/node_modules/@kardalum/plugin-package/dist/license-verdict.js +123 -0
- package/node_modules/@kardalum/plugin-package/dist/package-contract.d.ts +2 -2
- package/node_modules/@kardalum/plugin-package/dist/package-contract.js +5 -5
- package/node_modules/@kardalum/plugin-package/dist/types.d.ts +1 -1
- package/node_modules/@kardalum/ui/dist/components/alert-dialog.d.ts +1 -1
- package/node_modules/@kardalum/ui/dist/components/alert-dialog.js +8 -3
- package/node_modules/@kardalum/ui/dist/components/badge.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/button.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/dialog.d.ts +1 -1
- package/node_modules/@kardalum/ui/dist/components/dialog.js +49 -4
- package/node_modules/@kardalum/ui/dist/components/dropdown-menu.d.ts +5 -1
- package/node_modules/@kardalum/ui/dist/components/dropdown-menu.js +18 -5
- package/node_modules/@kardalum/ui/dist/components/empty-state.d.ts +4 -4
- package/node_modules/@kardalum/ui/dist/components/input.js +6 -1
- package/node_modules/@kardalum/ui/dist/components/property-field.js +3 -3
- package/node_modules/@kardalum/ui/dist/components/sheet.d.ts +1 -1
- package/node_modules/@kardalum/ui/dist/components/sheet.js +12 -7
- package/node_modules/@kardalum/ui/dist/components/skeleton.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/switch.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/tab-strip.d.ts +3 -3
- package/node_modules/@kardalum/ui/dist/components/toast.js +4 -3
- package/node_modules/@kardalum/ui/dist/components/tooltip.d.ts +27 -0
- package/node_modules/@kardalum/ui/dist/components/tooltip.js +81 -0
- package/node_modules/@kardalum/ui/dist/components/truncated-text.d.ts +16 -0
- package/node_modules/@kardalum/ui/dist/components/truncated-text.js +95 -0
- package/node_modules/@kardalum/ui/dist/components/use-toast.js +2 -2
- package/node_modules/@kardalum/ui/dist/index.d.ts +3 -1
- package/node_modules/@kardalum/ui/dist/index.js +3 -1
- package/node_modules/@kardalum/ui/dist/lib/menu-host.d.ts +5 -0
- package/node_modules/@kardalum/ui/dist/lib/menu-host.js +17 -0
- package/node_modules/@kardalum/ui/package.json +8 -6
- package/package.json +18 -7
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const SELECT_CLASS = "flex h-10 w-full rounded-md border border-border-strong bg-background-elevated px-3 py-2 text-sm text-text-primary transition-colors duration-fast focus-visible:border-primary-600 focus-visible:outline-hidden focus-visible:ring-4 focus-visible:ring-primary-50 disabled:cursor-not-allowed disabled:opacity-50";
|
|
2
|
+
export declare function GroupInputView(): import("react").JSX.Element;
|
|
3
|
+
export declare function GroupReadOnlyView(): import("react").JSX.Element;
|
|
4
|
+
/** Without a nested field host (a plugin preview) a sub-value is shown as its JSON, not as missing. */
|
|
5
|
+
export declare function ValueSummary({ value }: {
|
|
6
|
+
value: unknown;
|
|
7
|
+
}): import("react").JSX.Element;
|
|
8
|
+
export declare function GroupSettingsView(): import("react").JSX.Element;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from "react";
|
|
3
|
+
import { GROUP_FIELDS_MAX, SUB_FIELD_ALIAS_MAX, SUB_FIELD_NAME_MAX, isPlainRecord, readGroupSettings, } from "@kardalum/api-schemas";
|
|
4
|
+
import { Button, Checkbox, IconTooltip, Input, PropertyField } from "@kardalum/ui";
|
|
5
|
+
import { NestedField, holdsRichText, isNestableEditor, repeatedByList, useNestedFieldHost } from "../nested-field-host.js";
|
|
6
|
+
import { usePluginSettings, usePluginSettingsValue, usePluginValue } from "../plugin-context.js";
|
|
7
|
+
import { usePluginTranslate } from "../plugin-screen-context.js";
|
|
8
|
+
import { useAdminChromeProps } from "../sdk-strings.js";
|
|
9
|
+
import { suggestKey, useHandEditedKeys } from "./suggest-key.js";
|
|
10
|
+
// Month 32 D: the Group data type's views. The value is an object keyed by sub-field alias; each
|
|
11
|
+
// sub-field is mounted through the nested field host with its own data type's views.
|
|
12
|
+
// The same classes as the UI package's Input, for a native select.
|
|
13
|
+
export const SELECT_CLASS = "flex h-10 w-full rounded-md border border-border-strong bg-background-elevated px-3 py-2 text-sm text-text-primary transition-colors duration-fast focus-visible:border-primary-600 focus-visible:outline-hidden focus-visible:ring-4 focus-visible:ring-primary-50 disabled:cursor-not-allowed disabled:opacity-50";
|
|
14
|
+
export function GroupInputView() {
|
|
15
|
+
const { value, onChange } = usePluginValue();
|
|
16
|
+
const settings = readGroupSettings(usePluginSettings());
|
|
17
|
+
const host = useNestedFieldHost();
|
|
18
|
+
const t = usePluginTranslate();
|
|
19
|
+
const chrome = useAdminChromeProps();
|
|
20
|
+
if (!host) {
|
|
21
|
+
return (_jsxs("div", { ...chrome, className: "flex flex-col gap-2", children: [_jsx(GroupReadOnlyView, {}), _jsx("p", { className: "text-sm text-text-tertiary", children: t("group.noHost") })] }));
|
|
22
|
+
}
|
|
23
|
+
if (settings.fields.length === 0) {
|
|
24
|
+
return (_jsx("p", { ...chrome, className: "text-sm text-text-tertiary", children: t("group.noFields") }));
|
|
25
|
+
}
|
|
26
|
+
const current = isPlainRecord(value) ? value : {};
|
|
27
|
+
// The base keeps only the aliases the group has now, so a removed sub-field's value is dropped.
|
|
28
|
+
const base = {};
|
|
29
|
+
// Own keys only: an alias such as `constructor` must not read Object.prototype's member.
|
|
30
|
+
for (const field of settings.fields)
|
|
31
|
+
if (Object.hasOwn(current, field.alias))
|
|
32
|
+
base[field.alias] = current[field.alias];
|
|
33
|
+
return (_jsx("div", { ...chrome, className: "flex flex-col gap-4", children: settings.fields.map((field) => {
|
|
34
|
+
const type = host.resolve(field.dataTypeId);
|
|
35
|
+
return (_jsx(PropertyField, { label: field.name, required: field.required, requiredText: t("group.required"), helpText: type?.readOnlyNote, children: type ? (_jsx(NestedField, { type: type, value: base[field.alias], onChange: (next) => onChange({ ...base, [field.alias]: next }) })) : (_jsx("p", { className: "text-sm text-text-tertiary", children: t("group.missingType") })) }, field.alias));
|
|
36
|
+
}) }));
|
|
37
|
+
}
|
|
38
|
+
export function GroupReadOnlyView() {
|
|
39
|
+
const { value } = usePluginValue();
|
|
40
|
+
const settings = readGroupSettings(usePluginSettings());
|
|
41
|
+
const host = useNestedFieldHost();
|
|
42
|
+
const t = usePluginTranslate();
|
|
43
|
+
const chrome = useAdminChromeProps();
|
|
44
|
+
const current = isPlainRecord(value) ? value : {};
|
|
45
|
+
const filled = settings.fields.filter((field) => Object.hasOwn(current, field.alias) && current[field.alias] !== undefined && current[field.alias] !== null);
|
|
46
|
+
if (filled.length === 0) {
|
|
47
|
+
return (_jsx("span", { ...chrome, className: "text-sm text-text-tertiary", children: t("group.empty") }));
|
|
48
|
+
}
|
|
49
|
+
return (_jsx("dl", { ...chrome, className: "flex flex-col gap-3", children: filled.map((field) => {
|
|
50
|
+
const type = host?.resolve(field.dataTypeId) ?? null;
|
|
51
|
+
return (_jsxs("div", { className: "flex flex-col gap-1", children: [_jsx("dt", { className: "text-sm font-medium text-text-secondary", children: field.name }), _jsx("dd", { className: "text-sm text-text-primary", children: !host ? (_jsx(ValueSummary, { value: current[field.alias] })) : type ? (_jsx(NestedField, { type: type, value: current[field.alias], onChange: () => { }, readOnly: true })) : (_jsx("span", { className: "text-text-tertiary", children: t("group.missingType") })) })] }, field.alias));
|
|
52
|
+
}) }));
|
|
53
|
+
}
|
|
54
|
+
/** Without a nested field host (a plugin preview) a sub-value is shown as its JSON, not as missing. */
|
|
55
|
+
export function ValueSummary({ value }) {
|
|
56
|
+
return _jsx("pre", { className: "whitespace-pre-wrap break-words font-mono text-xs text-text-secondary", children: JSON.stringify(value ?? null, null, 2) });
|
|
57
|
+
}
|
|
58
|
+
function rawRows(settings) {
|
|
59
|
+
if (!Array.isArray(settings.fields))
|
|
60
|
+
return [];
|
|
61
|
+
return settings.fields.slice(0, GROUP_FIELDS_MAX).map((entry) => {
|
|
62
|
+
const bag = isPlainRecord(entry) ? entry : {};
|
|
63
|
+
return {
|
|
64
|
+
alias: typeof bag.alias === "string" ? bag.alias : "",
|
|
65
|
+
name: typeof bag.name === "string" ? bag.name : "",
|
|
66
|
+
dataTypeId: typeof bag.dataTypeId === "string" ? bag.dataTypeId : "",
|
|
67
|
+
required: bag.required === true,
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
const ALIAS_PATTERN = /^[a-zA-Z][a-zA-Z0-9_]*$/;
|
|
72
|
+
export function GroupSettingsView() {
|
|
73
|
+
const { value: settings, onChange } = usePluginSettingsValue();
|
|
74
|
+
const host = useNestedFieldHost();
|
|
75
|
+
const t = usePluginTranslate();
|
|
76
|
+
const idPrefix = useId();
|
|
77
|
+
const rows = rawRows(settings);
|
|
78
|
+
const write = (next) => onChange({ ...settings, fields: next });
|
|
79
|
+
const update = (index, patch) => write(rows.map((r, i) => (i === index ? { ...r, ...patch } : r)));
|
|
80
|
+
const keys = useHandEditedKeys(rows.map((r) => r.alias));
|
|
81
|
+
const move = (index, by) => {
|
|
82
|
+
keys.moved(index, by);
|
|
83
|
+
const next = [...rows];
|
|
84
|
+
const [row] = next.splice(index, 1);
|
|
85
|
+
next.splice(index + by, 0, row);
|
|
86
|
+
write(next);
|
|
87
|
+
};
|
|
88
|
+
const counts = new Map();
|
|
89
|
+
for (const row of rows)
|
|
90
|
+
if (row.alias !== "")
|
|
91
|
+
counts.set(row.alias, (counts.get(row.alias) ?? 0) + 1);
|
|
92
|
+
// M32 I5 (D10): a Group a Repeatable list repeats may not hold rich text, so its picker leaves out
|
|
93
|
+
// rich text and Groups holding it, as the list view's item picker does.
|
|
94
|
+
const repeated = host?.editingDataTypeId !== undefined && repeatedByList(host, host.editingDataTypeId);
|
|
95
|
+
const choices = host
|
|
96
|
+
? host.listDataTypes().filter((d) => isNestableEditor(host, d.editorId) && !(repeated && holdsRichText(host, d.id)))
|
|
97
|
+
: [];
|
|
98
|
+
return (_jsxs("div", { className: "flex flex-col gap-4", children: [rows.map((row, index) => {
|
|
99
|
+
const label = row.name !== "" ? row.name : String(index + 1);
|
|
100
|
+
// M32 I5 (D9): a blank alias is as bad as a malformed one, and a name needs more than spaces.
|
|
101
|
+
// Hints only: the save is not blocked here, the server judges it.
|
|
102
|
+
const badAlias = row.alias === "" || row.alias.length > SUB_FIELD_ALIAS_MAX || !ALIAS_PATTERN.test(row.alias);
|
|
103
|
+
const noName = row.name.trim() === "";
|
|
104
|
+
const duplicate = row.alias !== "" && (counts.get(row.alias) ?? 0) > 1;
|
|
105
|
+
const known = choices.some((d) => d.id === row.dataTypeId);
|
|
106
|
+
const noType = row.dataTypeId === "" && Boolean(host);
|
|
107
|
+
const base = `${idPrefix}-${index}`;
|
|
108
|
+
const aliasErrorIds = [badAlias && `${base}-alias-bad`, duplicate && `${base}-alias-duplicate`].filter(Boolean).join(" ");
|
|
109
|
+
return (_jsxs("div", { className: "flex flex-col gap-2 rounded-md border border-border-default p-4", children: [_jsxs("div", { className: "flex flex-wrap items-start gap-2", children: [_jsxs("div", { className: "flex min-w-32 flex-1 flex-col gap-1", children: [_jsx("label", { htmlFor: `${base}-name`, className: "text-xs font-medium text-text-secondary", children: t("group.nameColumn") }), _jsx(Input, { id: `${base}-name`, placeholder: t("group.namePlaceholder"), value: row.name, maxLength: SUB_FIELD_NAME_MAX, "aria-invalid": noName || undefined, "aria-describedby": noName ? `${base}-name-error` : undefined, onChange: (event) => {
|
|
110
|
+
const name = event.target.value;
|
|
111
|
+
update(index, keys.follows(index) ? { name, alias: suggestKey(name, SUB_FIELD_ALIAS_MAX, true) } : { name });
|
|
112
|
+
} }), noName && (_jsx("p", { id: `${base}-name-error`, className: "text-xs text-danger-600", children: t("group.nameRequired") }))] }), _jsxs("div", { className: "flex min-w-32 flex-1 flex-col gap-1", children: [_jsx("label", { htmlFor: `${base}-alias`, className: "text-xs font-medium text-text-secondary", children: t("group.aliasColumn") }), _jsx(Input, { id: `${base}-alias`, placeholder: t("group.aliasPlaceholder"), value: row.alias, "aria-invalid": badAlias || duplicate || undefined, "aria-describedby": aliasErrorIds || undefined, onChange: (event) => {
|
|
113
|
+
keys.markByHand(index);
|
|
114
|
+
update(index, { alias: event.target.value });
|
|
115
|
+
} }), badAlias && (_jsx("p", { id: `${base}-alias-bad`, className: "text-xs text-danger-600", children: t("group.badAlias") })), duplicate && (_jsx("p", { id: `${base}-alias-duplicate`, className: "text-xs text-danger-600", children: t("group.duplicateAlias", { alias: row.alias }) }))] })] }), host ? (_jsxs("div", { className: "flex flex-col gap-1", children: [_jsx("label", { htmlFor: `${base}-type`, className: "text-xs font-medium text-text-secondary", children: t("group.dataTypeColumn") }), _jsxs("select", { id: `${base}-type`, className: SELECT_CLASS, value: row.dataTypeId, "aria-invalid": noType || undefined, "aria-describedby": noType ? `${base}-type-error` : undefined, onChange: (event) => update(index, { dataTypeId: event.target.value }), children: [_jsx("option", { value: "", children: t("group.chooseDataType") }), row.dataTypeId !== "" && !known && (_jsx("option", { value: row.dataTypeId, disabled: true, children: t("group.missingType") })), choices.map((d) => (_jsx("option", { value: d.id, children: d.name }, d.id)))] }), noType && (_jsx("p", { id: `${base}-type-error`, className: "text-xs text-danger-600", children: t("group.typeRequired") }))] })) : (_jsx("p", { className: "text-sm text-text-tertiary", children: t("group.noHost") })), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Checkbox, { id: `group-required-${index}`, checked: row.required, onCheckedChange: (checked) => update(index, { required: checked === true }) }), _jsx("label", { htmlFor: `group-required-${index}`, className: "text-sm text-text-primary", children: t("group.requiredColumn") }), _jsx(IconTooltip, { children: _jsx(Button, { type: "button", variant: "ghost", size: "sm", className: "ms-auto", disabled: index === 0, "aria-label": t("group.moveUp", { name: label }), onClick: () => move(index, -1), children: _jsx("span", { "aria-hidden": "true", children: "\u2191" }) }) }), _jsx(IconTooltip, { children: _jsx(Button, { type: "button", variant: "ghost", size: "sm", disabled: index === rows.length - 1, "aria-label": t("group.moveDown", { name: label }), onClick: () => move(index, 1), children: _jsx("span", { "aria-hidden": "true", children: "\u2193" }) }) }), _jsx(IconTooltip, { children: _jsx(Button, { type: "button", variant: "ghost", size: "sm", "aria-label": t("group.removeField", { name: label }), onClick: () => {
|
|
116
|
+
keys.removed(index);
|
|
117
|
+
write(rows.filter((_, i) => i !== index));
|
|
118
|
+
}, children: _jsx("span", { "aria-hidden": "true", children: "\u2715" }) }) })] })] }, index));
|
|
119
|
+
}), _jsxs("div", { className: "flex items-center gap-3", children: [_jsx(Button, { type: "button", variant: "outline", size: "sm", disabled: rows.length >= GROUP_FIELDS_MAX, onClick: () => {
|
|
120
|
+
keys.added();
|
|
121
|
+
write([...rows, { alias: "", name: "", dataTypeId: "", required: false }]);
|
|
122
|
+
}, children: t("group.addField") }), rows.length >= GROUP_FIELDS_MAX && (_jsx("span", { className: "text-sm text-text-tertiary", children: t("group.atMax", { max: GROUP_FIELDS_MAX }) }))] })] }));
|
|
123
|
+
}
|
|
@@ -8,7 +8,7 @@ import { bracketMatching, defaultHighlightStyle, indentOnInput, syntaxHighlighti
|
|
|
8
8
|
import { autocompletion, closeBrackets, closeBracketsKeymap, completionKeymap } from "@codemirror/autocomplete";
|
|
9
9
|
// Tags a dispatch made by the value-sync effect below so the update
|
|
10
10
|
// listener can tell "we just replaced the doc from a new `value` prop"
|
|
11
|
-
// apart from a real user edit and skip the onChange echo
|
|
11
|
+
// apart from a real user edit and skip the onChange echo, the same pattern
|
|
12
12
|
// (and same rationale) as admin-ui's code-editor.tsx.
|
|
13
13
|
const externalSync = Annotation.define();
|
|
14
14
|
export function HtmlCodeEditor({ value, onChange, readOnly = false, fieldId, ariaLabelledBy, ariaDescribedBy, ariaInvalid, }) {
|
|
@@ -68,7 +68,7 @@ export function HtmlCodeEditor({ value, onChange, readOnly = false, fieldId, ari
|
|
|
68
68
|
view.destroy();
|
|
69
69
|
viewRef.current = null;
|
|
70
70
|
};
|
|
71
|
-
// Mount-only by design
|
|
71
|
+
// Mount-only by design; see admin-ui's code-editor.tsx for the same
|
|
72
72
|
// convention and rationale.
|
|
73
73
|
}, []);
|
|
74
74
|
// Sync an externally-changed `value` into the view, guarded against
|
package/dist/views/html-view.js
CHANGED
|
@@ -2,7 +2,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { lazy, Suspense } from "react";
|
|
3
3
|
import { PropertyField, Switch, usePropertyFieldControl } from "@kardalum/ui";
|
|
4
4
|
import { usePluginSettingsValue, usePluginValue } from "../plugin-context.js";
|
|
5
|
-
|
|
5
|
+
import { useSdkString } from "../sdk-strings.js";
|
|
6
|
+
// The only React.lazy() boundary in this package's views so far, mirrors
|
|
6
7
|
// apps/admin-ui/src/editor/lazy-code-editor.tsx's split (html-code-editor.js
|
|
7
8
|
// pulls in the whole @codemirror/* graph, ~six packages' worth, which must
|
|
8
9
|
// stay out of whatever chunk loads this file / built-ins.tsx's static
|
|
@@ -11,15 +12,14 @@ import { usePluginSettingsValue, usePluginValue } from "../plugin-context.js";
|
|
|
11
12
|
// point for the com.kardalum.html editor.
|
|
12
13
|
const HtmlCodeEditorLazy = lazy(() => import("./html-code-editor.js").then((module) => ({ default: module.HtmlCodeEditor })));
|
|
13
14
|
// Same role="status" + aria-hidden placeholder pattern as
|
|
14
|
-
// lazy-code-editor.tsx's CodeEditorFallback
|
|
15
|
-
// package's views deliberately hardcode English strings today, see
|
|
16
|
-
// built-ins.tsx's TextReadOnlyView/ImageInputView precedent).
|
|
15
|
+
// lazy-code-editor.tsx's CodeEditorFallback, named through useSdkString().
|
|
17
16
|
function HtmlEditorFallback() {
|
|
18
|
-
|
|
17
|
+
const s = useSdkString();
|
|
18
|
+
return (_jsx("div", { role: "status", "aria-label": s("html.loading"), children: _jsx("div", { "aria-hidden": "true", className: "h-44 w-full animate-pulse rounded-md border border-border-default bg-background-subtle" }) }));
|
|
19
19
|
}
|
|
20
20
|
// The Trusted setting has no bearing on how this field is EDITED (both
|
|
21
|
-
// modes get the same CodeMirror surface)
|
|
22
|
-
// (render-context.ts's html branch, S197 Task 8)
|
|
21
|
+
// modes get the same CodeMirror surface), only on how it's RENDERED
|
|
22
|
+
// (render-context.ts's html branch, S197 Task 8), so neither the input
|
|
23
23
|
// nor the readOnly view reads settings at all, matching the datatype's
|
|
24
24
|
// posture that `trusted` is purely a render-pipeline decision.
|
|
25
25
|
function HtmlEditor({ editable }) {
|
|
@@ -42,12 +42,13 @@ export function HtmlInputView() {
|
|
|
42
42
|
export function HtmlReadOnlyView() {
|
|
43
43
|
return _jsx(HtmlEditor, { editable: false });
|
|
44
44
|
}
|
|
45
|
-
// Rendered by the Data Types editor only (data-type-editor.tsx)
|
|
45
|
+
// Rendered by the Data Types editor only (data-type-editor.tsx): a
|
|
46
46
|
// settings-EDITING view, same usePluginSettingsValue() convention as
|
|
47
47
|
// TextSettingsView/ImageSettingsView in built-ins.tsx. The help copy is
|
|
48
|
-
// spec-binding verbatim text (S197 spec §7 / task brief), not a paraphrase
|
|
49
|
-
//
|
|
48
|
+
// spec-binding verbatim text (S197 spec §7 / task brief), not a paraphrase,
|
|
49
|
+
// so do not reword it (its English lives in SDK_STRINGS_EN, html.trustedHelp).
|
|
50
50
|
export function HtmlSettingsView() {
|
|
51
51
|
const { value: settings, onChange } = usePluginSettingsValue();
|
|
52
|
-
|
|
52
|
+
const s = useSdkString();
|
|
53
|
+
return (_jsx("div", { className: "flex flex-col gap-4", children: _jsx(PropertyField, { label: s("html.trustedLabel"), htmlFor: "html-settings-trusted", helpText: s("html.trustedHelp"), children: _jsx(Switch, { id: "html-settings-trusted", checked: settings.trusted === true, onCheckedChange: (checked) => onChange({ ...settings, trusted: checked === true }) }) }) }));
|
|
53
54
|
}
|
package/dist/views/image-view.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useId, useRef, useState } from "react";
|
|
3
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";
|
|
4
|
+
import { Button, cn, Input, PropertyField, TruncatedText, usePropertyFieldControl } from "@kardalum/ui";
|
|
5
5
|
import { MediaPicker } from "../media/media-picker.js";
|
|
6
|
-
import { uploadFailureMessage } from "../media/upload-error.js";
|
|
6
|
+
import { mediaUploadCodeMessage, uploadFailureMessage } from "../media/upload-error.js";
|
|
7
7
|
import { MANAGE_API, usePluginApi, usePluginSettings, usePluginSettingsValue, usePluginValue, } from "../plugin-context.js";
|
|
8
8
|
import { readAllPages } from "../read-all-pages.js";
|
|
9
|
+
import { useAdminChromeProps, useSdkString } from "../sdk-strings.js";
|
|
9
10
|
// downloadUrl is the stable app path for a public item (S186c §1/§3) but
|
|
10
|
-
// carries a freshly minted, short-lived `?token=` for a private one
|
|
11
|
+
// carries a freshly minted, short-lived `?token=` for a private one,
|
|
11
12
|
// never persisted; refetch GET /api/manage/v1/media/:id whenever the field's value
|
|
12
13
|
// (media id) changes rather than caching one, so a private item's
|
|
13
14
|
// preview always has a live token.
|
|
@@ -22,6 +23,7 @@ import { readAllPages } from "../read-all-pages.js";
|
|
|
22
23
|
// just changed. The listing is paged (200 at a time), so every page is read before a miss means "none".
|
|
23
24
|
function useMediaPreview(mediaId, rendition) {
|
|
24
25
|
const fetchApi = usePluginApi();
|
|
26
|
+
const s = useSdkString();
|
|
25
27
|
const [preview, setPreview] = useState(null);
|
|
26
28
|
const [loading, setLoading] = useState(false);
|
|
27
29
|
const [error, setError] = useState(null);
|
|
@@ -36,7 +38,7 @@ function useMediaPreview(mediaId, rendition) {
|
|
|
36
38
|
setError(null);
|
|
37
39
|
const item = fetchApi(`${MANAGE_API}/media/${mediaId}`).then(async (response) => {
|
|
38
40
|
if (!response.ok)
|
|
39
|
-
throw new Error(
|
|
41
|
+
throw new Error(s("image.loadFailed", { status: response.status }));
|
|
40
42
|
return (await response.json());
|
|
41
43
|
});
|
|
42
44
|
// A failed crop read resolves to "unknown" rather than rejecting: the
|
|
@@ -76,7 +78,7 @@ function useMediaPreview(mediaId, rendition) {
|
|
|
76
78
|
return () => {
|
|
77
79
|
cancelled = true;
|
|
78
80
|
};
|
|
79
|
-
}, [mediaId, rendition, fetchApi]);
|
|
81
|
+
}, [mediaId, rendition, fetchApi, s]);
|
|
80
82
|
return { preview, loading, error };
|
|
81
83
|
}
|
|
82
84
|
// Sized by the caller: the read-only view shows the picture on its own and
|
|
@@ -87,10 +89,11 @@ function PreviewImage({ preview, className }) {
|
|
|
87
89
|
}
|
|
88
90
|
function ImageThumbnail({ mediaId }) {
|
|
89
91
|
const { preview, loading, error } = useMediaPreview(mediaId, null);
|
|
92
|
+
const s = useSdkString();
|
|
90
93
|
if (!mediaId)
|
|
91
94
|
return null;
|
|
92
95
|
if (loading)
|
|
93
|
-
return _jsx("p", { className: "text-xs text-text-secondary", children: "
|
|
96
|
+
return _jsx("p", { className: "text-xs text-text-secondary", children: s("image.loading") });
|
|
94
97
|
if (error)
|
|
95
98
|
return _jsx("p", { className: "text-xs text-danger-600", children: error });
|
|
96
99
|
if (!preview)
|
|
@@ -127,7 +130,8 @@ function requestedRendition(settings) {
|
|
|
127
130
|
// known at all.
|
|
128
131
|
function PictureFacts({ preview }) {
|
|
129
132
|
const cut = preview.cut;
|
|
130
|
-
|
|
133
|
+
const s = useSdkString();
|
|
134
|
+
return (_jsxs("div", { className: "min-w-0 flex-1", children: [_jsx(TruncatedText, { className: "block truncate font-mono text-xs text-text-primary", dir: "auto", children: cut.state === "found" ? cut.filename : preview.filename }), cut.state === "found" && (_jsx(TruncatedText, { className: "block truncate text-xs text-text-tertiary", dir: "auto", children: s("image.cropOf", { crop: cut.name, file: 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: s("image.fullImage") }))] }));
|
|
131
135
|
}
|
|
132
136
|
export function ImageInputView() {
|
|
133
137
|
const { value, onChange } = usePluginValue();
|
|
@@ -139,6 +143,10 @@ export function ImageInputView() {
|
|
|
139
143
|
const [picking, setPicking] = useState(false);
|
|
140
144
|
const uploadInputRef = useRef(null);
|
|
141
145
|
const hintId = useId();
|
|
146
|
+
const s = useSdkString();
|
|
147
|
+
// The field's controls are the admin's words, so they take the admin's
|
|
148
|
+
// direction and language, not the content's around the field (S366f D10).
|
|
149
|
+
const chrome = useAdminChromeProps();
|
|
142
150
|
const rendition = requestedRendition(settings);
|
|
143
151
|
const { preview, loading, error: previewError } = useMediaPreview(value, rendition);
|
|
144
152
|
// The field's own hint joins whatever the host's PropertyField already
|
|
@@ -160,7 +168,7 @@ export function ImageInputView() {
|
|
|
160
168
|
// machine. Both numbers, same as the server's refusal, so a person
|
|
161
169
|
// knows by how much they are over either way.
|
|
162
170
|
if (settings.maxSizeBytes != null && file.size > settings.maxSizeBytes) {
|
|
163
|
-
setError(
|
|
171
|
+
setError(s("image.tooLarge", { size: file.size, limit: settings.maxSizeBytes }));
|
|
164
172
|
return;
|
|
165
173
|
}
|
|
166
174
|
setUploading(true);
|
|
@@ -172,8 +180,9 @@ export function ImageInputView() {
|
|
|
172
180
|
// these bytes for the file upload type's limit, which this field
|
|
173
181
|
// knows nothing about, and that refusal names the limit and the
|
|
174
182
|
// size (S234d Task 8).
|
|
175
|
-
if (!response.ok)
|
|
176
|
-
throw new Error(await uploadFailureMessage(response));
|
|
183
|
+
if (!response.ok) {
|
|
184
|
+
throw new Error(await uploadFailureMessage(response, (status) => s("shared.uploadFailed", { status }), (code) => mediaUploadCodeMessage(code, () => s("shared.mediaStoreSwitchedOff"))));
|
|
185
|
+
}
|
|
177
186
|
const media = (await response.json());
|
|
178
187
|
onChange(media.id);
|
|
179
188
|
}
|
|
@@ -184,8 +193,8 @@ export function ImageInputView() {
|
|
|
184
193
|
setUploading(false);
|
|
185
194
|
}
|
|
186
195
|
}
|
|
187
|
-
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 &&
|
|
188
|
-
(loading ? (_jsx("p", { className: "text-xs text-text-secondary", children: "
|
|
196
|
+
return (_jsxs("div", { ...chrome, 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 &&
|
|
197
|
+
(loading ? (_jsx("p", { className: "text-xs text-text-secondary", children: s("image.loading") })) : 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: s("image.choose") }), _jsx(Button, { type: "button", variant: "outline", size: "sm", disabled: uploading, onClick: () => uploadInputRef.current?.click(), children: uploading ? s("image.uploading") : s("image.upload") }), value && (_jsx(Button, { type: "button", variant: "ghost", size: "sm", disabled: uploading, onClick: () => onChange(null), children: s("image.remove") }))] })] }), _jsx("input", { ref: uploadInputRef, type: "file", className: "hidden", accept: settings.acceptedTypes && settings.acceptedTypes.length > 0 ? settings.acceptedTypes.join(",") : "image/*", "aria-label": s("image.uploadAria"), disabled: uploading, onChange: (e) => void handleFileChange(e) }), rendition !== null && (_jsx("p", { id: hintId, className: "text-xs text-text-tertiary", children: s("image.asksFor", { shape: renditionShape(rendition) }) })), error && _jsx("p", { className: "text-xs text-danger-600", children: error }), picking && (_jsx(MediaPicker
|
|
189
198
|
// The field stores one media id and has nowhere to put alt text,
|
|
190
199
|
// so a pick commits and the drawer closes in one gesture. Rich
|
|
191
200
|
// text passes true, because there the alt lives on the node.
|
|
@@ -273,6 +282,7 @@ function collectRenditionChoices(documentTypes, dataTypes) {
|
|
|
273
282
|
}
|
|
274
283
|
function useRenditionChoices() {
|
|
275
284
|
const fetchApi = usePluginApi();
|
|
285
|
+
const s = useSdkString();
|
|
276
286
|
const [groups, setGroups] = useState([]);
|
|
277
287
|
const [loading, setLoading] = useState(true);
|
|
278
288
|
const [error, setError] = useState(null);
|
|
@@ -286,8 +296,16 @@ function useRenditionChoices() {
|
|
|
286
296
|
setError(null);
|
|
287
297
|
setComplete(true);
|
|
288
298
|
Promise.all([
|
|
289
|
-
readAllPages(fetchApi, `${MANAGE_API}/document-types`, "document types", {
|
|
290
|
-
|
|
299
|
+
readAllPages(fetchApi, `${MANAGE_API}/document-types`, "document types", {
|
|
300
|
+
limit: TYPE_PAGE_LIMIT,
|
|
301
|
+
cap: TYPE_PAGE_CAP,
|
|
302
|
+
failure: ({ status }) => s("image.documentTypesFailed", { detail: status ?? s("shared.unexpectedAnswer") }),
|
|
303
|
+
}),
|
|
304
|
+
readAllPages(fetchApi, `${MANAGE_API}/data-types`, "data types", {
|
|
305
|
+
limit: TYPE_PAGE_LIMIT,
|
|
306
|
+
cap: TYPE_PAGE_CAP,
|
|
307
|
+
failure: ({ status }) => s("image.dataTypesFailed", { detail: status ?? s("shared.unexpectedAnswer") }),
|
|
308
|
+
}),
|
|
291
309
|
])
|
|
292
310
|
.then(([documentTypes, dataTypes]) => {
|
|
293
311
|
if (cancelled)
|
|
@@ -306,10 +324,10 @@ function useRenditionChoices() {
|
|
|
306
324
|
return () => {
|
|
307
325
|
cancelled = true;
|
|
308
326
|
};
|
|
309
|
-
}, [fetchApi]);
|
|
327
|
+
}, [fetchApi, s]);
|
|
310
328
|
return { groups, loading, error, complete };
|
|
311
329
|
}
|
|
312
|
-
// Rendered by the Data Types editor only
|
|
330
|
+
// Rendered by the Data Types editor only, a settings-EDITING view (see
|
|
313
331
|
// TextSettingsView in built-ins.tsx for the same pattern/rationale).
|
|
314
332
|
// acceptedTypes is edited as a comma-separated string (no multi-select
|
|
315
333
|
// widget precedent in this codebase) and parsed to string[] on change.
|
|
@@ -323,6 +341,7 @@ export function ImageSettingsView() {
|
|
|
323
341
|
const { value: settings, onChange } = usePluginSettingsValue();
|
|
324
342
|
const { groups, loading, error, complete } = useRenditionChoices();
|
|
325
343
|
const noticeId = useId();
|
|
344
|
+
const s = useSdkString();
|
|
326
345
|
const rendition = requestedRendition(settings);
|
|
327
346
|
const listed = groups.some((group) => group.choices.some((choice) => choice.name === rendition));
|
|
328
347
|
// Whether the question has been answered at all. It decides what this
|
|
@@ -340,7 +359,7 @@ export function ImageSettingsView() {
|
|
|
340
359
|
? {
|
|
341
360
|
role: "status",
|
|
342
361
|
className: "text-text-tertiary",
|
|
343
|
-
text: "
|
|
362
|
+
text: s("image.loadingCrops"),
|
|
344
363
|
}
|
|
345
364
|
: error !== null
|
|
346
365
|
? // Verbatim, the same convention the media picker follows: a list
|
|
@@ -351,20 +370,19 @@ export function ImageSettingsView() {
|
|
|
351
370
|
: {
|
|
352
371
|
role: "alert",
|
|
353
372
|
className: "text-danger-600",
|
|
354
|
-
text:
|
|
355
|
-
"so a crop declared beyond them is missing from this list.",
|
|
373
|
+
text: s("image.typesTruncated", { limit: TYPE_PAGE_CAP * TYPE_PAGE_LIMIT }),
|
|
356
374
|
};
|
|
357
|
-
return (_jsxs("div", { className: "flex flex-col gap-4", children: [_jsx(PropertyField, { label: "
|
|
375
|
+
return (_jsxs("div", { className: "flex flex-col gap-4", children: [_jsx(PropertyField, { label: s("image.acceptedTypesLabel"), htmlFor: "image-settings-accepted-types", helpText: s("image.acceptedTypesHelp"), children: _jsx(Input, { id: "image-settings-accepted-types", value: settings.acceptedTypes?.join(",") ?? "", onChange: (e) => {
|
|
358
376
|
const types = e.target.value
|
|
359
377
|
.split(",")
|
|
360
378
|
.map((t) => t.trim())
|
|
361
379
|
.filter((t) => t.length > 0);
|
|
362
380
|
onChange({ ...settings, acceptedTypes: types.length > 0 ? types : undefined });
|
|
363
|
-
} }) }), _jsx(PropertyField, { label: "
|
|
381
|
+
} }) }), _jsx(PropertyField, { label: s("image.maxSizeLabel"), htmlFor: "image-settings-max-size", helpText: s("image.maxSizeHelp"), 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: s("image.cropLabel"), htmlFor: "image-settings-rendition", helpText: s("image.cropHelp"), children: _jsxs("select", { id: "image-settings-rendition", className: SELECT_CLASS, "aria-describedby": notice ? noticeId : undefined, value: rendition ?? "",
|
|
364
382
|
// The empty option is `rendition: null`, which is how
|
|
365
383
|
// ImageSettingsSchema spells "any picture will do", rather than
|
|
366
384
|
// a missing key or an empty string.
|
|
367
|
-
onChange: (event) => onChange({ ...settings, rendition: event.target.value === "" ? null : event.target.value }), children: [_jsx("option", { value: "", children: "
|
|
385
|
+
onChange: (event) => onChange({ ...settings, rendition: event.target.value === "" ? null : event.target.value }), children: [_jsx("option", { value: "", children: s("image.noCrop") }), rendition !== null && !listed && (_jsx("option", { value: rendition, children: settled ? s("image.undeclaredCrop", { shape: renditionShape(rendition) }) : renditionShape(rendition) })), groups.map((group) => (_jsx("optgroup", { label: group.typeName, children: group.choices.map((choice) => (_jsx("option", { value: choice.name, children: s("image.cropChoice", { caption: choice.caption, shape: renditionShape(choice.name) }) }, choice.fieldId))) }, group.typeId)))] }) }), notice && (_jsx("p", { id: noticeId, role: notice.role, className: cn("text-xs", notice.className), children: notice.text }))] }));
|
|
368
386
|
}
|
|
369
387
|
export function ImageReadOnlyView() {
|
|
370
388
|
const { value } = usePluginValue();
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useId, useState } from "react";
|
|
3
|
+
import { LINK_LABEL_MAX, LINK_URL_MAX, isOutsideLinkAddress, readLinkSettings, readLinkValue, } from "@kardalum/api-schemas";
|
|
4
|
+
import { Button, Checkbox, Input, PropertyField, TruncatedText, cn, usePropertyFieldControl } from "@kardalum/ui";
|
|
5
|
+
import { PagePickerSheet } from "../content-picker/page-picker-sheet.js";
|
|
6
|
+
import { summaryMark, usePageSummaries } from "../content-picker/page-tree.js";
|
|
7
|
+
import { usePluginSettings, usePluginSettingsValue, usePluginValue } from "../plugin-context.js";
|
|
8
|
+
import { usePluginTranslate } from "../plugin-screen-context.js";
|
|
9
|
+
import { useAdminChromeProps } from "../sdk-strings.js";
|
|
10
|
+
function kindOf(link) {
|
|
11
|
+
if (link === null)
|
|
12
|
+
return null;
|
|
13
|
+
return link.page !== undefined ? "page" : "url";
|
|
14
|
+
}
|
|
15
|
+
function kindAllowed(kind, allow) {
|
|
16
|
+
return allow === "both" || (allow === "internal" ? kind === "page" : kind === "url");
|
|
17
|
+
}
|
|
18
|
+
/** The words for a page that is gone, trashed, a draft or unreadable; no mark for a plain page. */
|
|
19
|
+
function usePageLine(id) {
|
|
20
|
+
const t = usePluginTranslate();
|
|
21
|
+
const summaries = usePageSummaries(id === null ? [] : [id]);
|
|
22
|
+
const summary = id === null ? undefined : summaries.byId.get(id);
|
|
23
|
+
// Only a read in flight is "loading"; a failed read or an id the read did not return is a mark, never the id.
|
|
24
|
+
const loading = id !== null && (summaries.status === "loading" || summaries.status === "idle");
|
|
25
|
+
const mark = summary !== undefined ? summaryMark(summary) : id === null || loading ? null : summaries.status === "failed" ? "noAccess" : "missing";
|
|
26
|
+
const markText = mark === null ? null : t(`contentPicker.${mark}`);
|
|
27
|
+
return {
|
|
28
|
+
loading,
|
|
29
|
+
name: summary?.name ?? null,
|
|
30
|
+
path: summary?.path ?? null,
|
|
31
|
+
markText,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export function LinkInputView() {
|
|
35
|
+
const { value, onChange } = usePluginValue();
|
|
36
|
+
const { allow } = readLinkSettings(usePluginSettings());
|
|
37
|
+
const link = readLinkValue(value);
|
|
38
|
+
const field = usePropertyFieldControl();
|
|
39
|
+
// M32 I2: in page mode the group is named and described by the field, and the label's `for`
|
|
40
|
+
// (the control id) names the page button, which keeps its own name; aria-invalid stays off the
|
|
41
|
+
// group. M32 I5: aria-invalid sits on the button the label names, with the error description.
|
|
42
|
+
// In address mode the input takes the whole wiring.
|
|
43
|
+
// The error description sits on the page button only (not the group too), so it is read once.
|
|
44
|
+
const { id: controlId, "aria-invalid": invalid, "aria-describedby": describedBy, ...groupWiring } = field;
|
|
45
|
+
const t = usePluginTranslate();
|
|
46
|
+
const chrome = useAdminChromeProps();
|
|
47
|
+
const groupId = useId();
|
|
48
|
+
const labelInputId = useId();
|
|
49
|
+
const storedKind = kindOf(link);
|
|
50
|
+
const defaultKind = allow === "external" ? "url" : "page";
|
|
51
|
+
const [chosenKind, setChosenKind] = useState(null);
|
|
52
|
+
const [draft, setDraft] = useState({ label: "", newTab: false });
|
|
53
|
+
const [open, setOpen] = useState(false);
|
|
54
|
+
// A whitespace-only entry stays in the field but is never stored.
|
|
55
|
+
const [blankText, setBlankText] = useState(null);
|
|
56
|
+
// A value changed from outside (an undo, a panel's proposal) ends a blank entry in progress.
|
|
57
|
+
const [seenValue, setSeenValue] = useState(value);
|
|
58
|
+
if (seenValue !== value) {
|
|
59
|
+
setSeenValue(value);
|
|
60
|
+
if (blankText !== null)
|
|
61
|
+
setBlankText(null);
|
|
62
|
+
}
|
|
63
|
+
const notAllowed = storedKind !== null && !kindAllowed(storedKind, allow);
|
|
64
|
+
// A stored kind the settings no longer allow keeps its value, but the editor works in an allowed kind.
|
|
65
|
+
const kind = allow === "internal"
|
|
66
|
+
? "page"
|
|
67
|
+
: allow === "external"
|
|
68
|
+
? "url"
|
|
69
|
+
: (chosenKind ?? (notAllowed ? defaultKind : (storedKind ?? defaultKind)));
|
|
70
|
+
const label = link?.label ?? draft.label;
|
|
71
|
+
const newTab = link?.newTab ?? draft.newTab;
|
|
72
|
+
const page = kind === "page" ? (link?.page ?? null) : null;
|
|
73
|
+
const url = kind === "url" ? (link?.url ?? "") : "";
|
|
74
|
+
const pageLine = usePageLine(page);
|
|
75
|
+
const needsTarget = link === null && (label !== "" || newTab);
|
|
76
|
+
const needsTargetId = `${groupId}-needs`;
|
|
77
|
+
const badAddress = url.trim() !== "" && !isOutsideLinkAddress(url);
|
|
78
|
+
const store = (target, nextLabel, nextNewTab) => {
|
|
79
|
+
setDraft({ label: nextLabel, newTab: nextNewTab });
|
|
80
|
+
if (target === null)
|
|
81
|
+
return onChange(null);
|
|
82
|
+
onChange({ ...target, label: nextLabel, newTab: nextNewTab });
|
|
83
|
+
};
|
|
84
|
+
const current = () => link === null ? null : link.page !== undefined ? { page: link.page } : { url: link.url };
|
|
85
|
+
// The label and the tab choice sit beside the target; with no target they wait in the draft.
|
|
86
|
+
const setLabel = (next) => store(current(), next, newTab);
|
|
87
|
+
const setNewTab = (next) => store(current(), label, next);
|
|
88
|
+
const switchKind = (next) => {
|
|
89
|
+
setChosenKind(next);
|
|
90
|
+
setBlankText(null);
|
|
91
|
+
if (storedKind !== null && storedKind !== next)
|
|
92
|
+
store(null, label, newTab);
|
|
93
|
+
};
|
|
94
|
+
return (_jsxs("div", { ...chrome, className: "flex flex-col gap-3", children: [allow === "both" && (_jsxs("div", { role: "radiogroup", "aria-labelledby": `${groupId}-kind`, className: "flex flex-col gap-1", children: [_jsx("span", { id: `${groupId}-kind`, className: "text-sm font-medium text-text-primary", children: t("link.kindLabel") }), ["page", "url"].map((entry) => (_jsxs("label", { className: "flex items-center gap-2 text-sm text-text-primary", children: [_jsx("input", { type: "radio", name: groupId, checked: kind === entry, onChange: () => switchKind(entry), className: "size-4 accent-primary-600" }), t(entry === "page" ? "link.kindPage" : "link.kindUrl")] }, entry)))] })), notAllowed && (_jsx("p", { role: "alert", className: "text-sm text-danger-600", children: t("link.kindNotAllowed") })), notAllowed && link !== null && _jsx(LinkTargetLine, { link: link }), kind === "page" && (_jsxs("div", { ...groupWiring, role: "group", className: "flex flex-col gap-2", children: [page !== null ? (_jsxs("div", { className: "flex min-w-0 flex-col rounded-md border border-border-default px-3 py-2", children: [pageLine.loading && _jsx(TruncatedText, { className: "truncate text-sm text-text-tertiary", children: t("contentPicker.loading") }), pageLine.name !== null && _jsx(TruncatedText, { className: "truncate text-sm text-text-primary", children: pageLine.name }), pageLine.path !== null && _jsx(TruncatedText, { className: "truncate font-mono text-xs text-text-tertiary", children: pageLine.path }), pageLine.markText !== null && (_jsx("span", { className: cn("text-xs", pageLine.name !== null ? "text-text-secondary" : "text-sm text-text-primary"), children: pageLine.markText }))] })) : (_jsx("p", { className: "text-sm text-text-tertiary", children: t("link.noPage") })), _jsx("div", { children: _jsx(Button, { id: controlId, "aria-invalid": invalid, "aria-describedby": describedBy, "aria-label": t(page === null ? "link.choosePage" : "link.changePage"), type: "button", variant: "outline", size: "sm", onClick: () => setOpen(true), children: t(page === null ? "link.choosePage" : "link.changePage") }) }), _jsx(PagePickerSheet, { open: open, onOpenChange: setOpen, startNode: null, documentTypes: [], multiple: false, remaining: 1, chosen: [], onChoose: (picked) => {
|
|
95
|
+
const id = picked[0];
|
|
96
|
+
if (id !== undefined)
|
|
97
|
+
store({ page: id }, label, newTab);
|
|
98
|
+
} })] })), kind === "url" && (_jsxs("div", { className: "flex flex-col gap-1", children: [_jsx(Input, { ...field, type: "text", inputMode: "url", dir: "ltr", maxLength: LINK_URL_MAX, "aria-label": t("link.urlLabel"), "aria-invalid": badAddress || field["aria-invalid"] || undefined, "aria-describedby": [
|
|
99
|
+
...new Set([...(field["aria-describedby"] ?? "").split(" "), `${groupId}-hint`, badAddress ? `${groupId}-bad` : ""].filter((id) => id !== "")),
|
|
100
|
+
].join(" "), value: blankText ?? url, onChange: (event) => {
|
|
101
|
+
const raw = event.target.value;
|
|
102
|
+
if (raw === "") {
|
|
103
|
+
setBlankText(null);
|
|
104
|
+
store(null, label, newTab);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const text = raw.trim();
|
|
108
|
+
if (text === "") {
|
|
109
|
+
setBlankText(raw);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
setBlankText(null);
|
|
113
|
+
store({ url: text }, label, newTab);
|
|
114
|
+
} }), _jsx("p", { id: `${groupId}-hint`, className: "text-xs text-text-tertiary", children: t("link.urlHint") }), badAddress && (_jsx("p", { id: `${groupId}-bad`, role: "alert", className: "text-sm text-danger-600", children: t("link.badAddress") }))] })), _jsx(PropertyField, { label: t("link.labelLabel"), htmlFor: labelInputId, helpText: t("link.labelHint"), children: _jsx(Input, { id: labelInputId, maxLength: LINK_LABEL_MAX, value: label, "aria-describedby": needsTarget ? needsTargetId : undefined, onChange: (event) => setLabel(event.target.value) }) }), needsTarget && (_jsx("p", { id: needsTargetId, className: "text-xs text-text-secondary", children: t("link.labelNeedsTarget") })), _jsxs("label", { className: "flex items-center gap-2 text-sm text-text-primary", children: [_jsx(Checkbox, { checked: newTab, "aria-describedby": needsTarget ? needsTargetId : undefined, onCheckedChange: (checked) => setNewTab(checked === true) }), t("link.newTab")] }), link !== null && (_jsx("div", { children: _jsx(Button, { type: "button", variant: "ghost", size: "sm", onClick: () => store(null, "", false), children: t("link.clear") }) }))] }));
|
|
115
|
+
}
|
|
116
|
+
/** The stored target as plain text. An address is never an href; one that is not an outside address says so. */
|
|
117
|
+
function LinkTargetLine({ link }) {
|
|
118
|
+
const t = usePluginTranslate();
|
|
119
|
+
const pageLine = usePageLine(link.page ?? null);
|
|
120
|
+
if (link.page !== undefined) {
|
|
121
|
+
return (_jsx("span", { className: "font-mono text-xs text-text-secondary", children: pageLine.path ?? pageLine.markText ?? t("contentPicker.loading") }));
|
|
122
|
+
}
|
|
123
|
+
return (_jsxs("span", { className: "flex flex-col", children: [_jsx("span", { className: "break-all font-mono text-xs text-text-secondary", children: link.url }), !isOutsideLinkAddress(link.url) && _jsx("span", { className: "text-xs text-danger-600", children: t("link.badAddress") })] }));
|
|
124
|
+
}
|
|
125
|
+
export function LinkReadOnlyView() {
|
|
126
|
+
const { value } = usePluginValue();
|
|
127
|
+
const link = readLinkValue(value);
|
|
128
|
+
const t = usePluginTranslate();
|
|
129
|
+
const chrome = useAdminChromeProps();
|
|
130
|
+
const pageLine = usePageLine(link?.page ?? null);
|
|
131
|
+
if (link === null) {
|
|
132
|
+
return (_jsx("span", { ...chrome, className: "text-sm text-text-tertiary", children: t("link.none") }));
|
|
133
|
+
}
|
|
134
|
+
// A page that is missing or unreadable shows its mark, never its id.
|
|
135
|
+
const pageName = pageLine.name ?? (pageLine.loading ? t("contentPicker.loading") : null);
|
|
136
|
+
const shown = link.label !== "" ? link.label : link.page !== undefined ? pageName : link.url;
|
|
137
|
+
return (_jsxs("span", { ...chrome, className: "flex min-w-0 flex-col text-sm", children: [_jsxs("span", { className: "text-text-primary", children: [shown, link.newTab && _jsxs("span", { className: "text-text-secondary", children: [" ", t("link.newTabShort")] })] }), link.page !== undefined ? (_jsxs(_Fragment, { children: [pageLine.path !== null && _jsx("span", { className: "font-mono text-xs text-text-tertiary", children: pageLine.path }), pageLine.markText !== null && (_jsx("span", { className: cn("text-xs", pageLine.name !== null ? "text-text-secondary" : "text-sm text-text-primary"), children: pageLine.markText }))] })) : (_jsxs(_Fragment, { children: [_jsx("span", { className: "break-all font-mono text-xs text-text-tertiary", children: link.url }), !isOutsideLinkAddress(link.url) && _jsx("span", { className: "text-xs text-danger-600", children: t("link.badAddress") })] }))] }));
|
|
138
|
+
}
|
|
139
|
+
export function LinkSettingsView() {
|
|
140
|
+
const { value: stored, onChange } = usePluginSettingsValue();
|
|
141
|
+
const { allow } = readLinkSettings(stored);
|
|
142
|
+
const t = usePluginTranslate();
|
|
143
|
+
const groupName = useId();
|
|
144
|
+
const options = [
|
|
145
|
+
{ value: "both", key: "link.allowBoth" },
|
|
146
|
+
{ value: "internal", key: "link.allowInternal" },
|
|
147
|
+
{ value: "external", key: "link.allowExternal" },
|
|
148
|
+
];
|
|
149
|
+
return (_jsxs("fieldset", { className: "flex flex-col gap-2", children: [_jsx("legend", { className: "text-sm font-medium text-text-primary", children: t("link.allowLabel") }), options.map((option) => (_jsxs("label", { className: "flex items-center gap-2 text-sm text-text-primary", children: [_jsx("input", { type: "radio", name: groupName, checked: allow === option.value, onChange: () => onChange({ ...stored, allow: option.value }), className: "size-4 accent-primary-600" }), t(option.key)] }, option.value)))] }));
|
|
150
|
+
}
|