flow-lib-creomnia 1.0.0
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/README.md +12 -0
- package/lib/assets/icons/ChoiceNodeIcon.svg +16 -0
- package/lib/assets/icons/LeftArrowIcon.svg +3 -0
- package/lib/assets/icons/ParallelIcon.svg +5 -0
- package/lib/assets/icons/RightArrowIcon.svg +3 -0
- package/lib/assets/icons/flowIcon.svg +7 -0
- package/lib/config/colors.d.ts +13 -0
- package/lib/config/colors.js +16 -0
- package/lib/config/index.d.ts +20 -0
- package/lib/config/index.js +28 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +24 -0
- package/lib/modules/common/components/HorizontalDrawer/index.d.ts +9 -0
- package/lib/modules/common/components/HorizontalDrawer/index.js +86 -0
- package/lib/modules/common/components/ZoomToolbar/index.d.ts +8 -0
- package/lib/modules/common/components/ZoomToolbar/index.js +15 -0
- package/lib/modules/common/components/ZoomToolbar/styled.d.ts +9 -0
- package/lib/modules/common/components/ZoomToolbar/styled.js +13 -0
- package/lib/modules/common/components/index.d.ts +2 -0
- package/lib/modules/common/components/index.js +10 -0
- package/lib/modules/common/contexts/ThemeContext/index.d.ts +24 -0
- package/lib/modules/common/contexts/ThemeContext/index.js +9 -0
- package/lib/modules/common/hooks/useDragNode.d.ts +10 -0
- package/lib/modules/common/hooks/useDragNode.js +27 -0
- package/lib/modules/common/hooks/useDropNode.d.ts +11 -0
- package/lib/modules/common/hooks/useDropNode.js +16 -0
- package/lib/modules/common/types/index.d.ts +69 -0
- package/lib/modules/common/types/index.js +2 -0
- package/lib/modules/connection/components/AddButton/index.d.ts +16 -0
- package/lib/modules/connection/components/AddButton/index.js +45 -0
- package/lib/modules/connection/components/AddButton/styled.d.ts +29 -0
- package/lib/modules/connection/components/AddButton/styled.js +41 -0
- package/lib/modules/connection/components/BaseConnection/index.d.ts +4 -0
- package/lib/modules/connection/components/BaseConnection/index.js +40 -0
- package/lib/modules/connection/components/BaseConnection/styled.d.ts +18 -0
- package/lib/modules/connection/components/BaseConnection/styled.js +28 -0
- package/lib/modules/connection/components/ConnectionWithButton/index.d.ts +12 -0
- package/lib/modules/connection/components/ConnectionWithButton/index.js +83 -0
- package/lib/modules/connection/components/ConnectionWithButton/styled.d.ts +44 -0
- package/lib/modules/connection/components/ConnectionWithButton/styled.js +55 -0
- package/lib/modules/connection/enums/index.d.ts +4 -0
- package/lib/modules/connection/enums/index.js +8 -0
- package/lib/modules/connection/index.d.ts +9 -0
- package/lib/modules/connection/index.js +11 -0
- package/lib/modules/connection/services/connectionParametersServices.d.ts +28 -0
- package/lib/modules/connection/services/connectionParametersServices.js +84 -0
- package/lib/modules/connection/services/connectionServices.d.ts +7 -0
- package/lib/modules/connection/services/connectionServices.js +82 -0
- package/lib/modules/connection/types/index.d.ts +41 -0
- package/lib/modules/connection/types/index.js +2 -0
- package/lib/modules/flow/components/FlowSandbox/index.d.ts +18 -0
- package/lib/modules/flow/components/FlowSandbox/index.js +63 -0
- package/lib/modules/flow/components/FlowSandbox/styled.d.ts +9 -0
- package/lib/modules/flow/components/FlowSandbox/styled.js +32 -0
- package/lib/modules/flow/components/NodesFlow/index.d.ts +4 -0
- package/lib/modules/flow/components/NodesFlow/index.js +36 -0
- package/lib/modules/flow/components/Space/index.d.ts +3 -0
- package/lib/modules/flow/components/Space/index.js +35 -0
- package/lib/modules/flow/components/Space/styled.d.ts +2 -0
- package/lib/modules/flow/components/Space/styled.js +13 -0
- package/lib/modules/flow/context/FlowPosition/index.d.ts +13 -0
- package/lib/modules/flow/context/FlowPosition/index.js +23 -0
- package/lib/modules/flow/types/index.d.ts +29 -0
- package/lib/modules/flow/types/index.js +2 -0
- package/lib/modules/node/components/BaseNode/index.d.ts +4 -0
- package/lib/modules/node/components/BaseNode/index.js +51 -0
- package/lib/modules/node/components/BaseNode/styled.d.ts +18 -0
- package/lib/modules/node/components/BaseNode/styled.js +98 -0
- package/lib/modules/node/components/ChoiseNode/index.d.ts +4 -0
- package/lib/modules/node/components/ChoiseNode/index.js +45 -0
- package/lib/modules/node/components/ChoiseNode/styled.d.ts +20 -0
- package/lib/modules/node/components/ChoiseNode/styled.js +39 -0
- package/lib/modules/node/components/DragWrapper/index.d.ts +8 -0
- package/lib/modules/node/components/DragWrapper/index.js +15 -0
- package/lib/modules/node/components/EndNode/index.d.ts +3 -0
- package/lib/modules/node/components/EndNode/index.js +8 -0
- package/lib/modules/node/components/EndNode/styled.d.ts +16 -0
- package/lib/modules/node/components/EndNode/styled.js +22 -0
- package/lib/modules/node/components/HubNode/index.d.ts +3 -0
- package/lib/modules/node/components/HubNode/index.js +8 -0
- package/lib/modules/node/components/HubNode/styled.d.ts +2 -0
- package/lib/modules/node/components/HubNode/styled.js +12 -0
- package/lib/modules/node/components/NodesMenu/index.d.ts +14 -0
- package/lib/modules/node/components/NodesMenu/index.js +28 -0
- package/lib/modules/node/components/NodesMenu/styled.d.ts +127 -0
- package/lib/modules/node/components/NodesMenu/styled.js +69 -0
- package/lib/modules/node/components/ParallelNode/index.d.ts +4 -0
- package/lib/modules/node/components/ParallelNode/index.js +22 -0
- package/lib/modules/node/components/ParallelNode/styled.d.ts +2 -0
- package/lib/modules/node/components/ParallelNode/styled.js +16 -0
- package/lib/modules/node/components/StartNode/index.d.ts +3 -0
- package/lib/modules/node/components/StartNode/index.js +8 -0
- package/lib/modules/node/components/StartNode/styled.d.ts +16 -0
- package/lib/modules/node/components/StartNode/styled.js +22 -0
- package/lib/modules/node/contexts/SettingsContext/index.d.ts +10 -0
- package/lib/modules/node/contexts/SettingsContext/index.js +47 -0
- package/lib/modules/node/contexts/SettingsContext/styled.d.ts +20 -0
- package/lib/modules/node/contexts/SettingsContext/styled.js +40 -0
- package/lib/modules/node/enums/index.d.ts +8 -0
- package/lib/modules/node/enums/index.js +12 -0
- package/lib/modules/node/index.d.ts +10 -0
- package/lib/modules/node/index.js +22 -0
- package/lib/modules/node/services/expandCoefficientServices.d.ts +24 -0
- package/lib/modules/node/services/expandCoefficientServices.js +47 -0
- package/lib/modules/node/services/nodeServices.d.ts +11 -0
- package/lib/modules/node/services/nodeServices.js +145 -0
- package/lib/modules/node/services/pointCalculationServices.d.ts +11 -0
- package/lib/modules/node/services/pointCalculationServices.js +22 -0
- package/lib/modules/node/types/index.d.ts +49 -0
- package/lib/modules/node/types/index.js +2 -0
- package/package.json +65 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createPlaceholder = exports.createAddButton = void 0;
|
|
7
|
+
const system_1 = require("@mui/system");
|
|
8
|
+
const Add_1 = __importDefault(require("@mui/icons-material/Add"));
|
|
9
|
+
const config_1 = require("../../../../config");
|
|
10
|
+
const colors_1 = require("../../../../config/colors");
|
|
11
|
+
const material_1 = require("@mui/material");
|
|
12
|
+
const createAddButton = ({ background = colors_1.Colors.WHITE, x, y, }) => (0, system_1.styled)(Add_1.default) `
|
|
13
|
+
height: ${config_1.Config.ADD_BUTTON_WIDTH}px;
|
|
14
|
+
width: ${config_1.Config.ADD_BUTTON_WIDTH}px;
|
|
15
|
+
position: absolute;
|
|
16
|
+
top: ${y}px;
|
|
17
|
+
left: ${x}px;
|
|
18
|
+
font-size: ${config_1.Config.ADD_BUTTON_WIDTH}px;
|
|
19
|
+
background: ${background};
|
|
20
|
+
color: ${colors_1.Colors.NAVY_BLUE};
|
|
21
|
+
border-radius: 50%;
|
|
22
|
+
cursor: pointer;
|
|
23
|
+
z-index: 1000;
|
|
24
|
+
:hover {
|
|
25
|
+
background: ${colors_1.Colors.BLUE};
|
|
26
|
+
color: ${colors_1.Colors.WHITE};
|
|
27
|
+
box-shadow: 0 0 1px 3px ${colors_1.Colors.DEEP_BLUE};
|
|
28
|
+
}
|
|
29
|
+
`;
|
|
30
|
+
exports.createAddButton = createAddButton;
|
|
31
|
+
const createPlaceholder = (isOver, canDrop) => (0, system_1.styled)(material_1.Box)(() => `
|
|
32
|
+
width: ${config_1.Config.NODE_WIDTH}px;
|
|
33
|
+
height: ${config_1.Config.NODE_HEIGHT}px;
|
|
34
|
+
position: absolute;
|
|
35
|
+
border-radius: 8px;
|
|
36
|
+
background-color: rgba(99, 102, 241, 0.12);
|
|
37
|
+
border: dashed #2970FF 2px;
|
|
38
|
+
opacity: ${isOver ? 1 : 0};
|
|
39
|
+
z-index: ${canDrop ? 1000 : 0};
|
|
40
|
+
`);
|
|
41
|
+
exports.createPlaceholder = createPlaceholder;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const styled_1 = require("./styled");
|
|
6
|
+
const connectionParametersServices_1 = require("../../services/connectionParametersServices");
|
|
7
|
+
const web_1 = require("@react-spring/web");
|
|
8
|
+
const colors_1 = require("../../../../config/colors");
|
|
9
|
+
const BaseConnection = ({ startPoint, endPoint, node, curveType, isProcessed }) => {
|
|
10
|
+
const { ConnectionLine } = (0, react_1.useMemo)(() => {
|
|
11
|
+
const { width, height, x, y, top, bottom, left, right } = connectionParametersServices_1.connectionParametersServices.calculateConnectionParameters({
|
|
12
|
+
endPoint,
|
|
13
|
+
startPoint,
|
|
14
|
+
node,
|
|
15
|
+
curveType,
|
|
16
|
+
});
|
|
17
|
+
const ConnectionLine = (0, styled_1.createConnectionLine)({
|
|
18
|
+
width: Math.abs(width),
|
|
19
|
+
height,
|
|
20
|
+
x,
|
|
21
|
+
y,
|
|
22
|
+
border: {
|
|
23
|
+
top,
|
|
24
|
+
bottom,
|
|
25
|
+
left,
|
|
26
|
+
right,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
return { ConnectionLine };
|
|
30
|
+
}, [curveType, endPoint, node, startPoint]);
|
|
31
|
+
const props = (0, web_1.useSpring)({
|
|
32
|
+
borderColor: isProcessed ? colors_1.Colors.GREEN : colors_1.Colors.NAVY_BLUE,
|
|
33
|
+
config: {
|
|
34
|
+
duration: isProcessed ? 600 : 150
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
const AnimatedConnectionLine = (0, web_1.animated)(ConnectionLine);
|
|
38
|
+
return (0, jsx_runtime_1.jsx)(AnimatedConnectionLine, { style: props });
|
|
39
|
+
};
|
|
40
|
+
exports.default = BaseConnection;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
type ConnectionLinePropsType = {
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
border: {
|
|
8
|
+
top: boolean;
|
|
9
|
+
left: boolean;
|
|
10
|
+
right: boolean;
|
|
11
|
+
bottom: boolean;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export declare const createConnectionLine: ({ width, height, x, y, border }: ConnectionLinePropsType) => import("@emotion/styled").StyledComponent<{
|
|
15
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
16
|
+
as?: import("react").ElementType<any> | undefined;
|
|
17
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createConnectionLine = void 0;
|
|
7
|
+
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
8
|
+
const config_1 = require("../../../../config");
|
|
9
|
+
const createConnectionLine = ({ width, height, x, y, border }) => {
|
|
10
|
+
return (0, styled_1.default)("div") `
|
|
11
|
+
width: ${width}px;
|
|
12
|
+
height: ${height}px;
|
|
13
|
+
border-top: ${border.top ? config_1.Config.CONNECTION_WIDTH : 0}px solid;
|
|
14
|
+
border-left: ${border.left ? config_1.Config.CONNECTION_WIDTH : 0}px solid;
|
|
15
|
+
border-right: ${border.right ? config_1.Config.CONNECTION_WIDTH : 0}px solid;
|
|
16
|
+
border-bottom: ${border.bottom ? config_1.Config.CONNECTION_WIDTH : 0}px solid;
|
|
17
|
+
border-top-left-radius: ${border.left && border.top ? 8 : 0}px;
|
|
18
|
+
border-top-right-radius: ${border.right && border.top ? 8 : 0}px;
|
|
19
|
+
border-bottom-left-radius: ${border.left && border.bottom ? 8 : 0}px;
|
|
20
|
+
border-bottom-right-radius: ${border.right && border.bottom ? 8 : 0}px;
|
|
21
|
+
position: absolute;
|
|
22
|
+
top: ${y}px;
|
|
23
|
+
left: ${x}px;
|
|
24
|
+
display: flex;
|
|
25
|
+
align-items: center;
|
|
26
|
+
`;
|
|
27
|
+
};
|
|
28
|
+
exports.createConnectionLine = createConnectionLine;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ConnectionPropsType } from '../../types';
|
|
3
|
+
export declare const nodeHeightByType: {
|
|
4
|
+
startNode: number;
|
|
5
|
+
endNode: number;
|
|
6
|
+
baseNode: number;
|
|
7
|
+
choiceNode: number;
|
|
8
|
+
hubNode: number;
|
|
9
|
+
parallelNode: number;
|
|
10
|
+
};
|
|
11
|
+
declare const _default: React.NamedExoticComponent<ConnectionPropsType>;
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.nodeHeightByType = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const styled_1 = require("./styled");
|
|
10
|
+
const NodesMenu_1 = __importDefault(require("../../../node/components/NodesMenu"));
|
|
11
|
+
const config_1 = require("../../../../config");
|
|
12
|
+
const connectionParametersServices_1 = require("../../services/connectionParametersServices");
|
|
13
|
+
const enums_1 = require("../../../node/enums");
|
|
14
|
+
const material_1 = require("@mui/material");
|
|
15
|
+
const web_1 = require("@react-spring/web");
|
|
16
|
+
const colors_1 = require("../../../../config/colors");
|
|
17
|
+
const AddButton_1 = require("../AddButton");
|
|
18
|
+
exports.nodeHeightByType = {
|
|
19
|
+
[enums_1.NodeTypeEnum.StartNode]: config_1.Config.EDGE_NODE_HEIGHT,
|
|
20
|
+
[enums_1.NodeTypeEnum.EndNode]: config_1.Config.EDGE_NODE_HEIGHT,
|
|
21
|
+
[enums_1.NodeTypeEnum.BaseNode]: config_1.Config.NODE_HEIGHT,
|
|
22
|
+
[enums_1.NodeTypeEnum.ChoiceNode]: 0,
|
|
23
|
+
[enums_1.NodeTypeEnum.HubNode]: config_1.Config.HUB_NODE_HEIGHT,
|
|
24
|
+
[enums_1.NodeTypeEnum.ParallelNode]: 0,
|
|
25
|
+
};
|
|
26
|
+
const ConnectionWithButton = ({ parentId, menuTabs, startPoint, endPoint, addNewNodeCallback, node, connectionIndex, curveType, isProcessed, childNodeId }) => {
|
|
27
|
+
const popperRef = (0, react_1.useRef)();
|
|
28
|
+
const [anchorEl, setAnchorEl] = (0, react_1.useState)(false);
|
|
29
|
+
const [styles, setStyles] = (0, react_1.useState)({});
|
|
30
|
+
const ConnectionLine = (0, react_1.useMemo)(() => {
|
|
31
|
+
const { width, height, x, y, top, bottom, left, right } = connectionParametersServices_1.connectionParametersServices.calculateConnectionParameters({
|
|
32
|
+
endPoint,
|
|
33
|
+
startPoint,
|
|
34
|
+
node,
|
|
35
|
+
curveType,
|
|
36
|
+
});
|
|
37
|
+
return (0, styled_1.createConnectionLine)({
|
|
38
|
+
width: Math.abs(width),
|
|
39
|
+
height,
|
|
40
|
+
x,
|
|
41
|
+
y,
|
|
42
|
+
border: {
|
|
43
|
+
top,
|
|
44
|
+
bottom,
|
|
45
|
+
left,
|
|
46
|
+
right,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
}, [curveType, endPoint, node, startPoint]);
|
|
50
|
+
const handleClose = () => {
|
|
51
|
+
setAnchorEl(false);
|
|
52
|
+
};
|
|
53
|
+
const handleClick = (event) => {
|
|
54
|
+
const rect = popperRef?.current?.getBoundingClientRect();
|
|
55
|
+
const left = rect?.left || 0;
|
|
56
|
+
const top = rect?.top || 0;
|
|
57
|
+
const style = {
|
|
58
|
+
transform: `translate(${left - 292}px, ${top - 128}px)`,
|
|
59
|
+
};
|
|
60
|
+
setStyles(style);
|
|
61
|
+
setAnchorEl(true);
|
|
62
|
+
};
|
|
63
|
+
const isOpen = Boolean(anchorEl);
|
|
64
|
+
const props = (0, web_1.useSpring)({
|
|
65
|
+
borderColor: isProcessed ? colors_1.Colors.GREEN : colors_1.Colors.NAVY_BLUE,
|
|
66
|
+
config: {
|
|
67
|
+
duration: isProcessed ? 600 : 150
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
const AnimatedConnectionLine = (0, web_1.animated)(ConnectionLine);
|
|
71
|
+
const buttonProps = {
|
|
72
|
+
endPoint,
|
|
73
|
+
startPoint,
|
|
74
|
+
node,
|
|
75
|
+
curveType,
|
|
76
|
+
parentId,
|
|
77
|
+
childNodeId,
|
|
78
|
+
onClick: handleClick,
|
|
79
|
+
innerRef: popperRef
|
|
80
|
+
};
|
|
81
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(AddButton_1.AddButton, { ...buttonProps }), (0, jsx_runtime_1.jsx)(AnimatedConnectionLine, { style: props }), (0, jsx_runtime_1.jsx)(material_1.ClickAwayListener, { onClickAway: () => isOpen && handleClose(), mouseEvent: "onMouseDown", touchEvent: "onTouchStart", children: (0, jsx_runtime_1.jsx)(styled_1.StyledPopper, { placement: 'left', open: isOpen, sx: styles, modifiers: [{ name: 'arrow', enabled: true }], children: (0, jsx_runtime_1.jsx)(NodesMenu_1.default, { addNewNodeCallback: addNewNodeCallback, data: { parentId, connectionIndex }, menuTabs: menuTabs, onCloseMenu: handleClose }) }) })] }));
|
|
82
|
+
};
|
|
83
|
+
exports.default = (0, react_1.memo)(ConnectionWithButton);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
type ConnectionLinePropsType = {
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
border: {
|
|
8
|
+
top: boolean;
|
|
9
|
+
left: boolean;
|
|
10
|
+
right: boolean;
|
|
11
|
+
bottom: boolean;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export declare const createConnectionLine: ({ width, height, x, y, border, }: ConnectionLinePropsType) => import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/system").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
15
|
+
type AddButtonPropsType = {
|
|
16
|
+
background?: string;
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
};
|
|
20
|
+
export declare const createAddButton: ({ background, x, y, }: AddButtonPropsType) => import("@emotion/styled").StyledComponent<{
|
|
21
|
+
children?: import("react").ReactNode;
|
|
22
|
+
classes?: Partial<import("@mui/material").SvgIconClasses> | undefined;
|
|
23
|
+
color?: import("@mui/types").OverridableStringUnion<"error" | "inherit" | "action" | "disabled" | "success" | "info" | "warning" | "primary" | "secondary", import("@mui/material").SvgIconPropsColorOverrides> | undefined;
|
|
24
|
+
fontSize?: import("@mui/types").OverridableStringUnion<"small" | "medium" | "inherit" | "large", import("@mui/material").SvgIconPropsSizeOverrides> | undefined;
|
|
25
|
+
htmlColor?: string | undefined;
|
|
26
|
+
inheritViewBox?: boolean | undefined;
|
|
27
|
+
shapeRendering?: string | undefined;
|
|
28
|
+
sx?: import("@mui/system").SxProps<import("@mui/material").Theme> | undefined;
|
|
29
|
+
titleAccess?: string | undefined;
|
|
30
|
+
viewBox?: string | undefined;
|
|
31
|
+
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").SVGProps<SVGSVGElement>, "ref"> & {
|
|
32
|
+
ref?: ((instance: SVGSVGElement | null) => void) | import("react").RefObject<SVGSVGElement> | null | undefined;
|
|
33
|
+
}, "color" | "fontSize" | "shapeRendering" | "children" | "viewBox" | "sx" | keyof import("@mui/material/OverridableComponent").CommonProps | "htmlColor" | "inheritViewBox" | "titleAccess"> & import("@mui/system").MUIStyledCommonProps<import("@mui/system").Theme>, {}, {}>;
|
|
34
|
+
export declare const StyledPopper: import("@emotion/styled").StyledComponent<Omit<import("@mui/base").PopperProps<"div">, "direction"> & {
|
|
35
|
+
component?: import("react").ElementType<any> | undefined;
|
|
36
|
+
components?: {
|
|
37
|
+
Root?: import("react").ElementType<any> | undefined;
|
|
38
|
+
} | undefined;
|
|
39
|
+
componentsProps?: {
|
|
40
|
+
root?: import("@mui/base").SlotComponentProps<"div", import("@mui/base").PopperRootSlotPropsOverrides, import("@mui/base").PopperOwnProps> | undefined;
|
|
41
|
+
} | undefined;
|
|
42
|
+
sx?: import("@mui/system").SxProps<import("@mui/material").Theme> | undefined;
|
|
43
|
+
} & import("react").RefAttributes<HTMLDivElement> & import("@mui/system").MUIStyledCommonProps<import("@mui/system").Theme>, {}, {}>;
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.StyledPopper = exports.createAddButton = exports.createConnectionLine = void 0;
|
|
7
|
+
const system_1 = require("@mui/system");
|
|
8
|
+
const Add_1 = __importDefault(require("@mui/icons-material/Add"));
|
|
9
|
+
const config_1 = require("../../../../config");
|
|
10
|
+
const colors_1 = require("../../../../config/colors");
|
|
11
|
+
const material_1 = require("@mui/material");
|
|
12
|
+
const createConnectionLine = ({ width, height, x, y, border, }) => {
|
|
13
|
+
return (0, system_1.styled)("div") `
|
|
14
|
+
width: ${width}px;
|
|
15
|
+
height: ${height}px;
|
|
16
|
+
border-top: ${border.top ? config_1.Config.CONNECTION_WIDTH : 0}px solid;
|
|
17
|
+
border-left: ${border.left ? config_1.Config.CONNECTION_WIDTH : 0}px solid;
|
|
18
|
+
border-right: ${border.right ? config_1.Config.CONNECTION_WIDTH : 0}px solid;
|
|
19
|
+
border-bottom: ${border.bottom ? config_1.Config.CONNECTION_WIDTH : 0}px solid;
|
|
20
|
+
border-top-left-radius: ${border.left && border.top ? 8 : 0}px;
|
|
21
|
+
border-top-right-radius: ${border.right && border.top ? 8 : 0}px;
|
|
22
|
+
border-bottom-left-radius: ${border.left && border.bottom ? 8 : 0}px;
|
|
23
|
+
border-bottom-right-radius: ${border.right && border.bottom ? 8 : 0}px;
|
|
24
|
+
position: absolute;
|
|
25
|
+
top: ${y}px;
|
|
26
|
+
left: ${x}px;
|
|
27
|
+
display: flex;
|
|
28
|
+
align-items: center;
|
|
29
|
+
`;
|
|
30
|
+
};
|
|
31
|
+
exports.createConnectionLine = createConnectionLine;
|
|
32
|
+
const createAddButton = ({ background = colors_1.Colors.WHITE, x, y, }) => (0, system_1.styled)(Add_1.default) `
|
|
33
|
+
height: ${config_1.Config.ADD_BUTTON_WIDTH}px;
|
|
34
|
+
width: ${config_1.Config.ADD_BUTTON_WIDTH}px;
|
|
35
|
+
position: absolute;
|
|
36
|
+
top: ${y}px;
|
|
37
|
+
left: ${x}px;
|
|
38
|
+
font-size: ${config_1.Config.ADD_BUTTON_WIDTH}px;
|
|
39
|
+
background: ${background};
|
|
40
|
+
color: ${colors_1.Colors.NAVY_BLUE};
|
|
41
|
+
border-radius: 50%;
|
|
42
|
+
cursor: pointer;
|
|
43
|
+
z-index: 1000;
|
|
44
|
+
:hover {
|
|
45
|
+
background: ${colors_1.Colors.BLUE};
|
|
46
|
+
color: ${colors_1.Colors.WHITE};
|
|
47
|
+
box-shadow: 0 0 1px 3px ${colors_1.Colors.DEEP_BLUE};
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
exports.createAddButton = createAddButton;
|
|
51
|
+
exports.StyledPopper = (0, system_1.styled)(material_1.Popper) `
|
|
52
|
+
z-index: 1000;
|
|
53
|
+
overflow: hidden;
|
|
54
|
+
border-radius: 16px;
|
|
55
|
+
`;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConnectionCurveEnum = void 0;
|
|
4
|
+
var ConnectionCurveEnum;
|
|
5
|
+
(function (ConnectionCurveEnum) {
|
|
6
|
+
ConnectionCurveEnum["RIGHT"] = "right";
|
|
7
|
+
ConnectionCurveEnum["LEFT"] = "left";
|
|
8
|
+
})(ConnectionCurveEnum || (exports.ConnectionCurveEnum = ConnectionCurveEnum = {}));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.moduleConnection = void 0;
|
|
7
|
+
const ConnectionWithButton_1 = __importDefault(require("./components/ConnectionWithButton"));
|
|
8
|
+
const BaseConnection_1 = __importDefault(require("./components/BaseConnection"));
|
|
9
|
+
exports.moduleConnection = {
|
|
10
|
+
connections: { connectionWithButton: ConnectionWithButton_1.default, baseConnection: BaseConnection_1.default },
|
|
11
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { PointType } from "../../common/types";
|
|
2
|
+
import { NodeType } from "../../node/types";
|
|
3
|
+
import { ConnectionCurveEnum } from "../enums";
|
|
4
|
+
declare class ConnectionParametersServices {
|
|
5
|
+
private curveValueByType;
|
|
6
|
+
private calculateWidth;
|
|
7
|
+
private calculateHeight;
|
|
8
|
+
private calculateStartPoint;
|
|
9
|
+
private bordersByCurveType;
|
|
10
|
+
private calculateBorders;
|
|
11
|
+
calculateConnectionParameters: ({ startPoint, endPoint, node, curveType, }: {
|
|
12
|
+
endPoint: PointType;
|
|
13
|
+
startPoint: PointType;
|
|
14
|
+
node: NodeType;
|
|
15
|
+
curveType: ConnectionCurveEnum | undefined;
|
|
16
|
+
}) => {
|
|
17
|
+
width: number;
|
|
18
|
+
height: number;
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
top: boolean;
|
|
22
|
+
bottom: boolean;
|
|
23
|
+
left: boolean;
|
|
24
|
+
right: boolean;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export declare const connectionParametersServices: ConnectionParametersServices;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.connectionParametersServices = void 0;
|
|
4
|
+
const config_1 = require("../../../config");
|
|
5
|
+
const enums_1 = require("../enums");
|
|
6
|
+
class ConnectionParametersServices {
|
|
7
|
+
curveValueByType = {
|
|
8
|
+
[enums_1.ConnectionCurveEnum.LEFT]: -config_1.Config.HORIZONTAL_SHIFT / 2,
|
|
9
|
+
[enums_1.ConnectionCurveEnum.RIGHT]: config_1.Config.HORIZONTAL_SHIFT / 2,
|
|
10
|
+
};
|
|
11
|
+
calculateWidth = ({ endPoint, startPoint, curveType, }) => {
|
|
12
|
+
return endPoint.x - startPoint.x + (curveType ? this.curveValueByType[curveType] : 0);
|
|
13
|
+
};
|
|
14
|
+
calculateHeight = ({ endPoint, startPoint, curveType, }) => {
|
|
15
|
+
const height = endPoint.y - startPoint.y + config_1.Config.NODE_HEIGHT / 2 - config_1.Config.CONNECTION_WIDTH / 2;
|
|
16
|
+
if (curveType) {
|
|
17
|
+
return height - config_1.Config.CONNECTION_WIDTH;
|
|
18
|
+
}
|
|
19
|
+
return height;
|
|
20
|
+
};
|
|
21
|
+
calculateStartPoint = ({ width, startPoint }) => {
|
|
22
|
+
const y = startPoint.y;
|
|
23
|
+
const x = width < 0 ? startPoint.x + width : startPoint.x;
|
|
24
|
+
return { x, y };
|
|
25
|
+
};
|
|
26
|
+
bordersByCurveType = {
|
|
27
|
+
[enums_1.ConnectionCurveEnum.LEFT]: {
|
|
28
|
+
top: true,
|
|
29
|
+
bottom: true,
|
|
30
|
+
left: true,
|
|
31
|
+
right: false,
|
|
32
|
+
},
|
|
33
|
+
[enums_1.ConnectionCurveEnum.RIGHT]: {
|
|
34
|
+
top: true,
|
|
35
|
+
bottom: true,
|
|
36
|
+
left: false,
|
|
37
|
+
right: true,
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
calculateBorders = ({ node, width, startPoint, endPoint, curveType, }) => {
|
|
41
|
+
if (curveType) {
|
|
42
|
+
return this.bordersByCurveType[curveType];
|
|
43
|
+
}
|
|
44
|
+
const top = (node.childrenIds?.length || 0) > 1;
|
|
45
|
+
const bottom = !top;
|
|
46
|
+
const left = (top ? width < 0 : width > 0) || startPoint.x === endPoint.x;
|
|
47
|
+
const right = !left;
|
|
48
|
+
return { top, bottom, left, right };
|
|
49
|
+
};
|
|
50
|
+
calculateConnectionParameters = ({ startPoint, endPoint, node, curveType, }) => {
|
|
51
|
+
const width = this.calculateWidth({
|
|
52
|
+
endPoint,
|
|
53
|
+
startPoint,
|
|
54
|
+
curveType,
|
|
55
|
+
});
|
|
56
|
+
const height = this.calculateHeight({
|
|
57
|
+
endPoint,
|
|
58
|
+
startPoint,
|
|
59
|
+
curveType,
|
|
60
|
+
});
|
|
61
|
+
const { x, y } = this.calculateStartPoint({
|
|
62
|
+
width,
|
|
63
|
+
startPoint,
|
|
64
|
+
});
|
|
65
|
+
const { top, bottom, left, right } = this.calculateBorders({
|
|
66
|
+
node,
|
|
67
|
+
width,
|
|
68
|
+
startPoint,
|
|
69
|
+
endPoint,
|
|
70
|
+
curveType,
|
|
71
|
+
});
|
|
72
|
+
return {
|
|
73
|
+
width,
|
|
74
|
+
height,
|
|
75
|
+
x,
|
|
76
|
+
y,
|
|
77
|
+
top,
|
|
78
|
+
bottom,
|
|
79
|
+
left,
|
|
80
|
+
right,
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
exports.connectionParametersServices = new ConnectionParametersServices();
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BuildConnectionsType, CreateDrawerConnectionType } from '../types';
|
|
2
|
+
declare class ConnectionServices {
|
|
3
|
+
createDrawerConnection: CreateDrawerConnectionType;
|
|
4
|
+
buildConnections: BuildConnectionsType;
|
|
5
|
+
}
|
|
6
|
+
export declare const connectionServices: ConnectionServices;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.connectionServices = void 0;
|
|
4
|
+
const config_1 = require("../../../config");
|
|
5
|
+
const enums_1 = require("../../node/enums");
|
|
6
|
+
const enums_2 = require("../enums");
|
|
7
|
+
class ConnectionServices {
|
|
8
|
+
createDrawerConnection = ({ nodeDrawer, index, menuTabs, child, addNewNodeCallback, curveType, processedNodeIds, failedNodeId }) => {
|
|
9
|
+
const childProcessed = nodeDrawer.nodeData?.childrenIds?.filter(childId => processedNodeIds.includes(childId)).length;
|
|
10
|
+
const isIncorrect = childProcessed === 2 && child.type === enums_1.NodeTypeEnum.HubNode;
|
|
11
|
+
const nodesProcessed = processedNodeIds.includes(child.nodeData?.id || '') && processedNodeIds.includes(nodeDrawer.nodeData?.id || '');
|
|
12
|
+
const isStartNodeProcessed = nodeDrawer.id === enums_1.NodeTypeEnum.StartNode && processedNodeIds.includes(child.nodeData?.id || '');
|
|
13
|
+
const isFinishNodeProcessed = child.id === enums_1.NodeTypeEnum.EndNode && processedNodeIds.includes(nodeDrawer.nodeData?.id || '') && failedNodeId !== nodeDrawer.nodeData?.id;
|
|
14
|
+
return {
|
|
15
|
+
type: 'connectionWithButton',
|
|
16
|
+
connectionData: {
|
|
17
|
+
connectionIndex: index,
|
|
18
|
+
menuTabs,
|
|
19
|
+
startPoint: {
|
|
20
|
+
x: nodeDrawer.renderPoint.x,
|
|
21
|
+
y: nodeDrawer.renderPoint.y + config_1.Config.NODE_HEIGHT / 2,
|
|
22
|
+
},
|
|
23
|
+
endPoint: child.renderPoint,
|
|
24
|
+
parentId: nodeDrawer.id === enums_1.NodeTypeEnum.StartNode ? undefined : nodeDrawer.id,
|
|
25
|
+
childNodeId: child.id,
|
|
26
|
+
addNewNodeCallback,
|
|
27
|
+
node: nodeDrawer.nodeData,
|
|
28
|
+
curveType,
|
|
29
|
+
isProcessed: !isIncorrect && (nodesProcessed || isStartNodeProcessed || isFinishNodeProcessed)
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
buildConnections = ({ nodeDrawers, menuTabs, addNewNodeCallback, processedNodeIds, failedNodeId }) => nodeDrawers.reduce((connectionDrawers, nodeDrawer) => {
|
|
34
|
+
const childrenIds = nodeDrawer.nodeData?.childrenIds || [];
|
|
35
|
+
const children = nodeDrawers.filter((nodeDrawer) => childrenIds?.includes(nodeDrawer.id));
|
|
36
|
+
if (!children.length)
|
|
37
|
+
return connectionDrawers;
|
|
38
|
+
const isNodeWithDoubleConnections = config_1.Config.NODES_WITH_DOUBLE_CONNECTION.includes(nodeDrawer.type);
|
|
39
|
+
if (isNodeWithDoubleConnections) {
|
|
40
|
+
const leftChild = nodeDrawers.find((node) => node.nodeData?.id === nodeDrawer.nodeData?.leftChildrenId);
|
|
41
|
+
const rightChild = nodeDrawers.find((node) => node.nodeData?.id === nodeDrawer.nodeData?.rightChildrenId);
|
|
42
|
+
const newConnectionDrawers = [
|
|
43
|
+
this.createDrawerConnection({
|
|
44
|
+
failedNodeId,
|
|
45
|
+
processedNodeIds,
|
|
46
|
+
nodeDrawer,
|
|
47
|
+
index: 1,
|
|
48
|
+
menuTabs,
|
|
49
|
+
child: leftChild,
|
|
50
|
+
addNewNodeCallback,
|
|
51
|
+
curveType: leftChild?.nodeData?.startSectionNodeId
|
|
52
|
+
? enums_2.ConnectionCurveEnum.LEFT
|
|
53
|
+
: undefined,
|
|
54
|
+
}),
|
|
55
|
+
this.createDrawerConnection({
|
|
56
|
+
failedNodeId,
|
|
57
|
+
processedNodeIds,
|
|
58
|
+
nodeDrawer,
|
|
59
|
+
index: 2,
|
|
60
|
+
menuTabs,
|
|
61
|
+
child: rightChild,
|
|
62
|
+
addNewNodeCallback,
|
|
63
|
+
curveType: rightChild?.nodeData?.startSectionNodeId
|
|
64
|
+
? enums_2.ConnectionCurveEnum.RIGHT
|
|
65
|
+
: undefined,
|
|
66
|
+
}),
|
|
67
|
+
];
|
|
68
|
+
return [...connectionDrawers, ...newConnectionDrawers];
|
|
69
|
+
}
|
|
70
|
+
const newConnectionDrawers = children.map((child, index) => this.createDrawerConnection({
|
|
71
|
+
failedNodeId,
|
|
72
|
+
processedNodeIds,
|
|
73
|
+
nodeDrawer,
|
|
74
|
+
index: index + 1,
|
|
75
|
+
menuTabs,
|
|
76
|
+
child: child,
|
|
77
|
+
addNewNodeCallback,
|
|
78
|
+
}));
|
|
79
|
+
return [...connectionDrawers, ...newConnectionDrawers];
|
|
80
|
+
}, []);
|
|
81
|
+
}
|
|
82
|
+
exports.connectionServices = new ConnectionServices();
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { MenuTabType, PointType } from '../../common/types';
|
|
2
|
+
import { AddNewNodeCallbackType } from '../../flow/types';
|
|
3
|
+
import { BaseDrawableNodeType, NodeType } from '../../node/types';
|
|
4
|
+
import { ConnectionCurveEnum } from '../enums';
|
|
5
|
+
export type NodeLinkType = {
|
|
6
|
+
nodeId: string;
|
|
7
|
+
branch: number;
|
|
8
|
+
};
|
|
9
|
+
export type ConnectionPropsType = {
|
|
10
|
+
startPoint: PointType;
|
|
11
|
+
endPoint: PointType;
|
|
12
|
+
parentId: string | undefined;
|
|
13
|
+
childNodeId: string;
|
|
14
|
+
menuTabs: MenuTabType[];
|
|
15
|
+
addNewNodeCallback?: AddNewNodeCallbackType;
|
|
16
|
+
connectionIndex: number;
|
|
17
|
+
node: NodeType;
|
|
18
|
+
curveType?: ConnectionCurveEnum;
|
|
19
|
+
isProcessed: boolean;
|
|
20
|
+
};
|
|
21
|
+
export type ConnectionDrawerType = {
|
|
22
|
+
type: string;
|
|
23
|
+
connectionData: ConnectionPropsType;
|
|
24
|
+
};
|
|
25
|
+
export type CreateDrawerConnectionType = (props: {
|
|
26
|
+
menuTabs: MenuTabType[];
|
|
27
|
+
nodeDrawer: BaseDrawableNodeType;
|
|
28
|
+
child: BaseDrawableNodeType;
|
|
29
|
+
index: number;
|
|
30
|
+
addNewNodeCallback?: AddNewNodeCallbackType;
|
|
31
|
+
curveType?: ConnectionCurveEnum;
|
|
32
|
+
processedNodeIds: string[];
|
|
33
|
+
failedNodeId?: string;
|
|
34
|
+
}) => ConnectionDrawerType;
|
|
35
|
+
export type BuildConnectionsType = ({ nodeDrawers, menuTabs, addNewNodeCallback, }: {
|
|
36
|
+
processedNodeIds: string[];
|
|
37
|
+
failedNodeId?: string;
|
|
38
|
+
nodeDrawers: BaseDrawableNodeType[];
|
|
39
|
+
menuTabs: MenuTabType[];
|
|
40
|
+
addNewNodeCallback?: AddNewNodeCallbackType | undefined;
|
|
41
|
+
}) => ConnectionDrawerType[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FC, RefObject } from 'react';
|
|
2
|
+
import { BaseDrawableNodeType } from '../../../node/types';
|
|
3
|
+
import { ConnectionDrawerType } from '../../../connection/types';
|
|
4
|
+
import { Permissions } from "../../types";
|
|
5
|
+
import { UpdateNodePosition } from "../../../common/types";
|
|
6
|
+
type PropsType = {
|
|
7
|
+
nodeDrawers: BaseDrawableNodeType[];
|
|
8
|
+
connectionDrawers: ConnectionDrawerType[];
|
|
9
|
+
containerRef: RefObject<HTMLDivElement> | null;
|
|
10
|
+
permissions: Permissions;
|
|
11
|
+
onUpdateNodePosition: UpdateNodePosition;
|
|
12
|
+
processedNodeIds?: string[];
|
|
13
|
+
failedNodeId?: string;
|
|
14
|
+
failedNodeColor?: string;
|
|
15
|
+
onRedirect?: (flowId: string) => void;
|
|
16
|
+
};
|
|
17
|
+
declare const FlowSandbox: FC<PropsType>;
|
|
18
|
+
export default FlowSandbox;
|