@relax.dev/router
Version:
Router for VKUI
55 lines (54 loc) • 3.51 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Page = void 0;
var _const = require("../const");
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
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); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var Page = /*#__PURE__*/function () {
function Page(panelId, viewId, rootId) {
_classCallCheck(this, Page);
_defineProperty(this, "panelId", void 0);
_defineProperty(this, "viewId", void 0);
_defineProperty(this, "rootId", void 0);
_defineProperty(this, "additionalViews", []);
_defineProperty(this, "isInfinityPanel", false);
this.panelId = panelId || _const.PANEL_MAIN;
this.viewId = viewId || _const.VIEW_MAIN;
this.rootId = rootId || _const.ROOT_MAIN;
}
_createClass(Page, [{
key: "clone",
value: function clone() {
var p = new Page(this.panelId, this.viewId, this.rootId).addViews(this.additionalViews);
p.isInfinityPanel = this.isInfinityPanel;
return p;
}
}, {
key: "makeInfinity",
value: function makeInfinity() {
this.isInfinityPanel = true;
return this;
}
}, {
key: "addViews",
value: function addViews(views) {
this.additionalViews = _toConsumableArray(views);
if (this.additionalViews.length > 0 && !this.additionalViews.includes(this.viewId)) {
this.additionalViews.push(this.viewId);
}
return this;
}
}]);
return Page;
}();
exports.Page = Page;