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.

33 lines 1.56 kB
import { Violation, ViolationState, ViolationInfoResult } from "./Violation"; import { BaseTextItem } from "@aurigma/design-atoms-model/Product/Items"; import { ItemUtils } from "../../../Utils/ItemUtils"; import { HandlerFactoryByItem } from "../../../ItemHandlers"; export class TextInPlaceViolation extends Violation { constructor(_productHandler, _messages) { super(); this._productHandler = _productHandler; this._messages = _messages; this._reasonPlaceholder = "[REASON_PLACEHOLDER]"; } isAvailableFor(item) { return item instanceof BaseTextItem; } getViolationInfo(item) { var _a; if (!ItemUtils.isTextItemHandlerReady(item, this._productHandler)) return ViolationInfoResult.none; if (!item.violationSettings.allowInPlaceText) return ViolationInfoResult.good; const reasons = HandlerFactoryByItem.getUseLegacyTextReasons(item); if (reasons.length === 0) return ViolationInfoResult.good; const violationState = ViolationState.Warning; const message = (_a = this._messages.inPlaceNotSupportedWarning) === null || _a === void 0 ? void 0 : _a.replace(this._reasonPlaceholder, reasons.join(", ")); return { state: violationState, message: message }; } getStatePropertyName() { return TextInPlaceViolation.statePropertyName; } } TextInPlaceViolation.statePropertyName = "textInPlaceViolationState"; //# sourceMappingURL=TextInPlaceViolation.js.map