@hitachivantara/uikit-react-lab 5.37.1 → 5.37.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Dashboard/Dashboard.cjs +3 -6
- package/dist/cjs/Flow/DroppableFlow.cjs +4 -8
- package/dist/cjs/Flow/Node/BaseNode.cjs +2 -4
- package/dist/cjs/Flow/Node/Parameters/ParamRenderer.cjs +1 -2
- package/dist/cjs/Flow/Node/Parameters/Select.cjs +1 -2
- package/dist/cjs/Flow/Node/Parameters/Slider.cjs +1 -2
- package/dist/cjs/Flow/Node/Parameters/Text.cjs +1 -2
- package/dist/cjs/Flow/Sidebar/Sidebar.cjs +1 -2
- package/dist/cjs/Flow/hooks/useFlowNode.cjs +1 -2
- package/dist/cjs/Flow/hooks/useNode.cjs +1 -2
- package/dist/cjs/StepNavigation/DefaultNavigation/Step/Step.cjs +20 -17
- package/dist/cjs/StepNavigation/StepNavigation.cjs +3 -4
- package/dist/cjs/Wizard/WizardActions/WizardActions.cjs +1 -2
- package/dist/cjs/Wizard/WizardContent/WizardContent.cjs +26 -21
- package/dist/cjs/Wizard/WizardTitle/WizardTitle.cjs +6 -12
- package/dist/esm/Dashboard/Dashboard.js +3 -6
- package/dist/esm/Dashboard/Dashboard.js.map +1 -1
- package/dist/esm/Flow/DroppableFlow.js +4 -8
- package/dist/esm/Flow/DroppableFlow.js.map +1 -1
- package/dist/esm/Flow/Node/BaseNode.js +2 -4
- package/dist/esm/Flow/Node/BaseNode.js.map +1 -1
- package/dist/esm/Flow/Node/Parameters/ParamRenderer.js +1 -2
- package/dist/esm/Flow/Node/Parameters/ParamRenderer.js.map +1 -1
- package/dist/esm/Flow/Node/Parameters/Select.js +1 -2
- package/dist/esm/Flow/Node/Parameters/Select.js.map +1 -1
- package/dist/esm/Flow/Node/Parameters/Slider.js +1 -2
- package/dist/esm/Flow/Node/Parameters/Slider.js.map +1 -1
- package/dist/esm/Flow/Node/Parameters/Text.js +1 -2
- package/dist/esm/Flow/Node/Parameters/Text.js.map +1 -1
- package/dist/esm/Flow/Sidebar/Sidebar.js +1 -2
- package/dist/esm/Flow/Sidebar/Sidebar.js.map +1 -1
- package/dist/esm/Flow/hooks/useFlowNode.js +1 -2
- package/dist/esm/Flow/hooks/useFlowNode.js.map +1 -1
- package/dist/esm/Flow/hooks/useNode.js +1 -2
- package/dist/esm/Flow/hooks/useNode.js.map +1 -1
- package/dist/esm/StepNavigation/DefaultNavigation/DefaultNavigation.js.map +1 -1
- package/dist/esm/StepNavigation/DefaultNavigation/Step/Step.js +20 -17
- package/dist/esm/StepNavigation/DefaultNavigation/Step/Step.js.map +1 -1
- package/dist/esm/StepNavigation/SimpleNavigation/SimpleNavigation.js.map +1 -1
- package/dist/esm/StepNavigation/StepNavigation.js +4 -5
- package/dist/esm/StepNavigation/StepNavigation.js.map +1 -1
- package/dist/esm/Wizard/Wizard.js.map +1 -1
- package/dist/esm/Wizard/WizardActions/WizardActions.js +1 -2
- package/dist/esm/Wizard/WizardActions/WizardActions.js.map +1 -1
- package/dist/esm/Wizard/WizardContainer/WizardContainer.js.map +1 -1
- package/dist/esm/Wizard/WizardContent/WizardContent.js +26 -21
- package/dist/esm/Wizard/WizardContent/WizardContent.js.map +1 -1
- package/dist/esm/Wizard/WizardContext/WizardContext.js.map +1 -1
- package/dist/esm/Wizard/WizardTitle/WizardTitle.js +6 -12
- package/dist/esm/Wizard/WizardTitle/WizardTitle.js.map +1 -1
- package/dist/types/index.d.ts +35 -38
- package/package.json +4 -4
|
@@ -27,15 +27,12 @@ const HvDashboard = (props) => {
|
|
|
27
27
|
const { classes, cx } = Dashboard_styles.useClasses(classesProp);
|
|
28
28
|
const { activeTheme } = uikitReactCore.useTheme();
|
|
29
29
|
const layouts = React.useMemo(() => {
|
|
30
|
-
if (layoutsProp)
|
|
31
|
-
|
|
32
|
-
if (!layout)
|
|
33
|
-
return {};
|
|
30
|
+
if (layoutsProp) return layoutsProp;
|
|
31
|
+
if (!layout) return {};
|
|
34
32
|
return { xs: layout, sm: layout, md: layout, lg: layout, xl: layout };
|
|
35
33
|
}, [layoutsProp, layout]);
|
|
36
34
|
const cols = React.useMemo(() => {
|
|
37
|
-
if (!colsProp)
|
|
38
|
-
return defaultCols;
|
|
35
|
+
if (!colsProp) return defaultCols;
|
|
39
36
|
if (typeof colsProp === "number") {
|
|
40
37
|
return {
|
|
41
38
|
xs: colsProp,
|
|
@@ -23,16 +23,13 @@ const validateEdge = (nodes, edges, connection, nodeMetaRegistry) => {
|
|
|
23
23
|
target: targetId,
|
|
24
24
|
targetHandle
|
|
25
25
|
} = connection;
|
|
26
|
-
if (!sourceHandle || !targetHandle || !sourceId || !targetId)
|
|
27
|
-
return false;
|
|
26
|
+
if (!sourceHandle || !targetHandle || !sourceId || !targetId) return false;
|
|
28
27
|
const sourceNode = getNode(nodes, sourceId);
|
|
29
28
|
const targetNode = getNode(nodes, targetId);
|
|
30
|
-
if (!sourceNode || !targetNode)
|
|
31
|
-
return false;
|
|
29
|
+
if (!sourceNode || !targetNode) return false;
|
|
32
30
|
const sourceType = sourceNode.type;
|
|
33
31
|
const targetType = targetNode.type;
|
|
34
|
-
if (!sourceType || !targetType)
|
|
35
|
-
return false;
|
|
32
|
+
if (!sourceType || !targetType) return false;
|
|
36
33
|
const inputs = nodeMetaRegistry[targetId]?.inputs || [];
|
|
37
34
|
const outputs = nodeMetaRegistry[sourceId]?.outputs || [];
|
|
38
35
|
const source = outputs.flatMap((out) => out.outputs || out).find((out) => out.id === sourceHandle);
|
|
@@ -92,8 +89,7 @@ const HvDroppableFlow = ({
|
|
|
92
89
|
});
|
|
93
90
|
const handleDragEnd = React.useCallback(
|
|
94
91
|
(event) => {
|
|
95
|
-
if (event.over?.id !== elementId)
|
|
96
|
-
return;
|
|
92
|
+
if (event.over?.id !== elementId) return;
|
|
97
93
|
const hvFlow = event.active.data.current?.hvFlow;
|
|
98
94
|
const type = hvFlow?.type;
|
|
99
95
|
if (!type || !nodeTypes?.[type]) {
|
|
@@ -91,8 +91,7 @@ const HvFlowBaseNode = ({
|
|
|
91
91
|
input.isMandatory && !edgeConnected && /* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.mandatory })
|
|
92
92
|
] }, input.id);
|
|
93
93
|
};
|
|
94
|
-
if (!node)
|
|
95
|
-
return null;
|
|
94
|
+
if (!node) return null;
|
|
96
95
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
97
96
|
"div",
|
|
98
97
|
{
|
|
@@ -147,8 +146,7 @@ const HvFlowBaseNode = ({
|
|
|
147
146
|
inputs && inputs.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
148
147
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.inputsTitleContainer, children: /* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvTypography, { children: labels?.inputsTitle }) }),
|
|
149
148
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.inputsContainer, children: inputs?.map((input, idx) => {
|
|
150
|
-
if (!utils.isInputGroup(input))
|
|
151
|
-
return renderInput(input);
|
|
149
|
+
if (!utils.isInputGroup(input)) return renderInput(input);
|
|
152
150
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
153
151
|
"div",
|
|
154
152
|
{
|
|
@@ -12,8 +12,7 @@ const renderers = {
|
|
|
12
12
|
const ParamRenderer = ({ params, data }) => {
|
|
13
13
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: params.map((param, idx) => {
|
|
14
14
|
const Renderer = renderers[param.type];
|
|
15
|
-
if (!Renderer)
|
|
16
|
-
return null;
|
|
15
|
+
if (!Renderer) return null;
|
|
17
16
|
return /* @__PURE__ */ jsxRuntime.jsx(Renderer, { param, data }, idx);
|
|
18
17
|
}) });
|
|
19
18
|
};
|
|
@@ -50,8 +50,7 @@ const HvFlowSidebar = ({
|
|
|
50
50
|
onDragStart: handleDragStart
|
|
51
51
|
});
|
|
52
52
|
const filteredGroups = React.useMemo(() => {
|
|
53
|
-
if (!filterValue || !nodeGroups)
|
|
54
|
-
return nodeGroups || {};
|
|
53
|
+
if (!filterValue || !nodeGroups) return nodeGroups || {};
|
|
55
54
|
return filterValue ? Object.entries(nodeGroups).reduce(
|
|
56
55
|
(acc, [groupId, group]) => {
|
|
57
56
|
const filteredItems = (group.items || []).filter(
|
|
@@ -70,8 +70,7 @@ function useFlowNodeUtils(id) {
|
|
|
70
70
|
const reactFlowInstance = useFlowInstance.useFlowInstance();
|
|
71
71
|
const setNodeData = React.useCallback(
|
|
72
72
|
(setNewData) => {
|
|
73
|
-
if (!nodeId)
|
|
74
|
-
return;
|
|
73
|
+
if (!nodeId) return;
|
|
75
74
|
reactFlowInstance.setNodes((nodes) => {
|
|
76
75
|
return nodes.map((n) => {
|
|
77
76
|
if (n.id === nodeId) {
|
|
@@ -77,8 +77,7 @@ function useHvNode(props) {
|
|
|
77
77
|
}, [id, title, inputs, outputs, registerNode, unregisterNode]);
|
|
78
78
|
const handleDefaultAction = React.useCallback(
|
|
79
79
|
(action) => {
|
|
80
|
-
if (!node)
|
|
81
|
-
return;
|
|
80
|
+
if (!node) return;
|
|
82
81
|
if (action.callback) {
|
|
83
82
|
action.callback(node);
|
|
84
83
|
return;
|
|
@@ -5,6 +5,23 @@ const uikitReactCore = require("@hitachivantara/uikit-react-core");
|
|
|
5
5
|
const uikitReactIcons = require("@hitachivantara/uikit-react-icons");
|
|
6
6
|
const utils = require("../utils.cjs");
|
|
7
7
|
const Step_styles = require("./Step.styles.cjs");
|
|
8
|
+
const iconSizeObject = {
|
|
9
|
+
xs: "XS",
|
|
10
|
+
sm: "XS",
|
|
11
|
+
md: "S",
|
|
12
|
+
lg: "M",
|
|
13
|
+
xl: "M"
|
|
14
|
+
};
|
|
15
|
+
const stateObject = {
|
|
16
|
+
Pending: 16,
|
|
17
|
+
Failed: 24,
|
|
18
|
+
Completed: 24
|
|
19
|
+
};
|
|
20
|
+
const iconStateObject = {
|
|
21
|
+
Pending: uikitReactIcons.HourGlass,
|
|
22
|
+
Failed: uikitReactIcons.Level3Bad,
|
|
23
|
+
Completed: uikitReactIcons.Level0Good
|
|
24
|
+
};
|
|
8
25
|
const HvStep = ({
|
|
9
26
|
className,
|
|
10
27
|
classes: classesProp,
|
|
@@ -16,18 +33,8 @@ const HvStep = ({
|
|
|
16
33
|
number = 1
|
|
17
34
|
}) => {
|
|
18
35
|
const { classes, cx } = Step_styles.useClasses(classesProp);
|
|
19
|
-
const iconSize =
|
|
20
|
-
|
|
21
|
-
sm: "XS",
|
|
22
|
-
md: "S",
|
|
23
|
-
ml: "M",
|
|
24
|
-
xl: "M"
|
|
25
|
-
}[size];
|
|
26
|
-
const squareL = {
|
|
27
|
-
Pending: 16,
|
|
28
|
-
Failed: 24,
|
|
29
|
-
Completed: 24
|
|
30
|
-
}[state];
|
|
36
|
+
const iconSize = iconSizeObject[size];
|
|
37
|
+
const squareL = stateObject[state];
|
|
31
38
|
const svgSize = {
|
|
32
39
|
xs: squareL - 8,
|
|
33
40
|
sm: squareL,
|
|
@@ -39,11 +46,7 @@ const HvStep = ({
|
|
|
39
46
|
const color = state === "Pending" ? "atmo2" : void 0;
|
|
40
47
|
const semantic = state !== "Pending" ? utils.getSemantic(state) : void 0;
|
|
41
48
|
const status = state === "Current" ? "secondary_60" : void 0;
|
|
42
|
-
const IconComponent =
|
|
43
|
-
Pending: uikitReactIcons.HourGlass,
|
|
44
|
-
Failed: uikitReactIcons.Level3Bad,
|
|
45
|
-
Completed: uikitReactIcons.Level0Good
|
|
46
|
-
}[state];
|
|
49
|
+
const IconComponent = iconStateObject[state];
|
|
47
50
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
48
51
|
"div",
|
|
49
52
|
{
|
|
@@ -136,11 +136,11 @@ const HvStepNavigation = ({
|
|
|
136
136
|
title = rawTitle,
|
|
137
137
|
titleWidth = 0,
|
|
138
138
|
titleDisabled = false
|
|
139
|
-
} = getTitleProps({
|
|
139
|
+
} = getTitleProps?.({
|
|
140
140
|
state,
|
|
141
141
|
rawTitle,
|
|
142
142
|
number: index + 1
|
|
143
|
-
});
|
|
143
|
+
}) ?? {};
|
|
144
144
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
145
145
|
uikitReactCore.HvTypography,
|
|
146
146
|
{
|
|
@@ -173,9 +173,8 @@ const HvStepNavigation = ({
|
|
|
173
173
|
className: cx(classes.root, className),
|
|
174
174
|
...others,
|
|
175
175
|
children: ({ stepsWidth, navWidth, ...itemsProps }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
176
|
-
|
|
176
|
+
"nav",
|
|
177
177
|
{
|
|
178
|
-
component: "nav",
|
|
179
178
|
style: {
|
|
180
179
|
width: `${navWidth}px`,
|
|
181
180
|
margin: 0
|
|
@@ -57,8 +57,7 @@ const HvWizardActions = ({
|
|
|
57
57
|
[handleSubmit, context]
|
|
58
58
|
);
|
|
59
59
|
const nextDisabled = React.useMemo(() => {
|
|
60
|
-
if (loading)
|
|
61
|
-
return true;
|
|
60
|
+
if (loading) return true;
|
|
62
61
|
return !skippable && !context?.[tab]?.valid;
|
|
63
62
|
}, [context, loading, skippable, tab]);
|
|
64
63
|
return /* @__PURE__ */ jsxRuntime.jsxs(uikitReactCore.HvDialogActions, { className: classes.actionsContainer, children: [
|
|
@@ -20,27 +20,29 @@ const HvWizardContent = ({
|
|
|
20
20
|
const { classes, cx } = WizardContent_styles.useClasses(classesProp);
|
|
21
21
|
const { context, setContext, summary, tab } = React.useContext(WizardContext.default);
|
|
22
22
|
const arrayChildren = React__default.default.Children.toArray(children);
|
|
23
|
-
const initialContext = arrayChildren.reduce(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
const initialContext = arrayChildren.reduce(
|
|
24
|
+
(acc, child, index) => {
|
|
25
|
+
const invalid = "mustValidate" in child.props && child.props.mustValidate === true ? false : null;
|
|
26
|
+
const valid = invalid ?? (index === 0 || null);
|
|
27
|
+
acc[index] = { ...child.props, form: {}, valid, touched: index === 0 };
|
|
28
|
+
return acc;
|
|
29
|
+
},
|
|
30
|
+
{}
|
|
31
|
+
);
|
|
29
32
|
const summaryRef = React.useRef();
|
|
30
33
|
const resizedRef = React.useRef({ height: 0, width: 0 });
|
|
31
34
|
const [containerRef, sizes] = usehooksTs.useElementSize();
|
|
32
35
|
const [summaryHeight, setSummaryHeight] = React.useState(0);
|
|
33
36
|
const [summaryWidth, setSummaryWidth] = React.useState(0);
|
|
34
37
|
const [summaryLeft, setSummaryLeft] = React.useState(0);
|
|
35
|
-
const updateSummaryMeasures = React.useCallback((
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
setSummaryHeight(newSizes.height);
|
|
38
|
+
const updateSummaryMeasures = React.useCallback(({ height = 0, width = 0 }) => {
|
|
39
|
+
const drawerWidth = width * DRAWER_PERCENTAGE;
|
|
40
|
+
setSummaryHeight(height);
|
|
39
41
|
setSummaryWidth(Math.max(drawerWidth, DRAWER_MIN_WIDTH));
|
|
40
|
-
setSummaryLeft(
|
|
42
|
+
setSummaryLeft(width - Math.max(drawerWidth, DRAWER_MIN_WIDTH));
|
|
41
43
|
resizedRef.current = {
|
|
42
|
-
height
|
|
43
|
-
width
|
|
44
|
+
height,
|
|
45
|
+
width
|
|
44
46
|
};
|
|
45
47
|
}, []);
|
|
46
48
|
React.useEffect(() => {
|
|
@@ -61,14 +63,17 @@ const HvWizardContent = ({
|
|
|
61
63
|
React.useEffect(() => {
|
|
62
64
|
if (tab && !context[tab]?.touched) {
|
|
63
65
|
setContext(
|
|
64
|
-
(oldContext) => Object.entries(oldContext).reduce(
|
|
65
|
-
acc[key]
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
66
|
+
(oldContext) => Object.entries(oldContext).reduce(
|
|
67
|
+
(acc, [key, childState]) => {
|
|
68
|
+
acc[Number(key)] = +key <= tab ? {
|
|
69
|
+
...childState,
|
|
70
|
+
touched: true,
|
|
71
|
+
valid: childState?.valid ?? true
|
|
72
|
+
} : childState;
|
|
73
|
+
return acc;
|
|
74
|
+
},
|
|
75
|
+
{}
|
|
76
|
+
)
|
|
72
77
|
);
|
|
73
78
|
}
|
|
74
79
|
}, [tab, context, setContext]);
|
|
@@ -8,18 +8,12 @@ const WizardTitle_styles = require("./WizardTitle.styles.cjs");
|
|
|
8
8
|
const WizardContext = require("../WizardContext/WizardContext.cjs");
|
|
9
9
|
const StepNavigation = require("../../StepNavigation/StepNavigation.cjs");
|
|
10
10
|
const switchTabState = (state, currentTab, index) => {
|
|
11
|
-
if (state
|
|
12
|
-
|
|
13
|
-
if (
|
|
14
|
-
|
|
15
|
-
if (state
|
|
16
|
-
|
|
17
|
-
if (state.disabled)
|
|
18
|
-
return "Disabled";
|
|
19
|
-
if (state.valid === null)
|
|
20
|
-
return "Enabled";
|
|
21
|
-
if (state.touched && state.valid === false)
|
|
22
|
-
return "Failed";
|
|
11
|
+
if (state?.loading) return "Pending";
|
|
12
|
+
if (index === currentTab) return "Current";
|
|
13
|
+
if (state?.valid) return "Completed";
|
|
14
|
+
if (state?.disabled) return "Disabled";
|
|
15
|
+
if (state?.valid === null) return "Enabled";
|
|
16
|
+
if (state?.touched && state?.valid === false) return "Failed";
|
|
23
17
|
return "Enabled";
|
|
24
18
|
};
|
|
25
19
|
const HvWizardTitle = ({
|
|
@@ -26,15 +26,12 @@ const HvDashboard = (props) => {
|
|
|
26
26
|
const { classes, cx } = useClasses(classesProp);
|
|
27
27
|
const { activeTheme } = useTheme();
|
|
28
28
|
const layouts = useMemo(() => {
|
|
29
|
-
if (layoutsProp)
|
|
30
|
-
|
|
31
|
-
if (!layout)
|
|
32
|
-
return {};
|
|
29
|
+
if (layoutsProp) return layoutsProp;
|
|
30
|
+
if (!layout) return {};
|
|
33
31
|
return { xs: layout, sm: layout, md: layout, lg: layout, xl: layout };
|
|
34
32
|
}, [layoutsProp, layout]);
|
|
35
33
|
const cols = useMemo(() => {
|
|
36
|
-
if (!colsProp)
|
|
37
|
-
return defaultCols;
|
|
34
|
+
if (!colsProp) return defaultCols;
|
|
38
35
|
if (typeof colsProp === "number") {
|
|
39
36
|
return {
|
|
40
37
|
xs: colsProp,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dashboard.js","sources":["../../../src/Dashboard/Dashboard.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport {\n Layouts,\n ReactGridLayoutProps,\n Responsive as ResponsiveGrid,\n ResponsiveProps,\n WidthProvider,\n} from \"react-grid-layout\";\nimport { Global } from \"@emotion/react\";\nimport {\n ExtractNames,\n useDefaultProps,\n useTheme,\n} from \"@hitachivantara/uikit-react-core\";\n\nimport { gridStyles, staticClasses, useClasses } from \"./Dashboard.styles\";\n\nconst GridLayout = WidthProvider(ResponsiveGrid);\n\n/** Default column breakpoints. For now, use always 12-column */\nconst defaultCols: HvDashboardProps[\"cols\"] = {\n xs: 12,\n sm: 12,\n md: 12,\n lg: 12,\n xl: 12,\n};\n\nexport { staticClasses as dashboardClasses };\n\nexport type HvDashboardClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvDashboardProps extends Omit<ResponsiveProps, \"cols\"> {\n /** Dashboard items. Each node must be `key`'ed */\n children: React.ReactNode;\n /** An object used to override or extend the styles applied. */\n classes?: HvDashboardClasses;\n /**\n * Layout is an array of object with the format:\n *\n * `{i: string, x: number, y: number, w: number, h: number}`\n *\n * The `i` must match the key used on each item component.\n */\n layout?: ReactGridLayoutProps[\"layout\"];\n /** Number of grid columns or an object of breakpoint -> #columns */\n cols?: number | ResponsiveProps[\"cols\"];\n}\n\n/**\n * A Dashboard grid layout component, based on `react-grid-layout`.\n * The children elements are grid items and must be `key`ed.\n *\n * @see https://github.com/react-grid-layout/react-grid-layout?tab=readme-ov-file#grid-layout-props\n *\n * DISCLAIMER: This component is a work in progress and there might be breaking changes.\n */\nexport const HvDashboard = (props: HvDashboardProps) => {\n const {\n children,\n className,\n layout,\n cols: colsProp,\n layouts: layoutsProp,\n classes: classesProp,\n ...others\n } = useDefaultProps(\"HvDashboard\", props);\n const { classes, cx } = useClasses(classesProp);\n const { activeTheme } = useTheme();\n\n const layouts = useMemo<Layouts>(() => {\n if (layoutsProp) return layoutsProp;\n if (!layout) return {};\n\n return { xs: layout, sm: layout, md: layout, lg: layout, xl: layout };\n }, [layoutsProp, layout]);\n\n const cols = useMemo<ResponsiveProps[\"cols\"]>(() => {\n if (!colsProp) return defaultCols;\n\n if (typeof colsProp === \"number\") {\n return {\n xs: colsProp,\n sm: colsProp,\n md: colsProp,\n lg: colsProp,\n xl: colsProp,\n };\n }\n\n return colsProp;\n }, [colsProp]);\n\n return (\n <>\n <Global styles={gridStyles} />\n <GridLayout\n className={cx(classes.root, className)}\n breakpoints={activeTheme?.breakpoints.values}\n cols={cols}\n layouts={layouts}\n {...others}\n >\n {children}\n </GridLayout>\n </>\n );\n};\n"],"names":["ResponsiveGrid"],"mappings":";;;;;;;AAiBA,MAAM,aAAa,cAAcA,UAAc;AAG/C,MAAM,cAAwC;AAAA,EAC5C,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AA+Ba,MAAA,cAAc,CAAC,UAA4B;AAChD,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN,SAAS;AAAA,IACT,SAAS;AAAA,IACT,GAAG;AAAA,EAAA,IACD,gBAAgB,eAAe,KAAK;AACxC,QAAM,EAAE,SAAS,GAAG,IAAI,WAAW,WAAW;AACxC,QAAA,EAAE,gBAAgB;AAElB,QAAA,UAAU,QAAiB,MAAM;
|
|
1
|
+
{"version":3,"file":"Dashboard.js","sources":["../../../src/Dashboard/Dashboard.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport {\n Layouts,\n ReactGridLayoutProps,\n Responsive as ResponsiveGrid,\n ResponsiveProps,\n WidthProvider,\n} from \"react-grid-layout\";\nimport { Global } from \"@emotion/react\";\nimport {\n ExtractNames,\n useDefaultProps,\n useTheme,\n} from \"@hitachivantara/uikit-react-core\";\n\nimport { gridStyles, staticClasses, useClasses } from \"./Dashboard.styles\";\n\nconst GridLayout = WidthProvider(ResponsiveGrid);\n\n/** Default column breakpoints. For now, use always 12-column */\nconst defaultCols: HvDashboardProps[\"cols\"] = {\n xs: 12,\n sm: 12,\n md: 12,\n lg: 12,\n xl: 12,\n};\n\nexport { staticClasses as dashboardClasses };\n\nexport type HvDashboardClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvDashboardProps extends Omit<ResponsiveProps, \"cols\"> {\n /** Dashboard items. Each node must be `key`'ed */\n children: React.ReactNode;\n /** An object used to override or extend the styles applied. */\n classes?: HvDashboardClasses;\n /**\n * Layout is an array of object with the format:\n *\n * `{i: string, x: number, y: number, w: number, h: number}`\n *\n * The `i` must match the key used on each item component.\n */\n layout?: ReactGridLayoutProps[\"layout\"];\n /** Number of grid columns or an object of breakpoint -> #columns */\n cols?: number | ResponsiveProps[\"cols\"];\n}\n\n/**\n * A Dashboard grid layout component, based on `react-grid-layout`.\n * The children elements are grid items and must be `key`ed.\n *\n * @see https://github.com/react-grid-layout/react-grid-layout?tab=readme-ov-file#grid-layout-props\n *\n * DISCLAIMER: This component is a work in progress and there might be breaking changes.\n */\nexport const HvDashboard = (props: HvDashboardProps) => {\n const {\n children,\n className,\n layout,\n cols: colsProp,\n layouts: layoutsProp,\n classes: classesProp,\n ...others\n } = useDefaultProps(\"HvDashboard\", props);\n const { classes, cx } = useClasses(classesProp);\n const { activeTheme } = useTheme();\n\n const layouts = useMemo<Layouts>(() => {\n if (layoutsProp) return layoutsProp;\n if (!layout) return {};\n\n return { xs: layout, sm: layout, md: layout, lg: layout, xl: layout };\n }, [layoutsProp, layout]);\n\n const cols = useMemo<ResponsiveProps[\"cols\"]>(() => {\n if (!colsProp) return defaultCols;\n\n if (typeof colsProp === \"number\") {\n return {\n xs: colsProp,\n sm: colsProp,\n md: colsProp,\n lg: colsProp,\n xl: colsProp,\n };\n }\n\n return colsProp;\n }, [colsProp]);\n\n return (\n <>\n <Global styles={gridStyles} />\n <GridLayout\n className={cx(classes.root, className)}\n breakpoints={activeTheme?.breakpoints.values}\n cols={cols}\n layouts={layouts}\n {...others}\n >\n {children}\n </GridLayout>\n </>\n );\n};\n"],"names":["ResponsiveGrid"],"mappings":";;;;;;;AAiBA,MAAM,aAAa,cAAcA,UAAc;AAG/C,MAAM,cAAwC;AAAA,EAC5C,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AA+Ba,MAAA,cAAc,CAAC,UAA4B;AAChD,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN,SAAS;AAAA,IACT,SAAS;AAAA,IACT,GAAG;AAAA,EAAA,IACD,gBAAgB,eAAe,KAAK;AACxC,QAAM,EAAE,SAAS,GAAG,IAAI,WAAW,WAAW;AACxC,QAAA,EAAE,gBAAgB;AAElB,QAAA,UAAU,QAAiB,MAAM;AACrC,QAAI,YAAoB,QAAA;AACpB,QAAA,CAAC,OAAQ,QAAO;AAEb,WAAA,EAAE,IAAI,QAAQ,IAAI,QAAQ,IAAI,QAAQ,IAAI,QAAQ,IAAI,OAAO;AAAA,EAAA,GACnE,CAAC,aAAa,MAAM,CAAC;AAElB,QAAA,OAAO,QAAiC,MAAM;AAC9C,QAAA,CAAC,SAAiB,QAAA;AAElB,QAAA,OAAO,aAAa,UAAU;AACzB,aAAA;AAAA,QACL,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,MAAA;AAAA,IAER;AAEO,WAAA;AAAA,EAAA,GACN,CAAC,QAAQ,CAAC;AAEb,SAEI,qBAAA,UAAA,EAAA,UAAA;AAAA,IAAC,oBAAA,QAAA,EAAO,QAAQ,WAAY,CAAA;AAAA,IAC5B;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,WAAW,GAAG,QAAQ,MAAM,SAAS;AAAA,QACrC,aAAa,aAAa,YAAY;AAAA,QACtC;AAAA,QACA;AAAA,QACC,GAAG;AAAA,QAEH;AAAA,MAAA;AAAA,IACH;AAAA,EACF,EAAA,CAAA;AAEJ;"}
|
|
@@ -20,16 +20,13 @@ const validateEdge = (nodes, edges, connection, nodeMetaRegistry) => {
|
|
|
20
20
|
target: targetId,
|
|
21
21
|
targetHandle
|
|
22
22
|
} = connection;
|
|
23
|
-
if (!sourceHandle || !targetHandle || !sourceId || !targetId)
|
|
24
|
-
return false;
|
|
23
|
+
if (!sourceHandle || !targetHandle || !sourceId || !targetId) return false;
|
|
25
24
|
const sourceNode = getNode(nodes, sourceId);
|
|
26
25
|
const targetNode = getNode(nodes, targetId);
|
|
27
|
-
if (!sourceNode || !targetNode)
|
|
28
|
-
return false;
|
|
26
|
+
if (!sourceNode || !targetNode) return false;
|
|
29
27
|
const sourceType = sourceNode.type;
|
|
30
28
|
const targetType = targetNode.type;
|
|
31
|
-
if (!sourceType || !targetType)
|
|
32
|
-
return false;
|
|
29
|
+
if (!sourceType || !targetType) return false;
|
|
33
30
|
const inputs = nodeMetaRegistry[targetId]?.inputs || [];
|
|
34
31
|
const outputs = nodeMetaRegistry[sourceId]?.outputs || [];
|
|
35
32
|
const source = outputs.flatMap((out) => out.outputs || out).find((out) => out.id === sourceHandle);
|
|
@@ -89,8 +86,7 @@ const HvDroppableFlow = ({
|
|
|
89
86
|
});
|
|
90
87
|
const handleDragEnd = useCallback(
|
|
91
88
|
(event) => {
|
|
92
|
-
if (event.over?.id !== elementId)
|
|
93
|
-
return;
|
|
89
|
+
if (event.over?.id !== elementId) return;
|
|
94
90
|
const hvFlow = event.active.data.current?.hvFlow;
|
|
95
91
|
const type = hvFlow?.type;
|
|
96
92
|
if (!type || !nodeTypes?.[type]) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DroppableFlow.js","sources":["../../../src/Flow/DroppableFlow.tsx"],"sourcesContent":["import { useCallback, useRef, useState } from \"react\";\nimport { DragEndEvent, useDndMonitor, useDroppable } from \"@dnd-kit/core\";\nimport { Global } from \"@emotion/react\";\nimport ReactFlow, {\n addEdge,\n applyEdgeChanges,\n applyNodeChanges,\n Connection,\n Edge,\n EdgeChange,\n MarkerType,\n Node,\n NodeChange,\n ReactFlowProps,\n} from \"reactflow\";\nimport { uid } from \"uid\";\nimport { ExtractNames, useUniqueId } from \"@hitachivantara/uikit-react-core\";\n\nimport { flowStyles } from \"./base\";\nimport { staticClasses, useClasses } from \"./Flow.styles\";\nimport { useNodeMetaRegistry } from \"./FlowContext/NodeMetaContext\";\nimport { useFlowInstance } from \"./hooks\";\nimport {\n HvFlowNodeInputGroup,\n HvFlowNodeMetaRegistry,\n HvFlowNodeOutputGroup,\n HvFlowNodeTypes,\n} from \"./types\";\n\nexport { staticClasses as flowClasses };\n\nexport type HvFlowClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvDroppableFlowProps<\n NodeType extends string | undefined = string | undefined,\n NodeData = any,\n> extends Omit<ReactFlowProps, \"nodes\" | \"edges\" | \"nodeTypes\"> {\n /** Flow content: background, controls, and minimap. */\n children?: React.ReactNode;\n /** Flow nodes types. */\n nodeTypes?: HvFlowNodeTypes<NodeData>;\n /** Flow nodes. */\n nodes?: Node<NodeData, NodeType>[];\n /** Flow edges. */\n edges?: Edge[];\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvFlowClasses;\n /** Callback called when the flow changes. Returns the updated nodes and edges. */\n onFlowChange?: (nodes: Node<NodeData, NodeType>[], edges: Edge[]) => void;\n /**\n * Callback called when a node is dropped in the flow.\n *\n * This callback should be used to override the custom UI Kit drop event.\n * Thus, when defined, the user is responsible for adding nodes to the flow.\n *\n * This callback is called when `HvFlowSidebar` is used or a custom sidebar was created using Dnd Kit.\n * When a custom sidebar was created using the native HTML drag and drop API, refer to the `onDrop` callback.\n *\n * Returns the event and the node to be added to the flow.\n */\n onDndDrop?: (event: DragEndEvent, node: Node) => void;\n}\n\nexport const getNode = (nodes: Node[], nodeId: string) => {\n return nodes.find((n) => n.id === nodeId);\n};\n\nconst validateEdge = (\n nodes: Node[],\n edges: Edge[],\n connection: Connection,\n nodeMetaRegistry: HvFlowNodeMetaRegistry,\n) => {\n const {\n source: sourceId,\n sourceHandle,\n target: targetId,\n targetHandle,\n } = connection;\n\n if (!sourceHandle || !targetHandle || !sourceId || !targetId) return false;\n\n const sourceNode = getNode(nodes, sourceId);\n const targetNode = getNode(nodes, targetId);\n\n if (!sourceNode || !targetNode) return false;\n\n const sourceType = sourceNode.type;\n const targetType = targetNode.type;\n\n if (!sourceType || !targetType) return false;\n\n const inputs = nodeMetaRegistry[targetId]?.inputs || [];\n const outputs = nodeMetaRegistry[sourceId]?.outputs || [];\n\n const source = outputs\n .flatMap((out) => (out as HvFlowNodeOutputGroup).outputs || out)\n .find((out) => out.id === sourceHandle);\n const target = inputs\n .flatMap((inp) => (inp as HvFlowNodeInputGroup).inputs || inp)\n .find((inp) => inp.id === targetHandle);\n\n const sourceProvides = source?.provides || \"\";\n const targetAccepts = target?.accepts || [];\n const sourceMaxConnections = source?.maxConnections;\n const targetMaxConnections = target?.maxConnections;\n\n let isValid =\n targetAccepts.length === 0 || targetAccepts.includes(sourceProvides);\n\n if (isValid && targetMaxConnections != null) {\n const targetConnections = edges.filter(\n (edg) => edg.target === targetId && edg.targetHandle === targetHandle,\n ).length;\n\n isValid = targetConnections < targetMaxConnections;\n }\n\n if (isValid && sourceMaxConnections != null) {\n const sourceConnections = edges.filter(\n (edg) => edg.source === sourceId && edg.sourceHandle === sourceHandle,\n ).length;\n\n isValid = sourceConnections < sourceMaxConnections;\n }\n\n return isValid;\n};\n\nexport const HvDroppableFlow = ({\n id,\n className,\n children,\n onFlowChange,\n onDndDrop,\n classes: classesProp,\n nodes: initialNodes = [],\n edges: initialEdges = [],\n onConnect: onConnectProp,\n onNodesChange: onNodesChangeProp,\n onEdgesChange: onEdgesChangeProp,\n defaultEdgeOptions: defaultEdgeOptionsProp,\n nodeTypes,\n ...others\n}: HvDroppableFlowProps) => {\n const { classes, cx } = useClasses(classesProp);\n\n const elementId = useUniqueId(id);\n\n const reactFlowInstance = useFlowInstance();\n\n const [nodes, setNodes] = useState(initialNodes);\n const [edges, setEdges] = useState(initialEdges);\n // Keeping track of nodes and edges for onFlowChange since useState is async\n const nodesRef = useRef(initialNodes);\n const edgesRef = useRef(initialEdges);\n\n const updateNodes = (nds: Node[]) => {\n setNodes(nds);\n nodesRef.current = nds;\n };\n\n const updateEdges = (eds: Edge[]) => {\n setEdges(eds);\n edgesRef.current = eds;\n };\n\n const { setNodeRef } = useDroppable({\n id: elementId,\n });\n\n const handleDragEnd = useCallback(\n (event: DragEndEvent) => {\n if (event.over?.id !== elementId) return;\n\n const hvFlow = event.active.data.current?.hvFlow;\n const type = hvFlow?.type;\n\n // Only known node types can be dropped in the canvas\n if (!type || !nodeTypes?.[type]) {\n if (import.meta.env.DEV) {\n // eslint-disable-next-line no-console\n console.error(\n `Could not add node to the flow because of unknown type ${type}. Use nodeTypes to define all the node types.`,\n );\n }\n return;\n }\n\n // Position node in the flow\n const position = reactFlowInstance.screenToFlowPosition({\n x: hvFlow?.x || 0,\n y: hvFlow?.y || 0,\n });\n\n // Node data\n const data = {\n nodeLabel: hvFlow?.label,\n ...hvFlow?.data,\n };\n\n // Node to add\n const newNode: Node = {\n id: uid(),\n position,\n data,\n type,\n };\n\n // Drop override\n if (onDndDrop) {\n onDndDrop(event, newNode);\n return;\n }\n\n updateNodes(nodes.concat(newNode));\n },\n [elementId, nodeTypes, nodes, onDndDrop, reactFlowInstance],\n );\n\n useDndMonitor({\n onDragEnd: handleDragEnd,\n });\n\n const handleFlowChange = useCallback(\n (nds: Node[], eds: Edge[]) => {\n // The new flow is returned if the user is not dragging nodes\n // This avoids triggering this handler too many times\n const isDragging = nds.find((node) => node.dragging);\n if (!isDragging) {\n onFlowChange?.(nds, eds);\n }\n },\n [onFlowChange],\n );\n\n const handleConnect = useCallback(\n (connection: Connection) => {\n const eds = addEdge(connection, edgesRef.current);\n updateEdges(eds);\n\n handleFlowChange(nodesRef.current, eds);\n onConnectProp?.(connection);\n },\n [handleFlowChange, onConnectProp],\n );\n\n const handleNodesChange = useCallback(\n (changes: NodeChange[]) => {\n const nds = applyNodeChanges(changes, nodesRef.current);\n updateNodes(nds);\n\n handleFlowChange(nds, edgesRef.current);\n onNodesChangeProp?.(changes);\n },\n [handleFlowChange, onNodesChangeProp],\n );\n\n const handleEdgesChange = useCallback(\n (changes: EdgeChange[]) => {\n const eds = applyEdgeChanges(changes, edgesRef.current);\n updateEdges(eds);\n\n handleFlowChange(nodesRef.current, eds);\n onEdgesChangeProp?.(changes);\n },\n [handleFlowChange, onEdgesChangeProp],\n );\n\n const { registry } = useNodeMetaRegistry();\n\n const isValidConnection: ReactFlowProps[\"isValidConnection\"] = (connection) =>\n validateEdge(nodes, edges, connection, registry);\n\n const defaultEdgeOptions = {\n markerEnd: {\n type: MarkerType.ArrowClosed,\n height: 20,\n width: 20,\n },\n type: \"smoothstep\",\n pathOptions: {\n borderRadius: 40,\n },\n ...defaultEdgeOptionsProp,\n };\n\n return (\n <>\n <Global styles={flowStyles} />\n <div\n id={elementId}\n ref={setNodeRef}\n className={cx(classes.root, className)}\n >\n <ReactFlow\n nodes={nodes}\n edges={edges}\n nodeTypes={nodeTypes}\n onNodesChange={handleNodesChange}\n onEdgesChange={handleEdgesChange}\n onConnect={handleConnect}\n isValidConnection={isValidConnection}\n defaultEdgeOptions={defaultEdgeOptions}\n snapGrid={[1, 1]}\n snapToGrid\n onError={(code, message) => {\n if (import.meta.env.DEV) {\n // eslint-disable-next-line no-console\n console.error(message);\n }\n }}\n {...others}\n >\n {children}\n </ReactFlow>\n </div>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;AA+Da,MAAA,UAAU,CAAC,OAAe,WAAmB;A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AAGhC,QAAA,EAAE,aAAa;AAErB,QAAM,oBAAyD,CAAC,eAC9D,aAAa,OAAO,OAAO,YAAY,QAAQ;AAEjD,QAAM,qBAAqB;AAAA,IACzB,WAAW;AAAA,MACT,MAAM,WAAW;AAAA,MACjB,QAAQ;AAAA,MACR,OAAO;AAAA,IACT;AAAA,IACA,MAAM;AAAA,IACN,aAAa;AAAA,MACX,cAAc;AAAA,IAChB;AAAA,IACA,GAAG;AAAA,EAAA;AAGL,SAEI,qBAAA,UAAA,EAAA,UAAA;AAAA,IAAC,oBAAA,QAAA,EAAO,QAAQ,WAAY,CAAA;AAAA,IAC5B;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,IAAI;AAAA,QACJ,KAAK;AAAA,QACL,WAAW,GAAG,QAAQ,MAAM,SAAS;AAAA,QAErC,UAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC;AAAA,YACA;AAAA,YACA;AAAA,YACA,eAAe;AAAA,YACf,eAAe;AAAA,YACf,WAAW;AAAA,YACX;AAAA,YACA;AAAA,YACA,UAAU,CAAC,GAAG,CAAC;AAAA,YACf,YAAU;AAAA,YACV,SAAS,CAAC,MAAM,YAAY;AAAA,YAK5B;AAAA,YACC,GAAG;AAAA,YAEH;AAAA,UAAA;AAAA,QACH;AAAA,MAAA;AAAA,IACF;AAAA,EACF,EAAA,CAAA;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"DroppableFlow.js","sources":["../../../src/Flow/DroppableFlow.tsx"],"sourcesContent":["import { useCallback, useRef, useState } from \"react\";\nimport { DragEndEvent, useDndMonitor, useDroppable } from \"@dnd-kit/core\";\nimport { Global } from \"@emotion/react\";\nimport ReactFlow, {\n addEdge,\n applyEdgeChanges,\n applyNodeChanges,\n Connection,\n Edge,\n EdgeChange,\n MarkerType,\n Node,\n NodeChange,\n ReactFlowProps,\n} from \"reactflow\";\nimport { uid } from \"uid\";\nimport { ExtractNames, useUniqueId } from \"@hitachivantara/uikit-react-core\";\n\nimport { flowStyles } from \"./base\";\nimport { staticClasses, useClasses } from \"./Flow.styles\";\nimport { useNodeMetaRegistry } from \"./FlowContext/NodeMetaContext\";\nimport { useFlowInstance } from \"./hooks\";\nimport {\n HvFlowNodeInputGroup,\n HvFlowNodeMetaRegistry,\n HvFlowNodeOutputGroup,\n HvFlowNodeTypes,\n} from \"./types\";\n\nexport { staticClasses as flowClasses };\n\nexport type HvFlowClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvDroppableFlowProps<\n NodeType extends string | undefined = string | undefined,\n NodeData = any,\n> extends Omit<ReactFlowProps, \"nodes\" | \"edges\" | \"nodeTypes\"> {\n /** Flow content: background, controls, and minimap. */\n children?: React.ReactNode;\n /** Flow nodes types. */\n nodeTypes?: HvFlowNodeTypes<NodeData>;\n /** Flow nodes. */\n nodes?: Node<NodeData, NodeType>[];\n /** Flow edges. */\n edges?: Edge[];\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvFlowClasses;\n /** Callback called when the flow changes. Returns the updated nodes and edges. */\n onFlowChange?: (nodes: Node<NodeData, NodeType>[], edges: Edge[]) => void;\n /**\n * Callback called when a node is dropped in the flow.\n *\n * This callback should be used to override the custom UI Kit drop event.\n * Thus, when defined, the user is responsible for adding nodes to the flow.\n *\n * This callback is called when `HvFlowSidebar` is used or a custom sidebar was created using Dnd Kit.\n * When a custom sidebar was created using the native HTML drag and drop API, refer to the `onDrop` callback.\n *\n * Returns the event and the node to be added to the flow.\n */\n onDndDrop?: (event: DragEndEvent, node: Node) => void;\n}\n\nexport const getNode = (nodes: Node[], nodeId: string) => {\n return nodes.find((n) => n.id === nodeId);\n};\n\nconst validateEdge = (\n nodes: Node[],\n edges: Edge[],\n connection: Connection,\n nodeMetaRegistry: HvFlowNodeMetaRegistry,\n) => {\n const {\n source: sourceId,\n sourceHandle,\n target: targetId,\n targetHandle,\n } = connection;\n\n if (!sourceHandle || !targetHandle || !sourceId || !targetId) return false;\n\n const sourceNode = getNode(nodes, sourceId);\n const targetNode = getNode(nodes, targetId);\n\n if (!sourceNode || !targetNode) return false;\n\n const sourceType = sourceNode.type;\n const targetType = targetNode.type;\n\n if (!sourceType || !targetType) return false;\n\n const inputs = nodeMetaRegistry[targetId]?.inputs || [];\n const outputs = nodeMetaRegistry[sourceId]?.outputs || [];\n\n const source = outputs\n .flatMap((out) => (out as HvFlowNodeOutputGroup).outputs || out)\n .find((out) => out.id === sourceHandle);\n const target = inputs\n .flatMap((inp) => (inp as HvFlowNodeInputGroup).inputs || inp)\n .find((inp) => inp.id === targetHandle);\n\n const sourceProvides = source?.provides || \"\";\n const targetAccepts = target?.accepts || [];\n const sourceMaxConnections = source?.maxConnections;\n const targetMaxConnections = target?.maxConnections;\n\n let isValid =\n targetAccepts.length === 0 || targetAccepts.includes(sourceProvides);\n\n if (isValid && targetMaxConnections != null) {\n const targetConnections = edges.filter(\n (edg) => edg.target === targetId && edg.targetHandle === targetHandle,\n ).length;\n\n isValid = targetConnections < targetMaxConnections;\n }\n\n if (isValid && sourceMaxConnections != null) {\n const sourceConnections = edges.filter(\n (edg) => edg.source === sourceId && edg.sourceHandle === sourceHandle,\n ).length;\n\n isValid = sourceConnections < sourceMaxConnections;\n }\n\n return isValid;\n};\n\nexport const HvDroppableFlow = ({\n id,\n className,\n children,\n onFlowChange,\n onDndDrop,\n classes: classesProp,\n nodes: initialNodes = [],\n edges: initialEdges = [],\n onConnect: onConnectProp,\n onNodesChange: onNodesChangeProp,\n onEdgesChange: onEdgesChangeProp,\n defaultEdgeOptions: defaultEdgeOptionsProp,\n nodeTypes,\n ...others\n}: HvDroppableFlowProps) => {\n const { classes, cx } = useClasses(classesProp);\n\n const elementId = useUniqueId(id);\n\n const reactFlowInstance = useFlowInstance();\n\n const [nodes, setNodes] = useState(initialNodes);\n const [edges, setEdges] = useState(initialEdges);\n // Keeping track of nodes and edges for onFlowChange since useState is async\n const nodesRef = useRef(initialNodes);\n const edgesRef = useRef(initialEdges);\n\n const updateNodes = (nds: Node[]) => {\n setNodes(nds);\n nodesRef.current = nds;\n };\n\n const updateEdges = (eds: Edge[]) => {\n setEdges(eds);\n edgesRef.current = eds;\n };\n\n const { setNodeRef } = useDroppable({\n id: elementId,\n });\n\n const handleDragEnd = useCallback(\n (event: DragEndEvent) => {\n if (event.over?.id !== elementId) return;\n\n const hvFlow = event.active.data.current?.hvFlow;\n const type = hvFlow?.type;\n\n // Only known node types can be dropped in the canvas\n if (!type || !nodeTypes?.[type]) {\n if (import.meta.env.DEV) {\n // eslint-disable-next-line no-console\n console.error(\n `Could not add node to the flow because of unknown type ${type}. Use nodeTypes to define all the node types.`,\n );\n }\n return;\n }\n\n // Position node in the flow\n const position = reactFlowInstance.screenToFlowPosition({\n x: hvFlow?.x || 0,\n y: hvFlow?.y || 0,\n });\n\n // Node data\n const data = {\n nodeLabel: hvFlow?.label,\n ...hvFlow?.data,\n };\n\n // Node to add\n const newNode: Node = {\n id: uid(),\n position,\n data,\n type,\n };\n\n // Drop override\n if (onDndDrop) {\n onDndDrop(event, newNode);\n return;\n }\n\n updateNodes(nodes.concat(newNode));\n },\n [elementId, nodeTypes, nodes, onDndDrop, reactFlowInstance],\n );\n\n useDndMonitor({\n onDragEnd: handleDragEnd,\n });\n\n const handleFlowChange = useCallback(\n (nds: Node[], eds: Edge[]) => {\n // The new flow is returned if the user is not dragging nodes\n // This avoids triggering this handler too many times\n const isDragging = nds.find((node) => node.dragging);\n if (!isDragging) {\n onFlowChange?.(nds, eds);\n }\n },\n [onFlowChange],\n );\n\n const handleConnect = useCallback(\n (connection: Connection) => {\n const eds = addEdge(connection, edgesRef.current);\n updateEdges(eds);\n\n handleFlowChange(nodesRef.current, eds);\n onConnectProp?.(connection);\n },\n [handleFlowChange, onConnectProp],\n );\n\n const handleNodesChange = useCallback(\n (changes: NodeChange[]) => {\n const nds = applyNodeChanges(changes, nodesRef.current);\n updateNodes(nds);\n\n handleFlowChange(nds, edgesRef.current);\n onNodesChangeProp?.(changes);\n },\n [handleFlowChange, onNodesChangeProp],\n );\n\n const handleEdgesChange = useCallback(\n (changes: EdgeChange[]) => {\n const eds = applyEdgeChanges(changes, edgesRef.current);\n updateEdges(eds);\n\n handleFlowChange(nodesRef.current, eds);\n onEdgesChangeProp?.(changes);\n },\n [handleFlowChange, onEdgesChangeProp],\n );\n\n const { registry } = useNodeMetaRegistry();\n\n const isValidConnection: ReactFlowProps[\"isValidConnection\"] = (connection) =>\n validateEdge(nodes, edges, connection, registry);\n\n const defaultEdgeOptions = {\n markerEnd: {\n type: MarkerType.ArrowClosed,\n height: 20,\n width: 20,\n },\n type: \"smoothstep\",\n pathOptions: {\n borderRadius: 40,\n },\n ...defaultEdgeOptionsProp,\n };\n\n return (\n <>\n <Global styles={flowStyles} />\n <div\n id={elementId}\n ref={setNodeRef}\n className={cx(classes.root, className)}\n >\n <ReactFlow\n nodes={nodes}\n edges={edges}\n nodeTypes={nodeTypes}\n onNodesChange={handleNodesChange}\n onEdgesChange={handleEdgesChange}\n onConnect={handleConnect}\n isValidConnection={isValidConnection}\n defaultEdgeOptions={defaultEdgeOptions}\n snapGrid={[1, 1]}\n snapToGrid\n onError={(code, message) => {\n if (import.meta.env.DEV) {\n // eslint-disable-next-line no-console\n console.error(message);\n }\n }}\n {...others}\n >\n {children}\n </ReactFlow>\n </div>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;AA+Da,MAAA,UAAU,CAAC,OAAe,WAAmB;AACxD,SAAO,MAAM,KAAK,CAAC,MAAM,EAAE,OAAO,MAAM;AAC1C;AAEA,MAAM,eAAe,CACnB,OACA,OACA,YACA,qBACG;AACG,QAAA;AAAA,IACJ,QAAQ;AAAA,IACR;AAAA,IACA,QAAQ;AAAA,IACR;AAAA,EACE,IAAA;AAEA,MAAA,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,YAAY,CAAC,SAAiB,QAAA;AAE/D,QAAA,aAAa,QAAQ,OAAO,QAAQ;AACpC,QAAA,aAAa,QAAQ,OAAO,QAAQ;AAE1C,MAAI,CAAC,cAAc,CA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Y,CAAA;AAAA,IAC5B;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,IAAI;AAAA,QACJ,KAAK;AAAA,QACL,WAAW,GAAG,QAAQ,MAAM,SAAS;AAAA,QAErC,UAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC;AAAA,YACA;AAAA,YACA;AAAA,YACA,eAAe;AAAA,YACf,eAAe;AAAA,YACf,WAAW;AAAA,YACX;AAAA,YACA;AAAA,YACA,UAAU,CAAC,GAAG,CAAC;AAAA,YACf,YAAU;AAAA,YACV,SAAS,CAAC,MAAM,YAAY;AAAA,YAK5B;AAAA,YACC,GAAG;AAAA,YAEH;AAAA,UAAA;AAAA,QACH;AAAA,MAAA;AAAA,IACF;AAAA,EACF,EAAA,CAAA;AAEJ;"}
|
|
@@ -90,8 +90,7 @@ const HvFlowBaseNode = ({
|
|
|
90
90
|
input.isMandatory && !edgeConnected && /* @__PURE__ */ jsx("div", { className: classes.mandatory })
|
|
91
91
|
] }, input.id);
|
|
92
92
|
};
|
|
93
|
-
if (!node)
|
|
94
|
-
return null;
|
|
93
|
+
if (!node) return null;
|
|
95
94
|
return /* @__PURE__ */ jsxs(
|
|
96
95
|
"div",
|
|
97
96
|
{
|
|
@@ -146,8 +145,7 @@ const HvFlowBaseNode = ({
|
|
|
146
145
|
inputs && inputs.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
147
146
|
/* @__PURE__ */ jsx("div", { className: classes.inputsTitleContainer, children: /* @__PURE__ */ jsx(HvTypography, { children: labels?.inputsTitle }) }),
|
|
148
147
|
/* @__PURE__ */ jsx("div", { className: classes.inputsContainer, children: inputs?.map((input, idx) => {
|
|
149
|
-
if (!isInputGroup(input))
|
|
150
|
-
return renderInput(input);
|
|
148
|
+
if (!isInputGroup(input)) return renderInput(input);
|
|
151
149
|
return /* @__PURE__ */ jsxs(
|
|
152
150
|
"div",
|
|
153
151
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseNode.js","sources":["../../../../src/Flow/Node/BaseNode.tsx"],"sourcesContent":["import { Handle, NodeProps, NodeToolbar, Position } from \"reactflow\";\nimport {\n ExtractNames,\n HvBaseProps,\n HvIconButton,\n HvTypography,\n useLabels,\n} from \"@hitachivantara/uikit-react-core\";\n\nimport { HvUseNodeParams, useHvNode } from \"../hooks\";\nimport {\n HvFlowNodeInput,\n HvFlowNodeInputGroup,\n HvFlowNodeOutput,\n HvFlowNodeOutputGroup,\n} from \"../types\";\nimport { staticClasses, useClasses } from \"./BaseNode.styles\";\nimport {\n isConnected,\n isInputGroup,\n isOutputGroup,\n renderedIcon,\n} from \"./utils\";\n\nexport { staticClasses as flowBaseNodeClasses };\n\nexport type HvFlowBaseNodeClasses = ExtractNames<typeof useClasses>;\n\nexport const DEFAULT_LABELS = {\n outputsTitle: \"Outputs\",\n inputsTitle: \"Inputs\",\n deleteActionLabel: \"Delete\",\n duplicateActionLabel: \"Duplicate\",\n};\n\nexport interface HvFlowBaseNodeProps<T = any>\n extends Omit<HvBaseProps, \"id\" | \"color\">,\n Omit<HvUseNodeParams, \"id\">,\n NodeProps<T> {\n /** Header items */\n headerItems?: React.ReactNode;\n /** The content of the node footer */\n footer?: React.ReactNode;\n /** Labels used on the node. */\n labels?: Partial<typeof DEFAULT_LABELS>;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvFlowBaseNodeClasses;\n}\n\nexport const HvFlowBaseNode = ({\n id,\n title: titleProp,\n headerItems,\n icon: iconProp,\n color: colorProp,\n inputs: inputsProp,\n outputs: outputsProp,\n nodeActions: nodeActionsProp,\n footer,\n classes: classesProp,\n labels: labelsProp,\n className,\n children,\n}: HvFlowBaseNodeProps<unknown>) => {\n const {\n toggleShowActions,\n getNodeToolbarProps,\n handleDefaultAction,\n nodeActions,\n title,\n icon,\n color,\n iconColor,\n inputEdges,\n inputs,\n outputEdges,\n outputs,\n node,\n } = useHvNode({\n id,\n title: titleProp,\n inputs: inputsProp,\n outputs: outputsProp,\n icon: iconProp,\n color: colorProp,\n labels: labelsProp,\n nodeActions: nodeActionsProp,\n });\n\n const labels = useLabels(DEFAULT_LABELS, labelsProp);\n\n const { classes, cx } = useClasses(classesProp);\n\n const renderOutput = (output: HvFlowNodeOutput) => {\n const edgeConnected = isConnected(id, \"source\", output.id!, outputEdges);\n\n return (\n <div className={classes.outputContainer} key={output.id}>\n <Handle\n type=\"source\"\n isConnectableEnd={false}\n id={output.id}\n position={Position.Right}\n className={cx(classes.handle, {\n [classes.handleConnected]: edgeConnected,\n })}\n />\n {output.isMandatory && !edgeConnected && (\n <div className={classes.mandatory} />\n )}\n <HvTypography component=\"div\">{output.label}</HvTypography>\n </div>\n );\n };\n\n const renderInput = (input: HvFlowNodeInput) => {\n const edgeConnected = isConnected(id, \"target\", input.id!, inputEdges);\n\n return (\n <div className={classes.inputContainer} key={input.id}>\n <Handle\n type=\"target\"\n isConnectableStart={false}\n id={input.id}\n position={Position.Left}\n className={cx(classes.handle, {\n [classes.handleConnected]: edgeConnected,\n })}\n />\n <HvTypography component=\"div\">{input.label}</HvTypography>\n {input.isMandatory && !edgeConnected && (\n <div className={classes.mandatory} />\n )}\n </div>\n );\n };\n\n if (!node) return null;\n\n return (\n <div\n style={{\n // @ts-ignore\n \"--node-color\": color,\n }}\n className={cx(\n \"nowheel\", // Disables the default canvas pan behaviour when scrolling inside the node\n classes.root,\n className,\n )}\n onMouseEnter={toggleShowActions}\n onMouseLeave={toggleShowActions}\n >\n <NodeToolbar {...getNodeToolbarProps()}>\n {nodeActions?.map((action) => (\n <HvIconButton\n key={action.id}\n title={action.label}\n onClick={() => handleDefaultAction(action)}\n >\n {renderedIcon(action.icon)}\n </HvIconButton>\n ))}\n </NodeToolbar>\n <div className={classes.headerContainer}>\n <div\n style={{\n // @ts-ignore\n \"--icon-color\": iconColor,\n }}\n className={classes.titleContainer}\n >\n {icon}\n <HvTypography\n component=\"p\"\n variant=\"title4\"\n className={classes.title}\n >\n {title}\n </HvTypography>\n </div>\n {headerItems && <div style={{ display: \"flex\" }}>{headerItems}</div>}\n </div>\n {children && <div className={classes.contentContainer}>{children}</div>}\n {inputs && inputs.length > 0 && (\n <>\n <div className={classes.inputsTitleContainer}>\n <HvTypography>{labels?.inputsTitle}</HvTypography>\n </div>\n <div className={classes.inputsContainer}>\n {inputs?.map((input, idx) => {\n if (!isInputGroup(input)) return renderInput(input);\n\n return (\n <div\n className={classes.inputGroupContainer}\n key={`group${idx}`}\n >\n <HvTypography component=\"div\" variant=\"label\">\n {input.label}\n </HvTypography>\n {(input as HvFlowNodeInputGroup).inputs.map((inp) =>\n renderInput(inp),\n )}\n </div>\n );\n })}\n </div>\n </>\n )}\n {outputs && outputs.length > 0 && (\n <>\n <div className={classes.outputsTitleContainer}>\n <HvTypography>{labels?.outputsTitle}</HvTypography>\n </div>\n <div className={classes.outputsContainer}>\n {outputs?.map((output, idx) => {\n if (!isOutputGroup(output)) {\n return renderOutput(output);\n }\n\n return (\n <div\n className={classes.outputGroupContainer}\n key={`group${idx}`}\n >\n <HvTypography component=\"div\" variant=\"label\">\n {output.label}\n </HvTypography>\n {(output as HvFlowNodeOutputGroup).outputs.map((out) => {\n return renderOutput(out);\n })}\n </div>\n );\n })}\n </div>\n </>\n )}\n {footer && <div className={classes.footerContainer}>{footer}</div>}\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;AA4BO,MAAM,iBAAiB;AAAA,EAC5B,cAAc;AAAA,EACd,aAAa;AAAA,EACb,mBAAmB;AAAA,EACnB,sBAAsB;AACxB;AAgBO,MAAM,iBAAiB,CAAC;AAAA,EAC7B;AAAA,EACA,OAAO;AAAA,EACP;AAAA,EACA,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,aAAa;AAAA,EACb;AAAA,EACA,SAAS;AAAA,EACT,QAAQ;AAAA,EACR;AAAA,EACA;AACF,MAAoC;AAC5B,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,I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;AAAA,cAPI,QAAQ,GAAG;AAAA,YAAA;AAAA,UAUrB,CAAA,GACH;AAAA,QAAA,GACF;AAAA,QAED,UAAW,oBAAA,OAAA,EAAI,WAAW,QAAQ,iBAAkB,UAAO,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGlE;"}
|
|
1
|
+
{"version":3,"file":"BaseNode.js","sources":["../../../../src/Flow/Node/BaseNode.tsx"],"sourcesContent":["import { Handle, NodeProps, NodeToolbar, Position } from \"reactflow\";\nimport {\n ExtractNames,\n HvBaseProps,\n HvIconButton,\n HvTypography,\n useLabels,\n} from \"@hitachivantara/uikit-react-core\";\n\nimport { HvUseNodeParams, useHvNode } from \"../hooks\";\nimport {\n HvFlowNodeInput,\n HvFlowNodeInputGroup,\n HvFlowNodeOutput,\n HvFlowNodeOutputGroup,\n} from \"../types\";\nimport { staticClasses, useClasses } from \"./BaseNode.styles\";\nimport {\n isConnected,\n isInputGroup,\n isOutputGroup,\n renderedIcon,\n} from \"./utils\";\n\nexport { staticClasses as flowBaseNodeClasses };\n\nexport type HvFlowBaseNodeClasses = ExtractNames<typeof useClasses>;\n\nexport const DEFAULT_LABELS = {\n outputsTitle: \"Outputs\",\n inputsTitle: \"Inputs\",\n deleteActionLabel: \"Delete\",\n duplicateActionLabel: \"Duplicate\",\n};\n\nexport interface HvFlowBaseNodeProps<T = any>\n extends Omit<HvBaseProps, \"id\" | \"color\">,\n Omit<HvUseNodeParams, \"id\">,\n NodeProps<T> {\n /** Header items */\n headerItems?: React.ReactNode;\n /** The content of the node footer */\n footer?: React.ReactNode;\n /** Labels used on the node. */\n labels?: Partial<typeof DEFAULT_LABELS>;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvFlowBaseNodeClasses;\n}\n\nexport const HvFlowBaseNode = ({\n id,\n title: titleProp,\n headerItems,\n icon: iconProp,\n color: colorProp,\n inputs: inputsProp,\n outputs: outputsProp,\n nodeActions: nodeActionsProp,\n footer,\n classes: classesProp,\n labels: labelsProp,\n className,\n children,\n}: HvFlowBaseNodeProps<unknown>) => {\n const {\n toggleShowActions,\n getNodeToolbarProps,\n handleDefaultAction,\n nodeActions,\n title,\n icon,\n color,\n iconColor,\n inputEdges,\n inputs,\n outputEdges,\n outputs,\n node,\n } = useHvNode({\n id,\n title: titleProp,\n inputs: inputsProp,\n outputs: outputsProp,\n icon: iconProp,\n color: colorProp,\n labels: labelsProp,\n nodeActions: nodeActionsProp,\n });\n\n const labels = useLabels(DEFAULT_LABELS, labelsProp);\n\n const { classes, cx } = useClasses(classesProp);\n\n const renderOutput = (output: HvFlowNodeOutput) => {\n const edgeConnected = isConnected(id, \"source\", output.id!, outputEdges);\n\n return (\n <div className={classes.outputContainer} key={output.id}>\n <Handle\n type=\"source\"\n isConnectableEnd={false}\n id={output.id}\n position={Position.Right}\n className={cx(classes.handle, {\n [classes.handleConnected]: edgeConnected,\n })}\n />\n {output.isMandatory && !edgeConnected && (\n <div className={classes.mandatory} />\n )}\n <HvTypography component=\"div\">{output.label}</HvTypography>\n </div>\n );\n };\n\n const renderInput = (input: HvFlowNodeInput) => {\n const edgeConnected = isConnected(id, \"target\", input.id!, inputEdges);\n\n return (\n <div className={classes.inputContainer} key={input.id}>\n <Handle\n type=\"target\"\n isConnectableStart={false}\n id={input.id}\n position={Position.Left}\n className={cx(classes.handle, {\n [classes.handleConnected]: edgeConnected,\n })}\n />\n <HvTypography component=\"div\">{input.label}</HvTypography>\n {input.isMandatory && !edgeConnected && (\n <div className={classes.mandatory} />\n )}\n </div>\n );\n };\n\n if (!node) return null;\n\n return (\n <div\n style={{\n // @ts-ignore\n \"--node-color\": color,\n }}\n className={cx(\n \"nowheel\", // Disables the default canvas pan behaviour when scrolling inside the node\n classes.root,\n className,\n )}\n onMouseEnter={toggleShowActions}\n onMouseLeave={toggleShowActions}\n >\n <NodeToolbar {...getNodeToolbarProps()}>\n {nodeActions?.map((action) => (\n <HvIconButton\n key={action.id}\n title={action.label}\n onClick={() => handleDefaultAction(action)}\n >\n {renderedIcon(action.icon)}\n </HvIconButton>\n ))}\n </NodeToolbar>\n <div className={classes.headerContainer}>\n <div\n style={{\n // @ts-ignore\n \"--icon-color\": iconColor,\n }}\n className={classes.titleContainer}\n >\n {icon}\n <HvTypography\n component=\"p\"\n variant=\"title4\"\n className={classes.title}\n >\n {title}\n </HvTypography>\n </div>\n {headerItems && <div style={{ display: \"flex\" }}>{headerItems}</div>}\n </div>\n {children && <div className={classes.contentContainer}>{children}</div>}\n {inputs && inputs.length > 0 && (\n <>\n <div className={classes.inputsTitleContainer}>\n <HvTypography>{labels?.inputsTitle}</HvTypography>\n </div>\n <div className={classes.inputsContainer}>\n {inputs?.map((input, idx) => {\n if (!isInputGroup(input)) return renderInput(input);\n\n return (\n <div\n className={classes.inputGroupContainer}\n key={`group${idx}`}\n >\n <HvTypography component=\"div\" variant=\"label\">\n {input.label}\n </HvTypography>\n {(input as HvFlowNodeInputGroup).inputs.map((inp) =>\n renderInput(inp),\n )}\n </div>\n );\n })}\n </div>\n </>\n )}\n {outputs && outputs.length > 0 && (\n <>\n <div className={classes.outputsTitleContainer}>\n <HvTypography>{labels?.outputsTitle}</HvTypography>\n </div>\n <div className={classes.outputsContainer}>\n {outputs?.map((output, idx) => {\n if (!isOutputGroup(output)) {\n return renderOutput(output);\n }\n\n return (\n <div\n className={classes.outputGroupContainer}\n key={`group${idx}`}\n >\n <HvTypography component=\"div\" variant=\"label\">\n {output.label}\n </HvTypography>\n {(output as HvFlowNodeOutputGroup).outputs.map((out) => {\n return renderOutput(out);\n })}\n </div>\n );\n })}\n </div>\n </>\n )}\n {footer && <div className={classes.footerContainer}>{footer}</div>}\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;AA4BO,MAAM,iBAAiB;AAAA,EAC5B,cAAc;AAAA,EACd,aAAa;AAAA,EACb,mBAAmB;AAAA,EACnB,sBAAsB;AACxB;AAgBO,MAAM,iBAAiB,CAAC;AAAA,EAC7B;AAAA,EACA,OAAO;AAAA,EACP;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AA;AAAA,gBACC,WAAW,QAAQ;AAAA,gBAGnB,UAAA;AAAA,kBAAA,oBAAC,gBAAa,WAAU,OAAM,SAAQ,SACnC,iBAAO,OACV;AAAA,kBACE,OAAiC,QAAQ,IAAI,CAAC,QAAQ;AACtD,2BAAO,aAAa,GAAG;AAAA,kBAAA,CACxB;AAAA,gBAAA;AAAA,cAAA;AAAA,cAPI,QAAQ,GAAG;AAAA,YAAA;AAAA,UAUrB,CAAA,GACH;AAAA,QAAA,GACF;AAAA,QAED,UAAW,oBAAA,OAAA,EAAI,WAAW,QAAQ,iBAAkB,UAAO,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGlE;"}
|
|
@@ -10,8 +10,7 @@ const renderers = {
|
|
|
10
10
|
const ParamRenderer = ({ params, data }) => {
|
|
11
11
|
return /* @__PURE__ */ jsx(Fragment, { children: params.map((param, idx) => {
|
|
12
12
|
const Renderer = renderers[param.type];
|
|
13
|
-
if (!Renderer)
|
|
14
|
-
return null;
|
|
13
|
+
if (!Renderer) return null;
|
|
15
14
|
return /* @__PURE__ */ jsx(Renderer, { param, data }, idx);
|
|
16
15
|
}) });
|
|
17
16
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParamRenderer.js","sources":["../../../../../src/Flow/Node/Parameters/ParamRenderer.tsx"],"sourcesContent":["import { HvFlowNodeParam } from \"../../types\";\nimport Select from \"./Select\";\nimport Slider from \"./Slider\";\nimport Text from \"./Text\";\n\nexport type ParamRendererProps = {\n params: HvFlowNodeParam[];\n data: any;\n};\n\nconst renderers = {\n text: Text,\n select: Select,\n slider: Slider,\n};\n\nexport const ParamRenderer = ({ params, data }: ParamRendererProps) => {\n return (\n <>\n {params.map((param, idx) => {\n const Renderer = renderers[param.type];\n if (!Renderer) return null;\n\n return <Renderer key={idx} param={param} data={data} />;\n })}\n </>\n );\n};\n"],"names":[],"mappings":";;;;AAUA,MAAM,YAAY;AAAA,EAChB,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,QAAQ;AACV;AAEO,MAAM,gBAAgB,CAAC,EAAE,QAAQ,WAA+B;AACrE,SAEK,oBAAA,UAAA,EAAA,UAAA,OAAO,IAAI,CAAC,OAAO,QAAQ;AACpB,UAAA,WAAW,UAAU,MAAM,IAAI;
|
|
1
|
+
{"version":3,"file":"ParamRenderer.js","sources":["../../../../../src/Flow/Node/Parameters/ParamRenderer.tsx"],"sourcesContent":["import { HvFlowNodeParam } from \"../../types\";\nimport Select from \"./Select\";\nimport Slider from \"./Slider\";\nimport Text from \"./Text\";\n\nexport type ParamRendererProps = {\n params: HvFlowNodeParam[];\n data: any;\n};\n\nconst renderers = {\n text: Text,\n select: Select,\n slider: Slider,\n};\n\nexport const ParamRenderer = ({ params, data }: ParamRendererProps) => {\n return (\n <>\n {params.map((param, idx) => {\n const Renderer = renderers[param.type];\n if (!Renderer) return null;\n\n return <Renderer key={idx} param={param} data={data} />;\n })}\n </>\n );\n};\n"],"names":[],"mappings":";;;;AAUA,MAAM,YAAY;AAAA,EAChB,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,QAAQ;AACV;AAEO,MAAM,gBAAgB,CAAC,EAAE,QAAQ,WAA+B;AACrE,SAEK,oBAAA,UAAA,EAAA,UAAA,OAAO,IAAI,CAAC,OAAO,QAAQ;AACpB,UAAA,WAAW,UAAU,MAAM,IAAI;AACjC,QAAA,CAAC,SAAiB,QAAA;AAEtB,WAAQ,oBAAA,UAAA,EAAmB,OAAc,KAAA,GAAnB,GAA+B;AAAA,EACtD,CAAA,EACH,CAAA;AAEJ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.js","sources":["../../../../../src/Flow/Node/Parameters/Select.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport { HvDropdown, HvDropdownProps } from \"@hitachivantara/uikit-react-core\";\n\nimport { useFlowNodeUtils } from \"../../hooks\";\nimport { HvFlowNodeSelectParam } from \"../../types\";\n\ninterface SelectProps {\n param: Omit<HvFlowNodeSelectParam, \"type\">;\n data: any;\n}\n\nconst Select = ({ param, data }: SelectProps) => {\n const { id, label, multiple = false, options } = param;\n const { setNodeData } = useFlowNodeUtils();\n\n const [opts, setOpts] = useState<string[] | undefined>(\n data[id] ? (Array.isArray(data[id]) ? data[id] : [data[id]]) : undefined,\n );\n\n const handleChange: HvDropdownProps[\"onChange\"] = (item) => {\n const newOpts = Array.isArray(item)\n ? item.map((x) => x.id as string)\n : (item?.id as string) ?? undefined;\n\n setNodeData((prev) => ({ ...prev, [id]: newOpts }));\n setOpts(\n newOpts ? (Array.isArray(newOpts) ? newOpts : [newOpts]) : undefined,\n );\n };\n\n return (\n <HvDropdown\n className=\"nodrag\" // Prevents dragging within the select field\n disablePortal\n label={label}\n values={options?.map((option) => {\n const optionId = typeof option === \"string\" ? option : option.id;\n const optionLabel = typeof option === \"string\" ? option : option.label;\n\n return {\n id: optionId,\n label: optionLabel,\n selected: !!opts?.find((opt) => opt === optionId),\n };\n })}\n onChange={handleChange}\n maxHeight={100}\n multiSelect={multiple}\n />\n );\n};\n\nexport default Select;\n"],"names":[],"mappings":";;;;AAWA,MAAM,SAAS,CAAC,EAAE,OAAO,WAAwB;AAC/C,QAAM,EAAE,IAAI,OAAO,WAAW,OAAO,QAAY,IAAA;AAC3C,QAAA,EAAE,gBAAgB;AAElB,QAAA,CAAC,MAAM,OAAO,IAAI;AAAA,IACtB,KAAK,EAAE,IAAK,MAAM,QAAQ,KAAK,EAAE,CAAC,IAAI,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,IAAK;AAAA,EAAA;AAG3D,QAAA,eAA4C,CAAC,SAAS;AAC1D,UAAM,UAAU,MAAM,QAAQ,IAAI,IAC9B,KAAK,IAAI,CAAC,MAAM,EAAE,EAAY,
|
|
1
|
+
{"version":3,"file":"Select.js","sources":["../../../../../src/Flow/Node/Parameters/Select.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport { HvDropdown, HvDropdownProps } from \"@hitachivantara/uikit-react-core\";\n\nimport { useFlowNodeUtils } from \"../../hooks\";\nimport { HvFlowNodeSelectParam } from \"../../types\";\n\ninterface SelectProps {\n param: Omit<HvFlowNodeSelectParam, \"type\">;\n data: any;\n}\n\nconst Select = ({ param, data }: SelectProps) => {\n const { id, label, multiple = false, options } = param;\n const { setNodeData } = useFlowNodeUtils();\n\n const [opts, setOpts] = useState<string[] | undefined>(\n data[id] ? (Array.isArray(data[id]) ? data[id] : [data[id]]) : undefined,\n );\n\n const handleChange: HvDropdownProps[\"onChange\"] = (item) => {\n const newOpts = Array.isArray(item)\n ? item.map((x) => x.id as string)\n : ((item?.id as string) ?? undefined);\n\n setNodeData((prev) => ({ ...prev, [id]: newOpts }));\n setOpts(\n newOpts ? (Array.isArray(newOpts) ? newOpts : [newOpts]) : undefined,\n );\n };\n\n return (\n <HvDropdown\n className=\"nodrag\" // Prevents dragging within the select field\n disablePortal\n label={label}\n values={options?.map((option) => {\n const optionId = typeof option === \"string\" ? option : option.id;\n const optionLabel = typeof option === \"string\" ? option : option.label;\n\n return {\n id: optionId,\n label: optionLabel,\n selected: !!opts?.find((opt) => opt === optionId),\n };\n })}\n onChange={handleChange}\n maxHeight={100}\n multiSelect={multiple}\n />\n );\n};\n\nexport default Select;\n"],"names":[],"mappings":";;;;AAWA,MAAM,SAAS,CAAC,EAAE,OAAO,WAAwB;AAC/C,QAAM,EAAE,IAAI,OAAO,WAAW,OAAO,QAAY,IAAA;AAC3C,QAAA,EAAE,gBAAgB;AAElB,QAAA,CAAC,MAAM,OAAO,IAAI;AAAA,IACtB,KAAK,EAAE,IAAK,MAAM,QAAQ,KAAK,EAAE,CAAC,IAAI,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,IAAK;AAAA,EAAA;AAG3D,QAAA,eAA4C,CAAC,SAAS;AAC1D,UAAM,UAAU,MAAM,QAAQ,IAAI,IAC9B,KAAK,IAAI,CAAC,MAAM,EAAE,EAAY,IAC5B,MAAM,MAAiB;AAEjB,gBAAA,CAAC,UAAU,EAAE,GAAG,MAAM,CAAC,EAAE,GAAG,QAAU,EAAA;AAClD;AAAA,MACE,UAAW,MAAM,QAAQ,OAAO,IAAI,UAAU,CAAC,OAAO,IAAK;AAAA,IAAA;AAAA,EAC7D;AAIA,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAU;AAAA,MACV,eAAa;AAAA,MACb;AAAA,MACA,QAAQ,SAAS,IAAI,CAAC,WAAW;AAC/B,cAAM,WAAW,OAAO,WAAW,WAAW,SAAS,OAAO;AAC9D,cAAM,cAAc,OAAO,WAAW,WAAW,SAAS,OAAO;AAE1D,eAAA;AAAA,UACL,IAAI;AAAA,UACJ,OAAO;AAAA,UACP,UAAU,CAAC,CAAC,MAAM,KAAK,CAAC,QAAQ,QAAQ,QAAQ;AAAA,QAAA;AAAA,MAClD,CACD;AAAA,MACD,UAAU;AAAA,MACV,WAAW;AAAA,MACX,aAAa;AAAA,IAAA;AAAA,EAAA;AAGnB;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Slider.js","sources":["../../../../../src/Flow/Node/Parameters/Slider.tsx"],"sourcesContent":["import { css } from \"@emotion/css\";\nimport { HvSlider } from \"@hitachivantara/uikit-react-core\";\n\nimport { useFlowNodeUtils } from \"../../hooks\";\nimport { HvFlowNodeSliderParam } from \"../../types\";\n\ninterface SliderProps {\n param: Omit<HvFlowNodeSliderParam, \"type\">;\n data: any;\n}\n\nconst classes = {\n labelContainer: css({\n marginRight: 0,\n marginLeft: 0,\n }),\n sliderBase: css({\n padding: 0,\n }),\n};\n\nconst Slider = ({ param, data }: SliderProps) => {\n const { id } = param;\n const { setNodeData } = useFlowNodeUtils();\n\n return (\n <HvSlider\n className=\"nodrag\" // Prevents dragging within the input field\n defaultValues={data[id]}\n onChange={(val) => setNodeData((prev) => ({ ...prev, [id]: val }))}\n classes={{\n labelContainer: classes.labelContainer,\n sliderBase: classes.sliderBase,\n }}\n {...param}\n />\n );\n};\n\nexport default Slider;\n"],"names":[],"mappings":";;;;AAWA,MAAM,UAAU;AAAA,EACd,gBAAgB,IAAI;AAAA,IAClB,aAAa;AAAA,IACb,YAAY;AAAA,EAAA,CACb;AAAA,EACD,YAAY,IAAI;AAAA,IACd,SAAS;AAAA,EAAA,CACV;AACH;AAEA,MAAM,SAAS,CAAC,EAAE,OAAO,WAAwB;AACzC,QAAA,EAAE,GAAO,IAAA;AACT,QAAA,EAAE,gBAAgB;AAGtB,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAU;AAAA,MACV,eAAe,KAAK,EAAE;AAAA,MACtB,UAAU,CAAC,QAAQ,YAAY,CAAC,UAAU,EAAE,GAAG,MAAM,CAAC,EAAE,GAAG,MAAM;AAAA,MACjE,SAAS;AAAA,QACP,gBAAgB,QAAQ;AAAA,QACxB,YAAY,QAAQ;AAAA,MACtB;AAAA,MACC,GAAG;AAAA,IAAA;AAAA,EAAA;AAGV;
|
|
1
|
+
{"version":3,"file":"Slider.js","sources":["../../../../../src/Flow/Node/Parameters/Slider.tsx"],"sourcesContent":["import { css } from \"@emotion/css\";\nimport { HvSlider } from \"@hitachivantara/uikit-react-core\";\n\nimport { useFlowNodeUtils } from \"../../hooks\";\nimport { HvFlowNodeSliderParam } from \"../../types\";\n\ninterface SliderProps {\n param: Omit<HvFlowNodeSliderParam, \"type\">;\n data: any;\n}\n\nconst classes = {\n labelContainer: css({\n marginRight: 0,\n marginLeft: 0,\n }),\n sliderBase: css({\n padding: 0,\n }),\n};\n\nconst Slider = ({ param, data }: SliderProps) => {\n const { id } = param;\n const { setNodeData } = useFlowNodeUtils();\n\n return (\n <HvSlider\n className=\"nodrag\" // Prevents dragging within the input field\n defaultValues={data[id]}\n onChange={(val) => setNodeData((prev) => ({ ...prev, [id]: val }))}\n classes={{\n labelContainer: classes.labelContainer,\n sliderBase: classes.sliderBase,\n }}\n {...param}\n />\n );\n};\n\nexport default Slider;\n"],"names":[],"mappings":";;;;AAWA,MAAM,UAAU;AAAA,EACd,gBAAgB,IAAI;AAAA,IAClB,aAAa;AAAA,IACb,YAAY;AAAA,EAAA,CACb;AAAA,EACD,YAAY,IAAI;AAAA,IACd,SAAS;AAAA,EAAA,CACV;AACH;AAEA,MAAM,SAAS,CAAC,EAAE,OAAO,WAAwB;AACzC,QAAA,EAAE,GAAO,IAAA;AACT,QAAA,EAAE,gBAAgB;AAGtB,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAU;AAAA,MACV,eAAe,KAAK,EAAE;AAAA,MACtB,UAAU,CAAC,QAAQ,YAAY,CAAC,UAAU,EAAE,GAAG,MAAM,CAAC,EAAE,GAAG,MAAM;AAAA,MACjE,SAAS;AAAA,QACP,gBAAgB,QAAQ;AAAA,QACxB,YAAY,QAAQ;AAAA,MACtB;AAAA,MACC,GAAG;AAAA,IAAA;AAAA,EAAA;AAGV;"}
|