reshaped 3.9.0-canary.0 → 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 (177) hide show
  1. package/dist/bundle.css +1 -1
  2. package/dist/bundle.js +10 -10
  3. package/dist/components/Button/Button.module.css +1 -1
  4. package/dist/components/Card/Card.module.css +1 -1
  5. package/dist/components/DropdownMenu/DropdownMenu.js +1 -1
  6. package/dist/components/Flyout/Flyout.constants.d.ts +1 -3
  7. package/dist/components/Flyout/Flyout.constants.js +1 -3
  8. package/dist/components/Flyout/FlyoutControlled.js +6 -8
  9. package/dist/components/Flyout/utilities/cooldown.js +1 -2
  10. package/dist/components/Icon/Icon.module.css +1 -1
  11. package/dist/components/Progress/Progress.module.css +1 -1
  12. package/dist/components/Reshaped/Reshaped.css +1 -1
  13. package/dist/components/Text/Text.module.css +1 -1
  14. package/dist/components/Theme/Theme.module.css +1 -1
  15. package/dist/hooks/useOnClickOutside.js +2 -4
  16. package/dist/themes/_generator/tokens/css.js +2 -2
  17. package/dist/themes/figma/theme.css +1 -1
  18. package/dist/themes/fragments/twitter/theme.css +1 -1
  19. package/dist/themes/reshaped/theme.css +1 -1
  20. package/dist/themes/slate/theme.css +1 -1
  21. package/package.json +40 -35
  22. package/dist/components/Accordion/tests/Accordion.stories.d.ts +0 -44
  23. package/dist/components/Accordion/tests/Accordion.stories.js +0 -204
  24. package/dist/components/ActionBar/tests/ActionBar.stories.d.ts +0 -40
  25. package/dist/components/ActionBar/tests/ActionBar.stories.js +0 -223
  26. package/dist/components/Actionable/tests/Actionable.stories.d.ts +0 -41
  27. package/dist/components/Actionable/tests/Actionable.stories.js +0 -220
  28. package/dist/components/Alert/tests/Alert.stories.d.ts +0 -24
  29. package/dist/components/Alert/tests/Alert.stories.js +0 -78
  30. package/dist/components/Autocomplete/tests/Autocomplete.stories.d.ts +0 -32
  31. package/dist/components/Autocomplete/tests/Autocomplete.stories.js +0 -246
  32. package/dist/components/Avatar/tests/Avatar.stories.d.ts +0 -31
  33. package/dist/components/Avatar/tests/Avatar.stories.js +0 -176
  34. package/dist/components/Badge/tests/Badge.stories.d.ts +0 -55
  35. package/dist/components/Badge/tests/Badge.stories.js +0 -328
  36. package/dist/components/Breadcrumbs/tests/Breadcrumbs.stories.d.ts +0 -40
  37. package/dist/components/Breadcrumbs/tests/Breadcrumbs.stories.js +0 -187
  38. package/dist/components/Button/tests/Button.stories.d.ts +0 -79
  39. package/dist/components/Button/tests/Button.stories.js +0 -789
  40. package/dist/components/Calendar/tests/Calendar.stories.d.ts +0 -29
  41. package/dist/components/Calendar/tests/Calendar.stories.js +0 -255
  42. package/dist/components/Card/tests/Card.stories.d.ts +0 -52
  43. package/dist/components/Card/tests/Card.stories.js +0 -125
  44. package/dist/components/Carousel/tests/Carousel.stories.d.ts +0 -34
  45. package/dist/components/Carousel/tests/Carousel.stories.js +0 -224
  46. package/dist/components/Checkbox/tests/Checkbox.stories.d.ts +0 -30
  47. package/dist/components/Checkbox/tests/Checkbox.stories.js +0 -171
  48. package/dist/components/CheckboxGroup/tests/CheckboxGroup.stories.d.ts +0 -19
  49. package/dist/components/CheckboxGroup/tests/CheckboxGroup.stories.js +0 -83
  50. package/dist/components/Container/tests/Container.stories.d.ts +0 -24
  51. package/dist/components/Container/tests/Container.stories.js +0 -75
  52. package/dist/components/ContextMenu/tests/ContextMenu.stories.d.ts +0 -26
  53. package/dist/components/ContextMenu/tests/ContextMenu.stories.js +0 -70
  54. package/dist/components/Dismissible/tests/Dismissible.stories.d.ts +0 -25
  55. package/dist/components/Dismissible/tests/Dismissible.stories.js +0 -97
  56. package/dist/components/Divider/tests/Divider.stories.d.ts +0 -20
  57. package/dist/components/Divider/tests/Divider.stories.js +0 -120
  58. package/dist/components/DropdownMenu/tests/DropdownMenu.stories.d.ts +0 -53
  59. package/dist/components/DropdownMenu/tests/DropdownMenu.stories.js +0 -278
  60. package/dist/components/FileUpload/tests/FileUpload.stories.d.ts +0 -31
  61. package/dist/components/FileUpload/tests/FileUpload.stories.js +0 -140
  62. package/dist/components/Flyout/tests/Flyout.stories.d.ts +0 -103
  63. package/dist/components/Flyout/tests/Flyout.stories.js +0 -738
  64. package/dist/components/FormControl/tests/FormControl.stories.d.ts +0 -31
  65. package/dist/components/FormControl/tests/FormControl.stories.js +0 -143
  66. package/dist/components/Grid/tests/Grid.stories.d.ts +0 -38
  67. package/dist/components/Grid/tests/Grid.stories.js +0 -245
  68. package/dist/components/Hidden/tests/Hidden.stories.d.ts +0 -16
  69. package/dist/components/Hidden/tests/Hidden.stories.js +0 -48
  70. package/dist/components/HiddenVisually/tests/HiddenVisually.stories.d.ts +0 -16
  71. package/dist/components/HiddenVisually/tests/HiddenVisually.stories.js +0 -28
  72. package/dist/components/Hotkey/tests/Hotkey.stories.d.ts +0 -13
  73. package/dist/components/Hotkey/tests/Hotkey.stories.js +0 -53
  74. package/dist/components/Icon/tests/Icon.stories.d.ts +0 -25
  75. package/dist/components/Icon/tests/Icon.stories.js +0 -113
  76. package/dist/components/Image/tests/Image.stories.d.ts +0 -41
  77. package/dist/components/Image/tests/Image.stories.js +0 -196
  78. package/dist/components/Link/tests/Link.stories.d.ts +0 -42
  79. package/dist/components/Link/tests/Link.stories.js +0 -155
  80. package/dist/components/Loader/tests/Loader.stories.d.ts +0 -21
  81. package/dist/components/Loader/tests/Loader.stories.js +0 -68
  82. package/dist/components/MenuItem/tests/MenuItem.stories.d.ts +0 -59
  83. package/dist/components/MenuItem/tests/MenuItem.stories.js +0 -236
  84. package/dist/components/Modal/tests/Modal.stories.d.ts +0 -64
  85. package/dist/components/Modal/tests/Modal.stories.js +0 -410
  86. package/dist/components/NumberField/tests/NumberField.stories.d.ts +0 -28
  87. package/dist/components/NumberField/tests/NumberField.stories.js +0 -258
  88. package/dist/components/Overlay/tests/Overlay.stories.d.ts +0 -28
  89. package/dist/components/Overlay/tests/Overlay.stories.js +0 -202
  90. package/dist/components/Pagination/tests/Pagination.stories.d.ts +0 -24
  91. package/dist/components/Pagination/tests/Pagination.stories.js +0 -105
  92. package/dist/components/PinField/tests/PinField.stories.d.ts +0 -34
  93. package/dist/components/PinField/tests/PinField.stories.js +0 -209
  94. package/dist/components/Popover/tests/Popover.stories.d.ts +0 -69
  95. package/dist/components/Popover/tests/Popover.stories.js +0 -340
  96. package/dist/components/Progress/tests/Progress.stories.d.ts +0 -30
  97. package/dist/components/Progress/tests/Progress.stories.js +0 -102
  98. package/dist/components/ProgressIndicator/tests/ProgressIndicator.stories.d.ts +0 -19
  99. package/dist/components/ProgressIndicator/tests/ProgressIndicator.stories.js +0 -92
  100. package/dist/components/Radio/tests/Radio.stories.d.ts +0 -35
  101. package/dist/components/Radio/tests/Radio.stories.js +0 -162
  102. package/dist/components/RadioGroup/tests/RadioGroup.stories.d.ts +0 -19
  103. package/dist/components/RadioGroup/tests/RadioGroup.stories.js +0 -77
  104. package/dist/components/Reshaped/tests/Reshaped.stories.d.ts +0 -34
  105. package/dist/components/Reshaped/tests/Reshaped.stories.js +0 -108
  106. package/dist/components/Resizable/tests/Resizable.stories.d.ts +0 -38
  107. package/dist/components/Resizable/tests/Resizable.stories.js +0 -185
  108. package/dist/components/Scrim/tests/Scrim.stories.d.ts +0 -20
  109. package/dist/components/Scrim/tests/Scrim.stories.js +0 -67
  110. package/dist/components/ScrollArea/tests/ScrollArea.stories.d.ts +0 -37
  111. package/dist/components/ScrollArea/tests/ScrollArea.stories.js +0 -244
  112. package/dist/components/Select/tests/Select.stories.d.ts +0 -53
  113. package/dist/components/Select/tests/Select.stories.js +0 -616
  114. package/dist/components/Skeleton/tests/Skeleton.stories.d.ts +0 -20
  115. package/dist/components/Skeleton/tests/Skeleton.stories.js +0 -63
  116. package/dist/components/Slider/tests/Slider.stories.d.ts +0 -47
  117. package/dist/components/Slider/tests/Slider.stories.js +0 -279
  118. package/dist/components/Stepper/tests/Stepper.stories.d.ts +0 -31
  119. package/dist/components/Stepper/tests/Stepper.stories.js +0 -135
  120. package/dist/components/Switch/tests/Switch.stories.d.ts +0 -22
  121. package/dist/components/Switch/tests/Switch.stories.js +0 -137
  122. package/dist/components/Switch/tests/Switch.test.stories.d.ts +0 -13
  123. package/dist/components/Switch/tests/Switch.test.stories.js +0 -11
  124. package/dist/components/Table/tests/Table.stories.d.ts +0 -42
  125. package/dist/components/Table/tests/Table.stories.js +0 -348
  126. package/dist/components/Tabs/tests/Tabs.stories.d.ts +0 -62
  127. package/dist/components/Tabs/tests/Tabs.stories.js +0 -539
  128. package/dist/components/Text/tests/Text.stories.d.ts +0 -48
  129. package/dist/components/Text/tests/Text.stories.js +0 -201
  130. package/dist/components/TextArea/tests/TextArea.stories.d.ts +0 -53
  131. package/dist/components/TextArea/tests/TextArea.stories.js +0 -204
  132. package/dist/components/TextField/tests/TextField.stories.d.ts +0 -54
  133. package/dist/components/TextField/tests/TextField.stories.js +0 -252
  134. package/dist/components/Theme/tests/Theme.stories.d.ts +0 -25
  135. package/dist/components/Theme/tests/Theme.stories.js +0 -171
  136. package/dist/components/Timeline/tests/Timeline.stories.d.ts +0 -22
  137. package/dist/components/Timeline/tests/Timeline.stories.js +0 -86
  138. package/dist/components/Toast/tests/Toast.stories.d.ts +0 -41
  139. package/dist/components/Toast/tests/Toast.stories.js +0 -432
  140. package/dist/components/ToggleButton/tests/ToggleButton.stories.d.ts +0 -27
  141. package/dist/components/ToggleButton/tests/ToggleButton.stories.js +0 -97
  142. package/dist/components/ToggleButtonGroup/tests/ToggleButtonGroup.stories.d.ts +0 -27
  143. package/dist/components/ToggleButtonGroup/tests/ToggleButtonGroup.stories.js +0 -169
  144. package/dist/components/Tooltip/tests/Tooltip.stories.d.ts +0 -28
  145. package/dist/components/Tooltip/tests/Tooltip.stories.js +0 -182
  146. package/dist/components/View/tests/View.stories.d.ts +0 -141
  147. package/dist/components/View/tests/View.stories.js +0 -1329
  148. package/dist/components/_private/Portal/tests/Portal.stories.d.ts +0 -6
  149. package/dist/components/_private/Portal/tests/Portal.stories.js +0 -17
  150. package/dist/hooks/tests/useDrag.stories.d.ts +0 -31
  151. package/dist/hooks/tests/useDrag.stories.js +0 -147
  152. package/dist/hooks/tests/useElementId.stories.d.ts +0 -11
  153. package/dist/hooks/tests/useElementId.stories.js +0 -23
  154. package/dist/hooks/tests/useHandlerRef.stories.d.ts +0 -14
  155. package/dist/hooks/tests/useHandlerRef.stories.js +0 -44
  156. package/dist/hooks/tests/useHotkeys.stories.d.ts +0 -43
  157. package/dist/hooks/tests/useHotkeys.stories.js +0 -158
  158. package/dist/hooks/tests/useKeyboardArrowNavigation.stories.d.ts +0 -15
  159. package/dist/hooks/tests/useKeyboardArrowNavigation.stories.js +0 -128
  160. package/dist/hooks/tests/useKeyboardMode.stories.d.ts +0 -11
  161. package/dist/hooks/tests/useKeyboardMode.stories.js +0 -42
  162. package/dist/hooks/tests/useOnClickOutside.stories.d.ts +0 -23
  163. package/dist/hooks/tests/useOnClickOutside.stories.js +0 -111
  164. package/dist/hooks/tests/useRTL.stories.d.ts +0 -11
  165. package/dist/hooks/tests/useRTL.stories.js +0 -23
  166. package/dist/hooks/tests/useResponsiveClientValue.stories.d.ts +0 -18
  167. package/dist/hooks/tests/useResponsiveClientValue.stories.js +0 -30
  168. package/dist/hooks/tests/useScrollLock.stories.d.ts +0 -14
  169. package/dist/hooks/tests/useScrollLock.stories.js +0 -97
  170. package/dist/hooks/tests/useToggle.stories.d.ts +0 -13
  171. package/dist/hooks/tests/useToggle.stories.js +0 -59
  172. package/dist/tests/ShadowDOM.stories.d.ts +0 -6
  173. package/dist/tests/ShadowDOM.stories.js +0 -110
  174. package/dist/tests/themes.stories.d.ts +0 -16
  175. package/dist/tests/themes.stories.js +0 -327
  176. package/dist/utilities/a11y/tests/TrapFocus.stories.d.ts +0 -14
  177. package/dist/utilities/a11y/tests/TrapFocus.stories.js +0 -615
@@ -1,102 +0,0 @@
1
- import React from "react";
2
- import { Example } from "../../../utilities/storybook/index.js";
3
- import View from "../../View/index.js";
4
- import Progress from "../index.js";
5
- import Button from "../../Button/index.js";
6
- import { expect } from "storybook/test";
7
- export default {
8
- title: "Components/Progress",
9
- component: Progress,
10
- parameters: {
11
- iframe: {
12
- url: "https://reshaped.so/docs/components/progress",
13
- },
14
- },
15
- };
16
- export const value = {
17
- name: "value",
18
- render: () => (<Example>
19
- <Example.Item title="value: 50">
20
- <Progress value={50} ariaLabel="rating value"/>
21
- </Example.Item>
22
- <Example.Item title="value: 20, min: 0, max: 40">
23
- <Progress value={20} min={0} max={40} ariaLabel="rating value"/>
24
- </Example.Item>
25
- <Example.Item title="value: 50, min: 0, max: 40">
26
- <Progress value={50} min={0} max={40} ariaLabel="rating value"/>
27
- </Example.Item>
28
- </Example>),
29
- };
30
- export const size = {
31
- name: "size",
32
- render: () => (<Example>
33
- <Example.Item title="size: small, value: 50">
34
- <Progress value={50} size="small" ariaLabel="rating value"/>
35
- </Example.Item>
36
- <Example.Item title="size: medium, value: 50">
37
- <Progress value={50} size="medium" ariaLabel="rating value"/>
38
- </Example.Item>
39
- </Example>),
40
- };
41
- export const color = {
42
- name: "color",
43
- render: () => (<Example>
44
- <Example.Item title="color: critical, value: 50">
45
- <Progress value={50} color="critical" ariaLabel="rating value"/>
46
- </Example.Item>
47
- <Example.Item title="color: warning, value: 50">
48
- <Progress value={50} color="warning" ariaLabel="rating value"/>
49
- </Example.Item>
50
- <Example.Item title="color: positive, value: 50">
51
- <Progress value={50} color="positive" ariaLabel="rating value"/>
52
- </Example.Item>
53
- <Example.Item title="color: media, value: 50">
54
- <View padding={4} backgroundColor="black" borderRadius="medium">
55
- <Progress value={50} color="media" ariaLabel="rating value"/>
56
- </View>
57
- </Example.Item>
58
- </Example>),
59
- };
60
- export const duration = {
61
- name: "duration",
62
- render: () => {
63
- const [active, setActive] = React.useState(false);
64
- const handleChange = () => {
65
- setActive((state) => !state);
66
- };
67
- return (<Example>
68
- <Example.Item title="duration: 2000">
69
- <View gap={3}>
70
- <View.Item>
71
- <Button onClick={handleChange}>Change</Button>
72
- </View.Item>
73
-
74
- <Progress value={active ? 100 : 0} duration={2000} ariaLabel="rating value"/>
75
- </View>
76
- </Example.Item>
77
- </Example>);
78
- },
79
- };
80
- export const render = {
81
- name: "rendering",
82
- render: () => <Progress value={75} min={50} max={100} ariaLabel="progress"/>,
83
- play: async ({ canvas }) => {
84
- const el = canvas.getByRole("progressbar");
85
- expect(el).toBeInTheDocument();
86
- expect(el).toHaveAttribute("aria-valuenow", "75");
87
- expect(el).toHaveAttribute("aria-valuemin", "50");
88
- expect(el).toHaveAttribute("aria-valuemax", "100");
89
- expect(el).toHaveAccessibleName("progress");
90
- },
91
- };
92
- export const className = {
93
- name: "className, attributes",
94
- render: () => (<div data-testid="root">
95
- <Progress className="test-classname" attributes={{ id: "test-id" }} ariaLabel="progress"/>
96
- </div>),
97
- play: async ({ canvas }) => {
98
- const root = canvas.getByTestId("root").firstChild;
99
- expect(root).toHaveClass("test-classname");
100
- expect(root).toHaveAttribute("id", "test-id");
101
- },
102
- };
@@ -1,19 +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("./..").ProgressIndicatorProps>;
6
- parameters: {
7
- iframe: {
8
- url: string;
9
- };
10
- };
11
- };
12
- export default _default;
13
- export declare const base: StoryObj;
14
- export declare const color: {
15
- name: string;
16
- render: () => React.JSX.Element;
17
- };
18
- export declare const ariaLabel: StoryObj;
19
- export declare const className: StoryObj;
@@ -1,92 +0,0 @@
1
- import React from "react";
2
- import { expect } from "storybook/test";
3
- import { Example } from "../../../utilities/storybook/index.js";
4
- import ProgressIndicator from "../index.js";
5
- import View from "../../View/index.js";
6
- import Button from "../../Button/index.js";
7
- import Text from "../../Text/index.js";
8
- import Scrim from "../../Scrim/index.js";
9
- export default {
10
- title: "Components/ProgressIndicator",
11
- component: ProgressIndicator,
12
- parameters: {
13
- iframe: {
14
- url: "https://reshaped.so/docs/components/progress-indicator",
15
- },
16
- },
17
- };
18
- export const base = {
19
- name: "base",
20
- render: () => {
21
- const [activeIndex, setActiveIndex] = React.useState(0);
22
- const total = 10;
23
- return (<Example>
24
- <Example.Item title="base">
25
- <View gap={4}>
26
- <View direction="row" gap={2} align="center">
27
- <Button onClick={() => {
28
- setActiveIndex((prev) => Math.max(0, prev - 1));
29
- }}>
30
- Previous
31
- </Button>
32
- <Button onClick={() => {
33
- setActiveIndex((prev) => Math.min(total - 1, prev + 1));
34
- }}>
35
- Next
36
- </Button>
37
- <Text weight="medium">Index: {activeIndex}</Text>
38
- </View>
39
-
40
- <View borderRadius="medium" overflow="hidden" width="300px">
41
- <Scrim position="bottom" backgroundSlot={<View aspectRatio={16 / 9} backgroundColor="neutral-faded"/>}>
42
- <View align="center">
43
- <ProgressIndicator total={total} activeIndex={activeIndex} color="media"/>
44
- </View>
45
- </Scrim>
46
- </View>
47
- </View>
48
- </Example.Item>
49
- </Example>);
50
- },
51
- };
52
- export const color = {
53
- name: "color",
54
- render: () => {
55
- return (<Example>
56
- <Example.Item title="color: primary">
57
- <ProgressIndicator total={10} activeIndex={5} color="primary"/>
58
- </Example.Item>
59
- <Example.Item title="color: media">
60
- <View borderRadius="medium" overflow="hidden" width="300px">
61
- <Scrim position="bottom" backgroundSlot={<View aspectRatio={16 / 9} backgroundColor="neutral-faded"/>}>
62
- <View align="center">
63
- <ProgressIndicator total={10} activeIndex={5} color="media"/>
64
- </View>
65
- </Scrim>
66
- </View>
67
- </Example.Item>
68
- </Example>);
69
- },
70
- };
71
- export const ariaLabel = {
72
- name: "ariaLabel",
73
- render: () => <ProgressIndicator total={10} className="test-classname" ariaLabel="Progress"/>,
74
- play: async ({ canvas }) => {
75
- const progress = canvas.getByRole("progressbar");
76
- expect(progress).toHaveAttribute("aria-valuenow", "0");
77
- expect(progress).toHaveAttribute("aria-valuemin", "0");
78
- expect(progress).toHaveAttribute("aria-valuemax", "9");
79
- expect(progress).toHaveAccessibleName("Progress");
80
- },
81
- };
82
- export const className = {
83
- name: "className, attributes",
84
- render: () => (<div data-testid="root">
85
- <ProgressIndicator total={10} className="test-classname" attributes={{ id: "test-id" }}/>
86
- </div>),
87
- play: async ({ canvas }) => {
88
- const root = canvas.getByTestId("root").firstChild;
89
- expect(root).toHaveClass("test-classname");
90
- expect(root).toHaveAttribute("id", "test-id");
91
- },
92
- };
@@ -1,35 +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
- };
11
- };
12
- export default _default;
13
- export declare const size: {
14
- name: string;
15
- render: () => import("react").JSX.Element;
16
- };
17
- export declare const error: {
18
- name: string;
19
- render: () => import("react").JSX.Element;
20
- };
21
- export declare const render: StoryObj;
22
- export declare const checked: StoryObj<{
23
- handleChange: ReturnType<typeof fn>;
24
- }>;
25
- export declare const checkedFalse: StoryObj<{
26
- handleChange: ReturnType<typeof fn>;
27
- }>;
28
- export declare const defaultChecked: StoryObj<{
29
- handleChange: ReturnType<typeof fn>;
30
- }>;
31
- export declare const defaultCheckedFalse: StoryObj<{
32
- handleChange: ReturnType<typeof fn>;
33
- }>;
34
- export declare const disabled: StoryObj;
35
- export declare const className: StoryObj;
@@ -1,162 +0,0 @@
1
- import { Example } from "../../../utilities/storybook/index.js";
2
- import Radio from "../index.js";
3
- import View from "../../View/index.js";
4
- import { expect, fn, userEvent } from "storybook/test";
5
- export default {
6
- title: "Components/Radio",
7
- component: Radio,
8
- parameters: {
9
- iframe: {
10
- url: "https://reshaped.so/docs/components/radio",
11
- },
12
- },
13
- };
14
- export const size = {
15
- name: "size",
16
- render: () => (<Example>
17
- <Example.Item title="size: small">
18
- <View gap={4} direction="row">
19
- <Radio name="animal" value="dog" size="small" defaultChecked>
20
- Radio
21
- </Radio>
22
- </View>
23
- </Example.Item>
24
- <Example.Item title="size: medium">
25
- <View gap={4} direction="row">
26
- <Radio name="animal" value="dog" size="medium">
27
- Radio
28
- </Radio>
29
- </View>
30
- </Example.Item>
31
- <Example.Item title="size: large">
32
- <View gap={4} direction="row">
33
- <Radio name="animal" value="dog" size="large">
34
- Radio
35
- </Radio>
36
- </View>
37
- </Example.Item>
38
- <Example.Item title="size: responsive, s: small, m: large">
39
- <View gap={4} direction="row">
40
- <Radio name="animal" value="dog" size={{ s: "small", m: "large" }}>
41
- Radio
42
- </Radio>
43
- </View>
44
- </Example.Item>
45
- </Example>),
46
- };
47
- export const error = {
48
- name: "hasError",
49
- render: () => (<Example>
50
- <Example.Item title="error">
51
- <Radio name="error" value="dog" hasError>
52
- Radio
53
- </Radio>
54
- </Example.Item>
55
- </Example>),
56
- };
57
- export const render = {
58
- name: "name, value",
59
- render: () => (<Radio name="test-name" value="test-value">
60
- Content
61
- </Radio>),
62
- play: async ({ canvas }) => {
63
- const input = canvas.getByRole("radio");
64
- expect(input).toHaveAttribute("value", "test-value");
65
- expect(input).toHaveAttribute("name", "test-name");
66
- expect(input).not.toBeChecked();
67
- },
68
- };
69
- export const checked = {
70
- name: "checked, controlled",
71
- args: {
72
- handleChange: fn(),
73
- },
74
- render: (args) => (<Radio name="test-name" value="test-value" checked onChange={args.handleChange}>
75
- Content
76
- </Radio>),
77
- play: async ({ canvas, args }) => {
78
- const input = canvas.getByRole("radio");
79
- expect(input).toBeChecked();
80
- },
81
- };
82
- export const checkedFalse = {
83
- name: "checked false, controlled",
84
- args: {
85
- handleChange: fn(),
86
- },
87
- render: (args) => (<Radio name="test-name" value="test-value" checked={false} onChange={args.handleChange}>
88
- Content
89
- </Radio>),
90
- play: async ({ canvas, args }) => {
91
- const input = canvas.getByRole("radio");
92
- expect(input).not.toBeChecked();
93
- await userEvent.click(input);
94
- expect(args.handleChange).toHaveBeenCalledTimes(1);
95
- expect(args.handleChange).toHaveBeenCalledWith({
96
- name: "test-name",
97
- value: "test-value",
98
- checked: true,
99
- event: expect.objectContaining({ target: input }),
100
- });
101
- // Still not checked because it's controlled
102
- expect(input).not.toBeChecked();
103
- },
104
- };
105
- export const defaultChecked = {
106
- name: "defaultChecked, uncontrolled",
107
- args: {
108
- handleChange: fn(),
109
- },
110
- render: (args) => (<Radio name="test-name" value="test-value" defaultChecked onChange={args.handleChange}>
111
- Content
112
- </Radio>),
113
- play: async ({ canvas, args }) => {
114
- const input = canvas.getByRole("radio");
115
- expect(input).toBeChecked();
116
- },
117
- };
118
- export const defaultCheckedFalse = {
119
- name: "defaultChecked false, uncontrolled",
120
- args: {
121
- handleChange: fn(),
122
- },
123
- render: (args) => (<Radio name="test-name" value="test-value" onChange={args.handleChange}>
124
- Content
125
- </Radio>),
126
- play: async ({ canvas, args }) => {
127
- const input = canvas.getByRole("radio");
128
- expect(input).not.toBeChecked();
129
- await userEvent.click(input);
130
- expect(args.handleChange).toHaveBeenCalledTimes(1);
131
- expect(args.handleChange).toHaveBeenCalledWith({
132
- name: "test-name",
133
- value: "test-value",
134
- checked: true,
135
- event: expect.objectContaining({ target: input }),
136
- });
137
- expect(input).toBeChecked();
138
- },
139
- };
140
- export const disabled = {
141
- name: "disabled",
142
- render: () => (<Radio name="test-name" value="test-value" disabled>
143
- Content
144
- </Radio>),
145
- play: async ({ canvas }) => {
146
- const input = canvas.getByRole("radio");
147
- expect(input).toBeDisabled();
148
- },
149
- };
150
- export const className = {
151
- name: "className, attributes",
152
- render: () => (<div data-testid="root">
153
- <Radio className="test-classname" attributes={{ id: "test-id" }} value="value">
154
- Content
155
- </Radio>
156
- </div>),
157
- play: async ({ canvas }) => {
158
- const root = canvas.getByTestId("root").firstChild;
159
- expect(root).toHaveClass("test-classname");
160
- expect(root).toHaveAttribute("id", "test-id");
161
- },
162
- };
@@ -1,19 +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
- };
11
- };
12
- export default _default;
13
- export declare const value: StoryObj<{
14
- handleChange: ReturnType<typeof fn>;
15
- }>;
16
- export declare const defaultValue: StoryObj<{
17
- handleChange: ReturnType<typeof fn>;
18
- }>;
19
- export declare const disabled: StoryObj;
@@ -1,77 +0,0 @@
1
- import RadioGroup from "../index.js";
2
- import Radio from "../../Radio/index.js";
3
- import { expect, fn, userEvent } from "storybook/test";
4
- export default {
5
- title: "Components/RadioGroup",
6
- component: RadioGroup,
7
- parameters: {
8
- iframe: {
9
- url: "https://reshaped.so/docs/components/radio",
10
- },
11
- },
12
- };
13
- export const value = {
14
- name: "value, controlled",
15
- args: {
16
- handleChange: fn(),
17
- },
18
- render: (args) => (<RadioGroup name="test-name" value="1" onChange={args.handleChange}>
19
- {/* checked should be ignored */}
20
- <Radio value="1" checked={false}>
21
- Content
22
- </Radio>
23
-
24
- <Radio value="2">Content 2</Radio>
25
- </RadioGroup>),
26
- play: async ({ canvas, args }) => {
27
- const inputs = canvas.getAllByRole("radio");
28
- expect(inputs[0]).toBeChecked();
29
- await userEvent.click(inputs[1]);
30
- expect(args.handleChange).toHaveBeenCalledTimes(1);
31
- expect(args.handleChange).toHaveBeenCalledWith({
32
- name: "test-name",
33
- value: "2",
34
- event: expect.objectContaining({ target: inputs[1] }),
35
- });
36
- // Still checked because it's controlled
37
- expect(inputs[0]).toBeChecked();
38
- expect(inputs[1]).not.toBeChecked();
39
- },
40
- };
41
- export const defaultValue = {
42
- name: "defaultValue, uncontrolled",
43
- args: {
44
- handleChange: fn(),
45
- },
46
- render: (args) => (<RadioGroup name="test-name" defaultValue="1" onChange={args.handleChange}>
47
- {/* checked should be ignored */}
48
- <Radio value="1" checked={false}>
49
- Content
50
- </Radio>
51
-
52
- <Radio value="2">Content 2</Radio>
53
- </RadioGroup>),
54
- play: async ({ canvas, args }) => {
55
- const inputs = canvas.getAllByRole("radio");
56
- expect(inputs[0]).toBeChecked();
57
- await userEvent.click(inputs[1]);
58
- expect(args.handleChange).toHaveBeenCalledTimes(1);
59
- expect(args.handleChange).toHaveBeenCalledWith({
60
- name: "test-name",
61
- value: "2",
62
- event: expect.objectContaining({ target: inputs[1] }),
63
- });
64
- expect(inputs[0]).not.toBeChecked();
65
- expect(inputs[1]).toBeChecked();
66
- },
67
- };
68
- export const disabled = {
69
- name: "disabled",
70
- render: () => (<RadioGroup name="test-name" disabled>
71
- <Radio value="test-value">Content</Radio>
72
- </RadioGroup>),
73
- play: async ({ canvas }) => {
74
- const input = canvas.getByRole("radio");
75
- expect(input).toBeDisabled();
76
- },
77
- };
@@ -1,34 +0,0 @@
1
- import { StoryObj } from "@storybook/react-vite";
2
- declare const _default: {
3
- title: string;
4
- parameters: {
5
- disableWrapper: boolean;
6
- };
7
- };
8
- export default _default;
9
- export declare const rtl: {
10
- name: string;
11
- render: () => import("react").JSX.Element;
12
- };
13
- export declare const controlledMode: StoryObj;
14
- export declare const lightMode: {
15
- name: string;
16
- render: () => import("react").JSX.Element;
17
- play: () => void;
18
- };
19
- export declare const darkMode: {
20
- name: string;
21
- render: () => import("react").JSX.Element;
22
- play: () => void;
23
- };
24
- export declare const scoped: {
25
- name: string;
26
- render: () => import("react").JSX.Element;
27
- play: () => Promise<void>;
28
- };
29
- export declare const testScoped: StoryObj;
30
- export declare const keyboardMode: {
31
- name: string;
32
- render: () => import("react").JSX.Element;
33
- play: () => Promise<void>;
34
- };
@@ -1,108 +0,0 @@
1
- import { useState } from "react";
2
- import { expect, userEvent } from "storybook/test";
3
- import { useTheme } from "../../Theme/index.js";
4
- import Button from "../../Button/index.js";
5
- import Reshaped from "../Reshaped.js";
6
- export default {
7
- title: "Utility components/Reshaped",
8
- parameters: {
9
- disableWrapper: true,
10
- },
11
- };
12
- export const rtl = {
13
- name: "defaultRTL",
14
- render: () => (<Reshaped defaultRTL theme="reshaped" defaultColorMode="dark">
15
- Hello
16
- </Reshaped>),
17
- };
18
- export const controlledMode = {
19
- name: "colorMode, controlled",
20
- render: () => {
21
- const [mode, setMode] = useState("dark");
22
- return (<Reshaped theme="reshaped" colorMode={mode}>
23
- <Button onClick={() => {
24
- setMode(mode === "dark" ? "light" : "dark");
25
- }}>
26
- Toggle color mode
27
- </Button>
28
- </Reshaped>);
29
- },
30
- play: async ({ canvas }) => {
31
- const button = canvas.getAllByRole("button")[0];
32
- expect(document.documentElement.getAttribute("data-rs-color-mode")).toEqual("dark");
33
- await userEvent.click(button);
34
- expect(document.documentElement.getAttribute("data-rs-color-mode")).toEqual("light");
35
- },
36
- };
37
- export const lightMode = {
38
- name: "defaultColorMode=light",
39
- render: () => <Reshaped theme="reshaped">Hello</Reshaped>,
40
- play: () => {
41
- const theme = document.documentElement.getAttribute("data-rs-theme");
42
- const colorMode = document.documentElement.getAttribute("data-rs-color-mode");
43
- expect(theme).toEqual("reshaped");
44
- expect(colorMode).toEqual("light");
45
- },
46
- };
47
- export const darkMode = {
48
- name: "defaultColorMode=dark",
49
- render: () => (<Reshaped theme="reshaped" defaultColorMode="dark">
50
- Hello
51
- </Reshaped>),
52
- play: () => {
53
- const theme = document.documentElement.getAttribute("data-rs-theme");
54
- const colorMode = document.documentElement.getAttribute("data-rs-color-mode");
55
- expect(theme).toEqual("reshaped");
56
- expect(colorMode).toEqual("dark");
57
- },
58
- };
59
- export const scoped = {
60
- name: "scoped",
61
- render: () => (<Reshaped theme="reshaped" defaultColorMode="dark" scoped>
62
- Hello
63
- </Reshaped>),
64
- play: async () => {
65
- const root = document.querySelector("[data-rs-root]");
66
- expect(root).toBeInTheDocument();
67
- expect(root).not.toBe(document.documentElement);
68
- expect(root).toHaveAttribute("data-rs-theme", "reshaped");
69
- expect(document.documentElement).not.toHaveAttribute("data-rs-theme");
70
- },
71
- };
72
- const ScopedComponent = () => {
73
- const { invertColorMode } = useTheme();
74
- return <Button onClick={invertColorMode}>Invert</Button>;
75
- };
76
- export const testScoped = {
77
- name: "test: scoped switch",
78
- render: () => (<Reshaped theme="reshaped">
79
- <Reshaped theme="slate" scoped>
80
- <ScopedComponent />
81
- </Reshaped>
82
- </Reshaped>),
83
- play: async ({ canvas }) => {
84
- const nestedRoot = document.querySelector("[data-rs-root]");
85
- const button = canvas.getAllByRole("button")[0];
86
- expect(document.documentElement).toHaveAttribute("data-rs-theme", "reshaped");
87
- expect(document.documentElement).toHaveAttribute("data-rs-color-mode", "light");
88
- expect(nestedRoot).toHaveAttribute("data-rs-theme", "slate");
89
- expect(nestedRoot).toHaveAttribute("data-rs-color-mode", "light");
90
- await userEvent.click(button);
91
- expect(document.documentElement).toHaveAttribute("data-rs-color-mode", "light");
92
- expect(nestedRoot).toHaveAttribute("data-rs-color-mode", "dark");
93
- },
94
- };
95
- export const keyboardMode = {
96
- name: "test: keyboard mode",
97
- render: () => (<Reshaped theme="reshaped" defaultColorMode="dark">
98
- Hello
99
- </Reshaped>),
100
- play: async () => {
101
- const attribute = "data-rs-keyboard";
102
- expect(document.documentElement).not.toHaveAttribute(attribute);
103
- await userEvent.keyboard("{Tab/}");
104
- expect(document.documentElement).toHaveAttribute(attribute);
105
- await userEvent.click(document.body);
106
- expect(document.documentElement).not.toHaveAttribute(attribute);
107
- },
108
- };