dom-render
Advanced tools
Comparing version 1.0.59 to 1.0.60
@@ -8,4 +8,5 @@ export declare type Valid<T = any, E = Element> = (value?: T, target?: E, event?: Event) => boolean; | ||
private _autoValid; | ||
private _autoValidAction; | ||
private _validAction?; | ||
constructor(_value?: T | undefined, target?: E, event?: Event, autoValid?: boolean); | ||
constructor(_value?: T | undefined, target?: E, event?: Event, autoValid?: boolean, autoValidAction?: boolean); | ||
getValidAction(): ValidAction<T, E> | undefined; | ||
@@ -15,2 +16,4 @@ setValidAction(value: ValidAction<T, E>): this; | ||
setAutoValid(autoValid: boolean): this; | ||
getAutoValidAction(): boolean; | ||
setAutoValidAction(autoValid: boolean): this; | ||
getEvent(): Event | undefined; | ||
@@ -22,2 +25,3 @@ setEvent(event: Event | undefined): this; | ||
set value(value: T | undefined); | ||
protected tickValue(value: T | undefined): void; | ||
set(value?: T, target?: E, event?: Event): void; | ||
@@ -24,0 +28,0 @@ changeValue(value: T | undefined): void; |
{ | ||
"name": "dom-render", | ||
"version": "1.0.59", | ||
"version": "1.0.60", | ||
"main": "DomRender.js", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -199,3 +199,3 @@ var __read = (this && this.__read) || function (o, n) { | ||
varpath = drAttr_1.drForm + '.' + varpath; | ||
it.setAttribute(attrEventName, varpath + " = $target.value; " + fieldPath + ".setTarget($target); " + fieldPath + ".setEvent($event);"); | ||
it.setAttribute(attrEventName, fieldPath + ".set($target.value, $target, $event);"); | ||
data_1.setTarget(it); | ||
@@ -202,0 +202,0 @@ data_1.value = it.value; |
@@ -22,4 +22,10 @@ var __extends = (this && this.__extends) || (function () { | ||
var _this = _super.call(this, value, target, event, autoValid) || this; | ||
_this.validators = validators; | ||
_this.validators.forEach(function (it) { return it.set(_this.value, _this.getTarget(), _this.getEvent()); }); | ||
_this.validators = validators.map(function (it) { | ||
it.setAutoValid(false); | ||
it.setAutoValidAction(false); | ||
return it; | ||
}); | ||
_this.validators.forEach(function (it) { | ||
it.set(_this.value, _this.getTarget(), _this.getEvent()); | ||
}); | ||
return _this; | ||
@@ -26,0 +32,0 @@ } |
@@ -8,4 +8,5 @@ export declare type Valid<T = any, E = Element> = (value?: T, target?: E, event?: Event) => boolean; | ||
private _autoValid; | ||
private _autoValidAction; | ||
private _validAction?; | ||
constructor(_value?: T | undefined, target?: E, event?: Event, autoValid?: boolean); | ||
constructor(_value?: T | undefined, target?: E, event?: Event, autoValid?: boolean, autoValidAction?: boolean); | ||
getValidAction(): ValidAction<T, E> | undefined; | ||
@@ -15,2 +16,4 @@ setValidAction(value: ValidAction<T, E>): this; | ||
setAutoValid(autoValid: boolean): this; | ||
getAutoValidAction(): boolean; | ||
setAutoValidAction(autoValid: boolean): this; | ||
getEvent(): Event | undefined; | ||
@@ -22,2 +25,3 @@ setEvent(event: Event | undefined): this; | ||
set value(value: T | undefined); | ||
protected tickValue(value: T | undefined): void; | ||
set(value?: T, target?: E, event?: Event): void; | ||
@@ -24,0 +28,0 @@ changeValue(value: T | undefined): void; |
@@ -19,4 +19,5 @@ var __read = (this && this.__read) || function (o, n) { | ||
var Validator = (function () { | ||
function Validator(_value, target, event, autoValid) { | ||
function Validator(_value, target, event, autoValid, autoValidAction) { | ||
if (autoValid === void 0) { autoValid = true; } | ||
if (autoValidAction === void 0) { autoValidAction = true; } | ||
this._value = _value; | ||
@@ -26,2 +27,3 @@ this.setTarget(target); | ||
this.setAutoValid(autoValid); | ||
this.setAutoValidAction(autoValidAction); | ||
} | ||
@@ -42,2 +44,9 @@ Validator.prototype.getValidAction = function () { | ||
}; | ||
Validator.prototype.getAutoValidAction = function () { | ||
return this._autoValidAction; | ||
}; | ||
Validator.prototype.setAutoValidAction = function (autoValid) { | ||
this._autoValidAction = autoValid; | ||
return this; | ||
}; | ||
Validator.prototype.getEvent = function () { | ||
@@ -71,10 +80,3 @@ return this._event; | ||
this._value = value; | ||
this.changeValue(value); | ||
var target = this.getTarget(); | ||
if (target && (target === null || target === void 0 ? void 0 : target.value) !== undefined && (target === null || target === void 0 ? void 0 : target.value) !== null) { | ||
target.value = this._value; | ||
} | ||
if (this.getAutoValid()) { | ||
this.valid(); | ||
} | ||
this.tickValue(value); | ||
}, | ||
@@ -84,6 +86,19 @@ enumerable: false, | ||
}); | ||
Validator.prototype.tickValue = function (value) { | ||
this.changeValue(value); | ||
var target = this.getTarget(); | ||
if (target && (target === null || target === void 0 ? void 0 : target.value) !== undefined && (target === null || target === void 0 ? void 0 : target.value) !== null) { | ||
target.value = this._value; | ||
} | ||
if (this.getAutoValidAction()) { | ||
this.validAction(); | ||
} | ||
else if (this.getAutoValid()) { | ||
this.valid(); | ||
} | ||
}; | ||
Validator.prototype.set = function (value, target, event) { | ||
this.value = value; | ||
this.setTarget(target); | ||
this.setEvent(event); | ||
this.value = value; | ||
}; | ||
@@ -90,0 +105,0 @@ Validator.prototype.changeValue = function (value) { |
@@ -47,2 +47,3 @@ var __extends = (this && this.__extends) || (function () { | ||
}); | ||
this.tickValue(this.value); | ||
}; | ||
@@ -60,2 +61,3 @@ ValidatorArray.prototype.addValidator = function (value, target, event) { | ||
} | ||
this.tickValue(this.value); | ||
}; | ||
@@ -62,0 +64,0 @@ ValidatorArray.prototype.allChecked = function (checked) { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
317588
5842