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,75 +0,0 @@
|
|
|
1
|
-
:host {
|
|
2
|
-
display: block;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
/* ── Base ──────────────────────────────────────────────────────── */
|
|
6
|
-
.mf-checkbox {
|
|
7
|
-
font-family: var(--mf-font-base) !important;
|
|
8
|
-
display: flex;
|
|
9
|
-
flex-direction: column;
|
|
10
|
-
gap: var(--mf-space-1);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/* ── Label styling ────────────────────────────────────────────── */
|
|
14
|
-
.mf-checkbox .mdc-label,
|
|
15
|
-
.mf-checkbox .mat-mdc-checkbox-label {
|
|
16
|
-
font-family: var(--mf-font-base) !important;
|
|
17
|
-
font-size: var(--mf-text-sm) !important;
|
|
18
|
-
color: var(--mf-color-on-surface) !important;
|
|
19
|
-
cursor: pointer;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/* ── Unchecked state ──────────────────────────────────────────── */
|
|
23
|
-
.mf-checkbox .mdc-checkbox__background {
|
|
24
|
-
border-color: var(--mf-color-neutral-300) !important;
|
|
25
|
-
border-radius: var(--mf-radius-sm) !important;
|
|
26
|
-
border-width: 1.5px !important;
|
|
27
|
-
transition:
|
|
28
|
-
border-color var(--mf-duration-base) var(--mf-ease-standard),
|
|
29
|
-
background-color var(--mf-duration-base) var(--mf-ease-standard);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/* ── Checked state ────────────────────────────────────────────── */
|
|
33
|
-
.mf-checkbox .mdc-checkbox__native-control:checked ~ .mdc-checkbox__background,
|
|
34
|
-
.mf-checkbox .mdc-checkbox__native-control:indeterminate ~ .mdc-checkbox__background {
|
|
35
|
-
background-color: var(--mf-color-brand) !important;
|
|
36
|
-
border-color: var(--mf-color-brand) !important;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/* ── Hover ─────────────────────────────────────────────────────── */
|
|
40
|
-
.mf-checkbox:hover .mdc-checkbox__background {
|
|
41
|
-
border-color: var(--mf-color-brand) !important;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/* ── Ripple override ──────────────────────────────────────────── */
|
|
45
|
-
.mf-checkbox .mat-mdc-checkbox-ripple,
|
|
46
|
-
.mf-checkbox .mdc-checkbox__ripple {
|
|
47
|
-
display: none !important;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/* ── Focus ring ───────────────────────────────────────────────── */
|
|
51
|
-
.mf-checkbox .mdc-checkbox__native-control:focus ~ .mdc-checkbox__background {
|
|
52
|
-
box-shadow: 0 0 0 3px var(--mf-color-primary-100);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/* ── Disabled ──────────────────────────────────────────────────── */
|
|
56
|
-
.mf-checkbox--disabled {
|
|
57
|
-
opacity: 0.42;
|
|
58
|
-
pointer-events: none;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.mf-checkbox__hint,
|
|
62
|
-
.mf-checkbox__error {
|
|
63
|
-
margin: 0;
|
|
64
|
-
padding-left: calc(18px + var(--mf-space-3));
|
|
65
|
-
font-size: var(--mf-text-xs);
|
|
66
|
-
line-height: var(--mf-leading-normal);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.mf-checkbox__hint {
|
|
70
|
-
color: var(--mf-color-neutral-600);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
.mf-checkbox__error {
|
|
74
|
-
color: var(--mf-color-error-500);
|
|
75
|
-
}
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ChangeDetectionStrategy,
|
|
3
|
-
ChangeDetectorRef,
|
|
4
|
-
Component,
|
|
5
|
-
computed,
|
|
6
|
-
effect,
|
|
7
|
-
forwardRef,
|
|
8
|
-
inject,
|
|
9
|
-
input,
|
|
10
|
-
output,
|
|
11
|
-
signal,
|
|
12
|
-
} from '@angular/core';
|
|
13
|
-
import {
|
|
14
|
-
ControlValueAccessor,
|
|
15
|
-
NG_VALUE_ACCESSOR,
|
|
16
|
-
NgControl,
|
|
17
|
-
} from '@angular/forms';
|
|
18
|
-
import { MatCheckboxModule } from '@angular/material/checkbox';
|
|
19
|
-
import {
|
|
20
|
-
createUniqueId,
|
|
21
|
-
hasAccessibleName,
|
|
22
|
-
mergeAriaIds,
|
|
23
|
-
warnInDev,
|
|
24
|
-
} from '../../a11y';
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Checkbox de la librerÃa ng-comps.
|
|
28
|
-
* Envuelve Angular Material `mat-checkbox` y expone una API uniforme
|
|
29
|
-
* con look and feel de marca.
|
|
30
|
-
*/
|
|
31
|
-
@Component({
|
|
32
|
-
selector: 'mf-checkbox',
|
|
33
|
-
imports: [MatCheckboxModule],
|
|
34
|
-
providers: [
|
|
35
|
-
{
|
|
36
|
-
provide: NG_VALUE_ACCESSOR,
|
|
37
|
-
useExisting: forwardRef(() => MfCheckboxComponent),
|
|
38
|
-
multi: true,
|
|
39
|
-
},
|
|
40
|
-
],
|
|
41
|
-
template: `
|
|
42
|
-
<div [class]="hostClasses()">
|
|
43
|
-
<mat-checkbox
|
|
44
|
-
[id]="controlId()"
|
|
45
|
-
[checked]="internalValue()"
|
|
46
|
-
[disabled]="isDisabled()"
|
|
47
|
-
[indeterminate]="indeterminate()"
|
|
48
|
-
[required]="required()"
|
|
49
|
-
[attr.aria-label]="resolvedAriaLabel()"
|
|
50
|
-
[attr.aria-labelledby]="ariaLabelledby() || null"
|
|
51
|
-
[attr.aria-describedby]="describedBy()"
|
|
52
|
-
[attr.aria-invalid]="isInvalid() ? 'true' : null"
|
|
53
|
-
[attr.aria-required]="required() ? 'true' : null"
|
|
54
|
-
(change)="onCheckboxChange($event)"
|
|
55
|
-
(blur)="onBlur()"
|
|
56
|
-
>
|
|
57
|
-
{{ label() }}
|
|
58
|
-
</mat-checkbox>
|
|
59
|
-
|
|
60
|
-
@if (hint()) {
|
|
61
|
-
<p class="mf-checkbox__hint" [attr.id]="hintId()">{{ hint() }}</p>
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
@if (error()) {
|
|
65
|
-
<p class="mf-checkbox__error" [attr.id]="errorId()" role="alert">
|
|
66
|
-
{{ error() }}
|
|
67
|
-
</p>
|
|
68
|
-
}
|
|
69
|
-
</div>
|
|
70
|
-
`,
|
|
71
|
-
styleUrl: './mf-checkbox.component.css',
|
|
72
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
73
|
-
})
|
|
74
|
-
export class MfCheckboxComponent implements ControlValueAccessor {
|
|
75
|
-
private readonly cdr = inject(ChangeDetectorRef);
|
|
76
|
-
private readonly ngControl = inject(NgControl, { self: true, optional: true });
|
|
77
|
-
private readonly generatedId = createUniqueId('mf-checkbox');
|
|
78
|
-
private readonly disabledFromForm = signal(false);
|
|
79
|
-
protected readonly internalValue = signal(false);
|
|
80
|
-
private onControlChange: (value: boolean) => void = () => undefined;
|
|
81
|
-
private onControlTouched: () => void = () => undefined;
|
|
82
|
-
|
|
83
|
-
/** ID del control */
|
|
84
|
-
readonly id = input<string | undefined>(undefined);
|
|
85
|
-
/** Texto del checkbox */
|
|
86
|
-
readonly label = input<string>('');
|
|
87
|
-
/** Etiqueta accesible alternativa cuando no existe label visible */
|
|
88
|
-
readonly ariaLabel = input<string | undefined>(undefined);
|
|
89
|
-
/** Referencia externa a elementos que etiquetan el control */
|
|
90
|
-
readonly ariaLabelledby = input<string | undefined>(undefined);
|
|
91
|
-
/** Referencia externa a elementos descriptivos adicionales */
|
|
92
|
-
readonly ariaDescribedby = input<string | undefined>(undefined);
|
|
93
|
-
/** Estado marcado */
|
|
94
|
-
readonly checked = input(false);
|
|
95
|
-
/** Estado indeterminado */
|
|
96
|
-
readonly indeterminate = input(false);
|
|
97
|
-
/** Deshabilitado */
|
|
98
|
-
readonly disabled = input(false);
|
|
99
|
-
/** Requerido */
|
|
100
|
-
readonly required = input(false);
|
|
101
|
-
/** Texto de ayuda */
|
|
102
|
-
readonly hint = input<string | undefined>(undefined);
|
|
103
|
-
/** Mensaje de error */
|
|
104
|
-
readonly error = input<string | undefined>(undefined);
|
|
105
|
-
|
|
106
|
-
readonly mfChange = output<boolean>();
|
|
107
|
-
|
|
108
|
-
constructor() {
|
|
109
|
-
effect(() => {
|
|
110
|
-
this.internalValue.set(this.checked());
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
effect(() => {
|
|
114
|
-
if (
|
|
115
|
-
!hasAccessibleName(
|
|
116
|
-
this.label(),
|
|
117
|
-
this.ariaLabel(),
|
|
118
|
-
this.ariaLabelledby(),
|
|
119
|
-
)
|
|
120
|
-
) {
|
|
121
|
-
warnInDev(
|
|
122
|
-
'mf-checkbox requiere texto visible, `ariaLabel` o `ariaLabelledby` para exponer un nombre accesible.',
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
readonly controlId = computed(() => this.id() ?? this.generatedId);
|
|
129
|
-
readonly hintId = computed(() =>
|
|
130
|
-
this.hint() ? `${this.controlId()}-hint` : null,
|
|
131
|
-
);
|
|
132
|
-
readonly errorId = computed(() =>
|
|
133
|
-
this.error() ? `${this.controlId()}-error` : null,
|
|
134
|
-
);
|
|
135
|
-
readonly describedBy = computed(() =>
|
|
136
|
-
mergeAriaIds(this.ariaDescribedby(), this.hintId(), this.errorId()),
|
|
137
|
-
);
|
|
138
|
-
readonly resolvedAriaLabel = computed(() =>
|
|
139
|
-
this.label() ? null : this.ariaLabel() ?? null,
|
|
140
|
-
);
|
|
141
|
-
readonly isDisabled = computed(
|
|
142
|
-
() => this.disabled() || this.disabledFromForm(),
|
|
143
|
-
);
|
|
144
|
-
|
|
145
|
-
readonly hostClasses = computed(() => {
|
|
146
|
-
const classes = ['mf-checkbox'];
|
|
147
|
-
if (this.isDisabled()) classes.push('mf-checkbox--disabled');
|
|
148
|
-
if (this.error()) classes.push('mf-checkbox--error');
|
|
149
|
-
return classes.join(' ');
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
writeValue(value: boolean | null): void {
|
|
153
|
-
this.internalValue.set(Boolean(value));
|
|
154
|
-
this.cdr.markForCheck();
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
registerOnChange(fn: (value: boolean) => void): void {
|
|
158
|
-
this.onControlChange = fn;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
registerOnTouched(fn: () => void): void {
|
|
162
|
-
this.onControlTouched = fn;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
setDisabledState(isDisabled: boolean): void {
|
|
166
|
-
this.disabledFromForm.set(isDisabled);
|
|
167
|
-
this.cdr.markForCheck();
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
isInvalid(): boolean {
|
|
171
|
-
const control = this.ngControl?.control;
|
|
172
|
-
return Boolean(
|
|
173
|
-
this.error() || (control?.invalid && (control.touched || control.dirty)),
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
onCheckboxChange(event: { checked: boolean }): void {
|
|
178
|
-
this.internalValue.set(event.checked);
|
|
179
|
-
this.onControlChange(event.checked);
|
|
180
|
-
this.onControlTouched();
|
|
181
|
-
this.mfChange.emit(event.checked);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
onBlur(): void {
|
|
185
|
-
this.onControlTouched();
|
|
186
|
-
}
|
|
187
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
:host {
|
|
2
|
-
display: inline-block;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
/* ── Base ──────────────────────────────────────────────────────── */
|
|
6
|
-
.mf-chip.mat-mdc-chip {
|
|
7
|
-
font-family: var(--mf-font-base) !important;
|
|
8
|
-
font-size: var(--mf-text-sm) !important;
|
|
9
|
-
font-weight: var(--mf-weight-medium) !important;
|
|
10
|
-
border-radius: var(--mf-radius-full) !important;
|
|
11
|
-
transition:
|
|
12
|
-
background-color var(--mf-duration-base) var(--mf-ease-standard),
|
|
13
|
-
box-shadow var(--mf-duration-base) var(--mf-ease-standard);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/* ── Filled — Brand ───────────────────────────────────────────── */
|
|
17
|
-
.mf-chip--filled.mf-chip--brand.mat-mdc-chip {
|
|
18
|
-
background-color: var(--mf-color-primary-100) !important;
|
|
19
|
-
color: var(--mf-color-primary-800) !important;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/* ── Filled — Accent ──────────────────────────────────────────── */
|
|
23
|
-
.mf-chip--filled.mf-chip--accent.mat-mdc-chip {
|
|
24
|
-
background-color: var(--mf-color-accent-300) !important;
|
|
25
|
-
color: var(--mf-color-accent-700) !important;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/* ── Filled — Error ───────────────────────────────────────────── */
|
|
29
|
-
.mf-chip--filled.mf-chip--error.mat-mdc-chip {
|
|
30
|
-
background-color: #fee2e2 !important;
|
|
31
|
-
color: var(--mf-color-error-700) !important;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/* ── Filled — Neutral ─────────────────────────────────────────── */
|
|
35
|
-
.mf-chip--filled.mf-chip--neutral.mat-mdc-chip {
|
|
36
|
-
background-color: var(--mf-color-neutral-100) !important;
|
|
37
|
-
color: var(--mf-color-neutral-600) !important;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/* ── Outlined ─────────────────────────────────────────────────── */
|
|
41
|
-
.mf-chip--outlined.mat-mdc-chip {
|
|
42
|
-
background-color: transparent !important;
|
|
43
|
-
border: 1px solid var(--mf-color-border) !important;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.mf-chip--outlined.mf-chip--brand.mat-mdc-chip {
|
|
47
|
-
color: var(--mf-color-primary-700) !important;
|
|
48
|
-
border-color: var(--mf-color-primary-200) !important;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.mf-chip--outlined.mf-chip--accent.mat-mdc-chip {
|
|
52
|
-
color: var(--mf-color-accent-700) !important;
|
|
53
|
-
border-color: var(--mf-color-accent-300) !important;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.mf-chip--outlined.mf-chip--error.mat-mdc-chip {
|
|
57
|
-
color: var(--mf-color-error-700) !important;
|
|
58
|
-
border-color: var(--mf-color-error-500) !important;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/* ── Selected ─────────────────────────────────────────────────── */
|
|
62
|
-
.mf-chip--selected.mat-mdc-chip {
|
|
63
|
-
box-shadow: var(--mf-shadow-sm);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/* ── Disabled ─────────────────────────────────────────────────── */
|
|
67
|
-
.mf-chip.mat-mdc-chip.mat-mdc-chip-disabled {
|
|
68
|
-
opacity: 0.42;
|
|
69
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
-
import { MfChipComponent } from './mf-chip.component';
|
|
3
|
-
|
|
4
|
-
describe('MfChipComponent', () => {
|
|
5
|
-
let fixture: ComponentFixture<MfChipComponent>;
|
|
6
|
-
let component: MfChipComponent;
|
|
7
|
-
|
|
8
|
-
beforeEach(async () => {
|
|
9
|
-
await TestBed.configureTestingModule({
|
|
10
|
-
imports: [MfChipComponent],
|
|
11
|
-
}).compileComponents();
|
|
12
|
-
|
|
13
|
-
fixture = TestBed.createComponent(MfChipComponent);
|
|
14
|
-
component = fixture.componentInstance;
|
|
15
|
-
fixture.componentRef.setInput('label', 'Test');
|
|
16
|
-
fixture.detectChanges();
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('should create', () => {
|
|
20
|
-
expect(component).toBeTruthy();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('should render chip label', () => {
|
|
24
|
-
const chip = fixture.nativeElement.querySelector('mat-chip');
|
|
25
|
-
expect(chip?.textContent).toContain('Test');
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('should apply brand class by default', () => {
|
|
29
|
-
expect(component.hostClasses()).toContain('mf-chip--brand');
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('should apply filled variant by default', () => {
|
|
33
|
-
expect(component.hostClasses()).toContain('mf-chip--filled');
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('should apply selected class when selected', () => {
|
|
37
|
-
fixture.componentRef.setInput('selected', true);
|
|
38
|
-
expect(component.hostClasses()).toContain('mf-chip--selected');
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('should show remove button when removable', () => {
|
|
42
|
-
fixture.componentRef.setInput('removable', true);
|
|
43
|
-
fixture.detectChanges();
|
|
44
|
-
const removeBtn = fixture.nativeElement.querySelector('[matChipRemove]');
|
|
45
|
-
expect(removeBtn).toBeTruthy();
|
|
46
|
-
});
|
|
47
|
-
});
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ChangeDetectionStrategy,
|
|
3
|
-
Component,
|
|
4
|
-
computed,
|
|
5
|
-
input,
|
|
6
|
-
output,
|
|
7
|
-
} from '@angular/core';
|
|
8
|
-
import { MatChipsModule } from '@angular/material/chips';
|
|
9
|
-
import { MatIconModule } from '@angular/material/icon';
|
|
10
|
-
|
|
11
|
-
export type MfChipVariant = 'filled' | 'outlined';
|
|
12
|
-
export type MfChipColor = 'brand' | 'accent' | 'error' | 'neutral';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Chip de la librería ng-comps.
|
|
16
|
-
* Envuelve Angular Material `mat-chip` y expone una API uniforme
|
|
17
|
-
* con look and feel de marca. Ideal para tags, filtros y etiquetas.
|
|
18
|
-
*/
|
|
19
|
-
@Component({
|
|
20
|
-
selector: 'mf-chip',
|
|
21
|
-
imports: [MatChipsModule, MatIconModule],
|
|
22
|
-
template: `
|
|
23
|
-
@if (removable()) {
|
|
24
|
-
<mat-chip
|
|
25
|
-
[highlighted]="selected()"
|
|
26
|
-
[disabled]="disabled()"
|
|
27
|
-
[class]="hostClasses()"
|
|
28
|
-
(removed)="mfRemoved.emit()"
|
|
29
|
-
>
|
|
30
|
-
@if (leadingIcon()) {
|
|
31
|
-
<mat-icon matChipAvatar aria-hidden="true">{{ leadingIcon() }}</mat-icon>
|
|
32
|
-
}
|
|
33
|
-
{{ label() }}
|
|
34
|
-
<button matChipRemove [attr.aria-label]="'Remove ' + label()">
|
|
35
|
-
<mat-icon>cancel</mat-icon>
|
|
36
|
-
</button>
|
|
37
|
-
</mat-chip>
|
|
38
|
-
} @else {
|
|
39
|
-
<mat-chip
|
|
40
|
-
[highlighted]="selected()"
|
|
41
|
-
[disabled]="disabled()"
|
|
42
|
-
[class]="hostClasses()"
|
|
43
|
-
>
|
|
44
|
-
@if (leadingIcon()) {
|
|
45
|
-
<mat-icon matChipAvatar aria-hidden="true">{{ leadingIcon() }}</mat-icon>
|
|
46
|
-
}
|
|
47
|
-
{{ label() }}
|
|
48
|
-
</mat-chip>
|
|
49
|
-
}
|
|
50
|
-
`,
|
|
51
|
-
styleUrl: './mf-chip.component.css',
|
|
52
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
53
|
-
})
|
|
54
|
-
export class MfChipComponent {
|
|
55
|
-
/** Texto del chip */
|
|
56
|
-
readonly label = input.required<string>();
|
|
57
|
-
/** Variante visual */
|
|
58
|
-
readonly variant = input<MfChipVariant>('filled');
|
|
59
|
-
/** Color semántico */
|
|
60
|
-
readonly color = input<MfChipColor>('brand');
|
|
61
|
-
/** Seleccionado */
|
|
62
|
-
readonly selected = input(false);
|
|
63
|
-
/** Puede ser removido */
|
|
64
|
-
readonly removable = input(false);
|
|
65
|
-
/** Deshabilitado */
|
|
66
|
-
readonly disabled = input(false);
|
|
67
|
-
/** Icono inicial */
|
|
68
|
-
readonly leadingIcon = input<string | undefined>(undefined);
|
|
69
|
-
|
|
70
|
-
readonly mfRemoved = output<void>();
|
|
71
|
-
|
|
72
|
-
readonly hostClasses = computed(() => {
|
|
73
|
-
const classes = ['mf-chip', `mf-chip--${this.variant()}`, `mf-chip--${this.color()}`];
|
|
74
|
-
if (this.selected()) classes.push('mf-chip--selected');
|
|
75
|
-
return classes.join(' ');
|
|
76
|
-
});
|
|
77
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
:host {
|
|
2
|
-
display: inline-block;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
/* ── Base ──────────────────────────────────────────────────────── */
|
|
6
|
-
.mf-datepicker {
|
|
7
|
-
font-family: var(--mf-font-base) !important;
|
|
8
|
-
width: 100%;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.mf-datepicker--full {
|
|
12
|
-
width: 100%;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/* ── Mat-form-field overrides ─────────────────────────────────── */
|
|
16
|
-
.mf-datepicker .mat-mdc-text-field-wrapper {
|
|
17
|
-
border-radius: var(--mf-radius-md) !important;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.mf-datepicker .mdc-notched-outline__leading,
|
|
21
|
-
.mf-datepicker .mdc-notched-outline__notch,
|
|
22
|
-
.mf-datepicker .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-datepicker .mat-mdc-form-field-focus-overlay {
|
|
28
|
-
background-color: transparent !important;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/* ── Focus state ──────────────────────────────────────────────── */
|
|
32
|
-
.mf-datepicker.mat-focused .mdc-notched-outline__leading,
|
|
33
|
-
.mf-datepicker.mat-focused .mdc-notched-outline__notch,
|
|
34
|
-
.mf-datepicker.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-datepicker--error .mdc-notched-outline__leading,
|
|
41
|
-
.mf-datepicker--error .mdc-notched-outline__notch,
|
|
42
|
-
.mf-datepicker--error .mdc-notched-outline__trailing {
|
|
43
|
-
border-color: var(--mf-color-error-500) !important;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/* ── Label styles ─────────────────────────────────────────────── */
|
|
47
|
-
.mf-datepicker .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-datepicker.mat-focused .mat-mdc-floating-label {
|
|
54
|
-
color: var(--mf-color-brand) !important;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/* ── Input text ───────────────────────────────────────────────── */
|
|
58
|
-
.mf-datepicker .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
|
-
/* ── Toggle icon ──────────────────────────────────────────────── */
|
|
65
|
-
.mf-datepicker .mat-datepicker-toggle .mat-icon {
|
|
66
|
-
color: var(--mf-color-neutral-400) !important;
|
|
67
|
-
transition: color var(--mf-duration-base) var(--mf-ease-standard);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.mf-datepicker.mat-focused .mat-datepicker-toggle .mat-icon {
|
|
71
|
-
color: var(--mf-color-brand) !important;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/* ── Hint & Error ─────────────────────────────────────────────── */
|
|
75
|
-
.mf-datepicker .mat-mdc-form-field-hint {
|
|
76
|
-
font-size: var(--mf-text-xs) !important;
|
|
77
|
-
color: var(--mf-color-neutral-400) !important;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.mf-datepicker .mat-mdc-form-field-error {
|
|
81
|
-
font-size: var(--mf-text-xs) !important;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/* ── Sizes ─────────────────────────────────────────────────────── */
|
|
85
|
-
.mf-datepicker--sm .mat-mdc-input-element {
|
|
86
|
-
font-size: var(--mf-text-sm) !important;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
.mf-datepicker--md .mat-mdc-input-element {
|
|
90
|
-
font-size: var(--mf-text-base) !important;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
.mf-datepicker--lg .mat-mdc-input-element {
|
|
94
|
-
font-size: var(--mf-text-lg) !important;
|
|
95
|
-
padding-top: var(--mf-space-1) !important;
|
|
96
|
-
padding-bottom: var(--mf-space-1) !important;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/* ── Disabled ──────────────────────────────────────────────────── */
|
|
100
|
-
.mf-datepicker .mat-mdc-input-element:disabled {
|
|
101
|
-
color: var(--mf-color-neutral-300) !important;
|
|
102
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
-
import { MfDatepickerComponent } from './mf-datepicker.component';
|
|
3
|
-
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
|
4
|
-
|
|
5
|
-
describe('MfDatepickerComponent', () => {
|
|
6
|
-
let fixture: ComponentFixture<MfDatepickerComponent>;
|
|
7
|
-
let component: MfDatepickerComponent;
|
|
8
|
-
|
|
9
|
-
beforeEach(async () => {
|
|
10
|
-
await TestBed.configureTestingModule({
|
|
11
|
-
imports: [MfDatepickerComponent, NoopAnimationsModule],
|
|
12
|
-
}).compileComponents();
|
|
13
|
-
|
|
14
|
-
fixture = TestBed.createComponent(MfDatepickerComponent);
|
|
15
|
-
component = fixture.componentInstance;
|
|
16
|
-
fixture.detectChanges();
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('should create', () => {
|
|
20
|
-
expect(component).toBeTruthy();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('should render mat-form-field', () => {
|
|
24
|
-
const formField = fixture.nativeElement.querySelector('mat-form-field');
|
|
25
|
-
expect(formField).toBeTruthy();
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('should apply mf-datepicker class by default', () => {
|
|
29
|
-
expect(component.hostClasses()).toContain('mf-datepicker');
|
|
30
|
-
expect(component.hostClasses()).toContain('mf-datepicker--md');
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('should apply size class', () => {
|
|
34
|
-
fixture.componentRef.setInput('size', 'lg');
|
|
35
|
-
expect(component.hostClasses()).toContain('mf-datepicker--lg');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('should apply full-width class when fullWidth is true', () => {
|
|
39
|
-
fixture.componentRef.setInput('fullWidth', true);
|
|
40
|
-
expect(component.hostClasses()).toContain('mf-datepicker--full');
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('should apply error class when error is provided', () => {
|
|
44
|
-
fixture.componentRef.setInput('error', 'Date required');
|
|
45
|
-
expect(component.hostClasses()).toContain('mf-datepicker--error');
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('should render label when provided', () => {
|
|
49
|
-
fixture.componentRef.setInput('label', 'Start date');
|
|
50
|
-
fixture.detectChanges();
|
|
51
|
-
const label = fixture.nativeElement.querySelector('mat-label');
|
|
52
|
-
expect(label?.textContent).toContain('Start date');
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('should render hint when provided', () => {
|
|
56
|
-
fixture.componentRef.setInput('hint', 'Select a date');
|
|
57
|
-
fixture.detectChanges();
|
|
58
|
-
const hint = fixture.nativeElement.querySelector('mat-hint');
|
|
59
|
-
expect(hint).toBeTruthy();
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('should emit mfChange on date change', () => {
|
|
63
|
-
const spy = vi.fn();
|
|
64
|
-
component.mfChange.subscribe(spy);
|
|
65
|
-
const date = new Date(2025, 0, 15);
|
|
66
|
-
component.onDateChange({ value: date });
|
|
67
|
-
expect(spy).toHaveBeenCalledWith(date);
|
|
68
|
-
});
|
|
69
|
-
});
|