@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
|
@@ -6,16 +6,37 @@ import { isObservable, firstValueFrom, filter, take, map } from 'rxjs';
|
|
|
6
6
|
import { toObservable } from '@angular/core/rxjs-interop';
|
|
7
7
|
import { CngxSwipeDismiss } from '@cngx/common/interactive';
|
|
8
8
|
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Injection token to access the nearest `DialogRef` from inside a dialog.
|
|
11
|
+
*
|
|
12
|
+
* @category common/dialog
|
|
13
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/dialog/dialog/dialog-ref.ts
|
|
14
|
+
* @since 0.1.0
|
|
15
|
+
*/
|
|
10
16
|
const DIALOG_REF = new InjectionToken('CngxDialogRef');
|
|
11
17
|
|
|
12
18
|
/**
|
|
13
19
|
* Tracks open dialog instances as a stack for backdrop management.
|
|
14
20
|
*
|
|
15
|
-
* Provided in root
|
|
21
|
+
* Provided in root - always available, no manual provider setup needed.
|
|
16
22
|
* When multiple modal dialogs are stacked, only the topmost shows
|
|
17
23
|
* its `::backdrop`. Each `CngxDialog` reads `isTopmost` from this service
|
|
18
24
|
* to control `--cngx-dialog-backdrop-opacity`.
|
|
25
|
+
*
|
|
26
|
+
* @category common/dialog
|
|
27
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/dialog/dialog/dialog-stack.ts
|
|
28
|
+
* @since 0.1.0
|
|
29
|
+
* @relatedTo CngxDialog, CngxDialogOpener
|
|
30
|
+
* <example-url>http://localhost:4200/#/common/dialog/alert-dialog</example-url>
|
|
31
|
+
* <example-url>http://localhost:4200/#/common/dialog/bottom-sheet</example-url>
|
|
32
|
+
* <example-url>http://localhost:4200/#/common/dialog/cngxdialogopener-programmatic</example-url>
|
|
33
|
+
* <example-url>http://localhost:4200/#/common/dialog/draggable-dialog</example-url>
|
|
34
|
+
* <example-url>http://localhost:4200/#/common/dialog/fully-declarative</example-url>
|
|
35
|
+
* <example-url>http://localhost:4200/#/common/dialog/grid-snap-live-vs-release</example-url>
|
|
36
|
+
* <example-url>http://localhost:4200/#/common/dialog/nested-dialogs-cngxdialogstack</example-url>
|
|
37
|
+
* <example-url>http://localhost:4200/#/common/dialog/non-modal-panel</example-url>
|
|
38
|
+
* <example-url>http://localhost:4200/#/common/dialog/programmatic-control</example-url>
|
|
39
|
+
* <example-url>http://localhost:4200/#/common/dialog/template-directives</example-url>
|
|
19
40
|
*/
|
|
20
41
|
class CngxDialogStack {
|
|
21
42
|
stackState = signal([], ...(ngDevMode ? [{ debugName: "stackState" }] : /* istanbul ignore next */ []));
|
|
@@ -51,6 +72,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
51
72
|
* })
|
|
52
73
|
* export class NestedDialogHost { }
|
|
53
74
|
* ```
|
|
75
|
+
*
|
|
76
|
+
* @category common/dialog
|
|
54
77
|
*/
|
|
55
78
|
function provideDialogStack() {
|
|
56
79
|
return CngxDialogStack;
|
|
@@ -69,6 +92,23 @@ function provideDialogStack() {
|
|
|
69
92
|
* …
|
|
70
93
|
* </dialog>
|
|
71
94
|
* ```
|
|
95
|
+
*
|
|
96
|
+
* @category common/dialog
|
|
97
|
+
* @docsKind primary
|
|
98
|
+
* @wcag AA
|
|
99
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/dialog/dialog/dialog-title.directive.ts
|
|
100
|
+
* @since 0.1.0
|
|
101
|
+
* @relatedTo CngxDialog, CngxDialogDescription, CngxDialogClose
|
|
102
|
+
* <example-url>http://localhost:4200/#/common/dialog/alert-dialog</example-url>
|
|
103
|
+
* <example-url>http://localhost:4200/#/common/dialog/bottom-sheet</example-url>
|
|
104
|
+
* <example-url>http://localhost:4200/#/common/dialog/cngxdialogopener-programmatic</example-url>
|
|
105
|
+
* <example-url>http://localhost:4200/#/common/dialog/draggable-dialog</example-url>
|
|
106
|
+
* <example-url>http://localhost:4200/#/common/dialog/fully-declarative</example-url>
|
|
107
|
+
* <example-url>http://localhost:4200/#/common/dialog/grid-snap-live-vs-release</example-url>
|
|
108
|
+
* <example-url>http://localhost:4200/#/common/dialog/nested-dialogs-cngxdialogstack</example-url>
|
|
109
|
+
* <example-url>http://localhost:4200/#/common/dialog/non-modal-panel</example-url>
|
|
110
|
+
* <example-url>http://localhost:4200/#/common/dialog/programmatic-control</example-url>
|
|
111
|
+
* <example-url>http://localhost:4200/#/common/dialog/template-directives</example-url>
|
|
72
112
|
*/
|
|
73
113
|
class CngxDialogTitle {
|
|
74
114
|
elRef = inject((ElementRef));
|
|
@@ -120,6 +160,23 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
120
160
|
* …
|
|
121
161
|
* </dialog>
|
|
122
162
|
* ```
|
|
163
|
+
*
|
|
164
|
+
* @category common/dialog
|
|
165
|
+
* @docsKind primary
|
|
166
|
+
* @wcag AA
|
|
167
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/dialog/dialog/dialog-description.directive.ts
|
|
168
|
+
* @since 0.1.0
|
|
169
|
+
* @relatedTo CngxDialog, CngxDialogTitle, CngxDialogClose
|
|
170
|
+
* <example-url>http://localhost:4200/#/common/dialog/alert-dialog</example-url>
|
|
171
|
+
* <example-url>http://localhost:4200/#/common/dialog/bottom-sheet</example-url>
|
|
172
|
+
* <example-url>http://localhost:4200/#/common/dialog/cngxdialogopener-programmatic</example-url>
|
|
173
|
+
* <example-url>http://localhost:4200/#/common/dialog/draggable-dialog</example-url>
|
|
174
|
+
* <example-url>http://localhost:4200/#/common/dialog/fully-declarative</example-url>
|
|
175
|
+
* <example-url>http://localhost:4200/#/common/dialog/grid-snap-live-vs-release</example-url>
|
|
176
|
+
* <example-url>http://localhost:4200/#/common/dialog/nested-dialogs-cngxdialogstack</example-url>
|
|
177
|
+
* <example-url>http://localhost:4200/#/common/dialog/non-modal-panel</example-url>
|
|
178
|
+
* <example-url>http://localhost:4200/#/common/dialog/programmatic-control</example-url>
|
|
179
|
+
* <example-url>http://localhost:4200/#/common/dialog/template-directives</example-url>
|
|
123
180
|
*/
|
|
124
181
|
class CngxDialogDescription {
|
|
125
182
|
dialogRef = inject(DIALOG_REF, { optional: true });
|
|
@@ -150,9 +207,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
150
207
|
}]
|
|
151
208
|
}], ctorParameters: () => [] });
|
|
152
209
|
|
|
153
|
-
/**
|
|
210
|
+
/**
|
|
211
|
+
* Ref-count map for scroll lock - one lock per document root, shared across stacked modals.
|
|
212
|
+
*
|
|
213
|
+
* @internal
|
|
214
|
+
*/
|
|
154
215
|
const lockCounts = new WeakMap();
|
|
155
|
-
/**
|
|
216
|
+
/**
|
|
217
|
+
* Acquire a scroll lock on the document root, preserving prior overflow styles.
|
|
218
|
+
*
|
|
219
|
+
* @internal
|
|
220
|
+
*/
|
|
156
221
|
function acquireScrollLock(html) {
|
|
157
222
|
const count = lockCounts.get(html) ?? 0;
|
|
158
223
|
if (count === 0) {
|
|
@@ -163,7 +228,11 @@ function acquireScrollLock(html) {
|
|
|
163
228
|
}
|
|
164
229
|
lockCounts.set(html, count + 1);
|
|
165
230
|
}
|
|
166
|
-
/**
|
|
231
|
+
/**
|
|
232
|
+
* Release a scroll lock. Restores prior overflow styles when the count reaches zero.
|
|
233
|
+
*
|
|
234
|
+
* @internal
|
|
235
|
+
*/
|
|
167
236
|
function releaseScrollLock(html) {
|
|
168
237
|
const count = lockCounts.get(html) ?? 0;
|
|
169
238
|
if (count <= 1) {
|
|
@@ -232,6 +301,23 @@ function releaseScrollLock(html) {
|
|
|
232
301
|
* <input id="name-input" />
|
|
233
302
|
* </dialog>
|
|
234
303
|
* ```
|
|
304
|
+
*
|
|
305
|
+
* @category common/dialog
|
|
306
|
+
* @docsKind primary
|
|
307
|
+
* @wcag AA
|
|
308
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/dialog/dialog/dialog.directive.ts
|
|
309
|
+
* @since 0.1.0
|
|
310
|
+
* @relatedTo CngxBottomSheet, CngxDialogOpener, CngxDialogTitle, CngxDialogClose, CngxDialogDraggable
|
|
311
|
+
* <example-url>http://localhost:4200/#/common/dialog/alert-dialog</example-url>
|
|
312
|
+
* <example-url>http://localhost:4200/#/common/dialog/bottom-sheet</example-url>
|
|
313
|
+
* <example-url>http://localhost:4200/#/common/dialog/cngxdialogopener-programmatic</example-url>
|
|
314
|
+
* <example-url>http://localhost:4200/#/common/dialog/draggable-dialog</example-url>
|
|
315
|
+
* <example-url>http://localhost:4200/#/common/dialog/fully-declarative</example-url>
|
|
316
|
+
* <example-url>http://localhost:4200/#/common/dialog/grid-snap-live-vs-release</example-url>
|
|
317
|
+
* <example-url>http://localhost:4200/#/common/dialog/nested-dialogs-cngxdialogstack</example-url>
|
|
318
|
+
* <example-url>http://localhost:4200/#/common/dialog/non-modal-panel</example-url>
|
|
319
|
+
* <example-url>http://localhost:4200/#/common/dialog/programmatic-control</example-url>
|
|
320
|
+
* <example-url>http://localhost:4200/#/common/dialog/template-directives</example-url>
|
|
235
321
|
*/
|
|
236
322
|
class CngxDialog {
|
|
237
323
|
elRef = inject(ElementRef);
|
|
@@ -290,7 +376,7 @@ class CngxDialog {
|
|
|
290
376
|
*/
|
|
291
377
|
focusFallback = input(undefined, ...(ngDevMode ? [{ debugName: "focusFallback" }] : /* istanbul ignore next */ []));
|
|
292
378
|
/**
|
|
293
|
-
* Bind an async state
|
|
379
|
+
* Bind an async state - drives pending (aria-busy, prevents close) and
|
|
294
380
|
* error from a single source. When set, takes precedence over the
|
|
295
381
|
* `[error]` boolean input and `[submitAction]`.
|
|
296
382
|
*
|
|
@@ -306,7 +392,7 @@ class CngxDialog {
|
|
|
306
392
|
* On error, the dialog stays open with `cngx-dialog--error` and the error
|
|
307
393
|
* is announced to screen readers.
|
|
308
394
|
*
|
|
309
|
-
* When set, `close(value)` no longer closes immediately
|
|
395
|
+
* When set, `close(value)` no longer closes immediately - it enters a
|
|
310
396
|
* `submitting` phase (`isPending() = true`, `aria-busy`, close blocked).
|
|
311
397
|
*
|
|
312
398
|
* The submit lifecycle is exposed via `submitState: CngxAsyncState<unknown>`.
|
|
@@ -365,7 +451,7 @@ class CngxDialog {
|
|
|
365
451
|
/**
|
|
366
452
|
* `true` when any async operation is pending. Blocks close/dismiss and sets `aria-busy`.
|
|
367
453
|
*
|
|
368
|
-
* External `[state]` short-circuits
|
|
454
|
+
* External `[state]` short-circuits - when set, `submitAction` is ignored by the
|
|
369
455
|
* `close()` guard (`action && !this.state()`), so `submitStatusState` stays `'idle'`.
|
|
370
456
|
*/
|
|
371
457
|
isPending = computed(() => {
|
|
@@ -376,7 +462,7 @@ class CngxDialog {
|
|
|
376
462
|
return this.submitStatusState() === 'pending';
|
|
377
463
|
}, ...(ngDevMode ? [{ debugName: "isPending" }] : /* istanbul ignore next */ []));
|
|
378
464
|
/**
|
|
379
|
-
* Resolved error
|
|
465
|
+
* Resolved error - external `[state]` takes precedence over submit state,
|
|
380
466
|
* which takes precedence over the boolean `[error]` input.
|
|
381
467
|
*/
|
|
382
468
|
effectiveError = computed(() => {
|
|
@@ -396,7 +482,7 @@ class CngxDialog {
|
|
|
396
482
|
ariaModal = computed(() => this.modal() && this.lifecycleSignal() !== 'closed' ? 'true' : null, ...(ngDevMode ? [{ debugName: "ariaModal" }] : /* istanbul ignore next */ []));
|
|
397
483
|
ariaLabelledBy = computed(() => this.titleDirective()?.id() ?? null, ...(ngDevMode ? [{ debugName: "ariaLabelledBy" }] : /* istanbul ignore next */ []));
|
|
398
484
|
ariaDescribedBy = computed(() => this.descriptionDirective()?.id() ?? null, ...(ngDevMode ? [{ debugName: "ariaDescribedBy" }] : /* istanbul ignore next */ []));
|
|
399
|
-
backdropOpacity = computed(() => this.dialogStack.topmost() === this.idSignal() ?
|
|
485
|
+
backdropOpacity = computed(() => this.dialogStack.topmost() === this.idSignal() ? '1' : '0', ...(ngDevMode ? [{ debugName: "backdropOpacity" }] : /* istanbul ignore next */ []));
|
|
400
486
|
liveRegion = null;
|
|
401
487
|
constructor() {
|
|
402
488
|
this.createLiveRegion();
|
|
@@ -440,11 +526,9 @@ class CngxDialog {
|
|
|
440
526
|
return;
|
|
441
527
|
}
|
|
442
528
|
const dialog = this.dialogElement;
|
|
443
|
-
// Reset result and submit state from previous cycle
|
|
444
529
|
this.resultSignal.set(undefined);
|
|
445
530
|
this.submitStatusState.set('idle');
|
|
446
531
|
this.submitErrorState.set(undefined);
|
|
447
|
-
// Store trigger element for focus return
|
|
448
532
|
this.triggerElement.set(this.doc.activeElement);
|
|
449
533
|
this.lifecycleSignal.set('opening');
|
|
450
534
|
if (this.modal()) {
|
|
@@ -470,7 +554,7 @@ class CngxDialog {
|
|
|
470
554
|
*
|
|
471
555
|
* When `[submitAction]` is set and `[state]` is not set, executes the action
|
|
472
556
|
* with `value` before closing. The dialog enters a submitting phase
|
|
473
|
-
* (`isPending() = true`)
|
|
557
|
+
* (`isPending() = true`) - on success it auto-closes, on error it stays open.
|
|
474
558
|
*
|
|
475
559
|
* When `[submitAction]` is not set (or `[state]` overrides), closes immediately.
|
|
476
560
|
*
|
|
@@ -487,7 +571,6 @@ class CngxDialog {
|
|
|
487
571
|
return;
|
|
488
572
|
}
|
|
489
573
|
const action = this.submitAction();
|
|
490
|
-
// External [state] takes full precedence — submitAction is ignored
|
|
491
574
|
if (action && !this.state()) {
|
|
492
575
|
void this.executeSubmit(action, value);
|
|
493
576
|
}
|
|
@@ -703,6 +786,23 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
703
786
|
* <button [cngxDialogClose]="true">Confirm</button>
|
|
704
787
|
* </dialog>
|
|
705
788
|
* ```
|
|
789
|
+
*
|
|
790
|
+
* @category common/dialog
|
|
791
|
+
* @docsKind primary
|
|
792
|
+
* @wcag AA
|
|
793
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/dialog/dialog/dialog-close.directive.ts
|
|
794
|
+
* @since 0.1.0
|
|
795
|
+
* @relatedTo CngxDialog, CngxDialogTitle, CngxDialogDescription
|
|
796
|
+
* <example-url>http://localhost:4200/#/common/dialog/alert-dialog</example-url>
|
|
797
|
+
* <example-url>http://localhost:4200/#/common/dialog/bottom-sheet</example-url>
|
|
798
|
+
* <example-url>http://localhost:4200/#/common/dialog/cngxdialogopener-programmatic</example-url>
|
|
799
|
+
* <example-url>http://localhost:4200/#/common/dialog/draggable-dialog</example-url>
|
|
800
|
+
* <example-url>http://localhost:4200/#/common/dialog/fully-declarative</example-url>
|
|
801
|
+
* <example-url>http://localhost:4200/#/common/dialog/grid-snap-live-vs-release</example-url>
|
|
802
|
+
* <example-url>http://localhost:4200/#/common/dialog/nested-dialogs-cngxdialogstack</example-url>
|
|
803
|
+
* <example-url>http://localhost:4200/#/common/dialog/non-modal-panel</example-url>
|
|
804
|
+
* <example-url>http://localhost:4200/#/common/dialog/programmatic-control</example-url>
|
|
805
|
+
* <example-url>http://localhost:4200/#/common/dialog/template-directives</example-url>
|
|
706
806
|
*/
|
|
707
807
|
class CngxDialogClose {
|
|
708
808
|
dialogRef = inject(DIALOG_REF);
|
|
@@ -727,7 +827,6 @@ class CngxDialogClose {
|
|
|
727
827
|
* - `'Close dialog'` for icon-only / single-char content
|
|
728
828
|
*/
|
|
729
829
|
ariaLabel = computed(() => {
|
|
730
|
-
// Explicit override wins
|
|
731
830
|
const explicit = this.label();
|
|
732
831
|
if (explicit !== undefined) {
|
|
733
832
|
return explicit || null;
|
|
@@ -737,17 +836,15 @@ class CngxDialogClose {
|
|
|
737
836
|
if (el.hasAttribute('aria-label')) {
|
|
738
837
|
return null;
|
|
739
838
|
}
|
|
740
|
-
// Check text content — if descriptive (multi-char word), no label needed
|
|
741
839
|
const text = el.textContent?.trim() ?? '';
|
|
742
840
|
if (text.length > 1) {
|
|
743
841
|
return null;
|
|
744
842
|
}
|
|
745
|
-
// Icon-only or single char (e.g. "X", "x") — set default
|
|
746
843
|
return 'Close dialog';
|
|
747
844
|
}, ...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
|
|
748
845
|
handleClick() {
|
|
749
846
|
const v = this.value();
|
|
750
|
-
// Static attribute `cngxDialogClose` (no binding) resolves to ''
|
|
847
|
+
// Static attribute `cngxDialogClose` (no binding) resolves to '' - treat as dismiss.
|
|
751
848
|
// Only `[cngxDialogClose]="value"` with an explicit value calls close().
|
|
752
849
|
if (v !== undefined && v !== '') {
|
|
753
850
|
this.dialogRef.close(v);
|
|
@@ -773,7 +870,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
773
870
|
}]
|
|
774
871
|
}], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxDialogClose", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxDialogCloseLabel", required: false }] }] } });
|
|
775
872
|
|
|
776
|
-
/**
|
|
873
|
+
/**
|
|
874
|
+
* Injection token for data passed to a programmatically opened dialog via `CngxDialogOpener.open()`.
|
|
875
|
+
*
|
|
876
|
+
* @category common/dialog
|
|
877
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/dialog/dialog/dialog-config.ts
|
|
878
|
+
* @since 0.1.0
|
|
879
|
+
*/
|
|
777
880
|
const CNGX_DIALOG_DATA = new InjectionToken('CngxDialogData');
|
|
778
881
|
|
|
779
882
|
/**
|
|
@@ -843,6 +946,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
843
946
|
* if (result !== 'dismissed') console.log('Confirmed:', result);
|
|
844
947
|
* });
|
|
845
948
|
* ```
|
|
949
|
+
*
|
|
950
|
+
* @category common/dialog
|
|
951
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/dialog/dialog/dialog.service.ts
|
|
952
|
+
* @since 0.1.0
|
|
953
|
+
* @relatedTo CngxDialogOpener, CngxDialog, CNGX_DIALOG_DATA
|
|
846
954
|
*/
|
|
847
955
|
class CngxDialogRef {
|
|
848
956
|
inner;
|
|
@@ -927,7 +1035,7 @@ class CngxDialogRef {
|
|
|
927
1035
|
/**
|
|
928
1036
|
* Service for opening dialogs programmatically.
|
|
929
1037
|
*
|
|
930
|
-
* Works like `MatDialog.open()`
|
|
1038
|
+
* Works like `MatDialog.open()` - pass a component type and config,
|
|
931
1039
|
* get back a typed `CngxDialogRef<T>`.
|
|
932
1040
|
*
|
|
933
1041
|
* Must be provided via `provideDialog()`.
|
|
@@ -952,6 +1060,12 @@ class CngxDialogRef {
|
|
|
952
1060
|
* save(user: User) { this.dialogRef.close(user); }
|
|
953
1061
|
* }
|
|
954
1062
|
* ```
|
|
1063
|
+
*
|
|
1064
|
+
* @category common/dialog
|
|
1065
|
+
* @docsKind primary
|
|
1066
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/dialog/dialog/dialog.service.ts
|
|
1067
|
+
* @since 0.1.0
|
|
1068
|
+
* @relatedTo CngxDialog, CngxDialogRef, CNGX_DIALOG_DATA, CngxDialogStack
|
|
955
1069
|
*/
|
|
956
1070
|
class CngxDialogOpener {
|
|
957
1071
|
appRef = inject(ApplicationRef);
|
|
@@ -976,7 +1090,6 @@ class CngxDialogOpener {
|
|
|
976
1090
|
const innerDialog = outletRef.instance.dialog();
|
|
977
1091
|
const outletVcr = outletRef.instance.contentOutlet();
|
|
978
1092
|
let contentRef = null;
|
|
979
|
-
// Build a child injector that provides DIALOG_REF and CNGX_DIALOG_DATA
|
|
980
1093
|
const childInjector = Injector.create({
|
|
981
1094
|
parent: this.injector,
|
|
982
1095
|
providers: [
|
|
@@ -996,7 +1109,7 @@ class CngxDialogOpener {
|
|
|
996
1109
|
}
|
|
997
1110
|
const dialogRef = new CngxDialogRef(innerDialog, outletRef, contentRef, this.injector);
|
|
998
1111
|
this.openDialogs.push(dialogRef);
|
|
999
|
-
// CngxDialog has open() but the DialogRef<T> interface does not
|
|
1112
|
+
// CngxDialog has open() but the DialogRef<T> interface does not - call the concrete instance.
|
|
1000
1113
|
const dialogInstance = outletRef.instance.dialog();
|
|
1001
1114
|
dialogInstance.open();
|
|
1002
1115
|
effect(() => {
|
|
@@ -1051,19 +1164,21 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1051
1164
|
* providers: [provideDialog()],
|
|
1052
1165
|
* });
|
|
1053
1166
|
* ```
|
|
1167
|
+
*
|
|
1168
|
+
* @category common/dialog
|
|
1054
1169
|
*/
|
|
1055
1170
|
function provideDialog() {
|
|
1056
1171
|
return [CngxDialogOpener];
|
|
1057
1172
|
}
|
|
1058
1173
|
|
|
1059
1174
|
/**
|
|
1060
|
-
* Bottom sheet molecule
|
|
1175
|
+
* Bottom sheet molecule - a `CngxDialog` positioned at the viewport bottom
|
|
1061
1176
|
* with swipe-to-dismiss support.
|
|
1062
1177
|
*
|
|
1063
1178
|
* Place on the same `<dialog>` element alongside `cngxDialog`. Adds the
|
|
1064
1179
|
* `cngx-bottom-sheet` CSS class (styled by `bottom-sheet-theme.scss`).
|
|
1065
1180
|
* When `CngxSwipeDismiss` is also present, auto-wires the swipe output
|
|
1066
|
-
* to `dialogRef.dismiss()`
|
|
1181
|
+
* to `dialogRef.dismiss()` - no manual `(swiped)` binding needed.
|
|
1067
1182
|
*
|
|
1068
1183
|
* ### Basic bottom sheet
|
|
1069
1184
|
* ```html
|
|
@@ -1083,6 +1198,13 @@ function provideDialog() {
|
|
|
1083
1198
|
* <p>Content positioned at the bottom.</p>
|
|
1084
1199
|
* </dialog>
|
|
1085
1200
|
* ```
|
|
1201
|
+
*
|
|
1202
|
+
* @category common/dialog
|
|
1203
|
+
* @docsKind primary
|
|
1204
|
+
* @wcag AA
|
|
1205
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/dialog/bottom-sheet/bottom-sheet.directive.ts
|
|
1206
|
+
* @since 0.1.0
|
|
1207
|
+
* @relatedTo CngxDialog, CngxSwipeDismiss, CngxDialogClose
|
|
1086
1208
|
*/
|
|
1087
1209
|
class CngxBottomSheet {
|
|
1088
1210
|
dialogRef = inject(DIALOG_REF);
|
|
@@ -1097,7 +1219,6 @@ class CngxBottomSheet {
|
|
|
1097
1219
|
*/
|
|
1098
1220
|
showHandle = input(true, ...(ngDevMode ? [{ debugName: "showHandle" }] : /* istanbul ignore next */ []));
|
|
1099
1221
|
constructor() {
|
|
1100
|
-
// Auto-wire: swipe → dismiss (when CngxSwipeDismiss is on the same element)
|
|
1101
1222
|
if (this.swipe) {
|
|
1102
1223
|
const sub = this.swipe.swiped.subscribe(() => this.dialogRef.dismiss());
|
|
1103
1224
|
inject(DestroyRef).onDestroy(() => sub.unsubscribe());
|
|
@@ -1122,7 +1243,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1122
1243
|
* Opt-in drag behavior for `CngxDialog`.
|
|
1123
1244
|
*
|
|
1124
1245
|
* Uses Pointer Events for unified mouse/touch handling. Position is exposed
|
|
1125
|
-
* as CSS custom properties `--cngx-dialog-x` and `--cngx-dialog-y`
|
|
1246
|
+
* as CSS custom properties `--cngx-dialog-x` and `--cngx-dialog-y` - the
|
|
1126
1247
|
* consumer applies the transform via CSS.
|
|
1127
1248
|
*
|
|
1128
1249
|
* Keyboard-based moving is mandatory for accessibility:
|
|
@@ -1142,6 +1263,23 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1142
1263
|
* transform: translate(var(--cngx-dialog-x, 0px), var(--cngx-dialog-y, 0px));
|
|
1143
1264
|
* }
|
|
1144
1265
|
* ```
|
|
1266
|
+
*
|
|
1267
|
+
* @category common/dialog
|
|
1268
|
+
* @docsKind primary
|
|
1269
|
+
* @wcag AA
|
|
1270
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/dialog/draggable/dialog-draggable.directive.ts
|
|
1271
|
+
* @since 0.1.0
|
|
1272
|
+
* @relatedTo CngxDialog, CngxBottomSheet
|
|
1273
|
+
* <example-url>http://localhost:4200/#/common/dialog/alert-dialog</example-url>
|
|
1274
|
+
* <example-url>http://localhost:4200/#/common/dialog/bottom-sheet</example-url>
|
|
1275
|
+
* <example-url>http://localhost:4200/#/common/dialog/cngxdialogopener-programmatic</example-url>
|
|
1276
|
+
* <example-url>http://localhost:4200/#/common/dialog/draggable-dialog</example-url>
|
|
1277
|
+
* <example-url>http://localhost:4200/#/common/dialog/fully-declarative</example-url>
|
|
1278
|
+
* <example-url>http://localhost:4200/#/common/dialog/grid-snap-live-vs-release</example-url>
|
|
1279
|
+
* <example-url>http://localhost:4200/#/common/dialog/nested-dialogs-cngxdialogstack</example-url>
|
|
1280
|
+
* <example-url>http://localhost:4200/#/common/dialog/non-modal-panel</example-url>
|
|
1281
|
+
* <example-url>http://localhost:4200/#/common/dialog/programmatic-control</example-url>
|
|
1282
|
+
* <example-url>http://localhost:4200/#/common/dialog/template-directives</example-url>
|
|
1145
1283
|
*/
|
|
1146
1284
|
class CngxDialogDraggable {
|
|
1147
1285
|
elRef = inject(ElementRef);
|
|
@@ -1164,8 +1302,8 @@ class CngxDialogDraggable {
|
|
|
1164
1302
|
/**
|
|
1165
1303
|
* When to apply grid snapping.
|
|
1166
1304
|
*
|
|
1167
|
-
* - `'live'`
|
|
1168
|
-
* - `'release'`
|
|
1305
|
+
* - `'live'` - position snaps continuously during drag (default)
|
|
1306
|
+
* - `'release'` - position is free during drag, snaps on pointer up
|
|
1169
1307
|
*
|
|
1170
1308
|
* @defaultValue `'live'`
|
|
1171
1309
|
*/
|
|
@@ -1178,7 +1316,7 @@ class CngxDialogDraggable {
|
|
|
1178
1316
|
isDragging = this.draggingState.asReadonly();
|
|
1179
1317
|
cssX = computed(() => `${this.positionState().x}px`, ...(ngDevMode ? [{ debugName: "cssX" }] : /* istanbul ignore next */ []));
|
|
1180
1318
|
cssY = computed(() => `${this.positionState().y}px`, ...(ngDevMode ? [{ debugName: "cssY" }] : /* istanbul ignore next */ []));
|
|
1181
|
-
// Drag state
|
|
1319
|
+
// Drag state - not reactive, perf critical (pointermove runs at framerate).
|
|
1182
1320
|
dragStartX = 0;
|
|
1183
1321
|
dragStartY = 0;
|
|
1184
1322
|
posStartX = 0;
|