infinity-ui-elements 1.8.61 → 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/components/Radio/Radio.d.ts.map +1 -1
- package/dist/components/Switch/Switch.d.ts +14 -0
- package/dist/components/Switch/Switch.d.ts.map +1 -1
- package/dist/components/Switch/Switch.stories.d.ts +11 -0
- package/dist/components/Switch/Switch.stories.d.ts.map +1 -1
- package/dist/components/TextField/TextField.d.ts +1 -0
- package/dist/components/TextField/TextField.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.esm.js +123 -38
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +122 -37
- package/dist/index.js.map +1 -1
- package/dist/lib/icons.d.ts +2 -0
- package/dist/lib/icons.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -98,6 +98,14 @@ const iconRegistry = {
|
|
|
98
98
|
chevronUp: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
99
99
|
<path d="M12 11.2727L6.55555 17L5 15.3637L12 8L19 15.3637L17.4445 17L12 11.2727Z" fill="#081416"/>
|
|
100
100
|
</svg>
|
|
101
|
+
`,
|
|
102
|
+
chevronLeft: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
103
|
+
<path d="M11.2727 12L17 17.4445L15.3637 19L8 12L15.3637 5L17 6.55555L11.2727 12Z" fill="#081416"/>
|
|
104
|
+
</svg>
|
|
105
|
+
`,
|
|
106
|
+
chevronRight: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
107
|
+
<path d="M13.7272 12L8 6.55555L9.63635 5L17 12L9.63635 19L8 17.4445L13.7272 12Z" fill="#081416"/>
|
|
108
|
+
</svg>
|
|
101
109
|
`,
|
|
102
110
|
};
|
|
103
111
|
const Icon = ({ name, size = 24, className = "", style = {}, ...props }) => {
|
|
@@ -2864,8 +2872,6 @@ const textFieldVariants = classVarianceAuthority.cva("relative flex items-center
|
|
|
2864
2872
|
validationState: {
|
|
2865
2873
|
none: `
|
|
2866
2874
|
border-action-outline-neutral-faded
|
|
2867
|
-
hover:border-action-outline-neutral-faded-hover
|
|
2868
|
-
hover:bg-action-fill-neutral-faded-hover
|
|
2869
2875
|
focus-within:border-action-outline-primary-default
|
|
2870
2876
|
focus-within:bg-white!
|
|
2871
2877
|
focus-within:ring-2
|
|
@@ -2890,11 +2896,16 @@ const textFieldVariants = classVarianceAuthority.cva("relative flex items-center
|
|
|
2890
2896
|
cursor-not-allowed`,
|
|
2891
2897
|
false: "",
|
|
2892
2898
|
},
|
|
2899
|
+
isReadOnly: {
|
|
2900
|
+
true: "",
|
|
2901
|
+
false: "hover:border-action-outline-neutral-faded-hover hover:bg-action-fill-neutral-faded-hover",
|
|
2902
|
+
},
|
|
2893
2903
|
},
|
|
2894
2904
|
defaultVariants: {
|
|
2895
2905
|
size: "medium",
|
|
2896
2906
|
validationState: "none",
|
|
2897
2907
|
isDisabled: false,
|
|
2908
|
+
isReadOnly: false,
|
|
2898
2909
|
},
|
|
2899
2910
|
});
|
|
2900
2911
|
const TextField = React__namespace.forwardRef(({ label, helperText, errorText, successText, size = "medium", validationState = "none", isDisabled = false, isLoading = false, isRequired = false, isOptional = false, prefix, suffix, showClearButton = false, infoDescription, infoHeading, LinkComponent, linkText, linkHref, onLinkClick, onClear, containerClassName, labelClassName, inputClassName, className, value, onChange, ...props }, ref) => {
|
|
@@ -2944,13 +2955,14 @@ const TextField = React__namespace.forwardRef(({ label, helperText, errorText, s
|
|
|
2944
2955
|
size,
|
|
2945
2956
|
validationState: currentValidationState,
|
|
2946
2957
|
isDisabled,
|
|
2958
|
+
isReadOnly: props.readOnly,
|
|
2947
2959
|
}), isLoading && "text-field-loading", className), children: [prefix && (jsxRuntime.jsx("span", { className: cn("shrink-0 flex items-center", isDisabled
|
|
2948
2960
|
? "text-surface-ink-neutral-disabled"
|
|
2949
2961
|
: currentValidationState === "positive"
|
|
2950
2962
|
? "text-feedback-ink-positive-intense"
|
|
2951
2963
|
: currentValidationState === "negative"
|
|
2952
2964
|
? "text-feedback-ink-negative-subtle"
|
|
2953
|
-
: "text-surface-ink-neutral-muted"), children: prefix })), jsxRuntime.jsx("input", { ref: ref, value: inputValue, onChange: handleChange, disabled: isDisabled, required: isRequired, className: cn("
|
|
2965
|
+
: "text-surface-ink-neutral-muted"), children: prefix })), jsxRuntime.jsx("input", { ref: ref, value: inputValue, onChange: handleChange, disabled: isDisabled, required: isRequired, className: cn("w-full bg-transparent border-none outline-none text-surface-ink-neutral-normal placeholder:text-surface-ink-neutral-muted disabled:cursor-not-allowed disabled:text-surface-ink-neutral-disabled", inputClassName), ...props }), showClearButton && hasValue && !isDisabled && (jsxRuntime.jsx("button", { type: "button", onClick: handleClear, className: "shrink-0 flex items-center justify-center text-surface-ink-neutral-muted hover:text-surface-ink-neutral-normal transition-colors", tabIndex: -1, children: jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: jsxRuntime.jsx("path", { d: "M12 4L4 12M4 4L12 12", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }) }) })), suffix && (jsxRuntime.jsx("span", { className: cn("shrink-0 flex items-center", isDisabled
|
|
2954
2966
|
? "text-surface-ink-neutral-disabled"
|
|
2955
2967
|
: currentValidationState === "positive"
|
|
2956
2968
|
? "text-feedback-ink-positive-intense"
|
|
@@ -3126,7 +3138,7 @@ const Select = React__namespace.forwardRef(({ className, options = [], value: co
|
|
|
3126
3138
|
// Build the suffix: include both the optional suffix and the chevron icon
|
|
3127
3139
|
const chevronIcon = (jsxRuntime.jsx(Icon, { name: isOpen ? "chevronUp" : "chevronDown", size: 16, className: "shrink-0 transition-colors" }));
|
|
3128
3140
|
const displaySuffix = suffix ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [suffix, chevronIcon] })) : (chevronIcon);
|
|
3129
|
-
return (jsxRuntime.jsxs("div", { ref: containerRef, className: "relative", children: [jsxRuntime.jsx(TextField, { ref: inputRef, label: label, helperText: helperText, errorText: errorText, successText: successText, validationState: validationState, isDisabled: isDisabled, isRequired: isRequired, isOptional: isOptional, isLoading: isLoading, size: size, prefix: displayPrefix, suffix: displaySuffix, showClearButton: showClearButton && hasValue && !isLoading, onClear: handleClear, placeholder: placeholder, value: displayValue, readOnly: true, containerClassName: containerClassName, labelClassName: labelClassName, className: cn("cursor-pointer", triggerClassName, className), inputClassName: "cursor-pointer", infoHeading: infoHeading, infoDescription: infoDescription, LinkComponent: LinkComponent, linkText: linkText, linkHref: linkHref, onLinkClick: onLinkClick, onClick: toggleOpen, onKeyDown: handleKeyDown, role: "combobox", "aria-haspopup": "listbox", "aria-expanded": isOpen, ...props }), isOpen && !isDisabled && !isLoading && (jsxRuntime.jsx("div", { ref: dropdownContainerRef, className: cn("absolute z-50 left-0 right-0", dropdownPlacement === "bottom"
|
|
3141
|
+
return (jsxRuntime.jsxs("div", { ref: containerRef, className: "relative w-full", children: [jsxRuntime.jsx(TextField, { ref: inputRef, label: label, helperText: helperText, errorText: errorText, successText: successText, validationState: validationState, isDisabled: isDisabled, isRequired: isRequired, isOptional: isOptional, isLoading: isLoading, size: size, prefix: displayPrefix, suffix: displaySuffix, showClearButton: showClearButton && hasValue && !isLoading, onClear: handleClear, placeholder: placeholder, value: displayValue, readOnly: true, containerClassName: cn("w-full", containerClassName), labelClassName: labelClassName, className: cn("cursor-pointer", triggerClassName, className), inputClassName: "cursor-pointer", infoHeading: infoHeading, infoDescription: infoDescription, LinkComponent: LinkComponent, linkText: linkText, linkHref: linkHref, onLinkClick: onLinkClick, onClick: toggleOpen, onKeyDown: handleKeyDown, role: "combobox", "aria-haspopup": "listbox", "aria-expanded": isOpen, ...props }), isOpen && !isDisabled && !isLoading && (jsxRuntime.jsx("div", { ref: dropdownContainerRef, className: cn("absolute z-50 left-0 right-0", dropdownPlacement === "bottom"
|
|
3130
3142
|
? "top-full mt-1"
|
|
3131
3143
|
: "bottom-full mb-1"), children: jsxRuntime.jsx(DropdownMenu, { items: menuItems, sectionHeading: sectionHeading, isEmpty: options.length === 0, emptyTitle: emptyTitle, emptyDescription: emptyDescription, emptyIcon: emptyIcon, disableFooter: true, onClose: () => handleOpenChange(false), className: menuClassName, width: widthStyle }) }))] }));
|
|
3132
3144
|
});
|
|
@@ -3248,21 +3260,21 @@ const Pagination = React__namespace.forwardRef(({ className, currentPage: contro
|
|
|
3248
3260
|
return [];
|
|
3249
3261
|
};
|
|
3250
3262
|
const pageNumbers = getPageNumbers();
|
|
3251
|
-
return (jsxRuntime.jsxs("div", { ref: ref, className: cn(paginationVariants({ size }), className), ...props, children: [showRowsPerPage && (jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [jsxRuntime.jsx("span", { className: "text-surface-ink-neutral-muted whitespace-nowrap", children: rowsPerPageLabel }), jsxRuntime.jsx("div", { className: "w-[80px]", children: jsxRuntime.jsx(Select, { value: rowsPerPage.toString(), options: rowsPerPageSelectOptions, onChange: handleRowsPerPageChange, size: selectSize, isDisabled: isDisabled, menuWidth: "auto" }) })] })), jsxRuntime.jsxs("div", { className: "flex items-center gap-3 ml-auto", children: [showPrevNext && (jsxRuntime.jsx(Button, { variant: "tertiary", color: "neutral", size: buttonSize, onClick: handlePrevPage, isDisabled: isPrevDisabled, leadingIcon: jsxRuntime.jsx(
|
|
3263
|
+
return (jsxRuntime.jsxs("div", { ref: ref, className: cn(paginationVariants({ size }), className), ...props, children: [showRowsPerPage && (jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [jsxRuntime.jsx("span", { className: "text-surface-ink-neutral-muted whitespace-nowrap", children: rowsPerPageLabel }), jsxRuntime.jsx("div", { className: "w-[80px]", children: jsxRuntime.jsx(Select, { value: rowsPerPage.toString(), options: rowsPerPageSelectOptions, onChange: handleRowsPerPageChange, size: selectSize, isDisabled: isDisabled, menuWidth: "auto" }) })] })), jsxRuntime.jsxs("div", { className: "flex items-center gap-3 ml-auto", children: [showPrevNext && (jsxRuntime.jsx(Button, { variant: "tertiary", color: "neutral", size: buttonSize, onClick: handlePrevPage, isDisabled: isPrevDisabled, leadingIcon: jsxRuntime.jsx(Icon, { name: "chevronLeft", size: 16 }), "aria-label": "Previous page", children: prevLabel })), showPageJumper ? (
|
|
3252
3264
|
// Show page dropdown selector
|
|
3253
3265
|
jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [jsxRuntime.jsx("div", { className: "w-[80px]", children: jsxRuntime.jsx(Select, { value: currentPage.toString(), options: pageOptions, onChange: (value) => handlePageChange(typeof value === "string" ? parseInt(value) : value), size: selectSize, isDisabled: isDisabled, menuWidth: "auto" }) }), jsxRuntime.jsxs("span", { className: "text-surface-ink-neutral-muted whitespace-nowrap", children: [ofLabel, " ", totalPages] })] })) : (
|
|
3254
3266
|
// Show numbered page buttons
|
|
3255
3267
|
showPageNumber &&
|
|
3256
|
-
pageNumbers.length > 0 && (jsxRuntime.jsx(ButtonGroup, { variant: "separated", size: buttonSize, isDisabled: isDisabled, value: currentPage, onChange: (value) => handlePageChange(value), children: pageNumbers.map((pageNum) => (jsxRuntime.jsx(Button, { value: pageNum, variant: "tertiary", color: "primary", "aria-label": `Page ${pageNum}`, "aria-current": pageNum === currentPage ? "page" : undefined, children: pageNum }, pageNum))) }))), showPrevNext && (jsxRuntime.jsx(Button, { variant: "tertiary", color: "neutral", size: buttonSize, onClick: handleNextPage, isDisabled: isNextDisabled, trailingIcon: jsxRuntime.jsx(
|
|
3268
|
+
pageNumbers.length > 0 && (jsxRuntime.jsx(ButtonGroup, { variant: "separated", size: buttonSize, isDisabled: isDisabled, value: currentPage, onChange: (value) => handlePageChange(value), children: pageNumbers.map((pageNum) => (jsxRuntime.jsx(Button, { value: pageNum, variant: "tertiary", color: "primary", "aria-label": `Page ${pageNum}`, "aria-current": pageNum === currentPage ? "page" : undefined, children: pageNum }, pageNum))) }))), showPrevNext && (jsxRuntime.jsx(Button, { variant: "tertiary", color: "neutral", size: buttonSize, onClick: handleNextPage, isDisabled: isNextDisabled, trailingIcon: jsxRuntime.jsx(Icon, { name: "chevronRight", size: 16 }), "aria-label": "Next page", children: nextLabel }))] })] }));
|
|
3257
3269
|
});
|
|
3258
3270
|
Pagination.displayName = "Pagination";
|
|
3259
3271
|
|
|
3260
3272
|
const radioVariants = classVarianceAuthority.cva("relative inline-flex items-center justify-center shrink-0 border transition-all cursor-pointer rounded-full", {
|
|
3261
3273
|
variants: {
|
|
3262
3274
|
size: {
|
|
3263
|
-
small: "w-[
|
|
3264
|
-
medium: "w-[
|
|
3265
|
-
large: "w-[
|
|
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]",
|
|
3266
3278
|
},
|
|
3267
3279
|
validationState: {
|
|
3268
3280
|
none: "",
|
|
@@ -3387,17 +3399,20 @@ const Radio = React__namespace.forwardRef(({ label, errorText, size = "medium",
|
|
|
3387
3399
|
small: {
|
|
3388
3400
|
gap: "gap-2",
|
|
3389
3401
|
labelSize: "text-body-small-regular",
|
|
3390
|
-
innerCircleSize:
|
|
3402
|
+
innerCircleSize: 4,
|
|
3403
|
+
boundingBoxSize: "w-[14px] h-[14px] p-1",
|
|
3391
3404
|
},
|
|
3392
3405
|
medium: {
|
|
3393
3406
|
gap: "gap-2.5",
|
|
3394
3407
|
labelSize: "text-body-medium-regular",
|
|
3395
|
-
innerCircleSize:
|
|
3408
|
+
innerCircleSize: 5,
|
|
3409
|
+
boundingBoxSize: "w-[16px] h-[16px] p-1",
|
|
3396
3410
|
},
|
|
3397
3411
|
large: {
|
|
3398
3412
|
gap: "gap-3",
|
|
3399
3413
|
labelSize: "text-body-large-regular",
|
|
3400
|
-
innerCircleSize:
|
|
3414
|
+
innerCircleSize: 7,
|
|
3415
|
+
boundingBoxSize: "w-[20px] h-[20px] p-1",
|
|
3401
3416
|
},
|
|
3402
3417
|
};
|
|
3403
3418
|
const config = sizeConfig[size];
|
|
@@ -3407,16 +3422,16 @@ const Radio = React__namespace.forwardRef(({ label, errorText, size = "medium",
|
|
|
3407
3422
|
? "bg-action-outline-negative-faded"
|
|
3408
3423
|
: "bg-action-outline-primary-faded"), style: {
|
|
3409
3424
|
animation: "var(--animate-checkbox-ripple)",
|
|
3410
|
-
} })), jsxRuntime.jsx("div", { className: cn(radioVariants({
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
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
|
|
3420
3435
|
? "text-surface-ink-neutral-disabled"
|
|
3421
3436
|
: "text-surface-ink-neutral-normal", labelClassName), children: label }))] }), shouldShowError && (jsxRuntime.jsx(FormFooter, { helperText: errorText, validationState: "negative", size: size, isDisabled: isDisabled }))] }));
|
|
3422
3437
|
});
|
|
@@ -4193,31 +4208,73 @@ const switchVariants = classVarianceAuthority.cva("relative inline-flex items-ce
|
|
|
4193
4208
|
medium: "w-[28px] h-[16px]",
|
|
4194
4209
|
large: "w-[36px] h-[20px]",
|
|
4195
4210
|
},
|
|
4211
|
+
validationState: {
|
|
4212
|
+
none: "",
|
|
4213
|
+
error: "",
|
|
4214
|
+
},
|
|
4196
4215
|
isChecked: {
|
|
4197
|
-
true: "
|
|
4198
|
-
false: "
|
|
4216
|
+
true: "",
|
|
4217
|
+
false: "",
|
|
4199
4218
|
},
|
|
4200
4219
|
isDisabled: {
|
|
4201
4220
|
true: "cursor-not-allowed opacity-60",
|
|
4202
4221
|
false: "",
|
|
4203
4222
|
},
|
|
4223
|
+
isFocused: {
|
|
4224
|
+
true: "",
|
|
4225
|
+
false: "",
|
|
4226
|
+
},
|
|
4204
4227
|
},
|
|
4205
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
|
|
4206
4237
|
{
|
|
4207
4238
|
isChecked: true,
|
|
4239
|
+
validationState: "none",
|
|
4208
4240
|
isDisabled: false,
|
|
4209
|
-
class: "hover:bg-action-fill-primary-hover
|
|
4241
|
+
class: "bg-action-fill-primary-default hover:bg-action-fill-primary-hover",
|
|
4210
4242
|
},
|
|
4243
|
+
// Checked state - error validation
|
|
4244
|
+
{
|
|
4245
|
+
isChecked: true,
|
|
4246
|
+
validationState: "error",
|
|
4247
|
+
isDisabled: false,
|
|
4248
|
+
class: "bg-action-fill-negative-default hover:bg-action-fill-negative-hover",
|
|
4249
|
+
},
|
|
4250
|
+
// Unchecked state - error validation
|
|
4211
4251
|
{
|
|
4212
4252
|
isChecked: false,
|
|
4253
|
+
validationState: "error",
|
|
4213
4254
|
isDisabled: false,
|
|
4214
|
-
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",
|
|
4215
4270
|
},
|
|
4216
4271
|
],
|
|
4217
4272
|
defaultVariants: {
|
|
4218
4273
|
size: "medium",
|
|
4274
|
+
validationState: "none",
|
|
4219
4275
|
isChecked: false,
|
|
4220
4276
|
isDisabled: false,
|
|
4277
|
+
isFocused: false,
|
|
4221
4278
|
},
|
|
4222
4279
|
});
|
|
4223
4280
|
const switchThumbVariants = classVarianceAuthority.cva("inline-block rounded-full bg-white shadow-sm transition-transform duration-200", {
|
|
@@ -4272,8 +4329,10 @@ const switchThumbVariants = classVarianceAuthority.cva("inline-block rounded-ful
|
|
|
4272
4329
|
isChecked: false,
|
|
4273
4330
|
},
|
|
4274
4331
|
});
|
|
4275
|
-
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) => {
|
|
4276
4333
|
const [internalChecked, setInternalChecked] = React__namespace.useState(false);
|
|
4334
|
+
const [showRipple, setShowRipple] = React__namespace.useState(false);
|
|
4335
|
+
const [isFocused, setIsFocused] = React__namespace.useState(false);
|
|
4277
4336
|
const inputRef = React__namespace.useRef(null);
|
|
4278
4337
|
// Use forwarded ref or internal ref
|
|
4279
4338
|
React__namespace.useImperativeHandle(ref, () => inputRef.current);
|
|
@@ -4286,17 +4345,35 @@ const Switch = React__namespace.forwardRef(({ label, size = "medium", isDisabled
|
|
|
4286
4345
|
setInternalChecked(e.target.checked);
|
|
4287
4346
|
}
|
|
4288
4347
|
};
|
|
4348
|
+
const triggerRipple = () => {
|
|
4349
|
+
if (!isDisabled) {
|
|
4350
|
+
setShowRipple(true);
|
|
4351
|
+
setTimeout(() => {
|
|
4352
|
+
setShowRipple(false);
|
|
4353
|
+
}, 360); // Match animation duration (0.36s)
|
|
4354
|
+
}
|
|
4355
|
+
};
|
|
4289
4356
|
const handleContainerClick = () => {
|
|
4290
4357
|
if (!isDisabled && inputRef.current) {
|
|
4358
|
+
triggerRipple();
|
|
4291
4359
|
inputRef.current.click();
|
|
4292
4360
|
}
|
|
4293
4361
|
};
|
|
4294
4362
|
const handleKeyDown = (e) => {
|
|
4295
4363
|
if ((e.key === " " || e.key === "Enter") && !isDisabled) {
|
|
4296
4364
|
e.preventDefault();
|
|
4365
|
+
triggerRipple();
|
|
4297
4366
|
inputRef.current?.click();
|
|
4298
4367
|
}
|
|
4299
4368
|
};
|
|
4369
|
+
const handleFocus = () => {
|
|
4370
|
+
if (!isDisabled) {
|
|
4371
|
+
setIsFocused(true);
|
|
4372
|
+
}
|
|
4373
|
+
};
|
|
4374
|
+
const handleBlur = () => {
|
|
4375
|
+
setIsFocused(false);
|
|
4376
|
+
};
|
|
4300
4377
|
// Size-based configurations
|
|
4301
4378
|
const sizeConfig = {
|
|
4302
4379
|
small: {
|
|
@@ -4313,16 +4390,24 @@ const Switch = React__namespace.forwardRef(({ label, size = "medium", isDisabled
|
|
|
4313
4390
|
},
|
|
4314
4391
|
};
|
|
4315
4392
|
const config = sizeConfig[size];
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
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 }))] }));
|
|
4326
4411
|
});
|
|
4327
4412
|
Switch.displayName = "Switch";
|
|
4328
4413
|
|