@flowgram.ai/node 0.1.0-alpha.2 → 0.1.0-alpha.21

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 CHANGED
@@ -1,12 +1,10 @@
1
1
  import * as React from 'react';
2
2
  import React__default from 'react';
3
- import { FormModel, OnFormValuesChangePayload, FormModelValid, FormFeedback, FormManager, IFormItem, FormItem, IFormMeta, NodeFormContext } from '@flowgram.ai/form-core';
4
- import { FieldName as FieldName$1, FieldValue as FieldValue$1, Errors, Warnings } from '@flowgram.ai/form/src/types';
5
- import { FormValidateReturn, FormControl, FormModel as FormModel$1, FieldValue, IFieldArray, IField, FieldName, Validate as Validate$1, FormRenderProps, ValidateTrigger, FormState } from '@flowgram.ai/form';
6
- import * as _flowgram_ai_document from '@flowgram.ai/document';
7
- import { FlowNodeEntity } from '@flowgram.ai/document';
3
+ import { FormModel, OnFormValuesChangePayload, FormModelValid, FormFeedback, FormManager, IFormItem, NodeFormContext, FormItem, NodeContext, IFormMeta } from '@flowgram.ai/form-core';
4
+ import { FormValidateReturn, FormControl, FormModel as FormModel$1, FieldValue, IFieldArray, IField, FieldName, Validate as Validate$1, IForm, FormRenderProps, ValidateTrigger, FormState, Errors, Warnings } from '@flowgram.ai/form';
8
5
  import * as _flowgram_ai_utils from '@flowgram.ai/utils';
9
6
  import { Disposable, Emitter, DisposableCollection, Event } from '@flowgram.ai/utils';
7
+ import { FlowNodeEntity } from '@flowgram.ai/document';
10
8
 
11
9
  declare class FormModelV2 extends FormModel implements Disposable {
12
10
  protected effectMap: Record<string, EffectOptions[]>;
@@ -35,17 +33,17 @@ declare class FormModelV2 extends FormModel implements Disposable {
35
33
  get formManager(): FormManager;
36
34
  protected _formControl?: FormControl<any>;
37
35
  get formControl(): FormControl<any> | undefined;
38
- get formMeta(): any;
36
+ protected _formMeta: FormMeta;
37
+ get formMeta(): FormMeta;
38
+ get values(): any;
39
39
  protected _feedbacks: FormFeedback[];
40
40
  get feedbacks(): FormFeedback[];
41
+ updateFormValues(value: any): void;
41
42
  private set feedbacks(value);
42
43
  get formItemPathMap(): Map<string, IFormItem>;
43
44
  protected _initialized: boolean;
44
45
  get initialized(): boolean;
45
- get nodeContext(): {
46
- node: FlowNodeEntity;
47
- playgroundContext: unknown;
48
- };
46
+ get nodeContext(): NodeFormContext;
49
47
  get nativeFormModel(): FormModel$1 | undefined;
50
48
  render(): React.JSX.Element;
51
49
  initPlugins(plugins: FormPlugin[]): void;
@@ -62,7 +60,7 @@ declare class FormModelV2 extends FormModel implements Disposable {
62
60
  * @param name 路径
63
61
  * @param callback 回调函数
64
62
  */
65
- onFormValueChangeIn<TValue = FieldValue, TFormValue = FieldValue>(name: FieldName, callback: (payload: onFormValueChangeInPayload<TValue, TFormValue>) => void): void;
63
+ onFormValueChangeIn<TValue = FieldValue, TFormValue = FieldValue>(name: FieldName, callback: (payload: onFormValueChangeInPayload<TValue, TFormValue>) => void): Disposable;
66
64
  /**
67
65
  * @deprecated 该方法用于兼容 V1 版本 FormModel接口,如果确定是FormModelV2 请使用 FormModel.getValueIn
68
66
  * @param path glob path
@@ -77,19 +75,29 @@ declare class FormModelV2 extends FormModel implements Disposable {
77
75
  dispose(): void;
78
76
  }
79
77
 
78
+ /**
79
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
80
+ * SPDX-License-Identifier: MIT
81
+ */
82
+
80
83
  interface FormPluginConfig<Opts = any> {
81
84
  /**
82
- * FormModel 初始化时执行
85
+ * form plugin name, for debug use
86
+ */
87
+ name?: string;
88
+ /**
89
+ * setup formMeta
83
90
  * @param ctx
91
+ * @returns
84
92
  */
85
- onInit?: (ctx: FormPluginCtx, opts: Opts) => void;
93
+ onSetupFormMeta?: (ctx: FormPluginSetupMetaCtx, opts: Opts) => void;
86
94
  /**
87
- * FormMeta 中的effects 会与 FormMeta 中的effects 合并
95
+ * FormModel 初始化时执行
96
+ * @param ctx
88
97
  */
89
- effect?: Record<string, EffectOptions[]>;
98
+ onInit?: (ctx: FormPluginCtx, opts: Opts) => void;
90
99
  /**
91
100
  * FormModel 销毁时执行
92
- * @param ctx
93
101
  */
94
102
  onDispose?: (ctx: FormPluginCtx, opts: Opts) => void;
95
103
  }
@@ -99,33 +107,32 @@ declare class FormPlugin<Opts = any> implements Disposable {
99
107
  readonly config: FormPluginConfig;
100
108
  readonly opts?: Opts;
101
109
  protected _formModel: FormModelV2;
102
- constructor(name: string, config: FormPluginConfig, opts?: Opts);
110
+ constructor(config: FormPluginConfig, opts?: Opts);
103
111
  get formModel(): FormModelV2;
104
112
  get ctx(): {
105
113
  formModel: FormModelV2;
106
- node: _flowgram_ai_document.FlowNodeEntity;
107
- playgroundContext: unknown;
108
- };
114
+ } & NodeFormContext;
115
+ setupFormMeta(formMeta: FormMeta, nodeContext: NodeFormContext): FormMeta;
109
116
  init(formModel: FormModelV2): void;
110
117
  dispose(): void;
111
118
  }
112
- declare function defineFormPluginCreator<Opts>(name: string, config: FormPluginConfig): (opts: Opts) => FormPlugin<Opts>;
119
+ type FormPluginCreator<Opts> = (opts: Opts) => FormPlugin<Opts>;
120
+ declare function defineFormPluginCreator<Opts>(config: FormPluginConfig<Opts>): FormPluginCreator<Opts>;
121
+
122
+ /**
123
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
124
+ * SPDX-License-Identifier: MIT
125
+ */
113
126
 
114
127
  interface Node {
115
128
  }
116
129
  interface Flow {
117
130
  }
118
- /**
119
- * NodeContext contains
120
- * - node: the Editor's node entity.
121
- * - playgroundContext: the Editor's playgroundContext injected when initiate the Editor.
122
- */
123
- type NodeContext = NodeFormContext;
124
131
  type Validate<TFieldValue = any, TFormValues = any> = (props: {
125
132
  value: TFieldValue;
126
133
  formValues: TFormValues;
127
134
  context: NodeContext;
128
- name: FieldName$1;
135
+ name: FieldName;
129
136
  }) => ReturnType<Validate$1<TFieldValue, TFormValues>>;
130
137
  declare enum DataEvent {
131
138
  onValueChange = "onValueChange",
@@ -143,24 +150,28 @@ declare enum DataEvent {
143
150
  onArrayDelete = "onArrayDelete"
144
151
  }
145
152
  type EffectReturn = () => void;
146
- type Effect<TFieldValue = any, TFormValues = any> = (props: {
147
- name: FieldName$1;
153
+ interface EffectFuncProps<TFieldValue = any, TFormValues = any> {
154
+ name: FieldName;
148
155
  value: TFieldValue;
149
156
  prevValue?: TFieldValue;
150
157
  formValues: TFormValues;
158
+ form: IForm;
151
159
  context: NodeContext;
152
- }) => void | EffectReturn;
160
+ }
161
+ type Effect<TFieldValue = any, TFormValues = any> = (props: EffectFuncProps<TFieldValue, TFormValues>) => void | EffectReturn;
153
162
  type ArrayAppendEffect<TFieldValue = any, TFormValues = any> = (props: {
154
163
  index: number;
155
164
  value: TFieldValue;
156
165
  arrayValues: Array<TFieldValue>;
157
166
  formValues: TFormValues;
167
+ form: IForm;
158
168
  context: NodeContext;
159
169
  }) => void | EffectReturn;
160
170
  type ArrayDeleteEffect<TFieldValue = any, TFormValues = any> = (props: {
161
171
  index: number;
162
172
  arrayValue: Array<TFieldValue>;
163
173
  formValues: TFormValues;
174
+ form: IForm;
164
175
  context: NodeContext;
165
176
  }) => void | EffectReturn;
166
177
  type EffectOptions = {
@@ -186,15 +197,15 @@ interface FormMeta<TValues = any> {
186
197
  /**
187
198
  * Form data's validation rules. It's a key value map, where the key is a pattern of data's path (or field name), the value is a validate function.
188
199
  */
189
- validate?: Record<FieldName$1, Validate>;
200
+ validate?: Record<FieldName, Validate> | ((values: TValues, ctx: NodeContext) => Record<FieldName, Validate>);
190
201
  /**
191
202
  * Form data's effects. It's a key value map, where the key is a pattern of data's path (or field name), the value is an array of effect configuration.
192
203
  */
193
- effect?: Record<FieldName$1, EffectOptions[]>;
204
+ effect?: Record<FieldName, EffectOptions[]>;
194
205
  /**
195
206
  * Form data's complete default value. it will not be sent to formatOnInit, but used directly as form's value when needed.
196
207
  */
197
- defaultValues?: TValues | ((contest: NodeContext) => TValues);
208
+ defaultValues?: TValues | ((context: NodeContext) => TValues);
198
209
  /**
199
210
  * This function is to format the value when initiate the form, the returned value will be used as the initial value of the form.
200
211
  * @param value value input to node as initialValue.
@@ -213,23 +224,39 @@ interface FormMeta<TValues = any> {
213
224
  plugins?: FormPlugin[];
214
225
  }
215
226
  declare function isFormModelV2(fm: FormModel | FormModelV2): fm is FormModelV2;
216
- declare function isFormMetaV2(formMeta: IFormMeta | FormMeta): boolean;
227
+ declare function isFormMetaV2(formMeta: IFormMeta | FormMeta): formMeta is FormMeta<any>;
217
228
  type FormPluginCtx = {
218
229
  formModel: FormModelV2;
219
230
  } & NodeContext;
220
- interface onFormValueChangeInPayload<TValue = FieldValue$1, TFormValues = FieldValue$1> {
231
+ type FormPluginSetupMetaCtx = {
232
+ mergeEffect: (effect: Record<string, EffectOptions[]>) => void;
233
+ mergeValidate: (validate: Record<FieldName, Validate>) => void;
234
+ addFormatOnInit: (formatOnInit: FormMeta['formatOnInit']) => void;
235
+ addFormatOnSubmit: (formatOnSubmit: FormMeta['formatOnSubmit']) => void;
236
+ } & NodeContext;
237
+ interface onFormValueChangeInPayload<TValue = FieldValue, TFormValues = FieldValue> {
221
238
  value: TValue;
222
239
  prevValue: TValue;
223
240
  formValues: TFormValues;
224
241
  prevFormValues: TFormValues;
225
242
  }
226
243
 
244
+ /**
245
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
246
+ * SPDX-License-Identifier: MIT
247
+ */
248
+
227
249
  declare function isFormV2(node: FlowNodeEntity): boolean;
228
250
  declare function createEffectOptions<T>(event: DataEvent, effect: T): {
229
251
  effect: T;
230
252
  event: DataEvent;
231
253
  };
232
254
 
255
+ /**
256
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
257
+ * SPDX-License-Identifier: MIT
258
+ */
259
+
233
260
  /**
234
261
  * Listen to Form's values and refresh the React component.
235
262
  * By providing related node, you can use this hook outside the Form Component.
@@ -267,6 +294,11 @@ declare function useWatchFormErrors(node: FlowNodeEntity): Errors | undefined;
267
294
  */
268
295
  declare function useWatchFormWarnings(node: FlowNodeEntity): Warnings | undefined;
269
296
 
297
+ /**
298
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
299
+ * SPDX-License-Identifier: MIT
300
+ */
301
+
270
302
  interface NodeFormProps<TValues> {
271
303
  /**
272
304
  * The initialValues of the form.
@@ -291,6 +323,10 @@ interface NodeFormProps<TValues> {
291
323
  * @param name path
292
324
  */
293
325
  setValueIn<TValue>(name: FieldName, value: TValue): void;
326
+ /**
327
+ * set form values
328
+ */
329
+ updateFormValues(values: any): void;
294
330
  /**
295
331
  * Render form
296
332
  */
@@ -310,12 +346,13 @@ interface NodeFormProps<TValues> {
310
346
  /**
311
347
  * Form field value change event
312
348
  */
313
- onFormValueChangeIn<TValue = FieldValue, TFormValue = FieldValue>(name: FieldName, callback: (payload: onFormValueChangeInPayload<TValue, TFormValue>) => void): void;
349
+ onFormValueChangeIn<TValue = FieldValue, TFormValue = FieldValue>(name: FieldName, callback: (payload: onFormValueChangeInPayload<TValue, TFormValue>) => void): Disposable;
314
350
  }
315
351
  /**
316
- * Only support FormModelV2
352
+ * Use `node.form` instead
353
+ * @deprecated
317
354
  * @param node
318
355
  */
319
356
  declare function getNodeForm<TValues = FieldValue>(node: FlowNodeEntity): NodeFormProps<TValues> | undefined;
320
357
 
321
- export { type ArrayAppendEffect, type ArrayDeleteEffect, DataEvent, type Effect, type EffectOptions, type EffectReturn, type Flow, type FormMeta, FormModelV2, FormPlugin, type FormPluginConfig, type FormPluginCtx, type Node, type NodeFormProps, type Validate, createEffectOptions, defineFormPluginCreator, getNodeForm, isFormMetaV2, isFormModelV2, isFormV2, type onFormValueChangeInPayload, useInitializedFormModel, useWatchFormErrors, useWatchFormState, useWatchFormValueIn, useWatchFormValues, useWatchFormWarnings };
358
+ export { type ArrayAppendEffect, type ArrayDeleteEffect, DataEvent, type Effect, type EffectFuncProps, type EffectOptions, type EffectReturn, type Flow, type FormMeta, FormModelV2, FormPlugin, type FormPluginConfig, type FormPluginCreator, type FormPluginCtx, type FormPluginSetupMetaCtx, type Node, type NodeFormProps, type Validate, createEffectOptions, defineFormPluginCreator, getNodeForm, isFormMetaV2, isFormModelV2, isFormV2, type onFormValueChangeInPayload, useInitializedFormModel, useWatchFormErrors, useWatchFormState, useWatchFormValueIn, useWatchFormValues, useWatchFormWarnings };
package/dist/index.d.ts CHANGED
@@ -1,12 +1,10 @@
1
1
  import * as React from 'react';
2
2
  import React__default from 'react';
3
- import { FormModel, OnFormValuesChangePayload, FormModelValid, FormFeedback, FormManager, IFormItem, FormItem, IFormMeta, NodeFormContext } from '@flowgram.ai/form-core';
4
- import { FieldName as FieldName$1, FieldValue as FieldValue$1, Errors, Warnings } from '@flowgram.ai/form/src/types';
5
- import { FormValidateReturn, FormControl, FormModel as FormModel$1, FieldValue, IFieldArray, IField, FieldName, Validate as Validate$1, FormRenderProps, ValidateTrigger, FormState } from '@flowgram.ai/form';
6
- import * as _flowgram_ai_document from '@flowgram.ai/document';
7
- import { FlowNodeEntity } from '@flowgram.ai/document';
3
+ import { FormModel, OnFormValuesChangePayload, FormModelValid, FormFeedback, FormManager, IFormItem, NodeFormContext, FormItem, NodeContext, IFormMeta } from '@flowgram.ai/form-core';
4
+ import { FormValidateReturn, FormControl, FormModel as FormModel$1, FieldValue, IFieldArray, IField, FieldName, Validate as Validate$1, IForm, FormRenderProps, ValidateTrigger, FormState, Errors, Warnings } from '@flowgram.ai/form';
8
5
  import * as _flowgram_ai_utils from '@flowgram.ai/utils';
9
6
  import { Disposable, Emitter, DisposableCollection, Event } from '@flowgram.ai/utils';
7
+ import { FlowNodeEntity } from '@flowgram.ai/document';
10
8
 
11
9
  declare class FormModelV2 extends FormModel implements Disposable {
12
10
  protected effectMap: Record<string, EffectOptions[]>;
@@ -35,17 +33,17 @@ declare class FormModelV2 extends FormModel implements Disposable {
35
33
  get formManager(): FormManager;
36
34
  protected _formControl?: FormControl<any>;
37
35
  get formControl(): FormControl<any> | undefined;
38
- get formMeta(): any;
36
+ protected _formMeta: FormMeta;
37
+ get formMeta(): FormMeta;
38
+ get values(): any;
39
39
  protected _feedbacks: FormFeedback[];
40
40
  get feedbacks(): FormFeedback[];
41
+ updateFormValues(value: any): void;
41
42
  private set feedbacks(value);
42
43
  get formItemPathMap(): Map<string, IFormItem>;
43
44
  protected _initialized: boolean;
44
45
  get initialized(): boolean;
45
- get nodeContext(): {
46
- node: FlowNodeEntity;
47
- playgroundContext: unknown;
48
- };
46
+ get nodeContext(): NodeFormContext;
49
47
  get nativeFormModel(): FormModel$1 | undefined;
50
48
  render(): React.JSX.Element;
51
49
  initPlugins(plugins: FormPlugin[]): void;
@@ -62,7 +60,7 @@ declare class FormModelV2 extends FormModel implements Disposable {
62
60
  * @param name 路径
63
61
  * @param callback 回调函数
64
62
  */
65
- onFormValueChangeIn<TValue = FieldValue, TFormValue = FieldValue>(name: FieldName, callback: (payload: onFormValueChangeInPayload<TValue, TFormValue>) => void): void;
63
+ onFormValueChangeIn<TValue = FieldValue, TFormValue = FieldValue>(name: FieldName, callback: (payload: onFormValueChangeInPayload<TValue, TFormValue>) => void): Disposable;
66
64
  /**
67
65
  * @deprecated 该方法用于兼容 V1 版本 FormModel接口,如果确定是FormModelV2 请使用 FormModel.getValueIn
68
66
  * @param path glob path
@@ -77,19 +75,29 @@ declare class FormModelV2 extends FormModel implements Disposable {
77
75
  dispose(): void;
78
76
  }
79
77
 
78
+ /**
79
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
80
+ * SPDX-License-Identifier: MIT
81
+ */
82
+
80
83
  interface FormPluginConfig<Opts = any> {
81
84
  /**
82
- * FormModel 初始化时执行
85
+ * form plugin name, for debug use
86
+ */
87
+ name?: string;
88
+ /**
89
+ * setup formMeta
83
90
  * @param ctx
91
+ * @returns
84
92
  */
85
- onInit?: (ctx: FormPluginCtx, opts: Opts) => void;
93
+ onSetupFormMeta?: (ctx: FormPluginSetupMetaCtx, opts: Opts) => void;
86
94
  /**
87
- * FormMeta 中的effects 会与 FormMeta 中的effects 合并
95
+ * FormModel 初始化时执行
96
+ * @param ctx
88
97
  */
89
- effect?: Record<string, EffectOptions[]>;
98
+ onInit?: (ctx: FormPluginCtx, opts: Opts) => void;
90
99
  /**
91
100
  * FormModel 销毁时执行
92
- * @param ctx
93
101
  */
94
102
  onDispose?: (ctx: FormPluginCtx, opts: Opts) => void;
95
103
  }
@@ -99,33 +107,32 @@ declare class FormPlugin<Opts = any> implements Disposable {
99
107
  readonly config: FormPluginConfig;
100
108
  readonly opts?: Opts;
101
109
  protected _formModel: FormModelV2;
102
- constructor(name: string, config: FormPluginConfig, opts?: Opts);
110
+ constructor(config: FormPluginConfig, opts?: Opts);
103
111
  get formModel(): FormModelV2;
104
112
  get ctx(): {
105
113
  formModel: FormModelV2;
106
- node: _flowgram_ai_document.FlowNodeEntity;
107
- playgroundContext: unknown;
108
- };
114
+ } & NodeFormContext;
115
+ setupFormMeta(formMeta: FormMeta, nodeContext: NodeFormContext): FormMeta;
109
116
  init(formModel: FormModelV2): void;
110
117
  dispose(): void;
111
118
  }
112
- declare function defineFormPluginCreator<Opts>(name: string, config: FormPluginConfig): (opts: Opts) => FormPlugin<Opts>;
119
+ type FormPluginCreator<Opts> = (opts: Opts) => FormPlugin<Opts>;
120
+ declare function defineFormPluginCreator<Opts>(config: FormPluginConfig<Opts>): FormPluginCreator<Opts>;
121
+
122
+ /**
123
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
124
+ * SPDX-License-Identifier: MIT
125
+ */
113
126
 
114
127
  interface Node {
115
128
  }
116
129
  interface Flow {
117
130
  }
118
- /**
119
- * NodeContext contains
120
- * - node: the Editor's node entity.
121
- * - playgroundContext: the Editor's playgroundContext injected when initiate the Editor.
122
- */
123
- type NodeContext = NodeFormContext;
124
131
  type Validate<TFieldValue = any, TFormValues = any> = (props: {
125
132
  value: TFieldValue;
126
133
  formValues: TFormValues;
127
134
  context: NodeContext;
128
- name: FieldName$1;
135
+ name: FieldName;
129
136
  }) => ReturnType<Validate$1<TFieldValue, TFormValues>>;
130
137
  declare enum DataEvent {
131
138
  onValueChange = "onValueChange",
@@ -143,24 +150,28 @@ declare enum DataEvent {
143
150
  onArrayDelete = "onArrayDelete"
144
151
  }
145
152
  type EffectReturn = () => void;
146
- type Effect<TFieldValue = any, TFormValues = any> = (props: {
147
- name: FieldName$1;
153
+ interface EffectFuncProps<TFieldValue = any, TFormValues = any> {
154
+ name: FieldName;
148
155
  value: TFieldValue;
149
156
  prevValue?: TFieldValue;
150
157
  formValues: TFormValues;
158
+ form: IForm;
151
159
  context: NodeContext;
152
- }) => void | EffectReturn;
160
+ }
161
+ type Effect<TFieldValue = any, TFormValues = any> = (props: EffectFuncProps<TFieldValue, TFormValues>) => void | EffectReturn;
153
162
  type ArrayAppendEffect<TFieldValue = any, TFormValues = any> = (props: {
154
163
  index: number;
155
164
  value: TFieldValue;
156
165
  arrayValues: Array<TFieldValue>;
157
166
  formValues: TFormValues;
167
+ form: IForm;
158
168
  context: NodeContext;
159
169
  }) => void | EffectReturn;
160
170
  type ArrayDeleteEffect<TFieldValue = any, TFormValues = any> = (props: {
161
171
  index: number;
162
172
  arrayValue: Array<TFieldValue>;
163
173
  formValues: TFormValues;
174
+ form: IForm;
164
175
  context: NodeContext;
165
176
  }) => void | EffectReturn;
166
177
  type EffectOptions = {
@@ -186,15 +197,15 @@ interface FormMeta<TValues = any> {
186
197
  /**
187
198
  * Form data's validation rules. It's a key value map, where the key is a pattern of data's path (or field name), the value is a validate function.
188
199
  */
189
- validate?: Record<FieldName$1, Validate>;
200
+ validate?: Record<FieldName, Validate> | ((values: TValues, ctx: NodeContext) => Record<FieldName, Validate>);
190
201
  /**
191
202
  * Form data's effects. It's a key value map, where the key is a pattern of data's path (or field name), the value is an array of effect configuration.
192
203
  */
193
- effect?: Record<FieldName$1, EffectOptions[]>;
204
+ effect?: Record<FieldName, EffectOptions[]>;
194
205
  /**
195
206
  * Form data's complete default value. it will not be sent to formatOnInit, but used directly as form's value when needed.
196
207
  */
197
- defaultValues?: TValues | ((contest: NodeContext) => TValues);
208
+ defaultValues?: TValues | ((context: NodeContext) => TValues);
198
209
  /**
199
210
  * This function is to format the value when initiate the form, the returned value will be used as the initial value of the form.
200
211
  * @param value value input to node as initialValue.
@@ -213,23 +224,39 @@ interface FormMeta<TValues = any> {
213
224
  plugins?: FormPlugin[];
214
225
  }
215
226
  declare function isFormModelV2(fm: FormModel | FormModelV2): fm is FormModelV2;
216
- declare function isFormMetaV2(formMeta: IFormMeta | FormMeta): boolean;
227
+ declare function isFormMetaV2(formMeta: IFormMeta | FormMeta): formMeta is FormMeta<any>;
217
228
  type FormPluginCtx = {
218
229
  formModel: FormModelV2;
219
230
  } & NodeContext;
220
- interface onFormValueChangeInPayload<TValue = FieldValue$1, TFormValues = FieldValue$1> {
231
+ type FormPluginSetupMetaCtx = {
232
+ mergeEffect: (effect: Record<string, EffectOptions[]>) => void;
233
+ mergeValidate: (validate: Record<FieldName, Validate>) => void;
234
+ addFormatOnInit: (formatOnInit: FormMeta['formatOnInit']) => void;
235
+ addFormatOnSubmit: (formatOnSubmit: FormMeta['formatOnSubmit']) => void;
236
+ } & NodeContext;
237
+ interface onFormValueChangeInPayload<TValue = FieldValue, TFormValues = FieldValue> {
221
238
  value: TValue;
222
239
  prevValue: TValue;
223
240
  formValues: TFormValues;
224
241
  prevFormValues: TFormValues;
225
242
  }
226
243
 
244
+ /**
245
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
246
+ * SPDX-License-Identifier: MIT
247
+ */
248
+
227
249
  declare function isFormV2(node: FlowNodeEntity): boolean;
228
250
  declare function createEffectOptions<T>(event: DataEvent, effect: T): {
229
251
  effect: T;
230
252
  event: DataEvent;
231
253
  };
232
254
 
255
+ /**
256
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
257
+ * SPDX-License-Identifier: MIT
258
+ */
259
+
233
260
  /**
234
261
  * Listen to Form's values and refresh the React component.
235
262
  * By providing related node, you can use this hook outside the Form Component.
@@ -267,6 +294,11 @@ declare function useWatchFormErrors(node: FlowNodeEntity): Errors | undefined;
267
294
  */
268
295
  declare function useWatchFormWarnings(node: FlowNodeEntity): Warnings | undefined;
269
296
 
297
+ /**
298
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
299
+ * SPDX-License-Identifier: MIT
300
+ */
301
+
270
302
  interface NodeFormProps<TValues> {
271
303
  /**
272
304
  * The initialValues of the form.
@@ -291,6 +323,10 @@ interface NodeFormProps<TValues> {
291
323
  * @param name path
292
324
  */
293
325
  setValueIn<TValue>(name: FieldName, value: TValue): void;
326
+ /**
327
+ * set form values
328
+ */
329
+ updateFormValues(values: any): void;
294
330
  /**
295
331
  * Render form
296
332
  */
@@ -310,12 +346,13 @@ interface NodeFormProps<TValues> {
310
346
  /**
311
347
  * Form field value change event
312
348
  */
313
- onFormValueChangeIn<TValue = FieldValue, TFormValue = FieldValue>(name: FieldName, callback: (payload: onFormValueChangeInPayload<TValue, TFormValue>) => void): void;
349
+ onFormValueChangeIn<TValue = FieldValue, TFormValue = FieldValue>(name: FieldName, callback: (payload: onFormValueChangeInPayload<TValue, TFormValue>) => void): Disposable;
314
350
  }
315
351
  /**
316
- * Only support FormModelV2
352
+ * Use `node.form` instead
353
+ * @deprecated
317
354
  * @param node
318
355
  */
319
356
  declare function getNodeForm<TValues = FieldValue>(node: FlowNodeEntity): NodeFormProps<TValues> | undefined;
320
357
 
321
- export { type ArrayAppendEffect, type ArrayDeleteEffect, DataEvent, type Effect, type EffectOptions, type EffectReturn, type Flow, type FormMeta, FormModelV2, FormPlugin, type FormPluginConfig, type FormPluginCtx, type Node, type NodeFormProps, type Validate, createEffectOptions, defineFormPluginCreator, getNodeForm, isFormMetaV2, isFormModelV2, isFormV2, type onFormValueChangeInPayload, useInitializedFormModel, useWatchFormErrors, useWatchFormState, useWatchFormValueIn, useWatchFormValues, useWatchFormWarnings };
358
+ export { type ArrayAppendEffect, type ArrayDeleteEffect, DataEvent, type Effect, type EffectFuncProps, type EffectOptions, type EffectReturn, type Flow, type FormMeta, FormModelV2, FormPlugin, type FormPluginConfig, type FormPluginCreator, type FormPluginCtx, type FormPluginSetupMetaCtx, type Node, type NodeFormProps, type Validate, createEffectOptions, defineFormPluginCreator, getNodeForm, isFormMetaV2, isFormModelV2, isFormV2, type onFormValueChangeInPayload, useInitializedFormModel, useWatchFormErrors, useWatchFormState, useWatchFormValueIn, useWatchFormValues, useWatchFormWarnings };