reshaped 3.7.0-canary.2 → 3.7.0-canary.3

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "reshaped",
3
3
  "description": "Professionally crafted design system in React & Figma for building products of any scale and complexity",
4
- "version": "3.7.0-canary.2",
4
+ "version": "3.7.0-canary.3",
5
5
  "license": "MIT",
6
6
  "email": "hello@reshaped.so",
7
7
  "homepage": "https://reshaped.so",
@@ -1,27 +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("./..").TabsProps> & {
6
- Item: import("react").ForwardRefExoticComponent<import("./..").TabsItemProps & import("react").RefAttributes<import("../../Actionable").ActionableRef>>;
7
- List: import("react").FC<import("../Tabs.types").ListProps>;
8
- Panel: import("react").FC<import("../Tabs.types").PanelProps>;
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 base: StoryObj;
21
- export declare const defaultValue: StoryObj<{
22
- handleChange: ReturnType<typeof fn>;
23
- }>;
24
- export declare const value: StoryObj<{
25
- handleChange: ReturnType<typeof fn>;
26
- }>;
27
- export declare const className: StoryObj;
@@ -1,128 +0,0 @@
1
- import { expect, within, userEvent, waitFor, fn } from "storybook/test";
2
- import Tabs from "../index.js";
3
- export default {
4
- title: "Components/Tabs/tests",
5
- component: Tabs,
6
- parameters: {
7
- iframe: {
8
- url: "https://reshaped.so/docs/components/tabs",
9
- },
10
- chromatic: { disableSnapshot: true },
11
- },
12
- };
13
- export const base = {
14
- name: "base",
15
- render: () => (<Tabs>
16
- <Tabs.List>
17
- <Tabs.Item value="1">Item 1</Tabs.Item>
18
- <Tabs.Item value="2">Item 2</Tabs.Item>
19
- </Tabs.List>
20
-
21
- <Tabs.Panel value="1">Content 1</Tabs.Panel>
22
- <Tabs.Panel value="2">Content 2</Tabs.Panel>
23
- </Tabs>),
24
- play: async ({ canvas }) => {
25
- const list = canvas.getByRole("tablist");
26
- const items = canvas.getAllByRole("tab");
27
- const panels = canvas.getAllByRole("tabpanel", { hidden: true });
28
- expect(list).toBeInTheDocument();
29
- expect(items).toHaveLength(2);
30
- expect(panels).toHaveLength(2);
31
- expect(panels[0]).toBeVisible();
32
- expect(panels[1]).not.toBeVisible();
33
- const selectedItem = items[0];
34
- const selectedPanel = panels[0];
35
- expect(selectedItem).toHaveAttribute("aria-selected", "true");
36
- expect(selectedItem.getAttribute("aria-controls")).toBe(selectedPanel.getAttribute("id"));
37
- const unselectedItem = items[1];
38
- const unselectedPanel = panels[1];
39
- expect(unselectedItem).toHaveAttribute("aria-selected", "false");
40
- expect(unselectedItem.getAttribute("aria-controls")).toBe(unselectedPanel.getAttribute("id"));
41
- await userEvent.tab();
42
- expect(document.activeElement).toBe(items[0]);
43
- await userEvent.tab();
44
- waitFor(() => {
45
- expect(document.activeElement).toBe(panels[0]);
46
- });
47
- },
48
- };
49
- export const defaultValue = {
50
- name: "defaultValue, uncontrolled",
51
- args: {
52
- handleChange: fn(),
53
- },
54
- render: (args) => (<Tabs defaultValue="2" onChange={args.handleChange}>
55
- <Tabs.List>
56
- <Tabs.Item value="1">Item 1</Tabs.Item>
57
- <Tabs.Item value="2">Item 2</Tabs.Item>
58
- </Tabs.List>
59
-
60
- <Tabs.Panel value="1">Content 1</Tabs.Panel>
61
- <Tabs.Panel value="2">Content 2</Tabs.Panel>
62
- </Tabs>),
63
- play: async ({ canvas, args }) => {
64
- const items = canvas.getAllByRole("tab");
65
- expect(items[1]).toHaveAttribute("aria-selected", "true");
66
- expect(items[1]).toHaveAttribute("tabindex", "0");
67
- expect(items[0]).toHaveAttribute("tabindex", "-1");
68
- await userEvent.click(items[0]);
69
- expect(args.handleChange).toHaveBeenCalledTimes(1);
70
- expect(args.handleChange).toHaveBeenCalledWith({ value: "1" });
71
- expect(document.activeElement).toBe(items[0]);
72
- expect(items[0]).toHaveAttribute("aria-selected", "true");
73
- expect(items[0]).toHaveAttribute("tabindex", "0");
74
- expect(items[1]).toHaveAttribute("tabindex", "-1");
75
- },
76
- };
77
- export const value = {
78
- name: "value, controlled",
79
- args: {
80
- handleChange: fn(),
81
- },
82
- render: (args) => (<Tabs value="2" onChange={args.handleChange}>
83
- <Tabs.List>
84
- <Tabs.Item value="1">Item 1</Tabs.Item>
85
- <Tabs.Item value="2">Item 2</Tabs.Item>
86
- </Tabs.List>
87
-
88
- <Tabs.Panel value="1">Content 1</Tabs.Panel>
89
- <Tabs.Panel value="2">Content 2</Tabs.Panel>
90
- </Tabs>),
91
- play: async ({ canvas, args }) => {
92
- const items = canvas.getAllByRole("tab");
93
- expect(items[1]).toHaveAttribute("aria-selected", "true");
94
- expect(items[1]).toHaveAttribute("tabindex", "0");
95
- expect(items[0]).toHaveAttribute("tabindex", "-1");
96
- await userEvent.click(items[0]);
97
- expect(args.handleChange).toHaveBeenCalledTimes(1);
98
- expect(args.handleChange).toHaveBeenCalledWith({ value: "1" });
99
- expect(document.activeElement).toBe(items[0]);
100
- expect(items[1]).toHaveAttribute("aria-selected", "true");
101
- expect(items[1]).toHaveAttribute("tabindex", "0");
102
- expect(items[0]).toHaveAttribute("tabindex", "-1");
103
- },
104
- };
105
- export const className = {
106
- name: "className, attributes",
107
- render: () => (<div data-testid="root">
108
- <Tabs>
109
- <Tabs.List attributes={{ id: "test-list-id" }} className="test-list-classname">
110
- <Tabs.Item attributes={{ id: "test-item-id" }} value="1">
111
- Item
112
- </Tabs.Item>
113
- </Tabs.List>
114
-
115
- <Tabs.Panel attributes={{ "data-testid": "test-panel-id" }} className="test-panel-classname" value="1"/>
116
- </Tabs>
117
- </div>),
118
- play: async ({ canvas }) => {
119
- const list = canvas.getByTestId("root").firstChild;
120
- const item = within(list).getByRole("presentation");
121
- const panel = canvas.getByRole("tabpanel");
122
- expect(list).toHaveClass("test-list-classname");
123
- expect(list).toHaveAttribute("id", "test-list-id");
124
- expect(item).toHaveAttribute("id", "test-item-id");
125
- expect(panel).toHaveClass("test-panel-classname");
126
- expect(panel).toHaveAttribute("data-testid", "test-panel-id");
127
- },
128
- };