@flowgram.ai/form-materials 0.4.0 → 0.4.1
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/dist/esm/index.js +723 -401
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +132 -29
- package/dist/index.d.ts +132 -29
- package/dist/index.js +839 -510
- package/dist/index.js.map +1 -1
- package/package.json +6 -5
- package/src/components/batch-outputs/index.tsx +3 -2
- package/src/components/dynamic-value-input/hooks.ts +1 -1
- package/src/components/dynamic-value-input/index.tsx +1 -1
- package/src/components/dynamic-value-input/styles.tsx +14 -4
- package/src/components/index.ts +2 -0
- package/src/components/inputs-values/index.tsx +3 -3
- package/src/components/inputs-values/styles.tsx +1 -1
- package/src/components/inputs-values-tree/hooks/use-child-list.tsx +71 -0
- package/src/components/inputs-values-tree/index.tsx +56 -0
- package/src/components/inputs-values-tree/row.tsx +163 -0
- package/src/components/inputs-values-tree/styles.tsx +128 -0
- package/src/components/inputs-values-tree/types.ts +21 -0
- package/src/components/json-schema-editor/default-value.tsx +1 -3
- package/src/components/json-schema-editor/hooks.tsx +13 -2
- package/src/components/json-schema-editor/index.tsx +17 -57
- package/src/components/json-schema-editor/styles.tsx +12 -55
- package/src/components/json-schema-editor/types.ts +0 -1
- package/src/components/prompt-editor/index.tsx +10 -3
- package/src/effects/auto-rename-ref/index.ts +7 -54
- package/src/form-plugins/infer-inputs-plugin/index.ts +3 -75
- package/src/hooks/use-object-list/index.tsx +34 -6
- package/src/plugins/json-schema-preset/manager.ts +1 -0
- package/src/plugins/json-schema-preset/type-definition/string.tsx +18 -9
- package/src/shared/flow-value/index.ts +6 -0
- package/src/shared/flow-value/schema.ts +38 -0
- package/src/shared/flow-value/utils.ts +201 -0
- package/src/shared/index.ts +1 -0
- package/src/typings/flow-value/index.ts +2 -0
- package/src/components/json-schema-editor/components/blur-input.tsx +0 -27
- package/src/plugins/disable-declaration-plugin/config.json +0 -5
- package/src/plugins/json-schema-preset/config.json +0 -9
- /package/src/components/{inputs-values/components/blur-input.tsx → blur-input/index.tsx} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowgram.ai/form-materials",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"homepage": "https://flowgram.ai/",
|
|
5
5
|
"repository": "https://github.com/bytedance/flowgram.ai",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,8 +34,9 @@
|
|
|
34
34
|
"@codemirror/view": "~6.38.0",
|
|
35
35
|
"@codemirror/state": "~6.5.2",
|
|
36
36
|
"typescript": "^5.8.3",
|
|
37
|
-
"
|
|
38
|
-
"@flowgram.ai/
|
|
37
|
+
"zod": "^3.24.4",
|
|
38
|
+
"@flowgram.ai/editor": "0.4.1",
|
|
39
|
+
"@flowgram.ai/json-schema": "0.4.1"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
41
42
|
"@types/lodash": "^4.14.137",
|
|
@@ -51,8 +52,8 @@
|
|
|
51
52
|
"tsup": "^8.0.1",
|
|
52
53
|
"typescript": "^5.8.3",
|
|
53
54
|
"vitest": "^0.34.6",
|
|
54
|
-
"@flowgram.ai/eslint-config": "0.4.
|
|
55
|
-
"@flowgram.ai/ts-config": "0.4.
|
|
55
|
+
"@flowgram.ai/eslint-config": "0.4.1",
|
|
56
|
+
"@flowgram.ai/ts-config": "0.4.1"
|
|
56
57
|
},
|
|
57
58
|
"peerDependencies": {
|
|
58
59
|
"react": ">=16.8",
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
|
+
import { I18n } from '@flowgram.ai/editor';
|
|
8
9
|
import { Button, Input } from '@douyinfe/semi-ui';
|
|
9
10
|
import { IconDelete, IconPlus } from '@douyinfe/semi-icons';
|
|
10
11
|
|
|
@@ -46,8 +47,8 @@ export function BatchOutputs(props: PropsType) {
|
|
|
46
47
|
</UIRow>
|
|
47
48
|
))}
|
|
48
49
|
</UIRows>
|
|
49
|
-
<Button disabled={readonly} icon={<IconPlus />} size="small" onClick={add}>
|
|
50
|
-
Add
|
|
50
|
+
<Button disabled={readonly} icon={<IconPlus />} size="small" onClick={() => add()}>
|
|
51
|
+
{I18n.t('Add')}
|
|
51
52
|
</Button>
|
|
52
53
|
</div>
|
|
53
54
|
);
|
|
@@ -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
|
|
11
|
+
import { IFlowConstantRefValue } from '@/typings';
|
|
12
12
|
|
|
13
13
|
export function useRefVariable(value?: IFlowConstantRefValue) {
|
|
14
14
|
const available = useScopeAvailable();
|
|
@@ -9,7 +9,7 @@ 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 { IFlowConstantRefValue } from '@/typings
|
|
12
|
+
import { IFlowConstantRefValue } from '@/typings';
|
|
13
13
|
import { createInjectMaterial } from '@/shared';
|
|
14
14
|
import { InjectVariableSelector } from '@/components/variable-selector';
|
|
15
15
|
import { TypeSelector } from '@/components/type-selector';
|
|
@@ -20,6 +20,8 @@ export const UIMain = styled.div`
|
|
|
20
20
|
flex-grow: 1;
|
|
21
21
|
overflow: hidden;
|
|
22
22
|
min-width: 0;
|
|
23
|
+
border-left: 1px solid var(--semi-color-border);
|
|
24
|
+
border-right: 1px solid var(--semi-color-border);
|
|
23
25
|
|
|
24
26
|
& .semi-tree-select,
|
|
25
27
|
& .semi-input-number,
|
|
@@ -33,19 +35,27 @@ export const UIMain = styled.div`
|
|
|
33
35
|
border: none;
|
|
34
36
|
border-radius: 0;
|
|
35
37
|
}
|
|
38
|
+
|
|
39
|
+
& .semi-input-textarea-wrapper {
|
|
40
|
+
border: none;
|
|
41
|
+
border-radius: 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
& .semi-input-textarea {
|
|
45
|
+
padding: 2px 6px;
|
|
46
|
+
border: none;
|
|
47
|
+
border-radius: 0;
|
|
48
|
+
word-break: break-all;
|
|
49
|
+
}
|
|
36
50
|
`;
|
|
37
51
|
|
|
38
52
|
export const UIType = styled.div`
|
|
39
|
-
border-right: 1px solid #e5e5e5;
|
|
40
|
-
|
|
41
53
|
& .semi-button {
|
|
42
54
|
border-radius: 0;
|
|
43
55
|
}
|
|
44
56
|
`;
|
|
45
57
|
|
|
46
58
|
export const UITrigger = styled.div`
|
|
47
|
-
border-left: 1px solid #e5e5e5;
|
|
48
|
-
|
|
49
59
|
& .semi-button {
|
|
50
60
|
border-radius: 0;
|
|
51
61
|
}
|
package/src/components/index.ts
CHANGED
|
@@ -12,10 +12,10 @@ import { IconDelete, IconPlus } from '@douyinfe/semi-icons';
|
|
|
12
12
|
import { IFlowConstantRefValue, IFlowValue } from '@/typings';
|
|
13
13
|
import { useObjectList } from '@/hooks';
|
|
14
14
|
import { InjectDynamicValueInput } from '@/components/dynamic-value-input';
|
|
15
|
+
import { BlurInput } from '@/components/blur-input';
|
|
15
16
|
|
|
16
17
|
import { PropsType } from './types';
|
|
17
18
|
import { UIRow, UIRows } from './styles';
|
|
18
|
-
import { BlurInput } from './components/blur-input';
|
|
19
19
|
|
|
20
20
|
export function InputsValues({
|
|
21
21
|
value,
|
|
@@ -67,8 +67,8 @@ export function InputsValues({
|
|
|
67
67
|
</UIRow>
|
|
68
68
|
))}
|
|
69
69
|
</UIRows>
|
|
70
|
-
<Button disabled={readonly} icon={<IconPlus />} size="small" onClick={add}>
|
|
71
|
-
Add
|
|
70
|
+
<Button disabled={readonly} icon={<IconPlus />} size="small" onClick={() => add()}>
|
|
71
|
+
{I18n.t('Add')}
|
|
72
72
|
</Button>
|
|
73
73
|
</div>
|
|
74
74
|
);
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { useMemo } from 'react';
|
|
7
|
+
|
|
8
|
+
import { isPlainObject } from 'lodash';
|
|
9
|
+
|
|
10
|
+
import { FlowValueUtils } from '@/shared';
|
|
11
|
+
import { useObjectList } from '@/hooks';
|
|
12
|
+
|
|
13
|
+
interface ListItem {
|
|
14
|
+
id: string;
|
|
15
|
+
key?: string;
|
|
16
|
+
value?: any;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function useChildList(
|
|
20
|
+
value?: any,
|
|
21
|
+
onChange?: (value: any) => void
|
|
22
|
+
): {
|
|
23
|
+
canAddField: boolean;
|
|
24
|
+
list: ListItem[];
|
|
25
|
+
add: (key?: string) => void;
|
|
26
|
+
updateKey: (id: string, key: string) => void;
|
|
27
|
+
updateValue: (id: string, value: any) => void;
|
|
28
|
+
remove: (id: string) => void;
|
|
29
|
+
} {
|
|
30
|
+
const canAddField = useMemo(() => {
|
|
31
|
+
if (!isPlainObject(value)) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (FlowValueUtils.isFlowValue(value)) {
|
|
36
|
+
// Constant Object Value Can Add child fields
|
|
37
|
+
return FlowValueUtils.isConstant(value) && value?.schema?.type === 'object';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return true;
|
|
41
|
+
}, [value]);
|
|
42
|
+
|
|
43
|
+
const objectListValue = useMemo(() => {
|
|
44
|
+
if (isPlainObject(value)) {
|
|
45
|
+
if (FlowValueUtils.isFlowValue(value)) {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
return undefined;
|
|
51
|
+
}, [value]);
|
|
52
|
+
|
|
53
|
+
console.log('debugger objectListValue', objectListValue);
|
|
54
|
+
|
|
55
|
+
const { list, add, updateKey, updateValue, remove } = useObjectList<any>({
|
|
56
|
+
value: objectListValue,
|
|
57
|
+
onChange: (value) => {
|
|
58
|
+
onChange?.(value);
|
|
59
|
+
},
|
|
60
|
+
sortIndexKey: (value) => (FlowValueUtils.isFlowValue(value) ? 'extra.index' : ''),
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
canAddField,
|
|
65
|
+
list,
|
|
66
|
+
add,
|
|
67
|
+
updateKey,
|
|
68
|
+
updateValue,
|
|
69
|
+
remove,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import React from 'react';
|
|
7
|
+
|
|
8
|
+
import { I18n } from '@flowgram.ai/editor';
|
|
9
|
+
import { Button } from '@douyinfe/semi-ui';
|
|
10
|
+
import { IconPlus } from '@douyinfe/semi-icons';
|
|
11
|
+
|
|
12
|
+
import { FlowValueUtils } from '@/shared';
|
|
13
|
+
import { useObjectList } from '@/hooks';
|
|
14
|
+
|
|
15
|
+
import { PropsType } from './types';
|
|
16
|
+
import { UITreeItems } from './styles';
|
|
17
|
+
import { InputValueRow } from './row';
|
|
18
|
+
|
|
19
|
+
export function InputsValuesTree(props: PropsType) {
|
|
20
|
+
const { value, onChange, readonly, hasError, constantProps } = props;
|
|
21
|
+
|
|
22
|
+
const { list, updateKey, updateValue, remove, add } = useObjectList({
|
|
23
|
+
value,
|
|
24
|
+
onChange,
|
|
25
|
+
sortIndexKey: (value) => (FlowValueUtils.isFlowValue(value) ? 'extra.index' : ''),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div>
|
|
30
|
+
<UITreeItems>
|
|
31
|
+
{list.map((item) => (
|
|
32
|
+
<InputValueRow
|
|
33
|
+
key={item.id}
|
|
34
|
+
keyName={item.key}
|
|
35
|
+
value={item.value}
|
|
36
|
+
onUpdateKey={(key) => updateKey(item.id, key)}
|
|
37
|
+
onUpdateValue={(value) => updateValue(item.id, value)}
|
|
38
|
+
onRemove={() => remove(item.id)}
|
|
39
|
+
readonly={readonly}
|
|
40
|
+
hasError={hasError}
|
|
41
|
+
constantProps={constantProps}
|
|
42
|
+
/>
|
|
43
|
+
))}
|
|
44
|
+
</UITreeItems>
|
|
45
|
+
<Button
|
|
46
|
+
style={{ marginTop: 10, marginLeft: 16 }}
|
|
47
|
+
disabled={readonly}
|
|
48
|
+
icon={<IconPlus />}
|
|
49
|
+
size="small"
|
|
50
|
+
onClick={add}
|
|
51
|
+
>
|
|
52
|
+
{I18n.t('Add')}
|
|
53
|
+
</Button>
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import React, { useState } from 'react';
|
|
7
|
+
|
|
8
|
+
import { I18n } from '@flowgram.ai/editor';
|
|
9
|
+
import { IconButton, Input } from '@douyinfe/semi-ui';
|
|
10
|
+
import { IconChevronDown, IconChevronRight, IconDelete } from '@douyinfe/semi-icons';
|
|
11
|
+
|
|
12
|
+
import { ConstantInputStrategy } from '@/components/constant-input';
|
|
13
|
+
|
|
14
|
+
import { PropsType } from './types';
|
|
15
|
+
import {
|
|
16
|
+
IconAddChildren,
|
|
17
|
+
UIActions,
|
|
18
|
+
UICollapseTrigger,
|
|
19
|
+
UICollapsible,
|
|
20
|
+
UIRow,
|
|
21
|
+
UITreeItemLeft,
|
|
22
|
+
UITreeItemMain,
|
|
23
|
+
UITreeItemRight,
|
|
24
|
+
UITreeItems,
|
|
25
|
+
} from './styles';
|
|
26
|
+
import { useChildList } from './hooks/use-child-list';
|
|
27
|
+
import { InjectDynamicValueInput } from '../dynamic-value-input';
|
|
28
|
+
import { BlurInput } from '../blur-input';
|
|
29
|
+
|
|
30
|
+
const AddObjectChildStrategy: ConstantInputStrategy = {
|
|
31
|
+
hit: (schema) => schema.type === 'object',
|
|
32
|
+
Renderer: () => (
|
|
33
|
+
<Input
|
|
34
|
+
size="small"
|
|
35
|
+
disabled
|
|
36
|
+
style={{ pointerEvents: 'none' }}
|
|
37
|
+
value={I18n.t('Configure via child fields')}
|
|
38
|
+
/>
|
|
39
|
+
),
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export function InputValueRow(
|
|
43
|
+
props: {
|
|
44
|
+
keyName?: string;
|
|
45
|
+
value?: any;
|
|
46
|
+
onUpdateKey: (key: string) => void;
|
|
47
|
+
onUpdateValue: (value: any) => void;
|
|
48
|
+
onRemove?: () => void;
|
|
49
|
+
$isLast?: boolean;
|
|
50
|
+
$level?: number;
|
|
51
|
+
} & Pick<PropsType, 'constantProps' | 'hasError' | 'readonly'>
|
|
52
|
+
) {
|
|
53
|
+
const {
|
|
54
|
+
keyName,
|
|
55
|
+
value,
|
|
56
|
+
$level = 0,
|
|
57
|
+
onUpdateKey,
|
|
58
|
+
onUpdateValue,
|
|
59
|
+
$isLast,
|
|
60
|
+
onRemove,
|
|
61
|
+
constantProps,
|
|
62
|
+
hasError,
|
|
63
|
+
readonly,
|
|
64
|
+
} = props;
|
|
65
|
+
const [collapse, setCollapse] = useState(false);
|
|
66
|
+
|
|
67
|
+
const { canAddField, list, add, updateKey, updateValue, remove } = useChildList(
|
|
68
|
+
value,
|
|
69
|
+
onUpdateValue
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
const hasChildren = canAddField && list.length > 0;
|
|
73
|
+
|
|
74
|
+
const flowDisplayValue = hasChildren ? { type: 'constant', schema: { type: ' object' } } : value;
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<>
|
|
78
|
+
<UITreeItemLeft $isLast={$isLast} $showLine={$level > 0} $showCollapse={hasChildren}>
|
|
79
|
+
{hasChildren && (
|
|
80
|
+
<UICollapseTrigger onClick={() => setCollapse((_collapse) => !_collapse)}>
|
|
81
|
+
{collapse ? <IconChevronDown size="small" /> : <IconChevronRight size="small" />}
|
|
82
|
+
</UICollapseTrigger>
|
|
83
|
+
)}
|
|
84
|
+
</UITreeItemLeft>
|
|
85
|
+
<UITreeItemRight>
|
|
86
|
+
<UITreeItemMain>
|
|
87
|
+
<UIRow>
|
|
88
|
+
<BlurInput
|
|
89
|
+
style={{ width: 100, minWidth: 100, maxWidth: 100 }}
|
|
90
|
+
disabled={readonly}
|
|
91
|
+
size="small"
|
|
92
|
+
value={keyName}
|
|
93
|
+
onChange={(v) => onUpdateKey?.(v)}
|
|
94
|
+
placeholder={I18n.t('Input Key')}
|
|
95
|
+
/>
|
|
96
|
+
<InjectDynamicValueInput
|
|
97
|
+
style={{ flexGrow: 1 }}
|
|
98
|
+
readonly={readonly}
|
|
99
|
+
value={flowDisplayValue}
|
|
100
|
+
onChange={(v) => onUpdateValue(v)}
|
|
101
|
+
hasError={hasError}
|
|
102
|
+
constantProps={{
|
|
103
|
+
...constantProps,
|
|
104
|
+
strategies: [
|
|
105
|
+
...(hasChildren ? [AddObjectChildStrategy] : []),
|
|
106
|
+
...(constantProps?.strategies || []),
|
|
107
|
+
],
|
|
108
|
+
}}
|
|
109
|
+
/>
|
|
110
|
+
<UIActions>
|
|
111
|
+
{canAddField && (
|
|
112
|
+
<IconButton
|
|
113
|
+
disabled={readonly}
|
|
114
|
+
size="small"
|
|
115
|
+
theme="borderless"
|
|
116
|
+
icon={<IconAddChildren />}
|
|
117
|
+
onClick={() => {
|
|
118
|
+
add();
|
|
119
|
+
setCollapse(true);
|
|
120
|
+
}}
|
|
121
|
+
/>
|
|
122
|
+
)}
|
|
123
|
+
<IconButton
|
|
124
|
+
disabled={readonly}
|
|
125
|
+
theme="borderless"
|
|
126
|
+
icon={<IconDelete size="small" />}
|
|
127
|
+
size="small"
|
|
128
|
+
onClick={() => onRemove?.()}
|
|
129
|
+
/>
|
|
130
|
+
</UIActions>
|
|
131
|
+
</UIRow>
|
|
132
|
+
</UITreeItemMain>
|
|
133
|
+
{hasChildren && (
|
|
134
|
+
<UICollapsible $collapse={collapse}>
|
|
135
|
+
<UITreeItems $shrink={true}>
|
|
136
|
+
{list.map((_item, index) => (
|
|
137
|
+
<InputValueRow
|
|
138
|
+
readonly={readonly}
|
|
139
|
+
hasError={hasError}
|
|
140
|
+
constantProps={constantProps}
|
|
141
|
+
key={_item.id}
|
|
142
|
+
keyName={_item.key}
|
|
143
|
+
value={_item.value}
|
|
144
|
+
$level={$level + 1} // 传递递增的层级
|
|
145
|
+
onUpdateValue={(_v) => {
|
|
146
|
+
updateValue(_item.id, _v);
|
|
147
|
+
}}
|
|
148
|
+
onUpdateKey={(k) => {
|
|
149
|
+
updateKey(_item.id, k);
|
|
150
|
+
}}
|
|
151
|
+
onRemove={() => {
|
|
152
|
+
remove(_item.id);
|
|
153
|
+
}}
|
|
154
|
+
$isLast={index === list.length - 1}
|
|
155
|
+
/>
|
|
156
|
+
))}
|
|
157
|
+
</UITreeItems>
|
|
158
|
+
</UICollapsible>
|
|
159
|
+
)}
|
|
160
|
+
</UITreeItemRight>
|
|
161
|
+
</>
|
|
162
|
+
);
|
|
163
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import React from 'react';
|
|
7
|
+
|
|
8
|
+
import styled, { css } from 'styled-components';
|
|
9
|
+
import Icon from '@douyinfe/semi-icons';
|
|
10
|
+
|
|
11
|
+
export const UIContainer = styled.div``;
|
|
12
|
+
|
|
13
|
+
export const UIRow = styled.div`
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: flex-start;
|
|
16
|
+
gap: 5px;
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
export const UICollapseTrigger = styled.div`
|
|
20
|
+
cursor: pointer;
|
|
21
|
+
margin-right: 5px;
|
|
22
|
+
`;
|
|
23
|
+
|
|
24
|
+
export const UITreeItems = styled.div<{ $shrink?: boolean }>`
|
|
25
|
+
display: grid;
|
|
26
|
+
grid-template-columns: auto 1fr;
|
|
27
|
+
|
|
28
|
+
${({ $shrink }) =>
|
|
29
|
+
$shrink &&
|
|
30
|
+
css`
|
|
31
|
+
padding-left: 3px;
|
|
32
|
+
margin-top: 10px;
|
|
33
|
+
`}
|
|
34
|
+
`;
|
|
35
|
+
|
|
36
|
+
export const UITreeItemLeft = styled.div<{
|
|
37
|
+
$isLast?: boolean;
|
|
38
|
+
$showLine?: boolean;
|
|
39
|
+
$showCollapse?: boolean;
|
|
40
|
+
}>`
|
|
41
|
+
grid-column: 1;
|
|
42
|
+
position: relative;
|
|
43
|
+
width: 16px;
|
|
44
|
+
|
|
45
|
+
${({ $showLine, $isLast, $showCollapse }) => {
|
|
46
|
+
let height = $isLast ? '24px' : '100%';
|
|
47
|
+
let width = $showCollapse ? '12px' : '30px';
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
$showLine &&
|
|
51
|
+
css`
|
|
52
|
+
&::before {
|
|
53
|
+
/* 竖线 */
|
|
54
|
+
content: '';
|
|
55
|
+
height: ${height};
|
|
56
|
+
position: absolute;
|
|
57
|
+
left: -14px;
|
|
58
|
+
top: -16px;
|
|
59
|
+
width: 1px;
|
|
60
|
+
background: #d9d9d9;
|
|
61
|
+
display: block;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
&::after {
|
|
65
|
+
/* 横线 */
|
|
66
|
+
content: '';
|
|
67
|
+
position: absolute;
|
|
68
|
+
left: -14px; // 横线起点和竖线对齐
|
|
69
|
+
top: 8px; // 跟随你的行高调整
|
|
70
|
+
width: ${width}; // 横线长度
|
|
71
|
+
height: 1px;
|
|
72
|
+
background: #d9d9d9;
|
|
73
|
+
display: block;
|
|
74
|
+
}
|
|
75
|
+
`
|
|
76
|
+
);
|
|
77
|
+
}}
|
|
78
|
+
`;
|
|
79
|
+
|
|
80
|
+
export const UITreeItemRight = styled.div`
|
|
81
|
+
grid-column: 2;
|
|
82
|
+
margin-bottom: 10px;
|
|
83
|
+
|
|
84
|
+
&:last-child {
|
|
85
|
+
margin-bottom: 0px;
|
|
86
|
+
}
|
|
87
|
+
`;
|
|
88
|
+
|
|
89
|
+
export const UITreeItemMain = styled.div<{}>`
|
|
90
|
+
display: flex;
|
|
91
|
+
flex-direction: column;
|
|
92
|
+
gap: 10px;
|
|
93
|
+
position: relative;
|
|
94
|
+
`;
|
|
95
|
+
|
|
96
|
+
export const UICollapsible = styled.div<{ $collapse?: boolean }>`
|
|
97
|
+
display: none;
|
|
98
|
+
|
|
99
|
+
${({ $collapse }) =>
|
|
100
|
+
$collapse &&
|
|
101
|
+
css`
|
|
102
|
+
display: block;
|
|
103
|
+
`}
|
|
104
|
+
`;
|
|
105
|
+
|
|
106
|
+
export const UIActions = styled.div`
|
|
107
|
+
white-space: nowrap;
|
|
108
|
+
`;
|
|
109
|
+
|
|
110
|
+
const iconAddChildrenSvg = (
|
|
111
|
+
<svg
|
|
112
|
+
className="icon-icon icon-icon-coz_add_node "
|
|
113
|
+
width="1em"
|
|
114
|
+
height="1em"
|
|
115
|
+
viewBox="0 0 24 24"
|
|
116
|
+
fill="currentColor"
|
|
117
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
118
|
+
>
|
|
119
|
+
<path
|
|
120
|
+
fillRule="evenodd"
|
|
121
|
+
clipRule="evenodd"
|
|
122
|
+
d="M11 6.49988C11 8.64148 9.50397 10.4337 7.49995 10.8884V15.4998C7.49995 16.0521 7.94767 16.4998 8.49995 16.4998H11.208C11.0742 16.8061 11 17.1443 11 17.4998C11 17.8554 11.0742 18.1936 11.208 18.4998H8.49995C6.8431 18.4998 5.49995 17.1567 5.49995 15.4998V10.8884C3.49599 10.4336 2 8.64145 2 6.49988C2 4.0146 4.01472 1.99988 6.5 1.99988C8.98528 1.99988 11 4.0146 11 6.49988ZM6.5 8.99988C7.88071 8.99988 9 7.88059 9 6.49988C9 5.11917 7.88071 3.99988 6.5 3.99988C5.11929 3.99988 4 5.11917 4 6.49988C4 7.88059 5.11929 8.99988 6.5 8.99988Z"
|
|
123
|
+
></path>
|
|
124
|
+
<path d="M17.5 12.4999C18.0523 12.4999 18.5 12.9476 18.5 13.4999V16.4999H21.5C22.0523 16.4999 22.5 16.9476 22.5 17.4999C22.5 18.0522 22.0523 18.4999 21.5 18.4999H18.5V21.4999C18.5 22.0522 18.0523 22.4999 17.5 22.4999C16.9477 22.4999 16.5 22.0522 16.5 21.4999V18.4999H13.5C12.9477 18.4999 12.5 18.0522 12.5 17.4999C12.5 16.9476 12.9477 16.4999 13.5 16.4999H16.5V13.4999C16.5 12.9476 16.9477 12.4999 17.5 12.4999Z"></path>
|
|
125
|
+
</svg>
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
export const IconAddChildren = () => <Icon size="small" svg={iconAddChildrenSvg} />;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { IJsonSchema } from '@flowgram.ai/json-schema';
|
|
7
|
+
|
|
8
|
+
import { ConstantInputStrategy } from '@/components/constant-input';
|
|
9
|
+
|
|
10
|
+
export interface PropsType {
|
|
11
|
+
value?: any;
|
|
12
|
+
onChange: (value?: any) => void;
|
|
13
|
+
readonly?: boolean;
|
|
14
|
+
hasError?: boolean;
|
|
15
|
+
schema?: IJsonSchema;
|
|
16
|
+
style?: React.CSSProperties;
|
|
17
|
+
constantProps?: {
|
|
18
|
+
strategies?: ConstantInputStrategy[];
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -20,10 +20,7 @@ import { ConstantInputWrapper } from './styles';
|
|
|
20
20
|
export function DefaultValue(props: {
|
|
21
21
|
value: any;
|
|
22
22
|
schema?: IJsonSchema;
|
|
23
|
-
name?: string;
|
|
24
|
-
type?: string;
|
|
25
23
|
placeholder?: string;
|
|
26
|
-
jsonFormatText?: string;
|
|
27
24
|
onChange: (value: any) => void;
|
|
28
25
|
}) {
|
|
29
26
|
const { value, schema, onChange, placeholder } = props;
|
|
@@ -35,6 +32,7 @@ export function DefaultValue(props: {
|
|
|
35
32
|
onChange={(_v) => onChange(_v)}
|
|
36
33
|
schema={schema || { type: 'string' }}
|
|
37
34
|
placeholder={placeholder ?? I18n.t('Default value if parameter is not provided')}
|
|
35
|
+
enableMultiLineStr
|
|
38
36
|
/>
|
|
39
37
|
</ConstantInputWrapper>
|
|
40
38
|
);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { useEffect, useState } from 'react';
|
|
6
|
+
import { useEffect, useRef, useState } from 'react';
|
|
7
7
|
|
|
8
8
|
import { difference, omit } from 'lodash';
|
|
9
9
|
import { produce } from 'immer';
|
|
@@ -28,7 +28,16 @@ export function usePropertiesEdit(
|
|
|
28
28
|
|
|
29
29
|
const [propertyList, setPropertyList] = useState<PropertyValueType[]>([]);
|
|
30
30
|
|
|
31
|
+
const effectVersion = useRef(0);
|
|
32
|
+
const changeVersion = useRef(0);
|
|
33
|
+
|
|
31
34
|
useEffect(() => {
|
|
35
|
+
effectVersion.current = effectVersion.current + 1;
|
|
36
|
+
if (effectVersion.current === changeVersion.current) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
effectVersion.current = changeVersion.current;
|
|
40
|
+
|
|
32
41
|
// If the value is changed, update the property list
|
|
33
42
|
setPropertyList((_list) => {
|
|
34
43
|
const newNames = Object.entries(drilldownSchema?.properties || {})
|
|
@@ -44,7 +53,7 @@ export function usePropertiesEdit(
|
|
|
44
53
|
key: item.key,
|
|
45
54
|
name: item.name,
|
|
46
55
|
isPropertyRequired: drilldownSchema?.required?.includes(item.name || '') || false,
|
|
47
|
-
...item,
|
|
56
|
+
...(drilldownSchema?.properties?.[item.name || ''] || item || {}),
|
|
48
57
|
}))
|
|
49
58
|
.concat(
|
|
50
59
|
addNames.map((_name) => ({
|
|
@@ -58,6 +67,8 @@ export function usePropertiesEdit(
|
|
|
58
67
|
}, [drilldownSchema]);
|
|
59
68
|
|
|
60
69
|
const updatePropertyList = (updater: (list: PropertyValueType[]) => PropertyValueType[]) => {
|
|
70
|
+
changeVersion.current = changeVersion.current + 1;
|
|
71
|
+
|
|
61
72
|
setPropertyList((_list) => {
|
|
62
73
|
const next = updater(_list);
|
|
63
74
|
|