@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
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { Op } from "./types.mjs";
|
|
2
|
-
const defaultRules = {
|
|
3
|
-
string: {
|
|
4
|
-
[Op.EQ]: 'string',
|
|
5
|
-
[Op.NEQ]: 'string',
|
|
6
|
-
[Op.CONTAINS]: 'string',
|
|
7
|
-
[Op.NOT_CONTAINS]: 'string',
|
|
8
|
-
[Op.IN]: 'array',
|
|
9
|
-
[Op.NIN]: 'array',
|
|
10
|
-
[Op.IS_EMPTY]: null,
|
|
11
|
-
[Op.IS_NOT_EMPTY]: null
|
|
12
|
-
},
|
|
13
|
-
number: {
|
|
14
|
-
[Op.EQ]: 'number',
|
|
15
|
-
[Op.NEQ]: 'number',
|
|
16
|
-
[Op.GT]: 'number',
|
|
17
|
-
[Op.GTE]: 'number',
|
|
18
|
-
[Op.LT]: 'number',
|
|
19
|
-
[Op.LTE]: 'number',
|
|
20
|
-
[Op.IN]: 'array',
|
|
21
|
-
[Op.NIN]: 'array'
|
|
22
|
-
},
|
|
23
|
-
integer: {
|
|
24
|
-
[Op.EQ]: 'number',
|
|
25
|
-
[Op.NEQ]: 'number',
|
|
26
|
-
[Op.GT]: 'number',
|
|
27
|
-
[Op.GTE]: 'number',
|
|
28
|
-
[Op.LT]: 'number',
|
|
29
|
-
[Op.LTE]: 'number',
|
|
30
|
-
[Op.IN]: 'array',
|
|
31
|
-
[Op.NIN]: 'array'
|
|
32
|
-
},
|
|
33
|
-
boolean: {
|
|
34
|
-
[Op.EQ]: 'boolean',
|
|
35
|
-
[Op.NEQ]: 'boolean',
|
|
36
|
-
[Op.IS_TRUE]: null,
|
|
37
|
-
[Op.IS_FALSE]: null,
|
|
38
|
-
[Op.IN]: 'array',
|
|
39
|
-
[Op.NIN]: 'array'
|
|
40
|
-
},
|
|
41
|
-
object: {
|
|
42
|
-
[Op.IS_EMPTY]: null,
|
|
43
|
-
[Op.IS_NOT_EMPTY]: null
|
|
44
|
-
},
|
|
45
|
-
array: {
|
|
46
|
-
[Op.IS_EMPTY]: null,
|
|
47
|
-
[Op.IS_NOT_EMPTY]: null,
|
|
48
|
-
[Op.CONTAINS]: 'array',
|
|
49
|
-
[Op.NOT_CONTAINS]: 'array',
|
|
50
|
-
[Op.EQ]: 'array',
|
|
51
|
-
[Op.NEQ]: 'array'
|
|
52
|
-
},
|
|
53
|
-
map: {
|
|
54
|
-
[Op.IS_EMPTY]: null,
|
|
55
|
-
[Op.IS_NOT_EMPTY]: null
|
|
56
|
-
},
|
|
57
|
-
['date-time']: {
|
|
58
|
-
[Op.EQ]: 'date-time',
|
|
59
|
-
[Op.NEQ]: 'date-time',
|
|
60
|
-
[Op.GT]: 'date-time',
|
|
61
|
-
[Op.GTE]: 'date-time',
|
|
62
|
-
[Op.LT]: 'date-time',
|
|
63
|
-
[Op.LTE]: 'date-time'
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
const defaultOpConfigs = {
|
|
67
|
-
[Op.EQ]: {
|
|
68
|
-
label: 'Equal',
|
|
69
|
-
abbreviation: '='
|
|
70
|
-
},
|
|
71
|
-
[Op.NEQ]: {
|
|
72
|
-
label: 'Not Equal',
|
|
73
|
-
abbreviation: "\u2260"
|
|
74
|
-
},
|
|
75
|
-
[Op.GT]: {
|
|
76
|
-
label: 'Greater Than',
|
|
77
|
-
abbreviation: '>'
|
|
78
|
-
},
|
|
79
|
-
[Op.GTE]: {
|
|
80
|
-
label: 'Greater Than or Equal',
|
|
81
|
-
abbreviation: '>='
|
|
82
|
-
},
|
|
83
|
-
[Op.LT]: {
|
|
84
|
-
label: 'Less Than',
|
|
85
|
-
abbreviation: '<'
|
|
86
|
-
},
|
|
87
|
-
[Op.LTE]: {
|
|
88
|
-
label: 'Less Than or Equal',
|
|
89
|
-
abbreviation: '<='
|
|
90
|
-
},
|
|
91
|
-
[Op.IN]: {
|
|
92
|
-
label: 'In',
|
|
93
|
-
abbreviation: "\u2208"
|
|
94
|
-
},
|
|
95
|
-
[Op.NIN]: {
|
|
96
|
-
label: 'Not In',
|
|
97
|
-
abbreviation: "\u2209"
|
|
98
|
-
},
|
|
99
|
-
[Op.CONTAINS]: {
|
|
100
|
-
label: 'Contains',
|
|
101
|
-
abbreviation: "\u2287"
|
|
102
|
-
},
|
|
103
|
-
[Op.NOT_CONTAINS]: {
|
|
104
|
-
label: 'Not Contains',
|
|
105
|
-
abbreviation: "\u2289"
|
|
106
|
-
},
|
|
107
|
-
[Op.IS_EMPTY]: {
|
|
108
|
-
label: 'Is Empty',
|
|
109
|
-
abbreviation: '=',
|
|
110
|
-
rightDisplay: 'Empty'
|
|
111
|
-
},
|
|
112
|
-
[Op.IS_NOT_EMPTY]: {
|
|
113
|
-
label: 'Is Not Empty',
|
|
114
|
-
abbreviation: "\u2260",
|
|
115
|
-
rightDisplay: 'Empty'
|
|
116
|
-
},
|
|
117
|
-
[Op.IS_TRUE]: {
|
|
118
|
-
label: 'Is True',
|
|
119
|
-
abbreviation: '=',
|
|
120
|
-
rightDisplay: 'True'
|
|
121
|
-
},
|
|
122
|
-
[Op.IS_FALSE]: {
|
|
123
|
-
label: 'Is False',
|
|
124
|
-
abbreviation: '=',
|
|
125
|
-
rightDisplay: 'False'
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
export { defaultOpConfigs, defaultRules };
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo } from "react";
|
|
3
|
-
import { I18n } from "@flowgram.ai/editor";
|
|
4
|
-
import { Button, Select } from "@douyinfe/semi-ui";
|
|
5
|
-
import { IconChevronDownStroked } from "@douyinfe/semi-icons";
|
|
6
|
-
import { defaultOpConfigs } from "../constants.mjs";
|
|
7
|
-
function useOp({ rule, op, onChange, readonly, userOps }) {
|
|
8
|
-
const options = useMemo(()=>Object.keys(rule || {}).map((_op)=>({
|
|
9
|
-
...defaultOpConfigs[_op] || {},
|
|
10
|
-
...userOps?.[_op] || {},
|
|
11
|
-
value: _op,
|
|
12
|
-
label: I18n.t(userOps?.[_op]?.label || defaultOpConfigs[_op]?.label)
|
|
13
|
-
})), [
|
|
14
|
-
rule,
|
|
15
|
-
userOps
|
|
16
|
-
]);
|
|
17
|
-
const opConfig = useMemo(()=>defaultOpConfigs[op], [
|
|
18
|
-
op
|
|
19
|
-
]);
|
|
20
|
-
const renderOpSelect = ()=>/*#__PURE__*/ jsx(Select, {
|
|
21
|
-
style: {
|
|
22
|
-
height: 22
|
|
23
|
-
},
|
|
24
|
-
disabled: readonly,
|
|
25
|
-
size: "small",
|
|
26
|
-
value: op,
|
|
27
|
-
optionList: options,
|
|
28
|
-
onChange: (v)=>{
|
|
29
|
-
onChange(v);
|
|
30
|
-
},
|
|
31
|
-
triggerRender: ({ value })=>/*#__PURE__*/ jsx(Button, {
|
|
32
|
-
size: "small",
|
|
33
|
-
disabled: !rule,
|
|
34
|
-
children: opConfig?.abbreviation || /*#__PURE__*/ jsx(IconChevronDownStroked, {
|
|
35
|
-
size: "small"
|
|
36
|
-
})
|
|
37
|
-
})
|
|
38
|
-
});
|
|
39
|
-
return {
|
|
40
|
-
renderOpSelect,
|
|
41
|
-
opConfig
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
export { useOp };
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { useMemo } from "react";
|
|
2
|
-
import { JsonSchemaUtils } from "@flowgram.ai/json-schema";
|
|
3
|
-
import { useScopeAvailable } from "@flowgram.ai/editor";
|
|
4
|
-
import { defaultRules } from "../constants.mjs";
|
|
5
|
-
function useRule(left, userRules) {
|
|
6
|
-
const available = useScopeAvailable();
|
|
7
|
-
const rules = useMemo(()=>({
|
|
8
|
-
...defaultRules,
|
|
9
|
-
...userRules || {}
|
|
10
|
-
}), [
|
|
11
|
-
userRules
|
|
12
|
-
]);
|
|
13
|
-
const variable = useMemo(()=>{
|
|
14
|
-
if (!left) return;
|
|
15
|
-
return available.getByKeyPath(left.content);
|
|
16
|
-
}, [
|
|
17
|
-
available,
|
|
18
|
-
left
|
|
19
|
-
]);
|
|
20
|
-
const rule = useMemo(()=>{
|
|
21
|
-
if (!variable) return;
|
|
22
|
-
const schema = JsonSchemaUtils.astToSchema(variable.type, {
|
|
23
|
-
drilldown: false
|
|
24
|
-
});
|
|
25
|
-
return rules[schema?.type];
|
|
26
|
-
}, [
|
|
27
|
-
variable?.type,
|
|
28
|
-
rules
|
|
29
|
-
]);
|
|
30
|
-
return {
|
|
31
|
-
rule
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
export { useRule };
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo } from "react";
|
|
3
|
-
import { useTypeManager } from "@flowgram.ai/json-schema";
|
|
4
|
-
import { Icon } from "@douyinfe/semi-ui";
|
|
5
|
-
import { ConditionRow } from "../../index.mjs";
|
|
6
|
-
import { UIOptionLabel, UISelect } from "../styles.mjs";
|
|
7
|
-
const defaultRules = ConditionRow.defaultRules;
|
|
8
|
-
function useLeft({ left, options, userRules, readonly, onChange }) {
|
|
9
|
-
const rules = useMemo(()=>({
|
|
10
|
-
...defaultRules,
|
|
11
|
-
...userRules || {}
|
|
12
|
-
}), [
|
|
13
|
-
userRules
|
|
14
|
-
]);
|
|
15
|
-
const typeManager = useTypeManager();
|
|
16
|
-
const rule = useMemo(()=>{
|
|
17
|
-
if (!left) return;
|
|
18
|
-
const option = options?.find((item)=>item.value === left);
|
|
19
|
-
if (!option?.schema?.type) return;
|
|
20
|
-
return rules[option.schema.type];
|
|
21
|
-
}, [
|
|
22
|
-
left,
|
|
23
|
-
options,
|
|
24
|
-
rules
|
|
25
|
-
]);
|
|
26
|
-
const renderDBOptionSelect = ()=>/*#__PURE__*/ jsx(UISelect, {
|
|
27
|
-
disabled: readonly,
|
|
28
|
-
size: "small",
|
|
29
|
-
style: {
|
|
30
|
-
width: '100%'
|
|
31
|
-
},
|
|
32
|
-
value: left,
|
|
33
|
-
onChange: (v)=>onChange(v),
|
|
34
|
-
optionList: options?.map((item)=>({
|
|
35
|
-
label: /*#__PURE__*/ jsxs(UIOptionLabel, {
|
|
36
|
-
children: [
|
|
37
|
-
/*#__PURE__*/ jsx(Icon, {
|
|
38
|
-
size: "small",
|
|
39
|
-
svg: typeManager.getDisplayIcon(item.schema)
|
|
40
|
-
}),
|
|
41
|
-
item.label
|
|
42
|
-
]
|
|
43
|
-
}),
|
|
44
|
-
value: item.value
|
|
45
|
-
})) || []
|
|
46
|
-
});
|
|
47
|
-
return {
|
|
48
|
-
rule,
|
|
49
|
-
renderDBOptionSelect
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
export { useLeft };
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo } from "react";
|
|
3
|
-
import { I18n } from "@flowgram.ai/editor";
|
|
4
|
-
import { Button, Select } from "@douyinfe/semi-ui";
|
|
5
|
-
import { IconChevronDownStroked } from "@douyinfe/semi-icons";
|
|
6
|
-
import { ConditionRow } from "../../index.mjs";
|
|
7
|
-
const defaultOpConfigs = ConditionRow.defaultOpConfigs;
|
|
8
|
-
function useOp({ rule, op, onChange, readonly, userOps }) {
|
|
9
|
-
const options = useMemo(()=>Object.keys(rule || {}).map((_op)=>({
|
|
10
|
-
...defaultOpConfigs[_op] || {},
|
|
11
|
-
...userOps?.[_op] || {},
|
|
12
|
-
value: _op,
|
|
13
|
-
label: I18n.t(userOps?.[_op]?.label || defaultOpConfigs[_op]?.label)
|
|
14
|
-
})), [
|
|
15
|
-
rule,
|
|
16
|
-
userOps
|
|
17
|
-
]);
|
|
18
|
-
const opConfig = useMemo(()=>defaultOpConfigs[op], [
|
|
19
|
-
op
|
|
20
|
-
]);
|
|
21
|
-
const renderOpSelect = ()=>/*#__PURE__*/ jsx(Select, {
|
|
22
|
-
style: {
|
|
23
|
-
height: 22
|
|
24
|
-
},
|
|
25
|
-
disabled: readonly,
|
|
26
|
-
size: "small",
|
|
27
|
-
value: op,
|
|
28
|
-
optionList: options,
|
|
29
|
-
onChange: (v)=>{
|
|
30
|
-
onChange(v);
|
|
31
|
-
},
|
|
32
|
-
triggerRender: ({ value })=>/*#__PURE__*/ jsx(Button, {
|
|
33
|
-
size: "small",
|
|
34
|
-
disabled: !rule,
|
|
35
|
-
children: opConfig?.abbreviation || /*#__PURE__*/ jsx(IconChevronDownStroked, {
|
|
36
|
-
size: "small"
|
|
37
|
-
})
|
|
38
|
-
})
|
|
39
|
-
});
|
|
40
|
-
return {
|
|
41
|
-
renderOpSelect,
|
|
42
|
-
opConfig
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
export { useOp };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
-
* SPDX-License-Identifier: MIT
|
|
4
|
-
*/
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import { IRule, OpConfigs } from '../types';
|
|
7
|
-
interface HookParams {
|
|
8
|
-
rule?: IRule;
|
|
9
|
-
op?: string;
|
|
10
|
-
onChange: (op: string) => void;
|
|
11
|
-
readonly?: boolean;
|
|
12
|
-
userOps?: OpConfigs;
|
|
13
|
-
}
|
|
14
|
-
export declare function useOp({ rule, op, onChange, readonly, userOps }: HookParams): {
|
|
15
|
-
renderOpSelect: () => React.JSX.Element;
|
|
16
|
-
opConfig: import("../types").OpConfig;
|
|
17
|
-
};
|
|
18
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
-
* SPDX-License-Identifier: MIT
|
|
4
|
-
*/
|
|
5
|
-
import { IFlowRefValue } from '../../../shared';
|
|
6
|
-
import { IRules } from '../types';
|
|
7
|
-
export declare function useRule(left?: IFlowRefValue, userRules?: IRules): {
|
|
8
|
-
rule: Partial<Record<string, string | null>> | undefined;
|
|
9
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
-
* SPDX-License-Identifier: MIT
|
|
4
|
-
*/
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import { DBConditionOptionType, IRules } from '../types';
|
|
7
|
-
interface HookParams {
|
|
8
|
-
left?: string;
|
|
9
|
-
options?: DBConditionOptionType[];
|
|
10
|
-
userRules?: IRules;
|
|
11
|
-
readonly?: boolean;
|
|
12
|
-
onChange: (leftKey: string) => void;
|
|
13
|
-
}
|
|
14
|
-
export declare function useLeft({ left, options, userRules, readonly, onChange }: HookParams): {
|
|
15
|
-
rule: Partial<Record<string, string | null>> | undefined;
|
|
16
|
-
renderDBOptionSelect: () => React.JSX.Element;
|
|
17
|
-
};
|
|
18
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
-
* SPDX-License-Identifier: MIT
|
|
4
|
-
*/
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import { IRule, OpConfigs } from '../types';
|
|
7
|
-
interface HookParams {
|
|
8
|
-
rule?: IRule;
|
|
9
|
-
op?: string;
|
|
10
|
-
onChange: (op: string) => void;
|
|
11
|
-
readonly?: boolean;
|
|
12
|
-
userOps?: OpConfigs;
|
|
13
|
-
}
|
|
14
|
-
export declare function useOp({ rule, op, onChange, readonly, userOps }: HookParams): {
|
|
15
|
-
renderOpSelect: () => React.JSX.Element;
|
|
16
|
-
opConfig: import("../../condition-row/types").OpConfig;
|
|
17
|
-
};
|
|
18
|
-
export {};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
-
* SPDX-License-Identifier: MIT
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { typescript } from '@flowgram.ai/coze-editor/language-typescript';
|
|
7
|
-
|
|
8
|
-
let tsWorkerInit = false;
|
|
9
|
-
|
|
10
|
-
export const initTsWorker = () => {
|
|
11
|
-
if (tsWorkerInit) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
tsWorkerInit = true;
|
|
15
|
-
|
|
16
|
-
const tsWorker = new Worker(
|
|
17
|
-
new URL(`@flowgram.ai/coze-editor/language-typescript/worker`, import.meta.url),
|
|
18
|
-
{ type: 'module' }
|
|
19
|
-
);
|
|
20
|
-
typescript.languageService.initialize(tsWorker, {
|
|
21
|
-
compilerOptions: {
|
|
22
|
-
// eliminate Promise error
|
|
23
|
-
lib: ['es2015', 'dom'],
|
|
24
|
-
noImplicitAny: false,
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
};
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
-
* SPDX-License-Identifier: MIT
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { IRules, Op, OpConfigs } from './types';
|
|
7
|
-
|
|
8
|
-
export const defaultRules: IRules = {
|
|
9
|
-
string: {
|
|
10
|
-
[Op.EQ]: 'string',
|
|
11
|
-
[Op.NEQ]: 'string',
|
|
12
|
-
[Op.CONTAINS]: 'string',
|
|
13
|
-
[Op.NOT_CONTAINS]: 'string',
|
|
14
|
-
[Op.IN]: 'array',
|
|
15
|
-
[Op.NIN]: 'array',
|
|
16
|
-
[Op.IS_EMPTY]: null,
|
|
17
|
-
[Op.IS_NOT_EMPTY]: null,
|
|
18
|
-
},
|
|
19
|
-
number: {
|
|
20
|
-
[Op.EQ]: 'number',
|
|
21
|
-
[Op.NEQ]: 'number',
|
|
22
|
-
[Op.GT]: 'number',
|
|
23
|
-
[Op.GTE]: 'number',
|
|
24
|
-
[Op.LT]: 'number',
|
|
25
|
-
[Op.LTE]: 'number',
|
|
26
|
-
[Op.IN]: 'array',
|
|
27
|
-
[Op.NIN]: 'array',
|
|
28
|
-
},
|
|
29
|
-
integer: {
|
|
30
|
-
[Op.EQ]: 'number',
|
|
31
|
-
[Op.NEQ]: 'number',
|
|
32
|
-
[Op.GT]: 'number',
|
|
33
|
-
[Op.GTE]: 'number',
|
|
34
|
-
[Op.LT]: 'number',
|
|
35
|
-
[Op.LTE]: 'number',
|
|
36
|
-
[Op.IN]: 'array',
|
|
37
|
-
[Op.NIN]: 'array',
|
|
38
|
-
},
|
|
39
|
-
boolean: {
|
|
40
|
-
[Op.EQ]: 'boolean',
|
|
41
|
-
[Op.NEQ]: 'boolean',
|
|
42
|
-
[Op.IS_TRUE]: null,
|
|
43
|
-
[Op.IS_FALSE]: null,
|
|
44
|
-
[Op.IN]: 'array',
|
|
45
|
-
[Op.NIN]: 'array',
|
|
46
|
-
},
|
|
47
|
-
object: {
|
|
48
|
-
[Op.IS_EMPTY]: null,
|
|
49
|
-
[Op.IS_NOT_EMPTY]: null,
|
|
50
|
-
},
|
|
51
|
-
array: {
|
|
52
|
-
[Op.IS_EMPTY]: null,
|
|
53
|
-
[Op.IS_NOT_EMPTY]: null,
|
|
54
|
-
[Op.CONTAINS]: 'array',
|
|
55
|
-
[Op.NOT_CONTAINS]: 'array',
|
|
56
|
-
[Op.EQ]: 'array',
|
|
57
|
-
[Op.NEQ]: 'array',
|
|
58
|
-
},
|
|
59
|
-
map: {
|
|
60
|
-
[Op.IS_EMPTY]: null,
|
|
61
|
-
[Op.IS_NOT_EMPTY]: null,
|
|
62
|
-
},
|
|
63
|
-
['date-time']: {
|
|
64
|
-
[Op.EQ]: 'date-time',
|
|
65
|
-
[Op.NEQ]: 'date-time',
|
|
66
|
-
[Op.GT]: 'date-time',
|
|
67
|
-
[Op.GTE]: 'date-time',
|
|
68
|
-
[Op.LT]: 'date-time',
|
|
69
|
-
[Op.LTE]: 'date-time',
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
export const defaultOpConfigs: OpConfigs = {
|
|
74
|
-
[Op.EQ]: {
|
|
75
|
-
label: 'Equal',
|
|
76
|
-
abbreviation: '=',
|
|
77
|
-
},
|
|
78
|
-
[Op.NEQ]: {
|
|
79
|
-
label: 'Not Equal',
|
|
80
|
-
abbreviation: '≠',
|
|
81
|
-
},
|
|
82
|
-
[Op.GT]: {
|
|
83
|
-
label: 'Greater Than',
|
|
84
|
-
abbreviation: '>',
|
|
85
|
-
},
|
|
86
|
-
[Op.GTE]: {
|
|
87
|
-
label: 'Greater Than or Equal',
|
|
88
|
-
abbreviation: '>=',
|
|
89
|
-
},
|
|
90
|
-
[Op.LT]: {
|
|
91
|
-
label: 'Less Than',
|
|
92
|
-
abbreviation: '<',
|
|
93
|
-
},
|
|
94
|
-
[Op.LTE]: {
|
|
95
|
-
label: 'Less Than or Equal',
|
|
96
|
-
abbreviation: '<=',
|
|
97
|
-
},
|
|
98
|
-
[Op.IN]: {
|
|
99
|
-
label: 'In',
|
|
100
|
-
abbreviation: '∈',
|
|
101
|
-
},
|
|
102
|
-
[Op.NIN]: {
|
|
103
|
-
label: 'Not In',
|
|
104
|
-
abbreviation: '∉',
|
|
105
|
-
},
|
|
106
|
-
[Op.CONTAINS]: {
|
|
107
|
-
label: 'Contains',
|
|
108
|
-
abbreviation: '⊇',
|
|
109
|
-
},
|
|
110
|
-
[Op.NOT_CONTAINS]: {
|
|
111
|
-
label: 'Not Contains',
|
|
112
|
-
abbreviation: '⊉',
|
|
113
|
-
},
|
|
114
|
-
[Op.IS_EMPTY]: {
|
|
115
|
-
label: 'Is Empty',
|
|
116
|
-
abbreviation: '=',
|
|
117
|
-
rightDisplay: 'Empty',
|
|
118
|
-
},
|
|
119
|
-
[Op.IS_NOT_EMPTY]: {
|
|
120
|
-
label: 'Is Not Empty',
|
|
121
|
-
abbreviation: '≠',
|
|
122
|
-
rightDisplay: 'Empty',
|
|
123
|
-
},
|
|
124
|
-
[Op.IS_TRUE]: {
|
|
125
|
-
label: 'Is True',
|
|
126
|
-
abbreviation: '=',
|
|
127
|
-
rightDisplay: 'True',
|
|
128
|
-
},
|
|
129
|
-
[Op.IS_FALSE]: {
|
|
130
|
-
label: 'Is False',
|
|
131
|
-
abbreviation: '=',
|
|
132
|
-
rightDisplay: 'False',
|
|
133
|
-
},
|
|
134
|
-
};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
-
* SPDX-License-Identifier: MIT
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import React, { useMemo } from 'react';
|
|
7
|
-
|
|
8
|
-
import { I18n } from '@flowgram.ai/editor';
|
|
9
|
-
import { Button, Select } from '@douyinfe/semi-ui';
|
|
10
|
-
import { IconChevronDownStroked } from '@douyinfe/semi-icons';
|
|
11
|
-
|
|
12
|
-
import { IRule, OpConfigs } from '../types';
|
|
13
|
-
import { defaultOpConfigs } from '../constants';
|
|
14
|
-
|
|
15
|
-
interface HookParams {
|
|
16
|
-
rule?: IRule;
|
|
17
|
-
op?: string;
|
|
18
|
-
onChange: (op: string) => void;
|
|
19
|
-
readonly?: boolean;
|
|
20
|
-
userOps?: OpConfigs;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function useOp({ rule, op, onChange, readonly, userOps }: HookParams) {
|
|
24
|
-
const options = useMemo(
|
|
25
|
-
() =>
|
|
26
|
-
Object.keys(rule || {}).map((_op) => ({
|
|
27
|
-
...(defaultOpConfigs[_op] || {}),
|
|
28
|
-
...(userOps?.[_op] || {}),
|
|
29
|
-
value: _op,
|
|
30
|
-
label: I18n.t(userOps?.[_op]?.label || defaultOpConfigs[_op]?.label),
|
|
31
|
-
})),
|
|
32
|
-
[rule, userOps]
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
const opConfig = useMemo(() => defaultOpConfigs[op as string], [op]);
|
|
36
|
-
|
|
37
|
-
const renderOpSelect = () => (
|
|
38
|
-
<Select
|
|
39
|
-
style={{ height: 22 }}
|
|
40
|
-
disabled={readonly}
|
|
41
|
-
size="small"
|
|
42
|
-
value={op}
|
|
43
|
-
optionList={options}
|
|
44
|
-
onChange={(v) => {
|
|
45
|
-
onChange(v as string);
|
|
46
|
-
}}
|
|
47
|
-
triggerRender={({ value }) => (
|
|
48
|
-
<Button size="small" disabled={!rule}>
|
|
49
|
-
{opConfig?.abbreviation || <IconChevronDownStroked size="small" />}
|
|
50
|
-
</Button>
|
|
51
|
-
)}
|
|
52
|
-
/>
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
return { renderOpSelect, opConfig };
|
|
56
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
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 { JsonSchemaUtils, JsonSchemaBasicType } from '@flowgram.ai/json-schema';
|
|
9
|
-
import { useScopeAvailable } from '@flowgram.ai/editor';
|
|
10
|
-
|
|
11
|
-
import { IFlowRefValue } from '@/shared';
|
|
12
|
-
|
|
13
|
-
import { IRules } from '../types';
|
|
14
|
-
import { defaultRules } from '../constants';
|
|
15
|
-
|
|
16
|
-
export function useRule(left?: IFlowRefValue, userRules?: IRules) {
|
|
17
|
-
const available = useScopeAvailable();
|
|
18
|
-
|
|
19
|
-
const rules = useMemo(() => ({ ...defaultRules, ...(userRules || {}) }), [userRules]);
|
|
20
|
-
|
|
21
|
-
const variable = useMemo(() => {
|
|
22
|
-
if (!left) return undefined;
|
|
23
|
-
return available.getByKeyPath(left.content);
|
|
24
|
-
}, [available, left]);
|
|
25
|
-
|
|
26
|
-
const rule = useMemo(() => {
|
|
27
|
-
if (!variable) return undefined;
|
|
28
|
-
|
|
29
|
-
const schema = JsonSchemaUtils.astToSchema(variable.type, { drilldown: false });
|
|
30
|
-
|
|
31
|
-
return rules[schema?.type as JsonSchemaBasicType];
|
|
32
|
-
}, [variable?.type, rules]);
|
|
33
|
-
|
|
34
|
-
return { rule };
|
|
35
|
-
}
|