@flowgram.ai/form-core 0.1.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.
- package/dist/esm/index.js +835 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/index.d.mts +677 -0
- package/dist/index.d.ts +677 -0
- package/dist/index.js +909 -0
- package/dist/index.js.map +1 -0
- package/package.json +57 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,677 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FlowNodeEntity } from '@flowgram.ai/document';
|
|
3
|
+
import { EntityData, PlaygroundContext, EntityDataRegistry } from '@flowgram.ai/core';
|
|
4
|
+
import * as inversify from 'inversify';
|
|
5
|
+
import { ContainerModule } from 'inversify';
|
|
6
|
+
import * as _flowgram_ai_utils from '@flowgram.ai/utils';
|
|
7
|
+
import { Emitter, MaybePromise, Event, DisposableCollection } from '@flowgram.ai/utils';
|
|
8
|
+
|
|
9
|
+
interface ErrorData {
|
|
10
|
+
error: Error | null;
|
|
11
|
+
}
|
|
12
|
+
declare class FlowNodeErrorData extends EntityData {
|
|
13
|
+
static type: string;
|
|
14
|
+
getDefaultData(): ErrorData;
|
|
15
|
+
setError(e: ErrorData['error']): void;
|
|
16
|
+
getError(): Error;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface NodeErrorRenderProps {
|
|
20
|
+
error: Error;
|
|
21
|
+
context: NodeContext;
|
|
22
|
+
}
|
|
23
|
+
type NodeErrorRender = Render<NodeErrorRenderProps>;
|
|
24
|
+
|
|
25
|
+
declare const ErrorContainerModule: ContainerModule;
|
|
26
|
+
|
|
27
|
+
declare function getNodeError(node: FlowNodeEntity): Error;
|
|
28
|
+
|
|
29
|
+
interface NodeContext {
|
|
30
|
+
node: FlowNodeEntity;
|
|
31
|
+
playgroundContext: PlaygroundContext;
|
|
32
|
+
}
|
|
33
|
+
type Render<T = any> = (props: T) => any;
|
|
34
|
+
type NodePluginRender = Render<NodeContext>;
|
|
35
|
+
type NodePlaceholderRender = Render<NodeContext>;
|
|
36
|
+
interface NodeRenderProps {
|
|
37
|
+
node: FlowNodeEntity;
|
|
38
|
+
}
|
|
39
|
+
type NodeRenderHoc = (Component: React.JSXElementConstructor<NodeRenderProps>) => React.JSXElementConstructor<NodeRenderProps>;
|
|
40
|
+
|
|
41
|
+
declare enum MaterialRenderKey {
|
|
42
|
+
CustomNodeError = "Material_CustomNodeError"
|
|
43
|
+
}
|
|
44
|
+
declare class NodeManager {
|
|
45
|
+
readonly materialRenderRegistry: Map<string, Render>;
|
|
46
|
+
readonly pluginRenderRegistry: Map<string, Render>;
|
|
47
|
+
readonly nodeRenderHocs: NodeRenderHoc[];
|
|
48
|
+
protected nodeContributions: NodeContribution[];
|
|
49
|
+
registerMaterialRender(key: string, render: Render): void;
|
|
50
|
+
getMaterialRender(key: string): Render | undefined;
|
|
51
|
+
registerPluginRender(key: string, render: NodePluginRender): void;
|
|
52
|
+
getPluginRender(key: string): NodePluginRender | undefined;
|
|
53
|
+
registerNodeErrorRender(render: Render<NodeErrorRenderProps>): void;
|
|
54
|
+
get nodeRenderHoc(): (...args: any[]) => any;
|
|
55
|
+
registerNodeRenderHoc(hoc: NodeRenderHoc): void;
|
|
56
|
+
get nodeErrorRender(): Render | undefined;
|
|
57
|
+
protected init(): void;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
declare const NodeContribution: unique symbol;
|
|
61
|
+
interface NodeContribution {
|
|
62
|
+
onRegister?(nodeManager: NodeManager): void;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
declare const NodeContainerModule: ContainerModule;
|
|
66
|
+
|
|
67
|
+
declare const PLUGIN_KEY: {
|
|
68
|
+
FORM: string;
|
|
69
|
+
ERROR: string;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
declare const MATERIAL_KEY: {
|
|
73
|
+
NODE_ERROR_RENDER: string;
|
|
74
|
+
NODE_PLACEHOLDER_RENDER: string;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
interface INodeEngineContext {
|
|
78
|
+
readonly: boolean;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* NodeEngineContext 在 Node Engine 中为全局单例, 它的作用是让Node之间共享数据。
|
|
82
|
+
* context 分为内置context(如 readonly) 和 自定义context(业务可以按需注入)
|
|
83
|
+
*/
|
|
84
|
+
declare class NodeEngineContext {
|
|
85
|
+
static DEFAULT_READONLY: boolean;
|
|
86
|
+
static DEFAULT_JSON: {
|
|
87
|
+
readonly: boolean;
|
|
88
|
+
};
|
|
89
|
+
readonly onChangeEmitter: Emitter<NodeEngineContext>;
|
|
90
|
+
readonly onChange: _flowgram_ai_utils.Event<NodeEngineContext>;
|
|
91
|
+
private _readonly;
|
|
92
|
+
private _json;
|
|
93
|
+
get json(): INodeEngineContext;
|
|
94
|
+
get readonly(): boolean;
|
|
95
|
+
set readonly(value: boolean);
|
|
96
|
+
private fireChange;
|
|
97
|
+
private updateJSON;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
declare class NodeEngine {
|
|
101
|
+
nodeManager: NodeManager;
|
|
102
|
+
context: NodeEngineContext;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
declare const FormCoreContainerModule: ContainerModule;
|
|
106
|
+
|
|
107
|
+
interface FormItemAbility {
|
|
108
|
+
type: string;
|
|
109
|
+
/**
|
|
110
|
+
* 注册到formManager时钩子时调用
|
|
111
|
+
*/
|
|
112
|
+
onAbilityRegister?: () => void;
|
|
113
|
+
}
|
|
114
|
+
interface AbilityClass {
|
|
115
|
+
type: string;
|
|
116
|
+
new (): FormItemAbility;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
interface IFormItem<T = any> {
|
|
120
|
+
value: T;
|
|
121
|
+
}
|
|
122
|
+
declare enum FormItemEventName {
|
|
123
|
+
onFormValueChange = "onFormValueChange",
|
|
124
|
+
onFormItemInit = "onFormItemInit"
|
|
125
|
+
}
|
|
126
|
+
type FormModelValid = boolean | null;
|
|
127
|
+
type FeedbackStatus = 'error' | 'warning' | 'pending';
|
|
128
|
+
type FeedbackText = string;
|
|
129
|
+
interface FormItemFeedback {
|
|
130
|
+
feedbackStatus?: FeedbackStatus;
|
|
131
|
+
feedbackText?: FeedbackText;
|
|
132
|
+
}
|
|
133
|
+
interface FormFeedback {
|
|
134
|
+
feedbackStatus?: FeedbackStatus;
|
|
135
|
+
feedbackText?: FeedbackText;
|
|
136
|
+
path: string;
|
|
137
|
+
}
|
|
138
|
+
interface FormItemDomRef {
|
|
139
|
+
current: HTMLElement | null;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
interface FormItemAbilityMeta<Options = any> {
|
|
143
|
+
type: string;
|
|
144
|
+
options: Options;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* @deprecated
|
|
148
|
+
*/
|
|
149
|
+
interface FormItemContext {
|
|
150
|
+
/**
|
|
151
|
+
* @deprecated Use context.node instead
|
|
152
|
+
*/
|
|
153
|
+
formItemMeta: IFormItemMeta;
|
|
154
|
+
/**
|
|
155
|
+
* @deprecated
|
|
156
|
+
*/
|
|
157
|
+
formItem: IFormItem;
|
|
158
|
+
/**
|
|
159
|
+
* @deprecated Use context.node instead
|
|
160
|
+
*/
|
|
161
|
+
flowNodeEntity: FlowNodeEntity;
|
|
162
|
+
/**
|
|
163
|
+
* @deprecated Use context.playgroundContext instead
|
|
164
|
+
*/
|
|
165
|
+
playgroundContext: PlaygroundContext;
|
|
166
|
+
}
|
|
167
|
+
interface FormItemHookParams extends FormItemContext {
|
|
168
|
+
formItem: IFormItem;
|
|
169
|
+
}
|
|
170
|
+
interface FormItemHooks<T> {
|
|
171
|
+
/**
|
|
172
|
+
* FormItem初始化钩子
|
|
173
|
+
*/
|
|
174
|
+
onInit?: (params: FormItemHookParams & T) => void;
|
|
175
|
+
/**
|
|
176
|
+
* FormItem提交时钩子
|
|
177
|
+
*/
|
|
178
|
+
onSubmit?: (params: FormItemHookParams & T) => void;
|
|
179
|
+
/**
|
|
180
|
+
* FormItem克隆时钩子
|
|
181
|
+
*/
|
|
182
|
+
onClone?: (params: FormItemHookParams & T) => MaybePromise<void>;
|
|
183
|
+
/**
|
|
184
|
+
* 克隆后执行的逻辑
|
|
185
|
+
*/
|
|
186
|
+
afterClone?: (params: FormItemHookParams & T) => void;
|
|
187
|
+
/**
|
|
188
|
+
* FormItem全局校验时钩子
|
|
189
|
+
*/
|
|
190
|
+
onValidate?: (params: FormItemHookParams & T) => void;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
type FormDataTypeName = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null';
|
|
194
|
+
type FormDataType = string | number | boolean | FormDataObject | DataArray | null;
|
|
195
|
+
interface FormDataObject {
|
|
196
|
+
[key: string]: FormDataType;
|
|
197
|
+
}
|
|
198
|
+
type DataArray = Array<FormDataType>;
|
|
199
|
+
declare const FORM_VOID: "form-void";
|
|
200
|
+
interface TreeNode<T> {
|
|
201
|
+
name: string;
|
|
202
|
+
children?: TreeNode<T>[];
|
|
203
|
+
}
|
|
204
|
+
interface IFormItemMeta extends TreeNode<IFormItemMeta> {
|
|
205
|
+
/**
|
|
206
|
+
* 表单项名称
|
|
207
|
+
*/
|
|
208
|
+
name: string;
|
|
209
|
+
/**
|
|
210
|
+
* 数据类型
|
|
211
|
+
*/
|
|
212
|
+
type: FormDataTypeName | typeof FORM_VOID;
|
|
213
|
+
/**
|
|
214
|
+
* 枚举值
|
|
215
|
+
*/
|
|
216
|
+
enum?: FormDataType[];
|
|
217
|
+
/**
|
|
218
|
+
* 数组类型item的数据类型描述
|
|
219
|
+
*/
|
|
220
|
+
items?: IFormItemMeta;
|
|
221
|
+
/**
|
|
222
|
+
* 表单项标题
|
|
223
|
+
*/
|
|
224
|
+
title?: string;
|
|
225
|
+
/**
|
|
226
|
+
* 表单项描述
|
|
227
|
+
*/
|
|
228
|
+
description?: string;
|
|
229
|
+
/**
|
|
230
|
+
* 表单项默认值
|
|
231
|
+
*/
|
|
232
|
+
default?: FormDataType;
|
|
233
|
+
/**
|
|
234
|
+
* 是否必填
|
|
235
|
+
*/
|
|
236
|
+
required?: boolean;
|
|
237
|
+
/**
|
|
238
|
+
* 扩展能力
|
|
239
|
+
*/
|
|
240
|
+
abilities?: FormItemAbilityMeta[];
|
|
241
|
+
/**
|
|
242
|
+
* 子表单项
|
|
243
|
+
*/
|
|
244
|
+
children?: IFormItemMeta[];
|
|
245
|
+
}
|
|
246
|
+
interface IFormMeta {
|
|
247
|
+
/**
|
|
248
|
+
* 表单树结构root
|
|
249
|
+
*/
|
|
250
|
+
root: IFormItemMeta;
|
|
251
|
+
/**
|
|
252
|
+
* 表单全局配置
|
|
253
|
+
*/
|
|
254
|
+
options?: IFormMetaOptions;
|
|
255
|
+
}
|
|
256
|
+
interface NodeFormContext {
|
|
257
|
+
node: FlowNodeEntity;
|
|
258
|
+
playgroundContext: PlaygroundContext;
|
|
259
|
+
}
|
|
260
|
+
interface IFormMetaOptions {
|
|
261
|
+
formatOnInit?: (value: any, context: NodeFormContext) => any;
|
|
262
|
+
formatOnSubmit?: (value: any, context: NodeFormContext) => any;
|
|
263
|
+
[key: string]: any;
|
|
264
|
+
}
|
|
265
|
+
interface FormMetaGeneratorParams<PlaygroundContext, FormValue = any> {
|
|
266
|
+
node: FlowNodeEntity;
|
|
267
|
+
playgroundContext: PlaygroundContext;
|
|
268
|
+
initialValue?: FormValue;
|
|
269
|
+
}
|
|
270
|
+
type FormMetaGenerator<PlaygroundContext = any, FormValue = any> = (params: FormMetaGeneratorParams<FormValue, FormValue>) => MaybePromise<IFormMeta>;
|
|
271
|
+
type FormMetaOrFormMetaGenerator = FormMetaGenerator | IFormMeta;
|
|
272
|
+
|
|
273
|
+
type FormModelFactory = (entity: FlowNodeEntity) => FormModel;
|
|
274
|
+
declare const FormModelFactory: unique symbol;
|
|
275
|
+
declare const FormModelEntity: unique symbol;
|
|
276
|
+
declare abstract class FormModel {
|
|
277
|
+
readonly onValidate: Event<FormModel>;
|
|
278
|
+
readonly onValidChange: Event<FormModelValid>;
|
|
279
|
+
readonly onFeedbacksChange: Event<FormFeedback[]>;
|
|
280
|
+
readonly onInitialized: Event<FormModel>;
|
|
281
|
+
protected toDispose: DisposableCollection;
|
|
282
|
+
/**
|
|
283
|
+
* @deprecated
|
|
284
|
+
* use `formModel.node` instead in FormModelV2
|
|
285
|
+
*/
|
|
286
|
+
abstract get flowNodeEntity(): FlowNodeEntity;
|
|
287
|
+
/**
|
|
288
|
+
* @deprecated
|
|
289
|
+
*/
|
|
290
|
+
abstract get formManager(): FormManager;
|
|
291
|
+
abstract get formMeta(): IFormMeta;
|
|
292
|
+
abstract get initialized(): boolean;
|
|
293
|
+
abstract get valid(): FormModelValid;
|
|
294
|
+
/**
|
|
295
|
+
* @deprecated
|
|
296
|
+
* use `formModel.getFieldIn` instead in FormModelV2 to get the model of a form field
|
|
297
|
+
* do not use this in FormModelV2 since it only return an empty Map.
|
|
298
|
+
*/
|
|
299
|
+
abstract get formItemPathMap(): Map<string, IFormItem>;
|
|
300
|
+
/**
|
|
301
|
+
* @deprecated
|
|
302
|
+
*/
|
|
303
|
+
abstract clearValid(): void;
|
|
304
|
+
abstract validate(): Promise<boolean>;
|
|
305
|
+
abstract validateWithFeedbacks(): Promise<FormFeedback[]>;
|
|
306
|
+
abstract init(formMetaOrFormMetaGenerator: any, initialValue?: any): MaybePromise<void>;
|
|
307
|
+
abstract toJSON(): any;
|
|
308
|
+
/**
|
|
309
|
+
* @deprecated
|
|
310
|
+
* use `formModel.getField` instead in FormModelV2
|
|
311
|
+
*/
|
|
312
|
+
abstract getFormItemByPath(path: string): FormItem | undefined;
|
|
313
|
+
/**
|
|
314
|
+
* @deprecated
|
|
315
|
+
* use `formModel.getFieldValue` instead in FormModelV2 to get the model of a form field by path
|
|
316
|
+
*/
|
|
317
|
+
abstract getFormItemValueByPath<T = any>(path: string): any | undefined;
|
|
318
|
+
abstract render(): any;
|
|
319
|
+
abstract dispose(): void;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
declare abstract class FormItem {
|
|
323
|
+
readonly meta: IFormItemMeta;
|
|
324
|
+
readonly path: string;
|
|
325
|
+
readonly formModel: FormModel;
|
|
326
|
+
readonly onInitEventEmitter: Emitter<FormItem>;
|
|
327
|
+
readonly onInit: _flowgram_ai_utils.Event<FormItem>;
|
|
328
|
+
protected toDispose: DisposableCollection;
|
|
329
|
+
readonly onDispose: _flowgram_ai_utils.Event<void>;
|
|
330
|
+
private _domRef;
|
|
331
|
+
protected constructor(meta: IFormItemMeta, path: string, formModel: FormModel);
|
|
332
|
+
abstract get value(): any;
|
|
333
|
+
abstract set value(value: any);
|
|
334
|
+
abstract validate(): void;
|
|
335
|
+
set domRef(domRef: FormItemDomRef);
|
|
336
|
+
get domRef(): FormItemDomRef;
|
|
337
|
+
dispose(): void;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
interface FormMetaTraverseParams {
|
|
341
|
+
formItemMeta: IFormItemMeta;
|
|
342
|
+
parentPath?: string;
|
|
343
|
+
handle: (params: {
|
|
344
|
+
formItemMeta: IFormItemMeta;
|
|
345
|
+
path: string;
|
|
346
|
+
}) => any;
|
|
347
|
+
}
|
|
348
|
+
declare class FormMeta implements IFormMeta {
|
|
349
|
+
constructor(root: IFormItemMeta, options: IFormMetaOptions);
|
|
350
|
+
protected _root: IFormItemMeta;
|
|
351
|
+
get root(): IFormItemMeta;
|
|
352
|
+
protected _options: IFormMetaOptions;
|
|
353
|
+
get options(): IFormMetaOptions;
|
|
354
|
+
static traverse({ formItemMeta, parentPath, handle }: FormMetaTraverseParams): void;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
interface Extension {
|
|
358
|
+
key: string;
|
|
359
|
+
}
|
|
360
|
+
declare class FormAbilityExtensionRegistry {
|
|
361
|
+
protected registry: Map<string, Extension>;
|
|
362
|
+
register(extension: Extension): void;
|
|
363
|
+
get<T extends Extension>(key: string): T | undefined;
|
|
364
|
+
get objectMap(): Record<string, Extension>;
|
|
365
|
+
get collection(): Extension[];
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
interface FormItemMaterialContext {
|
|
369
|
+
/**
|
|
370
|
+
* 当前表单项的meta
|
|
371
|
+
*/
|
|
372
|
+
meta: IFormItemMeta;
|
|
373
|
+
/**
|
|
374
|
+
* 当前表单项的路径
|
|
375
|
+
*/
|
|
376
|
+
path: string;
|
|
377
|
+
/**
|
|
378
|
+
* 节点引擎全局readonly
|
|
379
|
+
*/
|
|
380
|
+
readonly: boolean;
|
|
381
|
+
/**
|
|
382
|
+
* 通过路径获取表单项的值
|
|
383
|
+
* @param path 表单项在当前表单中的绝对路径,路径协议遵循glob
|
|
384
|
+
*/
|
|
385
|
+
getFormItemValueByPath: <T>(path: string) => T;
|
|
386
|
+
/**
|
|
387
|
+
* 节点表单校验回调函数注册
|
|
388
|
+
*/
|
|
389
|
+
onFormValidate: FormModel['onValidate'];
|
|
390
|
+
/**
|
|
391
|
+
* 获取Node模型
|
|
392
|
+
*/
|
|
393
|
+
node: FlowNodeEntity;
|
|
394
|
+
/**
|
|
395
|
+
* 获取FormModel原始模型
|
|
396
|
+
*/
|
|
397
|
+
form: FormModel;
|
|
398
|
+
/**
|
|
399
|
+
* 业务注入的全局context
|
|
400
|
+
*/
|
|
401
|
+
playgroundContext: PlaygroundContext;
|
|
402
|
+
/**
|
|
403
|
+
* 数组场景下当前项的index
|
|
404
|
+
*/
|
|
405
|
+
index?: number | undefined;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
declare class SetterAbility implements FormItemAbility {
|
|
409
|
+
static readonly type = "setter";
|
|
410
|
+
get type(): string;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
declare class ValidationAbility implements FormItemAbility {
|
|
414
|
+
static readonly type = "validation";
|
|
415
|
+
get type(): string;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
interface IValidateResult {
|
|
419
|
+
type: 'error' | 'warning';
|
|
420
|
+
message: string;
|
|
421
|
+
}
|
|
422
|
+
type ValidatorFunctionResponse = null | void | undefined | string | boolean | IValidateResult;
|
|
423
|
+
interface ValidationAbilityOptions {
|
|
424
|
+
/**
|
|
425
|
+
* 已注册的validator唯一标识
|
|
426
|
+
*/
|
|
427
|
+
key?: string;
|
|
428
|
+
/**
|
|
429
|
+
* 不使用已注册的validator 也支持在options中直接写validator
|
|
430
|
+
*/
|
|
431
|
+
validator?: ValidatorFunction;
|
|
432
|
+
}
|
|
433
|
+
interface ValidatorProps<T = any, CustomOptions = any> {
|
|
434
|
+
value: T;
|
|
435
|
+
options: ValidationAbilityOptions & CustomOptions;
|
|
436
|
+
context: FormItemMaterialContext;
|
|
437
|
+
}
|
|
438
|
+
type ValidatorFunction = (props: ValidatorProps) => ValidatorFunctionResponse;
|
|
439
|
+
interface ValidationExtension {
|
|
440
|
+
key: string;
|
|
441
|
+
validator: ValidatorFunction;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
interface SetterAbilityOptions {
|
|
445
|
+
/**
|
|
446
|
+
* 已注册的setter的唯一标识
|
|
447
|
+
*/
|
|
448
|
+
key: string;
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Setter context 是 FormItemMaterialContext 的外观
|
|
452
|
+
* 基于外观设计模式设计,屏蔽了FormItemMaterialContext中一些setter不可见的接口
|
|
453
|
+
* readonly: 对于setter 已经放在props 根级别,所以在这里屏蔽,防止干扰
|
|
454
|
+
* getFormItemValueByPath: setter需通过表单联动方式获取其他表单项的值,不推荐是用这个方法,所以屏蔽
|
|
455
|
+
*/
|
|
456
|
+
type SetterOrDecoratorContext = Omit<FormItemMaterialContext, 'getFormItemValueByPath' | 'readonly'>;
|
|
457
|
+
interface SetterComponentProps<T = any, CustomOptions = any> extends FormItemFeedback, FormItemContext {
|
|
458
|
+
value: T;
|
|
459
|
+
onChange: (v: T) => void;
|
|
460
|
+
/**
|
|
461
|
+
* 节点引擎全局readonly
|
|
462
|
+
*/
|
|
463
|
+
readonly: boolean;
|
|
464
|
+
children?: any;
|
|
465
|
+
options: SetterAbilityOptions & CustomOptions;
|
|
466
|
+
context: SetterOrDecoratorContext;
|
|
467
|
+
}
|
|
468
|
+
interface SetterExtension {
|
|
469
|
+
key: string;
|
|
470
|
+
component: (props: SetterComponentProps) => any;
|
|
471
|
+
validator?: ValidatorFunction;
|
|
472
|
+
}
|
|
473
|
+
type SetterHoc = (Component: React.JSXElementConstructor<SetterComponentProps>) => React.JSXElementConstructor<SetterComponentProps>;
|
|
474
|
+
|
|
475
|
+
declare class DecoratorAbility implements FormItemAbility {
|
|
476
|
+
static readonly type = "decorator";
|
|
477
|
+
get type(): string;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
interface DecoratorAbilityOptions {
|
|
481
|
+
/**
|
|
482
|
+
* 已注册的decorator的唯一标识
|
|
483
|
+
*/
|
|
484
|
+
key: string;
|
|
485
|
+
}
|
|
486
|
+
interface DecoratorComponentProps<CustomOptions = any> extends FormItemFeedback, FormItemContext {
|
|
487
|
+
readonly: boolean;
|
|
488
|
+
children?: any;
|
|
489
|
+
options: DecoratorAbilityOptions & CustomOptions;
|
|
490
|
+
context: SetterOrDecoratorContext;
|
|
491
|
+
}
|
|
492
|
+
interface DecoratorExtension {
|
|
493
|
+
key: string;
|
|
494
|
+
component: (props: DecoratorComponentProps) => any;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
interface VisibilityAbilityOptions {
|
|
498
|
+
/**
|
|
499
|
+
* 是否隐藏
|
|
500
|
+
*/
|
|
501
|
+
hidden: string | boolean;
|
|
502
|
+
/**
|
|
503
|
+
* 隐藏是否要清空表单值, 默认为false
|
|
504
|
+
*/
|
|
505
|
+
clearWhenHidden?: boolean;
|
|
506
|
+
}
|
|
507
|
+
declare class VisibilityAbility implements FormItemAbility {
|
|
508
|
+
static readonly type = "visibility";
|
|
509
|
+
get type(): string;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
declare class EffectAbility implements FormItemAbility {
|
|
513
|
+
static readonly type = "effect";
|
|
514
|
+
get type(): string;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
interface EffectAbilityOptions {
|
|
518
|
+
/**
|
|
519
|
+
* 已注册的effect 唯一标识
|
|
520
|
+
*/
|
|
521
|
+
key?: string;
|
|
522
|
+
/**
|
|
523
|
+
* 触发 effect 的事件
|
|
524
|
+
*/
|
|
525
|
+
event?: FormItemEventName;
|
|
526
|
+
/**
|
|
527
|
+
* 如果不使用已经注册的effect, 也支持直接写effect函数
|
|
528
|
+
*/
|
|
529
|
+
effect?: EffectFunction;
|
|
530
|
+
}
|
|
531
|
+
interface EffectEvent {
|
|
532
|
+
target: any & {
|
|
533
|
+
value: any;
|
|
534
|
+
};
|
|
535
|
+
currentTarget: any;
|
|
536
|
+
type: FormItemEventName;
|
|
537
|
+
}
|
|
538
|
+
interface EffectProps<CustomOptions = any, Event = EffectEvent> extends FormItemContext {
|
|
539
|
+
event: Event;
|
|
540
|
+
options: EffectAbilityOptions & CustomOptions;
|
|
541
|
+
context: FormItemMaterialContext;
|
|
542
|
+
}
|
|
543
|
+
type EffectFunction = (props: EffectProps) => void;
|
|
544
|
+
interface EffectExtension {
|
|
545
|
+
key: string;
|
|
546
|
+
effect: EffectFunction;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
declare class DefaultAbility implements FormItemAbility {
|
|
550
|
+
static readonly type = "default";
|
|
551
|
+
get type(): string;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
interface GetDefaultValueProps extends FormItemContext {
|
|
555
|
+
options: DefaultAbilityOptions;
|
|
556
|
+
context: FormItemMaterialContext;
|
|
557
|
+
}
|
|
558
|
+
interface DefaultAbilityOptions<T = any> {
|
|
559
|
+
getDefaultValue: (params: GetDefaultValueProps) => T;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
declare class FormPathService {
|
|
563
|
+
static readonly ROOT = "/";
|
|
564
|
+
static readonly DIVIDER = "/";
|
|
565
|
+
static readonly RELATIVE_PARENT = "..";
|
|
566
|
+
static readonly RELATIVE_CURRENT = ".";
|
|
567
|
+
static readonly ARRAY = "[]";
|
|
568
|
+
static normalize(path: string): string;
|
|
569
|
+
static join(paths: string[]): string;
|
|
570
|
+
static toArrayPath(path: string): string;
|
|
571
|
+
static parseArrayItemPath(path: string): {
|
|
572
|
+
itemIndex: number;
|
|
573
|
+
arrayPath: string;
|
|
574
|
+
itemMetaPath: string;
|
|
575
|
+
} | null;
|
|
576
|
+
simplify(path: string): string;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
declare class FormContextMaker {
|
|
580
|
+
readonly nodeEngineContext: NodeEngineContext;
|
|
581
|
+
readonly playgroundContext: PlaygroundContext;
|
|
582
|
+
makeFormItemMaterialContext(formItem: FormItem, options?: {
|
|
583
|
+
getIndex: () => number | undefined;
|
|
584
|
+
}): FormItemMaterialContext;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
declare class FormManager {
|
|
588
|
+
readonly abilityRegistry: Map<string, FormItemAbility>;
|
|
589
|
+
readonly setterHocs: SetterHoc[];
|
|
590
|
+
readonly extensionRegistryMap: Map<string, FormAbilityExtensionRegistry>;
|
|
591
|
+
readonly pathManager: FormPathService;
|
|
592
|
+
readonly formContextMaker: FormContextMaker;
|
|
593
|
+
readonly playgroundContext: PlaygroundContext;
|
|
594
|
+
protected formContributions: FormContribution[];
|
|
595
|
+
get components(): Record<string, any>;
|
|
596
|
+
get decorators(): Record<string, any>;
|
|
597
|
+
registerAbilityExtension(type: string, extension: any): void;
|
|
598
|
+
getAbilityExtension(abilityType: string, extensionKey: string): any;
|
|
599
|
+
registerAbility(Ability: AbilityClass): void;
|
|
600
|
+
registerAbilities(Abilities: AbilityClass[]): void;
|
|
601
|
+
getAbility<ExtendAbility>(type: string): (FormItemAbility & ExtendAbility) | undefined;
|
|
602
|
+
/**
|
|
603
|
+
* @deprecated
|
|
604
|
+
* Setter Hoc and setter are no longer supported in NodeEngineV2
|
|
605
|
+
* @param hoc
|
|
606
|
+
*/
|
|
607
|
+
registerSetterHoc(hoc: SetterHoc): void;
|
|
608
|
+
protected init(): void;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
declare const FormContribution: unique symbol;
|
|
612
|
+
interface FormContribution {
|
|
613
|
+
onRegister?(formManager: FormManager): void;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
interface Options {
|
|
617
|
+
formModelFactory: FormModelFactory;
|
|
618
|
+
}
|
|
619
|
+
interface DetailChangeEvent {
|
|
620
|
+
path: string;
|
|
621
|
+
oldValue: any;
|
|
622
|
+
value: any;
|
|
623
|
+
initialized: boolean;
|
|
624
|
+
}
|
|
625
|
+
interface OnFormValuesChangePayload {
|
|
626
|
+
values: any;
|
|
627
|
+
prevValues: any;
|
|
628
|
+
name: string;
|
|
629
|
+
}
|
|
630
|
+
declare class FlowNodeFormData extends EntityData {
|
|
631
|
+
static type: string;
|
|
632
|
+
readonly formModel: FormModel;
|
|
633
|
+
protected flowNodeEntity: FlowNodeEntity;
|
|
634
|
+
/**
|
|
635
|
+
* @deprecated rehaje 版表单form Values change 事件
|
|
636
|
+
* @protected
|
|
637
|
+
*/
|
|
638
|
+
protected onDetailChangeEmitter: Emitter<DetailChangeEvent>;
|
|
639
|
+
/**
|
|
640
|
+
* @deprecated 该方法为旧版引擎(rehaje)表单数据变更事件, 新版节点引擎请使用
|
|
641
|
+
* this.getFormModel<FormModelV2>().onFormValuesChange.
|
|
642
|
+
* @protected
|
|
643
|
+
*/
|
|
644
|
+
readonly onDetailChange: _flowgram_ai_utils.Event<DetailChangeEvent>;
|
|
645
|
+
constructor(entity: FlowNodeEntity, opts: Options);
|
|
646
|
+
getFormModel<TFormModel>(): TFormModel;
|
|
647
|
+
getDefaultData(): any;
|
|
648
|
+
createForm(formMetaOrFormMetaGenerator: any, initialValue?: any): void;
|
|
649
|
+
recreateForm(formMetaOrFormMetaGenerator: FormMetaOrFormMetaGenerator, initialValue?: any): void;
|
|
650
|
+
toJSON(): any;
|
|
651
|
+
dispose(): void;
|
|
652
|
+
/**
|
|
653
|
+
* @deprecated rehaje 版表单form Values change 事件触发函数
|
|
654
|
+
* @protected
|
|
655
|
+
*/
|
|
656
|
+
fireDetaiChange(detailChangeEvent: DetailChangeEvent): void;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
declare function isNodeFormReady(node: FlowNodeEntity): boolean;
|
|
660
|
+
declare function getFormModel(node: FlowNodeEntity): FormModel;
|
|
661
|
+
|
|
662
|
+
declare function createNodeContainerModules(): inversify.ContainerModule[];
|
|
663
|
+
|
|
664
|
+
declare const NodeRender: React.MemoExoticComponent<({ node }: NodeRenderProps) => React.JSX.Element>;
|
|
665
|
+
|
|
666
|
+
declare function registerNodeErrorRender(nodeManager: NodeManager, render: Render): void;
|
|
667
|
+
declare function registerNodePlaceholderRender(nodeManager: NodeManager, render: NodePlaceholderRender): void;
|
|
668
|
+
|
|
669
|
+
declare function createNodeEntityDatas(): EntityDataRegistry[];
|
|
670
|
+
|
|
671
|
+
declare function useNodeEngineContext(): NodeEngineContext;
|
|
672
|
+
|
|
673
|
+
declare function useFormItem(path: string): IFormItem | undefined;
|
|
674
|
+
|
|
675
|
+
declare const NodeEngineReactContext: React.Context<INodeEngineContext>;
|
|
676
|
+
|
|
677
|
+
export { type AbilityClass, type DataArray, DecoratorAbility, type DecoratorAbilityOptions, type DecoratorComponentProps, type DecoratorExtension, DefaultAbility, type DefaultAbilityOptions, type DetailChangeEvent, EffectAbility, type EffectAbilityOptions, type EffectEvent, type EffectExtension, type EffectFunction, type EffectProps, ErrorContainerModule, type ErrorData, type Extension, FORM_VOID, type FeedbackStatus, type FeedbackText, FlowNodeErrorData, FlowNodeFormData, FormAbilityExtensionRegistry, FormContextMaker, FormContribution, FormCoreContainerModule, type FormDataObject, type FormDataType, type FormDataTypeName, type FormFeedback, FormItem, type FormItemAbility, type FormItemAbilityMeta, type FormItemContext, type FormItemDomRef, FormItemEventName, type FormItemFeedback, type FormItemHookParams, type FormItemHooks, type FormItemMaterialContext, FormManager, FormMeta, type FormMetaGenerator, type FormMetaGeneratorParams, type FormMetaOrFormMetaGenerator, type FormMetaTraverseParams, FormModel, FormModelEntity, FormModelFactory, type FormModelValid, FormPathService, type GetDefaultValueProps, type IFormItem, type IFormItemMeta, type IFormMeta, type IFormMetaOptions, type INodeEngineContext, type IValidateResult, MATERIAL_KEY, MaterialRenderKey, NodeContainerModule, type NodeContext, NodeContribution, NodeEngine, NodeEngineContext, NodeEngineReactContext, type NodeErrorRender, type NodeErrorRenderProps, type NodeFormContext, NodeManager, type NodePlaceholderRender, type NodePluginRender, NodeRender, type NodeRenderHoc, type NodeRenderProps, type OnFormValuesChangePayload, PLUGIN_KEY, type Render, SetterAbility, type SetterAbilityOptions, type SetterComponentProps, type SetterExtension, type SetterHoc, type SetterOrDecoratorContext, type TreeNode, ValidationAbility, type ValidationAbilityOptions, type ValidationExtension, type ValidatorFunction, type ValidatorFunctionResponse, type ValidatorProps, VisibilityAbility, type VisibilityAbilityOptions, createNodeContainerModules, createNodeEntityDatas, getFormModel, getNodeError, isNodeFormReady, registerNodeErrorRender, registerNodePlaceholderRender, useFormItem, useNodeEngineContext };
|