@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/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +12 -0
- package/dist/esm/index.js +67 -39
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +84 -55
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/Autocomplete/Autocomplete.stories.tsx +29 -0
- package/src/Autocomplete/AutocompleteSelect.tsx +24 -0
- package/src/Autocomplete/SingleAutocomplete.tsx +1 -1
- package/src/Autocomplete/index.ts +1 -0
- package/src/MenuContent/styles.tsx +5 -1
- package/src/NestedMenu/NestedMenu.stories.tsx +16 -8
- package/src/NestedMenu/NestedMenuItem.tsx +11 -8
package/package.json
CHANGED
|
@@ -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
|
+
};
|
|
@@ -153,14 +153,22 @@ export const NestedMenuMultiLevelStory: Story = {
|
|
|
153
153
|
render: (args) => {
|
|
154
154
|
return (
|
|
155
155
|
<MotionConfig reducedMotion="user">
|
|
156
|
-
<
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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 =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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}>
|