@wlcm/angular 17.7.15 → 17.7.17
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/filters/esm2022/index.mjs +6 -8
- package/filters/esm2022/lib/components/filters-group/filters-group.component.mjs +13 -0
- package/filters/esm2022/lib/constants/filter.constants.mjs +3 -0
- package/filters/esm2022/lib/constants/index.mjs +2 -0
- package/filters/esm2022/lib/directives/filter.directive.mjs +11 -0
- package/filters/esm2022/lib/directives/index.mjs +2 -0
- package/filters/esm2022/lib/filters.module.mjs +20 -0
- package/filters/esm2022/lib/models/array-filter.models.mjs +73 -0
- package/filters/esm2022/lib/models/filter.models.mjs +41 -0
- package/filters/esm2022/lib/models/filters-group.models.mjs +60 -0
- package/filters/esm2022/lib/models/index.mjs +4 -0
- package/filters/fesm2022/wlcm-angular-filters.mjs +159 -420
- package/filters/fesm2022/wlcm-angular-filters.mjs.map +1 -1
- package/filters/index.d.ts +5 -7
- package/filters/lib/components/filters-group/filters-group.component.d.ts +6 -0
- package/filters/lib/constants/filter.constants.d.ts +3 -0
- package/filters/lib/constants/index.d.ts +1 -0
- package/filters/lib/directives/filter.directive.d.ts +5 -0
- package/filters/lib/directives/index.d.ts +1 -0
- package/filters/lib/filters.module.d.ts +9 -0
- package/filters/lib/models/array-filter.models.d.ts +19 -0
- package/filters/lib/models/filter.models.d.ts +19 -0
- package/filters/lib/models/filters-group.models.d.ts +22 -0
- package/filters/lib/models/index.d.ts +3 -0
- package/package.json +1 -1
- package/styles/core/_all-theme.scss +0 -2
- package/filters/esm2022/lib/filters/components/filters/filters.component.mjs +0 -21
- package/filters/esm2022/lib/filters/components/filters-button/filters-button.component.mjs +0 -25
- package/filters/esm2022/lib/filters/components/filters-panel/filters-panel.component.mjs +0 -86
- package/filters/esm2022/lib/filters/components/filters-unit/filters-unit.component.mjs +0 -55
- package/filters/esm2022/lib/filters/directives/filters-content.directive.mjs +0 -11
- package/filters/esm2022/lib/filters/directives/filters-trigger.directive.mjs +0 -69
- package/filters/esm2022/lib/filters/filters.module.mjs +0 -53
- package/filters/esm2022/lib/filters/models/filters-default-selection-model.mjs +0 -56
- package/filters/esm2022/lib/filters/models/filters-trigger.base.mjs +0 -56
- package/filters/esm2022/lib/filters/models/filters.models.mjs +0 -44
- package/filters/esm2022/lib/filters/pipes/is-filters-param-checked.pipe.mjs +0 -21
- package/filters/esm2022/lib/filters/pipes/total-filters-applied.pipe.mjs +0 -18
- package/filters/esm2022/lib/filters/utils/filters.utils.mjs +0 -13
- package/filters/lib/filters/components/filters/filters.component.d.ts +0 -10
- package/filters/lib/filters/components/filters-button/filters-button.component.d.ts +0 -11
- package/filters/lib/filters/components/filters-panel/filters-panel.component.d.ts +0 -25
- package/filters/lib/filters/components/filters-unit/filters-unit.component.d.ts +0 -21
- package/filters/lib/filters/directives/filters-content.directive.d.ts +0 -5
- package/filters/lib/filters/directives/filters-trigger.directive.d.ts +0 -22
- package/filters/lib/filters/filters.module.d.ts +0 -20
- package/filters/lib/filters/models/filters-default-selection-model.d.ts +0 -18
- package/filters/lib/filters/models/filters-trigger.base.d.ts +0 -15
- package/filters/lib/filters/models/filters.models.d.ts +0 -42
- package/filters/lib/filters/pipes/is-filters-param-checked.pipe.d.ts +0 -10
- package/filters/lib/filters/pipes/total-filters-applied.pipe.d.ts +0 -8
- package/filters/lib/filters/utils/filters.utils.d.ts +0 -5
- package/styles/components/filters/_filters-panel.scss +0 -44
- package/styles/components/filters/_filters-unit.scss +0 -92
- package/styles/components/filters/index.scss +0 -7
@@ -1,467 +1,206 @@
|
|
1
|
+
import { BehaviorSubject, startWith, switchMap, combineLatest, map } from 'rxjs';
|
2
|
+
import { __decorate } from 'tslib';
|
1
3
|
import * as i0 from '@angular/core';
|
2
|
-
import { Directive,
|
3
|
-
import * as i3 from '@angular/common';
|
4
|
-
import { CommonModule } from '@angular/common';
|
5
|
-
import { __decorate, __metadata } from 'tslib';
|
6
|
-
import { BehaviorSubject, Subject, filter, switchMap, auditTime, skip, map } from 'rxjs';
|
4
|
+
import { InjectionToken, Directive, ContentChildren, forwardRef, Component, NgModule } from '@angular/core';
|
7
5
|
import { untilDestroyed, UntilDestroy } from '@ngneat/until-destroy';
|
8
|
-
import
|
9
|
-
import { WlcmStreamUtils, ChevronDownIconComponent, CloseIconComponent } from '@wlcm/angular/core';
|
10
|
-
import * as i2 from '@rx-angular/template/let';
|
11
|
-
import { RxLet } from '@rx-angular/template/let';
|
12
|
-
import * as i4 from '@wlcm/angular/button';
|
13
|
-
import { WlcmButtonComponent } from '@wlcm/angular/button';
|
14
|
-
import * as i1 from '@angular/cdk/overlay';
|
15
|
-
import { OverlayRef, OverlayConfig } from '@angular/cdk/overlay';
|
16
|
-
import { TemplatePortal } from '@angular/cdk/portal';
|
17
|
-
import * as i3$1 from '@angular/material/expansion';
|
18
|
-
import { MatExpansionModule } from '@angular/material/expansion';
|
19
|
-
import * as i1$1 from '@angular/material/checkbox';
|
20
|
-
import { MatCheckboxModule } from '@angular/material/checkbox';
|
21
|
-
|
22
|
-
class WlcmFiltersContentDirective {
|
23
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.6", ngImport: i0, type: WlcmFiltersContentDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
24
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.6", type: WlcmFiltersContentDirective, selector: "[wlcmFiltersContent]", ngImport: i0 }); }
|
25
|
-
}
|
26
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.6", ngImport: i0, type: WlcmFiltersContentDirective, decorators: [{
|
27
|
-
type: Directive,
|
28
|
-
args: [{ selector: '[wlcmFiltersContent]' }]
|
29
|
-
}] });
|
30
|
-
|
31
|
-
class WlcmFiltersUnit {
|
32
|
-
constructor(param, parent) {
|
33
|
-
this.param = '';
|
34
|
-
this.data = [];
|
35
|
-
this._dataChanges$ = new BehaviorSubject([...this.data]);
|
36
|
-
this.dataChanges$ = this._dataChanges$.asObservable();
|
37
|
-
this.param = param;
|
38
|
-
this.parent = parent;
|
39
|
-
}
|
40
|
-
add(value) {
|
41
|
-
this.data = [...this.data, value];
|
42
|
-
this.notifyChanges();
|
43
|
-
}
|
44
|
-
setAll(value, onlySelf = false) {
|
45
|
-
this.data = [...value];
|
46
|
-
this.notifyChanges(onlySelf);
|
47
|
-
}
|
48
|
-
remove(value) {
|
49
|
-
this.data = this.data.filter((_value) => _value !== value);
|
50
|
-
this.notifyChanges();
|
51
|
-
}
|
52
|
-
reset(onlySelf = false) {
|
53
|
-
this.data = [];
|
54
|
-
this.notifyChanges(onlySelf);
|
55
|
-
}
|
56
|
-
clone(parent) {
|
57
|
-
const unit = new WlcmFiltersUnit(this.param, parent);
|
58
|
-
unit.data = [...this.data];
|
59
|
-
unit.notifyChanges(true);
|
60
|
-
return unit;
|
61
|
-
}
|
62
|
-
notifyChanges(onlySelf = false) {
|
63
|
-
this._dataChanges$.next([...this.data]);
|
64
|
-
if (!onlySelf) {
|
65
|
-
this.parent.syncUnitChanges();
|
66
|
-
}
|
67
|
-
}
|
68
|
-
}
|
69
|
-
class WlcmFiltersSelectionModel {
|
70
|
-
}
|
71
|
-
class WlcmFiltersTriggerControl {
|
72
|
-
}
|
73
|
-
|
74
|
-
class WlcmFiltersUtils {
|
75
|
-
static modelToQueryFilters(model) {
|
76
|
-
const filters = {};
|
77
|
-
Object.keys(model).forEach((key) => {
|
78
|
-
const data = model[key].data;
|
79
|
-
if (data.length > 0) {
|
80
|
-
filters[key] = { oneOf: data };
|
81
|
-
}
|
82
|
-
});
|
83
|
-
return filters;
|
84
|
-
}
|
85
|
-
}
|
86
|
-
|
87
|
-
let WlcmFiltersPanelComponent = class WlcmFiltersPanelComponent {
|
88
|
-
constructor(injector, panelControl, globalSelectionModel) {
|
89
|
-
this.injector = injector;
|
90
|
-
this.panelControl = panelControl;
|
91
|
-
this.globalSelectionModel = globalSelectionModel;
|
92
|
-
this.loading$ = new BehaviorSubject(false);
|
93
|
-
this.totalResults$ = new BehaviorSubject(null);
|
94
|
-
this._selectionModel = inject(WlcmFiltersSelectionModel);
|
95
|
-
this._countResults$ = new Subject();
|
96
|
-
this.handleCountResultsEvent();
|
97
|
-
this.handleSelectionChanges();
|
98
|
-
}
|
99
|
-
ngOnInit() {
|
100
|
-
this._countResults$.next(this._selectionModel.model);
|
101
|
-
}
|
102
|
-
apply() {
|
103
|
-
this.updateGlobalModel();
|
104
|
-
this.panelControl.close();
|
105
|
-
}
|
106
|
-
reset() {
|
107
|
-
this._selectionModel.reset();
|
108
|
-
}
|
109
|
-
close() {
|
110
|
-
this.panelControl.close();
|
111
|
-
}
|
112
|
-
updateGlobalModel() {
|
113
|
-
this.globalSelectionModel.updateSelection(this._selectionModel.model);
|
114
|
-
}
|
115
|
-
handleSelectionChanges() {
|
116
|
-
this._selectionModel.modelChanges$
|
117
|
-
.pipe(untilDestroyed(this))
|
118
|
-
.subscribe((model) => this._countResults$.next(model));
|
119
|
-
}
|
120
|
-
handleCountResultsEvent() {
|
121
|
-
this._countResults$
|
122
|
-
.pipe(filter(() => this.countResults instanceof Function))
|
123
|
-
.pipe(switchMap((model) => {
|
124
|
-
const filters = WlcmFiltersUtils.modelToQueryFilters(model);
|
125
|
-
return this.countResults(filters).pipe(auditTime(300), WlcmStreamUtils.loadingDetector(this.loading$));
|
126
|
-
}))
|
127
|
-
.subscribe((totalResults) => this.totalResults$.next(totalResults));
|
128
|
-
}
|
129
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.6", ngImport: i0, type: WlcmFiltersPanelComponent, deps: [{ token: i0.Injector }, { token: WlcmFiltersTriggerControl }, { token: WlcmFiltersSelectionModel, skipSelf: true }], target: i0.ɵɵFactoryTarget.Component }); }
|
130
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.6", type: WlcmFiltersPanelComponent, selector: "wlcm-filters-panel", inputs: { countResults: "countResults", filtersContent: "filtersContent" }, providers: [
|
131
|
-
{
|
132
|
-
provide: WlcmFiltersSelectionModel,
|
133
|
-
useFactory: () => inject(WlcmFiltersSelectionModel, { skipSelf: true }).clone(),
|
134
|
-
},
|
135
|
-
], ngImport: i0, template: "<div class=\"wlcm-filters-panel\">\n <div class=\"wlcm-filters-panel-header\">\n <h4 class=\"filters-panel__title\">Filters</h4>\n\n <wlcm-close-icon\n (click)=\"close()\"\n class=\"wlcm-cursor-pointer\"\n ></wlcm-close-icon>\n </div>\n\n <div class=\"wlcm-filters-panel-units\">\n <ng-container\n *ngTemplateOutlet=\"filtersContent; injector: injector\"\n ></ng-container>\n </div>\n\n <div class=\"wlcm-filters-panel-actions\">\n <wlcm-button type=\"borderless\" (clicked)=\"reset()\">Reset All</wlcm-button>\n\n <wlcm-button\n (clicked)=\"apply()\"\n *rxLet=\"loading$ | async as isLoading\"\n [isLoading]=\"isLoading\"\n >\n Show\n\n <ng-container *rxLet=\"totalResults$ | async as totalResults\">\n <ng-container *ngIf=\"totalResults !== null && !isLoading\">\n ({{ totalResults }})\n </ng-container>\n </ng-container>\n </wlcm-button>\n </div>\n</div>\n", styles: [":host{width:100%;display:block}\n"], dependencies: [{ kind: "directive", type: i2.RxLet, selector: "[rxLet]", inputs: ["rxLet", "rxLetStrategy", "rxLetComplete", "rxLetError", "rxLetSuspense", "rxLetContextTrigger", "rxLetCompleteTrigger", "rxLetErrorTrigger", "rxLetSuspenseTrigger", "rxLetNextTrigger", "rxLetRenderCallback", "rxLetParent", "rxLetPatchZone"], outputs: ["rendered"] }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i3.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: i4.WlcmButtonComponent, selector: "wlcm-button", inputs: ["type", "size", "isDisabled", "isLoading"], outputs: ["clicked"] }, { kind: "component", type: i5.CloseIconComponent, selector: "wlcm-close-icon" }, { kind: "pipe", type: i3.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
136
|
-
};
|
137
|
-
WlcmFiltersPanelComponent = __decorate([
|
138
|
-
UntilDestroy(),
|
139
|
-
__metadata("design:paramtypes", [Injector,
|
140
|
-
WlcmFiltersTriggerControl,
|
141
|
-
WlcmFiltersSelectionModel])
|
142
|
-
], WlcmFiltersPanelComponent);
|
143
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.6", ngImport: i0, type: WlcmFiltersPanelComponent, decorators: [{
|
144
|
-
type: Component,
|
145
|
-
args: [{ selector: 'wlcm-filters-panel', changeDetection: ChangeDetectionStrategy.OnPush, providers: [
|
146
|
-
{
|
147
|
-
provide: WlcmFiltersSelectionModel,
|
148
|
-
useFactory: () => inject(WlcmFiltersSelectionModel, { skipSelf: true }).clone(),
|
149
|
-
},
|
150
|
-
], template: "<div class=\"wlcm-filters-panel\">\n <div class=\"wlcm-filters-panel-header\">\n <h4 class=\"filters-panel__title\">Filters</h4>\n\n <wlcm-close-icon\n (click)=\"close()\"\n class=\"wlcm-cursor-pointer\"\n ></wlcm-close-icon>\n </div>\n\n <div class=\"wlcm-filters-panel-units\">\n <ng-container\n *ngTemplateOutlet=\"filtersContent; injector: injector\"\n ></ng-container>\n </div>\n\n <div class=\"wlcm-filters-panel-actions\">\n <wlcm-button type=\"borderless\" (clicked)=\"reset()\">Reset All</wlcm-button>\n\n <wlcm-button\n (clicked)=\"apply()\"\n *rxLet=\"loading$ | async as isLoading\"\n [isLoading]=\"isLoading\"\n >\n Show\n\n <ng-container *rxLet=\"totalResults$ | async as totalResults\">\n <ng-container *ngIf=\"totalResults !== null && !isLoading\">\n ({{ totalResults }})\n </ng-container>\n </ng-container>\n </wlcm-button>\n </div>\n</div>\n", styles: [":host{width:100%;display:block}\n"] }]
|
151
|
-
}], ctorParameters: () => [{ type: i0.Injector }, { type: WlcmFiltersTriggerControl }, { type: WlcmFiltersSelectionModel, decorators: [{
|
152
|
-
type: SkipSelf
|
153
|
-
}] }], propDecorators: { countResults: [{
|
154
|
-
type: Input
|
155
|
-
}], filtersContent: [{
|
156
|
-
type: Input
|
157
|
-
}] } });
|
158
|
-
|
159
|
-
class WlcmFiltersComponent {
|
160
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.6", ngImport: i0, type: WlcmFiltersComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
161
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.6", type: WlcmFiltersComponent, selector: "wlcm-filters", inputs: { countResults: "countResults" }, queries: [{ propertyName: "filtersContent", first: true, predicate: WlcmFiltersContentDirective, descendants: true, read: TemplateRef }], viewQueries: [{ propertyName: "templateRef", first: true, predicate: ["filtersPanelTemplate"], descendants: true }], exportAs: ["wlcmFilters"], ngImport: i0, template: "<ng-template #filtersPanelTemplate>\n <wlcm-filters-panel\n [countResults]=\"countResults\"\n [filtersContent]=\"filtersContent\"\n >\n </wlcm-filters-panel>\n</ng-template>\n", styles: [":host{display:block}\n"], dependencies: [{ kind: "component", type: WlcmFiltersPanelComponent, selector: "wlcm-filters-panel", inputs: ["countResults", "filtersContent"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
162
|
-
}
|
163
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.6", ngImport: i0, type: WlcmFiltersComponent, decorators: [{
|
164
|
-
type: Component,
|
165
|
-
args: [{ selector: 'wlcm-filters', changeDetection: ChangeDetectionStrategy.OnPush, exportAs: 'wlcmFilters', template: "<ng-template #filtersPanelTemplate>\n <wlcm-filters-panel\n [countResults]=\"countResults\"\n [filtersContent]=\"filtersContent\"\n >\n </wlcm-filters-panel>\n</ng-template>\n", styles: [":host{display:block}\n"] }]
|
166
|
-
}], propDecorators: { countResults: [{
|
167
|
-
type: Input
|
168
|
-
}], templateRef: [{
|
169
|
-
type: ViewChild,
|
170
|
-
args: ['filtersPanelTemplate']
|
171
|
-
}], filtersContent: [{
|
172
|
-
type: ContentChild,
|
173
|
-
args: [WlcmFiltersContentDirective, { read: TemplateRef }]
|
174
|
-
}] } });
|
6
|
+
import { CommonModule } from '@angular/common';
|
175
7
|
|
176
|
-
class
|
8
|
+
class WlcmFilter {
|
177
9
|
constructor() {
|
178
|
-
|
179
|
-
this.
|
180
|
-
this.
|
181
|
-
this.
|
182
|
-
|
183
|
-
add(param, unit, wlcmtChanges = true) {
|
184
|
-
this.model[param] = unit;
|
185
|
-
if (wlcmtChanges) {
|
186
|
-
this.notifyChanges();
|
187
|
-
}
|
188
|
-
}
|
189
|
-
has(param) {
|
190
|
-
return this.model[param] instanceof WlcmFiltersUnit;
|
10
|
+
this._cachedValue = null;
|
11
|
+
this._size$ = new BehaviorSubject(0);
|
12
|
+
this.size$ = this._size$.asObservable();
|
13
|
+
this._value$ = new BehaviorSubject(this.initialValue);
|
14
|
+
this.value$ = this._value$.asObservable();
|
191
15
|
}
|
192
|
-
|
193
|
-
|
16
|
+
reset() {
|
17
|
+
this.value = this.initialValue;
|
194
18
|
}
|
195
|
-
|
196
|
-
|
19
|
+
cacheValue() {
|
20
|
+
this._cachedValue = this.prepareValueForCache(this.value);
|
197
21
|
}
|
198
|
-
|
199
|
-
this.
|
200
|
-
this.notifyChanges();
|
22
|
+
restoreCachedValue() {
|
23
|
+
this.value = this._cachedValue;
|
201
24
|
}
|
202
|
-
|
203
|
-
|
25
|
+
prepareValueForCache(value) {
|
26
|
+
return value;
|
204
27
|
}
|
205
|
-
|
206
|
-
|
207
|
-
clone.updateSelection({ ...this.model });
|
208
|
-
return clone;
|
28
|
+
getAppliedFilters() {
|
29
|
+
return this.value;
|
209
30
|
}
|
210
|
-
|
211
|
-
|
212
|
-
this.notifyChanges();
|
31
|
+
get initialValue() {
|
32
|
+
return null;
|
213
33
|
}
|
214
|
-
get
|
215
|
-
return
|
216
|
-
Object.values(this.model).every((unit) => unit.data.length === 0));
|
34
|
+
get size() {
|
35
|
+
return this._size$.value;
|
217
36
|
}
|
218
|
-
|
219
|
-
|
220
|
-
Object.keys(model).forEach((param) => {
|
221
|
-
_model[param] = model[param].clone(parent);
|
222
|
-
});
|
223
|
-
return _model;
|
37
|
+
get value() {
|
38
|
+
return this._value$.value;
|
224
39
|
}
|
225
|
-
|
226
|
-
this.
|
40
|
+
set value(data) {
|
41
|
+
this._value$.next(data);
|
42
|
+
if (data !== null) {
|
43
|
+
this._size$.next(this.computeSize(data));
|
44
|
+
}
|
227
45
|
}
|
228
46
|
}
|
229
47
|
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
this.
|
234
|
-
}
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
48
|
+
class WlcmArrayFilter extends WlcmFilter {
|
49
|
+
constructor() {
|
50
|
+
super();
|
51
|
+
this.prepareValue();
|
52
|
+
}
|
53
|
+
get initialValue() {
|
54
|
+
return new Map();
|
55
|
+
}
|
56
|
+
getAppliedFilters() {
|
57
|
+
if (!this.value)
|
58
|
+
return [];
|
59
|
+
return Array.from(this.value.values());
|
60
|
+
}
|
61
|
+
prepareValueForCache(value) {
|
62
|
+
if (!value)
|
63
|
+
return null;
|
64
|
+
return new Map(value);
|
65
|
+
}
|
66
|
+
computeSize(value) {
|
67
|
+
return value.size;
|
68
|
+
}
|
69
|
+
selectId(value) {
|
70
|
+
return value;
|
71
|
+
}
|
72
|
+
contains(value) {
|
73
|
+
if (!this.value)
|
74
|
+
return false;
|
75
|
+
return this.value.has(this.selectId(value));
|
76
|
+
}
|
77
|
+
addOne(value) {
|
78
|
+
this.prepareValue();
|
79
|
+
this.value = this.value.set(this.selectId(value), value);
|
80
|
+
}
|
81
|
+
addMany(values) {
|
82
|
+
this.prepareValue();
|
83
|
+
const currentValue = this.value;
|
84
|
+
values.forEach((value) => currentValue.set(this.selectId(value), value));
|
85
|
+
this.value = currentValue;
|
86
|
+
}
|
87
|
+
setAll(values) {
|
88
|
+
const newValue = new Map();
|
89
|
+
values.forEach((value) => newValue.set(this.selectId(value), value));
|
90
|
+
this.value = newValue;
|
91
|
+
}
|
92
|
+
removeOne(value) {
|
93
|
+
this.prepareValue();
|
94
|
+
const currentValue = this.value;
|
95
|
+
currentValue.delete(this.selectId(value));
|
96
|
+
this.value = currentValue;
|
97
|
+
}
|
98
|
+
removeAll() {
|
99
|
+
this.value = new Map();
|
100
|
+
}
|
101
|
+
toggle(value) {
|
102
|
+
this.prepareValue();
|
103
|
+
const currentValue = this.value;
|
104
|
+
const id = this.selectId(value);
|
105
|
+
if (currentValue.has(id)) {
|
106
|
+
currentValue.delete(id);
|
244
107
|
}
|
245
108
|
else {
|
246
|
-
|
247
|
-
Object.keys(filters).forEach((param) => {
|
248
|
-
const unit = this.selectionModel.createUnit(param);
|
249
|
-
unit.setAll(filters[param].oneOf, true);
|
250
|
-
this.selectionModel.add(param, unit, false);
|
251
|
-
});
|
109
|
+
currentValue.set(id, value);
|
252
110
|
}
|
111
|
+
this.value = currentValue;
|
253
112
|
}
|
254
|
-
|
255
|
-
|
256
|
-
const filters = WlcmFiltersUtils.modelToQueryFilters(model);
|
257
|
-
this.filtersChanges.next(filters);
|
258
|
-
});
|
259
|
-
}
|
260
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.6", ngImport: i0, type: FiltersTriggerBase, deps: [{ token: WlcmFiltersSelectionModel }], target: i0.ɵɵFactoryTarget.Directive }); }
|
261
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.6", type: FiltersTriggerBase, inputs: { filters: ["wlcmFiltersTriggerData", "filters"] }, outputs: { filtersChanges: "wlcmFiltersTriggerDataChanges" }, ngImport: i0 }); }
|
262
|
-
};
|
263
|
-
FiltersTriggerBase = __decorate([
|
264
|
-
UntilDestroy(),
|
265
|
-
__metadata("design:paramtypes", [WlcmFiltersSelectionModel])
|
266
|
-
], FiltersTriggerBase);
|
267
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.6", ngImport: i0, type: FiltersTriggerBase, decorators: [{
|
268
|
-
type: Directive
|
269
|
-
}], ctorParameters: () => [{ type: WlcmFiltersSelectionModel }], propDecorators: { filters: [{
|
270
|
-
type: Input,
|
271
|
-
args: ['wlcmFiltersTriggerData']
|
272
|
-
}], filtersChanges: [{
|
273
|
-
type: Output,
|
274
|
-
args: ['wlcmFiltersTriggerDataChanges']
|
275
|
-
}] } });
|
276
|
-
|
277
|
-
class WlcmFiltersTriggerDirective extends FiltersTriggerBase {
|
278
|
-
openPanel() {
|
279
|
-
if (this.overlayRef instanceof OverlayRef)
|
113
|
+
prepareValue() {
|
114
|
+
if (this.value instanceof Map)
|
280
115
|
return;
|
281
|
-
|
282
|
-
const injector = this.createInjector();
|
283
|
-
this.overlayRef = this.overlay.create(config);
|
284
|
-
this.overlayRef.attach(new TemplatePortal(this.panel.templateRef, this.viewContainerRef, null, injector));
|
285
|
-
}
|
286
|
-
constructor(overlay, injector, elementRef, viewContainerRef, selectionModel) {
|
287
|
-
super(selectionModel);
|
288
|
-
this.overlay = overlay;
|
289
|
-
this.injector = injector;
|
290
|
-
this.elementRef = elementRef;
|
291
|
-
this.viewContainerRef = viewContainerRef;
|
292
|
-
this.selectionModel = selectionModel;
|
293
|
-
this.overlayRef = null;
|
294
|
-
this.handleModelChanges();
|
295
|
-
}
|
296
|
-
close() {
|
297
|
-
this.overlayRef?.dispose();
|
298
|
-
this.overlayRef = null;
|
299
|
-
}
|
300
|
-
createInjector() {
|
301
|
-
return Injector.create({
|
302
|
-
providers: [
|
303
|
-
{ provide: WlcmFiltersSelectionModel, useValue: this.selectionModel },
|
304
|
-
{ provide: WlcmFiltersTriggerControl, useValue: { close: this.close.bind(this) } },
|
305
|
-
],
|
306
|
-
parent: this.injector,
|
307
|
-
});
|
308
|
-
}
|
309
|
-
createOverlayConfig() {
|
310
|
-
const strategy = this.overlay.position().flexibleConnectedTo(this.elementRef);
|
311
|
-
strategy.withPositions([{ originX: 'end', originY: 'bottom', overlayX: 'end', overlayY: 'top' }]);
|
312
|
-
strategy.withDefaultOffsetY(5);
|
313
|
-
return new OverlayConfig({
|
314
|
-
width: '300px',
|
315
|
-
positionStrategy: strategy,
|
316
|
-
scrollStrategy: this.overlay.scrollStrategies.reposition(),
|
317
|
-
});
|
116
|
+
this.value = new Map();
|
318
117
|
}
|
319
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.6", ngImport: i0, type: WlcmFiltersTriggerDirective, deps: [{ token: i1.Overlay }, { token: i0.Injector }, { token: i0.ElementRef }, { token: i0.ViewContainerRef }, { token: WlcmFiltersSelectionModel }], target: i0.ɵɵFactoryTarget.Directive }); }
|
320
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.6", type: WlcmFiltersTriggerDirective, selector: "[wlcmFiltersTrigger]", inputs: { panel: ["wlcmFiltersTrigger", "panel"] }, host: { listeners: { "click": "openPanel()" } }, providers: [{ provide: WlcmFiltersSelectionModel, useClass: FiltersDefaultSelectionModel }], usesInheritance: true, ngImport: i0 }); }
|
321
118
|
}
|
322
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.6", ngImport: i0, type: WlcmFiltersTriggerDirective, decorators: [{
|
323
|
-
type: Directive,
|
324
|
-
args: [{
|
325
|
-
selector: '[wlcmFiltersTrigger]',
|
326
|
-
providers: [{ provide: WlcmFiltersSelectionModel, useClass: FiltersDefaultSelectionModel }],
|
327
|
-
}]
|
328
|
-
}], ctorParameters: () => [{ type: i1.Overlay }, { type: i0.Injector }, { type: i0.ElementRef }, { type: i0.ViewContainerRef }, { type: WlcmFiltersSelectionModel }], propDecorators: { panel: [{
|
329
|
-
type: Input,
|
330
|
-
args: ['wlcmFiltersTrigger']
|
331
|
-
}], openPanel: [{
|
332
|
-
type: HostListener,
|
333
|
-
args: ['click']
|
334
|
-
}] } });
|
335
119
|
|
336
|
-
|
337
|
-
|
338
|
-
|
120
|
+
const WLCM_FILTER = new InjectionToken('WLCM_FILTER');
|
121
|
+
|
122
|
+
let WlcmFiltersGroup = class WlcmFiltersGroup {
|
123
|
+
constructor() {
|
124
|
+
this._size$ = new BehaviorSubject(0);
|
125
|
+
this.size$ = this._size$.asObservable();
|
339
126
|
}
|
340
|
-
|
341
|
-
this.
|
127
|
+
ngAfterContentInit() {
|
128
|
+
this.handleFiltersListChange();
|
342
129
|
}
|
343
|
-
|
344
|
-
|
345
|
-
}
|
346
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.6", ngImport: i0, type: IsFiltersParamCheckedPipe, decorators: [{
|
347
|
-
type: Pipe,
|
348
|
-
args: [{ name: 'isFiltersParamChecked' }]
|
349
|
-
}], ctorParameters: () => [{ type: i1$1.MatCheckbox, decorators: [{
|
350
|
-
type: Host
|
351
|
-
}] }] });
|
352
|
-
|
353
|
-
class WlcmFiltersUnitComponent {
|
354
|
-
constructor(selectionModel) {
|
355
|
-
this.selectionModel = selectionModel;
|
356
|
-
this.label = '';
|
357
|
-
this.param = '';
|
358
|
-
this.options = [];
|
130
|
+
resetAll() {
|
131
|
+
this.filters.forEach((filter) => filter.reset());
|
359
132
|
}
|
360
|
-
|
361
|
-
|
133
|
+
getAppliedFilters() {
|
134
|
+
const appliedFilters = {};
|
135
|
+
this.filters.forEach((filter) => {
|
136
|
+
appliedFilters[filter.key] = filter.getAppliedFilters();
|
137
|
+
});
|
138
|
+
return appliedFilters;
|
362
139
|
}
|
363
|
-
|
364
|
-
this.
|
140
|
+
cacheValues() {
|
141
|
+
this.filters.forEach((filter) => filter.cacheValue());
|
365
142
|
}
|
366
|
-
|
367
|
-
|
368
|
-
this.filtersUnit.add(event.source.value);
|
369
|
-
}
|
370
|
-
else {
|
371
|
-
this.filtersUnit.remove(event.source.value);
|
372
|
-
}
|
143
|
+
restoreCachedValues() {
|
144
|
+
this.filters.forEach((filter) => filter.restoreCachedValue());
|
373
145
|
}
|
374
|
-
|
375
|
-
|
376
|
-
this.filtersUnit = this.selectionModel.get(this.param);
|
377
|
-
}
|
378
|
-
else {
|
379
|
-
this.filtersUnit = this.selectionModel.createUnit(this.param);
|
380
|
-
this.selectionModel.add(this.param, this.filtersUnit, false);
|
381
|
-
}
|
382
|
-
this.dataChanges$ = this.filtersUnit.dataChanges$.pipe(map((data) => new Set(data)));
|
146
|
+
get size() {
|
147
|
+
return this._size$.value;
|
383
148
|
}
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
149
|
+
handleFiltersListChange() {
|
150
|
+
this.filters.changes
|
151
|
+
.pipe(untilDestroyed(this))
|
152
|
+
.pipe(startWith(this.filters))
|
153
|
+
.pipe(switchMap((filters) => this.handleSizeChange(filters.toArray())))
|
154
|
+
.subscribe();
|
155
|
+
}
|
156
|
+
handleSizeChange(list) {
|
157
|
+
return combineLatest(list.map((filter) => filter.size$)).pipe(map((sizes) => {
|
158
|
+
this._size$.next(sizes.reduce((a, b) => a + b, 0));
|
159
|
+
return list;
|
160
|
+
}));
|
161
|
+
}
|
162
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.6", ngImport: i0, type: WlcmFiltersGroup, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
163
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.6", type: WlcmFiltersGroup, queries: [{ propertyName: "filters", predicate: WLCM_FILTER }], ngImport: i0 }); }
|
164
|
+
};
|
165
|
+
WlcmFiltersGroup = __decorate([
|
166
|
+
UntilDestroy()
|
167
|
+
], WlcmFiltersGroup);
|
168
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.6", ngImport: i0, type: WlcmFiltersGroup, decorators: [{
|
169
|
+
type: Directive
|
170
|
+
}], propDecorators: { filters: [{
|
171
|
+
type: ContentChildren,
|
172
|
+
args: [WLCM_FILTER]
|
396
173
|
}] } });
|
397
174
|
|
398
|
-
class
|
399
|
-
|
400
|
-
|
401
|
-
return 0;
|
402
|
-
return Object.values(filters).reduce((total, filter) => {
|
403
|
-
return total + (filter.oneOf?.length || 0);
|
404
|
-
}, 0);
|
405
|
-
}
|
406
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.6", ngImport: i0, type: WlcmTotalFiltersAppliedPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
407
|
-
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "18.2.6", ngImport: i0, type: WlcmTotalFiltersAppliedPipe, isStandalone: true, name: "totalFiltersApplied" }); }
|
175
|
+
class FilterDirective {
|
176
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.6", ngImport: i0, type: FilterDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
177
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.6", type: FilterDirective, isStandalone: true, selector: "[wlcmFilter]", ngImport: i0 }); }
|
408
178
|
}
|
409
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.6", ngImport: i0, type:
|
410
|
-
type:
|
411
|
-
args: [{
|
179
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.6", ngImport: i0, type: FilterDirective, decorators: [{
|
180
|
+
type: Directive,
|
181
|
+
args: [{ selector: '[wlcmFilter]', standalone: true }]
|
412
182
|
}] });
|
413
183
|
|
414
|
-
class
|
415
|
-
|
416
|
-
|
417
|
-
}
|
418
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.6", ngImport: i0, type: WlcmFiltersButtonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
419
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.6", type: WlcmFiltersButtonComponent, selector: "wlcm-filters-button", inputs: { panel: "panel", filters: "filters" }, outputs: { filtersChange: "filtersChange" }, ngImport: i0, template: "<ng-container *rxLet=\"filters | totalFiltersApplied as filtersCount\">\n <wlcm-button\n [wlcmFiltersTrigger]=\"panel\"\n [wlcmFiltersTriggerData]=\"filters\"\n (wlcmFiltersTriggerDataChanges)=\"filtersChange.emit($event)\"\n [type]=\"filtersCount > 0 ? 'primary' : 'secondary'\"\n >\n Filters\n @if (filtersCount > 0) {\n <div class=\"wlcm-entities-count\">{{ filtersCount }}</div>\n }\n </wlcm-button>\n</ng-container>\n", styles: [":host{display:block}:host .wlcm-entities-count{margin-left:8px}\n"], dependencies: [{ kind: "directive", type: i2.RxLet, selector: "[rxLet]", inputs: ["rxLet", "rxLetStrategy", "rxLetComplete", "rxLetError", "rxLetSuspense", "rxLetContextTrigger", "rxLetCompleteTrigger", "rxLetErrorTrigger", "rxLetSuspenseTrigger", "rxLetNextTrigger", "rxLetRenderCallback", "rxLetParent", "rxLetPatchZone"], outputs: ["rendered"] }, { kind: "component", type: i4.WlcmButtonComponent, selector: "wlcm-button", inputs: ["type", "size", "isDisabled", "isLoading"], outputs: ["clicked"] }, { kind: "directive", type: WlcmFiltersTriggerDirective, selector: "[wlcmFiltersTrigger]", inputs: ["wlcmFiltersTrigger"] }, { kind: "pipe", type: WlcmTotalFiltersAppliedPipe, name: "totalFiltersApplied" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
184
|
+
class FiltersGroupComponent extends WlcmFiltersGroup {
|
185
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.6", ngImport: i0, type: FiltersGroupComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
186
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.6", type: FiltersGroupComponent, isStandalone: true, selector: "wlcm-filters-group", host: { classAttribute: "wlcm-filters-group" }, providers: [{ provide: WlcmFiltersGroup, useExisting: forwardRef(() => FiltersGroupComponent) }], usesInheritance: true, ngImport: i0, template: "<ng-content select=\"[wlcmFilter]\"></ng-content>\n", styles: [":host{display:block}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }] }); }
|
420
187
|
}
|
421
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.6", ngImport: i0, type:
|
188
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.6", ngImport: i0, type: FiltersGroupComponent, decorators: [{
|
422
189
|
type: Component,
|
423
|
-
args: [{ selector: 'wlcm-filters-
|
424
|
-
}]
|
425
|
-
type: Input
|
426
|
-
}], filters: [{
|
427
|
-
type: Input
|
428
|
-
}], filtersChange: [{
|
429
|
-
type: Output
|
430
|
-
}] } });
|
190
|
+
args: [{ selector: 'wlcm-filters-group', standalone: true, imports: [CommonModule], host: { class: 'wlcm-filters-group' }, providers: [{ provide: WlcmFiltersGroup, useExisting: forwardRef(() => FiltersGroupComponent) }], template: "<ng-content select=\"[wlcmFilter]\"></ng-content>\n", styles: [":host{display:block}\n"] }]
|
191
|
+
}] });
|
431
192
|
|
432
|
-
const publicComponents = [
|
433
|
-
const publicDirectives = [
|
193
|
+
const publicComponents = [FiltersGroupComponent];
|
194
|
+
const publicDirectives = [FilterDirective];
|
434
195
|
class WlcmFiltersModule {
|
435
196
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.6", ngImport: i0, type: WlcmFiltersModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
436
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.6", ngImport: i0, type: WlcmFiltersModule,
|
437
|
-
|
438
|
-
MatExpansionModule,
|
439
|
-
MatCheckboxModule,
|
440
|
-
WlcmTotalFiltersAppliedPipe,
|
441
|
-
ChevronDownIconComponent,
|
442
|
-
WlcmButtonComponent,
|
443
|
-
CloseIconComponent], exports: [WlcmFiltersComponent, WlcmFiltersUnitComponent, WlcmFiltersButtonComponent, WlcmFiltersTriggerDirective, WlcmFiltersContentDirective] }); }
|
444
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.6", ngImport: i0, type: WlcmFiltersModule, imports: [CommonModule,
|
445
|
-
MatExpansionModule,
|
446
|
-
MatCheckboxModule,
|
447
|
-
ChevronDownIconComponent,
|
448
|
-
WlcmButtonComponent,
|
449
|
-
CloseIconComponent] }); }
|
197
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.6", ngImport: i0, type: WlcmFiltersModule, imports: [CommonModule, FiltersGroupComponent, FilterDirective], exports: [FiltersGroupComponent, FilterDirective] }); }
|
198
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.6", ngImport: i0, type: WlcmFiltersModule, imports: [CommonModule, publicComponents] }); }
|
450
199
|
}
|
451
200
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.6", ngImport: i0, type: WlcmFiltersModule, decorators: [{
|
452
201
|
type: NgModule,
|
453
202
|
args: [{
|
454
|
-
imports: [
|
455
|
-
RxLet,
|
456
|
-
CommonModule,
|
457
|
-
MatExpansionModule,
|
458
|
-
MatCheckboxModule,
|
459
|
-
WlcmTotalFiltersAppliedPipe,
|
460
|
-
ChevronDownIconComponent,
|
461
|
-
WlcmButtonComponent,
|
462
|
-
CloseIconComponent,
|
463
|
-
],
|
464
|
-
declarations: [...publicComponents, ...publicDirectives, WlcmFiltersPanelComponent, IsFiltersParamCheckedPipe],
|
203
|
+
imports: [CommonModule, ...publicComponents, ...publicDirectives],
|
465
204
|
exports: [...publicComponents, ...publicDirectives],
|
466
205
|
}]
|
467
206
|
}] });
|
@@ -470,5 +209,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.6", ngImpor
|
|
470
209
|
* Generated bundle index. Do not edit.
|
471
210
|
*/
|
472
211
|
|
473
|
-
export {
|
212
|
+
export { FilterDirective, FiltersGroupComponent, WLCM_FILTER, WlcmArrayFilter, WlcmFilter, WlcmFiltersGroup, WlcmFiltersModule };
|
474
213
|
//# sourceMappingURL=wlcm-angular-filters.mjs.map
|