@rubenpazch/checkbox-input 3.2.5 → 3.4.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 CHANGED
@@ -4,10 +4,10 @@ Generated component package.
4
4
 
5
5
  <!-- catalogo:inicio (generado por pnpm catalogo, no editar) -->
6
6
 
7
- Casilla de verificación con etiqueta, ayuda y error.
7
+ Casilla de verificación con etiqueta, ayuda y error (CheckboxInput) y grupo de casillas con título, "Seleccionar todos" y máximo (CheckboxGroup).
8
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.
9
+ - **Usar cuando:** Opciones sí/no (CheckboxInput) o elegir varias opciones de una lista corta: permisos, días, especialidades (CheckboxGroup).
10
+ - **Evitar cuando:** Elegir una sola opción entre varias: usa RadioGroup. Listas largas o con búsqueda: usa Autocomplete. Activar/desactivar algo al instante: usa Switch.
11
11
 
12
12
  Se recomienda instalar el paquete completo `@rubenpazch/ui` (incluye este). Por separado:
13
13
 
@@ -36,6 +36,33 @@ Casilla de verificación con etiqueta, descripción y error.
36
36
  | `value` | `string` | | | Valor enviado con el formulario cuando está marcado. |
37
37
  | `variant` | `"default" \| "primary" \| "success" \| "warning" \| "danger"` | | `default` | |
38
38
 
39
- Tipos: `CheckboxInputProps`.
39
+ ## CheckboxGroup
40
+
41
+ Grupo de casillas con título (`fieldset`/`legend`), ayuda y error: para elegir varias
42
+ opciones de una lista corta (permisos, días, especialidades).
43
+
44
+ | Prop | Tipo | Req. | Por defecto | Descripción |
45
+ | ------------- | -------------------------------------------------------------- | ---- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
46
+ | `label` | `string` | sí | | Título del grupo (se muestra como `<legend>` del `<fieldset>`). |
47
+ | `onChange` | `(value: string[]) => void` | sí | | Recibe la nueva lista de valores marcados (en el orden de `options`). |
48
+ | `options` | `CheckboxOption[]` | sí | | Opciones del grupo. |
49
+ | `value` | `string[]` | sí | | Valores marcados. |
50
+ | `className` | `string` | | | Clase extra del contenedor. |
51
+ | `columns` | `2 \| 3 \| 4` | | | Columnas en pantallas desde 640px (en móvil siempre 1). Ignora `orientation`. |
52
+ | `disabled` | `boolean` | | `false` | Deshabilita todo el grupo. |
53
+ | `error` | `string` | | | Mensaje de error del grupo. |
54
+ | `hideLabel` | `boolean` | | `false` | Ocultar el título visualmente (sigue disponible para lectores de pantalla). |
55
+ | `hint` | `string` | | | Texto de ayuda bajo el título. |
56
+ | `id` | `string` | | | id del fieldset; si no se pasa se genera uno. |
57
+ | `labels` | `Partial<{ selectAll: string; }>` | | | Textos de la interfaz. Por defecto, los del idioma activo (`UiLocaleProvider`); también se cambian para toda la app con su prop `messages`. |
58
+ | `maxSelected` | `number` | | | Máximo de opciones marcadas: al llegar, las demás se deshabilitan. |
59
+ | `name` | `string` | | | name de cada casilla (formularios nativos: se envía una vez por valor marcado). |
60
+ | `orientation` | `"vertical" \| "horizontal"` | | `vertical` | `vertical` (por defecto) o `horizontal` (se ajusta a la siguiente línea). |
61
+ | `required` | `boolean` | | `false` | Marca el grupo como obligatorio (muestra *); la validación "al menos uno" va en `error`. |
62
+ | `selectAll` | `boolean \| string` | | `false` | Agrega una casilla "Seleccionar todos" (queda indeterminada si hay algunas marcadas). `true` usa el texto por defecto; un texto lo reemplaza. |
63
+ | `size` | `"sm" \| "md" \| "lg"` | | `md` | Tamaño de las casillas. |
64
+ | `variant` | `"default" \| "primary" \| "success" \| "warning" \| "danger"` | | `primary` | Color de las casillas marcadas. |
65
+
66
+ Tipos: `CheckboxInputProps`, `CheckboxGroupProps`, `CheckboxOption`.
40
67
 
41
68
  <!-- catalogo:fin -->
@@ -0,0 +1,64 @@
1
+ import React from "react";
2
+ import { type UiMessages } from "@rubenpazch/shared";
3
+ export interface CheckboxOption {
4
+ /** Texto visible de la casilla. */
5
+ label: string;
6
+ /** Valor que se agrega a la lista al marcarla. */
7
+ value: string;
8
+ /** Texto secundario bajo la etiqueta. */
9
+ description?: string;
10
+ /** Deshabilita solo esta casilla. */
11
+ disabled?: boolean;
12
+ }
13
+ export interface CheckboxGroupProps {
14
+ /** Título del grupo (se muestra como `<legend>` del `<fieldset>`). */
15
+ label: string;
16
+ /** Opciones del grupo. */
17
+ options: CheckboxOption[];
18
+ /** Valores marcados. */
19
+ value: string[];
20
+ /** Recibe la nueva lista de valores marcados (en el orden de `options`). */
21
+ onChange: (value: string[]) => void;
22
+ /** name de cada casilla (formularios nativos: se envía una vez por valor marcado). */
23
+ name?: string;
24
+ /** `vertical` (por defecto) o `horizontal` (se ajusta a la siguiente línea). */
25
+ orientation?: "vertical" | "horizontal";
26
+ /** Columnas en pantallas desde 640px (en móvil siempre 1). Ignora `orientation`. */
27
+ columns?: 2 | 3 | 4;
28
+ /** Tamaño de las casillas. */
29
+ size?: "sm" | "md" | "lg";
30
+ /** Color de las casillas marcadas. */
31
+ variant?: "default" | "primary" | "success" | "warning" | "danger";
32
+ /** Deshabilita todo el grupo. */
33
+ disabled?: boolean;
34
+ /** Marca el grupo como obligatorio (muestra *); la validación "al menos uno" va en `error`. */
35
+ required?: boolean;
36
+ /** Texto de ayuda bajo el título. */
37
+ hint?: string;
38
+ /** Mensaje de error del grupo. */
39
+ error?: string;
40
+ /**
41
+ * Agrega una casilla "Seleccionar todos" (queda indeterminada si hay algunas marcadas).
42
+ * `true` usa el texto por defecto; un texto lo reemplaza.
43
+ */
44
+ selectAll?: boolean | string;
45
+ /** Máximo de opciones marcadas: al llegar, las demás se deshabilitan. */
46
+ maxSelected?: number;
47
+ /** Ocultar el título visualmente (sigue disponible para lectores de pantalla). */
48
+ hideLabel?: boolean;
49
+ /** Clase extra del contenedor. */
50
+ className?: string;
51
+ /** id del fieldset; si no se pasa se genera uno. */
52
+ id?: string;
53
+ /**
54
+ * Textos de la interfaz. Por defecto, los del idioma activo (`UiLocaleProvider`);
55
+ * también se cambian para toda la app con su prop `messages`.
56
+ */
57
+ labels?: Partial<UiMessages["checkboxGroup"]>;
58
+ }
59
+ /**
60
+ * Grupo de casillas con título (`fieldset`/`legend`), ayuda y error: para elegir varias
61
+ * opciones de una lista corta (permisos, días, especialidades).
62
+ */
63
+ export default function CheckboxGroup({ label, options, value, onChange, name, orientation, columns, size, variant, disabled, required, hint, error, selectAll, maxSelected, hideLabel, className, id, labels, }: CheckboxGroupProps): React.JSX.Element;
64
+ //# sourceMappingURL=CheckboxGroup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CheckboxGroup.d.ts","sourceRoot":"","sources":["../src/CheckboxGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIpE,MAAM,WAAW,cAAc;IAC7B,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,KAAK,EAAE,MAAM,CAAC;IACd,yCAAyC;IACzC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qCAAqC;IACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,kBAAkB;IACjC,sEAAsE;IACtE,KAAK,EAAE,MAAM,CAAC;IACd,0BAA0B;IAC1B,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,wBAAwB;IACxB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,4EAA4E;IAC5E,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACpC,sFAAsF;IACtF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gFAAgF;IAChF,WAAW,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC;IACxC,oFAAoF;IACpF,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACpB,8BAA8B;IAC9B,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,sCAAsC;IACtC,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;IACnE,iCAAiC;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,+FAA+F;IAC/F,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qCAAqC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kCAAkC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC7B,yEAAyE;IACzE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kFAAkF;IAClF,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,kCAAkC;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oDAAoD;IACpD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC;CAC/C;AAKD;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACpC,KAAK,EACL,OAAO,EACP,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,WAAwB,EACxB,OAAO,EACP,IAAW,EACX,OAAmB,EACnB,QAAgB,EAChB,QAAgB,EAChB,IAAI,EACJ,KAAK,EACL,SAAiB,EACjB,WAAW,EACX,SAAiB,EACjB,SAAS,EACT,EAAE,EACF,MAAM,GACP,EAAE,kBAAkB,qBAgHpB"}
package/dist/index.cjs.js CHANGED
@@ -1,6 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var require$$0 = require('react');
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
4
6
  var shared = require('@rubenpazch/shared');
5
7
 
6
8
  var jsxRuntime = {exports: {}};
@@ -339,7 +341,7 @@ function requireReactJsxRuntime_development () {
339
341
  object.$$typeof === REACT_ELEMENT_TYPE
340
342
  );
341
343
  }
342
- var React = require$$0,
344
+ var React$1 = React,
343
345
  REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
344
346
  REACT_PORTAL_TYPE = Symbol.for("react.portal"),
345
347
  REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
@@ -355,7 +357,7 @@ function requireReactJsxRuntime_development () {
355
357
  REACT_ACTIVITY_TYPE = Symbol.for("react.activity"),
356
358
  REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"),
357
359
  ReactSharedInternals =
358
- React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
360
+ React$1.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
359
361
  hasOwnProperty = Object.prototype.hasOwnProperty,
360
362
  isArrayImpl = Array.isArray,
361
363
  createTask = console.createTask
@@ -363,15 +365,15 @@ function requireReactJsxRuntime_development () {
363
365
  : function () {
364
366
  return null;
365
367
  };
366
- React = {
368
+ React$1 = {
367
369
  react_stack_bottom_frame: function (callStackForError) {
368
370
  return callStackForError();
369
371
  }
370
372
  };
371
373
  var specialPropKeyWarningShown;
372
374
  var didWarnAboutElementRef = {};
373
- var unknownOwnerDebugStack = React.react_stack_bottom_frame.bind(
374
- React,
375
+ var unknownOwnerDebugStack = React$1.react_stack_bottom_frame.bind(
376
+ React$1,
375
377
  UnknownOwner
376
378
  )();
377
379
  var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
@@ -429,7 +431,7 @@ function styleInject(css, ref) {
429
431
  if ( ref === void 0 ) ref = {};
430
432
  var insertAt = ref.insertAt;
431
433
 
432
- if (typeof document === 'undefined') { return; }
434
+ if (!css || typeof document === 'undefined') { return; }
433
435
 
434
436
  var head = document.head || document.getElementsByTagName('head')[0];
435
437
  var style = document.createElement('style');
@@ -452,56 +454,113 @@ function styleInject(css, ref) {
452
454
  }
453
455
  }
454
456
 
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";
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"};
457
- styleInject(css_248z);
457
+ var css_248z$1 = ".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";
458
+ var styles$1 = {"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"};
459
+ styleInject(css_248z$1);
458
460
 
459
461
  const sizeClasses = {
460
462
  sm: {
461
- checkbox: styles.checkboxSm,
462
- label: styles.labelSm,
463
- description: styles.descriptionSm,
464
- container: styles.containerSm,
463
+ checkbox: styles$1.checkboxSm,
464
+ label: styles$1.labelSm,
465
+ description: styles$1.descriptionSm,
466
+ container: styles$1.containerSm,
465
467
  },
466
468
  md: {
467
- checkbox: styles.checkboxMd,
468
- label: styles.labelMd,
469
- description: styles.descriptionMd,
470
- container: styles.containerMd,
469
+ checkbox: styles$1.checkboxMd,
470
+ label: styles$1.labelMd,
471
+ description: styles$1.descriptionMd,
472
+ container: styles$1.containerMd,
471
473
  },
472
474
  lg: {
473
- checkbox: styles.checkboxLg,
474
- label: styles.labelLg,
475
- description: styles.descriptionLg,
476
- container: styles.containerLg,
475
+ checkbox: styles$1.checkboxLg,
476
+ label: styles$1.labelLg,
477
+ description: styles$1.descriptionLg,
478
+ container: styles$1.containerLg,
477
479
  },
478
480
  };
479
481
  const variantClasses = {
480
- default: styles.variantDefault,
481
- primary: styles.variantPrimary,
482
- success: styles.variantSuccess,
483
- warning: styles.variantWarning,
484
- danger: styles.variantDanger,
482
+ default: styles$1.variantDefault,
483
+ primary: styles$1.variantPrimary,
484
+ success: styles$1.variantSuccess,
485
+ warning: styles$1.variantWarning,
486
+ danger: styles$1.variantDanger,
485
487
  };
486
488
  const classNames = (...classes) => classes.filter(Boolean).join(" ");
487
489
  /** 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) {
490
+ const CheckboxInput = React.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
491
  const field = shared.useFieldIds({ id, name, required, error, hint: description });
490
492
  const sizeConfig = sizeClasses[size];
491
493
  const variantConfig = variantClasses[variant];
492
- const checkboxRef = require$$0.useRef(null);
493
- require$$0.useEffect(() => {
494
+ const checkboxRef = React.useRef(null);
495
+ React.useEffect(() => {
494
496
  if (checkboxRef.current) {
495
497
  checkboxRef.current.indeterminate = indeterminate;
496
498
  }
497
499
  }, [indeterminate]);
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) => {
500
+ return (jsxRuntimeExports.jsxs("div", { className: classNames(styles$1.wrapper, className), children: [jsxRuntimeExports.jsx("div", { className: classNames(styles$1.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) => {
499
501
  if (disabled) {
500
502
  return;
501
503
  }
502
504
  onChange?.(e.target.checked);
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 }))] })] }));
505
+ }, disabled: disabled, className: classNames(styles$1.checkbox, sizeConfig.checkbox, variantConfig, disabled && styles$1.checkboxDisabled, error && styles$1.checkboxError), required: required }) }), jsxRuntimeExports.jsxs("div", { className: styles$1.content, children: [jsxRuntimeExports.jsxs("label", { htmlFor: field.inputId, className: classNames(styles$1.label, sizeConfig.label, disabled ? styles$1.labelDisabled : styles$1.labelNormal), children: [label, required && (jsxRuntimeExports.jsx("span", { className: styles$1.required, "aria-hidden": "true", children: "*" }))] }), description && (jsxRuntimeExports.jsx("p", { id: field.hintId, className: classNames(styles$1.description, sizeConfig.description), children: description })), error && (jsxRuntimeExports.jsx("p", { id: field.errorId, className: styles$1.errorText, role: "alert", children: error }))] })] }));
504
506
  });
505
507
  CheckboxInput.displayName = "CheckboxInput";
506
508
 
507
- module.exports = CheckboxInput;
509
+ var css_248z = ".CheckboxGroup-module_fieldset__5eB3Z {\n min-inline-size: 0;\n margin: 0;\n padding: 0;\n border: 0;\n font-family: var(--lb-font-sans);\n}\n\n.CheckboxGroup-module_legend__pNuxN {\n margin-bottom: var(--lb-space-2);\n padding: 0;\n font-size: var(--lb-font-size-sm);\n font-weight: var(--lb-font-weight-medium);\n color: var(--lb-color-foreground);\n}\n\n.CheckboxGroup-module_required__2lbzi {\n color: var(--lb-color-danger);\n}\n\n.CheckboxGroup-module_hint__2Pl7J {\n margin: 0 0 var(--lb-space-3);\n font-size: var(--lb-font-size-xs);\n color: var(--lb-color-muted-foreground);\n}\n\n.CheckboxGroup-module_selectAll__qdf1U {\n margin-bottom: var(--lb-space-3);\n padding-bottom: var(--lb-space-3);\n border-bottom: 1px solid var(--lb-color-border);\n}\n\n.CheckboxGroup-module_vertical__D-Dlk {\n display: flex;\n flex-direction: column;\n gap: var(--lb-space-3);\n}\n\n.CheckboxGroup-module_horizontal__T8rDx {\n display: flex;\n flex-wrap: wrap;\n gap: var(--lb-space-3) var(--lb-space-6);\n}\n\n.CheckboxGroup-module_columns__ao0Db {\n display: grid;\n grid-template-columns: minmax(0, 1fr);\n gap: var(--lb-space-3) var(--lb-space-6);\n}\n\n@media (min-width: 640px) {\n .CheckboxGroup-module_cols2__RdYv0 {\n grid-template-columns: repeat(2, minmax(0, 1fr));\n }\n .CheckboxGroup-module_cols3__03Tcs {\n grid-template-columns: repeat(3, minmax(0, 1fr));\n }\n .CheckboxGroup-module_cols4__sI6xr {\n grid-template-columns: repeat(4, minmax(0, 1fr));\n }\n}\n\n.CheckboxGroup-module_error__Y6n9J {\n margin: var(--lb-space-2) 0 0;\n font-size: var(--lb-font-size-xs);\n color: var(--lb-color-danger);\n}\n\n.CheckboxGroup-module_srOnly__QdgTc {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border: 0;\n}\n";
510
+ var styles = {"fieldset":"CheckboxGroup-module_fieldset__5eB3Z","legend":"CheckboxGroup-module_legend__pNuxN","required":"CheckboxGroup-module_required__2lbzi","hint":"CheckboxGroup-module_hint__2Pl7J","selectAll":"CheckboxGroup-module_selectAll__qdf1U","vertical":"CheckboxGroup-module_vertical__D-Dlk","horizontal":"CheckboxGroup-module_horizontal__T8rDx","columns":"CheckboxGroup-module_columns__ao0Db","cols2":"CheckboxGroup-module_cols2__RdYv0","cols3":"CheckboxGroup-module_cols3__03Tcs","cols4":"CheckboxGroup-module_cols4__sI6xr","error":"CheckboxGroup-module_error__Y6n9J","srOnly":"CheckboxGroup-module_srOnly__QdgTc"};
511
+ styleInject(css_248z);
512
+
513
+ const cx = (...c) => c.filter(Boolean).join(" ");
514
+ /**
515
+ * Grupo de casillas con título (`fieldset`/`legend`), ayuda y error: para elegir varias
516
+ * opciones de una lista corta (permisos, días, especialidades).
517
+ */
518
+ function CheckboxGroup({ label, options, value, onChange, name, orientation = "vertical", columns, size = "md", variant = "primary", disabled = false, required = false, hint, error, selectAll = false, maxSelected, hideLabel = false, className, id, labels, }) {
519
+ const t = shared.useUiMessages("checkboxGroup", labels);
520
+ const generado = React.useId();
521
+ const baseId = id ?? `checkbox-group-${generado}`;
522
+ const hintId = `${baseId}-ayuda`;
523
+ const errorId = `${baseId}-error`;
524
+ const describedBy = [hint && hintId, error && errorId].filter(Boolean).join(" ") || undefined;
525
+ const marcados = new Set(value);
526
+ const habilitadas = options.filter((o) => !o.disabled);
527
+ const lleno = maxSelected !== undefined && marcados.size >= maxSelected;
528
+ const cambiar = (valor, marcar) => {
529
+ const siguiente = new Set(marcados);
530
+ if (marcar)
531
+ siguiente.add(valor);
532
+ else
533
+ siguiente.delete(valor);
534
+ // Orden estable: el de las opciones; se conservan valores que no estén en options.
535
+ const enOpciones = options
536
+ .map((o) => o.value)
537
+ .filter((v) => siguiente.has(v));
538
+ const otros = value.filter((v) => siguiente.has(v) && !options.some((o) => o.value === v));
539
+ onChange([...enOpciones, ...otros]);
540
+ };
541
+ const todasMarcadas = habilitadas.length > 0 && habilitadas.every((o) => marcados.has(o.value));
542
+ const algunaMarcada = habilitadas.some((o) => marcados.has(o.value));
543
+ const alternarTodas = (marcar) => {
544
+ const habilitadasSet = new Set(habilitadas.map((o) => o.value));
545
+ const conservar = value.filter((v) => !habilitadasSet.has(v));
546
+ let nuevas = marcar ? habilitadas.map((o) => o.value) : [];
547
+ if (marcar && maxSelected !== undefined)
548
+ nuevas = nuevas.slice(0, Math.max(0, maxSelected - conservar.length));
549
+ const resultado = new Set([...conservar, ...nuevas]);
550
+ onChange([
551
+ ...options.map((o) => o.value).filter((v) => resultado.has(v)),
552
+ ...conservar.filter((v) => !options.some((o) => o.value === v)),
553
+ ]);
554
+ };
555
+ return (jsxRuntimeExports.jsxs("fieldset", { id: baseId, className: cx(styles.fieldset, className), disabled: disabled, "aria-describedby": describedBy, "aria-invalid": error ? true : undefined, children: [jsxRuntimeExports.jsxs("legend", { className: cx(styles.legend, hideLabel && styles.srOnly), children: [label, required && (jsxRuntimeExports.jsxs("span", { className: styles.required, "aria-hidden": "true", children: [" ", "*"] }))] }), hint && (jsxRuntimeExports.jsx("p", { id: hintId, className: styles.hint, children: hint })), selectAll && (jsxRuntimeExports.jsx("div", { className: styles.selectAll, children: jsxRuntimeExports.jsx(CheckboxInput, { label: typeof selectAll === "string" ? selectAll : t.selectAll, checked: todasMarcadas, indeterminate: algunaMarcada && !todasMarcadas, onChange: alternarTodas, size: size, variant: variant, disabled: disabled }) })), jsxRuntimeExports.jsx("div", { className: cx(columns
556
+ ? cx(styles.columns, styles[`cols${columns}`])
557
+ : orientation === "horizontal"
558
+ ? styles.horizontal
559
+ : styles.vertical), children: options.map((o) => {
560
+ const marcada = marcados.has(o.value);
561
+ return (jsxRuntimeExports.jsx(CheckboxInput, { name: name, value: o.value, label: o.label, description: o.description, checked: marcada, onChange: (c) => cambiar(o.value, c), disabled: disabled || o.disabled || (lleno && !marcada), size: size, variant: variant }, o.value));
562
+ }) }), error && (jsxRuntimeExports.jsx("p", { id: errorId, className: styles.error, role: "alert", children: error }))] }));
563
+ }
564
+
565
+ exports.CheckboxGroup = CheckboxGroup;
566
+ exports.default = CheckboxInput;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { UiMessages } from '@rubenpazch/shared';
2
3
 
3
4
  type CheckboxSize = "sm" | "md" | "lg";
4
5
  type CheckboxVariant = "default" | "primary" | "success" | "warning" | "danger";
@@ -24,5 +25,67 @@ interface CheckboxInputProps {
24
25
  /** Casilla de verificación con etiqueta, descripción y error. */
25
26
  declare const CheckboxInput: React.ForwardRefExoticComponent<CheckboxInputProps & React.RefAttributes<HTMLInputElement>>;
26
27
 
27
- export { CheckboxInput as default };
28
- export type { CheckboxInputProps };
28
+ interface CheckboxOption {
29
+ /** Texto visible de la casilla. */
30
+ label: string;
31
+ /** Valor que se agrega a la lista al marcarla. */
32
+ value: string;
33
+ /** Texto secundario bajo la etiqueta. */
34
+ description?: string;
35
+ /** Deshabilita solo esta casilla. */
36
+ disabled?: boolean;
37
+ }
38
+ interface CheckboxGroupProps {
39
+ /** Título del grupo (se muestra como `<legend>` del `<fieldset>`). */
40
+ label: string;
41
+ /** Opciones del grupo. */
42
+ options: CheckboxOption[];
43
+ /** Valores marcados. */
44
+ value: string[];
45
+ /** Recibe la nueva lista de valores marcados (en el orden de `options`). */
46
+ onChange: (value: string[]) => void;
47
+ /** name de cada casilla (formularios nativos: se envía una vez por valor marcado). */
48
+ name?: string;
49
+ /** `vertical` (por defecto) o `horizontal` (se ajusta a la siguiente línea). */
50
+ orientation?: "vertical" | "horizontal";
51
+ /** Columnas en pantallas desde 640px (en móvil siempre 1). Ignora `orientation`. */
52
+ columns?: 2 | 3 | 4;
53
+ /** Tamaño de las casillas. */
54
+ size?: "sm" | "md" | "lg";
55
+ /** Color de las casillas marcadas. */
56
+ variant?: "default" | "primary" | "success" | "warning" | "danger";
57
+ /** Deshabilita todo el grupo. */
58
+ disabled?: boolean;
59
+ /** Marca el grupo como obligatorio (muestra *); la validación "al menos uno" va en `error`. */
60
+ required?: boolean;
61
+ /** Texto de ayuda bajo el título. */
62
+ hint?: string;
63
+ /** Mensaje de error del grupo. */
64
+ error?: string;
65
+ /**
66
+ * Agrega una casilla "Seleccionar todos" (queda indeterminada si hay algunas marcadas).
67
+ * `true` usa el texto por defecto; un texto lo reemplaza.
68
+ */
69
+ selectAll?: boolean | string;
70
+ /** Máximo de opciones marcadas: al llegar, las demás se deshabilitan. */
71
+ maxSelected?: number;
72
+ /** Ocultar el título visualmente (sigue disponible para lectores de pantalla). */
73
+ hideLabel?: boolean;
74
+ /** Clase extra del contenedor. */
75
+ className?: string;
76
+ /** id del fieldset; si no se pasa se genera uno. */
77
+ id?: string;
78
+ /**
79
+ * Textos de la interfaz. Por defecto, los del idioma activo (`UiLocaleProvider`);
80
+ * también se cambian para toda la app con su prop `messages`.
81
+ */
82
+ labels?: Partial<UiMessages["checkboxGroup"]>;
83
+ }
84
+ /**
85
+ * Grupo de casillas con título (`fieldset`/`legend`), ayuda y error: para elegir varias
86
+ * opciones de una lista corta (permisos, días, especialidades).
87
+ */
88
+ declare function CheckboxGroup({ label, options, value, onChange, name, orientation, columns, size, variant, disabled, required, hint, error, selectAll, maxSelected, hideLabel, className, id, labels, }: CheckboxGroupProps): React.JSX.Element;
89
+
90
+ export { CheckboxGroup, CheckboxInput as default };
91
+ export type { CheckboxGroupProps, CheckboxInputProps, CheckboxOption };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,YAAY,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC"}
package/dist/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
- import require$$0, { useRef, useEffect } from 'react';
2
- import { useFieldIds, mergeRefs } from '@rubenpazch/shared';
1
+ import React, { useRef, useEffect } from 'react';
2
+ import { useFieldIds, mergeRefs, useUiMessages } from '@rubenpazch/shared';
3
3
 
4
4
  var jsxRuntime = {exports: {}};
5
5
 
@@ -337,7 +337,7 @@ function requireReactJsxRuntime_development () {
337
337
  object.$$typeof === REACT_ELEMENT_TYPE
338
338
  );
339
339
  }
340
- var React = require$$0,
340
+ var React$1 = React,
341
341
  REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
342
342
  REACT_PORTAL_TYPE = Symbol.for("react.portal"),
343
343
  REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
@@ -353,7 +353,7 @@ function requireReactJsxRuntime_development () {
353
353
  REACT_ACTIVITY_TYPE = Symbol.for("react.activity"),
354
354
  REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"),
355
355
  ReactSharedInternals =
356
- React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
356
+ React$1.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
357
357
  hasOwnProperty = Object.prototype.hasOwnProperty,
358
358
  isArrayImpl = Array.isArray,
359
359
  createTask = console.createTask
@@ -361,15 +361,15 @@ function requireReactJsxRuntime_development () {
361
361
  : function () {
362
362
  return null;
363
363
  };
364
- React = {
364
+ React$1 = {
365
365
  react_stack_bottom_frame: function (callStackForError) {
366
366
  return callStackForError();
367
367
  }
368
368
  };
369
369
  var specialPropKeyWarningShown;
370
370
  var didWarnAboutElementRef = {};
371
- var unknownOwnerDebugStack = React.react_stack_bottom_frame.bind(
372
- React,
371
+ var unknownOwnerDebugStack = React$1.react_stack_bottom_frame.bind(
372
+ React$1,
373
373
  UnknownOwner
374
374
  )();
375
375
  var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
@@ -427,7 +427,7 @@ function styleInject(css, ref) {
427
427
  if ( ref === void 0 ) ref = {};
428
428
  var insertAt = ref.insertAt;
429
429
 
430
- if (typeof document === 'undefined') { return; }
430
+ if (!css || typeof document === 'undefined') { return; }
431
431
 
432
432
  var head = document.head || document.getElementsByTagName('head')[0];
433
433
  var style = document.createElement('style');
@@ -450,40 +450,40 @@ function styleInject(css, ref) {
450
450
  }
451
451
  }
452
452
 
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";
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"};
455
- styleInject(css_248z);
453
+ var css_248z$1 = ".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";
454
+ var styles$1 = {"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"};
455
+ styleInject(css_248z$1);
456
456
 
457
457
  const sizeClasses = {
458
458
  sm: {
459
- checkbox: styles.checkboxSm,
460
- label: styles.labelSm,
461
- description: styles.descriptionSm,
462
- container: styles.containerSm,
459
+ checkbox: styles$1.checkboxSm,
460
+ label: styles$1.labelSm,
461
+ description: styles$1.descriptionSm,
462
+ container: styles$1.containerSm,
463
463
  },
464
464
  md: {
465
- checkbox: styles.checkboxMd,
466
- label: styles.labelMd,
467
- description: styles.descriptionMd,
468
- container: styles.containerMd,
465
+ checkbox: styles$1.checkboxMd,
466
+ label: styles$1.labelMd,
467
+ description: styles$1.descriptionMd,
468
+ container: styles$1.containerMd,
469
469
  },
470
470
  lg: {
471
- checkbox: styles.checkboxLg,
472
- label: styles.labelLg,
473
- description: styles.descriptionLg,
474
- container: styles.containerLg,
471
+ checkbox: styles$1.checkboxLg,
472
+ label: styles$1.labelLg,
473
+ description: styles$1.descriptionLg,
474
+ container: styles$1.containerLg,
475
475
  },
476
476
  };
477
477
  const variantClasses = {
478
- default: styles.variantDefault,
479
- primary: styles.variantPrimary,
480
- success: styles.variantSuccess,
481
- warning: styles.variantWarning,
482
- danger: styles.variantDanger,
478
+ default: styles$1.variantDefault,
479
+ primary: styles$1.variantPrimary,
480
+ success: styles$1.variantSuccess,
481
+ warning: styles$1.variantWarning,
482
+ danger: styles$1.variantDanger,
483
483
  };
484
484
  const classNames = (...classes) => classes.filter(Boolean).join(" ");
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) {
486
+ const CheckboxInput = React.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
487
  const field = useFieldIds({ id, name, required, error, hint: description });
488
488
  const sizeConfig = sizeClasses[size];
489
489
  const variantConfig = variantClasses[variant];
@@ -493,13 +493,69 @@ const CheckboxInput = require$$0.forwardRef(function CheckboxInput({ id, name, v
493
493
  checkboxRef.current.indeterminate = indeterminate;
494
494
  }
495
495
  }, [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: mergeRefs(checkboxRef, ref), ...field.controlProps, name: name, value: value, type: "checkbox", checked: checked, "aria-checked": indeterminate ? "mixed" : undefined, onChange: (e) => {
496
+ return (jsxRuntimeExports.jsxs("div", { className: classNames(styles$1.wrapper, className), children: [jsxRuntimeExports.jsx("div", { className: classNames(styles$1.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) => {
497
497
  if (disabled) {
498
498
  return;
499
499
  }
500
500
  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: 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 }))] })] }));
501
+ }, disabled: disabled, className: classNames(styles$1.checkbox, sizeConfig.checkbox, variantConfig, disabled && styles$1.checkboxDisabled, error && styles$1.checkboxError), required: required }) }), jsxRuntimeExports.jsxs("div", { className: styles$1.content, children: [jsxRuntimeExports.jsxs("label", { htmlFor: field.inputId, className: classNames(styles$1.label, sizeConfig.label, disabled ? styles$1.labelDisabled : styles$1.labelNormal), children: [label, required && (jsxRuntimeExports.jsx("span", { className: styles$1.required, "aria-hidden": "true", children: "*" }))] }), description && (jsxRuntimeExports.jsx("p", { id: field.hintId, className: classNames(styles$1.description, sizeConfig.description), children: description })), error && (jsxRuntimeExports.jsx("p", { id: field.errorId, className: styles$1.errorText, role: "alert", children: error }))] })] }));
502
502
  });
503
503
  CheckboxInput.displayName = "CheckboxInput";
504
504
 
505
- export { CheckboxInput as default };
505
+ var css_248z = ".CheckboxGroup-module_fieldset__5eB3Z {\n min-inline-size: 0;\n margin: 0;\n padding: 0;\n border: 0;\n font-family: var(--lb-font-sans);\n}\n\n.CheckboxGroup-module_legend__pNuxN {\n margin-bottom: var(--lb-space-2);\n padding: 0;\n font-size: var(--lb-font-size-sm);\n font-weight: var(--lb-font-weight-medium);\n color: var(--lb-color-foreground);\n}\n\n.CheckboxGroup-module_required__2lbzi {\n color: var(--lb-color-danger);\n}\n\n.CheckboxGroup-module_hint__2Pl7J {\n margin: 0 0 var(--lb-space-3);\n font-size: var(--lb-font-size-xs);\n color: var(--lb-color-muted-foreground);\n}\n\n.CheckboxGroup-module_selectAll__qdf1U {\n margin-bottom: var(--lb-space-3);\n padding-bottom: var(--lb-space-3);\n border-bottom: 1px solid var(--lb-color-border);\n}\n\n.CheckboxGroup-module_vertical__D-Dlk {\n display: flex;\n flex-direction: column;\n gap: var(--lb-space-3);\n}\n\n.CheckboxGroup-module_horizontal__T8rDx {\n display: flex;\n flex-wrap: wrap;\n gap: var(--lb-space-3) var(--lb-space-6);\n}\n\n.CheckboxGroup-module_columns__ao0Db {\n display: grid;\n grid-template-columns: minmax(0, 1fr);\n gap: var(--lb-space-3) var(--lb-space-6);\n}\n\n@media (min-width: 640px) {\n .CheckboxGroup-module_cols2__RdYv0 {\n grid-template-columns: repeat(2, minmax(0, 1fr));\n }\n .CheckboxGroup-module_cols3__03Tcs {\n grid-template-columns: repeat(3, minmax(0, 1fr));\n }\n .CheckboxGroup-module_cols4__sI6xr {\n grid-template-columns: repeat(4, minmax(0, 1fr));\n }\n}\n\n.CheckboxGroup-module_error__Y6n9J {\n margin: var(--lb-space-2) 0 0;\n font-size: var(--lb-font-size-xs);\n color: var(--lb-color-danger);\n}\n\n.CheckboxGroup-module_srOnly__QdgTc {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border: 0;\n}\n";
506
+ var styles = {"fieldset":"CheckboxGroup-module_fieldset__5eB3Z","legend":"CheckboxGroup-module_legend__pNuxN","required":"CheckboxGroup-module_required__2lbzi","hint":"CheckboxGroup-module_hint__2Pl7J","selectAll":"CheckboxGroup-module_selectAll__qdf1U","vertical":"CheckboxGroup-module_vertical__D-Dlk","horizontal":"CheckboxGroup-module_horizontal__T8rDx","columns":"CheckboxGroup-module_columns__ao0Db","cols2":"CheckboxGroup-module_cols2__RdYv0","cols3":"CheckboxGroup-module_cols3__03Tcs","cols4":"CheckboxGroup-module_cols4__sI6xr","error":"CheckboxGroup-module_error__Y6n9J","srOnly":"CheckboxGroup-module_srOnly__QdgTc"};
507
+ styleInject(css_248z);
508
+
509
+ const cx = (...c) => c.filter(Boolean).join(" ");
510
+ /**
511
+ * Grupo de casillas con título (`fieldset`/`legend`), ayuda y error: para elegir varias
512
+ * opciones de una lista corta (permisos, días, especialidades).
513
+ */
514
+ function CheckboxGroup({ label, options, value, onChange, name, orientation = "vertical", columns, size = "md", variant = "primary", disabled = false, required = false, hint, error, selectAll = false, maxSelected, hideLabel = false, className, id, labels, }) {
515
+ const t = useUiMessages("checkboxGroup", labels);
516
+ const generado = React.useId();
517
+ const baseId = id ?? `checkbox-group-${generado}`;
518
+ const hintId = `${baseId}-ayuda`;
519
+ const errorId = `${baseId}-error`;
520
+ const describedBy = [hint && hintId, error && errorId].filter(Boolean).join(" ") || undefined;
521
+ const marcados = new Set(value);
522
+ const habilitadas = options.filter((o) => !o.disabled);
523
+ const lleno = maxSelected !== undefined && marcados.size >= maxSelected;
524
+ const cambiar = (valor, marcar) => {
525
+ const siguiente = new Set(marcados);
526
+ if (marcar)
527
+ siguiente.add(valor);
528
+ else
529
+ siguiente.delete(valor);
530
+ // Orden estable: el de las opciones; se conservan valores que no estén en options.
531
+ const enOpciones = options
532
+ .map((o) => o.value)
533
+ .filter((v) => siguiente.has(v));
534
+ const otros = value.filter((v) => siguiente.has(v) && !options.some((o) => o.value === v));
535
+ onChange([...enOpciones, ...otros]);
536
+ };
537
+ const todasMarcadas = habilitadas.length > 0 && habilitadas.every((o) => marcados.has(o.value));
538
+ const algunaMarcada = habilitadas.some((o) => marcados.has(o.value));
539
+ const alternarTodas = (marcar) => {
540
+ const habilitadasSet = new Set(habilitadas.map((o) => o.value));
541
+ const conservar = value.filter((v) => !habilitadasSet.has(v));
542
+ let nuevas = marcar ? habilitadas.map((o) => o.value) : [];
543
+ if (marcar && maxSelected !== undefined)
544
+ nuevas = nuevas.slice(0, Math.max(0, maxSelected - conservar.length));
545
+ const resultado = new Set([...conservar, ...nuevas]);
546
+ onChange([
547
+ ...options.map((o) => o.value).filter((v) => resultado.has(v)),
548
+ ...conservar.filter((v) => !options.some((o) => o.value === v)),
549
+ ]);
550
+ };
551
+ return (jsxRuntimeExports.jsxs("fieldset", { id: baseId, className: cx(styles.fieldset, className), disabled: disabled, "aria-describedby": describedBy, "aria-invalid": error ? true : undefined, children: [jsxRuntimeExports.jsxs("legend", { className: cx(styles.legend, hideLabel && styles.srOnly), children: [label, required && (jsxRuntimeExports.jsxs("span", { className: styles.required, "aria-hidden": "true", children: [" ", "*"] }))] }), hint && (jsxRuntimeExports.jsx("p", { id: hintId, className: styles.hint, children: hint })), selectAll && (jsxRuntimeExports.jsx("div", { className: styles.selectAll, children: jsxRuntimeExports.jsx(CheckboxInput, { label: typeof selectAll === "string" ? selectAll : t.selectAll, checked: todasMarcadas, indeterminate: algunaMarcada && !todasMarcadas, onChange: alternarTodas, size: size, variant: variant, disabled: disabled }) })), jsxRuntimeExports.jsx("div", { className: cx(columns
552
+ ? cx(styles.columns, styles[`cols${columns}`])
553
+ : orientation === "horizontal"
554
+ ? styles.horizontal
555
+ : styles.vertical), children: options.map((o) => {
556
+ const marcada = marcados.has(o.value);
557
+ return (jsxRuntimeExports.jsx(CheckboxInput, { name: name, value: o.value, label: o.label, description: o.description, checked: marcada, onChange: (c) => cambiar(o.value, c), disabled: disabled || o.disabled || (lleno && !marcada), size: size, variant: variant }, o.value));
558
+ }) }), error && (jsxRuntimeExports.jsx("p", { id: errorId, className: styles.error, role: "alert", children: error }))] }));
559
+ }
560
+
561
+ export { CheckboxGroup, CheckboxInput as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rubenpazch/checkbox-input",
3
- "version": "3.2.5",
3
+ "version": "3.4.0",
4
4
  "description": "CheckboxInput component",
5
5
  "private": false,
6
6
  "main": "dist/index.cjs.js",
@@ -32,8 +32,8 @@
32
32
  "@rubenpazch/tokens": "0.5.0"
33
33
  },
34
34
  "dependencies": {
35
- "@rubenpazch/button": "6.2.5",
36
- "@rubenpazch/shared": "5.3.0"
35
+ "@rubenpazch/button": "6.2.6",
36
+ "@rubenpazch/shared": "5.4.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@rubenpazch/typescript-config": "3.0.0"
@@ -43,9 +43,9 @@
43
43
  },
44
44
  "lbyte": {
45
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."
46
+ "resumen": "Casilla de verificación con etiqueta, ayuda y error (CheckboxInput) y grupo de casillas con título, \"Seleccionar todos\" y máximo (CheckboxGroup).",
47
+ "usarCuando": "Opciones sí/no (CheckboxInput) o elegir varias opciones de una lista corta: permisos, días, especialidades (CheckboxGroup).",
48
+ "evitarCuando": "Elegir una sola opción entre varias: usa RadioGroup. Listas largas o con búsqueda: usa Autocomplete. Activar/desactivar algo al instante: usa Switch."
49
49
  },
50
50
  "scripts": {
51
51
  "build": "rollup -c",