@cngx/ui 0.1.0-rc.7 → 0.1.0-rc.9

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 (101) hide show
  1. package/README.md +0 -1
  2. package/a11y/README.md +11 -5
  3. package/accordion/README.md +4 -2
  4. package/breadcrumb/README.md +262 -0
  5. package/collection/README.md +6 -0
  6. package/command-palette/README.md +227 -0
  7. package/data-grid-accordion/README.md +76 -2
  8. package/feedback/README.md +40 -0
  9. package/fesm2022/cngx-ui-a11y.mjs +189 -57
  10. package/fesm2022/cngx-ui-a11y.mjs.map +1 -1
  11. package/fesm2022/cngx-ui-accordion.mjs +120 -36
  12. package/fesm2022/cngx-ui-accordion.mjs.map +1 -1
  13. package/fesm2022/cngx-ui-action-button.mjs +121 -56
  14. package/fesm2022/cngx-ui-action-button.mjs.map +1 -1
  15. package/fesm2022/cngx-ui-breadcrumb.mjs +228 -108
  16. package/fesm2022/cngx-ui-breadcrumb.mjs.map +1 -1
  17. package/fesm2022/cngx-ui-chart-panel.mjs +180 -23
  18. package/fesm2022/cngx-ui-chart-panel.mjs.map +1 -1
  19. package/fesm2022/cngx-ui-collection.mjs +204 -62
  20. package/fesm2022/cngx-ui-collection.mjs.map +1 -1
  21. package/fesm2022/cngx-ui-command-palette.mjs +395 -119
  22. package/fesm2022/cngx-ui-command-palette.mjs.map +1 -1
  23. package/fesm2022/cngx-ui-context-menu.mjs +209 -40
  24. package/fesm2022/cngx-ui-context-menu.mjs.map +1 -1
  25. package/fesm2022/cngx-ui-data-grid-accordion.mjs +498 -101
  26. package/fesm2022/cngx-ui-data-grid-accordion.mjs.map +1 -1
  27. package/fesm2022/cngx-ui-empty-state.mjs +16 -6
  28. package/fesm2022/cngx-ui-empty-state.mjs.map +1 -1
  29. package/fesm2022/cngx-ui-feedback.mjs +1074 -460
  30. package/fesm2022/cngx-ui-feedback.mjs.map +1 -1
  31. package/fesm2022/cngx-ui-mat-accordion.mjs +76 -7
  32. package/fesm2022/cngx-ui-mat-accordion.mjs.map +1 -1
  33. package/fesm2022/cngx-ui-mat-paginator.mjs +67 -24
  34. package/fesm2022/cngx-ui-mat-paginator.mjs.map +1 -1
  35. package/fesm2022/cngx-ui-mat-stepper.mjs +72 -47
  36. package/fesm2022/cngx-ui-mat-stepper.mjs.map +1 -1
  37. package/fesm2022/cngx-ui-mat-tabs.mjs +555 -204
  38. package/fesm2022/cngx-ui-mat-tabs.mjs.map +1 -1
  39. package/fesm2022/cngx-ui-overlay.mjs +69 -13
  40. package/fesm2022/cngx-ui-overlay.mjs.map +1 -1
  41. package/fesm2022/cngx-ui-paginator.mjs +553 -198
  42. package/fesm2022/cngx-ui-paginator.mjs.map +1 -1
  43. package/fesm2022/cngx-ui-sidenav.mjs +344 -109
  44. package/fesm2022/cngx-ui-sidenav.mjs.map +1 -1
  45. package/fesm2022/cngx-ui-skeleton.mjs +4 -16
  46. package/fesm2022/cngx-ui-skeleton.mjs.map +1 -1
  47. package/fesm2022/cngx-ui-speak.mjs +107 -8
  48. package/fesm2022/cngx-ui-speak.mjs.map +1 -1
  49. package/fesm2022/cngx-ui-stat-card.mjs +146 -46
  50. package/fesm2022/cngx-ui-stat-card.mjs.map +1 -1
  51. package/fesm2022/cngx-ui-stepper.mjs +234 -99
  52. package/fesm2022/cngx-ui-stepper.mjs.map +1 -1
  53. package/fesm2022/cngx-ui-tabs.mjs +88 -25
  54. package/fesm2022/cngx-ui-tabs.mjs.map +1 -1
  55. package/fesm2022/cngx-ui-timeline.mjs +98 -23
  56. package/fesm2022/cngx-ui-timeline.mjs.map +1 -1
  57. package/fesm2022/cngx-ui-toc.mjs +101 -33
  58. package/fesm2022/cngx-ui-toc.mjs.map +1 -1
  59. package/fesm2022/cngx-ui.mjs +15 -20
  60. package/fesm2022/cngx-ui.mjs.map +1 -1
  61. package/mat-paginator/README.md +9 -2
  62. package/mat-tabs/README.md +30 -6
  63. package/mat-tabs/styles/mat-tabs.css +188 -42
  64. package/overlay/README.md +9 -4
  65. package/package.json +31 -7
  66. package/paginator/README.md +8 -4
  67. package/schematics/collection.json +9 -0
  68. package/schematics/ng-add/index.js +9 -0
  69. package/schematics/ng-add/schema.json +91 -0
  70. package/schematics/package.json +3 -0
  71. package/sidenav/README.md +33 -11
  72. package/speak/README.md +3 -2
  73. package/stepper/README.md +14 -2
  74. package/timeline/README.md +1 -1
  75. package/toc/README.md +4 -1
  76. package/types/cngx-ui-a11y.d.ts +121 -30
  77. package/types/cngx-ui-accordion.d.ts +100 -28
  78. package/types/cngx-ui-action-button.d.ts +44 -3
  79. package/types/cngx-ui-breadcrumb.d.ts +167 -60
  80. package/types/cngx-ui-chart-panel.d.ts +122 -18
  81. package/types/cngx-ui-collection.d.ts +157 -55
  82. package/types/cngx-ui-command-palette.d.ts +297 -183
  83. package/types/cngx-ui-context-menu.d.ts +140 -10
  84. package/types/cngx-ui-data-grid-accordion.d.ts +278 -39
  85. package/types/cngx-ui-empty-state.d.ts +9 -2
  86. package/types/cngx-ui-feedback.d.ts +605 -59
  87. package/types/cngx-ui-mat-accordion.d.ts +30 -1
  88. package/types/cngx-ui-mat-paginator.d.ts +37 -8
  89. package/types/cngx-ui-mat-stepper.d.ts +23 -11
  90. package/types/cngx-ui-mat-tabs.d.ts +250 -34
  91. package/types/cngx-ui-overlay.d.ts +56 -10
  92. package/types/cngx-ui-paginator.d.ts +425 -136
  93. package/types/cngx-ui-sidenav.d.ts +248 -74
  94. package/types/cngx-ui-skeleton.d.ts +6 -7
  95. package/types/cngx-ui-speak.d.ts +118 -5
  96. package/types/cngx-ui-stat-card.d.ts +117 -33
  97. package/types/cngx-ui-stepper.d.ts +88 -49
  98. package/types/cngx-ui-tabs.d.ts +6 -4
  99. package/types/cngx-ui-timeline.d.ts +35 -11
  100. package/types/cngx-ui-toc.d.ts +93 -16
  101. package/types/cngx-ui.d.ts +7 -4
@@ -0,0 +1,91 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "$id": "CngxNgAdd",
4
+ "title": "cngx ng-add",
5
+ "type": "object",
6
+ "properties": {
7
+ "project": {
8
+ "type": "string",
9
+ "description": "The project to add cngx to.",
10
+ "$default": {
11
+ "$source": "projectName"
12
+ }
13
+ },
14
+ "preset": {
15
+ "type": "string",
16
+ "description": "How much of the onboarding to apply. Asked first when a terminal is attached, after the preflight checklist; default recommended.",
17
+ "enum": ["minimal", "recommended", "full"]
18
+ },
19
+ "libs": {
20
+ "description": "The @cngx packages to install, comma-separated (--libs core,forms); their @cngx peers follow. Asked when a terminal is attached, otherwise every package.",
21
+ "oneOf": [
22
+ { "type": "string" },
23
+ {
24
+ "type": "array",
25
+ "items": { "type": "string", "enum": ["utils", "core", "common", "interop", "forms", "data-display", "ui"] },
26
+ "uniqueItems": true
27
+ }
28
+ ]
29
+ },
30
+ "theme": {
31
+ "type": "string",
32
+ "description": "The generated theme file: the cngx default, the Angular Material bridge, or none.",
33
+ "enum": ["cngx", "material", "none"]
34
+ },
35
+ "i18n": {
36
+ "type": "string",
37
+ "description": "The built-in copy: English only, or the German pack as well.",
38
+ "enum": ["en", "de"]
39
+ },
40
+ "runtimeSwitch": {
41
+ "oneOf": [{ "type": "boolean" }, { "type": "string", "enum": ["true", "false"] }],
42
+ "description": "Wire the language pack for switching at runtime instead of a fixed language."
43
+ },
44
+ "lint": {
45
+ "oneOf": [{ "type": "boolean" }, { "type": "string", "enum": ["true", "false"] }],
46
+ "description": "Add @cngx/eslint-plugin to the eslint flat config when one exists."
47
+ },
48
+ "a11yPreferences": {
49
+ "oneOf": [{ "type": "boolean" }, { "type": "string", "enum": ["true", "false"] }],
50
+ "description": "Provide the accessibility preference axes (density, text scale, motion, contrast) with persistence."
51
+ },
52
+ "feedback": {
53
+ "oneOf": [{ "type": "boolean" }, { "type": "string", "enum": ["true", "false"] }],
54
+ "description": "Provide toasts, alerts and banners at the root when @cngx/ui is installed."
55
+ },
56
+ "floatingFallback": {
57
+ "oneOf": [{ "type": "boolean" }, { "type": "string", "enum": ["true", "false"] }],
58
+ "description": "Install @floating-ui/dom and provide the popover positioning fallback for browsers without CSS anchor positioning."
59
+ },
60
+ "starter": {
61
+ "oneOf": [{ "type": "boolean" }, { "type": "string", "enum": ["true", "false"] }],
62
+ "description": "Replace the Angular welcome page of an untouched ng new standalone app with a cngx starter page that shows what was installed. Default true for --preset=full, false otherwise; --no-starter keeps the welcome page."
63
+ },
64
+ "aiTools": {
65
+ "description": "The editors to set up the cngx MCP server for, comma-separated (--ai-tools claude,vscode): the server entry in their project MCP config, a marked cngx block in the agent instructions (AGENTS.md, or CLAUDE.md for Claude Code) and .cngx/README.md. Asked when a terminal is attached. --preset=full preselects the detected editors (CLAUDE.md or .claude, .cursorrules or .cursor, .vscode) and sets them up without a terminal too; the other presets preselect none.",
66
+ "oneOf": [
67
+ { "type": "string" },
68
+ {
69
+ "type": "array",
70
+ "items": { "type": "string", "enum": ["claude", "cursor", "vscode"] },
71
+ "uniqueItems": true
72
+ }
73
+ ]
74
+ },
75
+ "yes": {
76
+ "oneOf": [{ "type": "boolean" }, { "type": "string", "enum": ["true", "false"] }],
77
+ "description": "Apply the plan to an existing app without asking for confirmation first."
78
+ },
79
+ "prompts": {
80
+ "oneOf": [{ "type": "boolean" }, { "type": "string", "enum": ["true", "false"] }],
81
+ "description": "Ask the detection-dependent questions when a terminal is attached. Pass false in CI runs under a pseudo-terminal; flags, the recorded answers of a re-run and the preset defaults answer instead.",
82
+ "default": true
83
+ },
84
+ "quiet": {
85
+ "oneOf": [{ "type": "boolean" }, { "type": "string", "enum": ["true", "false"] }],
86
+ "description": "Print only the summary, not the planned changes.",
87
+ "default": false
88
+ }
89
+ },
90
+ "required": []
91
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
package/sidenav/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # CngxSidenav
2
2
 
3
- Declarative sidebar component supporting responsive mode switching, two-way opened binding, and content projection.
3
+ Declarative sidebar component. Responsive out of the box: the rail docks beside the content on a wide layout and overlays it on a narrow one, with nothing bound.
4
4
 
5
5
  ## Import
6
6
 
@@ -31,7 +31,7 @@ import {
31
31
  selector: 'app-example',
32
32
  template: `
33
33
  <cngx-sidenav-layout>
34
- <cngx-sidenav position="start" [(opened)]="navOpen" [responsive]="'(min-width: 1024px)'">
34
+ <cngx-sidenav position="start" [(opened)]="navOpen">
35
35
  <cngx-sidenav-header>Logo</cngx-sidenav-header>
36
36
  <a cngxNavLink [active]="true">Dashboard</a>
37
37
  <cngx-sidenav-footer>v1.0</cngx-sidenav-footer>
@@ -57,22 +57,47 @@ export class ExampleComponent {
57
57
 
58
58
  ## Overview
59
59
 
60
- `CngxSidenav` is a composable sidebar component that handles drawer behavior, keyboard shortcuts, responsive mode switching, and optional resize functionality. It coordinates with `CngxSidenavLayout` for backdrop and scroll-lock management.
60
+ `CngxSidenav` is a composable sidebar component that handles drawer behavior, keyboard shortcuts, width-driven mode switching, and optional resize functionality. It coordinates with `CngxSidenavLayout` for backdrop and scroll-lock management.
61
61
 
62
62
  Key features:
63
63
 
64
- - **Mode switching:** `over` (overlay), `push` (nudges content), `side` (permanent), `mini` (collapsed icon rail; hover expands after a tunable dwell via `[expandDelay]` / `[collapseDelay]`)
65
- - **Responsive:** Media query-driven mode override via `[responsive]` input
64
+ - **Responsive by default:** `mode` is `auto` unless you say otherwise - `side` once the surrounding layout is `64rem` or wider, `over` below that
65
+ - **Mode switching:** bind `mode` to pin one of `over` (overlay), `push` (nudges content), `side` (permanent), `mini` (collapsed icon rail; hover expands after a tunable dwell via `[expandDelay]` / `[collapseDelay]`)
66
66
  - **Two-way binding:** `[(opened)]` synchronizes with external state
67
- - **Resize:** Optional drag handle with min/max constraints
67
+ - **Resize:** Optional drag handle with min/max constraints; the separator speaks its position as a percent of the min-max range (`aria-valuetext`, `sidenav` language section)
68
68
  - **Keyboard:** Escape closes overlay, configurable global shortcut via `[shortcut]`
69
69
  - **RTL-aware:** `position="start"` / `"end"` flip logically in RTL
70
70
  - **Deep-linking:** persist open state to a URL query param via `[cngxSidenavRouterSync]` (see [Deep-linking](#deep-linking-router-sync))
71
- - **App-wide defaults:** `CNGX_SIDENAV_CONFIG` cascade for dimensions, responsive query, shortcut, hover dwell, and router-sync param (see [Configuration](#configuration))
71
+ - **App-wide defaults:** `CNGX_SIDENAV_CONFIG` cascade for dimensions, shortcut, hover dwell, and router-sync param (see [Configuration](#configuration))
72
+
73
+ ## Container, not viewport
74
+
75
+ The docking decision reads the width of the surrounding `CngxSidenavLayout`, not the width of the window. A rail inside a dashboard pane collapses when that pane is narrow, whatever the browser window is doing.
76
+
77
+ The threshold lives in exactly one place - a `@container` rule in `sidenav-layout.css` that writes `--cngx-sidenav-layout-wide` on the rail:
78
+
79
+ ```css
80
+ @container cngx-sidenav-layout (min-inline-size: 64rem) {
81
+ cngx-sidenav-layout > cngx-sidenav {
82
+ --cngx-sidenav-layout-wide: 1;
83
+ }
84
+ }
85
+ ```
86
+
87
+ `CngxSidenav` reads the resolved value; it never evaluates the condition itself. Override that rule to move the breakpoint. To opt out of auto entirely, bind `mode`:
88
+
89
+ ```html
90
+ <!-- always an overlay, whatever the layout width -->
91
+ <cngx-sidenav mode="over" [(opened)]="navOpen">…</cngx-sidenav>
92
+ ```
93
+
94
+ A rail mounted without `<cngx-sidenav-layout>` has no container to measure; it renders as `over` and warns in dev mode.
95
+
96
+ See `core-concepts/responsive-by-default.md` for the library-wide contract.
72
97
 
73
98
  ## Configuration
74
99
 
75
- Every dimension default, the responsive query, the toggle shortcut, and the mini hover dwell resolve through a standard cascade. Per-instance bindings always win; unset keys fall back to the library defaults, so an unconfigured `<cngx-sidenav>` behaves exactly as before.
100
+ Every dimension default, the toggle shortcut, and the mini hover dwell resolve through a standard cascade. The docking threshold is deliberately not in the cascade - it is a CSS rule (see above), so it travels with the skin. Per-instance bindings always win; unset keys fall back to the library defaults, so an unconfigured `<cngx-sidenav>` behaves exactly as before.
76
101
 
77
102
  Resolution priority (high to low):
78
103
 
@@ -85,7 +110,6 @@ Resolution priority (high to low):
85
110
  import {
86
111
  provideSidenavConfig,
87
112
  withSidenavDimensions,
88
- withSidenavResponsive,
89
113
  withSidenavShortcut,
90
114
  withSidenavHoverDwell,
91
115
  } from '@cngx/ui';
@@ -94,7 +118,6 @@ bootstrapApplication(AppComponent, {
94
118
  providers: [
95
119
  provideSidenavConfig(
96
120
  withSidenavDimensions({ width: '320px', miniWidth: '64px' }),
97
- withSidenavResponsive('(min-width: 1024px)'),
98
121
  withSidenavShortcut('mod+b'),
99
122
  withSidenavHoverDwell({ enterDelay: 200, leaveDelay: 150 }),
100
123
  ),
@@ -105,7 +128,6 @@ bootstrapApplication(AppComponent, {
105
128
  | Feature | Overrides |
106
129
  |-|-|
107
130
  | `withSidenavDimensions({ width?, miniWidth?, minWidth?, maxWidth? })` | Panel dimensions |
108
- | `withSidenavResponsive(query)` | Default responsive media query |
109
131
  | `withSidenavShortcut(combo)` | Default toggle shortcut |
110
132
  | `withSidenavHoverDwell({ enterDelay?, leaveDelay? })` | Mini expand/collapse dwell (ms) |
111
133
  | `withSidenavRouterSync({ param })` | Default deep-link query-param key |
package/speak/README.md CHANGED
@@ -35,7 +35,7 @@ export class ExampleComponent {
35
35
  `CngxSpeakButton` is a ready-made speaker button that connects to a `CngxSpeak` directive via an explicit `[speakRef]` input. It provides:
36
36
 
37
37
  - **Speaker and stop icons** - Built-in SVGs that toggle based on speaking state
38
- - **Accessible labels** - ARIA labels that reflect the current state ("Read aloud" / "Stop speaking")
38
+ - **Accessible labels** - ARIA labels that reflect the current state, English by default (`"Read aloud"` / `"Stop speaking"`), translated through the `speak` section of the language pack, and overridable per instance via `[readAloudLabel]` / `[stopLabel]`
39
39
  - **Cognitive accessibility** - Part of CngxSpeak, targeting dyslexia and reading ease
40
40
  - **Full theming control** - CSS custom properties for styling, Material theme SCSS integration
41
41
  - **No ancestor injection** - Explicit `[speakRef]` wiring prevents hidden dependencies
@@ -44,7 +44,8 @@ export class ExampleComponent {
44
44
 
45
45
  `CngxSpeakButton` is designed for cognitive accessibility:
46
46
 
47
- - **ARIA labels:** Button label dynamically changes between "Read aloud" (idle) and "Stop speaking" (active).
47
+ - **ARIA labels:** Button label dynamically changes between "Read aloud" (idle) and "Stop speaking" (active); both are overridable via `[readAloudLabel]` / `[stopLabel]`.
48
+ - **Capability gating:** When `CngxSpeak` reports no speech-synthesis engine (`supported === false`), the button hides itself (`hidden`) rather than render a dead control, keeping it out of the layout and the accessibility tree.
48
49
  - **Icon semantics:** SVG icons are marked `aria-hidden="true"` - the text label carries the meaning.
49
50
  - **CngxSpeak integration:** The underlying `CngxSpeak` directive handles the speech synthesis API, managing pause/resume, focus restoration, and `prefers-reduced-motion` respect.
50
51
  - **Cognitive focus:** Targets users with dyslexia, ADHD, and reading difficulties by providing auditory reinforcement alongside visual text.
package/stepper/README.md CHANGED
@@ -68,7 +68,19 @@ Per-instance override:
68
68
  <cngx-stepper skin="linear-minimal" aria-label="Wizard">...</cngx-stepper>
69
69
  ```
70
70
 
71
- Under 480px viewports the classic strip auto-collapses to `<cngx-text-stepper>` (default) or `<cngx-dot-stepper>`. Configure via `withStepperMobileCollapse('text' | 'dots' | 'off')`.
71
+ ### Container, not viewport
72
+
73
+ Below `30rem` of **its own container width** the classic strip auto-collapses to `<cngx-text-stepper>` (default) or `<cngx-dot-stepper>`. A stepper in a 400px dialog collapses on a 4K desktop; one in a wide page stays classic on a phone in landscape.
74
+
75
+ `withStepperMobileCollapse('text' | 'dots' | 'off')` picks *what* it collapses into. *Where* is a `@container` rule in the stepper stylesheet and is not a TypeScript knob - override it in your own CSS:
76
+
77
+ ```css
78
+ .my-wizard .cngx-stepper::after {
79
+ --cngx-stepper-collapse: 1; /* or 0 to suppress the collapse */
80
+ }
81
+ ```
82
+
83
+ An unlayered author rule beats the library rule in `@layer cngx.components`, so no `!important` is needed. See `core-concepts/responsive-by-default.md`.
72
84
 
73
85
  ## Density
74
86
 
@@ -241,7 +253,7 @@ A step can be flagged as in error through two independent channels. Both render
241
253
  |Channel|How you flag it|Where the message appears|
242
254
  |-|-|-|
243
255
  |Validation|`[error]="true \| 'message'"` on `cngxStep`, or `[errorAggregator]` for multi-source forms|a row **below the strip** (every classic-style skin) via `*cngxStepError`; folded into the aggregate line on the `text` / `dot` / `progress-bar` mini variants|
244
- |Commit / async|a `commitAction` that rejects (sets `lastFailedIndex`)|`*cngxStepRejection` decoration; `CngxToastOn` / `CngxBannerOn` transition bridges|
256
+ |Commit / async|a `commitAction` that refuses (`false`) or fails (throw, rejection, error); only the most recent attempt is shown, the next one replaces it|`*cngxStepRejection` decoration (amber `⊘` refused, red `!` failed); `CngxToastOn` / `CngxBannerOn` transition bridges on a failure only|
245
257
 
246
258
  The message lives on its own row **below** the step strip, not inside a step. That is deliberate: a free-text message inside a horizontal (or column) strip item widens the shrink-to-fit step and tears the row; below the strip it has full width and wraps. The strip itself only ever carries the short state cue.
247
259
 
@@ -159,7 +159,7 @@ the swap from skeleton to content does not reflow.
159
159
  **`alternate` is not supported with `mode="activity"`.** Alternating a
160
160
  scan-feed defeats the scan; those rows render `start` and dev mode warns once.
161
161
 
162
- **`alternate` collapses to a single side below `32rem`** of the timeline's own
162
+ **`alternate` collapses to a single side below `30rem`** of the timeline's own
163
163
  width. It is a container query, not a viewport one, so the same timeline
164
164
  behaves correctly inside a narrow panel on a wide screen. The threshold is a
165
165
  literal because a container-query condition cannot read a custom property.
package/toc/README.md CHANGED
@@ -157,7 +157,10 @@ provideTocConfig(
157
157
  Root, or scoped to a subtree with `provideTocConfigAt` in `viewProviders`, where
158
158
  features merge onto the parent config rather than replacing it. Resolution runs
159
159
  per-instance input, then the scoped provider, then root, then the library
160
- default. Defaults are English; supply your locale through the cascade.
160
+ default. The landmark name comes from the `toc` section of the language pack
161
+ (English without one, `CNGX_TOC_LANGUAGE_EN`); the cascade overrides it.
162
+ `withTocAriaLabels` also takes a `Signal`, so the landmark name follows a runtime
163
+ language switch; read the resolved labels with `injectTocAriaLabels()`.
161
164
 
162
165
  ## Material Theme
163
166
 
@@ -1,6 +1,5 @@
1
- import * as _cngx_ui_a11y from '@cngx/ui/a11y';
2
1
  import * as i0 from '@angular/core';
3
- import { InjectionToken, EnvironmentProviders, Provider, Signal } from '@angular/core';
2
+ import { InjectionToken, Signal, EnvironmentProviders, Provider } from '@angular/core';
4
3
  import { CngxDensityValue, CngxTextScaleValue, CngxMotionPreference, CngxContrastPreference } from '@cngx/core';
5
4
 
6
5
  /**
@@ -16,8 +15,8 @@ type CngxA11yPanelAxis = 'density' | 'textScale' | 'motion' | 'contrast';
16
15
  * One selectable option in an axis control group: the value written to the
17
16
  * axis signal plus the visible/toggle label. `V` is the axis' own value union
18
17
  * (e.g. `CngxDensityValue`), so a misspelled value fails to compile rather
19
- * than reaching the global preference signal. Library defaults are English;
20
- * consumers relabel via `withA11yPanelAxes`.
18
+ * than reaching the global preference signal. An option without a `label`
19
+ * reads it from the `a11yPanel` section of the language pack, by value.
21
20
  *
22
21
  * @category ui/a11y
23
22
  * @relatedTo withA11yPanelAxes
@@ -27,8 +26,12 @@ type CngxA11yPanelAxis = 'density' | 'textScale' | 'motion' | 'contrast';
27
26
  interface CngxA11yPanelAxisOption<V extends string = string> {
28
27
  /** Value written to the axis signal - a valid member of that axis' union. */
29
28
  readonly value: V;
30
- /** Toggle-button label. */
31
- readonly label: string;
29
+ /**
30
+ * Toggle-button label. Leave it out to read the label for `value` from the
31
+ * `a11yPanel` section of the language pack (English without one), so the
32
+ * option follows a language switch. A label set here wins.
33
+ */
34
+ readonly label?: string;
32
35
  }
33
36
  /**
34
37
  * A rendered axis control group: which axis, its ordered options, and the
@@ -63,8 +66,9 @@ type CngxA11yPanelAxisSpec = {
63
66
  /**
64
67
  * Panel text: per-axis group labels, the Reset control label, the default
65
68
  * heading (shown when no `[cngxA11yPanelHeader]` is projected), and the
66
- * live-region message announced on Reset. Library defaults are English;
67
- * consumers localise via {@link withA11yPanelLabels}.
69
+ * live-region message announced on Reset. The defaults come from the
70
+ * `a11yPanel` section of the language pack (English without one); override
71
+ * single keys via {@link withA11yPanelLabels}.
68
72
  *
69
73
  * @category ui/a11y
70
74
  * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/a11y/a11y-panel.config.ts
@@ -81,17 +85,23 @@ interface CngxA11yPanelLabels {
81
85
  readonly resetMessage: string;
82
86
  }
83
87
  /**
84
- * Resolved panel configuration - the text bundle plus the ordered axis list.
85
- * Merged from the library defaults and any `with*` features by the reducer in
86
- * {@link provideA11yPanelConfig}.
88
+ * Resolved panel configuration - the text overrides plus the ordered axis
89
+ * list. Merged from the library defaults and any `with*` features by the
90
+ * reducer in {@link provideA11yPanelConfig}.
91
+ *
92
+ * `labels` holds overrides only: unset by default, a value or a `Signal` once
93
+ * {@link withA11yPanelLabels} ran; every key it leaves out reads the
94
+ * `a11yPanel` section of the language pack. `axes` accepts a value or a
95
+ * `Signal`; its option labels are optional and default to the section. Read
96
+ * both through {@link injectA11yPanelLabels} and {@link injectA11yPanelAxes}.
87
97
  *
88
98
  * @category ui/a11y
89
99
  * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/a11y/a11y-panel.config.ts
90
100
  * @since 0.1.0
91
101
  */
92
102
  interface CngxA11yPanelConfig {
93
- readonly labels: CngxA11yPanelLabels;
94
- readonly axes: readonly CngxA11yPanelAxisSpec[];
103
+ readonly labels?: CngxA11yPanelLabelsOverride | Signal<CngxA11yPanelLabelsOverride>;
104
+ readonly axes: readonly CngxA11yPanelAxisSpec[] | Signal<readonly CngxA11yPanelAxisSpec[]>;
95
105
  }
96
106
  /**
97
107
  * Partial text override accepted by `withA11yPanelLabels`. The `axes`
@@ -109,8 +119,14 @@ interface CngxA11yPanelLabelsOverride {
109
119
  readonly heading?: string;
110
120
  readonly resetMessage?: string;
111
121
  }
112
- /** Library defaults - English. Override via {@link provideA11yPanelConfig}. */
113
- declare const CNGX_A11Y_PANEL_DEFAULTS: CngxA11yPanelConfig;
122
+ /**
123
+ * Library defaults: the four axes in their default order, each with its reset
124
+ * value. Carries no copy - the text and the option labels are the `a11yPanel`
125
+ * section of the language pack. Override via {@link provideA11yPanelConfig}.
126
+ */
127
+ declare const CNGX_A11Y_PANEL_DEFAULTS: CngxA11yPanelConfig & {
128
+ readonly axes: readonly CngxA11yPanelAxisSpec[];
129
+ };
114
130
  /**
115
131
  * Configuration cascade token. Resolution priority (high to low):
116
132
  * `provideA11yPanelConfigAt(...)` in a component's `viewProviders`, then
@@ -134,15 +150,16 @@ declare const CNGX_A11Y_PANEL_CONFIG: InjectionToken<CngxA11yPanelConfig>;
134
150
  */
135
151
  type CngxA11yPanelConfigFeature = {
136
152
  readonly kind: 'labels';
137
- readonly payload: CngxA11yPanelLabelsOverride;
153
+ readonly payload: CngxA11yPanelLabelsOverride | Signal<CngxA11yPanelLabelsOverride>;
138
154
  } | {
139
155
  readonly kind: 'axes';
140
- readonly payload: readonly CngxA11yPanelAxisSpec[];
156
+ readonly payload: readonly CngxA11yPanelAxisSpec[] | Signal<readonly CngxA11yPanelAxisSpec[]>;
141
157
  };
142
158
  /**
143
159
  * Override any subset of the panel text - axis group labels, the Reset label,
144
160
  * the default heading, or the Reset announcement. The `axes` record merges
145
- * key-by-key, so a single axis can be relabelled in isolation.
161
+ * key-by-key, so a single axis can be relabelled in isolation. Pass a `Signal`
162
+ * to switch the language at runtime.
146
163
  *
147
164
  * ```ts
148
165
  * provideA11yPanelConfig(
@@ -159,17 +176,20 @@ type CngxA11yPanelConfigFeature = {
159
176
  * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/a11y/a11y-panel.config.ts
160
177
  * @since 0.1.0
161
178
  */
162
- declare function withA11yPanelLabels(payload: CngxA11yPanelLabelsOverride): CngxA11yPanelConfigFeature;
179
+ declare function withA11yPanelLabels(payload: CngxA11yPanelLabelsOverride | Signal<CngxA11yPanelLabelsOverride>): CngxA11yPanelConfigFeature;
163
180
  /**
164
181
  * Replace the rendered axis list - reorder groups, drop an axis, or restrict
165
182
  * the options a group offers. Supplying a subset renders only those groups.
183
+ * Leave an option's `label` out and it reads the `a11yPanel` section of the
184
+ * language pack, so the options translate without restating the list; pass a
185
+ * `Signal` to relabel options you set yourself on a runtime language switch.
166
186
  *
167
187
  * ```ts
168
188
  * provideA11yPanelConfig(
169
189
  * withA11yPanelAxes([
170
190
  * { axis: 'textScale', reset: 'md', options: [
171
- * { value: 'md', label: 'Default' },
172
- * { value: 'lg', label: 'Large' },
191
+ * { value: 'md' },
192
+ * { value: 'lg', label: 'Bigger' },
173
193
  * ] },
174
194
  * ]),
175
195
  * );
@@ -180,7 +200,7 @@ declare function withA11yPanelLabels(payload: CngxA11yPanelLabelsOverride): Cngx
180
200
  * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/a11y/a11y-panel.config.ts
181
201
  * @since 0.1.0
182
202
  */
183
- declare function withA11yPanelAxes(payload: readonly CngxA11yPanelAxisSpec[]): CngxA11yPanelConfigFeature;
203
+ declare function withA11yPanelAxes(payload: readonly CngxA11yPanelAxisSpec[] | Signal<readonly CngxA11yPanelAxisSpec[]>): CngxA11yPanelConfigFeature;
184
204
  /**
185
205
  * Application-root configuration cascade for the accessibility panel. Pass any
186
206
  * combination of `with*` features in `bootstrapApplication`'s providers;
@@ -234,6 +254,31 @@ declare function provideA11yPanelConfigAt(...features: CngxA11yPanelConfigFeatur
234
254
  * @since 0.1.0
235
255
  */
236
256
  declare function injectA11yPanelConfig(): CngxA11yPanelConfig;
257
+ /**
258
+ * The resolved text bundle of the panel config in scope, as a Signal that
259
+ * follows a runtime language switch: the config overrides over the `a11yPanel`
260
+ * section of the active pack, the `axes` record merged key by key. A key the
261
+ * config leaves unset, `null` or `undefined` reads the section. Runs in an
262
+ * injection context; read it inside a `computed()`, a template or a handler.
263
+ *
264
+ * @category ui/a11y
265
+ * @relatedTo withA11yPanelLabels
266
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/a11y/a11y-panel.config.ts
267
+ * @since 0.1.0
268
+ */
269
+ declare function injectA11yPanelLabels(): Signal<CngxA11yPanelLabels>;
270
+ /**
271
+ * The resolved axis list of the panel config in scope (values, option labels
272
+ * and reset targets), as a Signal that follows a runtime language switch.
273
+ * Every option without its own `label` carries the label for its value from
274
+ * the `a11yPanel` section of the active pack. Runs in an injection context.
275
+ *
276
+ * @category ui/a11y
277
+ * @relatedTo withA11yPanelAxes
278
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/a11y/a11y-panel.config.ts
279
+ * @since 0.1.0
280
+ */
281
+ declare function injectA11yPanelAxes(): Signal<readonly CngxA11yPanelAxisSpec[]>;
237
282
 
238
283
  /**
239
284
  * One rendered axis group, resolved once from the config against the
@@ -284,20 +329,66 @@ interface CngxA11yPanelAxisView {
284
329
  declare class CngxA11yPanel {
285
330
  private readonly announcer;
286
331
  private readonly prefs;
287
- protected readonly config: _cngx_ui_a11y.CngxA11yPanelConfig;
332
+ protected readonly labels: Signal<CngxA11yPanelLabels>;
333
+ private readonly axes;
288
334
  private readonly uid;
289
335
  /**
290
- * The axis groups to render. Resolved once from the config: the axis list is
291
- * static, so this is a plain field (no equality concern). Each view's `value`
292
- * is its own one-axis `computed`, so a change to one axis re-renders only its
293
- * group's bound value, not the whole list.
336
+ * The axis groups to render, rebuilt when the axis list or the labels change
337
+ * so both follow a language switch. A rebuild that yields the same axes,
338
+ * labels and options keeps the previous array. Each view's `value` is the
339
+ * axis preference itself, so picking an option re-renders only that group.
294
340
  */
295
- protected readonly axisViews: readonly CngxA11yPanelAxisView[];
341
+ protected readonly axisViews: Signal<readonly CngxA11yPanelAxisView[]>;
296
342
  private buildAxisViews;
297
343
  protected reset(): void;
298
344
  static ɵfac: i0.ɵɵFactoryDeclaration<CngxA11yPanel, never>;
299
345
  static ɵcmp: i0.ɵɵComponentDeclaration<CngxA11yPanel, "cngx-a11y-panel", never, {}, {}, never, ["[cngxA11yPanelHeader]"], true, never>;
300
346
  }
301
347
 
302
- export { CNGX_A11Y_PANEL_CONFIG, CNGX_A11Y_PANEL_DEFAULTS, CngxA11yPanel, injectA11yPanelConfig, provideA11yPanelConfig, provideA11yPanelConfigAt, withA11yPanelAxes, withA11yPanelLabels };
303
- export type { CngxA11yPanelAxis, CngxA11yPanelAxisOption, CngxA11yPanelAxisSpec, CngxA11yPanelConfig, CngxA11yPanelConfigFeature, CngxA11yPanelLabels, CngxA11yPanelLabelsOverride };
348
+ /**
349
+ * The accessibility-panel section of a {@link CngxLanguagePack}: the copy of
350
+ * `CngxA11yPanel`. The text keys feed the `labels` of `CNGX_A11Y_PANEL_CONFIG`
351
+ * (a key set through `withA11yPanelLabels` still wins); the four option
352
+ * records label the toggle options by value, so an axis list from
353
+ * `withA11yPanelAxes` without option labels reads them from here.
354
+ *
355
+ * @category ui/a11y/i18n
356
+ * @since 0.1.0
357
+ * @relatedTo CNGX_A11Y_PANEL_CONFIG, withA11yPanelLabels, withA11yPanelAxes
358
+ */
359
+ interface CngxA11yPanelLanguageSection {
360
+ /** Default heading, shown when no `[cngxA11yPanelHeader]` slot is projected. */
361
+ readonly heading: string;
362
+ /** Reset control label. */
363
+ readonly reset: string;
364
+ /** Announced when Reset restores every axis. */
365
+ readonly resetMessage: string;
366
+ /** Group label (the accessible name) per axis. */
367
+ readonly axes: Readonly<Record<'density' | 'textScale' | 'motion' | 'contrast', string>>;
368
+ /** Option labels of the spacing group, by value. */
369
+ readonly density: Readonly<Record<CngxDensityValue, string>>;
370
+ /** Option labels of the text-size group, by value. */
371
+ readonly textScale: Readonly<Record<CngxTextScaleValue, string>>;
372
+ /** Option labels of the motion group, by value. */
373
+ readonly motion: Readonly<Record<CngxMotionPreference, string>>;
374
+ /** Option labels of the contrast group, by value. */
375
+ readonly contrast: Readonly<Record<CngxContrastPreference, string>>;
376
+ }
377
+ /**
378
+ * The English accessibility-panel section: the single source of the panel's
379
+ * English copy. The `CNGX_A11Y_PANEL_CONFIG` labels and option labels default
380
+ * to it.
381
+ *
382
+ * @category ui/a11y/i18n
383
+ * @since 0.1.0
384
+ * @relatedTo CNGX_A11Y_PANEL_CONFIG
385
+ */
386
+ declare const CNGX_A11Y_PANEL_LANGUAGE_EN: CngxA11yPanelLanguageSection;
387
+ declare module '@cngx/core/i18n' {
388
+ interface CngxLanguagePack {
389
+ readonly a11yPanel: CngxA11yPanelLanguageSection;
390
+ }
391
+ }
392
+
393
+ export { CNGX_A11Y_PANEL_CONFIG, CNGX_A11Y_PANEL_DEFAULTS, CNGX_A11Y_PANEL_LANGUAGE_EN, CngxA11yPanel, injectA11yPanelAxes, injectA11yPanelConfig, injectA11yPanelLabels, provideA11yPanelConfig, provideA11yPanelConfigAt, withA11yPanelAxes, withA11yPanelLabels };
394
+ export type { CngxA11yPanelAxis, CngxA11yPanelAxisOption, CngxA11yPanelAxisSpec, CngxA11yPanelConfig, CngxA11yPanelConfigFeature, CngxA11yPanelLabels, CngxA11yPanelLabelsOverride, CngxA11yPanelLanguageSection };