From 4b2a3f38349113e342759b1a70b8476fc26df838 Mon Sep 17 00:00:00 2001 From: Ahmed Zamil Date: Wed, 10 Jul 2024 23:36:25 +0300 Subject: [PATCH] radix --- build/iui.js | 241 ++++++++++++++++++++------------------- package.json | 2 +- src/Core/Binding.js | 29 ++--- src/Core/IUI.js | 12 +- src/Core/IUIElement.js | 4 +- src/Data/Form.js | 4 +- src/Data/Repeat.js | 24 ++-- src/Router/Route.js | 4 +- src/UI/Check.js | 4 +- src/UI/DateTimePicker.js | 15 ++- src/UI/DropDown.js | 6 +- src/UI/Input.js | 4 +- src/UI/Select.js | 4 +- src/UI/Table.js | 4 +- 14 files changed, 188 insertions(+), 169 deletions(-) diff --git a/build/iui.js b/build/iui.js index fc515da..8c035e3 100644 --- a/build/iui.js +++ b/build/iui.js @@ -185,7 +185,7 @@ var Binding = /*#__PURE__*/function () { var proxy = new Proxy(map, detector); try { - var d = this.func.apply(thisArg, [proxy, proxy, {}, true].concat(_toConsumableArray(this.scopeValues))); + var d = this.func.apply(thisArg, [proxy, proxy, null, {}, true].concat(_toConsumableArray(this.scopeValues))); this.map = map; return d; } catch (ex) { @@ -196,7 +196,7 @@ var Binding = /*#__PURE__*/function () { }, { key: "_execute", value: function () { - var _execute2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(thisArg, data) { + var _execute2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(thisArg, data, radix) { var context, rt; return regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { @@ -204,7 +204,7 @@ var Binding = /*#__PURE__*/function () { case 0: if (!this.checked) this._findMap(thisArg); context = {}; - rt = this.func.apply(thisArg, [data, data, context, false].concat(_toConsumableArray(this.scopeValues))); + rt = this.func.apply(thisArg, [data, data, radix, context, false].concat(_toConsumableArray(this.scopeValues))); if (!(rt instanceof Promise)) { _context2.next = 6; @@ -273,7 +273,7 @@ var Binding = /*#__PURE__*/function () { }, _callee2, this, [[17, 23]]); })); - function _execute(_x, _x2) { + function _execute(_x, _x2, _x3) { return _execute2.apply(this, arguments); } @@ -316,7 +316,7 @@ var Binding = /*#__PURE__*/function () { }, { key: "render", value: function () { - var _render = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(data) { + var _render = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(data, radix) { var d, _d, _window, _window$app, targetElement, _d2, _targetElement$__i_bi, _targetElement$__i_bi2, _targetElement$__i_bi3, _targetElement$__i_bi4, _d3, _d4, _d5, _d6, _d7; return regeneratorRuntime.wrap(function _callee3$(_context3) { @@ -333,7 +333,7 @@ var Binding = /*#__PURE__*/function () { } _context3.next = 5; - return this._execute(this.target, data); + return this._execute(this.target, data, radix); case 5: d = _context3.sent; @@ -352,7 +352,7 @@ var Binding = /*#__PURE__*/function () { _context3.prev = 11; _context3.next = 14; - return this._execute(this.target.parentElement, data); + return this._execute(this.target.parentElement, data, radix); case 14: _d = _context3.sent; @@ -392,7 +392,7 @@ var Binding = /*#__PURE__*/function () { targetElement = this.target.ownerElement; _context3.next = 30; - return this._execute(targetElement, data); + return this._execute(targetElement, data, radix); case 30: _d2 = _context3.sent; @@ -438,7 +438,7 @@ var Binding = /*#__PURE__*/function () { } _context3.next = 48; - return this._execute(this.target.ownerElement, data); + return this._execute(this.target.ownerElement, data, radix); case 48: _d3 = _context3.sent; @@ -453,7 +453,7 @@ var Binding = /*#__PURE__*/function () { } _context3.next = 55; - return this._execute(this.target.ownerElement, data); + return this._execute(this.target.ownerElement, data, radix); case 55: _d4 = _context3.sent; @@ -476,7 +476,7 @@ var Binding = /*#__PURE__*/function () { } _context3.next = 63; - return this._execute(this.target.ownerElement, data); + return this._execute(this.target.ownerElement, data, radix); case 63: _d5 = _context3.sent; @@ -506,12 +506,12 @@ var Binding = /*#__PURE__*/function () { } _context3.next = 73; - return this._execute(this.target.ownerElement, data); + return this._execute(this.target.ownerElement, data, radix); case 73: _d6 = _context3.sent; _context3.next = 76; - return this.target.ownerElement.setData(_d6); + return this.target.ownerElement.setData(_d6, data); case 76: _context3.next = 85; @@ -524,7 +524,7 @@ var Binding = /*#__PURE__*/function () { } _context3.next = 81; - return this._execute(this.target.ownerElement, data); + return this._execute(this.target.ownerElement, data, radix); case 81: _d7 = _context3.sent; @@ -555,7 +555,7 @@ var Binding = /*#__PURE__*/function () { }, _callee3, this, [[1, 88], [11, 21]]); })); - function render(_x3) { + function render(_x4, _x5) { return _render.apply(this, arguments); } @@ -622,7 +622,7 @@ var Binding = /*#__PURE__*/function () { var scopeValues = Object.values(scope); try { - var args = ["data", "d", "context", "_test"].concat(_toConsumableArray(scopeKeys)); + var args = ["data", "d", "radix", "context", "_test"].concat(_toConsumableArray(scopeKeys)); if (isAsync) func = _construct(AsyncFunction, _toConsumableArray(args).concat([code]));else func = _construct(Function, _toConsumableArray(args).concat([code])); } catch (ex) { console.log("Test failed: " + ex, code); @@ -1156,6 +1156,7 @@ var IUI = /*#__PURE__*/function () { value: function () { var _render = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(element, data) { var textNodesOnly, + radix, bindings, i, el, @@ -1165,132 +1166,133 @@ var IUI = /*#__PURE__*/function () { switch (_context4.prev = _context4.next) { case 0: textNodesOnly = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : false; + radix = _args4.length > 3 && _args4[3] !== undefined ? _args4[3] : null; if (element.__i_bindings) { - _context4.next = 3; + _context4.next = 4; break; } return _context4.abrupt("return"); - case 3: + case 4: bindings = element.__i_bindings; if (!textNodesOnly) { - _context4.next = 15; + _context4.next = 16; break; } i = 0; - case 6: + case 7: if (!(i < bindings.length)) { - _context4.next = 13; + _context4.next = 14; break; } if (!(bindings[i].type == _Binding.BindingType.TextNode)) { - _context4.next = 10; + _context4.next = 11; break; } - _context4.next = 10; - return bindings[i].render(data); + _context4.next = 11; + return bindings[i].render(data, radix); - case 10: + case 11: i++; - _context4.next = 6; + _context4.next = 7; break; - case 13: - _context4.next = 22; + case 14: + _context4.next = 23; break; - case 15: - i = 0; - case 16: + i = 0; + + case 17: if (!(i < bindings.length)) { - _context4.next = 22; + _context4.next = 23; break; } - _context4.next = 19; - return bindings[i].render(data); + _context4.next = 20; + return bindings[i].render(data, radix); - case 19: + case 20: i++; - _context4.next = 16; + _context4.next = 17; break; - case 22: + case 23: i = 0; - case 23: + case 24: if (!(i < element.children.length)) { - _context4.next = 47; + _context4.next = 48; break; } el = element.children[i]; if (!(el instanceof _IUIElement["default"])) { - _context4.next = 36; + _context4.next = 37; break; } if (!(el.dataMap != null)) { - _context4.next = 32; + _context4.next = 33; break; } - _context4.next = 29; - return el.dataMap.render(data); - - case 29: - if (_context4.sent) { - _context4.next = 30; - break; - } + _context4.next = 30; + return el.dataMap.render(data, radix); case 30: - _context4.next = 34; - break; - - case 32: - _context4.next = 34; - return el.setData(data); - - case 34: - _context4.next = 44; - break; - - case 36: - if (!(el.dataMap != null)) { - _context4.next = 41; + if (_context4.sent) { + _context4.next = 31; break; } - _context4.next = 39; - return el.dataMap.render(data); - - case 39: - _context4.next = 42; + case 31: + _context4.next = 35; break; - case 41: - el.data = data; + case 33: + _context4.next = 35; + return el.setData(data); + + case 35: + _context4.next = 45; + break; + + case 37: + if (!(el.dataMap != null)) { + _context4.next = 42; + break; + } + + _context4.next = 40; + return el.dataMap.render(data, radix); + + case 40: + _context4.next = 43; + break; case 42: - _context4.next = 44; - return IUI.render(el, el.data); + el.data = data; - case 44: + case 43: + _context4.next = 45; + return IUI.render(el, el.data, textNodesOnly, data); + + case 45: i++; - _context4.next = 23; + _context4.next = 24; break; - case 47: + case 48: case "end": return _context4.stop(); } @@ -1631,7 +1633,7 @@ var IUIElement = /*#__PURE__*/function (_HTMLElement) { }, { key: "setData", value: function () { - var _setData = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(value) { + var _setData = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(value, radix) { return regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { @@ -1643,7 +1645,7 @@ var IUIElement = /*#__PURE__*/function (_HTMLElement) { }); _context2.next = 4; - return _IUI.IUI.render(this, value); + return _IUI.IUI.render(this, value, false, radix); case 4: _context2.next = 6; @@ -1657,7 +1659,7 @@ var IUIElement = /*#__PURE__*/function (_HTMLElement) { }, _callee2, this); })); - function setData(_x) { + function setData(_x, _x2) { return _setData.apply(this, arguments); } @@ -1805,7 +1807,7 @@ var IUIElement = /*#__PURE__*/function (_HTMLElement) { }, _callee5, this); })); - function update(_x2) { + function update(_x3) { return _update.apply(this, arguments); } @@ -2188,14 +2190,14 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) { }, { key: "setData", value: function () { - var _setData = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(value) { + var _setData = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(value, radix) { return regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: this.original = value; - _get(_getPrototypeOf(Form.prototype), "setData", this).call(this, new _Modifiable["default"](this.original, true)); + _get(_getPrototypeOf(Form.prototype), "setData", this).call(this, new _Modifiable["default"](this.original, true), radix); case 2: case "end": @@ -2205,7 +2207,7 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) { }, _callee2, this); })); - function setData(_x) { + function setData(_x, _x2) { return _setData.apply(this, arguments); } @@ -2910,8 +2912,19 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) { if (this.children.length > 0) this._repeatNode = this.children[0].cloneNode(true);else { this._repeatNode = document.createElement("div"); if (this.childNodes.length > 0 && this.childNodes[0].data.trim() != "") this._repeatNode.innerHTML = this.childNodes[0].data.trim(); + } // keep script + + var toBeRemoved = []; + + for (var i = 0; i < this.childNodes.length; i++) { + if (this.childNodes[i].tagName != "SCRIPT") toBeRemoved.push(this.childNodes[i]); } - this.innerHTML = ""; + + for (var _i = 0; _i < toBeRemoved.length; _i++) { + this.removeChild(toBeRemoved[_i]); + } //this.innerHTML = ""; + + this._container = this; } // var newElements = this.querySelectorAll("*"); // for (var i = 0; i < newElements.length; i++) @@ -2965,7 +2978,7 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) { }, { key: "setData", value: function () { - var _setData = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(value) { + var _setData = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(value, radix) { var _value; var i, _this$__i_bindings2, _this$__i_bindings2$s, _this$__i_bindings2$s2, el, _this$__i_bindings; @@ -2989,7 +3002,7 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) { if (((_value = value) === null || _value === void 0 ? void 0 : _value.toArray) instanceof Function) value = value.toArray();else if (value == null || !(value instanceof Array || value instanceof Int32Array)) value = []; //debugger; _context.next = 8; - return _get(_getPrototypeOf(Repeat.prototype), "setData", this).call(this, value); + return _get(_getPrototypeOf(Repeat.prototype), "setData", this).call(this, value, radix); case 8: i = 0; @@ -3040,7 +3053,7 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) { } _context.next = 29; - return el.dataMap.render(value[i]); + return el.dataMap.render(value[i], radix); case 29: if (_context.sent) { @@ -3054,7 +3067,7 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) { case 32: _context.next = 34; - return el.setData(value[i]); + return el.setData(value[i], radix); case 34: _context.next = 44; @@ -3067,7 +3080,7 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) { } _context.next = 39; - return el.dataMap.render(value[i]); + return el.dataMap.render(value[i], radix); case 39: _context.next = 42; @@ -3078,7 +3091,7 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) { case 42: _context.next = 44; - return _IUI.IUI.render(el, el.data, false); + return _IUI.IUI.render(el, el.data, false, value[i]); case 44: i++; @@ -3102,7 +3115,7 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) { }, _callee, this, [[12, 18]]); })); - function setData(_x) { + function setData(_x, _x2) { return _setData.apply(this, arguments); } @@ -3365,14 +3378,14 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) { _createClass(Route, [{ key: "setData", value: function () { - var _setData = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(value) { + var _setData = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(value, radix) { return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: if (this.hasAttribute("debug")) debugger; _context.next = 3; - return _get(_getPrototypeOf(Route.prototype), "setData", this).call(this, value); + return _get(_getPrototypeOf(Route.prototype), "setData", this).call(this, value, radix); case 3: return _context.abrupt("return", _context.sent); @@ -3385,7 +3398,7 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) { }, _callee, this); })); - function setData(_x) { + function setData(_x, _x2) { return _setData.apply(this, arguments); } @@ -4494,13 +4507,13 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) { }, { key: "setData", value: function () { - var _setData = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(value) { + var _setData = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(value, radix) { return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: _context.next = 2; - return _get(_getPrototypeOf(Check.prototype), "setData", this).call(this, value); + return _get(_getPrototypeOf(Check.prototype), "setData", this).call(this, value, radix); case 2: if (value != null && this.field != null) this.value = value[this.field];else if (this.field != null) this.value = null; @@ -4513,7 +4526,7 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) { }, _callee, this); })); - function setData(_x) { + function setData(_x, _x2) { return _setData.apply(this, arguments); } @@ -5072,19 +5085,15 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) { }, { key: "setData", value: function () { - var _setData = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(value) { + var _setData = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(value, radix) { return regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: _context2.next = 2; - return _get(_getPrototypeOf(DateTimePicker.prototype), "setData", this).call(this, value); + return _get(_getPrototypeOf(DateTimePicker.prototype), "setData", this).call(this, value, radix); case 2: - this.value = value; - if (this.isAuto) this.revert(); - - case 4: case "end": return _context2.stop(); } @@ -5092,7 +5101,7 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) { }, _callee2, this); })); - function setData(_x) { + function setData(_x, _x2) { return _setData.apply(this, arguments); } @@ -5601,17 +5610,17 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) { }, { key: "setData", value: function () { - var _setData = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(value) { + var _setData = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(value, radix) { return regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: _context2.next = 2; - return _get(_getPrototypeOf(DropDown.prototype), "setData", this).call(this, value); + return _get(_getPrototypeOf(DropDown.prototype), "setData", this).call(this, value, radix); case 2: _context2.next = 4; - return this.menu.setData(value); + return this.menu.setData(value, radix); case 4: case "end": @@ -5621,7 +5630,7 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) { }, _callee2, this); })); - function setData(_x) { + function setData(_x, _x2) { return _setData.apply(this, arguments); } @@ -6146,13 +6155,13 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) { }, { key: "setData", value: function () { - var _setData = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(value) { + var _setData = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(value, radix) { return regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: _context2.next = 2; - return _get(_getPrototypeOf(Input.prototype), "setData", this).call(this, value); + return _get(_getPrototypeOf(Input.prototype), "setData", this).call(this, value, radix); case 2: if (this.type == "checkbox") this._input.checked = value;else if (this.type == "date") { @@ -6178,7 +6187,7 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) { }, _callee2, this); })); - function setData(_x3) { + function setData(_x3, _x4) { return _setData.apply(this, arguments); } @@ -7578,13 +7587,13 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) { }, { key: "setData", value: function () { - var _setData = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(value) { + var _setData = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(value, radix) { return regeneratorRuntime.wrap(function _callee4$(_context4) { while (1) { switch (_context4.prev = _context4.next) { case 0: _context4.next = 2; - return _get(_getPrototypeOf(Select.prototype), "setData", this).call(this, value); + return _get(_getPrototypeOf(Select.prototype), "setData", this).call(this, value, radix); case 2: try { @@ -7611,7 +7620,7 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) { }, _callee4, this); })); - function setData(_x2) { + function setData(_x2, _x3) { return _setData.apply(this, arguments); } @@ -8952,14 +8961,14 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) { }, { key: "setData", value: function () { - var _setData = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(value) { + var _setData = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(value, radix) { var self, loadFunction, i; return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: _context.next = 2; - return _get(_getPrototypeOf(Table.prototype), "setData", this).call(this, value); + return _get(_getPrototypeOf(Table.prototype), "setData", this).call(this, value, radix); case 2: this.clear(); @@ -8999,7 +9008,7 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) { }, _callee, this); })); - function setData(_x) { + function setData(_x, _x2) { return _setData.apply(this, arguments); } diff --git a/package.json b/package.json index ba449d4..40713a8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@esiur/iui", - "version": "1.2.4", + "version": "1.2.5", "description": "Interactive User Interface", "main": "iui.js", "type": "module", diff --git a/src/Core/Binding.js b/src/Core/Binding.js index 36ab8f0..6335a26 100644 --- a/src/Core/Binding.js +++ b/src/Core/Binding.js @@ -107,7 +107,7 @@ export class Binding { let scopeValues = Object.values(scope); try { - let args = ["data", "d", "context", "_test", + let args = ["data", "d", "radix", "context", "_test", ...scopeKeys] if (isAsync) @@ -153,7 +153,7 @@ export class Binding { let proxy = new Proxy(map, detector); try { - let d = this.func.apply(thisArg, [proxy, proxy, {}, true + let d = this.func.apply(thisArg, [proxy, proxy, null, {}, true , ...this.scopeValues]); this.map = map; @@ -165,12 +165,12 @@ export class Binding { } } - async _execute(thisArg, data) { + async _execute(thisArg, data, radix) { if (!this.checked) this._findMap(thisArg); let context = {}; - var rt = this.func.apply(thisArg, [data, data, context, false, + var rt = this.func.apply(thisArg, [data, data, radix, context, false, ...this.scopeValues]); @@ -243,7 +243,7 @@ export class Binding { - async render(data) { + async render(data, radix) { // @TODO: Checking properties bindings moved here if (data != this.data) @@ -252,7 +252,7 @@ export class Binding { try { if (this.type === BindingType.IUIElement) { - let d = await this._execute(this.target, data); + let d = await this._execute(this.target, data, radix); await this.target.setData(d); } @@ -260,7 +260,7 @@ export class Binding { try { - let d = await this._execute(this.target.parentElement, data); + let d = await this._execute(this.target.parentElement, data, radix); if (d === undefined) return false; @@ -282,7 +282,7 @@ export class Binding { let targetElement = this.target.ownerElement; - let d = await this._execute(targetElement, data); + let d = await this._execute(targetElement, data, radix); if (d === undefined) return false; @@ -303,13 +303,13 @@ export class Binding { } else if (this.type == BindingType.IfAttribute) { - let d = await this._execute(this.target.ownerElement, data); + let d = await this._execute(this.target.ownerElement, data, radix); this.target.ownerElement.style.display = d ? "" : "none"; } else if (this.type == BindingType.RevertAttribute) { - let d = await this._execute(this.target.ownerElement, data); + let d = await this._execute(this.target.ownerElement, data, radix); if (d === undefined) return false; @@ -317,7 +317,7 @@ export class Binding { // Attribute else if (this.type === BindingType.Attribute) { - let d = await this._execute(this.target.ownerElement, data); + let d = await this._execute(this.target.ownerElement, data, radix); if (d === undefined) return false; @@ -336,14 +336,15 @@ export class Binding { // Data Attribute of IUI Element else if (this.type === BindingType.IUIElementDataAttribute) { - let d = await this._execute(this.target.ownerElement, data); + let d = await this._execute(this.target.ownerElement, data, radix); - await this.target.ownerElement.setData(d); + // radix is data + await this.target.ownerElement.setData(d, data); } // Data Attribute of HTML Element else if (this.type == BindingType.HTMLElementDataAttribute) { - let d = await this._execute(this.target.ownerElement, data); + let d = await this._execute(this.target.ownerElement, data, radix); if (d === undefined) return false; this.target.ownerElement.data = d; diff --git a/src/Core/IUI.js b/src/Core/IUI.js index 92515d7..9c977d8 100644 --- a/src/Core/IUI.js +++ b/src/Core/IUI.js @@ -344,7 +344,7 @@ export class IUI { element.__i_bindings = bindings; } - static async render(element, data, textNodesOnly = false) { + static async render(element, data, textNodesOnly = false, radix = null) { if (!element.__i_bindings) { return; @@ -355,11 +355,11 @@ export class IUI { if (textNodesOnly) { for (var i = 0; i < bindings.length; i++) if (bindings[i].type == BindingType.TextNode) - await bindings[i].render(data); + await bindings[i].render(data, radix); } else { // render attributes & text nodes for (var i = 0; i < bindings.length; i++) - await bindings[i].render(data); + await bindings[i].render(data, radix); } // render children @@ -369,7 +369,7 @@ export class IUI { // @TODO should check if the element depends on parent or not if (el.dataMap != null) { // if map function failed to call setData, we will render without it - if (!(await el.dataMap.render(data))){ + if (!(await el.dataMap.render(data, radix))){ // @BUG @TODO this causes stackoverflow // await el.render(); } @@ -380,11 +380,11 @@ export class IUI { } else { if (el.dataMap != null) - await el.dataMap.render(data); + await el.dataMap.render(data, radix); else el.data = data; - await IUI.render(el, el.data); + await IUI.render(el, el.data, textNodesOnly, data); } } } diff --git a/src/Core/IUIElement.js b/src/Core/IUIElement.js index ea7c002..a70b9c2 100644 --- a/src/Core/IUIElement.js +++ b/src/Core/IUIElement.js @@ -54,10 +54,10 @@ export default class IUIElement extends HTMLElement { return undefined; } - async setData(value) { + async setData(value, radix) { this._data = value; this._emit("data", {data: value}); - await IUI.render(this, value); + await IUI.render(this, value, false, radix); // notify updated callback await this.updated(); diff --git a/src/Data/Form.js b/src/Data/Form.js index 7d2d41c..d096bf1 100644 --- a/src/Data/Form.js +++ b/src/Data/Form.js @@ -28,9 +28,9 @@ export default IUI.module(class Form extends IUIElement { } - async setData(value) { + async setData(value, radix) { this.original = value; - super.setData(new Modifiable(this.original, true)); + super.setData(new Modifiable(this.original, true), radix); } diff --git a/src/Data/Repeat.js b/src/Data/Repeat.js index 0c36fe4..c957132 100644 --- a/src/Data/Repeat.js +++ b/src/Data/Repeat.js @@ -54,7 +54,16 @@ export default IUI.module(class Repeat extends IUIElement this._repeatNode.innerHTML = this.childNodes[0].data.trim(); } - this.innerHTML = ""; + // keep script + var toBeRemoved = []; + for(let i = 0; i < this.childNodes.length; i++) + if (this.childNodes[i].tagName != "SCRIPT") + toBeRemoved.push(this.childNodes[i]); + + for(let i = 0; i < toBeRemoved.length; i++) + this.removeChild(toBeRemoved[i]); + + //this.innerHTML = ""; this._container = this; } @@ -111,7 +120,7 @@ export default IUI.module(class Repeat extends IUIElement } - async setData(value) + async setData(value, radix) { @@ -135,7 +144,7 @@ export default IUI.module(class Repeat extends IUIElement //debugger; - await super.setData(value); + await super.setData(value, radix); for (let i = 0; i < value.length; i++) { @@ -166,23 +175,24 @@ export default IUI.module(class Repeat extends IUIElement // @TODO should check if the element depends on parent or not if (el.dataMap != null) { // if map function failed to call setData, we will render without it - if (!(await el.dataMap.render(value[i]))) { + if (!(await el.dataMap.render(value[i], radix))) { // @BUG @TODO this causes stackoverflow // await el.render(); } } else { - await el.setData(value[i]); + await el.setData(value[i], radix); } } else { if (el.dataMap != null) - await el.dataMap.render(value[i]); + await el.dataMap.render(value[i], radix); else el.data = value[i]; - await IUI.render(el, el.data, false); + // data is now the radix + await IUI.render(el, el.data, false, value[i]); } } diff --git a/src/Router/Route.js b/src/Router/Route.js index ea723ff..71e3f75 100644 --- a/src/Router/Route.js +++ b/src/Router/Route.js @@ -16,10 +16,10 @@ export default IUI.module( this._register("load"); } - async setData(value) { + async setData(value, radix) { if (this.hasAttribute("debug")) debugger; - return await super.setData(value); + return await super.setData(value, radix); } get scope() { diff --git a/src/UI/Check.js b/src/UI/Check.js index bccec3b..171654a 100644 --- a/src/UI/Check.js +++ b/src/UI/Check.js @@ -32,8 +32,8 @@ export default IUI.module(class Check extends IUIElement { this.field = this.getAttribute("field"); } - async setData(value) { - await super.setData(value); + async setData(value, radix) { + await super.setData(value, radix); if (value != null && this.field != null) this.value = value[this.field]; else if (this.field != null) diff --git a/src/UI/DateTimePicker.js b/src/UI/DateTimePicker.js index 188add2..549406c 100644 --- a/src/UI/DateTimePicker.js +++ b/src/UI/DateTimePicker.js @@ -296,14 +296,16 @@ export default IUI.module(class DateTimePicker extends IUIElement { this.clock.children[time / this.layout.time.range].classList.add(this.cssClass + "-time-selected"); } - async setData(value) { + async setData(value, radix) { - await super.setData(value); + await super.setData(value, radix); if (value != null && this.field != null) this.value = this.data[this.field]; - + else + this.value = value; + } get data() { @@ -311,13 +313,10 @@ export default IUI.module(class DateTimePicker extends IUIElement { } - async setData(value) { - await super.setData(value); + async setData(value, radix) { + await super.setData(value, radix); - this.value = value; - if (this.isAuto) - this.revert(); } /* diff --git a/src/UI/DropDown.js b/src/UI/DropDown.js index 9123ba8..3179a21 100644 --- a/src/UI/DropDown.js +++ b/src/UI/DropDown.js @@ -67,11 +67,11 @@ export default IUI.module(class DropDown extends IUIElement { } } - async setData(value){ + async setData(value, radix){ //debugger; - await super.setData(value); - await this.menu.setData(value); + await super.setData(value, radix); + await this.menu.setData(value, radix); } diff --git a/src/UI/Input.js b/src/UI/Input.js index fe18bf4..68a1222 100644 --- a/src/UI/Input.js +++ b/src/UI/Input.js @@ -136,8 +136,8 @@ export default IUI.module( return !this._input.disabled; } - async setData(value) { - await super.setData(value); + async setData(value, radix) { + await super.setData(value, radix); if (this.type == "checkbox") this._input.checked = value; else if (this.type == "date") { diff --git a/src/UI/Select.js b/src/UI/Select.js index 4065d3f..98d1e2b 100644 --- a/src/UI/Select.js +++ b/src/UI/Select.js @@ -345,11 +345,11 @@ export default IUI.module(class Select extends IUIElement { } - async setData(value) { + async setData(value, radix) { // this.label.innerHTML = ""; - await super.setData(value); + await super.setData(value, radix); try { //let text = this.formatter(value); diff --git a/src/UI/Table.js b/src/UI/Table.js index 40dc7ab..ee19a17 100644 --- a/src/UI/Table.js +++ b/src/UI/Table.js @@ -1389,9 +1389,9 @@ export default IUI.module(class Table extends IUIElement { - async setData(value) + async setData(value, radix) { - await super.setData(value); + await super.setData(value, radix); this.clear();