angular-matecu 2.0.6 → 2.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/README.md +29 -0
  2. package/angular-matecu.code-workspace +10 -0
  3. package/karma.conf.js +44 -0
  4. package/ng-package.json +13 -0
  5. package/package.json +7 -15
  6. package/src/lib/modules/matecu-alert-box/components/matecu-alert-box/matecu-alert-box.component.html +11 -0
  7. package/src/lib/modules/matecu-alert-box/components/matecu-alert-box/matecu-alert-box.component.scss +39 -0
  8. package/src/lib/modules/matecu-alert-box/components/matecu-alert-box/matecu-alert-box.component.spec.ts +25 -0
  9. package/src/lib/modules/matecu-alert-box/components/matecu-alert-box/matecu-alert-box.component.ts +56 -0
  10. package/src/lib/modules/matecu-alert-box/components/matecu-alert-dialog/matecu-alert-dialog.component.html +14 -0
  11. package/src/lib/modules/matecu-alert-box/components/matecu-alert-dialog/matecu-alert-dialog.component.scss +5 -0
  12. package/src/lib/modules/matecu-alert-box/components/matecu-alert-dialog/matecu-alert-dialog.component.spec.ts +25 -0
  13. package/src/lib/modules/matecu-alert-box/components/matecu-alert-dialog/matecu-alert-dialog.component.ts +47 -0
  14. package/src/lib/modules/matecu-alert-box/matecu-alert-box.module.ts +17 -0
  15. package/src/lib/modules/matecu-alert-box/matecu-alert-snack-bar/matecu-alert-snack-bar.component.css +0 -0
  16. package/src/lib/modules/matecu-alert-box/matecu-alert-snack-bar/matecu-alert-snack-bar.component.html +1 -0
  17. package/src/lib/modules/matecu-alert-box/matecu-alert-snack-bar/matecu-alert-snack-bar.component.spec.ts +25 -0
  18. package/src/lib/modules/matecu-alert-box/matecu-alert-snack-bar/matecu-alert-snack-bar.component.ts +15 -0
  19. package/src/lib/modules/matecu-alert-box/matecu-snack-bar-alert/matecu-snack-bar-alert.component.html +8 -0
  20. package/src/lib/modules/matecu-alert-box/matecu-snack-bar-alert/matecu-snack-bar-alert.component.scss +34 -0
  21. package/src/lib/modules/matecu-alert-box/matecu-snack-bar-alert/matecu-snack-bar-alert.component.spec.ts +25 -0
  22. package/src/lib/modules/matecu-alert-box/matecu-snack-bar-alert/matecu-snack-bar-alert.component.ts +41 -0
  23. package/src/lib/modules/matecu-alert-box/services/matecu-snack-bar.service.spec.ts +16 -0
  24. package/src/lib/modules/matecu-alert-box/services/matecu-snack-bar.service.ts +66 -0
  25. package/src/lib/modules/matecu-alert-box/types/matecu-alert-dialog.ts +10 -0
  26. package/src/lib/modules/matecu-alert-box/types/matecu-alert-snackbar.ts +8 -0
  27. package/src/lib/modules/matecu-alert-box/types/matecu-altert-box-type.ts +6 -0
  28. package/src/lib/modules/matecu-spinner/components/matecu-spinner/matecu-spinner.component.css +15 -0
  29. package/src/lib/modules/matecu-spinner/components/matecu-spinner/matecu-spinner.component.html +35 -0
  30. package/src/lib/modules/matecu-spinner/components/matecu-spinner/matecu-spinner.component.spec.ts +25 -0
  31. package/src/lib/modules/matecu-spinner/components/matecu-spinner/matecu-spinner.component.ts +47 -0
  32. package/src/lib/modules/matecu-spinner/components/matecu-spinner/spinner-loader.component.scss +13 -0
  33. package/src/lib/modules/matecu-spinner/matecu-spinner.module.ts +17 -0
  34. package/src/lib/modules/matecu-spinner/services/matecu-spinner.service.spec.ts +16 -0
  35. package/src/lib/modules/matecu-spinner/services/matecu-spinner.service.ts +40 -0
  36. package/src/lib/modules/matecu-topbar-layout/components/matecu-topbar-actions/matecu-topbar-actions.component.html +1 -0
  37. package/src/lib/modules/matecu-topbar-layout/components/matecu-topbar-actions/matecu-topbar-actions.component.scss +8 -0
  38. package/src/lib/modules/matecu-topbar-layout/components/matecu-topbar-actions/matecu-topbar-actions.component.spec.ts +25 -0
  39. package/src/lib/modules/matecu-topbar-layout/components/matecu-topbar-actions/matecu-topbar-actions.component.ts +12 -0
  40. package/src/lib/modules/matecu-topbar-layout/components/matecu-topbar-body/matecu-topbar-body.component.html +1 -0
  41. package/src/lib/modules/matecu-topbar-layout/components/matecu-topbar-body/matecu-topbar-body.component.scss +9 -0
  42. package/src/lib/modules/matecu-topbar-layout/components/matecu-topbar-body/matecu-topbar-body.component.spec.ts +25 -0
  43. package/src/lib/modules/matecu-topbar-layout/components/matecu-topbar-body/matecu-topbar-body.component.ts +23 -0
  44. package/src/lib/modules/matecu-topbar-layout/components/matecu-topbar-fab/matecu-topbar-fab.component.html +3 -0
  45. package/src/lib/modules/matecu-topbar-layout/components/matecu-topbar-fab/matecu-topbar-fab.component.scss +26 -0
  46. package/src/lib/modules/matecu-topbar-layout/components/matecu-topbar-fab/matecu-topbar-fab.component.spec.ts +25 -0
  47. package/src/lib/modules/matecu-topbar-layout/components/matecu-topbar-fab/matecu-topbar-fab.component.ts +27 -0
  48. package/src/lib/modules/matecu-topbar-layout/components/matecu-topbar-layout/matecu-topbar-layout.component.html +23 -0
  49. package/src/lib/modules/matecu-topbar-layout/components/matecu-topbar-layout/matecu-topbar-layout.component.scss +48 -0
  50. package/src/lib/modules/matecu-topbar-layout/components/matecu-topbar-layout/matecu-topbar-layout.component.spec.ts +25 -0
  51. package/src/lib/modules/matecu-topbar-layout/components/matecu-topbar-layout/matecu-topbar-layout.component.ts +93 -0
  52. package/src/lib/modules/matecu-topbar-layout/components/matecu-topbar-search/matecu-topbar-search.component.html +12 -0
  53. package/src/lib/modules/matecu-topbar-layout/components/matecu-topbar-search/matecu-topbar-search.component.scss +101 -0
  54. package/src/lib/modules/matecu-topbar-layout/components/matecu-topbar-search/matecu-topbar-search.component.spec.ts +25 -0
  55. package/src/lib/modules/matecu-topbar-layout/components/matecu-topbar-search/matecu-topbar-search.component.ts +79 -0
  56. package/src/lib/modules/matecu-topbar-layout/components/matecu-topbar-title/matecu-topbar-title.component.html +1 -0
  57. package/src/lib/modules/matecu-topbar-layout/components/matecu-topbar-title/matecu-topbar-title.component.scss +13 -0
  58. package/src/lib/modules/matecu-topbar-layout/components/matecu-topbar-title/matecu-topbar-title.component.spec.ts +25 -0
  59. package/src/lib/modules/matecu-topbar-layout/components/matecu-topbar-title/matecu-topbar-title.component.ts +16 -0
  60. package/src/lib/modules/matecu-topbar-layout/matecu-topbar-layout.module.ts +40 -0
  61. package/src/lib/modules/matecu-topbar-layout/scss/variables.scss +2 -0
  62. package/{public-api.d.ts → src/public-api.ts} +8 -0
  63. package/src/test.ts +28 -0
  64. package/tsconfig.lib.json +25 -0
  65. package/tsconfig.lib.prod.json +10 -0
  66. package/tsconfig.spec.json +17 -0
  67. package/tslint.json +17 -0
  68. package/angular-matecu.d.ts +0 -5
  69. package/bundles/angular-matecu.umd.js +0 -681
  70. package/bundles/angular-matecu.umd.js.map +0 -1
  71. package/esm2015/angular-matecu.js +0 -5
  72. package/esm2015/lib/modules/matecu-alert-box/components/matecu-alert-box/matecu-alert-box.component.js +0 -69
  73. package/esm2015/lib/modules/matecu-alert-box/components/matecu-alert-dialog/matecu-alert-dialog.component.js +0 -55
  74. package/esm2015/lib/modules/matecu-alert-box/matecu-alert-box.module.js +0 -23
  75. package/esm2015/lib/modules/matecu-alert-box/types/matecu-alert-dialog.js +0 -2
  76. package/esm2015/lib/modules/matecu-alert-box/types/matecu-altert-box-type.js +0 -8
  77. package/esm2015/lib/modules/matecu-spinner/components/matecu-spinner/matecu-spinner.component.js +0 -61
  78. package/esm2015/lib/modules/matecu-spinner/matecu-spinner.module.js +0 -24
  79. package/esm2015/lib/modules/matecu-spinner/services/matecu-spinner.service.js +0 -44
  80. package/esm2015/lib/modules/matecu-topbar-layout/components/matecu-topbar-actions/matecu-topbar-actions.component.js +0 -17
  81. package/esm2015/lib/modules/matecu-topbar-layout/components/matecu-topbar-body/matecu-topbar-body.component.js +0 -32
  82. package/esm2015/lib/modules/matecu-topbar-layout/components/matecu-topbar-fab/matecu-topbar-fab.component.js +0 -36
  83. package/esm2015/lib/modules/matecu-topbar-layout/components/matecu-topbar-layout/matecu-topbar-layout.component.js +0 -103
  84. package/esm2015/lib/modules/matecu-topbar-layout/components/matecu-topbar-search/matecu-topbar-search.component.js +0 -85
  85. package/esm2015/lib/modules/matecu-topbar-layout/components/matecu-topbar-title/matecu-topbar-title.component.js +0 -23
  86. package/esm2015/lib/modules/matecu-topbar-layout/matecu-topbar-layout.module.js +0 -70
  87. package/esm2015/public-api.js +0 -28
  88. package/fesm2015/angular-matecu.js +0 -603
  89. package/fesm2015/angular-matecu.js.map +0 -1
  90. package/lib/modules/matecu-alert-box/components/matecu-alert-box/matecu-alert-box.component.d.ts +0 -19
  91. package/lib/modules/matecu-alert-box/components/matecu-alert-dialog/matecu-alert-dialog.component.d.ts +0 -22
  92. package/lib/modules/matecu-alert-box/matecu-alert-box.module.d.ts +0 -12
  93. package/lib/modules/matecu-alert-box/types/matecu-alert-dialog.d.ts +0 -9
  94. package/lib/modules/matecu-alert-box/types/matecu-altert-box-type.d.ts +0 -6
  95. package/lib/modules/matecu-spinner/components/matecu-spinner/matecu-spinner.component.d.ts +0 -20
  96. package/lib/modules/matecu-spinner/matecu-spinner.module.d.ts +0 -8
  97. package/lib/modules/matecu-spinner/services/matecu-spinner.service.d.ts +0 -15
  98. package/lib/modules/matecu-topbar-layout/components/matecu-topbar-actions/matecu-topbar-actions.component.d.ts +0 -8
  99. package/lib/modules/matecu-topbar-layout/components/matecu-topbar-body/matecu-topbar-body.component.d.ts +0 -11
  100. package/lib/modules/matecu-topbar-layout/components/matecu-topbar-fab/matecu-topbar-fab.component.d.ts +0 -13
  101. package/lib/modules/matecu-topbar-layout/components/matecu-topbar-layout/matecu-topbar-layout.component.d.ts +0 -30
  102. package/lib/modules/matecu-topbar-layout/components/matecu-topbar-search/matecu-topbar-search.component.d.ts +0 -26
  103. package/lib/modules/matecu-topbar-layout/components/matecu-topbar-title/matecu-topbar-title.component.d.ts +0 -9
  104. package/lib/modules/matecu-topbar-layout/matecu-topbar-layout.module.d.ts +0 -17
package/README.md CHANGED
@@ -118,6 +118,35 @@ En el componente
118
118
  }
119
119
 
120
120
 
121
+ ## MatecuSnackBarService
122
+
123
+ Servicio para abrir dialogos snackBar con titulos con colores para Error, Success, Warning, Info
124
+
125
+ ### Uso
126
+
127
+ Importar en el módulo.
128
+
129
+ import { MatecuAlertBoxModule } from 'angular-matecu';
130
+
131
+ En el componente
132
+
133
+ import { MatecuSnackBarService } from 'angular-matecu';
134
+
135
+ // ....
136
+ constructor(private snackBar: MatecuSnackBarService) { }
137
+
138
+ openError(): void {
139
+ this.snackBar.openError('Mensaje de error');
140
+ }
141
+
142
+ ### Métodos
143
+
144
+ - openError()
145
+ - openInfo()
146
+ - openWarning()
147
+ - openSuccess()
148
+ - open()
149
+ - dismiss()
121
150
  # matecu-topbar-layout (Componente)
122
151
 
123
152
  ### Uso:
@@ -0,0 +1,10 @@
1
+ {
2
+ "folders": [
3
+ {
4
+ "path": "../.."
5
+ }
6
+ ],
7
+ "settings": {
8
+ "editor.formatOnSave": true
9
+ }
10
+ }
package/karma.conf.js ADDED
@@ -0,0 +1,44 @@
1
+ // Karma configuration file, see link for more information
2
+ // https://karma-runner.github.io/1.0/config/configuration-file.html
3
+
4
+ module.exports = function (config) {
5
+ config.set({
6
+ basePath: '',
7
+ frameworks: ['jasmine', '@angular-devkit/build-angular'],
8
+ plugins: [
9
+ require('karma-jasmine'),
10
+ require('karma-chrome-launcher'),
11
+ require('karma-jasmine-html-reporter'),
12
+ require('karma-coverage'),
13
+ require('@angular-devkit/build-angular/plugins/karma')
14
+ ],
15
+ client: {
16
+ jasmine: {
17
+ // you can add configuration options for Jasmine here
18
+ // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
19
+ // for example, you can disable the random execution with `random: false`
20
+ // or set a specific seed with `seed: 4321`
21
+ },
22
+ clearContext: false // leave Jasmine Spec Runner output visible in browser
23
+ },
24
+ jasmineHtmlReporter: {
25
+ suppressAll: true // removes the duplicated traces
26
+ },
27
+ coverageReporter: {
28
+ dir: require('path').join(__dirname, '../../coverage/angular-matecu'),
29
+ subdir: '.',
30
+ reporters: [
31
+ { type: 'html' },
32
+ { type: 'text-summary' }
33
+ ]
34
+ },
35
+ reporters: ['progress', 'kjhtml'],
36
+ port: 9876,
37
+ colors: true,
38
+ logLevel: config.LOG_INFO,
39
+ autoWatch: true,
40
+ browsers: ['Chrome'],
41
+ singleRun: false,
42
+ restartOnFileChange: true
43
+ });
44
+ };
@@ -0,0 +1,13 @@
1
+ {
2
+ "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3
+ "dest": "../../dist/angular-matecu",
4
+ "lib": {
5
+ "entryFile": "src/public-api.ts"
6
+ },
7
+ "assets": [
8
+ "src/scss/**/*.scss",
9
+ "src/css/**/*.css"
10
+
11
+ ]
12
+
13
+ }
package/package.json CHANGED
@@ -1,19 +1,11 @@
1
1
  {
2
2
  "name": "angular-matecu",
3
- "version": "2.0.6",
3
+ "version": "2.0.9",
4
4
  "peerDependencies": {
5
- "@angular/common": "^12.x",
6
- "@angular/core": "^12.x",
7
- "@angular/material": "^12.x"
5
+ "@angular/common": "^12.x || ^13.x",
6
+ "@angular/core": "^12.x || ^13.x",
7
+ "@angular/material": "^12.x || ^13.x"
8
8
  },
9
- "dependencies": {
10
- "tslib": "^2.1.0"
11
- },
12
- "main": "bundles/angular-matecu.umd.js",
13
- "module": "fesm2015/angular-matecu.js",
14
- "es2015": "fesm2015/angular-matecu.js",
15
- "esm2015": "esm2015/angular-matecu.js",
16
- "fesm2015": "fesm2015/angular-matecu.js",
17
- "typings": "angular-matecu.d.ts",
18
- "sideEffects": false
19
- }
9
+ "dependencies": {},
10
+ "devDependencies": {}
11
+ }
@@ -0,0 +1,11 @@
1
+ <ng-container *ngIf="icon && iconValue">
2
+ <div class="matecu-alert-box__icon">
3
+ <mat-icon>{{iconValue}}</mat-icon>
4
+ </div>
5
+ </ng-container>
6
+ <div class="matecu-alert-box__content">
7
+ <ng-content>
8
+
9
+
10
+ </ng-content>
11
+ </div>
@@ -0,0 +1,39 @@
1
+ :host.matecu-alert-box {
2
+ display: flex;
3
+ padding: 1rem;
4
+ border-radius: 0.25rem;
5
+ position: relative;
6
+ border: 1px solid rgb(224, 224, 224);
7
+ box-sizing: border-box;
8
+ margin: 1rem 0;
9
+
10
+ &--success {
11
+ color: rgb(15, 80, 50);
12
+ background-color: rgb(210, 230, 220);
13
+ border-color: rgb(186, 220, 205);
14
+ }
15
+ &--danger {
16
+ color: rgb(130, 30, 40);
17
+ background-color: rgb(248, 215, 218);
18
+ border-color: rgb(245, 194, 199);
19
+ }
20
+ &--warning {
21
+ color: rgb(100, 77, 3);
22
+ background-color: rgb(255, 243, 205);
23
+ border-color: rgb(255, 236, 180);
24
+ }
25
+ &--info {
26
+ color: rgb(5, 81, 96);
27
+ background-color: rgb(207, 244, 252);
28
+ border-color: rgb(182, 239, 251);
29
+ }
30
+ .matecu-alert-box {
31
+ &__icon {
32
+ display: flex;
33
+ margin-right: 1rem;
34
+ }
35
+ &__content {
36
+ align-self: center;
37
+ }
38
+ }
39
+ }
@@ -0,0 +1,25 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { MatecuAlertBoxComponent } from './matecu-alert-box.component';
4
+
5
+ describe('MatecuAlertBoxComponent', () => {
6
+ let component: MatecuAlertBoxComponent;
7
+ let fixture: ComponentFixture<MatecuAlertBoxComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ declarations: [ MatecuAlertBoxComponent ]
12
+ })
13
+ .compileComponents();
14
+ });
15
+
16
+ beforeEach(() => {
17
+ fixture = TestBed.createComponent(MatecuAlertBoxComponent);
18
+ component = fixture.componentInstance;
19
+ fixture.detectChanges();
20
+ });
21
+
22
+ it('should create', () => {
23
+ expect(component).toBeTruthy();
24
+ });
25
+ });
@@ -0,0 +1,56 @@
1
+ import { Component, HostBinding, Input, OnInit } from '@angular/core';
2
+ import { MatecuAlertBoxType } from '../../types/matecu-altert-box-type';
3
+
4
+ @Component({
5
+ selector: 'matecu-alert-box',
6
+ templateUrl: './matecu-alert-box.component.html',
7
+ styleUrls: ['./matecu-alert-box.component.scss'],
8
+ })
9
+ export class MatecuAlertBoxComponent implements OnInit {
10
+ classNameBase = 'matecu-alert-box';
11
+ alertColor?: MatecuAlertBoxType | undefined | string | null;
12
+ iconValue?: string | null | undefined;
13
+ private alertIcon = false;
14
+ get color(): MatecuAlertBoxType | undefined | string | null {
15
+ return this.alertColor;
16
+ }
17
+ @Input() set color(value: MatecuAlertBoxType | undefined | string | null) {
18
+ this.alertColor = value;
19
+ if (!!value) {
20
+ this.className = `${this.classNameBase} ${this.classNameBase}--${value}`;
21
+ } else {
22
+ this.className = this.classNameBase;
23
+ }
24
+ this.updateIcon();
25
+ }
26
+ get icon(): boolean {
27
+ return this.alertIcon;
28
+ }
29
+ @Input() set icon(value: boolean) {
30
+ this.alertIcon = value;
31
+ }
32
+ @HostBinding('class') className = this.classNameBase;
33
+ constructor() {}
34
+
35
+ ngOnInit(): void {}
36
+
37
+ private updateIcon(): void {
38
+ switch (this.color) {
39
+ case MatecuAlertBoxType.danger:
40
+ this.iconValue = 'dangerous';
41
+ break;
42
+ case MatecuAlertBoxType.warning:
43
+ this.iconValue = 'warning';
44
+ break;
45
+ case MatecuAlertBoxType.success:
46
+ this.iconValue = 'check_circle';
47
+ break;
48
+ case MatecuAlertBoxType.info:
49
+ this.iconValue = 'info';
50
+ break;
51
+ default:
52
+ this.iconValue = null;
53
+ break;
54
+ }
55
+ }
56
+ }
@@ -0,0 +1,14 @@
1
+ <h2 mat-dialog-title *ngIf="hasTitle">{{dialogData.title}}</h2>
2
+ <mat-dialog-content>
3
+
4
+ <matecu-alert-box [color]="dialogData.type" [icon]="!!dialogData.icon">
5
+ {{dialogData.message}}
6
+ </matecu-alert-box>
7
+
8
+ </mat-dialog-content>
9
+ <mat-dialog-actions *ngIf="showActions" align="end">
10
+ <button mat-button color="primary" tabindex="-1" mat-dialog-close
11
+ *ngIf="hasDismissBtn">{{dialogData.dismissText}}</button>
12
+ <button mat-button color="primary" tabindex="-2" (click)="activateAction()"
13
+ *ngIf="hasActionBtn">{{dialogData.action}}</button>
14
+ </mat-dialog-actions>
@@ -0,0 +1,5 @@
1
+ :host {
2
+ matecu-alert-box {
3
+ max-width: 900px;
4
+ }
5
+ }
@@ -0,0 +1,25 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { MatecuAlertDialogComponent } from './matecu-alert-dialog.component';
4
+
5
+ describe('MatecuAlertDialogComponent', () => {
6
+ let component: MatecuAlertDialogComponent;
7
+ let fixture: ComponentFixture<MatecuAlertDialogComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ declarations: [ MatecuAlertDialogComponent ]
12
+ })
13
+ .compileComponents();
14
+ });
15
+
16
+ beforeEach(() => {
17
+ fixture = TestBed.createComponent(MatecuAlertDialogComponent);
18
+ component = fixture.componentInstance;
19
+ fixture.detectChanges();
20
+ });
21
+
22
+ it('should create', () => {
23
+ expect(component).toBeTruthy();
24
+ });
25
+ });
@@ -0,0 +1,47 @@
1
+ import { Component, Inject, OnInit } from '@angular/core';
2
+ import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
3
+ import { MatecuAlertDialogData } from '../../types/matecu-alert-dialog';
4
+ @Component({
5
+ selector: 'matecu-alert-dialog',
6
+ templateUrl: './matecu-alert-dialog.component.html',
7
+ styleUrls: ['./matecu-alert-dialog.component.scss'],
8
+ })
9
+ export class MatecuAlertDialogComponent implements OnInit {
10
+ hasTitle = false;
11
+ hasDismissBtn = false;
12
+ hasActionBtn = false;
13
+ showActions = false;
14
+ constructor(
15
+ @Inject(MAT_DIALOG_DATA) public dialogData: MatecuAlertDialogData,
16
+ public dialogRef: MatDialogRef<MatecuAlertDialogComponent>
17
+ ) {
18
+ this.setHasTitle();
19
+ this.setHasDismissBtn();
20
+ this.setHasActionBtn();
21
+ this.setShowActions();
22
+ }
23
+
24
+ ngOnInit(): void {}
25
+
26
+ activateAction(): void {
27
+ this.dialogRef.close(true);
28
+ }
29
+
30
+ private setHasTitle(): void {
31
+ this.hasTitle = this.isValidString(this.dialogData.title);
32
+ }
33
+ private setHasDismissBtn(): void {
34
+ this.hasDismissBtn = this.isValidString(this.dialogData.dismissText);
35
+ }
36
+
37
+ private setHasActionBtn(): void {
38
+ this.hasActionBtn = this.isValidString(this.dialogData.action);
39
+ }
40
+ private setShowActions(): void {
41
+ this.showActions = this.hasActionBtn || this.hasDismissBtn;
42
+ }
43
+ private isValidString(str: string | null | undefined): boolean {
44
+ const isValid = typeof str === 'string' && str.trim().length > 0;
45
+ return isValid;
46
+ }
47
+ }
@@ -0,0 +1,17 @@
1
+ import { NgModule } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+ import { MatecuAlertBoxComponent } from './components/matecu-alert-box/matecu-alert-box.component';
4
+ import { MatIconModule } from '@angular/material/icon';
5
+ import { MatecuAlertDialogComponent } from './components/matecu-alert-dialog/matecu-alert-dialog.component';
6
+ import { MatDialogModule } from '@angular/material/dialog';
7
+ import { MatButtonModule } from '@angular/material/button';
8
+ import { MatecuSnackBarAlertComponent } from './matecu-snack-bar-alert/matecu-snack-bar-alert.component';
9
+ import { MatSnackBarModule } from '@angular/material/snack-bar';
10
+ import { MatecuAlertSnackBarComponent } from './matecu-alert-snack-bar/matecu-alert-snack-bar.component';
11
+
12
+ @NgModule({
13
+ declarations: [MatecuAlertBoxComponent, MatecuAlertDialogComponent, MatecuSnackBarAlertComponent, MatecuAlertSnackBarComponent],
14
+ imports: [CommonModule, MatIconModule, MatDialogModule, MatButtonModule, MatSnackBarModule],
15
+ exports: [MatecuAlertBoxComponent]
16
+ })
17
+ export class MatecuAlertBoxModule {}
@@ -0,0 +1,25 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { MatecuAlertSnackBarComponent } from './matecu-alert-snack-bar.component';
4
+
5
+ describe('MatecuAlertSnackBarComponent', () => {
6
+ let component: MatecuAlertSnackBarComponent;
7
+ let fixture: ComponentFixture<MatecuAlertSnackBarComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ declarations: [ MatecuAlertSnackBarComponent ]
12
+ })
13
+ .compileComponents();
14
+ });
15
+
16
+ beforeEach(() => {
17
+ fixture = TestBed.createComponent(MatecuAlertSnackBarComponent);
18
+ component = fixture.componentInstance;
19
+ fixture.detectChanges();
20
+ });
21
+
22
+ it('should create', () => {
23
+ expect(component).toBeTruthy();
24
+ });
25
+ });
@@ -0,0 +1,15 @@
1
+ import { Component, OnInit } from '@angular/core';
2
+
3
+ @Component({
4
+ selector: 'matecu-alert-snack-bar',
5
+ templateUrl: './matecu-alert-snack-bar.component.html',
6
+ styleUrls: ['./matecu-alert-snack-bar.component.css']
7
+ })
8
+ export class MatecuAlertSnackBarComponent implements OnInit {
9
+
10
+ constructor() { }
11
+
12
+ ngOnInit(): void {
13
+ }
14
+
15
+ }
@@ -0,0 +1,8 @@
1
+ <div>
2
+ <strong>{{title}}</strong> &nbsp;
3
+ <span>{{message}}</span>
4
+ </div>
5
+ <div *ngIf="!!action?.length">
6
+
7
+ <button mat-button color="accent" (click)="dismiss()">{{action}}</button>
8
+ </div>
@@ -0,0 +1,34 @@
1
+ :host.matecu-alert-snackbar {
2
+ display: flex;
3
+ align-items: center;
4
+ > * {
5
+ &:not(:first-child) {
6
+ margin-left: 10px;
7
+
8
+ }
9
+
10
+ }
11
+ &--success {
12
+ strong {
13
+
14
+ color: rgb(32, 219, 32);
15
+ }
16
+ }
17
+ &--danger {
18
+ strong {
19
+ color: red;
20
+ }
21
+ }
22
+ &--warning {
23
+ strong {
24
+ color: orange;
25
+ }
26
+ }
27
+ &--info {
28
+ strong {
29
+ color: rgb(7, 160, 237)
30
+ }
31
+ }
32
+
33
+
34
+ }
@@ -0,0 +1,25 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { MatecuSnackBarAlertComponent } from './matecu-snack-bar-alert.component';
4
+
5
+ describe('MatecuSnackBarAlertComponent', () => {
6
+ let component: MatecuSnackBarAlertComponent;
7
+ let fixture: ComponentFixture<MatecuSnackBarAlertComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ declarations: [ MatecuSnackBarAlertComponent ]
12
+ })
13
+ .compileComponents();
14
+ });
15
+
16
+ beforeEach(() => {
17
+ fixture = TestBed.createComponent(MatecuSnackBarAlertComponent);
18
+ component = fixture.componentInstance;
19
+ fixture.detectChanges();
20
+ });
21
+
22
+ it('should create', () => {
23
+ expect(component).toBeTruthy();
24
+ });
25
+ });
@@ -0,0 +1,41 @@
1
+ import { Component, HostBinding, Inject, OnInit } from '@angular/core';
2
+ import { MatSnackBarRef, MAT_SNACK_BAR_DATA } from '@angular/material/snack-bar';
3
+ import { MatecuAlertSnackBarData } from '../types/matecu-alert-snackbar';
4
+ import { MatecuAlertBoxType } from '../types/matecu-altert-box-type';
5
+
6
+ @Component({
7
+ selector: 'matecu-snack-bar-alert',
8
+ templateUrl: './matecu-snack-bar-alert.component.html',
9
+ styleUrls: ['./matecu-snack-bar-alert.component.scss']
10
+ })
11
+ export class MatecuSnackBarAlertComponent {
12
+
13
+ title: string;
14
+ message: string;
15
+ action?: string;
16
+ classNameBase = 'matecu-alert-snackbar';
17
+ alertColor!: MatecuAlertBoxType ;
18
+ get color(): MatecuAlertBoxType {
19
+ return this.alertColor;
20
+ }
21
+ set color(value: MatecuAlertBoxType ) {
22
+ this.alertColor = value;
23
+ this.className = `${this.classNameBase} ${this.classNameBase}--${value}`;
24
+ }
25
+ @HostBinding('class') className = this.classNameBase;
26
+ constructor(
27
+ @Inject(MAT_SNACK_BAR_DATA) public data: MatecuAlertSnackBarData,
28
+ private snackBarRef: MatSnackBarRef<MatecuSnackBarAlertComponent>) {
29
+ this.title = data.title;
30
+ this.message = data.message;
31
+ this.action = data.action;
32
+ this.color = data.type;
33
+
34
+ }
35
+
36
+ dismiss():void {
37
+ this.snackBarRef.dismissWithAction();
38
+ }
39
+
40
+
41
+ }
@@ -0,0 +1,16 @@
1
+ import { TestBed } from '@angular/core/testing';
2
+
3
+ import { MatecuSnackBarService } from './matecu-snack-bar.service';
4
+
5
+ describe('MatecuSnackBarService', () => {
6
+ let service: MatecuSnackBarService;
7
+
8
+ beforeEach(() => {
9
+ TestBed.configureTestingModule({});
10
+ service = TestBed.inject(MatecuSnackBarService);
11
+ });
12
+
13
+ it('should be created', () => {
14
+ expect(service).toBeTruthy();
15
+ });
16
+ });
@@ -0,0 +1,66 @@
1
+ import { Injectable } from '@angular/core';
2
+ import { MatSnackBar, MatSnackBarConfig, MatSnackBarRef, TextOnlySnackBar } from '@angular/material/snack-bar';
3
+ import { MatecuSnackBarAlertComponent } from '../matecu-snack-bar-alert/matecu-snack-bar-alert.component';
4
+ import { MatecuAlertSnackBarData } from '../types/matecu-alert-snackbar';
5
+ import { MatecuAlertBoxType } from '../types/matecu-altert-box-type';
6
+
7
+ @Injectable({
8
+ providedIn: 'root'
9
+ })
10
+ export class MatecuSnackBarService {
11
+
12
+ constructor(private snackBar: MatSnackBar) { }
13
+
14
+
15
+
16
+ openError(error: string | Error, title?: string | null, action?: string, config?:MatSnackBarConfig<any>): MatSnackBarRef<MatecuSnackBarAlertComponent> {
17
+ const message = this.getErrorMessage(error);
18
+ const titleStr = title || 'ERROR';
19
+ const type = MatecuAlertBoxType.danger;
20
+ return this.openAlert(message, titleStr, type, action, config);
21
+ }
22
+ openSuccess(message: string, title?: string | null, action?: string, config?:MatSnackBarConfig<any>): MatSnackBarRef<MatecuSnackBarAlertComponent> {
23
+ const titleStr = title || 'OK';
24
+ const type = MatecuAlertBoxType.success;
25
+ return this.openAlert(message, titleStr, type, action, config);
26
+ }
27
+ openWarning(message: string, title?: string | null, action?: string, config?:MatSnackBarConfig<any>): MatSnackBarRef<MatecuSnackBarAlertComponent> {
28
+ const titleStr = title || 'WARNING';
29
+ const type = MatecuAlertBoxType.warning;
30
+ return this.openAlert(message, titleStr, type, action, config);
31
+ }
32
+ openInfo(message: string, title?: string | null, action?: string, config?:MatSnackBarConfig<any>): MatSnackBarRef<MatecuSnackBarAlertComponent> {
33
+ const titleStr = title || 'INFO';
34
+ const type = MatecuAlertBoxType.info;
35
+ return this.openAlert(message, titleStr, type, action, config);
36
+ }
37
+ open(message: string, action?: string, config?: MatSnackBarConfig<any>): MatSnackBarRef<TextOnlySnackBar> {
38
+ return this.snackBar.open(message, action,config);
39
+ }
40
+ dismiss(): void {
41
+ this.snackBar.dismiss()
42
+ }
43
+ private openAlert(message: string, title: string, type: MatecuAlertBoxType, action?: string, config?:MatSnackBarConfig<any> ) {
44
+
45
+ const data: MatecuAlertSnackBarData = {
46
+ message,
47
+ title,
48
+ action,
49
+ type
50
+ }
51
+ const dialogConfig = {...config, data}
52
+
53
+ return this.snackBar.openFromComponent(MatecuSnackBarAlertComponent, dialogConfig);
54
+ }
55
+
56
+ private getErrorMessage(err: string | Error ): string {
57
+ const error = new Error()
58
+ if (typeof err === 'string') {
59
+ return err;
60
+ }
61
+ if (err instanceof Error) {
62
+ return err.message;
63
+ }
64
+ return '';
65
+ }
66
+ }
@@ -0,0 +1,10 @@
1
+ import { MatecuAlertBoxType } from './matecu-altert-box-type';
2
+
3
+ export interface MatecuAlertDialogData {
4
+ message: string;
5
+ title?: string | null | undefined;
6
+ action?: string | null | undefined;
7
+ icon?: boolean | null | undefined;
8
+ type?: MatecuAlertBoxType | string | null | undefined;
9
+ dismissText?: string | null | undefined;
10
+ }
@@ -0,0 +1,8 @@
1
+ import { MatecuAlertBoxType } from './matecu-altert-box-type';
2
+
3
+ export interface MatecuAlertSnackBarData {
4
+ message: string;
5
+ title: string;
6
+ action?: string;
7
+ type: MatecuAlertBoxType
8
+ }
@@ -0,0 +1,6 @@
1
+ export enum MatecuAlertBoxType {
2
+ warning = 'warning',
3
+ success = 'success',
4
+ danger = 'danger',
5
+ info = 'info',
6
+ }