@cngx/ui 0.1.0-rc.6 → 0.1.0-rc.8
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/README.md +112 -1
- package/a11y/README.md +87 -0
- package/accordion/README.md +4 -2
- package/breadcrumb/README.md +262 -0
- package/collection/README.md +6 -0
- package/command-palette/README.md +224 -0
- package/context-menu/README.md +98 -0
- package/data-grid-accordion/README.md +103 -2
- package/feedback/README.md +42 -0
- package/fesm2022/cngx-ui-a11y.mjs +452 -0
- package/fesm2022/cngx-ui-a11y.mjs.map +1 -0
- package/fesm2022/cngx-ui-accordion.mjs +116 -38
- package/fesm2022/cngx-ui-accordion.mjs.map +1 -1
- package/fesm2022/cngx-ui-action-button.mjs +115 -50
- package/fesm2022/cngx-ui-action-button.mjs.map +1 -1
- package/fesm2022/cngx-ui-breadcrumb.mjs +181 -96
- package/fesm2022/cngx-ui-breadcrumb.mjs.map +1 -1
- package/fesm2022/cngx-ui-chart-panel.mjs +586 -0
- package/fesm2022/cngx-ui-chart-panel.mjs.map +1 -0
- package/fesm2022/cngx-ui-collection.mjs +207 -66
- package/fesm2022/cngx-ui-collection.mjs.map +1 -1
- package/fesm2022/cngx-ui-command-palette.mjs +1281 -0
- package/fesm2022/cngx-ui-command-palette.mjs.map +1 -0
- package/fesm2022/cngx-ui-context-menu.mjs +857 -0
- package/fesm2022/cngx-ui-context-menu.mjs.map +1 -0
- package/fesm2022/cngx-ui-data-grid-accordion.mjs +498 -111
- package/fesm2022/cngx-ui-data-grid-accordion.mjs.map +1 -1
- package/fesm2022/cngx-ui-empty-state.mjs +16 -6
- package/fesm2022/cngx-ui-empty-state.mjs.map +1 -1
- package/fesm2022/cngx-ui-feedback.mjs +1095 -521
- package/fesm2022/cngx-ui-feedback.mjs.map +1 -1
- package/fesm2022/cngx-ui-layout.mjs +18 -9
- package/fesm2022/cngx-ui-layout.mjs.map +1 -1
- package/fesm2022/cngx-ui-mat-accordion.mjs +84 -16
- package/fesm2022/cngx-ui-mat-accordion.mjs.map +1 -1
- package/fesm2022/cngx-ui-mat-paginator.mjs +67 -24
- package/fesm2022/cngx-ui-mat-paginator.mjs.map +1 -1
- package/fesm2022/cngx-ui-mat-stepper.mjs +72 -47
- package/fesm2022/cngx-ui-mat-stepper.mjs.map +1 -1
- package/fesm2022/cngx-ui-mat-tabs.mjs +370 -203
- package/fesm2022/cngx-ui-mat-tabs.mjs.map +1 -1
- package/fesm2022/cngx-ui-overlay.mjs +69 -13
- package/fesm2022/cngx-ui-overlay.mjs.map +1 -1
- package/fesm2022/cngx-ui-paginator.mjs +501 -182
- package/fesm2022/cngx-ui-paginator.mjs.map +1 -1
- package/fesm2022/cngx-ui-sidenav.mjs +327 -106
- package/fesm2022/cngx-ui-sidenav.mjs.map +1 -1
- package/fesm2022/cngx-ui-skeleton.mjs +22 -21
- package/fesm2022/cngx-ui-skeleton.mjs.map +1 -1
- package/fesm2022/cngx-ui-speak.mjs +107 -8
- package/fesm2022/cngx-ui-speak.mjs.map +1 -1
- package/fesm2022/cngx-ui-stat-card.mjs +718 -0
- package/fesm2022/cngx-ui-stat-card.mjs.map +1 -0
- package/fesm2022/cngx-ui-stepper.mjs +217 -76
- package/fesm2022/cngx-ui-stepper.mjs.map +1 -1
- package/fesm2022/cngx-ui-tabs.mjs +40 -19
- package/fesm2022/cngx-ui-tabs.mjs.map +1 -1
- package/fesm2022/cngx-ui-timeline.mjs +548 -0
- package/fesm2022/cngx-ui-timeline.mjs.map +1 -0
- package/fesm2022/cngx-ui-toc.mjs +748 -0
- package/fesm2022/cngx-ui-toc.mjs.map +1 -0
- package/fesm2022/cngx-ui.mjs +16 -21
- package/fesm2022/cngx-ui.mjs.map +1 -1
- package/mat-accordion/README.md +1 -1
- package/mat-paginator/README.md +9 -2
- package/mat-tabs/styles/mat-tabs.css +29 -27
- package/overlay/README.md +9 -4
- package/package.json +32 -1
- package/paginator/README.md +8 -4
- package/sidenav/README.md +33 -11
- package/skeleton/README.md +2 -0
- package/speak/README.md +3 -2
- package/stepper/README.md +15 -3
- package/timeline/README.md +350 -0
- package/toc/README.md +186 -0
- package/types/cngx-ui-a11y.d.ts +394 -0
- package/types/cngx-ui-accordion.d.ts +100 -30
- package/types/cngx-ui-action-button.d.ts +47 -3
- package/types/cngx-ui-breadcrumb.d.ts +159 -58
- package/types/cngx-ui-chart-panel.d.ts +382 -0
- package/types/cngx-ui-collection.d.ts +159 -58
- package/types/cngx-ui-command-palette.d.ts +565 -0
- package/types/cngx-ui-context-menu.d.ts +559 -0
- package/types/cngx-ui-data-grid-accordion.d.ts +344 -51
- package/types/cngx-ui-empty-state.d.ts +9 -2
- package/types/cngx-ui-feedback.d.ts +664 -73
- package/types/cngx-ui-layout.d.ts +8 -3
- package/types/cngx-ui-mat-accordion.d.ts +32 -4
- package/types/cngx-ui-mat-paginator.d.ts +37 -8
- package/types/cngx-ui-mat-stepper.d.ts +23 -11
- package/types/cngx-ui-mat-tabs.d.ts +218 -23
- package/types/cngx-ui-overlay.d.ts +56 -10
- package/types/cngx-ui-paginator.d.ts +416 -132
- package/types/cngx-ui-sidenav.d.ts +248 -74
- package/types/cngx-ui-skeleton.d.ts +18 -7
- package/types/cngx-ui-speak.d.ts +118 -5
- package/types/cngx-ui-stat-card.d.ts +411 -0
- package/types/cngx-ui-stepper.d.ts +81 -29
- package/types/cngx-ui-tabs.d.ts +22 -6
- package/types/cngx-ui-timeline.d.ts +495 -0
- package/types/cngx-ui-toc.d.ts +581 -0
- package/types/cngx-ui.d.ts +8 -5
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
# CngxCommandPalette
|
|
2
|
+
|
|
3
|
+
The opinionated Cmd/Ctrl+K palette preset. Renders a search-driven command list
|
|
4
|
+
inside a native modal `<dialog cngxDialog>`, so focus trapping, trigger storage
|
|
5
|
+
at open and focus restore after the close transition come from `CngxDialog` and
|
|
6
|
+
the platform - no hand-rolled focus machinery. The body composes existing
|
|
7
|
+
atoms: `CngxSearch` (debounced term), `CngxListbox` + `CngxOption`
|
|
8
|
+
(active-descendant navigation), `CngxHighlight` (match marking). Commands are
|
|
9
|
+
data from `@cngx/common/command` (`provideCommands`); the palette commits no
|
|
10
|
+
form value - it fires `command.run()`, the locked demarcation from `CngxCombobox`.
|
|
11
|
+
|
|
12
|
+
## Import
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
import { CngxCommandPalette, CngxCommandPaletteTrigger } from '@cngx/ui/command-palette';
|
|
16
|
+
import { provideCommands } from '@cngx/common/command';
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { Component } from '@angular/core';
|
|
23
|
+
import { provideCommands } from '@cngx/common/command';
|
|
24
|
+
import { CngxCommandPalette, CngxCommandPaletteTrigger } from '@cngx/ui/command-palette';
|
|
25
|
+
|
|
26
|
+
@Component({
|
|
27
|
+
selector: 'app-example',
|
|
28
|
+
providers: [
|
|
29
|
+
provideCommands([
|
|
30
|
+
{ id: 'new-file', label: 'New file', run: () => void 0 },
|
|
31
|
+
{ id: 'toggle-theme', label: 'Toggle theme', group: 'View', run: () => void 0 },
|
|
32
|
+
]),
|
|
33
|
+
],
|
|
34
|
+
template: `
|
|
35
|
+
<button [cngxCommandPaletteTrigger]="palette">Search <kbd>Cmd K</kbd></button>
|
|
36
|
+
<cngx-command-palette #palette />
|
|
37
|
+
`,
|
|
38
|
+
imports: [CngxCommandPalette, CngxCommandPaletteTrigger],
|
|
39
|
+
})
|
|
40
|
+
export class ExampleComponent {}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Pressing Cmd/Ctrl+K anywhere opens the palette. Type to filter, arrows to
|
|
44
|
+
navigate, Enter runs the highlighted command and dismisses.
|
|
45
|
+
|
|
46
|
+
## Opening
|
|
47
|
+
|
|
48
|
+
The open combo resolves per instance `[openShortcut]` (parsed via
|
|
49
|
+
`parseKeyCombo`, e.g. `'mod+shift+p'`; changing it live re-installs the
|
|
50
|
+
listener), then `withPaletteShortcut(...)` from the config cascade, then the
|
|
51
|
+
`'mod+k'` default.
|
|
52
|
+
|
|
53
|
+
The global keydown listener is installed by a swappable factory,
|
|
54
|
+
`CNGX_PALETTE_KEYBINDING_FACTORY` (default `createPaletteKeybinding`). Override
|
|
55
|
+
the token to replace the whole listener - an enterprise key-capture policy, a
|
|
56
|
+
test double - without touching the palette. To only change the combo, use the
|
|
57
|
+
input or the config feature. On SSR the default factory is an inert no-op.
|
|
58
|
+
|
|
59
|
+
`[cngxCommandPaletteTrigger]` is the optional explicit trigger: opens on click,
|
|
60
|
+
sets `aria-haspopup="dialog"` and derives `aria-expanded` from the palette's
|
|
61
|
+
`isOpen()` signal. The palette is passed by template reference - orthogonal
|
|
62
|
+
composition, no ancestor injection. `open()` and `dismiss()` are public methods
|
|
63
|
+
for programmatic control.
|
|
64
|
+
|
|
65
|
+
## Commands and matching
|
|
66
|
+
|
|
67
|
+
The static registry is `provideCommands(...sources)` - each source an array or
|
|
68
|
+
a `Signal<readonly CngxCommand[]>`, merged reactively. A `CngxCommand` is pure
|
|
69
|
+
data plus `run()`: `id`, `label`, optional `keywords`, `group`, `icon`,
|
|
70
|
+
`disabled` (a `Signal<boolean>`), `disabledReason`, and an `unknown` `data`
|
|
71
|
+
payload the row slot narrows.
|
|
72
|
+
|
|
73
|
+
Ranking runs through the swappable `CNGX_COMMAND_MATCH_FACTORY`
|
|
74
|
+
(`@cngx/common/command`); results group by `command.group`, rank order
|
|
75
|
+
preserved. The two-way `[(scope)]` model feeds the matcher's scope filter and
|
|
76
|
+
renders as a chip in the input row.
|
|
77
|
+
|
|
78
|
+
A disabled command stays in the list and communicates its why: the default row
|
|
79
|
+
wires `aria-describedby` to a visually hidden node carrying `disabledReason`,
|
|
80
|
+
with the reference gated on the disabled state while the node itself stays in
|
|
81
|
+
the DOM.
|
|
82
|
+
|
|
83
|
+
## Async results
|
|
84
|
+
|
|
85
|
+
Bind `[results]` to a `CngxAsyncState<CngxCommandGroup[]>` (from
|
|
86
|
+
`createAsyncState`/`injectAsyncState`) and the palette merges consumer groups
|
|
87
|
+
above the ranked static registry. An internal shell maps the state through
|
|
88
|
+
`resolveAsyncView()`:
|
|
89
|
+
|
|
90
|
+
- first load renders the loading state; a first-load failure the error state
|
|
91
|
+
with a Retry button that emits `(retry)`;
|
|
92
|
+
- a re-query failure keeps stale results visible under an error banner;
|
|
93
|
+
- an empty success keeps the input mounted - the panel renders the empty slot
|
|
94
|
+
off its own result count, so typing to refine the term keeps working.
|
|
95
|
+
|
|
96
|
+
When async groups arrive mid-navigation, the highlight is re-resolved by
|
|
97
|
+
command id, not index - Enter always runs the row the user saw.
|
|
98
|
+
|
|
99
|
+
## Template slots
|
|
100
|
+
|
|
101
|
+
Six structural directives, projected as palette content. Resolution per slot:
|
|
102
|
+
instance directive, then `config.templates`, then the built-in default.
|
|
103
|
+
|
|
104
|
+
| Slot | Context |
|
|
105
|
+
|-|-|
|
|
106
|
+
| `*cngxCommandRow` | `$implicit: CngxRankedCommand`, `term`, `data`, `active` |
|
|
107
|
+
| `*cngxCommandGroupHeader` | `$implicit: CngxCommandGroup` |
|
|
108
|
+
| `*cngxCommandPaletteEmpty` | `term` |
|
|
109
|
+
| `*cngxCommandPaletteLoading` | none |
|
|
110
|
+
| `*cngxCommandPaletteError` | `error`, `retry: () => void` |
|
|
111
|
+
| `*cngxCommandPaletteFooter` | none |
|
|
112
|
+
|
|
113
|
+
The row is one slot on purpose - icon, label and shortcut hint are laid out in
|
|
114
|
+
the consumer's template:
|
|
115
|
+
|
|
116
|
+
```html
|
|
117
|
+
<cngx-command-palette #palette [results]="results()">
|
|
118
|
+
<ng-template cngxCommandRow let-entry let-active="active">
|
|
119
|
+
<my-icon [name]="entry.command.icon" />
|
|
120
|
+
<span>{{ entry.command.label }}</span>
|
|
121
|
+
</ng-template>
|
|
122
|
+
</cngx-command-palette>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
The default footer renders the configured keyboard legend as `<kbd>` rows.
|
|
126
|
+
|
|
127
|
+
## Host contract
|
|
128
|
+
|
|
129
|
+
The palette provides `CNGX_COMMAND_PALETTE_HOST` (`CngxCommandPaletteHost`):
|
|
130
|
+
`isOpen: Signal<boolean>` plus `dismiss()`. The panel uses it to dismiss after
|
|
131
|
+
a command runs and to reset term and highlight when the surface closes - the
|
|
132
|
+
dialog keeps its content mounted, so state must not leak into the next open.
|
|
133
|
+
The trigger binds `aria-expanded` to the same `isOpen()` seam.
|
|
134
|
+
|
|
135
|
+
## Configuration
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
provideCommandPaletteConfig(
|
|
139
|
+
withCommandPaletteLabels({ searchPlaceholder: 'Befehl eingeben...', emptyLabel: 'Keine Treffer.' }),
|
|
140
|
+
withPaletteShortcut('mod+shift+p'),
|
|
141
|
+
withKeyboardLegend([{ keys: 'enter', label: 'Ausfuehren' }]),
|
|
142
|
+
withResultCountFormatter((n) => `${n} Ergebnisse`),
|
|
143
|
+
withCommandPaletteTemplates({ row: myRowTemplate }),
|
|
144
|
+
);
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Root, or scoped to a subtree with `provideCommandPaletteConfigAt` in
|
|
148
|
+
`viewProviders`, where features merge onto the enclosing scope. The copy
|
|
149
|
+
defaults are the `commandPalette` section of the language pack (English
|
|
150
|
+
without one), so the language file translates the palette; the features above
|
|
151
|
+
override single keys on top of it. Each footer legend entry is spoken once,
|
|
152
|
+
through the section's `legendEntry` message (`'{keys} {label}'`). The `<kbd>`
|
|
153
|
+
glyphs are hidden from screen readers; an entry's `spokenKeys` (the navigate
|
|
154
|
+
entry's `navigateKeysSpoken`, English `'Up and Down arrows'`) is what they hear.
|
|
155
|
+
|
|
156
|
+
## Accessibility
|
|
157
|
+
|
|
158
|
+
- The surface is a native modal dialog: `showModal()` traps focus, Escape
|
|
159
|
+
closes, focus returns to the trigger after the close transition settles.
|
|
160
|
+
`[ariaLabel]` names the dialog (default `'Command palette'`).
|
|
161
|
+
- The input is `role="combobox"` with `aria-autocomplete="list"`,
|
|
162
|
+
`aria-controls` on the listbox and `aria-activedescendant` tracking the
|
|
163
|
+
highlighted row; focus never leaves the input while navigating.
|
|
164
|
+
- ArrowDown/ArrowUp move the highlight, Home/End jump, Enter activates.
|
|
165
|
+
Modified combos (Ctrl/Meta/Alt) pass through untouched so browser and app
|
|
166
|
+
shortcuts keep working; printable keys fall through to the search term.
|
|
167
|
+
- A polite `aria-live` region announces the result count on every re-rank,
|
|
168
|
+
formatted by `config.resultCount`.
|
|
169
|
+
- Groups render as `role="group"` with `aria-labelledby` pointing at minted,
|
|
170
|
+
panel-unique DOM ids - never raw consumer strings.
|
|
171
|
+
- Forced-colors mode re-signals the active row with the system Highlight pair
|
|
172
|
+
and pins the modal border to `CanvasText`.
|
|
173
|
+
|
|
174
|
+
## CSS custom properties
|
|
175
|
+
|
|
176
|
+
All spacing tokens are set from the global `--cngx-space-*` scale at the hosts,
|
|
177
|
+
so a root `[data-density]` swap re-scales the whole palette.
|
|
178
|
+
|
|
179
|
+
| Property | Default | Purpose |
|
|
180
|
+
|-|-|-|
|
|
181
|
+
| `--cngx-command-width` | `min(40rem, calc(100vw - 2rem))` | Dialog inline size |
|
|
182
|
+
| `--cngx-command-max-h` | `min(32rem, calc(100vh - 6rem))` | Dialog max block size |
|
|
183
|
+
| `--cngx-command-bg` / `--cngx-command-color` | surface / inherit | Dialog surface pair |
|
|
184
|
+
| `--cngx-command-border` / `--cngx-command-border-width` | `--cngx-color-border` / `1px` | Border, input row and footer separators |
|
|
185
|
+
| `--cngx-command-radius` | `--cngx-radius-lg` | Dialog corner radius |
|
|
186
|
+
| `--cngx-command-shadow` | elevation shadow | Dialog elevation |
|
|
187
|
+
| `--cngx-command-backdrop` | `rgb(0 0 0 / 0.4)` | `::backdrop` scrim |
|
|
188
|
+
| `--cngx-command-input-color` / `--cngx-command-placeholder-color` | inherit / muted | Search input text |
|
|
189
|
+
| `--cngx-command-input-gap` / `--cngx-command-input-pad` | `sm` / `md` space | Input row layout |
|
|
190
|
+
| `--cngx-command-chip-bg` / `--cngx-command-chip-color` / `--cngx-command-chip-size` / `--cngx-command-chip-radius` / `--cngx-command-chip-pad` | muted / inherit / `0.8125rem` / `--cngx-radius-sm` / `sm` space | Scope chip |
|
|
191
|
+
| `--cngx-command-listbox-max-h` / `--cngx-command-listbox-pad` | `22rem` / `xs` space | Results scroll area |
|
|
192
|
+
| `--cngx-command-header-color` / `--cngx-command-header-size` / `--cngx-command-header-weight` / `--cngx-command-header-pad-y` / `--cngx-command-header-pad-x` | muted / `0.75rem` / `600` / `xs` / `sm` space | Group headers |
|
|
193
|
+
| `--cngx-command-row-color` / `--cngx-command-row-radius` / `--cngx-command-row-gap` / `--cngx-command-row-pad` | inherit / `--cngx-radius-sm` / `sm` / `sm` space | Command rows |
|
|
194
|
+
| `--cngx-command-row-active-bg` / `--cngx-command-row-active-color` | accent / inherit | Highlighted row |
|
|
195
|
+
| `--cngx-command-mark-bg` | `--cngx-color-highlight` | Match `<mark>` |
|
|
196
|
+
| `--cngx-command-state-pad` / `--cngx-command-state-color` / `--cngx-command-error-color` / `--cngx-command-retry-bg` | `lg` space / muted / danger / transparent | Loading, empty and error chrome |
|
|
197
|
+
| `--cngx-command-footer-gap` / `--cngx-command-footer-pad-y` / `--cngx-command-footer-pad-x` / `--cngx-command-footer-size` / `--cngx-command-footer-color` | `md` / `sm` / `md` space / `0.75rem` / muted | Legend footer |
|
|
198
|
+
| `--cngx-command-kbd-bg` / `--cngx-command-kbd-color` | muted / inherit | `<kbd>` chips |
|
|
199
|
+
| `--cngx-command-focus-outline` / `--cngx-command-focus-offset` | `2px solid` focus color / `2px` | Focus ring |
|
|
200
|
+
|
|
201
|
+
## Material Theme
|
|
202
|
+
|
|
203
|
+
```scss
|
|
204
|
+
@use '@angular/material' as mat;
|
|
205
|
+
@use '@cngx/themes/material/command-palette-theme' as command-palette;
|
|
206
|
+
|
|
207
|
+
html {
|
|
208
|
+
@include command-palette.theme($theme);
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Without the bridge the palette uses the cngx foundation `--cngx-color-*`
|
|
213
|
+
tokens with a native look. The bridge paints an M3 dialog/menu hybrid:
|
|
214
|
+
surface-container-high modal on a scrim backdrop, secondary-container active
|
|
215
|
+
rows, container-tone chip and kbd sub-surfaces, error roles for the failure
|
|
216
|
+
chrome. Spacing stays on `--cngx-space-*` so density tracking keeps working.
|
|
217
|
+
|
|
218
|
+
## See Also
|
|
219
|
+
|
|
220
|
+
- `@cngx/common/command` - the framework-level command registry and matcher
|
|
221
|
+
- [CngxDialog](../../common/dialog/) - the modal surface the palette composes
|
|
222
|
+
- [CngxListbox](../../common/interactive/) - the navigation atom under the rows
|
|
223
|
+
- [API on compodocx](https://cngxjs.github.io/cngx/)
|
|
224
|
+
- Tests: `projects/ui/command-palette/palette/command-palette.component.spec.ts`, `panel/command-panel.component.spec.ts`
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# @cngx/ui/context-menu
|
|
2
|
+
|
|
3
|
+
Declarative context-menu organism over the headless menu brains
|
|
4
|
+
(`@cngx/common/interactive`). One `<cngx-context-menu>` docks onto many targets
|
|
5
|
+
via `[cngxContextMenuFor]`, opens at pointer coordinates on right-click or
|
|
6
|
+
`Shift+F10`, and hands each open a per-row datum. The panel stacks `CngxPopover`
|
|
7
|
+
and `CngxMenu` as host directives, so `role="menu"`, active-descendant
|
|
8
|
+
navigation, and the four dismiss sources come from the composition, not the
|
|
9
|
+
shell.
|
|
10
|
+
|
|
11
|
+
Placement follows the tabs precedent: components that host a popover surface
|
|
12
|
+
live in `@cngx/ui`, above the popover-free `common/interactive` layer.
|
|
13
|
+
|
|
14
|
+
## Anatomy
|
|
15
|
+
|
|
16
|
+
```html
|
|
17
|
+
<div [cngxContextMenuFor]="menu" [cngxContextMenuData]="row" tabindex="0">…</div>
|
|
18
|
+
|
|
19
|
+
<cngx-context-menu #menu="cngxContextMenu" ariaLabel="Row actions">
|
|
20
|
+
<cngx-context-menu-item value="open" kbd="⌘O" (select)="open()">Open</cngx-context-menu-item>
|
|
21
|
+
<cngx-context-menu-item value="rename" (select)="rename()">Rename</cngx-context-menu-item>
|
|
22
|
+
<cngx-context-menu-divider />
|
|
23
|
+
<cngx-context-menu-item value="delete" [disabled]="locked()" (select)="remove()">Delete</cngx-context-menu-item>
|
|
24
|
+
</cngx-context-menu>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Minimal case: two template elements, one binding. `ariaLabel` forwards to the
|
|
28
|
+
menu's required label, so the accessible name stays mandatory.
|
|
29
|
+
|
|
30
|
+
## Data channel
|
|
31
|
+
|
|
32
|
+
Two ways to obtain the datum `T`:
|
|
33
|
+
|
|
34
|
+
- `[cngxContextMenuData]` - a fixed datum for a single target.
|
|
35
|
+
- `[cngxContextMenuResolve]` - a resolver run against the `contextmenu` event,
|
|
36
|
+
so a table, grid, treetable, or virtualized list keeps one trigger instance
|
|
37
|
+
and derives the row from `event.target`. The resolver wins when both are
|
|
38
|
+
bound; a `null` result leaves the native menu untouched (no `preventDefault`,
|
|
39
|
+
no open).
|
|
40
|
+
|
|
41
|
+
The panel's `context()` is derived from popover visibility, never synced: the
|
|
42
|
+
lazy `*cngxContextMenuContent` template rebuilds with the right row on each open
|
|
43
|
+
and nulls out on close.
|
|
44
|
+
|
|
45
|
+
```html
|
|
46
|
+
<table [cngxContextMenuFor]="menu" [cngxContextMenuResolve]="resolveRow">…</table>
|
|
47
|
+
|
|
48
|
+
<cngx-context-menu #menu="cngxContextMenu" ariaLabel="Row actions">
|
|
49
|
+
<ng-template cngxContextMenuContent let-row>
|
|
50
|
+
<cngx-context-menu-item (select)="edit(row)">Edit {{ row.name }}</cngx-context-menu-item>
|
|
51
|
+
</ng-template>
|
|
52
|
+
</cngx-context-menu>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Items
|
|
56
|
+
|
|
57
|
+
`CngxContextMenuItem` (dual selector: `cngx-context-menu-item` or
|
|
58
|
+
`button[cngxContextMenuItem]`) is a thin shell over `CngxMenuItem` - the brain
|
|
59
|
+
owns `role="menuitem"`, activation, and disabled semantics. `icon` and `kbd`
|
|
60
|
+
render through the menu-item slots; `select` fires on click or Enter/Space.
|
|
61
|
+
|
|
62
|
+
Checkable rows: `cngx-context-menu-item-checkbox` two-way binds `[(checked)]`;
|
|
63
|
+
`cngx-context-menu-item-radio` scopes mutual exclusion to an enclosing
|
|
64
|
+
`[cngxMenuGroup]`. `role="menuitemcheckbox"` / `menuitemradio` and the reactive
|
|
65
|
+
`aria-checked` come from the brains.
|
|
66
|
+
|
|
67
|
+
## Submenu
|
|
68
|
+
|
|
69
|
+
Bind `[submenu]` on an item to a sibling `<cngx-context-menu>` - sibling
|
|
70
|
+
declaration, not inline nesting (inline-projected items would register with the
|
|
71
|
+
parent's active-descendant). The `CngxMenuItemSubmenu` brain is wired internally
|
|
72
|
+
through `CNGX_MENU_SUBMENU_WIRING`, so there is no `[exclusive]` handgrip and no
|
|
73
|
+
popover plumbing. The nested panel opens non-exclusively (the parent survives),
|
|
74
|
+
inherits the parent's row context, and shares the ArrowRight / ArrowLeft /
|
|
75
|
+
Escape keyboard contract with `CngxMenuTrigger`.
|
|
76
|
+
|
|
77
|
+
```html
|
|
78
|
+
<cngx-context-menu-item [submenu]="exportMenu">Export as</cngx-context-menu-item>
|
|
79
|
+
<cngx-context-menu #exportMenu="cngxContextMenu" ariaLabel="Export format">
|
|
80
|
+
<cngx-context-menu-item (select)="export('pdf')">PDF</cngx-context-menu-item>
|
|
81
|
+
</cngx-context-menu>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Config
|
|
85
|
+
|
|
86
|
+
No new config surface. All labels flow through `provideCngxMenu(...)` /
|
|
87
|
+
`injectMenuConfig()` from `@cngx/common/interactive`. Library defaults are
|
|
88
|
+
English.
|
|
89
|
+
|
|
90
|
+
## Theming
|
|
91
|
+
|
|
92
|
+
Default visuals ship with the components (Track A) - no theme import needed. The
|
|
93
|
+
popup surface, item geometry, divider, and checked glyph paint from the
|
|
94
|
+
`--cngx-context-menu-*` token family; spacing derives from `--cngx-space-*`, so a
|
|
95
|
+
root `[data-density]` compacts the menu and colours track the foundation across
|
|
96
|
+
light and dark. The item slot and highlight painting is adopted from the base
|
|
97
|
+
menu skin. Opt into Material with
|
|
98
|
+
`@use '@cngx/themes/material/context-menu-theme'`.
|
|
@@ -57,6 +57,86 @@ Above `--cngx-dga-min-width` the grid fills 100%; below it the host scrolls side
|
|
|
57
57
|
(`overflow-x: auto`) with every column intact. No column is ever dropped - horizontal
|
|
58
58
|
scroll over silent information loss.
|
|
59
59
|
|
|
60
|
+
The host composes `CngxScrollEdges`, so it carries `data-scroll-inline-start` /
|
|
61
|
+
`data-scroll-inline-end` only while columns are really hidden toward that side, and
|
|
62
|
+
fades that edge with a mask. The fade width is `--cngx-dga-edge-fade-size` (24px) and it
|
|
63
|
+
never drops below `--cngx-dga-edge-fade-min` opacity (0.35), so edge content and overlay
|
|
64
|
+
scrollbars stay visible; the border ring (skin frame, classic scrollbars) is left
|
|
65
|
+
unmasked. The gradient flips under `dir="rtl"`. A focused cell scrolled in sideways
|
|
66
|
+
lands clear of the fade (`scroll-padding-inline` = fade width plus
|
|
67
|
+
`--cngx-dga-focus-clearance`), and while the grid host itself holds keyboard focus the
|
|
68
|
+
mask yields so its focus ring stays visible.
|
|
69
|
+
|
|
70
|
+
## Bounded height
|
|
71
|
+
|
|
72
|
+
Bind `[maxBlockSize]` to cap the grid (a number is `px`, a string is any CSS length):
|
|
73
|
+
it becomes its own vertical scrollport, the column head pins to the top and the footer
|
|
74
|
+
to the bottom, and only the rows scroll between them - the totals in the footer stay
|
|
75
|
+
visible. The input reflects onto `--cngx-dga-max-block-size`, the same token a skin may
|
|
76
|
+
set directly. This is the only way to pin the head - `[cngxStickyHeader]` from
|
|
77
|
+
`@cngx/common/layout` is the wrong tool here, because the group is its own scrollport
|
|
78
|
+
and a content-height grid has nothing to stick to. Leave `[maxBlockSize]` unbound and
|
|
79
|
+
the grid stays content-height and unchanged.
|
|
80
|
+
|
|
81
|
+
In bounded mode the pinned bands communicate hidden rows: the head casts a shadow only
|
|
82
|
+
while `data-scroll-block-start` is set (rows scrolled away above), the footer only while
|
|
83
|
+
`data-scroll-block-end` is set (rows remaining below). Tune them with
|
|
84
|
+
`--cngx-dga-head-shadow` / `--cngx-dga-foot-shadow`. Keyboard focus never lands under a
|
|
85
|
+
band: the host pads its scrollport (`scroll-padding-block`) by the measured head and
|
|
86
|
+
foot size plus `--cngx-dga-focus-clearance` (4px, the widest ring plus its offset);
|
|
87
|
+
`--cngx-dga-head-scroll-pad` / `--cngx-dga-foot-scroll-pad` override the measured
|
|
88
|
+
values.
|
|
89
|
+
|
|
90
|
+
### Scroll-edge visuals are swappable defaults
|
|
91
|
+
|
|
92
|
+
The shadows and the inline fade are only the default look. The host attributes
|
|
93
|
+
`data-scroll-block-start`, `data-scroll-block-end`, `data-scroll-inline-start` and
|
|
94
|
+
`data-scroll-inline-end` are public: each is present (empty value) only while content is
|
|
95
|
+
hidden toward that edge, so you can key any visual on them.
|
|
96
|
+
|
|
97
|
+
Turn the default shadows off:
|
|
98
|
+
|
|
99
|
+
```css
|
|
100
|
+
cngx-data-grid-accordion {
|
|
101
|
+
--cngx-dga-head-shadow: none;
|
|
102
|
+
--cngx-dga-foot-shadow: none;
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
A line that appears under the pinned head instead. Use a background layer on the header
|
|
107
|
+
rather than a pseudo-element: some skins already use the header's pseudo-elements, and
|
|
108
|
+
a background layer stacks on top of the skin's own fill:
|
|
109
|
+
|
|
110
|
+
```css
|
|
111
|
+
cngx-data-grid-accordion {
|
|
112
|
+
--cngx-dga-head-shadow: none;
|
|
113
|
+
}
|
|
114
|
+
cngx-data-grid-accordion[data-scroll-block-start] .cngx-dga-header {
|
|
115
|
+
background-image: linear-gradient(to top, var(--cngx-color-border, #d1d5db) 2px, transparent 0);
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
A tonal head instead (the Material 3 top app bar pattern). Set the header's background
|
|
120
|
+
directly: the named skins paint the head fill themselves, so `--cngx-dga-head-bg` only
|
|
121
|
+
reaches the unskinned grid:
|
|
122
|
+
|
|
123
|
+
```css
|
|
124
|
+
cngx-data-grid-accordion {
|
|
125
|
+
--cngx-dga-head-shadow: none;
|
|
126
|
+
}
|
|
127
|
+
cngx-data-grid-accordion[data-scroll-block-start] .cngx-dga-header {
|
|
128
|
+
background-color: color-mix(in oklab, var(--cngx-color-primary, #1d4ed8) 8%, var(--cngx-color-surface, #fff));
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Under forced colors the UA strips shadows, so a line or border is the cue that survives
|
|
133
|
+
there.
|
|
134
|
+
|
|
135
|
+
Motion and forced colors: the shadow and fade ease over `--cngx-dga-edge-duration`
|
|
136
|
+
(default `--cngx-duration-fast`), which the global reduced-motion net collapses to an
|
|
137
|
+
instant change. Under forced colors the UA drops the shadows and the fade is removed;
|
|
138
|
+
the system-coloured scrollbar and the 1px head / foot rules carry the cue.
|
|
139
|
+
|
|
60
140
|
## Skins
|
|
61
141
|
|
|
62
142
|
Six built-in skins select via the `[skin]` input, reflected onto a `[data-skin]` host
|
|
@@ -84,8 +164,13 @@ a per-instance `[skin]` still wins. Columns are per-instance, so there is no
|
|
|
84
164
|
## Config
|
|
85
165
|
|
|
86
166
|
`provideDataGridAccordionConfig(...)` / `provideDataGridAccordionConfigAt(...)` with the
|
|
87
|
-
|
|
88
|
-
`injectDataGridAccordionConfig()`.
|
|
167
|
+
`withDataGridSkin(name)` and `withDataGridAccordionLabels({...})` features; read it back
|
|
168
|
+
with `injectDataGridAccordionConfig()`. `withDataGridAccordionLabels` takes a partial
|
|
169
|
+
bundle (or a `Signal` of one) for the count, sort, filter, row-error and note copy;
|
|
170
|
+
unset keys read the `dataGridAccordion` section of the language pack (English without
|
|
171
|
+
one). `CngxDataGridAccordionConfigFeature` is a union
|
|
172
|
+
since the labels feature landed - see [the migration note](./config-feature-migration.md)
|
|
173
|
+
if you extended or merged the old interface.
|
|
89
174
|
|
|
90
175
|
## Sort and filter
|
|
91
176
|
|
|
@@ -135,3 +220,19 @@ Sort and filter are per-instance, so there is no `withDataGridSort` / `withDataG
|
|
|
135
220
|
config feature - each grid sorts and filters its own data. No in-component sort/filter
|
|
136
221
|
engine: the `@cngx/common/data` atoms own comparison and predicate matching; the group only
|
|
137
222
|
coordinates and publishes state.
|
|
223
|
+
|
|
224
|
+
### Pairing with `injectSmartDataSource`
|
|
225
|
+
|
|
226
|
+
`injectSmartDataSource` resolves its atoms by injection, and injection walks up the tree -
|
|
227
|
+
the group's `sort` / `filter` live on the grid element below the consumer's injector, so
|
|
228
|
+
the source never sees them and silently skips those steps. Either derive the rows yourself
|
|
229
|
+
from the context (the prescribed shape above), or hand the hosted atoms over through the
|
|
230
|
+
source's options thunks:
|
|
231
|
+
|
|
232
|
+
```ts
|
|
233
|
+
readonly grid = viewChild(CngxDataGridAccordion);
|
|
234
|
+
readonly source = injectSmartDataSource(this.rows, {
|
|
235
|
+
sort: () => this.grid()?.sort,
|
|
236
|
+
filter: () => this.grid()?.filter,
|
|
237
|
+
});
|
|
238
|
+
```
|
package/feedback/README.md
CHANGED
|
@@ -27,7 +27,49 @@ Two patterns make the whole feedback layer feel cohesive:
|
|
|
27
27
|
|
|
28
28
|
Toast, banner, and alerter services are **not** `providedIn: 'root'`. Provide them via `provideFeedback(...)` in your application bootstrap, and render the outlets once at the application root. This is intentional - feedback presentation is application-level, not library-level, and forcing the consumer to opt in keeps a tree-shake-friendly footprint when only a subset of surfaces is in use.
|
|
29
29
|
|
|
30
|
+
Loading timing (the flash-suppression `showDelay` / `minDwell` shared by every loading surface) lives in the `CNGX_LOADING_CONFIG` cascade in `@cngx/core/utils`. `provideFeedback(withLoadingDefaults({ delay, minDuration }))` still writes that token as a back-compat wrapper (`delay` maps to `showDelay`, `minDuration` to `minDwell`), but it replaces the whole config and resets `spinnerVsSkeletonCutoff`. For new apps prefer `provideLoadingConfig(withShowDelay(...), withMinDwell(...), withSpinnerVsSkeletonCutoff(...))` from `@cngx/core/utils` as the canonical loading-timing knob.
|
|
31
|
+
|
|
32
|
+
The alert stack and the toast outlet name their `role="region"` host, and both
|
|
33
|
+
outlets announce state changes - all English by default and all overridable
|
|
34
|
+
through `CNGX_FEEDBACK_I18N`:
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
provideFeedback(
|
|
38
|
+
withToasts(),
|
|
39
|
+
withAlerts(),
|
|
40
|
+
withFeedbackI18nLabels({
|
|
41
|
+
alertsRegionLabel: 'Hinweise',
|
|
42
|
+
announcements: { alertDismissed: 'Hinweis verworfen' },
|
|
43
|
+
}),
|
|
44
|
+
)
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
`provideFeedbackI18n({ ... })` sets the same bundle on its own, which is what a
|
|
48
|
+
consumer-composed language file uses: `provideFeedback(...)` replaces the whole
|
|
49
|
+
`CNGX_FEEDBACK_CONFIG` value, so routing a translation through it would reset
|
|
50
|
+
unrelated feedback defaults. Both accept a `Signal` of the overrides to switch
|
|
51
|
+
the language at runtime; `CNGX_FEEDBACK_I18N` itself is a `Signal` of the
|
|
52
|
+
resolved bundle. To translate the whole family, put a `feedback` section in
|
|
53
|
+
your language pack (`provideCngxI18n` from `@cngx/core/i18n`); the English
|
|
54
|
+
section is `CNGX_FEEDBACK_LANGUAGE_EN`, and the two providers above override
|
|
55
|
+
single keys on top of it.
|
|
56
|
+
|
|
57
|
+
The state bridges append an error detail only through a mapping you own. With
|
|
58
|
+
`[toastErrorDetail]="true"` (and the alert and banner equivalents), development
|
|
59
|
+
builds show the raw `Error.message` and warn once in the console; production
|
|
60
|
+
builds show the message alone until you set `withErrorDetail`:
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
provideFeedback(
|
|
64
|
+
withToasts(),
|
|
65
|
+
withErrorDetail((error) =>
|
|
66
|
+
error instanceof HttpErrorResponse ? translate(`http.${error.status}`) : undefined,
|
|
67
|
+
),
|
|
68
|
+
)
|
|
69
|
+
```
|
|
70
|
+
|
|
30
71
|
## See also
|
|
31
72
|
|
|
32
73
|
- Outlet components, services, bridge directives, slot directives, and `with*` config features in the **API** tab.
|
|
74
|
+
- Localising every cngx string: the "Localisation" chapter in the docs sidebar.
|
|
33
75
|
- Conceptual deep dive: the "Async State Machine" chapter in the docs sidebar.
|