@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,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,18 +1,28 @@
1
1
  "use strict";
2
2
 
3
- require("core-js/modules/es.array.iterator.js");
3
+ require("core-js/modules/es.object.keys.js");
4
+ require("core-js/modules/es.symbol.js");
5
+ require("core-js/modules/es.array.filter.js");
4
6
  require("core-js/modules/es.object.to-string.js");
7
+ require("core-js/modules/es.object.get-own-property-descriptor.js");
8
+ require("core-js/modules/web.dom-collections.for-each.js");
9
+ require("core-js/modules/es.object.get-own-property-descriptors.js");
10
+ require("core-js/modules/es.array.iterator.js");
5
11
  require("core-js/modules/es.string.iterator.js");
6
12
  require("core-js/modules/es.weak-map.js");
7
13
  require("core-js/modules/web.dom-collections.iterator.js");
8
- require("core-js/modules/es.object.get-own-property-descriptor.js");
9
14
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
10
15
  var _typeof = require("@babel/runtime/helpers/typeof");
11
16
  Object.defineProperty(exports, "__esModule", {
12
17
  value: true
13
18
  });
14
19
  exports.default = void 0;
20
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
21
+ require("core-js/modules/es.array.map.js");
22
+ require("core-js/modules/es.array.concat.js");
23
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
15
24
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
25
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
16
26
  var _react = _interopRequireWildcard(require("react"));
17
27
  var _styles = require("@mui/styles");
18
28
  var _propTypes = _interopRequireDefault(require("prop-types"));
@@ -20,71 +30,96 @@ var _clsx = _interopRequireDefault(require("clsx"));
20
30
  var _uikitReactCore = require("@hitachivantara/uikit-react-core");
21
31
  var _uikitReactIcons = require("@hitachivantara/uikit-react-icons");
22
32
  var _styles2 = _interopRequireDefault(require("./styles"));
33
+ var _utils = require("./utils");
23
34
  var _jsxRuntime = require("react/jsx-runtime");
24
35
  var _Backwards, _Forwards;
36
+ var _excluded = ["onNavigationChange", "onToggleExpanded", "data", "selected", "expanded", "topPosition", "expandedPanelWidth", "collapsedPanelWidth", "position"],
37
+ _excluded2 = ["data"];
25
38
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
26
39
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
40
+ 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; }
41
+ 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) { (0, _defineProperty2.default)(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; }
27
42
  var HvVerticalNavigation = function HvVerticalNavigation(_ref) {
28
- var id = _ref.id,
29
- onNavigationChange = _ref.onNavigationChange,
43
+ var _findRootParentById;
44
+ var onNavigationChange = _ref.onNavigationChange,
45
+ onToggleExpanded = _ref.onToggleExpanded,
30
46
  data = _ref.data,
31
47
  selected = _ref.selected,
32
- collapseLabel = _ref.collapseLabel,
48
+ expanded = _ref.expanded,
33
49
  topPosition = _ref.topPosition,
34
50
  expandedPanelWidth = _ref.expandedPanelWidth,
35
- collapsedPanelWidth = _ref.collapsedPanelWidth;
51
+ collapsedPanelWidth = _ref.collapsedPanelWidth,
52
+ position = _ref.position,
53
+ others = (0, _objectWithoutProperties2.default)(_ref, _excluded);
36
54
  var classes = (0, _styles2.default)({
37
55
  topPosition: topPosition,
38
56
  expandedPanelWidth: expandedPanelWidth,
39
- collapsedPanelWidth: collapsedPanelWidth
57
+ collapsedPanelWidth: collapsedPanelWidth,
58
+ position: position
40
59
  })();
41
- var _useState = (0, _react.useState)(true),
60
+ var noSubData = data.map(function (_ref2) {
61
+ var dataToRemove = _ref2.data,
62
+ rest = (0, _objectWithoutProperties2.default)(_ref2, _excluded2);
63
+ return rest;
64
+ });
65
+ var _useState = (0, _react.useState)((0, _utils.getAllParents)(data).map(function (item) {
66
+ return item.id;
67
+ })),
42
68
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
43
- isExpanded = _useState2[0],
44
- setIsExpanded = _useState2[1];
69
+ expandedItems = _useState2[0],
70
+ setExpandedItems = _useState2[1];
71
+ var selectedTopParent = (_findRootParentById = (0, _utils.findRootParentById)(data, selected)) === null || _findRootParentById === void 0 ? void 0 : _findRootParentById.id;
45
72
  var handleVerticalNavigationChange = function handleVerticalNavigationChange(event, item) {
46
- onNavigationChange === null || onNavigationChange === void 0 ? void 0 : onNavigationChange(event, item);
73
+ // This need to be done because the item recieved on the callback is missing the original data object
74
+ var fullItem = (0, _utils.findItemById)(data, item.id);
75
+ if (!expanded && fullItem.data && fullItem.data.length > 0) {
76
+ setExpandedItems(function (prevState) {
77
+ return [].concat((0, _toConsumableArray2.default)(prevState), [item.id]);
78
+ });
79
+ onToggleExpanded(true);
80
+ } else {
81
+ onNavigationChange === null || onNavigationChange === void 0 ? void 0 : onNavigationChange(event, item);
82
+ }
83
+ };
84
+ var handleVerticalNavigationToggle = function handleVerticalNavigationToggle(event, currentExpandedItems) {
85
+ setExpandedItems(currentExpandedItems);
47
86
  };
48
87
  var handleExpandToggle = function handleExpandToggle() {
49
- setIsExpanded(function (prevState) {
50
- return !prevState;
51
- });
88
+ onToggleExpanded(!expanded);
52
89
  };
53
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_uikitReactCore.HvVerticalNavigation, {
54
- className: (0, _clsx.default)(classes.panel, isExpanded ? classes.panelExpanded : classes.panelCollapsed),
55
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_uikitReactCore.HvVerticalNavigationTree, {
56
- collapsible: true,
57
- data: data,
58
- selected: selected,
59
- onChange: handleVerticalNavigationChange
60
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_uikitReactCore.HvVerticalNavigationActions, {
90
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_uikitReactCore.HvVerticalNavigation, _objectSpread(_objectSpread({
91
+ className: (0, _clsx.default)(classes.panel, expanded ? classes.panelExpanded : classes.panelCollapsed)
92
+ }, others), {}, {
93
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_uikitReactCore.HvContainer, {
94
+ className: "".concat(classes.toggleCollapsePanel),
61
95
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_uikitReactCore.HvButton, {
62
- id: (0, _uikitReactCore.setId)(id, "button-toggle"),
63
- className: (0, _clsx.default)(isExpanded ? classes.collapseButton : classes.expandButton),
64
- category: "ghost",
65
- startIcon: isExpanded ? _Backwards || (_Backwards = /*#__PURE__*/(0, _jsxRuntime.jsx)(_uikitReactIcons.Backwards, {
96
+ icon: true,
97
+ onClick: handleExpandToggle,
98
+ children: expanded ? _Backwards || (_Backwards = /*#__PURE__*/(0, _jsxRuntime.jsx)(_uikitReactIcons.Backwards, {
66
99
  iconSize: "XS"
67
100
  })) : _Forwards || (_Forwards = /*#__PURE__*/(0, _jsxRuntime.jsx)(_uikitReactIcons.Forwards, {
68
101
  iconSize: "XS"
69
- })),
70
- onClick: handleExpandToggle,
71
- children: isExpanded && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
72
- className: classes.collapseTextContainer,
73
- children: collapseLabel
74
- })
102
+ }))
75
103
  })
104
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_uikitReactCore.HvVerticalNavigationTree, {
105
+ collapsible: true,
106
+ expanded: expandedItems,
107
+ data: expanded ? data : noSubData,
108
+ selected: expanded ? selected : selectedTopParent,
109
+ onChange: handleVerticalNavigationChange,
110
+ onToggle: handleVerticalNavigationToggle
76
111
  })]
77
- });
112
+ }));
78
113
  };
79
114
  process.env.NODE_ENV !== "production" ? HvVerticalNavigation.propTypes = {
80
- /**
81
- * Id to be applied to the root node of the panel.
82
- */
83
- id: _propTypes.default.string,
84
115
  /**
85
116
  * Called when a menu item is clicked.
86
117
  */
87
118
  onNavigationChange: _propTypes.default.func,
119
+ /**
120
+ * Called when the collapse / expand button is clicked.
121
+ */
122
+ onToggleExpanded: _propTypes.default.func,
88
123
  /**
89
124
  * An array containing the data for each menu item.
90
125
  *
@@ -103,14 +138,14 @@ process.env.NODE_ENV !== "production" ? HvVerticalNavigation.propTypes = {
103
138
  href: _propTypes.default.string,
104
139
  target: _propTypes.default.string
105
140
  })).isRequired,
106
- /**
107
- * Text to be displayed in the collpase area when the panel is expanded.
108
- */
109
- collapseLabel: _propTypes.default.string,
110
141
  /**
111
142
  * The ID of the selected page.
112
143
  */
113
144
  selected: _propTypes.default.string,
145
+ /**
146
+ * Boolean value stating if the panel should be collapsed or expanded.
147
+ */
148
+ expanded: _propTypes.default.bool,
114
149
  /**
115
150
  * The top value where the panel will be rendered. Default is 44 as it is the height of the Header component.
116
151
  */
@@ -122,13 +157,17 @@ process.env.NODE_ENV !== "production" ? HvVerticalNavigation.propTypes = {
122
157
  /**
123
158
  * The width of the panel when collapsed. Default vlaue is 52.
124
159
  */
125
- collapsedPanelWidth: _propTypes.default.number
160
+ collapsedPanelWidth: _propTypes.default.number,
161
+ /**
162
+ * Position of the component.
163
+ */
164
+ position: _propTypes.default.oneOf(["static", "relative", "fixed", "absolute", "sticky"])
126
165
  } : void 0;
127
166
  HvVerticalNavigation.defaultProps = {
128
- collapseLabel: "Collapse",
129
167
  topPosition: 44,
130
168
  expandedPanelWidth: 300,
131
- collapsedPanelWidth: 52
169
+ collapsedPanelWidth: 52,
170
+ position: "fixed"
132
171
  };
133
172
  var _default = (0, _styles.withStyles)(_styles2.default, {
134
173
  name: "HvVerticalNavigation"
@@ -1 +1 @@
1
- {"version":3,"file":"VerticalNavigation.js","names":["HvVerticalNavigation","id","onNavigationChange","data","selected","collapseLabel","topPosition","expandedPanelWidth","collapsedPanelWidth","classes","useStyles","useState","isExpanded","setIsExpanded","handleVerticalNavigationChange","event","item","handleExpandToggle","prevState","clsx","panel","panelExpanded","panelCollapsed","setId","collapseButton","expandButton","collapseTextContainer","propTypes","PropTypes","string","func","arrayOf","shape","isRequired","label","icon","node","array","href","target","number","defaultProps","withStyles","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":";;;;;;;;;;;;;;;AAA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AACF;AACA;EACEjC,kBAAkB,EAAEqB,kBAAS,CAACY,MAAM;EACpC;AACF;AACA;EACEhC,mBAAmB,EAAEoB,kBAAS,CAACY;AACjC,CAAC;AAEDxC,oBAAoB,CAACyC,YAAY,GAAG;EAClCpC,aAAa,EAAE,UAAU;EACzBC,WAAW,EAAE,EAAE;EACfC,kBAAkB,EAAE,GAAG;EACvBC,mBAAmB,EAAE;AACvB,CAAC;AAAC,eAEa,IAAAkC,kBAAU,EAAChC,gBAAS,EAAE;EAAEiC,IAAI,EAAE;AAAuB,CAAC,CAAC,CAAC3C,oBAAoB,CAAC;AAAA"}
1
+ {"version":3,"file":"VerticalNavigation.js","names":["HvVerticalNavigation","onNavigationChange","onToggleExpanded","data","selected","expanded","topPosition","expandedPanelWidth","collapsedPanelWidth","position","others","classes","useStyles","noSubData","map","dataToRemove","rest","useState","getAllParents","item","id","expandedItems","setExpandedItems","selectedTopParent","findRootParentById","handleVerticalNavigationChange","event","fullItem","findItemById","length","prevState","handleVerticalNavigationToggle","currentExpandedItems","handleExpandToggle","clsx","panel","panelExpanded","panelCollapsed","toggleCollapsePanel","propTypes","PropTypes","func","arrayOf","shape","string","isRequired","label","icon","node","array","href","target","bool","number","oneOf","defaultProps","withStyles","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;AACA;AACA;AACA;AAEA;AAMA;AAEA;AACA;AAA0E;AAAA;AAAA;EAAA;AAAA;AAAA;AAAA;AAAA;AAE1E,IAAMA,oBAAoB,GAAG,SAAvBA,oBAAoB,OAYpB;EAAA;EAAA,IAXJC,kBAAkB,QAAlBA,kBAAkB;IAClBC,gBAAgB,QAAhBA,gBAAgB;IAChBC,IAAI,QAAJA,IAAI;IACJC,QAAQ,QAARA,QAAQ;IACRC,QAAQ,QAARA,QAAQ;IACRC,WAAW,QAAXA,WAAW;IACXC,kBAAkB,QAAlBA,kBAAkB;IAClBC,mBAAmB,QAAnBA,mBAAmB;IACnBC,QAAQ,QAARA,QAAQ;IAELC,MAAM;EAET,IAAMC,OAAO,GAAG,IAAAC,gBAAS,EAAC;IAAEN,WAAW,EAAXA,WAAW;IAAEC,kBAAkB,EAAlBA,kBAAkB;IAAEC,mBAAmB,EAAnBA,mBAAmB;IAAEC,QAAQ,EAARA;EAAS,CAAC,CAAC,EAAE;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pB,CAAC,CAAC,CACH,CAACC,UAAU;EACZ;AACF;AACA;EACEzC,QAAQ,EAAEoC,kBAAS,CAACI,MAAM;EAC1B;AACF;AACA;EACEvC,QAAQ,EAAEmC,kBAAS,CAACY,IAAI;EACxB;AACF;AACA;EACE9C,WAAW,EAAEkC,kBAAS,CAACa,MAAM;EAC7B;AACF;AACA;EACE9C,kBAAkB,EAAEiC,kBAAS,CAACa,MAAM;EACpC;AACF;AACA;EACE7C,mBAAmB,EAAEgC,kBAAS,CAACa,MAAM;EACrC;AACF;AACA;EACE5C,QAAQ,EAAE+B,kBAAS,CAACc,KAAK,CAAC,CAAC,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAC;AACjF,CAAC;AAEDtD,oBAAoB,CAACuD,YAAY,GAAG;EAClCjD,WAAW,EAAE,EAAE;EACfC,kBAAkB,EAAE,GAAG;EACvBC,mBAAmB,EAAE,EAAE;EACvBC,QAAQ,EAAE;AACZ,CAAC;AAAC,eAEa,IAAA+C,kBAAU,EAAC5C,gBAAS,EAAE;EAAE6C,IAAI,EAAE;AAAuB,CAAC,CAAC,CAACzD,oBAAoB,CAAC;AAAA"}
@@ -1,26 +1,16 @@
1
1
  "use strict";
2
2
 
3
- require("core-js/modules/es.object.keys.js");
4
- require("core-js/modules/es.symbol.js");
5
- require("core-js/modules/es.array.filter.js");
6
- require("core-js/modules/es.object.to-string.js");
7
- require("core-js/modules/es.object.get-own-property-descriptor.js");
8
- require("core-js/modules/web.dom-collections.for-each.js");
9
- require("core-js/modules/es.object.get-own-property-descriptors.js");
10
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
11
3
  Object.defineProperty(exports, "__esModule", {
12
4
  value: true
13
5
  });
14
6
  exports.default = void 0;
15
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
7
  var _styles = require("@mui/styles");
17
- 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; }
18
- 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) { (0, _defineProperty2.default)(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; }
19
8
  var styles = function styles(props) {
20
9
  return (0, _styles.makeStyles)(function (theme) {
21
10
  return {
22
11
  panel: {
23
- position: "fixed",
12
+ justifyContent: "flex-start",
13
+ position: props.position,
24
14
  top: props.topPosition,
25
15
  left: 0,
26
16
  zIndex: 1100
@@ -28,22 +18,20 @@ var styles = function styles(props) {
28
18
  panelExpanded: {
29
19
  width: props.expandedPanelWidth,
30
20
  height: "calc(100vh - ".concat(props.topPosition, "px)"),
31
- // This is for the bottom actions
32
- "& > :not(:first-child) > button > span": {
33
- marginBottom: 0
21
+ // To remove the top border of the navigation section
22
+ "& > :not(:first-child)": {
23
+ borderTop: "none"
34
24
  }
35
25
  },
36
26
  panelCollapsed: {
37
27
  width: props.collapsedPanelWidth,
38
28
  height: "calc(100vh - ".concat(props.topPosition, "px)"),
39
- // This is for the bottom actions
29
+ // Customize the navigation section
40
30
  "& > :not(:first-child)": {
41
- padding: theme.hvSpacing("xs", "xs", "sm", "xs"),
42
- "& > button > span": {
43
- marginLeft: 0
44
- }
31
+ borderTop: "none",
32
+ padding: theme.hvSpacing("xs", "xs", "sm", "xs")
45
33
  },
46
- // This is for the top menu items
34
+ // Customize the collapse / expand
47
35
  "& > :first-child:not(:last-child)": {
48
36
  padding: theme.hvSpacing("sm", "xs", "xs", "xs")
49
37
  },
@@ -51,22 +39,9 @@ var styles = function styles(props) {
51
39
  marginLeft: "6px"
52
40
  }
53
41
  },
54
- collapseButton: _objectSpread(_objectSpread({}, theme.hv.typography.normalText), {}, {
55
- width: "100%",
56
- "& > span": {
57
- justifyContent: "flex-start"
58
- }
59
- }),
60
- expandButton: {
61
- width: "100%",
62
- minWidth: "unset",
63
- "& > span > span": {
64
- marginLeft: "unset"
65
- }
66
- },
67
- collapseTextContainer: {
68
- width: "100%",
69
- textAlign: "left"
42
+ toggleCollapsePanel: {
43
+ display: "flex",
44
+ justifyContent: "flex-end"
70
45
  }
71
46
  };
72
47
  });
@@ -1 +1 @@
1
- {"version":3,"file":"styles.js","names":["styles","props","makeStyles","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;AAAyC;AAAA;AAEzC,IAAMA,MAAM,GAAG,SAATA,MAAM,CAAIC,KAAK;EAAA,OACnB,IAAAC,kBAAU,EAAC,UAACC,KAAK;IAAA,OAAM;MACrBC,KAAK,EAAE;QACLC,QAAQ,EAAE,OAAO;QACjBC,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,wCAAwC,EAAE;UACxCO,YAAY,EAAE;QAChB;MACF,CAAC;MACDC,cAAc,EAAE;QACdJ,KAAK,EAAEV,KAAK,CAACe,mBAAmB;QAChCH,MAAM,yBAAkBZ,KAAK,CAACM,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;AAAC,eAES5B,MAAM;AAAA"}
1
+ {"version":3,"file":"styles.js","names":["styles","props","makeStyles","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;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAM,CAAIC,KAAK;EAAA,OACnB,IAAAC,kBAAU,EAAC,UAACC,KAAK;IAAA,OAAM;MACrBC,KAAK,EAAE;QACLC,cAAc,EAAE,YAAY;QAC5BC,QAAQ,EAAEL,KAAK,CAACK,QAAQ;QACxBC,GAAG,EAAEN,KAAK,CAACO,WAAW;QACtBC,IAAI,EAAE,CAAC;QACPC,MAAM,EAAE;MACV,CAAC;MACDC,aAAa,EAAE;QACbC,KAAK,EAAEX,KAAK,CAACY,kBAAkB;QAC/BC,MAAM,yBAAkBb,KAAK,CAACO,WAAW,QAAK;QAE9C;QACA,wBAAwB,EAAE;UACxBO,SAAS,EAAE;QACb;MACF,CAAC;MACDC,cAAc,EAAE;QACdJ,KAAK,EAAEX,KAAK,CAACgB,mBAAmB;QAChCH,MAAM,yBAAkBb,KAAK,CAACO,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;AAAC,eAESL,MAAM;AAAA"}
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.getAllParents = exports.findRootParentById = exports.findItemById = void 0;
8
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
+ require("core-js/modules/es.object.to-string.js");
10
+ require("core-js/modules/es.array.find.js");
11
+ require("core-js/modules/es.array.filter.js");
12
+ require("core-js/modules/es.array.flat-map.js");
13
+ require("core-js/modules/es.array.unscopables.flat-map.js");
14
+ require("core-js/modules/es.array.concat.js");
15
+ /**
16
+ * Receives the navigation data and the id of the item from which we want to get the root parent.
17
+ *
18
+ * @param {NavigationItem[]} data - The navigation data structure.
19
+ * @param {string} itemId - The item id.
20
+ * @returns The item that is the root parent of the received item.
21
+ */
22
+ var findRootParentById = function findRootParentById(data, itemId) {
23
+ return data.reduce(function (parent, item) {
24
+ if (parent) {
25
+ return parent;
26
+ }
27
+ if (item.id === itemId) {
28
+ return item;
29
+ }
30
+ if (item.data) {
31
+ var found = findRootParentById(item.data, itemId);
32
+ if (found) {
33
+ return item;
34
+ }
35
+ }
36
+ return null;
37
+ }, null);
38
+ };
39
+
40
+ /**
41
+ * Returns the complete item object from the data structure using the item id.
42
+ *
43
+ * @param {NavigationItem[]} data - The navigation data structure.
44
+ * @param {string} itemId - The item id.
45
+ * @returns The complete item object matching the received id.
46
+ */
47
+ exports.findRootParentById = findRootParentById;
48
+ var findItemById = function findItemById(data, itemId) {
49
+ return data.find(function (item) {
50
+ if (item.id === itemId) {
51
+ return true;
52
+ }
53
+ if (item.data && item.data.length > 0) {
54
+ var foundItem = findItemById(item.data, itemId);
55
+ if (foundItem) {
56
+ return true;
57
+ }
58
+ }
59
+ return false;
60
+ });
61
+ };
62
+
63
+ /**
64
+ * Returns all the items that have chilren associated.
65
+ *
66
+ * @param {NavigationItem[]} data - The navigation data structure.
67
+ * @returns All the items that have chilren associated.
68
+ */
69
+ exports.findItemById = findItemById;
70
+ var getAllParents = function getAllParents(items) {
71
+ var parents = items.filter(function (item) {
72
+ return item.data != null && item.data.length > 0;
73
+ });
74
+ var childParents = parents.flatMap(function (item) {
75
+ return getAllParents(item.data);
76
+ });
77
+ return [].concat((0, _toConsumableArray2.default)(parents), (0, _toConsumableArray2.default)(childParents));
78
+ };
79
+ exports.getAllParents = getAllParents;
80
+ //# 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,I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/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;