@flowgram.ai/form-materials 0.4.0 → 0.4.2

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 (41) hide show
  1. package/dist/esm/index.js +792 -423
  2. package/dist/esm/index.js.map +1 -1
  3. package/dist/index.d.mts +136 -30
  4. package/dist/index.d.ts +136 -30
  5. package/dist/index.js +902 -525
  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/display-flow-value/index.tsx +2 -12
  10. package/src/components/display-inputs-values/index.tsx +44 -6
  11. package/src/components/dynamic-value-input/hooks.ts +24 -3
  12. package/src/components/dynamic-value-input/index.tsx +2 -2
  13. package/src/components/dynamic-value-input/styles.tsx +14 -4
  14. package/src/components/index.ts +2 -0
  15. package/src/components/inputs-values/index.tsx +3 -3
  16. package/src/components/inputs-values/styles.tsx +1 -1
  17. package/src/components/inputs-values-tree/hooks/use-child-list.tsx +76 -0
  18. package/src/components/inputs-values-tree/index.tsx +56 -0
  19. package/src/components/inputs-values-tree/row.tsx +173 -0
  20. package/src/components/inputs-values-tree/styles.tsx +128 -0
  21. package/src/components/inputs-values-tree/types.ts +21 -0
  22. package/src/components/json-schema-editor/default-value.tsx +1 -3
  23. package/src/components/json-schema-editor/hooks.tsx +13 -2
  24. package/src/components/json-schema-editor/index.tsx +17 -57
  25. package/src/components/json-schema-editor/styles.tsx +12 -55
  26. package/src/components/json-schema-editor/types.ts +0 -1
  27. package/src/components/prompt-editor/index.tsx +10 -3
  28. package/src/effects/auto-rename-ref/index.ts +7 -54
  29. package/src/form-plugins/infer-inputs-plugin/index.ts +3 -75
  30. package/src/hooks/use-object-list/index.tsx +34 -6
  31. package/src/plugins/json-schema-preset/manager.ts +1 -0
  32. package/src/plugins/json-schema-preset/type-definition/string.tsx +18 -9
  33. package/src/shared/flow-value/index.ts +6 -0
  34. package/src/shared/flow-value/schema.ts +38 -0
  35. package/src/shared/flow-value/utils.ts +201 -0
  36. package/src/shared/index.ts +1 -0
  37. package/src/typings/flow-value/index.ts +2 -0
  38. package/src/components/json-schema-editor/components/blur-input.tsx +0 -27
  39. package/src/plugins/disable-declaration-plugin/config.json +0 -5
  40. package/src/plugins/json-schema-preset/config.json +0 -9
  41. /package/src/components/{inputs-values/components/blur-input.tsx → blur-input/index.tsx} +0 -0
package/dist/index.d.ts 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,60 @@ 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 {
445
- value?: Record<string, IFlowValue | undefined>;
451
+ interface PropsType$1 {
452
+ value?: any;
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;
456
+ declare function DisplayInputsValueAllInTag({ value, title, showIconInTree, }: PropsType$1 & {
457
+ title: string;
458
+ }): React$1.JSX.Element;
449
459
 
450
460
  /**
451
461
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
@@ -486,6 +496,38 @@ interface AssignRowProps {
486
496
 
487
497
  declare function AssignRow(props: AssignRowProps): React$1.JSX.Element;
488
498
 
499
+ /**
500
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
501
+ * SPDX-License-Identifier: MIT
502
+ */
503
+
504
+ declare function BlurInput(props: InputProps): React$1.JSX.Element;
505
+
506
+ /**
507
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
508
+ * SPDX-License-Identifier: MIT
509
+ */
510
+
511
+ interface PropsType {
512
+ value?: any;
513
+ onChange: (value?: any) => void;
514
+ readonly?: boolean;
515
+ hasError?: boolean;
516
+ schema?: IJsonSchema;
517
+ style?: React.CSSProperties;
518
+ constantProps?: {
519
+ strategies?: Strategy[];
520
+ [key: string]: any;
521
+ };
522
+ }
523
+
524
+ /**
525
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
526
+ * SPDX-License-Identifier: MIT
527
+ */
528
+
529
+ declare function InputsValuesTree(props: PropsType): React$1.JSX.Element;
530
+
489
531
  /**
490
532
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
491
533
  * SPDX-License-Identifier: MIT
@@ -708,6 +750,70 @@ declare function createInjectMaterial<Props>(Component: React$1.FC<Props> & {
708
750
  renderKey?: string;
709
751
  }): React$1.FC<Props>;
710
752
 
753
+ /**
754
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
755
+ * SPDX-License-Identifier: MIT
756
+ */
757
+
758
+ declare namespace FlowValueUtils {
759
+ /**
760
+ * Check if the value is a constant type
761
+ */
762
+ function isConstant(value: any): value is IFlowConstantValue;
763
+ /**
764
+ * Check if the value is a reference type
765
+ */
766
+ function isRef(value: any): value is IFlowRefValue;
767
+ /**
768
+ * Check if the value is an expression type
769
+ */
770
+ function isExpression(value: any): value is IFlowExpressionValue;
771
+ /**
772
+ * Check if the value is a template type
773
+ */
774
+ function isTemplate(value: any): value is IFlowTemplateValue;
775
+ /**
776
+ * Check if the value is either a constant or reference type
777
+ */
778
+ function isConstantOrRef(value: any): value is IFlowConstantRefValue;
779
+ /**
780
+ * Check if the value is a valid flow value type
781
+ */
782
+ function isFlowValue(value: any): value is IFlowValue;
783
+ /**
784
+ * Traverse all flow values in the given value
785
+ * @param value The value to traverse
786
+ * @param options The options to traverse
787
+ * @returns A generator of flow values
788
+ */
789
+ function traverse(value: any, options: {
790
+ includeTypes?: FlowValueType[];
791
+ path?: string;
792
+ }): Generator<{
793
+ value: IFlowValue;
794
+ path: string;
795
+ }>;
796
+ /**
797
+ * Get all key paths in the template value
798
+ * @param value The template value
799
+ * @returns A list of key paths
800
+ */
801
+ function getTemplateKeyPaths(value: IFlowTemplateValue): string[][];
802
+ /**
803
+ * Infer the schema of the constant value
804
+ * @param value
805
+ * @returns
806
+ */
807
+ function inferConstantJsonSchema(value: IFlowConstantValue): IJsonSchema | undefined;
808
+ /**
809
+ * Infer the schema of the flow value
810
+ * @param values The flow value or object contains flow value
811
+ * @param scope
812
+ * @returns
813
+ */
814
+ function inferJsonSchema(values: any, scope: Scope): IJsonSchema | undefined;
815
+ }
816
+
711
817
  /**
712
818
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
713
819
  * SPDX-License-Identifier: MIT
@@ -760,4 +866,4 @@ declare function validateFlowValue(value: IFlowValue | undefined, ctx: Context):
760
866
  message: string;
761
867
  } | undefined;
762
868
 
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 };
869
+ export { AssignRow, AssignRows, type AssignValueType, BatchOutputs, BatchVariableSelector, BlurInput, CodeEditor, CodeEditorMini, type CodeEditorPropsType, ConditionRow, type ConditionRowValueType, ConstantInput, type Strategy as ConstantInputStrategy, type ConstantRendererProps, DisplayFlowValue, DisplayInputsValueAllInTag, 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 };