@flowgram.ai/form-materials 0.1.0-alpha.17 → 0.1.0-alpha.19
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/cjs/components/batch-outputs/index.js +5 -3
- package/dist/cjs/components/batch-outputs/styles.css +13 -0
- package/dist/cjs/components/blur-input/index.js +1 -0
- package/dist/cjs/components/code-editor/editor.js +16 -12
- package/dist/cjs/components/code-editor/styles.css +4 -0
- package/dist/cjs/components/code-editor/theme/dark.js +1 -1
- package/dist/cjs/components/code-editor/theme/light.js +1 -1
- package/dist/cjs/components/code-editor-mini/index.js +2 -16
- package/dist/cjs/components/condition-context/hooks/use-condition.js +17 -1
- package/dist/cjs/components/condition-row/index.js +26 -12
- package/dist/cjs/components/condition-row/styles.css +19 -0
- package/dist/cjs/components/coze-editor-extensions/extensions/inputs-tree.js +2 -2
- package/dist/cjs/components/coze-editor-extensions/extensions/variable-tag.js +31 -11
- package/dist/{esm/components/coze-editor-extensions/styles.mjs → cjs/components/coze-editor-extensions/styles.css} +19 -18
- package/dist/cjs/components/db-condition-row/index.js +29 -14
- package/dist/cjs/components/db-condition-row/styles.css +30 -0
- package/dist/cjs/components/display-inputs-values/index.js +3 -2
- package/dist/cjs/components/display-inputs-values/styles.css +6 -0
- package/dist/cjs/components/display-outputs/index.js +5 -4
- package/dist/cjs/components/display-outputs/styles.css +6 -0
- package/dist/cjs/components/display-schema-tag/index.js +7 -4
- package/dist/cjs/components/display-schema-tag/styles.css +21 -0
- package/dist/cjs/components/display-schema-tree/index.js +12 -7
- package/dist/cjs/components/display-schema-tree/styles.css +64 -0
- package/dist/cjs/components/dynamic-value-input/index.js +9 -5
- package/dist/{esm/components/dynamic-value-input/styles.mjs → cjs/components/dynamic-value-input/styles.css} +24 -30
- package/dist/cjs/components/inputs-values/index.js +5 -3
- package/dist/cjs/components/inputs-values/styles.css +13 -0
- package/dist/cjs/components/inputs-values-tree/icon.js +70 -0
- package/dist/cjs/components/inputs-values-tree/index.js +4 -3
- package/dist/cjs/components/inputs-values-tree/row.js +19 -15
- package/dist/cjs/components/inputs-values-tree/styles.css +85 -0
- package/dist/cjs/components/json-schema-editor/default-value.js +2 -2
- package/dist/cjs/components/json-schema-editor/hooks.js +55 -48
- package/dist/cjs/components/json-schema-editor/icon.js +70 -0
- package/dist/cjs/components/json-schema-editor/index.js +37 -25
- package/dist/cjs/components/json-schema-editor/styles.css +113 -0
- package/dist/cjs/components/prompt-editor/editor.js +16 -6
- package/dist/cjs/components/prompt-editor/styles.css +10 -0
- package/dist/cjs/components/prompt-editor-with-inputs/index.js +16 -26
- package/dist/cjs/components/prompt-editor-with-variables/index.js +17 -26
- package/dist/cjs/components/variable-selector/context.js +7 -3
- package/dist/cjs/components/variable-selector/index.js +16 -10
- package/dist/{esm/components/variable-selector/styles.mjs → cjs/components/variable-selector/styles.css} +37 -29
- package/dist/cjs/components/variable-selector/use-variable-tree.js +3 -1
- package/dist/cjs/shared/inject-material/index.js +1 -1
- package/dist/esm/components/batch-outputs/index.mjs +5 -3
- package/dist/esm/components/batch-outputs/styles.css +13 -0
- package/dist/esm/components/blur-input/index.mjs +1 -0
- package/dist/esm/components/code-editor/editor.mjs +16 -11
- package/dist/esm/components/code-editor/styles.css +4 -0
- package/dist/esm/components/code-editor/theme/dark.mjs +1 -1
- package/dist/esm/components/code-editor/theme/light.mjs +1 -1
- package/dist/esm/components/code-editor-mini/index.mjs +2 -6
- package/dist/esm/components/condition-context/hooks/use-condition.mjs +18 -2
- package/dist/esm/components/condition-row/index.mjs +26 -12
- package/dist/esm/components/condition-row/styles.css +19 -0
- package/dist/esm/components/coze-editor-extensions/extensions/inputs-tree.mjs +3 -3
- package/dist/esm/components/coze-editor-extensions/extensions/variable-tag.mjs +32 -12
- package/dist/esm/components/coze-editor-extensions/styles.css +37 -0
- package/dist/esm/components/db-condition-row/index.mjs +29 -14
- package/dist/esm/components/db-condition-row/styles.css +30 -0
- package/dist/esm/components/display-inputs-values/index.mjs +3 -2
- package/dist/esm/components/display-inputs-values/styles.css +6 -0
- package/dist/esm/components/display-outputs/index.mjs +5 -4
- package/dist/esm/components/display-outputs/styles.css +6 -0
- package/dist/esm/components/display-schema-tag/index.mjs +8 -5
- package/dist/esm/components/display-schema-tag/styles.css +21 -0
- package/dist/esm/components/display-schema-tree/index.mjs +12 -7
- package/dist/esm/components/display-schema-tree/styles.css +64 -0
- package/dist/esm/components/dynamic-value-input/index.mjs +9 -5
- package/dist/esm/components/dynamic-value-input/styles.css +48 -0
- package/dist/esm/components/inputs-values/index.mjs +5 -3
- package/dist/esm/components/inputs-values/styles.css +13 -0
- package/dist/esm/components/inputs-values-tree/icon.mjs +26 -0
- package/dist/esm/components/inputs-values-tree/index.mjs +4 -3
- package/dist/esm/components/inputs-values-tree/row.mjs +18 -14
- package/dist/esm/components/inputs-values-tree/styles.css +85 -0
- package/dist/esm/components/json-schema-editor/default-value.mjs +2 -2
- package/dist/esm/components/json-schema-editor/hooks.mjs +55 -48
- package/dist/esm/components/json-schema-editor/icon.mjs +26 -0
- package/dist/esm/components/json-schema-editor/index.mjs +36 -24
- package/dist/esm/components/json-schema-editor/styles.css +113 -0
- package/dist/esm/components/prompt-editor/editor.mjs +16 -6
- package/dist/esm/components/prompt-editor/styles.css +10 -0
- package/dist/esm/components/prompt-editor-with-inputs/index.mjs +12 -4
- package/dist/esm/components/prompt-editor-with-variables/index.mjs +13 -4
- package/dist/esm/components/variable-selector/context.mjs +7 -3
- package/dist/esm/components/variable-selector/index.mjs +17 -11
- package/{src/components/variable-selector/styles.tsx → dist/esm/components/variable-selector/styles.css} +35 -38
- package/dist/esm/components/variable-selector/use-variable-tree.mjs +3 -1
- package/dist/esm/shared/inject-material/index.mjs +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/components/batch-outputs/index.d.ts +1 -0
- package/dist/types/components/blur-input/index.d.ts +1 -1
- package/dist/types/components/code-editor/editor.d.ts +1 -0
- package/dist/types/components/condition-context/hooks/use-condition.d.ts +16 -1
- package/dist/types/components/condition-row/index.d.ts +5 -1
- package/dist/types/components/coze-editor-extensions/extensions/inputs-tree.d.ts +3 -3
- package/dist/types/components/coze-editor-extensions/extensions/variable-tag.d.ts +1 -0
- package/dist/types/components/coze-editor-extensions/index.d.ts +1 -1
- package/dist/types/components/db-condition-row/index.d.ts +4 -0
- package/dist/types/components/db-condition-row/types.d.ts +0 -1
- package/dist/types/components/display-inputs-values/index.d.ts +3 -1
- package/dist/types/components/display-outputs/index.d.ts +1 -0
- package/dist/types/components/display-schema-tag/index.d.ts +1 -0
- package/dist/types/components/display-schema-tree/index.d.ts +1 -0
- package/dist/types/components/dynamic-value-input/index.d.ts +1 -0
- package/dist/types/components/inputs-values/index.d.ts +1 -0
- package/dist/types/components/inputs-values-tree/icon.d.ts +6 -0
- package/dist/types/components/inputs-values-tree/index.d.ts +1 -0
- package/dist/types/components/inputs-values-tree/row.d.ts +1 -0
- package/dist/types/components/inputs-values-tree/types.d.ts +3 -2
- package/dist/types/components/json-schema-editor/icon.d.ts +6 -0
- package/dist/types/components/json-schema-editor/index.d.ts +1 -0
- package/dist/types/components/prompt-editor/editor.d.ts +1 -0
- package/dist/types/components/prompt-editor-with-inputs/index.d.ts +7 -2
- package/dist/types/components/prompt-editor-with-variables/index.d.ts +5 -2
- package/dist/types/components/variable-selector/context.d.ts +16 -3
- package/dist/types/components/variable-selector/index.d.ts +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/shared/flow-value/index.d.ts +1 -1
- package/dist/types/shared/flow-value/types.d.ts +3 -0
- package/dist/types/shared/index.d.ts +1 -1
- package/package.json +7 -10
- package/src/components/batch-outputs/index.tsx +5 -5
- package/src/components/batch-outputs/{styles.tsx → styles.css} +4 -6
- package/src/components/blur-input/index.tsx +2 -1
- package/src/components/code-editor/editor.tsx +19 -14
- package/src/components/code-editor/styles.css +11 -0
- package/src/components/code-editor/theme/dark.ts +1 -1
- package/src/components/code-editor/theme/light.ts +1 -1
- package/src/components/code-editor-mini/index.tsx +2 -9
- package/src/components/condition-context/hooks/use-condition.tsx +51 -7
- package/src/components/condition-row/index.tsx +27 -22
- package/src/components/condition-row/{styles.tsx → styles.css} +11 -11
- package/src/components/coze-editor-extensions/extensions/inputs-tree.tsx +7 -6
- package/src/components/coze-editor-extensions/extensions/variable-tag.tsx +19 -14
- package/src/components/coze-editor-extensions/{styles.tsx → styles.css} +8 -11
- package/src/components/db-condition-row/index.tsx +29 -26
- package/src/components/db-condition-row/{styles.tsx → styles.css} +14 -16
- package/src/components/db-condition-row/types.ts +0 -1
- package/src/components/display-inputs-values/index.tsx +5 -4
- package/src/components/display-inputs-values/{styles.ts → styles.css} +2 -4
- package/src/components/display-outputs/index.tsx +5 -5
- package/src/components/display-outputs/{styles.ts → styles.css} +2 -4
- package/src/components/display-schema-tag/index.tsx +7 -7
- package/src/components/display-schema-tag/{styles.ts → styles.css} +7 -10
- package/src/components/display-schema-tree/index.tsx +10 -10
- package/src/components/display-schema-tree/{styles.tsx → styles.css} +18 -24
- package/src/components/dynamic-value-input/index.tsx +6 -6
- package/src/components/dynamic-value-input/{styles.tsx → styles.css} +9 -12
- package/src/components/inputs-values/index.tsx +5 -5
- package/src/components/inputs-values/{styles.tsx → styles.css} +4 -6
- package/src/components/inputs-values-tree/icon.tsx +28 -0
- package/src/components/inputs-values-tree/index.tsx +8 -6
- package/src/components/inputs-values-tree/row.tsx +25 -27
- package/src/components/inputs-values-tree/styles.css +94 -0
- package/src/components/inputs-values-tree/types.ts +3 -2
- package/src/components/json-schema-editor/default-value.tsx +2 -4
- package/src/components/json-schema-editor/hooks.tsx +60 -53
- package/src/components/json-schema-editor/icon.tsx +28 -0
- package/src/components/json-schema-editor/index.tsx +45 -50
- package/src/components/json-schema-editor/styles.css +135 -0
- package/src/components/prompt-editor/editor.tsx +18 -7
- package/src/components/prompt-editor/styles.css +14 -0
- package/src/components/prompt-editor-with-inputs/index.tsx +18 -5
- package/src/components/prompt-editor-with-variables/index.tsx +13 -5
- package/src/components/variable-selector/context.tsx +22 -2
- package/src/components/variable-selector/index.tsx +24 -14
- package/src/components/variable-selector/styles.css +70 -0
- package/src/components/variable-selector/use-variable-tree.tsx +9 -1
- package/src/index.ts +1 -0
- package/src/shared/flow-value/index.ts +1 -0
- package/src/shared/flow-value/types.ts +4 -0
- package/src/shared/index.ts +1 -0
- package/src/shared/inject-material/index.tsx +1 -1
- package/dist/cjs/components/batch-outputs/styles.js +0 -60
- package/dist/cjs/components/condition-row/styles.js +0 -77
- package/dist/cjs/components/coze-editor-extensions/styles.js +0 -89
- package/dist/cjs/components/db-condition-row/styles.js +0 -94
- package/dist/cjs/components/display-inputs-values/styles.js +0 -51
- package/dist/cjs/components/display-outputs/styles.js +0 -51
- package/dist/cjs/components/display-schema-tag/styles.js +0 -71
- package/dist/cjs/components/display-schema-tree/styles.js +0 -135
- package/dist/cjs/components/dynamic-value-input/styles.js +0 -107
- package/dist/cjs/components/inputs-values/styles.js +0 -60
- package/dist/cjs/components/inputs-values-tree/styles.js +0 -177
- package/dist/cjs/components/json-schema-editor/styles.js +0 -231
- package/dist/cjs/components/prompt-editor/styles.js +0 -55
- package/dist/cjs/components/prompt-editor-with-inputs/editor.js +0 -47
- package/dist/cjs/components/prompt-editor-with-variables/editor.js +0 -48
- package/dist/cjs/components/variable-selector/styles.js +0 -114
- package/dist/esm/components/batch-outputs/styles.mjs +0 -13
- package/dist/esm/components/condition-row/styles.mjs +0 -21
- package/dist/esm/components/db-condition-row/styles.mjs +0 -32
- package/dist/esm/components/display-inputs-values/styles.mjs +0 -7
- package/dist/esm/components/display-outputs/styles.mjs +0 -7
- package/dist/esm/components/display-schema-tag/styles.mjs +0 -21
- package/dist/esm/components/display-schema-tree/styles.mjs +0 -79
- package/dist/esm/components/inputs-values/styles.mjs +0 -13
- package/dist/esm/components/inputs-values-tree/styles.mjs +0 -105
- package/dist/esm/components/json-schema-editor/styles.mjs +0 -138
- package/dist/esm/components/prompt-editor/styles.mjs +0 -11
- package/dist/esm/components/prompt-editor-with-inputs/editor.mjs +0 -13
- package/dist/esm/components/prompt-editor-with-variables/editor.mjs +0 -14
- package/dist/types/components/batch-outputs/styles.d.ts +0 -6
- package/dist/types/components/condition-row/styles.d.ts +0 -9
- package/dist/types/components/coze-editor-extensions/styles.d.ts +0 -9
- package/dist/types/components/db-condition-row/styles.d.ts +0 -12
- package/dist/types/components/display-inputs-values/styles.d.ts +0 -5
- package/dist/types/components/display-outputs/styles.d.ts +0 -5
- package/dist/types/components/display-schema-tag/styles.d.ts +0 -8
- package/dist/types/components/display-schema-tree/styles.d.ts +0 -11
- package/dist/types/components/dynamic-value-input/styles.d.ts +0 -8
- package/dist/types/components/inputs-values/styles.d.ts +0 -6
- package/dist/types/components/inputs-values-tree/styles.d.ts +0 -23
- package/dist/types/components/json-schema-editor/styles.d.ts +0 -30
- package/dist/types/components/prompt-editor/styles.d.ts +0 -7
- package/dist/types/components/prompt-editor-with-inputs/editor.d.ts +0 -10
- package/dist/types/components/prompt-editor-with-variables/editor.d.ts +0 -9
- package/dist/types/components/variable-selector/styles.d.ts +0 -14
- package/src/components/inputs-values-tree/styles.tsx +0 -128
- package/src/components/json-schema-editor/styles.tsx +0 -168
- package/src/components/prompt-editor/styles.tsx +0 -18
- package/src/components/prompt-editor-with-inputs/editor.tsx +0 -24
- package/src/components/prompt-editor-with-variables/editor.tsx +0 -20
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.19",
|
|
4
4
|
"homepage": "https://flowgram.ai/",
|
|
5
5
|
"repository": "https://github.com/bytedance/flowgram.ai",
|
|
6
6
|
"license": "MIT",
|
|
@@ -67,9 +67,9 @@
|
|
|
67
67
|
"@codemirror/view": "~6.38.0",
|
|
68
68
|
"@codemirror/state": "~6.5.2",
|
|
69
69
|
"zod": "^3.24.4",
|
|
70
|
-
"@flowgram.ai/editor": "0.1.0-alpha.
|
|
71
|
-
"@flowgram.ai/
|
|
72
|
-
"@flowgram.ai/
|
|
70
|
+
"@flowgram.ai/editor": "0.1.0-alpha.19",
|
|
71
|
+
"@flowgram.ai/coze-editor": "0.1.0-alpha.19",
|
|
72
|
+
"@flowgram.ai/json-schema": "0.1.0-alpha.19"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@types/lodash-es": "^4.17.12",
|
|
@@ -77,24 +77,21 @@
|
|
|
77
77
|
"@types/react": "^18",
|
|
78
78
|
"@types/react-dom": "^18",
|
|
79
79
|
"@types/inquirer": "^9.0.9",
|
|
80
|
-
"@types/styled-components": "^5",
|
|
81
80
|
"eslint": "^8.54.0",
|
|
82
81
|
"react": "^18",
|
|
83
82
|
"react-dom": "^18",
|
|
84
|
-
"styled-components": "^5",
|
|
85
83
|
"typescript": "^5.8.3",
|
|
86
84
|
"vitest": "^3.2.4",
|
|
87
85
|
"@rslib/core": "~0.12.4",
|
|
88
86
|
"cross-env": "~7.0.3",
|
|
89
87
|
"@rsbuild/plugin-react": "^1.1.1",
|
|
90
88
|
"date-fns": "~4.1.0",
|
|
91
|
-
"@flowgram.ai/eslint-config": "0.1.0-alpha.
|
|
92
|
-
"@flowgram.ai/ts-config": "0.1.0-alpha.
|
|
89
|
+
"@flowgram.ai/eslint-config": "0.1.0-alpha.19",
|
|
90
|
+
"@flowgram.ai/ts-config": "0.1.0-alpha.19"
|
|
93
91
|
},
|
|
94
92
|
"peerDependencies": {
|
|
95
93
|
"react": ">=16.8",
|
|
96
|
-
"react-dom": ">=16.8"
|
|
97
|
-
"styled-components": ">=5"
|
|
94
|
+
"react-dom": ">=16.8"
|
|
98
95
|
},
|
|
99
96
|
"publishConfig": {
|
|
100
97
|
"access": "public",
|
|
@@ -13,7 +13,7 @@ import { useObjectList } from '@/hooks';
|
|
|
13
13
|
import { InjectVariableSelector } from '@/components/variable-selector';
|
|
14
14
|
|
|
15
15
|
import { PropsType } from './types';
|
|
16
|
-
import
|
|
16
|
+
import './styles.css';
|
|
17
17
|
|
|
18
18
|
export function BatchOutputs(props: PropsType) {
|
|
19
19
|
const { readonly, style } = props;
|
|
@@ -22,9 +22,9 @@ export function BatchOutputs(props: PropsType) {
|
|
|
22
22
|
|
|
23
23
|
return (
|
|
24
24
|
<div>
|
|
25
|
-
<
|
|
25
|
+
<div className="gedit-m-batch-outputs-rows" style={style}>
|
|
26
26
|
{list.map((item) => (
|
|
27
|
-
<
|
|
27
|
+
<div className="gedit-m-batch-outputs-row" key={item.id}>
|
|
28
28
|
<Input
|
|
29
29
|
style={{ width: 100 }}
|
|
30
30
|
disabled={readonly}
|
|
@@ -44,9 +44,9 @@ export function BatchOutputs(props: PropsType) {
|
|
|
44
44
|
size="small"
|
|
45
45
|
onClick={() => remove(item.id)}
|
|
46
46
|
/>
|
|
47
|
-
</
|
|
47
|
+
</div>
|
|
48
48
|
))}
|
|
49
|
-
</
|
|
49
|
+
</div>
|
|
50
50
|
<Button disabled={readonly} icon={<IconPlus />} size="small" onClick={() => add()}>
|
|
51
51
|
{I18n.t('Add')}
|
|
52
52
|
</Button>
|
|
@@ -3,17 +3,15 @@
|
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export const UIRows = styled.div`
|
|
6
|
+
.gedit-m-batch-outputs-rows {
|
|
9
7
|
display: flex;
|
|
10
8
|
flex-direction: column;
|
|
11
9
|
gap: 10px;
|
|
12
10
|
margin-bottom: 10px;
|
|
13
|
-
|
|
11
|
+
}
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
.gedit-m-batch-outputs-row {
|
|
16
14
|
display: flex;
|
|
17
15
|
align-items: center;
|
|
18
16
|
gap: 5px;
|
|
19
|
-
|
|
17
|
+
}
|
|
@@ -13,7 +13,7 @@ import React, { useEffect, useState } from 'react';
|
|
|
13
13
|
|
|
14
14
|
import { Input } from '@douyinfe/semi-ui';
|
|
15
15
|
|
|
16
|
-
type InputProps = React.
|
|
16
|
+
type InputProps = React.ComponentPropsWithRef<typeof Input>;
|
|
17
17
|
|
|
18
18
|
export function BlurInput(props: InputProps) {
|
|
19
19
|
const [value, setValue] = useState('');
|
|
@@ -24,6 +24,7 @@ export function BlurInput(props: InputProps) {
|
|
|
24
24
|
|
|
25
25
|
return (
|
|
26
26
|
<Input
|
|
27
|
+
ref={props.ref}
|
|
27
28
|
{...props}
|
|
28
29
|
value={value}
|
|
29
30
|
onChange={(value) => {
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
|
|
6
6
|
import React, { useEffect, useRef } from 'react';
|
|
7
7
|
|
|
8
|
-
import styled, { css } from 'styled-components';
|
|
9
8
|
import {
|
|
10
9
|
ActiveLinePlaceholder,
|
|
11
10
|
createRenderer,
|
|
@@ -17,6 +16,8 @@ import { EditorView } from '@codemirror/view';
|
|
|
17
16
|
|
|
18
17
|
import { getSuffixByLanguageId } from './utils';
|
|
19
18
|
|
|
19
|
+
import './styles.css';
|
|
20
|
+
|
|
20
21
|
const OriginCodeEditor = createRenderer(preset, [
|
|
21
22
|
EditorView.theme({
|
|
22
23
|
'&.cm-focused': {
|
|
@@ -25,13 +26,7 @@ const OriginCodeEditor = createRenderer(preset, [
|
|
|
25
26
|
}),
|
|
26
27
|
]);
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
${({ $mini }) =>
|
|
30
|
-
$mini &&
|
|
31
|
-
css`
|
|
32
|
-
height: 24px;
|
|
33
|
-
`}
|
|
34
|
-
`;
|
|
29
|
+
// CSS styles are in styles.css
|
|
35
30
|
|
|
36
31
|
type Preset = typeof preset;
|
|
37
32
|
type Options = Partial<InferValues<Preset[number]>>;
|
|
@@ -62,18 +57,28 @@ export function BaseCodeEditor({
|
|
|
62
57
|
}: CodeEditorPropsType) {
|
|
63
58
|
const editorRef = useRef<EditorAPI | null>(null);
|
|
64
59
|
|
|
60
|
+
const editorValue = String(value || '');
|
|
61
|
+
|
|
65
62
|
useEffect(() => {
|
|
66
63
|
// listen to value change
|
|
67
|
-
if (editorRef.current?.getValue() !==
|
|
68
|
-
|
|
64
|
+
if (editorRef.current?.getValue() !== editorValue) {
|
|
65
|
+
// apply updates on readonly mode
|
|
66
|
+
const editorView = editorRef.current?.$view;
|
|
67
|
+
editorView?.dispatch({
|
|
68
|
+
changes: {
|
|
69
|
+
from: 0,
|
|
70
|
+
to: editorView?.state.doc.length,
|
|
71
|
+
insert: editorValue,
|
|
72
|
+
},
|
|
73
|
+
});
|
|
69
74
|
}
|
|
70
|
-
}, [
|
|
75
|
+
}, [editorValue]);
|
|
71
76
|
|
|
72
77
|
return (
|
|
73
|
-
<
|
|
78
|
+
<div className={`gedit-m-code-editor-container ${mini ? 'mini' : ''}`}>
|
|
74
79
|
<EditorProvider>
|
|
75
80
|
<OriginCodeEditor
|
|
76
|
-
defaultValue={
|
|
81
|
+
defaultValue={editorValue}
|
|
77
82
|
options={{
|
|
78
83
|
uri: `file:///untitled${getSuffixByLanguageId(languageId)}`,
|
|
79
84
|
languageId,
|
|
@@ -101,6 +106,6 @@ export function BaseCodeEditor({
|
|
|
101
106
|
{children}
|
|
102
107
|
</OriginCodeEditor>
|
|
103
108
|
</EditorProvider>
|
|
104
|
-
</
|
|
109
|
+
</div>
|
|
105
110
|
);
|
|
106
111
|
}
|
|
@@ -47,7 +47,7 @@ export const darkTheme: Extension = createTheme({
|
|
|
47
47
|
gutterForeground: colors.foreground,
|
|
48
48
|
gutterBorderColor: 'transparent',
|
|
49
49
|
gutterBorderWidth: 0,
|
|
50
|
-
lineHighlight: '
|
|
50
|
+
lineHighlight: 'transparent',
|
|
51
51
|
bracketColors: ['#FBBF24', '#A78BFA', '#7DD3FC'],
|
|
52
52
|
tooltip: {
|
|
53
53
|
backgroundColor: '#21262D',
|
|
@@ -42,7 +42,7 @@ export const lightTheme: Extension = createTheme({
|
|
|
42
42
|
gutterForeground: colors.foreground,
|
|
43
43
|
gutterBorderColor: 'transparent',
|
|
44
44
|
gutterBorderWidth: 0,
|
|
45
|
-
lineHighlight:
|
|
45
|
+
lineHighlight: 'transparent',
|
|
46
46
|
bracketColors: ['#F59E0B', '#8B5CF6', '#06B6D4'],
|
|
47
47
|
tooltip: {
|
|
48
48
|
backgroundColor: colors.dropdownBackground,
|
|
@@ -5,21 +5,14 @@
|
|
|
5
5
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
|
-
import styled from 'styled-components';
|
|
9
|
-
|
|
10
8
|
import { CodeEditor, type CodeEditorPropsType } from '@/components/code-editor';
|
|
11
9
|
|
|
12
|
-
const UIMini = styled.div`
|
|
13
|
-
.ͼ1 .cm-content {
|
|
14
|
-
}
|
|
15
|
-
`;
|
|
16
|
-
|
|
17
10
|
/**
|
|
18
11
|
* @deprecated use mini in CodeEditorPropsType instead
|
|
19
12
|
*/
|
|
20
13
|
export function CodeEditorMini(props: CodeEditorPropsType) {
|
|
21
14
|
return (
|
|
22
|
-
<
|
|
15
|
+
<div className="gedit-m-code-editor-mini">
|
|
23
16
|
<CodeEditor
|
|
24
17
|
{...props}
|
|
25
18
|
options={{
|
|
@@ -29,6 +22,6 @@ export function CodeEditorMini(props: CodeEditorPropsType) {
|
|
|
29
22
|
...(props.options || {}),
|
|
30
23
|
}}
|
|
31
24
|
/>
|
|
32
|
-
</
|
|
25
|
+
</div>
|
|
33
26
|
);
|
|
34
27
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { useMemo } from 'react';
|
|
6
|
+
import { useEffect, useMemo, useRef } from 'react';
|
|
7
7
|
|
|
8
8
|
import { IJsonSchema } from '@flowgram.ai/json-schema';
|
|
9
9
|
import { I18n } from '@flowgram.ai/editor';
|
|
@@ -14,10 +14,28 @@ import { IConditionRule, ConditionOpConfigs } from '../types';
|
|
|
14
14
|
import { useConditionContext } from '../context';
|
|
15
15
|
|
|
16
16
|
interface HooksParams {
|
|
17
|
+
/**
|
|
18
|
+
* Left schema of condition
|
|
19
|
+
*/
|
|
17
20
|
leftSchema?: IJsonSchema;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Operator of condition
|
|
24
|
+
*/
|
|
18
25
|
operator?: string;
|
|
19
26
|
|
|
20
27
|
/**
|
|
28
|
+
* If op is not in opOptionList, clear it
|
|
29
|
+
*/
|
|
30
|
+
onClearOp?: () => void;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* If targetSchema updated, clear it
|
|
34
|
+
*/
|
|
35
|
+
onClearRight?: () => void;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @deprecated use ConditionProvider instead
|
|
21
39
|
* custom rule config
|
|
22
40
|
*/
|
|
23
41
|
ruleConfig?: {
|
|
@@ -26,26 +44,32 @@ interface HooksParams {
|
|
|
26
44
|
};
|
|
27
45
|
}
|
|
28
46
|
|
|
29
|
-
export function useCondition({
|
|
47
|
+
export function useCondition({
|
|
48
|
+
leftSchema,
|
|
49
|
+
operator,
|
|
50
|
+
onClearOp,
|
|
51
|
+
onClearRight,
|
|
52
|
+
ruleConfig,
|
|
53
|
+
}: HooksParams) {
|
|
30
54
|
const typeManager = useTypeManager();
|
|
31
55
|
const { rules: contextRules, ops: contextOps } = useConditionContext();
|
|
32
56
|
|
|
33
|
-
//
|
|
57
|
+
// Merge user rules and context rules
|
|
34
58
|
const userRules = useMemo(
|
|
35
59
|
() => ruleConfig?.rules || contextRules || {},
|
|
36
60
|
[contextRules, ruleConfig?.rules]
|
|
37
61
|
);
|
|
38
62
|
|
|
39
|
-
//
|
|
63
|
+
// Merge user operators and context operators
|
|
40
64
|
const allOps = useMemo(() => ruleConfig?.ops || contextOps || {}, [contextOps, ruleConfig?.ops]);
|
|
41
65
|
|
|
42
|
-
//
|
|
66
|
+
// Get type configuration
|
|
43
67
|
const config = useMemo(
|
|
44
68
|
() => (leftSchema ? typeManager.getTypeBySchema(leftSchema) : undefined),
|
|
45
69
|
[leftSchema, typeManager]
|
|
46
70
|
);
|
|
47
71
|
|
|
48
|
-
//
|
|
72
|
+
// Calculate rule
|
|
49
73
|
const rule = useMemo(() => {
|
|
50
74
|
if (!config) {
|
|
51
75
|
return undefined;
|
|
@@ -59,7 +83,7 @@ export function useCondition({ leftSchema, operator, ruleConfig }: HooksParams)
|
|
|
59
83
|
return config.conditionRule;
|
|
60
84
|
}, [userRules, leftSchema, config]);
|
|
61
85
|
|
|
62
|
-
//
|
|
86
|
+
// Calculate operator option list
|
|
63
87
|
const opOptionList = useMemo(
|
|
64
88
|
() =>
|
|
65
89
|
Object.keys(rule || {})
|
|
@@ -72,6 +96,16 @@ export function useCondition({ leftSchema, operator, ruleConfig }: HooksParams)
|
|
|
72
96
|
[rule, allOps]
|
|
73
97
|
);
|
|
74
98
|
|
|
99
|
+
// When op not in list, clear it
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
if (!operator || !rule) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (!opOptionList.find((item) => item.value === operator)) {
|
|
105
|
+
onClearOp?.();
|
|
106
|
+
}
|
|
107
|
+
}, [operator, opOptionList, onClearOp]);
|
|
108
|
+
|
|
75
109
|
// get target schema
|
|
76
110
|
const targetSchema = useMemo(() => {
|
|
77
111
|
const targetType: string | IJsonSchema | null = rule?.[operator || ''] || null;
|
|
@@ -87,6 +121,16 @@ export function useCondition({ leftSchema, operator, ruleConfig }: HooksParams)
|
|
|
87
121
|
return targetType;
|
|
88
122
|
}, [rule, operator]);
|
|
89
123
|
|
|
124
|
+
const prevTargetSchemaRef = useRef<IJsonSchema | undefined>(undefined);
|
|
125
|
+
|
|
126
|
+
// When type of target schema updated, clear it
|
|
127
|
+
useEffect(() => {
|
|
128
|
+
if (prevTargetSchemaRef.current?.type !== targetSchema?.type) {
|
|
129
|
+
onClearRight?.();
|
|
130
|
+
}
|
|
131
|
+
prevTargetSchemaRef.current = targetSchema;
|
|
132
|
+
}, [targetSchema, onClearRight]);
|
|
133
|
+
|
|
90
134
|
// get current operator config
|
|
91
135
|
const opConfig = useMemo(() => allOps[operator || ''], [operator, allOps]);
|
|
92
136
|
|
|
@@ -15,31 +15,23 @@ import { InjectDynamicValueInput } from '@/components/dynamic-value-input';
|
|
|
15
15
|
import { IConditionRule, ConditionOpConfigs, useCondition } from '@/components/condition-context';
|
|
16
16
|
|
|
17
17
|
import { ConditionRowValueType } from './types';
|
|
18
|
-
import
|
|
18
|
+
import './styles.css';
|
|
19
19
|
|
|
20
20
|
interface PropTypes {
|
|
21
21
|
value?: ConditionRowValueType;
|
|
22
22
|
onChange: (value?: ConditionRowValueType) => void;
|
|
23
23
|
style?: React.CSSProperties;
|
|
24
24
|
readonly?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated use ConditionContext instead to pass ruleConfig to multiple
|
|
27
|
+
*/
|
|
25
28
|
ruleConfig?: {
|
|
26
29
|
ops?: ConditionOpConfigs;
|
|
27
30
|
rules?: Record<string, IConditionRule>;
|
|
28
31
|
};
|
|
29
32
|
}
|
|
30
33
|
|
|
31
|
-
|
|
32
|
-
ops: {},
|
|
33
|
-
rules: {},
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export function ConditionRow({
|
|
37
|
-
style,
|
|
38
|
-
value,
|
|
39
|
-
onChange,
|
|
40
|
-
readonly,
|
|
41
|
-
ruleConfig = defaultRuleConfig,
|
|
42
|
-
}: PropTypes) {
|
|
34
|
+
export function ConditionRow({ style, value, onChange, readonly, ruleConfig }: PropTypes) {
|
|
43
35
|
const { left, operator, right } = value || {};
|
|
44
36
|
|
|
45
37
|
const available = useScopeAvailable();
|
|
@@ -57,6 +49,19 @@ export function ConditionRow({
|
|
|
57
49
|
const { rule, opConfig, opOptionList, targetSchema } = useCondition({
|
|
58
50
|
leftSchema,
|
|
59
51
|
operator,
|
|
52
|
+
ruleConfig,
|
|
53
|
+
onClearOp() {
|
|
54
|
+
onChange({
|
|
55
|
+
...value,
|
|
56
|
+
operator: undefined,
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
onClearRight() {
|
|
60
|
+
onChange({
|
|
61
|
+
...value,
|
|
62
|
+
right: undefined,
|
|
63
|
+
});
|
|
64
|
+
},
|
|
60
65
|
});
|
|
61
66
|
|
|
62
67
|
const renderOpSelect = () => (
|
|
@@ -81,10 +86,10 @@ export function ConditionRow({
|
|
|
81
86
|
);
|
|
82
87
|
|
|
83
88
|
return (
|
|
84
|
-
<
|
|
85
|
-
<
|
|
86
|
-
<
|
|
87
|
-
<
|
|
89
|
+
<div className="gedit-m-condition-row-container" style={style}>
|
|
90
|
+
<div className="gedit-m-condition-row-operator">{renderOpSelect()}</div>
|
|
91
|
+
<div className="gedit-m-condition-row-values">
|
|
92
|
+
<div className="gedit-m-condition-row-left">
|
|
88
93
|
<InjectVariableSelector
|
|
89
94
|
readonly={readonly}
|
|
90
95
|
style={{ width: '100%' }}
|
|
@@ -99,8 +104,8 @@ export function ConditionRow({
|
|
|
99
104
|
})
|
|
100
105
|
}
|
|
101
106
|
/>
|
|
102
|
-
</
|
|
103
|
-
<
|
|
107
|
+
</div>
|
|
108
|
+
<div className="gedit-m-condition-row-right">
|
|
104
109
|
{targetSchema ? (
|
|
105
110
|
<InjectDynamicValueInput
|
|
106
111
|
readonly={readonly || !rule}
|
|
@@ -116,9 +121,9 @@ export function ConditionRow({
|
|
|
116
121
|
value={opConfig?.rightDisplay || I18n.t('Empty')}
|
|
117
122
|
/>
|
|
118
123
|
)}
|
|
119
|
-
</
|
|
120
|
-
</
|
|
121
|
-
</
|
|
124
|
+
</div>
|
|
125
|
+
</div>
|
|
126
|
+
</div>
|
|
122
127
|
);
|
|
123
128
|
}
|
|
124
129
|
|
|
@@ -3,28 +3,28 @@
|
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export const UIContainer = styled.div`
|
|
6
|
+
.gedit-m-condition-row-container {
|
|
9
7
|
display: flex;
|
|
10
8
|
align-items: center;
|
|
11
9
|
gap: 4px;
|
|
12
|
-
|
|
10
|
+
}
|
|
13
11
|
|
|
14
|
-
|
|
12
|
+
.gedit-m-condition-row-operator {
|
|
13
|
+
}
|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
.gedit-m-condition-row-left {
|
|
17
16
|
width: 100%;
|
|
18
|
-
|
|
17
|
+
}
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
.gedit-m-condition-row-right {
|
|
21
20
|
width: 100%;
|
|
22
|
-
|
|
21
|
+
}
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
.gedit-m-condition-row-values {
|
|
25
24
|
flex-grow: 1;
|
|
26
25
|
display: flex;
|
|
27
26
|
flex-direction: column;
|
|
28
27
|
align-items: center;
|
|
29
28
|
gap: 4px;
|
|
30
|
-
|
|
29
|
+
overflow: hidden;
|
|
30
|
+
}
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
ASTMatch,
|
|
12
12
|
type BaseType,
|
|
13
13
|
type BaseVariableField,
|
|
14
|
-
|
|
14
|
+
useCurrentScope,
|
|
15
15
|
} from '@flowgram.ai/editor';
|
|
16
16
|
import {
|
|
17
17
|
Mention,
|
|
@@ -24,7 +24,8 @@ import { EditorAPI } from '@flowgram.ai/coze-editor/preset-prompt';
|
|
|
24
24
|
import { type TreeNodeData } from '@douyinfe/semi-ui/lib/es/tree';
|
|
25
25
|
import { Tree, Popover } from '@douyinfe/semi-ui';
|
|
26
26
|
|
|
27
|
-
import {
|
|
27
|
+
import { IInputsValues } from '@/shared/flow-value/types';
|
|
28
|
+
import { FlowValueUtils } from '@/shared';
|
|
28
29
|
|
|
29
30
|
type VariableField = BaseVariableField<{ icon?: string | JSX.Element; title?: string }>;
|
|
30
31
|
|
|
@@ -32,10 +33,10 @@ export function InputsPicker({
|
|
|
32
33
|
inputsValues,
|
|
33
34
|
onSelect,
|
|
34
35
|
}: {
|
|
35
|
-
inputsValues:
|
|
36
|
+
inputsValues: IInputsValues;
|
|
36
37
|
onSelect: (v: string) => void;
|
|
37
38
|
}) {
|
|
38
|
-
const
|
|
39
|
+
const scope = useCurrentScope();
|
|
39
40
|
|
|
40
41
|
const getArrayDrilldown = (type: ArrayType, depth = 1): { type: BaseType; depth: number } => {
|
|
41
42
|
if (ASTMatch.isArray(type.items)) {
|
|
@@ -89,7 +90,7 @@ export function InputsPicker({
|
|
|
89
90
|
|
|
90
91
|
if (FlowValueUtils.isFlowValue(value)) {
|
|
91
92
|
if (FlowValueUtils.isRef(value)) {
|
|
92
|
-
const variable = available
|
|
93
|
+
const variable = scope?.available?.getByKeyPath(value.content || []);
|
|
93
94
|
if (variable) {
|
|
94
95
|
return renderVariable(variable, keyPath);
|
|
95
96
|
}
|
|
@@ -130,7 +131,7 @@ export function InputsTree({
|
|
|
130
131
|
inputsValues,
|
|
131
132
|
triggerCharacters = DEFAULT_TRIGGER_CHARACTERS,
|
|
132
133
|
}: {
|
|
133
|
-
inputsValues:
|
|
134
|
+
inputsValues: IInputsValues;
|
|
134
135
|
triggerCharacters?: string[];
|
|
135
136
|
}) {
|
|
136
137
|
const [posKey, setPosKey] = useState('');
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
useCurrentScope,
|
|
15
15
|
} from '@flowgram.ai/editor';
|
|
16
16
|
import { useInjector } from '@flowgram.ai/coze-editor/react';
|
|
17
|
-
import { Popover } from '@douyinfe/semi-ui';
|
|
17
|
+
import { Popover, Tag } from '@douyinfe/semi-ui';
|
|
18
18
|
import { IconIssueStroked } from '@douyinfe/semi-icons';
|
|
19
19
|
import {
|
|
20
20
|
Decoration,
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
|
|
28
28
|
import { IPolyfillRoot, polyfillCreateRoot } from '@/shared';
|
|
29
29
|
|
|
30
|
-
import
|
|
30
|
+
import '../styles.css';
|
|
31
31
|
|
|
32
32
|
class VariableTagWidget extends WidgetType {
|
|
33
33
|
keyPath?: string[];
|
|
@@ -56,9 +56,10 @@ class VariableTagWidget extends WidgetType {
|
|
|
56
56
|
renderVariable(v?: BaseVariableField) {
|
|
57
57
|
if (!v) {
|
|
58
58
|
this.root.render(
|
|
59
|
-
<
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
<Tag className="gedit-m-coze-editor-tag" color="amber">
|
|
60
|
+
<IconIssueStroked style={{ marginRight: '4px' }} />
|
|
61
|
+
<span>Unknown</span>
|
|
62
|
+
</Tag>
|
|
62
63
|
);
|
|
63
64
|
return;
|
|
64
65
|
}
|
|
@@ -67,26 +68,30 @@ class VariableTagWidget extends WidgetType {
|
|
|
67
68
|
const isRoot = v === rootField;
|
|
68
69
|
|
|
69
70
|
const rootTitle = (
|
|
70
|
-
<
|
|
71
|
+
<span className="gedit-m-coze-editor-root-title">
|
|
71
72
|
{rootField.meta?.title ? `${rootField.meta.title} ${isRoot ? '' : '-'} ` : ''}
|
|
72
|
-
</
|
|
73
|
+
</span>
|
|
73
74
|
);
|
|
74
75
|
const rootIcon = this.renderIcon(rootField?.meta.icon);
|
|
75
76
|
|
|
76
77
|
this.root.render(
|
|
77
78
|
<Popover
|
|
78
79
|
content={
|
|
79
|
-
<
|
|
80
|
+
<div className="gedit-m-coze-editor-popover-content">
|
|
80
81
|
{rootIcon}
|
|
81
82
|
{rootTitle}
|
|
82
|
-
<
|
|
83
|
-
</
|
|
83
|
+
<span className="gedit-m-coze-editor-var-name">{v?.keyPath.slice(1).join('.')}</span>
|
|
84
|
+
</div>
|
|
84
85
|
}
|
|
85
86
|
>
|
|
86
|
-
<
|
|
87
|
+
<Tag
|
|
88
|
+
className="gedit-m-coze-editor-tag"
|
|
89
|
+
style={{ display: 'inline-flex', alignItems: 'center' }}
|
|
90
|
+
>
|
|
91
|
+
{rootIcon}
|
|
87
92
|
{rootTitle}
|
|
88
|
-
{!isRoot && <
|
|
89
|
-
</
|
|
93
|
+
{!isRoot && <span className="gedit-m-coze-editor-var-name">{v?.key}</span>}
|
|
94
|
+
</Tag>
|
|
90
95
|
</Popover>
|
|
91
96
|
);
|
|
92
97
|
}
|
|
@@ -133,7 +138,7 @@ class VariableTagWidget extends WidgetType {
|
|
|
133
138
|
export function VariableTagInject() {
|
|
134
139
|
const injector = useInjector();
|
|
135
140
|
|
|
136
|
-
const scope = useCurrentScope();
|
|
141
|
+
const scope = useCurrentScope({ strict: true });
|
|
137
142
|
|
|
138
143
|
// 基于 {{var}} 的正则进行匹配,匹配后进行自定义渲染
|
|
139
144
|
useLayoutEffect(() => {
|