infinity-ui-elements 1.14.9 → 1.14.11

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
@@ -4305,7 +4305,7 @@ const defaultFilter = (item, query) => {
4305
4305
  return (item.label?.toLowerCase()?.includes(searchQuery) ||
4306
4306
  (item.description?.toLowerCase()?.includes(searchQuery) ?? false));
4307
4307
  };
4308
- const SearchableDropdown = React__namespace.forwardRef(({ className, items = [], sectionHeading, isLoading = false, emptyTitle = "No Search Results Found", emptyDescription = "Add description of what the user can search for here.", emptyLinkText = "Link to support site", onEmptyLinkClick, primaryButtonText, secondaryButtonText, onPrimaryClick, onSecondaryClick, dropdownWidth = "full", showChevron = false, emptyIcon, disableFooter = false, footerLayout = "horizontal", onSearchChange, onItemSelect, filterFunction = defaultFilter, searchValue: controlledSearchValue, defaultSearchValue = "", dropdownClassName, minSearchLength = 0, showOnFocus = true, showAddNew = false, showAddNewIfDoesNotMatch = true, onAddNew, containerClassName, value: controlledValue, defaultValue, onChange, ...textFieldProps }, ref) => {
4308
+ const SearchableDropdown = React__namespace.forwardRef(({ className, items = [], sectionHeading, isLoading = false, emptyTitle = "No Search Results Found", emptyDescription = "Add description of what the user can search for here.", emptyLinkText = "Link to support site", onEmptyLinkClick, primaryButtonText, secondaryButtonText, onPrimaryClick, onSecondaryClick, dropdownWidth = "full", showChevron = false, emptyIcon, disableFooter = false, footerLayout = "horizontal", onSearchChange, onItemSelect, filterFunction = defaultFilter, searchValue: controlledSearchValue, defaultSearchValue = "", dropdownClassName, minSearchLength = 0, showOnFocus = true, showAddNew = false, showAddNewIfDoesNotMatch = true, addNewLabel = "Item", onAddNew, containerClassName, value: controlledValue, defaultValue, onChange, ...textFieldProps }, ref) => {
4309
4309
  // Find the selected item based on value/defaultValue
4310
4310
  const findSelectedItem = React__namespace.useCallback((val) => {
4311
4311
  if (val === undefined || val === "")
@@ -4496,12 +4496,23 @@ const SearchableDropdown = React__namespace.forwardRef(({ className, items = [],
4496
4496
  }, [items, searchValue, filterFunction]);
4497
4497
  // Add "Add New" option based on showAddNew and showAddNewIfDoesNotMatch props
4498
4498
  const itemsWithAddNew = React__namespace.useMemo(() => {
4499
- if (!showAddNew || !searchValue) {
4499
+ if (!showAddNew) {
4500
4500
  return filteredItems;
4501
4501
  }
4502
+ // When showAddNewIfDoesNotMatch is false, show "Add New" even without search value
4503
+ const shouldShowAddNew = showAddNewIfDoesNotMatch
4504
+ ? searchValue.length > 0
4505
+ : true;
4506
+ if (!shouldShowAddNew) {
4507
+ return filteredItems;
4508
+ }
4509
+ // Determine the label for "Add New" option
4510
+ const addNewDisplayLabel = searchValue
4511
+ ? `+ Add "${searchValue}"`
4512
+ : `+ Add New ${addNewLabel}`;
4502
4513
  const addNewItem = {
4503
- value: searchValue,
4504
- label: `+ Add "${searchValue}"`,
4514
+ value: searchValue || `new-${addNewLabel}`,
4515
+ label: addNewDisplayLabel,
4505
4516
  variant: "primary",
4506
4517
  onClick: () => {
4507
4518
  if (onAddNew) {
@@ -4536,6 +4547,7 @@ const SearchableDropdown = React__namespace.forwardRef(({ className, items = [],
4536
4547
  }, [
4537
4548
  showAddNew,
4538
4549
  showAddNewIfDoesNotMatch,
4550
+ addNewLabel,
4539
4551
  searchValue,
4540
4552
  filteredItems,
4541
4553
  onItemSelect,
@@ -4782,7 +4794,7 @@ const Skeleton = React__namespace.forwardRef(({ className, containerClassName, c
4782
4794
  });
4783
4795
  Skeleton.displayName = "Skeleton";
4784
4796
 
4785
- const selectTriggerVariants = classVarianceAuthority.cva("flex items-center gap-1 transition-all font-functional font-size-100 leading-100", {
4797
+ const selectTriggerVariants = classVarianceAuthority.cva("flex items-center gap-2 transition-all font-functional font-size-100 leading-100", {
4786
4798
  variants: {
4787
4799
  size: {
4788
4800
  small: "px-2 text-xs",
@@ -4805,7 +4817,7 @@ const selectTriggerVariants = classVarianceAuthority.cva("flex items-center gap-
4805
4817
  isDisabled: false,
4806
4818
  },
4807
4819
  });
4808
- const SelectTextField = React__namespace.forwardRef(({ textValue: controlledTextValue, defaultTextValue, onTextChange, selectOptions = [], selectValue: controlledSelectValue, defaultSelectValue, onSelectChange, selectPlaceholder = "Select", selectTriggerClassName, selectMenuClassName, selectMenuWidth = "auto", selectSectionHeading, selectEmptyTitle = "No options available", selectEmptyDescription = "There are no options to select from.", selectEmptyIcon, position = "suffix", label, helperText, errorText, successText, validationState = "none", isDisabled = false, isRequired = false, isOptional = false, size = "medium", containerClassName, labelClassName, inputClassName, className, ...textFieldProps }, ref) => {
4820
+ const SelectTextField = React__namespace.forwardRef(({ textValue: controlledTextValue, defaultTextValue, onTextChange, selectOptions = [], selectValue: controlledSelectValue, defaultSelectValue, onSelectChange, selectPlaceholder = "Select", selectTriggerClassName, selectMenuClassName, selectMenuWidth = "auto", selectSectionHeading, selectEmptyTitle = "No options available", selectEmptyDescription = "There are no options to select from.", selectEmptyIcon, position = "suffix", isSelectDisabled = false, isTextFieldDisabled = false, label, helperText, errorText, successText, validationState = "none", isDisabled = false, isRequired = false, isOptional = false, size = "medium", containerClassName, labelClassName, inputClassName, className, ...textFieldProps }, ref) => {
4809
4821
  const [uncontrolledTextValue, setUncontrolledTextValue] = React__namespace.useState(defaultTextValue || "");
4810
4822
  const [uncontrolledSelectValue, setUncontrolledSelectValue] = React__namespace.useState(defaultSelectValue);
4811
4823
  const [isSelectOpen, setIsSelectOpen] = React__namespace.useState(false);
@@ -4831,6 +4843,10 @@ const SelectTextField = React__namespace.forwardRef(({ textValue: controlledText
4831
4843
  const selectValue = controlledSelectValue !== undefined
4832
4844
  ? controlledSelectValue
4833
4845
  : uncontrolledSelectValue;
4846
+ // Compute effective disabled states
4847
+ // isDisabled disables both; individual props allow disabling each independently
4848
+ const effectiveSelectDisabled = isDisabled || isSelectDisabled;
4849
+ const effectiveTextFieldDisabled = isDisabled || isTextFieldDisabled;
4834
4850
  // Find the selected option
4835
4851
  const selectedOption = selectOptions.find((opt) => opt.value === selectValue);
4836
4852
  // Determine which helper text to show
@@ -4850,7 +4866,7 @@ const SelectTextField = React__namespace.forwardRef(({ textValue: controlledText
4850
4866
  }
4851
4867
  };
4852
4868
  const handleSelectOpenChange = (newOpen) => {
4853
- if (!isDisabled) {
4869
+ if (!effectiveSelectDisabled) {
4854
4870
  setIsSelectOpen(newOpen);
4855
4871
  }
4856
4872
  };
@@ -4978,27 +4994,27 @@ const SelectTextField = React__namespace.forwardRef(({ textValue: controlledText
4978
4994
  const selectComponent = (jsxRuntime.jsxs("div", { className: cn("relative flex items-stretch h-full"), children: [jsxRuntime.jsxs("div", { ref: selectRef, className: cn(selectTriggerVariants({
4979
4995
  size,
4980
4996
  validationState: currentValidationState,
4981
- isDisabled,
4997
+ isDisabled: effectiveSelectDisabled,
4982
4998
  }), "h-full flex items-center self-stretch", position === "prefix"
4983
4999
  ? "border-r border-action-outline-neutral-faded"
4984
- : "border-l border-action-outline-neutral-faded", selectTriggerClassName, position === "prefix" ? "pr-4" : "pl-4"), onClick: !isDisabled ? toggleSelectOpen : undefined, role: "combobox", "aria-haspopup": "listbox", "aria-expanded": isSelectOpen, "aria-disabled": isDisabled, children: [jsxRuntime.jsx("span", { className: cn("text-left truncate max-w-[120px] whitespace-nowrap", !selectedOption && "text-surface-ink-neutral-muted", isDisabled && "text-surface-ink-neutral-disabled"), children: selectedOption?.label || selectPlaceholder }), jsxRuntime.jsx(lucideReact.ChevronDown, { className: cn("shrink-0 transition-transform", size === "small"
5000
+ : "border-l border-action-outline-neutral-faded", selectTriggerClassName, position === "prefix" ? "pr-4" : "pl-4"), onClick: !effectiveSelectDisabled ? toggleSelectOpen : undefined, role: "combobox", "aria-haspopup": "listbox", "aria-expanded": isSelectOpen, "aria-disabled": effectiveSelectDisabled, children: [jsxRuntime.jsx("span", { className: cn("text-left truncate max-w-[120px] whitespace-nowrap", !selectedOption && "text-surface-ink-neutral-muted", effectiveSelectDisabled && "text-surface-ink-neutral-disabled", selectedOption && 'text-surface-ink-neutral-normal'), children: selectedOption?.label || selectPlaceholder }), jsxRuntime.jsx(Icon, { name: 'chevronDown', className: cn("shrink-0 transition-transform mt-1", size === "small"
4985
5001
  ? "w-3 h-3"
4986
5002
  : size === "medium"
4987
5003
  ? "w-3.5 h-3.5"
4988
- : "w-4 h-4", isDisabled
5004
+ : "w-4 h-4", effectiveSelectDisabled
4989
5005
  ? "text-surface-ink-neutral-disabled"
4990
5006
  : currentValidationState === "positive"
4991
5007
  ? "text-feedback-ink-positive-intense"
4992
5008
  : currentValidationState === "negative"
4993
5009
  ? "text-feedback-ink-negative-subtle"
4994
- : "text-surface-ink-neutral-muted", isSelectOpen && "transform rotate-180") })] }), isSelectOpen && !isDisabled && (isMobile ? (jsxRuntime.jsx(BottomSheet, { isOpen: isSelectOpen, onClose: () => handleSelectOpenChange(false), title: selectSectionHeading || label, variant: "default", showDragHandle: true, closeOnOverlayClick: true, closeOnEscape: true, closeOnSwipeDown: true, children: renderDropdownContent() })) : (jsxRuntime.jsx("div", { ref: dropdownContainerRef, className: cn("absolute z-50", position === "prefix" ? "left-[-12px]" : "right-[-12px]", dropdownPlacement === "bottom"
5010
+ : "text-surface-ink-neutral-muted", isSelectOpen && "transform rotate-180") })] }), isSelectOpen && !effectiveSelectDisabled && (isMobile ? (jsxRuntime.jsx(BottomSheet, { isOpen: isSelectOpen, onClose: () => handleSelectOpenChange(false), title: selectSectionHeading || label, variant: "default", showDragHandle: true, closeOnOverlayClick: true, closeOnEscape: true, closeOnSwipeDown: true, children: renderDropdownContent() })) : (jsxRuntime.jsx("div", { ref: dropdownContainerRef, className: cn("absolute z-50", position === "prefix" ? "left-[-12px]" : "right-[-12px]", dropdownPlacement === "bottom"
4995
5011
  ? "top-[30px] mt-1"
4996
5012
  : "bottom-full mb-1"), children: renderDropdownContent() })))] }));
4997
5013
  return (jsxRuntime.jsxs("div", { ref: componentRef, 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: textFieldProps.infoHeading, infoDescription: textFieldProps.infoDescription, LinkComponent: textFieldProps.LinkComponent, linkText: textFieldProps.linkText, linkHref: textFieldProps.linkHref, onLinkClick: textFieldProps.onLinkClick, htmlFor: textFieldProps.id, className: "mb-2", labelClassName: labelClassName })), jsxRuntime.jsx(TextField, { ref: ref, value: textValue, onChange: handleTextChange, ...(position === "prefix"
4998
5014
  ? { prefix: selectComponent }
4999
- : { suffix: selectComponent }), size: size, validationState: currentValidationState, isDisabled: isDisabled, isRequired: isRequired, isOptional: isOptional, containerClassName: "gap-0", className: className, inputClassName: inputClassName, ...textFieldProps }), jsxRuntime.jsx(FormFooter, { helperText: displayHelperText, validationState: currentValidationState === "none"
5015
+ : { suffix: selectComponent }), size: size, validationState: currentValidationState, isDisabled: effectiveTextFieldDisabled, isRequired: isRequired, isOptional: isOptional, containerClassName: "gap-0", className: className, inputClassName: inputClassName, ...textFieldProps }), jsxRuntime.jsx(FormFooter, { helperText: displayHelperText, validationState: currentValidationState === "none"
5000
5016
  ? "default"
5001
- : currentValidationState, size: size, isDisabled: isDisabled, className: "mt-1" })] }));
5017
+ : currentValidationState, size: size, isDisabled: effectiveSelectDisabled && effectiveTextFieldDisabled, className: "mt-1" })] }));
5002
5018
  });
5003
5019
  SelectTextField.displayName = "SelectTextField";
5004
5020