UNPKG

4.07 kBTypeScriptView Raw
1/// <reference types="react" />
2import * as t from './libs';
3export declare type ShellTheme = 'LIGHT' | 'DARK';
4export declare type IShell = {
5 events: IShellEvents;
6 state: IShellState;
7 initial(state: IShellPartialState): IShell;
8 register: ShellRegisterModule;
9 main: ShellRegisterModule;
10 load<P = Record<string, unknown>>(moduleId: string | number, options?: IShellLoadOptions<P>): Promise<IShellLoadResponse>;
11 progress: IShellProgress;
12};
13export declare type ShellRegisterModule = (moduleId: string, importer: ShellImporter, options?: {
14 timeout?: number;
15}) => IShell;
16export declare type IShellEvents = {
17 events$: t.Observable<ShellEvent>;
18 tree: t.ITreeEvents;
19 progress: {
20 start$: t.Observable<IShellProgressStart>;
21 complete$: t.Observable<IShellProgressComplete>;
22 };
23};
24export declare type IShellProgress = {
25 start(options?: {
26 duration?: number;
27 color?: string;
28 }): Promise<void>;
29 complete(): void;
30};
31export declare type IShellLoadOptions<P = Record<string, unknown>> = {
32 props?: P;
33 progress?: number;
34 simulateLatency?: number;
35};
36export declare type IShellContext = {
37 shell: IShell;
38};
39export declare type ShellImporter<P = Record<string, unknown>> = (props?: P) => Promise<ShellImporterResponse>;
40export declare type ShellImporterResponse = {
41 init: ShellImportInit;
42};
43export declare type ShellImportInit = (args: ShellImportInitArgs) => Promise<any>;
44export declare type ShellImportInitArgs = {
45 shell: IShell;
46};
47export declare type IShellLoadResponse = {
48 ok: boolean;
49 count: number;
50 error?: Error;
51 timedOut: boolean;
52};
53export declare type IShellState = {
54 readonly changed$: t.Observable<IShellStateChanged>;
55 readonly header: IShellHeaderState;
56 readonly tree: IShellTreeState;
57 readonly body: IShellBodyState;
58 readonly sidebar: IShellSidebarState;
59 readonly footer: IShellFooterState;
60};
61export declare type IShellPartialState = Partial<{
62 header: Partial<IShellHeaderState>;
63 tree: Partial<IShellTreeState>;
64 body: Partial<IShellBodyState>;
65 sidebar: Partial<IShellSidebarState>;
66 footer: Partial<IShellFooterState>;
67}>;
68export declare type IShellHeaderState = {
69 el?: JSX.Element;
70 foreground: IShellColor | string | number;
71 background: IShellColor | string | number;
72 border: IShellColor | string | number;
73 height: IShellSize | number;
74};
75export declare type IShellTreeState = {
76 root?: t.ITreeNode;
77 current?: string;
78 width: IShellSize | number;
79 render?: {
80 node?: t.RenderTreeNodeBody;
81 icon?: t.RenderTreeIcon;
82 panel?: t.RenderTreePanel;
83 };
84};
85export declare type IShellBodyState = {
86 el?: JSX.Element;
87 foreground: IShellColor | string | number;
88 background: IShellColor | string | number;
89};
90export declare type IShellSidebarState = {
91 el?: JSX.Element;
92 foreground: IShellColor | string | number;
93 background: IShellColor | string | number;
94 width: IShellSize | number;
95};
96export declare type IShellFooterState = {
97 el?: JSX.Element;
98 foreground: IShellColor | string | number;
99 background: IShellColor | string | number;
100 border: IShellColor | string | number;
101 height: IShellSize | number;
102};
103export declare type IShellColor = {
104 color: string;
105 fadeSpeed: number;
106};
107export declare type IShellSize = {
108 value: number;
109 speed: number;
110};
111export declare type ShellEvent = t.TreeviewEvent | IShellProgressStartEvent | IShellProgressCompleteEvent;
112export declare type IShellProgressStartEvent = {
113 type: 'SHELL/progress/start';
114 payload: IShellProgressStart;
115};
116export declare type IShellProgressStart = {
117 duration?: number;
118 color?: string;
119};
120export declare type IShellProgressCompleteEvent = {
121 type: 'SHELL/progress/complete';
122 payload: IShellProgressComplete;
123};
124export declare type IShellProgressComplete = {
125 success: boolean;
126};
127export declare type IShellStateChanged = t.IPropChanged & {
128 field: 'header' | 'footer' | 'tree' | 'body' | 'sidebar';
129};