infinity-ui-elements 1.14.10 → 1.14.12
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/SearchableDropdown/SearchableDropdown.d.ts +5 -0
- package/dist/components/SearchableDropdown/SearchableDropdown.d.ts.map +1 -1
- package/dist/components/SearchableDropdown/SearchableDropdown.stories.d.ts +11 -0
- package/dist/components/SearchableDropdown/SearchableDropdown.stories.d.ts.map +1 -1
- package/dist/index.esm.js +17 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +17 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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
|
|
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:
|
|
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,
|
|
@@ -5022,7 +5034,7 @@ const switchVariants = classVarianceAuthority.cva("relative inline-flex items-ce
|
|
|
5022
5034
|
false: "",
|
|
5023
5035
|
},
|
|
5024
5036
|
isDisabled: {
|
|
5025
|
-
true: "cursor-not-allowed
|
|
5037
|
+
true: "cursor-not-allowed bg-surface-fill-neutral-moderate",
|
|
5026
5038
|
false: "",
|
|
5027
5039
|
},
|
|
5028
5040
|
isFocused: {
|