@cngx/common 0.0.1-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/a11y/README.md +13 -16
- package/card/README.md +2 -21
- package/chart/README.md +5 -8
- package/data/README.md +45 -47
- package/dialog/README.md +12 -15
- package/display/README.md +5 -9
- package/fesm2022/cngx-common-a11y.mjs +164 -51
- package/fesm2022/cngx-common-a11y.mjs.map +1 -1
- package/fesm2022/cngx-common-card.mjs +157 -69
- package/fesm2022/cngx-common-card.mjs.map +1 -1
- package/fesm2022/cngx-common-chart.mjs +389 -92
- package/fesm2022/cngx-common-chart.mjs.map +1 -1
- package/fesm2022/cngx-common-data.mjs +311 -151
- package/fesm2022/cngx-common-data.mjs.map +1 -1
- package/fesm2022/cngx-common-dialog.mjs +167 -29
- package/fesm2022/cngx-common-dialog.mjs.map +1 -1
- package/fesm2022/cngx-common-display.mjs +445 -110
- package/fesm2022/cngx-common-display.mjs.map +1 -1
- package/fesm2022/cngx-common-interactive.mjs +2059 -435
- package/fesm2022/cngx-common-interactive.mjs.map +1 -1
- package/fesm2022/cngx-common-layout.mjs +188 -31
- package/fesm2022/cngx-common-layout.mjs.map +1 -1
- package/fesm2022/cngx-common-popover.mjs +711 -90
- package/fesm2022/cngx-common-popover.mjs.map +1 -1
- package/fesm2022/cngx-common-stepper.mjs +1479 -73
- package/fesm2022/cngx-common-stepper.mjs.map +1 -1
- package/fesm2022/cngx-common-tabs.mjs +1144 -85
- package/fesm2022/cngx-common-tabs.mjs.map +1 -1
- package/fesm2022/cngx-common.mjs +2 -2
- package/fesm2022/cngx-common.mjs.map +1 -1
- package/interactive/README.md +5 -5
- package/layout/README.md +2 -2
- package/package.json +7 -6
- package/popover/README.md +8 -34
- package/stepper/README.md +69 -8
- package/tabs/README.md +6 -6
- package/theming/components/cngx-async.css +74 -0
- package/theming/components/cngx-backdrop.css +73 -0
- package/theming/components/cngx-badge.css +340 -0
- package/theming/components/cngx-bottom-sheet.css +201 -0
- package/theming/components/cngx-button-toggle.css +99 -0
- package/theming/components/cngx-dialog.css +358 -0
- package/theming/components/cngx-divider.css +145 -0
- package/theming/components/cngx-listbox.css +220 -0
- package/theming/components/cngx-menu.css +371 -0
- package/theming/components/cngx-ripple.css +116 -0
- package/theming/components/cngx-tooltip.css +265 -0
- package/theming/system-tokens.css +24 -0
- package/types/cngx-common-a11y.d.ts +159 -38
- package/types/cngx-common-card.d.ts +137 -22
- package/types/cngx-common-chart.d.ts +337 -40
- package/types/cngx-common-data.d.ts +277 -45
- package/types/cngx-common-dialog.d.ts +162 -22
- package/types/cngx-common-display.d.ts +422 -78
- package/types/cngx-common-interactive.d.ts +1880 -305
- package/types/cngx-common-layout.d.ts +191 -28
- package/types/cngx-common-popover.d.ts +632 -87
- package/types/cngx-common-stepper.d.ts +1360 -45
- package/types/cngx-common-tabs.d.ts +1139 -56
- package/types/cngx-common.d.ts +1 -1
- package/README.md +0 -18
package/a11y/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# @cngx/common/a11y
|
|
2
2
|
|
|
3
|
-
Accessibility behavior directives
|
|
3
|
+
Accessibility behavior directives - focus management, keyboard navigation, live regions, and motion detection.
|
|
4
4
|
|
|
5
5
|
## CngxRovingTabindex
|
|
6
6
|
|
|
7
|
-
Implements the [WAI-ARIA roving tabindex](https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_roving_tabindex) pattern for composite widgets. Only the active item has `tabindex="0"`
|
|
7
|
+
Implements the [WAI-ARIA roving tabindex](https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_roving_tabindex) pattern for composite widgets. Only the active item has `tabindex="0"` - all others get `tabindex="-1"`. Arrow keys move focus within the group; Tab leaves it entirely.
|
|
8
8
|
|
|
9
9
|
```html
|
|
10
10
|
<div cngxRovingTabindex orientation="horizontal" [loop]="true" #rv="cngxRovingTabindex">
|
|
@@ -16,13 +16,13 @@ Implements the [WAI-ARIA roving tabindex](https://www.w3.org/WAI/ARIA/apg/practi
|
|
|
16
16
|
|
|
17
17
|
### CngxRovingTabindex Keyboard
|
|
18
18
|
|
|
19
|
-
| Key
|
|
20
|
-
|
|
21
|
-
| `ArrowRight` / `ArrowDown` | Move to next item (axis-dependent)
|
|
22
|
-
| `ArrowLeft` / `ArrowUp`
|
|
23
|
-
| `Home`
|
|
24
|
-
| `End`
|
|
25
|
-
| `Tab`
|
|
19
|
+
| Key | Action |
|
|
20
|
+
|-|-|
|
|
21
|
+
| `ArrowRight` / `ArrowDown` | Move to next item (axis-dependent) |
|
|
22
|
+
| `ArrowLeft` / `ArrowUp` | Move to previous item (axis-dependent) |
|
|
23
|
+
| `Home` | Jump to first enabled item |
|
|
24
|
+
| `End` | Jump to last enabled item |
|
|
25
|
+
| `Tab` | Leave the group (standard tab order) |
|
|
26
26
|
|
|
27
27
|
### Notes
|
|
28
28
|
|
|
@@ -30,7 +30,6 @@ Implements the [WAI-ARIA roving tabindex](https://www.w3.org/WAI/ARIA/apg/practi
|
|
|
30
30
|
- `activeIndex` is clamped to the valid range when items are added/removed.
|
|
31
31
|
- Items are discovered via `contentChildren(CngxRovingItem)`.
|
|
32
32
|
|
|
33
|
-
---
|
|
34
33
|
|
|
35
34
|
## CngxFocusRestore
|
|
36
35
|
|
|
@@ -52,25 +51,23 @@ Captures the previously focused element on init and restores focus when the host
|
|
|
52
51
|
3. Nearest focusable ancestor
|
|
53
52
|
4. Nothing (focus stays where it is)
|
|
54
53
|
|
|
55
|
-
---
|
|
56
54
|
|
|
57
55
|
## CngxAutofocus
|
|
58
56
|
|
|
59
|
-
Reactive autofocus for dynamically inserted elements. The native `autofocus` attribute only works on initial page load
|
|
57
|
+
Reactive autofocus for dynamically inserted elements. The native `autofocus` attribute only works on initial page load - this directive handles dialogs, panels, steppers, and conditional views.
|
|
60
58
|
|
|
61
59
|
```html
|
|
62
60
|
@if (showSearch()) {
|
|
63
|
-
<input [cngxAutofocus]="true" placeholder="Search…" />
|
|
61
|
+
<input [cngxAutofocus]="true" placeholder="Search…" />
|
|
64
62
|
}
|
|
65
63
|
```
|
|
66
64
|
|
|
67
65
|
### Notes
|
|
68
66
|
|
|
69
|
-
- Uses `afterNextRender` for initial focus
|
|
67
|
+
- Uses `afterNextRender` for initial focus - never synchronous.
|
|
70
68
|
- `delay > 0` uses `setTimeout`; `delay === 0` uses `afterNextRender`.
|
|
71
|
-
- Tracks `when` transitions via `effect()`
|
|
69
|
+
- Tracks `when` transitions via `effect()` - only re-focuses on `false → true`.
|
|
72
70
|
|
|
73
|
-
---
|
|
74
71
|
|
|
75
72
|
## Other Exports
|
|
76
73
|
|
package/card/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# CngxCard
|
|
2
2
|
|
|
3
|
-
Semantic card component that adapts its host element role based on the archetype (article/button/link). The host element **is** the semantic element
|
|
3
|
+
Semantic card component that adapts its host element role based on the archetype (article/button/link). The host element **is** the semantic element - no inner wrapper, no double focus rings.
|
|
4
4
|
|
|
5
5
|
## Quick Start
|
|
6
6
|
|
|
@@ -44,8 +44,6 @@ export class ExampleComponent {
|
|
|
44
44
|
|
|
45
45
|
## Accessibility
|
|
46
46
|
|
|
47
|
-
CngxCard is fully accessible:
|
|
48
|
-
|
|
49
47
|
- **ARIA roles:** `role="article"` (default), `role="button"`, or `role="link"` based on `as` input
|
|
50
48
|
- **Keyboard interaction:**
|
|
51
49
|
- `Enter` / `Space`: Activate interactive cards (button/link)
|
|
@@ -58,22 +56,5 @@ CngxCard is fully accessible:
|
|
|
58
56
|
|
|
59
57
|
CngxCard composes `CngxRovingItem` as a host directive for keyboard navigation within `CngxCardGrid`.
|
|
60
58
|
|
|
61
|
-
CngxCardGrid composes `CngxRovingTabindex` as a host directive
|
|
62
|
-
|
|
63
|
-
## Material Theme
|
|
64
|
-
|
|
65
|
-
CngxCard ships with Material 3 styling via CSS custom properties. To apply full Material theming (density, typography, color tokens), import the theme file in your global styles:
|
|
66
|
-
|
|
67
|
-
```scss
|
|
68
|
-
@import '@cngx/common/card/card-theme';
|
|
69
|
-
|
|
70
|
-
@include cngx-card-theme($material-theme);
|
|
71
|
-
@include cngx-card-density(-1); // compact
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
Density levels:
|
|
59
|
+
CngxCardGrid composes `CngxRovingTabindex` as a host directive - all arrow key/Home/End navigation is built in automatically.
|
|
75
60
|
|
|
76
|
-
- `-2` → extra compact
|
|
77
|
-
- `-1` → compact
|
|
78
|
-
- `0` → default (Material default)
|
|
79
|
-
- `1` → comfortable
|
package/chart/README.md
CHANGED
|
@@ -4,28 +4,25 @@ Declarative, Signal-first chart system. Built as two layers: composable atoms (o
|
|
|
4
4
|
|
|
5
5
|
## When you reach for it
|
|
6
6
|
|
|
7
|
-
You are visualising data inside an Angular template and want chart behaviour that lives in the same reactivity graph as the rest of your component
|
|
7
|
+
You are visualising data inside an Angular template and want chart behaviour that lives in the same reactivity graph as the rest of your component - not a wrapper around an imperative library. Typical reasons:
|
|
8
8
|
|
|
9
|
-
- A single-series sparkline next to a value cell
|
|
9
|
+
- A single-series sparkline next to a value cell - no axes, no legend, just a glanceable trend.
|
|
10
10
|
- A KPI tile with a donut or stacked bar showing composition or progress.
|
|
11
11
|
- A custom chart shape that the presets do not cover, where you want to compose your own `<svg:g>` layers against scales the container provides.
|
|
12
12
|
- Async data sources where loading, refresh, and error states should render through the same surface as the chart itself rather than as separate UI.
|
|
13
13
|
|
|
14
14
|
## Mental model
|
|
15
15
|
|
|
16
|
-
A cngx chart is just an SVG with a shared **chart context**
|
|
16
|
+
A cngx chart is just an SVG with a shared **chart context** - scales, dimensions, and theme tokens - exposed via DI to its children. Atoms read the context to render their slice (axis ticks, line path, bar rectangles, scatter points). Preset molecules wire the common combinations together so you do not assemble them every time.
|
|
17
17
|
|
|
18
18
|
Three properties make the chart system feel different from a wrapped library:
|
|
19
19
|
|
|
20
|
-
- **Reactive scales.** The X and Y scales are signals derived from the data and container dimensions. Resizing the container or swapping data triggers exactly the layers whose inputs changed
|
|
20
|
+
- **Reactive scales.** The X and Y scales are signals derived from the data and container dimensions. Resizing the container or swapping data triggers exactly the layers whose inputs changed - no full re-layout.
|
|
21
21
|
- **Async-native.** Bind `[state]` and the chart switches between skeleton, content, refresh, empty, and error views the same way every other cngx surface does. Loading is a built-in mode, not a parent wrapper.
|
|
22
22
|
- **Override slots.** Loading, empty, and error placeholders are template slots; the chart never blocks you from owning the UX of a failed fetch.
|
|
23
23
|
|
|
24
24
|
## Status
|
|
25
25
|
|
|
26
|
-
Under active development. Treat the **preset molecules** as stable for adoption. Treat the **atom internals** (axis tick computation, layer projection caching, custom-layer authoring) as still in flux until the chart-area master plan closes
|
|
26
|
+
Under active development. Treat the **preset molecules** as stable for adoption. Treat the **atom internals** (axis tick computation, layer projection caching, custom-layer authoring) as still in flux until the chart-area master plan closes - APIs may move between minor releases.
|
|
27
27
|
|
|
28
|
-
## See also
|
|
29
28
|
|
|
30
|
-
- Components, atoms, scales, and slot directives are listed in the **API** tab.
|
|
31
|
-
- Live examples and theming in the demo app under `dev-app/src/app/demos/common/chart/`.
|
package/data/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
# @cngx/common/data
|
|
1
|
+
# @cngx/common/data - Async State System
|
|
2
2
|
|
|
3
3
|
Signal-based state machine for async operations. One typed source drives
|
|
4
|
-
skeleton, loading bar, empty state, error, toast, and ARIA
|
|
4
|
+
skeleton, loading bar, empty state, error, toast, and ARIA - automatically.
|
|
5
5
|
|
|
6
6
|
## This Is UX State, Not Data State
|
|
7
7
|
|
|
@@ -19,7 +19,7 @@ different question:
|
|
|
19
19
|
|
|
20
20
|
A SignalStore holds your `Resident[]` collection and knows which
|
|
21
21
|
residents are selected. A `CngxAsyncState<Resident[]>` knows whether
|
|
22
|
-
that collection is currently loading, refreshing, empty, or failed
|
|
22
|
+
that collection is currently loading, refreshing, empty, or failed -
|
|
23
23
|
and tells every UI component about it.
|
|
24
24
|
|
|
25
25
|
They compose naturally:
|
|
@@ -84,26 +84,26 @@ readonly residents = injectAsyncState(() =>
|
|
|
84
84
|
);
|
|
85
85
|
// residents.status(), residents.data(), residents.isFirstLoad(),
|
|
86
86
|
// residents.isEmpty(), residents.error(), residents.isBusy()
|
|
87
|
-
//
|
|
87
|
+
// - all computed(), all reactive, all consistent
|
|
88
88
|
```
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
|
|
91
91
|
|
|
92
92
|
## Five Factories
|
|
93
93
|
|
|
94
94
|
| Factory | Use Case | Injection Context |
|
|
95
95
|
|-|-|-|
|
|
96
|
-
| `injectAsyncState(fn)` | Reactive query (GET)
|
|
97
|
-
| `createAsyncState()` | Mutation (POST/PUT/DELETE)
|
|
98
|
-
| `createManualState()` | Full manual control
|
|
96
|
+
| `injectAsyncState(fn)` | Reactive query (GET) - auto-reloads on signal change | Required |
|
|
97
|
+
| `createAsyncState()` | Mutation (POST/PUT/DELETE) - explicit `execute()` | Required |
|
|
98
|
+
| `createManualState()` | Full manual control - Web Workers, computations | Not needed |
|
|
99
99
|
| `fromResource(ref)` | Bridge for Angular `resource()` | Required |
|
|
100
100
|
| `fromHttpResource(ref)` | Bridge for Angular `httpResource()` with progress | Required |
|
|
101
101
|
|
|
102
|
-
All return `CngxAsyncState<T>`
|
|
102
|
+
All return `CngxAsyncState<T>` - the same interface every UI component accepts.
|
|
103
|
+
|
|
103
104
|
|
|
104
|
-
---
|
|
105
105
|
|
|
106
|
-
## 1. injectAsyncState
|
|
106
|
+
## 1. injectAsyncState - Reactive Query
|
|
107
107
|
|
|
108
108
|
Auto-loads when signal dependencies change. First load is `loading`,
|
|
109
109
|
subsequent loads are `refreshing` (old data stays visible).
|
|
@@ -116,7 +116,7 @@ private readonly filterText = signal('');
|
|
|
116
116
|
|
|
117
117
|
readonly residents = injectAsyncState(() =>
|
|
118
118
|
this.http.get<Resident[]>('/api/residents', {
|
|
119
|
-
params: { q: this.filterText() }, // tracked
|
|
119
|
+
params: { q: this.filterText() }, // tracked - re-queries on change
|
|
120
120
|
})
|
|
121
121
|
);
|
|
122
122
|
```
|
|
@@ -148,7 +148,7 @@ Network error: loading → error
|
|
|
148
148
|
Refresh: success → refreshing → success
|
|
149
149
|
```
|
|
150
150
|
|
|
151
|
-
### Template
|
|
151
|
+
### Template - Structural Directive
|
|
152
152
|
|
|
153
153
|
```html
|
|
154
154
|
<ul *cngxAsync="residents; let data; skeleton: skelTpl; empty: emptyTpl; error: errTpl">
|
|
@@ -172,7 +172,7 @@ Refresh: success → refreshing → success
|
|
|
172
172
|
</ng-template>
|
|
173
173
|
```
|
|
174
174
|
|
|
175
|
-
### Template
|
|
175
|
+
### Template - Async Container (named slots)
|
|
176
176
|
|
|
177
177
|
```html
|
|
178
178
|
<cngx-async-container [state]="residents" ariaLabel="Residents"
|
|
@@ -203,9 +203,9 @@ Refresh: success → refreshing → success
|
|
|
203
203
|
</cngx-async-container>
|
|
204
204
|
```
|
|
205
205
|
|
|
206
|
-
---
|
|
207
206
|
|
|
208
|
-
|
|
207
|
+
|
|
208
|
+
## 2. createAsyncState - Mutation
|
|
209
209
|
|
|
210
210
|
For user-triggered actions (POST, PUT, DELETE). Uses `execute(fn)` which
|
|
211
211
|
sets `pending`, then `success` or `error`.
|
|
@@ -272,9 +272,9 @@ protected handleDelete(id: string): void {
|
|
|
272
272
|
When `saveAction` is `pending`: dialog prevents close, shows `aria-busy`.
|
|
273
273
|
When `saveAction` is `error`: dialog shows `cngx-dialog--error` class.
|
|
274
274
|
|
|
275
|
-
---
|
|
276
275
|
|
|
277
|
-
|
|
276
|
+
|
|
277
|
+
## 3. createManualState - Full Control
|
|
278
278
|
|
|
279
279
|
No HTTP, no injection context. For Web Workers, heavy computations,
|
|
280
280
|
WebSocket streams, or any scenario where you drive the state yourself.
|
|
@@ -340,7 +340,7 @@ constructor() {
|
|
|
340
340
|
}
|
|
341
341
|
```
|
|
342
342
|
|
|
343
|
-
|
|
343
|
+
|
|
344
344
|
|
|
345
345
|
## RxJS Operators
|
|
346
346
|
|
|
@@ -353,7 +353,7 @@ automatically. No manual `subscribe({ next, error })` boilerplate.
|
|
|
353
353
|
| `tapAsyncProgress(state)` | `Observable<HttpEvent>` | `Observable<HttpEvent>` | Extracts progress events, calls `setProgress(0-100)` |
|
|
354
354
|
| `tapHttpAsyncState(state)` | `Observable<HttpEvent>` | `Observable<T>` | Combines: loading + progress + body extraction + success/error |
|
|
355
355
|
|
|
356
|
-
### tapAsyncState
|
|
356
|
+
### tapAsyncState - Simple Observable Wiring
|
|
357
357
|
|
|
358
358
|
```typescript
|
|
359
359
|
readonly residents = createManualState<Resident[]>();
|
|
@@ -385,7 +385,7 @@ interval(5000).pipe(
|
|
|
385
385
|
).subscribe();
|
|
386
386
|
```
|
|
387
387
|
|
|
388
|
-
Refresh mode
|
|
388
|
+
Refresh mode - pass `{ status: 'refreshing' }` for subsequent loads:
|
|
389
389
|
|
|
390
390
|
```typescript
|
|
391
391
|
refresh(): void {
|
|
@@ -397,7 +397,7 @@ refresh(): void {
|
|
|
397
397
|
}
|
|
398
398
|
```
|
|
399
399
|
|
|
400
|
-
### tapAsyncProgress
|
|
400
|
+
### tapAsyncProgress - HTTP Progress Tracking
|
|
401
401
|
|
|
402
402
|
Use with `{ observe: 'events', reportProgress: true }`:
|
|
403
403
|
|
|
@@ -422,7 +422,7 @@ handleUpload(file: File): void {
|
|
|
422
422
|
}
|
|
423
423
|
```
|
|
424
424
|
|
|
425
|
-
### tapHttpAsyncState
|
|
425
|
+
### tapHttpAsyncState - All-in-One HTTP Operator
|
|
426
426
|
|
|
427
427
|
Combines `tapAsyncState` + `tapAsyncProgress` + response body extraction.
|
|
428
428
|
One operator, zero boilerplate:
|
|
@@ -444,7 +444,7 @@ handleUpload(file: File): void {
|
|
|
444
444
|
}
|
|
445
445
|
```
|
|
446
446
|
|
|
447
|
-
Template
|
|
447
|
+
Template - everything wired from one source:
|
|
448
448
|
|
|
449
449
|
```html
|
|
450
450
|
<!-- Progress bar during upload -->
|
|
@@ -499,12 +499,12 @@ handleSave(): void {
|
|
|
499
499
|
}
|
|
500
500
|
```
|
|
501
501
|
|
|
502
|
-
---
|
|
503
502
|
|
|
504
|
-
|
|
503
|
+
|
|
504
|
+
## 4. fromResource - Angular resource() Bridge
|
|
505
505
|
|
|
506
506
|
Wraps Angular's `resource()` as `CngxAsyncState<T>`. The resource stays
|
|
507
|
-
the single source of truth
|
|
507
|
+
the single source of truth - all signals are derived projections.
|
|
508
508
|
|
|
509
509
|
```typescript
|
|
510
510
|
private readonly res = resource({
|
|
@@ -517,17 +517,17 @@ private readonly res = resource({
|
|
|
517
517
|
readonly items = fromResource(this.res);
|
|
518
518
|
```
|
|
519
519
|
|
|
520
|
-
### Template
|
|
520
|
+
### Template - same as any CngxAsyncState
|
|
521
521
|
|
|
522
522
|
```html
|
|
523
523
|
<cngx-async-container [state]="items" ariaLabel="Items">
|
|
524
|
-
<!-- identical template slots
|
|
524
|
+
<!-- identical template slots - UI doesn't know the source -->
|
|
525
525
|
</cngx-async-container>
|
|
526
526
|
```
|
|
527
527
|
|
|
528
|
-
---
|
|
529
528
|
|
|
530
|
-
|
|
529
|
+
|
|
530
|
+
## 5. fromHttpResource - Angular httpResource() Bridge
|
|
531
531
|
|
|
532
532
|
Like `fromResource` but maps HTTP progress (0-1 float) to
|
|
533
533
|
`CngxAsyncState.progress` (0-100 integer).
|
|
@@ -558,12 +558,12 @@ readonly report = fromHttpResource(this.res);
|
|
|
558
558
|
</cngx-async-container>
|
|
559
559
|
```
|
|
560
560
|
|
|
561
|
-
|
|
561
|
+
|
|
562
562
|
|
|
563
563
|
## Full Example: Resident Management
|
|
564
564
|
|
|
565
565
|
A complete feature combining query, mutation, skeleton, loading bar,
|
|
566
|
-
error handling, toast, and empty state
|
|
566
|
+
error handling, toast, and empty state - all from typed sources.
|
|
567
567
|
|
|
568
568
|
### Service
|
|
569
569
|
|
|
@@ -655,12 +655,12 @@ export class ResidentList {
|
|
|
655
655
|
private readonly api = inject(ResidentApi);
|
|
656
656
|
private readonly filterText = signal('');
|
|
657
657
|
|
|
658
|
-
// Query
|
|
658
|
+
// Query - auto-reloads when filter changes
|
|
659
659
|
readonly residents = injectAsyncState(() =>
|
|
660
660
|
this.api.getAll(this.filterText())
|
|
661
661
|
);
|
|
662
662
|
|
|
663
|
-
// Mutation
|
|
663
|
+
// Mutation - explicit execute()
|
|
664
664
|
readonly deleteState = createAsyncState<void>();
|
|
665
665
|
|
|
666
666
|
protected makeDelete(id: string): () => Promise<void> {
|
|
@@ -701,11 +701,11 @@ export class ResidentList {
|
|
|
701
701
|
Everything is derived from a single source. The state machine
|
|
702
702
|
cannot become inconsistent.
|
|
703
703
|
|
|
704
|
-
|
|
704
|
+
|
|
705
705
|
|
|
706
706
|
## CngxAsyncState Interface
|
|
707
707
|
|
|
708
|
-
Every factory returns this interface
|
|
708
|
+
Every factory returns this interface - every UI component accepts it.
|
|
709
709
|
|
|
710
710
|
| Signal | Type | Description |
|
|
711
711
|
|-|-|-|
|
|
@@ -716,14 +716,14 @@ Every factory returns this interface — every UI component accepts it.
|
|
|
716
716
|
| `isLoading` | `boolean` | `loading`, `pending`, or `refreshing` |
|
|
717
717
|
| `isPending` | `boolean` | Only `pending` (mutation in flight) |
|
|
718
718
|
| `isRefreshing` | `boolean` | Only `refreshing` (re-query, data visible) |
|
|
719
|
-
| `isBusy` | `boolean` | Same as `isLoading`
|
|
719
|
+
| `isBusy` | `boolean` | Same as `isLoading` - maps to `aria-busy` |
|
|
720
720
|
| `isFirstLoad` | `boolean` | No successful load yet |
|
|
721
721
|
| `isEmpty` | `boolean` | Data is `null`, `undefined`, or empty array |
|
|
722
722
|
| `hasData` | `boolean` | Inverse of `isEmpty` |
|
|
723
723
|
| `isSettled` | `boolean` | `success` or `error` |
|
|
724
724
|
| `lastUpdated` | `Date \| undefined` | Timestamp of last success |
|
|
725
725
|
|
|
726
|
-
## SmartDataSource
|
|
726
|
+
## SmartDataSource - Table with Full UX State
|
|
727
727
|
|
|
728
728
|
Pass a `CngxAsyncState<T[]>` to `injectSmartDataSource` and the table
|
|
729
729
|
receives skeleton, error, empty, and loading-bar projections automatically.
|
|
@@ -736,11 +736,11 @@ readonly residents = injectAsyncState(() =>
|
|
|
736
736
|
this.api.getAll(this.filter())
|
|
737
737
|
);
|
|
738
738
|
|
|
739
|
-
// DataSource
|
|
739
|
+
// DataSource - accepts CngxAsyncState directly
|
|
740
740
|
readonly dataSource = injectSmartDataSource(this.residents);
|
|
741
741
|
```
|
|
742
742
|
|
|
743
|
-
### Template
|
|
743
|
+
### Template - every state mapped to a table view
|
|
744
744
|
|
|
745
745
|
```html
|
|
746
746
|
<div cngxPaginate #pg="cngxPaginate"
|
|
@@ -768,7 +768,7 @@ readonly dataSource = injectSmartDataSource(this.residents);
|
|
|
768
768
|
<cngx-empty-state title="No residents" />
|
|
769
769
|
}
|
|
770
770
|
|
|
771
|
-
<!-- Content
|
|
771
|
+
<!-- Content - with loading bar during refresh -->
|
|
772
772
|
@else {
|
|
773
773
|
@if (dataSource.isRefreshing()) {
|
|
774
774
|
<cngx-loading-indicator [loading]="true" variant="bar" />
|
|
@@ -805,9 +805,8 @@ readonly residents = injectAsyncState(() =>
|
|
|
805
805
|
// Paginator disabled while loading via [state]
|
|
806
806
|
```
|
|
807
807
|
|
|
808
|
-
---
|
|
809
808
|
|
|
810
|
-
## CngxPaginate
|
|
809
|
+
## CngxPaginate - Async-Aware Pagination
|
|
811
810
|
|
|
812
811
|
The paginator accepts `[state]` and blocks navigation while busy:
|
|
813
812
|
|
|
@@ -823,9 +822,8 @@ The paginator accepts `[state]` and blocks navigation while busy:
|
|
|
823
822
|
- `CngxMatPaginator` auto-disables via `[disabled]="ref().isBusy()"`
|
|
824
823
|
- No manual disabled management needed
|
|
825
824
|
|
|
826
|
-
---
|
|
827
825
|
|
|
828
|
-
## CngxFileDrop
|
|
826
|
+
## CngxFileDrop - Upload State
|
|
829
827
|
|
|
830
828
|
The file drop accepts `[state]` for upload lifecycle feedback:
|
|
831
829
|
|
|
@@ -862,7 +860,7 @@ handleUpload(files: File[]): void {
|
|
|
862
860
|
- `aria-busy` applied automatically
|
|
863
861
|
- `cngx-file-drop--uploading` CSS class for styling
|
|
864
862
|
|
|
865
|
-
|
|
863
|
+
|
|
866
864
|
|
|
867
865
|
## UI Components That Accept `[state]`
|
|
868
866
|
|
package/dialog/README.md
CHANGED
|
@@ -7,14 +7,14 @@ Dialog system built on the native `<dialog>` element. Reactive lifecycle, determ
|
|
|
7
7
|
You need a dialog and want the browser to do the heavy lifting:
|
|
8
8
|
|
|
9
9
|
- A confirmation modal where the user picks one of two outcomes.
|
|
10
|
-
- A form that should stay open while saving and close itself when the save succeeds
|
|
10
|
+
- A form that should stay open while saving and close itself when the save succeeds - or stay open with an error annotation when it fails.
|
|
11
11
|
- A wizard or multi-step flow where you re-open the same dialog as the user advances.
|
|
12
12
|
- A non-modal popover that floats above the page without trapping focus.
|
|
13
13
|
- A nested dialog (a confirm on top of an editor) that should not double-stack the backdrop.
|
|
14
14
|
- A mobile bottom sheet with a slide-up animation and swipe-to-dismiss.
|
|
15
15
|
- A draggable, persistent panel anchored to viewport coordinates.
|
|
16
16
|
|
|
17
|
-
If you want a small inline overlay anchored to a trigger
|
|
17
|
+
If you want a small inline overlay anchored to a trigger - popover, tooltip, hovercard - that is `@cngx/common/popover`, not this entry.
|
|
18
18
|
|
|
19
19
|
## Two modes
|
|
20
20
|
|
|
@@ -25,21 +25,21 @@ Both modes share the same primitives and the same lifecycle. Pick the mode that
|
|
|
25
25
|
|
|
26
26
|
## Lifecycle as UX
|
|
27
27
|
|
|
28
|
-
Every dialog walks through `closed → opening → open → closing → closed`. The transition states are
|
|
28
|
+
Every dialog walks through `closed → opening → open → closing → closed`. The transition states are part of the public surface, not internal animation bookkeeping that consumers should ignore.
|
|
29
29
|
|
|
30
30
|
Why they exist:
|
|
31
31
|
|
|
32
32
|
- **`opening` and `closing` give CSS time.** Animations run on the transition states; the dialog does not finalize until the browser reports `transitionend`. There is no hardcoded `setTimeout` waiting for fade-out to "probably be done." Disable transitions and the finalization is immediate.
|
|
33
33
|
- **Focus restoration is automatic.** The element that was focused when `open()` was called is captured. On close, focus returns there. If the trigger has been removed from the DOM in the meantime, focus falls back to a consumer-supplied element.
|
|
34
|
-
- **Scroll lock is ref-counted.** Modal dialogs lock `<html>` scrolling for the duration. Two concurrent modals coordinate so the lock only releases when the last one closes
|
|
34
|
+
- **Scroll lock is ref-counted.** Modal dialogs lock `<html>` scrolling for the duration. Two concurrent modals coordinate so the lock only releases when the last one closes - closing one of two stacked dialogs does not let the page scroll out from under the user.
|
|
35
35
|
|
|
36
|
-
The `result()` signal is `undefined` while the dialog is open, becomes the close value once it settles, or becomes the literal string `'dismissed'` when the user closed without picking a value. Reading the result reactively is the standard pattern
|
|
36
|
+
The `result()` signal is `undefined` while the dialog is open, becomes the close value once it settles, or becomes the literal string `'dismissed'` when the user closed without picking a value. Reading the result reactively is the standard pattern - no `subscribe`, no manual cleanup.
|
|
37
37
|
|
|
38
38
|
## Async submit
|
|
39
39
|
|
|
40
40
|
`[submitAction]` turns a form dialog into a transactional surface. When the user clicks save, the action runs while the dialog stays open. The dialog blocks close and announces `aria-busy` while pending; on success it auto-closes with the result; on error it stays open, applies an error class, and surfaces the error to the screen reader.
|
|
41
41
|
|
|
42
|
-
Bind the dialog's `submitState` to a `[cngxToastOn]` or `[cngxBannerOn]` outside the dialog and the feedback layer wires itself with no extra plumbing
|
|
42
|
+
Bind the dialog's `submitState` to a `[cngxToastOn]` or `[cngxBannerOn]` outside the dialog and the feedback layer wires itself with no extra plumbing - the dialog is a producer of `CngxAsyncState` like any other.
|
|
43
43
|
|
|
44
44
|
If the consumer wants to own the lifecycle entirely (custom retry-with-backoff, optimistic local cache update, etc.), bind `[state]` directly and skip `[submitAction]`. The external state takes precedence.
|
|
45
45
|
|
|
@@ -53,12 +53,12 @@ There is no consumer configuration for this. Open dialogs nest correctly out of
|
|
|
53
53
|
|
|
54
54
|
Two opt-in directives extend the base dialog without forking it:
|
|
55
55
|
|
|
56
|
-
- **`CngxBottomSheet`** anchors a modal dialog to the viewport bottom, animates slide-up, and renders a drag-affordance handle. Combined with `CngxSwipeDismiss` on the same host, swipe-to-dismiss is auto-wired
|
|
56
|
+
- **`CngxBottomSheet`** anchors a modal dialog to the viewport bottom, animates slide-up, and renders a drag-affordance handle. Combined with `CngxSwipeDismiss` on the same host, swipe-to-dismiss is auto-wired - the consumer does not bind a `(swiped)` event.
|
|
57
57
|
- **`CngxDialogDraggable`** turns any dialog into a draggable panel. Position is exposed as CSS custom properties so the theme applies the transform; keyboard navigation is wired automatically (arrows for fine moves, Shift+arrows for coarse, Home to reset). Optional grid snap and viewport-clamp inputs cover the common ergonomic requests.
|
|
58
58
|
|
|
59
59
|
## Non-modal
|
|
60
60
|
|
|
61
|
-
`[modal]="false"` opens the dialog via the native `show()` method instead of `showModal()`. No backdrop, no focus trap, no scroll lock, no `aria-modal`. The browser also does not announce that a non-modal dialog opened
|
|
61
|
+
`[modal]="false"` opens the dialog via the native `show()` method instead of `showModal()`. No backdrop, no focus trap, no scroll lock, no `aria-modal`. The browser also does not announce that a non-modal dialog opened - a sibling `aria-live` region near the trigger is the consumer's responsibility, and a dev-mode warning fires when one is missing.
|
|
62
62
|
|
|
63
63
|
Use non-modal for floating panels that should not preempt the page. Most product dialogs are modal; reach for non-modal deliberately.
|
|
64
64
|
|
|
@@ -69,16 +69,13 @@ The dialog system is built around the native `<dialog>` element, which is the on
|
|
|
69
69
|
- **`aria-labelledby` and `aria-describedby` are wired automatically** from `[cngxDialogTitle]` and `[cngxDialogDescription]` content children. Place them in the template; the linkage is reactive.
|
|
70
70
|
- **Title announcement.** When a modal dialog transitions to `'open'`, the title text is announced through a polite live region. Screen-reader users hear the dialog purpose without an explicit `aria-live` element.
|
|
71
71
|
- **Icon-only close buttons** need an explicit `aria-label`. The library does not invent labels.
|
|
72
|
-
- **Multi-step content**
|
|
72
|
+
- **Multi-step content** - wizards, tabbed dialogs, paginated forms - is the consumer's responsibility. The dialog moves focus once on open. After that, calling `.focus()` on the first element of the new step is on you.
|
|
73
73
|
- **Error state.** Bind `[error]` to apply `aria-invalid="true"` and the `cngx-dialog--error` class. Pair with a `cngx-form-errors` block (or any `role="alert"` region) inside the dialog for WCAG-compliant form-error announcements.
|
|
74
|
-
- **Reduced motion.** The theme honors `prefers-reduced-motion: reduce`
|
|
74
|
+
- **Reduced motion.** The theme honors `prefers-reduced-motion: reduce` - open and close transitions disable themselves automatically.
|
|
75
75
|
|
|
76
76
|
## See also
|
|
77
77
|
|
|
78
78
|
- Directive selectors, signals, methods, inputs, and CSS custom properties in the **API** tab of the generated docs.
|
|
79
|
-
- Migration mapping from `MatDialog` (provider, data token, ref token, result type) in the API tab
|
|
80
|
-
- Live demos under `
|
|
79
|
+
- Migration mapping from `MatDialog` (provider, data token, ref token, result type) in the API tab - every `Mat*` symbol has a `Cngx*` equivalent.
|
|
80
|
+
- Live demos under `examples/stories/common/dialog/` cover declarative, programmatic, submit-action, bottom sheet, draggable, and nested patterns.
|
|
81
81
|
|
|
82
|
-
## Peer dependencies
|
|
83
|
-
|
|
84
|
-
`@angular/core`, `@angular/common`.
|
package/display/README.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# @cngx/common/display
|
|
2
2
|
|
|
3
|
-
Display-only atoms. Icons, avatars, badges, chips, tags, indicators, dividers
|
|
3
|
+
Display-only atoms. Icons, avatars, badges, chips, tags, indicators, dividers - the visual vocabulary of cngx. No behaviour, no state beyond presentational flags.
|
|
4
4
|
|
|
5
5
|
## When you reach for it
|
|
6
6
|
|
|
7
7
|
You need a primitive visual piece that other components compose:
|
|
8
8
|
|
|
9
9
|
- An avatar that gracefully degrades from photo URL → initials → fallback.
|
|
10
|
-
- A chip the user can remove (used internally by multi-select, combobox, tag-input, filter-chips
|
|
11
|
-
- A tag pill that conveys status, category, or count
|
|
10
|
+
- A chip the user can remove (used internally by multi-select, combobox, tag-input, filter-chips - and available to you for the same purpose).
|
|
11
|
+
- A tag pill that conveys status, category, or count - non-removable, theme-aware.
|
|
12
12
|
- A checkbox or radio glyph for a custom row design where you want the cngx look but own the selection logic yourself.
|
|
13
13
|
- A divider with an optional inline label.
|
|
14
14
|
|
|
@@ -16,15 +16,11 @@ For **interactive** atoms (ripple, async-click, nav badges, expandable disclosur
|
|
|
16
16
|
|
|
17
17
|
## Mental model
|
|
18
18
|
|
|
19
|
-
Every atom here is a thin visual surface that reads inputs and produces ARIA-correct markup. None of them own selection, focus, or async state
|
|
19
|
+
Every atom here is a thin visual surface that reads inputs and produces ARIA-correct markup. None of them own selection, focus, or async state - those are coordinated by the organisms that compose them. That separation is what lets `CngxCheckboxIndicator` appear inside a select panel row, a tree node, a menu item checkbox, and a custom table row without each context having to re-invent the visual or its accessibility shape.
|
|
20
20
|
|
|
21
21
|
`CngxChip` and `CngxTag` are easy to confuse: a chip is **removable and ephemeral** (the user added it, the user can remove it), a tag is **applied and static** (a label that classifies something). When in doubt, ask whether the user can dismiss it; if yes, it is a chip.
|
|
22
22
|
|
|
23
|
-
## Theming
|
|
24
|
-
|
|
25
|
-
Every visual property — colour, radius, spacing, sizing — is a CSS custom property with a Material 3 fallback. Override at any DOM level via standard cascade. The full token list lives next to each component in the API tab.
|
|
26
|
-
|
|
27
23
|
## See also
|
|
28
24
|
|
|
29
25
|
- Each component's inputs, slots, and CSS variables in the **API** tab.
|
|
30
|
-
- Live demos under `
|
|
26
|
+
- Live demos under `examples/stories/common/display/`.
|