reshaped 3.8.8 → 3.9.0-canary.1

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.
Files changed (191) hide show
  1. package/dist/bundle.css +1 -1
  2. package/dist/bundle.js +11 -11
  3. package/dist/components/Button/Button.module.css +1 -1
  4. package/dist/components/Card/Card.d.ts +1 -1
  5. package/dist/components/Divider/Divider.js +3 -3
  6. package/dist/components/Divider/Divider.module.css +1 -1
  7. package/dist/components/Divider/Divider.types.d.ts +6 -0
  8. package/dist/components/DropdownMenu/DropdownMenu.js +1 -1
  9. package/dist/components/DropdownMenu/DropdownMenu.types.d.ts +1 -1
  10. package/dist/components/Flyout/Flyout.constants.d.ts +1 -3
  11. package/dist/components/Flyout/Flyout.constants.js +1 -3
  12. package/dist/components/Flyout/Flyout.types.d.ts +2 -0
  13. package/dist/components/Flyout/FlyoutControlled.js +10 -11
  14. package/dist/components/Flyout/utilities/cooldown.js +1 -2
  15. package/dist/components/Icon/Icon.module.css +1 -1
  16. package/dist/components/Popover/Popover.types.d.ts +1 -1
  17. package/dist/components/Progress/Progress.module.css +1 -1
  18. package/dist/components/Select/Select.module.css +1 -1
  19. package/dist/components/Select/Select.types.d.ts +16 -11
  20. package/dist/components/Select/SelectCustomControlled.js +27 -10
  21. package/dist/components/Select/SelectGroup.d.ts +4 -0
  22. package/dist/components/Select/SelectGroup.js +10 -0
  23. package/dist/components/Select/SelectTrigger.js +1 -1
  24. package/dist/components/Select/index.d.ts +3 -2
  25. package/dist/components/Select/index.js +3 -2
  26. package/dist/components/Tabs/TabsContext.d.ts +1 -1
  27. package/dist/components/TextArea/TextArea.module.css +1 -1
  28. package/dist/components/TextArea/TextArea.types.d.ts +1 -1
  29. package/dist/components/TextField/TextField.module.css +1 -1
  30. package/dist/components/TextField/TextField.types.d.ts +1 -1
  31. package/dist/components/Tooltip/Tooltip.types.d.ts +1 -1
  32. package/dist/config/tailwind.d.ts +1 -1
  33. package/package.json +31 -30
  34. package/dist/components/Accordion/tests/Accordion.stories.d.ts +0 -44
  35. package/dist/components/Accordion/tests/Accordion.stories.js +0 -204
  36. package/dist/components/ActionBar/tests/ActionBar.stories.d.ts +0 -40
  37. package/dist/components/ActionBar/tests/ActionBar.stories.js +0 -223
  38. package/dist/components/Actionable/tests/Actionable.stories.d.ts +0 -41
  39. package/dist/components/Actionable/tests/Actionable.stories.js +0 -220
  40. package/dist/components/Alert/tests/Alert.stories.d.ts +0 -24
  41. package/dist/components/Alert/tests/Alert.stories.js +0 -78
  42. package/dist/components/Autocomplete/tests/Autocomplete.stories.d.ts +0 -32
  43. package/dist/components/Autocomplete/tests/Autocomplete.stories.js +0 -246
  44. package/dist/components/Avatar/tests/Avatar.stories.d.ts +0 -31
  45. package/dist/components/Avatar/tests/Avatar.stories.js +0 -176
  46. package/dist/components/Badge/tests/Badge.stories.d.ts +0 -55
  47. package/dist/components/Badge/tests/Badge.stories.js +0 -328
  48. package/dist/components/Breadcrumbs/tests/Breadcrumbs.stories.d.ts +0 -40
  49. package/dist/components/Breadcrumbs/tests/Breadcrumbs.stories.js +0 -187
  50. package/dist/components/Button/tests/Button.stories.d.ts +0 -79
  51. package/dist/components/Button/tests/Button.stories.js +0 -789
  52. package/dist/components/Calendar/tests/Calendar.stories.d.ts +0 -29
  53. package/dist/components/Calendar/tests/Calendar.stories.js +0 -255
  54. package/dist/components/Card/tests/Card.stories.d.ts +0 -52
  55. package/dist/components/Card/tests/Card.stories.js +0 -125
  56. package/dist/components/Carousel/tests/Carousel.stories.d.ts +0 -34
  57. package/dist/components/Carousel/tests/Carousel.stories.js +0 -224
  58. package/dist/components/Checkbox/tests/Checkbox.stories.d.ts +0 -30
  59. package/dist/components/Checkbox/tests/Checkbox.stories.js +0 -171
  60. package/dist/components/CheckboxGroup/tests/CheckboxGroup.stories.d.ts +0 -19
  61. package/dist/components/CheckboxGroup/tests/CheckboxGroup.stories.js +0 -83
  62. package/dist/components/Container/tests/Container.stories.d.ts +0 -24
  63. package/dist/components/Container/tests/Container.stories.js +0 -75
  64. package/dist/components/ContextMenu/tests/ContextMenu.stories.d.ts +0 -26
  65. package/dist/components/ContextMenu/tests/ContextMenu.stories.js +0 -70
  66. package/dist/components/Dismissible/tests/Dismissible.stories.d.ts +0 -25
  67. package/dist/components/Dismissible/tests/Dismissible.stories.js +0 -97
  68. package/dist/components/Divider/tests/Divider.stories.d.ts +0 -18
  69. package/dist/components/Divider/tests/Divider.stories.js +0 -94
  70. package/dist/components/DropdownMenu/tests/DropdownMenu.stories.d.ts +0 -53
  71. package/dist/components/DropdownMenu/tests/DropdownMenu.stories.js +0 -278
  72. package/dist/components/FileUpload/tests/FileUpload.stories.d.ts +0 -31
  73. package/dist/components/FileUpload/tests/FileUpload.stories.js +0 -140
  74. package/dist/components/Flyout/tests/Flyout.stories.d.ts +0 -102
  75. package/dist/components/Flyout/tests/Flyout.stories.js +0 -708
  76. package/dist/components/FormControl/tests/FormControl.stories.d.ts +0 -31
  77. package/dist/components/FormControl/tests/FormControl.stories.js +0 -143
  78. package/dist/components/Grid/tests/Grid.stories.d.ts +0 -38
  79. package/dist/components/Grid/tests/Grid.stories.js +0 -245
  80. package/dist/components/Hidden/tests/Hidden.stories.d.ts +0 -16
  81. package/dist/components/Hidden/tests/Hidden.stories.js +0 -48
  82. package/dist/components/HiddenVisually/tests/HiddenVisually.stories.d.ts +0 -16
  83. package/dist/components/HiddenVisually/tests/HiddenVisually.stories.js +0 -28
  84. package/dist/components/Hotkey/tests/Hotkey.stories.d.ts +0 -13
  85. package/dist/components/Hotkey/tests/Hotkey.stories.js +0 -53
  86. package/dist/components/Icon/tests/Icon.stories.d.ts +0 -25
  87. package/dist/components/Icon/tests/Icon.stories.js +0 -113
  88. package/dist/components/Image/tests/Image.stories.d.ts +0 -41
  89. package/dist/components/Image/tests/Image.stories.js +0 -196
  90. package/dist/components/Link/tests/Link.stories.d.ts +0 -42
  91. package/dist/components/Link/tests/Link.stories.js +0 -155
  92. package/dist/components/Loader/tests/Loader.stories.d.ts +0 -21
  93. package/dist/components/Loader/tests/Loader.stories.js +0 -68
  94. package/dist/components/MenuItem/tests/MenuItem.stories.d.ts +0 -59
  95. package/dist/components/MenuItem/tests/MenuItem.stories.js +0 -236
  96. package/dist/components/Modal/tests/Modal.stories.d.ts +0 -64
  97. package/dist/components/Modal/tests/Modal.stories.js +0 -410
  98. package/dist/components/NumberField/tests/NumberField.stories.d.ts +0 -28
  99. package/dist/components/NumberField/tests/NumberField.stories.js +0 -258
  100. package/dist/components/Overlay/tests/Overlay.stories.d.ts +0 -28
  101. package/dist/components/Overlay/tests/Overlay.stories.js +0 -202
  102. package/dist/components/Pagination/tests/Pagination.stories.d.ts +0 -24
  103. package/dist/components/Pagination/tests/Pagination.stories.js +0 -105
  104. package/dist/components/PinField/tests/PinField.stories.d.ts +0 -34
  105. package/dist/components/PinField/tests/PinField.stories.js +0 -209
  106. package/dist/components/Popover/tests/Popover.stories.d.ts +0 -69
  107. package/dist/components/Popover/tests/Popover.stories.js +0 -340
  108. package/dist/components/Progress/tests/Progress.stories.d.ts +0 -30
  109. package/dist/components/Progress/tests/Progress.stories.js +0 -102
  110. package/dist/components/ProgressIndicator/tests/ProgressIndicator.stories.d.ts +0 -19
  111. package/dist/components/ProgressIndicator/tests/ProgressIndicator.stories.js +0 -92
  112. package/dist/components/Radio/tests/Radio.stories.d.ts +0 -35
  113. package/dist/components/Radio/tests/Radio.stories.js +0 -162
  114. package/dist/components/RadioGroup/tests/RadioGroup.stories.d.ts +0 -19
  115. package/dist/components/RadioGroup/tests/RadioGroup.stories.js +0 -77
  116. package/dist/components/Reshaped/tests/Reshaped.stories.d.ts +0 -34
  117. package/dist/components/Reshaped/tests/Reshaped.stories.js +0 -108
  118. package/dist/components/Resizable/tests/Resizable.stories.d.ts +0 -38
  119. package/dist/components/Resizable/tests/Resizable.stories.js +0 -185
  120. package/dist/components/Scrim/tests/Scrim.stories.d.ts +0 -20
  121. package/dist/components/Scrim/tests/Scrim.stories.js +0 -67
  122. package/dist/components/ScrollArea/tests/ScrollArea.stories.d.ts +0 -37
  123. package/dist/components/ScrollArea/tests/ScrollArea.stories.js +0 -244
  124. package/dist/components/Select/SelectOptionGroup.d.ts +0 -4
  125. package/dist/components/Select/SelectOptionGroup.js +0 -9
  126. package/dist/components/Select/tests/Select.stories.d.ts +0 -47
  127. package/dist/components/Select/tests/Select.stories.js +0 -520
  128. package/dist/components/Skeleton/tests/Skeleton.stories.d.ts +0 -20
  129. package/dist/components/Skeleton/tests/Skeleton.stories.js +0 -63
  130. package/dist/components/Slider/tests/Slider.stories.d.ts +0 -47
  131. package/dist/components/Slider/tests/Slider.stories.js +0 -279
  132. package/dist/components/Stepper/tests/Stepper.stories.d.ts +0 -31
  133. package/dist/components/Stepper/tests/Stepper.stories.js +0 -135
  134. package/dist/components/Switch/tests/Switch.stories.d.ts +0 -22
  135. package/dist/components/Switch/tests/Switch.stories.js +0 -137
  136. package/dist/components/Switch/tests/Switch.test.stories.d.ts +0 -13
  137. package/dist/components/Switch/tests/Switch.test.stories.js +0 -11
  138. package/dist/components/Table/tests/Table.stories.d.ts +0 -42
  139. package/dist/components/Table/tests/Table.stories.js +0 -348
  140. package/dist/components/Tabs/tests/Tabs.stories.d.ts +0 -62
  141. package/dist/components/Tabs/tests/Tabs.stories.js +0 -539
  142. package/dist/components/Text/tests/Text.stories.d.ts +0 -48
  143. package/dist/components/Text/tests/Text.stories.js +0 -201
  144. package/dist/components/TextArea/tests/TextArea.stories.d.ts +0 -53
  145. package/dist/components/TextArea/tests/TextArea.stories.js +0 -200
  146. package/dist/components/TextField/tests/TextField.stories.d.ts +0 -53
  147. package/dist/components/TextField/tests/TextField.stories.js +0 -237
  148. package/dist/components/Theme/tests/Theme.stories.d.ts +0 -25
  149. package/dist/components/Theme/tests/Theme.stories.js +0 -171
  150. package/dist/components/Timeline/tests/Timeline.stories.d.ts +0 -22
  151. package/dist/components/Timeline/tests/Timeline.stories.js +0 -86
  152. package/dist/components/Toast/tests/Toast.stories.d.ts +0 -41
  153. package/dist/components/Toast/tests/Toast.stories.js +0 -432
  154. package/dist/components/ToggleButton/tests/ToggleButton.stories.d.ts +0 -27
  155. package/dist/components/ToggleButton/tests/ToggleButton.stories.js +0 -97
  156. package/dist/components/ToggleButtonGroup/tests/ToggleButtonGroup.stories.d.ts +0 -27
  157. package/dist/components/ToggleButtonGroup/tests/ToggleButtonGroup.stories.js +0 -169
  158. package/dist/components/Tooltip/tests/Tooltip.stories.d.ts +0 -28
  159. package/dist/components/Tooltip/tests/Tooltip.stories.js +0 -182
  160. package/dist/components/View/tests/View.stories.d.ts +0 -141
  161. package/dist/components/View/tests/View.stories.js +0 -1329
  162. package/dist/components/_private/Portal/tests/Portal.stories.d.ts +0 -6
  163. package/dist/components/_private/Portal/tests/Portal.stories.js +0 -17
  164. package/dist/hooks/tests/useDrag.stories.d.ts +0 -31
  165. package/dist/hooks/tests/useDrag.stories.js +0 -147
  166. package/dist/hooks/tests/useElementId.stories.d.ts +0 -11
  167. package/dist/hooks/tests/useElementId.stories.js +0 -23
  168. package/dist/hooks/tests/useHandlerRef.stories.d.ts +0 -14
  169. package/dist/hooks/tests/useHandlerRef.stories.js +0 -44
  170. package/dist/hooks/tests/useHotkeys.stories.d.ts +0 -43
  171. package/dist/hooks/tests/useHotkeys.stories.js +0 -158
  172. package/dist/hooks/tests/useKeyboardArrowNavigation.stories.d.ts +0 -15
  173. package/dist/hooks/tests/useKeyboardArrowNavigation.stories.js +0 -128
  174. package/dist/hooks/tests/useKeyboardMode.stories.d.ts +0 -11
  175. package/dist/hooks/tests/useKeyboardMode.stories.js +0 -42
  176. package/dist/hooks/tests/useOnClickOutside.stories.d.ts +0 -23
  177. package/dist/hooks/tests/useOnClickOutside.stories.js +0 -111
  178. package/dist/hooks/tests/useRTL.stories.d.ts +0 -11
  179. package/dist/hooks/tests/useRTL.stories.js +0 -23
  180. package/dist/hooks/tests/useResponsiveClientValue.stories.d.ts +0 -18
  181. package/dist/hooks/tests/useResponsiveClientValue.stories.js +0 -30
  182. package/dist/hooks/tests/useScrollLock.stories.d.ts +0 -14
  183. package/dist/hooks/tests/useScrollLock.stories.js +0 -97
  184. package/dist/hooks/tests/useToggle.stories.d.ts +0 -13
  185. package/dist/hooks/tests/useToggle.stories.js +0 -59
  186. package/dist/tests/ShadowDOM.stories.d.ts +0 -6
  187. package/dist/tests/ShadowDOM.stories.js +0 -110
  188. package/dist/tests/themes.stories.d.ts +0 -16
  189. package/dist/tests/themes.stories.js +0 -327
  190. package/dist/utilities/a11y/tests/TrapFocus.stories.d.ts +0 -14
  191. package/dist/utilities/a11y/tests/TrapFocus.stories.js +0 -615
@@ -1,432 +0,0 @@
1
- import { Example } from "../../../utilities/storybook/index.js";
2
- import { useToast, ToastProvider } from "../index.js";
3
- import Button from "../../Button/index.js";
4
- import View from "../../View/index.js";
5
- import Image from "../../Image/index.js";
6
- import Text from "../../Text/index.js";
7
- import Dismissible from "../../Dismissible/index.js";
8
- import IconZap from "../../../icons/Zap.js";
9
- import { expect, userEvent, waitFor, within } from "storybook/test";
10
- import { sleep } from "../../../utilities/helpers.js";
11
- export default {
12
- title: "Components/Toast",
13
- parameters: {
14
- iframe: {
15
- url: "https://reshaped.so/docs/components/toast",
16
- },
17
- },
18
- };
19
- const Size = () => {
20
- const toast = useToast();
21
- const props = {
22
- icon: IconZap,
23
- title: "Hey!",
24
- text: "Event completed",
25
- actionsSlot: [<Button>Action</Button>],
26
- };
27
- return (<Example>
28
- <Example.Item title="size: small">
29
- <Button onClick={() => {
30
- toast.show({ ...props });
31
- }}>
32
- Show toast
33
- </Button>
34
- </Example.Item>
35
- <Example.Item title="size: medium">
36
- <Button onClick={() => {
37
- toast.show({ ...props, size: "medium" });
38
- }}>
39
- Show toast
40
- </Button>
41
- </Example.Item>
42
- <Example.Item title="large">
43
- <Button onClick={() => {
44
- toast.show({ ...props, size: "large" });
45
- }}>
46
- Show toast
47
- </Button>
48
- </Example.Item>
49
- </Example>);
50
- };
51
- export const size = { name: "size", render: () => <Size /> };
52
- const Position = () => {
53
- const toast = useToast();
54
- return (<Example>
55
- <Example.Item title="position: bottom-start">
56
- <Button onClick={() => {
57
- const id = toast.show({
58
- text: "Event completed",
59
- position: "bottom-start",
60
- actionsSlot: <Button onClick={() => toast.hide(id)}>Close</Button>,
61
- });
62
- }}>
63
- Show toast
64
- </Button>
65
- </Example.Item>
66
- <Example.Item title="position: bottom">
67
- <Button onClick={() => {
68
- toast.show({
69
- text: "Event completed",
70
- position: "bottom",
71
- });
72
- }}>
73
- Show toast
74
- </Button>
75
- </Example.Item>
76
- <Example.Item title="position: bottom-end">
77
- <Button onClick={() => {
78
- toast.show({
79
- text: "Event completed",
80
- position: "bottom-end",
81
- });
82
- }}>
83
- Show toast
84
- </Button>
85
- </Example.Item>
86
- <Example.Item title="position: top-start">
87
- <Button onClick={() => {
88
- toast.show({
89
- text: "Event completed",
90
- position: "top-start",
91
- });
92
- }}>
93
- Show toast
94
- </Button>
95
- </Example.Item>
96
- <Example.Item title="position: top">
97
- <Button onClick={() => {
98
- toast.show({
99
- text: "Event completed",
100
- position: "top",
101
- });
102
- }}>
103
- Show toast
104
- </Button>
105
- </Example.Item>
106
- <Example.Item title="position: top-end">
107
- <Button onClick={() => {
108
- toast.show({
109
- text: "Event completed",
110
- position: "top-end",
111
- });
112
- }}>
113
- Show toast
114
- </Button>
115
- </Example.Item>
116
- </Example>);
117
- };
118
- export const position = { name: "position", render: () => <Position /> };
119
- const Color = () => {
120
- const toast = useToast();
121
- return (<Example>
122
- <Example.Item title="color: inverted">
123
- <Button onClick={() => {
124
- const id = toast.show({
125
- text: "Event completed",
126
- color: "inverted",
127
- title: "Hey!",
128
- icon: IconZap,
129
- actionsSlot: [
130
- <Button onClick={() => toast.hide(id)}>Undo</Button>,
131
- <Button onClick={() => toast.hide(id)}>Hide</Button>,
132
- ],
133
- });
134
- }}>
135
- Show toast
136
- </Button>
137
- </Example.Item>
138
- <Example.Item title="color: neutral">
139
- <Button onClick={() => {
140
- const id = toast.show({
141
- text: "Event completed",
142
- color: "neutral",
143
- title: "Hey!",
144
- icon: IconZap,
145
- actionsSlot: [
146
- <Button onClick={() => toast.hide(id)}>Undo</Button>,
147
- <Button onClick={() => toast.hide(id)}>Hide</Button>,
148
- ],
149
- });
150
- }}>
151
- Show toast
152
- </Button>
153
- </Example.Item>
154
- <Example.Item title="color: primary">
155
- <Button onClick={() => {
156
- const id = toast.show({
157
- text: "Event completed",
158
- color: "primary",
159
- title: "Hey!",
160
- icon: IconZap,
161
- actionsSlot: [
162
- <Button onClick={() => toast.hide(id)}>Undo</Button>,
163
- <Button onClick={() => toast.hide(id)}>Hide</Button>,
164
- ],
165
- });
166
- }}>
167
- Show toast
168
- </Button>
169
- </Example.Item>
170
- <Example.Item title="color: positive">
171
- <Button onClick={() => {
172
- const id = toast.show({
173
- text: "Event completed",
174
- color: "positive",
175
- title: "Hey!",
176
- icon: IconZap,
177
- actionsSlot: [
178
- <Button onClick={() => toast.hide(id)}>Undo</Button>,
179
- <Button onClick={() => toast.hide(id)}>Hide</Button>,
180
- ],
181
- });
182
- }}>
183
- Show toast
184
- </Button>
185
- </Example.Item>
186
- <Example.Item title="color: critical">
187
- <Button onClick={() => {
188
- const id = toast.show({
189
- text: "Event completed",
190
- color: "critical",
191
- title: "Hey!",
192
- icon: IconZap,
193
- actionsSlot: [
194
- <Button onClick={() => toast.hide(id)}>Undo</Button>,
195
- <Button onClick={() => toast.hide(id)}>Hide</Button>,
196
- ],
197
- });
198
- }}>
199
- Show toast
200
- </Button>
201
- </Example.Item>
202
- <Example.Item title="color: warning">
203
- <Button onClick={() => {
204
- const id = toast.show({
205
- text: "Event completed",
206
- color: "warning",
207
- title: "Hey!",
208
- icon: IconZap,
209
- actionsSlot: [
210
- <Button onClick={() => toast.hide(id)}>Undo</Button>,
211
- <Button onClick={() => toast.hide(id)}>Hide</Button>,
212
- ],
213
- });
214
- }}>
215
- Show toast
216
- </Button>
217
- </Example.Item>
218
- </Example>);
219
- };
220
- export const color = { name: "color", render: () => <Color /> };
221
- const Timeout = () => {
222
- const toast = useToast();
223
- return (<Example>
224
- <Example.Item title="timeout: short">
225
- <Button onClick={() => {
226
- toast.show({
227
- text: "Event completed",
228
- timeout: "short",
229
- });
230
- }}>
231
- Show toast
232
- </Button>
233
- </Example.Item>
234
- <Example.Item title="timeout: long">
235
- <Button onClick={() => {
236
- toast.show({
237
- text: "Event completed",
238
- timeout: "long",
239
- });
240
- }}>
241
- Show toast
242
- </Button>
243
- </Example.Item>
244
- <Example.Item title="timeout: 0">
245
- <Button onClick={() => {
246
- toast.show({
247
- text: "Event completed",
248
- timeout: 0,
249
- });
250
- }}>
251
- Show toast
252
- </Button>
253
- </Example.Item>
254
- </Example>);
255
- };
256
- export const timeout = { name: "timeout", render: () => <Timeout /> };
257
- const Expanded = () => {
258
- const toast = useToast();
259
- return (<Example>
260
- <Example.Item title="Custom width coming from Reshaped provider for bottom-start">
261
- <Button onClick={() => {
262
- toast.show({
263
- text: "Event completed",
264
- position: "bottom-start",
265
- });
266
- }}>
267
- Show toast
268
- </Button>
269
- </Example.Item>
270
- </Example>);
271
- };
272
- export const regionOptions = { name: "expanded", render: () => <Expanded /> };
273
- const Slots = () => {
274
- const toast = useToast();
275
- return (<Example>
276
- <Example.Item title="always expanded, promotion banner">
277
- <Button onClick={() => {
278
- const id = toast.show({
279
- children: (<View gap={3} direction="row">
280
- <View aspectRatio={1}>
281
- <Image height="100px" src="https://images.unsplash.com/photo-1618005182384-a83a8bd57fbe?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=400&q=80" borderRadius="medium"/>
282
- </View>
283
- <View.Item grow>
284
- <View gap={1}>
285
- <Dismissible closeAriaLabel="Close notification" onClose={() => toast.hide(id)}>
286
- <Text variant="body-2" weight="bold">
287
- Look at this gradient!
288
- </Text>
289
- </Dismissible>
290
- <Text variant="body-3">
291
- If you start using more gradients, your product will become even more
292
- succesful.
293
- </Text>
294
- </View>
295
- </View.Item>
296
- </View>),
297
- color: "neutral",
298
- position: "bottom-start",
299
- timeout: 0,
300
- });
301
- }}>
302
- Show toast
303
- </Button>
304
- </Example.Item>
305
- </Example>);
306
- };
307
- export const slots = { name: "slots", render: () => <Slots /> };
308
- export const base = {
309
- name: "base",
310
- render: () => {
311
- const toast = useToast();
312
- return (<Button onClick={() => {
313
- const id = toast.show({
314
- title: "Title",
315
- text: "Text",
316
- children: "Children",
317
- startSlot: "Slot",
318
- actionsSlot: (<Button attributes={{ "data-testid": "trigger-id" }} onClick={() => toast.hide(id)}>
319
- Trigger
320
- </Button>),
321
- });
322
- }}>
323
- Show toast
324
- </Button>);
325
- },
326
- play: async ({ canvasElement }) => {
327
- const canvas = within(canvasElement.ownerDocument.body);
328
- const button = canvas.getAllByRole("button")[0];
329
- await userEvent.click(button);
330
- const title = canvas.getByText("Title");
331
- const text = canvas.getByText("Text");
332
- const children = canvas.getByText("Children");
333
- const slot = canvas.getByText("Slot");
334
- const action = canvas.getByTestId("trigger-id");
335
- expect(title).toBeInTheDocument();
336
- expect(text).toBeInTheDocument();
337
- expect(children).toBeInTheDocument();
338
- expect(slot).toBeInTheDocument();
339
- expect(action).toBeInTheDocument();
340
- await userEvent.click(action);
341
- await sleep(600);
342
- await waitFor(() => {
343
- expect(title).not.toBeInTheDocument();
344
- });
345
- },
346
- };
347
- const NestedDemo = () => {
348
- const toast = useToast();
349
- return (<Button onClick={() => {
350
- toast.show({
351
- text: "Content",
352
- });
353
- }}>
354
- Show toast
355
- </Button>);
356
- };
357
- export const nested = {
358
- name: "ToastProvider",
359
- render: () => {
360
- return (<div data-testid="test-container-id">
361
- <ToastProvider>
362
- <NestedDemo />
363
- </ToastProvider>
364
- </div>);
365
- },
366
- play: async ({ canvasElement }) => {
367
- const canvas = within(canvasElement.ownerDocument.body);
368
- const button = canvas.getAllByRole("button")[0];
369
- await userEvent.click(button);
370
- const container = canvas.getByTestId("test-container-id");
371
- const toast = within(container).getByText("Content");
372
- expect(toast).toBeInTheDocument();
373
- },
374
- };
375
- export const className = {
376
- name: "className, attributes",
377
- render: () => {
378
- const toast = useToast();
379
- return (<Button onClick={() => {
380
- const id = toast.show({
381
- text: "Content",
382
- attributes: { "data-testid": "test-id" },
383
- className: "test-classname",
384
- });
385
- }}>
386
- Show toast
387
- </Button>);
388
- },
389
- play: async ({ canvasElement }) => {
390
- const canvas = within(canvasElement.ownerDocument.body);
391
- const button = canvas.getAllByRole("button")[0];
392
- await userEvent.click(button);
393
- const toast = canvas.getByTestId("test-id");
394
- expect(toast).toBeInTheDocument();
395
- expect(toast).toHaveClass("test-classname");
396
- },
397
- };
398
- const Multiline = () => {
399
- const toast = useToast();
400
- return (<Button onClick={() => {
401
- toast.show({
402
- text: "Very long event completed notification message",
403
- });
404
- }}>
405
- Show toast
406
- </Button>);
407
- };
408
- const Nested = () => {
409
- const toast = useToast();
410
- return (<View height="300px">
411
- <Button onClick={() => {
412
- toast.show({
413
- text: "Notification sent",
414
- });
415
- }}>
416
- Show toast
417
- </Button>
418
- </View>);
419
- };
420
- export const edgeCases = {
421
- name: "test: edge cases",
422
- render: () => (<Example>
423
- <Example.Item title="Multiline, should support dynamic height">
424
- <Multiline />
425
- </Example.Item>
426
- <Example.Item title="Nested ToastProvider">
427
- <ToastProvider>
428
- <Nested />
429
- </ToastProvider>
430
- </Example.Item>
431
- </Example>),
432
- };
@@ -1,27 +0,0 @@
1
- import { type StoryObj } from "@storybook/react-vite";
2
- import { type Mock } from "storybook/test";
3
- declare const _default: {
4
- title: string;
5
- component: import("react").FC<import("..").ToggleButtonProps>;
6
- parameters: {
7
- iframe: {
8
- url: string;
9
- };
10
- };
11
- };
12
- export default _default;
13
- export declare const variant: {
14
- name: string;
15
- render: () => import("react").JSX.Element;
16
- };
17
- export declare const selectedColor: {
18
- name: string;
19
- render: () => import("react").JSX.Element;
20
- };
21
- export declare const onChange: StoryObj<{
22
- handleUncontrolledChange: Mock;
23
- handleControlledChange: Mock;
24
- }>;
25
- export declare const onClick: StoryObj<{
26
- handleClick: Mock;
27
- }>;
@@ -1,97 +0,0 @@
1
- import { expect, fn, userEvent } from "storybook/test";
2
- import { Example } from "../../../utilities/storybook/index.js";
3
- import ToggleButton from "../ToggleButton.js";
4
- export default {
5
- title: "Components/ToggleButton",
6
- component: ToggleButton,
7
- parameters: {
8
- iframe: {
9
- url: "https://reshaped.so/docs/components/toggle-button",
10
- },
11
- },
12
- };
13
- export const variant = {
14
- name: "variant",
15
- render: () => (<Example>
16
- <Example.Item title="outline">
17
- <ToggleButton>Button</ToggleButton>
18
- </Example.Item>
19
- <Example.Item title="ghost">
20
- <ToggleButton variant="ghost">Button</ToggleButton>
21
- </Example.Item>
22
- </Example>),
23
- };
24
- export const selectedColor = {
25
- name: "selectedColor",
26
- render: () => (<Example>
27
- <Example.Item title="selectedColor: primary">
28
- <ToggleButton selectedColor="primary" defaultChecked>
29
- Button
30
- </ToggleButton>
31
- </Example.Item>
32
- </Example>),
33
- };
34
- export const onChange = {
35
- name: "checked, defaultChecked, onChange",
36
- args: {
37
- handleUncontrolledChange: fn(),
38
- handleControlledChange: fn(),
39
- },
40
- render: (args) => (<Example>
41
- <Example.Item title="defaultChecked, onChange">
42
- <ToggleButton defaultChecked onChange={args.handleUncontrolledChange} value="1">
43
- Button
44
- </ToggleButton>
45
- </Example.Item>
46
- <Example.Item title="checked, onChange">
47
- <ToggleButton checked onChange={args.handleControlledChange} value="2">
48
- Button
49
- </ToggleButton>
50
- </Example.Item>
51
- </Example>),
52
- play: async ({ canvas, args }) => {
53
- const [uncontrolledButton, controlledButton] = canvas.getAllByRole("button");
54
- await userEvent.click(uncontrolledButton);
55
- expect(args.handleUncontrolledChange).toHaveBeenCalledTimes(1);
56
- expect(args.handleUncontrolledChange).toHaveBeenLastCalledWith({
57
- checked: false,
58
- value: "1",
59
- event: expect.objectContaining({ target: uncontrolledButton }),
60
- });
61
- await userEvent.click(uncontrolledButton);
62
- expect(args.handleUncontrolledChange).toHaveBeenCalledTimes(2);
63
- expect(args.handleUncontrolledChange).toHaveBeenLastCalledWith({
64
- checked: true,
65
- value: "1",
66
- event: expect.objectContaining({ target: uncontrolledButton }),
67
- });
68
- await userEvent.click(controlledButton);
69
- expect(args.handleControlledChange).toHaveBeenCalledTimes(1);
70
- expect(args.handleControlledChange).toHaveBeenLastCalledWith({
71
- checked: false,
72
- value: "2",
73
- event: expect.objectContaining({ target: controlledButton }),
74
- });
75
- await userEvent.click(controlledButton);
76
- // Stayed checked after the first click
77
- expect(args.handleControlledChange).toHaveBeenCalledTimes(2);
78
- expect(args.handleControlledChange).toHaveBeenLastCalledWith({
79
- checked: false,
80
- value: "2",
81
- event: expect.objectContaining({ target: uncontrolledButton }),
82
- });
83
- },
84
- };
85
- export const onClick = {
86
- name: "onClick",
87
- args: {
88
- handleClick: fn(),
89
- },
90
- render: (args) => <ToggleButton onClick={args.handleClick}>Button</ToggleButton>,
91
- play: async ({ canvas, args }) => {
92
- const [button] = canvas.getAllByRole("button");
93
- await userEvent.click(button);
94
- expect(args.handleClick).toHaveBeenCalledOnce();
95
- expect(args.handleClick).toHaveBeenLastCalledWith(expect.objectContaining({ target: button }));
96
- },
97
- };
@@ -1,27 +0,0 @@
1
- import { StoryObj } from "@storybook/react-vite";
2
- import { Mock } from "storybook/test";
3
- declare const _default: {
4
- title: string;
5
- component: import("react").FC<import("./..").ToggleButtonGroupProps>;
6
- parameters: {
7
- iframe: {
8
- url: string;
9
- };
10
- };
11
- };
12
- export default _default;
13
- export declare const single: StoryObj<{
14
- handleUncontrolledChange: Mock;
15
- handleControlledChange: Mock;
16
- handleItemChange: Mock;
17
- }>;
18
- export declare const multiple: StoryObj<{
19
- handleUncontrolledChange: Mock;
20
- handleControlledChange: Mock;
21
- }>;
22
- export declare const selectedColor: StoryObj;
23
- export declare const className: StoryObj;
24
- export declare const testIcon: {
25
- name: string;
26
- render: () => import("react").JSX.Element;
27
- };