infinity-ui-elements 1.8.11 → 1.8.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 +1 -0
- package/dist/components/SearchableDropdown/SearchableDropdown.stories.d.ts.map +1 -1
- package/dist/index.esm.js +15 -9
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +15 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3214,7 +3214,7 @@ const defaultFilter = (item, query) => {
|
|
|
3214
3214
|
return (item.label.toLowerCase().includes(searchQuery) ||
|
|
3215
3215
|
(item.description?.toLowerCase().includes(searchQuery) ?? false));
|
|
3216
3216
|
};
|
|
3217
|
-
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, containerClassName, ...textFieldProps }, ref) => {
|
|
3217
|
+
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, onAddNew, containerClassName, ...textFieldProps }, ref) => {
|
|
3218
3218
|
const [uncontrolledSearchValue, setUncontrolledSearchValue] = React__namespace.useState(defaultSearchValue);
|
|
3219
3219
|
const [isOpen, setIsOpen] = React__namespace.useState(false);
|
|
3220
3220
|
const [focusedIndex, setFocusedIndex] = React__namespace.useState(-1);
|
|
@@ -3281,16 +3281,21 @@ const SearchableDropdown = React__namespace.forwardRef(({ className, items = [],
|
|
|
3281
3281
|
}
|
|
3282
3282
|
const addNewItem = {
|
|
3283
3283
|
value: searchValue,
|
|
3284
|
-
label: `+ Add ${searchValue}`,
|
|
3284
|
+
label: `+ Add "${searchValue}"`,
|
|
3285
3285
|
variant: "primary",
|
|
3286
3286
|
onClick: () => {
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3287
|
+
if (onAddNew) {
|
|
3288
|
+
onAddNew(searchValue);
|
|
3289
|
+
}
|
|
3290
|
+
else {
|
|
3291
|
+
const newItem = {
|
|
3292
|
+
value: searchValue,
|
|
3293
|
+
label: searchValue,
|
|
3294
|
+
};
|
|
3295
|
+
onItemSelect?.(newItem);
|
|
3296
|
+
if (controlledSearchValue === undefined) {
|
|
3297
|
+
setUncontrolledSearchValue(searchValue);
|
|
3298
|
+
}
|
|
3294
3299
|
}
|
|
3295
3300
|
setIsOpen(false);
|
|
3296
3301
|
inputRef.current?.focus();
|
|
@@ -3302,6 +3307,7 @@ const SearchableDropdown = React__namespace.forwardRef(({ className, items = [],
|
|
|
3302
3307
|
searchValue,
|
|
3303
3308
|
filteredItems,
|
|
3304
3309
|
onItemSelect,
|
|
3310
|
+
onAddNew,
|
|
3305
3311
|
controlledSearchValue,
|
|
3306
3312
|
]);
|
|
3307
3313
|
// Reset focused index when items change
|