flow-lib-creomnia 1.0.17 → 1.0.19-dev.1

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.
@@ -49,7 +49,7 @@ const createAddButton = ({ background = colors_1.Colors.WHITE, x, y, }) => (0, s
49
49
  `;
50
50
  exports.createAddButton = createAddButton;
51
51
  exports.StyledPopper = (0, system_1.styled)(material_1.Popper) `
52
- z-index: 1000;
52
+ z-index: 1400;
53
53
  overflow: hidden;
54
54
  border-radius: 16px;
55
55
  `;
@@ -13,10 +13,11 @@ const ThemeContext_1 = require("../../../common/contexts/ThemeContext");
13
13
  const expandCoefficientServices_1 = require("../../../node/services/expandCoefficientServices");
14
14
  const material_1 = require("@mui/material");
15
15
  const FlowPosition_1 = require("../../context/FlowPosition");
16
+ const FlowActions_1 = require("../../context/FlowActions");
16
17
  const react_dnd_html5_backend_1 = require("react-dnd-html5-backend");
17
18
  const react_dnd_1 = require("react-dnd");
18
19
  const colors_1 = require("../../../../config/colors");
19
- const NodesFlow = ({ theme, nodes, menuTabs, addNewNodeCallback, permissions, drawerProps, processedNodeIds, failedNodeId, failedNodeColor, onRedirect, onUpdateNodePosition, emptyMenuItemsComponent, searchPlaceholder, }) => {
20
+ const NodesFlow = ({ theme, nodes, menuTabs, addNewNodeCallback, permissions, drawerProps, processedNodeIds, failedNodeId, failedNodeColor, onRedirect, onUpdateNodePosition, emptyMenuItemsComponent, searchPlaceholder, onStartClick, }) => {
20
21
  const nodeDrawers = (0, react_1.useMemo)(() => {
21
22
  const { startNodeList, nodeListWithEndNode } = nodeServices_1.nodeServices.createListOfStartNodesAndEndNodes(nodes);
22
23
  const nodeListWithExpandCoefficients = expandCoefficientServices_1.expandCoefficientServices.calculateNodeExpandCoefficient(nodeListWithEndNode);
@@ -31,6 +32,6 @@ const NodesFlow = ({ theme, nodes, menuTabs, addNewNodeCallback, permissions, dr
31
32
  addNewNodeCallback,
32
33
  }), [nodeDrawers, menuTabs, addNewNodeCallback, processedNodeIds]);
33
34
  const containerRef = (0, react_1.useRef)(null);
34
- return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: permissions.canRead && ((0, jsx_runtime_1.jsx)(ThemeContext_1.ThemeContextProvider, { themContextValue: theme, children: (0, jsx_runtime_1.jsx)(react_dnd_1.DndProvider, { backend: react_dnd_html5_backend_1.HTML5Backend, children: (0, jsx_runtime_1.jsx)(material_1.Box, { ref: containerRef, style: { position: "relative", height: "100%", width: "100%", background: theme?.palette.background.default || colors_1.Colors.DIRTY_WHITE }, children: (0, jsx_runtime_1.jsx)(SettingsContext_1.NodeSettingsProvider, { permissions: permissions, drawerProps: drawerProps, children: (0, jsx_runtime_1.jsx)(FlowPosition_1.FlowPositionProvider, { children: (0, jsx_runtime_1.jsx)(FlowSandbox_1.default, { permissions: permissions, connectionDrawers: connectionDrawers, nodeDrawers: nodeDrawers, containerRef: containerRef, processedNodeIds: processedNodeIds, failedNodeId: failedNodeId, failedNodeColor: failedNodeColor, onRedirect: onRedirect, onUpdateNodePosition: onUpdateNodePosition, emptyMenuItemsComponent: emptyMenuItemsComponent, searchPlaceholder: searchPlaceholder }) }) }) }) }) })) }));
35
+ return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: permissions.canRead && ((0, jsx_runtime_1.jsx)(ThemeContext_1.ThemeContextProvider, { themContextValue: theme, children: (0, jsx_runtime_1.jsx)(react_dnd_1.DndProvider, { backend: react_dnd_html5_backend_1.HTML5Backend, children: (0, jsx_runtime_1.jsx)(material_1.Box, { ref: containerRef, style: { position: "relative", height: "100%", width: "100%", background: theme?.palette.background.default || colors_1.Colors.DIRTY_WHITE }, children: (0, jsx_runtime_1.jsx)(SettingsContext_1.NodeSettingsProvider, { permissions: permissions, drawerProps: drawerProps, children: (0, jsx_runtime_1.jsx)(FlowActions_1.FlowActionsProvider, { onStartClick: onStartClick, children: (0, jsx_runtime_1.jsx)(FlowPosition_1.FlowPositionProvider, { children: (0, jsx_runtime_1.jsx)(FlowSandbox_1.default, { permissions: permissions, connectionDrawers: connectionDrawers, nodeDrawers: nodeDrawers, containerRef: containerRef, processedNodeIds: processedNodeIds, failedNodeId: failedNodeId, failedNodeColor: failedNodeColor, onRedirect: onRedirect, onUpdateNodePosition: onUpdateNodePosition, emptyMenuItemsComponent: emptyMenuItemsComponent, searchPlaceholder: searchPlaceholder }) }) }) }) }) }) })) }));
35
36
  };
36
37
  exports.default = NodesFlow;
@@ -0,0 +1,8 @@
1
+ import React, { FC, PropsWithChildren } from 'react';
2
+ type FlowActionsValue = {
3
+ onStartClick?: () => void;
4
+ };
5
+ declare const FlowActionsContext: React.Context<FlowActionsValue>;
6
+ type ProviderProps = PropsWithChildren & FlowActionsValue;
7
+ declare const FlowActionsProvider: FC<ProviderProps>;
8
+ export { FlowActionsContext, FlowActionsProvider };
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FlowActionsProvider = exports.FlowActionsContext = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const FlowActionsContext = (0, react_1.createContext)({});
7
+ exports.FlowActionsContext = FlowActionsContext;
8
+ const FlowActionsProvider = ({ children, onStartClick }) => ((0, jsx_runtime_1.jsx)(FlowActionsContext.Provider, { value: { onStartClick }, children: children }));
9
+ exports.FlowActionsProvider = FlowActionsProvider;
@@ -22,6 +22,7 @@ export type NodeFlowPropsType = {
22
22
  theme: Theme;
23
23
  emptyMenuItemsComponent?: JSX.Element;
24
24
  searchPlaceholder?: string;
25
+ onStartClick?: () => void;
25
26
  };
26
27
  export type IDrawerProps = {
27
28
  isOpen: boolean;
@@ -1,8 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const jsx_runtime_1 = require("react/jsx-runtime");
4
+ const react_1 = require("react");
4
5
  const styled_1 = require("./styled");
6
+ const FlowActions_1 = require("../../../flow/context/FlowActions");
5
7
  const StartNode = () => {
6
- return ((0, jsx_runtime_1.jsx)(styled_1.IconContainer, { children: (0, jsx_runtime_1.jsx)(styled_1.Icon, {}) }));
8
+ const { onStartClick } = (0, react_1.useContext)(FlowActions_1.FlowActionsContext);
9
+ const clickable = !!onStartClick;
10
+ return ((0, jsx_runtime_1.jsx)(styled_1.IconContainer, { onClick: onStartClick, role: clickable ? "button" : undefined, style: clickable ? { cursor: "pointer" } : undefined, children: (0, jsx_runtime_1.jsx)(styled_1.Icon, {}) }));
7
11
  };
8
12
  exports.default = StartNode;
@@ -47,8 +47,13 @@ const NodeSettingsProvider = ({ children, permissions: { canUpdate, canDelete },
47
47
  setInternalNodeBase(null);
48
48
  }, config_1.Config.CLEAR_NODE_DELAY);
49
49
  };
50
- const onSaveNode = () => {
51
- const result = node?.settings?.footer?.onSave?.(node?.id);
50
+ const onSaveNode = async () => {
51
+ // `onSave` is allowed to be sync OR async — host apps that wrap a
52
+ // server call in an async handler need to surface validation errors
53
+ // BEFORE the drawer closes. Awaiting handles both cases: a sync
54
+ // `false` short-circuits, a `Promise<false>` resolves and short-
55
+ // circuits, anything else closes the drawer.
56
+ const result = await node?.settings?.footer?.onSave?.(node?.id);
52
57
  if (result === false)
53
58
  return;
54
59
  handleClose();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flow-lib-creomnia",
3
- "version": "1.0.17",
3
+ "version": "1.0.19-dev.1",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",