mat-helper 0.0.2 → 0.1.0

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.
@@ -22,6 +22,29 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.2", ngImpor
22
22
  args: [{ selector: 'lib-alert', imports: [MatDialogActions, MatDialogContent, MatButton], template: "<mat-dialog-content>\r\n <div style=\"white-space: pre-line\">{{ data.message }}</div>\r\n</mat-dialog-content>\r\n<mat-dialog-actions>\r\n <button mat-button (click)=\"close()\">OK</button>\r\n</mat-dialog-actions>\r\n" }]
23
23
  }], ctorParameters: () => [{ type: i1.MatDialogRef }] });
24
24
 
25
+ class ConfirmDialog {
26
+ dialogRef;
27
+ data = inject(MAT_DIALOG_DATA);
28
+ constructor(dialogRef) {
29
+ this.dialogRef = dialogRef;
30
+ }
31
+ close() {
32
+ this.dialogRef.close();
33
+ }
34
+ onCancel() {
35
+ this.dialogRef.close(false);
36
+ }
37
+ onConfirm() {
38
+ this.dialogRef.close(true);
39
+ }
40
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.2", ngImport: i0, type: ConfirmDialog, deps: [{ token: i1.MatDialogRef }], target: i0.ɵɵFactoryTarget.Component });
41
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.2", type: ConfirmDialog, isStandalone: true, selector: "lib-confirm-dialog", ngImport: i0, template: "@if (data.title) {\r\n<h2 mat-dialog-title>{{ data.title }}</h2>\r\n\r\n}\r\n\r\n<mat-dialog-content>\r\n <div style=\"white-space: pre-line\">{{ data.message }}</div>\r\n</mat-dialog-content>\r\n<mat-dialog-actions align=\"end\">\r\n <button mat-button (click)=\"onCancel()\">\r\n {{ data.cancelText || 'Cancel' }}\r\n </button>\r\n <button mat-flat-button color=\"warn\" (click)=\"onConfirm()\">\r\n {{ data.confirmText || 'Confirm' }}\r\n </button>\r\n</mat-dialog-actions>\r\n", styles: [""], dependencies: [{ kind: "directive", type: MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { kind: "directive", type: MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]", inputs: ["align"] }, { kind: "component", type: MatButton, selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ", inputs: ["matButton"], exportAs: ["matButton", "matAnchor"] }] });
42
+ }
43
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.2", ngImport: i0, type: ConfirmDialog, decorators: [{
44
+ type: Component,
45
+ args: [{ selector: 'lib-confirm-dialog', imports: [MatDialogContent, MatDialogActions, MatButton], template: "@if (data.title) {\r\n<h2 mat-dialog-title>{{ data.title }}</h2>\r\n\r\n}\r\n\r\n<mat-dialog-content>\r\n <div style=\"white-space: pre-line\">{{ data.message }}</div>\r\n</mat-dialog-content>\r\n<mat-dialog-actions align=\"end\">\r\n <button mat-button (click)=\"onCancel()\">\r\n {{ data.cancelText || 'Cancel' }}\r\n </button>\r\n <button mat-flat-button color=\"warn\" (click)=\"onConfirm()\">\r\n {{ data.confirmText || 'Confirm' }}\r\n </button>\r\n</mat-dialog-actions>\r\n" }]
46
+ }], ctorParameters: () => [{ type: i1.MatDialogRef }] });
47
+
25
48
  class MatHelper {
26
49
  snackBar = inject(MatSnackBar);
27
50
  dialog = inject(MatDialog);
@@ -36,6 +59,35 @@ class MatHelper {
36
59
  });
37
60
  }
38
61
  }
62
+ /**
63
+ * Displays a toast (snackbar) message.
64
+ * @param message Message to display.
65
+ * @param duration Duration in milliseconds (default: 1000ms).
66
+ * @param action Action button text (default: "OK").
67
+ * @param config Optional snackbar configuration override.
68
+ */
69
+ presentToast(message, duration, action, config) {
70
+ this.snackBar.open(message, action ? action : 'OK', config
71
+ ? config
72
+ : {
73
+ duration: duration ? duration : 1000,
74
+ });
75
+ }
76
+ presentConfirmDialog(message, onDidDismiss, confirmText, cancelText) {
77
+ const dialogRef = this.dialog.open(ConfirmDialog, {
78
+ minWidth: '300px',
79
+ data: {
80
+ message: message,
81
+ confirmText: confirmText ? confirmText : 'Yes',
82
+ cancelText: cancelText ? cancelText : 'No',
83
+ },
84
+ });
85
+ dialogRef.afterClosed().subscribe((result) => {
86
+ if (result) {
87
+ onDidDismiss();
88
+ }
89
+ });
90
+ }
39
91
  scrollToTarget(elementRef) {
40
92
  if (elementRef) {
41
93
  const nativeElement = elementRef.nativeElement;
@@ -49,6 +101,23 @@ class MatHelper {
49
101
  console.error('Target element reference not found.');
50
102
  }
51
103
  }
104
+ copyToClipboard(text) {
105
+ navigator.clipboard
106
+ .writeText(text)
107
+ .then(() => {
108
+ this.presentToast('Copied.');
109
+ // this.snackBar.open('Copied.', 'OK', {
110
+ // duration: 1000,
111
+ // });
112
+ })
113
+ .catch((e) => {
114
+ this.presentToast('Error.');
115
+ // this.snackBar.open('Error.', 'OK', {
116
+ // duration: 1000,
117
+ // });
118
+ console.log(e);
119
+ });
120
+ }
52
121
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.2", ngImport: i0, type: MatHelper, deps: [], target: i0.ɵɵFactoryTarget.Component });
53
122
  static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.2", type: MatHelper, isStandalone: true, selector: "lib-mat-helper", ngImport: i0, template: ` <p>mat-helper works!</p> `, isInline: true, styles: [""] });
54
123
  }
@@ -65,5 +134,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.2", ngImpor
65
134
  * Generated bundle index. Do not edit.
66
135
  */
67
136
 
68
- export { Alert, MatHelper };
137
+ export { Alert, ConfirmDialog, MatHelper };
69
138
  //# sourceMappingURL=mat-helper.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"mat-helper.mjs","sources":["../../../projects/mat-helper/src/lib/components/alert/alert.ts","../../../projects/mat-helper/src/lib/components/alert/alert.html","../../../projects/mat-helper/src/lib/mat-helper.ts","../../../projects/mat-helper/src/public-api.ts","../../../projects/mat-helper/src/mat-helper.ts"],"sourcesContent":["import { Component, inject } from '@angular/core';\r\nimport { MatButton } from '@angular/material/button';\r\nimport {\r\n MAT_DIALOG_DATA,\r\n MatDialogActions,\r\n MatDialogContent,\r\n MatDialogRef,\r\n} from '@angular/material/dialog';\r\n\r\nexport interface AlertInput {\r\n message: string;\r\n}\r\n\r\n@Component({\r\n selector: 'lib-alert',\r\n imports: [MatDialogActions, MatDialogContent, MatButton],\r\n templateUrl: './alert.html',\r\n styleUrl: './alert.css',\r\n})\r\nexport class Alert {\r\n readonly data = inject<AlertInput>(MAT_DIALOG_DATA);\r\n constructor(private dialogRef: MatDialogRef<Alert>) {}\r\n close(): void {\r\n this.dialogRef.close();\r\n }\r\n}\r\n","<mat-dialog-content>\r\n <div style=\"white-space: pre-line\">{{ data.message }}</div>\r\n</mat-dialog-content>\r\n<mat-dialog-actions>\r\n <button mat-button (click)=\"close()\">OK</button>\r\n</mat-dialog-actions>\r\n","import { Component, ElementRef, inject } from '@angular/core';\r\nimport { MatDialog } from '@angular/material/dialog';\r\nimport { MatSnackBar } from '@angular/material/snack-bar';\r\nimport { Alert, AlertInput } from './components/alert/alert';\r\n\r\n@Component({\r\n selector: 'lib-mat-helper',\r\n imports: [],\r\n template: ` <p>mat-helper works!</p> `,\r\n styles: ``,\r\n})\r\nexport class MatHelper {\r\n public snackBar = inject(MatSnackBar);\r\n public dialog = inject(MatDialog);\r\n\r\n async presentAlert(text: string, onDidDismiss?: () => void) {\r\n const dialogRef = this.dialog.open(Alert, {\r\n minWidth: '300px',\r\n data: { message: text } as AlertInput,\r\n });\r\n\r\n if (onDidDismiss) {\r\n dialogRef.afterClosed().subscribe(() => {\r\n onDidDismiss();\r\n });\r\n }\r\n }\r\n\r\n scrollToTarget(elementRef: ElementRef): void {\r\n if (elementRef) {\r\n const nativeElement = elementRef.nativeElement;\r\n\r\n nativeElement.scrollIntoView({\r\n behavior: 'smooth',\r\n block: 'start',\r\n });\r\n // console.log('Scrolling to target element...');\r\n } else {\r\n console.error('Target element reference not found.');\r\n }\r\n }\r\n}\r\n","/*\r\n * Public API Surface of mat-helper\r\n */\r\n\r\nexport * from './lib/mat-helper';\r\n\r\nexport * from './lib/components/alert/alert';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;MAmBa,KAAK,CAAA;AAEI,IAAA,SAAA;AADX,IAAA,IAAI,GAAG,MAAM,CAAa,eAAe,CAAC;AACnD,IAAA,WAAA,CAAoB,SAA8B,EAAA;QAA9B,IAAA,CAAA,SAAS,GAAT,SAAS;IAAwB;IACrD,KAAK,GAAA;AACH,QAAA,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE;IACxB;uGALW,KAAK,EAAA,IAAA,EAAA,CAAA,EAAA,KAAA,EAAA,EAAA,CAAA,YAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAL,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,KAAK,qECnBlB,+NAMA,EAAA,MAAA,EAAA,CAAA,EAAA,CAAA,EAAA,YAAA,EAAA,CAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EDSY,gBAAgB,EAAA,QAAA,EAAA,8DAAA,EAAA,MAAA,EAAA,CAAA,OAAA,CAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EAAE,gBAAgB,yGAAE,SAAS,EAAA,QAAA,EAAA,iOAAA,EAAA,MAAA,EAAA,CAAA,WAAA,CAAA,EAAA,QAAA,EAAA,CAAA,WAAA,EAAA,WAAA,CAAA,EAAA,CAAA,EAAA,CAAA;;2FAI5C,KAAK,EAAA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AAA,IAAA,EAAA,MAAA,EAAA,CAAA,EAAA,CAAA,EAAA,CAAA;;2FAG3B,SAAS,EAAA,UAAA,EAAA,CAAA;kBANrB,SAAS;+BACE,gBAAgB,EAAA,OAAA,EACjB,EAAE,EAAA,QAAA,EACD,CAAA,0BAAA,CAA4B,EAAA;;;ACRxC;;AAEG;;ACFH;;AAEG;;;;"}
1
+ {"version":3,"file":"mat-helper.mjs","sources":["../../../projects/mat-helper/src/lib/components/alert/alert.ts","../../../projects/mat-helper/src/lib/components/alert/alert.html","../../../projects/mat-helper/src/lib/components/confirm-dialog/confirm-dialog.ts","../../../projects/mat-helper/src/lib/components/confirm-dialog/confirm-dialog.html","../../../projects/mat-helper/src/lib/mat-helper.ts","../../../projects/mat-helper/src/public-api.ts","../../../projects/mat-helper/src/mat-helper.ts"],"sourcesContent":["import { Component, inject } from '@angular/core';\r\nimport { MatButton } from '@angular/material/button';\r\nimport {\r\n MAT_DIALOG_DATA,\r\n MatDialogActions,\r\n MatDialogContent,\r\n MatDialogRef,\r\n} from '@angular/material/dialog';\r\n\r\nexport interface AlertInput {\r\n message: string;\r\n}\r\n\r\n@Component({\r\n selector: 'lib-alert',\r\n imports: [MatDialogActions, MatDialogContent, MatButton],\r\n templateUrl: './alert.html',\r\n styleUrl: './alert.css',\r\n})\r\nexport class Alert {\r\n readonly data = inject<AlertInput>(MAT_DIALOG_DATA);\r\n constructor(private dialogRef: MatDialogRef<Alert>) {}\r\n close(): void {\r\n this.dialogRef.close();\r\n }\r\n}\r\n","<mat-dialog-content>\r\n <div style=\"white-space: pre-line\">{{ data.message }}</div>\r\n</mat-dialog-content>\r\n<mat-dialog-actions>\r\n <button mat-button (click)=\"close()\">OK</button>\r\n</mat-dialog-actions>\r\n","import { Component, inject } from '@angular/core';\r\nimport { MatButton } from '@angular/material/button';\r\nimport {\r\n MatDialogContent,\r\n MatDialogActions,\r\n MAT_DIALOG_DATA,\r\n MatDialogRef,\r\n} from '@angular/material/dialog';\r\n\r\nexport interface ConfirmDialogInput {\r\n title?: string;\r\n message: string;\r\n confirmText?: string;\r\n cancelText?: string;\r\n}\r\n\r\n@Component({\r\n selector: 'lib-confirm-dialog',\r\n imports: [MatDialogContent, MatDialogActions, MatButton],\r\n templateUrl: './confirm-dialog.html',\r\n styleUrl: './confirm-dialog.css',\r\n})\r\nexport class ConfirmDialog {\r\n readonly data = inject<ConfirmDialogInput>(MAT_DIALOG_DATA);\r\n constructor(private dialogRef: MatDialogRef<ConfirmDialog>) {}\r\n close(): void {\r\n this.dialogRef.close();\r\n }\r\n\r\n onCancel(): void {\r\n this.dialogRef.close(false);\r\n }\r\n\r\n onConfirm(): void {\r\n this.dialogRef.close(true);\r\n }\r\n}\r\n","@if (data.title) {\r\n<h2 mat-dialog-title>{{ data.title }}</h2>\r\n\r\n}\r\n\r\n<mat-dialog-content>\r\n <div style=\"white-space: pre-line\">{{ data.message }}</div>\r\n</mat-dialog-content>\r\n<mat-dialog-actions align=\"end\">\r\n <button mat-button (click)=\"onCancel()\">\r\n {{ data.cancelText || 'Cancel' }}\r\n </button>\r\n <button mat-flat-button color=\"warn\" (click)=\"onConfirm()\">\r\n {{ data.confirmText || 'Confirm' }}\r\n </button>\r\n</mat-dialog-actions>\r\n","import { Component, ElementRef, inject } from '@angular/core';\r\nimport { MatDialog } from '@angular/material/dialog';\r\nimport { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar';\r\nimport { Alert, AlertInput } from './components/alert/alert';\r\nimport { ConfirmDialog, ConfirmDialogInput } from './components/confirm-dialog/confirm-dialog';\r\n\r\n@Component({\r\n selector: 'lib-mat-helper',\r\n imports: [],\r\n template: ` <p>mat-helper works!</p> `,\r\n styles: ``,\r\n})\r\nexport class MatHelper {\r\n public snackBar = inject(MatSnackBar);\r\n public dialog = inject(MatDialog);\r\n\r\n async presentAlert(text: string, onDidDismiss?: () => void) {\r\n const dialogRef = this.dialog.open(Alert, {\r\n minWidth: '300px',\r\n data: { message: text } as AlertInput,\r\n });\r\n\r\n if (onDidDismiss) {\r\n dialogRef.afterClosed().subscribe(() => {\r\n onDidDismiss();\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Displays a toast (snackbar) message.\r\n * @param message Message to display.\r\n * @param duration Duration in milliseconds (default: 1000ms).\r\n * @param action Action button text (default: \"OK\").\r\n * @param config Optional snackbar configuration override.\r\n */\r\n presentToast(\r\n message: string,\r\n duration?: number,\r\n action?: string | undefined,\r\n config?: MatSnackBarConfig<any> | undefined\r\n ) {\r\n this.snackBar.open(\r\n message,\r\n action ? action : 'OK',\r\n config\r\n ? config\r\n : {\r\n duration: duration ? duration : 1000,\r\n }\r\n );\r\n }\r\n\r\n presentConfirmDialog(\r\n message: string,\r\n onDidDismiss: () => void,\r\n confirmText?: string,\r\n cancelText?: string\r\n ) {\r\n const dialogRef = this.dialog.open(ConfirmDialog, {\r\n minWidth: '300px',\r\n data: <ConfirmDialogInput>{\r\n message: message,\r\n confirmText: confirmText ? confirmText : 'Yes',\r\n cancelText: cancelText ? cancelText : 'No',\r\n },\r\n });\r\n dialogRef.afterClosed().subscribe((result) => {\r\n if (result) {\r\n onDidDismiss();\r\n }\r\n });\r\n }\r\n\r\n scrollToTarget(elementRef: ElementRef): void {\r\n if (elementRef) {\r\n const nativeElement = elementRef.nativeElement;\r\n\r\n nativeElement.scrollIntoView({\r\n behavior: 'smooth',\r\n block: 'start',\r\n });\r\n // console.log('Scrolling to target element...');\r\n } else {\r\n console.error('Target element reference not found.');\r\n }\r\n }\r\n\r\n copyToClipboard(text: string) {\r\n navigator.clipboard\r\n .writeText(text)\r\n .then(() => {\r\n this.presentToast('Copied.');\r\n // this.snackBar.open('Copied.', 'OK', {\r\n // duration: 1000,\r\n // });\r\n })\r\n .catch((e) => {\r\n this.presentToast('Error.');\r\n // this.snackBar.open('Error.', 'OK', {\r\n // duration: 1000,\r\n // });\r\n console.log(e);\r\n });\r\n }\r\n}\r\n","/*\r\n * Public API Surface of mat-helper\r\n */\r\n\r\nexport * from './lib/mat-helper';\r\n\r\nexport * from './lib/components/alert/alert';\r\nexport * from './lib/components/confirm-dialog/confirm-dialog';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;MAmBa,KAAK,CAAA;AAEI,IAAA,SAAA;AADX,IAAA,IAAI,GAAG,MAAM,CAAa,eAAe,CAAC;AACnD,IAAA,WAAA,CAAoB,SAA8B,EAAA;QAA9B,IAAA,CAAA,SAAS,GAAT,SAAS;IAAwB;IACrD,KAAK,GAAA;AACH,QAAA,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE;IACxB;uGALW,KAAK,EAAA,IAAA,EAAA,CAAA,EAAA,KAAA,EAAA,EAAA,CAAA,YAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAL,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,KAAK,qECnBlB,+NAMA,EAAA,MAAA,EAAA,CAAA,EAAA,CAAA,EAAA,YAAA,EAAA,CAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EDSY,gBAAgB,EAAA,QAAA,EAAA,8DAAA,EAAA,MAAA,EAAA,CAAA,OAAA,CAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EAAE,gBAAgB,yGAAE,SAAS,EAAA,QAAA,EAAA,iOAAA,EAAA,MAAA,EAAA,CAAA,WAAA,CAAA,EAAA,QAAA,EAAA,CAAA,WAAA,EAAA,WAAA,CAAA,EAAA,CAAA,EAAA,CAAA;;2FAI5C,KAAK,EAAA,UAAA,EAAA,CAAA;kBANjB,SAAS;AACE,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,WAAW,WACZ,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,SAAS,CAAC,EAAA,QAAA,EAAA,+NAA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/index.d.ts CHANGED
@@ -1,13 +1,23 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { ElementRef } from '@angular/core';
3
3
  import { MatDialog, MatDialogRef } from '@angular/material/dialog';
4
- import { MatSnackBar } from '@angular/material/snack-bar';
4
+ import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar';
5
5
 
6
6
  declare class MatHelper {
7
7
  snackBar: MatSnackBar;
8
8
  dialog: MatDialog;
9
9
  presentAlert(text: string, onDidDismiss?: () => void): Promise<void>;
10
+ /**
11
+ * Displays a toast (snackbar) message.
12
+ * @param message Message to display.
13
+ * @param duration Duration in milliseconds (default: 1000ms).
14
+ * @param action Action button text (default: "OK").
15
+ * @param config Optional snackbar configuration override.
16
+ */
17
+ presentToast(message: string, duration?: number, action?: string | undefined, config?: MatSnackBarConfig<any> | undefined): void;
18
+ presentConfirmDialog(message: string, onDidDismiss: () => void, confirmText?: string, cancelText?: string): void;
10
19
  scrollToTarget(elementRef: ElementRef): void;
20
+ copyToClipboard(text: string): void;
11
21
  static ɵfac: i0.ɵɵFactoryDeclaration<MatHelper, never>;
12
22
  static ɵcmp: i0.ɵɵComponentDeclaration<MatHelper, "lib-mat-helper", never, {}, {}, never, never, true, never>;
13
23
  }
@@ -24,5 +34,22 @@ declare class Alert {
24
34
  static ɵcmp: i0.ɵɵComponentDeclaration<Alert, "lib-alert", never, {}, {}, never, never, true, never>;
25
35
  }
26
36
 
27
- export { Alert, MatHelper };
28
- export type { AlertInput };
37
+ interface ConfirmDialogInput {
38
+ title?: string;
39
+ message: string;
40
+ confirmText?: string;
41
+ cancelText?: string;
42
+ }
43
+ declare class ConfirmDialog {
44
+ private dialogRef;
45
+ readonly data: ConfirmDialogInput;
46
+ constructor(dialogRef: MatDialogRef<ConfirmDialog>);
47
+ close(): void;
48
+ onCancel(): void;
49
+ onConfirm(): void;
50
+ static ɵfac: i0.ɵɵFactoryDeclaration<ConfirmDialog, never>;
51
+ static ɵcmp: i0.ɵɵComponentDeclaration<ConfirmDialog, "lib-confirm-dialog", never, {}, {}, never, never, true, never>;
52
+ }
53
+
54
+ export { Alert, ConfirmDialog, MatHelper };
55
+ export type { AlertInput, ConfirmDialogInput };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mat-helper",
3
- "version": "0.0.2",
3
+ "version": "0.1.0",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^20.3.0",
6
6
  "@angular/core": "^20.3.0"