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.

125 lines 4.95 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; import { ArgumentNullException } from "../../Exception"; import { EventObject } from "../../EventObject"; import { Property } from "../Decorators/Property"; import { equals } from "../../Utils/Utils"; import { arraysIsEqual } from "@aurigma/utils-js/algorithms/array"; export class ResizeGripsPermissions { set edgeConstraint(value) { const oldVal = this.edge; this._edgeConstraint = value; if (this.edge !== oldVal) this.propertyChanged.notify(); } get edge() { return this._edgeConstraint != null ? this._edgeConstraint : this._edge; } set edge(value) { if (this._edge === value) return; this._edge = value; this.propertyChanged.notify(); } get corner() { return this._corner; } set corner(value) { if (value == null) { throw new ArgumentNullException("corner cannot be null"); } if (this._corner === value) return; this._corner = value; this.propertyChanged.notify(); } constructor(proportional, arbitrary, arbitraryFirst = true) { this._edgeConstraint = null; this._cornerArbitraryConstraint = null; this.propertyChanged = new EventObject(); this.type = ResizeGripsPermissions.type; this.edge = arbitrary; this._setCornerValues(proportional, arbitrary, arbitraryFirst); } _setCornerValues(proportional, arbitrary, arbitraryFirst) { if (proportional && arbitrary) { this.corner = arbitraryFirst ? [ResizeGripsPermissions.arbitrary, ResizeGripsPermissions.proportional] : [ResizeGripsPermissions.proportional, ResizeGripsPermissions.arbitrary]; } else if (proportional) { this.corner = [ResizeGripsPermissions.proportional]; } else if (arbitrary) { this.corner = [ResizeGripsPermissions.arbitrary]; } else { this.corner = []; } } getCornerProportional() { return this.corner.includes(ResizeGripsPermissions.proportional); } getCornerArbitrary() { return this._cornerArbitraryConstraint != null ? this._cornerArbitraryConstraint : this.corner.includes(ResizeGripsPermissions.arbitrary); } setCornerProportional(value) { const arb = this.getCornerArbitrary(); this._setCornerValues(value, arb, true); } setCornerArbitrary(value) { const prop = this.getCornerProportional(); this._setCornerValues(prop, value, true); } setCornerArbitraryConstraint(value) { const oldVal = this.getCornerArbitrary(); this._cornerArbitraryConstraint = value; if (this.getCornerArbitrary() !== oldVal) this.propertyChanged.notify(); } clone() { const result = new ResizeGripsPermissions(true, true); result.edge = this.edge; result.corner = this.corner.slice(); return result; } equals(p) { return this.edge === p.edge && arraysIsEqual(this.corner, p.corner, equals); } get data() { return { Edge: this.edge, Corner: this.corner }; } static _fromData(data) { if (data == null) return new ResizeGripsPermissions(false, false); const result = new ResizeGripsPermissions(true, true); result.corner = data.Corner; result.edge = data.Edge; return result; } getSimplifiedObject() { const result = {}; result["edge"] = this.edge; result["corner"] = this.corner; return result; } } ResizeGripsPermissions.arbitrary = "Arbitrary"; ResizeGripsPermissions.proportional = "Proportional"; ResizeGripsPermissions.type = "ResizeGripsPermissions"; __decorate([ Property({ ignore: true }), __metadata("design:type", Boolean), __metadata("design:paramtypes", [Boolean]) ], ResizeGripsPermissions.prototype, "edgeConstraint", null); //# sourceMappingURL=ResizeGripsPermissions.js.map