Skip to content

Commit

Permalink
chore(all): prepare release 2.0.0-rc1
Browse files Browse the repository at this point in the history
  • Loading branch information
EisenbergEffect committed Mar 26, 2020
1 parent b495f63 commit cde6dff
Show file tree
Hide file tree
Showing 13 changed files with 700 additions and 128 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aurelia-validation",
"version": "1.6.0",
"version": "2.0.0-rc1",
"description": "Validation for Aurelia applications",
"keywords": [
"aurelia",
Expand Down
96 changes: 84 additions & 12 deletions dist/amd/aurelia-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,16 @@ define('aurelia-validation', ['exports', 'aurelia-binding', 'aurelia-templating'
* when it updates the model due to a change in the view.
*/
validateTrigger[validateTrigger["changeOrBlur"] = 3] = "changeOrBlur";
/**
* Validate the binding when the binding's target element fires a DOM "focusout" event.
* Unlike "blur", this event bubbles.
*/
validateTrigger[validateTrigger["focusout"] = 4] = "focusout";
/**
* Validate the binding when the binding's target element fires a DOM "focusout" event or
* when it updates the model due to a change in the view.
*/
validateTrigger[validateTrigger["changeOrFocusout"] = 6] = "changeOrFocusout";
})(exports.validateTrigger || (exports.validateTrigger = {}));

/**
Expand Down Expand Up @@ -1041,6 +1051,7 @@ define('aurelia-validation', ['exports', 'aurelia-binding', 'aurelia-templating'
return ValidationController;
}());

// tslint:disable:no-bitwise
/**
* Binding behavior. Indicates the bound property should be validated.
*/
Expand All @@ -1067,23 +1078,48 @@ define('aurelia-validation', ['exports', 'aurelia-binding', 'aurelia-templating'
controller.registerBinding(binding, target, rules);
binding.validationController = controller;
var trigger = this.getValidateTrigger(controller);
// tslint:disable-next-line:no-bitwise
if (trigger & exports.validateTrigger.change) {
var event = (trigger & exports.validateTrigger.blur) === exports.validateTrigger.blur ? 'blur'
: (trigger & exports.validateTrigger.focusout) === exports.validateTrigger.focusout ? 'focusout'
: null;
var hasChangeTrigger = (trigger & exports.validateTrigger.change) === exports.validateTrigger.change;
binding.isDirty = !hasChangeTrigger;
// validatedOnce is used to control whether controller should validate upon user input
//
// always true when validation trigger doesn't include "blur" event (blur/focusout)
// else it will be set to true after (a) the first user input & loss of focus or (b) validation
binding.validatedOnce = hasChangeTrigger && event === null;
if (hasChangeTrigger) {
binding.vbbUpdateSource = binding.updateSource;
// tslint:disable-next-line:only-arrow-functions
// tslint:disable-next-line:space-before-function-paren
binding.updateSource = function (value) {
this.vbbUpdateSource(value);
this.validationController.validateBinding(this);
this.isDirty = true;
if (this.validatedOnce) {
this.validationController.validateBinding(this);
}
};
}
// tslint:disable-next-line:no-bitwise
if (trigger & exports.validateTrigger.blur) {
binding.validateBlurHandler = function () {
_this.taskQueue.queueMicroTask(function () { return controller.validateBinding(binding); });
if (event !== null) {
binding.focusLossHandler = function () {
_this.taskQueue.queueMicroTask(function () {
if (binding.isDirty) {
controller.validateBinding(binding);
binding.validatedOnce = true;
}
});
};
binding.validationTriggerEvent = event;
binding.validateTarget = target;
target.addEventListener('blur', binding.validateBlurHandler);
target.addEventListener(event, binding.focusLossHandler);
if (hasChangeTrigger) {
var propertyName_1 = getPropertyInfo(binding.sourceExpression, binding.source).propertyName;
binding.validationSubscription = controller.subscribe(function (event) {
if (!binding.validatedOnce && event.type === 'validate') {
binding.validatedOnce = event.errors.findIndex(function (e) { return e.propertyName === propertyName_1; }) > -1;
}
});
}
}
if (trigger !== exports.validateTrigger.manual) {
binding.standardUpdateTarget = binding.updateTarget;
Expand All @@ -1105,13 +1141,19 @@ define('aurelia-validation', ['exports', 'aurelia-binding', 'aurelia-templating'
binding.updateTarget = binding.standardUpdateTarget;
binding.standardUpdateTarget = null;
}
if (binding.validateBlurHandler) {
binding.validateTarget.removeEventListener('blur', binding.validateBlurHandler);
binding.validateBlurHandler = null;
if (binding.focusLossHandler) {
binding.validateTarget.removeEventListener(binding.validationTriggerEvent, binding.focusLossHandler);
binding.focusLossHandler = null;
binding.validateTarget = null;
}
if (binding.validationSubscription) {
binding.validationSubscription.dispose();
binding.validationSubscription = null;
}
binding.validationController.unregisterBinding(binding);
binding.validationController = null;
binding.isDirty = null;
binding.validatedOnce = null;
};
return ValidateBindingBehaviorBase;
}());
Expand Down Expand Up @@ -1209,6 +1251,34 @@ define('aurelia-validation', ['exports', 'aurelia-binding', 'aurelia-templating'
aureliaBinding.bindingBehavior('validateOnChangeOrBlur')
], ValidateOnChangeOrBlurBindingBehavior);
return ValidateOnChangeOrBlurBindingBehavior;
}(ValidateBindingBehaviorBase));
var ValidateOnFocusoutBindingBehavior = /** @class */ (function (_super) {
__extends(ValidateOnFocusoutBindingBehavior, _super);
function ValidateOnFocusoutBindingBehavior() {
return _super !== null && _super.apply(this, arguments) || this;
}
ValidateOnFocusoutBindingBehavior.prototype.getValidateTrigger = function () {
return exports.validateTrigger.focusout;
};
ValidateOnFocusoutBindingBehavior.inject = [aureliaTaskQueue.TaskQueue];
ValidateOnFocusoutBindingBehavior = __decorate([
aureliaBinding.bindingBehavior('validateOnFocusout')
], ValidateOnFocusoutBindingBehavior);
return ValidateOnFocusoutBindingBehavior;
}(ValidateBindingBehaviorBase));
var ValidateOnChangeOrFocusoutBindingBehavior = /** @class */ (function (_super) {
__extends(ValidateOnChangeOrFocusoutBindingBehavior, _super);
function ValidateOnChangeOrFocusoutBindingBehavior() {
return _super !== null && _super.apply(this, arguments) || this;
}
ValidateOnChangeOrFocusoutBindingBehavior.prototype.getValidateTrigger = function () {
return exports.validateTrigger.changeOrFocusout;
};
ValidateOnChangeOrFocusoutBindingBehavior.inject = [aureliaTaskQueue.TaskQueue];
ValidateOnChangeOrFocusoutBindingBehavior = __decorate([
aureliaBinding.bindingBehavior('validateOnChangeOrFocusout')
], ValidateOnChangeOrFocusoutBindingBehavior);
return ValidateOnChangeOrFocusoutBindingBehavior;
}(ValidateBindingBehaviorBase));

/**
Expand Down Expand Up @@ -1865,7 +1935,7 @@ define('aurelia-validation', ['exports', 'aurelia-binding', 'aurelia-templating'
config.apply(frameworkConfig.container);
// globalize the behaviors.
if (frameworkConfig.globalResources) {
frameworkConfig.globalResources(ValidateBindingBehavior, ValidateManuallyBindingBehavior, ValidateOnBlurBindingBehavior, ValidateOnChangeBindingBehavior, ValidateOnChangeOrBlurBindingBehavior, ValidationErrorsCustomAttribute, ValidationRendererCustomAttribute);
frameworkConfig.globalResources(ValidateBindingBehavior, ValidateManuallyBindingBehavior, ValidateOnBlurBindingBehavior, ValidateOnFocusoutBindingBehavior, ValidateOnChangeBindingBehavior, ValidateOnChangeOrBlurBindingBehavior, ValidateOnChangeOrFocusoutBindingBehavior, ValidationErrorsCustomAttribute, ValidationRendererCustomAttribute);
}
}

Expand All @@ -1880,6 +1950,8 @@ define('aurelia-validation', ['exports', 'aurelia-binding', 'aurelia-templating'
exports.ValidateOnBlurBindingBehavior = ValidateOnBlurBindingBehavior;
exports.ValidateOnChangeBindingBehavior = ValidateOnChangeBindingBehavior;
exports.ValidateOnChangeOrBlurBindingBehavior = ValidateOnChangeOrBlurBindingBehavior;
exports.ValidateOnFocusoutBindingBehavior = ValidateOnFocusoutBindingBehavior;
exports.ValidateOnChangeOrFocusoutBindingBehavior = ValidateOnChangeOrFocusoutBindingBehavior;
exports.ValidateEvent = ValidateEvent;
exports.ValidateResult = ValidateResult;
exports.ValidationController = ValidationController;
Expand Down
20 changes: 19 additions & 1 deletion dist/aurelia-validation.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,17 @@ export declare enum validateTrigger {
* Validate the binding when the binding's target element fires a DOM "blur" event and
* when it updates the model due to a change in the view.
*/
changeOrBlur = 3
changeOrBlur = 3,
/**
* Validate the binding when the binding's target element fires a DOM "focusout" event.
* Unlike "blur", this event bubbles.
*/
focusout = 4,
/**
* Validate the binding when the binding's target element fires a DOM "focusout" event or
* when it updates the model due to a change in the view.
*/
changeOrFocusout = 6
}
export declare type ValidatorCtor = new (...args: any[]) => Validator;
/**
Expand Down Expand Up @@ -426,6 +436,14 @@ export declare class ValidateOnChangeOrBlurBindingBehavior extends ValidateBindi
static inject: (typeof TaskQueue)[];
getValidateTrigger(): validateTrigger;
}
export declare class ValidateOnFocusoutBindingBehavior extends ValidateBindingBehaviorBase {
static inject: (typeof TaskQueue)[];
getValidateTrigger(): validateTrigger;
}
export declare class ValidateOnChangeOrFocusoutBindingBehavior extends ValidateBindingBehaviorBase {
static inject: (typeof TaskQueue)[];
getValidateTrigger(): validateTrigger;
}
/**
* Creates ValidationController instances.
*/
Expand Down
96 changes: 84 additions & 12 deletions dist/commonjs/aurelia-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,16 @@ var StandardValidator = /** @class */ (function (_super) {
* when it updates the model due to a change in the view.
*/
validateTrigger[validateTrigger["changeOrBlur"] = 3] = "changeOrBlur";
/**
* Validate the binding when the binding's target element fires a DOM "focusout" event.
* Unlike "blur", this event bubbles.
*/
validateTrigger[validateTrigger["focusout"] = 4] = "focusout";
/**
* Validate the binding when the binding's target element fires a DOM "focusout" event or
* when it updates the model due to a change in the view.
*/
validateTrigger[validateTrigger["changeOrFocusout"] = 6] = "changeOrFocusout";
})(exports.validateTrigger || (exports.validateTrigger = {}));

/**
Expand Down Expand Up @@ -1050,6 +1060,7 @@ var ValidationController = /** @class */ (function () {
return ValidationController;
}());

// tslint:disable:no-bitwise
/**
* Binding behavior. Indicates the bound property should be validated.
*/
Expand All @@ -1076,23 +1087,48 @@ var ValidateBindingBehaviorBase = /** @class */ (function () {
controller.registerBinding(binding, target, rules);
binding.validationController = controller;
var trigger = this.getValidateTrigger(controller);
// tslint:disable-next-line:no-bitwise
if (trigger & exports.validateTrigger.change) {
var event = (trigger & exports.validateTrigger.blur) === exports.validateTrigger.blur ? 'blur'
: (trigger & exports.validateTrigger.focusout) === exports.validateTrigger.focusout ? 'focusout'
: null;
var hasChangeTrigger = (trigger & exports.validateTrigger.change) === exports.validateTrigger.change;
binding.isDirty = !hasChangeTrigger;
// validatedOnce is used to control whether controller should validate upon user input
//
// always true when validation trigger doesn't include "blur" event (blur/focusout)
// else it will be set to true after (a) the first user input & loss of focus or (b) validation
binding.validatedOnce = hasChangeTrigger && event === null;
if (hasChangeTrigger) {
binding.vbbUpdateSource = binding.updateSource;
// tslint:disable-next-line:only-arrow-functions
// tslint:disable-next-line:space-before-function-paren
binding.updateSource = function (value) {
this.vbbUpdateSource(value);
this.validationController.validateBinding(this);
this.isDirty = true;
if (this.validatedOnce) {
this.validationController.validateBinding(this);
}
};
}
// tslint:disable-next-line:no-bitwise
if (trigger & exports.validateTrigger.blur) {
binding.validateBlurHandler = function () {
_this.taskQueue.queueMicroTask(function () { return controller.validateBinding(binding); });
if (event !== null) {
binding.focusLossHandler = function () {
_this.taskQueue.queueMicroTask(function () {
if (binding.isDirty) {
controller.validateBinding(binding);
binding.validatedOnce = true;
}
});
};
binding.validationTriggerEvent = event;
binding.validateTarget = target;
target.addEventListener('blur', binding.validateBlurHandler);
target.addEventListener(event, binding.focusLossHandler);
if (hasChangeTrigger) {
var propertyName_1 = getPropertyInfo(binding.sourceExpression, binding.source).propertyName;
binding.validationSubscription = controller.subscribe(function (event) {
if (!binding.validatedOnce && event.type === 'validate') {
binding.validatedOnce = event.errors.findIndex(function (e) { return e.propertyName === propertyName_1; }) > -1;
}
});
}
}
if (trigger !== exports.validateTrigger.manual) {
binding.standardUpdateTarget = binding.updateTarget;
Expand All @@ -1114,13 +1150,19 @@ var ValidateBindingBehaviorBase = /** @class */ (function () {
binding.updateTarget = binding.standardUpdateTarget;
binding.standardUpdateTarget = null;
}
if (binding.validateBlurHandler) {
binding.validateTarget.removeEventListener('blur', binding.validateBlurHandler);
binding.validateBlurHandler = null;
if (binding.focusLossHandler) {
binding.validateTarget.removeEventListener(binding.validationTriggerEvent, binding.focusLossHandler);
binding.focusLossHandler = null;
binding.validateTarget = null;
}
if (binding.validationSubscription) {
binding.validationSubscription.dispose();
binding.validationSubscription = null;
}
binding.validationController.unregisterBinding(binding);
binding.validationController = null;
binding.isDirty = null;
binding.validatedOnce = null;
};
return ValidateBindingBehaviorBase;
}());
Expand Down Expand Up @@ -1218,6 +1260,34 @@ var ValidateOnChangeOrBlurBindingBehavior = /** @class */ (function (_super) {
aureliaBinding.bindingBehavior('validateOnChangeOrBlur')
], ValidateOnChangeOrBlurBindingBehavior);
return ValidateOnChangeOrBlurBindingBehavior;
}(ValidateBindingBehaviorBase));
var ValidateOnFocusoutBindingBehavior = /** @class */ (function (_super) {
__extends(ValidateOnFocusoutBindingBehavior, _super);
function ValidateOnFocusoutBindingBehavior() {
return _super !== null && _super.apply(this, arguments) || this;
}
ValidateOnFocusoutBindingBehavior.prototype.getValidateTrigger = function () {
return exports.validateTrigger.focusout;
};
ValidateOnFocusoutBindingBehavior.inject = [aureliaTaskQueue.TaskQueue];
ValidateOnFocusoutBindingBehavior = __decorate([
aureliaBinding.bindingBehavior('validateOnFocusout')
], ValidateOnFocusoutBindingBehavior);
return ValidateOnFocusoutBindingBehavior;
}(ValidateBindingBehaviorBase));
var ValidateOnChangeOrFocusoutBindingBehavior = /** @class */ (function (_super) {
__extends(ValidateOnChangeOrFocusoutBindingBehavior, _super);
function ValidateOnChangeOrFocusoutBindingBehavior() {
return _super !== null && _super.apply(this, arguments) || this;
}
ValidateOnChangeOrFocusoutBindingBehavior.prototype.getValidateTrigger = function () {
return exports.validateTrigger.changeOrFocusout;
};
ValidateOnChangeOrFocusoutBindingBehavior.inject = [aureliaTaskQueue.TaskQueue];
ValidateOnChangeOrFocusoutBindingBehavior = __decorate([
aureliaBinding.bindingBehavior('validateOnChangeOrFocusout')
], ValidateOnChangeOrFocusoutBindingBehavior);
return ValidateOnChangeOrFocusoutBindingBehavior;
}(ValidateBindingBehaviorBase));

/**
Expand Down Expand Up @@ -1874,7 +1944,7 @@ frameworkConfig, callback) {
config.apply(frameworkConfig.container);
// globalize the behaviors.
if (frameworkConfig.globalResources) {
frameworkConfig.globalResources(ValidateBindingBehavior, ValidateManuallyBindingBehavior, ValidateOnBlurBindingBehavior, ValidateOnChangeBindingBehavior, ValidateOnChangeOrBlurBindingBehavior, ValidationErrorsCustomAttribute, ValidationRendererCustomAttribute);
frameworkConfig.globalResources(ValidateBindingBehavior, ValidateManuallyBindingBehavior, ValidateOnBlurBindingBehavior, ValidateOnFocusoutBindingBehavior, ValidateOnChangeBindingBehavior, ValidateOnChangeOrBlurBindingBehavior, ValidateOnChangeOrFocusoutBindingBehavior, ValidationErrorsCustomAttribute, ValidationRendererCustomAttribute);
}
}

Expand All @@ -1889,6 +1959,8 @@ exports.ValidateManuallyBindingBehavior = ValidateManuallyBindingBehavior;
exports.ValidateOnBlurBindingBehavior = ValidateOnBlurBindingBehavior;
exports.ValidateOnChangeBindingBehavior = ValidateOnChangeBindingBehavior;
exports.ValidateOnChangeOrBlurBindingBehavior = ValidateOnChangeOrBlurBindingBehavior;
exports.ValidateOnFocusoutBindingBehavior = ValidateOnFocusoutBindingBehavior;
exports.ValidateOnChangeOrFocusoutBindingBehavior = ValidateOnChangeOrFocusoutBindingBehavior;
exports.ValidateEvent = ValidateEvent;
exports.ValidateResult = ValidateResult;
exports.ValidationController = ValidationController;
Expand Down
Loading

0 comments on commit cde6dff

Please sign in to comment.