ng-comps 1.0.2 → 2.0.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/fesm2022/ng-comps.mjs +4254 -0
- package/package.json +54 -58
- package/src/styles.css +54 -0
- package/types/ng-comps.d.ts +1348 -0
- package/.editorconfig +0 -17
- package/.github/copilot-instructions.md +0 -55
- package/.github/workflows/ci.yml +0 -29
- package/.prettierrc +0 -12
- package/.storybook/main.ts +0 -21
- package/.storybook/preview.ts +0 -27
- package/.storybook/tsconfig.doc.json +0 -10
- package/.storybook/tsconfig.json +0 -15
- package/.storybook/typings.d.ts +0 -4
- package/.vscode/extensions.json +0 -4
- package/.vscode/launch.json +0 -20
- package/.vscode/mcp.json +0 -9
- package/.vscode/tasks.json +0 -42
- package/ACCESSIBILITY.md +0 -127
- package/angular.json +0 -106
- package/documentation.json +0 -13394
- package/ng-package.json +0 -27
- package/public/favicon.ico +0 -0
- package/scripts/prepare-package.mjs +0 -80
- package/src/app/a11y/accessibility.utils.ts +0 -35
- package/src/app/a11y/index.ts +0 -6
- package/src/app/accessibility/ng-comps.a11y.spec.ts +0 -108
- package/src/app/app.config.ts +0 -11
- package/src/app/app.css +0 -107
- package/src/app/app.html +0 -48
- package/src/app/app.routes.ts +0 -3
- package/src/app/app.spec.ts +0 -23
- package/src/app/app.ts +0 -10
- package/src/app/components/accordion/index.ts +0 -2
- package/src/app/components/accordion/mf-accordion.component.css +0 -38
- package/src/app/components/accordion/mf-accordion.component.spec.ts +0 -48
- package/src/app/components/accordion/mf-accordion.component.ts +0 -53
- package/src/app/components/alert/index.ts +0 -2
- package/src/app/components/alert/mf-alert.component.css +0 -100
- package/src/app/components/alert/mf-alert.component.spec.ts +0 -59
- package/src/app/components/alert/mf-alert.component.ts +0 -68
- package/src/app/components/autocomplete/index.ts +0 -5
- package/src/app/components/autocomplete/mf-autocomplete.component.css +0 -105
- package/src/app/components/autocomplete/mf-autocomplete.component.spec.ts +0 -116
- package/src/app/components/autocomplete/mf-autocomplete.component.ts +0 -307
- package/src/app/components/avatar/index.ts +0 -2
- package/src/app/components/avatar/mf-avatar.component.css +0 -27
- package/src/app/components/avatar/mf-avatar.component.spec.ts +0 -49
- package/src/app/components/avatar/mf-avatar.component.ts +0 -99
- package/src/app/components/badge/index.ts +0 -2
- package/src/app/components/badge/mf-badge.component.css +0 -32
- package/src/app/components/badge/mf-badge.component.spec.ts +0 -40
- package/src/app/components/badge/mf-badge.component.ts +0 -105
- package/src/app/components/breadcrumb/index.ts +0 -2
- package/src/app/components/breadcrumb/mf-breadcrumb.component.css +0 -61
- package/src/app/components/breadcrumb/mf-breadcrumb.component.spec.ts +0 -61
- package/src/app/components/breadcrumb/mf-breadcrumb.component.ts +0 -75
- package/src/app/components/button/index.ts +0 -2
- package/src/app/components/button/mf-button.component.css +0 -136
- package/src/app/components/button/mf-button.component.ts +0 -174
- package/src/app/components/card/index.ts +0 -2
- package/src/app/components/card/mf-card.component.css +0 -82
- package/src/app/components/card/mf-card.component.ts +0 -59
- package/src/app/components/checkbox/index.ts +0 -1
- package/src/app/components/checkbox/mf-checkbox.component.css +0 -75
- package/src/app/components/checkbox/mf-checkbox.component.ts +0 -187
- package/src/app/components/chip/index.ts +0 -2
- package/src/app/components/chip/mf-chip.component.css +0 -69
- package/src/app/components/chip/mf-chip.component.spec.ts +0 -47
- package/src/app/components/chip/mf-chip.component.ts +0 -77
- package/src/app/components/datepicker/index.ts +0 -2
- package/src/app/components/datepicker/mf-datepicker.component.css +0 -102
- package/src/app/components/datepicker/mf-datepicker.component.spec.ts +0 -69
- package/src/app/components/datepicker/mf-datepicker.component.ts +0 -233
- package/src/app/components/dialog/index.ts +0 -3
- package/src/app/components/dialog/mf-dialog.component.css +0 -73
- package/src/app/components/dialog/mf-dialog.component.ts +0 -160
- package/src/app/components/dialog/mf-dialog.service.spec.ts +0 -61
- package/src/app/components/dialog/mf-dialog.service.ts +0 -52
- package/src/app/components/divider/index.ts +0 -2
- package/src/app/components/divider/mf-divider.component.css +0 -38
- package/src/app/components/divider/mf-divider.component.spec.ts +0 -40
- package/src/app/components/divider/mf-divider.component.ts +0 -44
- package/src/app/components/form-field/index.ts +0 -1
- package/src/app/components/form-field/mf-form-field.component.css +0 -51
- package/src/app/components/form-field/mf-form-field.component.ts +0 -74
- package/src/app/components/grid-list/index.ts +0 -2
- package/src/app/components/grid-list/mf-grid-list.component.css +0 -47
- package/src/app/components/grid-list/mf-grid-list.component.spec.ts +0 -57
- package/src/app/components/grid-list/mf-grid-list.component.ts +0 -68
- package/src/app/components/icon/index.ts +0 -2
- package/src/app/components/icon/mf-icon.component.css +0 -56
- package/src/app/components/icon/mf-icon.component.ts +0 -41
- package/src/app/components/input/index.ts +0 -2
- package/src/app/components/input/mf-input.component.css +0 -105
- package/src/app/components/input/mf-input.component.ts +0 -217
- package/src/app/components/menu/index.ts +0 -2
- package/src/app/components/menu/mf-menu.component.css +0 -31
- package/src/app/components/menu/mf-menu.component.spec.ts +0 -49
- package/src/app/components/menu/mf-menu.component.ts +0 -66
- package/src/app/components/paginator/index.ts +0 -1
- package/src/app/components/paginator/mf-paginator.component.css +0 -32
- package/src/app/components/paginator/mf-paginator.component.spec.ts +0 -44
- package/src/app/components/paginator/mf-paginator.component.ts +0 -52
- package/src/app/components/progress-bar/index.ts +0 -2
- package/src/app/components/progress-bar/mf-progress-bar.component.css +0 -53
- package/src/app/components/progress-bar/mf-progress-bar.component.spec.ts +0 -65
- package/src/app/components/progress-bar/mf-progress-bar.component.ts +0 -79
- package/src/app/components/progress-spinner/index.ts +0 -2
- package/src/app/components/progress-spinner/mf-progress-spinner.component.css +0 -38
- package/src/app/components/progress-spinner/mf-progress-spinner.component.spec.ts +0 -59
- package/src/app/components/progress-spinner/mf-progress-spinner.component.ts +0 -81
- package/src/app/components/radio-button/index.ts +0 -2
- package/src/app/components/radio-button/mf-radio-button.component.css +0 -86
- package/src/app/components/radio-button/mf-radio-button.component.spec.ts +0 -55
- package/src/app/components/radio-button/mf-radio-button.component.ts +0 -219
- package/src/app/components/select/index.ts +0 -2
- package/src/app/components/select/mf-select.component.css +0 -121
- package/src/app/components/select/mf-select.component.spec.ts +0 -108
- package/src/app/components/select/mf-select.component.ts +0 -252
- package/src/app/components/sidenav/index.ts +0 -2
- package/src/app/components/sidenav/mf-sidenav.component.css +0 -168
- package/src/app/components/sidenav/mf-sidenav.component.spec.ts +0 -57
- package/src/app/components/sidenav/mf-sidenav.component.ts +0 -126
- package/src/app/components/slide-toggle/index.ts +0 -1
- package/src/app/components/slide-toggle/mf-slide-toggle.component.css +0 -42
- package/src/app/components/slide-toggle/mf-slide-toggle.component.spec.ts +0 -43
- package/src/app/components/slide-toggle/mf-slide-toggle.component.ts +0 -188
- package/src/app/components/snackbar/index.ts +0 -2
- package/src/app/components/snackbar/mf-snackbar.service.css +0 -31
- package/src/app/components/snackbar/mf-snackbar.service.spec.ts +0 -81
- package/src/app/components/snackbar/mf-snackbar.service.ts +0 -77
- package/src/app/components/table/index.ts +0 -2
- package/src/app/components/table/mf-table.component.css +0 -68
- package/src/app/components/table/mf-table.component.spec.ts +0 -76
- package/src/app/components/table/mf-table.component.ts +0 -117
- package/src/app/components/tabs/index.ts +0 -2
- package/src/app/components/tabs/mf-tabs.component.css +0 -31
- package/src/app/components/tabs/mf-tabs.component.spec.ts +0 -50
- package/src/app/components/tabs/mf-tabs.component.ts +0 -62
- package/src/app/components/textarea/index.ts +0 -2
- package/src/app/components/textarea/mf-textarea.component.css +0 -48
- package/src/app/components/textarea/mf-textarea.component.spec.ts +0 -55
- package/src/app/components/textarea/mf-textarea.component.ts +0 -227
- package/src/app/components/toolbar/index.ts +0 -2
- package/src/app/components/toolbar/mf-toolbar.component.css +0 -77
- package/src/app/components/toolbar/mf-toolbar.component.ts +0 -56
- package/src/app/components/tooltip/index.ts +0 -3
- package/src/app/components/tooltip/mf-tooltip.component.css +0 -7
- package/src/app/components/tooltip/mf-tooltip.component.spec.ts +0 -37
- package/src/app/components/tooltip/mf-tooltip.component.ts +0 -47
- package/src/app/components/tooltip/mf-tooltip.directive.ts +0 -22
- package/src/index.html +0 -18
- package/src/main.ts +0 -6
- package/src/public-api.ts +0 -31
- package/src/stories/About.mdx +0 -72
- package/src/stories/Accessibility.mdx +0 -59
- package/src/stories/Welcome.mdx +0 -26
- package/src/stories/assets/accessibility.png +0 -0
- package/src/stories/assets/accessibility.svg +0 -1
- package/src/stories/assets/addon-library.png +0 -0
- package/src/stories/assets/assets.png +0 -0
- package/src/stories/assets/avif-test-image.avif +0 -0
- package/src/stories/assets/context.png +0 -0
- package/src/stories/assets/discord.svg +0 -1
- package/src/stories/assets/docs.png +0 -0
- package/src/stories/assets/figma-plugin.png +0 -0
- package/src/stories/assets/github.svg +0 -1
- package/src/stories/assets/share.png +0 -0
- package/src/stories/assets/styling.png +0 -0
- package/src/stories/assets/testing.png +0 -0
- package/src/stories/assets/theming.png +0 -0
- package/src/stories/assets/tutorials.svg +0 -1
- package/src/stories/assets/youtube.svg +0 -1
- package/src/stories/mf-a11y-contracts.stories.ts +0 -472
- package/src/stories/mf-autocomplete.stories.ts +0 -194
- package/src/stories/mf-button.stories.ts +0 -152
- package/src/stories/mf-card.stories.ts +0 -147
- package/src/stories/mf-checkbox.stories.ts +0 -88
- package/src/stories/mf-datepicker.stories.ts +0 -118
- package/src/stories/mf-dialog.stories.ts +0 -159
- package/src/stories/mf-form-field.stories.ts +0 -108
- package/src/stories/mf-grid-list.stories.ts +0 -104
- package/src/stories/mf-icon.stories.ts +0 -133
- package/src/stories/mf-input.stories.ts +0 -158
- package/src/stories/mf-menu.stories.ts +0 -71
- package/src/stories/mf-progress-bar.stories.ts +0 -119
- package/src/stories/mf-progress-spinner.stories.ts +0 -124
- package/src/stories/mf-radio-button.stories.ts +0 -111
- package/src/stories/mf-select.stories.ts +0 -184
- package/src/stories/mf-sidenav.stories.ts +0 -331
- package/src/stories/mf-table.stories.ts +0 -80
- package/src/stories/mf-toolbar.stories.ts +0 -112
- package/src/stories/user.ts +0 -3
- package/tsconfig.app.json +0 -15
- package/tsconfig.json +0 -33
- package/tsconfig.spec.json +0 -15
- package/vercel.json +0 -6
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
:host {
|
|
2
|
-
display: block;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.mf-alert {
|
|
6
|
-
display: flex;
|
|
7
|
-
align-items: flex-start;
|
|
8
|
-
gap: var(--mf-space-3);
|
|
9
|
-
padding: var(--mf-space-3) var(--mf-space-4);
|
|
10
|
-
border-radius: var(--mf-radius-md);
|
|
11
|
-
font-family: var(--mf-font-base);
|
|
12
|
-
font-size: var(--mf-text-sm);
|
|
13
|
-
line-height: var(--mf-leading-normal);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/* ── Info ──────────────────────────────────────────────────────── */
|
|
17
|
-
.mf-alert--info {
|
|
18
|
-
background-color: var(--mf-color-secondary-50);
|
|
19
|
-
border-left: 4px solid var(--mf-color-secondary-500);
|
|
20
|
-
color: var(--mf-color-secondary-900);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.mf-alert--info .mf-alert__icon {
|
|
24
|
-
color: var(--mf-color-secondary-500);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/* ── Success ──────────────────────────────────────────────────── */
|
|
28
|
-
.mf-alert--success {
|
|
29
|
-
background-color: var(--mf-color-primary-50);
|
|
30
|
-
border-left: 4px solid var(--mf-color-primary-500);
|
|
31
|
-
color: var(--mf-color-primary-900);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.mf-alert--success .mf-alert__icon {
|
|
35
|
-
color: var(--mf-color-primary-500);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/* ── Warning ──────────────────────────────────────────────────── */
|
|
39
|
-
.mf-alert--warning {
|
|
40
|
-
background-color: #fffbeb;
|
|
41
|
-
border-left: 4px solid var(--mf-color-accent-500);
|
|
42
|
-
color: var(--mf-color-accent-700);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
.mf-alert--warning .mf-alert__icon {
|
|
46
|
-
color: var(--mf-color-accent-500);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/* ── Error ─────────────────────────────────────────────────────── */
|
|
50
|
-
.mf-alert--error {
|
|
51
|
-
background-color: #fef2f2;
|
|
52
|
-
border-left: 4px solid var(--mf-color-error-500);
|
|
53
|
-
color: var(--mf-color-error-700);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.mf-alert--error .mf-alert__icon {
|
|
57
|
-
color: var(--mf-color-error-500);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/* ── Content ──────────────────────────────────────────────────── */
|
|
61
|
-
.mf-alert__content {
|
|
62
|
-
flex: 1;
|
|
63
|
-
display: flex;
|
|
64
|
-
flex-direction: column;
|
|
65
|
-
gap: var(--mf-space-1);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
.mf-alert__title {
|
|
69
|
-
font-weight: var(--mf-weight-bold);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
.mf-alert__icon {
|
|
73
|
-
flex-shrink: 0;
|
|
74
|
-
margin-top: 1px;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/* ── Close button ─────────────────────────────────────────────── */
|
|
78
|
-
.mf-alert__close {
|
|
79
|
-
display: inline-flex;
|
|
80
|
-
align-items: center;
|
|
81
|
-
justify-content: center;
|
|
82
|
-
border: none;
|
|
83
|
-
background: none;
|
|
84
|
-
cursor: pointer;
|
|
85
|
-
padding: var(--mf-space-1);
|
|
86
|
-
border-radius: var(--mf-radius-sm);
|
|
87
|
-
color: inherit;
|
|
88
|
-
opacity: 0.6;
|
|
89
|
-
transition: opacity var(--mf-duration-fast) var(--mf-ease-standard);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
.mf-alert__close:hover {
|
|
93
|
-
opacity: 1;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
.mf-alert__close .mat-icon {
|
|
97
|
-
font-size: 18px;
|
|
98
|
-
width: 18px;
|
|
99
|
-
height: 18px;
|
|
100
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
-
import { MfAlertComponent } from './mf-alert.component';
|
|
3
|
-
|
|
4
|
-
describe('MfAlertComponent', () => {
|
|
5
|
-
let fixture: ComponentFixture<MfAlertComponent>;
|
|
6
|
-
let component: MfAlertComponent;
|
|
7
|
-
|
|
8
|
-
beforeEach(async () => {
|
|
9
|
-
await TestBed.configureTestingModule({
|
|
10
|
-
imports: [MfAlertComponent],
|
|
11
|
-
}).compileComponents();
|
|
12
|
-
|
|
13
|
-
fixture = TestBed.createComponent(MfAlertComponent);
|
|
14
|
-
component = fixture.componentInstance;
|
|
15
|
-
fixture.componentRef.setInput('message', 'Test alert');
|
|
16
|
-
fixture.detectChanges();
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('should create', () => {
|
|
20
|
-
expect(component).toBeTruthy();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('should render message', () => {
|
|
24
|
-
const msg = fixture.nativeElement.querySelector('.mf-alert__message');
|
|
25
|
-
expect(msg?.textContent).toContain('Test alert');
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('should apply info severity by default', () => {
|
|
29
|
-
expect(component.hostClasses()).toContain('mf-alert--info');
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('should show info icon by default', () => {
|
|
33
|
-
expect(component.iconName()).toBe('info');
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('should show check_circle icon for success', () => {
|
|
37
|
-
fixture.componentRef.setInput('severity', 'success');
|
|
38
|
-
expect(component.iconName()).toBe('check_circle');
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('should show title when provided', () => {
|
|
42
|
-
fixture.componentRef.setInput('title', 'Attention');
|
|
43
|
-
fixture.detectChanges();
|
|
44
|
-
const title = fixture.nativeElement.querySelector('.mf-alert__title');
|
|
45
|
-
expect(title?.textContent).toContain('Attention');
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('should show close button when dismissible', () => {
|
|
49
|
-
fixture.componentRef.setInput('dismissible', true);
|
|
50
|
-
fixture.detectChanges();
|
|
51
|
-
const close = fixture.nativeElement.querySelector('.mf-alert__close');
|
|
52
|
-
expect(close).toBeTruthy();
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('should have role alert', () => {
|
|
56
|
-
const alert = fixture.nativeElement.querySelector('[role="alert"]');
|
|
57
|
-
expect(alert).toBeTruthy();
|
|
58
|
-
});
|
|
59
|
-
});
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ChangeDetectionStrategy,
|
|
3
|
-
Component,
|
|
4
|
-
computed,
|
|
5
|
-
input,
|
|
6
|
-
output,
|
|
7
|
-
} from '@angular/core';
|
|
8
|
-
import { MatIconModule } from '@angular/material/icon';
|
|
9
|
-
|
|
10
|
-
export type MfAlertSeverity = 'info' | 'success' | 'warning' | 'error';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Alerta de la librería ng-comps.
|
|
14
|
-
* Componente de banner para mensajes de sistema, alertas y notificaciones.
|
|
15
|
-
* Ideal para dashboards y paneles administrativos.
|
|
16
|
-
*/
|
|
17
|
-
@Component({
|
|
18
|
-
selector: 'mf-alert',
|
|
19
|
-
imports: [MatIconModule],
|
|
20
|
-
template: `
|
|
21
|
-
<div [class]="hostClasses()" role="alert">
|
|
22
|
-
<mat-icon class="mf-alert__icon" aria-hidden="true">{{ iconName() }}</mat-icon>
|
|
23
|
-
<div class="mf-alert__content">
|
|
24
|
-
@if (title()) {
|
|
25
|
-
<strong class="mf-alert__title">{{ title() }}</strong>
|
|
26
|
-
}
|
|
27
|
-
<span class="mf-alert__message">{{ message() }}</span>
|
|
28
|
-
</div>
|
|
29
|
-
@if (dismissible()) {
|
|
30
|
-
<button
|
|
31
|
-
class="mf-alert__close"
|
|
32
|
-
(click)="mfDismiss.emit()"
|
|
33
|
-
[attr.aria-label]="'Close alert'"
|
|
34
|
-
>
|
|
35
|
-
<mat-icon aria-hidden="true">close</mat-icon>
|
|
36
|
-
</button>
|
|
37
|
-
}
|
|
38
|
-
</div>
|
|
39
|
-
`,
|
|
40
|
-
styleUrl: './mf-alert.component.css',
|
|
41
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
42
|
-
})
|
|
43
|
-
export class MfAlertComponent {
|
|
44
|
-
/** Mensaje principal */
|
|
45
|
-
readonly message = input.required<string>();
|
|
46
|
-
/** Título opcional */
|
|
47
|
-
readonly title = input<string | undefined>(undefined);
|
|
48
|
-
/** Severidad de la alerta */
|
|
49
|
-
readonly severity = input<MfAlertSeverity>('info');
|
|
50
|
-
/** Se puede cerrar */
|
|
51
|
-
readonly dismissible = input(false);
|
|
52
|
-
|
|
53
|
-
readonly mfDismiss = output<void>();
|
|
54
|
-
|
|
55
|
-
readonly iconName = computed(() => {
|
|
56
|
-
const map: Record<MfAlertSeverity, string> = {
|
|
57
|
-
info: 'info',
|
|
58
|
-
success: 'check_circle',
|
|
59
|
-
warning: 'warning',
|
|
60
|
-
error: 'error',
|
|
61
|
-
};
|
|
62
|
-
return map[this.severity()];
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
readonly hostClasses = computed(() => {
|
|
66
|
-
return ['mf-alert', `mf-alert--${this.severity()}`].join(' ');
|
|
67
|
-
});
|
|
68
|
-
}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
:host {
|
|
2
|
-
display: inline-block;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
/* ── Base ──────────────────────────────────────────────────────── */
|
|
6
|
-
.mf-autocomplete {
|
|
7
|
-
font-family: var(--mf-font-base) !important;
|
|
8
|
-
width: 100%;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.mf-autocomplete--full {
|
|
12
|
-
width: 100%;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/* ── Mat-form-field overrides ─────────────────────────────────── */
|
|
16
|
-
.mf-autocomplete .mat-mdc-text-field-wrapper {
|
|
17
|
-
border-radius: var(--mf-radius-md) !important;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.mf-autocomplete .mdc-notched-outline__leading,
|
|
21
|
-
.mf-autocomplete .mdc-notched-outline__notch,
|
|
22
|
-
.mf-autocomplete .mdc-notched-outline__trailing {
|
|
23
|
-
border-color: var(--mf-color-border) !important;
|
|
24
|
-
transition: border-color var(--mf-duration-base) var(--mf-ease-standard);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.mf-autocomplete .mat-mdc-form-field-focus-overlay {
|
|
28
|
-
background-color: transparent !important;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/* ── Focus state ──────────────────────────────────────────────── */
|
|
32
|
-
.mf-autocomplete.mat-focused .mdc-notched-outline__leading,
|
|
33
|
-
.mf-autocomplete.mat-focused .mdc-notched-outline__notch,
|
|
34
|
-
.mf-autocomplete.mat-focused .mdc-notched-outline__trailing {
|
|
35
|
-
border-color: var(--mf-color-brand) !important;
|
|
36
|
-
border-width: 1.5px !important;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/* ── Error state ──────────────────────────────────────────────── */
|
|
40
|
-
.mf-autocomplete--error .mdc-notched-outline__leading,
|
|
41
|
-
.mf-autocomplete--error .mdc-notched-outline__notch,
|
|
42
|
-
.mf-autocomplete--error .mdc-notched-outline__trailing {
|
|
43
|
-
border-color: var(--mf-color-error-500) !important;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/* ── Label ────────────────────────────────────────────────────── */
|
|
47
|
-
.mf-autocomplete .mat-mdc-floating-label {
|
|
48
|
-
font-family: var(--mf-font-base) !important;
|
|
49
|
-
font-weight: var(--mf-weight-medium) !important;
|
|
50
|
-
color: var(--mf-color-neutral-400) !important;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
.mf-autocomplete.mat-focused .mat-mdc-floating-label {
|
|
54
|
-
color: var(--mf-color-brand) !important;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/* ── Input text ───────────────────────────────────────────────── */
|
|
58
|
-
.mf-autocomplete .mat-mdc-input-element {
|
|
59
|
-
font-family: var(--mf-font-base) !important;
|
|
60
|
-
color: var(--mf-color-on-surface) !important;
|
|
61
|
-
caret-color: var(--mf-color-brand);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/* ── Hint & Error ─────────────────────────────────────────────── */
|
|
65
|
-
.mf-autocomplete .mat-mdc-form-field-hint {
|
|
66
|
-
font-size: var(--mf-text-xs) !important;
|
|
67
|
-
color: var(--mf-color-neutral-400) !important;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.mf-autocomplete .mat-mdc-form-field-error {
|
|
71
|
-
font-size: var(--mf-text-xs) !important;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/* ── Prefix / Suffix icons ────────────────────────────────────── */
|
|
75
|
-
.mf-autocomplete .mat-icon {
|
|
76
|
-
color: var(--mf-color-neutral-400) !important;
|
|
77
|
-
font-size: 20px;
|
|
78
|
-
width: 20px;
|
|
79
|
-
height: 20px;
|
|
80
|
-
transition: color var(--mf-duration-base) var(--mf-ease-standard);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
.mf-autocomplete.mat-focused .mat-icon {
|
|
84
|
-
color: var(--mf-color-brand) !important;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/* ── Sizes ─────────────────────────────────────────────────────── */
|
|
88
|
-
.mf-autocomplete--sm .mat-mdc-input-element {
|
|
89
|
-
font-size: var(--mf-text-sm) !important;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
.mf-autocomplete--md .mat-mdc-input-element {
|
|
93
|
-
font-size: var(--mf-text-base) !important;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
.mf-autocomplete--lg .mat-mdc-input-element {
|
|
97
|
-
font-size: var(--mf-text-lg) !important;
|
|
98
|
-
padding-top: var(--mf-space-1) !important;
|
|
99
|
-
padding-bottom: var(--mf-space-1) !important;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/* ── Disabled ──────────────────────────────────────────────────── */
|
|
103
|
-
.mf-autocomplete .mat-mdc-input-element:disabled {
|
|
104
|
-
color: var(--mf-color-neutral-300) !important;
|
|
105
|
-
}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
-
import { MfAutocompleteComponent } from './mf-autocomplete.component';
|
|
3
|
-
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
|
4
|
-
|
|
5
|
-
describe('MfAutocompleteComponent', () => {
|
|
6
|
-
let fixture: ComponentFixture<MfAutocompleteComponent>;
|
|
7
|
-
let component: MfAutocompleteComponent;
|
|
8
|
-
|
|
9
|
-
const testOptions = [
|
|
10
|
-
{ value: '1', label: 'Angular' },
|
|
11
|
-
{ value: '2', label: 'React' },
|
|
12
|
-
{ value: '3', label: 'Vue' },
|
|
13
|
-
{ value: '4', label: 'Svelte', disabled: true },
|
|
14
|
-
];
|
|
15
|
-
|
|
16
|
-
beforeEach(async () => {
|
|
17
|
-
await TestBed.configureTestingModule({
|
|
18
|
-
imports: [MfAutocompleteComponent, NoopAnimationsModule],
|
|
19
|
-
}).compileComponents();
|
|
20
|
-
|
|
21
|
-
fixture = TestBed.createComponent(MfAutocompleteComponent);
|
|
22
|
-
component = fixture.componentInstance;
|
|
23
|
-
fixture.componentRef.setInput('options', testOptions);
|
|
24
|
-
fixture.detectChanges();
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('should create', () => {
|
|
28
|
-
expect(component).toBeTruthy();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('should render input with mat-autocomplete', () => {
|
|
32
|
-
const input = fixture.nativeElement.querySelector('input[matinput]');
|
|
33
|
-
expect(input).toBeTruthy();
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('should apply md size class by default', () => {
|
|
37
|
-
expect(component.hostClasses()).toContain('mf-autocomplete--md');
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('should apply sm size class', () => {
|
|
41
|
-
fixture.componentRef.setInput('size', 'sm');
|
|
42
|
-
expect(component.hostClasses()).toContain('mf-autocomplete--sm');
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('should apply lg size class', () => {
|
|
46
|
-
fixture.componentRef.setInput('size', 'lg');
|
|
47
|
-
expect(component.hostClasses()).toContain('mf-autocomplete--lg');
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('should include mf-autocomplete--full when fullWidth is true', () => {
|
|
51
|
-
fixture.componentRef.setInput('fullWidth', true);
|
|
52
|
-
expect(component.hostClasses()).toContain('mf-autocomplete--full');
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('should include mf-autocomplete--error when error is provided', () => {
|
|
56
|
-
fixture.componentRef.setInput('error', 'Required');
|
|
57
|
-
expect(component.hostClasses()).toContain('mf-autocomplete--error');
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('should include mf-autocomplete-panel in panelClasses by default', () => {
|
|
61
|
-
expect(component.autocompletePanelClasses()).toContain('mf-autocomplete-panel');
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('should merge extra panelClass string', () => {
|
|
65
|
-
fixture.componentRef.setInput('panelClass', 'custom-panel');
|
|
66
|
-
expect(component.autocompletePanelClasses()).toContain('mf-autocomplete-panel');
|
|
67
|
-
expect(component.autocompletePanelClasses()).toContain('custom-panel');
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('should filter options based on input text', () => {
|
|
71
|
-
component.inputValue = 'ang';
|
|
72
|
-
fixture.detectChanges();
|
|
73
|
-
const filtered = component.filteredOptions();
|
|
74
|
-
expect(filtered.length).toBe(1);
|
|
75
|
-
expect(filtered[0].label).toBe('Angular');
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it('should return all options when input is empty', () => {
|
|
79
|
-
component.inputValue = '';
|
|
80
|
-
expect(component.filteredOptions().length).toBe(testOptions.length);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it('should emit mfInput on input change', () => {
|
|
84
|
-
const spy = vi.fn();
|
|
85
|
-
component.mfInput.subscribe(spy);
|
|
86
|
-
component.onInputChange('Ang');
|
|
87
|
-
expect(spy).toHaveBeenCalledWith('Ang');
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it('should emit mfOptionSelected when option is selected', () => {
|
|
91
|
-
const spy = vi.fn();
|
|
92
|
-
component.mfOptionSelected.subscribe(spy);
|
|
93
|
-
component.onOptionSelected({ option: { value: 'Angular' } });
|
|
94
|
-
expect(spy).toHaveBeenCalledWith(testOptions[0]);
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it('should render label when provided', () => {
|
|
98
|
-
fixture.componentRef.setInput('label', 'Framework');
|
|
99
|
-
fixture.detectChanges();
|
|
100
|
-
const label = fixture.nativeElement.querySelector('mat-label');
|
|
101
|
-
expect(label?.textContent).toContain('Framework');
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it('should render hint when provided', () => {
|
|
105
|
-
fixture.componentRef.setInput('hint', 'Start typing...');
|
|
106
|
-
fixture.detectChanges();
|
|
107
|
-
const hint = fixture.nativeElement.querySelector('mat-hint');
|
|
108
|
-
expect(hint?.textContent).toContain('Start typing...');
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('should render error when provided', () => {
|
|
112
|
-
fixture.componentRef.setInput('error', 'Selection required');
|
|
113
|
-
fixture.detectChanges();
|
|
114
|
-
expect(fixture.nativeElement.textContent).toContain('Selection required');
|
|
115
|
-
});
|
|
116
|
-
});
|