dom-render 1.0.90 → 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 +15 -3
- package/components/ComponentSet.d.ts +5 -2
- package/components/ComponentSet.js +2 -3
- package/configs/Config.d.ts +5 -0
- package/configs/TargetElement.d.ts +1 -1
- package/dist/bundle.js +1337 -968
- package/events/EventManager.js +1 -0
- package/operators/Dr.d.ts +7 -3
- package/operators/Dr.js +64 -25
- package/operators/DrAppender.d.ts +7 -3
- package/operators/DrAppender.js +70 -28
- package/operators/DrFor.d.ts +7 -3
- package/operators/DrFor.js +67 -25
- package/operators/DrForOf.d.ts +7 -3
- package/operators/DrForOf.js +70 -28
- package/operators/DrForm.d.ts +7 -3
- package/operators/DrForm.js +93 -55
- package/operators/DrIf.d.ts +7 -3
- package/operators/DrIf.js +71 -35
- package/operators/DrInnerHTML.d.ts +7 -3
- package/operators/DrInnerHTML.js +62 -23
- package/operators/DrInnerText.d.ts +7 -3
- package/operators/DrInnerText.js +60 -21
- package/operators/DrPre.d.ts +6 -3
- package/operators/DrPre.js +49 -6
- package/operators/DrRepeat.d.ts +7 -3
- package/operators/DrRepeat.js +67 -25
- package/operators/DrTargetAttr.d.ts +6 -3
- package/operators/DrTargetAttr.js +72 -29
- package/operators/DrTargetElement.d.ts +6 -3
- package/operators/DrTargetElement.js +86 -64
- package/operators/DrThis.d.ts +4 -3
- package/operators/DrThis.js +77 -33
- package/operators/OperatorExecuter.d.ts +49 -0
- package/operators/OperatorExecuter.js +89 -0
- package/operators/OperatorExecuterAttrRequire.d.ts +8 -0
- package/operators/OperatorExecuterAttrRequire.js +79 -0
- package/package.json +1 -1
- package/rawsets/RawSet.d.ts +4 -4
- package/rawsets/RawSet.js +460 -317
- 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/operators/OperatorRender.d.ts +0 -45
- package/operators/OperatorRender.js +0 -21
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
@@ -1,4 +1,8 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
1
|
+
import { OperatorExecuterAttrRequire } from './OperatorExecuterAttrRequire';
|
2
|
+
import { RawSet } from '../rawsets/RawSet';
|
3
|
+
import { Render } from '../rawsets/Render';
|
4
|
+
import { AfterCallBack, ElementSource, ExecuteState, ReturnContainer, Source } from './OperatorExecuter';
|
5
|
+
export declare class Dr extends OperatorExecuterAttrRequire<null> {
|
6
|
+
constructor(rawSet: RawSet, render: Render, returnContainer: ReturnContainer, elementSource: ElementSource, source: Source, afterCallBack: AfterCallBack);
|
7
|
+
executeAttrRequire(data: null): Promise<ExecuteState>;
|
4
8
|
}
|
package/operators/Dr.js
CHANGED
@@ -25,38 +25,77 @@ 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
|
-
var
|
66
|
+
var OperatorExecuterAttrRequire_1 = require("./OperatorExecuterAttrRequire");
|
31
67
|
var ScriptUtils_1 = require("../utils/script/ScriptUtils");
|
32
68
|
var RawSet_1 = require("../rawsets/RawSet");
|
69
|
+
var OperatorExecuter_1 = require("./OperatorExecuter");
|
33
70
|
var Dr = /** @class */ (function (_super) {
|
34
71
|
__extends(Dr, _super);
|
35
|
-
function Dr() {
|
36
|
-
return _super
|
72
|
+
function Dr(rawSet, render, returnContainer, elementSource, source, afterCallBack) {
|
73
|
+
return _super.call(this, rawSet, render, returnContainer, elementSource, source, afterCallBack) || this;
|
37
74
|
}
|
38
|
-
Dr.prototype.
|
39
|
-
var _a;
|
40
|
-
|
41
|
-
|
42
|
-
var
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
75
|
+
Dr.prototype.executeAttrRequire = function (data) {
|
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
|
+
});
|
59
98
|
};
|
60
99
|
return Dr;
|
61
|
-
}(
|
100
|
+
}(OperatorExecuterAttrRequire_1.OperatorExecuterAttrRequire));
|
62
101
|
exports.Dr = Dr;
|
@@ -1,4 +1,8 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
1
|
+
import { OperatorExecuterAttrRequire } from './OperatorExecuterAttrRequire';
|
2
|
+
import { RawSet } from '../rawsets/RawSet';
|
3
|
+
import { Render } from '../rawsets/Render';
|
4
|
+
import { AfterCallBack, ElementSource, ExecuteState, ReturnContainer, Source } from './OperatorExecuter';
|
5
|
+
export declare class DrAppender extends OperatorExecuterAttrRequire<string> {
|
6
|
+
constructor(rawSet: RawSet, render: Render, returnContainer: ReturnContainer, elementSource: ElementSource, source: Source, afterCallBack: AfterCallBack);
|
7
|
+
executeAttrRequire(attr: string): Promise<ExecuteState>;
|
4
8
|
}
|
package/operators/DrAppender.js
CHANGED
@@ -25,41 +25,83 @@ 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
|
-
var
|
66
|
+
var OperatorExecuterAttrRequire_1 = require("./OperatorExecuterAttrRequire");
|
31
67
|
var ScriptUtils_1 = require("../utils/script/ScriptUtils");
|
32
68
|
var RawSet_1 = require("../rawsets/RawSet");
|
69
|
+
var OperatorExecuter_1 = require("./OperatorExecuter");
|
33
70
|
var DrAppender = /** @class */ (function (_super) {
|
34
71
|
__extends(DrAppender, _super);
|
35
|
-
function DrAppender() {
|
36
|
-
|
72
|
+
function DrAppender(rawSet, render, returnContainer, elementSource, source, afterCallBack) {
|
73
|
+
var _this = this;
|
74
|
+
source.operatorAround = undefined;
|
75
|
+
_this = _super.call(this, rawSet, render, returnContainer, elementSource, source, afterCallBack, false) || this;
|
76
|
+
return _this;
|
37
77
|
}
|
38
|
-
DrAppender.prototype.
|
39
|
-
var _a;
|
40
|
-
|
41
|
-
|
42
|
-
var
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
78
|
+
DrAppender.prototype.executeAttrRequire = function (attr) {
|
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
|
+
});
|
62
104
|
};
|
63
105
|
return DrAppender;
|
64
|
-
}(
|
106
|
+
}(OperatorExecuterAttrRequire_1.OperatorExecuterAttrRequire));
|
65
107
|
exports.DrAppender = DrAppender;
|
package/operators/DrFor.d.ts
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
1
|
+
import { OperatorExecuterAttrRequire } from './OperatorExecuterAttrRequire';
|
2
|
+
import { RawSet } from '../rawsets/RawSet';
|
3
|
+
import { Render } from '../rawsets/Render';
|
4
|
+
import { AfterCallBack, ElementSource, ExecuteState, ReturnContainer, Source } from './OperatorExecuter';
|
5
|
+
export declare class DrFor extends OperatorExecuterAttrRequire<string> {
|
6
|
+
constructor(rawSet: RawSet, render: Render, returnContainer: ReturnContainer, elementSource: ElementSource, source: Source, afterCallBack: AfterCallBack);
|
7
|
+
executeAttrRequire(attr: string): Promise<ExecuteState>;
|
4
8
|
}
|
package/operators/DrFor.js
CHANGED
@@ -25,38 +25,80 @@ 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
|
-
var
|
66
|
+
var OperatorExecuterAttrRequire_1 = require("./OperatorExecuterAttrRequire");
|
31
67
|
var ScriptUtils_1 = require("../utils/script/ScriptUtils");
|
32
68
|
var RawSet_1 = require("../rawsets/RawSet");
|
69
|
+
var OperatorExecuter_1 = require("./OperatorExecuter");
|
33
70
|
var DrFor = /** @class */ (function (_super) {
|
34
71
|
__extends(DrFor, _super);
|
35
|
-
function DrFor() {
|
36
|
-
|
72
|
+
function DrFor(rawSet, render, returnContainer, elementSource, source, afterCallBack) {
|
73
|
+
var _this = this;
|
74
|
+
source.operatorAround = undefined;
|
75
|
+
_this = _super.call(this, rawSet, render, returnContainer, elementSource, source, afterCallBack, false) || this;
|
76
|
+
return _this;
|
37
77
|
}
|
38
|
-
DrFor.prototype.
|
39
|
-
var _a;
|
40
|
-
|
41
|
-
|
42
|
-
var
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
78
|
+
DrFor.prototype.executeAttrRequire = function (attr) {
|
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
|
+
});
|
59
101
|
};
|
60
102
|
return DrFor;
|
61
|
-
}(
|
103
|
+
}(OperatorExecuterAttrRequire_1.OperatorExecuterAttrRequire));
|
62
104
|
exports.DrFor = DrFor;
|
package/operators/DrForOf.d.ts
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
1
|
+
import { OperatorExecuterAttrRequire } from './OperatorExecuterAttrRequire';
|
2
|
+
import { RawSet } from '../rawsets/RawSet';
|
3
|
+
import { Render } from '../rawsets/Render';
|
4
|
+
import { AfterCallBack, ElementSource, ExecuteState, ReturnContainer, Source } from './OperatorExecuter';
|
5
|
+
export declare class DrForOf extends OperatorExecuterAttrRequire<string> {
|
6
|
+
constructor(rawSet: RawSet, render: Render, returnContainer: ReturnContainer, elementSource: ElementSource, source: Source, afterCallBack: AfterCallBack);
|
7
|
+
executeAttrRequire(attr: string): Promise<ExecuteState>;
|
4
8
|
}
|
package/operators/DrForOf.js
CHANGED
@@ -25,41 +25,83 @@ 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
|
-
var
|
66
|
+
var OperatorExecuterAttrRequire_1 = require("./OperatorExecuterAttrRequire");
|
31
67
|
var ScriptUtils_1 = require("../utils/script/ScriptUtils");
|
32
68
|
var RawSet_1 = require("../rawsets/RawSet");
|
69
|
+
var OperatorExecuter_1 = require("./OperatorExecuter");
|
33
70
|
var DrForOf = /** @class */ (function (_super) {
|
34
71
|
__extends(DrForOf, _super);
|
35
|
-
function DrForOf() {
|
36
|
-
|
72
|
+
function DrForOf(rawSet, render, returnContainer, elementSource, source, afterCallBack) {
|
73
|
+
var _this = this;
|
74
|
+
source.operatorAround = undefined;
|
75
|
+
_this = _super.call(this, rawSet, render, returnContainer, elementSource, source, afterCallBack, false) || this;
|
76
|
+
return _this;
|
37
77
|
}
|
38
|
-
DrForOf.prototype.
|
39
|
-
var _a;
|
40
|
-
|
41
|
-
|
42
|
-
var
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
78
|
+
DrForOf.prototype.executeAttrRequire = function (attr) {
|
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
|
+
});
|
62
104
|
};
|
63
105
|
return DrForOf;
|
64
|
-
}(
|
106
|
+
}(OperatorExecuterAttrRequire_1.OperatorExecuterAttrRequire));
|
65
107
|
exports.DrForOf = DrForOf;
|
package/operators/DrForm.d.ts
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
1
|
+
import { RawSet } from '../rawsets/RawSet';
|
2
|
+
import { Render } from '../rawsets/Render';
|
3
|
+
import { OperatorExecuterAttrRequire } from './OperatorExecuterAttrRequire';
|
4
|
+
import { AfterCallBack, ElementSource, ExecuteState, ReturnContainer, Source } from './OperatorExecuter';
|
5
|
+
export declare class DrForm extends OperatorExecuterAttrRequire<string> {
|
6
|
+
constructor(rawSet: RawSet, render: Render, returnContainer: ReturnContainer, elementSource: ElementSource, source: Source, afterCallBack: AfterCallBack);
|
7
|
+
executeAttrRequire(attr: string): Promise<ExecuteState>;
|
4
8
|
}
|