UNPKG

@dooboostore/dom-render

Version:
141 lines (140 loc) 5.4 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var A_exports = {}; __export(A_exports, { A: () => A, default: () => A_default }); module.exports = __toCommonJS(A_exports); var import_ComponentBase = require("../ComponentBase"); var import_DomRender = require("../../DomRender"); var import_RawSet = require("../../rawsets/RawSet"); var __decorate = function(decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = function(k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var A; (function(A_1) { A_1.selector = "dr-a"; class A2 extends import_ComponentBase.ComponentBase { constructor() { super(...arguments); this.href = null; this.target = null; this.style = null; this.classAttr = null; this.drClass = null; this.click = null; this.replace = false; this.scrollToTop = true; } onClick(event) { if (this.click) { const attributes = { href: this.href, target: this.target, style: this.style, class: this.classAttr, replace: this.replace, scrollToTop: this.scrollToTop }; this.click({ event, attributes }); } if (event.defaultPrevented) { return; } if (this.target !== "_blank" && this.href) { event.preventDefault(); this.domRenderConfig?.router?.go({ path: this.href, replace: this.replace, scrollToTop: this.scrollToTop }); } } onChangeAttrRender(name, value, other) { super.onChangeAttrRender(name, value, other); if (this.element && name.startsWith("attribute-")) { this.element.setAttribute(name, value); } } onAElementInit($element) { this.element = $element; this.getAttribute("onInit")?.($element); this.getAttributeNames().filter((it) => it.startsWith("attribute-")).forEach((it) => { const attrName = it.replace(/^attribute-/, ""); const attrValue = this.getAttribute(it); this.element.setAttribute(attrName, attrValue); }); } } __decorate([ (0, import_ComponentBase.attribute)({ converter: (v) => v || null }), __metadata("design:type", String) ], A2.prototype, "href", void 0); __decorate([ (0, import_ComponentBase.attribute)({ converter: (v) => v || null }), __metadata("design:type", String) ], A2.prototype, "target", void 0); __decorate([ (0, import_ComponentBase.attribute)({ converter: (v) => v || null }), __metadata("design:type", String) ], A2.prototype, "style", void 0); __decorate([ (0, import_ComponentBase.attribute)({ name: "class", converter: (v) => v || null }), __metadata("design:type", String) ], A2.prototype, "classAttr", void 0); __decorate([ (0, import_ComponentBase.attribute)({ name: "dr-class", converter: (v) => v || null }), __metadata("design:type", String) ], A2.prototype, "drClass", void 0); __decorate([ (0, import_ComponentBase.attribute)(), __metadata("design:type", Function) ], A2.prototype, "click", void 0); __decorate([ (0, import_ComponentBase.attribute)({ converter: (v) => v !== null && String(v) !== "false" }), __metadata("design:type", Object) ], A2.prototype, "replace", void 0); __decorate([ (0, import_ComponentBase.attribute)({ converter: (v) => v !== null && String(v) !== "false" }), __metadata("design:type", Object) ], A2.prototype, "scrollToTop", void 0); A_1.A = A2; })(A || (A = {})); var A_default = { a: (config) => { return import_RawSet.RawSet.createComponentTargetElement({ name: A.selector, template: `<a href="\${@this@.href}$" target="\${@this@.target}$" style="\${@this@.style}$" class="\${@this@.classAttr}$" dr-event-click="@this@.onClick($event)" dr-class="\${@this@.drClass}$" dr-on-init="@this@.onAElementInit($element)" >#innerHTML#</a>`, objFactory: (e, o, r2, constructorParam) => { return import_DomRender.DomRender.run({ rootObject: new A.A(...constructorParam), config }); } }); } }; //# sourceMappingURL=A.js.map