reshaped 3.8.0-canary.7 → 3.8.0-canary.9

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 (214) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/bundle.css +1 -1
  3. package/dist/bundle.js +9 -9
  4. package/dist/components/Accordion/AccordionControlled.js +1 -0
  5. package/dist/components/Actionable/Actionable.js +1 -0
  6. package/dist/components/Actionable/Actionable.module.css +1 -1
  7. package/dist/components/Alert/tests/Alert.stories.d.ts +6 -5
  8. package/dist/components/Alert/tests/Alert.stories.js +15 -2
  9. package/dist/components/Badge/Badge.module.css +1 -1
  10. package/dist/components/Badge/tests/Badge.stories.d.ts +5 -0
  11. package/dist/components/Badge/tests/Badge.stories.js +34 -0
  12. package/dist/components/Breadcrumbs/Breadcrumbs.js +1 -0
  13. package/dist/components/Breadcrumbs/tests/Breadcrumbs.stories.d.ts +8 -4
  14. package/dist/components/Breadcrumbs/tests/Breadcrumbs.stories.js +57 -1
  15. package/dist/components/Button/tests/Button.stories.d.ts +54 -12
  16. package/dist/components/Button/tests/Button.stories.js +725 -588
  17. package/dist/components/Calendar/CalendarMonth.js +1 -0
  18. package/dist/components/Card/Card.module.css +1 -1
  19. package/dist/components/Card/tests/Card.stories.d.ts +28 -6
  20. package/dist/components/Card/tests/Card.stories.js +110 -65
  21. package/dist/components/Carousel/Carousel.js +1 -0
  22. package/dist/components/Carousel/Carousel.module.css +1 -1
  23. package/dist/components/Checkbox/Checkbox.module.css +1 -1
  24. package/dist/components/Checkbox/tests/Checkbox.stories.d.ts +20 -4
  25. package/dist/components/Checkbox/tests/Checkbox.stories.js +150 -79
  26. package/dist/components/CheckboxGroup/tests/CheckboxGroup.stories.d.ts +9 -2
  27. package/dist/components/CheckboxGroup/tests/CheckboxGroup.stories.js +67 -35
  28. package/dist/components/Container/tests/Container.stories.d.ts +2 -0
  29. package/dist/components/Container/tests/Container.stories.js +14 -0
  30. package/dist/components/ContextMenu/tests/ContextMenu.stories.d.ts +10 -1
  31. package/dist/components/ContextMenu/tests/ContextMenu.stories.js +57 -13
  32. package/dist/components/Dismissible/tests/Dismissible.stories.d.ts +5 -0
  33. package/dist/components/Dismissible/tests/Dismissible.stories.js +30 -1
  34. package/dist/components/Divider/tests/Divider.stories.d.ts +8 -3
  35. package/dist/components/Divider/tests/Divider.stories.js +71 -41
  36. package/dist/components/DropdownMenu/tests/DropdownMenu.stories.d.ts +35 -6
  37. package/dist/components/DropdownMenu/tests/DropdownMenu.stories.js +222 -115
  38. package/dist/components/DropdownMenu/tests/DropdownMenu.test.stories.d.ts +0 -15
  39. package/dist/components/DropdownMenu/tests/DropdownMenu.test.stories.js +0 -106
  40. package/dist/components/FileUpload/FileUpload.module.css +1 -1
  41. package/dist/components/Flyout/Flyout.module.css +1 -1
  42. package/dist/components/Flyout/FlyoutContent.js +3 -0
  43. package/dist/components/Flyout/FlyoutControlled.js +6 -1
  44. package/dist/components/Flyout/utilities/flyout.js +0 -1
  45. package/dist/components/FormControl/FormControl.context.d.ts +1 -1
  46. package/dist/components/FormControl/tests/FormControl.stories.d.ts +2 -0
  47. package/dist/components/FormControl/tests/FormControl.stories.js +35 -0
  48. package/dist/components/Hidden/tests/Hidden.stories.d.ts +2 -0
  49. package/dist/components/Hidden/tests/Hidden.stories.js +9 -0
  50. package/dist/components/HiddenVisually/tests/HiddenVisually.stories.d.ts +2 -0
  51. package/dist/components/HiddenVisually/tests/HiddenVisually.stories.js +9 -0
  52. package/dist/components/Hotkey/tests/Hotkey.stories.d.ts +2 -0
  53. package/dist/components/Hotkey/tests/Hotkey.stories.js +15 -0
  54. package/dist/components/Icon/tests/Icon.stories.d.ts +3 -0
  55. package/dist/components/Icon/tests/Icon.stories.js +23 -0
  56. package/dist/components/Link/tests/Link.stories.d.ts +28 -5
  57. package/dist/components/Link/tests/Link.stories.js +141 -58
  58. package/dist/components/Link/tests/Link.test.stories.d.ts +0 -13
  59. package/dist/components/Link/tests/Link.test.stories.js +0 -85
  60. package/dist/components/Loader/tests/Loader.stories.d.ts +11 -2
  61. package/dist/components/Loader/tests/Loader.stories.js +52 -25
  62. package/dist/components/Loader/tests/Loader.test.stories.d.ts +0 -3
  63. package/dist/components/Loader/tests/Loader.test.stories.js +0 -21
  64. package/dist/components/MenuItem/tests/MenuItem.stories.d.ts +37 -7
  65. package/dist/components/MenuItem/tests/MenuItem.stories.js +218 -112
  66. package/dist/components/Modal/Modal.js +1 -1
  67. package/dist/components/Modal/Modal.module.css +1 -1
  68. package/dist/components/Modal/tests/Modal.stories.d.ts +53 -10
  69. package/dist/components/Modal/tests/Modal.stories.js +366 -214
  70. package/dist/components/Overlay/Overlay.js +1 -0
  71. package/dist/components/Overlay/tests/Overlay.stories.d.ts +15 -1
  72. package/dist/components/Overlay/tests/Overlay.stories.js +135 -1
  73. package/dist/components/Pagination/tests/Pagination.stories.d.ts +14 -1
  74. package/dist/components/Pagination/tests/Pagination.stories.js +93 -15
  75. package/dist/components/PinField/tests/PinField.stories.d.ts +1 -1
  76. package/dist/components/PinField/tests/PinField.stories.js +1 -1
  77. package/dist/components/Popover/Popover.module.css +1 -1
  78. package/dist/components/Progress/tests/Progress.stories.d.ts +19 -4
  79. package/dist/components/Progress/tests/Progress.stories.js +85 -49
  80. package/dist/components/Radio/Radio.module.css +1 -1
  81. package/dist/components/Radio/tests/Radio.stories.d.ts +25 -4
  82. package/dist/components/Radio/tests/Radio.stories.js +147 -65
  83. package/dist/components/RadioGroup/tests/RadioGroup.stories.d.ts +9 -2
  84. package/dist/components/RadioGroup/tests/RadioGroup.stories.js +64 -38
  85. package/dist/components/Reshaped/Reshaped.css +1 -1
  86. package/dist/components/Scrim/tests/Scrim.stories.d.ts +10 -2
  87. package/dist/components/Scrim/tests/Scrim.stories.js +51 -31
  88. package/dist/components/ScrollArea/ScrollArea.module.css +1 -1
  89. package/dist/components/Select/Select.module.css +1 -1
  90. package/dist/components/Select/Select.types.d.ts +38 -11
  91. package/dist/components/Select/SelectCustom.js +2 -1
  92. package/dist/components/Select/SelectCustomControlled.js +24 -9
  93. package/dist/components/Select/SelectCustomUncontrolled.js +10 -7
  94. package/dist/components/Select/SelectTrigger.js +1 -1
  95. package/dist/components/Select/tests/Select.stories.d.ts +3 -0
  96. package/dist/components/Select/tests/Select.stories.js +91 -34
  97. package/dist/components/Skeleton/tests/Skeleton.stories.d.ts +10 -2
  98. package/dist/components/Skeleton/tests/Skeleton.stories.js +46 -28
  99. package/dist/components/Slider/Slider.module.css +1 -1
  100. package/dist/components/Stepper/tests/Stepper.stories.d.ts +18 -4
  101. package/dist/components/Stepper/tests/Stepper.stories.js +99 -70
  102. package/dist/components/Switch/Switch.module.css +1 -1
  103. package/dist/components/Switch/tests/Switch.stories.d.ts +10 -2
  104. package/dist/components/Switch/tests/Switch.stories.js +77 -23
  105. package/dist/components/Switch/tests/Switch.test.stories.d.ts +0 -10
  106. package/dist/components/Switch/tests/Switch.test.stories.js +0 -68
  107. package/dist/components/Table/Table.module.css +1 -1
  108. package/dist/components/Table/tests/Table.stories.d.ts +25 -5
  109. package/dist/components/Table/tests/Table.stories.js +274 -177
  110. package/dist/components/Table/tests/Table.test.stories.d.ts +0 -5
  111. package/dist/components/Table/tests/Table.test.stories.js +0 -82
  112. package/dist/components/Tabs/Tabs.module.css +1 -1
  113. package/dist/components/Tabs/TabsControlled.js +1 -0
  114. package/dist/components/TextArea/TextArea.module.css +1 -1
  115. package/dist/components/TextArea/tests/TextArea.stories.d.ts +41 -9
  116. package/dist/components/TextArea/tests/TextArea.stories.js +179 -93
  117. package/dist/components/TextField/TextField.js +1 -1
  118. package/dist/components/TextField/TextField.module.css +1 -1
  119. package/dist/components/TextField/tests/TextField.stories.d.ts +41 -11
  120. package/dist/components/TextField/tests/TextField.stories.js +206 -132
  121. package/dist/components/TextField/tests/TextField.test.stories.d.ts +0 -13
  122. package/dist/components/TextField/tests/TextField.test.stories.js +0 -88
  123. package/dist/components/Theme/Theme.module.css +1 -1
  124. package/dist/components/Timeline/tests/Timeline.stories.d.ts +10 -2
  125. package/dist/components/Timeline/tests/Timeline.stories.js +69 -42
  126. package/dist/components/Timeline/tests/Timeline.test.stories.d.ts +0 -2
  127. package/dist/components/Timeline/tests/Timeline.test.stories.js +0 -21
  128. package/dist/components/Toast/ToastContainer.js +1 -0
  129. package/dist/components/Toast/ToastRegion.js +1 -0
  130. package/dist/components/Toast/tests/Toast.stories.d.ts +32 -8
  131. package/dist/components/Toast/tests/Toast.stories.js +111 -37
  132. package/dist/components/ToggleButtonGroup/ToggleButtonGroupControlled.js +1 -0
  133. package/dist/components/Tooltip/tests/Tooltip.stories.d.ts +18 -4
  134. package/dist/components/Tooltip/tests/Tooltip.stories.js +139 -107
  135. package/dist/components/Tooltip/tests/Tooltip.test.stories.d.ts +0 -6
  136. package/dist/components/Tooltip/tests/Tooltip.test.stories.js +0 -29
  137. package/dist/components/View/View.js +1 -0
  138. package/dist/components/View/tests/View.stories.d.ts +4 -0
  139. package/dist/components/View/tests/View.stories.js +39 -0
  140. package/dist/components/_private/Expandable/Expandable.js +3 -1
  141. package/dist/components/_private/Portal/Portal.js +4 -1
  142. package/dist/hooks/_private/usePrevious.js +1 -0
  143. package/dist/hooks/tests/useDrag.stories.js +1 -1
  144. package/dist/styles/resolvers/align/align.css +1 -1
  145. package/dist/styles/resolvers/aspectRatio/aspectRatio.css +1 -1
  146. package/dist/styles/resolvers/bleed/bleed.module.css +1 -1
  147. package/dist/styles/resolvers/justify/justify.css +1 -1
  148. package/dist/styles/resolvers/maxHeight/maxHeight.module.css +1 -1
  149. package/dist/styles/resolvers/maxWidth/maxWidth.module.css +1 -1
  150. package/dist/styles/resolvers/minHeight/minHeight.module.css +1 -1
  151. package/dist/styles/resolvers/minWidth/minWidth.module.css +1 -1
  152. package/dist/styles/resolvers/position/position.css +1 -1
  153. package/dist/styles/resolvers/textAlign/textAlign.css +1 -1
  154. package/dist/styles/resolvers/width/width.module.css +1 -1
  155. package/dist/utilities/scroll/disable.js +2 -2
  156. package/package.json +21 -21
  157. package/dist/components/Alert/tests/Alert.test.stories.d.ts +0 -15
  158. package/dist/components/Alert/tests/Alert.test.stories.js +0 -26
  159. package/dist/components/Badge/tests/Badge.test.stories.d.ts +0 -20
  160. package/dist/components/Badge/tests/Badge.test.stories.js +0 -46
  161. package/dist/components/Breadcrumbs/tests/Breadcrumbs.test.stories.d.ts +0 -23
  162. package/dist/components/Breadcrumbs/tests/Breadcrumbs.test.stories.js +0 -76
  163. package/dist/components/Button/tests/Button.test.stories.d.ts +0 -28
  164. package/dist/components/Button/tests/Button.test.stories.js +0 -135
  165. package/dist/components/Card/tests/Card.test.stories.d.ts +0 -35
  166. package/dist/components/Card/tests/Card.test.stories.js +0 -54
  167. package/dist/components/Checkbox/tests/Checkbox.test.stories.d.ts +0 -25
  168. package/dist/components/Checkbox/tests/Checkbox.test.stories.js +0 -104
  169. package/dist/components/CheckboxGroup/tests/CheckboxGroup.test.stories.d.ts +0 -22
  170. package/dist/components/CheckboxGroup/tests/CheckboxGroup.test.stories.js +0 -78
  171. package/dist/components/Container/tests/Container.test.stories.d.ts +0 -15
  172. package/dist/components/Container/tests/Container.test.stories.js +0 -26
  173. package/dist/components/ContextMenu/tests/ContextMenu.test.stories.d.ts +0 -25
  174. package/dist/components/ContextMenu/tests/ContextMenu.test.stories.js +0 -53
  175. package/dist/components/Dismissible/tests/Dismissible.test.stories.d.ts +0 -19
  176. package/dist/components/Dismissible/tests/Dismissible.test.stories.js +0 -42
  177. package/dist/components/Divider/tests/Divider.test.stories.d.ts +0 -18
  178. package/dist/components/Divider/tests/Divider.test.stories.js +0 -47
  179. package/dist/components/FormControl/tests/FormControl.test.stories.d.ts +0 -20
  180. package/dist/components/FormControl/tests/FormControl.test.stories.js +0 -49
  181. package/dist/components/Hidden/tests/Hidden.test.stories.d.ts +0 -15
  182. package/dist/components/Hidden/tests/Hidden.test.stories.js +0 -20
  183. package/dist/components/HiddenVisually/tests/HiddenVisually.test.stories.d.ts +0 -15
  184. package/dist/components/HiddenVisually/tests/HiddenVisually.test.stories.js +0 -20
  185. package/dist/components/Hotkey/tests/Hotkey.test.stories.d.ts +0 -15
  186. package/dist/components/Hotkey/tests/Hotkey.test.stories.js +0 -26
  187. package/dist/components/Icon/tests/Icon.test.stories.d.ts +0 -16
  188. package/dist/components/Icon/tests/Icon.test.stories.js +0 -35
  189. package/dist/components/MenuItem/tests/MenuItem.test.stories.d.ts +0 -27
  190. package/dist/components/MenuItem/tests/MenuItem.test.stories.js +0 -116
  191. package/dist/components/Modal/tests/Modal.test.stories.d.ts +0 -31
  192. package/dist/components/Modal/tests/Modal.test.stories.js +0 -149
  193. package/dist/components/Overlay/tests/Overlay.test.stories.d.ts +0 -28
  194. package/dist/components/Overlay/tests/Overlay.test.stories.js +0 -148
  195. package/dist/components/Pagination/tests/Pagination.test.stories.d.ts +0 -23
  196. package/dist/components/Pagination/tests/Pagination.test.stories.js +0 -86
  197. package/dist/components/Progress/tests/Progress.test.stories.d.ts +0 -16
  198. package/dist/components/Progress/tests/Progress.test.stories.js +0 -35
  199. package/dist/components/Radio/tests/Radio.test.stories.d.ts +0 -30
  200. package/dist/components/Radio/tests/Radio.test.stories.js +0 -118
  201. package/dist/components/RadioGroup/tests/RadioGroup.test.stories.d.ts +0 -22
  202. package/dist/components/RadioGroup/tests/RadioGroup.test.stories.js +0 -78
  203. package/dist/components/Scrim/tests/Scrim.test.stories.d.ts +0 -15
  204. package/dist/components/Scrim/tests/Scrim.test.stories.js +0 -25
  205. package/dist/components/Skeleton/tests/Skeleton.test.stories.d.ts +0 -15
  206. package/dist/components/Skeleton/tests/Skeleton.test.stories.js +0 -23
  207. package/dist/components/Stepper/tests/Stepper.test.stories.d.ts +0 -20
  208. package/dist/components/Stepper/tests/Stepper.test.stories.js +0 -28
  209. package/dist/components/TextArea/tests/TextArea.test.stories.d.ts +0 -28
  210. package/dist/components/TextArea/tests/TextArea.test.stories.js +0 -99
  211. package/dist/components/Toast/tests/Toast.test.stories.d.ts +0 -16
  212. package/dist/components/Toast/tests/Toast.test.stories.js +0 -101
  213. package/dist/components/View/tests/View.test.stories.d.ts +0 -24
  214. package/dist/components/View/tests/View.test.stories.js +0 -50
@@ -1,148 +0,0 @@
1
- import React from "react";
2
- import { within, expect, fn, userEvent, waitFor } from "storybook/test";
3
- import Button from "../../Button/index.js";
4
- import Overlay from "../index.js";
5
- import useToggle from "../../../hooks/useToggle.js";
6
- import { sleep } from "../../../utilities/helpers.js";
7
- export default {
8
- title: "Utility components/Overlay/tests",
9
- component: Overlay,
10
- parameters: {
11
- iframe: {
12
- url: "https://reshaped.so/docs/utilities/overlay",
13
- },
14
- chromatic: { disableSnapshot: true },
15
- },
16
- };
17
- export const renderProps = {
18
- name: "children, render props",
19
- render: () => (<Overlay active className="test-classname" attributes={{ "data-testid": "test-id" }}>
20
- {(args) => (args.active ? "Opened" : "Closed")}
21
- </Overlay>),
22
- play: async ({ canvasElement }) => {
23
- const canvas = within(canvasElement.ownerDocument.body);
24
- const root = canvas.getByText("Opened");
25
- expect(root).toBeInTheDocument();
26
- },
27
- };
28
- export const handlers = {
29
- name: "onOpen, onClose, onAfterOpen, onAfterClose",
30
- args: {
31
- handleOpen: fn(),
32
- handleClose: fn(),
33
- handleAfterClose: fn(),
34
- handleAfterOpen: fn(),
35
- },
36
- render: (args) => {
37
- const overlayToggle = useToggle();
38
- return (<>
39
- <Button onClick={() => overlayToggle.toggle()}>Open overlay</Button>
40
- <Overlay active={overlayToggle.active} onClose={(closeArgs) => {
41
- overlayToggle.deactivate();
42
- args.handleClose(closeArgs);
43
- }} onOpen={args.handleOpen} onAfterOpen={args.handleAfterOpen} onAfterClose={args.handleAfterClose}>
44
- Content
45
- </Overlay>
46
- </>);
47
- },
48
- play: async ({ canvasElement, args }) => {
49
- const canvas = within(canvasElement.ownerDocument.body);
50
- const trigger = canvas.getAllByRole("button")[0];
51
- let overlay;
52
- await userEvent.click(trigger);
53
- overlay = canvas.getByText("Content");
54
- await waitFor(() => {
55
- expect(args.handleOpen).toHaveBeenCalledTimes(1);
56
- expect(args.handleOpen).toHaveBeenCalledWith();
57
- });
58
- // Wait for transition
59
- await waitFor(() => {
60
- expect(args.handleAfterOpen).toHaveBeenCalledTimes(1);
61
- expect(args.handleAfterOpen).toHaveBeenCalledWith();
62
- });
63
- // Close by changing the state after the trigger click
64
- await userEvent.click(trigger);
65
- // Changing state doesn't trigger onClose
66
- expect(args.handleClose).toHaveBeenCalledTimes(0);
67
- // Wait for transition
68
- await waitFor(() => {
69
- expect(args.handleAfterClose).toHaveBeenCalledTimes(1);
70
- expect(args.handleAfterClose).toHaveBeenCalledWith();
71
- });
72
- // Open
73
- await userEvent.click(trigger);
74
- overlay = canvas.getByText("Content");
75
- // TODO: Fails CLI tests in Storybook without a timeout
76
- await sleep(100);
77
- // Close by clicking on the overlay
78
- await userEvent.click(overlay);
79
- expect(args.handleClose).toHaveBeenCalledTimes(1);
80
- expect(args.handleClose).toHaveBeenCalledWith({ reason: "overlay-click" });
81
- await waitFor(() => {
82
- expect(args.handleAfterClose).toHaveBeenCalledTimes(2);
83
- expect(args.handleAfterClose).toHaveBeenCalledWith();
84
- });
85
- // Open
86
- await userEvent.click(trigger);
87
- // TODO: Fails CLI tests in Storybook without a timeout
88
- await sleep(100);
89
- // Close by pressing Escape
90
- await userEvent.keyboard("{Escape}");
91
- expect(args.handleClose).toHaveBeenCalledTimes(2);
92
- expect(args.handleClose).toHaveBeenCalledWith({ reason: "escape-key" });
93
- await waitFor(() => {
94
- expect(args.handleAfterClose).toHaveBeenCalledTimes(3);
95
- expect(args.handleAfterClose).toHaveBeenCalledWith();
96
- });
97
- },
98
- };
99
- export const disableCloseOnClick = {
100
- name: "disableCloseOnClick",
101
- args: {
102
- handleClose: fn(),
103
- },
104
- render: (args) => (<Overlay active disableCloseOnClick onClose={(closeArgs) => {
105
- args.handleClose(closeArgs);
106
- }}>
107
- Content
108
- </Overlay>),
109
- play: async ({ canvasElement, args }) => {
110
- const canvas = within(canvasElement.ownerDocument.body);
111
- const overlay = canvas.getByText("Content");
112
- await userEvent.click(overlay);
113
- // TODO: Fails CLI tests in Storybook without a timeout
114
- await sleep(100);
115
- expect(args.handleClose).toHaveBeenCalledTimes(0);
116
- await userEvent.keyboard("{Escape}");
117
- expect(args.handleClose).toHaveBeenCalledTimes(1);
118
- },
119
- };
120
- export const containerRef = {
121
- name: "containerRef",
122
- render: () => {
123
- const containerRef = React.useRef(null);
124
- return (<>
125
- <div ref={containerRef} data-testid="test-id" style={{ height: 200 }}/>
126
- <Overlay active containerRef={containerRef}>
127
- Content
128
- </Overlay>
129
- </>);
130
- },
131
- play: ({ canvasElement }) => {
132
- const canvas = within(canvasElement.ownerDocument.body);
133
- const container = canvas.getByTestId("test-id");
134
- const overlay = canvas.getByText("Content");
135
- expect(container).toContainElement(overlay);
136
- },
137
- };
138
- export const className = {
139
- name: "className, attributes",
140
- render: () => (<Overlay active className="test-classname" attributes={{ "data-testid": "test-id" }}>
141
- Content
142
- </Overlay>),
143
- play: async ({ canvasElement }) => {
144
- const canvas = within(canvasElement.ownerDocument.body);
145
- const root = canvas.getByTestId("test-id");
146
- expect(root).toHaveClass("test-classname");
147
- },
148
- };
@@ -1,23 +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("./..").PaginationProps>;
6
- parameters: {
7
- iframe: {
8
- url: string;
9
- };
10
- chromatic: {
11
- disableSnapshot: boolean;
12
- };
13
- };
14
- };
15
- export default _default;
16
- export declare const render: StoryObj;
17
- export declare const defaultPage: StoryObj<{
18
- handleChange: ReturnType<typeof fn>;
19
- }>;
20
- export declare const page: StoryObj<{
21
- handleChange: ReturnType<typeof fn>;
22
- }>;
23
- export declare const className: StoryObj;
@@ -1,86 +0,0 @@
1
- import { expect, within, fn, userEvent } from "storybook/test";
2
- import Pagination from "../index.js";
3
- export default {
4
- title: "Components/Pagination/tests",
5
- component: Pagination,
6
- parameters: {
7
- iframe: {
8
- url: "https://reshaped.so/docs/components/pagination",
9
- },
10
- chromatic: { disableSnapshot: true },
11
- },
12
- };
13
- export const render = {
14
- name: "rendering",
15
- render: () => (<div data-testid="root">
16
- <Pagination total={10} previousAriaLabel="Previous" nextAriaLabel="Next" pageAriaLabel={(args) => `Page ${args.page}`}/>
17
- </div>),
18
- play: async ({ canvas }) => {
19
- const root = within(canvas.getByTestId("root"));
20
- const buttons = root.getAllByRole("button");
21
- const pages = buttons.slice(1, -1);
22
- const prevButton = root.getByLabelText("Previous");
23
- const nextButton = root.getByLabelText("Next");
24
- const firstPageButton = root.getByLabelText("Page 1");
25
- expect(buttons.length).toBe(8);
26
- expect(prevButton).toEqual(buttons[0]);
27
- expect(prevButton).toBeDisabled();
28
- expect(nextButton).toEqual(buttons.at(-1));
29
- expect(nextButton).not.toBeDisabled();
30
- expect(firstPageButton).toBeInTheDocument();
31
- expect(firstPageButton).toEqual(pages[0]);
32
- expect(firstPageButton).toHaveAttribute("aria-current", "true");
33
- },
34
- };
35
- export const defaultPage = {
36
- name: "defaultPage, uncontrolled",
37
- args: {
38
- handleChange: fn(),
39
- },
40
- render: (args) => (<div data-testid="root">
41
- <Pagination total={10} defaultPage={2} onChange={args.handleChange} previousAriaLabel="Previous" nextAriaLabel="Next"/>
42
- </div>),
43
- play: async ({ canvas, args }) => {
44
- const root = within(canvas.getByTestId("root"));
45
- const buttons = root.getAllByRole("button");
46
- const pages = buttons.slice(1, -1);
47
- expect(pages[1]).toHaveAttribute("aria-current");
48
- await userEvent.click(pages[2]);
49
- expect(args.handleChange).toHaveBeenCalledTimes(1);
50
- expect(args.handleChange).toHaveBeenCalledWith({ page: 3 });
51
- expect(pages[1]).toHaveAttribute("aria-current", "false");
52
- expect(pages[2]).toHaveAttribute("aria-current", "true");
53
- },
54
- };
55
- export const page = {
56
- name: "page, controlled",
57
- args: {
58
- handleChange: fn(),
59
- },
60
- render: (args) => (<div data-testid="root">
61
- <Pagination total={10} page={2} onChange={args.handleChange} previousAriaLabel="Previous" nextAriaLabel="Next"/>
62
- </div>),
63
- play: async ({ canvas, args }) => {
64
- const root = within(canvas.getByTestId("root"));
65
- const buttons = root.getAllByRole("button");
66
- const pages = buttons.slice(1, -1);
67
- expect(pages[1]).toHaveAttribute("aria-current");
68
- await userEvent.click(pages[2]);
69
- expect(args.handleChange).toHaveBeenCalledTimes(1);
70
- expect(args.handleChange).toHaveBeenCalledWith({ page: 3 });
71
- // Stays the same because it's controlled
72
- expect(pages[1]).toHaveAttribute("aria-current", "true");
73
- expect(pages[2]).toHaveAttribute("aria-current", "false");
74
- },
75
- };
76
- export const className = {
77
- name: "className, attributes",
78
- render: () => (<div data-testid="root">
79
- <Pagination className="test-classname" attributes={{ id: "test-id" }} total={10} previousAriaLabel="Previous" nextAriaLabel="Next"/>
80
- </div>),
81
- play: async ({ canvas }) => {
82
- const root = canvas.getByTestId("root").firstChild;
83
- expect(root).toHaveClass("test-classname");
84
- expect(root).toHaveAttribute("id", "test-id");
85
- },
86
- };
@@ -1,16 +0,0 @@
1
- import { StoryObj } from "@storybook/react-vite";
2
- declare const _default: {
3
- title: string;
4
- component: import("react").FC<import("./..").ProgressProps>;
5
- parameters: {
6
- iframe: {
7
- url: string;
8
- };
9
- chromatic: {
10
- disableSnapshot: boolean;
11
- };
12
- };
13
- };
14
- export default _default;
15
- export declare const render: StoryObj;
16
- export declare const className: StoryObj;
@@ -1,35 +0,0 @@
1
- import { expect } from "storybook/test";
2
- import Progress from "../index.js";
3
- export default {
4
- title: "Components/Progress/tests",
5
- component: Progress,
6
- parameters: {
7
- iframe: {
8
- url: "https://reshaped.so/docs/components/progress",
9
- },
10
- chromatic: { disableSnapshot: true },
11
- },
12
- };
13
- export const render = {
14
- name: "rendering",
15
- render: () => <Progress value={75} min={50} max={100} ariaLabel="progress"/>,
16
- play: async ({ canvas }) => {
17
- const el = canvas.getByRole("progressbar");
18
- expect(el).toBeInTheDocument();
19
- expect(el).toHaveAttribute("aria-valuenow", "75");
20
- expect(el).toHaveAttribute("aria-valuemin", "50");
21
- expect(el).toHaveAttribute("aria-valuemax", "100");
22
- expect(el).toHaveAccessibleName("progress");
23
- },
24
- };
25
- export const className = {
26
- name: "className, attributes",
27
- render: () => (<div data-testid="root">
28
- <Progress className="test-classname" attributes={{ id: "test-id" }} ariaLabel="progress"/>
29
- </div>),
30
- play: async ({ canvas }) => {
31
- const root = canvas.getByTestId("root").firstChild;
32
- expect(root).toHaveClass("test-classname");
33
- expect(root).toHaveAttribute("id", "test-id");
34
- },
35
- };
@@ -1,30 +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("./..").RadioProps>;
6
- parameters: {
7
- iframe: {
8
- url: string;
9
- };
10
- chromatic: {
11
- disableSnapshot: boolean;
12
- };
13
- };
14
- };
15
- export default _default;
16
- export declare const render: StoryObj;
17
- export declare const checked: StoryObj<{
18
- handleChange: ReturnType<typeof fn>;
19
- }>;
20
- export declare const checkedFalse: StoryObj<{
21
- handleChange: ReturnType<typeof fn>;
22
- }>;
23
- export declare const defaultChecked: StoryObj<{
24
- handleChange: ReturnType<typeof fn>;
25
- }>;
26
- export declare const defaultCheckedFalse: StoryObj<{
27
- handleChange: ReturnType<typeof fn>;
28
- }>;
29
- export declare const disabled: StoryObj;
30
- export declare const className: StoryObj;
@@ -1,118 +0,0 @@
1
- import { expect, userEvent, fn } from "storybook/test";
2
- import Radio from "../index.js";
3
- export default {
4
- title: "Components/Radio/tests",
5
- component: Radio,
6
- parameters: {
7
- iframe: {
8
- url: "https://reshaped.so/docs/components/radio",
9
- },
10
- chromatic: { disableSnapshot: true },
11
- },
12
- };
13
- export const render = {
14
- name: "name, value",
15
- render: () => (<Radio name="test-name" value="test-value">
16
- Content
17
- </Radio>),
18
- play: async ({ canvas }) => {
19
- const input = canvas.getByRole("radio");
20
- expect(input).toHaveAttribute("value", "test-value");
21
- expect(input).toHaveAttribute("name", "test-name");
22
- expect(input).not.toBeChecked();
23
- },
24
- };
25
- export const checked = {
26
- name: "checked, controlled",
27
- args: {
28
- handleChange: fn(),
29
- },
30
- render: (args) => (<Radio name="test-name" value="test-value" checked onChange={args.handleChange}>
31
- Content
32
- </Radio>),
33
- play: async ({ canvas, args }) => {
34
- const input = canvas.getByRole("radio");
35
- expect(input).toBeChecked();
36
- },
37
- };
38
- export const checkedFalse = {
39
- name: "checked false, controlled",
40
- args: {
41
- handleChange: fn(),
42
- },
43
- render: (args) => (<Radio name="test-name" value="test-value" checked={false} onChange={args.handleChange}>
44
- Content
45
- </Radio>),
46
- play: async ({ canvas, args }) => {
47
- const input = canvas.getByRole("radio");
48
- expect(input).not.toBeChecked();
49
- await userEvent.click(input);
50
- expect(args.handleChange).toHaveBeenCalledTimes(1);
51
- expect(args.handleChange).toHaveBeenCalledWith({
52
- name: "test-name",
53
- value: "test-value",
54
- checked: true,
55
- event: expect.objectContaining({ target: input }),
56
- });
57
- // Still not checked because it's controlled
58
- expect(input).not.toBeChecked();
59
- },
60
- };
61
- export const defaultChecked = {
62
- name: "defaultChecked, uncontrolled",
63
- args: {
64
- handleChange: fn(),
65
- },
66
- render: (args) => (<Radio name="test-name" value="test-value" defaultChecked onChange={args.handleChange}>
67
- Content
68
- </Radio>),
69
- play: async ({ canvas, args }) => {
70
- const input = canvas.getByRole("radio");
71
- expect(input).toBeChecked();
72
- },
73
- };
74
- export const defaultCheckedFalse = {
75
- name: "defaultChecked false, uncontrolled",
76
- args: {
77
- handleChange: fn(),
78
- },
79
- render: (args) => (<Radio name="test-name" value="test-value" onChange={args.handleChange}>
80
- Content
81
- </Radio>),
82
- play: async ({ canvas, args }) => {
83
- const input = canvas.getByRole("radio");
84
- expect(input).not.toBeChecked();
85
- await userEvent.click(input);
86
- expect(args.handleChange).toHaveBeenCalledTimes(1);
87
- expect(args.handleChange).toHaveBeenCalledWith({
88
- name: "test-name",
89
- value: "test-value",
90
- checked: true,
91
- event: expect.objectContaining({ target: input }),
92
- });
93
- expect(input).toBeChecked();
94
- },
95
- };
96
- export const disabled = {
97
- name: "disabled",
98
- render: () => (<Radio name="test-name" value="test-value" disabled>
99
- Content
100
- </Radio>),
101
- play: async ({ canvas }) => {
102
- const input = canvas.getByRole("radio");
103
- expect(input).toBeDisabled();
104
- },
105
- };
106
- export const className = {
107
- name: "className, attributes",
108
- render: () => (<div data-testid="root">
109
- <Radio className="test-classname" attributes={{ id: "test-id" }} value="value">
110
- Content
111
- </Radio>
112
- </div>),
113
- play: async ({ canvas }) => {
114
- const root = canvas.getByTestId("root").firstChild;
115
- expect(root).toHaveClass("test-classname");
116
- expect(root).toHaveAttribute("id", "test-id");
117
- },
118
- };
@@ -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("./..").RadioGroupProps>;
6
- parameters: {
7
- iframe: {
8
- url: string;
9
- };
10
- chromatic: {
11
- disableSnapshot: boolean;
12
- };
13
- };
14
- };
15
- export default _default;
16
- export declare const value: StoryObj<{
17
- handleChange: ReturnType<typeof fn>;
18
- }>;
19
- export declare const defaultValue: StoryObj<{
20
- handleChange: ReturnType<typeof fn>;
21
- }>;
22
- export declare const disabled: StoryObj;
@@ -1,78 +0,0 @@
1
- import { fn, userEvent, expect } from "storybook/test";
2
- import RadioGroup from "../index.js";
3
- import Radio from "../../Radio/index.js";
4
- export default {
5
- title: "Components/RadioGroup/tests",
6
- component: RadioGroup,
7
- parameters: {
8
- iframe: {
9
- url: "https://reshaped.so/docs/components/radio",
10
- },
11
- chromatic: { disableSnapshot: true },
12
- },
13
- };
14
- export const value = {
15
- name: "value, controlled",
16
- args: {
17
- handleChange: fn(),
18
- },
19
- render: (args) => (<RadioGroup name="test-name" value="1" onChange={args.handleChange}>
20
- {/* checked should be ignored */}
21
- <Radio value="1" checked={false}>
22
- Content
23
- </Radio>
24
-
25
- <Radio value="2">Content 2</Radio>
26
- </RadioGroup>),
27
- play: async ({ canvas, args }) => {
28
- const inputs = canvas.getAllByRole("radio");
29
- expect(inputs[0]).toBeChecked();
30
- await userEvent.click(inputs[1]);
31
- expect(args.handleChange).toHaveBeenCalledTimes(1);
32
- expect(args.handleChange).toHaveBeenCalledWith({
33
- name: "test-name",
34
- value: "2",
35
- event: expect.objectContaining({ target: inputs[1] }),
36
- });
37
- // Still checked because it's controlled
38
- expect(inputs[0]).toBeChecked();
39
- expect(inputs[1]).not.toBeChecked();
40
- },
41
- };
42
- export const defaultValue = {
43
- name: "defaultValue, uncontrolled",
44
- args: {
45
- handleChange: fn(),
46
- },
47
- render: (args) => (<RadioGroup name="test-name" defaultValue="1" onChange={args.handleChange}>
48
- {/* checked should be ignored */}
49
- <Radio value="1" checked={false}>
50
- Content
51
- </Radio>
52
-
53
- <Radio value="2">Content 2</Radio>
54
- </RadioGroup>),
55
- play: async ({ canvas, args }) => {
56
- const inputs = canvas.getAllByRole("radio");
57
- expect(inputs[0]).toBeChecked();
58
- await userEvent.click(inputs[1]);
59
- expect(args.handleChange).toHaveBeenCalledTimes(1);
60
- expect(args.handleChange).toHaveBeenCalledWith({
61
- name: "test-name",
62
- value: "2",
63
- event: expect.objectContaining({ target: inputs[1] }),
64
- });
65
- expect(inputs[0]).not.toBeChecked();
66
- expect(inputs[1]).toBeChecked();
67
- },
68
- };
69
- export const disabled = {
70
- name: "disabled",
71
- render: () => (<RadioGroup name="test-name" disabled>
72
- <Radio value="test-value">Content</Radio>
73
- </RadioGroup>),
74
- play: async ({ canvas }) => {
75
- const input = canvas.getByRole("radio");
76
- expect(input).toBeDisabled();
77
- },
78
- };
@@ -1,15 +0,0 @@
1
- import { StoryObj } from "@storybook/react-vite";
2
- declare const _default: {
3
- title: string;
4
- component: import("react").FC<import("./..").ScrimProps>;
5
- parameters: {
6
- iframe: {
7
- url: string;
8
- };
9
- chromatic: {
10
- disableSnapshot: boolean;
11
- };
12
- };
13
- };
14
- export default _default;
15
- export declare const className: StoryObj;
@@ -1,25 +0,0 @@
1
- import { expect } from "storybook/test";
2
- import Scrim from "../index.js";
3
- export default {
4
- title: "Components/Scrim/tests",
5
- component: Scrim,
6
- parameters: {
7
- iframe: {
8
- url: "https://reshaped.so/docs/components/scrim",
9
- },
10
- chromatic: { disableSnapshot: true },
11
- },
12
- };
13
- export const className = {
14
- name: "className, attributes",
15
- render: () => (<div data-testid="root">
16
- <Scrim className="test-classname" attributes={{ id: "test-id" }}>
17
- Content
18
- </Scrim>
19
- </div>),
20
- play: async ({ canvas }) => {
21
- const root = canvas.getByTestId("root").firstChild;
22
- expect(root).toHaveClass("test-classname");
23
- expect(root).toHaveAttribute("id", "test-id");
24
- },
25
- };
@@ -1,15 +0,0 @@
1
- import { StoryObj } from "@storybook/react-vite";
2
- declare const _default: {
3
- title: string;
4
- component: import("react").FC<import("./..").SkeletonProps>;
5
- parameters: {
6
- iframe: {
7
- url: string;
8
- };
9
- chromatic: {
10
- disableSnapshot: boolean;
11
- };
12
- };
13
- };
14
- export default _default;
15
- export declare const className: StoryObj;
@@ -1,23 +0,0 @@
1
- import { expect } from "storybook/test";
2
- import Skeleton from "../index.js";
3
- export default {
4
- title: "Components/Skeleton/tests",
5
- component: Skeleton,
6
- parameters: {
7
- iframe: {
8
- url: "https://reshaped.so/docs/components/skeleton",
9
- },
10
- chromatic: { disableSnapshot: true },
11
- },
12
- };
13
- export const className = {
14
- name: "className, attributes",
15
- render: () => (<div data-testid="root">
16
- <Skeleton className="test-classname" attributes={{ id: "test-id" }}/>
17
- </div>),
18
- play: async ({ canvas }) => {
19
- const root = canvas.getByTestId("root").firstChild;
20
- expect(root).toHaveClass("test-classname");
21
- expect(root).toHaveAttribute("id", "test-id");
22
- },
23
- };
@@ -1,20 +0,0 @@
1
- import { StoryObj } from "@storybook/react-vite";
2
- declare const _default: {
3
- title: string;
4
- component: import("react").FC<import("./..").StepperProps> & {
5
- Item: {
6
- (_: import("../Stepper.types").ItemProps): null;
7
- displayName: string;
8
- };
9
- };
10
- parameters: {
11
- iframe: {
12
- url: string;
13
- };
14
- chromatic: {
15
- disableSnapshot: boolean;
16
- };
17
- };
18
- };
19
- export default _default;
20
- export declare const className: StoryObj;