@dooboostore/dom-render
Version:
html view template engine
119 lines (118 loc) • 4.19 kB
JavaScript
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 Choose_exports = {};
__export(Choose_exports, {
Choose: () => Choose,
default: () => Choose_default
});
module.exports = __toCommonJS(Choose_exports);
var import_ComponentBase = require("../ComponentBase");
var import_DomRender = require("../../DomRender");
var import_RawSet = require("../../rawsets/RawSet");
var Choose;
((_Choose) => {
_Choose.selector = "dr-choose";
class ChildOtherWiseBase extends import_ComponentBase.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 import_ComponentBase.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 import_RawSet.RawSet.createComponentTargetElement({
name: `${Choose.selector}-when`,
template: '<div dr-if="!@this@.hidden" dr-option-strip="true" >#innerHTML#</div>',
objFactory: (e, o, r2, counstructorParam) => {
return import_DomRender.DomRender.run({ rootObject: new Choose.When(), config });
}
});
},
chooseOtherWise: (config) => {
return import_RawSet.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 import_DomRender.DomRender.run({ rootObject: new Choose.OtherWise(), config });
}
});
},
choose: (config) => {
return import_RawSet.RawSet.createComponentTargetElement({
name: `${Choose.selector}`,
template: "#innerHTML#",
objFactory: (e, o, r2, counstructorParam) => {
return import_DomRender.DomRender.run({ rootObject: new Choose.Choose(...counstructorParam), config });
}
});
}
};
//# sourceMappingURL=Choose.js.map