UNPKG

@dooboostore/dom-render

Version:
84 lines (83 loc) 2.7 kB
import { ComponentBase } from "../ComponentBase.js"; import { DomRender } from "../../DomRender.js"; import { RawSet } from "../../rawsets/RawSet.js"; import { isOnChangeAttrRender } from "../../lifecycle/OnChangeAttrRender.js"; var This; ((_This) => { _This.selector = "dr-this"; class This2 extends 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 (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 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 DomRender.run({ rootObject: new This.This(...counstructorParam), config }); } }); } }; export { This, This_default as default }; //# sourceMappingURL=This.js.map