@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.
- package/bin/index.ts +5 -19
- package/bin/materials.ts +31 -89
- package/bin/project.ts +4 -0
- package/bin/utils/import.ts +127 -0
- package/bin/utils/traverse-file.ts +60 -0
- package/dist/esm/index.js +431 -505
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +77 -23
- package/dist/index.d.ts +77 -23
- package/dist/index.js +657 -731
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/components/assign-row/index.tsx +4 -4
- package/src/components/assign-rows/index.tsx +1 -1
- package/src/components/batch-outputs/index.tsx +4 -3
- package/src/components/batch-outputs/types.ts +1 -1
- package/src/components/batch-variable-selector/index.tsx +1 -1
- package/src/components/code-editor-mini/index.tsx +1 -1
- package/src/components/condition-row/constants.ts +2 -2
- package/src/components/condition-row/hooks/useOp.tsx +13 -9
- package/src/components/condition-row/hooks/useRule.ts +8 -4
- package/src/components/condition-row/index.tsx +27 -10
- package/src/components/condition-row/types.ts +5 -7
- package/src/components/constant-input/index.tsx +5 -2
- package/src/components/constant-input/types.ts +1 -1
- package/src/components/display-flow-value/index.tsx +2 -2
- package/src/components/display-inputs-values/index.tsx +3 -2
- package/src/components/display-outputs/index.tsx +2 -1
- package/src/components/display-schema-tag/index.tsx +3 -2
- package/src/components/display-schema-tree/index.tsx +2 -1
- package/src/components/dynamic-value-input/hooks.ts +1 -1
- package/src/components/dynamic-value-input/index.tsx +13 -9
- package/src/components/inputs-values/index.tsx +7 -5
- package/src/components/inputs-values/types.ts +3 -3
- package/src/components/json-editor-with-variables/extensions/variable-tree.tsx +1 -1
- package/src/components/json-editor-with-variables/index.tsx +2 -1
- package/src/components/json-schema-editor/default-value.tsx +11 -105
- package/src/components/json-schema-editor/hooks.tsx +53 -94
- package/src/components/json-schema-editor/index.tsx +18 -12
- package/src/components/json-schema-editor/styles.tsx +0 -29
- package/src/components/prompt-editor/types.tsx +1 -1
- package/src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx +2 -1
- package/src/components/prompt-editor-with-inputs/index.tsx +3 -2
- package/src/components/prompt-editor-with-inputs/inputs-picker.tsx +1 -1
- package/src/components/prompt-editor-with-variables/extensions/variable-tree.tsx +1 -1
- package/src/components/prompt-editor-with-variables/index.tsx +2 -1
- package/src/components/type-selector/index.tsx +9 -7
- package/src/components/variable-selector/index.tsx +9 -5
- package/src/components/variable-selector/use-variable-tree.tsx +1 -1
- package/src/effects/auto-rename-ref/index.ts +1 -1
- package/src/effects/listen-ref-schema-change/index.ts +1 -1
- package/src/effects/listen-ref-value-change/index.ts +1 -1
- package/src/effects/provide-batch-input/index.ts +1 -1
- package/src/form-plugins/batch-outputs-plugin/index.ts +1 -1
- package/src/form-plugins/infer-assign-plugin/index.ts +1 -1
- package/src/form-plugins/infer-inputs-plugin/index.ts +1 -1
- package/src/plugins/json-schema-preset/type-definition/array.tsx +3 -1
- package/src/plugins/json-schema-preset/type-definition/boolean.tsx +4 -3
- package/src/plugins/json-schema-preset/type-definition/integer.tsx +2 -1
- package/src/plugins/json-schema-preset/type-definition/number.tsx +2 -1
- package/src/plugins/json-schema-preset/type-definition/object.tsx +3 -1
- package/src/plugins/json-schema-preset/type-definition/string.tsx +7 -1
- package/src/shared/index.ts +1 -0
- package/src/shared/inject-material/README.md +170 -0
- package/src/shared/inject-material/README.zh.md +174 -0
- package/src/shared/inject-material/index.tsx +87 -0
- package/src/components/assign-row/config.json +0 -11
- package/src/components/assign-rows/config.json +0 -11
- package/src/components/batch-outputs/config.json +0 -13
- package/src/components/batch-variable-selector/config.json +0 -9
- package/src/components/code-editor/config.json +0 -10
- package/src/components/code-editor-mini/config.json +0 -7
- package/src/components/condition-row/config.json +0 -13
- package/src/components/constant-input/config.json +0 -9
- package/src/components/display-flow-value/config.json +0 -8
- package/src/components/display-inputs-values/config.json +0 -9
- package/src/components/display-outputs/config.json +0 -10
- package/src/components/display-schema-tag/config.json +0 -10
- package/src/components/display-schema-tree/config.json +0 -11
- package/src/components/dynamic-value-input/config.json +0 -14
- package/src/components/inputs-values/config.json +0 -13
- package/src/components/json-editor-with-variables/config.json +0 -13
- package/src/components/json-schema-editor/config.json +0 -13
- package/src/components/json-schema-editor/utils.ts +0 -29
- package/src/components/prompt-editor/config.json +0 -9
- package/src/components/prompt-editor-with-inputs/config.json +0 -13
- package/src/components/prompt-editor-with-variables/config.json +0 -13
- package/src/components/type-selector/config.json +0 -9
- package/src/components/variable-selector/config.json +0 -9
- package/src/effects/auto-rename-ref/config.json +0 -5
- package/src/effects/listen-ref-schema-change/config.json +0 -10
- package/src/effects/listen-ref-value-change/config.json +0 -9
- package/src/effects/provide-batch-input/config.json +0 -5
- package/src/effects/provide-json-schema-outputs/config.json +0 -7
- package/src/effects/sync-variable-title/config.json +0 -5
- package/src/effects/validate-when-variable-sync/config.json +0 -5
- package/src/form-plugins/batch-outputs-plugin/config.json +0 -7
- package/src/form-plugins/infer-assign-plugin/config.json +0 -7
- package/src/form-plugins/infer-inputs-plugin/config.json +0 -9
- package/src/hooks/use-object-list/config.json +0 -8
- package/src/shared/format-legacy-refs/config.json +0 -5
- package/src/typings/flow-value/config.json +0 -7
- 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
|
+
"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.
|
|
38
|
-
"@flowgram.ai/json-schema": "0.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.
|
|
55
|
-
"@flowgram.ai/ts-config": "0.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
|
-
<
|
|
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
|
-
<
|
|
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 '
|
|
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
|
-
<
|
|
34
|
+
<InjectVariableSelector
|
|
34
35
|
style={{ flexGrow: 1 }}
|
|
35
36
|
readonly={readonly}
|
|
36
37
|
value={item.value?.content}
|
|
@@ -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 '
|
|
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 '
|
|
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
|
|
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
|
|
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,
|
|
12
|
-
import {
|
|
12
|
+
import { IRule, OpConfigs } from '../types';
|
|
13
|
+
import { defaultOpConfigs } from '../constants';
|
|
13
14
|
|
|
14
15
|
interface HookParams {
|
|
15
16
|
rule?: IRule;
|
|
16
|
-
op?:
|
|
17
|
-
onChange: (op:
|
|
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
|
-
...(
|
|
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(() =>
|
|
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
|
|
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 {
|
|
12
|
-
import { IFlowRefValue } from '../../../typings';
|
|
11
|
+
import { IFlowRefValue } from '@/typings';
|
|
13
12
|
|
|
14
|
-
|
|
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 {
|
|
8
|
+
import { I18n } from '@flowgram.ai/editor';
|
|
9
9
|
import { Input } from '@douyinfe/semi-ui';
|
|
10
10
|
|
|
11
|
-
import {
|
|
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
|
-
|
|
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:
|
|
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
|
-
<
|
|
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
|
-
<
|
|
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 {
|
|
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<
|
|
32
|
+
export type OpConfigs = Record<string, OpConfig>;
|
|
35
33
|
|
|
36
|
-
export type IRule = Partial<Record<
|
|
34
|
+
export type IRule = Partial<Record<string, string | null>>;
|
|
37
35
|
|
|
38
|
-
export type IRules = Record<
|
|
36
|
+
export type IRules = Record<string, IRule>;
|
|
39
37
|
|
|
40
38
|
export interface ConditionRowValueType {
|
|
41
39
|
left?: IFlowRefValue;
|
|
42
|
-
operator?:
|
|
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 '
|
|
12
|
-
|
|
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;
|
|
@@ -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 {
|
|
12
|
-
import {
|
|
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 {
|
|
9
|
-
import {
|
|
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 '
|
|
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 {
|
|
12
|
-
import {
|
|
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 '
|
|
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 '
|
|
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 {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
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?:
|
|
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
|
-
<
|
|
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
|
-
<
|
|
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
|
-
<
|
|
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=
|
|
46
|
+
placeholder={I18n.t('Input Key')}
|
|
45
47
|
/>
|
|
46
|
-
<
|
|
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 {
|
|
9
|
-
import {
|
|
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?:
|
|
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 '
|
|
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[] {
|