infinity-ui-elements 1.8.58 → 1.8.59

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
@@ -89,6 +89,14 @@ const iconRegistry = {
89
89
  file: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
90
90
  <path d="M19.1111 21H4.88889C4.39797 21 4 20.5971 4 20.1V3.9C4 3.40295 4.39797 3 4.88889 3H19.1111C19.602 3 20 3.40295 20 3.9V20.1C20 20.5971 19.602 21 19.1111 21ZM18.2222 19.2V4.8H5.77778V19.2H18.2222ZM8.44444 9.3H15.5556V11.1H8.44444V9.3ZM8.44444 12.9H15.5556V14.7H8.44444V12.9Z" fill="#081416"/>
91
91
  </svg>
92
+ `,
93
+ chevronDown: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
94
+ <path d="M12 13.7272L17.4445 8L19 9.63635L12 17L5 9.63635L6.55555 8L12 13.7272Z" fill="#081416"/>
95
+ </svg>
96
+ `,
97
+ chevronUp: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
98
+ <path d="M12 11.2727L6.55555 17L5 15.3637L12 8L19 15.3637L17.4445 17L12 11.2727Z" fill="#081416"/>
99
+ </svg>
92
100
  `,
93
101
  };
94
102
  const Icon = ({ name, size = 24, className = "", style = {}, ...props }) => {
@@ -2851,7 +2859,7 @@ const Modal = React__namespace.forwardRef(({ isOpen, onClose, title, description
2851
2859
  });
2852
2860
  Modal.displayName = "Modal";
2853
2861
 
2854
- const selectVariants = classVarianceAuthority.cva("relative flex items-center gap-2 border rounded-large transition-all font-functional font-size-100 leading-100", {
2862
+ const textFieldVariants = classVarianceAuthority.cva("relative flex items-center gap-3 border rounded-large transition-all font-functional font-size-100 leading-100", {
2855
2863
  variants: {
2856
2864
  size: {
2857
2865
  small: "h-[28px] px-3 text-xs gap-2",
@@ -2861,10 +2869,11 @@ const selectVariants = classVarianceAuthority.cva("relative flex items-center ga
2861
2869
  validationState: {
2862
2870
  none: `
2863
2871
  border-action-outline-neutral-faded
2864
- hover:border-action-outline-primary-hover
2865
- focus-within:border-action-outline-primary-hover
2872
+ hover:border-action-outline-neutral-faded-hover
2873
+ hover:bg-action-fill-neutral-faded-hover
2874
+ focus-within:border-action-outline-primary-default
2866
2875
  focus-within:ring-2
2867
- ring-action-outline-primary-faded-hover`,
2876
+ ring-surface-outline-primary-muted`,
2868
2877
  positive: `
2869
2878
  border-action-outline-positive-default
2870
2879
  focus-within:border-action-outline-positive-hover
@@ -2877,11 +2886,13 @@ const selectVariants = classVarianceAuthority.cva("relative flex items-center ga
2877
2886
  },
2878
2887
  isDisabled: {
2879
2888
  true: `
2880
- border-[var(--border-width-thinner)]
2881
- hover:border-action-outline-neutral-disabled
2889
+ border
2882
2890
  border-action-outline-neutral-disabled
2883
- bg-surface-fill-neutral-intense cursor-not-allowed opacity-60`,
2884
- false: "bg-surface-fill-neutral-intense",
2891
+ hover:border-action-outline-neutral-disabled
2892
+ bg-surface-fill-neutral-intense
2893
+ hover:bg-surface-fill-neutral-intense
2894
+ cursor-not-allowed`,
2895
+ false: "",
2885
2896
  },
2886
2897
  },
2887
2898
  defaultVariants: {
@@ -2890,23 +2901,83 @@ const selectVariants = classVarianceAuthority.cva("relative flex items-center ga
2890
2901
  isDisabled: false,
2891
2902
  },
2892
2903
  });
2904
+ 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) => {
2905
+ const [internalValue, setInternalValue] = React__namespace.useState("");
2906
+ const inputValue = value !== undefined ? value : internalValue;
2907
+ const hasValue = inputValue && String(inputValue).length > 0;
2908
+ const handleChange = (e) => {
2909
+ if (onChange) {
2910
+ onChange(e);
2911
+ }
2912
+ else {
2913
+ setInternalValue(e.target.value);
2914
+ }
2915
+ };
2916
+ const handleClear = () => {
2917
+ if (onClear) {
2918
+ onClear();
2919
+ }
2920
+ else {
2921
+ setInternalValue("");
2922
+ }
2923
+ // Focus the input after clearing
2924
+ const input = document.getElementById(props.id || "");
2925
+ if (input) {
2926
+ input.focus();
2927
+ }
2928
+ };
2929
+ // Determine which helper text to show
2930
+ const displayHelperText = errorText || successText || helperText;
2931
+ const currentValidationState = errorText
2932
+ ? "negative"
2933
+ : successText
2934
+ ? "positive"
2935
+ : validationState;
2936
+ const sizeConfig = {
2937
+ small: {
2938
+ gap: "gap-2",
2939
+ },
2940
+ medium: {
2941
+ gap: "gap-2",
2942
+ },
2943
+ large: {
2944
+ gap: "gap-3",
2945
+ },
2946
+ };
2947
+ return (jsxRuntime.jsxs("div", { className: cn("w-full flex flex-col", sizeConfig[size].gap, containerClassName), 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: props.id, className: "mb-2", labelClassName: labelClassName })), jsxRuntime.jsxs("div", { className: cn(textFieldVariants({
2948
+ size,
2949
+ validationState: currentValidationState,
2950
+ isDisabled,
2951
+ }), isLoading && "text-field-loading", className), children: [prefix && (jsxRuntime.jsx("span", { className: cn("shrink-0 flex items-center", isDisabled
2952
+ ? "text-surface-ink-neutral-disabled"
2953
+ : currentValidationState === "positive"
2954
+ ? "text-feedback-ink-positive-intense"
2955
+ : currentValidationState === "negative"
2956
+ ? "text-feedback-ink-negative-subtle"
2957
+ : "text-surface-ink-neutral-muted"), children: prefix })), jsxRuntime.jsx("input", { ref: ref, value: inputValue, onChange: handleChange, disabled: isDisabled, required: isRequired, className: cn("flex-1 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
2958
+ ? "text-surface-ink-neutral-disabled"
2959
+ : currentValidationState === "positive"
2960
+ ? "text-feedback-ink-positive-intense"
2961
+ : currentValidationState === "negative"
2962
+ ? "text-feedback-ink-negative-subtle"
2963
+ : "text-surface-ink-neutral-muted"), children: suffix }))] }), jsxRuntime.jsx(FormFooter, { helperText: displayHelperText, validationState: currentValidationState === "none"
2964
+ ? "default"
2965
+ : currentValidationState, size: size, isDisabled: isDisabled, className: "mt-1" })] }));
2966
+ });
2967
+ TextField.displayName = "TextField";
2968
+
2893
2969
  const Select = React__namespace.forwardRef(({ className, options = [], value: controlledValue, defaultValue, onChange, placeholder = "Select an option", label, helperText, errorText, successText, validationState = "none", isDisabled = false, isRequired = false, isOptional = false, isLoading = false, size = "medium", prefix, suffix, showClearButton = false, onClear, showLeadingIcon = false, containerClassName, labelClassName, triggerClassName, menuClassName, menuWidth = "full", sectionHeading, emptyTitle = "No options available", emptyDescription = "There are no options to select from.", emptyIcon, infoHeading, infoDescription, LinkComponent, linkText, linkHref, onLinkClick, ...props }, ref) => {
2894
2970
  const [uncontrolledValue, setUncontrolledValue] = React__namespace.useState(defaultValue);
2895
2971
  const [isOpen, setIsOpen] = React__namespace.useState(false);
2896
2972
  const [dropdownPlacement, setDropdownPlacement] = React__namespace.useState("bottom");
2897
- const selectRef = React__namespace.useRef(null);
2973
+ const containerRef = React__namespace.useRef(null);
2898
2974
  const dropdownContainerRef = React__namespace.useRef(null);
2975
+ const inputRef = React__namespace.useRef(null);
2976
+ React__namespace.useImperativeHandle(ref, () => inputRef.current);
2899
2977
  const value = controlledValue !== undefined ? controlledValue : uncontrolledValue;
2900
2978
  // Find the selected option
2901
2979
  const selectedOption = options.find((opt) => opt.value === value);
2902
2980
  const hasValue = value !== undefined && value !== "";
2903
- // Determine which helper text to show
2904
- const displayHelperText = errorText || successText || helperText;
2905
- const currentValidationState = errorText
2906
- ? "negative"
2907
- : successText
2908
- ? "positive"
2909
- : validationState;
2910
2981
  const handleOpenChange = (newOpen) => {
2911
2982
  if (!isDisabled && !isLoading) {
2912
2983
  setIsOpen(newOpen);
@@ -2921,9 +2992,9 @@ const Select = React__namespace.forwardRef(({ className, options = [], value: co
2921
2992
  }
2922
2993
  onChange?.(option.value, option);
2923
2994
  setIsOpen(false);
2995
+ inputRef.current?.focus();
2924
2996
  };
2925
- const handleClear = (e) => {
2926
- e.stopPropagation();
2997
+ const handleClear = () => {
2927
2998
  if (onClear) {
2928
2999
  onClear();
2929
3000
  }
@@ -2937,7 +3008,7 @@ const Select = React__namespace.forwardRef(({ className, options = [], value: co
2937
3008
  const updateDropdownPlacement = React__namespace.useCallback(() => {
2938
3009
  if (typeof window === "undefined")
2939
3010
  return;
2940
- const trigger = selectRef.current;
3011
+ const trigger = containerRef.current;
2941
3012
  if (!trigger)
2942
3013
  return;
2943
3014
  const triggerRect = trigger.getBoundingClientRect();
@@ -2986,8 +3057,10 @@ const Select = React__namespace.forwardRef(({ className, options = [], value: co
2986
3057
  // Close dropdown when clicking outside
2987
3058
  React__namespace.useEffect(() => {
2988
3059
  const handleClickOutside = (event) => {
2989
- if (selectRef.current &&
2990
- !selectRef.current.contains(event.target)) {
3060
+ if (containerRef.current &&
3061
+ !containerRef.current.contains(event.target) &&
3062
+ dropdownContainerRef.current &&
3063
+ !dropdownContainerRef.current.contains(event.target)) {
2991
3064
  handleOpenChange(false);
2992
3065
  }
2993
3066
  };
@@ -3013,35 +3086,27 @@ const Select = React__namespace.forwardRef(({ className, options = [], value: co
3013
3086
  }
3014
3087
  }, [isOpen]);
3015
3088
  // Handle keyboard navigation
3016
- React__namespace.useEffect(() => {
3017
- const handleKeyDown = (event) => {
3018
- if (isDisabled || isLoading)
3019
- return;
3020
- if (!isOpen && (event.key === "Enter" || event.key === " ")) {
3089
+ const handleKeyDown = (event) => {
3090
+ if (isDisabled || isLoading)
3091
+ return;
3092
+ if (!isOpen && (event.key === "Enter" || event.key === " ")) {
3093
+ event.preventDefault();
3094
+ setIsOpen(true);
3095
+ return;
3096
+ }
3097
+ if (isOpen) {
3098
+ if (event.key === "ArrowDown" || event.key === "ArrowUp") {
3021
3099
  event.preventDefault();
3022
- setIsOpen(true);
3023
- return;
3024
- }
3025
- if (isOpen) {
3026
- if (event.key === "ArrowDown" || event.key === "ArrowUp") {
3027
- event.preventDefault();
3028
- const currentIndex = options.findIndex((opt) => opt.value === value);
3029
- const nextIndex = event.key === "ArrowDown"
3030
- ? Math.min(currentIndex + 1, options.length - 1)
3031
- : Math.max(currentIndex - 1, 0);
3032
- if (options[nextIndex] && !options[nextIndex].isDisabled) {
3033
- handleSelect(options[nextIndex]);
3034
- }
3100
+ const currentIndex = options.findIndex((opt) => opt.value === value);
3101
+ const nextIndex = event.key === "ArrowDown"
3102
+ ? Math.min(currentIndex + 1, options.length - 1)
3103
+ : Math.max(currentIndex - 1, 0);
3104
+ if (options[nextIndex] && !options[nextIndex].isDisabled) {
3105
+ handleSelect(options[nextIndex]);
3035
3106
  }
3036
3107
  }
3037
- };
3038
- if (selectRef.current) {
3039
- selectRef.current.addEventListener("keydown", handleKeyDown);
3040
- return () => {
3041
- selectRef.current?.removeEventListener("keydown", handleKeyDown);
3042
- };
3043
3108
  }
3044
- }, [isOpen, value, options, isDisabled, isLoading]);
3109
+ };
3045
3110
  // Transform options to dropdown menu items
3046
3111
  const menuItems = options.map((option) => ({
3047
3112
  value: option.value,
@@ -3054,50 +3119,20 @@ const Select = React__namespace.forwardRef(({ className, options = [], value: co
3054
3119
  onClick: () => handleSelect(option),
3055
3120
  }));
3056
3121
  const widthStyle = menuWidth === "full" ? "100%" : menuWidth === "auto" ? "auto" : menuWidth;
3057
- const sizeConfig = {
3058
- small: {
3059
- gap: "gap-2",
3060
- },
3061
- medium: {
3062
- gap: "gap-2",
3063
- },
3064
- large: {
3065
- gap: "gap-3",
3066
- },
3067
- };
3068
- return (jsxRuntime.jsxs("div", { className: cn("w-full flex flex-col", sizeConfig[size].gap, containerClassName), 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: props.id, className: "mb-2", labelClassName: labelClassName })), jsxRuntime.jsxs("div", { ref: selectRef, className: cn(selectVariants({
3069
- size,
3070
- validationState: currentValidationState,
3071
- isDisabled,
3072
- }), "relative w-full cursor-pointer", className), onClick: !isDisabled && !isLoading ? toggleOpen : undefined, role: "combobox", "aria-haspopup": "listbox", "aria-expanded": isOpen, "aria-disabled": isDisabled, ...props, children: [prefix ? (jsxRuntime.jsx("span", { className: cn("shrink-0 flex items-center", isDisabled
3073
- ? "text-surface-ink-neutral-disabled"
3074
- : currentValidationState === "positive"
3075
- ? "text-feedback-ink-positive-intense"
3076
- : currentValidationState === "negative"
3077
- ? "text-feedback-ink-negative-subtle"
3078
- : "text-surface-ink-neutral-muted"), children: prefix })) : showLeadingIcon && selectedOption?.leadingIcon ? (jsxRuntime.jsx("span", { className: cn("shrink-0 flex items-center", isDisabled
3079
- ? "text-surface-ink-neutral-disabled"
3080
- : currentValidationState === "positive"
3081
- ? "text-feedback-ink-positive-intense"
3082
- : currentValidationState === "negative"
3083
- ? "text-feedback-ink-negative-subtle"
3084
- : "text-surface-ink-neutral-muted"), children: selectedOption.leadingIcon })) : null, jsxRuntime.jsx("span", { className: cn("flex-1 text-left truncate", !selectedOption && "text-surface-ink-neutral-muted", isDisabled && "text-surface-ink-neutral-disabled"), children: isLoading ? "Loading..." : selectedOption?.label || placeholder }), showClearButton && hasValue && !isDisabled && !isLoading && (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 && !showClearButton && (jsxRuntime.jsx("span", { className: cn("shrink-0 flex items-center", isDisabled
3085
- ? "text-surface-ink-neutral-disabled"
3086
- : currentValidationState === "positive"
3087
- ? "text-feedback-ink-positive-intense"
3088
- : currentValidationState === "negative"
3089
- ? "text-feedback-ink-negative-subtle"
3090
- : "text-surface-ink-neutral-muted"), children: suffix })), jsxRuntime.jsx(lucideReact.ChevronDown, { className: cn("shrink-0 w-4 h-4 transition-transform", isDisabled
3091
- ? "text-surface-ink-neutral-disabled"
3092
- : currentValidationState === "positive"
3093
- ? "text-feedback-ink-positive-intense"
3094
- : currentValidationState === "negative"
3095
- ? "text-feedback-ink-negative-subtle"
3096
- : "text-surface-ink-neutral-muted", isOpen && "transform rotate-180") }), isOpen && !isDisabled && !isLoading && (jsxRuntime.jsx("div", { ref: dropdownContainerRef, className: cn("absolute z-50 left-0 right-0", dropdownPlacement === "bottom"
3097
- ? "top-full mt-1"
3098
- : "bottom-full mb-1"), children: jsxRuntime.jsx(DropdownMenu, { ref: ref, items: menuItems, sectionHeading: sectionHeading, isEmpty: options.length === 0, emptyTitle: emptyTitle, emptyDescription: emptyDescription, emptyIcon: emptyIcon, disableFooter: true, onClose: () => handleOpenChange(false), className: menuClassName, width: widthStyle }) }))] }), jsxRuntime.jsx(FormFooter, { helperText: displayHelperText, validationState: currentValidationState === "none"
3099
- ? "default"
3100
- : currentValidationState, size: size, isDisabled: isDisabled, className: "mt-1" })] }));
3122
+ // Get the display value for the TextField
3123
+ const displayValue = isLoading ? "Loading..." : selectedOption?.label || "";
3124
+ // Build the prefix: either provided prefix or selected option's leadingIcon
3125
+ const displayPrefix = prefix
3126
+ ? prefix
3127
+ : showLeadingIcon && selectedOption?.leadingIcon
3128
+ ? selectedOption.leadingIcon
3129
+ : undefined;
3130
+ // Build the suffix: include both the optional suffix and the chevron icon
3131
+ const chevronIcon = (jsxRuntime.jsx(Icon, { name: isOpen ? "chevronUp" : "chevronDown", size: 16, className: "shrink-0 transition-colors" }));
3132
+ const displaySuffix = suffix ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [suffix, chevronIcon] })) : (chevronIcon);
3133
+ 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"
3134
+ ? "top-full mt-1"
3135
+ : "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 }) }))] }));
3101
3136
  });
3102
3137
  Select.displayName = "Select";
3103
3138
 
@@ -3525,110 +3560,6 @@ const RadioGroup = React__namespace.forwardRef(({ value: controlledValue, defaul
3525
3560
  });
3526
3561
  RadioGroup.displayName = "RadioGroup";
3527
3562
 
3528
- const textFieldVariants = classVarianceAuthority.cva("relative flex items-center gap-2 border rounded-large transition-all font-functional font-size-100 leading-100", {
3529
- variants: {
3530
- size: {
3531
- small: "h-[28px] px-3 text-xs gap-2",
3532
- medium: "h-[36px] px-4 text-sm gap-2",
3533
- large: "h-[44px] px-5 text-base gap-3",
3534
- },
3535
- validationState: {
3536
- none: `
3537
- border-action-outline-neutral-faded
3538
- hover:border-action-outline-primary-hover
3539
- focus-within:border-action-outline-primary-hover
3540
- focus-within:ring-2
3541
- ring-action-outline-primary-faded-hover`,
3542
- positive: `
3543
- border-action-outline-positive-default
3544
- focus-within:border-action-outline-positive-hover
3545
- focus-within:ring-2
3546
- ring-action-outline-positive-faded-hover`,
3547
- negative: `border-action-outline-negative-default
3548
- focus-within:border-action-outline-negative-hover
3549
- focus-within:ring-2
3550
- ring-action-outline-negative-faded-hover`,
3551
- },
3552
- isDisabled: {
3553
- true: `
3554
- border-[var(--border-width-thinner)]
3555
- hover:border-action-outline-neutral-disabled
3556
- border-action-outline-neutral-disabled
3557
- bg-surface-fill-neutral-intense cursor-not-allowed opacity-60`,
3558
- false: "bg-surface-fill-neutral-intense",
3559
- },
3560
- },
3561
- defaultVariants: {
3562
- size: "medium",
3563
- validationState: "none",
3564
- isDisabled: false,
3565
- },
3566
- });
3567
- 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) => {
3568
- const [internalValue, setInternalValue] = React__namespace.useState("");
3569
- const inputValue = value !== undefined ? value : internalValue;
3570
- const hasValue = inputValue && String(inputValue).length > 0;
3571
- const handleChange = (e) => {
3572
- if (onChange) {
3573
- onChange(e);
3574
- }
3575
- else {
3576
- setInternalValue(e.target.value);
3577
- }
3578
- };
3579
- const handleClear = () => {
3580
- if (onClear) {
3581
- onClear();
3582
- }
3583
- else {
3584
- setInternalValue("");
3585
- }
3586
- // Focus the input after clearing
3587
- const input = document.getElementById(props.id || "");
3588
- if (input) {
3589
- input.focus();
3590
- }
3591
- };
3592
- // Determine which helper text to show
3593
- const displayHelperText = errorText || successText || helperText;
3594
- const currentValidationState = errorText
3595
- ? "negative"
3596
- : successText
3597
- ? "positive"
3598
- : validationState;
3599
- const sizeConfig = {
3600
- small: {
3601
- gap: "gap-2",
3602
- },
3603
- medium: {
3604
- gap: "gap-2",
3605
- },
3606
- large: {
3607
- gap: "gap-3",
3608
- },
3609
- };
3610
- return (jsxRuntime.jsxs("div", { className: cn("w-full flex flex-col", sizeConfig[size].gap, containerClassName), 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: props.id, className: "mb-2", labelClassName: labelClassName })), jsxRuntime.jsxs("div", { className: cn(textFieldVariants({
3611
- size,
3612
- validationState: currentValidationState,
3613
- isDisabled,
3614
- }), isLoading && "text-field-loading", className), children: [prefix && (jsxRuntime.jsx("span", { className: cn("shrink-0 flex items-center", isDisabled
3615
- ? "text-surface-ink-neutral-disabled"
3616
- : currentValidationState === "positive"
3617
- ? "text-feedback-ink-positive-intense"
3618
- : currentValidationState === "negative"
3619
- ? "text-feedback-ink-negative-subtle"
3620
- : "text-surface-ink-neutral-muted"), children: prefix })), jsxRuntime.jsx("input", { ref: ref, value: inputValue, onChange: handleChange, disabled: isDisabled, required: isRequired, className: cn("flex-1 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
3621
- ? "text-surface-ink-neutral-disabled"
3622
- : currentValidationState === "positive"
3623
- ? "text-feedback-ink-positive-intense"
3624
- : currentValidationState === "negative"
3625
- ? "text-feedback-ink-negative-subtle"
3626
- : "text-surface-ink-neutral-muted"), children: suffix }))] }), jsxRuntime.jsx(FormFooter, { helperText: displayHelperText, validationState: currentValidationState === "none"
3627
- ? "default"
3628
- : currentValidationState, size: size, isDisabled: isDisabled, className: "mt-1" })] }));
3629
- });
3630
- TextField.displayName = "TextField";
3631
-
3632
3563
  const defaultFilter = (item, query) => {
3633
3564
  const searchQuery = query?.toLowerCase();
3634
3565
  return (item.label?.toLowerCase()?.includes(searchQuery) ||
@@ -5263,7 +5194,6 @@ exports.listItemVariants = listItemVariants;
5263
5194
  exports.paginationVariants = paginationVariants;
5264
5195
  exports.radioVariants = radioVariants;
5265
5196
  exports.selectTriggerVariants = selectTriggerVariants;
5266
- exports.selectVariants = selectVariants;
5267
5197
  exports.switchVariants = switchVariants;
5268
5198
  exports.tableCellVariants = tableCellVariants;
5269
5199
  exports.tableHeaderVariants = tableHeaderVariants;