@sproutsocial/seeds-react-menu 1.1.1 → 1.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sproutsocial/seeds-react-menu",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "description": "Seeds React Menu",
5
5
  "author": "Sprout Social, Inc.",
6
6
  "license": "MIT",
@@ -12,6 +12,7 @@ import {
12
12
  MenuLabel,
13
13
  MenuToggleButton,
14
14
  type TypeInternalItemProps,
15
+ AutocompleteSelect,
15
16
  } from "../index";
16
17
  // eslint-disable-next-line no-restricted-imports
17
18
  import { TEST_BOOKS } from "../__fixtures__/menu-test-data";
@@ -161,6 +162,34 @@ export const AutocompleteTokenInputExample: Story = {
161
162
  },
162
163
  };
163
164
 
165
+ export const AutocompleteSelectExample: Story = {
166
+ name: "Autocomplete Select",
167
+ render: (args) => {
168
+ return (
169
+ <Autocomplete
170
+ itemToString={(item) => (item ? TEST_BOOKS[item.index].title : "")}
171
+ menuToggleElement={
172
+ <>
173
+ <MenuLabel htmlFor="my-combobox" mb={300}>
174
+ Choose a book
175
+ </MenuLabel>
176
+ <AutocompleteSelect />
177
+ </>
178
+ }
179
+ {...(args as object)}
180
+ >
181
+ <MenuContent>
182
+ {TEST_BOOKS.map(({ id, title }) => (
183
+ <MenuItem key={id} id={id}>
184
+ {title}
185
+ </MenuItem>
186
+ ))}
187
+ </MenuContent>
188
+ </Autocomplete>
189
+ );
190
+ },
191
+ };
192
+
164
193
  const TestControlledSingleAutocomplete = ({
165
194
  ...args
166
195
  }: CustomAutocompleteArgs) => {
@@ -0,0 +1,24 @@
1
+ import Icon from "@sproutsocial/seeds-react-icon";
2
+ import React from "react";
3
+
4
+ import {
5
+ AutocompleteInput,
6
+ type TypeAutocompleteInputProps,
7
+ } from "./AutocompleteInput";
8
+ import styled from "styled-components";
9
+ import { Accessory } from "@sproutsocial/seeds-react-input";
10
+
11
+ const StyledAutocompleteInput = styled(AutocompleteInput)`
12
+ ${Accessory} {
13
+ pointer-events: none;
14
+ }
15
+ `;
16
+
17
+ export const AutocompleteSelect = (props: TypeAutocompleteInputProps) => {
18
+ return (
19
+ <StyledAutocompleteInput
20
+ elemAfter={<Icon name="chevron-down" />}
21
+ {...props}
22
+ />
23
+ );
24
+ };
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import React, { useEffect } from "react";
2
2
  import { useCombobox } from "downshift";
3
3
  import { useMenuChildren } from "../hooks/useMenuChildren";
4
4
  import { itemToString as defaultItemToString } from "../utils/downshiftDefaults";
@@ -2,3 +2,4 @@ export * from "./Autocomplete";
2
2
  export * from "./AutocompleteInput";
3
3
  export * from "./AutocompleteTokenInput";
4
4
  export * from "./AutocompleteTypes";
5
+ export * from "./AutocompleteSelect";
@@ -3,5 +3,9 @@ import styled from "styled-components";
3
3
  export const StyledMenuContent = styled.ul`
4
4
  margin: 0;
5
5
  padding: 0;
6
- outline: none;
6
+
7
+ &:focus {
8
+ outline: none;
9
+ box-shadow: none;
10
+ }
7
11
  `;
@@ -153,14 +153,22 @@ export const NestedMenuMultiLevelStory: Story = {
153
153
  render: (args) => {
154
154
  return (
155
155
  <MotionConfig reducedMotion="user">
156
- <NestedMenu
157
- initialMenuId="root"
158
- menus={menus}
159
- backArrowLabel="Go Back"
160
- menuToggleElement={
161
- <MenuToggleButton width="200px">Open Menu</MenuToggleButton>
162
- }
163
- />
156
+ <Box
157
+ display="flex"
158
+ alignItems="center"
159
+ justifyContent="center"
160
+ height="100vh"
161
+ width="100vw"
162
+ >
163
+ <NestedMenu
164
+ initialMenuId="root"
165
+ menus={menus}
166
+ backArrowLabel="Go Back"
167
+ menuToggleElement={
168
+ <MenuToggleButton width="200px">Open Menu</MenuToggleButton>
169
+ }
170
+ />
171
+ </Box>
164
172
  </MotionConfig>
165
173
  );
166
174
  },
@@ -13,14 +13,17 @@ const NestedMenuItem = ({
13
13
  const { setSelectedMenuId } = useNestedMenuContext();
14
14
  // This method of passing onClick is necessary because passing undefined for onClick
15
15
  // behaves differently from not passing anything at all.
16
- const onClickProps = childMenuId
17
- ? {
18
- onClick: (e) => {
19
- onClickProp?.(e);
20
- setSelectedMenuId?.(childMenuId);
21
- },
22
- }
23
- : {};
16
+ const onClickProps =
17
+ childMenuId || onClickProp
18
+ ? {
19
+ onClick: (e) => {
20
+ onClickProp?.(e);
21
+ if (childMenuId) {
22
+ setSelectedMenuId?.(childMenuId);
23
+ }
24
+ },
25
+ }
26
+ : {};
24
27
 
25
28
  return (
26
29
  <MenuItem {...onClickProps} {...rest}>