@embedpdf/plugin-ui 1.0.11 → 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.
- package/dist/index.cjs +2 -883
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -495
- package/dist/index.js +37 -56
- package/dist/index.js.map +1 -1
- package/dist/lib/actions.d.ts +88 -0
- package/dist/lib/icons/icon-manager.d.ts +47 -0
- package/dist/lib/icons/types.d.ts +36 -0
- package/dist/lib/index.d.ts +13 -0
- package/dist/lib/manifest.d.ts +4 -0
- package/dist/lib/menu/menu-manager.d.ts +98 -0
- package/dist/lib/menu/types.d.ts +83 -0
- package/dist/lib/menu/utils.d.ts +5 -0
- package/dist/lib/reducer.d.ts +5 -0
- package/dist/lib/types.d.ts +204 -0
- package/dist/lib/ui-component.d.ts +30 -0
- package/dist/lib/ui-plugin.d.ts +24 -0
- package/dist/lib/utils.d.ts +33 -0
- package/dist/preact/adapter.d.ts +5 -0
- package/dist/preact/core.d.ts +1 -0
- package/dist/preact/index.cjs +2 -130
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.d.ts +1 -70
- package/dist/preact/index.js +19 -26
- package/dist/preact/index.js.map +1 -1
- package/dist/react/adapter.d.ts +2 -0
- package/dist/react/core.d.ts +1 -0
- package/dist/react/index.cjs +2 -2
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.ts +1 -2
- package/dist/react/index.js +92 -1
- package/dist/react/index.js.map +1 -1
- package/dist/shared-preact/components/component-wrapper.d.ts +5 -0
- package/dist/shared-preact/components/index.d.ts +1 -0
- package/dist/shared-preact/components/plugin-ui-provider.d.ts +37 -0
- package/dist/shared-preact/hooks/index.d.ts +2 -0
- package/dist/shared-preact/hooks/use-icon.d.ts +15 -0
- package/dist/shared-preact/hooks/use-ui.d.ts +11 -0
- package/dist/shared-preact/index.d.ts +2 -0
- package/dist/shared-react/components/component-wrapper.d.ts +5 -0
- package/dist/shared-react/components/index.d.ts +1 -0
- package/dist/shared-react/components/plugin-ui-provider.d.ts +37 -0
- package/dist/shared-react/hooks/index.d.ts +2 -0
- package/dist/shared-react/hooks/use-icon.d.ts +15 -0
- package/dist/shared-react/hooks/use-ui.d.ts +11 -0
- package/dist/shared-react/index.d.ts +2 -0
- package/package.json +14 -11
- package/dist/index.d.cts +0 -495
- package/dist/preact/index.d.cts +0 -70
- package/dist/react/index.d.cts +0 -2
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { UIPlugin } from '../../lib/index.ts';
|
|
2
|
+
export declare const useUIPlugin: () => {
|
|
3
|
+
plugin: UIPlugin | null;
|
|
4
|
+
isLoading: boolean;
|
|
5
|
+
ready: Promise<void>;
|
|
6
|
+
};
|
|
7
|
+
export declare const useUICapability: () => {
|
|
8
|
+
provides: Readonly<import('../../lib/index.ts').UICapability> | null;
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
ready: Promise<void>;
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './plugin-ui-provider';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ReactNode } from '../../react/adapter.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Interface for UI components organized by type/location
|
|
4
|
+
*/
|
|
5
|
+
export interface UIComponentsMap {
|
|
6
|
+
headers: {
|
|
7
|
+
top: ReactNode[];
|
|
8
|
+
bottom: ReactNode[];
|
|
9
|
+
left: ReactNode[];
|
|
10
|
+
right: ReactNode[];
|
|
11
|
+
};
|
|
12
|
+
panels: {
|
|
13
|
+
left: ReactNode[];
|
|
14
|
+
right: ReactNode[];
|
|
15
|
+
};
|
|
16
|
+
floating: {
|
|
17
|
+
insideScroller: ReactNode[];
|
|
18
|
+
outsideScroller: ReactNode[];
|
|
19
|
+
};
|
|
20
|
+
commandMenu: ReactNode | null;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Props for the PluginUIProvider
|
|
24
|
+
*/
|
|
25
|
+
export interface PluginUIProviderProps {
|
|
26
|
+
/**
|
|
27
|
+
* Render function that receives UI components
|
|
28
|
+
*/
|
|
29
|
+
children: (components: UIComponentsMap) => ReactNode;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* PluginUIProvider collects all components from the UI plugin system
|
|
33
|
+
* and provides them to a render function without imposing any structure.
|
|
34
|
+
*
|
|
35
|
+
* It uses the render props pattern for maximum flexibility.
|
|
36
|
+
*/
|
|
37
|
+
export declare function PluginUIProvider({ children }: PluginUIProviderProps): ReactNode;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IconIdentifier, Icon as IconType, IconRegistry } from '../../lib/index.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Hook to access icon functionality in React
|
|
4
|
+
*/
|
|
5
|
+
export declare function useIcon(): {
|
|
6
|
+
registerIcon: (icon: IconType) => void;
|
|
7
|
+
registerIcons: (icons: IconType[] | IconRegistry) => void;
|
|
8
|
+
getIcon: (id: string) => IconType | undefined;
|
|
9
|
+
getAllIcons: () => IconRegistry;
|
|
10
|
+
getSvgString: (identifier: IconIdentifier) => string | undefined;
|
|
11
|
+
isSvgString: (identifier: IconIdentifier) => boolean;
|
|
12
|
+
isSvgDataUri: (value: string) => boolean;
|
|
13
|
+
dataUriToSvgString: (dataUri: string) => string;
|
|
14
|
+
svgStringToDataUri: (svgString: string) => string;
|
|
15
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { UIPlugin } from '../../lib/index.ts';
|
|
2
|
+
export declare const useUIPlugin: () => {
|
|
3
|
+
plugin: UIPlugin | null;
|
|
4
|
+
isLoading: boolean;
|
|
5
|
+
ready: Promise<void>;
|
|
6
|
+
};
|
|
7
|
+
export declare const useUICapability: () => {
|
|
8
|
+
provides: Readonly<import('../../lib/index.ts').UICapability> | null;
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
ready: Promise<void>;
|
|
11
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embedpdf/plugin-ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -22,18 +22,20 @@
|
|
|
22
22
|
"require": "./dist/preact/index.cjs"
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@embedpdf/models": "1.0.12"
|
|
27
|
+
},
|
|
25
28
|
"devDependencies": {
|
|
26
29
|
"@types/react": "^18.2.0",
|
|
27
|
-
"tsup": "^8.0.0",
|
|
28
30
|
"typescript": "^5.0.0",
|
|
29
|
-
"@embedpdf/
|
|
30
|
-
"@embedpdf/
|
|
31
|
+
"@embedpdf/core": "1.0.12",
|
|
32
|
+
"@embedpdf/build": "1.0.0"
|
|
31
33
|
},
|
|
32
34
|
"peerDependencies": {
|
|
33
35
|
"react": ">=16.8.0",
|
|
34
36
|
"react-dom": ">=16.8.0",
|
|
35
37
|
"preact": "^10.26.4",
|
|
36
|
-
"@embedpdf/core": "1.0.
|
|
38
|
+
"@embedpdf/core": "1.0.12"
|
|
37
39
|
},
|
|
38
40
|
"files": [
|
|
39
41
|
"dist",
|
|
@@ -52,11 +54,12 @@
|
|
|
52
54
|
"access": "public"
|
|
53
55
|
},
|
|
54
56
|
"scripts": {
|
|
55
|
-
"build": "
|
|
56
|
-
"build:
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
57
|
+
"build:base": "vite build --mode base",
|
|
58
|
+
"build:react": "vite build --mode react",
|
|
59
|
+
"build:preact": "vite build --mode preact",
|
|
60
|
+
"build": "pnpm run clean && concurrently -c auto -n base,react,preact \"vite build --mode base\" \"vite build --mode react\" \"vite build --mode preact\"",
|
|
61
|
+
"clean": "rimraf dist",
|
|
62
|
+
"lint": "eslint src --color",
|
|
63
|
+
"lint:fix": "eslint src --color --fix"
|
|
61
64
|
}
|
|
62
65
|
}
|
package/dist/index.d.cts
DELETED
|
@@ -1,495 +0,0 @@
|
|
|
1
|
-
import { PluginManifest, PluginRegistry, Action as Action$1, CoreState, BasePlugin, PluginPackage } from '@embedpdf/core';
|
|
2
|
-
|
|
3
|
-
declare const UI_PLUGIN_ID = "ui";
|
|
4
|
-
declare const manifest: PluginManifest<UIPluginConfig>;
|
|
5
|
-
|
|
6
|
-
declare class UIComponent<T extends BaseUIComponent<any, any, any>> {
|
|
7
|
-
componentConfig: T;
|
|
8
|
-
props: T['id'] extends string ? T extends BaseUIComponent<infer P, any, any> ? P & {
|
|
9
|
-
id: string;
|
|
10
|
-
} : any : any;
|
|
11
|
-
type: string;
|
|
12
|
-
private children;
|
|
13
|
-
private registry;
|
|
14
|
-
private updateCallbacks;
|
|
15
|
-
private hadUpdateBeforeListeners;
|
|
16
|
-
constructor(componentConfig: T, registry: Record<string, (props: any, children: (options?: childrenFunctionOptions) => any[], context?: Record<string, any>) => any>);
|
|
17
|
-
addChild(id: string, child: UIComponent<any>, priority?: number, className?: string): void;
|
|
18
|
-
private sortChildren;
|
|
19
|
-
removeChild(child: UIComponent<any>): void;
|
|
20
|
-
clearChildren(): void;
|
|
21
|
-
get getRenderType(): string;
|
|
22
|
-
getRenderer(): (props: any, children: (options?: childrenFunctionOptions) => any[], context?: Record<string, any>) => any;
|
|
23
|
-
getChildren(): {
|
|
24
|
-
id: string;
|
|
25
|
-
component: UIComponent<any>;
|
|
26
|
-
priority: number;
|
|
27
|
-
className?: string;
|
|
28
|
-
}[];
|
|
29
|
-
getChildContext(context: Record<string, any>): Record<string, any>;
|
|
30
|
-
update(newProps: Partial<T extends BaseUIComponent<infer P, any, any> ? P : any>): void;
|
|
31
|
-
onUpdate(callback: () => void): boolean;
|
|
32
|
-
offUpdate(callback: () => void): void;
|
|
33
|
-
protected notifyUpdate(): void;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
type Dynamic<TStore, T> = T | ((state: TStore) => T);
|
|
37
|
-
interface MenuItemBase<TStore = any> {
|
|
38
|
-
icon?: Dynamic<TStore, string>;
|
|
39
|
-
label: Dynamic<TStore, string>;
|
|
40
|
-
active?: Dynamic<TStore, boolean>;
|
|
41
|
-
disabled?: Dynamic<TStore, boolean>;
|
|
42
|
-
shortcut?: string;
|
|
43
|
-
shortcutLabel?: string;
|
|
44
|
-
visible?: Dynamic<TStore, boolean>;
|
|
45
|
-
dividerBefore?: boolean;
|
|
46
|
-
}
|
|
47
|
-
interface Action<TStore = any> extends MenuItemBase<TStore> {
|
|
48
|
-
id: string;
|
|
49
|
-
type: 'action';
|
|
50
|
-
action: (registry: PluginRegistry, state: TStore) => void;
|
|
51
|
-
}
|
|
52
|
-
interface Group<TStore = any> {
|
|
53
|
-
id: string;
|
|
54
|
-
type: 'group';
|
|
55
|
-
label: Dynamic<TStore, string>;
|
|
56
|
-
children: string[];
|
|
57
|
-
}
|
|
58
|
-
interface Menu<TStore = any> extends MenuItemBase<TStore> {
|
|
59
|
-
id: string;
|
|
60
|
-
type: 'menu';
|
|
61
|
-
children: string[];
|
|
62
|
-
}
|
|
63
|
-
type MenuItem<TStore = any> = Action<TStore> | Group | Menu<TStore>;
|
|
64
|
-
type MenuRegistry = Record<string, MenuItem>;
|
|
65
|
-
interface ExecuteOptions {
|
|
66
|
-
source?: 'click' | 'shortcut' | 'api';
|
|
67
|
-
triggerElement?: HTMLElement;
|
|
68
|
-
flatten?: boolean;
|
|
69
|
-
position?: 'top' | 'bottom' | 'left' | 'right';
|
|
70
|
-
}
|
|
71
|
-
declare function hasActive<TStore>(command: MenuItem<TStore>): command is Action<TStore>;
|
|
72
|
-
interface MenuManagerCapabilities {
|
|
73
|
-
registerItem: (commandItem: MenuItem) => void;
|
|
74
|
-
registerItems: (commands: MenuRegistry) => void;
|
|
75
|
-
executeCommand: (id: string, options?: ExecuteOptions) => void;
|
|
76
|
-
getAction: (id: string) => ResolvedAction | undefined;
|
|
77
|
-
getMenuOrAction: (id: string) => ResolvedMenu | ResolvedAction | undefined;
|
|
78
|
-
getChildItems: (commandId: string, options?: {
|
|
79
|
-
flatten?: boolean;
|
|
80
|
-
}) => ResolvedMenuItem[];
|
|
81
|
-
getItemsByIds: (ids: string[]) => ResolvedMenuItem[];
|
|
82
|
-
getAllItems: () => MenuRegistry;
|
|
83
|
-
}
|
|
84
|
-
type Resolved<TStore, T> = T extends Dynamic<TStore, infer U> ? U : T;
|
|
85
|
-
interface ResolvedMenuItemBase<TStore = any> {
|
|
86
|
-
icon?: string;
|
|
87
|
-
label: string;
|
|
88
|
-
active?: boolean;
|
|
89
|
-
disabled?: boolean;
|
|
90
|
-
shortcut?: string;
|
|
91
|
-
shortcutLabel?: string;
|
|
92
|
-
visible?: boolean;
|
|
93
|
-
dividerBefore?: boolean;
|
|
94
|
-
}
|
|
95
|
-
interface ResolvedAction<TStore = any> extends ResolvedMenuItemBase<TStore> {
|
|
96
|
-
id: string;
|
|
97
|
-
type: 'action';
|
|
98
|
-
action: (registry: PluginRegistry, state: TStore) => void;
|
|
99
|
-
}
|
|
100
|
-
interface ResolvedGroup<TStore = any> {
|
|
101
|
-
id: string;
|
|
102
|
-
type: 'group';
|
|
103
|
-
label: string;
|
|
104
|
-
children: string[];
|
|
105
|
-
}
|
|
106
|
-
interface ResolvedMenu<TStore = any> extends ResolvedMenuItemBase<TStore> {
|
|
107
|
-
id: string;
|
|
108
|
-
type: 'menu';
|
|
109
|
-
children: string[];
|
|
110
|
-
}
|
|
111
|
-
type ResolvedMenuItem<TStore = any> = ResolvedAction<TStore> | ResolvedGroup<TStore> | ResolvedMenu<TStore>;
|
|
112
|
-
interface ResolvedMenuItemResult<TStore = any> {
|
|
113
|
-
item: ResolvedMenuItem<TStore>;
|
|
114
|
-
isGroup: boolean;
|
|
115
|
-
isMenu: boolean;
|
|
116
|
-
isAction: boolean;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Represents an icon in the icon registry
|
|
121
|
-
*/
|
|
122
|
-
interface Icon {
|
|
123
|
-
id: string;
|
|
124
|
-
svg: string;
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Record type for icon registry
|
|
128
|
-
*/
|
|
129
|
-
type IconRegistry = Record<string, Icon>;
|
|
130
|
-
/**
|
|
131
|
-
* An identifier for an icon that can be either a registered icon id or raw SVG
|
|
132
|
-
*/
|
|
133
|
-
type IconIdentifier = string;
|
|
134
|
-
/**
|
|
135
|
-
* Options for rendering an icon
|
|
136
|
-
*/
|
|
137
|
-
interface IconRenderOptions {
|
|
138
|
-
className?: string;
|
|
139
|
-
title?: string;
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Capabilities for the IconManager
|
|
143
|
-
*/
|
|
144
|
-
interface IconCapabilities {
|
|
145
|
-
registerIcon: (icon: Icon) => void;
|
|
146
|
-
registerIcons: (icons: Icon[] | IconRegistry) => void;
|
|
147
|
-
getIcon: (id: string) => Icon | undefined;
|
|
148
|
-
getAllIcons: () => IconRegistry;
|
|
149
|
-
getSvgString: (identifier: IconIdentifier) => string | undefined;
|
|
150
|
-
isSvgString: (identifier: IconIdentifier) => boolean;
|
|
151
|
-
isSvgDataUri: (value: string) => boolean;
|
|
152
|
-
dataUriToSvgString: (dataUri: string) => string;
|
|
153
|
-
svgStringToDataUri: (svgString: string) => string;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
declare const UI_INIT_COMPONENTS = "UI_INIT_COMPONENTS";
|
|
157
|
-
declare const UI_INIT_FLYOUT = "UI_INIT_FLYOUT";
|
|
158
|
-
declare const UI_TOGGLE_FLYOUT = "UI_TOGGLE_FLYOUT";
|
|
159
|
-
declare const UI_SET_HEADER_VISIBLE = "UI_SET_HEADER_VISIBLE";
|
|
160
|
-
declare const UI_TOGGLE_PANEL = "UI_TOGGLE_PANEL";
|
|
161
|
-
declare const UI_SHOW_COMMAND_MENU = "UI_SHOW_COMMAND_MENU";
|
|
162
|
-
declare const UI_HIDE_COMMAND_MENU = "UI_HIDE_COMMAND_MENU";
|
|
163
|
-
declare const UI_UPDATE_COMPONENT_STATE = "UI_UPDATE_COMPONENT_STATE";
|
|
164
|
-
interface InitFlyoutPayload {
|
|
165
|
-
id: string;
|
|
166
|
-
triggerElement: HTMLElement;
|
|
167
|
-
}
|
|
168
|
-
interface ToggleFlyoutPayload {
|
|
169
|
-
id: string;
|
|
170
|
-
open?: boolean;
|
|
171
|
-
}
|
|
172
|
-
interface SetHeaderVisiblePayload {
|
|
173
|
-
id: string;
|
|
174
|
-
visible: boolean;
|
|
175
|
-
visibleChild?: string;
|
|
176
|
-
}
|
|
177
|
-
interface TogglePanelPayload {
|
|
178
|
-
id: string;
|
|
179
|
-
open?: boolean;
|
|
180
|
-
visibleChild: string;
|
|
181
|
-
}
|
|
182
|
-
interface ShowCommandMenuPayload {
|
|
183
|
-
id: string;
|
|
184
|
-
commandId: string;
|
|
185
|
-
triggerElement?: HTMLElement;
|
|
186
|
-
position?: 'top' | 'bottom' | 'left' | 'right';
|
|
187
|
-
flatten?: boolean;
|
|
188
|
-
}
|
|
189
|
-
interface UpdateComponentStatePayload<T = any> {
|
|
190
|
-
/** one of the top-level keys inside UIPluginState, e.g. "panel" | "custom" … */
|
|
191
|
-
componentType: keyof UIPluginState;
|
|
192
|
-
/** same id you used when registering the component */
|
|
193
|
-
componentId: string;
|
|
194
|
-
/** partial patch – only keys existing in the current state will be applied */
|
|
195
|
-
patch: Partial<T>;
|
|
196
|
-
}
|
|
197
|
-
interface HideCommandMenuPayload {
|
|
198
|
-
id: string;
|
|
199
|
-
}
|
|
200
|
-
interface UiInitComponentsAction extends Action$1 {
|
|
201
|
-
type: typeof UI_INIT_COMPONENTS;
|
|
202
|
-
payload: UIPluginState;
|
|
203
|
-
}
|
|
204
|
-
interface UiInitFlyoutAction extends Action$1 {
|
|
205
|
-
type: typeof UI_INIT_FLYOUT;
|
|
206
|
-
payload: InitFlyoutPayload;
|
|
207
|
-
}
|
|
208
|
-
interface UiToggleFlyoutAction extends Action$1 {
|
|
209
|
-
type: typeof UI_TOGGLE_FLYOUT;
|
|
210
|
-
payload: ToggleFlyoutPayload;
|
|
211
|
-
}
|
|
212
|
-
interface UiSetHeaderVisibleAction extends Action$1 {
|
|
213
|
-
type: typeof UI_SET_HEADER_VISIBLE;
|
|
214
|
-
payload: SetHeaderVisiblePayload;
|
|
215
|
-
}
|
|
216
|
-
interface UiTogglePanelAction extends Action$1 {
|
|
217
|
-
type: typeof UI_TOGGLE_PANEL;
|
|
218
|
-
payload: TogglePanelPayload;
|
|
219
|
-
}
|
|
220
|
-
interface UiShowCommandMenuAction extends Action$1 {
|
|
221
|
-
type: typeof UI_SHOW_COMMAND_MENU;
|
|
222
|
-
payload: ShowCommandMenuPayload;
|
|
223
|
-
}
|
|
224
|
-
interface UiHideCommandMenuAction extends Action$1 {
|
|
225
|
-
type: typeof UI_HIDE_COMMAND_MENU;
|
|
226
|
-
payload: HideCommandMenuPayload;
|
|
227
|
-
}
|
|
228
|
-
interface UiUpdateComponentStateAction extends Action$1 {
|
|
229
|
-
type: typeof UI_UPDATE_COMPONENT_STATE;
|
|
230
|
-
payload: UpdateComponentStatePayload;
|
|
231
|
-
}
|
|
232
|
-
type UIPluginAction = UiInitComponentsAction | UiInitFlyoutAction | UiToggleFlyoutAction | UiSetHeaderVisibleAction | UiTogglePanelAction | UiShowCommandMenuAction | UiHideCommandMenuAction | UiUpdateComponentStateAction;
|
|
233
|
-
|
|
234
|
-
interface UIPluginConfig {
|
|
235
|
-
enabled: boolean;
|
|
236
|
-
components: Record<string, UIComponentType>;
|
|
237
|
-
menuItems?: MenuRegistry;
|
|
238
|
-
icons?: IconRegistry;
|
|
239
|
-
}
|
|
240
|
-
interface UIPluginState {
|
|
241
|
-
panel: {
|
|
242
|
-
[id: string]: PanelState;
|
|
243
|
-
};
|
|
244
|
-
header: {
|
|
245
|
-
[id: string]: HeaderState;
|
|
246
|
-
};
|
|
247
|
-
groupedItems: {
|
|
248
|
-
[id: string]: {};
|
|
249
|
-
};
|
|
250
|
-
divider: {
|
|
251
|
-
[id: string]: {};
|
|
252
|
-
};
|
|
253
|
-
iconButton: {
|
|
254
|
-
[id: string]: {};
|
|
255
|
-
};
|
|
256
|
-
tabButton: {
|
|
257
|
-
[id: string]: {};
|
|
258
|
-
};
|
|
259
|
-
selectButton: {
|
|
260
|
-
[id: string]: {};
|
|
261
|
-
};
|
|
262
|
-
custom: {
|
|
263
|
-
[id: string]: any;
|
|
264
|
-
};
|
|
265
|
-
floating: {
|
|
266
|
-
[id: string]: FloatingState;
|
|
267
|
-
};
|
|
268
|
-
commandMenu: {
|
|
269
|
-
[id: string]: CommandMenuState;
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
type NavbarPlacement = 'top' | 'bottom' | 'left' | 'right';
|
|
273
|
-
interface childrenFunctionOptions {
|
|
274
|
-
context?: Record<string, any>;
|
|
275
|
-
filter?: (childId: string) => boolean;
|
|
276
|
-
}
|
|
277
|
-
type UICapability = IconCapabilities & MenuManagerCapabilities & {
|
|
278
|
-
registerComponentRenderer: (type: string, renderer: (props: any, children: (options?: childrenFunctionOptions) => any[], context?: Record<string, any>) => any) => void;
|
|
279
|
-
getComponent: <T extends BaseUIComponent<any, any, any>>(id: string) => UIComponent<T> | undefined;
|
|
280
|
-
getCommandMenu: () => UIComponent<CommandMenuComponent> | undefined;
|
|
281
|
-
hideCommandMenu: () => void;
|
|
282
|
-
getHeadersByPlacement: (placement: 'top' | 'bottom' | 'left' | 'right') => UIComponent<HeaderComponent<any>>[];
|
|
283
|
-
getPanelsByLocation: (location: 'left' | 'right') => UIComponent<PanelComponent<any>>[];
|
|
284
|
-
getFloatingComponents: (viewportPosition?: 'inside' | 'outside') => UIComponent<FloatingComponent>[];
|
|
285
|
-
addSlot: (parentId: string, slotId: string, priority?: number) => void;
|
|
286
|
-
registerComponent: (componentId: string, componentProps: UIComponentType) => UIComponent<any>;
|
|
287
|
-
togglePanel: (payload: TogglePanelPayload) => void;
|
|
288
|
-
setHeaderVisible: (payload: SetHeaderVisiblePayload) => void;
|
|
289
|
-
updateComponentState: <T>(payload: UpdateComponentStatePayload<T>) => void;
|
|
290
|
-
};
|
|
291
|
-
interface BaseUIComponent<TProps, TInitial = undefined, TStore = any> {
|
|
292
|
-
id: string;
|
|
293
|
-
type: string;
|
|
294
|
-
render?: string;
|
|
295
|
-
/**
|
|
296
|
-
* A function that returns a context object for the component's children.
|
|
297
|
-
*/
|
|
298
|
-
getChildContext?: ((props: TProps) => Record<string, any>) | Record<string, any>;
|
|
299
|
-
/**
|
|
300
|
-
* A function that returns a partial set of props from the initial state.
|
|
301
|
-
*/
|
|
302
|
-
props?: ((init: TInitial) => TProps) | TProps;
|
|
303
|
-
/**
|
|
304
|
-
* An object containing the initial state for the component, typed as TInitial.
|
|
305
|
-
*/
|
|
306
|
-
initialState?: TInitial;
|
|
307
|
-
/**
|
|
308
|
-
* A function that, on store changes, returns new or changed props to update
|
|
309
|
-
* the component with (Redux-like).
|
|
310
|
-
*/
|
|
311
|
-
mapStateToProps?: (storeState: TStore, ownProps: TProps) => TProps;
|
|
312
|
-
}
|
|
313
|
-
interface Slot {
|
|
314
|
-
componentId: string;
|
|
315
|
-
priority: number;
|
|
316
|
-
className?: string;
|
|
317
|
-
}
|
|
318
|
-
interface PanelState {
|
|
319
|
-
open: boolean;
|
|
320
|
-
visibleChild: string | null;
|
|
321
|
-
}
|
|
322
|
-
interface PanelProps {
|
|
323
|
-
location: 'left' | 'right';
|
|
324
|
-
open: boolean;
|
|
325
|
-
visibleChild: string | null;
|
|
326
|
-
[name: string]: any;
|
|
327
|
-
}
|
|
328
|
-
interface PanelComponent<TStore = any> extends BaseUIComponent<PanelProps, PanelState, TStore> {
|
|
329
|
-
type: 'panel';
|
|
330
|
-
slots: Slot[];
|
|
331
|
-
}
|
|
332
|
-
interface HeaderState {
|
|
333
|
-
visible?: boolean;
|
|
334
|
-
visibleChild?: string | null;
|
|
335
|
-
}
|
|
336
|
-
interface HeaderProps {
|
|
337
|
-
placement: 'top' | 'bottom' | 'left' | 'right';
|
|
338
|
-
style?: Record<string, string>;
|
|
339
|
-
visible?: boolean;
|
|
340
|
-
visibleChild?: string | null;
|
|
341
|
-
}
|
|
342
|
-
interface HeaderComponent<TStore = any> extends BaseUIComponent<HeaderProps, HeaderState, TStore> {
|
|
343
|
-
type: 'header';
|
|
344
|
-
slots: Slot[];
|
|
345
|
-
}
|
|
346
|
-
interface GroupedItemsProps {
|
|
347
|
-
justifyContent?: 'start' | 'center' | 'end';
|
|
348
|
-
grow?: number;
|
|
349
|
-
gap?: number;
|
|
350
|
-
}
|
|
351
|
-
interface GroupedItemsComponent<TStore = any> extends BaseUIComponent<GroupedItemsProps, undefined, TStore> {
|
|
352
|
-
type: 'groupedItems';
|
|
353
|
-
slots: Slot[];
|
|
354
|
-
}
|
|
355
|
-
interface DividerComponent<TStore = any> extends BaseUIComponent<undefined, undefined, TStore> {
|
|
356
|
-
type: 'divider';
|
|
357
|
-
}
|
|
358
|
-
interface IconButtonProps {
|
|
359
|
-
active?: boolean;
|
|
360
|
-
disabled?: boolean;
|
|
361
|
-
commandId?: string;
|
|
362
|
-
onClick?: () => void;
|
|
363
|
-
label?: string;
|
|
364
|
-
img?: string;
|
|
365
|
-
color?: string;
|
|
366
|
-
}
|
|
367
|
-
interface IconButtonComponent<TStore = any> extends BaseUIComponent<IconButtonProps, undefined, TStore> {
|
|
368
|
-
type: 'iconButton';
|
|
369
|
-
}
|
|
370
|
-
interface TabButtonProps {
|
|
371
|
-
active?: boolean;
|
|
372
|
-
commandId?: string;
|
|
373
|
-
onClick?: () => void;
|
|
374
|
-
label: string;
|
|
375
|
-
}
|
|
376
|
-
interface TabButtonComponent<TStore = any> extends BaseUIComponent<TabButtonProps, undefined, TStore> {
|
|
377
|
-
type: 'tabButton';
|
|
378
|
-
}
|
|
379
|
-
interface SelectButtonProps {
|
|
380
|
-
active?: boolean;
|
|
381
|
-
commandIds: string[];
|
|
382
|
-
menuCommandId: string;
|
|
383
|
-
activeCommandId: string;
|
|
384
|
-
}
|
|
385
|
-
interface SelectButtonComponent<TStore = any> extends BaseUIComponent<SelectButtonProps, undefined, TStore> {
|
|
386
|
-
type: 'selectButton';
|
|
387
|
-
}
|
|
388
|
-
interface CustomComponent<TStore = any> extends BaseUIComponent<any, any, TStore> {
|
|
389
|
-
type: 'custom';
|
|
390
|
-
render: string;
|
|
391
|
-
slots?: Slot[];
|
|
392
|
-
}
|
|
393
|
-
interface FloatingState {
|
|
394
|
-
[name: string]: any;
|
|
395
|
-
}
|
|
396
|
-
interface FloatingComponentProps {
|
|
397
|
-
scrollerPosition: 'inside' | 'outside';
|
|
398
|
-
[name: string]: any;
|
|
399
|
-
}
|
|
400
|
-
interface FloatingComponent<TStore = any> extends BaseUIComponent<FloatingComponentProps, FloatingState, TStore> {
|
|
401
|
-
type: 'floating';
|
|
402
|
-
slots?: Slot[];
|
|
403
|
-
}
|
|
404
|
-
interface CommandMenuState {
|
|
405
|
-
triggerElement?: HTMLElement;
|
|
406
|
-
activeCommand: string | null;
|
|
407
|
-
open: boolean;
|
|
408
|
-
position?: 'top' | 'bottom' | 'left' | 'right';
|
|
409
|
-
flatten?: boolean;
|
|
410
|
-
}
|
|
411
|
-
interface CommandMenuProps {
|
|
412
|
-
triggerElement?: HTMLElement;
|
|
413
|
-
activeCommand: string | null;
|
|
414
|
-
open: boolean;
|
|
415
|
-
position?: 'top' | 'bottom' | 'left' | 'right';
|
|
416
|
-
flatten?: boolean;
|
|
417
|
-
}
|
|
418
|
-
interface CommandMenuComponent<TStore = any> extends BaseUIComponent<CommandMenuProps, CommandMenuState, TStore> {
|
|
419
|
-
type: 'commandMenu';
|
|
420
|
-
}
|
|
421
|
-
type WithComponentId<TProps> = TProps & {
|
|
422
|
-
id: string;
|
|
423
|
-
};
|
|
424
|
-
type ComponentRenderFunction<TProps> = (props: WithComponentId<TProps>, children: (options?: childrenFunctionOptions) => any[], context?: Record<string, any>) => any;
|
|
425
|
-
interface GlobalStoreState<TPlugins extends Record<string, any> = {}> {
|
|
426
|
-
core: CoreState;
|
|
427
|
-
plugins: {
|
|
428
|
-
[UI_PLUGIN_ID]: UIPluginState;
|
|
429
|
-
} & TPlugins;
|
|
430
|
-
}
|
|
431
|
-
type UIComponentType<TStore = any> = GroupedItemsComponent<TStore> | DividerComponent<TStore> | IconButtonComponent<TStore> | TabButtonComponent<TStore> | HeaderComponent<TStore> | PanelComponent<TStore> | CustomComponent<TStore> | FloatingComponent<TStore> | CommandMenuComponent<TStore> | SelectButtonComponent<TStore>;
|
|
432
|
-
|
|
433
|
-
declare class UIPlugin extends BasePlugin<UIPluginConfig, UICapability, UIPluginState, UIPluginAction> {
|
|
434
|
-
static readonly id: "ui";
|
|
435
|
-
private componentRenderers;
|
|
436
|
-
private components;
|
|
437
|
-
private config;
|
|
438
|
-
private mapStateCallbacks;
|
|
439
|
-
private globalStoreSubscription;
|
|
440
|
-
private menuManager;
|
|
441
|
-
private iconManager;
|
|
442
|
-
constructor(id: string, registry: PluginRegistry, config: UIPluginConfig);
|
|
443
|
-
initialize(): Promise<void>;
|
|
444
|
-
private setupCommandEventHandlers;
|
|
445
|
-
private addComponent;
|
|
446
|
-
private buildComponents;
|
|
447
|
-
private linkGroupedItems;
|
|
448
|
-
private setInitialStateUIComponents;
|
|
449
|
-
private onGlobalStoreChange;
|
|
450
|
-
private addSlot;
|
|
451
|
-
protected buildCapability(): UICapability;
|
|
452
|
-
destroy(): Promise<void>;
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
declare function defineComponent<TInit, TProps, TStore = any>(): <C extends CustomComponent<TStore> & {
|
|
456
|
-
initialState: TInit;
|
|
457
|
-
props: (init: TInit) => TProps;
|
|
458
|
-
mapStateToProps: (storeState: TStore, ownProps: TProps) => TProps;
|
|
459
|
-
}>(c: C) => C;
|
|
460
|
-
/**
|
|
461
|
-
* Type definition for event callbacks
|
|
462
|
-
*/
|
|
463
|
-
type EventCallback = (data: any) => void;
|
|
464
|
-
/**
|
|
465
|
-
* Interface for the event controller
|
|
466
|
-
*/
|
|
467
|
-
interface EventController {
|
|
468
|
-
/**
|
|
469
|
-
* Emit an event of the specified type with the given data
|
|
470
|
-
*/
|
|
471
|
-
emit(eventType: string, data: any): void;
|
|
472
|
-
/**
|
|
473
|
-
* Subscribe to events of the specified type
|
|
474
|
-
* Returns a function that can be called to unsubscribe
|
|
475
|
-
*/
|
|
476
|
-
on(eventType: string, callback: EventCallback): () => void;
|
|
477
|
-
/**
|
|
478
|
-
* Unsubscribe a specific callback from events of the specified type
|
|
479
|
-
*/
|
|
480
|
-
off(eventType: string, callback: EventCallback): void;
|
|
481
|
-
}
|
|
482
|
-
/**
|
|
483
|
-
* Creates an event controller that manages event subscriptions and dispatching
|
|
484
|
-
* This is a lightweight pub/sub implementation for typed events
|
|
485
|
-
*/
|
|
486
|
-
declare function createEventController(): EventController;
|
|
487
|
-
|
|
488
|
-
declare function resolveMenuItem<TStore>(item: MenuItem<TStore>, state: TStore): ResolvedMenuItem<TStore>;
|
|
489
|
-
declare function isActive<TStore>(item: MenuItem<TStore>, state: TStore): boolean;
|
|
490
|
-
declare function isVisible<TStore>(item: MenuItem<TStore>, state: TStore): boolean;
|
|
491
|
-
declare function isDisabled<TStore>(item: MenuItem<TStore>, state: TStore): boolean;
|
|
492
|
-
|
|
493
|
-
declare const UIPluginPackage: PluginPackage<UIPlugin, UIPluginConfig, UIPluginState, UIPluginAction>;
|
|
494
|
-
|
|
495
|
-
export { type Action, type BaseUIComponent, type CommandMenuComponent, type CommandMenuProps, type CommandMenuState, type ComponentRenderFunction, type CustomComponent, type DividerComponent, type Dynamic, type EventCallback, type EventController, type ExecuteOptions, type FloatingComponent, type FloatingComponentProps, type FloatingState, type GlobalStoreState, type Group, type GroupedItemsComponent, type GroupedItemsProps, type HeaderComponent, type HeaderProps, type HeaderState, type Icon, type IconButtonComponent, type IconButtonProps, type IconCapabilities, type IconIdentifier, type IconRegistry, type IconRenderOptions, type Menu, type MenuItem, type MenuItemBase, type MenuManagerCapabilities, type MenuRegistry, type NavbarPlacement, type PanelComponent, type PanelProps, type PanelState, type Resolved, type ResolvedAction, type ResolvedGroup, type ResolvedMenu, type ResolvedMenuItem, type ResolvedMenuItemBase, type ResolvedMenuItemResult, type SelectButtonComponent, type SelectButtonProps, type Slot, type TabButtonComponent, type TabButtonProps, type UICapability, UIComponent, type UIComponentType, UIPlugin, type UIPluginConfig, UIPluginPackage, type UIPluginState, UI_PLUGIN_ID, type WithComponentId, type childrenFunctionOptions, createEventController, defineComponent, hasActive, isActive, isDisabled, isVisible, manifest, resolveMenuItem };
|