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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +1313 -655
  4. package/dist/index.js.map +1 -1
  5. package/dist/lib/actions.d.ts +110 -74
  6. package/dist/lib/index.d.ts +8 -7
  7. package/dist/lib/reducer.d.ts +5 -5
  8. package/dist/lib/schema.d.ts +257 -0
  9. package/dist/lib/selectors.d.ts +16 -0
  10. package/dist/lib/types.d.ts +185 -202
  11. package/dist/lib/ui-plugin.d.ts +66 -18
  12. package/dist/lib/utils/consts.d.ts +25 -0
  13. package/dist/lib/utils/index.d.ts +5 -0
  14. package/dist/lib/utils/responsive-utils.d.ts +10 -0
  15. package/dist/lib/utils/schema-merger.d.ts +15 -0
  16. package/dist/lib/utils/stylesheet-generator.d.ts +40 -0
  17. package/dist/lib/utils/ui-props.d.ts +14 -0
  18. package/dist/preact/adapter.d.ts +4 -2
  19. package/dist/preact/index.cjs +1 -1
  20. package/dist/preact/index.cjs.map +1 -1
  21. package/dist/preact/index.js +450 -49
  22. package/dist/preact/index.js.map +1 -1
  23. package/dist/preact/utils.d.ts +1 -0
  24. package/dist/react/adapter.d.ts +2 -2
  25. package/dist/react/index.cjs +1 -1
  26. package/dist/react/index.cjs.map +1 -1
  27. package/dist/react/index.js +449 -48
  28. package/dist/react/index.js.map +1 -1
  29. package/dist/react/utils.d.ts +1 -0
  30. package/dist/shared/auto-menu-renderer.d.ts +13 -0
  31. package/dist/shared/hooks/index.d.ts +4 -0
  32. package/dist/shared/hooks/use-item-renderer.d.ts +14 -0
  33. package/dist/shared/hooks/use-register-anchor.d.ts +17 -0
  34. package/dist/shared/hooks/use-schema-renderer.d.ts +61 -0
  35. package/dist/shared/hooks/use-selection-menu.d.ts +11 -0
  36. package/dist/shared/hooks/use-ui.d.ts +13 -5
  37. package/dist/shared/index.d.ts +4 -1
  38. package/dist/shared/provider.d.ts +68 -0
  39. package/dist/shared/registries/anchor-registry.d.ts +16 -0
  40. package/dist/shared/registries/component-registry.d.ts +20 -0
  41. package/dist/shared/registries/index.d.ts +3 -0
  42. package/dist/shared/registries/renderers-registry.d.ts +8 -0
  43. package/dist/shared/root.d.ts +12 -0
  44. package/dist/shared/types.d.ts +67 -0
  45. package/dist/shared-preact/auto-menu-renderer.d.ts +13 -0
  46. package/dist/shared-preact/hooks/index.d.ts +4 -0
  47. package/dist/shared-preact/hooks/use-item-renderer.d.ts +14 -0
  48. package/dist/shared-preact/hooks/use-register-anchor.d.ts +17 -0
  49. package/dist/shared-preact/hooks/use-schema-renderer.d.ts +61 -0
  50. package/dist/shared-preact/hooks/use-selection-menu.d.ts +11 -0
  51. package/dist/shared-preact/hooks/use-ui.d.ts +13 -5
  52. package/dist/shared-preact/index.d.ts +4 -1
  53. package/dist/shared-preact/provider.d.ts +68 -0
  54. package/dist/shared-preact/registries/anchor-registry.d.ts +16 -0
  55. package/dist/shared-preact/registries/component-registry.d.ts +20 -0
  56. package/dist/shared-preact/registries/index.d.ts +3 -0
  57. package/dist/shared-preact/registries/renderers-registry.d.ts +8 -0
  58. package/dist/shared-preact/root.d.ts +12 -0
  59. package/dist/shared-preact/types.d.ts +67 -0
  60. package/dist/shared-react/auto-menu-renderer.d.ts +13 -0
  61. package/dist/shared-react/hooks/index.d.ts +4 -0
  62. package/dist/shared-react/hooks/use-item-renderer.d.ts +14 -0
  63. package/dist/shared-react/hooks/use-register-anchor.d.ts +17 -0
  64. package/dist/shared-react/hooks/use-schema-renderer.d.ts +61 -0
  65. package/dist/shared-react/hooks/use-selection-menu.d.ts +11 -0
  66. package/dist/shared-react/hooks/use-ui.d.ts +13 -5
  67. package/dist/shared-react/index.d.ts +4 -1
  68. package/dist/shared-react/provider.d.ts +68 -0
  69. package/dist/shared-react/registries/anchor-registry.d.ts +16 -0
  70. package/dist/shared-react/registries/component-registry.d.ts +20 -0
  71. package/dist/shared-react/registries/index.d.ts +3 -0
  72. package/dist/shared-react/registries/renderers-registry.d.ts +8 -0
  73. package/dist/shared-react/root.d.ts +12 -0
  74. package/dist/shared-react/types.d.ts +67 -0
  75. package/dist/svelte/auto-menu-renderer.svelte.d.ts +15 -0
  76. package/dist/svelte/hooks/index.d.ts +5 -0
  77. package/dist/svelte/hooks/use-item-renderer.svelte.d.ts +24 -0
  78. package/dist/svelte/hooks/use-register-anchor.svelte.d.ts +18 -0
  79. package/dist/svelte/hooks/use-schema-renderer.svelte.d.ts +78 -0
  80. package/dist/svelte/hooks/use-selection-menu.svelte.d.ts +9 -0
  81. package/dist/svelte/hooks/use-ui.svelte.d.ts +34 -0
  82. package/dist/svelte/index.cjs +2 -0
  83. package/dist/svelte/index.cjs.map +1 -0
  84. package/dist/svelte/index.d.ts +6 -0
  85. package/dist/svelte/index.js +553 -0
  86. package/dist/svelte/index.js.map +1 -0
  87. package/dist/svelte/provider.svelte.d.ts +33 -0
  88. package/dist/svelte/registries/anchor-registry.svelte.d.ts +14 -0
  89. package/dist/svelte/registries/component-registry.svelte.d.ts +17 -0
  90. package/dist/svelte/registries/index.d.ts +3 -0
  91. package/dist/svelte/registries/renderers-registry.svelte.d.ts +3 -0
  92. package/dist/svelte/root.svelte.d.ts +8 -0
  93. package/dist/svelte/types.d.ts +67 -0
  94. package/dist/vue/auto-menu-renderer.vue.d.ts +15 -0
  95. package/dist/vue/hooks/index.d.ts +5 -0
  96. package/dist/vue/hooks/use-item-renderer.d.ts +16 -0
  97. package/dist/vue/hooks/use-register-anchor.d.ts +19 -0
  98. package/dist/vue/hooks/use-schema-renderer.d.ts +63 -0
  99. package/dist/vue/hooks/use-selection-menu.d.ts +28 -0
  100. package/dist/vue/hooks/use-ui.d.ts +940 -0
  101. package/dist/vue/index.cjs +2 -0
  102. package/dist/vue/index.cjs.map +1 -0
  103. package/dist/vue/index.d.ts +6 -0
  104. package/dist/vue/index.js +544 -0
  105. package/dist/vue/index.js.map +1 -0
  106. package/dist/vue/provider.vue.d.ts +43 -0
  107. package/dist/vue/registries/anchor-registry.d.ts +14 -0
  108. package/dist/vue/registries/component-registry.d.ts +17 -0
  109. package/dist/vue/registries/index.d.ts +3 -0
  110. package/dist/vue/registries/renderers-registry.d.ts +3 -0
  111. package/dist/vue/root.vue.d.ts +13 -0
  112. package/dist/vue/types.d.ts +67 -0
  113. package/package.json +32 -9
  114. package/dist/lib/menu/menu-manager.d.ts +0 -98
  115. package/dist/lib/menu/types.d.ts +0 -91
  116. package/dist/lib/menu/utils.d.ts +0 -6
  117. package/dist/lib/ui-component.d.ts +0 -30
  118. package/dist/lib/utils.d.ts +0 -33
  119. package/dist/shared/components/component-wrapper.d.ts +0 -5
  120. package/dist/shared/components/index.d.ts +0 -1
  121. package/dist/shared/components/plugin-ui-provider.d.ts +0 -37
  122. package/dist/shared-preact/components/component-wrapper.d.ts +0 -5
  123. package/dist/shared-preact/components/index.d.ts +0 -1
  124. package/dist/shared-preact/components/plugin-ui-provider.d.ts +0 -37
  125. package/dist/shared-react/components/component-wrapper.d.ts +0 -5
  126. package/dist/shared-react/components/index.d.ts +0 -1
  127. package/dist/shared-react/components/plugin-ui-provider.d.ts +0 -37
@@ -1,12 +1,13 @@
1
1
  import { PluginPackage } from '@embedpdf/core';
2
+ import { UIPluginConfig, UIState } from './types';
2
3
  import { UIPlugin } from './ui-plugin';
3
- import { UIPluginConfig, UIPluginState } from './types';
4
- import { UIPluginAction } from './actions';
5
- export declare const UIPluginPackage: PluginPackage<UIPlugin, UIPluginConfig, UIPluginState, UIPluginAction>;
6
- export * from './manifest';
4
+ import { UIAction } from './actions';
5
+ export declare const UIPluginPackage: PluginPackage<UIPlugin, UIPluginConfig, UIState, UIAction>;
7
6
  export * from './ui-plugin';
8
7
  export * from './types';
9
- export * from './ui-component';
8
+ export * from './schema';
9
+ export * from './manifest';
10
10
  export * from './utils';
11
- export * from './menu/types';
12
- export * from './menu/utils';
11
+ export * from './selectors';
12
+ export * from './actions';
13
+ export { generateUIStylesheet, extractCategories, getStylesheetConfig, type StylesheetConfig, } from './utils/stylesheet-generator';
@@ -1,5 +1,5 @@
1
- import { Reducer } from '@embedpdf/core';
2
- import { UIPluginState } from './types';
3
- import { UIPluginAction } from './actions';
4
- export declare const initialState: UIPluginState;
5
- export declare const uiReducer: Reducer<UIPluginState, UIPluginAction>;
1
+ import { UIState, UIDocumentState } from './types';
2
+ import { UIAction } from './actions';
3
+ export declare const initialDocumentState: UIDocumentState;
4
+ export declare const initialState: UIState;
5
+ export declare const uiReducer: (state: UIState | undefined, action: UIAction) => UIState;
@@ -0,0 +1,257 @@
1
+ /**
2
+ * Top-level UI Schema
3
+ */
4
+ export interface UISchema {
5
+ id: string;
6
+ version: string;
7
+ toolbars: Record<string, ToolbarSchema>;
8
+ menus: Record<string, MenuSchema>;
9
+ panels: Record<string, PanelSchema>;
10
+ selectionMenus: Record<string, SelectionMenuSchema>;
11
+ }
12
+ export interface ToolbarPosition {
13
+ placement: 'top' | 'bottom' | 'left' | 'right';
14
+ slot?: string;
15
+ order?: number;
16
+ }
17
+ export interface VisibilityDependency {
18
+ /** Menu whose visible items determine this element's visibility */
19
+ menuId?: string;
20
+ /** Direct item IDs this element depends on */
21
+ itemIds?: string[];
22
+ }
23
+ export interface CustomComponentItem {
24
+ type: 'custom';
25
+ id: string;
26
+ componentId: string;
27
+ props?: Record<string, any>;
28
+ categories?: string[];
29
+ visibilityDependsOn?: VisibilityDependency;
30
+ }
31
+ /**
32
+ * Toolbar item types
33
+ */
34
+ export type ToolbarItem = CommandButtonItem | TabGroupItem | DividerItem | SpacerItem | GroupItem | CustomComponentItem;
35
+ /**
36
+ * Toolbar definition
37
+ */
38
+ export interface ToolbarSchema {
39
+ id: string;
40
+ position: ToolbarPosition;
41
+ permanent?: boolean;
42
+ items: ToolbarItem[];
43
+ responsive?: ResponsiveRules;
44
+ categories?: string[];
45
+ visibilityDependsOn?: VisibilityDependency;
46
+ }
47
+ export interface TabGroupItem {
48
+ type: 'tab-group';
49
+ id: string;
50
+ tabs: TabItem[];
51
+ defaultTab?: string;
52
+ variant?: 'pills' | 'underline' | 'enclosed';
53
+ alignment?: 'start' | 'center' | 'end';
54
+ categories?: string[];
55
+ visibilityDependsOn?: VisibilityDependency;
56
+ }
57
+ export interface TabItem {
58
+ id: string;
59
+ commandId: string;
60
+ variant?: 'icon' | 'text' | 'icon-text';
61
+ categories?: string[];
62
+ visibilityDependsOn?: VisibilityDependency;
63
+ }
64
+ export interface CommandButtonItem {
65
+ type: 'command-button';
66
+ id: string;
67
+ commandId: string;
68
+ variant?: 'icon' | 'text' | 'icon-text' | 'tab';
69
+ size?: 'sm' | 'md' | 'lg';
70
+ /** Categories this item belongs to (hidden when ANY category is disabled) */
71
+ categories?: string[];
72
+ visibilityDependsOn?: VisibilityDependency;
73
+ }
74
+ export interface DividerItem {
75
+ type: 'divider';
76
+ id: string;
77
+ orientation?: 'vertical' | 'horizontal';
78
+ categories?: string[];
79
+ visibilityDependsOn?: VisibilityDependency;
80
+ }
81
+ export interface SpacerItem {
82
+ type: 'spacer';
83
+ id: string;
84
+ flex?: boolean;
85
+ categories?: string[];
86
+ visibilityDependsOn?: VisibilityDependency;
87
+ }
88
+ export interface GroupItem {
89
+ type: 'group';
90
+ id: string;
91
+ items: ToolbarItem[];
92
+ gap?: number;
93
+ alignment?: 'start' | 'center' | 'end';
94
+ categories?: string[];
95
+ visibilityDependsOn?: VisibilityDependency;
96
+ }
97
+ /**
98
+ * Menu definition - pure structure, no trigger info
99
+ */
100
+ export interface MenuSchema {
101
+ id: string;
102
+ items: MenuItem[];
103
+ responsive?: ResponsiveRules;
104
+ categories?: string[];
105
+ visibilityDependsOn?: VisibilityDependency;
106
+ }
107
+ /**
108
+ * Menu item types
109
+ */
110
+ export type MenuItem = MenuCommandItem | MenuSectionItem | MenuSubmenuItem | MenuDividerItem | MenuCustomItem;
111
+ export interface MenuCommandItem {
112
+ type: 'command';
113
+ id: string;
114
+ commandId: string;
115
+ categories?: string[];
116
+ visibilityDependsOn?: VisibilityDependency;
117
+ }
118
+ export interface MenuSectionItem {
119
+ type: 'section';
120
+ id: string;
121
+ labelKey?: string;
122
+ label?: string;
123
+ items: MenuItem[];
124
+ categories?: string[];
125
+ visibilityDependsOn?: VisibilityDependency;
126
+ }
127
+ export interface MenuSubmenuItem {
128
+ type: 'submenu';
129
+ id: string;
130
+ labelKey?: string;
131
+ label?: string;
132
+ icon?: string;
133
+ menuId: string;
134
+ categories?: string[];
135
+ visibilityDependsOn?: VisibilityDependency;
136
+ }
137
+ export interface MenuDividerItem {
138
+ type: 'divider';
139
+ id: string;
140
+ categories?: string[];
141
+ visibilityDependsOn?: VisibilityDependency;
142
+ }
143
+ export interface MenuCustomItem {
144
+ type: 'custom';
145
+ id: string;
146
+ componentId: string;
147
+ props?: Record<string, any>;
148
+ categories?: string[];
149
+ visibilityDependsOn?: VisibilityDependency;
150
+ }
151
+ /**
152
+ * Panel definition (sidebars, overlays, modals)
153
+ */
154
+ export interface PanelSchema {
155
+ id: string;
156
+ type: 'sidebar' | 'overlay' | 'modal' | 'popover';
157
+ position?: PanelPosition;
158
+ content: PanelContent;
159
+ collapsible?: boolean;
160
+ defaultOpen?: boolean;
161
+ closeOnClickOutside?: boolean;
162
+ width?: string;
163
+ height?: string;
164
+ minWidth?: string;
165
+ minHeight?: string;
166
+ maxWidth?: string;
167
+ maxHeight?: string;
168
+ categories?: string[];
169
+ visibilityDependsOn?: VisibilityDependency;
170
+ }
171
+ export interface PanelPosition {
172
+ placement: 'left' | 'right' | 'top' | 'bottom';
173
+ slot?: string;
174
+ order?: number;
175
+ }
176
+ /**
177
+ * Panel content types
178
+ */
179
+ export type PanelContent = TabsPanelContent | ComponentPanelContent;
180
+ export interface TabsPanelContent {
181
+ type: 'tabs';
182
+ tabs: PanelTab[];
183
+ defaultTab?: string;
184
+ }
185
+ export interface PanelTab {
186
+ id: string;
187
+ labelKey?: string;
188
+ label?: string;
189
+ icon?: string;
190
+ componentId: string;
191
+ categories?: string[];
192
+ visibilityDependsOn?: VisibilityDependency;
193
+ }
194
+ export interface ComponentPanelContent {
195
+ type: 'component';
196
+ componentId: string;
197
+ props?: Record<string, any>;
198
+ }
199
+ export interface ResponsiveRules {
200
+ breakpoints: Record<string, BreakpointRule>;
201
+ localeOverrides?: LocaleOverrides;
202
+ }
203
+ export interface BreakpointRule {
204
+ minWidth?: number;
205
+ maxWidth?: number;
206
+ hide?: string[];
207
+ show?: string[];
208
+ }
209
+ /**
210
+ * Locale-based responsive overrides
211
+ * Allows grouping languages and adjusting show/hide rules per breakpoint
212
+ */
213
+ export interface LocaleOverrides {
214
+ groups: LocaleVisibilityGroup[];
215
+ }
216
+ export interface LocaleVisibilityGroup {
217
+ id: string;
218
+ locales: string[];
219
+ description?: string;
220
+ breakpoints: Record<string, LocaleBreakpointOverride>;
221
+ }
222
+ export interface LocaleBreakpointOverride {
223
+ hide?: string[];
224
+ show?: string[];
225
+ replaceHide?: string[];
226
+ replaceShow?: string[];
227
+ }
228
+ export type SelectionMenuItem = SelectionMenuCommandItem | SelectionMenuDividerItem | SelectionMenuGroupItem;
229
+ export interface SelectionMenuCommandItem {
230
+ type: 'command-button';
231
+ id: string;
232
+ commandId: string;
233
+ variant?: 'icon' | 'text' | 'icon-text';
234
+ categories?: string[];
235
+ visibilityDependsOn?: VisibilityDependency;
236
+ }
237
+ export interface SelectionMenuDividerItem {
238
+ type: 'divider';
239
+ id: string;
240
+ categories?: string[];
241
+ visibilityDependsOn?: VisibilityDependency;
242
+ }
243
+ export interface SelectionMenuGroupItem {
244
+ type: 'group';
245
+ id: string;
246
+ items: SelectionMenuItem[];
247
+ gap?: number;
248
+ categories?: string[];
249
+ visibilityDependsOn?: VisibilityDependency;
250
+ }
251
+ export interface SelectionMenuSchema {
252
+ id: string;
253
+ items: SelectionMenuItem[];
254
+ categories?: string[];
255
+ visibilityDependsOn?: VisibilityDependency;
256
+ responsive?: ResponsiveRules;
257
+ }
@@ -0,0 +1,16 @@
1
+ import { UIState, UIDocumentState, ToolbarSlotState, PanelSlotState } from './types';
2
+ export type PluginsSlice = Record<string, any>;
3
+ export declare function selectUIState(plugins: PluginsSlice): UIState | null;
4
+ export declare function selectUIDocumentState(plugins: PluginsSlice, documentId: string): UIDocumentState | null;
5
+ export declare function selectToolbarSlot(plugins: PluginsSlice, documentId: string, placement: string, slot: string): ToolbarSlotState | null;
6
+ /**
7
+ * Is a toolbar open in this slot?
8
+ * If toolbarId is provided, also matches that specific toolbar.
9
+ */
10
+ export declare function isToolbarOpen(plugins: PluginsSlice, documentId: string, placement: string, slot: string, toolbarId?: string): boolean;
11
+ export declare function selectPanelSlot(plugins: PluginsSlice, documentId: string, placement: string, slot: string): PanelSlotState | null;
12
+ /**
13
+ * Is a panel open in this slot?
14
+ * If panelId is provided, also matches that specific panel.
15
+ */
16
+ export declare function isPanelOpen(plugins: PluginsSlice, documentId: string, placement: string, slot: string, panelId?: string): boolean;