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,279 +0,0 @@
1
- import React from "react";
2
- import { expect, fireEvent, fn } from "storybook/test";
3
- import { Example } from "../../../utilities/storybook/index.js";
4
- import Slider from "../index.js";
5
- import View from "../../View/index.js";
6
- import Modal from "../../Modal/index.js";
7
- import useToggle from "../../../hooks/useToggle.js";
8
- export default {
9
- title: "Components/Slider",
10
- component: Slider,
11
- parameters: {
12
- iframe: {
13
- url: "https://reshaped.so/docs/components/slider",
14
- },
15
- },
16
- };
17
- export const base = {
18
- name: "name, minName, maxName, range",
19
- render: () => (<Example>
20
- <Example.Item title="single, name">
21
- <Slider name="slider-single" defaultValue={30}/>
22
- </Example.Item>
23
- <Example.Item title="range, name">
24
- <Slider range name="slider-range" defaultMinValue={30} defaultMaxValue={85}/>
25
- </Example.Item>
26
- <Example.Item title="range, minName, maxName">
27
- <Slider range minName="slider-min" maxName="slider-max" defaultMinValue={30} defaultMaxValue={85}/>
28
- </Example.Item>
29
- <div style={{ height: 2000 }}/>
30
- </Example>),
31
- play: ({ canvas }) => {
32
- const inputs = canvas.getAllByRole("slider");
33
- expect(inputs[0]).toHaveAttribute("name", "slider-single");
34
- expect(inputs[1]).toHaveAttribute("name", "slider-range");
35
- expect(inputs[2]).toHaveAttribute("name", "slider-range");
36
- expect(inputs[3]).toHaveAttribute("name", "slider-min");
37
- expect(inputs[4]).toHaveAttribute("name", "slider-max");
38
- },
39
- };
40
- export const orientation = {
41
- name: "orientation",
42
- render: () => (<Example>
43
- <Example.Item title="orientation: vertical">
44
- <View height="200px">
45
- <Slider range name="slider" defaultMinValue={30} defaultMaxValue={85} orientation="vertical"/>
46
- </View>
47
- </Example.Item>
48
- <View height="2000px"/>
49
- </Example>),
50
- };
51
- export const minMax = {
52
- name: "min, max",
53
- render: () => (<Example>
54
- <Example.Item title="min, max">
55
- <Slider name="name" min={50} max={70} defaultValue={60}/>
56
- </Example.Item>
57
- <Example.Item title="min, max, value < min">
58
- <Slider name="name" min={50} max={70} defaultValue={30}/>
59
- </Example.Item>
60
- <Example.Item title="min, max, value > max">
61
- <Slider name="name" min={50} max={70} defaultValue={80}/>
62
- </Example.Item>
63
- </Example>),
64
- play: async ({ canvas }) => {
65
- const inputs = canvas.getAllByRole("slider");
66
- expect(inputs[0]).toHaveAttribute("min", "50");
67
- expect(inputs[0]).toHaveAttribute("max", "70");
68
- expect(inputs[0]).toHaveValue("60");
69
- fireEvent.change(inputs[0], { target: { value: 30 } });
70
- expect(inputs[0]).toHaveValue("50");
71
- fireEvent.change(inputs[0], { target: { value: 80 } });
72
- expect(inputs[0]).toHaveValue("70");
73
- expect(inputs[1]).toHaveValue("50");
74
- expect(inputs[2]).toHaveValue("70");
75
- },
76
- };
77
- export const step = {
78
- name: "step",
79
- render: () => (<Example>
80
- <Example.Item title="step: 5">
81
- <Slider name="slider" defaultValue={30} step={5}/>
82
- </Example.Item>
83
-
84
- <Example.Item title="step: 5, defaultValue: 31, rounded down to 30">
85
- <Slider name="slider" defaultValue={31} step={5}/>
86
- </Example.Item>
87
-
88
- <Example.Item title="step: 0.01, float">
89
- <Slider name="slider" defaultValue={30} step={0.01}/>
90
- </Example.Item>
91
- </Example>),
92
- play: ({ canvas }) => {
93
- const inputs = canvas.getAllByRole("slider");
94
- expect(inputs[0]).toHaveValue("30");
95
- fireEvent.change(inputs[0], { target: { value: 31 } });
96
- expect(inputs[0]).toHaveValue("30");
97
- fireEvent.change(inputs[0], { target: { value: 34 } });
98
- expect(inputs[0]).toHaveValue("35");
99
- expect(inputs[1]).toHaveValue("30");
100
- },
101
- };
102
- export const disabled = {
103
- name: "disabled",
104
- render: () => (<Example>
105
- <Example.Item title="disabled">
106
- <Slider name="slider" defaultValue={30} disabled/>
107
- </Example.Item>
108
-
109
- <Example.Item title="disabled, range">
110
- <Slider name="slider" range defaultMinValue={30} defaultMaxValue={80} disabled/>
111
- </Example.Item>
112
- </Example>),
113
- play: async ({ canvas }) => {
114
- const inputs = canvas.getAllByRole("slider");
115
- expect(inputs[0]).toBeDisabled();
116
- expect(inputs[1]).toBeDisabled();
117
- },
118
- };
119
- export const renderValue = {
120
- name: "renderValue",
121
- render: () => (<Example>
122
- <Example.Item title="renderValue: $">
123
- <Slider name="name" defaultValue={50} renderValue={(args) => `$${args.value}`}/>
124
- </Example.Item>
125
- <Example.Item title="renderValue: false">
126
- <Slider name="name" defaultValue={50} renderValue={false}/>
127
- </Example.Item>
128
- </Example>),
129
- play: async ({ canvas }) => {
130
- const tooltip = canvas.getByText("$50");
131
- const hiddenTooltip = canvas.queryByText("50");
132
- expect(tooltip).toBeInTheDocument();
133
- expect(hiddenTooltip).not.toBeInTheDocument();
134
- },
135
- };
136
- export const defaultValue = {
137
- name: "defaultValue, onChange, onChangeCommit",
138
- args: {
139
- handleChange: fn(),
140
- handleChangeCommit: fn(),
141
- },
142
- render: (args) => (<View paddingTop={10}>
143
- <Slider name="test-name" defaultValue={50} onChange={args.handleChange} onChangeCommit={args.handleChangeCommit}/>
144
- </View>),
145
- play: async ({ canvas, args }) => {
146
- const input = canvas.getByRole("slider");
147
- expect(input).toHaveValue("50");
148
- fireEvent.change(input, { target: { value: 51 } });
149
- expect(args.handleChange).toHaveBeenCalledTimes(1);
150
- expect(args.handleChange).toHaveBeenCalledWith({ value: 51, name: "test-name" });
151
- expect(input).toHaveValue("51");
152
- },
153
- };
154
- export const value = {
155
- name: "value, onChange, onChangeCommit",
156
- args: {
157
- handleChange: fn(),
158
- handleChangeCommit: fn(),
159
- },
160
- render: (args) => (<View paddingTop={10}>
161
- <Slider name="test-name" value={50} onChange={args.handleChange} onChangeCommit={args.handleChangeCommit}/>
162
- </View>),
163
- play: async ({ canvas, args }) => {
164
- const input = canvas.getByRole("slider");
165
- expect(input).toHaveValue("50");
166
- fireEvent.change(input, { target: { value: 51 } });
167
- expect(args.handleChange).toHaveBeenCalledTimes(1);
168
- expect(args.handleChange).toHaveBeenCalledWith({ value: 51, name: "test-name" });
169
- expect(input).toHaveValue("50");
170
- },
171
- };
172
- export const rangeDefaultValue = {
173
- name: "range, defaultValue, onChange, onChangeCommit",
174
- args: {
175
- handleChange: fn(),
176
- handleChangeCommit: fn(),
177
- },
178
- render: (args) => (<View paddingTop={10}>
179
- <Slider range name="test-name" defaultMinValue={50} defaultMaxValue={70} onChange={args.handleChange} onChangeCommit={args.handleChangeCommit}/>
180
- </View>),
181
- play: async ({ canvas, args }) => {
182
- const [minInput, maxInput] = canvas.getAllByRole("slider");
183
- expect(minInput).toHaveValue("50");
184
- expect(maxInput).toHaveValue("70");
185
- fireEvent.change(minInput, { target: { value: 51 } });
186
- expect(args.handleChange).toHaveBeenCalledTimes(1);
187
- expect(args.handleChange).toHaveBeenCalledWith({
188
- minValue: 51,
189
- maxValue: 70,
190
- name: "test-name",
191
- minName: "test-name",
192
- maxName: "test-name",
193
- });
194
- expect(minInput).toHaveValue("51");
195
- expect(maxInput).toHaveValue("70");
196
- },
197
- };
198
- export const rangeValue = {
199
- name: "range, value, onChange, onChangeCommit, minName, maxName",
200
- args: {
201
- handleChange: fn(),
202
- handleChangeCommit: fn(),
203
- },
204
- render: (args) => (<View paddingTop={10}>
205
- <Slider range minName="test-name-min" maxName="test-name-max" minValue={50} maxValue={70} onChange={args.handleChange} onChangeCommit={args.handleChangeCommit}/>
206
- </View>),
207
- play: async ({ canvas, args }) => {
208
- const [minInput, maxInput] = canvas.getAllByRole("slider");
209
- expect(minInput).toHaveValue("50");
210
- expect(maxInput).toHaveValue("70");
211
- fireEvent.change(minInput, { target: { value: 51 } });
212
- expect(args.handleChange).toHaveBeenCalledTimes(1);
213
- expect(args.handleChange).toHaveBeenCalledWith({
214
- minValue: 51,
215
- maxValue: 70,
216
- minName: "test-name-min",
217
- maxName: "test-name-max",
218
- });
219
- expect(minInput).toHaveValue("50");
220
- expect(maxInput).toHaveValue("70");
221
- },
222
- };
223
- export const className = {
224
- name: "className, attributes",
225
- render: () => (<div data-testid="root">
226
- <Slider name="name" className="test-classname" attributes={{ id: "test-id" }}/>
227
- </div>),
228
- play: async ({ canvas }) => {
229
- const root = canvas.getByTestId("root").firstChild;
230
- expect(root).toHaveClass("test-classname");
231
- expect(root).toHaveAttribute("id", "test-id");
232
- },
233
- };
234
- export const testForm = {
235
- name: "test: form onChange",
236
- args: {
237
- handleFormChange: fn(),
238
- handleFormInit: fn(),
239
- },
240
- render: (args) => {
241
- const formRef = React.useRef(null);
242
- const [data, setData] = React.useState([]);
243
- const handleChange = (e) => {
244
- const formData = new FormData(e.currentTarget);
245
- const nextState = [...formData.entries()];
246
- args.handleFormChange({ formData: nextState });
247
- setData(nextState);
248
- };
249
- return (<View paddingTop={10} gap={4}>
250
- <form onChange={handleChange} ref={formRef}>
251
- <Slider range minName="slider-min" maxName="slider-max" defaultMinValue={30} defaultMaxValue={50}/>
252
- </form>
253
-
254
- {data.map((v) => v.join(": ")).join(", ")}
255
- </View>);
256
- },
257
- play: async () => {
258
- /**
259
- * Placeholder
260
- *
261
- * No way to test dragging here without calling fireEvent.change
262
- * Which defeats the purpose of testing custom emitted events
263
- *
264
- * Test this behavior manually in Storybook by dragging the thumbs
265
- */
266
- },
267
- };
268
- export const testSwipe = {
269
- name: "test: prevents parent swipe",
270
- render: () => {
271
- const toggle = useToggle(true);
272
- return (<Modal active={toggle.active} onClose={toggle.deactivate} position="end">
273
- <View gap={4}>
274
- <Modal.Title>Modal</Modal.Title>
275
- <Slider name="slider" defaultValue={30}/>
276
- </View>
277
- </Modal>);
278
- },
279
- };
@@ -1,31 +0,0 @@
1
- import React from "react";
2
- import { StoryObj } from "@storybook/react-vite";
3
- declare const _default: {
4
- title: string;
5
- component: React.FC<import("./..").StepperProps> & {
6
- Item: typeof import("../Stepper").StepperItem;
7
- };
8
- parameters: {
9
- iframe: {
10
- url: string;
11
- };
12
- };
13
- };
14
- export default _default;
15
- export declare const direction: {
16
- name: string;
17
- render: () => React.JSX.Element;
18
- };
19
- export declare const labelDisplay: {
20
- name: string;
21
- render: () => React.JSX.Element;
22
- };
23
- export declare const gap: {
24
- name: string;
25
- render: () => React.JSX.Element;
26
- };
27
- export declare const className: StoryObj;
28
- export declare const edgeCases: {
29
- name: string;
30
- render: () => React.JSX.Element;
31
- };
@@ -1,135 +0,0 @@
1
- import React from "react";
2
- import { Example, Placeholder } from "../../../utilities/storybook/index.js";
3
- import Stepper from "../index.js";
4
- import Button from "../../Button/index.js";
5
- import View from "../../View/index.js";
6
- import { expect } from "storybook/test";
7
- export default {
8
- title: "Components/Stepper",
9
- component: Stepper,
10
- parameters: {
11
- iframe: {
12
- url: "https://reshaped.so/docs/components/stepper",
13
- },
14
- },
15
- };
16
- const Demo = (props) => {
17
- const [activeId, setActiveId] = React.useState(props.activeId ?? 1);
18
- const content = (<View gap={3}>
19
- <Placeholder />
20
- <View direction="row" gap={3}>
21
- <Button onClick={() => setActiveId((prev) => Math.max(0, prev - 1))}>Previous</Button>
22
- <Button onClick={() => setActiveId((prev) => Math.min(2, prev + 1))}>Next</Button>
23
- </View>
24
- </View>);
25
- return (<Stepper activeId={activeId} direction="column">
26
- <Stepper.Item completed={activeId > 0} title="Step 1" subtitle={props.subtitle || "Step subtitle"}>
27
- {content}
28
- </Stepper.Item>
29
- <Stepper.Item completed={activeId > 1} title="Step 2">
30
- {content}
31
- </Stepper.Item>
32
- <Stepper.Item completed={activeId > 2} title="Step 3 very long title">
33
- {content}
34
- </Stepper.Item>
35
- </Stepper>);
36
- };
37
- export const direction = {
38
- name: "direction",
39
- render: () => (<Example>
40
- <Example.Item title="direction: row">
41
- <Stepper activeId="1">
42
- <Stepper.Item completed title="Step 1" subtitle="Step subtitle"/>
43
- <Stepper.Item title="Step 2"/>
44
- <Stepper.Item title="Step 3 very long title"/>
45
- </Stepper>
46
- </Example.Item>
47
- <Example.Item title="direction: column">
48
- <Stepper activeId="1" direction="column">
49
- <Stepper.Item completed title="Step 1" subtitle="Step subtitle"/>
50
- <Stepper.Item title="Step 2"/>
51
- <Stepper.Item title="Step 3 very long title"/>
52
- </Stepper>
53
- </Example.Item>
54
- </Example>),
55
- };
56
- export const labelDisplay = {
57
- name: "labelDisplay",
58
- render: () => (<Example>
59
- <Example.Item title="direction: row, labels hidden">
60
- <Stepper activeId="1" labelDisplay="hidden">
61
- <Stepper.Item completed title="Step 1" subtitle="Step subtitle"/>
62
- <Stepper.Item title="Step 2"/>
63
- <Stepper.Item title="Step 3 very long title"/>
64
- </Stepper>
65
- </Example.Item>
66
- <Example.Item title="direction: column, labels hiden">
67
- <Stepper activeId="1" direction="column" labelDisplay="hidden">
68
- <Stepper.Item completed title="Step 1" subtitle="Step subtitle"/>
69
- <Stepper.Item title="Step 2"/>
70
- <Stepper.Item title="Step 3 very long title"/>
71
- </Stepper>
72
- </Example.Item>
73
- <Example.Item title="direction: row, labels hidden on s">
74
- <Stepper activeId="1" labelDisplay={{ s: "hidden", m: "inline" }}>
75
- <Stepper.Item completed title="Step 1" subtitle="Step subtitle"/>
76
- <Stepper.Item title="Step 2"/>
77
- <Stepper.Item title="Step 3 very long title"/>
78
- </Stepper>
79
- </Example.Item>
80
- </Example>),
81
- };
82
- export const gap = {
83
- name: "gap",
84
- render: () => (<Example>
85
- <Example.Item title="gap: 6, direction: row">
86
- <Stepper activeId="1" gap={6}>
87
- <Stepper.Item completed title="Step 1" subtitle="Step subtitle"/>
88
- <Stepper.Item title="Step 2"/>
89
- <Stepper.Item title="Step 3 very long title"/>
90
- </Stepper>
91
- </Example.Item>
92
- <Example.Item title="gap: 6, direction: column">
93
- <Stepper activeId="1" direction="column" gap={6}>
94
- <Stepper.Item completed title="Step 1" subtitle="Step subtitle"/>
95
- <Stepper.Item title="Step 2"/>
96
- <Stepper.Item title="Step 3 very long title"/>
97
- </Stepper>
98
- </Example.Item>
99
- <Example.Item title={["responsive gap", "[s] 2", "[m+] 5"]}>
100
- <Stepper activeId="1" gap={{ s: 2, m: 5 }}>
101
- <Stepper.Item completed title="Step 1" subtitle="Step subtitle"/>
102
- <Stepper.Item title="Step 2"/>
103
- <Stepper.Item title="Step 3 very long title"/>
104
- </Stepper>
105
- </Example.Item>
106
- </Example>),
107
- };
108
- export const className = {
109
- name: "className, attributes",
110
- render: () => (<div data-testid="root">
111
- <Stepper className="test-classname" attributes={{ id: "test-id" }}>
112
- <Stepper.Item attributes={{ id: "test-item-id" }} className="test-item-classname"/>
113
- </Stepper>
114
- </div>),
115
- play: async ({ canvas }) => {
116
- const root = canvas.getByTestId("root").firstChild;
117
- const item = root?.firstChild;
118
- expect(root).toHaveClass("test-classname");
119
- expect(root).toHaveAttribute("id", "test-id");
120
- expect(item).toHaveClass("test-item-classname");
121
- expect(item).toHaveAttribute("id", "test-item-id");
122
- },
123
- };
124
- export const edgeCases = {
125
- name: "test: edge cases",
126
- render: () => (<Example>
127
- <Example.Item title={[
128
- "multiline subtitle",
129
- "should wrap the text correctly",
130
- "should display the connector correctly",
131
- ]}>
132
- <Demo activeId={0} subtitle="It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy"/>
133
- </Example.Item>
134
- </Example>),
135
- };
@@ -1,22 +0,0 @@
1
- import { StoryObj } from "@storybook/react-vite";
2
- import { fn } from "storybook/test";
3
- declare const _default: {
4
- title: string;
5
- component: import("react").FC<import("./..").SwitchProps>;
6
- parameters: {
7
- iframe: {
8
- url: string;
9
- };
10
- };
11
- };
12
- export default _default;
13
- export declare const size: () => import("react").JSX.Element;
14
- export declare const label: () => import("react").JSX.Element;
15
- export declare const defaultChecked: StoryObj<{
16
- handleChange: ReturnType<typeof fn>;
17
- }>;
18
- export declare const checked: StoryObj<{
19
- handleChange: ReturnType<typeof fn>;
20
- }>;
21
- export declare const disabled: StoryObj;
22
- export declare const className: StoryObj;
@@ -1,137 +0,0 @@
1
- import { Example } from "../../../utilities/storybook/index.js";
2
- import Switch from "../index.js";
3
- import View from "../../View/index.js";
4
- import { expect, fn, userEvent } from "storybook/test";
5
- export default {
6
- title: "Components/Switch",
7
- component: Switch,
8
- parameters: {
9
- iframe: {
10
- url: "https://reshaped.so/docs/components/switch",
11
- },
12
- },
13
- };
14
- export const size = () => (<Example>
15
- <Example.Item title="size: medium">
16
- <Switch name="active" size="medium" inputAttributes={{ "aria-label": "test switch" }}/>
17
- </Example.Item>
18
- <Example.Item title="size: small">
19
- <Switch name="active" size="small" inputAttributes={{ "aria-label": "test switch" }}/>
20
- </Example.Item>
21
- <Example.Item title="size: large">
22
- <Switch name="active" size="large" inputAttributes={{ "aria-label": "test switch" }}/>
23
- </Example.Item>
24
- <Example.Item title="size: responsive, s: small, m: large">
25
- <Switch name="active" size={{ s: "small", m: "large" }} inputAttributes={{ "aria-label": "test switch" }}/>
26
- </Example.Item>
27
- </Example>);
28
- export const label = () => (<Example>
29
- <Example.Item title="size: medium">
30
- <View direction="row" gap={8}>
31
- <Switch name="active" inputAttributes={{ "aria-label": "test switch" }}>
32
- Wi-fi
33
- </Switch>
34
- <Switch reversed name="active" inputAttributes={{ "aria-label": "test switch" }}>
35
- Wi-fi
36
- </Switch>
37
- </View>
38
- </Example.Item>
39
- <Example.Item title="size: small">
40
- <View direction="row" gap={8}>
41
- <Switch name="active" size="small" inputAttributes={{ "aria-label": "test switch" }}>
42
- Wi-fi
43
- </Switch>
44
- <Switch reversed name="active" size="small" inputAttributes={{ "aria-label": "test switch" }}>
45
- Wi-fi
46
- </Switch>
47
- </View>
48
- </Example.Item>
49
-
50
- <Example.Item title="size: large">
51
- <View direction="row" gap={8}>
52
- <Switch name="active" size="large" inputAttributes={{ "aria-label": "test switch" }}>
53
- Wi-fi
54
- </Switch>
55
- <Switch reversed name="active" size="large" inputAttributes={{ "aria-label": "test switch" }}>
56
- Wi-fi
57
- </Switch>
58
- </View>
59
- </Example.Item>
60
- </Example>);
61
- export const defaultChecked = {
62
- name: "defaultChecked, uncontrolled",
63
- args: {
64
- handleChange: fn(),
65
- },
66
- render: (args) => (<Switch name="test-name" defaultChecked onChange={args.handleChange}>
67
- Label
68
- </Switch>),
69
- play: async ({ canvas, args }) => {
70
- const input = canvas.getByRole("checkbox");
71
- expect(input).toBeChecked();
72
- await userEvent.click(input);
73
- expect(args.handleChange).toBeCalledTimes(1);
74
- expect(args.handleChange).toHaveBeenCalledWith({
75
- name: "test-name",
76
- checked: false,
77
- event: expect.objectContaining({ target: input }),
78
- });
79
- expect(input).not.toBeChecked();
80
- },
81
- };
82
- export const checked = {
83
- name: "checked, uncontrolled",
84
- args: {
85
- handleChange: fn(),
86
- },
87
- render: (args) => (<Switch name="test-name" checked onChange={args.handleChange}>
88
- Label
89
- </Switch>),
90
- play: async ({ canvas, args }) => {
91
- const input = canvas.getByRole("checkbox");
92
- expect(input).toBeChecked();
93
- await userEvent.click(input);
94
- expect(args.handleChange).toBeCalledTimes(1);
95
- expect(args.handleChange).toHaveBeenCalledWith({
96
- name: "test-name",
97
- checked: false,
98
- event: expect.objectContaining({ target: input }),
99
- });
100
- expect(input).toBeChecked();
101
- },
102
- };
103
- export const disabled = {
104
- name: "disabled",
105
- render: () => (<Example>
106
- <Example.Item title="disabled, unselected">
107
- <Switch name="active" disabled inputAttributes={{ "aria-label": "test switch" }}/>
108
- </Example.Item>
109
- <Example.Item title="disabled, selected">
110
- <Switch name="active" disabled defaultChecked inputAttributes={{ "aria-label": "test switch" }}/>
111
- </Example.Item>
112
- <Example.Item title="disabled, with label">
113
- <Switch name="active" disabled>
114
- Switch
115
- </Switch>
116
- </Example.Item>
117
- </Example>),
118
- play: async ({ canvas }) => {
119
- const [input] = canvas.getAllByRole("checkbox");
120
- expect(input).toBeDisabled();
121
- },
122
- };
123
- export const className = {
124
- name: "className, attributes",
125
- render: () => (<div data-testid="root">
126
- <Switch className="test-classname" attributes={{ id: "test-id" }} inputAttributes={{ "aria-label": "test select", id: "test-input-id" }} name="name">
127
- Label
128
- </Switch>
129
- </div>),
130
- play: async ({ canvas }) => {
131
- const root = canvas.getByTestId("root").firstChild;
132
- const input = canvas.getByRole("checkbox");
133
- expect(root).toHaveClass("test-classname");
134
- expect(root).toHaveAttribute("id", "test-id");
135
- expect(input).toHaveAttribute("id", "test-input-id");
136
- },
137
- };
@@ -1,13 +0,0 @@
1
- declare const _default: {
2
- title: string;
3
- component: import("react").FC<import("./..").SwitchProps>;
4
- parameters: {
5
- iframe: {
6
- url: string;
7
- };
8
- chromatic: {
9
- disableSnapshot: boolean;
10
- };
11
- };
12
- };
13
- export default _default;
@@ -1,11 +0,0 @@
1
- import Switch from "../index.js";
2
- export default {
3
- title: "Components/Switch/tests",
4
- component: Switch,
5
- parameters: {
6
- iframe: {
7
- url: "https://reshaped.so/docs/components/switch",
8
- },
9
- chromatic: { disableSnapshot: true },
10
- },
11
- };
@@ -1,42 +0,0 @@
1
- import React from "react";
2
- import { StoryObj } from "@storybook/react-vite";
3
- declare const _default: {
4
- title: string;
5
- component: React.FC<import("./..").TableProps> & {
6
- Cell: typeof import("../Table").TableCell;
7
- Heading: typeof import("../Table").TableHeading;
8
- Row: typeof import("../Table").TableRow;
9
- Body: typeof import("../Table").TableBody;
10
- Head: typeof import("../Table").TableHead;
11
- };
12
- parameters: {
13
- iframe: {
14
- url: string;
15
- };
16
- };
17
- };
18
- export default _default;
19
- export declare const layout: {
20
- name: string;
21
- render: () => React.JSX.Element;
22
- };
23
- export declare const border: {
24
- name: string;
25
- render: () => React.JSX.Element;
26
- };
27
- export declare const rows: {
28
- name: string;
29
- render: () => React.JSX.Element;
30
- };
31
- export declare const render: StoryObj;
32
- export declare const tbody: StoryObj;
33
- export declare const tabIndex: StoryObj;
34
- export declare const className: StoryObj;
35
- export declare const edgeCases: {
36
- name: string;
37
- render: () => React.JSX.Element;
38
- };
39
- export declare const examples: {
40
- name: string;
41
- render: () => React.JSX.Element;
42
- };