flow-lib-creomnia 1.0.7 → 1.0.8-dev.2

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 (110) hide show
  1. package/lib/assets/icons/ChoiceNodeIcon.svg +16 -0
  2. package/lib/assets/icons/LeftArrowIcon.svg +3 -0
  3. package/lib/assets/icons/ParallelIcon.svg +5 -0
  4. package/lib/assets/icons/RightArrowIcon.svg +3 -0
  5. package/lib/assets/icons/flowIcon.svg +7 -0
  6. package/lib/config/colors.d.ts +13 -0
  7. package/lib/config/colors.js +16 -0
  8. package/lib/config/index.d.ts +20 -0
  9. package/lib/config/index.js +28 -0
  10. package/lib/index.d.ts +4 -0
  11. package/lib/index.js +24 -0
  12. package/lib/modules/common/components/HorizontalDrawer/index.d.ts +9 -0
  13. package/lib/modules/common/components/HorizontalDrawer/index.js +86 -0
  14. package/lib/modules/common/components/ZoomToolbar/index.d.ts +8 -0
  15. package/lib/modules/common/components/ZoomToolbar/index.js +15 -0
  16. package/lib/modules/common/components/ZoomToolbar/styled.d.ts +9 -0
  17. package/lib/modules/common/components/ZoomToolbar/styled.js +13 -0
  18. package/lib/modules/common/components/index.d.ts +2 -0
  19. package/lib/modules/common/components/index.js +10 -0
  20. package/lib/modules/common/contexts/ThemeContext/index.d.ts +24 -0
  21. package/lib/modules/common/contexts/ThemeContext/index.js +9 -0
  22. package/lib/modules/common/hooks/useDragNode.d.ts +10 -0
  23. package/lib/modules/common/hooks/useDragNode.js +27 -0
  24. package/lib/modules/common/hooks/useDropNode.d.ts +11 -0
  25. package/lib/modules/common/hooks/useDropNode.js +16 -0
  26. package/lib/modules/common/types/index.d.ts +72 -0
  27. package/lib/modules/common/types/index.js +2 -0
  28. package/lib/modules/connection/components/AddButton/index.d.ts +16 -0
  29. package/lib/modules/connection/components/AddButton/index.js +45 -0
  30. package/lib/modules/connection/components/AddButton/styled.d.ts +29 -0
  31. package/lib/modules/connection/components/AddButton/styled.js +41 -0
  32. package/lib/modules/connection/components/BaseConnection/index.d.ts +4 -0
  33. package/lib/modules/connection/components/BaseConnection/index.js +40 -0
  34. package/lib/modules/connection/components/BaseConnection/styled.d.ts +18 -0
  35. package/lib/modules/connection/components/BaseConnection/styled.js +28 -0
  36. package/lib/modules/connection/components/ConnectionWithButton/index.d.ts +12 -0
  37. package/lib/modules/connection/components/ConnectionWithButton/index.js +84 -0
  38. package/lib/modules/connection/components/ConnectionWithButton/styled.d.ts +44 -0
  39. package/lib/modules/connection/components/ConnectionWithButton/styled.js +55 -0
  40. package/lib/modules/connection/enums/index.d.ts +4 -0
  41. package/lib/modules/connection/enums/index.js +8 -0
  42. package/lib/modules/connection/index.d.ts +9 -0
  43. package/lib/modules/connection/index.js +11 -0
  44. package/lib/modules/connection/services/connectionParametersServices.d.ts +28 -0
  45. package/lib/modules/connection/services/connectionParametersServices.js +84 -0
  46. package/lib/modules/connection/services/connectionServices.d.ts +7 -0
  47. package/lib/modules/connection/services/connectionServices.js +88 -0
  48. package/lib/modules/connection/types/index.d.ts +44 -0
  49. package/lib/modules/connection/types/index.js +2 -0
  50. package/lib/modules/flow/components/FlowSandbox/index.d.ts +20 -0
  51. package/lib/modules/flow/components/FlowSandbox/index.js +63 -0
  52. package/lib/modules/flow/components/FlowSandbox/styled.d.ts +9 -0
  53. package/lib/modules/flow/components/FlowSandbox/styled.js +32 -0
  54. package/lib/modules/flow/components/NodesFlow/index.d.ts +4 -0
  55. package/lib/modules/flow/components/NodesFlow/index.js +36 -0
  56. package/lib/modules/flow/components/Space/index.d.ts +3 -0
  57. package/lib/modules/flow/components/Space/index.js +35 -0
  58. package/lib/modules/flow/components/Space/styled.d.ts +2 -0
  59. package/lib/modules/flow/components/Space/styled.js +13 -0
  60. package/lib/modules/flow/context/FlowPosition/index.d.ts +13 -0
  61. package/lib/modules/flow/context/FlowPosition/index.js +23 -0
  62. package/lib/modules/flow/types/index.d.ts +34 -0
  63. package/lib/modules/flow/types/index.js +2 -0
  64. package/lib/modules/node/components/BaseNode/index.d.ts +4 -0
  65. package/lib/modules/node/components/BaseNode/index.js +51 -0
  66. package/lib/modules/node/components/BaseNode/styled.d.ts +18 -0
  67. package/lib/modules/node/components/BaseNode/styled.js +98 -0
  68. package/lib/modules/node/components/ChoiseNode/index.d.ts +4 -0
  69. package/lib/modules/node/components/ChoiseNode/index.js +45 -0
  70. package/lib/modules/node/components/ChoiseNode/styled.d.ts +20 -0
  71. package/lib/modules/node/components/ChoiseNode/styled.js +39 -0
  72. package/lib/modules/node/components/DragWrapper/index.d.ts +8 -0
  73. package/lib/modules/node/components/DragWrapper/index.js +15 -0
  74. package/lib/modules/node/components/EndNode/index.d.ts +3 -0
  75. package/lib/modules/node/components/EndNode/index.js +8 -0
  76. package/lib/modules/node/components/EndNode/styled.d.ts +16 -0
  77. package/lib/modules/node/components/EndNode/styled.js +22 -0
  78. package/lib/modules/node/components/HubNode/index.d.ts +3 -0
  79. package/lib/modules/node/components/HubNode/index.js +8 -0
  80. package/lib/modules/node/components/HubNode/styled.d.ts +2 -0
  81. package/lib/modules/node/components/HubNode/styled.js +12 -0
  82. package/lib/modules/node/components/NodesMenu/index.d.ts +16 -0
  83. package/lib/modules/node/components/NodesMenu/index.js +41 -0
  84. package/lib/modules/node/components/NodesMenu/styled.d.ts +130 -0
  85. package/lib/modules/node/components/NodesMenu/styled.js +80 -0
  86. package/lib/modules/node/components/ParallelNode/index.d.ts +4 -0
  87. package/lib/modules/node/components/ParallelNode/index.js +22 -0
  88. package/lib/modules/node/components/ParallelNode/styled.d.ts +2 -0
  89. package/lib/modules/node/components/ParallelNode/styled.js +16 -0
  90. package/lib/modules/node/components/StartNode/index.d.ts +3 -0
  91. package/lib/modules/node/components/StartNode/index.js +8 -0
  92. package/lib/modules/node/components/StartNode/styled.d.ts +16 -0
  93. package/lib/modules/node/components/StartNode/styled.js +22 -0
  94. package/lib/modules/node/contexts/SettingsContext/index.d.ts +10 -0
  95. package/lib/modules/node/contexts/SettingsContext/index.js +49 -0
  96. package/lib/modules/node/contexts/SettingsContext/styled.d.ts +20 -0
  97. package/lib/modules/node/contexts/SettingsContext/styled.js +40 -0
  98. package/lib/modules/node/enums/index.d.ts +12 -0
  99. package/lib/modules/node/enums/index.js +17 -0
  100. package/lib/modules/node/index.d.ts +10 -0
  101. package/lib/modules/node/index.js +22 -0
  102. package/lib/modules/node/services/expandCoefficientServices.d.ts +24 -0
  103. package/lib/modules/node/services/expandCoefficientServices.js +52 -0
  104. package/lib/modules/node/services/nodeServices.d.ts +11 -0
  105. package/lib/modules/node/services/nodeServices.js +147 -0
  106. package/lib/modules/node/services/pointCalculationServices.d.ts +11 -0
  107. package/lib/modules/node/services/pointCalculationServices.js +22 -0
  108. package/lib/modules/node/types/index.d.ts +49 -0
  109. package/lib/modules/node/types/index.js +2 -0
  110. package/package.json +1 -1
@@ -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,4 @@
1
+ import { FC } from "react";
2
+ import { ConnectionPropsType } from "../../types";
3
+ declare const BaseConnection: FC<ConnectionPropsType>;
4
+ export default BaseConnection;
@@ -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,84 @@
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, emptyMenuItemsComponent, searchPlaceholder }) => {
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 - 400}px, ${top - 228}px)`,
59
+ overflow: 'visible',
60
+ };
61
+ setStyles(style);
62
+ setAnchorEl(true);
63
+ };
64
+ const isOpen = Boolean(anchorEl);
65
+ const props = (0, web_1.useSpring)({
66
+ borderColor: isProcessed ? colors_1.Colors.GREEN : colors_1.Colors.NAVY_BLUE,
67
+ config: {
68
+ duration: isProcessed ? 600 : 150
69
+ },
70
+ });
71
+ const AnimatedConnectionLine = (0, web_1.animated)(ConnectionLine);
72
+ const buttonProps = {
73
+ endPoint,
74
+ startPoint,
75
+ node,
76
+ curveType,
77
+ parentId,
78
+ childNodeId,
79
+ onClick: handleClick,
80
+ innerRef: popperRef
81
+ };
82
+ 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, emptyMenuItemsComponent: emptyMenuItemsComponent, searchPlaceholder: searchPlaceholder }) }) })] }));
83
+ };
84
+ 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,4 @@
1
+ export declare enum ConnectionCurveEnum {
2
+ RIGHT = "right",
3
+ LEFT = "left"
4
+ }
@@ -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,9 @@
1
+ import { FC } from "react";
2
+ import { ConnectionPropsType } from "./types";
3
+ type ModuleType = {
4
+ connections: {
5
+ [key: string]: FC<ConnectionPropsType>;
6
+ };
7
+ };
8
+ export declare const moduleConnection: ModuleType;
9
+ export {};
@@ -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,88 @@
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 }) => {
34
+ const drawerById = new Map(nodeDrawers.map((d) => [d.id, d]));
35
+ const drawerByNodeDataId = new Map(nodeDrawers.map((d) => [d.nodeData?.id, d]));
36
+ return nodeDrawers.reduce((connectionDrawers, nodeDrawer) => {
37
+ const childrenIds = nodeDrawer.nodeData?.childrenIds || [];
38
+ const children = childrenIds
39
+ .map((id) => drawerById.get(id))
40
+ .filter((d) => !!d);
41
+ if (!children.length)
42
+ return connectionDrawers;
43
+ const isNodeWithDoubleConnections = config_1.Config.NODES_WITH_DOUBLE_CONNECTION.includes(nodeDrawer.type);
44
+ if (isNodeWithDoubleConnections) {
45
+ const leftChild = drawerByNodeDataId.get(nodeDrawer.nodeData?.leftChildrenId);
46
+ const rightChild = drawerByNodeDataId.get(nodeDrawer.nodeData?.rightChildrenId);
47
+ const newConnectionDrawers = [
48
+ this.createDrawerConnection({
49
+ failedNodeId,
50
+ processedNodeIds,
51
+ nodeDrawer,
52
+ index: 1,
53
+ menuTabs,
54
+ child: leftChild,
55
+ addNewNodeCallback,
56
+ curveType: leftChild?.nodeData?.startSectionNodeId
57
+ ? enums_2.ConnectionCurveEnum.LEFT
58
+ : undefined,
59
+ }),
60
+ this.createDrawerConnection({
61
+ failedNodeId,
62
+ processedNodeIds,
63
+ nodeDrawer,
64
+ index: 2,
65
+ menuTabs,
66
+ child: rightChild,
67
+ addNewNodeCallback,
68
+ curveType: rightChild?.nodeData?.startSectionNodeId
69
+ ? enums_2.ConnectionCurveEnum.RIGHT
70
+ : undefined,
71
+ }),
72
+ ];
73
+ return [...connectionDrawers, ...newConnectionDrawers];
74
+ }
75
+ const newConnectionDrawers = children.map((child, index) => this.createDrawerConnection({
76
+ failedNodeId,
77
+ processedNodeIds,
78
+ nodeDrawer,
79
+ index: index + 1,
80
+ menuTabs,
81
+ child: child,
82
+ addNewNodeCallback,
83
+ }));
84
+ return [...connectionDrawers, ...newConnectionDrawers];
85
+ }, []);
86
+ };
87
+ }
88
+ exports.connectionServices = new ConnectionServices();
@@ -0,0 +1,44 @@
1
+ /// <reference types="react" />
2
+ import { MenuTabType, PointType } from '../../common/types';
3
+ import { AddNewNodeCallbackType } from '../../flow/types';
4
+ import { BaseDrawableNodeType, NodeType } from '../../node/types';
5
+ import { ConnectionCurveEnum } from '../enums';
6
+ export type NodeLinkType = {
7
+ nodeId: string;
8
+ branch: number;
9
+ };
10
+ export type ConnectionPropsType = {
11
+ startPoint: PointType;
12
+ endPoint: PointType;
13
+ parentId: string | undefined;
14
+ childNodeId: string;
15
+ menuTabs: MenuTabType[];
16
+ addNewNodeCallback?: AddNewNodeCallbackType;
17
+ connectionIndex: number;
18
+ node: NodeType;
19
+ curveType?: ConnectionCurveEnum;
20
+ isProcessed: boolean;
21
+ emptyMenuItemsComponent?: JSX.Element;
22
+ searchPlaceholder?: string;
23
+ };
24
+ export type ConnectionDrawerType = {
25
+ type: string;
26
+ connectionData: ConnectionPropsType;
27
+ };
28
+ export type CreateDrawerConnectionType = (props: {
29
+ menuTabs: MenuTabType[];
30
+ nodeDrawer: BaseDrawableNodeType;
31
+ child: BaseDrawableNodeType;
32
+ index: number;
33
+ addNewNodeCallback?: AddNewNodeCallbackType;
34
+ curveType?: ConnectionCurveEnum;
35
+ processedNodeIds: string[];
36
+ failedNodeId?: string;
37
+ }) => ConnectionDrawerType;
38
+ export type BuildConnectionsType = ({ nodeDrawers, menuTabs, addNewNodeCallback, }: {
39
+ processedNodeIds: string[];
40
+ failedNodeId?: string;
41
+ nodeDrawers: BaseDrawableNodeType[];
42
+ menuTabs: MenuTabType[];
43
+ addNewNodeCallback?: AddNewNodeCallbackType | undefined;
44
+ }) => ConnectionDrawerType[];
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,20 @@
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
+ emptyMenuItemsComponent?: JSX.Element;
17
+ searchPlaceholder?: string;
18
+ };
19
+ declare const FlowSandbox: FC<PropsType>;
20
+ export default FlowSandbox;