UNPKG

2.18 kBJavaScriptView Raw
1"use strict";
2
3var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
4
5Object.defineProperty(exports, "__esModule", {
6 value: true
7});
8exports.default = void 0;
9
10var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/extends"));
11
12var _objectSpread2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/objectSpread"));
13
14var _react = _interopRequireDefault(require("react"));
15
16var _reactRouterDom = require("react-router-dom");
17
18var _List = _interopRequireDefault(require("@material-ui/core/List"));
19
20var _DrawerItem = _interopRequireDefault(require("./DrawerItem"));
21
22var _propTypes = _interopRequireDefault(require("prop-types"));
23
24/* eslint-disable import/no-extraneous-dependencies */
25var mergeNavItems = function mergeNavItems(navItemPairs) {
26 return navItemPairs.map(function (i) {
27 return Array.isArray(i) ? (0, _objectSpread2.default)({}, i[0], i[1]) : i;
28 });
29};
30
31var NavList = function NavList(_ref) {
32 var navItems = _ref.navItems;
33 return _react.default.createElement(_List.default, null, mergeNavItems(navItems).map(function (_ref2) {
34 var path = _ref2.path,
35 label = _ref2.title,
36 Icon = _ref2.Icon,
37 hardLink = _ref2.hardLink,
38 newTab = _ref2.newTab;
39 return hardLink || newTab ? _react.default.createElement("a", (0, _extends2.default)({
40 href: path,
41 key: path
42 }, newTab ? {
43 target: '_blank'
44 } : {}), _react.default.createElement(_DrawerItem.default, {
45 label: label,
46 icon: Icon
47 })) : _react.default.createElement(_reactRouterDom.Link, {
48 to: path,
49 key: path
50 }, _react.default.createElement(_DrawerItem.default, {
51 label: label,
52 icon: Icon
53 }));
54 }));
55};
56
57NavList.propTypes = {
58 navItems: _propTypes.default.arrayOf(function (props, propName, componentName) {
59 if (!Object.prototype.hasOwnProperty.call(props, propName)) {
60 throw new Error("Prop `".concat(propName, "` has type 'any' or 'mixed', but was not provided to `").concat(componentName, "`. Pass undefined or any other value."));
61 }
62 }).isRequired
63};
64var _default = NavList;
65exports.default = _default;
\No newline at end of file