@cngx/common 0.1.0-rc.0 → 0.1.0-rc.1

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.
@@ -1,8 +1,9 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Signal, InjectionToken, ModelSignal, TemplateRef, EnvironmentProviders, Provider, Injector } from '@angular/core';
2
+ import { Signal, InjectionToken, ModelSignal, TemplateRef, OnInit, EnvironmentProviders, Provider, Injector } from '@angular/core';
3
3
  import { CngxAsyncState, StatusTransition } from '@cngx/core/utils';
4
4
  import { Observable } from 'rxjs';
5
5
  import { CngxErrorAggregatorContract } from '@cngx/common/interactive';
6
+ import { Router } from '@angular/router';
6
7
  import { CngxCommitController } from '@cngx/common/data';
7
8
  import { CngxActiveDescendant, ActiveDescendantItem } from '@cngx/common/a11y';
8
9
  import { CngxPopover } from '@cngx/common/popover';
@@ -19,8 +20,51 @@ import { CngxPopover } from '@cngx/common/popover';
19
20
  interface CngxTabHandle {
20
21
  readonly id: string;
21
22
  readonly label: Signal<string | undefined>;
23
+ /**
24
+ * Optional secondary label line. Rendered stacked under the primary
25
+ * label by the organism and folded into the tab's accessible name.
26
+ * `undefined` (default) renders byte-identically to a single-line
27
+ * tab. `[cngxMatTabs]` pins this to `undefined` - Material owns its
28
+ * own tab chrome.
29
+ */
30
+ readonly subLabel: Signal<string | undefined>;
22
31
  readonly disabled: Signal<boolean>;
23
32
  readonly errorAggregator: Signal<CngxErrorAggregatorContract | undefined>;
33
+ /**
34
+ * Folded per-tab error state, exposed by reference. `true` when the
35
+ * direct `[error]` flag is set OR the aggregator wants to reveal
36
+ * (`shouldShow()`, so deferred-reveal validation stays silent until
37
+ * revealed). The organism gates the error badge + SR descriptor on
38
+ * this; both handle producers (`CngxTab`, `createMatTabHandle`)
39
+ * carry it.
40
+ */
41
+ readonly hasError: Signal<boolean>;
42
+ /**
43
+ * Resolved direct-error message - the `[error]` string when non-empty,
44
+ * else `undefined`. Rides the handle so the error badge slot can render
45
+ * it via `ctx.tab.errorMessage()`. `[cngxMatTabs]` pins this to
46
+ * `undefined` - Material owns its own tab chrome.
47
+ */
48
+ readonly errorMessage: Signal<string | undefined>;
49
+ /**
50
+ * Per-tab closable override. `undefined` (default) inherits the
51
+ * group-level `closable` resolution; `true`/`false` pin this tab's
52
+ * close affordance regardless of the group default (e.g. a
53
+ * non-closable "Home" tab inside an otherwise dismissable group).
54
+ */
55
+ readonly closable: Signal<boolean | undefined>;
56
+ }
57
+ /**
58
+ * Payload of {@link CngxTabGroupHost.tabClose}. Carries the closed
59
+ * tab's id and its index at close time. The consumer removes the tab
60
+ * from its own data in response; the presenter has already moved the
61
+ * active index to the surviving neighbour.
62
+ *
63
+ * @category common/tabs
64
+ */
65
+ interface CngxTabCloseEvent {
66
+ readonly id: string;
67
+ readonly index: number;
24
68
  }
25
69
  /**
26
70
  * Contract atoms see when they inject the presenter via
@@ -74,6 +118,20 @@ interface CngxTabGroupHost {
74
118
  selectNext(): void;
75
119
  selectPrevious(): void;
76
120
  selectById(id: string): void;
121
+ /**
122
+ * Request closing the tab with the given id. The presenter moves the
123
+ * active index onto the surviving neighbour (APG: next tab, or the
124
+ * previous one when closing the last tab) and emits `tabClose`; the
125
+ * consumer performs the actual removal from its data. No-op for an
126
+ * unknown id.
127
+ */
128
+ requestClose(id: string): void;
129
+ /**
130
+ * Request adding a new tab. Emits `tabAdd`; the consumer appends to
131
+ * its data. The presenter owns no tab-creation logic - tabs are
132
+ * derived from consumer data (Ableitung statt Verwaltung).
133
+ */
134
+ requestAdd(): void;
77
135
  /**
78
136
  * Clear {@link lastFailedIndex} without unwinding
79
137
  * {@link originIndexDuringCommit} (consumers gate reads on
@@ -85,7 +143,9 @@ interface CngxTabGroupHost {
85
143
  /**
86
144
  * DI token for the tab presenter's contract. Presenter provides via
87
145
  * `useExisting`; `CngxTab` injects to register; the organism injects
88
- * to forward keyboard nav from `CngxRovingTabindex`.
146
+ * to drive the APG tablist keyboard model (automatic activation via
147
+ * `select()`, roving stop derived from `activeId`) through
148
+ * `createTabKeyboardNav`.
89
149
  *
90
150
  * @category common/tabs
91
151
  * @wcag AA
@@ -133,15 +193,51 @@ declare class CngxTabGroupPresenter implements CngxTabGroupHost {
133
193
  * action's resolution decides whether the change lands. Supersede
134
194
  * semantics come from the commit-controller - a rapid second
135
195
  * `select(...)` cancels the in-flight runner.
196
+ *
197
+ * @internal Two-field alias - bind the public `[commitAction]`; read
198
+ * the resolved {@link commitAction} computed (input ?? DI fallback).
136
199
  */
137
- readonly commitAction: i0.InputSignal<CngxTabsCommitAction | null>;
200
+ readonly commitActionInput: i0.InputSignal<CngxTabsCommitAction | null>;
138
201
  /**
139
202
  * Default `'optimistic'` - tab change is navigation, not a save,
140
203
  * so eager visual feedback matches the user's mental model.
141
204
  * Switch to `'pessimistic'` when the new tab must wait for the
142
205
  * action to confirm.
206
+ *
207
+ * @internal Two-field alias - bind the public `[commitMode]`; read
208
+ * the resolved {@link commitMode} computed (DI fallback mode wins
209
+ * when a routed action is active).
210
+ */
211
+ readonly commitModeInput: i0.InputSignal<"optimistic" | "pessimistic">;
212
+ private readonly injector;
213
+ private injectedActionSource;
214
+ private resolveInjectedAction;
215
+ /**
216
+ * Resolved commit-action: the `[commitAction]` input when bound, else
217
+ * the {@link CNGX_TABS_COMMIT_ACTION} DI fallback (routed path), else
218
+ * `null`. `select()` reads this.
219
+ */
220
+ readonly commitAction: Signal<CngxTabsCommitAction | null>;
221
+ /**
222
+ * Resolved commit mode. When the DI fallback supplies an active
223
+ * action its `mode` wins - the routed path pins `'pessimistic'` so a
224
+ * stray `[commitMode]="'optimistic'"` cannot break the
225
+ * route-follows-resolution invariant. Otherwise the `[commitMode]`
226
+ * input drives.
227
+ */
228
+ readonly commitMode: Signal<"optimistic" | "pessimistic">;
229
+ /**
230
+ * Emitted when a tab's close affordance is activated (the close
231
+ * button or Delete/Backspace on the focused tab). The presenter has
232
+ * already moved the active index onto the surviving neighbour; the
233
+ * consumer removes the tab from its own data in the handler.
234
+ */
235
+ readonly tabClose: i0.OutputEmitterRef<CngxTabCloseEvent>;
236
+ /**
237
+ * Emitted when the add-tab affordance is activated. The consumer
238
+ * appends a tab to its own data; the presenter owns no creation logic.
143
239
  */
144
- readonly commitMode: i0.InputSignal<"optimistic" | "pessimistic">;
240
+ readonly tabAdd: i0.OutputEmitterRef<void>;
145
241
  private readonly genericFactory;
146
242
  private readonly commitController;
147
243
  private readonly commitHandler;
@@ -179,8 +275,10 @@ declare class CngxTabGroupPresenter implements CngxTabGroupHost {
179
275
  selectNext(): void;
180
276
  selectPrevious(): void;
181
277
  selectById(id: string): void;
278
+ requestClose(id: string): void;
279
+ requestAdd(): void;
182
280
  static ɵfac: i0.ɵɵFactoryDeclaration<CngxTabGroupPresenter, never>;
183
- static ɵdir: i0.ɵɵDirectiveDeclaration<CngxTabGroupPresenter, "[cngxTabGroup]", ["cngxTabGroup"], { "activeIndex": { "alias": "activeIndex"; "required": false; "isSignal": true; }; "orientation": { "alias": "orientation"; "required": false; "isSignal": true; }; "loop": { "alias": "loop"; "required": false; "isSignal": true; }; "commitAction": { "alias": "commitAction"; "required": false; "isSignal": true; }; "commitMode": { "alias": "commitMode"; "required": false; "isSignal": true; }; }, { "activeIndex": "activeIndexChange"; }, never, never, true, never>;
281
+ static ɵdir: i0.ɵɵDirectiveDeclaration<CngxTabGroupPresenter, "[cngxTabGroup]", ["cngxTabGroup"], { "activeIndex": { "alias": "activeIndex"; "required": false; "isSignal": true; }; "orientation": { "alias": "orientation"; "required": false; "isSignal": true; }; "loop": { "alias": "loop"; "required": false; "isSignal": true; }; "commitActionInput": { "alias": "commitAction"; "required": false; "isSignal": true; }; "commitModeInput": { "alias": "commitMode"; "required": false; "isSignal": true; }; }, { "activeIndex": "activeIndexChange"; "tabClose": "tabClose"; "tabAdd": "tabAdd"; }, never, never, true, never>;
184
282
  }
185
283
 
186
284
  /**
@@ -278,6 +376,34 @@ declare class CngxTabLabel {
278
376
  static ɵdir: i0.ɵɵDirectiveDeclaration<CngxTabLabel, "ng-template[cngxTabLabel]", ["cngxTabLabel"], {}, {}, never, never, true, never>;
279
377
  }
280
378
 
379
+ /**
380
+ * Structural slot directive marking a tab's secondary label template.
381
+ * Discovered by `<cngx-tab-group>` via `contentChild` on each
382
+ * `CngxTab` and rendered as a stacked second line under the primary
383
+ * label. Per-tab content, mirroring `CngxTabLabel` - the convenience
384
+ * `[subLabel]` string input on `CngxTab` covers the plain-text case.
385
+ *
386
+ * ```html
387
+ * <div cngxTab id="bookmarks">
388
+ * <ng-template cngxTabLabel>Bookmarks</ng-template>
389
+ * <ng-template cngxTabSubLabel>45 saved</ng-template>
390
+ * <ng-template cngxTabContent>...</ng-template>
391
+ * </div>
392
+ * ```
393
+ *
394
+ * @category common/tabs
395
+ * @wcag AA
396
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/slots/tab-sub-label.directive.ts
397
+ * @since 0.1.0
398
+ * @relatedTo CngxTab, CngxTabLabel, CngxTabContent
399
+ * <example-url>http://localhost:4200/#/ui/tabs/tab-sub-label/label-with-count</example-url>
400
+ */
401
+ declare class CngxTabSubLabel {
402
+ readonly templateRef: TemplateRef<any>;
403
+ static ɵfac: i0.ɵɵFactoryDeclaration<CngxTabSubLabel, never>;
404
+ static ɵdir: i0.ɵɵDirectiveDeclaration<CngxTabSubLabel, "ng-template[cngxTabSubLabel]", ["cngxTabSubLabel"], {}, {}, never, never, true, never>;
405
+ }
406
+
281
407
  /**
282
408
  * Single-tab atom. Registers with the enclosing presenter via
283
409
  * {@link CNGX_TAB_GROUP_HOST} on construction; deregisters via
@@ -301,19 +427,62 @@ declare class CngxTabLabel {
301
427
  * <example-url>http://localhost:4200/#/ui/tabs/tab-slot-overrides/custom-error-badge-via-code-cngxtaberrorbadge-code</example-url>
302
428
  * <example-url>http://localhost:4200/#/ui/tabs/tab-slot-overrides/rejection-decoration-via-code-cngxtabrejectionicon-code</example-url>
303
429
  */
304
- declare class CngxTab {
430
+ declare class CngxTab implements OnInit {
305
431
  readonly id: i0.InputSignal<string>;
306
432
  readonly disabled: i0.InputSignal<boolean>;
307
433
  readonly label: i0.InputSignal<string | undefined>;
434
+ /**
435
+ * Optional secondary text line under the primary label (a count, a
436
+ * status word, a short detail). Convenience for the common text
437
+ * case, parallel to `[label]`; the `*cngxTabSubLabel` slot covers
438
+ * richer content. Folds into the tab's accessible name.
439
+ */
440
+ readonly subLabel: i0.InputSignal<string | undefined>;
308
441
  readonly errorAggregator: i0.InputSignal<CngxErrorAggregatorContract | undefined>;
442
+ /**
443
+ * Direct error flag for the common "this tab is invalid" case - no
444
+ * `errorAggregator` boilerplate required. `true` or a non-empty string
445
+ * drives the error state; a string doubles as the inline message
446
+ * (surfaced via the `*cngxTabErrorBadge` slot context). `false` / `''`
447
+ * clear it. The aggregator stays the rich multi-source forms path; the
448
+ * two channels compose (either errors). Mirrors `CngxStep.error`.
449
+ */
450
+ readonly error: i0.InputSignal<string | boolean>;
451
+ /**
452
+ * Resolved direct-error message: the `[error]` string when non-empty,
453
+ * else `undefined`. Carried onto the registration handle so the error
454
+ * badge slot can render it. `computed` over the input - never written.
455
+ */
456
+ readonly errorMessage: Signal<string | undefined>;
457
+ /**
458
+ * Per-tab error fold driving the badge + SR descriptor. `true` when
459
+ * the direct `[error]` flag is set OR the optional aggregator wants to
460
+ * reveal (`shouldShow()` = `hasError` AND scope reveal-state). The
461
+ * aggregator arm reads `shouldShow`, not `hasError`, so deferred-reveal
462
+ * validation stays silent until revealed - the direct flag has no
463
+ * reveal concept (the consumer sets it when it wants it shown). A
464
+ * boolean, not a status enum: tabs carry no success/completed/disabled
465
+ * model (Pillar 3).
466
+ */
467
+ readonly hasError: Signal<boolean>;
468
+ /**
469
+ * Per-tab close-affordance override. `undefined` (default) inherits
470
+ * the group-level `[closable]` resolution; set `false` to pin this
471
+ * tab open inside a dismissable group, or `true` to make a single tab
472
+ * closable while the group default is off.
473
+ */
474
+ readonly closable: i0.InputSignal<boolean | undefined>;
309
475
  readonly labelTemplate: Signal<CngxTabLabel | undefined>;
476
+ readonly subLabelTemplate: Signal<CngxTabSubLabel | undefined>;
310
477
  readonly contentTemplate: Signal<CngxTabContent | undefined>;
311
478
  private readonly host;
479
+ private readonly destroyRef;
312
480
  /** `true` when the presenter's `activeId` equals this tab's id. */
313
481
  readonly selected: Signal<boolean>;
314
482
  constructor();
483
+ ngOnInit(): void;
315
484
  static ɵfac: i0.ɵɵFactoryDeclaration<CngxTab, never>;
316
- static ɵdir: i0.ɵɵDirectiveDeclaration<CngxTab, "[cngxTab]", ["cngxTab"], { "id": { "alias": "id"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "label": { "alias": "label"; "required": false; "isSignal": true; }; "errorAggregator": { "alias": "errorAggregator"; "required": false; "isSignal": true; }; }, {}, ["labelTemplate", "contentTemplate"], never, true, never>;
485
+ static ɵdir: i0.ɵɵDirectiveDeclaration<CngxTab, "[cngxTab]", ["cngxTab"], { "id": { "alias": "id"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "label": { "alias": "label"; "required": false; "isSignal": true; }; "subLabel": { "alias": "subLabel"; "required": false; "isSignal": true; }; "errorAggregator": { "alias": "errorAggregator"; "required": false; "isSignal": true; }; "error": { "alias": "error"; "required": false; "isSignal": true; }; "closable": { "alias": "closable"; "required": false; "isSignal": true; }; }, {}, ["labelTemplate", "subLabelTemplate", "contentTemplate"], never, true, never>;
317
486
  }
318
487
 
319
488
  /**
@@ -347,6 +516,153 @@ declare class CngxTabsFragmentSync {
347
516
  static ɵdir: i0.ɵɵDirectiveDeclaration<CngxTabsFragmentSync, "[cngxTabsFragmentSync]", ["cngxTabsFragmentSync"], { "mode": { "alias": "mode"; "required": false; "isSignal": true; }; "paramName": { "alias": "paramName"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
348
517
  }
349
518
 
519
+ /**
520
+ * Source supplied through {@link CNGX_TABS_COMMIT_ACTION}. A sync
521
+ * directive (e.g. `[cngxTabsRouteSync]`) provides one so the presenter
522
+ * picks up a commit-action without the consumer hand-binding
523
+ * `[commitAction]`. Carries `mode` alongside `action` so the routed
524
+ * path can pin pessimistic - the active tab must follow the *resolved*
525
+ * route, and a stray `[commitMode]="'optimistic'"` must not override
526
+ * that invariant.
527
+ *
528
+ * @category common/tabs
529
+ */
530
+ interface CngxTabsCommitActionSource {
531
+ readonly action: Signal<CngxTabsCommitAction | null>;
532
+ readonly mode: Signal<'optimistic' | 'pessimistic'>;
533
+ }
534
+ /**
535
+ * DI fallback the presenter reads when its `[commitAction]` input is
536
+ * unbound. Directives compose via DI tokens, not by hand-binding
537
+ * another directive's input (Pillar 3). When a source is present and
538
+ * exposes a non-null `action()`, its `mode()` wins over the
539
+ * `[commitMode]` input.
540
+ *
541
+ * @category common/tabs
542
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/commit-action.token.ts
543
+ * @since 0.1.0
544
+ */
545
+ declare const CNGX_TABS_COMMIT_ACTION: InjectionToken<CngxTabsCommitActionSource>;
546
+
547
+ /**
548
+ * Router-outlet integration for tab groups. Opt-in via
549
+ * `[cngxTabsRouteSync]` on the presenter element. Each tab is an
550
+ * Angular child route whose component renders into a `<router-outlet>`;
551
+ * switching tabs navigates, and a `CanDeactivate` guard can gate the
552
+ * leave.
553
+ *
554
+ * Supplies the presenter's commit-action through the
555
+ * {@link CNGX_TABS_COMMIT_ACTION} DI fallback (no consumer
556
+ * `[commitAction]` hand-binding) and pins **pessimistic** mode so the
557
+ * active tab follows the *resolved* route - a guard-cancelled switch
558
+ * keeps the old tab. The routing gate reuses the presenter's commit
559
+ * lifecycle verbatim; the router navigation is the async op.
560
+ *
561
+ * Seeds the active tab from the current URL on mount and reflects
562
+ * external navigations (back/forward, direct URL) into `activeIndex`
563
+ * *without* re-navigating - those writes bypass the commit-action,
564
+ * since the router is already at the resolved route.
565
+ *
566
+ * `Router` is optional - without it the directive logs a single dev
567
+ * warning via `afterNextRender`, exposes a null action, and becomes a
568
+ * no-op. Mirrors {@link CngxTabsFragmentSync}; every `activeIndex`
569
+ * write inside an effect sits in `untracked()`.
570
+ *
571
+ * @category common/tabs
572
+ * @docsKind primary
573
+ * @wcag AA
574
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/route-sync.directive.ts
575
+ * @since 0.1.0
576
+ * @relatedTo CngxTabGroupPresenter, CngxTabsFragmentSync, createTabRouterCommit
577
+ */
578
+ declare class CngxTabsRouteSync implements CngxTabsCommitActionSource {
579
+ /**
580
+ * Maps a tab handle to its router command array. Default
581
+ * `(handle) => [handle.id]` - the tab id is the child segment.
582
+ * Override for real route paths.
583
+ */
584
+ readonly routeFor: i0.InputSignal<(handle: CngxTabHandle) => unknown[]>;
585
+ private readonly host;
586
+ private readonly router;
587
+ /**
588
+ * Pessimistic-only - not exposed as an input. The route-sync owns the
589
+ * mode so optimistic (show-then-revert) can never flash the target
590
+ * tab before a `CanDeactivate` guard decides.
591
+ */
592
+ readonly mode: Signal<'optimistic' | 'pessimistic'>;
593
+ /**
594
+ * Router commit-action read by the presenter via the DI fallback.
595
+ * `null` when no `Router` is available (graceful no-op). Rebuilt only
596
+ * when `routeFor` changes; the navigation gate itself is the async
597
+ * op inside the action.
598
+ */
599
+ readonly action: Signal<CngxTabsCommitAction | null>;
600
+ constructor();
601
+ /**
602
+ * Mirror the URL's active tab onto `activeIndex` without navigating.
603
+ * Writing the index directly (not via `select()`) is the re-entry
604
+ * guard: `select()` would re-run the commit-action and navigate to
605
+ * the route the router is already on, leaving the commit pending
606
+ * forever.
607
+ */
608
+ private reflectFromUrl;
609
+ /**
610
+ * Find the tab whose route is the trailing segment(s) of the current
611
+ * URL path. Anchors on position (a suffix match), not a loose
612
+ * "appears anywhere" scan - a tab id that happens to equal an
613
+ * unrelated parent segment cannot win. The path is taken before any
614
+ * query/fragment. If two tabs produce the same trailing segment(s)
615
+ * (only possible with a custom `routeFor` that collides), the first
616
+ * registered tab wins - the default id-based mapping never collides.
617
+ */
618
+ private readActiveId;
619
+ static ɵfac: i0.ɵɵFactoryDeclaration<CngxTabsRouteSync, never>;
620
+ static ɵdir: i0.ɵɵDirectiveDeclaration<CngxTabsRouteSync, "[cngxTabsRouteSync]", ["cngxTabsRouteSync"], { "routeFor": { "alias": "routeFor"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
621
+ }
622
+
623
+ /**
624
+ * Options for {@link createTabRouterCommit}.
625
+ *
626
+ * `tabs` is the presenter's live handle list - the action receives the
627
+ * target *index*, so it needs the registry to resolve the matching
628
+ * {@link CngxTabHandle} before computing its route. `[cngxTabsRouteSync]`
629
+ * passes the host's `tabs` signal straight through.
630
+ *
631
+ * @category common/tabs
632
+ */
633
+ interface CngxTabRouterCommitOptions {
634
+ readonly router: Router;
635
+ readonly tabs: () => readonly CngxTabHandle[];
636
+ /**
637
+ * Maps a tab handle to its router command array. Default
638
+ * `(handle) => [handle.id]` - the tab id is the child segment.
639
+ * Override for real route paths (`(h) => ['settings', h.id]`).
640
+ */
641
+ readonly routeFor?: (handle: CngxTabHandle) => unknown[];
642
+ }
643
+ /**
644
+ * Builds a {@link CngxTabsCommitAction} that gates a tab switch through
645
+ * `@angular/router`. The action navigates to the target tab's route and
646
+ * resolves on the router's own outcome:
647
+ *
648
+ * - `NavigationEnd` → `true` (commit the switch)
649
+ * - `NavigationCancel` (a `CanDeactivate` guard blocked) → `false`
650
+ * - `NavigationError` (guard/resolver threw) → `false`
651
+ *
652
+ * Routed tabs reuse the presenter's commit lifecycle verbatim - the
653
+ * router navigation is simply the async op. In pessimistic mode the
654
+ * active tab follows the *resolved* route, so a cancelled guard keeps
655
+ * the old tab with zero extra gate machinery. The events subscription
656
+ * is opened *before* `navigate(...)` so a synchronously-resolving
657
+ * navigation cannot emit before the action is listening; the commit
658
+ * controller's `cancel()` unsubscribes on supersede.
659
+ *
660
+ * @category common/tabs
661
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/router-commit.ts
662
+ * @since 0.1.0
663
+ */
664
+ declare function createTabRouterCommit(opts: CngxTabRouterCommitOptions): CngxTabsCommitAction;
665
+
350
666
  /**
351
667
  * Context for the `*cngxTabOverflowItem` template. Replaces the
352
668
  * default `tab.label() ?? tab.id` text inside the More popover; the
@@ -483,6 +799,42 @@ declare class CngxTabBusySpinner {
483
799
  static ɵdir: i0.ɵɵDirectiveDeclaration<CngxTabBusySpinner, "ng-template[cngxTabBusySpinner]", ["cngxTabBusySpinner"], {}, {}, never, never, true, never>;
484
800
  }
485
801
 
802
+ /**
803
+ * Context for the `*cngxTabCloseIcon` template. Rendered inside each
804
+ * closable tab's close button (the button itself owns the
805
+ * `aria-label`); the template paints only the glyph, so it carries the
806
+ * tab handle in case the visual varies per tab.
807
+ *
808
+ * @category common/tabs/slots
809
+ */
810
+ interface CngxTabCloseIconContext {
811
+ /** The tab handle whose close button this icon paints. */
812
+ readonly tab: CngxTabHandle;
813
+ }
814
+ /**
815
+ * Structural slot for a tab's close-button glyph. 3-stage cascade:
816
+ * per-instance directive > `CNGX_TABS_CONFIG.templates.closeIcon` >
817
+ * `CNGX_TABS_GLYPHS.closeIcon`.
818
+ *
819
+ * ```html
820
+ * <cngx-tab-group closable (tabClose)="remove($event.id)">
821
+ * <ng-template cngxTabCloseIcon><cngx-icon name="close" /></ng-template>
822
+ * ...
823
+ * </cngx-tab-group>
824
+ * ```
825
+ *
826
+ * @category common/tabs/slots
827
+ * @wcag AA
828
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/slots/tab-close-icon.directive.ts
829
+ * @since 0.1.0
830
+ * @relatedTo CngxTabAddIcon, CngxTabGroup
831
+ */
832
+ declare class CngxTabCloseIcon {
833
+ readonly templateRef: TemplateRef<CngxTabCloseIconContext>;
834
+ static ɵfac: i0.ɵɵFactoryDeclaration<CngxTabCloseIcon, never>;
835
+ static ɵdir: i0.ɵɵDirectiveDeclaration<CngxTabCloseIcon, "ng-template[cngxTabCloseIcon]", ["cngxTabCloseIcon"], {}, {}, never, never, true, never>;
836
+ }
837
+
486
838
  /**
487
839
  * Context for the `*cngxTabErrorBadge` template. Renders only when
488
840
  * the tab's `errorAggregator?.shouldShow()` is `true`; the visibility
@@ -525,6 +877,50 @@ declare class CngxTabErrorBadge {
525
877
  static ɵdir: i0.ɵɵDirectiveDeclaration<CngxTabErrorBadge, "ng-template[cngxTabErrorBadge]", ["cngxTabErrorBadge"], {}, {}, never, never, true, never>;
526
878
  }
527
879
 
880
+ /**
881
+ * Context for the `*cngxTabIcon` template. Rendered once per tab in the
882
+ * header, ahead of the label. Carries the tab handle plus the two
883
+ * per-tab signals a consumer icon usually keys off - whether the tab is
884
+ * the active one and its positional index. Richer than
885
+ * {@link CngxTabErrorBadgeContext} (which only needs `tab`) because an
886
+ * icon commonly swaps glyph on the active tab.
887
+ *
888
+ * @category common/tabs/slots
889
+ */
890
+ interface CngxTabIconContext {
891
+ /** The tab handle carrying id / label / disabled / aggregator signals. */
892
+ readonly tab: CngxTabHandle;
893
+ /** Whether this tab is the currently active one. */
894
+ readonly active: boolean;
895
+ /** Zero-based position of the tab in the strip. */
896
+ readonly index: number;
897
+ }
898
+ /**
899
+ * Structural slot for the tab-icon template. One group-level slot with
900
+ * per-tab context (stepper-slot parity), not a per-`CngxTab` input.
901
+ * 3-stage cascade: per-instance directive >
902
+ * `CNGX_TABS_CONFIG.templates.icon` > none (no icon rendered).
903
+ *
904
+ * ```html
905
+ * <cngx-tab-group iconLayout="start">
906
+ * <ng-template cngxTabIcon let-tab="tab" let-active="active">
907
+ * <cngx-icon [name]="active ? 'folder-open' : 'folder'" />
908
+ * </ng-template>
909
+ * </cngx-tab-group>
910
+ * ```
911
+ *
912
+ * @category common/tabs/slots
913
+ * @wcag AA
914
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/slots/tab-icon.directive.ts
915
+ * @since 0.1.0
916
+ * @relatedTo CngxTabErrorBadge, CngxTab, CngxTabGroup
917
+ */
918
+ declare class CngxTabIcon {
919
+ readonly templateRef: TemplateRef<CngxTabIconContext>;
920
+ static ɵfac: i0.ɵɵFactoryDeclaration<CngxTabIcon, never>;
921
+ static ɵdir: i0.ɵɵDirectiveDeclaration<CngxTabIcon, "ng-template[cngxTabIcon]", ["cngxTabIcon"], {}, {}, never, never, true, never>;
922
+ }
923
+
528
924
  /**
529
925
  * Context for the `*cngxTabRejectionIcon` template. Renders only on
530
926
  * the tab matching `presenter.lastFailedIndex()`; the visibility
@@ -618,7 +1014,60 @@ interface CngxTabsTemplates {
618
1014
  readonly errorBadge?: TemplateRef<CngxTabErrorBadgeContext>;
619
1015
  readonly rejectionIcon?: TemplateRef<CngxTabRejectionIconContext>;
620
1016
  readonly busySpinner?: TemplateRef<CngxTabBusySpinnerContext>;
1017
+ readonly icon?: TemplateRef<CngxTabIconContext>;
1018
+ readonly closeIcon?: TemplateRef<CngxTabCloseIconContext>;
1019
+ readonly addIcon?: TemplateRef<void>;
621
1020
  }
1021
+ /**
1022
+ * Selectable visual skin for `<cngx-tab-group>`. The skin is a pure
1023
+ * thematic concern - every value renders the same `tablist` / `tab` /
1024
+ * `tabpanel` structure, slots, ARIA, and keyboard behaviour, and only
1025
+ * redirects CSS via the `[data-skin]` host attribute. `'line'`
1026
+ * (default) is the underline indicator; `'contained'` fuses the active
1027
+ * tab with the panel surface; `'segmented'` sits the tabs in a muted
1028
+ * track and lifts the active tab onto a raised surface; `'pill'`
1029
+ * renders rounded solid fills; `'pill-outline'` renders the same pill
1030
+ * geometry with a tinted, outlined active state instead of a solid
1031
+ * fill. Sized to the tab use cases - not a 1:1 copy of the stepper's
1032
+ * seven skins. The Material twin (`[cngxMatTabs]`) ignores this setting.
1033
+ *
1034
+ * @category common/tabs
1035
+ */
1036
+ type CngxTabsSkin = 'line' | 'contained' | 'segmented' | 'pill' | 'pill-outline';
1037
+ /**
1038
+ * Icon-layout axis for `<cngx-tab-group>`, orthogonal to both skin and
1039
+ * orientation. Positions the `*cngxTabIcon` slot relative to the tab
1040
+ * label: `'start'` (default) places the icon before the label in a row;
1041
+ * `'end'` places it after the label in a row; `'top'` stacks the icon
1042
+ * above the label in a column; `'only'` hides the label visually while
1043
+ * keeping it in the DOM as the accessible name. Redirected purely via
1044
+ * the `[data-icon-layout]` host attribute.
1045
+ *
1046
+ * @category common/tabs
1047
+ */
1048
+ type CngxTabIconLayout = 'start' | 'end' | 'top' | 'only';
1049
+ /**
1050
+ * Panel render strategy for `<cngx-tab-group>`. The panel `<div>` (the
1051
+ * `aria-controls` target) always stays in the DOM; only its content is
1052
+ * rendered per mode. `'eager'` (default) renders every panel's content
1053
+ * up front and toggles visibility via `[hidden]` - today's behaviour,
1054
+ * byte-identical. `'lazy'` renders a panel's content the first time it
1055
+ * is activated and keeps it (keep-alive). `'lazy-destroy'` renders only
1056
+ * the active panel's content and destroys it on leave.
1057
+ *
1058
+ * @category common/tabs
1059
+ */
1060
+ type CngxTabsPanelMode = 'eager' | 'lazy' | 'lazy-destroy';
1061
+ /**
1062
+ * Horizontal alignment of the tab cluster along the strip, set via the
1063
+ * `[tabAlign]` Input and reflected onto `[data-tab-align]`. `'start'`
1064
+ * (default), `'center'`, or `'end'`. Horizontal only - ignored under
1065
+ * `orientation="vertical"` (tabs fill the column) and when `[fitted]`
1066
+ * stretches them to the full width.
1067
+ *
1068
+ * @category common/tabs
1069
+ */
1070
+ type CngxTabAlign = 'start' | 'center' | 'end';
622
1071
  /**
623
1072
  * Tab-group config surface. Resolution priority: per-instance Input
624
1073
  * → `provideTabsConfigAt` (viewProviders) → `provideTabsConfig`
@@ -630,8 +1079,54 @@ interface CngxTabsConfig {
630
1079
  readonly defaultOrientation?: 'horizontal' | 'vertical';
631
1080
  readonly defaultLoop?: boolean;
632
1081
  readonly defaultCommitMode?: 'optimistic' | 'pessimistic';
633
- readonly routerSyncMode?: 'fragment' | 'queryParam';
634
- readonly routerSyncParam?: string;
1082
+ readonly fragmentSyncMode?: 'fragment' | 'queryParam';
1083
+ readonly fragmentSyncParam?: string;
1084
+ /**
1085
+ * App-wide default visual skin. Default `'line'`. Per-instance
1086
+ * `[skin]` Input still wins; the cascade default itself lives in
1087
+ * `createTabsHostAttrs`, not here (mirrors the stepper). Override via
1088
+ * {@link withTabsSkin}.
1089
+ */
1090
+ readonly skin?: CngxTabsSkin;
1091
+ /**
1092
+ * App-wide default icon layout. Default `'start'`. Per-instance
1093
+ * `[iconLayout]` Input still wins; the cascade default lives in
1094
+ * `createTabsHostAttrs`. Override via {@link withTabsIconLayout}.
1095
+ */
1096
+ readonly iconLayout?: CngxTabIconLayout;
1097
+ /**
1098
+ * App-wide default panel render strategy. Default `'eager'`.
1099
+ * Per-instance `[panelMode]` Input still wins; the cascade default
1100
+ * lives in `createTabsHostAttrs`. Override via
1101
+ * {@link withTabsPanelMode}.
1102
+ */
1103
+ readonly panelMode?: CngxTabsPanelMode;
1104
+ /**
1105
+ * App-wide default for stretching tabs to the full strip width
1106
+ * (horizontal only). Default `false`. Per-instance `[fitted]` Input
1107
+ * wins; the cascade default lives in `createTabsHostAttrs`. Override
1108
+ * via {@link withTabsFitted}.
1109
+ */
1110
+ readonly fitted?: boolean;
1111
+ /**
1112
+ * App-wide default tab-cluster alignment (horizontal only). Default
1113
+ * `'start'`. Per-instance `[tabAlign]` Input wins; the cascade default
1114
+ * lives in `createTabsHostAttrs`. Override via {@link withTabsAlign}.
1115
+ */
1116
+ readonly tabAlign?: CngxTabAlign;
1117
+ /**
1118
+ * App-wide default for whether tabs render a close affordance.
1119
+ * Default `false`. Per-instance `[closable]` Input wins, and a
1120
+ * per-`CngxTab` `[closable]` override wins over both. The cascade
1121
+ * default lives in the organism. Override via {@link withTabsClosable}.
1122
+ */
1123
+ readonly closable?: boolean;
1124
+ /**
1125
+ * App-wide default for whether the group renders an add-tab button.
1126
+ * Default `false`. Per-instance `[addable]` Input wins. Override via
1127
+ * {@link withTabsAddable}.
1128
+ */
1129
+ readonly addable?: boolean;
635
1130
  readonly ariaLabels?: CngxTabsAriaLabels;
636
1131
  readonly fallbackLabels?: CngxTabsFallbackLabels;
637
1132
  /**
@@ -711,13 +1206,87 @@ declare function withTabsRovingLoop(loop: boolean): CngxTabsConfigFeature;
711
1206
  */
712
1207
  declare function withTabsCommitMode(mode: 'optimistic' | 'pessimistic'): CngxTabsConfigFeature;
713
1208
  /**
714
- * Configure router synchronisation for the active tab. `mode` chooses
715
- * the URL surface (URL fragment or query parameter); `param` names
716
- * the key (default `'tab'`).
1209
+ * Configure URL fragment / query-param deep-linking for the active tab
1210
+ * (the {@link CngxTabsFragmentSync} directive). `mode` chooses the URL
1211
+ * surface (URL fragment or query parameter); `param` names the key
1212
+ * (default `'tab'`).
1213
+ *
1214
+ * Not to be confused with `[cngxTabsRouteSync]`, the router-outlet
1215
+ * integration - this feature configures fragment deep-linking only.
1216
+ *
1217
+ * @category common/tabs
1218
+ */
1219
+ declare function withTabsFragmentSync(mode: 'fragment' | 'queryParam', param?: string): CngxTabsConfigFeature;
1220
+ /**
1221
+ * @deprecated Use {@link withTabsFragmentSync}. "Router sync" collided
1222
+ * with the new `[cngxTabsRouteSync]` router-outlet directive; this
1223
+ * feature only ever configured fragment / query-param deep-linking. The
1224
+ * alias stays for one minor release before removal.
717
1225
  *
718
1226
  * @category common/tabs
719
1227
  */
720
- declare function withTabsRouterSync(mode: 'fragment' | 'queryParam', param?: string): CngxTabsConfigFeature;
1228
+ declare const withTabsRouterSync: typeof withTabsFragmentSync;
1229
+ /**
1230
+ * Select the app-wide default visual skin for `<cngx-tab-group>`.
1231
+ * Default `'line'`. Per-instance `[skin]` Input still wins; this moves
1232
+ * the cascade default. Structure, slots, ARIA, and keyboard behaviour
1233
+ * are identical across skins - only the `[data-skin]` host attribute
1234
+ * changes the CSS layer. The Material twin (`[cngxMatTabs]`) ignores it.
1235
+ *
1236
+ * @category common/tabs
1237
+ */
1238
+ declare function withTabsSkin(skin: CngxTabsSkin): CngxTabsConfigFeature;
1239
+ /**
1240
+ * Set the app-wide default icon layout for `<cngx-tab-group>`. Default
1241
+ * `'start'`. Per-instance `[iconLayout]` Input still wins. Orthogonal to
1242
+ * skin and orientation - only the `[data-icon-layout]` host attribute
1243
+ * changes.
1244
+ *
1245
+ * @category common/tabs
1246
+ */
1247
+ declare function withTabsIconLayout(layout: CngxTabIconLayout): CngxTabsConfigFeature;
1248
+ /**
1249
+ * Set the app-wide default panel render strategy for `<cngx-tab-group>`.
1250
+ * Default `'eager'` (every panel's content rendered up front, toggled
1251
+ * via `[hidden]`). `'lazy'` keep-alives content after first activation;
1252
+ * `'lazy-destroy'` renders only the active panel's content. Per-instance
1253
+ * `[panelMode]` Input still wins. The panel `<div>` always stays in the
1254
+ * DOM regardless of mode (the `aria-controls` target).
1255
+ *
1256
+ * @category common/tabs
1257
+ */
1258
+ declare function withTabsPanelMode(mode: CngxTabsPanelMode): CngxTabsConfigFeature;
1259
+ /**
1260
+ * Set the app-wide default for stretching tabs to the full strip width
1261
+ * (horizontal only). Default `false`. Per-instance `[fitted]` Input still
1262
+ * wins. No effect under `orientation="vertical"`.
1263
+ *
1264
+ * @category common/tabs
1265
+ */
1266
+ declare function withTabsFitted(fitted: boolean): CngxTabsConfigFeature;
1267
+ /**
1268
+ * Set the app-wide default tab-cluster alignment (horizontal only).
1269
+ * Default `'start'`. Per-instance `[tabAlign]` Input still wins. Ignored
1270
+ * under `orientation="vertical"` and when the group is `fitted`.
1271
+ *
1272
+ * @category common/tabs
1273
+ */
1274
+ declare function withTabsAlign(align: CngxTabAlign): CngxTabsConfigFeature;
1275
+ /**
1276
+ * Set the app-wide default for whether tabs render a close affordance.
1277
+ * Default `false`. Per-instance `[closable]` Input wins; a per-`CngxTab`
1278
+ * `[closable]` override wins over both.
1279
+ *
1280
+ * @category common/tabs
1281
+ */
1282
+ declare function withTabsClosable(closable: boolean): CngxTabsConfigFeature;
1283
+ /**
1284
+ * Set the app-wide default for whether the group renders an add-tab
1285
+ * button. Default `false`. Per-instance `[addable]` Input wins.
1286
+ *
1287
+ * @category common/tabs
1288
+ */
1289
+ declare function withTabsAddable(addable: boolean): CngxTabsConfigFeature;
721
1290
  /**
722
1291
  * Merge ARIA labels into the cascade. Keys not provided keep their
723
1292
  * library defaults; per-instance overrides on the tab group still win.
@@ -791,6 +1360,28 @@ declare function withTabRejectionIconTemplate(template: TemplateRef<CngxTabRejec
791
1360
  * @category common/tabs
792
1361
  */
793
1362
  declare function withTabBusySpinnerTemplate(template: TemplateRef<CngxTabBusySpinnerContext>): CngxTabsConfigFeature;
1363
+ /**
1364
+ * App-wide override for the tab-icon slot. Middle tier of the 3-stage
1365
+ * cascade; per-instance `*cngxTabIcon` still wins. Sibling of
1366
+ * {@link withStepIndicatorTemplate}.
1367
+ *
1368
+ * @category common/tabs
1369
+ */
1370
+ declare function withTabIconTemplate(template: TemplateRef<CngxTabIconContext>): CngxTabsConfigFeature;
1371
+ /**
1372
+ * App-wide override for a tab's close-button glyph. Middle tier;
1373
+ * per-instance `*cngxTabCloseIcon` still wins.
1374
+ *
1375
+ * @category common/tabs
1376
+ */
1377
+ declare function withTabCloseIconTemplate(template: TemplateRef<CngxTabCloseIconContext>): CngxTabsConfigFeature;
1378
+ /**
1379
+ * App-wide override for the add-tab button glyph. Middle tier;
1380
+ * per-instance `*cngxTabAddIcon` still wins.
1381
+ *
1382
+ * @category common/tabs
1383
+ */
1384
+ declare function withTabAddIconTemplate(template: TemplateRef<void>): CngxTabsConfigFeature;
794
1385
  /**
795
1386
  * Root-level provider. Apply once in `bootstrapApplication` /
796
1387
  * `appConfig.providers`. Returns {@link EnvironmentProviders} per
@@ -821,6 +1412,51 @@ declare function provideTabsConfigAt(...features: readonly CngxTabsConfigFeature
821
1412
  */
822
1413
  declare function injectTabsConfig(): CngxTabsConfig;
823
1414
 
1415
+ /**
1416
+ * Input bundle for {@link createTabsHostAttrs}: the per-instance inputs
1417
+ * (each `Signal<T | undefined>`) and the resolved config (read
1418
+ * synchronously at construction). Each cascade collapses through
1419
+ * `input ?? config ?? library-default`.
1420
+ *
1421
+ * @internal
1422
+ */
1423
+ interface CngxTabsHostAttrsInputs {
1424
+ readonly skin: Signal<CngxTabsSkin | undefined>;
1425
+ readonly iconLayout: Signal<CngxTabIconLayout | undefined>;
1426
+ readonly panelMode: Signal<CngxTabsPanelMode | undefined>;
1427
+ readonly fitted: Signal<boolean | undefined>;
1428
+ readonly tabAlign: Signal<CngxTabAlign | undefined>;
1429
+ readonly config: CngxTabsConfig;
1430
+ }
1431
+ /**
1432
+ * Host-attribute signals for `<cngx-tab-group>`. Each is read by a
1433
+ * `[attr.data-*]` host binding on the organism.
1434
+ *
1435
+ * @internal
1436
+ */
1437
+ interface CngxTabsHostAttrs {
1438
+ readonly resolvedSkin: Signal<CngxTabsSkin>;
1439
+ readonly resolvedIconLayout: Signal<CngxTabIconLayout>;
1440
+ readonly resolvedPanelMode: Signal<CngxTabsPanelMode>;
1441
+ readonly resolvedFitted: Signal<boolean>;
1442
+ readonly resolvedTabAlign: Signal<CngxTabAlign>;
1443
+ }
1444
+ /**
1445
+ * Level-2 helper resolving the host-attribute cascades for
1446
+ * `<cngx-tab-group>` (skin / iconLayout). Keeps the organism class
1447
+ * under the LOC guard while making the cascade pattern reusable. Sibling
1448
+ * shape to `createStepperHostAttrs`; the resolved-type unions differ per
1449
+ * family, so the helpers are siblings, not shared code.
1450
+ *
1451
+ * Each computed honors Pillar 1 (Ableitung statt Verwaltung):
1452
+ * per-instance input wins over root config wins over library default. No
1453
+ * manual sync. The library defaults (`'line'` / `'start'`) live here,
1454
+ * not in `TABS_CONFIG_DEFAULTS` - mirroring the stepper.
1455
+ *
1456
+ * @internal
1457
+ */
1458
+ declare function createTabsHostAttrs(inputs: CngxTabsHostAttrsInputs): CngxTabsHostAttrs;
1459
+
824
1460
  /**
825
1461
  * Tabs i18n surface. Library defaults are English; consumers
826
1462
  * override via {@link provideTabsI18n}. Sibling to
@@ -831,10 +1467,26 @@ declare function injectTabsConfig(): CngxTabsConfig;
831
1467
  interface CngxTabsI18n {
832
1468
  readonly tabsLabel: string;
833
1469
  readonly selectedTab: (label: string, position: number, count: number) => string;
1470
+ /**
1471
+ * Folds a tab's optional secondary label into its accessible name.
1472
+ * Receives the primary label and the sub-label detail; the result
1473
+ * is passed to {@link selectedTab} as the label part, e.g.
1474
+ * `Tab 2 of 5: Bookmarks, 45`. Only invoked when a sub-label is
1475
+ * present.
1476
+ */
1477
+ readonly tabLabelWithDetail: (label: string, detail: string) => string;
834
1478
  readonly tabHasErrors: (count: number) => string;
835
1479
  readonly moreTabsLabel: (count: number) => string;
836
1480
  readonly previousTab: string;
837
1481
  readonly nextTab: string;
1482
+ /**
1483
+ * Accessible name for a tab's close button. Receives the tab label
1484
+ * (or a generic fallback when unlabeled) and yields the button's
1485
+ * `aria-label`, e.g. `Close "Profile"`.
1486
+ */
1487
+ readonly closeTab: (label: string) => string;
1488
+ /** Accessible name for the add-tab button. */
1489
+ readonly addTab: string;
838
1490
  /**
839
1491
  * @deprecated Superseded by {@link commitRolledBackTo}. Retained as
840
1492
  * the defensive fallback in `liveAnnouncement` when the origin
@@ -1162,6 +1814,144 @@ type CngxDomAnchorRetryFactory = (options: CngxDomAnchorRetryOptions) => CngxDom
1162
1814
  */
1163
1815
  declare const CNGX_DOM_ANCHOR_RETRY_FACTORY: InjectionToken<CngxDomAnchorRetryFactory>;
1164
1816
 
1817
+ /**
1818
+ * Structural slot for the add-tab button glyph. 3-stage cascade:
1819
+ * per-instance directive > `CNGX_TABS_CONFIG.templates.addIcon` >
1820
+ * `CNGX_TABS_GLYPHS.addIcon`. The button owns its `aria-label`; the
1821
+ * template paints only the glyph, so its context is `void`.
1822
+ *
1823
+ * ```html
1824
+ * <cngx-tab-group addable (tabAdd)="add()">
1825
+ * <ng-template cngxTabAddIcon><cngx-icon name="plus" /></ng-template>
1826
+ * ...
1827
+ * </cngx-tab-group>
1828
+ * ```
1829
+ *
1830
+ * @category common/tabs/slots
1831
+ * @wcag AA
1832
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/slots/tab-add-icon.directive.ts
1833
+ * @since 0.1.0
1834
+ * @relatedTo CngxTabCloseIcon, CngxTabGroup
1835
+ */
1836
+ declare class CngxTabAddIcon {
1837
+ readonly templateRef: TemplateRef<void>;
1838
+ static ɵfac: i0.ɵɵFactoryDeclaration<CngxTabAddIcon, never>;
1839
+ static ɵdir: i0.ɵɵDirectiveDeclaration<CngxTabAddIcon, "ng-template[cngxTabAddIcon]", ["cngxTabAddIcon"], {}, {}, never, never, true, never>;
1840
+ }
1841
+
1842
+ /**
1843
+ * Inputs to {@link createTabDismissals}. The organism owns the
1844
+ * `[closable]` / `[addable]` inputs and the DOM handle; the factory runs
1845
+ * the cascade + the close/add interaction so the organism class stays
1846
+ * under the LOC guard. Sibling shape to `createTabGroupAnnouncements`.
1847
+ *
1848
+ * @category common/tabs
1849
+ */
1850
+ interface CngxTabDismissalsOptions {
1851
+ readonly host: CngxTabGroupHost;
1852
+ readonly config: CngxTabsConfig;
1853
+ readonly i18n: CngxTabsI18n;
1854
+ readonly closable: Signal<boolean | undefined>;
1855
+ readonly addable: Signal<boolean | undefined>;
1856
+ readonly hostElement: HTMLElement;
1857
+ readonly injector: Injector;
1858
+ }
1859
+ /**
1860
+ * Resolved dismissable/addable surface for `<cngx-tab-group>`. The
1861
+ * organism holds this as one field and the template reads it.
1862
+ *
1863
+ * @category common/tabs
1864
+ */
1865
+ interface CngxTabDismissals {
1866
+ /** Effective group-level close affordance (`input ?? config ?? false`). */
1867
+ readonly resolvedClosable: Signal<boolean>;
1868
+ /** Effective group-level add affordance (`input ?? config ?? false`). */
1869
+ readonly resolvedAddable: Signal<boolean>;
1870
+ /** Per-tab closable: per-tab override > group resolution. */
1871
+ isTabClosable(tab: CngxTabHandle): boolean;
1872
+ /** i18n accessible name for a tab's close button. */
1873
+ closeButtonLabel(tab: CngxTabHandle): string;
1874
+ /** Stable `*cngxTabCloseIcon` context (`{ tab }`) per tab. */
1875
+ closeIconContextFor(tab: CngxTabHandle): CngxTabCloseIconContext;
1876
+ /** Close a tab and restore focus to the new active tab / add button. */
1877
+ handleClose(tab: CngxTabHandle, event?: Event): void;
1878
+ /** Delete on a focused closable tab requests its close (APG). */
1879
+ handleTabKeydown(tab: CngxTabHandle, event: KeyboardEvent): void;
1880
+ /** Request a new tab via the add button. */
1881
+ handleAdd(): void;
1882
+ }
1883
+ /**
1884
+ * Level-2 helper resolving the dismissable/addable affordances for
1885
+ * `<cngx-tab-group>`. Keeps the close/add cascade + interaction off the
1886
+ * organism class (LOC guard). Pillar 1: each cascade is one `computed()`.
1887
+ * The actual tab removal is the consumer's (Ableitung statt Verwaltung) -
1888
+ * `handleClose` only routes through the presenter's `requestClose`, which
1889
+ * moves the active index, and restores focus once the consumer's removal
1890
+ * has rendered.
1891
+ *
1892
+ * @category common/tabs
1893
+ */
1894
+ declare function createTabDismissals(opts: CngxTabDismissalsOptions): CngxTabDismissals;
1895
+
1896
+ /**
1897
+ * Inputs to {@link createTabKeyboardNav}. The organism owns the DOM
1898
+ * handle and the presenter contract; the factory runs the APG tablist
1899
+ * keyboard model so the organism class stays under the LOC guard.
1900
+ * Sibling shape to `createTabDismissals`.
1901
+ *
1902
+ * @category common/tabs
1903
+ */
1904
+ interface CngxTabKeyboardNavOptions {
1905
+ readonly host: CngxTabGroupHost;
1906
+ readonly hostElement: HTMLElement;
1907
+ }
1908
+ /**
1909
+ * Resolved keyboard surface for `<cngx-tab-group>`'s tablist. The
1910
+ * organism holds this as one field; the template reads `tabTabindex`
1911
+ * for the roving stop and routes the tab buttons' `(keydown)` through
1912
+ * `handleKeydown`.
1913
+ *
1914
+ * @category common/tabs
1915
+ */
1916
+ interface CngxTabKeyboardNav {
1917
+ /**
1918
+ * Roving `tabindex` for a tab button: `0` for the selected tab, `-1`
1919
+ * for every other. Derived from `host.activeId()` (Pillar 1: a single
1920
+ * source, never a second index to keep in sync) so the active tab is
1921
+ * the group's lone tab stop and `Tab` always lands on it.
1922
+ */
1923
+ tabTabindex(tab: CngxTabHandle): 0 | -1;
1924
+ /**
1925
+ * APG tablist navigation: arrow keys (axis from orientation), Home,
1926
+ * and End move between tabs with disabled-skip + loop, activate the
1927
+ * target through `host.select()` (automatic activation), and move DOM
1928
+ * focus to it. Returns silently for any other key so the caller can
1929
+ * chain further handlers (e.g. Delete-to-close).
1930
+ */
1931
+ handleKeydown(event: KeyboardEvent): void;
1932
+ }
1933
+ /**
1934
+ * Level-2 helper implementing the WAI-ARIA APG tabs keyboard model for
1935
+ * `<cngx-tab-group>` with **automatic activation**: an arrow press moves
1936
+ * focus AND activates the target tab in one step, so focus and selection
1937
+ * never diverge. Keeps the keyboard logic off the organism class (LOC
1938
+ * guard) and out of a competing roving-tabindex state machine.
1939
+ *
1940
+ * Pillar 1 (Ableitung statt Verwaltung): the tab stop is derived from the
1941
+ * presenter's `activeId`, not managed as a second index. Pillar 2
1942
+ * (Kommunikation): activation routes through `host.select()`, which owns
1943
+ * disabled-skip, loop, commit gating, and the live-region announcement -
1944
+ * the keyboard layer adds only focus movement (a DOM concern the
1945
+ * presenter, living in `@cngx/common`, must not own).
1946
+ *
1947
+ * Navigation always originates from the active tab: under automatic
1948
+ * activation the focused tab is always the active one, so the clamped
1949
+ * active index is the correct origin.
1950
+ *
1951
+ * @category common/tabs
1952
+ */
1953
+ declare function createTabKeyboardNav(opts: CngxTabKeyboardNavOptions): CngxTabKeyboardNav;
1954
+
1165
1955
  /**
1166
1956
  * Inputs to {@link createTabGroupTemplateBindings}. The organism owns
1167
1957
  * the `contentChild()` queries (NG8110 — must run in component
@@ -1175,6 +1965,11 @@ interface CngxTabGroupTemplateBindingsOptions {
1175
1965
  readonly errorBadgeSlot: Signal<CngxTabErrorBadge | undefined>;
1176
1966
  readonly rejectionIconSlot: Signal<CngxTabRejectionIcon | undefined>;
1177
1967
  readonly busySpinnerSlot: Signal<CngxTabBusySpinner | undefined>;
1968
+ readonly iconSlot: Signal<CngxTabIcon | undefined>;
1969
+ /** Per-instance `*cngxTabCloseIcon` slot. Optional - close is opt-in. */
1970
+ readonly closeIconSlot?: Signal<CngxTabCloseIcon | undefined>;
1971
+ /** Per-instance `*cngxTabAddIcon` slot. Optional - add is opt-in. */
1972
+ readonly addIconSlot?: Signal<CngxTabAddIcon | undefined>;
1178
1973
  readonly config: CngxTabsConfig;
1179
1974
  }
1180
1975
  /**
@@ -1188,13 +1983,21 @@ interface CngxTabGroupTemplateBindings {
1188
1983
  readonly errorBadge: Signal<TemplateRef<CngxTabErrorBadgeContext> | null>;
1189
1984
  readonly rejectionIcon: Signal<TemplateRef<CngxTabRejectionIconContext> | null>;
1190
1985
  readonly busySpinner: Signal<TemplateRef<CngxTabBusySpinnerContext> | null>;
1986
+ readonly icon: Signal<TemplateRef<CngxTabIconContext> | null>;
1987
+ readonly closeIcon: Signal<TemplateRef<CngxTabCloseIconContext> | null>;
1988
+ readonly addIcon: Signal<TemplateRef<void> | null>;
1191
1989
  }
1192
1990
  /**
1193
- * Wires the 3-stage template cascade for the three `<cngx-tab-group>`
1194
- * skin slots:
1991
+ * Wires the 3-stage template cascade for the `<cngx-tab-group>` skin
1992
+ * slots (errorBadge / rejectionIcon / busySpinner / icon / closeIcon /
1993
+ * addIcon):
1195
1994
  * per-instance directive >
1196
1995
  * `CNGX_TABS_CONFIG.templates.<key>` >
1197
- * `null` (built-in default).
1996
+ * `null`.
1997
+ *
1998
+ * `null` means the organism renders its built-in default - a default
1999
+ * span for the state decorations, the `CNGX_TABS_GLYPHS` glyph for
2000
+ * `closeIcon` / `addIcon`, and nothing for `icon`.
1198
2001
  *
1199
2002
  * Pure — no DI, no side effects. Safe in field-init. Sibling to
1200
2003
  * `createStepperTemplateBindings` and `createTabOverflowTemplateBindings`.
@@ -1265,11 +2068,13 @@ interface CngxTabGroupAnnouncements {
1265
2068
  */
1266
2069
  readonly liveAnnouncement: Signal<string>;
1267
2070
  /**
1268
- * SR descriptor phrase for a tab's `cngx-sr-only` span.
1269
- * `aggregator.announcement()` when bound + revealed; falls back
1270
- * to `i18n.tabHasErrors(errorCount)` on empty; empty string when
1271
- * nothing wants reveal. The span itself is always rendered (cngx
1272
- * ARIA-by-value rule); this returns its content.
2071
+ * SR descriptor phrase for a tab's `cngx-sr-only` span. Gated on the
2072
+ * folded `tab.hasError()` so a direct `[error]` tab announces without
2073
+ * an aggregator. Resolution: `aggregator.announcement()` →
2074
+ * `tab.errorMessage()` (the direct-channel message) →
2075
+ * `i18n.tabHasErrors(errorCount)`. Empty string when the tab has no
2076
+ * error. The span itself is always rendered (cngx ARIA-by-value
2077
+ * rule); this returns its content.
1273
2078
  */
1274
2079
  statusPhrase(tab: CngxTabHandle): string;
1275
2080
  /**
@@ -1308,6 +2113,10 @@ declare const CNGX_TABS_GLYPHS: {
1308
2113
  readonly errorBadge: "!";
1309
2114
  /** Default visual for `*cngxTabRejectionIcon` when no override is bound. */
1310
2115
  readonly rejectionIcon: "!";
2116
+ /** Default visual for a tab's close button when no override is bound. */
2117
+ readonly closeIcon: "×";
2118
+ /** Default visual for the add-tab button when no override is bound. */
2119
+ readonly addIcon: "+";
1311
2120
  };
1312
2121
 
1313
2122
  /**
@@ -1507,5 +2316,5 @@ type CngxDirectiveByIdMapFactory = <T extends {
1507
2316
  */
1508
2317
  declare const CNGX_DIRECTIVE_BY_ID_MAP_FACTORY: InjectionToken<CngxDirectiveByIdMapFactory>;
1509
2318
 
1510
- export { CNGX_DIRECTIVE_BY_ID_MAP_FACTORY, CNGX_DOM_ANCHOR_RETRY_FACTORY, CNGX_ORGANISM_SCROLL_SYNC_FACTORY, CNGX_OVERFLOW_POPOVER_HIGHLIGHT_FACTORY, CNGX_TABS_COMMIT_HANDLER_FACTORY, CNGX_TABS_CONFIG, CNGX_TABS_GLYPHS, CNGX_TABS_I18N, CNGX_TAB_GROUP_HOST, CNGX_TAB_OVERFLOW_DOM_ADAPTER_FACTORY, CNGX_TAB_PANEL_HOST, CngxTab, CngxTabBusySpinner, CngxTabContent, CngxTabErrorBadge, CngxTabGroupPresenter, CngxTabLabel, CngxTabOverflowItem, CngxTabOverflowTrigger, CngxTabRejectionIcon, CngxTabsFragmentSync, createCngxTabOverflowDefaultDomAdapter, createDirectiveByIdMap, createDomAnchorRetry, createOrganismScrollSync, createOverflowPopoverHighlightSync, createTabGroupAnnouncements, createTabGroupTemplateBindings, createTabOverflowTemplateBindings, createTabsCommitHandler, injectTabsConfig, injectTabsI18n, provideCngxTabs, provideCngxTabsAt, provideTabsConfig, provideTabsConfigAt, provideTabsI18n, tabOverflowOptionId, withDefaultOrientation, withTabBusySpinnerTemplate, withTabErrorBadgeTemplate, withTabOverflowItemTemplate, withTabOverflowMaxDeferMs, withTabOverflowStabilizeMs, withTabOverflowTriggerTemplate, withTabRejectionIconTemplate, withTabsAriaLabels, withTabsCommitMode, withTabsDefaultOrientation, withTabsFallbackLabels, withTabsI18nLabels, withTabsRouterSync, withTabsRovingLoop };
1511
- export type { CngxDirectiveByIdMapFactory, CngxDirectiveByIdMapOptions, CngxDomAnchorRetryFactory, CngxDomAnchorRetryHandle, CngxDomAnchorRetryOptions, CngxDomAnchorRetryResult, CngxOrganismScrollSyncFactory, CngxOrganismScrollSyncOptions, CngxOverflowPopoverHighlightSyncFactory, CngxTabBusySpinnerContext, CngxTabErrorBadgeContext, CngxTabGroupAnnouncements, CngxTabGroupAnnouncementsOptions, CngxTabGroupHost, CngxTabGroupTemplateBindings, CngxTabGroupTemplateBindingsOptions, CngxTabHandle, CngxTabOverflowDomAdapter, CngxTabOverflowDomAdapterFactory, CngxTabOverflowItemContext, CngxTabOverflowTemplateBindings, CngxTabOverflowTemplateBindingsOptions, CngxTabOverflowTriggerContext, CngxTabPanelHost, CngxTabRejectionIconContext, CngxTabsAriaLabels, CngxTabsCommitAction, CngxTabsCommitHandler, CngxTabsCommitHandlerFactory, CngxTabsCommitHandlerOptions, CngxTabsConfig, CngxTabsConfigFeature, CngxTabsFallbackLabels, CngxTabsFeature, CngxTabsI18n, CngxTabsI18nFeature, CngxTabsTemplates };
2319
+ export { CNGX_DIRECTIVE_BY_ID_MAP_FACTORY, CNGX_DOM_ANCHOR_RETRY_FACTORY, CNGX_ORGANISM_SCROLL_SYNC_FACTORY, CNGX_OVERFLOW_POPOVER_HIGHLIGHT_FACTORY, CNGX_TABS_COMMIT_ACTION, CNGX_TABS_COMMIT_HANDLER_FACTORY, CNGX_TABS_CONFIG, CNGX_TABS_GLYPHS, CNGX_TABS_I18N, CNGX_TAB_GROUP_HOST, CNGX_TAB_OVERFLOW_DOM_ADAPTER_FACTORY, CNGX_TAB_PANEL_HOST, CngxTab, CngxTabAddIcon, CngxTabBusySpinner, CngxTabCloseIcon, CngxTabContent, CngxTabErrorBadge, CngxTabGroupPresenter, CngxTabIcon, CngxTabLabel, CngxTabOverflowItem, CngxTabOverflowTrigger, CngxTabRejectionIcon, CngxTabSubLabel, CngxTabsFragmentSync, CngxTabsRouteSync, createCngxTabOverflowDefaultDomAdapter, createDirectiveByIdMap, createDomAnchorRetry, createOrganismScrollSync, createOverflowPopoverHighlightSync, createTabDismissals, createTabGroupAnnouncements, createTabGroupTemplateBindings, createTabKeyboardNav, createTabOverflowTemplateBindings, createTabRouterCommit, createTabsCommitHandler, createTabsHostAttrs, injectTabsConfig, injectTabsI18n, provideCngxTabs, provideCngxTabsAt, provideTabsConfig, provideTabsConfigAt, provideTabsI18n, tabOverflowOptionId, withDefaultOrientation, withTabAddIconTemplate, withTabBusySpinnerTemplate, withTabCloseIconTemplate, withTabErrorBadgeTemplate, withTabIconTemplate, withTabOverflowItemTemplate, withTabOverflowMaxDeferMs, withTabOverflowStabilizeMs, withTabOverflowTriggerTemplate, withTabRejectionIconTemplate, withTabsAddable, withTabsAlign, withTabsAriaLabels, withTabsClosable, withTabsCommitMode, withTabsDefaultOrientation, withTabsFallbackLabels, withTabsFitted, withTabsFragmentSync, withTabsI18nLabels, withTabsIconLayout, withTabsPanelMode, withTabsRouterSync, withTabsRovingLoop, withTabsSkin };
2320
+ export type { CngxDirectiveByIdMapFactory, CngxDirectiveByIdMapOptions, CngxDomAnchorRetryFactory, CngxDomAnchorRetryHandle, CngxDomAnchorRetryOptions, CngxDomAnchorRetryResult, CngxOrganismScrollSyncFactory, CngxOrganismScrollSyncOptions, CngxOverflowPopoverHighlightSyncFactory, CngxTabAlign, CngxTabBusySpinnerContext, CngxTabCloseEvent, CngxTabCloseIconContext, CngxTabDismissals, CngxTabDismissalsOptions, CngxTabErrorBadgeContext, CngxTabGroupAnnouncements, CngxTabGroupAnnouncementsOptions, CngxTabGroupHost, CngxTabGroupTemplateBindings, CngxTabGroupTemplateBindingsOptions, CngxTabHandle, CngxTabIconContext, CngxTabIconLayout, CngxTabKeyboardNav, CngxTabKeyboardNavOptions, CngxTabOverflowDomAdapter, CngxTabOverflowDomAdapterFactory, CngxTabOverflowItemContext, CngxTabOverflowTemplateBindings, CngxTabOverflowTemplateBindingsOptions, CngxTabOverflowTriggerContext, CngxTabPanelHost, CngxTabRejectionIconContext, CngxTabRouterCommitOptions, CngxTabsAriaLabels, CngxTabsCommitAction, CngxTabsCommitActionSource, CngxTabsCommitHandler, CngxTabsCommitHandlerFactory, CngxTabsCommitHandlerOptions, CngxTabsConfig, CngxTabsConfigFeature, CngxTabsFallbackLabels, CngxTabsFeature, CngxTabsHostAttrs, CngxTabsHostAttrsInputs, CngxTabsI18n, CngxTabsI18nFeature, CngxTabsPanelMode, CngxTabsSkin, CngxTabsTemplates };