ngx-mat-table-multi-sort 19.6.0 → 20.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -1,5 +1,396 @@
1
+ import * as i0 from '@angular/core';
2
+ import { InjectionToken, EventEmitter, WritableSignal, OnInit, OnDestroy, ComponentRef } from '@angular/core';
3
+ import { MatSort, Sort, SortDirection, MatSortable, MatSortHeader } from '@angular/material/sort';
4
+ import { CdkDragDrop, DropListOrientation } from '@angular/cdk/drag-drop';
5
+ import { MatPaginator } from '@angular/material/paginator';
6
+ import { MatTableDataSource } from '@angular/material/table';
7
+ import { Observable } from 'rxjs';
8
+
1
9
  /**
2
- * Generated bundle index. Do not edit.
10
+ * Represents the configuration for a table column.
11
+ *
12
+ * @template T - The type of the data object that the table displays.
3
13
  */
4
- /// <amd-module name="ngx-mat-table-multi-sort" />
5
- export * from './public-api';
14
+ interface TableColumn<T> {
15
+ id: keyof T;
16
+ label: string;
17
+ visible: boolean;
18
+ }
19
+ /**
20
+ * Injection token for the storage mechanism used to persist column configuration.
21
+ *
22
+ * This token can be used to provide a custom storage implementation for saving
23
+ * and retrieving the state of table column configurations.
24
+ *
25
+ */
26
+ declare const COLUMN_CONFIG_PERSISTENCE_STORAGE: InjectionToken<Storage>;
27
+ /**
28
+ * Injection token used to enable or disable column configuration persistence.
29
+ *
30
+ * This token can be provided with a boolean value to indicate whether the
31
+ * column configurations should be persisted (e.g., in local storage or a database).
32
+ *
33
+ */
34
+ declare const COLUMN_CONFIG_PERSISTENCE_ENABLED: InjectionToken<boolean>;
35
+ /**
36
+ * Injection token for the column configuration persistence key.
37
+ * This token is used to provide a unique key for persisting column configurations.
38
+ */
39
+ declare const COLUMN_CONFIG_PERSISTENCE_KEY: InjectionToken<string>;
40
+
41
+ /**
42
+ * Injection token for the storage mechanism used to persist sorting state.
43
+ *
44
+ * This token can be used to provide a custom storage implementation for persisting
45
+ * the sorting state of a table. By default, it can be set to use localStorage, sessionStorage,
46
+ * or any other storage mechanism that implements the Storage interface.
47
+ *
48
+ */
49
+ declare const SORT_PERSISTENCE_STORAGE: InjectionToken<Storage>;
50
+ /**
51
+ * Injection token used to enable or disable the persistence of sorting state.
52
+ *
53
+ * This token can be provided in the application's dependency injection system
54
+ * to control whether the sorting state of a table should be persisted across
55
+ * sessions or not.
56
+ *
57
+ * @example
58
+ * // To enable sort persistence:
59
+ * providers: [
60
+ * { provide: SORT_PERSISTENCE_ENABLED, useValue: true }
61
+ * ]
62
+ *
63
+ * @example
64
+ * // To disable sort persistence:
65
+ * providers: [
66
+ * { provide: SORT_PERSISTENCE_ENABLED, useValue: false }
67
+ * ]
68
+ */
69
+ declare const SORT_PERSISTENCE_ENABLED: InjectionToken<boolean>;
70
+ /**
71
+ * Injection token for the key used to persist sorting state.
72
+ *
73
+ * This token can be used to provide a custom key for storing
74
+ * the sorting state in a persistence layer, such as local storage
75
+ * or a database.
76
+ */
77
+ declare const SORT_PERSISTENCE_KEY: InjectionToken<string>;
78
+ declare class MatMultiSortDirective extends MatSort {
79
+ private readonly storage;
80
+ private persistenceKey;
81
+ isPersistenceEnabled: boolean;
82
+ /**
83
+ * Event emitter that fires when the persistence state changes.
84
+ *
85
+ * This output emits an array of Sort objects whenever the sorting state
86
+ * is persisted or restored from storage. This can be useful for components
87
+ * that need to react to changes in the persisted sorting configuration.
88
+ *
89
+ * @example
90
+ * ```html
91
+ * <table mat-table [dataSource]="dataSource" matMultiSort
92
+ * (persistenceChanged)="onPersistenceChanged($event)">
93
+ * ```
94
+ *
95
+ * @example
96
+ * ```typescript
97
+ * onPersistenceChanged(sorts: Sort[]): void {
98
+ * console.log('Sorting state changed:', sorts);
99
+ * // Handle the updated sorting configuration
100
+ * }
101
+ * ```
102
+ */
103
+ readonly persistenceChanged: EventEmitter<Sort[]>;
104
+ /**
105
+ * A writable signal that holds an array of Sort objects.
106
+ * This signal is used to manage the sorting state of the table.
107
+ *
108
+ * @readonly
109
+ */
110
+ readonly _sorts: WritableSignal<Sort[]>;
111
+ /**
112
+ * Gets the key used for column configuration persistence.
113
+ *
114
+ * @returns {string} The key used for column configuration persistence.
115
+ */
116
+ get key(): string;
117
+ constructor();
118
+ /**
119
+ * Retrieves the sort direction for a given column ID.
120
+ *
121
+ * @param id - The ID of the column to get the sort direction for.
122
+ * @returns The sort direction ('asc', 'desc', or '') for the specified column ID.
123
+ */
124
+ getSortDirection(id: string): SortDirection;
125
+ /**
126
+ * Gets the sort index of the given column ID.
127
+ *
128
+ * @param id - The ID of the column to get the sort index for.
129
+ * @returns The sort index of the column, or -1 if the column is not active.
130
+ */
131
+ getSortIndex(id: string): number;
132
+ sort(sortable: MatSortable): void;
133
+ /**
134
+ * Removes a sort level by its identifier.
135
+ * If the sort level is not found, the method returns without making any changes.
136
+ *
137
+ * @param id - The identifier of the sort level to be removed.
138
+ * @returns void
139
+ */
140
+ removeSortLevel(id: string): void;
141
+ /**
142
+ * Reorders the sort level by moving an item in the sort array from a previous index to a current index.
143
+ * If the previous index is the same as the current index, the function returns without making any changes.
144
+ *
145
+ * @param previousIndex - The index of the item to be moved.
146
+ * @param currentIndex - The index to which the item should be moved.
147
+ */
148
+ reorderSortLevel(previousIndex: number, currentIndex: number): void;
149
+ /**
150
+ * Toggles the sort direction for the given column ID.
151
+ *
152
+ * @param id - The unique identifier of the column to toggle the sort direction for.
153
+ * @returns void
154
+ */
155
+ toggleSortDirection(id: string): void;
156
+ /**
157
+ * Clears the current sorting state.
158
+ *
159
+ * @param id - The unique identifier of the column to toggle the sort direction for.
160
+ * @returns void
161
+ */
162
+ clearSorting(): void;
163
+ private persistSortSettings;
164
+ /**
165
+ * Sets the persistence key for storing sort settings and optionally overwrites the persisted value.
166
+ *
167
+ * @param key - The key to be used for persisting sort settings.
168
+ * @param overwritePersistedValue - If true, the current sort settings will be persisted immediately, overwriting any existing value. Defaults to false.
169
+ *
170
+ * @returns void
171
+ */
172
+ setPersistenceKey(key: string, overwritePersistedValue?: boolean): void;
173
+ static ɵfac: i0.ɵɵFactoryDeclaration<MatMultiSortDirective, never>;
174
+ static ɵdir: i0.ɵɵDirectiveDeclaration<MatMultiSortDirective, "[matMultiSort]", ["matMultiSort"], {}, { "persistenceChanged": "persistenceChanged"; }, never, never, true, never>;
175
+ }
176
+
177
+ declare class MatTableColumnConfigComponent<T> implements OnInit, OnDestroy {
178
+ private readonly persistenceService;
179
+ private subscription;
180
+ columns: TableColumn<T>[];
181
+ ngOnInit(): void;
182
+ ngOnDestroy(): void;
183
+ /**
184
+ * Handles the event when a dragged column is dropped.
185
+ * This method updates the order of columns based on the drag and drop action.
186
+ *
187
+ * @param event - The event object containing information about the drag and drop action.
188
+ */
189
+ onColumnDropped(event: CdkDragDrop<T>): void;
190
+ /**
191
+ * Toggles the visibility of a column based on its identifier.
192
+ *
193
+ * @param id - The identifier of the column whose visibility is to be changed.
194
+ */
195
+ onColumnVisibilityChanged(id: keyof T): void;
196
+ /**
197
+ * Sets all columns in the table to visible and updates the persisted column configuration.
198
+ *
199
+ * Iterates through the `columns` array, setting each column's `visible` property to `true`.
200
+ * Then, updates the `persistenceService.columns` property to reflect the new visibility state.
201
+ */
202
+ selectAllColumns(): void;
203
+ /**
204
+ * Deselects all columns by setting their `visible` property to `false`.
205
+ * Updates the persisted columns state via the `persistenceService`.
206
+ *
207
+ * @remarks
208
+ * This method iterates through all columns in the `columns` array and hides each one.
209
+ * After updating the visibility, it synchronizes the state with the persistence service.
210
+ */
211
+ deselectAllColumns(): void;
212
+ /**
213
+ * Inverts the visibility state of all columns in the `columns` array.
214
+ * Each column's `visible` property is toggled between `true` and `false`.
215
+ * After updating the visibility, the modified columns array is assigned to the persistence service
216
+ * to persist the new visibility state.
217
+ */
218
+ invertColumnSelection(): void;
219
+ static ɵfac: i0.ɵɵFactoryDeclaration<MatTableColumnConfigComponent<any>, never>;
220
+ static ɵcmp: i0.ɵɵComponentDeclaration<MatTableColumnConfigComponent<any>, "mat-table-column-config", never, {}, {}, never, never, true, never>;
221
+ }
222
+
223
+ declare class MatTableColumnConfigTriggerDirective<T> {
224
+ private readonly elementRef;
225
+ private readonly overlay;
226
+ private readonly viewContainerRef;
227
+ private _componentRef;
228
+ /**
229
+ * Gets the reference to the MatTableColumnConfigComponent.
230
+ *
231
+ * @returns {ComponentRef<MatTableColumnConfigComponent<T>> | null}
232
+ * The reference to the MatTableColumnConfigComponent if it exists, otherwise null.
233
+ */
234
+ get componentRef(): ComponentRef<MatTableColumnConfigComponent<T>> | null;
235
+ onClick(): void;
236
+ static ɵfac: i0.ɵɵFactoryDeclaration<MatTableColumnConfigTriggerDirective<any>, never>;
237
+ static ɵdir: i0.ɵɵDirectiveDeclaration<MatTableColumnConfigTriggerDirective<any>, "[matTableColumnConfigTrigger]", ["matTableColumnConfigTrigger"], {}, {}, never, never, true, never>;
238
+ }
239
+
240
+ /**
241
+ * Sorts two items based on multiple sorting criteria.
242
+ *
243
+ * @description To do this, we iterate over each sort level and compare the values of the active column. If the values are equal, we move to the next sort level. If all sort levels are equal, we return 0.
244
+ *
245
+ * @template T - The type of the items being sorted.
246
+ * @param {T} a - The first item to compare.
247
+ * @param {T} b - The second item to compare.
248
+ * @param {Sort[]} sorts - An array of sorting criteria, where each criterion specifies the property to sort by and the direction of sorting.
249
+ * @returns {number} - A negative number if `a` should come before `b`, a positive number if `a` should come after `b`, or 0 if they are considered equal.
250
+ */
251
+ declare function MultiCriterionSort<T>(a: T, b: T, sorts: Sort[]): number;
252
+ /**
253
+ * A data source class that extends `MatTableDataSource` to support multi-column sorting.
254
+ *
255
+ * @template T The type of data that the table displays.
256
+ * @template P The type of paginator used, defaults to `MatPaginator`.
257
+ *
258
+ * @extends MatTableDataSource<T, P>
259
+ */
260
+ declare class MatMultiSortTableDataSource<T, P extends MatPaginator = MatPaginator> extends MatTableDataSource<T, P> {
261
+ get sort(): MatMultiSortDirective | null;
262
+ set sort(sort: MatMultiSortDirective | null);
263
+ constructor(initialData?: T[]);
264
+ private sortDataFunction;
265
+ }
266
+
267
+ declare class MatTableColumnConfigPersistenceService<T> {
268
+ private readonly columns$;
269
+ private readonly storage;
270
+ private persistenceKey;
271
+ isPersistenceEnabled: boolean;
272
+ /**
273
+ * Gets the current table columns configuration.
274
+ *
275
+ * @returns {TableColumn<T>[]} An array of table columns.
276
+ */
277
+ get columns(): TableColumn<T>[];
278
+ /**
279
+ * Sets the columns configuration for the table and persists the configuration.
280
+ *
281
+ * @param value - An array of `TableColumn<T>` representing the new column configuration.
282
+ */
283
+ set columns(value: TableColumn<T>[]);
284
+ /**
285
+ * Gets the key used for column configuration persistence.
286
+ *
287
+ * @returns {string} The key used for column configuration persistence.
288
+ */
289
+ get key(): string;
290
+ constructor();
291
+ /**
292
+ * Retrieves an observable stream of table columns.
293
+ *
294
+ * @returns {Observable<TableColumn<T>[]>} An observable that emits an array of table columns.
295
+ */
296
+ getColumns(): Observable<TableColumn<T>[]>;
297
+ private persistColumnConfig;
298
+ /**
299
+ * Sets the persistence key for storing column configurations.
300
+ *
301
+ * @param key - The key to be used for persistence.
302
+ * @param overwritePersistedValue - If true, the current column configuration will be persisted immediately overwriting any exising value stored under the new key.
303
+ * If false, the persisted column configuration will be loaded and applied.
304
+ * Defaults to false.
305
+ *
306
+ * @returns void
307
+ */
308
+ setPersistenceKey(key: string, overwritePersistedValue?: boolean): void;
309
+ static ɵfac: i0.ɵɵFactoryDeclaration<MatTableColumnConfigPersistenceService<any>, never>;
310
+ static ɵprov: i0.ɵɵInjectableDeclaration<MatTableColumnConfigPersistenceService<any>>;
311
+ }
312
+
313
+ declare class MatMultiSortHeaderComponent extends MatSortHeader implements OnInit {
314
+ readonly _sort: MatMultiSortDirective;
315
+ /**
316
+ * Retrieves the sort direction for the current column.
317
+ *
318
+ * @returns {SortDirection} The sort direction for the column identified by this.id.
319
+ */
320
+ get sortDirection(): SortDirection;
321
+ /**
322
+ * Gets the sort index for the current column.
323
+ *
324
+ * @returns {number} The index of the sort order for this column.
325
+ */
326
+ get sortIndex(): number;
327
+ _isSorted(): boolean;
328
+ _toggleOnInteraction(): void;
329
+ static ɵfac: i0.ɵɵFactoryDeclaration<MatMultiSortHeaderComponent, never>;
330
+ static ɵcmp: i0.ɵɵComponentDeclaration<MatMultiSortHeaderComponent, "[mat-multi-sort-header]", ["matMultiSortHeader"], {}, {}, never, ["*"], true, never>;
331
+ }
332
+
333
+ declare class MatMultiSortControlComponent {
334
+ /**
335
+ * Injects the ANIMATION_MODULE_TYPE token, which indicates the type of animation module being used.
336
+ * This is an optional dependency and may be undefined if the animation module is not provided.
337
+ *
338
+ * @readonly
339
+ * @type {ANIMATION_MODULE_TYPE | undefined}
340
+ */
341
+ readonly _animationModule: "NoopAnimations" | "BrowserAnimations" | null;
342
+ /**
343
+ * Specifies the orientation of the drop list.
344
+ * Can be either "horizontal" or "vertical".
345
+ *
346
+ * @type {DropListOrientation}
347
+ * @default "horizontal"
348
+ */
349
+ orientation: DropListOrientation;
350
+ /**
351
+ * An optional input property that accepts an instance of `MatMultiSortDirective`.
352
+ * This directive is used to control the sorting behavior of the table.
353
+ */
354
+ sort?: MatMultiSortDirective;
355
+ /**
356
+ * Retrieves the array of Sort objects from the current sort instance.
357
+ * If the sort instance is not defined, it returns an empty array.
358
+ *
359
+ * @returns {Sort[]} An array of Sort objects or an empty array if no sorts are defined.
360
+ */
361
+ get sorts(): Sort[];
362
+ /**
363
+ * Handles the click event on a sort chip.
364
+ * Toggles the sort direction for the given sort ID.
365
+ *
366
+ * @param id - The identifier of the sort field to toggle.
367
+ * @returns void
368
+ */
369
+ onChipClick(id: string): void;
370
+ /**
371
+ * Handles the event when a sort chip is removed.
372
+ *
373
+ * @param id - The identifier of the sort level to be removed.
374
+ * @returns void
375
+ */
376
+ onChipRemoved(id: string): void;
377
+ /**
378
+ * Clears the current sorting applied to the table.
379
+ *
380
+ * @param id - The identifier of the sort level to be removed.
381
+ * @returns void
382
+ */
383
+ onClearClick(): void;
384
+ /**
385
+ * Handles the drop event for drag-and-drop sorting.
386
+ * Reorders the sort levels based on the previous and current indices.
387
+ *
388
+ * @param event - The drag-and-drop event containing the previous and current indices of the sort order.
389
+ */
390
+ onDrop(event: CdkDragDrop<Sort[]>): void;
391
+ static ɵfac: i0.ɵɵFactoryDeclaration<MatMultiSortControlComponent, never>;
392
+ static ɵcmp: i0.ɵɵComponentDeclaration<MatMultiSortControlComponent, "mat-multi-sort-control", never, { "orientation": { "alias": "orientation"; "required": false; }; "sort": { "alias": "sort"; "required": false; }; }, {}, never, never, true, never>;
393
+ }
394
+
395
+ 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 };
396
+ export type { TableColumn };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ngx-mat-table-multi-sort",
3
- "version": "19.6.0",
3
+ "version": "20.0.0",
4
4
  "preview": false,
5
5
  "license": "MIT",
6
6
  "author": {
@@ -30,13 +30,13 @@
30
30
  "tslib": "^2.8.1"
31
31
  },
32
32
  "peerDependencies": {
33
- "@angular/animations": "^19.2.13",
34
- "@angular/cdk": "^19.2.17",
35
- "@angular/common": "^19.2.13",
36
- "@angular/core": "^19.2.13",
37
- "@angular/forms": "^19.2.13",
38
- "@angular/localize": "19.2.14",
39
- "@angular/material": "^19.2.17",
33
+ "@angular/animations": "^20.0.5",
34
+ "@angular/cdk": "^20.0.4",
35
+ "@angular/common": "^20.0.5",
36
+ "@angular/core": "^20.0.5",
37
+ "@angular/forms": "^20.0.5",
38
+ "@angular/localize": "20.0.5",
39
+ "@angular/material": "^20.0.4",
40
40
  "rxjs": "^7.8.1",
41
41
  "zone.js": "^0.15.0"
42
42
  },
@@ -1,65 +0,0 @@
1
- import { CdkDragDrop, DropListOrientation } from "@angular/cdk/drag-drop";
2
- import { Sort } from "@angular/material/sort";
3
- import { MatMultiSortDirective } from "../mat-multi-sort.directive";
4
- import * as i0 from "@angular/core";
5
- export declare class MatMultiSortControlComponent {
6
- /**
7
- * Injects the ANIMATION_MODULE_TYPE token, which indicates the type of animation module being used.
8
- * This is an optional dependency and may be undefined if the animation module is not provided.
9
- *
10
- * @readonly
11
- * @type {ANIMATION_MODULE_TYPE | undefined}
12
- */
13
- readonly _animationModule: "NoopAnimations" | "BrowserAnimations" | null;
14
- /**
15
- * Specifies the orientation of the drop list.
16
- * Can be either "horizontal" or "vertical".
17
- *
18
- * @type {DropListOrientation}
19
- * @default "horizontal"
20
- */
21
- orientation: DropListOrientation;
22
- /**
23
- * An optional input property that accepts an instance of `MatMultiSortDirective`.
24
- * This directive is used to control the sorting behavior of the table.
25
- */
26
- sort?: MatMultiSortDirective;
27
- /**
28
- * Retrieves the array of Sort objects from the current sort instance.
29
- * If the sort instance is not defined, it returns an empty array.
30
- *
31
- * @returns {Sort[]} An array of Sort objects or an empty array if no sorts are defined.
32
- */
33
- get sorts(): Sort[];
34
- /**
35
- * Handles the click event on a sort chip.
36
- * Toggles the sort direction for the given sort ID.
37
- *
38
- * @param id - The identifier of the sort field to toggle.
39
- * @returns void
40
- */
41
- onChipClick(id: string): void;
42
- /**
43
- * Handles the event when a sort chip is removed.
44
- *
45
- * @param id - The identifier of the sort level to be removed.
46
- * @returns void
47
- */
48
- onChipRemoved(id: string): void;
49
- /**
50
- * Clears the current sorting applied to the table.
51
- *
52
- * @param id - The identifier of the sort level to be removed.
53
- * @returns void
54
- */
55
- onClearClick(): void;
56
- /**
57
- * Handles the drop event for drag-and-drop sorting.
58
- * Reorders the sort levels based on the previous and current indices.
59
- *
60
- * @param event - The drag-and-drop event containing the previous and current indices of the sort order.
61
- */
62
- onDrop(event: CdkDragDrop<Sort[]>): void;
63
- static ɵfac: i0.ɵɵFactoryDeclaration<MatMultiSortControlComponent, never>;
64
- static ɵcmp: i0.ɵɵComponentDeclaration<MatMultiSortControlComponent, "mat-multi-sort-control", never, { "orientation": { "alias": "orientation"; "required": false; }; "sort": { "alias": "sort"; "required": false; }; }, {}, never, never, true, never>;
65
- }
@@ -1,23 +0,0 @@
1
- import { OnInit } from "@angular/core";
2
- import { MatSortHeader, SortDirection } from "@angular/material/sort";
3
- import { MatMultiSortDirective } from "../mat-multi-sort.directive";
4
- import * as i0 from "@angular/core";
5
- export declare class MatMultiSortHeaderComponent extends MatSortHeader implements OnInit {
6
- readonly _sort: MatMultiSortDirective;
7
- /**
8
- * Retrieves the sort direction for the current column.
9
- *
10
- * @returns {SortDirection} The sort direction for the column identified by this.id.
11
- */
12
- get sortDirection(): SortDirection;
13
- /**
14
- * Gets the sort index for the current column.
15
- *
16
- * @returns {number} The index of the sort order for this column.
17
- */
18
- get sortIndex(): number;
19
- _isSorted(): boolean;
20
- _toggleOnInteraction(): void;
21
- static ɵfac: i0.ɵɵFactoryDeclaration<MatMultiSortHeaderComponent, never>;
22
- static ɵcmp: i0.ɵɵComponentDeclaration<MatMultiSortHeaderComponent, "[mat-multi-sort-header]", ["matMultiSortHeader"], {}, {}, never, ["*"], true, never>;
23
- }
@@ -1,30 +0,0 @@
1
- import { MatPaginator } from "@angular/material/paginator";
2
- import { Sort } from "@angular/material/sort";
3
- import { MatTableDataSource } from "@angular/material/table";
4
- import { MatMultiSortDirective } from "./mat-multi-sort.directive";
5
- /**
6
- * Sorts two items based on multiple sorting criteria.
7
- *
8
- * @description To do this, we iterate over each sort level and compare the values of the active column. If the values are equal, we move to the next sort level. If all sort levels are equal, we return 0.
9
- *
10
- * @template T - The type of the items being sorted.
11
- * @param {T} a - The first item to compare.
12
- * @param {T} b - The second item to compare.
13
- * @param {Sort[]} sorts - An array of sorting criteria, where each criterion specifies the property to sort by and the direction of sorting.
14
- * @returns {number} - A negative number if `a` should come before `b`, a positive number if `a` should come after `b`, or 0 if they are considered equal.
15
- */
16
- export declare function MultiCriterionSort<T>(a: T, b: T, sorts: Sort[]): number;
17
- /**
18
- * A data source class that extends `MatTableDataSource` to support multi-column sorting.
19
- *
20
- * @template T The type of data that the table displays.
21
- * @template P The type of paginator used, defaults to `MatPaginator`.
22
- *
23
- * @extends MatTableDataSource<T, P>
24
- */
25
- export declare class MatMultiSortTableDataSource<T, P extends MatPaginator = MatPaginator> extends MatTableDataSource<T, P> {
26
- get sort(): MatMultiSortDirective | null;
27
- set sort(sort: MatMultiSortDirective | null);
28
- constructor(initialData?: T[]);
29
- private sortDataFunction;
30
- }
@@ -1,118 +0,0 @@
1
- import { InjectionToken, WritableSignal } from "@angular/core";
2
- import { MatSort, MatSortable, MatSortDefaultOptions, Sort, SortDirection } from "@angular/material/sort";
3
- import * as i0 from "@angular/core";
4
- /**
5
- * Injection token for the storage mechanism used to persist sorting state.
6
- *
7
- * This token can be used to provide a custom storage implementation for persisting
8
- * the sorting state of a table. By default, it can be set to use localStorage, sessionStorage,
9
- * or any other storage mechanism that implements the Storage interface.
10
- *
11
- */
12
- export declare const SORT_PERSISTENCE_STORAGE: InjectionToken<Storage>;
13
- /**
14
- * Injection token used to enable or disable the persistence of sorting state.
15
- *
16
- * This token can be provided in the application's dependency injection system
17
- * to control whether the sorting state of a table should be persisted across
18
- * sessions or not.
19
- *
20
- * @example
21
- * // To enable sort persistence:
22
- * providers: [
23
- * { provide: SORT_PERSISTENCE_ENABLED, useValue: true }
24
- * ]
25
- *
26
- * @example
27
- * // To disable sort persistence:
28
- * providers: [
29
- * { provide: SORT_PERSISTENCE_ENABLED, useValue: false }
30
- * ]
31
- */
32
- export declare const SORT_PERSISTENCE_ENABLED: InjectionToken<boolean>;
33
- /**
34
- * Injection token for the key used to persist sorting state.
35
- *
36
- * This token can be used to provide a custom key for storing
37
- * the sorting state in a persistence layer, such as local storage
38
- * or a database.
39
- */
40
- export declare const SORT_PERSISTENCE_KEY: InjectionToken<string>;
41
- export declare class MatMultiSortDirective extends MatSort {
42
- isPersistenceEnabled: boolean;
43
- readonly initialKey: string;
44
- private readonly storage;
45
- private readonly persistenceChanged;
46
- private _key;
47
- /**
48
- * A writable signal that holds an array of Sort objects.
49
- * This signal is used to manage the sorting state of the table.
50
- *
51
- * @readonly
52
- */
53
- readonly _sorts: WritableSignal<Sort[]>;
54
- /**
55
- * Gets the key used for column configuration persistence.
56
- *
57
- * @returns {string} The key used for column configuration persistence.
58
- */
59
- get key(): string;
60
- constructor(isPersistenceEnabled: boolean, initialKey: string, storage: Storage, defaultOptions?: MatSortDefaultOptions | undefined);
61
- /**
62
- * Retrieves the sort direction for a given column ID.
63
- *
64
- * @param id - The ID of the column to get the sort direction for.
65
- * @returns The sort direction ('asc', 'desc', or '') for the specified column ID.
66
- */
67
- getSortDirection(id: string): SortDirection;
68
- /**
69
- * Gets the sort index of the given column ID.
70
- *
71
- * @param id - The ID of the column to get the sort index for.
72
- * @returns The sort index of the column, or -1 if the column is not active.
73
- */
74
- getSortIndex(id: string): number;
75
- sort(sortable: MatSortable): void;
76
- /**
77
- * Removes a sort level by its identifier.
78
- * If the sort level is not found, the method returns without making any changes.
79
- *
80
- * @param id - The identifier of the sort level to be removed.
81
- * @returns void
82
- */
83
- removeSortLevel(id: string): void;
84
- /**
85
- * Reorders the sort level by moving an item in the sort array from a previous index to a current index.
86
- * If the previous index is the same as the current index, the function returns without making any changes.
87
- *
88
- * @param previousIndex - The index of the item to be moved.
89
- * @param currentIndex - The index to which the item should be moved.
90
- */
91
- reorderSortLevel(previousIndex: number, currentIndex: number): void;
92
- /**
93
- * Toggles the sort direction for the given column ID.
94
- *
95
- * @param id - The unique identifier of the column to toggle the sort direction for.
96
- * @returns void
97
- */
98
- toggleSortDirection(id: string): void;
99
- /**
100
- * Clears the current sorting state.
101
- *
102
- * @param id - The unique identifier of the column to toggle the sort direction for.
103
- * @returns void
104
- */
105
- clearSorting(): void;
106
- private persistSortSettings;
107
- /**
108
- * Sets the persistence key for storing sort settings and optionally overwrites the persisted value.
109
- *
110
- * @param key - The key to be used for persisting sort settings.
111
- * @param overwritePersistedValue - If true, the current sort settings will be persisted immediately, overwriting any existing value. Defaults to false.
112
- *
113
- * @returns void
114
- */
115
- setPersistenceKey(key: string, overwritePersistedValue?: boolean): void;
116
- static ɵfac: i0.ɵɵFactoryDeclaration<MatMultiSortDirective, [{ optional: true; }, { optional: true; }, { optional: true; }, { optional: true; }]>;
117
- static ɵdir: i0.ɵɵDirectiveDeclaration<MatMultiSortDirective, "[matMultiSort]", ["matMultiSort"], {}, { "persistenceChanged": "persistenceChanged"; }, never, never, true, never>;
118
- }