@flowgram.ai/form-materials 0.3.1 → 0.3.3

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 (37) hide show
  1. package/bin/materials.ts +1 -0
  2. package/dist/esm/index.js +331 -13
  3. package/dist/esm/index.js.map +1 -1
  4. package/dist/index.d.mts +125 -6
  5. package/dist/index.d.ts +125 -6
  6. package/dist/index.js +360 -51
  7. package/dist/index.js.map +1 -1
  8. package/package.json +5 -5
  9. package/src/components/assign-row/components/blur-input.tsx +27 -0
  10. package/src/components/assign-row/config.json +11 -0
  11. package/src/components/assign-row/index.tsx +84 -0
  12. package/src/components/assign-row/types.ts +25 -0
  13. package/src/components/assign-rows/config.json +11 -0
  14. package/src/components/assign-rows/index.tsx +59 -0
  15. package/src/components/constant-input/config.json +1 -1
  16. package/src/components/display-outputs/index.tsx +7 -1
  17. package/src/components/display-schema-tree/config.json +1 -1
  18. package/src/components/index.ts +2 -0
  19. package/src/components/variable-selector/index.tsx +1 -1
  20. package/src/effects/index.ts +3 -0
  21. package/src/effects/listen-ref-schema-change/config.json +10 -0
  22. package/src/effects/listen-ref-schema-change/index.ts +56 -0
  23. package/src/effects/listen-ref-value-change/config.json +9 -0
  24. package/src/effects/listen-ref-value-change/index.ts +53 -0
  25. package/src/effects/validate-when-variable-sync/config.json +5 -0
  26. package/src/effects/validate-when-variable-sync/index.ts +35 -0
  27. package/src/form-plugins/index.ts +1 -0
  28. package/src/form-plugins/infer-assign-plugin/config.json +7 -0
  29. package/src/form-plugins/infer-assign-plugin/index.ts +90 -0
  30. package/src/index.ts +1 -0
  31. package/src/plugins/json-schema-preset/create-type-preset-plugin.tsx +1 -1
  32. package/src/plugins/json-schema-preset/index.tsx +2 -0
  33. package/src/plugins/json-schema-preset/type-definition/array.tsx +2 -1
  34. package/src/plugins/json-schema-preset/type-definition/object.tsx +2 -1
  35. package/src/validate/index.tsx +6 -0
  36. package/src/validate/validate-flow-value/config.json +7 -0
  37. package/src/validate/validate-flow-value/index.tsx +73 -0
package/dist/index.d.mts CHANGED
@@ -1,10 +1,10 @@
1
1
  import React$1 from 'react';
2
2
  import { IJsonSchema, JsonSchemaTypeRegistry as JsonSchemaTypeRegistry$1, JsonSchemaTypeManager } from '@flowgram.ai/json-schema';
3
- export { IJsonSchema, JsonSchemaUtils } from '@flowgram.ai/json-schema';
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
6
  import preset from '@coze-editor/editor/preset-code';
7
- import { BaseVariableField, EffectOptions, FormPluginCreator } from '@flowgram.ai/editor';
7
+ import { BaseVariableField, EffectOptions, EffectFuncProps, FormPluginCreator, FeedbackLevel, FlowNodeEntity } from '@flowgram.ai/editor';
8
8
  import * as _flowgram_ai_node from '@flowgram.ai/node';
9
9
  import * as _flowgram_ai_core from '@flowgram.ai/core';
10
10
  import { TreeNodeData } from '@douyinfe/semi-ui/lib/es/tree';
@@ -120,7 +120,7 @@ interface JsonSchemaTypeRegistry<Value = any> extends JsonSchemaTypeRegistry$1 {
120
120
  }
121
121
 
122
122
  declare const createTypePresetPlugin: _flowgram_ai_core.PluginCreator<{
123
- types?: JsonSchemaTypeRegistry[];
123
+ types?: Partial<JsonSchemaTypeRegistry> & Pick<JsonSchemaTypeRegistry, "type">[];
124
124
  unregisterTypes?: string[];
125
125
  }>;
126
126
 
@@ -440,6 +440,45 @@ interface PropsType {
440
440
  }
441
441
  declare function DisplayInputsValues({ value, showIconInTree }: PropsType): React$1.JSX.Element;
442
442
 
443
+ /**
444
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
445
+ * SPDX-License-Identifier: MIT
446
+ */
447
+
448
+ interface AssignRowsProps {
449
+ name: string;
450
+ readonly?: boolean;
451
+ }
452
+ declare function AssignRows(props: AssignRowsProps): React$1.JSX.Element;
453
+
454
+ /**
455
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
456
+ * SPDX-License-Identifier: MIT
457
+ */
458
+
459
+ type AssignValueType = {
460
+ operator: 'assign';
461
+ left?: IFlowRefValue;
462
+ right?: IFlowValue;
463
+ } | {
464
+ operator: 'declare';
465
+ left?: string;
466
+ right?: IFlowValue;
467
+ };
468
+ interface AssignRowProps {
469
+ value?: AssignValueType;
470
+ onChange?: (value?: AssignValueType) => void;
471
+ onDelete?: () => void;
472
+ readonly?: boolean;
473
+ }
474
+
475
+ /**
476
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
477
+ * SPDX-License-Identifier: MIT
478
+ */
479
+
480
+ declare function AssignRow(props: AssignRowProps): React$1.JSX.Element;
481
+
443
482
  /**
444
483
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
445
484
  * SPDX-License-Identifier: MIT
@@ -479,6 +518,58 @@ declare const provideJsonSchemaOutputs: EffectOptions[];
479
518
 
480
519
  declare const syncVariableTitle: EffectOptions[];
481
520
 
521
+ /**
522
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
523
+ * SPDX-License-Identifier: MIT
524
+ */
525
+
526
+ declare const validateWhenVariableSync: ({ scope, }?: {
527
+ scope?: "private" | "public";
528
+ }) => EffectOptions[];
529
+
530
+ /**
531
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
532
+ * SPDX-License-Identifier: MIT
533
+ */
534
+
535
+ /**
536
+ * Example:
537
+ * const formMeta = {
538
+ * effect: {
539
+ * 'inputsValues.*': listenRefValueChange(({ name, variable, form }) => {
540
+ * const schema = JsonSchemaUtils.astToSchema(variable?.type);
541
+ * form.setValueIn(`${name}.schema`, schema);
542
+ * })
543
+ * }
544
+ * }
545
+ * @param cb
546
+ * @returns
547
+ */
548
+ declare const listenRefValueChange: (cb: (props: EffectFuncProps<IFlowRefValue> & {
549
+ variable?: BaseVariableField;
550
+ }) => void) => EffectOptions[];
551
+
552
+ /**
553
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
554
+ * SPDX-License-Identifier: MIT
555
+ */
556
+
557
+ /**
558
+ * Example:
559
+ * const formMeta = {
560
+ * effect: {
561
+ * 'inputsValues.*': listenRefSchemaChange(({ name, schema, form }) => {
562
+ * form.setValueIn(`${name}.schema`, schema);
563
+ * })
564
+ * }
565
+ * }
566
+ * @param cb
567
+ * @returns
568
+ */
569
+ declare const listenRefSchemaChange: (cb: (props: EffectFuncProps<IFlowRefValue> & {
570
+ schema?: IJsonSchema;
571
+ }) => void) => EffectOptions[];
572
+
482
573
  /**
483
574
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
484
575
  * SPDX-License-Identifier: MIT
@@ -580,11 +671,39 @@ declare const createBatchOutputsFormPlugin: FormPluginCreator<{
580
671
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
581
672
  * SPDX-License-Identifier: MIT
582
673
  */
583
- interface InputConfig {
674
+ interface InputConfig$1 {
584
675
  sourceKey: string;
585
676
  targetKey: string;
586
677
  scope?: 'private' | 'public';
587
678
  }
588
- declare const createInferInputsPlugin: _flowgram_ai_node.FormPluginCreator<InputConfig>;
679
+ declare const createInferInputsPlugin: _flowgram_ai_node.FormPluginCreator<InputConfig$1>;
680
+
681
+ /**
682
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
683
+ * SPDX-License-Identifier: MIT
684
+ */
685
+ interface InputConfig {
686
+ assignKey: string;
687
+ outputKey: string;
688
+ }
689
+ declare const createInferAssignPlugin: _flowgram_ai_node.FormPluginCreator<InputConfig>;
690
+
691
+ /**
692
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
693
+ * SPDX-License-Identifier: MIT
694
+ */
695
+
696
+ interface Context {
697
+ node: FlowNodeEntity;
698
+ required?: boolean;
699
+ errorMessages?: {
700
+ required?: string;
701
+ unknownVariable?: string;
702
+ };
703
+ }
704
+ declare function validateFlowValue(value: IFlowValue | undefined, ctx: Context): {
705
+ level: FeedbackLevel;
706
+ message: string;
707
+ } | undefined;
589
708
 
590
- export { BatchOutputs, BatchVariableSelector, CodeEditor, CodeEditorMini, type CodeEditorPropsType, ConditionRow, type ConditionRowValueType, ConstantInput, type ConstantRendererProps, DisplayFlowValue, DisplayInputsValues, DisplayOutputs, DisplaySchemaTag, DisplaySchemaTree, DynamicValueInput, type IFlowConstantRefValue, type IFlowConstantValue, type IFlowExpressionValue, type IFlowRefValue, type IFlowTemplateValue, type IFlowValue, type IFlowValueExtra, InputsValues, JsonEditorWithVariables, JsonSchemaEditor, JsonSchemaTypePresetProvider, type JsonSchemaTypeRegistry, PromptEditor, type PromptEditorPropsType, PromptEditorWithInputs, PromptEditorWithVariables, TypeSelector, VariableSelector, type VariableSelectorProps, autoRenameRefEffect, createBatchOutputsFormPlugin, createDisableDeclarationPlugin, createInferInputsPlugin, createTypePresetPlugin, formatLegacyRefOnInit, formatLegacyRefOnSubmit, formatLegacyRefToNewRef, formatNewRefToLegacyRef, getTypeSelectValue, isLegacyFlowRefValueSchema, isNewFlowRefValueSchema, parseTypeSelectValue, provideBatchInputEffect, provideBatchOutputsEffect, provideJsonSchemaOutputs, syncVariableTitle, useTypeManager, useVariableTree };
709
+ export { AssignRow, AssignRows, type AssignValueType, BatchOutputs, BatchVariableSelector, CodeEditor, CodeEditorMini, type CodeEditorPropsType, ConditionRow, type ConditionRowValueType, ConstantInput, type ConstantRendererProps, DisplayFlowValue, DisplayInputsValues, DisplayOutputs, DisplaySchemaTag, DisplaySchemaTree, DynamicValueInput, type IFlowConstantRefValue, type IFlowConstantValue, type IFlowExpressionValue, type IFlowRefValue, type IFlowTemplateValue, type IFlowValue, type IFlowValueExtra, InputsValues, JsonEditorWithVariables, JsonSchemaEditor, JsonSchemaTypePresetProvider, type JsonSchemaTypeRegistry, PromptEditor, type PromptEditorPropsType, PromptEditorWithInputs, PromptEditorWithVariables, TypeSelector, VariableSelector, type VariableSelectorProps, autoRenameRefEffect, createBatchOutputsFormPlugin, createDisableDeclarationPlugin, createInferAssignPlugin, createInferInputsPlugin, createTypePresetPlugin, formatLegacyRefOnInit, formatLegacyRefOnSubmit, formatLegacyRefToNewRef, formatNewRefToLegacyRef, getTypeSelectValue, isLegacyFlowRefValueSchema, isNewFlowRefValueSchema, listenRefSchemaChange, listenRefValueChange, parseTypeSelectValue, provideBatchInputEffect, provideBatchOutputsEffect, provideJsonSchemaOutputs, syncVariableTitle, useTypeManager, useVariableTree, validateFlowValue, validateWhenVariableSync };
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import React$1 from 'react';
2
2
  import { IJsonSchema, JsonSchemaTypeRegistry as JsonSchemaTypeRegistry$1, JsonSchemaTypeManager } from '@flowgram.ai/json-schema';
3
- export { IJsonSchema, JsonSchemaUtils } from '@flowgram.ai/json-schema';
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
6
  import preset from '@coze-editor/editor/preset-code';
7
- import { BaseVariableField, EffectOptions, FormPluginCreator } from '@flowgram.ai/editor';
7
+ import { BaseVariableField, EffectOptions, EffectFuncProps, FormPluginCreator, FeedbackLevel, FlowNodeEntity } from '@flowgram.ai/editor';
8
8
  import * as _flowgram_ai_node from '@flowgram.ai/node';
9
9
  import * as _flowgram_ai_core from '@flowgram.ai/core';
10
10
  import { TreeNodeData } from '@douyinfe/semi-ui/lib/es/tree';
@@ -120,7 +120,7 @@ interface JsonSchemaTypeRegistry<Value = any> extends JsonSchemaTypeRegistry$1 {
120
120
  }
121
121
 
122
122
  declare const createTypePresetPlugin: _flowgram_ai_core.PluginCreator<{
123
- types?: JsonSchemaTypeRegistry[];
123
+ types?: Partial<JsonSchemaTypeRegistry> & Pick<JsonSchemaTypeRegistry, "type">[];
124
124
  unregisterTypes?: string[];
125
125
  }>;
126
126
 
@@ -440,6 +440,45 @@ interface PropsType {
440
440
  }
441
441
  declare function DisplayInputsValues({ value, showIconInTree }: PropsType): React$1.JSX.Element;
442
442
 
443
+ /**
444
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
445
+ * SPDX-License-Identifier: MIT
446
+ */
447
+
448
+ interface AssignRowsProps {
449
+ name: string;
450
+ readonly?: boolean;
451
+ }
452
+ declare function AssignRows(props: AssignRowsProps): React$1.JSX.Element;
453
+
454
+ /**
455
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
456
+ * SPDX-License-Identifier: MIT
457
+ */
458
+
459
+ type AssignValueType = {
460
+ operator: 'assign';
461
+ left?: IFlowRefValue;
462
+ right?: IFlowValue;
463
+ } | {
464
+ operator: 'declare';
465
+ left?: string;
466
+ right?: IFlowValue;
467
+ };
468
+ interface AssignRowProps {
469
+ value?: AssignValueType;
470
+ onChange?: (value?: AssignValueType) => void;
471
+ onDelete?: () => void;
472
+ readonly?: boolean;
473
+ }
474
+
475
+ /**
476
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
477
+ * SPDX-License-Identifier: MIT
478
+ */
479
+
480
+ declare function AssignRow(props: AssignRowProps): React$1.JSX.Element;
481
+
443
482
  /**
444
483
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
445
484
  * SPDX-License-Identifier: MIT
@@ -479,6 +518,58 @@ declare const provideJsonSchemaOutputs: EffectOptions[];
479
518
 
480
519
  declare const syncVariableTitle: EffectOptions[];
481
520
 
521
+ /**
522
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
523
+ * SPDX-License-Identifier: MIT
524
+ */
525
+
526
+ declare const validateWhenVariableSync: ({ scope, }?: {
527
+ scope?: "private" | "public";
528
+ }) => EffectOptions[];
529
+
530
+ /**
531
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
532
+ * SPDX-License-Identifier: MIT
533
+ */
534
+
535
+ /**
536
+ * Example:
537
+ * const formMeta = {
538
+ * effect: {
539
+ * 'inputsValues.*': listenRefValueChange(({ name, variable, form }) => {
540
+ * const schema = JsonSchemaUtils.astToSchema(variable?.type);
541
+ * form.setValueIn(`${name}.schema`, schema);
542
+ * })
543
+ * }
544
+ * }
545
+ * @param cb
546
+ * @returns
547
+ */
548
+ declare const listenRefValueChange: (cb: (props: EffectFuncProps<IFlowRefValue> & {
549
+ variable?: BaseVariableField;
550
+ }) => void) => EffectOptions[];
551
+
552
+ /**
553
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
554
+ * SPDX-License-Identifier: MIT
555
+ */
556
+
557
+ /**
558
+ * Example:
559
+ * const formMeta = {
560
+ * effect: {
561
+ * 'inputsValues.*': listenRefSchemaChange(({ name, schema, form }) => {
562
+ * form.setValueIn(`${name}.schema`, schema);
563
+ * })
564
+ * }
565
+ * }
566
+ * @param cb
567
+ * @returns
568
+ */
569
+ declare const listenRefSchemaChange: (cb: (props: EffectFuncProps<IFlowRefValue> & {
570
+ schema?: IJsonSchema;
571
+ }) => void) => EffectOptions[];
572
+
482
573
  /**
483
574
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
484
575
  * SPDX-License-Identifier: MIT
@@ -580,11 +671,39 @@ declare const createBatchOutputsFormPlugin: FormPluginCreator<{
580
671
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
581
672
  * SPDX-License-Identifier: MIT
582
673
  */
583
- interface InputConfig {
674
+ interface InputConfig$1 {
584
675
  sourceKey: string;
585
676
  targetKey: string;
586
677
  scope?: 'private' | 'public';
587
678
  }
588
- declare const createInferInputsPlugin: _flowgram_ai_node.FormPluginCreator<InputConfig>;
679
+ declare const createInferInputsPlugin: _flowgram_ai_node.FormPluginCreator<InputConfig$1>;
680
+
681
+ /**
682
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
683
+ * SPDX-License-Identifier: MIT
684
+ */
685
+ interface InputConfig {
686
+ assignKey: string;
687
+ outputKey: string;
688
+ }
689
+ declare const createInferAssignPlugin: _flowgram_ai_node.FormPluginCreator<InputConfig>;
690
+
691
+ /**
692
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
693
+ * SPDX-License-Identifier: MIT
694
+ */
695
+
696
+ interface Context {
697
+ node: FlowNodeEntity;
698
+ required?: boolean;
699
+ errorMessages?: {
700
+ required?: string;
701
+ unknownVariable?: string;
702
+ };
703
+ }
704
+ declare function validateFlowValue(value: IFlowValue | undefined, ctx: Context): {
705
+ level: FeedbackLevel;
706
+ message: string;
707
+ } | undefined;
589
708
 
590
- export { BatchOutputs, BatchVariableSelector, CodeEditor, CodeEditorMini, type CodeEditorPropsType, ConditionRow, type ConditionRowValueType, ConstantInput, type ConstantRendererProps, DisplayFlowValue, DisplayInputsValues, DisplayOutputs, DisplaySchemaTag, DisplaySchemaTree, DynamicValueInput, type IFlowConstantRefValue, type IFlowConstantValue, type IFlowExpressionValue, type IFlowRefValue, type IFlowTemplateValue, type IFlowValue, type IFlowValueExtra, InputsValues, JsonEditorWithVariables, JsonSchemaEditor, JsonSchemaTypePresetProvider, type JsonSchemaTypeRegistry, PromptEditor, type PromptEditorPropsType, PromptEditorWithInputs, PromptEditorWithVariables, TypeSelector, VariableSelector, type VariableSelectorProps, autoRenameRefEffect, createBatchOutputsFormPlugin, createDisableDeclarationPlugin, createInferInputsPlugin, createTypePresetPlugin, formatLegacyRefOnInit, formatLegacyRefOnSubmit, formatLegacyRefToNewRef, formatNewRefToLegacyRef, getTypeSelectValue, isLegacyFlowRefValueSchema, isNewFlowRefValueSchema, parseTypeSelectValue, provideBatchInputEffect, provideBatchOutputsEffect, provideJsonSchemaOutputs, syncVariableTitle, useTypeManager, useVariableTree };
709
+ export { AssignRow, AssignRows, type AssignValueType, BatchOutputs, BatchVariableSelector, CodeEditor, CodeEditorMini, type CodeEditorPropsType, ConditionRow, type ConditionRowValueType, ConstantInput, type ConstantRendererProps, DisplayFlowValue, DisplayInputsValues, DisplayOutputs, DisplaySchemaTag, DisplaySchemaTree, DynamicValueInput, type IFlowConstantRefValue, type IFlowConstantValue, type IFlowExpressionValue, type IFlowRefValue, type IFlowTemplateValue, type IFlowValue, type IFlowValueExtra, InputsValues, JsonEditorWithVariables, JsonSchemaEditor, JsonSchemaTypePresetProvider, type JsonSchemaTypeRegistry, PromptEditor, type PromptEditorPropsType, PromptEditorWithInputs, PromptEditorWithVariables, TypeSelector, VariableSelector, type VariableSelectorProps, autoRenameRefEffect, createBatchOutputsFormPlugin, createDisableDeclarationPlugin, createInferAssignPlugin, createInferInputsPlugin, createTypePresetPlugin, formatLegacyRefOnInit, formatLegacyRefOnSubmit, formatLegacyRefToNewRef, formatNewRefToLegacyRef, getTypeSelectValue, isLegacyFlowRefValueSchema, isNewFlowRefValueSchema, listenRefSchemaChange, listenRefValueChange, parseTypeSelectValue, provideBatchInputEffect, provideBatchOutputsEffect, provideJsonSchemaOutputs, syncVariableTitle, useTypeManager, useVariableTree, validateFlowValue, validateWhenVariableSync };