@sproutsocial/seeds-react-menu 1.2.2 → 1.2.3
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/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +6 -0
- package/dist/esm/index.js +35 -29
- package/dist/esm/index.js.map +1 -1
- package/dist/index.js +64 -57
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/Autocomplete/MultiAutocomplete.tsx +26 -18
- package/src/Autocomplete/SingleAutocomplete.tsx +18 -6
- package/src/MenuRoot/MenuRoot.tsx +0 -7
package/.turbo/turbo-build.log
CHANGED
|
@@ -84,14 +84,14 @@ ESM Build start
|
|
|
84
84
|
╵ [32m~~~~~~~~~[0m
|
|
85
85
|
|
|
86
86
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
87
|
+
ESM dist/esm/index.js 131.72 KB
|
|
88
|
+
ESM dist/esm/index.js.map 364.88 KB
|
|
89
|
+
ESM ⚡️ Build success in 550ms
|
|
90
|
+
CJS dist/index.js 141.25 KB
|
|
91
|
+
CJS dist/index.js.map 366.13 KB
|
|
92
|
+
CJS ⚡️ Build success in 555ms
|
|
93
93
|
DTS Build start
|
|
94
|
-
DTS ⚡️ Build success in
|
|
94
|
+
DTS ⚡️ Build success in 15567ms
|
|
95
95
|
DTS dist/index.d.ts 36.84 KB
|
|
96
96
|
DTS dist/index.d.mts 36.84 KB
|
|
97
|
-
Done in
|
|
97
|
+
Done in 17.81s.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @sproutsocial/seeds-react-menu
|
|
2
2
|
|
|
3
|
+
## 1.2.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 68254a6: Fixed issue where Menus using the MenuSearchInput automatically closed when the results were empty. They now remain open when no match is found.
|
|
8
|
+
|
|
3
9
|
## 1.2.2
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/esm/index.js
CHANGED
|
@@ -2549,7 +2549,6 @@ MenuGroup.__MENU_PRIMITIVE_TYPE = "MenuGroup";
|
|
|
2549
2549
|
// src/MenuRoot/MenuRoot.tsx
|
|
2550
2550
|
import React7, {
|
|
2551
2551
|
useCallback as useCallback2,
|
|
2552
|
-
useEffect,
|
|
2553
2552
|
useLayoutEffect
|
|
2554
2553
|
} from "react";
|
|
2555
2554
|
import styled7 from "styled-components";
|
|
@@ -2656,12 +2655,6 @@ var MenuRoot = ({
|
|
|
2656
2655
|
setFinalWidth(min_width);
|
|
2657
2656
|
}
|
|
2658
2657
|
}, [width2, toggleElementRef.current?.offsetWidth]);
|
|
2659
|
-
useEffect(() => {
|
|
2660
|
-
if (!inputValue) return;
|
|
2661
|
-
if (items && hiddenItemsCount >= items.length && isOpen) {
|
|
2662
|
-
closeMenu?.();
|
|
2663
|
-
}
|
|
2664
|
-
}, [hiddenItemsCount, items?.length, isOpen, inputValue]);
|
|
2665
2658
|
const menuContext = useMenu(contextProps);
|
|
2666
2659
|
getMenuProps?.({}, { suppressRefError: true });
|
|
2667
2660
|
return /* @__PURE__ */ jsx10(
|
|
@@ -3621,6 +3614,7 @@ var MultiSelectMenu = ({
|
|
|
3621
3614
|
import "react";
|
|
3622
3615
|
|
|
3623
3616
|
// src/Autocomplete/SingleAutocomplete.tsx
|
|
3617
|
+
import React18 from "react";
|
|
3624
3618
|
import { useCombobox as useCombobox2 } from "downshift";
|
|
3625
3619
|
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
3626
3620
|
var SingleAutocomplete = ({
|
|
@@ -3638,14 +3632,15 @@ var SingleAutocomplete = ({
|
|
|
3638
3632
|
menuItems,
|
|
3639
3633
|
MenuItemComponent
|
|
3640
3634
|
});
|
|
3641
|
-
const
|
|
3635
|
+
const downshiftDefaults = useDownshiftDefaults({ isCombobox: true });
|
|
3636
|
+
const { setHiddenItemsMap, defaultDownshiftProps, hiddenItemsCount } = downshiftDefaults;
|
|
3642
3637
|
const { updateFilteredItems } = useItemFiltering({
|
|
3643
3638
|
allMenuItems,
|
|
3644
3639
|
itemToString: itemToString2,
|
|
3645
3640
|
getIsItemVisible,
|
|
3646
3641
|
setHiddenItemsMap
|
|
3647
3642
|
});
|
|
3648
|
-
const
|
|
3643
|
+
const useComboboxReturnProps = useCombobox2({
|
|
3649
3644
|
...defaultDownshiftProps.combobox,
|
|
3650
3645
|
items: allMenuItems,
|
|
3651
3646
|
itemToString: itemToString2,
|
|
@@ -3656,6 +3651,13 @@ var SingleAutocomplete = ({
|
|
|
3656
3651
|
),
|
|
3657
3652
|
...useComboboxProps
|
|
3658
3653
|
});
|
|
3654
|
+
const { isOpen, closeMenu, inputValue } = useComboboxReturnProps;
|
|
3655
|
+
React18.useEffect(() => {
|
|
3656
|
+
if (!inputValue) return;
|
|
3657
|
+
if (allMenuItems && hiddenItemsCount >= allMenuItems.length && isOpen) {
|
|
3658
|
+
closeMenu?.();
|
|
3659
|
+
}
|
|
3660
|
+
}, [hiddenItemsCount, allMenuItems?.length, isOpen, inputValue]);
|
|
3659
3661
|
return /* @__PURE__ */ jsx21(
|
|
3660
3662
|
MenuRootComponent,
|
|
3661
3663
|
{
|
|
@@ -3663,11 +3665,9 @@ var SingleAutocomplete = ({
|
|
|
3663
3665
|
isListbox: true,
|
|
3664
3666
|
items: allMenuItems,
|
|
3665
3667
|
itemToString: itemToString2,
|
|
3666
|
-
isOpen,
|
|
3667
|
-
setHiddenItemsMap,
|
|
3668
3668
|
...useComboboxProps,
|
|
3669
3669
|
...useComboboxReturnProps,
|
|
3670
|
-
...
|
|
3670
|
+
...downshiftDefaults
|
|
3671
3671
|
},
|
|
3672
3672
|
popoutProps: {
|
|
3673
3673
|
focusOnContent: false
|
|
@@ -3678,7 +3678,7 @@ var SingleAutocomplete = ({
|
|
|
3678
3678
|
};
|
|
3679
3679
|
|
|
3680
3680
|
// src/Autocomplete/MultiAutocomplete.tsx
|
|
3681
|
-
import
|
|
3681
|
+
import React19 from "react";
|
|
3682
3682
|
import { useCombobox as useCombobox3, useMultipleSelection as useMultipleSelection2 } from "downshift";
|
|
3683
3683
|
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
3684
3684
|
var MultiAutocomplete = ({
|
|
@@ -3704,21 +3704,21 @@ var MultiAutocomplete = ({
|
|
|
3704
3704
|
menuItems,
|
|
3705
3705
|
MenuItemComponent
|
|
3706
3706
|
});
|
|
3707
|
-
const [selectedItems, setSelectedItems] =
|
|
3708
|
-
const [selectedItemIds, setSelectedItemIds] =
|
|
3709
|
-
const getIsItemVisibleMulti =
|
|
3710
|
-
(item,
|
|
3711
|
-
return (showSelectedItemsInDropdown || !selectedItemIds[item.id]) && getIsItemVisible(item,
|
|
3707
|
+
const [selectedItems, setSelectedItems] = React19.useState(initialSelectedItems);
|
|
3708
|
+
const [selectedItemIds, setSelectedItemIds] = React19.useState(getSelectedItemIds(initialSelectedItems));
|
|
3709
|
+
const getIsItemVisibleMulti = React19.useCallback(
|
|
3710
|
+
(item, inputValue2) => {
|
|
3711
|
+
return (showSelectedItemsInDropdown || !selectedItemIds[item.id]) && getIsItemVisible(item, inputValue2);
|
|
3712
3712
|
},
|
|
3713
3713
|
[selectedItemIds, showSelectedItemsInDropdown, getIsItemVisible]
|
|
3714
3714
|
);
|
|
3715
|
-
const getShouldFilterMulti =
|
|
3715
|
+
const getShouldFilterMulti = React19.useCallback(
|
|
3716
3716
|
(args) => {
|
|
3717
3717
|
return !showSelectedItemsInDropdown && Object.keys(selectedItemIds).length > 0 || defaultGetShouldFilter(args);
|
|
3718
3718
|
},
|
|
3719
3719
|
[selectedItemIds, showSelectedItemsInDropdown, getIsItemVisible]
|
|
3720
3720
|
);
|
|
3721
|
-
const
|
|
3721
|
+
const downshiftDefaults = useDownshiftDefaults({
|
|
3722
3722
|
isCombobox: true,
|
|
3723
3723
|
isMulti: true,
|
|
3724
3724
|
// handles the prop name mapping for multi select
|
|
@@ -3729,6 +3729,7 @@ var MultiAutocomplete = ({
|
|
|
3729
3729
|
...useComboboxProps
|
|
3730
3730
|
}
|
|
3731
3731
|
});
|
|
3732
|
+
const { setHiddenItemsMap, defaultDownshiftProps, hiddenItemsCount } = downshiftDefaults;
|
|
3732
3733
|
const { updateFilteredItems } = useItemFiltering({
|
|
3733
3734
|
allMenuItems,
|
|
3734
3735
|
itemToString: itemToString2,
|
|
@@ -3736,7 +3737,7 @@ var MultiAutocomplete = ({
|
|
|
3736
3737
|
getShouldFilter: getShouldFilterMulti,
|
|
3737
3738
|
setHiddenItemsMap
|
|
3738
3739
|
});
|
|
3739
|
-
|
|
3740
|
+
React19.useEffect(() => {
|
|
3740
3741
|
updateFilteredItems({ inputValue: "" });
|
|
3741
3742
|
}, [selectedItemIds]);
|
|
3742
3743
|
const useMultipleSelectionReturnProps = useMultipleSelection2({
|
|
@@ -3749,7 +3750,7 @@ var MultiAutocomplete = ({
|
|
|
3749
3750
|
onSelectedItemsChange && onSelectedItemsChange({ selectedItems: selectedItems2, ...changes });
|
|
3750
3751
|
}
|
|
3751
3752
|
});
|
|
3752
|
-
const
|
|
3753
|
+
const useComboboxReturnProps = useCombobox3({
|
|
3753
3754
|
...defaultDownshiftProps.combobox,
|
|
3754
3755
|
items: allMenuItems,
|
|
3755
3756
|
itemToString: itemToString2,
|
|
@@ -3759,7 +3760,7 @@ var MultiAutocomplete = ({
|
|
|
3759
3760
|
externalStateReducer
|
|
3760
3761
|
),
|
|
3761
3762
|
onStateChange(changes) {
|
|
3762
|
-
const { type, selectedItem: newSelectedItem, inputValue } = changes;
|
|
3763
|
+
const { type, selectedItem: newSelectedItem, inputValue: inputValue2 } = changes;
|
|
3763
3764
|
switch (type) {
|
|
3764
3765
|
// Add the selected item to the selected items list
|
|
3765
3766
|
case useCombobox3.stateChangeTypes.InputKeyDownEnter:
|
|
@@ -3780,11 +3781,18 @@ var MultiAutocomplete = ({
|
|
|
3780
3781
|
default:
|
|
3781
3782
|
break;
|
|
3782
3783
|
}
|
|
3783
|
-
if (
|
|
3784
|
+
if (inputValue2 !== void 0) updateFilteredItems({ inputValue: inputValue2 });
|
|
3784
3785
|
onStateChange && onStateChange(changes);
|
|
3785
3786
|
},
|
|
3786
3787
|
...useComboboxProps
|
|
3787
3788
|
});
|
|
3789
|
+
const { isOpen, closeMenu, inputValue } = useComboboxReturnProps;
|
|
3790
|
+
React19.useEffect(() => {
|
|
3791
|
+
if (!inputValue) return;
|
|
3792
|
+
if (allMenuItems && hiddenItemsCount >= allMenuItems.length && isOpen) {
|
|
3793
|
+
closeMenu?.();
|
|
3794
|
+
}
|
|
3795
|
+
}, [hiddenItemsCount, allMenuItems?.length, isOpen, inputValue]);
|
|
3788
3796
|
return /* @__PURE__ */ jsx22(
|
|
3789
3797
|
MenuRootComponent,
|
|
3790
3798
|
{
|
|
@@ -3792,18 +3800,16 @@ var MultiAutocomplete = ({
|
|
|
3792
3800
|
isListbox: true,
|
|
3793
3801
|
items: allMenuItems,
|
|
3794
3802
|
itemToString: itemToString2,
|
|
3795
|
-
isOpen,
|
|
3796
3803
|
initialSelectedItems,
|
|
3797
3804
|
onStateChange,
|
|
3798
3805
|
onSelectedItemsChange,
|
|
3799
3806
|
getA11yMultiStatusMessage,
|
|
3800
3807
|
onMultiSelectStateChange,
|
|
3801
3808
|
multiSelectStateReducer,
|
|
3802
|
-
setHiddenItemsMap,
|
|
3803
3809
|
...useComboboxProps,
|
|
3804
3810
|
...useComboboxReturnProps,
|
|
3805
3811
|
...useMultipleSelectionReturnProps,
|
|
3806
|
-
...
|
|
3812
|
+
...downshiftDefaults
|
|
3807
3813
|
},
|
|
3808
3814
|
popoutProps: {
|
|
3809
3815
|
focusOnContent: false
|
|
@@ -4107,7 +4113,7 @@ var NestedMenuHeader = ({
|
|
|
4107
4113
|
};
|
|
4108
4114
|
|
|
4109
4115
|
// src/NestedMenu/NestedMenuRoot.tsx
|
|
4110
|
-
import
|
|
4116
|
+
import React24 from "react";
|
|
4111
4117
|
import { jsx as jsx31 } from "react/jsx-runtime";
|
|
4112
4118
|
var NestedMenuRoot = ({
|
|
4113
4119
|
children,
|
|
@@ -4116,7 +4122,7 @@ var NestedMenuRoot = ({
|
|
|
4116
4122
|
}) => {
|
|
4117
4123
|
const menuContext = useMenu(contextProps);
|
|
4118
4124
|
const { setActiveMenuContext, selectedMenuPath } = useNestedMenuContext();
|
|
4119
|
-
|
|
4125
|
+
React24.useEffect(() => {
|
|
4120
4126
|
setActiveMenuContext(menuContext);
|
|
4121
4127
|
}, [
|
|
4122
4128
|
selectedMenuPath[selectedMenuPath.length - 1],
|