@cngx/ui 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.
- package/fesm2022/cngx-ui-mat-stepper.mjs +76 -229
- package/fesm2022/cngx-ui-mat-stepper.mjs.map +1 -1
- package/fesm2022/cngx-ui-mat-tabs.mjs +346 -39
- package/fesm2022/cngx-ui-mat-tabs.mjs.map +1 -1
- package/fesm2022/cngx-ui-stepper.mjs +205 -32
- package/fesm2022/cngx-ui-stepper.mjs.map +1 -1
- package/fesm2022/cngx-ui-tabs.mjs +238 -23
- package/fesm2022/cngx-ui-tabs.mjs.map +1 -1
- package/fesm2022/cngx-ui.mjs +1 -1
- package/mat-stepper/README.md +37 -14
- package/mat-tabs/styles/mat-tabs.css +58 -40
- package/package.json +3 -3
- package/stepper/README.md +74 -0
- package/tabs/README.md +18 -0
- package/types/cngx-ui-mat-stepper.d.ts +64 -113
- package/types/cngx-ui-mat-tabs.d.ts +170 -13
- package/types/cngx-ui-stepper.d.ts +121 -12
- package/types/cngx-ui-tabs.d.ts +145 -9
package/stepper/README.md
CHANGED
|
@@ -172,3 +172,77 @@ onSwipe(direction: SwipeDirection): void {
|
|
|
172
172
|
Keyboard navigation (arrow keys, Home / End) is built into the indicator and needs no wiring; swipe is the touch counterpart you add yourself.
|
|
173
173
|
|
|
174
174
|
**Caveat:** only wire swipe onto panels that are genuinely paged content (onboarding, galleries). Do not make a panel that holds real form fields swipe-navigable - a horizontal drag while editing inputs is ambiguous and fights native gestures. For form wizards, keep explicit Back / Next controls.
|
|
175
|
+
|
|
176
|
+
## Header navigation
|
|
177
|
+
|
|
178
|
+
`headerNavigation` decides whether the step headers are controls or pure indicators. It is a two-value policy - `'none'` or `'visited'` - that folds into the existing `linear` axis instead of adding a third mode.
|
|
179
|
+
|
|
180
|
+
|Value|Headers|Reachability|
|
|
181
|
+
|-|-|-|
|
|
182
|
+
|`'none'`|Inert labels (no button, no roving, no click). The footer is the only navigation.|n/a - headers never navigate|
|
|
183
|
+
|`'visited'` (default)|Focusable buttons|Gated by `linear`|
|
|
184
|
+
|
|
185
|
+
With `'visited'`, the `linear` flag does the rest:
|
|
186
|
+
|
|
187
|
+
- `linear="false"` (the default): every enabled header is clickable - free navigation, the old behaviour.
|
|
188
|
+
- `linear="true"`: only already-visited (completed) steps are reachable; forward-incomplete headers carry `aria-disabled="true"` and stay focusable so the gate is announced, not a silent no-op.
|
|
189
|
+
|
|
190
|
+
There is no separate `'free'` value - "free" is just `headerNavigation="visited"` with `linear="false"`.
|
|
191
|
+
|
|
192
|
+
```html
|
|
193
|
+
<!-- Footer-only wizard: headers are read-only indicators. -->
|
|
194
|
+
<cngx-stepper headerNavigation="none" [linear]="true" aria-label="Checkout">
|
|
195
|
+
<div cngxStep label="Cart"></div>
|
|
196
|
+
<div cngxStep label="Address"></div>
|
|
197
|
+
<div cngxStep label="Payment"></div>
|
|
198
|
+
<cngx-stepper-footer>
|
|
199
|
+
<button cngxStepperFooterStart cngxStepperPrevious>Back</button>
|
|
200
|
+
<button cngxStepperFooterEnd cngxStepperNext>Continue</button>
|
|
201
|
+
</cngx-stepper-footer>
|
|
202
|
+
</cngx-stepper>
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Set the app-wide default with `provideStepperConfig(withStepperHeaderNavigation('none'))`; the per-instance `[headerNavigation]` input wins over it.
|
|
206
|
+
|
|
207
|
+
While a commit is in flight (`commitAction` pending), the `'visited'` headers lock - they go `aria-disabled`, click and arrow-key navigation no-op - so the strip cannot supersede the pending transition. This matches the footer nav atoms (`cngxStepperPrevious` / `cngxStepperNext`), which disable on `busy()` too; the strip and the footer lock together during an async step.
|
|
208
|
+
|
|
209
|
+
### Migration
|
|
210
|
+
|
|
211
|
+
The default is `'visited'`. For non-linear steppers (`linear="false"`, the default) this is identical to previous behaviour - every header stays clickable. **Linear steppers change:** headers that used to be clickable-but-blocked are now marked `aria-disabled` and only visited steps are reachable. If you relied on always-clickable headers under `linear="true"`, set `[linear]="false"` (or keep `headerNavigation="visited"` and gate completion yourself).
|
|
212
|
+
|
|
213
|
+
## Error channels
|
|
214
|
+
|
|
215
|
+
A step can be flagged as in error through two independent channels. Both render the same error **state** on every skin (the indicator / badge / tile turns errored); the error **message** surfaces separately.
|
|
216
|
+
|
|
217
|
+
|Channel|How you flag it|Where the message appears|
|
|
218
|
+
|-|-|-|
|
|
219
|
+
|Validation|`[error]="true \| 'message'"` on `cngxStep`, or `[errorAggregator]` for multi-source forms|a row **below the strip** (every classic-style skin) via `*cngxStepError`; folded into the aggregate line on the `text` / `dot` / `progress-bar` mini variants|
|
|
220
|
+
|Commit / async|a `commitAction` that rejects (sets `lastFailedIndex`)|`*cngxStepRejection` decoration; `CngxToastOn` / `CngxBannerOn` transition bridges|
|
|
221
|
+
|
|
222
|
+
The message lives on its own row **below** the step strip, not inside a step. That is deliberate: a free-text message inside a horizontal (or column) strip item widens the shrink-to-fit step and tears the row; below the strip it has full width and wraps. The strip itself only ever carries the short state cue.
|
|
223
|
+
|
|
224
|
+
Only steps with a **real reason** show a message row - the bare `errored` state is already communicated by the indicator / badge, so a boolean `[error]="true"` adds no text-only noise. A reason is the direct `[error]` string or the first `errorAggregator` label.
|
|
225
|
+
|
|
226
|
+
The validation channel is the common case and needs no async machine. The simplest form is a single input:
|
|
227
|
+
|
|
228
|
+
```html
|
|
229
|
+
<cngx-stepper aria-label="Payment">
|
|
230
|
+
<div cngxStep label="Card" [error]="cardInvalid() ? 'Card declined' : false"></div>
|
|
231
|
+
<div cngxStep label="Review"></div>
|
|
232
|
+
</cngx-stepper>
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
`[error]="true"` puts the step in the error state (red indicator, no message); `[error]="'Card declined'"` does the same and supplies the message rendered below the strip. A string wins over an aggregator label, which wins over the i18n `errored` status word. No `<fieldset cngxErrorAggregator>` / `<input cngxErrorSource>` scaffolding is required to flag "this step is invalid" - the `errorAggregator` stays the path for genuine multi-source aggregation (per-source keys, labels, SR announcement).
|
|
236
|
+
|
|
237
|
+
Override the message presentation per instance with `*cngxStepError`, app-wide with `withStepErrorTemplate(...)`:
|
|
238
|
+
|
|
239
|
+
```html
|
|
240
|
+
<cngx-stepper aria-label="Payment">
|
|
241
|
+
<div cngxStep label="Card" [error]="cardError()"></div>
|
|
242
|
+
<ng-template cngxStepError let-message="message">
|
|
243
|
+
<strong>{{ message }}</strong>
|
|
244
|
+
</ng-template>
|
|
245
|
+
</cngx-stepper>
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
The commit / async channel is separate: a rejected `commitAction` decorates the rolled-back step (`*cngxStepRejection`) and flows its message through the `CngxToastOn` / `CngxBannerOn` transition bridges. The two channels never collide - validation owns `*cngxStepError`, commit owns `*cngxStepRejection`.
|
package/tabs/README.md
CHANGED
|
@@ -22,6 +22,24 @@ Two pieces give the tab strip its character:
|
|
|
22
22
|
- **Commit lifecycle.** Activating a tab can fire an async action. In optimistic mode the tab becomes active immediately and rolls back on error; in pessimistic mode it stays inactive until success. Per-tab busy and error markers ride the same channel.
|
|
23
23
|
- **Overflow.** When tabs do not fit, the overflowing ones collapse into a "more" menu. Recompute is debounced through an `IntersectionObserver` so resize storms do not thrash the layout.
|
|
24
24
|
|
|
25
|
+
## Skins
|
|
26
|
+
|
|
27
|
+
`[skin]` picks the visual treatment; it maps to a `[data-skin]` host attribute that selects a CSS scope. Structure, slots, ARIA, and keyboard behaviour are identical across every value - only the paint changes. Orthogonal to `[orientation]` (horizontal/vertical) and `[iconLayout]`.
|
|
28
|
+
|
|
29
|
+
|Skin|Look|
|
|
30
|
+
|-|-|
|
|
31
|
+
|`line`|Default. Primary underline ink-bar under the active tab.|
|
|
32
|
+
|`contained`|Square folder tabs; the active tab fuses with the panel into one box and carries a primary accent bar on its leading edge.|
|
|
33
|
+
|`segmented`|Tabs share a muted track; the active tab lifts onto a raised surface.|
|
|
34
|
+
|`pill`|Rounded solid fills; the active pill takes the primary fill.|
|
|
35
|
+
|`pill-outline`|Same pill shape, but the active tab is a tinted, outlined chip.|
|
|
36
|
+
|
|
37
|
+
```html
|
|
38
|
+
<cngx-tab-group skin="segmented" orientation="vertical"> ... </cngx-tab-group>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Set an app-wide default with `withTabsSkin()` (via `provideCngxTabs`). Colours and sizes are CSS custom properties (`--cngx-tab-*`) that chain to `--mat-sys-*` when a Material theme is present.
|
|
42
|
+
|
|
25
43
|
## Companion entries
|
|
26
44
|
|
|
27
45
|
- **`@cngx/common/tabs`** - the headless brain, configuration cascade, slot directives.
|
|
@@ -1,127 +1,78 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import {
|
|
1
|
+
import * as _cngx_common_stepper from '@cngx/common/stepper';
|
|
2
|
+
import { CngxStepRegistration } from '@cngx/common/stepper';
|
|
3
3
|
import * as i0 from '@angular/core';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { InjectionToken } from '@angular/core';
|
|
5
|
+
import { MatStep } from '@angular/material/stepper';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Material
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* Bidirectional sync between presenter and `MatStepper.selectedIndex`
|
|
14
|
-
* runs in a single `effect()` with `untracked()` writes so neither
|
|
15
|
-
* direction tracks the other.
|
|
16
|
-
*
|
|
17
|
-
* Material owns keyboard nav and focus on `MatStepperHeader`, so the
|
|
18
|
-
* organism does NOT compose `CngxRovingTabindex` /
|
|
19
|
-
* `CngxFocusRestore`. Group nodes flatten - `<mat-stepper>` does not
|
|
20
|
-
* support nesting - with the depth preserved as a `data-step-depth`
|
|
21
|
-
* hint on the rendered label.
|
|
22
|
-
*
|
|
23
|
-
* @playground Bridge instrumentation ./examples/bridge/bridge-example.component.ts
|
|
24
|
-
*
|
|
25
|
-
* @category ui/mat-stepper
|
|
26
|
-
* @docsKind primary
|
|
27
|
-
* @wcag AA
|
|
28
|
-
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-stepper/mat-stepper.component.ts
|
|
29
|
-
* @since 0.1.0
|
|
30
|
-
* @relatedTo CngxMatStepperBridge, CngxStepperPresenter, CngxStep
|
|
31
|
-
* <example-url>http://localhost:4200/#/ui/stepper/stepper-footer/mat-stepper-footer</example-url>
|
|
32
|
-
*/
|
|
33
|
-
declare class CngxMatStepper implements CngxStepPanelHost {
|
|
34
|
-
protected readonly presenter: i1.CngxStepperHost;
|
|
35
|
-
private readonly destroyRef;
|
|
36
|
-
private readonly injector;
|
|
37
|
-
protected readonly matStepper: Signal<MatStepper>;
|
|
38
|
-
private readonly hostCdr;
|
|
39
|
-
readonly flatSteps: Signal<readonly CngxStepNode[]>;
|
|
40
|
-
readonly activeStepIndex: Signal<number>;
|
|
41
|
-
readonly activeStepId: Signal<string | null>;
|
|
42
|
-
private readonly stepDirectives;
|
|
43
|
-
/**
|
|
44
|
-
* Consumer-projected `<ng-template matStepperIcon>` templates,
|
|
45
|
-
* forwarded into `MatStepper._iconOverrides` from the
|
|
46
|
-
* `afterNextRender` patch below. `<ng-content>` projection cannot
|
|
47
|
-
* reach Material's `@ContentChildren(MatStepperIcon)` - content-init
|
|
48
|
-
* resolves the inner query before the wrapper's projection lands.
|
|
49
|
-
* `_iconOverrides` is a Material-internal slot.
|
|
50
|
-
*/
|
|
51
|
-
private readonly stepperIcons;
|
|
52
|
-
/**
|
|
53
|
-
* `Map<id, CngxStep>` so `labelTemplateFor` / `contentTemplateFor`
|
|
54
|
-
* are O(1). Structural `equal` on the id-set + per-id directive
|
|
55
|
-
* identity stops the map from cascading on shape-stable
|
|
56
|
-
* `contentChildren` re-emits.
|
|
57
|
-
*/
|
|
58
|
-
private readonly stepDirectiveById;
|
|
59
|
-
/**
|
|
60
|
-
* Step-only flat projection - `<mat-step>` does not nest, so
|
|
61
|
-
* groups collapse into the same level. Memoised via
|
|
62
|
-
* `flatStepsEqual` so consumers (`stepLabel`, panel `@for`,
|
|
63
|
-
* `stepLabelContextFor`) don't re-walk on shape-stable
|
|
64
|
-
* `flatSteps()` re-emits. Sibling-symmetric with
|
|
65
|
-
* `CngxStepper.stepsOnly`.
|
|
66
|
-
*/
|
|
67
|
-
protected readonly stepsOnly: Signal<readonly CngxStepNode[]>;
|
|
68
|
-
/** Material orientation literal - narrows our `'horizontal'|'vertical'` to its own union. */
|
|
69
|
-
protected readonly matOrientation: Signal<"horizontal" | "vertical">;
|
|
70
|
-
protected stepIndexOf(node: CngxStepNode): number;
|
|
71
|
-
/** Editability rule - non-linear lets every step click; linear only past completed. */
|
|
72
|
-
protected isEditable(node: CngxStepNode): boolean;
|
|
73
|
-
protected hasError(node: CngxStepNode): boolean;
|
|
74
|
-
protected isCompleted(node: CngxStepNode): boolean;
|
|
75
|
-
protected stepLabel(node: CngxStepNode): string;
|
|
76
|
-
/** Group nodes carry a depth marker so the label can distinguish nested rows. */
|
|
77
|
-
protected stepDepth(node: CngxStepNode): number;
|
|
78
|
-
labelTemplateFor(id: string): TemplateRef<CngxStepLabelContext> | null;
|
|
79
|
-
contentTemplateFor(id: string): TemplateRef<CngxStepContentContext> | null;
|
|
80
|
-
/**
|
|
81
|
-
* Per-node-id slot-context cache for `*cngxStepLabel` /
|
|
82
|
-
* `*cngxStepContent`. Mutating fields in place preserves the
|
|
83
|
-
* object reference, so `*ngTemplateOutlet`'s `Object.is` diff
|
|
84
|
-
* short-circuits the embedded-view rebind; the embedded view's
|
|
85
|
-
* `let-` bindings re-read the mutated fields on the next CD pass.
|
|
86
|
-
* Stale ids are pruned by the constructor effect tied to
|
|
87
|
-
* `presenter.flatSteps`.
|
|
88
|
-
*/
|
|
89
|
-
private readonly stepLabelContextCache;
|
|
90
|
-
/** Build the {@link CngxStepLabelContext} for the projected label template. */
|
|
91
|
-
protected stepLabelContextFor(node: CngxStepNode): CngxStepLabelContext;
|
|
92
|
-
/** Build the {@link CngxStepContentContext} for the projected content template. */
|
|
93
|
-
protected stepContentContextFor(node: CngxStepNode): CngxStepContentContext;
|
|
94
|
-
constructor();
|
|
95
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<CngxMatStepper, never>;
|
|
96
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<CngxMatStepper, "cngx-mat-stepper", ["cngxMatStepper"], {}, {}, ["stepDirectives", "stepperIcons"], ["cngx-stepper-footer, [cngxStepperFooter]"], true, [{ directive: typeof i1.CngxStepperPresenter; inputs: { "activeStepIndex": "activeStepIndex"; "linear": "linear"; "orientation": "orientation"; "commitAction": "commitAction"; "commitMode": "commitMode"; }; outputs: { "activeStepIndexChange": "activeStepIndexChange"; }; }]>;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Attaches to an existing `<mat-stepper>` and bridges it to a
|
|
101
|
-
* {@link CngxStepperPresenter} - consumers gain the commit-action
|
|
8
|
+
* The Material twin of the CNGX stepper: attach `cngxMatStepper` to a
|
|
9
|
+
* vanilla `<mat-stepper>` and it is bridged to a
|
|
10
|
+
* {@link CngxStepperPresenter}. \
|
|
11
|
+
* Consumers gain the commit-action
|
|
102
12
|
* lifecycle, `CNGX_STATEFUL` (so `<cngx-toast-on />` /
|
|
103
|
-
* `<cngx-banner-on />` compose as children),
|
|
104
|
-
*
|
|
13
|
+
* `<cngx-banner-on />` compose as children), the shared
|
|
14
|
+
* `CNGX_STEPPER_HOST` contract (so a `<cngx-stepper-footer>` can drive
|
|
15
|
+
* Back / Next instead of Material's own buttons via
|
|
16
|
+
* `[host]="ref.presenter"`), and the step-handle registry - all from
|
|
17
|
+
* one attribute.
|
|
105
18
|
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
* `exportAs` differs (`cngxMatStepperDirective`) to avoid colliding
|
|
110
|
-
* with the wrapper's `cngxMatStepper`.
|
|
19
|
+
* This is the instrumentation pattern: Material owns the rendering and
|
|
20
|
+
* the consumer authors native `<mat-step>` markup; CNGX is the
|
|
21
|
+
* behaviour layer. Topology mirrors `[cngxMatTabs]`.
|
|
111
22
|
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
23
|
+
* Inputs/outputs are forwarded from {@link CngxStepperPresenter}:
|
|
24
|
+
* - `activeStepIndex` (two-way, with `activeStepIndexChange`),
|
|
25
|
+
* - `linear`,
|
|
26
|
+
* - `orientation`,
|
|
27
|
+
* - `commitAction`,
|
|
28
|
+
* - `commitMode`. \
|
|
29
|
+
* See the presenter for their semantics.
|
|
30
|
+
* ```html
|
|
31
|
+
* <mat-stepper
|
|
32
|
+
* cngxMatStepper
|
|
33
|
+
* #s="cngxMatStepper"
|
|
34
|
+
* [(activeStepIndex)]="active"
|
|
35
|
+
* [commitAction]="commitAction"
|
|
36
|
+
* [commitMode]="mode()"
|
|
37
|
+
* cngxToastOn
|
|
38
|
+
* [toastError]="'Step transition failed'"
|
|
39
|
+
* cngxBannerOn
|
|
40
|
+
* bannerId="stepper:commit-error"
|
|
41
|
+
* [bannerError]="'The server rejected the step change.'"
|
|
42
|
+
* aria-label="Account setup"
|
|
43
|
+
* >
|
|
44
|
+
* <mat-step label="Personal info">
|
|
45
|
+
* <p>Tell us who you are.</p>
|
|
46
|
+
* </mat-step>
|
|
47
|
+
* <mat-step
|
|
48
|
+
* label="Account"
|
|
49
|
+
* [hasError]="!accepted()"
|
|
50
|
+
* errorMessage="Accept the terms to continue"
|
|
51
|
+
* >
|
|
52
|
+
* <p>Choose your sign-in method.</p>
|
|
53
|
+
* </mat-step>
|
|
54
|
+
* <mat-step label="Confirm">
|
|
55
|
+
* <p>Review everything, then finish.</p>
|
|
56
|
+
* </mat-step>
|
|
57
|
+
* </mat-stepper>
|
|
58
|
+
* ```
|
|
59
|
+
* @playground Bridge instrumentation ./examples/bridge/bridge-example.component.ts
|
|
114
60
|
*
|
|
115
61
|
* @category ui/mat-stepper
|
|
116
62
|
* @docsKind primary
|
|
117
63
|
* @wcag AA
|
|
118
64
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-stepper/mat-stepper.directive.ts
|
|
119
65
|
* @since 0.1.0
|
|
120
|
-
* @relatedTo
|
|
66
|
+
* @relatedTo CngxStepper, CngxStepperPresenter, CngxMatTabs, CngxStepperFooter
|
|
121
67
|
*/
|
|
122
|
-
declare class
|
|
68
|
+
declare class CngxMatStepper {
|
|
123
69
|
private readonly matStepper;
|
|
124
|
-
|
|
70
|
+
/**
|
|
71
|
+
* Shared host contract. Public so a `<cngx-stepper-footer>` placed
|
|
72
|
+
* outside the `<mat-stepper>` can bind `[host]="ref.presenter"` (via
|
|
73
|
+
* `#ref="cngxMatStepper"`) and drive navigation.
|
|
74
|
+
*/
|
|
75
|
+
readonly presenter: _cngx_common_stepper.CngxStepperHost;
|
|
125
76
|
private readonly destroyRef;
|
|
126
77
|
private readonly injector;
|
|
127
78
|
private readonly matSteps;
|
|
@@ -129,8 +80,8 @@ declare class CngxMatStepperBridge {
|
|
|
129
80
|
private readonly createHandle;
|
|
130
81
|
constructor();
|
|
131
82
|
private syncHandles;
|
|
132
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<
|
|
133
|
-
static ɵdir: i0.ɵɵDirectiveDeclaration<
|
|
83
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CngxMatStepper, never>;
|
|
84
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<CngxMatStepper, "[cngxMatStepper]", ["cngxMatStepper"], {}, {}, ["matSteps"], never, true, [{ directive: typeof _cngx_common_stepper.CngxStepperPresenter; inputs: { "activeStepIndex": "activeStepIndex"; "linear": "linear"; "orientation": "orientation"; "commitAction": "commitAction"; "commitMode": "commitMode"; }; outputs: { "activeStepIndexChange": "activeStepIndexChange"; }; }]>;
|
|
134
85
|
}
|
|
135
86
|
|
|
136
87
|
/**
|
|
@@ -245,5 +196,5 @@ type CngxMatStepHandleFactory = typeof createMatStepHandle;
|
|
|
245
196
|
*/
|
|
246
197
|
declare const CNGX_MAT_STEP_HANDLE_FACTORY: InjectionToken<typeof createMatStepHandle>;
|
|
247
198
|
|
|
248
|
-
export { CNGX_MAT_STEP_HANDLE_FACTORY, CngxMatStepper,
|
|
199
|
+
export { CNGX_MAT_STEP_HANDLE_FACTORY, CngxMatStepper, createMatStepHandle };
|
|
249
200
|
export type { CngxMatStepHandleFactory };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as i1 from '@cngx/common/tabs';
|
|
2
2
|
import { CngxTabHandle, CngxTabOverflowDomAdapter } from '@cngx/common/tabs';
|
|
3
3
|
import * as i0 from '@angular/core';
|
|
4
|
-
import { Signal, WritableSignal, InjectionToken, Injector, TemplateRef, EnvironmentProviders, Provider } from '@angular/core';
|
|
4
|
+
import { Signal, WritableSignal, InjectionToken, Injector, OnInit, TemplateRef, EnvironmentProviders, Provider } from '@angular/core';
|
|
5
5
|
import { MatTab } from '@angular/material/tabs';
|
|
6
6
|
import { CngxErrorAggregatorContract } from '@cngx/common/interactive';
|
|
7
7
|
import { MatStepperIconContext } from '@angular/material/stepper';
|
|
@@ -21,6 +21,12 @@ interface CngxMatTabHandleSetup {
|
|
|
21
21
|
/** Convenience mirror of `handle.disabled`. */
|
|
22
22
|
readonly disabled: Signal<boolean>;
|
|
23
23
|
readonly errorAggregator: WritableSignal<CngxErrorAggregatorContract | undefined>;
|
|
24
|
+
/**
|
|
25
|
+
* Direct invalid flag the `[cngxMatTabErrorFlag]` directive writes -
|
|
26
|
+
* `string | boolean`, mirroring `CngxTab.error`. Folds into the
|
|
27
|
+
* handle's `hasError` / `errorMessage` alongside the aggregator.
|
|
28
|
+
*/
|
|
29
|
+
readonly directError: WritableSignal<string | boolean>;
|
|
24
30
|
}
|
|
25
31
|
/**
|
|
26
32
|
* Translates a Material `MatTab` into a cngx {@link CngxTabHandle}
|
|
@@ -38,6 +44,9 @@ interface CngxMatTabHandleSetup {
|
|
|
38
44
|
* `[cngxMatTabError]` writes its bound aggregator in and resets
|
|
39
45
|
* on teardown. The handle exposes `.asReadonly()` to preserve the
|
|
40
46
|
* `CngxTabHandle` contract.
|
|
47
|
+
* - `directError` - writable seeded at `false`;
|
|
48
|
+
* `[cngxMatTabErrorFlag]` writes its `string | boolean` value in
|
|
49
|
+
* and resets on teardown. Folds into `hasError` / `errorMessage`.
|
|
41
50
|
*
|
|
42
51
|
* @category ui/mat-tabs
|
|
43
52
|
*/
|
|
@@ -96,14 +105,14 @@ declare const CNGX_MAT_TAB_HANDLE_FACTORY: InjectionToken<typeof createMatTabHan
|
|
|
96
105
|
*/
|
|
97
106
|
interface CngxMatTabsRegistryHost {
|
|
98
107
|
/**
|
|
99
|
-
* Returns the per-handle
|
|
100
|
-
* before the tab is registered. The
|
|
101
|
-
* query lands during content-init, so a
|
|
102
|
-
* from an attribute directive can race;
|
|
103
|
-
* tracking `presenter.tabs()` and re-attempting
|
|
104
|
-
* tick.
|
|
108
|
+
* Returns the per-handle writable slots (`errorAggregator`,
|
|
109
|
+
* `directError`), or `undefined` before the tab is registered. The
|
|
110
|
+
* `contentChildren(MatTab)` query lands during content-init, so a
|
|
111
|
+
* same-microtask injection from an attribute directive can race;
|
|
112
|
+
* consumers recover by tracking `presenter.tabs()` and re-attempting
|
|
113
|
+
* on the next sync tick.
|
|
105
114
|
*/
|
|
106
|
-
getHandleSetup(matTab: MatTab): Pick<CngxMatTabHandleSetup, 'errorAggregator'> | undefined;
|
|
115
|
+
getHandleSetup(matTab: MatTab): Pick<CngxMatTabHandleSetup, 'errorAggregator' | 'directError'> | undefined;
|
|
107
116
|
}
|
|
108
117
|
/**
|
|
109
118
|
* DI token the {@link CngxMatTabsRegistry} directive provides via
|
|
@@ -148,7 +157,7 @@ declare class CngxMatTabsRegistry implements CngxMatTabsRegistryHost {
|
|
|
148
157
|
private readonly matTabs;
|
|
149
158
|
private readonly setupsByTab;
|
|
150
159
|
constructor();
|
|
151
|
-
getHandleSetup(matTab: MatTab): Pick<CngxMatTabHandleSetup, 'errorAggregator'> | undefined;
|
|
160
|
+
getHandleSetup(matTab: MatTab): Pick<CngxMatTabHandleSetup, 'errorAggregator' | 'directError'> | undefined;
|
|
152
161
|
private syncHandles;
|
|
153
162
|
static ɵfac: i0.ɵɵFactoryDeclaration<CngxMatTabsRegistry, never>;
|
|
154
163
|
static ɵdir: i0.ɵɵDirectiveDeclaration<CngxMatTabsRegistry, "[cngxMatTabsRegistry]", ["cngxMatTabsRegistry"], {}, {}, ["matTabs"], never, true, never>;
|
|
@@ -178,7 +187,7 @@ declare class CngxMatTabsRegistry implements CngxMatTabsRegistryHost {
|
|
|
178
187
|
* @wcag AA
|
|
179
188
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-tabs/mat-tabs.directive.ts
|
|
180
189
|
* @since 0.1.0
|
|
181
|
-
* @relatedTo CngxMatTabsRegistry, CngxMatTabError,
|
|
190
|
+
* @relatedTo CngxMatTabsRegistry, CngxMatTabError, CngxMatStepper
|
|
182
191
|
*/
|
|
183
192
|
declare class CngxMatTabs {
|
|
184
193
|
private readonly matTabGroup;
|
|
@@ -206,7 +215,119 @@ declare class CngxMatTabs {
|
|
|
206
215
|
*/
|
|
207
216
|
clearLastFailed(): void;
|
|
208
217
|
static ɵfac: i0.ɵɵFactoryDeclaration<CngxMatTabs, never>;
|
|
209
|
-
static ɵdir: i0.ɵɵDirectiveDeclaration<CngxMatTabs, "[cngxMatTabs]", ["cngxMatTabs"], {}, {}, ["aggregatorContentSlot", "rejectionContentSlot"], never, true, [{ directive: typeof
|
|
218
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<CngxMatTabs, "[cngxMatTabs]", ["cngxMatTabs"], {}, {}, ["aggregatorContentSlot", "rejectionContentSlot"], never, true, [{ directive: typeof i1.CngxTabGroupPresenter; inputs: { "activeIndex": "activeIndex"; "orientation": "orientation"; "loop": "loop"; "commitAction": "commitAction"; "commitMode": "commitMode"; }; outputs: { "activeIndexChange": "activeIndexChange"; }; }, { directive: typeof CngxMatTabsRegistry; inputs: {}; outputs: {}; }]>;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Layers the cngx error / rejection / announcement layer onto
|
|
223
|
+
* Material's native router tabs (`<nav mat-tab-nav-bar>` /
|
|
224
|
+
* `<a mat-tab-link>` / `<mat-tab-nav-panel>`). The parallel bridge to
|
|
225
|
+
* {@link CngxMatTabs}: `MatTabNav` has no `MatTab` and no
|
|
226
|
+
* `selectedIndex`, so handles register per `<a mat-tab-link>` via
|
|
227
|
+
* {@link CngxMatTabLink}, and the decoration projectors target
|
|
228
|
+
* `.mat-mdc-tab-link` instead of `.mat-mdc-tab`.
|
|
229
|
+
*
|
|
230
|
+
* Gating is **native**: each link is a `routerLink`, so the router runs
|
|
231
|
+
* `CanDeactivate` directly and this directive installs no
|
|
232
|
+
* commit-action. The active index follows the route - add
|
|
233
|
+
* `[cngxTabsRouteSync]` to the same `<nav>` and give each
|
|
234
|
+
* `[cngxMatTabLink]` an `id` matching its route segment; route-sync
|
|
235
|
+
* reflects `NavigationEnd` onto `activeIndex` (its commit-action stays
|
|
236
|
+
* dormant because link clicks navigate natively, never through
|
|
237
|
+
* `presenter.select`). Ableitung statt Verwaltung - the route-active
|
|
238
|
+
* link is the single source of the active index.
|
|
239
|
+
*
|
|
240
|
+
* Composes {@link CngxTabGroupPresenter} via `hostDirectives` so the
|
|
241
|
+
* `CNGX_STATEFUL` producer, the `lastFailedIndex` rejection slot, and
|
|
242
|
+
* the live-region announcer come for free, identical to the cngx
|
|
243
|
+
* organism (Pillar 2 - same communication across skins).
|
|
244
|
+
*
|
|
245
|
+
* Decoration content-template slots (`*cngxMatTabRejectionContent` /
|
|
246
|
+
* `*cngxMatTabAggregatorContent`) are not forwarded on this bridge yet -
|
|
247
|
+
* the projectors render their built-in `cngx-sr-only` spans. The slot
|
|
248
|
+
* inputs that `[cngxMatTabs]` exposes are a deferred follow-up.
|
|
249
|
+
*
|
|
250
|
+
* @category ui/mat-tabs
|
|
251
|
+
* @docsKind primary
|
|
252
|
+
* @wcag AA
|
|
253
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-tabs/mat-tab-nav.directive.ts
|
|
254
|
+
* @since 0.1.0
|
|
255
|
+
* @relatedTo CngxMatTabLink, CngxMatTabs, CngxTabsRouteSync
|
|
256
|
+
*/
|
|
257
|
+
declare class CngxMatTabNav {
|
|
258
|
+
private readonly presenter;
|
|
259
|
+
private readonly destroyRef;
|
|
260
|
+
private readonly injector;
|
|
261
|
+
private readonly renderer;
|
|
262
|
+
private readonly hostEl;
|
|
263
|
+
private readonly i18n;
|
|
264
|
+
private readonly failedHandleId;
|
|
265
|
+
private readonly rejectionState;
|
|
266
|
+
private readonly aggregatedErrorTabs;
|
|
267
|
+
constructor();
|
|
268
|
+
/**
|
|
269
|
+
* Clears `presenter.lastFailedIndex`, dismissing the rejection
|
|
270
|
+
* decoration. Mirrors {@link CngxMatTabs.clearLastFailed} so a
|
|
271
|
+
* template ref (`#nav="cngxMatTabNav"`) is enough.
|
|
272
|
+
*/
|
|
273
|
+
clearLastFailed(): void;
|
|
274
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CngxMatTabNav, never>;
|
|
275
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<CngxMatTabNav, "[cngxMatTabNav]", ["cngxMatTabNav"], {}, {}, never, never, true, [{ directive: typeof i1.CngxTabGroupPresenter; inputs: {}; outputs: {}; }]>;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Registers an `<a mat-tab-link>` anchor as a {@link CngxTabHandle}
|
|
280
|
+
* with the enclosing {@link CngxMatTabNav} presenter. `mat-tab-nav-bar`
|
|
281
|
+
* has no `MatTab` to hang a handle on (the links are the tabs), so this
|
|
282
|
+
* per-link directive is the registration seam - symmetric with how
|
|
283
|
+
* `CngxTab` registers in the cngx-native path and how
|
|
284
|
+
* {@link CngxMatTabsRegistry} registers each `<mat-tab>`.
|
|
285
|
+
*
|
|
286
|
+
* Registration order follows DOM order (Angular instantiates content
|
|
287
|
+
* directives top-to-bottom), so the presenter's `tabs()` index aligns
|
|
288
|
+
* with `nav.querySelectorAll('.mat-mdc-tab-link')` - the index the
|
|
289
|
+
* decoration projectors correlate against.
|
|
290
|
+
*
|
|
291
|
+
* Gating is native: the link's `routerLink` runs `CanDeactivate`
|
|
292
|
+
* directly, so this directive installs no commit-action. The active
|
|
293
|
+
* index follows the route through `[cngxTabsRouteSync]` on the nav,
|
|
294
|
+
* which matches each handle's `id` (set to the route segment) against
|
|
295
|
+
* the URL.
|
|
296
|
+
*
|
|
297
|
+
* @category ui/mat-tabs
|
|
298
|
+
* @docsKind primary
|
|
299
|
+
* @wcag AA
|
|
300
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-tabs/mat-tab-link.directive.ts
|
|
301
|
+
* @since 0.1.0
|
|
302
|
+
* @relatedTo CngxMatTabNav, CngxMatTabs, CngxTab
|
|
303
|
+
*/
|
|
304
|
+
declare class CngxMatTabLink implements OnInit {
|
|
305
|
+
private readonly matLink;
|
|
306
|
+
private readonly host;
|
|
307
|
+
private readonly destroyRef;
|
|
308
|
+
/**
|
|
309
|
+
* Handle id. Set it to the link's route segment so the nav's
|
|
310
|
+
* `[cngxTabsRouteSync]` reflects the active route onto this tab via
|
|
311
|
+
* the default `(h) => [h.id]` mapping. Defaults to a fresh uid when
|
|
312
|
+
* route-sync is not used.
|
|
313
|
+
*/
|
|
314
|
+
readonly id: i0.InputSignal<string>;
|
|
315
|
+
/** Accessible label fed to the live-region announcer. */
|
|
316
|
+
readonly label: i0.InputSignal<string | undefined>;
|
|
317
|
+
/**
|
|
318
|
+
* Direct error flag for the link - `true` or a non-empty string marks
|
|
319
|
+
* it invalid (the string doubles as the message). Mirrors
|
|
320
|
+
* `CngxTab.error` and `[cngxMatTabErrorFlag]`.
|
|
321
|
+
*/
|
|
322
|
+
readonly error: i0.InputSignal<string | boolean>;
|
|
323
|
+
/** Optional rich error aggregator for the link. */
|
|
324
|
+
readonly errorAggregator: i0.InputSignal<CngxErrorAggregatorContract | undefined>;
|
|
325
|
+
private readonly errorMessage;
|
|
326
|
+
private readonly hasError;
|
|
327
|
+
private readonly disabledState;
|
|
328
|
+
ngOnInit(): void;
|
|
329
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CngxMatTabLink, never>;
|
|
330
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<CngxMatTabLink, "[cngxMatTabLink]", ["cngxMatTabLink"], { "id": { "alias": "id"; "required": false; "isSignal": true; }; "label": { "alias": "label"; "required": false; "isSignal": true; }; "error": { "alias": "error"; "required": false; "isSignal": true; }; "errorAggregator": { "alias": "errorAggregator"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
210
331
|
}
|
|
211
332
|
|
|
212
333
|
/**
|
|
@@ -248,6 +369,42 @@ declare class CngxMatTabError {
|
|
|
248
369
|
static ɵdir: i0.ɵɵDirectiveDeclaration<CngxMatTabError, "[cngxMatTabError]", ["cngxMatTabError"], { "aggregator": { "alias": "cngxMatTabError"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
249
370
|
}
|
|
250
371
|
|
|
372
|
+
/**
|
|
373
|
+
* Per-tab direct invalid flag for `[cngxMatTabs]` - the simple-case
|
|
374
|
+
* sibling to `[cngxMatTabError]`. Attach to a `<mat-tab>`; the bound
|
|
375
|
+
* `string | boolean` writes the per-handle `directError` slot, which
|
|
376
|
+
* folds into the handle's `hasError` / `errorMessage`. A non-empty
|
|
377
|
+
* string doubles as the SR descriptor message; `true` marks the tab
|
|
378
|
+
* invalid with no message; `false` / `''` clear it.
|
|
379
|
+
*
|
|
380
|
+
* Symmetric with `[cngxMatTabError]` (one directive, one
|
|
381
|
+
* responsibility - Pillar 3): the aggregator stays the rich
|
|
382
|
+
* multi-source path, this is the "this tab is invalid" marker that
|
|
383
|
+
* needs no aggregator boilerplate. A bare `cngxMatTabErrorFlag`
|
|
384
|
+
* attribute (no brackets) binds the empty string and is coerced to
|
|
385
|
+
* `true` so presence alone marks the tab invalid.
|
|
386
|
+
*
|
|
387
|
+
* Locates its target via {@link CNGX_MAT_TABS_REGISTRY_HOST}, tracks
|
|
388
|
+
* `presenter.tabs()` to recover from the content-init race, and
|
|
389
|
+
* clears the slot on destroy - exactly as {@link CngxMatTabError}.
|
|
390
|
+
*
|
|
391
|
+
* @category ui/mat-tabs
|
|
392
|
+
* @wcag AA
|
|
393
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-tabs/mat-tab-error-flag.directive.ts
|
|
394
|
+
* @since 0.1.0
|
|
395
|
+
* @relatedTo CngxMatTabs, CngxMatTabError, CngxMatTabsRegistry
|
|
396
|
+
*/
|
|
397
|
+
declare class CngxMatTabErrorFlag {
|
|
398
|
+
private readonly matTab;
|
|
399
|
+
private readonly registry;
|
|
400
|
+
private readonly presenter;
|
|
401
|
+
private readonly destroyRef;
|
|
402
|
+
readonly error: i0.InputSignalWithTransform<string | boolean, string | boolean>;
|
|
403
|
+
constructor();
|
|
404
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CngxMatTabErrorFlag, never>;
|
|
405
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<CngxMatTabErrorFlag, "[cngxMatTabErrorFlag]", ["cngxMatTabErrorFlag"], { "error": { "alias": "cngxMatTabErrorFlag"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
406
|
+
}
|
|
407
|
+
|
|
251
408
|
/**
|
|
252
409
|
* Context passed to the `*cngxMatTabAggregatorContent` template.
|
|
253
410
|
* Drives the SR-descriptor content rendered inside the
|
|
@@ -710,5 +867,5 @@ declare namespace MaterialPrivateSurfaces {
|
|
|
710
867
|
*/
|
|
711
868
|
declare function createCngxMatTabOverflowDomAdapter(): CngxTabOverflowDomAdapter;
|
|
712
869
|
|
|
713
|
-
export { CNGX_MAT_TABS_CONFIG, CNGX_MAT_TABS_REGISTRY_HOST, CNGX_MAT_TAB_HANDLE_FACTORY, CngxMatTabAggregatorContent, CngxMatTabError, CngxMatTabRejectionContent, CngxMatTabs, CngxMatTabsRegistry, MaterialPrivateSurfaces, createCngxMatTabOverflowDomAdapter, createMatTabHandle, injectMatTabsConfig, provideMatTabsConfig, provideMatTabsConfigAt, withAnchorRetryAttempts, withHalfWiredSlotSink };
|
|
870
|
+
export { CNGX_MAT_TABS_CONFIG, CNGX_MAT_TABS_REGISTRY_HOST, CNGX_MAT_TAB_HANDLE_FACTORY, CngxMatTabAggregatorContent, CngxMatTabError, CngxMatTabErrorFlag, CngxMatTabLink, CngxMatTabNav, CngxMatTabRejectionContent, CngxMatTabs, CngxMatTabsRegistry, MaterialPrivateSurfaces, createCngxMatTabOverflowDomAdapter, createMatTabHandle, injectMatTabsConfig, provideMatTabsConfig, provideMatTabsConfigAt, withAnchorRetryAttempts, withHalfWiredSlotSink };
|
|
714
871
|
export type { CngxMatTabAggregatorContentContext, CngxMatTabHalfWiredSlotSink, CngxMatTabHandleFactory, CngxMatTabRejectionContentContext, CngxMatTabsConfig, CngxMatTabsConfigFeature, CngxMatTabsRegistryHost };
|