@cngx/ui 0.1.0-rc.8 → 0.3.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 (108) hide show
  1. package/README.md +118 -59
  2. package/action-button/README.md +170 -53
  3. package/breadcrumb/README.md +5 -6
  4. package/collection/README.md +1 -1
  5. package/command-palette/README.md +9 -5
  6. package/data-grid-accordion/README.md +1 -1
  7. package/empty-state/README.md +2 -3
  8. package/feedback/README.md +1 -1
  9. package/fesm2022/cngx-ui-a11y.mjs +13 -23
  10. package/fesm2022/cngx-ui-a11y.mjs.map +1 -1
  11. package/fesm2022/cngx-ui-accordion.mjs +55 -60
  12. package/fesm2022/cngx-ui-accordion.mjs.map +1 -1
  13. package/fesm2022/cngx-ui-action-button.mjs +220 -339
  14. package/fesm2022/cngx-ui-action-button.mjs.map +1 -1
  15. package/fesm2022/cngx-ui-breadcrumb.mjs +100 -80
  16. package/fesm2022/cngx-ui-breadcrumb.mjs.map +1 -1
  17. package/fesm2022/cngx-ui-chart-panel.mjs +18 -31
  18. package/fesm2022/cngx-ui-chart-panel.mjs.map +1 -1
  19. package/fesm2022/cngx-ui-collection.mjs +28 -34
  20. package/fesm2022/cngx-ui-collection.mjs.map +1 -1
  21. package/fesm2022/cngx-ui-command-palette.mjs +29 -51
  22. package/fesm2022/cngx-ui-command-palette.mjs.map +1 -1
  23. package/fesm2022/cngx-ui-context-menu.mjs +138 -89
  24. package/fesm2022/cngx-ui-context-menu.mjs.map +1 -1
  25. package/fesm2022/cngx-ui-data-grid-accordion.mjs +135 -77
  26. package/fesm2022/cngx-ui-data-grid-accordion.mjs.map +1 -1
  27. package/fesm2022/cngx-ui-empty-state.mjs +17 -44
  28. package/fesm2022/cngx-ui-empty-state.mjs.map +1 -1
  29. package/fesm2022/cngx-ui-feedback.mjs +648 -495
  30. package/fesm2022/cngx-ui-feedback.mjs.map +1 -1
  31. package/fesm2022/cngx-ui-layout.mjs +17 -13
  32. package/fesm2022/cngx-ui-layout.mjs.map +1 -1
  33. package/fesm2022/cngx-ui-mat-accordion.mjs +6 -7
  34. package/fesm2022/cngx-ui-mat-accordion.mjs.map +1 -1
  35. package/fesm2022/cngx-ui-mat-paginator.mjs +5 -9
  36. package/fesm2022/cngx-ui-mat-paginator.mjs.map +1 -1
  37. package/fesm2022/cngx-ui-mat-stepper.mjs +6 -9
  38. package/fesm2022/cngx-ui-mat-stepper.mjs.map +1 -1
  39. package/fesm2022/cngx-ui-mat-tabs.mjs +315 -134
  40. package/fesm2022/cngx-ui-mat-tabs.mjs.map +1 -1
  41. package/fesm2022/cngx-ui-nav-rail.mjs +440 -0
  42. package/fesm2022/cngx-ui-nav-rail.mjs.map +1 -0
  43. package/fesm2022/cngx-ui-overlay.mjs +9 -10
  44. package/fesm2022/cngx-ui-overlay.mjs.map +1 -1
  45. package/fesm2022/cngx-ui-paginator.mjs +212 -188
  46. package/fesm2022/cngx-ui-paginator.mjs.map +1 -1
  47. package/fesm2022/cngx-ui-sidenav.mjs +872 -721
  48. package/fesm2022/cngx-ui-sidenav.mjs.map +1 -1
  49. package/fesm2022/cngx-ui-skeleton.mjs +17 -19
  50. package/fesm2022/cngx-ui-skeleton.mjs.map +1 -1
  51. package/fesm2022/cngx-ui-speak.mjs +21 -74
  52. package/fesm2022/cngx-ui-speak.mjs.map +1 -1
  53. package/fesm2022/cngx-ui-stat-card.mjs +39 -62
  54. package/fesm2022/cngx-ui-stat-card.mjs.map +1 -1
  55. package/fesm2022/cngx-ui-stepper.mjs +259 -130
  56. package/fesm2022/cngx-ui-stepper.mjs.map +1 -1
  57. package/fesm2022/cngx-ui-tabs.mjs +148 -50
  58. package/fesm2022/cngx-ui-tabs.mjs.map +1 -1
  59. package/fesm2022/cngx-ui-timeline.mjs +48 -32
  60. package/fesm2022/cngx-ui-timeline.mjs.map +1 -1
  61. package/fesm2022/cngx-ui-toc.mjs +59 -48
  62. package/fesm2022/cngx-ui-toc.mjs.map +1 -1
  63. package/fesm2022/cngx-ui.mjs +5 -5
  64. package/fesm2022/cngx-ui.mjs.map +1 -1
  65. package/mat-tabs/README.md +57 -19
  66. package/mat-tabs/styles/mat-tabs.css +285 -163
  67. package/nav-rail/README.md +325 -0
  68. package/package.json +37 -8
  69. package/paginator/README.md +10 -0
  70. package/schematics/collection.json +9 -0
  71. package/schematics/ng-add/index.js +9 -0
  72. package/schematics/ng-add/schema.json +96 -0
  73. package/schematics/package.json +3 -0
  74. package/sidenav/README.md +150 -55
  75. package/skeleton/README.md +1 -1
  76. package/speak/README.md +1 -2
  77. package/stepper/README.md +20 -5
  78. package/tabs/README.md +13 -0
  79. package/timeline/README.md +1 -1
  80. package/toc/README.md +1 -1
  81. package/types/cngx-ui-a11y.d.ts +20 -38
  82. package/types/cngx-ui-accordion.d.ts +46 -71
  83. package/types/cngx-ui-action-button.d.ts +113 -151
  84. package/types/cngx-ui-breadcrumb.d.ts +60 -85
  85. package/types/cngx-ui-chart-panel.d.ts +22 -40
  86. package/types/cngx-ui-collection.d.ts +30 -43
  87. package/types/cngx-ui-command-palette.d.ts +40 -64
  88. package/types/cngx-ui-context-menu.d.ts +109 -48
  89. package/types/cngx-ui-data-grid-accordion.d.ts +50 -75
  90. package/types/cngx-ui-empty-state.d.ts +18 -8
  91. package/types/cngx-ui-feedback.d.ts +275 -292
  92. package/types/cngx-ui-layout.d.ts +4 -12
  93. package/types/cngx-ui-mat-accordion.d.ts +5 -5
  94. package/types/cngx-ui-mat-paginator.d.ts +4 -10
  95. package/types/cngx-ui-mat-stepper.d.ts +5 -10
  96. package/types/cngx-ui-mat-tabs.d.ts +86 -89
  97. package/types/cngx-ui-nav-rail.d.ts +416 -0
  98. package/types/cngx-ui-overlay.d.ts +4 -13
  99. package/types/cngx-ui-paginator.d.ts +186 -161
  100. package/types/cngx-ui-sidenav.d.ts +557 -437
  101. package/types/cngx-ui-skeleton.d.ts +7 -13
  102. package/types/cngx-ui-speak.d.ts +40 -24
  103. package/types/cngx-ui-stat-card.d.ts +45 -36
  104. package/types/cngx-ui-stepper.d.ts +205 -84
  105. package/types/cngx-ui-tabs.d.ts +104 -28
  106. package/types/cngx-ui-timeline.d.ts +31 -51
  107. package/types/cngx-ui-toc.d.ts +43 -54
  108. package/types/cngx-ui.d.ts +1 -1
package/README.md CHANGED
@@ -161,30 +161,34 @@ element of your own lands in the body instead.
161
161
 
162
162
  ### CngxActionButton
163
163
 
164
- Action button molecule with built-in async status communication. Composes
165
- `CngxAsyncClick` internally, adding template projection for pending/succeeded/failed
166
- states, an `aria-live` region for screen reader announcements, optional toast
167
- integration, and a `state` property for downstream feedback consumers.
164
+ Action button organism with built-in async status communication, on the cngx
165
+ button core. `button[cngxActionButton]` sits on the native `<button>`: it
166
+ co-hosts `CngxAsyncClick` as a host directive, takes the `CngxButton` axes
167
+ (`variant` through the selector, `tone`, `size`) and `disabled` /
168
+ `disabledReason`, and adds status labels or templates, optional toast
169
+ integration and a `state` property for downstream feedback consumers. The
170
+ labels sit stacked in one cell, so the button keeps the width of its widest
171
+ label in every state.
168
172
 
169
173
  ```html
170
174
  <!-- Minimal -->
171
- <cngx-action-button [action]="save">Save</cngx-action-button>
175
+ <button cngxActionButton tone="primary" [action]="save">Save</button>
172
176
 
173
177
  <!-- With template slots -->
174
- <cngx-action-button [action]="save">
178
+ <button cngxActionButton [action]="save">
175
179
  Save
176
- <ng-template cngxPending><mat-spinner diameter="18" /> Saving...</ng-template>
180
+ <ng-template cngxPending>Saving...</ng-template>
177
181
  <ng-template cngxSucceeded>Saved!</ng-template>
178
- <ng-template cngxFailed let-err>{{ err }} -- retry?</ng-template>
179
- </cngx-action-button>
182
+ <ng-template cngxFailed let-err>{{ err }} - retry?</ng-template>
183
+ </button>
180
184
 
181
185
  <!-- With toast feedback -->
182
- <cngx-action-button [action]="save" toastSuccess="Saved" toastError="Save failed">
186
+ <button cngxActionButton [action]="save" toastSuccess="Saved" toastError="Save failed">
183
187
  Save
184
- </cngx-action-button>
188
+ </button>
185
189
 
186
190
  <!-- Downstream state binding -->
187
- <cngx-action-button [action]="save" #btn="cngxActionButton">Save</cngx-action-button>
191
+ <button cngxActionButton [action]="save" #btn="cngxActionButton">Save</button>
188
192
  <cngx-alert [state]="btn.state" severity="error" title="Details" />
189
193
  ```
190
194
 
@@ -192,51 +196,64 @@ integration, and a `state` property for downstream feedback consumers.
192
196
 
193
197
  | Input | Type | Default | Description |
194
198
  |-|-|-|-|
195
- | `action` | `AsyncAction` | required | Async action to execute on click |
199
+ | `action` | `AsyncAction` | required | Async action to execute on click (the host directive's `cngxAsyncClick`) |
196
200
  | `feedbackDuration` | `number` | `2000` | Duration in ms to show feedback state |
197
- | `enabled` | `boolean` | `true` | When `false`, clicks are ignored |
198
- | `type` | `'button' \| 'submit' \| 'reset'` | `'button'` | Button type attribute |
199
- | `variant` | `ActionButtonVariant` | `'primary'` | Visual variant (`'primary'`, `'secondary'`, `'ghost'`) |
200
- | `pendingLabel` | `string` | -- | Fallback text while pending (when no `cngxPending` template) |
201
- | `succeededLabel` | `string` | -- | Fallback text after success (when no `cngxSucceeded` template) |
202
- | `failedLabel` | `string` | -- | Fallback text after failure (when no `cngxFailed` template) |
203
- | `succeededAnnouncement` | `string` | -- | SR announcement on success (falls back to `succeededLabel`) |
204
- | `failedAnnouncement` | `string` | -- | SR announcement on failure (falls back to `failedLabel`) |
201
+ | `showDelay` | `number` | `CNGX_LOADING_CONFIG.showDelay` (120 ms) | Delay before the busy visual shows |
202
+ | `minDwell` | `number` | `CNGX_LOADING_CONFIG.minDwell` (400 ms) | Minimum time the busy visual stays once shown |
203
+ | `cngxActionButton` | `CngxButtonVariant` | `solid` | Emphasis, bound through the selector; falls through group and config |
204
+ | `tone` | `CngxButtonTone` | `neutral` | Intent |
205
+ | `size` | `CngxButtonSize` | `md` | Size; `md` is the form-control row |
206
+ | `disabled` | `boolean` | `false` | Rendered as `aria-disabled`; the button stays focusable, clicks are swallowed |
207
+ | `disabledReason` | `string` | -- | Referenced through `aria-describedby` while disabled |
208
+ | `cngxDescribedBy` | `string \| null` | `null` | Extra ids for `aria-describedby` |
209
+ | `type` | `'button' \| 'submit' \| 'reset'` | `'button'` | Native type |
210
+ | `pendingLabel` | `string` | -- | Text while pending (when no `cngxPending` template); shown after the show delay and held for the dwell past the run, so a fast run never flashes it; without one the idle label stays under the spinner |
211
+ | `succeededLabel` | `string` | -- | Text after success (when no `cngxSucceeded` template) |
212
+ | `failedLabel` | `string` | -- | Text after failure (when no `cngxFailed` template) |
213
+ | `succeededAnnouncement` | `string` | -- | SR announcement on success (falls back to the rendered result cell, then `succeededLabel`) |
214
+ | `failedAnnouncement` | `string` | -- | SR announcement on failure (falls back to the rendered result cell, then `failedLabel`) |
215
+ | `announce` | `'auto' \| 'always' \| 'never'` | `'auto'` | Speaks the outcome unless a shown toast already covers it; `'always'` also next to a toast, `'never'` never |
205
216
  | `externalState` | `CngxAsyncState<unknown>` | -- | External state override for visual status |
206
217
  | `toastSuccess` | `string` | -- | Toast message on success (requires `CngxToaster`) |
207
218
  | `toastError` | `string` | -- | Toast message on error (requires `CngxToaster`) |
208
219
  | `toastErrorDetail` | `boolean` | `false` | Append error message to error toast |
209
- | `toastSuccessDuration` | `number` | `3000` | Success toast duration in ms |
220
+ | `toastSuccessDuration` | `number` | `withToasts({ defaultDuration })`, else `5000` | Success toast duration in ms |
210
221
  | `toastErrorDuration` | `number \| 'persistent'` | `'persistent'` | Error toast duration |
211
222
 
212
223
  **State producer:** `readonly state: CngxAsyncState<unknown>` -- the effective
213
224
  lifecycle state (internal or external). Bind to any `[state]` consumer.
214
225
 
215
- **Toast integration:** When `toastSuccess` or `toastError` inputs are set and
216
- `CngxToaster` is provided (via `provideFeedback(withToasts())` or `provideToasts()`),
217
- toasts fire automatically on status transitions. If `CngxToaster` is not provided,
226
+ **Outputs:** `(settled)` from `CngxAsyncClick`, once per own run; `(outcome)`
227
+ from `CngxActionStatusBrain`, once per own settle and once per `[externalState]`
228
+ `success` / `error` edge.
229
+
230
+ **Toast integration:** The co-hosted `CngxActionToast` (also exported from
231
+ `@cngx/ui/action-button` for ejected hosts) owns the toast inputs. When
232
+ `toastSuccess` or `toastError` is set and `CngxToaster` is provided (via
233
+ `provideFeedback(withToasts())` or `provideToasts()`), it shows one toast per
234
+ own settle and per `[externalState]` edge. If `CngxToaster` is not provided,
218
235
  toast inputs are silently ignored. Do not combine with `[cngxToastOn]` on the same
219
236
  element -- a dev-mode warning is emitted if both are active.
220
237
 
221
238
  **Template directives:** `cngxPending`, `cngxSucceeded`, `cngxFailed` (project `<ng-template>` for each state)
222
239
 
223
- **CSS Classes:** `cngx-action-button`, `cngx-action-button--{variant}`
240
+ **CSS Classes:** `cngx-button`, `cngx-action-button`; `data-variant` / `data-tone` / `data-size` / `data-status` on the host
224
241
 
225
- **Selector:** `cngx-action-button` -- exportAs `"cngxActionButton"`
242
+ **Selector:** `button[cngxActionButton]` -- exportAs `"cngxActionButton"`
226
243
 
227
244
  ### CngxSidenav
228
245
 
229
246
  Declarative sidebar organism with dual-sidebar support, responsive mode
230
- switching, mini/rail mode, resize handle, and keyboard shortcut toggle.
247
+ switching, a collapsible rail (composed `CngxSidebar`), resize handle, and keyboard shortcut toggle.
231
248
 
232
249
  ```html
233
250
  <cngx-sidenav-layout>
234
251
  <cngx-sidenav position="start" [(opened)]="navOpen" mode="side"
235
252
  [resizable]="true" shortcut="mod+b" width="240px">
236
- <cngx-sidenav-header>Workspace</cngx-sidenav-header>
253
+ <cngx-nav-header>Workspace</cngx-nav-header>
237
254
  <a cngxNavLink [active]="true">Dashboard</a>
238
255
  <a cngxNavLink>Settings</a>
239
- <cngx-sidenav-footer>v1.0</cngx-sidenav-footer>
256
+ <cngx-nav-footer>v1.0</cngx-nav-footer>
240
257
  </cngx-sidenav>
241
258
  <cngx-sidenav-content>
242
259
  <router-outlet />
@@ -244,7 +261,7 @@ switching, mini/rail mode, resize handle, and keyboard shortcut toggle.
244
261
  </cngx-sidenav-layout>
245
262
  ```
246
263
 
247
- **Modes:** `'over'` (overlay + backdrop), `'push'` (pushes content), `'side'` (permanent), `'mini'` (collapsed rail, expands on hover)
264
+ **Modes:** `'auto'` (default; follows the layout width class), `'over'` (overlay + backdrop), `'side'` (docked; `[(collapsed)]` rests it as a rail that peeks on hover, or hides it with `collapsedAs="hidden"`)
248
265
 
249
266
  **CngxSidenav inputs:**
250
267
 
@@ -252,61 +269,78 @@ switching, mini/rail mode, resize handle, and keyboard shortcut toggle.
252
269
  |-|-|-|-|
253
270
  | `ariaLabel` | `string` | - | Accessible label for the complementary landmark |
254
271
  | `position` | `'start' \| 'end'` | `'start'` | Logical position (flips in RTL) |
255
- | `mode` | `SidenavMode` | `'over'` | Interaction mode |
256
- | `responsive` | `string` | - | CSS media query; matches = `'side'`, else falls back to `mode` |
272
+ | `mode` | `SidenavMode` | `'auto'` | Interaction mode |
257
273
  | `width` | `string` (model) | `'280px'` | Panel width, two-way `[(width)]` for resize |
258
- | `miniWidth` | `string` | `'56px'` | Collapsed rail width in mini mode |
259
- | `expandOnHover` | `boolean` | `true` | Expand mini rail on mouse hover |
274
+ | `miniWidth` | `string` | derived | Width of the collapsed rail; unbound, derived from the nav row tokens |
275
+ | `collapsed` | `boolean` (model) | `false` | Rest a docked rail collapsed, two-way `[(collapsed)]` |
276
+ | `collapsedAs` | `'rail' \| 'hidden'` | `'rail'` | How a collapsed rail rests |
277
+ | `expandOnHover` | `boolean` | `true` | Peek a collapsed rail on hover |
278
+ | `modality` | `'page' \| 'contained' \| 'none'` | `'page'` | How far an open overlay takes over the page |
279
+ | `tooltip` | `boolean` | config, else `true` | Label tooltip on the collapsed rail; unbound, `withNavRailTooltip` applies |
260
280
  | `resizable` | `boolean` | `false` | Show drag handle for user resize |
261
281
  | `minWidth` | `string` | `'120px'` | Min width constraint during resize |
262
282
  | `maxWidth` | `string` | `'600px'` | Max width constraint during resize |
263
283
  | `shortcut` | `string` | - | Keyboard shortcut, e.g. `'mod+b'` (`mod` = Cmd on Mac, Ctrl elsewhere) |
264
284
 
265
- **CngxSidenav signals:** `opened` (model), `expanded` (mini hover state), `effectiveMode`, `effectiveWidth`, `resizing`, `isOverlay`
266
- **Methods:** `open()`, `close()`, `toggle()`, `expand()`, `collapse()`
285
+ **CngxSidenav signals:** `opened` (model), `expanded` (full nav shown), `widthClass`, `effectiveMode`, `resizing`, `isOverlay`
286
+ **Methods:** `open()`, `close()`, `toggle()`
267
287
 
268
- **Slot components:** `CngxSidenavHeader`, `CngxSidenavFooter` (projected into named slots)
269
- **Layout:** `CngxSidenavLayout` (container, manages backdrop + scroll lock), `CngxSidenavContent` (main area)
288
+ **Slots:** `CngxNavHeader`, `CngxNavFooter` from `@cngx/common/interactive` (projected above and below the body; skinned by `cngx-nav.css`)
289
+ **Layout:** `CngxSidenavLayout` (container, width class, backdrop), `CngxSidenavContent` (main area)
270
290
 
271
291
  **CSS Custom Properties:**
272
292
 
273
293
  | Variable | Default | Description |
274
294
  |-|-|-|
275
295
  | `--cngx-sidenav-width` | `280px` | Panel width |
276
- | `--cngx-sidenav-mini-width` | `56px` | Mini mode rail width |
277
- | `--cngx-sidenav-bg` | M3 surface-container | Background |
278
- | `--cngx-sidenav-color` | M3 on-surface | Text color |
279
- | `--cngx-sidenav-border-color` | M3 outline-variant | Border color |
280
- | `--cngx-sidenav-padding` | density-dependent | Header/footer padding |
281
- | `--cngx-sidenav-header-bg` | M3 surface-container-low | Header background |
282
- | `--cngx-sidenav-footer-bg` | M3 surface-container-low | Footer background |
296
+ | `--cngx-sidenav-mini-width` | derived from the row tokens | Collapsed rail width |
297
+ | `--cngx-sidenav-bg` | `--cngx-color-surface` (Material bridge: surface-container) | Background |
298
+ | `--cngx-sidenav-color` | `--cngx-color-text` (Material bridge: on-surface) | Text color |
299
+ | `--cngx-sidenav-border-color` | `--cngx-color-border` (Material bridge: outline-variant) | Border color |
300
+ | `--cngx-sidenav-padding` | density-dependent | Header/footer block padding |
301
+ | `--cngx-sidenav-z-index` | `2` | Stacking of the rail over the content |
302
+ | `--cngx-sidenav-row-gap` | half of `--cngx-space-xs` (Material 3 bridge: `0`) | Gap between body rows |
303
+ | `--cngx-nav-header-bg` | M3 surface-container-low | Header background (nav atom token) |
304
+ | `--cngx-nav-footer-bg` | M3 surface-container-low | Footer background (nav atom token) |
283
305
  | `--cngx-sidenav-backdrop-bg` | M3 scrim | Backdrop color |
284
306
  | `--cngx-sidenav-backdrop-opacity` | `0.5` | Backdrop opacity |
285
307
  | `--cngx-sidenav-transition-duration` | `0.25s` | Animation duration |
286
308
  | `--cngx-sidenav-resize-handle-width` | `4px` | Resize handle hit area |
287
309
  | `--cngx-sidenav-resize-handle-color` | M3 primary | Handle highlight color |
288
- | `--cngx-sidenav-expanded-shadow` | `4px 0 12px rgba(0,0,0,0.1)` | Mini expanded shadow |
310
+ | `--cngx-sidenav-expanded-shadow` | 12px shadow toward the content, deeper in a dark scheme or island | Peek shadow |
311
+ | `--cngx-sidenav-overlay-shadow` | `--cngx-sidenav-expanded-shadow` (Material 3 bridge: level 1) | Open overlay shadow |
289
312
 
290
- **Nav link theming** (applied inside sidenavs via `sidenav.theme()`):
313
+ **Nav row theming** (links and `[cngxNavGroup]` heads inside `cngx-sidenav`; the state fills, indicator, inset and ring colours are SET on the `cngx-sidenav` host, `sidenav.theme()` maps them onto M3 roles):
291
314
 
292
315
  | Variable | Description |
293
316
  |-|-|
294
317
  | `--cngx-nav-link-color` | Default text color |
295
318
  | `--cngx-nav-link-hover-color` | Hover text color |
319
+ | `--cngx-nav-link-hover-bg` | Hover fill (primary 6 % over transparent) |
320
+ | `--cngx-nav-link-pressed-bg` | Pressed fill (primary 12 %) |
296
321
  | `--cngx-nav-link-active-color` | Active text color |
297
- | `--cngx-nav-link-active-bg` | Active background (M3 secondary-container) |
298
- | `--cngx-nav-link-radius` | Border radius (default 8px) |
299
- | `--cngx-nav-link-padding` | Padding (density-dependent) |
322
+ | `--cngx-nav-link-active-bg` | Active fill (primary 16 %; M3 secondary-container in the bridge) |
323
+ | `--cngx-nav-link-active-hover-bg` | Active row under the pointer (primary 22 %) |
324
+ | `--cngx-nav-link-active-indicator-color` | Inline-start bar on the active row (`--cngx-color-primary-text`; `transparent` in the M3 bridge) |
325
+ | `--cngx-nav-link-active-indicator-size` | Bar width (from `--cngx-space-xs`) |
326
+ | `--cngx-nav-link-active-indicator-inset` | Bar block inset (from `--cngx-space-sm`) |
327
+ | `--cngx-nav-link-inset` | Row inline inset from the rail edges (from `--cngx-space-xs`) |
328
+ | `--cngx-nav-link-focus-outline-color` | Outer focus ring (`--cngx-color-text`) |
329
+ | `--cngx-nav-link-focus-inner-color` | Inner focus ring (`--cngx-sidenav-bg`) |
330
+ | `--cngx-nav-link-radius` | Border radius (default 4px, 8px in the M3 bridge) |
331
+ | `--cngx-nav-link-padding` | Padding (from `--cngx-space-sm` / `--cngx-space-md`) |
300
332
 
301
333
  **Animated nav group expand/collapse:**
302
334
 
303
- Replace `@if` with the `.cngx-nav-group-content` wrapper for smooth height animation
304
- via the CSS `grid-template-rows: 0fr/1fr` trick (no `@angular/animations` needed):
335
+ Replace `@if` with a `[cngxNavGroupContent]` wrapper (`@cngx/common/interactive`) for
336
+ smooth height animation via the CSS `grid-template-rows: 0fr/1fr` trick (no
337
+ `@angular/animations` needed). The directive sets the `.cngx-nav-group-content` /
338
+ `--open` classes and makes the region `inert` while the group is closed, so collapsed
339
+ links leave the tab order and the accessibility tree. Do not set the classes by hand:
305
340
 
306
341
  ```html
307
342
  <button cngxNavGroup #group="cngxNavGroup" [controls]="'items'">Settings</button>
308
- <div class="cngx-nav-group-content"
309
- [class.cngx-nav-group-content--open]="group.disclosure.opened()">
343
+ <div [cngxNavGroupContent]="group">
310
344
  <div id="items" role="group">
311
345
  <a cngxNavLink [depth]="1">General</a>
312
346
  <a cngxNavLink [depth]="1">Security</a>
@@ -316,6 +350,32 @@ via the CSS `grid-template-rows: 0fr/1fr` trick (no `@angular/animations` needed
316
350
 
317
351
  **Material theme:** `@use '@cngx/themes/material/sidenav-theme'` - includes nav-link theme automatically
318
352
 
353
+ ### CngxNavRail (`@cngx/ui/nav-rail`)
354
+
355
+ A narrow, always-collapsed column of nav rows for apps whose primary
356
+ navigation never expands. Reach for `CngxSidenav` when the same navigation
357
+ also opens to full width. The rows are the nav atoms of
358
+ `@cngx/common/interactive`; the rail only sets their tokens and its width.
359
+
360
+ ```html
361
+ <cngx-nav-rail labelPlacement="below">
362
+ <a cngxNavLink routerLink="/inbox">
363
+ <cngx-icon cngxNavIcon><mat-icon>inbox</mat-icon></cngx-icon>
364
+ Inbox
365
+ </a>
366
+ </cngx-nav-rail>
367
+ ```
368
+
369
+ **Inputs:** `labelPlacement` (`'end'`: icon only with a tooltip, default;
370
+ `'below'`: icon over a short label), `ariaLabel` (unbound, the `navRail`
371
+ language-pack copy names the landmark).
372
+ **Slots:** `cngx-nav-header` / `[cngxNavHeader]` above the rows,
373
+ `cngx-nav-footer` / `[cngxNavFooter]` below them.
374
+ A nav group opens as a flyout beside its head; `aria-expanded` stays the one
375
+ state. See `projects/ui/nav-rail/README.md`.
376
+
377
+ **Material theme:** `@use '@cngx/themes/material/nav-rail-theme'` - rail surface, flyout and the rows
378
+
319
379
  ### CngxToc (`@cngx/ui/toc`)
320
380
 
321
381
  "On this page" navigation rail. Renders a `<nav>` of anchor links from a
@@ -405,13 +465,13 @@ Three visibility modes:
405
465
 
406
466
  ```html
407
467
  <!-- Static -->
408
- <cngx-alert severity="warning" title="Unsaved changes" [closable]="true">
468
+ <cngx-alert severity="warning" title="Unsaved changes" [dismissible]="true">
409
469
  Your changes will be lost if you leave.
410
470
  <button cngxAlertAction (click)="save()">Save now</button>
411
471
  </cngx-alert>
412
472
 
413
473
  <!-- State-driven -->
414
- <cngx-alert [state]="saveState" severity="error" title="Save failed" [closable]="true">
474
+ <cngx-alert [state]="saveState" severity="error" title="Save failed" [dismissible]="true">
415
475
  {{ saveState.error() }}
416
476
  </cngx-alert>
417
477
 
@@ -433,8 +493,7 @@ Three visibility modes:
433
493
  |-|-|-|-|
434
494
  | `severity` | `AlertSeverity` | `'info'` | Visual style + ARIA role |
435
495
  | `title` | `string` | -- | Bold title above content |
436
- | `closable` | `boolean` | `false` | Show dismiss button |
437
- | `dismissible` | `boolean` | `false` | Deprecated alias for `closable` |
496
+ | `dismissible` | `boolean` | `false` | Show dismiss button |
438
497
  | `state` | `CngxAsyncState<unknown>` | -- | State-driven visibility |
439
498
  | `when` | `boolean` | -- | Boolean visibility trigger |
440
499
  | `autoDismissDelay` | `number` | `5000` | Auto-dismiss delay for success state (ms) |
@@ -1,96 +1,213 @@
1
1
  # CngxActionButton
2
2
 
3
- Action button molecule combining async state tracking, visual feedback, and optional toast notifications.
3
+ A `cngxButton` that runs an async action and reports the outcome in its own label, in a live
4
+ region and, optionally, in a toast. Sits on the native `<button>`.
4
5
 
5
6
  ## Import
6
7
 
7
8
  ```typescript
8
- import { CngxActionButton } from '@cngx/ui';
9
+ import { CngxActionButton } from '@cngx/ui/action-button';
10
+ // Template slots for the status cells
11
+ import { CngxFailed, CngxPending, CngxSucceeded } from '@cngx/common/interactive';
9
12
  ```
10
13
 
11
14
  ## Quick Start
12
15
 
13
16
  ```typescript
14
- import { Component } from '@angular/core';
15
- import { CngxActionButton } from '@cngx/ui';
17
+ import { HttpClient } from '@angular/common/http';
18
+ import { Component, inject } from '@angular/core';
19
+ import { CngxActionButton } from '@cngx/ui/action-button';
16
20
 
17
21
  @Component({
18
22
  selector: 'app-example',
19
- template: ` <cngx-action-button [action]="save"> Save Draft </cngx-action-button> `,
23
+ template: `
24
+ <button cngxActionButton tone="primary" [action]="save" pendingLabel="Saving..." succeededLabel="Saved">
25
+ Save Draft
26
+ </button>
27
+ `,
20
28
  imports: [CngxActionButton],
21
29
  })
22
30
  export class ExampleComponent {
31
+ private readonly http = inject(HttpClient);
32
+
23
33
  save = () => this.http.post('/api/draft', {});
24
34
  }
25
35
  ```
26
36
 
27
- ## Overview
37
+ ## When to use it
38
+
39
+ `cngxButton` with `[cngxAsyncClick]` already gets the busy layer, `aria-busy`, the click guard
40
+ and a generic announcement ("Action succeeded"). Its label stays as written unless you switch
41
+ on `btn.status()` yourself.
42
+
43
+ Use `cngxActionButton` when the label itself should report the outcome, when the announcement
44
+ should say what the button shows, when the button reflects a run it does not own, or when the
45
+ outcome raises a toast.
46
+
47
+ Variant, tone, size, `disabled` with a reason and the busy layer work as on `cngxButton`, see
48
+ [`@cngx/common/button`](../../common/button/README.md) and
49
+ [Gated surfaces](../../../core-concepts/async-state-machine.md#gated-surfaces).
50
+
51
+ ## What the user sees
52
+
53
+ The idle content and the status labels sit stacked in one cell. Only the active one is visible
54
+ and names the button, so the button is as wide as its widest label and never jumps after a run.
55
+ A `cngxFailed` template that renders the error text is the exception: that text is unknown until
56
+ the run fails, so the button grows when it shows.
57
+
58
+ 1. Click: the action starts, and `aria-busy`, `aria-disabled` and the click guard are set.
59
+ 2. After `showDelay` (120 ms by default) the pending label replaces the idle label. Without
60
+ one, the spinner covers the idle label. The busy visual stays for at least `minDwell`
61
+ (400 ms).
62
+ 3. The run settles. Once the busy visual releases, the success or failure label shows and
63
+ `aria-busy`, `aria-disabled` and the guard clear. A run faster than `showDelay` shows no
64
+ busy visual and goes from the idle label straight to the result.
65
+ 4. `feedbackDuration` (2000 ms) after the release, the idle label returns.
66
+
67
+ A state without a label or template keeps the idle label. The English language pack ships
68
+ empty status labels, so a button without labels, templates or app-wide defaults never changes
69
+ its visible label: only the live region reports the outcome.
70
+
71
+ A projected template beats a bound label, and a bound `''` switches a cell off. App-wide
72
+ defaults go through `provideActionStatusConfig(withActionStatusLabels({ ... }))`; the full order and
73
+ app-wide templates are documented on `CngxActionStatusBrain`.
74
+
75
+ ```html
76
+ <button cngxActionButton [action]="save" pendingLabel="Saving...">
77
+ Save draft
78
+ <ng-template cngxSucceeded>Saved</ng-template>
79
+ <ng-template cngxFailed let-err>{{ err }}, retry?</ng-template>
80
+ </button>
81
+ ```
28
82
 
29
- `CngxActionButton` is a molecule wrapping the `CngxAsyncClick` directive with built-in state communication, template slots, and optional toast integration. It uses `display: contents` - the host produces no DOM box; the inner `<button>` carries the directive directly.
83
+ ## Accessibility
30
84
 
31
- The component supports three visual feedback pathways:
85
+ The visible label is the accessible name; inactive labels are `aria-hidden`. `Enter` and
86
+ `Space` run the action, focus stays on the button.
32
87
 
33
- 1. **Fallback labels** - `pendingLabel`, `succeededLabel`, `failedLabel` strings
34
- 2. **Template slots** - `cngxPending`, `cngxSucceeded`, `cngxFailed` directives
35
- 3. **Automatic state prop** - bind `btn.state` to any state consumer
88
+ Each outcome is written once to the live region `cngxAsyncClick` renders next to the button,
89
+ right after the settle and not held by the dwell. The text matches what the button shows:
36
90
 
37
- A screen-reader-only `aria-live` region announces state transitions without visual noise.
91
+ 1. `succeededAnnouncement` / `failedAnnouncement`
92
+ 2. the text of the rendered result cell (template or label)
93
+ 3. the language pack: "Action succeeded" / "Action failed" in English
38
94
 
39
- ## Accessibility
95
+ `announce` decides whether the region speaks:
40
96
 
41
- - **ARIA roles:** The inner `<button>` carries all ARIA attributes from `CngxAsyncClick` - `aria-busy` when pending, no explicit role (semantic `<button>`).
42
- - **Keyboard interaction:**
43
- - `Enter` / `Space` - Activate the action
44
- - `Escape` - No special behavior (standard button)
45
- - **Screen reader:** `aria-live="polite"` region announces state transitions: "Action succeeded", "Action failed", and the optional custom announcements via `succeededAnnouncement` / `failedAnnouncement`.
46
- - **Focus management:** Focus remains on the button throughout the lifecycle - no focus trap or restoration.
97
+ - `'auto'` (default): every outcome, except one a shown toast already announces
98
+ - `'always'`: every outcome, also next to a toast
99
+ - `'never'`: nothing. The region stays in the DOM but gets no text; drive your own from
100
+ `(settled)` or `(outcome)`.
47
101
 
48
- ## Composition
102
+ ## Toasts
49
103
 
50
- `CngxActionButton` is built from these atomic units and integrates with:
104
+ `CngxActionToast` is co-hosted. Bind `toastSuccess`, `toastError` or both, and provide a
105
+ `CngxToaster` with `provideFeedback(withToasts())` or `provideToasts()`. Without a toaster the
106
+ toast inputs do nothing.
51
107
 
52
- - **Host directives:** Applies `CngxAsyncClick` directly on the inner `<button>` (not exposed as hostDirective).
53
- - **Combines with:** `CngxPending`, `CngxSucceeded`, `CngxFailed` template marker directives; `CngxToaster` for toast integration.
54
- - **Provides:** The `state` signal export for binding to any async state consumer.
108
+ ```html
109
+ <button cngxActionButton [action]="save" toastSuccess="Draft saved" toastError="Could not save">
110
+ Save
111
+ </button>
112
+ ```
55
113
 
56
- ### Example: Composition Pattern
114
+ Each outcome raises one toast. A toasted outcome is not spoken by the region as well, so a
115
+ button with only `toastError` still speaks its successes. Do not add `[cngxToastOn]` to the
116
+ same button; it toasts the same outcome again
117
+ ([`CNGX3008`](../../../core-concepts/error-codes/cngx3008.md)). Durations and the error detail
118
+ are documented on the toast inputs.
57
119
 
58
- ```typescript
59
- // Bind button state to an alert
60
- <cngx-action-button #btn="cngxActionButton" [action]="save">
61
- Save
62
- </cngx-action-button>
63
- <cngx-alert [state]="btn.state" title="Save Status" />
120
+ ## External state
121
+
122
+ `[externalState]` takes a `CngxAsyncState` the button does not own, such as a form submit or a
123
+ query, and shows it as if it were its own run.
124
+
125
+ ```html
126
+ <button cngxActionButton [action]="save" [externalState]="submitState" succeededLabel="Sent">
127
+ Send
128
+ </button>
64
129
  ```
65
130
 
66
- ## Styling
131
+ Labels, the busy layer, `state`, `(outcome)` and the announcement follow the bound state, once
132
+ per `success` / `error` edge. While it is pending the button refuses clicks. Own runs are not
133
+ reflected or spoken while a state is bound.
67
134
 
68
- All colors and spacing use CSS Custom Properties with Material 3 defaults. Override at any scope:
135
+ ## State and outputs
69
136
 
70
- ```scss
71
- // Override defaults in your component or global styles
72
- :host {
73
- --cngx-action-btn-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
74
- --cngx-action-btn-radius: 8px;
75
- --cngx-action-btn-primary-bg: #1565c0;
76
- --cngx-action-btn-primary-color: #fff;
77
- }
137
+ |Member|What it carries|
138
+ |-|-|
139
+ |`state`|`CngxAsyncState` of the effective run, for any `[state]` consumer|
140
+ |`state.lastUpdated`|Time of the last successful own run; with `[externalState]` bound, that state's value, with no fall back to own runs|
141
+ |`status()`|Effective status, immediate (not gated by the busy visual)|
142
+ |`busyVisible()`|`true` while the spinner or pending label shows|
143
+ |`(settled)`|Once per own run, with a monotonic `generation`|
144
+ |`(outcome)`|Once per own settle and once per `[externalState]` `success` / `error` edge|
145
+
146
+ ```html
147
+ <button cngxActionButton #btn="cngxActionButton" [action]="save">Save</button>
148
+ <cngx-alert [state]="btn.state" title="Save status" />
78
149
  ```
79
150
 
80
- ## Material Theme
151
+ ## Inputs
152
+
153
+ The button declares no input of its own. Each one is forwarded to a host directive.
154
+
155
+ |Input|Forwarded to|Default|
156
+ |-|-|-|
157
+ |`cngxActionButton` (variant), `tone`, `size`, `disabled`, `disabledReason`, `cngxDescribedBy`, `type`|`CngxButtonBrain`|as on `cngxButton`, variant `solid`|
158
+ |`action`|`CngxAsyncClick` (`cngxAsyncClick`)|required|
159
+ |`feedbackDuration`|`CngxAsyncClick`|`2000` ms|
160
+ |`showDelay`, `minDwell`|`CngxAsyncClick`|`CNGX_LOADING_CONFIG` (120 / 400 ms)|
161
+ |`pendingLabel`, `succeededLabel`, `failedLabel`|`CngxActionStatusBrain`|app-wide label, else the language pack (empty in English)|
162
+ |`succeededAnnouncement`, `failedAnnouncement`|`CngxActionStatusBrain`|the rendered result cell|
163
+ |`announce`|`CngxActionStatusBrain`|`'auto'`|
164
+ |`externalState`|`CngxActionStatusBrain`|unbound (own runs)|
165
+ |`toastSuccess`, `toastError`|`CngxActionToast`|no toast|
166
+ |`toastErrorDetail`|`CngxActionToast`|`false`|
167
+ |`toastSuccessDuration`|`CngxActionToast`|`withToasts({ defaultDuration })`, else `5000` ms|
168
+ |`toastErrorDuration`|`CngxActionToast`|`'persistent'`|
81
169
 
82
- To apply Material Design 3 theme colors, include the theme SCSS in your global stylesheet:
170
+ ## Composition
83
171
 
84
- ```scss
85
- @use '@angular/material' as mat;
86
- @use '@cngx/themes/material/action-button-theme' as action-btn;
172
+ The component is skin: template, stylesheet, `provideButtonHost()` and
173
+ `provideActionStatusHost()`. Four host directives do the work:
87
174
 
88
- $theme: mat.define-theme((...));
175
+ - `CngxButtonBrain` (`@cngx/common/button`): the button axes and the disabled contract
176
+ - `CngxAsyncClick` (`@cngx/common/interactive`): the run, the busy gate and the live region
177
+ - `CngxActionStatusBrain` (`@cngx/common/interactive`): status, label cells, the announcement
178
+ and `[externalState]`, read through `inject(CNGX_ACTION_STATUS)` on the button's injector
179
+ - `CngxActionToast` (this entry): the toasts
89
180
 
90
- html {
91
- @include mat.all-component-themes($theme);
92
- @include action-btn.theme($theme);
93
- }
94
- ```
181
+ For your own markup, list the same directives in `hostDirectives` (`CngxActionToast` only if
182
+ the host toasts), add the two providers and render the cells with `CngxActionStatusStack`. See
183
+ [Building a custom button host](../../common/button/README.md#building-a-custom-button-host) and
184
+ the ejected-host example (`/#/ui/action-button/async-button/ejected-host`).
185
+
186
+ ## Styling
95
187
 
96
- The theme mixin automatically derives success/error colors from Material's primary and error palettes. Both Material 3 (M3) and Material 2 (M2) are supported; colors adapt to the theme version automatically.
188
+ Box, paint, sizes and states come from the `cngxButton` sheet (`--cngx-button-*`). This entry
189
+ adds only the label stack. `cngxAsyncClick` still sets its `cngx-async--*` classes on the host,
190
+ but the `--cngx-async-*` tint skips `.cngx-button` hosts: the result shows as the label swap,
191
+ not as a colour.
192
+
193
+ ## Migrating from `<cngx-action-button>`
194
+
195
+ - `<cngx-action-button [action]="save">Save</cngx-action-button>` becomes
196
+ `<button cngxActionButton [action]="save">Save</button>`.
197
+ - `variant="primary" | "secondary" | "ghost"` and `ActionButtonVariant` are gone. Use
198
+ `tone="primary"` for the old filled default, `cngxActionButton="outline"` or `"ghost"` for the
199
+ others.
200
+ - `[enabled]="false"` becomes `[disabled]="true"`. `disabledReason` keeps working.
201
+ - The `--cngx-action-btn-*` colour, radius and padding tokens are gone. Theme the
202
+ `--cngx-button-*` tokens instead.
203
+ - The async state tokens moved to `@cngx/common` as `--cngx-async-*`:
204
+
205
+ |Old|New|
206
+ |-|-|
207
+ |`--cngx-action-btn-pending-opacity`|`--cngx-async-pending-opacity`|
208
+ |`--cngx-action-btn-transition`|`--cngx-async-transition`|
209
+ |`--cngx-action-btn-succeeded-{bg,color,border}`|`--cngx-async-success-{bg,color,border}`|
210
+ |`--cngx-action-btn-failed-{bg,color,border}`|`--cngx-async-error-{bg,color,border}`|
211
+
212
+ The colour tokens have no registered default. Unset, they follow `--cngx-color-success` /
213
+ `--cngx-color-danger` in both colour schemes.
@@ -44,8 +44,9 @@ track key (NG0955).
44
44
 
45
45
  Set `[maxVisible]` and the trail collapses its middle, keeping the first crumb
46
46
  and the last `maxVisible - 1`. When anything is collapsed the bar auto-renders
47
- a `<cngx-breadcrumb-overflow>` after the first crumb: an ellipsis trigger plus
48
- a `CngxPopoverPanel` hosting a `CngxMenu` of the collapsed crumbs. It reads the
47
+ a `<cngx-breadcrumb-overflow>` after the first crumb: an ellipsis
48
+ `cngxIconMenuButton` trigger plus a `CngxPopoverPanel` hosting a `CngxMenu` of
49
+ the collapsed crumbs. It reads the
49
50
  collapse set through the `CNGX_BREADCRUMB` DI contract and self-hides when
50
51
  nothing is collapsed.
51
52
 
@@ -224,8 +225,6 @@ config with `injectBreadcrumbConfig()` and the resolved labels with
224
225
  | `--cngx-breadcrumb-current-weight` | `600` | Terminal crumb font-weight |
225
226
  | `--cngx-breadcrumb-separator` | `'\203A'` (`'\2039'` under RTL) | Separator glyph in skin paint |
226
227
  | `--cngx-breadcrumb-separator-color` | `inherit` | Separator color |
227
- | `--cngx-breadcrumb-overflow-trigger-width` | `32px` | Ellipsis trigger width |
228
- | `--cngx-breadcrumb-overflow-trigger-height` | `26px` | Ellipsis trigger height |
229
228
  | `--cngx-breadcrumb-overflow-menu-min-width` | `11.875rem` | Collapsed-crumb menu min width |
230
229
  | `--cngx-breadcrumb-siblings-trigger-size` | `22px` | Chevron trigger box |
231
230
  | `--cngx-breadcrumb-siblings-menu-min-width` | `11.25rem` | Sibling list min width |
@@ -256,7 +255,7 @@ re-declared here.
256
255
 
257
256
  ## See Also
258
257
 
259
- - [CngxBreadcrumb / CngxBreadcrumbItem / CngxBreadcrumbSeparator](../../common/interactive/) - the headless trio for hand-composed trails
258
+ - [CngxBreadcrumb / CngxBreadcrumbItem / CngxBreadcrumbSeparator](../../common/interactive/breadcrumb/) - the headless trio for hand-composed trails
260
259
  - [CngxPopoverPanel](../../common/popover/) - the dropdown surface both menus render into
261
- - [API on compodocx](https://cngxjs.github.io/cngx/)
260
+ - [API on compodocx](https://cngxjs.github.io/cngx/main/ui/breadcrumb/)
262
261
  - Tests: `projects/ui/breadcrumb/breadcrumb-bar.component.spec.ts`, `breadcrumb-router-sync.directive.spec.ts`
@@ -169,5 +169,5 @@ error, and the retry button onto `--mat-sys-*`.
169
169
 
170
170
  - [CngxAsyncState](../../core/utils/) - async state contract
171
171
  - [CngxPaginate](../../common/data/paginate/) - the pagination brain
172
- - [API on compodocx](https://cngxjs.github.io/cngx/)
172
+ - [API on compodocx](https://cngxjs.github.io/cngx/main/ui/collection/)
173
173
  - Tests: `projects/ui/collection/incremental-list.component.spec.ts`