ngx-mat-table-multi-sort 18.1.0 → 18.2.0-pre.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.
@@ -1,29 +1,83 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, signal, effect, Directive, Component, Inject, Injector, Input, HostListener, inject, ViewEncapsulation, ANIMATION_MODULE_TYPE } from '@angular/core';
2
+ import { InjectionToken, EventEmitter, signal, effect, Directive, Optional, Inject, Output, Injectable, Component, HostListener, inject, ViewEncapsulation, ANIMATION_MODULE_TYPE, Input } from '@angular/core';
3
3
  import { moveItemInArray, CdkDropList, CdkDrag } from '@angular/cdk/drag-drop';
4
- import { MatSort, MatSortHeader } from '@angular/material/sort';
4
+ import { MatSort, MAT_SORT_DEFAULT_OPTIONS, MatSortHeader } from '@angular/material/sort';
5
5
  import { ComponentPortal } from '@angular/cdk/portal';
6
- import * as i1 from '@angular/material/checkbox';
6
+ import * as i2 from '@angular/material/checkbox';
7
7
  import { MatCheckboxModule } from '@angular/material/checkbox';
8
- import * as i2 from '@angular/material/icon';
8
+ import * as i3 from '@angular/material/icon';
9
9
  import { MatIconModule } from '@angular/material/icon';
10
- import * as i1$1 from '@angular/cdk/overlay';
10
+ import { BehaviorSubject } from 'rxjs';
11
+ import * as i1 from '@angular/cdk/overlay';
11
12
  import { MatTableDataSource } from '@angular/material/table';
12
13
  import { NgIf } from '@angular/common';
13
- import * as i1$2 from '@angular/material/chips';
14
+ import * as i1$1 from '@angular/material/chips';
14
15
  import { MatChipsModule } from '@angular/material/chips';
15
16
 
16
17
  /**
17
- * Injection token for providing table column configurations.
18
+ * Injection token for the storage mechanism used to persist column configuration.
18
19
  *
19
- * This token is used to inject an array of `TableColumn` configurations
20
- * into Angular components or services. The generic type `unknown` is used
21
- * to allow for flexibility in the type of data that can be represented
22
- * by the table columns.
20
+ * This token can be used to provide a custom storage implementation for saving
21
+ * and retrieving the state of table column configurations.
22
+ *
23
+ */
24
+ const COLUMN_CONFIG_PERSISTENCE_STORAGE = new InjectionToken("COLUMN_CONFIG_PERSISTENCE_STORAGE");
25
+ /**
26
+ * Injection token used to enable or disable column configuration persistence.
27
+ *
28
+ * This token can be provided with a boolean value to indicate whether the
29
+ * column configurations should be persisted (e.g., in local storage or a database).
30
+ *
31
+ */
32
+ const COLUMN_CONFIG_PERSISTENCE_ENABLED = new InjectionToken("COLUMN_CONFIG_PERSISTENCE_ENABLED");
33
+ /**
34
+ * Injection token for the column configuration persistence key.
35
+ * This token is used to provide a unique key for persisting column configurations.
23
36
  */
24
- const TABLE_COLUMNS = new InjectionToken("TABLE_COLUMNS");
37
+ const COLUMN_CONFIG_PERSISTENCE_KEY = new InjectionToken("COLUMN_CONFIG_PERSISTENCE_KEY");
25
38
 
39
+ /**
40
+ * Injection token for the storage mechanism used to persist sorting state.
41
+ *
42
+ * This token can be used to provide a custom storage implementation for persisting
43
+ * the sorting state of a table. By default, it can be set to use localStorage, sessionStorage,
44
+ * or any other storage mechanism that implements the Storage interface.
45
+ *
46
+ */
47
+ const SORT_PERSISTENCE_STORAGE = new InjectionToken("SORT_PERSISTENCE_STORAGE");
48
+ /**
49
+ * Injection token used to enable or disable the persistence of sorting state.
50
+ *
51
+ * This token can be provided in the application's dependency injection system
52
+ * to control whether the sorting state of a table should be persisted across
53
+ * sessions or not.
54
+ *
55
+ * @example
56
+ * // To enable sort persistence:
57
+ * providers: [
58
+ * { provide: SORT_PERSISTENCE_ENABLED, useValue: true }
59
+ * ]
60
+ *
61
+ * @example
62
+ * // To disable sort persistence:
63
+ * providers: [
64
+ * { provide: SORT_PERSISTENCE_ENABLED, useValue: false }
65
+ * ]
66
+ */
67
+ const SORT_PERSISTENCE_ENABLED = new InjectionToken("SORT_PERSISTENCE_ENABLED");
68
+ /**
69
+ * Injection token for the key used to persist sorting state.
70
+ *
71
+ * This token can be used to provide a custom key for storing
72
+ * the sorting state in a persistence layer, such as local storage
73
+ * or a database.
74
+ */
75
+ const SORT_PERSISTENCE_KEY = new InjectionToken("SORT_PERSISTENCE_KEY");
26
76
  class MatMultiSortDirective extends MatSort {
77
+ isPersistenceEnabled;
78
+ key;
79
+ storage;
80
+ persistenceChanged = new EventEmitter();
27
81
  /**
28
82
  * A writable signal that holds an array of Sort objects.
29
83
  * This signal is used to manage the sorting state of the table.
@@ -31,17 +85,26 @@ class MatMultiSortDirective extends MatSort {
31
85
  * @readonly
32
86
  */
33
87
  _sorts = signal([]);
34
- constructor() {
35
- super();
36
- /* We are using an effect to emit the sortChange event whenever the _sorts signal changes.
37
- * This is necessary because the sortChange event is not emitted when the _sorts signal is updated directly (e.g., this._sorts.set([])).
38
- */
88
+ constructor(isPersistenceEnabled, key, storage, defaultOptions) {
89
+ super(defaultOptions);
90
+ this.isPersistenceEnabled = isPersistenceEnabled;
91
+ this.key = key;
92
+ this.storage = storage;
93
+ this.isPersistenceEnabled ??= true;
94
+ this.key ??= "mat-table-persistence-sort";
95
+ this.storage ??= localStorage;
96
+ if (this.isPersistenceEnabled) {
97
+ const sortsSerialized = this.storage.getItem(this.key);
98
+ this._sorts.set(sortsSerialized ? JSON.parse(sortsSerialized) : []);
99
+ }
100
+ // This is necessary because the sortChange event is not emitted when the _sorts signal is updated directly (e.g., this._sorts.set([])).
39
101
  effect(() => {
40
102
  const length = this._sorts().length;
41
103
  this.sortChange.emit({
42
104
  active: length ? this._sorts()[length - 1].active : "",
43
105
  direction: length ? this._sorts()[length - 1].direction : "",
44
106
  });
107
+ this.persistSortSettings();
45
108
  });
46
109
  }
47
110
  /**
@@ -83,6 +146,7 @@ class MatMultiSortDirective extends MatSort {
83
146
  }
84
147
  }
85
148
  this.sortChange.emit({ active: this.active, direction: this.direction });
149
+ this.persistSortSettings();
86
150
  }
87
151
  /**
88
152
  * Removes a sort level by its identifier.
@@ -97,6 +161,7 @@ class MatMultiSortDirective extends MatSort {
97
161
  return;
98
162
  this._sorts().splice(index, 1);
99
163
  this.sortChange.emit();
164
+ this.persistSortSettings();
100
165
  }
101
166
  /**
102
167
  * Reorders the sort level by moving an item in the sort array from a previous index to a current index.
@@ -110,6 +175,7 @@ class MatMultiSortDirective extends MatSort {
110
175
  return;
111
176
  moveItemInArray(this._sorts(), previousIndex, currentIndex);
112
177
  this.sortChange.emit(this._sorts()[currentIndex]);
178
+ this.persistSortSettings();
113
179
  }
114
180
  /**
115
181
  * Toggles the sort direction for the given column ID.
@@ -130,6 +196,7 @@ class MatMultiSortDirective extends MatSort {
130
196
  });
131
197
  this._sorts()[index].direction = this.direction;
132
198
  this.sortChange.emit({ active: this.active, direction: this.direction });
199
+ this.persistSortSettings();
133
200
  }
134
201
  /**
135
202
  * Clears the current sorting state.
@@ -142,9 +209,15 @@ class MatMultiSortDirective extends MatSort {
142
209
  this.direction = "";
143
210
  this._sorts.set([]);
144
211
  this.sortChange.emit();
212
+ this.persistSortSettings();
145
213
  }
146
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: MatMultiSortDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
147
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.13", type: MatMultiSortDirective, isStandalone: true, selector: "[matMultiSort]", host: { classAttribute: "mat-sort" }, exportAs: ["matMultiSort"], usesInheritance: true, ngImport: i0 });
214
+ persistSortSettings() {
215
+ this.persistenceChanged.emit(this._sorts());
216
+ if (this.isPersistenceEnabled)
217
+ this.storage.setItem(this.key, JSON.stringify(this._sorts()));
218
+ }
219
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: MatMultiSortDirective, deps: [{ token: SORT_PERSISTENCE_ENABLED, optional: true }, { token: SORT_PERSISTENCE_KEY, optional: true }, { token: SORT_PERSISTENCE_STORAGE, optional: true }, { token: MAT_SORT_DEFAULT_OPTIONS, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
220
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.13", type: MatMultiSortDirective, isStandalone: true, selector: "[matMultiSort]", outputs: { persistenceChanged: "persistenceChanged" }, host: { classAttribute: "mat-sort" }, exportAs: ["matMultiSort"], usesInheritance: true, ngImport: i0 });
148
221
  }
149
222
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: MatMultiSortDirective, decorators: [{
150
223
  type: Directive,
@@ -156,12 +229,119 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
156
229
  },
157
230
  standalone: true,
158
231
  }]
159
- }], ctorParameters: () => [] });
232
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
233
+ type: Optional
234
+ }, {
235
+ type: Inject,
236
+ args: [SORT_PERSISTENCE_ENABLED]
237
+ }] }, { type: undefined, decorators: [{
238
+ type: Optional
239
+ }, {
240
+ type: Inject,
241
+ args: [SORT_PERSISTENCE_KEY]
242
+ }] }, { type: Storage, decorators: [{
243
+ type: Optional
244
+ }, {
245
+ type: Inject,
246
+ args: [SORT_PERSISTENCE_STORAGE]
247
+ }] }, { type: undefined, decorators: [{
248
+ type: Optional
249
+ }, {
250
+ type: Inject,
251
+ args: [MAT_SORT_DEFAULT_OPTIONS]
252
+ }] }], propDecorators: { persistenceChanged: [{
253
+ type: Output
254
+ }] } });
255
+
256
+ class MatTableColumnConfigPersistenceService {
257
+ isPersistenceEnabled;
258
+ key;
259
+ storage;
260
+ columns$ = new BehaviorSubject([]);
261
+ /**
262
+ * Gets the current table columns configuration.
263
+ *
264
+ * @returns {TableColumn<T>[]} An array of table columns.
265
+ */
266
+ get columns() {
267
+ return this.columns$.getValue();
268
+ }
269
+ /**
270
+ * Sets the columns configuration for the table and persists the configuration.
271
+ *
272
+ * @param value - An array of `TableColumn<T>` representing the new column configuration.
273
+ */
274
+ set columns(value) {
275
+ this.columns$.next(value);
276
+ this.persistColumnConfig(value);
277
+ }
278
+ constructor(isPersistenceEnabled, key, storage) {
279
+ this.isPersistenceEnabled = isPersistenceEnabled;
280
+ this.key = key;
281
+ this.storage = storage;
282
+ this.isPersistenceEnabled ??= true;
283
+ this.key ??= "mat-table-persistence-column-config";
284
+ this.storage ??= localStorage;
285
+ if (this.isPersistenceEnabled) {
286
+ const columnsSerialized = this.storage.getItem(this.key);
287
+ this.columns$.next(columnsSerialized ? JSON.parse(columnsSerialized) : []);
288
+ }
289
+ }
290
+ /**
291
+ * Retrieves an observable stream of table columns.
292
+ *
293
+ * @returns {Observable<TableColumn<T>[]>} An observable that emits an array of table columns.
294
+ */
295
+ getColumns() {
296
+ return this.columns$.asObservable();
297
+ }
298
+ persistColumnConfig(columns) {
299
+ if (!this.isPersistenceEnabled)
300
+ return;
301
+ this.storage.setItem(this.key, JSON.stringify(columns));
302
+ }
303
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: MatTableColumnConfigPersistenceService, deps: [{ token: COLUMN_CONFIG_PERSISTENCE_ENABLED, optional: true }, { token: COLUMN_CONFIG_PERSISTENCE_KEY, optional: true }, { token: COLUMN_CONFIG_PERSISTENCE_STORAGE, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
304
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: MatTableColumnConfigPersistenceService, providedIn: "root" });
305
+ }
306
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: MatTableColumnConfigPersistenceService, decorators: [{
307
+ type: Injectable,
308
+ args: [{
309
+ providedIn: "root",
310
+ }]
311
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
312
+ type: Optional
313
+ }, {
314
+ type: Inject,
315
+ args: [COLUMN_CONFIG_PERSISTENCE_ENABLED]
316
+ }] }, { type: undefined, decorators: [{
317
+ type: Optional
318
+ }, {
319
+ type: Inject,
320
+ args: [COLUMN_CONFIG_PERSISTENCE_KEY]
321
+ }] }, { type: Storage, decorators: [{
322
+ type: Optional
323
+ }, {
324
+ type: Inject,
325
+ args: [COLUMN_CONFIG_PERSISTENCE_STORAGE]
326
+ }] }] });
160
327
 
161
328
  class MatTableColumnConfigComponent {
162
- columns;
163
- constructor(columns) {
164
- this.columns = columns;
329
+ persistenceService;
330
+ subscription;
331
+ columns = [];
332
+ constructor(persistenceService) {
333
+ this.persistenceService = persistenceService;
334
+ }
335
+ ngOnInit() {
336
+ this.subscription = this.persistenceService
337
+ .getColumns()
338
+ .subscribe((columns) => {
339
+ this.columns = columns;
340
+ });
341
+ }
342
+ ngOnDestroy() {
343
+ this.subscription?.unsubscribe();
344
+ this.subscription = undefined;
165
345
  }
166
346
  /**
167
347
  * Handles the event when a dragged column is dropped.
@@ -171,6 +351,7 @@ class MatTableColumnConfigComponent {
171
351
  */
172
352
  onColumnDropped(event) {
173
353
  moveItemInArray(this.columns, event.previousIndex, event.currentIndex);
354
+ this.persistenceService.columns = this.columns;
174
355
  }
175
356
  /**
176
357
  * Toggles the visibility of a column based on its identifier.
@@ -182,31 +363,21 @@ class MatTableColumnConfigComponent {
182
363
  if (index < 0)
183
364
  return;
184
365
  this.columns[index].visible = !this.columns[index].visible;
366
+ this.persistenceService.columns = this.columns;
185
367
  }
186
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: MatTableColumnConfigComponent, deps: [{ token: TABLE_COLUMNS }], target: i0.ɵɵFactoryTarget.Component });
187
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.13", type: MatTableColumnConfigComponent, isStandalone: true, selector: "mat-table-column-config", ngImport: i0, template: "<div\n cdkDropList\n class=\"table-column-list mat-elevation-z4\"\n cdkDropListOrientation=\"vertical\"\n (cdkDropListDropped)=\"onColumnDropped($event)\">\n @for (column of columns; track column.id) {\n <div cdkDrag class=\"table-column\">\n <mat-icon cdkDragHandle>drag_indicator</mat-icon>\n <mat-checkbox\n [checked]=\"column.visible\"\n (change)=\"onColumnVisibilityChanged(column.id)\"\n >{{ column.label }}</mat-checkbox\n >\n </div>\n }\n</div>\n", styles: [".cdk-drag-placeholder{opacity:0}.cdk-drag-animating{transition:transform .15s cubic-bezier(0,0,.2,1)}.cdk-drag-preview{box-sizing:border-box;box-shadow:0 5px 5px -3px #0003,0 8px 10px 1px #00000024,0 3px 14px 2px #0000001f;overflow:hidden}.table-column-list{background-color:var(--mat-sys-surface-container, #eeeeee);color:var(--mat-sys-on-surface, rgba(0, 0, 0, .87))}.table-column{background:var(--mat-sys-surface, #ffffff);display:flex;justify-content:flex-start;align-items:center;height:48px;padding:0 16px 0 8px}.table-column mat-icon{margin-right:16px}.table-column mat-checkbox{line-height:48px;color:#000000de;font-size:14px;font-weight:400}.table-column:last-child{border:none}.cdk-drop-list-dragging .table-column:not(.cdk-drag-placeholder){transition:transform .15s cubic-bezier(0,0,.2,1)}\n"], dependencies: [{ kind: "directive", type: CdkDropList, selector: "[cdkDropList], cdk-drop-list", inputs: ["cdkDropListConnectedTo", "cdkDropListData", "cdkDropListOrientation", "id", "cdkDropListLockAxis", "cdkDropListDisabled", "cdkDropListSortingDisabled", "cdkDropListEnterPredicate", "cdkDropListSortPredicate", "cdkDropListAutoScrollDisabled", "cdkDropListAutoScrollStep", "cdkDropListElementContainer"], outputs: ["cdkDropListDropped", "cdkDropListEntered", "cdkDropListExited", "cdkDropListSorted"], exportAs: ["cdkDropList"] }, { kind: "directive", type: CdkDrag, selector: "[cdkDrag]", inputs: ["cdkDragData", "cdkDragLockAxis", "cdkDragRootElement", "cdkDragBoundary", "cdkDragStartDelay", "cdkDragFreeDragPosition", "cdkDragDisabled", "cdkDragConstrainPosition", "cdkDragPreviewClass", "cdkDragPreviewContainer", "cdkDragScale"], outputs: ["cdkDragStarted", "cdkDragReleased", "cdkDragEnded", "cdkDragEntered", "cdkDragExited", "cdkDragDropped", "cdkDragMoved"], exportAs: ["cdkDrag"] }, { kind: "ngmodule", type: MatCheckboxModule }, { kind: "component", type: i1.MatCheckbox, selector: "mat-checkbox", inputs: ["aria-label", "aria-labelledby", "aria-describedby", "id", "required", "labelPosition", "name", "value", "disableRipple", "tabIndex", "color", "disabledInteractive", "checked", "disabled", "indeterminate"], outputs: ["change", "indeterminateChange"], exportAs: ["matCheckbox"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i2.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }] });
368
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: MatTableColumnConfigComponent, deps: [{ token: MatTableColumnConfigPersistenceService }], target: i0.ɵɵFactoryTarget.Component });
369
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.13", type: MatTableColumnConfigComponent, isStandalone: true, selector: "mat-table-column-config", ngImport: i0, template: "<div\n cdkDropList\n class=\"table-column-list mat-elevation-z4\"\n cdkDropListOrientation=\"vertical\"\n (cdkDropListDropped)=\"onColumnDropped($event)\">\n @for (column of columns; track column.id) {\n <div cdkDrag class=\"table-column\">\n <mat-icon cdkDragHandle>drag_indicator</mat-icon>\n <mat-checkbox\n [checked]=\"column.visible\"\n (change)=\"onColumnVisibilityChanged(column.id)\"\n >{{ column.label }}</mat-checkbox\n >\n </div>\n }\n</div>\n", styles: [".cdk-drag-placeholder{opacity:0}.cdk-drag-animating{transition:transform .15s cubic-bezier(0,0,.2,1)}.cdk-drag-preview{box-sizing:border-box;box-shadow:0 5px 5px -3px #0003,0 8px 10px 1px #00000024,0 3px 14px 2px #0000001f;overflow:hidden}.table-column-list{background-color:var(--mat-sys-surface-container, #eeeeee);color:var(--mat-sys-on-surface, rgba(0, 0, 0, .87))}.table-column{background:var(--mat-sys-surface, #ffffff);display:flex;justify-content:flex-start;align-items:center;height:48px;padding:0 16px 0 8px}.table-column mat-icon{margin-right:16px}.table-column mat-checkbox{line-height:48px;color:#000000de;font-size:14px;font-weight:400}.table-column:last-child{border:none}.cdk-drop-list-dragging .table-column:not(.cdk-drag-placeholder){transition:transform .15s cubic-bezier(0,0,.2,1)}\n"], dependencies: [{ kind: "directive", type: CdkDropList, selector: "[cdkDropList], cdk-drop-list", inputs: ["cdkDropListConnectedTo", "cdkDropListData", "cdkDropListOrientation", "id", "cdkDropListLockAxis", "cdkDropListDisabled", "cdkDropListSortingDisabled", "cdkDropListEnterPredicate", "cdkDropListSortPredicate", "cdkDropListAutoScrollDisabled", "cdkDropListAutoScrollStep", "cdkDropListElementContainer"], outputs: ["cdkDropListDropped", "cdkDropListEntered", "cdkDropListExited", "cdkDropListSorted"], exportAs: ["cdkDropList"] }, { kind: "directive", type: CdkDrag, selector: "[cdkDrag]", inputs: ["cdkDragData", "cdkDragLockAxis", "cdkDragRootElement", "cdkDragBoundary", "cdkDragStartDelay", "cdkDragFreeDragPosition", "cdkDragDisabled", "cdkDragConstrainPosition", "cdkDragPreviewClass", "cdkDragPreviewContainer", "cdkDragScale"], outputs: ["cdkDragStarted", "cdkDragReleased", "cdkDragEnded", "cdkDragEntered", "cdkDragExited", "cdkDragDropped", "cdkDragMoved"], exportAs: ["cdkDrag"] }, { kind: "ngmodule", type: MatCheckboxModule }, { kind: "component", type: i2.MatCheckbox, selector: "mat-checkbox", inputs: ["aria-label", "aria-labelledby", "aria-describedby", "id", "required", "labelPosition", "name", "value", "disableRipple", "tabIndex", "color", "disabledInteractive", "checked", "disabled", "indeterminate"], outputs: ["change", "indeterminateChange"], exportAs: ["matCheckbox"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }] });
188
370
  }
189
371
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: MatTableColumnConfigComponent, decorators: [{
190
372
  type: Component,
191
373
  args: [{ selector: "mat-table-column-config", imports: [CdkDropList, CdkDrag, MatCheckboxModule, MatIconModule], standalone: true, template: "<div\n cdkDropList\n class=\"table-column-list mat-elevation-z4\"\n cdkDropListOrientation=\"vertical\"\n (cdkDropListDropped)=\"onColumnDropped($event)\">\n @for (column of columns; track column.id) {\n <div cdkDrag class=\"table-column\">\n <mat-icon cdkDragHandle>drag_indicator</mat-icon>\n <mat-checkbox\n [checked]=\"column.visible\"\n (change)=\"onColumnVisibilityChanged(column.id)\"\n >{{ column.label }}</mat-checkbox\n >\n </div>\n }\n</div>\n", styles: [".cdk-drag-placeholder{opacity:0}.cdk-drag-animating{transition:transform .15s cubic-bezier(0,0,.2,1)}.cdk-drag-preview{box-sizing:border-box;box-shadow:0 5px 5px -3px #0003,0 8px 10px 1px #00000024,0 3px 14px 2px #0000001f;overflow:hidden}.table-column-list{background-color:var(--mat-sys-surface-container, #eeeeee);color:var(--mat-sys-on-surface, rgba(0, 0, 0, .87))}.table-column{background:var(--mat-sys-surface, #ffffff);display:flex;justify-content:flex-start;align-items:center;height:48px;padding:0 16px 0 8px}.table-column mat-icon{margin-right:16px}.table-column mat-checkbox{line-height:48px;color:#000000de;font-size:14px;font-weight:400}.table-column:last-child{border:none}.cdk-drop-list-dragging .table-column:not(.cdk-drag-placeholder){transition:transform .15s cubic-bezier(0,0,.2,1)}\n"] }]
192
- }], ctorParameters: () => [{ type: undefined, decorators: [{
193
- type: Inject,
194
- args: [TABLE_COLUMNS]
195
- }] }] });
374
+ }], ctorParameters: () => [{ type: MatTableColumnConfigPersistenceService }] });
196
375
 
197
376
  class MatTableColumnConfigTriggerDirective {
198
377
  elementRef;
199
378
  overlay;
200
379
  viewContainerRef;
201
380
  _componentRef = null;
202
- /**
203
- * Input property that accepts an array of table column configurations.
204
- * The alias for this input property is "matTableColumnConfigTrigger".
205
- * This property is required.
206
- *
207
- * @type {TableColumn<T>[]} columns - The array of table column configurations.
208
- */
209
- columns;
210
381
  /**
211
382
  * Gets the reference to the MatTableColumnConfigComponent.
212
383
  *
@@ -243,11 +414,7 @@ class MatTableColumnConfigTriggerDirective {
243
414
  hasBackdrop: true,
244
415
  backdropClass: "cdk-overlay-transparent-backdrop",
245
416
  });
246
- const injector = Injector.create({
247
- providers: [{ provide: TABLE_COLUMNS, useValue: this.columns }],
248
- parent: this.viewContainerRef.injector,
249
- });
250
- const portal = new ComponentPortal((MatTableColumnConfigComponent), this.viewContainerRef, injector);
417
+ const portal = new ComponentPortal((MatTableColumnConfigComponent), this.viewContainerRef, this.viewContainerRef.injector);
251
418
  this._componentRef = overlayRef.attach(portal);
252
419
  overlayRef.backdropClick().subscribe(() => {
253
420
  overlayRef.detach();
@@ -255,8 +422,8 @@ class MatTableColumnConfigTriggerDirective {
255
422
  this._componentRef = null;
256
423
  });
257
424
  }
258
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: MatTableColumnConfigTriggerDirective, deps: [{ token: i0.ElementRef }, { token: i1$1.Overlay }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
259
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.13", type: MatTableColumnConfigTriggerDirective, isStandalone: true, selector: "[matTableColumnConfigTrigger]", inputs: { columns: ["matTableColumnConfigTrigger", "columns"] }, host: { listeners: { "click": "onClick()" } }, exportAs: ["matTableColumnConfigTrigger"], ngImport: i0 });
425
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: MatTableColumnConfigTriggerDirective, deps: [{ token: i0.ElementRef }, { token: i1.Overlay }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
426
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.13", type: MatTableColumnConfigTriggerDirective, isStandalone: true, selector: "[matTableColumnConfigTrigger]", host: { listeners: { "click": "onClick()" } }, exportAs: ["matTableColumnConfigTrigger"], ngImport: i0 });
260
427
  }
261
428
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: MatTableColumnConfigTriggerDirective, decorators: [{
262
429
  type: Directive,
@@ -265,10 +432,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
265
432
  exportAs: "matTableColumnConfigTrigger",
266
433
  standalone: true,
267
434
  }]
268
- }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i1$1.Overlay }, { type: i0.ViewContainerRef }], propDecorators: { columns: [{
269
- type: Input,
270
- args: [{ alias: "matTableColumnConfigTrigger", required: true }]
271
- }], onClick: [{
435
+ }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i1.Overlay }, { type: i0.ViewContainerRef }], propDecorators: { onClick: [{
272
436
  type: HostListener,
273
437
  args: ["click"]
274
438
  }] } });
@@ -456,7 +620,7 @@ class MatMultiSortControlComponent {
456
620
  this.sort?.reorderSortLevel(event.previousIndex, event.currentIndex);
457
621
  }
458
622
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: MatMultiSortControlComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
459
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.13", type: MatMultiSortControlComponent, isStandalone: true, selector: "mat-multi-sort-control", inputs: { orientation: "orientation", sort: "sort" }, ngImport: i0, template: "<mat-chip-listbox\n cdkDropList\n [cdkDropListOrientation]=\"orientation\"\n (cdkDropListDropped)=\"onDrop($event)\">\n <mat-chip\n [disabled]=\"!sorts.length\"\n [highlighted]=\"true\"\n (click)=\"onClearClick()\"\n ><mat-icon matChipAvatar fontIcon=\"clear_all\"></mat-icon>Clear All</mat-chip\n >\n @for (column of sorts; track $index) {\n <mat-chip\n class=\"mat-sort-header\"\n cdkDrag\n (click)=\"onChipClick(column.active)\"\n (removed)=\"onChipRemoved(column.active)\">\n <div\n matChipAvatar\n class=\"mat-sort-header-container mat-sort-header-sorted mat-focus-indicator\"\n [class.mat-sort-header-descending]=\"column.direction === 'desc'\"\n [class.mat-sort-header-ascending]=\"column.direction === 'asc'\"\n [class.mat-sort-header-animations-disabled]=\"\n _animationModule === 'NoopAnimations'\n \">\n <div class=\"mat-sort-header-arrow\">\n <svg viewBox=\"0 -960 960 960\" focusable=\"false\" aria-hidden=\"true\">\n <path\n d=\"M440-240v-368L296-464l-56-56 240-240 240 240-56 56-144-144v368h-80Z\" />\n </svg>\n </div>\n </div>\n {{ column.active }}\n <button matChipRemove>\n <mat-icon>clear</mat-icon>\n </button>\n </mat-chip>\n }\n</mat-chip-listbox>\n", styles: [".cdk-drag-placeholder{opacity:0}.cdk-drag-animating{transition:transform .15s cubic-bezier(0,0,.2,1)}.cdk-drag-preview{box-sizing:border-box;box-shadow:0 5px 5px -3px #0003,0 8px 10px 1px #00000024,0 3px 14px 2px #0000001f;overflow:hidden}.mat-mdc-chip-listbox.mat-mdc-chip-set.cdk-drop-list .cdk-drop-list-dragging{transition:transform .15s cubic-bezier(0,0,.2,1)}.mat-mdc-chip.mat-sort-header{background-color:var(--mat-sys-surface, #ffffff);transition:background-color .1s cubic-bezier(0,0,.2,1),box-shadow .1s cubic-bezier(0,0,.2,1)}.mat-mdc-chip.mat-sort-header:hover{cursor:move}.mat-mdc-chip.mat-sort-header:hover:after{opacity:0}.mat-mdc-chip.mat-sort-header:focus:after{opacity:0}.mat-mdc-chip.mat-sort-header:active{box-shadow:0 5px 5px -3px #0003,0 8px 10px 1px #00000024,0 3px 14px 2px #0000001f}.mat-sort-header-content{display:flex;align-items:center}.mat-sort-header-position-before{flex-direction:row-reverse}@keyframes _mat-sort-header-recently-cleared-ascending{0%{transform:translateY(0);opacity:1}to{transform:translateY(-25%);opacity:0}}@keyframes _mat-sort-header-recently-cleared-descending{0%{transform:translateY(0) rotate(180deg);opacity:1}to{transform:translateY(25%) rotate(180deg);opacity:0}}.mat-sort-header-arrow{height:12px;width:12px;position:relative;transition:transform 225ms cubic-bezier(.4,0,.2,1),opacity 225ms cubic-bezier(.4,0,.2,1);opacity:0;overflow:visible;color:var(--mat-sort-arrow-color, var(--mat-app-on-surface))}.mat-sort-header.cdk-keyboard-focused .mat-sort-header-arrow,.mat-sort-header.cdk-program-focused .mat-sort-header-arrow,.mat-sort-header:hover .mat-sort-header-arrow{opacity:.54}.mat-sort-header .mat-sort-header-sorted .mat-sort-header-arrow{opacity:1}.mat-sort-header-descending .mat-sort-header-arrow{transform:rotate(180deg)}.mat-sort-header-recently-cleared-ascending .mat-sort-header-arrow{transform:translateY(-25%);transition:none;animation:_mat-sort-header-recently-cleared-ascending 225ms cubic-bezier(.4,0,.2,1) forwards}.mat-sort-header-recently-cleared-descending .mat-sort-header-arrow{transition:none;animation:_mat-sort-header-recently-cleared-descending 225ms cubic-bezier(.4,0,.2,1) forwards}.mat-sort-header-animations-disabled .mat-sort-header-arrow{transition-duration:0ms;animation-duration:0ms}.mat-sort-header-arrow svg{width:24px;height:24px;fill:currentColor;position:absolute;top:50%;left:50%;margin:-12px 0 0 -12px;transform:translateZ(0)}.mat-sort-header-arrow,[dir=rtl] .mat-sort-header-position-before .mat-sort-header-arrow{margin:0 0 0 6px}.mat-sort-header-position-before .mat-sort-header-arrow,[dir=rtl] .mat-sort-header-arrow{margin:0 6px 0 0}.cdk-drop-list-dragging .mat-sort-header:not(.cdk-drag-placeholder){background-color:var(--mat-sys-surface-dim, #ffffff);transition:transform .15s cubic-bezier(0,0,.2,1)}\n"], dependencies: [{ kind: "directive", type: CdkDropList, selector: "[cdkDropList], cdk-drop-list", inputs: ["cdkDropListConnectedTo", "cdkDropListData", "cdkDropListOrientation", "id", "cdkDropListLockAxis", "cdkDropListDisabled", "cdkDropListSortingDisabled", "cdkDropListEnterPredicate", "cdkDropListSortPredicate", "cdkDropListAutoScrollDisabled", "cdkDropListAutoScrollStep", "cdkDropListElementContainer"], outputs: ["cdkDropListDropped", "cdkDropListEntered", "cdkDropListExited", "cdkDropListSorted"], exportAs: ["cdkDropList"] }, { kind: "directive", type: CdkDrag, selector: "[cdkDrag]", inputs: ["cdkDragData", "cdkDragLockAxis", "cdkDragRootElement", "cdkDragBoundary", "cdkDragStartDelay", "cdkDragFreeDragPosition", "cdkDragDisabled", "cdkDragConstrainPosition", "cdkDragPreviewClass", "cdkDragPreviewContainer", "cdkDragScale"], outputs: ["cdkDragStarted", "cdkDragReleased", "cdkDragEnded", "cdkDragEntered", "cdkDragExited", "cdkDragDropped", "cdkDragMoved"], exportAs: ["cdkDrag"] }, { kind: "ngmodule", type: MatChipsModule }, { kind: "component", type: i1$2.MatChip, selector: "mat-basic-chip, [mat-basic-chip], mat-chip, [mat-chip]", inputs: ["role", "id", "aria-label", "aria-description", "value", "color", "removable", "highlighted", "disableRipple", "disabled"], outputs: ["removed", "destroyed"], exportAs: ["matChip"] }, { kind: "directive", type: i1$2.MatChipAvatar, selector: "mat-chip-avatar, [matChipAvatar]" }, { kind: "component", type: i1$2.MatChipListbox, selector: "mat-chip-listbox", inputs: ["multiple", "aria-orientation", "selectable", "compareWith", "required", "hideSingleSelectionIndicator", "value"], outputs: ["change"] }, { kind: "directive", type: i1$2.MatChipRemove, selector: "[matChipRemove]" }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i2.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }] });
623
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.13", type: MatMultiSortControlComponent, isStandalone: true, selector: "mat-multi-sort-control", inputs: { orientation: "orientation", sort: "sort" }, ngImport: i0, template: "<mat-chip-listbox\n cdkDropList\n [cdkDropListOrientation]=\"orientation\"\n (cdkDropListDropped)=\"onDrop($event)\">\n <mat-chip\n [disabled]=\"!sorts.length\"\n [highlighted]=\"true\"\n (click)=\"onClearClick()\"\n ><mat-icon matChipAvatar fontIcon=\"clear_all\"></mat-icon>Clear All</mat-chip\n >\n @for (column of sorts; track $index) {\n <mat-chip\n class=\"mat-sort-header\"\n cdkDrag\n (click)=\"onChipClick(column.active)\"\n (removed)=\"onChipRemoved(column.active)\">\n <div\n matChipAvatar\n class=\"mat-sort-header-container mat-sort-header-sorted mat-focus-indicator\"\n [class.mat-sort-header-descending]=\"column.direction === 'desc'\"\n [class.mat-sort-header-ascending]=\"column.direction === 'asc'\"\n [class.mat-sort-header-animations-disabled]=\"\n _animationModule === 'NoopAnimations'\n \">\n <div class=\"mat-sort-header-arrow\">\n <svg viewBox=\"0 -960 960 960\" focusable=\"false\" aria-hidden=\"true\">\n <path\n d=\"M440-240v-368L296-464l-56-56 240-240 240 240-56 56-144-144v368h-80Z\" />\n </svg>\n </div>\n </div>\n {{ column.active }}\n <button matChipRemove>\n <mat-icon>clear</mat-icon>\n </button>\n </mat-chip>\n }\n</mat-chip-listbox>\n", styles: [".cdk-drag-placeholder{opacity:0}.cdk-drag-animating{transition:transform .15s cubic-bezier(0,0,.2,1)}.cdk-drag-preview{box-sizing:border-box;box-shadow:0 5px 5px -3px #0003,0 8px 10px 1px #00000024,0 3px 14px 2px #0000001f;overflow:hidden}.mat-mdc-chip-listbox.mat-mdc-chip-set.cdk-drop-list .cdk-drop-list-dragging{transition:transform .15s cubic-bezier(0,0,.2,1)}.mat-mdc-chip.mat-sort-header{background-color:var(--mat-sys-surface, #ffffff);transition:background-color .1s cubic-bezier(0,0,.2,1),box-shadow .1s cubic-bezier(0,0,.2,1)}.mat-mdc-chip.mat-sort-header:hover{cursor:move}.mat-mdc-chip.mat-sort-header:hover:after{opacity:0}.mat-mdc-chip.mat-sort-header:focus:after{opacity:0}.mat-mdc-chip.mat-sort-header:active{box-shadow:0 5px 5px -3px #0003,0 8px 10px 1px #00000024,0 3px 14px 2px #0000001f}.mat-sort-header-content{display:flex;align-items:center}.mat-sort-header-position-before{flex-direction:row-reverse}@keyframes _mat-sort-header-recently-cleared-ascending{0%{transform:translateY(0);opacity:1}to{transform:translateY(-25%);opacity:0}}@keyframes _mat-sort-header-recently-cleared-descending{0%{transform:translateY(0) rotate(180deg);opacity:1}to{transform:translateY(25%) rotate(180deg);opacity:0}}.mat-sort-header-arrow{height:12px;width:12px;position:relative;transition:transform 225ms cubic-bezier(.4,0,.2,1),opacity 225ms cubic-bezier(.4,0,.2,1);opacity:0;overflow:visible;color:var(--mat-sort-arrow-color, var(--mat-app-on-surface))}.mat-sort-header.cdk-keyboard-focused .mat-sort-header-arrow,.mat-sort-header.cdk-program-focused .mat-sort-header-arrow,.mat-sort-header:hover .mat-sort-header-arrow{opacity:.54}.mat-sort-header .mat-sort-header-sorted .mat-sort-header-arrow{opacity:1}.mat-sort-header-descending .mat-sort-header-arrow{transform:rotate(180deg)}.mat-sort-header-recently-cleared-ascending .mat-sort-header-arrow{transform:translateY(-25%);transition:none;animation:_mat-sort-header-recently-cleared-ascending 225ms cubic-bezier(.4,0,.2,1) forwards}.mat-sort-header-recently-cleared-descending .mat-sort-header-arrow{transition:none;animation:_mat-sort-header-recently-cleared-descending 225ms cubic-bezier(.4,0,.2,1) forwards}.mat-sort-header-animations-disabled .mat-sort-header-arrow{transition-duration:0ms;animation-duration:0ms}.mat-sort-header-arrow svg{width:24px;height:24px;fill:currentColor;position:absolute;top:50%;left:50%;margin:-12px 0 0 -12px;transform:translateZ(0)}.mat-sort-header-arrow,[dir=rtl] .mat-sort-header-position-before .mat-sort-header-arrow{margin:0 0 0 6px}.mat-sort-header-position-before .mat-sort-header-arrow,[dir=rtl] .mat-sort-header-arrow{margin:0 6px 0 0}.cdk-drop-list-dragging .mat-sort-header:not(.cdk-drag-placeholder){background-color:var(--mat-sys-surface-dim, #ffffff);transition:transform .15s cubic-bezier(0,0,.2,1)}\n"], dependencies: [{ kind: "directive", type: CdkDropList, selector: "[cdkDropList], cdk-drop-list", inputs: ["cdkDropListConnectedTo", "cdkDropListData", "cdkDropListOrientation", "id", "cdkDropListLockAxis", "cdkDropListDisabled", "cdkDropListSortingDisabled", "cdkDropListEnterPredicate", "cdkDropListSortPredicate", "cdkDropListAutoScrollDisabled", "cdkDropListAutoScrollStep", "cdkDropListElementContainer"], outputs: ["cdkDropListDropped", "cdkDropListEntered", "cdkDropListExited", "cdkDropListSorted"], exportAs: ["cdkDropList"] }, { kind: "directive", type: CdkDrag, selector: "[cdkDrag]", inputs: ["cdkDragData", "cdkDragLockAxis", "cdkDragRootElement", "cdkDragBoundary", "cdkDragStartDelay", "cdkDragFreeDragPosition", "cdkDragDisabled", "cdkDragConstrainPosition", "cdkDragPreviewClass", "cdkDragPreviewContainer", "cdkDragScale"], outputs: ["cdkDragStarted", "cdkDragReleased", "cdkDragEnded", "cdkDragEntered", "cdkDragExited", "cdkDragDropped", "cdkDragMoved"], exportAs: ["cdkDrag"] }, { kind: "ngmodule", type: MatChipsModule }, { kind: "component", type: i1$1.MatChip, selector: "mat-basic-chip, [mat-basic-chip], mat-chip, [mat-chip]", inputs: ["role", "id", "aria-label", "aria-description", "value", "color", "removable", "highlighted", "disableRipple", "disabled"], outputs: ["removed", "destroyed"], exportAs: ["matChip"] }, { kind: "directive", type: i1$1.MatChipAvatar, selector: "mat-chip-avatar, [matChipAvatar]" }, { kind: "component", type: i1$1.MatChipListbox, selector: "mat-chip-listbox", inputs: ["multiple", "aria-orientation", "selectable", "compareWith", "required", "hideSingleSelectionIndicator", "value"], outputs: ["change"] }, { kind: "directive", type: i1$1.MatChipRemove, selector: "[matChipRemove]" }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }] });
460
624
  }
461
625
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: MatMultiSortControlComponent, decorators: [{
462
626
  type: Component,
@@ -468,12 +632,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
468
632
  }] } });
469
633
 
470
634
  /*
471
- * Public API Surface of lib
635
+ * Public API surface of the library
472
636
  */
473
637
 
474
638
  /**
475
639
  * Generated bundle index. Do not edit.
476
640
  */
477
641
 
478
- export { MatMultiSortControlComponent, MatMultiSortDirective, MatMultiSortHeaderComponent, MatMultiSortTableDataSource, MatTableColumnConfigComponent, MatTableColumnConfigTriggerDirective, MultiCriterionSort, TABLE_COLUMNS };
642
+ export { COLUMN_CONFIG_PERSISTENCE_ENABLED, COLUMN_CONFIG_PERSISTENCE_KEY, COLUMN_CONFIG_PERSISTENCE_STORAGE, MatMultiSortControlComponent, MatMultiSortDirective, MatMultiSortHeaderComponent, MatMultiSortTableDataSource, MatTableColumnConfigComponent, MatTableColumnConfigPersistenceService, MatTableColumnConfigTriggerDirective, MultiCriterionSort, SORT_PERSISTENCE_ENABLED, SORT_PERSISTENCE_KEY, SORT_PERSISTENCE_STORAGE };
479
643
  //# sourceMappingURL=ngx-mat-table-multi-sort.mjs.map