@hitachivantara/uikit-react-lab 4.3.3 → 4.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.
Files changed (97) hide show
  1. package/dist/NavigationSlider/Header/Header.js +79 -0
  2. package/dist/NavigationSlider/Header/Header.js.map +1 -0
  3. package/dist/NavigationSlider/Header/index.js +14 -0
  4. package/dist/NavigationSlider/Header/index.js.map +1 -0
  5. package/dist/NavigationSlider/Header/styles.js +36 -0
  6. package/dist/NavigationSlider/Header/styles.js.map +1 -0
  7. package/dist/NavigationSlider/Navigation/Navigation.js +102 -0
  8. package/dist/NavigationSlider/Navigation/Navigation.js.map +1 -0
  9. package/dist/NavigationSlider/Navigation/index.js +14 -0
  10. package/dist/NavigationSlider/Navigation/index.js.map +1 -0
  11. package/dist/NavigationSlider/Navigation/styles.js +30 -0
  12. package/dist/NavigationSlider/Navigation/styles.js.map +1 -0
  13. package/dist/NavigationSlider/NavigationSlider.d.ts +30 -0
  14. package/dist/NavigationSlider/NavigationSlider.js +139 -0
  15. package/dist/NavigationSlider/NavigationSlider.js.map +1 -0
  16. package/dist/NavigationSlider/index.d.ts +2 -0
  17. package/dist/NavigationSlider/index.js +14 -0
  18. package/dist/NavigationSlider/index.js.map +1 -0
  19. package/dist/NavigationSlider/styles.js +29 -0
  20. package/dist/NavigationSlider/styles.js.map +1 -0
  21. package/dist/NavigationSlider/utils.js +87 -0
  22. package/dist/NavigationSlider/utils.js.map +1 -0
  23. package/dist/VerticalNavigation/VerticalNavigation.d.ts +12 -8
  24. package/dist/VerticalNavigation/VerticalNavigation.js +71 -41
  25. package/dist/VerticalNavigation/VerticalNavigation.js.map +1 -1
  26. package/dist/VerticalNavigation/styles.js +11 -36
  27. package/dist/VerticalNavigation/styles.js.map +1 -1
  28. package/dist/VerticalNavigation/utils.js +88 -0
  29. package/dist/VerticalNavigation/utils.js.map +1 -0
  30. package/dist/index.d.ts +3 -0
  31. package/dist/index.js +9 -1
  32. package/dist/index.js.map +1 -1
  33. package/dist/legacy/NavigationSlider/Header/Header.js +72 -0
  34. package/dist/legacy/NavigationSlider/Header/Header.js.map +1 -0
  35. package/dist/legacy/NavigationSlider/Header/index.js +2 -0
  36. package/dist/legacy/NavigationSlider/Header/index.js.map +1 -0
  37. package/dist/legacy/NavigationSlider/Header/styles.js +29 -0
  38. package/dist/legacy/NavigationSlider/Header/styles.js.map +1 -0
  39. package/dist/legacy/NavigationSlider/Navigation/Navigation.js +94 -0
  40. package/dist/legacy/NavigationSlider/Navigation/Navigation.js.map +1 -0
  41. package/dist/legacy/NavigationSlider/Navigation/index.js +2 -0
  42. package/dist/legacy/NavigationSlider/Navigation/index.js.map +1 -0
  43. package/dist/legacy/NavigationSlider/Navigation/styles.js +23 -0
  44. package/dist/legacy/NavigationSlider/Navigation/styles.js.map +1 -0
  45. package/dist/legacy/NavigationSlider/NavigationSlider.d.ts +30 -0
  46. package/dist/legacy/NavigationSlider/NavigationSlider.js +123 -0
  47. package/dist/legacy/NavigationSlider/NavigationSlider.js.map +1 -0
  48. package/dist/legacy/NavigationSlider/index.d.ts +2 -0
  49. package/dist/legacy/NavigationSlider/index.js +2 -0
  50. package/dist/legacy/NavigationSlider/index.js.map +1 -0
  51. package/dist/legacy/NavigationSlider/styles.js +22 -0
  52. package/dist/legacy/NavigationSlider/styles.js.map +1 -0
  53. package/dist/legacy/NavigationSlider/utils.js +78 -0
  54. package/dist/legacy/NavigationSlider/utils.js.map +1 -0
  55. package/dist/legacy/VerticalNavigation/VerticalNavigation.d.ts +12 -8
  56. package/dist/legacy/VerticalNavigation/VerticalNavigation.js +72 -40
  57. package/dist/legacy/VerticalNavigation/VerticalNavigation.js.map +1 -1
  58. package/dist/legacy/VerticalNavigation/styles.js +11 -35
  59. package/dist/legacy/VerticalNavigation/styles.js.map +1 -1
  60. package/dist/legacy/VerticalNavigation/utils.js +79 -0
  61. package/dist/legacy/VerticalNavigation/utils.js.map +1 -0
  62. package/dist/legacy/index.d.ts +3 -0
  63. package/dist/legacy/index.js +1 -0
  64. package/dist/legacy/index.js.map +1 -1
  65. package/dist/modern/NavigationSlider/Header/Header.js +72 -0
  66. package/dist/modern/NavigationSlider/Header/Header.js.map +1 -0
  67. package/dist/modern/NavigationSlider/Header/index.js +2 -0
  68. package/dist/modern/NavigationSlider/Header/index.js.map +1 -0
  69. package/dist/modern/NavigationSlider/Header/styles.js +25 -0
  70. package/dist/modern/NavigationSlider/Header/styles.js.map +1 -0
  71. package/dist/modern/NavigationSlider/Navigation/Navigation.js +88 -0
  72. package/dist/modern/NavigationSlider/Navigation/Navigation.js.map +1 -0
  73. package/dist/modern/NavigationSlider/Navigation/index.js +2 -0
  74. package/dist/modern/NavigationSlider/Navigation/index.js.map +1 -0
  75. package/dist/modern/NavigationSlider/Navigation/styles.js +21 -0
  76. package/dist/modern/NavigationSlider/Navigation/styles.js.map +1 -0
  77. package/dist/modern/NavigationSlider/NavigationSlider.d.ts +30 -0
  78. package/dist/modern/NavigationSlider/NavigationSlider.js +116 -0
  79. package/dist/modern/NavigationSlider/NavigationSlider.js.map +1 -0
  80. package/dist/modern/NavigationSlider/index.d.ts +2 -0
  81. package/dist/modern/NavigationSlider/index.js +2 -0
  82. package/dist/modern/NavigationSlider/index.js.map +1 -0
  83. package/dist/modern/NavigationSlider/styles.js +18 -0
  84. package/dist/modern/NavigationSlider/styles.js.map +1 -0
  85. package/dist/modern/NavigationSlider/utils.js +70 -0
  86. package/dist/modern/NavigationSlider/utils.js.map +1 -0
  87. package/dist/modern/VerticalNavigation/VerticalNavigation.d.ts +12 -8
  88. package/dist/modern/VerticalNavigation/VerticalNavigation.js +68 -43
  89. package/dist/modern/VerticalNavigation/VerticalNavigation.js.map +1 -1
  90. package/dist/modern/VerticalNavigation/styles.js +11 -28
  91. package/dist/modern/VerticalNavigation/styles.js.map +1 -1
  92. package/dist/modern/VerticalNavigation/utils.js +76 -0
  93. package/dist/modern/VerticalNavigation/utils.js.map +1 -0
  94. package/dist/modern/index.d.ts +3 -0
  95. package/dist/modern/index.js +1 -0
  96. package/dist/modern/index.js.map +1 -1
  97. package/package.json +4 -4
@@ -0,0 +1,88 @@
1
+ var _DropRightXS, _div;
2
+ import React from "react";
3
+ import { withStyles } from "@mui/styles";
4
+ import PropTypes from "prop-types";
5
+ import { HvListContainer, HvListItem, HvButton } from "@hitachivantara/uikit-react-core";
6
+ import { DropRightXS } from "@hitachivantara/uikit-react-icons";
7
+ import styles from "./styles";
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ const Navigation = ({
10
+ id,
11
+ classes,
12
+ data,
13
+ selected,
14
+ onNavigateToTarget,
15
+ onNavigateToChild
16
+ }) => {
17
+ return /*#__PURE__*/_jsx(HvListContainer, {
18
+ interactive: true,
19
+ id: id,
20
+ children: data.map(item => /*#__PURE__*/_jsx(HvListItem, {
21
+ classes: {
22
+ root: classes.listItemRoot,
23
+ selected: classes.listItemSelected
24
+ },
25
+ onClick: event => onNavigateToTarget(event, item),
26
+ selected: selected === item.id,
27
+ startAdornment: item.icon,
28
+ endAdornment: item.data && item.data.length > 0 ? /*#__PURE__*/_jsx(HvButton, {
29
+ icon: true,
30
+ onClick: event => onNavigateToChild(event, item),
31
+ children: _DropRightXS || (_DropRightXS = /*#__PURE__*/_jsx(DropRightXS, {}))
32
+ }) : _div || (_div = /*#__PURE__*/_jsx("div", {})),
33
+ children: /*#__PURE__*/_jsx("span", {
34
+ children: item.label
35
+ })
36
+ }, item.id))
37
+ });
38
+ };
39
+ process.env.NODE_ENV !== "production" ? Navigation.propTypes = {
40
+ /**
41
+ * Id to be applied to the root node of the panel.
42
+ */
43
+ id: PropTypes.string,
44
+ /**
45
+ * A Jss Object used to override or extend the styles applied.
46
+ */
47
+ classes: PropTypes.shape({
48
+ /**
49
+ * styles object applied to the root
50
+ */
51
+ listItemRoot: PropTypes.string,
52
+ listItemSelected: PropTypes.string
53
+ }).isRequired,
54
+ /**
55
+ * An array containing the data for each menu item.
56
+ *
57
+ * id - the id to be applied to the root element.
58
+ * label - the label to be rendered on the menu item.
59
+ * icon - the icon react element
60
+ * data - sub-menu items
61
+ * href - the url used for navigation.
62
+ * target - the behavior when opening an url.
63
+ */
64
+ data: PropTypes.arrayOf(PropTypes.shape({
65
+ id: PropTypes.string.isRequired,
66
+ label: PropTypes.string.isRequired,
67
+ icon: PropTypes.node,
68
+ data: PropTypes.array,
69
+ href: PropTypes.string,
70
+ target: PropTypes.string
71
+ })).isRequired,
72
+ /**
73
+ * The selected item id.
74
+ */
75
+ selected: PropTypes.string,
76
+ /**
77
+ * Triggered when the item is clicked.
78
+ */
79
+ onNavigateToTarget: PropTypes.func,
80
+ /**
81
+ * Triggered when the navigate to child button is clicked.
82
+ */
83
+ onNavigateToChild: PropTypes.func
84
+ } : void 0;
85
+ export default withStyles(styles, {
86
+ name: "Navigation"
87
+ })(Navigation);
88
+ //# sourceMappingURL=Navigation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Navigation.js","names":["React","withStyles","PropTypes","HvListContainer","HvListItem","HvButton","DropRightXS","styles","Navigation","id","classes","data","selected","onNavigateToTarget","onNavigateToChild","map","item","root","listItemRoot","listItemSelected","event","icon","length","label","propTypes","string","shape","isRequired","arrayOf","node","array","href","target","func","name"],"sources":["../../../../src/NavigationSlider/Navigation/Navigation.js"],"sourcesContent":["import React from \"react\";\nimport { withStyles } from \"@mui/styles\";\nimport PropTypes from \"prop-types\";\n\nimport { HvListContainer, HvListItem, HvButton } from \"@hitachivantara/uikit-react-core\";\nimport { DropRightXS } from \"@hitachivantara/uikit-react-icons\";\n\nimport styles from \"./styles\";\n\nconst Navigation = ({ id, classes, data, selected, onNavigateToTarget, onNavigateToChild }) => {\n return (\n <HvListContainer interactive id={id}>\n {data.map((item) => (\n <HvListItem\n key={item.id}\n classes={{\n root: classes.listItemRoot,\n selected: classes.listItemSelected,\n }}\n onClick={(event) => onNavigateToTarget(event, item)}\n selected={selected === item.id}\n startAdornment={item.icon}\n endAdornment={\n item.data && item.data.length > 0 ? (\n <HvButton icon onClick={(event) => onNavigateToChild(event, item)}>\n <DropRightXS />\n </HvButton>\n ) : (\n <div />\n )\n }\n >\n <span>{item.label}</span>\n </HvListItem>\n ))}\n </HvListContainer>\n );\n};\n\nNavigation.propTypes = {\n /**\n * Id to be applied to the root node of the panel.\n */\n id: PropTypes.string,\n /**\n * A Jss Object used to override or extend the styles applied.\n */\n classes: PropTypes.shape({\n /**\n * styles object applied to the root\n */\n listItemRoot: PropTypes.string,\n listItemSelected: PropTypes.string,\n }).isRequired,\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 react element\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 selected item id.\n */\n selected: PropTypes.string,\n /**\n * Triggered when the item is clicked.\n */\n onNavigateToTarget: PropTypes.func,\n /**\n * Triggered when the navigate to child button is clicked.\n */\n onNavigateToChild: PropTypes.func,\n};\n\nexport default withStyles(styles, { name: \"Navigation\" })(Navigation);\n"],"mappings":";AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,UAAU,QAAQ,aAAa;AACxC,OAAOC,SAAS,MAAM,YAAY;AAElC,SAASC,eAAe,EAAEC,UAAU,EAAEC,QAAQ,QAAQ,kCAAkC;AACxF,SAASC,WAAW,QAAQ,mCAAmC;AAE/D,OAAOC,MAAM,MAAM,UAAU;AAAC;AAE9B,MAAMC,UAAU,GAAG,CAAC;EAAEC,EAAE;EAAEC,OAAO;EAAEC,IAAI;EAAEC,QAAQ;EAAEC,kBAAkB;EAAEC;AAAkB,CAAC,KAAK;EAC7F,oBACE,KAAC,eAAe;IAAC,WAAW;IAAC,EAAE,EAAEL,EAAG;IAAA,UAC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;IACpBlB,IAAI,EAAET,SAAS,CAAC4B,KAAK;IACrBC,IAAI,EAAE7B,SAAS,CAACuB,MAAM;IACtBO,MAAM,EAAE9B,SAAS,CAACuB;EACpB,CAAC,CAAC,CACH,CAACE,UAAU;EACZ;AACF;AACA;EACEf,QAAQ,EAAEV,SAAS,CAACuB,MAAM;EAC1B;AACF;AACA;EACEZ,kBAAkB,EAAEX,SAAS,CAAC+B,IAAI;EAClC;AACF;AACA;EACEnB,iBAAiB,EAAEZ,SAAS,CAAC+B;AAC/B,CAAC;AAED,eAAehC,UAAU,CAACM,MAAM,EAAE;EAAE2B,IAAI,EAAE;AAAa,CAAC,CAAC,CAAC1B,UAAU,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { default } from "./Navigation";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["default"],"sources":["../../../../src/NavigationSlider/Navigation/index.js"],"sourcesContent":["export { default } from \"./Navigation\";\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,cAAc"}
@@ -0,0 +1,21 @@
1
+ const styles = theme => ({
2
+ listItemRoot: {
3
+ display: "flex",
4
+ alignItems: "center",
5
+ borderLeft: `2px solid transparent`,
6
+ minHeight: "52px",
7
+ marginBottom: "8px",
8
+ "& > button": {
9
+ marginLeft: "auto"
10
+ }
11
+ },
12
+ listItemSelected: {
13
+ background: theme.hv.palette.atmosphere.atmo3,
14
+ borderLeft: `2px solid ${theme.hv.palette.accent.acce3}`,
15
+ "& *": {
16
+ background: theme.hv.palette.atmosphere.atmo3
17
+ }
18
+ }
19
+ });
20
+ export default styles;
21
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.js","names":["styles","theme","listItemRoot","display","alignItems","borderLeft","minHeight","marginBottom","marginLeft","listItemSelected","background","hv","palette","atmosphere","atmo3","accent","acce3"],"sources":["../../../../src/NavigationSlider/Navigation/styles.js"],"sourcesContent":["const styles = (theme) => ({\n listItemRoot: {\n display: \"flex\",\n alignItems: \"center\",\n borderLeft: `2px solid transparent`,\n minHeight: \"52px\",\n marginBottom: \"8px\",\n \"& > button\": {\n marginLeft: \"auto\",\n },\n },\n listItemSelected: {\n background: theme.hv.palette.atmosphere.atmo3,\n borderLeft: `2px solid ${theme.hv.palette.accent.acce3}`,\n \"& *\": {\n background: theme.hv.palette.atmosphere.atmo3,\n },\n },\n});\n\nexport default styles;\n"],"mappings":"AAAA,MAAMA,MAAM,GAAIC,KAAK,KAAM;EACzBC,YAAY,EAAE;IACZC,OAAO,EAAE,MAAM;IACfC,UAAU,EAAE,QAAQ;IACpBC,UAAU,EAAG,uBAAsB;IACnCC,SAAS,EAAE,MAAM;IACjBC,YAAY,EAAE,KAAK;IACnB,YAAY,EAAE;MACZC,UAAU,EAAE;IACd;EACF,CAAC;EACDC,gBAAgB,EAAE;IAChBC,UAAU,EAAET,KAAK,CAACU,EAAE,CAACC,OAAO,CAACC,UAAU,CAACC,KAAK;IAC7CT,UAAU,EAAG,aAAYJ,KAAK,CAACU,EAAE,CAACC,OAAO,CAACG,MAAM,CAACC,KAAM,EAAC;IACxD,KAAK,EAAE;MACLN,UAAU,EAAET,KAAK,CAACU,EAAE,CAACC,OAAO,CAACC,UAAU,CAACC;IAC1C;EACF;AACF,CAAC,CAAC;AAEF,eAAed,MAAM"}
@@ -0,0 +1,30 @@
1
+ import { NavigationData } from "@hitachivantara/uikit-react-core";
2
+
3
+ export interface HvVerticalNavigationProps {
4
+ /**
5
+ * Id to be applied to the root node of the panel.
6
+ */
7
+ id?: string;
8
+ /**
9
+ * Called when a menu item is clicked.
10
+ */
11
+ onNavigationChange?: Function;
12
+ /**
13
+ * An array containing the data for each menu item.
14
+ */
15
+ data: NavigationData[];
16
+ /**
17
+ * The ID of the selected page.
18
+ */
19
+ selected?: string;
20
+ /**
21
+ * The top value where the panel will be rendered. Default is 44 as it is the height of the Header component.
22
+ */
23
+ topPosition?: number;
24
+ /**
25
+ * The width of the panel. Default value is 300.
26
+ */
27
+ panelWidth?: number;
28
+ }
29
+
30
+ export default function HvVerticalNavigation(props: HvVerticalNavigationProps): JSX.Element | null;
@@ -0,0 +1,116 @@
1
+ import React, { useState, useMemo } from "react";
2
+ import { withStyles } from "@mui/styles";
3
+ import PropTypes from "prop-types";
4
+ import { HvVerticalNavigation as HvVerticalNavigationCore } from "@hitachivantara/uikit-react-core";
5
+ import Header from "./Header";
6
+ import Navigation from "./Navigation";
7
+ import { fillDataWithParentId, getNavigationItemById, getParentItemById } from "./utils";
8
+ import useStyles from "./styles";
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ import { jsxs as _jsxs } from "react/jsx-runtime";
11
+ const HvNavigationSlider = ({
12
+ id,
13
+ onNavigationChange,
14
+ data,
15
+ title,
16
+ selected,
17
+ topPosition,
18
+ panelWidth
19
+ }) => {
20
+ const classes = useStyles({
21
+ topPosition,
22
+ panelWidth
23
+ })();
24
+ const withParentData = useMemo(() => fillDataWithParentId(data), [data]);
25
+ const initialParentItem = useMemo(() => getParentItemById(withParentData, selected), [withParentData, selected]);
26
+ const [parentItem, setParentItem] = useState(initialParentItem);
27
+ const navigateToParentHandler = () => {
28
+ setParentItem(getParentItemById(withParentData, parentItem.id));
29
+ };
30
+ const navigateToTargetHandler = (event, selectedItem) => {
31
+ onNavigationChange(event, selectedItem);
32
+ };
33
+ const navigateToChildHandler = (event, item) => {
34
+ setParentItem(getNavigationItemById(withParentData, item.id));
35
+ event.stopPropagation();
36
+ };
37
+ return /*#__PURE__*/_jsx("div", {
38
+ id: id,
39
+ className: classes.container,
40
+ children: /*#__PURE__*/_jsxs(HvVerticalNavigationCore, {
41
+ className: classes.root,
42
+ children: [/*#__PURE__*/_jsx(Header, {
43
+ onBackButtonClick: navigateToParentHandler,
44
+ showBackButton: !!(parentItem !== null && parentItem !== void 0 && parentItem.label),
45
+ title: (parentItem === null || parentItem === void 0 ? void 0 : parentItem.label) || title
46
+ }), /*#__PURE__*/_jsx(Navigation, {
47
+ data: parentItem.data || withParentData,
48
+ selected: selected,
49
+ onNavigateToTarget: navigateToTargetHandler,
50
+ onNavigateToChild: navigateToChildHandler
51
+ })]
52
+ })
53
+ });
54
+ };
55
+ process.env.NODE_ENV !== "production" ? HvNavigationSlider.propTypes = {
56
+ /**
57
+ * Id to be applied to the root node of the panel.
58
+ */
59
+ id: PropTypes.string,
60
+ /**
61
+ * A Jss Object used to override or extend the styles applied.
62
+ */
63
+ classes: PropTypes.shape({
64
+ /**
65
+ * styles object applied to the root
66
+ */
67
+ container: PropTypes.string,
68
+ root: PropTypes.string,
69
+ footer: PropTypes.string
70
+ }).isRequired,
71
+ /**
72
+ * Called when a menu item is clicked.
73
+ */
74
+ onNavigationChange: PropTypes.func,
75
+ /**
76
+ * An array containing the data for each menu item.
77
+ *
78
+ * id - the id to be applied to the root element.
79
+ * label - the label to be rendered on the menu item.
80
+ * data - sub-menu items
81
+ * href - the url used for navigation.
82
+ * target - the behavior when opening an url.
83
+ */
84
+ data: PropTypes.arrayOf(PropTypes.shape({
85
+ id: PropTypes.string.isRequired,
86
+ label: PropTypes.string.isRequired,
87
+ icon: PropTypes.node,
88
+ data: PropTypes.array,
89
+ href: PropTypes.string,
90
+ target: PropTypes.string
91
+ })).isRequired,
92
+ /**
93
+ * The text to be displayed when at the root of the structure.
94
+ */
95
+ title: PropTypes.string,
96
+ /**
97
+ * The ID of the selected page.
98
+ */
99
+ selected: PropTypes.string,
100
+ /**
101
+ * The top value where the panel will be rendered. Default is 44 as it is the height of the Header component.
102
+ */
103
+ topPosition: PropTypes.number,
104
+ /**
105
+ * The width of the panel when expanded. Default value is 300.
106
+ */
107
+ panelWidth: PropTypes.number
108
+ } : void 0;
109
+ HvNavigationSlider.defaultProps = {
110
+ topPosition: 44,
111
+ panelWidth: 300
112
+ };
113
+ export default withStyles(useStyles, {
114
+ name: "HvNavigationSlider"
115
+ })(HvNavigationSlider);
116
+ //# sourceMappingURL=NavigationSlider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NavigationSlider.js","names":["React","useState","useMemo","withStyles","PropTypes","HvVerticalNavigation","HvVerticalNavigationCore","Header","Navigation","fillDataWithParentId","getNavigationItemById","getParentItemById","useStyles","HvNavigationSlider","id","onNavigationChange","data","title","selected","topPosition","panelWidth","classes","withParentData","initialParentItem","parentItem","setParentItem","navigateToParentHandler","navigateToTargetHandler","event","selectedItem","navigateToChildHandler","item","stopPropagation","container","root","label","propTypes","string","shape","footer","isRequired","func","arrayOf","icon","node","array","href","target","number","defaultProps","name"],"sources":["../../../src/NavigationSlider/NavigationSlider.js"],"sourcesContent":["import React, { useState, useMemo } from \"react\";\nimport { withStyles } from \"@mui/styles\";\nimport PropTypes from \"prop-types\";\n\nimport { HvVerticalNavigation as HvVerticalNavigationCore } from \"@hitachivantara/uikit-react-core\";\n\nimport Header from \"./Header\";\nimport Navigation from \"./Navigation\";\nimport { fillDataWithParentId, getNavigationItemById, getParentItemById } from \"./utils\";\n\nimport useStyles from \"./styles\";\n\nconst HvNavigationSlider = ({\n id,\n onNavigationChange,\n data,\n title,\n selected,\n topPosition,\n panelWidth,\n}) => {\n const classes = useStyles({ topPosition, panelWidth })();\n\n const withParentData = useMemo(() => fillDataWithParentId(data), [data]);\n\n const initialParentItem = useMemo(\n () => getParentItemById(withParentData, selected),\n [withParentData, selected]\n );\n\n const [parentItem, setParentItem] = useState(initialParentItem);\n\n const navigateToParentHandler = () => {\n setParentItem(getParentItemById(withParentData, parentItem.id));\n };\n\n const navigateToTargetHandler = (event, selectedItem) => {\n onNavigationChange(event, selectedItem);\n };\n\n const navigateToChildHandler = (event, item) => {\n setParentItem(getNavigationItemById(withParentData, item.id));\n\n event.stopPropagation();\n };\n\n return (\n <div id={id} className={classes.container}>\n <HvVerticalNavigationCore className={classes.root}>\n <Header\n onBackButtonClick={navigateToParentHandler}\n showBackButton={!!parentItem?.label}\n title={parentItem?.label || title}\n />\n\n <Navigation\n data={parentItem.data || withParentData}\n selected={selected}\n onNavigateToTarget={navigateToTargetHandler}\n onNavigateToChild={navigateToChildHandler}\n />\n </HvVerticalNavigationCore>\n </div>\n );\n};\n\nHvNavigationSlider.propTypes = {\n /**\n * Id to be applied to the root node of the panel.\n */\n id: PropTypes.string,\n /**\n * A Jss Object used to override or extend the styles applied.\n */\n classes: PropTypes.shape({\n /**\n * styles object applied to the root\n */\n container: PropTypes.string,\n root: PropTypes.string,\n footer: PropTypes.string,\n }).isRequired,\n /**\n * Called when a menu item is clicked.\n */\n onNavigationChange: 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 * 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 text to be displayed when at the root of the structure.\n */\n title: PropTypes.string,\n /**\n * The ID of the selected page.\n */\n selected: PropTypes.string,\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 panelWidth: PropTypes.number,\n};\n\nHvNavigationSlider.defaultProps = {\n topPosition: 44,\n panelWidth: 300,\n};\n\nexport default withStyles(useStyles, { name: \"HvNavigationSlider\" })(HvNavigationSlider);\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,OAAO,QAAQ,OAAO;AAChD,SAASC,UAAU,QAAQ,aAAa;AACxC,OAAOC,SAAS,MAAM,YAAY;AAElC,SAASC,oBAAoB,IAAIC,wBAAwB,QAAQ,kCAAkC;AAEnG,OAAOC,MAAM,MAAM,UAAU;AAC7B,OAAOC,UAAU,MAAM,cAAc;AACrC,SAASC,oBAAoB,EAAEC,qBAAqB,EAAEC,iBAAiB,QAAQ,SAAS;AAExF,OAAOC,SAAS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1B;AACF;AACA;EACElB,WAAW,EAAEf,SAAS,CAAC4C,MAAM;EAC7B;AACF;AACA;EACE5B,UAAU,EAAEhB,SAAS,CAAC4C;AACxB,CAAC;AAEDnC,kBAAkB,CAACoC,YAAY,GAAG;EAChC9B,WAAW,EAAE,EAAE;EACfC,UAAU,EAAE;AACd,CAAC;AAED,eAAejB,UAAU,CAACS,SAAS,EAAE;EAAEsC,IAAI,EAAE;AAAqB,CAAC,CAAC,CAACrC,kBAAkB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { default } from "./NavigationSlider";
2
+ export * from "./NavigationSlider";
@@ -0,0 +1,2 @@
1
+ export { default } from "./NavigationSlider";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["default"],"sources":["../../../src/NavigationSlider/index.js"],"sourcesContent":["export { default } from \"./NavigationSlider\";\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,oBAAoB"}
@@ -0,0 +1,18 @@
1
+ import { makeStyles } from "@mui/styles";
2
+ const styles = props => makeStyles(() => ({
3
+ container: {
4
+ position: "fixed",
5
+ left: 0,
6
+ top: props.topPosition
7
+ },
8
+ root: {
9
+ width: props.panelWidth,
10
+ height: `calc(100vh - ${props.topPosition}px)`,
11
+ justifyContent: "flex-start"
12
+ },
13
+ footer: {
14
+ marginTop: "auto"
15
+ }
16
+ }));
17
+ export default styles;
18
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.js","names":["makeStyles","styles","props","container","position","left","top","topPosition","root","width","panelWidth","height","justifyContent","footer","marginTop"],"sources":["../../../src/NavigationSlider/styles.js"],"sourcesContent":["import { makeStyles } from \"@mui/styles\";\n\nconst styles = (props) =>\n makeStyles(() => ({\n container: {\n position: \"fixed\",\n left: 0,\n top: props.topPosition,\n },\n root: {\n width: props.panelWidth,\n height: `calc(100vh - ${props.topPosition}px)`,\n justifyContent: \"flex-start\",\n },\n footer: {\n marginTop: \"auto\",\n },\n }));\n\nexport default styles;\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,aAAa;AAExC,MAAMC,MAAM,GAAIC,KAAK,IACnBF,UAAU,CAAC,OAAO;EAChBG,SAAS,EAAE;IACTC,QAAQ,EAAE,OAAO;IACjBC,IAAI,EAAE,CAAC;IACPC,GAAG,EAAEJ,KAAK,CAACK;EACb,CAAC;EACDC,IAAI,EAAE;IACJC,KAAK,EAAEP,KAAK,CAACQ,UAAU;IACvBC,MAAM,EAAG,gBAAeT,KAAK,CAACK,WAAY,KAAI;IAC9CK,cAAc,EAAE;EAClB,CAAC;EACDC,MAAM,EAAE;IACNC,SAAS,EAAE;EACb;AACF,CAAC,CAAC,CAAC;AAEL,eAAeb,MAAM"}
@@ -0,0 +1,70 @@
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
+ /**
5
+ * Recursively searches in a collection the first element where the property matches the specified value.
6
+ *
7
+ * @param collection - Collection where the search will be performed
8
+ * @param childrenPropName - The children property name where the recursive search will be performed
9
+ * @param propName - The name of the property to be used on the search
10
+ * @param propValue - The value of the property to be used on the search
11
+ * @returns The element that matches the requirement or null if none is found
12
+ */
13
+ const searchInCollection = (collection, childrenPropName, propName, propValue) => {
14
+ if (collection[propName] === propValue) {
15
+ return collection;
16
+ }
17
+ const items = collection[childrenPropName] || collection;
18
+ let foundItem = null;
19
+ for (let index = 0; foundItem === null && index < items.length; index += 1) {
20
+ foundItem = searchInCollection(items[index], childrenPropName, propName, propValue);
21
+ }
22
+ return foundItem;
23
+ };
24
+
25
+ /**
26
+ * Returns the navigation item with the specified id.
27
+ *
28
+ * @param navigationItems - The collection of navigation items.
29
+ * @param navigationItemId - The id to be used on the search
30
+ * @returns The navigation item with the specified id.
31
+ */
32
+ const getNavigationItemById = (navigationItems, navigationItemId) => {
33
+ return searchInCollection(navigationItems, "data", "id", navigationItemId);
34
+ };
35
+
36
+ /**
37
+ * Returns the parent item for the received item id.
38
+ *
39
+ * @param navigationItems - The collection of navigation items.
40
+ * @param navigationItemId - The id to be used on the search
41
+ * @returns The parent navigation item.
42
+ */
43
+ const getParentItemById = (navigationItems, navigationItemId) => {
44
+ const parentId = getNavigationItemById(navigationItems, navigationItemId).parent;
45
+ return getNavigationItemById(navigationItems, parentId);
46
+ };
47
+
48
+ /**
49
+ * Fills the data structure with the parent id on each one of the nodes.
50
+ *
51
+ * @param navigationItems - The collection of navigation items.
52
+ * @param parentItemId - The parent id to be added.
53
+ * @returns The structure now filled with the parent id.
54
+ */
55
+ const fillDataWithParentId = (navigationItems, parentItemId) => {
56
+ return navigationItems.map(item => {
57
+ var _item$data;
58
+ if ((item === null || item === void 0 ? void 0 : (_item$data = item.data) === null || _item$data === void 0 ? void 0 : _item$data.length) > 0) {
59
+ return _objectSpread(_objectSpread({}, item), {}, {
60
+ parent: parentItemId,
61
+ data: fillDataWithParentId(item.data, item.id)
62
+ });
63
+ }
64
+ return _objectSpread(_objectSpread({}, item), {}, {
65
+ parent: parentItemId
66
+ });
67
+ });
68
+ };
69
+ export { getNavigationItemById, getParentItemById, fillDataWithParentId };
70
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","names":["searchInCollection","collection","childrenPropName","propName","propValue","items","foundItem","index","length","getNavigationItemById","navigationItems","navigationItemId","getParentItemById","parentId","parent","fillDataWithParentId","parentItemId","map","item","data","id"],"sources":["../../../src/NavigationSlider/utils.js"],"sourcesContent":["/**\n * Recursively searches in a collection the first element where the property matches the specified value.\n *\n * @param collection - Collection where the search will be performed\n * @param childrenPropName - The children property name where the recursive search will be performed\n * @param propName - The name of the property to be used on the search\n * @param propValue - The value of the property to be used on the search\n * @returns The element that matches the requirement or null if none is found\n */\nconst searchInCollection = (collection, childrenPropName, propName, propValue) => {\n if (collection[propName] === propValue) {\n return collection;\n }\n\n const items = collection[childrenPropName] || collection;\n\n let foundItem = null;\n for (let index = 0; foundItem === null && index < items.length; index += 1) {\n foundItem = searchInCollection(items[index], childrenPropName, propName, propValue);\n }\n return foundItem;\n};\n\n/**\n * Returns the navigation item with the specified id.\n *\n * @param navigationItems - The collection of navigation items.\n * @param navigationItemId - The id to be used on the search\n * @returns The navigation item with the specified id.\n */\nconst getNavigationItemById = (navigationItems, navigationItemId) => {\n return searchInCollection(navigationItems, \"data\", \"id\", navigationItemId);\n};\n\n/**\n * Returns the parent item for the received item id.\n *\n * @param navigationItems - The collection of navigation items.\n * @param navigationItemId - The id to be used on the search\n * @returns The parent navigation item.\n */\nconst getParentItemById = (navigationItems, navigationItemId) => {\n const parentId = getNavigationItemById(navigationItems, navigationItemId).parent;\n return getNavigationItemById(navigationItems, parentId);\n};\n\n/**\n * Fills the data structure with the parent id on each one of the nodes.\n *\n * @param navigationItems - The collection of navigation items.\n * @param parentItemId - The parent id to be added.\n * @returns The structure now filled with the parent id.\n */\nconst fillDataWithParentId = (navigationItems, parentItemId) => {\n return navigationItems.map((item) => {\n if (item?.data?.length > 0) {\n return { ...item, parent: parentItemId, data: fillDataWithParentId(item.data, item.id) };\n }\n return { ...item, parent: parentItemId };\n });\n};\n\nexport { getNavigationItemById, getParentItemById, fillDataWithParentId };\n"],"mappings":";;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM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U,IAAI;QAAEJ,MAAM,EAAEE,YAAY;QAAEG,IAAI,EAAEJ,oBAAoB,CAACG,IAAI,CAACC,IAAI,EAAED,IAAI,CAACE,EAAE;MAAC;IACxF;IACA,uCAAYF,IAAI;MAAEJ,MAAM,EAAEE;IAAY;EACxC,CAAC,CAAC;AACJ,CAAC;AAED,SAASP,qBAAqB,EAAEG,iBAAiB,EAAEG,oBAAoB"}
@@ -1,26 +1,26 @@
1
1
  import { NavigationData } from "@hitachivantara/uikit-react-core";
2
2
 
3
3
  export interface HvVerticalNavigationProps {
4
- /**
5
- * Id to be applied to the root node of the panel.
6
- */
7
- id?: string;
8
4
  /**
9
5
  * Called when a menu item is clicked.
10
6
  */
11
7
  onNavigationChange?: Function;
12
8
  /**
13
- * An array containing the data for each menu item.
9
+ * Called the collpase / expand button is clicked.
14
10
  */
15
- data: NavigationData[];
11
+ onToggleExpanded?: Function;
16
12
  /**
17
- * Text to be displayed in the collpase area when the panel is expanded.
13
+ * An array containing the data for each menu item.
18
14
  */
19
- collapseLabel?: string;
15
+ data: NavigationData[];
20
16
  /**
21
17
  * The ID of the selected page.
22
18
  */
23
19
  selected?: string;
20
+ /**
21
+ * Flag that sets the panel to expanded / collapsed.
22
+ */
23
+ expanded: boolean;
24
24
  /**
25
25
  * The top value where the panel will be rendered. Default is 44 as it is the height of the Header component.
26
26
  */
@@ -33,6 +33,10 @@ export interface HvVerticalNavigationProps {
33
33
  * The width of the panel when collapsed. Default vlaue is 52.
34
34
  */
35
35
  collapsedPanelWidth?: number;
36
+ /**
37
+ * Sets the Css position of the panel. Default value is `sticked`
38
+ */
39
+ position?: "static" | "relative" | "fixed" | "absolute" | "sticky";
36
40
  }
37
41
 
38
42
  export default function HvVerticalNavigation(props: HvVerticalNavigationProps): JSX.Element | null;
@@ -1,72 +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, HvVerticalNavigationActions, HvButton, setId } from "@hitachivantara/uikit-react-core";
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 { findRootParentById, findItemById, pathToItem } 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
- id,
13
- onNavigationChange,
14
- data,
15
- selected,
16
- collapseLabel,
17
- topPosition,
18
- expandedPanelWidth,
19
- collapsedPanelWidth,
20
- position
21
- }) => {
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);
22
32
  const classes = useStyles({
23
33
  topPosition,
24
34
  expandedPanelWidth,
25
35
  collapsedPanelWidth,
26
36
  position
27
37
  })();
28
- const [isExpanded, setIsExpanded] = useState(true);
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(pathToItem(data, selected));
46
+ const selectedTopParent = (_findRootParentById = findRootParentById(data, selected)) === null || _findRootParentById === void 0 ? void 0 : _findRootParentById.id;
29
47
  const handleVerticalNavigationChange = (event, item) => {
30
- onNavigationChange === null || onNavigationChange === void 0 ? void 0 : onNavigationChange(event, item);
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);
31
59
  };
32
60
  const handleExpandToggle = () => {
33
- setIsExpanded(prevState => !prevState);
61
+ onToggleExpanded(!expanded);
34
62
  };
35
- return /*#__PURE__*/_jsxs(HvVerticalNavigationCore, {
36
- className: clsx(classes.panel, isExpanded ? classes.panelExpanded : classes.panelCollapsed),
37
- children: [/*#__PURE__*/_jsx(HvVerticalNavigationTree, {
38
- collapsible: true,
39
- data: data,
40
- selected: selected,
41
- onChange: handleVerticalNavigationChange
42
- }), /*#__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}`,
43
68
  children: /*#__PURE__*/_jsx(HvButton, {
44
- id: setId(id, "button-toggle"),
45
- className: clsx(isExpanded ? classes.collapseButton : classes.expandButton),
46
- category: "ghost",
47
- startIcon: isExpanded ? _Backwards || (_Backwards = /*#__PURE__*/_jsx(Backwards, {
69
+ icon: true,
70
+ onClick: handleExpandToggle,
71
+ children: expanded ? _Backwards || (_Backwards = /*#__PURE__*/_jsx(Backwards, {
48
72
  iconSize: "XS"
49
73
  })) : _Forwards || (_Forwards = /*#__PURE__*/_jsx(Forwards, {
50
74
  iconSize: "XS"
51
- })),
52
- onClick: handleExpandToggle,
53
- children: isExpanded && /*#__PURE__*/_jsx("span", {
54
- className: classes.collapseTextContainer,
55
- children: collapseLabel
56
- })
75
+ }))
57
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
58
84
  })]
59
- });
85
+ }));
60
86
  };
61
87
  process.env.NODE_ENV !== "production" ? HvVerticalNavigation.propTypes = {
62
- /**
63
- * Id to be applied to the root node of the panel.
64
- */
65
- id: PropTypes.string,
66
88
  /**
67
89
  * Called when a menu item is clicked.
68
90
  */
69
91
  onNavigationChange: PropTypes.func,
92
+ /**
93
+ * Called when the collapse / expand button is clicked.
94
+ */
95
+ onToggleExpanded: PropTypes.func,
70
96
  /**
71
97
  * An array containing the data for each menu item.
72
98
  *
@@ -85,14 +111,14 @@ process.env.NODE_ENV !== "production" ? HvVerticalNavigation.propTypes = {
85
111
  href: PropTypes.string,
86
112
  target: PropTypes.string
87
113
  })).isRequired,
88
- /**
89
- * Text to be displayed in the collpase area when the panel is expanded.
90
- */
91
- collapseLabel: PropTypes.string,
92
114
  /**
93
115
  * The ID of the selected page.
94
116
  */
95
117
  selected: PropTypes.string,
118
+ /**
119
+ * Boolean value stating if the panel should be collapsed or expanded.
120
+ */
121
+ expanded: PropTypes.bool,
96
122
  /**
97
123
  * The top value where the panel will be rendered. Default is 44 as it is the height of the Header component.
98
124
  */
@@ -111,7 +137,6 @@ process.env.NODE_ENV !== "production" ? HvVerticalNavigation.propTypes = {
111
137
  position: PropTypes.oneOf(["static", "relative", "fixed", "absolute", "sticky"])
112
138
  } : void 0;
113
139
  HvVerticalNavigation.defaultProps = {
114
- collapseLabel: "Collapse",
115
140
  topPosition: 44,
116
141
  expandedPanelWidth: 300,
117
142
  collapsedPanelWidth: 52,