UNPKG

@dooboostore/dom-render

Version:
103 lines (102 loc) 3.68 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 This_exports = {}; __export(This_exports, { This: () => This, default: () => This_default }); module.exports = __toCommonJS(This_exports); var import_ComponentBase = require("../ComponentBase"); var import_DomRender = require("../../DomRender"); var import_RawSet = require("../../rawsets/RawSet"); var import_OnChangeAttrRender = require("../../lifecycle/OnChangeAttrRender"); var This; ((_This) => { _This.selector = "dr-this"; class This2 extends import_ComponentBase.ComponentBase { constructor() { super(...arguments); this.if = null; this.sw = false; } setValue(value) { this.sw = false; setTimeout(() => { this.value = value; }, 0); setTimeout(() => { this.sw = true; }, 0); } async onInitRender(param, rawSet) { await super.onInitRender(param, rawSet); } onDestroyRender(data) { super.onDestroyRender(data); } onDestroy() { super.onDestroy(); } onChangeAttrRender(name, value, other) { super.onChangeAttrRender(name, value, other); if (this.equalsAttributeName(name, "value")) { this.setValue(value); } if (this.equalsAttributeName(name, "if")) { this.if = value; } if (this.equalsAttributeName(name, "createArguments")) { this.createArguments = value; } } created($component, $rawSet) { this.childObject = $component ?? ($component = this.value?.obj); this.childRawSet = $rawSet; if ($component) { this.getAttribute("onCreated")?.($component); if ((0, import_OnChangeAttrRender.isOnChangeAttrRender)($component)) { this.getAttributeNames().filter((it) => it.startsWith("attribute-")).forEach((it) => { var _a; const attrName = it.replace(/^attribute-/, ""); const attrValue = this.getAttribute(it); (_a = $rawSet.dataSet.render).attribute ?? (_a.attribute = {}); $rawSet.dataSet.render.attribute[attrName] = attrValue; $component.onChangeAttrRender(attrName, attrValue, { rawSet: $rawSet }); }); } } } } _This.This = This2; })(This || (This = {})); var This_default = { this: (config) => { return import_RawSet.RawSet.createComponentTargetElement({ name: This.selector, template: ` <dr-if value="\${@this@.sw}$"> <div dr-this="@this@.value" dr-detect-option-if="@this@?.value && @this@?.if" dr-option-strip="true" dr-on-create:arguments="@this@.createArguments" dr-on-create:callback="@this@?.created?.($component, $rawSet)">#innerHTML#</div> </dr-if> `, objFactory: (e, o, r2, counstructorParam) => { return import_DomRender.DomRender.run({ rootObject: new This.This(...counstructorParam), config }); } }); } }; //# sourceMappingURL=This.js.map