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.js CHANGED
@@ -3272,9 +3272,9 @@ Pagination.displayName = "Pagination";
3272
3272
  const radioVariants = classVarianceAuthority.cva("relative inline-flex items-center justify-center shrink-0 border transition-all cursor-pointer rounded-full", {
3273
3273
  variants: {
3274
3274
  size: {
3275
- small: "w-[14px] h-[14px] border-[1.5px]",
3276
- medium: "w-[16px] h-[16px] border-[1.5px]",
3277
- large: "w-[20px] h-[20px] border-[2px]",
3275
+ small: "w-[10px] h-[10px] border-[1.5px]",
3276
+ medium: "w-[12px] h-[12px] border-[1.5px]",
3277
+ large: "w-[16px] h-[16px] border-[2px]",
3278
3278
  },
3279
3279
  validationState: {
3280
3280
  none: "",
@@ -3399,17 +3399,20 @@ const Radio = React__namespace.forwardRef(({ label, errorText, size = "medium",
3399
3399
  small: {
3400
3400
  gap: "gap-2",
3401
3401
  labelSize: "text-body-small-regular",
3402
- innerCircleSize: 6,
3402
+ innerCircleSize: 4,
3403
+ boundingBoxSize: "w-[14px] h-[14px] p-1",
3403
3404
  },
3404
3405
  medium: {
3405
3406
  gap: "gap-2.5",
3406
3407
  labelSize: "text-body-medium-regular",
3407
- innerCircleSize: 7,
3408
+ innerCircleSize: 5,
3409
+ boundingBoxSize: "w-[16px] h-[16px] p-1",
3408
3410
  },
3409
3411
  large: {
3410
3412
  gap: "gap-3",
3411
3413
  labelSize: "text-body-large-regular",
3412
- innerCircleSize: 8,
3414
+ innerCircleSize: 7,
3415
+ boundingBoxSize: "w-[20px] h-[20px] p-1",
3413
3416
  },
3414
3417
  };
3415
3418
  const config = sizeConfig[size];
@@ -3419,16 +3422,16 @@ const Radio = React__namespace.forwardRef(({ label, errorText, size = "medium",
3419
3422
  ? "bg-action-outline-negative-faded"
3420
3423
  : "bg-action-outline-primary-faded"), style: {
3421
3424
  animation: "var(--animate-checkbox-ripple)",
3422
- } })), jsxRuntime.jsx("div", { className: cn(radioVariants({
3423
- size,
3424
- validationState,
3425
- isChecked,
3426
- isDisabled,
3427
- isFocused,
3428
- }), className), children: isChecked && (jsxRuntime.jsx("div", { className: "rounded-full bg-white transition-all", style: {
3429
- width: `${config.innerCircleSize}px`,
3430
- height: `${config.innerCircleSize}px`,
3431
- } })) })] }), label && (jsxRuntime.jsx("label", { className: cn(config.labelSize, "select-none inline-flex items-center", isDisabled
3425
+ } })), jsxRuntime.jsx("div", { className: cn("inline-flex items-center justify-center shrink-0 box-border", config.boundingBoxSize), children: jsxRuntime.jsx("div", { className: cn(radioVariants({
3426
+ size,
3427
+ validationState,
3428
+ isChecked,
3429
+ isDisabled,
3430
+ isFocused,
3431
+ }), className), children: isChecked && (jsxRuntime.jsx("div", { className: "rounded-full bg-white transition-all box-border", style: {
3432
+ width: `${config.innerCircleSize}px`,
3433
+ height: `${config.innerCircleSize}px`,
3434
+ } })) }) })] }), label && (jsxRuntime.jsx("label", { className: cn(config.labelSize, "select-none inline-flex items-center", isDisabled
3432
3435
  ? "text-surface-ink-neutral-disabled"
3433
3436
  : "text-surface-ink-neutral-normal", labelClassName), children: label }))] }), shouldShowError && (jsxRuntime.jsx(FormFooter, { helperText: errorText, validationState: "negative", size: size, isDisabled: isDisabled }))] }));
3434
3437
  });
@@ -4205,31 +4208,73 @@ const switchVariants = classVarianceAuthority.cva("relative inline-flex items-ce
4205
4208
  medium: "w-[28px] h-[16px]",
4206
4209
  large: "w-[36px] h-[20px]",
4207
4210
  },
4211
+ validationState: {
4212
+ none: "",
4213
+ error: "",
4214
+ },
4208
4215
  isChecked: {
4209
- true: "bg-action-fill-primary-default ",
4210
- false: "bg-surface-fill-neutral-subtle",
4216
+ true: "",
4217
+ false: "",
4211
4218
  },
4212
4219
  isDisabled: {
4213
4220
  true: "cursor-not-allowed opacity-60",
4214
4221
  false: "",
4215
4222
  },
4223
+ isFocused: {
4224
+ true: "",
4225
+ false: "",
4226
+ },
4216
4227
  },
4217
4228
  compoundVariants: [
4229
+ // Unchecked state - none validation
4230
+ {
4231
+ isChecked: false,
4232
+ validationState: "none",
4233
+ isDisabled: false,
4234
+ class: "bg-surface-fill-neutral-subtle hover:bg-action-fill-neutral-faded",
4235
+ },
4236
+ // Checked state - none validation
4237
+ {
4238
+ isChecked: true,
4239
+ validationState: "none",
4240
+ isDisabled: false,
4241
+ class: "bg-action-fill-primary-default hover:bg-action-fill-primary-hover",
4242
+ },
4243
+ // Checked state - error validation
4218
4244
  {
4219
4245
  isChecked: true,
4246
+ validationState: "error",
4220
4247
  isDisabled: false,
4221
- class: "hover:bg-action-fill-primary-hover ",
4248
+ class: "bg-action-fill-negative-default hover:bg-action-fill-negative-hover",
4222
4249
  },
4250
+ // Unchecked state - error validation
4223
4251
  {
4224
4252
  isChecked: false,
4253
+ validationState: "error",
4225
4254
  isDisabled: false,
4226
- class: "hover:bg-action-fill-neutral-faded",
4255
+ class: "bg-surface-fill-neutral-subtle hover:bg-action-fill-neutral-faded",
4256
+ },
4257
+ // Focused state - none validation
4258
+ {
4259
+ isFocused: true,
4260
+ validationState: "none",
4261
+ isDisabled: false,
4262
+ class: "ring-2 ring-action-outline-primary-faded",
4263
+ },
4264
+ // Focused state - error validation
4265
+ {
4266
+ isFocused: true,
4267
+ validationState: "error",
4268
+ isDisabled: false,
4269
+ class: "ring-2 ring-action-outline-negative-faded",
4227
4270
  },
4228
4271
  ],
4229
4272
  defaultVariants: {
4230
4273
  size: "medium",
4274
+ validationState: "none",
4231
4275
  isChecked: false,
4232
4276
  isDisabled: false,
4277
+ isFocused: false,
4233
4278
  },
4234
4279
  });
4235
4280
  const switchThumbVariants = classVarianceAuthority.cva("inline-block rounded-full bg-white shadow-sm transition-transform duration-200", {
@@ -4284,8 +4329,10 @@ const switchThumbVariants = classVarianceAuthority.cva("inline-block rounded-ful
4284
4329
  isChecked: false,
4285
4330
  },
4286
4331
  });
4287
- const Switch = React__namespace.forwardRef(({ label, size = "medium", isDisabled = false, containerClassName, labelClassName, trackClassName, thumbClassName, className, checked, onChange, ...props }, ref) => {
4332
+ const Switch = React__namespace.forwardRef(({ label, errorText, size = "medium", validationState = "none", isDisabled = false, showErrorText = true, containerClassName, labelClassName, trackClassName, thumbClassName, className, checked, onChange, ...props }, ref) => {
4288
4333
  const [internalChecked, setInternalChecked] = React__namespace.useState(false);
4334
+ const [showRipple, setShowRipple] = React__namespace.useState(false);
4335
+ const [isFocused, setIsFocused] = React__namespace.useState(false);
4289
4336
  const inputRef = React__namespace.useRef(null);
4290
4337
  // Use forwarded ref or internal ref
4291
4338
  React__namespace.useImperativeHandle(ref, () => inputRef.current);
@@ -4298,17 +4345,35 @@ const Switch = React__namespace.forwardRef(({ label, size = "medium", isDisabled
4298
4345
  setInternalChecked(e.target.checked);
4299
4346
  }
4300
4347
  };
4348
+ const triggerRipple = () => {
4349
+ if (!isDisabled) {
4350
+ setShowRipple(true);
4351
+ setTimeout(() => {
4352
+ setShowRipple(false);
4353
+ }, 360); // Match animation duration (0.36s)
4354
+ }
4355
+ };
4301
4356
  const handleContainerClick = () => {
4302
4357
  if (!isDisabled && inputRef.current) {
4358
+ triggerRipple();
4303
4359
  inputRef.current.click();
4304
4360
  }
4305
4361
  };
4306
4362
  const handleKeyDown = (e) => {
4307
4363
  if ((e.key === " " || e.key === "Enter") && !isDisabled) {
4308
4364
  e.preventDefault();
4365
+ triggerRipple();
4309
4366
  inputRef.current?.click();
4310
4367
  }
4311
4368
  };
4369
+ const handleFocus = () => {
4370
+ if (!isDisabled) {
4371
+ setIsFocused(true);
4372
+ }
4373
+ };
4374
+ const handleBlur = () => {
4375
+ setIsFocused(false);
4376
+ };
4312
4377
  // Size-based configurations
4313
4378
  const sizeConfig = {
4314
4379
  small: {
@@ -4325,16 +4390,24 @@ const Switch = React__namespace.forwardRef(({ label, size = "medium", isDisabled
4325
4390
  },
4326
4391
  };
4327
4392
  const config = sizeConfig[size];
4328
- return (jsxRuntime.jsx("div", { className: cn("inline-flex flex-col", containerClassName), children: jsxRuntime.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: [jsxRuntime.jsx("input", { ref: inputRef, type: "checkbox", role: "switch", className: "sr-only", checked: isChecked, onChange: handleChange, disabled: isDisabled, ...props }), jsxRuntime.jsx("div", { className: "relative inline-flex shrink-0", children: jsxRuntime.jsx("div", { className: cn(switchVariants({
4329
- size,
4330
- isChecked,
4331
- isDisabled,
4332
- }), trackClassName, className, "focus-visible:ring-2 focus-visible:ring-action-outline-primary-faded focus-visible:ring-offset-2"), children: jsxRuntime.jsx("span", { className: cn(switchThumbVariants({
4333
- size,
4334
- isChecked,
4335
- }), thumbClassName) }) }) }), label && (jsxRuntime.jsx("label", { className: cn(config.labelSize, "select-none inline-flex items-center", isDisabled
4336
- ? "text-surface-ink-neutral-disabled"
4337
- : "text-surface-ink-neutral-normal", labelClassName), children: label }))] }) }));
4393
+ // Determine if we should show the error text
4394
+ const shouldShowError = errorText && showErrorText;
4395
+ return (jsxRuntime.jsxs("div", { className: cn("inline-flex flex-col", containerClassName), children: [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: "switch", "aria-checked": isChecked, "aria-disabled": isDisabled, tabIndex: isDisabled ? -1 : 0, children: [jsxRuntime.jsx("input", { ref: inputRef, type: "checkbox", role: "switch", 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"
4396
+ ? "bg-action-outline-negative-faded"
4397
+ : "bg-action-outline-primary-faded"), style: {
4398
+ animation: "var(--animate-checkbox-ripple)",
4399
+ } })), jsxRuntime.jsx("div", { className: cn(switchVariants({
4400
+ size,
4401
+ validationState,
4402
+ isChecked,
4403
+ isDisabled,
4404
+ isFocused,
4405
+ }), trackClassName, className), children: jsxRuntime.jsx("span", { className: cn(switchThumbVariants({
4406
+ size,
4407
+ isChecked,
4408
+ }), thumbClassName) }) })] }), label && (jsxRuntime.jsx("label", { className: cn(config.labelSize, "select-none inline-flex items-center", isDisabled
4409
+ ? "text-surface-ink-neutral-disabled"
4410
+ : "text-surface-ink-neutral-normal", labelClassName), children: label }))] }), shouldShowError && (jsxRuntime.jsx(FormFooter, { helperText: errorText, validationState: "negative", size: size, isDisabled: isDisabled }))] }));
4338
4411
  });
4339
4412
  Switch.displayName = "Switch";
4340
4413