@sumaris-net/ngx-components 1.12.12 → 1.13.1
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/bundles/sumaris-net.ngx-components.umd.js +112 -0
- package/bundles/sumaris-net.ngx-components.umd.js.map +1 -1
- package/bundles/sumaris-net.ngx-components.umd.min.js +1 -1
- package/bundles/sumaris-net.ngx-components.umd.min.js.map +1 -1
- package/doc/changelog.md +7 -2
- package/esm2015/src/app/shared/observables.js +1 -1
- package/esm2015/src/app/shared/pipes/pipes.module.js +4 -2
- package/esm2015/src/app/shared/pipes/string.pipes.js +13 -1
- package/esm2015/src/app/shared/validator/validators.js +94 -2
- package/fesm2015/sumaris-net.ngx-components.js +106 -2
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/src/app/shared/pipes/string.pipes.d.ts +3 -0
- package/src/app/shared/validator/validators.d.ts +30 -1
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -2957,6 +2957,21 @@
|
|
|
2957
2957
|
},] },
|
|
2958
2958
|
{ type: i0.Injectable, args: [{ providedIn: 'root' },] }
|
|
2959
2959
|
];
|
|
2960
|
+
var StrIncludesPipe = /** @class */ (function () {
|
|
2961
|
+
function StrIncludesPipe() {
|
|
2962
|
+
}
|
|
2963
|
+
StrIncludesPipe.prototype.transform = function (value, searchString, position) {
|
|
2964
|
+
return (value === null || value === void 0 ? void 0 : value.includes(searchString, position)) || false;
|
|
2965
|
+
};
|
|
2966
|
+
return StrIncludesPipe;
|
|
2967
|
+
}());
|
|
2968
|
+
StrIncludesPipe.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function StrIncludesPipe_Factory() { return new StrIncludesPipe(); }, token: StrIncludesPipe, providedIn: "root" });
|
|
2969
|
+
StrIncludesPipe.decorators = [
|
|
2970
|
+
{ type: i0.Pipe, args: [{
|
|
2971
|
+
name: 'strIncludes'
|
|
2972
|
+
},] },
|
|
2973
|
+
{ type: i0.Injectable, args: [{ providedIn: 'root' },] }
|
|
2974
|
+
];
|
|
2960
2975
|
|
|
2961
2976
|
var TranslateContextService = /** @class */ (function () {
|
|
2962
2977
|
function TranslateContextService(translate) {
|
|
@@ -3570,6 +3585,99 @@
|
|
|
3570
3585
|
};
|
|
3571
3586
|
return SharedFormArrayValidators;
|
|
3572
3587
|
}());
|
|
3588
|
+
// @dynamic
|
|
3589
|
+
var SharedAsyncValidators = /** @class */ (function () {
|
|
3590
|
+
function SharedAsyncValidators() {
|
|
3591
|
+
}
|
|
3592
|
+
/**
|
|
3593
|
+
* Add a debounce time to a validator.
|
|
3594
|
+
* @param form
|
|
3595
|
+
* @param validatorFn
|
|
3596
|
+
* @param opts Use opts.stopSubject to stop the validator, before end
|
|
3597
|
+
*/
|
|
3598
|
+
SharedAsyncValidators.debounceTime = function (validatorFn, opts) {
|
|
3599
|
+
// DEBUG only
|
|
3600
|
+
var debug = (opts === null || opts === void 0 ? void 0 : opts.debug) || false;
|
|
3601
|
+
var logPrefix = debug && "[debounceTime-validator] #" + SharedAsyncValidators.DEBOUNCE_TIME_VALIDATOR_ID++ + " - ";
|
|
3602
|
+
var debounceTime = toNumber(opts === null || opts === void 0 ? void 0 : opts.debounceTime, 250);
|
|
3603
|
+
// DEBUG
|
|
3604
|
+
if (debug)
|
|
3605
|
+
console.debug(logPrefix + ("New validator with a debounceTime at " + debounceTime + "ms"));
|
|
3606
|
+
var $disposeSubject = new rxjs.Subject();
|
|
3607
|
+
var disposeEvent$ = (opts === null || opts === void 0 ? void 0 : opts.dispose) ? rxjs.merge($disposeSubject, opts === null || opts === void 0 ? void 0 : opts.dispose)
|
|
3608
|
+
: $disposeSubject;
|
|
3609
|
+
// DEBUG
|
|
3610
|
+
if (debug && (opts === null || opts === void 0 ? void 0 : opts.dispose)) {
|
|
3611
|
+
opts === null || opts === void 0 ? void 0 : opts.dispose.pipe(operators.first()).subscribe(function () {
|
|
3612
|
+
console.debug(logPrefix + 'Stopping');
|
|
3613
|
+
});
|
|
3614
|
+
}
|
|
3615
|
+
return function (control) {
|
|
3616
|
+
if (debug)
|
|
3617
|
+
console.debug(logPrefix + 'Form ask validation...');
|
|
3618
|
+
// Stop previous observables
|
|
3619
|
+
$disposeSubject.next();
|
|
3620
|
+
var now;
|
|
3621
|
+
// Add a delay before execution
|
|
3622
|
+
return rxjs.timer(debounceTime)
|
|
3623
|
+
.pipe(
|
|
3624
|
+
// DEBUG
|
|
3625
|
+
operators.tap(function (_) {
|
|
3626
|
+
if (debug) {
|
|
3627
|
+
console.debug(logPrefix + 'Executing...');
|
|
3628
|
+
now = Date.now();
|
|
3629
|
+
}
|
|
3630
|
+
}), operators.switchMap(function (_) {
|
|
3631
|
+
// Call the validator
|
|
3632
|
+
var res = validatorFn(control);
|
|
3633
|
+
// Make sure to return an Observable
|
|
3634
|
+
if (rxjs.isObservable(res))
|
|
3635
|
+
return res;
|
|
3636
|
+
if (res instanceof Promise)
|
|
3637
|
+
return rxjs.from(res);
|
|
3638
|
+
return rxjs.of(res);
|
|
3639
|
+
}),
|
|
3640
|
+
// DEBUG
|
|
3641
|
+
operators.tap(function (res) { return debug && console.debug(logPrefix + ("Finished in " + (Date.now() - now) + "ms (" + (res ? 'with errors' : 'no error') + ")"), res); }), operators.catchError(function (error) {
|
|
3642
|
+
console.error('[debounceTime-validator] Error while executing validator. Stopping job', error);
|
|
3643
|
+
$disposeSubject.next();
|
|
3644
|
+
throw error;
|
|
3645
|
+
}),
|
|
3646
|
+
// Refresh UI, after a successful execution
|
|
3647
|
+
operators.tap(function () { return (opts === null || opts === void 0 ? void 0 : opts.markForCheck) && (opts === null || opts === void 0 ? void 0 : opts.markForCheck()); }),
|
|
3648
|
+
// Make sure to stop, because of the switchMap
|
|
3649
|
+
operators.takeUntil(disposeEvent$));
|
|
3650
|
+
};
|
|
3651
|
+
};
|
|
3652
|
+
/**
|
|
3653
|
+
* Add an async validator, that can be disposed by the returned subscription
|
|
3654
|
+
* @param form
|
|
3655
|
+
* @param validatorFn the validator or job to execute
|
|
3656
|
+
* @param opts
|
|
3657
|
+
*/
|
|
3658
|
+
SharedAsyncValidators.registerAsyncValidator = function (form, validatorFn, opts) {
|
|
3659
|
+
if (form.asyncValidator)
|
|
3660
|
+
throw Error('Form already have an async validator. Cannot configure job');
|
|
3661
|
+
var debounceTime = toNumber(opts === null || opts === void 0 ? void 0 : opts.debounceTime, 250);
|
|
3662
|
+
var $dispose = new rxjs.Subject();
|
|
3663
|
+
var asyncValidatorFn = SharedAsyncValidators.debounceTime(validatorFn, Object.assign(Object.assign({}, opts), { debounceTime: debounceTime, dispose: $dispose }));
|
|
3664
|
+
form.setAsyncValidators(asyncValidatorFn);
|
|
3665
|
+
var subscription = new rxjs.Subscription();
|
|
3666
|
+
// When unsubscribing, remove async validator
|
|
3667
|
+
subscription.add(function () {
|
|
3668
|
+
// Clear added validator. Must be done NOW (without delay) because generally a new Job is given just after
|
|
3669
|
+
form.clearAsyncValidators();
|
|
3670
|
+
// Stop the job, with a delay to let the last execution finished
|
|
3671
|
+
setTimeout(function () {
|
|
3672
|
+
$dispose.next();
|
|
3673
|
+
$dispose.unsubscribe();
|
|
3674
|
+
}, debounceTime);
|
|
3675
|
+
});
|
|
3676
|
+
return subscription;
|
|
3677
|
+
};
|
|
3678
|
+
return SharedAsyncValidators;
|
|
3679
|
+
}());
|
|
3680
|
+
SharedAsyncValidators.DEBOUNCE_TIME_VALIDATOR_ID = 0;
|
|
3573
3681
|
|
|
3574
3682
|
/**
|
|
3575
3683
|
* Fill a form using a source entity
|
|
@@ -4474,6 +4582,7 @@
|
|
|
4474
4582
|
IsNotNilOrBlankPipe,
|
|
4475
4583
|
ToStringPipe,
|
|
4476
4584
|
StrLengthPipe,
|
|
4585
|
+
StrIncludesPipe,
|
|
4477
4586
|
TranslateContextPipe,
|
|
4478
4587
|
TranslatablePipe,
|
|
4479
4588
|
NgInitDirective,
|
|
@@ -4509,6 +4618,7 @@
|
|
|
4509
4618
|
IsNotNilOrBlankPipe,
|
|
4510
4619
|
ToStringPipe,
|
|
4511
4620
|
StrLengthPipe,
|
|
4621
|
+
StrIncludesPipe,
|
|
4512
4622
|
ArrayIncludesPipe,
|
|
4513
4623
|
ArrayFilterPipe,
|
|
4514
4624
|
TranslateContextPipe,
|
|
@@ -30890,6 +31000,7 @@
|
|
|
30890
31000
|
exports.SPACE_PLACEHOLDER_CHAR = SPACE_PLACEHOLDER_CHAR;
|
|
30891
31001
|
exports.SelectPeerModal = SelectPeerModal;
|
|
30892
31002
|
exports.SettingsPage = SettingsPage;
|
|
31003
|
+
exports.SharedAsyncValidators = SharedAsyncValidators;
|
|
30893
31004
|
exports.SharedDirectivesModule = SharedDirectivesModule;
|
|
30894
31005
|
exports.SharedFormArrayValidators = SharedFormArrayValidators;
|
|
30895
31006
|
exports.SharedFormGroupValidators = SharedFormGroupValidators;
|
|
@@ -30915,6 +31026,7 @@
|
|
|
30915
31026
|
exports.StatusById = StatusById;
|
|
30916
31027
|
exports.StatusIds = StatusIds;
|
|
30917
31028
|
exports.StatusList = StatusList;
|
|
31029
|
+
exports.StrIncludesPipe = StrIncludesPipe;
|
|
30918
31030
|
exports.StrLengthPipe = StrLengthPipe;
|
|
30919
31031
|
exports.SwipeTestPage = SwipeTestPage;
|
|
30920
31032
|
exports.TableSelectColumnsComponent = TableSelectColumnsComponent;
|