@hitachivantara/uikit-react-lab 5.4.49 → 5.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/Flow/Background/Background.cjs +16 -0
- package/dist/cjs/components/Flow/Background/Background.cjs.map +1 -0
- package/dist/cjs/components/Flow/Controls/Controls.cjs +108 -0
- package/dist/cjs/components/Flow/Controls/Controls.cjs.map +1 -0
- package/dist/cjs/components/Flow/DroppableFlow.cjs +105 -0
- package/dist/cjs/components/Flow/DroppableFlow.cjs.map +1 -0
- package/dist/cjs/components/Flow/Flow.cjs +53 -0
- package/dist/cjs/components/Flow/Flow.cjs.map +1 -0
- package/dist/cjs/components/Flow/Flow.styles.cjs +14 -0
- package/dist/cjs/components/Flow/Flow.styles.cjs.map +1 -0
- package/dist/cjs/components/Flow/FlowContext/FlowContext.cjs +27 -0
- package/dist/cjs/components/Flow/FlowContext/FlowContext.cjs.map +1 -0
- package/dist/cjs/components/Flow/Minimap/Minimap.cjs +31 -0
- package/dist/cjs/components/Flow/Minimap/Minimap.cjs.map +1 -0
- package/dist/cjs/components/Flow/Minimap/Minimap.styles.cjs +16 -0
- package/dist/cjs/components/Flow/Minimap/Minimap.styles.cjs.map +1 -0
- package/dist/cjs/components/Flow/Sidebar/Sidebar.cjs +121 -0
- package/dist/cjs/components/Flow/Sidebar/Sidebar.cjs.map +1 -0
- package/dist/cjs/components/Flow/Sidebar/Sidebar.styles.cjs +34 -0
- package/dist/cjs/components/Flow/Sidebar/Sidebar.styles.cjs.map +1 -0
- package/dist/cjs/components/Flow/Sidebar/SidebarGroup/SidebarGroup.cjs +78 -0
- package/dist/cjs/components/Flow/Sidebar/SidebarGroup/SidebarGroup.cjs.map +1 -0
- package/dist/cjs/components/Flow/Sidebar/SidebarGroup/SidebarGroup.styles.cjs +37 -0
- package/dist/cjs/components/Flow/Sidebar/SidebarGroup/SidebarGroup.styles.cjs.map +1 -0
- package/dist/cjs/components/Flow/Sidebar/SidebarGroup/SidebarGroupItem/DraggableSidebarGroupItem.cjs +48 -0
- package/dist/cjs/components/Flow/Sidebar/SidebarGroup/SidebarGroupItem/DraggableSidebarGroupItem.cjs.map +1 -0
- package/dist/cjs/components/Flow/Sidebar/SidebarGroup/SidebarGroupItem/SidebarGroupItem.cjs +34 -0
- package/dist/cjs/components/Flow/Sidebar/SidebarGroup/SidebarGroupItem/SidebarGroupItem.cjs.map +1 -0
- package/dist/cjs/components/Flow/Sidebar/SidebarGroup/SidebarGroupItem/SidebarGroupItem.styles.cjs +26 -0
- package/dist/cjs/components/Flow/Sidebar/SidebarGroup/SidebarGroupItem/SidebarGroupItem.styles.cjs.map +1 -0
- package/dist/cjs/components/Flow/Sidebar/utils.cjs +27 -0
- package/dist/cjs/components/Flow/Sidebar/utils.cjs.map +1 -0
- package/dist/cjs/index.cjs +16 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/components/Flow/Background/Background.js +16 -0
- package/dist/esm/components/Flow/Background/Background.js.map +1 -0
- package/dist/esm/components/Flow/Controls/Controls.js +108 -0
- package/dist/esm/components/Flow/Controls/Controls.js.map +1 -0
- package/dist/esm/components/Flow/DroppableFlow.js +104 -0
- package/dist/esm/components/Flow/DroppableFlow.js.map +1 -0
- package/dist/esm/components/Flow/Flow.js +53 -0
- package/dist/esm/components/Flow/Flow.js.map +1 -0
- package/dist/esm/components/Flow/Flow.styles.js +14 -0
- package/dist/esm/components/Flow/Flow.styles.js.map +1 -0
- package/dist/esm/components/Flow/FlowContext/FlowContext.js +27 -0
- package/dist/esm/components/Flow/FlowContext/FlowContext.js.map +1 -0
- package/dist/esm/components/Flow/Minimap/Minimap.js +32 -0
- package/dist/esm/components/Flow/Minimap/Minimap.js.map +1 -0
- package/dist/esm/components/Flow/Minimap/Minimap.styles.js +16 -0
- package/dist/esm/components/Flow/Minimap/Minimap.styles.js.map +1 -0
- package/dist/esm/components/Flow/Sidebar/Sidebar.js +120 -0
- package/dist/esm/components/Flow/Sidebar/Sidebar.js.map +1 -0
- package/dist/esm/components/Flow/Sidebar/Sidebar.styles.js +34 -0
- package/dist/esm/components/Flow/Sidebar/Sidebar.styles.js.map +1 -0
- package/dist/esm/components/Flow/Sidebar/SidebarGroup/SidebarGroup.js +79 -0
- package/dist/esm/components/Flow/Sidebar/SidebarGroup/SidebarGroup.js.map +1 -0
- package/dist/esm/components/Flow/Sidebar/SidebarGroup/SidebarGroup.styles.js +37 -0
- package/dist/esm/components/Flow/Sidebar/SidebarGroup/SidebarGroup.styles.js.map +1 -0
- package/dist/esm/components/Flow/Sidebar/SidebarGroup/SidebarGroupItem/DraggableSidebarGroupItem.js +48 -0
- package/dist/esm/components/Flow/Sidebar/SidebarGroup/SidebarGroupItem/DraggableSidebarGroupItem.js.map +1 -0
- package/dist/esm/components/Flow/Sidebar/SidebarGroup/SidebarGroupItem/SidebarGroupItem.js +35 -0
- package/dist/esm/components/Flow/Sidebar/SidebarGroup/SidebarGroupItem/SidebarGroupItem.js.map +1 -0
- package/dist/esm/components/Flow/Sidebar/SidebarGroup/SidebarGroupItem/SidebarGroupItem.styles.js +26 -0
- package/dist/esm/components/Flow/Sidebar/SidebarGroup/SidebarGroupItem/SidebarGroupItem.styles.js.map +1 -0
- package/dist/esm/components/Flow/Sidebar/utils.js +27 -0
- package/dist/esm/components/Flow/Sidebar/utils.js.map +1 -0
- package/dist/esm/index.js +16 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/types/index.d.ts +216 -0
- package/package.json +10 -4
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { useSensors, useSensor, PointerSensor, KeyboardSensor, DndContext, DragOverlay } from "@dnd-kit/core";
|
|
3
|
+
import { restrictToWindowEdges } from "@dnd-kit/modifiers";
|
|
4
|
+
import { ReactFlowProvider } from "reactflow";
|
|
5
|
+
import { HvDroppableFlow } from "./DroppableFlow.js";
|
|
6
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
7
|
+
import { HvFlowProvider } from "./FlowContext/FlowContext.js";
|
|
8
|
+
import { HvFlowSidebarGroupItem } from "./Sidebar/SidebarGroup/SidebarGroupItem/SidebarGroupItem.js";
|
|
9
|
+
const HvFlow = ({
|
|
10
|
+
nodeTypes,
|
|
11
|
+
nodeGroups,
|
|
12
|
+
sidebar,
|
|
13
|
+
dndContextProps,
|
|
14
|
+
...others
|
|
15
|
+
}) => {
|
|
16
|
+
const [draggingLabel, setDraggingLabel] = useState(void 0);
|
|
17
|
+
const sensors = useSensors(useSensor(PointerSensor), useSensor(KeyboardSensor));
|
|
18
|
+
const handleDragStart = (event) => {
|
|
19
|
+
var _a, _b;
|
|
20
|
+
if ((_a = event.active.data.current) == null ? void 0 : _a.hvFlow) {
|
|
21
|
+
setDraggingLabel((_b = event.active.data.current.hvFlow) == null ? void 0 : _b.label);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const handleDragEnd = () => {
|
|
25
|
+
setDraggingLabel(void 0);
|
|
26
|
+
};
|
|
27
|
+
return /* @__PURE__ */ jsx(ReactFlowProvider, {
|
|
28
|
+
children: /* @__PURE__ */ jsx(HvFlowProvider, {
|
|
29
|
+
nodeGroups,
|
|
30
|
+
nodeTypes,
|
|
31
|
+
children: /* @__PURE__ */ jsxs(DndContext, {
|
|
32
|
+
onDragStart: handleDragStart,
|
|
33
|
+
onDragEnd: handleDragEnd,
|
|
34
|
+
sensors,
|
|
35
|
+
modifiers: [restrictToWindowEdges],
|
|
36
|
+
...dndContextProps,
|
|
37
|
+
children: [/* @__PURE__ */ jsx(HvDroppableFlow, {
|
|
38
|
+
...others
|
|
39
|
+
}), sidebar, /* @__PURE__ */ jsx(DragOverlay, {
|
|
40
|
+
modifiers: [restrictToWindowEdges],
|
|
41
|
+
children: draggingLabel ? /* @__PURE__ */ jsx(HvFlowSidebarGroupItem, {
|
|
42
|
+
label: draggingLabel,
|
|
43
|
+
isDragging: true
|
|
44
|
+
}) : null
|
|
45
|
+
})]
|
|
46
|
+
})
|
|
47
|
+
})
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
export {
|
|
51
|
+
HvFlow
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=Flow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Flow.js","sources":["../../../../src/components/Flow/Flow.tsx"],"sourcesContent":["import { useState } from \"react\";\n\nimport {\n DndContext,\n DndContextProps,\n DragOverlay,\n KeyboardSensor,\n PointerSensor,\n useSensor,\n useSensors,\n} from \"@dnd-kit/core\";\nimport { restrictToWindowEdges } from \"@dnd-kit/modifiers\";\n\nimport { ReactFlowProvider } from \"reactflow\";\n\nimport { HvFlowNodeGroups, HvFlowNodeTypes } from \"./types\";\nimport { HvFlowProvider } from \"./FlowContext\";\nimport { HvDroppableFlow, HvDroppableFlowProps } from \"./DroppableFlow\";\nimport { HvFlowSidebarGroupItem } from \"./Sidebar/SidebarGroup/SidebarGroupItem\";\n\nexport interface HvFlowProps<\n NodeData = any,\n NodeType extends string | undefined = string | undefined,\n NodeGroups extends keyof any = string\n> extends HvDroppableFlowProps<NodeData, NodeType> {\n /** Flow nodes groups. */\n nodeGroups?: HvFlowNodeGroups<NodeGroups>;\n /** Flow nodes types. */\n nodeTypes?: HvFlowNodeTypes<NodeGroups>;\n /** Flow sidebar. */\n sidebar?: React.ReactNode;\n /**\n * Dnd Kit context props. This should be used for accessibility purposes.\n *\n * More information can be found on the [Dnd Kit documentation](https://docs.dndkit.com/guides/accessibility)\n */\n dndContextProps?: Pick<DndContextProps, \"accessibility\">;\n}\n\n/**\n * Flow component to build interactive node-based UIs.\n *\n * This implementation leverages [React Flow](https://reactflow.dev).\n * The drag and drop functionality leverages [Dnd Kit](https://docs.dndkit.com)\n *\n * DISCLAIMER: This component is a work in progress and there might be breaking changes.\n */\nexport const HvFlow = ({\n nodeTypes,\n nodeGroups,\n sidebar,\n dndContextProps,\n ...others\n}: HvFlowProps) => {\n const [draggingLabel, setDraggingLabel] = useState(undefined);\n\n const sensors = useSensors(\n useSensor(PointerSensor),\n useSensor(KeyboardSensor)\n );\n\n const handleDragStart: DndContextProps[\"onDragStart\"] = (event) => {\n if (event.active.data.current?.hvFlow) {\n setDraggingLabel(event.active.data.current.hvFlow?.label);\n }\n };\n\n const handleDragEnd: DndContextProps[\"onDragEnd\"] = () => {\n setDraggingLabel(undefined);\n };\n\n // We're wrapping the main Flow component with the ReactFlowProvider to access the react flow instance.\n // HvFlowContext is our custom internal context.\n return (\n <ReactFlowProvider>\n <HvFlowProvider nodeGroups={nodeGroups} nodeTypes={nodeTypes}>\n <DndContext\n onDragStart={handleDragStart}\n onDragEnd={handleDragEnd}\n sensors={sensors}\n modifiers={[restrictToWindowEdges]}\n {...dndContextProps}\n >\n <HvDroppableFlow {...others} />\n {sidebar}\n <DragOverlay modifiers={[restrictToWindowEdges]}>\n {draggingLabel ? (\n <HvFlowSidebarGroupItem label={draggingLabel} isDragging />\n ) : null}\n </DragOverlay>\n </DndContext>\n </HvFlowProvider>\n </ReactFlowProvider>\n );\n};\n"],"names":["HvFlow","nodeTypes","nodeGroups","sidebar","dndContextProps","others","draggingLabel","setDraggingLabel","useState","undefined","sensors","useSensors","useSensor","PointerSensor","KeyboardSensor","handleDragStart","event","active","data","current","hvFlow","label","handleDragEnd","ReactFlowProvider","children","HvFlowProvider","DndContext","onDragStart","onDragEnd","modifiers","restrictToWindowEdges","_jsx","HvDroppableFlow","DragOverlay","HvFlowSidebarGroupItem","isDragging"],"mappings":";;;;;;;;AA+CO,MAAMA,SAASA,CAAC;AAAA,EACrBC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACA,GAAGC;AACQ,MAAM;AACjB,QAAM,CAACC,eAAeC,gBAAgB,IAAIC,SAASC,MAAS;AAE5D,QAAMC,UAAUC,WACdC,UAAUC,aAAa,GACvBD,UAAUE,cAAc,CAC1B;AAEA,QAAMC,kBAAmDC,CAAU,UAAA;;AACjE,SAAIA,WAAMC,OAAOC,KAAKC,YAAlBH,mBAA2BI,QAAQ;AACrCb,wBAAiBS,WAAMC,OAAOC,KAAKC,QAAQC,WAA1BJ,mBAAkCK,KAAK;AAAA,IAC1D;AAAA,EAAA;AAGF,QAAMC,gBAA8CA,MAAM;AACxDf,qBAAiBE,MAAS;AAAA,EAAA;AAK5B,6BACGc,mBAAiB;AAAA,IAAAC,8BACfC,gBAAc;AAAA,MAACvB;AAAAA,MAAwBD;AAAAA,MAAqBuB,+BAC1DE,YAAU;AAAA,QACTC,aAAaZ;AAAAA,QACba,WAAWN;AAAAA,QACXZ;AAAAA,QACAmB,WAAW,CAACC,qBAAqB;AAAA,QAAE,GAC/B1B;AAAAA,QAAeoB,UAAA,CAEnBO,oBAACC,iBAAe;AAAA,UAAA,GAAK3B;AAAAA,QAAAA,CAAS,GAC7BF,SACD4B,oBAACE,aAAW;AAAA,UAACJ,WAAW,CAACC,qBAAqB;AAAA,UAAEN,UAC7ClB,gBACCyB,oBAACG,wBAAsB;AAAA,YAACb,OAAOf;AAAAA,YAAe6B,YAAU;AAAA,UAAE,CAAA,IACxD;AAAA,QAAA,CACO,CAAC;AAAA,MAAA,CACJ;AAAA,IAAA,CACE;AAAA,EAAA,CACC;AAEvB;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createClasses } from "@hitachivantara/uikit-react-core";
|
|
2
|
+
const {
|
|
3
|
+
staticClasses,
|
|
4
|
+
useClasses
|
|
5
|
+
} = createClasses("HvFlow", {
|
|
6
|
+
root: {
|
|
7
|
+
height: "100%"
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
export {
|
|
11
|
+
staticClasses,
|
|
12
|
+
useClasses
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=Flow.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Flow.styles.js","sources":["../../../../src/components/Flow/Flow.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-core\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvFlow\", {\n root: { height: \"100%\" },\n});\n"],"names":["staticClasses","useClasses","createClasses","root","height"],"mappings":";AAEa,MAAA;AAAA,EAAEA;AAAAA,EAAeC;AAAW,IAAIC,cAAc,UAAU;AAAA,EACnEC,MAAM;AAAA,IAAEC,QAAQ;AAAA,EAAO;AACzB,CAAC;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createContext, useState, useMemo, useContext } from "react";
|
|
2
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
3
|
+
const HvFlowContext = createContext({});
|
|
4
|
+
const HvFlowProvider = ({
|
|
5
|
+
nodeGroups,
|
|
6
|
+
nodeTypes,
|
|
7
|
+
children
|
|
8
|
+
}) => {
|
|
9
|
+
const [expandedNodeGroups, setExpandedNodeGroups] = useState([]);
|
|
10
|
+
const value = useMemo(() => ({
|
|
11
|
+
nodeTypes,
|
|
12
|
+
nodeGroups,
|
|
13
|
+
expandedNodeGroups,
|
|
14
|
+
setExpandedNodeGroups
|
|
15
|
+
}), [nodeGroups, nodeTypes, expandedNodeGroups]);
|
|
16
|
+
return /* @__PURE__ */ jsx(HvFlowContext.Provider, {
|
|
17
|
+
value,
|
|
18
|
+
children
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
const useFlowContext = () => useContext(HvFlowContext);
|
|
22
|
+
export {
|
|
23
|
+
HvFlowContext,
|
|
24
|
+
HvFlowProvider,
|
|
25
|
+
useFlowContext
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=FlowContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FlowContext.js","sources":["../../../../../src/components/Flow/FlowContext/FlowContext.tsx"],"sourcesContent":["import {\n Dispatch,\n SetStateAction,\n createContext,\n useContext,\n useMemo,\n useState,\n} from \"react\";\n\nimport { HvFlowNodeGroups, HvFlowNodeTypes } from \"../types\";\n\nexport interface HvFlowContextValue<NodeGroups extends keyof any = string> {\n /** Flow nodes types. */\n nodeTypes?: HvFlowNodeTypes<NodeGroups>;\n /** Flow nodes groups. */\n nodeGroups?: HvFlowNodeGroups<NodeGroups>;\n /** Flow nodes groups expanded on sidebar. */\n expandedNodeGroups?: string[];\n /** Function to set `expandedNodeGroups`. */\n setExpandedNodeGroups?: Dispatch<SetStateAction<string[]>>;\n}\n\nexport const HvFlowContext = createContext<HvFlowContextValue>({});\n\nexport interface HvFlowProviderProps<NodeGroups extends keyof any = string> {\n /** Flow nodes types. */\n nodeTypes?: HvFlowContextValue<NodeGroups>[\"nodeTypes\"];\n /** Flow nodes groups. */\n nodeGroups?: HvFlowContextValue<NodeGroups>[\"nodeGroups\"];\n /** Children. */\n children?: React.ReactNode;\n}\n\nexport const HvFlowProvider = ({\n nodeGroups,\n nodeTypes,\n children,\n}: HvFlowProviderProps) => {\n const [expandedNodeGroups, setExpandedNodeGroups] = useState<string[]>([]);\n\n const value = useMemo(\n () => ({\n nodeTypes,\n nodeGroups,\n expandedNodeGroups,\n setExpandedNodeGroups,\n }),\n [nodeGroups, nodeTypes, expandedNodeGroups]\n );\n\n return (\n <HvFlowContext.Provider value={value}>{children}</HvFlowContext.Provider>\n );\n};\n\nexport const useFlowContext = () => useContext(HvFlowContext);\n"],"names":["HvFlowContext","createContext","HvFlowProvider","nodeGroups","nodeTypes","children","expandedNodeGroups","setExpandedNodeGroups","useState","value","useMemo","_jsx","Provider","useFlowContext","useContext"],"mappings":";;AAsBaA,MAAAA,gBAAgBC,cAAkC,EAAE;AAW1D,MAAMC,iBAAiBA,CAAC;AAAA,EAC7BC;AAAAA,EACAC;AAAAA,EACAC;AACmB,MAAM;AACzB,QAAM,CAACC,oBAAoBC,qBAAqB,IAAIC,SAAmB,CAAE,CAAA;AAEnEC,QAAAA,QAAQC,QACZ,OAAO;AAAA,IACLN;AAAAA,IACAD;AAAAA,IACAG;AAAAA,IACAC;AAAAA,EAEF,IAAA,CAACJ,YAAYC,WAAWE,kBAAkB,CAC5C;AAGEK,SAAAA,oBAACX,cAAcY,UAAQ;AAAA,IAACH;AAAAA,IAAaJ;AAAAA,EAAAA,CAAmC;AAE5E;AAEaQ,MAAAA,iBAAiBA,MAAMC,WAAWd,aAAa;"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { MiniMap } from "reactflow";
|
|
2
|
+
import { getColor, theme } from "@hitachivantara/uikit-styles";
|
|
3
|
+
import { useClasses } from "./Minimap.styles.js";
|
|
4
|
+
import { staticClasses } from "./Minimap.styles.js";
|
|
5
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
6
|
+
const HvFlowMinimap = ({
|
|
7
|
+
nodeColor = "atmo4",
|
|
8
|
+
maskColor = "atmo3",
|
|
9
|
+
maskStrokeColor = "atmo3",
|
|
10
|
+
nodeStrokeColor = "atmo4",
|
|
11
|
+
classes: classesProp,
|
|
12
|
+
className,
|
|
13
|
+
...others
|
|
14
|
+
}) => {
|
|
15
|
+
const {
|
|
16
|
+
classes,
|
|
17
|
+
cx
|
|
18
|
+
} = useClasses(classesProp);
|
|
19
|
+
return /* @__PURE__ */ jsx(MiniMap, {
|
|
20
|
+
className: cx(classes.root, className),
|
|
21
|
+
nodeColor: typeof nodeColor === "string" ? getColor(nodeColor, theme.colors.atmo4) : nodeColor,
|
|
22
|
+
nodeStrokeColor: typeof nodeStrokeColor === "string" ? getColor(nodeStrokeColor, theme.colors.atmo4) : nodeStrokeColor,
|
|
23
|
+
maskColor: getColor(maskColor, theme.colors.atmo3),
|
|
24
|
+
maskStrokeColor: getColor(maskStrokeColor, theme.colors.atmo3),
|
|
25
|
+
...others
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
HvFlowMinimap,
|
|
30
|
+
staticClasses as flowMinimapClasses
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=Minimap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Minimap.js","sources":["../../../../../src/components/Flow/Minimap/Minimap.tsx"],"sourcesContent":["import { GetMiniMapNodeAttribute, MiniMap, MiniMapProps } from \"reactflow\";\n\nimport { ExtractNames } from \"@hitachivantara/uikit-react-core\";\nimport { HvColorAny, getColor, theme } from \"@hitachivantara/uikit-styles\";\n\nimport { staticClasses, useClasses } from \"./Minimap.styles\";\n\nexport { staticClasses as flowMinimapClasses };\n\nexport type HvFlowMinimapClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvFlowMinimapProps<NodeData = any>\n extends Omit<\n MiniMapProps<NodeData>,\n \"nodeColor\" | \"nodeStrokeColor\" | \"maskColor\" | \"maskStrokeColor\"\n > {\n /** Node color. Defaults to `atmo4`. */\n nodeColor?: HvColorAny | GetMiniMapNodeAttribute<NodeData>;\n /** Node stroke color. Defaults to `atmo4`. */\n nodeStrokeColor?: HvColorAny | GetMiniMapNodeAttribute<NodeData>;\n /** Mask color. Defaults to `atmo3`. */\n maskColor?: HvColorAny;\n /** Mask stroke color. Defaults to `atmo3`. */\n maskStrokeColor?: HvColorAny;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvFlowMinimapClasses;\n}\n\nexport const HvFlowMinimap = ({\n nodeColor = \"atmo4\",\n maskColor = \"atmo3\",\n maskStrokeColor = \"atmo3\",\n nodeStrokeColor = \"atmo4\",\n classes: classesProp,\n className,\n ...others\n}: HvFlowMinimapProps) => {\n const { classes, cx } = useClasses(classesProp);\n\n return (\n <MiniMap\n className={cx(classes.root, className)}\n nodeColor={\n typeof nodeColor === \"string\"\n ? getColor(nodeColor, theme.colors.atmo4)\n : nodeColor\n }\n nodeStrokeColor={\n typeof nodeStrokeColor === \"string\"\n ? getColor(nodeStrokeColor, theme.colors.atmo4)\n : nodeStrokeColor\n }\n maskColor={getColor(maskColor, theme.colors.atmo3)}\n maskStrokeColor={getColor(maskStrokeColor, theme.colors.atmo3)}\n {...others}\n />\n );\n};\n"],"names":["HvFlowMinimap","nodeColor","maskColor","maskStrokeColor","nodeStrokeColor","classes","classesProp","className","others","cx","useClasses","MiniMap","root","getColor","theme","colors","atmo4","atmo3"],"mappings":";;;;;AA4BO,MAAMA,gBAAgBA,CAAC;AAAA,EAC5BC,YAAY;AAAA,EACZC,YAAY;AAAA,EACZC,kBAAkB;AAAA,EAClBC,kBAAkB;AAAA,EAClBC,SAASC;AAAAA,EACTC;AAAAA,EACA,GAAGC;AACe,MAAM;AAClB,QAAA;AAAA,IAAEH;AAAAA,IAASI;AAAAA,EAAAA,IAAOC,WAAWJ,WAAW;AAE9C,6BACGK,SAAO;AAAA,IACNJ,WAAWE,GAAGJ,QAAQO,MAAML,SAAS;AAAA,IACrCN,WACE,OAAOA,cAAc,WACjBY,SAASZ,WAAWa,MAAMC,OAAOC,KAAK,IACtCf;AAAAA,IAENG,iBACE,OAAOA,oBAAoB,WACvBS,SAAST,iBAAiBU,MAAMC,OAAOC,KAAK,IAC5CZ;AAAAA,IAENF,WAAWW,SAASX,WAAWY,MAAMC,OAAOE,KAAK;AAAA,IACjDd,iBAAiBU,SAASV,iBAAiBW,MAAMC,OAAOE,KAAK;AAAA,IAAE,GAC3DT;AAAAA,EAAAA,CACL;AAEL;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createClasses, theme } from "@hitachivantara/uikit-react-core";
|
|
2
|
+
const {
|
|
3
|
+
staticClasses,
|
|
4
|
+
useClasses
|
|
5
|
+
} = createClasses("HvFlowMinimap", {
|
|
6
|
+
root: {
|
|
7
|
+
"&.react-flow__minimap": {
|
|
8
|
+
backgroundColor: theme.colors.atmo2
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
export {
|
|
13
|
+
staticClasses,
|
|
14
|
+
useClasses
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=Minimap.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Minimap.styles.js","sources":["../../../../../src/components/Flow/Minimap/Minimap.styles.tsx"],"sourcesContent":["import { createClasses, theme } from \"@hitachivantara/uikit-react-core\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvFlowMinimap\", {\n root: {\n \"&.react-flow__minimap\": { backgroundColor: theme.colors.atmo2 },\n },\n});\n"],"names":["staticClasses","useClasses","createClasses","root","backgroundColor","theme","colors","atmo2"],"mappings":";AAEa,MAAA;AAAA,EAAEA;AAAAA,EAAeC;AAAW,IAAIC,cAAc,iBAAiB;AAAA,EAC1EC,MAAM;AAAA,IACJ,yBAAyB;AAAA,MAAEC,iBAAiBC,MAAMC,OAAOC;AAAAA,IAAM;AAAA,EACjE;AACF,CAAC;"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { useMemo, useState } from "react";
|
|
2
|
+
import debounce from "lodash/debounce";
|
|
3
|
+
import { useDroppable } from "@dnd-kit/core";
|
|
4
|
+
import { useLabels, useUniqueId, HvDrawer, HvTypography, HvInput } from "@hitachivantara/uikit-react-core";
|
|
5
|
+
import { Add } from "@hitachivantara/uikit-react-icons";
|
|
6
|
+
import { useClasses } from "./Sidebar.styles.js";
|
|
7
|
+
import { staticClasses } from "./Sidebar.styles.js";
|
|
8
|
+
import { buildGroups } from "./utils.js";
|
|
9
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
10
|
+
import { HvFlowSidebarGroup } from "./SidebarGroup/SidebarGroup.js";
|
|
11
|
+
import { useFlowContext } from "../FlowContext/FlowContext.js";
|
|
12
|
+
const DEFAULT_LABELS = {
|
|
13
|
+
itemAriaRoleDescription: "Draggable",
|
|
14
|
+
expandGroupButtonAriaLabel: "Expand group",
|
|
15
|
+
searchPlaceholder: "Search node...",
|
|
16
|
+
searchAriaLabel: "Search node..."
|
|
17
|
+
};
|
|
18
|
+
const HvFlowSidebar = ({
|
|
19
|
+
id,
|
|
20
|
+
title,
|
|
21
|
+
description,
|
|
22
|
+
anchor = "right",
|
|
23
|
+
buttonTitle = "Close",
|
|
24
|
+
classes: classesProp,
|
|
25
|
+
labels: labelsProps,
|
|
26
|
+
...others
|
|
27
|
+
}) => {
|
|
28
|
+
const {
|
|
29
|
+
classes
|
|
30
|
+
} = useClasses(classesProp);
|
|
31
|
+
const {
|
|
32
|
+
nodeGroups,
|
|
33
|
+
nodeTypes,
|
|
34
|
+
setExpandedNodeGroups
|
|
35
|
+
} = useFlowContext();
|
|
36
|
+
const unfilteredGroups = useMemo(() => buildGroups(nodeGroups, nodeTypes), [nodeGroups, nodeTypes]);
|
|
37
|
+
const [groups, setGroups] = useState(unfilteredGroups);
|
|
38
|
+
const labels = useLabels(DEFAULT_LABELS, labelsProps);
|
|
39
|
+
const drawerElementId = useUniqueId(id, "hvFlowSidebarDrawer");
|
|
40
|
+
const groupsElementId = useUniqueId(id, "hvFlowSidebarGroups");
|
|
41
|
+
const {
|
|
42
|
+
setNodeRef
|
|
43
|
+
} = useDroppable({
|
|
44
|
+
id: drawerElementId
|
|
45
|
+
});
|
|
46
|
+
const handleSearch = (event, value) => {
|
|
47
|
+
const gps = value ? Object.entries(unfilteredGroups).reduce((acc, curr) => {
|
|
48
|
+
const filteredNodes = curr[1].nodes.filter((obj) => obj.label.toLocaleLowerCase().includes(value.toLocaleLowerCase()));
|
|
49
|
+
const nodesCount = filteredNodes.length;
|
|
50
|
+
if (nodesCount > 0) {
|
|
51
|
+
acc[curr[0]] = {
|
|
52
|
+
...curr[1],
|
|
53
|
+
nodes: filteredNodes
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return acc;
|
|
57
|
+
}, {}) : unfilteredGroups;
|
|
58
|
+
setGroups(gps);
|
|
59
|
+
setExpandedNodeGroups == null ? void 0 : setExpandedNodeGroups(value ? Object.keys(gps) : []);
|
|
60
|
+
};
|
|
61
|
+
const handleDebouncedSearch = debounce(handleSearch, 500);
|
|
62
|
+
return /* @__PURE__ */ jsx(HvDrawer, {
|
|
63
|
+
BackdropComponent: void 0,
|
|
64
|
+
variant: "persistent",
|
|
65
|
+
classes: {
|
|
66
|
+
paper: classes.drawerPaper
|
|
67
|
+
},
|
|
68
|
+
anchor,
|
|
69
|
+
buttonTitle,
|
|
70
|
+
...others,
|
|
71
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
72
|
+
id: drawerElementId,
|
|
73
|
+
ref: setNodeRef,
|
|
74
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
75
|
+
className: classes.titleContainer,
|
|
76
|
+
children: [/* @__PURE__ */ jsx(Add, {
|
|
77
|
+
role: "none"
|
|
78
|
+
}), /* @__PURE__ */ jsx(HvTypography, {
|
|
79
|
+
variant: "title3",
|
|
80
|
+
children: title
|
|
81
|
+
})]
|
|
82
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
83
|
+
className: classes.contentContainer,
|
|
84
|
+
children: [/* @__PURE__ */ jsx(HvTypography, {
|
|
85
|
+
className: classes.description,
|
|
86
|
+
children: description
|
|
87
|
+
}), /* @__PURE__ */ jsx(HvInput, {
|
|
88
|
+
className: classes.searchRoot,
|
|
89
|
+
type: "search",
|
|
90
|
+
placeholder: labels == null ? void 0 : labels.searchPlaceholder,
|
|
91
|
+
"aria-label": labels == null ? void 0 : labels.searchAriaLabel,
|
|
92
|
+
"aria-controls": groupsElementId,
|
|
93
|
+
"aria-owns": groupsElementId,
|
|
94
|
+
onChange: handleDebouncedSearch,
|
|
95
|
+
inputProps: {
|
|
96
|
+
autoComplete: "off"
|
|
97
|
+
}
|
|
98
|
+
}), /* @__PURE__ */ jsx("ul", {
|
|
99
|
+
id: groupsElementId,
|
|
100
|
+
className: classes.groupsContainer,
|
|
101
|
+
children: Object.entries(groups).map((obj) => /* @__PURE__ */ jsx(HvFlowSidebarGroup, {
|
|
102
|
+
id: obj[0],
|
|
103
|
+
expandButtonProps: {
|
|
104
|
+
"aria-label": labels == null ? void 0 : labels.expandGroupButtonAriaLabel
|
|
105
|
+
},
|
|
106
|
+
itemProps: {
|
|
107
|
+
"aria-roledescription": labels == null ? void 0 : labels.itemAriaRoleDescription
|
|
108
|
+
},
|
|
109
|
+
...obj[1]
|
|
110
|
+
}, obj[0]))
|
|
111
|
+
})]
|
|
112
|
+
})]
|
|
113
|
+
})
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
export {
|
|
117
|
+
HvFlowSidebar,
|
|
118
|
+
staticClasses as flowSidebarClasses
|
|
119
|
+
};
|
|
120
|
+
//# sourceMappingURL=Sidebar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Sidebar.js","sources":["../../../../../src/components/Flow/Sidebar/Sidebar.tsx"],"sourcesContent":["import { useMemo, useState } from \"react\";\n\nimport debounce from \"lodash/debounce\";\n\nimport { useDroppable } from \"@dnd-kit/core\";\n\nimport {\n ExtractNames,\n HvDrawer,\n HvDrawerProps,\n HvInput,\n HvInputProps,\n HvTypography,\n useLabels,\n useUniqueId,\n} from \"@hitachivantara/uikit-react-core\";\nimport { Add } from \"@hitachivantara/uikit-react-icons\";\n\nimport { staticClasses, useClasses } from \"./Sidebar.styles\";\nimport { HvFlowSidebarGroup } from \"./SidebarGroup\";\nimport { useFlowContext } from \"../FlowContext\";\nimport { buildGroups } from \"./utils\";\n\nexport { staticClasses as flowSidebarClasses };\n\nexport type HvFlowSidebarClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvFlowSidebarProps\n extends Omit<HvDrawerProps, \"classes\" | \"title\"> {\n /** Sidebar title. */\n title?: string;\n /** Sidebar description. */\n description?: string;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvFlowSidebarClasses;\n /** Labels used on the sidebar. */\n labels?: {\n itemAriaRoleDescription?: string;\n expandGroupButtonAriaLabel?: string;\n searchPlaceholder?: string;\n searchAriaLabel?: string;\n };\n}\n\nconst DEFAULT_LABELS: HvFlowSidebarProps[\"labels\"] = {\n itemAriaRoleDescription: \"Draggable\",\n expandGroupButtonAriaLabel: \"Expand group\",\n searchPlaceholder: \"Search node...\",\n searchAriaLabel: \"Search node...\",\n};\n\nexport const HvFlowSidebar = ({\n id,\n title,\n description,\n anchor = \"right\",\n buttonTitle = \"Close\",\n classes: classesProp,\n labels: labelsProps,\n ...others\n}: HvFlowSidebarProps) => {\n const { classes } = useClasses(classesProp);\n\n const { nodeGroups, nodeTypes, setExpandedNodeGroups } = useFlowContext();\n\n const unfilteredGroups = useMemo(\n () => buildGroups(nodeGroups, nodeTypes),\n [nodeGroups, nodeTypes]\n );\n\n const [groups, setGroups] = useState(unfilteredGroups);\n\n const labels = useLabels(DEFAULT_LABELS, labelsProps);\n\n const drawerElementId = useUniqueId(id, \"hvFlowSidebarDrawer\");\n const groupsElementId = useUniqueId(id, \"hvFlowSidebarGroups\");\n\n // The sidebar is droppable to distinguish between the canvas and the sidebar\n // Otherwise items dropped inside the sidebar will be added to the canvas\n const { setNodeRef } = useDroppable({\n id: drawerElementId,\n });\n\n const handleSearch: HvInputProps[\"onChange\"] = (event, value) => {\n const gps = value\n ? Object.entries(unfilteredGroups).reduce((acc, curr) => {\n // Filter nodes by search\n const filteredNodes = curr[1].nodes.filter((obj) =>\n obj.label.toLocaleLowerCase().includes(value.toLocaleLowerCase())\n );\n const nodesCount = filteredNodes.length;\n\n // Only show groups with nodes\n if (nodesCount > 0) {\n acc[curr[0]] = {\n ...curr[1],\n nodes: filteredNodes,\n };\n }\n\n return acc;\n }, {})\n : unfilteredGroups;\n\n setGroups(gps);\n setExpandedNodeGroups?.(value ? Object.keys(gps) : []);\n };\n\n const handleDebouncedSearch = debounce(handleSearch, 500);\n\n return (\n <HvDrawer\n BackdropComponent={undefined}\n variant=\"persistent\"\n classes={{\n paper: classes.drawerPaper,\n }}\n anchor={anchor}\n buttonTitle={buttonTitle}\n {...others}\n >\n <div id={drawerElementId} ref={setNodeRef}>\n <div className={classes.titleContainer}>\n <Add role=\"none\" />\n <HvTypography variant=\"title3\">{title}</HvTypography>\n </div>\n <div className={classes.contentContainer}>\n <HvTypography className={classes.description}>\n {description}\n </HvTypography>\n <HvInput\n className={classes.searchRoot}\n type=\"search\"\n placeholder={labels?.searchPlaceholder}\n aria-label={labels?.searchAriaLabel}\n aria-controls={groupsElementId}\n aria-owns={groupsElementId}\n onChange={handleDebouncedSearch}\n inputProps={{ autoComplete: \"off\" }}\n />\n <ul id={groupsElementId} className={classes.groupsContainer}>\n {Object.entries(groups).map((obj) => (\n <HvFlowSidebarGroup\n key={obj[0]}\n id={obj[0]}\n expandButtonProps={{\n \"aria-label\": labels?.expandGroupButtonAriaLabel,\n }}\n itemProps={{\n \"aria-roledescription\": labels?.itemAriaRoleDescription,\n }}\n {...obj[1]}\n />\n ))}\n </ul>\n </div>\n </div>\n </HvDrawer>\n );\n};\n"],"names":["DEFAULT_LABELS","itemAriaRoleDescription","expandGroupButtonAriaLabel","searchPlaceholder","searchAriaLabel","HvFlowSidebar","id","title","description","anchor","buttonTitle","classes","classesProp","labels","labelsProps","others","useClasses","nodeGroups","nodeTypes","setExpandedNodeGroups","useFlowContext","unfilteredGroups","useMemo","buildGroups","groups","setGroups","useState","useLabels","drawerElementId","useUniqueId","groupsElementId","setNodeRef","useDroppable","handleSearch","event","value","gps","Object","entries","reduce","acc","curr","filteredNodes","nodes","filter","obj","label","toLocaleLowerCase","includes","nodesCount","length","keys","handleDebouncedSearch","debounce","HvDrawer","BackdropComponent","undefined","variant","paper","drawerPaper","children","ref","_jsxs","className","titleContainer","_jsx","Add","role","HvTypography","contentContainer","HvInput","searchRoot","type","placeholder","onChange","inputProps","autoComplete","groupsContainer","map","HvFlowSidebarGroup","expandButtonProps","itemProps"],"mappings":"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"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createClasses, theme } from "@hitachivantara/uikit-react-core";
|
|
2
|
+
const {
|
|
3
|
+
staticClasses,
|
|
4
|
+
useClasses
|
|
5
|
+
} = createClasses("HvFlowSidebar", {
|
|
6
|
+
drawerPaper: {
|
|
7
|
+
width: "360px"
|
|
8
|
+
},
|
|
9
|
+
titleContainer: {
|
|
10
|
+
display: "flex",
|
|
11
|
+
padding: theme.spacing("sm", "lg", "xs", "sm")
|
|
12
|
+
},
|
|
13
|
+
contentContainer: {
|
|
14
|
+
padding: theme.spacing(0, "lg", "sm", "lg")
|
|
15
|
+
},
|
|
16
|
+
description: {
|
|
17
|
+
color: theme.colors.secondary_60
|
|
18
|
+
},
|
|
19
|
+
searchRoot: {
|
|
20
|
+
paddingTop: theme.space.sm,
|
|
21
|
+
paddingBottom: theme.space.sm
|
|
22
|
+
},
|
|
23
|
+
groupsContainer: {
|
|
24
|
+
display: "flex",
|
|
25
|
+
flexDirection: "column",
|
|
26
|
+
gap: theme.space.sm,
|
|
27
|
+
listStyleType: "none"
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
export {
|
|
31
|
+
staticClasses,
|
|
32
|
+
useClasses
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=Sidebar.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Sidebar.styles.js","sources":["../../../../../src/components/Flow/Sidebar/Sidebar.styles.tsx"],"sourcesContent":["import { createClasses, theme } from \"@hitachivantara/uikit-react-core\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvFlowSidebar\", {\n drawerPaper: { width: \"360px\" },\n titleContainer: {\n display: \"flex\",\n padding: theme.spacing(\"sm\", \"lg\", \"xs\", \"sm\"),\n },\n contentContainer: { padding: theme.spacing(0, \"lg\", \"sm\", \"lg\") },\n description: { color: theme.colors.secondary_60 },\n searchRoot: {\n paddingTop: theme.space.sm,\n paddingBottom: theme.space.sm,\n },\n groupsContainer: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: theme.space.sm,\n listStyleType: \"none\",\n },\n});\n"],"names":["staticClasses","useClasses","createClasses","drawerPaper","width","titleContainer","display","padding","theme","spacing","contentContainer","description","color","colors","secondary_60","searchRoot","paddingTop","space","sm","paddingBottom","groupsContainer","flexDirection","gap","listStyleType"],"mappings":";AAEa,MAAA;AAAA,EAAEA;AAAAA,EAAeC;AAAW,IAAIC,cAAc,iBAAiB;AAAA,EAC1EC,aAAa;AAAA,IAAEC,OAAO;AAAA,EAAQ;AAAA,EAC9BC,gBAAgB;AAAA,IACdC,SAAS;AAAA,IACTC,SAASC,MAAMC,QAAQ,MAAM,MAAM,MAAM,IAAI;AAAA,EAC/C;AAAA,EACAC,kBAAkB;AAAA,IAAEH,SAASC,MAAMC,QAAQ,GAAG,MAAM,MAAM,IAAI;AAAA,EAAE;AAAA,EAChEE,aAAa;AAAA,IAAEC,OAAOJ,MAAMK,OAAOC;AAAAA,EAAa;AAAA,EAChDC,YAAY;AAAA,IACVC,YAAYR,MAAMS,MAAMC;AAAAA,IACxBC,eAAeX,MAAMS,MAAMC;AAAAA,EAC7B;AAAA,EACAE,iBAAiB;AAAA,IACfd,SAAS;AAAA,IACTe,eAAe;AAAA,IACfC,KAAKd,MAAMS,MAAMC;AAAAA,IACjBK,eAAe;AAAA,EACjB;AACF,CAAC;"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { useMemo, useCallback } from "react";
|
|
2
|
+
import { Up, Down } from "@hitachivantara/uikit-react-icons";
|
|
3
|
+
import { HvTypography, HvButton } from "@hitachivantara/uikit-react-core";
|
|
4
|
+
import { getColor } from "@hitachivantara/uikit-styles";
|
|
5
|
+
import { useClasses } from "./SidebarGroup.styles.js";
|
|
6
|
+
import { staticClasses } from "./SidebarGroup.styles.js";
|
|
7
|
+
import { jsxs, jsx } from "@emotion/react/jsx-runtime";
|
|
8
|
+
import { useFlowContext } from "../../FlowContext/FlowContext.js";
|
|
9
|
+
import { HvFlowDraggableSidebarGroupItem } from "./SidebarGroupItem/DraggableSidebarGroupItem.js";
|
|
10
|
+
const HvFlowSidebarGroup = ({
|
|
11
|
+
id,
|
|
12
|
+
label,
|
|
13
|
+
nodes,
|
|
14
|
+
color,
|
|
15
|
+
description,
|
|
16
|
+
icon,
|
|
17
|
+
expandButtonProps,
|
|
18
|
+
classes: classesProp,
|
|
19
|
+
itemProps
|
|
20
|
+
}) => {
|
|
21
|
+
const {
|
|
22
|
+
classes,
|
|
23
|
+
cx,
|
|
24
|
+
css
|
|
25
|
+
} = useClasses(classesProp);
|
|
26
|
+
const {
|
|
27
|
+
expandedNodeGroups,
|
|
28
|
+
setExpandedNodeGroups
|
|
29
|
+
} = useFlowContext();
|
|
30
|
+
const opened = useMemo(() => !!(expandedNodeGroups == null ? void 0 : expandedNodeGroups.find((groupId) => groupId === id)), [expandedNodeGroups, id]);
|
|
31
|
+
const handleClick = useCallback(() => {
|
|
32
|
+
setExpandedNodeGroups == null ? void 0 : setExpandedNodeGroups((prev) => opened ? prev.filter((groupId) => id !== groupId) : [...prev, id]);
|
|
33
|
+
}, [id, opened, setExpandedNodeGroups]);
|
|
34
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
35
|
+
className: cx(css({
|
|
36
|
+
borderColor: getColor(color)
|
|
37
|
+
}), classes.root),
|
|
38
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
39
|
+
className: classes.titleContainer,
|
|
40
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
41
|
+
className: classes.labelContainer,
|
|
42
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
43
|
+
className: classes.icon,
|
|
44
|
+
role: "none",
|
|
45
|
+
children: icon
|
|
46
|
+
}), /* @__PURE__ */ jsx(HvTypography, {
|
|
47
|
+
variant: "title4",
|
|
48
|
+
children: nodes.length > 1 ? `${label} (${nodes.length})` : label
|
|
49
|
+
})]
|
|
50
|
+
}), /* @__PURE__ */ jsx(HvButton, {
|
|
51
|
+
icon: true,
|
|
52
|
+
onClick: handleClick,
|
|
53
|
+
"aria-expanded": opened,
|
|
54
|
+
...expandButtonProps,
|
|
55
|
+
children: opened ? /* @__PURE__ */ jsx(Up, {
|
|
56
|
+
role: "none"
|
|
57
|
+
}) : /* @__PURE__ */ jsx(Down, {
|
|
58
|
+
role: "none"
|
|
59
|
+
})
|
|
60
|
+
})]
|
|
61
|
+
}), description && /* @__PURE__ */ jsx("div", {
|
|
62
|
+
className: classes.descriptionContainer,
|
|
63
|
+
children: /* @__PURE__ */ jsx(HvTypography, {
|
|
64
|
+
children: description
|
|
65
|
+
})
|
|
66
|
+
}), opened && /* @__PURE__ */ jsx("div", {
|
|
67
|
+
className: classes.itemsContainer,
|
|
68
|
+
children: nodes.map((obj) => /* @__PURE__ */ jsx(HvFlowDraggableSidebarGroupItem, {
|
|
69
|
+
...itemProps,
|
|
70
|
+
...obj
|
|
71
|
+
}, obj.id))
|
|
72
|
+
})]
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
export {
|
|
76
|
+
HvFlowSidebarGroup,
|
|
77
|
+
staticClasses as flowSidebarGroupClasses
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=SidebarGroup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SidebarGroup.js","sources":["../../../../../../src/components/Flow/Sidebar/SidebarGroup/SidebarGroup.tsx"],"sourcesContent":["import { useCallback, useMemo } from \"react\";\n\nimport { Down, Up } from \"@hitachivantara/uikit-react-icons\";\nimport {\n ExtractNames,\n HvButton,\n HvButtonProps,\n HvTypography,\n} from \"@hitachivantara/uikit-react-core\";\nimport { getColor } from \"@hitachivantara/uikit-styles\";\n\nimport { HvFlowNodeGroup } from \"../../types\";\nimport { staticClasses, useClasses } from \"./SidebarGroup.styles\";\nimport {\n HvFlowDraggableSidebarGroupItem,\n HvFlowDraggableSidebarGroupItemProps,\n} from \"./SidebarGroupItem\";\nimport { useFlowContext } from \"../../FlowContext\";\n\nexport { staticClasses as flowSidebarGroupClasses };\n\nexport type HvFlowSidebarGroupClasses = ExtractNames<typeof useClasses>;\n\nexport type HvFlowSidebarGroupNodes = {\n id: string;\n label: string;\n}[];\n\nexport interface HvFlowSidebarGroupProps extends HvFlowNodeGroup {\n /** Group id. */\n id: string;\n /** Group nodes. */\n nodes: HvFlowSidebarGroupNodes;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvFlowSidebarGroupClasses;\n /** Expand button props. */\n expandButtonProps?: HvButtonProps;\n /** Item group props. */\n itemProps?: Partial<HvFlowDraggableSidebarGroupItemProps>;\n}\n\nexport const HvFlowSidebarGroup = ({\n id,\n label,\n nodes,\n color,\n description,\n icon,\n expandButtonProps,\n classes: classesProp,\n itemProps,\n}: HvFlowSidebarGroupProps) => {\n const { classes, cx, css } = useClasses(classesProp);\n\n const { expandedNodeGroups, setExpandedNodeGroups } = useFlowContext();\n\n const opened = useMemo(\n () => !!expandedNodeGroups?.find((groupId) => groupId === id),\n [expandedNodeGroups, id]\n );\n\n const handleClick = useCallback(() => {\n setExpandedNodeGroups?.((prev) =>\n opened ? prev.filter((groupId) => id !== groupId) : [...prev, id]\n );\n }, [id, opened, setExpandedNodeGroups]);\n\n return (\n <li className={cx(css({ borderColor: getColor(color) }), classes.root)}>\n <div className={classes.titleContainer}>\n <div className={classes.labelContainer}>\n <div className={classes.icon} role=\"none\">\n {icon}\n </div>\n <HvTypography variant=\"title4\">\n {nodes.length > 1 ? `${label} (${nodes.length})` : label}\n </HvTypography>\n </div>\n <HvButton\n icon\n onClick={handleClick}\n aria-expanded={opened}\n {...expandButtonProps}\n >\n {opened ? <Up role=\"none\" /> : <Down role=\"none\" />}\n </HvButton>\n </div>\n {description && (\n <div className={classes.descriptionContainer}>\n <HvTypography>{description}</HvTypography>\n </div>\n )}\n {opened && (\n <div className={classes.itemsContainer}>\n {nodes.map((obj) => (\n <HvFlowDraggableSidebarGroupItem\n key={obj.id}\n {...itemProps}\n {...obj}\n />\n ))}\n </div>\n )}\n </li>\n );\n};\n"],"names":["HvFlowSidebarGroup","id","label","nodes","color","description","icon","expandButtonProps","classes","classesProp","itemProps","cx","css","useClasses","expandedNodeGroups","setExpandedNodeGroups","useFlowContext","opened","useMemo","find","groupId","handleClick","useCallback","prev","filter","className","borderColor","getColor","root","children","_jsxs","titleContainer","labelContainer","_jsx","role","HvTypography","variant","length","HvButton","onClick","Up","Down","descriptionContainer","itemsContainer","map","obj","HvFlowDraggableSidebarGroupItem"],"mappings":";;;;;;;;;AAyCO,MAAMA,qBAAqBA,CAAC;AAAA,EACjCC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC,SAASC;AAAAA,EACTC;AACuB,MAAM;AACvB,QAAA;AAAA,IAAEF;AAAAA,IAASG;AAAAA,IAAIC;AAAAA,EAAAA,IAAQC,WAAWJ,WAAW;AAE7C,QAAA;AAAA,IAAEK;AAAAA,IAAoBC;AAAAA,MAA0BC,eAAe;AAErE,QAAMC,SAASC,QACb,MAAM,CAAC,EAACJ,yDAAoBK,KAAMC,CAAYA,YAAAA,YAAYnB,MAC1D,CAACa,oBAAoBb,EAAE,CACzB;AAEMoB,QAAAA,cAAcC,YAAY,MAAM;AACpCP,mEAAyBQ,CACvBN,SAAAA,SAASM,KAAKC,OAAQJ,CAAYnB,YAAAA,OAAOmB,OAAO,IAAI,CAAC,GAAGG,MAAMtB,EAAE;AAAA,EAEjE,GAAA,CAACA,IAAIgB,QAAQF,qBAAqB,CAAC;AAEtC,8BACE,MAAA;AAAA,IAAIU,WAAWd,GAAGC,IAAI;AAAA,MAAEc,aAAaC,SAASvB,KAAK;AAAA,IAAA,CAAG,GAAGI,QAAQoB,IAAI;AAAA,IAAEC,WACrEC,qBAAA,OAAA;AAAA,MAAKL,WAAWjB,QAAQuB;AAAAA,MAAeF,WACrCC,qBAAA,OAAA;AAAA,QAAKL,WAAWjB,QAAQwB;AAAAA,QAAeH,WACrCI,oBAAA,OAAA;AAAA,UAAKR,WAAWjB,QAAQF;AAAAA,UAAM4B,MAAK;AAAA,UAAML,UACtCvB;AAAAA,QAAAA,CACE,GACL2B,oBAACE,cAAY;AAAA,UAACC,SAAQ;AAAA,UAAQP,UAC3B1B,MAAMkC,SAAS,IAAK,GAAEnC,KAAM,KAAIC,MAAMkC,MAAO,MAAKnC;AAAAA,QAAAA,CACvC,CAAC;AAAA,MAAA,CACZ,GACL+B,oBAACK,UAAQ;AAAA,QACPhC,MAAI;AAAA,QACJiC,SAASlB;AAAAA,QACT,iBAAeJ;AAAAA,QAAO,GAClBV;AAAAA,QAAiBsB,UAEpBZ,SAASgB,oBAACO,IAAE;AAAA,UAACN,MAAK;AAAA,QAAA,CAAQ,IAAID,oBAACQ,MAAI;AAAA,UAACP,MAAK;AAAA,QAAA,CAAQ;AAAA,MAAA,CAC1C,CAAC;AAAA,IAAA,CACR,GACJ7B,eACC4B,oBAAA,OAAA;AAAA,MAAKR,WAAWjB,QAAQkC;AAAAA,MAAqBb,8BAC1CM,cAAY;AAAA,QAAAN,UAAExB;AAAAA,MAAAA,CAA0B;AAAA,IAAA,CACtC,GAENY,UACCgB,oBAAA,OAAA;AAAA,MAAKR,WAAWjB,QAAQmC;AAAAA,MAAed,UACpC1B,MAAMyC,IAAKC,CAAAA,4BACTC,iCAA+B;AAAA,QAAA,GAE1BpC;AAAAA,QAAS,GACTmC;AAAAA,MAAAA,GAFCA,IAAI5C,EAGV,CACF;AAAA,IAAA,CACE,CACN;AAAA,EAAA,CACC;AAER;"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createClasses, theme } from "@hitachivantara/uikit-react-core";
|
|
2
|
+
const {
|
|
3
|
+
staticClasses,
|
|
4
|
+
useClasses
|
|
5
|
+
} = createClasses("HvFlowSidebarGroup", {
|
|
6
|
+
root: {
|
|
7
|
+
padding: theme.space.sm,
|
|
8
|
+
borderRadius: theme.radii.round,
|
|
9
|
+
borderWidth: "1px",
|
|
10
|
+
borderTopWidth: "3px"
|
|
11
|
+
},
|
|
12
|
+
titleContainer: {
|
|
13
|
+
display: "flex",
|
|
14
|
+
justifyContent: "space-between"
|
|
15
|
+
},
|
|
16
|
+
labelContainer: {
|
|
17
|
+
display: "flex",
|
|
18
|
+
alignItems: "center"
|
|
19
|
+
},
|
|
20
|
+
icon: {
|
|
21
|
+
paddingRight: theme.space.xs
|
|
22
|
+
},
|
|
23
|
+
descriptionContainer: {
|
|
24
|
+
padding: `${theme.space.xs} 0 ${theme.space.sm} calc(32px + ${theme.space.xs})`
|
|
25
|
+
},
|
|
26
|
+
itemsContainer: {
|
|
27
|
+
display: "flex",
|
|
28
|
+
flexDirection: "column",
|
|
29
|
+
gap: theme.space.xs,
|
|
30
|
+
paddingLeft: theme.space.sm
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
export {
|
|
34
|
+
staticClasses,
|
|
35
|
+
useClasses
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=SidebarGroup.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SidebarGroup.styles.js","sources":["../../../../../../src/components/Flow/Sidebar/SidebarGroup/SidebarGroup.styles.tsx"],"sourcesContent":["import { createClasses, theme } from \"@hitachivantara/uikit-react-core\";\n\nexport const { staticClasses, useClasses } = createClasses(\n \"HvFlowSidebarGroup\",\n {\n root: {\n padding: theme.space.sm,\n borderRadius: theme.radii.round,\n borderWidth: \"1px\",\n borderTopWidth: \"3px\",\n },\n titleContainer: {\n display: \"flex\",\n justifyContent: \"space-between\",\n },\n labelContainer: {\n display: \"flex\",\n alignItems: \"center\",\n },\n icon: { paddingRight: theme.space.xs },\n descriptionContainer: {\n padding: `${theme.space.xs} 0 ${theme.space.sm} calc(32px + ${theme.space.xs})`,\n },\n itemsContainer: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: theme.space.xs,\n paddingLeft: theme.space.sm,\n },\n }\n);\n"],"names":["staticClasses","useClasses","createClasses","root","padding","theme","space","sm","borderRadius","radii","round","borderWidth","borderTopWidth","titleContainer","display","justifyContent","labelContainer","alignItems","icon","paddingRight","xs","descriptionContainer","itemsContainer","flexDirection","gap","paddingLeft"],"mappings":";AAEa,MAAA;AAAA,EAAEA;AAAAA,EAAeC;AAAW,IAAIC,cAC3C,sBACA;AAAA,EACEC,MAAM;AAAA,IACJC,SAASC,MAAMC,MAAMC;AAAAA,IACrBC,cAAcH,MAAMI,MAAMC;AAAAA,IAC1BC,aAAa;AAAA,IACbC,gBAAgB;AAAA,EAClB;AAAA,EACAC,gBAAgB;AAAA,IACdC,SAAS;AAAA,IACTC,gBAAgB;AAAA,EAClB;AAAA,EACAC,gBAAgB;AAAA,IACdF,SAAS;AAAA,IACTG,YAAY;AAAA,EACd;AAAA,EACAC,MAAM;AAAA,IAAEC,cAAcd,MAAMC,MAAMc;AAAAA,EAAG;AAAA,EACrCC,sBAAsB;AAAA,IACpBjB,SAAU,GAAEC,MAAMC,MAAMc,EAAG,MAAKf,MAAMC,MAAMC,EAAG,gBAAeF,MAAMC,MAAMc,EAAG;AAAA,EAC/E;AAAA,EACAE,gBAAgB;AAAA,IACdR,SAAS;AAAA,IACTS,eAAe;AAAA,IACfC,KAAKnB,MAAMC,MAAMc;AAAAA,IACjBK,aAAapB,MAAMC,MAAMC;AAAAA,EAC3B;AACF,CACF;"}
|
package/dist/esm/components/Flow/Sidebar/SidebarGroup/SidebarGroupItem/DraggableSidebarGroupItem.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { useForkRef } from "@mui/material";
|
|
2
|
+
import { useRef } from "react";
|
|
3
|
+
import { useDraggable } from "@dnd-kit/core";
|
|
4
|
+
import { HvFlowSidebarGroupItem } from "./SidebarGroupItem.js";
|
|
5
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
6
|
+
const HvFlowDraggableSidebarGroupItem = ({
|
|
7
|
+
label,
|
|
8
|
+
id,
|
|
9
|
+
...others
|
|
10
|
+
}) => {
|
|
11
|
+
var _a, _b;
|
|
12
|
+
const itemRef = useRef(null);
|
|
13
|
+
const {
|
|
14
|
+
attributes,
|
|
15
|
+
listeners,
|
|
16
|
+
setNodeRef,
|
|
17
|
+
isDragging,
|
|
18
|
+
transform
|
|
19
|
+
} = useDraggable({
|
|
20
|
+
id,
|
|
21
|
+
data: {
|
|
22
|
+
hvFlow: {
|
|
23
|
+
// Needed for the drag overlay: otherwise the item is cut by the drawer because of overflow
|
|
24
|
+
label,
|
|
25
|
+
// Item position: used to position the item when dropped
|
|
26
|
+
x: (_a = itemRef.current) == null ? void 0 : _a.getBoundingClientRect().x,
|
|
27
|
+
y: (_b = itemRef.current) == null ? void 0 : _b.getBoundingClientRect().y
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const forkedRef = useForkRef(itemRef, setNodeRef);
|
|
32
|
+
const style = transform ? {
|
|
33
|
+
transform: `translate3d(${transform.x}px, ${transform.y}px, 0)`
|
|
34
|
+
} : void 0;
|
|
35
|
+
return /* @__PURE__ */ jsx(HvFlowSidebarGroupItem, {
|
|
36
|
+
ref: forkedRef,
|
|
37
|
+
style,
|
|
38
|
+
label,
|
|
39
|
+
isDragging,
|
|
40
|
+
...listeners,
|
|
41
|
+
...attributes,
|
|
42
|
+
...others
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
export {
|
|
46
|
+
HvFlowDraggableSidebarGroupItem
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=DraggableSidebarGroupItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DraggableSidebarGroupItem.js","sources":["../../../../../../../src/components/Flow/Sidebar/SidebarGroup/SidebarGroupItem/DraggableSidebarGroupItem.tsx"],"sourcesContent":["import { useForkRef } from \"@mui/material\";\n\nimport { useRef } from \"react\";\n\nimport { useDraggable } from \"@dnd-kit/core\";\n\nimport {\n HvFlowSidebarGroupItem,\n HvFlowSidebarGroupItemProps,\n} from \"./SidebarGroupItem\";\n\nexport interface HvFlowDraggableSidebarGroupItemProps\n extends HvFlowSidebarGroupItemProps {\n /** Item id: the item type. */\n id: string;\n}\n\nexport const HvFlowDraggableSidebarGroupItem = ({\n label,\n id,\n ...others\n}: HvFlowDraggableSidebarGroupItemProps) => {\n const itemRef = useRef<HTMLElement>(null);\n\n const { attributes, listeners, setNodeRef, isDragging, transform } =\n useDraggable({\n id,\n data: {\n hvFlow: {\n // Needed for the drag overlay: otherwise the item is cut by the drawer because of overflow\n label,\n // Item position: used to position the item when dropped\n x: itemRef.current?.getBoundingClientRect().x,\n y: itemRef.current?.getBoundingClientRect().y,\n },\n },\n });\n\n const forkedRef = useForkRef(itemRef, setNodeRef);\n\n const style = transform\n ? {\n transform: `translate3d(${transform.x}px, ${transform.y}px, 0)`,\n }\n : undefined;\n\n return (\n <HvFlowSidebarGroupItem\n ref={forkedRef}\n style={style}\n label={label}\n isDragging={isDragging}\n {...listeners}\n {...attributes}\n {...others}\n />\n );\n};\n"],"names":["HvFlowDraggableSidebarGroupItem","label","id","others","itemRef","useRef","attributes","listeners","setNodeRef","isDragging","transform","useDraggable","data","hvFlow","x","current","getBoundingClientRect","y","forkedRef","useForkRef","style","undefined","HvFlowSidebarGroupItem","ref"],"mappings":";;;;;AAiBO,MAAMA,kCAAkCA,CAAC;AAAA,EAC9CC;AAAAA,EACAC;AAAAA,EACA,GAAGC;AACiC,MAAM;;AACpCC,QAAAA,UAAUC,OAAoB,IAAI;AAElC,QAAA;AAAA,IAAEC;AAAAA,IAAYC;AAAAA,IAAWC;AAAAA,IAAYC;AAAAA,IAAYC;AAAAA,MACrDC,aAAa;AAAA,IACXT;AAAAA,IACAU,MAAM;AAAA,MACJC,QAAQ;AAAA;AAAA,QAENZ;AAAAA;AAAAA,QAEAa,IAAGV,aAAQW,YAARX,mBAAiBY,wBAAwBF;AAAAA,QAC5CG,IAAGb,aAAQW,YAARX,mBAAiBY,wBAAwBC;AAAAA,MAC9C;AAAA,IACF;AAAA,EAAA,CACD;AAEGC,QAAAA,YAAYC,WAAWf,SAASI,UAAU;AAEhD,QAAMY,QAAQV,YACV;AAAA,IACEA,WAAY,eAAcA,UAAUI,CAAE,OAAMJ,UAAUO,CAAE;AAAA,EAE1DI,IAAAA;AAEJ,6BACGC,wBAAsB;AAAA,IACrBC,KAAKL;AAAAA,IACLE;AAAAA,IACAnB;AAAAA,IACAQ;AAAAA,IAAuB,GACnBF;AAAAA,IAAS,GACTD;AAAAA,IAAU,GACVH;AAAAA,EAAAA,CACL;AAEL;"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import { HvTypography } from "@hitachivantara/uikit-react-core";
|
|
3
|
+
import { Drag } from "@hitachivantara/uikit-react-icons";
|
|
4
|
+
import { useClasses } from "./SidebarGroupItem.styles.js";
|
|
5
|
+
import { staticClasses } from "./SidebarGroupItem.styles.js";
|
|
6
|
+
import { jsxs, jsx } from "@emotion/react/jsx-runtime";
|
|
7
|
+
const HvFlowSidebarGroupItem = forwardRef(({
|
|
8
|
+
label,
|
|
9
|
+
isDragging,
|
|
10
|
+
classes: classesProp,
|
|
11
|
+
className,
|
|
12
|
+
...others
|
|
13
|
+
}, ref) => {
|
|
14
|
+
const {
|
|
15
|
+
classes,
|
|
16
|
+
cx
|
|
17
|
+
} = useClasses(classesProp);
|
|
18
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
19
|
+
ref,
|
|
20
|
+
className: cx(classes.root, {
|
|
21
|
+
[classes.dragging]: isDragging
|
|
22
|
+
}, className),
|
|
23
|
+
...others,
|
|
24
|
+
children: [/* @__PURE__ */ jsx(HvTypography, {
|
|
25
|
+
children: label
|
|
26
|
+
}), /* @__PURE__ */ jsx(Drag, {
|
|
27
|
+
role: "none"
|
|
28
|
+
})]
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
export {
|
|
32
|
+
HvFlowSidebarGroupItem,
|
|
33
|
+
staticClasses as flowSidebarGroupItemClasses
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=SidebarGroupItem.js.map
|
package/dist/esm/components/Flow/Sidebar/SidebarGroup/SidebarGroupItem/SidebarGroupItem.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SidebarGroupItem.js","sources":["../../../../../../../src/components/Flow/Sidebar/SidebarGroup/SidebarGroupItem/SidebarGroupItem.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\n\nimport {\n ExtractNames,\n HvBaseProps,\n HvTypography,\n} from \"@hitachivantara/uikit-react-core\";\nimport { Drag } from \"@hitachivantara/uikit-react-icons\";\n\nimport { staticClasses, useClasses } from \"./SidebarGroupItem.styles\";\n\nexport { staticClasses as flowSidebarGroupItemClasses };\n\nexport type HvFlowSidebarGroupItemClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvFlowSidebarGroupItemProps extends HvBaseProps {\n /** Item label. */\n label: string;\n /** Whether the item is being dragged. */\n isDragging?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvFlowSidebarGroupItemClasses;\n}\n\nexport const HvFlowSidebarGroupItem = forwardRef<\n HTMLDivElement,\n HvFlowSidebarGroupItemProps\n>(\n (\n {\n label,\n isDragging,\n classes: classesProp,\n className,\n ...others\n }: HvFlowSidebarGroupItemProps,\n ref\n ) => {\n const { classes, cx } = useClasses(classesProp);\n\n return (\n <div\n ref={ref}\n className={cx(\n classes.root,\n { [classes.dragging]: isDragging },\n className\n )}\n {...others}\n >\n <HvTypography>{label}</HvTypography>\n <Drag role=\"none\" />\n </div>\n );\n }\n);\n"],"names":["HvFlowSidebarGroupItem","forwardRef","label","isDragging","classes","classesProp","className","others","ref","cx","useClasses","root","dragging","children","_jsx","HvTypography","Drag","role"],"mappings":";;;;;;AAwBaA,MAAAA,yBAAyBC,WAIpC,CACE;AAAA,EACEC;AAAAA,EACAC;AAAAA,EACAC,SAASC;AAAAA,EACTC;AAAAA,EACA,GAAGC;AACwB,GAC7BC,QACG;AACG,QAAA;AAAA,IAAEJ;AAAAA,IAASK;AAAAA,EAAAA,IAAOC,WAAWL,WAAW;AAE9C,8BACE,OAAA;AAAA,IACEG;AAAAA,IACAF,WAAWG,GACTL,QAAQO,MACR;AAAA,MAAE,CAACP,QAAQQ,QAAQ,GAAGT;AAAAA,OACtBG,SACF;AAAA,IAAE,GACEC;AAAAA,IAAMM,UAAA,CAEVC,oBAACC,cAAY;AAAA,MAAAF,UAAEX;AAAAA,IAAAA,CAAoB,GACnCY,oBAACE,MAAI;AAAA,MAACC,MAAK;AAAA,IAAA,CAAQ,CAAC;AAAA,EAAA,CACjB;AAET,CACF;"}
|
package/dist/esm/components/Flow/Sidebar/SidebarGroup/SidebarGroupItem/SidebarGroupItem.styles.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createClasses, theme, outlineStyles } from "@hitachivantara/uikit-react-core";
|
|
2
|
+
const {
|
|
3
|
+
staticClasses,
|
|
4
|
+
useClasses
|
|
5
|
+
} = createClasses("HvFlowSidebarGroupItem", {
|
|
6
|
+
root: {
|
|
7
|
+
display: "flex",
|
|
8
|
+
alignItems: "center",
|
|
9
|
+
justifyContent: "space-between",
|
|
10
|
+
border: `1px solid ${theme.colors.atmo4}`,
|
|
11
|
+
padding: theme.spacing(0, 0, 0, "sm"),
|
|
12
|
+
cursor: "pointer",
|
|
13
|
+
boxShadow: `0 1px 0 ${theme.colors.shad1}`,
|
|
14
|
+
"&:focus-visible": {
|
|
15
|
+
...outlineStyles
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
dragging: {
|
|
19
|
+
borderColor: theme.colors.primary_80
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
export {
|
|
23
|
+
staticClasses,
|
|
24
|
+
useClasses
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=SidebarGroupItem.styles.js.map
|