mat-helper 0.1.0 → 1.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.
package/README.md CHANGED
@@ -31,13 +31,16 @@ This command will compile your project, and the build artifacts will be placed i
31
31
  Once the project is built, you can publish your library by following these steps:
32
32
 
33
33
  1. Navigate to the `dist` directory:
34
+
34
35
  ```bash
35
36
  cd dist/mat-helper
36
37
  ```
37
38
 
38
39
  2. Run the `npm publish` command to publish your library to the npm registry:
39
40
  ```bash
41
+ npm config set //registry.npmjs.org/:_authToken=YOUR_NPM_TOKEN
40
42
  npm publish
43
+ npm config delete //registry.npmjs.org/:_authToken
41
44
  ```
42
45
 
43
46
  ## Running unit tests
@@ -14,10 +14,10 @@ class Alert {
14
14
  close() {
15
15
  this.dialogRef.close();
16
16
  }
17
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.2", ngImport: i0, type: Alert, deps: [{ token: i1.MatDialogRef }], target: i0.ɵɵFactoryTarget.Component });
18
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.2", type: Alert, isStandalone: true, selector: "lib-alert", ngImport: i0, 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", styles: [""], dependencies: [{ kind: "directive", type: MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]", inputs: ["align"] }, { kind: "directive", type: MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { 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"] }] });
17
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: Alert, deps: [{ token: i1.MatDialogRef }], target: i0.ɵɵFactoryTarget.Component });
18
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.1.3", type: Alert, isStandalone: true, selector: "lib-alert", ngImport: i0, 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", styles: [""], dependencies: [{ kind: "directive", type: MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]", inputs: ["align"] }, { kind: "directive", type: MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { 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"] }] });
19
19
  }
20
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.2", ngImport: i0, type: Alert, decorators: [{
20
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: Alert, decorators: [{
21
21
  type: Component,
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 }] });
@@ -37,10 +37,10 @@ class ConfirmDialog {
37
37
  onConfirm() {
38
38
  this.dialogRef.close(true);
39
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"] }] });
40
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: ConfirmDialog, deps: [{ token: i1.MatDialogRef }], target: i0.ɵɵFactoryTarget.Component });
41
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.3", 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
42
  }
43
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.2", ngImport: i0, type: ConfirmDialog, decorators: [{
43
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: ConfirmDialog, decorators: [{
44
44
  type: Component,
45
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
46
  }], ctorParameters: () => [{ type: i1.MatDialogRef }] });
@@ -48,6 +48,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.2", ngImpor
48
48
  class MatHelper {
49
49
  snackBar = inject(MatSnackBar);
50
50
  dialog = inject(MatDialog);
51
+ sidenav;
52
+ toggleSideNav() {
53
+ this.sidenav.toggle();
54
+ }
55
+ setSideNav(sidenav) {
56
+ this.sidenav = sidenav;
57
+ }
51
58
  async presentAlert(text, onDidDismiss) {
52
59
  const dialogRef = this.dialog.open(Alert, {
53
60
  minWidth: '300px',
@@ -118,10 +125,10 @@ class MatHelper {
118
125
  console.log(e);
119
126
  });
120
127
  }
121
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.2", ngImport: i0, type: MatHelper, deps: [], target: i0.ɵɵFactoryTarget.Component });
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: [""] });
128
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: MatHelper, deps: [], target: i0.ɵɵFactoryTarget.Component });
129
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.1.3", type: MatHelper, isStandalone: true, selector: "lib-mat-helper", ngImport: i0, template: ` <p>mat-helper works!</p> `, isInline: true, styles: [""] });
123
130
  }
124
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.2", ngImport: i0, type: MatHelper, decorators: [{
131
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: MatHelper, decorators: [{
125
132
  type: Component,
126
133
  args: [{ selector: 'lib-mat-helper', imports: [], template: ` <p>mat-helper works!</p> ` }]
127
134
  }] });
@@ -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/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,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e,CAAC,IAAY,EAAA;AAC1B,QAAA,SAAS,CAAC;aACP,SAAS,CAAC,IAAI;aACd,IAAI,CAAC,MAAK;AACT,YAAA,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC;;;;AAI9B,QAAA,CAAC;AACA,aAAA,KAAK,CAAC,CAAC,CAAC,KAAI;AACX,YAAA,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC;;;;AAI3B,YAAA,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;AAChB,QAAA,CAAC,CAAC;IACN;uGA5FW,SAAS,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAT,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,SAAS,0EAHV,CAAA,0BAAA,CAA4B,EAAA,QAAA,EAAA,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;;;ACTxC;;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\nimport { MatSidenav } from '@angular/material/sidenav';\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 private sidenav!: MatSidenav;\r\n\r\n toggleSideNav() {\r\n this.sidenav.toggle();\r\n }\r\n\r\n setSideNav(sidenav: MatSidenav) {\r\n this.sidenav = sidenav;\r\n }\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,EAA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ACf,aAAA,CAAC;;QAEJ;aAAO;AACL,YAAA,OAAO,CAAC,KAAK,CAAC,qCAAqC,CAAC;QACtD;IACF;AAEA,IAAA,eAAe,CAAC,IAAY,EAAA;AAC1B,QAAA,SAAS,CAAC;aACP,SAAS,CAAC,IAAI;aACd,IAAI,CAAC,MAAK;AACT,YAAA,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC;;;;AAI9B,QAAA,CAAC;AACA,aAAA,KAAK,CAAC,CAAC,CAAC,KAAI;AACX,YAAA,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC;;;;AAI3B,YAAA,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;AAChB,QAAA,CAAC,CAAC;IACN;uGAtGW,SAAS,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAT,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,SAAS,0EAHV,CAAA,0BAAA,CAA4B,EAAA,QAAA,EAAA,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;;;ACVxC;;AAEG;;ACFH;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,22 +1,22 @@
1
1
  {
2
2
  "name": "mat-helper",
3
- "version": "0.1.0",
3
+ "version": "1.1.0",
4
4
  "peerDependencies": {
5
- "@angular/common": "^20.3.0",
6
- "@angular/core": "^20.3.0"
5
+ "@angular/common": "^21.1.0",
6
+ "@angular/core": "^21.1.0"
7
7
  },
8
8
  "dependencies": {
9
9
  "tslib": "^2.3.0"
10
10
  },
11
11
  "sideEffects": false,
12
12
  "module": "fesm2022/mat-helper.mjs",
13
- "typings": "index.d.ts",
13
+ "typings": "types/mat-helper.d.ts",
14
14
  "exports": {
15
15
  "./package.json": {
16
16
  "default": "./package.json"
17
17
  },
18
18
  ".": {
19
- "types": "./index.d.ts",
19
+ "types": "./types/mat-helper.d.ts",
20
20
  "default": "./fesm2022/mat-helper.mjs"
21
21
  }
22
22
  }
@@ -2,10 +2,14 @@ import * as i0 from '@angular/core';
2
2
  import { ElementRef } from '@angular/core';
3
3
  import { MatDialog, MatDialogRef } from '@angular/material/dialog';
4
4
  import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar';
5
+ import { MatSidenav } from '@angular/material/sidenav';
5
6
 
6
7
  declare class MatHelper {
7
8
  snackBar: MatSnackBar;
8
9
  dialog: MatDialog;
10
+ private sidenav;
11
+ toggleSideNav(): void;
12
+ setSideNav(sidenav: MatSidenav): void;
9
13
  presentAlert(text: string, onDidDismiss?: () => void): Promise<void>;
10
14
  /**
11
15
  * Displays a toast (snackbar) message.