infinity-ui-elements 1.8.62 → 1.8.63

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
@@ -3251,9 +3251,9 @@ Pagination.displayName = "Pagination";
3251
3251
  const radioVariants = cva("relative inline-flex items-center justify-center shrink-0 border transition-all cursor-pointer rounded-full", {
3252
3252
  variants: {
3253
3253
  size: {
3254
- small: "w-[14px] h-[14px] border-[1.5px]",
3255
- medium: "w-[16px] h-[16px] border-[1.5px]",
3256
- large: "w-[20px] h-[20px] border-[2px]",
3254
+ small: "w-[10px] h-[10px] border-[1.5px]",
3255
+ medium: "w-[12px] h-[12px] border-[1.5px]",
3256
+ large: "w-[16px] h-[16px] border-[2px]",
3257
3257
  },
3258
3258
  validationState: {
3259
3259
  none: "",
@@ -3378,17 +3378,20 @@ const Radio = React.forwardRef(({ label, errorText, size = "medium", validationS
3378
3378
  small: {
3379
3379
  gap: "gap-2",
3380
3380
  labelSize: "text-body-small-regular",
3381
- innerCircleSize: 6,
3381
+ innerCircleSize: 4,
3382
+ boundingBoxSize: "w-[14px] h-[14px] p-1",
3382
3383
  },
3383
3384
  medium: {
3384
3385
  gap: "gap-2.5",
3385
3386
  labelSize: "text-body-medium-regular",
3386
- innerCircleSize: 7,
3387
+ innerCircleSize: 5,
3388
+ boundingBoxSize: "w-[16px] h-[16px] p-1",
3387
3389
  },
3388
3390
  large: {
3389
3391
  gap: "gap-3",
3390
3392
  labelSize: "text-body-large-regular",
3391
- innerCircleSize: 8,
3393
+ innerCircleSize: 7,
3394
+ boundingBoxSize: "w-[20px] h-[20px] p-1",
3392
3395
  },
3393
3396
  };
3394
3397
  const config = sizeConfig[size];
@@ -3398,16 +3401,16 @@ const Radio = React.forwardRef(({ label, errorText, size = "medium", validationS
3398
3401
  ? "bg-action-outline-negative-faded"
3399
3402
  : "bg-action-outline-primary-faded"), style: {
3400
3403
  animation: "var(--animate-checkbox-ripple)",
3401
- } })), jsx("div", { className: cn(radioVariants({
3402
- size,
3403
- validationState,
3404
- isChecked,
3405
- isDisabled,
3406
- isFocused,
3407
- }), className), children: isChecked && (jsx("div", { className: "rounded-full bg-white transition-all", style: {
3408
- width: `${config.innerCircleSize}px`,
3409
- height: `${config.innerCircleSize}px`,
3410
- } })) })] }), label && (jsx("label", { className: cn(config.labelSize, "select-none inline-flex items-center", isDisabled
3404
+ } })), jsx("div", { className: cn("inline-flex items-center justify-center shrink-0 box-border", config.boundingBoxSize), children: jsx("div", { className: cn(radioVariants({
3405
+ size,
3406
+ validationState,
3407
+ isChecked,
3408
+ isDisabled,
3409
+ isFocused,
3410
+ }), className), children: isChecked && (jsx("div", { className: "rounded-full bg-white transition-all box-border", style: {
3411
+ width: `${config.innerCircleSize}px`,
3412
+ height: `${config.innerCircleSize}px`,
3413
+ } })) }) })] }), label && (jsx("label", { className: cn(config.labelSize, "select-none inline-flex items-center", isDisabled
3411
3414
  ? "text-surface-ink-neutral-disabled"
3412
3415
  : "text-surface-ink-neutral-normal", labelClassName), children: label }))] }), shouldShowError && (jsx(FormFooter, { helperText: errorText, validationState: "negative", size: size, isDisabled: isDisabled }))] }));
3413
3416
  });
@@ -4184,31 +4187,73 @@ const switchVariants = cva("relative inline-flex items-center shrink-0 cursor-po
4184
4187
  medium: "w-[28px] h-[16px]",
4185
4188
  large: "w-[36px] h-[20px]",
4186
4189
  },
4190
+ validationState: {
4191
+ none: "",
4192
+ error: "",
4193
+ },
4187
4194
  isChecked: {
4188
- true: "bg-action-fill-primary-default ",
4189
- false: "bg-surface-fill-neutral-subtle",
4195
+ true: "",
4196
+ false: "",
4190
4197
  },
4191
4198
  isDisabled: {
4192
4199
  true: "cursor-not-allowed opacity-60",
4193
4200
  false: "",
4194
4201
  },
4202
+ isFocused: {
4203
+ true: "",
4204
+ false: "",
4205
+ },
4195
4206
  },
4196
4207
  compoundVariants: [
4208
+ // Unchecked state - none validation
4209
+ {
4210
+ isChecked: false,
4211
+ validationState: "none",
4212
+ isDisabled: false,
4213
+ class: "bg-surface-fill-neutral-subtle hover:bg-action-fill-neutral-faded",
4214
+ },
4215
+ // Checked state - none validation
4216
+ {
4217
+ isChecked: true,
4218
+ validationState: "none",
4219
+ isDisabled: false,
4220
+ class: "bg-action-fill-primary-default hover:bg-action-fill-primary-hover",
4221
+ },
4222
+ // Checked state - error validation
4197
4223
  {
4198
4224
  isChecked: true,
4225
+ validationState: "error",
4199
4226
  isDisabled: false,
4200
- class: "hover:bg-action-fill-primary-hover ",
4227
+ class: "bg-action-fill-negative-default hover:bg-action-fill-negative-hover",
4201
4228
  },
4229
+ // Unchecked state - error validation
4202
4230
  {
4203
4231
  isChecked: false,
4232
+ validationState: "error",
4204
4233
  isDisabled: false,
4205
- class: "hover:bg-action-fill-neutral-faded",
4234
+ class: "bg-surface-fill-neutral-subtle hover:bg-action-fill-neutral-faded",
4235
+ },
4236
+ // Focused state - none validation
4237
+ {
4238
+ isFocused: true,
4239
+ validationState: "none",
4240
+ isDisabled: false,
4241
+ class: "ring-2 ring-action-outline-primary-faded",
4242
+ },
4243
+ // Focused state - error validation
4244
+ {
4245
+ isFocused: true,
4246
+ validationState: "error",
4247
+ isDisabled: false,
4248
+ class: "ring-2 ring-action-outline-negative-faded",
4206
4249
  },
4207
4250
  ],
4208
4251
  defaultVariants: {
4209
4252
  size: "medium",
4253
+ validationState: "none",
4210
4254
  isChecked: false,
4211
4255
  isDisabled: false,
4256
+ isFocused: false,
4212
4257
  },
4213
4258
  });
4214
4259
  const switchThumbVariants = cva("inline-block rounded-full bg-white shadow-sm transition-transform duration-200", {
@@ -4263,8 +4308,10 @@ const switchThumbVariants = cva("inline-block rounded-full bg-white shadow-sm tr
4263
4308
  isChecked: false,
4264
4309
  },
4265
4310
  });
4266
- const Switch = React.forwardRef(({ label, size = "medium", isDisabled = false, containerClassName, labelClassName, trackClassName, thumbClassName, className, checked, onChange, ...props }, ref) => {
4311
+ const Switch = React.forwardRef(({ label, errorText, size = "medium", validationState = "none", isDisabled = false, showErrorText = true, containerClassName, labelClassName, trackClassName, thumbClassName, className, checked, onChange, ...props }, ref) => {
4267
4312
  const [internalChecked, setInternalChecked] = React.useState(false);
4313
+ const [showRipple, setShowRipple] = React.useState(false);
4314
+ const [isFocused, setIsFocused] = React.useState(false);
4268
4315
  const inputRef = React.useRef(null);
4269
4316
  // Use forwarded ref or internal ref
4270
4317
  React.useImperativeHandle(ref, () => inputRef.current);
@@ -4277,17 +4324,35 @@ const Switch = React.forwardRef(({ label, size = "medium", isDisabled = false, c
4277
4324
  setInternalChecked(e.target.checked);
4278
4325
  }
4279
4326
  };
4327
+ const triggerRipple = () => {
4328
+ if (!isDisabled) {
4329
+ setShowRipple(true);
4330
+ setTimeout(() => {
4331
+ setShowRipple(false);
4332
+ }, 360); // Match animation duration (0.36s)
4333
+ }
4334
+ };
4280
4335
  const handleContainerClick = () => {
4281
4336
  if (!isDisabled && inputRef.current) {
4337
+ triggerRipple();
4282
4338
  inputRef.current.click();
4283
4339
  }
4284
4340
  };
4285
4341
  const handleKeyDown = (e) => {
4286
4342
  if ((e.key === " " || e.key === "Enter") && !isDisabled) {
4287
4343
  e.preventDefault();
4344
+ triggerRipple();
4288
4345
  inputRef.current?.click();
4289
4346
  }
4290
4347
  };
4348
+ const handleFocus = () => {
4349
+ if (!isDisabled) {
4350
+ setIsFocused(true);
4351
+ }
4352
+ };
4353
+ const handleBlur = () => {
4354
+ setIsFocused(false);
4355
+ };
4291
4356
  // Size-based configurations
4292
4357
  const sizeConfig = {
4293
4358
  small: {
@@ -4304,16 +4369,24 @@ const Switch = React.forwardRef(({ label, size = "medium", isDisabled = false, c
4304
4369
  },
4305
4370
  };
4306
4371
  const config = sizeConfig[size];
4307
- return (jsx("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, role: "switch", "aria-checked": isChecked, "aria-disabled": isDisabled, tabIndex: isDisabled ? -1 : 0, children: [jsx("input", { ref: inputRef, type: "checkbox", role: "switch", className: "sr-only", checked: isChecked, onChange: handleChange, disabled: isDisabled, ...props }), jsx("div", { className: "relative inline-flex shrink-0", children: jsx("div", { className: cn(switchVariants({
4308
- size,
4309
- isChecked,
4310
- isDisabled,
4311
- }), trackClassName, className, "focus-visible:ring-2 focus-visible:ring-action-outline-primary-faded focus-visible:ring-offset-2"), children: jsx("span", { className: cn(switchThumbVariants({
4312
- size,
4313
- isChecked,
4314
- }), thumbClassName) }) }) }), label && (jsx("label", { className: cn(config.labelSize, "select-none inline-flex items-center", isDisabled
4315
- ? "text-surface-ink-neutral-disabled"
4316
- : "text-surface-ink-neutral-normal", labelClassName), children: label }))] }) }));
4372
+ // Determine if we should show the error text
4373
+ const shouldShowError = errorText && showErrorText;
4374
+ 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: "switch", "aria-checked": isChecked, "aria-disabled": isDisabled, tabIndex: isDisabled ? -1 : 0, children: [jsx("input", { ref: inputRef, type: "checkbox", role: "switch", 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"
4375
+ ? "bg-action-outline-negative-faded"
4376
+ : "bg-action-outline-primary-faded"), style: {
4377
+ animation: "var(--animate-checkbox-ripple)",
4378
+ } })), jsx("div", { className: cn(switchVariants({
4379
+ size,
4380
+ validationState,
4381
+ isChecked,
4382
+ isDisabled,
4383
+ isFocused,
4384
+ }), trackClassName, className), children: jsx("span", { className: cn(switchThumbVariants({
4385
+ size,
4386
+ isChecked,
4387
+ }), thumbClassName) }) })] }), label && (jsx("label", { className: cn(config.labelSize, "select-none inline-flex items-center", isDisabled
4388
+ ? "text-surface-ink-neutral-disabled"
4389
+ : "text-surface-ink-neutral-normal", labelClassName), children: label }))] }), shouldShowError && (jsx(FormFooter, { helperText: errorText, validationState: "negative", size: size, isDisabled: isDisabled }))] }));
4317
4390
  });
4318
4391
  Switch.displayName = "Switch";
4319
4392