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/index.esm.js CHANGED
@@ -3854,7 +3854,7 @@ const radioVariants = cva("relative inline-flex items-center justify-center shri
3854
3854
  isFocused: false,
3855
3855
  },
3856
3856
  });
3857
- const Radio = React.forwardRef(({ label, errorText, size = "medium", validationState = "none", isDisabled = false, showErrorText = true, containerClassName, labelClassName, className, checked, onChange, ...props }, ref) => {
3857
+ const Radio = React.forwardRef(({ label, errorText, size = "medium", validationState = "none", isDisabled = false, showErrorText = true, variant = "default", containerClassName, labelClassName, cardClassName, className, checked, onChange, ...props }, ref) => {
3858
3858
  const [internalChecked, setInternalChecked] = React.useState(false);
3859
3859
  const [showRipple, setShowRipple] = React.useState(false);
3860
3860
  const [isFocused, setIsFocused] = React.useState(false);
@@ -3931,26 +3931,42 @@ const Radio = React.forwardRef(({ label, errorText, size = "medium", validationS
3931
3931
  const config = sizeConfig[size];
3932
3932
  // Determine if we should show the error text
3933
3933
  const shouldShowError = errorText && showErrorText;
3934
- return (jsxs("div", { className: cn("inline-flex flex-col", containerClassName), children: [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: [jsx("input", { ref: inputRef, type: "radio", className: "sr-only", checked: isChecked, onChange: handleChange, disabled: isDisabled, ...props }), jsxs("div", { className: "relative inline-flex shrink-0", children: [showRipple && (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"
3935
- ? "bg-action-outline-negative-faded"
3936
- : "bg-action-outline-primary-faded"), style: {
3937
- animation: "var(--animate-checkbox-ripple)",
3938
- } })), jsx("div", { className: cn("inline-flex items-center justify-center shrink-0 box-border", config.boundingBoxSize), children: jsx("div", { className: cn(radioVariants({
3939
- size,
3940
- validationState,
3941
- isChecked,
3942
- isDisabled,
3943
- isFocused,
3944
- }), className), children: isChecked && (jsx("div", { className: "rounded-full bg-white transition-all box-border", style: {
3945
- width: `${config.innerCircleSize}px`,
3946
- height: `${config.innerCircleSize}px`,
3947
- } })) }) })] }), label && (jsx("label", { className: cn(config.labelSize, "select-none inline-flex items-center", isDisabled
3948
- ? "text-surface-ink-neutral-disabled"
3949
- : "text-surface-ink-neutral-normal", labelClassName), children: label }))] }), shouldShowError && (jsx(FormFooter, { helperText: errorText, validationState: "negative", size: size, isDisabled: isDisabled }))] }));
3934
+ const radioContent = (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: [jsx("input", { ref: inputRef, type: "radio", className: "sr-only", checked: isChecked, onChange: handleChange, disabled: isDisabled, ...props }), jsxs("div", { className: "relative inline-flex shrink-0", children: [showRipple && (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"
3935
+ ? "bg-action-outline-negative-faded"
3936
+ : "bg-action-outline-primary-faded"), style: {
3937
+ animation: "var(--animate-checkbox-ripple)",
3938
+ } })), jsx("div", { className: cn("inline-flex items-center justify-center shrink-0 box-border", config.boundingBoxSize), children: jsx("div", { className: cn(radioVariants({
3939
+ size,
3940
+ validationState,
3941
+ isChecked,
3942
+ isDisabled,
3943
+ isFocused,
3944
+ }), className), children: isChecked && (jsx("div", { className: "rounded-full bg-white transition-all box-border", style: {
3945
+ width: `${config.innerCircleSize}px`,
3946
+ height: `${config.innerCircleSize}px`,
3947
+ } })) }) })] }), label && (jsx("label", { className: cn(config.labelSize, "select-none inline-flex items-center", isDisabled
3948
+ ? "text-surface-ink-neutral-disabled"
3949
+ : "text-surface-ink-neutral-normal", labelClassName), children: label }))] }));
3950
+ // Wrap in card container if variant is "card"
3951
+ if (variant === "card") {
3952
+ return (jsxs("div", { className: cn("inline-flex flex-col w-full", containerClassName), children: [jsx("div", { className: cn("w-full border rounded-xlarge p-5 transition-all", isChecked
3953
+ ? "border-action-outline-primary-default bg-action-fill-primary-faded"
3954
+ : "border-surface-outline-neutral-subtle hover:border-surface-outline-neutral-normal hover:bg-surface-fill-neutral-faded", isDisabled
3955
+ ? "opacity-60 cursor-not-allowed"
3956
+ : "cursor-pointer", cardClassName), onClick: (e) => {
3957
+ if (!isDisabled) {
3958
+ // Prevent double-click if already clicking on the radio itself
3959
+ if (e.target === inputRef.current)
3960
+ return;
3961
+ inputRef.current?.click();
3962
+ }
3963
+ }, children: radioContent }), shouldShowError && (jsx(FormFooter, { helperText: errorText, validationState: "negative", size: size, isDisabled: isDisabled }))] }));
3964
+ }
3965
+ return (jsxs("div", { className: cn("inline-flex flex-col w-full", containerClassName), children: [radioContent, shouldShowError && (jsx(FormFooter, { helperText: errorText, validationState: "negative", size: size, isDisabled: isDisabled }))] }));
3950
3966
  });
3951
3967
  Radio.displayName = "Radio";
3952
3968
 
3953
- const RadioGroup = React.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) => {
3969
+ const RadioGroup = React.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) => {
3954
3970
  const [uncontrolledValue, setUncontrolledValue] = React.useState(defaultValue);
3955
3971
  const groupId = React.useId();
3956
3972
  const name = nameProp || `radio-group-${groupId}`;
@@ -4035,7 +4051,7 @@ const RadioGroup = React.forwardRef(({ value: controlledValue, defaultValue, onC
4035
4051
  if (e.target.checked) {
4036
4052
  handleChange(option.value);
4037
4053
  }
4038
- }, size: size, validationState: currentValidationState, isDisabled: optionDisabled, showErrorText: false, containerClassName: option.containerClassName, labelClassName: option.labelClassName }, option.value));
4054
+ }, size: size, variant: variant, validationState: currentValidationState, isDisabled: optionDisabled, showErrorText: false, containerClassName: option.containerClassName, labelClassName: option.labelClassName, cardClassName: cardClassName }, option.value));
4039
4055
  });
4040
4056
  };
4041
4057
  // Clone children and inject props
@@ -4068,13 +4084,15 @@ const RadioGroup = React.forwardRef(({ value: controlledValue, defaultValue, onC
4068
4084
  }
4069
4085
  },
4070
4086
  size: child.props.size || size,
4087
+ variant: child.props.variant || variant,
4071
4088
  validationState: child.props.validationState || currentValidationState,
4072
4089
  isDisabled: childDisabled,
4073
4090
  showErrorText: false,
4091
+ cardClassName: cardClassName,
4074
4092
  });
4075
4093
  });
4076
4094
  };
4077
- return (jsxs("div", { ref: ref, className: cn("w-full flex flex-col", sizeConfig[size].gap, containerClassName), ...props, children: [label && (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 })), jsx("div", { ref: groupRef, role: "radiogroup", "aria-label": label, "aria-required": isRequired, "aria-invalid": currentValidationState === "error", "aria-disabled": isDisabled, className: cn("flex", orientation === "horizontal"
4095
+ return (jsxs("div", { ref: ref, className: cn("w-full flex flex-col", sizeConfig[size].gap, containerClassName), ...props, children: [label && (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 })), 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"
4078
4096
  ? "flex-row items-center"
4079
4097
  : "flex-col items-start", spacingConfig[spacing], groupClassName, className), onKeyDown: handleKeyDown, id: id, children: options ? renderOptions() : renderChildren() }), jsx(FormFooter, { helperText: displayHelperText, validationState: currentValidationState === "none"
4080
4098
  ? "default"