From 0e275faa81f5eb812abb35da2261f1ed8f6e67de Mon Sep 17 00:00:00 2001 From: Esiur Project Date: Wed, 8 Jun 2022 11:16:54 +0300 Subject: [PATCH] Refs --- build/iui.js | 43 ++++++++++++++++++++++++++---------------- src/Core/IUIElement.js | 3 +-- src/Data/Include.js | 2 +- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/build/iui.js b/build/iui.js index d264b8b..e89a2e4 100644 --- a/build/iui.js +++ b/build/iui.js @@ -2220,7 +2220,7 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) { _classCallCheck(this, Include); _this = _super.call(this); - _this.refs = new _RefsCollection["default"](); + _this.refs = new _RefsCollection["default"](_assertThisInitialized(_this)); return _this; } @@ -3589,7 +3589,7 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_Target) { switch (_context.prev = _context.next) { case 0: dataToQuery = _args.length > 4 && _args[4] !== undefined ? _args[4] : true; - q = url.match(/^\/*(.*?)\?(.*)$|^\/*(.*)$/); //debugger; + q = url.match(/^\/*(.*?)\?(.*)$|^\/*(.*)$/); // do we have a query string ? if (q[2] !== undefined) { @@ -3655,7 +3655,7 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_Target) { if (!(target instanceof _Target2["default"])) target = this; if (state == null) { - id = Math.random().toString(36).substr(2, 10); + id = Math.random().toString(36).substring(2, 12); state = { id: id, url: url, @@ -3771,7 +3771,11 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_Target) { value: function create() { // save origin this.origin = window.location.pathname + window.location.search; - this.base = this.getAttribute("base") || ""; + } + }, { + key: "base", + get: function get() { + return this.getAttribute("base") || ""; } }, { key: "destroy", @@ -3792,9 +3796,9 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_Target) { } } - this._emit("created"); + this._emit("created"); // this.navigate(this.origin); + //console.log("Router created", this); - this.navigate(this.origin); //console.log("Router created", this); } }, { key: "connectedCallback", @@ -5884,16 +5888,20 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) { return _get(_getPrototypeOf(Input.prototype), "setData", this).call(this, value); case 2: - if (this.type == "checkbox") this._input.checked = value;else if (this.type == "date") this._input.value = value != null ? value.toISOString().slice(0, 10) : value;else if (this.type == null || this.type == "text" || this.type == "search" || this.type == "password") this._input.value = value == null ? '' : value;else if (this.type == "file") {// can't set value on file input + if (this.type == "checkbox") this._input.checked = value;else if (this.type == "date") { + this._input.value = value ? value.toISOString().slice(0, 10) : value; + } else if (this.type == "datetime-local") { + this._input.value = value ? value.toISOString().substring(0, 19) : value; + } else if (this.type == null || this.type == "text" || this.type == "search" || this.type == "password") this._input.value = value == null ? "" : value;else if (this.type == "file") {// can't set value on file input } else this._input.value = value; if (this._checkValidity() && this.isAuto) this.revert(); /* - await super.setData(value); - if (value != null && this.field != null) - this.value = value[this.field]; - else if (this.field != null) - this.value = null; - */ + await super.setData(value); + if (value != null && this.field != null) + this.value = value[this.field]; + else if (this.field != null) + this.value = null; + */ case 4: case "end": @@ -5930,7 +5938,7 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) { return _context3.abrupt("return", this._input.checked); case 4: - if (!(this.type == "date")) { + if (!(this.type == "date" || this.type == "datetime-local")) { _context3.next = 8; break; } @@ -5973,7 +5981,7 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) { get: function get() { var _this3 = this; - if (this.type == "checkbox") return this._input.checked;else if (this.type == "date") return new Date(this._input.value);else if (this.type == "file") { + if (this.type == "checkbox") return this._input.checked;else if (this.type == "date" || this.type == "datetime-local") return new Date(this._input.value);else if (this.type == "file") { return new Promise(function (resolve) { _this3._input.files[0].arrayBuffer().then(function (x) { resolve(new Uint8Array(x)); @@ -5997,7 +6005,7 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) { // set value(value) { // if (this.type == "checkbox") // this._input.checked = value; - // else if (this.type == "date") + // else if (this.type == "date") // this._input.value = value != null ? value.toISOString().slice(0, 10) : value; // else if (this.type == null || this.type == "text") // this._input.value = value == null ? '' : value; @@ -9352,6 +9360,9 @@ window.addEventListener("load", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/reg return _IUI.IUI.created(document.body); case 4: + console.log("IUI.create()"); + + case 5: case "end": return _context.stop(); } diff --git a/src/Core/IUIElement.js b/src/Core/IUIElement.js index 20b0b9c..9980131 100644 --- a/src/Core/IUIElement.js +++ b/src/Core/IUIElement.js @@ -18,7 +18,6 @@ export default class IUIElement extends HTMLElement { } this._register("data"); - this._register("rendered"); } static get moduleName(){ @@ -58,7 +57,7 @@ export default class IUIElement extends HTMLElement { this._data = value; this._emit("data", {data: value}); await IUI.render(this, value); - this._emit("rendered", {data: value}); + } diff --git a/src/Data/Include.js b/src/Data/Include.js index a041ccf..288c45d 100644 --- a/src/Data/Include.js +++ b/src/Data/Include.js @@ -7,7 +7,7 @@ export default IUI.module(class Include extends IUIElement constructor() { super(); - this.refs = new RefsCollection(); + this.refs = new RefsCollection(this); } get src(){