@sdata-plugin-adapter/types 0.0.0-alpha.2 → 0.0.0-alpha.4
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.d.mts +186 -29
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -3,12 +3,11 @@ import * as ReactDOMClientType from "react-dom/client";
|
|
|
3
3
|
|
|
4
4
|
//#region index.d.ts
|
|
5
5
|
interface CustomConfig {
|
|
6
|
-
componentId
|
|
6
|
+
componentId?: string;
|
|
7
7
|
id: string;
|
|
8
|
-
appId?: string;
|
|
9
8
|
[key: string]: any;
|
|
10
9
|
}
|
|
11
|
-
type ConfigType =
|
|
10
|
+
type ConfigType = 'default' | 'data' | 'style' | 'interaction';
|
|
12
11
|
type ActionsFunction = {
|
|
13
12
|
[key: string]: (...args: any[]) => any;
|
|
14
13
|
};
|
|
@@ -30,55 +29,213 @@ type EventsPayload = {
|
|
|
30
29
|
key: string;
|
|
31
30
|
dataType: string;
|
|
32
31
|
}[];
|
|
33
|
-
}
|
|
32
|
+
};
|
|
34
33
|
interface EventActionDefinitions {
|
|
35
|
-
actions: ActionsPayload;
|
|
36
|
-
events: EventsPayload;
|
|
34
|
+
actions: ActionsPayload[];
|
|
35
|
+
events: EventsPayload[];
|
|
37
36
|
}
|
|
38
37
|
interface UseRegisterComponentParams {
|
|
39
|
-
actions
|
|
40
|
-
eventActionDefinitions
|
|
38
|
+
actions: ActionsFunction;
|
|
39
|
+
eventActionDefinitions: EventActionDefinitions;
|
|
41
40
|
}
|
|
42
|
-
interface
|
|
41
|
+
interface TriggerEventPayload {
|
|
43
42
|
componentId?: string;
|
|
44
43
|
event: string;
|
|
45
44
|
payload?: Record<string, any>;
|
|
46
45
|
[key: string]: any;
|
|
47
46
|
}
|
|
48
|
-
interface
|
|
49
|
-
isConfig
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
interface BaseAppProps {
|
|
48
|
+
isConfig: boolean;
|
|
49
|
+
configType: ConfigType;
|
|
50
|
+
customConfig: CustomConfig;
|
|
51
|
+
onConfigChange: (parasm: Record<string, any>) => void;
|
|
52
|
+
appTriggerEvent: (payload: TriggerEventPayload) => void;
|
|
53
|
+
}
|
|
54
|
+
interface AppAdapterProps extends BaseAppProps {
|
|
55
|
+
changeCustomConfig: (customConfig: string | CustomConfig) => void;
|
|
56
|
+
componentId: string;
|
|
57
|
+
type: string;
|
|
58
|
+
triggerEvent: (eventName: string, payload?: Record<string, any>) => void;
|
|
59
|
+
useRegisterComponent: (params: UseRegisterComponentParams) => void;
|
|
60
|
+
[key: string]: any;
|
|
61
|
+
}
|
|
62
|
+
interface FormConfig {
|
|
63
|
+
id: string;
|
|
64
|
+
form_name: string;
|
|
65
|
+
[key: string]: any;
|
|
66
|
+
}
|
|
67
|
+
interface QueryProps {
|
|
68
|
+
data: Record<string, any>;
|
|
69
|
+
queryConfig: Record<string, any>;
|
|
70
|
+
onSearch: (...args: unknown[]) => void;
|
|
71
|
+
onChange: (params: Record<string, any>) => void;
|
|
72
|
+
}
|
|
73
|
+
interface BaseReportProps {
|
|
74
|
+
type: string;
|
|
75
|
+
data: string;
|
|
76
|
+
onChange: (data: string) => void;
|
|
77
|
+
formConfig: FormConfig;
|
|
78
|
+
queryProps: QueryProps;
|
|
79
|
+
queryData: Record<string, any>;
|
|
80
|
+
component: CustomConfig;
|
|
81
|
+
control$: Record<string, any>;
|
|
82
|
+
parent: CustomConfig;
|
|
83
|
+
configuration: string;
|
|
84
|
+
changeConfiguration: (param: any) => void;
|
|
85
|
+
instance: Record<string, any>;
|
|
86
|
+
isDesign: boolean;
|
|
87
|
+
index: string | number;
|
|
88
|
+
child_id: string | number;
|
|
89
|
+
setCustomRuleFunc?: (func: (value: any) => boolean) => void;
|
|
90
|
+
}
|
|
91
|
+
interface ReportAdapterProps extends BaseReportProps {
|
|
92
|
+
formId: string;
|
|
93
|
+
formName: string;
|
|
94
|
+
isInChildTable: boolean;
|
|
95
|
+
componentId: string;
|
|
96
|
+
componentName: string;
|
|
97
|
+
customConfig: CustomConfig;
|
|
98
|
+
type: string;
|
|
99
|
+
changeCustomConfig?: (customConfig: string | Record<string, any>) => void;
|
|
100
|
+
onSearch: (...args: unknown[]) => void;
|
|
101
|
+
onSearchChange: (value: unknown, type: number) => void;
|
|
102
|
+
triggerEvent: (eventName: string, payload?: Record<string, any>) => void;
|
|
103
|
+
useRegisterComponent: (params: UseRegisterComponentParams) => void;
|
|
104
|
+
[key: string]: any;
|
|
105
|
+
}
|
|
106
|
+
type baseCol = {
|
|
107
|
+
id: string | number;
|
|
108
|
+
showType: string;
|
|
109
|
+
componentConfig: Record<string, any>;
|
|
110
|
+
[key: string]: any;
|
|
111
|
+
};
|
|
112
|
+
type columnListItem = {
|
|
113
|
+
showType: string;
|
|
114
|
+
value: string | number | unknown;
|
|
115
|
+
label: string;
|
|
116
|
+
[key: string]: any;
|
|
117
|
+
};
|
|
118
|
+
type columnsItem = {
|
|
119
|
+
title: string;
|
|
120
|
+
[key: string]: any;
|
|
121
|
+
};
|
|
122
|
+
type dataItem = {
|
|
123
|
+
label: string;
|
|
124
|
+
value: string | number | unknown;
|
|
125
|
+
[key: string]: any;
|
|
126
|
+
};
|
|
127
|
+
interface BaseDFListProps {
|
|
128
|
+
data: dataItem[];
|
|
129
|
+
viewId: string;
|
|
130
|
+
pluginId: string;
|
|
131
|
+
type: string;
|
|
132
|
+
configuration: string;
|
|
133
|
+
columns: columnsItem[];
|
|
134
|
+
pluginConfig: CustomConfig;
|
|
135
|
+
allComponentList: baseCol[];
|
|
136
|
+
changeConfiguration: (param: any) => void;
|
|
137
|
+
}
|
|
138
|
+
interface DFListAdapterProps extends BaseDFListProps {
|
|
139
|
+
componentId: string;
|
|
140
|
+
type: 'designConfiguration' | 'main';
|
|
53
141
|
customConfig: CustomConfig;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
useRegisterComponent?: (params: UseRegisterComponentParams) => void;
|
|
142
|
+
columnList: columnListItem[];
|
|
143
|
+
changeCustomConfig?: (customConfig: string | Record<string, any>) => void;
|
|
144
|
+
triggerEvent: (eventName: string, payload?: Record<string, any>) => void;
|
|
145
|
+
useRegisterComponent: (params: UseRegisterComponentParams) => void;
|
|
59
146
|
[key: string]: any;
|
|
60
147
|
}
|
|
61
|
-
type
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
148
|
+
type BScreenBlock = {
|
|
149
|
+
baseConfig: {
|
|
150
|
+
id: string | number;
|
|
151
|
+
} & Record<string, any>;
|
|
152
|
+
dataConfig: {
|
|
153
|
+
pluginOptions: Record<string, any>;
|
|
154
|
+
columns: unknown;
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
type bigScreenType = {
|
|
158
|
+
updateBlockById: (id: string | number, data: Record<string, any>) => void;
|
|
159
|
+
pluginDetailMap: Record<string, any>;
|
|
160
|
+
variableList: unknown;
|
|
161
|
+
rootStore: {
|
|
162
|
+
bigscreen: bigScreenType;
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
type bigScreenOptions = {
|
|
166
|
+
externalVariables: any;
|
|
167
|
+
} & Record<string, any>;
|
|
168
|
+
type bigScreenPubSub = {
|
|
169
|
+
subscribe: (id: string, call: (...args: unknown[]) => void) => void;
|
|
170
|
+
};
|
|
171
|
+
interface BaseBScreenProps {
|
|
172
|
+
componentId: string;
|
|
173
|
+
type: 'main' | string;
|
|
174
|
+
block: BScreenBlock;
|
|
175
|
+
bigscreen: bigScreenType;
|
|
176
|
+
options: bigScreenOptions;
|
|
177
|
+
pubSub: bigScreenPubSub;
|
|
178
|
+
}
|
|
179
|
+
interface BScreenAdapterProps extends BaseBScreenProps {
|
|
180
|
+
customConfig: Record<string, any>;
|
|
181
|
+
customOptions: bigScreenOptions;
|
|
182
|
+
variableList: unknown;
|
|
183
|
+
afterUpdateComponent: (callback: (data: unknown) => unknown) => void;
|
|
184
|
+
setComponentVisible: (visible: boolean) => void;
|
|
185
|
+
changeCustomConfig: (pluginOptions: string) => void;
|
|
186
|
+
triggerEvent: (eventName: string, payload?: Record<string, any>) => void;
|
|
187
|
+
useRegisterComponent: (params: UseRegisterComponentParams) => void;
|
|
188
|
+
[key: string]: any;
|
|
189
|
+
}
|
|
190
|
+
type AnalyzerOptions = {
|
|
191
|
+
analyzer_secondary_configuration: string;
|
|
192
|
+
externalVariables: Record<string, any>;
|
|
193
|
+
};
|
|
194
|
+
interface BaseAnalyzerProps {
|
|
195
|
+
componentId: string;
|
|
196
|
+
type: 'main' | string;
|
|
197
|
+
configuration: CustomConfig;
|
|
198
|
+
options: AnalyzerOptions;
|
|
199
|
+
dataSource: unknown;
|
|
200
|
+
data: unknown;
|
|
201
|
+
changeConfiguration: (configuration: unknown) => void;
|
|
202
|
+
}
|
|
203
|
+
interface AnalyzerAdapterProps extends BaseAnalyzerProps {
|
|
204
|
+
data: unknown;
|
|
205
|
+
customConfig: CustomConfig;
|
|
206
|
+
customOptions: Record<string, any>;
|
|
207
|
+
changeCustomConfig: (configuration: string) => void;
|
|
208
|
+
triggerEvent: (eventName: string, payload?: Record<string, any>) => void;
|
|
209
|
+
useRegisterComponent: (params: UseRegisterComponentParams) => void;
|
|
210
|
+
[key: string]: any;
|
|
211
|
+
}
|
|
212
|
+
interface CommonProps {
|
|
213
|
+
type: string;
|
|
214
|
+
}
|
|
215
|
+
type BaseProps = BaseAppProps | BaseReportProps | BaseDFListProps | BaseBScreenProps | BaseAnalyzerProps | CommonProps;
|
|
216
|
+
type AdapterFn<T extends BaseProps, R extends T> = (props: T) => R;
|
|
217
|
+
type BeforeBootstrap = <T extends Record<string, any> = {}>(callback: () => void, payload?: T) => void;
|
|
218
|
+
interface StartOptions<P extends BaseProps> {
|
|
219
|
+
App: React.ComponentType<P>;
|
|
220
|
+
beforeBootstrap?: BeforeBootstrap;
|
|
65
221
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
222
|
+
type SetAttributes<T extends BaseProps> = (dom: Element, props: T) => Promise<void>;
|
|
223
|
+
interface CreatePluginOptions<P extends BaseProps, R extends P> extends StartOptions<R> {
|
|
224
|
+
setAttributes: SetAttributes<P>;
|
|
225
|
+
adapter: AdapterFn<P, R>;
|
|
69
226
|
}
|
|
70
227
|
interface EventBus {
|
|
71
228
|
emit: (props: Record<string, any>) => void;
|
|
72
229
|
on: (callback: (payload?: any) => void) => void;
|
|
73
230
|
remove: () => void;
|
|
74
231
|
}
|
|
75
|
-
type PluginRun = (dom: Element, props:
|
|
232
|
+
type PluginRun<T extends BaseProps> = (dom: Element, props: T, context: Record<string, any>, eventBus: EventBus, setCompRoot?: (root: ReactDOMClientType.Root) => void) => void;
|
|
76
233
|
declare global {
|
|
77
234
|
interface Window {
|
|
78
235
|
React: typeof ReactType;
|
|
79
236
|
ReactDOM: typeof ReactDOMClientType;
|
|
80
237
|
online_development_islocal: boolean;
|
|
81
|
-
CUSTOM_PLUGIN: Map<string, PluginRun
|
|
238
|
+
CUSTOM_PLUGIN: Map<string, PluginRun<keyof BaseProps>>;
|
|
82
239
|
eventCenter: {
|
|
83
240
|
triggerEventNew: (payload: Record<string, any>) => void;
|
|
84
241
|
[key: string]: any;
|
|
@@ -92,4 +249,4 @@ declare global {
|
|
|
92
249
|
}
|
|
93
250
|
}
|
|
94
251
|
//#endregion
|
|
95
|
-
export { type ActionsFunction, type ActionsPayload, type
|
|
252
|
+
export { type ActionsFunction, type ActionsPayload, type AdapterFn, type AnalyzerAdapterProps, type AppAdapterProps, type BScreenAdapterProps, type BaseAnalyzerProps, type BaseAppProps, type BaseBScreenProps, type BaseDFListProps, type BaseProps, type BaseReportProps, type CommonProps, type CreatePluginOptions, type CustomConfig, type DFListAdapterProps, type EventActionDefinitions, type EventBus, type EventsPayload, type PluginRun, type ReportAdapterProps, type SetAttributes, type StartOptions, type TriggerEventPayload, type UseRegisterComponentParams };
|