@sproutsocial/seeds-react-menu 1.10.8 → 1.11.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 +21 -15
- package/CHANGELOG.md +22 -0
- package/dist/esm/index.js +45 -24
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/v2/index.js +1 -1
- package/dist/esm/v2/index.js.map +1 -1
- package/dist/esm/v3/index.js +800 -0
- package/dist/esm/v3/index.js.map +1 -0
- package/dist/index.d.mts +22 -22
- package/dist/index.d.ts +22 -22
- package/dist/index.js +35 -14
- package/dist/index.js.map +1 -1
- package/dist/v2/index.js +1 -1
- package/dist/v2/index.js.map +1 -1
- package/dist/v3/index.d.mts +295 -0
- package/dist/v3/index.d.ts +295 -0
- package/dist/v3/index.js +868 -0
- package/dist/v3/index.js.map +1 -0
- package/package.json +7 -1
- package/src/MenuGroup/MenuGroup.tsx +16 -3
- package/src/MenuGroup/__tests__/MenuGroup.test.tsx +19 -0
- package/src/MenuItem/MenuItem.tsx +21 -10
- package/src/MenuItem/__tests__/MenuItem.test.tsx +19 -0
- package/src/v2/Common-V2/ComboboxContent.tsx +1 -1
- package/src/v3/Common/ComboboxItem.tsx +82 -0
- package/src/v3/Common/ComboboxStyles.tsx +475 -0
- package/src/v3/Common/SelectGroup.tsx +28 -0
- package/src/v3/Common/SelectIcons.tsx +26 -0
- package/src/v3/Common/SelectItem.tsx +108 -0
- package/src/v3/Common/SelectStyles.tsx +126 -0
- package/src/v3/Common/VirtualizedComboboxList.tsx +200 -0
- package/src/v3/Common/groupItems.ts +12 -0
- package/src/v3/Common/types.ts +3 -0
- package/src/v3/ModalStories.stories.tsx +181 -0
- package/src/v3/MultiCombobox.stories.tsx +322 -0
- package/src/v3/MultiCombobox.tsx +562 -0
- package/src/v3/MultiSearchableSelect.stories.tsx +389 -0
- package/src/v3/MultiSearchableSelect.tsx +545 -0
- package/src/v3/MultiSelect.stories.tsx +300 -0
- package/src/v3/MultiSelect.tsx +498 -0
- package/src/v3/SeedsPortal.tsx +35 -0
- package/src/v3/SingleCombobox.stories.tsx +169 -0
- package/src/v3/SingleCombobox.tsx +304 -0
- package/src/v3/SingleSearchableSelect.stories.tsx +239 -0
- package/src/v3/SingleSearchableSelect.tsx +319 -0
- package/src/v3/SingleSelect.stories.tsx +227 -0
- package/src/v3/SingleSelect.tsx +245 -0
- package/src/v3/index.ts +7 -0
- package/src/v3/storyData.tsx +117 -0
- package/tsup.config.ts +1 -0
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
|
+
import { FormField } from "@sproutsocial/seeds-react-form-field";
|
|
4
|
+
import MultiSelect from "./MultiSelect";
|
|
5
|
+
import SelectItem from "./Common/SelectItem";
|
|
6
|
+
import SelectGroup from "./Common/SelectGroup";
|
|
7
|
+
import { books, itemToString, renderItem } from "./storyData";
|
|
8
|
+
|
|
9
|
+
const meta: Meta<typeof MultiSelect> = {
|
|
10
|
+
title: "Really Under Development/V3/Multi Select",
|
|
11
|
+
component: MultiSelect,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default meta;
|
|
15
|
+
type Story = StoryObj<typeof MultiSelect>;
|
|
16
|
+
|
|
17
|
+
export const Basic: Story = {
|
|
18
|
+
name: "Basic",
|
|
19
|
+
render: () => (
|
|
20
|
+
<div style={{ width: "300px" }}>
|
|
21
|
+
<FormField label="Pick books">
|
|
22
|
+
{({ id }) => (
|
|
23
|
+
<MultiSelect
|
|
24
|
+
id={id}
|
|
25
|
+
data={books}
|
|
26
|
+
itemToString={itemToString}
|
|
27
|
+
placeholder="Select books..."
|
|
28
|
+
/>
|
|
29
|
+
)}
|
|
30
|
+
</FormField>
|
|
31
|
+
</div>
|
|
32
|
+
),
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const CustomRenderItem: Story = {
|
|
36
|
+
name: "Custom render item",
|
|
37
|
+
render: () => (
|
|
38
|
+
<div style={{ width: "300px" }}>
|
|
39
|
+
<FormField label="Pick books">
|
|
40
|
+
{({ id }) => (
|
|
41
|
+
<MultiSelect
|
|
42
|
+
id={id}
|
|
43
|
+
data={books}
|
|
44
|
+
itemToString={itemToString}
|
|
45
|
+
renderItem={renderItem}
|
|
46
|
+
placeholder="Select books..."
|
|
47
|
+
/>
|
|
48
|
+
)}
|
|
49
|
+
</FormField>
|
|
50
|
+
</div>
|
|
51
|
+
),
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const Grouped: Story = {
|
|
55
|
+
name: "Grouped",
|
|
56
|
+
render: () => (
|
|
57
|
+
<div style={{ width: "300px" }}>
|
|
58
|
+
<FormField label="Pick books">
|
|
59
|
+
{({ id }) => (
|
|
60
|
+
<MultiSelect
|
|
61
|
+
id={id}
|
|
62
|
+
data={books}
|
|
63
|
+
itemToString={itemToString}
|
|
64
|
+
renderItem={renderItem}
|
|
65
|
+
placeholder="Select books..."
|
|
66
|
+
groupBy={(book) => book.author}
|
|
67
|
+
/>
|
|
68
|
+
)}
|
|
69
|
+
</FormField>
|
|
70
|
+
</div>
|
|
71
|
+
),
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const DefaultSelected: Story = {
|
|
75
|
+
name: "Default selected",
|
|
76
|
+
render: () => (
|
|
77
|
+
<div style={{ width: "300px" }}>
|
|
78
|
+
<FormField label="Pick books">
|
|
79
|
+
{({ id }) => (
|
|
80
|
+
<MultiSelect
|
|
81
|
+
id={id}
|
|
82
|
+
data={books}
|
|
83
|
+
itemToString={itemToString}
|
|
84
|
+
renderItem={renderItem}
|
|
85
|
+
placeholder="Select books..."
|
|
86
|
+
defaultSelectedItemIds={["book-1", "book-3"]}
|
|
87
|
+
/>
|
|
88
|
+
)}
|
|
89
|
+
</FormField>
|
|
90
|
+
</div>
|
|
91
|
+
),
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export const Controlled: Story = {
|
|
95
|
+
name: "Controlled",
|
|
96
|
+
render: () => {
|
|
97
|
+
const [selectedIds, setSelectedIds] = React.useState<string[]>(["book-2"]);
|
|
98
|
+
const selected = books.filter((b) => selectedIds.includes(b.id));
|
|
99
|
+
return (
|
|
100
|
+
<div
|
|
101
|
+
style={{
|
|
102
|
+
width: "300px",
|
|
103
|
+
display: "flex",
|
|
104
|
+
flexDirection: "column",
|
|
105
|
+
gap: 16,
|
|
106
|
+
}}
|
|
107
|
+
>
|
|
108
|
+
<FormField label="Pick books">
|
|
109
|
+
{({ id }) => (
|
|
110
|
+
<MultiSelect
|
|
111
|
+
id={id}
|
|
112
|
+
data={books}
|
|
113
|
+
itemToString={itemToString}
|
|
114
|
+
renderItem={renderItem}
|
|
115
|
+
placeholder="Select books..."
|
|
116
|
+
selectedItemIds={selectedIds}
|
|
117
|
+
onSelectedItemIdsChange={(ids: string[]) => setSelectedIds(ids)}
|
|
118
|
+
/>
|
|
119
|
+
)}
|
|
120
|
+
</FormField>
|
|
121
|
+
<div style={{ fontSize: 13 }}>
|
|
122
|
+
Selected:{" "}
|
|
123
|
+
<strong>
|
|
124
|
+
{selected.length > 0
|
|
125
|
+
? selected.map((b) => b.title).join(", ")
|
|
126
|
+
: "none"}
|
|
127
|
+
</strong>
|
|
128
|
+
</div>
|
|
129
|
+
<div style={{ display: "flex", gap: 8 }}>
|
|
130
|
+
<button onClick={() => setSelectedIds([])}>Clear all</button>
|
|
131
|
+
<button onClick={() => setSelectedIds(["book-5", "book-7"])}>
|
|
132
|
+
Select 1984 & Meditations
|
|
133
|
+
</button>
|
|
134
|
+
</div>
|
|
135
|
+
</div>
|
|
136
|
+
);
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
export const CustomSelection: Story = {
|
|
141
|
+
name: "Custom renderSelection",
|
|
142
|
+
render: () => (
|
|
143
|
+
<div style={{ width: "300px" }}>
|
|
144
|
+
<FormField label="Pick books">
|
|
145
|
+
{({ id }) => (
|
|
146
|
+
<MultiSelect
|
|
147
|
+
id={id}
|
|
148
|
+
data={books}
|
|
149
|
+
itemToString={itemToString}
|
|
150
|
+
renderItem={renderItem}
|
|
151
|
+
placeholder="Select books..."
|
|
152
|
+
renderSelection={(selected) => {
|
|
153
|
+
if (selected.length === 0)
|
|
154
|
+
return <span style={{ color: "#888" }}>Select books...</span>;
|
|
155
|
+
const first = itemToString(selected[0]);
|
|
156
|
+
const extra =
|
|
157
|
+
selected.length > 1 ? ` (+${selected.length - 1})` : "";
|
|
158
|
+
return (
|
|
159
|
+
<span>
|
|
160
|
+
{first}
|
|
161
|
+
{extra}
|
|
162
|
+
</span>
|
|
163
|
+
);
|
|
164
|
+
}}
|
|
165
|
+
/>
|
|
166
|
+
)}
|
|
167
|
+
</FormField>
|
|
168
|
+
</div>
|
|
169
|
+
),
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
export const CustomToken: Story = {
|
|
173
|
+
name: "Custom renderToken",
|
|
174
|
+
render: () => (
|
|
175
|
+
<div style={{ width: "300px" }}>
|
|
176
|
+
<FormField label="Pick books">
|
|
177
|
+
{({ id }) => (
|
|
178
|
+
<MultiSelect
|
|
179
|
+
id={id}
|
|
180
|
+
data={books}
|
|
181
|
+
itemToString={itemToString}
|
|
182
|
+
renderItem={renderItem}
|
|
183
|
+
placeholder="Select books..."
|
|
184
|
+
renderToken={(item) => (
|
|
185
|
+
<span>
|
|
186
|
+
{item.title}{" "}
|
|
187
|
+
<span style={{ fontSize: "11px", opacity: 0.7 }}>
|
|
188
|
+
({item.author})
|
|
189
|
+
</span>
|
|
190
|
+
</span>
|
|
191
|
+
)}
|
|
192
|
+
/>
|
|
193
|
+
)}
|
|
194
|
+
</FormField>
|
|
195
|
+
</div>
|
|
196
|
+
),
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
export const MaxTokens: Story = {
|
|
200
|
+
name: "Max tokens",
|
|
201
|
+
render: () => (
|
|
202
|
+
<div style={{ width: "300px" }}>
|
|
203
|
+
<FormField label="Pick books">
|
|
204
|
+
{({ id }) => (
|
|
205
|
+
<MultiSelect
|
|
206
|
+
id={id}
|
|
207
|
+
data={books}
|
|
208
|
+
itemToString={itemToString}
|
|
209
|
+
renderItem={renderItem}
|
|
210
|
+
placeholder="Select books..."
|
|
211
|
+
defaultSelectedItemIds={[
|
|
212
|
+
"book-1",
|
|
213
|
+
"book-2",
|
|
214
|
+
"book-3",
|
|
215
|
+
"book-4",
|
|
216
|
+
"book-5",
|
|
217
|
+
]}
|
|
218
|
+
maxTokens={2}
|
|
219
|
+
/>
|
|
220
|
+
)}
|
|
221
|
+
</FormField>
|
|
222
|
+
</div>
|
|
223
|
+
),
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
export const RemoveSelectedItems: Story = {
|
|
227
|
+
name: "Remove selected items",
|
|
228
|
+
render: () => (
|
|
229
|
+
<div style={{ width: "300px" }}>
|
|
230
|
+
<FormField label="Pick books">
|
|
231
|
+
{({ id }) => (
|
|
232
|
+
<MultiSelect
|
|
233
|
+
id={id}
|
|
234
|
+
data={books}
|
|
235
|
+
itemToString={itemToString}
|
|
236
|
+
renderItem={renderItem}
|
|
237
|
+
placeholder="Select books..."
|
|
238
|
+
removeSelectedItems
|
|
239
|
+
/>
|
|
240
|
+
)}
|
|
241
|
+
</FormField>
|
|
242
|
+
</div>
|
|
243
|
+
),
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
export const Children: Story = {
|
|
247
|
+
name: "Children API",
|
|
248
|
+
render: () => (
|
|
249
|
+
<div style={{ width: "300px" }}>
|
|
250
|
+
<FormField label="Pick books">
|
|
251
|
+
{({ id }) => (
|
|
252
|
+
<MultiSelect id={id} placeholder="Select books...">
|
|
253
|
+
<SelectGroup label="Tolstoy" showSeparator>
|
|
254
|
+
<SelectItem
|
|
255
|
+
value="book-2"
|
|
256
|
+
label="War and Peace"
|
|
257
|
+
inputType="checkbox"
|
|
258
|
+
/>
|
|
259
|
+
<SelectItem
|
|
260
|
+
value="book-9"
|
|
261
|
+
label="Anna Karenina"
|
|
262
|
+
inputType="checkbox"
|
|
263
|
+
/>
|
|
264
|
+
</SelectGroup>
|
|
265
|
+
<SelectGroup label="Dostoevsky" showSeparator>
|
|
266
|
+
<SelectItem
|
|
267
|
+
value="book-3"
|
|
268
|
+
label="The Idiot"
|
|
269
|
+
inputType="checkbox"
|
|
270
|
+
/>
|
|
271
|
+
<SelectItem
|
|
272
|
+
value="book-8"
|
|
273
|
+
label="The Brothers Karamazov"
|
|
274
|
+
inputType="checkbox"
|
|
275
|
+
/>
|
|
276
|
+
<SelectItem
|
|
277
|
+
value="book-10"
|
|
278
|
+
label="Crime and Punishment"
|
|
279
|
+
inputType="checkbox"
|
|
280
|
+
/>
|
|
281
|
+
</SelectGroup>
|
|
282
|
+
<SelectGroup label="Other">
|
|
283
|
+
<SelectItem
|
|
284
|
+
value="book-1"
|
|
285
|
+
label="To Kill a Mockingbird"
|
|
286
|
+
inputType="checkbox"
|
|
287
|
+
/>
|
|
288
|
+
<SelectItem value="book-5" label="1984" inputType="checkbox" />
|
|
289
|
+
<SelectItem
|
|
290
|
+
value="book-7"
|
|
291
|
+
label="Meditations"
|
|
292
|
+
inputType="checkbox"
|
|
293
|
+
/>
|
|
294
|
+
</SelectGroup>
|
|
295
|
+
</MultiSelect>
|
|
296
|
+
)}
|
|
297
|
+
</FormField>
|
|
298
|
+
</div>
|
|
299
|
+
),
|
|
300
|
+
};
|