@sumaris-net/ngx-components 1.12.11 → 1.13.0
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 +176 -9
- package/bundles/sumaris-net.ngx-components.umd.js.map +1 -1
- package/bundles/sumaris-net.ngx-components.umd.min.js +2 -2
- 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 +12 -2
- package/esm2015/src/app/shared/pipes/form.pipes.js +28 -4
- package/esm2015/src/app/shared/pipes/pipes.module.js +11 -5
- package/esm2015/src/app/shared/pipes/string.pipes.js +13 -1
- package/esm2015/src/app/shared/validator/validators.js +103 -2
- package/fesm2015/sumaris-net.ngx-components.js +157 -7
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/src/app/shared/observables.d.ts +1 -0
- package/src/app/shared/pipes/form.pipes.d.ts +8 -2
- package/src/app/shared/pipes/string.pipes.d.ts +3 -0
- package/src/app/shared/validator/validators.d.ts +35 -1
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -1187,6 +1187,16 @@
|
|
|
1187
1187
|
});
|
|
1188
1188
|
});
|
|
1189
1189
|
}
|
|
1190
|
+
function fromPromise(promise) {
|
|
1191
|
+
var $observable = new rxjs.Subject();
|
|
1192
|
+
promise
|
|
1193
|
+
.then(function (errors) {
|
|
1194
|
+
$observable.next(errors);
|
|
1195
|
+
$observable.complete();
|
|
1196
|
+
})
|
|
1197
|
+
.catch(function (err) { return $observable.error(err); });
|
|
1198
|
+
return $observable;
|
|
1199
|
+
}
|
|
1190
1200
|
|
|
1191
1201
|
function createPromiseEventEmitter() {
|
|
1192
1202
|
return new i0.EventEmitter(true);
|
|
@@ -2957,6 +2967,21 @@
|
|
|
2957
2967
|
},] },
|
|
2958
2968
|
{ type: i0.Injectable, args: [{ providedIn: 'root' },] }
|
|
2959
2969
|
];
|
|
2970
|
+
var StrIncludesPipe = /** @class */ (function () {
|
|
2971
|
+
function StrIncludesPipe() {
|
|
2972
|
+
}
|
|
2973
|
+
StrIncludesPipe.prototype.transform = function (value, searchString, position) {
|
|
2974
|
+
return (value === null || value === void 0 ? void 0 : value.includes(searchString, position)) || false;
|
|
2975
|
+
};
|
|
2976
|
+
return StrIncludesPipe;
|
|
2977
|
+
}());
|
|
2978
|
+
StrIncludesPipe.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function StrIncludesPipe_Factory() { return new StrIncludesPipe(); }, token: StrIncludesPipe, providedIn: "root" });
|
|
2979
|
+
StrIncludesPipe.decorators = [
|
|
2980
|
+
{ type: i0.Pipe, args: [{
|
|
2981
|
+
name: 'strIncludes'
|
|
2982
|
+
},] },
|
|
2983
|
+
{ type: i0.Injectable, args: [{ providedIn: 'root' },] }
|
|
2984
|
+
];
|
|
2960
2985
|
|
|
2961
2986
|
var TranslateContextService = /** @class */ (function () {
|
|
2962
2987
|
function TranslateContextService(translate) {
|
|
@@ -3570,6 +3595,107 @@
|
|
|
3570
3595
|
};
|
|
3571
3596
|
return SharedFormArrayValidators;
|
|
3572
3597
|
}());
|
|
3598
|
+
// @dynamic
|
|
3599
|
+
var SharedAsyncValidators = /** @class */ (function () {
|
|
3600
|
+
function SharedAsyncValidators() {
|
|
3601
|
+
}
|
|
3602
|
+
/**
|
|
3603
|
+
* Create an observable validator function. Will execute the validator, then cnvert the result into an observable
|
|
3604
|
+
* @param validatorFn any validator
|
|
3605
|
+
*/
|
|
3606
|
+
SharedAsyncValidators.of = function (validatorFn) {
|
|
3607
|
+
return function (control) {
|
|
3608
|
+
var res = validatorFn(control);
|
|
3609
|
+
if (rxjs.isObservable(res)) {
|
|
3610
|
+
return res;
|
|
3611
|
+
} // Already an observable
|
|
3612
|
+
if (res instanceof Promise)
|
|
3613
|
+
return fromPromise(res);
|
|
3614
|
+
return rxjs.of(res);
|
|
3615
|
+
};
|
|
3616
|
+
};
|
|
3617
|
+
/**
|
|
3618
|
+
* Add a debounce time to a validator.
|
|
3619
|
+
* @param form
|
|
3620
|
+
* @param validatorFn
|
|
3621
|
+
* @param opts Use opts.stopSubject to stop the validator, before end
|
|
3622
|
+
*/
|
|
3623
|
+
SharedAsyncValidators.debounceTime = function (validatorFn, opts) {
|
|
3624
|
+
// DEBUG only
|
|
3625
|
+
var debug = (opts === null || opts === void 0 ? void 0 : opts.debug) || false;
|
|
3626
|
+
var logPrefix = debug && "[debounceTime-validator] #" + SharedAsyncValidators.DEBOUNCE_TIME_VALIDATOR_ID++ + " - ";
|
|
3627
|
+
var debounceTime = toNumber(opts === null || opts === void 0 ? void 0 : opts.debounceTime, 250);
|
|
3628
|
+
// DEBUG
|
|
3629
|
+
if (debug)
|
|
3630
|
+
console.debug(logPrefix + ("New validator with a debounceTime at " + debounceTime + "ms"));
|
|
3631
|
+
var $disposeSubject = new rxjs.Subject();
|
|
3632
|
+
var disposeEvent$ = (opts === null || opts === void 0 ? void 0 : opts.dispose) ? rxjs.merge($disposeSubject, opts === null || opts === void 0 ? void 0 : opts.dispose)
|
|
3633
|
+
: $disposeSubject;
|
|
3634
|
+
// Make sure validator will return an Observable - This is need by the switchMap()
|
|
3635
|
+
var asyncValidatorFn = SharedAsyncValidators.of(validatorFn);
|
|
3636
|
+
// DEBUG
|
|
3637
|
+
if (debug && (opts === null || opts === void 0 ? void 0 : opts.dispose)) {
|
|
3638
|
+
opts === null || opts === void 0 ? void 0 : opts.dispose.pipe(operators.first()).subscribe(function () {
|
|
3639
|
+
console.debug(logPrefix + 'Stopping');
|
|
3640
|
+
});
|
|
3641
|
+
}
|
|
3642
|
+
return function (control) {
|
|
3643
|
+
if (debug)
|
|
3644
|
+
console.debug(logPrefix + 'Form ask validation...');
|
|
3645
|
+
// Stop previous observables
|
|
3646
|
+
$disposeSubject.next();
|
|
3647
|
+
var now;
|
|
3648
|
+
// Add a delay before execution
|
|
3649
|
+
return rxjs.timer(debounceTime)
|
|
3650
|
+
.pipe(
|
|
3651
|
+
// DEBUG
|
|
3652
|
+
operators.tap(function (_) {
|
|
3653
|
+
if (debug) {
|
|
3654
|
+
console.debug(logPrefix + 'Executing...');
|
|
3655
|
+
now = Date.now();
|
|
3656
|
+
}
|
|
3657
|
+
}), operators.switchMap(function (_) { return asyncValidatorFn(control); }),
|
|
3658
|
+
// DEBUG
|
|
3659
|
+
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) {
|
|
3660
|
+
console.error('[debounceTime-validator] Error while executing validator. Stopping job', error);
|
|
3661
|
+
$disposeSubject.next();
|
|
3662
|
+
throw error;
|
|
3663
|
+
}),
|
|
3664
|
+
// Refresh UI, after a successful execution
|
|
3665
|
+
operators.tap(function () { return (opts === null || opts === void 0 ? void 0 : opts.markForCheck) && (opts === null || opts === void 0 ? void 0 : opts.markForCheck()); }),
|
|
3666
|
+
// Make sure to stop, because of the switchMap
|
|
3667
|
+
operators.takeUntil(disposeEvent$));
|
|
3668
|
+
};
|
|
3669
|
+
};
|
|
3670
|
+
/**
|
|
3671
|
+
* Add an async validator, that can be disposed by the returned subscription
|
|
3672
|
+
* @param form
|
|
3673
|
+
* @param validatorFn the validator or job to execute
|
|
3674
|
+
* @param opts
|
|
3675
|
+
*/
|
|
3676
|
+
SharedAsyncValidators.registerAsyncValidator = function (form, validatorFn, opts) {
|
|
3677
|
+
if (form.asyncValidator)
|
|
3678
|
+
throw Error('Form already have an async validator. Cannot configure job');
|
|
3679
|
+
var debounceTime = toNumber(opts === null || opts === void 0 ? void 0 : opts.debounceTime, 250);
|
|
3680
|
+
var $dispose = new rxjs.Subject();
|
|
3681
|
+
var asyncValidatorFn = SharedAsyncValidators.debounceTime(validatorFn, Object.assign(Object.assign({}, opts), { debounceTime: debounceTime, dispose: $dispose }));
|
|
3682
|
+
form.setAsyncValidators(asyncValidatorFn);
|
|
3683
|
+
var subscription = new rxjs.Subscription();
|
|
3684
|
+
// When unsubscribing, remove async validator
|
|
3685
|
+
subscription.add(function () {
|
|
3686
|
+
// Clear added validator. Must be done NOW (without delay) because generally a new Job is given just after
|
|
3687
|
+
form.clearAsyncValidators();
|
|
3688
|
+
// Stop the job, with a delay to let the last execution finished
|
|
3689
|
+
setTimeout(function () {
|
|
3690
|
+
$dispose.next();
|
|
3691
|
+
$dispose.unsubscribe();
|
|
3692
|
+
}, debounceTime);
|
|
3693
|
+
});
|
|
3694
|
+
return subscription;
|
|
3695
|
+
};
|
|
3696
|
+
return SharedAsyncValidators;
|
|
3697
|
+
}());
|
|
3698
|
+
SharedAsyncValidators.DEBOUNCE_TIME_VALIDATOR_ID = 0;
|
|
3573
3699
|
|
|
3574
3700
|
/**
|
|
3575
3701
|
* Fill a form using a source entity
|
|
@@ -4387,21 +4513,51 @@
|
|
|
4387
4513
|
{ type: FormErrorTranslator },
|
|
4388
4514
|
{ type: i0.ChangeDetectorRef }
|
|
4389
4515
|
]; };
|
|
4390
|
-
var
|
|
4391
|
-
function
|
|
4516
|
+
var FormGetPipe = /** @class */ (function () {
|
|
4517
|
+
function FormGetPipe() {
|
|
4392
4518
|
}
|
|
4393
|
-
|
|
4519
|
+
FormGetPipe.prototype.transform = function (form, path) {
|
|
4394
4520
|
return form.get(path);
|
|
4395
4521
|
};
|
|
4396
|
-
return
|
|
4522
|
+
return FormGetPipe;
|
|
4397
4523
|
}());
|
|
4398
|
-
|
|
4399
|
-
|
|
4524
|
+
FormGetPipe.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function FormGetPipe_Factory() { return new FormGetPipe(); }, token: FormGetPipe, providedIn: "root" });
|
|
4525
|
+
FormGetPipe.decorators = [
|
|
4400
4526
|
{ type: i0.Pipe, args: [{
|
|
4401
4527
|
name: 'formGet'
|
|
4402
4528
|
},] },
|
|
4403
4529
|
{ type: i0.Injectable, args: [{ providedIn: 'root' },] }
|
|
4404
4530
|
];
|
|
4531
|
+
var FormGetControlPipe = /** @class */ (function () {
|
|
4532
|
+
function FormGetControlPipe() {
|
|
4533
|
+
}
|
|
4534
|
+
FormGetControlPipe.prototype.transform = function (form, path) {
|
|
4535
|
+
return form.get(path);
|
|
4536
|
+
};
|
|
4537
|
+
return FormGetControlPipe;
|
|
4538
|
+
}());
|
|
4539
|
+
FormGetControlPipe.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function FormGetControlPipe_Factory() { return new FormGetControlPipe(); }, token: FormGetControlPipe, providedIn: "root" });
|
|
4540
|
+
FormGetControlPipe.decorators = [
|
|
4541
|
+
{ type: i0.Pipe, args: [{
|
|
4542
|
+
name: 'formGetControl'
|
|
4543
|
+
},] },
|
|
4544
|
+
{ type: i0.Injectable, args: [{ providedIn: 'root' },] }
|
|
4545
|
+
];
|
|
4546
|
+
var FormGetArrayPipe = /** @class */ (function () {
|
|
4547
|
+
function FormGetArrayPipe() {
|
|
4548
|
+
}
|
|
4549
|
+
FormGetArrayPipe.prototype.transform = function (form, path) {
|
|
4550
|
+
return form.get(path);
|
|
4551
|
+
};
|
|
4552
|
+
return FormGetArrayPipe;
|
|
4553
|
+
}());
|
|
4554
|
+
FormGetArrayPipe.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function FormGetArrayPipe_Factory() { return new FormGetArrayPipe(); }, token: FormGetArrayPipe, providedIn: "root" });
|
|
4555
|
+
FormGetArrayPipe.decorators = [
|
|
4556
|
+
{ type: i0.Pipe, args: [{
|
|
4557
|
+
name: 'formGetArray'
|
|
4558
|
+
},] },
|
|
4559
|
+
{ type: i0.Injectable, args: [{ providedIn: 'root' },] }
|
|
4560
|
+
];
|
|
4405
4561
|
|
|
4406
4562
|
var SharedPipesModule = /** @class */ (function () {
|
|
4407
4563
|
function SharedPipesModule() {
|
|
@@ -4444,11 +4600,14 @@
|
|
|
4444
4600
|
IsNotNilOrBlankPipe,
|
|
4445
4601
|
ToStringPipe,
|
|
4446
4602
|
StrLengthPipe,
|
|
4603
|
+
StrIncludesPipe,
|
|
4447
4604
|
TranslateContextPipe,
|
|
4448
4605
|
TranslatablePipe,
|
|
4449
4606
|
NgInitDirective,
|
|
4450
4607
|
FormErrorTranslatePipe,
|
|
4451
|
-
|
|
4608
|
+
FormGetPipe,
|
|
4609
|
+
FormGetControlPipe,
|
|
4610
|
+
FormGetArrayPipe
|
|
4452
4611
|
],
|
|
4453
4612
|
exports: [
|
|
4454
4613
|
PropertyGetPipe,
|
|
@@ -4477,13 +4636,16 @@
|
|
|
4477
4636
|
IsNotNilOrBlankPipe,
|
|
4478
4637
|
ToStringPipe,
|
|
4479
4638
|
StrLengthPipe,
|
|
4639
|
+
StrIncludesPipe,
|
|
4480
4640
|
ArrayIncludesPipe,
|
|
4481
4641
|
ArrayFilterPipe,
|
|
4482
4642
|
TranslateContextPipe,
|
|
4483
4643
|
TranslatablePipe,
|
|
4484
4644
|
NgInitDirective,
|
|
4485
4645
|
FormErrorTranslatePipe,
|
|
4486
|
-
|
|
4646
|
+
FormGetPipe,
|
|
4647
|
+
FormGetControlPipe,
|
|
4648
|
+
FormGetArrayPipe
|
|
4487
4649
|
]
|
|
4488
4650
|
},] }
|
|
4489
4651
|
];
|
|
@@ -30766,10 +30928,12 @@
|
|
|
30766
30928
|
exports.FormArrayHelper = FormArrayHelper;
|
|
30767
30929
|
exports.FormButtonsBarComponent = FormButtonsBarComponent;
|
|
30768
30930
|
exports.FormButtonsBarToken = FormButtonsBarToken;
|
|
30769
|
-
exports.FormControlGetPipe = FormControlGetPipe;
|
|
30770
30931
|
exports.FormErrorTranslatePipe = FormErrorTranslatePipe;
|
|
30771
30932
|
exports.FormErrorTranslator = FormErrorTranslator;
|
|
30772
30933
|
exports.FormFieldValuesHolder = FormFieldValuesHolder;
|
|
30934
|
+
exports.FormGetArrayPipe = FormGetArrayPipe;
|
|
30935
|
+
exports.FormGetControlPipe = FormGetControlPipe;
|
|
30936
|
+
exports.FormGetPipe = FormGetPipe;
|
|
30773
30937
|
exports.Fragments = Fragments;
|
|
30774
30938
|
exports.GraphqlService = GraphqlService;
|
|
30775
30939
|
exports.HAMMER_PRESS_TIME = HAMMER_PRESS_TIME;
|
|
@@ -30854,6 +31018,7 @@
|
|
|
30854
31018
|
exports.SPACE_PLACEHOLDER_CHAR = SPACE_PLACEHOLDER_CHAR;
|
|
30855
31019
|
exports.SelectPeerModal = SelectPeerModal;
|
|
30856
31020
|
exports.SettingsPage = SettingsPage;
|
|
31021
|
+
exports.SharedAsyncValidators = SharedAsyncValidators;
|
|
30857
31022
|
exports.SharedDirectivesModule = SharedDirectivesModule;
|
|
30858
31023
|
exports.SharedFormArrayValidators = SharedFormArrayValidators;
|
|
30859
31024
|
exports.SharedFormGroupValidators = SharedFormGroupValidators;
|
|
@@ -30879,6 +31044,7 @@
|
|
|
30879
31044
|
exports.StatusById = StatusById;
|
|
30880
31045
|
exports.StatusIds = StatusIds;
|
|
30881
31046
|
exports.StatusList = StatusList;
|
|
31047
|
+
exports.StrIncludesPipe = StrIncludesPipe;
|
|
30882
31048
|
exports.StrLengthPipe = StrLengthPipe;
|
|
30883
31049
|
exports.SwipeTestPage = SwipeTestPage;
|
|
30884
31050
|
exports.TableSelectColumnsComponent = TableSelectColumnsComponent;
|
|
@@ -30945,6 +31111,7 @@
|
|
|
30945
31111
|
exports.formatLatitude = formatLatitude;
|
|
30946
31112
|
exports.formatLongitude = formatLongitude;
|
|
30947
31113
|
exports.fromDateISOString = fromDateISOString;
|
|
31114
|
+
exports.fromPromise = fromPromise;
|
|
30948
31115
|
exports.fromScrollEndEvent = fromScrollEndEvent;
|
|
30949
31116
|
exports.fromUnixMsTimestamp = fromUnixMsTimestamp;
|
|
30950
31117
|
exports.fromUnixTimestamp = fromUnixTimestamp;
|