sapenlinea-components 0.0.22 → 0.0.23

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/README.md CHANGED
@@ -1,63 +1,426 @@
1
- # SapenlineaComponents
1
+ # Componentes de la librería `sapenlinea-components`
2
2
 
3
- This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 20.3.0.
3
+ Esta librería incluye una colección de componentes reutilizables para formularios, tablas y filtros.
4
+ A continuación se documenta **qué hace cada componente** y **cómo se utiliza**.
4
5
 
5
- ## Code scaffolding
6
+ > Nota: todos los componentes son _standalone_ de Angular, por lo que se importan directamente en el `imports` del componente donde se usen.
6
7
 
7
- Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
8
+ ### 1. `lib-date-time-filter` (DateTimeFilter)
8
9
 
9
- ```bash
10
- ng generate component component-name
10
+ **Qué hace**
11
+ Componente para gestionar **filtros de fecha y fecha/hora** a partir de una lista de filtros configurables. Implementa `ControlValueAccessor` para integrarse con formularios reactivos.
12
+
13
+ **Selector:** `lib-date-time-filter`
14
+
15
+ **Inputs:**
16
+
17
+ - `filters: FilterItem[]` (requerido)
18
+ - Cada `FilterItem` define un filtro disponible:
19
+ - `label: string` – Texto visible en el chip/botón.
20
+ - `value: string` – Identificador interno del filtro.
21
+ - `type: 'date' | 'datetime'` – Tipo de filtro.
22
+ - `placeholder?: string` – Placeholder específico.
23
+ - `minDate?: Date` / `maxDate?: Date` – Rango permitido.
24
+
25
+ **Outputs:**
26
+
27
+ - `dateSelected: EventEmitter<DateFilterSelection>` – Emite `{ filter: string; value: Date }` con el filtro activo y la fecha seleccionada.
28
+ - `dateChange: EventEmitter<Date | null>` – Emite la fecha seleccionada al cambiar (o `null` si se limpia).
29
+
30
+ **Uso con formularios reactivos:**
31
+
32
+ ```html
33
+ <lib-date-time-filter
34
+ [filters]="dateFilters"
35
+ (dateSelected)="onDateSelected($event)"
36
+ (dateChange)="onDateChange($event)"
37
+ formControlName="fechaFiltro"
38
+ ></lib-date-time-filter>
39
+ ```
40
+
41
+ ```ts
42
+ const form = this.fb.group({
43
+ fechaFiltro: [null],
44
+ });
45
+
46
+ dateFilters: FilterItem[] = [
47
+ { label: 'Fecha inicio', value: 'startDate', type: 'date', placeholder: 'Seleccionar fecha inicio' },
48
+ { label: 'Fecha fin', value: 'endDate', type: 'date', placeholder: 'Seleccionar fecha fin' },
49
+ ];
50
+ ```
51
+
52
+ ---
53
+
54
+ ### 2. `lib-date-time-picker` (DateTimePicker)
55
+
56
+ **Qué hace**
57
+ Componente de **selector de fecha o fecha/hora** independiente (sin lista de filtros). Implementa `ControlValueAccessor`.
58
+
59
+ **Selector:** `lib-date-time-picker`
60
+
61
+ **Inputs:**
62
+
63
+ - `mode: 'date' | 'datetime' = 'date'` – Modo fecha sola o fecha + hora.
64
+ - `placeholder: string = 'Seleccionar fecha'` – Texto cuando no hay valor.
65
+ - `minDate: Date | null = null` – Fecha mínima.
66
+ - `maxDate: Date | null = null` – Fecha máxima.
67
+
68
+ **Outputs:**
69
+
70
+ - `dateChange: EventEmitter<Date | null>` – Emite la fecha seleccionada.
71
+
72
+ **Ejemplo de uso:**
73
+
74
+ ```html
75
+ <lib-date-time-picker
76
+ mode="datetime"
77
+ [minDate]="minDate"
78
+ [maxDate]="maxDate"
79
+ (dateChange)="onDateChange($event)"
80
+ formControlName="fechaEvento"
81
+ ></lib-date-time-picker>
82
+ ```
83
+
84
+ ---
85
+
86
+ ### 3. `lib-dialog-alert-component` (DialogAlertComponent)
87
+
88
+ **Qué hace**
89
+ Componente de **diálogo/modal de alerta/confirmación**, con opción de exigir una razón (select + textarea) antes de confirmar.
90
+
91
+ **Selector:** `lib-dialog-alert-component`
92
+
93
+ **Inputs:**
94
+
95
+ - `title: string = 'Mensaje'` – Título del diálogo.
96
+ - `message: string` – Mensaje principal.
97
+ - `type: 'warning' | 'error' | 'info' | 'success' = 'info'` – Tipo visual de alerta.
98
+ - `action?: string` – Acción asociada (ej. `'deactivate'`, `'delete'`, `'anulate'`, `'sancionar'`, `'active'`).
99
+ - `showReason: boolean = false` – Forzar mostrar campo de razón.
100
+ - `confirm: boolean = false` – Indica si muestra botón de confirmación principal.
101
+ - `confirmLabel: string = 'Aceptar'` – Texto del botón de confirmación.
102
+ - `reasonOptions: { label: string; value: any }[] = []` – Opciones para el campo "Razón" cuando se requiere.
103
+
104
+ **Outputs:**
105
+
106
+ - `close: EventEmitter<boolean>` – Emite `true` al confirmar y `false` al cancelar.
107
+ - `confirmReason: EventEmitter<string | undefined>` – Emite la razón seleccionada (o `undefined`).
108
+
109
+ **Ejemplo de uso:**
110
+
111
+ ```html
112
+ <lib-dialog-alert-component
113
+ [title]="'Desactivar usuario'"
114
+ [message]="'¿Está seguro que desea desactivar este usuario?'"
115
+ type="warning"
116
+ action="deactivate"
117
+ [showReason]="true"
118
+ [reasonOptions]="reasonOptions"
119
+ (close)="onClose($event)"
120
+ (confirmReason)="onConfirmReason($event)"
121
+ ></lib-dialog-alert-component>
122
+ ```
123
+
124
+ ---
125
+
126
+ ### 4. `lib-dynamic-form-fields` (DynamicFormFields)
127
+
128
+ **Qué hace**
129
+ Componente que **renderiza dinámicamente campos de formulario** a partir de una configuración (`sections` y `fields`), soportando textos, números, selects, checkboxes, radios, textarea, fechas y más. Maneja lógicas de copiado automático entre campos.
130
+
131
+ **Selector:** `lib-dynamic-form-fields`
132
+
133
+ **Inputs:**
134
+
135
+ - `form: FormGroup` (requerido) – Formulario reactivo que contiene los controles.
136
+ - `sections: SectionConfig[] = []` – Secciones y campos del formulario.
137
+ - `compact: boolean = false` – Permite estilos compactos.
138
+
139
+ **Tipos principales:**
140
+
141
+ ```ts
142
+ export interface FieldConfig {
143
+ key: string;
144
+ label?: string;
145
+ type: 'text' | 'email' | 'number' | 'date' | 'datetime-local' | 'select' | 'radio' | 'checkbox' | 'textarea' | 'disabled' | 'password' | 'time' | 'file';
146
+ placeholder?: string;
147
+ required?: boolean;
148
+ options?: { value: string | number | boolean; label: string }[];
149
+ col?: number;
150
+ disabled?: boolean;
151
+ readonly?: boolean;
152
+ matchWith?: string;
153
+ copyFrom?: string;
154
+ pattern?: string;
155
+ patternType?: 'numbers' | 'phone' | 'custom' | 'text' | 'username' | 'alphanumeric';
156
+ minDate?: Date;
157
+ maxDate?: Date;
158
+ }
159
+
160
+ export interface SectionConfig {
161
+ title?: string;
162
+ description?: string;
163
+ fields: FieldConfig[];
164
+ }
165
+ ```
166
+
167
+ **Ejemplo de uso:**
168
+
169
+ ```html
170
+ <lib-dynamic-form-fields
171
+ [form]="form"
172
+ [sections]="sections"
173
+ [compact]="true"
174
+ ></lib-dynamic-form-fields>
175
+ ```
176
+
177
+ ---
178
+
179
+ ### 5. `lib-input-text-filter` (InputTextFilter)
180
+
181
+ **Qué hace**
182
+ Componente de **filtro por texto** con chips de filtros configurables (por ejemplo, buscar por nombre, documento, etc.). Implementa `ControlValueAccessor`.
183
+
184
+ **Selector:** `lib-input-text-filter`
185
+
186
+ **Inputs:**
187
+
188
+ - `filters: FilterItem[]` (requerido) – Filtros disponibles de texto.
189
+ - `clearTrigger: number = 0` – Al incrementar este valor desde el padre se limpian todos los filtros.
190
+
191
+ **Outputs:**
192
+
193
+ - `filterSelected: EventEmitter<{ filter: string; value: string }>` – Emite el filtro y el valor aplicado.
194
+ - `valueChange: EventEmitter<string | null>` – Emite el valor actual del filtro de texto.
195
+
196
+ **Ejemplo de uso:**
197
+
198
+ ```html
199
+ <lib-input-text-filter
200
+ [filters]="textFilters"
201
+ [clearTrigger]="clearVersion"
202
+ (filterSelected)="onTextFilter($event)"
203
+ (valueChange)="onTextValueChange($event)"
204
+ ></lib-input-text-filter>
11
205
  ```
12
206
 
13
- For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
207
+ ---
14
208
 
15
- ```bash
16
- ng generate --help
209
+ ### 6. `lib-input-number-filter` (InputNumberFilter)
210
+
211
+ **Qué hace**
212
+ Componente de **filtro numérico** con múltiples chips (ej. "monto mínimo", "monto máximo"). Implementa `ControlValueAccessor`.
213
+
214
+ **Selector:** `lib-input-number-filter`
215
+
216
+ **Inputs:**
217
+
218
+ - `filters: FilterItem[]` (requerido) – Filtros numéricos.
219
+ - `clearTrigger: number = 0` – Limpia filtros al cambiar.
220
+
221
+ **Outputs:**
222
+
223
+ - `filterSelected: EventEmitter<{ filter: string; value: string }>` – Filtro seleccionado y valor.
224
+ - `valueChange: EventEmitter<string | null>` – Valor numérico aplicado.
225
+
226
+ **Ejemplo de uso:**
227
+
228
+ ```html
229
+ <lib-input-number-filter
230
+ [filters]="numberFilters"
231
+ (filterSelected)="onNumberFilter($event)"
232
+ ></lib-input-number-filter>
233
+ ```
234
+
235
+ ---
236
+
237
+ ### 7. `lib-input-select-filter` (InputSelectFilter)
238
+
239
+ **Qué hace**
240
+ Componente de **filtro basado en select** con chips. Permite seleccionar una opción por cada tipo de filtro configurado.
241
+
242
+ **Selector:** `lib-input-select-filter`
243
+
244
+ **Inputs:**
245
+
246
+ - `filters: FilterItem[]` (requerido) – Deben incluir `options` con `{ label, value }`.
247
+ - `clearTrigger: number = 0` – Limpia filtros.
248
+
249
+ **Outputs:**
250
+
251
+ - `filterSelected: EventEmitter<{ filter: string; value: string }>` – Filtro e identificador de opción seleccionada.
252
+ - `valueChange: EventEmitter<string | null>` – Valor del select actual.
253
+
254
+ **Ejemplo de uso:**
255
+
256
+ ```html
257
+ <lib-input-select-filter
258
+ [filters]="statusFilters"
259
+ (filterSelected)="onStatusFilter($event)"
260
+ ></lib-input-select-filter>
261
+ ```
262
+
263
+ ---
264
+
265
+ ### 8. `lib-select-custom-search` (SelectCustomSearch)
266
+
267
+ **Qué hace**
268
+ Componente de **select con buscador** y filtrado en tiempo real sobre las opciones. Implementa `ControlValueAccessor`.
269
+
270
+ **Selector:** `lib-select-custom-search`
271
+
272
+ **Inputs:**
273
+
274
+ - `options: { value: any; label: string }[] = []` – Opciones disponibles.
275
+ - `placeholder: string = 'Seleccionar opción'` – Texto cuando no hay selección.
276
+
277
+ **Outputs:**
278
+
279
+ - `selectionChange: EventEmitter<Option | null>` – Emite la opción seleccionada (o `null`).
280
+
281
+ **Ejemplo de uso:**
282
+
283
+ ```html
284
+ <lib-select-custom-search
285
+ [options]="userOptions"
286
+ (selectionChange)="onUserSelected($event)"
287
+ formControlName="usuarioId"
288
+ ></lib-select-custom-search>
17
289
  ```
18
290
 
19
- ## Building
291
+ ---
292
+
293
+ ### 9. `lib-pagination` (PaginationComponent)
294
+
295
+ **Qué hace**
296
+ Componente de **paginación** para tablas o listas, con opción de selector de tamaño de página.
297
+
298
+ **Selector:** `lib-pagination`
299
+
300
+ **Inputs:**
301
+
302
+ - `page: number = 1` – Página actual.
303
+ - `pageSize: number = 10` – Elementos por página (valor inicial).
304
+ - `totalItems: number = 0` – Total de elementos.
305
+ - `showPageSizeSelector: boolean = false` – Muestra/oculta el selector de tamaño de página.
306
+ - `pageSizeOptions: number[] = [5, 10, 20, 50]` – Opciones disponibles.
20
307
 
21
- To build the library, run:
308
+ **Outputs:**
22
309
 
23
- ```bash
24
- ng build sapenlinea-components
310
+ - `pageChange: EventEmitter<number>` – Emite la nueva página seleccionada.
311
+ - `pageSizeChange: EventEmitter<number>` – Emite el nuevo tamaño de página.
312
+
313
+ **Ejemplo de uso:**
314
+
315
+ ```html
316
+ <lib-pagination
317
+ [page]="currentPage"
318
+ [pageSize]="pageSize"
319
+ [totalItems]="totalItems"
320
+ [showPageSizeSelector]="true"
321
+ [pageSizeOptions]="[10, 20, 50]"
322
+ (pageChange)="onPageChange($event)"
323
+ (pageSizeChange)="onPageSizeChange($event)"
324
+ ></lib-pagination>
25
325
  ```
26
326
 
27
- This command will compile your project, and the build artifacts will be placed in the `dist/` directory.
327
+ ---
328
+
329
+ ### 10. `lib-table` (Table)
330
+
331
+ **Qué hace**
332
+ Componente de **tabla dinámica** con soporte de ordenamiento, acciones por fila y estado con tonos configurables.
333
+
334
+ **Selector:** `lib-table`
335
+
336
+ **Inputs:**
337
+
338
+ - `columns: TableColumn[]` (requerido) – Definición de columnas.
339
+ - `data: TableRow[]` (requerido) – Datos a mostrar.
340
+ - `actions: TableAction[] | ((row: TableRow) => TableAction[])` – Acciones por fila.
341
+ - `showActions: boolean = true` – Muestra/oculta columna de acciones.
342
+ - `statusToneMap: StatusToneMap` – Mapa para estilo de estados (`success`, `error`, `warning`, `info`, `neutral`).
28
343
 
29
- ### Publishing the Library
344
+ **Outputs:**
30
345
 
31
- Once the project is built, you can publish your library by following these steps:
346
+ - `optionSelected: EventEmitter<{ action: string; row: TableRow }>` Emite la acción seleccionada y la fila.
32
347
 
33
- 1. Navigate to the `dist` directory:
34
- ```bash
35
- cd dist/sapenlinea-components
36
- ```
348
+ **Ejemplo de uso:**
37
349
 
38
- 2. Run the `npm publish` command to publish your library to the npm registry:
39
- ```bash
40
- npm publish
41
- ```
350
+ ```html
351
+ <lib-table
352
+ [columns]="columns"
353
+ [data]="rows"
354
+ [actions]="rowActions"
355
+ [statusToneMap]="statusToneMap"
356
+ (optionSelected)="onTableAction($event)"
357
+ ></lib-table>
358
+ ```
359
+
360
+ ---
361
+
362
+ ### 11. `lib-modal-form` (ModalForm)
363
+
364
+ **Qué hace**
365
+ Componente de **modal genérico de formulario multi-paso**, que delega la navegación de pasos a `lib-wizard-form`.
42
366
 
43
- ## Running unit tests
367
+ **Selector:** `lib-modal-form`
44
368
 
45
- To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
369
+ **Inputs:**
46
370
 
47
- ```bash
48
- ng test
371
+ - `title: string = 'Formulario'` – Título del modal.
372
+ - `submitLabel: string = 'Guardar'` – Texto del botón de guardar.
373
+ - `form: FormGroup` – Formulario reactivo principal.
374
+ - `steps: ModalFormStep[] = []` – Pasos del formulario.
375
+
376
+ ```ts
377
+ export interface ModalFormStep {
378
+ key: string; // Nombre del subgrupo dentro de form
379
+ label: string; // Texto visible del paso
380
+ component: Type<any>; // Componente que se renderiza en ese paso
381
+ }
49
382
  ```
50
383
 
51
- ## Running end-to-end tests
384
+ **Outputs:**
385
+
386
+ - `onSubmit: EventEmitter<any>` – Emite el valor completo del formulario.
387
+ - `onCancel: EventEmitter<void>` – Emite cuando se cancela el modal.
52
388
 
53
- For end-to-end (e2e) testing, run:
389
+ **Ejemplo de uso:**
54
390
 
55
- ```bash
56
- ng e2e
391
+ ```html
392
+ <lib-modal-form
393
+ [title]="'Registro de usuario'"
394
+ [submitLabel]="'Guardar'"
395
+ [form]="form"
396
+ [steps]="steps"
397
+ (onSubmit)="onSubmit($event)"
398
+ (onCancel)="onCancel()"
399
+ ></lib-modal-form>
57
400
  ```
58
401
 
59
- Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
402
+ ---
403
+
404
+ ### 12. `lib-wizard-form` (WizardForm)
405
+
406
+ **Qué hace**
407
+ Componente que **orquesta la lógica de pasos** de un formulario tipo wizard, validando el sub-formulario del paso actual y notificando si se puede continuar.
408
+
409
+ **Selector:** `lib-wizard-form`
410
+
411
+ **Inputs:**
412
+
413
+ - `form: FormGroup` – Formulario principal que contiene subgrupos.
414
+ - `currentStep: number = 1` – Paso actual (1-based).
415
+ - `steps: ModalFormStep[] = []` – Definición de los pasos.
416
+
417
+ **Outputs:**
418
+
419
+ - `canContinue: EventEmitter<boolean>` – Emite si el grupo del paso actual es válido.
420
+
421
+ **Uso habitual (interno de `lib-modal-form`):**
422
+ No suele consumirse directamente, pero puede utilizarse si se quiere un wizard sin modal.
60
423
 
61
- ## Additional Resources
424
+ ---
62
425
 
63
- For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
426
+ Si necesitas que adapte los ejemplos a un caso concreto de tu aplicación (por ejemplo, filtros específicos o estructura de formularios), coméntame qué escenario quieres documentar y lo ajustamos.