@coding-flow/flow-design 0.0.11 → 0.0.13

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.
Files changed (22) hide show
  1. package/dist/components/design-editor/components/branch-adder/index.js +3 -1
  2. package/dist/components/design-editor/components/node-icon/index.js +6 -0
  3. package/dist/components/design-editor/nodes/condition-else-branch/form-meta.d.ts +4 -0
  4. package/dist/components/design-editor/nodes/condition-else-branch/form-meta.js +37 -0
  5. package/dist/components/design-editor/nodes/condition-else-branch/index.d.ts +2 -0
  6. package/dist/components/design-editor/nodes/condition-else-branch/index.js +31 -0
  7. package/dist/components/design-editor/nodes/inclusive-else-branch/form-meta.d.ts +4 -0
  8. package/dist/components/design-editor/nodes/inclusive-else-branch/form-meta.js +37 -0
  9. package/dist/components/design-editor/nodes/inclusive-else-branch/index.d.ts +2 -0
  10. package/dist/components/design-editor/nodes/inclusive-else-branch/index.js +20 -0
  11. package/dist/components/design-editor/nodes/index.js +4 -0
  12. package/dist/components/design-panel/presenters/index.js +1 -1
  13. package/dist/script-components/components/condition/components/condition-group/condition.d.ts +1 -0
  14. package/dist/script-components/components/condition/components/condition-group/condition.js +5 -0
  15. package/dist/script-components/components/condition/components/condition-group/group.js +14 -3
  16. package/dist/script-components/components/condition/components/condition-group/type.js +2 -1
  17. package/dist/script-components/components/condition/convertor/groovy.js +21 -7
  18. package/dist/script-components/components/condition/convertor/group.js +11 -3
  19. package/dist/script-components/components/condition/presenters/group-presenter.js +19 -4
  20. package/dist/script-components/components/condition/typings/index.d.ts +2 -2
  21. package/dist/script-components/components/condition/typings/index.js +4 -0
  22. package/package.json +7 -7
@@ -17,7 +17,9 @@ const BranchAdderRender = (props)=>{
17
17
  const presenter = context.getPresenter();
18
18
  const handleAddBranch = ()=>{
19
19
  presenter.createNode(node.id, props.addType).then((block)=>{
20
- operation.addBlock(node, block);
20
+ operation.addBlock(node, block, {
21
+ index: block.data.order - 1
22
+ });
21
23
  setTimeout(()=>{
22
24
  handleClose();
23
25
  }, 10);
@@ -21,6 +21,9 @@ const NodeIcon = (props)=>{
21
21
  if ('CONDITION_BRANCH' === icon) return /*#__PURE__*/ jsx(BranchesOutlined, {
22
22
  style: style
23
23
  });
24
+ if ('CONDITION_ELSE_BRANCH' === icon) return /*#__PURE__*/ jsx(BranchesOutlined, {
25
+ style: style
26
+ });
24
27
  if ('DELAY' === icon) return /*#__PURE__*/ jsx(ClockCircleOutlined, {
25
28
  style: style
26
29
  });
@@ -42,6 +45,9 @@ const NodeIcon = (props)=>{
42
45
  if ('INCLUSIVE_BRANCH' === icon) return /*#__PURE__*/ jsx(MergeOutlined, {
43
46
  style: style
44
47
  });
48
+ if ('INCLUSIVE_ELSE_BRANCH' === icon) return /*#__PURE__*/ jsx(MergeOutlined, {
49
+ style: style
50
+ });
45
51
  if ('NOTIFY' === icon) return /*#__PURE__*/ jsx(BellOutlined, {
46
52
  style: style
47
53
  });
@@ -0,0 +1,4 @@
1
+ import { FormMeta, FormRenderProps } from '@flowgram.ai/fixed-layout-editor';
2
+ import { FlowNodeJSON } from '../../typings';
3
+ export declare const renderForm: (data: FormRenderProps<FlowNodeJSON["data"]>) => import("react/jsx-runtime").JSX.Element;
4
+ export declare const formMeta: FormMeta<FlowNodeJSON['data']>;
@@ -0,0 +1,37 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { provideJsonSchemaOutputs, syncVariableTitle } from "@flowgram.ai/form-materials";
3
+ import { ValidateTrigger } from "@flowgram.ai/fixed-layout-editor";
4
+ import { NodePanel } from "../../node-components/panel/index.js";
5
+ import "react";
6
+ import { NodeIcon } from "../../components/node-icon/index.js";
7
+ import { Space } from "antd";
8
+ const renderForm = (data)=>/*#__PURE__*/ jsx(NodePanel, {
9
+ data: data,
10
+ children: /*#__PURE__*/ jsxs(Space, {
11
+ style: {
12
+ width: 100,
13
+ textAlign: 'center',
14
+ padding: 5
15
+ },
16
+ children: [
17
+ /*#__PURE__*/ jsx(NodeIcon, {
18
+ type: "CONDITION_ELSE_BRANCH"
19
+ }),
20
+ /*#__PURE__*/ jsx("span", {
21
+ children: "其他情况"
22
+ })
23
+ ]
24
+ })
25
+ });
26
+ const formMeta = {
27
+ render: renderForm,
28
+ validateTrigger: ValidateTrigger.onChange,
29
+ validate: {
30
+ title: ({ value })=>value ? void 0 : 'Title is required'
31
+ },
32
+ effect: {
33
+ title: syncVariableTitle,
34
+ outputs: provideJsonSchemaOutputs
35
+ }
36
+ };
37
+ export { formMeta, renderForm };
@@ -0,0 +1,2 @@
1
+ import { FlowNodeRegistry } from '../../typings';
2
+ export declare const ConditionElseBranchNodeRegistry: FlowNodeRegistry;
@@ -0,0 +1,31 @@
1
+ import { formMeta } from "./form-meta.js";
2
+ import { nanoid } from "nanoid";
3
+ const ConditionElseBranchNodeRegistry = {
4
+ type: 'CONDITION_ELSE_BRANCH',
5
+ extend: 'block',
6
+ meta: {
7
+ copyDisable: true,
8
+ addDisable: true,
9
+ deleteDisable: true,
10
+ sidebarDisable: true,
11
+ style: {
12
+ width: '100%'
13
+ }
14
+ },
15
+ info: {
16
+ icon: 'CONDITION_ELSE_BRANCH',
17
+ description: '分支else节点'
18
+ },
19
+ formMeta: formMeta,
20
+ onAdd (ctx, from) {
21
+ return {
22
+ id: `condition_branch_${nanoid(5)}`,
23
+ type: 'CONDITION_ELSE_BRANCH',
24
+ data: {
25
+ title: "条件else分支节点",
26
+ value: 'branch Value'
27
+ }
28
+ };
29
+ }
30
+ };
31
+ export { ConditionElseBranchNodeRegistry };
@@ -0,0 +1,4 @@
1
+ import { FormMeta, FormRenderProps } from '@flowgram.ai/fixed-layout-editor';
2
+ import { FlowNodeJSON } from '../../typings';
3
+ export declare const renderForm: (data: FormRenderProps<FlowNodeJSON["data"]>) => import("react/jsx-runtime").JSX.Element;
4
+ export declare const formMeta: FormMeta<FlowNodeJSON['data']>;
@@ -0,0 +1,37 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { provideJsonSchemaOutputs, syncVariableTitle } from "@flowgram.ai/form-materials";
3
+ import { ValidateTrigger } from "@flowgram.ai/fixed-layout-editor";
4
+ import { NodePanel } from "../../node-components/panel/index.js";
5
+ import "react";
6
+ import { NodeIcon } from "../../components/node-icon/index.js";
7
+ import { Space } from "antd";
8
+ const renderForm = (data)=>/*#__PURE__*/ jsx(NodePanel, {
9
+ data: data,
10
+ children: /*#__PURE__*/ jsxs(Space, {
11
+ style: {
12
+ width: 100,
13
+ textAlign: 'center',
14
+ padding: 5
15
+ },
16
+ children: [
17
+ /*#__PURE__*/ jsx(NodeIcon, {
18
+ type: "INCLUSIVE_ELSE_BRANCH"
19
+ }),
20
+ /*#__PURE__*/ jsx("span", {
21
+ children: "其他情况"
22
+ })
23
+ ]
24
+ })
25
+ });
26
+ const formMeta = {
27
+ render: renderForm,
28
+ validateTrigger: ValidateTrigger.onChange,
29
+ validate: {
30
+ title: ({ value })=>value ? void 0 : 'Title is required'
31
+ },
32
+ effect: {
33
+ title: syncVariableTitle,
34
+ outputs: provideJsonSchemaOutputs
35
+ }
36
+ };
37
+ export { formMeta, renderForm };
@@ -0,0 +1,2 @@
1
+ import { FlowNodeRegistry } from '../../typings';
2
+ export declare const InclusiveElseBranchNodeRegistry: FlowNodeRegistry;
@@ -0,0 +1,20 @@
1
+ import { formMeta } from "./form-meta.js";
2
+ const InclusiveElseBranchNodeRegistry = {
3
+ type: 'INCLUSIVE_ELSE_BRANCH',
4
+ extend: 'block',
5
+ meta: {
6
+ copyDisable: true,
7
+ addDisable: true,
8
+ sidebarDisable: true,
9
+ deleteDisable: true,
10
+ style: {
11
+ width: '100%'
12
+ }
13
+ },
14
+ info: {
15
+ icon: 'INCLUSIVE_ELSE_BRANCH',
16
+ description: '包容else分支'
17
+ },
18
+ formMeta: formMeta
19
+ };
20
+ export { InclusiveElseBranchNodeRegistry };
@@ -15,15 +15,19 @@ import { SubProcessNodeRegistry } from "./sub-process/index.js";
15
15
  import { TriggerNodeRegistry } from "./trigger/index.js";
16
16
  import { ManualNodeRegistry } from "./manual/index.js";
17
17
  import { ManualBranchNodeRegistry } from "./manual-branch/index.js";
18
+ import { ConditionElseBranchNodeRegistry } from "./condition-else-branch/index.js";
19
+ import { InclusiveElseBranchNodeRegistry } from "./inclusive-else-branch/index.js";
18
20
  const FlowNodeRegistries = [
19
21
  ApprovalNodeRegistry,
20
22
  ConditionNodeRegistry,
21
23
  ConditionBranchNodeRegistry,
24
+ ConditionElseBranchNodeRegistry,
22
25
  DelayNodeRegistry,
23
26
  EndNodeRegistry,
24
27
  HandleNodeRegistry,
25
28
  InclusiveNodeRegistry,
26
29
  InclusiveBranchNodeRegistry,
30
+ InclusiveElseBranchNodeRegistry,
27
31
  ManualNodeRegistry,
28
32
  ManualBranchNodeRegistry,
29
33
  NotifyNodeRegistry,
@@ -120,7 +120,7 @@ class Presenter {
120
120
  const block = nodeManager.toItemRender(flowNode);
121
121
  if (currentNode) {
122
122
  if (currentNode.blocks) {
123
- const order = currentNode.blocks.length + 1;
123
+ const order = currentNode.blocks.length;
124
124
  return {
125
125
  ...block,
126
126
  data: {
@@ -4,6 +4,7 @@ interface ConditionItemViewProps {
4
4
  data?: Condition;
5
5
  id: string;
6
6
  location: 'left' | 'right';
7
+ disabled?: boolean;
7
8
  }
8
9
  export declare const ConditionItemView: React.FC<ConditionItemViewProps>;
9
10
  export {};
@@ -32,6 +32,7 @@ const VariableSelect = (props)=>{
32
32
  });
33
33
  };
34
34
  return /*#__PURE__*/ jsx(Select, {
35
+ disabled: props.disabled,
35
36
  showSearch: {
36
37
  filterOption: (value, option)=>{
37
38
  if (option.value) return option.value.includes(value) || option.label.includes(value);
@@ -57,6 +58,7 @@ const TypeInput = (props)=>{
57
58
  });
58
59
  };
59
60
  return /*#__PURE__*/ jsx(Input, {
61
+ disabled: props.disabled,
60
62
  style: {
61
63
  width: "200px"
62
64
  },
@@ -90,6 +92,7 @@ const ConditionItemView = (props)=>{
90
92
  width: "100px"
91
93
  },
92
94
  value: type,
95
+ disabled: props.disabled,
93
96
  options: [
94
97
  {
95
98
  label: '选择变量',
@@ -105,12 +108,14 @@ const ConditionItemView = (props)=>{
105
108
  }
106
109
  }),
107
110
  "variable" === type && /*#__PURE__*/ jsx(VariableSelect, {
111
+ disabled: props.disabled,
108
112
  value: props.data?.value || '',
109
113
  onChange: (value)=>{
110
114
  handleUpdate(value);
111
115
  }
112
116
  }),
113
117
  "input" === type && /*#__PURE__*/ jsx(TypeInput, {
118
+ disabled: props.disabled,
114
119
  value: props.data?.value || '',
115
120
  onChange: (value)=>{
116
121
  handleUpdate(value);
@@ -55,18 +55,29 @@ const Group = ()=>{
55
55
  key: 'right',
56
56
  title: '右侧参数',
57
57
  dataIndex: 'right',
58
- render: (_, record)=>/*#__PURE__*/ jsx(ConditionItemView, {
58
+ render: (_, record)=>{
59
+ if (false !== record.right) return /*#__PURE__*/ jsx(ConditionItemView, {
59
60
  id: record.id,
60
61
  location: 'right',
61
62
  data: record.right
62
- })
63
+ });
64
+ return /*#__PURE__*/ jsx("div", {
65
+ style: {
66
+ width: "100px"
67
+ },
68
+ children: "无"
69
+ });
70
+ }
63
71
  },
64
72
  {
65
73
  key: 'option',
66
74
  title: '操作',
67
75
  render: (text, record)=>/*#__PURE__*/ jsxs(Space, {
76
+ style: {
77
+ width: '100px'
78
+ },
68
79
  children: [
69
- /*#__PURE__*/ jsx("a", {
80
+ 'is_null' != record.type && /*#__PURE__*/ jsx("a", {
70
81
  onClick: ()=>{
71
82
  presenter.switchCondition(record.id);
72
83
  },
@@ -8,7 +8,8 @@ const ConditionTypeView = (props)=>{
8
8
  const { context } = useConditionContext();
9
9
  const presenter = context.getPresenter().getConditionGroupPresenter();
10
10
  const handleChangeType = (value)=>{
11
- presenter.updateType(props.id, value);
11
+ const relationType = value;
12
+ presenter.updateType(props.id, relationType);
12
13
  };
13
14
  return /*#__PURE__*/ jsx(Select, {
14
15
  placeholder: "请选择关系",
@@ -43,8 +43,9 @@ class ConditionReturnConvertor {
43
43
  if (conditionGroup.left) {
44
44
  if ('variable' === conditionGroup.left.type) return conditionGroup.left.dataType;
45
45
  }
46
- if (conditionGroup.right) {
47
- if ('variable' === conditionGroup.right.type) return conditionGroup.right.dataType;
46
+ if (false !== conditionGroup.right && conditionGroup.right) {
47
+ const right = conditionGroup.right;
48
+ if ('variable' === right.type) return right.dataType;
48
49
  }
49
50
  return 'STRING';
50
51
  }
@@ -70,11 +71,24 @@ class ConditionReturnConvertor {
70
71
  const left = conditionGroup.left;
71
72
  const right = conditionGroup.right;
72
73
  const type = conditionGroup.type;
73
- if (left && right && type) {
74
- const leftExpression = this.getConditionExpression(left, dataType);
75
- const rightExpression = this.getConditionExpression(right, dataType);
76
- const typeExpression = this.getConditionTypeExpression(type);
77
- return leftExpression + typeExpression + rightExpression;
74
+ if (type) {
75
+ if ('is_null' === type) {
76
+ if (left) {
77
+ const leftExpression = this.getConditionExpression(left, dataType);
78
+ if ('STRING' === dataType) return `(${leftExpression} == '' || ${leftExpression} == null)`;
79
+ if ('LONG' === dataType) return `${leftExpression} == 0`;
80
+ if ('INTEGER' === dataType) return `${leftExpression} == 0`;
81
+ if ('DOUBLE' === dataType) return `${leftExpression} == 0`;
82
+ if ('BOOLEAN' === dataType) return `${leftExpression} == false`;
83
+ return `${leftExpression} == null`;
84
+ }
85
+ }
86
+ if (left && right && type) {
87
+ const leftExpression = this.getConditionExpression(left, dataType);
88
+ const rightExpression = this.getConditionExpression(right, dataType);
89
+ const typeExpression = this.getConditionTypeExpression(type);
90
+ return leftExpression + typeExpression + rightExpression;
91
+ }
78
92
  }
79
93
  }
80
94
  return '';
@@ -8,9 +8,17 @@ class GroupConvertor {
8
8
  const left = this.group.left;
9
9
  const right = this.group.right;
10
10
  const type = this.group.type;
11
- if (left && right && type) {
12
- const relation = relationTypeOptions.find((relationTypeOption)=>relationTypeOption.value === type);
13
- return `${left.label} ${relation?.label} ${right.label}`;
11
+ if (type) {
12
+ if ('is_null' === type) {
13
+ if (left) {
14
+ const relation = relationTypeOptions.find((relationTypeOption)=>relationTypeOption.value === type);
15
+ return `${left.label} ${relation?.label}`;
16
+ }
17
+ }
18
+ if (left && right && type) {
19
+ const relation = relationTypeOptions.find((relationTypeOption)=>relationTypeOption.value === type);
20
+ return `${left.label} ${relation?.label} ${right.label}`;
21
+ }
14
22
  }
15
23
  return '未知';
16
24
  }
@@ -22,10 +22,25 @@ class ConditionGroupPresenter {
22
22
  updateType(id, type) {
23
23
  this.presenter.updateState((prevState)=>{
24
24
  const groups = prevState.groups.map((group)=>{
25
- if (group.id === id) return {
26
- ...group,
27
- type: type
28
- };
25
+ if (group.id === id) {
26
+ if ('is_null' === type) return {
27
+ ...group,
28
+ type: type,
29
+ right: false
30
+ };
31
+ if (group.right) return {
32
+ ...group,
33
+ type: type
34
+ };
35
+ {
36
+ const data = {
37
+ ...group,
38
+ type: type
39
+ };
40
+ delete data.right;
41
+ return data;
42
+ }
43
+ }
29
44
  return group;
30
45
  });
31
46
  return {
@@ -3,7 +3,7 @@ import { GroovyVariableMapping } from "../../../typings";
3
3
  /**
4
4
  * 条件类型
5
5
  */
6
- export type RelationType = 'equal' | 'greater_than' | 'greater_equal' | 'less_than' | 'less_equal' | 'not_equal' | 'unknow';
6
+ export type RelationType = 'equal' | 'greater_than' | 'greater_equal' | 'less_than' | 'less_equal' | 'not_equal' | 'is_null' | 'unknow';
7
7
  /**
8
8
  * 逻辑关系
9
9
  */
@@ -74,6 +74,6 @@ export interface Condition {
74
74
  export interface ConditionGroup {
75
75
  id: string;
76
76
  left?: Condition;
77
- right?: Condition;
77
+ right?: Condition | boolean;
78
78
  type?: RelationType;
79
79
  }
@@ -27,6 +27,10 @@ const relationTypeOptions = [
27
27
  {
28
28
  label: '不等于',
29
29
  value: 'not_equal'
30
+ },
31
+ {
32
+ label: '为空',
33
+ value: 'is_null'
30
34
  }
31
35
  ];
32
36
  export { initStateData, relationTypeOptions };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coding-flow/flow-design",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "description": "flow-engine design components ",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -54,16 +54,16 @@
54
54
  "nanoid": "^5.1.6",
55
55
  "react-redux": "^9.2.0",
56
56
  "styled-components": "^5.3.11",
57
- "@coding-flow/flow-core": "0.0.11",
58
- "@coding-flow/flow-types": "0.0.11",
59
- "@coding-flow/flow-icons": "0.0.11",
60
- "@coding-flow/flow-pc-ui": "0.0.11"
57
+ "@coding-flow/flow-core": "0.0.13",
58
+ "@coding-flow/flow-types": "0.0.13",
59
+ "@coding-flow/flow-icons": "0.0.13",
60
+ "@coding-flow/flow-pc-ui": "0.0.13"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@types/lodash-es": "^4.17.12",
64
64
  "@types/styled-components": "^5.1.36",
65
- "@coding-flow/flow-core": "0.0.11",
66
- "@coding-flow/flow-types": "0.0.11"
65
+ "@coding-flow/flow-types": "0.0.13",
66
+ "@coding-flow/flow-core": "0.0.13"
67
67
  },
68
68
  "scripts": {
69
69
  "build": "rslib build",