@cngx/ui 0.1.0-rc.2 → 0.1.0-rc.3

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.
@@ -24,6 +24,8 @@ import { CngxPopover } from '@cngx/common/popover';
24
24
  * @playground Overflow "More" menu under resize ./examples/overflow-resize/overflow-resize.component.ts
25
25
  * @playground Async commit-action (optimistic / pessimistic) ./examples/async-commit/async-commit.component.ts
26
26
  * @playground Dismissable + addable tabs ./examples/dynamic-tabs/dynamic-tabs.component.ts
27
+ * @playground Data-driven tabs via HTTP (Material) ./examples/http-commit/http-commit-material.component.ts
28
+ * @playground Data-driven tabs via HTTP (default theme) ./examples/http-commit/http-commit-plain.component.ts
27
29
  * @playground Form error aggregation ./examples/form-errors/form-errors.component.ts
28
30
  * @playground Routed tabs with a CanDeactivate guard ./examples/routed-outlet/routed-outlet.component.ts
29
31
  * @see {@link CngxMatTabs} for the Material `<mat-tab-group>` variant with `[cngxMatTabError]`.
@@ -1,90 +0,0 @@
1
- import * as i0 from '@angular/core';
2
- import { input, ChangeDetectionStrategy, Component } from '@angular/core';
3
- import * as i1 from '@angular/material/paginator';
4
- import { MatPaginatorModule } from '@angular/material/paginator';
5
-
6
- /**
7
- * Material paginator wrapper that connects to a {@link CngxPaginate} directive
8
- * via an explicit `[cngxPaginateRef]` input - no ancestor injection.
9
- *
10
- * ```html
11
- * <div cngxPaginate #pg="cngxPaginate" [total]="items.length">
12
- * <!-- table / list -->
13
- * </div>
14
- * <cngx-mat-paginator [cngxPaginateRef]="pg" />
15
- * ```
16
- *
17
- * For SmartDataSource integration, expose `filteredCount` from the data source
18
- * and bind it to `[total]` on the element that carries `cngxPaginate`:
19
- * ```html
20
- * <div cngxPaginate #pg="cngxPaginate" [total]="ds.filteredCount()">
21
- * <mat-table [dataSource]="ds" />
22
- * </div>
23
- * <cngx-mat-paginator [cngxPaginateRef]="pg" />
24
- * ```
25
- *
26
- * @category ui/material
27
- * @docsKind primary
28
- * @wcag AA
29
- * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/material/mat-paginator.ts
30
- * @since 0.1.0
31
- * @relatedTo CngxPaginate, CngxDataSource
32
- * <example-url>http://localhost:4200/#/common/data/data-source/datasource-cngxpaginate-manual-pipeline</example-url>
33
- * <example-url>http://localhost:4200/#/common/data/data-source/signal-observable-bridge</example-url>
34
- * <example-url>http://localhost:4200/#/common/data/paginate-list/paginated-list-cngxpaginate-cngxmatpaginator</example-url>
35
- * <example-url>http://localhost:4200/#/common/data/paginate-list/uncontrolled-mode-zero-class-boilerplate</example-url>
36
- */
37
- class CngxMatPaginator {
38
- /** The `CngxPaginate` directive instance to connect to. */
39
- cngxPaginateRef = input.required({ ...(ngDevMode ? { debugName: "cngxPaginateRef" } : /* istanbul ignore next */ {}), alias: 'cngxPaginateRef' });
40
- /** Options for the page-size selector. */
41
- pageSizeOptions = input([5, 10, 25], ...(ngDevMode ? [{ debugName: "pageSizeOptions" }] : /* istanbul ignore next */ []));
42
- ref = this.cngxPaginateRef;
43
- handlePage(event) {
44
- // setPageSize(..., false) suppresses the implicit page reset so the
45
- // explicit setPage below lands the index mat-paginator already computed.
46
- this.ref().setPageSize(event.pageSize, false);
47
- this.ref().setPage(event.pageIndex);
48
- }
49
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatPaginator, deps: [], target: i0.ɵɵFactoryTarget.Component });
50
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.4", type: CngxMatPaginator, isStandalone: true, selector: "cngx-mat-paginator", inputs: { cngxPaginateRef: { classPropertyName: "cngxPaginateRef", publicName: "cngxPaginateRef", isSignal: true, isRequired: true, transformFunction: null }, pageSizeOptions: { classPropertyName: "pageSizeOptions", publicName: "pageSizeOptions", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
51
- <mat-paginator
52
- [length]="ref().total()"
53
- [pageIndex]="ref().pageIndex()"
54
- [pageSize]="ref().pageSize()"
55
- [pageSizeOptions]="pageSizeOptions()"
56
- [disabled]="ref().isBusy()"
57
- (page)="handlePage($event)"
58
- />
59
- `, isInline: true, dependencies: [{ kind: "ngmodule", type: MatPaginatorModule }, { kind: "component", type: i1.MatPaginator, selector: "mat-paginator", inputs: ["color", "pageIndex", "length", "pageSize", "pageSizeOptions", "hidePageSize", "showFirstLastButtons", "selectConfig", "disabled"], outputs: ["page"], exportAs: ["matPaginator"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
60
- }
61
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatPaginator, decorators: [{
62
- type: Component,
63
- args: [{
64
- selector: 'cngx-mat-paginator',
65
- standalone: true,
66
- changeDetection: ChangeDetectionStrategy.OnPush,
67
- imports: [MatPaginatorModule],
68
- template: `
69
- <mat-paginator
70
- [length]="ref().total()"
71
- [pageIndex]="ref().pageIndex()"
72
- [pageSize]="ref().pageSize()"
73
- [pageSizeOptions]="pageSizeOptions()"
74
- [disabled]="ref().isBusy()"
75
- (page)="handlePage($event)"
76
- />
77
- `,
78
- }]
79
- }], propDecorators: { cngxPaginateRef: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxPaginateRef", required: true }] }], pageSizeOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "pageSizeOptions", required: false }] }] } });
80
-
81
- /**
82
- * @module @cngx/ui/material
83
- */
84
-
85
- /**
86
- * Generated bundle index. Do not edit.
87
- */
88
-
89
- export { CngxMatPaginator };
90
- //# sourceMappingURL=cngx-ui-material.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cngx-ui-material.mjs","sources":["../../../projects/ui/material/mat-paginator.ts","../../../projects/ui/material/public-api.ts","../../../projects/ui/material/cngx-ui-material.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, input } from '@angular/core';\nimport { MatPaginatorModule, type PageEvent } from '@angular/material/paginator';\nimport { type CngxPaginate } from '@cngx/common/data';\n\n/**\n * Material paginator wrapper that connects to a {@link CngxPaginate} directive\n * via an explicit `[cngxPaginateRef]` input - no ancestor injection.\n *\n * ```html\n * <div cngxPaginate #pg=\"cngxPaginate\" [total]=\"items.length\">\n * <!-- table / list -->\n * </div>\n * <cngx-mat-paginator [cngxPaginateRef]=\"pg\" />\n * ```\n *\n * For SmartDataSource integration, expose `filteredCount` from the data source\n * and bind it to `[total]` on the element that carries `cngxPaginate`:\n * ```html\n * <div cngxPaginate #pg=\"cngxPaginate\" [total]=\"ds.filteredCount()\">\n * <mat-table [dataSource]=\"ds\" />\n * </div>\n * <cngx-mat-paginator [cngxPaginateRef]=\"pg\" />\n * ```\n *\n * @category ui/material\n * @docsKind primary\n * @wcag AA\n * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/material/mat-paginator.ts\n * @since 0.1.0\n * @relatedTo CngxPaginate, CngxDataSource\n * <example-url>http://localhost:4200/#/common/data/data-source/datasource-cngxpaginate-manual-pipeline</example-url>\n * <example-url>http://localhost:4200/#/common/data/data-source/signal-observable-bridge</example-url>\n * <example-url>http://localhost:4200/#/common/data/paginate-list/paginated-list-cngxpaginate-cngxmatpaginator</example-url>\n * <example-url>http://localhost:4200/#/common/data/paginate-list/uncontrolled-mode-zero-class-boilerplate</example-url>\n */\n@Component({\n selector: 'cngx-mat-paginator',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [MatPaginatorModule],\n template: `\n <mat-paginator\n [length]=\"ref().total()\"\n [pageIndex]=\"ref().pageIndex()\"\n [pageSize]=\"ref().pageSize()\"\n [pageSizeOptions]=\"pageSizeOptions()\"\n [disabled]=\"ref().isBusy()\"\n (page)=\"handlePage($event)\"\n />\n `,\n})\nexport class CngxMatPaginator {\n /** The `CngxPaginate` directive instance to connect to. */\n readonly cngxPaginateRef = input.required<CngxPaginate>({ alias: 'cngxPaginateRef' });\n /** Options for the page-size selector. */\n readonly pageSizeOptions = input<number[]>([5, 10, 25]);\n\n protected readonly ref = this.cngxPaginateRef;\n\n protected handlePage(event: PageEvent): void {\n // setPageSize(..., false) suppresses the implicit page reset so the\n // explicit setPage below lands the index mat-paginator already computed.\n this.ref().setPageSize(event.pageSize, false);\n this.ref().setPage(event.pageIndex);\n }\n}\n","/**\n * @module @cngx/ui/material\n */\nexport { CngxMatPaginator } from './mat-paginator';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BG;MAiBU,gBAAgB,CAAA;;IAElB,eAAe,GAAG,KAAK,CAAC,QAAQ,sFAAiB,KAAK,EAAE,iBAAiB,EAAA,CAAG;;IAE5E,eAAe,GAAG,KAAK,CAAW,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,EAAA,IAAA,SAAA,GAAA,CAAA,EAAA,SAAA,EAAA,iBAAA,EAAA,CAAA,8BAAA,EAAA,CAAA,CAAC;AAEpC,IAAA,GAAG,GAAG,IAAI,CAAC,eAAe;AAEnC,IAAA,UAAU,CAAC,KAAgB,EAAA;;;AAGnC,QAAA,IAAI,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC;QAC7C,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC;IACrC;uGAbW,gBAAgB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAhB,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,gBAAgB,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,oBAAA,EAAA,MAAA,EAAA,EAAA,eAAA,EAAA,EAAA,iBAAA,EAAA,iBAAA,EAAA,UAAA,EAAA,iBAAA,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
7
- ```typescript
8
- import { CngxMatPaginator } from '@cngx/ui/material';
9
- ```
10
-
11
- ## Quick Start
12
-
13
- ```typescript
14
- import { Component, signal } from '@angular/core';
15
- import { MatTableModule } from '@angular/material/table';
16
- import { CngxPaginate } from '@cngx/common/data';
17
- import { CngxMatPaginator } from '@cngx/ui/material';
18
-
19
- @Component({
20
- selector: 'app-example',
21
- template: `
22
- <div cngxPaginate #pg="cngxPaginate" [total]="items.length">
23
- <table mat-table [dataSource]="paginatedItems()">
24
- <!-- table columns -->
25
- </table>
26
- </div>
27
- <cngx-mat-paginator [cngxPaginateRef]="pg" />
28
- `,
29
- imports: [MatTableModule, CngxMatPaginator],
30
- })
31
- export class ExampleComponent {
32
- readonly items = [];
33
-
34
- readonly paginatedItems = computed(() => {
35
- const pg = inject(CngxPaginate);
36
- return this.items.slice(pg.pageIndex() * pg.pageSize(), (pg.pageIndex() + 1) * pg.pageSize());
37
- });
38
- }
39
- ```
40
-
41
- ## Overview
42
-
43
- `CngxMatPaginator` is a Material Design paginator component that wraps the Material `mat-paginator` element and wires it to a `CngxPaginate` directive. It provides:
44
-
45
- - **Type-safe integration** - Explicit `[cngxPaginateRef]` input (no ancestor injection)
46
- - **Automatic state sync** - Page index, page size, and total count are automatically synchronized
47
- - **Page size selector** - Customizable page size options via `[pageSizeOptions]`
48
- - **Disabled state** - Paginator disables when `CngxPaginate.isBusy()` is true
49
-
50
- The component requires an explicit reference to the `CngxPaginate` directive instance - no hidden ancestor injection, no implicit wiring.
51
-
52
- ## Accessibility
53
-
54
- `CngxMatPaginator` delegates accessibility to Material's `mat-paginator` component. The Material paginator is fully accessible with:
55
-
56
- - **ARIA labels** - Paginator navigation and page size controls are properly labeled
57
- - **Keyboard navigation** - Tab order and keyboard shortcuts for page navigation
58
- - **Disabled state** - When `isBusy()` is true, controls are disabled and announced to screen readers
59
-
60
- ## Composition
61
-
62
- `CngxMatPaginator` composes:
63
-
64
- - **Material paginator** - `mat-paginator` component from `@angular/material/paginator`
65
- - **CngxPaginate directive** - Manages pagination state (page index, page size, total)
66
- - **Event handling** - Subscribes to Material paginator's `page` event and updates directive state
67
-
68
- ## How It Works
69
-
70
- 1. **Setup** - Consumer applies `cngxPaginate` on a container element and assigns a template reference
71
- 2. **Data binding** - Consumer passes `[total]="items.length"` to the directive
72
- 3. **Component wire-up** - `CngxMatPaginator` binds to the directive via `[cngxPaginateRef]`
73
- 4. **State sync** - Component reads `ref.pageIndex()`, `ref.pageSize()`, `ref.total()` and binds to Material's `mat-paginator`
74
- 5. **User interaction** - When user changes page or page size, Material's `page` event fires
75
- 6. **State update** - `CngxMatPaginator.handlePage()` calls `ref.setPageSize()` and `ref.setPage()` to update directive state
76
- 7. **Data refresh** - Consumer reactively filters/slices data based on directive signals
77
-
78
- ## Material Theming
79
-
80
- `CngxMatPaginator` uses the standard Material `mat-paginator` component, which inherits theming from your Material theme automatically. No additional theme configuration needed - include the Material theme in your global stylesheet.
81
-
82
- ```scss
83
- @use '@angular/material' as mat;
84
-
85
- $theme: mat.define-theme((...));
86
-
87
- html {
88
- @include mat.all-component-themes($theme);
89
- }
90
- ```
@@ -1,47 +0,0 @@
1
- import * as _angular_core from '@angular/core';
2
- import { PageEvent } from '@angular/material/paginator';
3
- import { CngxPaginate } from '@cngx/common/data';
4
-
5
- /**
6
- * Material paginator wrapper that connects to a {@link CngxPaginate} directive
7
- * via an explicit `[cngxPaginateRef]` input - no ancestor injection.
8
- *
9
- * ```html
10
- * <div cngxPaginate #pg="cngxPaginate" [total]="items.length">
11
- * <!-- table / list -->
12
- * </div>
13
- * <cngx-mat-paginator [cngxPaginateRef]="pg" />
14
- * ```
15
- *
16
- * For SmartDataSource integration, expose `filteredCount` from the data source
17
- * and bind it to `[total]` on the element that carries `cngxPaginate`:
18
- * ```html
19
- * <div cngxPaginate #pg="cngxPaginate" [total]="ds.filteredCount()">
20
- * <mat-table [dataSource]="ds" />
21
- * </div>
22
- * <cngx-mat-paginator [cngxPaginateRef]="pg" />
23
- * ```
24
- *
25
- * @category ui/material
26
- * @docsKind primary
27
- * @wcag AA
28
- * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/material/mat-paginator.ts
29
- * @since 0.1.0
30
- * @relatedTo CngxPaginate, CngxDataSource
31
- * <example-url>http://localhost:4200/#/common/data/data-source/datasource-cngxpaginate-manual-pipeline</example-url>
32
- * <example-url>http://localhost:4200/#/common/data/data-source/signal-observable-bridge</example-url>
33
- * <example-url>http://localhost:4200/#/common/data/paginate-list/paginated-list-cngxpaginate-cngxmatpaginator</example-url>
34
- * <example-url>http://localhost:4200/#/common/data/paginate-list/uncontrolled-mode-zero-class-boilerplate</example-url>
35
- */
36
- declare class CngxMatPaginator {
37
- /** The `CngxPaginate` directive instance to connect to. */
38
- readonly cngxPaginateRef: _angular_core.InputSignal<CngxPaginate>;
39
- /** Options for the page-size selector. */
40
- readonly pageSizeOptions: _angular_core.InputSignal<number[]>;
41
- protected readonly ref: _angular_core.InputSignal<CngxPaginate>;
42
- protected handlePage(event: PageEvent): void;
43
- static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxMatPaginator, never>;
44
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxMatPaginator, "cngx-mat-paginator", never, { "cngxPaginateRef": { "alias": "cngxPaginateRef"; "required": true; "isSignal": true; }; "pageSizeOptions": { "alias": "pageSizeOptions"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
45
- }
46
-
47
- export { CngxMatPaginator };