UNPKG

@aurigma/design-atoms-model

Version:

Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.

84 lines 3.8 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); import { ModelComponent } from "./ModelComponent"; import { Collection } from "../Collection"; var SurfaceMockup = /** @class */ (function (_super) { __extends(SurfaceMockup, _super); function SurfaceMockup(downContainers, upContainers) { if (downContainers === void 0) { downContainers = []; } if (upContainers === void 0) { upContainers = []; } var _this = _super.call(this) || this; _this.parentSurface = null; _this._underContainers = new Collection(); _this._overContainers = new Collection(); _this._onContainerAdded = function (_a) { var container = _a.item; container.parentComponent = _this; }; _this.underContainers.add_itemAdded(_this._onContainerAdded); _this.underContainers.setRange(downContainers); _this.overContainers.add_itemAdded(_this._onContainerAdded); _this.overContainers.setRange(upContainers); return _this; } SurfaceMockup.prototype.isEmpty = function () { return this.underContainers .concat(this.overContainers) .all(function (c) { return c.items.empty; }); }; Object.defineProperty(SurfaceMockup.prototype, "underContainers", { get: function () { return this._underContainers; }, enumerable: true, configurable: true }); Object.defineProperty(SurfaceMockup.prototype, "overContainers", { get: function () { return this._overContainers; }, enumerable: true, configurable: true }); Object.defineProperty(SurfaceMockup.prototype, "allContainers", { get: function () { return this._overContainers.concat(this._underContainers); }, enumerable: true, configurable: true }); SurfaceMockup.prototype.getSimplifiedObject = function () { var simplified = _super.prototype.getSimplifiedObject.call(this, ["parentSurface", "allContainers"]); return simplified; }; SurfaceMockup.prototype.clone = function (generateNewIds) { if (generateNewIds === void 0) { generateNewIds = false; } var surfaceMockup = new SurfaceMockup(); this._copy(this, surfaceMockup, generateNewIds); return surfaceMockup; }; SurfaceMockup.prototype.generateNewIds = function () { this._generateNewId(); this._underContainers.forEach(function (i) { return i.generateNewIds(); }); this._overContainers.forEach(function (i) { return i.generateNewIds(); }); }; SurfaceMockup.prototype._copy = function (source, destination, generateNewIds) { _super.prototype._copy.call(this, source, destination, generateNewIds); destination.underContainers.addRange(source.underContainers.toArray().map(function (c) { return c.clone(generateNewIds); })); destination.overContainers.addRange(source.overContainers.toArray().map(function (c) { return c.clone(generateNewIds); })); }; return SurfaceMockup; }(ModelComponent)); export { SurfaceMockup }; //# sourceMappingURL=SurfaceMockup.js.map