@adamosuiteservices/ui 2.14.2 → 2.15.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.
Files changed (41) hide show
  1. package/dist/combobox-DGuQtXjP.js +608 -0
  2. package/dist/combobox-hTCtPMUL.cjs +40 -0
  3. package/dist/combobox.cjs +1 -1
  4. package/dist/combobox.js +1 -1
  5. package/dist/components/ui/combobox/combobox.d.ts +5 -1
  6. package/dist/components/ui/date-picker-selector/date-picker-selector.d.ts +5 -1
  7. package/dist/components/ui/file-upload/file-upload.d.ts +3 -1
  8. package/dist/components/ui/slider/slider.d.ts +1 -1
  9. package/dist/components/ui/switch/switch.d.ts +1 -1
  10. package/dist/date-picker-selector.cjs +1 -1
  11. package/dist/date-picker-selector.js +38 -28
  12. package/dist/field.cjs +2 -2
  13. package/dist/field.js +2 -2
  14. package/dist/file-upload.cjs +5 -3
  15. package/dist/file-upload.js +178 -149
  16. package/dist/slider.cjs +5 -5
  17. package/dist/slider.js +196 -177
  18. package/dist/styles.css +1 -1
  19. package/dist/switch.cjs +3 -3
  20. package/dist/switch.js +105 -85
  21. package/docs/components/ui/accordion-rounded.md +2 -6
  22. package/docs/components/ui/avatar.md +3 -1
  23. package/docs/components/ui/button.md +22 -16
  24. package/docs/components/ui/card.md +49 -31
  25. package/docs/components/ui/checkbox.md +44 -8
  26. package/docs/components/ui/combobox.md +62 -4
  27. package/docs/components/ui/date-picker-selector.md +90 -26
  28. package/docs/components/ui/file-upload.md +241 -94
  29. package/docs/components/ui/icon.md +1 -1
  30. package/docs/components/ui/input.md +4 -1
  31. package/docs/components/ui/radio-group.md +1 -1
  32. package/docs/components/ui/select.md +51 -34
  33. package/docs/components/ui/sheet.md +3 -9
  34. package/docs/components/ui/slider.md +120 -99
  35. package/docs/components/ui/switch.md +408 -408
  36. package/docs/components/ui/textarea.md +37 -22
  37. package/docs/components/ui/tooltip.md +5 -2
  38. package/docs/components/ui/typography.md +63 -39
  39. package/package.json +1 -1
  40. package/dist/combobox-CCJGIMFQ.cjs +0 -40
  41. package/dist/combobox-Cj-GEp-T.js +0 -604
@@ -40,6 +40,8 @@ import { Combobox } from "@adamosuiteservices/ui/combobox";
40
40
  | `classNames` | `ComboboxClassNames` | - | Clases CSS por sección (ver tabla abajo) |
41
41
  | `renders` | `ComboboxRenderProps` | - | Funciones de renderizado personalizadas (ver tabla abajo) |
42
42
  | `ref` | `React.Ref<HTMLButtonElement>` | - | Ref al botón trigger para posicionamiento externo |
43
+ | `aria-invalid` | `"true" \| "false" \| boolean` | - | Indica estado inválido (borde rojo) |
44
+ | `disabled` | `boolean` | `false` | Deshabilita el combobox |
43
45
 
44
46
  ### ComboboxLabels
45
47
 
@@ -120,10 +122,7 @@ function MyComponent() {
120
122
 
121
123
  return (
122
124
  <>
123
- <Combobox
124
- ref={comboboxRef}
125
- options={options}
126
- />
125
+ <Combobox ref={comboboxRef} options={options} />
127
126
  {/* Usar comboboxRef para posicionar otros elementos */}
128
127
  <Popover>
129
128
  <PopoverAnchor virtualRef={comboboxRef} />
@@ -135,6 +134,7 @@ function MyComponent() {
135
134
  ```
136
135
 
137
136
  **Notas importantes sobre el ref:**
137
+
138
138
  - El ref apunta directamente al botón trigger (`<Button>`), no a un wrapper
139
139
  - Internamente, el Combobox mantiene su propio ref para medir el ancho del popover
140
140
  - Cuando pasas un ref externo, ambos refs se sincronizan automáticamente
@@ -288,6 +288,63 @@ const options = [
288
288
  />;
289
289
  ```
290
290
 
291
+ ### Estado Inválido
292
+
293
+ ```tsx
294
+ const [value, setValue] = useState("");
295
+ const isInvalid = !value; // Required validation
296
+
297
+ <div className="space-y-2">
298
+ <Combobox
299
+ searchable
300
+ options={frameworks}
301
+ value={value}
302
+ onValueChange={(newValue) => setValue(newValue as string)}
303
+ aria-invalid={isInvalid}
304
+ labels={{ placeholder: "Select framework..." }}
305
+ />
306
+ {isInvalid && (
307
+ <p className="text-sm text-destructive">
308
+ Please select a framework to continue
309
+ </p>
310
+ )}
311
+ </div>;
312
+ ```
313
+
314
+ **Estilos**: Cuando `aria-invalid="true"`, el trigger muestra borde rojo (heredado del componente Button).
315
+
316
+ ### Estado Deshabilitado
317
+
318
+ ```tsx
319
+ // Usando disabled
320
+ <Combobox
321
+ searchable
322
+ options={frameworks}
323
+ value="next.js"
324
+ disabled
325
+ labels={{ placeholder: "Select framework..." }}
326
+ />
327
+ ```
328
+
329
+ ### En Fieldset Disabled
330
+
331
+ ```tsx
332
+ <fieldset disabled>
333
+ <legend>Preferences (Disabled)</legend>
334
+ <Field>
335
+ <FieldLabel>Framework</FieldLabel>
336
+ <Combobox
337
+ searchable
338
+ options={frameworks}
339
+ value="next.js"
340
+ labels={{ placeholder: "Select framework..." }}
341
+ />
342
+ </Field>
343
+ </fieldset>
344
+ ```
345
+
346
+ Los comboboxes dentro de un `<fieldset disabled>` automáticamente heredan el estado disabled del navegador.
347
+
291
348
  ### Labels Personalizadas
292
349
 
293
350
  ```tsx
@@ -584,6 +641,7 @@ El prop `renders` permite personalizar completamente la UI usando el patrón ren
584
641
  ### Command Components
585
642
 
586
643
  Hereda estilos de Command component:
644
+
587
645
  - **Input wrapper**: `h-10`, `px-3`, `border-b`
588
646
  - **List**: `max-h-[300px]` con scroll
589
647
  - **Empty state**: Centrado con padding vertical
@@ -49,6 +49,7 @@ El componente maneja dos Popovers simultáneamente:
49
49
  ```
50
50
 
51
51
  **Ventajas de este enfoque:**
52
+
52
53
  - ✅ Sin elementos wrapper innecesarios en el DOM
53
54
  - ✅ Referencia directa al botón trigger del Combobox
54
55
  - ✅ Posicionamiento preciso del calendario
@@ -56,6 +57,7 @@ El componente maneja dos Popovers simultáneamente:
56
57
  - ✅ Type-safe con el tipo `Measurable` (cualquier elemento con `getBoundingClientRect()`)
57
58
 
58
59
  **Detalles técnicos:**
60
+
59
61
  - `comboboxRef` tiene tipo `RefObject<Measurable | null>` para compatibilidad con Radix UI
60
62
  - El callback ref captura el elemento button cuando se monta
61
63
  - Se usa type assertion `as React.RefObject<Measurable>` para satisfacer el tipo de Radix
@@ -92,13 +94,15 @@ function MyComponent() {
92
94
 
93
95
  ## Props
94
96
 
95
- | Prop | Tipo | Default | Descripción |
96
- | ------------------ | ------------------------ | ----------- | -------------------------------------------------------------- |
97
- | `dateRange` | `DateRange` | - | **Requerido**. Rango de fechas actual |
98
- | `onDateRangeChange`| `(dateRange: DateRange) => void` | - | **Requerido**. Callback al cambiar el rango |
99
- | `labels` | `DatePickerSelectorLabels` | - | Labels personalizables para todos los textos de UI |
100
- | `combobox` | `ComboboxProps` | - | Props adicionales para el componente Combobox |
101
- | `calendar` | `CalendarProps` | - | Props adicionales para el componente Calendar |
97
+ | Prop | Tipo | Default | Descripción |
98
+ | ------------------- | -------------------------------- | ------- | -------------------------------------------------- |
99
+ | `dateRange` | `DateRange` | - | **Requerido**. Rango de fechas actual |
100
+ | `onDateRangeChange` | `(dateRange: DateRange) => void` | - | **Requerido**. Callback al cambiar el rango |
101
+ | `labels` | `DatePickerSelectorLabels` | - | Labels personalizables para todos los textos de UI |
102
+ | `combobox` | `ComboboxProps` | - | Props adicionales para el componente Combobox |
103
+ | `calendar` | `CalendarProps` | - | Props adicionales para el componente Calendar |
104
+ | `aria-invalid` | `"true" \| "false" \| boolean` | - | Indica estado inválido (borde rojo) |
105
+ | `disabled` | `boolean` | `false` | Deshabilita el selector de fechas |
102
106
 
103
107
  ### DateRange Type
104
108
 
@@ -113,13 +117,13 @@ type DateRange = {
113
117
 
114
118
  ```typescript
115
119
  type DatePickerSelectorLabels = {
116
- last30Days?: string; // Default: "Last 30 days"
117
- last7Days?: string; // Default: "Last 7 days"
118
- last90Days?: string; // Default: "Last 90 days"
119
- custom?: string; // Default: "Custom"
120
- placeholder?: string; // Default: "Date"
121
- cancel?: string; // Default: "Cancel"
122
- apply?: string; // Default: "Apply"
120
+ last30Days?: string; // Default: "Last 30 days"
121
+ last7Days?: string; // Default: "Last 7 days"
122
+ last90Days?: string; // Default: "Last 90 days"
123
+ custom?: string; // Default: "Custom"
124
+ placeholder?: string; // Default: "Date"
125
+ cancel?: string; // Default: "Cancel"
126
+ apply?: string; // Default: "Apply"
123
127
  };
124
128
  ```
125
129
 
@@ -204,7 +208,10 @@ function MyComponent() {
204
208
 
205
209
  const formatDateRange = () => {
206
210
  if (!dateRange.from || !dateRange.to) return "No date selected";
207
- return `${format(dateRange.from, "MMM d, yyyy")} - ${format(dateRange.to, "MMM d, yyyy")}`;
211
+ return `${format(dateRange.from, "MMM d, yyyy")} - ${format(
212
+ dateRange.to,
213
+ "MMM d, yyyy"
214
+ )}`;
208
215
  };
209
216
 
210
217
  return (
@@ -253,6 +260,61 @@ function MyComponent() {
253
260
  }
254
261
  ```
255
262
 
263
+ ### Estado Inválido
264
+
265
+ ```tsx
266
+ function MyComponent() {
267
+ const [dateRange, setDateRange] = useState<DateRange>({
268
+ from: undefined,
269
+ to: undefined,
270
+ });
271
+
272
+ const isInvalid = !dateRange.from || !dateRange.to;
273
+
274
+ return (
275
+ <div className="space-y-2">
276
+ <DatePickerSelector
277
+ dateRange={dateRange}
278
+ onDateRangeChange={setDateRange}
279
+ aria-invalid={isInvalid}
280
+ labels={{
281
+ placeholder: "Date (Required)",
282
+ }}
283
+ />
284
+ {isInvalid && (
285
+ <p className="text-sm text-destructive">
286
+ Please select a date range to continue
287
+ </p>
288
+ )}
289
+ </div>
290
+ );
291
+ }
292
+ ```
293
+
294
+ **Estilos**: Cuando `aria-invalid="true"`, el combobox muestra borde rojo (heredado del componente Button).
295
+
296
+ ### Estado Deshabilitado
297
+
298
+ ```tsx
299
+ // Usando disabled
300
+ <DatePickerSelector
301
+ dateRange={dateRange}
302
+ onDateRangeChange={setDateRange}
303
+ disabled
304
+ />
305
+ ```
306
+
307
+ ### En Fieldset Disabled
308
+
309
+ ```tsx
310
+ <fieldset disabled>
311
+ <legend>Date Range (Disabled)</legend>
312
+ <DatePickerSelector dateRange={dateRange} onDateRangeChange={setDateRange} />
313
+ </fieldset>
314
+ ```
315
+
316
+ El selector de fechas dentro de un `<fieldset disabled>` automáticamente hereda el estado disabled del navegador.
317
+
256
318
  ## Comportamiento
257
319
 
258
320
  ### Rangos Predefinidos
@@ -264,6 +326,7 @@ El componente ofrece tres rangos predefinidos:
264
326
  - **Last 90 days**: Desde hace 90 días hasta hoy
265
327
 
266
328
  Todos los rangos predefinidos:
329
+
267
330
  - Usan `date-fns` para cálculos precisos
268
331
  - Establecen las fechas a medianoche (00:00:00)
269
332
  - Se calculan dinámicamente basándose en la fecha actual
@@ -271,11 +334,13 @@ Todos los rangos predefinidos:
271
334
  ### Rango Personalizado
272
335
 
273
336
  Al seleccionar la opción "Custom":
337
+
274
338
  1. Se abre un popover con un calendario
275
339
  2. El usuario selecciona un rango de fechas (from y to)
276
340
  3. Los botones "Cancel" y "Apply" permiten confirmar o descartar la selección
277
341
 
278
342
  **Comportamiento de cancelación:**
343
+
279
344
  - **Botón Cancel**: Restaura la selección anterior y cierra el calendario
280
345
  - **Botón Apply sin rango completo**: Si no se seleccionó un rango completo (ambas fechas), restaura la selección anterior
281
346
  - **Botón Apply con rango completo**: Aplica el rango personalizado y mantiene "Custom" seleccionado
@@ -295,7 +360,7 @@ Esto asegura que el usuario nunca quede con "Custom" seleccionado sin haber comp
295
360
  **Dashboards**: Filtrar datos por períodos de tiempo
296
361
  **Analytics**: Comparar métricas en diferentes rangos
297
362
  **Búsquedas**: Filtrar resultados por rango de fechas
298
- **Logs**: Visualizar registros en períodos específicos
363
+ **Logs**: Visualizar registros en períodos específicos
299
364
 
300
365
  ## Dependencias
301
366
 
@@ -334,10 +399,7 @@ const [dateRange, setDateRange] = useState<DateRange>({
334
399
  to: undefined,
335
400
  });
336
401
 
337
- <DatePickerSelector
338
- dateRange={dateRange}
339
- onDateRangeChange={setDateRange}
340
- />
402
+ <DatePickerSelector dateRange={dateRange} onDateRangeChange={setDateRange} />;
341
403
 
342
404
  // ❌ Incorrecto - Estado no inicializado
343
405
  const [dateRange, setDateRange] = useState();
@@ -355,9 +417,11 @@ const handleChange = (range: DateRange) => {
355
417
  };
356
418
 
357
419
  // ✅ Correcto - Mostrar feedback de validación
358
- {!dateRange.from || !dateRange.to ? (
359
- <p className="text-destructive">Please select both dates</p>
360
- ) : null}
420
+ {
421
+ !dateRange.from || !dateRange.to ? (
422
+ <p className="text-destructive">Please select both dates</p>
423
+ ) : null;
424
+ }
361
425
  ```
362
426
 
363
427
  ### Formateo de Fechas
@@ -366,7 +430,7 @@ const handleChange = (range: DateRange) => {
366
430
  import { format } from "date-fns";
367
431
 
368
432
  // ✅ Correcto - Formatear con date-fns
369
- const displayDate = dateRange.from
433
+ const displayDate = dateRange.from
370
434
  ? format(dateRange.from, "PP")
371
435
  : "Not selected";
372
436
 
@@ -425,5 +489,5 @@ const normalizedRange = {
425
489
 
426
490
  - **Combobox**: [Ver documentación](./combobox.md)
427
491
  - **Calendar**: [Ver documentación](./calendar.md)
428
- - **date-fns**: https://date-fns.org/
429
- - **react-day-picker**: https://react-day-picker.js.org/
492
+ - **date-fns**: <https://date-fns.org/>
493
+ - **react-day-picker**: <https://react-day-picker.js.org/>