@sproutsocial/seeds-react-drawer 1.0.1 → 1.0.2
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/.turbo/turbo-build.log +19 -19
- package/CHANGELOG.md +12 -0
- package/package.json +8 -8
- package/src/__tests__/Drawer.test.tsx +80 -59
- package/tsconfig.json +7 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
yarn run v1.22.22
|
|
2
2
|
$ tsup --dts
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
Done in
|
|
3
|
+
[34mCLI[39m Building entry: src/index.ts
|
|
4
|
+
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
5
|
+
[34mCLI[39m tsup v8.5.0
|
|
6
|
+
[34mCLI[39m Using tsup config: /home/runner/work/seeds/seeds/seeds-react/seeds-react-drawer/tsup.config.ts
|
|
7
|
+
[34mCLI[39m Target: es2022
|
|
8
|
+
[34mCLI[39m Cleaning output folder
|
|
9
|
+
[34mCJS[39m Build start
|
|
10
|
+
[34mESM[39m Build start
|
|
11
|
+
[32mCJS[39m [1mdist/index.js [22m[32m9.40 KB[39m
|
|
12
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m15.31 KB[39m
|
|
13
|
+
[32mCJS[39m ⚡️ Build success in 229ms
|
|
14
|
+
[32mESM[39m [1mdist/esm/index.js [22m[32m6.90 KB[39m
|
|
15
|
+
[32mESM[39m [1mdist/esm/index.js.map [22m[32m15.15 KB[39m
|
|
16
|
+
[32mESM[39m ⚡️ Build success in 212ms
|
|
17
|
+
[34mDTS[39m Build start
|
|
18
|
+
[32mDTS[39m ⚡️ Build success in 45262ms
|
|
19
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m3.35 KB[39m
|
|
20
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m3.35 KB[39m
|
|
21
|
+
Done in 54.99s.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @sproutsocial/seeds-react-drawer
|
|
2
2
|
|
|
3
|
+
## 1.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [22e1111]
|
|
8
|
+
- @sproutsocial/seeds-react-button@1.2.2
|
|
9
|
+
- @sproutsocial/seeds-react-portal@1.1.4
|
|
10
|
+
- @sproutsocial/seeds-react-text@1.3.2
|
|
11
|
+
- @sproutsocial/seeds-react-theme@3.0.1
|
|
12
|
+
- @sproutsocial/seeds-react-box@1.1.3
|
|
13
|
+
- @sproutsocial/seeds-react-icon@1.1.3
|
|
14
|
+
|
|
3
15
|
## 1.0.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sproutsocial/seeds-react-drawer",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Seeds React Drawer",
|
|
5
5
|
"author": "Sprout Social, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
"test:watch": "jest --watch --coverage=false"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@sproutsocial/seeds-react-theme": "^
|
|
21
|
+
"@sproutsocial/seeds-react-theme": "^3.0.1",
|
|
22
22
|
"@sproutsocial/seeds-react-system-props": "^3.0.1",
|
|
23
|
-
"@sproutsocial/seeds-react-box": "^1.1.
|
|
24
|
-
"@sproutsocial/seeds-react-button": "^1.2.
|
|
25
|
-
"@sproutsocial/seeds-react-icon": "^1.1.
|
|
26
|
-
"@sproutsocial/seeds-react-text": "^1.3.
|
|
27
|
-
"@sproutsocial/seeds-react-portal": "^1.1.
|
|
23
|
+
"@sproutsocial/seeds-react-box": "^1.1.3",
|
|
24
|
+
"@sproutsocial/seeds-react-button": "^1.2.2",
|
|
25
|
+
"@sproutsocial/seeds-react-icon": "^1.1.3",
|
|
26
|
+
"@sproutsocial/seeds-react-text": "^1.3.2",
|
|
27
|
+
"@sproutsocial/seeds-react-portal": "^1.1.4",
|
|
28
28
|
"@sproutsocial/seeds-motion": "^1.8.0",
|
|
29
29
|
"@react-spring/web": "^9.0.0",
|
|
30
30
|
"react-focus-lock": "^2.0.3"
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@sproutsocial/eslint-config-seeds": "*",
|
|
36
36
|
"react": "^18.0.0",
|
|
37
37
|
"styled-components": "^5.2.3",
|
|
38
|
-
"tsup": "^8.
|
|
38
|
+
"tsup": "^8.3.4",
|
|
39
39
|
"typescript": "^5.6.2",
|
|
40
40
|
"@sproutsocial/seeds-tsconfig": "*",
|
|
41
41
|
"@sproutsocial/seeds-testing": "*",
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
import React, { useState } from "react";
|
|
4
4
|
import {
|
|
5
5
|
render as testRender,
|
|
6
|
-
fireEvent,
|
|
7
6
|
waitFor,
|
|
7
|
+
screen,
|
|
8
|
+
act,
|
|
8
9
|
} from "@sproutsocial/seeds-react-testing-library";
|
|
9
10
|
import type { TypeDrawerProps } from "../DrawerTypes";
|
|
10
11
|
import Drawer from "../Drawer";
|
|
@@ -18,7 +19,9 @@ const StatefulDrawer = ({
|
|
|
18
19
|
const [isDrawerOpen, setIsDrawerOpen] = useState(isOpen || false);
|
|
19
20
|
|
|
20
21
|
const onDrawerClose = () => {
|
|
21
|
-
|
|
22
|
+
act(() => {
|
|
23
|
+
setIsDrawerOpen(false);
|
|
24
|
+
});
|
|
22
25
|
onClose();
|
|
23
26
|
};
|
|
24
27
|
|
|
@@ -55,53 +58,59 @@ const render = ({
|
|
|
55
58
|
}: Partial<TypeDrawerProps>) => {
|
|
56
59
|
const { baseElement } = testRender(<div id="main-content" />);
|
|
57
60
|
const mainContentRef = baseElement.querySelector("#main-content");
|
|
58
|
-
return
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
61
|
+
return {
|
|
62
|
+
...testRender(
|
|
63
|
+
<div>
|
|
64
|
+
{baseElement.innerHTML}
|
|
65
|
+
<StatefulDrawer
|
|
66
|
+
isOpen={isOpen}
|
|
67
|
+
direction={direction}
|
|
68
|
+
offset={offset}
|
|
69
|
+
onClose={onClose}
|
|
70
|
+
closeButtonLabel={closeButtonLabel}
|
|
71
|
+
id={id}
|
|
72
|
+
disableCloseOnClickOutside={disableCloseOnClickOutside}
|
|
73
|
+
// @ts-ignore - We'll come back to test updating this
|
|
74
|
+
closeTargets={[mainContentRef]}
|
|
75
|
+
width={width}
|
|
76
|
+
>
|
|
77
|
+
{children}
|
|
78
|
+
</StatefulDrawer>
|
|
79
|
+
</div>
|
|
80
|
+
),
|
|
81
|
+
};
|
|
77
82
|
};
|
|
78
83
|
|
|
79
84
|
describe("Drawer", () => {
|
|
80
85
|
it("should not be in the document by default", () => {
|
|
81
|
-
|
|
82
|
-
expect(queryByText(/drawer content/i)).not.toBeInTheDocument();
|
|
86
|
+
render({});
|
|
87
|
+
expect(screen.queryByText(/drawer content/i)).not.toBeInTheDocument();
|
|
83
88
|
});
|
|
84
89
|
|
|
85
90
|
it("should render drawer", () => {
|
|
86
|
-
|
|
91
|
+
render({
|
|
87
92
|
isOpen: true,
|
|
88
93
|
});
|
|
89
|
-
expect(getByText(/drawer content/i)).toBeInTheDocument();
|
|
94
|
+
expect(screen.getByText(/drawer content/i)).toBeInTheDocument();
|
|
90
95
|
});
|
|
91
96
|
|
|
92
|
-
|
|
93
|
-
const {
|
|
97
|
+
it("should close drawer on header click", async () => {
|
|
98
|
+
const { user } = render({
|
|
94
99
|
isOpen: true,
|
|
95
100
|
});
|
|
96
|
-
|
|
97
|
-
|
|
101
|
+
|
|
102
|
+
expect(screen.getByText(/drawer content/i)).toBeInTheDocument();
|
|
103
|
+
await act(async () => {
|
|
104
|
+
await user.click(screen.getByLabelText("close button"));
|
|
105
|
+
});
|
|
106
|
+
|
|
98
107
|
await waitFor(() => {
|
|
99
|
-
expect(queryByText(/drawer content/i)).not.toBeInTheDocument();
|
|
108
|
+
expect(screen.queryByText(/drawer content/i)).not.toBeInTheDocument();
|
|
100
109
|
});
|
|
101
110
|
});
|
|
102
111
|
|
|
103
|
-
|
|
104
|
-
const {
|
|
112
|
+
it("should close drawer on header click when using custom header", async () => {
|
|
113
|
+
const { user } = render({
|
|
105
114
|
isOpen: true,
|
|
106
115
|
children: (
|
|
107
116
|
<React.Fragment>
|
|
@@ -115,74 +124,86 @@ describe("Drawer", () => {
|
|
|
115
124
|
</React.Fragment>
|
|
116
125
|
),
|
|
117
126
|
});
|
|
118
|
-
expect(getByText(/drawer content/i)).toBeInTheDocument();
|
|
119
|
-
|
|
127
|
+
expect(screen.getByText(/drawer content/i)).toBeInTheDocument();
|
|
128
|
+
await act(async () => {
|
|
129
|
+
await user.click(screen.getByLabelText("close button"));
|
|
130
|
+
});
|
|
120
131
|
await waitFor(() => {
|
|
121
|
-
expect(queryByText(/drawer content/i)).not.toBeInTheDocument();
|
|
132
|
+
expect(screen.queryByText(/drawer content/i)).not.toBeInTheDocument();
|
|
122
133
|
});
|
|
123
134
|
});
|
|
124
135
|
|
|
125
|
-
|
|
126
|
-
const {
|
|
136
|
+
it("should close drawer on outside click", async () => {
|
|
137
|
+
const { user, baseElement } = render({
|
|
127
138
|
isOpen: true,
|
|
128
139
|
});
|
|
129
|
-
expect(getByText(/drawer content/i)).toBeInTheDocument();
|
|
130
|
-
|
|
140
|
+
expect(screen.getByText(/drawer content/i)).toBeInTheDocument();
|
|
141
|
+
await act(async () => {
|
|
142
|
+
await user.click(baseElement.querySelector("#main-content") as Element);
|
|
143
|
+
});
|
|
131
144
|
await waitFor(() => {
|
|
132
|
-
expect(queryByText(/drawer content/i)).not.toBeInTheDocument();
|
|
145
|
+
expect(screen.queryByText(/drawer content/i)).not.toBeInTheDocument();
|
|
133
146
|
});
|
|
134
147
|
});
|
|
135
148
|
|
|
136
149
|
it("should not close drawer on outside click when disabled", async () => {
|
|
137
|
-
const {
|
|
150
|
+
const { user, baseElement } = render({
|
|
138
151
|
isOpen: true,
|
|
139
152
|
disableCloseOnClickOutside: true,
|
|
140
153
|
});
|
|
141
|
-
expect(getByText(/drawer content/i)).toBeInTheDocument();
|
|
142
|
-
|
|
154
|
+
expect(screen.getByText(/drawer content/i)).toBeInTheDocument();
|
|
155
|
+
await user.click(baseElement.querySelector("#main-content") as Element);
|
|
143
156
|
await waitFor(() => {
|
|
144
157
|
// eslint-disable-next-line testing-library/prefer-presence-queries
|
|
145
|
-
expect(queryByText(/drawer content/i)).toBeInTheDocument();
|
|
158
|
+
expect(screen.queryByText(/drawer content/i)).toBeInTheDocument();
|
|
146
159
|
});
|
|
147
160
|
});
|
|
148
161
|
|
|
149
162
|
it("should close drawer on esc key", async () => {
|
|
150
|
-
const {
|
|
163
|
+
const { user, baseElement } = render({
|
|
151
164
|
isOpen: true,
|
|
152
165
|
disableCloseOnClickOutside: true,
|
|
153
166
|
});
|
|
154
|
-
expect(getByText(/drawer content/i)).toBeInTheDocument();
|
|
155
|
-
|
|
156
|
-
|
|
167
|
+
expect(screen.getByText(/drawer content/i)).toBeInTheDocument();
|
|
168
|
+
await act(async () => {
|
|
169
|
+
await user.keyboard("{Escape}");
|
|
157
170
|
});
|
|
158
171
|
await waitFor(() => {
|
|
159
|
-
expect(queryByText(/drawer content/i)).not.toBeInTheDocument();
|
|
172
|
+
expect(screen.queryByText(/drawer content/i)).not.toBeInTheDocument();
|
|
160
173
|
});
|
|
161
174
|
});
|
|
175
|
+
|
|
162
176
|
it("should have dialog role", () => {
|
|
163
|
-
|
|
177
|
+
render({
|
|
164
178
|
isOpen: true,
|
|
165
179
|
});
|
|
166
|
-
expect(getByRole("dialog")).toBeInTheDocument();
|
|
180
|
+
expect(screen.getByRole("dialog")).toBeInTheDocument();
|
|
167
181
|
});
|
|
182
|
+
|
|
168
183
|
it("should have focus on drawer when opened", () => {
|
|
169
|
-
|
|
184
|
+
render({
|
|
170
185
|
isOpen: true,
|
|
171
186
|
});
|
|
172
|
-
expect(getByLabelText("close button")).toHaveFocus();
|
|
187
|
+
expect(screen.getByLabelText("close button")).toHaveFocus();
|
|
173
188
|
});
|
|
189
|
+
|
|
174
190
|
it("should have an h2 with id", () => {
|
|
175
|
-
|
|
191
|
+
render({
|
|
176
192
|
isOpen: true,
|
|
177
193
|
});
|
|
178
|
-
expect(getByRole("heading")).toHaveAttribute(
|
|
194
|
+
expect(screen.getByRole("heading")).toHaveAttribute(
|
|
195
|
+
"id",
|
|
196
|
+
"drawer-1-header"
|
|
197
|
+
);
|
|
179
198
|
});
|
|
199
|
+
|
|
180
200
|
it("should be 600px wide by default", () => {
|
|
181
|
-
|
|
182
|
-
expect(getByRole("dialog")).toHaveStyle("width: 600px");
|
|
201
|
+
render({ isOpen: true });
|
|
202
|
+
expect(screen.getByRole("dialog")).toHaveStyle("width: 600px");
|
|
183
203
|
});
|
|
204
|
+
|
|
184
205
|
it("should customize the drawer width when provided", () => {
|
|
185
|
-
|
|
186
|
-
expect(getByRole("dialog")).toHaveStyle("width: 400px");
|
|
206
|
+
render({ isOpen: true, width: 400 });
|
|
207
|
+
expect(screen.getByRole("dialog")).toHaveStyle("width: 400px");
|
|
187
208
|
});
|
|
188
209
|
});
|