infinity-ui-elements 1.9.21 → 1.9.24
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/dist/components/Radio/Radio.d.ts +8 -0
- package/dist/components/Radio/Radio.d.ts.map +1 -1
- package/dist/components/Radio/Radio.stories.d.ts +3 -0
- package/dist/components/Radio/Radio.stories.d.ts.map +1 -1
- package/dist/components/Radio/RadioGroup.d.ts +8 -0
- package/dist/components/Radio/RadioGroup.d.ts.map +1 -1
- package/dist/components/Radio/RadioGroup.stories.d.ts +7 -0
- package/dist/components/Radio/RadioGroup.stories.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.esm.js +38 -20
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +38 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3875,7 +3875,7 @@ const radioVariants = classVarianceAuthority.cva("relative inline-flex items-cen
|
|
|
3875
3875
|
isFocused: false,
|
|
3876
3876
|
},
|
|
3877
3877
|
});
|
|
3878
|
-
const Radio = React__namespace.forwardRef(({ label, errorText, size = "medium", validationState = "none", isDisabled = false, showErrorText = true, containerClassName, labelClassName, className, checked, onChange, ...props }, ref) => {
|
|
3878
|
+
const Radio = React__namespace.forwardRef(({ label, errorText, size = "medium", validationState = "none", isDisabled = false, showErrorText = true, variant = "default", containerClassName, labelClassName, cardClassName, className, checked, onChange, ...props }, ref) => {
|
|
3879
3879
|
const [internalChecked, setInternalChecked] = React__namespace.useState(false);
|
|
3880
3880
|
const [showRipple, setShowRipple] = React__namespace.useState(false);
|
|
3881
3881
|
const [isFocused, setIsFocused] = React__namespace.useState(false);
|
|
@@ -3952,26 +3952,42 @@ const Radio = React__namespace.forwardRef(({ label, errorText, size = "medium",
|
|
|
3952
3952
|
const config = sizeConfig[size];
|
|
3953
3953
|
// Determine if we should show the error text
|
|
3954
3954
|
const shouldShowError = errorText && showErrorText;
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3955
|
+
const radioContent = (jsxRuntime.jsxs("div", { className: cn("inline-flex items-center", config.gap, isDisabled ? "cursor-not-allowed" : "cursor-pointer"), onClick: handleContainerClick, onKeyDown: handleKeyDown, onFocus: handleFocus, onBlur: handleBlur, role: "radio", "aria-checked": isChecked, "aria-disabled": isDisabled, tabIndex: isDisabled ? -1 : 0, children: [jsxRuntime.jsx("input", { ref: inputRef, type: "radio", className: "sr-only", checked: isChecked, onChange: handleChange, disabled: isDisabled, ...props }), jsxRuntime.jsxs("div", { className: "relative inline-flex shrink-0", children: [showRipple && (jsxRuntime.jsx("div", { className: cn("absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full pointer-events-none w-full h-full", validationState === "error"
|
|
3956
|
+
? "bg-action-outline-negative-faded"
|
|
3957
|
+
: "bg-action-outline-primary-faded"), style: {
|
|
3958
|
+
animation: "var(--animate-checkbox-ripple)",
|
|
3959
|
+
} })), jsxRuntime.jsx("div", { className: cn("inline-flex items-center justify-center shrink-0 box-border", config.boundingBoxSize), children: jsxRuntime.jsx("div", { className: cn(radioVariants({
|
|
3960
|
+
size,
|
|
3961
|
+
validationState,
|
|
3962
|
+
isChecked,
|
|
3963
|
+
isDisabled,
|
|
3964
|
+
isFocused,
|
|
3965
|
+
}), className), children: isChecked && (jsxRuntime.jsx("div", { className: "rounded-full bg-white transition-all box-border", style: {
|
|
3966
|
+
width: `${config.innerCircleSize}px`,
|
|
3967
|
+
height: `${config.innerCircleSize}px`,
|
|
3968
|
+
} })) }) })] }), label && (jsxRuntime.jsx("label", { className: cn(config.labelSize, "select-none inline-flex items-center", isDisabled
|
|
3969
|
+
? "text-surface-ink-neutral-disabled"
|
|
3970
|
+
: "text-surface-ink-neutral-normal", labelClassName), children: label }))] }));
|
|
3971
|
+
// Wrap in card container if variant is "card"
|
|
3972
|
+
if (variant === "card") {
|
|
3973
|
+
return (jsxRuntime.jsxs("div", { className: cn("inline-flex flex-col w-full", containerClassName), children: [jsxRuntime.jsx("div", { className: cn("w-full border rounded-xlarge p-5 transition-all", isChecked
|
|
3974
|
+
? "border-action-outline-primary-default bg-action-fill-primary-faded"
|
|
3975
|
+
: "border-surface-outline-neutral-subtle hover:border-surface-outline-neutral-normal hover:bg-surface-fill-neutral-faded", isDisabled
|
|
3976
|
+
? "opacity-60 cursor-not-allowed"
|
|
3977
|
+
: "cursor-pointer", cardClassName), onClick: (e) => {
|
|
3978
|
+
if (!isDisabled) {
|
|
3979
|
+
// Prevent double-click if already clicking on the radio itself
|
|
3980
|
+
if (e.target === inputRef.current)
|
|
3981
|
+
return;
|
|
3982
|
+
inputRef.current?.click();
|
|
3983
|
+
}
|
|
3984
|
+
}, children: radioContent }), shouldShowError && (jsxRuntime.jsx(FormFooter, { helperText: errorText, validationState: "negative", size: size, isDisabled: isDisabled }))] }));
|
|
3985
|
+
}
|
|
3986
|
+
return (jsxRuntime.jsxs("div", { className: cn("inline-flex flex-col w-full", containerClassName), children: [radioContent, shouldShowError && (jsxRuntime.jsx(FormFooter, { helperText: errorText, validationState: "negative", size: size, isDisabled: isDisabled }))] }));
|
|
3971
3987
|
});
|
|
3972
3988
|
Radio.displayName = "Radio";
|
|
3973
3989
|
|
|
3974
|
-
const RadioGroup = React__namespace.forwardRef(({ value: controlledValue, defaultValue, onChange, options, children, label, helperText, errorText, successText, validationState = "none", isDisabled = false, isRequired = false, isOptional = false, size = "medium", name: nameProp, orientation = "vertical", spacing = "normal", containerClassName, labelClassName, groupClassName, infoHeading, infoDescription, LinkComponent, linkText, linkHref, onLinkClick, className, id, ...props }, ref) => {
|
|
3990
|
+
const RadioGroup = React__namespace.forwardRef(({ value: controlledValue, defaultValue, onChange, options, children, label, helperText, errorText, successText, validationState = "none", isDisabled = false, isRequired = false, isOptional = false, size = "medium", name: nameProp, orientation = "vertical", spacing = "normal", variant = "default", containerClassName, labelClassName, groupClassName, cardClassName, infoHeading, infoDescription, LinkComponent, linkText, linkHref, onLinkClick, className, id, ...props }, ref) => {
|
|
3975
3991
|
const [uncontrolledValue, setUncontrolledValue] = React__namespace.useState(defaultValue);
|
|
3976
3992
|
const groupId = React__namespace.useId();
|
|
3977
3993
|
const name = nameProp || `radio-group-${groupId}`;
|
|
@@ -4056,7 +4072,7 @@ const RadioGroup = React__namespace.forwardRef(({ value: controlledValue, defaul
|
|
|
4056
4072
|
if (e.target.checked) {
|
|
4057
4073
|
handleChange(option.value);
|
|
4058
4074
|
}
|
|
4059
|
-
}, size: size, validationState: currentValidationState, isDisabled: optionDisabled, showErrorText: false, containerClassName: option.containerClassName, labelClassName: option.labelClassName }, option.value));
|
|
4075
|
+
}, size: size, variant: variant, validationState: currentValidationState, isDisabled: optionDisabled, showErrorText: false, containerClassName: option.containerClassName, labelClassName: option.labelClassName, cardClassName: cardClassName }, option.value));
|
|
4060
4076
|
});
|
|
4061
4077
|
};
|
|
4062
4078
|
// Clone children and inject props
|
|
@@ -4089,13 +4105,15 @@ const RadioGroup = React__namespace.forwardRef(({ value: controlledValue, defaul
|
|
|
4089
4105
|
}
|
|
4090
4106
|
},
|
|
4091
4107
|
size: child.props.size || size,
|
|
4108
|
+
variant: child.props.variant || variant,
|
|
4092
4109
|
validationState: child.props.validationState || currentValidationState,
|
|
4093
4110
|
isDisabled: childDisabled,
|
|
4094
4111
|
showErrorText: false,
|
|
4112
|
+
cardClassName: cardClassName,
|
|
4095
4113
|
});
|
|
4096
4114
|
});
|
|
4097
4115
|
};
|
|
4098
|
-
return (jsxRuntime.jsxs("div", { ref: ref, className: cn("w-full flex flex-col", sizeConfig[size].gap, containerClassName), ...props, children: [label && (jsxRuntime.jsx(FormHeader, { label: label, size: size, isRequired: isRequired, isOptional: isOptional, infoHeading: infoHeading, infoDescription: infoDescription, LinkComponent: LinkComponent, linkText: linkText, linkHref: linkHref, onLinkClick: onLinkClick, htmlFor: id, className: "mb-2", labelClassName: labelClassName })), jsxRuntime.jsx("div", { ref: groupRef, role: "radiogroup", "aria-label": label, "aria-required": isRequired, "aria-invalid": currentValidationState === "error", "aria-disabled": isDisabled, className: cn("flex", orientation === "horizontal"
|
|
4116
|
+
return (jsxRuntime.jsxs("div", { ref: ref, className: cn("w-full flex flex-col", sizeConfig[size].gap, containerClassName), ...props, children: [label && (jsxRuntime.jsx(FormHeader, { label: label, size: size, isRequired: isRequired, isOptional: isOptional, infoHeading: infoHeading, infoDescription: infoDescription, LinkComponent: LinkComponent, linkText: linkText, linkHref: linkHref, onLinkClick: onLinkClick, htmlFor: id, className: "mb-2", labelClassName: labelClassName })), jsxRuntime.jsx("div", { ref: groupRef, role: "radiogroup", "aria-label": label, "aria-required": isRequired, "aria-invalid": currentValidationState === "error", "aria-disabled": isDisabled, className: cn("flex w-full", orientation === "horizontal"
|
|
4099
4117
|
? "flex-row items-center"
|
|
4100
4118
|
: "flex-col items-start", spacingConfig[spacing], groupClassName, className), onKeyDown: handleKeyDown, id: id, children: options ? renderOptions() : renderChildren() }), jsxRuntime.jsx(FormFooter, { helperText: displayHelperText, validationState: currentValidationState === "none"
|
|
4101
4119
|
? "default"
|