@flowgram.ai/form-materials 0.3.3 → 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 (103) 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 +431 -505
  7. package/dist/esm/index.js.map +1 -1
  8. package/dist/index.d.mts +77 -23
  9. package/dist/index.d.ts +77 -23
  10. package/dist/index.js +657 -731
  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/constants.ts +2 -2
  20. package/src/components/condition-row/hooks/useOp.tsx +13 -9
  21. package/src/components/condition-row/hooks/useRule.ts +8 -4
  22. package/src/components/condition-row/index.tsx +27 -10
  23. package/src/components/condition-row/types.ts +5 -7
  24. package/src/components/constant-input/index.tsx +5 -2
  25. package/src/components/constant-input/types.ts +1 -1
  26. package/src/components/display-flow-value/index.tsx +2 -2
  27. package/src/components/display-inputs-values/index.tsx +3 -2
  28. package/src/components/display-outputs/index.tsx +2 -1
  29. package/src/components/display-schema-tag/index.tsx +3 -2
  30. package/src/components/display-schema-tree/index.tsx +2 -1
  31. package/src/components/dynamic-value-input/hooks.ts +1 -1
  32. package/src/components/dynamic-value-input/index.tsx +13 -9
  33. package/src/components/inputs-values/index.tsx +7 -5
  34. package/src/components/inputs-values/types.ts +3 -3
  35. package/src/components/json-editor-with-variables/extensions/variable-tree.tsx +1 -1
  36. package/src/components/json-editor-with-variables/index.tsx +2 -1
  37. package/src/components/json-schema-editor/default-value.tsx +11 -105
  38. package/src/components/json-schema-editor/hooks.tsx +53 -94
  39. package/src/components/json-schema-editor/index.tsx +18 -12
  40. package/src/components/json-schema-editor/styles.tsx +0 -29
  41. package/src/components/prompt-editor/types.tsx +1 -1
  42. package/src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx +2 -1
  43. package/src/components/prompt-editor-with-inputs/index.tsx +3 -2
  44. package/src/components/prompt-editor-with-inputs/inputs-picker.tsx +1 -1
  45. package/src/components/prompt-editor-with-variables/extensions/variable-tree.tsx +1 -1
  46. package/src/components/prompt-editor-with-variables/index.tsx +2 -1
  47. package/src/components/type-selector/index.tsx +9 -7
  48. package/src/components/variable-selector/index.tsx +9 -5
  49. package/src/components/variable-selector/use-variable-tree.tsx +1 -1
  50. package/src/effects/auto-rename-ref/index.ts +1 -1
  51. package/src/effects/listen-ref-schema-change/index.ts +1 -1
  52. package/src/effects/listen-ref-value-change/index.ts +1 -1
  53. package/src/effects/provide-batch-input/index.ts +1 -1
  54. package/src/form-plugins/batch-outputs-plugin/index.ts +1 -1
  55. package/src/form-plugins/infer-assign-plugin/index.ts +1 -1
  56. package/src/form-plugins/infer-inputs-plugin/index.ts +1 -1
  57. package/src/plugins/json-schema-preset/type-definition/array.tsx +3 -1
  58. package/src/plugins/json-schema-preset/type-definition/boolean.tsx +4 -3
  59. package/src/plugins/json-schema-preset/type-definition/integer.tsx +2 -1
  60. package/src/plugins/json-schema-preset/type-definition/number.tsx +2 -1
  61. package/src/plugins/json-schema-preset/type-definition/object.tsx +3 -1
  62. package/src/plugins/json-schema-preset/type-definition/string.tsx +7 -1
  63. package/src/shared/index.ts +1 -0
  64. package/src/shared/inject-material/README.md +170 -0
  65. package/src/shared/inject-material/README.zh.md +174 -0
  66. package/src/shared/inject-material/index.tsx +87 -0
  67. package/src/components/assign-row/config.json +0 -11
  68. package/src/components/assign-rows/config.json +0 -11
  69. package/src/components/batch-outputs/config.json +0 -13
  70. package/src/components/batch-variable-selector/config.json +0 -9
  71. package/src/components/code-editor/config.json +0 -10
  72. package/src/components/code-editor-mini/config.json +0 -7
  73. package/src/components/condition-row/config.json +0 -13
  74. package/src/components/constant-input/config.json +0 -9
  75. package/src/components/display-flow-value/config.json +0 -8
  76. package/src/components/display-inputs-values/config.json +0 -9
  77. package/src/components/display-outputs/config.json +0 -10
  78. package/src/components/display-schema-tag/config.json +0 -10
  79. package/src/components/display-schema-tree/config.json +0 -11
  80. package/src/components/dynamic-value-input/config.json +0 -14
  81. package/src/components/inputs-values/config.json +0 -13
  82. package/src/components/json-editor-with-variables/config.json +0 -13
  83. package/src/components/json-schema-editor/config.json +0 -13
  84. package/src/components/json-schema-editor/utils.ts +0 -29
  85. package/src/components/prompt-editor/config.json +0 -9
  86. package/src/components/prompt-editor-with-inputs/config.json +0 -13
  87. package/src/components/prompt-editor-with-variables/config.json +0 -13
  88. package/src/components/type-selector/config.json +0 -9
  89. package/src/components/variable-selector/config.json +0 -9
  90. package/src/effects/auto-rename-ref/config.json +0 -5
  91. package/src/effects/listen-ref-schema-change/config.json +0 -10
  92. package/src/effects/listen-ref-value-change/config.json +0 -9
  93. package/src/effects/provide-batch-input/config.json +0 -5
  94. package/src/effects/provide-json-schema-outputs/config.json +0 -7
  95. package/src/effects/sync-variable-title/config.json +0 -5
  96. package/src/effects/validate-when-variable-sync/config.json +0 -5
  97. package/src/form-plugins/batch-outputs-plugin/config.json +0 -7
  98. package/src/form-plugins/infer-assign-plugin/config.json +0 -7
  99. package/src/form-plugins/infer-inputs-plugin/config.json +0 -9
  100. package/src/hooks/use-object-list/config.json +0 -8
  101. package/src/shared/format-legacy-refs/config.json +0 -5
  102. package/src/typings/flow-value/config.json +0 -7
  103. package/src/validate/validate-flow-value/config.json +0 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowgram.ai/form-materials",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "homepage": "https://flowgram.ai/",
5
5
  "repository": "https://github.com/bytedance/flowgram.ai",
6
6
  "license": "MIT",
@@ -34,8 +34,8 @@
34
34
  "@codemirror/view": "~6.38.0",
35
35
  "@codemirror/state": "~6.5.2",
36
36
  "typescript": "^5.8.3",
37
- "@flowgram.ai/editor": "0.3.3",
38
- "@flowgram.ai/json-schema": "0.3.3"
37
+ "@flowgram.ai/editor": "0.3.5",
38
+ "@flowgram.ai/json-schema": "0.3.5"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/lodash": "^4.14.137",
@@ -51,8 +51,8 @@
51
51
  "tsup": "^8.0.1",
52
52
  "typescript": "^5.8.3",
53
53
  "vitest": "^0.34.6",
54
- "@flowgram.ai/eslint-config": "0.3.3",
55
- "@flowgram.ai/ts-config": "0.3.3"
54
+ "@flowgram.ai/eslint-config": "0.3.5",
55
+ "@flowgram.ai/ts-config": "0.3.5"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "react": ">=16.8",
@@ -9,11 +9,11 @@ import { IconButton } from '@douyinfe/semi-ui';
9
9
  import { IconMinus } from '@douyinfe/semi-icons';
10
10
 
11
11
  import { IFlowConstantRefValue } from '@/typings';
12
+ import { InjectVariableSelector } from '@/components/variable-selector';
13
+ import { InjectDynamicValueInput } from '@/components/dynamic-value-input';
12
14
 
13
15
  import { AssignRowProps } from './types';
14
16
  import { BlurInput } from './components/blur-input';
15
- import { VariableSelector } from '../variable-selector';
16
- import { DynamicValueInput } from '../dynamic-value-input';
17
17
 
18
18
  export function AssignRow(props: AssignRowProps) {
19
19
  const {
@@ -29,7 +29,7 @@ export function AssignRow(props: AssignRowProps) {
29
29
  <div style={{ display: 'flex', alignItems: 'center', gap: 5 }}>
30
30
  <div style={{ width: 150, minWidth: 150, maxWidth: 150 }}>
31
31
  {value?.operator === 'assign' ? (
32
- <VariableSelector
32
+ <InjectVariableSelector
33
33
  style={{ width: '100%', height: 26 }}
34
34
  value={value?.left?.content}
35
35
  config={{ placeholder: 'Select Left' }}
@@ -56,7 +56,7 @@ export function AssignRow(props: AssignRowProps) {
56
56
  )}
57
57
  </div>
58
58
  <div style={{ flexGrow: 1 }}>
59
- <DynamicValueInput
59
+ <InjectDynamicValueInput
60
60
  readonly={readonly}
61
61
  value={value?.right as IFlowConstantRefValue | undefined}
62
62
  onChange={(v) =>
@@ -9,7 +9,7 @@ import { FieldArray, FieldArrayRenderProps } from '@flowgram.ai/editor';
9
9
  import { Button } from '@douyinfe/semi-ui';
10
10
  import { IconPlus } from '@douyinfe/semi-icons';
11
11
 
12
- import { AssignRow, AssignValueType } from '../assign-row';
12
+ import { AssignRow, AssignValueType } from '@/components/assign-row';
13
13
 
14
14
  interface AssignRowsProps {
15
15
  name: string;
@@ -8,9 +8,10 @@ import React from 'react';
8
8
  import { Button, Input } from '@douyinfe/semi-ui';
9
9
  import { IconDelete, IconPlus } from '@douyinfe/semi-icons';
10
10
 
11
+ import { useObjectList } from '@/hooks';
12
+ import { InjectVariableSelector } from '@/components/variable-selector';
13
+
11
14
  import { PropsType } from './types';
12
- import { VariableSelector } from '../variable-selector';
13
- import { useObjectList } from '../../hooks';
14
15
  import { UIRow, UIRows } from './styles';
15
16
 
16
17
  export function BatchOutputs(props: PropsType) {
@@ -30,7 +31,7 @@ export function BatchOutputs(props: PropsType) {
30
31
  value={item.key}
31
32
  onChange={(v) => updateKey(item.id, v)}
32
33
  />
33
- <VariableSelector
34
+ <InjectVariableSelector
34
35
  style={{ flexGrow: 1 }}
35
36
  readonly={readonly}
36
37
  value={item.value?.content}
@@ -3,7 +3,7 @@
3
3
  * SPDX-License-Identifier: MIT
4
4
  */
5
5
 
6
- import { IFlowRefValue } from '../../typings';
6
+ import { IFlowRefValue } from '@/typings';
7
7
 
8
8
  export type ValueType = Record<string, IFlowRefValue | undefined>;
9
9
 
@@ -8,7 +8,7 @@ import React from 'react';
8
8
  import { IJsonSchema } from '@flowgram.ai/json-schema';
9
9
  import { PrivateScopeProvider } from '@flowgram.ai/editor';
10
10
 
11
- import { VariableSelector, VariableSelectorProps } from '../variable-selector';
11
+ import { VariableSelector, VariableSelectorProps } from '@/components/variable-selector';
12
12
 
13
13
  const batchVariableSchema: IJsonSchema = {
14
14
  type: 'array',
@@ -7,7 +7,7 @@ import React from 'react';
7
7
 
8
8
  import styled from 'styled-components';
9
9
 
10
- import { CodeEditor, CodeEditorPropsType } from '../code-editor';
10
+ import { CodeEditor, CodeEditorPropsType } from '@/components/code-editor';
11
11
 
12
12
  const UIMini = styled.div`
13
13
  .ͼ1 .cm-content {
@@ -5,7 +5,7 @@
5
5
 
6
6
  import { IRules, Op, OpConfigs } from './types';
7
7
 
8
- export const rules: IRules = {
8
+ export const defaultRules: IRules = {
9
9
  string: {
10
10
  [Op.EQ]: 'string',
11
11
  [Op.NEQ]: 'string',
@@ -62,7 +62,7 @@ export const rules: IRules = {
62
62
  },
63
63
  };
64
64
 
65
- export const opConfigs: OpConfigs = {
65
+ export const defaultOpConfigs: OpConfigs = {
66
66
  [Op.EQ]: {
67
67
  label: 'Equal',
68
68
  abbreviation: '=',
@@ -5,30 +5,34 @@
5
5
 
6
6
  import React, { useMemo } from 'react';
7
7
 
8
+ import { I18n } from '@flowgram.ai/editor';
8
9
  import { Button, Select } from '@douyinfe/semi-ui';
9
10
  import { IconChevronDownStroked } from '@douyinfe/semi-icons';
10
11
 
11
- import { IRule, Op } from '../types';
12
- import { opConfigs } from '../constants';
12
+ import { IRule, OpConfigs } from '../types';
13
+ import { defaultOpConfigs } from '../constants';
13
14
 
14
15
  interface HookParams {
15
16
  rule?: IRule;
16
- op?: Op;
17
- onChange: (op: Op) => void;
17
+ op?: string;
18
+ onChange: (op: string) => void;
18
19
  readonly?: boolean;
20
+ userOps?: OpConfigs;
19
21
  }
20
22
 
21
- export function useOp({ rule, op, onChange, readonly }: HookParams) {
23
+ export function useOp({ rule, op, onChange, readonly, userOps }: HookParams) {
22
24
  const options = useMemo(
23
25
  () =>
24
26
  Object.keys(rule || {}).map((_op) => ({
25
- ...(opConfigs[_op as Op] || {}),
27
+ ...(defaultOpConfigs[_op] || {}),
28
+ ...(userOps?.[_op] || {}),
26
29
  value: _op,
30
+ label: I18n.t(userOps?.[_op]?.label || defaultOpConfigs[_op]?.label),
27
31
  })),
28
- [rule]
32
+ [rule, userOps]
29
33
  );
30
34
 
31
- const opConfig = useMemo(() => opConfigs[op as Op], [op]);
35
+ const opConfig = useMemo(() => defaultOpConfigs[op as string], [op]);
32
36
 
33
37
  const renderOpSelect = () => (
34
38
  <Select
@@ -38,7 +42,7 @@ export function useOp({ rule, op, onChange, readonly }: HookParams) {
38
42
  value={op}
39
43
  optionList={options}
40
44
  onChange={(v) => {
41
- onChange(v as Op);
45
+ onChange(v as string);
42
46
  }}
43
47
  triggerRender={({ value }) => (
44
48
  <Button size="small" disabled={!rule}>
@@ -8,12 +8,16 @@ import { useMemo } from 'react';
8
8
  import { JsonSchemaUtils, JsonSchemaBasicType } from '@flowgram.ai/json-schema';
9
9
  import { useScopeAvailable } from '@flowgram.ai/editor';
10
10
 
11
- import { rules } from '../constants';
12
- import { IFlowRefValue } from '../../../typings';
11
+ import { IFlowRefValue } from '@/typings';
13
12
 
14
- export function useRule(left?: IFlowRefValue) {
13
+ import { IRules } from '../types';
14
+ import { defaultRules } from '../constants';
15
+
16
+ export function useRule(left?: IFlowRefValue, userRules?: IRules) {
15
17
  const available = useScopeAvailable();
16
18
 
19
+ const rules = useMemo(() => ({ ...defaultRules, ...(userRules || {}) }), [userRules]);
20
+
17
21
  const variable = useMemo(() => {
18
22
  if (!left) return undefined;
19
23
  return available.getByKeyPath(left.content);
@@ -25,7 +29,7 @@ export function useRule(left?: IFlowRefValue) {
25
29
  const schema = JsonSchemaUtils.astToSchema(variable.type, { drilldown: false });
26
30
 
27
31
  return rules[schema?.type as JsonSchemaBasicType];
28
- }, [variable?.type]);
32
+ }, [variable?.type, rules]);
29
33
 
30
34
  return { rule };
31
35
  }
@@ -5,35 +5,52 @@
5
5
 
6
6
  import React, { useMemo } from 'react';
7
7
 
8
- import { JsonSchemaBasicType } from '@flowgram.ai/json-schema';
8
+ import { I18n } from '@flowgram.ai/editor';
9
9
  import { Input } from '@douyinfe/semi-ui';
10
10
 
11
- import { ConditionRowValueType, Op } from './types';
11
+ import { InjectVariableSelector } from '@/components/variable-selector';
12
+ import { InjectDynamicValueInput } from '@/components/dynamic-value-input';
13
+
14
+ import { ConditionRowValueType, IRules, OpConfigs } from './types';
12
15
  import { UIContainer, UILeft, UIOperator, UIRight, UIValues } from './styles';
13
16
  import { useRule } from './hooks/useRule';
14
17
  import { useOp } from './hooks/useOp';
15
- import { VariableSelector } from '../variable-selector';
16
- import { DynamicValueInput } from '../dynamic-value-input';
17
18
 
18
19
  interface PropTypes {
19
20
  value?: ConditionRowValueType;
20
21
  onChange: (value?: ConditionRowValueType) => void;
21
22
  style?: React.CSSProperties;
22
23
  readonly?: boolean;
24
+ ruleConfig?: {
25
+ ops?: OpConfigs;
26
+ rules?: IRules;
27
+ };
23
28
  }
24
29
 
25
- export function ConditionRow({ style, value, onChange, readonly }: PropTypes) {
30
+ const defaultRuleConfig = {
31
+ ops: {},
32
+ rules: {},
33
+ };
34
+
35
+ export function ConditionRow({
36
+ style,
37
+ value,
38
+ onChange,
39
+ readonly,
40
+ ruleConfig = defaultRuleConfig,
41
+ }: PropTypes) {
26
42
  const { left, operator, right } = value || {};
27
- const { rule } = useRule(left);
43
+ const { rule } = useRule(left, ruleConfig.rules);
28
44
  const { renderOpSelect, opConfig } = useOp({
29
45
  rule,
30
46
  op: operator,
31
47
  onChange: (v) => onChange({ ...value, operator: v }),
32
48
  readonly,
49
+ userOps: ruleConfig.ops,
33
50
  });
34
51
 
35
52
  const targetSchema = useMemo(() => {
36
- const targetType: JsonSchemaBasicType | null = rule?.[operator as Op] || null;
53
+ const targetType: string | null = rule?.[operator || ''] || null;
37
54
  return targetType ? { type: targetType, extra: { weak: true } } : null;
38
55
  }, [rule, opConfig]);
39
56
 
@@ -42,7 +59,7 @@ export function ConditionRow({ style, value, onChange, readonly }: PropTypes) {
42
59
  <UIOperator>{renderOpSelect()}</UIOperator>
43
60
  <UIValues>
44
61
  <UILeft>
45
- <VariableSelector
62
+ <InjectVariableSelector
46
63
  readonly={readonly}
47
64
  style={{ width: '100%' }}
48
65
  value={left?.content}
@@ -59,7 +76,7 @@ export function ConditionRow({ style, value, onChange, readonly }: PropTypes) {
59
76
  </UILeft>
60
77
  <UIRight>
61
78
  {targetSchema ? (
62
- <DynamicValueInput
79
+ <InjectDynamicValueInput
63
80
  readonly={readonly || !rule}
64
81
  value={right}
65
82
  schema={targetSchema}
@@ -70,7 +87,7 @@ export function ConditionRow({ style, value, onChange, readonly }: PropTypes) {
70
87
  size="small"
71
88
  disabled
72
89
  style={{ pointerEvents: 'none' }}
73
- value={opConfig?.rightDisplay || 'Empty'}
90
+ value={opConfig?.rightDisplay || I18n.t('Empty')}
74
91
  />
75
92
  )}
76
93
  </UIRight>
@@ -3,9 +3,7 @@
3
3
  * SPDX-License-Identifier: MIT
4
4
  */
5
5
 
6
- import { JsonSchemaBasicType } from '@flowgram.ai/json-schema';
7
-
8
- import { IFlowConstantRefValue, IFlowRefValue } from '../../typings';
6
+ import { IFlowConstantRefValue, IFlowRefValue } from '@/typings';
9
7
 
10
8
  export enum Op {
11
9
  EQ = 'eq',
@@ -31,14 +29,14 @@ export interface OpConfig {
31
29
  rightDisplay?: string;
32
30
  }
33
31
 
34
- export type OpConfigs = Record<Op, OpConfig>;
32
+ export type OpConfigs = Record<string, OpConfig>;
35
33
 
36
- export type IRule = Partial<Record<Op, JsonSchemaBasicType | null>>;
34
+ export type IRule = Partial<Record<string, string | null>>;
37
35
 
38
- export type IRules = Record<JsonSchemaBasicType, IRule>;
36
+ export type IRules = Record<string, IRule>;
39
37
 
40
38
  export interface ConditionRowValueType {
41
39
  left?: IFlowRefValue;
42
- operator?: Op;
40
+ operator?: string;
43
41
  right?: IFlowConstantRefValue;
44
42
  }
@@ -8,8 +8,11 @@ import React, { useMemo } from 'react';
8
8
 
9
9
  import { Input } from '@douyinfe/semi-ui';
10
10
 
11
- import { useTypeManager } from '../../plugins';
12
- import { PropsType } from './types';
11
+ import { useTypeManager } from '@/plugins';
12
+
13
+ import { PropsType, Strategy as ConstantInputStrategy } from './types';
14
+
15
+ export { ConstantInputStrategy };
13
16
 
14
17
  export function ConstantInput(props: PropsType) {
15
18
  const { value, onChange, schema, strategies, fallbackRenderer, readonly, ...rest } = props;
@@ -5,7 +5,7 @@
5
5
 
6
6
  import { IJsonSchema } from '@flowgram.ai/json-schema';
7
7
 
8
- import { ConstantRendererProps } from '../../plugins';
8
+ import { ConstantRendererProps } from '@/plugins';
9
9
 
10
10
  export interface Strategy<Value = any> {
11
11
  hit: (schema: IJsonSchema) => boolean;
@@ -8,8 +8,8 @@ import React, { useMemo } from 'react';
8
8
  import { JsonSchemaTypeManager, JsonSchemaUtils } from '@flowgram.ai/json-schema';
9
9
  import { useScopeAvailable } from '@flowgram.ai/editor';
10
10
 
11
- import { DisplaySchemaTag } from '../display-schema-tag';
12
- import { IFlowValue } from '../../typings';
11
+ import { IFlowValue } from '@/typings';
12
+ import { DisplaySchemaTag } from '@/components/display-schema-tag';
13
13
 
14
14
  interface PropsType {
15
15
  value?: IFlowValue;
@@ -5,8 +5,9 @@
5
5
 
6
6
  import React from 'react';
7
7
 
8
- import { DisplayFlowValue } from '../display-flow-value';
9
- import { IFlowValue } from '../../typings';
8
+ import { IFlowValue } from '@/typings';
9
+ import { DisplayFlowValue } from '@/components/display-flow-value';
10
+
10
11
  import { DisplayInputsWrapper } from './styles';
11
12
 
12
13
  interface PropsType {
@@ -8,7 +8,8 @@ import React, { useEffect } from 'react';
8
8
  import { IJsonSchema, JsonSchemaTypeManager, JsonSchemaUtils } from '@flowgram.ai/json-schema';
9
9
  import { useCurrentScope, useRefresh } from '@flowgram.ai/editor';
10
10
 
11
- import { DisplaySchemaTag } from '../display-schema-tag';
11
+ import { DisplaySchemaTag } from '@/components/display-schema-tag';
12
+
12
13
  import { DisplayOutputsWrapper } from './styles';
13
14
 
14
15
  interface PropsType {
@@ -8,8 +8,9 @@ import React from 'react';
8
8
  import { IJsonSchema } from '@flowgram.ai/json-schema';
9
9
  import { Popover } from '@douyinfe/semi-ui';
10
10
 
11
- import { DisplaySchemaTree } from '../display-schema-tree';
12
- import { useTypeManager } from '../../plugins';
11
+ import { useTypeManager } from '@/plugins';
12
+ import { DisplaySchemaTree } from '@/components/display-schema-tree';
13
+
13
14
  import { PopoverContent, StyledTag, TitleSpan } from './styles';
14
15
 
15
16
  interface PropsType {
@@ -7,7 +7,8 @@ import React from 'react';
7
7
 
8
8
  import { IJsonSchema, JsonSchemaTypeManager } from '@flowgram.ai/json-schema';
9
9
 
10
- import { useTypeManager } from '../../plugins';
10
+ import { useTypeManager } from '@/plugins';
11
+
11
12
  import { HorizontalLine, TreeItem, TreeLevel, TreeRow, TreeTitle } from './styles';
12
13
 
13
14
  interface PropsType {
@@ -8,7 +8,7 @@ import { useMemo, useState } from 'react';
8
8
  import { IJsonSchema } from '@flowgram.ai/json-schema';
9
9
  import { useScopeAvailable } from '@flowgram.ai/editor';
10
10
 
11
- import { IFlowConstantRefValue } from '../../typings/flow-value';
11
+ import { IFlowConstantRefValue } from '@/typings/flow-value';
12
12
 
13
13
  export function useRefVariable(value?: IFlowConstantRefValue) {
14
14
  const available = useScopeAvailable();
@@ -9,11 +9,12 @@ import { JsonSchemaUtils, IJsonSchema } from '@flowgram.ai/json-schema';
9
9
  import { IconButton } from '@douyinfe/semi-ui';
10
10
  import { IconSetting } from '@douyinfe/semi-icons';
11
11
 
12
- import { VariableSelector } from '../variable-selector';
13
- import { TypeSelector } from '../type-selector';
14
- import { Strategy } from '../constant-input/types';
15
- import { ConstantInput } from '../constant-input';
16
- import { IFlowConstantRefValue } from '../../typings/flow-value';
12
+ import { IFlowConstantRefValue } from '@/typings/flow-value';
13
+ import { createInjectMaterial } from '@/shared';
14
+ import { InjectVariableSelector } from '@/components/variable-selector';
15
+ import { TypeSelector } from '@/components/type-selector';
16
+ import { ConstantInput, ConstantInputStrategy } from '@/components/constant-input';
17
+
17
18
  import { UIContainer, UIMain, UITrigger, UIType } from './styles';
18
19
  import { useIncludeSchema, useRefVariable, useSelectSchema } from './hooks';
19
20
 
@@ -25,7 +26,7 @@ interface PropsType {
25
26
  style?: React.CSSProperties;
26
27
  schema?: IJsonSchema;
27
28
  constantProps?: {
28
- strategies?: Strategy[];
29
+ strategies?: ConstantInputStrategy[];
29
30
  schema?: IJsonSchema; // set schema of constant input only
30
31
  [key: string]: any;
31
32
  };
@@ -88,7 +89,7 @@ export function DynamicValueInput({
88
89
  if (value?.type === 'ref') {
89
90
  // Display Variable Or Delete
90
91
  return (
91
- <VariableSelector
92
+ <InjectVariableSelector
92
93
  style={{ width: '100%' }}
93
94
  value={value?.content}
94
95
  onChange={(_v) => onChange(_v ? { type: 'ref', content: _v } : undefined)}
@@ -108,7 +109,7 @@ export function DynamicValueInput({
108
109
  readonly={readonly}
109
110
  strategies={[...(constantProps?.strategies || [])]}
110
111
  fallbackRenderer={() => (
111
- <VariableSelector
112
+ <InjectVariableSelector
112
113
  style={{ width: '100%' }}
113
114
  onChange={(_v) => onChange(_v ? { type: 'ref', content: _v } : undefined)}
114
115
  includeSchema={includeSchema}
@@ -121,7 +122,7 @@ export function DynamicValueInput({
121
122
  };
122
123
 
123
124
  const renderTrigger = () => (
124
- <VariableSelector
125
+ <InjectVariableSelector
125
126
  style={{ width: '100%' }}
126
127
  value={value?.type === 'ref' ? value?.content : undefined}
127
128
  onChange={(_v) => onChange({ type: 'ref', content: _v })}
@@ -141,3 +142,6 @@ export function DynamicValueInput({
141
142
  </UIContainer>
142
143
  );
143
144
  }
145
+
146
+ DynamicValueInput.renderKey = 'dynamic-value-input-render-key';
147
+ export const InjectDynamicValueInput = createInjectMaterial(DynamicValueInput);
@@ -5,13 +5,15 @@
5
5
 
6
6
  import React from 'react';
7
7
 
8
+ import { I18n } from '@flowgram.ai/editor';
8
9
  import { Button, IconButton } from '@douyinfe/semi-ui';
9
10
  import { IconDelete, IconPlus } from '@douyinfe/semi-icons';
10
11
 
12
+ import { IFlowConstantRefValue, IFlowValue } from '@/typings';
13
+ import { useObjectList } from '@/hooks';
14
+ import { InjectDynamicValueInput } from '@/components/dynamic-value-input';
15
+
11
16
  import { PropsType } from './types';
12
- import { DynamicValueInput } from '../dynamic-value-input';
13
- import { IFlowConstantRefValue, IFlowValue } from '../../typings';
14
- import { useObjectList } from '../../hooks';
15
17
  import { UIRow, UIRows } from './styles';
16
18
  import { BlurInput } from './components/blur-input';
17
19
 
@@ -41,9 +43,9 @@ export function InputsValues({
41
43
  size="small"
42
44
  value={item.key}
43
45
  onChange={(v) => updateKey(item.id, v)}
44
- placeholder="Input Key"
46
+ placeholder={I18n.t('Input Key')}
45
47
  />
46
- <DynamicValueInput
48
+ <InjectDynamicValueInput
47
49
  style={{ flexGrow: 1 }}
48
50
  readonly={readonly}
49
51
  value={item.value as IFlowConstantRefValue}
@@ -5,8 +5,8 @@
5
5
 
6
6
  import { IJsonSchema } from '@flowgram.ai/json-schema';
7
7
 
8
- import { Strategy } from '../constant-input/types';
9
- import { IFlowValue } from '../../typings';
8
+ import { IFlowValue } from '@/typings';
9
+ import { ConstantInputStrategy } from '@/components/constant-input';
10
10
 
11
11
  export interface PropsType {
12
12
  value?: Record<string, IFlowValue | undefined>;
@@ -16,7 +16,7 @@ export interface PropsType {
16
16
  schema?: IJsonSchema;
17
17
  style?: React.CSSProperties;
18
18
  constantProps?: {
19
- strategies?: Strategy[];
19
+ strategies?: ConstantInputStrategy[];
20
20
  [key: string]: any;
21
21
  };
22
22
  }
@@ -15,7 +15,7 @@ import {
15
15
  } from '@coze-editor/editor/react';
16
16
  import { EditorAPI } from '@coze-editor/editor/preset-prompt';
17
17
 
18
- import { useVariableTree } from '../../variable-selector';
18
+ import { useVariableTree } from '@/components/variable-selector';
19
19
 
20
20
  export function VariableTree() {
21
21
  const [posKey, setPosKey] = useState('');
@@ -8,9 +8,10 @@ import React from 'react';
8
8
  import { transformerCreator } from '@coze-editor/editor/preset-code';
9
9
  import { Text } from '@coze-editor/editor/language-json';
10
10
 
11
+ import { CodeEditor, type CodeEditorPropsType } from '@/components/code-editor';
12
+
11
13
  import { VariableTree } from './extensions/variable-tree';
12
14
  import { VariableTagInject } from './extensions/variable-tag';
13
- import { CodeEditor, type CodeEditorPropsType } from '../code-editor';
14
15
 
15
16
  type Match = { match: string; range: [number, number] };
16
17
  function findAllMatches(inputString: string, regex: RegExp): Match[] {