angular-material-wrap 0.1.0-beta.6 → 0.1.0-beta.7
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.
|
@@ -7370,74 +7370,286 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImpor
|
|
|
7370
7370
|
}] }], propDecorators: { config: [{ type: i0.Input, args: [{ isSignal: true, alias: "config", required: false }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], position: [{ type: i0.Input, args: [{ isSignal: true, alias: "position", required: false }] }], title: [{ type: i0.Input, args: [{ isSignal: true, alias: "title", required: false }] }], content: [{ type: i0.Input, args: [{ isSignal: true, alias: "content", required: false }] }], actions: [{ type: i0.Input, args: [{ isSignal: true, alias: "actions", required: false }] }], showCloseButton: [{ type: i0.Input, args: [{ isSignal: true, alias: "showCloseButton", required: false }] }], showHeader: [{ type: i0.Input, args: [{ isSignal: true, alias: "showHeader", required: false }] }], showFooter: [{ type: i0.Input, args: [{ isSignal: true, alias: "showFooter", required: false }] }], loading: [{ type: i0.Input, args: [{ isSignal: true, alias: "loading", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], closable: [{ type: i0.Input, args: [{ isSignal: true, alias: "closable", required: false }] }], backdrop: [{ type: i0.Input, args: [{ isSignal: true, alias: "backdrop", required: false }] }], escapeKeyClose: [{ type: i0.Input, args: [{ isSignal: true, alias: "escapeKeyClose", required: false }] }], clickOutsideClose: [{ type: i0.Input, args: [{ isSignal: true, alias: "clickOutsideClose", required: false }] }], maxWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxWidth", required: false }] }], maxHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxHeight", required: false }] }], minWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "minWidth", required: false }] }], minHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "minHeight", required: false }] }], width: [{ type: i0.Input, args: [{ isSignal: true, alias: "width", required: false }] }], height: [{ type: i0.Input, args: [{ isSignal: true, alias: "height", required: false }] }], autoFocus: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoFocus", required: false }] }], restoreFocus: [{ type: i0.Input, args: [{ isSignal: true, alias: "restoreFocus", required: false }] }], hasBackdrop: [{ type: i0.Input, args: [{ isSignal: true, alias: "hasBackdrop", required: false }] }], backdropClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "backdropClass", required: false }] }], panelClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "panelClass", required: false }] }], dialogOpen: [{ type: i0.Output, args: ["dialogOpen"] }], dialogClose: [{ type: i0.Output, args: ["dialogClose"] }], dialogAfterOpen: [{ type: i0.Output, args: ["dialogAfterOpen"] }], dialogAfterClose: [{ type: i0.Output, args: ["dialogAfterClose"] }], actionClick: [{ type: i0.Output, args: ["actionClick"] }], closeClick: [{ type: i0.Output, args: ["closeClick"] }], headerTemplate: [{ type: i0.ContentChild, args: ['dialogHeader', { isSignal: true }] }], contentTemplate: [{ type: i0.ContentChild, args: ['dialogContent', { isSignal: true }] }], footerTemplate: [{ type: i0.ContentChild, args: ['dialogFooter', { isSignal: true }] }] } });
|
|
7371
7371
|
|
|
7372
7372
|
/**
|
|
7373
|
-
*
|
|
7373
|
+
* Modern dialog reference that provides typed access to the component instance.
|
|
7374
|
+
* Use with signal-based communication patterns for reactive dialog interactions.
|
|
7374
7375
|
*
|
|
7375
|
-
*
|
|
7376
|
-
*
|
|
7376
|
+
* @example
|
|
7377
|
+
* ```typescript
|
|
7378
|
+
* const dialogRef = this.dialogService.open('Edit User', EditUserComponent, {
|
|
7379
|
+
* data: { userId: 123 }
|
|
7380
|
+
* });
|
|
7381
|
+
*
|
|
7382
|
+
* // Signal-based communication (recommended)
|
|
7383
|
+
* effect(() => {
|
|
7384
|
+
* const savedData = dialogRef.instance.saveSignal();
|
|
7385
|
+
* if (savedData) {
|
|
7386
|
+
* this.handleSave(savedData);
|
|
7387
|
+
* dialogRef.close();
|
|
7388
|
+
* }
|
|
7389
|
+
* });
|
|
7390
|
+
* ```
|
|
7391
|
+
*/
|
|
7392
|
+
class AmwDialogRef {
|
|
7393
|
+
matDialogRef;
|
|
7394
|
+
_instance;
|
|
7395
|
+
_afterClosed = new Subject();
|
|
7396
|
+
_afterOpened = new Subject();
|
|
7397
|
+
constructor(matDialogRef, _instance) {
|
|
7398
|
+
this.matDialogRef = matDialogRef;
|
|
7399
|
+
this._instance = _instance;
|
|
7400
|
+
// Forward MatDialogRef events
|
|
7401
|
+
this.matDialogRef.afterClosed().subscribe(result => {
|
|
7402
|
+
this._afterClosed.next(result);
|
|
7403
|
+
this._afterClosed.complete();
|
|
7404
|
+
});
|
|
7405
|
+
this.matDialogRef.afterOpened().subscribe(() => {
|
|
7406
|
+
this._afterOpened.next();
|
|
7407
|
+
this._afterOpened.complete();
|
|
7408
|
+
});
|
|
7409
|
+
}
|
|
7410
|
+
/**
|
|
7411
|
+
* The component instance inside the dialog.
|
|
7412
|
+
* Use this to access signals and methods on your dialog component.
|
|
7413
|
+
*/
|
|
7414
|
+
get instance() {
|
|
7415
|
+
return this._instance;
|
|
7416
|
+
}
|
|
7417
|
+
/**
|
|
7418
|
+
* Closes the dialog with an optional result value.
|
|
7419
|
+
*/
|
|
7420
|
+
close(result) {
|
|
7421
|
+
this.matDialogRef.close(result);
|
|
7422
|
+
}
|
|
7423
|
+
/**
|
|
7424
|
+
* Observable that emits when the dialog is closed.
|
|
7425
|
+
*/
|
|
7426
|
+
afterClosed() {
|
|
7427
|
+
return this._afterClosed.asObservable();
|
|
7428
|
+
}
|
|
7429
|
+
/**
|
|
7430
|
+
* Observable that emits when the dialog is opened.
|
|
7431
|
+
*/
|
|
7432
|
+
afterOpened() {
|
|
7433
|
+
return this._afterOpened.asObservable();
|
|
7434
|
+
}
|
|
7435
|
+
/**
|
|
7436
|
+
* Updates the dialog's position.
|
|
7437
|
+
*/
|
|
7438
|
+
updatePosition(position) {
|
|
7439
|
+
this.matDialogRef.updatePosition(position);
|
|
7440
|
+
return this;
|
|
7441
|
+
}
|
|
7442
|
+
/**
|
|
7443
|
+
* Updates the dialog's size.
|
|
7444
|
+
*/
|
|
7445
|
+
updateSize(width, height) {
|
|
7446
|
+
this.matDialogRef.updateSize(width, height);
|
|
7447
|
+
return this;
|
|
7448
|
+
}
|
|
7449
|
+
/**
|
|
7450
|
+
* Adds a CSS class to the dialog panel.
|
|
7451
|
+
*/
|
|
7452
|
+
addPanelClass(classes) {
|
|
7453
|
+
this.matDialogRef.addPanelClass(classes);
|
|
7454
|
+
return this;
|
|
7455
|
+
}
|
|
7456
|
+
/**
|
|
7457
|
+
* Removes a CSS class from the dialog panel.
|
|
7458
|
+
*/
|
|
7459
|
+
removePanelClass(classes) {
|
|
7460
|
+
this.matDialogRef.removePanelClass(classes);
|
|
7461
|
+
return this;
|
|
7462
|
+
}
|
|
7463
|
+
}
|
|
7464
|
+
/**
|
|
7465
|
+
* Service for managing dialogs programmatically.
|
|
7466
|
+
*
|
|
7467
|
+
* ## Recommended Usage (Signal-based)
|
|
7468
|
+
*
|
|
7469
|
+
* The preferred way to use dialogs is with the `open()` method and signal-based
|
|
7470
|
+
* communication for reactive interactions:
|
|
7377
7471
|
*
|
|
7378
7472
|
* @example
|
|
7379
7473
|
* ```typescript
|
|
7474
|
+
* // In your component
|
|
7380
7475
|
* constructor(private dialogService: DialogService) {}
|
|
7381
7476
|
*
|
|
7382
|
-
*
|
|
7383
|
-
* this.dialogService.
|
|
7384
|
-
* }
|
|
7477
|
+
* openEditor() {
|
|
7478
|
+
* const dialogRef = this.dialogService.open('Edit Item', EditItemComponent, {
|
|
7479
|
+
* data: { itemId: this.itemId }
|
|
7480
|
+
* });
|
|
7385
7481
|
*
|
|
7386
|
-
*
|
|
7387
|
-
*
|
|
7388
|
-
*
|
|
7389
|
-
*
|
|
7482
|
+
* // React to signals from the dialog component
|
|
7483
|
+
* effect(() => {
|
|
7484
|
+
* const savedItem = dialogRef.instance.savedItem();
|
|
7485
|
+
* if (savedItem) {
|
|
7486
|
+
* this.items.update(items => [...items, savedItem]);
|
|
7487
|
+
* dialogRef.close();
|
|
7390
7488
|
* }
|
|
7391
7489
|
* });
|
|
7392
7490
|
* }
|
|
7393
7491
|
* ```
|
|
7492
|
+
*
|
|
7493
|
+
* ```typescript
|
|
7494
|
+
* // In your dialog component
|
|
7495
|
+
* import { getAmwDialogTitle, AmwDialogData } from '@amw/dialog';
|
|
7496
|
+
*
|
|
7497
|
+
* @Component({
|
|
7498
|
+
* selector: 'app-edit-item',
|
|
7499
|
+
* template: `
|
|
7500
|
+
* <h2 mat-dialog-title>{{ title }}</h2>
|
|
7501
|
+
* <mat-dialog-content>
|
|
7502
|
+
* <!-- form content -->
|
|
7503
|
+
* </mat-dialog-content>
|
|
7504
|
+
* <mat-dialog-actions>
|
|
7505
|
+
* <amw-button (click)="cancel()">Cancel</amw-button>
|
|
7506
|
+
* <amw-button color="primary" (click)="save()">Save</amw-button>
|
|
7507
|
+
* </mat-dialog-actions>
|
|
7508
|
+
* `
|
|
7509
|
+
* })
|
|
7510
|
+
* export class EditItemComponent {
|
|
7511
|
+
* readonly data = inject<{ itemId: number } & AmwDialogData>(MAT_DIALOG_DATA);
|
|
7512
|
+
* readonly title = getAmwDialogTitle(this.data);
|
|
7513
|
+
*
|
|
7514
|
+
* // Signal for communicating save events to parent
|
|
7515
|
+
* readonly savedItem = signal<Item | null>(null);
|
|
7516
|
+
*
|
|
7517
|
+
* save() {
|
|
7518
|
+
* // Setting the signal triggers the effect in the parent
|
|
7519
|
+
* this.savedItem.set(this.form.value);
|
|
7520
|
+
* }
|
|
7521
|
+
*
|
|
7522
|
+
* cancel() {
|
|
7523
|
+
* this.savedItem.set(null); // Parent handles closing
|
|
7524
|
+
* }
|
|
7525
|
+
* }
|
|
7526
|
+
* ```
|
|
7527
|
+
*
|
|
7528
|
+
* ## Legacy Usage
|
|
7529
|
+
*
|
|
7530
|
+
* The convenience methods (alert, confirm, etc.) are still available but
|
|
7531
|
+
* are considered legacy patterns. Prefer the signal-based approach for
|
|
7532
|
+
* new development.
|
|
7394
7533
|
*/
|
|
7395
7534
|
class DialogService {
|
|
7396
7535
|
dialog;
|
|
7397
|
-
|
|
7536
|
+
injector;
|
|
7537
|
+
constructor(dialog, injector) {
|
|
7398
7538
|
this.dialog = dialog;
|
|
7539
|
+
this.injector = injector;
|
|
7399
7540
|
}
|
|
7400
7541
|
/**
|
|
7401
|
-
* Opens a
|
|
7542
|
+
* Opens a dialog with a custom component.
|
|
7402
7543
|
*
|
|
7403
|
-
*
|
|
7404
|
-
*
|
|
7544
|
+
* This is the recommended way to open dialogs. It returns an AmwDialogRef
|
|
7545
|
+
* that provides typed access to the component instance for signal-based
|
|
7546
|
+
* communication.
|
|
7547
|
+
*
|
|
7548
|
+
* @param title - The dialog title (accessible via getAmwDialogTitle(data) in your component)
|
|
7549
|
+
* @param component - The Angular component to display in the dialog
|
|
7550
|
+
* @param config - Optional dialog configuration
|
|
7551
|
+
* @returns AmwDialogRef with typed access to the component instance
|
|
7405
7552
|
*
|
|
7406
7553
|
* @example
|
|
7407
7554
|
* ```typescript
|
|
7408
|
-
* const dialogRef = this.dialogService.open({
|
|
7409
|
-
*
|
|
7410
|
-
*
|
|
7411
|
-
* type: 'info',
|
|
7412
|
-
* size: 'medium',
|
|
7413
|
-
* actions: [
|
|
7414
|
-
* { label: 'OK', action: 'close', color: 'primary' }
|
|
7415
|
-
* ]
|
|
7555
|
+
* const dialogRef = this.dialogService.open('Edit User', EditUserComponent, {
|
|
7556
|
+
* width: '600px',
|
|
7557
|
+
* data: { userId: 123 }
|
|
7416
7558
|
* });
|
|
7417
7559
|
*
|
|
7418
|
-
*
|
|
7419
|
-
*
|
|
7560
|
+
* // Access component signals
|
|
7561
|
+
* effect(() => {
|
|
7562
|
+
* const saved = dialogRef.instance.saveSignal();
|
|
7563
|
+
* if (saved) {
|
|
7564
|
+
* this.handleSave(saved);
|
|
7565
|
+
* dialogRef.close();
|
|
7566
|
+
* }
|
|
7420
7567
|
* });
|
|
7421
7568
|
* ```
|
|
7422
7569
|
*/
|
|
7423
|
-
open(
|
|
7570
|
+
open(title, component, config) {
|
|
7571
|
+
// Embed the title in the data object for component access via getAmwDialogTitle()
|
|
7572
|
+
const dataWithTitle = {
|
|
7573
|
+
...(config?.data ?? {}),
|
|
7574
|
+
_amwTitle: title
|
|
7575
|
+
};
|
|
7576
|
+
const matConfig = {
|
|
7577
|
+
width: config?.width ?? '500px',
|
|
7578
|
+
height: config?.height,
|
|
7579
|
+
maxWidth: config?.maxWidth ?? '90vw',
|
|
7580
|
+
maxHeight: config?.maxHeight ?? '90vh',
|
|
7581
|
+
minWidth: config?.minWidth,
|
|
7582
|
+
minHeight: config?.minHeight,
|
|
7583
|
+
position: config?.position,
|
|
7584
|
+
hasBackdrop: config?.hasBackdrop ?? true,
|
|
7585
|
+
backdropClass: config?.backdropClass ?? 'amw-dialog-backdrop',
|
|
7586
|
+
panelClass: config?.panelClass ?? 'amw-dialog-panel',
|
|
7587
|
+
disableClose: config?.disableClose ?? false,
|
|
7588
|
+
autoFocus: config?.autoFocus ?? 'first-tabbable',
|
|
7589
|
+
restoreFocus: config?.restoreFocus ?? true,
|
|
7590
|
+
data: dataWithTitle
|
|
7591
|
+
};
|
|
7592
|
+
const matDialogRef = this.dialog.open(component, matConfig);
|
|
7593
|
+
// Create and return our typed dialog ref
|
|
7594
|
+
const dialogRef = new AmwDialogRef(matDialogRef, matDialogRef.componentInstance);
|
|
7595
|
+
// Inject the dialog ref into the component if it has a dialogRef property
|
|
7596
|
+
if (matDialogRef.componentInstance && typeof matDialogRef.componentInstance === 'object') {
|
|
7597
|
+
matDialogRef.componentInstance._amwDialogRef = dialogRef;
|
|
7598
|
+
}
|
|
7599
|
+
return dialogRef;
|
|
7600
|
+
}
|
|
7601
|
+
/**
|
|
7602
|
+
* @deprecated Use `open(title, component, config)` instead.
|
|
7603
|
+
* Opens a standard dialog with custom configuration using the legacy options pattern.
|
|
7604
|
+
*
|
|
7605
|
+
* Migrate to the new signal-based pattern:
|
|
7606
|
+
* ```typescript
|
|
7607
|
+
* // Old pattern (deprecated)
|
|
7608
|
+
* this.dialogService.openWithOptions({ title: 'My Dialog', content: '...' });
|
|
7609
|
+
*
|
|
7610
|
+
* // New pattern (recommended)
|
|
7611
|
+
* const ref = this.dialogService.open('My Dialog', MyDialogComponent);
|
|
7612
|
+
* ```
|
|
7613
|
+
*/
|
|
7614
|
+
openWithOptions(options) {
|
|
7615
|
+
console.warn('[DialogService] openWithOptions() is deprecated. ' +
|
|
7616
|
+
'Use open(title, component, config) with signal-based communication instead.');
|
|
7424
7617
|
const config = this.getDialogConfig(options);
|
|
7425
7618
|
return this.dialog.open(AmwDialogComponent, config);
|
|
7426
7619
|
}
|
|
7427
7620
|
/**
|
|
7428
|
-
*
|
|
7621
|
+
* @deprecated Use `open(title, component, config)` instead.
|
|
7622
|
+
* Opens a custom dialog with any Angular component.
|
|
7429
7623
|
*
|
|
7430
|
-
*
|
|
7431
|
-
*
|
|
7432
|
-
*
|
|
7624
|
+
* Migrate to the new pattern:
|
|
7625
|
+
* ```typescript
|
|
7626
|
+
* // Old pattern (deprecated)
|
|
7627
|
+
* this.dialogService.openComponent(MyComponent, { data: { id: 1 } });
|
|
7433
7628
|
*
|
|
7434
|
-
*
|
|
7629
|
+
* // New pattern (recommended)
|
|
7630
|
+
* const ref = this.dialogService.open('Title', MyComponent, { data: { id: 1 } });
|
|
7631
|
+
* ```
|
|
7632
|
+
*/
|
|
7633
|
+
openComponent(component, config) {
|
|
7634
|
+
console.warn('[DialogService] openComponent() is deprecated. ' +
|
|
7635
|
+
'Use open(title, component, config) with signal-based communication instead.');
|
|
7636
|
+
return this.dialog.open(component, config);
|
|
7637
|
+
}
|
|
7638
|
+
/**
|
|
7639
|
+
* @deprecated Use a custom dialog component with signal-based communication instead.
|
|
7640
|
+
* Opens an alert dialog with a single OK button.
|
|
7641
|
+
*
|
|
7642
|
+
* For new code, create a reusable alert component and use signals:
|
|
7435
7643
|
* ```typescript
|
|
7436
|
-
* this.dialogService.
|
|
7644
|
+
* const ref = this.dialogService.open('Alert', AlertComponent, {
|
|
7645
|
+
* data: { message: 'Operation completed!' }
|
|
7646
|
+
* });
|
|
7437
7647
|
* ```
|
|
7438
7648
|
*/
|
|
7439
7649
|
alert(message, title = 'Alert') {
|
|
7440
|
-
|
|
7650
|
+
console.warn('[DialogService] alert() is deprecated. ' +
|
|
7651
|
+
'Use open(title, component, config) with a custom alert component instead.');
|
|
7652
|
+
return this.openWithOptions({
|
|
7441
7653
|
title,
|
|
7442
7654
|
content: message,
|
|
7443
7655
|
type: 'alert',
|
|
@@ -7448,24 +7660,26 @@ class DialogService {
|
|
|
7448
7660
|
});
|
|
7449
7661
|
}
|
|
7450
7662
|
/**
|
|
7451
|
-
*
|
|
7663
|
+
* @deprecated Use a custom dialog component with signal-based communication instead.
|
|
7664
|
+
* Opens a confirmation dialog with Cancel and Confirm buttons.
|
|
7452
7665
|
*
|
|
7453
|
-
*
|
|
7454
|
-
* @param title - Dialog title (default: 'Confirm')
|
|
7455
|
-
* @returns Observable that emits the result when dialog closes
|
|
7456
|
-
*
|
|
7457
|
-
* @example
|
|
7666
|
+
* For new code, create a reusable confirm component and use signals:
|
|
7458
7667
|
* ```typescript
|
|
7459
|
-
* this.dialogService.
|
|
7460
|
-
*
|
|
7461
|
-
*
|
|
7462
|
-
*
|
|
7463
|
-
*
|
|
7464
|
-
*
|
|
7668
|
+
* const ref = this.dialogService.open('Confirm', ConfirmComponent, {
|
|
7669
|
+
* data: { message: 'Are you sure?' }
|
|
7670
|
+
* });
|
|
7671
|
+
* effect(() => {
|
|
7672
|
+
* if (ref.instance.confirmed()) {
|
|
7673
|
+
* // Handle confirmation
|
|
7674
|
+
* ref.close();
|
|
7675
|
+
* }
|
|
7676
|
+
* });
|
|
7465
7677
|
* ```
|
|
7466
7678
|
*/
|
|
7467
7679
|
confirm(message, title = 'Confirm') {
|
|
7468
|
-
|
|
7680
|
+
console.warn('[DialogService] confirm() is deprecated. ' +
|
|
7681
|
+
'Use open(title, component, config) with a custom confirm component instead.');
|
|
7682
|
+
const dialogRef = this.openWithOptions({
|
|
7469
7683
|
title,
|
|
7470
7684
|
content: message,
|
|
7471
7685
|
type: 'confirm',
|
|
@@ -7478,25 +7692,13 @@ class DialogService {
|
|
|
7478
7692
|
return dialogRef.afterClosed();
|
|
7479
7693
|
}
|
|
7480
7694
|
/**
|
|
7481
|
-
*
|
|
7482
|
-
*
|
|
7483
|
-
* @param message - Prompt message to display
|
|
7484
|
-
* @param title - Dialog title (default: 'Prompt')
|
|
7485
|
-
* @param defaultValue - Default input value (default: '')
|
|
7486
|
-
* @returns Observable that emits the result when dialog closes
|
|
7487
|
-
*
|
|
7488
|
-
* @example
|
|
7489
|
-
* ```typescript
|
|
7490
|
-
* this.dialogService.prompt('Enter your name:', 'User Input', 'John Doe')
|
|
7491
|
-
* .subscribe(result => {
|
|
7492
|
-
* if (result === 'confirm') {
|
|
7493
|
-
* console.log('User input:', result);
|
|
7494
|
-
* }
|
|
7495
|
-
* });
|
|
7496
|
-
* ```
|
|
7695
|
+
* @deprecated Use a custom dialog component with signal-based communication instead.
|
|
7696
|
+
* Opens a prompt dialog for user input.
|
|
7497
7697
|
*/
|
|
7498
7698
|
prompt(message, title = 'Prompt', defaultValue = '') {
|
|
7499
|
-
|
|
7699
|
+
console.warn('[DialogService] prompt() is deprecated. ' +
|
|
7700
|
+
'Use open(title, component, config) with a custom prompt component instead.');
|
|
7701
|
+
const dialogRef = this.openWithOptions({
|
|
7500
7702
|
title,
|
|
7501
7703
|
content: message,
|
|
7502
7704
|
type: 'prompt',
|
|
@@ -7510,19 +7712,13 @@ class DialogService {
|
|
|
7510
7712
|
return dialogRef.afterClosed();
|
|
7511
7713
|
}
|
|
7512
7714
|
/**
|
|
7513
|
-
*
|
|
7514
|
-
*
|
|
7515
|
-
* @param message - Information message to display
|
|
7516
|
-
* @param title - Dialog title (default: 'Information')
|
|
7517
|
-
* @returns MatDialogRef for the opened dialog
|
|
7518
|
-
*
|
|
7519
|
-
* @example
|
|
7520
|
-
* ```typescript
|
|
7521
|
-
* this.dialogService.info('This feature is coming soon!', 'Feature Notice');
|
|
7522
|
-
* ```
|
|
7715
|
+
* @deprecated Use a custom dialog component with signal-based communication instead.
|
|
7716
|
+
* Opens an informational dialog.
|
|
7523
7717
|
*/
|
|
7524
7718
|
info(message, title = 'Information') {
|
|
7525
|
-
|
|
7719
|
+
console.warn('[DialogService] info() is deprecated. ' +
|
|
7720
|
+
'Use open(title, component, config) with a custom info component instead.');
|
|
7721
|
+
return this.openWithOptions({
|
|
7526
7722
|
title,
|
|
7527
7723
|
content: message,
|
|
7528
7724
|
type: 'info',
|
|
@@ -7533,24 +7729,13 @@ class DialogService {
|
|
|
7533
7729
|
});
|
|
7534
7730
|
}
|
|
7535
7731
|
/**
|
|
7536
|
-
*
|
|
7537
|
-
*
|
|
7538
|
-
* @param message - Warning message to display
|
|
7539
|
-
* @param title - Dialog title (default: 'Warning')
|
|
7540
|
-
* @returns Observable that emits the result when dialog closes
|
|
7541
|
-
*
|
|
7542
|
-
* @example
|
|
7543
|
-
* ```typescript
|
|
7544
|
-
* this.dialogService.warning('This action cannot be undone!', 'Warning')
|
|
7545
|
-
* .subscribe(result => {
|
|
7546
|
-
* if (result === 'confirm') {
|
|
7547
|
-
* this.performDestructiveAction();
|
|
7548
|
-
* }
|
|
7549
|
-
* });
|
|
7550
|
-
* ```
|
|
7732
|
+
* @deprecated Use a custom dialog component with signal-based communication instead.
|
|
7733
|
+
* Opens a warning dialog with Cancel and Proceed buttons.
|
|
7551
7734
|
*/
|
|
7552
7735
|
warning(message, title = 'Warning') {
|
|
7553
|
-
|
|
7736
|
+
console.warn('[DialogService] warning() is deprecated. ' +
|
|
7737
|
+
'Use open(title, component, config) with a custom warning component instead.');
|
|
7738
|
+
const dialogRef = this.openWithOptions({
|
|
7554
7739
|
title,
|
|
7555
7740
|
content: message,
|
|
7556
7741
|
type: 'warning',
|
|
@@ -7563,19 +7748,13 @@ class DialogService {
|
|
|
7563
7748
|
return dialogRef.afterClosed();
|
|
7564
7749
|
}
|
|
7565
7750
|
/**
|
|
7566
|
-
*
|
|
7567
|
-
*
|
|
7568
|
-
* @param message - Error message to display
|
|
7569
|
-
* @param title - Dialog title (default: 'Error')
|
|
7570
|
-
* @returns MatDialogRef for the opened dialog
|
|
7571
|
-
*
|
|
7572
|
-
* @example
|
|
7573
|
-
* ```typescript
|
|
7574
|
-
* this.dialogService.error('Failed to save data. Please try again.', 'Save Error');
|
|
7575
|
-
* ```
|
|
7751
|
+
* @deprecated Use a custom dialog component with signal-based communication instead.
|
|
7752
|
+
* Opens an error dialog.
|
|
7576
7753
|
*/
|
|
7577
7754
|
error(message, title = 'Error') {
|
|
7578
|
-
|
|
7755
|
+
console.warn('[DialogService] error() is deprecated. ' +
|
|
7756
|
+
'Use open(title, component, config) with a custom error component instead.');
|
|
7757
|
+
return this.openWithOptions({
|
|
7579
7758
|
title,
|
|
7580
7759
|
content: message,
|
|
7581
7760
|
type: 'error',
|
|
@@ -7586,19 +7765,13 @@ class DialogService {
|
|
|
7586
7765
|
});
|
|
7587
7766
|
}
|
|
7588
7767
|
/**
|
|
7589
|
-
*
|
|
7590
|
-
*
|
|
7591
|
-
* @param message - Success message to display
|
|
7592
|
-
* @param title - Dialog title (default: 'Success')
|
|
7593
|
-
* @returns MatDialogRef for the opened dialog
|
|
7594
|
-
*
|
|
7595
|
-
* @example
|
|
7596
|
-
* ```typescript
|
|
7597
|
-
* this.dialogService.success('Data saved successfully!', 'Success');
|
|
7598
|
-
* ```
|
|
7768
|
+
* @deprecated Use a custom dialog component with signal-based communication instead.
|
|
7769
|
+
* Opens a success dialog.
|
|
7599
7770
|
*/
|
|
7600
7771
|
success(message, title = 'Success') {
|
|
7601
|
-
|
|
7772
|
+
console.warn('[DialogService] success() is deprecated. ' +
|
|
7773
|
+
'Use open(title, component, config) with a custom success component instead.');
|
|
7774
|
+
return this.openWithOptions({
|
|
7602
7775
|
title,
|
|
7603
7776
|
content: message,
|
|
7604
7777
|
type: 'success',
|
|
@@ -7609,25 +7782,13 @@ class DialogService {
|
|
|
7609
7782
|
});
|
|
7610
7783
|
}
|
|
7611
7784
|
/**
|
|
7612
|
-
*
|
|
7613
|
-
*
|
|
7614
|
-
* @param message - Loading message to display (default: 'Loading...')
|
|
7615
|
-
* @param title - Dialog title (default: 'Please wait')
|
|
7616
|
-
* @returns MatDialogRef for the opened dialog
|
|
7617
|
-
*
|
|
7618
|
-
* @example
|
|
7619
|
-
* ```typescript
|
|
7620
|
-
* const loadingDialog = this.dialogService.loading('Processing your request...', 'Please wait');
|
|
7621
|
-
*
|
|
7622
|
-
* // Simulate async operation
|
|
7623
|
-
* setTimeout(() => {
|
|
7624
|
-
* loadingDialog.close();
|
|
7625
|
-
* this.dialogService.success('Complete!', 'Success');
|
|
7626
|
-
* }, 3000);
|
|
7627
|
-
* ```
|
|
7785
|
+
* @deprecated Use a custom dialog component with signal-based communication instead.
|
|
7786
|
+
* Opens a loading dialog with spinner.
|
|
7628
7787
|
*/
|
|
7629
7788
|
loading(message = 'Loading...', title = 'Please wait') {
|
|
7630
|
-
|
|
7789
|
+
console.warn('[DialogService] loading() is deprecated. ' +
|
|
7790
|
+
'Use open(title, component, config) with a custom loading component instead.');
|
|
7791
|
+
return this.openWithOptions({
|
|
7631
7792
|
title,
|
|
7632
7793
|
content: message,
|
|
7633
7794
|
loading: true,
|
|
@@ -7639,60 +7800,19 @@ class DialogService {
|
|
|
7639
7800
|
});
|
|
7640
7801
|
}
|
|
7641
7802
|
/**
|
|
7642
|
-
*
|
|
7643
|
-
*
|
|
7644
|
-
* @param component - Angular component to display in dialog
|
|
7645
|
-
* @param config - Optional MatDialog configuration
|
|
7646
|
-
* @returns MatDialogRef for the opened dialog
|
|
7647
|
-
*
|
|
7648
|
-
* @example
|
|
7649
|
-
* ```typescript
|
|
7650
|
-
* const dialogRef = this.dialogService.openComponent(MyCustomComponent, {
|
|
7651
|
-
* width: '600px',
|
|
7652
|
-
* height: '400px',
|
|
7653
|
-
* data: { userId: 123 }
|
|
7654
|
-
* });
|
|
7655
|
-
* ```
|
|
7656
|
-
*/
|
|
7657
|
-
openComponent(component, config) {
|
|
7658
|
-
return this.dialog.open(component, config);
|
|
7659
|
-
}
|
|
7660
|
-
/**
|
|
7661
|
-
* Closes all currently open dialogs
|
|
7662
|
-
*
|
|
7663
|
-
* @example
|
|
7664
|
-
* ```typescript
|
|
7665
|
-
* this.dialogService.closeAll();
|
|
7666
|
-
* ```
|
|
7803
|
+
* Closes all currently open dialogs.
|
|
7667
7804
|
*/
|
|
7668
7805
|
closeAll() {
|
|
7669
7806
|
this.dialog.closeAll();
|
|
7670
7807
|
}
|
|
7671
7808
|
/**
|
|
7672
|
-
* Gets all currently open dialogs
|
|
7673
|
-
*
|
|
7674
|
-
* @returns Array of MatDialogRef instances for open dialogs
|
|
7675
|
-
*
|
|
7676
|
-
* @example
|
|
7677
|
-
* ```typescript
|
|
7678
|
-
* const openDialogs = this.dialogService.getOpenDialogs();
|
|
7679
|
-
* console.log(`Currently ${openDialogs.length} dialogs are open`);
|
|
7680
|
-
* ```
|
|
7809
|
+
* Gets all currently open dialogs.
|
|
7681
7810
|
*/
|
|
7682
7811
|
getOpenDialogs() {
|
|
7683
7812
|
return this.dialog.openDialogs;
|
|
7684
7813
|
}
|
|
7685
7814
|
/**
|
|
7686
|
-
* Checks if any dialogs are currently open
|
|
7687
|
-
*
|
|
7688
|
-
* @returns True if any dialogs are open, false otherwise
|
|
7689
|
-
*
|
|
7690
|
-
* @example
|
|
7691
|
-
* ```typescript
|
|
7692
|
-
* if (this.dialogService.hasOpenDialogs()) {
|
|
7693
|
-
* console.log('Some dialogs are still open');
|
|
7694
|
-
* }
|
|
7695
|
-
* ```
|
|
7815
|
+
* Checks if any dialogs are currently open.
|
|
7696
7816
|
*/
|
|
7697
7817
|
hasOpenDialogs() {
|
|
7698
7818
|
return this.dialog.openDialogs.length > 0;
|
|
@@ -7700,10 +7820,6 @@ class DialogService {
|
|
|
7700
7820
|
getDialogConfig(options) {
|
|
7701
7821
|
const backdropClass = this.getBackdropClass(options.type) || 'amw-dialog-backdrop';
|
|
7702
7822
|
const panelClass = this.getPanelClass(options.type, options.size) || 'amw-dialog-panel';
|
|
7703
|
-
// Final validation to ensure no whitespace in class names
|
|
7704
|
-
if (backdropClass.includes(' ') || panelClass.includes(' ')) {
|
|
7705
|
-
// Handle whitespace in class names if needed
|
|
7706
|
-
}
|
|
7707
7823
|
const config = {
|
|
7708
7824
|
data: {
|
|
7709
7825
|
title: options.title || '',
|
|
@@ -7740,7 +7856,6 @@ class DialogService {
|
|
|
7740
7856
|
restoreFocus: options.restoreFocus !== false,
|
|
7741
7857
|
closeOnNavigation: true
|
|
7742
7858
|
};
|
|
7743
|
-
// Apply position
|
|
7744
7859
|
if (options.position) {
|
|
7745
7860
|
config.position = this.getPosition(options.position);
|
|
7746
7861
|
}
|
|
@@ -7757,9 +7872,6 @@ class DialogService {
|
|
|
7757
7872
|
}
|
|
7758
7873
|
getDefaultHeight(size) {
|
|
7759
7874
|
switch (size) {
|
|
7760
|
-
case 'small': return 'auto';
|
|
7761
|
-
case 'medium': return 'auto';
|
|
7762
|
-
case 'large': return 'auto';
|
|
7763
7875
|
case 'fullscreen': return '100vh';
|
|
7764
7876
|
default: return 'auto';
|
|
7765
7877
|
}
|
|
@@ -7793,9 +7905,6 @@ class DialogService {
|
|
|
7793
7905
|
}
|
|
7794
7906
|
getDefaultMinHeight(size) {
|
|
7795
7907
|
switch (size) {
|
|
7796
|
-
case 'small': return 'auto';
|
|
7797
|
-
case 'medium': return 'auto';
|
|
7798
|
-
case 'large': return 'auto';
|
|
7799
7908
|
case 'fullscreen': return '100vh';
|
|
7800
7909
|
default: return 'auto';
|
|
7801
7910
|
}
|
|
@@ -7811,7 +7920,6 @@ class DialogService {
|
|
|
7811
7920
|
}
|
|
7812
7921
|
}
|
|
7813
7922
|
getBackdropClass(type) {
|
|
7814
|
-
// Angular Material expects a single class name, not multiple classes
|
|
7815
7923
|
const baseClass = 'amw-dialog-backdrop';
|
|
7816
7924
|
if (type && typeof type === 'string' && type.trim()) {
|
|
7817
7925
|
const cleanType = this.sanitizeClassName(type);
|
|
@@ -7822,7 +7930,6 @@ class DialogService {
|
|
|
7822
7930
|
return baseClass;
|
|
7823
7931
|
}
|
|
7824
7932
|
getPanelClass(type, size) {
|
|
7825
|
-
// Angular Material expects a single class name, not multiple classes
|
|
7826
7933
|
const baseClass = 'amw-dialog-panel';
|
|
7827
7934
|
if (type && typeof type === 'string' && type.trim()) {
|
|
7828
7935
|
const cleanType = this.sanitizeClassName(type);
|
|
@@ -7841,25 +7948,17 @@ class DialogService {
|
|
|
7841
7948
|
sanitizeClassName(value) {
|
|
7842
7949
|
if (!value || typeof value !== 'string')
|
|
7843
7950
|
return '';
|
|
7844
|
-
// First, ensure we have a string and trim it
|
|
7845
7951
|
let sanitized = String(value).trim();
|
|
7846
|
-
// If empty after trim, return empty string
|
|
7847
7952
|
if (!sanitized)
|
|
7848
7953
|
return '';
|
|
7849
|
-
// Replace any whitespace (including tabs, newlines, etc.) with hyphens
|
|
7850
7954
|
sanitized = sanitized.replace(/\s+/g, '-');
|
|
7851
|
-
// Remove any characters that are not alphanumeric, hyphens, or underscores
|
|
7852
7955
|
sanitized = sanitized.replace(/[^a-zA-Z0-9-_]/g, '');
|
|
7853
|
-
// Replace multiple consecutive hyphens with single hyphen
|
|
7854
7956
|
sanitized = sanitized.replace(/-+/g, '-');
|
|
7855
|
-
// Remove leading and trailing hyphens
|
|
7856
7957
|
sanitized = sanitized.replace(/^-+|-+$/g, '');
|
|
7857
|
-
// Final check: ensure no whitespace characters remain
|
|
7858
7958
|
sanitized = sanitized.replace(/\s/g, '');
|
|
7859
|
-
// Return empty string if nothing valid remains
|
|
7860
7959
|
return sanitized || '';
|
|
7861
7960
|
}
|
|
7862
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: DialogService, deps: [{ token: i3.MatDialog }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
7961
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: DialogService, deps: [{ token: i3.MatDialog }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
7863
7962
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: DialogService, providedIn: 'root' });
|
|
7864
7963
|
}
|
|
7865
7964
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: DialogService, decorators: [{
|
|
@@ -7867,7 +7966,26 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImpor
|
|
|
7867
7966
|
args: [{
|
|
7868
7967
|
providedIn: 'root'
|
|
7869
7968
|
}]
|
|
7870
|
-
}], ctorParameters: () => [{ type: i3.MatDialog }] });
|
|
7969
|
+
}], ctorParameters: () => [{ type: i3.MatDialog }, { type: i0.Injector }] });
|
|
7970
|
+
/**
|
|
7971
|
+
* Helper function to extract the dialog title from MAT_DIALOG_DATA.
|
|
7972
|
+
* Use this in your dialog component to access the title passed to DialogService.open()
|
|
7973
|
+
*
|
|
7974
|
+
* @example
|
|
7975
|
+
* ```typescript
|
|
7976
|
+
* import { MAT_DIALOG_DATA } from '@angular/material/dialog';
|
|
7977
|
+
* import { getAmwDialogTitle } from '@amw/dialog';
|
|
7978
|
+
*
|
|
7979
|
+
* @Component({ ... })
|
|
7980
|
+
* export class MyDialogComponent {
|
|
7981
|
+
* private readonly data = inject(MAT_DIALOG_DATA);
|
|
7982
|
+
* readonly title = getAmwDialogTitle(this.data);
|
|
7983
|
+
* }
|
|
7984
|
+
* ```
|
|
7985
|
+
*/
|
|
7986
|
+
function getAmwDialogTitle(data) {
|
|
7987
|
+
return data?._amwTitle ?? '';
|
|
7988
|
+
}
|
|
7871
7989
|
|
|
7872
7990
|
/**
|
|
7873
7991
|
* AMW Data Table Component
|
|
@@ -17463,5 +17581,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImpor
|
|
|
17463
17581
|
* Generated bundle index. Do not edit.
|
|
17464
17582
|
*/
|
|
17465
17583
|
|
|
17466
|
-
export { AmwAccordionComponent, AmwAccordionPanelComponent, AmwAutoFocusDirective, AmwAutocompleteComponent, AmwBadgeDirective, AmwButtonComponent, AmwButtonToggleComponent, AmwButtonToggleGroupComponent, AmwCalendarBaseComponent, AmwCalendarFullComponent, AmwCalendarMiniComponent, AmwCalendarPickerComponent, AmwCardComponent, AmwCheckboxComponent, AmwChipComponent, AmwChipInputComponent, AmwChipsComponent, AmwClickOutsideDirective, AmwColorPickerComponent, AmwCopyToClipboardDirective, AmwCurrencyPipe, AmwDashboardPageComponent, AmwDataTableComponent, AmwDatePipe, AmwDatepickerComponent, AmwDetailPageComponent, AmwDialogComponent, AmwDividerComponent, AmwFileInputComponent, AmwFormPageComponent, AmwFormValidationComponent, AmwIconButtonComponent, AmwIconComponent, AmwInputComponent, AmwListComponent, AmwListItemComponent, AmwListPageComponent, AmwLoadingService, AmwMasterDetailPageComponent, AmwMenuComponent, AmwMenuItemComponent, AmwMenuTriggerForDirective, AmwMessagingService, AmwNotificationService, AmwPaginatorComponent, AmwPopoverComponent, AmwProgressBarComponent, AmwProgressSpinnerComponent, AmwRadioComponent, AmwRadioGroupComponent, AmwRangeSliderComponent, AmwReportPageComponent, AmwSearchPageComponent, AmwSelectComponent, AmwSidenavComponent, AmwSliderComponent, AmwStepperComponent, AmwSwitchComponent, AmwTabComponent, AmwTabsComponent, AmwTextTransformPipe, AmwTextareaComponent, AmwTimepickerComponent, AmwToggleComponent, AmwToolbarComponent, AmwTooltipComponent, AmwTooltipDirective, AmwWorkflowPageComponent, BaseComponent, CacheConfigService, CacheSyncService, CardService, DefaultDashboardDataSource, DefaultFormPageDataSource, DefaultMasterDetailDataSource, DefaultReportPageDataSource, DefaultWorkflowPageDataSource, DialogService, HttpCacheInterceptor, HttpCacheService, IndexedDbStorageService, LIST_PAGE_DATA_SOURCE, ThemeEditorComponent, ThemeManagerComponent, ThemePickerComponent, ThemeService, WORKFLOW_PAGE_DATA_SOURCE, httpCacheInterceptor };
|
|
17584
|
+
export { AmwAccordionComponent, AmwAccordionPanelComponent, AmwAutoFocusDirective, AmwAutocompleteComponent, AmwBadgeDirective, AmwButtonComponent, AmwButtonToggleComponent, AmwButtonToggleGroupComponent, AmwCalendarBaseComponent, AmwCalendarFullComponent, AmwCalendarMiniComponent, AmwCalendarPickerComponent, AmwCardComponent, AmwCheckboxComponent, AmwChipComponent, AmwChipInputComponent, AmwChipsComponent, AmwClickOutsideDirective, AmwColorPickerComponent, AmwCopyToClipboardDirective, AmwCurrencyPipe, AmwDashboardPageComponent, AmwDataTableComponent, AmwDatePipe, AmwDatepickerComponent, AmwDetailPageComponent, AmwDialogComponent, AmwDialogRef, AmwDividerComponent, AmwFileInputComponent, AmwFormPageComponent, AmwFormValidationComponent, AmwIconButtonComponent, AmwIconComponent, AmwInputComponent, AmwListComponent, AmwListItemComponent, AmwListPageComponent, AmwLoadingService, AmwMasterDetailPageComponent, AmwMenuComponent, AmwMenuItemComponent, AmwMenuTriggerForDirective, AmwMessagingService, AmwNotificationService, AmwPaginatorComponent, AmwPopoverComponent, AmwProgressBarComponent, AmwProgressSpinnerComponent, AmwRadioComponent, AmwRadioGroupComponent, AmwRangeSliderComponent, AmwReportPageComponent, AmwSearchPageComponent, AmwSelectComponent, AmwSidenavComponent, AmwSliderComponent, AmwStepperComponent, AmwSwitchComponent, AmwTabComponent, AmwTabsComponent, AmwTextTransformPipe, AmwTextareaComponent, AmwTimepickerComponent, AmwToggleComponent, AmwToolbarComponent, AmwTooltipComponent, AmwTooltipDirective, AmwWorkflowPageComponent, BaseComponent, CacheConfigService, CacheSyncService, CardService, DefaultDashboardDataSource, DefaultFormPageDataSource, DefaultMasterDetailDataSource, DefaultReportPageDataSource, DefaultWorkflowPageDataSource, DialogService, HttpCacheInterceptor, HttpCacheService, IndexedDbStorageService, LIST_PAGE_DATA_SOURCE, ThemeEditorComponent, ThemeManagerComponent, ThemePickerComponent, ThemeService, WORKFLOW_PAGE_DATA_SOURCE, getAmwDialogTitle, httpCacheInterceptor };
|
|
17467
17585
|
//# sourceMappingURL=angular-material-wrap.mjs.map
|