UNPKG

@dooboostore/dom-render

Version:
100 lines (99 loc) 3.16 kB
import { ComponentBase } from "../ComponentBase.js"; import { DomRender } from "../../DomRender.js"; import { RawSet } from "../../rawsets/RawSet.js"; var Choose; ((_Choose) => { _Choose.selector = "dr-choose"; class ChildOtherWiseBase extends ComponentBase { constructor() { super(...arguments); this.hidden = true; } } class ChildBase extends ChildOtherWiseBase { } class When extends ChildBase { constructor() { super({ onlyParentType: Choose2 }); } } _Choose.When = When; class OtherWise extends ChildBase { constructor() { super({ onlyParentType: Choose2 }); } } _Choose.OtherWise = OtherWise; class Choose2 extends ComponentBase { onCreatedThisChild(child, data) { super.onCreatedThisChild(child, data); this.setChange(child); } onChangeAttrRender(name, value, other) { super.onChangeAttrRender(name, value, other); if (this.equalsAttributeName(name, "data")) { this.choose = void 0; const children = this.getChildren([When, OtherWise]).sort( (a, b) => (a instanceof OtherWise ? 1 : 0) - (b instanceof OtherWise ? 1 : 0) ); children.forEach((it) => this.setChange(it)); } } setChange(child) { child.data = this.getAttribute("data"); console.log("eeeeeee?", child, child.getAttribute("test"), this.getAttribute("data")); if (!this.choose && child instanceof When && child.getAttribute("test")?.(this.getAttribute("data"))) { console.log("eeeeeee?2"); this.choose = child; if (child.hidden) { child.hidden = false; } } else if (this.choose !== child) { child.hidden = true; } console.log("eeeeeee?3"); if (!this.choose && child instanceof OtherWise) { this.choose = child; if (child.hidden) { child.hidden = false; } } console.log("eeeeeee?34"); } } _Choose.Choose = Choose2; })(Choose || (Choose = {})); var Choose_default = { chooseWhen: (config) => { return RawSet.createComponentTargetElement({ name: `${Choose.selector}-when`, template: '<div dr-if="!@this@.hidden" dr-option-strip="true" >#innerHTML#</div>', objFactory: (e, o, r2, counstructorParam) => { return DomRender.run({ rootObject: new Choose.When(), config }); } }); }, chooseOtherWise: (config) => { return RawSet.createComponentTargetElement({ name: `${Choose.selector}-other-wise`, template: '<div dr-if="!@this@.hidden" dr-option-strip="true" >#innerHTML#</div>', objFactory: (e, o, r2, counstructorParam) => { return DomRender.run({ rootObject: new Choose.OtherWise(), config }); } }); }, choose: (config) => { return RawSet.createComponentTargetElement({ name: `${Choose.selector}`, template: "#innerHTML#", objFactory: (e, o, r2, counstructorParam) => { return DomRender.run({ rootObject: new Choose.Choose(...counstructorParam), config }); } }); } }; export { Choose, Choose_default as default }; //# sourceMappingURL=Choose.js.map