@cngx/common 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.
@@ -8,7 +8,7 @@ export * from '@cngx/common/popover';
8
8
  import { makeVersion } from '@cngx/utils';
9
9
 
10
10
  /** @internal — replaced at publish time, not part of consumer API. */
11
- const VERSION = makeVersion('0.1.0-rc.1');
11
+ const VERSION = makeVersion('0.1.0-rc.3');
12
12
 
13
13
  /**
14
14
  * Public API Surface of @cngx/common
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cngx/common",
3
- "version": "0.1.0-rc.1",
4
- "description": "Atoms and molecules (a11y, interactive, layout, dialog, popover, display) for the CNGX Angular component library. CDK-only, no Material.",
3
+ "version": "0.1.0-rc.3",
4
+ "description": "Atoms and molecules (a11y, interactive, layout, dialog, popover, display) for the CNGX Angular component library.",
5
5
  "keywords": [
6
6
  "cngx",
7
7
  "angular",
package/stepper/README.md CHANGED
@@ -148,16 +148,3 @@ A step carries an error through two independent channels:
148
148
  - **Commit / async** - a `commitAction` that rejects sets `lastFailedIndex`; the rolled-back step decorates via `*cngxStepRejection` and announces through the `CngxToastOn` / `CngxBannerOn` bridges.
149
149
 
150
150
  The two never collide: validation owns `*cngxStepError`, commit owns `*cngxStepRejection`. The `[error]` input replaces the old `<fieldset cngxErrorAggregator><input cngxErrorSource>` boilerplate for the common "this step is invalid" case; the aggregator stays the power path. See `@cngx/ui/stepper` for the per-skin text-surface table.
151
-
152
- ## Architecture notes
153
-
154
- - **Pillar 1** (`Ableitung statt Verwaltung`): every derived value is a `computed()`; the only writable slot is the active-step model + a registry `WritableSignal<readonly CngxStepRegistration[]>` mutated only by `register`/`unregister`.
155
- - **Pillar 2** (`Kommunikation als First-Class`): host contracts (`CNGX_STEPPER_HOST` / `CNGX_STEP_PANEL_HOST`) expose ARIA-relevant state as `Signal<T>` so organisms can wire reactive `aria-current` / `aria-busy` / `aria-describedby` from day one.
156
- - **Pillar 3** (`Komposition statt Konfiguration`): step content is content-projected (`<cngxStep>` atoms), not configured via an options array. Organisms compose the presenter via `hostDirectives` rather than extending it.
157
- - **Memory hygiene**: every atom registers a `DestroyRef.onDestroy` unregister hook; the router-sync directive uses `takeUntilDestroyed` for its `NavigationEnd` stream.
158
-
159
- ## See also
160
-
161
- - `@cngx/ui/stepper` - `<cngx-stepper>` CNGX-standard organism
162
- - `@cngx/ui/mat-stepper` - `<cngx-mat-stepper>` Material-twin organism
163
- - `.internal/architektur/stepper-accepted-debt.md` - tracked architectural debt (single §1: native `<mat-step>` adoption is structurally impossible via Angular content projection)
@@ -1,8 +1,8 @@
1
1
  import * as _angular_core from '@angular/core';
2
- import { TemplateRef, Signal, InjectionToken, ElementRef, Injector, DestroyRef } from '@angular/core';
2
+ import { TemplateRef, Signal, OnInit, InjectionToken, Resource, ElementRef, Injector, DestroyRef } from '@angular/core';
3
3
  import { CngxAsyncState, AsyncStatus } from '@cngx/core/utils';
4
4
  import { DataSource } from '@angular/cdk/collections';
5
- import { Observable } from 'rxjs';
5
+ import { Observable, MonoTypeOperatorFunction, OperatorFunction } from 'rxjs';
6
6
  import { CngxRovingTabindex, CngxActiveDescendant } from '@cngx/common/a11y';
7
7
 
8
8
  /**
@@ -442,8 +442,10 @@ declare class CngxFilterChips<TItem = unknown, TValue = unknown> {
442
442
  * @for (item of items.slice(pg.range()[0], pg.range()[1]); track item.id) { ... }
443
443
  * </div>
444
444
  *
445
- * // With CngxMatPaginator:
446
- * <cngx-mat-paginator [cngxPaginateRef]="pg" />
445
+ * // Drive any UI off the brain - e.g. a Material paginator wired by hand:
446
+ * <mat-paginator
447
+ * [length]="pg.total()" [pageIndex]="pg.pageIndex()" [pageSize]="pg.pageSize()"
448
+ * (page)="pg.setPageSize($event.pageSize, false); pg.setPage($event.pageIndex)" />
447
449
  *
448
450
  * @category common/data/paginate
449
451
  * @docsKind primary
@@ -453,11 +455,10 @@ declare class CngxFilterChips<TItem = unknown, TValue = unknown> {
453
455
  * @relatedTo CngxSort, CngxFilter, CngxSmartDataSource
454
456
  *
455
457
  * <example-url>http://localhost:4200/#/common/data/data-source/datasource-cngxpaginate-manual-pipeline</example-url>
456
- * <example-url>http://localhost:4200/#/common/data/data-source/signal-observable-bridge</example-url>
458
+ * <example-url>http://localhost:4200/#/common/data/paginate-list/bridge-announce-page-changes</example-url>
459
+ * <example-url>http://localhost:4200/#/common/data/paginate-list/instrumentation-bridge-cngxmatpaginator</example-url>
457
460
  * <example-url>http://localhost:4200/#/common/data/paginate-list/paginated-list-cngxpaginate-cngxmatpaginator</example-url>
458
461
  * <example-url>http://localhost:4200/#/common/data/paginate-list/uncontrolled-mode-zero-class-boilerplate</example-url>
459
- * <example-url>http://localhost:4200/#/common/data/smart-data-source/auto-wired</example-url>
460
- * <example-url>http://localhost:4200/#/common/data/smart-data-source/how-it-works-hostdirectives-inject</example-url>
461
462
  * <example-url>http://localhost:4200/#/common/data/smart-data-source/smartdatasource-cngxpaginate-hostdirective</example-url>
462
463
  */
463
464
  declare class CngxPaginate {
@@ -495,6 +496,15 @@ declare class CngxPaginate {
495
496
  * Consumer: `items.slice(range()[0], range()[1])`.
496
497
  */
497
498
  readonly range: _angular_core.Signal<[number, number]>;
499
+ /**
500
+ * `[0, end]` cumulative slice indices for append-don't-replace (load-more)
501
+ * consumers: every page already stepped through, sliced from the top. `end`
502
+ * is `(pageIndex + 1) * pageSize` - the count revealed so far, uncapped (a
503
+ * partial final page is clamped by the consumer against `total`).
504
+ * Pure derivation of `pageIndex` / `pageSize`; the explicit tuple `equal`
505
+ * stops a fresh-array identity from cascading downstream.
506
+ */
507
+ readonly cumulativeRange: _angular_core.Signal<[number, number]>;
498
508
  /** Emitted when the page index changes. */
499
509
  readonly pageChange: _angular_core.OutputEmitterRef<number>;
500
510
  /** Emitted when the page size changes. */
@@ -521,6 +531,232 @@ declare class CngxPaginate {
521
531
  static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxPaginate, "[cngxPaginate]", ["cngxPaginate"], { "pageIndexInput": { "alias": "cngxPageIndex"; "required": false; "isSignal": true; }; "pageSizeInput": { "alias": "cngxPageSize"; "required": false; "isSignal": true; }; "total": { "alias": "total"; "required": false; "isSignal": true; }; "state": { "alias": "state"; "required": false; "isSignal": true; }; }, { "pageChange": "pageChange"; "pageSizeChange": "pageSizeChange"; }, never, never, true, never>;
522
532
  }
523
533
 
534
+ /**
535
+ * Wires the reset-on-change behaviour onto a {@link CngxPaginate} brain: when
536
+ * `key()` changes (after the initial run) the paginator jumps to the first
537
+ * page. The first run captures the mounting value without resetting, and an
538
+ * already-first paginator emits nothing.
539
+ *
540
+ * Shared by `[cngxPaginateResetOn]`, the `CngxPaginator` shell's `resetOn`
541
+ * input, and the `CngxMatPaginator` bridge's `resetOn` input, so the behaviour
542
+ * is byte-identical across all three. Call inside an injection context
543
+ * (constructor or field initialiser).
544
+ *
545
+ * @category common/data/paginate
546
+ * @since 0.1.0
547
+ */
548
+ declare function connectPaginateResetOn(paginate: CngxPaginate, key: () => unknown): void;
549
+ /**
550
+ * Resets a `cngxPaginate` host to the first page whenever the bound key
551
+ * changes - the composable form of {@link connectPaginateResetOn}. Drop it on
552
+ * the same element as `cngxPaginate` (or a `CngxPaginator` / `CngxMatPaginator`,
553
+ * which provide the brain), and bind the sort / filter / search value a result
554
+ * set depends on, so a narrowed result never strands the user on a now-empty
555
+ * page.
556
+ *
557
+ * Bind a primitive or a `computed` - an inline array / object literal recomputes
558
+ * every change-detection pass and would reset on each.
559
+ *
560
+ * ```html
561
+ * <table cngxPaginate [cngxPaginateResetOn]="filter()"><!-- ... --></table>
562
+ * ```
563
+ *
564
+ * @category common/data/paginate
565
+ * @docsKind primary
566
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/paginate/paginate-reset.directive.ts
567
+ * @since 0.1.0
568
+ * @relatedTo CngxPaginate, CngxPaginator, CngxMatPaginator
569
+ */
570
+ declare class CngxPaginateResetOn {
571
+ private readonly paginate;
572
+ /** The reset key. A change (after mount) jumps the paginator to page 0. */
573
+ readonly key: _angular_core.InputSignal<unknown>;
574
+ constructor();
575
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxPaginateResetOn, never>;
576
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxPaginateResetOn, "[cngxPaginateResetOn]", ["cngxPaginateResetOn"], { "key": { "alias": "cngxPaginateResetOn"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
577
+ }
578
+
579
+ /**
580
+ * Persists a `cngxPaginate` host's page / size in the URL query string, so a
581
+ * paginated view is deep-linkable and survives reload / back / forward.
582
+ *
583
+ * Drop it on the same element as `cngxPaginate` (or a `CngxPaginator` /
584
+ * `CngxMatPaginator`, which provide the brain). The page is written 1-based
585
+ * (`?page=2`) for human-readable URLs; the brain stays 0-based.
586
+ *
587
+ * ```html
588
+ * <cngx-paginator cngxPaginateRouting [total]="items().length"></cngx-paginator>
589
+ * ```
590
+ *
591
+ * Two paginators on one route must take distinct param names via
592
+ * `[cngxPaginatePageParam]` / `[cngxPaginateSizeParam]` to avoid a collision.
593
+ * Requires `@angular/router` (`provideRouter`); without it the directive is an
594
+ * inert no-op (a dev-mode warning is logged). Framework-agnostic of any UI - it
595
+ * needs only the brain and the router.
596
+ *
597
+ * @category common/data/paginate
598
+ * @docsKind primary
599
+ * @wcag AA
600
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/paginate/paginate-routing.directive.ts
601
+ * @since 0.1.0
602
+ * @relatedTo CngxPaginate, CngxPaginator, CngxMatPaginator
603
+ * <example-url>http://localhost:4200/#/ui/paginator/paginator-behaviors/url-synced-paging</example-url>
604
+ */
605
+ declare class CngxPaginateRouting implements OnInit {
606
+ private readonly paginate;
607
+ private readonly router;
608
+ private readonly route;
609
+ private readonly destroyRef;
610
+ /** Query-param name for the 1-based page. */
611
+ readonly pageParam: _angular_core.InputSignal<string>;
612
+ /** Query-param name for the page size. */
613
+ readonly sizeParam: _angular_core.InputSignal<string>;
614
+ private applyingFromUrl;
615
+ constructor();
616
+ ngOnInit(): void;
617
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxPaginateRouting, never>;
618
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxPaginateRouting, "[cngxPaginateRouting]", ["cngxPaginateRouting"], { "pageParam": { "alias": "cngxPaginatePageParam"; "required": false; "isSignal": true; }; "sizeParam": { "alias": "cngxPaginateSizeParam"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
619
+ }
620
+
621
+ /**
622
+ * A single bucket as the chips segment reads it - the label only. The match
623
+ * predicate that decides membership stays internal to `CngxBucketPaginate`; a
624
+ * presentation segment never needs it, only the label to render and the
625
+ * derived empty/active state to reflect.
626
+ *
627
+ * @category common/data/paginate
628
+ */
629
+ interface CngxBucketPaginateView {
630
+ /** Human-readable bucket label, e.g. `'A-C'`. Rendered as the chip text. */
631
+ readonly label: string;
632
+ }
633
+ /**
634
+ * Read-and-write contract a category/range chip strip (`cngx-pgn-alpha`)
635
+ * injects instead of the concrete `CngxBucketPaginate` directive. \
636
+ * The directive provides it via `useExisting`, so a chip strip stays
637
+ * decompose-ready - it talks to the token, never to the model class (DI
638
+ * abstraction).
639
+ *
640
+ * The signals are the single derivation source for every chip's pressed and
641
+ * disabled state; `select` / `clear` are the only write paths, each routing
642
+ * through the directive's `active` model so the toggle invariant (re-selecting
643
+ * the active bucket clears it) holds in one place.
644
+ *
645
+ * @category common/data/paginate
646
+ */
647
+ interface CngxBucketPaginateHost {
648
+ /** The buckets to render, in declaration order. One chip per entry. */
649
+ readonly buckets: Signal<readonly CngxBucketPaginateView[]>;
650
+ /** Label of the active bucket, or `null` when no bucket is selected. */
651
+ readonly active: Signal<string | null>;
652
+ /**
653
+ * `true` when no bound item matches the bucket's predicate. Derived from the
654
+ * `items` / `buckets` inputs (never a synced flag); a chip binds its disabled
655
+ * state to this so an empty bucket is a dead control with a stated reason.
656
+ */
657
+ isEmpty(label: string): boolean;
658
+ /**
659
+ * Select the bucket. Re-selecting the already-active bucket clears the
660
+ * selection (toggle). No-op for an empty bucket.
661
+ */
662
+ select(label: string): void;
663
+ /** Clear the active bucket (show the unfiltered collection). */
664
+ clear(): void;
665
+ }
666
+ /**
667
+ * DI token the `CngxBucketPaginate` range model provides via `useExisting`.
668
+ * The category chips segment (`cngx-pgn-alpha`) injects this rather than the
669
+ * concrete directive class, keeping the strip decompose-ready and the model
670
+ * swappable.
671
+ *
672
+ * @category common/data/paginate
673
+ * @wcag AA
674
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/paginate/bucket-paginate-host.token.ts
675
+ * @since 0.1.0
676
+ */
677
+ declare const CNGX_BUCKET_PAGINATE_HOST: InjectionToken<CngxBucketPaginateHost>;
678
+
679
+ /**
680
+ * A category bucket: a label plus a predicate that decides which items fall
681
+ * into it. The predicate keeps the model content-agnostic - the same directive
682
+ * buckets by letter range, date band, price tier, or any other partition the
683
+ * consumer expresses, without the brain knowing what it is bucketing.
684
+ *
685
+ * @category common/data/paginate
686
+ */
687
+ interface CngxBucket<T> {
688
+ /** Human-readable bucket label, e.g. `'A-C'`. Rendered as the chip text. */
689
+ readonly label: string;
690
+ /** Returns `true` when `item` belongs to this bucket. */
691
+ readonly match: (item: T) => boolean;
692
+ }
693
+ /**
694
+ * Range/category pagination model - a sibling to {@link CngxPaginate}, NOT a
695
+ * mode flag on it. Where `CngxPaginate` steps a page index over a slice window,
696
+ * this directive partitions a collection into labelled buckets (letter ranges,
697
+ * date bands, price tiers) and tracks which one is active. The page-index brain
698
+ * stays single-responsibility; a consumer composes whichever model the data
699
+ * calls for (Komposition statt Konfiguration).
700
+ *
701
+ * The empty/disabled state of every bucket is **derived**, never managed: a
702
+ * bucket is empty when no bound item matches its predicate, computed from the
703
+ * `items` / `buckets` inputs. There is no synced flag and no effect.
704
+ *
705
+ * `active` is the two-way primary value (a `model<string | null>()`):
706
+ * `null` shows the unfiltered collection; a label filters to that bucket.
707
+ * `select(label)` toggles - re-selecting the active bucket clears it.
708
+ *
709
+ * ```html
710
+ * <div
711
+ * cngxBucketPaginate
712
+ * #bp="cngxBucketPaginate"
713
+ * [buckets]="letterBuckets"
714
+ * [items]="people"
715
+ * [(active)]="activeBucket"
716
+ * >
717
+ * @for (p of bp.active() ? people.filter(byActiveBucket) : people; track p.id) { ... }
718
+ * </div>
719
+ * ```
720
+ *
721
+ * @category common/data/paginate
722
+ * @docsKind primary
723
+ * @wcag AA
724
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/paginate/bucket-paginate.directive.ts
725
+ * @since 0.1.0
726
+ * @relatedTo CngxPaginate, CngxFilter
727
+ * <example-url>http://localhost:4200/#/ui/paginator/paginator-modes/alphabetical</example-url>
728
+ */
729
+ declare class CngxBucketPaginate<T = unknown> implements CngxBucketPaginateHost {
730
+ /** The buckets to partition into, in render order. One chip per entry. */
731
+ readonly buckets: _angular_core.InputSignal<readonly CngxBucket<T>[]>;
732
+ /** The collection the buckets test against. Drives the derived empty state. */
733
+ readonly items: _angular_core.InputSignal<readonly T[]>;
734
+ /**
735
+ * Active bucket label, or `null` for the unfiltered collection. The two-way
736
+ * primary value (`[(active)]`); a `model()` because it is the directive's
737
+ * bindable state, not a derived read.
738
+ */
739
+ readonly active: _angular_core.ModelSignal<string | null>;
740
+ /**
741
+ * Labels of every bucket whose predicate matches no bound item. A pure
742
+ * `computed()` over `items` / `buckets` - the disabled chips read this, so
743
+ * the empty state is derived, never synced. The explicit set `equal` stops a
744
+ * fresh-`Set` identity from cascading downstream on every unrelated recompute.
745
+ */
746
+ private readonly emptyLabels;
747
+ /** `true` when no bound item falls into the bucket. */
748
+ isEmpty(label: string): boolean;
749
+ /**
750
+ * Select the bucket, or clear the selection when it is already active
751
+ * (toggle). An empty bucket is a no-op - it never becomes the active filter.
752
+ */
753
+ select(label: string): void;
754
+ /** Clear the active bucket - show the unfiltered collection. */
755
+ clear(): void;
756
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxBucketPaginate<any>, never>;
757
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxBucketPaginate<any>, "[cngxBucketPaginate]", ["cngxBucketPaginate"], { "buckets": { "alias": "buckets"; "required": false; "isSignal": true; }; "items": { "alias": "items"; "required": false; "isSignal": true; }; "active": { "alias": "active"; "required": false; "isSignal": true; }; }, { "active": "activeChange"; }, never, never, true, never>;
758
+ }
759
+
524
760
  /**
525
761
  * Minimal CDK `DataSource` that bridges a Signal to the CDK table's
526
762
  * Observable-based data contract.
@@ -824,6 +1060,162 @@ type AsyncView = 'none' | 'skeleton' | 'content' | 'empty' | 'error' | 'content+
824
1060
  */
825
1061
  declare function resolveAsyncView(status: AsyncStatus, firstLoad: boolean, empty: boolean): AsyncView;
826
1062
 
1063
+ /**
1064
+ * Bridge that projects an Angular `Resource<T>` onto `CngxAsyncState<T>`.
1065
+ *
1066
+ * Must be called in an injection context (the `effect()` that tracks
1067
+ * `hadSuccess` requires one).
1068
+ *
1069
+ * All signals are derived reactively from the resource — no manual
1070
+ * synchronization. The resource stays the single source of truth.
1071
+ *
1072
+ * ```typescript
1073
+ * private readonly res = resource({
1074
+ * request: () => ({ filter: this.filter() }),
1075
+ * loader: ({ request, abortSignal }) =>
1076
+ * fetch(`/api/items?q=${request.filter}`, { signal: abortSignal })
1077
+ * .then(r => r.json()),
1078
+ * });
1079
+ *
1080
+ * readonly items = fromResource(this.res);
1081
+ * // items.status(), items.data(), items.isFirstLoad() — all work
1082
+ * // <cngx-async-container [state]="items"> — direct binding
1083
+ * ```
1084
+ *
1085
+ * @category common/data/async-state
1086
+ */
1087
+ declare function fromResource<T>(ref: Resource<T>): CngxAsyncState<T>;
1088
+
1089
+ /**
1090
+ * Shape of an `HttpResourceRef` — only the signals we need.
1091
+ *
1092
+ * Declared here to avoid a hard dependency on `@angular/common/http`.
1093
+ * The consumer passes the actual `httpResource()` return value which
1094
+ * satisfies this interface at runtime.
1095
+ */
1096
+ interface HttpResourceLike<T> extends Resource<T> {
1097
+ progress: () => number | undefined;
1098
+ }
1099
+ /**
1100
+ * Bridge that projects an Angular `httpResource()` ref onto `CngxAsyncState<T>`.
1101
+ *
1102
+ * Identical to `fromResource` but additionally maps the HTTP progress
1103
+ * signal to `CngxAsyncState.progress` (0–100 scale).
1104
+ *
1105
+ * Must be called in an injection context.
1106
+ *
1107
+ * ```typescript
1108
+ * private readonly res = httpResource<Item[]>(() => ({
1109
+ * url: '/api/items',
1110
+ * params: { q: this.filter() },
1111
+ * }));
1112
+ *
1113
+ * readonly items = fromHttpResource(this.res);
1114
+ * // items.progress() tracks upload/download progress
1115
+ * // <cngx-progress [state]="items"> — auto-wired progress bar
1116
+ * ```
1117
+ *
1118
+ * @category common/data/async-state
1119
+ */
1120
+ declare function fromHttpResource<T>(ref: HttpResourceLike<T>): CngxAsyncState<T>;
1121
+
1122
+ /**
1123
+ * Minimal write interface for async state operators.
1124
+ *
1125
+ * Any `ManualAsyncState<T>` satisfies this — operators only need the write side.
1126
+ */
1127
+ interface AsyncStateSink<T> {
1128
+ set(status: 'loading' | 'refreshing' | 'pending'): void;
1129
+ setSuccess(data: T): void;
1130
+ setError(error: unknown): void;
1131
+ setProgress(value: number | undefined): void;
1132
+ }
1133
+ /**
1134
+ * RxJS operator that wires an Observable's lifecycle to a `ManualAsyncState`.
1135
+ *
1136
+ * On subscribe: sets `loading` (or `refreshing` if data was already loaded).
1137
+ * On next: calls `setSuccess(value)`.
1138
+ * On error: calls `setError(err)` and **re-throws** (does not swallow).
1139
+ *
1140
+ * The Observable passes through unchanged — `tapAsyncState` is a side-effect operator.
1141
+ *
1142
+ * ```typescript
1143
+ * readonly residents = createManualState<Resident[]>();
1144
+ *
1145
+ * load(): void {
1146
+ * this.http.get<Resident[]>('/api/residents').pipe(
1147
+ * tapAsyncState(this.residents),
1148
+ * takeUntilDestroyed(this.destroyRef),
1149
+ * ).subscribe();
1150
+ * }
1151
+ * ```
1152
+ *
1153
+ * @category common/data/async-state
1154
+ */
1155
+ declare function tapAsyncState<T>(state: AsyncStateSink<T>, options?: {
1156
+ status?: 'loading' | 'refreshing' | 'pending';
1157
+ }): MonoTypeOperatorFunction<T>;
1158
+ /**
1159
+ * RxJS operator that extracts upload/download progress from an
1160
+ * `HttpEvent` stream and reports it to a `ManualAsyncState`.
1161
+ *
1162
+ * Filters progress events, calculates percentage, calls `setProgress()`.
1163
+ * Non-progress events pass through unchanged.
1164
+ *
1165
+ * Use with `{ observe: 'events', reportProgress: true }` on HttpClient.
1166
+ *
1167
+ * ```typescript
1168
+ * readonly upload = createManualState<UploadResult>();
1169
+ *
1170
+ * handleUpload(file: File): void {
1171
+ * this.http.post('/api/upload', file, {
1172
+ * reportProgress: true,
1173
+ * observe: 'events',
1174
+ * }).pipe(
1175
+ * tapAsyncProgress(this.upload),
1176
+ * takeUntilDestroyed(this.destroyRef),
1177
+ * ).subscribe();
1178
+ * }
1179
+ * ```
1180
+ *
1181
+ * @category common/data/async-state
1182
+ */
1183
+ declare function tapAsyncProgress<E>(state: Pick<AsyncStateSink<unknown>, 'setProgress'>): MonoTypeOperatorFunction<E>;
1184
+ /**
1185
+ * RxJS operator that combines `tapAsyncState` + `tapAsyncProgress` for HTTP event streams.
1186
+ *
1187
+ * Pipe this onto an `HttpClient` call with `{ observe: 'events', reportProgress: true }`.
1188
+ * It will:
1189
+ * 1. Set `loading` on subscribe
1190
+ * 2. Report upload/download progress via `setProgress()`
1191
+ * 3. Extract the response body on `HttpEventType.Response`
1192
+ * 4. Call `setSuccess(body)` with the extracted body
1193
+ * 5. Call `setError(err)` on error
1194
+ *
1195
+ * The output Observable emits the **response body** (not HttpEvents).
1196
+ * Throws if the response body is `null`.
1197
+ *
1198
+ * ```typescript
1199
+ * readonly upload = createManualState<UploadResult>();
1200
+ *
1201
+ * handleUpload(file: File): void {
1202
+ * this.http.post('/api/upload', file, {
1203
+ * reportProgress: true,
1204
+ * observe: 'events',
1205
+ * }).pipe(
1206
+ * tapHttpAsyncState(this.upload),
1207
+ * takeUntilDestroyed(this.destroyRef),
1208
+ * ).subscribe();
1209
+ * // upload.status(), upload.progress(), upload.data() — all wired
1210
+ * }
1211
+ * ```
1212
+ *
1213
+ * @category common/data/async-state
1214
+ */
1215
+ declare function tapHttpAsyncState<T>(state: AsyncStateSink<T>, options?: {
1216
+ status?: 'loading' | 'refreshing' | 'pending';
1217
+ }): OperatorFunction<unknown, T>;
1218
+
827
1219
  /**
828
1220
  * Template context for the `*cngxAsync` content template.
829
1221
  * `$implicit` provides the data value, typed via `ngTemplateContextGuard`.
@@ -1584,9 +1976,8 @@ declare const CNGX_COMMIT_CONTROLLER_FACTORY: InjectionToken<CngxCommitControlle
1584
1976
  *
1585
1977
  * Material types never enter this surface. The caller maps Material's
1586
1978
  * own event/property shape to a host-agnostic `Signal<number>` /
1587
- * `Observable<number>` / getter / setter at the directive boundary.
1588
- * That keeps `@cngx/common/data` independent of `@angular/material`
1589
- * (Sheriff Level-2 invariant).
1979
+ * `Observable<number>` / getter / setter at the directive boundary. \
1980
+ * That keeps `@cngx/common/data` independent of `@angular/material`.
1590
1981
  *
1591
1982
  * @category common/data/material-bridge
1592
1983
  */
@@ -1629,6 +2020,22 @@ interface CngxMaterialBidirectionalSyncOptions {
1629
2020
  /** DestroyRef used to clean up the effect and the subscription. */
1630
2021
  readonly destroyRef: DestroyRef;
1631
2022
  }
2023
+ /**
2024
+ * Handle returned by {@link createMaterialBidirectionalSync}.
2025
+ *
2026
+ * @category common/data/material-bridge
2027
+ */
2028
+ interface CngxMaterialBidirectionalSyncHandle {
2029
+ /**
2030
+ * Force Material's selected index to the presenter's current index,
2031
+ * routed through the factory's self-echo suppression so it never
2032
+ * re-enters the Material→presenter path. Hosts call this from their
2033
+ * commit lifecycle when a pessimistic commit settles WITHOUT advancing
2034
+ * the presenter (a rejected switch), which leaves Material eager-
2035
+ * advanced on the refused tab. A no-op when already in sync.
2036
+ */
2037
+ readonly reconcile: () => void;
2038
+ }
1632
2039
  /**
1633
2040
  * Single shared bidirectional-sync factory for cngx organisms /
1634
2041
  * directives that bridge a cngx presenter against a Material parent
@@ -1654,39 +2061,37 @@ interface CngxMaterialBidirectionalSyncOptions {
1654
2061
  *
1655
2062
  * Both sides clean up via `destroyRef`.
1656
2063
  *
1657
- * **Pessimistic-commit gate (deliberately absent).** An earlier draft
1658
- * carried a third option `commitState: CngxAsyncState<unknown>` that
1659
- * gated the Material write while `commitState.isPending()`. The plan
1660
- * (`global-material-bridge-and-architecture-hardening-plan` §54)
1661
- * specified this gate "for the pessimistic flow." Implementation
1662
- * showed the gate is redundant: cngx commit handlers already keep
1663
- * `presenter.activeIndex` at the origin during pessimistic-pending,
1664
- * so the equality guard alone suppresses the Material write.
1665
- * Conversely, in optimistic mode the presenter advances IMMEDIATELY
1666
- * (before the commit settles); a `pending`-keyed gate would suppress
1667
- * that legitimate advance and break the optimistic UX. Dropping the
1668
- * gate makes both modes work via the simple presenter→Material
1669
- * mirror — same outcome as the gate version for pessimistic, and the
1670
- * correct outcome for optimistic.
1671
- *
1672
2064
  * **Material-eager-advance reconciliation.** Material's MDC click
1673
- * handler advances `selectedIndex` synchronously *before* the
1674
- * Material→presenter subscription forwards the click to
1675
- * `onMaterialSelection`. When the presenter HOLDS its index
1676
- * (pessimistic mode + bound `commitAction`, or any future contract
1677
- * that refuses a select), the presenter→Material `effect()` does
1678
- * NOT fire — `presenterIndex` did not change — so Material's
1679
- * eager-advance is never reverted, and the visual diverges from the
1680
- * cngx semantic state. Closes `tabs-accepted-debt §6` by force-
1681
- * writing Material back to the presenter's value when the
1682
- * forwarding callback returns and the values still diverge. Idempotent
1683
- * with the regular presenter→Material effect (the read-equality guard
1684
- * at the effect site suppresses a duplicate write when the presenter
1685
- * later changes to the same value).
2065
+ * handler advances `selectedIndex` *before* the Material→presenter
2066
+ * subscription forwards the click. When the presenter HOLDS its index
2067
+ * (pessimistic mode + bound `commitAction`), the subscriber does NOT
2068
+ * write Material back: on a SUCCESSFUL commit the presenter later
2069
+ * advances to the clicked target and Material is already there, so the
2070
+ * mirror effect is a no-op (no flash); on a REJECTED commit the presenter
2071
+ * never moves, leaving Material eager-advanced on the refused tab. The
2072
+ * host detects the rejection through its own commit lifecycle and calls
2073
+ * {@link CngxMaterialBidirectionalSyncHandle.reconcile} to snap Material
2074
+ * back. Writing from inside the subscriber instead is unsafe: Material's
2075
+ * `selectedIndex` read-back lags a programmatic write, so the mirror
2076
+ * effect's equality guard reads a stale value and skips the corrective
2077
+ * write, sticking the visual on the wrong tab.
2078
+ *
2079
+ * **Self-echo suppression (loop-safety).** Every programmatic
2080
+ * `selectedIndex` write makes Material re-emit `selectionChange`. The
2081
+ * factory records each value it writes and drops the matching echo
2082
+ * (`indexOf` + splice, which also prunes earlier writes whose echo
2083
+ * Material coalesced away) before any other processing. This is
2084
+ * load-bearing for an ASYNC commit-action: Material emits the echo a
2085
+ * microtask later, by which point the commit may have advanced
2086
+ * `presenterIndex`, so an equality-only guard (`presenterIndex() ===
2087
+ * idx`) would FAIL to drop the echo — it would re-enter the subscriber
2088
+ * and ping-pong against the in-flight navigation (the demo freezes).
2089
+ * Matching the echo by the value we wrote drops it regardless of where
2090
+ * the presenter has moved.
1686
2091
  *
1687
2092
  * @category common/data/material-bridge
1688
2093
  */
1689
- declare function createMaterialBidirectionalSync(opts: CngxMaterialBidirectionalSyncOptions): void;
2094
+ declare function createMaterialBidirectionalSync(opts: CngxMaterialBidirectionalSyncOptions): CngxMaterialBidirectionalSyncHandle;
1690
2095
 
1691
- export { CNGX_COMMIT_CONTROLLER_FACTORY, CNGX_RECYCLER_I18N, CngxAsync, CngxDataSource, CngxFilter, CngxFilterChip, CngxFilterChips, CngxMeasure, CngxMetric, CngxPaginate, CngxRecyclerAnnouncer, CngxSmartDataSource, CngxSort, CngxSortHeader, CngxTrend, CngxVirtualItem, connectRecyclerToActiveDescendant, connectRecyclerToRoving, createAsyncState, createCommitController, createManualState, createMaterialBidirectionalSync, injectAsyncState, injectDataSource, injectRecycler, injectSmartDataSource, provideRecyclerI18n, resolveAsyncView };
1692
- export type { AsyncView, CngxAsyncContext, CngxCommitBeginHandlers, CngxCommitController, CngxCommitControllerFactory, CngxCommitHandle, CngxCommitRunner, CngxFilterChipContext, CngxMaterialBidirectionalSyncOptions, CngxRecycler, CngxSmartDataSourceOptions, InjectAsyncStateOptions, ManualAsyncState, MutableAsyncState, ReactiveAsyncState, RecyclerConfig, RecyclerI18n, SortEntry };
2096
+ export { CNGX_BUCKET_PAGINATE_HOST, CNGX_COMMIT_CONTROLLER_FACTORY, CNGX_RECYCLER_I18N, CngxAsync, CngxBucketPaginate, CngxDataSource, CngxFilter, CngxFilterChip, CngxFilterChips, CngxMeasure, CngxMetric, CngxPaginate, CngxPaginateResetOn, CngxPaginateRouting, CngxRecyclerAnnouncer, CngxSmartDataSource, CngxSort, CngxSortHeader, CngxTrend, CngxVirtualItem, connectPaginateResetOn, connectRecyclerToActiveDescendant, connectRecyclerToRoving, createAsyncState, createCommitController, createManualState, createMaterialBidirectionalSync, fromHttpResource, fromResource, injectAsyncState, injectDataSource, injectRecycler, injectSmartDataSource, provideRecyclerI18n, resolveAsyncView, tapAsyncProgress, tapAsyncState, tapHttpAsyncState };
2097
+ export type { AsyncView, CngxAsyncContext, CngxBucket, CngxBucketPaginateHost, CngxBucketPaginateView, CngxCommitBeginHandlers, CngxCommitController, CngxCommitControllerFactory, CngxCommitHandle, CngxCommitRunner, CngxFilterChipContext, CngxMaterialBidirectionalSyncHandle, CngxMaterialBidirectionalSyncOptions, CngxRecycler, CngxSmartDataSourceOptions, InjectAsyncStateOptions, ManualAsyncState, MutableAsyncState, ReactiveAsyncState, RecyclerConfig, RecyclerI18n, SortEntry };