@embedpdf/plugin-ui 1.0.10 → 1.0.12

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 (50) hide show
  1. package/dist/index.cjs +2 -883
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.ts +1 -495
  4. package/dist/index.js +37 -56
  5. package/dist/index.js.map +1 -1
  6. package/dist/lib/actions.d.ts +88 -0
  7. package/dist/lib/icons/icon-manager.d.ts +47 -0
  8. package/dist/lib/icons/types.d.ts +36 -0
  9. package/dist/lib/index.d.ts +13 -0
  10. package/dist/lib/manifest.d.ts +4 -0
  11. package/dist/lib/menu/menu-manager.d.ts +98 -0
  12. package/dist/lib/menu/types.d.ts +83 -0
  13. package/dist/lib/menu/utils.d.ts +5 -0
  14. package/dist/lib/reducer.d.ts +5 -0
  15. package/dist/lib/types.d.ts +204 -0
  16. package/dist/lib/ui-component.d.ts +30 -0
  17. package/dist/lib/ui-plugin.d.ts +24 -0
  18. package/dist/lib/utils.d.ts +33 -0
  19. package/dist/preact/adapter.d.ts +5 -0
  20. package/dist/preact/core.d.ts +1 -0
  21. package/dist/preact/index.cjs +2 -130
  22. package/dist/preact/index.cjs.map +1 -1
  23. package/dist/preact/index.d.ts +1 -70
  24. package/dist/preact/index.js +19 -26
  25. package/dist/preact/index.js.map +1 -1
  26. package/dist/react/adapter.d.ts +2 -0
  27. package/dist/react/core.d.ts +1 -0
  28. package/dist/react/index.cjs +2 -2
  29. package/dist/react/index.cjs.map +1 -1
  30. package/dist/react/index.d.ts +1 -2
  31. package/dist/react/index.js +92 -1
  32. package/dist/react/index.js.map +1 -1
  33. package/dist/shared-preact/components/component-wrapper.d.ts +5 -0
  34. package/dist/shared-preact/components/index.d.ts +1 -0
  35. package/dist/shared-preact/components/plugin-ui-provider.d.ts +37 -0
  36. package/dist/shared-preact/hooks/index.d.ts +2 -0
  37. package/dist/shared-preact/hooks/use-icon.d.ts +15 -0
  38. package/dist/shared-preact/hooks/use-ui.d.ts +11 -0
  39. package/dist/shared-preact/index.d.ts +2 -0
  40. package/dist/shared-react/components/component-wrapper.d.ts +5 -0
  41. package/dist/shared-react/components/index.d.ts +1 -0
  42. package/dist/shared-react/components/plugin-ui-provider.d.ts +37 -0
  43. package/dist/shared-react/hooks/index.d.ts +2 -0
  44. package/dist/shared-react/hooks/use-icon.d.ts +15 -0
  45. package/dist/shared-react/hooks/use-ui.d.ts +11 -0
  46. package/dist/shared-react/index.d.ts +2 -0
  47. package/package.json +14 -11
  48. package/dist/index.d.cts +0 -495
  49. package/dist/preact/index.d.cts +0 -70
  50. package/dist/react/index.d.cts +0 -2
@@ -0,0 +1,47 @@
1
+ import { Icon, IconCapabilities, IconIdentifier, IconRegistry } from './types';
2
+ /**
3
+ * Registry for managing icons throughout the application
4
+ */
5
+ export declare class IconManager {
6
+ private icons;
7
+ constructor(icons: Icon[] | IconRegistry);
8
+ /**
9
+ * Register a single icon
10
+ */
11
+ registerIcon(icon: Icon): void;
12
+ /**
13
+ * Register multiple icons at once
14
+ */
15
+ registerIcons(icons: Icon[] | IconRegistry): void;
16
+ /**
17
+ * Get all registered icons
18
+ */
19
+ getAllIcons(): IconRegistry;
20
+ /**
21
+ * Get an icon by its ID
22
+ */
23
+ getIcon(id: string): Icon | undefined;
24
+ /**
25
+ * Check if an identifier is an SVG string
26
+ */
27
+ isSvgString(identifier: IconIdentifier): boolean;
28
+ /**
29
+ * Check if a string is an SVG data URI
30
+ */
31
+ isSvgDataUri(value: string): boolean;
32
+ /**
33
+ * Get the SVG string for an icon identifier
34
+ * If the identifier is a raw SVG string, it is returned as is
35
+ * If the identifier is an icon ID, the registered SVG is returned
36
+ */
37
+ getSvgString(identifier: IconIdentifier): string | undefined;
38
+ /**
39
+ * Utility method to parse a data URI
40
+ */
41
+ dataUriToSvgString(dataUri: string): string;
42
+ /**
43
+ * Convert an SVG string to a data URI
44
+ */
45
+ svgStringToDataUri(svgString: string): string;
46
+ capabilities(): IconCapabilities;
47
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Represents an icon in the icon registry
3
+ */
4
+ export interface Icon {
5
+ id: string;
6
+ svg: string;
7
+ }
8
+ /**
9
+ * Record type for icon registry
10
+ */
11
+ export type IconRegistry = Record<string, Icon>;
12
+ /**
13
+ * An identifier for an icon that can be either a registered icon id or raw SVG
14
+ */
15
+ export type IconIdentifier = string;
16
+ /**
17
+ * Options for rendering an icon
18
+ */
19
+ export interface IconRenderOptions {
20
+ className?: string;
21
+ title?: string;
22
+ }
23
+ /**
24
+ * Capabilities for the IconManager
25
+ */
26
+ export interface IconCapabilities {
27
+ registerIcon: (icon: Icon) => void;
28
+ registerIcons: (icons: Icon[] | IconRegistry) => void;
29
+ getIcon: (id: string) => Icon | undefined;
30
+ getAllIcons: () => IconRegistry;
31
+ getSvgString: (identifier: IconIdentifier) => string | undefined;
32
+ isSvgString: (identifier: IconIdentifier) => boolean;
33
+ isSvgDataUri: (value: string) => boolean;
34
+ dataUriToSvgString: (dataUri: string) => string;
35
+ svgStringToDataUri: (svgString: string) => string;
36
+ }
@@ -0,0 +1,13 @@
1
+ import { PluginPackage } from '@embedpdf/core';
2
+ 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';
7
+ export * from './ui-plugin';
8
+ export * from './types';
9
+ export * from './ui-component';
10
+ export * from './utils';
11
+ export * from './menu/types';
12
+ export * from './icons/types';
13
+ export * from './menu/utils';
@@ -0,0 +1,4 @@
1
+ import { PluginManifest } from '@embedpdf/core';
2
+ import { UIPluginConfig } from './types';
3
+ export declare const UI_PLUGIN_ID = "ui";
4
+ export declare const manifest: PluginManifest<UIPluginConfig>;
@@ -0,0 +1,98 @@
1
+ import { PluginRegistry } from '@embedpdf/core';
2
+ import { MenuItem, ExecuteOptions, ResolvedMenuItem, MenuRegistry, MenuManagerCapabilities, ResolvedMenuItemResult, ResolvedMenu, ResolvedAction } from './types';
3
+ import { EventCallback } from '../utils';
4
+ /**
5
+ * MenuManager manages a registry of menu items and handles their execution.
6
+ * It also manages keyboard shortcuts and implements responsive behavior.
7
+ */
8
+ export declare class MenuManager {
9
+ private registry;
10
+ private shortcutMap;
11
+ private eventController;
12
+ private pluginRegistry;
13
+ static readonly EVENTS: {
14
+ COMMAND_EXECUTED: string;
15
+ MENU_REQUESTED: string;
16
+ SHORTCUT_EXECUTED: string;
17
+ };
18
+ constructor(items: MenuRegistry | undefined, pluginRegistry: PluginRegistry);
19
+ /**
20
+ * Get the current state of the plugin registry
21
+ */
22
+ private get state();
23
+ /**
24
+ * Register a single menu item
25
+ */
26
+ registerItem(item: MenuItem): void;
27
+ /**
28
+ * Register multiple menu items at once
29
+ */
30
+ registerItems(items: MenuRegistry): void;
31
+ /**
32
+ * Resolve a menu item by ID
33
+ */
34
+ resolve(id: string): ResolvedMenuItem;
35
+ /**
36
+ * Get a menu item by ID with type information
37
+ */
38
+ getMenuItem(id: string): ResolvedMenuItemResult | undefined;
39
+ /**
40
+ * Get a action by ID (only returns Action type items)
41
+ */
42
+ getAction(id: string): ResolvedAction | undefined;
43
+ /**
44
+ * Get menu or action by ID
45
+ */
46
+ getMenuOrAction(id: string): ResolvedMenu | ResolvedAction | undefined;
47
+ /**
48
+ * Get all registered menu items
49
+ */
50
+ getAllItems(): MenuRegistry;
51
+ /**
52
+ * Get menu items by their IDs
53
+ */
54
+ getItemsByIds(ids: string[]): ResolvedMenuItem[];
55
+ /**
56
+ * Get child items for a given menu ID
57
+ * If flatten is true, it will recursively include submenu children but not groups
58
+ */
59
+ getChildItems(menuId: string, options?: {
60
+ flatten?: boolean;
61
+ }): ResolvedMenuItem[];
62
+ /**
63
+ * Execute a command by ID
64
+ */
65
+ executeCommand(id: string, options?: ExecuteOptions): void;
66
+ /**
67
+ * Execute a command from a keyboard shortcut
68
+ */
69
+ executeShortcut(shortcut: string): boolean;
70
+ /**
71
+ * Subscribe to menu events
72
+ */
73
+ on(eventType: string, callback: EventCallback): () => void;
74
+ /**
75
+ * Remove an event subscription
76
+ */
77
+ off(eventType: string, callback: EventCallback): void;
78
+ /**
79
+ * Handle a menu item that has children (showing a submenu)
80
+ */
81
+ private handleSubmenu;
82
+ /**
83
+ * Set up keyboard listeners for shortcuts
84
+ */
85
+ private setupKeyboardListeners;
86
+ /**
87
+ * Convert a KeyboardEvent to a shortcut string
88
+ */
89
+ private buildShortcutString;
90
+ /**
91
+ * Normalize a shortcut string for consistent comparison
92
+ */
93
+ private normalizeShortcut;
94
+ /**
95
+ * Get capabilities for the MenuManager
96
+ */
97
+ capabilities(): MenuManagerCapabilities;
98
+ }
@@ -0,0 +1,83 @@
1
+ import { PluginRegistry } from '@embedpdf/core';
2
+ export type Dynamic<TStore, T> = T | ((state: TStore) => T);
3
+ export interface MenuItemBase<TStore = any> {
4
+ icon?: Dynamic<TStore, string>;
5
+ label: Dynamic<TStore, string>;
6
+ active?: Dynamic<TStore, boolean>;
7
+ disabled?: Dynamic<TStore, boolean>;
8
+ shortcut?: string;
9
+ shortcutLabel?: string;
10
+ visible?: Dynamic<TStore, boolean>;
11
+ dividerBefore?: boolean;
12
+ }
13
+ export interface Action<TStore = any> extends MenuItemBase<TStore> {
14
+ id: string;
15
+ type: 'action';
16
+ action: (registry: PluginRegistry, state: TStore) => void;
17
+ }
18
+ export interface Group<TStore = any> {
19
+ id: string;
20
+ type: 'group';
21
+ label: Dynamic<TStore, string>;
22
+ children: string[];
23
+ }
24
+ export interface Menu<TStore = any> extends MenuItemBase<TStore> {
25
+ id: string;
26
+ type: 'menu';
27
+ children: string[];
28
+ }
29
+ export type MenuItem<TStore = any> = Action<TStore> | Group | Menu<TStore>;
30
+ export type MenuRegistry = Record<string, MenuItem>;
31
+ export interface ExecuteOptions {
32
+ source?: 'click' | 'shortcut' | 'api';
33
+ triggerElement?: HTMLElement;
34
+ flatten?: boolean;
35
+ position?: 'top' | 'bottom' | 'left' | 'right';
36
+ }
37
+ export declare function hasActive<TStore>(command: MenuItem<TStore>): command is Action<TStore>;
38
+ export interface MenuManagerCapabilities {
39
+ registerItem: (commandItem: MenuItem) => void;
40
+ registerItems: (commands: MenuRegistry) => void;
41
+ executeCommand: (id: string, options?: ExecuteOptions) => void;
42
+ getAction: (id: string) => ResolvedAction | undefined;
43
+ getMenuOrAction: (id: string) => ResolvedMenu | ResolvedAction | undefined;
44
+ getChildItems: (commandId: string, options?: {
45
+ flatten?: boolean;
46
+ }) => ResolvedMenuItem[];
47
+ getItemsByIds: (ids: string[]) => ResolvedMenuItem[];
48
+ getAllItems: () => MenuRegistry;
49
+ }
50
+ export type Resolved<TStore, T> = T extends Dynamic<TStore, infer U> ? U : T;
51
+ export interface ResolvedMenuItemBase<TStore = any> {
52
+ icon?: string;
53
+ label: string;
54
+ active?: boolean;
55
+ disabled?: boolean;
56
+ shortcut?: string;
57
+ shortcutLabel?: string;
58
+ visible?: boolean;
59
+ dividerBefore?: boolean;
60
+ }
61
+ export interface ResolvedAction<TStore = any> extends ResolvedMenuItemBase<TStore> {
62
+ id: string;
63
+ type: 'action';
64
+ action: (registry: PluginRegistry, state: TStore) => void;
65
+ }
66
+ export interface ResolvedGroup<TStore = any> {
67
+ id: string;
68
+ type: 'group';
69
+ label: string;
70
+ children: string[];
71
+ }
72
+ export interface ResolvedMenu<TStore = any> extends ResolvedMenuItemBase<TStore> {
73
+ id: string;
74
+ type: 'menu';
75
+ children: string[];
76
+ }
77
+ export type ResolvedMenuItem<TStore = any> = ResolvedAction<TStore> | ResolvedGroup<TStore> | ResolvedMenu<TStore>;
78
+ export interface ResolvedMenuItemResult<TStore = any> {
79
+ item: ResolvedMenuItem<TStore>;
80
+ isGroup: boolean;
81
+ isMenu: boolean;
82
+ isAction: boolean;
83
+ }
@@ -0,0 +1,5 @@
1
+ import { MenuItem, ResolvedMenuItem } from './types';
2
+ export declare function resolveMenuItem<TStore>(item: MenuItem<TStore>, state: TStore): ResolvedMenuItem<TStore>;
3
+ export declare function isActive<TStore>(item: MenuItem<TStore>, state: TStore): boolean;
4
+ export declare function isVisible<TStore>(item: MenuItem<TStore>, state: TStore): boolean;
5
+ export declare function isDisabled<TStore>(item: MenuItem<TStore>, state: TStore): boolean;
@@ -0,0 +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>;
@@ -0,0 +1,204 @@
1
+ import { CoreState } from '@embedpdf/core';
2
+ import { UI_PLUGIN_ID } from './manifest';
3
+ import { UIComponent } from './ui-component';
4
+ import { MenuRegistry, MenuManagerCapabilities } from './menu/types';
5
+ import { IconRegistry, IconCapabilities } from './icons/types';
6
+ import { SetHeaderVisiblePayload, TogglePanelPayload, UpdateComponentStatePayload } from './actions';
7
+ export interface UIPluginConfig {
8
+ enabled: boolean;
9
+ components: Record<string, UIComponentType>;
10
+ menuItems?: MenuRegistry;
11
+ icons?: IconRegistry;
12
+ }
13
+ export interface UIPluginState {
14
+ panel: {
15
+ [id: string]: PanelState;
16
+ };
17
+ header: {
18
+ [id: string]: HeaderState;
19
+ };
20
+ groupedItems: {
21
+ [id: string]: {};
22
+ };
23
+ divider: {
24
+ [id: string]: {};
25
+ };
26
+ iconButton: {
27
+ [id: string]: {};
28
+ };
29
+ tabButton: {
30
+ [id: string]: {};
31
+ };
32
+ selectButton: {
33
+ [id: string]: {};
34
+ };
35
+ custom: {
36
+ [id: string]: any;
37
+ };
38
+ floating: {
39
+ [id: string]: FloatingState;
40
+ };
41
+ commandMenu: {
42
+ [id: string]: CommandMenuState;
43
+ };
44
+ }
45
+ export type NavbarPlacement = 'top' | 'bottom' | 'left' | 'right';
46
+ export interface childrenFunctionOptions {
47
+ context?: Record<string, any>;
48
+ filter?: (childId: string) => boolean;
49
+ }
50
+ export type UICapability = IconCapabilities & MenuManagerCapabilities & {
51
+ registerComponentRenderer: (type: string, renderer: (props: any, children: (options?: childrenFunctionOptions) => any[], context?: Record<string, any>) => any) => void;
52
+ getComponent: <T extends BaseUIComponent<any, any, any>>(id: string) => UIComponent<T> | undefined;
53
+ getCommandMenu: () => UIComponent<CommandMenuComponent> | undefined;
54
+ hideCommandMenu: () => void;
55
+ getHeadersByPlacement: (placement: 'top' | 'bottom' | 'left' | 'right') => UIComponent<HeaderComponent<any>>[];
56
+ getPanelsByLocation: (location: 'left' | 'right') => UIComponent<PanelComponent<any>>[];
57
+ getFloatingComponents: (viewportPosition?: 'inside' | 'outside') => UIComponent<FloatingComponent>[];
58
+ addSlot: (parentId: string, slotId: string, priority?: number) => void;
59
+ registerComponent: (componentId: string, componentProps: UIComponentType) => UIComponent<any>;
60
+ togglePanel: (payload: TogglePanelPayload) => void;
61
+ setHeaderVisible: (payload: SetHeaderVisiblePayload) => void;
62
+ updateComponentState: <T>(payload: UpdateComponentStatePayload<T>) => void;
63
+ };
64
+ export interface BaseUIComponent<TProps, TInitial = undefined, TStore = any> {
65
+ id: string;
66
+ type: string;
67
+ render?: string;
68
+ /**
69
+ * A function that returns a context object for the component's children.
70
+ */
71
+ getChildContext?: ((props: TProps) => Record<string, any>) | Record<string, any>;
72
+ /**
73
+ * A function that returns a partial set of props from the initial state.
74
+ */
75
+ props?: ((init: TInitial) => TProps) | TProps;
76
+ /**
77
+ * An object containing the initial state for the component, typed as TInitial.
78
+ */
79
+ initialState?: TInitial;
80
+ /**
81
+ * A function that, on store changes, returns new or changed props to update
82
+ * the component with (Redux-like).
83
+ */
84
+ mapStateToProps?: (storeState: TStore, ownProps: TProps) => TProps;
85
+ }
86
+ export interface Slot {
87
+ componentId: string;
88
+ priority: number;
89
+ className?: string;
90
+ }
91
+ export interface PanelState {
92
+ open: boolean;
93
+ visibleChild: string | null;
94
+ }
95
+ export interface PanelProps {
96
+ location: 'left' | 'right';
97
+ open: boolean;
98
+ visibleChild: string | null;
99
+ [name: string]: any;
100
+ }
101
+ export interface PanelComponent<TStore = any> extends BaseUIComponent<PanelProps, PanelState, TStore> {
102
+ type: 'panel';
103
+ slots: Slot[];
104
+ }
105
+ export interface HeaderState {
106
+ visible?: boolean;
107
+ visibleChild?: string | null;
108
+ }
109
+ export interface HeaderProps {
110
+ placement: 'top' | 'bottom' | 'left' | 'right';
111
+ style?: Record<string, string>;
112
+ visible?: boolean;
113
+ visibleChild?: string | null;
114
+ }
115
+ export interface HeaderComponent<TStore = any> extends BaseUIComponent<HeaderProps, HeaderState, TStore> {
116
+ type: 'header';
117
+ slots: Slot[];
118
+ }
119
+ export interface GroupedItemsProps {
120
+ justifyContent?: 'start' | 'center' | 'end';
121
+ grow?: number;
122
+ gap?: number;
123
+ }
124
+ export interface GroupedItemsComponent<TStore = any> extends BaseUIComponent<GroupedItemsProps, undefined, TStore> {
125
+ type: 'groupedItems';
126
+ slots: Slot[];
127
+ }
128
+ export interface DividerComponent<TStore = any> extends BaseUIComponent<undefined, undefined, TStore> {
129
+ type: 'divider';
130
+ }
131
+ export interface IconButtonProps {
132
+ active?: boolean;
133
+ disabled?: boolean;
134
+ commandId?: string;
135
+ onClick?: () => void;
136
+ label?: string;
137
+ img?: string;
138
+ color?: string;
139
+ }
140
+ export interface IconButtonComponent<TStore = any> extends BaseUIComponent<IconButtonProps, undefined, TStore> {
141
+ type: 'iconButton';
142
+ }
143
+ export interface TabButtonProps {
144
+ active?: boolean;
145
+ commandId?: string;
146
+ onClick?: () => void;
147
+ label: string;
148
+ }
149
+ export interface TabButtonComponent<TStore = any> extends BaseUIComponent<TabButtonProps, undefined, TStore> {
150
+ type: 'tabButton';
151
+ }
152
+ export interface SelectButtonProps {
153
+ active?: boolean;
154
+ commandIds: string[];
155
+ menuCommandId: string;
156
+ activeCommandId: string;
157
+ }
158
+ export interface SelectButtonComponent<TStore = any> extends BaseUIComponent<SelectButtonProps, undefined, TStore> {
159
+ type: 'selectButton';
160
+ }
161
+ export interface CustomComponent<TStore = any> extends BaseUIComponent<any, any, TStore> {
162
+ type: 'custom';
163
+ render: string;
164
+ slots?: Slot[];
165
+ }
166
+ export interface FloatingState {
167
+ [name: string]: any;
168
+ }
169
+ export interface FloatingComponentProps {
170
+ scrollerPosition: 'inside' | 'outside';
171
+ [name: string]: any;
172
+ }
173
+ export interface FloatingComponent<TStore = any> extends BaseUIComponent<FloatingComponentProps, FloatingState, TStore> {
174
+ type: 'floating';
175
+ slots?: Slot[];
176
+ }
177
+ export interface CommandMenuState {
178
+ triggerElement?: HTMLElement;
179
+ activeCommand: string | null;
180
+ open: boolean;
181
+ position?: 'top' | 'bottom' | 'left' | 'right';
182
+ flatten?: boolean;
183
+ }
184
+ export interface CommandMenuProps {
185
+ triggerElement?: HTMLElement;
186
+ activeCommand: string | null;
187
+ open: boolean;
188
+ position?: 'top' | 'bottom' | 'left' | 'right';
189
+ flatten?: boolean;
190
+ }
191
+ export interface CommandMenuComponent<TStore = any> extends BaseUIComponent<CommandMenuProps, CommandMenuState, TStore> {
192
+ type: 'commandMenu';
193
+ }
194
+ export type WithComponentId<TProps> = TProps & {
195
+ id: string;
196
+ };
197
+ export type ComponentRenderFunction<TProps> = (props: WithComponentId<TProps>, children: (options?: childrenFunctionOptions) => any[], context?: Record<string, any>) => any;
198
+ export interface GlobalStoreState<TPlugins extends Record<string, any> = {}> {
199
+ core: CoreState;
200
+ plugins: {
201
+ [UI_PLUGIN_ID]: UIPluginState;
202
+ } & TPlugins;
203
+ }
204
+ export type UIComponentType<TStore = any> = GroupedItemsComponent<TStore> | DividerComponent<TStore> | IconButtonComponent<TStore> | TabButtonComponent<TStore> | HeaderComponent<TStore> | PanelComponent<TStore> | CustomComponent<TStore> | FloatingComponent<TStore> | CommandMenuComponent<TStore> | SelectButtonComponent<TStore>;
@@ -0,0 +1,30 @@
1
+ import { BaseUIComponent, childrenFunctionOptions } from './types';
2
+ export declare class UIComponent<T extends BaseUIComponent<any, any, any>> {
3
+ componentConfig: T;
4
+ props: T['id'] extends string ? T extends BaseUIComponent<infer P, any, any> ? P & {
5
+ id: string;
6
+ } : any : any;
7
+ type: string;
8
+ private children;
9
+ private registry;
10
+ private updateCallbacks;
11
+ private hadUpdateBeforeListeners;
12
+ constructor(componentConfig: T, registry: Record<string, (props: any, children: (options?: childrenFunctionOptions) => any[], context?: Record<string, any>) => any>);
13
+ addChild(id: string, child: UIComponent<any>, priority?: number, className?: string): void;
14
+ private sortChildren;
15
+ removeChild(child: UIComponent<any>): void;
16
+ clearChildren(): void;
17
+ get getRenderType(): string;
18
+ getRenderer(): (props: any, children: (options?: childrenFunctionOptions) => any[], context?: Record<string, any>) => any;
19
+ getChildren(): {
20
+ id: string;
21
+ component: UIComponent<any>;
22
+ priority: number;
23
+ className?: string;
24
+ }[];
25
+ getChildContext(context: Record<string, any>): Record<string, any>;
26
+ update(newProps: Partial<T extends BaseUIComponent<infer P, any, any> ? P : any>): void;
27
+ onUpdate(callback: () => void): boolean;
28
+ offUpdate(callback: () => void): void;
29
+ protected notifyUpdate(): void;
30
+ }
@@ -0,0 +1,24 @@
1
+ import { BasePlugin, PluginRegistry } from '@embedpdf/core';
2
+ import { UICapability, UIPluginConfig, UIPluginState } from './types';
3
+ import { UIPluginAction } from './actions';
4
+ export declare class UIPlugin extends BasePlugin<UIPluginConfig, UICapability, UIPluginState, UIPluginAction> {
5
+ static readonly id: "ui";
6
+ private componentRenderers;
7
+ private components;
8
+ private config;
9
+ private mapStateCallbacks;
10
+ private globalStoreSubscription;
11
+ private menuManager;
12
+ private iconManager;
13
+ constructor(id: string, registry: PluginRegistry, config: UIPluginConfig);
14
+ initialize(): Promise<void>;
15
+ private setupCommandEventHandlers;
16
+ private addComponent;
17
+ private buildComponents;
18
+ private linkGroupedItems;
19
+ private setInitialStateUIComponents;
20
+ private onGlobalStoreChange;
21
+ private addSlot;
22
+ protected buildCapability(): UICapability;
23
+ destroy(): Promise<void>;
24
+ }
@@ -0,0 +1,33 @@
1
+ import { CustomComponent } from './types';
2
+ export declare function defineComponent<TInit, TProps, TStore = any>(): <C extends CustomComponent<TStore> & {
3
+ initialState: TInit;
4
+ props: (init: TInit) => TProps;
5
+ mapStateToProps: (storeState: TStore, ownProps: TProps) => TProps;
6
+ }>(c: C) => C;
7
+ /**
8
+ * Type definition for event callbacks
9
+ */
10
+ export type EventCallback = (data: any) => void;
11
+ /**
12
+ * Interface for the event controller
13
+ */
14
+ export interface EventController {
15
+ /**
16
+ * Emit an event of the specified type with the given data
17
+ */
18
+ emit(eventType: string, data: any): void;
19
+ /**
20
+ * Subscribe to events of the specified type
21
+ * Returns a function that can be called to unsubscribe
22
+ */
23
+ on(eventType: string, callback: EventCallback): () => void;
24
+ /**
25
+ * Unsubscribe a specific callback from events of the specified type
26
+ */
27
+ off(eventType: string, callback: EventCallback): void;
28
+ }
29
+ /**
30
+ * Creates an event controller that manages event subscriptions and dispatching
31
+ * This is a lightweight pub/sub implementation for typed events
32
+ */
33
+ export declare function createEventController(): EventController;
@@ -0,0 +1,5 @@
1
+ export { Fragment } from 'preact';
2
+ export { useEffect, useRef, useState, useCallback, useMemo } from 'preact/hooks';
3
+ export type { ComponentChildren as ReactNode } from 'preact';
4
+ export type CSSProperties = import('preact').JSX.CSSProperties;
5
+ export type HTMLAttributes<T = any> = import('preact').JSX.HTMLAttributes<T extends EventTarget ? T : never>;
@@ -0,0 +1 @@
1
+ export * from '@embedpdf/core/preact';