dom-render 1.0.74 → 1.0.77
Sign up to get free protection for your applications and to get access to all the features.
- package/Config.d.ts +38 -36
- package/Config.js +2 -2
- package/DomRender.d.ts +28 -27
- package/DomRender.js +90 -88
- package/DomRenderProxy.d.ts +29 -29
- package/DomRenderProxy.js +342 -327
- package/README.MD +638 -567
- package/RawSet.d.ts +140 -118
- package/RawSet.js +771 -905
- package/components/ComponentSet.d.ts +7 -0
- package/components/ComponentSet.js +14 -0
- package/dist/bundle.js +3789 -3214
- package/events/EventManager.d.ts +48 -47
- package/events/EventManager.js +530 -499
- package/iterators/Range.d.ts +22 -22
- package/iterators/Range.js +65 -65
- package/lifecycle/OnBeforeReturnGet.d.ts +3 -3
- package/lifecycle/OnBeforeReturnGet.js +2 -2
- package/lifecycle/OnBeforeReturnSet.d.ts +3 -3
- package/lifecycle/OnBeforeReturnSet.js +2 -2
- package/lifecycle/OnCreateRender.d.ts +3 -3
- package/lifecycle/OnCreateRender.js +2 -2
- package/lifecycle/OnDestroyRender.d.ts +4 -4
- package/lifecycle/OnDestroyRender.js +2 -2
- package/lifecycle/OnInitRender.d.ts +7 -7
- package/lifecycle/OnInitRender.js +2 -2
- package/lifecycle/OnProxyDomRender.d.ts +4 -0
- package/lifecycle/OnProxyDomRender.js +2 -0
- package/managers/RenderManager.d.ts +3 -3
- package/managers/RenderManager.js +18 -18
- package/messenger/DefaultMessenger.d.ts +3 -0
- package/messenger/DefaultMessenger.js +27 -0
- package/messenger/Messenger.d.ts +78 -0
- package/messenger/Messenger.js +201 -0
- package/operators/Appender.d.ts +7 -12
- package/operators/Appender.js +32 -39
- package/operators/AttrExpresion.d.ts +0 -0
- package/operators/AttrExpresion.js +44 -0
- package/operators/Dr.d.ts +4 -0
- package/operators/Dr.js +62 -0
- package/operators/DrAppender.d.ts +4 -0
- package/operators/DrAppender.js +65 -0
- package/operators/DrFor.d.ts +4 -0
- package/operators/DrFor.js +62 -0
- package/operators/DrForOf.d.ts +4 -0
- package/operators/DrForOf.js +65 -0
- package/operators/DrForm.d.ts +4 -0
- package/operators/DrForm.js +100 -0
- package/operators/DrIf.d.ts +4 -0
- package/operators/DrIf.js +72 -0
- package/operators/DrInnerHTML.d.ts +4 -0
- package/operators/DrInnerHTML.js +60 -0
- package/operators/DrInnerText.d.ts +4 -0
- package/operators/DrInnerText.js +58 -0
- package/operators/DrPre.d.ts +4 -0
- package/operators/DrPre.js +30 -0
- package/operators/DrRepeat.d.ts +4 -0
- package/operators/DrRepeat.js +63 -0
- package/operators/DrTargetAttr.d.ts +4 -0
- package/operators/DrTargetAttr.js +55 -0
- package/operators/DrTargetElement.d.ts +4 -0
- package/operators/DrTargetElement.js +65 -0
- package/operators/DrThis.d.ts +4 -0
- package/operators/DrThis.js +59 -0
- package/operators/OperatorRender.d.ts +41 -0
- package/operators/OperatorRender.js +21 -0
- package/package.json +94 -94
- package/routers/HashRouter.d.ts +9 -9
- package/routers/HashRouter.js +53 -53
- package/routers/PathRouter.d.ts +9 -9
- package/routers/PathRouter.js +52 -52
- package/routers/Router.d.ts +25 -25
- package/routers/Router.js +116 -116
- package/types/Types.d.ts +14 -14
- package/types/Types.js +36 -36
- package/utils/clipboard/ClipBoardUtils.d.ts +6 -6
- package/utils/clipboard/ClipBoardUtils.js +25 -25
- package/utils/dom/DomUtils.d.ts +13 -13
- package/utils/dom/DomUtils.js +47 -47
- package/utils/location/LocationUtils.d.ts +16 -16
- package/utils/location/LocationUtils.js +57 -57
- package/utils/node/NodeUtils.d.ts +10 -10
- package/utils/node/NodeUtils.js +27 -27
- package/utils/random/RandomUtils.d.ts +7 -7
- package/utils/random/RandomUtils.js +47 -47
- package/utils/script/ScriptUtils.d.ts +14 -14
- package/utils/script/ScriptUtils.js +89 -89
- package/utils/storage/StorageUtils.d.ts +9 -9
- package/utils/storage/StorageUtils.js +48 -48
- package/utils/string/StringUtils.d.ts +5 -5
- package/utils/string/StringUtils.js +41 -41
- package/utils/valid/ValidUtils.d.ts +10 -10
- package/utils/valid/ValidUtils.js +78 -78
- package/validators/AllCheckedValidatorArray.d.ts +6 -6
- package/validators/AllCheckedValidatorArray.js +32 -32
- package/validators/AllUnCheckedValidatorArray.d.ts +6 -6
- package/validators/AllUnCheckedValidatorArray.js +32 -32
- package/validators/CheckedValidator.d.ts +5 -5
- package/validators/CheckedValidator.js +32 -32
- package/validators/CountEqualsCheckedValidatorArray.d.ts +7 -7
- package/validators/CountEqualsCheckedValidatorArray.js +34 -34
- package/validators/CountEqualsUnCheckedValidatorArray.d.ts +7 -7
- package/validators/CountEqualsUnCheckedValidatorArray.js +34 -34
- package/validators/CountGreaterThanCheckedValidatorArray.d.ts +7 -7
- package/validators/CountGreaterThanCheckedValidatorArray.js +34 -34
- package/validators/CountGreaterThanEqualsCheckedValidatorArray.d.ts +7 -7
- package/validators/CountGreaterThanEqualsCheckedValidatorArray.js +34 -34
- package/validators/CountGreaterThanEqualsUnCheckedValidatorArray.d.ts +7 -7
- package/validators/CountGreaterThanEqualsUnCheckedValidatorArray.js +34 -34
- package/validators/CountGreaterThanUnCheckedValidatorArray.d.ts +7 -7
- package/validators/CountGreaterThanUnCheckedValidatorArray.js +34 -34
- package/validators/CountLessThanCheckedValidatorArray.d.ts +7 -7
- package/validators/CountLessThanCheckedValidatorArray.js +34 -34
- package/validators/CountLessThanEqualsCheckedValidatorArray.d.ts +7 -7
- package/validators/CountLessThanEqualsCheckedValidatorArray.js +34 -34
- package/validators/CountLessThanEqualsUnCheckedValidatorArray.d.ts +7 -7
- package/validators/CountLessThanEqualsUnCheckedValidatorArray.js +34 -34
- package/validators/CountLessThanUnCheckedValidatorArray.d.ts +7 -7
- package/validators/CountLessThanUnCheckedValidatorArray.js +34 -34
- package/validators/CountUnCheckedValidatorArray.d.ts +7 -7
- package/validators/CountUnCheckedValidatorArray.js +34 -34
- package/validators/EmptyValidator.d.ts +5 -5
- package/validators/EmptyValidator.js +33 -33
- package/validators/ExcludeCheckedValidatorArray.d.ts +8 -8
- package/validators/ExcludeCheckedValidatorArray.js +41 -41
- package/validators/FormValidator.d.ts +7 -7
- package/validators/FormValidator.js +37 -37
- package/validators/IncludeCheckedValidatorArray.d.ts +8 -8
- package/validators/IncludeCheckedValidatorArray.js +41 -41
- package/validators/MultipleValidator.d.ts +8 -8
- package/validators/MultipleValidator.js +48 -48
- package/validators/NonPassValidator.d.ts +5 -5
- package/validators/NonPassValidator.js +31 -31
- package/validators/NotEmptyValidator.d.ts +5 -5
- package/validators/NotEmptyValidator.js +34 -34
- package/validators/NotRegExpTestValidator.d.ts +6 -6
- package/validators/NotRegExpTestValidator.js +42 -42
- package/validators/PassValidator.d.ts +5 -5
- package/validators/PassValidator.js +31 -31
- package/validators/RegExpTestValidator.d.ts +6 -6
- package/validators/RegExpTestValidator.js +43 -43
- package/validators/RequiredValidator.d.ts +5 -5
- package/validators/RequiredValidator.js +33 -33
- package/validators/UnCheckedValidator.d.ts +5 -5
- package/validators/UnCheckedValidator.js +32 -32
- package/validators/ValidMultipleValidator.d.ts +9 -9
- package/validators/ValidMultipleValidator.js +34 -34
- package/validators/ValidValidator.d.ts +6 -6
- package/validators/ValidValidator.js +33 -33
- package/validators/ValidValidatorArray.d.ts +7 -7
- package/validators/ValidValidatorArray.js +33 -33
- package/validators/Validator.d.ts +57 -57
- package/validators/Validator.js +242 -242
- package/validators/ValidatorArray.d.ts +17 -17
- package/validators/ValidatorArray.js +99 -99
- package/validators/ValueEqualsValidator.d.ts +6 -6
- package/validators/ValueEqualsValidator.js +33 -33
- package/validators/ValueNotEqualsValidator.d.ts +6 -6
- package/validators/ValueNotEqualsValidator.js +33 -33
package/validators/Validator.js
CHANGED
@@ -1,242 +1,242 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.Validator = void 0;
|
4
|
-
// export interface Valid<T = any, E = Element> {
|
5
|
-
// valid(value?: T, target?: E, event?: Event): boolean;
|
6
|
-
// }
|
7
|
-
var Validator = /** @class */ (function () {
|
8
|
-
function Validator(_value, target, event, autoValid, autoValidAction) {
|
9
|
-
if (autoValid === void 0) { autoValid = true; }
|
10
|
-
if (autoValidAction === void 0) { autoValidAction = true; }
|
11
|
-
this._value = _value;
|
12
|
-
this.setTarget(target);
|
13
|
-
this.setEvent(event);
|
14
|
-
this.setAutoValid(autoValid);
|
15
|
-
this.setAutoValidAction(autoValidAction);
|
16
|
-
}
|
17
|
-
Validator.prototype.getValidAction = function () {
|
18
|
-
return this._validAction;
|
19
|
-
};
|
20
|
-
Validator.prototype.setValidAction = function (value) {
|
21
|
-
this._validAction = value;
|
22
|
-
return this;
|
23
|
-
};
|
24
|
-
Validator.prototype.getAutoValid = function () {
|
25
|
-
return this._autoValid;
|
26
|
-
};
|
27
|
-
Validator.prototype.setAutoValid = function (autoValid) {
|
28
|
-
this._autoValid = autoValid;
|
29
|
-
return this;
|
30
|
-
};
|
31
|
-
Validator.prototype.getAutoValidAction = function () {
|
32
|
-
return this._autoValidAction;
|
33
|
-
};
|
34
|
-
Validator.prototype.setAutoValidAction = function (autoValid) {
|
35
|
-
this._autoValidAction = autoValid;
|
36
|
-
return this;
|
37
|
-
};
|
38
|
-
Validator.prototype.getEvent = function () {
|
39
|
-
return this._event;
|
40
|
-
};
|
41
|
-
Validator.prototype.setEvent = function (event) {
|
42
|
-
if (event) {
|
43
|
-
this._event = this.domRenderFinal(event);
|
44
|
-
}
|
45
|
-
return this;
|
46
|
-
};
|
47
|
-
Validator.prototype.getTarget = function () {
|
48
|
-
return this._target;
|
49
|
-
};
|
50
|
-
Validator.prototype.targetFocus = function () {
|
51
|
-
var _a, _b;
|
52
|
-
(_b = (_a = this._target) === null || _a === void 0 ? void 0 : _a.focus) === null || _b === void 0 ? void 0 : _b.call(_a);
|
53
|
-
};
|
54
|
-
Validator.prototype.targetReset = function () {
|
55
|
-
var _a, _b;
|
56
|
-
(_b = (_a = this._target) === null || _a === void 0 ? void 0 : _a.reset) === null || _b === void 0 ? void 0 : _b.call(_a);
|
57
|
-
};
|
58
|
-
Validator.prototype.targetDispatchEvent = function (event) {
|
59
|
-
var _a;
|
60
|
-
return (_a = this._target) === null || _a === void 0 ? void 0 : _a.dispatchEvent(event);
|
61
|
-
};
|
62
|
-
Validator.prototype.setTarget = function (target) {
|
63
|
-
if (target) {
|
64
|
-
this._target = this.domRenderFinal(target);
|
65
|
-
}
|
66
|
-
return this;
|
67
|
-
};
|
68
|
-
Validator.prototype.domRenderFinal = function (obj) {
|
69
|
-
obj._DomRender_isFinal = true;
|
70
|
-
return obj;
|
71
|
-
};
|
72
|
-
Object.defineProperty(Validator.prototype, "value", {
|
73
|
-
get: function () {
|
74
|
-
var _a;
|
75
|
-
if (this._value === undefined || this._value === null) {
|
76
|
-
this._value = (_a = this.getTarget()) === null || _a === void 0 ? void 0 : _a.value;
|
77
|
-
}
|
78
|
-
return this._value;
|
79
|
-
},
|
80
|
-
set: function (value) {
|
81
|
-
// console.log('---?set?', value, this)
|
82
|
-
this._value = value;
|
83
|
-
this.tickValue(value);
|
84
|
-
},
|
85
|
-
enumerable: false,
|
86
|
-
configurable: true
|
87
|
-
});
|
88
|
-
Validator.prototype.tickValue = function (value) {
|
89
|
-
this.changeValue(value);
|
90
|
-
var target = this.getTarget();
|
91
|
-
if (target && (target === null || target === void 0 ? void 0 : target.value) !== undefined && (target === null || target === void 0 ? void 0 : target.value) !== null) {
|
92
|
-
try {
|
93
|
-
target.value = this._value;
|
94
|
-
}
|
95
|
-
catch (e) {
|
96
|
-
console.log('set value function is blocked ');
|
97
|
-
}
|
98
|
-
}
|
99
|
-
if (this.getAutoValidAction()) {
|
100
|
-
this.validAction();
|
101
|
-
}
|
102
|
-
else if (this.getAutoValid()) {
|
103
|
-
this.valid();
|
104
|
-
}
|
105
|
-
};
|
106
|
-
Validator.prototype.set = function (value, target, event) {
|
107
|
-
this.setTarget(target);
|
108
|
-
this.setEvent(event);
|
109
|
-
this.value = value;
|
110
|
-
};
|
111
|
-
Validator.prototype.changeValue = function (value) {
|
112
|
-
};
|
113
|
-
Object.defineProperty(Validator.prototype, "checked", {
|
114
|
-
get: function () {
|
115
|
-
var _a, _b;
|
116
|
-
return (_b = (_a = this.getTarget()) === null || _a === void 0 ? void 0 : _a.checked) !== null && _b !== void 0 ? _b : false;
|
117
|
-
},
|
118
|
-
set: function (checked) {
|
119
|
-
var target = this.getTarget();
|
120
|
-
if (target) {
|
121
|
-
target.checked = checked;
|
122
|
-
}
|
123
|
-
},
|
124
|
-
enumerable: false,
|
125
|
-
configurable: true
|
126
|
-
});
|
127
|
-
Object.defineProperty(Validator.prototype, "selectedIndex", {
|
128
|
-
get: function () {
|
129
|
-
var _a, _b;
|
130
|
-
return (_b = (_a = this.getTarget()) === null || _a === void 0 ? void 0 : _a.selectedIndex) !== null && _b !== void 0 ? _b : -1;
|
131
|
-
},
|
132
|
-
set: function (selectedIndex) {
|
133
|
-
var target = this.getTarget();
|
134
|
-
if (target) {
|
135
|
-
target.selectedIndex = selectedIndex;
|
136
|
-
}
|
137
|
-
},
|
138
|
-
enumerable: false,
|
139
|
-
configurable: true
|
140
|
-
});
|
141
|
-
Validator.prototype.querySelector = function (selector) {
|
142
|
-
var _a;
|
143
|
-
return (_a = this.getTarget()) === null || _a === void 0 ? void 0 : _a.querySelector(selector);
|
144
|
-
};
|
145
|
-
Validator.prototype.querySelectorALL = function (selector) {
|
146
|
-
var _a;
|
147
|
-
return (_a = this.getTarget()) === null || _a === void 0 ? void 0 : _a.querySelectorAll(selector);
|
148
|
-
};
|
149
|
-
Validator.prototype.validAction = function () {
|
150
|
-
var _a;
|
151
|
-
var valid = this.valid();
|
152
|
-
(_a = this.getValidAction()) === null || _a === void 0 ? void 0 : _a(valid, this.value, this.getTarget(), this.getEvent());
|
153
|
-
return valid;
|
154
|
-
};
|
155
|
-
Validator.prototype.inValid = function () {
|
156
|
-
return !this.valid();
|
157
|
-
};
|
158
|
-
;
|
159
|
-
Validator.prototype.allValid = function () {
|
160
|
-
return this.valid() && this.childInValid();
|
161
|
-
};
|
162
|
-
Validator.prototype.allValidAction = function () {
|
163
|
-
return this.validAction() && this.childInValidAction();
|
164
|
-
};
|
165
|
-
Validator.prototype.allInValid = function () {
|
166
|
-
return !this.allValid();
|
167
|
-
};
|
168
|
-
Validator.prototype.allInValidAction = function () {
|
169
|
-
return !this.allValidAction();
|
170
|
-
};
|
171
|
-
Validator.prototype.childValid = function () {
|
172
|
-
return !this.childInValid();
|
173
|
-
};
|
174
|
-
Validator.prototype.childValue = function () {
|
175
|
-
var data = {};
|
176
|
-
this.childValidators().filter(function (_a) {
|
177
|
-
var k = _a[0], v = _a[1];
|
178
|
-
data[k] = v.value;
|
179
|
-
});
|
180
|
-
return data;
|
181
|
-
};
|
182
|
-
Validator.prototype.childValidAction = function () {
|
183
|
-
return !this.childInValidAction();
|
184
|
-
};
|
185
|
-
Validator.prototype.childInValid = function () {
|
186
|
-
var inValid = this.childValidators().filter(function (_a) {
|
187
|
-
var k = _a[0], v = _a[1];
|
188
|
-
return !v.valid();
|
189
|
-
});
|
190
|
-
return inValid.length > 0;
|
191
|
-
};
|
192
|
-
Validator.prototype.childInValidValidator = function () {
|
193
|
-
var inValid = this.childValidators().filter(function (_a) {
|
194
|
-
var k = _a[0], v = _a[1];
|
195
|
-
return !v.valid();
|
196
|
-
});
|
197
|
-
return inValid;
|
198
|
-
};
|
199
|
-
Validator.prototype.childInValidAction = function () {
|
200
|
-
var inValid = this.childValidators().filter(function (_a) {
|
201
|
-
var k = _a[0], v = _a[1];
|
202
|
-
return !v.validAction();
|
203
|
-
});
|
204
|
-
return inValid.length > 0;
|
205
|
-
};
|
206
|
-
Validator.prototype.childValidator = function (name) {
|
207
|
-
var _a;
|
208
|
-
return (_a = Object.entries(this).find(function (_a) {
|
209
|
-
var k = _a[0], v = _a[1];
|
210
|
-
return (k === name && (v instanceof Validator));
|
211
|
-
})) === null || _a === void 0 ? void 0 : _a[1];
|
212
|
-
};
|
213
|
-
Validator.prototype.childValidators = function () {
|
214
|
-
return Object.entries(this).filter(function (_a) {
|
215
|
-
var k = _a[0], v = _a[1];
|
216
|
-
return (v instanceof Validator);
|
217
|
-
});
|
218
|
-
};
|
219
|
-
Validator.prototype.childValidValidator = function () {
|
220
|
-
return this.childValidators().filter(function (it) { return it[1].valid(); });
|
221
|
-
};
|
222
|
-
Validator.prototype.syncValue = function () {
|
223
|
-
var _a;
|
224
|
-
this.value = (_a = this.getTarget()) === null || _a === void 0 ? void 0 : _a.value;
|
225
|
-
};
|
226
|
-
Validator.prototype.allSyncValue = function () {
|
227
|
-
this.childValidators().forEach(function (_a) {
|
228
|
-
var k = _a[0], e = _a[1];
|
229
|
-
e.syncValue();
|
230
|
-
});
|
231
|
-
};
|
232
|
-
Object.defineProperty(Validator.prototype, "length", {
|
233
|
-
get: function () {
|
234
|
-
var _a, _b;
|
235
|
-
return (_b = (_a = this.value) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
236
|
-
},
|
237
|
-
enumerable: false,
|
238
|
-
configurable: true
|
239
|
-
});
|
240
|
-
return Validator;
|
241
|
-
}());
|
242
|
-
exports.Validator = Validator;
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.Validator = void 0;
|
4
|
+
// export interface Valid<T = any, E = Element> {
|
5
|
+
// valid(value?: T, target?: E, event?: Event): boolean;
|
6
|
+
// }
|
7
|
+
var Validator = /** @class */ (function () {
|
8
|
+
function Validator(_value, target, event, autoValid, autoValidAction) {
|
9
|
+
if (autoValid === void 0) { autoValid = true; }
|
10
|
+
if (autoValidAction === void 0) { autoValidAction = true; }
|
11
|
+
this._value = _value;
|
12
|
+
this.setTarget(target);
|
13
|
+
this.setEvent(event);
|
14
|
+
this.setAutoValid(autoValid);
|
15
|
+
this.setAutoValidAction(autoValidAction);
|
16
|
+
}
|
17
|
+
Validator.prototype.getValidAction = function () {
|
18
|
+
return this._validAction;
|
19
|
+
};
|
20
|
+
Validator.prototype.setValidAction = function (value) {
|
21
|
+
this._validAction = value;
|
22
|
+
return this;
|
23
|
+
};
|
24
|
+
Validator.prototype.getAutoValid = function () {
|
25
|
+
return this._autoValid;
|
26
|
+
};
|
27
|
+
Validator.prototype.setAutoValid = function (autoValid) {
|
28
|
+
this._autoValid = autoValid;
|
29
|
+
return this;
|
30
|
+
};
|
31
|
+
Validator.prototype.getAutoValidAction = function () {
|
32
|
+
return this._autoValidAction;
|
33
|
+
};
|
34
|
+
Validator.prototype.setAutoValidAction = function (autoValid) {
|
35
|
+
this._autoValidAction = autoValid;
|
36
|
+
return this;
|
37
|
+
};
|
38
|
+
Validator.prototype.getEvent = function () {
|
39
|
+
return this._event;
|
40
|
+
};
|
41
|
+
Validator.prototype.setEvent = function (event) {
|
42
|
+
if (event) {
|
43
|
+
this._event = this.domRenderFinal(event);
|
44
|
+
}
|
45
|
+
return this;
|
46
|
+
};
|
47
|
+
Validator.prototype.getTarget = function () {
|
48
|
+
return this._target;
|
49
|
+
};
|
50
|
+
Validator.prototype.targetFocus = function () {
|
51
|
+
var _a, _b;
|
52
|
+
(_b = (_a = this._target) === null || _a === void 0 ? void 0 : _a.focus) === null || _b === void 0 ? void 0 : _b.call(_a);
|
53
|
+
};
|
54
|
+
Validator.prototype.targetReset = function () {
|
55
|
+
var _a, _b;
|
56
|
+
(_b = (_a = this._target) === null || _a === void 0 ? void 0 : _a.reset) === null || _b === void 0 ? void 0 : _b.call(_a);
|
57
|
+
};
|
58
|
+
Validator.prototype.targetDispatchEvent = function (event) {
|
59
|
+
var _a;
|
60
|
+
return (_a = this._target) === null || _a === void 0 ? void 0 : _a.dispatchEvent(event);
|
61
|
+
};
|
62
|
+
Validator.prototype.setTarget = function (target) {
|
63
|
+
if (target) {
|
64
|
+
this._target = this.domRenderFinal(target);
|
65
|
+
}
|
66
|
+
return this;
|
67
|
+
};
|
68
|
+
Validator.prototype.domRenderFinal = function (obj) {
|
69
|
+
obj._DomRender_isFinal = true;
|
70
|
+
return obj;
|
71
|
+
};
|
72
|
+
Object.defineProperty(Validator.prototype, "value", {
|
73
|
+
get: function () {
|
74
|
+
var _a;
|
75
|
+
if (this._value === undefined || this._value === null) {
|
76
|
+
this._value = (_a = this.getTarget()) === null || _a === void 0 ? void 0 : _a.value;
|
77
|
+
}
|
78
|
+
return this._value;
|
79
|
+
},
|
80
|
+
set: function (value) {
|
81
|
+
// console.log('---?set?', value, this)
|
82
|
+
this._value = value;
|
83
|
+
this.tickValue(value);
|
84
|
+
},
|
85
|
+
enumerable: false,
|
86
|
+
configurable: true
|
87
|
+
});
|
88
|
+
Validator.prototype.tickValue = function (value) {
|
89
|
+
this.changeValue(value);
|
90
|
+
var target = this.getTarget();
|
91
|
+
if (target && (target === null || target === void 0 ? void 0 : target.value) !== undefined && (target === null || target === void 0 ? void 0 : target.value) !== null) {
|
92
|
+
try {
|
93
|
+
target.value = this._value;
|
94
|
+
}
|
95
|
+
catch (e) {
|
96
|
+
console.log('set value function is blocked ');
|
97
|
+
}
|
98
|
+
}
|
99
|
+
if (this.getAutoValidAction()) {
|
100
|
+
this.validAction();
|
101
|
+
}
|
102
|
+
else if (this.getAutoValid()) {
|
103
|
+
this.valid();
|
104
|
+
}
|
105
|
+
};
|
106
|
+
Validator.prototype.set = function (value, target, event) {
|
107
|
+
this.setTarget(target);
|
108
|
+
this.setEvent(event);
|
109
|
+
this.value = value;
|
110
|
+
};
|
111
|
+
Validator.prototype.changeValue = function (value) {
|
112
|
+
};
|
113
|
+
Object.defineProperty(Validator.prototype, "checked", {
|
114
|
+
get: function () {
|
115
|
+
var _a, _b;
|
116
|
+
return (_b = (_a = this.getTarget()) === null || _a === void 0 ? void 0 : _a.checked) !== null && _b !== void 0 ? _b : false;
|
117
|
+
},
|
118
|
+
set: function (checked) {
|
119
|
+
var target = this.getTarget();
|
120
|
+
if (target) {
|
121
|
+
target.checked = checked;
|
122
|
+
}
|
123
|
+
},
|
124
|
+
enumerable: false,
|
125
|
+
configurable: true
|
126
|
+
});
|
127
|
+
Object.defineProperty(Validator.prototype, "selectedIndex", {
|
128
|
+
get: function () {
|
129
|
+
var _a, _b;
|
130
|
+
return (_b = (_a = this.getTarget()) === null || _a === void 0 ? void 0 : _a.selectedIndex) !== null && _b !== void 0 ? _b : -1;
|
131
|
+
},
|
132
|
+
set: function (selectedIndex) {
|
133
|
+
var target = this.getTarget();
|
134
|
+
if (target) {
|
135
|
+
target.selectedIndex = selectedIndex;
|
136
|
+
}
|
137
|
+
},
|
138
|
+
enumerable: false,
|
139
|
+
configurable: true
|
140
|
+
});
|
141
|
+
Validator.prototype.querySelector = function (selector) {
|
142
|
+
var _a;
|
143
|
+
return (_a = this.getTarget()) === null || _a === void 0 ? void 0 : _a.querySelector(selector);
|
144
|
+
};
|
145
|
+
Validator.prototype.querySelectorALL = function (selector) {
|
146
|
+
var _a;
|
147
|
+
return (_a = this.getTarget()) === null || _a === void 0 ? void 0 : _a.querySelectorAll(selector);
|
148
|
+
};
|
149
|
+
Validator.prototype.validAction = function () {
|
150
|
+
var _a;
|
151
|
+
var valid = this.valid();
|
152
|
+
(_a = this.getValidAction()) === null || _a === void 0 ? void 0 : _a(valid, this.value, this.getTarget(), this.getEvent());
|
153
|
+
return valid;
|
154
|
+
};
|
155
|
+
Validator.prototype.inValid = function () {
|
156
|
+
return !this.valid();
|
157
|
+
};
|
158
|
+
;
|
159
|
+
Validator.prototype.allValid = function () {
|
160
|
+
return this.valid() && this.childInValid();
|
161
|
+
};
|
162
|
+
Validator.prototype.allValidAction = function () {
|
163
|
+
return this.validAction() && this.childInValidAction();
|
164
|
+
};
|
165
|
+
Validator.prototype.allInValid = function () {
|
166
|
+
return !this.allValid();
|
167
|
+
};
|
168
|
+
Validator.prototype.allInValidAction = function () {
|
169
|
+
return !this.allValidAction();
|
170
|
+
};
|
171
|
+
Validator.prototype.childValid = function () {
|
172
|
+
return !this.childInValid();
|
173
|
+
};
|
174
|
+
Validator.prototype.childValue = function () {
|
175
|
+
var data = {};
|
176
|
+
this.childValidators().filter(function (_a) {
|
177
|
+
var k = _a[0], v = _a[1];
|
178
|
+
data[k] = v.value;
|
179
|
+
});
|
180
|
+
return data;
|
181
|
+
};
|
182
|
+
Validator.prototype.childValidAction = function () {
|
183
|
+
return !this.childInValidAction();
|
184
|
+
};
|
185
|
+
Validator.prototype.childInValid = function () {
|
186
|
+
var inValid = this.childValidators().filter(function (_a) {
|
187
|
+
var k = _a[0], v = _a[1];
|
188
|
+
return !v.valid();
|
189
|
+
});
|
190
|
+
return inValid.length > 0;
|
191
|
+
};
|
192
|
+
Validator.prototype.childInValidValidator = function () {
|
193
|
+
var inValid = this.childValidators().filter(function (_a) {
|
194
|
+
var k = _a[0], v = _a[1];
|
195
|
+
return !v.valid();
|
196
|
+
});
|
197
|
+
return inValid;
|
198
|
+
};
|
199
|
+
Validator.prototype.childInValidAction = function () {
|
200
|
+
var inValid = this.childValidators().filter(function (_a) {
|
201
|
+
var k = _a[0], v = _a[1];
|
202
|
+
return !v.validAction();
|
203
|
+
});
|
204
|
+
return inValid.length > 0;
|
205
|
+
};
|
206
|
+
Validator.prototype.childValidator = function (name) {
|
207
|
+
var _a;
|
208
|
+
return (_a = Object.entries(this).find(function (_a) {
|
209
|
+
var k = _a[0], v = _a[1];
|
210
|
+
return (k === name && (v instanceof Validator));
|
211
|
+
})) === null || _a === void 0 ? void 0 : _a[1];
|
212
|
+
};
|
213
|
+
Validator.prototype.childValidators = function () {
|
214
|
+
return Object.entries(this).filter(function (_a) {
|
215
|
+
var k = _a[0], v = _a[1];
|
216
|
+
return (v instanceof Validator);
|
217
|
+
});
|
218
|
+
};
|
219
|
+
Validator.prototype.childValidValidator = function () {
|
220
|
+
return this.childValidators().filter(function (it) { return it[1].valid(); });
|
221
|
+
};
|
222
|
+
Validator.prototype.syncValue = function () {
|
223
|
+
var _a;
|
224
|
+
this.value = (_a = this.getTarget()) === null || _a === void 0 ? void 0 : _a.value;
|
225
|
+
};
|
226
|
+
Validator.prototype.allSyncValue = function () {
|
227
|
+
this.childValidators().forEach(function (_a) {
|
228
|
+
var k = _a[0], e = _a[1];
|
229
|
+
e.syncValue();
|
230
|
+
});
|
231
|
+
};
|
232
|
+
Object.defineProperty(Validator.prototype, "length", {
|
233
|
+
get: function () {
|
234
|
+
var _a, _b;
|
235
|
+
return (_b = (_a = this.value) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
236
|
+
},
|
237
|
+
enumerable: false,
|
238
|
+
configurable: true
|
239
|
+
});
|
240
|
+
return Validator;
|
241
|
+
}());
|
242
|
+
exports.Validator = Validator;
|
@@ -1,17 +1,17 @@
|
|
1
|
-
import { Validator } from './Validator';
|
2
|
-
export declare type MakeValidator<T = any, E = Element> = (value: T, target: E, event?: Event) => Validator<T, E>;
|
3
|
-
export declare abstract class ValidatorArray<T = any, E = Element> extends Validator<Validator<T, E>[], E> {
|
4
|
-
private _makeValidatorFactory;
|
5
|
-
constructor(value?: Validator<T, E>[], target?: E, event?: Event, autoValid?: boolean);
|
6
|
-
getMakeValidatorFactory(): MakeValidator<T, E>;
|
7
|
-
setMakeValidatorFactory(value: MakeValidator<T, E>): this;
|
8
|
-
setArrayValue(target: E, value: T, event?: Event): void;
|
9
|
-
addValidator(value: T, target: E, event?: Event): void;
|
10
|
-
allChecked(checked: boolean): void;
|
11
|
-
getValidators(): Validator<T, E>[] | undefined;
|
12
|
-
getValidator(e: E): Validator<T, E> | undefined;
|
13
|
-
getValidatorByValue(value: T): Validator<T, E>;
|
14
|
-
getValidatorByValues(value: T): Validator<T, E>[];
|
15
|
-
removeElement(e: E): void;
|
16
|
-
makeValidator(value: T, target: E, event?: Event): Validator<T, E>;
|
17
|
-
}
|
1
|
+
import { Validator } from './Validator';
|
2
|
+
export declare type MakeValidator<T = any, E = Element> = (value: T, target: E, event?: Event) => Validator<T, E>;
|
3
|
+
export declare abstract class ValidatorArray<T = any, E = Element> extends Validator<Validator<T, E>[], E> {
|
4
|
+
private _makeValidatorFactory;
|
5
|
+
constructor(value?: Validator<T, E>[], target?: E, event?: Event, autoValid?: boolean);
|
6
|
+
getMakeValidatorFactory(): MakeValidator<T, E>;
|
7
|
+
setMakeValidatorFactory(value: MakeValidator<T, E>): this;
|
8
|
+
setArrayValue(target: E, value: T, event?: Event): void;
|
9
|
+
addValidator(value: T, target: E, event?: Event): void;
|
10
|
+
allChecked(checked: boolean): void;
|
11
|
+
getValidators(): Validator<T, E>[] | undefined;
|
12
|
+
getValidator(e: E): Validator<T, E> | undefined;
|
13
|
+
getValidatorByValue(value: T): Validator<T, E>;
|
14
|
+
getValidatorByValues(value: T): Validator<T, E>[];
|
15
|
+
removeElement(e: E): void;
|
16
|
+
makeValidator(value: T, target: E, event?: Event): Validator<T, E>;
|
17
|
+
}
|