@intellegens/cornerstone-client-angular-material 0.0.45

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/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # @intellegens/cornerstone-client-angular-material
2
+
3
+ Contains directives and overrides which improve `Angular Material UI` if used with `@intellegens/cornerstone-client-angular` and `@intellegens/cornerstone-client` libraries.
4
+
5
+ ## MatPaginatorIntlOverrides
6
+
7
+ Custom paginator service to adjust the label for the paginator.
8
+
9
+ Used on `MatTablePaginationDirective`:
10
+
11
+ ```typescript
12
+ @Directive({
13
+ selector: 'mat-paginator',
14
+ providers: [{ provide: MatPaginatorIntl, useClass: MatPaginatorIntlOverrides }],
15
+ standalone: true,
16
+ })
17
+ ```
18
+
19
+ ## MatTableSortDirective
20
+
21
+ Directive used to pass data to the `CollectionViewAdapter` and reverse the default direction of shown table header sorting arrows.
22
+
23
+ Usage example:
24
+
25
+ ```html
26
+ <table mat-table matSort [adapter]="_adapter" [dataSource]="_tableDataSource">
27
+ <!-- table contents -->
28
+ </table>
29
+ ```
30
+
31
+ ## MatTablePaginationDirective
32
+
33
+ Directive used to pass data to the `CollectionViewAdapter`, uses `MatPaginatorIntlOverrides` to change pagination UI.
34
+
35
+ Usage example:
36
+
37
+ ```html
38
+ <mat-paginator
39
+ [adapter]="_adapter"
40
+ [pageSizeOptions]="[10, 20, 50]"
41
+ [pageSize]="_adapter.pageSize"
42
+ [pageIndex]="(currentPage ?? 1) - 1"
43
+ [length]="_totalItemsCount()"
44
+ (page)="$event"
45
+ ></mat-paginator>
46
+ ```
@@ -0,0 +1,107 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Injectable, inject, input, Directive } from '@angular/core';
3
+ import { MatPaginatorIntl, MatPaginator } from '@angular/material/paginator';
4
+ import { MatSort } from '@angular/material/sort';
5
+ import { ReadSelectedOrderingDirection } from '@intellegens/cornerstone-client-angular';
6
+
7
+ /**
8
+ * Custom paginator service to adjust the label for the paginator.
9
+ */
10
+ class MatPaginatorIntlOverrides extends MatPaginatorIntl {
11
+ getRangeLabel = (page, pageSize, length) => {
12
+ if (length === 0) {
13
+ return 'Page 1 of 1';
14
+ }
15
+ const isLengthValid = length && length !== Infinity;
16
+ return isLengthValid ? `Page ${page + 1} of ${Math.ceil(length / pageSize)}` : `Page ${page + 1}`;
17
+ };
18
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: MatPaginatorIntlOverrides, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
19
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: MatPaginatorIntlOverrides });
20
+ }
21
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: MatPaginatorIntlOverrides, decorators: [{
22
+ type: Injectable
23
+ }] });
24
+
25
+ /**
26
+ * Directive used to pass data to the `CollectionViewAdapter`, uses `MatPaginatorIntlOverrides` to change pagination UI.
27
+ */
28
+ class MatTablePaginationDirective {
29
+ _matPaginator = inject(MatPaginator);
30
+ adapter = input(...(ngDevMode ? [undefined, { debugName: "adapter" }] : []));
31
+ _subscription;
32
+ ngOnInit() {
33
+ this._subscription = this._matPaginator.page.subscribe((event) => {
34
+ const adapter = this.adapter();
35
+ if (!adapter)
36
+ return;
37
+ const targetPage = event.pageIndex + 1;
38
+ if (event.pageSize !== adapter.pageSize) {
39
+ adapter.setPageSize(event.pageSize);
40
+ }
41
+ else if (targetPage !== adapter.currentPage) {
42
+ adapter.jumpToPage(targetPage);
43
+ }
44
+ });
45
+ }
46
+ ngOnDestroy() {
47
+ this._subscription?.unsubscribe();
48
+ }
49
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: MatTablePaginationDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
50
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.3", type: MatTablePaginationDirective, isStandalone: true, selector: "mat-paginator", inputs: { adapter: { classPropertyName: "adapter", publicName: "adapter", isSignal: true, isRequired: false, transformFunction: null } }, providers: [{ provide: MatPaginatorIntl, useClass: MatPaginatorIntlOverrides }], ngImport: i0 });
51
+ }
52
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: MatTablePaginationDirective, decorators: [{
53
+ type: Directive,
54
+ args: [{
55
+ selector: 'mat-paginator',
56
+ providers: [{ provide: MatPaginatorIntl, useClass: MatPaginatorIntlOverrides }],
57
+ standalone: true,
58
+ }]
59
+ }] });
60
+
61
+ /**
62
+ * Directive used to pass data to the `CollectionViewAdapter` and reverse the default direction of shown table header sorting arrows
63
+ */
64
+ class MatTableSortDirective {
65
+ _matSort = inject(MatSort);
66
+ adapter = input(...(ngDevMode ? [undefined, { debugName: "adapter" }] : []));
67
+ ngOnInit() {
68
+ this._matSort.disableClear = true; // removes "unsorted" option, syncs column header arrows with actual current sort direction
69
+ // tell MatSort our starting sort direction
70
+ const adapter = this.adapter();
71
+ if (adapter) {
72
+ const initialSort = adapter.getCurrentSort();
73
+ this._matSort.active = (initialSort.sortByPath && initialSort.sortByPath[0]) || '';
74
+ this._matSort.direction = initialSort.sortDirection === ReadSelectedOrderingDirection.Ascending ? 'desc' : 'asc'; // show reverse arrows
75
+ }
76
+ }
77
+ _subscription = this._matSort.sortChange.subscribe((event) => {
78
+ const adapter = this.adapter();
79
+ if (adapter && event?.active) {
80
+ const newDirection = event.direction == 'desc' ? ReadSelectedOrderingDirection.Ascending : ReadSelectedOrderingDirection.Descending; // show reverse arrows
81
+ adapter.setSorting([event.active], newDirection);
82
+ }
83
+ });
84
+ ngOnDestroy() {
85
+ this._subscription.unsubscribe();
86
+ }
87
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: MatTableSortDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
88
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.3", type: MatTableSortDirective, isStandalone: true, selector: "mat-table[matSort], table[mat-table][matSort]", inputs: { adapter: { classPropertyName: "adapter", publicName: "adapter", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 });
89
+ }
90
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: MatTableSortDirective, decorators: [{
91
+ type: Directive,
92
+ args: [{
93
+ selector: 'mat-table[matSort], table[mat-table][matSort]',
94
+ standalone: true,
95
+ }]
96
+ }] });
97
+
98
+ /*
99
+ * Public API Surface of cornerstone-client-angular-material
100
+ */
101
+
102
+ /**
103
+ * Generated bundle index. Do not edit.
104
+ */
105
+
106
+ export { MatPaginatorIntlOverrides, MatTablePaginationDirective, MatTableSortDirective };
107
+ //# sourceMappingURL=intellegens-cornerstone-client-angular-material.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intellegens-cornerstone-client-angular-material.mjs","sources":["../../../../projects/intellegens/cornerstone-client-angular-material/src/lib/overrides/MatPaginatorIntlOverrides/index.ts","../../../../projects/intellegens/cornerstone-client-angular-material/src/lib/directives/MatTablePaginationDirective/index.ts","../../../../projects/intellegens/cornerstone-client-angular-material/src/lib/directives/MatTableSortDirective/index.ts","../../../../projects/intellegens/cornerstone-client-angular-material/src/public-api.ts","../../../../projects/intellegens/cornerstone-client-angular-material/src/intellegens-cornerstone-client-angular-material.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\nimport { MatPaginatorIntl } from '@angular/material/paginator';\n\n/**\n * Custom paginator service to adjust the label for the paginator.\n */\n@Injectable()\nexport class MatPaginatorIntlOverrides extends MatPaginatorIntl {\n override getRangeLabel = (page: number, pageSize: number, length: number) => {\n if (length === 0) {\n return 'Page 1 of 1';\n }\n const isLengthValid = length && length !== Infinity;\n return isLengthValid ? `Page ${page + 1} of ${Math.ceil(length / pageSize)}` : `Page ${page + 1}`;\n };\n}\n","import { Directive, InputSignal, inject, input } from '@angular/core';\nimport { MatPaginator, MatPaginatorIntl, PageEvent } from '@angular/material/paginator';\nimport { MatPaginatorIntlOverrides } from '../../overrides'; // using path alias results in `Could not resolve \"@overrides\"` in app\nimport { Subscription } from 'rxjs';\nimport { CollectionViewAdapter } from '@intellegens/cornerstone-client-angular';\n\n/**\n * Directive used to pass data to the `CollectionViewAdapter`, uses `MatPaginatorIntlOverrides` to change pagination UI.\n */\n@Directive({\n selector: 'mat-paginator',\n providers: [{ provide: MatPaginatorIntl, useClass: MatPaginatorIntlOverrides }],\n standalone: true,\n})\nexport class MatTablePaginationDirective {\n private _matPaginator = inject(MatPaginator);\n public adapter: InputSignal<CollectionViewAdapter<any, any> | undefined> = input();\n private _subscription?: Subscription;\n ngOnInit() {\n this._subscription = this._matPaginator.page.subscribe((event: PageEvent) => {\n const adapter = this.adapter();\n if (!adapter) return;\n const targetPage = event.pageIndex + 1;\n if (event.pageSize !== adapter.pageSize) {\n adapter.setPageSize(event.pageSize);\n } else if (targetPage !== adapter.currentPage) {\n adapter.jumpToPage(targetPage);\n }\n });\n }\n ngOnDestroy() {\n this._subscription?.unsubscribe();\n }\n}\n","import { Directive, inject, input, InputSignal } from '@angular/core';\nimport { MatSort, Sort } from '@angular/material/sort';\nimport { CollectionViewAdapter, ReadSelectedOrderingDirection } from '@intellegens/cornerstone-client-angular';\n\n/**\n * Directive used to pass data to the `CollectionViewAdapter` and reverse the default direction of shown table header sorting arrows\n */\n@Directive({\n selector: 'mat-table[matSort], table[mat-table][matSort]',\n standalone: true,\n})\nexport class MatTableSortDirective {\n private _matSort = inject(MatSort);\n public adapter: InputSignal<CollectionViewAdapter<any, any> | undefined> = input();\n ngOnInit() {\n this._matSort.disableClear = true; // removes \"unsorted\" option, syncs column header arrows with actual current sort direction\n // tell MatSort our starting sort direction\n const adapter = this.adapter();\n if (adapter) {\n const initialSort = adapter.getCurrentSort();\n this._matSort.active = (initialSort.sortByPath && initialSort.sortByPath[0]) || '';\n this._matSort.direction = initialSort.sortDirection === ReadSelectedOrderingDirection.Ascending ? 'desc' : 'asc'; // show reverse arrows\n }\n }\n private _subscription = this._matSort.sortChange.subscribe((event: Sort) => {\n const adapter = this.adapter();\n if (adapter && event?.active) {\n const newDirection = event.direction == 'desc' ? ReadSelectedOrderingDirection.Ascending : ReadSelectedOrderingDirection.Descending; // show reverse arrows\n adapter.setSorting([event.active], newDirection);\n }\n });\n ngOnDestroy() {\n this._subscription.unsubscribe();\n }\n}\n","/*\n * Public API Surface of cornerstone-client-angular-material\n */\n\nexport * from './lib/';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;AAGA;;AAEG;AAEG,MAAO,yBAA0B,SAAQ,gBAAgB,CAAA;IACpD,aAAa,GAAG,CAAC,IAAY,EAAE,QAAgB,EAAE,MAAc,KAAI;AAC1E,QAAA,IAAI,MAAM,KAAK,CAAC,EAAE;AAChB,YAAA,OAAO,aAAa;QACtB;AACA,QAAA,MAAM,aAAa,GAAG,MAAM,IAAI,MAAM,KAAK,QAAQ;QACnD,OAAO,aAAa,GAAG,CAAA,KAAA,EAAQ,IAAI,GAAG,CAAC,CAAA,IAAA,EAAO,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,CAAA,CAAE,GAAG,CAAA,KAAA,EAAQ,IAAI,GAAG,CAAC,CAAA,CAAE;AACnG,IAAA,CAAC;uGAPU,yBAAyB,EAAA,IAAA,EAAA,IAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;2GAAzB,yBAAyB,EAAA,CAAA;;2FAAzB,yBAAyB,EAAA,UAAA,EAAA,CAAA;kBADrC;;;ACAD;;AAEG;MAMU,2BAA2B,CAAA;AAC9B,IAAA,aAAa,GAAG,MAAM,CAAC,YAAY,CAAC;IACrC,OAAO,GAA6D,KAAK,CAAA,IAAA,SAAA,G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C,KAAK,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC;QAClD;AACF,IAAA,CAAC,CAAC;IACF,WAAW,GAAA;AACT,QAAA,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE;IAClC;uGAtBW,qBAAqB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;2FAArB,qBAAqB,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,+CAAA,EAAA,MAAA,EAAA,EAAA,OAAA,EAAA,EAAA,iBAAA,EAAA,SAAA,EAAA,UAAA,EAAA,SAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA;;2FAArB,qBAAqB,EAAA,UAAA,EAAA,CAAA;kBAJjC,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,+CAA+C;AACzD,oBAAA,UAAU,EAAE,IAAI;AACjB,iBAAA;;;ACVD;;AAEG;;ACFH;;AAEG;;;;"}
package/index.d.ts ADDED
@@ -0,0 +1,41 @@
1
+ import { MatPaginatorIntl } from '@angular/material/paginator';
2
+ import * as i0 from '@angular/core';
3
+ import { InputSignal } from '@angular/core';
4
+ import { CollectionViewAdapter } from '@intellegens/cornerstone-client-angular';
5
+
6
+ /**
7
+ * Custom paginator service to adjust the label for the paginator.
8
+ */
9
+ declare class MatPaginatorIntlOverrides extends MatPaginatorIntl {
10
+ getRangeLabel: (page: number, pageSize: number, length: number) => string;
11
+ static ɵfac: i0.ɵɵFactoryDeclaration<MatPaginatorIntlOverrides, never>;
12
+ static ɵprov: i0.ɵɵInjectableDeclaration<MatPaginatorIntlOverrides>;
13
+ }
14
+
15
+ /**
16
+ * Directive used to pass data to the `CollectionViewAdapter`, uses `MatPaginatorIntlOverrides` to change pagination UI.
17
+ */
18
+ declare class MatTablePaginationDirective {
19
+ private _matPaginator;
20
+ adapter: InputSignal<CollectionViewAdapter<any, any> | undefined>;
21
+ private _subscription?;
22
+ ngOnInit(): void;
23
+ ngOnDestroy(): void;
24
+ static ɵfac: i0.ɵɵFactoryDeclaration<MatTablePaginationDirective, never>;
25
+ static ɵdir: i0.ɵɵDirectiveDeclaration<MatTablePaginationDirective, "mat-paginator", never, { "adapter": { "alias": "adapter"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
26
+ }
27
+
28
+ /**
29
+ * Directive used to pass data to the `CollectionViewAdapter` and reverse the default direction of shown table header sorting arrows
30
+ */
31
+ declare class MatTableSortDirective {
32
+ private _matSort;
33
+ adapter: InputSignal<CollectionViewAdapter<any, any> | undefined>;
34
+ ngOnInit(): void;
35
+ private _subscription;
36
+ ngOnDestroy(): void;
37
+ static ɵfac: i0.ɵɵFactoryDeclaration<MatTableSortDirective, never>;
38
+ static ɵdir: i0.ɵɵDirectiveDeclaration<MatTableSortDirective, "mat-table[matSort], table[mat-table][matSort]", never, { "adapter": { "alias": "adapter"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
39
+ }
40
+
41
+ export { MatPaginatorIntlOverrides, MatTablePaginationDirective, MatTableSortDirective };
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@intellegens/cornerstone-client-angular-material",
3
+ "version": "0.0.45",
4
+ "private": false,
5
+ "publishable": true,
6
+ "sideEffects": false,
7
+ "module": "fesm2022/intellegens-cornerstone-client-angular-material.mjs",
8
+ "typings": "index.d.ts",
9
+ "exports": {
10
+ "./package.json": {
11
+ "default": "./package.json"
12
+ },
13
+ ".": {
14
+ "types": "./index.d.ts",
15
+ "default": "./fesm2022/intellegens-cornerstone-client-angular-material.mjs"
16
+ }
17
+ },
18
+ "dependencies": {
19
+ "tslib": "^2.3.0"
20
+ }
21
+ }