@flowgram.ai/form-materials 0.3.4 → 0.3.5

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 (95) hide show
  1. package/bin/index.ts +5 -19
  2. package/bin/materials.ts +31 -89
  3. package/bin/project.ts +4 -0
  4. package/bin/utils/import.ts +127 -0
  5. package/bin/utils/traverse-file.ts +60 -0
  6. package/dist/esm/index.js +383 -488
  7. package/dist/esm/index.js.map +1 -1
  8. package/dist/index.d.mts +64 -6
  9. package/dist/index.d.ts +64 -6
  10. package/dist/index.js +625 -730
  11. package/dist/index.js.map +1 -1
  12. package/package.json +5 -5
  13. package/src/components/assign-row/index.tsx +4 -4
  14. package/src/components/assign-rows/index.tsx +1 -1
  15. package/src/components/batch-outputs/index.tsx +4 -3
  16. package/src/components/batch-outputs/types.ts +1 -1
  17. package/src/components/batch-variable-selector/index.tsx +1 -1
  18. package/src/components/code-editor-mini/index.tsx +1 -1
  19. package/src/components/condition-row/hooks/useRule.ts +2 -1
  20. package/src/components/condition-row/index.tsx +5 -4
  21. package/src/components/condition-row/types.ts +1 -1
  22. package/src/components/constant-input/index.tsx +5 -2
  23. package/src/components/constant-input/types.ts +1 -1
  24. package/src/components/display-flow-value/index.tsx +2 -2
  25. package/src/components/display-inputs-values/index.tsx +3 -2
  26. package/src/components/display-outputs/index.tsx +2 -1
  27. package/src/components/display-schema-tag/index.tsx +3 -2
  28. package/src/components/display-schema-tree/index.tsx +2 -1
  29. package/src/components/dynamic-value-input/hooks.ts +1 -1
  30. package/src/components/dynamic-value-input/index.tsx +13 -9
  31. package/src/components/inputs-values/index.tsx +7 -5
  32. package/src/components/inputs-values/types.ts +3 -3
  33. package/src/components/json-editor-with-variables/extensions/variable-tree.tsx +1 -1
  34. package/src/components/json-editor-with-variables/index.tsx +2 -1
  35. package/src/components/json-schema-editor/default-value.tsx +11 -105
  36. package/src/components/json-schema-editor/hooks.tsx +53 -94
  37. package/src/components/json-schema-editor/index.tsx +11 -8
  38. package/src/components/json-schema-editor/styles.tsx +0 -29
  39. package/src/components/prompt-editor/types.tsx +1 -1
  40. package/src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx +2 -1
  41. package/src/components/prompt-editor-with-inputs/index.tsx +3 -2
  42. package/src/components/prompt-editor-with-inputs/inputs-picker.tsx +1 -1
  43. package/src/components/prompt-editor-with-variables/extensions/variable-tree.tsx +1 -1
  44. package/src/components/prompt-editor-with-variables/index.tsx +2 -1
  45. package/src/components/type-selector/index.tsx +7 -3
  46. package/src/components/variable-selector/index.tsx +7 -4
  47. package/src/components/variable-selector/use-variable-tree.tsx +1 -1
  48. package/src/effects/auto-rename-ref/index.ts +1 -1
  49. package/src/effects/listen-ref-schema-change/index.ts +1 -1
  50. package/src/effects/listen-ref-value-change/index.ts +1 -1
  51. package/src/effects/provide-batch-input/index.ts +1 -1
  52. package/src/form-plugins/batch-outputs-plugin/index.ts +1 -1
  53. package/src/form-plugins/infer-assign-plugin/index.ts +1 -1
  54. package/src/form-plugins/infer-inputs-plugin/index.ts +1 -1
  55. package/src/shared/index.ts +1 -0
  56. package/src/shared/inject-material/README.md +170 -0
  57. package/src/shared/inject-material/README.zh.md +174 -0
  58. package/src/shared/inject-material/index.tsx +87 -0
  59. package/src/components/assign-row/config.json +0 -11
  60. package/src/components/assign-rows/config.json +0 -11
  61. package/src/components/batch-outputs/config.json +0 -13
  62. package/src/components/batch-variable-selector/config.json +0 -9
  63. package/src/components/code-editor/config.json +0 -10
  64. package/src/components/code-editor-mini/config.json +0 -7
  65. package/src/components/condition-row/config.json +0 -13
  66. package/src/components/constant-input/config.json +0 -9
  67. package/src/components/display-flow-value/config.json +0 -8
  68. package/src/components/display-inputs-values/config.json +0 -9
  69. package/src/components/display-outputs/config.json +0 -10
  70. package/src/components/display-schema-tag/config.json +0 -10
  71. package/src/components/display-schema-tree/config.json +0 -11
  72. package/src/components/dynamic-value-input/config.json +0 -14
  73. package/src/components/inputs-values/config.json +0 -13
  74. package/src/components/json-editor-with-variables/config.json +0 -13
  75. package/src/components/json-schema-editor/config.json +0 -13
  76. package/src/components/json-schema-editor/utils.ts +0 -29
  77. package/src/components/prompt-editor/config.json +0 -9
  78. package/src/components/prompt-editor-with-inputs/config.json +0 -13
  79. package/src/components/prompt-editor-with-variables/config.json +0 -13
  80. package/src/components/type-selector/config.json +0 -9
  81. package/src/components/variable-selector/config.json +0 -9
  82. package/src/effects/auto-rename-ref/config.json +0 -5
  83. package/src/effects/listen-ref-schema-change/config.json +0 -10
  84. package/src/effects/listen-ref-value-change/config.json +0 -9
  85. package/src/effects/provide-batch-input/config.json +0 -5
  86. package/src/effects/provide-json-schema-outputs/config.json +0 -7
  87. package/src/effects/sync-variable-title/config.json +0 -5
  88. package/src/effects/validate-when-variable-sync/config.json +0 -5
  89. package/src/form-plugins/batch-outputs-plugin/config.json +0 -7
  90. package/src/form-plugins/infer-assign-plugin/config.json +0 -7
  91. package/src/form-plugins/infer-inputs-plugin/config.json +0 -9
  92. package/src/hooks/use-object-list/config.json +0 -8
  93. package/src/shared/format-legacy-refs/config.json +0 -5
  94. package/src/typings/flow-value/config.json +0 -7
  95. package/src/validate/validate-flow-value/config.json +0 -7
package/dist/index.d.mts CHANGED
@@ -30,7 +30,7 @@ declare function useVariableTree(params: {
30
30
  * SPDX-License-Identifier: MIT
31
31
  */
32
32
 
33
- interface PropTypes$2 {
33
+ interface VariableSelectorProps {
34
34
  value?: string[];
35
35
  config?: {
36
36
  placeholder?: string;
@@ -44,16 +44,19 @@ interface PropTypes$2 {
44
44
  style?: React$1.CSSProperties;
45
45
  triggerRender?: (props: TriggerRenderProps) => React$1.ReactNode;
46
46
  }
47
- type VariableSelectorProps = PropTypes$2;
48
47
 
49
- declare const VariableSelector: ({ value, config, onChange, style, readonly, includeSchema, excludeSchema, hasError, triggerRender, }: PropTypes$2) => React$1.JSX.Element;
48
+ declare const VariableSelector: {
49
+ ({ value, config, onChange, style, readonly, includeSchema, excludeSchema, hasError, triggerRender, }: VariableSelectorProps): React$1.JSX.Element;
50
+ renderKey: string;
51
+ };
52
+ declare const InjectVariableSelector: React$1.FC<VariableSelectorProps>;
50
53
 
51
54
  /**
52
55
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
53
56
  * SPDX-License-Identifier: MIT
54
57
  */
55
58
 
56
- interface PropTypes$1 {
59
+ interface TypeSelectorProps {
57
60
  value?: Partial<IJsonSchema>;
58
61
  onChange?: (value?: Partial<IJsonSchema>) => void;
59
62
  readonly?: boolean;
@@ -65,7 +68,11 @@ interface PropTypes$1 {
65
68
  }
66
69
  declare const getTypeSelectValue: (value?: Partial<IJsonSchema>) => string[] | undefined;
67
70
  declare const parseTypeSelectValue: (value?: string[]) => Partial<IJsonSchema> | undefined;
68
- declare function TypeSelector(props: PropTypes$1): React$1.JSX.Element;
71
+ declare function TypeSelector(props: TypeSelectorProps): React$1.JSX.Element;
72
+ declare namespace TypeSelector {
73
+ var renderKey: string;
74
+ }
75
+ declare const InjectTypeSelector: React$1.FC<TypeSelectorProps>;
69
76
 
70
77
  /**
71
78
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
@@ -214,6 +221,10 @@ interface PropsType$9 {
214
221
  };
215
222
  }
216
223
  declare function DynamicValueInput({ value, onChange, readonly, style, schema: schemaFromProps, constantProps, }: PropsType$9): React$1.JSX.Element;
224
+ declare namespace DynamicValueInput {
225
+ var renderKey: string;
226
+ }
227
+ declare const InjectDynamicValueInput: React$1.FC<PropsType$9>;
217
228
 
218
229
  /**
219
230
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
@@ -650,6 +661,53 @@ declare function formatNewRefToLegacyRef(value: NewFlowRefValueSchema): {
650
661
  content: string;
651
662
  };
652
663
 
664
+ /**
665
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
666
+ * SPDX-License-Identifier: MIT
667
+ */
668
+
669
+ /**
670
+ * Creates a material component wrapper with dependency injection support
671
+ *
672
+ * This Higher-Order Component (HOC) implements a dynamic component replacement mechanism
673
+ * for material components. It automatically checks if a custom renderer is registered
674
+ * in the editor context, using the injected component if available, otherwise
675
+ * falling back to the default component.
676
+ *
677
+ * @example
678
+ * ```tsx
679
+ * // 1.Create an injectable material component
680
+ * const InjectVariableSelector = createInjectMaterial(VariableSelector)
681
+ *
682
+ * // 2. Register custom components in editor
683
+ * // Configure in use-editor-props.tsx:
684
+ * const editorProps = {
685
+ * materials: {
686
+ * components: {
687
+ * [VariableSelector.renderKey]: YourCustomVariableSelector
688
+ * }
689
+ * }
690
+ * }
691
+ * ```
692
+ *
693
+ * @description
694
+ * Data flow explanation:
695
+ * - Register components to FlowRendererRegistry in use-editor-props
696
+ * - InjectMaterial reads renderers from FlowRendererRegistry
697
+ * - If registered renderer exists and type is REACT, use injected component
698
+ * - If not exists or type mismatch, fallback to default component
699
+ *
700
+ * @param Component - Default React component
701
+ * @param params - Optional parameters
702
+ * @param params.renderKey - Custom render key name, highest priority
703
+ * @returns Wrapper component with dependency injection support
704
+ */
705
+ declare function createInjectMaterial<Props>(Component: React$1.FC<Props> & {
706
+ renderKey?: string;
707
+ }, params?: {
708
+ renderKey?: string;
709
+ }): React$1.FC<Props>;
710
+
653
711
  /**
654
712
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
655
713
  * SPDX-License-Identifier: MIT
@@ -702,4 +760,4 @@ declare function validateFlowValue(value: IFlowValue | undefined, ctx: Context):
702
760
  message: string;
703
761
  } | undefined;
704
762
 
705
- 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 };
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 };
package/dist/index.d.ts CHANGED
@@ -30,7 +30,7 @@ declare function useVariableTree(params: {
30
30
  * SPDX-License-Identifier: MIT
31
31
  */
32
32
 
33
- interface PropTypes$2 {
33
+ interface VariableSelectorProps {
34
34
  value?: string[];
35
35
  config?: {
36
36
  placeholder?: string;
@@ -44,16 +44,19 @@ interface PropTypes$2 {
44
44
  style?: React$1.CSSProperties;
45
45
  triggerRender?: (props: TriggerRenderProps) => React$1.ReactNode;
46
46
  }
47
- type VariableSelectorProps = PropTypes$2;
48
47
 
49
- declare const VariableSelector: ({ value, config, onChange, style, readonly, includeSchema, excludeSchema, hasError, triggerRender, }: PropTypes$2) => React$1.JSX.Element;
48
+ declare const VariableSelector: {
49
+ ({ value, config, onChange, style, readonly, includeSchema, excludeSchema, hasError, triggerRender, }: VariableSelectorProps): React$1.JSX.Element;
50
+ renderKey: string;
51
+ };
52
+ declare const InjectVariableSelector: React$1.FC<VariableSelectorProps>;
50
53
 
51
54
  /**
52
55
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
53
56
  * SPDX-License-Identifier: MIT
54
57
  */
55
58
 
56
- interface PropTypes$1 {
59
+ interface TypeSelectorProps {
57
60
  value?: Partial<IJsonSchema>;
58
61
  onChange?: (value?: Partial<IJsonSchema>) => void;
59
62
  readonly?: boolean;
@@ -65,7 +68,11 @@ interface PropTypes$1 {
65
68
  }
66
69
  declare const getTypeSelectValue: (value?: Partial<IJsonSchema>) => string[] | undefined;
67
70
  declare const parseTypeSelectValue: (value?: string[]) => Partial<IJsonSchema> | undefined;
68
- declare function TypeSelector(props: PropTypes$1): React$1.JSX.Element;
71
+ declare function TypeSelector(props: TypeSelectorProps): React$1.JSX.Element;
72
+ declare namespace TypeSelector {
73
+ var renderKey: string;
74
+ }
75
+ declare const InjectTypeSelector: React$1.FC<TypeSelectorProps>;
69
76
 
70
77
  /**
71
78
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
@@ -214,6 +221,10 @@ interface PropsType$9 {
214
221
  };
215
222
  }
216
223
  declare function DynamicValueInput({ value, onChange, readonly, style, schema: schemaFromProps, constantProps, }: PropsType$9): React$1.JSX.Element;
224
+ declare namespace DynamicValueInput {
225
+ var renderKey: string;
226
+ }
227
+ declare const InjectDynamicValueInput: React$1.FC<PropsType$9>;
217
228
 
218
229
  /**
219
230
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
@@ -650,6 +661,53 @@ declare function formatNewRefToLegacyRef(value: NewFlowRefValueSchema): {
650
661
  content: string;
651
662
  };
652
663
 
664
+ /**
665
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
666
+ * SPDX-License-Identifier: MIT
667
+ */
668
+
669
+ /**
670
+ * Creates a material component wrapper with dependency injection support
671
+ *
672
+ * This Higher-Order Component (HOC) implements a dynamic component replacement mechanism
673
+ * for material components. It automatically checks if a custom renderer is registered
674
+ * in the editor context, using the injected component if available, otherwise
675
+ * falling back to the default component.
676
+ *
677
+ * @example
678
+ * ```tsx
679
+ * // 1.Create an injectable material component
680
+ * const InjectVariableSelector = createInjectMaterial(VariableSelector)
681
+ *
682
+ * // 2. Register custom components in editor
683
+ * // Configure in use-editor-props.tsx:
684
+ * const editorProps = {
685
+ * materials: {
686
+ * components: {
687
+ * [VariableSelector.renderKey]: YourCustomVariableSelector
688
+ * }
689
+ * }
690
+ * }
691
+ * ```
692
+ *
693
+ * @description
694
+ * Data flow explanation:
695
+ * - Register components to FlowRendererRegistry in use-editor-props
696
+ * - InjectMaterial reads renderers from FlowRendererRegistry
697
+ * - If registered renderer exists and type is REACT, use injected component
698
+ * - If not exists or type mismatch, fallback to default component
699
+ *
700
+ * @param Component - Default React component
701
+ * @param params - Optional parameters
702
+ * @param params.renderKey - Custom render key name, highest priority
703
+ * @returns Wrapper component with dependency injection support
704
+ */
705
+ declare function createInjectMaterial<Props>(Component: React$1.FC<Props> & {
706
+ renderKey?: string;
707
+ }, params?: {
708
+ renderKey?: string;
709
+ }): React$1.FC<Props>;
710
+
653
711
  /**
654
712
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
655
713
  * SPDX-License-Identifier: MIT
@@ -702,4 +760,4 @@ declare function validateFlowValue(value: IFlowValue | undefined, ctx: Context):
702
760
  message: string;
703
761
  } | undefined;
704
762
 
705
- 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 };
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 };