@aurigma/design-atoms
Version:
Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.
53 lines • 2.57 kB
JavaScript
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 { BaseTextItem } from "@aurigma/design-atoms-model/Product/Items";
import { ItemUtils } from "../../../Utils/ItemUtils";
import { NewBaseTextItemHandler } from "../../../ItemHandlers";
var TextCropViolation = /** @class */ (function (_super) {
__extends(TextCropViolation, _super);
function TextCropViolation(_productHandler, _messages) {
var _this = _super.call(this) || this;
_this._productHandler = _productHandler;
_this._messages = _messages;
_this.prepareItem = function (item) {
if (!(item instanceof BaseTextItem))
return;
item.checkTextCrop = true;
};
return _this;
}
TextCropViolation.prototype.isAvailableFor = function (item) {
return item instanceof BaseTextItem;
};
TextCropViolation.prototype.getViolationInfo = function (item) {
if (!ItemUtils.isTextItemHandlerReady(item, this._productHandler))
return ViolationInfoResult.none;
if (!item.violationSettings.allowTextCrop)
return ViolationInfoResult.good;
var handler = this._productHandler.getHandler(item);
if (handler instanceof NewBaseTextItemHandler && handler.isInEdit)
return ViolationInfoResult.none;
var violationState = handler.textCropped ? ViolationState.Warning : ViolationState.Good;
var message = violationState === ViolationState.Warning ? this._messages.textCropWarning : null;
return { state: violationState, message: message };
};
TextCropViolation.prototype.getStatePropertyName = function () {
return TextCropViolation.statePropertyName;
};
TextCropViolation.statePropertyName = "textCropViolationState";
return TextCropViolation;
}(Violation));
export { TextCropViolation };
//# sourceMappingURL=TextCropViolation.js.map