@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,139 @@
|
|
|
1
|
+
/* Menu family — context, dropdown, drawer, popover */
|
|
2
|
+
|
|
3
|
+
[data-ui-component="menu"] {
|
|
4
|
+
--ui-menu-item-gap: 0;
|
|
5
|
+
--ui-menu-icon-size: 1.25rem;
|
|
6
|
+
--ui-menu-icon-size-sm: 0.875rem;
|
|
7
|
+
--ui-menu-icon-gap: 0.5rem;
|
|
8
|
+
--ui-menu-sub-width: 12rem;
|
|
9
|
+
--ui-menu-drawer-max-height: 85svh;
|
|
10
|
+
--ui-menu-drawer-pad-x: 0.5rem;
|
|
11
|
+
--ui-menu-drawer-pad-top: 0.75rem;
|
|
12
|
+
--ui-menu-drawer-pad-bottom: calc(env(safe-area-inset-bottom, 0px) + 0.75rem);
|
|
13
|
+
--ui-menu-item-min-height: 2.75rem;
|
|
14
|
+
--ui-menu-item-radius: var(--radius, 0.375rem);
|
|
15
|
+
--ui-menu-popover-min-width: 8rem;
|
|
16
|
+
--ui-menu-popover-max-width: 20rem;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
[data-ui-component="menu"][data-ui-part="item-row"] {
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: center;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
[data-ui-component="menu"][data-ui-part="item-icon"],
|
|
25
|
+
[data-ui-component="menu"] .menu-item-icon {
|
|
26
|
+
width: var(--ui-menu-icon-size);
|
|
27
|
+
height: var(--ui-menu-icon-size);
|
|
28
|
+
margin-inline-end: var(--ui-menu-icon-gap);
|
|
29
|
+
flex-shrink: 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
[data-ui-component="menu"][data-ui-part="item-icon"][data-ui-size="sm"],
|
|
33
|
+
[data-ui-component="menu"] .menu-item-icon-sm {
|
|
34
|
+
width: var(--ui-menu-icon-size-sm);
|
|
35
|
+
height: var(--ui-menu-icon-size-sm);
|
|
36
|
+
margin-inline-end: var(--ui-menu-icon-gap);
|
|
37
|
+
flex-shrink: 0;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
[data-ui-component="menu"][data-ui-part="sub-content"] {
|
|
41
|
+
width: var(--ui-menu-sub-width);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
[data-ui-component="menu"][data-ui-part="drawer-content"] {
|
|
45
|
+
max-height: var(--ui-menu-drawer-max-height);
|
|
46
|
+
gap: 0;
|
|
47
|
+
padding: 0;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
[data-ui-component="menu"][data-ui-part="drawer-body"] {
|
|
51
|
+
overflow-y: auto;
|
|
52
|
+
padding-inline: var(--ui-menu-drawer-pad-x);
|
|
53
|
+
padding-block-start: var(--ui-menu-drawer-pad-top);
|
|
54
|
+
padding-block-end: var(--ui-menu-drawer-pad-bottom);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
[data-ui-component="menu"][data-ui-part="drawer-section"] {
|
|
58
|
+
padding-block: 0.25rem;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
[data-ui-component="menu"][data-ui-part="drawer-separator"] {
|
|
62
|
+
margin-block: 0.25rem;
|
|
63
|
+
border-top: 1px solid var(--border);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
[data-ui-component="menu"][data-ui-part="drawer-heading"] {
|
|
67
|
+
color: var(--muted-foreground);
|
|
68
|
+
padding-inline: 0.75rem 0.75rem;
|
|
69
|
+
padding-inline-start: 2.75rem;
|
|
70
|
+
padding-block: 0.75rem 0.25rem;
|
|
71
|
+
font-size: 0.75rem;
|
|
72
|
+
font-weight: 500;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
[data-ui-component="menu"][data-ui-part="drawer-item"] {
|
|
76
|
+
display: flex;
|
|
77
|
+
align-items: center;
|
|
78
|
+
gap: 0.75rem;
|
|
79
|
+
width: 100%;
|
|
80
|
+
min-height: var(--ui-menu-item-min-height);
|
|
81
|
+
padding: 0.5rem 0.75rem;
|
|
82
|
+
border-radius: var(--ui-menu-item-radius);
|
|
83
|
+
text-align: left;
|
|
84
|
+
font-size: 0.875rem;
|
|
85
|
+
outline: none;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
[data-ui-component="menu"][data-ui-part="drawer-item"]:hover {
|
|
89
|
+
background: var(--accent);
|
|
90
|
+
color: var(--accent-foreground);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
[data-ui-component="menu"][data-ui-part="drawer-item"]:focus-visible {
|
|
94
|
+
box-shadow: 0 0 0 2px var(--ring);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
[data-ui-component="menu"][data-ui-part="drawer-item"]:disabled {
|
|
98
|
+
pointer-events: none;
|
|
99
|
+
opacity: 0.5;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
[data-ui-component="menu"][data-ui-part="drawer-item-icon"],
|
|
103
|
+
[data-ui-component="menu"] .menu-drawer-icon {
|
|
104
|
+
width: var(--ui-menu-icon-size);
|
|
105
|
+
height: var(--ui-menu-icon-size);
|
|
106
|
+
flex-shrink: 0;
|
|
107
|
+
color: var(--muted-foreground);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
[data-ui-component="menu"][data-ui-part="drawer-item-label"] {
|
|
111
|
+
min-width: 0;
|
|
112
|
+
flex: 1 1 0%;
|
|
113
|
+
overflow: hidden;
|
|
114
|
+
text-overflow: ellipsis;
|
|
115
|
+
white-space: nowrap;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
[data-ui-component="menu"][data-ui-part="popover-content"] {
|
|
119
|
+
z-index: 50;
|
|
120
|
+
min-width: var(--ui-menu-popover-min-width);
|
|
121
|
+
max-width: var(--ui-menu-popover-max-width);
|
|
122
|
+
padding: 0.25rem;
|
|
123
|
+
border: 1px solid var(--border);
|
|
124
|
+
border-radius: var(--ui-menu-item-radius);
|
|
125
|
+
background: var(--popover);
|
|
126
|
+
color: var(--popover-foreground);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
[data-ui-component="menu"][data-ui-part="popover-content"]:focus {
|
|
130
|
+
outline: none;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
[data-ui-component="menu"][data-ui-part="command-icon"],
|
|
134
|
+
[data-ui-component="menu"] .menu-command-icon {
|
|
135
|
+
width: var(--ui-menu-icon-size);
|
|
136
|
+
height: var(--ui-menu-icon-size);
|
|
137
|
+
margin-inline-end: var(--ui-menu-icon-gap);
|
|
138
|
+
flex-shrink: 0;
|
|
139
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { type Menu as AppMenu } from "../../menu.svelte";
|
|
3
|
+
import ContextMenuContent from "./context-menu.svelte";
|
|
4
|
+
import DropdownMenuContent from "./dropdown-menu.svelte";
|
|
5
|
+
import PopoverMenu from "./popover-menu.svelte";
|
|
6
|
+
import * as Dropdown from "@lapismd/design-core/shadcn/dropdown-menu";
|
|
7
|
+
import * as ContextMenu from "@lapismd/design-core/shadcn/context-menu";
|
|
8
|
+
import type { WithChildren } from "bits-ui";
|
|
9
|
+
import "./menu.css";
|
|
10
|
+
|
|
11
|
+
let {
|
|
12
|
+
menu,
|
|
13
|
+
anchor = null,
|
|
14
|
+
type = "popover",
|
|
15
|
+
class: className,
|
|
16
|
+
children,
|
|
17
|
+
}: WithChildren<{
|
|
18
|
+
menu: AppMenu;
|
|
19
|
+
class?: string;
|
|
20
|
+
type?: "popover" | "dropdown-menu" | "context-menu";
|
|
21
|
+
anchor?: HTMLElement | null;
|
|
22
|
+
}> = $props();
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
{#if type === "popover"}
|
|
26
|
+
<PopoverMenu {menu} {anchor} class={className} />
|
|
27
|
+
{:else if type === "dropdown-menu"}
|
|
28
|
+
<Dropdown.Root bind:open={() => menu.open, (value) => menu.setOpen(value)}>
|
|
29
|
+
{@render children?.()}
|
|
30
|
+
<DropdownMenuContent {menu} {anchor} class={className} />
|
|
31
|
+
</Dropdown.Root>
|
|
32
|
+
{:else if type === "context-menu"}
|
|
33
|
+
<ContextMenu.Root bind:open={() => menu.open, (value) => menu.setOpen(value)}>
|
|
34
|
+
{@render children?.()}
|
|
35
|
+
<ContextMenuContent {menu} {anchor} class={className} />
|
|
36
|
+
</ContextMenu.Root>
|
|
37
|
+
{/if}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Menu as AppMenu } from "../../menu.svelte";
|
|
2
|
+
import type { WithChildren } from "bits-ui";
|
|
3
|
+
import "./menu.css";
|
|
4
|
+
declare const Menu: import("svelte").Component<WithChildren<{
|
|
5
|
+
menu: AppMenu;
|
|
6
|
+
class?: string;
|
|
7
|
+
type?: "popover" | "dropdown-menu" | "context-menu";
|
|
8
|
+
anchor?: HTMLElement | null;
|
|
9
|
+
}>, {}, "">;
|
|
10
|
+
type Menu = ReturnType<typeof Menu>;
|
|
11
|
+
export default Menu;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { onMount } from "svelte";
|
|
2
|
+
export function createMobileMenuQuery() {
|
|
3
|
+
let matches = $state(globalThis.matchMedia?.("(max-width: 767px)").matches ?? false);
|
|
4
|
+
onMount(() => {
|
|
5
|
+
if (!globalThis.matchMedia) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
const media = globalThis.matchMedia("(max-width: 767px)");
|
|
9
|
+
const update = () => {
|
|
10
|
+
matches = media.matches;
|
|
11
|
+
};
|
|
12
|
+
update();
|
|
13
|
+
media.addEventListener("change", update);
|
|
14
|
+
return () => media.removeEventListener("change", update);
|
|
15
|
+
});
|
|
16
|
+
return {
|
|
17
|
+
get matches() {
|
|
18
|
+
return matches;
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import * as Popover from "@lapismd/design-core/shadcn/popover";
|
|
3
|
+
import * as Command from "@lapismd/design-core/shadcn/command";
|
|
4
|
+
import { cn } from "../../utils";
|
|
5
|
+
import Icon from "../icon/icon.svelte";
|
|
6
|
+
import DrawerMenu from "./drawer-menu.svelte";
|
|
7
|
+
import { createMobileMenuQuery } from "./mobile-menu-query.svelte";
|
|
8
|
+
import {
|
|
9
|
+
isMenuItem,
|
|
10
|
+
type Menu as AppMenu,
|
|
11
|
+
type MenuItem,
|
|
12
|
+
} from "../../menu.svelte";
|
|
13
|
+
import "./menu.css";
|
|
14
|
+
|
|
15
|
+
let {
|
|
16
|
+
menu,
|
|
17
|
+
anchor = null,
|
|
18
|
+
class: className,
|
|
19
|
+
}: {
|
|
20
|
+
menu: AppMenu;
|
|
21
|
+
class?: string;
|
|
22
|
+
anchor?: HTMLElement | null;
|
|
23
|
+
} = $props();
|
|
24
|
+
|
|
25
|
+
const mobileMenu = createMobileMenuQuery();
|
|
26
|
+
const hasItems = $derived(
|
|
27
|
+
Object.keys(menu.filter ? menu.filteredItems : menu.renderedItems).length >
|
|
28
|
+
0,
|
|
29
|
+
);
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
{#if hasItems}
|
|
33
|
+
{#if mobileMenu.matches}
|
|
34
|
+
<DrawerMenu {menu} />
|
|
35
|
+
{:else}
|
|
36
|
+
<Popover.Root bind:open={() => menu.open, (value) => menu.setOpen(value)}>
|
|
37
|
+
<Popover.Content
|
|
38
|
+
onInteractOutside={(evt) => {
|
|
39
|
+
if (evt.target !== anchor) {
|
|
40
|
+
menu.setOpen(false);
|
|
41
|
+
}
|
|
42
|
+
}}
|
|
43
|
+
trapFocus={false}
|
|
44
|
+
interactOutsideBehavior="defer-otherwise-close"
|
|
45
|
+
customAnchor={anchor}
|
|
46
|
+
data-ui-component="menu"
|
|
47
|
+
data-ui-part="popover-content"
|
|
48
|
+
class={cn(className)}
|
|
49
|
+
>
|
|
50
|
+
<Command.Root shouldFilter={false}>
|
|
51
|
+
<Command.List>
|
|
52
|
+
<Command.Group heading={menu.title}>
|
|
53
|
+
{@render CommandContent({ menu })}
|
|
54
|
+
</Command.Group>
|
|
55
|
+
</Command.List>
|
|
56
|
+
</Command.Root>
|
|
57
|
+
</Popover.Content>
|
|
58
|
+
</Popover.Root>
|
|
59
|
+
{/if}
|
|
60
|
+
{/if}
|
|
61
|
+
|
|
62
|
+
{#snippet CommandContent({ menu }: { menu: AppMenu })}
|
|
63
|
+
{#each Object.entries(menu?.filteredItems ?? {}) as [id, items]}
|
|
64
|
+
{#each items as item}
|
|
65
|
+
<Command.Group>
|
|
66
|
+
{#if item === "separator"}
|
|
67
|
+
<Command.Separator />
|
|
68
|
+
{:else if isMenuItem(item)}
|
|
69
|
+
{@render CommandItem({ item })}
|
|
70
|
+
{:else}
|
|
71
|
+
<Command.Group heading={item.title}>
|
|
72
|
+
{@render CommandContent({ menu: item })}
|
|
73
|
+
</Command.Group>
|
|
74
|
+
{/if}
|
|
75
|
+
</Command.Group>
|
|
76
|
+
{/each}
|
|
77
|
+
{/each}
|
|
78
|
+
{/snippet}
|
|
79
|
+
|
|
80
|
+
{#snippet CommandItem({ item }: { item: MenuItem })}
|
|
81
|
+
<Command.Item
|
|
82
|
+
onclick={(evt: MouseEvent) => item.click(evt)}
|
|
83
|
+
value={typeof item.title === "string" ? item.title : ""}
|
|
84
|
+
>
|
|
85
|
+
{#if item.icon}
|
|
86
|
+
<Icon class="menu-command-icon" name={item.icon} />
|
|
87
|
+
{/if}
|
|
88
|
+
{item.title}
|
|
89
|
+
</Command.Item>
|
|
90
|
+
{/snippet}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Menu as AppMenu } from "../../menu.svelte";
|
|
2
|
+
import "./menu.css";
|
|
3
|
+
type $$ComponentProps = {
|
|
4
|
+
menu: AppMenu;
|
|
5
|
+
class?: string;
|
|
6
|
+
anchor?: HTMLElement | null;
|
|
7
|
+
};
|
|
8
|
+
declare const PopoverMenu: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
9
|
+
type PopoverMenu = ReturnType<typeof PopoverMenu>;
|
|
10
|
+
export default PopoverMenu;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import * as SelectPrimitive from "@lapismd/design-core/shadcn/select";
|
|
3
|
+
import { type SelectRootProps } from "bits-ui";
|
|
4
|
+
const SelectRoot: any = SelectPrimitive.Root;
|
|
5
|
+
|
|
6
|
+
export type SelectItem = {
|
|
7
|
+
value: string;
|
|
8
|
+
label: string;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
type SharedSelectProps = {
|
|
13
|
+
items?: SelectItem[];
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
ref?: HTMLElement | null;
|
|
16
|
+
} & Omit<SelectRootProps, "items" | "type" | "value" | "onValueChange">;
|
|
17
|
+
|
|
18
|
+
export type SingleSelectProps = SharedSelectProps & {
|
|
19
|
+
type?: "single";
|
|
20
|
+
value?: string;
|
|
21
|
+
onValueChange?: (value: string) => void;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type MultipleSelectProps = SharedSelectProps & {
|
|
25
|
+
type: "multiple";
|
|
26
|
+
value?: string[];
|
|
27
|
+
onValueChange?: (value: string[]) => void;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type SelectProps = SingleSelectProps | MultipleSelectProps;
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<script lang="ts">
|
|
34
|
+
let {
|
|
35
|
+
items = [],
|
|
36
|
+
type = "single",
|
|
37
|
+
value = $bindable(),
|
|
38
|
+
ref = $bindable(null),
|
|
39
|
+
placeholder = "Select...",
|
|
40
|
+
...rest
|
|
41
|
+
}: SelectProps = $props();
|
|
42
|
+
|
|
43
|
+
const triggerContent = $derived.by(() => {
|
|
44
|
+
if (Array.isArray(value)) {
|
|
45
|
+
const selectedValues = value;
|
|
46
|
+
const selected = items
|
|
47
|
+
.filter((item) => selectedValues.includes(item.value))
|
|
48
|
+
.map((item) => item.label);
|
|
49
|
+
return selected.length ? selected.join(", ") : placeholder;
|
|
50
|
+
}
|
|
51
|
+
return items.find((item) => item.value === value)?.label ?? placeholder;
|
|
52
|
+
});
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<div bind:this={ref}>
|
|
56
|
+
<SelectRoot {...rest} {type} bind:value>
|
|
57
|
+
<SelectPrimitive.Trigger>
|
|
58
|
+
{triggerContent}
|
|
59
|
+
</SelectPrimitive.Trigger>
|
|
60
|
+
<SelectPrimitive.Content>
|
|
61
|
+
<SelectPrimitive.Group>
|
|
62
|
+
{#each items as item (item.value)}
|
|
63
|
+
<SelectPrimitive.Item
|
|
64
|
+
value={item.value}
|
|
65
|
+
label={item.label}
|
|
66
|
+
disabled={item.disabled}
|
|
67
|
+
/>
|
|
68
|
+
{/each}
|
|
69
|
+
</SelectPrimitive.Group>
|
|
70
|
+
</SelectPrimitive.Content>
|
|
71
|
+
</SelectRoot>
|
|
72
|
+
</div>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type SelectRootProps } from "bits-ui";
|
|
2
|
+
export type SelectItem = {
|
|
3
|
+
value: string;
|
|
4
|
+
label: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
};
|
|
7
|
+
type SharedSelectProps = {
|
|
8
|
+
items?: SelectItem[];
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
ref?: HTMLElement | null;
|
|
11
|
+
} & Omit<SelectRootProps, "items" | "type" | "value" | "onValueChange">;
|
|
12
|
+
export type SingleSelectProps = SharedSelectProps & {
|
|
13
|
+
type?: "single";
|
|
14
|
+
value?: string;
|
|
15
|
+
onValueChange?: (value: string) => void;
|
|
16
|
+
};
|
|
17
|
+
export type MultipleSelectProps = SharedSelectProps & {
|
|
18
|
+
type: "multiple";
|
|
19
|
+
value?: string[];
|
|
20
|
+
onValueChange?: (value: string[]) => void;
|
|
21
|
+
};
|
|
22
|
+
export type SelectProps = SingleSelectProps | MultipleSelectProps;
|
|
23
|
+
declare const Select: import("svelte").Component<SelectProps, {}, "ref" | "value">;
|
|
24
|
+
type Select = ReturnType<typeof Select>;
|
|
25
|
+
export default Select;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { StringType, EnumType } from "./configuration.svelte";
|
|
2
|
+
export declare function normalizeMetadataFieldOptionValues(values: readonly unknown[]): string[];
|
|
3
|
+
export declare function filterOptionsByQuery(options: readonly {
|
|
4
|
+
value: string;
|
|
5
|
+
label?: string;
|
|
6
|
+
}[], query: string, limit?: number): Array<{
|
|
7
|
+
value: string;
|
|
8
|
+
label: string;
|
|
9
|
+
}>;
|
|
10
|
+
export declare function resolveMetadataFieldValues(getValues: (field: string) => readonly unknown[], schema: StringType | EnumType, query?: string, limit?: number): Array<{
|
|
11
|
+
value: string;
|
|
12
|
+
label: string;
|
|
13
|
+
}>;
|
|
14
|
+
export declare function resolveMetadataFieldValuesAsync(getValues: (field: string) => Promise<readonly unknown[]>, schema: StringType | EnumType, query?: string, limit?: number): Promise<Array<{
|
|
15
|
+
value: string;
|
|
16
|
+
label: string;
|
|
17
|
+
}>>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export function normalizeMetadataFieldOptionValues(values) {
|
|
2
|
+
const normalized = new Set();
|
|
3
|
+
for (const value of values) {
|
|
4
|
+
if (typeof value === "string") {
|
|
5
|
+
const trimmed = value.trim();
|
|
6
|
+
if (trimmed) {
|
|
7
|
+
normalized.add(trimmed);
|
|
8
|
+
}
|
|
9
|
+
continue;
|
|
10
|
+
}
|
|
11
|
+
if (Array.isArray(value)) {
|
|
12
|
+
for (const entry of value) {
|
|
13
|
+
if (typeof entry === "string") {
|
|
14
|
+
const trimmed = entry.trim();
|
|
15
|
+
if (trimmed) {
|
|
16
|
+
normalized.add(trimmed);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
if (value != null) {
|
|
23
|
+
const trimmed = String(value).trim();
|
|
24
|
+
if (trimmed) {
|
|
25
|
+
normalized.add(trimmed);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return [...normalized].sort((a, b) => a.localeCompare(b));
|
|
30
|
+
}
|
|
31
|
+
export function filterOptionsByQuery(options, query, limit = 50) {
|
|
32
|
+
const normalizedQuery = query.trim().toLowerCase();
|
|
33
|
+
const filtered = normalizedQuery
|
|
34
|
+
? options.filter((option) => {
|
|
35
|
+
const haystack = `${option.label ?? option.value} ${option.value}`.toLowerCase();
|
|
36
|
+
return haystack.includes(normalizedQuery);
|
|
37
|
+
})
|
|
38
|
+
: options;
|
|
39
|
+
return filtered.slice(0, limit).map((option) => ({
|
|
40
|
+
value: option.value,
|
|
41
|
+
label: option.label ?? option.value,
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
export function resolveMetadataFieldValues(getValues, schema, query = "", limit = 50) {
|
|
45
|
+
const field = schema.optionsSourceParams?.field;
|
|
46
|
+
if (typeof field !== "string" || !field.trim()) {
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
const values = normalizeMetadataFieldOptionValues(getValues(field.trim()));
|
|
50
|
+
const options = values.map((value) => ({ value, label: value }));
|
|
51
|
+
return filterOptionsByQuery(options, query, limit);
|
|
52
|
+
}
|
|
53
|
+
export async function resolveMetadataFieldValuesAsync(getValues, schema, query = "", limit = 50) {
|
|
54
|
+
const field = schema.optionsSourceParams?.field;
|
|
55
|
+
if (typeof field !== "string" || !field.trim())
|
|
56
|
+
return [];
|
|
57
|
+
const values = normalizeMetadataFieldOptionValues(await getValues(field.trim()));
|
|
58
|
+
return filterOptionsByQuery(values.map((value) => ({ value, label: value })), query, limit);
|
|
59
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { App } from "./context.svelte";
|
|
2
|
+
import type { EnumType, StringType } from "./configuration.svelte";
|
|
3
|
+
import { EventDispatcher } from "./events";
|
|
4
|
+
export type ConfigurationOption = {
|
|
5
|
+
value: string;
|
|
6
|
+
label?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
markdownDescription?: string;
|
|
9
|
+
detail?: string;
|
|
10
|
+
icon?: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
source?: string;
|
|
13
|
+
};
|
|
14
|
+
export type ConfigurationOptionSourceContext = {
|
|
15
|
+
app: App;
|
|
16
|
+
sourceId: string;
|
|
17
|
+
schema: StringType | EnumType;
|
|
18
|
+
configId?: string;
|
|
19
|
+
categoryId?: string;
|
|
20
|
+
settingTitle?: string;
|
|
21
|
+
currentValue?: unknown;
|
|
22
|
+
query?: string;
|
|
23
|
+
limit?: number;
|
|
24
|
+
signal?: AbortSignal;
|
|
25
|
+
};
|
|
26
|
+
export type MaybePromise<T> = T | Promise<T>;
|
|
27
|
+
export type ConfigurationOptionSourceProvider = {
|
|
28
|
+
label?: string;
|
|
29
|
+
description?: string;
|
|
30
|
+
pluginId?: string;
|
|
31
|
+
cache?: "none" | "session";
|
|
32
|
+
getOptions(context: ConfigurationOptionSourceContext): MaybePromise<readonly ConfigurationOption[]>;
|
|
33
|
+
};
|
|
34
|
+
export type ConfigurationOptionSourceChangeReason = "registered" | "unregistered" | "invalidated";
|
|
35
|
+
export type ConfigurationOptionSourceChange = {
|
|
36
|
+
sourceId: string;
|
|
37
|
+
reason: ConfigurationOptionSourceChangeReason;
|
|
38
|
+
};
|
|
39
|
+
export type ConfigurationOptionSourceRegistration = {
|
|
40
|
+
readonly id: string;
|
|
41
|
+
invalidate(): void;
|
|
42
|
+
dispose(): void;
|
|
43
|
+
};
|
|
44
|
+
export declare function normalizeOptionSourceId(id: string): string;
|
|
45
|
+
export declare function validateOptionSourceId(id: string): void;
|
|
46
|
+
export declare function normalizeConfigurationOptions(options: readonly ConfigurationOption[], sourceId: string): ConfigurationOption[];
|
|
47
|
+
export declare class ConfigurationOptionSourceRegistry extends EventDispatcher<{
|
|
48
|
+
changed: [change: ConfigurationOptionSourceChange];
|
|
49
|
+
}> {
|
|
50
|
+
private readonly sources;
|
|
51
|
+
private readonly sessionCache;
|
|
52
|
+
private sessionCachePrefix;
|
|
53
|
+
private clearSessionCache;
|
|
54
|
+
private sessionCacheKey;
|
|
55
|
+
register(id: string, provider: ConfigurationOptionSourceProvider): ConfigurationOptionSourceRegistration;
|
|
56
|
+
has(id: string): boolean;
|
|
57
|
+
resolve(id: string, context: Omit<ConfigurationOptionSourceContext, "sourceId">): Promise<ConfigurationOption[]>;
|
|
58
|
+
getRegisteredSourceIds(): string[];
|
|
59
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { EventDispatcher } from "./events";
|
|
2
|
+
import { logging } from "./logging";
|
|
3
|
+
const SOURCE_ID_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._:-]*$/;
|
|
4
|
+
const logger = logging.getLogger("configuration-option-sources");
|
|
5
|
+
export function normalizeOptionSourceId(id) {
|
|
6
|
+
return id.trim();
|
|
7
|
+
}
|
|
8
|
+
export function validateOptionSourceId(id) {
|
|
9
|
+
const normalized = normalizeOptionSourceId(id);
|
|
10
|
+
if (!normalized) {
|
|
11
|
+
throw new Error("Configuration option source id must not be empty.");
|
|
12
|
+
}
|
|
13
|
+
if (!SOURCE_ID_PATTERN.test(normalized)) {
|
|
14
|
+
throw new Error(`Invalid configuration option source id: ${id}. Expected pattern ${SOURCE_ID_PATTERN.source}.`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export function normalizeConfigurationOptions(options, sourceId) {
|
|
18
|
+
const seen = new Set();
|
|
19
|
+
const normalized = [];
|
|
20
|
+
for (const option of options) {
|
|
21
|
+
const value = String(option.value ?? "").trim();
|
|
22
|
+
if (!value || seen.has(value)) {
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
seen.add(value);
|
|
26
|
+
normalized.push({
|
|
27
|
+
...option,
|
|
28
|
+
value,
|
|
29
|
+
label: option.label?.trim() || value,
|
|
30
|
+
source: option.source ?? sourceId,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return normalized;
|
|
34
|
+
}
|
|
35
|
+
export class ConfigurationOptionSourceRegistry extends EventDispatcher {
|
|
36
|
+
sources = new Map();
|
|
37
|
+
sessionCache = new Map();
|
|
38
|
+
sessionCachePrefix(sourceId) {
|
|
39
|
+
return `${sourceId}:`;
|
|
40
|
+
}
|
|
41
|
+
clearSessionCache(sourceId) {
|
|
42
|
+
const prefix = this.sessionCachePrefix(sourceId);
|
|
43
|
+
for (const key of [...this.sessionCache.keys()]) {
|
|
44
|
+
if (key.startsWith(prefix)) {
|
|
45
|
+
this.sessionCache.delete(key);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
sessionCacheKey(sourceId, context) {
|
|
50
|
+
const params = "optionsSourceParams" in context.schema
|
|
51
|
+
? context.schema.optionsSourceParams
|
|
52
|
+
: undefined;
|
|
53
|
+
const query = context.query?.trim() ?? "";
|
|
54
|
+
const limit = context.limit ?? 50;
|
|
55
|
+
return `${sourceId}:${JSON.stringify(params ?? null)}:${query}:${limit}`;
|
|
56
|
+
}
|
|
57
|
+
register(id, provider) {
|
|
58
|
+
validateOptionSourceId(id);
|
|
59
|
+
const sourceId = normalizeOptionSourceId(id);
|
|
60
|
+
if (this.sources.has(sourceId)) {
|
|
61
|
+
throw new Error(`Configuration option source already registered: ${sourceId}`);
|
|
62
|
+
}
|
|
63
|
+
this.sources.set(sourceId, provider);
|
|
64
|
+
this.emit("changed", { sourceId, reason: "registered" });
|
|
65
|
+
let disposed = false;
|
|
66
|
+
return {
|
|
67
|
+
id: sourceId,
|
|
68
|
+
invalidate: () => {
|
|
69
|
+
if (!disposed && this.sources.get(sourceId) === provider) {
|
|
70
|
+
this.clearSessionCache(sourceId);
|
|
71
|
+
this.emit("changed", { sourceId, reason: "invalidated" });
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
dispose: () => {
|
|
75
|
+
if (disposed) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
disposed = true;
|
|
79
|
+
if (this.sources.get(sourceId) === provider) {
|
|
80
|
+
this.clearSessionCache(sourceId);
|
|
81
|
+
this.sources.delete(sourceId);
|
|
82
|
+
this.emit("changed", { sourceId, reason: "unregistered" });
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
has(id) {
|
|
88
|
+
return this.sources.has(normalizeOptionSourceId(id));
|
|
89
|
+
}
|
|
90
|
+
async resolve(id, context) {
|
|
91
|
+
const sourceId = normalizeOptionSourceId(id);
|
|
92
|
+
const provider = this.sources.get(sourceId);
|
|
93
|
+
if (!provider) {
|
|
94
|
+
return [];
|
|
95
|
+
}
|
|
96
|
+
const useSessionCache = provider.cache === "session";
|
|
97
|
+
if (useSessionCache) {
|
|
98
|
+
const cached = this.sessionCache.get(this.sessionCacheKey(sourceId, context));
|
|
99
|
+
if (cached) {
|
|
100
|
+
return normalizeConfigurationOptions(cached, sourceId);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
try {
|
|
104
|
+
const options = await provider.getOptions({
|
|
105
|
+
...context,
|
|
106
|
+
sourceId,
|
|
107
|
+
limit: context.limit ?? 50,
|
|
108
|
+
});
|
|
109
|
+
const normalized = normalizeConfigurationOptions(options, sourceId);
|
|
110
|
+
if (useSessionCache) {
|
|
111
|
+
this.sessionCache.set(this.sessionCacheKey(sourceId, context), normalized);
|
|
112
|
+
}
|
|
113
|
+
return normalized;
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
logger.warn(`Configuration option source ${sourceId} failed to resolve options.`, error);
|
|
117
|
+
return [];
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
getRegisteredSourceIds() {
|
|
121
|
+
return [...this.sources.keys()].sort();
|
|
122
|
+
}
|
|
123
|
+
}
|