@cngx/common 0.1.0-rc.7 → 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/data/README.md +10 -1
- package/dialog/README.md +23 -1
- package/fesm2022/cngx-common-a11y.mjs +125 -111
- package/fesm2022/cngx-common-a11y.mjs.map +1 -1
- package/fesm2022/cngx-common-audio.mjs +47 -5
- package/fesm2022/cngx-common-audio.mjs.map +1 -1
- package/fesm2022/cngx-common-card.mjs +300 -46
- package/fesm2022/cngx-common-card.mjs.map +1 -1
- package/fesm2022/cngx-common-chart.mjs +1176 -453
- package/fesm2022/cngx-common-chart.mjs.map +1 -1
- package/fesm2022/cngx-common-command.mjs +37 -10
- package/fesm2022/cngx-common-command.mjs.map +1 -1
- package/fesm2022/cngx-common-data.mjs +1318 -469
- package/fesm2022/cngx-common-data.mjs.map +1 -1
- package/fesm2022/cngx-common-dialog.mjs +151 -14
- package/fesm2022/cngx-common-dialog.mjs.map +1 -1
- package/fesm2022/cngx-common-display.mjs +340 -73
- package/fesm2022/cngx-common-display.mjs.map +1 -1
- package/fesm2022/cngx-common-interactive.mjs +1744 -952
- package/fesm2022/cngx-common-interactive.mjs.map +1 -1
- package/fesm2022/cngx-common-layout.mjs +841 -114
- package/fesm2022/cngx-common-layout.mjs.map +1 -1
- package/fesm2022/cngx-common-popover.mjs +350 -60
- package/fesm2022/cngx-common-popover.mjs.map +1 -1
- package/fesm2022/cngx-common-stepper.mjs +727 -317
- package/fesm2022/cngx-common-stepper.mjs.map +1 -1
- package/fesm2022/cngx-common-tabs.mjs +1601 -1243
- package/fesm2022/cngx-common-tabs.mjs.map +1 -1
- package/fesm2022/cngx-common-timeline.mjs +137 -53
- package/fesm2022/cngx-common-timeline.mjs.map +1 -1
- package/fesm2022/cngx-common.mjs +1 -1
- package/interactive/README.md +15 -4
- package/layout/README.md +21 -1
- package/package.json +3 -3
- package/popover/README.md +18 -2
- package/stepper/README.md +6 -4
- package/theming/components/cngx-accordion.css +1 -1
- package/theming/components/cngx-backdrop.css +12 -0
- package/theming/components/cngx-button-toggle.css +29 -3
- package/theming/components/cngx-data-grid.css +168 -1
- package/theming/components/cngx-dialog.css +13 -0
- package/theming/components/cngx-listbox.css +21 -12
- package/theming/components/cngx-menu.css +56 -16
- package/theming/components/cngx-popover.css +24 -0
- package/theming/components/cngx-recycler-placeholder.css +196 -0
- package/theming/components/cngx-ripple.css +1 -1
- package/theming/components/cngx-slider.css +32 -1
- package/theming/components/cngx-tooltip.css +12 -0
- package/timeline/README.md +155 -0
- package/types/cngx-common-a11y.d.ts +42 -18
- package/types/cngx-common-card.d.ts +201 -17
- package/types/cngx-common-chart.d.ts +343 -47
- package/types/cngx-common-command.d.ts +31 -8
- package/types/cngx-common-data.d.ts +581 -68
- package/types/cngx-common-dialog.d.ts +158 -3
- package/types/cngx-common-display.d.ts +356 -142
- package/types/cngx-common-interactive.d.ts +859 -210
- package/types/cngx-common-layout.d.ts +567 -28
- package/types/cngx-common-popover.d.ts +262 -39
- package/types/cngx-common-stepper.d.ts +366 -116
- package/types/cngx-common-tabs.d.ts +214 -50
- package/types/cngx-common-timeline.d.ts +82 -16
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, signal, computed, Injectable,
|
|
2
|
+
import { InjectionToken, inject, signal, computed, Injectable, ElementRef, DestroyRef, Directive, Renderer2, contentChild, input, effect, untracked, isDevMode, viewChild, ViewContainerRef, ChangeDetectionStrategy, Component, ApplicationRef, EnvironmentInjector, Injector, createComponent } from '@angular/core';
|
|
3
3
|
import { DOCUMENT } from '@angular/common';
|
|
4
|
-
import { nextUid, buildAsyncStateView, hasTransition, onTransitionDone } from '@cngx/core/utils';
|
|
4
|
+
import { createOverrideMerge, nextUid, coerceSignal, buildAsyncStateView, hasTransition, onTransitionDone } from '@cngx/core/utils';
|
|
5
5
|
import { createScrollLock } from '@cngx/common/layout';
|
|
6
6
|
import { isObservable, firstValueFrom, filter, take, map } from 'rxjs';
|
|
7
|
+
import { createLanguageSection } from '@cngx/core/i18n';
|
|
7
8
|
import { toObservable } from '@angular/core/rxjs-interop';
|
|
8
9
|
import { CngxSwipeDismiss } from '@cngx/common/interactive';
|
|
9
10
|
|
|
@@ -16,6 +17,103 @@ import { CngxSwipeDismiss } from '@cngx/common/interactive';
|
|
|
16
17
|
*/
|
|
17
18
|
const DIALOG_REF = new InjectionToken('CngxDialogRef');
|
|
18
19
|
|
|
20
|
+
/**
|
|
21
|
+
* The English dialog section: the single source of the dialog family's
|
|
22
|
+
* English copy. The `CNGX_DIALOG_DEFAULTS` labels default to it.
|
|
23
|
+
*
|
|
24
|
+
* @category common/dialog/i18n
|
|
25
|
+
* @since 0.1.0
|
|
26
|
+
* @relatedTo CNGX_DIALOG_DEFAULTS
|
|
27
|
+
*/
|
|
28
|
+
const CNGX_DIALOG_LANGUAGE_EN = {
|
|
29
|
+
close: 'Close dialog',
|
|
30
|
+
errorFallback: 'An error occurred',
|
|
31
|
+
dragHandle: 'Move dialog',
|
|
32
|
+
dragHandleRoleDescription: 'draggable',
|
|
33
|
+
dragInstructions: 'Use arrow keys to move the dialog; Shift for larger steps',
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/** @internal The dialog section of the active pack over the English labels. */
|
|
37
|
+
const dialogLabelsFromPack = createLanguageSection('dialog', CNGX_DIALOG_LANGUAGE_EN);
|
|
38
|
+
/**
|
|
39
|
+
* DI token carrying the merged {@link CngxDialogDefaults}. `providedIn: 'root'`:
|
|
40
|
+
* `labels` is the dialog section of the active language pack over the English
|
|
41
|
+
* defaults, so a consumer who provides nothing keeps today's behaviour
|
|
42
|
+
* exactly.
|
|
43
|
+
*
|
|
44
|
+
* @category common/dialog/config
|
|
45
|
+
* @wcag AA
|
|
46
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/dialog/config/dialog-config.ts
|
|
47
|
+
* @since 0.1.0
|
|
48
|
+
* @relatedTo CngxDialog, CngxDialogClose, CngxDialogDraggable
|
|
49
|
+
*/
|
|
50
|
+
const CNGX_DIALOG_DEFAULTS = new InjectionToken('CngxDialogDefaults', {
|
|
51
|
+
providedIn: 'root',
|
|
52
|
+
factory: () => ({ labels: dialogLabelsFromPack() }),
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* Override dialog interaction strings. Unset keys keep the language pack's
|
|
56
|
+
* text, or the English default, and two calls merge rather than replace.
|
|
57
|
+
* Pass a `Signal` to switch the language at runtime.
|
|
58
|
+
*
|
|
59
|
+
* ```ts
|
|
60
|
+
* bootstrapApplication(AppComponent, {
|
|
61
|
+
* providers: [
|
|
62
|
+
* provideDialogConfig(
|
|
63
|
+
* withDialogLabels({ close: 'Dialog schließen', dragHandle: 'Dialog verschieben' }),
|
|
64
|
+
* ),
|
|
65
|
+
* ],
|
|
66
|
+
* });
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @category common/dialog/config
|
|
70
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/dialog/config/dialog-config.ts
|
|
71
|
+
* @since 0.1.0
|
|
72
|
+
*/
|
|
73
|
+
function withDialogLabels(overrides) {
|
|
74
|
+
return { labels: overrides };
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Register app-wide dialog defaults composed from `with*` features, applied
|
|
78
|
+
* on top of the active language pack.
|
|
79
|
+
*
|
|
80
|
+
* @category common/dialog/config
|
|
81
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/dialog/config/dialog-config.ts
|
|
82
|
+
* @since 0.1.0
|
|
83
|
+
*/
|
|
84
|
+
function provideDialogConfig(...features) {
|
|
85
|
+
return [
|
|
86
|
+
{
|
|
87
|
+
provide: CNGX_DIALOG_DEFAULTS,
|
|
88
|
+
useFactory: () => ({
|
|
89
|
+
labels: features.reduce((acc, feature) => createOverrideMerge(acc, feature.labels), dialogLabelsFromPack()),
|
|
90
|
+
}),
|
|
91
|
+
},
|
|
92
|
+
];
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Sub-tree variant - use in `viewProviders` so the defaults only apply to
|
|
96
|
+
* dialogs opened from descendants of this component.
|
|
97
|
+
*
|
|
98
|
+
* @category common/dialog/config
|
|
99
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/dialog/config/dialog-config.ts
|
|
100
|
+
* @since 0.1.0
|
|
101
|
+
*/
|
|
102
|
+
function provideDialogConfigAt(...features) {
|
|
103
|
+
return provideDialogConfig(...features);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Inject the currently-resolved dialog defaults. Safe in any injection
|
|
107
|
+
* context; falls back to the English bundle when nothing is provided.
|
|
108
|
+
*
|
|
109
|
+
* @category common/dialog/config
|
|
110
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/dialog/config/dialog-config.ts
|
|
111
|
+
* @since 0.1.0
|
|
112
|
+
*/
|
|
113
|
+
function injectDialogConfig() {
|
|
114
|
+
return inject(CNGX_DIALOG_DEFAULTS);
|
|
115
|
+
}
|
|
116
|
+
|
|
19
117
|
/**
|
|
20
118
|
* Injection token for the dialog ARIA registry.
|
|
21
119
|
*
|
|
@@ -339,6 +437,10 @@ class CngxDialog {
|
|
|
339
437
|
renderer = inject(Renderer2);
|
|
340
438
|
destroyRef = inject(DestroyRef);
|
|
341
439
|
dialogStack = inject(CngxDialogStack);
|
|
440
|
+
labels = coerceSignal(injectDialogConfig().labels);
|
|
441
|
+
// Armed while a close transition runs; cancelled on destroy so the
|
|
442
|
+
// transitionend listener and fallback timer never outlive the directive.
|
|
443
|
+
pendingClose = null;
|
|
342
444
|
titleDirective = contentChild(CngxDialogTitle, ...(ngDevMode ? [{ debugName: "titleDirective" }] : /* istanbul ignore next */ []));
|
|
343
445
|
descriptionDirective = contentChild(CngxDialogDescription, ...(ngDevMode ? [{ debugName: "descriptionDirective" }] : /* istanbul ignore next */ []));
|
|
344
446
|
// Push-registered counterparts of the content queries above. Programmatic
|
|
@@ -544,7 +646,10 @@ class CngxDialog {
|
|
|
544
646
|
// so a retried identical failure would never re-fire this effect.
|
|
545
647
|
if (this.effectiveError() && this.liveRegion) {
|
|
546
648
|
const errMsg = this.state()?.error() ?? this.submitErrorState();
|
|
547
|
-
|
|
649
|
+
// The fallback copy is read untracked: a language switch must not
|
|
650
|
+
// re-fire the announcement; the next error speaks the new language.
|
|
651
|
+
this.liveRegion.textContent =
|
|
652
|
+
typeof errMsg === 'string' ? errMsg : untracked(() => this.labels().errorFallback);
|
|
548
653
|
// Clear after one frame (same pattern as the title announce) so a
|
|
549
654
|
// repeated identical error is a fresh mutation the SR re-announces.
|
|
550
655
|
requestAnimationFrame(() => {
|
|
@@ -555,6 +660,8 @@ class CngxDialog {
|
|
|
555
660
|
}
|
|
556
661
|
});
|
|
557
662
|
this.destroyRef.onDestroy(() => {
|
|
663
|
+
// finalize() disarms pendingClose; a 'closed' lifecycle means it
|
|
664
|
+
// already ran and the handle is gone.
|
|
558
665
|
if (this.lifecycleSignal() !== 'closed') {
|
|
559
666
|
this.finalize();
|
|
560
667
|
}
|
|
@@ -752,13 +859,17 @@ class CngxDialog {
|
|
|
752
859
|
startClosing() {
|
|
753
860
|
if (hasTransition(this.dialogElement)) {
|
|
754
861
|
this.lifecycleSignal.set('closing');
|
|
755
|
-
onTransitionDone(this.dialogElement, () => this.finalize());
|
|
862
|
+
this.pendingClose = onTransitionDone(this.dialogElement, () => this.finalize());
|
|
756
863
|
}
|
|
757
864
|
else {
|
|
758
865
|
this.finalize();
|
|
759
866
|
}
|
|
760
867
|
}
|
|
761
868
|
finalize() {
|
|
869
|
+
// Disarm any pending close wait no matter which path got here, so the
|
|
870
|
+
// settled handle never lingers as a stale armed field.
|
|
871
|
+
this.pendingClose?.cancel();
|
|
872
|
+
this.pendingClose = null;
|
|
762
873
|
const dialog = this.dialogElement;
|
|
763
874
|
if (dialog.open) {
|
|
764
875
|
dialog.close();
|
|
@@ -930,10 +1041,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
930
1041
|
class CngxDialogClose {
|
|
931
1042
|
dialogRef = inject(DIALOG_REF);
|
|
932
1043
|
elRef = inject((ElementRef));
|
|
1044
|
+
labels = coerceSignal(injectDialogConfig().labels);
|
|
933
1045
|
/** Value to pass to `close()`. When `undefined`, calls `dismiss()` instead. */
|
|
934
1046
|
value = input(undefined, { ...(ngDevMode ? { debugName: "value" } : /* istanbul ignore next */ {}), alias: 'cngxDialogClose' });
|
|
935
1047
|
/**
|
|
936
|
-
* Explicit `aria-label` override.
|
|
1048
|
+
* Explicit `aria-label` override. Bind a dynamic accessible name here,
|
|
1049
|
+
* not through `[attr.aria-label]`: the directive owns the host's
|
|
1050
|
+
* `aria-label` binding, so a second binding on the same attribute races it.
|
|
1051
|
+
* A static `aria-label="..."` attribute on the host is kept as is.
|
|
937
1052
|
*
|
|
938
1053
|
* When not set, the directive auto-detects whether the host element
|
|
939
1054
|
* has descriptive text content. If it does (e.g. "Cancel", "Confirm"),
|
|
@@ -941,11 +1056,17 @@ class CngxDialogClose {
|
|
|
941
1056
|
* empty, or visually an icon, `aria-label` defaults to `"Close dialog"`.
|
|
942
1057
|
*/
|
|
943
1058
|
label = input(undefined, { ...(ngDevMode ? { debugName: "label" } : /* istanbul ignore next */ {}), alias: 'cngxDialogCloseLabel' });
|
|
1059
|
+
// The value is read once at construction and written back through the host
|
|
1060
|
+
// binding: returning null would remove the consumer's attribute, and after
|
|
1061
|
+
// the first render the binding owns aria-label, so a recompute must not
|
|
1062
|
+
// mistake the directive's own value for a consumer-authored one.
|
|
1063
|
+
consumerAriaLabel = this.elRef.nativeElement.getAttribute('aria-label');
|
|
944
1064
|
/** Set type="button" on <button> hosts to prevent form submit. */
|
|
945
1065
|
hostType = this.elRef.nativeElement.tagName === 'BUTTON' ? 'button' : null;
|
|
946
1066
|
/**
|
|
947
1067
|
* Computed `aria-label`. Returns:
|
|
948
1068
|
* - explicit `label()` input if set
|
|
1069
|
+
* - the consumer's static `aria-label` attribute, kept as is
|
|
949
1070
|
* - `null` if host text is descriptive (> 1 char, not whitespace-only)
|
|
950
1071
|
* - `'Close dialog'` for icon-only / single-char content
|
|
951
1072
|
*/
|
|
@@ -954,16 +1075,15 @@ class CngxDialogClose {
|
|
|
954
1075
|
if (explicit !== undefined) {
|
|
955
1076
|
return explicit || null;
|
|
956
1077
|
}
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
if (el.hasAttribute('aria-label')) {
|
|
960
|
-
return null;
|
|
1078
|
+
if (this.consumerAriaLabel !== null) {
|
|
1079
|
+
return this.consumerAriaLabel;
|
|
961
1080
|
}
|
|
1081
|
+
const el = this.elRef.nativeElement;
|
|
962
1082
|
const text = el.textContent?.trim() ?? '';
|
|
963
1083
|
if (text.length > 1) {
|
|
964
1084
|
return null;
|
|
965
1085
|
}
|
|
966
|
-
return
|
|
1086
|
+
return this.labels().close;
|
|
967
1087
|
}, ...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
|
|
968
1088
|
handleClick() {
|
|
969
1089
|
const v = this.value();
|
|
@@ -1461,6 +1581,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1461
1581
|
class CngxDialogDraggable {
|
|
1462
1582
|
elRef = inject(ElementRef);
|
|
1463
1583
|
doc = inject(DOCUMENT);
|
|
1584
|
+
labels = coerceSignal(injectDialogConfig().labels);
|
|
1464
1585
|
destroyRef = inject(DestroyRef);
|
|
1465
1586
|
ariaRegistry = inject(CNGX_DIALOG_ARIA_REGISTRY, { optional: true });
|
|
1466
1587
|
/** Handle element for initiating drag. If not set, entire dialog is the handle. */
|
|
@@ -1510,6 +1631,12 @@ class CngxDialogDraggable {
|
|
|
1510
1631
|
// a signal write that must not become a tracked dependency.
|
|
1511
1632
|
untracked(() => this.setupHandle(handleEl));
|
|
1512
1633
|
});
|
|
1634
|
+
// A language switch relabels the promoted handle and the instruction in
|
|
1635
|
+
// place, without re-running the handle setup.
|
|
1636
|
+
effect(() => {
|
|
1637
|
+
const labels = this.labels();
|
|
1638
|
+
untracked(() => this.applyLabels(labels));
|
|
1639
|
+
});
|
|
1513
1640
|
this.destroyRef.onDestroy(() => this.cleanup());
|
|
1514
1641
|
}
|
|
1515
1642
|
currentHandle = null;
|
|
@@ -1532,8 +1659,8 @@ class CngxDialogDraggable {
|
|
|
1532
1659
|
// on the dialog element itself would clobber its accessible name (the
|
|
1533
1660
|
// title) and its role text.
|
|
1534
1661
|
if (!el.hasAttribute('aria-roledescription') && el !== this.elRef.nativeElement) {
|
|
1535
|
-
el.setAttribute('aria-roledescription',
|
|
1536
|
-
el.setAttribute('aria-label',
|
|
1662
|
+
el.setAttribute('aria-roledescription', this.labels().dragHandleRoleDescription);
|
|
1663
|
+
el.setAttribute('aria-label', this.labels().dragHandle);
|
|
1537
1664
|
this.handleAddedAria = true;
|
|
1538
1665
|
}
|
|
1539
1666
|
// The keyboard path is live on every handle, so the instruction is too.
|
|
@@ -1671,6 +1798,16 @@ class CngxDialogDraggable {
|
|
|
1671
1798
|
y: Math.round(y / grid) * grid,
|
|
1672
1799
|
};
|
|
1673
1800
|
}
|
|
1801
|
+
/** Re-apply the handle labels and the instruction text this directive owns. */
|
|
1802
|
+
applyLabels(labels) {
|
|
1803
|
+
if (this.currentHandle && this.handleAddedAria) {
|
|
1804
|
+
this.currentHandle.setAttribute('aria-roledescription', labels.dragHandleRoleDescription);
|
|
1805
|
+
this.currentHandle.setAttribute('aria-label', labels.dragHandle);
|
|
1806
|
+
}
|
|
1807
|
+
if (this.instructionNode) {
|
|
1808
|
+
this.instructionNode.textContent = labels.dragInstructions;
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1674
1811
|
instructionNode = null;
|
|
1675
1812
|
releaseInstruction = null;
|
|
1676
1813
|
handleAddedDescribedBy = false;
|
|
@@ -1683,7 +1820,7 @@ class CngxDialogDraggable {
|
|
|
1683
1820
|
createInstructionNode() {
|
|
1684
1821
|
const node = this.doc.createElement('span');
|
|
1685
1822
|
node.id = nextUid('cngx-dialog-drag-hint');
|
|
1686
|
-
node.textContent =
|
|
1823
|
+
node.textContent = this.labels().dragInstructions;
|
|
1687
1824
|
applySrOnly(node);
|
|
1688
1825
|
this.elRef.nativeElement.appendChild(node);
|
|
1689
1826
|
this.instructionNode = node;
|
|
@@ -1769,5 +1906,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1769
1906
|
* Generated bundle index. Do not edit.
|
|
1770
1907
|
*/
|
|
1771
1908
|
|
|
1772
|
-
export { CNGX_DIALOG_DATA, CngxBottomSheet, CngxDialog, CngxDialogClose, CngxDialogDescription, CngxDialogDraggable, CngxDialogOpener, CngxDialogRef, CngxDialogStack, CngxDialogTitle, DIALOG_REF, provideDialog, provideDialogStack };
|
|
1909
|
+
export { CNGX_DIALOG_DATA, CNGX_DIALOG_DEFAULTS, CNGX_DIALOG_LANGUAGE_EN, CngxBottomSheet, CngxDialog, CngxDialogClose, CngxDialogDescription, CngxDialogDraggable, CngxDialogOpener, CngxDialogRef, CngxDialogStack, CngxDialogTitle, DIALOG_REF, injectDialogConfig, provideDialog, provideDialogConfig, provideDialogConfigAt, provideDialogStack, withDialogLabels };
|
|
1773
1910
|
//# sourceMappingURL=cngx-common-dialog.mjs.map
|