angular-matecu 4.0.7 → 4.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.
Files changed (126) hide show
  1. package/README.md +347 -130
  2. package/ng-package.json +7 -0
  3. package/package.json +6 -21
  4. package/src/lib/components/matecu-alert-box/matecu-alert-box.component.html +11 -0
  5. package/src/lib/components/matecu-alert-box/matecu-alert-box.component.scss +39 -0
  6. package/src/lib/components/matecu-alert-box/matecu-alert-box.component.spec.ts +25 -0
  7. package/src/lib/components/matecu-alert-box/matecu-alert-box.component.ts +60 -0
  8. package/src/lib/components/matecu-alert-dialog/matecu-alert-dialog.component.html +24 -0
  9. package/src/lib/components/matecu-alert-dialog/matecu-alert-dialog.component.scss +5 -0
  10. package/src/lib/components/matecu-alert-dialog/matecu-alert-dialog.component.spec.ts +25 -0
  11. package/src/lib/components/matecu-alert-dialog/matecu-alert-dialog.component.ts +53 -0
  12. package/src/lib/components/matecu-alert-snack-bar/matecu-alert-snack-bar.component.html +10 -0
  13. package/src/lib/components/matecu-alert-snack-bar/matecu-alert-snack-bar.component.scss +34 -0
  14. package/src/lib/components/matecu-alert-snack-bar/matecu-alert-snack-bar.component.spec.ts +25 -0
  15. package/src/lib/components/matecu-alert-snack-bar/matecu-alert-snack-bar.component.ts +45 -0
  16. package/src/lib/components/matecu-autocomplete/matecu-autocomplete.html +36 -0
  17. package/src/lib/components/matecu-autocomplete/matecu-autocomplete.scss +56 -0
  18. package/src/lib/components/matecu-autocomplete/matecu-autocomplete.spec.ts +23 -0
  19. package/src/lib/components/matecu-autocomplete/matecu-autocomplete.ts +336 -0
  20. package/src/lib/components/matecu-autocomplete-multiple/matecu-autocomplete-multiple.html +64 -0
  21. package/src/lib/components/matecu-autocomplete-multiple/matecu-autocomplete-multiple.scss +23 -0
  22. package/src/lib/components/matecu-autocomplete-multiple/matecu-autocomplete-multiple.spec.ts +23 -0
  23. package/src/lib/components/matecu-autocomplete-multiple/matecu-autocomplete-multiple.ts +314 -0
  24. package/src/lib/components/matecu-file-input/matecu-file-input-customization.md +284 -0
  25. package/src/lib/components/matecu-file-input/matecu-file-input.example.md +228 -0
  26. package/src/lib/components/matecu-file-input/matecu-file-input.html +128 -0
  27. package/src/lib/components/matecu-file-input/matecu-file-input.scss +461 -0
  28. package/src/lib/components/matecu-file-input/matecu-file-input.spec.ts +340 -0
  29. package/src/lib/components/matecu-file-input/matecu-file-input.ts +438 -0
  30. package/src/lib/components/matecu-spinner/matecu-spinner.component.css +15 -0
  31. package/src/lib/components/matecu-spinner/matecu-spinner.component.html +44 -0
  32. package/src/lib/components/matecu-spinner/matecu-spinner.component.spec.ts +25 -0
  33. package/src/lib/components/matecu-spinner/matecu-spinner.component.ts +54 -0
  34. package/src/lib/components/matecu-spinner/spinner-loader.component.scss +13 -0
  35. package/src/lib/components/matecu-topbar-action/matecu-topbar-action.component.html +1 -0
  36. package/src/lib/components/matecu-topbar-action/matecu-topbar-action.component.scss +19 -0
  37. package/src/lib/components/matecu-topbar-action/matecu-topbar-action.component.spec.ts +25 -0
  38. package/src/lib/components/matecu-topbar-action/matecu-topbar-action.component.ts +14 -0
  39. package/src/lib/components/matecu-topbar-body/matecu-topbar-body.component.html +1 -0
  40. package/src/lib/components/matecu-topbar-body/matecu-topbar-body.component.scss +14 -0
  41. package/src/lib/components/matecu-topbar-body/matecu-topbar-body.component.spec.ts +25 -0
  42. package/src/lib/components/matecu-topbar-body/matecu-topbar-body.component.ts +11 -0
  43. package/src/lib/components/matecu-topbar-fab/matecu-topbar-fab.component.html +3 -0
  44. package/src/lib/components/matecu-topbar-fab/matecu-topbar-fab.component.scss +19 -0
  45. package/src/lib/components/matecu-topbar-fab/matecu-topbar-fab.component.spec.ts +25 -0
  46. package/src/lib/components/matecu-topbar-fab/matecu-topbar-fab.component.ts +31 -0
  47. package/src/lib/components/matecu-topbar-header-column/matecu-topbar-header-column.component.html +1 -0
  48. package/src/lib/components/matecu-topbar-header-column/matecu-topbar-header-column.component.scss +8 -0
  49. package/src/lib/components/matecu-topbar-header-column/matecu-topbar-header-column.component.spec.ts +23 -0
  50. package/src/lib/components/matecu-topbar-header-column/matecu-topbar-header-column.component.ts +11 -0
  51. package/src/lib/components/matecu-topbar-header-row/matecu-topbar-header-row.component.html +9 -0
  52. package/src/lib/components/matecu-topbar-header-row/matecu-topbar-header-row.component.scss +34 -0
  53. package/src/lib/components/matecu-topbar-header-row/matecu-topbar-header-row.component.spec.ts +23 -0
  54. package/src/lib/components/matecu-topbar-header-row/matecu-topbar-header-row.component.ts +18 -0
  55. package/src/lib/components/matecu-topbar-layout/matecu-topbar-layout.component.html +7 -0
  56. package/src/lib/components/matecu-topbar-layout/matecu-topbar-layout.component.scss +49 -0
  57. package/src/lib/components/matecu-topbar-layout/matecu-topbar-layout.component.spec.ts +25 -0
  58. package/src/lib/components/matecu-topbar-layout/matecu-topbar-layout.component.ts +112 -0
  59. package/src/lib/components/matecu-topbar-search/matecu-topbar-search.component.html +20 -0
  60. package/src/lib/components/matecu-topbar-search/matecu-topbar-search.component.scss +90 -0
  61. package/src/lib/components/matecu-topbar-search/matecu-topbar-search.component.spec.ts +25 -0
  62. package/src/lib/components/matecu-topbar-search/matecu-topbar-search.component.ts +92 -0
  63. package/src/lib/components/matecu-topbar-title/matecu-topbar-title.component.html +1 -0
  64. package/src/lib/components/matecu-topbar-title/matecu-topbar-title.component.scss +91 -0
  65. package/src/lib/components/matecu-topbar-title/matecu-topbar-title.component.spec.ts +25 -0
  66. package/src/lib/components/matecu-topbar-title/matecu-topbar-title.component.ts +14 -0
  67. package/src/lib/modules/matecu-alert-box/matecu-alert-box.module.ts +16 -0
  68. package/src/lib/modules/matecu-spinner/matecu-spinner.module.ts +14 -0
  69. package/src/lib/modules/matecu-topbar-layout/matecu-topbar-layout.module.ts +45 -0
  70. package/src/lib/services/matecu-snack-bar.service.spec.ts +16 -0
  71. package/src/lib/services/matecu-snack-bar.service.ts +66 -0
  72. package/src/lib/services/matecu-spinner.service.spec.ts +16 -0
  73. package/src/lib/services/matecu-spinner.service.ts +39 -0
  74. package/src/lib/types/matecu-alert-dialog.ts +10 -0
  75. package/{lib/types/matecu-alert-snackbar.d.ts → src/lib/types/matecu-alert-snackbar.ts} +5 -4
  76. package/src/lib/types/matecu-altert-box-type.ts +6 -0
  77. package/src/lib/types/matecu-autocomplete.ts +5 -0
  78. package/{public-api.d.ts → src/public-api.ts} +14 -0
  79. package/tsconfig.lib.json +17 -0
  80. package/tsconfig.lib.prod.json +11 -0
  81. package/tsconfig.spec.json +15 -0
  82. package/CHANGELOG.md +0 -22
  83. package/esm2022/angular-matecu.mjs +0 -5
  84. package/esm2022/lib/components/matecu-alert-box/matecu-alert-box.component.mjs +0 -67
  85. package/esm2022/lib/components/matecu-alert-dialog/matecu-alert-dialog.component.mjs +0 -54
  86. package/esm2022/lib/components/matecu-alert-snack-bar/matecu-alert-snack-bar.component.mjs +0 -43
  87. package/esm2022/lib/components/matecu-spinner/matecu-spinner.component.mjs +0 -58
  88. package/esm2022/lib/components/matecu-topbar-action/matecu-topbar-action.component.mjs +0 -18
  89. package/esm2022/lib/components/matecu-topbar-body/matecu-topbar-body.component.mjs +0 -17
  90. package/esm2022/lib/components/matecu-topbar-fab/matecu-topbar-fab.component.mjs +0 -43
  91. package/esm2022/lib/components/matecu-topbar-header-column/matecu-topbar-header-column.component.mjs +0 -12
  92. package/esm2022/lib/components/matecu-topbar-header-row/matecu-topbar-header-row.component.mjs +0 -29
  93. package/esm2022/lib/components/matecu-topbar-layout/matecu-topbar-layout.component.mjs +0 -112
  94. package/esm2022/lib/components/matecu-topbar-search/matecu-topbar-search.component.mjs +0 -93
  95. package/esm2022/lib/components/matecu-topbar-title/matecu-topbar-title.component.mjs +0 -18
  96. package/esm2022/lib/modules/matecu-alert-box/matecu-alert-box.module.mjs +0 -24
  97. package/esm2022/lib/modules/matecu-spinner/matecu-spinner.module.mjs +0 -22
  98. package/esm2022/lib/modules/matecu-topbar-layout/matecu-topbar-layout.module.mjs +0 -83
  99. package/esm2022/lib/services/matecu-snack-bar.service.mjs +0 -66
  100. package/esm2022/lib/services/matecu-spinner.service.mjs +0 -44
  101. package/esm2022/lib/types/matecu-alert-dialog.mjs +0 -2
  102. package/esm2022/lib/types/matecu-alert-snackbar.mjs +0 -2
  103. package/esm2022/lib/types/matecu-altert-box-type.mjs +0 -8
  104. package/esm2022/public-api.mjs +0 -32
  105. package/fesm2022/angular-matecu.mjs +0 -735
  106. package/fesm2022/angular-matecu.mjs.map +0 -1
  107. package/index.d.ts +0 -5
  108. package/lib/components/matecu-alert-box/matecu-alert-box.component.d.ts +0 -19
  109. package/lib/components/matecu-alert-dialog/matecu-alert-dialog.component.d.ts +0 -22
  110. package/lib/components/matecu-alert-snack-bar/matecu-alert-snack-bar.component.d.ts +0 -20
  111. package/lib/components/matecu-spinner/matecu-spinner.component.d.ts +0 -20
  112. package/lib/components/matecu-topbar-action/matecu-topbar-action.component.d.ts +0 -9
  113. package/lib/components/matecu-topbar-body/matecu-topbar-body.component.d.ts +0 -6
  114. package/lib/components/matecu-topbar-fab/matecu-topbar-fab.component.d.ts +0 -12
  115. package/lib/components/matecu-topbar-header-column/matecu-topbar-header-column.component.d.ts +0 -5
  116. package/lib/components/matecu-topbar-header-row/matecu-topbar-header-row.component.d.ts +0 -8
  117. package/lib/components/matecu-topbar-layout/matecu-topbar-layout.component.d.ts +0 -27
  118. package/lib/components/matecu-topbar-search/matecu-topbar-search.component.d.ts +0 -27
  119. package/lib/components/matecu-topbar-title/matecu-topbar-title.component.d.ts +0 -9
  120. package/lib/modules/matecu-alert-box/matecu-alert-box.module.d.ts +0 -14
  121. package/lib/modules/matecu-spinner/matecu-spinner.module.d.ts +0 -8
  122. package/lib/modules/matecu-topbar-layout/matecu-topbar-layout.module.d.ts +0 -19
  123. package/lib/services/matecu-snack-bar.service.d.ts +0 -17
  124. package/lib/services/matecu-spinner.service.d.ts +0 -15
  125. package/lib/types/matecu-alert-dialog.d.ts +0 -9
  126. package/lib/types/matecu-altert-box-type.d.ts +0 -6
package/package.json CHANGED
@@ -1,27 +1,12 @@
1
1
  {
2
2
  "name": "angular-matecu",
3
- "version": "4.0.7",
3
+ "version": "4.1.0",
4
4
  "license": "MIT",
5
5
  "peerDependencies": {
6
- "@angular/common": "^15.x || ^16.x || ^17.x || ^18.x || 19.x",
7
- "@angular/core": "^15.x || ^16.x || ^17.x || ^18.x || 19.x",
8
- "@angular/material": "^15.x || ^16.x || ^17.x || ^18.x || 19.x"
6
+ "@angular/common": ">=17.0.0",
7
+ "@angular/core": ">=17.0.0",
8
+ "@angular/material": ">=17.0.0"
9
9
  },
10
- "dependencies": {
11
- "tslib": "^2.3.0"
12
- },
13
- "module": "fesm2022/angular-matecu.mjs",
14
- "typings": "index.d.ts",
15
- "exports": {
16
- "./package.json": {
17
- "default": "./package.json"
18
- },
19
- ".": {
20
- "types": "./index.d.ts",
21
- "esm2022": "./esm2022/angular-matecu.mjs",
22
- "esm": "./esm2022/angular-matecu.mjs",
23
- "default": "./fesm2022/angular-matecu.mjs"
24
- }
25
- },
26
- "sideEffects": false
10
+ "dependencies": {},
11
+ "devDependencies": {}
27
12
  }
@@ -0,0 +1,11 @@
1
+ @if (icon && iconValue) {
2
+ <div class="matecu-alert-box__icon">
3
+ <mat-icon>{{iconValue}}</mat-icon>
4
+ </div>
5
+ }
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,60 @@
1
+ import { CommonModule } from '@angular/common';
2
+ import { Component, HostBinding, Input, OnInit } from '@angular/core';
3
+ import { MatIconModule } from '@angular/material/icon';
4
+ import { MatecuAlertBoxType } from '../../types/matecu-altert-box-type';
5
+
6
+ @Component({
7
+ selector: 'matecu-alert-box',
8
+ templateUrl: './matecu-alert-box.component.html',
9
+ styleUrls: ['./matecu-alert-box.component.scss'],
10
+ standalone: true,
11
+ imports: [CommonModule, MatIconModule]
12
+ })
13
+ export class MatecuAlertBoxComponent implements OnInit {
14
+ classNameBase = 'matecu-alert-box';
15
+ alertColor?: MatecuAlertBoxType | undefined | string | null;
16
+ iconValue?: string | null | undefined;
17
+ private alertIcon = false;
18
+ get color(): MatecuAlertBoxType | undefined | string | null {
19
+ return this.alertColor;
20
+ }
21
+ @Input() set color(value: MatecuAlertBoxType | undefined | string | null) {
22
+ this.alertColor = value;
23
+ if (!!value) {
24
+ this.className = `${this.classNameBase} ${this.classNameBase}--${value}`;
25
+ } else {
26
+ this.className = this.classNameBase;
27
+ }
28
+ this.updateIcon();
29
+ }
30
+ get icon(): boolean {
31
+ return this.alertIcon;
32
+ }
33
+ @Input() set icon(value: boolean) {
34
+ this.alertIcon = value;
35
+ }
36
+ @HostBinding('class') className = this.classNameBase;
37
+ constructor() { }
38
+
39
+ ngOnInit(): void { }
40
+
41
+ private updateIcon(): void {
42
+ switch (this.color) {
43
+ case MatecuAlertBoxType.danger:
44
+ this.iconValue = 'dangerous';
45
+ break;
46
+ case MatecuAlertBoxType.warning:
47
+ this.iconValue = 'warning';
48
+ break;
49
+ case MatecuAlertBoxType.success:
50
+ this.iconValue = 'check_circle';
51
+ break;
52
+ case MatecuAlertBoxType.info:
53
+ this.iconValue = 'info';
54
+ break;
55
+ default:
56
+ this.iconValue = null;
57
+ break;
58
+ }
59
+ }
60
+ }
@@ -0,0 +1,24 @@
1
+ @if (hasTitle) {
2
+
3
+ <h2 mat-dialog-title>{{dialogData.title}}</h2>
4
+ }
5
+ <mat-dialog-content>
6
+
7
+ <matecu-alert-box [color]="dialogData.type" [icon]="!!dialogData.icon">
8
+ {{dialogData.message}}
9
+ </matecu-alert-box>
10
+
11
+ </mat-dialog-content>
12
+ @if (showActions) {
13
+
14
+ <mat-dialog-actions align="end">
15
+ @if (hasDismissBtn) {
16
+ <button mat-button color="primary" tabindex="-1" mat-dialog-close>{{dialogData.dismissText}}
17
+ </button>
18
+ }
19
+ @if(hasActionBtn) {
20
+ <button mat-button color="primary" tabindex="-2" (click)="activateAction()">{{dialogData.action}}
21
+ </button>
22
+ }
23
+ </mat-dialog-actions>
24
+ }
@@ -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,53 @@
1
+ import { CommonModule } from '@angular/common';
2
+ import { Component, Inject, OnInit } from '@angular/core';
3
+ import { MatButtonModule } from '@angular/material/button';
4
+ import { MAT_DIALOG_DATA, MatDialogRef, MatDialogModule } from '@angular/material/dialog';
5
+ import { MatIconModule } from '@angular/material/icon';
6
+ import { MatecuAlertDialogData } from '../../types/matecu-alert-dialog';
7
+ import { MatecuAlertBoxComponent } from '../matecu-alert-box/matecu-alert-box.component';
8
+ @Component({
9
+ selector: 'matecu-alert-dialog',
10
+ templateUrl: './matecu-alert-dialog.component.html',
11
+ styleUrls: ['./matecu-alert-dialog.component.scss'],
12
+ standalone: true,
13
+ imports: [CommonModule, MatDialogModule, MatIconModule, MatecuAlertBoxComponent, MatButtonModule]
14
+ })
15
+ export class MatecuAlertDialogComponent implements OnInit {
16
+ hasTitle = false;
17
+ hasDismissBtn = false;
18
+ hasActionBtn = false;
19
+ showActions = false;
20
+ constructor(
21
+ @Inject(MAT_DIALOG_DATA) public dialogData: MatecuAlertDialogData,
22
+ public dialogRef: MatDialogRef<MatecuAlertDialogComponent>
23
+ ) {
24
+ this.setHasTitle();
25
+ this.setHasDismissBtn();
26
+ this.setHasActionBtn();
27
+ this.setShowActions();
28
+ }
29
+
30
+ ngOnInit(): void { }
31
+
32
+ activateAction(): void {
33
+ this.dialogRef.close(true);
34
+ }
35
+
36
+ private setHasTitle(): void {
37
+ this.hasTitle = this.isValidString(this.dialogData.title);
38
+ }
39
+ private setHasDismissBtn(): void {
40
+ this.hasDismissBtn = this.isValidString(this.dialogData.dismissText);
41
+ }
42
+
43
+ private setHasActionBtn(): void {
44
+ this.hasActionBtn = this.isValidString(this.dialogData.action);
45
+ }
46
+ private setShowActions(): void {
47
+ this.showActions = this.hasActionBtn || this.hasDismissBtn;
48
+ }
49
+ private isValidString(str: string | null | undefined): boolean {
50
+ const isValid = typeof str === 'string' && str.trim().length > 0;
51
+ return isValid;
52
+ }
53
+ }
@@ -0,0 +1,10 @@
1
+ <div>
2
+ <strong>{{title}}</strong> &nbsp;
3
+ <span>{{message}}</span>
4
+ </div>
5
+ @if(action?.length){
6
+
7
+ <div>
8
+ <button mat-button color="accent" (click)="dismiss()">{{action}}</button>
9
+ </div>
10
+ }
@@ -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 { 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,45 @@
1
+ import { CommonModule } from '@angular/common';
2
+ import { Component, HostBinding, Inject, OnInit } from '@angular/core';
3
+ import { MatButtonModule } from '@angular/material/button';
4
+ import { MatSnackBarModule, MatSnackBarRef, MAT_SNACK_BAR_DATA } from '@angular/material/snack-bar';
5
+ import { MatecuAlertSnackBarData } from '../../types/matecu-alert-snackbar';
6
+ import { MatecuAlertBoxType } from '../../types/matecu-altert-box-type';
7
+
8
+ @Component({
9
+ selector: 'matecu-alert-snack-bar',
10
+ templateUrl: './matecu-alert-snack-bar.component.html',
11
+ styleUrls: ['./matecu-alert-snack-bar.component.scss'],
12
+ standalone: true,
13
+ imports: [CommonModule, MatButtonModule, MatSnackBarModule]
14
+ })
15
+ export class MatecuAlertSnackBarComponent {
16
+
17
+ title: string;
18
+ message: string;
19
+ action?: string;
20
+ classNameBase = 'matecu-alert-snackbar';
21
+ alertColor!: MatecuAlertBoxType;
22
+ get color(): MatecuAlertBoxType {
23
+ return this.alertColor;
24
+ }
25
+ set color(value: MatecuAlertBoxType) {
26
+ this.alertColor = value;
27
+ this.className = `${this.classNameBase} ${this.classNameBase}--${value}`;
28
+ }
29
+ @HostBinding('class') className = this.classNameBase;
30
+ constructor(
31
+ @Inject(MAT_SNACK_BAR_DATA) public data: MatecuAlertSnackBarData,
32
+ private snackBarRef: MatSnackBarRef<MatecuAlertSnackBarComponent>) {
33
+ this.title = data.title;
34
+ this.message = data.message;
35
+ this.action = data.action;
36
+ this.color = data.type;
37
+
38
+ }
39
+
40
+ dismiss(): void {
41
+ this.snackBarRef.dismissWithAction();
42
+ }
43
+
44
+
45
+ }
@@ -0,0 +1,36 @@
1
+ <input matInput type="text" matInput [formControl]="inputControl" [matAutocomplete]="auto" [class.loading]="loading"
2
+ [disabled]="disabled" [readonly]="readonly" />
3
+
4
+
5
+ <mat-autocomplete #auto="matAutocomplete" (optionSelected)="onOptionSelected($event.option.value)"
6
+ [displayWith]="displayLabel">
7
+
8
+ @for (option of filteredOptions$ | async; track $index) {
9
+
10
+ <mat-option [value]="option[0]">
11
+ {{ option[1] }}
12
+ </mat-option>
13
+
14
+ }
15
+
16
+ <!-- Crear nuevo -->
17
+ @if(allowCreate){
18
+
19
+ <mat-divider></mat-divider>
20
+
21
+ @if(showCreateOption ){
22
+ <mat-option (click)="onCreateClick()" class="create-option">
23
+ <span>➕</span><span>" {{ inputControl.value }}"</span>
24
+
25
+ </mat-option>
26
+ }
27
+ }
28
+
29
+ </mat-autocomplete>
30
+
31
+ <!-- Spinner -->
32
+ @if(loading){
33
+ <mat-progress-spinner class="loading-spinner" diameter="20" mode="indeterminate"
34
+ style="position:absolute; right:10px; top:50%; transform:translateY(-50%);">
35
+ </mat-progress-spinner>
36
+ }
@@ -0,0 +1,56 @@
1
+ :host {
2
+ display: block;
3
+ position: relative;
4
+ box-sizing: border-box;
5
+ width: 100%;
6
+ input {
7
+ border: none;
8
+ background-color: transparent;
9
+ outline: none;
10
+ }
11
+ .create-option {
12
+ display: flex;
13
+ justify-content: space-between;
14
+ align-items: center;
15
+ &:first-child {
16
+ margin-right: auto;
17
+ color: green;
18
+ }
19
+ }
20
+ }
21
+
22
+ // /* Spinner alineado como suffix de Material */
23
+ .loading-spinner {
24
+ position: absolute;
25
+ right: 12px;
26
+ top: 50%;
27
+ transform: translateY(-50%);
28
+ pointer-events: none;
29
+ }
30
+
31
+ // /* Ajuste para que no choque con el spinner */
32
+ input.loading {
33
+ padding-right: 40px;
34
+ }
35
+
36
+ // /* Opción de crear */
37
+ .create-option {
38
+ font-style: italic;
39
+ opacity: 0.85;
40
+ }
41
+
42
+ /* Hover más suave */
43
+ ::ng-deep .mat-mdc-option.create-option:hover {
44
+ background: rgba(0, 0, 0, 0.04);
45
+ }
46
+
47
+ /* Divider más discreto */
48
+ ::ng-deep .mat-mdc-autocomplete-panel mat-divider {
49
+ margin: 4px 0;
50
+ }
51
+
52
+ /* Estado disabled */
53
+ :host(.mat-mdc-input-disabled) {
54
+ opacity: 0.6;
55
+ pointer-events: none;
56
+ }
@@ -0,0 +1,23 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { MatecuAutocomplete } from './matecu-autocomplete';
4
+
5
+ describe('MatecuAutocomplete', () => {
6
+ let component: MatecuAutocomplete;
7
+ let fixture: ComponentFixture<MatecuAutocomplete>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ imports: [MatecuAutocomplete]
12
+ })
13
+ .compileComponents();
14
+
15
+ fixture = TestBed.createComponent(MatecuAutocomplete);
16
+ component = fixture.componentInstance;
17
+ await fixture.whenStable();
18
+ });
19
+
20
+ it('should create', () => {
21
+ expect(component).toBeTruthy();
22
+ });
23
+ });