@dooboostore/dom-render
Version:
html view template engine
102 lines (101 loc) • 4.39 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 Input_exports = {};
__export(Input_exports, {
Input: () => Input,
default: () => Input_default
});
module.exports = __toCommonJS(Input_exports);
var import_ComponentBase = require("../ComponentBase");
var import_DomRender = require("../../DomRender");
var import_RawSet = require("../../rawsets/RawSet");
var import_core2 = require("@dooboostore/core");
var import_core3 = require("@dooboostore/core");
var import_core_web = require("@dooboostore/core-web");
var Input;
((_Input) => {
_Input.selector = `dr-input`;
class Base extends import_ComponentBase.ComponentBase {
}
_Input.Base = Base;
class Input2 extends Base {
onCreateRender(...param) {
}
async onInitRender(param, rawSet) {
await super.onInitRender(param, rawSet);
const inputElement = this.element;
const debounceTimeAttribute = this.getAttribute("debounceTime");
const debounceTimeValue = import_core2.ValidUtils.isNotNullUndefined(debounceTimeAttribute) ? Number(debounceTimeAttribute) : 0;
const distinct = import_core2.ValidUtils.isNotNullUndefined(this.getAttribute("distinct"));
if (inputElement) {
const makeDeboundceDistinctUtilChanged = () => {
let result$ = import_core_web.EventUtils.htmlElementEventObservable(inputElement, "input").pipe(
import_core3.MessageOperator.map((event) => {
const target = event.target;
if (target instanceof HTMLInputElement) {
return target.value.trim();
}
console.warn("Input event target is not an HTMLInputElement:", target);
return "";
})
);
if (import_core2.ValidUtils.isNotNullUndefined(debounceTimeValue) && debounceTimeValue > 0) {
result$ = result$.pipe(import_core3.MessageOperator.debounceTime(debounceTimeValue));
}
if (import_core2.ValidUtils.isNotNullUndefined(distinct) && distinct === true) {
result$ = result$.pipe(import_core3.MessageOperator.distinctUntilChanged());
}
return result$;
};
this.inputSubscription = makeDeboundceDistinctUtilChanged().subscribe((it) => {
this.getAttribute("input")?.(it, inputElement);
});
if (inputElement.form) {
this.resetSubscripton = import_core_web.EventUtils.htmlElementEventObservable(inputElement.form, "reset").subscribe((it) => {
this.inputSubscription?.unsubscribe();
this.inputSubscription = makeDeboundceDistinctUtilChanged().subscribe((it2) => {
this.getAttribute("input")?.(it2, inputElement);
});
});
}
}
}
onChangeAttrRender(name, value, other) {
super.onChangeAttrRender(name, value, other);
if (name === "value") {
}
}
onDestroyRender(metaData) {
this.resetSubscripton?.unsubscribe();
this.inputSubscription?.unsubscribe();
}
}
_Input.Input = Input2;
})(Input || (Input = {}));
var Input_default = {
input: (config) => {
return import_RawSet.RawSet.createComponentTargetElement({
name: `${Input.selector}`,
template: `<Input type="\${@this@.getAttribute('type')}$" class="\${@this@.getAttribute('class')}$" id="\${@this@.getAttribute('id')}$" name="\${@this@.getAttribute('name')}$" dr-on-init="@this@.element=$element" >#innerHTML#`,
objFactory: (e, o, r2, counstructorParam) => {
return import_DomRender.DomRender.run({ rootObject: new Input.Input(...counstructorParam), config });
}
});
}
};
//# sourceMappingURL=Input.js.map