@embedpdf/plugin-ui 2.0.0-next.1 → 2.0.0-next.3

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/vue/hooks/use-ui.ts","../../src/vue/registries/anchor-registry.ts","../../src/vue/hooks/use-register-anchor.ts","../../src/vue/registries/component-registry.ts","../../src/vue/hooks/use-item-renderer.ts","../../src/vue/registries/renderers-registry.ts","../../src/vue/hooks/use-schema-renderer.ts","../../src/vue/hooks/use-selection-menu.ts","../../src/vue/auto-menu-renderer.vue","../../src/vue/root.vue","../../src/vue/provider.vue"],"sourcesContent":["import { ref, watch, computed, readonly, toValue, type MaybeRefOrGetter } from 'vue';\nimport { useCapability, usePlugin } from '@embedpdf/core/vue';\nimport { UIPlugin, UIDocumentState, UISchema } from '@embedpdf/plugin-ui';\n\nexport const useUIPlugin = () => usePlugin<UIPlugin>(UIPlugin.id);\nexport const useUICapability = () => useCapability<UIPlugin>(UIPlugin.id);\n\n/**\n * Hook for UI state for a specific document\n * @param documentId Document ID (can be ref, computed, getter, or plain value)\n */\nexport const useUIState = (documentId: MaybeRefOrGetter<string>) => {\n const { provides } = useUICapability();\n const state = ref<UIDocumentState | null>(null);\n\n watch(\n [provides, () => toValue(documentId)],\n ([providesValue, docId], _, onCleanup) => {\n if (!providesValue) {\n state.value = null;\n return;\n }\n\n const scope = providesValue.forDocument(docId);\n\n // Set initial state\n state.value = scope.getState();\n\n // Subscribe to all changes\n const unsubToolbar = scope.onToolbarChanged(() => {\n state.value = scope.getState();\n });\n const unsubPanel = scope.onPanelChanged(() => {\n state.value = scope.getState();\n });\n const unsubModal = scope.onModalChanged(() => {\n state.value = scope.getState();\n });\n const unsubMenu = scope.onMenuChanged(() => {\n state.value = scope.getState();\n });\n\n onCleanup(() => {\n unsubToolbar();\n unsubPanel();\n unsubModal();\n unsubMenu();\n });\n },\n { immediate: true },\n );\n\n // Return a computed ref for the scoped capability\n const scopedProvides = computed(() => {\n const docId = toValue(documentId);\n return provides.value?.forDocument(docId) ?? null;\n });\n\n return {\n provides: scopedProvides,\n state: readonly(state),\n };\n};\n\n/**\n * Hook to get UI schema\n */\nexport const useUISchema = () => {\n const { provides } = useUICapability();\n const schema = computed<UISchema | null>(() => provides.value?.getSchema() ?? null);\n\n return readonly(schema);\n};\n","import { ref, inject, provide, type InjectionKey, type Ref } from 'vue';\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 AnchorRegistryKey: InjectionKey<AnchorRegistry> = Symbol('AnchorRegistry');\n\nexport function createAnchorRegistry(): AnchorRegistry {\n const anchors: Ref<Map<string, HTMLElement>> = ref(new Map());\n\n return {\n register(documentId: string, itemId: string, element: HTMLElement) {\n const key = `${documentId}:${itemId}`;\n anchors.value.set(key, element);\n },\n\n unregister(documentId: string, itemId: string) {\n const key = `${documentId}:${itemId}`;\n anchors.value.delete(key);\n },\n\n getAnchor(documentId: string, itemId: string) {\n const key = `${documentId}:${itemId}`;\n return anchors.value.get(key) || null;\n },\n };\n}\n\nexport function provideAnchorRegistry() {\n const registry = createAnchorRegistry();\n provide(AnchorRegistryKey, registry);\n return registry;\n}\n\nexport function useAnchorRegistry(): AnchorRegistry {\n const registry = inject(AnchorRegistryKey);\n if (!registry) {\n throw new Error('useAnchorRegistry must be used within UIProvider');\n }\n return registry;\n}\n","import { onBeforeUnmount, ref, watch } from 'vue';\nimport { useAnchorRegistry } from '../registries/anchor-registry';\n\n/**\n * Register a DOM element as an anchor for menus\n *\n * @param documentId - Document ID\n * @param itemId - Item ID (typically matches the toolbar/menu item ID)\n * @returns Ref to attach to the element (use with :ref=\"anchorRef\")\n *\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * const anchorRef = useRegisterAnchor(props.documentId, 'zoom-button');\n * </script>\n *\n * <template>\n * <button :ref=\"anchorRef\">Zoom</button>\n * </template>\n * ```\n */\nexport function useRegisterAnchor(documentId: string, itemId: string) {\n const registry = useAnchorRegistry();\n const elementRef = ref<HTMLElement | null>(null);\n\n // Function to set ref\n const setRef = (el: any) => {\n // Handle Vue 3 ref binding\n const element = el?.$el || el;\n\n // Unregister previous element if exists\n if (elementRef.value && elementRef.value !== element) {\n registry.unregister(documentId, itemId);\n }\n\n elementRef.value = element;\n\n // Register new element\n if (element) {\n registry.register(documentId, itemId, element);\n }\n };\n\n // Cleanup on unmount\n onBeforeUnmount(() => {\n if (elementRef.value) {\n registry.unregister(documentId, itemId);\n }\n });\n\n return setRef;\n}\n","import { ref, inject, provide, type Component, type InjectionKey, type Ref } from 'vue';\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 ComponentRegistryKey: InjectionKey<ComponentRegistry> = Symbol('ComponentRegistry');\n\nexport function createComponentRegistry(\n initialComponents: Record<string, Component<BaseComponentProps>> = {},\n): ComponentRegistry {\n const components: Ref<Map<string, Component<BaseComponentProps>>> = ref(\n new Map(Object.entries(initialComponents)),\n );\n\n return {\n register(id: string, component: Component<BaseComponentProps>) {\n components.value.set(id, component);\n },\n\n unregister(id: string) {\n components.value.delete(id);\n },\n\n get(id: string) {\n return components.value.get(id);\n },\n\n has(id: string) {\n return components.value.has(id);\n },\n\n getRegisteredIds() {\n return Array.from(components.value.keys());\n },\n };\n}\n\nexport function provideComponentRegistry(\n initialComponents: Record<string, Component<BaseComponentProps>> = {},\n) {\n const registry = createComponentRegistry(initialComponents);\n provide(ComponentRegistryKey, registry);\n return registry;\n}\n\nexport function useComponentRegistry(): ComponentRegistry {\n const registry = inject(ComponentRegistryKey);\n if (!registry) {\n throw new Error('useComponentRegistry must be used within UIProvider');\n }\n return registry;\n}\n","import { h } from 'vue';\nimport { useComponentRegistry } from '../registries/component-registry';\n\n/**\n * Helper utilities for building renderers\n */\nexport function useItemRenderer() {\n const componentRegistry = useComponentRegistry();\n\n return {\n /**\n * Render a custom component by ID\n *\n * @param componentId - Component ID from schema\n * @param documentId - Document ID\n * @param props - Additional props to pass to component\n * @returns Rendered component or null if not found\n */\n renderCustomComponent: (componentId: string, documentId: string, props?: any) => {\n const Component = componentRegistry.get(componentId);\n\n if (!Component) {\n console.error(`Component \"${componentId}\" not found in registry`);\n return null;\n }\n\n return h(Component, { documentId, ...(props || {}) });\n },\n };\n}\n","import { inject, provide, type InjectionKey } from 'vue';\nimport type { UIRenderers } from '../types';\n\n/**\n * Renderers Registry\n *\n * Provides access to user-supplied renderers (toolbar, panel, menu).\n */\nconst RenderersKey: InjectionKey<UIRenderers> = Symbol('Renderers');\n\nexport function provideRenderers(renderers: UIRenderers) {\n provide(RenderersKey, renderers);\n}\n\nexport function useRenderers(): UIRenderers {\n const renderers = inject(RenderersKey);\n if (!renderers) {\n throw new Error('useRenderers must be used within UIProvider');\n }\n return renderers;\n}\n","import { h, toValue, type VNode, type MaybeRefOrGetter } from 'vue';\nimport { useUICapability, useUIState } from './use-ui';\nimport { useRenderers } from '../registries/renderers-registry';\n\n/**\n * High-level composable for rendering UI from schema\n *\n * Provides simple functions to render toolbars and panels by placement+slot.\n * Always passes isOpen state to renderers so they can control animations.\n *\n * Automatically subscribes to UI state changes for the given document.\n * @param documentId Document ID (can be ref, computed, getter, or plain value)\n */\nexport function useSchemaRenderer(documentId: MaybeRefOrGetter<string>) {\n const renderers = useRenderers();\n const { provides } = useUICapability();\n const { state: uiState } = useUIState(documentId);\n\n return {\n /**\n * Render a toolbar by placement and slot\n *\n * Always renders with isOpen state when toolbar exists in slot.\n *\n * @param placement - 'top' | 'bottom' | 'left' | 'right'\n * @param slot - Slot name (e.g. 'main', 'secondary')\n *\n * @example\n * ```vue\n * <component :is=\"renderToolbar('top', 'main')\" />\n * <component :is=\"renderToolbar('top', 'secondary')\" />\n * ```\n */\n renderToolbar: (placement: 'top' | 'bottom' | 'left' | 'right', slot: string): VNode | null => {\n const schema = provides.value?.getSchema();\n\n if (!schema || !provides.value || !uiState.value) return null;\n\n const slotKey = `${placement}-${slot}`;\n const toolbarSlot = uiState.value.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 provides.value?.forDocument(toValue(documentId)).closeToolbarSlot(placement, slot);\n }\n : undefined;\n\n const ToolbarRenderer = renderers.toolbar;\n\n // ALWAYS render, pass isOpen state\n return h(ToolbarRenderer, {\n key: toolbarSlot.toolbarId,\n schema: toolbarSchema,\n documentId: toValue(documentId),\n isOpen: toolbarSlot.isOpen,\n onClose: handleClose,\n });\n },\n\n /**\n * Render a panel by placement and slot\n *\n * ALWAYS renders (when panel exists in slot) with isOpen state.\n * Your renderer controls whether to display or animate.\n *\n * @param placement - 'left' | 'right' | 'top' | 'bottom'\n * @param slot - Slot name (e.g. 'main', 'secondary', 'inspector')\n *\n * @example\n * ```vue\n * <component :is=\"renderPanel('left', 'main')\" />\n * <component :is=\"renderPanel('right', 'main')\" />\n * ```\n */\n renderPanel: (placement: 'left' | 'right' | 'top' | 'bottom', slot: string): VNode | null => {\n const schema = provides.value?.getSchema();\n\n if (!schema || !provides.value || !uiState.value) return null;\n\n const slotKey = `${placement}-${slot}`;\n const panelSlot = uiState.value.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 provides.value?.forDocument(toValue(documentId)).closePanelSlot(placement, slot);\n };\n\n const PanelRenderer = renderers.panel;\n\n // ALWAYS render, pass isOpen state\n // Your renderer decides whether to return null or animate\n return h(PanelRenderer, {\n key: panelSlot.panelId,\n schema: panelSchema,\n documentId: toValue(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.value) return [];\n return Object.entries(uiState.value.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.value) return [];\n return Object.entries(uiState.value.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","import { computed, h, toValue, type VNode, type MaybeRefOrGetter } from 'vue';\nimport type { SelectionMenuPropsBase, SelectionMenuRenderFn } from '@embedpdf/utils/vue';\nimport { useUICapability } from './use-ui';\nimport { useRenderers } from '../registries/renderers-registry';\n\n/**\n * Creates a render function for a selection menu from the schema\n *\n * @param menuId - The selection menu ID from schema\n * @param documentId - Document ID (can be ref, computed, getter, or plain value)\n * @returns A computed ref containing the render function or undefined\n *\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * const annotationMenu = useSelectionMenu('annotation', () => props.documentId);\n * </script>\n *\n * <template>\n * <AnnotationLayer\n * :documentId=\"documentId\"\n * :selectionMenu=\"annotationMenu\"\n * />\n * </template>\n * ```\n */\nexport function useSelectionMenu<TContext extends { type: string } = { type: string }>(\n menuId: MaybeRefOrGetter<string>,\n documentId: MaybeRefOrGetter<string>,\n) {\n const { provides } = useUICapability();\n const renderers = useRenderers();\n\n const schema = computed(() => provides.value?.getSchema());\n const menuSchema = computed(() => schema.value?.selectionMenus?.[toValue(menuId)]);\n\n // Return a computed that produces the render function (or undefined)\n const renderFn = computed<SelectionMenuRenderFn<TContext> | undefined>(() => {\n // If no schema for this menu, return undefined\n if (!menuSchema.value) {\n return undefined;\n }\n\n // Capture current values for the closure\n const currentMenuSchema = menuSchema.value;\n const currentDocumentId = toValue(documentId);\n const SelectionMenuRenderer = renderers.selectionMenu;\n\n // Return the render function\n return (props: SelectionMenuPropsBase<TContext>): VNode | null => {\n if (!props.selected) {\n return null;\n }\n\n return h(SelectionMenuRenderer, {\n schema: currentMenuSchema,\n documentId: currentDocumentId,\n props,\n });\n };\n });\n\n return renderFn;\n}\n","<template>\n <component\n v-if=\"activeMenu && menuSchema && MenuRenderer\"\n :is=\"MenuRenderer\"\n :schema=\"menuSchema\"\n :documentId=\"documentId\"\n :anchorEl=\"activeMenu.anchorEl\"\n :onClose=\"handleClose\"\n :container=\"container\"\n />\n</template>\n\n<script setup lang=\"ts\">\nimport { ref, computed, watch } from 'vue';\nimport { useUIState, useUICapability } from './hooks/use-ui';\nimport { useAnchorRegistry } from './registries/anchor-registry';\nimport { useRenderers } from './registries/renderers-registry';\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\ninterface Props {\n documentId: string; // Which document's menus to render\n container?: HTMLElement | null;\n}\n\nconst props = defineProps<Props>();\n\nconst { state: uiState } = useUIState(props.documentId);\nconst { provides } = useUICapability();\nconst anchorRegistry = useAnchorRegistry();\nconst renderers = useRenderers();\n\nconst activeMenu = ref<{\n menuId: string;\n anchorEl: HTMLElement | null;\n} | null>(null);\n\nconst openMenus = computed(() => uiState.value?.openMenus || {});\nconst schema = computed(() => provides.value?.getSchema());\n\n// Update active menu when state changes\nwatch(\n openMenus,\n (menus) => {\n const openMenuIds = Object.keys(menus);\n\n if (openMenuIds.length > 0) {\n // Show the first open menu (in practice, should only be one)\n const menuId = openMenuIds[0];\n if (!menuId) {\n activeMenu.value = null;\n return;\n }\n\n const menuState = menus[menuId];\n if (menuState && menuState.triggeredByItemId) {\n // Look up anchor with documentId scope\n const anchor = anchorRegistry.getAnchor(props.documentId, menuState.triggeredByItemId);\n activeMenu.value = { menuId, anchorEl: anchor };\n } else {\n activeMenu.value = null;\n }\n } else {\n activeMenu.value = null;\n }\n },\n { immediate: true },\n);\n\nconst menuSchema = computed(() => {\n if (!activeMenu.value || !schema.value) return null;\n\n const menuSchemaValue = schema.value.menus[activeMenu.value.menuId];\n if (!menuSchemaValue) {\n console.warn(`Menu \"${activeMenu.value.menuId}\" not found in schema`);\n return null;\n }\n\n return menuSchemaValue;\n});\n\nconst handleClose = () => {\n if (activeMenu.value) {\n provides.value?.forDocument(props.documentId).closeMenu(activeMenu.value.menuId);\n }\n};\n\n// Use the user-provided menu renderer\nconst MenuRenderer = computed(() => renderers.menu);\n</script>\n","<template>\n <div\n ref=\"rootRef\"\n v-bind=\"{ ...attrs, ...(rootAttrs as any) }\"\n :style=\"{ containerType: 'inline-size' }\"\n >\n <slot />\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { ref, computed, onMounted, onUnmounted, watch, useAttrs } from 'vue';\nimport { UI_ATTRIBUTES, UI_SELECTORS } from '@embedpdf/plugin-ui';\nimport { useUIPlugin, useUICapability } from './hooks/use-ui';\n\n// Disable automatic attribute inheritance since we handle it manually\ndefineOptions({\n inheritAttrs: false,\n});\n\nconst attrs = useAttrs();\n\nconst { plugin } = useUIPlugin();\nconst { provides } = useUICapability();\n\nconst disabledCategories = ref<string[]>([]);\nconst rootRef = ref<HTMLDivElement | null>(null);\n\nlet styleEl: HTMLStyleElement | null = null;\nlet styleTarget: HTMLElement | ShadowRoot | null = null;\n\n/**\n * Find the style injection target for an element.\n * Returns the shadow root if inside one, otherwise document.head.\n */\nfunction 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/**\n * Inject or update stylesheet\n */\nfunction injectStyles() {\n if (!rootRef.value || !plugin.value) {\n return;\n }\n\n styleTarget = getStyleTarget(rootRef.value);\n\n // Check if styles already exist in this target\n const existingStyle = styleTarget.querySelector(UI_SELECTORS.STYLES) as HTMLStyleElement | null;\n\n if (existingStyle) {\n styleEl = existingStyle;\n // Update content in case locale changed\n existingStyle.textContent = plugin.value.getStylesheet();\n return;\n }\n\n // Create and inject stylesheet\n const stylesheet = plugin.value.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\n/**\n * Cleanup styles\n */\nfunction cleanupStyles() {\n if (styleEl?.parentNode) {\n styleEl.remove();\n }\n styleEl = null;\n styleTarget = null;\n}\n\n// Build root element attributes\nconst rootAttrs = computed(() => {\n const result: Record<string, string> = {\n [UI_ATTRIBUTES.ROOT]: '',\n };\n\n if (disabledCategories.value.length > 0) {\n result[UI_ATTRIBUTES.DISABLED_CATEGORIES] = disabledCategories.value.join(' ');\n }\n\n return result;\n});\n\n// Stylesheet invalidation cleanup\nlet stylesheetCleanup: (() => void) | null = null;\n\n// Category change cleanup\nlet categoryCleanup: (() => void) | null = null;\n\nonMounted(() => {\n // Inject styles on mount\n injectStyles();\n\n // Subscribe to stylesheet invalidation\n if (plugin.value) {\n stylesheetCleanup = plugin.value.onStylesheetInvalidated(() => {\n if (styleEl && plugin.value) {\n styleEl.textContent = plugin.value.getStylesheet();\n }\n });\n }\n\n // Subscribe to category changes\n if (provides.value) {\n disabledCategories.value = provides.value.getDisabledCategories();\n\n categoryCleanup = provides.value.onCategoryChanged((event) => {\n disabledCategories.value = event.disabledCategories;\n });\n }\n});\n\nonUnmounted(() => {\n cleanupStyles();\n stylesheetCleanup?.();\n categoryCleanup?.();\n});\n\n// Re-inject styles if plugin changes\nwatch(plugin, () => {\n if (rootRef.value && plugin.value) {\n injectStyles();\n }\n});\n</script>\n","<template>\n <UIRoot v-bind=\"attrs\">\n <slot />\n <!-- Automatically render menus for this document -->\n <AutoMenuRenderer :documentId=\"documentId\" :container=\"menuContainer\" />\n </UIRoot>\n</template>\n\n<script setup lang=\"ts\">\nimport type { Component } from 'vue';\nimport { useAttrs } from 'vue';\nimport { provideAnchorRegistry } from './registries/anchor-registry';\nimport { provideComponentRegistry } from './registries/component-registry';\nimport { provideRenderers } from './registries/renderers-registry';\nimport type { BaseComponentProps, UIRenderers } from './types';\nimport AutoMenuRenderer from './auto-menu-renderer.vue';\nimport UIRoot from './root.vue';\n\n// Disable automatic attribute inheritance since we pass them to UIRoot\ndefineOptions({\n inheritAttrs: false,\n});\n\nconst attrs = useAttrs();\n\n/**\n * UIProvider Props\n */\ninterface Props {\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?: Record<string, Component<BaseComponentProps>>;\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\nconst props = withDefaults(defineProps<Props>(), {\n components: () => ({}),\n menuContainer: null,\n});\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 * ```vue\n * <EmbedPDF :engine=\"engine\" :plugins=\"plugins\">\n * <template v-slot=\"{ pluginsReady, activeDocumentId }\">\n * <UIProvider\n * v-if=\"pluginsReady && activeDocumentId\"\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 * class=\"relative flex h-full w-full\"\n * >\n * <ViewerLayout />\n * </UIProvider>\n * </template>\n * </EmbedPDF>\n * ```\n */\n\n// Provide all registries\nprovideAnchorRegistry();\nprovideComponentRegistry(props.components);\nprovideRenderers(props.renderers);\n</script>\n"],"names":["_a","_openBlock","_createBlock","_resolveDynamicComponent","_createElementBlock","_mergeProps","_unref","_renderSlot","UIRoot","_createVNode","AutoMenuRenderer"],"mappings":";;;;AAIO,MAAM,cAAc,MAAM,UAAoB,SAAS,EAAE;AACzD,MAAM,kBAAkB,MAAM,cAAwB,SAAS,EAAE;AAMjE,MAAM,aAAa,CAAC,eAAyC;AAClE,QAAM,EAAE,SAA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M;AAC7D,cAAI,WAAW,OAAO,OAAO;AAC3B,oBAAQ,cAAc,OAAO,MAAM,cAAA;AAAA,UACrC;AAAA,QACF,CAAC;AAAA,MACH;AAGA,UAAI,SAAS,OAAO;AAClB,2BAAmB,QAAQ,SAAS,MAAM,sBAAA;AAE1C,0BAAkB,SAAS,MAAM,kBAAkB,CAAC,UAAU;AAC5D,6BAAmB,QAAQ,MAAM;AAAA,QACnC,CAAC;AAAA,MACH;AAAA,IACF,CAAC;AAED,gBAAY,MAAM;AAChB,oBAAA;AACA;AACA;AAAA,IACF,CAAC;AAGD,UAAM,QAAQ,MAAM;AAClB,UAAI,QAAQ,SAAS,OAAO,OAAO;AACjC,qBAAA;AAAA,MACF;AAAA,IACF,CAAC;;AA7IC,aAAAF,UAAA,GAAAG,mBAMM,OANNC,WAMM;AAAA,iBALA;AAAA,QAAJ,KAAI;AAAA,MAAA,GACS,EAAA,GAAAC,MAAA,KAAA,GAAK,GAAM,UAAA,SAAS,EAChC,OAAO,EAAA,eAAA,cAAA,EAAA,CAAgC,GAAA;AAAA,QAExCC,WAAQ,KAAA,QAAA,SAAA;AAAA,MAAA;;;;;;;;;;;;;;;;ACiBZ,UAAM,QAAQ,SAAA;AA+Bd,UAAM,QAAQ;AAwCd,0BAAA;AACA,6BAAyB,MAAM,UAAU;AACzC,qBAAiB,MAAM,SAAS;;AA/F9B,aAAAN,UAAA,GAAAC,YAISM,+CAJOF,MAAA,KAAA,CAAK,CAAA,GAAA;AAAA,yBACnB,MAAQ;AAAA,UAARC,WAAQ,KAAA,QAAA,SAAA;AAAA,UAERE,YAAwEC,aAAA;AAAA,YAArD,YAAY,QAAA;AAAA,YAAa,WAAW,QAAA;AAAA,UAAA;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/vue/hooks/use-ui.ts","../../src/vue/hooks/use-ui-container.ts","../../src/vue/registries/anchor-registry.ts","../../src/vue/hooks/use-register-anchor.ts","../../src/vue/registries/component-registry.ts","../../src/vue/hooks/use-item-renderer.ts","../../src/vue/registries/renderers-registry.ts","../../src/vue/hooks/use-schema-renderer.ts","../../src/vue/hooks/use-selection-menu.ts","../../src/vue/auto-menu-renderer.vue","../../src/vue/root.vue","../../src/vue/provider.vue"],"sourcesContent":["import { ref, watch, computed, readonly, toValue, type MaybeRefOrGetter } from 'vue';\nimport { useCapability, usePlugin } from '@embedpdf/core/vue';\nimport { UIPlugin, UIDocumentState, UISchema } from '@embedpdf/plugin-ui';\n\nexport const useUIPlugin = () => usePlugin<UIPlugin>(UIPlugin.id);\nexport const useUICapability = () => useCapability<UIPlugin>(UIPlugin.id);\n\n/**\n * Hook for UI state for a specific document\n * @param documentId Document ID (can be ref, computed, getter, or plain value)\n */\nexport const useUIState = (documentId: MaybeRefOrGetter<string>) => {\n const { provides } = useUICapability();\n const state = ref<UIDocumentState | null>(null);\n\n watch(\n [provides, () => toValue(documentId)],\n ([providesValue, docId], _, onCleanup) => {\n if (!providesValue) {\n state.value = null;\n return;\n }\n\n const scope = providesValue.forDocument(docId);\n\n // Set initial state\n state.value = scope.getState();\n\n // Subscribe to all changes\n const unsubToolbar = scope.onToolbarChanged(() => {\n state.value = scope.getState();\n });\n const unsubSidebar = scope.onSidebarChanged(() => {\n state.value = scope.getState();\n });\n const unsubModal = scope.onModalChanged(() => {\n state.value = scope.getState();\n });\n const unsubMenu = scope.onMenuChanged(() => {\n state.value = scope.getState();\n });\n\n onCleanup(() => {\n unsubToolbar();\n unsubSidebar();\n unsubModal();\n unsubMenu();\n });\n },\n { immediate: true },\n );\n\n // Return a computed ref for the scoped capability\n const scopedProvides = computed(() => {\n const docId = toValue(documentId);\n return provides.value?.forDocument(docId) ?? null;\n });\n\n return {\n provides: scopedProvides,\n state: readonly(state),\n };\n};\n\n/**\n * Hook to get UI schema\n */\nexport const useUISchema = () => {\n const { provides } = useUICapability();\n const schema = computed<UISchema | null>(() => provides.value?.getSchema() ?? null);\n\n return readonly(schema);\n};\n","import { inject, type Ref, type InjectionKey } from 'vue';\n\nexport interface UIContainerContextValue {\n /** Reference to the UIRoot container element */\n containerRef: Ref<HTMLDivElement | null>;\n /** Get the container element (may be null if not mounted) */\n getContainer: () => HTMLDivElement | null;\n}\n\nexport const UI_CONTAINER_KEY: InjectionKey<UIContainerContextValue> = Symbol('ui-container');\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 * ```vue\n * <script setup>\n * import { useUIContainer } from '@embedpdf/plugin-ui/vue';\n * import { onMounted, onUnmounted } from 'vue';\n *\n * const { containerRef, getContainer } = useUIContainer();\n *\n * onMounted(() => {\n * const container = getContainer();\n * if (!container) return;\n *\n * const observer = new ResizeObserver(() => {\n * console.log('Container width:', container.clientWidth);\n * });\n * observer.observe(container);\n *\n * onUnmounted(() => observer.disconnect());\n * });\n * </script>\n * ```\n */\nexport function useUIContainer(): UIContainerContextValue {\n const context = inject(UI_CONTAINER_KEY);\n if (!context) {\n throw new Error('useUIContainer must be used within a UIProvider');\n }\n return context;\n}\n","import { ref, inject, provide, type InjectionKey, type Ref } from 'vue';\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 AnchorRegistryKey: InjectionKey<AnchorRegistry> = Symbol('AnchorRegistry');\n\nexport function createAnchorRegistry(): AnchorRegistry {\n const anchors: Ref<Map<string, HTMLElement>> = ref(new Map());\n\n return {\n register(documentId: string, itemId: string, element: HTMLElement) {\n const key = `${documentId}:${itemId}`;\n anchors.value.set(key, element);\n },\n\n unregister(documentId: string, itemId: string) {\n const key = `${documentId}:${itemId}`;\n anchors.value.delete(key);\n },\n\n getAnchor(documentId: string, itemId: string) {\n const key = `${documentId}:${itemId}`;\n return anchors.value.get(key) || null;\n },\n };\n}\n\nexport function provideAnchorRegistry() {\n const registry = createAnchorRegistry();\n provide(AnchorRegistryKey, registry);\n return registry;\n}\n\nexport function useAnchorRegistry(): AnchorRegistry {\n const registry = inject(AnchorRegistryKey);\n if (!registry) {\n throw new Error('useAnchorRegistry must be used within UIProvider');\n }\n return registry;\n}\n","import { onBeforeUnmount, ref, watch } from 'vue';\nimport { useAnchorRegistry } from '../registries/anchor-registry';\n\n/**\n * Register a DOM element as an anchor for menus\n *\n * @param documentId - Document ID\n * @param itemId - Item ID (typically matches the toolbar/menu item ID)\n * @returns Ref to attach to the element (use with :ref=\"anchorRef\")\n *\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * const anchorRef = useRegisterAnchor(props.documentId, 'zoom-button');\n * </script>\n *\n * <template>\n * <button :ref=\"anchorRef\">Zoom</button>\n * </template>\n * ```\n */\nexport function useRegisterAnchor(documentId: string, itemId: string) {\n const registry = useAnchorRegistry();\n const elementRef = ref<HTMLElement | null>(null);\n\n // Function to set ref\n const setRef = (el: any) => {\n // Handle Vue 3 ref binding\n const element = el?.$el || el;\n\n // Unregister previous element if exists\n if (elementRef.value && elementRef.value !== element) {\n registry.unregister(documentId, itemId);\n }\n\n elementRef.value = element;\n\n // Register new element\n if (element) {\n registry.register(documentId, itemId, element);\n }\n };\n\n // Cleanup on unmount\n onBeforeUnmount(() => {\n if (elementRef.value) {\n registry.unregister(documentId, itemId);\n }\n });\n\n return setRef;\n}\n","import { ref, inject, provide, type Component, type InjectionKey, type Ref } from 'vue';\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 ComponentRegistryKey: InjectionKey<ComponentRegistry> = Symbol('ComponentRegistry');\n\nexport function createComponentRegistry(\n initialComponents: Record<string, Component<BaseComponentProps>> = {},\n): ComponentRegistry {\n const components: Ref<Map<string, Component<BaseComponentProps>>> = ref(\n new Map(Object.entries(initialComponents)),\n );\n\n return {\n register(id: string, component: Component<BaseComponentProps>) {\n components.value.set(id, component);\n },\n\n unregister(id: string) {\n components.value.delete(id);\n },\n\n get(id: string) {\n return components.value.get(id);\n },\n\n has(id: string) {\n return components.value.has(id);\n },\n\n getRegisteredIds() {\n return Array.from(components.value.keys());\n },\n };\n}\n\nexport function provideComponentRegistry(\n initialComponents: Record<string, Component<BaseComponentProps>> = {},\n) {\n const registry = createComponentRegistry(initialComponents);\n provide(ComponentRegistryKey, registry);\n return registry;\n}\n\nexport function useComponentRegistry(): ComponentRegistry {\n const registry = inject(ComponentRegistryKey);\n if (!registry) {\n throw new Error('useComponentRegistry must be used within UIProvider');\n }\n return registry;\n}\n","import { h } from 'vue';\nimport { useComponentRegistry } from '../registries/component-registry';\n\n/**\n * Helper utilities for building renderers\n */\nexport function useItemRenderer() {\n const componentRegistry = useComponentRegistry();\n\n return {\n /**\n * Render a custom component by ID\n *\n * @param componentId - Component ID from schema\n * @param documentId - Document ID\n * @param props - Additional props to pass to component\n * @returns Rendered component or null if not found\n */\n renderCustomComponent: (componentId: string, documentId: string, props?: any) => {\n const Component = componentRegistry.get(componentId);\n\n if (!Component) {\n console.error(`Component \"${componentId}\" not found in registry`);\n return null;\n }\n\n return h(Component, { documentId, ...(props || {}) });\n },\n };\n}\n","import { inject, provide, type InjectionKey } from 'vue';\nimport type { UIRenderers } from '../types';\n\n/**\n * Renderers Registry\n *\n * Provides access to user-supplied renderers (toolbar, panel, menu).\n */\nconst RenderersKey: InjectionKey<UIRenderers> = Symbol('Renderers');\n\nexport function provideRenderers(renderers: UIRenderers) {\n provide(RenderersKey, renderers);\n}\n\nexport function useRenderers(): UIRenderers {\n const renderers = inject(RenderersKey);\n if (!renderers) {\n throw new Error('useRenderers must be used within UIProvider');\n }\n return renderers;\n}\n","import { h, toValue, type VNode, type MaybeRefOrGetter } from 'vue';\nimport { useUICapability, useUIState } from './use-ui';\nimport { useRenderers } from '../registries/renderers-registry';\n\n/**\n * High-level composable for rendering UI from schema\n *\n * Provides simple functions to render toolbars, sidebars, and modals.\n * Always passes isOpen state to renderers so they can control animations.\n *\n * Automatically subscribes to UI state changes for the given document.\n * @param documentId Document ID (can be ref, computed, getter, or plain value)\n */\nexport function useSchemaRenderer(documentId: MaybeRefOrGetter<string>) {\n const renderers = useRenderers();\n const { provides } = useUICapability();\n const { state: uiState } = useUIState(documentId);\n\n return {\n /**\n * Render a toolbar by placement and slot\n *\n * Always renders with isOpen state when toolbar exists in slot.\n *\n * @param placement - 'top' | 'bottom' | 'left' | 'right'\n * @param slot - Slot name (e.g. 'main', 'secondary')\n *\n * @example\n * ```vue\n * <component :is=\"renderToolbar('top', 'main')\" />\n * <component :is=\"renderToolbar('top', 'secondary')\" />\n * ```\n */\n renderToolbar: (placement: 'top' | 'bottom' | 'left' | 'right', slot: string): VNode | null => {\n const schema = provides.value?.getSchema();\n\n if (!schema || !provides.value || !uiState.value) return null;\n\n const slotKey = `${placement}-${slot}`;\n const toolbarSlot = uiState.value.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 provides.value?.forDocument(toValue(documentId)).closeToolbarSlot(placement, slot);\n }\n : undefined;\n\n const ToolbarRenderer = renderers.toolbar;\n\n // ALWAYS render, pass isOpen state\n return h(ToolbarRenderer, {\n key: toolbarSlot.toolbarId,\n schema: toolbarSchema,\n documentId: toValue(documentId),\n isOpen: toolbarSlot.isOpen,\n onClose: handleClose,\n });\n },\n\n /**\n * Render a sidebar by placement and slot\n *\n * ALWAYS renders (when sidebar exists in slot) with isOpen state.\n * Your renderer controls whether to display or animate.\n *\n * @param placement - 'left' | 'right' | 'top' | 'bottom'\n * @param slot - Slot name (e.g. 'main', 'secondary', 'inspector')\n *\n * @example\n * ```vue\n * <component :is=\"renderSidebar('left', 'main')\" />\n * <component :is=\"renderSidebar('right', 'main')\" />\n * ```\n */\n renderSidebar: (placement: 'left' | 'right' | 'top' | 'bottom', slot: string): VNode | null => {\n const schema = provides.value?.getSchema();\n\n if (!schema || !provides.value || !uiState.value) return null;\n\n const slotKey = `${placement}-${slot}`;\n const sidebarSlot = uiState.value.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 provides.value?.forDocument(toValue(documentId)).closeSidebarSlot(placement, slot);\n };\n\n const SidebarRenderer = renderers.sidebar;\n\n // ALWAYS render, pass isOpen state\n return h(SidebarRenderer, {\n key: sidebarSlot.sidebarId,\n schema: sidebarSchema,\n documentId: toValue(documentId),\n isOpen: sidebarSlot.isOpen,\n onClose: handleClose,\n });\n },\n\n /**\n * Render the active modal (if any)\n *\n * Only one modal can be active at a time.\n * Modals are defined in schema.modals.\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 * @example\n * ```vue\n * <component :is=\"renderModal()\" />\n * ```\n */\n renderModal: (): VNode | null => {\n const schema = provides.value?.getSchema();\n\n if (!schema || !provides.value || !uiState.value?.activeModal) return null;\n\n const { modalId, isOpen } = uiState.value.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 provides.value?.forDocument(toValue(documentId)).closeModal();\n };\n\n const handleExited = () => {\n provides.value?.forDocument(toValue(documentId)).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 h(ModalRenderer, {\n key: modalId,\n schema: modalSchema,\n documentId: toValue(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.value) return [];\n return Object.entries(uiState.value.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.value) return [];\n return Object.entries(uiState.value.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 * Render 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 * ```vue\n * <div class=\"relative\">\n * <slot />\n * <component :is=\"renderOverlays()\" />\n * </div>\n * ```\n */\n renderOverlays: (): VNode[] | null => {\n const schema = provides.value?.getSchema();\n\n if (!schema?.overlays || !provides.value) return null;\n\n const OverlayRenderer = renderers.overlay;\n if (!OverlayRenderer) {\n return null;\n }\n\n const overlays = Object.values(schema.overlays);\n if (overlays.length === 0) return null;\n\n return overlays.map((overlaySchema) =>\n h(OverlayRenderer, {\n key: overlaySchema.id,\n schema: overlaySchema,\n documentId: toValue(documentId),\n }),\n );\n },\n };\n}\n","import { computed, h, toValue, type VNode, type MaybeRefOrGetter } from 'vue';\nimport type { SelectionMenuPropsBase, SelectionMenuRenderFn } from '@embedpdf/utils/vue';\nimport { useUICapability } from './use-ui';\nimport { useRenderers } from '../registries/renderers-registry';\n\n/**\n * Creates a render function for a selection menu from the schema\n *\n * @param menuId - The selection menu ID from schema\n * @param documentId - Document ID (can be ref, computed, getter, or plain value)\n * @returns A computed ref containing the render function or undefined\n *\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * const annotationMenu = useSelectionMenu('annotation', () => props.documentId);\n * </script>\n *\n * <template>\n * <AnnotationLayer\n * :documentId=\"documentId\"\n * :selectionMenu=\"annotationMenu\"\n * />\n * </template>\n * ```\n */\nexport function useSelectionMenu<TContext extends { type: string } = { type: string }>(\n menuId: MaybeRefOrGetter<string>,\n documentId: MaybeRefOrGetter<string>,\n) {\n const { provides } = useUICapability();\n const renderers = useRenderers();\n\n const schema = computed(() => provides.value?.getSchema());\n const menuSchema = computed(() => schema.value?.selectionMenus?.[toValue(menuId)]);\n\n // Return a computed that produces the render function (or undefined)\n const renderFn = computed<SelectionMenuRenderFn<TContext> | undefined>(() => {\n // If no schema for this menu, return undefined\n if (!menuSchema.value) {\n return undefined;\n }\n\n // Capture current values for the closure\n const currentMenuSchema = menuSchema.value;\n const currentDocumentId = toValue(documentId);\n const SelectionMenuRenderer = renderers.selectionMenu;\n\n // Return the render function\n return (props: SelectionMenuPropsBase<TContext>): VNode | null => {\n if (!props.selected) {\n return null;\n }\n\n return h(SelectionMenuRenderer, {\n schema: currentMenuSchema,\n documentId: currentDocumentId,\n props,\n });\n };\n });\n\n return renderFn;\n}\n","<template>\n <component\n v-if=\"activeMenu && menuSchema && MenuRenderer\"\n :is=\"MenuRenderer\"\n :schema=\"menuSchema\"\n :documentId=\"documentId\"\n :anchorEl=\"activeMenu.anchorEl\"\n :onClose=\"handleClose\"\n :container=\"container\"\n />\n</template>\n\n<script setup lang=\"ts\">\nimport { ref, computed, watch } from 'vue';\nimport { useUIState, useUICapability } from './hooks/use-ui';\nimport { useAnchorRegistry } from './registries/anchor-registry';\nimport { useRenderers } from './registries/renderers-registry';\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\ninterface Props {\n documentId: string; // Which document's menus to render\n container?: HTMLElement | null;\n}\n\nconst props = defineProps<Props>();\n\nconst { state: uiState } = useUIState(props.documentId);\nconst { provides } = useUICapability();\nconst anchorRegistry = useAnchorRegistry();\nconst renderers = useRenderers();\n\nconst activeMenu = ref<{\n menuId: string;\n anchorEl: HTMLElement | null;\n} | null>(null);\n\nconst openMenus = computed(() => uiState.value?.openMenus || {});\nconst schema = computed(() => provides.value?.getSchema());\n\n// Update active menu when state changes\nwatch(\n openMenus,\n (menus) => {\n const openMenuIds = Object.keys(menus);\n\n if (openMenuIds.length > 0) {\n // Show the first open menu (in practice, should only be one)\n const menuId = openMenuIds[0];\n if (!menuId) {\n activeMenu.value = null;\n return;\n }\n\n const menuState = menus[menuId];\n if (menuState && menuState.triggeredByItemId) {\n // Look up anchor with documentId scope\n const anchor = anchorRegistry.getAnchor(props.documentId, menuState.triggeredByItemId);\n activeMenu.value = { menuId, anchorEl: anchor };\n } else {\n activeMenu.value = null;\n }\n } else {\n activeMenu.value = null;\n }\n },\n { immediate: true },\n);\n\nconst menuSchema = computed(() => {\n if (!activeMenu.value || !schema.value) return null;\n\n const menuSchemaValue = schema.value.menus[activeMenu.value.menuId];\n if (!menuSchemaValue) {\n console.warn(`Menu \"${activeMenu.value.menuId}\" not found in schema`);\n return null;\n }\n\n return menuSchemaValue;\n});\n\nconst handleClose = () => {\n if (activeMenu.value) {\n provides.value?.forDocument(props.documentId).closeMenu(activeMenu.value.menuId);\n }\n};\n\n// Use the user-provided menu renderer\nconst MenuRenderer = computed(() => renderers.menu);\n</script>\n","<template>\n <div\n ref=\"rootRef\"\n v-bind=\"{ ...attrs, ...(rootAttrs as any) }\"\n :style=\"{ containerType: 'inline-size' }\"\n >\n <slot />\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { ref, computed, onMounted, onUnmounted, watch, useAttrs, provide } from 'vue';\nimport { UI_ATTRIBUTES, UI_SELECTORS } from '@embedpdf/plugin-ui';\nimport { useUIPlugin, useUICapability } from './hooks/use-ui';\nimport { UI_CONTAINER_KEY, type UIContainerContextValue } from './hooks/use-ui-container';\n\n// Disable automatic attribute inheritance since we handle it manually\ndefineOptions({\n inheritAttrs: false,\n});\n\nconst attrs = useAttrs();\n\nconst { plugin } = useUIPlugin();\nconst { provides } = useUICapability();\n\nconst disabledCategories = ref<string[]>([]);\nconst hiddenItems = ref<string[]>([]);\nconst rootRef = ref<HTMLDivElement | null>(null);\n\n// Provide container context for child components\nconst containerContext: UIContainerContextValue = {\n containerRef: rootRef,\n getContainer: () => rootRef.value,\n};\nprovide(UI_CONTAINER_KEY, containerContext);\n\nlet styleEl: HTMLStyleElement | null = null;\nlet styleTarget: HTMLElement | ShadowRoot | null = null;\n\n/**\n * Find the style injection target for an element.\n * Returns the shadow root if inside one, otherwise document.head.\n */\nfunction 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/**\n * Inject or update stylesheet\n */\nfunction injectStyles() {\n if (!rootRef.value || !plugin.value) {\n return;\n }\n\n styleTarget = getStyleTarget(rootRef.value);\n\n // Check if styles already exist in this target\n const existingStyle = styleTarget.querySelector(UI_SELECTORS.STYLES) as HTMLStyleElement | null;\n\n if (existingStyle) {\n styleEl = existingStyle;\n // Update content in case locale changed\n existingStyle.textContent = plugin.value.getStylesheet();\n return;\n }\n\n // Create and inject stylesheet\n const stylesheet = plugin.value.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\n/**\n * Cleanup styles\n */\nfunction cleanupStyles() {\n if (styleEl?.parentNode) {\n styleEl.remove();\n }\n styleEl = null;\n styleTarget = null;\n}\n\n// Build root element attributes\nconst rootAttrs = computed(() => {\n const result: Record<string, string> = {\n [UI_ATTRIBUTES.ROOT]: '',\n };\n\n if (disabledCategories.value.length > 0) {\n result[UI_ATTRIBUTES.DISABLED_CATEGORIES] = disabledCategories.value.join(' ');\n }\n\n if (hiddenItems.value.length > 0) {\n result[UI_ATTRIBUTES.HIDDEN_ITEMS] = hiddenItems.value.join(' ');\n }\n\n return result;\n});\n\n// Stylesheet invalidation cleanup\nlet stylesheetCleanup: (() => void) | null = null;\n\n// Category change cleanup\nlet categoryCleanup: (() => void) | null = null;\n\nonMounted(() => {\n // Inject styles on mount\n injectStyles();\n\n // Subscribe to stylesheet invalidation\n if (plugin.value) {\n stylesheetCleanup = plugin.value.onStylesheetInvalidated(() => {\n if (styleEl && plugin.value) {\n styleEl.textContent = plugin.value.getStylesheet();\n }\n });\n }\n\n // Subscribe to category changes\n if (provides.value) {\n disabledCategories.value = provides.value.getDisabledCategories();\n hiddenItems.value = provides.value.getHiddenItems();\n\n categoryCleanup = provides.value.onCategoryChanged((event) => {\n disabledCategories.value = event.disabledCategories;\n hiddenItems.value = event.hiddenItems;\n });\n }\n});\n\nonUnmounted(() => {\n cleanupStyles();\n stylesheetCleanup?.();\n categoryCleanup?.();\n});\n\n// Re-inject styles if plugin changes\nwatch(plugin, () => {\n if (rootRef.value && plugin.value) {\n injectStyles();\n }\n});\n</script>\n","<template>\n <UIRoot v-bind=\"attrs\">\n <slot />\n <!-- Automatically render menus for this document -->\n <AutoMenuRenderer :documentId=\"documentId\" :container=\"menuContainer\" />\n </UIRoot>\n</template>\n\n<script setup lang=\"ts\">\nimport type { Component } from 'vue';\nimport { useAttrs } from 'vue';\nimport { provideAnchorRegistry } from './registries/anchor-registry';\nimport { provideComponentRegistry } from './registries/component-registry';\nimport { provideRenderers } from './registries/renderers-registry';\nimport type { BaseComponentProps, UIRenderers } from './types';\nimport AutoMenuRenderer from './auto-menu-renderer.vue';\nimport UIRoot from './root.vue';\n\n// Disable automatic attribute inheritance since we pass them to UIRoot\ndefineOptions({\n inheritAttrs: false,\n});\n\nconst attrs = useAttrs();\n\n/**\n * UIProvider Props\n */\ninterface Props {\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?: Record<string, Component<BaseComponentProps>>;\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\nconst props = withDefaults(defineProps<Props>(), {\n components: () => ({}),\n menuContainer: null,\n});\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 * ```vue\n * <EmbedPDF :engine=\"engine\" :plugins=\"plugins\">\n * <template v-slot=\"{ pluginsReady, activeDocumentId }\">\n * <UIProvider\n * v-if=\"pluginsReady && activeDocumentId\"\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 * class=\"relative flex h-full w-full\"\n * >\n * <ViewerLayout />\n * </UIProvider>\n * </template>\n * </EmbedPDF>\n * ```\n */\n\n// Provide all registries\nprovideAnchorRegistry();\nprovideComponentRegistry(props.components);\nprovideRenderers(props.renderers);\n</script>\n"],"names":["_a","_openBlock","_createBlock","_resolveDynamicComponent","_createElementBlock","_mergeProps","_unref","_renderSlot","UIRoot","_createVNode","AutoMenuRenderer"],"mappings":";;;;A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Q,MAAM;AAClB,UAAI,QAAQ,SAAS,OAAO,OAAO;AACjC,qBAAA;AAAA,MACF;AAAA,IACF,CAAC;;AA5JC,aAAAF,UAAA,GAAAG,mBAMM,OANNC,WAMM;AAAA,iBALA;AAAA,QAAJ,KAAI;AAAA,MAAA,GACS,EAAA,GAAAC,MAAA,KAAA,GAAK,GAAM,UAAA,SAAS,EAChC,OAAO,EAAA,eAAA,cAAA,EAAA,CAAgC,GAAA;AAAA,QAExCC,WAAQ,KAAA,QAAA,SAAA;AAAA,MAAA;;;;;;;;;;;;;;;;ACiBZ,UAAM,QAAQ,SAAA;AA+Bd,UAAM,QAAQ;AAwCd,0BAAA;AACA,6BAAyB,MAAM,UAAU;AACzC,qBAAiB,MAAM,SAAS;;AA/F9B,aAAAN,UAAA,GAAAC,YAISM,+CAJOF,MAAA,KAAA,CAAK,CAAA,GAAA;AAAA,yBACnB,MAAQ;AAAA,UAARC,WAAQ,KAAA,QAAA,SAAA;AAAA,UAERE,YAAwEC,aAAA;AAAA,YAArD,YAAY,QAAA;AAAA,YAAa,WAAW,QAAA;AAAA,UAAA;;;;;;;"}
@@ -1,5 +1,5 @@
1
1
  import { Component } from 'vue';
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/vue';
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embedpdf/plugin-ui",
3
- "version": "2.0.0-next.1",
3
+ "version": "2.0.0-next.3",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.cjs",
@@ -35,18 +35,18 @@
35
35
  }
36
36
  },
37
37
  "dependencies": {
38
- "@embedpdf/models": "2.0.0-next.1"
38
+ "@embedpdf/models": "2.0.0-next.3"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/react": "^18.2.0",
42
42
  "typescript": "^5.0.0",
43
- "@embedpdf/core": "2.0.0-next.1",
43
+ "@embedpdf/core": "2.0.0-next.3",
44
44
  "@embedpdf/build": "1.1.0",
45
- "@embedpdf/plugin-scroll": "2.0.0-next.1",
46
- "@embedpdf/plugin-render": "2.0.0-next.1",
47
- "@embedpdf/plugin-viewport": "2.0.0-next.1",
48
- "@embedpdf/plugin-i18n": "2.0.0-next.1",
49
- "@embedpdf/utils": "2.0.0-next.1"
45
+ "@embedpdf/plugin-render": "2.0.0-next.3",
46
+ "@embedpdf/plugin-scroll": "2.0.0-next.3",
47
+ "@embedpdf/plugin-viewport": "2.0.0-next.3",
48
+ "@embedpdf/plugin-i18n": "2.0.0-next.3",
49
+ "@embedpdf/utils": "2.0.0-next.3"
50
50
  },
51
51
  "peerDependencies": {
52
52
  "react": ">=16.8.0",
@@ -54,10 +54,10 @@
54
54
  "preact": "^10.26.4",
55
55
  "vue": ">=3.2.0",
56
56
  "svelte": ">=5 <6",
57
- "@embedpdf/core": "2.0.0-next.1",
58
- "@embedpdf/plugin-render": "2.0.0-next.1",
59
- "@embedpdf/plugin-scroll": "2.0.0-next.1",
60
- "@embedpdf/plugin-viewport": "2.0.0-next.1"
57
+ "@embedpdf/core": "2.0.0-next.3",
58
+ "@embedpdf/plugin-viewport": "2.0.0-next.3",
59
+ "@embedpdf/plugin-scroll": "2.0.0-next.3",
60
+ "@embedpdf/plugin-render": "2.0.0-next.3"
61
61
  },
62
62
  "files": [
63
63
  "dist",