@sproutsocial/seeds-react-menu 0.2.2 → 0.3.0
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 +10 -10
- package/CHANGELOG.md +18 -0
- package/dist/esm/index.js +18 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +70 -43
- package/dist/index.d.ts +70 -43
- package/dist/index.js +18 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/ActionMenu/ActionMenu.tsx +2 -16
- package/src/ActionMenu/ActionMenuTypes.ts +12 -0
- package/src/ActionMenu/index.ts +1 -0
- package/src/{ComboBox/ComboBox.feature → Autocomplete/Autocomplete.feature} +16 -16
- package/src/Autocomplete/Autocomplete.tsx +65 -0
- package/src/Autocomplete/AutocompleteTypes.ts +8 -0
- package/src/Autocomplete/__tests__/Autocomplete.test.tsx +113 -0
- package/src/Autocomplete/__tests__/Autocomplete.typetest.tsx +78 -0
- package/src/Autocomplete/index.ts +2 -0
- package/src/MenuContent/MenuContent.tsx +3 -3
- package/src/MenuContext.tsx +65 -9
- package/src/MenuGroup/MenuGroup.feature +15 -15
- package/src/MenuGroup/MenuGroup.tsx +6 -2
- package/src/MenuGroup/MenuGroupTypes.ts +2 -0
- package/src/MenuGroup/__tests__/MenuGroup.test.tsx +144 -9
- package/src/MenuGroup/__tests__/MenuGroup.typetest.tsx +24 -12
- package/src/MenuItem/MenuItem.tsx +1 -1
- package/src/MenuItem/__tests__/MenuItem.test.tsx +4 -1
- package/src/MenuRoot/__tests__/MenuRoot.test.tsx +1 -1
- package/src/MultiSelectMenu/MultiSelectMenu.tsx +8 -0
- package/src/MultiSelectMenu/MultiSelectMenuTypes.ts +5 -1
- package/src/MultiSelectMenu/__tests__/MultiSelectMenu.test.tsx +6 -8
- package/src/MultiSelectMenu/index.ts +1 -0
- package/src/SingleSelectMenu/SingleSelectMenuTypes.ts +2 -3
- package/src/SingleSelectMenu/__tests__/SingleSelectMenu.test.tsx +3 -3
- package/src/hooks/useItemsFromChildren.tsx +12 -5
- package/src/reducers/useComboboxStateReducer.tsx +26 -0
- package/src/types.ts +2 -0
- package/src/ComboBox/TokenInput.feature +0 -84
package/.turbo/turbo-build.log
CHANGED
|
@@ -8,14 +8,14 @@ CLI Target: es2022
|
|
|
8
8
|
CLI Cleaning output folder
|
|
9
9
|
CJS Build start
|
|
10
10
|
ESM Build start
|
|
11
|
-
ESM dist/esm/index.js 80.
|
|
12
|
-
ESM dist/esm/index.js.map
|
|
13
|
-
ESM ⚡️ Build success in
|
|
14
|
-
CJS dist/index.js 85.
|
|
15
|
-
CJS dist/index.js.map
|
|
16
|
-
CJS ⚡️ Build success in
|
|
11
|
+
ESM dist/esm/index.js 80.99 KB
|
|
12
|
+
ESM dist/esm/index.js.map 254.93 KB
|
|
13
|
+
ESM ⚡️ Build success in 542ms
|
|
14
|
+
CJS dist/index.js 85.59 KB
|
|
15
|
+
CJS dist/index.js.map 255.79 KB
|
|
16
|
+
CJS ⚡️ Build success in 566ms
|
|
17
17
|
DTS Build start
|
|
18
|
-
DTS ⚡️ Build success in
|
|
19
|
-
DTS dist/index.d.ts
|
|
20
|
-
DTS dist/index.d.mts
|
|
21
|
-
Done in
|
|
18
|
+
DTS ⚡️ Build success in 15441ms
|
|
19
|
+
DTS dist/index.d.ts 15.86 KB
|
|
20
|
+
DTS dist/index.d.mts 15.86 KB
|
|
21
|
+
Done in 19.62s.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @sproutsocial/seeds-react-menu
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 1178353: Implements isSingleSelect prop on MenuGroup
|
|
8
|
+
- This prop allows you to specify that only one item in the MenuGroup can be selected at a time.
|
|
9
|
+
- This prop is necessary if you need to combine multiple single-select MenuGroups or a mix of single-select and multi-select MenuGroups within a single Menu.
|
|
10
|
+
- In this case, you should use MultiSelectMenu and set isSingleSelect to true on the MenuGroup(s) that should only allow one selection.
|
|
11
|
+
- By contrast, the SingleSelectMenu component only allows one item to be selected across all MenuGroups.
|
|
12
|
+
- If you only have one MenuGroup, or if you only want to allow a single selection across all MenuGroups, you should use SingleSelectMenu instead.
|
|
13
|
+
- SingleSelectMenu ignores the `isSingleSelect` prop on MenuGroup.
|
|
14
|
+
|
|
15
|
+
## 0.2.3
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 753d7c9: Fix various ts issues for Menu.Item, Collapsible, and VisuallyHidden
|
|
20
|
+
|
|
3
21
|
## 0.2.2
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/esm/index.js
CHANGED
|
@@ -1900,12 +1900,12 @@ var MenuItem = ({
|
|
|
1900
1900
|
...props
|
|
1901
1901
|
}) => {
|
|
1902
1902
|
const { getItemProps, itemsMap, highlightedIndex, isListbox } = useContext3(MenuContext);
|
|
1903
|
+
const item = itemsMap[id] || { index: 0, id };
|
|
1903
1904
|
const { ...optionProps } = useOptionProps({
|
|
1904
1905
|
id,
|
|
1905
1906
|
children,
|
|
1906
1907
|
...props
|
|
1907
1908
|
});
|
|
1908
|
-
const item = itemsMap[id] || { index: 0, id };
|
|
1909
1909
|
const highlighted = highlightedIndex === item?.index;
|
|
1910
1910
|
return /* @__PURE__ */ jsx3(MenuItemContainer, { role: "none", children: /* @__PURE__ */ jsx3(
|
|
1911
1911
|
StyledMenuItem,
|
|
@@ -2038,7 +2038,7 @@ var MenuContent = ({
|
|
|
2038
2038
|
autoFocus: true,
|
|
2039
2039
|
id,
|
|
2040
2040
|
tabIndex: 0,
|
|
2041
|
-
onKeyDown: getToggleButtonProps?.()
|
|
2041
|
+
onKeyDown: getToggleButtonProps?.()["onKeyDown"] || void 0,
|
|
2042
2042
|
"aria-activedescendant": getToggleButtonProps?.()["aria-activedescendant"],
|
|
2043
2043
|
...getMenuProps?.(
|
|
2044
2044
|
{
|
|
@@ -2225,6 +2225,8 @@ var MenuGroup = ({
|
|
|
2225
2225
|
children,
|
|
2226
2226
|
title,
|
|
2227
2227
|
color: color2,
|
|
2228
|
+
isSingleSelect,
|
|
2229
|
+
id,
|
|
2228
2230
|
...rest
|
|
2229
2231
|
}) => {
|
|
2230
2232
|
const titleId = `menu-group-title-${Math.random().toString(36).slice(2, 11)}`;
|
|
@@ -2232,6 +2234,8 @@ var MenuGroup = ({
|
|
|
2232
2234
|
StyledMenuGroup,
|
|
2233
2235
|
{
|
|
2234
2236
|
role: "group",
|
|
2237
|
+
id,
|
|
2238
|
+
isSingleSelect,
|
|
2235
2239
|
"aria-labelledby": title ? titleId : void 0,
|
|
2236
2240
|
color: color2,
|
|
2237
2241
|
...rest,
|
|
@@ -2365,12 +2369,16 @@ var useItemsFromChildren = ({
|
|
|
2365
2369
|
const allMenuItemElements = getAllMenuItems(children);
|
|
2366
2370
|
const menuItemsMap2 = {};
|
|
2367
2371
|
const allMenuItems2 = allMenuItemElements.map(
|
|
2368
|
-
({ element }, index) => {
|
|
2372
|
+
({ element, parents }, index) => {
|
|
2373
|
+
const parentMenuGroup = parents.find(
|
|
2374
|
+
(parent) => checkIfIsElement(parent, "MenuGroup")
|
|
2375
|
+
);
|
|
2369
2376
|
const item = {
|
|
2370
2377
|
id: element.props.id,
|
|
2371
2378
|
disabled: element.props.disabled,
|
|
2372
2379
|
index,
|
|
2373
|
-
menuItemProps: element.props
|
|
2380
|
+
menuItemProps: element.props,
|
|
2381
|
+
menuGroupProps: parentMenuGroup ? parentMenuGroup.props : void 0
|
|
2374
2382
|
};
|
|
2375
2383
|
menuItemsMap2[`${item.id}`] = item;
|
|
2376
2384
|
return item;
|
|
@@ -2604,6 +2612,12 @@ var MultiSelectMenu = ({
|
|
|
2604
2612
|
} else {
|
|
2605
2613
|
addSelectedItem(newSelectedItem);
|
|
2606
2614
|
}
|
|
2615
|
+
if (newSelectedItem.menuGroupProps?.isSingleSelect) {
|
|
2616
|
+
const groupItems = selectedItems.filter(
|
|
2617
|
+
(item) => item.menuGroupProps?.id === newSelectedItem.menuGroupProps?.id
|
|
2618
|
+
);
|
|
2619
|
+
groupItems.forEach((item) => removeSelectedItem(item));
|
|
2620
|
+
}
|
|
2607
2621
|
break;
|
|
2608
2622
|
default:
|
|
2609
2623
|
break;
|