@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.
- 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 +383 -488
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +64 -6
- package/dist/index.d.ts +64 -6
- package/dist/index.js +625 -730
- 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/hooks/useRule.ts +2 -1
- package/src/components/condition-row/index.tsx +5 -4
- package/src/components/condition-row/types.ts +1 -1
- 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 +11 -8
- 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 +7 -3
- package/src/components/variable-selector/index.tsx +7 -4
- 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/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
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { useEffect,
|
|
6
|
+
import { useEffect, useState } from 'react';
|
|
7
7
|
|
|
8
|
-
import { omit } from 'lodash';
|
|
9
|
-
import {
|
|
8
|
+
import { difference, omit } from 'lodash';
|
|
9
|
+
import { produce } from 'immer';
|
|
10
|
+
import { IJsonSchema, type JsonSchemaTypeManager, useTypeManager } from '@flowgram.ai/json-schema';
|
|
10
11
|
|
|
11
12
|
import { PropertyValueType } from './types';
|
|
12
13
|
|
|
@@ -15,92 +16,46 @@ function genId() {
|
|
|
15
16
|
return _id++;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
function getDrilldownSchema(
|
|
19
|
-
value?: PropertyValueType,
|
|
20
|
-
path?: (keyof PropertyValueType)[]
|
|
21
|
-
): { schema?: PropertyValueType | null; path?: (keyof PropertyValueType)[] } {
|
|
22
|
-
if (!value) {
|
|
23
|
-
return {};
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (value.type === 'array' && value.items) {
|
|
27
|
-
return getDrilldownSchema(value.items, [...(path || []), 'items']);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return { schema: value, path };
|
|
31
|
-
}
|
|
32
|
-
|
|
33
19
|
export function usePropertiesEdit(
|
|
34
20
|
value?: PropertyValueType,
|
|
35
21
|
onChange?: (value: PropertyValueType) => void
|
|
36
22
|
) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
() =>
|
|
45
|
-
isDrilldownObject
|
|
46
|
-
? Object.entries(drilldown.schema?.properties || {})
|
|
47
|
-
.sort(([, a], [, b]) => (a.extra?.index ?? 0) - (b.extra?.index ?? 0))
|
|
48
|
-
.map(
|
|
49
|
-
([name, _value], index) =>
|
|
50
|
-
({
|
|
51
|
-
key: genId(),
|
|
52
|
-
name,
|
|
53
|
-
isPropertyRequired: drilldown.schema?.required?.includes(name) || false,
|
|
54
|
-
..._value,
|
|
55
|
-
extra: {
|
|
56
|
-
...(_value.extra || {}),
|
|
57
|
-
index,
|
|
58
|
-
},
|
|
59
|
-
} as PropertyValueType)
|
|
60
|
-
)
|
|
61
|
-
: [],
|
|
62
|
-
[isDrilldownObject]
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
const [propertyList, setPropertyList] = useState<PropertyValueType[]>(initPropertyList);
|
|
66
|
-
|
|
67
|
-
const mountRef = useRef(false);
|
|
23
|
+
const typeManager = useTypeManager() as JsonSchemaTypeManager;
|
|
24
|
+
|
|
25
|
+
// Get drilldown properties (array.items.items.properties...)
|
|
26
|
+
const drilldownSchema = typeManager.getPropertiesParent(value || {});
|
|
27
|
+
const canAddField = typeManager.canAddField(value || {});
|
|
28
|
+
|
|
29
|
+
const [propertyList, setPropertyList] = useState<PropertyValueType[]>([]);
|
|
68
30
|
|
|
69
31
|
useEffect(() => {
|
|
70
|
-
// If
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
.
|
|
83
|
-
.
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
..._value,
|
|
98
|
-
};
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
mountRef.current = true;
|
|
103
|
-
}, [drilldown.schema]);
|
|
32
|
+
// If the value is changed, update the property list
|
|
33
|
+
setPropertyList((_list) => {
|
|
34
|
+
const newNames = Object.entries(drilldownSchema?.properties || {})
|
|
35
|
+
.sort(([, a], [, b]) => (a.extra?.index ?? 0) - (b.extra?.index ?? 0))
|
|
36
|
+
.map(([key]) => key);
|
|
37
|
+
|
|
38
|
+
const oldNames = _list.map((item) => item.name).filter(Boolean) as string[];
|
|
39
|
+
const addNames = difference(newNames, oldNames);
|
|
40
|
+
|
|
41
|
+
return _list
|
|
42
|
+
.filter((item) => !item.name || newNames.includes(item.name))
|
|
43
|
+
.map((item) => ({
|
|
44
|
+
key: item.key,
|
|
45
|
+
name: item.name,
|
|
46
|
+
isPropertyRequired: drilldownSchema?.required?.includes(item.name || '') || false,
|
|
47
|
+
...item,
|
|
48
|
+
}))
|
|
49
|
+
.concat(
|
|
50
|
+
addNames.map((_name) => ({
|
|
51
|
+
key: genId(),
|
|
52
|
+
name: _name,
|
|
53
|
+
isPropertyRequired: drilldownSchema?.required?.includes(_name) || false,
|
|
54
|
+
...(drilldownSchema?.properties?.[_name] || {}),
|
|
55
|
+
}))
|
|
56
|
+
);
|
|
57
|
+
});
|
|
58
|
+
}, [drilldownSchema]);
|
|
104
59
|
|
|
105
60
|
const updatePropertyList = (updater: (list: PropertyValueType[]) => PropertyValueType[]) => {
|
|
106
61
|
setPropertyList((_list) => {
|
|
@@ -122,21 +77,25 @@ export function usePropertiesEdit(
|
|
|
122
77
|
}
|
|
123
78
|
}
|
|
124
79
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
drilldownSchema.properties = nextProperties;
|
|
130
|
-
drilldownSchema.required = nextRequired;
|
|
80
|
+
onChange?.(
|
|
81
|
+
produce(value || {}, (draft) => {
|
|
82
|
+
const propertiesParent = typeManager.getPropertiesParent(draft);
|
|
131
83
|
|
|
132
|
-
|
|
84
|
+
if (propertiesParent) {
|
|
85
|
+
propertiesParent.properties = nextProperties;
|
|
86
|
+
propertiesParent.required = nextRequired;
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
);
|
|
133
91
|
|
|
134
92
|
return next;
|
|
135
93
|
});
|
|
136
94
|
};
|
|
137
95
|
|
|
138
96
|
const onAddProperty = () => {
|
|
139
|
-
|
|
97
|
+
// set property list only, not trigger updatePropertyList
|
|
98
|
+
setPropertyList((_list) => [
|
|
140
99
|
..._list,
|
|
141
100
|
{ key: genId(), name: '', type: 'string', extra: { index: _list.length + 1 } },
|
|
142
101
|
]);
|
|
@@ -153,14 +112,14 @@ export function usePropertiesEdit(
|
|
|
153
112
|
};
|
|
154
113
|
|
|
155
114
|
useEffect(() => {
|
|
156
|
-
if (!
|
|
115
|
+
if (!canAddField) {
|
|
157
116
|
setPropertyList([]);
|
|
158
117
|
}
|
|
159
|
-
}, [
|
|
118
|
+
}, [canAddField]);
|
|
160
119
|
|
|
161
120
|
return {
|
|
162
121
|
propertyList,
|
|
163
|
-
|
|
122
|
+
canAddField,
|
|
164
123
|
onAddProperty,
|
|
165
124
|
onRemoveProperty,
|
|
166
125
|
onEditProperty,
|
|
@@ -17,7 +17,8 @@ import {
|
|
|
17
17
|
IconMinus,
|
|
18
18
|
} from '@douyinfe/semi-icons';
|
|
19
19
|
|
|
20
|
-
import {
|
|
20
|
+
import { InjectTypeSelector } from '@/components/type-selector';
|
|
21
|
+
|
|
21
22
|
import { ConfigType, PropertyValueType } from './types';
|
|
22
23
|
import {
|
|
23
24
|
IconAddChildren,
|
|
@@ -40,6 +41,8 @@ import { usePropertiesEdit } from './hooks';
|
|
|
40
41
|
import { DefaultValue } from './default-value';
|
|
41
42
|
import { BlurInput } from './components/blur-input';
|
|
42
43
|
|
|
44
|
+
const DEFAULT = { type: 'object' };
|
|
45
|
+
|
|
43
46
|
export function JsonSchemaEditor(props: {
|
|
44
47
|
value?: IJsonSchema;
|
|
45
48
|
onChange?: (value: IJsonSchema) => void;
|
|
@@ -47,7 +50,7 @@ export function JsonSchemaEditor(props: {
|
|
|
47
50
|
className?: string;
|
|
48
51
|
readonly?: boolean;
|
|
49
52
|
}) {
|
|
50
|
-
const { value =
|
|
53
|
+
const { value = DEFAULT, config = {}, onChange: onChangeProps, readonly } = props;
|
|
51
54
|
const { propertyList, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(
|
|
52
55
|
value,
|
|
53
56
|
onChangeProps
|
|
@@ -79,7 +82,7 @@ export function JsonSchemaEditor(props: {
|
|
|
79
82
|
icon={<IconPlus />}
|
|
80
83
|
onClick={onAddProperty}
|
|
81
84
|
>
|
|
82
|
-
{config?.addButtonText ?? 'Add'}
|
|
85
|
+
{config?.addButtonText ?? I18n.t('Add')}
|
|
83
86
|
</Button>
|
|
84
87
|
</UIContainer>
|
|
85
88
|
);
|
|
@@ -121,7 +124,7 @@ function PropertyEdit(props: {
|
|
|
121
124
|
|
|
122
125
|
const typeSelectorValue = useMemo(() => ({ type, items }), [type, items]);
|
|
123
126
|
|
|
124
|
-
const { propertyList,
|
|
127
|
+
const { propertyList, canAddField, onAddProperty, onRemoveProperty, onEditProperty } =
|
|
125
128
|
usePropertiesEdit(value, onChangeProps);
|
|
126
129
|
|
|
127
130
|
const onChange = (key: string, _value: any) => {
|
|
@@ -131,7 +134,7 @@ function PropertyEdit(props: {
|
|
|
131
134
|
});
|
|
132
135
|
};
|
|
133
136
|
|
|
134
|
-
const showCollapse =
|
|
137
|
+
const showCollapse = canAddField && propertyList.length > 0;
|
|
135
138
|
|
|
136
139
|
return (
|
|
137
140
|
<>
|
|
@@ -169,7 +172,7 @@ function PropertyEdit(props: {
|
|
|
169
172
|
/>
|
|
170
173
|
</UIName>
|
|
171
174
|
<UIType>
|
|
172
|
-
<
|
|
175
|
+
<InjectTypeSelector
|
|
173
176
|
value={typeSelectorValue}
|
|
174
177
|
readonly={readonly}
|
|
175
178
|
onChange={(_value) => {
|
|
@@ -197,7 +200,7 @@ function PropertyEdit(props: {
|
|
|
197
200
|
setExpand((_expand) => !_expand);
|
|
198
201
|
}}
|
|
199
202
|
/>
|
|
200
|
-
{
|
|
203
|
+
{canAddField && (
|
|
201
204
|
<IconButton
|
|
202
205
|
disabled={readonly}
|
|
203
206
|
size="small"
|
|
@@ -230,7 +233,7 @@ function PropertyEdit(props: {
|
|
|
230
233
|
config?.descPlaceholder ?? I18n.t('Help LLM to understand the property')
|
|
231
234
|
}
|
|
232
235
|
/>
|
|
233
|
-
{$level === 0 &&
|
|
236
|
+
{$level === 0 && (
|
|
234
237
|
<>
|
|
235
238
|
<UILabel style={{ marginTop: 10 }}>
|
|
236
239
|
{config?.defaultValueTitle ?? I18n.t('Default Value')}
|
|
@@ -200,35 +200,6 @@ export const DefaultValueWrapper = styled.div`
|
|
|
200
200
|
margin: 0;
|
|
201
201
|
`;
|
|
202
202
|
|
|
203
|
-
export const JSONViewerWrapper = styled.div`
|
|
204
|
-
padding: 0 0 24px;
|
|
205
|
-
&:first-child {
|
|
206
|
-
margin-top: 0px;
|
|
207
|
-
}
|
|
208
|
-
`;
|
|
209
|
-
|
|
210
|
-
export const JSONHeader = styled.div`
|
|
211
|
-
display: flex;
|
|
212
|
-
justify-content: space-between;
|
|
213
|
-
align-items: center;
|
|
214
|
-
background-color: var(--semi-color-fill-0);
|
|
215
|
-
border-radius: 6px 6px 0 0;
|
|
216
|
-
height: 36px;
|
|
217
|
-
padding: 0 8px 0 12px;
|
|
218
|
-
`;
|
|
219
|
-
|
|
220
|
-
export const JSONHeaderLeft = styled.div`
|
|
221
|
-
display: flex;
|
|
222
|
-
align-items: center;
|
|
223
|
-
gap: 10px;
|
|
224
|
-
`;
|
|
225
|
-
|
|
226
|
-
export const JSONHeaderRight = styled.div`
|
|
227
|
-
display: flex;
|
|
228
|
-
align-items: center;
|
|
229
|
-
gap: 10px;
|
|
230
|
-
`;
|
|
231
|
-
|
|
232
203
|
export const ConstantInputWrapper = styled.div`
|
|
233
204
|
flex-grow: 1;
|
|
234
205
|
|
|
@@ -15,8 +15,9 @@ import {
|
|
|
15
15
|
} from '@coze-editor/editor/react';
|
|
16
16
|
import { EditorAPI } from '@coze-editor/editor/preset-prompt';
|
|
17
17
|
|
|
18
|
+
import { IFlowValue } from '@/typings';
|
|
19
|
+
|
|
18
20
|
import { InputsPicker } from '../inputs-picker';
|
|
19
|
-
import { IFlowValue } from '../../../typings';
|
|
20
21
|
|
|
21
22
|
export function InputsTree({ inputsValues }: { inputsValues: Record<string, IFlowValue> }) {
|
|
22
23
|
const [posKey, setPosKey] = useState('');
|
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
|
+
import { IFlowValue } from '@/typings';
|
|
9
|
+
import { PromptEditor, PromptEditorPropsType } from '@/components/prompt-editor';
|
|
10
|
+
|
|
8
11
|
import { InputsTree } from './extensions/inputs-tree';
|
|
9
|
-
import { PromptEditor, PromptEditorPropsType } from '../prompt-editor';
|
|
10
|
-
import { IFlowValue } from '../../typings';
|
|
11
12
|
|
|
12
13
|
interface PropsType extends PromptEditorPropsType {
|
|
13
14
|
inputsValues: Record<string, IFlowValue>;
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
import { TreeNodeData } from '@douyinfe/semi-ui/lib/es/tree';
|
|
17
17
|
import { Tree } from '@douyinfe/semi-ui';
|
|
18
18
|
|
|
19
|
-
import { IFlowValue } from '
|
|
19
|
+
import { IFlowValue } from '@/typings';
|
|
20
20
|
|
|
21
21
|
type VariableField = BaseVariableField<{ icon?: string | JSX.Element; title?: string }>;
|
|
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('');
|
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
|
+
import { PromptEditor, PromptEditorPropsType } from '@/components/prompt-editor';
|
|
9
|
+
|
|
8
10
|
import { VariableTree } from './extensions/variable-tree';
|
|
9
11
|
import { VariableTagInject } from './extensions/variable-tag';
|
|
10
|
-
import { PromptEditor, PromptEditorPropsType } from '../prompt-editor';
|
|
11
12
|
|
|
12
13
|
export function PromptEditorWithVariables(props: PromptEditorPropsType) {
|
|
13
14
|
return (
|
|
@@ -8,9 +8,10 @@ import React, { useMemo } from 'react';
|
|
|
8
8
|
import { IJsonSchema } from '@flowgram.ai/json-schema';
|
|
9
9
|
import { Cascader, Icon, IconButton } from '@douyinfe/semi-ui';
|
|
10
10
|
|
|
11
|
-
import {
|
|
11
|
+
import { createInjectMaterial } from '@/shared/inject-material';
|
|
12
|
+
import { useTypeManager } from '@/plugins';
|
|
12
13
|
|
|
13
|
-
interface
|
|
14
|
+
export interface TypeSelectorProps {
|
|
14
15
|
value?: Partial<IJsonSchema>;
|
|
15
16
|
onChange?: (value?: Partial<IJsonSchema>) => void;
|
|
16
17
|
readonly?: boolean;
|
|
@@ -41,7 +42,7 @@ export const parseTypeSelectValue = (value?: string[]): Partial<IJsonSchema> | u
|
|
|
41
42
|
return { type };
|
|
42
43
|
};
|
|
43
44
|
|
|
44
|
-
export function TypeSelector(props:
|
|
45
|
+
export function TypeSelector(props: TypeSelectorProps) {
|
|
45
46
|
const { value, onChange, readonly, disabled, style } = props;
|
|
46
47
|
|
|
47
48
|
const selectValue = useMemo(() => getTypeSelectValue(value), [value]);
|
|
@@ -101,3 +102,6 @@ export function TypeSelector(props: PropTypes) {
|
|
|
101
102
|
/>
|
|
102
103
|
);
|
|
103
104
|
}
|
|
105
|
+
|
|
106
|
+
TypeSelector.renderKey = 'type-selector-render-key';
|
|
107
|
+
export const InjectTypeSelector = createInjectMaterial(TypeSelector);
|
|
@@ -12,10 +12,12 @@ import { TreeNodeData } from '@douyinfe/semi-ui/lib/es/tree';
|
|
|
12
12
|
import { Popover } from '@douyinfe/semi-ui';
|
|
13
13
|
import { IconChevronDownStroked, IconIssueStroked } from '@douyinfe/semi-icons';
|
|
14
14
|
|
|
15
|
+
import { createInjectMaterial } from '@/shared';
|
|
16
|
+
|
|
15
17
|
import { useVariableTree } from './use-variable-tree';
|
|
16
18
|
import { UIPopoverContent, UIRootTitle, UITag, UITreeSelect, UIVarName } from './styles';
|
|
17
19
|
|
|
18
|
-
interface
|
|
20
|
+
export interface VariableSelectorProps {
|
|
19
21
|
value?: string[];
|
|
20
22
|
config?: {
|
|
21
23
|
placeholder?: string;
|
|
@@ -30,8 +32,6 @@ interface PropTypes {
|
|
|
30
32
|
triggerRender?: (props: TriggerRenderProps) => React.ReactNode;
|
|
31
33
|
}
|
|
32
34
|
|
|
33
|
-
export type VariableSelectorProps = PropTypes;
|
|
34
|
-
|
|
35
35
|
export { useVariableTree };
|
|
36
36
|
|
|
37
37
|
export const VariableSelector = ({
|
|
@@ -44,7 +44,7 @@ export const VariableSelector = ({
|
|
|
44
44
|
excludeSchema,
|
|
45
45
|
hasError,
|
|
46
46
|
triggerRender,
|
|
47
|
-
}:
|
|
47
|
+
}: VariableSelectorProps) => {
|
|
48
48
|
const treeData = useVariableTree({ includeSchema, excludeSchema });
|
|
49
49
|
|
|
50
50
|
const treeValue = useMemo(() => {
|
|
@@ -136,3 +136,6 @@ export const VariableSelector = ({
|
|
|
136
136
|
</>
|
|
137
137
|
);
|
|
138
138
|
};
|
|
139
|
+
|
|
140
|
+
VariableSelector.renderKey = 'variable-selector-render-key';
|
|
141
|
+
export const InjectVariableSelector = createInjectMaterial(VariableSelector);
|
|
@@ -10,7 +10,7 @@ import { ASTMatch, BaseVariableField, useAvailableVariables } from '@flowgram.ai
|
|
|
10
10
|
import { TreeNodeData } from '@douyinfe/semi-ui/lib/es/tree';
|
|
11
11
|
import { Icon } from '@douyinfe/semi-ui';
|
|
12
12
|
|
|
13
|
-
import { useTypeManager } from '
|
|
13
|
+
import { useTypeManager } from '@/plugins';
|
|
14
14
|
|
|
15
15
|
type VariableField = BaseVariableField<{
|
|
16
16
|
icon?: string | JSX.Element;
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
VariableFieldKeyRenameService,
|
|
12
12
|
} from '@flowgram.ai/editor';
|
|
13
13
|
|
|
14
|
-
import { IFlowRefValue, IFlowTemplateValue } from '
|
|
14
|
+
import { IFlowRefValue, IFlowTemplateValue } from '@/typings';
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Auto rename ref when form item's key is renamed
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
getNodeForm,
|
|
12
12
|
} from '@flowgram.ai/editor';
|
|
13
13
|
|
|
14
|
-
import { IFlowRefValue } from '
|
|
14
|
+
import { IFlowRefValue } from '@/typings';
|
|
15
15
|
|
|
16
16
|
export const provideBatchInputEffect: EffectOptions[] = createEffectFromVariableProvider({
|
|
17
17
|
private: true,
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
FlowNodeScopeType,
|
|
18
18
|
} from '@flowgram.ai/editor';
|
|
19
19
|
|
|
20
|
-
import { IFlowRefValue } from '
|
|
20
|
+
import { IFlowRefValue } from '@/typings';
|
|
21
21
|
|
|
22
22
|
export const provideBatchOutputsEffect: EffectOptions[] = createEffectFromVariableProvider({
|
|
23
23
|
parse: (value: Record<string, IFlowRefValue>, ctx) => [
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
Scope,
|
|
13
13
|
} from '@flowgram.ai/editor';
|
|
14
14
|
|
|
15
|
-
import { IFlowConstantValue, IFlowRefValue, IFlowTemplateValue } from '
|
|
15
|
+
import { IFlowConstantValue, IFlowRefValue, IFlowTemplateValue } from '@/typings';
|
|
16
16
|
|
|
17
17
|
interface InputConfig {
|
|
18
18
|
sourceKey: string;
|
package/src/shared/index.ts
CHANGED