UNPKG

@dooboostore/dom-render

Version:
90 lines (89 loc) 3.14 kB
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); }; import { attribute, ComponentBase } from "../ComponentBase.js"; import { DomRender } from "../../DomRender.js"; import { RawSet } from "../../rawsets/RawSet.js"; import { DomRenderNoProxy } from "../../decorators/DomRenderNoProxy.js"; var Route; (function(Route2) { Route2.selector = "dr-route"; class CheckerBase extends ComponentBase { constructor(domRenderConfig) { super(); this.sw = false; this.inputDomRenderConfig = domRenderConfig; } async onInitRender(param, rawSet) { await super.onInitRender(param, rawSet); this.routerSubscription = this.inputDomRenderConfig?.router?.observable.subscribe((it) => { if (this.value && this.inputDomRenderConfig) { this.sw = this.check(this.inputDomRenderConfig); } else { this.sw = false; } }); } onDrThisBind() { super.onDrThisBind(); } onDrThisUnBind() { super.onDrThisUnBind(); } onDestroyRender(data) { super.onDestroyRender(data); this.routerSubscription?.unsubscribe(); } } __decorate([ attribute({ name: "value" }), __metadata("design:type", String) ], CheckerBase.prototype, "value", void 0); __decorate([ DomRenderNoProxy, __metadata("design:type", Object) ], CheckerBase.prototype, "inputDomRenderConfig", void 0); class Match extends CheckerBase { check(config) { return !!config?.router?.test(this.value); } } Route2.Match = Match; class Regexp extends CheckerBase { check(config) { return !!config?.router?.testRegexp(this.value); } } Route2.Regexp = Regexp; })(Route || (Route = {})); var Route_default = { match: (config) => { return RawSet.createComponentTargetElement({ name: `${Route.selector}-match`, template: '<div dr-if="@this@.sw" dr-option-strip="true">#innerHTML#</div>', objFactory: (e, o, r2, counstructorParam) => { return DomRender.run({ rootObject: new Route.Match(config), config }); } }); }, regexp: (config) => { return RawSet.createComponentTargetElement({ name: `${Route.selector}-regexp`, template: '<div dr-if="@this@.sw" dr-option-strip="true">#innerHTML#</div>', objFactory: (e, o, r2, counstructorParam) => { return DomRender.run({ rootObject: new Route.Regexp(config), config }); } }); } }; export { Route, Route_default as default }; //# sourceMappingURL=Route.js.map