ng-comps 0.2.0 → 1.0.1

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 +26 -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 +194 -0
  174. package/src/stories/mf-button.stories.ts +152 -0
  175. package/src/stories/mf-card.stories.ts +147 -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 +159 -0
  179. package/src/stories/mf-form-field.stories.ts +108 -0
  180. package/src/stories/mf-grid-list.stories.ts +104 -0
  181. package/src/stories/mf-icon.stories.ts +133 -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 +184 -0
  188. package/src/stories/mf-sidenav.stories.ts +331 -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,121 @@
1
+ :host {
2
+ display: inline-block;
3
+ }
4
+
5
+ /* ── Base ──────────────────────────────────────────────────────── */
6
+ .mf-select {
7
+ font-family: var(--mf-font-base) !important;
8
+ width: 100%;
9
+ }
10
+
11
+ .mf-select--full {
12
+ width: 100%;
13
+ }
14
+
15
+ /* ── Mat-form-field overrides ─────────────────────────────────── */
16
+ .mf-select .mat-mdc-text-field-wrapper {
17
+ border-radius: var(--mf-radius-md) !important;
18
+ }
19
+
20
+ .mf-select .mdc-notched-outline {
21
+ border-radius: var(--mf-radius-md) !important;
22
+ }
23
+
24
+ .mf-select .mdc-notched-outline__leading,
25
+ .mf-select .mdc-notched-outline__notch,
26
+ .mf-select .mdc-notched-outline__trailing {
27
+ border-color: var(--mf-color-border) !important;
28
+ transition: border-color var(--mf-duration-base) var(--mf-ease-standard);
29
+ }
30
+
31
+ .mf-select .mat-mdc-form-field-focus-overlay {
32
+ background-color: transparent !important;
33
+ }
34
+
35
+ /* ── Focus state ──────────────────────────────────────────────── */
36
+ .mf-select.mat-focused .mdc-notched-outline__leading,
37
+ .mf-select.mat-focused .mdc-notched-outline__notch,
38
+ .mf-select.mat-focused .mdc-notched-outline__trailing {
39
+ border-color: var(--mf-color-brand) !important;
40
+ border-width: 1.5px !important;
41
+ }
42
+
43
+ /* ── Error state ──────────────────────────────────────────────── */
44
+ .mf-select--error .mdc-notched-outline__leading,
45
+ .mf-select--error .mdc-notched-outline__notch,
46
+ .mf-select--error .mdc-notched-outline__trailing {
47
+ border-color: var(--mf-color-error-500) !important;
48
+ }
49
+
50
+ /* ── Label ────────────────────────────────────────────────────── */
51
+ .mf-select .mat-mdc-floating-label {
52
+ font-family: var(--mf-font-base) !important;
53
+ font-weight: var(--mf-weight-medium) !important;
54
+ color: var(--mf-color-neutral-400) !important;
55
+ }
56
+
57
+ .mf-select.mat-focused .mat-mdc-floating-label {
58
+ color: var(--mf-color-brand) !important;
59
+ }
60
+
61
+ /* ── Trigger text ─────────────────────────────────────────────── */
62
+ .mf-select .mat-mdc-select-trigger {
63
+ font-family: var(--mf-font-base) !important;
64
+ color: var(--mf-color-on-surface) !important;
65
+ }
66
+
67
+ .mf-select .mat-mdc-select-placeholder {
68
+ color: var(--mf-color-neutral-400) !important;
69
+ }
70
+
71
+ /* ── Arrow icon ───────────────────────────────────────────────── */
72
+ .mf-select .mat-mdc-select-arrow {
73
+ color: var(--mf-color-neutral-400) !important;
74
+ transition: color var(--mf-duration-base) var(--mf-ease-standard);
75
+ }
76
+
77
+ .mf-select.mat-focused .mat-mdc-select-arrow {
78
+ color: var(--mf-color-brand) !important;
79
+ }
80
+
81
+ /* ── Prefix / Suffix icons ────────────────────────────────────── */
82
+ .mf-select .mat-icon {
83
+ color: var(--mf-color-neutral-400) !important;
84
+ font-size: 20px;
85
+ width: 20px;
86
+ height: 20px;
87
+ transition: color var(--mf-duration-base) var(--mf-ease-standard);
88
+ }
89
+
90
+ .mf-select.mat-focused .mat-icon {
91
+ color: var(--mf-color-brand) !important;
92
+ }
93
+
94
+ /* ── Hint & Error ─────────────────────────────────────────────── */
95
+ .mf-select .mat-mdc-form-field-hint {
96
+ font-size: var(--mf-text-xs) !important;
97
+ color: var(--mf-color-neutral-400) !important;
98
+ }
99
+
100
+ .mf-select .mat-mdc-form-field-error {
101
+ font-size: var(--mf-text-xs) !important;
102
+ }
103
+
104
+ /* ── Sizes ─────────────────────────────────────────────────────── */
105
+ .mf-select--sm .mat-mdc-select-trigger {
106
+ font-size: var(--mf-text-sm) !important;
107
+ }
108
+
109
+ .mf-select--md .mat-mdc-select-trigger {
110
+ font-size: var(--mf-text-base) !important;
111
+ }
112
+
113
+ .mf-select--lg .mat-mdc-select-trigger {
114
+ font-size: var(--mf-text-lg) !important;
115
+ }
116
+
117
+ /* ── Disabled ──────────────────────────────────────────────────── */
118
+ .mf-select .mat-mdc-select-trigger[aria-disabled='true'],
119
+ .mf-select .mat-mdc-select-trigger.mat-mdc-select-disabled {
120
+ color: var(--mf-color-neutral-300) !important;
121
+ }
@@ -0,0 +1,108 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+ import { MfSelectComponent } from './mf-select.component';
3
+ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
4
+
5
+ describe('MfSelectComponent', () => {
6
+ let fixture: ComponentFixture<MfSelectComponent>;
7
+ let component: MfSelectComponent;
8
+
9
+ const testOptions = [
10
+ { value: '1', label: 'Option 1' },
11
+ { value: '2', label: 'Option 2' },
12
+ { value: '3', label: 'Option 3', disabled: true },
13
+ ];
14
+
15
+ beforeEach(async () => {
16
+ await TestBed.configureTestingModule({
17
+ imports: [MfSelectComponent, NoopAnimationsModule],
18
+ }).compileComponents();
19
+
20
+ fixture = TestBed.createComponent(MfSelectComponent);
21
+ component = fixture.componentInstance;
22
+ fixture.componentRef.setInput('options', testOptions);
23
+ fixture.detectChanges();
24
+ });
25
+
26
+ it('should create', () => {
27
+ expect(component).toBeTruthy();
28
+ });
29
+
30
+ it('should render mat-select', () => {
31
+ const select = fixture.nativeElement.querySelector('mat-select');
32
+ expect(select).toBeTruthy();
33
+ });
34
+
35
+ it('should apply md size class by default', () => {
36
+ expect(component.hostClasses()).toContain('mf-select--md');
37
+ });
38
+
39
+ it('should apply sm size class', () => {
40
+ fixture.componentRef.setInput('size', 'sm');
41
+ expect(component.hostClasses()).toContain('mf-select--sm');
42
+ });
43
+
44
+ it('should apply lg size class', () => {
45
+ fixture.componentRef.setInput('size', 'lg');
46
+ expect(component.hostClasses()).toContain('mf-select--lg');
47
+ });
48
+
49
+ it('should include mf-select--full when fullWidth is true', () => {
50
+ fixture.componentRef.setInput('fullWidth', true);
51
+ expect(component.hostClasses()).toContain('mf-select--full');
52
+ });
53
+
54
+ it('should include mf-select--error when error is provided', () => {
55
+ fixture.componentRef.setInput('error', 'Required');
56
+ expect(component.hostClasses()).toContain('mf-select--error');
57
+ });
58
+
59
+ it('should emit selection change', () => {
60
+ const spy = vi.fn();
61
+ component.mfSelectionChange.subscribe(spy);
62
+ component.onSelectionChange({ value: '2' });
63
+ expect(spy).toHaveBeenCalledWith('2');
64
+ });
65
+
66
+ it('should render label when provided', () => {
67
+ fixture.componentRef.setInput('label', 'Choose');
68
+ fixture.detectChanges();
69
+ const label = fixture.nativeElement.querySelector('mat-label');
70
+ expect(label?.textContent).toContain('Choose');
71
+ });
72
+
73
+ it('should render hint when provided', () => {
74
+ fixture.componentRef.setInput('hint', 'Pick one');
75
+ fixture.detectChanges();
76
+ const hint = fixture.nativeElement.querySelector('mat-hint');
77
+ expect(hint?.textContent).toContain('Pick one');
78
+ });
79
+
80
+ it('should render error when provided', () => {
81
+ fixture.componentRef.setInput('error', 'This field is required');
82
+ fixture.detectChanges();
83
+ expect(fixture.nativeElement.textContent).toContain('This field is required');
84
+ });
85
+
86
+ it('should include mf-select-panel in panelClasses by default', () => {
87
+ expect(component.panelClasses()).toContain('mf-select-panel');
88
+ });
89
+
90
+ it('should merge extra panelClass string into panelClasses', () => {
91
+ fixture.componentRef.setInput('panelClass', 'custom-panel');
92
+ expect(component.panelClasses()).toContain('mf-select-panel');
93
+ expect(component.panelClasses()).toContain('custom-panel');
94
+ });
95
+
96
+ it('should merge extra panelClass array into panelClasses', () => {
97
+ fixture.componentRef.setInput('panelClass', ['panel-a', 'panel-b']);
98
+ expect(component.panelClasses()).toContain('panel-a');
99
+ expect(component.panelClasses()).toContain('panel-b');
100
+ });
101
+
102
+ it('should render leading icon when provided', () => {
103
+ fixture.componentRef.setInput('leadingIcon', 'search');
104
+ fixture.detectChanges();
105
+ const icon = fixture.nativeElement.querySelector('[matprefix]');
106
+ expect(icon).toBeTruthy();
107
+ });
108
+ });
@@ -0,0 +1,252 @@
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 { ErrorStateMatcher } from '@angular/material/core';
19
+ import { MatFormFieldModule } from '@angular/material/form-field';
20
+ import { MatIconModule } from '@angular/material/icon';
21
+ import { MatSelectModule } from '@angular/material/select';
22
+ import {
23
+ createUniqueId,
24
+ hasAccessibleName,
25
+ mergeAriaIds,
26
+ warnInDev,
27
+ } from '../../a11y';
28
+
29
+ export interface MfSelectOption {
30
+ value: string | number;
31
+ label: string;
32
+ disabled?: boolean;
33
+ }
34
+
35
+ export type MfSelectSize = 'sm' | 'md' | 'lg';
36
+
37
+ /**
38
+ * Select de la librería ng-comps.
39
+ * Envuelve Angular Material `mat-select` y expone una API uniforme
40
+ * con look and feel de marca.
41
+ *
42
+ * El dropdown se estiliza mediante la clase global `mf-select-panel` que se
43
+ * inserta en el overlay. Puedes añadir clases adicionales con `panelClass`.
44
+ */
45
+ @Component({
46
+ selector: 'mf-select',
47
+ imports: [MatSelectModule, MatFormFieldModule, MatIconModule],
48
+ providers: [
49
+ {
50
+ provide: NG_VALUE_ACCESSOR,
51
+ useExisting: forwardRef(() => MfSelectComponent),
52
+ multi: true,
53
+ },
54
+ ],
55
+ template: `
56
+ <mat-form-field [appearance]="'outline'" [class]="hostClasses()">
57
+ @if (label()) {
58
+ <mat-label>{{ label() }}</mat-label>
59
+ }
60
+ @if (leadingIcon()) {
61
+ <mat-icon matPrefix aria-hidden="true">{{ leadingIcon() }}</mat-icon>
62
+ }
63
+ <mat-select
64
+ [id]="controlId()"
65
+ [value]="internalValue()"
66
+ [disabled]="isDisabled()"
67
+ [multiple]="multiple()"
68
+ [placeholder]="placeholder()"
69
+ [required]="required()"
70
+ [errorStateMatcher]="errorStateMatcher"
71
+ [panelClass]="panelClasses()"
72
+ [attr.aria-label]="resolvedAriaLabel()"
73
+ [attr.aria-labelledby]="ariaLabelledby() || null"
74
+ [attr.aria-describedby]="describedBy()"
75
+ [attr.aria-invalid]="isInvalid() ? 'true' : null"
76
+ [attr.aria-required]="required() ? 'true' : null"
77
+ (selectionChange)="onSelectionChange($event)"
78
+ >
79
+ @for (option of options(); track option.value) {
80
+ <mat-option [value]="option.value" [disabled]="option.disabled ?? false">
81
+ {{ option.label }}
82
+ </mat-option>
83
+ }
84
+ </mat-select>
85
+ @if (trailingIcon()) {
86
+ <mat-icon matSuffix aria-hidden="true">{{ trailingIcon() }}</mat-icon>
87
+ }
88
+ @if (hint()) {
89
+ <mat-hint [attr.id]="hintId()">{{ hint() }}</mat-hint>
90
+ }
91
+ </mat-form-field>
92
+ @if (error()) {
93
+ <p class="mf-select__error" [attr.id]="errorId()" role="alert">{{ error() }}</p>
94
+ }
95
+ `,
96
+ styleUrl: './mf-select.component.css',
97
+ changeDetection: ChangeDetectionStrategy.OnPush,
98
+ })
99
+ export class MfSelectComponent implements ControlValueAccessor {
100
+ private readonly cdr = inject(ChangeDetectorRef);
101
+ private readonly ngControl = inject(NgControl, { self: true, optional: true });
102
+ private readonly generatedId = createUniqueId('mf-select');
103
+ private readonly disabledFromForm = signal(false);
104
+ protected readonly internalValue = signal<
105
+ string | number | (string | number)[] | undefined
106
+ >(undefined);
107
+ private onControlChange: (
108
+ value: string | number | (string | number)[] | undefined,
109
+ ) => void = () => undefined;
110
+ private onControlTouched: () => void = () => undefined;
111
+ readonly errorStateMatcher: ErrorStateMatcher = {
112
+ isErrorState: (control) =>
113
+ Boolean(
114
+ this.error() || (control?.invalid && (control.touched || control.dirty)),
115
+ ),
116
+ };
117
+
118
+ /** Opciones del select */
119
+ readonly options = input.required<MfSelectOption[]>();
120
+ /** ID del control */
121
+ readonly id = input<string | undefined>(undefined);
122
+ /** Etiqueta flotante */
123
+ readonly label = input<string | undefined>(undefined);
124
+ /** Etiqueta accesible alternativa cuando no existe label visible */
125
+ readonly ariaLabel = input<string | undefined>(undefined);
126
+ /** Referencia externa a elementos que etiquetan el control */
127
+ readonly ariaLabelledby = input<string | undefined>(undefined);
128
+ /** Referencia externa a elementos descriptivos adicionales */
129
+ readonly ariaDescribedby = input<string | undefined>(undefined);
130
+ /** Placeholder */
131
+ readonly placeholder = input<string>('');
132
+ /** Valor actual */
133
+ readonly value = input<string | number | (string | number)[] | undefined>(
134
+ undefined,
135
+ );
136
+ /** Selección múltiple */
137
+ readonly multiple = input(false);
138
+ /** Deshabilitado */
139
+ readonly disabled = input(false);
140
+ /** Requerido */
141
+ readonly required = input(false);
142
+ /** Texto de ayuda */
143
+ readonly hint = input<string | undefined>(undefined);
144
+ /** Mensaje de error */
145
+ readonly error = input<string | undefined>(undefined);
146
+ /** Tamaño del campo */
147
+ readonly size = input<MfSelectSize>('md');
148
+ /** Ancho completo */
149
+ readonly fullWidth = input(false);
150
+ /** Icono al inicio del campo */
151
+ readonly leadingIcon = input<string | undefined>(undefined);
152
+ /** Icono al final del campo */
153
+ readonly trailingIcon = input<string | undefined>(undefined);
154
+ /**
155
+ * Clases extra que se añaden al panel del dropdown (overlay).
156
+ * La clase `mf-select-panel` siempre está presente para los estilos base.
157
+ */
158
+ readonly panelClass = input<string | string[]>('');
159
+
160
+ readonly mfSelectionChange = output<string | number | (string | number)[]>();
161
+
162
+ constructor() {
163
+ effect(() => {
164
+ this.internalValue.set(this.value());
165
+ });
166
+
167
+ effect(() => {
168
+ if (
169
+ !hasAccessibleName(
170
+ this.label(),
171
+ this.ariaLabel(),
172
+ this.ariaLabelledby(),
173
+ )
174
+ ) {
175
+ warnInDev(
176
+ 'mf-select requiere `label`, `ariaLabel` o `ariaLabelledby` para exponer un nombre accesible.',
177
+ );
178
+ }
179
+ });
180
+ }
181
+
182
+ readonly controlId = computed(() => this.id() ?? this.generatedId);
183
+ readonly hintId = computed(() =>
184
+ this.hint() ? `${this.controlId()}-hint` : null,
185
+ );
186
+ readonly errorId = computed(() =>
187
+ this.error() ? `${this.controlId()}-error` : null,
188
+ );
189
+ readonly describedBy = computed(() =>
190
+ mergeAriaIds(this.ariaDescribedby(), this.hintId(), this.errorId()),
191
+ );
192
+ readonly resolvedAriaLabel = computed(() =>
193
+ this.label() ? null : this.ariaLabel() ?? null,
194
+ );
195
+ readonly isDisabled = computed(
196
+ () => this.disabled() || this.disabledFromForm(),
197
+ );
198
+
199
+ readonly hostClasses = computed(() => {
200
+ const classes = ['mf-select', `mf-select--${this.size()}`];
201
+ if (this.fullWidth()) classes.push('mf-select--full');
202
+ if (this.error()) classes.push('mf-select--error');
203
+ return classes.join(' ');
204
+ });
205
+
206
+ readonly panelClasses = computed(() => {
207
+ const base = ['mf-select-panel'];
208
+ const extra = this.panelClass();
209
+
210
+ if (Array.isArray(extra)) {
211
+ base.push(...extra.filter(Boolean));
212
+ } else if (extra) {
213
+ base.push(extra);
214
+ }
215
+
216
+ return base;
217
+ });
218
+
219
+ writeValue(value: string | number | (string | number)[] | null): void {
220
+ this.internalValue.set(value ?? undefined);
221
+ this.cdr.markForCheck();
222
+ }
223
+
224
+ registerOnChange(
225
+ fn: (value: string | number | (string | number)[] | undefined) => void,
226
+ ): void {
227
+ this.onControlChange = fn;
228
+ }
229
+
230
+ registerOnTouched(fn: () => void): void {
231
+ this.onControlTouched = fn;
232
+ }
233
+
234
+ setDisabledState(isDisabled: boolean): void {
235
+ this.disabledFromForm.set(isDisabled);
236
+ this.cdr.markForCheck();
237
+ }
238
+
239
+ isInvalid(): boolean {
240
+ const control = this.ngControl?.control;
241
+ return Boolean(
242
+ this.error() || (control?.invalid && (control.touched || control.dirty)),
243
+ );
244
+ }
245
+
246
+ onSelectionChange(event: { value: string | number | (string | number)[] }): void {
247
+ this.internalValue.set(event.value);
248
+ this.onControlChange(event.value);
249
+ this.onControlTouched();
250
+ this.mfSelectionChange.emit(event.value);
251
+ }
252
+ }
@@ -0,0 +1,2 @@
1
+ export { MfSidenavComponent } from './mf-sidenav.component';
2
+ export type { MfSidenavMode, MfSidenavPosition, MfSidenavNavItem } from './mf-sidenav.component';
@@ -0,0 +1,168 @@
1
+ :host {
2
+ display: block;
3
+ height: 100%;
4
+ }
5
+
6
+ /* ── Container ─────────────────────────────────────────────────── */
7
+ .mf-sidenav-container {
8
+ height: 100%;
9
+ background-color: var(--mf-color-surface) !important;
10
+ }
11
+
12
+ /* ── Sidenav panel ─────────────────────────────────────────────── */
13
+ .mf-sidenav {
14
+ background-color: var(--mf-color-surface) !important;
15
+ border-right: 1px solid var(--mf-color-border) !important;
16
+ font-family: var(--mf-font-base) !important;
17
+ }
18
+
19
+ .mf-sidenav--over,
20
+ .mf-sidenav--push {
21
+ box-shadow: var(--mf-shadow-lg) !important;
22
+ }
23
+
24
+ .mf-sidenav--side {
25
+ box-shadow: none;
26
+ border-right: 1px solid var(--mf-color-border) !important;
27
+ }
28
+
29
+ /* ── Nav wrapper ───────────────────────────────────────────────── */
30
+ .mf-sidenav__nav {
31
+ display: flex;
32
+ flex-direction: column;
33
+ height: 100%;
34
+ overflow: hidden;
35
+ }
36
+
37
+ /* ── Header ────────────────────────────────────────────────────── */
38
+ .mf-sidenav__header {
39
+ display: flex;
40
+ align-items: center;
41
+ gap: var(--mf-space-2);
42
+ padding: var(--mf-space-5) var(--mf-space-4) var(--mf-space-4);
43
+ border-bottom: 1px solid var(--mf-color-border);
44
+ flex-shrink: 0;
45
+ }
46
+
47
+ .mf-sidenav__header-icon {
48
+ color: var(--mf-color-brand) !important;
49
+ font-size: 22px;
50
+ width: 22px;
51
+ height: 22px;
52
+ }
53
+
54
+ .mf-sidenav__header-title {
55
+ font-family: var(--mf-font-display) !important;
56
+ font-size: var(--mf-text-base);
57
+ font-weight: var(--mf-weight-bold);
58
+ color: var(--mf-color-on-surface);
59
+ white-space: nowrap;
60
+ overflow: hidden;
61
+ text-overflow: ellipsis;
62
+ }
63
+
64
+ /* ── Menu nav ──────────────────────────────────────────────────── */
65
+ .mf-sidenav__menu {
66
+ display: flex;
67
+ flex-direction: column;
68
+ gap: var(--mf-space-1);
69
+ padding: var(--mf-space-3) var(--mf-space-3);
70
+ flex: 1;
71
+ overflow-y: auto;
72
+ }
73
+
74
+ /* ── Nav item ──────────────────────────────────────────────────── */
75
+ .mf-sidenav__item {
76
+ display: flex;
77
+ align-items: center;
78
+ gap: var(--mf-space-3);
79
+ width: 100%;
80
+ padding: var(--mf-space-2) var(--mf-space-3);
81
+ border: none;
82
+ border-radius: var(--mf-radius-md);
83
+ background: transparent;
84
+ color: var(--mf-color-neutral-600);
85
+ font-family: var(--mf-font-base);
86
+ font-size: var(--mf-text-sm);
87
+ font-weight: var(--mf-weight-medium);
88
+ cursor: pointer;
89
+ text-align: left;
90
+ transition:
91
+ background-color var(--mf-duration-fast) var(--mf-ease-standard),
92
+ color var(--mf-duration-fast) var(--mf-ease-standard);
93
+ position: relative;
94
+ }
95
+
96
+ .mf-sidenav__item:hover:not(.mf-sidenav__item--disabled) {
97
+ background-color: var(--mf-color-neutral-100);
98
+ color: var(--mf-color-on-surface);
99
+ }
100
+
101
+ .mf-sidenav__item:hover:not(.mf-sidenav__item--disabled) .mf-sidenav__item-icon {
102
+ color: var(--mf-color-brand) !important;
103
+ }
104
+
105
+ /* Active state */
106
+ .mf-sidenav__item--active {
107
+ background-color: var(--mf-color-brand-light) !important;
108
+ color: var(--mf-color-brand) !important;
109
+ font-weight: var(--mf-weight-bold) !important;
110
+ }
111
+
112
+ .mf-sidenav__item--active .mf-sidenav__item-icon {
113
+ color: var(--mf-color-brand) !important;
114
+ }
115
+
116
+ /* Disabled state */
117
+ .mf-sidenav__item--disabled {
118
+ opacity: 0.4;
119
+ cursor: not-allowed;
120
+ }
121
+
122
+ /* ── Icon ──────────────────────────────────────────────────────── */
123
+ .mf-sidenav__item-icon {
124
+ font-size: 20px;
125
+ width: 20px;
126
+ height: 20px;
127
+ flex-shrink: 0;
128
+ color: var(--mf-color-neutral-400) !important;
129
+ transition: color var(--mf-duration-fast) var(--mf-ease-standard);
130
+ }
131
+
132
+ /* ── Label ─────────────────────────────────────────────────────── */
133
+ .mf-sidenav__item-label {
134
+ flex: 1;
135
+ white-space: nowrap;
136
+ overflow: hidden;
137
+ text-overflow: ellipsis;
138
+ }
139
+
140
+ /* ── Badge ─────────────────────────────────────────────────────── */
141
+ .mf-sidenav__item-badge {
142
+ display: inline-flex;
143
+ align-items: center;
144
+ justify-content: center;
145
+ min-width: 20px;
146
+ height: 20px;
147
+ padding: 0 var(--mf-space-1);
148
+ border-radius: var(--mf-radius-full);
149
+ background-color: var(--mf-color-brand);
150
+ color: var(--mf-color-on-brand);
151
+ font-size: 0.625rem;
152
+ font-weight: var(--mf-weight-bold);
153
+ line-height: 1;
154
+ flex-shrink: 0;
155
+ }
156
+
157
+ /* ── Main content ──────────────────────────────────────────────── */
158
+ .mf-sidenav__main {
159
+ background-color: var(--mf-color-surface);
160
+ padding: var(--mf-space-6);
161
+ font-family: var(--mf-font-base);
162
+ }
163
+
164
+ /* ── Backdrop ──────────────────────────────────────────────────── */
165
+ .mf-sidenav-container .mat-drawer-backdrop.mat-drawer-shown {
166
+ background-color: rgba(15, 23, 42, 0.32) !important;
167
+ }
168
+