@cngx/common 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 (90) hide show
  1. package/a11y/README.md +15 -2
  2. package/button/README.md +258 -0
  3. package/command/README.md +42 -2
  4. package/data/README.md +15 -12
  5. package/fesm2022/cngx-common-a11y.mjs +1076 -319
  6. package/fesm2022/cngx-common-a11y.mjs.map +1 -1
  7. package/fesm2022/cngx-common-audio.mjs +99 -77
  8. package/fesm2022/cngx-common-audio.mjs.map +1 -1
  9. package/fesm2022/cngx-common-button.mjs +1084 -0
  10. package/fesm2022/cngx-common-button.mjs.map +1 -0
  11. package/fesm2022/cngx-common-card.mjs +138 -78
  12. package/fesm2022/cngx-common-card.mjs.map +1 -1
  13. package/fesm2022/cngx-common-chart.mjs +799 -327
  14. package/fesm2022/cngx-common-chart.mjs.map +1 -1
  15. package/fesm2022/cngx-common-command.mjs +101 -25
  16. package/fesm2022/cngx-common-command.mjs.map +1 -1
  17. package/fesm2022/cngx-common-data.mjs +861 -423
  18. package/fesm2022/cngx-common-data.mjs.map +1 -1
  19. package/fesm2022/cngx-common-dialog.mjs +198 -160
  20. package/fesm2022/cngx-common-dialog.mjs.map +1 -1
  21. package/fesm2022/cngx-common-display.mjs +693 -329
  22. package/fesm2022/cngx-common-display.mjs.map +1 -1
  23. package/fesm2022/cngx-common-interactive.mjs +7303 -2774
  24. package/fesm2022/cngx-common-interactive.mjs.map +1 -1
  25. package/fesm2022/cngx-common-layout.mjs +2174 -442
  26. package/fesm2022/cngx-common-layout.mjs.map +1 -1
  27. package/fesm2022/cngx-common-menu-button.mjs +557 -0
  28. package/fesm2022/cngx-common-menu-button.mjs.map +1 -0
  29. package/fesm2022/cngx-common-popover.mjs +2109 -557
  30. package/fesm2022/cngx-common-popover.mjs.map +1 -1
  31. package/fesm2022/cngx-common-stepper.mjs +548 -419
  32. package/fesm2022/cngx-common-stepper.mjs.map +1 -1
  33. package/fesm2022/cngx-common-tabs.mjs +442 -331
  34. package/fesm2022/cngx-common-tabs.mjs.map +1 -1
  35. package/fesm2022/cngx-common-timeline.mjs +44 -71
  36. package/fesm2022/cngx-common-timeline.mjs.map +1 -1
  37. package/fesm2022/cngx-common.mjs +10 -10
  38. package/fesm2022/cngx-common.mjs.map +1 -1
  39. package/interactive/README.md +30 -19
  40. package/layout/README.md +17 -1
  41. package/menu-button/README.md +234 -0
  42. package/package.json +31 -8
  43. package/popover/README.md +81 -4
  44. package/popover/tooltip-indicator.scss +52 -0
  45. package/schematics/collection.json +9 -0
  46. package/schematics/ng-add/index.js +9 -0
  47. package/schematics/ng-add/schema.json +96 -0
  48. package/schematics/package.json +3 -0
  49. package/stepper/README.md +5 -5
  50. package/theming/components/cngx-accordion.css +36 -7
  51. package/theming/components/cngx-async.css +185 -37
  52. package/theming/components/cngx-backdrop.css +3 -1
  53. package/theming/components/cngx-badge.css +20 -5
  54. package/theming/components/cngx-bottom-sheet.css +2 -0
  55. package/theming/components/cngx-breadcrumb.css +3 -1
  56. package/theming/components/cngx-button-group.css +325 -0
  57. package/theming/components/cngx-button-toggle.css +55 -23
  58. package/theming/components/cngx-button.css +975 -0
  59. package/theming/components/cngx-data-grid.css +2 -0
  60. package/theming/components/cngx-dialog.css +3 -1
  61. package/theming/components/cngx-divider.css +24 -9
  62. package/theming/components/cngx-drawer.css +153 -0
  63. package/theming/components/cngx-icon-glyph.css +76 -0
  64. package/theming/components/cngx-listbox.css +79 -25
  65. package/theming/components/cngx-menu.css +112 -52
  66. package/theming/components/cngx-nav.css +1220 -0
  67. package/theming/components/cngx-popover-sheet.css +434 -0
  68. package/theming/components/cngx-popover.css +37 -9
  69. package/theming/components/cngx-recycler-placeholder.css +2 -0
  70. package/theming/components/cngx-ripple.css +74 -16
  71. package/theming/components/cngx-sidebar.css +71 -0
  72. package/theming/components/cngx-slider.css +3 -1
  73. package/theming/components/cngx-tooltip.css +2 -0
  74. package/timeline/README.md +2 -2
  75. package/types/cngx-common-a11y.d.ts +488 -112
  76. package/types/cngx-common-audio.d.ts +60 -88
  77. package/types/cngx-common-button.d.ts +698 -0
  78. package/types/cngx-common-card.d.ts +104 -78
  79. package/types/cngx-common-chart.d.ts +677 -389
  80. package/types/cngx-common-command.d.ts +55 -41
  81. package/types/cngx-common-data.d.ts +506 -360
  82. package/types/cngx-common-dialog.d.ts +94 -127
  83. package/types/cngx-common-display.d.ts +475 -300
  84. package/types/cngx-common-interactive.d.ts +4383 -1721
  85. package/types/cngx-common-layout.d.ts +1399 -288
  86. package/types/cngx-common-menu-button.d.ts +382 -0
  87. package/types/cngx-common-popover.d.ts +990 -268
  88. package/types/cngx-common-stepper.d.ts +374 -465
  89. package/types/cngx-common-tabs.d.ts +309 -403
  90. package/types/cngx-common-timeline.d.ts +50 -109
package/a11y/README.md CHANGED
@@ -24,6 +24,8 @@ Implements the [WAI-ARIA roving tabindex](https://www.w3.org/WAI/ARIA/apg/practi
24
24
  | `End` | Jump to last enabled item |
25
25
  | `Tab` | Leave the group (standard tab order) |
26
26
 
27
+ Under a right-to-left document direction (`<html dir="rtl">`, or `provideDirection()`) the horizontal arrows flip: `ArrowLeft` moves to the next item, `ArrowRight` to the previous. `CngxActiveDescendant` follows the same rule.
28
+
27
29
  ### Notes
28
30
 
29
31
  - Disabled items are skipped during arrow-key navigation.
@@ -33,7 +35,7 @@ Implements the [WAI-ARIA roving tabindex](https://www.w3.org/WAI/ARIA/apg/practi
33
35
 
34
36
  ## CngxFocusRestore
35
37
 
36
- Captures the previously focused element on init and restores focus when the host is destroyed. Prevents focus from falling to `<body>` when dynamic content is removed.
38
+ Captures the previously focused element on init and restores focus when the host is destroyed while focus is inside it or on `<body>`; focus the user moved elsewhere stays put. Prevents focus from falling to `<body>` when dynamic content is removed.
37
39
 
38
40
  ```html
39
41
  @if (panelOpen()) {
@@ -71,4 +73,15 @@ Reactive autofocus for dynamically inserted elements. The native `autofocus` att
71
73
 
72
74
  ## Other Exports
73
75
 
74
- `CngxAriaExpanded`, `CngxFocusTrap`, `CngxFocusVisible`, `CngxLiveRegion`, `CngxReducedMotion`
76
+ | Export | Kind |
77
+ |-|-|
78
+ | `CngxAriaExpanded`, `CngxFocusTrap`, `CngxFocusVisible`, `CngxLiveRegion`, `CngxReducedMotion` | Directives |
79
+ | `CngxRovingItem` | Item marker for `CngxRovingTabindex` |
80
+ | `CngxActiveDescendant` | Directive: `aria-activedescendant` navigation for listbox-like hosts |
81
+ | `CngxLiveAnnouncer`, `AriaLivePoliteness` | Root service for imperative announcements, its politeness type |
82
+ | `injectScopedLiveRegion`, `CngxScopedLiveRegion`, `CngxPendingAnnouncement` | Live-region pair inside a host element (modal overlays) |
83
+ | `CNGX_FOCUSABLE_SELECTOR` | CSS selector of natively focusable elements |
84
+ | `CNGX_AD_ITEM`, `ActiveDescendantItem`, `CngxAdItemHandle` | Item registration token and shapes for `CngxActiveDescendant` |
85
+ | `CNGX_FOCUS_TRAP_DRIVER`, `CNGX_FOCUS_RESTORE_DRIVER`, `CNGX_ARIA_EXPANDED_DRIVER` (+ `Cngx*Driver` types) | Let a composing directive drive the host directive from its own state |
86
+
87
+ Details: [focus/README.md](focus/README.md), [aria/README.md](aria/README.md).
@@ -0,0 +1,258 @@
1
+ # @cngx/common/button
2
+
3
+ Buttons that sit on the native element. `cngxButton` and `cngxIconButton` are attribute
4
+ components on `<button>` and `<a>`, `cngxCloseButton` on `<button>`. Forms, `routerLink`, middle
5
+ click and every attribute you write keep working on the real element. No wrapper, no inner
6
+ button.
7
+
8
+ ## Quick Start
9
+
10
+ ```typescript
11
+ import { Component } from '@angular/core';
12
+ import { RouterLink } from '@angular/router';
13
+ import { CngxButton, CngxButtonStart, CngxIconButton } from '@cngx/common/button';
14
+ import { CngxAsyncClick } from '@cngx/common/interactive';
15
+
16
+ @Component({
17
+ selector: 'app-toolbar',
18
+ imports: [CngxButton, CngxButtonStart, CngxIconButton, CngxAsyncClick, RouterLink],
19
+ template: `
20
+ <button cngxButton tone="primary" [cngxAsyncClick]="save">
21
+ <svg cngxButtonStart aria-hidden="true" viewBox="0 0 24 24">...</svg>
22
+ Save
23
+ </button>
24
+ <button cngxButton="outline" type="submit">Submit</button>
25
+ <a cngxButton="link" routerLink="/help">Help</a>
26
+ <button cngxIconButton aria-label="Delete row" tone="danger" (click)="remove()">
27
+ <svg aria-hidden="true" viewBox="0 0 24 24">...</svg>
28
+ </button>
29
+ `,
30
+ })
31
+ export class AppToolbar {
32
+ readonly save = () => fetch('/api/drafts', { method: 'POST' });
33
+
34
+ remove(): void {
35
+ // delete the row
36
+ }
37
+ }
38
+ ```
39
+
40
+ ## Axes
41
+
42
+ | Axis | Values | Bound through | Default |
43
+ |-|-|-|-|
44
+ | `variant` | `solid`, `secondary`, `outline`, `ghost`, `link` | the selector value: `cngxButton="outline"`, `[cngxButton]="v()"` | `solid` (`ghost` on `cngxIconButton`) |
45
+ | `tone` | `neutral`, `primary`, `danger` | `tone` | `neutral` |
46
+ | `size` | `xs`, `sm`, `md`, `lg` | `size` | `md` |
47
+
48
+ Each axis resolves `input ?? fixed ?? group ?? config ?? default`:
49
+
50
+ 1. The input on the button.
51
+ 2. Axes the host pins through `provideButtonHost(..., { fixed })`. `cngxCloseButton` pins `ghost`,
52
+ `sm` and `neutral`.
53
+ 3. A surrounding `cngxButtonGroup`, for variant and size only. Tone is per button.
54
+ 4. `provideButtonConfigAt(...)` in a parent's `viewProviders`, merged over the outer config.
55
+ 5. `provideButtonConfig(...)` at the root.
56
+ 6. The host default.
57
+
58
+ `provideButtonConfig` takes `withButtonVariant`, `withButtonTone` and `withButtonSize`. Each
59
+ concern has one provider, and each works in `providers` and `viewProviders`:
60
+
61
+ | Concern | Provider |
62
+ |-|-|
63
+ | Variant, tone, size | `provideButtonConfig(...)` / `provideButtonConfigAt(...)` |
64
+ | Close glyph | `provideButtonCloseIcon(MyIcon)` |
65
+ | Busy glyph | `provideButtonSpinner(MySpinner)` |
66
+ | Status labels and templates | `provideActionStatusConfig(...)` / `provideActionStatusConfigAt(...)` in `@cngx/common/interactive` |
67
+
68
+ The menu-button caret and labels live in `@cngx/common/menu-button`.
69
+
70
+ Density, text scale, touch floor, motion and contrast are not inputs. They come from the
71
+ preference axes in `@cngx/core`. `md` is the form-control row, so an `md` button lines up with
72
+ `cngxInput` and every select trigger.
73
+
74
+ ## Accessibility
75
+
76
+ - `[disabled]` renders `aria-disabled="true"`, not the native attribute. The button stays in the
77
+ tab order and `disabledReason` is read through `aria-describedby`. Clicks, middle clicks,
78
+ `routerLink` navigation and form submission are swallowed. A disabled menu trigger opens on
79
+ neither click nor key, and an open menu closes when its trigger becomes disabled.
80
+ - A disabled `<a cngxButton>` keeps its `href`, so the context menu can still open it in a new
81
+ tab.
82
+ - The button merges every description source into one `aria-describedby`. A static attribute is
83
+ read once at creation, so bind ids that change at runtime through `[cngxDescribedBy]`, not
84
+ `[attr.aria-describedby]`.
85
+ - A `<button>` host defaults to `type="button"`, so it never submits a form by accident.
86
+ - `cngxIconButton` and `cngxCloseButton` need a name: `aria-label`, `aria-labelledby` or `title`.
87
+ Without one they warn [`CNGX1071`](../../../core-concepts/error-codes/cngx1071.md) in
88
+ development. Compose `[cngxTooltip]` where the glyph alone is ambiguous.
89
+ - Co-host `cngxAsyncClick` for an async action. The label keeps its place under a spinner that
90
+ appears after 120 ms and stays at least 400 ms (`showDelay` / `minDwell`, see
91
+ [Gated surfaces](../../../core-concepts/async-state-machine.md#gated-surfaces)). For the whole
92
+ dwell the button reads busy and refuses a second run. `provideButtonSpinner(MySpinner)` swaps
93
+ the ring in a subtree. Under reduced motion it stops turning.
94
+ - Every size floors to 44px on a coarse pointer, an icon button on both axes. The `link` variant
95
+ is the inline exception (WCAG 2.5.8).
96
+ - Under forced colors every variant re-signals with system colours. Disabled is `GrayText`.
97
+
98
+ ## Button group
99
+
100
+ `[cngxButtonGroup]` joins buttons, icon buttons, addons and separators into one framed row. The host is `role="group"` and needs a name: set `aria-label` or `aria-labelledby`, else it warns [`CNGX1072`](../../../core-concepts/error-codes/cngx1072.md) in development.
101
+
102
+ ```html
103
+ <div cngxButtonGroup variant="outline" aria-label="History">
104
+ <button cngxButton>Undo</button>
105
+ <button cngxButton>Redo</button>
106
+ </div>
107
+ ```
108
+
109
+ - **Orientation.** `orientation="horizontal"` is the default; `vertical` stacks the segments into a column.
110
+ - **Shared variant and size.** `variant` and `size` set on the group reach every `cngxButton` and `cngxIconButton` inside through `CNGX_BUTTON_GROUP`; a button's own input still wins (`input ?? group ?? config ?? default`). `tone` is not passed, intent is per button. A nested group without its own value inherits the outer group's.
111
+ - **Toolbar.** A group whose direct children are groups is a toolbar: the sub-groups sit apart, the gap floored to `--cngx-target-gap` on a coarse pointer. One group child is enough, so a loose button next to sub-groups gets no segment geometry; wrap it in a group of its own.
112
+ - **Separator.** `cngxButtonGroupSeparator` draws a divider that follows the orientation. It is decorative (`aria-hidden="true"`); when the split carries meaning, use two labelled groups.
113
+ - **Addon.** `cngxButtonGroupAddon` gives non-interactive content (an avatar, an icon, a count, a short status) a segment of the group's size. It adds no role; its text is read in document order between the buttons. Its media is capped to `--cngx-button-group-addon-media-size` (`1lh` of the addon), so a 24px avatar never stretches a 20px-line row.
114
+ - **Geometry.** The segment geometry (collapsed seams, outer radius only, lifted hover and focus) ships in the `cngx.css` bundle (`cngx-button-group.css`), not on the directive.
115
+ - **Selection** is not the group's job; use `CngxButtonToggleGroup` from `@cngx/common/interactive` for pressed state.
116
+
117
+ ## Close button
118
+
119
+ `button[cngxCloseButton]` is the icon button with the cngx X glyph, used by alerts, toasts,
120
+ banners and the popover panel. Name what it closes, not the affordance. A bare "Close" reads the
121
+ same for every dismiss target on the page.
122
+
123
+ ```html
124
+ <button cngxCloseButton aria-label="Close settings dialog" (click)="close()"></button>
125
+ ```
126
+
127
+ It stays `ghost`, `sm` and `neutral` inside a group and under any button config, so an app
128
+ default never makes a dismiss loud. Set `cngxCloseButton="outline"`, `size` or `tone` per
129
+ instance. Project a glyph to replace the X, or swap it for a subtree with
130
+ `provideButtonCloseIcon(MyIcon)`. `provideFeedback(withCloseIcon(...))` in `@cngx/ui/feedback`
131
+ forwards to it. `--cngx-close-button-size` and `--cngx-close-button-icon-size` size the box and
132
+ the glyph.
133
+
134
+ Migrating from `<cngx-close-button label="...">` in `@cngx/common/interactive`: write
135
+ `<button cngxCloseButton aria-label="...">` and drop `.cngx-close-button__btn` from selectors.
136
+ `--cngx-close-button-padding`, `-focus-outline`, `-focus-offset`, `-bg`, `-border` and
137
+ `-transition` are gone. The button tokens and the global focus ring take over.
138
+
139
+ ## Opening a menu
140
+
141
+ Use `button[cngxMenuButton]` from [`@cngx/common/menu-button`](../menu-button/README.md), not
142
+ `cngxMenuTrigger` and `cngxPopoverTrigger` hand-wired onto a `cngxButton`. It sits on the same
143
+ brain and adds the caret:
144
+
145
+ ```html
146
+ <button cngxMenuButton="outline" [menu]="menu" [popover]="pop">Export</button>
147
+ ```
148
+
149
+ [Choosing a Trigger](../../../core-concepts/choosing-a-trigger.md) compares action button, menu
150
+ button, split button, select, disclosure and toggle group.
151
+
152
+ ## Composition
153
+
154
+ - `CngxButtonStart` / `CngxButtonEnd` mark projected icons, badges or `<kbd>` hints. They are
155
+ sized in `em` and trim the padding on their side. An `svg` or `img` in a slot, or inside the
156
+ marked element, is sized to `--cngx-button-icon-size` (`1.25em`, the `cngx-icon` `md` rung).
157
+ - Icon fonts ignore the slot size: `.material-icons` and `<mat-icon>` stay at 24px. Wrap the
158
+ glyph in `<cngx-icon cngxButtonStart>`. Under the Material icon bridge
159
+ (`@cngx/themes/material/icon-theme`) a wrapped `<mat-icon>` takes the rung size. Without it,
160
+ use `<mat-icon inline>`, or `font-size: inherit` on a plain icon-font span.
161
+ - The pressed state is built in on `:active`, never on a disabled or busy button. `:active` lags
162
+ on touch and iOS Safari fires it only with a touch listener, so co-host `cngxPressable`
163
+ (`@cngx/common/interactive`) where it matters. The button paints its `.cngx-pressed` class the
164
+ same way.
165
+ - The ripple is opt-in: co-host `cngxRipple` (`@cngx/common/interactive`), with
166
+ `[rippleCentered]="true"` on an icon button. Under the Material bridge a cngx button ripples
167
+ only with the directive. The wave is off under `prefers-reduced-motion: reduce`.
168
+
169
+ ## Building a custom button host
170
+
171
+ Every cngx button renders on one host directive, `CngxButtonBrain`. It owns the axes, the ARIA,
172
+ the activation guard and the busy state. Your host declares it in `hostDirectives`, forwards the
173
+ inputs it wants to expose and names itself with `provideButtonHost`. Without `provideButtonHost`
174
+ the brain throws [`CNGX1075`](../../../core-concepts/error-codes/cngx1075.md).
175
+
176
+ ```typescript
177
+ import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
178
+ import { CngxButtonBrain, provideButtonHost } from '@cngx/common/button';
179
+
180
+ @Component({
181
+ selector: 'button[appChipButton]',
182
+ changeDetection: ChangeDetectionStrategy.OnPush,
183
+ hostDirectives: [
184
+ {
185
+ directive: CngxButtonBrain,
186
+ inputs: ['variant: appChipButton', 'tone', 'size', 'disabled', 'disabledReason', 'cngxDescribedBy', 'type'],
187
+ },
188
+ ],
189
+ providers: [provideButtonHost('appChipButton', { defaultVariant: 'outline' })],
190
+ host: { class: 'app-chip-button' },
191
+ template: `
192
+ <ng-content />
193
+ @if (brain.busyVisible()) {
194
+ <span class="app-chip-button__busy" aria-hidden="true"></span>
195
+ }
196
+ @if (brain.disabledReason(); as reason) {
197
+ <span [id]="brain.reasonId" hidden>{{ reason }}</span>
198
+ }
199
+ `,
200
+ styleUrl: './chip-button.css',
201
+ })
202
+ export class AppChipButton {
203
+ protected readonly brain = inject(CngxButtonBrain);
204
+ }
205
+ ```
206
+
207
+ Forward only the brain inputs your host should take, and alias `variant` to the selector so
208
+ `appChipButton="solid"` works. `provideButtonHost(name, { defaultVariant, fixed, iconOnly })`
209
+ fills `CNGX_BUTTON_HOST`. `name` is what development diagnostics print, `fixed` pins axes against
210
+ the group and the config, `iconOnly: true` turns on the
211
+ [`CNGX1071`](../../../core-concepts/error-codes/cngx1071.md) name check.
212
+
213
+ To take the cngx paint instead of your own CSS, put `cngx-button` (plus `cngx-icon-button` for a
214
+ square box) in the host `class` and load `@cngx/themes/cngx.css`, or import
215
+ `@cngx/common/theming/components/cngx-button.css` after the foundation. Every axis, the states,
216
+ the busy fade and forced colors then follow the brain's attributes. Render the busy layer and the
217
+ reason span with `<cngx-button-adornment />` (`CngxButtonAdornment`): it shows the
218
+ `provideButtonSpinner` glyph while `brain.busyVisible()` and carries the span the brain's
219
+ `aria-describedby` points at.
220
+
221
+ ```typescript
222
+ @Component({
223
+ selector: 'button[appSaveButton]',
224
+ imports: [CngxButtonAdornment],
225
+ hostDirectives: [{ directive: CngxButtonBrain, inputs: ['variant: appSaveButton', 'disabled', 'disabledReason'] }],
226
+ providers: [provideButtonHost('appSaveButton', { defaultVariant: 'solid' })],
227
+ host: { class: 'cngx-button' },
228
+ template: `<span class="cngx-button__label"><ng-content /></span><cngx-button-adornment />`,
229
+ })
230
+ export class AppSaveButton {}
231
+ ```
232
+
233
+ A host with its own skin keeps its template, slots and CSS. It renders the busy layer while
234
+ `brain.busyVisible()`, with `brain.spinner` inside (the `provideButtonSpinner` glyph or `null`,
235
+ the same value `injectButtonSpinner()` returns), and the hidden reason span shown above. A
236
+ dismiss host reads its glyph through `injectButtonCloseIcon()`, a segment that sizes itself like
237
+ a button reads the scope's defaults through `injectButtonConfig()`.
238
+
239
+ The brain writes only attributes on the host element. Skin off these:
240
+
241
+ - `[data-variant]`, `[data-tone]`, `[data-size]`
242
+ - `[aria-disabled='true']`. The click guard runs in the capture phase, so this always means no
243
+ activation, a co-located `RouterLink` included.
244
+ - `[data-pending]`, set when a run starts, before any delay. Paint the delay window off it.
245
+ - `[data-busy]`, set after `showDelay` and held for `minDwell`. Paint the shown-busy state off it.
246
+
247
+ Scope disabled rules to `:not([data-busy], [data-pending])` so a running button never paints
248
+ disabled.
249
+
250
+ A co-hosted `cngxAsyncClick` needs no wiring: the brain reads its run through
251
+ `CNGX_ASYNC_RUN_STATE` (`@cngx/common/interactive`). A host that refuses or runs on its own
252
+ provides `CNGX_BUTTON_HOST_STATE` with a `refusing` and an optional `busy` signal.
253
+
254
+ A host on `CngxActionStatusBrain` (`@cngx/common/interactive`) adds `provideActionStatusHost()`
255
+ next to `provideButtonHost`. `CngxActionButton` and `CngxPopoverAction` are built that way.
256
+
257
+ `CNGX_BUTTON_STATE` on the element injector exposes `blocked`, `busy` and `activeReasonId` to a
258
+ composing molecule. `cngxSplitButton` reads its main action through it.
package/command/README.md CHANGED
@@ -42,6 +42,29 @@ bootstrapApplication(AppComponent, {
42
42
  export class EditorView {}
43
43
  ```
44
44
 
45
+ A scoped call adds to the commands above it and never hides them. That holds
46
+ across both injector trees: a lazy route's `providers` and a shell component's
47
+ `viewProviders` around the `<router-outlet>` both reach the routed page, on top
48
+ of the root set.
49
+
50
+ ```typescript
51
+ // root: FILE_COMMANDS; route: REPORT_COMMANDS; shell: NAV_COMMANDS
52
+ { path: 'reports', providers: [provideCommands(REPORT_COMMANDS)], component: Reports }
53
+ // injectCommands() inside Reports -> FILE, REPORT, NAV
54
+ ```
55
+
56
+ Order is root and route scopes first (outer to inner), then component scopes
57
+ outer to inner, each in registration order. Registering the same source
58
+ reference at two levels lists it once. A `viewProviders` set stays invisible to
59
+ projected content, as for any `viewProviders` entry; use `providers` when
60
+ content children need it.
61
+
62
+ Command ids are unique in the merged list. A command whose `id` is already
63
+ registered further out replaces that command in place: the innermost scope (or,
64
+ on one level, the later registration) wins, and the entry keeps the position of
65
+ the first occurrence. Reuse an id on purpose to swap a global command for a
66
+ scoped version; give unrelated commands distinct ids.
67
+
45
68
  A source is either a static list or a reactive `Signal` - a signal source lets a
46
69
  contributor add, remove, or disable commands live:
47
70
 
@@ -53,6 +76,23 @@ provideCommands(commands); // injectCommands() tracks it
53
76
  commands.update((list) => [...list, publishCmd]);
54
77
  ```
55
78
 
79
+ When the source lives in a service, pass a factory. It runs once, in the
80
+ injection context of the level it is registered at, so it can call `inject()`:
81
+
82
+ ```typescript
83
+ { path: 'editor', providers: [provideCommands(() => inject(EditorStore).commands)] }
84
+ ```
85
+
86
+ Return the `Signal` itself to stay reactive. A factory that reads the signal
87
+ (`() => inject(EditorStore).commands()`) returns a plain array, and that array
88
+ is frozen at the first call.
89
+
90
+ A factory must not read the registry it contributes to. `injectCommands()`
91
+ inside it, or in a service it injects at the same level, resolves that level's
92
+ merged list while the factory is still building it, and Angular throws a
93
+ circular-dependency error (NG0200). Hand the factory the source, not the
94
+ merged result.
95
+
56
96
  ## Read Them
57
97
 
58
98
  ```typescript
@@ -147,9 +187,9 @@ slot overrides. See the live demos at `/ui/command-palette/basic` and
147
187
  | `CngxCommand` | interface | the command model |
148
188
  | `CommandGroup` | interface | a named cluster of commands |
149
189
  | `CngxCommandSource` | type | a static list or a `Signal` of commands |
150
- | `provideCommands(...sources)` | `Provider[]` | register sources at any injector scope |
190
+ | `CngxCommandSourceFactory` | type | `() => CngxCommandSource`, run once in the level's injection context |
191
+ | `provideCommands(...sources)` | `Provider[]` | register sources or source factories at any injector scope |
151
192
  | `injectCommands()` | `Signal<readonly CngxCommand[]>` | merged, `equal`-guarded registry |
152
- | `CNGX_COMMAND_SOURCE` | multi token | what `provideCommands` contributes to |
153
193
  | `createDefaultCommandMatcher()` | factory | the pure label/keyword ranker |
154
194
  | `CngxCommandMatcher` | type | `(commands, term, scope?) => RankedCommand[]` |
155
195
  | `RankedCommand` | interface | `{ command, score }` |
package/data/README.md CHANGED
@@ -227,10 +227,10 @@ protected handleSave(): void {
227
227
  ### Template with action button
228
228
 
229
229
  ```html
230
- <cngx-action-button [action]="handleSave" variant="primary"
230
+ <button cngxActionButton tone="primary" [action]="handleSave"
231
231
  pendingLabel="Saving..." succeededLabel="Saved">
232
232
  Save Resident
233
- </cngx-action-button>
233
+ </button>
234
234
  ```
235
235
 
236
236
  ### Template with manual status
@@ -510,9 +510,9 @@ the single source of truth - all signals are derived projections.
510
510
 
511
511
  ```typescript
512
512
  private readonly res = resource({
513
- request: () => ({ q: this.filter() }),
514
- loader: ({ request, abortSignal }) =>
515
- fetch(`/api/items?q=${request.q}`, { signal: abortSignal })
513
+ params: () => ({ q: this.filter() }),
514
+ loader: ({ params, abortSignal }) =>
515
+ fetch(`/api/items?q=${params.q}`, { signal: abortSignal })
516
516
  .then(r => r.json()),
517
517
  });
518
518
 
@@ -531,14 +531,17 @@ readonly items = fromResource(this.res);
531
531
 
532
532
  ## 5. fromHttpResource - Angular httpResource() Bridge
533
533
 
534
- Like `fromResource` but maps HTTP progress (0-1 float) to
535
- `CngxAsyncState.progress` (0-100 integer).
534
+ Like `fromResource` but maps the latest `HttpProgressEvent` to
535
+ `CngxAsyncState.progress` (0-100 integer, `loaded / total` rounded and
536
+ clamped; `undefined` while the total is unknown or zero). Angular only
537
+ emits progress events when the request sets `reportProgress: true`.
536
538
 
537
539
  ```typescript
538
540
  private readonly res = httpResource<Report>(() => ({
539
541
  url: '/api/reports/generate',
540
542
  method: 'POST',
541
543
  body: { params: this.reportParams() },
544
+ reportProgress: true,
542
545
  }));
543
546
 
544
547
  readonly report = fromHttpResource(this.res);
@@ -623,10 +626,10 @@ import { CngxEmptyState } from '@cngx/ui/empty-state';
623
626
  <header cngxCardHeader>{{ r.name }}</header>
624
627
  <div cngxCardBody>Room {{ r.room }}</div>
625
628
  <footer cngxCardFooter>
626
- <cngx-action-button [action]="makeDelete(r.id)"
627
- variant="ghost" pendingLabel="Deleting...">
629
+ <button cngxActionButton="ghost" [action]="makeDelete(r.id)"
630
+ pendingLabel="Deleting...">
628
631
  Delete
629
- </cngx-action-button>
632
+ </button>
630
633
  </footer>
631
634
  </cngx-card>
632
635
  }
@@ -898,13 +901,13 @@ handleUpload(files: File[]): void {
898
901
  | `[cngxFileDrop]` | `uploading`, `uploadProgress`, `uploadError`, blocks drop/browse |
899
902
  | `injectSmartDataSource` | `isLoading`, `isRefreshing`, `error`, `isEmpty`, `filteredCount` |
900
903
 
901
- The loading surfaces above (skeleton, overlay, async-container refresh bar, recycler skeleton) debounce their show/hide through the `CNGX_LOADING_CONFIG` cascade in `@cngx/core/utils`: `provideLoadingConfig(withShowDelay(...), withMinDwell(...))` suppresses the flash on fast operations app-wide, with per-instance `[delay]` / `[minDwell]` / `[skeletonDelay]` overrides. See the Async State Machine chapter for the full timing model.
904
+ The loading surfaces above (skeleton, overlay, async-container refresh bar, recycler skeleton) debounce their show/hide through the `CNGX_LOADING_CONFIG` cascade in `@cngx/core/utils`: `provideLoadingConfig(withShowDelay(...), withMinDwell(...))` suppresses the flash on fast operations app-wide, with per-instance `[delay]` / `[minDwell]` / `[showDelay]` overrides and the recycler's `skeletonDelay` / `skeletonMinDwell`. See the Async State Machine chapter for the full timing model.
902
905
 
903
906
  ## Latency probe
904
907
 
905
908
  `injectLatencyProbe()` measures how long the app's aggregate busy window lasted, so an app-shell indicator can pick spinner-vs-skeleton from observed latency before the next load renders.
906
909
 
907
- It bridges `CngxAsyncRegistry.isAnythingLoading` (see the async-registry section) into a `createLatencyProbe` from `@cngx/core/utils`:
910
+ It bridges `CngxAsyncRegistry.isAnythingLoading` (see [Opt-in async observability](../../../core-concepts/store-bridges-and-observability.md#opt-in-async-observability)) into a `createLatencyProbe` from `@cngx/core/utils`:
908
911
 
909
912
  ```typescript
910
913
  const probe = injectLatencyProbe();