carconnect-gatherleads-ui-lib 2.4.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +229 -51
- package/dist/carconnect-gatherleads-ui-lib.css +1 -1
- package/dist/carconnect-gatherleads-ui-lib.d.ts +390 -0
- package/dist/carconnect-gatherleads-ui-lib.js +12298 -13468
- package/dist/carconnect-gatherleads-ui-lib.umd.cjs +27 -136
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -870,66 +870,80 @@ interface GatherTextareaFieldConfig extends BaseFieldConfig {
|
|
|
870
870
|
}
|
|
871
871
|
```
|
|
872
872
|
|
|
873
|
-
|
|
873
|
+
#### **Características Destacadas**
|
|
874
874
|
|
|
875
|
-
|
|
876
|
-
interface GatherDateFieldConfig extends BaseFieldConfig {
|
|
877
|
-
type: 'date' | 'daterange';
|
|
878
|
-
maxDate?: Date;
|
|
879
|
-
minDate?: Date;
|
|
880
|
-
singleDate?: boolean; // Solo para daterange
|
|
881
|
-
displayFormat?: string; // Formato de visualización
|
|
882
|
-
size?: 'sm' | 'md' | 'lg';
|
|
883
|
-
}
|
|
884
|
-
```
|
|
875
|
+
✨ **Nuevas Funcionalidades:**
|
|
885
876
|
|
|
886
|
-
**
|
|
877
|
+
1. **Scroll en selector de años** - El selector ahora tiene altura máxima y scroll automático
|
|
878
|
+
2. **Control de años personalizables** - `pastYearsCount={10}` muestra año actual + últimos 10 años
|
|
879
|
+
3. **Textos personalizables** - Botones Apply/Cancel en cualquier idioma
|
|
880
|
+
4. **Callbacks para eventos** - `onApply`, `onCancel`, `onOpenChange` para lógica personalizada
|
|
881
|
+
5. **Formatos de fecha flexibles** - Personaliza cómo se muestran las fechas
|
|
882
|
+
6. **Auto-cierre inteligente** - Cierre automático tras selección para UX más rápida
|
|
883
|
+
7. **Modo sin botones** - `hideActionButtons={true}` para aplicar cambios inmediatamente
|
|
884
|
+
|
|
885
|
+
#### **Ejemplos de Uso Avanzado**
|
|
887
886
|
|
|
888
887
|
```tsx
|
|
889
|
-
//
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
size: "md"
|
|
899
|
-
}
|
|
888
|
+
// EJEMPLO 1: Date Picker rápido sin confirmación
|
|
889
|
+
<GatherDatePicker
|
|
890
|
+
mode="single"
|
|
891
|
+
selected={date}
|
|
892
|
+
onSelect={setDate}
|
|
893
|
+
autoClose={true}
|
|
894
|
+
hideActionButtons={true}
|
|
895
|
+
placeholder="Selección rápida"
|
|
896
|
+
/>
|
|
900
897
|
|
|
901
|
-
//
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
898
|
+
// EJEMPLO 2: Con validación y callbacks
|
|
899
|
+
<GatherDatePicker
|
|
900
|
+
mode="single"
|
|
901
|
+
selected={date}
|
|
902
|
+
onSelect={setDate}
|
|
903
|
+
applyButtonText="Guardar Fecha"
|
|
904
|
+
cancelButtonText="Descartar"
|
|
905
|
+
onApply={(selectedDate) => {
|
|
906
|
+
// Validar y guardar
|
|
907
|
+
if (selectedDate) {
|
|
908
|
+
saveToAPI(selectedDate);
|
|
909
|
+
toast.success('Fecha guardada');
|
|
910
|
+
}
|
|
911
|
+
}}
|
|
912
|
+
onCancel={() => {
|
|
913
|
+
toast.info('Cambios descartados');
|
|
914
|
+
}}
|
|
915
|
+
/>
|
|
912
916
|
|
|
913
|
-
//
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
917
|
+
// EJEMPLO 3: Rango con formato personalizado y años limitados
|
|
918
|
+
<GatherDatePicker
|
|
919
|
+
mode="range"
|
|
920
|
+
selected={dateRange}
|
|
921
|
+
onSelect={setDateRange}
|
|
922
|
+
rangeFromFormat="dd/MM/yy"
|
|
923
|
+
rangeToFormat="dd/MM/yy"
|
|
924
|
+
pastYearsCount={5} // Solo últimos 5 años
|
|
925
|
+
placeholder="Del - Al"
|
|
926
|
+
/>
|
|
922
927
|
|
|
923
|
-
//
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
}
|
|
928
|
+
// EJEMPLO 4: Input de formulario completo
|
|
929
|
+
<GatherDatePickerInput
|
|
930
|
+
label="Fecha de Registro"
|
|
931
|
+
description="Seleccione la fecha de registro del cliente"
|
|
932
|
+
placeholder="dd/mm/aaaa"
|
|
933
|
+
mode="single"
|
|
934
|
+
selected={date}
|
|
935
|
+
onSelect={setDate}
|
|
936
|
+
dateFormat="dd/MM/yyyy"
|
|
937
|
+
showSelectedDate={true}
|
|
938
|
+
selectedDateLabel="Registrado el:"
|
|
939
|
+
autoClose={true}
|
|
940
|
+
minDate={subDays(new Date(), 365)}
|
|
941
|
+
maxDate={new Date()}
|
|
942
|
+
/>
|
|
931
943
|
```
|
|
932
944
|
|
|
945
|
+
---
|
|
946
|
+
|
|
933
947
|
### 7. **GatherCheckboxGroupFieldConfig** - Grupo de Checkboxes
|
|
934
948
|
|
|
935
949
|
```tsx
|
|
@@ -3010,3 +3024,167 @@ const DetailsSidebar = ({ user, isOpen, onClose }) => (
|
|
|
3010
3024
|
```
|
|
3011
3025
|
|
|
3012
3026
|
Esta guía cubre los aspectos principales de GatherModal, proporcionando ejemplos prácticos para implementaciones comunes desde modales simples hasta paneles laterales complejos.
|
|
3027
|
+
|
|
3028
|
+
# 📅 Guía Completa de GatherDatePicker
|
|
3029
|
+
|
|
3030
|
+
## 🎯 Introducción
|
|
3031
|
+
|
|
3032
|
+
`GatherDatePicker` es un componente de selección de fechas flexible y robusto, basado en `react-day-picker`. Ofrece dos variantes principales: un botón que abre un popover (`GatherDatePicker`) y un input de texto (`GatherDatePickerInput`). Soporta selección de fechas individuales y rangos, zonas horarias, y validaciones.
|
|
3033
|
+
|
|
3034
|
+
## 📦 Uso Básico
|
|
3035
|
+
|
|
3036
|
+
### Selector de Fecha Simple (Botón)
|
|
3037
|
+
|
|
3038
|
+
```tsx
|
|
3039
|
+
import { GatherDatePicker } from '@/base/date-picker/gather-date-picker';
|
|
3040
|
+
|
|
3041
|
+
const SimpleDatePicker = () => {
|
|
3042
|
+
const [date, setDate] = React.useState<Date | undefined>(new Date());
|
|
3043
|
+
|
|
3044
|
+
return (
|
|
3045
|
+
<GatherDatePicker
|
|
3046
|
+
mode='single'
|
|
3047
|
+
selected={date}
|
|
3048
|
+
onSelect={setDate}
|
|
3049
|
+
placeholder='Seleccionar fecha'
|
|
3050
|
+
/>
|
|
3051
|
+
);
|
|
3052
|
+
};
|
|
3053
|
+
```
|
|
3054
|
+
|
|
3055
|
+
### Input de Fecha
|
|
3056
|
+
|
|
3057
|
+
```tsx
|
|
3058
|
+
import { GatherDatePickerInput } from '@/base/date-picker/gather-date-picker-input';
|
|
3059
|
+
|
|
3060
|
+
const InputDatePicker = () => {
|
|
3061
|
+
const [date, setDate] = React.useState<Date | undefined>();
|
|
3062
|
+
|
|
3063
|
+
return (
|
|
3064
|
+
<GatherDatePickerInput
|
|
3065
|
+
mode='single'
|
|
3066
|
+
selected={date}
|
|
3067
|
+
onSelect={setDate}
|
|
3068
|
+
label='Fecha de nacimiento'
|
|
3069
|
+
placeholder='Seleccione su fecha de nacimiento'
|
|
3070
|
+
/>
|
|
3071
|
+
);
|
|
3072
|
+
};
|
|
3073
|
+
```
|
|
3074
|
+
|
|
3075
|
+
## ⚙️ Props Principales
|
|
3076
|
+
|
|
3077
|
+
### GatherDatePickerProps & GatherDatePickerInputProps
|
|
3078
|
+
|
|
3079
|
+
Ambos componentes comparten la mayoría de las props, heredando de una base común:
|
|
3080
|
+
|
|
3081
|
+
```tsx
|
|
3082
|
+
interface GatherDatePickerProps {
|
|
3083
|
+
// CONFIGURACIÓN
|
|
3084
|
+
mode?: 'single' | 'range'; // Modo de selección
|
|
3085
|
+
selected?: Date | DateRange; // Valor seleccionado
|
|
3086
|
+
onSelect?: (date: any) => void; // Callback de selección
|
|
3087
|
+
timeZone?: string; // Zona horaria (default: 'America/Guayaquil')
|
|
3088
|
+
|
|
3089
|
+
// VISUAL
|
|
3090
|
+
placeholder?: string; // Texto placeholder
|
|
3091
|
+
disabled?: boolean; // Estado deshabilitado
|
|
3092
|
+
className?: string; // Clases adicionales
|
|
3093
|
+
|
|
3094
|
+
// RANGO Y RESTRICCIONES
|
|
3095
|
+
minDate?: Date; // Fecha mínima
|
|
3096
|
+
maxDate?: Date; // Fecha máxima
|
|
3097
|
+
disabledDates?: Date[]; // Fechas deshabilitadas específicas
|
|
3098
|
+
pastYearsCount?: number; // Años pasados a mostrar en selector
|
|
3099
|
+
|
|
3100
|
+
// FORMATO
|
|
3101
|
+
dateFormat?: string; // Formato de fecha (ej: 'dd MMM yyyy')
|
|
3102
|
+
rangeFromFormat?: string; // Formato inicio rango
|
|
3103
|
+
rangeToFormat?: string; // Formato fin rango
|
|
3104
|
+
|
|
3105
|
+
// COMPORTAMIENTO
|
|
3106
|
+
autoClose?: boolean; // Cerrar al seleccionar (single mode)
|
|
3107
|
+
|
|
3108
|
+
// VALIDACIÓN (NUEVO)
|
|
3109
|
+
error?: boolean; // Estado de error (borde rojo)
|
|
3110
|
+
helperText?: string; // Texto de ayuda/error
|
|
3111
|
+
required?: boolean; // Marca de campo requerido (*)
|
|
3112
|
+
}
|
|
3113
|
+
```
|
|
3114
|
+
|
|
3115
|
+
### Props Específicas de GatherDatePicker (Botón)
|
|
3116
|
+
|
|
3117
|
+
```tsx
|
|
3118
|
+
interface GatherDatePickerProps {
|
|
3119
|
+
// ... props comunes
|
|
3120
|
+
variant?: 'default' | 'outline' | 'ghost' | 'secondary'; // Variante del botón
|
|
3121
|
+
hideActionButtons?: boolean; // Ocultar botones Aplicar/Cancelar
|
|
3122
|
+
applyButtonText?: string; // Texto botón Aplicar
|
|
3123
|
+
cancelButtonText?: string; // Texto botón Cancelar
|
|
3124
|
+
showPresets?: boolean; // Mostrar panel de presets (ayer, hoy, etc.)
|
|
3125
|
+
presets?: DatePreset[]; // Presets personalizados
|
|
3126
|
+
}
|
|
3127
|
+
```
|
|
3128
|
+
|
|
3129
|
+
### Props Específicas de GatherDatePickerInput (Input)
|
|
3130
|
+
|
|
3131
|
+
```tsx
|
|
3132
|
+
interface GatherDatePickerInputProps {
|
|
3133
|
+
// ... props comunes
|
|
3134
|
+
label?: string; // Etiqueta del input
|
|
3135
|
+
description?: string; // Descripción bajo el label
|
|
3136
|
+
showSelectedDate?: boolean; // Mostrar texto de fecha seleccionada
|
|
3137
|
+
selectedDateLabel?: string; // Prefijo para fecha seleccionada
|
|
3138
|
+
}
|
|
3139
|
+
```
|
|
3140
|
+
|
|
3141
|
+
## 🚨 Manejo de Errores y Validaciones
|
|
3142
|
+
|
|
3143
|
+
Los componentes ahora soportan estados visuales de error y campos requeridos para integrarse mejor en formularios.
|
|
3144
|
+
|
|
3145
|
+
### Input con Error y Mensaje
|
|
3146
|
+
|
|
3147
|
+
```tsx
|
|
3148
|
+
<GatherDatePickerInput
|
|
3149
|
+
mode='single'
|
|
3150
|
+
label='Fecha de Facturación'
|
|
3151
|
+
required={true} // Muestra asterisco rojo *
|
|
3152
|
+
error={true} // Borde rojo en el input
|
|
3153
|
+
helperText='La fecha es obligatoria' // Muestra mensaje en rojo si hay error
|
|
3154
|
+
onSelect={setDate}
|
|
3155
|
+
selected={date}
|
|
3156
|
+
/>
|
|
3157
|
+
```
|
|
3158
|
+
|
|
3159
|
+
### Botón con Estado de Error
|
|
3160
|
+
|
|
3161
|
+
```tsx
|
|
3162
|
+
<GatherDatePicker
|
|
3163
|
+
mode='single'
|
|
3164
|
+
selected={date}
|
|
3165
|
+
onSelect={setDate}
|
|
3166
|
+
error={true} // El botón tendrá un borde rojo
|
|
3167
|
+
className='w-full'
|
|
3168
|
+
/>;
|
|
3169
|
+
{
|
|
3170
|
+
/* Puedes renderizar el texto de error manualmente si usas la versión de botón */
|
|
3171
|
+
}
|
|
3172
|
+
{
|
|
3173
|
+
hasError && (
|
|
3174
|
+
<p className='mt-1 text-xs text-red-500'>Seleccione una fecha válida</p>
|
|
3175
|
+
);
|
|
3176
|
+
}
|
|
3177
|
+
```
|
|
3178
|
+
|
|
3179
|
+
## 🌍 Zonas Horarias y Formatos
|
|
3180
|
+
|
|
3181
|
+
El componente maneja zonas horarias utilizando `date-fns-tz`. Por defecto usa `America/Guayaquil`.
|
|
3182
|
+
|
|
3183
|
+
```tsx
|
|
3184
|
+
<GatherDatePicker
|
|
3185
|
+
timeZone='Europe/Madrid' // Configurar zona horaria
|
|
3186
|
+
dateFormat='dd/MM/yyyy' // Configurar formato visual
|
|
3187
|
+
selected={date}
|
|
3188
|
+
onSelect={setDate}
|
|
3189
|
+
/>
|
|
3190
|
+
```
|