ng-comps 0.2.0 → 1.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.
Files changed (200) hide show
  1. package/.editorconfig +17 -0
  2. package/.github/copilot-instructions.md +55 -0
  3. package/.github/workflows/ci.yml +29 -0
  4. package/.prettierrc +12 -0
  5. package/.storybook/main.ts +21 -0
  6. package/.storybook/preview.ts +27 -0
  7. package/.storybook/tsconfig.doc.json +10 -0
  8. package/.storybook/tsconfig.json +15 -0
  9. package/.storybook/typings.d.ts +4 -0
  10. package/.vscode/extensions.json +4 -0
  11. package/.vscode/launch.json +20 -0
  12. package/.vscode/mcp.json +9 -0
  13. package/.vscode/tasks.json +42 -0
  14. package/ACCESSIBILITY.md +127 -0
  15. package/README.md +79 -62
  16. package/angular.json +105 -0
  17. package/documentation.json +13394 -0
  18. package/ng-package.json +27 -0
  19. package/package.json +58 -45
  20. package/public/favicon.ico +0 -0
  21. package/scripts/prepare-package.mjs +61 -0
  22. package/src/app/a11y/accessibility.utils.ts +35 -0
  23. package/src/app/a11y/index.ts +6 -0
  24. package/src/app/accessibility/ng-comps.a11y.spec.ts +108 -0
  25. package/src/app/app.config.ts +11 -0
  26. package/src/app/app.css +107 -0
  27. package/src/app/app.html +48 -0
  28. package/src/app/app.routes.ts +3 -0
  29. package/src/app/app.spec.ts +23 -0
  30. package/src/app/app.ts +10 -0
  31. package/src/app/components/accordion/index.ts +2 -0
  32. package/src/app/components/accordion/mf-accordion.component.css +38 -0
  33. package/src/app/components/accordion/mf-accordion.component.spec.ts +48 -0
  34. package/src/app/components/accordion/mf-accordion.component.ts +53 -0
  35. package/src/app/components/alert/index.ts +2 -0
  36. package/src/app/components/alert/mf-alert.component.css +100 -0
  37. package/src/app/components/alert/mf-alert.component.spec.ts +59 -0
  38. package/src/app/components/alert/mf-alert.component.ts +68 -0
  39. package/src/app/components/autocomplete/index.ts +5 -0
  40. package/src/app/components/autocomplete/mf-autocomplete.component.css +105 -0
  41. package/src/app/components/autocomplete/mf-autocomplete.component.spec.ts +116 -0
  42. package/src/app/components/autocomplete/mf-autocomplete.component.ts +307 -0
  43. package/src/app/components/avatar/index.ts +2 -0
  44. package/src/app/components/avatar/mf-avatar.component.css +27 -0
  45. package/src/app/components/avatar/mf-avatar.component.spec.ts +49 -0
  46. package/src/app/components/avatar/mf-avatar.component.ts +99 -0
  47. package/src/app/components/badge/index.ts +2 -0
  48. package/src/app/components/badge/mf-badge.component.css +32 -0
  49. package/src/app/components/badge/mf-badge.component.spec.ts +40 -0
  50. package/src/app/components/badge/mf-badge.component.ts +105 -0
  51. package/src/app/components/breadcrumb/index.ts +2 -0
  52. package/src/app/components/breadcrumb/mf-breadcrumb.component.css +61 -0
  53. package/src/app/components/breadcrumb/mf-breadcrumb.component.spec.ts +61 -0
  54. package/src/app/components/breadcrumb/mf-breadcrumb.component.ts +75 -0
  55. package/src/app/components/button/index.ts +2 -0
  56. package/src/app/components/button/mf-button.component.css +136 -0
  57. package/src/app/components/button/mf-button.component.ts +174 -0
  58. package/src/app/components/card/index.ts +2 -0
  59. package/src/app/components/card/mf-card.component.css +82 -0
  60. package/src/app/components/card/mf-card.component.ts +59 -0
  61. package/src/app/components/checkbox/index.ts +1 -0
  62. package/src/app/components/checkbox/mf-checkbox.component.css +75 -0
  63. package/src/app/components/checkbox/mf-checkbox.component.ts +187 -0
  64. package/src/app/components/chip/index.ts +2 -0
  65. package/src/app/components/chip/mf-chip.component.css +69 -0
  66. package/src/app/components/chip/mf-chip.component.spec.ts +47 -0
  67. package/src/app/components/chip/mf-chip.component.ts +77 -0
  68. package/src/app/components/datepicker/index.ts +2 -0
  69. package/src/app/components/datepicker/mf-datepicker.component.css +102 -0
  70. package/src/app/components/datepicker/mf-datepicker.component.spec.ts +69 -0
  71. package/src/app/components/datepicker/mf-datepicker.component.ts +233 -0
  72. package/src/app/components/dialog/index.ts +3 -0
  73. package/src/app/components/dialog/mf-dialog.component.css +73 -0
  74. package/src/app/components/dialog/mf-dialog.component.ts +160 -0
  75. package/src/app/components/dialog/mf-dialog.service.spec.ts +61 -0
  76. package/src/app/components/dialog/mf-dialog.service.ts +52 -0
  77. package/src/app/components/divider/index.ts +2 -0
  78. package/src/app/components/divider/mf-divider.component.css +38 -0
  79. package/src/app/components/divider/mf-divider.component.spec.ts +40 -0
  80. package/src/app/components/divider/mf-divider.component.ts +44 -0
  81. package/src/app/components/form-field/index.ts +1 -0
  82. package/src/app/components/form-field/mf-form-field.component.css +51 -0
  83. package/src/app/components/form-field/mf-form-field.component.ts +74 -0
  84. package/src/app/components/grid-list/index.ts +2 -0
  85. package/src/app/components/grid-list/mf-grid-list.component.css +47 -0
  86. package/src/app/components/grid-list/mf-grid-list.component.spec.ts +57 -0
  87. package/src/app/components/grid-list/mf-grid-list.component.ts +68 -0
  88. package/src/app/components/icon/index.ts +2 -0
  89. package/src/app/components/icon/mf-icon.component.css +56 -0
  90. package/src/app/components/icon/mf-icon.component.ts +41 -0
  91. package/src/app/components/input/index.ts +2 -0
  92. package/src/app/components/input/mf-input.component.css +105 -0
  93. package/src/app/components/input/mf-input.component.ts +217 -0
  94. package/src/app/components/menu/index.ts +2 -0
  95. package/src/app/components/menu/mf-menu.component.css +31 -0
  96. package/src/app/components/menu/mf-menu.component.spec.ts +49 -0
  97. package/src/app/components/menu/mf-menu.component.ts +66 -0
  98. package/src/app/components/paginator/index.ts +1 -0
  99. package/src/app/components/paginator/mf-paginator.component.css +32 -0
  100. package/src/app/components/paginator/mf-paginator.component.spec.ts +44 -0
  101. package/src/app/components/paginator/mf-paginator.component.ts +52 -0
  102. package/src/app/components/progress-bar/index.ts +2 -0
  103. package/src/app/components/progress-bar/mf-progress-bar.component.css +53 -0
  104. package/src/app/components/progress-bar/mf-progress-bar.component.spec.ts +65 -0
  105. package/src/app/components/progress-bar/mf-progress-bar.component.ts +79 -0
  106. package/src/app/components/progress-spinner/index.ts +2 -0
  107. package/src/app/components/progress-spinner/mf-progress-spinner.component.css +38 -0
  108. package/src/app/components/progress-spinner/mf-progress-spinner.component.spec.ts +59 -0
  109. package/src/app/components/progress-spinner/mf-progress-spinner.component.ts +81 -0
  110. package/src/app/components/radio-button/index.ts +2 -0
  111. package/src/app/components/radio-button/mf-radio-button.component.css +86 -0
  112. package/src/app/components/radio-button/mf-radio-button.component.spec.ts +55 -0
  113. package/src/app/components/radio-button/mf-radio-button.component.ts +219 -0
  114. package/src/app/components/select/index.ts +2 -0
  115. package/src/app/components/select/mf-select.component.css +121 -0
  116. package/src/app/components/select/mf-select.component.spec.ts +108 -0
  117. package/src/app/components/select/mf-select.component.ts +252 -0
  118. package/src/app/components/sidenav/index.ts +2 -0
  119. package/src/app/components/sidenav/mf-sidenav.component.css +168 -0
  120. package/src/app/components/sidenav/mf-sidenav.component.spec.ts +57 -0
  121. package/src/app/components/sidenav/mf-sidenav.component.ts +126 -0
  122. package/src/app/components/slide-toggle/index.ts +1 -0
  123. package/src/app/components/slide-toggle/mf-slide-toggle.component.css +42 -0
  124. package/src/app/components/slide-toggle/mf-slide-toggle.component.spec.ts +43 -0
  125. package/src/app/components/slide-toggle/mf-slide-toggle.component.ts +188 -0
  126. package/src/app/components/snackbar/index.ts +2 -0
  127. package/src/app/components/snackbar/mf-snackbar.service.css +31 -0
  128. package/src/app/components/snackbar/mf-snackbar.service.spec.ts +81 -0
  129. package/src/app/components/snackbar/mf-snackbar.service.ts +77 -0
  130. package/src/app/components/table/index.ts +2 -0
  131. package/src/app/components/table/mf-table.component.css +68 -0
  132. package/src/app/components/table/mf-table.component.spec.ts +76 -0
  133. package/src/app/components/table/mf-table.component.ts +117 -0
  134. package/src/app/components/tabs/index.ts +2 -0
  135. package/src/app/components/tabs/mf-tabs.component.css +31 -0
  136. package/src/app/components/tabs/mf-tabs.component.spec.ts +50 -0
  137. package/src/app/components/tabs/mf-tabs.component.ts +62 -0
  138. package/src/app/components/textarea/index.ts +2 -0
  139. package/src/app/components/textarea/mf-textarea.component.css +48 -0
  140. package/src/app/components/textarea/mf-textarea.component.spec.ts +55 -0
  141. package/src/app/components/textarea/mf-textarea.component.ts +227 -0
  142. package/src/app/components/toolbar/index.ts +2 -0
  143. package/src/app/components/toolbar/mf-toolbar.component.css +77 -0
  144. package/src/app/components/toolbar/mf-toolbar.component.ts +56 -0
  145. package/src/app/components/tooltip/index.ts +3 -0
  146. package/src/app/components/tooltip/mf-tooltip.component.css +7 -0
  147. package/src/app/components/tooltip/mf-tooltip.component.spec.ts +37 -0
  148. package/src/app/components/tooltip/mf-tooltip.component.ts +47 -0
  149. package/src/app/components/tooltip/mf-tooltip.directive.ts +22 -0
  150. package/src/index.html +18 -0
  151. package/src/main.ts +6 -0
  152. package/src/public-api.ts +31 -0
  153. package/src/stories/About.mdx +72 -0
  154. package/src/stories/Accessibility.mdx +59 -0
  155. package/src/stories/Welcome.mdx +27 -0
  156. package/src/stories/assets/accessibility.png +0 -0
  157. package/src/stories/assets/accessibility.svg +1 -0
  158. package/src/stories/assets/addon-library.png +0 -0
  159. package/src/stories/assets/assets.png +0 -0
  160. package/src/stories/assets/avif-test-image.avif +0 -0
  161. package/src/stories/assets/context.png +0 -0
  162. package/src/stories/assets/discord.svg +1 -0
  163. package/src/stories/assets/docs.png +0 -0
  164. package/src/stories/assets/figma-plugin.png +0 -0
  165. package/src/stories/assets/github.svg +1 -0
  166. package/src/stories/assets/share.png +0 -0
  167. package/src/stories/assets/styling.png +0 -0
  168. package/src/stories/assets/testing.png +0 -0
  169. package/src/stories/assets/theming.png +0 -0
  170. package/src/stories/assets/tutorials.svg +1 -0
  171. package/src/stories/assets/youtube.svg +1 -0
  172. package/src/stories/mf-a11y-contracts.stories.ts +472 -0
  173. package/src/stories/mf-autocomplete.stories.ts +188 -0
  174. package/src/stories/mf-button.stories.ts +156 -0
  175. package/src/stories/mf-card.stories.ts +148 -0
  176. package/src/stories/mf-checkbox.stories.ts +88 -0
  177. package/src/stories/mf-datepicker.stories.ts +118 -0
  178. package/src/stories/mf-dialog.stories.ts +167 -0
  179. package/src/stories/mf-form-field.stories.ts +108 -0
  180. package/src/stories/mf-grid-list.stories.ts +105 -0
  181. package/src/stories/mf-icon.stories.ts +130 -0
  182. package/src/stories/mf-input.stories.ts +158 -0
  183. package/src/stories/mf-menu.stories.ts +71 -0
  184. package/src/stories/mf-progress-bar.stories.ts +119 -0
  185. package/src/stories/mf-progress-spinner.stories.ts +124 -0
  186. package/src/stories/mf-radio-button.stories.ts +111 -0
  187. package/src/stories/mf-select.stories.ts +178 -0
  188. package/src/stories/mf-sidenav.stories.ts +334 -0
  189. package/src/stories/mf-table.stories.ts +80 -0
  190. package/src/stories/mf-toolbar.stories.ts +112 -0
  191. package/src/stories/user.ts +3 -0
  192. package/src/styles.css +58 -21
  193. package/src/theme/tokens.css +7 -4
  194. package/tsconfig.app.json +15 -0
  195. package/tsconfig.json +33 -0
  196. package/tsconfig.spec.json +15 -0
  197. package/vercel.json +6 -0
  198. package/fesm2022/ng-comps.mjs +0 -2479
  199. package/fesm2022/ng-comps.mjs.map +0 -1
  200. package/types/ng-comps.d.ts +0 -917
@@ -0,0 +1,75 @@
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
+ }
@@ -0,0 +1,187 @@
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
+ }
@@ -0,0 +1,2 @@
1
+ export { MfChipComponent } from './mf-chip.component';
2
+ export type { MfChipVariant, MfChipColor } from './mf-chip.component';
@@ -0,0 +1,69 @@
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
+ }
@@ -0,0 +1,47 @@
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
+ });
@@ -0,0 +1,77 @@
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]="'Eliminar ' + 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
+ }
@@ -0,0 +1,2 @@
1
+ export { MfDatepickerComponent } from './mf-datepicker.component';
2
+ export type { MfDatepickerSize } from './mf-datepicker.component';
@@ -0,0 +1,102 @@
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
+ }
@@ -0,0 +1,69 @@
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', 'Fecha requerida');
45
+ expect(component.hostClasses()).toContain('mf-datepicker--error');
46
+ });
47
+
48
+ it('should render label when provided', () => {
49
+ fixture.componentRef.setInput('label', 'Fecha de inicio');
50
+ fixture.detectChanges();
51
+ const label = fixture.nativeElement.querySelector('mat-label');
52
+ expect(label?.textContent).toContain('Fecha de inicio');
53
+ });
54
+
55
+ it('should render hint when provided', () => {
56
+ fixture.componentRef.setInput('hint', 'Selecciona una fecha');
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
+ });