@flowgram.ai/form-materials 0.1.0-alpha.10 → 0.1.0-alpha.12
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 +11 -5
- package/bin/materials.ts +10 -1
- package/dist/esm/index.js +1996 -1361
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +328 -114
- package/dist/index.d.ts +328 -114
- package/dist/index.js +2096 -1472
- package/dist/index.js.map +1 -1
- package/package.json +7 -5
- package/src/components/assign-row/components/blur-input.tsx +27 -0
- package/src/components/assign-row/config.json +11 -0
- package/src/components/assign-row/index.tsx +84 -0
- package/src/components/assign-row/types.ts +25 -0
- package/src/components/assign-rows/config.json +11 -0
- package/src/components/assign-rows/index.tsx +59 -0
- package/src/components/batch-outputs/config.json +2 -1
- package/src/components/batch-outputs/index.tsx +4 -12
- package/src/components/batch-variable-selector/config.json +6 -2
- package/src/components/batch-variable-selector/index.tsx +1 -1
- package/src/components/code-editor/config.json +2 -1
- package/src/components/code-editor/index.tsx +23 -1
- package/src/components/code-editor/language-features.ts +23 -3
- package/src/components/code-editor/theme/light.ts +2 -2
- package/src/components/code-editor-mini/config.json +7 -0
- package/src/components/code-editor-mini/index.tsx +31 -0
- package/src/components/condition-row/config.json +10 -2
- package/src/components/condition-row/constants.ts +6 -8
- package/src/components/condition-row/hooks/useOp.tsx +3 -1
- package/src/components/condition-row/hooks/useRule.ts +2 -2
- package/src/components/condition-row/index.tsx +2 -1
- package/src/components/condition-row/types.ts +3 -1
- package/src/components/constant-input/config.json +6 -3
- package/src/components/constant-input/index.tsx +18 -62
- package/src/components/constant-input/types.ts +6 -9
- package/src/components/display-flow-value/config.json +8 -0
- package/src/components/display-flow-value/index.tsx +59 -0
- package/src/components/display-inputs-values/config.json +9 -0
- package/src/components/display-inputs-values/index.tsx +27 -0
- package/src/components/display-inputs-values/styles.ts +12 -0
- package/src/components/display-outputs/config.json +10 -0
- package/src/components/display-outputs/index.tsx +64 -0
- package/src/components/display-outputs/styles.ts +12 -0
- package/src/components/display-schema-tag/config.json +10 -0
- package/src/components/display-schema-tag/index.tsx +44 -0
- package/src/components/display-schema-tag/styles.ts +28 -0
- package/src/components/display-schema-tree/config.json +11 -0
- package/src/components/display-schema-tree/index.tsx +74 -0
- package/src/components/display-schema-tree/styles.tsx +90 -0
- package/src/components/dynamic-value-input/config.json +11 -2
- package/src/components/dynamic-value-input/hooks.ts +53 -0
- package/src/components/dynamic-value-input/index.tsx +64 -13
- package/src/components/dynamic-value-input/styles.tsx +28 -2
- package/src/components/index.ts +9 -0
- package/src/components/inputs-values/components/blur-input.tsx +27 -0
- package/src/components/inputs-values/config.json +13 -0
- package/src/components/inputs-values/index.tsx +73 -0
- package/src/components/inputs-values/styles.tsx +19 -0
- package/src/components/inputs-values/types.ts +22 -0
- package/src/components/json-editor-with-variables/index.tsx +47 -1
- package/src/components/json-schema-editor/config.json +2 -2
- package/src/components/json-schema-editor/default-value.tsx +1 -1
- package/src/components/json-schema-editor/hooks.tsx +4 -2
- package/src/components/json-schema-editor/index.tsx +15 -2
- package/src/components/json-schema-editor/types.ts +1 -1
- package/src/components/prompt-editor/index.tsx +2 -1
- package/src/components/prompt-editor/types.tsx +1 -0
- package/src/components/prompt-editor-with-inputs/inputs-picker.tsx +1 -1
- package/src/components/prompt-editor-with-variables/extensions/variable-tag.tsx +6 -3
- package/src/components/type-selector/config.json +6 -2
- package/src/components/type-selector/index.tsx +55 -12
- package/src/components/variable-selector/config.json +6 -2
- package/src/components/variable-selector/index.tsx +34 -13
- package/src/components/variable-selector/styles.tsx +18 -8
- package/src/components/variable-selector/use-variable-tree.tsx +19 -22
- package/src/effects/auto-rename-ref/index.ts +59 -8
- package/src/effects/index.ts +3 -1
- package/src/effects/listen-ref-schema-change/config.json +10 -0
- package/src/effects/listen-ref-schema-change/index.ts +56 -0
- package/src/effects/listen-ref-value-change/config.json +9 -0
- package/src/effects/listen-ref-value-change/index.ts +53 -0
- package/src/effects/provide-json-schema-outputs/config.json +4 -5
- package/src/effects/provide-json-schema-outputs/index.ts +1 -3
- package/src/effects/sync-variable-title/index.ts +1 -0
- package/src/effects/validate-when-variable-sync/config.json +5 -0
- package/src/effects/validate-when-variable-sync/index.ts +35 -0
- package/src/form-plugins/index.ts +3 -1
- package/src/form-plugins/infer-assign-plugin/config.json +7 -0
- package/src/form-plugins/infer-assign-plugin/index.ts +90 -0
- package/src/form-plugins/infer-inputs-plugin/config.json +9 -0
- package/src/form-plugins/infer-inputs-plugin/index.ts +108 -0
- package/src/hooks/index.tsx +6 -0
- package/src/hooks/use-object-list/config.json +8 -0
- package/src/hooks/use-object-list/index.tsx +136 -0
- package/src/index.ts +3 -1
- package/src/{typings/json-schema → plugins/disable-declaration-plugin}/config.json +1 -1
- package/src/plugins/disable-declaration-plugin/create-disable-declaration-plugin.ts +31 -0
- package/src/plugins/disable-declaration-plugin/index.tsx +6 -0
- package/src/plugins/index.ts +7 -0
- package/src/plugins/json-schema-preset/config.json +9 -0
- package/src/plugins/json-schema-preset/create-type-preset-plugin.tsx +28 -0
- package/src/plugins/json-schema-preset/index.tsx +41 -0
- package/src/plugins/json-schema-preset/manager.ts +18 -0
- package/src/plugins/json-schema-preset/type-definition/array.tsx +24 -0
- package/src/plugins/json-schema-preset/type-definition/boolean.tsx +32 -0
- package/src/plugins/json-schema-preset/type-definition/index.tsx +24 -0
- package/src/plugins/json-schema-preset/type-definition/integer.tsx +24 -0
- package/src/plugins/json-schema-preset/type-definition/number.tsx +24 -0
- package/src/plugins/json-schema-preset/type-definition/object.tsx +24 -0
- package/src/plugins/json-schema-preset/type-definition/string.tsx +18 -0
- package/src/{utils → shared}/index.ts +0 -1
- package/src/typings/flow-value/config.json +3 -1
- package/src/typings/flow-value/index.ts +11 -0
- package/src/typings/index.ts +0 -1
- package/src/validate/index.tsx +6 -0
- package/src/validate/validate-flow-value/config.json +7 -0
- package/src/validate/validate-flow-value/index.tsx +73 -0
- package/src/components/batch-outputs/use-list.ts +0 -86
- package/src/components/type-selector/constants.tsx +0 -364
- package/src/effects/provide-batch-outputs/config.json +0 -5
- package/src/effects/provide-batch-outputs/index.ts +0 -38
- package/src/typings/json-schema/index.ts +0 -36
- package/src/utils/json-schema/config.json +0 -5
- package/src/utils/json-schema/index.ts +0 -180
- /package/src/{utils → shared}/format-legacy-refs/config.json +0 -0
- /package/src/{utils → shared}/format-legacy-refs/index.ts +0 -0
- /package/src/{utils → shared}/format-legacy-refs/readme.md +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowgram.ai/form-materials",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.12",
|
|
4
4
|
"homepage": "https://flowgram.ai/",
|
|
5
5
|
"repository": "https://github.com/bytedance/flowgram.ai",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,7 +33,9 @@
|
|
|
33
33
|
"@coze-editor/editor": "0.1.0-alpha.879fbb",
|
|
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.1.0-alpha.12",
|
|
38
|
+
"@flowgram.ai/json-schema": "0.1.0-alpha.12"
|
|
37
39
|
},
|
|
38
40
|
"devDependencies": {
|
|
39
41
|
"@types/lodash": "^4.14.137",
|
|
@@ -47,10 +49,10 @@
|
|
|
47
49
|
"react-dom": "^18",
|
|
48
50
|
"styled-components": "^5",
|
|
49
51
|
"tsup": "^8.0.1",
|
|
50
|
-
"typescript": "^5.
|
|
52
|
+
"typescript": "^5.8.3",
|
|
51
53
|
"vitest": "^0.34.6",
|
|
52
|
-
"@flowgram.ai/eslint-config": "0.1.0-alpha.
|
|
53
|
-
"@flowgram.ai/ts-config": "0.1.0-alpha.
|
|
54
|
+
"@flowgram.ai/eslint-config": "0.1.0-alpha.12",
|
|
55
|
+
"@flowgram.ai/ts-config": "0.1.0-alpha.12"
|
|
54
56
|
},
|
|
55
57
|
"peerDependencies": {
|
|
56
58
|
"react": ">=16.8",
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import React, { useEffect, useState } from 'react';
|
|
7
|
+
|
|
8
|
+
import Input, { InputProps } from '@douyinfe/semi-ui/lib/es/input';
|
|
9
|
+
|
|
10
|
+
export function BlurInput(props: InputProps) {
|
|
11
|
+
const [value, setValue] = useState('');
|
|
12
|
+
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
setValue(props.value as string);
|
|
15
|
+
}, [props.value]);
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<Input
|
|
19
|
+
{...props}
|
|
20
|
+
value={value}
|
|
21
|
+
onChange={(value) => {
|
|
22
|
+
setValue(value);
|
|
23
|
+
}}
|
|
24
|
+
onBlur={(e) => props.onChange?.(value, e)}
|
|
25
|
+
/>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
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 { IconButton } from '@douyinfe/semi-ui';
|
|
9
|
+
import { IconMinus } from '@douyinfe/semi-icons';
|
|
10
|
+
|
|
11
|
+
import { IFlowConstantRefValue } from '@/typings';
|
|
12
|
+
|
|
13
|
+
import { AssignRowProps } from './types';
|
|
14
|
+
import { BlurInput } from './components/blur-input';
|
|
15
|
+
import { VariableSelector } from '../variable-selector';
|
|
16
|
+
import { DynamicValueInput } from '../dynamic-value-input';
|
|
17
|
+
|
|
18
|
+
export function AssignRow(props: AssignRowProps) {
|
|
19
|
+
const {
|
|
20
|
+
value = {
|
|
21
|
+
operator: 'assign',
|
|
22
|
+
},
|
|
23
|
+
onChange,
|
|
24
|
+
onDelete,
|
|
25
|
+
readonly,
|
|
26
|
+
} = props;
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: 5 }}>
|
|
30
|
+
<div style={{ width: 150, minWidth: 150, maxWidth: 150 }}>
|
|
31
|
+
{value?.operator === 'assign' ? (
|
|
32
|
+
<VariableSelector
|
|
33
|
+
style={{ width: '100%', height: 26 }}
|
|
34
|
+
value={value?.left?.content}
|
|
35
|
+
config={{ placeholder: 'Select Left' }}
|
|
36
|
+
onChange={(v) =>
|
|
37
|
+
onChange?.({
|
|
38
|
+
...value,
|
|
39
|
+
left: { type: 'ref', content: v },
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
/>
|
|
43
|
+
) : (
|
|
44
|
+
<BlurInput
|
|
45
|
+
style={{ height: 26 }}
|
|
46
|
+
size="small"
|
|
47
|
+
placeholder="Input Name"
|
|
48
|
+
value={value?.left}
|
|
49
|
+
onChange={(v) =>
|
|
50
|
+
onChange?.({
|
|
51
|
+
...value,
|
|
52
|
+
left: v,
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
/>
|
|
56
|
+
)}
|
|
57
|
+
</div>
|
|
58
|
+
<div style={{ flexGrow: 1 }}>
|
|
59
|
+
<DynamicValueInput
|
|
60
|
+
readonly={readonly}
|
|
61
|
+
value={value?.right as IFlowConstantRefValue | undefined}
|
|
62
|
+
onChange={(v) =>
|
|
63
|
+
onChange?.({
|
|
64
|
+
...value,
|
|
65
|
+
right: v,
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
/>
|
|
69
|
+
</div>
|
|
70
|
+
{onDelete && (
|
|
71
|
+
<div>
|
|
72
|
+
<IconButton
|
|
73
|
+
size="small"
|
|
74
|
+
theme="borderless"
|
|
75
|
+
icon={<IconMinus />}
|
|
76
|
+
onClick={() => onDelete?.()}
|
|
77
|
+
/>
|
|
78
|
+
</div>
|
|
79
|
+
)}
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export { AssignValueType } from './types';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { IFlowRefValue, IFlowValue } from '@/typings';
|
|
7
|
+
|
|
8
|
+
export type AssignValueType =
|
|
9
|
+
| {
|
|
10
|
+
operator: 'assign';
|
|
11
|
+
left?: IFlowRefValue;
|
|
12
|
+
right?: IFlowValue;
|
|
13
|
+
}
|
|
14
|
+
| {
|
|
15
|
+
operator: 'declare';
|
|
16
|
+
left?: string;
|
|
17
|
+
right?: IFlowValue;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export interface AssignRowProps {
|
|
21
|
+
value?: AssignValueType;
|
|
22
|
+
onChange?: (value?: AssignValueType) => void;
|
|
23
|
+
onDelete?: () => void;
|
|
24
|
+
readonly?: boolean;
|
|
25
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
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 { FieldArray, FieldArrayRenderProps } from '@flowgram.ai/editor';
|
|
9
|
+
import { Button } from '@douyinfe/semi-ui';
|
|
10
|
+
import { IconPlus } from '@douyinfe/semi-icons';
|
|
11
|
+
|
|
12
|
+
import { AssignRow, AssignValueType } from '../assign-row';
|
|
13
|
+
|
|
14
|
+
interface AssignRowsProps {
|
|
15
|
+
name: string;
|
|
16
|
+
readonly?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function AssignRows(props: AssignRowsProps) {
|
|
20
|
+
const { name, readonly } = props;
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<FieldArray name={name}>
|
|
24
|
+
{({ field }: FieldArrayRenderProps<AssignValueType | undefined>) => (
|
|
25
|
+
<>
|
|
26
|
+
{field.map((childField, index) => (
|
|
27
|
+
<AssignRow
|
|
28
|
+
key={childField.key}
|
|
29
|
+
readonly={readonly}
|
|
30
|
+
value={childField.value}
|
|
31
|
+
onChange={(value) => {
|
|
32
|
+
childField.onChange(value);
|
|
33
|
+
}}
|
|
34
|
+
onDelete={() => field.remove(index)}
|
|
35
|
+
/>
|
|
36
|
+
))}
|
|
37
|
+
<div style={{ display: 'flex', gap: 5 }}>
|
|
38
|
+
<Button
|
|
39
|
+
size="small"
|
|
40
|
+
theme="borderless"
|
|
41
|
+
icon={<IconPlus />}
|
|
42
|
+
onClick={() => field.append({ operator: 'assign' })}
|
|
43
|
+
>
|
|
44
|
+
Assign
|
|
45
|
+
</Button>
|
|
46
|
+
<Button
|
|
47
|
+
size="small"
|
|
48
|
+
theme="borderless"
|
|
49
|
+
icon={<IconPlus />}
|
|
50
|
+
onClick={() => field.append({ operator: 'declare' })}
|
|
51
|
+
>
|
|
52
|
+
Declaration
|
|
53
|
+
</Button>
|
|
54
|
+
</div>
|
|
55
|
+
</>
|
|
56
|
+
)}
|
|
57
|
+
</FieldArray>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
@@ -8,15 +8,15 @@ 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 { useList } from './use-list';
|
|
12
11
|
import { PropsType } from './types';
|
|
13
12
|
import { VariableSelector } from '../variable-selector';
|
|
13
|
+
import { useObjectList } from '../../hooks';
|
|
14
14
|
import { UIRow, UIRows } from './styles';
|
|
15
15
|
|
|
16
16
|
export function BatchOutputs(props: PropsType) {
|
|
17
17
|
const { readonly, style } = props;
|
|
18
18
|
|
|
19
|
-
const { list, add,
|
|
19
|
+
const { list, add, updateKey, updateValue, remove } = useObjectList(props);
|
|
20
20
|
|
|
21
21
|
return (
|
|
22
22
|
<div>
|
|
@@ -28,21 +28,13 @@ export function BatchOutputs(props: PropsType) {
|
|
|
28
28
|
disabled={readonly}
|
|
29
29
|
size="small"
|
|
30
30
|
value={item.key}
|
|
31
|
-
onChange={(v) =>
|
|
31
|
+
onChange={(v) => updateKey(item.id, v)}
|
|
32
32
|
/>
|
|
33
33
|
<VariableSelector
|
|
34
34
|
style={{ flexGrow: 1 }}
|
|
35
35
|
readonly={readonly}
|
|
36
36
|
value={item.value?.content}
|
|
37
|
-
onChange={(v) =>
|
|
38
|
-
update({
|
|
39
|
-
...item,
|
|
40
|
-
value: {
|
|
41
|
-
type: 'ref',
|
|
42
|
-
content: v,
|
|
43
|
-
},
|
|
44
|
-
})
|
|
45
|
-
}
|
|
37
|
+
onChange={(v) => updateValue(item.id, { type: 'ref', content: v })}
|
|
46
38
|
/>
|
|
47
39
|
<Button
|
|
48
40
|
disabled={readonly}
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
|
+
import { IJsonSchema } from '@flowgram.ai/json-schema';
|
|
8
9
|
import { PrivateScopeProvider } from '@flowgram.ai/editor';
|
|
9
10
|
|
|
10
11
|
import { VariableSelector, VariableSelectorProps } from '../variable-selector';
|
|
11
|
-
import { IJsonSchema } from '../../typings';
|
|
12
12
|
|
|
13
13
|
const batchVariableSchema: IJsonSchema = {
|
|
14
14
|
type: 'array',
|
|
@@ -5,11 +5,17 @@
|
|
|
5
5
|
|
|
6
6
|
import React, { useEffect, useRef } from 'react';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
ActiveLinePlaceholder,
|
|
10
|
+
createRenderer,
|
|
11
|
+
EditorProvider,
|
|
12
|
+
InferValues,
|
|
13
|
+
} from '@coze-editor/editor/react';
|
|
9
14
|
import preset, { type EditorAPI } from '@coze-editor/editor/preset-code';
|
|
10
15
|
import { EditorView } from '@codemirror/view';
|
|
11
16
|
|
|
12
17
|
import { getSuffixByLanguageId } from './utils';
|
|
18
|
+
import { initTsWorker } from './language-features';
|
|
13
19
|
|
|
14
20
|
import './theme';
|
|
15
21
|
import './language-features';
|
|
@@ -22,6 +28,9 @@ const OriginCodeEditor = createRenderer(preset, [
|
|
|
22
28
|
}),
|
|
23
29
|
]);
|
|
24
30
|
|
|
31
|
+
type Preset = typeof preset;
|
|
32
|
+
type Options = Partial<InferValues<Preset[number]>>;
|
|
33
|
+
|
|
25
34
|
export interface CodeEditorPropsType extends React.PropsWithChildren<{}> {
|
|
26
35
|
value?: string;
|
|
27
36
|
onChange?: (value: string) => void;
|
|
@@ -29,6 +38,8 @@ export interface CodeEditorPropsType extends React.PropsWithChildren<{}> {
|
|
|
29
38
|
theme?: 'dark' | 'light';
|
|
30
39
|
placeholder?: string;
|
|
31
40
|
activeLinePlaceholder?: string;
|
|
41
|
+
readonly?: boolean;
|
|
42
|
+
options?: Options;
|
|
32
43
|
}
|
|
33
44
|
|
|
34
45
|
export function CodeEditor({
|
|
@@ -39,9 +50,17 @@ export function CodeEditor({
|
|
|
39
50
|
children,
|
|
40
51
|
placeholder,
|
|
41
52
|
activeLinePlaceholder,
|
|
53
|
+
options,
|
|
54
|
+
readonly,
|
|
42
55
|
}: CodeEditorPropsType) {
|
|
43
56
|
const editorRef = useRef<EditorAPI | null>(null);
|
|
44
57
|
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
if (languageId === 'typescript') {
|
|
60
|
+
initTsWorker();
|
|
61
|
+
}
|
|
62
|
+
}, [languageId]);
|
|
63
|
+
|
|
45
64
|
useEffect(() => {
|
|
46
65
|
// listen to value change
|
|
47
66
|
if (editorRef.current?.getValue() !== value) {
|
|
@@ -58,6 +77,9 @@ export function CodeEditor({
|
|
|
58
77
|
languageId,
|
|
59
78
|
theme,
|
|
60
79
|
placeholder,
|
|
80
|
+
readOnly: readonly,
|
|
81
|
+
editable: !readonly,
|
|
82
|
+
...(options || {}),
|
|
61
83
|
}}
|
|
62
84
|
didMount={(editor: EditorAPI) => {
|
|
63
85
|
editorRef.current = editor;
|
|
@@ -4,14 +4,15 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { languages } from '@coze-editor/editor/preset-code';
|
|
7
|
-
|
|
7
|
+
import { typescript } from '@coze-editor/editor/language-typescript';
|
|
8
8
|
import { shell } from '@coze-editor/editor/language-shell';
|
|
9
9
|
import { python } from '@coze-editor/editor/language-python';
|
|
10
10
|
import { json } from '@coze-editor/editor/language-json';
|
|
11
11
|
import { mixLanguages } from '@coze-editor/editor';
|
|
12
12
|
|
|
13
13
|
languages.register('python', python);
|
|
14
|
-
|
|
14
|
+
languages.register('shell', shell);
|
|
15
|
+
languages.register('typescript', typescript);
|
|
15
16
|
|
|
16
17
|
languages.register('json', {
|
|
17
18
|
// mixLanguages is used to solve the problem that interpolation also uses parentheses, which causes incorrect highlighting
|
|
@@ -21,4 +22,23 @@ languages.register('json', {
|
|
|
21
22
|
languageService: json.languageService,
|
|
22
23
|
});
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
let tsWorkerInit = false;
|
|
26
|
+
|
|
27
|
+
export const initTsWorker = () => {
|
|
28
|
+
if (tsWorkerInit) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
tsWorkerInit = true;
|
|
32
|
+
|
|
33
|
+
const tsWorker = new Worker(
|
|
34
|
+
new URL(`@coze-editor/editor/language-typescript/worker`, import.meta.url),
|
|
35
|
+
{ type: 'module' }
|
|
36
|
+
);
|
|
37
|
+
typescript.languageService.initialize(tsWorker, {
|
|
38
|
+
compilerOptions: {
|
|
39
|
+
// eliminate Promise error
|
|
40
|
+
lib: ['es2015', 'dom'],
|
|
41
|
+
noImplicitAny: false,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
};
|
|
@@ -29,8 +29,8 @@ export const lightTheme: Extension = createTheme({
|
|
|
29
29
|
gutterForeground: '#666',
|
|
30
30
|
gutterBorderColor: 'transparent',
|
|
31
31
|
gutterBorderWidth: 0,
|
|
32
|
-
lineHighlight: '#
|
|
33
|
-
bracketColors: ['#
|
|
32
|
+
lineHighlight: '#e1e1e180',
|
|
33
|
+
bracketColors: ['#FFD700', '#DD99FF', '#78B0FF'],
|
|
34
34
|
tooltip: {
|
|
35
35
|
backgroundColor: '#f0f0f0',
|
|
36
36
|
color: '#000',
|
|
@@ -0,0 +1,31 @@
|
|
|
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 from 'styled-components';
|
|
9
|
+
|
|
10
|
+
import { CodeEditor, CodeEditorPropsType } from '../code-editor';
|
|
11
|
+
|
|
12
|
+
const UIMini = styled.div`
|
|
13
|
+
.ͼ1 .cm-content {
|
|
14
|
+
padding: 0;
|
|
15
|
+
}
|
|
16
|
+
`;
|
|
17
|
+
|
|
18
|
+
export function CodeEditorMini(props: CodeEditorPropsType) {
|
|
19
|
+
return (
|
|
20
|
+
<UIMini>
|
|
21
|
+
<CodeEditor
|
|
22
|
+
{...props}
|
|
23
|
+
options={{
|
|
24
|
+
lineNumbersGutter: false,
|
|
25
|
+
foldGutter: false,
|
|
26
|
+
...(props.options || {}),
|
|
27
|
+
}}
|
|
28
|
+
/>
|
|
29
|
+
</UIMini>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "condition-row",
|
|
3
|
-
"depMaterials": [
|
|
4
|
-
|
|
3
|
+
"depMaterials": [
|
|
4
|
+
"variable-selector",
|
|
5
|
+
"dynamic-value-input",
|
|
6
|
+
"flow-value"
|
|
7
|
+
],
|
|
8
|
+
"depPackages": [
|
|
9
|
+
"@douyinfe/semi-ui",
|
|
10
|
+
"styled-components",
|
|
11
|
+
"@flowgram.ai/json-schema"
|
|
12
|
+
]
|
|
5
13
|
}
|
|
@@ -13,8 +13,8 @@ export const rules: IRules = {
|
|
|
13
13
|
[Op.NOT_CONTAINS]: 'string',
|
|
14
14
|
[Op.IN]: 'array',
|
|
15
15
|
[Op.NIN]: 'array',
|
|
16
|
-
[Op.IS_EMPTY]:
|
|
17
|
-
[Op.IS_NOT_EMPTY]:
|
|
16
|
+
[Op.IS_EMPTY]: null,
|
|
17
|
+
[Op.IS_NOT_EMPTY]: null,
|
|
18
18
|
},
|
|
19
19
|
number: {
|
|
20
20
|
[Op.EQ]: 'number',
|
|
@@ -25,8 +25,6 @@ export const rules: IRules = {
|
|
|
25
25
|
[Op.LTE]: 'number',
|
|
26
26
|
[Op.IN]: 'array',
|
|
27
27
|
[Op.NIN]: 'array',
|
|
28
|
-
[Op.IS_EMPTY]: null,
|
|
29
|
-
[Op.IS_NOT_EMPTY]: null,
|
|
30
28
|
},
|
|
31
29
|
integer: {
|
|
32
30
|
[Op.EQ]: 'number',
|
|
@@ -37,8 +35,6 @@ export const rules: IRules = {
|
|
|
37
35
|
[Op.LTE]: 'number',
|
|
38
36
|
[Op.IN]: 'array',
|
|
39
37
|
[Op.NIN]: 'array',
|
|
40
|
-
[Op.IS_EMPTY]: null,
|
|
41
|
-
[Op.IS_NOT_EMPTY]: null,
|
|
42
38
|
},
|
|
43
39
|
boolean: {
|
|
44
40
|
[Op.EQ]: 'boolean',
|
|
@@ -47,8 +43,6 @@ export const rules: IRules = {
|
|
|
47
43
|
[Op.IS_FALSE]: null,
|
|
48
44
|
[Op.IN]: 'array',
|
|
49
45
|
[Op.NIN]: 'array',
|
|
50
|
-
[Op.IS_EMPTY]: null,
|
|
51
|
-
[Op.IS_NOT_EMPTY]: null,
|
|
52
46
|
},
|
|
53
47
|
object: {
|
|
54
48
|
[Op.IS_EMPTY]: null,
|
|
@@ -57,6 +51,10 @@ export const rules: IRules = {
|
|
|
57
51
|
array: {
|
|
58
52
|
[Op.IS_EMPTY]: null,
|
|
59
53
|
[Op.IS_NOT_EMPTY]: null,
|
|
54
|
+
[Op.CONTAINS]: 'array',
|
|
55
|
+
[Op.NOT_CONTAINS]: 'array',
|
|
56
|
+
[Op.EQ]: 'array',
|
|
57
|
+
[Op.NEQ]: 'array',
|
|
60
58
|
},
|
|
61
59
|
map: {
|
|
62
60
|
[Op.IS_EMPTY]: null,
|
|
@@ -15,9 +15,10 @@ interface HookParams {
|
|
|
15
15
|
rule?: IRule;
|
|
16
16
|
op?: Op;
|
|
17
17
|
onChange: (op: Op) => void;
|
|
18
|
+
readonly?: boolean;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
export function useOp({ rule, op, onChange }: HookParams) {
|
|
21
|
+
export function useOp({ rule, op, onChange, readonly }: HookParams) {
|
|
21
22
|
const options = useMemo(
|
|
22
23
|
() =>
|
|
23
24
|
Object.keys(rule || {}).map((_op) => ({
|
|
@@ -32,6 +33,7 @@ export function useOp({ rule, op, onChange }: HookParams) {
|
|
|
32
33
|
const renderOpSelect = () => (
|
|
33
34
|
<Select
|
|
34
35
|
style={{ height: 22 }}
|
|
36
|
+
disabled={readonly}
|
|
35
37
|
size="small"
|
|
36
38
|
value={op}
|
|
37
39
|
optionList={options}
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
import { useMemo } from 'react';
|
|
7
7
|
|
|
8
|
+
import { JsonSchemaUtils, JsonSchemaBasicType } from '@flowgram.ai/json-schema';
|
|
8
9
|
import { useScopeAvailable } from '@flowgram.ai/editor';
|
|
9
10
|
|
|
10
11
|
import { rules } from '../constants';
|
|
11
|
-
import {
|
|
12
|
-
import { IFlowRefValue, JsonSchemaBasicType } from '../../../typings';
|
|
12
|
+
import { IFlowRefValue } from '../../../typings';
|
|
13
13
|
|
|
14
14
|
export function useRule(left?: IFlowRefValue) {
|
|
15
15
|
const available = useScopeAvailable();
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import React, { useMemo } from 'react';
|
|
7
7
|
|
|
8
|
+
import { JsonSchemaBasicType } from '@flowgram.ai/json-schema';
|
|
8
9
|
import { Input } from '@douyinfe/semi-ui';
|
|
9
10
|
|
|
10
11
|
import { ConditionRowValueType, Op } from './types';
|
|
@@ -13,7 +14,6 @@ import { useRule } from './hooks/useRule';
|
|
|
13
14
|
import { useOp } from './hooks/useOp';
|
|
14
15
|
import { VariableSelector } from '../variable-selector';
|
|
15
16
|
import { DynamicValueInput } from '../dynamic-value-input';
|
|
16
|
-
import { JsonSchemaBasicType } from '../../typings';
|
|
17
17
|
|
|
18
18
|
interface PropTypes {
|
|
19
19
|
value?: ConditionRowValueType;
|
|
@@ -29,6 +29,7 @@ export function ConditionRow({ style, value, onChange, readonly }: PropTypes) {
|
|
|
29
29
|
rule,
|
|
30
30
|
op: operator,
|
|
31
31
|
onChange: (v) => onChange({ ...value, operator: v }),
|
|
32
|
+
readonly,
|
|
32
33
|
});
|
|
33
34
|
|
|
34
35
|
const targetSchema = useMemo(() => {
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { JsonSchemaBasicType } from '@flowgram.ai/json-schema';
|
|
7
|
+
|
|
8
|
+
import { IFlowConstantRefValue, IFlowRefValue } from '../../typings';
|
|
7
9
|
|
|
8
10
|
export enum Op {
|
|
9
11
|
EQ = 'eq',
|