@flowgram.ai/form-materials 0.4.0 → 0.4.1

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.
Files changed (39) hide show
  1. package/dist/esm/index.js +723 -401
  2. package/dist/esm/index.js.map +1 -1
  3. package/dist/index.d.mts +132 -29
  4. package/dist/index.d.ts +132 -29
  5. package/dist/index.js +839 -510
  6. package/dist/index.js.map +1 -1
  7. package/package.json +6 -5
  8. package/src/components/batch-outputs/index.tsx +3 -2
  9. package/src/components/dynamic-value-input/hooks.ts +1 -1
  10. package/src/components/dynamic-value-input/index.tsx +1 -1
  11. package/src/components/dynamic-value-input/styles.tsx +14 -4
  12. package/src/components/index.ts +2 -0
  13. package/src/components/inputs-values/index.tsx +3 -3
  14. package/src/components/inputs-values/styles.tsx +1 -1
  15. package/src/components/inputs-values-tree/hooks/use-child-list.tsx +71 -0
  16. package/src/components/inputs-values-tree/index.tsx +56 -0
  17. package/src/components/inputs-values-tree/row.tsx +163 -0
  18. package/src/components/inputs-values-tree/styles.tsx +128 -0
  19. package/src/components/inputs-values-tree/types.ts +21 -0
  20. package/src/components/json-schema-editor/default-value.tsx +1 -3
  21. package/src/components/json-schema-editor/hooks.tsx +13 -2
  22. package/src/components/json-schema-editor/index.tsx +17 -57
  23. package/src/components/json-schema-editor/styles.tsx +12 -55
  24. package/src/components/json-schema-editor/types.ts +0 -1
  25. package/src/components/prompt-editor/index.tsx +10 -3
  26. package/src/effects/auto-rename-ref/index.ts +7 -54
  27. package/src/form-plugins/infer-inputs-plugin/index.ts +3 -75
  28. package/src/hooks/use-object-list/index.tsx +34 -6
  29. package/src/plugins/json-schema-preset/manager.ts +1 -0
  30. package/src/plugins/json-schema-preset/type-definition/string.tsx +18 -9
  31. package/src/shared/flow-value/index.ts +6 -0
  32. package/src/shared/flow-value/schema.ts +38 -0
  33. package/src/shared/flow-value/utils.ts +201 -0
  34. package/src/shared/index.ts +1 -0
  35. package/src/typings/flow-value/index.ts +2 -0
  36. package/src/components/json-schema-editor/components/blur-input.tsx +0 -27
  37. package/src/plugins/disable-declaration-plugin/config.json +0 -5
  38. package/src/plugins/json-schema-preset/config.json +0 -9
  39. /package/src/components/{inputs-values/components/blur-input.tsx → blur-input/index.tsx} +0 -0
package/dist/index.d.mts CHANGED
@@ -3,8 +3,10 @@ import { IJsonSchema, JsonSchemaTypeRegistry as JsonSchemaTypeRegistry$1, JsonSc
3
3
  export { IJsonSchema, JsonSchemaBasicType, JsonSchemaUtils } from '@flowgram.ai/json-schema';
4
4
  import { TriggerRenderProps } from '@douyinfe/semi-ui/lib/es/treeSelect';
5
5
  import { InferValues } from '@coze-editor/editor/react';
6
- import preset from '@coze-editor/editor/preset-code';
7
- import { BaseVariableField, EffectOptions, EffectFuncProps, FormPluginCreator, FeedbackLevel, FlowNodeEntity } from '@flowgram.ai/editor';
6
+ import preset from '@coze-editor/editor/preset-prompt';
7
+ import preset$1 from '@coze-editor/editor/preset-code';
8
+ import { InputProps } from '@douyinfe/semi-ui/lib/es/input';
9
+ import { BaseVariableField, EffectOptions, EffectFuncProps, Scope, FormPluginCreator, FeedbackLevel, FlowNodeEntity } from '@flowgram.ai/editor';
8
10
  import * as _flowgram_ai_node from '@flowgram.ai/node';
9
11
  import * as _flowgram_ai_core from '@flowgram.ai/core';
10
12
  import { TreeNodeData } from '@douyinfe/semi-ui/lib/es/tree';
@@ -86,7 +88,6 @@ interface ConfigType {
86
88
  defaultValueTitle?: string;
87
89
  defaultValuePlaceholder?: string;
88
90
  addButtonText?: string;
89
- jsonFormatText?: string;
90
91
  }
91
92
 
92
93
  /**
@@ -118,6 +119,7 @@ interface ConstantRendererProps<Value = any> {
118
119
  value?: Value;
119
120
  onChange?: (value: Value) => void;
120
121
  readonly?: boolean;
122
+ [key: string]: any;
121
123
  }
122
124
  interface JsonSchemaTypeRegistry<Value = any> extends JsonSchemaTypeRegistry$1 {
123
125
  /**
@@ -156,7 +158,7 @@ interface Strategy<Value = any> {
156
158
  hit: (schema: IJsonSchema) => boolean;
157
159
  Renderer: React.FC<ConstantRendererProps<Value>>;
158
160
  }
159
- interface PropsType$a extends ConstantRendererProps {
161
+ interface PropsType$b extends ConstantRendererProps {
160
162
  schema: IJsonSchema;
161
163
  strategies?: Strategy[];
162
164
  fallbackRenderer?: React.FC<ConstantRendererProps>;
@@ -168,7 +170,7 @@ interface PropsType$a extends ConstantRendererProps {
168
170
  * SPDX-License-Identifier: MIT
169
171
  */
170
172
 
171
- declare function ConstantInput(props: PropsType$a): React$1.JSX.Element;
173
+ declare function ConstantInput(props: PropsType$b): React$1.JSX.Element;
172
174
 
173
175
  /**
174
176
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
@@ -178,6 +180,7 @@ declare function ConstantInput(props: PropsType$a): React$1.JSX.Element;
178
180
  interface IFlowValueExtra {
179
181
  index?: number;
180
182
  }
183
+ type FlowValueType = 'constant' | 'ref' | 'expression' | 'template';
181
184
  interface IFlowConstantValue {
182
185
  type: 'constant';
183
186
  content?: string | number | boolean;
@@ -207,7 +210,7 @@ type IFlowConstantRefValue = IFlowConstantValue | IFlowRefValue;
207
210
  * SPDX-License-Identifier: MIT
208
211
  */
209
212
 
210
- interface PropsType$9 {
213
+ interface PropsType$a {
211
214
  value?: IFlowConstantRefValue;
212
215
  onChange: (value?: IFlowConstantRefValue) => void;
213
216
  readonly?: boolean;
@@ -220,11 +223,11 @@ interface PropsType$9 {
220
223
  [key: string]: any;
221
224
  };
222
225
  }
223
- declare function DynamicValueInput({ value, onChange, readonly, style, schema: schemaFromProps, constantProps, }: PropsType$9): React$1.JSX.Element;
226
+ declare function DynamicValueInput({ value, onChange, readonly, style, schema: schemaFromProps, constantProps, }: PropsType$a): React$1.JSX.Element;
224
227
  declare namespace DynamicValueInput {
225
228
  var renderKey: string;
226
229
  }
227
- declare const InjectDynamicValueInput: React$1.FC<PropsType$9>;
230
+ declare const InjectDynamicValueInput: React$1.FC<PropsType$a>;
228
231
 
229
232
  /**
230
233
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
@@ -268,7 +271,7 @@ declare function ConditionRow({ style, value, onChange, readonly, ruleConfig, }:
268
271
  */
269
272
 
270
273
  type ValueType = Record<string, IFlowRefValue | undefined>;
271
- interface PropsType$8 {
274
+ interface PropsType$9 {
272
275
  value?: ValueType;
273
276
  onChange: (value?: ValueType) => void;
274
277
  readonly?: boolean;
@@ -281,14 +284,14 @@ interface PropsType$8 {
281
284
  * SPDX-License-Identifier: MIT
282
285
  */
283
286
 
284
- declare function BatchOutputs(props: PropsType$8): React$1.JSX.Element;
287
+ declare function BatchOutputs(props: PropsType$9): React$1.JSX.Element;
285
288
 
286
289
  /**
287
290
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
288
291
  * SPDX-License-Identifier: MIT
289
292
  */
290
293
 
291
- type PropsType$7 = React$1.PropsWithChildren<{
294
+ type PropsType$8 = React$1.PropsWithChildren<{
292
295
  value?: IFlowTemplateValue;
293
296
  onChange: (value?: IFlowTemplateValue) => void;
294
297
  readonly?: boolean;
@@ -304,8 +307,12 @@ type PropsType$7 = React$1.PropsWithChildren<{
304
307
  * SPDX-License-Identifier: MIT
305
308
  */
306
309
 
307
- type PromptEditorPropsType = PropsType$7;
308
- declare function PromptEditor(props: PropsType$7): React$1.JSX.Element;
310
+ type Preset$1 = typeof preset;
311
+ type Options$1 = Partial<InferValues<Preset$1[number]>>;
312
+ interface PromptEditorPropsType extends PropsType$8 {
313
+ options?: Options$1;
314
+ }
315
+ declare function PromptEditor(props: PromptEditorPropsType): React$1.JSX.Element;
309
316
 
310
317
  /**
311
318
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
@@ -319,17 +326,17 @@ declare function PromptEditorWithVariables(props: PromptEditorPropsType): React$
319
326
  * SPDX-License-Identifier: MIT
320
327
  */
321
328
 
322
- interface PropsType$6 extends PromptEditorPropsType {
329
+ interface PropsType$7 extends PromptEditorPropsType {
323
330
  inputsValues: Record<string, IFlowValue>;
324
331
  }
325
- declare function PromptEditorWithInputs({ inputsValues, ...restProps }: PropsType$6): React$1.JSX.Element;
332
+ declare function PromptEditorWithInputs({ inputsValues, ...restProps }: PropsType$7): React$1.JSX.Element;
326
333
 
327
334
  /**
328
335
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
329
336
  * SPDX-License-Identifier: MIT
330
337
  */
331
338
 
332
- type Preset = typeof preset;
339
+ type Preset = typeof preset$1;
333
340
  type Options = Partial<InferValues<Preset[number]>>;
334
341
  interface CodeEditorPropsType extends React$1.PropsWithChildren<{}> {
335
342
  value?: string;
@@ -362,7 +369,7 @@ declare function JsonEditorWithVariables(props: Omit<CodeEditorPropsType, 'langu
362
369
  * SPDX-License-Identifier: MIT
363
370
  */
364
371
 
365
- interface PropsType$5 {
372
+ interface PropsType$6 {
366
373
  value?: Record<string, IFlowValue | undefined>;
367
374
  onChange: (value?: Record<string, IFlowValue | undefined>) => void;
368
375
  readonly?: boolean;
@@ -380,14 +387,14 @@ interface PropsType$5 {
380
387
  * SPDX-License-Identifier: MIT
381
388
  */
382
389
 
383
- declare function InputsValues({ value, onChange, style, readonly, constantProps, schema, hasError, }: PropsType$5): React$1.JSX.Element;
390
+ declare function InputsValues({ value, onChange, style, readonly, constantProps, schema, hasError, }: PropsType$6): React$1.JSX.Element;
384
391
 
385
392
  /**
386
393
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
387
394
  * SPDX-License-Identifier: MIT
388
395
  */
389
396
 
390
- interface PropsType$4 {
397
+ interface PropsType$5 {
391
398
  value?: IJsonSchema;
392
399
  parentKey?: string;
393
400
  depth?: number;
@@ -395,57 +402,57 @@ interface PropsType$4 {
395
402
  showIcon?: boolean;
396
403
  typeManager?: JsonSchemaTypeManager;
397
404
  }
398
- declare function DisplaySchemaTree(props: Omit<PropsType$4, 'parentKey' | 'depth'>): React$1.JSX.Element;
405
+ declare function DisplaySchemaTree(props: Omit<PropsType$5, 'parentKey' | 'depth'>): React$1.JSX.Element;
399
406
 
400
407
  /**
401
408
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
402
409
  * SPDX-License-Identifier: MIT
403
410
  */
404
411
 
405
- interface PropsType$3 {
412
+ interface PropsType$4 {
406
413
  value?: IJsonSchema;
407
414
  showIconInTree?: boolean;
408
415
  displayFromScope?: boolean;
409
416
  typeManager?: JsonSchemaTypeManager;
410
417
  }
411
- declare function DisplayOutputs({ value, showIconInTree, displayFromScope }: PropsType$3): React$1.JSX.Element;
418
+ declare function DisplayOutputs({ value, showIconInTree, displayFromScope }: PropsType$4): React$1.JSX.Element;
412
419
 
413
420
  /**
414
421
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
415
422
  * SPDX-License-Identifier: MIT
416
423
  */
417
424
 
418
- interface PropsType$2 {
425
+ interface PropsType$3 {
419
426
  title?: JSX.Element | string;
420
427
  value?: IJsonSchema;
421
428
  showIconInTree?: boolean;
422
429
  warning?: boolean;
423
430
  }
424
- declare function DisplaySchemaTag({ value, showIconInTree, title, warning }: PropsType$2): React$1.JSX.Element;
431
+ declare function DisplaySchemaTag({ value, showIconInTree, title, warning }: PropsType$3): React$1.JSX.Element;
425
432
 
426
433
  /**
427
434
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
428
435
  * SPDX-License-Identifier: MIT
429
436
  */
430
437
 
431
- interface PropsType$1 {
438
+ interface PropsType$2 {
432
439
  value?: IFlowValue;
433
440
  title?: JSX.Element | string;
434
441
  showIconInTree?: boolean;
435
442
  typeManager?: JsonSchemaTypeManager;
436
443
  }
437
- declare function DisplayFlowValue({ value, title, showIconInTree }: PropsType$1): React$1.JSX.Element;
444
+ declare function DisplayFlowValue({ value, title, showIconInTree }: PropsType$2): React$1.JSX.Element;
438
445
 
439
446
  /**
440
447
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
441
448
  * SPDX-License-Identifier: MIT
442
449
  */
443
450
 
444
- interface PropsType {
451
+ interface PropsType$1 {
445
452
  value?: Record<string, IFlowValue | undefined>;
446
453
  showIconInTree?: boolean;
447
454
  }
448
- declare function DisplayInputsValues({ value, showIconInTree }: PropsType): React$1.JSX.Element;
455
+ declare function DisplayInputsValues({ value, showIconInTree }: PropsType$1): React$1.JSX.Element;
449
456
 
450
457
  /**
451
458
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
@@ -486,6 +493,38 @@ interface AssignRowProps {
486
493
 
487
494
  declare function AssignRow(props: AssignRowProps): React$1.JSX.Element;
488
495
 
496
+ /**
497
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
498
+ * SPDX-License-Identifier: MIT
499
+ */
500
+
501
+ declare function BlurInput(props: InputProps): React$1.JSX.Element;
502
+
503
+ /**
504
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
505
+ * SPDX-License-Identifier: MIT
506
+ */
507
+
508
+ interface PropsType {
509
+ value?: any;
510
+ onChange: (value?: any) => void;
511
+ readonly?: boolean;
512
+ hasError?: boolean;
513
+ schema?: IJsonSchema;
514
+ style?: React.CSSProperties;
515
+ constantProps?: {
516
+ strategies?: Strategy[];
517
+ [key: string]: any;
518
+ };
519
+ }
520
+
521
+ /**
522
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
523
+ * SPDX-License-Identifier: MIT
524
+ */
525
+
526
+ declare function InputsValuesTree(props: PropsType): React$1.JSX.Element;
527
+
489
528
  /**
490
529
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
491
530
  * SPDX-License-Identifier: MIT
@@ -708,6 +747,70 @@ declare function createInjectMaterial<Props>(Component: React$1.FC<Props> & {
708
747
  renderKey?: string;
709
748
  }): React$1.FC<Props>;
710
749
 
750
+ /**
751
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
752
+ * SPDX-License-Identifier: MIT
753
+ */
754
+
755
+ declare namespace FlowValueUtils {
756
+ /**
757
+ * Check if the value is a constant type
758
+ */
759
+ function isConstant(value: any): value is IFlowConstantValue;
760
+ /**
761
+ * Check if the value is a reference type
762
+ */
763
+ function isRef(value: any): value is IFlowRefValue;
764
+ /**
765
+ * Check if the value is an expression type
766
+ */
767
+ function isExpression(value: any): value is IFlowExpressionValue;
768
+ /**
769
+ * Check if the value is a template type
770
+ */
771
+ function isTemplate(value: any): value is IFlowTemplateValue;
772
+ /**
773
+ * Check if the value is either a constant or reference type
774
+ */
775
+ function isConstantOrRef(value: any): value is IFlowConstantRefValue;
776
+ /**
777
+ * Check if the value is a valid flow value type
778
+ */
779
+ function isFlowValue(value: any): value is IFlowValue;
780
+ /**
781
+ * Traverse all flow values in the given value
782
+ * @param value The value to traverse
783
+ * @param options The options to traverse
784
+ * @returns A generator of flow values
785
+ */
786
+ function traverse(value: any, options: {
787
+ includeTypes?: FlowValueType[];
788
+ path?: string;
789
+ }): Generator<{
790
+ value: IFlowValue;
791
+ path: string;
792
+ }>;
793
+ /**
794
+ * Get all key paths in the template value
795
+ * @param value The template value
796
+ * @returns A list of key paths
797
+ */
798
+ function getTemplateKeyPaths(value: IFlowTemplateValue): string[][];
799
+ /**
800
+ * Infer the schema of the constant value
801
+ * @param value
802
+ * @returns
803
+ */
804
+ function inferConstantJsonSchema(value: IFlowConstantValue): IJsonSchema | undefined;
805
+ /**
806
+ * Infer the schema of the flow value
807
+ * @param values The flow value or object contains flow value
808
+ * @param scope
809
+ * @returns
810
+ */
811
+ function inferJsonSchema(values: any, scope: Scope): IJsonSchema | undefined;
812
+ }
813
+
711
814
  /**
712
815
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
713
816
  * SPDX-License-Identifier: MIT
@@ -760,4 +863,4 @@ declare function validateFlowValue(value: IFlowValue | undefined, ctx: Context):
760
863
  message: string;
761
864
  } | undefined;
762
865
 
763
- export { AssignRow, AssignRows, type AssignValueType, BatchOutputs, BatchVariableSelector, CodeEditor, CodeEditorMini, type CodeEditorPropsType, ConditionRow, type ConditionRowValueType, ConstantInput, type Strategy as ConstantInputStrategy, type ConstantRendererProps, DisplayFlowValue, DisplayInputsValues, DisplayOutputs, DisplaySchemaTag, DisplaySchemaTree, DynamicValueInput, type IFlowConstantRefValue, type IFlowConstantValue, type IFlowExpressionValue, type IFlowRefValue, type IFlowTemplateValue, type IFlowValue, type IFlowValueExtra, InjectDynamicValueInput, InjectTypeSelector, InjectVariableSelector, InputsValues, JsonEditorWithVariables, JsonSchemaEditor, JsonSchemaTypePresetProvider, type JsonSchemaTypeRegistry, PromptEditor, type PromptEditorPropsType, PromptEditorWithInputs, PromptEditorWithVariables, TypeSelector, type TypeSelectorProps, VariableSelector, type VariableSelectorProps, autoRenameRefEffect, createBatchOutputsFormPlugin, createDisableDeclarationPlugin, createInferAssignPlugin, createInferInputsPlugin, createInjectMaterial, createTypePresetPlugin, formatLegacyRefOnInit, formatLegacyRefOnSubmit, formatLegacyRefToNewRef, formatNewRefToLegacyRef, getTypeSelectValue, isLegacyFlowRefValueSchema, isNewFlowRefValueSchema, listenRefSchemaChange, listenRefValueChange, parseTypeSelectValue, provideBatchInputEffect, provideBatchOutputsEffect, provideJsonSchemaOutputs, syncVariableTitle, useTypeManager, useVariableTree, validateFlowValue, validateWhenVariableSync };
866
+ export { AssignRow, AssignRows, type AssignValueType, BatchOutputs, BatchVariableSelector, BlurInput, CodeEditor, CodeEditorMini, type CodeEditorPropsType, ConditionRow, type ConditionRowValueType, ConstantInput, type Strategy as ConstantInputStrategy, type ConstantRendererProps, DisplayFlowValue, DisplayInputsValues, DisplayOutputs, DisplaySchemaTag, DisplaySchemaTree, DynamicValueInput, type FlowValueType, FlowValueUtils, type IFlowConstantRefValue, type IFlowConstantValue, type IFlowExpressionValue, type IFlowRefValue, type IFlowTemplateValue, type IFlowValue, type IFlowValueExtra, InjectDynamicValueInput, InjectTypeSelector, InjectVariableSelector, InputsValues, InputsValuesTree, JsonEditorWithVariables, JsonSchemaEditor, JsonSchemaTypePresetProvider, type JsonSchemaTypeRegistry, PromptEditor, type PromptEditorPropsType, PromptEditorWithInputs, PromptEditorWithVariables, TypeSelector, type TypeSelectorProps, VariableSelector, type VariableSelectorProps, autoRenameRefEffect, createBatchOutputsFormPlugin, createDisableDeclarationPlugin, createInferAssignPlugin, createInferInputsPlugin, createInjectMaterial, createTypePresetPlugin, formatLegacyRefOnInit, formatLegacyRefOnSubmit, formatLegacyRefToNewRef, formatNewRefToLegacyRef, getTypeSelectValue, isLegacyFlowRefValueSchema, isNewFlowRefValueSchema, listenRefSchemaChange, listenRefValueChange, parseTypeSelectValue, provideBatchInputEffect, provideBatchOutputsEffect, provideJsonSchemaOutputs, syncVariableTitle, useTypeManager, useVariableTree, validateFlowValue, validateWhenVariableSync };