@rubenpazch/checkbox-input 3.0.0 → 3.2.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 +36 -0
- package/dist/CheckboxInput.d.ts +8 -2
- package/dist/CheckboxInput.d.ts.map +1 -1
- package/dist/index.cjs.js +9 -6
- package/dist/index.d.ts +7 -2
- package/dist/index.esm.js +9 -6
- package/package.json +10 -3
package/README.md
CHANGED
|
@@ -1,3 +1,39 @@
|
|
|
1
1
|
# CheckboxInput
|
|
2
2
|
|
|
3
3
|
Generated component package.
|
|
4
|
+
|
|
5
|
+
<!-- catalogo:inicio (generado por pnpm catalogo, no editar) -->
|
|
6
|
+
|
|
7
|
+
Casilla de verificación con etiqueta, ayuda y error.
|
|
8
|
+
|
|
9
|
+
- **Usar cuando:** Opciones sí/no o selección múltiple independiente.
|
|
10
|
+
- **Evitar cuando:** Elegir una sola opción entre varias: usa RadioGroup.
|
|
11
|
+
|
|
12
|
+
Se recomienda instalar el paquete completo `@rubenpazch/ui` (incluye este). Por separado:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @rubenpazch/checkbox-input
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## CheckboxInput
|
|
19
|
+
|
|
20
|
+
Casilla de verificación con etiqueta, descripción y error.
|
|
21
|
+
|
|
22
|
+
| Prop | Tipo | Req. | Por defecto | Descripción |
|
|
23
|
+
| --------------- | -------------------------------------------------------------- | ---- | ----------- | ------------------------------------------------------- |
|
|
24
|
+
| `label` | `string` | sí | | |
|
|
25
|
+
| `checked` | `boolean` | | `false` | |
|
|
26
|
+
| `className` | `string` | | `` | |
|
|
27
|
+
| `description` | `string` | | | |
|
|
28
|
+
| `disabled` | `boolean` | | `false` | |
|
|
29
|
+
| `error` | `string` | | | |
|
|
30
|
+
| `id` | `string` | | | id del input; si no se pasa se genera uno estable. |
|
|
31
|
+
| `indeterminate` | `boolean` | | `false` | |
|
|
32
|
+
| `name` | `string` | | | name del input (formularios nativos, react-hook-form…). |
|
|
33
|
+
| `onChange` | `(checked: boolean) => void` | | | |
|
|
34
|
+
| `required` | `boolean` | | `false` | |
|
|
35
|
+
| `size` | `"sm" \| "md" \| "lg"` | | `md` | |
|
|
36
|
+
| `value` | `string` | | | Valor enviado con el formulario cuando está marcado. |
|
|
37
|
+
| `variant` | `"default" \| "primary" \| "success" \| "warning" \| "danger"` | | `default` | |
|
|
38
|
+
|
|
39
|
+
<!-- catalogo:fin -->
|
package/dist/CheckboxInput.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
type CheckboxSize = "sm" | "md" | "lg";
|
|
3
3
|
type CheckboxVariant = "default" | "primary" | "success" | "warning" | "danger";
|
|
4
|
-
interface CheckboxInputProps {
|
|
4
|
+
export interface CheckboxInputProps {
|
|
5
|
+
/** id del input; si no se pasa se genera uno estable. */
|
|
5
6
|
id?: string;
|
|
7
|
+
/** name del input (formularios nativos, react-hook-form…). */
|
|
8
|
+
name?: string;
|
|
9
|
+
/** Valor enviado con el formulario cuando está marcado. */
|
|
10
|
+
value?: string;
|
|
6
11
|
label: string;
|
|
7
12
|
checked?: boolean;
|
|
8
13
|
onChange?: (checked: boolean) => void;
|
|
@@ -15,6 +20,7 @@ interface CheckboxInputProps {
|
|
|
15
20
|
variant?: CheckboxVariant;
|
|
16
21
|
indeterminate?: boolean;
|
|
17
22
|
}
|
|
18
|
-
|
|
23
|
+
/** Casilla de verificación con etiqueta, descripción y error. */
|
|
24
|
+
declare const CheckboxInput: React.ForwardRefExoticComponent<CheckboxInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
19
25
|
export default CheckboxInput;
|
|
20
26
|
//# sourceMappingURL=CheckboxInput.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxInput.d.ts","sourceRoot":"","sources":["../src/CheckboxInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"CheckboxInput.d.ts","sourceRoot":"","sources":["../src/CheckboxInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAIjD,KAAK,YAAY,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AACvC,KAAK,eAAe,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEhF,MAAM,WAAW,kBAAkB;IACjC,yDAAyD;IACzD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,8DAA8D;IAC9D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,2DAA2D;IAC3D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AA0CD,iEAAiE;AACjE,QAAA,MAAM,aAAa,6FA8FlB,CAAC;AAIF,eAAe,aAAa,CAAC"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var require$$0 = require('react');
|
|
4
|
+
var shared = require('@rubenpazch/shared');
|
|
4
5
|
|
|
5
6
|
var jsxRuntime = {exports: {}};
|
|
6
7
|
|
|
@@ -451,7 +452,7 @@ function styleInject(css, ref) {
|
|
|
451
452
|
}
|
|
452
453
|
}
|
|
453
454
|
|
|
454
|
-
var css_248z = ".CheckboxInput-module_wrapper__lJGfc {\n display: flex;\n align-items: flex-start;\n gap: 0.75rem;\n}\n\n.CheckboxInput-module_checkboxContainer__ou1mg {\n display: flex;\n align-items: center;\n}\n\n.CheckboxInput-module_containerSm__zAmsB {\n height: 1rem;\n}\n\n.CheckboxInput-module_containerMd__lXzhK {\n height: 1.25rem;\n}\n\n.CheckboxInput-module_containerLg__ckD4Q {\n height: 1.5rem;\n}\n\n.CheckboxInput-module_checkbox__lYmgh {\n border: 1px solid var(--lb-color-neutral-300);\n border-radius: 0.25rem;\n background: var(--lb-color-background);\n cursor: pointer;\n transition: all 150ms ease;\n accent-color: var(--checkbox-color, var(--lb-color-primary));\n}\n\n.CheckboxInput-module_checkbox__lYmgh:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px\n var(--focus-ring
|
|
455
|
+
var css_248z = ".CheckboxInput-module_wrapper__lJGfc {\n display: flex;\n align-items: flex-start;\n gap: 0.75rem;\n}\n\n.CheckboxInput-module_checkboxContainer__ou1mg {\n display: flex;\n align-items: center;\n}\n\n.CheckboxInput-module_containerSm__zAmsB {\n height: 1rem;\n}\n\n.CheckboxInput-module_containerMd__lXzhK {\n height: 1.25rem;\n}\n\n.CheckboxInput-module_containerLg__ckD4Q {\n height: 1.5rem;\n}\n\n.CheckboxInput-module_checkbox__lYmgh {\n border: 1px solid var(--lb-color-neutral-300);\n border-radius: 0.25rem;\n background: var(--lb-color-background);\n cursor: pointer;\n transition: all 150ms ease;\n accent-color: var(--checkbox-color, var(--lb-color-primary));\n}\n\n.CheckboxInput-module_checkbox__lYmgh:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px\n var(\n --focus-ring,\n color-mix(in srgb, var(--lb-color-primary) 30%, transparent)\n );\n}\n\n.CheckboxInput-module_checkboxDisabled__B4hsr {\n background: var(--lb-color-muted);\n cursor: not-allowed;\n opacity: 0.6;\n}\n\n.CheckboxInput-module_checkboxError__IAnd9 {\n border-color: var(--lb-color-danger);\n}\n\n.CheckboxInput-module_checkboxSm__h9Yfl {\n width: 0.75rem;\n height: 0.75rem;\n}\n\n.CheckboxInput-module_checkboxMd__Xn47v {\n width: 1rem;\n height: 1rem;\n}\n\n.CheckboxInput-module_checkboxLg__31itM {\n width: 1.25rem;\n height: 1.25rem;\n}\n\n.CheckboxInput-module_variantDefault__kOFV4 {\n --checkbox-color: var(--lb-color-primary);\n --focus-ring: color-mix(in srgb, var(--lb-color-primary) 30%, transparent);\n}\n\n.CheckboxInput-module_variantPrimary__oOcxM {\n --checkbox-color: var(--lb-color-indigo-accent);\n --focus-ring: rgba(79, 70, 229, 0.3);\n}\n\n.CheckboxInput-module_variantSuccess__Do-4i {\n --checkbox-color: var(--lb-color-success);\n --focus-ring: color-mix(in srgb, var(--lb-color-success) 30%, transparent);\n}\n\n.CheckboxInput-module_variantWarning__3-Z0F {\n --checkbox-color: var(--lb-color-warning);\n --focus-ring: color-mix(in srgb, var(--lb-color-warning) 30%, transparent);\n}\n\n.CheckboxInput-module_variantDanger__617R7 {\n --checkbox-color: var(--lb-color-danger);\n --focus-ring: color-mix(in srgb, var(--lb-color-danger) 30%, transparent);\n}\n\n.CheckboxInput-module_content__Qf9er {\n display: flex;\n flex-direction: column;\n}\n\n.CheckboxInput-module_label__rdC0e {\n font-weight: 500;\n}\n\n.CheckboxInput-module_labelSm__8m4I8 {\n font-size: 0.75rem;\n line-height: 1rem;\n}\n\n.CheckboxInput-module_labelMd__LpiV4 {\n font-size: 0.875rem;\n line-height: 1.25rem;\n}\n\n.CheckboxInput-module_labelLg__CZ1q0 {\n font-size: 1rem;\n line-height: 1.5rem;\n}\n\n.CheckboxInput-module_labelNormal__DxrKv {\n color: var(--lb-color-neutral-700);\n cursor: pointer;\n}\n\n.CheckboxInput-module_labelDisabled__wUItt {\n color: var(--lb-color-muted-foreground);\n cursor: not-allowed;\n}\n\n.CheckboxInput-module_required__hNTK3 {\n color: var(--lb-color-red-accent);\n margin-left: 0.25rem;\n}\n\n.CheckboxInput-module_description__cwaQ6 {\n color: var(--lb-color-neutral-500);\n margin-top: 0.25rem;\n}\n\n.CheckboxInput-module_descriptionSm__cdniJ {\n font-size: 0.625rem;\n line-height: 0.875rem;\n}\n\n.CheckboxInput-module_descriptionMd__21Bdi {\n font-size: 0.75rem;\n line-height: 1rem;\n}\n\n.CheckboxInput-module_descriptionLg__qCwRF {\n font-size: 0.875rem;\n line-height: 1.25rem;\n}\n\n.CheckboxInput-module_errorText__r7ffs {\n margin-top: 0.25rem;\n font-size: 0.75rem;\n line-height: 1rem;\n color: var(--lb-color-danger);\n}\n";
|
|
455
456
|
var styles = {"wrapper":"CheckboxInput-module_wrapper__lJGfc","checkboxContainer":"CheckboxInput-module_checkboxContainer__ou1mg","containerSm":"CheckboxInput-module_containerSm__zAmsB","containerMd":"CheckboxInput-module_containerMd__lXzhK","containerLg":"CheckboxInput-module_containerLg__ckD4Q","checkbox":"CheckboxInput-module_checkbox__lYmgh","checkboxDisabled":"CheckboxInput-module_checkboxDisabled__B4hsr","checkboxError":"CheckboxInput-module_checkboxError__IAnd9","checkboxSm":"CheckboxInput-module_checkboxSm__h9Yfl","checkboxMd":"CheckboxInput-module_checkboxMd__Xn47v","checkboxLg":"CheckboxInput-module_checkboxLg__31itM","variantDefault":"CheckboxInput-module_variantDefault__kOFV4","variantPrimary":"CheckboxInput-module_variantPrimary__oOcxM","variantSuccess":"CheckboxInput-module_variantSuccess__Do-4i","variantWarning":"CheckboxInput-module_variantWarning__3-Z0F","variantDanger":"CheckboxInput-module_variantDanger__617R7","content":"CheckboxInput-module_content__Qf9er","label":"CheckboxInput-module_label__rdC0e","labelSm":"CheckboxInput-module_labelSm__8m4I8","labelMd":"CheckboxInput-module_labelMd__LpiV4","labelLg":"CheckboxInput-module_labelLg__CZ1q0","labelNormal":"CheckboxInput-module_labelNormal__DxrKv","labelDisabled":"CheckboxInput-module_labelDisabled__wUItt","required":"CheckboxInput-module_required__hNTK3","description":"CheckboxInput-module_description__cwaQ6","descriptionSm":"CheckboxInput-module_descriptionSm__cdniJ","descriptionMd":"CheckboxInput-module_descriptionMd__21Bdi","descriptionLg":"CheckboxInput-module_descriptionLg__qCwRF","errorText":"CheckboxInput-module_errorText__r7ffs"};
|
|
456
457
|
styleInject(css_248z);
|
|
457
458
|
|
|
@@ -483,8 +484,9 @@ const variantClasses = {
|
|
|
483
484
|
danger: styles.variantDanger,
|
|
484
485
|
};
|
|
485
486
|
const classNames = (...classes) => classes.filter(Boolean).join(" ");
|
|
486
|
-
|
|
487
|
-
|
|
487
|
+
/** Casilla de verificación con etiqueta, descripción y error. */
|
|
488
|
+
const CheckboxInput = require$$0.forwardRef(function CheckboxInput({ id, name, value, label, checked = false, onChange, disabled = false, description, error, className = "", required = false, size = "md", variant = "default", indeterminate = false, }, ref) {
|
|
489
|
+
const field = shared.useFieldIds({ id, name, required, error, hint: description });
|
|
488
490
|
const sizeConfig = sizeClasses[size];
|
|
489
491
|
const variantConfig = variantClasses[variant];
|
|
490
492
|
const checkboxRef = require$$0.useRef(null);
|
|
@@ -493,12 +495,13 @@ const CheckboxInput = ({ id, label, checked = false, onChange, disabled = false,
|
|
|
493
495
|
checkboxRef.current.indeterminate = indeterminate;
|
|
494
496
|
}
|
|
495
497
|
}, [indeterminate]);
|
|
496
|
-
return (jsxRuntimeExports.jsxs("div", { className: classNames(styles.wrapper, className), children: [jsxRuntimeExports.jsx("div", { className: classNames(styles.checkboxContainer, sizeConfig.container), children: jsxRuntimeExports.jsx("input", { ref: checkboxRef,
|
|
498
|
+
return (jsxRuntimeExports.jsxs("div", { className: classNames(styles.wrapper, className), children: [jsxRuntimeExports.jsx("div", { className: classNames(styles.checkboxContainer, sizeConfig.container), children: jsxRuntimeExports.jsx("input", { ref: shared.mergeRefs(checkboxRef, ref), ...field.controlProps, name: name, value: value, type: "checkbox", checked: checked, "aria-checked": indeterminate ? "mixed" : undefined, onChange: (e) => {
|
|
497
499
|
if (disabled) {
|
|
498
500
|
return;
|
|
499
501
|
}
|
|
500
502
|
onChange?.(e.target.checked);
|
|
501
|
-
}, disabled: disabled, className: classNames(styles.checkbox, sizeConfig.checkbox, variantConfig, disabled && styles.checkboxDisabled, error && styles.checkboxError), required: required }) }), jsxRuntimeExports.jsxs("div", { className: styles.content, children: [jsxRuntimeExports.jsxs("label", { htmlFor: inputId, className: classNames(styles.label, sizeConfig.label, disabled ? styles.labelDisabled : styles.labelNormal), children: [label, required && jsxRuntimeExports.jsx("span", { className: styles.required, children: "*" })] }), description && (jsxRuntimeExports.jsx("p", { className: classNames(styles.description, sizeConfig.description), children: description })), error && jsxRuntimeExports.jsx("p", { className: styles.errorText, children: error })] })] }));
|
|
502
|
-
};
|
|
503
|
+
}, disabled: disabled, className: classNames(styles.checkbox, sizeConfig.checkbox, variantConfig, disabled && styles.checkboxDisabled, error && styles.checkboxError), required: required }) }), jsxRuntimeExports.jsxs("div", { className: styles.content, children: [jsxRuntimeExports.jsxs("label", { htmlFor: field.inputId, className: classNames(styles.label, sizeConfig.label, disabled ? styles.labelDisabled : styles.labelNormal), children: [label, required && (jsxRuntimeExports.jsx("span", { className: styles.required, "aria-hidden": "true", children: "*" }))] }), description && (jsxRuntimeExports.jsx("p", { id: field.hintId, className: classNames(styles.description, sizeConfig.description), children: description })), error && (jsxRuntimeExports.jsx("p", { id: field.errorId, className: styles.errorText, role: "alert", children: error }))] })] }));
|
|
504
|
+
});
|
|
505
|
+
CheckboxInput.displayName = "CheckboxInput";
|
|
503
506
|
|
|
504
507
|
module.exports = CheckboxInput;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,12 @@ import React from 'react';
|
|
|
3
3
|
type CheckboxSize = "sm" | "md" | "lg";
|
|
4
4
|
type CheckboxVariant = "default" | "primary" | "success" | "warning" | "danger";
|
|
5
5
|
interface CheckboxInputProps {
|
|
6
|
+
/** id del input; si no se pasa se genera uno estable. */
|
|
6
7
|
id?: string;
|
|
8
|
+
/** name del input (formularios nativos, react-hook-form…). */
|
|
9
|
+
name?: string;
|
|
10
|
+
/** Valor enviado con el formulario cuando está marcado. */
|
|
11
|
+
value?: string;
|
|
7
12
|
label: string;
|
|
8
13
|
checked?: boolean;
|
|
9
14
|
onChange?: (checked: boolean) => void;
|
|
@@ -16,7 +21,7 @@ interface CheckboxInputProps {
|
|
|
16
21
|
variant?: CheckboxVariant;
|
|
17
22
|
indeterminate?: boolean;
|
|
18
23
|
}
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
/** Casilla de verificación con etiqueta, descripción y error. */
|
|
25
|
+
declare const CheckboxInput: React.ForwardRefExoticComponent<CheckboxInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
21
26
|
|
|
22
27
|
export { CheckboxInput as default };
|
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import require$$0, { useRef, useEffect } from 'react';
|
|
2
|
+
import { useFieldIds, mergeRefs } from '@rubenpazch/shared';
|
|
2
3
|
|
|
3
4
|
var jsxRuntime = {exports: {}};
|
|
4
5
|
|
|
@@ -449,7 +450,7 @@ function styleInject(css, ref) {
|
|
|
449
450
|
}
|
|
450
451
|
}
|
|
451
452
|
|
|
452
|
-
var css_248z = ".CheckboxInput-module_wrapper__lJGfc {\n display: flex;\n align-items: flex-start;\n gap: 0.75rem;\n}\n\n.CheckboxInput-module_checkboxContainer__ou1mg {\n display: flex;\n align-items: center;\n}\n\n.CheckboxInput-module_containerSm__zAmsB {\n height: 1rem;\n}\n\n.CheckboxInput-module_containerMd__lXzhK {\n height: 1.25rem;\n}\n\n.CheckboxInput-module_containerLg__ckD4Q {\n height: 1.5rem;\n}\n\n.CheckboxInput-module_checkbox__lYmgh {\n border: 1px solid var(--lb-color-neutral-300);\n border-radius: 0.25rem;\n background: var(--lb-color-background);\n cursor: pointer;\n transition: all 150ms ease;\n accent-color: var(--checkbox-color, var(--lb-color-primary));\n}\n\n.CheckboxInput-module_checkbox__lYmgh:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px\n var(--focus-ring
|
|
453
|
+
var css_248z = ".CheckboxInput-module_wrapper__lJGfc {\n display: flex;\n align-items: flex-start;\n gap: 0.75rem;\n}\n\n.CheckboxInput-module_checkboxContainer__ou1mg {\n display: flex;\n align-items: center;\n}\n\n.CheckboxInput-module_containerSm__zAmsB {\n height: 1rem;\n}\n\n.CheckboxInput-module_containerMd__lXzhK {\n height: 1.25rem;\n}\n\n.CheckboxInput-module_containerLg__ckD4Q {\n height: 1.5rem;\n}\n\n.CheckboxInput-module_checkbox__lYmgh {\n border: 1px solid var(--lb-color-neutral-300);\n border-radius: 0.25rem;\n background: var(--lb-color-background);\n cursor: pointer;\n transition: all 150ms ease;\n accent-color: var(--checkbox-color, var(--lb-color-primary));\n}\n\n.CheckboxInput-module_checkbox__lYmgh:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px\n var(\n --focus-ring,\n color-mix(in srgb, var(--lb-color-primary) 30%, transparent)\n );\n}\n\n.CheckboxInput-module_checkboxDisabled__B4hsr {\n background: var(--lb-color-muted);\n cursor: not-allowed;\n opacity: 0.6;\n}\n\n.CheckboxInput-module_checkboxError__IAnd9 {\n border-color: var(--lb-color-danger);\n}\n\n.CheckboxInput-module_checkboxSm__h9Yfl {\n width: 0.75rem;\n height: 0.75rem;\n}\n\n.CheckboxInput-module_checkboxMd__Xn47v {\n width: 1rem;\n height: 1rem;\n}\n\n.CheckboxInput-module_checkboxLg__31itM {\n width: 1.25rem;\n height: 1.25rem;\n}\n\n.CheckboxInput-module_variantDefault__kOFV4 {\n --checkbox-color: var(--lb-color-primary);\n --focus-ring: color-mix(in srgb, var(--lb-color-primary) 30%, transparent);\n}\n\n.CheckboxInput-module_variantPrimary__oOcxM {\n --checkbox-color: var(--lb-color-indigo-accent);\n --focus-ring: rgba(79, 70, 229, 0.3);\n}\n\n.CheckboxInput-module_variantSuccess__Do-4i {\n --checkbox-color: var(--lb-color-success);\n --focus-ring: color-mix(in srgb, var(--lb-color-success) 30%, transparent);\n}\n\n.CheckboxInput-module_variantWarning__3-Z0F {\n --checkbox-color: var(--lb-color-warning);\n --focus-ring: color-mix(in srgb, var(--lb-color-warning) 30%, transparent);\n}\n\n.CheckboxInput-module_variantDanger__617R7 {\n --checkbox-color: var(--lb-color-danger);\n --focus-ring: color-mix(in srgb, var(--lb-color-danger) 30%, transparent);\n}\n\n.CheckboxInput-module_content__Qf9er {\n display: flex;\n flex-direction: column;\n}\n\n.CheckboxInput-module_label__rdC0e {\n font-weight: 500;\n}\n\n.CheckboxInput-module_labelSm__8m4I8 {\n font-size: 0.75rem;\n line-height: 1rem;\n}\n\n.CheckboxInput-module_labelMd__LpiV4 {\n font-size: 0.875rem;\n line-height: 1.25rem;\n}\n\n.CheckboxInput-module_labelLg__CZ1q0 {\n font-size: 1rem;\n line-height: 1.5rem;\n}\n\n.CheckboxInput-module_labelNormal__DxrKv {\n color: var(--lb-color-neutral-700);\n cursor: pointer;\n}\n\n.CheckboxInput-module_labelDisabled__wUItt {\n color: var(--lb-color-muted-foreground);\n cursor: not-allowed;\n}\n\n.CheckboxInput-module_required__hNTK3 {\n color: var(--lb-color-red-accent);\n margin-left: 0.25rem;\n}\n\n.CheckboxInput-module_description__cwaQ6 {\n color: var(--lb-color-neutral-500);\n margin-top: 0.25rem;\n}\n\n.CheckboxInput-module_descriptionSm__cdniJ {\n font-size: 0.625rem;\n line-height: 0.875rem;\n}\n\n.CheckboxInput-module_descriptionMd__21Bdi {\n font-size: 0.75rem;\n line-height: 1rem;\n}\n\n.CheckboxInput-module_descriptionLg__qCwRF {\n font-size: 0.875rem;\n line-height: 1.25rem;\n}\n\n.CheckboxInput-module_errorText__r7ffs {\n margin-top: 0.25rem;\n font-size: 0.75rem;\n line-height: 1rem;\n color: var(--lb-color-danger);\n}\n";
|
|
453
454
|
var styles = {"wrapper":"CheckboxInput-module_wrapper__lJGfc","checkboxContainer":"CheckboxInput-module_checkboxContainer__ou1mg","containerSm":"CheckboxInput-module_containerSm__zAmsB","containerMd":"CheckboxInput-module_containerMd__lXzhK","containerLg":"CheckboxInput-module_containerLg__ckD4Q","checkbox":"CheckboxInput-module_checkbox__lYmgh","checkboxDisabled":"CheckboxInput-module_checkboxDisabled__B4hsr","checkboxError":"CheckboxInput-module_checkboxError__IAnd9","checkboxSm":"CheckboxInput-module_checkboxSm__h9Yfl","checkboxMd":"CheckboxInput-module_checkboxMd__Xn47v","checkboxLg":"CheckboxInput-module_checkboxLg__31itM","variantDefault":"CheckboxInput-module_variantDefault__kOFV4","variantPrimary":"CheckboxInput-module_variantPrimary__oOcxM","variantSuccess":"CheckboxInput-module_variantSuccess__Do-4i","variantWarning":"CheckboxInput-module_variantWarning__3-Z0F","variantDanger":"CheckboxInput-module_variantDanger__617R7","content":"CheckboxInput-module_content__Qf9er","label":"CheckboxInput-module_label__rdC0e","labelSm":"CheckboxInput-module_labelSm__8m4I8","labelMd":"CheckboxInput-module_labelMd__LpiV4","labelLg":"CheckboxInput-module_labelLg__CZ1q0","labelNormal":"CheckboxInput-module_labelNormal__DxrKv","labelDisabled":"CheckboxInput-module_labelDisabled__wUItt","required":"CheckboxInput-module_required__hNTK3","description":"CheckboxInput-module_description__cwaQ6","descriptionSm":"CheckboxInput-module_descriptionSm__cdniJ","descriptionMd":"CheckboxInput-module_descriptionMd__21Bdi","descriptionLg":"CheckboxInput-module_descriptionLg__qCwRF","errorText":"CheckboxInput-module_errorText__r7ffs"};
|
|
454
455
|
styleInject(css_248z);
|
|
455
456
|
|
|
@@ -481,8 +482,9 @@ const variantClasses = {
|
|
|
481
482
|
danger: styles.variantDanger,
|
|
482
483
|
};
|
|
483
484
|
const classNames = (...classes) => classes.filter(Boolean).join(" ");
|
|
484
|
-
|
|
485
|
-
|
|
485
|
+
/** Casilla de verificación con etiqueta, descripción y error. */
|
|
486
|
+
const CheckboxInput = require$$0.forwardRef(function CheckboxInput({ id, name, value, label, checked = false, onChange, disabled = false, description, error, className = "", required = false, size = "md", variant = "default", indeterminate = false, }, ref) {
|
|
487
|
+
const field = useFieldIds({ id, name, required, error, hint: description });
|
|
486
488
|
const sizeConfig = sizeClasses[size];
|
|
487
489
|
const variantConfig = variantClasses[variant];
|
|
488
490
|
const checkboxRef = useRef(null);
|
|
@@ -491,12 +493,13 @@ const CheckboxInput = ({ id, label, checked = false, onChange, disabled = false,
|
|
|
491
493
|
checkboxRef.current.indeterminate = indeterminate;
|
|
492
494
|
}
|
|
493
495
|
}, [indeterminate]);
|
|
494
|
-
return (jsxRuntimeExports.jsxs("div", { className: classNames(styles.wrapper, className), children: [jsxRuntimeExports.jsx("div", { className: classNames(styles.checkboxContainer, sizeConfig.container), children: jsxRuntimeExports.jsx("input", { ref: checkboxRef,
|
|
496
|
+
return (jsxRuntimeExports.jsxs("div", { className: classNames(styles.wrapper, className), children: [jsxRuntimeExports.jsx("div", { className: classNames(styles.checkboxContainer, sizeConfig.container), children: jsxRuntimeExports.jsx("input", { ref: mergeRefs(checkboxRef, ref), ...field.controlProps, name: name, value: value, type: "checkbox", checked: checked, "aria-checked": indeterminate ? "mixed" : undefined, onChange: (e) => {
|
|
495
497
|
if (disabled) {
|
|
496
498
|
return;
|
|
497
499
|
}
|
|
498
500
|
onChange?.(e.target.checked);
|
|
499
|
-
}, disabled: disabled, className: classNames(styles.checkbox, sizeConfig.checkbox, variantConfig, disabled && styles.checkboxDisabled, error && styles.checkboxError), required: required }) }), jsxRuntimeExports.jsxs("div", { className: styles.content, children: [jsxRuntimeExports.jsxs("label", { htmlFor: inputId, className: classNames(styles.label, sizeConfig.label, disabled ? styles.labelDisabled : styles.labelNormal), children: [label, required && jsxRuntimeExports.jsx("span", { className: styles.required, children: "*" })] }), description && (jsxRuntimeExports.jsx("p", { className: classNames(styles.description, sizeConfig.description), children: description })), error && jsxRuntimeExports.jsx("p", { className: styles.errorText, children: error })] })] }));
|
|
500
|
-
};
|
|
501
|
+
}, disabled: disabled, className: classNames(styles.checkbox, sizeConfig.checkbox, variantConfig, disabled && styles.checkboxDisabled, error && styles.checkboxError), required: required }) }), jsxRuntimeExports.jsxs("div", { className: styles.content, children: [jsxRuntimeExports.jsxs("label", { htmlFor: field.inputId, className: classNames(styles.label, sizeConfig.label, disabled ? styles.labelDisabled : styles.labelNormal), children: [label, required && (jsxRuntimeExports.jsx("span", { className: styles.required, "aria-hidden": "true", children: "*" }))] }), description && (jsxRuntimeExports.jsx("p", { id: field.hintId, className: classNames(styles.description, sizeConfig.description), children: description })), error && (jsxRuntimeExports.jsx("p", { id: field.errorId, className: styles.errorText, role: "alert", children: error }))] })] }));
|
|
502
|
+
});
|
|
503
|
+
CheckboxInput.displayName = "CheckboxInput";
|
|
501
504
|
|
|
502
505
|
export { CheckboxInput as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rubenpazch/checkbox-input",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "CheckboxInput component",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "dist/index.cjs.js",
|
|
@@ -29,10 +29,11 @@
|
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"react": "^19.0.0",
|
|
31
31
|
"react-dom": "^19.0.0",
|
|
32
|
-
"@rubenpazch/tokens": "0.
|
|
32
|
+
"@rubenpazch/tokens": "0.4.0"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@rubenpazch/button": "6.
|
|
35
|
+
"@rubenpazch/button": "6.2.0",
|
|
36
|
+
"@rubenpazch/shared": "5.2.0"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
39
|
"@rubenpazch/typescript-config": "3.0.0"
|
|
@@ -40,6 +41,12 @@
|
|
|
40
41
|
"publishConfig": {
|
|
41
42
|
"access": "public"
|
|
42
43
|
},
|
|
44
|
+
"lbyte": {
|
|
45
|
+
"categoria": "formularios",
|
|
46
|
+
"resumen": "Casilla de verificación con etiqueta, ayuda y error.",
|
|
47
|
+
"usarCuando": "Opciones sí/no o selección múltiple independiente.",
|
|
48
|
+
"evitarCuando": "Elegir una sola opción entre varias: usa RadioGroup."
|
|
49
|
+
},
|
|
43
50
|
"scripts": {
|
|
44
51
|
"build": "rollup -c",
|
|
45
52
|
"test": "jest --passWithNoTests"
|