@hitachivantara/uikit-react-lab 5.34.2 → 5.35.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Flow/DroppableFlow.cjs +7 -5
- package/dist/cjs/Flow/Flow.cjs +10 -19
- package/dist/cjs/Flow/FlowContext/FlowContext.cjs +1 -3
- package/dist/cjs/Flow/Node/Node.cjs +17 -17
- package/dist/cjs/Flow/Sidebar/Sidebar.cjs +41 -61
- package/dist/cjs/Flow/Sidebar/Sidebar.styles.cjs +0 -3
- package/dist/cjs/Flow/Sidebar/SidebarGroup/SidebarGroup.cjs +8 -8
- package/dist/cjs/Flow/Sidebar/SidebarGroup/SidebarGroupItem/DraggableSidebarGroupItem.cjs +5 -5
- package/dist/cjs/Flow/Sidebar/SidebarGroup/SidebarGroupItem/SidebarGroupItem.cjs +21 -22
- package/dist/esm/Flow/DroppableFlow.js +7 -5
- package/dist/esm/Flow/DroppableFlow.js.map +1 -1
- package/dist/esm/Flow/Flow.js +10 -19
- package/dist/esm/Flow/Flow.js.map +1 -1
- package/dist/esm/Flow/FlowContext/FlowContext.js +1 -3
- package/dist/esm/Flow/FlowContext/FlowContext.js.map +1 -1
- package/dist/esm/Flow/Node/Node.js +17 -17
- package/dist/esm/Flow/Node/Node.js.map +1 -1
- package/dist/esm/Flow/Sidebar/Sidebar.js +42 -62
- package/dist/esm/Flow/Sidebar/Sidebar.js.map +1 -1
- package/dist/esm/Flow/Sidebar/Sidebar.styles.js +0 -3
- package/dist/esm/Flow/Sidebar/Sidebar.styles.js.map +1 -1
- package/dist/esm/Flow/Sidebar/SidebarGroup/SidebarGroup.js +8 -8
- package/dist/esm/Flow/Sidebar/SidebarGroup/SidebarGroup.js.map +1 -1
- package/dist/esm/Flow/Sidebar/SidebarGroup/SidebarGroupItem/DraggableSidebarGroupItem.js +5 -5
- package/dist/esm/Flow/Sidebar/SidebarGroup/SidebarGroupItem/DraggableSidebarGroupItem.js.map +1 -1
- package/dist/esm/Flow/Sidebar/SidebarGroup/SidebarGroupItem/SidebarGroupItem.js +21 -22
- package/dist/esm/Flow/Sidebar/SidebarGroup/SidebarGroupItem/SidebarGroupItem.js.map +1 -1
- package/dist/types/index.d.ts +33 -52
- package/package.json +3 -3
- package/dist/cjs/Flow/Sidebar/utils.cjs +0 -43
- package/dist/esm/Flow/Sidebar/utils.js +0 -43
- package/dist/esm/Flow/Sidebar/utils.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Flow.js","sources":["../../../src/Flow/Flow.tsx"],"sourcesContent":["import {\n DndContext,\n DndContextProps,\n KeyboardSensor,\n PointerSensor,\n useSensor,\n useSensors,\n} from \"@dnd-kit/core\";\nimport { restrictToWindowEdges } from \"@dnd-kit/modifiers\";\nimport { ReactFlowProvider } from \"reactflow\";\n\nimport { HvDroppableFlow, HvDroppableFlowProps } from \"./DroppableFlow\";\nimport { HvFlowProvider } from \"./FlowContext\";\nimport { HvFlowNodeAction, HvFlowNodeGroups
|
|
1
|
+
{"version":3,"file":"Flow.js","sources":["../../../src/Flow/Flow.tsx"],"sourcesContent":["import {\n DndContext,\n DndContextProps,\n KeyboardSensor,\n PointerSensor,\n useSensor,\n useSensors,\n} from \"@dnd-kit/core\";\nimport { restrictToWindowEdges } from \"@dnd-kit/modifiers\";\nimport { ReactFlowProvider } from \"reactflow\";\n\nimport { HvDroppableFlow, HvDroppableFlowProps } from \"./DroppableFlow\";\nimport { HvFlowProvider } from \"./FlowContext\";\nimport { HvFlowNodeAction, HvFlowNodeGroups } from \"./types\";\n\nexport interface HvFlowProps<\n NodeGroups extends keyof any = string,\n NodeType extends string | undefined = string | undefined,\n NodeData = any,\n> extends HvDroppableFlowProps<NodeType, NodeData> {\n /** Flow nodes groups. */\n nodeGroups?: HvFlowNodeGroups<NodeGroups>;\n /** Flow sidebar. */\n sidebar?: React.ReactNode;\n /** Flow default actions. */\n defaultActions?: HvFlowNodeAction[];\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 * Take a look at the [usage page](https://lumada-design.github.io/uikit/master/?path=/docs/lab-flow-usage--docs) to learn more about this component.\n *\n * DISCLAIMER: This component is a work in progress and there might be breaking changes.\n */\nexport const HvFlow = ({\n nodeGroups,\n sidebar,\n defaultActions,\n dndContextProps,\n ...others\n}: HvFlowProps) => {\n const sensors = useSensors(\n useSensor(PointerSensor),\n useSensor(KeyboardSensor),\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} defaultActions={defaultActions}>\n <DndContext\n sensors={sensors}\n modifiers={[restrictToWindowEdges]}\n {...dndContextProps}\n >\n <HvDroppableFlow {...others} />\n {sidebar}\n </DndContext>\n </HvFlowProvider>\n </ReactFlowProvider>\n );\n};\n"],"names":[],"mappings":";;;;;;AA4CO,MAAM,SAAS,CAAC;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAmB;AACjB,QAAM,UAAU;AAAA,IACd,UAAU,aAAa;AAAA,IACvB,UAAU,cAAc;AAAA,EAAA;AAK1B,SACG,oBAAA,mBAAA,EACC,UAAC,oBAAA,gBAAA,EAAe,YAAwB,gBACtC,UAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA,WAAW,CAAC,qBAAqB;AAAA,MAChC,GAAG;AAAA,MAEJ,UAAA;AAAA,QAAC,oBAAA,iBAAA,EAAiB,GAAG,QAAQ;AAAA,QAC5B;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,EAEL,CAAA,EACF,CAAA;AAEJ;"}
|
|
@@ -4,20 +4,18 @@ import { HvFlowNodeMetaProvider } from "./NodeMetaContext.js";
|
|
|
4
4
|
const HvFlowContext = createContext({});
|
|
5
5
|
const HvFlowProvider = ({
|
|
6
6
|
nodeGroups,
|
|
7
|
-
nodeTypes,
|
|
8
7
|
defaultActions,
|
|
9
8
|
children
|
|
10
9
|
}) => {
|
|
11
10
|
const [expandedNodeGroups, setExpandedNodeGroups] = useState([]);
|
|
12
11
|
const value = useMemo(
|
|
13
12
|
() => ({
|
|
14
|
-
nodeTypes,
|
|
15
13
|
nodeGroups,
|
|
16
14
|
defaultActions,
|
|
17
15
|
expandedNodeGroups,
|
|
18
16
|
setExpandedNodeGroups
|
|
19
17
|
}),
|
|
20
|
-
[
|
|
18
|
+
[nodeGroups, defaultActions, expandedNodeGroups]
|
|
21
19
|
);
|
|
22
20
|
return /* @__PURE__ */ jsx(HvFlowNodeMetaProvider, { children: /* @__PURE__ */ jsx(HvFlowContext.Provider, { value, children }) });
|
|
23
21
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlowContext.js","sources":["../../../../src/Flow/FlowContext/FlowContext.tsx"],"sourcesContent":["import {\n createContext,\n Dispatch,\n SetStateAction,\n useMemo,\n useState,\n} from \"react\";\n\nimport { HvFlowNodeAction, HvFlowNodeGroups
|
|
1
|
+
{"version":3,"file":"FlowContext.js","sources":["../../../../src/Flow/FlowContext/FlowContext.tsx"],"sourcesContent":["import {\n createContext,\n Dispatch,\n SetStateAction,\n useMemo,\n useState,\n} from \"react\";\n\nimport { HvFlowNodeAction, HvFlowNodeGroups } from \"../types\";\nimport { HvFlowNodeMetaProvider } from \"./NodeMetaContext\";\n\nexport interface HvFlowContextValue<NodeGroups extends keyof any = string> {\n /** Flow nodes groups. */\n nodeGroups?: HvFlowNodeGroups<NodeGroups>;\n /** Flow nodes groups expanded on sidebar. */\n expandedNodeGroups?: string[];\n /** Flow default actions. */\n defaultActions?: HvFlowNodeAction[];\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 groups. */\n nodeGroups?: HvFlowContextValue<NodeGroups>[\"nodeGroups\"];\n /** Flow default actions. */\n defaultActions?: HvFlowNodeAction[];\n /** Children. */\n children?: React.ReactNode;\n}\n\nexport const HvFlowProvider = ({\n nodeGroups,\n defaultActions,\n children,\n}: HvFlowProviderProps) => {\n const [expandedNodeGroups, setExpandedNodeGroups] = useState<string[]>([]);\n\n const value = useMemo(\n () => ({\n nodeGroups,\n defaultActions,\n expandedNodeGroups,\n setExpandedNodeGroups,\n }),\n [nodeGroups, defaultActions, expandedNodeGroups],\n );\n\n return (\n <HvFlowNodeMetaProvider>\n <HvFlowContext.Provider value={value}>{children}</HvFlowContext.Provider>\n </HvFlowNodeMetaProvider>\n );\n};\n"],"names":[],"mappings":";;;AAsBa,MAAA,gBAAgB,cAAkC,EAAE;AAW1D,MAAM,iBAAiB,CAAC;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AACF,MAA2B;AACzB,QAAM,CAAC,oBAAoB,qBAAqB,IAAI,SAAmB,CAAE,CAAA;AAEzE,QAAM,QAAQ;AAAA,IACZ,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,IAEF,CAAC,YAAY,gBAAgB,kBAAkB;AAAA,EAAA;AAI/C,SAAA,oBAAC,0BACC,UAAC,oBAAA,cAAc,UAAd,EAAuB,OAAe,SAAS,CAAA,EAClD,CAAA;AAEJ;"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from "@emotion/react/jsx-runtime";
|
|
2
2
|
import { useState } from "react";
|
|
3
|
-
import { css } from "@emotion/css";
|
|
4
3
|
import { useLabels, theme, HvTooltip, HvButton, HvTypography, HvInlineEditor, HvActionsGeneric } from "@hitachivantara/uikit-react-core";
|
|
5
4
|
import { Info, Up, Down } from "@hitachivantara/uikit-react-icons";
|
|
6
5
|
import { HvFlowBaseNode } from "./BaseNode.js";
|
|
@@ -17,7 +16,6 @@ const HvFlowNode = ({
|
|
|
17
16
|
id,
|
|
18
17
|
type,
|
|
19
18
|
headerItems,
|
|
20
|
-
description,
|
|
21
19
|
actions,
|
|
22
20
|
actionCallback,
|
|
23
21
|
// TODO - remove in v6
|
|
@@ -26,34 +24,38 @@ const HvFlowNode = ({
|
|
|
26
24
|
expanded = false,
|
|
27
25
|
actionsIconOnly = true,
|
|
28
26
|
params,
|
|
29
|
-
nodeDefaults,
|
|
30
27
|
classes: classesProp,
|
|
31
28
|
labels: labelsProps,
|
|
32
29
|
children,
|
|
33
30
|
expandParamsButtonProps,
|
|
34
31
|
disableInlineEdit,
|
|
32
|
+
title: titleProp,
|
|
33
|
+
subtitle: subtitleProp,
|
|
34
|
+
description,
|
|
35
|
+
groupId,
|
|
36
|
+
color: colorProp,
|
|
37
|
+
icon: iconProp,
|
|
35
38
|
...props
|
|
36
39
|
}) => {
|
|
37
40
|
const { classes } = useClasses(classesProp);
|
|
38
|
-
const labels = useLabels(DEFAULT_LABELS, labelsProps);
|
|
39
41
|
const [showParams, setShowParams] = useState(expanded);
|
|
42
|
+
const { nodeGroups, defaultActions } = useFlowContext();
|
|
43
|
+
const labels = useLabels(DEFAULT_LABELS, labelsProps);
|
|
40
44
|
const node = useFlowNode();
|
|
41
45
|
const { setNodeData } = useFlowNodeUtils();
|
|
42
|
-
const { nodeGroups, nodeTypes, defaultActions } = useFlowContext();
|
|
43
|
-
const subtitle = node?.data.customNodeLabel || nodeTypes?.[type].meta?.label || nodeDefaults?.subTitle;
|
|
44
|
-
const groupId = nodeTypes?.[type].meta?.groupId;
|
|
45
46
|
const inlineEditorWidth = actions === void 0 || Array.isArray(actions) && actions.length === 0 || maxVisibleActions === 0 ? "100%" : `calc(200px - calc(${maxVisibleActions} * 32px + ${theme.spacing(2)}))`;
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
const icon =
|
|
49
|
-
const color =
|
|
47
|
+
const nodeGroup = groupId && nodeGroups && nodeGroups[groupId] || void 0;
|
|
48
|
+
const title = titleProp || nodeGroup?.label;
|
|
49
|
+
const icon = iconProp || nodeGroup?.icon;
|
|
50
|
+
const color = colorProp || nodeGroup?.color;
|
|
51
|
+
const subtitle = subtitleProp || node?.data.nodeLabel;
|
|
50
52
|
const hasParams = !!(params && params.length > 0);
|
|
51
53
|
return /* @__PURE__ */ jsxs(
|
|
52
54
|
HvFlowBaseNode,
|
|
53
55
|
{
|
|
54
56
|
id,
|
|
55
57
|
type,
|
|
56
|
-
title
|
|
58
|
+
title,
|
|
57
59
|
icon,
|
|
58
60
|
color,
|
|
59
61
|
nodeActions: defaultActions,
|
|
@@ -82,14 +84,12 @@ const HvFlowNode = ({
|
|
|
82
84
|
{
|
|
83
85
|
defaultValue: subtitle,
|
|
84
86
|
showIcon: true,
|
|
87
|
+
style: { width: inlineEditorWidth },
|
|
85
88
|
classes: {
|
|
86
89
|
root: classes.inlineEditRoot,
|
|
87
|
-
button: classes.inlineEditButton
|
|
88
|
-
inputRoot: css({
|
|
89
|
-
width: inlineEditorWidth
|
|
90
|
-
})
|
|
90
|
+
button: classes.inlineEditButton
|
|
91
91
|
},
|
|
92
|
-
onBlur: (evt, value) => setNodeData((prev) => ({ ...prev,
|
|
92
|
+
onBlur: (evt, value) => setNodeData((prev) => ({ ...prev, nodeLabel: value }))
|
|
93
93
|
}
|
|
94
94
|
)),
|
|
95
95
|
actions && /* @__PURE__ */ jsx(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Node.js","sources":["../../../../src/Flow/Node/Node.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"Node.js","sources":["../../../../src/Flow/Node/Node.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport {\n ExtractNames,\n HvActionsGeneric,\n HvActionsGenericProps,\n HvButton,\n HvButtonProps,\n HvInlineEditor,\n HvTooltip,\n HvTypography,\n theme,\n useLabels,\n} from \"@hitachivantara/uikit-react-core\";\nimport { Down, Info, Up } from \"@hitachivantara/uikit-react-icons\";\n\nimport { useFlowContext, useFlowNode, useFlowNodeUtils } from \"../hooks\";\nimport { HvFlowNodeParam } from \"../types\";\nimport { HvFlowBaseNode, HvFlowBaseNodeProps } from \"./BaseNode\";\nimport { staticClasses, useClasses } from \"./Node.styles\";\nimport { ParamRenderer } from \"./Parameters\";\n\nexport { staticClasses as flowNodeClasses };\n\nexport type HvFlowNodeClasses = ExtractNames<typeof useClasses>;\n\nconst DEFAULT_LABELS = {\n collapseLabel: \"Collapse\",\n expandLabel: \"Expand\",\n};\n\nexport interface HvFlowNodeProps<T = any> extends HvFlowBaseNodeProps<T> {\n /** Node description. */\n description?: string;\n /** Node actions. */\n actions?: HvActionsGenericProps[\"actions\"];\n /**\n * Node action callback.\n *\n * @deprecated Use `onAction` instead.\n * */\n actionCallback?: HvActionsGenericProps[\"actionsCallback\"]; // TODO - remove in v6\n /** Node action callback. */\n onAction?: HvActionsGenericProps[\"onAction\"];\n /** Whether the actions should be all icon buttons when visible. @default true */\n actionsIconOnly?: HvActionsGenericProps[\"iconOnly\"];\n /** Node maximum number of actions visible. */\n maxVisibleActions?: HvActionsGenericProps[\"maxVisibleActions\"];\n /** Node subtitle - this is typically the node \"name\" */\n subtitle?: string;\n /** Node group ID */\n groupId?: string;\n /** Node expanded */\n expanded?: boolean;\n /** Node parameters */\n params?: HvFlowNodeParam[];\n /** Props to be passed to the expand parameters button. */\n expandParamsButtonProps?: HvButtonProps;\n /** Labels used on the node. */\n labels?: HvFlowBaseNodeProps[\"labels\"] & Partial<typeof DEFAULT_LABELS>;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvFlowNodeClasses;\n /** Remove the ability to customize the label of the Node */\n disableInlineEdit?: boolean;\n}\n\nexport const HvFlowNode = ({\n id,\n type,\n headerItems,\n actions,\n actionCallback, // TODO - remove in v6\n onAction,\n maxVisibleActions = 1,\n expanded = false,\n actionsIconOnly = true,\n params,\n classes: classesProp,\n labels: labelsProps,\n children,\n expandParamsButtonProps,\n disableInlineEdit,\n title: titleProp,\n subtitle: subtitleProp,\n description,\n groupId,\n color: colorProp,\n icon: iconProp,\n ...props\n}: HvFlowNodeProps<unknown>) => {\n const { classes } = useClasses(classesProp);\n const [showParams, setShowParams] = useState(expanded);\n const { nodeGroups, defaultActions } = useFlowContext();\n const labels = useLabels(DEFAULT_LABELS, labelsProps);\n const node = useFlowNode();\n const { setNodeData } = useFlowNodeUtils();\n\n const inlineEditorWidth =\n actions === undefined ||\n (Array.isArray(actions) && actions.length === 0) ||\n maxVisibleActions === 0\n ? \"100%\"\n : `calc(200px - calc(${maxVisibleActions} * 32px + ${theme.spacing(2)}))`;\n\n const nodeGroup = (groupId && nodeGroups && nodeGroups[groupId]) || undefined;\n\n const title = titleProp || nodeGroup?.label;\n const icon = iconProp || nodeGroup?.icon;\n const color = colorProp || nodeGroup?.color;\n const subtitle = subtitleProp || node?.data.nodeLabel;\n\n const hasParams = !!(params && params.length > 0);\n\n return (\n <HvFlowBaseNode\n id={id}\n type={type}\n title={title}\n icon={icon}\n color={color}\n nodeActions={defaultActions}\n classes={classes}\n headerItems={\n <>\n {headerItems}\n {description && (\n <HvTooltip title={description}>\n <Info color=\"base_dark\" />\n </HvTooltip>\n )}\n {hasParams && (\n <HvButton\n icon\n overrideIconColors={false}\n onClick={() => setShowParams((p) => !p)}\n aria-label={\n showParams ? labels?.collapseLabel : labels?.expandLabel\n }\n {...expandParamsButtonProps}\n >\n {showParams ? (\n <Up color=\"base_dark\" />\n ) : (\n <Down color=\"base_dark\" />\n )}\n </HvButton>\n )}\n </>\n }\n labels={labels as HvFlowNodeProps[\"labels\"]}\n {...props}\n >\n {(subtitle || actions) && (\n <div className={classes.subtitleContainer}>\n {subtitle &&\n (disableInlineEdit ? (\n <HvTypography className={classes.subtitle}>\n {subtitle}\n </HvTypography>\n ) : (\n <HvInlineEditor\n defaultValue={subtitle}\n showIcon\n style={{ width: inlineEditorWidth }}\n classes={{\n root: classes.inlineEditRoot,\n button: classes.inlineEditButton,\n }}\n onBlur={(evt, value) =>\n setNodeData((prev) => ({ ...prev, nodeLabel: value }))\n }\n />\n ))}\n {actions && (\n <HvActionsGeneric\n className={classes.actions}\n classes={{ button: classes.actionsButton }}\n actions={actions}\n actionsCallback={actionCallback}\n onAction={onAction}\n maxVisibleActions={maxVisibleActions}\n iconOnly={actionsIconOnly}\n />\n )}\n </div>\n )}\n {children}\n {showParams && params && (\n <div className={classes.paramsContainer}>\n <ParamRenderer params={params} data={node?.data} />\n </div>\n )}\n </HvFlowBaseNode>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;AAyBA,MAAM,iBAAiB;AAAA,EACrB,eAAe;AAAA,EACf,aAAa;AACf;AAqCO,MAAM,aAAa,CAAC;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EACA;AAAA,EACA,oBAAoB;AAAA,EACpB,WAAW;AAAA,EACX,kBAAkB;AAAA,EAClB;AAAA,EACA,SAAS;AAAA,EACT,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP,MAAM;AAAA,EACN,GAAG;AACL,MAAgC;AAC9B,QAAM,EAAE,QAAA,IAAY,WAAW,WAAW;AAC1C,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,QAAQ;AACrD,QAAM,EAAE,YAAY,eAAe,IAAI,eAAe;AAChD,QAAA,SAAS,UAAU,gBAAgB,WAAW;AACpD,QAAM,OAAO;AACP,QAAA,EAAE,gBAAgB;AAExB,QAAM,oBACJ,YAAY,UACX,MAAM,QAAQ,OAAO,KAAK,QAAQ,WAAW,KAC9C,sBAAsB,IACl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d,QAAQ,QAAQ;AAAA,cAClB;AAAA,cACA,QAAQ,CAAC,KAAK,UACZ,YAAY,CAAC,UAAU,EAAE,GAAG,MAAM,WAAW,MAAQ,EAAA;AAAA,YAAA;AAAA,UAAA;AAAA,UAI5D,WACC;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAW,QAAQ;AAAA,cACnB,SAAS,EAAE,QAAQ,QAAQ,cAAc;AAAA,cACzC;AAAA,cACA,iBAAiB;AAAA,cACjB;AAAA,cACA;AAAA,cACA,UAAU;AAAA,YAAA;AAAA,UACZ;AAAA,QAAA,GAEJ;AAAA,QAED;AAAA,QACA,cAAc,UACZ,oBAAA,OAAA,EAAI,WAAW,QAAQ,iBACtB,UAAA,oBAAC,eAAc,EAAA,QAAgB,MAAM,MAAM,KAAM,CAAA,GACnD;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR;"}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { jsxs, jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useState, useMemo, useEffect } from "react";
|
|
3
3
|
import { useDroppable, useDndMonitor, DragOverlay } from "@dnd-kit/core";
|
|
4
4
|
import { restrictToWindowEdges } from "@dnd-kit/modifiers";
|
|
5
|
-
import { useDebounceCallback } from "usehooks-ts";
|
|
6
5
|
import { useLabels, useUniqueId, HvDrawer, HvTypography, HvInput } from "@hitachivantara/uikit-react-core";
|
|
7
6
|
import { Add } from "@hitachivantara/uikit-react-icons";
|
|
8
7
|
import { useClasses } from "./Sidebar.styles.js";
|
|
9
8
|
import { staticClasses } from "./Sidebar.styles.js";
|
|
10
|
-
import { buildGroups } from "./utils.js";
|
|
11
9
|
import { HvFlowSidebarGroup } from "./SidebarGroup/SidebarGroup.js";
|
|
12
10
|
import { HvFlowSidebarGroupItem } from "./SidebarGroup/SidebarGroupItem/SidebarGroupItem.js";
|
|
13
11
|
import { useFlowContext } from "../hooks/useFlowContext.js";
|
|
@@ -24,30 +22,20 @@ const HvFlowSidebar = ({
|
|
|
24
22
|
description,
|
|
25
23
|
anchor = "right",
|
|
26
24
|
buttonTitle = "Close",
|
|
25
|
+
flatten = false,
|
|
27
26
|
classes: classesProp,
|
|
28
27
|
labels: labelsProps,
|
|
29
28
|
dragOverlayProps,
|
|
30
|
-
defaultGroupProps,
|
|
31
29
|
...others
|
|
32
30
|
}) => {
|
|
33
31
|
const { classes } = useClasses(classesProp);
|
|
34
|
-
const { nodeGroups,
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
[nodeGroups, nodeTypes, defaultGroupProps]
|
|
38
|
-
);
|
|
39
|
-
const [groups, setGroups] = useState(unfilteredGroups);
|
|
40
|
-
const [ndTypes, setNdTypes] = useState(nodeTypes);
|
|
41
|
-
const [draggingLabel, setDraggingLabel] = useState(void 0);
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
setGroups(unfilteredGroups);
|
|
44
|
-
}, [unfilteredGroups]);
|
|
32
|
+
const { nodeGroups, setExpandedNodeGroups } = useFlowContext();
|
|
33
|
+
const [filterValue, setFilterValue] = useState("");
|
|
34
|
+
const [draggingLabel, setDraggingLabel] = useState();
|
|
45
35
|
const labels = useLabels(DEFAULT_LABELS, labelsProps);
|
|
46
36
|
const drawerElementId = useUniqueId(id);
|
|
47
|
-
const groupsElementId = useUniqueId(
|
|
48
|
-
const { setNodeRef } = useDroppable({
|
|
49
|
-
id: drawerElementId
|
|
50
|
-
});
|
|
37
|
+
const groupsElementId = useUniqueId();
|
|
38
|
+
const { setNodeRef } = useDroppable({ id: drawerElementId });
|
|
51
39
|
const handleDragStart = (event) => {
|
|
52
40
|
if (event.active.data.current?.hvFlow) {
|
|
53
41
|
setDraggingLabel(event.active.data.current.hvFlow?.label);
|
|
@@ -60,34 +48,29 @@ const HvFlowSidebar = ({
|
|
|
60
48
|
onDragEnd: handleDragEnd,
|
|
61
49
|
onDragStart: handleDragStart
|
|
62
50
|
});
|
|
63
|
-
const
|
|
64
|
-
if (nodeGroups)
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
51
|
+
const filteredGroups = useMemo(() => {
|
|
52
|
+
if (!filterValue || !nodeGroups)
|
|
53
|
+
return nodeGroups || {};
|
|
54
|
+
return filterValue ? Object.entries(nodeGroups).reduce(
|
|
55
|
+
(acc, [groupId, group]) => {
|
|
56
|
+
const filteredItems = (group.items || []).filter(
|
|
57
|
+
(item) => item.label.toLowerCase().includes(filterValue.toLowerCase())
|
|
68
58
|
);
|
|
69
|
-
const
|
|
70
|
-
if (
|
|
71
|
-
acc[
|
|
72
|
-
...
|
|
73
|
-
|
|
59
|
+
const itemsCount = Object.keys(filteredItems).length;
|
|
60
|
+
if (itemsCount > 0) {
|
|
61
|
+
acc[groupId] = {
|
|
62
|
+
...group,
|
|
63
|
+
items: filteredItems
|
|
74
64
|
};
|
|
75
65
|
}
|
|
76
66
|
return acc;
|
|
77
|
-
},
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
filteredNodeTypes[key] = node;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
setNdTypes(value ? filteredNodeTypes : nodeTypes);
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
const handleDebouncedSearch = useDebounceCallback(handleSearch, 500);
|
|
67
|
+
},
|
|
68
|
+
{}
|
|
69
|
+
) : nodeGroups;
|
|
70
|
+
}, [filterValue, nodeGroups]);
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
setExpandedNodeGroups?.(filterValue ? Object.keys(filteredGroups) : []);
|
|
73
|
+
}, [filterValue, filteredGroups, setExpandedNodeGroups]);
|
|
91
74
|
return /* @__PURE__ */ jsxs(
|
|
92
75
|
HvDrawer,
|
|
93
76
|
{
|
|
@@ -117,39 +100,36 @@ const HvFlowSidebar = ({
|
|
|
117
100
|
"aria-label": labels?.searchAriaLabel,
|
|
118
101
|
"aria-controls": groupsElementId,
|
|
119
102
|
"aria-owns": groupsElementId,
|
|
120
|
-
onChange:
|
|
103
|
+
onChange: (evt, val) => setFilterValue(val.trim()),
|
|
121
104
|
inputProps: { autoComplete: "off" }
|
|
122
105
|
}
|
|
123
106
|
),
|
|
124
|
-
|
|
107
|
+
/* @__PURE__ */ jsx("ul", { id: groupsElementId, className: classes.groupsContainer, children: Object.entries(filteredGroups).map(([groupId, group]) => {
|
|
108
|
+
if (flatten) {
|
|
109
|
+
return (group.items || []).map((item, i) => /* @__PURE__ */ jsx(
|
|
110
|
+
HvFlowDraggableSidebarGroupItem,
|
|
111
|
+
{
|
|
112
|
+
"aria-roledescription": labels?.itemAriaRoleDescription,
|
|
113
|
+
...item
|
|
114
|
+
},
|
|
115
|
+
`${item.nodeType}-${i}`
|
|
116
|
+
));
|
|
117
|
+
}
|
|
125
118
|
return /* @__PURE__ */ jsx(
|
|
126
119
|
HvFlowSidebarGroup,
|
|
127
120
|
{
|
|
128
|
-
id:
|
|
121
|
+
id: groupId,
|
|
129
122
|
expandButtonProps: {
|
|
130
123
|
"aria-label": labels?.expandGroupButtonAriaLabel
|
|
131
124
|
},
|
|
132
125
|
itemProps: {
|
|
133
126
|
"aria-roledescription": labels?.itemAriaRoleDescription
|
|
134
127
|
},
|
|
135
|
-
...
|
|
136
|
-
},
|
|
137
|
-
obj[0]
|
|
138
|
-
);
|
|
139
|
-
}) }) : ndTypes && Object.entries(ndTypes).map((obj) => {
|
|
140
|
-
return /* @__PURE__ */ jsx(
|
|
141
|
-
HvFlowDraggableSidebarGroupItem,
|
|
142
|
-
{
|
|
143
|
-
id: obj[0],
|
|
144
|
-
type: obj[0],
|
|
145
|
-
label: obj[1]?.meta?.label || "",
|
|
146
|
-
data: obj[1]?.meta?.data,
|
|
147
|
-
"aria-roledescription": labels?.itemAriaRoleDescription,
|
|
148
|
-
className: classes.nodeType
|
|
128
|
+
...group
|
|
149
129
|
},
|
|
150
|
-
|
|
130
|
+
groupId
|
|
151
131
|
);
|
|
152
|
-
})
|
|
132
|
+
}) })
|
|
153
133
|
] })
|
|
154
134
|
] }),
|
|
155
135
|
/* @__PURE__ */ jsx(DragOverlay, { modifiers: [restrictToWindowEdges], ...dragOverlayProps, children: draggingLabel ? /* @__PURE__ */ jsx(HvFlowSidebarGroupItem, { label: draggingLabel, isDragging: true }) : null })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sidebar.js","sources":["../../../../src/Flow/Sidebar/Sidebar.tsx"],"sourcesContent":["import { useEffect, useMemo, useState } from \"react\";\nimport {\n DndContextProps,\n DragOverlay,\n DragOverlayProps,\n useDndMonitor,\n useDroppable,\n} from \"@dnd-kit/core\";\nimport { restrictToWindowEdges } from \"@dnd-kit/modifiers\";\nimport { useDebounceCallback } from \"usehooks-ts\";\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 { useFlowContext } from \"../hooks\";\nimport { HvFlowNodeGroup } from \"../types\";\nimport { staticClasses, useClasses } from \"./Sidebar.styles\";\nimport { HvFlowSidebarGroup } from \"./SidebarGroup\";\nimport {\n HvFlowDraggableSidebarGroupItem,\n HvFlowSidebarGroupItem,\n} from \"./SidebarGroup/SidebarGroupItem\";\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?: Partial<typeof DEFAULT_LABELS>;\n /**\n * Dnd Kit drag overlay props for customization.\n *\n * More information can be found in the [Dnd Kit documentation](https://docs.dndkit.com/api-documentation/draggable/drag-overlay).\n */\n dragOverlayProps?: DragOverlayProps;\n /** Props to be applied to the default nodes group. */\n defaultGroupProps?: HvFlowNodeGroup;\n}\n\nconst DEFAULT_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 dragOverlayProps,\n defaultGroupProps,\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, defaultGroupProps),\n [nodeGroups, nodeTypes, defaultGroupProps],\n );\n\n const [groups, setGroups] = useState(unfilteredGroups);\n const [ndTypes, setNdTypes] = useState(nodeTypes);\n const [draggingLabel, setDraggingLabel] = useState(undefined);\n\n useEffect(() => {\n setGroups(unfilteredGroups);\n }, [unfilteredGroups]);\n\n const labels = useLabels(DEFAULT_LABELS, labelsProps);\n\n const drawerElementId = useUniqueId(id);\n const groupsElementId = useUniqueId(id);\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 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 useDndMonitor({\n onDragEnd: handleDragEnd,\n onDragStart: handleDragStart,\n });\n\n const handleSearch: HvInputProps[\"onChange\"] = (event, value) => {\n if (nodeGroups) {\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 } else if (nodeTypes) {\n const filteredNodeTypes = {};\n for (const [key, node] of Object.entries(nodeTypes)) {\n if (\n node.meta?.label\n .toLocaleLowerCase()\n .includes(value.toLocaleLowerCase())\n ) {\n filteredNodeTypes[key] = node;\n }\n }\n setNdTypes(value ? filteredNodeTypes : nodeTypes);\n }\n };\n\n const handleDebouncedSearch = useDebounceCallback(handleSearch, 500);\n\n return (\n <HvDrawer\n BackdropComponent={undefined}\n variant=\"persistent\"\n classes={{\n paper: classes.drawerPaper,\n }}\n showBackdrop={false}\n anchor={anchor}\n buttonTitle={buttonTitle}\n {...others}\n >\n <div id={drawerElementId} ref={setNodeRef}>\n <div className={classes.titleContainer}>\n <Add />\n <HvTypography component=\"p\" variant=\"title3\">\n {title}\n </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 {nodeGroups ? (\n <ul id={groupsElementId} className={classes.groupsContainer}>\n {Object.entries(groups).map((obj) => {\n return (\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 })}\n </ul>\n ) : (\n ndTypes &&\n Object.entries(ndTypes).map((obj) => {\n return (\n <HvFlowDraggableSidebarGroupItem\n key={obj[0]}\n id={obj[0]}\n type={obj[0]}\n label={obj[1]?.meta?.label || \"\"}\n data={obj[1]?.meta?.data}\n aria-roledescription={labels?.itemAriaRoleDescription}\n className={classes.nodeType}\n />\n );\n })\n )}\n </div>\n </div>\n <DragOverlay modifiers={[restrictToWindowEdges]} {...dragOverlayProps}>\n {draggingLabel ? (\n <HvFlowSidebarGroupItem label={draggingLabel} isDragging />\n ) : null}\n </DragOverlay>\n </HvDrawer>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAwDA,MAAM,iBAAiB;AAAA,EACrB,yBAAyB;AAAA,EACzB,4BAA4B;AAAA,EAC5B,mBAAmB;AAAA,EACnB,iBAAiB;AACnB;AAEO,MAAM,gBAAgB,CAAC;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,cAAc;AAAA,EACd,SAAS;AAAA,EACT,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAA0B;AACxB,QAAM,EAAE,QAAA,IAAY,WAAW,WAAW;AAE1C,QAAM,EAAE,YAAY,WAAW,0BAA0B,eAAe;AAExE,QAAM,mBAAmB;AAAA,IACvB,MAAM,YAAY,YAAY,WAAW,iBAAiB;AAAA,IAC1D,CAAC,YAAY,WAAW,iBAAiB;AAAA,EAAA;AAG3C,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAS,gBAAgB;AACrD,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,SAAS;AAChD,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAS,MAAS;AAE5D,YAAU,MAAM;AACd,cAAU,gBAAgB;AAAA,EAAA,GACzB,CAAC,gBAAgB,CAAC;AAEf,QAAA,SAAS,UAAU,gBAAgB,WAAW;AAE9C,QAAA,kBAAkB,YAAY,EAAE;AAChC,QAAA,kBAAkB,YAAY,EAAE;AAIhC,QAAA,EAAE,WAAW,IAAI,a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,qBAAA;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBAEC,IAAI,IAAI,CAAC;AAAA,kBACT,MAAM,IAAI,CAAC;AAAA,kBACX,OAAO,IAAI,CAAC,GAAG,MAAM,SAAS;AAAA,kBAC9B,MAAM,IAAI,CAAC,GAAG,MAAM;AAAA,kBACpB,wBAAsB,QAAQ;AAAA,kBAC9B,WAAW,QAAQ;AAAA,gBAAA;AAAA,gBANd,IAAI,CAAC;AAAA,cAAA;AAAA,YAOZ,CAEH;AAAA,UAAA,GAEL;AAAA,QAAA,GACF;AAAA,4BACC,aAAY,EAAA,WAAW,CAAC,qBAAqB,GAAI,GAAG,kBAClD,UACC,gBAAA,oBAAC,0BAAuB,OAAO,eAAe,YAAU,KAAC,CAAA,IACvD,MACN;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
1
|
+
{"version":3,"file":"Sidebar.js","sources":["../../../../src/Flow/Sidebar/Sidebar.tsx"],"sourcesContent":["import { useEffect, useMemo, useState } from \"react\";\nimport {\n DndContextProps,\n DragOverlay,\n DragOverlayProps,\n useDndMonitor,\n useDroppable,\n} from \"@dnd-kit/core\";\nimport { restrictToWindowEdges } from \"@dnd-kit/modifiers\";\nimport {\n ExtractNames,\n HvDrawer,\n HvDrawerProps,\n HvInput,\n HvTypography,\n useLabels,\n useUniqueId,\n} from \"@hitachivantara/uikit-react-core\";\nimport { Add } from \"@hitachivantara/uikit-react-icons\";\n\nimport { useFlowContext } from \"../hooks\";\nimport { HvFlowNodeGroups } from \"../types\";\nimport { staticClasses, useClasses } from \"./Sidebar.styles\";\nimport { HvFlowSidebarGroup } from \"./SidebarGroup\";\nimport {\n HvFlowDraggableSidebarGroupItem,\n HvFlowSidebarGroupItem,\n} from \"./SidebarGroup/SidebarGroupItem\";\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 /** Flatten sidebar items */\n flatten?: boolean;\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?: Partial<typeof DEFAULT_LABELS>;\n /**\n * Dnd Kit drag overlay props for customization.\n *\n * More information can be found in the [Dnd Kit documentation](https://docs.dndkit.com/api-documentation/draggable/drag-overlay).\n */\n dragOverlayProps?: DragOverlayProps;\n}\n\nconst DEFAULT_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 flatten = false,\n classes: classesProp,\n labels: labelsProps,\n dragOverlayProps,\n ...others\n}: HvFlowSidebarProps) => {\n const { classes } = useClasses(classesProp);\n\n const { nodeGroups, setExpandedNodeGroups } = useFlowContext();\n\n const [filterValue, setFilterValue] = useState(\"\");\n const [draggingLabel, setDraggingLabel] = useState<string>();\n\n const labels = useLabels(DEFAULT_LABELS, labelsProps);\n\n const drawerElementId = useUniqueId(id);\n const groupsElementId = useUniqueId();\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({ id: drawerElementId });\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 useDndMonitor({\n onDragEnd: handleDragEnd,\n onDragStart: handleDragStart,\n });\n\n const filteredGroups = useMemo(() => {\n if (!filterValue || !nodeGroups) return nodeGroups || {};\n\n return filterValue\n ? Object.entries(nodeGroups).reduce<HvFlowNodeGroups>(\n (acc, [groupId, group]) => {\n // Filter items by search\n const filteredItems = (group.items || []).filter((item) =>\n item.label.toLowerCase().includes(filterValue.toLowerCase()),\n );\n const itemsCount = Object.keys(filteredItems).length;\n\n // Only show groups with nodes\n if (itemsCount > 0) {\n acc[groupId] = {\n ...group,\n items: filteredItems,\n };\n }\n\n return acc;\n },\n {},\n )\n : nodeGroups;\n }, [filterValue, nodeGroups]);\n\n useEffect(() => {\n setExpandedNodeGroups?.(filterValue ? Object.keys(filteredGroups) : []);\n }, [filterValue, filteredGroups, setExpandedNodeGroups]);\n\n return (\n <HvDrawer\n BackdropComponent={undefined}\n variant=\"persistent\"\n classes={{\n paper: classes.drawerPaper,\n }}\n showBackdrop={false}\n anchor={anchor}\n buttonTitle={buttonTitle}\n {...others}\n >\n <div id={drawerElementId} ref={setNodeRef}>\n <div className={classes.titleContainer}>\n <Add />\n <HvTypography component=\"p\" variant=\"title3\">\n {title}\n </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={(evt, val) => setFilterValue(val.trim())}\n inputProps={{ autoComplete: \"off\" }}\n />\n <ul id={groupsElementId} className={classes.groupsContainer}>\n {Object.entries(filteredGroups).map(([groupId, group]) => {\n if (flatten) {\n return (group.items || []).map((item, i) => (\n <HvFlowDraggableSidebarGroupItem\n key={`${item.nodeType}-${i}`}\n aria-roledescription={labels?.itemAriaRoleDescription}\n {...item}\n />\n ));\n }\n\n return (\n <HvFlowSidebarGroup\n key={groupId}\n id={groupId}\n expandButtonProps={{\n \"aria-label\": labels?.expandGroupButtonAriaLabel,\n }}\n itemProps={{\n \"aria-roledescription\": labels?.itemAriaRoleDescription,\n }}\n {...group}\n />\n );\n })}\n </ul>\n </div>\n </div>\n <DragOverlay modifiers={[restrictToWindowEdges]} {...dragOverlayProps}>\n {draggingLabel ? (\n <HvFlowSidebarGroupItem label={draggingLabel} isDragging />\n ) : null}\n </DragOverlay>\n </HvDrawer>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;AAqDA,MAAM,iBAAiB;AAAA,EACrB,yBAAyB;AAAA,EACzB,4BAA4B;AAAA,EAC5B,mBAAmB;AAAA,EACnB,iBAAiB;AACnB;AAEO,MAAM,gBAAgB,CAAC;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,cAAc;AAAA,EACd,UAAU;AAAA,EACV,SAAS;AAAA,EACT,QAAQ;AAAA,EACR;AAAA,EACA,GAAG;AACL,MAA0B;AACxB,QAAM,EAAE,QAAA,IAAY,WAAW,WAAW;AAE1C,QAAM,EAAE,YAAY,sBAAsB,IAAI,eAAe;AAE7D,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,EAAE;AACjD,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAiB;AAErD,QAAA,SAAS,UAAU,gBAAgB,WAAW;AAE9C,QAAA,kBAAkB,YAAY,EAAE;AACtC,QAAM,kBAAkB;AAIxB,QAAM,EAAE,WAAW,IAAI,aAAa,EAAE,IAAI,iBAAiB;AAErD,QAAA,kBAAkD,CAAC,UAAU;AACjE,QAAI,MAAM,OAAO,KAAK,SAAS,QAAQ;AACrC,uBAAiB,MAAM,OAAO,KAAK,QAAQ,QAAQ,KAAK;AAAA,IAC1D;AAAA,EAAA;AAGF,QAAM,gBAA8C,MAAM;AACxD,qBAAiB,MAAS;AAAA,EAAA;AAGd,gBAAA;AAAA,IACZ,WAAW;AAAA,IACX,aAAa;AAAA,EAAA,CACd;AAEK,QAAA,iBAAiB,QAAQ,MAAM;AAC/B,QAAA,CAAC,eAAe,CAAC;AAAY,aAAO,cAAc,CAAA;AAEtD,WAAO,cACH,OAAO,QAAQ,UAAU,EAAE;AAAA,MACzB,CAAC,KAAK,CAAC,SAAS,KAA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;AAAA,gBACX,UAAU,CAAC,KAAK,QAAQ,eAAe,IAAI,MAAM;AAAA,gBACjD,YAAY,EAAE,cAAc,MAAM;AAAA,cAAA;AAAA,YACpC;AAAA,gCACC,MAAG,EAAA,IAAI,iBAAiB,WAAW,QAAQ,iBACzC,UAAA,OAAO,QAAQ,cAAc,EAAE,IAAI,CAAC,CAAC,SAAS,KAAK,MAAM;AACxD,kBAAI,SAAS;AACX,wBAAQ,MAAM,SAAS,CAAA,GAAI,IAAI,CAAC,MAAM,MACpC;AAAA,kBAAC;AAAA,kBAAA;AAAA,oBAEC,wBAAsB,QAAQ;AAAA,oBAC7B,GAAG;AAAA,kBAAA;AAAA,kBAFC,GAAG,KAAK,QAAQ,IAAI,CAAC;AAAA,gBAAA,CAI7B;AAAA,cACH;AAGE,qBAAA;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBAEC,IAAI;AAAA,kBACJ,mBAAmB;AAAA,oBACjB,cAAc,QAAQ;AAAA,kBACxB;AAAA,kBACA,WAAW;AAAA,oBACT,wBAAwB,QAAQ;AAAA,kBAClC;AAAA,kBACC,GAAG;AAAA,gBAAA;AAAA,gBARC;AAAA,cAAA;AAAA,YAWV,CAAA,GACH;AAAA,UAAA,GACF;AAAA,QAAA,GACF;AAAA,4BACC,aAAY,EAAA,WAAW,CAAC,qBAAqB,GAAI,GAAG,kBAClD,UACC,gBAAA,oBAAC,0BAAuB,OAAO,eAAe,YAAU,KAAC,CAAA,IACvD,MACN;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sidebar.styles.js","sources":["../../../../src/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
|
|
1
|
+
{"version":3,"file":"Sidebar.styles.js","sources":["../../../../src/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":[],"mappings":";AAEO,MAAM,EAAE,eAAe,eAAe,cAAc,iBAAiB;AAAA,EAC1E,aAAa,EAAE,OAAO,QAAQ;AAAA,EAC9B,gBAAgB;AAAA,IACd,SAAS;AAAA,IACT,SAAS,MAAM,QAAQ,MAAM,MAAM,MAAM,IAAI;AAAA,EAC/C;AAAA,EACA,kBAAkB,EAAE,SAAS,MAAM,QAAQ,GAAG,MAAM,MAAM,IAAI,EAAE;AAAA,EAChE,aAAa,EAAE,OAAO,MAAM,OAAO,aAAa;AAAA,EAChD,YAAY;AAAA,IACV,YAAY,MAAM,MAAM;AAAA,IACxB,eAAe,MAAM,MAAM;AAAA,EAC7B;AAAA,EACA,iBAAiB;AAAA,IACf,SAAS;AAAA,IACT,eAAe;AAAA,IACf,KAAK,MAAM,MAAM;AAAA,IACjB,eAAe;AAAA,EACjB;AACF,CAAC;"}
|
|
@@ -10,7 +10,7 @@ import { HvFlowDraggableSidebarGroupItem } from "./SidebarGroupItem/DraggableSid
|
|
|
10
10
|
const HvFlowSidebarGroup = ({
|
|
11
11
|
id,
|
|
12
12
|
label,
|
|
13
|
-
|
|
13
|
+
items = [],
|
|
14
14
|
color,
|
|
15
15
|
description,
|
|
16
16
|
icon,
|
|
@@ -21,19 +21,19 @@ const HvFlowSidebarGroup = ({
|
|
|
21
21
|
const { classes, cx, css } = useClasses(classesProp);
|
|
22
22
|
const { expandedNodeGroups, setExpandedNodeGroups } = useFlowContext();
|
|
23
23
|
const opened = useMemo(
|
|
24
|
-
() => !!expandedNodeGroups?.find((
|
|
24
|
+
() => !!expandedNodeGroups?.find((group) => group === id),
|
|
25
25
|
[expandedNodeGroups, id]
|
|
26
26
|
);
|
|
27
27
|
const handleClick = useCallback(() => {
|
|
28
28
|
setExpandedNodeGroups?.(
|
|
29
|
-
(prev) => opened ? prev.filter((
|
|
29
|
+
(prev) => opened ? prev.filter((group) => id !== group) : [...prev, id]
|
|
30
30
|
);
|
|
31
31
|
}, [id, opened, setExpandedNodeGroups]);
|
|
32
32
|
return /* @__PURE__ */ jsxs("li", { className: cx(css({ borderColor: getColor(color) }), classes.root), children: [
|
|
33
33
|
/* @__PURE__ */ jsxs("div", { className: classes.titleContainer, children: [
|
|
34
34
|
/* @__PURE__ */ jsxs("div", { className: classes.labelContainer, children: [
|
|
35
|
-
/* @__PURE__ */ jsx("div", { className: classes.icon, children: icon }),
|
|
36
|
-
/* @__PURE__ */ jsx(HvTypography, { component: "p", variant: "title4", children:
|
|
35
|
+
/* @__PURE__ */ jsx("div", { className: classes.icon, role: "presentation", children: icon }),
|
|
36
|
+
/* @__PURE__ */ jsx(HvTypography, { component: "p", variant: "title4", children: Object.keys(items).length > 1 ? `${label} (${Object.keys(items).length})` : label })
|
|
37
37
|
] }),
|
|
38
38
|
/* @__PURE__ */ jsx(
|
|
39
39
|
HvButton,
|
|
@@ -47,13 +47,13 @@ const HvFlowSidebarGroup = ({
|
|
|
47
47
|
)
|
|
48
48
|
] }),
|
|
49
49
|
description && /* @__PURE__ */ jsx("div", { className: classes.descriptionContainer, children: /* @__PURE__ */ jsx(HvTypography, { children: description }) }),
|
|
50
|
-
opened && /* @__PURE__ */ jsx("div", { className: classes.itemsContainer, children:
|
|
50
|
+
opened && /* @__PURE__ */ jsx("div", { className: classes.itemsContainer, children: Object.entries(items).map(([itemId, item]) => /* @__PURE__ */ jsx(
|
|
51
51
|
HvFlowDraggableSidebarGroupItem,
|
|
52
52
|
{
|
|
53
53
|
...itemProps,
|
|
54
|
-
...
|
|
54
|
+
...item
|
|
55
55
|
},
|
|
56
|
-
|
|
56
|
+
itemId
|
|
57
57
|
)) })
|
|
58
58
|
] });
|
|
59
59
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SidebarGroup.js","sources":["../../../../../src/Flow/Sidebar/SidebarGroup/SidebarGroup.tsx"],"sourcesContent":["import { useCallback, useMemo } from \"react\";\nimport {\n ExtractNames,\n HvButton,\n HvButtonProps,\n HvTypography,\n} from \"@hitachivantara/uikit-react-core\";\nimport { Down, Up } from \"@hitachivantara/uikit-react-icons\";\nimport { getColor } from \"@hitachivantara/uikit-styles\";\n\nimport { useFlowContext } from \"../../hooks\";\nimport { HvFlowNodeGroup } from \"../../types\";\nimport { staticClasses, useClasses } from \"./SidebarGroup.styles\";\nimport {\n HvFlowDraggableSidebarGroupItem,\n HvFlowDraggableSidebarGroupItemProps,\n} from \"./SidebarGroupItem\";\n\nexport { staticClasses as flowSidebarGroupClasses };\n\nexport type HvFlowSidebarGroupClasses = ExtractNames<typeof useClasses>;\n\nexport
|
|
1
|
+
{"version":3,"file":"SidebarGroup.js","sources":["../../../../../src/Flow/Sidebar/SidebarGroup/SidebarGroup.tsx"],"sourcesContent":["import { useCallback, useMemo } from \"react\";\nimport {\n ExtractNames,\n HvButton,\n HvButtonProps,\n HvTypography,\n} from \"@hitachivantara/uikit-react-core\";\nimport { Down, Up } from \"@hitachivantara/uikit-react-icons\";\nimport { getColor } from \"@hitachivantara/uikit-styles\";\n\nimport { useFlowContext } from \"../../hooks\";\nimport { HvFlowNodeGroup } from \"../../types\";\nimport { staticClasses, useClasses } from \"./SidebarGroup.styles\";\nimport {\n HvFlowDraggableSidebarGroupItem,\n HvFlowDraggableSidebarGroupItemProps,\n} from \"./SidebarGroupItem\";\n\nexport { staticClasses as flowSidebarGroupClasses };\n\nexport type HvFlowSidebarGroupClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvFlowSidebarGroupProps extends HvFlowNodeGroup {\n /** Group id. */\n id: string;\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 items = [],\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((group) => group === id),\n [expandedNodeGroups, id],\n );\n\n const handleClick = useCallback(() => {\n setExpandedNodeGroups?.((prev) =>\n opened ? prev.filter((group) => id !== group) : [...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=\"presentation\">\n {icon}\n </div>\n <HvTypography component=\"p\" variant=\"title4\">\n {Object.keys(items).length > 1\n ? `${label} (${Object.keys(items).length})`\n : label}\n </HvTypography>\n </div>\n <HvButton\n icon\n onClick={handleClick}\n aria-expanded={opened}\n {...expandButtonProps}\n >\n {opened ? <Up /> : <Down />}\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 {Object.entries(items).map(([itemId, item]) => (\n <HvFlowDraggableSidebarGroupItem\n key={itemId}\n {...itemProps}\n {...item}\n />\n ))}\n </div>\n )}\n </li>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AAiCO,MAAM,qBAAqB,CAAC;AAAA,EACjC;AAAA,EACA;AAAA,EACA,QAAQ,CAAC;AAAA,EACT;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT;AACF,MAA+B;AAC7B,QAAM,EAAE,SAAS,IAAI,IAAI,IAAI,WAAW,WAAW;AAEnD,QAAM,EAAE,oBAAoB,sBAAsB,IAAI,eAAe;AAErE,QAAM,SAAS;AAAA,IACb,MAAM,CAAC,CAAC,oBAAoB,KAAK,CAAC,UAAU,UAAU,EAAE;AAAA,IACxD,CAAC,oBAAoB,EAAE;AAAA,EAAA;AAGnB,QAAA,cAAc,YAAY,MAAM;AACpC;AAAA,MAAwB,CAAC,SACvB,SAAS,KAAK,OAAO,CAAC,UAAU,OAAO,KAAK,IAAI,CAAC,GAAG,MAAM,EAAE;AAAA,IAAA;AAAA,EAE7D,GAAA,CAAC,IAAI,QAAQ,qBAAqB,CAAC;AAEtC,SACG,qBAAA,MAAA,EAAG,WAAW,GAAG,IAAI,EAAE,aAAa,SAAS,KAAK,EAAE,CAAC,GAAG,QAAQ,IAAI,GACnE,UAAA;AAAA,IAAC,qBAAA,OAAA,EAAI,WAAW,QAAQ,gBACtB,UAAA;AAAA,MAAC,qBAAA,OAAA,EAAI,WAAW,QAAQ,gBACtB,UAAA;AAAA,QAAA,oBAAC,SAAI,WAAW,QAAQ,MAAM,MAAK,gBAChC,UACH,MAAA;AAAA,QACA,oBAAC,gBAAa,WAAU,KAAI,SAAQ,UACjC,UAAA,OAAO,KAAK,KAAK,EAAE,SAAS,IACzB,GAAG,KAAK,KAAK,OAAO,KAAK,KAAK,EAAE,MAAM,MACtC,MACN,CAAA;AAAA,MAAA,GACF;AAAA,MACA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,MAAI;AAAA,UACJ,SAAS;AAAA,UACT,iBAAe;AAAA,UACd,GAAG;AAAA,UAEH,UAAS,SAAA,oBAAC,IAAG,CAAA,CAAA,wBAAM,MAAK,EAAA;AAAA,QAAA;AAAA,MAC3B;AAAA,IAAA,GACF;AAAA,IACC,mCACE,OAAI,EAAA,WAAW,QAAQ,sBACtB,UAAA,oBAAC,cAAc,EAAA,UAAA,YAAA,CAAY,EAC7B,CAAA;AAAA,IAED,UACC,oBAAC,OAAI,EAAA,WAAW,QAAQ,gBACrB,UAAA,OAAO,QAAQ,KAAK,EAAE,IAAI,CAAC,CAAC,QAAQ,IAAI,MACvC;AAAA,MAAC;AAAA,MAAA;AAAA,QAEE,GAAG;AAAA,QACH,GAAG;AAAA,MAAA;AAAA,MAFC;AAAA,IAIR,CAAA,GACH;AAAA,EAEJ,EAAA,CAAA;AAEJ;"}
|
|
@@ -5,20 +5,20 @@ import { useForkRef } from "@mui/material/utils";
|
|
|
5
5
|
import { useUniqueId } from "@hitachivantara/uikit-react-core";
|
|
6
6
|
import { HvFlowSidebarGroupItem } from "./SidebarGroupItem.js";
|
|
7
7
|
const HvFlowDraggableSidebarGroupItem = ({
|
|
8
|
-
id,
|
|
8
|
+
id: idProp,
|
|
9
9
|
label,
|
|
10
|
-
|
|
10
|
+
nodeType,
|
|
11
11
|
data,
|
|
12
12
|
...others
|
|
13
13
|
}) => {
|
|
14
14
|
const itemRef = useRef(null);
|
|
15
|
-
const
|
|
15
|
+
const id = useUniqueId(idProp);
|
|
16
16
|
const { attributes, listeners, setNodeRef, isDragging, transform } = useDraggable({
|
|
17
|
-
id
|
|
17
|
+
id,
|
|
18
18
|
data: {
|
|
19
19
|
hvFlow: {
|
|
20
20
|
// Needed to know which item is being dragged and dropped
|
|
21
|
-
type,
|
|
21
|
+
type: nodeType,
|
|
22
22
|
// Needed for the drag overlay: otherwise the item is cut by the drawer because of overflow
|
|
23
23
|
label,
|
|
24
24
|
// Item position: used to position the item when dropped
|
package/dist/esm/Flow/Sidebar/SidebarGroup/SidebarGroupItem/DraggableSidebarGroupItem.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DraggableSidebarGroupItem.js","sources":["../../../../../../src/Flow/Sidebar/SidebarGroup/SidebarGroupItem/DraggableSidebarGroupItem.tsx"],"sourcesContent":["import { useRef } from \"react\";\nimport { useDraggable } from \"@dnd-kit/core\";\nimport { useForkRef } from \"@mui/material/utils\";\nimport { useUniqueId } from \"@hitachivantara/uikit-react-core\";\n\nimport {\n HvFlowSidebarGroupItem,\n HvFlowSidebarGroupItemProps,\n} from \"./SidebarGroupItem\";\n\nexport interface HvFlowDraggableSidebarGroupItemProps\n extends HvFlowSidebarGroupItemProps {
|
|
1
|
+
{"version":3,"file":"DraggableSidebarGroupItem.js","sources":["../../../../../../src/Flow/Sidebar/SidebarGroup/SidebarGroupItem/DraggableSidebarGroupItem.tsx"],"sourcesContent":["import { useRef } from \"react\";\nimport { useDraggable } from \"@dnd-kit/core\";\nimport { useForkRef } from \"@mui/material/utils\";\nimport { useUniqueId } from \"@hitachivantara/uikit-react-core\";\n\nimport { HvFlowGroupItem } from \"../../../types\";\nimport {\n HvFlowSidebarGroupItem,\n HvFlowSidebarGroupItemProps,\n} from \"./SidebarGroupItem\";\n\nexport interface HvFlowDraggableSidebarGroupItemProps\n extends HvFlowSidebarGroupItemProps,\n HvFlowGroupItem {}\n\nexport const HvFlowDraggableSidebarGroupItem = ({\n id: idProp,\n label,\n nodeType,\n data,\n ...others\n}: HvFlowDraggableSidebarGroupItemProps) => {\n const itemRef = useRef<HTMLElement>(null);\n const id = useUniqueId(idProp);\n\n const { attributes, listeners, setNodeRef, isDragging, transform } =\n useDraggable({\n id,\n data: {\n hvFlow: {\n // Needed to know which item is being dragged and dropped\n type: nodeType,\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 // Data\n data,\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":[],"mappings":";;;;;;AAeO,MAAM,kCAAkC,CAAC;AAAA,EAC9C,IAAI;AAAA,EACJ;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAA4C;AACpC,QAAA,UAAU,OAAoB,IAAI;AAClC,QAAA,KAAK,YAAY,MAAM;AAE7B,QAAM,EAAE,YAAY,WAAW,YAAY,YAAY,cACrD,aAAa;AAAA,IACX;AAAA,IACA,MAAM;AAAA,MACJ,QAAQ;AAAA;AAAA,QAEN,MAAM;AAAA;AAAA,QAEN;AAAA;AAAA,QAEA,GAAG,QAAQ,SAAS,sBAAwB,EAAA;AAAA,QAC5C,GAAG,QAAQ,SAAS,sBAAwB,EAAA;AAAA;AAAA,QAE5C;AAAA,MACF;AAAA,IACF;AAAA,EAAA,CACD;AAEG,QAAA,YAAY,WAAW,SAAS,UAAU;AAEhD,QAAM,QAAQ,YACV;AAAA,IACE,WAAW,eAAe,UAAU,CAAC,OAAO,UAAU,CAAC;AAAA,EAEzD,IAAA;AAGF,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAK;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACC,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,IAAA;AAAA,EAAA;AAGV;"}
|
|
@@ -4,33 +4,32 @@ import { HvTypography } from "@hitachivantara/uikit-react-core";
|
|
|
4
4
|
import { Drag } from "@hitachivantara/uikit-react-icons";
|
|
5
5
|
import { useClasses } from "./SidebarGroupItem.styles.js";
|
|
6
6
|
import { staticClasses } from "./SidebarGroupItem.styles.js";
|
|
7
|
-
const HvFlowSidebarGroupItem = forwardRef(
|
|
8
|
-
|
|
7
|
+
const HvFlowSidebarGroupItem = forwardRef((props, ref) => {
|
|
8
|
+
const {
|
|
9
9
|
label,
|
|
10
10
|
isDragging,
|
|
11
11
|
classes: classesProp,
|
|
12
12
|
className,
|
|
13
13
|
...others
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
);
|
|
14
|
+
} = props;
|
|
15
|
+
const { classes, cx } = useClasses(classesProp);
|
|
16
|
+
return /* @__PURE__ */ jsxs(
|
|
17
|
+
"div",
|
|
18
|
+
{
|
|
19
|
+
ref,
|
|
20
|
+
className: cx(
|
|
21
|
+
classes.root,
|
|
22
|
+
{ [classes.dragging]: isDragging },
|
|
23
|
+
className
|
|
24
|
+
),
|
|
25
|
+
...others,
|
|
26
|
+
children: [
|
|
27
|
+
/* @__PURE__ */ jsx(HvTypography, { children: label }),
|
|
28
|
+
/* @__PURE__ */ jsx(Drag, {})
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
});
|
|
34
33
|
export {
|
|
35
34
|
HvFlowSidebarGroupItem,
|
|
36
35
|
staticClasses as flowSidebarGroupItemClasses
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SidebarGroupItem.js","sources":["../../../../../../src/Flow/Sidebar/SidebarGroup/SidebarGroupItem/SidebarGroupItem.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\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
|
|
1
|
+
{"version":3,"file":"SidebarGroupItem.js","sources":["../../../../../../src/Flow/Sidebar/SidebarGroup/SidebarGroupItem/SidebarGroupItem.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\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>((props, ref) => {\n const {\n label,\n isDragging,\n classes: classesProp,\n className,\n ...others\n } = props;\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 />\n </div>\n );\n});\n"],"names":[],"mappings":";;;;;;AAuBO,MAAM,yBAAyB,WAGpC,CAAC,OAAO,QAAQ;AACV,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA,GAAG;AAAA,EACD,IAAA;AACJ,QAAM,EAAE,SAAS,GAAG,IAAI,WAAW,WAAW;AAG5C,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA,WAAW;AAAA,QACT,QAAQ;AAAA,QACR,EAAE,CAAC,QAAQ,QAAQ,GAAG,WAAW;AAAA,QACjC;AAAA,MACF;AAAA,MACC,GAAG;AAAA,MAEJ,UAAA;AAAA,QAAA,oBAAC,gBAAc,UAAM,MAAA,CAAA;AAAA,4BACpB,MAAK,EAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGZ,CAAC;"}
|