This repository was archived by the owner on Feb 10, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMultipleSelect.stories.tsx
172 lines (161 loc) · 3.98 KB
/
MultipleSelect.stories.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
import { action } from "@storybook/addon-actions";
import type { Meta, StoryObj } from "@storybook/react";
import { MultipleSelect } from "./MultipleSelect";
const onChange = action("onChange");
const meta = {
title: "Components/MultipleSelect",
component: MultipleSelect,
parameters: {
layout: "centered",
},
} satisfies Meta<typeof MultipleSelect>;
export default meta;
type Story = StoryObj<typeof MultipleSelect>;
// Basic example with single group
export const Basic: Story = {
args: {
options: [
{
items: [
{ value: "1", label: "Option 1" },
{ value: "2", label: "Option 2" },
{ value: "3", label: "Option 3" },
],
},
],
placeholder: "Select options",
onChange: (values) => onChange(values),
},
};
// Example with exclusive options (like order by)
export const OrderByExample: Story = {
args: {
options: [
{
groupLabel: "ORDER BY TIME",
multiple: false,
items: ["Recent", "Oldest"].map((value) => ({
label: value,
value,
exclusive: true,
exclusiveScope: "global",
})),
},
{
groupLabel: "ORDER BY NAME",
multiple: false,
items: ["A-Z", "Z-A"].map((value) => ({
label: value,
value,
exclusive: true,
exclusiveScope: "global",
})),
},
],
defaultValue: { "ORDER BY TIME": ["Recent"] },
variants: {
triggerTextColor: "green",
headerPosition: "end",
itemsPosition: "end",
},
placeholder: "Order by",
className: "w-40",
onChange: (values) => onChange(values),
},
};
// Example with filters including "All" option and collapsible groups
export const FilterExample: Story = {
args: {
options: [
{
multiple: false,
items: [
{
label: "All",
value: "All-id",
exclusive: true,
exclusiveScope: "global",
},
],
},
{
groupLabel: "Network",
multiple: true,
collapsible: true,
items: [
{ label: "Rounds on Ethereum", value: "1" },
{ label: "Rounds on Polygon", value: "137" },
{ label: "Rounds on Optimism", value: "10" },
],
},
{
groupLabel: "Status",
multiple: true,
collapsible: true,
items: [
{ label: "Active", value: "active" },
{ label: "Taking Applications", value: "applications" },
{ label: "Finished", value: "finished" },
],
},
],
defaultValue: { ungrouped: ["All-id"] },
variants: { triggerTextColor: "red" },
placeholder: "Filter by",
className: "w-64",
onChange: (values) => onChange(values),
},
};
// Example with mixed exclusive and non-exclusive options
export const MixedSelectionTypes: Story = {
args: {
options: [
{
groupLabel: "Special Actions",
items: [
{
label: "Reset All",
value: "reset",
exclusive: true,
exclusiveScope: "global",
},
],
},
{
groupLabel: "Regular Options",
multiple: true,
items: [
{ label: "Option 1", value: "1" },
{ label: "Option 2", value: "2" },
{ label: "Option 3", value: "3" },
],
},
],
placeholder: "Select options",
onChange: (values) => onChange(values),
},
};
// Example with all variant options
export const WithVariants: Story = {
args: {
options: [
{
groupLabel: "Group 1",
multiple: true,
collapsible: true,
items: [
{ label: "Option 1", value: "1" },
{ label: "Option 2", value: "2" },
],
},
],
variants: {
triggerTextColor: "green",
headerPosition: "end",
itemsPosition: "end",
},
placeholder: "Select with variants",
onChange: (values) => onChange(values),
className: "w-40",
},
};