@cngx/common 0.0.1-rc.0

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.
Files changed (50) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +18 -0
  3. package/a11y/README.md +77 -0
  4. package/card/README.md +79 -0
  5. package/chart/README.md +31 -0
  6. package/data/README.md +883 -0
  7. package/dialog/README.md +84 -0
  8. package/display/README.md +30 -0
  9. package/fesm2022/cngx-common-a11y.mjs +1260 -0
  10. package/fesm2022/cngx-common-a11y.mjs.map +1 -0
  11. package/fesm2022/cngx-common-card.mjs +765 -0
  12. package/fesm2022/cngx-common-card.mjs.map +1 -0
  13. package/fesm2022/cngx-common-chart.mjs +2943 -0
  14. package/fesm2022/cngx-common-chart.mjs.map +1 -0
  15. package/fesm2022/cngx-common-data.mjs +2886 -0
  16. package/fesm2022/cngx-common-data.mjs.map +1 -0
  17. package/fesm2022/cngx-common-dialog.mjs +1366 -0
  18. package/fesm2022/cngx-common-dialog.mjs.map +1 -0
  19. package/fesm2022/cngx-common-display.mjs +1603 -0
  20. package/fesm2022/cngx-common-display.mjs.map +1 -0
  21. package/fesm2022/cngx-common-interactive.mjs +8185 -0
  22. package/fesm2022/cngx-common-interactive.mjs.map +1 -0
  23. package/fesm2022/cngx-common-layout.mjs +1335 -0
  24. package/fesm2022/cngx-common-layout.mjs.map +1 -0
  25. package/fesm2022/cngx-common-popover.mjs +1200 -0
  26. package/fesm2022/cngx-common-popover.mjs.map +1 -0
  27. package/fesm2022/cngx-common-stepper.mjs +1350 -0
  28. package/fesm2022/cngx-common-stepper.mjs.map +1 -0
  29. package/fesm2022/cngx-common-tabs.mjs +1551 -0
  30. package/fesm2022/cngx-common-tabs.mjs.map +1 -0
  31. package/fesm2022/cngx-common.mjs +34 -0
  32. package/fesm2022/cngx-common.mjs.map +1 -0
  33. package/interactive/README.md +211 -0
  34. package/layout/README.md +117 -0
  35. package/package.json +100 -0
  36. package/popover/README.md +218 -0
  37. package/stepper/README.md +102 -0
  38. package/tabs/README.md +32 -0
  39. package/types/cngx-common-a11y.d.ts +616 -0
  40. package/types/cngx-common-card.d.ts +413 -0
  41. package/types/cngx-common-chart.d.ts +1081 -0
  42. package/types/cngx-common-data.d.ts +1460 -0
  43. package/types/cngx-common-dialog.d.ts +772 -0
  44. package/types/cngx-common-display.d.ts +1136 -0
  45. package/types/cngx-common-interactive.d.ts +5013 -0
  46. package/types/cngx-common-layout.d.ts +737 -0
  47. package/types/cngx-common-popover.d.ts +520 -0
  48. package/types/cngx-common-stepper.d.ts +982 -0
  49. package/types/cngx-common-tabs.d.ts +1237 -0
  50. package/types/cngx-common.d.ts +13 -0
@@ -0,0 +1,117 @@
1
+ # @cngx/common/layout
2
+
3
+ Layout observation, scroll control, drawer system, and skeleton loading directives.
4
+
5
+ ## CngxSkeleton
6
+
7
+ Headless skeleton loading placeholder. Toggles between loading and content states via CSS classes
8
+ and ARIA attributes. The consumer renders the skeleton UI.
9
+
10
+ ```html
11
+ <div [cngxSkeleton]="isLoading()" [count]="3" #sk="cngxSkeleton">
12
+ @if (sk.loading()) {
13
+ @for (i of sk.indices(); track i) {
14
+ <div class="skeleton-line" aria-hidden="true"></div>
15
+ }
16
+ } @else {
17
+ <p>{{ content() }}</p>
18
+ }
19
+ </div>
20
+ ```
21
+
22
+ ## CngxInfiniteScroll
23
+
24
+ Infinite scroll trigger using `IntersectionObserver`. Place on a sentinel element at the
25
+ bottom of a list. Fires `loadMore` when the sentinel enters the viewport.
26
+
27
+ ```html
28
+ <div class="item-list">
29
+ @for (item of items(); track item.id) {
30
+ <app-item [data]="item" />
31
+ }
32
+ <div cngxInfiniteScroll
33
+ [enabled]="hasNextPage()"
34
+ [loading]="isFetching()"
35
+ (loadMore)="fetchNext()"
36
+ #scroll="cngxInfiniteScroll">
37
+ @if (scroll.isLoading()) { <mat-spinner diameter="24" /> }
38
+ </div>
39
+ </div>
40
+ ```
41
+
42
+ ### Notes
43
+
44
+ - Observer auto-recreates when `root`, `rootMargin`, or `threshold` inputs change.
45
+ - Observer disconnects on destroy or when `enabled` is `false`.
46
+ - Includes a time-based debounce guard to prevent rapid re-triggers.
47
+
48
+ ## CngxStickyHeader
49
+
50
+ Communicates when a `position: sticky` element becomes stuck. Does NOT apply sticky positioning — CSS handles that. Inserts a sentinel element before the host and uses `IntersectionObserver` to detect when the sentinel scrolls out.
51
+
52
+ ```html
53
+ <header cngxStickyHeader style="position: sticky; top: 0;">
54
+ Page header
55
+ </header>
56
+ ```
57
+
58
+ ```css
59
+ .cngx-sticky--active { box-shadow: 0 2px 4px rgba(0,0,0,.1); }
60
+ ```
61
+
62
+ ### Notes
63
+
64
+ - Sentinel is a 1px invisible element with `aria-hidden="true"`.
65
+ - Sentinel and observer are created in `afterNextRender`, cleaned up via `DestroyRef`.
66
+ - Sticky header itself remains visible to screen readers (`aria-hidden` is not set on host).
67
+
68
+ ## CngxScrollSpy
69
+
70
+ Tracks which section is currently most visible in the viewport. Observes a list of elements by their IDs using `IntersectionObserver` with fine-grained thresholds (10% steps). Reports the one with the highest ratio above the minimum threshold.
71
+
72
+ ```html
73
+ <nav [cngxScrollSpy]="['intro', 'features', 'pricing']" #spy="cngxScrollSpy">
74
+ <a [class.active]="spy.activeId() === 'intro'" href="#intro">Intro</a>
75
+ <a [class.active]="spy.activeId() === 'features'" href="#features">Features</a>
76
+ <a [class.active]="spy.activeId() === 'pricing'" href="#pricing">Pricing</a>
77
+ </nav>
78
+
79
+ <section id="intro">…</section>
80
+ <section id="features">…</section>
81
+ <section id="pricing">…</section>
82
+ ```
83
+
84
+ ### Notes
85
+
86
+ - Observer recreated via `effect()` when `sections`, `threshold`, `root`, or `rootMargin` change.
87
+ - Uses 11 threshold steps (0, 0.1, 0.2 … 1.0) for accurate ratio tracking.
88
+ - Pairs naturally with `CngxNavLink` for scroll-based navigation highlighting.
89
+
90
+ ## CngxTruncate
91
+
92
+ Manages text truncation with expand/collapse state detection. Applies `-webkit-line-clamp` when collapsed and uses `ResizeObserver` to detect whether the text actually overflows. The `isClamped` signal lets the consumer show a toggle button only when needed.
93
+
94
+ ```html
95
+ <p [cngxTruncate]="3" [(expanded)]="expanded" #trunc="cngxTruncate">
96
+ Long text content…
97
+ </p>
98
+ @if (trunc.isClamped() || trunc.expanded()) {
99
+ <button (click)="expanded.set(!expanded())"
100
+ [attr.aria-expanded]="expanded()">
101
+ {{ expanded() ? 'Show less' : 'Show more' }}
102
+ </button>
103
+ }
104
+ ```
105
+
106
+ ### Notes
107
+
108
+ - Host styles applied automatically: `-webkit-line-clamp`, `display: -webkit-box`, `-webkit-box-orient: vertical`, `overflow: hidden`.
109
+ - All styles removed when expanded.
110
+ - `ResizeObserver` re-checks on container resize.
111
+ - `isClamped` is only updated when collapsed — expanded state preserves the last known value.
112
+ - Consumer is responsible for the toggle button and `aria-expanded` attribute.
113
+
114
+ ## Other Exports
115
+
116
+ `CngxIntersectionObserver`, `CngxResizeObserver`, `CngxScrollLock`, `CngxBackdrop`,
117
+ `CngxMediaQuery`, `CngxDrawer`, `CngxDrawerPanel`, `CngxDrawerContent`, `CngxInfiniteScroll`
package/package.json ADDED
@@ -0,0 +1,100 @@
1
+ {
2
+ "name": "@cngx/common",
3
+ "version": "0.0.1-rc.0",
4
+ "description": "Atoms and molecules (a11y, interactive, layout, dialog, popover, display) for the cngx Angular component library. CDK-only, no Material.",
5
+ "keywords": [
6
+ "cngx",
7
+ "angular",
8
+ "signals",
9
+ "a11y",
10
+ "cdk",
11
+ "directives",
12
+ "components"
13
+ ],
14
+ "author": "Christian Weiss <c.weiss@sobit.at>",
15
+ "license": "MIT",
16
+ "homepage": "https://github.com/cngxjs/cngx#readme",
17
+ "bugs": {
18
+ "url": "https://github.com/cngxjs/cngx/issues"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/cngxjs/cngx.git",
23
+ "directory": "projects/common"
24
+ },
25
+ "peerDependencies": {
26
+ "@angular/cdk": "^21.2.0",
27
+ "@angular/common": "^21.2.0",
28
+ "@angular/core": "^21.2.0",
29
+ "@angular/router": "^21.2.0",
30
+ "rxjs": "^7.8.0",
31
+ "@floating-ui/dom": "^1.0.0"
32
+ },
33
+ "peerDependenciesMeta": {
34
+ "@floating-ui/dom": {
35
+ "optional": true
36
+ },
37
+ "@angular/router": {
38
+ "optional": true
39
+ }
40
+ },
41
+ "dependencies": {
42
+ "tslib": "^2.3.0"
43
+ },
44
+ "sideEffects": false,
45
+ "module": "fesm2022/cngx-common.mjs",
46
+ "typings": "types/cngx-common.d.ts",
47
+ "exports": {
48
+ "./package.json": {
49
+ "default": "./package.json"
50
+ },
51
+ ".": {
52
+ "types": "./types/cngx-common.d.ts",
53
+ "default": "./fesm2022/cngx-common.mjs"
54
+ },
55
+ "./a11y": {
56
+ "types": "./types/cngx-common-a11y.d.ts",
57
+ "default": "./fesm2022/cngx-common-a11y.mjs"
58
+ },
59
+ "./card": {
60
+ "types": "./types/cngx-common-card.d.ts",
61
+ "default": "./fesm2022/cngx-common-card.mjs"
62
+ },
63
+ "./chart": {
64
+ "types": "./types/cngx-common-chart.d.ts",
65
+ "default": "./fesm2022/cngx-common-chart.mjs"
66
+ },
67
+ "./data": {
68
+ "types": "./types/cngx-common-data.d.ts",
69
+ "default": "./fesm2022/cngx-common-data.mjs"
70
+ },
71
+ "./dialog": {
72
+ "types": "./types/cngx-common-dialog.d.ts",
73
+ "default": "./fesm2022/cngx-common-dialog.mjs"
74
+ },
75
+ "./display": {
76
+ "types": "./types/cngx-common-display.d.ts",
77
+ "default": "./fesm2022/cngx-common-display.mjs"
78
+ },
79
+ "./interactive": {
80
+ "types": "./types/cngx-common-interactive.d.ts",
81
+ "default": "./fesm2022/cngx-common-interactive.mjs"
82
+ },
83
+ "./layout": {
84
+ "types": "./types/cngx-common-layout.d.ts",
85
+ "default": "./fesm2022/cngx-common-layout.mjs"
86
+ },
87
+ "./popover": {
88
+ "types": "./types/cngx-common-popover.d.ts",
89
+ "default": "./fesm2022/cngx-common-popover.mjs"
90
+ },
91
+ "./stepper": {
92
+ "types": "./types/cngx-common-stepper.d.ts",
93
+ "default": "./fesm2022/cngx-common-stepper.mjs"
94
+ },
95
+ "./tabs": {
96
+ "types": "./types/cngx-common-tabs.d.ts",
97
+ "default": "./fesm2022/cngx-common-tabs.mjs"
98
+ }
99
+ }
100
+ }
@@ -0,0 +1,218 @@
1
+ # @cngx/common/popover
2
+
3
+ Signal-driven popover, tooltip, and popover panel components built on the native **Popover API** and **CSS Anchor Positioning**. No CDK Overlay, no z-index management, no JavaScript positioning by default.
4
+
5
+ ## Features
6
+
7
+ - Native Popover API (`popover="manual"` / `popover="auto"`) with Top Layer
8
+ - CSS Anchor Positioning (Chrome 125+, Firefox 131+, Safari 18.4+)
9
+ - Optional Floating UI fallback for older browsers
10
+ - Signal-driven state machine (`closed` -> `opening` -> `open` -> `closing` -> `closed`)
11
+ - Transition-aware lifecycle with CSS class hooks
12
+ - WCAG 1.4.13 compliant tooltips (dismissable, hoverable, persistent)
13
+ - Material theme SCSS with M3 tokens
14
+ - Exclusive mode (one popover at a time by default)
15
+
16
+ ## Quick Start
17
+
18
+ ```typescript
19
+ import {
20
+ CngxPopover,
21
+ CngxPopoverTrigger,
22
+ CngxTooltip,
23
+ } from '@cngx/common/popover';
24
+ ```
25
+
26
+ ### Tooltip
27
+
28
+ ```html
29
+ <button cngxTooltip="Save (Ctrl+S)">Save</button>
30
+
31
+ <button cngxTooltip="Delete item" tooltipPlacement="bottom" [tooltipDelay]="500">
32
+ Delete
33
+ </button>
34
+ ```
35
+
36
+ ### Click Popover
37
+
38
+ ```html
39
+ <button [cngxPopoverTrigger]="pop" (click)="pop.toggle()">Menu</button>
40
+ <div cngxPopover #pop="cngxPopover" placement="bottom-start">
41
+ <menu>
42
+ <li><button (click)="pop.hide()">Edit</button></li>
43
+ <li><button (click)="pop.hide()">Delete</button></li>
44
+ </menu>
45
+ </div>
46
+ ```
47
+
48
+ ### Controlled Popover
49
+
50
+ ```html
51
+ <div cngxPopover [cngxPopoverOpen]="showErrors()" role="alert">
52
+ {{ errorSummary() }}
53
+ </div>
54
+ ```
55
+
56
+ ## Popover Panel
57
+
58
+ Rich popover molecule with header/body/footer slots, variant styling, arrow, close button, and async action buttons.
59
+
60
+ ```typescript
61
+ import {
62
+ CngxPopoverPanel,
63
+ CngxPopoverTrigger,
64
+ CngxPopoverHeader,
65
+ CngxPopoverBody,
66
+ CngxPopoverFooter,
67
+ CngxPopoverAction,
68
+ providePopoverPanel,
69
+ withCloseButton,
70
+ withArrow,
71
+ withAutoDismiss,
72
+ } from '@cngx/common/popover';
73
+ import { CngxPending, CngxSucceeded, CngxFailed } from '@cngx/common/interactive';
74
+ ```
75
+
76
+ ```html
77
+ <button [cngxPopoverTrigger]="panel.popover" (click)="panel.popover.toggle()">
78
+ Delete
79
+ </button>
80
+ <cngx-popover-panel #panel variant="danger" [showClose]="true" [showArrow]="true"
81
+ [hasFooter]="true" placement="bottom">
82
+ <span cngxPopoverHeader>Delete Item?</span>
83
+ <p cngxPopoverBody>This action cannot be undone.</p>
84
+ <div cngxPopoverFooter>
85
+ <cngx-popover-action role="dismiss">Cancel</cngx-popover-action>
86
+ <cngx-popover-action role="confirm" [action]="deleteItem" variant="danger">
87
+ Delete
88
+ <ng-template cngxPending>Deleting...</ng-template>
89
+ <ng-template cngxSucceeded>Deleted!</ng-template>
90
+ <ng-template cngxFailed let-err>{{ err }}</ng-template>
91
+ </cngx-popover-action>
92
+ </div>
93
+ </cngx-popover-panel>
94
+ ```
95
+
96
+ ### Content States
97
+
98
+ ```html
99
+ <cngx-popover-panel [loading]="isLoading()" [error]="loadError()">
100
+ <p cngxPopoverBody>Loaded content here</p>
101
+ <ng-template cngxPopoverLoading>Loading...</ng-template>
102
+ <ng-template cngxPopoverError let-err>Failed: {{ err }}</ng-template>
103
+ <ng-template cngxPopoverEmpty>No data found</ng-template>
104
+ </cngx-popover-panel>
105
+ ```
106
+
107
+ ### Custom Close Button
108
+
109
+ ```html
110
+ <cngx-popover-panel [showClose]="true">
111
+ <ng-template cngxPopoverClose>
112
+ <button mat-icon-button (click)="panel.popover.hide()">
113
+ <mat-icon>close</mat-icon>
114
+ </button>
115
+ </ng-template>
116
+ ...
117
+ </cngx-popover-panel>
118
+ ```
119
+
120
+ ## Configuration
121
+
122
+ ### Global Defaults
123
+
124
+ ```typescript
125
+ providers: [
126
+ providePopoverPanel(
127
+ withCloseButton(), // showClose=true globally
128
+ withArrow(), // showArrow=true globally
129
+ withAutoDismiss({ info: 5000, success: 3000 }), // auto-close per variant
130
+ withCloseOnSuccess(300), // close after async action success
131
+ withDefaultVariant('default'), // default variant
132
+ ),
133
+ ]
134
+ ```
135
+
136
+ ### Variants
137
+
138
+ The `variant` input is a free-form string mapped to CSS class `cngx-popover-panel--{variant}`. Five are pre-themed: `default`, `info`, `success`, `warning`, `danger`. Add custom variants via CSS:
139
+
140
+ ```css
141
+ .cngx-popover-panel--beta {
142
+ --cngx-pp-accent: purple;
143
+ --cngx-pp-accent-text: white;
144
+ }
145
+ ```
146
+
147
+ ## Theming
148
+
149
+ ### Material Theme
150
+
151
+ ```scss
152
+ @use '@angular/material' as mat;
153
+ @use '@cngx/common/popover/tooltip-theme' as tooltip;
154
+ @use '@cngx/common/popover/popover-panel-theme' as panel;
155
+
156
+ $theme: mat.define-theme((...));
157
+
158
+ html {
159
+ @include mat.all-component-themes($theme);
160
+ @include tooltip.theme($theme);
161
+ @include panel.theme($theme);
162
+ }
163
+ ```
164
+
165
+ ### Tooltip Indicator (opt-in)
166
+
167
+ ```scss
168
+ @use '@cngx/common/popover/tooltip-indicator' as indicator;
169
+
170
+ // Touch devices only (recommended)
171
+ @include indicator.touch-only();
172
+
173
+ // Or always visible
174
+ @include indicator.always();
175
+ ```
176
+
177
+ Customizable via CSS custom properties: `--cngx-tooltip-indicator-size`, `--cngx-tooltip-indicator-gap`, `--cngx-tooltip-indicator-color`, `--cngx-tooltip-indicator-opacity`, `--cngx-tooltip-indicator-icon`.
178
+
179
+ ## Browser Support
180
+
181
+ ### Native Support (zero polyfills needed)
182
+
183
+ - Chrome 125+
184
+ - Firefox 131+
185
+ - Safari 18.4+
186
+
187
+ ### Older Browsers
188
+
189
+ **Popover API polyfill** (required for browsers without `showPopover()`):
190
+
191
+ ```bash
192
+ npm install @oddbird/popover-polyfill
193
+ ```
194
+
195
+ ```typescript
196
+ // polyfills.ts
197
+ import '@oddbird/popover-polyfill';
198
+ ```
199
+
200
+ A DevMode warning is logged automatically when the Popover API is missing.
201
+
202
+ **CSS Anchor Positioning fallback** (optional, for positioning in older browsers):
203
+
204
+ ```bash
205
+ npm install @floating-ui/dom
206
+ ```
207
+
208
+ ```typescript
209
+ import { computePosition, flip, offset, shift } from '@floating-ui/dom';
210
+ import { provideFloatingFallback } from '@cngx/common/popover';
211
+
212
+ providers: [
213
+ provideFloatingFallback(computePosition, [offset(8), flip(), shift()]),
214
+ ]
215
+ ```
216
+
217
+ The library never imports `@floating-ui/dom` directly. When not provided, positioning falls back to browser defaults. Zero bundle impact for modern browsers.
218
+
@@ -0,0 +1,102 @@
1
+ # @cngx/common/stepper
2
+
3
+ Level-2 directive-only logic for stepper / wizard flows. Zero `@Component`, zero `.html`, zero `.css` — those live in `@cngx/ui/stepper` (CNGX-standard skin) and `@cngx/ui/mat-stepper` (Material twin).
4
+
5
+ ## What it does
6
+
7
+ Ships the **brain** that both stepper organisms compose: the presenter directive that owns active-step state, linear/non-linear navigation, async commit lifecycle, and a register/unregister contract for content-projected step atoms. Plus a router-sync directive for URL deep-linking, a config cascade for app-wide defaults, an i18n bundle, and a commit-handler factory for swappable async-commit semantics.
8
+
9
+ The presenter is a pure-derivation host directive — every visible piece of state (step tree, flat projection, active id, orientation, linear flag) is a `Signal<T>` derived from inputs and the registered atom set. Group nodes nest; flat-projection indices are computed once via `flattenStepTree` and cached.
10
+
11
+ ## Exports
12
+
13
+ ### Directives
14
+
15
+ | Export | Selector | Description |
16
+ |-|-|-|
17
+ | `CngxStepperPresenter` | `[cngxStepper]` | The brain. Owns active step, linear, orientation, commit lifecycle. Composed via `hostDirectives` by `<cngx-stepper>` and `<cngx-mat-stepper>` — never instantiated directly by consumers. |
18
+ | `CngxStep` | `[cngxStep]` | Step atom — registers itself with the enclosing presenter (or `CngxStepGroup`) at construction time, unregisters on destroy. Carries `id`, `label`, `disabled`, `state`, optional `errorAggregator`. |
19
+ | `CngxStepGroup` | `[cngxStepGroup]` | Group atom — nests child `cngxStep`s under a labelled cluster. Aggregates child status (`success` / `error` / `pending`) for the strip's group-header rendering. |
20
+ | `CngxStepLabel` | `ng-template[cngxStepLabel]` | Per-step label override (replaces the default `node.label()` text rendering). |
21
+ | `CngxStepContent` | `ng-template[cngxStepContent]` | Per-step panel body. The cngx-side organisms render this template inside the step's panel region. |
22
+ | `CngxStepperRouterSync` | `[cngxStepperRouterSync]` | Bidirectional URL deep-linking. Toggleable between `'fragment'` (default, `#step=<id>`) and `'queryParam'` (`?step=<id>`) via the `[mode]` Input or the `withStepperRouterSync` config feature. Optional `(syncError)` Output for router-rejection observers. |
23
+
24
+ ### Tokens
25
+
26
+ | Export | Description |
27
+ |-|-|
28
+ | `CNGX_STEPPER_HOST` | The presenter contract. Injected by atoms (`CngxStep` / `CngxStepGroup`) for register/unregister + read-only state access. Provided via `useExisting` by `<cngx-stepper>` and `<cngx-mat-stepper>`. |
29
+ | `CNGX_STEP_GROUP_HOST` | Group-scoped variant of the host contract. `CngxStep` injects this with optional fallback to `CNGX_STEPPER_HOST` so steps can register against a parent group OR the root presenter. |
30
+ | `CNGX_STEP_PANEL_HOST` | Rendering-surface contract for organisms. Provides `flatSteps` / `activeStepIndex` / `activeStepId` Signals plus `labelTemplateFor(id)` / `contentTemplateFor(id)` template lookups. |
31
+ | `CNGX_STEPPER_CONFIG` | App-wide stepper configuration token (defaults, ARIA labels, fallback labels, router-sync mode). |
32
+ | `CNGX_STEPPER_I18N` | I18n bundle token (default English; consumers override via `provideStepperI18n`). |
33
+ | `CNGX_STEPPER_COMMIT_HANDLER_FACTORY` | Pluggable async-commit handler factory. Default: `createStepperCommitHandler`. Override for telemetry / retry / offline-queue without forking. |
34
+
35
+ ### Configuration cascade
36
+
37
+ Resolution priority: per-instance Input → `viewProviders` → root provider → library default.
38
+
39
+ | Export | Description |
40
+ |-|-|
41
+ | `provideStepperConfig(...features)` | App-wide registration. |
42
+ | `provideStepperConfigAt(...features)` | Component-scoped via `viewProviders`. |
43
+ | `injectStepperConfig()` | Read the resolved config in directives / components. |
44
+ | `withStepperDefaultOrientation('horizontal' \| 'vertical')` | Default orientation when `[orientation]` is unbound. |
45
+ | `withStepperLinear(boolean)` | Default linear-mode flag. |
46
+ | `withStepperCommitMode('optimistic' \| 'pessimistic')` | Default commit mode. |
47
+ | `withStepperRouterSync(mode, paramName?)` | Default router-sync `mode` + `paramName`. |
48
+ | `withStepperAriaLabels({ stepperRegion?, ... })` | App-wide ARIA-label overrides (consumer locale). |
49
+ | `withStepperFallbackLabels({ groupRoleDescription?, stepRoleDescription?, ... })` | App-wide role-description overrides. |
50
+
51
+ ### I18n
52
+
53
+ | Export | Description |
54
+ |-|-|
55
+ | `provideStepperI18n(bundle)` | Provide a localised i18n bundle (defaults are English). |
56
+ | `injectStepperI18n()` | Read the resolved i18n bundle in directives / components. |
57
+ | `CngxStepperI18n` | The bundle interface (`stepperLabel`, `selectedStep(label, idx, count)`, `stepCompleted`, `stepErrored`, …). |
58
+
59
+ ### Utilities
60
+
61
+ | Export | Description |
62
+ |-|-|
63
+ | `createStepperCommitHandler({ controller })` | Factory for the async-commit state-machine adapter. Default `CNGX_STEPPER_COMMIT_HANDLER_FACTORY`. |
64
+
65
+ ## Usage
66
+
67
+ The Level-2 surface is consumed exclusively by Level-4 organisms (`<cngx-stepper>` / `<cngx-mat-stepper>`). Consumers do NOT instantiate `CngxStepperPresenter` directly. They use one of the organisms and project `<cngxStep>` atoms:
68
+
69
+ ```ts
70
+ import { CngxStep, CngxStepContent } from '@cngx/common/stepper';
71
+ import { CngxStepper } from '@cngx/ui/stepper';
72
+
73
+ @Component({
74
+ imports: [CngxStepper, CngxStep, CngxStepContent],
75
+ template: `
76
+ <cngx-stepper [(activeStepIndex)]="active" aria-label="Wizard">
77
+ <div cngxStep label="Profile">
78
+ <ng-template cngxStepContent>Profile content…</ng-template>
79
+ </div>
80
+ <div cngxStep label="Confirm">
81
+ <ng-template cngxStepContent>Confirm content…</ng-template>
82
+ </div>
83
+ </cngx-stepper>
84
+ `,
85
+ })
86
+ class WizardCmp {
87
+ protected readonly active = signal(0);
88
+ }
89
+ ```
90
+
91
+ ## Architecture notes
92
+
93
+ - **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`.
94
+ - **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.
95
+ - **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.
96
+ - **Memory hygiene**: every atom registers a `DestroyRef.onDestroy` unregister hook; the router-sync directive uses `takeUntilDestroyed` for its `NavigationEnd` stream.
97
+
98
+ ## See also
99
+
100
+ - `@cngx/ui/stepper` — `<cngx-stepper>` CNGX-standard organism
101
+ - `@cngx/ui/mat-stepper` — `<cngx-mat-stepper>` Material-twin organism
102
+ - `.internal/architektur/stepper-accepted-debt.md` — tracked architectural debt (single §1: native `<mat-step>` adoption is structurally impossible via Angular content projection)
package/tabs/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # @cngx/common/tabs
2
+
3
+ The headless brain of the cngx tabs system. Presenter directive, host contracts, configuration cascade, slot directives, overflow strategy. Pairs with a rendering skin from `@cngx/ui/tabs` (CDK) or `@cngx/ui/mat-tabs` (Material), or with consumer-authored templates.
4
+
5
+ ## When you reach for it
6
+
7
+ Almost never directly. This entry is consumed by the skin packages — you import from `@cngx/ui/tabs` or `@cngx/ui/mat-tabs` for ready-to-use components.
8
+
9
+ You touch this entry when:
10
+
11
+ - You are building a **custom rendering** for tabs (a fully bespoke design system) and want the cngx keyboard, ARIA, commit lifecycle, and overflow behaviour without redoing them.
12
+ - You are wiring **tab-level slot defaults** (busy spinner, error badge, overflow trigger) across the application via the configuration cascade.
13
+ - You need to read the per-tab contract from inside a sub-component — host tokens, not concrete classes.
14
+
15
+ ## Mental model
16
+
17
+ Tabs are a presenter applied as a `hostDirective`, a set of declarative `CngxTab` definitions, content projection via `CngxTabContent` / `CngxTabLabel`, and a configurable overflow surface. The skin component is thin — it forwards inputs and renders a `<div role="tablist">` (or a `<mat-tab-group>` in the Material twin). All the state lives in the presenter, and all the wiring between presenter and content runs through `CNGX_TAB_GROUP_HOST` and `CNGX_TAB_PANEL_HOST`.
18
+
19
+ Two things make this layout work:
20
+
21
+ - **Commit lifecycle.** Activating a tab can fire an async action with optimistic or pessimistic semantics. The active state rolls back if the action fails. Per-tab busy and error markers ride the same channel.
22
+ - **Overflow.** When tabs do not fit, the runaway tabs collapse into a "more" trigger. Overflow recompute runs on an `IntersectionObserver` with a debounce, so resize storms do not thrash the layout.
23
+
24
+ ## Companion entries
25
+
26
+ - **`@cngx/ui/tabs`** — CDK skin (`<cngx-tab-group>`, `<cngx-tab-overflow>`).
27
+ - **`@cngx/ui/mat-tabs`** — Material twin.
28
+ - **`@cngx/common/stepper`** — sibling brain for ordered flows.
29
+
30
+ ## See also
31
+
32
+ - Presenter inputs/outputs, host tokens, slot directives, and `with*` config features in the **API** tab.