@cngx/ui 0.1.0-rc.1 → 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.
@@ -0,0 +1,131 @@
1
+ # @cngx/ui/paginator
2
+
3
+ Default-theme, skinnable, framework-neutral pagination organism. A declarative
4
+ `<cngx-paginator>` shell over the `CngxPaginate` brain from `@cngx/common/data`,
5
+ assembled from projected segment parts in DOM order - no `show*` config inputs.
6
+
7
+ ## When you reach for it
8
+
9
+ You want a paginator that:
10
+
11
+ - Composes from child parts (`cngx-pgn-prev`, `cngx-pgn-pages`,
12
+ `cngx-pgn-page-size`, `cngx-pgn-range`, `cngx-pgn-goto`, ...) instead of a pile
13
+ of boolean inputs.
14
+ - Repaints across seven skins via a single `[skin]` attribute, with identical
15
+ DOM, ARIA, and keyboard behaviour across all of them.
16
+ - Carries async-aware navigation gating, a roving-keyboard page row, and
17
+ live-region announcements out of the box.
18
+ - Ships no Material runtime.
19
+
20
+ If you already render a Material `<mat-paginator>`, reach for `[cngxMatPaginator]`
21
+ in `@cngx/ui/mat-paginator` instead. The `CngxPaginate` brain is shared.
22
+
23
+ ## Usage
24
+
25
+ The shell exposes only `total`, `[(pageIndex)]`, `[(pageSize)]`, `[state]`,
26
+ `skin`, `density`, and `resetOn`. Everything else is a projected segment in DOM
27
+ order. The brain owns no data: bind `[total]`, read the active page back through
28
+ the two-way bindings, and slice your own array.
29
+
30
+ ```html
31
+ <cngx-paginator skin="numbered" [total]="items().length" [(pageIndex)]="pageIndex">
32
+ <cngx-pgn-prev />
33
+ <cngx-pgn-pages />
34
+ <cngx-pgn-next />
35
+ <cngx-pgn-range />
36
+ </cngx-paginator>
37
+ ```
38
+
39
+ ```ts
40
+ protected readonly pageIndex = signal(0);
41
+ protected readonly pageSize = signal(10);
42
+ protected readonly pageItems = computed(() => {
43
+ const start = this.pageIndex() * this.pageSize();
44
+ return this.items().slice(start, start + this.pageSize());
45
+ });
46
+ ```
47
+
48
+ ## Segments
49
+
50
+ Each part injects `CNGX_PAGINATOR_HOST` and self-wires; drop in only what the
51
+ context needs.
52
+
53
+ |Segment|Selector|Role|
54
+ |-|-|-|
55
+ |First / last|`cngx-pgn-first` / `cngx-pgn-last`|Jump to the boundaries; `aria-disabled` at the bound|
56
+ |Previous / next|`cngx-pgn-prev` / `cngx-pgn-next`|Step one page; `aria-disabled` at the bound|
57
+ |Pages|`cngx-pgn-pages`|Roving numbered row with ellipsis overflow menu, `aria-current` on the active page|
58
+ |Range|`cngx-pgn-range`|`start-end of total` readout (format from config)|
59
+ |Page size|`cngx-pgn-page-size`|`CngxListbox` select; `[options]` is data; resets to the first page|
60
+ |Page of pages|`cngx-pgn-page-of-pages`|`current / total` jump dropdown|
61
+ |Go to|`cngx-pgn-goto`|Native number input; Enter or blur navigates|
62
+ |Dots|`cngx-pgn-dots`|One dot per page (organism-internal), for the `dots` skin|
63
+
64
+ ## Skins
65
+
66
+ `numbered`, `minimal`, `pill`, `segmented`, `rail`, `dots`, `bar`. Set via
67
+ `[skin]` -> `[data-skin]`. Skin is paint-only: DOM, ARIA, and keyboard behaviour
68
+ are identical across all seven. `density` (`compact` / `default` / `comfortable`)
69
+ is orthogonal.
70
+
71
+ ## Reset and deep-linking
72
+
73
+ `[resetOn]` jumps to the first page whenever its bound value changes - bind the
74
+ sort / filter / search value the result set depends on so a narrowed result never
75
+ strands the user on a now-empty page. Mounting does not reset; bind a primitive
76
+ or a `computed`, never an inline literal.
77
+
78
+ ```html
79
+ <cngx-paginator [total]="filtered().length" [resetOn]="search()">…</cngx-paginator>
80
+ ```
81
+
82
+ For deep-linkable, back-button-safe URLs add the brain-level
83
+ `[cngxPaginateRouting]` directive (from `@cngx/common/data`) on the same host - it
84
+ persists the page / size in the query string and needs `@angular/router`.
85
+
86
+ ```html
87
+ <cngx-paginator cngxPaginateRouting [total]="items().length">…</cngx-paginator>
88
+ ```
89
+
90
+ ## Async
91
+
92
+ `CngxPaginator` is an async-state consumer. Bind `[state]` and, while busy, it
93
+ gates navigation, renders an indeterminate `cngx-progress` bar, flips
94
+ `aria-busy`, and announces the transition.
95
+
96
+ ```html
97
+ <cngx-paginator [total]="total()" [state]="loading">…</cngx-paginator>
98
+ ```
99
+
100
+ ## Configuration
101
+
102
+ All accessible-name strings, announcement phrasing, and the range format cascade
103
+ through `CNGX_PAGINATOR_CONFIG` (English defaults). Override at the app root with
104
+ `provideCngxPaginatorConfig(...)`, or per region with
105
+ `provideCngxPaginatorConfigAt(...)` in `viewProviders`.
106
+
107
+ ```ts
108
+ provideCngxPaginatorConfig(
109
+ withPaginatorAriaLabels({ next: 'Nächste Seite', pageOfPages: 'Seite wählen' }),
110
+ withPaginatorAnnouncements({ pageChange: (p, t) => `Seite ${p} von ${t}` }),
111
+ withPaginatorRangeFormat((start, end, total) => `${start}-${end} von ${total}`),
112
+ );
113
+ ```
114
+
115
+ `withPaginatorRangeFormat` localises the `cngx-pgn-range` text (including the
116
+ `of` connector); `ariaLabels.pageOfPages` is the dedicated label for the
117
+ page-of-pages selector.
118
+
119
+ The live-region announcer is swappable. `CNGX_PAGINATOR_ANNOUNCER_FACTORY`
120
+ defaults to `createPaginatorAnnouncer`; override it to wrap the busy / settle /
121
+ page-change derivation (telemetry tap, politeness escalation, custom branching)
122
+ without forking the shell. It mirrors the select family's
123
+ `CNGX_COMMIT_ERROR_ANNOUNCER_FACTORY`.
124
+
125
+ ## Accessibility
126
+
127
+ `role="navigation"` landmark with a configurable `aria-label`; a single
128
+ roving tab stop on the page row (arrows / Home / End); `aria-current="page"` on
129
+ the active page; a single computed `aria-busy` owner; live-region page-change,
130
+ clamp, and async announcements. A `total`-shrink clamp is never silent - the
131
+ clamped page is both emitted back to the consumer and announced.
package/stepper/README.md CHANGED
@@ -70,6 +70,30 @@ Per-instance override:
70
70
 
71
71
  Under 480px viewports the classic strip auto-collapses to `<cngx-text-stepper>` (default) or `<cngx-dot-stepper>`. Configure via `withStepperMobileCollapse('text' | 'dots' | 'off')`.
72
72
 
73
+ ## Density
74
+
75
+ `density` controls how the horizontal strip reacts to a narrow container. It defaults to `'comfortable'` (full labels, unchanged); `'auto'` arms a continuous, container-query-driven label budget.
76
+
77
+ ```ts
78
+ import { provideStepperConfig, withStepperDensity } from '@cngx/common/stepper';
79
+
80
+ bootstrapApplication(AppComponent, {
81
+ providers: [provideStepperConfig(withStepperDensity('auto'))],
82
+ });
83
+ ```
84
+
85
+ Under `'auto'` labels keep their full width as long as the strip has room; they only give way when it would otherwise overflow. Each step's shrink priority grows with its distance from the active step, so the furthest labels truncate first and the nearest stay readable longest. The active step has the lowest priority of all, so its label stays fully readable while the strip has room and only yields once its neighbours have collapsed to number-only. Because nothing is capped below the available width, space freed by a collapsed label is reused rather than left empty, and the strip clips instead of growing a horizontal scrollbar. The relayout is animated when the active step changes (`prefers-reduced-motion` short-circuits it); a resize reflows continuously without animation. Collapsed labels stay in the accessibility tree (clipped, never removed), so every step button keeps its accessible name. Each skin keeps its own treatment: skins with a numbered disc keep it visible as the label collapses; the fill-the-width tile skins (`path-chevron`, `pill-segment`) keep filling the strip but truncate progressively too; label-only skins with no number (`chips`, `breadcrumb`, `path-chevron`) truncate to a small readable stub.
86
+
87
+ Tune the model with custom properties:
88
+
89
+ | Property | Default | Effect |
90
+ |-|-|-|
91
+ | `--cngx-step-shrink-weight` | `20` | How strongly distance from the active step raises a non-active step's shrink priority. Larger keeps the active label full longer at the neighbours' expense. |
92
+ | `--cngx-step-active-label-max` | `60cqi` | Maximum active-label width (container units), so a long active label cannot squeeze the sequence out and the strip reflow on navigation stays bounded. |
93
+ | `--cngx-step-active-label-min` | `4rem` | Guaranteed minimum label width for the active step. |
94
+ | `--cngx-step-collapsed-min` | `3.25rem` | Minimum step width - the floor a collapsing step shrinks to, wide enough to keep its indicator. |
95
+ | `--cngx-step-collapsed-label-min` | `2ch` | Minimum label stub for non-active steps on label-only skins. |
96
+
73
97
  ## Progress-Bar Stepper
74
98
 
75
99
  `CngxProgressBarStepper` renders the active step ratio as a determinate `<cngx-progress>` bar. Thin Level-4 organism composing `CngxStepperPresenter` via `hostDirectives` plus the embedded `CngxProgress` primitive - no reinvented `<div role="progressbar">`. Material consumers inherit Material progress palette automatically via `@cngx/themes/material/feedback-theme`.
@@ -0,0 +1,108 @@
1
+ import * as _angular_core from '@angular/core';
2
+ import * as i1 from '@cngx/common/data';
3
+ import { CngxPaginate } from '@cngx/common/data';
4
+ export { CngxPaginateResetOn, CngxPaginateRouting } from '@cngx/common/data';
5
+
6
+ /**
7
+ * Context handed to {@link CngxMatPaginator.announceLabel} to build the
8
+ * screen-reader announcement after each page / page-size change.
9
+ *
10
+ * @category ui/mat-paginator
11
+ */
12
+ interface CngxMatPaginatorAnnounceContext {
13
+ /** 1-based current page. */
14
+ readonly page: number;
15
+ /** Total page count (minimum 1). */
16
+ readonly totalPages: number;
17
+ /** 1-based index of the first item on the page. */
18
+ readonly start: number;
19
+ /** 1-based index of the last item on the page, capped at `total`. */
20
+ readonly end: number;
21
+ /** Total item count before pagination. */
22
+ readonly total: number;
23
+ }
24
+ /**
25
+ * The in-place adoption half of the Material paginator instrumentation: add
26
+ * `cngxMatPaginator` to an existing `<mat-paginator>` and the signal-native
27
+ * {@link CngxPaginate} brain takes over its state with no DOM rewrite, mirroring
28
+ * `[cngxMatStepper]` / `[cngxMatTabs]`.
29
+ *
30
+ * The bridge composes the untouched brain via `hostDirectives`, injects the
31
+ * consumer's own `MatPaginator` with `{ self: true }`, and syncs the four
32
+ * Material properties (`length` / `pageIndex` / `pageSize` / `disabled`) plus
33
+ * `pageSizeOptions` against the brain's `computed()` graph, forwarding `(page)`
34
+ * back into the brain.
35
+ *
36
+ * Beyond plain `<mat-paginator>`, the bridge adds:
37
+ * - `[resetOn]` - jump to the first page whenever a bound key (a sort / filter /
38
+ * search value) changes, so a filtered result set never strands the user on a
39
+ * now-empty page. Pass a primitive (or a `computed` string key); an inline
40
+ * array literal recomputes every change-detection pass and would reset on each.
41
+ * - `[announce]` - mount a visually-hidden `aria-live` region that speaks the new
42
+ * page + visible range after every change; `<mat-paginator>` only relabels its
43
+ * own range text, which AT does not announce. Localise via `[announceLabel]`.
44
+ * - `[cngxPaginateRouting]` (generic companion directive from `@cngx/common/data`)
45
+ * - persist the page / size in the URL query string for deep-linkable,
46
+ * back-button-safe pagination.
47
+ *
48
+ * ```html
49
+ * <mat-paginator
50
+ * cngxMatPaginator
51
+ * #pg="cngxMatPaginator"
52
+ * [total]="items.length"
53
+ * [pageSizeOptions]="[5, 10, 25]"
54
+ * />
55
+ * <ul>
56
+ * @for (item of items.slice(pg.paginate.range()[0], pg.paginate.range()[1]); track item.id) {
57
+ * <li>{{ item.label }}</li>
58
+ * }
59
+ * </ul>
60
+ * ```
61
+ *
62
+ * @category ui/mat-paginator
63
+ * @docsKind primary
64
+ * @wcag AA
65
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-paginator/mat-paginator-bridge.directive.ts
66
+ * @since 0.1.0
67
+ * @relatedTo CngxPaginate, CngxMatStepper, CngxPaginator
68
+ * <example-url>http://localhost:4200/#/common/data/data-source/datasource-cngxpaginate-manual-pipeline</example-url>
69
+ * <example-url>http://localhost:4200/#/common/data/paginate-list/bridge-announce-page-changes</example-url>
70
+ * <example-url>http://localhost:4200/#/common/data/paginate-list/instrumentation-bridge-cngxmatpaginator</example-url>
71
+ * <example-url>http://localhost:4200/#/common/data/paginate-list/paginated-list-cngxpaginate-cngxmatpaginator</example-url>
72
+ * <example-url>http://localhost:4200/#/common/data/paginate-list/uncontrolled-mode-zero-class-boilerplate</example-url>
73
+ */
74
+ declare class CngxMatPaginator {
75
+ private readonly matPaginator;
76
+ /**
77
+ * The composed {@link CngxPaginate} brain. Public so a sibling list or table
78
+ * outside the `<mat-paginator>` reads `range()` via `#ref="cngxMatPaginator"`.
79
+ */
80
+ readonly paginate: CngxPaginate;
81
+ /** Options for the page-size selector. A Material-render concern, owned here. */
82
+ readonly pageSizeOptions: _angular_core.InputSignal<number[]>;
83
+ /**
84
+ * Reset key. When its value changes (after the initial render) the brain jumps
85
+ * to the first page. Bind the sort / filter / search value a result set
86
+ * depends on. Pass a primitive or a `computed` - an inline array / object
87
+ * literal recomputes every change-detection pass and would reset every time.
88
+ */
89
+ readonly resetOn: _angular_core.InputSignal<unknown>;
90
+ /** Speak page changes through a visually-hidden `aria-live` region when `true`. */
91
+ readonly announce: _angular_core.InputSignal<boolean>;
92
+ /** Builds the announcement string. Defaults to an English template. */
93
+ readonly announceLabel: _angular_core.InputSignal<(context: CngxMatPaginatorAnnounceContext) => string>;
94
+ private readonly elementRef;
95
+ private readonly renderer;
96
+ private readonly destroyRef;
97
+ /** The live-region message - derived, so it never drifts from brain state. */
98
+ private readonly announceMessage;
99
+ private liveRegion;
100
+ constructor();
101
+ /** A visually-hidden polite live region appended to the host paginator. */
102
+ private createLiveRegion;
103
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxMatPaginator, never>;
104
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxMatPaginator, "[cngxMatPaginator]", ["cngxMatPaginator"], { "pageSizeOptions": { "alias": "pageSizeOptions"; "required": false; "isSignal": true; }; "resetOn": { "alias": "resetOn"; "required": false; "isSignal": true; }; "announce": { "alias": "announce"; "required": false; "isSignal": true; }; "announceLabel": { "alias": "announceLabel"; "required": false; "isSignal": true; }; }, {}, never, never, true, [{ directive: typeof i1.CngxPaginate; inputs: { "cngxPageIndex": "cngxPageIndex"; "cngxPageSize": "cngxPageSize"; "total": "total"; "state": "state"; }; outputs: { "pageChange": "pageChange"; "pageSizeChange": "pageSizeChange"; }; }]>;
105
+ }
106
+
107
+ export { CngxMatPaginator };
108
+ export type { CngxMatPaginatorAnnounceContext };
@@ -247,6 +247,8 @@ declare class CngxMatTabs {
247
247
  * the projectors render their built-in `cngx-sr-only` spans. The slot
248
248
  * inputs that `[cngxMatTabs]` exposes are a deferred follow-up.
249
249
  *
250
+ * @playground Native router tabs with a CanDeactivate guard ./examples/router-nav/router-nav.component.ts
251
+ *
250
252
  * @category ui/mat-tabs
251
253
  * @docsKind primary
252
254
  * @wcag AA
@@ -864,6 +866,9 @@ declare namespace MaterialPrivateSurfaces {
864
866
  * ```
865
867
  *
866
868
  * @category ui/mat-tabs
869
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-tabs/overflow/mat-tab-overflow-dom-adapter.ts
870
+ * @since 0.1.0
871
+ * @relatedTo CngxTabOverflow, CngxMatTabs, CNGX_TAB_OVERFLOW_DOM_ADAPTER_FACTORY
867
872
  */
868
873
  declare function createCngxMatTabOverflowDomAdapter(): CngxTabOverflowDomAdapter;
869
874