@cngx/common 0.1.0-rc.8 → 0.1.0-rc.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/command/README.md +29 -0
- package/data/README.md +5 -2
- package/fesm2022/cngx-common-a11y.mjs +403 -84
- package/fesm2022/cngx-common-a11y.mjs.map +1 -1
- package/fesm2022/cngx-common-audio.mjs +16 -13
- package/fesm2022/cngx-common-audio.mjs.map +1 -1
- package/fesm2022/cngx-common-card.mjs +4 -3
- package/fesm2022/cngx-common-card.mjs.map +1 -1
- package/fesm2022/cngx-common-chart.mjs +55 -36
- package/fesm2022/cngx-common-chart.mjs.map +1 -1
- package/fesm2022/cngx-common-command.mjs +60 -6
- package/fesm2022/cngx-common-command.mjs.map +1 -1
- package/fesm2022/cngx-common-data.mjs +185 -37
- package/fesm2022/cngx-common-data.mjs.map +1 -1
- package/fesm2022/cngx-common-dialog.mjs +86 -48
- package/fesm2022/cngx-common-dialog.mjs.map +1 -1
- package/fesm2022/cngx-common-display.mjs +27 -23
- package/fesm2022/cngx-common-display.mjs.map +1 -1
- package/fesm2022/cngx-common-interactive.mjs +324 -122
- package/fesm2022/cngx-common-interactive.mjs.map +1 -1
- package/fesm2022/cngx-common-layout.mjs +129 -26
- package/fesm2022/cngx-common-layout.mjs.map +1 -1
- package/fesm2022/cngx-common-popover.mjs +947 -33
- package/fesm2022/cngx-common-popover.mjs.map +1 -1
- package/fesm2022/cngx-common-stepper.mjs +300 -166
- package/fesm2022/cngx-common-stepper.mjs.map +1 -1
- package/fesm2022/cngx-common-tabs.mjs +251 -80
- package/fesm2022/cngx-common-tabs.mjs.map +1 -1
- package/fesm2022/cngx-common-timeline.mjs +16 -10
- package/fesm2022/cngx-common-timeline.mjs.map +1 -1
- package/fesm2022/cngx-common.mjs +1 -1
- package/layout/README.md +16 -0
- package/package.json +20 -7
- package/popover/README.md +40 -0
- package/schematics/collection.json +9 -0
- package/schematics/ng-add/index.js +9 -0
- package/schematics/ng-add/schema.json +91 -0
- package/schematics/package.json +3 -0
- package/stepper/README.md +5 -4
- package/theming/components/cngx-popover-sheet.css +402 -0
- package/theming/components/cngx-popover.css +10 -6
- package/types/cngx-common-a11y.d.ts +167 -14
- package/types/cngx-common-chart.d.ts +8 -7
- package/types/cngx-common-command.d.ts +19 -2
- package/types/cngx-common-data.d.ts +164 -26
- package/types/cngx-common-dialog.d.ts +3 -7
- package/types/cngx-common-interactive.d.ts +52 -17
- package/types/cngx-common-layout.d.ts +37 -5
- package/types/cngx-common-popover.d.ts +353 -13
- package/types/cngx-common-stepper.d.ts +168 -129
- package/types/cngx-common-tabs.d.ts +149 -30
- package/types/cngx-common-timeline.d.ts +27 -7
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, inject, signal, computed, Injectable, ElementRef, DestroyRef, Directive, Renderer2, contentChild, input, effect, untracked,
|
|
2
|
+
import { InjectionToken, inject, signal, computed, Injectable, ElementRef, DestroyRef, Directive, Renderer2, contentChild, input, effect, untracked, viewChild, ViewContainerRef, ChangeDetectionStrategy, Component, ApplicationRef, EnvironmentInjector, Injector, createComponent } from '@angular/core';
|
|
3
3
|
import { DOCUMENT } from '@angular/common';
|
|
4
4
|
import { createOverrideMerge, nextUid, coerceSignal, buildAsyncStateView, hasTransition, onTransitionDone } from '@cngx/core/utils';
|
|
5
5
|
import { createScrollLock } from '@cngx/common/layout';
|
|
6
|
+
import { cngxDevWarn } from '@cngx/utils';
|
|
6
7
|
import { isObservable, firstValueFrom, filter, take, map } from 'rxjs';
|
|
7
8
|
import { createLanguageSection } from '@cngx/core/i18n';
|
|
8
9
|
import { toObservable } from '@angular/core/rxjs-interop';
|
|
@@ -358,6 +359,42 @@ function applySrOnly(el) {
|
|
|
358
359
|
el.style.border = '0';
|
|
359
360
|
}
|
|
360
361
|
|
|
362
|
+
/**
|
|
363
|
+
* The registry is single-slot per kind, so a second live registration
|
|
364
|
+
* silently wins - surface the authoring error instead of letting the
|
|
365
|
+
* two open paths resolve different labelling. A module function, not a
|
|
366
|
+
* method: a class keeps its methods in the bundle, and an emptied method
|
|
367
|
+
* still pulls `cngxDevWarn` into the production build.
|
|
368
|
+
*/
|
|
369
|
+
function warnDoubleRegistration(id, kind, current, next) {
|
|
370
|
+
if (!(typeof ngDevMode !== 'undefined' && ngDevMode)) {
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
if (current === null || current === next) {
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
cngxDevWarn('CNGX1014', `[cngxDialog] dialog "${id}" has a second ${kind} registered while another ` +
|
|
377
|
+
`is live. The dialog references one ${kind} id, and both elements render it; a ` +
|
|
378
|
+
`template-declared ${kind} wins over a registered one. Remove the extra ` +
|
|
379
|
+
`cngxDialog${kind === 'title' ? 'Title' : 'Description'} element.`);
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* A non-modal dialog keeps focus on the page, so the only announcement is
|
|
383
|
+
* the title text the dialog writes into its own live region on open. Warn
|
|
384
|
+
* when there is no title text to announce. A module function for the same
|
|
385
|
+
* reason as `warnDoubleRegistration`.
|
|
386
|
+
*/
|
|
387
|
+
function warnNonModalA11y(id, titleText) {
|
|
388
|
+
if (!(typeof ngDevMode !== 'undefined' && ngDevMode)) {
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
if (titleText === '') {
|
|
392
|
+
cngxDevWarn('CNGX1015', `[cngxDialog] non-modal dialog "${id}" opened without a title. ` +
|
|
393
|
+
'A non-modal dialog leaves focus on the page and is announced only by ' +
|
|
394
|
+
'reading its title into its live region; with no title text, screen reader ' +
|
|
395
|
+
'users are not told it appeared. Add a [cngxDialogTitle] element with text.');
|
|
396
|
+
}
|
|
397
|
+
}
|
|
361
398
|
/**
|
|
362
399
|
* Signal-driven state machine for native `<dialog>`.
|
|
363
400
|
*
|
|
@@ -616,6 +653,10 @@ class CngxDialog {
|
|
|
616
653
|
}, ...(ngDevMode ? [{ debugName: "ariaDescribedBy" }] : /* istanbul ignore next */ []));
|
|
617
654
|
backdropOpacity = computed(() => this.dialogStack.topmost() === this.idSignal() ? '1' : '0', ...(ngDevMode ? [{ debugName: "backdropOpacity" }] : /* istanbul ignore next */ []));
|
|
618
655
|
liveRegion = null;
|
|
656
|
+
/** The title text the open announcement reads; `''` when there is none. */
|
|
657
|
+
currentTitleText() {
|
|
658
|
+
return (this.titleDirective() ?? this.registeredTitle())?.textContent?.() ?? '';
|
|
659
|
+
}
|
|
619
660
|
/**
|
|
620
661
|
* The modal mode latched at `open()`. Everything that depends on how the
|
|
621
662
|
* dialog actually opened derives from this - scroll-lock release, stack
|
|
@@ -628,7 +669,12 @@ class CngxDialog {
|
|
|
628
669
|
this.createLiveRegion();
|
|
629
670
|
effect(() => {
|
|
630
671
|
if (this.lifecycleSignal() === 'open') {
|
|
631
|
-
const titleText = untracked(() =>
|
|
672
|
+
const titleText = untracked(() => this.currentTitleText());
|
|
673
|
+
// Checked where the announcement reads the title: an opener-created
|
|
674
|
+
// dialog's title only exists once its content view has rendered.
|
|
675
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode && !untracked(this.openedAsModal)) {
|
|
676
|
+
warnNonModalA11y(untracked(this.idSignal), titleText);
|
|
677
|
+
}
|
|
632
678
|
if (titleText && this.liveRegion) {
|
|
633
679
|
this.liveRegion.textContent = titleText;
|
|
634
680
|
// Clear after one frame so subsequent opens re-announce
|
|
@@ -676,7 +722,9 @@ class CngxDialog {
|
|
|
676
722
|
* @internal CNGX_DIALOG_ARIA_REGISTRY implementation - not public API.
|
|
677
723
|
*/
|
|
678
724
|
registerTitle(handle) {
|
|
679
|
-
|
|
725
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
726
|
+
warnDoubleRegistration(untracked(this.idSignal), 'title', untracked(this.registeredTitle), handle);
|
|
727
|
+
}
|
|
680
728
|
this.registeredTitle.set(handle);
|
|
681
729
|
return () => this.registeredTitle.update((current) => (current === handle ? null : current));
|
|
682
730
|
}
|
|
@@ -686,7 +734,9 @@ class CngxDialog {
|
|
|
686
734
|
* @internal CNGX_DIALOG_ARIA_REGISTRY implementation - not public API.
|
|
687
735
|
*/
|
|
688
736
|
registerDescription(handle) {
|
|
689
|
-
|
|
737
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
738
|
+
warnDoubleRegistration(untracked(this.idSignal), 'description', untracked(this.registeredDescription), handle);
|
|
739
|
+
}
|
|
690
740
|
this.registeredDescription.set(handle);
|
|
691
741
|
return () => this.registeredDescription.update((current) => (current === handle ? null : current));
|
|
692
742
|
}
|
|
@@ -727,7 +777,6 @@ class CngxDialog {
|
|
|
727
777
|
}
|
|
728
778
|
else {
|
|
729
779
|
dialog.show();
|
|
730
|
-
this.warnNonModalA11y();
|
|
731
780
|
}
|
|
732
781
|
// Transition to open after browser paints the opening class
|
|
733
782
|
requestAnimationFrame(() => {
|
|
@@ -940,35 +989,6 @@ class CngxDialog {
|
|
|
940
989
|
this.scrollLockRelease?.();
|
|
941
990
|
this.scrollLockRelease = null;
|
|
942
991
|
}
|
|
943
|
-
/**
|
|
944
|
-
* The registry is single-slot per kind, so a second live registration
|
|
945
|
-
* silently wins - surface the authoring error instead of letting the
|
|
946
|
-
* two open paths resolve different labelling.
|
|
947
|
-
*/
|
|
948
|
-
warnDoubleRegistration(kind, current, next) {
|
|
949
|
-
if (!isDevMode() || current === null || current === next) {
|
|
950
|
-
return;
|
|
951
|
-
}
|
|
952
|
-
console.warn(`CngxDialog [${this.idSignal()}]: a second ${kind} registered while another ` +
|
|
953
|
-
`is live. The dialog references one ${kind} id - the newest registration ` +
|
|
954
|
-
`wins. Remove the extra cngxDialog${kind === 'title' ? 'Title' : 'Description'} element.`);
|
|
955
|
-
}
|
|
956
|
-
warnNonModalA11y() {
|
|
957
|
-
if (!isDevMode()) {
|
|
958
|
-
return;
|
|
959
|
-
}
|
|
960
|
-
// Non-modal dialogs are silent to SR. Warn if no aria-live sibling found.
|
|
961
|
-
const trigger = this.triggerElement();
|
|
962
|
-
if (trigger) {
|
|
963
|
-
const parent = trigger.parentElement;
|
|
964
|
-
if (parent && !parent.querySelector('[aria-live]')) {
|
|
965
|
-
console.warn(`CngxDialog [${this.idSignal()}]: Non-modal dialog opened without an ` +
|
|
966
|
-
'`aria-live` region near the trigger. Screen reader users will not ' +
|
|
967
|
-
'be notified that the dialog appeared. Add `aria-live="polite"` to a ' +
|
|
968
|
-
'sibling element that announces the dialog presence.');
|
|
969
|
-
}
|
|
970
|
-
}
|
|
971
|
-
}
|
|
972
992
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDialog, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
973
993
|
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.4", type: CngxDialog, isStandalone: true, selector: "dialog[cngxDialog]", inputs: { modal: { classPropertyName: "modal", publicName: "modal", isSignal: true, isRequired: false, transformFunction: null }, closeOnBackdropClick: { classPropertyName: "closeOnBackdropClick", publicName: "closeOnBackdropClick", isSignal: true, isRequired: false, transformFunction: null }, closeOnEscape: { classPropertyName: "closeOnEscape", publicName: "closeOnEscape", isSignal: true, isRequired: false, transformFunction: null }, autoFocus: { classPropertyName: "autoFocus", publicName: "autoFocus", isSignal: true, isRequired: false, transformFunction: null }, focusFallback: { classPropertyName: "focusFallback", publicName: "focusFallback", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, submitAction: { classPropertyName: "submitAction", publicName: "submitAction", isSignal: true, isRequired: false, transformFunction: null }, error: { classPropertyName: "error", publicName: "error", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "cancel": "handleCancel($event)", "pointerdown": "handlePointerDown($event)", "click": "handleClick($event)" }, properties: { "class.cngx-dialog--opening": "isOpening()", "class.cngx-dialog--open": "isOpen()", "class.cngx-dialog--closing": "isClosing()", "class.cngx-dialog--modal": "modal()", "attr.aria-modal": "ariaModal()", "attr.aria-labelledby": "ariaLabelledBy()", "attr.aria-describedby": "ariaDescribedBy()", "class.cngx-dialog--pending": "isPending()", "attr.aria-busy": "isPending() || null", "class.cngx-dialog--error": "effectiveError()", "style.--cngx-dialog-backdrop-opacity": "backdropOpacity()" } }, providers: [
|
|
974
994
|
{ provide: DIALOG_REF, useExisting: CngxDialog },
|
|
@@ -1387,19 +1407,32 @@ class CngxDialogOpener {
|
|
|
1387
1407
|
{ provide: CNGX_DIALOG_DATA, useValue: config.data ?? null },
|
|
1388
1408
|
],
|
|
1389
1409
|
});
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1410
|
+
// Creating the content and its first render run consumer code. A throw
|
|
1411
|
+
// there must leave no outlet in the body and no ref in openDialogs, so
|
|
1412
|
+
// the ref is registered only after open() succeeded.
|
|
1413
|
+
try {
|
|
1414
|
+
if (outletVcr) {
|
|
1415
|
+
if (typeof content === 'function') {
|
|
1416
|
+
contentRef = outletVcr.createComponent(content, {
|
|
1417
|
+
injector: childInjector,
|
|
1418
|
+
});
|
|
1419
|
+
}
|
|
1420
|
+
else {
|
|
1421
|
+
outletVcr.createEmbeddedView(content, { $implicit: innerDialog }, { injector: childInjector });
|
|
1422
|
+
}
|
|
1398
1423
|
}
|
|
1424
|
+
// The outlet's inputs reach the inner cngxDialog through template
|
|
1425
|
+
// bindings, and open() latches [modal]. Without this pass the dialog
|
|
1426
|
+
// would still see its input defaults and always open modal.
|
|
1427
|
+
outletRef.changeDetectorRef.detectChanges();
|
|
1428
|
+
dialogInstance.open();
|
|
1429
|
+
}
|
|
1430
|
+
catch (error) {
|
|
1431
|
+
this.discardOutlet(outletRef);
|
|
1432
|
+
throw error;
|
|
1399
1433
|
}
|
|
1400
1434
|
const dialogRef = new CngxDialogRef(innerDialog, outletRef, contentRef, this.injector);
|
|
1401
1435
|
this.openDialogs.push(dialogRef);
|
|
1402
|
-
dialogInstance.open();
|
|
1403
1436
|
this.cleanupEffects.set(dialogRef, effect(() => {
|
|
1404
1437
|
if (innerDialog.lifecycle() === 'closed' &&
|
|
1405
1438
|
outletRef.hostView &&
|
|
@@ -1430,12 +1463,17 @@ class CngxDialogOpener {
|
|
|
1430
1463
|
if (ref.componentRef && !ref.componentRef.hostView.destroyed) {
|
|
1431
1464
|
ref.componentRef.destroy();
|
|
1432
1465
|
}
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1466
|
+
if (ref._outletRef) {
|
|
1467
|
+
this.discardOutlet(ref._outletRef);
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
discardOutlet(outletRef) {
|
|
1471
|
+
if (outletRef.hostView.destroyed) {
|
|
1472
|
+
return;
|
|
1438
1473
|
}
|
|
1474
|
+
this.appRef.detachView(outletRef.hostView);
|
|
1475
|
+
outletRef.location.nativeElement.remove();
|
|
1476
|
+
outletRef.destroy();
|
|
1439
1477
|
}
|
|
1440
1478
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDialogOpener, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1441
1479
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDialogOpener });
|