ng-comps 1.0.0 → 1.0.2

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 (38) hide show
  1. package/angular.json +9 -8
  2. package/documentation.json +32 -32
  3. package/package.json +1 -1
  4. package/scripts/prepare-package.mjs +38 -19
  5. package/src/app/components/alert/mf-alert.component.spec.ts +2 -2
  6. package/src/app/components/alert/mf-alert.component.ts +1 -1
  7. package/src/app/components/chip/mf-chip.component.ts +1 -1
  8. package/src/app/components/datepicker/mf-datepicker.component.spec.ts +4 -4
  9. package/src/app/components/datepicker/mf-datepicker.component.ts +1 -1
  10. package/src/app/components/dialog/mf-dialog.component.ts +1 -1
  11. package/src/app/components/dialog/mf-dialog.service.spec.ts +2 -2
  12. package/src/app/components/menu/mf-menu.component.spec.ts +1 -1
  13. package/src/app/components/menu/mf-menu.component.ts +1 -1
  14. package/src/app/components/progress-bar/mf-progress-bar.component.spec.ts +2 -2
  15. package/src/app/components/progress-spinner/mf-progress-spinner.component.spec.ts +3 -3
  16. package/src/app/components/sidenav/mf-sidenav.component.ts +2 -2
  17. package/src/app/components/table/mf-table.component.ts +1 -1
  18. package/src/stories/About.mdx +72 -72
  19. package/src/stories/Welcome.mdx +26 -27
  20. package/src/stories/mf-a11y-contracts.stories.ts +49 -49
  21. package/src/stories/mf-autocomplete.stories.ts +194 -188
  22. package/src/stories/mf-button.stories.ts +152 -156
  23. package/src/stories/mf-card.stories.ts +147 -148
  24. package/src/stories/mf-checkbox.stories.ts +88 -88
  25. package/src/stories/mf-datepicker.stories.ts +118 -118
  26. package/src/stories/mf-dialog.stories.ts +159 -167
  27. package/src/stories/mf-form-field.stories.ts +108 -108
  28. package/src/stories/mf-grid-list.stories.ts +104 -105
  29. package/src/stories/mf-icon.stories.ts +133 -130
  30. package/src/stories/mf-input.stories.ts +158 -158
  31. package/src/stories/mf-menu.stories.ts +10 -10
  32. package/src/stories/mf-progress-bar.stories.ts +119 -119
  33. package/src/stories/mf-progress-spinner.stories.ts +124 -124
  34. package/src/stories/mf-radio-button.stories.ts +111 -111
  35. package/src/stories/mf-select.stories.ts +184 -178
  36. package/src/stories/mf-sidenav.stories.ts +331 -334
  37. package/src/stories/mf-table.stories.ts +13 -13
  38. package/src/stories/mf-toolbar.stories.ts +112 -112
@@ -1,178 +1,184 @@
1
- import type { Meta, StoryObj } from '@storybook/angular';
2
-
3
- import { MfSelectComponent } from '../app/components/select';
4
-
5
- const SAMPLE_OPTIONS = [
6
- { value: 'angular', label: 'Angular' },
7
- { value: 'react', label: 'React' },
8
- { value: 'vue', label: 'Vue' },
9
- { value: 'svelte', label: 'Svelte' },
10
- { value: 'solid', label: 'SolidJS', disabled: true },
11
- ];
12
-
13
- const meta: Meta<MfSelectComponent> = {
14
- title: 'Atoms/MfSelect',
15
- component: MfSelectComponent,
16
- tags: ['autodocs'],
17
- parameters: {
18
- docs: {
19
- description: {
20
- component: `
21
- **MfSelect** es el selector desplegable de la librería ng-comps.
22
- Usa Angular Material \`mat-select\` por debajo pero expone una API uniforme con look and feel de marca.
23
-
24
- El panel del dropdown se estiliza a través de la clase global \`mf-select-panel\`. Puedes inyectar clases adicionales con la propiedad \`panelClass\` para personalizar el dropdown a nivel de historia o componente.
25
-
26
- | Propiedad | Descripción |
27
- |----------------|-----------------------------------------------------|
28
- | \`options\` | Array de opciones \`{ value, label, disabled? }\` |
29
- | \`label\` | Etiqueta flotante del campo |
30
- | \`placeholder\` | Texto de placeholder |
31
- | \`hint\` | Texto de ayuda debajo del campo |
32
- | \`error\` | Mensaje de error |
33
- | \`multiple\` | Selección múltiple |
34
- | \`leadingIcon\` | Icono Material al inicio |
35
- | \`trailingIcon\` | Icono Material al final |
36
- | \`panelClass\` | Clases extra para el panel dropdown |
37
- `,
38
- },
39
- },
40
- },
41
- argTypes: {
42
- label: { control: 'text', description: 'Etiqueta flotante' },
43
- placeholder: { control: 'text', description: 'Placeholder' },
44
- size: {
45
- control: 'select',
46
- options: ['sm', 'md', 'lg'],
47
- description: 'Tamaño del campo',
48
- },
49
- multiple: { control: 'boolean', description: 'Selección múltiple' },
50
- disabled: { control: 'boolean' },
51
- hint: { control: 'text', description: 'Texto de ayuda' },
52
- error: { control: 'text', description: 'Mensaje de error' },
53
- leadingIcon: { control: 'text', description: 'Icono al inicio (nombre Material)' },
54
- trailingIcon: { control: 'text', description: 'Icono al final (nombre Material)' },
55
- fullWidth: { control: 'boolean', description: 'Ancho completo' },
56
- mfSelectionChange: { action: 'mfSelectionChange' },
57
- },
58
- };
59
-
60
- export default meta;
61
- type Story = StoryObj<MfSelectComponent>;
62
-
63
- export const Default: Story = {
64
- args: {
65
- options: SAMPLE_OPTIONS,
66
- label: 'Framework',
67
- placeholder: 'Selecciona un framework',
68
- },
69
- };
70
-
71
- export const WithHint: Story = {
72
- name: 'Con texto de ayuda',
73
- args: {
74
- options: SAMPLE_OPTIONS,
75
- label: 'Framework',
76
- hint: 'Elige el framework principal de tu proyecto',
77
- },
78
- };
79
-
80
- export const WithError: Story = {
81
- name: 'Con error',
82
- args: {
83
- options: SAMPLE_OPTIONS,
84
- label: 'Framework',
85
- error: 'Este campo es obligatorio',
86
- },
87
- };
88
-
89
- export const Multiple: Story = {
90
- name: 'Selección múltiple',
91
- args: {
92
- options: SAMPLE_OPTIONS,
93
- label: 'Frameworks',
94
- multiple: true,
95
- placeholder: 'Selecciona uno o más',
96
- },
97
- };
98
-
99
- export const WithLeadingIcon: Story = {
100
- name: 'Con icono al inicio',
101
- args: {
102
- options: SAMPLE_OPTIONS,
103
- label: 'Framework',
104
- leadingIcon: 'code',
105
- },
106
- };
107
-
108
- export const Disabled: Story = {
109
- args: {
110
- options: SAMPLE_OPTIONS,
111
- label: 'Framework (deshabilitado)',
112
- value: 'angular',
113
- disabled: true,
114
- },
115
- };
116
-
117
- export const Small: Story = {
118
- args: {
119
- options: SAMPLE_OPTIONS,
120
- label: 'Pequeño',
121
- size: 'sm',
122
- },
123
- };
124
-
125
- export const Large: Story = {
126
- args: {
127
- options: SAMPLE_OPTIONS,
128
- label: 'Grande',
129
- size: 'lg',
130
- },
131
- };
132
-
133
- export const FullWidth: Story = {
134
- name: 'Ancho completo',
135
- args: {
136
- options: SAMPLE_OPTIONS,
137
- label: 'Framework',
138
- fullWidth: true,
139
- },
140
- parameters: {
141
- layout: 'padded',
142
- },
143
- };
144
-
145
- export const CustomPanelClass: Story = {
146
- name: 'Panel con clase personalizada',
147
- args: {
148
- options: SAMPLE_OPTIONS,
149
- label: 'Framework',
150
- panelClass: 'mi-panel-personalizado',
151
- },
152
- parameters: {
153
- docs: {
154
- description: {
155
- story:
156
- 'Mediante `panelClass` puedes añadir clases CSS al panel del dropdown para aplicar estilos propios.',
157
- },
158
- },
159
- },
160
- };
161
-
162
- export const AllVariants: Story = {
163
- name: 'Todas las variantes',
164
- render: () => ({
165
- template: `
166
- <div style="display: flex; flex-direction: column; gap: 16px; max-width: 360px;">
167
- <mf-select [options]="opts" label="Normal" placeholder="Selecciona..." />
168
- <mf-select [options]="opts" label="Con ayuda" hint="Elige tu framework favorito" />
169
- <mf-select [options]="opts" label="Con error" error="Este campo es obligatorio" />
170
- <mf-select [options]="opts" label="Con icono" leadingIcon="code" />
171
- <mf-select [options]="opts" label="Deshabilitado" value="angular" [disabled]="true" />
172
- <mf-select [options]="opts" label="Múltiple" [multiple]="true" />
173
- </div>
174
- `,
175
- props: { opts: SAMPLE_OPTIONS },
176
- moduleMetadata: { imports: [MfSelectComponent] },
177
- }),
178
- };
1
+ import type { Meta, StoryObj } from '@storybook/angular';
2
+
3
+ import { MfSelectComponent } from '../app/components/select';
4
+
5
+ const SAMPLE_OPTIONS = [
6
+ { value: 'angular', label: 'Angular' },
7
+ { value: 'react', label: 'React' },
8
+ { value: 'vue', label: 'Vue' },
9
+ { value: 'svelte', label: 'Svelte' },
10
+ { value: 'solid', label: 'SolidJS', disabled: true },
11
+ ];
12
+
13
+ const meta: Meta<MfSelectComponent> = {
14
+ title: 'Atoms/MfSelect',
15
+ component: MfSelectComponent,
16
+ tags: ['autodocs'],
17
+ parameters: {
18
+ docs: {
19
+ description: {
20
+ component: `
21
+ **MfSelect** is the dropdown select component from the ng-comps library.
22
+ It uses Angular Material \`mat-select\` under the hood while exposing a consistent branded API.
23
+
24
+ The dropdown panel is styled through the global \`mf-select-panel\` class. You can inject additional classes with the \`panelClass\` property to customize the panel at the story or component level.
25
+
26
+ | Property | Description |
27
+ |-----------------|-------------------------------------------------|
28
+ | \`options\` | Array of options \`{ value, label, disabled? }\` |
29
+ | \`label\` | Floating field label |
30
+ | \`placeholder\` | Placeholder text |
31
+ | \`hint\` | Helper text shown below the field |
32
+ | \`error\` | Error message |
33
+ | \`multiple\` | Multiple selection |
34
+ | \`leadingIcon\` | Material icon shown at the start |
35
+ | \`trailingIcon\` | Material icon shown at the end |
36
+ | \`panelClass\` | Extra classes for the dropdown panel |
37
+ `,
38
+ },
39
+ },
40
+ },
41
+ argTypes: {
42
+ label: { control: 'text', description: 'Floating label' },
43
+ placeholder: { control: 'text', description: 'Placeholder' },
44
+ size: {
45
+ control: 'select',
46
+ options: ['sm', 'md', 'lg'],
47
+ description: 'Field size',
48
+ },
49
+ multiple: { control: 'boolean', description: 'Multiple selection' },
50
+ disabled: { control: 'boolean' },
51
+ hint: { control: 'text', description: 'Helper text' },
52
+ error: { control: 'text', description: 'Error message' },
53
+ leadingIcon: {
54
+ control: 'text',
55
+ description: 'Leading icon (Material icon name)',
56
+ },
57
+ trailingIcon: {
58
+ control: 'text',
59
+ description: 'Trailing icon (Material icon name)',
60
+ },
61
+ fullWidth: { control: 'boolean', description: 'Full width' },
62
+ mfSelectionChange: { action: 'mfSelectionChange' },
63
+ },
64
+ };
65
+
66
+ export default meta;
67
+ type Story = StoryObj<MfSelectComponent>;
68
+
69
+ export const Default: Story = {
70
+ args: {
71
+ options: SAMPLE_OPTIONS,
72
+ label: 'Framework',
73
+ placeholder: 'Select a framework',
74
+ },
75
+ };
76
+
77
+ export const WithHint: Story = {
78
+ name: 'With helper text',
79
+ args: {
80
+ options: SAMPLE_OPTIONS,
81
+ label: 'Framework',
82
+ hint: 'Choose the main framework for your project',
83
+ },
84
+ };
85
+
86
+ export const WithError: Story = {
87
+ name: 'With error',
88
+ args: {
89
+ options: SAMPLE_OPTIONS,
90
+ label: 'Framework',
91
+ error: 'This field is required',
92
+ },
93
+ };
94
+
95
+ export const Multiple: Story = {
96
+ name: 'Multiple selection',
97
+ args: {
98
+ options: SAMPLE_OPTIONS,
99
+ label: 'Frameworks',
100
+ multiple: true,
101
+ placeholder: 'Select one or more',
102
+ },
103
+ };
104
+
105
+ export const WithLeadingIcon: Story = {
106
+ name: 'With leading icon',
107
+ args: {
108
+ options: SAMPLE_OPTIONS,
109
+ label: 'Framework',
110
+ leadingIcon: 'code',
111
+ },
112
+ };
113
+
114
+ export const Disabled: Story = {
115
+ args: {
116
+ options: SAMPLE_OPTIONS,
117
+ label: 'Framework (disabled)',
118
+ value: 'angular',
119
+ disabled: true,
120
+ },
121
+ };
122
+
123
+ export const Small: Story = {
124
+ args: {
125
+ options: SAMPLE_OPTIONS,
126
+ label: 'Small',
127
+ size: 'sm',
128
+ },
129
+ };
130
+
131
+ export const Large: Story = {
132
+ args: {
133
+ options: SAMPLE_OPTIONS,
134
+ label: 'Large',
135
+ size: 'lg',
136
+ },
137
+ };
138
+
139
+ export const FullWidth: Story = {
140
+ name: 'Full width',
141
+ args: {
142
+ options: SAMPLE_OPTIONS,
143
+ label: 'Framework',
144
+ fullWidth: true,
145
+ },
146
+ parameters: {
147
+ layout: 'padded',
148
+ },
149
+ };
150
+
151
+ export const CustomPanelClass: Story = {
152
+ name: 'Panel with custom class',
153
+ args: {
154
+ options: SAMPLE_OPTIONS,
155
+ label: 'Framework',
156
+ panelClass: 'my-custom-panel',
157
+ },
158
+ parameters: {
159
+ docs: {
160
+ description: {
161
+ story:
162
+ 'Use `panelClass` to add CSS classes to the dropdown panel and apply custom styling.',
163
+ },
164
+ },
165
+ },
166
+ };
167
+
168
+ export const AllVariants: Story = {
169
+ name: 'All variants',
170
+ render: () => ({
171
+ template: `
172
+ <div style="display: flex; flex-direction: column; gap: 16px; max-width: 360px;">
173
+ <mf-select [options]="opts" label="Default" placeholder="Select..." />
174
+ <mf-select [options]="opts" label="With help" hint="Choose your favorite framework" />
175
+ <mf-select [options]="opts" label="With error" error="This field is required" />
176
+ <mf-select [options]="opts" label="With icon" leadingIcon="code" />
177
+ <mf-select [options]="opts" label="Disabled" value="angular" [disabled]="true" />
178
+ <mf-select [options]="opts" label="Multiple" [multiple]="true" />
179
+ </div>
180
+ `,
181
+ props: { opts: SAMPLE_OPTIONS },
182
+ moduleMetadata: { imports: [MfSelectComponent] },
183
+ }),
184
+ };