infinity-ui-elements 1.8.58 → 1.8.60

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
@@ -59,9 +59,10 @@ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
59
59
  */
60
60
  const iconRegistry = {
61
61
  // Tick/Check icon
62
- tick: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
63
- <path d="M10.364 15.1924L19.5564 6L20.9706 7.41421L10.364 18.0208L4 11.6569L5.41422 10.2427L10.364 15.1924Z" fill="#081416"/>
64
- </svg>`,
62
+ tick: `<svg width="10" height="10" viewBox="0 0 10 10" fill="none" xmlns="http://www.w3.org/2000/svg">
63
+ <path d="M7.99907 1.77063L8.63188 2.42981L8.69829 2.49915L8.63188 2.56848L3.88188 7.50891L3.80962 7.58411L3.73833 7.50891L0.887741 4.54504L0.821335 4.47571L0.887741 4.40637L1.52153 3.74719L1.5938 3.672L1.66508 3.74719L3.80962 5.97766L7.85454 1.77063L7.9268 1.69543L7.99907 1.77063Z" fill="white" stroke="white" stroke-width="0.2"/>
64
+ </svg>
65
+ `,
65
66
  // Alias: check points to the same icon as tick
66
67
  check: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
67
68
  <path d="M10.364 15.1924L19.5564 6L20.9706 7.41421L10.364 18.0208L4 11.6569L5.41422 10.2427L10.364 15.1924Z" fill="#081416"/>
@@ -89,6 +90,14 @@ const iconRegistry = {
89
90
  file: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
90
91
  <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
92
  </svg>
93
+ `,
94
+ chevronDown: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
95
+ <path d="M12 13.7272L17.4445 8L19 9.63635L12 17L5 9.63635L6.55555 8L12 13.7272Z" fill="#081416"/>
96
+ </svg>
97
+ `,
98
+ chevronUp: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
99
+ <path d="M12 11.2727L6.55555 17L5 15.3637L12 8L19 15.3637L17.4445 17L12 11.2727Z" fill="#081416"/>
100
+ </svg>
92
101
  `,
93
102
  };
94
103
  const Icon = ({ name, size = 24, className = "", style = {}, ...props }) => {
@@ -1506,9 +1515,9 @@ FormFooter.displayName = "FormFooter";
1506
1515
  const checkboxVariants = classVarianceAuthority.cva("relative inline-flex items-center justify-center shrink-0 transition-all cursor-pointer box-border", {
1507
1516
  variants: {
1508
1517
  size: {
1509
- small: "w-[10px] h-[10px] rounded-small border-[1.5px]",
1510
- medium: "w-[12px] h-[12px] rounded-small border-[1.5px]",
1511
- large: "w-[16px] h-[16px] rounded-medium border-[2px]",
1518
+ small: "w-[14px] h-[14px] rounded-small border-[1.5px]",
1519
+ medium: "w-[16px] h-[16px] rounded-small border-[1.5px]",
1520
+ large: "w-[20px] h-[20px] rounded-medium border-[2px]",
1512
1521
  },
1513
1522
  validationState: {
1514
1523
  none: "",
@@ -1576,7 +1585,6 @@ const Checkbox = React__namespace.forwardRef(({ label, errorText, size = "medium
1576
1585
  const [internalChecked, setInternalChecked] = React__namespace.useState(false);
1577
1586
  const [showRipple, setShowRipple] = React__namespace.useState(false);
1578
1587
  const inputRef = React__namespace.useRef(null);
1579
- const rippleTimeoutRef = React__namespace.useRef(null);
1580
1588
  // Use forwarded ref or internal ref
1581
1589
  React__namespace.useImperativeHandle(ref, () => inputRef.current);
1582
1590
  const isChecked = checked !== undefined ? checked : internalChecked;
@@ -1586,14 +1594,6 @@ const Checkbox = React__namespace.forwardRef(({ label, errorText, size = "medium
1586
1594
  inputRef.current.indeterminate = isIndeterminate;
1587
1595
  }
1588
1596
  }, [isIndeterminate]);
1589
- // Cleanup timeout on unmount
1590
- React__namespace.useEffect(() => {
1591
- return () => {
1592
- if (rippleTimeoutRef.current) {
1593
- clearTimeout(rippleTimeoutRef.current);
1594
- }
1595
- };
1596
- }, []);
1597
1597
  const handleChange = (e) => {
1598
1598
  if (onChange) {
1599
1599
  onChange(e);
@@ -1603,28 +1603,31 @@ const Checkbox = React__namespace.forwardRef(({ label, errorText, size = "medium
1603
1603
  }
1604
1604
  };
1605
1605
  const triggerRipple = () => {
1606
- if (!isDisabled && !showRipple) {
1607
- // Clear any existing timeout
1608
- if (rippleTimeoutRef.current) {
1609
- clearTimeout(rippleTimeoutRef.current);
1610
- }
1606
+ if (!isDisabled) {
1611
1607
  setShowRipple(true);
1612
- rippleTimeoutRef.current = setTimeout(() => {
1608
+ setTimeout(() => {
1613
1609
  setShowRipple(false);
1614
- rippleTimeoutRef.current = null;
1615
- }, 400); // Match animation duration (0.4s)
1610
+ }, 360); // Match animation duration (0.36s)
1616
1611
  }
1617
1612
  };
1618
1613
  const handleContainerClick = () => {
1619
1614
  if (!isDisabled && inputRef.current) {
1620
- triggerRipple();
1615
+ // Only show ripple when checking or entering indeterminate state (not unchecking)
1616
+ const willBeChecked = !isChecked || isIndeterminate;
1617
+ if (willBeChecked) {
1618
+ triggerRipple();
1619
+ }
1621
1620
  inputRef.current.click();
1622
1621
  }
1623
1622
  };
1624
1623
  const handleKeyDown = (e) => {
1625
1624
  if ((e.key === " " || e.key === "Enter") && !isDisabled) {
1626
1625
  e.preventDefault();
1627
- triggerRipple();
1626
+ // Only show ripple when checking or entering indeterminate state (not unchecking)
1627
+ const willBeChecked = !isChecked || isIndeterminate;
1628
+ if (willBeChecked) {
1629
+ triggerRipple();
1630
+ }
1628
1631
  inputRef.current?.click();
1629
1632
  }
1630
1633
  };
@@ -1633,23 +1636,23 @@ const Checkbox = React__namespace.forwardRef(({ label, errorText, size = "medium
1633
1636
  small: {
1634
1637
  gap: "gap-2",
1635
1638
  labelSize: "text-body-small-regular",
1636
- iconSize: 10,
1639
+ iconSize: 7,
1637
1640
  },
1638
1641
  medium: {
1639
1642
  gap: "gap-2",
1640
1643
  labelSize: "text-body-small-regular",
1641
- iconSize: 12,
1644
+ iconSize: 9.6,
1642
1645
  },
1643
1646
  large: {
1644
1647
  gap: "gap-3",
1645
1648
  labelSize: "text-body-medium-regular",
1646
- iconSize: 14,
1649
+ iconSize: 13.33,
1647
1650
  },
1648
1651
  };
1649
1652
  const config = sizeConfig[size];
1650
1653
  // Determine if we should show the error text
1651
1654
  const shouldShowError = errorText && showErrorText;
1652
- return (jsxRuntime.jsxs("div", { className: cn("inline-flex flex-col px-2", containerClassName), children: [jsxRuntime.jsxs("div", { className: cn("inline-flex items-center", config.gap, isDisabled ? "cursor-not-allowed" : "cursor-pointer"), onClick: handleContainerClick, onKeyDown: handleKeyDown, role: "checkbox", "aria-checked": isIndeterminate ? "mixed" : isChecked, "aria-disabled": isDisabled, tabIndex: isDisabled ? -1 : 0, children: [jsxRuntime.jsx("input", { ref: inputRef, type: "checkbox", 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"
1655
+ return (jsxRuntime.jsxs("div", { className: cn("inline-flex flex-col py-0.5", containerClassName), children: [jsxRuntime.jsxs("div", { className: cn("inline-flex items-center", config.gap, isDisabled ? "cursor-not-allowed" : "cursor-pointer"), onClick: handleContainerClick, onKeyDown: handleKeyDown, role: "checkbox", "aria-checked": isIndeterminate ? "mixed" : isChecked, "aria-disabled": isDisabled, tabIndex: isDisabled ? -1 : 0, children: [jsxRuntime.jsx("input", { ref: inputRef, type: "checkbox", 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"
1653
1656
  ? "bg-action-outline-negative-faded"
1654
1657
  : "bg-action-outline-primary-faded"), style: {
1655
1658
  animation: "var(--animate-checkbox-ripple)",
@@ -2851,7 +2854,7 @@ const Modal = React__namespace.forwardRef(({ isOpen, onClose, title, description
2851
2854
  });
2852
2855
  Modal.displayName = "Modal";
2853
2856
 
2854
- const selectVariants = classVarianceAuthority.cva("relative flex items-center gap-2 border rounded-large transition-all font-functional font-size-100 leading-100", {
2857
+ const textFieldVariants = classVarianceAuthority.cva("relative flex items-center gap-3 border rounded-large transition-all font-functional font-size-100 leading-100", {
2855
2858
  variants: {
2856
2859
  size: {
2857
2860
  small: "h-[28px] px-3 text-xs gap-2",
@@ -2861,10 +2864,11 @@ const selectVariants = classVarianceAuthority.cva("relative flex items-center ga
2861
2864
  validationState: {
2862
2865
  none: `
2863
2866
  border-action-outline-neutral-faded
2864
- hover:border-action-outline-primary-hover
2865
- focus-within:border-action-outline-primary-hover
2867
+ hover:border-action-outline-neutral-faded-hover
2868
+ hover:bg-action-fill-neutral-faded-hover
2869
+ focus-within:border-action-outline-primary-default
2866
2870
  focus-within:ring-2
2867
- ring-action-outline-primary-faded-hover`,
2871
+ ring-surface-outline-primary-muted`,
2868
2872
  positive: `
2869
2873
  border-action-outline-positive-default
2870
2874
  focus-within:border-action-outline-positive-hover
@@ -2877,11 +2881,13 @@ const selectVariants = classVarianceAuthority.cva("relative flex items-center ga
2877
2881
  },
2878
2882
  isDisabled: {
2879
2883
  true: `
2880
- border-[var(--border-width-thinner)]
2881
- hover:border-action-outline-neutral-disabled
2884
+ border
2882
2885
  border-action-outline-neutral-disabled
2883
- bg-surface-fill-neutral-intense cursor-not-allowed opacity-60`,
2884
- false: "bg-surface-fill-neutral-intense",
2886
+ hover:border-action-outline-neutral-disabled
2887
+ bg-surface-fill-neutral-intense
2888
+ hover:bg-surface-fill-neutral-intense
2889
+ cursor-not-allowed`,
2890
+ false: "",
2885
2891
  },
2886
2892
  },
2887
2893
  defaultVariants: {
@@ -2890,23 +2896,83 @@ const selectVariants = classVarianceAuthority.cva("relative flex items-center ga
2890
2896
  isDisabled: false,
2891
2897
  },
2892
2898
  });
2899
+ 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) => {
2900
+ const [internalValue, setInternalValue] = React__namespace.useState("");
2901
+ const inputValue = value !== undefined ? value : internalValue;
2902
+ const hasValue = inputValue && String(inputValue).length > 0;
2903
+ const handleChange = (e) => {
2904
+ if (onChange) {
2905
+ onChange(e);
2906
+ }
2907
+ else {
2908
+ setInternalValue(e.target.value);
2909
+ }
2910
+ };
2911
+ const handleClear = () => {
2912
+ if (onClear) {
2913
+ onClear();
2914
+ }
2915
+ else {
2916
+ setInternalValue("");
2917
+ }
2918
+ // Focus the input after clearing
2919
+ const input = document.getElementById(props.id || "");
2920
+ if (input) {
2921
+ input.focus();
2922
+ }
2923
+ };
2924
+ // Determine which helper text to show
2925
+ const displayHelperText = errorText || successText || helperText;
2926
+ const currentValidationState = errorText
2927
+ ? "negative"
2928
+ : successText
2929
+ ? "positive"
2930
+ : validationState;
2931
+ const sizeConfig = {
2932
+ small: {
2933
+ gap: "gap-2",
2934
+ },
2935
+ medium: {
2936
+ gap: "gap-2",
2937
+ },
2938
+ large: {
2939
+ gap: "gap-3",
2940
+ },
2941
+ };
2942
+ 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({
2943
+ size,
2944
+ validationState: currentValidationState,
2945
+ isDisabled,
2946
+ }), isLoading && "text-field-loading", className), children: [prefix && (jsxRuntime.jsx("span", { className: cn("shrink-0 flex items-center", isDisabled
2947
+ ? "text-surface-ink-neutral-disabled"
2948
+ : currentValidationState === "positive"
2949
+ ? "text-feedback-ink-positive-intense"
2950
+ : currentValidationState === "negative"
2951
+ ? "text-feedback-ink-negative-subtle"
2952
+ : "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
2953
+ ? "text-surface-ink-neutral-disabled"
2954
+ : currentValidationState === "positive"
2955
+ ? "text-feedback-ink-positive-intense"
2956
+ : currentValidationState === "negative"
2957
+ ? "text-feedback-ink-negative-subtle"
2958
+ : "text-surface-ink-neutral-muted"), children: suffix }))] }), jsxRuntime.jsx(FormFooter, { helperText: displayHelperText, validationState: currentValidationState === "none"
2959
+ ? "default"
2960
+ : currentValidationState, size: size, isDisabled: isDisabled, className: "mt-1" })] }));
2961
+ });
2962
+ TextField.displayName = "TextField";
2963
+
2893
2964
  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
2965
  const [uncontrolledValue, setUncontrolledValue] = React__namespace.useState(defaultValue);
2895
2966
  const [isOpen, setIsOpen] = React__namespace.useState(false);
2896
2967
  const [dropdownPlacement, setDropdownPlacement] = React__namespace.useState("bottom");
2897
- const selectRef = React__namespace.useRef(null);
2968
+ const containerRef = React__namespace.useRef(null);
2898
2969
  const dropdownContainerRef = React__namespace.useRef(null);
2970
+ const inputRef = React__namespace.useRef(null);
2971
+ React__namespace.useImperativeHandle(ref, () => inputRef.current);
2899
2972
  const value = controlledValue !== undefined ? controlledValue : uncontrolledValue;
2900
2973
  // Find the selected option
2901
2974
  const selectedOption = options.find((opt) => opt.value === value);
2902
2975
  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
2976
  const handleOpenChange = (newOpen) => {
2911
2977
  if (!isDisabled && !isLoading) {
2912
2978
  setIsOpen(newOpen);
@@ -2921,9 +2987,9 @@ const Select = React__namespace.forwardRef(({ className, options = [], value: co
2921
2987
  }
2922
2988
  onChange?.(option.value, option);
2923
2989
  setIsOpen(false);
2990
+ inputRef.current?.focus();
2924
2991
  };
2925
- const handleClear = (e) => {
2926
- e.stopPropagation();
2992
+ const handleClear = () => {
2927
2993
  if (onClear) {
2928
2994
  onClear();
2929
2995
  }
@@ -2937,7 +3003,7 @@ const Select = React__namespace.forwardRef(({ className, options = [], value: co
2937
3003
  const updateDropdownPlacement = React__namespace.useCallback(() => {
2938
3004
  if (typeof window === "undefined")
2939
3005
  return;
2940
- const trigger = selectRef.current;
3006
+ const trigger = containerRef.current;
2941
3007
  if (!trigger)
2942
3008
  return;
2943
3009
  const triggerRect = trigger.getBoundingClientRect();
@@ -2986,8 +3052,10 @@ const Select = React__namespace.forwardRef(({ className, options = [], value: co
2986
3052
  // Close dropdown when clicking outside
2987
3053
  React__namespace.useEffect(() => {
2988
3054
  const handleClickOutside = (event) => {
2989
- if (selectRef.current &&
2990
- !selectRef.current.contains(event.target)) {
3055
+ if (containerRef.current &&
3056
+ !containerRef.current.contains(event.target) &&
3057
+ dropdownContainerRef.current &&
3058
+ !dropdownContainerRef.current.contains(event.target)) {
2991
3059
  handleOpenChange(false);
2992
3060
  }
2993
3061
  };
@@ -3013,35 +3081,27 @@ const Select = React__namespace.forwardRef(({ className, options = [], value: co
3013
3081
  }
3014
3082
  }, [isOpen]);
3015
3083
  // 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 === " ")) {
3084
+ const handleKeyDown = (event) => {
3085
+ if (isDisabled || isLoading)
3086
+ return;
3087
+ if (!isOpen && (event.key === "Enter" || event.key === " ")) {
3088
+ event.preventDefault();
3089
+ setIsOpen(true);
3090
+ return;
3091
+ }
3092
+ if (isOpen) {
3093
+ if (event.key === "ArrowDown" || event.key === "ArrowUp") {
3021
3094
  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
- }
3095
+ const currentIndex = options.findIndex((opt) => opt.value === value);
3096
+ const nextIndex = event.key === "ArrowDown"
3097
+ ? Math.min(currentIndex + 1, options.length - 1)
3098
+ : Math.max(currentIndex - 1, 0);
3099
+ if (options[nextIndex] && !options[nextIndex].isDisabled) {
3100
+ handleSelect(options[nextIndex]);
3035
3101
  }
3036
3102
  }
3037
- };
3038
- if (selectRef.current) {
3039
- selectRef.current.addEventListener("keydown", handleKeyDown);
3040
- return () => {
3041
- selectRef.current?.removeEventListener("keydown", handleKeyDown);
3042
- };
3043
3103
  }
3044
- }, [isOpen, value, options, isDisabled, isLoading]);
3104
+ };
3045
3105
  // Transform options to dropdown menu items
3046
3106
  const menuItems = options.map((option) => ({
3047
3107
  value: option.value,
@@ -3054,50 +3114,20 @@ const Select = React__namespace.forwardRef(({ className, options = [], value: co
3054
3114
  onClick: () => handleSelect(option),
3055
3115
  }));
3056
3116
  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" })] }));
3117
+ // Get the display value for the TextField
3118
+ const displayValue = isLoading ? "Loading..." : selectedOption?.label || "";
3119
+ // Build the prefix: either provided prefix or selected option's leadingIcon
3120
+ const displayPrefix = prefix
3121
+ ? prefix
3122
+ : showLeadingIcon && selectedOption?.leadingIcon
3123
+ ? selectedOption.leadingIcon
3124
+ : undefined;
3125
+ // Build the suffix: include both the optional suffix and the chevron icon
3126
+ const chevronIcon = (jsxRuntime.jsx(Icon, { name: isOpen ? "chevronUp" : "chevronDown", size: 16, className: "shrink-0 transition-colors" }));
3127
+ const displaySuffix = suffix ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [suffix, chevronIcon] })) : (chevronIcon);
3128
+ 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"
3129
+ ? "top-full mt-1"
3130
+ : "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
3131
  });
3102
3132
  Select.displayName = "Select";
3103
3133
 
@@ -3525,110 +3555,6 @@ const RadioGroup = React__namespace.forwardRef(({ value: controlledValue, defaul
3525
3555
  });
3526
3556
  RadioGroup.displayName = "RadioGroup";
3527
3557
 
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
3558
  const defaultFilter = (item, query) => {
3633
3559
  const searchQuery = query?.toLowerCase();
3634
3560
  return (item.label?.toLowerCase()?.includes(searchQuery) ||
@@ -5263,7 +5189,6 @@ exports.listItemVariants = listItemVariants;
5263
5189
  exports.paginationVariants = paginationVariants;
5264
5190
  exports.radioVariants = radioVariants;
5265
5191
  exports.selectTriggerVariants = selectTriggerVariants;
5266
- exports.selectVariants = selectVariants;
5267
5192
  exports.switchVariants = switchVariants;
5268
5193
  exports.tableCellVariants = tableCellVariants;
5269
5194
  exports.tableHeaderVariants = tableHeaderVariants;