corekit-ui 0.1.16 → 0.1.19

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.
@@ -7,6 +7,7 @@ export declare const Checkbox: React.ForwardRefExoticComponent<{
7
7
  isIndeterminate?: boolean;
8
8
  isDisabled?: boolean;
9
9
  isReadOnly?: boolean;
10
+ isRequired?: boolean;
10
11
  size?: import('./types').CheckboxSize;
11
12
  color?: import('./types').CheckboxColor;
12
13
  customColor?: string;
@@ -1,2 +1,11 @@
1
- import { CheckboxGroupProps } from './types';
2
- export declare const CheckboxGroup: ({ label, children, description, errorMessage, isInvalid, orientation, className, value: controlledValue, defaultValue, onChange, isDisabled, isReadOnly, name, }: CheckboxGroupProps) => import("react/jsx-runtime").JSX.Element;
1
+ import { CheckboxGroupProps, CheckboxOptionBase } from './types';
2
+ /**
3
+ * Componente CheckboxGroup genérico con soporte para opciones tipadas.
4
+ * La coma <T,> es necesaria en arrow functions .tsx para que no se confunda con un tag HTML.
5
+ *
6
+ * @template T - Tipo de las opciones (string, number u objeto)
7
+ */
8
+ export declare const CheckboxGroup: {
9
+ <T extends CheckboxOptionBase>({ label, children, description, errorMessage, isInvalid, orientation, className, value: controlledValue, defaultValue, onChange, isDisabled, isReadOnly, isRequired, name, options, optionValueKey, optionLabelKey, optionDisabledKey, optionDescriptionKey, }: CheckboxGroupProps<T>): import("react/jsx-runtime").JSX.Element;
10
+ displayName: string;
11
+ };
@@ -18,6 +18,7 @@ export type CheckboxProps = {
18
18
  isIndeterminate?: boolean;
19
19
  isDisabled?: boolean;
20
20
  isReadOnly?: boolean;
21
+ isRequired?: boolean;
21
22
  size?: CheckboxSize;
22
23
  color?: CheckboxColor;
23
24
  customColor?: string;
@@ -38,20 +39,70 @@ export type CheckboxGroupContextValue = {
38
39
  onChange: (value: string) => void;
39
40
  isDisabled?: boolean;
40
41
  isReadOnly?: boolean;
42
+ isRequired?: boolean;
41
43
  name?: string;
42
44
  };
43
- export type CheckboxGroupProps = {
45
+ /**
46
+ * Tipo auxiliar para opciones primitivas u objetos.
47
+ * Usado como constraint para el genérico T en CheckboxGroupProps.
48
+ */
49
+ export type CheckboxOptionBase = string | number | Record<string, unknown>;
50
+ /**
51
+ * Props del componente CheckboxGroup con soporte genérico.
52
+ * @template T - Tipo de las opciones (string, number u objeto)
53
+ */
54
+ export type CheckboxGroupProps<T extends CheckboxOptionBase = string> = {
55
+ /** Label del grupo */
44
56
  label?: ReactNode;
45
- children: ReactNode;
57
+ /** Children (Checkbox individuales). Si se pasa `options`, children se ignora */
58
+ children?: ReactNode;
59
+ /** Descripción del grupo */
46
60
  description?: ReactNode;
61
+ /** Mensaje de error */
47
62
  errorMessage?: ReactNode;
63
+ /** Si el grupo tiene error de validación */
48
64
  isInvalid?: boolean;
65
+ /** Orientación del grupo */
49
66
  orientation?: CheckboxOrientation;
67
+ /** Clase CSS adicional */
50
68
  className?: string;
69
+ /** Valores seleccionados (modo controlado) */
51
70
  value?: string[];
71
+ /** Valores por defecto (modo no controlado) */
52
72
  defaultValue?: string[];
73
+ /** Callback cuando cambian los valores seleccionados */
53
74
  onChange?: (value: string[]) => void;
75
+ /** Si el grupo está deshabilitado */
54
76
  isDisabled?: boolean;
77
+ /** Si el grupo está en modo solo lectura */
55
78
  isReadOnly?: boolean;
79
+ /** Si el grupo es requerido */
80
+ isRequired?: boolean;
81
+ /** Nombre del grupo para formularios */
56
82
  name?: string;
83
+ /**
84
+ * Array de opciones para generar checkboxes automáticamente.
85
+ * Puede ser un array de strings/numbers o un array de objetos.
86
+ */
87
+ options?: T[];
88
+ /**
89
+ * Campo del objeto a usar como valor único (key).
90
+ * @default 'value'
91
+ */
92
+ optionValueKey?: keyof T;
93
+ /**
94
+ * Campo del objeto a usar como etiqueta visible.
95
+ * @default 'label'
96
+ */
97
+ optionLabelKey?: keyof T;
98
+ /**
99
+ * Campo del objeto a usar para determinar si está deshabilitada.
100
+ * @default 'isDisabled'
101
+ */
102
+ optionDisabledKey?: keyof T;
103
+ /**
104
+ * Campo del objeto a usar como descripción/hint.
105
+ * @default 'description'
106
+ */
107
+ optionDescriptionKey?: keyof T;
57
108
  };