@recursyve/nice-data-filter-kit 14.1.6 → 14.2.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.
Files changed (41) hide show
  1. package/esm2020/lib/components/nice-filter-view/store/nice-filter-view.query.mjs +4 -1
  2. package/esm2020/lib/components/nice-filter-view/store/nice-filter-view.service.mjs +4 -18
  3. package/esm2020/lib/components/nice-filter-view/store/nice-filter-view.store.mjs +15 -1
  4. package/esm2020/lib/directive/public-api.mjs +2 -0
  5. package/esm2020/lib/directive/selectable-list/model/load-all-entities-options.model.mjs +2 -0
  6. package/esm2020/lib/directive/selectable-list/model/selectable-list-options.model.mjs +2 -0
  7. package/esm2020/lib/directive/selectable-list/providers/preload-selected-entities.provider.mjs +10 -0
  8. package/esm2020/lib/directive/selectable-list/providers/selectable-list-content.service.mjs +26 -0
  9. package/esm2020/lib/directive/selectable-list/public-api.mjs +10 -0
  10. package/esm2020/lib/directive/selectable-list/selectable-list-checkbox.directive.mjs +122 -0
  11. package/esm2020/lib/directive/selectable-list/selectable-list-select-all.directive.mjs +48 -0
  12. package/esm2020/lib/directive/selectable-list/selectable-list.constant.mjs +3 -0
  13. package/esm2020/lib/directive/selectable-list/selectable-list.directive.mjs +48 -0
  14. package/esm2020/lib/directive/selectable-list/selectable-list.module.mjs +32 -0
  15. package/esm2020/lib/directive/selectable-list/store/selectable-list-state.service.mjs +181 -0
  16. package/esm2020/lib/directive/selectable-list/store/selectable-list.service.mjs +49 -0
  17. package/esm2020/lib/directive/selectable-list/store/selectable-list.state.mjs +2 -0
  18. package/esm2020/public-api.mjs +2 -1
  19. package/fesm2015/recursyve-nice-data-filter-kit.mjs +525 -17
  20. package/fesm2015/recursyve-nice-data-filter-kit.mjs.map +1 -1
  21. package/fesm2020/recursyve-nice-data-filter-kit.mjs +500 -20
  22. package/fesm2020/recursyve-nice-data-filter-kit.mjs.map +1 -1
  23. package/lib/components/nice-filter-view/store/nice-filter-view.query.d.ts +1 -0
  24. package/lib/components/nice-filter-view/store/nice-filter-view.service.d.ts +0 -1
  25. package/lib/components/nice-filter-view/store/nice-filter-view.store.d.ts +1 -0
  26. package/lib/directive/public-api.d.ts +1 -0
  27. package/lib/directive/selectable-list/model/load-all-entities-options.model.d.ts +4 -0
  28. package/lib/directive/selectable-list/model/selectable-list-options.model.d.ts +4 -0
  29. package/lib/directive/selectable-list/providers/preload-selected-entities.provider.d.ts +12 -0
  30. package/lib/directive/selectable-list/providers/selectable-list-content.service.d.ts +13 -0
  31. package/lib/directive/selectable-list/public-api.d.ts +9 -0
  32. package/lib/directive/selectable-list/selectable-list-checkbox.directive.d.ts +24 -0
  33. package/lib/directive/selectable-list/selectable-list-select-all.directive.d.ts +18 -0
  34. package/lib/directive/selectable-list/selectable-list.constant.d.ts +2 -0
  35. package/lib/directive/selectable-list/selectable-list.directive.d.ts +18 -0
  36. package/lib/directive/selectable-list/selectable-list.module.d.ts +12 -0
  37. package/lib/directive/selectable-list/store/selectable-list-state.service.d.ts +32 -0
  38. package/lib/directive/selectable-list/store/selectable-list.service.d.ts +23 -0
  39. package/lib/directive/selectable-list/store/selectable-list.state.d.ts +8 -0
  40. package/package.json +1 -1
  41. package/public-api.d.ts +1 -0
@@ -4,8 +4,8 @@ import { HttpParams } from '@angular/common/http';
4
4
  import * as i5$1 from '@recursyve/nice-ui-kit.v2';
5
5
  import { isNullOrUndefined, ObjectUtils, FileUtils, ArrayUtils, ExportBottomSheetComponent, NiceLoadingSpinnerModule, NiceTypeaheadModule, NiceExportBottomSheetModule } from '@recursyve/nice-ui-kit.v2';
6
6
  import * as i0 from '@angular/core';
7
- import { Directive, Input, NgModule, Injectable, Inject, InjectionToken, Optional, Pipe, EventEmitter, Component, ViewEncapsulation, ChangeDetectionStrategy, Output, HostListener, forwardRef, TemplateRef, ContentChild, ContentChildren, ViewChild } from '@angular/core';
8
- import { Store, StoreConfig, Query, arrayAdd, arrayUpsert, arrayRemove, EntityStore, QueryEntity } from '@datorama/akita';
7
+ import { Directive, Input, NgModule, Injectable, Inject, InjectionToken, Optional, Pipe, EventEmitter, Component, ViewEncapsulation, ChangeDetectionStrategy, Output, HostListener, forwardRef, TemplateRef, ContentChild, ContentChildren, ViewChild, QueryList } from '@angular/core';
8
+ import { Store, StoreConfig, Query, arrayAdd, arrayUpsert, arrayRemove, EntityStore, QueryEntity, EntityActions } from '@datorama/akita';
9
9
  import { combineLatest, Subject, firstValueFrom, of, tap } from 'rxjs';
10
10
  import { __decorate, __metadata, __awaiter, __rest } from 'tslib';
11
11
  import * as i2 from '@angular/router';
@@ -55,6 +55,7 @@ import * as i1$2 from '@ngx-translate/core';
55
55
  import { TranslateModule } from '@ngx-translate/core';
56
56
  import * as i18 from '@angular/material/badge';
57
57
  import { MatBadgeModule } from '@angular/material/badge';
58
+ import * as i1$4 from '@angular/material/checkbox';
58
59
 
59
60
  class QueryParamsUtils {
60
61
  static hasFilterParameters(params) {
@@ -2846,6 +2847,17 @@ class NiceFilterViewStore extends EntityStore {
2846
2847
  });
2847
2848
  this.remove(value[idKey]);
2848
2849
  }
2850
+ getParameters(filterParameters) {
2851
+ const { baseRules } = this.getValue();
2852
+ const parameters = Object.assign(Object.assign({}, filterParameters), { rules: (filterParameters === null || filterParameters === void 0 ? void 0 : filterParameters.rules) ? [...filterParameters.rules] : [] });
2853
+ if (baseRules === null || baseRules === void 0 ? void 0 : baseRules.length) {
2854
+ parameters.rules.push({
2855
+ condition: "and",
2856
+ rules: baseRules
2857
+ });
2858
+ }
2859
+ return parameters;
2860
+ }
2849
2861
  }
2850
2862
  NiceFilterViewStore.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceFilterViewStore, deps: [{ token: FILTER_VIEW_STATE }, { token: FILTER_VIEW_STORE }], target: i0.ɵɵFactoryTarget.Injectable });
2851
2863
  NiceFilterViewStore.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceFilterViewStore });
@@ -2878,6 +2890,9 @@ class NiceFilterViewQuery extends QueryEntity {
2878
2890
  selectFilterResult() {
2879
2891
  return this.select("filterResult");
2880
2892
  }
2893
+ getParameters() {
2894
+ return this.store.getParameters(this.store.getValue().filterParameters);
2895
+ }
2881
2896
  }
2882
2897
  NiceFilterViewQuery.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceFilterViewQuery, deps: [{ token: NiceFilterViewStore }], target: i0.ɵɵFactoryTarget.Injectable });
2883
2898
  NiceFilterViewQuery.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceFilterViewQuery });
@@ -2953,7 +2968,7 @@ class NiceFilterViewService {
2953
2968
  }
2954
2969
  try {
2955
2970
  this.store.setLoading(true);
2956
- const result = yield firstValueFrom(this.filterService.filter(this.getParameters(filterParameters)));
2971
+ const result = yield firstValueFrom(this.filterService.filter(this.store.getParameters(filterParameters)));
2957
2972
  this.store.setResult(result);
2958
2973
  }
2959
2974
  catch (e) {
@@ -2972,7 +2987,7 @@ class NiceFilterViewService {
2972
2987
  }
2973
2988
  try {
2974
2989
  this.store.setLoading(true);
2975
- const result = yield firstValueFrom(this.filterService.getFile(type, this.getParameters(filterParameters)));
2990
+ const result = yield firstValueFrom(this.filterService.getFile(type, this.store.getParameters(filterParameters)));
2976
2991
  FileUtils.downloadFile(`${downloadFileName}.${type}`, result);
2977
2992
  }
2978
2993
  catch (e) {
@@ -2991,7 +3006,7 @@ class NiceFilterViewService {
2991
3006
  }
2992
3007
  try {
2993
3008
  this.store.setLoading(true);
2994
- const result = yield firstValueFrom(this.filterService.getPrintableHtml(this.getParameters(filterParameters)));
3009
+ const result = yield firstValueFrom(this.filterService.getPrintableHtml(this.store.getParameters(filterParameters)));
2995
3010
  FileUtils.openPrintableWindow(result);
2996
3011
  }
2997
3012
  catch (e) {
@@ -3103,17 +3118,6 @@ class NiceFilterViewService {
3103
3118
  });
3104
3119
  }
3105
3120
  }
3106
- getParameters(filterParameters) {
3107
- const { baseRules } = this.store.getValue();
3108
- const parameters = Object.assign(Object.assign({}, filterParameters), { rules: (filterParameters === null || filterParameters === void 0 ? void 0 : filterParameters.rules) ? [...filterParameters.rules] : [] });
3109
- if (baseRules === null || baseRules === void 0 ? void 0 : baseRules.length) {
3110
- parameters.rules.push({
3111
- condition: "and",
3112
- rules: baseRules
3113
- });
3114
- }
3115
- return parameters;
3116
- }
3117
3121
  }
3118
3122
  NiceFilterViewService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceFilterViewService, deps: [{ token: NiceFilterViewStore }, { token: NiceFilterService }], target: i0.ɵɵFactoryTarget.Injectable });
3119
3123
  NiceFilterViewService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceFilterViewService });
@@ -3684,6 +3688,510 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.3", ngImpor
3684
3688
  }]
3685
3689
  }] });
3686
3690
 
3691
+ class NicePreloadSelectedEntitiesProvider {
3692
+ }
3693
+ NicePreloadSelectedEntitiesProvider.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NicePreloadSelectedEntitiesProvider, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
3694
+ NicePreloadSelectedEntitiesProvider.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NicePreloadSelectedEntitiesProvider });
3695
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NicePreloadSelectedEntitiesProvider, decorators: [{
3696
+ type: Injectable
3697
+ }] });
3698
+
3699
+ const NICE_PRELOAD_SELECTED_ENTITIES_PROVIDER = new InjectionToken("nice_preload_selected_entities_provider");
3700
+
3701
+ class SelectableListStateService {
3702
+ constructor(store, preloadService, options) {
3703
+ this.store = store;
3704
+ this.preloadService = preloadService;
3705
+ this.options = options;
3706
+ }
3707
+ get idKey() {
3708
+ var _a, _b;
3709
+ return (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.idKey) !== null && _b !== void 0 ? _b : "id";
3710
+ }
3711
+ get preloadedWindow() {
3712
+ var _a, _b;
3713
+ return (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.preloadWindow) !== null && _b !== void 0 ? _b : 2;
3714
+ }
3715
+ setActive(entity) {
3716
+ this.store.setActive(entity[this.idKey]);
3717
+ }
3718
+ getIndex(identifier) {
3719
+ const { ids } = this.store.getValue();
3720
+ const index = ids.indexOf(identifier);
3721
+ return index + 1;
3722
+ }
3723
+ selectAll(options) {
3724
+ return __awaiter(this, void 0, void 0, function* () {
3725
+ if (!this.preloadService) {
3726
+ return this.store.update({
3727
+ allSelected: true
3728
+ });
3729
+ }
3730
+ const ids = yield this.preloadService.loadAllEntities(options);
3731
+ this.store.set(ids.map((id) => ({
3732
+ [this.idKey]: id,
3733
+ loaded: false
3734
+ })));
3735
+ return this.store.update({
3736
+ allSelected: true
3737
+ });
3738
+ });
3739
+ }
3740
+ select(id) {
3741
+ return __awaiter(this, void 0, void 0, function* () {
3742
+ this.store.update((state) => ({
3743
+ unselectedEntity: arrayRemove(state.unselectedEntity, id)
3744
+ }));
3745
+ if (!this.preloadService) {
3746
+ this.store.add({
3747
+ [this.idKey]: id,
3748
+ loaded: false
3749
+ });
3750
+ }
3751
+ const entity = yield this.preloadService.loadEntityById(id);
3752
+ return this.store.add(Object.assign(Object.assign({}, entity), { loaded: true }));
3753
+ });
3754
+ }
3755
+ selectEntity(entity) {
3756
+ return __awaiter(this, void 0, void 0, function* () {
3757
+ this.store.update((state) => ({
3758
+ unselectedEntity: arrayRemove(state.unselectedEntity, entity[this.idKey])
3759
+ }));
3760
+ if (!this.preloadService) {
3761
+ return this.store.upsert(entity[this.idKey], Object.assign(Object.assign({}, entity), { loaded: true }));
3762
+ }
3763
+ const preloadedEntity = yield this.preloadService.reloadEntity(entity);
3764
+ return this.store.upsert(preloadedEntity[this.idKey], Object.assign(Object.assign({}, preloadedEntity), { loaded: true }));
3765
+ });
3766
+ }
3767
+ selectManyEntities(entities) {
3768
+ return __awaiter(this, void 0, void 0, function* () {
3769
+ if (!this.preloadService) {
3770
+ return this.store.upsertMany(entities.map((entity) => (Object.assign(Object.assign({}, entity), { loaded: true }))));
3771
+ }
3772
+ const preloadedEntities = yield this.preloadService.reloadEntities(entities);
3773
+ return this.store.upsertMany(preloadedEntities.map((preloadedEntity) => (Object.assign(Object.assign({}, preloadedEntity), { loaded: true }))));
3774
+ });
3775
+ }
3776
+ unselectAll() {
3777
+ this.store.set([]);
3778
+ return this.store.update({
3779
+ allSelected: false,
3780
+ unselectedEntity: []
3781
+ });
3782
+ }
3783
+ unselect(id) {
3784
+ this.store.update((state) => ({
3785
+ unselectedEntity: arrayAdd(state.unselectedEntity, id)
3786
+ }));
3787
+ this.store.remove(id);
3788
+ }
3789
+ unselectEntity(entity) {
3790
+ this.store.update((state) => ({
3791
+ unselectedEntity: arrayAdd(state.unselectedEntity, entity[this.idKey])
3792
+ }));
3793
+ this.store.remove(entity[this.idKey]);
3794
+ }
3795
+ unselectManyEntities(entities) {
3796
+ this.store.remove(entities.map((entity) => entity[this.idKey]));
3797
+ }
3798
+ setEntities(ids, activeId) {
3799
+ return __awaiter(this, void 0, void 0, function* () {
3800
+ this.store.update({
3801
+ unselectedEntity: [],
3802
+ allSelected: false
3803
+ });
3804
+ this.store.set(ids.map((id) => ({
3805
+ [this.idKey]: id,
3806
+ loaded: false
3807
+ })));
3808
+ if (activeId) {
3809
+ this.store.setActive(activeId);
3810
+ }
3811
+ });
3812
+ }
3813
+ next() {
3814
+ return __awaiter(this, void 0, void 0, function* () {
3815
+ const { ids, active } = this.store.getValue();
3816
+ const index = ids.indexOf(active);
3817
+ yield this.loadActiveEntity(ids[index + 1], 1);
3818
+ });
3819
+ }
3820
+ previous() {
3821
+ return __awaiter(this, void 0, void 0, function* () {
3822
+ const { ids, active } = this.store.getValue();
3823
+ const index = ids.indexOf(active);
3824
+ yield this.loadActiveEntity(ids[index - 1], -1);
3825
+ });
3826
+ }
3827
+ first() {
3828
+ return __awaiter(this, void 0, void 0, function* () {
3829
+ const { ids } = this.store.getValue();
3830
+ yield this.loadActiveEntity(ids[0], 1);
3831
+ });
3832
+ }
3833
+ last() {
3834
+ return __awaiter(this, void 0, void 0, function* () {
3835
+ const { ids } = this.store.getValue();
3836
+ yield this.loadActiveEntity(ids[ids.length - 1], -1);
3837
+ });
3838
+ }
3839
+ removeActive() {
3840
+ return __awaiter(this, void 0, void 0, function* () {
3841
+ const { active, ids } = this.store.getValue();
3842
+ const index = ids.indexOf(active);
3843
+ this.store.remove(active);
3844
+ if (index === (ids.length - 1)) {
3845
+ yield this.loadActiveEntity(ids[index - 1], -1);
3846
+ }
3847
+ else {
3848
+ yield this.loadActiveEntity(ids[index + 1], 1);
3849
+ }
3850
+ });
3851
+ }
3852
+ loadActiveEntity(id, direction) {
3853
+ var _a;
3854
+ return __awaiter(this, void 0, void 0, function* () {
3855
+ try {
3856
+ this.store.setActive(id);
3857
+ const { entities } = this.store.getValue();
3858
+ if (!((_a = entities[+id + direction * this.preloadedWindow]) === null || _a === void 0 ? void 0 : _a.loaded)) {
3859
+ yield this.loadEntities(false);
3860
+ }
3861
+ }
3862
+ catch (e) {
3863
+ this.store.setError(e);
3864
+ }
3865
+ });
3866
+ }
3867
+ loadEntities(loadExtremity) {
3868
+ return __awaiter(this, void 0, void 0, function* () {
3869
+ if (!this.preloadService) {
3870
+ return;
3871
+ }
3872
+ const toLoad = this.getListIdToLoad(loadExtremity);
3873
+ if (!toLoad.length) {
3874
+ return;
3875
+ }
3876
+ const entities = yield this.preloadService.loadEntitiesById(toLoad);
3877
+ this.store.upsertMany(entities.map((entity) => (Object.assign(Object.assign({}, entity), { loaded: true }))));
3878
+ });
3879
+ }
3880
+ getListIdToLoad(loadExtremity) {
3881
+ var _a;
3882
+ const { active, ids, entities } = this.store.getValue();
3883
+ const from = ids.indexOf(active) - this.preloadedWindow > 0 ? ids.indexOf(active) - this.preloadedWindow : 0;
3884
+ const to = ids.indexOf(active) + this.preloadedWindow < ids.length - 1
3885
+ ? ids.indexOf(active) + this.preloadedWindow
3886
+ : ids.length - 1;
3887
+ const toLoad = [];
3888
+ if (loadExtremity) {
3889
+ if (ids.length <= 2) {
3890
+ return ids;
3891
+ }
3892
+ toLoad.push(ids[0], ids[ids.length - 1]);
3893
+ }
3894
+ for (let i = from; i <= to; i++) {
3895
+ if (ids[i] === null || ids[0] === undefined) {
3896
+ continue;
3897
+ }
3898
+ if (!toLoad.includes(ids[i]) && !((_a = entities[ids[i]]) === null || _a === void 0 ? void 0 : _a.loaded)) {
3899
+ toLoad.push(ids[i]);
3900
+ }
3901
+ }
3902
+ return toLoad;
3903
+ }
3904
+ }
3905
+
3906
+ class SelectableListService {
3907
+ constructor(providers) {
3908
+ this.providers = providers;
3909
+ this.stores = new Map();
3910
+ }
3911
+ createState(name, options) {
3912
+ const store = new EntityStore({ allSelected: false, unselectedEntity: [] }, { name, idKey: options === null || options === void 0 ? void 0 : options.idKey });
3913
+ const query = new QueryEntity(store);
3914
+ const state = { store, query };
3915
+ this.stores.set(name, state);
3916
+ return state;
3917
+ }
3918
+ getState(name) {
3919
+ return this.stores.get(name);
3920
+ }
3921
+ withState(stateName, options) {
3922
+ var _a;
3923
+ const provider = (_a = this.providers) === null || _a === void 0 ? void 0 : _a.find((p) => p.state === stateName);
3924
+ const state = this.getState(stateName);
3925
+ if (state) {
3926
+ return new SelectableListStateService(state.store, provider, options);
3927
+ }
3928
+ const newState = this.createState(stateName, options);
3929
+ return new SelectableListStateService(newState.store, provider, options);
3930
+ }
3931
+ query(stateName) {
3932
+ const state = this.getState(stateName);
3933
+ if (!state) {
3934
+ throw new Error("No state found");
3935
+ }
3936
+ return state.query;
3937
+ }
3938
+ }
3939
+ SelectableListService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: SelectableListService, deps: [{ token: NICE_PRELOAD_SELECTED_ENTITIES_PROVIDER, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
3940
+ SelectableListService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: SelectableListService, providedIn: "root" });
3941
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: SelectableListService, decorators: [{
3942
+ type: Injectable,
3943
+ args: [{ providedIn: "root" }]
3944
+ }], ctorParameters: function () {
3945
+ return [{ type: undefined, decorators: [{
3946
+ type: Optional
3947
+ }, {
3948
+ type: Inject,
3949
+ args: [NICE_PRELOAD_SELECTED_ENTITIES_PROVIDER]
3950
+ }] }];
3951
+ } });
3952
+
3953
+ class SelectableListContentService {
3954
+ constructor() {
3955
+ this._state = null;
3956
+ this._checkboxes = new QueryList();
3957
+ }
3958
+ get state() {
3959
+ return this._state;
3960
+ }
3961
+ get checkboxes() {
3962
+ return this._checkboxes;
3963
+ }
3964
+ setState(state) {
3965
+ this._state = state;
3966
+ }
3967
+ setCheckboxes(checkboxes) {
3968
+ this._checkboxes = checkboxes;
3969
+ }
3970
+ }
3971
+ SelectableListContentService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: SelectableListContentService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
3972
+ SelectableListContentService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: SelectableListContentService });
3973
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: SelectableListContentService, decorators: [{
3974
+ type: Injectable
3975
+ }] });
3976
+
3977
+ // tslint:disable-next-line:directive-class-suffix
3978
+ class NiceSelectableListCheckboxDirective {
3979
+ constructor(checkbox, service, selectableListService) {
3980
+ this.checkbox = checkbox;
3981
+ this.service = service;
3982
+ this.selectableListService = selectableListService;
3983
+ this.unsubscribeAll$ = new Subject();
3984
+ }
3985
+ get currentId() {
3986
+ if (!this.selectableEntity || !this.selectableListStateService) {
3987
+ return null;
3988
+ }
3989
+ return this.selectableEntity[this.selectableListStateService.idKey];
3990
+ }
3991
+ ngOnInit() {
3992
+ this.selectableListStateService = this.selectableListService.withState(this.service.state);
3993
+ this.selectableListStateQuery = this.selectableListService.query(this.service.state);
3994
+ if (this.selectableEntity) {
3995
+ this.handleSelectableEntity();
3996
+ }
3997
+ if (this.selectPage) {
3998
+ this.handleSelectPage();
3999
+ }
4000
+ }
4001
+ ngOnDestroy() {
4002
+ this.unsubscribeAll$.next();
4003
+ this.unsubscribeAll$.complete();
4004
+ }
4005
+ handleSelectableEntity() {
4006
+ if (this.checkbox.checked) {
4007
+ this.selectableListStateService.selectEntity(this.selectableEntity);
4008
+ }
4009
+ if (!this.checkbox.checked && this.selectableListStateQuery.getEntity(this.currentId)) {
4010
+ this.checkbox.checked = true;
4011
+ }
4012
+ this.checkbox.change.pipe(takeUntil(this.unsubscribeAll$)).subscribe((value) => {
4013
+ if (value.checked && !this.selectableListStateQuery.getEntity(this.currentId)) {
4014
+ this.selectableListStateService.selectEntity(this.selectableEntity);
4015
+ }
4016
+ if (!value.checked && this.selectableListStateQuery.getEntity(this.currentId)) {
4017
+ this.selectableListStateService.unselectEntity(this.selectableEntity);
4018
+ }
4019
+ });
4020
+ this.selectableListStateQuery.selectEntityAction([
4021
+ EntityActions.Add,
4022
+ EntityActions.Remove,
4023
+ EntityActions.Set
4024
+ ]).pipe(takeUntil(this.unsubscribeAll$)).subscribe(({ ids, type }) => {
4025
+ const shouldTakeAction = ids.includes(this.currentId);
4026
+ if (!shouldTakeAction) {
4027
+ if (type === EntityActions.Set) {
4028
+ this.checkbox.checked = false;
4029
+ }
4030
+ return;
4031
+ }
4032
+ if (!this.checkbox.checked && (type === EntityActions.Add || type === EntityActions.Set)) {
4033
+ this.checkbox.checked = true;
4034
+ }
4035
+ if (this.checkbox.checked && type === EntityActions.Remove) {
4036
+ this.checkbox.checked = false;
4037
+ }
4038
+ });
4039
+ }
4040
+ handleSelectPage() {
4041
+ this.selectableListStateQuery.selectCount().subscribe(() => this.updateCheckboxState());
4042
+ this.service.checkboxes.changes.pipe(takeUntil(this.unsubscribeAll$)).subscribe(() => this.updateCheckboxState());
4043
+ this.checkbox.change.pipe(takeUntil(this.unsubscribeAll$)).subscribe((value) => {
4044
+ for (const checkbox of this.service.checkboxes) {
4045
+ if (checkbox.selectPage) {
4046
+ continue;
4047
+ }
4048
+ checkbox.checkbox.checked = value.checked;
4049
+ checkbox.checkbox.change.emit({ checked: value.checked, source: checkbox.checkbox });
4050
+ }
4051
+ });
4052
+ }
4053
+ updateCheckboxState() {
4054
+ const checkboxes = this.service.checkboxes.filter((checkbox) => !checkbox.selectPage);
4055
+ if (!checkboxes.length) {
4056
+ return;
4057
+ }
4058
+ const count = this.selectableListStateQuery.getCount();
4059
+ if (!count) {
4060
+ this.checkbox.indeterminate = false;
4061
+ this.checkbox.checked = false;
4062
+ return;
4063
+ }
4064
+ if (count !== checkboxes.length) {
4065
+ this.checkbox.indeterminate = true;
4066
+ this.checkbox.checked = false;
4067
+ return;
4068
+ }
4069
+ if (count === checkboxes.length) {
4070
+ this.checkbox.checked = true;
4071
+ this.checkbox.indeterminate = false;
4072
+ }
4073
+ }
4074
+ }
4075
+ NiceSelectableListCheckboxDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceSelectableListCheckboxDirective, deps: [{ token: i1$4.MatCheckbox }, { token: SelectableListContentService }, { token: SelectableListService }], target: i0.ɵɵFactoryTarget.Directive });
4076
+ NiceSelectableListCheckboxDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.3", type: NiceSelectableListCheckboxDirective, selector: "mat-checkbox[niceSelectableListCheckbox]", inputs: { selectableEntity: "selectableEntity", selectPage: "selectPage" }, ngImport: i0 });
4077
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceSelectableListCheckboxDirective, decorators: [{
4078
+ type: Directive,
4079
+ args: [{
4080
+ selector: "mat-checkbox[niceSelectableListCheckbox]"
4081
+ }]
4082
+ }], ctorParameters: function () { return [{ type: i1$4.MatCheckbox }, { type: SelectableListContentService }, { type: SelectableListService }]; }, propDecorators: { selectableEntity: [{
4083
+ type: Input
4084
+ }], selectPage: [{
4085
+ type: Input
4086
+ }] } });
4087
+
4088
+ // tslint:disable-next-line:directive-class-suffix
4089
+ class NiceSelectableListSelectAllDirective {
4090
+ constructor(niceFilterViewQuery, service, selectableListService) {
4091
+ this.niceFilterViewQuery = niceFilterViewQuery;
4092
+ this.service = service;
4093
+ this.selectableListService = selectableListService;
4094
+ this.action = "select";
4095
+ }
4096
+ ngOnInit() {
4097
+ this.selectableListStateService = this.selectableListService.withState(this.service.state);
4098
+ this.selectableListStateQuery = this.selectableListService.query(this.service.state);
4099
+ }
4100
+ onClick() {
4101
+ var _a, _b;
4102
+ if (this.action === "select") {
4103
+ const filterParameters = (_b = (_a = this.niceFilterViewQuery) === null || _a === void 0 ? void 0 : _a.getParameters()) !== null && _b !== void 0 ? _b : {};
4104
+ const query = filterParameters ? FilterUtils.parametersToRequest(filterParameters) : null;
4105
+ this.selectableListStateService.selectAll({ query });
4106
+ }
4107
+ else {
4108
+ this.selectableListStateService.unselectAll();
4109
+ }
4110
+ }
4111
+ }
4112
+ NiceSelectableListSelectAllDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceSelectableListSelectAllDirective, deps: [{ token: NiceFilterViewQuery, optional: true }, { token: SelectableListContentService }, { token: SelectableListService }], target: i0.ɵɵFactoryTarget.Directive });
4113
+ NiceSelectableListSelectAllDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.3", type: NiceSelectableListSelectAllDirective, selector: "button[niceSelectableListSelectAll]", inputs: { action: "action" }, host: { listeners: { "click": "onClick()" } }, ngImport: i0 });
4114
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceSelectableListSelectAllDirective, decorators: [{
4115
+ type: Directive,
4116
+ args: [{
4117
+ selector: "button[niceSelectableListSelectAll]"
4118
+ }]
4119
+ }], ctorParameters: function () {
4120
+ return [{ type: NiceFilterViewQuery, decorators: [{
4121
+ type: Optional
4122
+ }] }, { type: SelectableListContentService }, { type: SelectableListService }];
4123
+ }, propDecorators: { action: [{
4124
+ type: Input
4125
+ }], onClick: [{
4126
+ type: HostListener,
4127
+ args: ["click"]
4128
+ }] } });
4129
+
4130
+ // tslint:disable-next-line:directive-class-suffix
4131
+ class NiceSelectableListDirective {
4132
+ constructor(service) {
4133
+ this.service = service;
4134
+ this.defaultOptions = { idKey: "id", preloadWindow: 2 };
4135
+ }
4136
+ ngOnInit() {
4137
+ if (!this.options) {
4138
+ this.options = Object.assign({}, this.defaultOptions);
4139
+ }
4140
+ }
4141
+ ngOnChanges(changes) {
4142
+ if ("options" in changes) {
4143
+ this.options = Object.assign(Object.assign({}, this.defaultOptions), changes.options.currentValue);
4144
+ }
4145
+ if ("state" in changes) {
4146
+ this.service.setState(this.state);
4147
+ }
4148
+ }
4149
+ ngAfterContentInit() {
4150
+ this.service.setCheckboxes(this.checkboxes);
4151
+ }
4152
+ }
4153
+ NiceSelectableListDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceSelectableListDirective, deps: [{ token: SelectableListContentService }], target: i0.ɵɵFactoryTarget.Directive });
4154
+ NiceSelectableListDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.3", type: NiceSelectableListDirective, selector: "[niceSelectableList]", inputs: { state: "state", options: "options" }, providers: [SelectableListContentService], queries: [{ propertyName: "checkboxes", predicate: NiceSelectableListCheckboxDirective, descendants: true }], usesOnChanges: true, ngImport: i0 });
4155
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceSelectableListDirective, decorators: [{
4156
+ type: Directive,
4157
+ args: [{
4158
+ selector: "[niceSelectableList]",
4159
+ providers: [SelectableListContentService]
4160
+ }]
4161
+ }], ctorParameters: function () { return [{ type: SelectableListContentService }]; }, propDecorators: { state: [{
4162
+ type: Input
4163
+ }], options: [{
4164
+ type: Input
4165
+ }], checkboxes: [{
4166
+ type: ContentChildren,
4167
+ args: [NiceSelectableListCheckboxDirective, { descendants: true }]
4168
+ }] } });
4169
+
4170
+ class NiceSelectableListModule {
4171
+ static register(...providers) {
4172
+ return {
4173
+ ngModule: NiceSelectableListModule,
4174
+ providers: providers.map(x => ({
4175
+ provide: NICE_PRELOAD_SELECTED_ENTITIES_PROVIDER,
4176
+ useClass: x,
4177
+ multi: true
4178
+ }))
4179
+ };
4180
+ }
4181
+ }
4182
+ NiceSelectableListModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceSelectableListModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
4183
+ NiceSelectableListModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.3", ngImport: i0, type: NiceSelectableListModule, declarations: [NiceSelectableListDirective, NiceSelectableListCheckboxDirective, NiceSelectableListSelectAllDirective], exports: [NiceSelectableListDirective, NiceSelectableListCheckboxDirective, NiceSelectableListSelectAllDirective] });
4184
+ NiceSelectableListModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceSelectableListModule, providers: [SelectableListService] });
4185
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceSelectableListModule, decorators: [{
4186
+ type: NgModule,
4187
+ args: [{
4188
+ imports: [],
4189
+ declarations: [NiceSelectableListDirective, NiceSelectableListCheckboxDirective, NiceSelectableListSelectAllDirective],
4190
+ providers: [SelectableListService],
4191
+ exports: [NiceSelectableListDirective, NiceSelectableListCheckboxDirective, NiceSelectableListSelectAllDirective]
4192
+ }]
4193
+ }] });
4194
+
3687
4195
  class StringUtils {
3688
4196
  }
3689
4197
  // tslint:disable-next-line:max-line-length
@@ -3700,5 +4208,5 @@ String.prototype.toTableColumn = function (sortableOrOptions, nullLast) {
3700
4208
  * Generated bundle index. Do not edit.
3701
4209
  */
3702
4210
 
3703
- export { DateFilterComponent, FilterComponent, FilterGroupIconPipe, FilterOperatorTypes, FilterSelectionComponent, FilterType, FilterUtils, LayoutContent, NiceBaseFilterViewComponent, NiceBaseListButtonsDirective, NiceBaseListCardsDirective, NiceBaseListComponent, NiceBaseListCustomContentDirective, NiceBaseListDirectiveModule, NiceBaseListEmptySearchResultStateDirective, NiceBaseListEmptyStateDirective, NiceBaseListFiltersDirective, NiceBaseListModule, NiceBaseListQuery, NiceBaseListService, NiceBaseListStore, NiceBaseListTableDirective, NiceBaseListTitleDirective, NiceCustomDateAdapter, NiceFilterApi, NiceFilterCustomDataViewComponent, NiceFilterDataDirective, NiceFilterExportButtonsComponent, NiceFilterExportDirective, NiceFilterGroupService, NiceFilterInfiniteScrollDataViewComponent, NiceFilterMatPaginatorPaginationDirective, NiceFilterMatSortSortingDirective, NiceFilterMatTableViewDirective, NiceFilterQueryParamsDirective, NiceFilterSearchComponent, NiceFilterService, NiceFilterViewComponent, NiceFilterViewModule, NiceFilterViewQuery, NiceFilterViewService, NiceListState, NiceMultiStateFilterService, NiceMultiStateListComponent, NiceMultiStateListModule, NiceMultiStateListQuery, NiceMultiStateListService, NiceMultiStateListStore, NiceQueryBuilderComponent, NiceQueryBuilderModule, NiceSavedReportService, NumberFilterComponent, OrderUtils, QBFilterUtils, QueryBuilderTriggerDirective, RadioFilterComponent, RuleComponent, SelectFilterComponent, StringUtils, TableColumns, TextFilterComponent, defaultLayout, initialBaseListState, initialValue$1 as initialValue, mixinNiceFilterApi };
4211
+ export { DateFilterComponent, FilterComponent, FilterGroupIconPipe, FilterOperatorTypes, FilterSelectionComponent, FilterType, FilterUtils, LayoutContent, NiceBaseFilterViewComponent, NiceBaseListButtonsDirective, NiceBaseListCardsDirective, NiceBaseListComponent, NiceBaseListCustomContentDirective, NiceBaseListDirectiveModule, NiceBaseListEmptySearchResultStateDirective, NiceBaseListEmptyStateDirective, NiceBaseListFiltersDirective, NiceBaseListModule, NiceBaseListQuery, NiceBaseListService, NiceBaseListStore, NiceBaseListTableDirective, NiceBaseListTitleDirective, NiceCustomDateAdapter, NiceFilterApi, NiceFilterCustomDataViewComponent, NiceFilterDataDirective, NiceFilterExportButtonsComponent, NiceFilterExportDirective, NiceFilterGroupService, NiceFilterInfiniteScrollDataViewComponent, NiceFilterMatPaginatorPaginationDirective, NiceFilterMatSortSortingDirective, NiceFilterMatTableViewDirective, NiceFilterQueryParamsDirective, NiceFilterSearchComponent, NiceFilterService, NiceFilterViewComponent, NiceFilterViewModule, NiceFilterViewQuery, NiceFilterViewService, NiceListState, NiceMultiStateFilterService, NiceMultiStateListComponent, NiceMultiStateListModule, NiceMultiStateListQuery, NiceMultiStateListService, NiceMultiStateListStore, NicePreloadSelectedEntitiesProvider, NiceQueryBuilderComponent, NiceQueryBuilderModule, NiceSavedReportService, NiceSelectableListCheckboxDirective, NiceSelectableListDirective, NiceSelectableListModule, NiceSelectableListSelectAllDirective, NumberFilterComponent, OrderUtils, QBFilterUtils, QueryBuilderTriggerDirective, RadioFilterComponent, RuleComponent, SelectFilterComponent, SelectableListService, SelectableListStateService, StringUtils, TableColumns, TextFilterComponent, defaultLayout, initialBaseListState, initialValue$1 as initialValue, mixinNiceFilterApi };
3704
4212
  //# sourceMappingURL=recursyve-nice-data-filter-kit.mjs.map