@hitachivantara/uikit-react-lab 4.3.2 → 4.4.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/VerticalNavigation/VerticalNavigation.d.ts +12 -8
- package/dist/VerticalNavigation/VerticalNavigation.js +83 -44
- package/dist/VerticalNavigation/VerticalNavigation.js.map +1 -1
- package/dist/VerticalNavigation/styles.js +12 -37
- package/dist/VerticalNavigation/styles.js.map +1 -1
- package/dist/VerticalNavigation/utils.js +80 -0
- package/dist/VerticalNavigation/utils.js.map +1 -0
- package/dist/legacy/VerticalNavigation/VerticalNavigation.d.ts +12 -8
- package/dist/legacy/VerticalNavigation/VerticalNavigation.js +84 -43
- package/dist/legacy/VerticalNavigation/VerticalNavigation.js.map +1 -1
- package/dist/legacy/VerticalNavigation/styles.js +12 -36
- package/dist/legacy/VerticalNavigation/styles.js.map +1 -1
- package/dist/legacy/VerticalNavigation/utils.js +71 -0
- package/dist/legacy/VerticalNavigation/utils.js.map +1 -0
- package/dist/modern/VerticalNavigation/VerticalNavigation.d.ts +12 -8
- package/dist/modern/VerticalNavigation/VerticalNavigation.js +77 -45
- package/dist/modern/VerticalNavigation/VerticalNavigation.js.map +1 -1
- package/dist/modern/VerticalNavigation/styles.js +12 -29
- package/dist/modern/VerticalNavigation/styles.js.map +1 -1
- package/dist/modern/VerticalNavigation/utils.js +60 -0
- package/dist/modern/VerticalNavigation/utils.js.map +1 -0
- package/package.json +4 -4
|
@@ -1,70 +1,98 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
1
3
|
var _Backwards, _Forwards;
|
|
4
|
+
const _excluded = ["onNavigationChange", "onToggleExpanded", "data", "selected", "expanded", "topPosition", "expandedPanelWidth", "collapsedPanelWidth", "position"],
|
|
5
|
+
_excluded2 = ["data"];
|
|
6
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
7
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
2
8
|
import React, { useState } from "react";
|
|
3
9
|
import { withStyles } from "@mui/styles";
|
|
4
10
|
import PropTypes from "prop-types";
|
|
5
11
|
import clsx from "clsx";
|
|
6
|
-
import { HvVerticalNavigation as HvVerticalNavigationCore, HvVerticalNavigationTree,
|
|
12
|
+
import { HvVerticalNavigation as HvVerticalNavigationCore, HvVerticalNavigationTree, HvButton, HvContainer } from "@hitachivantara/uikit-react-core";
|
|
7
13
|
import { Backwards, Forwards } from "@hitachivantara/uikit-react-icons";
|
|
8
14
|
import useStyles from "./styles";
|
|
15
|
+
import { getAllParents, findRootParentById, findItemById } from "./utils";
|
|
9
16
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
17
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
-
const HvVerticalNavigation =
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
const HvVerticalNavigation = _ref => {
|
|
19
|
+
var _findRootParentById;
|
|
20
|
+
let {
|
|
21
|
+
onNavigationChange,
|
|
22
|
+
onToggleExpanded,
|
|
23
|
+
data,
|
|
24
|
+
selected,
|
|
25
|
+
expanded,
|
|
26
|
+
topPosition,
|
|
27
|
+
expandedPanelWidth,
|
|
28
|
+
collapsedPanelWidth,
|
|
29
|
+
position
|
|
30
|
+
} = _ref,
|
|
31
|
+
others = _objectWithoutProperties(_ref, _excluded);
|
|
21
32
|
const classes = useStyles({
|
|
22
33
|
topPosition,
|
|
23
34
|
expandedPanelWidth,
|
|
24
|
-
collapsedPanelWidth
|
|
35
|
+
collapsedPanelWidth,
|
|
36
|
+
position
|
|
25
37
|
})();
|
|
26
|
-
const
|
|
38
|
+
const noSubData = data.map(_ref2 => {
|
|
39
|
+
let {
|
|
40
|
+
data: dataToRemove
|
|
41
|
+
} = _ref2,
|
|
42
|
+
rest = _objectWithoutProperties(_ref2, _excluded2);
|
|
43
|
+
return rest;
|
|
44
|
+
});
|
|
45
|
+
const [expandedItems, setExpandedItems] = useState(getAllParents(data).map(item => item.id));
|
|
46
|
+
const selectedTopParent = (_findRootParentById = findRootParentById(data, selected)) === null || _findRootParentById === void 0 ? void 0 : _findRootParentById.id;
|
|
27
47
|
const handleVerticalNavigationChange = (event, item) => {
|
|
28
|
-
|
|
48
|
+
// This need to be done because the item recieved on the callback is missing the original data object
|
|
49
|
+
const fullItem = findItemById(data, item.id);
|
|
50
|
+
if (!expanded && fullItem.data && fullItem.data.length > 0) {
|
|
51
|
+
setExpandedItems(prevState => [...prevState, item.id]);
|
|
52
|
+
onToggleExpanded(true);
|
|
53
|
+
} else {
|
|
54
|
+
onNavigationChange === null || onNavigationChange === void 0 ? void 0 : onNavigationChange(event, item);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const handleVerticalNavigationToggle = (event, currentExpandedItems) => {
|
|
58
|
+
setExpandedItems(currentExpandedItems);
|
|
29
59
|
};
|
|
30
60
|
const handleExpandToggle = () => {
|
|
31
|
-
|
|
61
|
+
onToggleExpanded(!expanded);
|
|
32
62
|
};
|
|
33
|
-
return /*#__PURE__*/_jsxs(HvVerticalNavigationCore, {
|
|
34
|
-
className: clsx(classes.panel,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
selected: selected,
|
|
39
|
-
onChange: handleVerticalNavigationChange
|
|
40
|
-
}), /*#__PURE__*/_jsx(HvVerticalNavigationActions, {
|
|
63
|
+
return /*#__PURE__*/_jsxs(HvVerticalNavigationCore, _objectSpread(_objectSpread({
|
|
64
|
+
className: clsx(classes.panel, expanded ? classes.panelExpanded : classes.panelCollapsed)
|
|
65
|
+
}, others), {}, {
|
|
66
|
+
children: [/*#__PURE__*/_jsx(HvContainer, {
|
|
67
|
+
className: `${classes.toggleCollapsePanel}`,
|
|
41
68
|
children: /*#__PURE__*/_jsx(HvButton, {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
startIcon: isExpanded ? _Backwards || (_Backwards = /*#__PURE__*/_jsx(Backwards, {
|
|
69
|
+
icon: true,
|
|
70
|
+
onClick: handleExpandToggle,
|
|
71
|
+
children: expanded ? _Backwards || (_Backwards = /*#__PURE__*/_jsx(Backwards, {
|
|
46
72
|
iconSize: "XS"
|
|
47
73
|
})) : _Forwards || (_Forwards = /*#__PURE__*/_jsx(Forwards, {
|
|
48
74
|
iconSize: "XS"
|
|
49
|
-
}))
|
|
50
|
-
onClick: handleExpandToggle,
|
|
51
|
-
children: isExpanded && /*#__PURE__*/_jsx("span", {
|
|
52
|
-
className: classes.collapseTextContainer,
|
|
53
|
-
children: collapseLabel
|
|
54
|
-
})
|
|
75
|
+
}))
|
|
55
76
|
})
|
|
77
|
+
}), /*#__PURE__*/_jsx(HvVerticalNavigationTree, {
|
|
78
|
+
collapsible: true,
|
|
79
|
+
expanded: expandedItems,
|
|
80
|
+
data: expanded ? data : noSubData,
|
|
81
|
+
selected: expanded ? selected : selectedTopParent,
|
|
82
|
+
onChange: handleVerticalNavigationChange,
|
|
83
|
+
onToggle: handleVerticalNavigationToggle
|
|
56
84
|
})]
|
|
57
|
-
});
|
|
85
|
+
}));
|
|
58
86
|
};
|
|
59
87
|
process.env.NODE_ENV !== "production" ? HvVerticalNavigation.propTypes = {
|
|
60
|
-
/**
|
|
61
|
-
* Id to be applied to the root node of the panel.
|
|
62
|
-
*/
|
|
63
|
-
id: PropTypes.string,
|
|
64
88
|
/**
|
|
65
89
|
* Called when a menu item is clicked.
|
|
66
90
|
*/
|
|
67
91
|
onNavigationChange: PropTypes.func,
|
|
92
|
+
/**
|
|
93
|
+
* Called when the collapse / expand button is clicked.
|
|
94
|
+
*/
|
|
95
|
+
onToggleExpanded: PropTypes.func,
|
|
68
96
|
/**
|
|
69
97
|
* An array containing the data for each menu item.
|
|
70
98
|
*
|
|
@@ -83,14 +111,14 @@ process.env.NODE_ENV !== "production" ? HvVerticalNavigation.propTypes = {
|
|
|
83
111
|
href: PropTypes.string,
|
|
84
112
|
target: PropTypes.string
|
|
85
113
|
})).isRequired,
|
|
86
|
-
/**
|
|
87
|
-
* Text to be displayed in the collpase area when the panel is expanded.
|
|
88
|
-
*/
|
|
89
|
-
collapseLabel: PropTypes.string,
|
|
90
114
|
/**
|
|
91
115
|
* The ID of the selected page.
|
|
92
116
|
*/
|
|
93
117
|
selected: PropTypes.string,
|
|
118
|
+
/**
|
|
119
|
+
* Boolean value stating if the panel should be collapsed or expanded.
|
|
120
|
+
*/
|
|
121
|
+
expanded: PropTypes.bool,
|
|
94
122
|
/**
|
|
95
123
|
* The top value where the panel will be rendered. Default is 44 as it is the height of the Header component.
|
|
96
124
|
*/
|
|
@@ -102,13 +130,17 @@ process.env.NODE_ENV !== "production" ? HvVerticalNavigation.propTypes = {
|
|
|
102
130
|
/**
|
|
103
131
|
* The width of the panel when collapsed. Default vlaue is 52.
|
|
104
132
|
*/
|
|
105
|
-
collapsedPanelWidth: PropTypes.number
|
|
133
|
+
collapsedPanelWidth: PropTypes.number,
|
|
134
|
+
/**
|
|
135
|
+
* Position of the component.
|
|
136
|
+
*/
|
|
137
|
+
position: PropTypes.oneOf(["static", "relative", "fixed", "absolute", "sticky"])
|
|
106
138
|
} : void 0;
|
|
107
139
|
HvVerticalNavigation.defaultProps = {
|
|
108
|
-
collapseLabel: "Collapse",
|
|
109
140
|
topPosition: 44,
|
|
110
141
|
expandedPanelWidth: 300,
|
|
111
|
-
collapsedPanelWidth: 52
|
|
142
|
+
collapsedPanelWidth: 52,
|
|
143
|
+
position: "fixed"
|
|
112
144
|
};
|
|
113
145
|
export default withStyles(useStyles, {
|
|
114
146
|
name: "HvVerticalNavigation"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VerticalNavigation.js","names":["React","useState","withStyles","PropTypes","clsx","HvVerticalNavigation","HvVerticalNavigationCore","HvVerticalNavigationTree","
|
|
1
|
+
{"version":3,"file":"VerticalNavigation.js","names":["React","useState","withStyles","PropTypes","clsx","HvVerticalNavigation","HvVerticalNavigationCore","HvVerticalNavigationTree","HvButton","HvContainer","Backwards","Forwards","useStyles","getAllParents","findRootParentById","findItemById","onNavigationChange","onToggleExpanded","data","selected","expanded","topPosition","expandedPanelWidth","collapsedPanelWidth","position","others","classes","noSubData","map","dataToRemove","rest","expandedItems","setExpandedItems","item","id","selectedTopParent","handleVerticalNavigationChange","event","fullItem","length","prevState","handleVerticalNavigationToggle","currentExpandedItems","handleExpandToggle","panel","panelExpanded","panelCollapsed","toggleCollapsePanel","propTypes","func","arrayOf","shape","string","isRequired","label","icon","node","array","href","target","bool","number","oneOf","defaultProps","name"],"sources":["../../../src/VerticalNavigation/VerticalNavigation.js"],"sourcesContent":["import React, { useState } from \"react\";\nimport { withStyles } from \"@mui/styles\";\nimport PropTypes from \"prop-types\";\nimport clsx from \"clsx\";\n\nimport {\n HvVerticalNavigation as HvVerticalNavigationCore,\n HvVerticalNavigationTree,\n HvButton,\n HvContainer,\n} from \"@hitachivantara/uikit-react-core\";\nimport { Backwards, Forwards } from \"@hitachivantara/uikit-react-icons\";\n\nimport useStyles from \"./styles\";\nimport { getAllParents, findRootParentById, findItemById } from \"./utils\";\n\nconst HvVerticalNavigation = ({\n onNavigationChange,\n onToggleExpanded,\n data,\n selected,\n expanded,\n topPosition,\n expandedPanelWidth,\n collapsedPanelWidth,\n position,\n\n ...others\n}) => {\n const classes = useStyles({ topPosition, expandedPanelWidth, collapsedPanelWidth, position })();\n\n const noSubData = data.map(({ data: dataToRemove, ...rest }) => rest);\n\n const [expandedItems, setExpandedItems] = useState(getAllParents(data).map((item) => item.id));\n\n const selectedTopParent = findRootParentById(data, selected)?.id;\n\n const handleVerticalNavigationChange = (event, item) => {\n // This need to be done because the item recieved on the callback is missing the original data object\n const fullItem = findItemById(data, item.id);\n\n if (!expanded && fullItem.data && fullItem.data.length > 0) {\n setExpandedItems((prevState) => [...prevState, item.id]);\n onToggleExpanded(true);\n } else {\n onNavigationChange?.(event, item);\n }\n };\n\n const handleVerticalNavigationToggle = (event, currentExpandedItems) => {\n setExpandedItems(currentExpandedItems);\n };\n\n const handleExpandToggle = () => {\n onToggleExpanded(!expanded);\n };\n\n return (\n <HvVerticalNavigationCore\n className={clsx(classes.panel, {\n [classes.panelExpanded]: expanded,\n [classes.panelCollapsed]: !expanded,\n })}\n {...others}\n >\n <HvContainer className={`${classes.toggleCollapsePanel}`}>\n <HvButton icon onClick={handleExpandToggle}>\n {expanded ? <Backwards iconSize=\"XS\" /> : <Forwards iconSize=\"XS\" />}\n </HvButton>\n </HvContainer>\n\n <HvVerticalNavigationTree\n collapsible\n expanded={expandedItems}\n data={expanded ? data : noSubData}\n selected={expanded ? selected : selectedTopParent}\n onChange={handleVerticalNavigationChange}\n onToggle={handleVerticalNavigationToggle}\n />\n </HvVerticalNavigationCore>\n );\n};\n\nHvVerticalNavigation.propTypes = {\n /**\n * Called when a menu item is clicked.\n */\n onNavigationChange: PropTypes.func,\n /**\n * Called when the collapse / expand button is clicked.\n */\n onToggleExpanded: PropTypes.func,\n /**\n * An array containing the data for each menu item.\n *\n * id - the id to be applied to the root element.\n * label - the label to be rendered on the menu item.\n * icon - the icon component.\n * data - sub-menu items\n * href - the url used for navigation.\n * target - the behavior when opening an url.\n */\n data: PropTypes.arrayOf(\n PropTypes.shape({\n id: PropTypes.string.isRequired,\n label: PropTypes.string.isRequired,\n icon: PropTypes.node,\n data: PropTypes.array,\n href: PropTypes.string,\n target: PropTypes.string,\n })\n ).isRequired,\n /**\n * The ID of the selected page.\n */\n selected: PropTypes.string,\n /**\n * Boolean value stating if the panel should be collapsed or expanded.\n */\n expanded: PropTypes.bool,\n /**\n * The top value where the panel will be rendered. Default is 44 as it is the height of the Header component.\n */\n topPosition: PropTypes.number,\n /**\n * The width of the panel when expanded. Default value is 300.\n */\n expandedPanelWidth: PropTypes.number,\n /**\n * The width of the panel when collapsed. Default vlaue is 52.\n */\n collapsedPanelWidth: PropTypes.number,\n /**\n * Position of the component.\n */\n position: PropTypes.oneOf([\"static\", \"relative\", \"fixed\", \"absolute\", \"sticky\"]),\n};\n\nHvVerticalNavigation.defaultProps = {\n topPosition: 44,\n expandedPanelWidth: 300,\n collapsedPanelWidth: 52,\n position: \"fixed\",\n};\n\nexport default withStyles(useStyles, { name: \"HvVerticalNavigation\" })(HvVerticalNavigation);\n"],"mappings":";;;;;;;AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,SAASC,UAAU,QAAQ,aAAa;AACxC,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,IAAI,MAAM,MAAM;AAEvB,SACEC,oBAAoB,IAAIC,wBAAwB,EAChDC,wBAAwB,EACxBC,QAAQ,EACRC,WAAW,QACN,kCAAkC;AACzC,SAASC,SAAS,EAAEC,QAAQ,QAAQ,mCAAmC;AAEvE,OAAOC,SAAS,MAAM,UAAU;AAChC,SAASC,aAAa,EAAEC,kBAAkB,EAAEC,YAAY,QAAQ,SAAS;AAAC;AAAA;AAE1E,MAAMV,oBAAoB,GAAG,QAYvB;EAAA;EAAA,IAZwB;MAC5BW,kBAAkB;MAClBC,gBAAgB;MAChBC,IAAI;MACJC,QAAQ;MACRC,QAAQ;MACRC,WAAW;MACXC,kBAAkB;MAClBC,mBAAmB;MACnBC;IA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O,MAAM,EAAExD,SAAS,CAACiD;EACpB,CAAC,CAAC,CACH,CAACC,UAAU;EACZ;AACF;AACA;EACElC,QAAQ,EAAEhB,SAAS,CAACiD,MAAM;EAC1B;AACF;AACA;EACEhC,QAAQ,EAAEjB,SAAS,CAACyD,IAAI;EACxB;AACF;AACA;EACEvC,WAAW,EAAElB,SAAS,CAAC0D,MAAM;EAC7B;AACF;AACA;EACEvC,kBAAkB,EAAEnB,SAAS,CAAC0D,MAAM;EACpC;AACF;AACA;EACEtC,mBAAmB,EAAEpB,SAAS,CAAC0D,MAAM;EACrC;AACF;AACA;EACErC,QAAQ,EAAErB,SAAS,CAAC2D,KAAK,CAAC,CAAC,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAC;AACjF,CAAC;AAEDzD,oBAAoB,CAAC0D,YAAY,GAAG;EAClC1C,WAAW,EAAE,EAAE;EACfC,kBAAkB,EAAE,GAAG;EACvBC,mBAAmB,EAAE,EAAE;EACvBC,QAAQ,EAAE;AACZ,CAAC;AAED,eAAetB,UAAU,CAACU,SAAS,EAAE;EAAEoD,IAAI,EAAE;AAAuB,CAAC,CAAC,CAAC3D,oBAAoB,CAAC"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
1
|
import { makeStyles } from "@mui/styles";
|
|
5
2
|
const styles = props => makeStyles(theme => ({
|
|
6
3
|
panel: {
|
|
7
|
-
|
|
4
|
+
justifyContent: "flex-start",
|
|
5
|
+
position: props.position,
|
|
8
6
|
top: props.topPosition,
|
|
9
7
|
left: 0,
|
|
10
8
|
zIndex: 1100
|
|
@@ -12,22 +10,20 @@ const styles = props => makeStyles(theme => ({
|
|
|
12
10
|
panelExpanded: {
|
|
13
11
|
width: props.expandedPanelWidth,
|
|
14
12
|
height: `calc(100vh - ${props.topPosition}px)`,
|
|
15
|
-
//
|
|
16
|
-
"& > :not(:first-child)
|
|
17
|
-
|
|
13
|
+
// To remove the top border of the navigation section
|
|
14
|
+
"& > :not(:first-child)": {
|
|
15
|
+
borderTop: "none"
|
|
18
16
|
}
|
|
19
17
|
},
|
|
20
18
|
panelCollapsed: {
|
|
21
19
|
width: props.collapsedPanelWidth,
|
|
22
20
|
height: `calc(100vh - ${props.topPosition}px)`,
|
|
23
|
-
//
|
|
21
|
+
// Customize the navigation section
|
|
24
22
|
"& > :not(:first-child)": {
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
marginLeft: 0
|
|
28
|
-
}
|
|
23
|
+
borderTop: "none",
|
|
24
|
+
padding: theme.hvSpacing("xs", "xs", "sm", "xs")
|
|
29
25
|
},
|
|
30
|
-
//
|
|
26
|
+
// Customize the collapse / expand
|
|
31
27
|
"& > :first-child:not(:last-child)": {
|
|
32
28
|
padding: theme.hvSpacing("sm", "xs", "xs", "xs")
|
|
33
29
|
},
|
|
@@ -35,22 +31,9 @@ const styles = props => makeStyles(theme => ({
|
|
|
35
31
|
marginLeft: "6px"
|
|
36
32
|
}
|
|
37
33
|
},
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
justifyContent: "flex-start"
|
|
42
|
-
}
|
|
43
|
-
}),
|
|
44
|
-
expandButton: {
|
|
45
|
-
width: "100%",
|
|
46
|
-
minWidth: "unset",
|
|
47
|
-
"& > span > span": {
|
|
48
|
-
marginLeft: "unset"
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
collapseTextContainer: {
|
|
52
|
-
width: "100%",
|
|
53
|
-
textAlign: "left"
|
|
34
|
+
toggleCollapsePanel: {
|
|
35
|
+
display: "flex",
|
|
36
|
+
justifyContent: "flex-end"
|
|
54
37
|
}
|
|
55
38
|
}));
|
|
56
39
|
export default styles;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","names":["makeStyles","styles","props","theme","panel","position","top","topPosition","left","zIndex","panelExpanded","width","expandedPanelWidth","height","
|
|
1
|
+
{"version":3,"file":"styles.js","names":["makeStyles","styles","props","theme","panel","justifyContent","position","top","topPosition","left","zIndex","panelExpanded","width","expandedPanelWidth","height","borderTop","panelCollapsed","collapsedPanelWidth","padding","hvSpacing","marginLeft","toggleCollapsePanel","display"],"sources":["../../../src/VerticalNavigation/styles.js"],"sourcesContent":["import { makeStyles } from \"@mui/styles\";\n\nconst styles = (props) =>\n makeStyles((theme) => ({\n panel: {\n justifyContent: \"flex-start\",\n position: props.position,\n top: props.topPosition,\n left: 0,\n zIndex: 1100,\n },\n panelExpanded: {\n width: props.expandedPanelWidth,\n height: `calc(100vh - ${props.topPosition}px)`,\n\n // To remove the top border of the navigation section\n \"& > :not(:first-child)\": {\n borderTop: \"none\",\n },\n },\n panelCollapsed: {\n width: props.collapsedPanelWidth,\n height: `calc(100vh - ${props.topPosition}px)`,\n\n // Customize the navigation section\n \"& > :not(:first-child)\": {\n borderTop: \"none\",\n padding: theme.hvSpacing(\"xs\", \"xs\", \"sm\", \"xs\"),\n },\n\n // Customize the collapse / expand\n \"& > :first-child:not(:last-child)\": {\n padding: theme.hvSpacing(\"sm\", \"xs\", \"xs\", \"xs\"),\n },\n\n \"& > nav > ul > li > div > div\": {\n marginLeft: \"6px\",\n },\n },\n\n toggleCollapsePanel: {\n display: \"flex\",\n justifyContent: \"flex-end\",\n },\n }));\n\nexport default styles;\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,aAAa;AAExC,MAAMC,MAAM,GAAIC,KAAK,IACnBF,UAAU,CAAEG,KAAK,KAAM;EACrBC,KAAK,EAAE;IACLC,cAAc,EAAE,YAAY;IAC5BC,QAAQ,EAAEJ,KAAK,CAACI,QAAQ;IACxBC,GAAG,EAAEL,KAAK,CAACM,WAAW;IACtBC,IAAI,EAAE,CAAC;IACPC,MAAM,EAAE;EACV,CAAC;EACDC,aAAa,EAAE;IACbC,KAAK,EAAEV,KAAK,CAACW,kBAAkB;IAC/BC,MAAM,EAAG,gBAAeZ,KAAK,CAACM,WAAY,KAAI;IAE9C;IACA,wBAAwB,EAAE;MACxBO,SAAS,EAAE;IACb;EACF,CAAC;EACDC,cAAc,EAAE;IACdJ,KAAK,EAAEV,KAAK,CAACe,mBAAmB;IAChCH,MAAM,EAAG,gBAAeZ,KAAK,CAACM,WAAY,KAAI;IAE9C;IACA,wBAAwB,EAAE;MACxBO,SAAS,EAAE,MAAM;MACjBG,OAAO,EAAEf,KAAK,CAACgB,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IACjD,CAAC;IAED;IACA,mCAAmC,EAAE;MACnCD,OAAO,EAAEf,KAAK,CAACgB,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IACjD,CAAC;IAED,+BAA+B,EAAE;MAC/BC,UAAU,EAAE;IACd;EACF,CAAC;EAEDC,mBAAmB,EAAE;IACnBC,OAAO,EAAE,MAAM;IACfjB,cAAc,EAAE;EAClB;AACF,CAAC,CAAC,CAAC;AAEL,eAAeJ,MAAM"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Receives the navigation data and the id of the item from which we want to get the root parent.
|
|
3
|
+
*
|
|
4
|
+
* @param {NavigationItem[]} data - The navigation data structure.
|
|
5
|
+
* @param {string} itemId - The item id.
|
|
6
|
+
* @returns The item that is the root parent of the received item.
|
|
7
|
+
*/
|
|
8
|
+
const findRootParentById = (data, itemId) => {
|
|
9
|
+
return data.reduce((parent, item) => {
|
|
10
|
+
if (parent) {
|
|
11
|
+
return parent;
|
|
12
|
+
}
|
|
13
|
+
if (item.id === itemId) {
|
|
14
|
+
return item;
|
|
15
|
+
}
|
|
16
|
+
if (item.data) {
|
|
17
|
+
const found = findRootParentById(item.data, itemId);
|
|
18
|
+
if (found) {
|
|
19
|
+
return item;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
}, null);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Returns the complete item object from the data structure using the item id.
|
|
28
|
+
*
|
|
29
|
+
* @param {NavigationItem[]} data - The navigation data structure.
|
|
30
|
+
* @param {string} itemId - The item id.
|
|
31
|
+
* @returns The complete item object matching the received id.
|
|
32
|
+
*/
|
|
33
|
+
const findItemById = (data, itemId) => {
|
|
34
|
+
return data.find(item => {
|
|
35
|
+
if (item.id === itemId) {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
if (item.data && item.data.length > 0) {
|
|
39
|
+
const foundItem = findItemById(item.data, itemId);
|
|
40
|
+
if (foundItem) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return false;
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Returns all the items that have chilren associated.
|
|
50
|
+
*
|
|
51
|
+
* @param {NavigationItem[]} data - The navigation data structure.
|
|
52
|
+
* @returns All the items that have chilren associated.
|
|
53
|
+
*/
|
|
54
|
+
const getAllParents = items => {
|
|
55
|
+
const parents = items.filter(item => item.data != null && item.data.length > 0);
|
|
56
|
+
const childParents = parents.flatMap(item => getAllParents(item.data));
|
|
57
|
+
return [...parents, ...childParents];
|
|
58
|
+
};
|
|
59
|
+
export { findRootParentById, findItemById, getAllParents };
|
|
60
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","names":["findRootParentById","data","itemId","reduce","parent","item","id","found","findItemById","find","length","foundItem","getAllParents","items","parents","filter","childParents","flatMap"],"sources":["../../../src/VerticalNavigation/utils.js"],"sourcesContent":["/**\n * Receives the navigation data and the id of the item from which we want to get the root parent.\n *\n * @param {NavigationItem[]} data - The navigation data structure.\n * @param {string} itemId - The item id.\n * @returns The item that is the root parent of the received item.\n */\nconst findRootParentById = (data, itemId) => {\n return data.reduce((parent, item) => {\n if (parent) {\n return parent;\n }\n\n if (item.id === itemId) {\n return item;\n }\n\n if (item.data) {\n const found = findRootParentById(item.data, itemId);\n if (found) {\n return item;\n }\n }\n return null;\n }, null);\n};\n\n/**\n * Returns the complete item object from the data structure using the item id.\n *\n * @param {NavigationItem[]} data - The navigation data structure.\n * @param {string} itemId - The item id.\n * @returns The complete item object matching the received id.\n */\nconst findItemById = (data, itemId) => {\n return data.find((item) => {\n if (item.id === itemId) {\n return true;\n }\n\n if (item.data && item.data.length > 0) {\n const foundItem = findItemById(item.data, itemId);\n if (foundItem) {\n return true;\n }\n }\n return false;\n });\n};\n\n/**\n * Returns all the items that have chilren associated.\n *\n * @param {NavigationItem[]} data - The navigation data structure.\n * @returns All the items that have chilren associated.\n */\nconst getAllParents = (items) => {\n const parents = items.filter((item) => item.data != null && item.data.length > 0);\n const childParents = parents.flatMap((item) => getAllParents(item.data));\n\n return [...parents, ...childParents];\n};\n\nexport { findRootParentById, findItemById, getAllParents };\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,kBAAkB,GAAG,CAACC,IAAI,EAAEC,MAAM,KAAK;EAC3C,OAAOD,IAAI,CAACE,MAAM,CAAC,CAACC,MAAM,EAAEC,IAAI,KAAK;IACnC,IAAID,MAAM,EAAE;MACV,OAAOA,MAAM;IACf;IAEA,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json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hitachivantara/uikit-react-lab",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"description": "A collection of contributed React components for the Hitachi Vantara's Design System.",
|
|
5
5
|
"homepage": "https://github.com/lumada-design/hv-uikit-react",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"react-dom": "^16.13.1 || ^17.0.2"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@hitachivantara/uikit-react-core": "^4.4.
|
|
48
|
-
"@hitachivantara/uikit-react-icons": "^4.0.
|
|
47
|
+
"@hitachivantara/uikit-react-core": "^4.4.3",
|
|
48
|
+
"@hitachivantara/uikit-react-icons": "^4.0.6",
|
|
49
49
|
"clsx": "^1.2.1",
|
|
50
50
|
"core-js": "^3.26.1",
|
|
51
51
|
"dayjs": "^1.11.4",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"publishConfig": {
|
|
65
65
|
"access": "public"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "1306e807ca35c09ab5d243cb10a3c8aae600d6fe"
|
|
68
68
|
}
|