dom-render 1.0.91 → 1.0.92
Sign up to get free protection for your applications and to get access to all the features.
- package/DomRender.js +5 -1
- package/DomRenderProxy.d.ts +1 -1
- package/DomRenderProxy.js +121 -63
- package/README.MD +14 -2
- package/configs/TargetElement.d.ts +1 -1
- package/dist/bundle.js +1189 -835
- package/events/EventManager.js +1 -0
- package/operators/Dr.d.ts +1 -1
- package/operators/Dr.js +58 -17
- package/operators/DrAppender.d.ts +1 -1
- package/operators/DrAppender.js +61 -21
- package/operators/DrFor.d.ts +1 -1
- package/operators/DrFor.js +58 -17
- package/operators/DrForOf.d.ts +1 -1
- package/operators/DrForOf.js +61 -20
- package/operators/DrForm.d.ts +1 -1
- package/operators/DrForm.js +87 -46
- package/operators/DrIf.d.ts +1 -1
- package/operators/DrIf.js +62 -23
- package/operators/DrInnerHTML.d.ts +1 -1
- package/operators/DrInnerHTML.js +56 -15
- package/operators/DrInnerText.d.ts +1 -1
- package/operators/DrInnerText.js +54 -13
- package/operators/DrPre.d.ts +1 -1
- package/operators/DrPre.js +41 -1
- package/operators/DrRepeat.d.ts +1 -1
- package/operators/DrRepeat.js +58 -17
- package/operators/DrTargetAttr.d.ts +1 -1
- package/operators/DrTargetAttr.js +64 -23
- package/operators/DrTargetElement.d.ts +1 -1
- package/operators/DrTargetElement.js +78 -34
- package/operators/DrThis.d.ts +1 -1
- package/operators/DrThis.js +73 -23
- package/operators/OperatorExecuter.d.ts +3 -2
- package/operators/OperatorExecuter.js +60 -14
- package/operators/OperatorExecuterAttrRequire.d.ts +2 -2
- package/operators/OperatorExecuterAttrRequire.js +48 -24
- package/package.json +1 -1
- package/rawsets/RawSet.d.ts +3 -3
- package/rawsets/RawSet.js +458 -315
- package/routers/HashRouter.js +1 -1
- package/routers/PathRouter.js +1 -1
- package/routers/Router.d.ts +3 -0
- package/routers/Router.js +10 -0
package/events/EventManager.js
CHANGED
@@ -378,6 +378,7 @@ var EventManager = /** @class */ (function () {
|
|
378
378
|
// eslint-disable-next-line no-undef
|
379
379
|
EventManager.prototype.addDrEvents = function (obj, eventName, elements, config) {
|
380
380
|
var _this = this;
|
381
|
+
// console.log('-------?', config?.router)
|
381
382
|
var attr = EventManager.attrPrefix + 'event-' + eventName;
|
382
383
|
this.procAttr(elements, attr, function (it, attribute) {
|
383
384
|
var script = attribute;
|
package/operators/Dr.d.ts
CHANGED
@@ -4,5 +4,5 @@ import { Render } from '../rawsets/Render';
|
|
4
4
|
import { AfterCallBack, ElementSource, ExecuteState, ReturnContainer, Source } from './OperatorExecuter';
|
5
5
|
export declare class Dr extends OperatorExecuterAttrRequire<null> {
|
6
6
|
constructor(rawSet: RawSet, render: Render, returnContainer: ReturnContainer, elementSource: ElementSource, source: Source, afterCallBack: AfterCallBack);
|
7
|
-
executeAttrRequire(data: null): ExecuteState
|
7
|
+
executeAttrRequire(data: null): Promise<ExecuteState>;
|
8
8
|
}
|
package/operators/Dr.js
CHANGED
@@ -25,6 +25,42 @@ var __assign = (this && this.__assign) || function () {
|
|
25
25
|
};
|
26
26
|
return __assign.apply(this, arguments);
|
27
27
|
};
|
28
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
29
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
30
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
31
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
32
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
33
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
34
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
35
|
+
});
|
36
|
+
};
|
37
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
38
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
39
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
40
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
41
|
+
function step(op) {
|
42
|
+
if (f) throw new TypeError("Generator is already executing.");
|
43
|
+
while (_) try {
|
44
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
45
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
46
|
+
switch (op[0]) {
|
47
|
+
case 0: case 1: t = op; break;
|
48
|
+
case 4: _.label++; return { value: op[1], done: false };
|
49
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
50
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
51
|
+
default:
|
52
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
53
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
54
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
55
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
56
|
+
if (t[2]) _.ops.pop();
|
57
|
+
_.trys.pop(); continue;
|
58
|
+
}
|
59
|
+
op = body.call(thisArg, _);
|
60
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
61
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
62
|
+
}
|
63
|
+
};
|
28
64
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
65
|
exports.Dr = void 0;
|
30
66
|
var OperatorExecuterAttrRequire_1 = require("./OperatorExecuterAttrRequire");
|
@@ -37,23 +73,28 @@ var Dr = /** @class */ (function (_super) {
|
|
37
73
|
return _super.call(this, rawSet, render, returnContainer, elementSource, source, afterCallBack) || this;
|
38
74
|
}
|
39
75
|
Dr.prototype.executeAttrRequire = function (data) {
|
40
|
-
var _a;
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
76
|
+
var _a, _b;
|
77
|
+
return __awaiter(this, void 0, void 0, function () {
|
78
|
+
var itRandom, vars, newTemp, tempalte, rr;
|
79
|
+
var _c;
|
80
|
+
return __generator(this, function (_d) {
|
81
|
+
itRandom = RawSet_1.RawSet.drItOtherEncoding(this.elementSource.element);
|
82
|
+
vars = RawSet_1.RawSet.drVarEncoding(this.elementSource.element, (_a = this.elementSource.attrs.drVarOption) !== null && _a !== void 0 ? _a : '');
|
83
|
+
newTemp = this.source.config.window.document.createElement('temp');
|
84
|
+
ScriptUtils_1.ScriptUtils.eval("\n ".concat(this.render.bindScript, "\n const n = $element.cloneNode(true);\n var destIt = ").concat(this.elementSource.attrs.drItOption, ";\n if (destIt !== undefined) {\n n.getAttributeNames().forEach(it => n.setAttribute(it, n.getAttribute(it).replace(/\\#it\\#/g, destIt)))\n // console.log('----', n.innerHTML);\n n.innerHTML = n.innerHTML.replace(/\\#it\\#/g, destIt);\n // console.log('----', n.innerHTML);\n }\n if (this.__render.drStripOption === 'true') {\n Array.from(n.childNodes).forEach(it => this.__fag.append(it));\n } else {\n this.__render.fag.append(n);\n }"), Object.assign(this.source.obj, {
|
85
|
+
__render: Object.freeze(__assign({ fag: newTemp, drStripOption: this.elementSource.attrs.drStripOption }, this.render))
|
86
|
+
}));
|
87
|
+
RawSet_1.RawSet.drVarDecoding(newTemp, vars);
|
88
|
+
RawSet_1.RawSet.drItOtherDecoding(newTemp, itRandom);
|
89
|
+
tempalte = this.source.config.window.document.createElement('template');
|
90
|
+
tempalte.innerHTML = newTemp.innerHTML;
|
91
|
+
this.returnContainer.fag.append(tempalte.content);
|
92
|
+
rr = RawSet_1.RawSet.checkPointCreates(this.returnContainer.fag, this.source.obj, this.source.config);
|
93
|
+
(_b = this.elementSource.element.parentNode) === null || _b === void 0 ? void 0 : _b.replaceChild(this.returnContainer.fag, this.elementSource.element);
|
94
|
+
(_c = this.returnContainer.raws).push.apply(_c, rr);
|
95
|
+
return [2 /*return*/, OperatorExecuter_1.ExecuteState.EXECUTE];
|
96
|
+
});
|
97
|
+
});
|
57
98
|
};
|
58
99
|
return Dr;
|
59
100
|
}(OperatorExecuterAttrRequire_1.OperatorExecuterAttrRequire));
|
@@ -4,5 +4,5 @@ import { Render } from '../rawsets/Render';
|
|
4
4
|
import { AfterCallBack, ElementSource, ExecuteState, ReturnContainer, Source } from './OperatorExecuter';
|
5
5
|
export declare class DrAppender extends OperatorExecuterAttrRequire<string> {
|
6
6
|
constructor(rawSet: RawSet, render: Render, returnContainer: ReturnContainer, elementSource: ElementSource, source: Source, afterCallBack: AfterCallBack);
|
7
|
-
executeAttrRequire(attr: string): ExecuteState
|
7
|
+
executeAttrRequire(attr: string): Promise<ExecuteState>;
|
8
8
|
}
|
package/operators/DrAppender.js
CHANGED
@@ -25,6 +25,42 @@ var __assign = (this && this.__assign) || function () {
|
|
25
25
|
};
|
26
26
|
return __assign.apply(this, arguments);
|
27
27
|
};
|
28
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
29
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
30
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
31
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
32
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
33
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
34
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
35
|
+
});
|
36
|
+
};
|
37
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
38
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
39
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
40
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
41
|
+
function step(op) {
|
42
|
+
if (f) throw new TypeError("Generator is already executing.");
|
43
|
+
while (_) try {
|
44
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
45
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
46
|
+
switch (op[0]) {
|
47
|
+
case 0: case 1: t = op; break;
|
48
|
+
case 4: _.label++; return { value: op[1], done: false };
|
49
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
50
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
51
|
+
default:
|
52
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
53
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
54
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
55
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
56
|
+
if (t[2]) _.ops.pop();
|
57
|
+
_.trys.pop(); continue;
|
58
|
+
}
|
59
|
+
op = body.call(thisArg, _);
|
60
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
61
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
62
|
+
}
|
63
|
+
};
|
28
64
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
65
|
exports.DrAppender = void 0;
|
30
66
|
var OperatorExecuterAttrRequire_1 = require("./OperatorExecuterAttrRequire");
|
@@ -40,27 +76,31 @@ var DrAppender = /** @class */ (function (_super) {
|
|
40
76
|
return _this;
|
41
77
|
}
|
42
78
|
DrAppender.prototype.executeAttrRequire = function (attr) {
|
43
|
-
var _a;
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
79
|
+
var _a, _b, _c, _d;
|
80
|
+
return __awaiter(this, void 0, void 0, function () {
|
81
|
+
var itRandom, vars, newTemp, tempalte, rr;
|
82
|
+
var _e;
|
83
|
+
return __generator(this, function (_f) {
|
84
|
+
itRandom = RawSet_1.RawSet.drItOtherEncoding(this.elementSource.element);
|
85
|
+
vars = RawSet_1.RawSet.drVarEncoding(this.elementSource.element, (_a = this.elementSource.attrs.drVarOption) !== null && _a !== void 0 ? _a : '');
|
86
|
+
newTemp = this.source.config.window.document.createElement('temp');
|
87
|
+
ScriptUtils_1.ScriptUtils.eval("\n try{\n ".concat(this.render.bindScript, "\n ").concat((_b = this.elementSource.attrs.drBeforeOption) !== null && _b !== void 0 ? _b : '', "\n const ifWrap = document.createElement('div');\n ifWrap.setAttribute('dr-strip', 'true');\n ifWrap.setAttribute('dr-if', '").concat(this.elementSource.attrs.drAppender, " && ").concat(this.elementSource.attrs.drAppender, ".length > 0');\n const n = this.__render.element.cloneNode(true);\n Object.entries(this.__render.drAttr).filter(([k,v]) => k !== 'drAppender' && v).forEach(([k, v]) => n.setAttribute(this.__render.drAttrsOriginName[k], v));\n n.setAttribute('dr-for-of', '").concat(this.elementSource.attrs.drAppender, "[' + (").concat(this.elementSource.attrs.drAppender, ".length-1) + ']');\n n.setAttribute('dr-next', '").concat(this.elementSource.attrs.drAppender, ",' + ").concat(this.elementSource.attrs.drAppender, ".length);\n ifWrap.append(n);\n this.__render.fag.append(ifWrap);\n ").concat((_c = this.elementSource.attrs.drAfterOption) !== null && _c !== void 0 ? _c : '', "\n }catch(e){}\n "), Object.assign(this.source.obj, {
|
88
|
+
__render: Object.freeze(__assign({ drStripOption: this.elementSource.attrs.drStripOption, drAttr: this.elementSource.attrs, drAttrsOriginName: RawSet_1.RawSet.drAttrsOriginName, fag: newTemp }, this.render
|
89
|
+
// eslint-disable-next-line no-use-before-define
|
90
|
+
))
|
91
|
+
}));
|
92
|
+
RawSet_1.RawSet.drVarDecoding(newTemp, vars);
|
93
|
+
RawSet_1.RawSet.drItOtherDecoding(newTemp, itRandom);
|
94
|
+
tempalte = this.source.config.window.document.createElement('template');
|
95
|
+
tempalte.innerHTML = newTemp.innerHTML;
|
96
|
+
this.returnContainer.fag.append(tempalte.content);
|
97
|
+
rr = RawSet_1.RawSet.checkPointCreates(this.returnContainer.fag, this.source.obj, this.source.config);
|
98
|
+
(_d = this.elementSource.element.parentNode) === null || _d === void 0 ? void 0 : _d.replaceChild(this.returnContainer.fag, this.elementSource.element);
|
99
|
+
// const rrr = rr.flatMap(it => it.render(obj, config));// .flat();
|
100
|
+
(_e = this.returnContainer.raws).push.apply(_e, rr);
|
101
|
+
return [2 /*return*/, OperatorExecuter_1.ExecuteState.EXECUTE];
|
102
|
+
});
|
103
|
+
});
|
64
104
|
};
|
65
105
|
return DrAppender;
|
66
106
|
}(OperatorExecuterAttrRequire_1.OperatorExecuterAttrRequire));
|
package/operators/DrFor.d.ts
CHANGED
@@ -4,5 +4,5 @@ import { Render } from '../rawsets/Render';
|
|
4
4
|
import { AfterCallBack, ElementSource, ExecuteState, ReturnContainer, Source } from './OperatorExecuter';
|
5
5
|
export declare class DrFor extends OperatorExecuterAttrRequire<string> {
|
6
6
|
constructor(rawSet: RawSet, render: Render, returnContainer: ReturnContainer, elementSource: ElementSource, source: Source, afterCallBack: AfterCallBack);
|
7
|
-
executeAttrRequire(attr: string): ExecuteState
|
7
|
+
executeAttrRequire(attr: string): Promise<ExecuteState>;
|
8
8
|
}
|
package/operators/DrFor.js
CHANGED
@@ -25,6 +25,42 @@ var __assign = (this && this.__assign) || function () {
|
|
25
25
|
};
|
26
26
|
return __assign.apply(this, arguments);
|
27
27
|
};
|
28
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
29
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
30
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
31
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
32
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
33
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
34
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
35
|
+
});
|
36
|
+
};
|
37
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
38
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
39
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
40
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
41
|
+
function step(op) {
|
42
|
+
if (f) throw new TypeError("Generator is already executing.");
|
43
|
+
while (_) try {
|
44
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
45
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
46
|
+
switch (op[0]) {
|
47
|
+
case 0: case 1: t = op; break;
|
48
|
+
case 4: _.label++; return { value: op[1], done: false };
|
49
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
50
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
51
|
+
default:
|
52
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
53
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
54
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
55
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
56
|
+
if (t[2]) _.ops.pop();
|
57
|
+
_.trys.pop(); continue;
|
58
|
+
}
|
59
|
+
op = body.call(thisArg, _);
|
60
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
61
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
62
|
+
}
|
63
|
+
};
|
28
64
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
65
|
exports.DrFor = void 0;
|
30
66
|
var OperatorExecuterAttrRequire_1 = require("./OperatorExecuterAttrRequire");
|
@@ -40,23 +76,28 @@ var DrFor = /** @class */ (function (_super) {
|
|
40
76
|
return _this;
|
41
77
|
}
|
42
78
|
DrFor.prototype.executeAttrRequire = function (attr) {
|
43
|
-
var _a;
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
79
|
+
var _a, _b, _c, _d;
|
80
|
+
return __awaiter(this, void 0, void 0, function () {
|
81
|
+
var itRandom, vars, newTemp, tempalte, rr;
|
82
|
+
var _e;
|
83
|
+
return __generator(this, function (_f) {
|
84
|
+
itRandom = RawSet_1.RawSet.drItOtherEncoding(this.elementSource.element);
|
85
|
+
vars = RawSet_1.RawSet.drVarEncoding(this.elementSource.element, (_a = this.elementSource.attrs.drVarOption) !== null && _a !== void 0 ? _a : '');
|
86
|
+
newTemp = this.source.config.window.document.createElement('temp');
|
87
|
+
ScriptUtils_1.ScriptUtils.eval("\n ".concat(this.render.bindScript, "\n ").concat((_b = this.elementSource.attrs.drBeforeOption) !== null && _b !== void 0 ? _b : '', "\n for(").concat(attr, ") {\n const n = this.__render.element.cloneNode(true);\n var destIt = ").concat(this.elementSource.attrs.drItOption, ";\n if (destIt !== undefined) {\n n.getAttributeNames().forEach(it => n.setAttribute(it, n.getAttribute(it).replace(/\\#it\\#/g, destIt).replace(/\\#nearForIt\\#/g, destIt).replace(/\\#nearForIndex\\#/g, destIt))) \n n.innerHTML = n.innerHTML.replace(/\\#it\\#/g, destIt).replace(/\\#index\\#/g, destIt);\n }\n if (this.__render.drStripOption === 'true') {\n Array.from(n.childNodes).forEach(it => this.__render.fag.append(it));\n } else {\n this.__render.fag.append(n);\n }\n }\n ").concat((_c = this.elementSource.attrs.drAfterOption) !== null && _c !== void 0 ? _c : '', "\n "), Object.assign(this.source.obj, {
|
88
|
+
__render: Object.freeze(__assign({ fag: newTemp, drStripOption: this.elementSource.attrs.drStripOption }, this.render))
|
89
|
+
}));
|
90
|
+
RawSet_1.RawSet.drVarDecoding(newTemp, vars);
|
91
|
+
RawSet_1.RawSet.drItOtherDecoding(newTemp, itRandom);
|
92
|
+
tempalte = this.source.config.window.document.createElement('template');
|
93
|
+
tempalte.innerHTML = newTemp.innerHTML;
|
94
|
+
this.returnContainer.fag.append(tempalte.content);
|
95
|
+
rr = RawSet_1.RawSet.checkPointCreates(this.returnContainer.fag, this.source.obj, this.source.config);
|
96
|
+
(_d = this.elementSource.element.parentNode) === null || _d === void 0 ? void 0 : _d.replaceChild(this.returnContainer.fag, this.elementSource.element);
|
97
|
+
(_e = this.returnContainer.raws).push.apply(_e, rr);
|
98
|
+
return [2 /*return*/, OperatorExecuter_1.ExecuteState.EXECUTE];
|
99
|
+
});
|
100
|
+
});
|
60
101
|
};
|
61
102
|
return DrFor;
|
62
103
|
}(OperatorExecuterAttrRequire_1.OperatorExecuterAttrRequire));
|
package/operators/DrForOf.d.ts
CHANGED
@@ -4,5 +4,5 @@ import { Render } from '../rawsets/Render';
|
|
4
4
|
import { AfterCallBack, ElementSource, ExecuteState, ReturnContainer, Source } from './OperatorExecuter';
|
5
5
|
export declare class DrForOf extends OperatorExecuterAttrRequire<string> {
|
6
6
|
constructor(rawSet: RawSet, render: Render, returnContainer: ReturnContainer, elementSource: ElementSource, source: Source, afterCallBack: AfterCallBack);
|
7
|
-
executeAttrRequire(attr: string): ExecuteState
|
7
|
+
executeAttrRequire(attr: string): Promise<ExecuteState>;
|
8
8
|
}
|
package/operators/DrForOf.js
CHANGED
@@ -25,6 +25,42 @@ var __assign = (this && this.__assign) || function () {
|
|
25
25
|
};
|
26
26
|
return __assign.apply(this, arguments);
|
27
27
|
};
|
28
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
29
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
30
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
31
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
32
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
33
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
34
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
35
|
+
});
|
36
|
+
};
|
37
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
38
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
39
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
40
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
41
|
+
function step(op) {
|
42
|
+
if (f) throw new TypeError("Generator is already executing.");
|
43
|
+
while (_) try {
|
44
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
45
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
46
|
+
switch (op[0]) {
|
47
|
+
case 0: case 1: t = op; break;
|
48
|
+
case 4: _.label++; return { value: op[1], done: false };
|
49
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
50
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
51
|
+
default:
|
52
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
53
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
54
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
55
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
56
|
+
if (t[2]) _.ops.pop();
|
57
|
+
_.trys.pop(); continue;
|
58
|
+
}
|
59
|
+
op = body.call(thisArg, _);
|
60
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
61
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
62
|
+
}
|
63
|
+
};
|
28
64
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
65
|
exports.DrForOf = void 0;
|
30
66
|
var OperatorExecuterAttrRequire_1 = require("./OperatorExecuterAttrRequire");
|
@@ -40,26 +76,31 @@ var DrForOf = /** @class */ (function (_super) {
|
|
40
76
|
return _this;
|
41
77
|
}
|
42
78
|
DrForOf.prototype.executeAttrRequire = function (attr) {
|
43
|
-
var _a;
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
79
|
+
var _a, _b, _c, _d;
|
80
|
+
return __awaiter(this, void 0, void 0, function () {
|
81
|
+
var itRandom, vars, newTemp, tempalte, rr;
|
82
|
+
var _e;
|
83
|
+
return __generator(this, function (_f) {
|
84
|
+
itRandom = RawSet_1.RawSet.drItOtherEncoding(this.elementSource.element);
|
85
|
+
vars = RawSet_1.RawSet.drVarEncoding(this.elementSource.element, (_a = this.elementSource.attrs.drVarOption) !== null && _a !== void 0 ? _a : '');
|
86
|
+
newTemp = this.source.config.window.document.createElement('temp');
|
87
|
+
ScriptUtils_1.ScriptUtils.eval("\n ".concat(this.render.bindScript, "\n ").concat((_b = this.elementSource.attrs.drBeforeOption) !== null && _b !== void 0 ? _b : '', "\n var i = 0; \n const forOf = ").concat(attr, ";\n const forOfStr = `").concat(attr, "`.trim();\n if (forOf) {\n for(const it of forOf) {\n var destIt = it;\n if (/\\[(.*,?)\\],/g.test(forOfStr)) {\n if (typeof it === 'string') {\n destIt = it;\n } else {\n destIt = forOfStr.substring(1, forOfStr.length-1).split(',')[i];\n }\n } else if (forOf.isRange) {\n destIt = it;\n } else {\n destIt = forOfStr + '[' + i +']'\n }\n const n = this.__render.element.cloneNode(true);\n Object.entries(this.__render.drAttr).filter(([k,v]) => k !== 'drForOf' && k !== 'drNextOption' && v).forEach(([k, v]) => n.setAttribute(this.__render.drAttrsOriginName[k], v));\n n.getAttributeNames().forEach(it => n.setAttribute(it, n.getAttribute(it).replace(/\\#it\\#/g, destIt).replace(/\\#nearForOfIt\\#/g, destIt).replace(/\\#it\\#/g, destIt).replace(/\\#nearForOfIndex\\#/g, i)))\n n.innerHTML = n.innerHTML.replace(/\\#it\\#/g, destIt).replace(/\\#index\\#/g, i);\n if (this.__render.drStripOption === 'true') {\n Array.from(n.childNodes).forEach(it => this.__render.fag.append(it));\n } else {\n this.__render.fag.append(n);\n }\n i++;\n }\n \n if('").concat(this.elementSource.attrs.drNextOption, "' !== 'null') {\n const n = this.__render.element.cloneNode(true);\n Object.entries(this.__render.drAttr).filter(([k,v]) => k !== 'drForOf' && k !== 'drNextOption' && v).forEach(([k, v]) => n.setAttribute(this.__render.drAttrsOriginName[k], v));\n const [name, idx] = '").concat(this.elementSource.attrs.drNextOption, "'.split(',');\n n.setAttribute('dr-for-of', name + '[' + idx + ']');\n n.setAttribute('dr-next', name + ',' + (Number(idx) + 1));\n this.__render.fag.append(n);\n }\n }\n ").concat((_c = this.elementSource.attrs.drAfterOption) !== null && _c !== void 0 ? _c : '', "\n "), Object.assign(this.source.obj, {
|
88
|
+
__render: Object.freeze(__assign({ drStripOption: this.elementSource.attrs.drStripOption, drAttr: this.elementSource.attrs, drAttrsOriginName: RawSet_1.RawSet.drAttrsOriginName, fag: newTemp }, this.render
|
89
|
+
// eslint-disable-next-line no-use-before-define
|
90
|
+
))
|
91
|
+
}));
|
92
|
+
RawSet_1.RawSet.drVarDecoding(newTemp, vars);
|
93
|
+
RawSet_1.RawSet.drItOtherDecoding(newTemp, itRandom);
|
94
|
+
tempalte = this.source.config.window.document.createElement('template');
|
95
|
+
tempalte.innerHTML = newTemp.innerHTML;
|
96
|
+
this.returnContainer.fag.append(tempalte.content);
|
97
|
+
rr = RawSet_1.RawSet.checkPointCreates(this.returnContainer.fag, this.source.obj, this.source.config);
|
98
|
+
(_d = this.elementSource.element.parentNode) === null || _d === void 0 ? void 0 : _d.replaceChild(this.returnContainer.fag, this.elementSource.element);
|
99
|
+
// const rrr = rr.flatMap(it => it.render(obj, config));// .flat();
|
100
|
+
(_e = this.returnContainer.raws).push.apply(_e, rr);
|
101
|
+
return [2 /*return*/, OperatorExecuter_1.ExecuteState.EXECUTE];
|
102
|
+
});
|
103
|
+
});
|
63
104
|
};
|
64
105
|
return DrForOf;
|
65
106
|
}(OperatorExecuterAttrRequire_1.OperatorExecuterAttrRequire));
|
package/operators/DrForm.d.ts
CHANGED
@@ -4,5 +4,5 @@ import { OperatorExecuterAttrRequire } from './OperatorExecuterAttrRequire';
|
|
4
4
|
import { AfterCallBack, ElementSource, ExecuteState, ReturnContainer, Source } from './OperatorExecuter';
|
5
5
|
export declare class DrForm extends OperatorExecuterAttrRequire<string> {
|
6
6
|
constructor(rawSet: RawSet, render: Render, returnContainer: ReturnContainer, elementSource: ElementSource, source: Source, afterCallBack: AfterCallBack);
|
7
|
-
executeAttrRequire(attr: string): ExecuteState
|
7
|
+
executeAttrRequire(attr: string): Promise<ExecuteState>;
|
8
8
|
}
|