@embedpdf/plugin-ui 2.0.0-next.0 → 2.0.0-next.2

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.
Files changed (56) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +235 -146
  4. package/dist/index.js.map +1 -1
  5. package/dist/lib/actions.d.ts +31 -15
  6. package/dist/lib/schema.d.ts +51 -10
  7. package/dist/lib/selectors.d.ts +5 -5
  8. package/dist/lib/types.d.ts +39 -23
  9. package/dist/lib/ui-plugin.d.ts +11 -8
  10. package/dist/lib/utils/consts.d.ts +3 -0
  11. package/dist/lib/utils/schema-merger.d.ts +1 -1
  12. package/dist/lib/utils/stylesheet-generator.d.ts +17 -0
  13. package/dist/preact/adapter.d.ts +1 -1
  14. package/dist/preact/index.cjs +1 -1
  15. package/dist/preact/index.cjs.map +1 -1
  16. package/dist/preact/index.js +143 -38
  17. package/dist/preact/index.js.map +1 -1
  18. package/dist/react/adapter.d.ts +1 -1
  19. package/dist/react/index.cjs +1 -1
  20. package/dist/react/index.cjs.map +1 -1
  21. package/dist/react/index.js +143 -38
  22. package/dist/react/index.js.map +1 -1
  23. package/dist/shared/hooks/index.d.ts +1 -0
  24. package/dist/shared/hooks/use-schema-renderer.d.ts +41 -9
  25. package/dist/shared/hooks/use-ui-container.d.ts +39 -0
  26. package/dist/shared/root.d.ts +1 -1
  27. package/dist/shared/types.d.ts +31 -6
  28. package/dist/shared-preact/hooks/index.d.ts +1 -0
  29. package/dist/shared-preact/hooks/use-schema-renderer.d.ts +41 -9
  30. package/dist/shared-preact/hooks/use-ui-container.d.ts +39 -0
  31. package/dist/shared-preact/root.d.ts +1 -1
  32. package/dist/shared-preact/types.d.ts +31 -6
  33. package/dist/shared-react/hooks/index.d.ts +1 -0
  34. package/dist/shared-react/hooks/use-schema-renderer.d.ts +41 -9
  35. package/dist/shared-react/hooks/use-ui-container.d.ts +39 -0
  36. package/dist/shared-react/root.d.ts +1 -1
  37. package/dist/shared-react/types.d.ts +31 -6
  38. package/dist/svelte/hooks/index.d.ts +1 -0
  39. package/dist/svelte/hooks/use-schema-renderer.svelte.d.ts +55 -12
  40. package/dist/svelte/hooks/use-ui-container.svelte.d.ts +41 -0
  41. package/dist/svelte/hooks/use-ui.svelte.d.ts +2 -2
  42. package/dist/svelte/index.cjs +1 -1
  43. package/dist/svelte/index.cjs.map +1 -1
  44. package/dist/svelte/index.js +112 -20
  45. package/dist/svelte/index.js.map +1 -1
  46. package/dist/svelte/types.d.ts +31 -6
  47. package/dist/vue/hooks/index.d.ts +1 -0
  48. package/dist/vue/hooks/use-schema-renderer.d.ts +41 -9
  49. package/dist/vue/hooks/use-ui-container.d.ts +39 -0
  50. package/dist/vue/hooks/use-ui.d.ts +148 -20
  51. package/dist/vue/index.cjs +1 -1
  52. package/dist/vue/index.cjs.map +1 -1
  53. package/dist/vue/index.js +126 -25
  54. package/dist/vue/index.js.map +1 -1
  55. package/dist/vue/types.d.ts +31 -6
  56. package/package.json +12 -12
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/svelte/hooks/use-ui.svelte.ts","../../src/svelte/registries/anchor-registry.svelte.ts","../../src/svelte/hooks/use-register-anchor.svelte.ts","../../src/svelte/registries/component-registry.svelte.ts","../../src/svelte/hooks/use-item-renderer.svelte.ts","../../src/svelte/registries/renderers-registry.svelte.ts","../../src/svelte/hooks/use-schema-renderer.svelte.ts","../../src/svelte/hooks/use-selection-menu.svelte.ts","../../src/svelte/auto-menu-renderer.svelte","../../src/svelte/root.svelte","../../src/svelte/provider.svelte"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/svelte';\nimport { UIPlugin, UIDocumentState, UISchema, UIScope } from '@embedpdf/plugin-ui';\n\n/**\n * Hook to get the raw UI plugin instance.\n */\nexport const useUIPlugin = () => usePlugin<UIPlugin>(UIPlugin.id);\n\n/**\n * Hook to get the UI plugin's capability API.\n */\nexport const useUICapability = () => useCapability<UIPlugin>(UIPlugin.id);\n\n// Define the return type explicitly to maintain type safety\ninterface UseUIStateReturn {\n provides: UIScope | null;\n state: UIDocumentState | null;\n}\n\n/**\n * Hook for UI state for a specific document\n * @param getDocumentId Function that returns the document ID\n */\nexport const useUIState = (getDocumentId: () => string | null): UseUIStateReturn => {\n const capability = useUICapability();\n\n let state = $state<UIDocumentState | null>(null);\n\n // Reactive documentId\n const documentId = $derived(getDocumentId());\n\n // Scoped capability for current docId\n const scopedProvides = $derived(\n capability.provides && documentId ? capability.provides.forDocument(documentId) : null,\n );\n\n $effect(() => {\n const provides = capability.provides;\n const docId = documentId;\n\n if (!provides || !docId) {\n state = null;\n return;\n }\n\n const scope = provides.forDocument(docId);\n\n // Set initial state\n state = scope.getState();\n\n // Subscribe to all changes and update state\n const unsubToolbar = scope.onToolbarChanged(() => {\n state = scope.getState();\n });\n const unsubPanel = scope.onPanelChanged(() => {\n state = scope.getState();\n });\n const unsubModal = scope.onModalChanged(() => {\n state = scope.getState();\n });\n const unsubMenu = scope.onMenuChanged(() => {\n state = scope.getState();\n });\n\n return () => {\n unsubToolbar();\n unsubPanel();\n unsubModal();\n unsubMenu();\n };\n });\n\n return {\n get provides() {\n return scopedProvides;\n },\n get state() {\n return state;\n },\n };\n};\n\n/**\n * Hook to get UI schema\n * Returns an object with a reactive getter for the schema\n */\nexport const useUISchema = () => {\n const capability = useUICapability();\n\n return {\n get schema() {\n return capability.provides?.getSchema() ?? null;\n },\n };\n};\n","import { getContext, setContext } from 'svelte';\n\n/**\n * Anchor Registry\n *\n * Tracks DOM elements for menu positioning.\n * Each anchor is scoped by documentId and itemId.\n */\nexport interface AnchorRegistry {\n register(documentId: string, itemId: string, element: HTMLElement): void;\n unregister(documentId: string, itemId: string): void;\n getAnchor(documentId: string, itemId: string): HTMLElement | null;\n}\n\nconst ANCHOR_REGISTRY_KEY = Symbol('AnchorRegistry');\n\nexport function createAnchorRegistry(): AnchorRegistry {\n const anchors = new Map<string, HTMLElement>();\n\n return {\n register(documentId: string, itemId: string, element: HTMLElement) {\n const key = `${documentId}:${itemId}`;\n anchors.set(key, element);\n },\n\n unregister(documentId: string, itemId: string) {\n const key = `${documentId}:${itemId}`;\n anchors.delete(key);\n },\n\n getAnchor(documentId: string, itemId: string) {\n const key = `${documentId}:${itemId}`;\n return anchors.get(key) || null;\n },\n };\n}\n\nexport function provideAnchorRegistry() {\n const registry = createAnchorRegistry();\n setContext(ANCHOR_REGISTRY_KEY, registry);\n return registry;\n}\n\nexport function useAnchorRegistry(): AnchorRegistry {\n const registry = getContext<AnchorRegistry>(ANCHOR_REGISTRY_KEY);\n if (!registry) {\n throw new Error('useAnchorRegistry must be used within UIProvider');\n }\n return registry;\n}\n","import { onDestroy } from 'svelte';\nimport { useAnchorRegistry } from '../registries/anchor-registry.svelte';\n\n/**\n * Register a DOM element as an anchor for menus\n *\n * @param getDocumentId - Function returning document ID\n * @param getItemId - Function returning item ID (typically matches the toolbar/menu item ID)\n * @returns Function to attach to the element via use:action\n *\n * @example\n *\n * <script lang=\"ts\">\n * const registerAnchor = useRegisterAnchor(() => documentId, () => 'zoom-button');\n * </script>\n *\n * <button use:registerAnchor>Zoom</button>\n * */\nexport function useRegisterAnchor(getDocumentId: () => string | null, getItemId: () => string) {\n const registry = useAnchorRegistry();\n let currentElement = $state<HTMLElement | null>(null);\n\n // Reactive values - these update when the functions return different values\n const documentId = $derived(getDocumentId());\n const itemId = $derived(getItemId());\n\n // Re-register anchor when documentId, itemId, or element changes\n $effect(() => {\n const docId = documentId;\n const item = itemId;\n const element = currentElement;\n\n // Only register if we have all required values\n if (element && docId && item) {\n registry.register(docId, item, element);\n\n // Cleanup: unregister when effect re-runs or component unmounts\n return () => {\n registry.unregister(docId, item);\n };\n }\n });\n\n // Svelte action function\n const action = (element: HTMLElement) => {\n currentElement = element;\n\n return {\n destroy() {\n // Clear the element reference when the action is destroyed\n currentElement = null;\n },\n };\n };\n\n return action;\n}\n","import { getContext, setContext, type Component } from 'svelte';\nimport type { BaseComponentProps } from '../types';\n\n/**\n * Component Registry\n *\n * Stores custom components that can be referenced in the UI schema.\n */\nexport interface ComponentRegistry {\n register(id: string, component: Component<BaseComponentProps>): void;\n unregister(id: string): void;\n get(id: string): Component<BaseComponentProps> | undefined;\n has(id: string): boolean;\n getRegisteredIds(): string[];\n}\n\nconst COMPONENT_REGISTRY_KEY = Symbol('ComponentRegistry');\n\nexport function createComponentRegistry(\n initialComponents: Record<string, Component<BaseComponentProps>> = {},\n): ComponentRegistry {\n const components = new Map<string, Component<BaseComponentProps>>(\n Object.entries(initialComponents),\n );\n\n return {\n register(id: string, component: Component<BaseComponentProps>) {\n components.set(id, component);\n },\n\n unregister(id: string) {\n components.delete(id);\n },\n\n get(id: string) {\n return components.get(id);\n },\n\n has(id: string) {\n return components.has(id);\n },\n\n getRegisteredIds() {\n return Array.from(components.keys());\n },\n };\n}\n\nexport function provideComponentRegistry(\n initialComponents: Record<string, Component<BaseComponentProps>> = {},\n) {\n const registry = createComponentRegistry(initialComponents);\n setContext(COMPONENT_REGISTRY_KEY, registry);\n return registry;\n}\n\nexport function useComponentRegistry(): ComponentRegistry {\n const registry = getContext<ComponentRegistry>(COMPONENT_REGISTRY_KEY);\n if (!registry) {\n throw new Error('useComponentRegistry must be used within UIProvider');\n }\n return registry;\n}\n","import { useComponentRegistry } from '../registries/component-registry.svelte';\n\n/**\n * Helper utilities for building renderers\n */\nexport function useItemRenderer() {\n const componentRegistry = useComponentRegistry();\n\n return {\n /**\n * Get a custom component by ID\n *\n * @param componentId - Component ID from schema\n * @returns Component constructor or undefined if not found\n *\n * @example\n * ```svelte\n * <script lang=\"ts\">\n * const { getCustomComponent } = useItemRenderer();\n * const MyComponent = getCustomComponent('my-component-id');\n * </script>\n *\n * {#if MyComponent}\n * <MyComponent {documentId} {...props} />\n * {/if}\n * ```\n */\n getCustomComponent: (componentId: string) => {\n const Component = componentRegistry.get(componentId);\n\n if (!Component) {\n console.error(`Component \"${componentId}\" not found in registry`);\n return undefined;\n }\n\n return Component;\n },\n };\n}\n","import { getContext, setContext } from 'svelte';\nimport type { UIRenderers } from '../types';\n\n/**\n * Renderers Registry\n *\n * Provides access to user-supplied renderers (toolbar, panel, menu).\n */\nconst RENDERERS_KEY = Symbol('Renderers');\n\nexport function provideRenderers(renderers: UIRenderers) {\n setContext(RENDERERS_KEY, renderers);\n}\n\nexport function useRenderers(): UIRenderers {\n const renderers = getContext<UIRenderers>(RENDERERS_KEY);\n if (!renderers) {\n throw new Error('useRenderers must be used within UIProvider');\n }\n return renderers;\n}\n","import { useUICapability } from './use-ui.svelte';\nimport { useRenderers } from '../registries/renderers-registry.svelte';\n\n/**\n * High-level hook for rendering UI from schema\n *\n * Provides information about active toolbars and panels by placement+slot.\n * Always includes isOpen state so renderers can control animations.\n *\n * Use with Svelte's component binding to render toolbars and panels.\n *\n * @example\n * ```svelte\n * <script lang=\"ts\">\n * const { getToolbarInfo, getPanelInfo } = useSchemaRenderer(() => documentId);\n *\n * const topMainToolbar = $derived(getToolbarInfo('top', 'main'));\n * const leftMainPanel = $derived(getPanelInfo('left', 'main'));\n * </script>\n *\n * {#if topMainToolbar}\n * {@const ToolbarRenderer = topMainToolbar.renderer}\n * <ToolbarRenderer\n * schema={topMainToolbar.schema}\n * documentId={topMainToolbar.documentId}\n * isOpen={topMainToolbar.isOpen}\n * onClose={topMainToolbar.onClose}\n * />\n * {/if}\n * ```\n */\nexport function useSchemaRenderer(getDocumentId: () => string | null) {\n const renderers = useRenderers();\n const capability = useUICapability();\n const uiState = useUIState(getDocumentId);\n\n return {\n /**\n * Get toolbar information by placement and slot\n *\n * @param placement - 'top' | 'bottom' | 'left' | 'right'\n * @param slot - Slot name (e.g. 'main', 'secondary')\n * @returns Toolbar info or null if no toolbar in slot\n */\n getToolbarInfo: (placement: 'top' | 'bottom' | 'left' | 'right', slot: string) => {\n const schema = capability.provides?.getSchema();\n const documentId = getDocumentId();\n\n if (!schema || !uiState.provides || !uiState.state || !documentId) return null;\n\n const slotKey = `${placement}-${slot}`;\n const toolbarSlot = uiState.state.activeToolbars[slotKey];\n\n // If no toolbar in this slot, nothing to render\n if (!toolbarSlot) return null;\n\n const toolbarSchema = schema.toolbars[toolbarSlot.toolbarId];\n if (!toolbarSchema) {\n console.warn(`Toolbar \"${toolbarSlot.toolbarId}\" not found in schema`);\n return null;\n }\n\n // Check if toolbar is closable\n const isClosable = !toolbarSchema.permanent;\n\n const handleClose = isClosable\n ? () => {\n uiState.provides?.closeToolbarSlot(placement, slot);\n }\n : undefined;\n\n return {\n renderer: renderers.toolbar,\n schema: toolbarSchema,\n documentId,\n isOpen: toolbarSlot.isOpen,\n onClose: handleClose,\n };\n },\n\n /**\n * Get panel information by placement and slot\n *\n * @param placement - 'left' | 'right' | 'top' | 'bottom'\n * @param slot - Slot name (e.g. 'main', 'secondary', 'inspector')\n * @returns Panel info or null if no panel in slot\n */\n getPanelInfo: (placement: 'left' | 'right' | 'top' | 'bottom', slot: string) => {\n const schema = capability.provides?.getSchema();\n const documentId = getDocumentId();\n\n if (!schema || !uiState.provides || !uiState.state || !documentId) return null;\n\n const slotKey = `${placement}-${slot}`;\n const panelSlot = uiState.state.activePanels[slotKey];\n\n // If no panel in this slot, nothing to render\n if (!panelSlot) return null;\n\n const panelSchema = schema.panels[panelSlot.panelId];\n if (!panelSchema) {\n console.warn(`Panel \"${panelSlot.panelId}\" not found in schema`);\n return null;\n }\n\n const handleClose = () => {\n uiState.provides?.closePanelSlot(placement, slot);\n };\n\n return {\n renderer: renderers.panel,\n schema: panelSchema,\n documentId,\n isOpen: panelSlot.isOpen,\n onClose: handleClose,\n };\n },\n\n /**\n * Helper: Get all active toolbars for this document\n * Useful for batch rendering or debugging\n */\n getActiveToolbars: () => {\n if (!uiState.state) return [];\n return Object.entries(uiState.state.activeToolbars).map(([slotKey, toolbarSlot]) => {\n const [placement, slot] = slotKey.split('-');\n return {\n placement,\n slot,\n toolbarId: toolbarSlot.toolbarId,\n isOpen: toolbarSlot.isOpen,\n };\n });\n },\n\n /**\n * Helper: Get all active panels for this document\n * Useful for batch rendering or debugging\n */\n getActivePanels: () => {\n if (!uiState.state) return [];\n return Object.entries(uiState.state.activePanels).map(([slotKey, panelSlot]) => {\n const [placement, slot] = slotKey.split('-');\n return {\n placement,\n slot,\n panelId: panelSlot.panelId,\n isOpen: panelSlot.isOpen,\n };\n });\n },\n };\n}\n\n// Import after definition to avoid circular dependency\nimport { useUIState } from './use-ui.svelte';\n","import type {\n SelectionMenuPropsBase,\n SelectionMenuRenderFn,\n SelectionMenuRenderResult,\n} from '@embedpdf/utils/svelte';\nimport { useUICapability } from './use-ui.svelte';\nimport { useRenderers } from '../registries/renderers-registry.svelte';\n\n/**\n * Hook for schema-driven selection menus\n */\nexport function useSelectionMenu<TContext extends { type: string }>(\n menuId: string | (() => string),\n getDocumentId: () => string,\n) {\n const uiCapability = useUICapability();\n const renderers = useRenderers();\n\n // Normalize menuId to always be a function, then make it reactive\n const getMenuIdFn = typeof menuId === 'function' ? menuId : () => menuId;\n const menuIdValue = $derived(getMenuIdFn());\n const documentId = $derived(getDocumentId());\n const schema = $derived(uiCapability.provides?.getSchema());\n const menuSchema = $derived(schema?.selectionMenus?.[menuIdValue]);\n\n const renderFn = $derived.by<SelectionMenuRenderFn<TContext> | undefined>(() => {\n if (!menuSchema) return undefined;\n\n const currentMenuSchema = menuSchema;\n const currentDocumentId = documentId;\n const SelectionMenuRenderer = renderers.selectionMenu;\n\n return (props: SelectionMenuPropsBase<TContext>): SelectionMenuRenderResult | null => {\n if (!props.selected) return null;\n\n return {\n component: SelectionMenuRenderer,\n props: {\n schema: currentMenuSchema,\n documentId: currentDocumentId,\n props,\n },\n };\n };\n });\n\n return {\n get renderFn() {\n return renderFn;\n },\n };\n}\n","<script lang=\"ts\">\n import { useUIState, useUICapability } from './hooks/use-ui.svelte';\n import { useAnchorRegistry } from './registries/anchor-registry.svelte';\n import { useRenderers } from './registries/renderers-registry.svelte';\n\n /**\n * Automatically renders menus when opened\n *\n * This component:\n * 1. Listens to UI plugin state for open menus\n * 2. Looks up anchor elements from the anchor registry\n * 3. Renders menus using the user-provided menu renderer\n */\n\n interface Props {\n documentId: string; // Which document's menus to render\n container?: HTMLElement | null;\n }\n\n let { documentId, container = null }: Props = $props();\n\n const uiState = useUIState(() => documentId);\n const capability = useUICapability();\n const anchorRegistry = useAnchorRegistry();\n const renderers = useRenderers();\n\n // Derived state for active menu\n const activeMenu = $derived.by(() => {\n const openMenus = uiState.state?.openMenus || {};\n const openMenuIds = Object.keys(openMenus);\n\n if (openMenuIds.length === 0) return null;\n\n // Show the first open menu (in practice, should only be one)\n const menuId = openMenuIds[0];\n if (!menuId) return null;\n\n const menuState = openMenus[menuId];\n if (!menuState || !menuState.triggeredByItemId) return null;\n\n // Look up anchor with documentId scope\n const anchor = anchorRegistry.getAnchor(documentId, menuState.triggeredByItemId);\n return { menuId, anchorEl: anchor };\n });\n\n const schema = $derived(capability.provides?.getSchema());\n\n const menuSchema = $derived.by(() => {\n if (!activeMenu || !schema) return null;\n\n const menuSchemaValue = schema.menus[activeMenu.menuId];\n if (!menuSchemaValue) {\n console.warn(`Menu \"${activeMenu.menuId}\" not found in schema`);\n return null;\n }\n\n return menuSchemaValue;\n });\n\n const handleClose = () => {\n if (activeMenu) {\n uiState.provides?.closeMenu(activeMenu.menuId);\n }\n };\n\n // Use the user-provided menu renderer\n const MenuRenderer = renderers.menu;\n</script>\n\n{#if activeMenu && menuSchema && MenuRenderer}\n <MenuRenderer\n schema={menuSchema}\n {documentId}\n anchorEl={activeMenu.anchorEl}\n onClose={handleClose}\n {container}\n />\n{/if}\n","<script lang=\"ts\">\n import { UI_ATTRIBUTES, UI_SELECTORS } from '@embedpdf/plugin-ui';\n import { useUIPlugin, useUICapability } from './hooks/use-ui.svelte';\n import type { Snippet } from 'svelte';\n import type { HTMLAttributes } from 'svelte/elements';\n\n type Props = HTMLAttributes<HTMLDivElement> & {\n children?: Snippet;\n };\n\n let { children, class: className, ...restProps }: Props = $props();\n\n const { plugin } = useUIPlugin();\n const { provides } = useUICapability();\n\n let disabledCategories = $state<string[]>([]);\n let rootElement: HTMLDivElement | null = $state(null);\n let styleEl: HTMLStyleElement | null = null;\n let styleTarget: HTMLElement | ShadowRoot | null = null;\n\n function getStyleTarget(element: HTMLElement): HTMLElement | ShadowRoot {\n const root = element.getRootNode();\n if (root instanceof ShadowRoot) {\n return root;\n }\n return document.head;\n }\n\n $effect(() => {\n if (!rootElement || !plugin) {\n styleTarget = null;\n return;\n }\n\n styleTarget = getStyleTarget(rootElement);\n\n const existingStyle = styleTarget.querySelector(UI_SELECTORS.STYLES) as HTMLStyleElement | null;\n\n if (existingStyle) {\n styleEl = existingStyle;\n existingStyle.textContent = plugin.getStylesheet();\n return;\n }\n\n const stylesheet = plugin.getStylesheet();\n const newStyleEl = document.createElement('style');\n newStyleEl.setAttribute(UI_ATTRIBUTES.STYLES, '');\n newStyleEl.textContent = stylesheet;\n\n if (styleTarget instanceof ShadowRoot) {\n styleTarget.insertBefore(newStyleEl, styleTarget.firstChild);\n } else {\n styleTarget.appendChild(newStyleEl);\n }\n\n styleEl = newStyleEl;\n\n return () => {\n if (styleEl?.parentNode) {\n styleEl.remove();\n }\n styleEl = null;\n styleTarget = null;\n };\n });\n\n $effect(() => {\n if (!plugin) return;\n\n return plugin.onStylesheetInvalidated(() => {\n if (styleEl) {\n styleEl.textContent = plugin.getStylesheet();\n }\n });\n });\n\n $effect(() => {\n if (!provides) return;\n\n disabledCategories = provides.getDisabledCategories();\n\n return provides.onCategoryChanged((event) => {\n disabledCategories = event.disabledCategories;\n });\n });\n\n const disabledCategoriesAttr = $derived(\n disabledCategories.length > 0 ? disabledCategories.join(' ') : undefined,\n );\n</script>\n\n<div\n bind:this={rootElement}\n {...restProps}\n {...{ [UI_ATTRIBUTES.ROOT]: '' }}\n {...disabledCategoriesAttr ? { [UI_ATTRIBUTES.DISABLED_CATEGORIES]: disabledCategoriesAttr } : {}}\n class={className}\n style:container-type=\"inline-size\"\n>\n {#if children}\n {@render children()}\n {/if}\n</div>\n","<script lang=\"ts\">\n import type { Component, Snippet } from 'svelte';\n import { provideAnchorRegistry } from './registries/anchor-registry.svelte';\n import { provideComponentRegistry } from './registries/component-registry.svelte';\n import { provideRenderers } from './registries/renderers-registry.svelte';\n import type { UIComponents, UIRenderers } from './types';\n import AutoMenuRenderer from './auto-menu-renderer.svelte';\n import UIRoot from './root.svelte';\n import type { HTMLAttributes } from 'svelte/elements';\n\n /**\n * UIProvider Props\n */\n type ProviderProps = HTMLAttributes<HTMLDivElement> & {\n children: Snippet;\n\n /**\n * Document ID for this UI context\n * Required for menu rendering\n */\n documentId: string;\n\n /**\n * Custom component registry\n * Maps component IDs to components\n */\n components?: UIComponents;\n\n /**\n * REQUIRED: User-provided renderers\n * These define how toolbars, panels, and menus are displayed\n */\n renderers: UIRenderers;\n\n /**\n * Optional: Container for menu portal\n * Defaults to document.body\n */\n menuContainer?: HTMLElement | null;\n\n class?: string;\n };\n\n let {\n children,\n documentId,\n components = {},\n renderers,\n menuContainer = null,\n class: className,\n ...restProps\n }: ProviderProps = $props();\n\n /**\n * UIProvider - Single provider for all UI plugin functionality\n *\n * Manages:\n * - Anchor registry for menu positioning\n * - Component registry for custom components\n * - Renderers for toolbars, panels, and menus\n * - Automatic menu rendering\n *\n * @example\n * ```svelte\n * <EmbedPDF {engine} {plugins}>\n * {#snippet children({ pluginsReady, activeDocumentId })}\n * {#if pluginsReady && activeDocumentId}\n * <UIProvider\n * documentId={activeDocumentId}\n * components={{\n * 'thumbnail-panel': ThumbnailPanel,\n * 'bookmark-panel': BookmarkPanel,\n * }}\n * renderers={{\n * toolbar: ToolbarRenderer,\n * panel: PanelRenderer,\n * menu: MenuRenderer,\n * }}\n * >\n * {#snippet children()}\n * <ViewerLayout />\n * {/snippet}\n * </UIProvider>\n * {/if}\n * {/snippet}\n * </EmbedPDF>\n * ```\n */\n\n // Provide all registries\n provideAnchorRegistry();\n provideComponentRegistry(components);\n provideRenderers(renderers);\n</script>\n\n<UIRoot class={className} {...restProps}>\n {@render children()}\n <AutoMenuRenderer {documentId} container={menuContainer} />\n</UIRoot>\n"],"names":["_a"],"mappings":";;;;;;AAMa,MAAA,cAAA,MAAoB,UAAoB,SAAS,EAAE;AAKnD,MAAA,kBAAA,MAAwB,cAAwB,SAAS,EAAE;MAY3D,aAAA,CAAc,kBAAyD;AAC5E,QAAA,aAAa,gBAAA;AAEf,MAAA,gBAAuC,IAAI;AAGzC,QAAA,uBAAsB,aAAA;AAGtB,QAAA,iBAAA,EAAA,QAAA,MACJ,WAAW,kBAAY,UAAA,IAAa,WAAW,SAAS,kBAAY,UAAU,CAAA,IAAI,IAAA;AAGpF,IAAA,kBAAc;UACN,WAAW,WAAW;AACtB,UAAA,cAAQ,UAAA;SAET,YAAA,CAAa,OAAO;AACvB,QAAA,IAAA,OAAQ,IAAA;;IAEV;AAEM,UAAA,QAAQ,SAAS,YAAY,KAAK;UAGxC,OAAQ,MAAM,SAAA,GAAA,IAAA;AAGR,UAAA,eAAe,MAAM,uBAAuB;YAChD,OAAQ,MAAM,SAAA,GAAA,IAAA;AAAA,IAChB,CAAC;AACK,UAAA,aAAa,MAAM,qBAAqB;YAC5C,OAAQ,MAAM,SAAA,GAAA,IAAA;AAAA,IAChB,CAAC;AACK,UAAA,aAAa,MAAM,qBAAqB;YAC5C,OAAQ,MAAM,SAAA,GAAA,IAAA;AAAA,IAChB,CAAC;AACK,UAAA,YAAY,MAAM,oBAAoB;YAC1C,OAAQ,MAAM,SAAA,GAAA,IAAA;AAAA,IAChB,CAAC;iBAEY;AACX,mBAAA;AACA,iBAAA;AACA,iBAAA;AACA,gBAAA;AAAA,IACF;AAAA,EACF,CAAC;;IAGK,IAAA,WAAW;mBACN,cAAA;AAAA,IACT;AAAA,IACI,IAAA,QAAQ;mBACH,KAAA;AAAA,IACT;AAAA;AAEJ;AAMa,MAAA,oBAAoB;AACzB,QAAA,aAAa,gBAAA;;IAGb,IAAA,SAAS;;AACJ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M;WAEJ,OAAO,wBAAuB,MAAO;AACtC,UAAA,SAAS;AACX,gBAAQ,cAAc,OAAO,cAAa;AAAA,MAC5C;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AAED,IAAA,YAAO,MAAO;SACP,SAAQ;UAEb,oBAAqB,SAAS,sBAAqB,GAAA,IAAA;AAE5C,WAAA,SAAS,kBAAiB,CAAE,UAAU;YAC3C,oBAAqB,MAAM,oBAAkB,IAAA;AAAA,IAC/C,CAAC;AAAA,EACH,CAAC;AAEK,QAAA,yBAAsB,EAAA,QAAA,MAAA,EAAA,IAC1B,kBAAkB,EAAC,SAAS,IAAC,EAAA,IAAG,kBAAkB,EAAC,KAAK,GAAG,IAAI,MAAS;;;OAMtE;AAAA,UACG,cAAc,IAAI,GAAG,GAAE;AAAA,aAC1B,sBAAsB;OAAM,cAAc,mBAAmB,GAAA,EAAA,IAAG,sBAAsB;AAAA;;;;;;;;;;;;;;;;;AAH/E,IAAA,UAAA,KAAA,CAAA,YAAA,EAAA,IAAA,mCAAA,WAAW,CAAA;;;AAHxB;;qCCzFA;;MA8CI,aAAU,EAAA,KAAA,SAAA,cAAA,IAAA,OAAA,CAAA,EAAA,GAEV,oDAAgB,IAAI,GAEjB,YAAQ,EAAA,WAAA,SAAA;AAAA;;;;;;;;;;AAwCb,wBAAqB;AACrB,2BAAyB,WAAU,CAAA;AACnC,mBAAgB,QAAA,SAAA;;;;;;;UAGY;AAAA;;;;;;;;;;;mBAEc,cAAa;AAAA;;;;;;;;AAJzD;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/svelte/hooks/use-ui.svelte.ts","../../src/svelte/hooks/use-ui-container.svelte.ts","../../src/svelte/registries/anchor-registry.svelte.ts","../../src/svelte/hooks/use-register-anchor.svelte.ts","../../src/svelte/registries/component-registry.svelte.ts","../../src/svelte/hooks/use-item-renderer.svelte.ts","../../src/svelte/registries/renderers-registry.svelte.ts","../../src/svelte/hooks/use-schema-renderer.svelte.ts","../../src/svelte/hooks/use-selection-menu.svelte.ts","../../src/svelte/auto-menu-renderer.svelte","../../src/svelte/root.svelte","../../src/svelte/provider.svelte"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/svelte';\nimport { UIPlugin, UIDocumentState, UIScope } from '@embedpdf/plugin-ui';\n\n/**\n * Hook to get the raw UI plugin instance.\n */\nexport const useUIPlugin = () => usePlugin<UIPlugin>(UIPlugin.id);\n\n/**\n * Hook to get the UI plugin's capability API.\n */\nexport const useUICapability = () => useCapability<UIPlugin>(UIPlugin.id);\n\n// Define the return type explicitly to maintain type safety\ninterface UseUIStateReturn {\n provides: UIScope | null;\n state: UIDocumentState | null;\n}\n\n/**\n * Hook for UI state for a specific document\n * @param getDocumentId Function that returns the document ID\n */\nexport const useUIState = (getDocumentId: () => string | null): UseUIStateReturn => {\n const capability = useUICapability();\n\n let state = $state<UIDocumentState | null>(null);\n\n // Reactive documentId\n const documentId = $derived(getDocumentId());\n\n // Scoped capability for current docId\n const scopedProvides = $derived(\n capability.provides && documentId ? capability.provides.forDocument(documentId) : null,\n );\n\n $effect(() => {\n const provides = capability.provides;\n const docId = documentId;\n\n if (!provides || !docId) {\n state = null;\n return;\n }\n\n const scope = provides.forDocument(docId);\n\n // Set initial state\n state = scope.getState();\n\n // Subscribe to all changes and update state\n const unsubToolbar = scope.onToolbarChanged(() => {\n state = scope.getState();\n });\n const unsubSidebar = scope.onSidebarChanged(() => {\n state = scope.getState();\n });\n const unsubModal = scope.onModalChanged(() => {\n state = scope.getState();\n });\n const unsubMenu = scope.onMenuChanged(() => {\n state = scope.getState();\n });\n\n return () => {\n unsubToolbar();\n unsubSidebar();\n unsubModal();\n unsubMenu();\n };\n });\n\n return {\n get provides() {\n return scopedProvides;\n },\n get state() {\n return state;\n },\n };\n};\n\n/**\n * Hook to get UI schema\n * Returns an object with a reactive getter for the schema\n */\nexport const useUISchema = () => {\n const capability = useUICapability();\n\n return {\n get schema() {\n return capability.provides?.getSchema() ?? null;\n },\n };\n};\n","import { getContext, setContext } from 'svelte';\n\nexport interface UIContainerContextValue {\n /** Get the container element (may be null if not mounted) */\n getContainer: () => HTMLDivElement | null;\n}\n\nconst UI_CONTAINER_KEY = Symbol('ui-container');\n\n/**\n * Set up the container context (called by UIRoot)\n */\nexport function setUIContainerContext(value: UIContainerContextValue): void {\n setContext(UI_CONTAINER_KEY, value);\n}\n\n/**\n * Hook to access the UI container element.\n *\n * This provides access to the UIRoot container for:\n * - Container query based responsiveness\n * - Portaling elements to the root\n * - Measuring container dimensions\n *\n * @example\n * ```svelte\n * <script>\n * import { useUIContainer } from '@embedpdf/plugin-ui/svelte';\n * import { onMount, onDestroy } from 'svelte';\n *\n * const { getContainer } = useUIContainer();\n *\n * let observer;\n *\n * onMount(() => {\n * const container = getContainer();\n * if (!container) return;\n *\n * observer = new ResizeObserver(() => {\n * console.log('Container width:', container.clientWidth);\n * });\n * observer.observe(container);\n * });\n *\n * onDestroy(() => observer?.disconnect());\n * </script>\n * ```\n */\nexport function useUIContainer(): UIContainerContextValue {\n const context = getContext<UIContainerContextValue>(UI_CONTAINER_KEY);\n if (!context) {\n throw new Error('useUIContainer must be used within a UIProvider');\n }\n return context;\n}\n","import { getContext, setContext } from 'svelte';\n\n/**\n * Anchor Registry\n *\n * Tracks DOM elements for menu positioning.\n * Each anchor is scoped by documentId and itemId.\n */\nexport interface AnchorRegistry {\n register(documentId: string, itemId: string, element: HTMLElement): void;\n unregister(documentId: string, itemId: string): void;\n getAnchor(documentId: string, itemId: string): HTMLElement | null;\n}\n\nconst ANCHOR_REGISTRY_KEY = Symbol('AnchorRegistry');\n\nexport function createAnchorRegistry(): AnchorRegistry {\n const anchors = new Map<string, HTMLElement>();\n\n return {\n register(documentId: string, itemId: string, element: HTMLElement) {\n const key = `${documentId}:${itemId}`;\n anchors.set(key, element);\n },\n\n unregister(documentId: string, itemId: string) {\n const key = `${documentId}:${itemId}`;\n anchors.delete(key);\n },\n\n getAnchor(documentId: string, itemId: string) {\n const key = `${documentId}:${itemId}`;\n return anchors.get(key) || null;\n },\n };\n}\n\nexport function provideAnchorRegistry() {\n const registry = createAnchorRegistry();\n setContext(ANCHOR_REGISTRY_KEY, registry);\n return registry;\n}\n\nexport function useAnchorRegistry(): AnchorRegistry {\n const registry = getContext<AnchorRegistry>(ANCHOR_REGISTRY_KEY);\n if (!registry) {\n throw new Error('useAnchorRegistry must be used within UIProvider');\n }\n return registry;\n}\n","import { onDestroy } from 'svelte';\nimport { useAnchorRegistry } from '../registries/anchor-registry.svelte';\n\n/**\n * Register a DOM element as an anchor for menus\n *\n * @param getDocumentId - Function returning document ID\n * @param getItemId - Function returning item ID (typically matches the toolbar/menu item ID)\n * @returns Function to attach to the element via use:action\n *\n * @example\n *\n * <script lang=\"ts\">\n * const registerAnchor = useRegisterAnchor(() => documentId, () => 'zoom-button');\n * </script>\n *\n * <button use:registerAnchor>Zoom</button>\n * */\nexport function useRegisterAnchor(getDocumentId: () => string | null, getItemId: () => string) {\n const registry = useAnchorRegistry();\n let currentElement = $state<HTMLElement | null>(null);\n\n // Reactive values - these update when the functions return different values\n const documentId = $derived(getDocumentId());\n const itemId = $derived(getItemId());\n\n // Re-register anchor when documentId, itemId, or element changes\n $effect(() => {\n const docId = documentId;\n const item = itemId;\n const element = currentElement;\n\n // Only register if we have all required values\n if (element && docId && item) {\n registry.register(docId, item, element);\n\n // Cleanup: unregister when effect re-runs or component unmounts\n return () => {\n registry.unregister(docId, item);\n };\n }\n });\n\n // Svelte action function\n const action = (element: HTMLElement) => {\n currentElement = element;\n\n return {\n destroy() {\n // Clear the element reference when the action is destroyed\n currentElement = null;\n },\n };\n };\n\n return action;\n}\n","import { getContext, setContext, type Component } from 'svelte';\nimport type { BaseComponentProps } from '../types';\n\n/**\n * Component Registry\n *\n * Stores custom components that can be referenced in the UI schema.\n */\nexport interface ComponentRegistry {\n register(id: string, component: Component<BaseComponentProps>): void;\n unregister(id: string): void;\n get(id: string): Component<BaseComponentProps> | undefined;\n has(id: string): boolean;\n getRegisteredIds(): string[];\n}\n\nconst COMPONENT_REGISTRY_KEY = Symbol('ComponentRegistry');\n\nexport function createComponentRegistry(\n initialComponents: Record<string, Component<BaseComponentProps>> = {},\n): ComponentRegistry {\n const components = new Map<string, Component<BaseComponentProps>>(\n Object.entries(initialComponents),\n );\n\n return {\n register(id: string, component: Component<BaseComponentProps>) {\n components.set(id, component);\n },\n\n unregister(id: string) {\n components.delete(id);\n },\n\n get(id: string) {\n return components.get(id);\n },\n\n has(id: string) {\n return components.has(id);\n },\n\n getRegisteredIds() {\n return Array.from(components.keys());\n },\n };\n}\n\nexport function provideComponentRegistry(\n initialComponents: Record<string, Component<BaseComponentProps>> = {},\n) {\n const registry = createComponentRegistry(initialComponents);\n setContext(COMPONENT_REGISTRY_KEY, registry);\n return registry;\n}\n\nexport function useComponentRegistry(): ComponentRegistry {\n const registry = getContext<ComponentRegistry>(COMPONENT_REGISTRY_KEY);\n if (!registry) {\n throw new Error('useComponentRegistry must be used within UIProvider');\n }\n return registry;\n}\n","import { useComponentRegistry } from '../registries/component-registry.svelte';\n\n/**\n * Helper utilities for building renderers\n */\nexport function useItemRenderer() {\n const componentRegistry = useComponentRegistry();\n\n return {\n /**\n * Get a custom component by ID\n *\n * @param componentId - Component ID from schema\n * @returns Component constructor or undefined if not found\n *\n * @example\n * ```svelte\n * <script lang=\"ts\">\n * const { getCustomComponent } = useItemRenderer();\n * const MyComponent = getCustomComponent('my-component-id');\n * </script>\n *\n * {#if MyComponent}\n * <MyComponent {documentId} {...props} />\n * {/if}\n * ```\n */\n getCustomComponent: (componentId: string) => {\n const Component = componentRegistry.get(componentId);\n\n if (!Component) {\n console.error(`Component \"${componentId}\" not found in registry`);\n return undefined;\n }\n\n return Component;\n },\n };\n}\n","import { getContext, setContext } from 'svelte';\nimport type { UIRenderers } from '../types';\n\n/**\n * Renderers Registry\n *\n * Provides access to user-supplied renderers (toolbar, panel, menu).\n */\nconst RENDERERS_KEY = Symbol('Renderers');\n\nexport function provideRenderers(renderers: UIRenderers) {\n setContext(RENDERERS_KEY, renderers);\n}\n\nexport function useRenderers(): UIRenderers {\n const renderers = getContext<UIRenderers>(RENDERERS_KEY);\n if (!renderers) {\n throw new Error('useRenderers must be used within UIProvider');\n }\n return renderers;\n}\n","import { useUICapability } from './use-ui.svelte';\nimport { useRenderers } from '../registries/renderers-registry.svelte';\n\n/**\n * High-level hook for rendering UI from schema\n *\n * Provides information about active toolbars, sidebars, and modals.\n * Always includes isOpen state so renderers can control animations.\n *\n * Use with Svelte's component binding to render toolbars and sidebars.\n *\n * @example\n * ```svelte\n * <script lang=\"ts\">\n * const { getToolbarInfo, getSidebarInfo, getModalInfo } = useSchemaRenderer(() => documentId);\n *\n * const topMainToolbar = $derived(getToolbarInfo('top', 'main'));\n * const leftMainSidebar = $derived(getSidebarInfo('left', 'main'));\n * const modal = $derived(getModalInfo());\n * </script>\n *\n * {#if topMainToolbar}\n * {@const ToolbarRenderer = topMainToolbar.renderer}\n * <ToolbarRenderer\n * schema={topMainToolbar.schema}\n * documentId={topMainToolbar.documentId}\n * isOpen={topMainToolbar.isOpen}\n * onClose={topMainToolbar.onClose}\n * />\n * {/if}\n * ```\n */\nexport function useSchemaRenderer(getDocumentId: () => string | null) {\n const renderers = useRenderers();\n const capability = useUICapability();\n const uiState = useUIState(getDocumentId);\n\n return {\n /**\n * Get toolbar information by placement and slot\n *\n * @param placement - 'top' | 'bottom' | 'left' | 'right'\n * @param slot - Slot name (e.g. 'main', 'secondary')\n * @returns Toolbar info or null if no toolbar in slot\n */\n getToolbarInfo: (placement: 'top' | 'bottom' | 'left' | 'right', slot: string) => {\n const schema = capability.provides?.getSchema();\n const documentId = getDocumentId();\n\n if (!schema || !uiState.provides || !uiState.state || !documentId) return null;\n\n const slotKey = `${placement}-${slot}`;\n const toolbarSlot = uiState.state.activeToolbars[slotKey];\n\n // If no toolbar in this slot, nothing to render\n if (!toolbarSlot) return null;\n\n const toolbarSchema = schema.toolbars[toolbarSlot.toolbarId];\n if (!toolbarSchema) {\n console.warn(`Toolbar \"${toolbarSlot.toolbarId}\" not found in schema`);\n return null;\n }\n\n // Check if toolbar is closable\n const isClosable = !toolbarSchema.permanent;\n\n const handleClose = isClosable\n ? () => {\n uiState.provides?.closeToolbarSlot(placement, slot);\n }\n : undefined;\n\n return {\n renderer: renderers.toolbar,\n schema: toolbarSchema,\n documentId,\n isOpen: toolbarSlot.isOpen,\n onClose: handleClose,\n };\n },\n\n /**\n * Get sidebar information by placement and slot\n *\n * @param placement - 'left' | 'right' | 'top' | 'bottom'\n * @param slot - Slot name (e.g. 'main', 'secondary', 'inspector')\n * @returns Sidebar info or null if no sidebar in slot\n */\n getSidebarInfo: (placement: 'left' | 'right' | 'top' | 'bottom', slot: string) => {\n const schema = capability.provides?.getSchema();\n const documentId = getDocumentId();\n\n if (!schema || !uiState.provides || !uiState.state || !documentId) return null;\n\n const slotKey = `${placement}-${slot}`;\n const sidebarSlot = uiState.state.activeSidebars[slotKey];\n\n // If no sidebar in this slot, nothing to render\n if (!sidebarSlot) return null;\n\n const sidebarSchema = schema.sidebars?.[sidebarSlot.sidebarId];\n if (!sidebarSchema) {\n console.warn(`Sidebar \"${sidebarSlot.sidebarId}\" not found in schema`);\n return null;\n }\n\n const handleClose = () => {\n uiState.provides?.closeSidebarSlot(placement, slot);\n };\n\n return {\n renderer: renderers.sidebar,\n schema: sidebarSchema,\n documentId,\n isOpen: sidebarSlot.isOpen,\n onClose: handleClose,\n };\n },\n\n /**\n * Get modal information (if active)\n *\n * Supports animation lifecycle:\n * - isOpen: true = visible\n * - isOpen: false = animate out (modal still rendered)\n * - onExited called after animation → modal removed\n *\n * @returns Modal info or null if no modal active\n */\n getModalInfo: () => {\n const schema = capability.provides?.getSchema();\n const documentId = getDocumentId();\n\n if (!schema || !uiState.provides || !uiState.state?.activeModal || !documentId) return null;\n\n const { modalId, isOpen } = uiState.state.activeModal;\n\n const modalSchema = schema.modals?.[modalId];\n if (!modalSchema) {\n console.warn(`Modal \"${modalId}\" not found in schema`);\n return null;\n }\n\n const handleClose = () => {\n uiState.provides?.closeModal();\n };\n\n const handleExited = () => {\n uiState.provides?.clearModal();\n };\n\n const ModalRenderer = renderers.modal;\n if (!ModalRenderer) {\n console.warn('No modal renderer registered');\n return null;\n }\n\n return {\n renderer: ModalRenderer,\n schema: modalSchema,\n documentId,\n isOpen,\n onClose: handleClose,\n onExited: handleExited,\n };\n },\n\n /**\n * Helper: Get all active toolbars for this document\n * Useful for batch rendering or debugging\n */\n getActiveToolbars: () => {\n if (!uiState.state) return [];\n return Object.entries(uiState.state.activeToolbars).map(([slotKey, toolbarSlot]) => {\n const [placement, slot] = slotKey.split('-');\n return {\n placement,\n slot,\n toolbarId: toolbarSlot.toolbarId,\n isOpen: toolbarSlot.isOpen,\n };\n });\n },\n\n /**\n * Helper: Get all active sidebars for this document\n * Useful for batch rendering or debugging\n */\n getActiveSidebars: () => {\n if (!uiState.state) return [];\n return Object.entries(uiState.state.activeSidebars).map(([slotKey, sidebarSlot]) => {\n const [placement, slot] = slotKey.split('-');\n return {\n placement,\n slot,\n sidebarId: sidebarSlot.sidebarId,\n isOpen: sidebarSlot.isOpen,\n };\n });\n },\n\n /**\n * Get overlay information for all enabled overlays\n *\n * Overlays are floating components positioned over the document content.\n * Unlike modals, multiple overlays can be visible and they don't block interaction.\n *\n * @example\n * ```svelte\n * <script lang=\"ts\">\n * const { getOverlaysInfo } = useSchemaRenderer(() => documentId);\n * const overlays = $derived(getOverlaysInfo());\n * </script>\n *\n * {#each overlays as overlay (overlay.schema.id)}\n * {@const OverlayRenderer = overlay.renderer}\n * <OverlayRenderer schema={overlay.schema} documentId={overlay.documentId} />\n * {/each}\n * ```\n */\n getOverlaysInfo: () => {\n const schema = capability.provides?.getSchema();\n const documentId = getDocumentId();\n\n if (!schema?.overlays || !documentId) return [];\n\n const OverlayRenderer = renderers.overlay;\n if (!OverlayRenderer) {\n return [];\n }\n\n return Object.values(schema.overlays).map((overlaySchema) => ({\n renderer: OverlayRenderer,\n schema: overlaySchema,\n documentId,\n }));\n },\n };\n}\n\n// Import after definition to avoid circular dependency\nimport { useUIState } from './use-ui.svelte';\n","import type {\n SelectionMenuPropsBase,\n SelectionMenuRenderFn,\n SelectionMenuRenderResult,\n} from '@embedpdf/utils/svelte';\nimport { useUICapability } from './use-ui.svelte';\nimport { useRenderers } from '../registries/renderers-registry.svelte';\n\n/**\n * Hook for schema-driven selection menus\n */\nexport function useSelectionMenu<TContext extends { type: string }>(\n menuId: string | (() => string),\n getDocumentId: () => string,\n) {\n const uiCapability = useUICapability();\n const renderers = useRenderers();\n\n // Normalize menuId to always be a function, then make it reactive\n const getMenuIdFn = typeof menuId === 'function' ? menuId : () => menuId;\n const menuIdValue = $derived(getMenuIdFn());\n const documentId = $derived(getDocumentId());\n const schema = $derived(uiCapability.provides?.getSchema());\n const menuSchema = $derived(schema?.selectionMenus?.[menuIdValue]);\n\n const renderFn = $derived.by<SelectionMenuRenderFn<TContext> | undefined>(() => {\n if (!menuSchema) return undefined;\n\n const currentMenuSchema = menuSchema;\n const currentDocumentId = documentId;\n const SelectionMenuRenderer = renderers.selectionMenu;\n\n return (props: SelectionMenuPropsBase<TContext>): SelectionMenuRenderResult | null => {\n if (!props.selected) return null;\n\n return {\n component: SelectionMenuRenderer,\n props: {\n schema: currentMenuSchema,\n documentId: currentDocumentId,\n props,\n },\n };\n };\n });\n\n return {\n get renderFn() {\n return renderFn;\n },\n };\n}\n","<script lang=\"ts\">\n import { useUIState, useUICapability } from './hooks/use-ui.svelte';\n import { useAnchorRegistry } from './registries/anchor-registry.svelte';\n import { useRenderers } from './registries/renderers-registry.svelte';\n\n /**\n * Automatically renders menus when opened\n *\n * This component:\n * 1. Listens to UI plugin state for open menus\n * 2. Looks up anchor elements from the anchor registry\n * 3. Renders menus using the user-provided menu renderer\n */\n\n interface Props {\n documentId: string; // Which document's menus to render\n container?: HTMLElement | null;\n }\n\n let { documentId, container = null }: Props = $props();\n\n const uiState = useUIState(() => documentId);\n const capability = useUICapability();\n const anchorRegistry = useAnchorRegistry();\n const renderers = useRenderers();\n\n // Derived state for active menu\n const activeMenu = $derived.by(() => {\n const openMenus = uiState.state?.openMenus || {};\n const openMenuIds = Object.keys(openMenus);\n\n if (openMenuIds.length === 0) return null;\n\n // Show the first open menu (in practice, should only be one)\n const menuId = openMenuIds[0];\n if (!menuId) return null;\n\n const menuState = openMenus[menuId];\n if (!menuState || !menuState.triggeredByItemId) return null;\n\n // Look up anchor with documentId scope\n const anchor = anchorRegistry.getAnchor(documentId, menuState.triggeredByItemId);\n return { menuId, anchorEl: anchor };\n });\n\n const schema = $derived(capability.provides?.getSchema());\n\n const menuSchema = $derived.by(() => {\n if (!activeMenu || !schema) return null;\n\n const menuSchemaValue = schema.menus[activeMenu.menuId];\n if (!menuSchemaValue) {\n console.warn(`Menu \"${activeMenu.menuId}\" not found in schema`);\n return null;\n }\n\n return menuSchemaValue;\n });\n\n const handleClose = () => {\n if (activeMenu) {\n uiState.provides?.closeMenu(activeMenu.menuId);\n }\n };\n\n // Use the user-provided menu renderer\n const MenuRenderer = renderers.menu;\n</script>\n\n{#if activeMenu && menuSchema && MenuRenderer}\n <MenuRenderer\n schema={menuSchema}\n {documentId}\n anchorEl={activeMenu.anchorEl}\n onClose={handleClose}\n {container}\n />\n{/if}\n","<script lang=\"ts\">\n import { UI_ATTRIBUTES, UI_SELECTORS } from '@embedpdf/plugin-ui';\n import { useUIPlugin, useUICapability } from './hooks/use-ui.svelte';\n import { setUIContainerContext } from './hooks/use-ui-container.svelte';\n import type { Snippet } from 'svelte';\n import type { HTMLAttributes } from 'svelte/elements';\n\n type Props = HTMLAttributes<HTMLDivElement> & {\n children?: Snippet;\n };\n\n let { children, class: className, ...restProps }: Props = $props();\n\n const { plugin } = useUIPlugin();\n const { provides } = useUICapability();\n\n let disabledCategories = $state<string[]>([]);\n let hiddenItems = $state<string[]>([]);\n let rootElement: HTMLDivElement | null = $state(null);\n let styleEl: HTMLStyleElement | null = null;\n let styleTarget: HTMLElement | ShadowRoot | null = null;\n\n // Provide container context for child components\n setUIContainerContext({\n getContainer: () => rootElement,\n });\n\n function getStyleTarget(element: HTMLElement): HTMLElement | ShadowRoot {\n const root = element.getRootNode();\n if (root instanceof ShadowRoot) {\n return root;\n }\n return document.head;\n }\n\n $effect(() => {\n if (!rootElement || !plugin) {\n styleTarget = null;\n return;\n }\n\n styleTarget = getStyleTarget(rootElement);\n\n const existingStyle = styleTarget.querySelector(UI_SELECTORS.STYLES) as HTMLStyleElement | null;\n\n if (existingStyle) {\n styleEl = existingStyle;\n existingStyle.textContent = plugin.getStylesheet();\n return;\n }\n\n const stylesheet = plugin.getStylesheet();\n const newStyleEl = document.createElement('style');\n newStyleEl.setAttribute(UI_ATTRIBUTES.STYLES, '');\n newStyleEl.textContent = stylesheet;\n\n if (styleTarget instanceof ShadowRoot) {\n styleTarget.insertBefore(newStyleEl, styleTarget.firstChild);\n } else {\n styleTarget.appendChild(newStyleEl);\n }\n\n styleEl = newStyleEl;\n\n return () => {\n if (styleEl?.parentNode) {\n styleEl.remove();\n }\n styleEl = null;\n styleTarget = null;\n };\n });\n\n $effect(() => {\n if (!plugin) return;\n\n return plugin.onStylesheetInvalidated(() => {\n if (styleEl) {\n styleEl.textContent = plugin.getStylesheet();\n }\n });\n });\n\n $effect(() => {\n if (!provides) return;\n\n disabledCategories = provides.getDisabledCategories();\n hiddenItems = provides.getHiddenItems();\n\n return provides.onCategoryChanged((event) => {\n disabledCategories = event.disabledCategories;\n hiddenItems = event.hiddenItems;\n });\n });\n\n const disabledCategoriesAttr = $derived(\n disabledCategories.length > 0 ? disabledCategories.join(' ') : undefined,\n );\n\n const hiddenItemsAttr = $derived(hiddenItems.length > 0 ? hiddenItems.join(' ') : undefined);\n</script>\n\n<div\n bind:this={rootElement}\n {...restProps}\n {...{ [UI_ATTRIBUTES.ROOT]: '' }}\n {...disabledCategoriesAttr ? { [UI_ATTRIBUTES.DISABLED_CATEGORIES]: disabledCategoriesAttr } : {}}\n {...hiddenItemsAttr ? { [UI_ATTRIBUTES.HIDDEN_ITEMS]: hiddenItemsAttr } : {}}\n class={className}\n style:container-type=\"inline-size\"\n>\n {#if children}\n {@render children()}\n {/if}\n</div>\n","<script lang=\"ts\">\n import type { Component, Snippet } from 'svelte';\n import { provideAnchorRegistry } from './registries/anchor-registry.svelte';\n import { provideComponentRegistry } from './registries/component-registry.svelte';\n import { provideRenderers } from './registries/renderers-registry.svelte';\n import type { UIComponents, UIRenderers } from './types';\n import AutoMenuRenderer from './auto-menu-renderer.svelte';\n import UIRoot from './root.svelte';\n import type { HTMLAttributes } from 'svelte/elements';\n\n /**\n * UIProvider Props\n */\n type ProviderProps = HTMLAttributes<HTMLDivElement> & {\n children: Snippet;\n\n /**\n * Document ID for this UI context\n * Required for menu rendering\n */\n documentId: string;\n\n /**\n * Custom component registry\n * Maps component IDs to components\n */\n components?: UIComponents;\n\n /**\n * REQUIRED: User-provided renderers\n * These define how toolbars, panels, and menus are displayed\n */\n renderers: UIRenderers;\n\n /**\n * Optional: Container for menu portal\n * Defaults to document.body\n */\n menuContainer?: HTMLElement | null;\n\n class?: string;\n };\n\n let {\n children,\n documentId,\n components = {},\n renderers,\n menuContainer = null,\n class: className,\n ...restProps\n }: ProviderProps = $props();\n\n /**\n * UIProvider - Single provider for all UI plugin functionality\n *\n * Manages:\n * - Anchor registry for menu positioning\n * - Component registry for custom components\n * - Renderers for toolbars, panels, and menus\n * - Automatic menu rendering\n *\n * @example\n * ```svelte\n * <EmbedPDF {engine} {plugins}>\n * {#snippet children({ pluginsReady, activeDocumentId })}\n * {#if pluginsReady && activeDocumentId}\n * <UIProvider\n * documentId={activeDocumentId}\n * components={{\n * 'thumbnail-panel': ThumbnailPanel,\n * 'bookmark-panel': BookmarkPanel,\n * }}\n * renderers={{\n * toolbar: ToolbarRenderer,\n * panel: PanelRenderer,\n * menu: MenuRenderer,\n * }}\n * >\n * {#snippet children()}\n * <ViewerLayout />\n * {/snippet}\n * </UIProvider>\n * {/if}\n * {/snippet}\n * </EmbedPDF>\n * ```\n */\n\n // Provide all registries\n provideAnchorRegistry();\n provideComponentRegistry(components);\n provideRenderers(renderers);\n</script>\n\n<UIRoot class={className} {...restProps}>\n {@render children()}\n <AutoMenuRenderer {documentId} container={menuContainer} />\n</UIRoot>\n"],"names":["_a"],"mappings":";;;;;;AAMa,MAAA,cAAA,MAAoB,UAAoB,SAAS,EAAE;AAKnD,MAAA,kBAAA,MAAwB,cAAwB,SAAS,EAAE;MAY3D,aAAA,CAAc,kBAAyD;AAC5E,QAAA,aAAa,gBAAA;AAEf,MAAA,gBAAuC,IAAI;AAGzC,QAAA,uBAAsB,aAAA;AAGtB,QAAA,iBAAA,EAAA,QAAA,MACJ,WAAW,kBAAY,UAAA,IAAa,WAAW,SAAS,kBAAY,UAAU,CAAA,IAAI,IAAA;AAGpF,IAAA,kBAAc;UACN,WAAW,WAAW;AACtB,UAAA,cAAQ,UAAA;SAET,YAAA,CAAa,OAAO;AACvB,QAAA,IAAA,OAAQ,IAAA;;IAEV;AAEM,UAAA,QAAQ,SAAS,YAAY,KAAK;UAGxC,OAAQ,MAAM,SAAA,GAAA,IAAA;AAGR,UAAA,eAAe,MAAM,uBAAuB;YAChD,OAAQ,MAAM,SAAA,GAAA,IAAA;AAAA,IAChB,CAAC;AACK,UAAA,eAAe,MAAM,uBAAuB;YAChD,OAAQ,MAAM,SAAA,GAAA,IAAA;AAAA,IAChB,CAAC;AACK,UAAA,aAAa,MAAM,qBAAqB;YAC5C,OAAQ,MAAM,SAAA,GAAA,IAAA;AAAA,IAChB,CAAC;AACK,UAAA,YAAY,MAAM,oBAAoB;YAC1C,OAAQ,MAAM,SAAA,GAAA,IAAA;AAAA,IAChB,CAAC;iBAEY;AACX,mBAAA;AACA,mBAAA;AACA,iBAAA;AACA,gBAAA;AAAA,IACF;AAAA,EACF,CAAC;;IAGK,IAAA,WAAW;mBACN,cAAA;AAAA,IACT;AAAA,IACI,IAAA,QAAQ;mBACH,KAAA;AAAA,IACT;AAAA;AA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A,EAAA,IAAA,mCAAA,WAAW,CAAA;;;AAHxB;;qCCpGA;;MA8CI,aAAU,EAAA,KAAA,SAAA,cAAA,IAAA,OAAA,CAAA,EAAA,GAEV,oDAAgB,IAAI,GAEjB,YAAQ,EAAA,WAAA,SAAA;AAAA;;;;;;;;;;AAwCb,wBAAqB;AACrB,2BAAyB,WAAU,CAAA;AACnC,mBAAgB,QAAA,SAAA;;;;;;;UAGY;AAAA;;;;;;;;;;;mBAEc,cAAa;AAAA;;;;;;;;AAJzD;"}
@@ -1,5 +1,5 @@
1
1
  import { Component } from 'svelte';
2
- import { ToolbarSchema, PanelSchema, MenuSchema, SelectionMenuSchema } from '../lib';
2
+ import { ToolbarSchema, SidebarSchema, ModalSchema, OverlaySchema, MenuSchema, SelectionMenuSchema } from '../lib';
3
3
  import { SelectionMenuPropsBase } from '@embedpdf/utils/svelte';
4
4
  export type { SelectionMenuPropsBase };
5
5
  export type UIComponents = Record<string, Component<BaseComponentProps>>;
@@ -23,17 +23,40 @@ export interface ToolbarRendererProps {
23
23
  }
24
24
  export type ToolbarRenderer = Component<ToolbarRendererProps>;
25
25
  /**
26
- * Props for panel renderer
26
+ * Props for sidebar renderer
27
27
  * The app provides a component matching this contract
28
28
  */
29
- export interface PanelRendererProps {
30
- schema: PanelSchema;
29
+ export interface SidebarRendererProps {
30
+ schema: SidebarSchema;
31
31
  documentId: string;
32
32
  isOpen: boolean;
33
33
  onClose: () => void;
34
34
  className?: string;
35
35
  }
36
- export type PanelRenderer = Component<PanelRendererProps>;
36
+ export type SidebarRenderer = Component<SidebarRendererProps>;
37
+ /**
38
+ * Props for modal renderer (with animation lifecycle support)
39
+ * The app provides a component matching this contract
40
+ */
41
+ export interface ModalRendererProps {
42
+ schema: ModalSchema;
43
+ documentId: string;
44
+ isOpen: boolean;
45
+ onClose: () => void;
46
+ onExited: () => void;
47
+ className?: string;
48
+ }
49
+ export type ModalRenderer = Component<ModalRendererProps>;
50
+ /**
51
+ * Props for overlay renderer
52
+ * The app provides a component matching this contract
53
+ */
54
+ export interface OverlayRendererProps {
55
+ schema: OverlaySchema;
56
+ documentId: string;
57
+ className?: string;
58
+ }
59
+ export type OverlayRenderer = Component<OverlayRendererProps>;
37
60
  /**
38
61
  * Props for menu renderer
39
62
  * The app provides a component matching this contract
@@ -61,7 +84,9 @@ export type SelectionMenuRenderer = Component<SelectionMenuRendererProps>;
61
84
  */
62
85
  export interface UIRenderers {
63
86
  toolbar: ToolbarRenderer;
64
- panel: PanelRenderer;
87
+ sidebar: SidebarRenderer;
88
+ modal?: ModalRenderer;
89
+ overlay?: OverlayRenderer;
65
90
  menu: MenuRenderer;
66
91
  selectionMenu: SelectionMenuRenderer;
67
92
  }
@@ -1,4 +1,5 @@
1
1
  export * from './use-ui';
2
+ export * from './use-ui-container';
2
3
  export * from './use-register-anchor';
3
4
  export * from './use-item-renderer';
4
5
  export * from './use-schema-renderer';
@@ -2,7 +2,7 @@ import { VNode, MaybeRefOrGetter } from 'vue';
2
2
  /**
3
3
  * High-level composable for rendering UI from schema
4
4
  *
5
- * Provides simple functions to render toolbars and panels by placement+slot.
5
+ * Provides simple functions to render toolbars, sidebars, and modals.
6
6
  * Always passes isOpen state to renderers so they can control animations.
7
7
  *
8
8
  * Automatically subscribes to UI state changes for the given document.
@@ -25,9 +25,9 @@ export declare function useSchemaRenderer(documentId: MaybeRefOrGetter<string>):
25
25
  */
26
26
  renderToolbar: (placement: "top" | "bottom" | "left" | "right", slot: string) => VNode | null;
27
27
  /**
28
- * Render a panel by placement and slot
28
+ * Render a sidebar by placement and slot
29
29
  *
30
- * ALWAYS renders (when panel exists in slot) with isOpen state.
30
+ * ALWAYS renders (when sidebar exists in slot) with isOpen state.
31
31
  * Your renderer controls whether to display or animate.
32
32
  *
33
33
  * @param placement - 'left' | 'right' | 'top' | 'bottom'
@@ -35,11 +35,28 @@ export declare function useSchemaRenderer(documentId: MaybeRefOrGetter<string>):
35
35
  *
36
36
  * @example
37
37
  * ```vue
38
- * <component :is="renderPanel('left', 'main')" />
39
- * <component :is="renderPanel('right', 'main')" />
38
+ * <component :is="renderSidebar('left', 'main')" />
39
+ * <component :is="renderSidebar('right', 'main')" />
40
40
  * ```
41
41
  */
42
- renderPanel: (placement: "left" | "right" | "top" | "bottom", slot: string) => VNode | null;
42
+ renderSidebar: (placement: "left" | "right" | "top" | "bottom", slot: string) => VNode | null;
43
+ /**
44
+ * Render the active modal (if any)
45
+ *
46
+ * Only one modal can be active at a time.
47
+ * Modals are defined in schema.modals.
48
+ *
49
+ * Supports animation lifecycle:
50
+ * - isOpen: true = visible
51
+ * - isOpen: false = animate out (modal still rendered)
52
+ * - onExited called after animation → modal removed
53
+ *
54
+ * @example
55
+ * ```vue
56
+ * <component :is="renderModal()" />
57
+ * ```
58
+ */
59
+ renderModal: () => VNode | null;
43
60
  /**
44
61
  * Helper: Get all active toolbars for this document
45
62
  * Useful for batch rendering or debugging
@@ -51,13 +68,28 @@ export declare function useSchemaRenderer(documentId: MaybeRefOrGetter<string>):
51
68
  isOpen: boolean;
52
69
  }[];
53
70
  /**
54
- * Helper: Get all active panels for this document
71
+ * Helper: Get all active sidebars for this document
55
72
  * Useful for batch rendering or debugging
56
73
  */
57
- getActivePanels: () => {
74
+ getActiveSidebars: () => {
58
75
  placement: string;
59
76
  slot: string;
60
- panelId: string;
77
+ sidebarId: string;
61
78
  isOpen: boolean;
62
79
  }[];
80
+ /**
81
+ * Render all enabled overlays
82
+ *
83
+ * Overlays are floating components positioned over the document content.
84
+ * Unlike modals, multiple overlays can be visible and they don't block interaction.
85
+ *
86
+ * @example
87
+ * ```vue
88
+ * <div class="relative">
89
+ * <slot />
90
+ * <component :is="renderOverlays()" />
91
+ * </div>
92
+ * ```
93
+ */
94
+ renderOverlays: () => VNode[] | null;
63
95
  };
@@ -0,0 +1,39 @@
1
+ import { Ref, InjectionKey } from 'vue';
2
+ export interface UIContainerContextValue {
3
+ /** Reference to the UIRoot container element */
4
+ containerRef: Ref<HTMLDivElement | null>;
5
+ /** Get the container element (may be null if not mounted) */
6
+ getContainer: () => HTMLDivElement | null;
7
+ }
8
+ export declare const UI_CONTAINER_KEY: InjectionKey<UIContainerContextValue>;
9
+ /**
10
+ * Hook to access the UI container element.
11
+ *
12
+ * This provides access to the UIRoot container for:
13
+ * - Container query based responsiveness
14
+ * - Portaling elements to the root
15
+ * - Measuring container dimensions
16
+ *
17
+ * @example
18
+ * ```vue
19
+ * <script setup>
20
+ * import { useUIContainer } from '@embedpdf/plugin-ui/vue';
21
+ * import { onMounted, onUnmounted } from 'vue';
22
+ *
23
+ * const { containerRef, getContainer } = useUIContainer();
24
+ *
25
+ * onMounted(() => {
26
+ * const container = getContainer();
27
+ * if (!container) return;
28
+ *
29
+ * const observer = new ResizeObserver(() => {
30
+ * console.log('Container width:', container.clientWidth);
31
+ * });
32
+ * observer.observe(container);
33
+ *
34
+ * onUnmounted(() => observer.disconnect());
35
+ * });
36
+ * </script>
37
+ * ```
38
+ */
39
+ export declare function useUIContainer(): UIContainerContextValue;
@@ -15,13 +15,16 @@ export declare const useUIState: (documentId: MaybeRefOrGetter<string>) => {
15
15
  readonly isOpen: boolean;
16
16
  };
17
17
  };
18
- readonly activePanels: {
18
+ readonly activeSidebars: {
19
19
  readonly [x: string]: {
20
- readonly panelId: string;
20
+ readonly sidebarId: string;
21
21
  readonly isOpen: boolean;
22
22
  };
23
23
  };
24
- readonly activeModal: string | null;
24
+ readonly activeModal: {
25
+ readonly modalId: string;
26
+ readonly isOpen: boolean;
27
+ } | null;
25
28
  readonly openMenus: {
26
29
  readonly [x: string]: {
27
30
  readonly menuId: string;
@@ -29,7 +32,7 @@ export declare const useUIState: (documentId: MaybeRefOrGetter<string>) => {
29
32
  readonly triggeredByItemId?: string | undefined;
30
33
  };
31
34
  };
32
- readonly panelTabs: {
35
+ readonly sidebarTabs: {
33
36
  readonly [x: string]: string;
34
37
  };
35
38
  } | null, {
@@ -39,13 +42,16 @@ export declare const useUIState: (documentId: MaybeRefOrGetter<string>) => {
39
42
  readonly isOpen: boolean;
40
43
  };
41
44
  };
42
- readonly activePanels: {
45
+ readonly activeSidebars: {
43
46
  readonly [x: string]: {
44
- readonly panelId: string;
47
+ readonly sidebarId: string;
45
48
  readonly isOpen: boolean;
46
49
  };
47
50
  };
48
- readonly activeModal: string | null;
51
+ readonly activeModal: {
52
+ readonly modalId: string;
53
+ readonly isOpen: boolean;
54
+ } | null;
49
55
  readonly openMenus: {
50
56
  readonly [x: string]: {
51
57
  readonly menuId: string;
@@ -53,7 +59,7 @@ export declare const useUIState: (documentId: MaybeRefOrGetter<string>) => {
53
59
  readonly triggeredByItemId?: string | undefined;
54
60
  };
55
61
  };
56
- readonly panelTabs: {
62
+ readonly sidebarTabs: {
57
63
  readonly [x: string]: string;
58
64
  };
59
65
  } | null>>;
@@ -370,15 +376,14 @@ export declare const useUISchema: () => Readonly<import('vue').Ref<{
370
376
  } | undefined;
371
377
  };
372
378
  };
373
- readonly panels: {
379
+ readonly sidebars: {
374
380
  readonly [x: string]: {
375
381
  readonly id: string;
376
- readonly type: "sidebar" | "overlay" | "modal" | "popover";
377
- readonly position?: {
382
+ readonly position: {
378
383
  readonly placement: "left" | "right" | "top" | "bottom";
379
- readonly slot?: string | undefined;
384
+ readonly slot: string;
380
385
  readonly order?: number | undefined;
381
- } | undefined;
386
+ };
382
387
  readonly content: {
383
388
  readonly type: "tabs";
384
389
  readonly tabs: readonly {
@@ -403,11 +408,46 @@ export declare const useUISchema: () => Readonly<import('vue').Ref<{
403
408
  };
404
409
  readonly collapsible?: boolean | undefined;
405
410
  readonly defaultOpen?: boolean | undefined;
406
- readonly closeOnClickOutside?: boolean | undefined;
407
411
  readonly width?: string | undefined;
408
412
  readonly height?: string | undefined;
409
413
  readonly minWidth?: string | undefined;
410
414
  readonly minHeight?: string | undefined;
415
+ readonly categories?: readonly string[] | undefined;
416
+ readonly visibilityDependsOn?: {
417
+ readonly menuId?: string | undefined;
418
+ readonly itemIds?: readonly string[] | undefined;
419
+ } | undefined;
420
+ };
421
+ };
422
+ readonly modals: {
423
+ readonly [x: string]: {
424
+ readonly id: string;
425
+ readonly content: {
426
+ readonly type: "tabs";
427
+ readonly tabs: readonly {
428
+ readonly id: string;
429
+ readonly labelKey?: string | undefined;
430
+ readonly label?: string | undefined;
431
+ readonly icon?: string | undefined;
432
+ readonly componentId: string;
433
+ readonly categories?: readonly string[] | undefined;
434
+ readonly visibilityDependsOn?: {
435
+ readonly menuId?: string | undefined;
436
+ readonly itemIds?: readonly string[] | undefined;
437
+ } | undefined;
438
+ }[];
439
+ readonly defaultTab?: string | undefined;
440
+ } | {
441
+ readonly type: "component";
442
+ readonly componentId: string;
443
+ readonly props?: {
444
+ readonly [x: string]: any;
445
+ } | undefined;
446
+ };
447
+ readonly closeOnClickOutside?: boolean | undefined;
448
+ readonly closeOnEscape?: boolean | undefined;
449
+ readonly width?: string | undefined;
450
+ readonly height?: string | undefined;
411
451
  readonly maxWidth?: string | undefined;
412
452
  readonly maxHeight?: string | undefined;
413
453
  readonly categories?: readonly string[] | undefined;
@@ -417,6 +457,33 @@ export declare const useUISchema: () => Readonly<import('vue').Ref<{
417
457
  } | undefined;
418
458
  };
419
459
  };
460
+ readonly overlays?: {
461
+ readonly [x: string]: {
462
+ readonly id: string;
463
+ readonly position: {
464
+ readonly anchor: import('../../lib').OverlayAnchor;
465
+ readonly offset?: {
466
+ readonly top?: string | undefined;
467
+ readonly right?: string | undefined;
468
+ readonly bottom?: string | undefined;
469
+ readonly left?: string | undefined;
470
+ } | undefined;
471
+ };
472
+ readonly content: {
473
+ readonly type: "component";
474
+ readonly componentId: string;
475
+ readonly props?: {
476
+ readonly [x: string]: any;
477
+ } | undefined;
478
+ };
479
+ readonly defaultEnabled?: boolean | undefined;
480
+ readonly categories?: readonly string[] | undefined;
481
+ readonly visibilityDependsOn?: {
482
+ readonly menuId?: string | undefined;
483
+ readonly itemIds?: readonly string[] | undefined;
484
+ } | undefined;
485
+ };
486
+ } | undefined;
420
487
  readonly selectionMenus: {
421
488
  readonly [x: string]: {
422
489
  readonly id: string;
@@ -808,15 +875,14 @@ export declare const useUISchema: () => Readonly<import('vue').Ref<{
808
875
  } | undefined;
809
876
  };
810
877
  };
811
- readonly panels: {
878
+ readonly sidebars: {
812
879
  readonly [x: string]: {
813
880
  readonly id: string;
814
- readonly type: "sidebar" | "overlay" | "modal" | "popover";
815
- readonly position?: {
881
+ readonly position: {
816
882
  readonly placement: "left" | "right" | "top" | "bottom";
817
- readonly slot?: string | undefined;
883
+ readonly slot: string;
818
884
  readonly order?: number | undefined;
819
- } | undefined;
885
+ };
820
886
  readonly content: {
821
887
  readonly type: "tabs";
822
888
  readonly tabs: readonly {
@@ -841,11 +907,46 @@ export declare const useUISchema: () => Readonly<import('vue').Ref<{
841
907
  };
842
908
  readonly collapsible?: boolean | undefined;
843
909
  readonly defaultOpen?: boolean | undefined;
844
- readonly closeOnClickOutside?: boolean | undefined;
845
910
  readonly width?: string | undefined;
846
911
  readonly height?: string | undefined;
847
912
  readonly minWidth?: string | undefined;
848
913
  readonly minHeight?: string | undefined;
914
+ readonly categories?: readonly string[] | undefined;
915
+ readonly visibilityDependsOn?: {
916
+ readonly menuId?: string | undefined;
917
+ readonly itemIds?: readonly string[] | undefined;
918
+ } | undefined;
919
+ };
920
+ };
921
+ readonly modals: {
922
+ readonly [x: string]: {
923
+ readonly id: string;
924
+ readonly content: {
925
+ readonly type: "tabs";
926
+ readonly tabs: readonly {
927
+ readonly id: string;
928
+ readonly labelKey?: string | undefined;
929
+ readonly label?: string | undefined;
930
+ readonly icon?: string | undefined;
931
+ readonly componentId: string;
932
+ readonly categories?: readonly string[] | undefined;
933
+ readonly visibilityDependsOn?: {
934
+ readonly menuId?: string | undefined;
935
+ readonly itemIds?: readonly string[] | undefined;
936
+ } | undefined;
937
+ }[];
938
+ readonly defaultTab?: string | undefined;
939
+ } | {
940
+ readonly type: "component";
941
+ readonly componentId: string;
942
+ readonly props?: {
943
+ readonly [x: string]: any;
944
+ } | undefined;
945
+ };
946
+ readonly closeOnClickOutside?: boolean | undefined;
947
+ readonly closeOnEscape?: boolean | undefined;
948
+ readonly width?: string | undefined;
949
+ readonly height?: string | undefined;
849
950
  readonly maxWidth?: string | undefined;
850
951
  readonly maxHeight?: string | undefined;
851
952
  readonly categories?: readonly string[] | undefined;
@@ -855,6 +956,33 @@ export declare const useUISchema: () => Readonly<import('vue').Ref<{
855
956
  } | undefined;
856
957
  };
857
958
  };
959
+ readonly overlays?: {
960
+ readonly [x: string]: {
961
+ readonly id: string;
962
+ readonly position: {
963
+ readonly anchor: import('../../lib').OverlayAnchor;
964
+ readonly offset?: {
965
+ readonly top?: string | undefined;
966
+ readonly right?: string | undefined;
967
+ readonly bottom?: string | undefined;
968
+ readonly left?: string | undefined;
969
+ } | undefined;
970
+ };
971
+ readonly content: {
972
+ readonly type: "component";
973
+ readonly componentId: string;
974
+ readonly props?: {
975
+ readonly [x: string]: any;
976
+ } | undefined;
977
+ };
978
+ readonly defaultEnabled?: boolean | undefined;
979
+ readonly categories?: readonly string[] | undefined;
980
+ readonly visibilityDependsOn?: {
981
+ readonly menuId?: string | undefined;
982
+ readonly itemIds?: readonly string[] | undefined;
983
+ } | undefined;
984
+ };
985
+ } | undefined;
858
986
  readonly selectionMenus: {
859
987
  readonly [x: string]: {
860
988
  readonly id: string;