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);
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;
}
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 31:
_context4.next = 35;
break;
case 39:
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;
}
case 41:
el.data = data;
_context4.next = 40;
return el.dataMap.render(data, radix);
case 42:
_context4.next = 44;
return IUI.render(el, el.data);
case 44:
i++;
_context4.next = 23;
case 40:
_context4.next = 43;
break;
case 47:
case 42:
el.data = data;
case 43:
_context4.next = 45;
return IUI.render(el, el.data, textNodesOnly, data);
case 45:
i++;
_context4.next = 24;
break;
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);
}

View File

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

View File

@ -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;

View File

@ -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);
}
}
}

View File

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

View File

@ -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);
}

View File

@ -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]);
}
}

View File

@ -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() {

View File

@ -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)

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");
}
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;
}
@ -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();
}
/*

View File

@ -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);
}

View File

@ -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") {

View File

@ -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);

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();