VerticalNavbar.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _react = _interopRequireDefault(require("react"));
  7. var _modularityFront = _interopRequireDefault(require("modularity-front"));
  8. var _reactMaterialize = require("react-materialize");
  9. var _reactSidenav = _interopRequireWildcard(require("@trendmicro/react-sidenav"));
  10. require("./VerticalNavbar.css");
  11. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
  12. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  13. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  14. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  15. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  16. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  17. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  18. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  19. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  20. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  21. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  22. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  23. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  24. var Module = _modularityFront.default.Module;
  25. var Link = _modularityFront.default.Modules.Link;
  26. var VerticalNavbar =
  27. /*#__PURE__*/
  28. function (_Modularity$Module) {
  29. _inherits(VerticalNavbar, _Modularity$Module);
  30. function VerticalNavbar(props) {
  31. var _this;
  32. _classCallCheck(this, VerticalNavbar);
  33. _this = _possibleConstructorReturn(this, _getPrototypeOf(VerticalNavbar).call(this, props));
  34. _this.state = {};
  35. return _this;
  36. }
  37. _createClass(VerticalNavbar, [{
  38. key: "render",
  39. value: function render() {
  40. var _this2 = this;
  41. var selectedNavItem = "home";
  42. var url = this.RoutingSystem.getRoute().url;
  43. var navitems = this.NavItems.value.map(function (item, indx) {
  44. if (url.includes(item.link)) {
  45. selectedNavItem = item.link;
  46. }
  47. return _react.default.createElement(_reactSidenav.NavItem, {
  48. key: item.text + item.link,
  49. eventKey: item.link
  50. }, _react.default.createElement(_reactSidenav.NavIcon, null, _react.default.createElement("i", {
  51. className: "fa fa-fw " + item.icon,
  52. style: {
  53. fontSize: '1.75em'
  54. }
  55. })), _react.default.createElement(_reactSidenav.NavText, null, item.text));
  56. });
  57. return _react.default.createElement(_reactSidenav.default, {
  58. onSelect: function onSelect(eventKey, event) {
  59. _this2.CoreSystem.go(eventKey);
  60. },
  61. defaultExpanded: this.Expanded.value
  62. }, _react.default.createElement(_reactSidenav.default.Nav, {
  63. selected: selectedNavItem
  64. }, navitems), _get(_getPrototypeOf(VerticalNavbar.prototype), "render", this).call(this, false));
  65. }
  66. }]);
  67. return VerticalNavbar;
  68. }(_modularityFront.default.Module);
  69. VerticalNavbar.Inputs = {
  70. Expanded: {
  71. type: Module.Types.Boolean,
  72. defaultValue: true
  73. },
  74. NavItems: {
  75. type: Module.Types.Array,
  76. defaultValue: [{
  77. link: "home",
  78. text: "Home",
  79. icon: "fa-home"
  80. }, {
  81. link: "products",
  82. text: "Products",
  83. icon: "fa-product"
  84. }, {
  85. link: "products",
  86. text: "Products",
  87. icon: "fa-product"
  88. }],
  89. arrType: Module.Types.Object
  90. }
  91. };
  92. VerticalNavbar.Category = "sxoinas";
  93. VerticalNavbar.EditPosition = "center";
  94. var _default = VerticalNavbar;
  95. exports.default = _default;