@flowgram.ai/form-materials 0.4.13 → 0.4.14
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/code-editor/editor.js +54 -77
- package/dist/cjs/components/code-editor/index.js +10 -2
- package/dist/cjs/components/code-editor/language-features.js +119 -16
- package/dist/cjs/components/code-editor/theme/dark.js +120 -50
- package/dist/cjs/components/code-editor/theme/light.js +110 -61
- package/dist/cjs/components/condition-context/context.js +59 -0
- package/dist/cjs/components/condition-context/hooks/use-condition.js +97 -0
- package/dist/cjs/components/condition-context/index.js +47 -0
- package/dist/cjs/components/condition-context/op.js +117 -0
- package/dist/cjs/components/condition-row/index.js +43 -26
- package/dist/cjs/components/condition-row/types.js +1 -35
- package/dist/cjs/components/coze-editor-extensions/extensions/variable-tag.js +4 -3
- package/dist/cjs/components/coze-editor-extensions/extensions/variable-tree.js +3 -0
- package/dist/cjs/components/db-condition-row/index.js +59 -34
- package/dist/cjs/form-plugins/infer-inputs-plugin/index.js +30 -3
- package/dist/cjs/plugins/json-schema-preset/create-type-preset-plugin.js +1 -0
- package/dist/cjs/plugins/json-schema-preset/react.js +1 -0
- package/dist/cjs/plugins/json-schema-preset/type-definition/array.js +30 -1
- package/dist/cjs/plugins/json-schema-preset/type-definition/boolean.js +23 -0
- package/dist/cjs/plugins/json-schema-preset/type-definition/date-time.js +31 -2
- package/dist/cjs/plugins/json-schema-preset/type-definition/index.js +9 -1
- package/dist/cjs/plugins/json-schema-preset/type-definition/integer.js +34 -1
- package/dist/cjs/{components/code-editor/init-worker.js → plugins/json-schema-preset/type-definition/map.js} +21 -23
- package/dist/cjs/plugins/json-schema-preset/type-definition/number.js +34 -1
- package/dist/cjs/plugins/json-schema-preset/type-definition/object.js +6 -1
- package/dist/cjs/plugins/json-schema-preset/type-definition/string.js +30 -1
- package/dist/cjs/plugins/json-schema-preset/types.js +18 -0
- package/dist/cjs/shared/flow-value/utils.js +22 -8
- package/dist/esm/components/code-editor/editor.mjs +4 -9
- package/dist/esm/components/code-editor/index.mjs +5 -2
- package/dist/esm/components/code-editor/language-features.mjs +49 -13
- package/dist/esm/components/code-editor/theme/dark.mjs +117 -50
- package/dist/esm/components/code-editor/theme/light.mjs +108 -62
- package/dist/esm/components/condition-context/context.mjs +19 -0
- package/dist/esm/components/condition-context/hooks/use-condition.mjs +63 -0
- package/dist/esm/components/condition-context/index.mjs +4 -0
- package/dist/esm/components/condition-context/op.mjs +80 -0
- package/dist/esm/components/condition-row/index.mjs +45 -28
- package/dist/esm/components/condition-row/types.mjs +0 -18
- package/dist/esm/components/coze-editor-extensions/extensions/variable-tag.mjs +4 -3
- package/dist/esm/components/coze-editor-extensions/extensions/variable-tree.mjs +3 -0
- package/dist/esm/components/db-condition-row/index.mjs +59 -34
- package/dist/esm/form-plugins/infer-inputs-plugin/index.mjs +31 -4
- package/dist/esm/plugins/json-schema-preset/create-type-preset-plugin.mjs +2 -1
- package/dist/esm/plugins/json-schema-preset/react.mjs +2 -1
- package/dist/esm/plugins/json-schema-preset/type-definition/array.mjs +30 -1
- package/dist/esm/plugins/json-schema-preset/type-definition/boolean.mjs +23 -0
- package/dist/esm/plugins/json-schema-preset/type-definition/date-time.mjs +31 -2
- package/dist/esm/plugins/json-schema-preset/type-definition/index.mjs +7 -2
- package/dist/esm/plugins/json-schema-preset/type-definition/integer.mjs +34 -1
- package/dist/esm/plugins/json-schema-preset/type-definition/map.mjs +20 -0
- package/dist/esm/plugins/json-schema-preset/type-definition/number.mjs +34 -1
- package/dist/esm/plugins/json-schema-preset/type-definition/object.mjs +6 -1
- package/dist/esm/plugins/json-schema-preset/type-definition/string.mjs +30 -1
- package/dist/esm/plugins/json-schema-preset/types.mjs +0 -0
- package/dist/esm/shared/flow-value/utils.mjs +22 -8
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/components/code-editor/editor.d.ts +0 -2
- package/dist/types/components/code-editor/language-features.d.ts +4 -1
- package/dist/types/components/code-editor/theme/dark.d.ts +29 -0
- package/dist/types/components/code-editor/theme/light.d.ts +24 -0
- package/dist/types/components/condition-context/context.d.ts +14 -0
- package/dist/types/components/condition-context/hooks/use-condition.d.ts +29 -0
- package/dist/types/components/condition-context/index.d.ts +8 -0
- package/dist/types/components/condition-context/op.d.ts +22 -0
- package/dist/types/components/condition-context/types.d.ts +14 -0
- package/dist/types/components/condition-row/index.d.ts +4 -7
- package/dist/types/components/condition-row/types.d.ts +0 -24
- package/dist/types/components/db-condition-row/index.d.ts +4 -3
- package/dist/types/components/db-condition-row/types.d.ts +0 -8
- package/dist/types/form-plugins/infer-inputs-plugin/index.d.ts +4 -0
- package/dist/types/plugins/json-schema-preset/create-type-preset-plugin.d.ts +1 -1
- package/dist/types/plugins/json-schema-preset/index.d.ts +1 -1
- package/dist/types/plugins/json-schema-preset/react.d.ts +1 -1
- package/dist/types/plugins/json-schema-preset/type-definition/array.d.ts +1 -1
- package/dist/types/plugins/json-schema-preset/type-definition/boolean.d.ts +1 -1
- package/dist/types/plugins/json-schema-preset/type-definition/date-time.d.ts +1 -1
- package/dist/types/plugins/json-schema-preset/type-definition/index.d.ts +3 -1
- package/dist/types/plugins/json-schema-preset/type-definition/integer.d.ts +1 -1
- package/dist/types/plugins/json-schema-preset/type-definition/map.d.ts +6 -0
- package/dist/types/plugins/json-schema-preset/type-definition/number.d.ts +1 -1
- package/dist/types/plugins/json-schema-preset/type-definition/object.d.ts +1 -1
- package/dist/types/plugins/json-schema-preset/type-definition/string.d.ts +1 -1
- package/dist/types/plugins/json-schema-preset/{manager.d.ts → types.d.ts} +5 -0
- package/dist/types/shared/flow-value/utils.d.ts +3 -1
- package/package.json +7 -6
- package/src/components/code-editor/editor.tsx +7 -10
- package/src/components/code-editor/index.tsx +3 -1
- package/src/components/code-editor/language-features.ts +52 -14
- package/src/components/code-editor/theme/dark.ts +62 -77
- package/src/components/code-editor/theme/light.ts +60 -91
- package/src/components/condition-context/context.tsx +28 -0
- package/src/components/condition-context/hooks/use-condition.tsx +99 -0
- package/src/components/condition-context/index.tsx +14 -0
- package/src/components/condition-context/op.ts +86 -0
- package/src/components/condition-context/types.ts +22 -0
- package/src/components/condition-row/index.tsx +44 -22
- package/src/components/condition-row/types.ts +0 -30
- package/src/components/coze-editor-extensions/extensions/variable-tag.tsx +6 -3
- package/src/components/coze-editor-extensions/extensions/variable-tree.tsx +3 -0
- package/src/components/db-condition-row/index.tsx +76 -24
- package/src/components/db-condition-row/types.ts +0 -13
- package/src/form-plugins/infer-inputs-plugin/index.ts +62 -14
- package/src/plugins/json-schema-preset/create-type-preset-plugin.tsx +4 -2
- package/src/plugins/json-schema-preset/index.tsx +1 -1
- package/src/plugins/json-schema-preset/react.tsx +5 -2
- package/src/plugins/json-schema-preset/type-definition/array.tsx +10 -1
- package/src/plugins/json-schema-preset/type-definition/boolean.tsx +17 -1
- package/src/plugins/json-schema-preset/type-definition/date-time.tsx +21 -2
- package/src/plugins/json-schema-preset/type-definition/index.tsx +10 -1
- package/src/plugins/json-schema-preset/type-definition/integer.tsx +19 -1
- package/src/plugins/json-schema-preset/type-definition/map.tsx +31 -0
- package/src/plugins/json-schema-preset/type-definition/number.tsx +19 -1
- package/src/plugins/json-schema-preset/type-definition/object.tsx +6 -1
- package/src/plugins/json-schema-preset/type-definition/string.tsx +19 -1
- package/src/plugins/json-schema-preset/{manager.ts → types.ts} +7 -0
- package/src/shared/flow-value/utils.ts +22 -9
- package/dist/cjs/components/condition-row/constants.js +0 -165
- package/dist/cjs/components/condition-row/hooks/useOp.js +0 -78
- package/dist/cjs/components/condition-row/hooks/useRule.js +0 -68
- package/dist/cjs/components/db-condition-row/hooks/use-left.js +0 -86
- package/dist/cjs/components/db-condition-row/hooks/use-op.js +0 -79
- package/dist/esm/components/code-editor/init-worker.mjs +0 -19
- package/dist/esm/components/condition-row/constants.mjs +0 -128
- package/dist/esm/components/condition-row/hooks/useOp.mjs +0 -44
- package/dist/esm/components/condition-row/hooks/useRule.mjs +0 -34
- package/dist/esm/components/db-condition-row/hooks/use-left.mjs +0 -52
- package/dist/esm/components/db-condition-row/hooks/use-op.mjs +0 -45
- package/dist/types/components/code-editor/init-worker.d.ts +0 -5
- package/dist/types/components/condition-row/constants.d.ts +0 -7
- package/dist/types/components/condition-row/hooks/useOp.d.ts +0 -18
- package/dist/types/components/condition-row/hooks/useRule.d.ts +0 -9
- package/dist/types/components/db-condition-row/hooks/use-left.d.ts +0 -18
- package/dist/types/components/db-condition-row/hooks/use-op.d.ts +0 -18
- package/src/components/code-editor/init-worker.ts +0 -27
- package/src/components/condition-row/constants.ts +0 -134
- package/src/components/condition-row/hooks/useOp.tsx +0 -56
- package/src/components/condition-row/hooks/useRule.ts +0 -35
- package/src/components/db-condition-row/hooks/use-left.tsx +0 -66
- package/src/components/db-condition-row/hooks/use-op.tsx +0 -59
- /package/dist/cjs/{plugins/json-schema-preset/manager.js → components/condition-context/types.js} +0 -0
- /package/dist/esm/{plugins/json-schema-preset/manager.mjs → components/condition-context/types.mjs} +0 -0
|
@@ -6,28 +6,45 @@
|
|
|
6
6
|
import { createTheme, tags as t } from '@flowgram.ai/coze-editor/preset-code';
|
|
7
7
|
import { type Extension } from '@codemirror/state';
|
|
8
8
|
|
|
9
|
-
const colors = {
|
|
10
|
-
background: '#
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
export const colors = {
|
|
10
|
+
background: '#24292e',
|
|
11
|
+
foreground: '#d1d5da',
|
|
12
|
+
selection: '#3392FF44',
|
|
13
|
+
cursor: '#c8e1ff',
|
|
14
|
+
dropdownBackground: '#24292e',
|
|
15
|
+
dropdownBorder: '#1b1f23',
|
|
16
|
+
activeLine: '#4d566022',
|
|
17
|
+
matchingBracket: '#888892',
|
|
18
|
+
keyword: '#9197F1',
|
|
19
|
+
storage: '#f97583',
|
|
20
|
+
variable: '#ffab70',
|
|
21
|
+
variableName: '#D9DCFA',
|
|
22
|
+
parameter: '#e1e4e8',
|
|
23
|
+
function: '#FFCA66',
|
|
24
|
+
string: '#FF9878',
|
|
25
|
+
constant: '#79b8ff',
|
|
26
|
+
type: '#79b8ff',
|
|
27
|
+
class: '#b392f0',
|
|
28
|
+
number: '#2EC7D9',
|
|
29
|
+
comment: '#568B2A',
|
|
30
|
+
heading: '#79b8ff',
|
|
31
|
+
invalid: '#f97583',
|
|
32
|
+
regexp: '#9ecbff',
|
|
33
|
+
propertyName: '#9197F1',
|
|
34
|
+
separator: '#888892',
|
|
35
|
+
gutters: '#888892',
|
|
36
|
+
moduleKeyword: '#CC4FD4',
|
|
20
37
|
};
|
|
21
38
|
|
|
22
39
|
export const darkTheme: Extension = createTheme({
|
|
23
40
|
variant: 'dark',
|
|
24
41
|
settings: {
|
|
25
42
|
background: colors.background,
|
|
26
|
-
foreground:
|
|
27
|
-
caret:
|
|
28
|
-
selection:
|
|
43
|
+
foreground: colors.foreground,
|
|
44
|
+
caret: colors.cursor,
|
|
45
|
+
selection: colors.selection,
|
|
29
46
|
gutterBackground: colors.background,
|
|
30
|
-
gutterForeground:
|
|
47
|
+
gutterForeground: colors.foreground,
|
|
31
48
|
gutterBorderColor: 'transparent',
|
|
32
49
|
gutterBorderWidth: 0,
|
|
33
50
|
lineHighlight: '#21262D',
|
|
@@ -44,7 +61,8 @@ export const darkTheme: Extension = createTheme({
|
|
|
44
61
|
backgroundColor: '#21262D',
|
|
45
62
|
},
|
|
46
63
|
completionItemSelected: {
|
|
47
|
-
backgroundColor:
|
|
64
|
+
backgroundColor: colors.selection,
|
|
65
|
+
color: colors.foreground,
|
|
48
66
|
},
|
|
49
67
|
completionItemIcon: {
|
|
50
68
|
color: '#8B949E',
|
|
@@ -60,79 +78,46 @@ export const darkTheme: Extension = createTheme({
|
|
|
60
78
|
},
|
|
61
79
|
},
|
|
62
80
|
styles: [
|
|
63
|
-
|
|
81
|
+
{ tag: t.keyword, color: colors.keyword },
|
|
82
|
+
{ tag: t.variableName, color: colors.variableName },
|
|
64
83
|
{
|
|
65
|
-
tag: t.
|
|
66
|
-
color: colors.
|
|
84
|
+
tag: [t.name, t.deleted, t.character, t.macroName],
|
|
85
|
+
color: colors.variable,
|
|
67
86
|
},
|
|
87
|
+
{ tag: [t.propertyName], color: colors.propertyName },
|
|
68
88
|
{
|
|
69
|
-
tag: [t.
|
|
70
|
-
color: colors.key,
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
tag: [t.string],
|
|
89
|
+
tag: [t.processingInstruction, t.string, t.inserted, t.special(t.string)],
|
|
74
90
|
color: colors.string,
|
|
75
91
|
},
|
|
76
92
|
{
|
|
77
|
-
tag: [t.
|
|
78
|
-
color: colors.
|
|
93
|
+
tag: [t.function(t.variableName), t.function(t.propertyName), t.labelName],
|
|
94
|
+
color: colors.function,
|
|
79
95
|
},
|
|
80
96
|
{
|
|
81
|
-
tag: [t.
|
|
82
|
-
color: colors.
|
|
97
|
+
tag: [t.moduleKeyword, t.controlKeyword],
|
|
98
|
+
color: colors.moduleKeyword,
|
|
83
99
|
},
|
|
84
100
|
{
|
|
85
|
-
tag: [t.
|
|
86
|
-
color: colors.
|
|
101
|
+
tag: [t.color, t.constant(t.name), t.standard(t.name)],
|
|
102
|
+
color: colors.constant,
|
|
87
103
|
},
|
|
104
|
+
{ tag: t.definition(t.name), color: colors.variable },
|
|
105
|
+
{ tag: [t.className], color: colors.class },
|
|
88
106
|
{
|
|
89
|
-
tag: [t.
|
|
90
|
-
color: colors.
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
// js
|
|
94
|
-
{
|
|
95
|
-
tag: [t.definitionKeyword],
|
|
96
|
-
color: '#C084FC',
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
tag: [t.modifier],
|
|
100
|
-
color: '#C084FC',
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
tag: [t.controlKeyword],
|
|
104
|
-
color: '#C084FC',
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
tag: [t.operatorKeyword],
|
|
108
|
-
color: '#C084FC',
|
|
109
|
-
},
|
|
110
|
-
|
|
111
|
-
// markdown
|
|
112
|
-
{
|
|
113
|
-
tag: [t.heading],
|
|
114
|
-
color: '#7DD3FC',
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
tag: [t.processingInstruction],
|
|
118
|
-
color: '#7DD3FC',
|
|
119
|
-
},
|
|
120
|
-
|
|
121
|
-
// shell
|
|
122
|
-
// curl
|
|
123
|
-
{
|
|
124
|
-
tag: [t.standard(t.variableName)],
|
|
125
|
-
color: '#34D399',
|
|
126
|
-
},
|
|
127
|
-
// -X
|
|
128
|
-
{
|
|
129
|
-
tag: [t.attributeName],
|
|
130
|
-
color: '#FBBF24',
|
|
131
|
-
},
|
|
132
|
-
// url in string (includes quotes), e.g. "https://..."
|
|
133
|
-
{
|
|
134
|
-
tag: [t.special(t.string)],
|
|
135
|
-
color: '#7DD3FC',
|
|
107
|
+
tag: [t.number, t.changed, t.annotation, t.modifier, t.self, t.namespace],
|
|
108
|
+
color: colors.number,
|
|
136
109
|
},
|
|
110
|
+
{ tag: [t.typeName], color: colors.type, fontStyle: colors.type },
|
|
111
|
+
{ tag: [t.operatorKeyword], color: colors.keyword },
|
|
112
|
+
{ tag: [t.url, t.escape, t.regexp, t.link], color: colors.regexp },
|
|
113
|
+
{ tag: [t.meta, t.comment], color: colors.comment },
|
|
114
|
+
{ tag: t.strong, fontWeight: 'bold' },
|
|
115
|
+
{ tag: t.emphasis, fontStyle: 'italic' },
|
|
116
|
+
{ tag: t.link, textDecoration: 'underline' },
|
|
117
|
+
{ tag: t.heading, fontWeight: 'bold', color: colors.heading },
|
|
118
|
+
{ tag: [t.atom, t.bool, t.special(t.variableName)], color: colors.variable },
|
|
119
|
+
{ tag: t.invalid, color: colors.invalid },
|
|
120
|
+
{ tag: t.strikethrough, textDecoration: 'line-through' },
|
|
121
|
+
{ tag: t.separator, color: colors.separator },
|
|
137
122
|
],
|
|
138
123
|
});
|
|
@@ -6,45 +6,61 @@
|
|
|
6
6
|
import { createTheme, tags as t } from '@flowgram.ai/coze-editor/preset-code';
|
|
7
7
|
import { type Extension } from '@codemirror/state';
|
|
8
8
|
|
|
9
|
-
const colors = {
|
|
10
|
-
background: '#
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
export const colors = {
|
|
10
|
+
background: '#f4f5f5',
|
|
11
|
+
foreground: '#444d56',
|
|
12
|
+
selection: '#0366d625',
|
|
13
|
+
cursor: '#044289',
|
|
14
|
+
dropdownBackground: '#fff',
|
|
15
|
+
dropdownBorder: '#e1e4e8',
|
|
16
|
+
activeLine: '#c6c6c622',
|
|
17
|
+
matchingBracket: '#34d05840',
|
|
18
|
+
keyword: '#d73a49',
|
|
19
|
+
storage: '#d73a49',
|
|
20
|
+
variable: '#e36209',
|
|
21
|
+
parameter: '#24292e',
|
|
22
|
+
function: '#005cc5',
|
|
23
|
+
string: '#032f62',
|
|
24
|
+
constant: '#005cc5',
|
|
25
|
+
type: '#005cc5',
|
|
26
|
+
class: '#6f42c1',
|
|
27
|
+
number: '#005cc5',
|
|
28
|
+
comment: '#6a737d',
|
|
29
|
+
heading: '#005cc5',
|
|
30
|
+
invalid: '#cb2431',
|
|
31
|
+
regexp: '#032f62',
|
|
19
32
|
};
|
|
20
33
|
|
|
21
34
|
export const lightTheme: Extension = createTheme({
|
|
22
35
|
variant: 'light',
|
|
23
36
|
settings: {
|
|
24
|
-
background:
|
|
25
|
-
foreground:
|
|
26
|
-
caret:
|
|
27
|
-
selection:
|
|
28
|
-
gutterBackground:
|
|
29
|
-
gutterForeground:
|
|
37
|
+
background: colors.background,
|
|
38
|
+
foreground: colors.foreground,
|
|
39
|
+
caret: colors.cursor,
|
|
40
|
+
selection: colors.selection,
|
|
41
|
+
gutterBackground: colors.background,
|
|
42
|
+
gutterForeground: colors.foreground,
|
|
30
43
|
gutterBorderColor: 'transparent',
|
|
31
44
|
gutterBorderWidth: 0,
|
|
32
|
-
lineHighlight:
|
|
45
|
+
lineHighlight: colors.background,
|
|
33
46
|
bracketColors: ['#F59E0B', '#8B5CF6', '#06B6D4'],
|
|
34
47
|
tooltip: {
|
|
35
|
-
backgroundColor:
|
|
36
|
-
color:
|
|
37
|
-
border: '
|
|
38
|
-
boxShadow: '0
|
|
48
|
+
backgroundColor: colors.dropdownBackground,
|
|
49
|
+
color: colors.foreground,
|
|
50
|
+
border: 'none',
|
|
51
|
+
boxShadow: '0 0 1px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .1)!important',
|
|
52
|
+
maxWidth: '400px',
|
|
39
53
|
},
|
|
40
54
|
link: {
|
|
41
55
|
color: '#2563EB',
|
|
56
|
+
caret: colors.cursor,
|
|
42
57
|
},
|
|
43
58
|
completionItemHover: {
|
|
44
59
|
backgroundColor: '#F3F4F6',
|
|
45
60
|
},
|
|
46
61
|
completionItemSelected: {
|
|
47
|
-
backgroundColor:
|
|
62
|
+
backgroundColor: colors.selection,
|
|
63
|
+
color: colors.foreground,
|
|
48
64
|
},
|
|
49
65
|
completionItemIcon: {
|
|
50
66
|
color: '#4B5563',
|
|
@@ -60,84 +76,37 @@ export const lightTheme: Extension = createTheme({
|
|
|
60
76
|
},
|
|
61
77
|
},
|
|
62
78
|
styles: [
|
|
63
|
-
|
|
64
|
-
{
|
|
65
|
-
tag: t.comment,
|
|
66
|
-
color: colors.comment,
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
tag: [t.propertyName],
|
|
70
|
-
color: colors.key,
|
|
71
|
-
},
|
|
79
|
+
{ tag: t.keyword, color: colors.keyword },
|
|
72
80
|
{
|
|
73
|
-
tag: [t.
|
|
81
|
+
tag: [t.name, t.deleted, t.character, t.macroName],
|
|
74
82
|
color: colors.variable,
|
|
75
83
|
},
|
|
76
|
-
|
|
84
|
+
{ tag: [t.propertyName], color: colors.function },
|
|
77
85
|
{
|
|
78
|
-
tag: [t.string],
|
|
86
|
+
tag: [t.processingInstruction, t.string, t.inserted, t.special(t.string)],
|
|
79
87
|
color: colors.string,
|
|
80
88
|
},
|
|
89
|
+
{ tag: [t.function(t.variableName), t.labelName], color: colors.function },
|
|
81
90
|
{
|
|
82
|
-
tag: [t.
|
|
83
|
-
color: colors.
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
tag: [t.bool],
|
|
87
|
-
color: colors.boolean,
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
tag: [t.null],
|
|
91
|
-
color: colors.null,
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
tag: [t.separator],
|
|
95
|
-
color: colors.separator,
|
|
96
|
-
},
|
|
97
|
-
|
|
98
|
-
// markdown
|
|
99
|
-
{
|
|
100
|
-
tag: [t.heading],
|
|
101
|
-
color: '#2563EB',
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
tag: [t.processingInstruction],
|
|
105
|
-
color: '#2563EB',
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
// js
|
|
109
|
-
{
|
|
110
|
-
tag: [t.definitionKeyword],
|
|
111
|
-
color: '#9333EA',
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
tag: [t.modifier],
|
|
115
|
-
color: '#9333EA',
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
tag: [t.controlKeyword],
|
|
119
|
-
color: '#9333EA',
|
|
91
|
+
tag: [t.color, t.constant(t.name), t.standard(t.name)],
|
|
92
|
+
color: colors.constant,
|
|
120
93
|
},
|
|
94
|
+
{ tag: [t.definition(t.name), t.separator], color: colors.variable },
|
|
95
|
+
{ tag: [t.className], color: colors.class },
|
|
121
96
|
{
|
|
122
|
-
tag: [t.
|
|
123
|
-
color:
|
|
124
|
-
},
|
|
125
|
-
|
|
126
|
-
// shell
|
|
127
|
-
// curl
|
|
128
|
-
{
|
|
129
|
-
tag: [t.standard(t.variableName)],
|
|
130
|
-
color: '#059669',
|
|
131
|
-
},
|
|
132
|
-
// -X
|
|
133
|
-
{
|
|
134
|
-
tag: [t.attributeName],
|
|
135
|
-
color: '#EA580C',
|
|
136
|
-
},
|
|
137
|
-
// url in string (includes quotes), e.g. "https://..."
|
|
138
|
-
{
|
|
139
|
-
tag: [t.special(t.string)],
|
|
140
|
-
color: '#2563EB',
|
|
97
|
+
tag: [t.number, t.changed, t.annotation, t.modifier, t.self, t.namespace],
|
|
98
|
+
color: colors.number,
|
|
141
99
|
},
|
|
100
|
+
{ tag: [t.typeName], color: colors.type, fontStyle: colors.type },
|
|
101
|
+
{ tag: [t.operator, t.operatorKeyword], color: colors.keyword },
|
|
102
|
+
{ tag: [t.url, t.escape, t.regexp, t.link], color: colors.regexp },
|
|
103
|
+
{ tag: [t.meta, t.comment], color: colors.comment },
|
|
104
|
+
{ tag: t.strong, fontWeight: 'bold' },
|
|
105
|
+
{ tag: t.emphasis, fontStyle: 'italic' },
|
|
106
|
+
{ tag: t.link, textDecoration: 'underline' },
|
|
107
|
+
{ tag: t.heading, fontWeight: 'bold', color: colors.heading },
|
|
108
|
+
{ tag: [t.atom, t.bool, t.special(t.variableName)], color: colors.variable },
|
|
109
|
+
{ tag: t.invalid, color: colors.invalid },
|
|
110
|
+
{ tag: t.strikethrough, textDecoration: 'line-through' },
|
|
142
111
|
],
|
|
143
112
|
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import React, { createContext, useContext } from 'react';
|
|
7
|
+
|
|
8
|
+
import { IConditionRule, ConditionOpConfigs } from './types';
|
|
9
|
+
import { defaultConditionOpConfigs } from './op';
|
|
10
|
+
|
|
11
|
+
interface ContextType {
|
|
12
|
+
rules?: Record<string, IConditionRule>;
|
|
13
|
+
ops?: ConditionOpConfigs;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const ConditionContext = createContext<ContextType>({
|
|
17
|
+
rules: {},
|
|
18
|
+
ops: defaultConditionOpConfigs,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export const ConditionProvider = (props: React.PropsWithChildren<ContextType>) => {
|
|
22
|
+
const { rules, ops } = props;
|
|
23
|
+
return (
|
|
24
|
+
<ConditionContext.Provider value={{ rules, ops }}>{props.children}</ConditionContext.Provider>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const useConditionContext = () => useContext(ConditionContext);
|
|
@@ -0,0 +1,99 @@
|
|
|
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 { IJsonSchema } from '@flowgram.ai/json-schema';
|
|
9
|
+
import { I18n } from '@flowgram.ai/editor';
|
|
10
|
+
|
|
11
|
+
import { useTypeManager } from '@/plugins';
|
|
12
|
+
|
|
13
|
+
import { IConditionRule, ConditionOpConfigs } from '../types';
|
|
14
|
+
import { useConditionContext } from '../context';
|
|
15
|
+
|
|
16
|
+
interface HooksParams {
|
|
17
|
+
leftSchema?: IJsonSchema;
|
|
18
|
+
operator?: string;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* custom rule config
|
|
22
|
+
*/
|
|
23
|
+
ruleConfig?: {
|
|
24
|
+
ops?: ConditionOpConfigs;
|
|
25
|
+
rules?: Record<string, IConditionRule>;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function useCondition({ leftSchema, operator, ruleConfig }: HooksParams) {
|
|
30
|
+
const typeManager = useTypeManager();
|
|
31
|
+
const { rules: contextRules, ops: contextOps } = useConditionContext();
|
|
32
|
+
|
|
33
|
+
// 合并用户规则和上下文规则
|
|
34
|
+
const userRules = useMemo(
|
|
35
|
+
() => ruleConfig?.rules || contextRules || {},
|
|
36
|
+
[contextRules, ruleConfig?.rules]
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
// 合并用户操作符和上下文操作符
|
|
40
|
+
const allOps = useMemo(() => ruleConfig?.ops || contextOps || {}, [contextOps, ruleConfig?.ops]);
|
|
41
|
+
|
|
42
|
+
// 获取类型配置
|
|
43
|
+
const config = useMemo(
|
|
44
|
+
() => (leftSchema ? typeManager.getTypeBySchema(leftSchema) : undefined),
|
|
45
|
+
[leftSchema, typeManager]
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
// 计算规则
|
|
49
|
+
const rule = useMemo(() => {
|
|
50
|
+
if (!config) {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
if (userRules[config.type]) {
|
|
54
|
+
return userRules[config.type];
|
|
55
|
+
}
|
|
56
|
+
if (typeof config.conditionRule === 'function') {
|
|
57
|
+
return config.conditionRule(leftSchema);
|
|
58
|
+
}
|
|
59
|
+
return config.conditionRule;
|
|
60
|
+
}, [userRules, leftSchema, config]);
|
|
61
|
+
|
|
62
|
+
// 计算操作符选项列表
|
|
63
|
+
const opOptionList = useMemo(
|
|
64
|
+
() =>
|
|
65
|
+
Object.keys(rule || {})
|
|
66
|
+
.filter((_op) => allOps[_op])
|
|
67
|
+
.map((_op) => ({
|
|
68
|
+
...(allOps?.[_op] || {}),
|
|
69
|
+
value: _op,
|
|
70
|
+
label: I18n.t(allOps?.[_op]?.label || _op),
|
|
71
|
+
})),
|
|
72
|
+
[rule, allOps]
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
// get target schema
|
|
76
|
+
const targetSchema = useMemo(() => {
|
|
77
|
+
const targetType: string | IJsonSchema | null = rule?.[operator || ''] || null;
|
|
78
|
+
|
|
79
|
+
if (!targetType) {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (typeof targetType === 'string') {
|
|
84
|
+
return { type: targetType, extra: { weak: true } };
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return targetType;
|
|
88
|
+
}, [rule, operator]);
|
|
89
|
+
|
|
90
|
+
// get current operator config
|
|
91
|
+
const opConfig = useMemo(() => allOps[operator || ''], [operator, allOps]);
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
rule,
|
|
95
|
+
opConfig,
|
|
96
|
+
opOptionList,
|
|
97
|
+
targetSchema,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export {
|
|
7
|
+
type IConditionRule,
|
|
8
|
+
type IConditionRuleFactory,
|
|
9
|
+
type ConditionOpConfigs,
|
|
10
|
+
type ConditionOpConfig,
|
|
11
|
+
} from './types';
|
|
12
|
+
export { ConditionPresetOp } from './op';
|
|
13
|
+
export { ConditionProvider, useConditionContext } from './context';
|
|
14
|
+
export { useCondition } from './hooks/use-condition';
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { ConditionOpConfigs } from './types';
|
|
7
|
+
|
|
8
|
+
export enum ConditionPresetOp {
|
|
9
|
+
EQ = 'eq',
|
|
10
|
+
NEQ = 'neq',
|
|
11
|
+
GT = 'gt',
|
|
12
|
+
GTE = 'gte',
|
|
13
|
+
LT = 'lt',
|
|
14
|
+
LTE = 'lte',
|
|
15
|
+
IN = 'in',
|
|
16
|
+
NIN = 'nin',
|
|
17
|
+
CONTAINS = 'contains',
|
|
18
|
+
NOT_CONTAINS = 'not_contains',
|
|
19
|
+
IS_EMPTY = 'is_empty',
|
|
20
|
+
IS_NOT_EMPTY = 'is_not_empty',
|
|
21
|
+
IS_TRUE = 'is_true',
|
|
22
|
+
IS_FALSE = 'is_false',
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const defaultConditionOpConfigs: ConditionOpConfigs = {
|
|
26
|
+
[ConditionPresetOp.EQ]: {
|
|
27
|
+
label: 'Equal',
|
|
28
|
+
abbreviation: '=',
|
|
29
|
+
},
|
|
30
|
+
[ConditionPresetOp.NEQ]: {
|
|
31
|
+
label: 'Not Equal',
|
|
32
|
+
abbreviation: '≠',
|
|
33
|
+
},
|
|
34
|
+
[ConditionPresetOp.GT]: {
|
|
35
|
+
label: 'Greater Than',
|
|
36
|
+
abbreviation: '>',
|
|
37
|
+
},
|
|
38
|
+
[ConditionPresetOp.GTE]: {
|
|
39
|
+
label: 'Greater Than or Equal',
|
|
40
|
+
abbreviation: '>=',
|
|
41
|
+
},
|
|
42
|
+
[ConditionPresetOp.LT]: {
|
|
43
|
+
label: 'Less Than',
|
|
44
|
+
abbreviation: '<',
|
|
45
|
+
},
|
|
46
|
+
[ConditionPresetOp.LTE]: {
|
|
47
|
+
label: 'Less Than or Equal',
|
|
48
|
+
abbreviation: '<=',
|
|
49
|
+
},
|
|
50
|
+
[ConditionPresetOp.IN]: {
|
|
51
|
+
label: 'In',
|
|
52
|
+
abbreviation: '∈',
|
|
53
|
+
},
|
|
54
|
+
[ConditionPresetOp.NIN]: {
|
|
55
|
+
label: 'Not In',
|
|
56
|
+
abbreviation: '∉',
|
|
57
|
+
},
|
|
58
|
+
[ConditionPresetOp.CONTAINS]: {
|
|
59
|
+
label: 'Contains',
|
|
60
|
+
abbreviation: '⊇',
|
|
61
|
+
},
|
|
62
|
+
[ConditionPresetOp.NOT_CONTAINS]: {
|
|
63
|
+
label: 'Not Contains',
|
|
64
|
+
abbreviation: '⊉',
|
|
65
|
+
},
|
|
66
|
+
[ConditionPresetOp.IS_EMPTY]: {
|
|
67
|
+
label: 'Is Empty',
|
|
68
|
+
abbreviation: '=',
|
|
69
|
+
rightDisplay: 'Empty',
|
|
70
|
+
},
|
|
71
|
+
[ConditionPresetOp.IS_NOT_EMPTY]: {
|
|
72
|
+
label: 'Is Not Empty',
|
|
73
|
+
abbreviation: '≠',
|
|
74
|
+
rightDisplay: 'Empty',
|
|
75
|
+
},
|
|
76
|
+
[ConditionPresetOp.IS_TRUE]: {
|
|
77
|
+
label: 'Is True',
|
|
78
|
+
abbreviation: '=',
|
|
79
|
+
rightDisplay: 'True',
|
|
80
|
+
},
|
|
81
|
+
[ConditionPresetOp.IS_FALSE]: {
|
|
82
|
+
label: 'Is False',
|
|
83
|
+
abbreviation: '=',
|
|
84
|
+
rightDisplay: 'False',
|
|
85
|
+
},
|
|
86
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { type IJsonSchema } from '@flowgram.ai/json-schema';
|
|
7
|
+
|
|
8
|
+
export interface ConditionOpConfig {
|
|
9
|
+
label: string;
|
|
10
|
+
abbreviation: string;
|
|
11
|
+
// When right is not a value, display this text
|
|
12
|
+
rightDisplay?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type OpKey = string;
|
|
16
|
+
|
|
17
|
+
export type ConditionOpConfigs = Record<OpKey, ConditionOpConfig>;
|
|
18
|
+
|
|
19
|
+
export type IConditionRule = Record<OpKey, string | IJsonSchema | null>;
|
|
20
|
+
export type IConditionRuleFactory = (
|
|
21
|
+
schema?: IJsonSchema
|
|
22
|
+
) => Record<OpKey, string | IJsonSchema | null>;
|