@aurigma/design-atoms
Version:
Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.
50 lines • 2.5 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 { HandlerFactoryByItem } from "../../../ItemHandlers";
var TextInPlaceViolation = /** @class */ (function (_super) {
__extends(TextInPlaceViolation, _super);
function TextInPlaceViolation(_productHandler, _messages) {
var _this = _super.call(this) || this;
_this._productHandler = _productHandler;
_this._messages = _messages;
_this._reasonPlaceholder = "[REASON_PLACEHOLDER]";
return _this;
}
TextInPlaceViolation.prototype.isAvailableFor = function (item) {
return item instanceof BaseTextItem;
};
TextInPlaceViolation.prototype.getViolationInfo = function (item) {
var _a;
if (!ItemUtils.isTextItemHandlerReady(item, this._productHandler))
return ViolationInfoResult.none;
if (!item.violationSettings.allowInPlaceText)
return ViolationInfoResult.good;
var reasons = HandlerFactoryByItem.getUseLegacyTextReasons(item);
if (reasons.length === 0)
return ViolationInfoResult.good;
var violationState = ViolationState.Warning;
var message = (_a = this._messages.inPlaceNotSupportedWarning) === null || _a === void 0 ? void 0 : _a.replace(this._reasonPlaceholder, reasons.join(", "));
return { state: violationState, message: message };
};
TextInPlaceViolation.prototype.getStatePropertyName = function () {
return TextInPlaceViolation.statePropertyName;
};
TextInPlaceViolation.statePropertyName = "textInPlaceViolationState";
return TextInPlaceViolation;
}(Violation));
export { TextInPlaceViolation };
//# sourceMappingURL=TextInPlaceViolation.js.map