corekit-ui 0.1.12 → 0.1.14
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 +16 -0
- package/dist/index.d.ts +115 -381
- package/dist/index.js +3351 -3344
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +6 -6
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +24 -27
package/README.md
CHANGED
|
@@ -16,6 +16,22 @@
|
|
|
16
16
|
|
|
17
17
|
---
|
|
18
18
|
|
|
19
|
+
## 📦 Instalación Rápida
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install corekit-ui
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**⚠️ IMPORTANTE**: Los estilos NO se importan automáticamente. Debes agregar esto en tu archivo principal:
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import 'corekit-ui/styles.css'; // ✅ Obligatorio
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
📖 **[Ver Guía Completa de Instalación →](./INSTALLATION.md)**
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
19
35
|
## Características
|
|
20
36
|
|
|
21
37
|
- ⚡ **Vite** + **pnpm** → desarrollo y builds rápidos.
|
package/dist/index.d.ts
CHANGED
|
@@ -48,30 +48,6 @@ declare type ActualizarTablaConfig = {
|
|
|
48
48
|
onClick: () => void;
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
/**
|
|
52
|
-
* Aplana opciones agrupadas a una lista lineal con metadatos
|
|
53
|
-
* @template T - Tipo de las opciones
|
|
54
|
-
* @param opcionesAgrupadas - Lista de grupos de opciones
|
|
55
|
-
* @returns Lista plana con encabezados de grupo y opciones
|
|
56
|
-
*
|
|
57
|
-
* @example
|
|
58
|
-
* ```ts
|
|
59
|
-
* const grupos = [
|
|
60
|
-
* { grupo: 'Frutas', opciones: ['Manzana', 'Pera'] },
|
|
61
|
-
* { grupo: 'Verduras', opciones: ['Zanahoria'] }
|
|
62
|
-
* ];
|
|
63
|
-
* aplanarOpcionesAgrupadas(grupos)
|
|
64
|
-
* // [
|
|
65
|
-
* // { tipo: 'grupo', datos: null, nombreGrupo: 'Frutas', indice: 0 },
|
|
66
|
-
* // { tipo: 'opcion', datos: 'Manzana', indice: 1 },
|
|
67
|
-
* // { tipo: 'opcion', datos: 'Pera', indice: 2 },
|
|
68
|
-
* // { tipo: 'grupo', datos: null, nombreGrupo: 'Verduras', indice: 3 },
|
|
69
|
-
* // { tipo: 'opcion', datos: 'Zanahoria', indice: 4 }
|
|
70
|
-
* // ]
|
|
71
|
-
* ```
|
|
72
|
-
*/
|
|
73
|
-
export declare function aplanarOpcionesAgrupadas<T>(opcionesAgrupadas: OpcionGrupo<T>[]): OpcionPlana<T>[];
|
|
74
|
-
|
|
75
51
|
export declare const Badge: default_2.FC<BadgeProps>;
|
|
76
52
|
|
|
77
53
|
export declare type BadgeColor = 'default' | 'primary' | 'secondary' | 'success' | 'warning' | 'danger' | 'info' | 'brand';
|
|
@@ -148,10 +124,7 @@ export declare function BadgeVoz({ tipo, texto, size, estirar, }: {
|
|
|
148
124
|
estirar?: boolean;
|
|
149
125
|
}): JSX.Element;
|
|
150
126
|
|
|
151
|
-
/**
|
|
152
|
-
* Props base que comparten todos los modos del Select.
|
|
153
|
-
* Excluye las props que cambian según el tipo de dato.
|
|
154
|
-
*/
|
|
127
|
+
/** Props base compartidas por todos los modos del Select */
|
|
155
128
|
declare type BaseSelectProps<T> = Omit<SelectProps<T>, 'options' | 'value' | 'onChange' | 'optionValueKey' | 'optionLabelKey'>;
|
|
156
129
|
|
|
157
130
|
export declare const Boton: ({ variant, color, size, radius, fullWidth, isLoading, onlyLoading, isDisabled, isIconOnly, disableRipple, disableAnimation, customColor, spinner, spinnerPlacement, children, className, onClick, style, type, "aria-label": ariaLabel, ...props }: BotonProps) => JSX.Element;
|
|
@@ -433,55 +406,6 @@ export declare type DrawerProps = {
|
|
|
433
406
|
*/
|
|
434
407
|
export declare type DrawerSize = 'sm' | 'md' | 'lg' | 'xl' | 'full';
|
|
435
408
|
|
|
436
|
-
/**
|
|
437
|
-
* Verifica si las opciones están agrupadas
|
|
438
|
-
* @template T - Tipo de las opciones
|
|
439
|
-
* @param opciones - Lista de opciones
|
|
440
|
-
* @returns true si las opciones tienen estructura de grupo
|
|
441
|
-
*
|
|
442
|
-
* @example
|
|
443
|
-
* ```ts
|
|
444
|
-
* esOpcionesAgrupadas([{ grupo: 'Frutas', opciones: ['Manzana'] }]) // true
|
|
445
|
-
* esOpcionesAgrupadas(['Manzana', 'Pera']) // false
|
|
446
|
-
* ```
|
|
447
|
-
*/
|
|
448
|
-
export declare function esOpcionesAgrupadas<T>(opciones: (T | OpcionGrupo<T>)[]): opciones is OpcionGrupo<T>[];
|
|
449
|
-
|
|
450
|
-
/**
|
|
451
|
-
* Verifica si una opción está deshabilitada
|
|
452
|
-
* @template T - Tipo de la opción
|
|
453
|
-
* @param opcion - La opción a verificar
|
|
454
|
-
* @returns true si la opción tiene disabled: true
|
|
455
|
-
*
|
|
456
|
-
* @example
|
|
457
|
-
* ```ts
|
|
458
|
-
* estaDeshabilitada({ label: 'Opción', disabled: true }) // true
|
|
459
|
-
* estaDeshabilitada({ label: 'Opción' }) // false
|
|
460
|
-
* estaDeshabilitada('Texto simple') // false
|
|
461
|
-
* ```
|
|
462
|
-
*/
|
|
463
|
-
export declare function estaDeshabilitada<T>(opcion: T): boolean;
|
|
464
|
-
|
|
465
|
-
/**
|
|
466
|
-
* Verifica si una opción está seleccionada
|
|
467
|
-
* @template T - Tipo de la opción
|
|
468
|
-
* @param opcion - La opción a verificar
|
|
469
|
-
* @param valorActual - El valor actual (puede ser single o array para multi)
|
|
470
|
-
* @param esMultiple - Si el select permite múltiple selección
|
|
471
|
-
* @param claveValor - Campo a usar para comparación
|
|
472
|
-
* @returns true si la opción está seleccionada
|
|
473
|
-
*
|
|
474
|
-
* @example
|
|
475
|
-
* ```ts
|
|
476
|
-
* // Selección simple
|
|
477
|
-
* estaSeleccionada('Manzana', 'Manzana', false, 'id') // true
|
|
478
|
-
*
|
|
479
|
-
* // Selección múltiple
|
|
480
|
-
* estaSeleccionada('Manzana', ['Manzana', 'Pera'], true, 'id') // true
|
|
481
|
-
* ```
|
|
482
|
-
*/
|
|
483
|
-
export declare function estaSeleccionada<T>(opcion: T, valorActual: T | T[] | null, esMultiple: boolean, claveValor: string): boolean;
|
|
484
|
-
|
|
485
409
|
/**
|
|
486
410
|
* Valida si una fecha está dentro de un rango
|
|
487
411
|
* @param fecha - Fecha a validar (YYYY-MM-DD)
|
|
@@ -491,44 +415,6 @@ export declare function estaSeleccionada<T>(opcion: T, valorActual: T | T[] | nu
|
|
|
491
415
|
*/
|
|
492
416
|
export declare function fechaEnRango(fecha: string, min?: string, max?: string): boolean;
|
|
493
417
|
|
|
494
|
-
/**
|
|
495
|
-
* Filtra las opciones según el texto de búsqueda
|
|
496
|
-
* @template T - Tipo de las opciones
|
|
497
|
-
* @param opciones - Lista de opciones a filtrar
|
|
498
|
-
* @param textoBusqueda - Texto a buscar
|
|
499
|
-
* @param claveLabel - Campo a usar para la búsqueda
|
|
500
|
-
* @param funcionFiltro - Función de filtro personalizada (opcional)
|
|
501
|
-
* @returns Lista de opciones filtradas
|
|
502
|
-
*
|
|
503
|
-
* @example
|
|
504
|
-
* ```ts
|
|
505
|
-
* const frutas = ['Manzana', 'Mandarina', 'Pera'];
|
|
506
|
-
* filtrarOpciones(frutas, 'man', 'label') // ['Manzana', 'Mandarina']
|
|
507
|
-
* ```
|
|
508
|
-
*/
|
|
509
|
-
export declare function filtrarOpciones<T>(opciones: T[], textoBusqueda: string, claveLabel: string, funcionFiltro?: (opcion: T, busqueda: string) => boolean): T[];
|
|
510
|
-
|
|
511
|
-
/**
|
|
512
|
-
* Filtra opciones agrupadas manteniendo la estructura de grupos
|
|
513
|
-
* @template T - Tipo de las opciones
|
|
514
|
-
* @param grupos - Lista de grupos de opciones
|
|
515
|
-
* @param textoBusqueda - Texto a buscar
|
|
516
|
-
* @param claveLabel - Campo a usar para la búsqueda
|
|
517
|
-
* @param funcionFiltro - Función de filtro personalizada (opcional)
|
|
518
|
-
* @returns Grupos filtrados (elimina grupos vacíos)
|
|
519
|
-
*
|
|
520
|
-
* @example
|
|
521
|
-
* ```ts
|
|
522
|
-
* const grupos = [
|
|
523
|
-
* { grupo: 'Frutas', opciones: ['Manzana', 'Pera'] },
|
|
524
|
-
* { grupo: 'Verduras', opciones: ['Zanahoria'] }
|
|
525
|
-
* ];
|
|
526
|
-
* filtrarOpcionesAgrupadas(grupos, 'man', 'label')
|
|
527
|
-
* // [{ grupo: 'Frutas', opciones: ['Manzana'] }]
|
|
528
|
-
* ```
|
|
529
|
-
*/
|
|
530
|
-
export declare function filtrarOpcionesAgrupadas<T>(grupos: OpcionGrupo<T>[], textoBusqueda: string, claveLabel: string, funcionFiltro?: (opcion: T, busqueda: string) => boolean): OpcionGrupo<T>[];
|
|
531
|
-
|
|
532
418
|
declare type FiltrosAplicadosType = {
|
|
533
419
|
/** Nombre del filtro aplicado */
|
|
534
420
|
nombre: string;
|
|
@@ -2051,42 +1937,6 @@ declare type NativeTextareaProps = Omit<TextareaHTMLAttributes<HTMLTextAreaEleme
|
|
|
2051
1937
|
*/
|
|
2052
1938
|
export declare function obtenerFechaHoy(): string;
|
|
2053
1939
|
|
|
2054
|
-
/**
|
|
2055
|
-
* Obtiene el label de una opción
|
|
2056
|
-
* @template T - Tipo de la opción
|
|
2057
|
-
* @param opcion - La opción de la cual extraer el label
|
|
2058
|
-
* @param claveLabel - Campo del objeto a usar como label
|
|
2059
|
-
* @returns El texto del label
|
|
2060
|
-
*
|
|
2061
|
-
* @example
|
|
2062
|
-
* ```ts
|
|
2063
|
-
* // Con string
|
|
2064
|
-
* obtenerLabelOpcion('Manzana', 'label') // 'Manzana'
|
|
2065
|
-
*
|
|
2066
|
-
* // Con objeto
|
|
2067
|
-
* obtenerLabelOpcion({ nombre: 'Colombia', id: 'co' }, 'nombre') // 'Colombia'
|
|
2068
|
-
* ```
|
|
2069
|
-
*/
|
|
2070
|
-
export declare function obtenerLabelOpcion<T>(opcion: T, claveLabel: string): string;
|
|
2071
|
-
|
|
2072
|
-
/**
|
|
2073
|
-
* Obtiene el valor único de una opción
|
|
2074
|
-
* @template T - Tipo de la opción
|
|
2075
|
-
* @param opcion - La opción de la cual extraer el valor
|
|
2076
|
-
* @param claveValor - Campo del objeto a usar como valor
|
|
2077
|
-
* @returns El valor único de la opción
|
|
2078
|
-
*
|
|
2079
|
-
* @example
|
|
2080
|
-
* ```ts
|
|
2081
|
-
* // Con string
|
|
2082
|
-
* obtenerValorOpcion('Manzana', 'id') // 'Manzana'
|
|
2083
|
-
*
|
|
2084
|
-
* // Con objeto
|
|
2085
|
-
* obtenerValorOpcion({ nombre: 'Colombia', id: 'co' }, 'id') // 'co'
|
|
2086
|
-
* ```
|
|
2087
|
-
*/
|
|
2088
|
-
export declare function obtenerValorOpcion<T>(opcion: T, claveValor: string): string;
|
|
2089
|
-
|
|
2090
1940
|
/**
|
|
2091
1941
|
* @fileoverview Funciones utilitarias para el componente Select
|
|
2092
1942
|
* @module Select/funciones
|
|
@@ -2115,6 +1965,12 @@ export declare type OpcionPlana<T> = {
|
|
|
2115
1965
|
indice: number;
|
|
2116
1966
|
};
|
|
2117
1967
|
|
|
1968
|
+
/**
|
|
1969
|
+
* Tipo auxiliar para opciones primitivas u objetos.
|
|
1970
|
+
* Usado como constraint para el genérico T en RadioGroupProps.
|
|
1971
|
+
*/
|
|
1972
|
+
export declare type OptionBase = string | number | Record<string, unknown>;
|
|
1973
|
+
|
|
2118
1974
|
export declare const PanelFiltros: ({ abierto, al_cerrar, al_aplicar, al_limpiar, titulo, backdropVariant, closeOnBackdropClick, allowBackdropInteraction, getContainer, children, }: PanelFiltrosProps) => JSX.Element | null;
|
|
2119
1975
|
|
|
2120
1976
|
export declare type PanelFiltrosProps = {
|
|
@@ -2216,23 +2072,36 @@ export declare const Radio: default_2.NamedExoticComponent<{
|
|
|
2216
2072
|
|
|
2217
2073
|
export declare type RadioColor = 'primary' | 'secondary' | 'success' | 'warning' | 'danger';
|
|
2218
2074
|
|
|
2219
|
-
|
|
2075
|
+
/**
|
|
2076
|
+
* Componente RadioGroup genérico con soporte para opciones tipadas.
|
|
2077
|
+
* La coma <T,> es necesaria en arrow functions .tsx para que no se confunda con un tag HTML.
|
|
2078
|
+
*
|
|
2079
|
+
* @template T - Tipo de las opciones (string, number u objeto)
|
|
2080
|
+
*/
|
|
2081
|
+
export declare const RadioGroup: {
|
|
2082
|
+
<T extends OptionBase>({ name, value, defaultValue, onChange, orientation, label, description, isDisabled, isReadOnly, isRequired, isInvalid, errorMessage, size, color, customColor, variant, justifyContent, children, className, options, optionValueKey, optionLabelKey, optionDisabledKey, optionDescriptionKey, }: RadioGroupProps<T>): JSX.Element;
|
|
2083
|
+
displayName: string;
|
|
2084
|
+
};
|
|
2220
2085
|
|
|
2221
2086
|
export declare type RadioGroupOrientation = 'vertical' | 'horizontal';
|
|
2222
2087
|
|
|
2223
|
-
|
|
2088
|
+
/**
|
|
2089
|
+
* Props del componente RadioGroup con soporte genérico.
|
|
2090
|
+
* @template T - Tipo de las opciones (string, number u objeto)
|
|
2091
|
+
*/
|
|
2092
|
+
export declare type RadioGroupProps<T extends OptionBase = string> = {
|
|
2224
2093
|
/**
|
|
2225
2094
|
* Nombre del grupo (crítico para HTML)
|
|
2226
2095
|
*/
|
|
2227
|
-
name
|
|
2096
|
+
name?: string;
|
|
2228
2097
|
/**
|
|
2229
2098
|
* Valor seleccionado actual (modo controlado)
|
|
2230
2099
|
*/
|
|
2231
|
-
value?: string;
|
|
2100
|
+
value?: string | number;
|
|
2232
2101
|
/**
|
|
2233
2102
|
* Valor por defecto (modo no controlado)
|
|
2234
2103
|
*/
|
|
2235
|
-
defaultValue?: string;
|
|
2104
|
+
defaultValue?: string | number;
|
|
2236
2105
|
/**
|
|
2237
2106
|
* Callback cuando cambia la selección
|
|
2238
2107
|
*/
|
|
@@ -2291,15 +2160,44 @@ export declare type RadioGroupProps = {
|
|
|
2291
2160
|
* Alineación de los radios (horizontal)
|
|
2292
2161
|
* @default 'flex-start'
|
|
2293
2162
|
*/
|
|
2294
|
-
justifyContent?: 'flex-start' | 'center' | 'flex-end';
|
|
2163
|
+
justifyContent?: 'flex-start' | 'center' | 'flex-end' | 'space-between';
|
|
2295
2164
|
/**
|
|
2296
|
-
* Children (Radio components)
|
|
2165
|
+
* Children (Radio components) - Usado como fallback si no se pasa options
|
|
2297
2166
|
*/
|
|
2298
|
-
children
|
|
2167
|
+
children?: default_2.ReactNode;
|
|
2299
2168
|
/**
|
|
2300
2169
|
* Clase CSS adicional
|
|
2301
2170
|
*/
|
|
2302
2171
|
className?: string;
|
|
2172
|
+
/**
|
|
2173
|
+
* Array de opciones. Puede ser strings, números u objetos.
|
|
2174
|
+
* Si se pasa options, se ignora children.
|
|
2175
|
+
*/
|
|
2176
|
+
options?: T[];
|
|
2177
|
+
/**
|
|
2178
|
+
* Nombre de la propiedad del objeto para usar como VALOR (ej: 'id', 'codigo').
|
|
2179
|
+
* Solo acepta llaves que existan en el tipo T.
|
|
2180
|
+
* @default 'value'
|
|
2181
|
+
*/
|
|
2182
|
+
optionValueKey?: keyof T;
|
|
2183
|
+
/**
|
|
2184
|
+
* Nombre de la propiedad del objeto para usar como ETIQUETA (ej: 'nombre', 'label').
|
|
2185
|
+
* Solo acepta llaves que existan en el tipo T.
|
|
2186
|
+
* @default 'label'
|
|
2187
|
+
*/
|
|
2188
|
+
optionLabelKey?: keyof T;
|
|
2189
|
+
/**
|
|
2190
|
+
* Nombre de la propiedad para deshabilitar una opción específica.
|
|
2191
|
+
* Solo acepta llaves que existan en el tipo T.
|
|
2192
|
+
* @default 'isDisabled'
|
|
2193
|
+
*/
|
|
2194
|
+
optionDisabledKey?: keyof T;
|
|
2195
|
+
/**
|
|
2196
|
+
* Nombre de la propiedad para descripción de una opción específica.
|
|
2197
|
+
* Solo acepta llaves que existan en el tipo T.
|
|
2198
|
+
* @default 'description'
|
|
2199
|
+
*/
|
|
2200
|
+
optionDescriptionKey?: keyof T;
|
|
2303
2201
|
};
|
|
2304
2202
|
|
|
2305
2203
|
export declare type RadioProps = {
|
|
@@ -2354,12 +2252,12 @@ export declare type RadioProps = {
|
|
|
2354
2252
|
/**
|
|
2355
2253
|
* Children (usado cuando no se pasa label)
|
|
2356
2254
|
*/
|
|
2357
|
-
children?:
|
|
2255
|
+
children?: default_2.ReactNode;
|
|
2358
2256
|
/**
|
|
2359
2257
|
* Clase CSS adicional
|
|
2360
2258
|
*/
|
|
2361
2259
|
className?: string;
|
|
2362
|
-
} & Omit<
|
|
2260
|
+
} & Omit<default_2.InputHTMLAttributes<HTMLInputElement>, 'size' | 'type'>;
|
|
2363
2261
|
|
|
2364
2262
|
export declare type RadioSize = 'sm' | 'md' | 'lg';
|
|
2365
2263
|
|
|
@@ -2391,48 +2289,48 @@ export declare type ResultadoValidacion = {
|
|
|
2391
2289
|
};
|
|
2392
2290
|
|
|
2393
2291
|
/**
|
|
2394
|
-
*
|
|
2395
|
-
*
|
|
2396
|
-
* @template T - Tipo de las opciones (string u objeto personalizado)
|
|
2397
|
-
*
|
|
2398
|
-
* @description
|
|
2399
|
-
* Este es el componente público que se debe usar en la aplicación.
|
|
2400
|
-
* Internamente delega el renderizado a SelectBase pero añade la capa
|
|
2401
|
-
* inteligente de conversión de tipos.
|
|
2402
|
-
*
|
|
2403
|
-
* ### Ventajas de esta arquitectura:
|
|
2404
|
-
* - ✅ Separación de responsabilidades (Clean Architecture)
|
|
2405
|
-
* - ✅ SelectBase es 100% reutilizable
|
|
2406
|
-
* - ✅ Tipado estricto sin 'any'
|
|
2407
|
-
* - ✅ Fácil testing (puedes testear SelectBase aislado)
|
|
2408
|
-
* - ✅ Retrocompatibilidad total
|
|
2409
|
-
*
|
|
2410
|
-
* @see {@link SelectBase} para la implementación visual
|
|
2411
|
-
* @see {@link SmartSelectProps} para los tipos disponibles
|
|
2412
|
-
* @see {@link SelectRef} para métodos imperativos
|
|
2413
|
-
*/
|
|
2414
|
-
export declare const Select: <T extends string | Record<string, unknown>>(props: SmartSelectProps<T> & {
|
|
2415
|
-
ref?: React.ForwardedRef<SelectRef>;
|
|
2416
|
-
}) => React.ReactElement;
|
|
2417
|
-
|
|
2418
|
-
/**
|
|
2419
|
-
* Props para Select con objetos múltiples (retorna objetos completos).
|
|
2292
|
+
* Select con inferencia automática de tipos según las props.
|
|
2420
2293
|
*
|
|
2421
2294
|
* @example
|
|
2422
2295
|
* ```tsx
|
|
2423
|
-
*
|
|
2424
|
-
*
|
|
2425
|
-
*
|
|
2426
|
-
*
|
|
2427
|
-
*
|
|
2428
|
-
*
|
|
2429
|
-
*
|
|
2430
|
-
*
|
|
2431
|
-
* }}
|
|
2432
|
-
* />
|
|
2296
|
+
* // Strings
|
|
2297
|
+
* <Select options={['A', 'B']} onChange={(val) => {}} />
|
|
2298
|
+
*
|
|
2299
|
+
* // Objetos → retorna ID
|
|
2300
|
+
* <Select options={usuarios} optionValueKey="id" onChange={(id) => {}} />
|
|
2301
|
+
*
|
|
2302
|
+
* // Objetos → retorna objeto completo
|
|
2303
|
+
* <Select options={usuarios} optionValueKey="id" devolverObjeto onChange={(user) => {}} />
|
|
2433
2304
|
* ```
|
|
2434
2305
|
*/
|
|
2435
|
-
declare
|
|
2306
|
+
export declare const Select: SelectComponent;
|
|
2307
|
+
|
|
2308
|
+
declare type SelectComponent = {
|
|
2309
|
+
(props: SelectStringProps & {
|
|
2310
|
+
ref?: React.Ref<SelectRef>;
|
|
2311
|
+
}): React.ReactElement;
|
|
2312
|
+
(props: SelectMultiStringProps & {
|
|
2313
|
+
ref?: React.Ref<SelectRef>;
|
|
2314
|
+
}): React.ReactElement;
|
|
2315
|
+
<T extends Record<string, unknown>>(props: SelectObjectIdProps<T> & {
|
|
2316
|
+
ref?: React.Ref<SelectRef>;
|
|
2317
|
+
}): React.ReactElement;
|
|
2318
|
+
<T extends Record<string, unknown>>(props: SelectMultiObjectIdProps<T> & {
|
|
2319
|
+
ref?: React.Ref<SelectRef>;
|
|
2320
|
+
}): React.ReactElement;
|
|
2321
|
+
<T extends Record<string, unknown>>(props: SelectObjectFullProps<T> & {
|
|
2322
|
+
ref?: React.Ref<SelectRef>;
|
|
2323
|
+
}): React.ReactElement;
|
|
2324
|
+
<T extends Record<string, unknown>>(props: SelectMultiObjectFullProps<T> & {
|
|
2325
|
+
ref?: React.Ref<SelectRef>;
|
|
2326
|
+
}): React.ReactElement;
|
|
2327
|
+
<T extends string | Record<string, unknown>>(props: SmartSelectProps<T> & {
|
|
2328
|
+
ref?: React.ForwardedRef<SelectRef>;
|
|
2329
|
+
}): React.ReactElement;
|
|
2330
|
+
};
|
|
2331
|
+
|
|
2332
|
+
/** Objetos múltiples - retorna array de objetos */
|
|
2333
|
+
export declare type SelectMultiObjectFullProps<T> = BaseSelectProps<T> & WrapperProps & {
|
|
2436
2334
|
options: T[];
|
|
2437
2335
|
value?: T[];
|
|
2438
2336
|
onChange?: (value: T[]) => void;
|
|
@@ -2442,21 +2340,8 @@ declare type SelectMultiObjectFullProps<T> = BaseSelectProps<T> & WrapperProps &
|
|
|
2442
2340
|
isMultiple: true;
|
|
2443
2341
|
};
|
|
2444
2342
|
|
|
2445
|
-
/**
|
|
2446
|
-
|
|
2447
|
-
*
|
|
2448
|
-
* @example
|
|
2449
|
-
* ```tsx
|
|
2450
|
-
* <Select
|
|
2451
|
-
* options={usuarios}
|
|
2452
|
-
* value={['1', '2', '3']} // Array de IDs
|
|
2453
|
-
* optionValueKey="id"
|
|
2454
|
-
* isMultiple
|
|
2455
|
-
* onChange={(ids) => console.log(ids)} // ['1', '2', '3']
|
|
2456
|
-
* />
|
|
2457
|
-
* ```
|
|
2458
|
-
*/
|
|
2459
|
-
declare type SelectMultiObjectIdProps<T> = BaseSelectProps<T> & WrapperProps & {
|
|
2343
|
+
/** Objetos múltiples - retorna array de IDs */
|
|
2344
|
+
export declare type SelectMultiObjectIdProps<T> = BaseSelectProps<T> & WrapperProps & {
|
|
2460
2345
|
options: T[];
|
|
2461
2346
|
value?: Array<string | number>;
|
|
2462
2347
|
onChange?: (value: Array<string | number>) => void;
|
|
@@ -2466,21 +2351,8 @@ declare type SelectMultiObjectIdProps<T> = BaseSelectProps<T> & WrapperProps & {
|
|
|
2466
2351
|
isMultiple: true;
|
|
2467
2352
|
};
|
|
2468
2353
|
|
|
2469
|
-
/**
|
|
2470
|
-
|
|
2471
|
-
*
|
|
2472
|
-
* @example
|
|
2473
|
-
* ```tsx
|
|
2474
|
-
* const colores = ['Rojo', 'Verde', 'Azul'];
|
|
2475
|
-
* <Select
|
|
2476
|
-
* options={colores}
|
|
2477
|
-
* value={['Rojo', 'Verde']}
|
|
2478
|
-
* isMultiple
|
|
2479
|
-
* onChange={(seleccionados) => console.log(seleccionados)} // string[]
|
|
2480
|
-
* />
|
|
2481
|
-
* ```
|
|
2482
|
-
*/
|
|
2483
|
-
declare type SelectMultiStringProps = BaseSelectProps<string> & WrapperProps & {
|
|
2354
|
+
/** Strings múltiples */
|
|
2355
|
+
export declare type SelectMultiStringProps = BaseSelectProps<string> & WrapperProps & {
|
|
2484
2356
|
options: string[];
|
|
2485
2357
|
value?: string[];
|
|
2486
2358
|
onChange?: (value: string[]) => void;
|
|
@@ -2490,101 +2362,29 @@ declare type SelectMultiStringProps = BaseSelectProps<string> & WrapperProps & {
|
|
|
2490
2362
|
isMultiple: true;
|
|
2491
2363
|
};
|
|
2492
2364
|
|
|
2493
|
-
/**
|
|
2494
|
-
|
|
2495
|
-
*
|
|
2496
|
-
* @description
|
|
2497
|
-
* Modo alternativo donde `onChange` devuelve el objeto completo en lugar del ID.
|
|
2498
|
-
* Útil cuando necesitas acceder a otras propiedades sin hacer búsquedas.
|
|
2499
|
-
*
|
|
2500
|
-
* @example
|
|
2501
|
-
* ```tsx
|
|
2502
|
-
* <Select
|
|
2503
|
-
* options={usuarios}
|
|
2504
|
-
* value={usuarioSeleccionado} // Pasas el objeto
|
|
2505
|
-
* optionValueKey="id"
|
|
2506
|
-
* devolverObjeto // Activa este modo
|
|
2507
|
-
* onChange={(usuario) => {
|
|
2508
|
-
* console.log(usuario); // { id: '123', nombre: 'Ana', ... }
|
|
2509
|
-
* // Tienes acceso directo a todas las propiedades
|
|
2510
|
-
* }}
|
|
2511
|
-
* />
|
|
2512
|
-
* ```
|
|
2513
|
-
*/
|
|
2514
|
-
declare type SelectObjectFullProps<T> = BaseSelectProps<T> & WrapperProps & {
|
|
2365
|
+
/** Objetos - retorna objeto completo */
|
|
2366
|
+
export declare type SelectObjectFullProps<T> = BaseSelectProps<T> & WrapperProps & {
|
|
2515
2367
|
options: T[];
|
|
2516
|
-
/** Recibe el objeto completo */
|
|
2517
2368
|
value?: T | null;
|
|
2518
|
-
/** Devuelve el objeto completo */
|
|
2519
2369
|
onChange?: (value: T | null) => void;
|
|
2520
2370
|
optionValueKey: keyof T;
|
|
2521
2371
|
optionLabelKey?: keyof T;
|
|
2522
|
-
/** Debe ser true explícitamente */
|
|
2523
2372
|
devolverObjeto: true;
|
|
2524
2373
|
isMultiple?: false;
|
|
2525
2374
|
};
|
|
2526
2375
|
|
|
2527
|
-
/**
|
|
2528
|
-
|
|
2529
|
-
*
|
|
2530
|
-
* @template T - Tipo del objeto de la opción
|
|
2531
|
-
*
|
|
2532
|
-
* @description
|
|
2533
|
-
* Este es el modo más común para stores/APIs.
|
|
2534
|
-
* - El `value` que recibe es el ID (string | number)
|
|
2535
|
-
* - El `onChange` devuelve el ID
|
|
2536
|
-
* - `optionValueKey` es **obligatorio**
|
|
2537
|
-
*
|
|
2538
|
-
* @example
|
|
2539
|
-
* ```tsx
|
|
2540
|
-
* interface Usuario { id: string; nombre: string; email: string; }
|
|
2541
|
-
* const usuarios: Usuario[] = [...];
|
|
2542
|
-
*
|
|
2543
|
-
* <Select
|
|
2544
|
-
* options={usuarios}
|
|
2545
|
-
* value="123" // Pasas el ID
|
|
2546
|
-
* optionValueKey="id" // Obligatorio
|
|
2547
|
-
* optionLabelKey="nombre"
|
|
2548
|
-
* onChange={(id) => {
|
|
2549
|
-
* console.log(id); // '123' (string)
|
|
2550
|
-
* // Luego buscas el objeto si lo necesitas
|
|
2551
|
-
* }}
|
|
2552
|
-
* />
|
|
2553
|
-
* ```
|
|
2554
|
-
*/
|
|
2555
|
-
declare type SelectObjectIdProps<T> = BaseSelectProps<T> & WrapperProps & {
|
|
2376
|
+
/** Objetos - retorna ID (comportamiento por defecto) */
|
|
2377
|
+
export declare type SelectObjectIdProps<T> = BaseSelectProps<T> & WrapperProps & {
|
|
2556
2378
|
options: T[];
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
/** Devuelve el ID */
|
|
2560
|
-
onChange?: (value: string | number | null) => void;
|
|
2561
|
-
/** Obligatorio cuando son objetos */
|
|
2379
|
+
value?: string | number;
|
|
2380
|
+
onChange?: (value: string | number) => void;
|
|
2562
2381
|
optionValueKey: keyof T;
|
|
2563
|
-
/** Opcional */
|
|
2564
2382
|
optionLabelKey?: keyof T;
|
|
2565
|
-
/** Debe ser false o no definido */
|
|
2566
2383
|
devolverObjeto?: false;
|
|
2567
2384
|
isMultiple?: false;
|
|
2568
2385
|
};
|
|
2569
2386
|
|
|
2570
|
-
/**
|
|
2571
|
-
* Tipo de opción del Select.
|
|
2572
|
-
*
|
|
2573
|
-
* Puede ser un string simple o un objeto con propiedades adicionales.
|
|
2574
|
-
* Si es objeto, puede incluir `disabled: true` para deshabilitarla.
|
|
2575
|
-
*
|
|
2576
|
-
* @template T - Tipo base de la opción
|
|
2577
|
-
*
|
|
2578
|
-
* @example
|
|
2579
|
-
* ```ts
|
|
2580
|
-
* // String simple
|
|
2581
|
-
* type OpcionSimple = SelectOption<string>; // string
|
|
2582
|
-
*
|
|
2583
|
-
* // Objeto con disabled
|
|
2584
|
-
* type OpcionObjeto = SelectOption<{ id: string; label: string }>;
|
|
2585
|
-
* // { id: string; label: string; disabled?: boolean }
|
|
2586
|
-
* ```
|
|
2587
|
-
*/
|
|
2387
|
+
/** Opción del Select: string simple u objeto con `disabled` opcional */
|
|
2588
2388
|
export declare type SelectOption<T = string> = T extends string ? string : T & {
|
|
2589
2389
|
disabled?: boolean;
|
|
2590
2390
|
};
|
|
@@ -3134,49 +2934,21 @@ export declare type SelectProps<T = string> = {
|
|
|
3134
2934
|
* ```
|
|
3135
2935
|
*/
|
|
3136
2936
|
export declare type SelectRef = {
|
|
3137
|
-
/** Enfoca el trigger del select */
|
|
3138
2937
|
focus: () => void;
|
|
3139
|
-
/** Quita el focus del trigger */
|
|
3140
2938
|
blur: () => void;
|
|
3141
|
-
/** Abre el menú desplegable */
|
|
3142
2939
|
open: () => void;
|
|
3143
|
-
/** Cierra el menú desplegable */
|
|
3144
2940
|
close: () => void;
|
|
3145
|
-
/** Limpia la selección (null en simple, [] en múltiple) */
|
|
3146
2941
|
clear: () => void;
|
|
3147
2942
|
};
|
|
3148
2943
|
|
|
3149
|
-
/**
|
|
3150
|
-
|
|
3151
|
-
*
|
|
3152
|
-
* @description
|
|
3153
|
-
* Cuando las opciones son strings, no se necesitan optionValueKey ni optionLabelKey.
|
|
3154
|
-
* El onChange recibe directamente el string seleccionado o null.
|
|
3155
|
-
*
|
|
3156
|
-
* @example
|
|
3157
|
-
* ```tsx
|
|
3158
|
-
* const frutas = ['Manzana', 'Pera', 'Naranja'];
|
|
3159
|
-
* <Select
|
|
3160
|
-
* options={frutas}
|
|
3161
|
-
* value="Manzana"
|
|
3162
|
-
* onChange={(fruta) => console.log(fruta)} // 'Manzana' | null
|
|
3163
|
-
* />
|
|
3164
|
-
* ```
|
|
3165
|
-
*/
|
|
3166
|
-
declare type SelectStringProps = BaseSelectProps<string> & WrapperProps & {
|
|
3167
|
-
/** Lista de strings */
|
|
2944
|
+
/** Strings simples (selección única) */
|
|
2945
|
+
export declare type SelectStringProps = BaseSelectProps<string> & WrapperProps & {
|
|
3168
2946
|
options: string[];
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
/** Callback al cambiar selección */
|
|
3172
|
-
onChange?: (value: string | null) => void;
|
|
3173
|
-
/** No debe existir en modo string */
|
|
2947
|
+
value?: string;
|
|
2948
|
+
onChange?: (value: string) => void;
|
|
3174
2949
|
optionValueKey?: never;
|
|
3175
|
-
/** No debe existir en modo string */
|
|
3176
2950
|
optionLabelKey?: never;
|
|
3177
|
-
/** No aplica en modo string */
|
|
3178
2951
|
devolverObjeto?: never;
|
|
3179
|
-
/** Debe ser false o no definido */
|
|
3180
2952
|
isMultiple?: false;
|
|
3181
2953
|
};
|
|
3182
2954
|
|
|
@@ -3187,19 +2959,8 @@ declare type SinDatosProps = {
|
|
|
3187
2959
|
etiquetaAccion?: string;
|
|
3188
2960
|
};
|
|
3189
2961
|
|
|
3190
|
-
/**
|
|
3191
|
-
|
|
3192
|
-
*
|
|
3193
|
-
* @description
|
|
3194
|
-
* TypeScript inferirá automáticamente qué interfaz usar según:
|
|
3195
|
-
* - El tipo de `options` (string[] vs objeto[])
|
|
3196
|
-
* - El valor de `isMultiple`
|
|
3197
|
-
* - El valor de `devolverObjeto`
|
|
3198
|
-
* - La presencia de `optionValueKey`
|
|
3199
|
-
*
|
|
3200
|
-
* Esto fuerza el uso correcto en tiempo de compilación.
|
|
3201
|
-
*/
|
|
3202
|
-
declare type SmartSelectProps<T> = SelectStringProps | SelectMultiStringProps | SelectObjectIdProps<T> | SelectMultiObjectIdProps<T> | SelectObjectFullProps<T> | SelectMultiObjectFullProps<T>;
|
|
2962
|
+
/** Unión discriminada de todos los tipos posibles */
|
|
2963
|
+
export declare type SmartSelectProps<T> = SelectStringProps | SelectMultiStringProps | SelectObjectIdProps<T> | SelectMultiObjectIdProps<T> | SelectObjectFullProps<T> | SelectMultiObjectFullProps<T>;
|
|
3203
2964
|
|
|
3204
2965
|
export declare function SonidoIcono(props: SVGProps<SVGSVGElement>): JSX.Element;
|
|
3205
2966
|
|
|
@@ -3974,36 +3735,9 @@ export declare type ValidationResult = boolean | string | {
|
|
|
3974
3735
|
message?: string;
|
|
3975
3736
|
} | null | undefined;
|
|
3976
3737
|
|
|
3977
|
-
/**
|
|
3978
|
-
* Props adicionales del wrapper inteligente.
|
|
3979
|
-
*/
|
|
3738
|
+
/** Props del wrapper para control de retorno */
|
|
3980
3739
|
declare type WrapperProps = {
|
|
3981
|
-
/**
|
|
3982
|
-
* Controla el formato del valor retornado en onChange.
|
|
3983
|
-
*
|
|
3984
|
-
* - `true`: Devuelve el objeto completo cuando se selecciona una opción
|
|
3985
|
-
* - `false`: Devuelve solo el ID/valor primitivo (string | number)
|
|
3986
|
-
*
|
|
3987
|
-
* @default false
|
|
3988
|
-
*
|
|
3989
|
-
* @example
|
|
3990
|
-
* ```tsx
|
|
3991
|
-
* // devolverObjeto={false} (default)
|
|
3992
|
-
* <Select
|
|
3993
|
-
* options={usuarios}
|
|
3994
|
-
* optionValueKey="id"
|
|
3995
|
-
* onChange={(valor) => console.log(valor)} // '123' (string)
|
|
3996
|
-
* />
|
|
3997
|
-
*
|
|
3998
|
-
* // devolverObjeto={true}
|
|
3999
|
-
* <Select
|
|
4000
|
-
* options={usuarios}
|
|
4001
|
-
* optionValueKey="id"
|
|
4002
|
-
* devolverObjeto
|
|
4003
|
-
* onChange={(valor) => console.log(valor)} // { id: '123', nombre: 'Ana' }
|
|
4004
|
-
* />
|
|
4005
|
-
* ```
|
|
4006
|
-
*/
|
|
3740
|
+
/** Si true, onChange devuelve el objeto completo en lugar del ID */
|
|
4007
3741
|
devolverObjeto?: boolean;
|
|
4008
3742
|
};
|
|
4009
3743
|
|