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.

67 lines 2.65 kB
import { ArgumentException } from "../Exception"; import * as Utils from "../Utils/Utils"; var Color = /** @class */ (function () { function Color(value) { this._previewFromServer = false; this.preview = null; this.profileId = null; if (value == null) return; if (!Utils.isNullOrEmptyOrWhiteSpace(value.preview)) this._previewFromServer = true; if (typeof value != "string") this._init(value); } Object.defineProperty(Color.prototype, "previewFromServer", { get: function () { return this._previewFromServer; }, enumerable: true, configurable: true }); Color.prototype.needUpdate = function (defaultRgbProfileId) { var isRgb = this.type === "RgbColor"; var isNonDefaultRgb = isRgb && this.profileId != null && this.profileId !== defaultRgbProfileId; return (!isRgb || isNonDefaultRgb) && !this.previewFromServer; }; Color.prototype.equals = function (color, ignorePreview) { if (ignorePreview === void 0) { ignorePreview = false; } return color.profileId === this.profileId && (ignorePreview || color.preview === this.preview); }; Color.prototype.getData = function () { var data = { preview: this.preview, profileId: this.profileId, type: this.type }; return data; }; Color.prototype._init = function (colorObject) { if (!Utils.isNullOrEmptyOrWhiteSpace(colorObject.preview)) this.preview = colorObject.preview; if (!Utils.isNullOrEmptyOrWhiteSpace(colorObject.profileId)) this.profileId = colorObject.profileId; }; Color.prototype._validateString = function (value) { if (Utils.isNullOrEmptyOrWhiteSpace(value)) throw new ArgumentException("Value must be a non-empty string"); }; Color.prototype._validateNumber = function (value, min, max) { if (min === void 0) { min = 0; } if (max === void 0) { max = 255; } if (typeof value != "number") throw new ArgumentException("Value must be a number"); if (value < min || value > max) throw new ArgumentException("Value must be in range [" + min + ", " + max + "]"); }; Color.equals = function (a, b) { if (a == null && b == null) return true; if (a != null) return a.equals(b); return false; }; return Color; }()); export { Color }; //# sourceMappingURL=Color.js.map