2
0
mirror of https://github.com/esiur/iui.git synced 2025-05-06 06:42:58 +00:00
This commit is contained in:
Ahmed Zamil 2024-07-10 23:36:25 +03:00
parent e6b3023406
commit 4b2a3f3834
14 changed files with 188 additions and 169 deletions

View File

@ -185,7 +185,7 @@ var Binding = /*#__PURE__*/function () {
var proxy = new Proxy(map, detector); var proxy = new Proxy(map, detector);
try { 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; this.map = map;
return d; return d;
} catch (ex) { } catch (ex) {
@ -196,7 +196,7 @@ var Binding = /*#__PURE__*/function () {
}, { }, {
key: "_execute", key: "_execute",
value: function () { 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; var context, rt;
return regeneratorRuntime.wrap(function _callee2$(_context2) { return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) { while (1) {
@ -204,7 +204,7 @@ var Binding = /*#__PURE__*/function () {
case 0: case 0:
if (!this.checked) this._findMap(thisArg); if (!this.checked) this._findMap(thisArg);
context = {}; 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)) { if (!(rt instanceof Promise)) {
_context2.next = 6; _context2.next = 6;
@ -273,7 +273,7 @@ var Binding = /*#__PURE__*/function () {
}, _callee2, this, [[17, 23]]); }, _callee2, this, [[17, 23]]);
})); }));
function _execute(_x, _x2) { function _execute(_x, _x2, _x3) {
return _execute2.apply(this, arguments); return _execute2.apply(this, arguments);
} }
@ -316,7 +316,7 @@ var Binding = /*#__PURE__*/function () {
}, { }, {
key: "render", key: "render",
value: function () { 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; 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) { return regeneratorRuntime.wrap(function _callee3$(_context3) {
@ -333,7 +333,7 @@ var Binding = /*#__PURE__*/function () {
} }
_context3.next = 5; _context3.next = 5;
return this._execute(this.target, data); return this._execute(this.target, data, radix);
case 5: case 5:
d = _context3.sent; d = _context3.sent;
@ -352,7 +352,7 @@ var Binding = /*#__PURE__*/function () {
_context3.prev = 11; _context3.prev = 11;
_context3.next = 14; _context3.next = 14;
return this._execute(this.target.parentElement, data); return this._execute(this.target.parentElement, data, radix);
case 14: case 14:
_d = _context3.sent; _d = _context3.sent;
@ -392,7 +392,7 @@ var Binding = /*#__PURE__*/function () {
targetElement = this.target.ownerElement; targetElement = this.target.ownerElement;
_context3.next = 30; _context3.next = 30;
return this._execute(targetElement, data); return this._execute(targetElement, data, radix);
case 30: case 30:
_d2 = _context3.sent; _d2 = _context3.sent;
@ -438,7 +438,7 @@ var Binding = /*#__PURE__*/function () {
} }
_context3.next = 48; _context3.next = 48;
return this._execute(this.target.ownerElement, data); return this._execute(this.target.ownerElement, data, radix);
case 48: case 48:
_d3 = _context3.sent; _d3 = _context3.sent;
@ -453,7 +453,7 @@ var Binding = /*#__PURE__*/function () {
} }
_context3.next = 55; _context3.next = 55;
return this._execute(this.target.ownerElement, data); return this._execute(this.target.ownerElement, data, radix);
case 55: case 55:
_d4 = _context3.sent; _d4 = _context3.sent;
@ -476,7 +476,7 @@ var Binding = /*#__PURE__*/function () {
} }
_context3.next = 63; _context3.next = 63;
return this._execute(this.target.ownerElement, data); return this._execute(this.target.ownerElement, data, radix);
case 63: case 63:
_d5 = _context3.sent; _d5 = _context3.sent;
@ -506,12 +506,12 @@ var Binding = /*#__PURE__*/function () {
} }
_context3.next = 73; _context3.next = 73;
return this._execute(this.target.ownerElement, data); return this._execute(this.target.ownerElement, data, radix);
case 73: case 73:
_d6 = _context3.sent; _d6 = _context3.sent;
_context3.next = 76; _context3.next = 76;
return this.target.ownerElement.setData(_d6); return this.target.ownerElement.setData(_d6, data);
case 76: case 76:
_context3.next = 85; _context3.next = 85;
@ -524,7 +524,7 @@ var Binding = /*#__PURE__*/function () {
} }
_context3.next = 81; _context3.next = 81;
return this._execute(this.target.ownerElement, data); return this._execute(this.target.ownerElement, data, radix);
case 81: case 81:
_d7 = _context3.sent; _d7 = _context3.sent;
@ -555,7 +555,7 @@ var Binding = /*#__PURE__*/function () {
}, _callee3, this, [[1, 88], [11, 21]]); }, _callee3, this, [[1, 88], [11, 21]]);
})); }));
function render(_x3) { function render(_x4, _x5) {
return _render.apply(this, arguments); return _render.apply(this, arguments);
} }
@ -622,7 +622,7 @@ var Binding = /*#__PURE__*/function () {
var scopeValues = Object.values(scope); var scopeValues = Object.values(scope);
try { 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])); if (isAsync) func = _construct(AsyncFunction, _toConsumableArray(args).concat([code]));else func = _construct(Function, _toConsumableArray(args).concat([code]));
} catch (ex) { } catch (ex) {
console.log("Test failed: " + ex, code); console.log("Test failed: " + ex, code);
@ -1156,6 +1156,7 @@ var IUI = /*#__PURE__*/function () {
value: function () { value: function () {
var _render = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(element, data) { var _render = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(element, data) {
var textNodesOnly, var textNodesOnly,
radix,
bindings, bindings,
i, i,
el, el,
@ -1165,132 +1166,133 @@ var IUI = /*#__PURE__*/function () {
switch (_context4.prev = _context4.next) { switch (_context4.prev = _context4.next) {
case 0: case 0:
textNodesOnly = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : false; textNodesOnly = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : false;
radix = _args4.length > 3 && _args4[3] !== undefined ? _args4[3] : null;
if (element.__i_bindings) { if (element.__i_bindings) {
_context4.next = 3; _context4.next = 4;
break; break;
} }
return _context4.abrupt("return"); return _context4.abrupt("return");
case 3: case 4:
bindings = element.__i_bindings; bindings = element.__i_bindings;
if (!textNodesOnly) { if (!textNodesOnly) {
_context4.next = 15; _context4.next = 16;
break; break;
} }
i = 0; i = 0;
case 6: case 7:
if (!(i < bindings.length)) { if (!(i < bindings.length)) {
_context4.next = 13; _context4.next = 14;
break; break;
} }
if (!(bindings[i].type == _Binding.BindingType.TextNode)) { if (!(bindings[i].type == _Binding.BindingType.TextNode)) {
_context4.next = 10; _context4.next = 11;
break; break;
} }
_context4.next = 10; _context4.next = 11;
return bindings[i].render(data); return bindings[i].render(data, radix);
case 10: case 11:
i++; i++;
_context4.next = 6; _context4.next = 7;
break; break;
case 13: case 14:
_context4.next = 22; _context4.next = 23;
break; break;
case 15:
i = 0;
case 16: case 16:
i = 0;
case 17:
if (!(i < bindings.length)) { if (!(i < bindings.length)) {
_context4.next = 22; _context4.next = 23;
break; break;
} }
_context4.next = 19; _context4.next = 20;
return bindings[i].render(data); return bindings[i].render(data, radix);
case 19: case 20:
i++; i++;
_context4.next = 16; _context4.next = 17;
break; break;
case 22: case 23:
i = 0; i = 0;
case 23: case 24:
if (!(i < element.children.length)) { if (!(i < element.children.length)) {
_context4.next = 47; _context4.next = 48;
break; break;
} }
el = element.children[i]; el = element.children[i];
if (!(el instanceof _IUIElement["default"])) { if (!(el instanceof _IUIElement["default"])) {
_context4.next = 36; _context4.next = 37;
break; break;
} }
if (!(el.dataMap != null)) { if (!(el.dataMap != null)) {
_context4.next = 32; _context4.next = 33;
break; break;
} }
_context4.next = 29; _context4.next = 30;
return el.dataMap.render(data); return el.dataMap.render(data, radix);
case 29:
if (_context4.sent) {
_context4.next = 30;
break;
}
case 30: case 30:
_context4.next = 34; if (_context4.sent) {
break; _context4.next = 31;
case 32:
_context4.next = 34;
return el.setData(data);
case 34:
_context4.next = 44;
break;
case 36:
if (!(el.dataMap != null)) {
_context4.next = 41;
break; break;
} }
_context4.next = 39; case 31:
return el.dataMap.render(data); _context4.next = 35;
case 39:
_context4.next = 42;
break; break;
case 41: case 33:
el.data = data; _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: case 42:
_context4.next = 44; el.data = data;
return IUI.render(el, el.data);
case 44: case 43:
_context4.next = 45;
return IUI.render(el, el.data, textNodesOnly, data);
case 45:
i++; i++;
_context4.next = 23; _context4.next = 24;
break; break;
case 47: case 48:
case "end": case "end":
return _context4.stop(); return _context4.stop();
} }
@ -1631,7 +1633,7 @@ var IUIElement = /*#__PURE__*/function (_HTMLElement) {
}, { }, {
key: "setData", key: "setData",
value: function () { 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) { return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) { while (1) {
switch (_context2.prev = _context2.next) { switch (_context2.prev = _context2.next) {
@ -1643,7 +1645,7 @@ var IUIElement = /*#__PURE__*/function (_HTMLElement) {
}); });
_context2.next = 4; _context2.next = 4;
return _IUI.IUI.render(this, value); return _IUI.IUI.render(this, value, false, radix);
case 4: case 4:
_context2.next = 6; _context2.next = 6;
@ -1657,7 +1659,7 @@ var IUIElement = /*#__PURE__*/function (_HTMLElement) {
}, _callee2, this); }, _callee2, this);
})); }));
function setData(_x) { function setData(_x, _x2) {
return _setData.apply(this, arguments); return _setData.apply(this, arguments);
} }
@ -1805,7 +1807,7 @@ var IUIElement = /*#__PURE__*/function (_HTMLElement) {
}, _callee5, this); }, _callee5, this);
})); }));
function update(_x2) { function update(_x3) {
return _update.apply(this, arguments); return _update.apply(this, arguments);
} }
@ -2188,14 +2190,14 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) {
}, { }, {
key: "setData", key: "setData",
value: function () { 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) { return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) { while (1) {
switch (_context2.prev = _context2.next) { switch (_context2.prev = _context2.next) {
case 0: case 0:
this.original = value; 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 2:
case "end": case "end":
@ -2205,7 +2207,7 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) {
}, _callee2, this); }, _callee2, this);
})); }));
function setData(_x) { function setData(_x, _x2) {
return _setData.apply(this, arguments); 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 { if (this.children.length > 0) this._repeatNode = this.children[0].cloneNode(true);else {
this._repeatNode = document.createElement("div"); this._repeatNode = document.createElement("div");
if (this.childNodes.length > 0 && this.childNodes[0].data.trim() != "") this._repeatNode.innerHTML = this.childNodes[0].data.trim(); 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; this._container = this;
} // var newElements = this.querySelectorAll("*"); } // var newElements = this.querySelectorAll("*");
// for (var i = 0; i < newElements.length; i++) // for (var i = 0; i < newElements.length; i++)
@ -2965,7 +2978,7 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) {
}, { }, {
key: "setData", key: "setData",
value: function () { value: function () {
var _setData = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(value) { var _setData = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(value, radix) {
var _value; var _value;
var i, _this$__i_bindings2, _this$__i_bindings2$s, _this$__i_bindings2$s2, el, _this$__i_bindings; 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; 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; _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: case 8:
i = 0; i = 0;
@ -3040,7 +3053,7 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) {
} }
_context.next = 29; _context.next = 29;
return el.dataMap.render(value[i]); return el.dataMap.render(value[i], radix);
case 29: case 29:
if (_context.sent) { if (_context.sent) {
@ -3054,7 +3067,7 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) {
case 32: case 32:
_context.next = 34; _context.next = 34;
return el.setData(value[i]); return el.setData(value[i], radix);
case 34: case 34:
_context.next = 44; _context.next = 44;
@ -3067,7 +3080,7 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) {
} }
_context.next = 39; _context.next = 39;
return el.dataMap.render(value[i]); return el.dataMap.render(value[i], radix);
case 39: case 39:
_context.next = 42; _context.next = 42;
@ -3078,7 +3091,7 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) {
case 42: case 42:
_context.next = 44; _context.next = 44;
return _IUI.IUI.render(el, el.data, false); return _IUI.IUI.render(el, el.data, false, value[i]);
case 44: case 44:
i++; i++;
@ -3102,7 +3115,7 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) {
}, _callee, this, [[12, 18]]); }, _callee, this, [[12, 18]]);
})); }));
function setData(_x) { function setData(_x, _x2) {
return _setData.apply(this, arguments); return _setData.apply(this, arguments);
} }
@ -3365,14 +3378,14 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) {
_createClass(Route, [{ _createClass(Route, [{
key: "setData", key: "setData",
value: function () { 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) { return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) { while (1) {
switch (_context.prev = _context.next) { switch (_context.prev = _context.next) {
case 0: case 0:
if (this.hasAttribute("debug")) debugger; if (this.hasAttribute("debug")) debugger;
_context.next = 3; _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: case 3:
return _context.abrupt("return", _context.sent); return _context.abrupt("return", _context.sent);
@ -3385,7 +3398,7 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) {
}, _callee, this); }, _callee, this);
})); }));
function setData(_x) { function setData(_x, _x2) {
return _setData.apply(this, arguments); return _setData.apply(this, arguments);
} }
@ -4494,13 +4507,13 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) {
}, { }, {
key: "setData", key: "setData",
value: function () { 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) { return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) { while (1) {
switch (_context.prev = _context.next) { switch (_context.prev = _context.next) {
case 0: case 0:
_context.next = 2; _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: case 2:
if (value != null && this.field != null) this.value = value[this.field];else if (this.field != null) this.value = null; 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); }, _callee, this);
})); }));
function setData(_x) { function setData(_x, _x2) {
return _setData.apply(this, arguments); return _setData.apply(this, arguments);
} }
@ -5072,19 +5085,15 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) {
}, { }, {
key: "setData", key: "setData",
value: function () { 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) { return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) { while (1) {
switch (_context2.prev = _context2.next) { switch (_context2.prev = _context2.next) {
case 0: case 0:
_context2.next = 2; _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: case 2:
this.value = value;
if (this.isAuto) this.revert();
case 4:
case "end": case "end":
return _context2.stop(); return _context2.stop();
} }
@ -5092,7 +5101,7 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) {
}, _callee2, this); }, _callee2, this);
})); }));
function setData(_x) { function setData(_x, _x2) {
return _setData.apply(this, arguments); return _setData.apply(this, arguments);
} }
@ -5601,17 +5610,17 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) {
}, { }, {
key: "setData", key: "setData",
value: function () { 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) { return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) { while (1) {
switch (_context2.prev = _context2.next) { switch (_context2.prev = _context2.next) {
case 0: case 0:
_context2.next = 2; _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: case 2:
_context2.next = 4; _context2.next = 4;
return this.menu.setData(value); return this.menu.setData(value, radix);
case 4: case 4:
case "end": case "end":
@ -5621,7 +5630,7 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) {
}, _callee2, this); }, _callee2, this);
})); }));
function setData(_x) { function setData(_x, _x2) {
return _setData.apply(this, arguments); return _setData.apply(this, arguments);
} }
@ -6146,13 +6155,13 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) {
}, { }, {
key: "setData", key: "setData",
value: function () { 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) { return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) { while (1) {
switch (_context2.prev = _context2.next) { switch (_context2.prev = _context2.next) {
case 0: case 0:
_context2.next = 2; _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: case 2:
if (this.type == "checkbox") this._input.checked = value;else if (this.type == "date") { 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); }, _callee2, this);
})); }));
function setData(_x3) { function setData(_x3, _x4) {
return _setData.apply(this, arguments); return _setData.apply(this, arguments);
} }
@ -7578,13 +7587,13 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) {
}, { }, {
key: "setData", key: "setData",
value: function () { 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) { return regeneratorRuntime.wrap(function _callee4$(_context4) {
while (1) { while (1) {
switch (_context4.prev = _context4.next) { switch (_context4.prev = _context4.next) {
case 0: case 0:
_context4.next = 2; _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: case 2:
try { try {
@ -7611,7 +7620,7 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) {
}, _callee4, this); }, _callee4, this);
})); }));
function setData(_x2) { function setData(_x2, _x3) {
return _setData.apply(this, arguments); return _setData.apply(this, arguments);
} }
@ -8952,14 +8961,14 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) {
}, { }, {
key: "setData", key: "setData",
value: function () { 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; var self, loadFunction, i;
return regeneratorRuntime.wrap(function _callee$(_context) { return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) { while (1) {
switch (_context.prev = _context.next) { switch (_context.prev = _context.next) {
case 0: case 0:
_context.next = 2; _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: case 2:
this.clear(); this.clear();
@ -8999,7 +9008,7 @@ var _default = _IUI.IUI.module( /*#__PURE__*/function (_IUIElement) {
}, _callee, this); }, _callee, this);
})); }));
function setData(_x) { function setData(_x, _x2) {
return _setData.apply(this, arguments); return _setData.apply(this, arguments);
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "@esiur/iui", "name": "@esiur/iui",
"version": "1.2.4", "version": "1.2.5",
"description": "Interactive User Interface", "description": "Interactive User Interface",
"main": "iui.js", "main": "iui.js",
"type": "module", "type": "module",

View File

@ -107,7 +107,7 @@ export class Binding {
let scopeValues = Object.values(scope); let scopeValues = Object.values(scope);
try { try {
let args = ["data", "d", "context", "_test", let args = ["data", "d", "radix", "context", "_test",
...scopeKeys] ...scopeKeys]
if (isAsync) if (isAsync)
@ -153,7 +153,7 @@ export class Binding {
let proxy = new Proxy(map, detector); let proxy = new Proxy(map, detector);
try { try {
let d = this.func.apply(thisArg, [proxy, proxy, {}, true let d = this.func.apply(thisArg, [proxy, proxy, null, {}, true
, ...this.scopeValues]); , ...this.scopeValues]);
this.map = map; this.map = map;
@ -165,12 +165,12 @@ export class Binding {
} }
} }
async _execute(thisArg, data) { async _execute(thisArg, data, radix) {
if (!this.checked) if (!this.checked)
this._findMap(thisArg); this._findMap(thisArg);
let context = {}; 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]); ...this.scopeValues]);
@ -243,7 +243,7 @@ export class Binding {
async render(data) { async render(data, radix) {
// @TODO: Checking properties bindings moved here // @TODO: Checking properties bindings moved here
if (data != this.data) if (data != this.data)
@ -252,7 +252,7 @@ export class Binding {
try { try {
if (this.type === BindingType.IUIElement) { 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); await this.target.setData(d);
} }
@ -260,7 +260,7 @@ export class Binding {
try { try {
let d = await this._execute(this.target.parentElement, data); let d = await this._execute(this.target.parentElement, data, radix);
if (d === undefined) if (d === undefined)
return false; return false;
@ -282,7 +282,7 @@ export class Binding {
let targetElement = this.target.ownerElement; let targetElement = this.target.ownerElement;
let d = await this._execute(targetElement, data); let d = await this._execute(targetElement, data, radix);
if (d === undefined) if (d === undefined)
return false; return false;
@ -303,13 +303,13 @@ export class Binding {
} }
else if (this.type == BindingType.IfAttribute) 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"; this.target.ownerElement.style.display = d ? "" : "none";
} }
else if (this.type == BindingType.RevertAttribute) 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) if (d === undefined)
return false; return false;
@ -317,7 +317,7 @@ export class Binding {
// Attribute // Attribute
else if (this.type === BindingType.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) if (d === undefined)
return false; return false;
@ -336,14 +336,15 @@ export class Binding {
// Data Attribute of IUI Element // Data Attribute of IUI Element
else if (this.type === BindingType.IUIElementDataAttribute) { 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 // Data Attribute of HTML Element
else if (this.type == BindingType.HTMLElementDataAttribute) { 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) if (d === undefined)
return false; return false;
this.target.ownerElement.data = d; this.target.ownerElement.data = d;

View File

@ -344,7 +344,7 @@ export class IUI {
element.__i_bindings = bindings; element.__i_bindings = bindings;
} }
static async render(element, data, textNodesOnly = false) { static async render(element, data, textNodesOnly = false, radix = null) {
if (!element.__i_bindings) { if (!element.__i_bindings) {
return; return;
@ -355,11 +355,11 @@ export class IUI {
if (textNodesOnly) { if (textNodesOnly) {
for (var i = 0; i < bindings.length; i++) for (var i = 0; i < bindings.length; i++)
if (bindings[i].type == BindingType.TextNode) if (bindings[i].type == BindingType.TextNode)
await bindings[i].render(data); await bindings[i].render(data, radix);
} else { } else {
// render attributes & text nodes // render attributes & text nodes
for (var i = 0; i < bindings.length; i++) for (var i = 0; i < bindings.length; i++)
await bindings[i].render(data); await bindings[i].render(data, radix);
} }
// render children // render children
@ -369,7 +369,7 @@ export class IUI {
// @TODO should check if the element depends on parent or not // @TODO should check if the element depends on parent or not
if (el.dataMap != null) { if (el.dataMap != null) {
// if map function failed to call setData, we will render without it // 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 // @BUG @TODO this causes stackoverflow
// await el.render(); // await el.render();
} }
@ -380,11 +380,11 @@ export class IUI {
} }
else { else {
if (el.dataMap != null) if (el.dataMap != null)
await el.dataMap.render(data); await el.dataMap.render(data, radix);
else else
el.data = data; el.data = data;
await IUI.render(el, el.data); await IUI.render(el, el.data, textNodesOnly, data);
} }
} }
} }

View File

@ -54,10 +54,10 @@ export default class IUIElement extends HTMLElement {
return undefined; return undefined;
} }
async setData(value) { async setData(value, radix) {
this._data = value; this._data = value;
this._emit("data", {data: value}); this._emit("data", {data: value});
await IUI.render(this, value); await IUI.render(this, value, false, radix);
// notify updated callback // notify updated callback
await this.updated(); await this.updated();

View File

@ -28,9 +28,9 @@ export default IUI.module(class Form extends IUIElement {
} }
async setData(value) { async setData(value, radix) {
this.original = value; this.original = value;
super.setData(new Modifiable(this.original, true)); super.setData(new Modifiable(this.original, true), radix);
} }

View File

@ -54,7 +54,16 @@ export default IUI.module(class Repeat extends IUIElement
this._repeatNode.innerHTML = this.childNodes[0].data.trim(); 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; 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; //debugger;
await super.setData(value); await super.setData(value, radix);
for (let i = 0; i < value.length; i++) { 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 // @TODO should check if the element depends on parent or not
if (el.dataMap != null) { if (el.dataMap != null) {
// if map function failed to call setData, we will render without it // 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 // @BUG @TODO this causes stackoverflow
// await el.render(); // await el.render();
} }
} }
else { else {
await el.setData(value[i]); await el.setData(value[i], radix);
} }
} }
else else
{ {
if (el.dataMap != null) if (el.dataMap != null)
await el.dataMap.render(value[i]); await el.dataMap.render(value[i], radix);
else else
el.data = value[i]; 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]);
} }
} }

View File

@ -16,10 +16,10 @@ export default IUI.module(
this._register("load"); this._register("load");
} }
async setData(value) { async setData(value, radix) {
if (this.hasAttribute("debug")) debugger; if (this.hasAttribute("debug")) debugger;
return await super.setData(value); return await super.setData(value, radix);
} }
get scope() { get scope() {

View File

@ -32,8 +32,8 @@ export default IUI.module(class Check extends IUIElement {
this.field = this.getAttribute("field"); this.field = this.getAttribute("field");
} }
async setData(value) { async setData(value, radix) {
await super.setData(value); await super.setData(value, radix);
if (value != null && this.field != null) if (value != null && this.field != null)
this.value = value[this.field]; this.value = value[this.field];
else if (this.field != null) else if (this.field != null)

View File

@ -296,13 +296,15 @@ export default IUI.module(class DateTimePicker extends IUIElement {
this.clock.children[time / this.layout.time.range].classList.add(this.cssClass + "-time-selected"); 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) if (value != null && this.field != null)
this.value = this.data[this.field]; this.value = this.data[this.field];
else
this.value = value;
} }
@ -311,13 +313,10 @@ export default IUI.module(class DateTimePicker extends IUIElement {
} }
async setData(value) { async setData(value, radix) {
await super.setData(value); await super.setData(value, radix);
this.value = value;
if (this.isAuto)
this.revert();
} }
/* /*

View File

@ -67,11 +67,11 @@ export default IUI.module(class DropDown extends IUIElement {
} }
} }
async setData(value){ async setData(value, radix){
//debugger; //debugger;
await super.setData(value); await super.setData(value, radix);
await this.menu.setData(value); await this.menu.setData(value, radix);
} }

View File

@ -136,8 +136,8 @@ export default IUI.module(
return !this._input.disabled; return !this._input.disabled;
} }
async setData(value) { async setData(value, radix) {
await super.setData(value); await super.setData(value, radix);
if (this.type == "checkbox") this._input.checked = value; if (this.type == "checkbox") this._input.checked = value;
else if (this.type == "date") { else if (this.type == "date") {

View File

@ -345,11 +345,11 @@ export default IUI.module(class Select extends IUIElement {
} }
async setData(value) { async setData(value, radix) {
// this.label.innerHTML = ""; // this.label.innerHTML = "";
await super.setData(value); await super.setData(value, radix);
try { try {
//let text = this.formatter(value); //let text = this.formatter(value);

View File

@ -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(); this.clear();