@rubenpazch/radio-button 4.1.2 → 4.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 +21 -18
- package/dist/RadioButton.d.ts +1 -1
- package/dist/RadioButton.d.ts.map +1 -1
- package/dist/RadioGroup.d.ts +6 -1
- package/dist/RadioGroup.d.ts.map +1 -1
- package/dist/index.cjs.js +25 -15
- package/dist/index.d.ts +7 -2
- package/dist/index.esm.js +25 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -35,24 +35,27 @@ npm install @rubenpazch/radio-button
|
|
|
35
35
|
|
|
36
36
|
## RadioGroup
|
|
37
37
|
|
|
38
|
-
| Prop | Tipo | Req. | Por defecto
|
|
39
|
-
| ------------------- | -------------------------------------------------------------- | ---- |
|
|
40
|
-
| `name` | `string` | sí |
|
|
41
|
-
| `onChange` | `(value: string) => void` | sí |
|
|
42
|
-
| `options` | `RadioOption[]` | sí |
|
|
43
|
-
| `bordered` | `boolean` | | `false`
|
|
44
|
-
| `borderLabel` | `string` | |
|
|
45
|
-
| `className` | `string` | | ``
|
|
46
|
-
| `disabled` | `boolean` | | `false`
|
|
47
|
-
| `error` | `string` | |
|
|
48
|
-
| `groupLabel` | `string` | |
|
|
49
|
-
| `
|
|
50
|
-
| `
|
|
51
|
-
| `
|
|
52
|
-
| `
|
|
53
|
-
| `
|
|
54
|
-
| `
|
|
55
|
-
| `
|
|
38
|
+
| Prop | Tipo | Req. | Por defecto | Descripción |
|
|
39
|
+
| ------------------- | -------------------------------------------------------------- | ---- | --------------- | ------------------------------------------- |
|
|
40
|
+
| `name` | `string` | sí | | |
|
|
41
|
+
| `onChange` | `(value: string) => void` | sí | | |
|
|
42
|
+
| `options` | `RadioOption[]` | sí | | |
|
|
43
|
+
| `bordered` | `boolean` | | `false` | |
|
|
44
|
+
| `borderLabel` | `string` | | | |
|
|
45
|
+
| `className` | `string` | | `` | |
|
|
46
|
+
| `disabled` | `boolean` | | `false` | |
|
|
47
|
+
| `error` | `string` | | | |
|
|
48
|
+
| `groupLabel` | `string` | | | |
|
|
49
|
+
| `hint` | `string` | | | Texto de ayuda bajo el grupo. |
|
|
50
|
+
| `id` | `string` | | | |
|
|
51
|
+
| `label` | `string` | | | Etiqueta del grupo (alias de `groupLabel`). |
|
|
52
|
+
| `orientation` | `"vertical" \| "horizontal"` | | `vertical` | |
|
|
53
|
+
| `required` | `boolean` | | `false` | |
|
|
54
|
+
| `selectedLabelText` | `string` | | `Seleccionado:` | |
|
|
55
|
+
| `showSelectedLabel` | `boolean` | | `false` | |
|
|
56
|
+
| `size` | `"sm" \| "md" \| "lg"` | | `md` | |
|
|
57
|
+
| `value` | `string` | | | |
|
|
58
|
+
| `variant` | `"default" \| "primary" \| "success" \| "warning" \| "danger"` | | `default` | |
|
|
56
59
|
|
|
57
60
|
Tipos: `RadioButtonProps`, `RadioSize`, `RadioVariant`, `RadioGroupProps`, `RadioOption`, `RadioGroupOrientation`.
|
|
58
61
|
|
package/dist/RadioButton.d.ts
CHANGED
|
@@ -16,6 +16,6 @@ export interface RadioButtonProps {
|
|
|
16
16
|
size?: RadioSize;
|
|
17
17
|
variant?: RadioVariant;
|
|
18
18
|
}
|
|
19
|
-
declare const RadioButton: React.
|
|
19
|
+
declare const RadioButton: React.ForwardRefExoticComponent<RadioButtonProps & React.RefAttributes<HTMLInputElement>>;
|
|
20
20
|
export default RadioButton;
|
|
21
21
|
//# sourceMappingURL=RadioButton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioButton.d.ts","sourceRoot":"","sources":["../src/RadioButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAC3C,MAAM,MAAM,YAAY,GACtB,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE3D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,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB;AAqDD,QAAA,MAAM,WAAW,2FAiHhB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
package/dist/RadioGroup.d.ts
CHANGED
|
@@ -18,6 +18,11 @@ export interface RadioGroupProps {
|
|
|
18
18
|
disabled?: boolean;
|
|
19
19
|
required?: boolean;
|
|
20
20
|
error?: string;
|
|
21
|
+
/** Texto de ayuda bajo el grupo. */
|
|
22
|
+
hint?: string;
|
|
23
|
+
/** Etiqueta del grupo (alias de `groupLabel`). */
|
|
24
|
+
label?: string;
|
|
25
|
+
id?: string;
|
|
21
26
|
className?: string;
|
|
22
27
|
showSelectedLabel?: boolean;
|
|
23
28
|
selectedLabelText?: string;
|
|
@@ -25,6 +30,6 @@ export interface RadioGroupProps {
|
|
|
25
30
|
bordered?: boolean;
|
|
26
31
|
borderLabel?: string;
|
|
27
32
|
}
|
|
28
|
-
declare const RadioGroup: React.
|
|
33
|
+
declare const RadioGroup: React.ForwardRefExoticComponent<RadioGroupProps & React.RefAttributes<HTMLDivElement>>;
|
|
29
34
|
export default RadioGroup;
|
|
30
35
|
//# sourceMappingURL=RadioGroup.d.ts.map
|
package/dist/RadioGroup.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioGroup.d.ts","sourceRoot":"","sources":["../src/RadioGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAoB,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAGrE,MAAM,MAAM,qBAAqB,GAAG,UAAU,GAAG,YAAY,CAAC;AAE9D,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OA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AAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,WAAW,CAAC,EAAE,qBAAqB,CAAC;IACpC,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oCAAoC;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,QAAA,MAAM,UAAU,wFAyHf,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var React = require('react');
|
|
6
6
|
|
|
7
7
|
var jsxRuntime = {exports: {}};
|
|
8
8
|
|
|
@@ -340,7 +340,7 @@ function requireReactJsxRuntime_development () {
|
|
|
340
340
|
object.$$typeof === REACT_ELEMENT_TYPE
|
|
341
341
|
);
|
|
342
342
|
}
|
|
343
|
-
var React =
|
|
343
|
+
var React$1 = React,
|
|
344
344
|
REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
|
|
345
345
|
REACT_PORTAL_TYPE = Symbol.for("react.portal"),
|
|
346
346
|
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
|
|
@@ -356,7 +356,7 @@ function requireReactJsxRuntime_development () {
|
|
|
356
356
|
REACT_ACTIVITY_TYPE = Symbol.for("react.activity"),
|
|
357
357
|
REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"),
|
|
358
358
|
ReactSharedInternals =
|
|
359
|
-
React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
|
|
359
|
+
React$1.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
|
|
360
360
|
hasOwnProperty = Object.prototype.hasOwnProperty,
|
|
361
361
|
isArrayImpl = Array.isArray,
|
|
362
362
|
createTask = console.createTask
|
|
@@ -364,15 +364,15 @@ function requireReactJsxRuntime_development () {
|
|
|
364
364
|
: function () {
|
|
365
365
|
return null;
|
|
366
366
|
};
|
|
367
|
-
React = {
|
|
367
|
+
React$1 = {
|
|
368
368
|
react_stack_bottom_frame: function (callStackForError) {
|
|
369
369
|
return callStackForError();
|
|
370
370
|
}
|
|
371
371
|
};
|
|
372
372
|
var specialPropKeyWarningShown;
|
|
373
373
|
var didWarnAboutElementRef = {};
|
|
374
|
-
var unknownOwnerDebugStack = React.react_stack_bottom_frame.bind(
|
|
375
|
-
React,
|
|
374
|
+
var unknownOwnerDebugStack = React$1.react_stack_bottom_frame.bind(
|
|
375
|
+
React$1,
|
|
376
376
|
UnknownOwner
|
|
377
377
|
)();
|
|
378
378
|
var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
|
|
@@ -500,8 +500,11 @@ const variantClasses = {
|
|
|
500
500
|
focus: styles$1.radioFocusDanger,
|
|
501
501
|
},
|
|
502
502
|
};
|
|
503
|
-
const RadioButton = ({ id, name, label, value, checked = false, onChange, disabled = false, description, error, className = "", required = false, size = "md", variant = "default", })
|
|
503
|
+
const RadioButton = React.forwardRef(function RadioButton({ id, name, label, value, checked = false, onChange, disabled = false, description, error, className = "", required = false, size = "md", variant = "default", }, ref) {
|
|
504
504
|
const radioId = id || `radio-${name}-${value}`;
|
|
505
|
+
const describedBy = [description && `${radioId}-description`, error && `${radioId}-error`]
|
|
506
|
+
.filter(Boolean)
|
|
507
|
+
.join(" ") || undefined;
|
|
505
508
|
const sizes = sizeClasses[size];
|
|
506
509
|
const variants = variantClasses[variant];
|
|
507
510
|
const handleChange = (event) => {
|
|
@@ -523,22 +526,29 @@ const RadioButton = ({ id, name, label, value, checked = false, onChange, disabl
|
|
|
523
526
|
: size === "lg"
|
|
524
527
|
? styles$1.errorLg
|
|
525
528
|
: styles$1.errorMd);
|
|
526
|
-
return (jsxRuntimeExports.jsxs("div", { className: classNames(styles$1.container, className), "data-testid": "radio-button-container", "data-size": size, "data-variant": variant, "data-checked": checked, "data-disabled": disabled, "data-error": !!error, children: [jsxRuntimeExports.jsx("div", { className: classNames(styles$1.radioWrapper, sizes.container), children: jsxRuntimeExports.jsx("input", { id: radioId, name: name, type: "radio", value: value, checked: checked, onChange: handleChange, disabled: disabled, required: required, className: radioClasses, "aria-describedby":
|
|
527
|
-
};
|
|
529
|
+
return (jsxRuntimeExports.jsxs("div", { className: classNames(styles$1.container, className), "data-testid": "radio-button-container", "data-size": size, "data-variant": variant, "data-checked": checked, "data-disabled": disabled, "data-error": !!error, children: [jsxRuntimeExports.jsx("div", { className: classNames(styles$1.radioWrapper, sizes.container), children: jsxRuntimeExports.jsx("input", { ref: ref, id: radioId, name: name, type: "radio", value: value, checked: checked, onChange: handleChange, disabled: disabled, required: required, className: radioClasses, "aria-describedby": describedBy, "aria-invalid": error ? true : undefined }) }), jsxRuntimeExports.jsxs("div", { className: styles$1.contentWrapper, children: [jsxRuntimeExports.jsx("label", { htmlFor: radioId, className: labelClasses, children: label }), description && (jsxRuntimeExports.jsx("p", { id: `${radioId}-description`, className: descriptionClasses, children: description })), error && (jsxRuntimeExports.jsx("p", { id: `${radioId}-error`, className: errorClasses, children: error }))] })] }));
|
|
530
|
+
});
|
|
528
531
|
|
|
529
|
-
var css_248z = "/* Radio group orientation */\n.RadioGroup-module_groupVertical__5DpXK {\n display: flex;\n flex-direction: column;\n gap: var(--lb-space-3);\n}\n\n.RadioGroup-module_groupHorizontal__SFlwH {\n display: flex;\n flex-direction: row;\n flex-wrap: wrap;\n gap: var(--lb-space-4);\n}\n\n/* Group label */\n.RadioGroup-module_groupLabel__b5sBv {\n font-weight: var(--lb-font-weight-semibold);\n margin-bottom: var(--lb-space-3);\n color: var(--lb-color-foreground);\n}\n\n.RadioGroup-module_groupLabelInvalid__YrZzU {\n color: var(--lb-color-danger);\n}\n\n/* Bordered fieldset */\n.RadioGroup-module_fieldset__cXVuK {\n border-radius: var(--lb-radius-lg);\n padding: var(--lb-space-4);\n border: 1px solid var(--lb-color-border);\n min-inline-size: auto;\n}\n\n.RadioGroup-module_fieldsetInvalid__2ih-T {\n border: 2px solid var(--lb-color-danger);\n}\n\n.RadioGroup-module_legend__dJZQq {\n padding: 0 var(--lb-space-2);\n font-size: var(--lb-font-size-sm);\n font-weight: var(--lb-font-weight-medium);\n color: var(--lb-color-neutral-700);\n}\n\n.RadioGroup-module_legendInvalid__llTj2 {\n color: var(--lb-color-danger);\n}\n\n/* Error message */\n.RadioGroup-module_error__YzQEP {\n font-size: var(--lb-font-size-sm);\n color: var(--lb-color-danger);\n margin-top: var(--lb-space-2);\n}\n\n/* Selected label preview */\n.RadioGroup-module_selectedLabel__OG4Ln {\n margin-top: var(--lb-space-4);\n padding: var(--lb-space-3);\n background: var(--lb-color-neutral-100);\n border-radius: var(--lb-radius-sm);\n}\n";
|
|
530
|
-
var styles = {"groupVertical":"RadioGroup-module_groupVertical__5DpXK","groupHorizontal":"RadioGroup-module_groupHorizontal__SFlwH","groupLabel":"RadioGroup-module_groupLabel__b5sBv","groupLabelInvalid":"RadioGroup-module_groupLabelInvalid__YrZzU","fieldset":"RadioGroup-module_fieldset__cXVuK","fieldsetInvalid":"RadioGroup-module_fieldsetInvalid__2ih-T","legend":"RadioGroup-module_legend__dJZQq","legendInvalid":"RadioGroup-module_legendInvalid__llTj2","error":"RadioGroup-module_error__YzQEP","selectedLabel":"RadioGroup-module_selectedLabel__OG4Ln"};
|
|
532
|
+
var css_248z = "/* Radio group orientation */\n.RadioGroup-module_groupVertical__5DpXK {\n display: flex;\n flex-direction: column;\n gap: var(--lb-space-3);\n}\n\n.RadioGroup-module_groupHorizontal__SFlwH {\n display: flex;\n flex-direction: row;\n flex-wrap: wrap;\n gap: var(--lb-space-4);\n}\n\n/* Group label */\n.RadioGroup-module_groupLabel__b5sBv {\n font-weight: var(--lb-font-weight-semibold);\n margin-bottom: var(--lb-space-3);\n color: var(--lb-color-foreground);\n}\n\n.RadioGroup-module_groupLabelInvalid__YrZzU {\n color: var(--lb-color-danger);\n}\n\n/* Bordered fieldset */\n.RadioGroup-module_fieldset__cXVuK {\n border-radius: var(--lb-radius-lg);\n padding: var(--lb-space-4);\n border: 1px solid var(--lb-color-border);\n min-inline-size: auto;\n}\n\n.RadioGroup-module_fieldsetInvalid__2ih-T {\n border: 2px solid var(--lb-color-danger);\n}\n\n.RadioGroup-module_legend__dJZQq {\n padding: 0 var(--lb-space-2);\n font-size: var(--lb-font-size-sm);\n font-weight: var(--lb-font-weight-medium);\n color: var(--lb-color-neutral-700);\n}\n\n.RadioGroup-module_legendInvalid__llTj2 {\n color: var(--lb-color-danger);\n}\n\n/* Error message */\n.RadioGroup-module_error__YzQEP {\n font-size: var(--lb-font-size-sm);\n color: var(--lb-color-danger);\n margin-top: var(--lb-space-2);\n}\n\n/* Selected label preview */\n.RadioGroup-module_selectedLabel__OG4Ln {\n margin-top: var(--lb-space-4);\n padding: var(--lb-space-3);\n background: var(--lb-color-neutral-100);\n border-radius: var(--lb-radius-sm);\n}\n\n.RadioGroup-module_hint__bFpkX {\n margin: 0.25rem 0 0;\n font-size: var(--lb-font-size-xs);\n color: var(--lb-color-muted-foreground);\n}\n";
|
|
533
|
+
var styles = {"groupVertical":"RadioGroup-module_groupVertical__5DpXK","groupHorizontal":"RadioGroup-module_groupHorizontal__SFlwH","groupLabel":"RadioGroup-module_groupLabel__b5sBv","groupLabelInvalid":"RadioGroup-module_groupLabelInvalid__YrZzU","fieldset":"RadioGroup-module_fieldset__cXVuK","fieldsetInvalid":"RadioGroup-module_fieldsetInvalid__2ih-T","legend":"RadioGroup-module_legend__dJZQq","legendInvalid":"RadioGroup-module_legendInvalid__llTj2","error":"RadioGroup-module_error__YzQEP","selectedLabel":"RadioGroup-module_selectedLabel__OG4Ln","hint":"RadioGroup-module_hint__bFpkX"};
|
|
531
534
|
styleInject(css_248z);
|
|
532
535
|
|
|
533
|
-
const RadioGroup = ({ name, options, value, onChange, orientation = "vertical", size = "md", variant = "default", disabled = false, required = false, error, className = "", showSelectedLabel = false, selectedLabelText = "
|
|
536
|
+
const RadioGroup = React.forwardRef(function RadioGroup({ name, options, value, onChange, orientation = "vertical", size = "md", variant = "default", disabled = false, required = false, error, hint, label, id, className = "", showSelectedLabel = false, selectedLabelText = "Seleccionado:", groupLabel, bordered = false, borderLabel, }, ref) {
|
|
537
|
+
const generatedId = React.useId();
|
|
538
|
+
const baseId = id ?? `${name}-${generatedId}`;
|
|
539
|
+
const titulo = groupLabel ?? label;
|
|
540
|
+
const labelId = `${baseId}-etiqueta`;
|
|
541
|
+
const hintId = `${baseId}-ayuda`;
|
|
542
|
+
const errorId = `${baseId}-error`;
|
|
543
|
+
const describedBy = [hint && hintId, error && errorId].filter(Boolean).join(" ") || undefined;
|
|
534
544
|
const orientationClasses = {
|
|
535
545
|
vertical: styles.groupVertical,
|
|
536
546
|
horizontal: styles.groupHorizontal,
|
|
537
547
|
};
|
|
538
548
|
const selectedOption = options.find((option) => option.value === value);
|
|
539
|
-
const radioGroupContent = (jsxRuntimeExports.jsx("div", { className: orientationClasses[orientation], role: "radiogroup", children: options.map((option) => (jsxRuntimeExports.jsx(RadioButton, { name: name, label: option.label, value: option.value, checked: value === option.value, onChange: onChange, description: option.description, disabled: disabled || option.disabled, required: required, size: size, variant: variant }, option.value))) }));
|
|
540
|
-
return (jsxRuntimeExports.jsxs("div", { className: className, children: [
|
|
541
|
-
};
|
|
549
|
+
const radioGroupContent = (jsxRuntimeExports.jsx("div", { ref: ref, id: baseId, className: orientationClasses[orientation], role: "radiogroup", "aria-labelledby": titulo ? labelId : undefined, "aria-label": !titulo ? borderLabel : undefined, "aria-describedby": describedBy, "aria-invalid": error ? true : undefined, "aria-required": required || undefined, children: options.map((option) => (jsxRuntimeExports.jsx(RadioButton, { name: name, label: option.label, value: option.value, checked: value === option.value, onChange: onChange, description: option.description, disabled: disabled || option.disabled, required: required, size: size, variant: variant }, option.value))) }));
|
|
550
|
+
return (jsxRuntimeExports.jsxs("div", { className: className, children: [titulo && (jsxRuntimeExports.jsx("div", { id: labelId, className: `${styles.groupLabel} ${required && !value ? styles.groupLabelInvalid : ""}`, children: titulo })), bordered ? (jsxRuntimeExports.jsxs("fieldset", { className: `${styles.fieldset} ${required && !value ? styles.fieldsetInvalid : ""}`, children: [borderLabel && (jsxRuntimeExports.jsx("legend", { className: `${styles.legend} ${required && !value ? styles.legendInvalid : ""}`, children: borderLabel })), radioGroupContent] })) : (radioGroupContent), hint && (jsxRuntimeExports.jsx("p", { id: hintId, className: styles.hint, children: hint })), error && (jsxRuntimeExports.jsx("p", { id: errorId, className: styles.error, role: "alert", children: error })), showSelectedLabel && (jsxRuntimeExports.jsxs("div", { className: styles.selectedLabel, children: [jsxRuntimeExports.jsx("strong", { children: selectedLabelText }), " ", selectedOption?.label || value || "Ninguno"] }))] }));
|
|
551
|
+
});
|
|
542
552
|
|
|
543
553
|
exports.RadioGroup = RadioGroup;
|
|
544
554
|
exports.default = RadioButton;
|
package/dist/index.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ interface RadioButtonProps {
|
|
|
17
17
|
size?: RadioSize;
|
|
18
18
|
variant?: RadioVariant;
|
|
19
19
|
}
|
|
20
|
-
declare const RadioButton: React.
|
|
20
|
+
declare const RadioButton: React.ForwardRefExoticComponent<RadioButtonProps & React.RefAttributes<HTMLInputElement>>;
|
|
21
21
|
|
|
22
22
|
type RadioGroupOrientation = "vertical" | "horizontal";
|
|
23
23
|
interface RadioOption {
|
|
@@ -37,6 +37,11 @@ interface RadioGroupProps {
|
|
|
37
37
|
disabled?: boolean;
|
|
38
38
|
required?: boolean;
|
|
39
39
|
error?: string;
|
|
40
|
+
/** Texto de ayuda bajo el grupo. */
|
|
41
|
+
hint?: string;
|
|
42
|
+
/** Etiqueta del grupo (alias de `groupLabel`). */
|
|
43
|
+
label?: string;
|
|
44
|
+
id?: string;
|
|
40
45
|
className?: string;
|
|
41
46
|
showSelectedLabel?: boolean;
|
|
42
47
|
selectedLabelText?: string;
|
|
@@ -44,7 +49,7 @@ interface RadioGroupProps {
|
|
|
44
49
|
bordered?: boolean;
|
|
45
50
|
borderLabel?: string;
|
|
46
51
|
}
|
|
47
|
-
declare const RadioGroup: React.
|
|
52
|
+
declare const RadioGroup: React.ForwardRefExoticComponent<RadioGroupProps & React.RefAttributes<HTMLDivElement>>;
|
|
48
53
|
|
|
49
54
|
export { RadioGroup, RadioButton as default };
|
|
50
55
|
export type { RadioButtonProps, RadioGroupOrientation, RadioGroupProps, RadioOption, RadioSize, RadioVariant };
|
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = {exports: {}};
|
|
4
4
|
|
|
@@ -336,7 +336,7 @@ function requireReactJsxRuntime_development () {
|
|
|
336
336
|
object.$$typeof === REACT_ELEMENT_TYPE
|
|
337
337
|
);
|
|
338
338
|
}
|
|
339
|
-
var React =
|
|
339
|
+
var React$1 = React,
|
|
340
340
|
REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
|
|
341
341
|
REACT_PORTAL_TYPE = Symbol.for("react.portal"),
|
|
342
342
|
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
|
|
@@ -352,7 +352,7 @@ function requireReactJsxRuntime_development () {
|
|
|
352
352
|
REACT_ACTIVITY_TYPE = Symbol.for("react.activity"),
|
|
353
353
|
REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"),
|
|
354
354
|
ReactSharedInternals =
|
|
355
|
-
React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
|
|
355
|
+
React$1.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
|
|
356
356
|
hasOwnProperty = Object.prototype.hasOwnProperty,
|
|
357
357
|
isArrayImpl = Array.isArray,
|
|
358
358
|
createTask = console.createTask
|
|
@@ -360,15 +360,15 @@ function requireReactJsxRuntime_development () {
|
|
|
360
360
|
: function () {
|
|
361
361
|
return null;
|
|
362
362
|
};
|
|
363
|
-
React = {
|
|
363
|
+
React$1 = {
|
|
364
364
|
react_stack_bottom_frame: function (callStackForError) {
|
|
365
365
|
return callStackForError();
|
|
366
366
|
}
|
|
367
367
|
};
|
|
368
368
|
var specialPropKeyWarningShown;
|
|
369
369
|
var didWarnAboutElementRef = {};
|
|
370
|
-
var unknownOwnerDebugStack = React.react_stack_bottom_frame.bind(
|
|
371
|
-
React,
|
|
370
|
+
var unknownOwnerDebugStack = React$1.react_stack_bottom_frame.bind(
|
|
371
|
+
React$1,
|
|
372
372
|
UnknownOwner
|
|
373
373
|
)();
|
|
374
374
|
var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
|
|
@@ -496,8 +496,11 @@ const variantClasses = {
|
|
|
496
496
|
focus: styles$1.radioFocusDanger,
|
|
497
497
|
},
|
|
498
498
|
};
|
|
499
|
-
const RadioButton = ({ id, name, label, value, checked = false, onChange, disabled = false, description, error, className = "", required = false, size = "md", variant = "default", })
|
|
499
|
+
const RadioButton = React.forwardRef(function RadioButton({ id, name, label, value, checked = false, onChange, disabled = false, description, error, className = "", required = false, size = "md", variant = "default", }, ref) {
|
|
500
500
|
const radioId = id || `radio-${name}-${value}`;
|
|
501
|
+
const describedBy = [description && `${radioId}-description`, error && `${radioId}-error`]
|
|
502
|
+
.filter(Boolean)
|
|
503
|
+
.join(" ") || undefined;
|
|
501
504
|
const sizes = sizeClasses[size];
|
|
502
505
|
const variants = variantClasses[variant];
|
|
503
506
|
const handleChange = (event) => {
|
|
@@ -519,21 +522,28 @@ const RadioButton = ({ id, name, label, value, checked = false, onChange, disabl
|
|
|
519
522
|
: size === "lg"
|
|
520
523
|
? styles$1.errorLg
|
|
521
524
|
: styles$1.errorMd);
|
|
522
|
-
return (jsxRuntimeExports.jsxs("div", { className: classNames(styles$1.container, className), "data-testid": "radio-button-container", "data-size": size, "data-variant": variant, "data-checked": checked, "data-disabled": disabled, "data-error": !!error, children: [jsxRuntimeExports.jsx("div", { className: classNames(styles$1.radioWrapper, sizes.container), children: jsxRuntimeExports.jsx("input", { id: radioId, name: name, type: "radio", value: value, checked: checked, onChange: handleChange, disabled: disabled, required: required, className: radioClasses, "aria-describedby":
|
|
523
|
-
};
|
|
525
|
+
return (jsxRuntimeExports.jsxs("div", { className: classNames(styles$1.container, className), "data-testid": "radio-button-container", "data-size": size, "data-variant": variant, "data-checked": checked, "data-disabled": disabled, "data-error": !!error, children: [jsxRuntimeExports.jsx("div", { className: classNames(styles$1.radioWrapper, sizes.container), children: jsxRuntimeExports.jsx("input", { ref: ref, id: radioId, name: name, type: "radio", value: value, checked: checked, onChange: handleChange, disabled: disabled, required: required, className: radioClasses, "aria-describedby": describedBy, "aria-invalid": error ? true : undefined }) }), jsxRuntimeExports.jsxs("div", { className: styles$1.contentWrapper, children: [jsxRuntimeExports.jsx("label", { htmlFor: radioId, className: labelClasses, children: label }), description && (jsxRuntimeExports.jsx("p", { id: `${radioId}-description`, className: descriptionClasses, children: description })), error && (jsxRuntimeExports.jsx("p", { id: `${radioId}-error`, className: errorClasses, children: error }))] })] }));
|
|
526
|
+
});
|
|
524
527
|
|
|
525
|
-
var css_248z = "/* Radio group orientation */\n.RadioGroup-module_groupVertical__5DpXK {\n display: flex;\n flex-direction: column;\n gap: var(--lb-space-3);\n}\n\n.RadioGroup-module_groupHorizontal__SFlwH {\n display: flex;\n flex-direction: row;\n flex-wrap: wrap;\n gap: var(--lb-space-4);\n}\n\n/* Group label */\n.RadioGroup-module_groupLabel__b5sBv {\n font-weight: var(--lb-font-weight-semibold);\n margin-bottom: var(--lb-space-3);\n color: var(--lb-color-foreground);\n}\n\n.RadioGroup-module_groupLabelInvalid__YrZzU {\n color: var(--lb-color-danger);\n}\n\n/* Bordered fieldset */\n.RadioGroup-module_fieldset__cXVuK {\n border-radius: var(--lb-radius-lg);\n padding: var(--lb-space-4);\n border: 1px solid var(--lb-color-border);\n min-inline-size: auto;\n}\n\n.RadioGroup-module_fieldsetInvalid__2ih-T {\n border: 2px solid var(--lb-color-danger);\n}\n\n.RadioGroup-module_legend__dJZQq {\n padding: 0 var(--lb-space-2);\n font-size: var(--lb-font-size-sm);\n font-weight: var(--lb-font-weight-medium);\n color: var(--lb-color-neutral-700);\n}\n\n.RadioGroup-module_legendInvalid__llTj2 {\n color: var(--lb-color-danger);\n}\n\n/* Error message */\n.RadioGroup-module_error__YzQEP {\n font-size: var(--lb-font-size-sm);\n color: var(--lb-color-danger);\n margin-top: var(--lb-space-2);\n}\n\n/* Selected label preview */\n.RadioGroup-module_selectedLabel__OG4Ln {\n margin-top: var(--lb-space-4);\n padding: var(--lb-space-3);\n background: var(--lb-color-neutral-100);\n border-radius: var(--lb-radius-sm);\n}\n";
|
|
526
|
-
var styles = {"groupVertical":"RadioGroup-module_groupVertical__5DpXK","groupHorizontal":"RadioGroup-module_groupHorizontal__SFlwH","groupLabel":"RadioGroup-module_groupLabel__b5sBv","groupLabelInvalid":"RadioGroup-module_groupLabelInvalid__YrZzU","fieldset":"RadioGroup-module_fieldset__cXVuK","fieldsetInvalid":"RadioGroup-module_fieldsetInvalid__2ih-T","legend":"RadioGroup-module_legend__dJZQq","legendInvalid":"RadioGroup-module_legendInvalid__llTj2","error":"RadioGroup-module_error__YzQEP","selectedLabel":"RadioGroup-module_selectedLabel__OG4Ln"};
|
|
528
|
+
var css_248z = "/* Radio group orientation */\n.RadioGroup-module_groupVertical__5DpXK {\n display: flex;\n flex-direction: column;\n gap: var(--lb-space-3);\n}\n\n.RadioGroup-module_groupHorizontal__SFlwH {\n display: flex;\n flex-direction: row;\n flex-wrap: wrap;\n gap: var(--lb-space-4);\n}\n\n/* Group label */\n.RadioGroup-module_groupLabel__b5sBv {\n font-weight: var(--lb-font-weight-semibold);\n margin-bottom: var(--lb-space-3);\n color: var(--lb-color-foreground);\n}\n\n.RadioGroup-module_groupLabelInvalid__YrZzU {\n color: var(--lb-color-danger);\n}\n\n/* Bordered fieldset */\n.RadioGroup-module_fieldset__cXVuK {\n border-radius: var(--lb-radius-lg);\n padding: var(--lb-space-4);\n border: 1px solid var(--lb-color-border);\n min-inline-size: auto;\n}\n\n.RadioGroup-module_fieldsetInvalid__2ih-T {\n border: 2px solid var(--lb-color-danger);\n}\n\n.RadioGroup-module_legend__dJZQq {\n padding: 0 var(--lb-space-2);\n font-size: var(--lb-font-size-sm);\n font-weight: var(--lb-font-weight-medium);\n color: var(--lb-color-neutral-700);\n}\n\n.RadioGroup-module_legendInvalid__llTj2 {\n color: var(--lb-color-danger);\n}\n\n/* Error message */\n.RadioGroup-module_error__YzQEP {\n font-size: var(--lb-font-size-sm);\n color: var(--lb-color-danger);\n margin-top: var(--lb-space-2);\n}\n\n/* Selected label preview */\n.RadioGroup-module_selectedLabel__OG4Ln {\n margin-top: var(--lb-space-4);\n padding: var(--lb-space-3);\n background: var(--lb-color-neutral-100);\n border-radius: var(--lb-radius-sm);\n}\n\n.RadioGroup-module_hint__bFpkX {\n margin: 0.25rem 0 0;\n font-size: var(--lb-font-size-xs);\n color: var(--lb-color-muted-foreground);\n}\n";
|
|
529
|
+
var styles = {"groupVertical":"RadioGroup-module_groupVertical__5DpXK","groupHorizontal":"RadioGroup-module_groupHorizontal__SFlwH","groupLabel":"RadioGroup-module_groupLabel__b5sBv","groupLabelInvalid":"RadioGroup-module_groupLabelInvalid__YrZzU","fieldset":"RadioGroup-module_fieldset__cXVuK","fieldsetInvalid":"RadioGroup-module_fieldsetInvalid__2ih-T","legend":"RadioGroup-module_legend__dJZQq","legendInvalid":"RadioGroup-module_legendInvalid__llTj2","error":"RadioGroup-module_error__YzQEP","selectedLabel":"RadioGroup-module_selectedLabel__OG4Ln","hint":"RadioGroup-module_hint__bFpkX"};
|
|
527
530
|
styleInject(css_248z);
|
|
528
531
|
|
|
529
|
-
const RadioGroup = ({ name, options, value, onChange, orientation = "vertical", size = "md", variant = "default", disabled = false, required = false, error, className = "", showSelectedLabel = false, selectedLabelText = "
|
|
532
|
+
const RadioGroup = React.forwardRef(function RadioGroup({ name, options, value, onChange, orientation = "vertical", size = "md", variant = "default", disabled = false, required = false, error, hint, label, id, className = "", showSelectedLabel = false, selectedLabelText = "Seleccionado:", groupLabel, bordered = false, borderLabel, }, ref) {
|
|
533
|
+
const generatedId = React.useId();
|
|
534
|
+
const baseId = id ?? `${name}-${generatedId}`;
|
|
535
|
+
const titulo = groupLabel ?? label;
|
|
536
|
+
const labelId = `${baseId}-etiqueta`;
|
|
537
|
+
const hintId = `${baseId}-ayuda`;
|
|
538
|
+
const errorId = `${baseId}-error`;
|
|
539
|
+
const describedBy = [hint && hintId, error && errorId].filter(Boolean).join(" ") || undefined;
|
|
530
540
|
const orientationClasses = {
|
|
531
541
|
vertical: styles.groupVertical,
|
|
532
542
|
horizontal: styles.groupHorizontal,
|
|
533
543
|
};
|
|
534
544
|
const selectedOption = options.find((option) => option.value === value);
|
|
535
|
-
const radioGroupContent = (jsxRuntimeExports.jsx("div", { className: orientationClasses[orientation], role: "radiogroup", children: options.map((option) => (jsxRuntimeExports.jsx(RadioButton, { name: name, label: option.label, value: option.value, checked: value === option.value, onChange: onChange, description: option.description, disabled: disabled || option.disabled, required: required, size: size, variant: variant }, option.value))) }));
|
|
536
|
-
return (jsxRuntimeExports.jsxs("div", { className: className, children: [
|
|
537
|
-
};
|
|
545
|
+
const radioGroupContent = (jsxRuntimeExports.jsx("div", { ref: ref, id: baseId, className: orientationClasses[orientation], role: "radiogroup", "aria-labelledby": titulo ? labelId : undefined, "aria-label": !titulo ? borderLabel : undefined, "aria-describedby": describedBy, "aria-invalid": error ? true : undefined, "aria-required": required || undefined, children: options.map((option) => (jsxRuntimeExports.jsx(RadioButton, { name: name, label: option.label, value: option.value, checked: value === option.value, onChange: onChange, description: option.description, disabled: disabled || option.disabled, required: required, size: size, variant: variant }, option.value))) }));
|
|
546
|
+
return (jsxRuntimeExports.jsxs("div", { className: className, children: [titulo && (jsxRuntimeExports.jsx("div", { id: labelId, className: `${styles.groupLabel} ${required && !value ? styles.groupLabelInvalid : ""}`, children: titulo })), bordered ? (jsxRuntimeExports.jsxs("fieldset", { className: `${styles.fieldset} ${required && !value ? styles.fieldsetInvalid : ""}`, children: [borderLabel && (jsxRuntimeExports.jsx("legend", { className: `${styles.legend} ${required && !value ? styles.legendInvalid : ""}`, children: borderLabel })), radioGroupContent] })) : (radioGroupContent), hint && (jsxRuntimeExports.jsx("p", { id: hintId, className: styles.hint, children: hint })), error && (jsxRuntimeExports.jsx("p", { id: errorId, className: styles.error, role: "alert", children: error })), showSelectedLabel && (jsxRuntimeExports.jsxs("div", { className: styles.selectedLabel, children: [jsxRuntimeExports.jsx("strong", { children: selectedLabelText }), " ", selectedOption?.label || value || "Ninguno"] }))] }));
|
|
547
|
+
});
|
|
538
548
|
|
|
539
549
|
export { RadioGroup, RadioButton as default };
|