@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.
@@ -1,75 +1,112 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
1
3
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
5
  var _Backwards, _Forwards;
6
+ var _excluded = ["onNavigationChange", "onToggleExpanded", "data", "selected", "expanded", "topPosition", "expandedPanelWidth", "collapsedPanelWidth", "position"],
7
+ _excluded2 = ["data"];
8
+ 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; }
9
+ 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; }
10
+ import "core-js/modules/es.array.map.js";
11
+ import "core-js/modules/es.array.concat.js";
12
+ import "core-js/modules/es.object.keys.js";
13
+ import "core-js/modules/es.symbol.js";
14
+ import "core-js/modules/es.array.filter.js";
15
+ import "core-js/modules/es.object.to-string.js";
16
+ import "core-js/modules/es.object.get-own-property-descriptor.js";
17
+ import "core-js/modules/web.dom-collections.for-each.js";
18
+ import "core-js/modules/es.object.get-own-property-descriptors.js";
3
19
  import React, { useState } from "react";
4
20
  import { withStyles } from "@mui/styles";
5
21
  import PropTypes from "prop-types";
6
22
  import clsx from "clsx";
7
- import { HvVerticalNavigation as HvVerticalNavigationCore, HvVerticalNavigationTree, HvVerticalNavigationActions, HvButton, setId } from "@hitachivantara/uikit-react-core";
23
+ import { HvVerticalNavigation as HvVerticalNavigationCore, HvVerticalNavigationTree, HvButton, HvContainer } from "@hitachivantara/uikit-react-core";
8
24
  import { Backwards, Forwards } from "@hitachivantara/uikit-react-icons";
9
25
  import useStyles from "./styles";
26
+ import { getAllParents, findRootParentById, findItemById } from "./utils";
10
27
  import { jsx as _jsx } from "react/jsx-runtime";
11
28
  import { jsxs as _jsxs } from "react/jsx-runtime";
12
29
  var HvVerticalNavigation = function HvVerticalNavigation(_ref) {
13
- var id = _ref.id,
14
- onNavigationChange = _ref.onNavigationChange,
30
+ var _findRootParentById;
31
+ var onNavigationChange = _ref.onNavigationChange,
32
+ onToggleExpanded = _ref.onToggleExpanded,
15
33
  data = _ref.data,
16
34
  selected = _ref.selected,
17
- collapseLabel = _ref.collapseLabel,
35
+ expanded = _ref.expanded,
18
36
  topPosition = _ref.topPosition,
19
37
  expandedPanelWidth = _ref.expandedPanelWidth,
20
- collapsedPanelWidth = _ref.collapsedPanelWidth;
38
+ collapsedPanelWidth = _ref.collapsedPanelWidth,
39
+ position = _ref.position,
40
+ others = _objectWithoutProperties(_ref, _excluded);
21
41
  var classes = useStyles({
22
42
  topPosition: topPosition,
23
43
  expandedPanelWidth: expandedPanelWidth,
24
- collapsedPanelWidth: collapsedPanelWidth
44
+ collapsedPanelWidth: collapsedPanelWidth,
45
+ position: position
25
46
  })();
26
- var _useState = useState(true),
47
+ var noSubData = data.map(function (_ref2) {
48
+ var dataToRemove = _ref2.data,
49
+ rest = _objectWithoutProperties(_ref2, _excluded2);
50
+ return rest;
51
+ });
52
+ var _useState = useState(getAllParents(data).map(function (item) {
53
+ return item.id;
54
+ })),
27
55
  _useState2 = _slicedToArray(_useState, 2),
28
- isExpanded = _useState2[0],
29
- setIsExpanded = _useState2[1];
56
+ expandedItems = _useState2[0],
57
+ setExpandedItems = _useState2[1];
58
+ var selectedTopParent = (_findRootParentById = findRootParentById(data, selected)) === null || _findRootParentById === void 0 ? void 0 : _findRootParentById.id;
30
59
  var handleVerticalNavigationChange = function handleVerticalNavigationChange(event, item) {
31
- onNavigationChange === null || onNavigationChange === void 0 ? void 0 : onNavigationChange(event, item);
60
+ // This need to be done because the item recieved on the callback is missing the original data object
61
+ var fullItem = findItemById(data, item.id);
62
+ if (!expanded && fullItem.data && fullItem.data.length > 0) {
63
+ setExpandedItems(function (prevState) {
64
+ return [].concat(_toConsumableArray(prevState), [item.id]);
65
+ });
66
+ onToggleExpanded(true);
67
+ } else {
68
+ onNavigationChange === null || onNavigationChange === void 0 ? void 0 : onNavigationChange(event, item);
69
+ }
70
+ };
71
+ var handleVerticalNavigationToggle = function handleVerticalNavigationToggle(event, currentExpandedItems) {
72
+ setExpandedItems(currentExpandedItems);
32
73
  };
33
74
  var handleExpandToggle = function handleExpandToggle() {
34
- setIsExpanded(function (prevState) {
35
- return !prevState;
36
- });
75
+ onToggleExpanded(!expanded);
37
76
  };
38
- return /*#__PURE__*/_jsxs(HvVerticalNavigationCore, {
39
- className: clsx(classes.panel, isExpanded ? classes.panelExpanded : classes.panelCollapsed),
40
- children: [/*#__PURE__*/_jsx(HvVerticalNavigationTree, {
41
- collapsible: true,
42
- data: data,
43
- selected: selected,
44
- onChange: handleVerticalNavigationChange
45
- }), /*#__PURE__*/_jsx(HvVerticalNavigationActions, {
77
+ return /*#__PURE__*/_jsxs(HvVerticalNavigationCore, _objectSpread(_objectSpread({
78
+ className: clsx(classes.panel, expanded ? classes.panelExpanded : classes.panelCollapsed)
79
+ }, others), {}, {
80
+ children: [/*#__PURE__*/_jsx(HvContainer, {
81
+ className: "".concat(classes.toggleCollapsePanel),
46
82
  children: /*#__PURE__*/_jsx(HvButton, {
47
- id: setId(id, "button-toggle"),
48
- className: clsx(isExpanded ? classes.collapseButton : classes.expandButton),
49
- category: "ghost",
50
- startIcon: isExpanded ? _Backwards || (_Backwards = /*#__PURE__*/_jsx(Backwards, {
83
+ icon: true,
84
+ onClick: handleExpandToggle,
85
+ children: expanded ? _Backwards || (_Backwards = /*#__PURE__*/_jsx(Backwards, {
51
86
  iconSize: "XS"
52
87
  })) : _Forwards || (_Forwards = /*#__PURE__*/_jsx(Forwards, {
53
88
  iconSize: "XS"
54
- })),
55
- onClick: handleExpandToggle,
56
- children: isExpanded && /*#__PURE__*/_jsx("span", {
57
- className: classes.collapseTextContainer,
58
- children: collapseLabel
59
- })
89
+ }))
60
90
  })
91
+ }), /*#__PURE__*/_jsx(HvVerticalNavigationTree, {
92
+ collapsible: true,
93
+ expanded: expandedItems,
94
+ data: expanded ? data : noSubData,
95
+ selected: expanded ? selected : selectedTopParent,
96
+ onChange: handleVerticalNavigationChange,
97
+ onToggle: handleVerticalNavigationToggle
61
98
  })]
62
- });
99
+ }));
63
100
  };
64
101
  process.env.NODE_ENV !== "production" ? HvVerticalNavigation.propTypes = {
65
- /**
66
- * Id to be applied to the root node of the panel.
67
- */
68
- id: PropTypes.string,
69
102
  /**
70
103
  * Called when a menu item is clicked.
71
104
  */
72
105
  onNavigationChange: PropTypes.func,
106
+ /**
107
+ * Called when the collapse / expand button is clicked.
108
+ */
109
+ onToggleExpanded: PropTypes.func,
73
110
  /**
74
111
  * An array containing the data for each menu item.
75
112
  *
@@ -88,14 +125,14 @@ process.env.NODE_ENV !== "production" ? HvVerticalNavigation.propTypes = {
88
125
  href: PropTypes.string,
89
126
  target: PropTypes.string
90
127
  })).isRequired,
91
- /**
92
- * Text to be displayed in the collpase area when the panel is expanded.
93
- */
94
- collapseLabel: PropTypes.string,
95
128
  /**
96
129
  * The ID of the selected page.
97
130
  */
98
131
  selected: PropTypes.string,
132
+ /**
133
+ * Boolean value stating if the panel should be collapsed or expanded.
134
+ */
135
+ expanded: PropTypes.bool,
99
136
  /**
100
137
  * The top value where the panel will be rendered. Default is 44 as it is the height of the Header component.
101
138
  */
@@ -107,13 +144,17 @@ process.env.NODE_ENV !== "production" ? HvVerticalNavigation.propTypes = {
107
144
  /**
108
145
  * The width of the panel when collapsed. Default vlaue is 52.
109
146
  */
110
- collapsedPanelWidth: PropTypes.number
147
+ collapsedPanelWidth: PropTypes.number,
148
+ /**
149
+ * Position of the component.
150
+ */
151
+ position: PropTypes.oneOf(["static", "relative", "fixed", "absolute", "sticky"])
111
152
  } : void 0;
112
153
  HvVerticalNavigation.defaultProps = {
113
- collapseLabel: "Collapse",
114
154
  topPosition: 44,
115
155
  expandedPanelWidth: 300,
116
- collapsedPanelWidth: 52
156
+ collapsedPanelWidth: 52,
157
+ position: "fixed"
117
158
  };
118
159
  export default withStyles(useStyles, {
119
160
  name: "HvVerticalNavigation"
@@ -1 +1 @@
1
- {"version":3,"file":"VerticalNavigation.js","names":["React","useState","withStyles","PropTypes","clsx","HvVerticalNavigation","HvVerticalNavigationCore","HvVerticalNavigationTree","HvVerticalNavigationActions","HvButton","setId","Backwards","Forwards","useStyles","id","onNavigationChange","data","selected","collapseLabel","topPosition","expandedPanelWidth","collapsedPanelWidth","classes","isExpanded","setIsExpanded","handleVerticalNavigationChange","event","item","handleExpandToggle","prevState","panel","panelExpanded","panelCollapsed","collapseButton","expandButton","collapseTextContainer","propTypes","string","func","arrayOf","shape","isRequired","label","icon","node","array","href","target","number","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 HvVerticalNavigationActions,\n HvButton,\n setId,\n} from \"@hitachivantara/uikit-react-core\";\nimport { Backwards, Forwards } from \"@hitachivantara/uikit-react-icons\";\n\nimport useStyles from \"./styles\";\n\nconst HvVerticalNavigation = ({\n id,\n onNavigationChange,\n data,\n selected,\n collapseLabel,\n\n topPosition,\n expandedPanelWidth,\n collapsedPanelWidth,\n}) => {\n const classes = useStyles({ topPosition, expandedPanelWidth, collapsedPanelWidth })();\n\n const [isExpanded, setIsExpanded] = useState(true);\n\n const handleVerticalNavigationChange = (event, item) => {\n onNavigationChange?.(event, item);\n };\n\n const handleExpandToggle = () => {\n setIsExpanded((prevState) => !prevState);\n };\n\n return (\n <HvVerticalNavigationCore\n className={clsx(classes.panel, {\n [classes.panelExpanded]: isExpanded,\n [classes.panelCollapsed]: !isExpanded,\n })}\n >\n <HvVerticalNavigationTree\n collapsible\n data={data}\n selected={selected}\n onChange={handleVerticalNavigationChange}\n />\n\n <HvVerticalNavigationActions>\n <HvButton\n id={setId(id, \"button-toggle\")}\n className={clsx({\n [classes.collapseButton]: isExpanded,\n [classes.expandButton]: !isExpanded,\n })}\n category=\"ghost\"\n startIcon={isExpanded ? <Backwards iconSize=\"XS\" /> : <Forwards iconSize=\"XS\" />}\n onClick={handleExpandToggle}\n >\n {isExpanded && <span className={classes.collapseTextContainer}>{collapseLabel}</span>}\n </HvButton>\n </HvVerticalNavigationActions>\n </HvVerticalNavigationCore>\n );\n};\n\nHvVerticalNavigation.propTypes = {\n /**\n * Id to be applied to the root node of the panel.\n */\n id: PropTypes.string,\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 * 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 * Text to be displayed in the collpase area when the panel is expanded.\n */\n collapseLabel: 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 expandedPanelWidth: PropTypes.number,\n /**\n * The width of the panel when collapsed. Default vlaue is 52.\n */\n collapsedPanelWidth: PropTypes.number,\n};\n\nHvVerticalNavigation.defaultProps = {\n collapseLabel: \"Collapse\",\n topPosition: 44,\n expandedPanelWidth: 300,\n collapsedPanelWidth: 52,\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,2BAA2B,EAC3BC,QAAQ,EACRC,KAAK,QACA,kCAAkC;AACzC,SAASC,SAAS,EAAEC,QAAQ,QAAQ,mCAAmC;AAEvE,OAAOC,SAAS,MAAM,UAAU;AAAC;AAAA;AAEjC,IAAMR,oBAAoB,GAAG,SAAvBA,oBAAoB,OAUpB;EAAA,IATJS,EAAE,QAAFA,EAAE;IACFC,kBAAkB,QAAlBA,kBAAkB;IAClBC,IAAI,QAAJA,IAAI;IACJC,QAAQ,QAARA,QAAQ;IACRC,aAAa,QAAbA,aAAa;IAEbC,WAAW,QAAXA,WAAW;IACXC,kBAAkB,QAAlBA,kBAAkB;IAClBC,mBAAmB,QAAnBA,mBAAmB;EAEnB,IAAMC,OAAO,GAAGT,SAAS,CAAC;IAAEM,WAAW,EAAXA,WAAW;IAAEC,kBAAkB,EAAlBA,kBAAkB;IAAEC,mBAAmB,EAAnBA;EAAoB,CAAC,CAAC,EAAE;EAErF,gBAAoCpB,QAAQ,CAAC,IAAI,CAAC;IAAA;IAA3CsB,UAAU;IAAEC,aAAa;EAEhC,IAAMC,8BAA8B,GAAG,SAAjCA,8BAA8B,CAAIC,KAAK,EAA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;AACA;EACEtB,IAAI,EAAEb,SAAS,CAACoC,OAAO,CACrBpC,SAAS,CAACqC,KAAK,CAAC;IACd1B,EAAE,EAAEX,SAAS,CAACkC,MAAM,CAACI,UAAU;IAC/BC,KAAK,EAAEvC,SAAS,CAACkC,MAAM,CAACI,UAAU;IAClCE,IAAI,EAAExC,SAAS,CAACyC,IAAI;IACpB5B,IAAI,EAAEb,SAAS,CAAC0C,KAAK;IACrBC,IAAI,EAAE3C,SAAS,CAACkC,MAAM;IACtBU,MAAM,EAAE5C,SAAS,CAACkC;EACpB,CAAC,CAAC,CACH,CAACI,UAAU;EACZ;AACF;AACA;EACEvB,aAAa,EAAEf,SAAS,CAACkC,MAAM;EAC/B;AACF;AACA;EACEpB,QAAQ,EAAEd,SAAS,CAACkC,MAAM;EAC1B;AACF;AACA;EACElB,WAAW,EAAEhB,SAAS,CAAC6C,MAAM;EAC7B;AACF;AACA;EACE5B,kBAAkB,EAAEjB,SAAS,CAAC6C,MAAM;EACpC;AACF;AACA;EACE3B,mBAAmB,EAAElB,SAAS,CAAC6C;AACjC,CAAC;AAED3C,oBAAoB,CAAC4C,YAAY,GAAG;EAClC/B,aAAa,EAAE,UAAU;EACzBC,WAAW,EAAE,EAAE;EACfC,kBAAkB,EAAE,GAAG;EACvBC,mBAAmB,EAAE;AACvB,CAAC;AAED,eAAenB,UAAU,CAACW,SAAS,EAAE;EAAEqC,IAAI,EAAE;AAAuB,CAAC,CAAC,CAAC7C,oBAAoB,CAAC"}
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","item","id","expandedItems","setExpandedItems","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,I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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,19 +1,10 @@
1
- import "core-js/modules/es.object.keys.js";
2
- import "core-js/modules/es.symbol.js";
3
- import "core-js/modules/es.array.filter.js";
4
- import "core-js/modules/es.object.to-string.js";
5
- import "core-js/modules/es.object.get-own-property-descriptor.js";
6
- import "core-js/modules/web.dom-collections.for-each.js";
7
- import "core-js/modules/es.object.get-own-property-descriptors.js";
8
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
9
- 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; }
10
- 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; }
11
1
  import { makeStyles } from "@mui/styles";
12
2
  var styles = function styles(props) {
13
3
  return makeStyles(function (theme) {
14
4
  return {
15
5
  panel: {
16
- position: "fixed",
6
+ justifyContent: "flex-start",
7
+ position: props.position,
17
8
  top: props.topPosition,
18
9
  left: 0,
19
10
  zIndex: 1100
@@ -21,22 +12,20 @@ var styles = function styles(props) {
21
12
  panelExpanded: {
22
13
  width: props.expandedPanelWidth,
23
14
  height: "calc(100vh - ".concat(props.topPosition, "px)"),
24
- // This is for the bottom actions
25
- "& > :not(:first-child) > button > span": {
26
- marginBottom: 0
15
+ // To remove the top border of the navigation section
16
+ "& > :not(:first-child)": {
17
+ borderTop: "none"
27
18
  }
28
19
  },
29
20
  panelCollapsed: {
30
21
  width: props.collapsedPanelWidth,
31
22
  height: "calc(100vh - ".concat(props.topPosition, "px)"),
32
- // This is for the bottom actions
23
+ // Customize the navigation section
33
24
  "& > :not(:first-child)": {
34
- padding: theme.hvSpacing("xs", "xs", "sm", "xs"),
35
- "& > button > span": {
36
- marginLeft: 0
37
- }
25
+ borderTop: "none",
26
+ padding: theme.hvSpacing("xs", "xs", "sm", "xs")
38
27
  },
39
- // This is for the top menu items
28
+ // Customize the collapse / expand
40
29
  "& > :first-child:not(:last-child)": {
41
30
  padding: theme.hvSpacing("sm", "xs", "xs", "xs")
42
31
  },
@@ -44,22 +33,9 @@ var styles = function styles(props) {
44
33
  marginLeft: "6px"
45
34
  }
46
35
  },
47
- collapseButton: _objectSpread(_objectSpread({}, theme.hv.typography.normalText), {}, {
48
- width: "100%",
49
- "& > span": {
50
- justifyContent: "flex-start"
51
- }
52
- }),
53
- expandButton: {
54
- width: "100%",
55
- minWidth: "unset",
56
- "& > span > span": {
57
- marginLeft: "unset"
58
- }
59
- },
60
- collapseTextContainer: {
61
- width: "100%",
62
- textAlign: "left"
36
+ toggleCollapsePanel: {
37
+ display: "flex",
38
+ justifyContent: "flex-end"
63
39
  }
64
40
  };
65
41
  });
@@ -1 +1 @@
1
- {"version":3,"file":"styles.js","names":["makeStyles","styles","props","theme","panel","position","top","topPosition","left","zIndex","panelExpanded","width","expandedPanelWidth","height","marginBottom","panelCollapsed","collapsedPanelWidth","padding","hvSpacing","marginLeft","collapseButton","hv","typography","normalText","justifyContent","expandButton","minWidth","collapseTextContainer","textAlign"],"sources":["../../../src/VerticalNavigation/styles.js"],"sourcesContent":["import { makeStyles } from \"@mui/styles\";\n\nconst styles = (props) =>\n makeStyles((theme) => ({\n panel: {\n position: \"fixed\",\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 // This is for the bottom actions\n \"& > :not(:first-child) > button > span\": {\n marginBottom: 0,\n },\n },\n panelCollapsed: {\n width: props.collapsedPanelWidth,\n height: `calc(100vh - ${props.topPosition}px)`,\n\n // This is for the bottom actions\n \"& > :not(:first-child)\": {\n padding: theme.hvSpacing(\"xs\", \"xs\", \"sm\", \"xs\"),\n\n \"& > button > span\": {\n marginLeft: 0,\n },\n },\n // This is for the top menu items\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 collapseButton: {\n ...theme.hv.typography.normalText,\n width: \"100%\",\n\n \"& > span\": {\n justifyContent: \"flex-start\",\n },\n },\n expandButton: {\n width: \"100%\",\n minWidth: \"unset\",\n\n \"& > span > span\": {\n marginLeft: \"unset\",\n },\n },\n collapseTextContainer: {\n width: \"100%\",\n textAlign: \"left\",\n },\n }));\n\nexport default styles;\n"],"mappings":";;;;;;;;;;AAAA,SAASA,UAAU,QAAQ,aAAa;AAExC,IAAMC,MAAM,GAAG,SAATA,MAAM,CAAIC,KAAK;EAAA,OACnBF,UAAU,CAAC,UAACG,KAAK;IAAA,OAAM;MACrBC,KAAK,EAAE;QACLC,QAAQ,EAAE,OAAO;QACjBC,GAAG,EAAEJ,KAAK,CAACK,WAAW;QACtBC,IAAI,EAAE,CAAC;QACPC,MAAM,EAAE;MACV,CAAC;MACDC,aAAa,EAAE;QACbC,KAAK,EAAET,KAAK,CAACU,kBAAkB;QAC/BC,MAAM,yBAAkBX,KAAK,CAACK,WAAW,QAAK;QAE9C;QACA,wCAAwC,EAAE;UACxCO,YAAY,EAAE;QAChB;MACF,CAAC;MACDC,cAAc,EAAE;QACdJ,KAAK,EAAET,KAAK,CAACc,mBAAmB;QAChCH,MAAM,yBAAkBX,KAAK,CAACK,WAAW,QAAK;QAE9C;QACA,wBAAwB,EAAE;UACxBU,OAAO,EAAEd,KAAK,CAACe,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;UAEhD,mBAAmB,EAAE;YACnBC,UAAU,EAAE;UACd;QACF,CAAC;QACD;QACA,mCAAmC,EAAE;UACnCF,OAAO,EAAEd,KAAK,CAACe,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;QACjD,CAAC;QAED,+BAA+B,EAAE;UAC/BC,UAAU,EAAE;QACd;MACF,CAAC;MACDC,cAAc,kCACTjB,KAAK,CAACkB,EAAE,CAACC,UAAU,CAACC,UAAU;QACjCZ,KAAK,EAAE,MAAM;QAEb,UAAU,EAAE;UACVa,cAAc,EAAE;QAClB;MAAC,EACF;MACDC,YAAY,EAAE;QACZd,KAAK,EAAE,MAAM;QACbe,QAAQ,EAAE,OAAO;QAEjB,iBAAiB,EAAE;UACjBP,UAAU,EAAE;QACd;MACF,CAAC;MACDQ,qBAAqB,EAAE;QACrBhB,KAAK,EAAE,MAAM;QACbiB,SAAS,EAAE;MACb;IACF,CAAC;EAAA,CAAC,CAAC;AAAA;AAEL,eAAe3B,MAAM"}
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,IAAMC,MAAM,GAAG,SAATA,MAAM,CAAIC,KAAK;EAAA,OACnBF,UAAU,CAAC,UAACG,KAAK;IAAA,OAAM;MACrBC,KAAK,EAAE;QACLC,cAAc,EAAE,YAAY;QAC5BC,QAAQ,EAAEJ,KAAK,CAACI,QAAQ;QACxBC,GAAG,EAAEL,KAAK,CAACM,WAAW;QACtBC,IAAI,EAAE,CAAC;QACPC,MAAM,EAAE;MACV,CAAC;MACDC,aAAa,EAAE;QACbC,KAAK,EAAEV,KAAK,CAACW,kBAAkB;QAC/BC,MAAM,yBAAkBZ,KAAK,CAACM,WAAW,QAAK;QAE9C;QACA,wBAAwB,EAAE;UACxBO,SAAS,EAAE;QACb;MACF,CAAC;MACDC,cAAc,EAAE;QACdJ,KAAK,EAAEV,KAAK,CAACe,mBAAmB;QAChCH,MAAM,yBAAkBZ,KAAK,CAACM,WAAW,QAAK;QAE9C;QACA,wBAAwB,EAAE;UACxBO,SAAS,EAAE,MAAM;UACjBG,OAAO,EAAEf,KAAK,CAACgB,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;QACjD,CAAC;QAED;QACA,mCAAmC,EAAE;UACnCD,OAAO,EAAEf,KAAK,CAACgB,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;QACjD,CAAC;QAED,+BAA+B,EAAE;UAC/BC,UAAU,EAAE;QACd;MACF,CAAC;MAEDC,mBAAmB,EAAE;QACnBC,OAAO,EAAE,MAAM;QACfjB,cAAc,EAAE;MAClB;IACF,CAAC;EAAA,CAAC,CAAC;AAAA;AAEL,eAAeJ,MAAM"}
@@ -0,0 +1,71 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
+ import "core-js/modules/es.object.to-string.js";
3
+ import "core-js/modules/es.array.find.js";
4
+ import "core-js/modules/es.array.filter.js";
5
+ import "core-js/modules/es.array.flat-map.js";
6
+ import "core-js/modules/es.array.unscopables.flat-map.js";
7
+ import "core-js/modules/es.array.concat.js";
8
+ /**
9
+ * Receives the navigation data and the id of the item from which we want to get the root parent.
10
+ *
11
+ * @param {NavigationItem[]} data - The navigation data structure.
12
+ * @param {string} itemId - The item id.
13
+ * @returns The item that is the root parent of the received item.
14
+ */
15
+ var findRootParentById = function findRootParentById(data, itemId) {
16
+ return data.reduce(function (parent, item) {
17
+ if (parent) {
18
+ return parent;
19
+ }
20
+ if (item.id === itemId) {
21
+ return item;
22
+ }
23
+ if (item.data) {
24
+ var found = findRootParentById(item.data, itemId);
25
+ if (found) {
26
+ return item;
27
+ }
28
+ }
29
+ return null;
30
+ }, null);
31
+ };
32
+
33
+ /**
34
+ * Returns the complete item object from the data structure using the item id.
35
+ *
36
+ * @param {NavigationItem[]} data - The navigation data structure.
37
+ * @param {string} itemId - The item id.
38
+ * @returns The complete item object matching the received id.
39
+ */
40
+ var findItemById = function findItemById(data, itemId) {
41
+ return data.find(function (item) {
42
+ if (item.id === itemId) {
43
+ return true;
44
+ }
45
+ if (item.data && item.data.length > 0) {
46
+ var foundItem = findItemById(item.data, itemId);
47
+ if (foundItem) {
48
+ return true;
49
+ }
50
+ }
51
+ return false;
52
+ });
53
+ };
54
+
55
+ /**
56
+ * Returns all the items that have chilren associated.
57
+ *
58
+ * @param {NavigationItem[]} data - The navigation data structure.
59
+ * @returns All the items that have chilren associated.
60
+ */
61
+ var getAllParents = function getAllParents(items) {
62
+ var parents = items.filter(function (item) {
63
+ return item.data != null && item.data.length > 0;
64
+ });
65
+ var childParents = parents.flatMap(function (item) {
66
+ return getAllParents(item.data);
67
+ });
68
+ return [].concat(_toConsumableArray(parents), _toConsumableArray(childParents));
69
+ };
70
+ export { findRootParentById, findItemById, getAllParents };
71
+ //# 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,IAAMA,kBAAkB,GAAG,SAArBA,kBAAkB,CAAIC,IAAI,EAAEC,MAAM,EAAK;EAC3C,OAAOD,IAAI,CAACE,MAAM,CAAC,UAACC,MAAM,EAAEC,IAAI,EAAK;IACnC,IAAID,MAAM,EAAE;MACV,OAAOA,MAAM;IACf;IAEA,IAAIC,IAAI,CAACC,EAAE,KAAKJ,MAAM,EAAE;MACtB,OAAOG,IAAI;IACb;IAEA,IAAIA,IAAI,CAACJ,IAAI,EAAE;MACb,IAAMM,KAAK,GAAGP,kBAAkB,CAACK,IAAI,CAACJ,IAAI,EAAEC,MAAM,CAAC;MACnD,IAAIK,KAAK,EAAE;QACT,OAAOF,IAAI;MACb;IACF;IACA,OAAO,IAAI;EACb,CAAC,EAAE,IAAI,CAAC;AACV,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMG,YAAY,GAAG,SAAfA,YAAY,CAAIP,IAAI,EAAEC,MAAM,EAAK;EACrC,OAAOD,IAAI,CAACQ,IAAI,CAAC,UAACJ,IAAI,EAAK;IACzB,IAAIA,IAAI,CAACC,EAAE,KAAKJ,MAAM,EAAE;MACtB,OAAO,IAAI;IACb;IAEA,IAAIG,IAAI,CAACJ,IAAI,IAAII,IAAI,CAACJ,IAAI,CAACS,MAAM,GAAG,CAAC,EAAE;MACrC,IAAMC,SAAS,GAAGH,YAAY,CAACH,IAAI,CAACJ,IAAI,EAAEC,MAAM,CAAC;MACjD,IAAIS,SAAS,EAAE;QACb,OAAO,IAAI;MACb;IACF;IACA,OAAO,KAAK;EACd,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,aAAa,GAAG,SAAhBA,aAAa,CAAIC,KAAK,EAAK;EAC/B,IAAMC,OAAO,GAAGD,KAAK,CAACE,MAAM,CAAC,UAACV,IAAI;IAAA,OAAKA,IAAI,CAACJ,IAAI,IAAI,IAAI,IAAII,IAAI,CAACJ,IAAI,CAACS,MAAM,GAAG,CAAC;EAAA,EAAC;EACjF,IAAMM,YAAY,GAAGF,OAAO,CAACG,OAAO,CAAC,UAACZ,IAAI;IAAA,OAAKO,aAAa,CAACP,IAAI,CAACJ,IAAI,CAAC;EAAA,EAAC;EAExE,oCAAWa,OAAO,sBAAKE,YAAY;AACrC,CAAC;AAED,SAAShB,kBAAkB,EAAEQ,YAAY,EAAEI,aAAa"}
@@ -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;