@lapis-notes/api 0.1.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 +9 -0
- package/LICENSE.md +4 -0
- package/README.md +43 -0
- package/dist/__tests__/data-adapter-conformance.js +205 -0
- package/dist/__tests__/lapis-runtime-manifest.js +32 -0
- package/dist/__tests__/svelte-internal-client.d.ts +3 -0
- package/dist/agent-result-views.d.ts +52 -0
- package/dist/agent-result-views.js +89 -0
- package/dist/agent-skills.d.ts +99 -0
- package/dist/agent-skills.js +182 -0
- package/dist/agent-tools.d.ts +92 -0
- package/dist/agent-tools.js +139 -0
- package/dist/app-database-host.d.ts +4 -0
- package/dist/app-database-host.js +4 -0
- package/dist/app-shell-plugin-persistence.d.ts +15 -0
- package/dist/app-shell-plugin-persistence.js +34 -0
- package/dist/app-url.d.ts +54 -0
- package/dist/app-url.js +269 -0
- package/dist/application-compatibility.d.ts +31 -0
- package/dist/application-compatibility.js +64 -0
- package/dist/application-state.svelte.d.ts +14 -0
- package/dist/application-state.svelte.js +30 -0
- package/dist/assets/lapis-logo.svg +471 -0
- package/dist/bases.d.ts +281 -0
- package/dist/bases.js +475 -0
- package/dist/cache.svelte.d.ts +569 -0
- package/dist/cache.svelte.js +1433 -0
- package/dist/command.svelte.d.ts +337 -0
- package/dist/command.svelte.js +571 -0
- package/dist/compat.d.ts +29 -0
- package/dist/compat.js +30 -0
- package/dist/components/configuration/configuration.css +199 -0
- package/dist/components/configuration/date-setting.svelte +71 -0
- package/dist/components/configuration/date-setting.svelte.d.ts +8 -0
- package/dist/components/configuration/list-setting.svelte +128 -0
- package/dist/components/configuration/list-setting.svelte.d.ts +13 -0
- package/dist/components/configuration/object-array-row-grip.svelte +78 -0
- package/dist/components/configuration/object-array-row-grip.svelte.d.ts +9 -0
- package/dist/components/configuration/object-array-row.svelte +163 -0
- package/dist/components/configuration/object-array-row.svelte.d.ts +19 -0
- package/dist/components/configuration/object-array-setting.svelte +196 -0
- package/dist/components/configuration/object-array-setting.svelte.d.ts +15 -0
- package/dist/components/configuration/object-array-table-dnd.d.ts +8 -0
- package/dist/components/configuration/object-array-table-dnd.js +10 -0
- package/dist/components/configuration/object-array-utils.d.ts +11 -0
- package/dist/components/configuration/object-array-utils.js +103 -0
- package/dist/components/configuration/object-grid-setting.svelte +79 -0
- package/dist/components/configuration/object-grid-setting.svelte.d.ts +10 -0
- package/dist/components/configuration/object-map-row.svelte +147 -0
- package/dist/components/configuration/object-map-row.svelte.d.ts +15 -0
- package/dist/components/configuration/object-map-setting.svelte +137 -0
- package/dist/components/configuration/object-map-setting.svelte.d.ts +14 -0
- package/dist/components/configuration/object-map-types.d.ts +5 -0
- package/dist/components/configuration/object-map-types.js +1 -0
- package/dist/components/configuration/options-combobox-setting.svelte +129 -0
- package/dist/components/configuration/options-combobox-setting.svelte.d.ts +12 -0
- package/dist/components/copy-button/button.svelte +93 -0
- package/dist/components/copy-button/button.svelte.d.ts +13 -0
- package/dist/components/copy-button/index.d.ts +2 -0
- package/dist/components/copy-button/index.js +2 -0
- package/dist/components/editor/editor.css +565 -0
- package/dist/components/editor/editor.d.ts +33 -0
- package/dist/components/editor/editor.js +132 -0
- package/dist/components/editor/editor.svelte +176 -0
- package/dist/components/editor/editor.svelte.d.ts +15 -0
- package/dist/components/editor/embedded-editor-surface.d.ts +12 -0
- package/dist/components/editor/embedded-editor-surface.js +22 -0
- package/dist/components/editor/embedded-editor-surface.svelte +115 -0
- package/dist/components/editor/embedded-editor-surface.svelte.d.ts +17 -0
- package/dist/components/editor/extensions/autocomplete/index.d.ts +2 -0
- package/dist/components/editor/extensions/autocomplete/index.js +2 -0
- package/dist/components/editor/extensions/autocomplete/lapis-code-mirror-autocomplete.d.ts +16 -0
- package/dist/components/editor/extensions/autocomplete/lapis-code-mirror-autocomplete.js +34 -0
- package/dist/components/editor/extensions/autocomplete/vault-completion-sources.d.ts +27 -0
- package/dist/components/editor/extensions/autocomplete/vault-completion-sources.js +55 -0
- package/dist/components/editor/extensions/class-highlighter/index.d.ts +1 -0
- package/dist/components/editor/extensions/class-highlighter/index.js +47 -0
- package/dist/components/editor/extensions/fold-gutter/index.d.ts +8 -0
- package/dist/components/editor/extensions/fold-gutter/index.js +40 -0
- package/dist/components/editor/extensions/gutter-line-style-sync/index.d.ts +2 -0
- package/dist/components/editor/extensions/gutter-line-style-sync/index.js +118 -0
- package/dist/components/editor/extensions/lint/index.d.ts +4 -0
- package/dist/components/editor/extensions/lint/index.js +4 -0
- package/dist/components/editor/extensions/lint/lapis-code-mirror-lint.d.ts +26 -0
- package/dist/components/editor/extensions/lint/lapis-code-mirror-lint.js +101 -0
- package/dist/components/editor/extensions/lint/lapis-lint-diagnostic-helpers.d.ts +8 -0
- package/dist/components/editor/extensions/lint/lapis-lint-diagnostic-helpers.js +7 -0
- package/dist/components/editor/extensions/lint/lapis-lint-diagnostic.d.ts +20 -0
- package/dist/components/editor/extensions/lint/lapis-lint-diagnostic.js +47 -0
- package/dist/components/editor/extensions/lint/lapis-lint-hover-tooltip.d.ts +9 -0
- package/dist/components/editor/extensions/lint/lapis-lint-hover-tooltip.js +373 -0
- package/dist/components/editor/extensions/lint/lapis-lint-inline-widget.d.ts +31 -0
- package/dist/components/editor/extensions/lint/lapis-lint-inline-widget.js +191 -0
- package/dist/components/editor/extensions/lint/lapis-lint-tooltip.svelte +176 -0
- package/dist/components/editor/extensions/lint/lapis-lint-tooltip.svelte.d.ts +15 -0
- package/dist/components/editor/extensions/lint/lint-tooltip-actions.d.ts +11 -0
- package/dist/components/editor/extensions/lint/lint-tooltip-actions.js +21 -0
- package/dist/components/editor/extensions/lint/mount-lint-tooltip.d.ts +16 -0
- package/dist/components/editor/extensions/lint/mount-lint-tooltip.js +60 -0
- package/dist/components/editor/extensions/search/dom.d.ts +2 -0
- package/dist/components/editor/extensions/search/dom.js +6 -0
- package/dist/components/editor/extensions/search/index.d.ts +35 -0
- package/dist/components/editor/extensions/search/index.js +44 -0
- package/dist/components/editor/extensions/search/search.svelte +335 -0
- package/dist/components/editor/extensions/search/search.svelte.d.ts +8 -0
- package/dist/components/editor/index.d.ts +9 -0
- package/dist/components/editor/index.js +9 -0
- package/dist/components/editor/language-service/dom.d.ts +1 -0
- package/dist/components/editor/language-service/dom.js +6 -0
- package/dist/components/editor/language-service/index.d.ts +28 -0
- package/dist/components/editor/language-service/index.js +342 -0
- package/dist/components/empty-view/empty-view.css +39 -0
- package/dist/components/empty-view/empty-view.svelte +26 -0
- package/dist/components/empty-view/empty-view.svelte.d.ts +9 -0
- package/dist/components/empty-view/index.d.ts +2 -0
- package/dist/components/empty-view/index.js +2 -0
- package/dist/components/icon/icon-list.css +74 -0
- package/dist/components/icon/icon-list.svelte +213 -0
- package/dist/components/icon/icon-list.svelte.d.ts +11 -0
- package/dist/components/icon/icon.svelte +15 -0
- package/dist/components/icon/icon.svelte.d.ts +7 -0
- package/dist/components/icon/index.d.ts +3 -0
- package/dist/components/icon/index.js +3 -0
- package/dist/components/menu/context-menu.svelte +89 -0
- package/dist/components/menu/context-menu.svelte.d.ts +11 -0
- package/dist/components/menu/drawer-menu.svelte +83 -0
- package/dist/components/menu/drawer-menu.svelte.d.ts +8 -0
- package/dist/components/menu/dropdown-menu.svelte +89 -0
- package/dist/components/menu/dropdown-menu.svelte.d.ts +11 -0
- package/dist/components/menu/index.d.ts +6 -0
- package/dist/components/menu/index.js +6 -0
- package/dist/components/menu/menu.css +139 -0
- package/dist/components/menu/menu.svelte +37 -0
- package/dist/components/menu/menu.svelte.d.ts +11 -0
- package/dist/components/menu/mobile-menu-query.svelte.d.ts +3 -0
- package/dist/components/menu/mobile-menu-query.svelte.js +21 -0
- package/dist/components/menu/popover-menu.svelte +90 -0
- package/dist/components/menu/popover-menu.svelte.d.ts +10 -0
- package/dist/components/select/index.d.ts +2 -0
- package/dist/components/select/index.js +2 -0
- package/dist/components/select/select.svelte +72 -0
- package/dist/components/select/select.svelte.d.ts +25 -0
- package/dist/configuration-option-source-providers.d.ts +17 -0
- package/dist/configuration-option-source-providers.js +59 -0
- package/dist/configuration-option-source-registry.d.ts +59 -0
- package/dist/configuration-option-source-registry.js +123 -0
- package/dist/configuration.svelte.d.ts +258 -0
- package/dist/configuration.svelte.js +887 -0
- package/dist/context-keys.svelte.d.ts +42 -0
- package/dist/context-keys.svelte.js +278 -0
- package/dist/context.svelte.d.ts +247 -0
- package/dist/context.svelte.js +540 -0
- package/dist/daily-document-provider.d.ts +38 -0
- package/dist/daily-document-provider.js +176 -0
- package/dist/design-core-button-types.d.ts +7 -0
- package/dist/design-core-button-types.js +1 -0
- package/dist/diagnostics.d.ts +93 -0
- package/dist/diagnostics.js +84 -0
- package/dist/dialog-portal.d.ts +3 -0
- package/dist/dialog-portal.js +3 -0
- package/dist/docs-api.d.ts +44 -0
- package/dist/docs-api.js +29 -0
- package/dist/editor-view-registry.d.ts +35 -0
- package/dist/editor-view-registry.js +112 -0
- package/dist/editor.svelte.d.ts +126 -0
- package/dist/editor.svelte.js +454 -0
- package/dist/embed-registry.d.ts +15 -0
- package/dist/embed-registry.js +16 -0
- package/dist/enhance.d.ts +111 -0
- package/dist/enhance.js +309 -0
- package/dist/events.d.ts +28 -0
- package/dist/events.js +49 -0
- package/dist/file-manager.d.ts +90 -0
- package/dist/file-manager.js +289 -0
- package/dist/file-tools/app-tools.d.ts +3 -0
- package/dist/file-tools/app-tools.js +242 -0
- package/dist/file-tools/index.d.ts +3 -0
- package/dist/file-tools/index.js +3 -0
- package/dist/file-tools/paths.d.ts +14 -0
- package/dist/file-tools/paths.js +33 -0
- package/dist/file-tools/vault-operations.d.ts +3 -0
- package/dist/file-tools/vault-operations.js +60 -0
- package/dist/generated/plugin-host-modules.schema.generated.d.ts +371 -0
- package/dist/generated/plugin-host-modules.schema.generated.js +374 -0
- package/dist/glob.d.ts +15 -0
- package/dist/glob.js +68 -0
- package/dist/history.svelte.d.ts +24 -0
- package/dist/history.svelte.js +74 -0
- package/dist/hooks/createVirtualizer.svelte.d.ts +7 -0
- package/dist/hooks/createVirtualizer.svelte.js +70 -0
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/index.js +5 -0
- package/dist/hooks/is-mobile.svelte.d.ts +5 -0
- package/dist/hooks/is-mobile.svelte.js +23 -0
- package/dist/hooks/mountComponent.svelte.d.ts +7 -0
- package/dist/hooks/mountComponent.svelte.js +16 -0
- package/dist/hooks/use-text-highlight.d.ts +17 -0
- package/dist/hooks/use-text-highlight.js +82 -0
- package/dist/hooks/useBoundingRect.svelte.d.ts +11 -0
- package/dist/hooks/useBoundingRect.svelte.js +46 -0
- package/dist/icons/index.d.ts +57 -0
- package/dist/icons/index.js +288 -0
- package/dist/index.d.ts +87 -0
- package/dist/index.js +87 -0
- package/dist/language-service/index.d.ts +9 -0
- package/dist/language-service/index.js +7 -0
- package/dist/language-service/manager.d.ts +47 -0
- package/dist/language-service/manager.js +404 -0
- package/dist/language-service/types.d.ts +92 -0
- package/dist/language-service/types.js +1 -0
- package/dist/language-service/virtual-document.d.ts +11 -0
- package/dist/language-service/virtual-document.js +45 -0
- package/dist/language-service/worker-protocol.d.ts +63 -0
- package/dist/language-service/worker-protocol.js +1 -0
- package/dist/language-service/worker-provider.d.ts +9 -0
- package/dist/language-service/worker-provider.js +38 -0
- package/dist/lapis-extension.d.ts +244 -0
- package/dist/lapis-extension.js +591 -0
- package/dist/links.d.ts +34 -0
- package/dist/links.js +191 -0
- package/dist/loaders.d.ts +9 -0
- package/dist/loaders.js +59 -0
- package/dist/localization-manager.svelte.d.ts +56 -0
- package/dist/localization-manager.svelte.js +157 -0
- package/dist/logging.d.ts +172 -0
- package/dist/logging.js +352 -0
- package/dist/markdown-extension-registry.d.ts +31 -0
- package/dist/markdown-extension-registry.js +31 -0
- package/dist/markdown-file-surface-registry.d.ts +25 -0
- package/dist/markdown-file-surface-registry.js +23 -0
- package/dist/markdown.d.ts +205 -0
- package/dist/markdown.js +147 -0
- package/dist/menu-utils.d.ts +1 -0
- package/dist/menu-utils.js +47 -0
- package/dist/menu.svelte.d.ts +121 -0
- package/dist/menu.svelte.js +295 -0
- package/dist/metadata-value.d.ts +10 -0
- package/dist/metadata-value.js +173 -0
- package/dist/metadata.svelte.d.ts +106 -0
- package/dist/metadata.svelte.js +608 -0
- package/dist/notifications.d.ts +209 -0
- package/dist/notifications.js +338 -0
- package/dist/open-file.d.ts +23 -0
- package/dist/open-file.js +102 -0
- package/dist/platform.d.ts +86 -0
- package/dist/platform.js +86 -0
- package/dist/plugin-asset-server.d.ts +60 -0
- package/dist/plugin-asset-server.js +222 -0
- package/dist/plugin-assets.d.ts +4 -0
- package/dist/plugin-assets.js +3 -0
- package/dist/plugin-capability-facade.d.ts +104 -0
- package/dist/plugin-capability-facade.js +61 -0
- package/dist/plugin-dependency-resolver.d.ts +36 -0
- package/dist/plugin-dependency-resolver.js +54 -0
- package/dist/plugin-dependency-scanner.d.ts +9 -0
- package/dist/plugin-dependency-scanner.js +274 -0
- package/dist/plugin-distribution/canonical-json.d.ts +1 -0
- package/dist/plugin-distribution/canonical-json.js +40 -0
- package/dist/plugin-distribution/compatibility.d.ts +5 -0
- package/dist/plugin-distribution/compatibility.js +38 -0
- package/dist/plugin-distribution/errors.d.ts +11 -0
- package/dist/plugin-distribution/errors.js +13 -0
- package/dist/plugin-distribution/hashes.d.ts +2 -0
- package/dist/plugin-distribution/hashes.js +17 -0
- package/dist/plugin-distribution/index.d.ts +18 -0
- package/dist/plugin-distribution/index.js +18 -0
- package/dist/plugin-distribution/installed-plugin-state.d.ts +20 -0
- package/dist/plugin-distribution/installed-plugin-state.js +73 -0
- package/dist/plugin-distribution/installer.d.ts +89 -0
- package/dist/plugin-distribution/installer.js +395 -0
- package/dist/plugin-distribution/manager.d.ts +128 -0
- package/dist/plugin-distribution/manager.js +358 -0
- package/dist/plugin-distribution/path-safety.d.ts +2 -0
- package/dist/plugin-distribution/path-safety.js +20 -0
- package/dist/plugin-distribution/plugin-bundle-verifier.d.ts +28 -0
- package/dist/plugin-distribution/plugin-bundle-verifier.js +96 -0
- package/dist/plugin-distribution/plugin-bundle-worker.d.ts +34 -0
- package/dist/plugin-distribution/plugin-bundle-worker.js +99 -0
- package/dist/plugin-distribution/plugin-bundle.d.ts +16 -0
- package/dist/plugin-distribution/plugin-bundle.js +244 -0
- package/dist/plugin-distribution/plugin-bundle.worker.d.ts +1 -0
- package/dist/plugin-distribution/plugin-bundle.worker.js +38 -0
- package/dist/plugin-distribution/registry-cache.d.ts +26 -0
- package/dist/plugin-distribution/registry-cache.js +85 -0
- package/dist/plugin-distribution/registry-client.d.ts +36 -0
- package/dist/plugin-distribution/registry-client.js +115 -0
- package/dist/plugin-distribution/reserved-ids.d.ts +4 -0
- package/dist/plugin-distribution/reserved-ids.js +10 -0
- package/dist/plugin-distribution/runtime-validation.d.ts +14 -0
- package/dist/plugin-distribution/runtime-validation.js +388 -0
- package/dist/plugin-distribution/schemas.d.ts +4895 -0
- package/dist/plugin-distribution/schemas.js +299 -0
- package/dist/plugin-distribution/signing.d.ts +5 -0
- package/dist/plugin-distribution/signing.js +38 -0
- package/dist/plugin-distribution/types.d.ts +217 -0
- package/dist/plugin-distribution/types.js +1 -0
- package/dist/plugin-install-progress.d.ts +15 -0
- package/dist/plugin-install-progress.js +86 -0
- package/dist/plugin-manager.d.ts +306 -0
- package/dist/plugin-manager.js +2848 -0
- package/dist/plugin-runtime-entry.d.ts +19 -0
- package/dist/plugin-runtime-entry.js +135 -0
- package/dist/plugin.d.ts +350 -0
- package/dist/plugin.js +754 -0
- package/dist/popover.d.ts +20 -0
- package/dist/popover.js +32 -0
- package/dist/promise-worker.d.ts +22 -0
- package/dist/promise-worker.js +65 -0
- package/dist/prompt-confirm.d.ts +9 -0
- package/dist/prompt-confirm.js +33 -0
- package/dist/search-document-provider.d.ts +45 -0
- package/dist/search-document-provider.js +54 -0
- package/dist/search-query/index.d.ts +78 -0
- package/dist/search-query/index.js +426 -0
- package/dist/search-query/parser.d.ts +3 -0
- package/dist/search-query/parser.js +16 -0
- package/dist/search-query/parser.terms.js +26 -0
- package/dist/search-query/search-query.grammar +128 -0
- package/dist/search.d.ts +19 -0
- package/dist/search.js +104 -0
- package/dist/setting-section-layout.d.ts +19 -0
- package/dist/setting-section-layout.js +194 -0
- package/dist/settings.svelte.d.ts +474 -0
- package/dist/settings.svelte.js +1421 -0
- package/dist/source-text-file-view.d.ts +25 -0
- package/dist/source-text-file-view.js +78 -0
- package/dist/status-bar.svelte.d.ts +29 -0
- package/dist/status-bar.svelte.js +72 -0
- package/dist/storage/app-database.d.ts +860 -0
- package/dist/storage/app-database.js +2372 -0
- package/dist/storage/blob-store.d.ts +12 -0
- package/dist/storage/blob-store.js +1 -0
- package/dist/storage/browser-app-database-coordination.d.ts +35 -0
- package/dist/storage/browser-app-database-coordination.js +207 -0
- package/dist/storage/browser-coordinated-app-database.d.ts +109 -0
- package/dist/storage/browser-coordinated-app-database.js +704 -0
- package/dist/storage/browser.d.ts +153 -0
- package/dist/storage/browser.js +794 -0
- package/dist/storage/desktop-native.d.ts +184 -0
- package/dist/storage/desktop-native.js +415 -0
- package/dist/storage/fs.d.ts +188 -0
- package/dist/storage/fs.js +307 -0
- package/dist/storage/index-projection.d.ts +236 -0
- package/dist/storage/index-projection.js +402 -0
- package/dist/storage/index.d.ts +17 -0
- package/dist/storage/index.js +17 -0
- package/dist/storage/keyval.d.ts +94 -0
- package/dist/storage/keyval.js +199 -0
- package/dist/storage/memory-vault-adapter.d.ts +44 -0
- package/dist/storage/memory-vault-adapter.js +351 -0
- package/dist/storage/native-vault-bootstrap-kv.d.ts +22 -0
- package/dist/storage/native-vault-bootstrap-kv.js +96 -0
- package/dist/storage/path.d.ts +22 -0
- package/dist/storage/path.js +110 -0
- package/dist/storage/search-embedding-provider.d.ts +75 -0
- package/dist/storage/search-embedding-provider.js +446 -0
- package/dist/storage/search-embedding-worker.d.ts +1 -0
- package/dist/storage/search-embedding-worker.js +63 -0
- package/dist/storage/search-query-evaluator.d.ts +14 -0
- package/dist/storage/search-query-evaluator.js +678 -0
- package/dist/storage/task-projection.d.ts +152 -0
- package/dist/storage/task-projection.js +154 -0
- package/dist/storage/turso-app-database.d.ts +150 -0
- package/dist/storage/turso-app-database.js +2671 -0
- package/dist/storage/vault-session.d.ts +37 -0
- package/dist/storage/vault-session.js +196 -0
- package/dist/storage/vault-state.d.ts +74 -0
- package/dist/storage/vault-state.js +181 -0
- package/dist/storage/vault.svelte.d.ts +257 -0
- package/dist/storage/vault.svelte.js +661 -0
- package/dist/suggest.d.ts +193 -0
- package/dist/suggest.js +391 -0
- package/dist/tasks.d.ts +7 -0
- package/dist/tasks.js +18 -0
- package/dist/telemetry.d.ts +116 -0
- package/dist/telemetry.js +103 -0
- package/dist/utils.d.ts +55 -0
- package/dist/utils.js +314 -0
- package/dist/vault-api.d.ts +5 -0
- package/dist/vault-api.js +3 -0
- package/dist/vault-maintenance-commands.d.ts +5 -0
- package/dist/vault-maintenance-commands.js +32 -0
- package/dist/view.svelte.d.ts +215 -0
- package/dist/view.svelte.js +381 -0
- package/dist/vite-env.d.ts +2 -0
- package/dist/workspace-host-internal.d.ts +7 -0
- package/dist/workspace-host-internal.js +7 -0
- package/dist/workspace-host.d.ts +10 -0
- package/dist/workspace-host.js +14 -0
- package/dist/workspace-layout-commands.d.ts +3 -0
- package/dist/workspace-layout-commands.js +72 -0
- package/dist/workspace-layout-normalizer.d.ts +92 -0
- package/dist/workspace-layout-normalizer.js +301 -0
- package/dist/workspace-layouts.d.ts +7 -0
- package/dist/workspace-layouts.js +23 -0
- package/dist/workspace-trust.d.ts +32 -0
- package/dist/workspace-trust.js +72 -0
- package/dist/workspace.svelte.d.ts +796 -0
- package/dist/workspace.svelte.js +4380 -0
- package/package.json +240 -0
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { DragDropProvider } from "@dnd-kit/svelte";
|
|
3
|
+
import type {
|
|
4
|
+
DragEndEvent,
|
|
5
|
+
DragOverEvent,
|
|
6
|
+
DragStartEvent,
|
|
7
|
+
} from "@dnd-kit/dom";
|
|
8
|
+
import { cn } from "@lapis-notes/ui";
|
|
9
|
+
import { Button } from "@lapismd/design-core/shadcn/button";
|
|
10
|
+
import * as Table from "@lapismd/design-core/shadcn/table";
|
|
11
|
+
import { tableReorderSensors } from "@lapis-notes/ui/table-dnd/sensors";
|
|
12
|
+
import type { ArrayType, ObjectType } from "../../configuration.svelte";
|
|
13
|
+
import type { ObjectMapOption } from "./object-map-setting.svelte";
|
|
14
|
+
import ObjectArrayRow from "./object-array-row.svelte";
|
|
15
|
+
import {
|
|
16
|
+
parseTableDragData,
|
|
17
|
+
resolveTableDragTargetIndex,
|
|
18
|
+
SETTINGS_TABLE_COL_TYPE,
|
|
19
|
+
SETTINGS_TABLE_ROW_TYPE,
|
|
20
|
+
type SettingsTableDragSource,
|
|
21
|
+
} from "./object-array-table-dnd";
|
|
22
|
+
import {
|
|
23
|
+
columnLabel,
|
|
24
|
+
createDefaultRow,
|
|
25
|
+
moveArrayItem,
|
|
26
|
+
sortedObjectProperties,
|
|
27
|
+
} from "./object-array-utils";
|
|
28
|
+
import "./configuration.css";
|
|
29
|
+
|
|
30
|
+
let {
|
|
31
|
+
schema,
|
|
32
|
+
value = $bindable<Record<string, unknown>[]>([]),
|
|
33
|
+
columnOptions = {},
|
|
34
|
+
columnOnQueryChange = {},
|
|
35
|
+
onValueChange,
|
|
36
|
+
}: {
|
|
37
|
+
schema: ArrayType & { items: ObjectType };
|
|
38
|
+
value?: Record<string, unknown>[];
|
|
39
|
+
columnOptions?: Record<string, ObjectMapOption[]>;
|
|
40
|
+
columnOnQueryChange?: Record<string, (query: string) => void>;
|
|
41
|
+
onValueChange?: (value: Record<string, unknown>[]) => void;
|
|
42
|
+
} = $props();
|
|
43
|
+
|
|
44
|
+
const objectSchema = $derived(schema.items);
|
|
45
|
+
const columns = $derived(sortedObjectProperties(objectSchema));
|
|
46
|
+
const minItems = $derived(schema.minItems ?? 0);
|
|
47
|
+
const maxItems = $derived(schema.maxItems);
|
|
48
|
+
const canAddRow = $derived(
|
|
49
|
+
maxItems === undefined ? true : value.length < maxItems,
|
|
50
|
+
);
|
|
51
|
+
const canRemoveRow = $derived(value.length > minItems);
|
|
52
|
+
const canReorderRows = $derived(value.length > 1);
|
|
53
|
+
|
|
54
|
+
let rowKeys = $state<string[]>([]);
|
|
55
|
+
let dragSource = $state<SettingsTableDragSource | null>(null);
|
|
56
|
+
let dragOverIndex = $state<number | null>(null);
|
|
57
|
+
|
|
58
|
+
$effect(() => {
|
|
59
|
+
while (rowKeys.length < value.length) {
|
|
60
|
+
rowKeys.push(crypto.randomUUID());
|
|
61
|
+
}
|
|
62
|
+
while (rowKeys.length > value.length) {
|
|
63
|
+
rowKeys.pop();
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
function emit(next: Record<string, unknown>[]): void {
|
|
68
|
+
value = next;
|
|
69
|
+
onValueChange?.(next);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function updateField(index: number, key: string, fieldValue: unknown): void {
|
|
73
|
+
const next = value.map((row, rowIndex) =>
|
|
74
|
+
rowIndex === index ? { ...row, [key]: fieldValue } : row,
|
|
75
|
+
);
|
|
76
|
+
emit(next);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function addRow(): void {
|
|
80
|
+
if (!canAddRow) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
emit([...value, createDefaultRow(objectSchema, columnOptions)]);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function removeRow(index: number): void {
|
|
87
|
+
if (!canRemoveRow) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
rowKeys.splice(index, 1);
|
|
91
|
+
emit(value.filter((_, rowIndex) => rowIndex !== index));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function moveRow(from: number, to: number): void {
|
|
95
|
+
emit(moveArrayItem(value, from, to));
|
|
96
|
+
rowKeys = moveArrayItem(rowKeys, from, to);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function handleDragOver(event: DragOverEvent): void {
|
|
100
|
+
const target = event.operation.target?.data as
|
|
101
|
+
| { type: string; index: number }
|
|
102
|
+
| undefined;
|
|
103
|
+
if (
|
|
104
|
+
target &&
|
|
105
|
+
dragSource &&
|
|
106
|
+
target.type === dragSource.type &&
|
|
107
|
+
target.index !== dragSource.index
|
|
108
|
+
) {
|
|
109
|
+
dragOverIndex = target.index;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function handleDragStart(event: DragStartEvent): void {
|
|
114
|
+
const data = parseTableDragData(
|
|
115
|
+
event.operation.source,
|
|
116
|
+
SETTINGS_TABLE_ROW_TYPE,
|
|
117
|
+
SETTINGS_TABLE_COL_TYPE,
|
|
118
|
+
);
|
|
119
|
+
if (data?.type === SETTINGS_TABLE_ROW_TYPE) {
|
|
120
|
+
dragSource = { type: data.type, index: data.index };
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function handleDragEnd(event: DragEndEvent): void {
|
|
125
|
+
const source = parseTableDragData(
|
|
126
|
+
event.operation.source,
|
|
127
|
+
SETTINGS_TABLE_ROW_TYPE,
|
|
128
|
+
SETTINGS_TABLE_COL_TYPE,
|
|
129
|
+
);
|
|
130
|
+
const targetIndex = resolveTableDragTargetIndex(
|
|
131
|
+
event,
|
|
132
|
+
dragOverIndex,
|
|
133
|
+
SETTINGS_TABLE_ROW_TYPE,
|
|
134
|
+
SETTINGS_TABLE_COL_TYPE,
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
if (source?.type === SETTINGS_TABLE_ROW_TYPE && targetIndex !== null) {
|
|
138
|
+
moveRow(source.index, targetIndex);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
dragSource = null;
|
|
142
|
+
dragOverIndex = null;
|
|
143
|
+
}
|
|
144
|
+
</script>
|
|
145
|
+
|
|
146
|
+
<DragDropProvider
|
|
147
|
+
sensors={tableReorderSensors}
|
|
148
|
+
onDragStart={handleDragStart}
|
|
149
|
+
onDragOver={handleDragOver}
|
|
150
|
+
onDragEnd={handleDragEnd}
|
|
151
|
+
>
|
|
152
|
+
<div
|
|
153
|
+
class={cn("config-array-table", dragSource && "is-table-chrome-dragging")}
|
|
154
|
+
data-ui-component="configuration"
|
|
155
|
+
data-ui-part="stack"
|
|
156
|
+
data-testid="object-array-setting"
|
|
157
|
+
>
|
|
158
|
+
<Table.Root class="configuration-table">
|
|
159
|
+
<Table.Header>
|
|
160
|
+
<Table.Row>
|
|
161
|
+
{#if canReorderRows}
|
|
162
|
+
<Table.Head class="configuration-grip-head"></Table.Head>
|
|
163
|
+
{/if}
|
|
164
|
+
{#each columns as [key, field] (key)}
|
|
165
|
+
<Table.Head>{columnLabel(key, field)}</Table.Head>
|
|
166
|
+
{/each}
|
|
167
|
+
<Table.Head class="configuration-actions-head">Actions</Table.Head>
|
|
168
|
+
</Table.Row>
|
|
169
|
+
</Table.Header>
|
|
170
|
+
<Table.Body>
|
|
171
|
+
{#each value as row, index (rowKeys[index])}
|
|
172
|
+
<ObjectArrayRow
|
|
173
|
+
{row}
|
|
174
|
+
{index}
|
|
175
|
+
{columns}
|
|
176
|
+
{columnOptions}
|
|
177
|
+
{columnOnQueryChange}
|
|
178
|
+
{dragSource}
|
|
179
|
+
{dragOverIndex}
|
|
180
|
+
showGrip={canReorderRows}
|
|
181
|
+
removeDisabled={!canRemoveRow}
|
|
182
|
+
onFieldChange={(key, fieldValue) => updateField(index, key, fieldValue)}
|
|
183
|
+
onRemove={() => removeRow(index)}
|
|
184
|
+
/>
|
|
185
|
+
{/each}
|
|
186
|
+
</Table.Body>
|
|
187
|
+
</Table.Root>
|
|
188
|
+
<Button
|
|
189
|
+
variant="outline"
|
|
190
|
+
size="sm"
|
|
191
|
+
data-testid="object-array-add-button"
|
|
192
|
+
disabled={!canAddRow}
|
|
193
|
+
onclick={addRow}>Add row</Button
|
|
194
|
+
>
|
|
195
|
+
</div>
|
|
196
|
+
</DragDropProvider>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ArrayType, ObjectType } from "../../configuration.svelte";
|
|
2
|
+
import type { ObjectMapOption } from "./object-map-setting.svelte";
|
|
3
|
+
import "./configuration.css";
|
|
4
|
+
type $$ComponentProps = {
|
|
5
|
+
schema: ArrayType & {
|
|
6
|
+
items: ObjectType;
|
|
7
|
+
};
|
|
8
|
+
value?: Record<string, unknown>[];
|
|
9
|
+
columnOptions?: Record<string, ObjectMapOption[]>;
|
|
10
|
+
columnOnQueryChange?: Record<string, (query: string) => void>;
|
|
11
|
+
onValueChange?: (value: Record<string, unknown>[]) => void;
|
|
12
|
+
};
|
|
13
|
+
declare const ObjectArraySetting: import("svelte").Component<$$ComponentProps, {}, "value">;
|
|
14
|
+
type ObjectArraySetting = ReturnType<typeof ObjectArraySetting>;
|
|
15
|
+
export default ObjectArraySetting;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { parseTableDragData, resolveTableDragTargetIndex, type TableDragData, type TableDragSource } from "@lapis-notes/ui/table-dnd/utils";
|
|
2
|
+
export declare const SETTINGS_TABLE_ROW_TYPE: string;
|
|
3
|
+
export declare const SETTINGS_TABLE_COL_TYPE: string;
|
|
4
|
+
export type SettingsTableDragSource = TableDragSource;
|
|
5
|
+
export type SettingsTableDragData = TableDragData;
|
|
6
|
+
export { parseTableDragData, resolveTableDragTargetIndex };
|
|
7
|
+
export declare function dropIndicatorClasses(dragSource: SettingsTableDragSource | null, dragOverIndex: number | null, rowIndex: number): string;
|
|
8
|
+
export declare function isRowDragSource(dragSource: SettingsTableDragSource | null, rowIndex: number): boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { dropIndicatorClasses as dropIndicatorClassesBase, isRowDragSource as isRowDragSourceBase, parseTableDragData, resolveTableDragTargetIndex, tableColDragType, tableRowDragType, } from "@lapis-notes/ui/table-dnd/utils";
|
|
2
|
+
export const SETTINGS_TABLE_ROW_TYPE = tableRowDragType("settings");
|
|
3
|
+
export const SETTINGS_TABLE_COL_TYPE = tableColDragType("settings");
|
|
4
|
+
export { parseTableDragData, resolveTableDragTargetIndex };
|
|
5
|
+
export function dropIndicatorClasses(dragSource, dragOverIndex, rowIndex) {
|
|
6
|
+
return dropIndicatorClassesBase(dragSource, dragOverIndex, rowIndex, 0, SETTINGS_TABLE_ROW_TYPE, SETTINGS_TABLE_COL_TYPE);
|
|
7
|
+
}
|
|
8
|
+
export function isRowDragSource(dragSource, rowIndex) {
|
|
9
|
+
return isRowDragSourceBase(dragSource, rowIndex, SETTINGS_TABLE_ROW_TYPE);
|
|
10
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ObjectType, SchemaType } from "../../configuration.svelte";
|
|
2
|
+
import type { ObjectMapOption } from "./object-map-types";
|
|
3
|
+
export declare function compareSchemaEntriesByOrder(a: [string, SchemaType], b: [string, SchemaType]): number;
|
|
4
|
+
export declare function sortedObjectProperties(objectSchema: ObjectType): Array<[string, SchemaType]>;
|
|
5
|
+
export declare function columnLabel(key: string, field: SchemaType): string;
|
|
6
|
+
export declare function createDefaultCellValue(fieldSchema: SchemaType, columnOptions?: ObjectMapOption[]): unknown;
|
|
7
|
+
export declare function createDefaultRow(objectSchema: ObjectType, columnOptions?: Record<string, ObjectMapOption[]>): Record<string, unknown>;
|
|
8
|
+
export declare function moveArrayItem<T>(items: T[], from: number, to: number): T[];
|
|
9
|
+
export declare function isOptionsSourceComboboxField(field: SchemaType): boolean;
|
|
10
|
+
export declare function filterComboboxOptions(options: ObjectMapOption[], currentValue: unknown, filterQuery: string, limit?: number): ObjectMapOption[];
|
|
11
|
+
export declare function buildSelectOptionsForValue(baseOptions: ObjectMapOption[], currentValue: unknown, allowUnknownOptions?: boolean): ObjectMapOption[];
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { fuzzySearch } from "@lapis-notes/ui";
|
|
2
|
+
function schemaOrder(schema) {
|
|
3
|
+
return "order" in schema && typeof schema.order === "number"
|
|
4
|
+
? schema.order
|
|
5
|
+
: Number.MAX_SAFE_INTEGER;
|
|
6
|
+
}
|
|
7
|
+
export function compareSchemaEntriesByOrder(a, b) {
|
|
8
|
+
const orderA = schemaOrder(a[1]);
|
|
9
|
+
const orderB = schemaOrder(b[1]);
|
|
10
|
+
if (orderA !== orderB) {
|
|
11
|
+
return orderA - orderB;
|
|
12
|
+
}
|
|
13
|
+
return a[0].localeCompare(b[0]);
|
|
14
|
+
}
|
|
15
|
+
export function sortedObjectProperties(objectSchema) {
|
|
16
|
+
return Object.entries(objectSchema.properties ?? {}).sort(compareSchemaEntriesByOrder);
|
|
17
|
+
}
|
|
18
|
+
export function columnLabel(key, field) {
|
|
19
|
+
return "title" in field && typeof field.title === "string"
|
|
20
|
+
? field.title
|
|
21
|
+
: key;
|
|
22
|
+
}
|
|
23
|
+
export function createDefaultCellValue(fieldSchema, columnOptions) {
|
|
24
|
+
if ("default" in fieldSchema && fieldSchema.default !== undefined) {
|
|
25
|
+
return structuredClone(fieldSchema.default);
|
|
26
|
+
}
|
|
27
|
+
if (fieldSchema.type === "string") {
|
|
28
|
+
if ("enum" in fieldSchema && fieldSchema.enum.length > 0) {
|
|
29
|
+
return fieldSchema.enum[0];
|
|
30
|
+
}
|
|
31
|
+
if (columnOptions && columnOptions.length > 0) {
|
|
32
|
+
return columnOptions[0].value;
|
|
33
|
+
}
|
|
34
|
+
return "";
|
|
35
|
+
}
|
|
36
|
+
if (fieldSchema.type === "boolean") {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
if (fieldSchema.type === "number" || fieldSchema.type === "integer") {
|
|
40
|
+
return 0;
|
|
41
|
+
}
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
export function createDefaultRow(objectSchema, columnOptions = {}) {
|
|
45
|
+
if (objectSchema.default &&
|
|
46
|
+
typeof objectSchema.default === "object" &&
|
|
47
|
+
!Array.isArray(objectSchema.default)) {
|
|
48
|
+
return structuredClone(objectSchema.default);
|
|
49
|
+
}
|
|
50
|
+
const row = {};
|
|
51
|
+
for (const [key, field] of Object.entries(objectSchema.properties ?? {})) {
|
|
52
|
+
row[key] = createDefaultCellValue(field, columnOptions[key]);
|
|
53
|
+
}
|
|
54
|
+
return row;
|
|
55
|
+
}
|
|
56
|
+
export function moveArrayItem(items, from, to) {
|
|
57
|
+
if (from === to ||
|
|
58
|
+
from < 0 ||
|
|
59
|
+
to < 0 ||
|
|
60
|
+
from >= items.length ||
|
|
61
|
+
to >= items.length) {
|
|
62
|
+
return items;
|
|
63
|
+
}
|
|
64
|
+
const next = [...items];
|
|
65
|
+
const [item] = next.splice(from, 1);
|
|
66
|
+
next.splice(to, 0, item);
|
|
67
|
+
return next;
|
|
68
|
+
}
|
|
69
|
+
export function isOptionsSourceComboboxField(field) {
|
|
70
|
+
return (field.type === "string" &&
|
|
71
|
+
"optionsSource" in field &&
|
|
72
|
+
typeof field.optionsSource === "string" &&
|
|
73
|
+
field.optionsSource.length > 0 &&
|
|
74
|
+
field.allowUnknownOptions === true);
|
|
75
|
+
}
|
|
76
|
+
export function filterComboboxOptions(options, currentValue, filterQuery, limit = 50) {
|
|
77
|
+
const merged = buildSelectOptionsForValue(options, currentValue, true);
|
|
78
|
+
const normalizedQuery = filterQuery.trim();
|
|
79
|
+
if (!normalizedQuery) {
|
|
80
|
+
return merged.slice(0, limit);
|
|
81
|
+
}
|
|
82
|
+
return fuzzySearch(merged.map((option) => ({
|
|
83
|
+
...option,
|
|
84
|
+
searchText: `${option.label} ${option.value}`,
|
|
85
|
+
})), normalizedQuery, { keys: ["searchText"] })
|
|
86
|
+
.map((result) => result.item)
|
|
87
|
+
.slice(0, limit);
|
|
88
|
+
}
|
|
89
|
+
export function buildSelectOptionsForValue(baseOptions, currentValue, allowUnknownOptions = false) {
|
|
90
|
+
const optionValues = new Set(baseOptions.map((item) => item.value));
|
|
91
|
+
const value = String(currentValue ?? "");
|
|
92
|
+
if (!value || optionValues.has(value)) {
|
|
93
|
+
return baseOptions;
|
|
94
|
+
}
|
|
95
|
+
return [
|
|
96
|
+
...baseOptions,
|
|
97
|
+
{
|
|
98
|
+
value,
|
|
99
|
+
label: allowUnknownOptions ? `${value} (custom)` : `${value} (missing)`,
|
|
100
|
+
disabled: !allowUnknownOptions,
|
|
101
|
+
},
|
|
102
|
+
];
|
|
103
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Input } from "@lapismd/design-core/shadcn/input";
|
|
3
|
+
import { Switch } from "@lapismd/design-core/shadcn/switch";
|
|
4
|
+
import * as Table from "@lapismd/design-core/shadcn/table";
|
|
5
|
+
import type { ObjectType, SchemaType } from "../../configuration.svelte";
|
|
6
|
+
import "./configuration.css";
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
schema,
|
|
10
|
+
value = $bindable<Record<string, unknown>>({}),
|
|
11
|
+
onValueChange,
|
|
12
|
+
}: {
|
|
13
|
+
schema: ObjectType;
|
|
14
|
+
value?: Record<string, unknown>;
|
|
15
|
+
onValueChange?: (value: Record<string, unknown>) => void;
|
|
16
|
+
} = $props();
|
|
17
|
+
|
|
18
|
+
const entries = $derived(Object.entries(schema.properties));
|
|
19
|
+
|
|
20
|
+
function emit(next: Record<string, unknown>): void {
|
|
21
|
+
value = next;
|
|
22
|
+
onValueChange?.(next);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function updateField(key: string, fieldValue: unknown): void {
|
|
26
|
+
emit({ ...value, [key]: fieldValue });
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function cellLabel(key: string, field: SchemaType): string {
|
|
30
|
+
return field.title ?? key;
|
|
31
|
+
}
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<Table.Root class="configuration-table">
|
|
35
|
+
<Table.Header>
|
|
36
|
+
<Table.Row>
|
|
37
|
+
<Table.Head class="configuration-property-head">Property</Table.Head>
|
|
38
|
+
<Table.Head>Value</Table.Head>
|
|
39
|
+
</Table.Row>
|
|
40
|
+
</Table.Header>
|
|
41
|
+
<Table.Body>
|
|
42
|
+
{#each entries as [key, field] (key)}
|
|
43
|
+
<Table.Row>
|
|
44
|
+
<Table.Cell class="configuration-cell-label"
|
|
45
|
+
>{cellLabel(key, field)}</Table.Cell
|
|
46
|
+
>
|
|
47
|
+
<Table.Cell class="configuration-cell">
|
|
48
|
+
{#if field.type === "boolean"}
|
|
49
|
+
<Switch
|
|
50
|
+
checked={Boolean(value[key])}
|
|
51
|
+
onCheckedChange={(checked) => updateField(key, checked)}
|
|
52
|
+
/>
|
|
53
|
+
{:else if field.type === "number" || field.type === "integer"}
|
|
54
|
+
<Input
|
|
55
|
+
type="number"
|
|
56
|
+
class="configuration-control"
|
|
57
|
+
value={String(value[key] ?? 0)}
|
|
58
|
+
oninput={(event) => {
|
|
59
|
+
const target = event.currentTarget as HTMLInputElement;
|
|
60
|
+
const parsed = Number(target.value);
|
|
61
|
+
updateField(key, Number.isFinite(parsed) ? parsed : 0);
|
|
62
|
+
}}
|
|
63
|
+
/>
|
|
64
|
+
{:else}
|
|
65
|
+
<Input
|
|
66
|
+
type="text"
|
|
67
|
+
class="configuration-control"
|
|
68
|
+
value={String(value[key] ?? "")}
|
|
69
|
+
oninput={(event) => {
|
|
70
|
+
const target = event.currentTarget as HTMLInputElement;
|
|
71
|
+
updateField(key, target.value);
|
|
72
|
+
}}
|
|
73
|
+
/>
|
|
74
|
+
{/if}
|
|
75
|
+
</Table.Cell>
|
|
76
|
+
</Table.Row>
|
|
77
|
+
{/each}
|
|
78
|
+
</Table.Body>
|
|
79
|
+
</Table.Root>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ObjectType } from "../../configuration.svelte";
|
|
2
|
+
import "./configuration.css";
|
|
3
|
+
type $$ComponentProps = {
|
|
4
|
+
schema: ObjectType;
|
|
5
|
+
value?: Record<string, unknown>;
|
|
6
|
+
onValueChange?: (value: Record<string, unknown>) => void;
|
|
7
|
+
};
|
|
8
|
+
declare const ObjectGridSetting: import("svelte").Component<$$ComponentProps, {}, "value">;
|
|
9
|
+
type ObjectGridSetting = ReturnType<typeof ObjectGridSetting>;
|
|
10
|
+
export default ObjectGridSetting;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Trash2 from "@lucide/svelte/icons/trash-2";
|
|
3
|
+
import { Button } from "@lapismd/design-core/shadcn/button";
|
|
4
|
+
import { Input } from "@lapismd/design-core/shadcn/input";
|
|
5
|
+
import * as Table from "@lapismd/design-core/shadcn/table";
|
|
6
|
+
import { Select } from "../select";
|
|
7
|
+
import type { SchemaType } from "../../configuration.svelte";
|
|
8
|
+
import type { ObjectMapOption } from "./object-map-setting.svelte";
|
|
9
|
+
import OptionsComboboxSetting from "./options-combobox-setting.svelte";
|
|
10
|
+
import {
|
|
11
|
+
buildSelectOptionsForValue,
|
|
12
|
+
isOptionsSourceComboboxField,
|
|
13
|
+
} from "./object-array-utils";
|
|
14
|
+
|
|
15
|
+
let {
|
|
16
|
+
pattern,
|
|
17
|
+
entryValue,
|
|
18
|
+
valueSchema,
|
|
19
|
+
selectOptions,
|
|
20
|
+
onValueQueryChange,
|
|
21
|
+
onPatternChange,
|
|
22
|
+
onValueChange,
|
|
23
|
+
onRemove,
|
|
24
|
+
}: {
|
|
25
|
+
pattern: string;
|
|
26
|
+
entryValue: unknown;
|
|
27
|
+
valueSchema: SchemaType;
|
|
28
|
+
selectOptions: ObjectMapOption[];
|
|
29
|
+
onValueQueryChange?: (query: string) => void;
|
|
30
|
+
onPatternChange: (nextPattern: string) => boolean;
|
|
31
|
+
onValueChange: (nextValue: unknown) => void;
|
|
32
|
+
onRemove: () => void;
|
|
33
|
+
} = $props();
|
|
34
|
+
|
|
35
|
+
let draftPattern = $state("");
|
|
36
|
+
|
|
37
|
+
$effect(() => {
|
|
38
|
+
draftPattern = pattern;
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
function commitPattern(): void {
|
|
42
|
+
const trimmed = draftPattern.trim();
|
|
43
|
+
if (!trimmed) {
|
|
44
|
+
draftPattern = pattern;
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (trimmed === pattern) {
|
|
49
|
+
draftPattern = trimmed;
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (!onPatternChange(trimmed)) {
|
|
54
|
+
draftPattern = pattern;
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
draftPattern = trimmed;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function handlePatternKeydown(event: KeyboardEvent): void {
|
|
62
|
+
if (event.key === "Enter") {
|
|
63
|
+
event.currentTarget instanceof HTMLInputElement &&
|
|
64
|
+
event.currentTarget.blur();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
</script>
|
|
68
|
+
|
|
69
|
+
<Table.Row>
|
|
70
|
+
<Table.Cell class="configuration-cell">
|
|
71
|
+
<Input
|
|
72
|
+
type="text"
|
|
73
|
+
class="configuration-control"
|
|
74
|
+
data-testid="object-map-pattern-input"
|
|
75
|
+
bind:value={draftPattern}
|
|
76
|
+
placeholder="*.md"
|
|
77
|
+
onblur={commitPattern}
|
|
78
|
+
onkeydown={handlePatternKeydown}
|
|
79
|
+
/>
|
|
80
|
+
</Table.Cell>
|
|
81
|
+
<Table.Cell class="configuration-cell">
|
|
82
|
+
{#if isOptionsSourceComboboxField(valueSchema)}
|
|
83
|
+
<OptionsComboboxSetting
|
|
84
|
+
value={String(entryValue ?? "")}
|
|
85
|
+
options={selectOptions}
|
|
86
|
+
placeholder="Enter or select"
|
|
87
|
+
onValueChange={(nextValue) => onValueChange(nextValue)}
|
|
88
|
+
onQueryChange={onValueQueryChange}
|
|
89
|
+
/>
|
|
90
|
+
{:else if valueSchema.type === "string" && selectOptions.length > 0}
|
|
91
|
+
<Select
|
|
92
|
+
type="single"
|
|
93
|
+
value={String(entryValue ?? "")}
|
|
94
|
+
items={buildSelectOptionsForValue(
|
|
95
|
+
selectOptions,
|
|
96
|
+
entryValue,
|
|
97
|
+
"allowUnknownOptions" in valueSchema &&
|
|
98
|
+
valueSchema.allowUnknownOptions === true,
|
|
99
|
+
)}
|
|
100
|
+
placeholder="Select editor view"
|
|
101
|
+
onValueChange={(nextValue) => onValueChange(nextValue)}
|
|
102
|
+
/>
|
|
103
|
+
{:else if valueSchema.type === "boolean"}
|
|
104
|
+
<Input
|
|
105
|
+
type="checkbox"
|
|
106
|
+
checked={Boolean(entryValue)}
|
|
107
|
+
onchange={(event) => {
|
|
108
|
+
const target = event.currentTarget as HTMLInputElement;
|
|
109
|
+
onValueChange(target.checked);
|
|
110
|
+
}}
|
|
111
|
+
/>
|
|
112
|
+
{:else if valueSchema.type === "number" || valueSchema.type === "integer"}
|
|
113
|
+
<Input
|
|
114
|
+
type="number"
|
|
115
|
+
class="configuration-control"
|
|
116
|
+
value={String(entryValue ?? 0)}
|
|
117
|
+
oninput={(event) => {
|
|
118
|
+
const target = event.currentTarget as HTMLInputElement;
|
|
119
|
+
const parsed = Number(target.value);
|
|
120
|
+
onValueChange(Number.isFinite(parsed) ? parsed : 0);
|
|
121
|
+
}}
|
|
122
|
+
/>
|
|
123
|
+
{:else}
|
|
124
|
+
<Input
|
|
125
|
+
type="text"
|
|
126
|
+
class="configuration-control"
|
|
127
|
+
value={String(entryValue ?? "")}
|
|
128
|
+
oninput={(event) => {
|
|
129
|
+
const target = event.currentTarget as HTMLInputElement;
|
|
130
|
+
onValueChange(target.value);
|
|
131
|
+
}}
|
|
132
|
+
/>
|
|
133
|
+
{/if}
|
|
134
|
+
</Table.Cell>
|
|
135
|
+
<Table.Cell class="configuration-cell-actions">
|
|
136
|
+
<Button
|
|
137
|
+
variant="ghost"
|
|
138
|
+
size="icon"
|
|
139
|
+
class="configuration-icon-button"
|
|
140
|
+
data-testid="object-map-remove-button"
|
|
141
|
+
aria-label="Remove association"
|
|
142
|
+
onclick={onRemove}
|
|
143
|
+
>
|
|
144
|
+
<Trash2 class="configuration-icon" />
|
|
145
|
+
</Button>
|
|
146
|
+
</Table.Cell>
|
|
147
|
+
</Table.Row>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { SchemaType } from "../../configuration.svelte";
|
|
2
|
+
import type { ObjectMapOption } from "./object-map-setting.svelte";
|
|
3
|
+
type $$ComponentProps = {
|
|
4
|
+
pattern: string;
|
|
5
|
+
entryValue: unknown;
|
|
6
|
+
valueSchema: SchemaType;
|
|
7
|
+
selectOptions: ObjectMapOption[];
|
|
8
|
+
onValueQueryChange?: (query: string) => void;
|
|
9
|
+
onPatternChange: (nextPattern: string) => boolean;
|
|
10
|
+
onValueChange: (nextValue: unknown) => void;
|
|
11
|
+
onRemove: () => void;
|
|
12
|
+
};
|
|
13
|
+
declare const ObjectMapRow: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
14
|
+
type ObjectMapRow = ReturnType<typeof ObjectMapRow>;
|
|
15
|
+
export default ObjectMapRow;
|