@cngx/common 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/card/README.md +2 -1
- package/chart/README.md +85 -0
- package/command/README.md +157 -0
- package/data/README.md +33 -1
- package/dialog/README.md +23 -1
- package/fesm2022/cngx-common-a11y.mjs +356 -180
- package/fesm2022/cngx-common-a11y.mjs.map +1 -1
- package/fesm2022/cngx-common-audio.mjs +84 -42
- package/fesm2022/cngx-common-audio.mjs.map +1 -1
- package/fesm2022/cngx-common-card.mjs +311 -53
- package/fesm2022/cngx-common-card.mjs.map +1 -1
- package/fesm2022/cngx-common-chart.mjs +4360 -1625
- package/fesm2022/cngx-common-chart.mjs.map +1 -1
- package/fesm2022/cngx-common-command.mjs +171 -0
- package/fesm2022/cngx-common-command.mjs.map +1 -0
- package/fesm2022/cngx-common-data.mjs +1556 -616
- package/fesm2022/cngx-common-data.mjs.map +1 -1
- package/fesm2022/cngx-common-dialog.mjs +518 -112
- package/fesm2022/cngx-common-dialog.mjs.map +1 -1
- package/fesm2022/cngx-common-display.mjs +468 -87
- package/fesm2022/cngx-common-display.mjs.map +1 -1
- package/fesm2022/cngx-common-interactive.mjs +2725 -1303
- package/fesm2022/cngx-common-interactive.mjs.map +1 -1
- package/fesm2022/cngx-common-layout.mjs +943 -164
- package/fesm2022/cngx-common-layout.mjs.map +1 -1
- package/fesm2022/cngx-common-popover.mjs +769 -103
- package/fesm2022/cngx-common-popover.mjs.map +1 -1
- package/fesm2022/cngx-common-stepper.mjs +816 -348
- package/fesm2022/cngx-common-stepper.mjs.map +1 -1
- package/fesm2022/cngx-common-tabs.mjs +2330 -1554
- package/fesm2022/cngx-common-tabs.mjs.map +1 -1
- package/fesm2022/cngx-common-timeline.mjs +1170 -0
- package/fesm2022/cngx-common-timeline.mjs.map +1 -0
- package/fesm2022/cngx-common.mjs +2 -2
- package/fesm2022/cngx-common.mjs.map +1 -1
- package/interactive/README.md +15 -4
- package/layout/README.md +21 -1
- package/package.json +11 -1
- package/popover/README.md +18 -2
- package/stepper/README.md +7 -5
- package/theming/components/cngx-accordion.css +4 -1
- package/theming/components/cngx-backdrop.css +12 -0
- package/theming/components/cngx-badge.css +22 -0
- package/theming/components/cngx-bottom-sheet.css +14 -2
- package/theming/components/cngx-breadcrumb.css +8 -0
- package/theming/components/cngx-button-toggle.css +73 -5
- package/theming/components/cngx-data-grid.css +234 -1
- package/theming/components/cngx-dialog.css +25 -0
- package/theming/components/cngx-divider.css +12 -0
- package/theming/components/cngx-listbox.css +48 -12
- package/theming/components/cngx-menu.css +91 -15
- package/theming/components/cngx-popover.css +24 -0
- package/theming/components/cngx-recycler-placeholder.css +196 -0
- package/theming/components/cngx-ripple.css +2 -2
- package/theming/components/cngx-slider.css +32 -1
- package/theming/components/cngx-tooltip.css +23 -0
- package/timeline/README.md +155 -0
- package/types/cngx-common-a11y.d.ts +101 -31
- package/types/cngx-common-audio.d.ts +32 -32
- package/types/cngx-common-card.d.ts +211 -20
- package/types/cngx-common-chart.d.ts +1605 -169
- package/types/cngx-common-command.d.ts +190 -0
- package/types/cngx-common-data.d.ts +842 -163
- package/types/cngx-common-dialog.d.ts +372 -28
- package/types/cngx-common-display.d.ts +432 -148
- package/types/cngx-common-interactive.d.ts +1553 -370
- package/types/cngx-common-layout.d.ts +613 -27
- package/types/cngx-common-popover.d.ts +376 -36
- package/types/cngx-common-stepper.d.ts +414 -114
- package/types/cngx-common-tabs.d.ts +597 -72
- package/types/cngx-common-timeline.d.ts +1125 -0
- package/types/cngx-common.d.ts +1 -1
|
@@ -5,7 +5,7 @@ import { injectMediaQuery } from '@cngx/common/layout';
|
|
|
5
5
|
import { CNGX_STATEFUL, createTransitionTracker } from '@cngx/core/utils';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Library defaults
|
|
8
|
+
* Library defaults - English, browser-native.
|
|
9
9
|
* @category common/audio
|
|
10
10
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/audio/config/audio-config.ts
|
|
11
11
|
* @since 0.1.0
|
|
@@ -45,7 +45,7 @@ function injectAudioConfig() {
|
|
|
45
45
|
/**
|
|
46
46
|
* Fold a `with*` feature list into a single partial config.
|
|
47
47
|
*
|
|
48
|
-
* @internal
|
|
48
|
+
* @internal - shared by {@link provideCngxAudio} and `provideCngxAudioAt`;
|
|
49
49
|
* not exported from `public-api.ts`.
|
|
50
50
|
*/
|
|
51
51
|
function foldAudioFeatures(features) {
|
|
@@ -56,7 +56,7 @@ function foldAudioFeatures(features) {
|
|
|
56
56
|
return config;
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
|
-
* Register global audio defaults. Mirrors `provideFeedback`
|
|
59
|
+
* Register global audio defaults. Mirrors `provideFeedback` - a single small
|
|
60
60
|
* config object folded through `with*` features.
|
|
61
61
|
*
|
|
62
62
|
* ```ts
|
|
@@ -73,7 +73,7 @@ function foldAudioFeatures(features) {
|
|
|
73
73
|
* Register this at **application bootstrap**. The shared engine is
|
|
74
74
|
* `providedIn: 'root'` and reads its configuration once, when it is first built,
|
|
75
75
|
* so config registered in a lazy route's `providers` never reaches it. To
|
|
76
|
-
* configure a subtree, use `provideCngxAudioAt(...)` in `viewProviders`
|
|
76
|
+
* configure a subtree, use `provideCngxAudioAt(...)` in `viewProviders` - it
|
|
77
77
|
* layers over this one and re-provides the engine so the scope actually applies.
|
|
78
78
|
*
|
|
79
79
|
* @category common/audio
|
|
@@ -148,14 +148,14 @@ const GESTURE_EVENTS = ['pointerdown', 'keydown', 'touchstart'];
|
|
|
148
148
|
* `AudioContext`, honouring the browser autoplay policy without a permission
|
|
149
149
|
* prompt.
|
|
150
150
|
*
|
|
151
|
-
* Pure factory
|
|
151
|
+
* Pure factory - takes its `target` and `destroyRef` as arguments rather than
|
|
152
152
|
* calling `inject()`, so it composes inside the engine's injection context yet
|
|
153
153
|
* stays testable with a fake target. No DI token: the gate has no independent
|
|
154
154
|
* swap consumer (severity ladder `concern: over-abstraction`), so it ships
|
|
155
155
|
* token-less and the engine owns it.
|
|
156
156
|
*
|
|
157
157
|
* @param deps.target The event target to listen on (typically the `Document`).
|
|
158
|
-
* @param deps.destroyRef Cleanup owner
|
|
158
|
+
* @param deps.destroyRef Cleanup owner - removes any surviving listeners on destroy.
|
|
159
159
|
* @category common/audio
|
|
160
160
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/audio/autoplay-gate/autoplay-gate.ts
|
|
161
161
|
* @since 0.1.0
|
|
@@ -193,13 +193,13 @@ const DEFAULT_WINDOW_MS = 100;
|
|
|
193
193
|
/**
|
|
194
194
|
* Per-name time-window debouncer: suppresses repeated fires of the same earcon
|
|
195
195
|
* within `windowMs`. A separate composed factory rather than logic buried in
|
|
196
|
-
* the engine (Pillar 3). Plain factory, no DI token
|
|
196
|
+
* the engine (Pillar 3). Plain factory, no DI token - `withDebounceMs` covers
|
|
197
197
|
* configuration and there is no independent swap consumer.
|
|
198
198
|
*
|
|
199
199
|
* `windowMs` accepts a getter so a caller whose window is a reactive input can
|
|
200
200
|
* hold ONE debouncer instance for its lifetime and still track changes: the
|
|
201
201
|
* window is resolved per `shouldFire` call, not captured at construction. That
|
|
202
|
-
* keeps the (stateful) debouncer out of the signal graph
|
|
202
|
+
* keeps the (stateful) debouncer out of the signal graph - minting one inside a
|
|
203
203
|
* `computed` would return a fresh object per evaluation and break the equality
|
|
204
204
|
* rule. `CngxAudioPitch` is the getter consumer; the engine passes a number.
|
|
205
205
|
*
|
|
@@ -239,7 +239,7 @@ function createDebouncer(options) {
|
|
|
239
239
|
}
|
|
240
240
|
|
|
241
241
|
/**
|
|
242
|
-
* The six built-in earcons, synthesised entirely from `OscillatorNode`
|
|
242
|
+
* The six built-in earcons, synthesised entirely from `OscillatorNode` - zero
|
|
243
243
|
* audio assets. Plain `as const` (mirrors `CNGX_SELECT_GLYPHS`): tree-shakeable,
|
|
244
244
|
* compile-time exhaustive keys, and NOT exported from `public-api.ts`. The
|
|
245
245
|
* consumer override surface is `withEarcons({...})` and the engine's runtime
|
|
@@ -257,7 +257,7 @@ const CNGX_AUDIO_DEFAULT_EARCONS = {
|
|
|
257
257
|
{ freq: 880, duration: 120 },
|
|
258
258
|
],
|
|
259
259
|
},
|
|
260
|
-
/** Falling sawtooth pair for a failure
|
|
260
|
+
/** Falling sawtooth pair for a failure - deliberately harsher. */
|
|
261
261
|
error: {
|
|
262
262
|
sequence: [
|
|
263
263
|
{ freq: 400, duration: 100, type: 'sawtooth', gain: 0.15 },
|
|
@@ -288,9 +288,9 @@ const CNGX_AUDIO_DEFAULT_EARCONS = {
|
|
|
288
288
|
},
|
|
289
289
|
};
|
|
290
290
|
|
|
291
|
-
/** Attack ramp, seconds
|
|
291
|
+
/** Attack ramp, seconds - lifts gain from 0 so the oscillator start is click-free. */
|
|
292
292
|
const ATTACK_SEC = 0.005;
|
|
293
|
-
/** Release ramp, seconds
|
|
293
|
+
/** Release ramp, seconds - drops gain to 0 before stop so the end is click-free. */
|
|
294
294
|
const RELEASE_SEC = 0.03;
|
|
295
295
|
/** A tone shorter than attack+release cannot host both ramps; clamp up to this floor. */
|
|
296
296
|
const MIN_DURATION_SEC = ATTACK_SEC + RELEASE_SEC;
|
|
@@ -304,7 +304,7 @@ const MIN_DURATION_SEC = ATTACK_SEC + RELEASE_SEC;
|
|
|
304
304
|
*/
|
|
305
305
|
const DEFAULT_TONE_GAIN = 0.2;
|
|
306
306
|
/**
|
|
307
|
-
* Pure `OscillatorNode` synthesis
|
|
307
|
+
* Pure `OscillatorNode` synthesis - no audio assets. Each tone is an
|
|
308
308
|
* oscillator through a per-note gain envelope (5 ms attack, 30 ms release)
|
|
309
309
|
* into the engine's master-volume node. The envelope is not decoration: a
|
|
310
310
|
* bare `start()`/`stop()` on a full-amplitude oscillator produces an audible
|
|
@@ -359,7 +359,7 @@ const createToneGenerator = (deps) => {
|
|
|
359
359
|
/**
|
|
360
360
|
* Swappable tone-generator factory. Defaults to {@link createToneGenerator}
|
|
361
361
|
* (oscillator synthesis). Override to swap in sample-based playback without
|
|
362
|
-
* forking the engine
|
|
362
|
+
* forking the engine - the documented second consumer of this boundary token.
|
|
363
363
|
*
|
|
364
364
|
* @relatedTo createToneGenerator, CNGX_AUDIO_ENGINE_FACTORY
|
|
365
365
|
* @category common/audio
|
|
@@ -371,6 +371,30 @@ const CNGX_AUDIO_TONE_GENERATOR_FACTORY = new InjectionToken('CngxAudioToneGener
|
|
|
371
371
|
function clampVolume(v) {
|
|
372
372
|
return Math.max(0, Math.min(1, v));
|
|
373
373
|
}
|
|
374
|
+
/**
|
|
375
|
+
* Map a raw `AudioContext.state` onto {@link AudioStatus}. Safari reports a
|
|
376
|
+
* non-standard `'interrupted'` (phone call, Siri, audio-route change) that the
|
|
377
|
+
* spec union does not carry; it resumes on the next gesture exactly like a
|
|
378
|
+
* suspended context, so it folds to `'suspended'` rather than being cast into
|
|
379
|
+
* the union. Any unknown value degrades to `'suspended'`, the safe resting
|
|
380
|
+
* state a subsequent `resume()` can lift.
|
|
381
|
+
*/
|
|
382
|
+
function mapAudioStatus(state) {
|
|
383
|
+
switch (state) {
|
|
384
|
+
case 'running':
|
|
385
|
+
return 'running';
|
|
386
|
+
case 'closed':
|
|
387
|
+
return 'closed';
|
|
388
|
+
case 'suspended':
|
|
389
|
+
case 'interrupted':
|
|
390
|
+
default:
|
|
391
|
+
return 'suspended';
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
/** A context that a `resume()` can lift - suspended, or Safari's interrupted. */
|
|
395
|
+
function isSuspendedLike(state) {
|
|
396
|
+
return state === 'suspended' || state === 'interrupted';
|
|
397
|
+
}
|
|
374
398
|
/**
|
|
375
399
|
* Apply a per-call `[0, 1]` scale to a tone's peak gain. Centralised here so
|
|
376
400
|
* every play path (`play` / `tone` / `sequence`) scales identically and an
|
|
@@ -417,6 +441,9 @@ const createAudioEngine = (options) => {
|
|
|
417
441
|
const gate = createAutoplayGate({ target: doc, destroyRef });
|
|
418
442
|
const debouncer = createDebouncer({ windowMs: config.debounceMs });
|
|
419
443
|
const earcons = new Map(Object.entries({ ...CNGX_AUDIO_DEFAULT_EARCONS, ...config.earcons }));
|
|
444
|
+
// Dev-only: an unknown earcon name is a fixed authoring mistake, so warn once
|
|
445
|
+
// per name rather than on every (debounced) play attempt.
|
|
446
|
+
const warnedUnknownEarcons = new Set();
|
|
420
447
|
let context = null;
|
|
421
448
|
let masterGain = null;
|
|
422
449
|
const contextFactory = options?.contextFactory ??
|
|
@@ -429,9 +456,19 @@ const createAudioEngine = (options) => {
|
|
|
429
456
|
context: () => context,
|
|
430
457
|
destination: () => masterGain,
|
|
431
458
|
});
|
|
459
|
+
// Single source of truth for `status`: the context's own statechange event.
|
|
460
|
+
// Browser-initiated transitions the page never requested (Safari interrupt,
|
|
461
|
+
// OS suspend) flow through here too, and because resume()/suspend() land
|
|
462
|
+
// their result via this listener there is no manual status write left to
|
|
463
|
+
// race - a stale resume resolution cannot clobber a later suspend.
|
|
464
|
+
const onStateChange = () => {
|
|
465
|
+
if (context) {
|
|
466
|
+
status.set(mapAudioStatus(context.state));
|
|
467
|
+
}
|
|
468
|
+
};
|
|
432
469
|
function resumeIfArmed() {
|
|
433
|
-
if (context && gate.armed() && context.state
|
|
434
|
-
void context.resume().
|
|
470
|
+
if (context && gate.armed() && isSuspendedLike(context.state)) {
|
|
471
|
+
void context.resume().catch(() => undefined);
|
|
435
472
|
}
|
|
436
473
|
}
|
|
437
474
|
function ensureContext() {
|
|
@@ -447,14 +484,17 @@ const createAudioEngine = (options) => {
|
|
|
447
484
|
masterGain = created.createGain();
|
|
448
485
|
masterGain.gain.value = volume();
|
|
449
486
|
masterGain.connect(created.destination);
|
|
450
|
-
|
|
487
|
+
// Born in its current state - no statechange fires for the initial value,
|
|
488
|
+
// so seed it directly; every later transition arrives via onStateChange.
|
|
489
|
+
status.set(mapAudioStatus(created.state));
|
|
490
|
+
created.addEventListener('statechange', onStateChange);
|
|
451
491
|
resumeIfArmed();
|
|
452
492
|
return context;
|
|
453
493
|
}
|
|
454
494
|
function blocked() {
|
|
455
495
|
return muted() || (config.respectReducedMotion && reducedMotion()) || !gate.armed();
|
|
456
496
|
}
|
|
457
|
-
// Volume is communicated to the master node reactively
|
|
497
|
+
// Volume is communicated to the master node reactively - the single writer is
|
|
458
498
|
// setVolume(), but binding through an effect keeps the node in sync from any
|
|
459
499
|
// future volume source too.
|
|
460
500
|
effect(() => {
|
|
@@ -470,7 +510,7 @@ const createAudioEngine = (options) => {
|
|
|
470
510
|
}
|
|
471
511
|
if (doc.hidden) {
|
|
472
512
|
if (context.state === 'running') {
|
|
473
|
-
void context.suspend().
|
|
513
|
+
void context.suspend().catch(() => undefined);
|
|
474
514
|
}
|
|
475
515
|
}
|
|
476
516
|
else {
|
|
@@ -480,6 +520,7 @@ const createAudioEngine = (options) => {
|
|
|
480
520
|
doc.addEventListener('visibilitychange', onVisibility);
|
|
481
521
|
destroyRef.onDestroy(() => {
|
|
482
522
|
doc.removeEventListener('visibilitychange', onVisibility);
|
|
523
|
+
context?.removeEventListener('statechange', onStateChange);
|
|
483
524
|
// close() rejects on an already-closed context; swallow it so a double
|
|
484
525
|
// destroy does not surface an unhandled rejection.
|
|
485
526
|
const closing = context?.close?.();
|
|
@@ -499,7 +540,8 @@ const createAudioEngine = (options) => {
|
|
|
499
540
|
}
|
|
500
541
|
const earcon = earcons.get(name);
|
|
501
542
|
if (!earcon) {
|
|
502
|
-
if (isDevMode()) {
|
|
543
|
+
if (isDevMode() && !warnedUnknownEarcons.has(name)) {
|
|
544
|
+
warnedUnknownEarcons.add(name);
|
|
503
545
|
console.warn(`[cngxAudio] Unknown earcon "${name}". Register it via withEarcons({...}) or engine.register(name, config).`);
|
|
504
546
|
}
|
|
505
547
|
return;
|
|
@@ -542,7 +584,7 @@ const createAudioEngine = (options) => {
|
|
|
542
584
|
};
|
|
543
585
|
/**
|
|
544
586
|
* Swappable engine factory. Defaults to {@link createAudioEngine}. Override to
|
|
545
|
-
* wrap the engine with telemetry/audit logging
|
|
587
|
+
* wrap the engine with telemetry/audit logging - the documented second consumer
|
|
546
588
|
* of this boundary token.
|
|
547
589
|
*
|
|
548
590
|
* Register the override at **application bootstrap**. The shared engine instance
|
|
@@ -564,9 +606,9 @@ const CNGX_AUDIO_ENGINE_FACTORY = new InjectionToken('CngxAudioEngineFactory', {
|
|
|
564
606
|
/**
|
|
565
607
|
* The shared engine instance. Lazily built from `CNGX_AUDIO_ENGINE_FACTORY` and
|
|
566
608
|
* memoised per injector so every directive shares one `AudioContext`, mute
|
|
567
|
-
* state, and volume. `@internal`
|
|
609
|
+
* state, and volume. `@internal` - the public entry point is {@link injectCngxAudio};
|
|
568
610
|
* consumers override the swappable factory, not this instance anchor. To scope
|
|
569
|
-
* audio to a subtree, use {@link provideCngxAudioAt}
|
|
611
|
+
* audio to a subtree, use {@link provideCngxAudioAt} - it re-provides this token
|
|
570
612
|
* for you alongside the scoped config.
|
|
571
613
|
*
|
|
572
614
|
* @internal
|
|
@@ -597,7 +639,7 @@ function injectCngxAudio() {
|
|
|
597
639
|
return inject(CNGX_AUDIO_ENGINE);
|
|
598
640
|
}
|
|
599
641
|
/**
|
|
600
|
-
* Component-scope audio config
|
|
642
|
+
* Component-scope audio config - place in a component's `viewProviders` so a
|
|
601
643
|
* subtree runs its own muted / volume / earcon set, independent of the app-wide
|
|
602
644
|
* `provideCngxAudio(...)`.
|
|
603
645
|
*
|
|
@@ -616,19 +658,19 @@ function injectCngxAudio() {
|
|
|
616
658
|
* registered on a lazy route never reaches it.
|
|
617
659
|
*
|
|
618
660
|
* Features **layer over** the ancestor config (root, or an enclosing scope)
|
|
619
|
-
* rather than replacing it
|
|
661
|
+
* rather than replacing it - the `provideMenuConfigAt` pattern. Scalar fields
|
|
620
662
|
* (`muted`, `volume`, `debounceMs`, `respectReducedMotion`) override; `earcons`
|
|
621
663
|
* merge, so a subtree adds or overrides individual earcons without dropping the
|
|
622
664
|
* app-wide registry.
|
|
623
665
|
*
|
|
624
666
|
* The default shared engine is a single, process-global `AudioContext`; this
|
|
625
667
|
* deliberately re-provides {@link CNGX_AUDIO_ENGINE} so the subtree gets an
|
|
626
|
-
* **isolated engine** reading the scoped {@link CNGX_AUDIO_CONFIG}
|
|
668
|
+
* **isolated engine** reading the scoped {@link CNGX_AUDIO_CONFIG} - a
|
|
627
669
|
* config-only override would be inert against the already-built root engine.
|
|
628
670
|
* That engine owns a **second `AudioContext`**, created lazily on its first play
|
|
629
671
|
* and closed with the component's `DestroyRef`. Browsers cap the number of live
|
|
630
672
|
* `AudioContext`s, so reach for this only when a subtree genuinely needs an
|
|
631
|
-
* independent audio scope
|
|
673
|
+
* independent audio scope - per-element `[audioVolume]` / `[audioDisabled]`
|
|
632
674
|
* cover the common case without a second context.
|
|
633
675
|
*
|
|
634
676
|
* @category common/audio
|
|
@@ -659,7 +701,7 @@ function provideCngxAudioAt(...features) {
|
|
|
659
701
|
* parsed bindings are identical (the signal-hygiene Equality Rule). Same size,
|
|
660
702
|
* same value per key.
|
|
661
703
|
*
|
|
662
|
-
* @internal
|
|
704
|
+
* @internal - not exported from `public-api.ts`.
|
|
663
705
|
*/
|
|
664
706
|
function sameStringMap(a, b) {
|
|
665
707
|
if (a.size !== b.size) {
|
|
@@ -699,7 +741,7 @@ const DOM_EVENT_SET$1 = new Set(CNGX_AUDIO_DOM_EVENTS);
|
|
|
699
741
|
const LIFECYCLE_SET = new Set(LIFECYCLE_KEYS);
|
|
700
742
|
/**
|
|
701
743
|
* Parse the `event:earcon` grammar (`'click:tap, focus:notification'`) into a
|
|
702
|
-
* DOM-event map. Pure
|
|
744
|
+
* DOM-event map. Pure - no DOM, no `inject()`. Keys are categorised so the
|
|
703
745
|
* directive can dev-warn on unknown earcon keys and, separately, on lifecycle
|
|
704
746
|
* keys that should have used `[cngxAudioStatus]`.
|
|
705
747
|
*/
|
|
@@ -736,7 +778,7 @@ function parseEventBindings(spec) {
|
|
|
736
778
|
|
|
737
779
|
/**
|
|
738
780
|
* Event-mode audio binder. Maps DOM events on the host to earcons via the
|
|
739
|
-
* `event:earcon` grammar
|
|
781
|
+
* `event:earcon` grammar - a pure DOM-event-to-sound directive with no state
|
|
740
782
|
* coupling (that is `[cngxAudioStatus]`'s job).
|
|
741
783
|
*
|
|
742
784
|
* ```html
|
|
@@ -824,7 +866,7 @@ class CngxAudio {
|
|
|
824
866
|
if (this.bound.has(type)) {
|
|
825
867
|
continue;
|
|
826
868
|
}
|
|
827
|
-
// Captures the type only
|
|
869
|
+
// Captures the type only - the earcon is read fresh at fire time, so
|
|
828
870
|
// renaming it in the grammar needs no rebind.
|
|
829
871
|
const listener = () => this.handleEvent(type);
|
|
830
872
|
// Not passive: none of the bindable types are scroll-blocking, so the
|
|
@@ -891,7 +933,7 @@ const CNGX_AUDIO_STATUS_DOM_EVENTS = [
|
|
|
891
933
|
const DOM_EVENT_SET = new Set(CNGX_AUDIO_STATUS_DOM_EVENTS);
|
|
892
934
|
/**
|
|
893
935
|
* Parse the `status:earcon` grammar (`'pending:tap, succeeded:success'`) into a
|
|
894
|
-
* status map. Pure
|
|
936
|
+
* status map. Pure - no DOM, no `inject()`. Keys are categorised so the
|
|
895
937
|
* directive can dev-error on DOM-event keys that should have used `[cngxAudio]`
|
|
896
938
|
* and dev-warn on unknown keys. `succeeded`/`failed` normalise to
|
|
897
939
|
* `success`/`error` so a lookup by the tracker's raw `AsyncStatus` hits.
|
|
@@ -930,7 +972,7 @@ function parseStatusBindings(spec) {
|
|
|
930
972
|
|
|
931
973
|
/**
|
|
932
974
|
* Status-mode audio bridge. Maps `CngxAsyncState` lifecycle transitions to
|
|
933
|
-
* earcons via the `status:earcon` grammar
|
|
975
|
+
* earcons via the `status:earcon` grammar - the audition counterpart of
|
|
934
976
|
* `CngxToastOn`. Fires only on a real status transition, never on the initial
|
|
935
977
|
* `idle`, and at most once per transition.
|
|
936
978
|
*
|
|
@@ -945,7 +987,7 @@ function parseStatusBindings(spec) {
|
|
|
945
987
|
*
|
|
946
988
|
* The state source resolves the same way the feedback bridges do: an explicit
|
|
947
989
|
* `[state]` input wins, otherwise it falls back to an ancestor's
|
|
948
|
-
* `CNGX_STATEFUL`. The grammar keys are lifecycle statuses only
|
|
990
|
+
* `CNGX_STATEFUL`. The grammar keys are lifecycle statuses only - DOM-event
|
|
949
991
|
* keys (`click`, `focus`, …) belong to `[cngxAudio]` and are rejected with a
|
|
950
992
|
* dev-error. `succeeded`/`failed` are accepted as aliases for `success`/`error`.
|
|
951
993
|
*
|
|
@@ -963,7 +1005,7 @@ class CngxAudioStatus {
|
|
|
963
1005
|
/** The `status:earcon` grammar, e.g. `'pending:tap, succeeded:success'`. */
|
|
964
1006
|
spec = input('', { ...(ngDevMode ? { debugName: "spec" } : /* istanbul ignore next */ {}), alias: 'cngxAudioStatus' });
|
|
965
1007
|
/**
|
|
966
|
-
* The async state to watch. Optional
|
|
1008
|
+
* The async state to watch. Optional - when omitted, the bridge falls back to
|
|
967
1009
|
* an ancestor `CNGX_STATEFUL`. A bare `[state]` attribute (empty string) is
|
|
968
1010
|
* treated as "no input bound" so the fallback kicks in.
|
|
969
1011
|
*/
|
|
@@ -972,7 +1014,7 @@ class CngxAudioStatus {
|
|
|
972
1014
|
audioVolume = input(undefined, ...(ngDevMode ? [{ debugName: "audioVolume" }] : /* istanbul ignore next */ []));
|
|
973
1015
|
/** Suppress this element's audio without unbinding. */
|
|
974
1016
|
audioDisabled = input(false, { ...(ngDevMode ? { debugName: "audioDisabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
975
|
-
/** Effective state
|
|
1017
|
+
/** Effective state - explicit input wins over ancestor `CNGX_STATEFUL`. */
|
|
976
1018
|
effectiveState = computed(() => this.state() ?? this.statefulFallback?.state, ...(ngDevMode ? [{ debugName: "effectiveState" }] : /* istanbul ignore next */ []));
|
|
977
1019
|
bindings = computed(() => parseStatusBindings(this.spec()).bindings, { ...(ngDevMode ? { debugName: "bindings" } : /* istanbul ignore next */ {}), equal: sameStringMap });
|
|
978
1020
|
constructor() {
|
|
@@ -1021,7 +1063,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1021
1063
|
|
|
1022
1064
|
/**
|
|
1023
1065
|
* Zone-mode audio binder. Plays earcons as the pointer or keyboard focus enters
|
|
1024
|
-
* and leaves the host
|
|
1066
|
+
* and leaves the host - a spatial complement to `[cngxAudio]`. The record input
|
|
1025
1067
|
* makes the four zone transitions explicit rather than encoding them in the
|
|
1026
1068
|
* `event:earcon` string grammar, because the listener set (pointer/focus zone)
|
|
1027
1069
|
* and the shape (record vs string) are semantically distinct from event-mode.
|
|
@@ -1055,7 +1097,7 @@ class CngxAudioZone {
|
|
|
1055
1097
|
/**
|
|
1056
1098
|
* `focusin`/`focusout` bubble, so a zone wrapping focusable children would
|
|
1057
1099
|
* otherwise fire on every internal tab move. Only a crossing of the zone
|
|
1058
|
-
* boundary counts
|
|
1100
|
+
* boundary counts - the focus counterpart of pointerenter/pointerleave.
|
|
1059
1101
|
*/
|
|
1060
1102
|
handleFocusCross(kind, event) {
|
|
1061
1103
|
if (this.host.nativeElement.contains(event.relatedTarget)) {
|
|
@@ -1089,13 +1131,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1089
1131
|
}]
|
|
1090
1132
|
}], propDecorators: { zone: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxAudioZone", required: false }] }], audioVolume: [{ type: i0.Input, args: [{ isSignal: true, alias: "audioVolume", required: false }] }], audioDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "audioDisabled", required: false }] }] } });
|
|
1091
1133
|
|
|
1092
|
-
/** Throttle key
|
|
1134
|
+
/** Throttle key - the pitch directive plays a single ad-hoc voice. */
|
|
1093
1135
|
const PITCH_VOICE = 'pitch';
|
|
1094
1136
|
/**
|
|
1095
1137
|
* Pitch-mode audio binder. Sonifies a continuous numeric value: each change of
|
|
1096
1138
|
* `[cngxAudioPitch]` clamps against a fixed domain, linear-scales into an output
|
|
1097
1139
|
* frequency range, and plays a short tone. Useful for sliders, gauges, and live
|
|
1098
|
-
* metrics
|
|
1140
|
+
* metrics - the ear tracks a value without looking.
|
|
1099
1141
|
*
|
|
1100
1142
|
* ```html
|
|
1101
1143
|
* <input type="range" min="0" max="100"
|
|
@@ -1105,7 +1147,7 @@ const PITCH_VOICE = 'pitch';
|
|
|
1105
1147
|
* ```
|
|
1106
1148
|
*
|
|
1107
1149
|
* The inputs are discrete rather than an options record so `[cngxAudioPitch]`
|
|
1108
|
-
* stays a native reactive input
|
|
1150
|
+
* stays a native reactive input - passing `[cngxAudioPitch]="volume()"` binds a
|
|
1109
1151
|
* signal value directly, never a `Signal` smuggled inside a config object. The
|
|
1110
1152
|
* domain is caller-supplied and fixed; it is never accumulated from observed
|
|
1111
1153
|
* values, so the directive holds no hidden state. Value-to-frequency is a pure
|
|
@@ -1192,7 +1234,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1192
1234
|
* Web Audio adapter: zero asset weight (earcons synthesised from
|
|
1193
1235
|
* `OscillatorNode`), a single shared `AudioContext` behind the engine, and
|
|
1194
1236
|
* the `provideCngxAudio(...)` aggregator. Mirrors the shape of the sibling
|
|
1195
|
-
* feedback primitives (`CngxRipple`, `CngxPressable`, `CngxSpeak`)
|
|
1237
|
+
* feedback primitives (`CngxRipple`, `CngxPressable`, `CngxSpeak`) - the
|
|
1196
1238
|
* fourth sense, audition, as composable atoms.
|
|
1197
1239
|
*/
|
|
1198
1240
|
// Handle + component-scope provider
|