@cngx/common 0.1.0-rc.3 → 0.1.0-rc.5

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 (43) hide show
  1. package/audio/README.md +180 -0
  2. package/display/README.md +1 -0
  3. package/fesm2022/cngx-common-a11y.mjs +123 -3
  4. package/fesm2022/cngx-common-a11y.mjs.map +1 -1
  5. package/fesm2022/cngx-common-audio.mjs +1205 -0
  6. package/fesm2022/cngx-common-audio.mjs.map +1 -0
  7. package/fesm2022/cngx-common-card.mjs +8 -8
  8. package/fesm2022/cngx-common-card.mjs.map +1 -1
  9. package/fesm2022/cngx-common-chart.mjs +2 -2
  10. package/fesm2022/cngx-common-chart.mjs.map +1 -1
  11. package/fesm2022/cngx-common-data.mjs +996 -55
  12. package/fesm2022/cngx-common-data.mjs.map +1 -1
  13. package/fesm2022/cngx-common-display.mjs +320 -8
  14. package/fesm2022/cngx-common-display.mjs.map +1 -1
  15. package/fesm2022/cngx-common-interactive.mjs +1633 -80
  16. package/fesm2022/cngx-common-interactive.mjs.map +1 -1
  17. package/fesm2022/cngx-common-layout.mjs +187 -3
  18. package/fesm2022/cngx-common-layout.mjs.map +1 -1
  19. package/fesm2022/cngx-common-popover.mjs +63 -8
  20. package/fesm2022/cngx-common-popover.mjs.map +1 -1
  21. package/fesm2022/cngx-common.mjs +1 -1
  22. package/interactive/README.md +101 -0
  23. package/layout/README.md +39 -1
  24. package/package.json +5 -1
  25. package/theming/components/cngx-accordion.css +147 -0
  26. package/theming/components/cngx-badge.css +6 -0
  27. package/theming/components/cngx-bottom-sheet.css +8 -1
  28. package/theming/components/cngx-breadcrumb.css +108 -0
  29. package/theming/components/cngx-button-toggle.css +6 -0
  30. package/theming/components/cngx-data-grid.css +154 -0
  31. package/theming/components/cngx-dialog.css +4 -0
  32. package/theming/components/cngx-divider.css +4 -0
  33. package/theming/components/cngx-listbox.css +6 -0
  34. package/theming/components/cngx-menu.css +7 -0
  35. package/theming/components/cngx-slider.css +237 -0
  36. package/theming/components/cngx-tooltip.css +6 -0
  37. package/types/cngx-common-a11y.d.ts +67 -2
  38. package/types/cngx-common-audio.d.ts +736 -0
  39. package/types/cngx-common-data.d.ts +632 -22
  40. package/types/cngx-common-display.d.ts +189 -1
  41. package/types/cngx-common-interactive.d.ts +1028 -31
  42. package/types/cngx-common-layout.d.ts +88 -3
  43. package/types/cngx-common-popover.d.ts +25 -4
@@ -269,6 +269,9 @@
269
269
 
270
270
  @layer cngx.components {
271
271
  [cngxMenu] {
272
+ /* Derive container padding from the global scale (SET-from-scale rule; the
273
+ registered pixel initial defeats the use-site fallback). 4 -> xs. */
274
+ --cngx-menu-padding: var(--cngx-space-xs);
272
275
  list-style: none;
273
276
  margin: 0;
274
277
  padding: var(--cngx-menu-padding, 4px);
@@ -285,6 +288,10 @@
285
288
  [cngxMenuItemCheckbox],
286
289
  [cngxMenuItemRadio],
287
290
  [cngxMenuItemSubmenu] {
291
+ /* Derive item gap + padding from the global scale (SET-from-scale rule).
292
+ gap 8 -> sm; padding 6/10 -> xs/sm (10 -> 8). Read on this element. */
293
+ --cngx-menu-item-gap: var(--cngx-space-sm);
294
+ --cngx-menu-item-padding: var(--cngx-space-xs) var(--cngx-space-sm);
288
295
  display: flex;
289
296
  align-items: center;
290
297
  gap: var(--cngx-menu-item-gap, 8px);
@@ -0,0 +1,237 @@
1
+ /**
2
+ * @overview
3
+ * Default skin for the headless `cngxSliderTrack` / `cngxRangeSliderTrack`
4
+ * directives. (The finished `<cngx-slider>` / `<cngx-range-slider>` components
5
+ * ship their own Track-A styles.) The directive paints `role="slider"`, the
6
+ * ARIA value surface, and publishes the thumb position as the inherited custom
7
+ * property `--cngx-slider-fraction` (0..1). This stylesheet turns that fraction
8
+ * into a track, a fill, and a draggable thumb. Without it the host renders as a
9
+ * bare focusable box.
10
+ *
11
+ * Markup the default skin expects (BEM classes are opt-in - bring your own and
12
+ * read `--cngx-slider-fraction` yourself for a custom skin):
13
+ *
14
+ * ```html
15
+ * <div cngxSliderTrack class="cngx-slider" [(value)]="v">
16
+ * <span class="cngx-slider__track"><span class="cngx-slider__fill"></span></span>
17
+ * <span class="cngx-slider__thumb"></span>
18
+ * </div>
19
+ * ```
20
+ *
21
+ * `--cngx-slider-fraction` is intentionally NOT registered as an `@property`:
22
+ * it is a runtime position the directive sets on the host (single) or on each
23
+ * thumb element (range), and it must inherit to the fill / thumb descendants.
24
+ * Only the themeable tokens below are registered.
25
+ *
26
+ * **Inheritance**
27
+ *
28
+ * - track / fill colour -> `--cngx-color-border` / `--cngx-color-primary`
29
+ * - thumb fill -> `--cngx-color-surface`, border -> `--cngx-color-primary`
30
+ * - focus ring -> `--cngx-color-primary` (contrast >= 3:1 against the surface)
31
+ */
32
+
33
+ @layer cngx.tokens {
34
+ /* Colour tokens (track / fill / thumb / thumb-border / focus-ring / tick) are
35
+ * intentionally NOT registered as `@property`: a registered custom property
36
+ * always resolves to its initial-value, which would shadow the dark-aware
37
+ * foundation fallback (`var(--cngx-slider-*-color, var(--cngx-color-*, …))`)
38
+ * and freeze the slider in light mode. Leaving them unregistered lets the
39
+ * fallback chain reach `--cngx-color-border` / `--cngx-color-primary` /
40
+ * `--cngx-color-surface`, which adapt to colour-scheme. Only geometry tokens
41
+ * (dark-mode-agnostic) are registered below. */
42
+
43
+ /**
44
+ * Thickness of the slider track (and fill).
45
+ * @group Track
46
+ */
47
+ @property --cngx-slider-track-size {
48
+ syntax: '<length>';
49
+ inherits: true;
50
+ initial-value: 4px;
51
+ }
52
+
53
+ /**
54
+ * Diameter of the thumb.
55
+ * @group Thumb
56
+ */
57
+ @property --cngx-slider-thumb-size {
58
+ syntax: '<length>';
59
+ inherits: true;
60
+ initial-value: 16px;
61
+ }
62
+
63
+ /**
64
+ * Thumb border stroke width.
65
+ * @group Thumb
66
+ */
67
+ @property --cngx-slider-thumb-border-width {
68
+ syntax: '<length>';
69
+ inherits: true;
70
+ initial-value: 2px;
71
+ }
72
+
73
+ /**
74
+ * Focus-ring stroke width.
75
+ * @group State / Focus
76
+ */
77
+ @property --cngx-slider-focus-ring-width {
78
+ syntax: '<length>';
79
+ inherits: true;
80
+ initial-value: 2px;
81
+ }
82
+
83
+ /**
84
+ * Length of a vertical slider (a vertical track has no intrinsic extent).
85
+ * Ignored in the default horizontal orientation.
86
+ * @group Track
87
+ */
88
+ @property --cngx-slider-length {
89
+ syntax: '<length>';
90
+ inherits: true;
91
+ initial-value: 9rem;
92
+ }
93
+ }
94
+
95
+ @layer cngx.components {
96
+ :is([cngxSliderTrack], [cngxRangeSliderTrack]) {
97
+ position: relative;
98
+ display: inline-flex;
99
+ align-items: center;
100
+ box-sizing: border-box;
101
+ inline-size: 100%;
102
+ min-block-size: var(--cngx-slider-thumb-size, 16px);
103
+ cursor: pointer;
104
+ }
105
+
106
+ :is([cngxSliderTrack], [cngxRangeSliderTrack])[aria-disabled='true'] {
107
+ opacity: 0.5;
108
+ cursor: not-allowed;
109
+ }
110
+
111
+ :is([cngxSliderTrack], [cngxRangeSliderTrack]) .cngx-slider__track {
112
+ position: relative;
113
+ flex: 1 1 auto;
114
+ block-size: var(--cngx-slider-track-size, 4px);
115
+ border-radius: 999px;
116
+ background: var(--cngx-slider-track-color, var(--cngx-color-border, oklch(0.88 0.005 250)));
117
+ }
118
+
119
+ /* Single-thumb fill: track start to the thumb. The host carries the
120
+ * fraction, so the fill spans `fraction * 100%`. */
121
+ :is([cngxSliderTrack]) .cngx-slider__fill {
122
+ position: absolute;
123
+ inset-block: 0;
124
+ inset-inline-start: 0;
125
+ inline-size: calc(var(--cngx-slider-fraction, 0) * 100%);
126
+ border-radius: inherit;
127
+ background: var(--cngx-slider-fill-color, var(--cngx-color-primary, oklch(0.66 0.19 50)));
128
+ }
129
+
130
+ /* Range fill: the band between the two thumbs. The range host publishes
131
+ * `--cngx-slider-start-fraction` / `--cngx-slider-end-fraction`, so a single
132
+ * gradient on the track paints track-fill-track with no extra element. */
133
+ [cngxRangeSliderTrack] .cngx-slider__track {
134
+ background: linear-gradient(
135
+ to right,
136
+ var(--cngx-slider-track-color, var(--cngx-color-border, oklch(0.88 0.005 250))) 0,
137
+ var(--cngx-slider-track-color, var(--cngx-color-border, oklch(0.88 0.005 250)))
138
+ calc(var(--cngx-slider-start-fraction, 0) * 100%),
139
+ var(--cngx-slider-fill-color, var(--cngx-color-primary, oklch(0.66 0.19 50)))
140
+ calc(var(--cngx-slider-start-fraction, 0) * 100%),
141
+ var(--cngx-slider-fill-color, var(--cngx-color-primary, oklch(0.66 0.19 50)))
142
+ calc(var(--cngx-slider-end-fraction, 1) * 100%),
143
+ var(--cngx-slider-track-color, var(--cngx-color-border, oklch(0.88 0.005 250)))
144
+ calc(var(--cngx-slider-end-fraction, 1) * 100%)
145
+ );
146
+ }
147
+
148
+ /* Single-thumb handle: positioned from the host fraction. */
149
+ :is([cngxSliderTrack]) .cngx-slider__thumb {
150
+ position: absolute;
151
+ inset-block-start: 50%;
152
+ inset-inline-start: calc(var(--cngx-slider-fraction, 0) * 100%);
153
+ inline-size: var(--cngx-slider-thumb-size, 16px);
154
+ block-size: var(--cngx-slider-thumb-size, 16px);
155
+ border-radius: 50%;
156
+ background: var(--cngx-slider-thumb-color, var(--cngx-color-surface, oklch(1 0 0)));
157
+ border: var(--cngx-slider-thumb-border-width, 2px) solid
158
+ var(--cngx-slider-thumb-border-color, var(--cngx-color-primary, oklch(0.66 0.19 50)));
159
+ translate: -50% -50%;
160
+ }
161
+
162
+ /* Range thumbs ARE the `[cngxSliderThumb]` elements - each carries its
163
+ * own fraction, so it positions itself directly. */
164
+ [cngxSliderThumb] {
165
+ position: absolute;
166
+ inset-block-start: 50%;
167
+ inset-inline-start: calc(var(--cngx-slider-fraction, 0) * 100%);
168
+ inline-size: var(--cngx-slider-thumb-size, 16px);
169
+ block-size: var(--cngx-slider-thumb-size, 16px);
170
+ border-radius: 50%;
171
+ background: var(--cngx-slider-thumb-color, var(--cngx-color-surface, oklch(1 0 0)));
172
+ border: var(--cngx-slider-thumb-border-width, 2px) solid
173
+ var(--cngx-slider-thumb-border-color, var(--cngx-color-primary, oklch(0.66 0.19 50)));
174
+ translate: -50% -50%;
175
+ cursor: grab;
176
+ }
177
+
178
+ /* Focus ring on the focusable element: the single-slider host's thumb,
179
+ * or each range thumb. >= 3:1 contrast via the primary token. */
180
+ [cngxSliderTrack]:focus-visible {
181
+ outline: none;
182
+ }
183
+ [cngxSliderTrack]:focus-visible .cngx-slider__thumb,
184
+ [cngxSliderThumb]:focus-visible {
185
+ outline: var(--cngx-slider-focus-ring-width, 2px) solid
186
+ var(--cngx-slider-focus-ring-color, var(--cngx-color-primary, oklch(0.66 0.19 50)));
187
+ outline-offset: 2px;
188
+ }
189
+
190
+ /* Vertical orientation: the brain emits aria-orientation="vertical" and its
191
+ * pointer math measures bottom-up, so the skin anchors the fill + thumb to the
192
+ * track's lower edge. The host needs an explicit length (no intrinsic height). */
193
+ :is([cngxSliderTrack], [cngxRangeSliderTrack])[aria-orientation='vertical'] {
194
+ flex-direction: column;
195
+ inline-size: max-content;
196
+ min-inline-size: var(--cngx-slider-thumb-size, 16px);
197
+ block-size: var(--cngx-slider-length, 9rem);
198
+ min-block-size: 0;
199
+ }
200
+
201
+ :is([cngxSliderTrack], [cngxRangeSliderTrack])[aria-orientation='vertical']
202
+ .cngx-slider__track {
203
+ flex: 1 1 auto;
204
+ inline-size: var(--cngx-slider-track-size, 4px);
205
+ block-size: auto;
206
+ }
207
+
208
+ [cngxSliderTrack][aria-orientation='vertical'] .cngx-slider__fill {
209
+ inset-inline: 0;
210
+ inset-block: auto 0;
211
+ inline-size: 100%;
212
+ block-size: calc(var(--cngx-slider-fraction, 0) * 100%);
213
+ }
214
+
215
+ [cngxRangeSliderTrack][aria-orientation='vertical'] .cngx-slider__track {
216
+ background: linear-gradient(
217
+ to top,
218
+ var(--cngx-slider-track-color, var(--cngx-color-border, oklch(0.88 0.005 250))) 0,
219
+ var(--cngx-slider-track-color, var(--cngx-color-border, oklch(0.88 0.005 250)))
220
+ calc(var(--cngx-slider-start-fraction, 0) * 100%),
221
+ var(--cngx-slider-fill-color, var(--cngx-color-primary, oklch(0.66 0.19 50)))
222
+ calc(var(--cngx-slider-start-fraction, 0) * 100%),
223
+ var(--cngx-slider-fill-color, var(--cngx-color-primary, oklch(0.66 0.19 50)))
224
+ calc(var(--cngx-slider-end-fraction, 1) * 100%),
225
+ var(--cngx-slider-track-color, var(--cngx-color-border, oklch(0.88 0.005 250)))
226
+ calc(var(--cngx-slider-end-fraction, 1) * 100%)
227
+ );
228
+ }
229
+
230
+ [cngxSliderTrack][aria-orientation='vertical'] .cngx-slider__thumb,
231
+ [cngxRangeSliderTrack][aria-orientation='vertical'] [cngxSliderThumb] {
232
+ inset-inline-start: 50%;
233
+ inset-block-start: auto;
234
+ inset-block-end: calc(var(--cngx-slider-fraction, 0) * 100%);
235
+ translate: -50% 50%;
236
+ }
237
+ }
@@ -216,6 +216,12 @@
216
216
  line-height: var(--cngx-tooltip-line-height, 1rem);
217
217
  font-weight: var(--cngx-tooltip-font-weight, 400);
218
218
  letter-spacing: var(--cngx-tooltip-letter-spacing, 0.033em);
219
+ /* Derive the default padding from the global scale (SET-from-scale rule;
220
+ the registered pixel initial defeats the use-site fallback). Read on the
221
+ host. padding-block 4 -> xs; padding-inline 8 -> sm. The @media
222
+ (hover:none) touch override below keeps its larger literal. */
223
+ --cngx-tooltip-padding-block: var(--cngx-space-xs);
224
+ --cngx-tooltip-padding-inline: var(--cngx-space-sm);
219
225
  padding: var(--cngx-tooltip-padding-block, 4px) var(--cngx-tooltip-padding-inline, 8px);
220
226
  border-radius: var(--cngx-tooltip-border-radius, 4px);
221
227
  max-width: var(--cngx-tooltip-max-width, 200px);
@@ -1,5 +1,5 @@
1
1
  import * as _angular_core from '@angular/core';
2
- import { ElementRef, InjectionToken, Signal } from '@angular/core';
2
+ import { OnDestroy, ElementRef, InjectionToken, Signal } from '@angular/core';
3
3
 
4
4
  /**
5
5
  * Manages `aria-expanded` and optionally `aria-controls` on the host element.
@@ -104,6 +104,55 @@ declare class CngxLiveRegion {
104
104
  static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxLiveRegion, "[cngxLiveRegion]", ["cngxLiveRegion"], { "politeness": { "alias": "politeness"; "required": false; "isSignal": true; }; "atomic": { "alias": "atomic"; "required": false; "isSignal": true; }; "relevant": { "alias": "relevant"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
105
105
  }
106
106
 
107
+ /**
108
+ * Imperative, reusable polite/assertive live-region announcer.
109
+ *
110
+ * The imperative counterpart to {@link CngxLiveRegion}: where the directive
111
+ * decorates an element you render (the content IS the announcement), this
112
+ * service owns a single visually-hidden `aria-live` element appended to
113
+ * `document.body` and exposes an `announce(message)` call for template-less
114
+ * directives and event handlers (e.g. `CngxCopyValue` copy success,
115
+ * `CngxOtpInput` completion).
116
+ *
117
+ * One root element is created lazily on the first announcement and reused for
118
+ * every subsequent call. The text is cleared and re-set on the next macrotask
119
+ * so an identical consecutive message is still re-read by the screen reader.
120
+ *
121
+ * SSR-safe: all DOM access is guarded by `isPlatformBrowser`; on the server
122
+ * `announce()` is a no-op and no element is created.
123
+ *
124
+ * ```typescript
125
+ * const announcer = inject(CngxLiveAnnouncer);
126
+ * announcer.announce('Copied');
127
+ * announcer.announce('Save failed', 'assertive');
128
+ * ```
129
+ *
130
+ * @category common/a11y
131
+ * @docsKind primary
132
+ * @wcag AA
133
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/aria/live-announcer.ts
134
+ * @since 0.1.0
135
+ * @relatedTo CngxLiveRegion
136
+ */
137
+ declare class CngxLiveAnnouncer implements OnDestroy {
138
+ private readonly doc;
139
+ private readonly isBrowser;
140
+ private region;
141
+ private pending;
142
+ /**
143
+ * Announces `message` through the shared live region.
144
+ *
145
+ * @param message Text read by the screen reader.
146
+ * @param politeness `'polite'` (default) queues after the current
147
+ * utterance; `'assertive'` interrupts immediately.
148
+ */
149
+ announce(message: string, politeness?: 'polite' | 'assertive'): void;
150
+ ngOnDestroy(): void;
151
+ private ensureRegion;
152
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxLiveAnnouncer, never>;
153
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<CngxLiveAnnouncer>;
154
+ }
155
+
107
156
  /**
108
157
  * Reactive autofocus for dynamically inserted elements.
109
158
  *
@@ -452,6 +501,13 @@ declare class CngxRovingTabindex {
452
501
  /** Host element for `data-cngx-recycle-index` queries in virtual mode. */
453
502
  private readonly hostEl;
454
503
  private readonly pendingFocusState;
504
+ /**
505
+ * Set true just before a navigation key (arrow / Home / End) moves focus to a
506
+ * new item, cleared by {@link consumeNavigationKey}. Transient handshake, not
507
+ * reactive state: consumer groups read it synchronously from the
508
+ * newly-focused leaf's `(focus)` handler.
509
+ */
510
+ private navigationKeyInFlight;
455
511
  /**
456
512
  * Index of the item that should receive focus but is not currently in the DOM.
457
513
  * Non-null when virtual navigation targets an out-of-range item.
@@ -464,6 +520,15 @@ declare class CngxRovingTabindex {
464
520
  * after the item has been scrolled into view and focused.
465
521
  */
466
522
  clearPendingFocus(): void;
523
+ /**
524
+ * Whether the last focus move was driven by a navigation key, consuming the
525
+ * flag so it reads `true` exactly once. Consumer groups (radio,
526
+ * button-toggle) call this from the newly-focused leaf's `(focus)` handler to
527
+ * decide whether to auto-select. The flag is set before `.focus()`, so it is
528
+ * already `true` when focus lands - this closes the one-press-behind race
529
+ * that a group's own `(keydown)` binding suffered (#135).
530
+ */
531
+ consumeNavigationKey(): boolean;
467
532
  /**
468
533
  * Handles arrow-key, Home, and End navigation within the group.
469
534
  * Prevents default scrolling on arrow keys.
@@ -733,5 +798,5 @@ declare class CngxReducedMotion {
733
798
  static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxReducedMotion, "[cngxReducedMotion]", ["cngxReducedMotion"], {}, {}, never, never, true, never>;
734
799
  }
735
800
 
736
- export { CNGX_AD_ITEM, CNGX_FOCUSABLE_SELECTOR, CngxActiveDescendant, CngxAriaExpanded, CngxAutofocus, CngxFocusRestore, CngxFocusTrap, CngxFocusVisible, CngxLiveRegion, CngxReducedMotion, CngxRovingItem, CngxRovingTabindex };
801
+ export { CNGX_AD_ITEM, CNGX_FOCUSABLE_SELECTOR, CngxActiveDescendant, CngxAriaExpanded, CngxAutofocus, CngxFocusRestore, CngxFocusTrap, CngxFocusVisible, CngxLiveAnnouncer, CngxLiveRegion, CngxReducedMotion, CngxRovingItem, CngxRovingTabindex };
737
802
  export type { ActiveDescendantItem, CngxAdItemHandle };