UNPKG

@aurigma/design-atoms

Version:

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

58 lines 2.99 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 { Violation, ViolationState, ViolationInfoResult } from "./Violation"; import { ImageItem, PlaceholderItem } from "@aurigma/design-atoms-model/Product/Items"; import { ValidationSeverity } from "../../../Viewer/Interfaces"; import { ItemUtils } from "../../../Utils/ItemUtils"; import { SurfaceContainer } from "@aurigma/design-atoms-model/Product/Container"; var RasterElementsViolation = /** @class */ (function (_super) { __extends(RasterElementsViolation, _super); function RasterElementsViolation(_messages, _conf) { var _a, _b; var _this = _super.call(this) || this; _this._messages = _messages; _this._conf = _conf; _this._severity = (_b = (_a = _conf.rasterElements) === null || _a === void 0 ? void 0 : _a.severity) !== null && _b !== void 0 ? _b : ValidationSeverity.Warning; return _this; } RasterElementsViolation.prototype.isAvailableFor = function (item) { return item instanceof ImageItem || item instanceof PlaceholderItem; }; RasterElementsViolation.prototype.getViolationInfo = function (item) { var _a, _b; var image = ItemUtils.getImageItem(item); if (!image || !((_a = image.source) === null || _a === void 0 ? void 0 : _a.id)) { return ViolationInfoResult.none; } var parentContainer = item.parentContainer; if (!(parentContainer instanceof SurfaceContainer) || ((_b = parentContainer.printingTechniqueConstraints) === null || _b === void 0 ? void 0 : _b.allowRasterElements) !== false) { return ViolationInfoResult.good; } var isVector = image.source.isVector; if (isVector) { return ViolationInfoResult.good; } var violationState = this._severity === ValidationSeverity.Error ? ViolationState.Bad : ViolationState.Warning; return { state: violationState, message: this._messages.rasterElementsViolationWarning }; }; RasterElementsViolation.prototype.getStatePropertyName = function () { return RasterElementsViolation.statePropertyName; }; RasterElementsViolation.statePropertyName = "rasterElementsViolationState"; return RasterElementsViolation; }(Violation)); export { RasterElementsViolation }; //# sourceMappingURL=RasterElementsViolation.js.map