@cngx/common 0.0.1-rc.0 → 0.1.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/a11y/README.md +13 -16
- package/card/README.md +2 -21
- package/chart/README.md +5 -8
- package/data/README.md +45 -47
- package/dialog/README.md +12 -15
- package/display/README.md +5 -9
- package/fesm2022/cngx-common-a11y.mjs +164 -51
- package/fesm2022/cngx-common-a11y.mjs.map +1 -1
- package/fesm2022/cngx-common-card.mjs +157 -69
- package/fesm2022/cngx-common-card.mjs.map +1 -1
- package/fesm2022/cngx-common-chart.mjs +389 -92
- package/fesm2022/cngx-common-chart.mjs.map +1 -1
- package/fesm2022/cngx-common-data.mjs +311 -151
- package/fesm2022/cngx-common-data.mjs.map +1 -1
- package/fesm2022/cngx-common-dialog.mjs +167 -29
- package/fesm2022/cngx-common-dialog.mjs.map +1 -1
- package/fesm2022/cngx-common-display.mjs +445 -110
- package/fesm2022/cngx-common-display.mjs.map +1 -1
- package/fesm2022/cngx-common-interactive.mjs +2059 -435
- package/fesm2022/cngx-common-interactive.mjs.map +1 -1
- package/fesm2022/cngx-common-layout.mjs +188 -31
- package/fesm2022/cngx-common-layout.mjs.map +1 -1
- package/fesm2022/cngx-common-popover.mjs +711 -90
- package/fesm2022/cngx-common-popover.mjs.map +1 -1
- package/fesm2022/cngx-common-stepper.mjs +1479 -73
- package/fesm2022/cngx-common-stepper.mjs.map +1 -1
- package/fesm2022/cngx-common-tabs.mjs +1144 -85
- package/fesm2022/cngx-common-tabs.mjs.map +1 -1
- package/fesm2022/cngx-common.mjs +2 -2
- package/fesm2022/cngx-common.mjs.map +1 -1
- package/interactive/README.md +5 -5
- package/layout/README.md +2 -2
- package/package.json +7 -6
- package/popover/README.md +8 -34
- package/stepper/README.md +69 -8
- package/tabs/README.md +6 -6
- package/theming/components/cngx-async.css +74 -0
- package/theming/components/cngx-backdrop.css +73 -0
- package/theming/components/cngx-badge.css +340 -0
- package/theming/components/cngx-bottom-sheet.css +201 -0
- package/theming/components/cngx-button-toggle.css +99 -0
- package/theming/components/cngx-dialog.css +358 -0
- package/theming/components/cngx-divider.css +145 -0
- package/theming/components/cngx-listbox.css +220 -0
- package/theming/components/cngx-menu.css +371 -0
- package/theming/components/cngx-ripple.css +116 -0
- package/theming/components/cngx-tooltip.css +265 -0
- package/theming/system-tokens.css +24 -0
- package/types/cngx-common-a11y.d.ts +159 -38
- package/types/cngx-common-card.d.ts +137 -22
- package/types/cngx-common-chart.d.ts +337 -40
- package/types/cngx-common-data.d.ts +277 -45
- package/types/cngx-common-dialog.d.ts +162 -22
- package/types/cngx-common-display.d.ts +422 -78
- package/types/cngx-common-interactive.d.ts +1880 -305
- package/types/cngx-common-layout.d.ts +191 -28
- package/types/cngx-common-popover.d.ts +632 -87
- package/types/cngx-common-stepper.d.ts +1360 -45
- package/types/cngx-common-tabs.d.ts +1139 -56
- package/types/cngx-common.d.ts +1 -1
- package/README.md +0 -18
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @overview
|
|
3
|
+
* Theming bridge for the `CngxTooltip` directive. The directive
|
|
4
|
+
* renders `<div class="cngx-tooltip">` on demand and toggles
|
|
5
|
+
* transition classes (`cngx-popover--opening` / `-open` / `-closing`)
|
|
6
|
+
* via the underlying `CngxPopover` state machine; this stylesheet
|
|
7
|
+
* paints the pill. Surface defaults to charcoal-on-near-white so it
|
|
8
|
+
* stays neutral and out of the brand-color conversation.
|
|
9
|
+
*
|
|
10
|
+
* **State modifiers**
|
|
11
|
+
*
|
|
12
|
+
* - `cngx-popover--opening` - opacity 0, scale(0.95)
|
|
13
|
+
* - `cngx-popover--open` - opacity 1, scale(1)
|
|
14
|
+
* - `cngx-popover--closing` - opacity 0, scale(0.95)
|
|
15
|
+
*
|
|
16
|
+
* Suppressed under `prefers-reduced-motion: reduce`.
|
|
17
|
+
*
|
|
18
|
+
* **Inheritance**
|
|
19
|
+
*
|
|
20
|
+
* No foundation delegation by design - the tooltip is an inverse
|
|
21
|
+
* surface that intentionally contrasts with the page chrome rather
|
|
22
|
+
* than tracking `--cngx-color-surface`.
|
|
23
|
+
*
|
|
24
|
+
* **Touch devices**
|
|
25
|
+
*
|
|
26
|
+
* `@media (hover: none)` bumps padding, font-size, line-height, and
|
|
27
|
+
* max-width for readability without a per-instance override.
|
|
28
|
+
*
|
|
29
|
+
* **Dark mode**
|
|
30
|
+
*
|
|
31
|
+
* Three hooks (`prefers-color-scheme: dark`, `[data-color-scheme="dark"]`,
|
|
32
|
+
* `.dark`) flip to a light pill on dark text (Material-style
|
|
33
|
+
* inverse-surface) so the tooltip stays as a high-contrast call-out
|
|
34
|
+
* rather than blending into the dark page chrome.
|
|
35
|
+
*
|
|
36
|
+
* **Notes**
|
|
37
|
+
*
|
|
38
|
+
* - The optional `tooltip-indicator.scss` (the `::after` info-icon
|
|
39
|
+
* next to triggers) is a Sass opt-in mixin and ships outside this
|
|
40
|
+
* file.
|
|
41
|
+
* - The pill uses the Popover API top-layer; no z-index needed.
|
|
42
|
+
*
|
|
43
|
+
* **Pair with**
|
|
44
|
+
*
|
|
45
|
+
* - `@cngx/themes/material/tooltip-theme` - Material 3 inverse-surface
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
@layer cngx.tokens {
|
|
49
|
+
/**
|
|
50
|
+
* Tooltip surface color - defaults to a near-black charcoal.
|
|
51
|
+
* @group Surface
|
|
52
|
+
*/
|
|
53
|
+
@property --cngx-tooltip-bg {
|
|
54
|
+
syntax: '<color>';
|
|
55
|
+
inherits: true;
|
|
56
|
+
initial-value: oklch(0.2 0.005 290);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Tooltip text color - defaults to near-white to pair with the
|
|
61
|
+
* default charcoal surface.
|
|
62
|
+
* @group Surface
|
|
63
|
+
*/
|
|
64
|
+
@property --cngx-tooltip-color {
|
|
65
|
+
syntax: '<color>';
|
|
66
|
+
inherits: true;
|
|
67
|
+
initial-value: oklch(0.96 0.005 290);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Font-family stack. Inherits `system-ui` from the foundation.
|
|
72
|
+
* @group Typography
|
|
73
|
+
*/
|
|
74
|
+
@property --cngx-tooltip-font-family {
|
|
75
|
+
syntax: '*';
|
|
76
|
+
inherits: true;
|
|
77
|
+
initial-value: system-ui;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Font-size of the tooltip text.
|
|
82
|
+
* @group Typography
|
|
83
|
+
*/
|
|
84
|
+
@property --cngx-tooltip-font-size {
|
|
85
|
+
syntax: '*';
|
|
86
|
+
inherits: true;
|
|
87
|
+
initial-value: 0.75rem;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Line-height of the tooltip text.
|
|
92
|
+
* @group Typography
|
|
93
|
+
*/
|
|
94
|
+
@property --cngx-tooltip-line-height {
|
|
95
|
+
syntax: '*';
|
|
96
|
+
inherits: true;
|
|
97
|
+
initial-value: 1rem;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Font-weight of the tooltip text.
|
|
102
|
+
* @group Typography
|
|
103
|
+
*/
|
|
104
|
+
@property --cngx-tooltip-font-weight {
|
|
105
|
+
syntax: '<number>';
|
|
106
|
+
inherits: true;
|
|
107
|
+
initial-value: 400;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Letter-spacing - a touch of tracking lifts legibility at the
|
|
112
|
+
* small font-size.
|
|
113
|
+
* @group Typography
|
|
114
|
+
*/
|
|
115
|
+
@property --cngx-tooltip-letter-spacing {
|
|
116
|
+
syntax: '*';
|
|
117
|
+
inherits: true;
|
|
118
|
+
initial-value: 0.033em;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Block-axis padding.
|
|
123
|
+
* @group Layout
|
|
124
|
+
*/
|
|
125
|
+
@property --cngx-tooltip-padding-block {
|
|
126
|
+
syntax: '<length>';
|
|
127
|
+
inherits: false;
|
|
128
|
+
initial-value: 4px;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Inline-axis padding.
|
|
133
|
+
* @group Layout
|
|
134
|
+
*/
|
|
135
|
+
@property --cngx-tooltip-padding-inline {
|
|
136
|
+
syntax: '<length>';
|
|
137
|
+
inherits: false;
|
|
138
|
+
initial-value: 8px;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Corner radius.
|
|
143
|
+
* @group Layout
|
|
144
|
+
*/
|
|
145
|
+
@property --cngx-tooltip-border-radius {
|
|
146
|
+
syntax: '<length>';
|
|
147
|
+
inherits: false;
|
|
148
|
+
initial-value: 4px;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Maximum inline size - caps long tooltip content before it wraps
|
|
153
|
+
* into too narrow a column.
|
|
154
|
+
* @group Layout
|
|
155
|
+
*/
|
|
156
|
+
@property --cngx-tooltip-max-width {
|
|
157
|
+
syntax: '<length>';
|
|
158
|
+
inherits: false;
|
|
159
|
+
initial-value: 200px;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Duration of the open / close transition.
|
|
164
|
+
* @group Motion
|
|
165
|
+
*/
|
|
166
|
+
@property --cngx-tooltip-transition-duration {
|
|
167
|
+
syntax: '<time>';
|
|
168
|
+
inherits: false;
|
|
169
|
+
initial-value: 150ms;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Easing curve of the open / close transition.
|
|
174
|
+
* @group Motion
|
|
175
|
+
*/
|
|
176
|
+
@property --cngx-tooltip-transition-easing {
|
|
177
|
+
syntax: '*';
|
|
178
|
+
inherits: false;
|
|
179
|
+
initial-value: cubic-bezier(0.4, 0, 0.2, 1);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/* Dark-mode swap - flip to inverse-surface (light pill, dark text)
|
|
183
|
+
* so the tooltip pops off the dark page rather than blending into
|
|
184
|
+
* the surrounding chrome at low contrast. */
|
|
185
|
+
@media (prefers-color-scheme: dark) {
|
|
186
|
+
:root:not([data-color-scheme='light']):not(.light) {
|
|
187
|
+
--cngx-tooltip-bg: oklch(0.95 0.005 290);
|
|
188
|
+
--cngx-tooltip-color: oklch(0.2 0.005 290);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
[data-color-scheme='dark'],
|
|
192
|
+
.dark {
|
|
193
|
+
--cngx-tooltip-bg: oklch(0.95 0.005 290);
|
|
194
|
+
--cngx-tooltip-color: oklch(0.2 0.005 290);
|
|
195
|
+
}
|
|
196
|
+
[data-color-scheme='light'],
|
|
197
|
+
.light {
|
|
198
|
+
--cngx-tooltip-bg: oklch(0.2 0.005 290);
|
|
199
|
+
--cngx-tooltip-color: oklch(0.96 0.005 290);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
@layer cngx.components {
|
|
204
|
+
@scope (.cngx-tooltip) {
|
|
205
|
+
:scope {
|
|
206
|
+
position: fixed;
|
|
207
|
+
inset: unset;
|
|
208
|
+
border: none;
|
|
209
|
+
margin: 0;
|
|
210
|
+
box-sizing: border-box;
|
|
211
|
+
|
|
212
|
+
background: var(--cngx-tooltip-bg, oklch(0.2 0.005 290));
|
|
213
|
+
color: var(--cngx-tooltip-color, oklch(0.96 0.005 290));
|
|
214
|
+
font-family: var(--cngx-tooltip-font-family, inherit);
|
|
215
|
+
font-size: var(--cngx-tooltip-font-size, 0.75rem);
|
|
216
|
+
line-height: var(--cngx-tooltip-line-height, 1rem);
|
|
217
|
+
font-weight: var(--cngx-tooltip-font-weight, 400);
|
|
218
|
+
letter-spacing: var(--cngx-tooltip-letter-spacing, 0.033em);
|
|
219
|
+
padding: var(--cngx-tooltip-padding-block, 4px) var(--cngx-tooltip-padding-inline, 8px);
|
|
220
|
+
border-radius: var(--cngx-tooltip-border-radius, 4px);
|
|
221
|
+
max-width: var(--cngx-tooltip-max-width, 200px);
|
|
222
|
+
width: max-content;
|
|
223
|
+
word-wrap: break-word;
|
|
224
|
+
white-space: normal;
|
|
225
|
+
pointer-events: none;
|
|
226
|
+
|
|
227
|
+
/* Popover API top-layer - no z-index needed. */
|
|
228
|
+
transition:
|
|
229
|
+
opacity var(--cngx-tooltip-transition-duration, 150ms)
|
|
230
|
+
var(--cngx-tooltip-transition-easing, cubic-bezier(0.4, 0, 0.2, 1)),
|
|
231
|
+
transform var(--cngx-tooltip-transition-duration, 150ms)
|
|
232
|
+
var(--cngx-tooltip-transition-easing, cubic-bezier(0.4, 0, 0.2, 1));
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
:scope.cngx-popover--opening {
|
|
236
|
+
opacity: 0;
|
|
237
|
+
transform: scale(0.95);
|
|
238
|
+
}
|
|
239
|
+
:scope.cngx-popover--open {
|
|
240
|
+
opacity: 1;
|
|
241
|
+
transform: scale(1);
|
|
242
|
+
}
|
|
243
|
+
:scope.cngx-popover--closing {
|
|
244
|
+
opacity: 0;
|
|
245
|
+
transform: scale(0.95);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/* Touch devices: larger padding + font-size for readability. */
|
|
249
|
+
@media (hover: none) {
|
|
250
|
+
:scope {
|
|
251
|
+
--cngx-tooltip-padding-block: 8px;
|
|
252
|
+
--cngx-tooltip-padding-inline: 16px;
|
|
253
|
+
--cngx-tooltip-font-size: 0.875rem;
|
|
254
|
+
--cngx-tooltip-line-height: 1.25rem;
|
|
255
|
+
--cngx-tooltip-max-width: 280px;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
@media (prefers-reduced-motion: reduce) {
|
|
260
|
+
:scope {
|
|
261
|
+
transition: none;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @overview
|
|
3
|
+
* Domain-specific system tokens for `@cngx/common`. Empty
|
|
4
|
+
* placeholder - the file exists so each lib's `theming/` layer has a
|
|
5
|
+
* canonical home that ng-packagr already ships.
|
|
6
|
+
*
|
|
7
|
+
* **When to populate**
|
|
8
|
+
*
|
|
9
|
+
* Add `@property` declarations here when a token belongs to this
|
|
10
|
+
* lib's domain (atoms and molecules scope: display, interactive,
|
|
11
|
+
* a11y, popover, dialog, card) but isn't tied to a single component.
|
|
12
|
+
*
|
|
13
|
+
* **Inheritance**
|
|
14
|
+
*
|
|
15
|
+
* - System tokens shared across all libs -> `@cngx/core/theming/system-tokens.css`
|
|
16
|
+
* - Per-component tokens -> `<comp>.component.css` next to the component
|
|
17
|
+
* - Per-directive bridges -> `theming/components/<comp>.css`
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
@layer cngx.tokens {
|
|
21
|
+
/* Add @property declarations here when domain-specific system tokens
|
|
22
|
+
* are needed. Empty layer-block is valid CSS and serves as the
|
|
23
|
+
* structural anchor for future additions. */
|
|
24
|
+
}
|
|
@@ -31,6 +31,15 @@ import { ElementRef, InjectionToken, Signal } from '@angular/core';
|
|
|
31
31
|
* }
|
|
32
32
|
* }
|
|
33
33
|
* ```
|
|
34
|
+
*
|
|
35
|
+
* @category common/a11y
|
|
36
|
+
* @docsKind primary
|
|
37
|
+
* @wcag AA
|
|
38
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/aria/aria-expanded.directive.ts
|
|
39
|
+
* @since 0.1.0
|
|
40
|
+
* @relatedTo CngxLiveRegion, CngxExpandable, CngxDisclosure
|
|
41
|
+
* <example-url>http://localhost:4200/#/common/a11y/aria-expanded/accordion-multiple-panels</example-url>
|
|
42
|
+
* <example-url>http://localhost:4200/#/common/a11y/aria-expanded/disclosure-pattern</example-url>
|
|
34
43
|
*/
|
|
35
44
|
declare class CngxAriaExpanded {
|
|
36
45
|
/** Whether the controlled element is currently expanded. Sets `aria-expanded`. */
|
|
@@ -49,11 +58,11 @@ declare class CngxAriaExpanded {
|
|
|
49
58
|
* `assertive` announcements interrupt immediately. `off` disables announcements.
|
|
50
59
|
*
|
|
51
60
|
* Sets `role="alert"` for assertive regions and `role="status"` for polite regions
|
|
52
|
-
* via a host binding
|
|
61
|
+
* via a host binding - no manual attribute wiring needed.
|
|
53
62
|
*
|
|
54
63
|
* Unlike CDK's `LiveAnnouncer` service (which creates a hidden DOM element and
|
|
55
64
|
* requires imperative `announce()` calls), this directive decorates your own
|
|
56
|
-
* element declaratively
|
|
65
|
+
* element declaratively - the content you render IS the announcement.
|
|
57
66
|
*
|
|
58
67
|
* ### Status message
|
|
59
68
|
* ```html
|
|
@@ -69,13 +78,22 @@ declare class CngxAriaExpanded {
|
|
|
69
78
|
* {{ error() }}
|
|
70
79
|
* </div>
|
|
71
80
|
* ```
|
|
81
|
+
*
|
|
82
|
+
* @category common/a11y
|
|
83
|
+
* @docsKind primary
|
|
84
|
+
* @wcag AA
|
|
85
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/aria/live-region.directive.ts
|
|
86
|
+
* @since 0.1.0
|
|
87
|
+
* @relatedTo CngxAriaExpanded
|
|
88
|
+
* <example-url>http://localhost:4200/#/common/a11y/live-region/form-validation-assertive-error-announcements</example-url>
|
|
89
|
+
* <example-url>http://localhost:4200/#/common/a11y/live-region/polite-vs-assertive</example-url>
|
|
72
90
|
*/
|
|
73
91
|
declare class CngxLiveRegion {
|
|
74
92
|
/**
|
|
75
93
|
* Controls the urgency of announcements.
|
|
76
|
-
* - `'polite'`
|
|
77
|
-
* - `'assertive'`
|
|
78
|
-
* - `'off'`
|
|
94
|
+
* - `'polite'` - queued after current speech (default)
|
|
95
|
+
* - `'assertive'` - interrupts immediately
|
|
96
|
+
* - `'off'` - no announcements
|
|
79
97
|
*/
|
|
80
98
|
readonly politeness: _angular_core.InputSignal<"polite" | "assertive" | "off">;
|
|
81
99
|
/** Whether the entire region should be announced as a whole. */
|
|
@@ -112,11 +130,20 @@ declare class CngxLiveRegion {
|
|
|
112
130
|
* ```html
|
|
113
131
|
* <input cngxAutofocus [autofocusDelay]="200" />
|
|
114
132
|
* ```
|
|
133
|
+
*
|
|
134
|
+
* @category common/a11y
|
|
135
|
+
* @docsKind primary
|
|
136
|
+
* @wcag AA
|
|
137
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/focus/autofocus.directive.ts
|
|
138
|
+
* @since 0.1.0
|
|
139
|
+
* @relatedTo CngxFocusRestore, CngxFocusTrap, CngxFocusVisible
|
|
140
|
+
* <example-url>http://localhost:4200/#/common/a11y/autofocus/conditional-focus</example-url>
|
|
141
|
+
* <example-url>http://localhost:4200/#/common/a11y/autofocus/focus-on-insert</example-url>
|
|
115
142
|
*/
|
|
116
143
|
declare class CngxAutofocus {
|
|
117
144
|
/** Whether to focus the element. Defaults to `true` (always focus on render). */
|
|
118
145
|
readonly when: _angular_core.InputSignal<boolean>;
|
|
119
|
-
/** Delay in ms before focusing
|
|
146
|
+
/** Delay in ms before focusing - useful when the element appears during a transition. */
|
|
120
147
|
readonly delay: _angular_core.InputSignal<number>;
|
|
121
148
|
/** `FocusOptions` passed to `element.focus()`. */
|
|
122
149
|
readonly options: _angular_core.InputSignal<FocusOptions>;
|
|
@@ -132,6 +159,22 @@ declare class CngxAutofocus {
|
|
|
132
159
|
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxAutofocus, "[cngxAutofocus]", ["cngxAutofocus"], { "when": { "alias": "cngxAutofocus"; "required": false; "isSignal": true; }; "delay": { "alias": "autofocusDelay"; "required": false; "isSignal": true; }; "options": { "alias": "autofocusOptions"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
133
160
|
}
|
|
134
161
|
|
|
162
|
+
/**
|
|
163
|
+
* CSS selector matching natively-focusable elements: links with an
|
|
164
|
+
* `href`, the enabled form controls, and anything with an explicit
|
|
165
|
+
* non-negative `tabindex`. Form controls carry `:not(:disabled)` because
|
|
166
|
+
* a disabled control is not in the tab order - without it a descendant
|
|
167
|
+
* probe would count a disabled button as focusable and a restore target
|
|
168
|
+
* could land on an unfocusable element. Single source of truth for "is
|
|
169
|
+
* this focusable" - the element-level {@link CngxFocusRestore} predicate
|
|
170
|
+
* matches against it, and descendant probes (e.g. "does this panel
|
|
171
|
+
* contain a focusable child?") query against it. Keeping one selector
|
|
172
|
+
* stops the two uses from drifting apart.
|
|
173
|
+
*
|
|
174
|
+
* @category common/a11y
|
|
175
|
+
* @since 0.1.0
|
|
176
|
+
*/
|
|
177
|
+
declare const CNGX_FOCUSABLE_SELECTOR = "a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])";
|
|
135
178
|
/**
|
|
136
179
|
* Stores the previously focused element and restores focus on destroy.
|
|
137
180
|
*
|
|
@@ -159,6 +202,15 @@ declare class CngxAutofocus {
|
|
|
159
202
|
* </div>
|
|
160
203
|
* <button #fallbackBtn>Fallback target</button>
|
|
161
204
|
* ```
|
|
205
|
+
*
|
|
206
|
+
* @category common/a11y
|
|
207
|
+
* @docsKind primary
|
|
208
|
+
* @wcag AA
|
|
209
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/focus/focus-restore.directive.ts
|
|
210
|
+
* @since 0.1.0
|
|
211
|
+
* @relatedTo CngxAutofocus, CngxFocusTrap, CngxFocusVisible
|
|
212
|
+
* <example-url>http://localhost:4200/#/common/a11y/focus-restore/inline-details</example-url>
|
|
213
|
+
* <example-url>http://localhost:4200/#/common/a11y/focus-restore/panel-with-automatic-restore</example-url>
|
|
162
214
|
*/
|
|
163
215
|
declare class CngxFocusRestore {
|
|
164
216
|
/** Whether to restore focus when the host element is destroyed. */
|
|
@@ -182,7 +234,12 @@ declare class CngxFocusRestore {
|
|
|
182
234
|
private resolveTarget;
|
|
183
235
|
/** Traverses up the DOM tree looking for the first natively focusable element. */
|
|
184
236
|
private findFocusableAncestor;
|
|
185
|
-
/**
|
|
237
|
+
/**
|
|
238
|
+
* Checks if an element is natively focusable (tabindex, links, form
|
|
239
|
+
* controls). Element-level predicate over the shared
|
|
240
|
+
* {@link CNGX_FOCUSABLE_SELECTOR}, so it never drifts from the
|
|
241
|
+
* descendant-query callers.
|
|
242
|
+
*/
|
|
186
243
|
private isFocusable;
|
|
187
244
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxFocusRestore, never>;
|
|
188
245
|
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxFocusRestore, "[cngxFocusRestore]", ["cngxFocusRestore"], { "restoreOnDestroy": { "alias": "restoreOnDestroy"; "required": false; "isSignal": true; }; "fallback": { "alias": "fallback"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
@@ -216,6 +273,15 @@ declare class CngxFocusRestore {
|
|
|
216
273
|
* <a href="/settings">Settings</a>
|
|
217
274
|
* </nav>
|
|
218
275
|
* ```
|
|
276
|
+
*
|
|
277
|
+
* @category common/a11y
|
|
278
|
+
* @docsKind primary
|
|
279
|
+
* @wcag AA
|
|
280
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/focus/focus-trap.directive.ts
|
|
281
|
+
* @since 0.1.0
|
|
282
|
+
* @relatedTo CngxAutofocus, CngxFocusRestore, CngxDialog
|
|
283
|
+
* <example-url>http://localhost:4200/#/common/a11y/focus-trap/modal-dialog</example-url>
|
|
284
|
+
* <example-url>http://localhost:4200/#/common/a11y/focus-trap/slide-out-drawer</example-url>
|
|
219
285
|
*/
|
|
220
286
|
declare class CngxFocusTrap {
|
|
221
287
|
/** Whether the focus trap is active. When `false`, Tab navigates normally. */
|
|
@@ -246,6 +312,15 @@ declare class CngxFocusTrap {
|
|
|
246
312
|
* @if (fv.focusVisible()) { Focus ring visible }
|
|
247
313
|
* </button>
|
|
248
314
|
* ```
|
|
315
|
+
*
|
|
316
|
+
* @category common/a11y
|
|
317
|
+
* @docsKind primary
|
|
318
|
+
* @wcag AA
|
|
319
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/focus/focus-visible.directive.ts
|
|
320
|
+
* @since 0.1.0
|
|
321
|
+
* @relatedTo CngxAutofocus, CngxFocusRestore, CngxFocusTrap
|
|
322
|
+
* <example-url>http://localhost:4200/#/common/a11y/focus-visible/form-fields-custom-focus-ring</example-url>
|
|
323
|
+
* <example-url>http://localhost:4200/#/common/a11y/focus-visible/keyboard-vs-pointer</example-url>
|
|
249
324
|
*/
|
|
250
325
|
declare class CngxFocusVisible {
|
|
251
326
|
private readonly focusVisibleState;
|
|
@@ -275,6 +350,15 @@ declare class CngxFocusVisible {
|
|
|
275
350
|
* <button cngxRovingItem>Three</button>
|
|
276
351
|
* </div>
|
|
277
352
|
* ```
|
|
353
|
+
*
|
|
354
|
+
* @category common/a11y
|
|
355
|
+
* @docsKind primary
|
|
356
|
+
* @wcag AA
|
|
357
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/roving/roving-tabindex.directive.ts
|
|
358
|
+
* @since 0.1.0
|
|
359
|
+
* @relatedTo CngxRovingTabindex, CngxButtonToggle
|
|
360
|
+
* <example-url>http://localhost:4200/#/common/a11y/roving-tabindex/horizontal-toolbar</example-url>
|
|
361
|
+
* <example-url>http://localhost:4200/#/common/a11y/roving-tabindex/vertical-menu</example-url>
|
|
278
362
|
*/
|
|
279
363
|
declare class CngxRovingItem {
|
|
280
364
|
/** @internal Reference used by the parent `CngxRovingTabindex` to set `tabindex`. */
|
|
@@ -289,7 +373,7 @@ declare class CngxRovingItem {
|
|
|
289
373
|
/**
|
|
290
374
|
* Implements the WAI-ARIA roving tabindex pattern for composite widgets.
|
|
291
375
|
*
|
|
292
|
-
* Only the active item in the group has `tabindex="0"`
|
|
376
|
+
* Only the active item in the group has `tabindex="0"` - all others get
|
|
293
377
|
* `tabindex="-1"`. Arrow keys move focus within the group; Tab leaves it.
|
|
294
378
|
* Home/End jump to first/last item.
|
|
295
379
|
*
|
|
@@ -332,10 +416,25 @@ declare class CngxRovingItem {
|
|
|
332
416
|
* }
|
|
333
417
|
* </div>
|
|
334
418
|
* ```
|
|
419
|
+
*
|
|
420
|
+
* @category common/a11y
|
|
421
|
+
* @docsKind primary
|
|
422
|
+
* @wcag AA
|
|
423
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/roving/roving-tabindex.directive.ts
|
|
424
|
+
* @since 0.1.0
|
|
425
|
+
* @relatedTo CngxRovingItem, CngxActiveDescendant
|
|
426
|
+
* <example-url>http://localhost:4200/#/common/a11y/roving-tabindex/horizontal-toolbar</example-url>
|
|
427
|
+
* <example-url>http://localhost:4200/#/common/a11y/roving-tabindex/vertical-menu</example-url>
|
|
335
428
|
*/
|
|
336
429
|
declare class CngxRovingTabindex {
|
|
337
|
-
/**
|
|
338
|
-
|
|
430
|
+
/**
|
|
431
|
+
* Arrow key navigation axis. `'both'` enables both horizontal and
|
|
432
|
+
* vertical arrows. Exposed as a `model` so composite hosts (e.g.
|
|
433
|
+
* `CngxRadioGroup`, where the keyboard axis must always be `'both'`
|
|
434
|
+
* per WAI-ARIA APG regardless of the cosmetic group orientation) can
|
|
435
|
+
* override it from their own constructor.
|
|
436
|
+
*/
|
|
437
|
+
readonly orientation: _angular_core.ModelSignal<"horizontal" | "vertical" | "both">;
|
|
339
438
|
/** Whether navigation wraps from last to first and vice versa. */
|
|
340
439
|
readonly loop: _angular_core.InputSignal<boolean>;
|
|
341
440
|
/** Index of the currently active (focusable) item. Supports two-way `[(activeIndex)]` binding. */
|
|
@@ -369,7 +468,7 @@ declare class CngxRovingTabindex {
|
|
|
369
468
|
* Handles arrow-key, Home, and End navigation within the group.
|
|
370
469
|
* Prevents default scrolling on arrow keys.
|
|
371
470
|
*
|
|
372
|
-
* Unified handler
|
|
471
|
+
* Unified handler - delegates to virtual or contentChildren navigation
|
|
373
472
|
* based on whether `virtualCount` is set.
|
|
374
473
|
*/
|
|
375
474
|
protected handleKeyDown(event: KeyboardEvent): void;
|
|
@@ -379,7 +478,7 @@ declare class CngxRovingTabindex {
|
|
|
379
478
|
*/
|
|
380
479
|
private focusVirtualItem;
|
|
381
480
|
/**
|
|
382
|
-
* Finds the next index in virtual mode. No disabled-item skipping
|
|
481
|
+
* Finds the next index in virtual mode. No disabled-item skipping - can't check
|
|
383
482
|
* disabled state of items not in the DOM.
|
|
384
483
|
*/
|
|
385
484
|
private findNextVirtual;
|
|
@@ -388,14 +487,14 @@ declare class CngxRovingTabindex {
|
|
|
388
487
|
private isVertical;
|
|
389
488
|
/**
|
|
390
489
|
* Searches for the next enabled item starting from `current + direction`.
|
|
391
|
-
* Respects `loop`
|
|
490
|
+
* Respects `loop` - wraps around or stops at the boundary.
|
|
392
491
|
* Skips disabled items.
|
|
393
492
|
*/
|
|
394
493
|
private findNext;
|
|
395
494
|
private findFirst;
|
|
396
495
|
private findLast;
|
|
397
496
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxRovingTabindex, never>;
|
|
398
|
-
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxRovingTabindex, "[cngxRovingTabindex]", ["cngxRovingTabindex"], { "orientation": { "alias": "orientation"; "required": false; "isSignal": true; }; "loop": { "alias": "loop"; "required": false; "isSignal": true; }; "activeIndex": { "alias": "activeIndex"; "required": false; "isSignal": true; }; "virtualCount": { "alias": "virtualCount"; "required": false; "isSignal": true; }; }, { "activeIndex": "activeIndexChange"; }, ["items"], never, true, never>;
|
|
497
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxRovingTabindex, "[cngxRovingTabindex]", ["cngxRovingTabindex"], { "orientation": { "alias": "orientation"; "required": false; "isSignal": true; }; "loop": { "alias": "loop"; "required": false; "isSignal": true; }; "activeIndex": { "alias": "activeIndex"; "required": false; "isSignal": true; }; "virtualCount": { "alias": "virtualCount"; "required": false; "isSignal": true; }; }, { "orientation": "orientationChange"; "activeIndex": "activeIndexChange"; }, ["items"], never, true, never>;
|
|
399
498
|
}
|
|
400
499
|
|
|
401
500
|
/**
|
|
@@ -403,9 +502,11 @@ declare class CngxRovingTabindex {
|
|
|
403
502
|
*
|
|
404
503
|
* `id` must be unique and stable across change detection runs (use `nextUid()`
|
|
405
504
|
* from `@cngx/core/utils`). `label` is used by typeahead matching.
|
|
505
|
+
*
|
|
506
|
+
* @category common/a11y
|
|
406
507
|
*/
|
|
407
508
|
interface ActiveDescendantItem {
|
|
408
|
-
/** Unique DOM `id` on the element
|
|
509
|
+
/** Unique DOM `id` on the element - required for `aria-activedescendant`. */
|
|
409
510
|
readonly id: string;
|
|
410
511
|
/** Opaque value emitted on `activated`. Compared with `Object.is` by default. */
|
|
411
512
|
readonly value: unknown;
|
|
@@ -425,13 +526,20 @@ interface ActiveDescendantItem {
|
|
|
425
526
|
* ```
|
|
426
527
|
*
|
|
427
528
|
* The contained directive must expose `id`, `value`, `label`, and optionally
|
|
428
|
-
* `disabled` as signals
|
|
529
|
+
* `disabled` as signals - the AD reads them reactively.
|
|
530
|
+
*
|
|
531
|
+
* @category common/a11y
|
|
532
|
+
* @wcag AA
|
|
533
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/active-descendant/ad-item.token.ts
|
|
534
|
+
* @since 0.1.0
|
|
429
535
|
*/
|
|
430
536
|
declare const CNGX_AD_ITEM: InjectionToken<CngxAdItemHandle>;
|
|
431
537
|
/**
|
|
432
538
|
* Minimum shape an AD-registered directive must expose.
|
|
433
539
|
*
|
|
434
540
|
* The shape is signal-based so the AD recomputes when any field changes.
|
|
541
|
+
*
|
|
542
|
+
* @category common/a11y
|
|
435
543
|
*/
|
|
436
544
|
interface CngxAdItemHandle {
|
|
437
545
|
readonly id: string;
|
|
@@ -445,44 +553,49 @@ interface CngxAdItemHandle {
|
|
|
445
553
|
}
|
|
446
554
|
|
|
447
555
|
/**
|
|
448
|
-
*
|
|
449
|
-
*
|
|
450
|
-
* option is communicated via `aria-activedescendant`.
|
|
556
|
+
* WAI-ARIA active-descendant pattern. Focus stays on the host; the active
|
|
557
|
+
* option is reported via `aria-activedescendant`.
|
|
451
558
|
*
|
|
452
559
|
* ### When to use this vs. `CngxRovingTabindex`
|
|
453
560
|
*
|
|
454
|
-
* - **Active-descendant** when focus
|
|
455
|
-
*
|
|
456
|
-
*
|
|
457
|
-
*
|
|
458
|
-
*
|
|
459
|
-
* tab list, grid cells). See `CngxRovingTabindex`.
|
|
561
|
+
* - **Active-descendant** when focus stays on one container (listbox, menu,
|
|
562
|
+
* combobox input) and items must not be tab-stops. Screen readers announce
|
|
563
|
+
* the referenced option while the focus ring stays on the host.
|
|
564
|
+
* - **Roving tabindex** when items themselves are tab-stops (toolbar, tab
|
|
565
|
+
* list, grid cells). See `CngxRovingTabindex`.
|
|
460
566
|
*
|
|
461
567
|
* ### Item registration
|
|
462
568
|
*
|
|
463
|
-
* Items register either by providing `CNGX_AD_ITEM` via `hostDirectives`
|
|
569
|
+
* Items register either by providing `CNGX_AD_ITEM` via `hostDirectives` /
|
|
464
570
|
* `providers`, or by passing a `Signal<ActiveDescendantItem[]>` through the
|
|
465
|
-
* `items` input. The
|
|
466
|
-
*
|
|
571
|
+
* `items` input. The `items` input wins when both are present; use it when
|
|
572
|
+
* items come from a dynamic data source.
|
|
467
573
|
*
|
|
468
574
|
* ### Virtualization
|
|
469
575
|
*
|
|
470
|
-
* When `virtualCount` is set, navigation
|
|
471
|
-
*
|
|
472
|
-
*
|
|
473
|
-
* `clearPendingHighlight()`.
|
|
576
|
+
* When `virtualCount` is set, navigation can address indices not currently
|
|
577
|
+
* in the DOM. `pendingHighlight` tells the consumer to scroll the missing
|
|
578
|
+
* item into view; the consumer calls `clearPendingHighlight()` afterwards.
|
|
474
579
|
*
|
|
475
580
|
* ### Material/CDK equivalent
|
|
476
581
|
*
|
|
477
|
-
*
|
|
478
|
-
*
|
|
479
|
-
*
|
|
582
|
+
* Same model as `cdk-listbox` and `mat-select`, without the visual shell and
|
|
583
|
+
* driven by signals instead of `ListKeyManager`.
|
|
584
|
+
*
|
|
585
|
+
* @category common/a11y
|
|
586
|
+
* @docsKind primary
|
|
587
|
+
* @wcag AA
|
|
588
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/active-descendant/active-descendant.directive.ts
|
|
589
|
+
* @since 0.1.0
|
|
590
|
+
* @relatedTo CngxRovingTabindex, CngxListbox, CngxMenu
|
|
591
|
+
* <example-url>http://localhost:4200/#/common/a11y/active-descendant/listbox-with-items-input</example-url>
|
|
592
|
+
* <example-url>http://localhost:4200/#/common/a11y/active-descendant/typeahead</example-url>
|
|
480
593
|
*/
|
|
481
594
|
declare class CngxActiveDescendant {
|
|
482
595
|
/**
|
|
483
596
|
* Optional explicit item list. When provided, takes precedence over items
|
|
484
597
|
* registered via `CNGX_AD_ITEM`. Useful for combobox-style consumers that
|
|
485
|
-
* drive the menu from a dynamic data source
|
|
598
|
+
* drive the menu from a dynamic data source - pass the unwrapped array
|
|
486
599
|
* (typically the result of a `computed()`), Angular's signal inputs make it
|
|
487
600
|
* reactive automatically.
|
|
488
601
|
*/
|
|
@@ -584,7 +697,7 @@ declare class CngxActiveDescendant {
|
|
|
584
697
|
*
|
|
585
698
|
* Adds the `cngx-reduced-motion` CSS class to the host when the user prefers
|
|
586
699
|
* reduced motion. The `prefersReducedMotion()` signal updates live when the
|
|
587
|
-
* OS preference changes
|
|
700
|
+
* OS preference changes - use it in TypeScript to skip animations, disable
|
|
588
701
|
* auto-playing media, or choose between animated and instant transitions.
|
|
589
702
|
*
|
|
590
703
|
* Unlike a CSS-only `@media (prefers-reduced-motion: reduce)` approach, this
|
|
@@ -603,6 +716,14 @@ declare class CngxActiveDescendant {
|
|
|
603
716
|
* readonly rm = viewChild(CngxReducedMotion);
|
|
604
717
|
* readonly duration = computed(() => this.rm()?.prefersReducedMotion() ? 0 : 300);
|
|
605
718
|
* ```
|
|
719
|
+
*
|
|
720
|
+
* @category common/a11y
|
|
721
|
+
* @docsKind primary
|
|
722
|
+
* @wcag AA
|
|
723
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/motion/reduced-motion.directive.ts
|
|
724
|
+
* @since 0.1.0
|
|
725
|
+
* <example-url>http://localhost:4200/#/common/a11y/reduced-motion/animation-toggle</example-url>
|
|
726
|
+
* <example-url>http://localhost:4200/#/common/a11y/reduced-motion/toast-notifications-motion-aware</example-url>
|
|
606
727
|
*/
|
|
607
728
|
declare class CngxReducedMotion {
|
|
608
729
|
/** `true` when the user's OS is set to prefer reduced motion. Updates reactively. */
|
|
@@ -612,5 +733,5 @@ declare class CngxReducedMotion {
|
|
|
612
733
|
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxReducedMotion, "[cngxReducedMotion]", ["cngxReducedMotion"], {}, {}, never, never, true, never>;
|
|
613
734
|
}
|
|
614
735
|
|
|
615
|
-
export { CNGX_AD_ITEM, CngxActiveDescendant, CngxAriaExpanded, CngxAutofocus, CngxFocusRestore, CngxFocusTrap, CngxFocusVisible, CngxLiveRegion, CngxReducedMotion, CngxRovingItem, CngxRovingTabindex };
|
|
736
|
+
export { CNGX_AD_ITEM, CNGX_FOCUSABLE_SELECTOR, CngxActiveDescendant, CngxAriaExpanded, CngxAutofocus, CngxFocusRestore, CngxFocusTrap, CngxFocusVisible, CngxLiveRegion, CngxReducedMotion, CngxRovingItem, CngxRovingTabindex };
|
|
616
737
|
export type { ActiveDescendantItem, CngxAdItemHandle };
|