dom-render 1.0.54 → 1.0.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DomRenderProxy.d.ts +1 -0
- package/DomRenderProxy.js +6 -6
- package/README.MD +84 -159
- package/RawSet.js +15 -12
- package/dist/DomRenderProxy.d.ts +1 -0
- package/dist/bundle.js +190 -63
- package/dist/bundle.js.map +1 -1
- package/dist/iterators/Range.d.ts +1 -0
- package/dist/validators/AllCheckedValidatorArray.d.ts +6 -0
- package/dist/validators/AllUnCheckedValidatorArray.d.ts +6 -0
- package/dist/validators/CheckedValidator.d.ts +5 -0
- package/dist/validators/CountEqualsCheckedValidatorArray.d.ts +7 -0
- package/dist/validators/CountEqualsUnCheckedValidatorArray.d.ts +7 -0
- package/dist/validators/CountGreaterThanCheckedValidatorArray.d.ts +7 -0
- package/dist/validators/CountGreaterThanEqualsCheckedValidatorArray.d.ts +7 -0
- package/dist/validators/CountGreaterThanEqualsUnCheckedValidatorArray.d.ts +7 -0
- package/dist/validators/CountGreaterThanUnCheckedValidatorArray.d.ts +7 -0
- package/dist/validators/CountLessThanCheckedValidatorArray.d.ts +7 -0
- package/dist/validators/CountLessThanEqualsCheckedValidatorArray.d.ts +7 -0
- package/dist/validators/CountLessThanEqualsUnCheckedValidatorArray.d.ts +7 -0
- package/dist/validators/CountLessThanUnCheckedValidatorArray.d.ts +7 -0
- package/dist/validators/CountUnCheckedValidatorArray.d.ts +7 -0
- package/dist/validators/EmptyValidator.d.ts +5 -0
- package/dist/validators/ExcludeCheckedValidatorArray.d.ts +8 -0
- package/dist/validators/FormValidator.d.ts +5 -0
- package/dist/validators/IncludeCheckedValidatorArray.d.ts +8 -0
- package/dist/validators/MultipleValidator.d.ts +7 -0
- package/dist/validators/NonPassValidator.d.ts +5 -0
- package/dist/validators/NotEmptyValidator.d.ts +5 -0
- package/dist/validators/NotRegExpTestValidator.d.ts +6 -0
- package/dist/validators/PassValidator.d.ts +5 -0
- package/dist/validators/RegExpTestValidator.d.ts +6 -0
- package/dist/validators/RequiredValidator.d.ts +5 -0
- package/dist/validators/UnCheckedValidator.d.ts +5 -0
- package/dist/validators/ValidMultipleValidator.d.ts +9 -0
- package/dist/validators/ValidValidator.d.ts +6 -0
- package/dist/validators/ValidValidatorArray.d.ts +7 -0
- package/dist/validators/Validator.d.ts +31 -0
- package/dist/validators/ValidatorArray.d.ts +17 -0
- package/dist/validators/ValueEqualsValidator.d.ts +6 -0
- package/dist/validators/ValueNotEqualsValidator.d.ts +6 -0
- package/events/EventManager.js +0 -2
- package/iterators/Range.d.ts +1 -0
- package/iterators/Range.js +12 -0
- package/package.json +1 -1
- package/validators/AllCheckedValidatorArray.d.ts +6 -0
- package/validators/AllCheckedValidatorArray.js +29 -0
- package/validators/AllUnCheckedValidatorArray.d.ts +6 -0
- package/validators/AllUnCheckedValidatorArray.js +29 -0
- package/validators/CheckedValidator.d.ts +5 -0
- package/validators/CheckedValidator.js +29 -0
- package/validators/CountEqualsCheckedValidatorArray.d.ts +7 -0
- package/validators/CountEqualsCheckedValidatorArray.js +31 -0
- package/validators/CountEqualsUnCheckedValidatorArray.d.ts +7 -0
- package/validators/CountEqualsUnCheckedValidatorArray.js +31 -0
- package/validators/CountGreaterThanCheckedValidatorArray.d.ts +7 -0
- package/validators/CountGreaterThanCheckedValidatorArray.js +31 -0
- package/validators/CountGreaterThanEqualsCheckedValidatorArray.d.ts +7 -0
- package/validators/CountGreaterThanEqualsCheckedValidatorArray.js +31 -0
- package/validators/CountGreaterThanEqualsUnCheckedValidatorArray.d.ts +7 -0
- package/validators/CountGreaterThanEqualsUnCheckedValidatorArray.js +31 -0
- package/validators/CountGreaterThanUnCheckedValidatorArray.d.ts +7 -0
- package/validators/CountGreaterThanUnCheckedValidatorArray.js +31 -0
- package/validators/CountLessThanCheckedValidatorArray.d.ts +7 -0
- package/validators/CountLessThanCheckedValidatorArray.js +31 -0
- package/validators/CountLessThanEqualsCheckedValidatorArray.d.ts +7 -0
- package/validators/CountLessThanEqualsCheckedValidatorArray.js +31 -0
- package/validators/CountLessThanEqualsUnCheckedValidatorArray.d.ts +7 -0
- package/validators/CountLessThanEqualsUnCheckedValidatorArray.js +31 -0
- package/validators/CountLessThanUnCheckedValidatorArray.d.ts +7 -0
- package/validators/CountLessThanUnCheckedValidatorArray.js +31 -0
- package/validators/CountUnCheckedValidatorArray.d.ts +7 -0
- package/validators/CountUnCheckedValidatorArray.js +31 -0
- package/validators/EmptyValidator.d.ts +5 -0
- package/validators/EmptyValidator.js +30 -0
- package/validators/ExcludeCheckedValidatorArray.d.ts +8 -0
- package/validators/ExcludeCheckedValidatorArray.js +38 -0
- package/validators/FormValidator.d.ts +5 -0
- package/validators/FormValidator.js +28 -0
- package/validators/IncludeCheckedValidatorArray.d.ts +8 -0
- package/validators/IncludeCheckedValidatorArray.js +38 -0
- package/validators/MultipleValidator.d.ts +7 -0
- package/validators/MultipleValidator.js +35 -0
- package/validators/NonPassValidator.d.ts +5 -0
- package/validators/NonPassValidator.js +28 -0
- package/validators/NotEmptyValidator.d.ts +5 -0
- package/validators/NotEmptyValidator.js +30 -0
- package/validators/NotRegExpTestValidator.d.ts +6 -0
- package/validators/NotRegExpTestValidator.js +39 -0
- package/validators/PassValidator.d.ts +5 -0
- package/validators/PassValidator.js +28 -0
- package/validators/RegExpTestValidator.d.ts +6 -0
- package/validators/RegExpTestValidator.js +39 -0
- package/validators/RequiredValidator.d.ts +5 -0
- package/{validations/validators → validators}/RequiredValidator.js +7 -5
- package/validators/UnCheckedValidator.d.ts +5 -0
- package/validators/UnCheckedValidator.js +29 -0
- package/validators/ValidMultipleValidator.d.ts +9 -0
- package/validators/ValidMultipleValidator.js +31 -0
- package/validators/ValidValidator.d.ts +6 -0
- package/validators/ValidValidator.js +30 -0
- package/validators/ValidValidatorArray.d.ts +7 -0
- package/validators/ValidValidatorArray.js +30 -0
- package/validators/Validator.d.ts +31 -0
- package/validators/Validator.js +146 -0
- package/validators/ValidatorArray.d.ts +17 -0
- package/validators/ValidatorArray.js +94 -0
- package/validators/ValueEqualsValidator.d.ts +6 -0
- package/validators/ValueEqualsValidator.js +30 -0
- package/validators/ValueNotEqualsValidator.d.ts +6 -0
- package/validators/ValueNotEqualsValidator.js +30 -0
- package/dist/validations/Validation.d.ts +0 -13
- package/dist/validations/Validations.d.ts +0 -9
- package/dist/validations/validators/RequiredValidator.d.ts +0 -5
- package/validations/Validation.d.ts +0 -13
- package/validations/Validation.js +0 -53
- package/validations/Validations.d.ts +0 -9
- package/validations/Validations.js +0 -63
- package/validations/validators/RequiredValidator.d.ts +0 -5
@@ -0,0 +1,31 @@
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
2
|
+
var extendStatics = function (d, b) {
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
6
|
+
return extendStatics(d, b);
|
7
|
+
};
|
8
|
+
return function (d, b) {
|
9
|
+
if (typeof b !== "function" && b !== null)
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
11
|
+
extendStatics(d, b);
|
12
|
+
function __() { this.constructor = d; }
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
14
|
+
};
|
15
|
+
})();
|
16
|
+
import { MultipleValidator } from './MultipleValidator';
|
17
|
+
var ValidMultipleValidator = (function (_super) {
|
18
|
+
__extends(ValidMultipleValidator, _super);
|
19
|
+
function ValidMultipleValidator(validMultipleCallback, validators, value, target, event, autoValid) {
|
20
|
+
if (autoValid === void 0) { autoValid = true; }
|
21
|
+
var _this = _super.call(this, validators, value, target, event, autoValid) || this;
|
22
|
+
_this.validMultipleCallback = validMultipleCallback;
|
23
|
+
_this.validators = validators;
|
24
|
+
return _this;
|
25
|
+
}
|
26
|
+
ValidMultipleValidator.prototype.valid = function () {
|
27
|
+
return this.validMultipleCallback(this.validators, this.value, this.getTarget(), this.getEvent());
|
28
|
+
};
|
29
|
+
return ValidMultipleValidator;
|
30
|
+
}(MultipleValidator));
|
31
|
+
export { ValidMultipleValidator };
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import { Valid, Validator } from './Validator';
|
2
|
+
export declare class ValidValidator<T = any, E = Element> extends Validator<T, E> {
|
3
|
+
validCallBack: Valid<T, E>;
|
4
|
+
constructor(validCallBack: Valid<T, E>, value?: T, target?: E, event?: Event, autoValid?: boolean);
|
5
|
+
valid(value?: T, target?: E, event?: Event): boolean;
|
6
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
2
|
+
var extendStatics = function (d, b) {
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
6
|
+
return extendStatics(d, b);
|
7
|
+
};
|
8
|
+
return function (d, b) {
|
9
|
+
if (typeof b !== "function" && b !== null)
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
11
|
+
extendStatics(d, b);
|
12
|
+
function __() { this.constructor = d; }
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
14
|
+
};
|
15
|
+
})();
|
16
|
+
import { Validator } from './Validator';
|
17
|
+
var ValidValidator = (function (_super) {
|
18
|
+
__extends(ValidValidator, _super);
|
19
|
+
function ValidValidator(validCallBack, value, target, event, autoValid) {
|
20
|
+
if (autoValid === void 0) { autoValid = true; }
|
21
|
+
var _this = _super.call(this, value, target, event, autoValid) || this;
|
22
|
+
_this.validCallBack = validCallBack;
|
23
|
+
return _this;
|
24
|
+
}
|
25
|
+
ValidValidator.prototype.valid = function (value, target, event) {
|
26
|
+
return this.validCallBack(value, target, event);
|
27
|
+
};
|
28
|
+
return ValidValidator;
|
29
|
+
}(Validator));
|
30
|
+
export { ValidValidator };
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { Valid, Validator } from './Validator';
|
2
|
+
import { ValidatorArray } from './ValidatorArray';
|
3
|
+
export declare class ValidValidatorArray<T = any, E = Element> extends ValidatorArray<T, E> {
|
4
|
+
validCallBack: Valid<Validator<T, E>[], E>;
|
5
|
+
constructor(validCallBack: Valid<Validator<T, E>[], E>, value?: Validator<T, E>[], target?: E, event?: Event, autoValid?: boolean);
|
6
|
+
valid(): boolean;
|
7
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
2
|
+
var extendStatics = function (d, b) {
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
6
|
+
return extendStatics(d, b);
|
7
|
+
};
|
8
|
+
return function (d, b) {
|
9
|
+
if (typeof b !== "function" && b !== null)
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
11
|
+
extendStatics(d, b);
|
12
|
+
function __() { this.constructor = d; }
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
14
|
+
};
|
15
|
+
})();
|
16
|
+
import { ValidatorArray } from './ValidatorArray';
|
17
|
+
var ValidValidatorArray = (function (_super) {
|
18
|
+
__extends(ValidValidatorArray, _super);
|
19
|
+
function ValidValidatorArray(validCallBack, value, target, event, autoValid) {
|
20
|
+
if (autoValid === void 0) { autoValid = true; }
|
21
|
+
var _this = _super.call(this, value, target, event, autoValid) || this;
|
22
|
+
_this.validCallBack = validCallBack;
|
23
|
+
return _this;
|
24
|
+
}
|
25
|
+
ValidValidatorArray.prototype.valid = function () {
|
26
|
+
return this.validCallBack(this.value, this.getTarget(), this.getEvent());
|
27
|
+
};
|
28
|
+
return ValidValidatorArray;
|
29
|
+
}(ValidatorArray));
|
30
|
+
export { ValidValidatorArray };
|
@@ -0,0 +1,31 @@
|
|
1
|
+
export declare type Valid<T = any, E = Element> = (value?: T, target?: E, event?: Event) => boolean;
|
2
|
+
export declare abstract class Validator<T = any, E = Element> {
|
3
|
+
protected _value?: T | undefined;
|
4
|
+
private _target?;
|
5
|
+
private _event?;
|
6
|
+
private _autoValid;
|
7
|
+
constructor(_value?: T | undefined, target?: E, event?: Event, autoValid?: boolean);
|
8
|
+
getAutoValid(): boolean;
|
9
|
+
setAutoValid(autoValid: boolean): this;
|
10
|
+
getEvent(): Event | undefined;
|
11
|
+
setEvent(event: Event | undefined): this;
|
12
|
+
getTarget(): E | undefined;
|
13
|
+
setTarget(target: E | undefined): this;
|
14
|
+
get value(): T | undefined;
|
15
|
+
set value(value: T | undefined);
|
16
|
+
set(value?: T, target?: E, event?: Event): void;
|
17
|
+
changeValue(value: T | undefined): void;
|
18
|
+
get checked(): boolean;
|
19
|
+
set checked(checked: boolean);
|
20
|
+
get selectedIndex(): number;
|
21
|
+
set selectedIndex(selectedIndex: number);
|
22
|
+
querySelector(selector: string): Element | null;
|
23
|
+
querySelectorALL(selector: string): NodeListOf<Element>;
|
24
|
+
abstract valid(): boolean;
|
25
|
+
inValid(): boolean;
|
26
|
+
allValid(): boolean;
|
27
|
+
allInValid(): boolean;
|
28
|
+
childValids(): boolean;
|
29
|
+
childInValids(): boolean;
|
30
|
+
get length(): any;
|
31
|
+
}
|
@@ -0,0 +1,146 @@
|
|
1
|
+
var __read = (this && this.__read) || function (o, n) {
|
2
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
3
|
+
if (!m) return o;
|
4
|
+
var i = m.call(o), r, ar = [], e;
|
5
|
+
try {
|
6
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
7
|
+
}
|
8
|
+
catch (error) { e = { error: error }; }
|
9
|
+
finally {
|
10
|
+
try {
|
11
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
12
|
+
}
|
13
|
+
finally { if (e) throw e.error; }
|
14
|
+
}
|
15
|
+
return ar;
|
16
|
+
};
|
17
|
+
import { DomRenderProxy } from '../DomRenderProxy';
|
18
|
+
var Validator = (function () {
|
19
|
+
function Validator(_value, target, event, autoValid) {
|
20
|
+
if (autoValid === void 0) { autoValid = true; }
|
21
|
+
this._value = _value;
|
22
|
+
this.setTarget(target);
|
23
|
+
this.setEvent(event);
|
24
|
+
this.setAutoValid(autoValid);
|
25
|
+
}
|
26
|
+
Validator.prototype.getAutoValid = function () {
|
27
|
+
return this._autoValid;
|
28
|
+
};
|
29
|
+
Validator.prototype.setAutoValid = function (autoValid) {
|
30
|
+
this._autoValid = autoValid;
|
31
|
+
return this;
|
32
|
+
};
|
33
|
+
Validator.prototype.getEvent = function () {
|
34
|
+
return this._event;
|
35
|
+
};
|
36
|
+
Validator.prototype.setEvent = function (event) {
|
37
|
+
if (event) {
|
38
|
+
this._event = DomRenderProxy.final(event);
|
39
|
+
}
|
40
|
+
return this;
|
41
|
+
};
|
42
|
+
Validator.prototype.getTarget = function () {
|
43
|
+
return this._target;
|
44
|
+
};
|
45
|
+
Validator.prototype.setTarget = function (target) {
|
46
|
+
if (target) {
|
47
|
+
this._target = DomRenderProxy.final(target);
|
48
|
+
}
|
49
|
+
return this;
|
50
|
+
};
|
51
|
+
Object.defineProperty(Validator.prototype, "value", {
|
52
|
+
get: function () {
|
53
|
+
var _a;
|
54
|
+
if (this._value === undefined || this._value === null) {
|
55
|
+
this._value = (_a = this.getTarget()) === null || _a === void 0 ? void 0 : _a.value;
|
56
|
+
}
|
57
|
+
return this._value;
|
58
|
+
},
|
59
|
+
set: function (value) {
|
60
|
+
this._value = value;
|
61
|
+
this.changeValue(value);
|
62
|
+
var target = this.getTarget();
|
63
|
+
if (target && (target === null || target === void 0 ? void 0 : target.value) !== undefined && (target === null || target === void 0 ? void 0 : target.value) !== null) {
|
64
|
+
target.value = this._value;
|
65
|
+
}
|
66
|
+
if (this.getAutoValid()) {
|
67
|
+
this.valid();
|
68
|
+
}
|
69
|
+
},
|
70
|
+
enumerable: false,
|
71
|
+
configurable: true
|
72
|
+
});
|
73
|
+
Validator.prototype.set = function (value, target, event) {
|
74
|
+
this.value = value;
|
75
|
+
this.setTarget(target);
|
76
|
+
this.setEvent(event);
|
77
|
+
};
|
78
|
+
Validator.prototype.changeValue = function (value) {
|
79
|
+
};
|
80
|
+
Object.defineProperty(Validator.prototype, "checked", {
|
81
|
+
get: function () {
|
82
|
+
var _a, _b;
|
83
|
+
return (_b = (_a = this.getTarget()) === null || _a === void 0 ? void 0 : _a.checked) !== null && _b !== void 0 ? _b : false;
|
84
|
+
},
|
85
|
+
set: function (checked) {
|
86
|
+
var target = this.getTarget();
|
87
|
+
if (target) {
|
88
|
+
target.checked = checked;
|
89
|
+
}
|
90
|
+
},
|
91
|
+
enumerable: false,
|
92
|
+
configurable: true
|
93
|
+
});
|
94
|
+
Object.defineProperty(Validator.prototype, "selectedIndex", {
|
95
|
+
get: function () {
|
96
|
+
var _a, _b;
|
97
|
+
return (_b = (_a = this.getTarget()) === null || _a === void 0 ? void 0 : _a.selectedIndex) !== null && _b !== void 0 ? _b : -1;
|
98
|
+
},
|
99
|
+
set: function (selectedIndex) {
|
100
|
+
var target = this.getTarget();
|
101
|
+
if (target) {
|
102
|
+
target.selectedIndex = selectedIndex;
|
103
|
+
}
|
104
|
+
},
|
105
|
+
enumerable: false,
|
106
|
+
configurable: true
|
107
|
+
});
|
108
|
+
Validator.prototype.querySelector = function (selector) {
|
109
|
+
var _a;
|
110
|
+
return (_a = this.getTarget()) === null || _a === void 0 ? void 0 : _a.querySelector(selector);
|
111
|
+
};
|
112
|
+
Validator.prototype.querySelectorALL = function (selector) {
|
113
|
+
var _a;
|
114
|
+
return (_a = this.getTarget()) === null || _a === void 0 ? void 0 : _a.querySelectorAll(selector);
|
115
|
+
};
|
116
|
+
Validator.prototype.inValid = function () {
|
117
|
+
return !this.valid();
|
118
|
+
};
|
119
|
+
;
|
120
|
+
Validator.prototype.allValid = function () {
|
121
|
+
return this.valid() && this.childInValids();
|
122
|
+
};
|
123
|
+
Validator.prototype.allInValid = function () {
|
124
|
+
return !this.allValid();
|
125
|
+
};
|
126
|
+
Validator.prototype.childValids = function () {
|
127
|
+
return !this.childInValids();
|
128
|
+
};
|
129
|
+
Validator.prototype.childInValids = function () {
|
130
|
+
var inValid = Object.entries(this).filter(function (_a) {
|
131
|
+
var _b = __read(_a, 2), k = _b[0], v = _b[1];
|
132
|
+
return (v instanceof Validator) && !v.valid();
|
133
|
+
});
|
134
|
+
return inValid.length > 0;
|
135
|
+
};
|
136
|
+
Object.defineProperty(Validator.prototype, "length", {
|
137
|
+
get: function () {
|
138
|
+
var _a, _b;
|
139
|
+
return (_b = (_a = this.value) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
140
|
+
},
|
141
|
+
enumerable: false,
|
142
|
+
configurable: true
|
143
|
+
});
|
144
|
+
return Validator;
|
145
|
+
}());
|
146
|
+
export { Validator };
|
@@ -0,0 +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
|
+
}
|
@@ -0,0 +1,94 @@
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
2
|
+
var extendStatics = function (d, b) {
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
6
|
+
return extendStatics(d, b);
|
7
|
+
};
|
8
|
+
return function (d, b) {
|
9
|
+
if (typeof b !== "function" && b !== null)
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
11
|
+
extendStatics(d, b);
|
12
|
+
function __() { this.constructor = d; }
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
14
|
+
};
|
15
|
+
})();
|
16
|
+
import { Validator } from './Validator';
|
17
|
+
import { NonPassValidator } from './NonPassValidator';
|
18
|
+
var ValidatorArray = (function (_super) {
|
19
|
+
__extends(ValidatorArray, _super);
|
20
|
+
function ValidatorArray(value, target, event, autoValid) {
|
21
|
+
if (autoValid === void 0) { autoValid = true; }
|
22
|
+
var _this = _super.call(this, value, target, event, autoValid) || this;
|
23
|
+
_this._makeValidatorFactory = function (value, target, event) {
|
24
|
+
return new NonPassValidator(value, target, event);
|
25
|
+
};
|
26
|
+
return _this;
|
27
|
+
}
|
28
|
+
ValidatorArray.prototype.getMakeValidatorFactory = function () {
|
29
|
+
return this._makeValidatorFactory;
|
30
|
+
};
|
31
|
+
ValidatorArray.prototype.setMakeValidatorFactory = function (value) {
|
32
|
+
this._makeValidatorFactory = value;
|
33
|
+
return this;
|
34
|
+
};
|
35
|
+
ValidatorArray.prototype.setArrayValue = function (target, value, event) {
|
36
|
+
var _a;
|
37
|
+
(_a = this.value) === null || _a === void 0 ? void 0 : _a.filter(function (it) {
|
38
|
+
if (it.getTarget()) {
|
39
|
+
return it.getTarget() === target;
|
40
|
+
}
|
41
|
+
else {
|
42
|
+
return false;
|
43
|
+
}
|
44
|
+
}).forEach(function (it) {
|
45
|
+
it.set(value, target, event);
|
46
|
+
});
|
47
|
+
};
|
48
|
+
ValidatorArray.prototype.addValidator = function (value, target, event) {
|
49
|
+
var _a, _b;
|
50
|
+
if (!this.value) {
|
51
|
+
this.value = [];
|
52
|
+
}
|
53
|
+
if (value instanceof Validator) {
|
54
|
+
(_a = this.value) === null || _a === void 0 ? void 0 : _a.push(value);
|
55
|
+
}
|
56
|
+
else {
|
57
|
+
(_b = this.value) === null || _b === void 0 ? void 0 : _b.push(this.makeValidator(value, target, event));
|
58
|
+
}
|
59
|
+
};
|
60
|
+
ValidatorArray.prototype.allChecked = function (checked) {
|
61
|
+
var _a;
|
62
|
+
this.checked = checked;
|
63
|
+
(_a = this.value) === null || _a === void 0 ? void 0 : _a.forEach(function (it) {
|
64
|
+
it.checked = checked;
|
65
|
+
});
|
66
|
+
};
|
67
|
+
ValidatorArray.prototype.getValidators = function () {
|
68
|
+
return this._value;
|
69
|
+
};
|
70
|
+
ValidatorArray.prototype.getValidator = function (e) {
|
71
|
+
var _a;
|
72
|
+
return (_a = this.value) === null || _a === void 0 ? void 0 : _a.filter(function (it) { return it.getTarget() === e; })[0];
|
73
|
+
};
|
74
|
+
ValidatorArray.prototype.getValidatorByValue = function (value) {
|
75
|
+
var validatorByValue = this.getValidatorByValues(value)[0];
|
76
|
+
return validatorByValue;
|
77
|
+
};
|
78
|
+
ValidatorArray.prototype.getValidatorByValues = function (value) {
|
79
|
+
var _a, _b;
|
80
|
+
return (_b = (_a = this.value) === null || _a === void 0 ? void 0 : _a.filter(function (it) { return it.value === value; })) !== null && _b !== void 0 ? _b : [];
|
81
|
+
};
|
82
|
+
ValidatorArray.prototype.removeElement = function (e) {
|
83
|
+
var value = this.value;
|
84
|
+
if (value) {
|
85
|
+
this.value = value.filter(function (it) { return it.getTarget() !== e; });
|
86
|
+
}
|
87
|
+
};
|
88
|
+
ValidatorArray.prototype.makeValidator = function (value, target, event) {
|
89
|
+
return this._makeValidatorFactory(value, target, event);
|
90
|
+
};
|
91
|
+
;
|
92
|
+
return ValidatorArray;
|
93
|
+
}(Validator));
|
94
|
+
export { ValidatorArray };
|
@@ -0,0 +1,30 @@
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
2
|
+
var extendStatics = function (d, b) {
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
6
|
+
return extendStatics(d, b);
|
7
|
+
};
|
8
|
+
return function (d, b) {
|
9
|
+
if (typeof b !== "function" && b !== null)
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
11
|
+
extendStatics(d, b);
|
12
|
+
function __() { this.constructor = d; }
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
14
|
+
};
|
15
|
+
})();
|
16
|
+
import { Validator } from './Validator';
|
17
|
+
var ValueEqualsValidator = (function (_super) {
|
18
|
+
__extends(ValueEqualsValidator, _super);
|
19
|
+
function ValueEqualsValidator(equalsValue, value, target, event, autoValid) {
|
20
|
+
if (autoValid === void 0) { autoValid = true; }
|
21
|
+
var _this = _super.call(this, value, target, event, autoValid) || this;
|
22
|
+
_this.equalsValue = equalsValue;
|
23
|
+
return _this;
|
24
|
+
}
|
25
|
+
ValueEqualsValidator.prototype.valid = function () {
|
26
|
+
return this.value === this.equalsValue;
|
27
|
+
};
|
28
|
+
return ValueEqualsValidator;
|
29
|
+
}(Validator));
|
30
|
+
export { ValueEqualsValidator };
|
@@ -0,0 +1,30 @@
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
2
|
+
var extendStatics = function (d, b) {
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
6
|
+
return extendStatics(d, b);
|
7
|
+
};
|
8
|
+
return function (d, b) {
|
9
|
+
if (typeof b !== "function" && b !== null)
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
11
|
+
extendStatics(d, b);
|
12
|
+
function __() { this.constructor = d; }
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
14
|
+
};
|
15
|
+
})();
|
16
|
+
import { Validator } from './Validator';
|
17
|
+
var ValueNotEqualsValidator = (function (_super) {
|
18
|
+
__extends(ValueNotEqualsValidator, _super);
|
19
|
+
function ValueNotEqualsValidator(equalsValue, value, target, event, autoValid) {
|
20
|
+
if (autoValid === void 0) { autoValid = true; }
|
21
|
+
var _this = _super.call(this, value, target, event, autoValid) || this;
|
22
|
+
_this.equalsValue = equalsValue;
|
23
|
+
return _this;
|
24
|
+
}
|
25
|
+
ValueNotEqualsValidator.prototype.valid = function () {
|
26
|
+
return this.value !== this.equalsValue;
|
27
|
+
};
|
28
|
+
return ValueNotEqualsValidator;
|
29
|
+
}(Validator));
|
30
|
+
export { ValueNotEqualsValidator };
|
@@ -1,13 +0,0 @@
|
|
1
|
-
export declare abstract class Validation<T = any, E = Element> {
|
2
|
-
protected _value?: T | undefined;
|
3
|
-
target?: E | undefined;
|
4
|
-
event?: Event | undefined;
|
5
|
-
constructor(_value?: T | undefined, target?: E | undefined, event?: Event | undefined);
|
6
|
-
get value(): T | undefined;
|
7
|
-
set value(value: T);
|
8
|
-
abstract valid(): boolean;
|
9
|
-
valids(): boolean;
|
10
|
-
inValids(): boolean;
|
11
|
-
get length(): any;
|
12
|
-
[name: string]: Validation | string | undefined | Element | any;
|
13
|
-
}
|
@@ -1,9 +0,0 @@
|
|
1
|
-
import { Validation } from './Validation';
|
2
|
-
export declare abstract class Validations<T = any, E = Element> extends Validation<Validation<T, E>[]> {
|
3
|
-
constructor(value?: Validation<T, E>[]);
|
4
|
-
get values(): Validation<T, E>[] | undefined;
|
5
|
-
setValue(target: E, value: T, event?: Event): void;
|
6
|
-
addValue(value: T, target: E, event?: Event): void;
|
7
|
-
removeElement(e: E): void;
|
8
|
-
makeValidation(value: T, target: E, event?: Event): Validation<T, E>;
|
9
|
-
}
|
@@ -1,13 +0,0 @@
|
|
1
|
-
export declare abstract class Validation<T = any, E = Element> {
|
2
|
-
protected _value?: T | undefined;
|
3
|
-
target?: E | undefined;
|
4
|
-
event?: Event | undefined;
|
5
|
-
constructor(_value?: T | undefined, target?: E | undefined, event?: Event | undefined);
|
6
|
-
get value(): T | undefined;
|
7
|
-
set value(value: T);
|
8
|
-
abstract valid(): boolean;
|
9
|
-
valids(): boolean;
|
10
|
-
inValids(): boolean;
|
11
|
-
get length(): any;
|
12
|
-
[name: string]: Validation | string | undefined | Element | any;
|
13
|
-
}
|
@@ -1,53 +0,0 @@
|
|
1
|
-
var __read = (this && this.__read) || function (o, n) {
|
2
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
3
|
-
if (!m) return o;
|
4
|
-
var i = m.call(o), r, ar = [], e;
|
5
|
-
try {
|
6
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
7
|
-
}
|
8
|
-
catch (error) { e = { error: error }; }
|
9
|
-
finally {
|
10
|
-
try {
|
11
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
12
|
-
}
|
13
|
-
finally { if (e) throw e.error; }
|
14
|
-
}
|
15
|
-
return ar;
|
16
|
-
};
|
17
|
-
var Validation = (function () {
|
18
|
-
function Validation(_value, target, event) {
|
19
|
-
this._value = _value;
|
20
|
-
this.target = target;
|
21
|
-
this.event = event;
|
22
|
-
}
|
23
|
-
Object.defineProperty(Validation.prototype, "value", {
|
24
|
-
get: function () {
|
25
|
-
return this._value;
|
26
|
-
},
|
27
|
-
set: function (value) {
|
28
|
-
this._value = value;
|
29
|
-
},
|
30
|
-
enumerable: false,
|
31
|
-
configurable: true
|
32
|
-
});
|
33
|
-
Validation.prototype.valids = function () {
|
34
|
-
return !this.inValids();
|
35
|
-
};
|
36
|
-
Validation.prototype.inValids = function () {
|
37
|
-
var inValid = Object.entries(this).filter(function (_a) {
|
38
|
-
var _b = __read(_a, 2), k = _b[0], v = _b[1];
|
39
|
-
return (v instanceof Validation) && !v.valid();
|
40
|
-
});
|
41
|
-
return inValid.length > 0;
|
42
|
-
};
|
43
|
-
Object.defineProperty(Validation.prototype, "length", {
|
44
|
-
get: function () {
|
45
|
-
var _a, _b;
|
46
|
-
return (_b = (_a = this.value) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
47
|
-
},
|
48
|
-
enumerable: false,
|
49
|
-
configurable: true
|
50
|
-
});
|
51
|
-
return Validation;
|
52
|
-
}());
|
53
|
-
export { Validation };
|
@@ -1,9 +0,0 @@
|
|
1
|
-
import { Validation } from './Validation';
|
2
|
-
export declare abstract class Validations<T = any, E = Element> extends Validation<Validation<T, E>[]> {
|
3
|
-
constructor(value?: Validation<T, E>[]);
|
4
|
-
get values(): Validation<T, E>[] | undefined;
|
5
|
-
setValue(target: E, value: T, event?: Event): void;
|
6
|
-
addValue(value: T, target: E, event?: Event): void;
|
7
|
-
removeElement(e: E): void;
|
8
|
-
makeValidation(value: T, target: E, event?: Event): Validation<T, E>;
|
9
|
-
}
|
@@ -1,63 +0,0 @@
|
|
1
|
-
var __extends = (this && this.__extends) || (function () {
|
2
|
-
var extendStatics = function (d, b) {
|
3
|
-
extendStatics = Object.setPrototypeOf ||
|
4
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
5
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
6
|
-
return extendStatics(d, b);
|
7
|
-
};
|
8
|
-
return function (d, b) {
|
9
|
-
if (typeof b !== "function" && b !== null)
|
10
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
11
|
-
extendStatics(d, b);
|
12
|
-
function __() { this.constructor = d; }
|
13
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
14
|
-
};
|
15
|
-
})();
|
16
|
-
import { Validation } from './Validation';
|
17
|
-
import { RequiredValidator } from './validators/RequiredValidator';
|
18
|
-
var Validations = (function (_super) {
|
19
|
-
__extends(Validations, _super);
|
20
|
-
function Validations(value) {
|
21
|
-
return _super.call(this, value) || this;
|
22
|
-
}
|
23
|
-
Object.defineProperty(Validations.prototype, "values", {
|
24
|
-
get: function () {
|
25
|
-
return this._value;
|
26
|
-
},
|
27
|
-
enumerable: false,
|
28
|
-
configurable: true
|
29
|
-
});
|
30
|
-
Validations.prototype.setValue = function (target, value, event) {
|
31
|
-
var _a;
|
32
|
-
(_a = this.value) === null || _a === void 0 ? void 0 : _a.filter(function (it) {
|
33
|
-
return it.target === target || it.target._DomRender_origin === target;
|
34
|
-
}).forEach(function (it) {
|
35
|
-
it.value = value;
|
36
|
-
it.event = event;
|
37
|
-
});
|
38
|
-
};
|
39
|
-
Validations.prototype.addValue = function (value, target, event) {
|
40
|
-
var _a, _b;
|
41
|
-
console.log('validations --> ', value, target, event);
|
42
|
-
if (!this.value) {
|
43
|
-
this.value = [];
|
44
|
-
}
|
45
|
-
if (value instanceof Validation) {
|
46
|
-
(_a = this.value) === null || _a === void 0 ? void 0 : _a.push(value);
|
47
|
-
}
|
48
|
-
else {
|
49
|
-
(_b = this.value) === null || _b === void 0 ? void 0 : _b.push(this.makeValidation(value, target, event));
|
50
|
-
}
|
51
|
-
};
|
52
|
-
Validations.prototype.removeElement = function (e) {
|
53
|
-
if (this.value) {
|
54
|
-
this.value = this.value.filter(function (it) { return it.target !== e; });
|
55
|
-
}
|
56
|
-
};
|
57
|
-
Validations.prototype.makeValidation = function (value, target, event) {
|
58
|
-
return new RequiredValidator(value, target, event);
|
59
|
-
};
|
60
|
-
;
|
61
|
-
return Validations;
|
62
|
-
}(Validation));
|
63
|
-
export { Validations };
|