infinity-ui-elements 1.14.9 → 1.14.10
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.
|
@@ -67,6 +67,18 @@ export interface SelectTextFieldProps extends Omit<TextFieldProps, "suffix" | "o
|
|
|
67
67
|
* @default "suffix"
|
|
68
68
|
*/
|
|
69
69
|
position?: "prefix" | "suffix";
|
|
70
|
+
/**
|
|
71
|
+
* Whether the select dropdown is disabled (independent of text field)
|
|
72
|
+
* When true, only the select portion is disabled. Use `isDisabled` to disable both.
|
|
73
|
+
* @default false
|
|
74
|
+
*/
|
|
75
|
+
isSelectDisabled?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Whether the text field is disabled (independent of select)
|
|
78
|
+
* When true, only the text field portion is disabled. Use `isDisabled` to disable both.
|
|
79
|
+
* @default false
|
|
80
|
+
*/
|
|
81
|
+
isTextFieldDisabled?: boolean;
|
|
70
82
|
}
|
|
71
83
|
declare const selectTriggerVariants: (props?: ({
|
|
72
84
|
size?: "medium" | "large" | "small" | null | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectTextField.d.ts","sourceRoot":"","sources":["../../../src/components/SelectTextField/SelectTextField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAI9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"SelectTextField.d.ts","sourceRoot":"","sources":["../../../src/components/SelectTextField/SelectTextField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAI9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAI9C,MAAM,WAAW,oBACf,SAAQ,IAAI,C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3B,CAAC;AAIF,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
|
package/dist/index.esm.js
CHANGED
|
@@ -5,7 +5,7 @@ import { Slot } from '@radix-ui/react-slot';
|
|
|
5
5
|
import { PulseLoader, ClipLoader } from 'react-spinners';
|
|
6
6
|
import { clsx } from 'clsx';
|
|
7
7
|
import { twMerge } from 'tailwind-merge';
|
|
8
|
-
import { ExternalLink, Calendar, X, ChevronLeft, ChevronRight, Loader2, Search
|
|
8
|
+
import { ExternalLink, Calendar, X, ChevronLeft, ChevronRight, Loader2, Search } from 'lucide-react';
|
|
9
9
|
import { createPortal } from 'react-dom';
|
|
10
10
|
import Calendar$1 from 'react-calendar';
|
|
11
11
|
import 'react-calendar/dist/Calendar.css';
|
|
@@ -4761,7 +4761,7 @@ const Skeleton = React.forwardRef(({ className, containerClassName, containerSty
|
|
|
4761
4761
|
});
|
|
4762
4762
|
Skeleton.displayName = "Skeleton";
|
|
4763
4763
|
|
|
4764
|
-
const selectTriggerVariants = cva("flex items-center gap-
|
|
4764
|
+
const selectTriggerVariants = cva("flex items-center gap-2 transition-all font-functional font-size-100 leading-100", {
|
|
4765
4765
|
variants: {
|
|
4766
4766
|
size: {
|
|
4767
4767
|
small: "px-2 text-xs",
|
|
@@ -4784,7 +4784,7 @@ const selectTriggerVariants = cva("flex items-center gap-1 transition-all font-f
|
|
|
4784
4784
|
isDisabled: false,
|
|
4785
4785
|
},
|
|
4786
4786
|
});
|
|
4787
|
-
const SelectTextField = React.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) => {
|
|
4787
|
+
const SelectTextField = React.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) => {
|
|
4788
4788
|
const [uncontrolledTextValue, setUncontrolledTextValue] = React.useState(defaultTextValue || "");
|
|
4789
4789
|
const [uncontrolledSelectValue, setUncontrolledSelectValue] = React.useState(defaultSelectValue);
|
|
4790
4790
|
const [isSelectOpen, setIsSelectOpen] = React.useState(false);
|
|
@@ -4810,6 +4810,10 @@ const SelectTextField = React.forwardRef(({ textValue: controlledTextValue, defa
|
|
|
4810
4810
|
const selectValue = controlledSelectValue !== undefined
|
|
4811
4811
|
? controlledSelectValue
|
|
4812
4812
|
: uncontrolledSelectValue;
|
|
4813
|
+
// Compute effective disabled states
|
|
4814
|
+
// isDisabled disables both; individual props allow disabling each independently
|
|
4815
|
+
const effectiveSelectDisabled = isDisabled || isSelectDisabled;
|
|
4816
|
+
const effectiveTextFieldDisabled = isDisabled || isTextFieldDisabled;
|
|
4813
4817
|
// Find the selected option
|
|
4814
4818
|
const selectedOption = selectOptions.find((opt) => opt.value === selectValue);
|
|
4815
4819
|
// Determine which helper text to show
|
|
@@ -4829,7 +4833,7 @@ const SelectTextField = React.forwardRef(({ textValue: controlledTextValue, defa
|
|
|
4829
4833
|
}
|
|
4830
4834
|
};
|
|
4831
4835
|
const handleSelectOpenChange = (newOpen) => {
|
|
4832
|
-
if (!
|
|
4836
|
+
if (!effectiveSelectDisabled) {
|
|
4833
4837
|
setIsSelectOpen(newOpen);
|
|
4834
4838
|
}
|
|
4835
4839
|
};
|
|
@@ -4957,27 +4961,27 @@ const SelectTextField = React.forwardRef(({ textValue: controlledTextValue, defa
|
|
|
4957
4961
|
const selectComponent = (jsxs("div", { className: cn("relative flex items-stretch h-full"), children: [jsxs("div", { ref: selectRef, className: cn(selectTriggerVariants({
|
|
4958
4962
|
size,
|
|
4959
4963
|
validationState: currentValidationState,
|
|
4960
|
-
isDisabled,
|
|
4964
|
+
isDisabled: effectiveSelectDisabled,
|
|
4961
4965
|
}), "h-full flex items-center self-stretch", position === "prefix"
|
|
4962
4966
|
? "border-r border-action-outline-neutral-faded"
|
|
4963
|
-
: "border-l border-action-outline-neutral-faded", selectTriggerClassName, position === "prefix" ? "pr-4" : "pl-4"), onClick: !
|
|
4967
|
+
: "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: [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 }), jsx(Icon, { name: 'chevronDown', className: cn("shrink-0 transition-transform mt-1", size === "small"
|
|
4964
4968
|
? "w-3 h-3"
|
|
4965
4969
|
: size === "medium"
|
|
4966
4970
|
? "w-3.5 h-3.5"
|
|
4967
|
-
: "w-4 h-4",
|
|
4971
|
+
: "w-4 h-4", effectiveSelectDisabled
|
|
4968
4972
|
? "text-surface-ink-neutral-disabled"
|
|
4969
4973
|
: currentValidationState === "positive"
|
|
4970
4974
|
? "text-feedback-ink-positive-intense"
|
|
4971
4975
|
: currentValidationState === "negative"
|
|
4972
4976
|
? "text-feedback-ink-negative-subtle"
|
|
4973
|
-
: "text-surface-ink-neutral-muted", isSelectOpen && "transform rotate-180") })] }), isSelectOpen && !
|
|
4977
|
+
: "text-surface-ink-neutral-muted", isSelectOpen && "transform rotate-180") })] }), isSelectOpen && !effectiveSelectDisabled && (isMobile ? (jsx(BottomSheet, { isOpen: isSelectOpen, onClose: () => handleSelectOpenChange(false), title: selectSectionHeading || label, variant: "default", showDragHandle: true, closeOnOverlayClick: true, closeOnEscape: true, closeOnSwipeDown: true, children: renderDropdownContent() })) : (jsx("div", { ref: dropdownContainerRef, className: cn("absolute z-50", position === "prefix" ? "left-[-12px]" : "right-[-12px]", dropdownPlacement === "bottom"
|
|
4974
4978
|
? "top-[30px] mt-1"
|
|
4975
4979
|
: "bottom-full mb-1"), children: renderDropdownContent() })))] }));
|
|
4976
4980
|
return (jsxs("div", { ref: componentRef, className: cn("w-full flex flex-col", sizeConfig[size].gap, containerClassName), children: [label && (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 })), jsx(TextField, { ref: ref, value: textValue, onChange: handleTextChange, ...(position === "prefix"
|
|
4977
4981
|
? { prefix: selectComponent }
|
|
4978
|
-
: { suffix: selectComponent }), size: size, validationState: currentValidationState, isDisabled:
|
|
4982
|
+
: { suffix: selectComponent }), size: size, validationState: currentValidationState, isDisabled: effectiveTextFieldDisabled, isRequired: isRequired, isOptional: isOptional, containerClassName: "gap-0", className: className, inputClassName: inputClassName, ...textFieldProps }), jsx(FormFooter, { helperText: displayHelperText, validationState: currentValidationState === "none"
|
|
4979
4983
|
? "default"
|
|
4980
|
-
: currentValidationState, size: size, isDisabled:
|
|
4984
|
+
: currentValidationState, size: size, isDisabled: effectiveSelectDisabled && effectiveTextFieldDisabled, className: "mt-1" })] }));
|
|
4981
4985
|
});
|
|
4982
4986
|
SelectTextField.displayName = "SelectTextField";
|
|
4983
4987
|
|