@dt-dds/react-drawer 1.0.0-beta.47
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/CHANGELOG.md +447 -0
- package/LICENSE.md +21 -0
- package/README.md +111 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +483 -0
- package/dist/index.mjs +449 -0
- package/package.json +56 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
|
|
21
|
+
// src/Drawer.tsx
|
|
22
|
+
import { useTheme as useTheme3, Global } from "@emotion/react";
|
|
23
|
+
import { useCallback, useEffect as useEffect2, useState } from "react";
|
|
24
|
+
|
|
25
|
+
// src/components/title/DrawerTitle.tsx
|
|
26
|
+
import { Typography } from "@dt-dds/react-typography";
|
|
27
|
+
import { jsx } from "react/jsx-runtime";
|
|
28
|
+
var DrawerTitle = ({ title }) => /* @__PURE__ */ jsx(Typography, { color: "content.dark", element: "h4", fontStyles: "h4", children: title });
|
|
29
|
+
|
|
30
|
+
// src/components/header/DrawerHeader.tsx
|
|
31
|
+
import { IconButton } from "@dt-dds/react-icon-button";
|
|
32
|
+
|
|
33
|
+
// ../../dt-dds-react/core/assets/svgs/AllOut.tsx
|
|
34
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
35
|
+
|
|
36
|
+
// ../../dt-dds-react/core/assets/svgs/Apis.tsx
|
|
37
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
38
|
+
|
|
39
|
+
// ../../dt-dds-react/core/assets/svgs/Apps.tsx
|
|
40
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
41
|
+
|
|
42
|
+
// ../../dt-dds-react/core/assets/svgs/ArrowDropDown.tsx
|
|
43
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
44
|
+
|
|
45
|
+
// ../../dt-dds-react/core/assets/svgs/ArrowDropUp.tsx
|
|
46
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
47
|
+
|
|
48
|
+
// ../../dt-dds-react/core/assets/svgs/ArrowLeft.tsx
|
|
49
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
50
|
+
|
|
51
|
+
// ../../dt-dds-react/core/assets/svgs/ArrowRight.tsx
|
|
52
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
53
|
+
|
|
54
|
+
// ../../dt-dds-react/core/assets/svgs/AvatarThumbnail.tsx
|
|
55
|
+
import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
56
|
+
|
|
57
|
+
// ../../dt-dds-react/core/assets/svgs/Bolt.tsx
|
|
58
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
59
|
+
|
|
60
|
+
// ../../dt-dds-react/core/assets/svgs/CalendarMonth.tsx
|
|
61
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
62
|
+
|
|
63
|
+
// ../../dt-dds-react/core/assets/svgs/Cancel.tsx
|
|
64
|
+
import { jsx as jsx12, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
65
|
+
|
|
66
|
+
// ../../dt-dds-react/core/assets/svgs/Check.tsx
|
|
67
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
68
|
+
|
|
69
|
+
// ../../dt-dds-react/core/assets/svgs/CheckCircle.tsx
|
|
70
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
71
|
+
|
|
72
|
+
// ../../dt-dds-react/core/assets/svgs/CheckCircleOutline.tsx
|
|
73
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
74
|
+
|
|
75
|
+
// ../../dt-dds-react/core/assets/svgs/Close.tsx
|
|
76
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
77
|
+
var CloseIcon = (props) => {
|
|
78
|
+
return /* @__PURE__ */ jsx16(
|
|
79
|
+
"svg",
|
|
80
|
+
__spreadProps(__spreadValues({
|
|
81
|
+
fill: "none",
|
|
82
|
+
height: "24",
|
|
83
|
+
viewBox: "0 0 24 24",
|
|
84
|
+
width: "24",
|
|
85
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
86
|
+
}, props), {
|
|
87
|
+
children: /* @__PURE__ */ jsx16(
|
|
88
|
+
"path",
|
|
89
|
+
{
|
|
90
|
+
d: "M19 6.41L17.59 5L12 10.59L6.41 5L5 6.41L10.59 12L5 17.59L6.41 19L12 13.41L17.59 19L19 17.59L13.41 12L19 6.41Z",
|
|
91
|
+
fill: "currentColor"
|
|
92
|
+
}
|
|
93
|
+
)
|
|
94
|
+
})
|
|
95
|
+
);
|
|
96
|
+
};
|
|
97
|
+
var Close_default = CloseIcon;
|
|
98
|
+
|
|
99
|
+
// ../../dt-dds-react/core/assets/svgs/Copy.tsx
|
|
100
|
+
import { jsx as jsx17, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
101
|
+
|
|
102
|
+
// ../../dt-dds-react/core/assets/svgs/Delete.tsx
|
|
103
|
+
import { jsx as jsx18, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
104
|
+
|
|
105
|
+
// ../../dt-dds-react/core/assets/svgs/Edit.tsx
|
|
106
|
+
import { jsx as jsx19, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
107
|
+
|
|
108
|
+
// ../../dt-dds-react/core/assets/svgs/Email.tsx
|
|
109
|
+
import { jsx as jsx20, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
110
|
+
|
|
111
|
+
// ../../dt-dds-react/core/assets/svgs/EmailSend.tsx
|
|
112
|
+
import { jsx as jsx21, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
113
|
+
|
|
114
|
+
// ../../dt-dds-react/core/assets/svgs/Error.tsx
|
|
115
|
+
import { useTheme } from "@emotion/react";
|
|
116
|
+
import { jsx as jsx22, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
117
|
+
|
|
118
|
+
// ../../dt-dds-react/core/assets/svgs/ErrorOutline.tsx
|
|
119
|
+
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
120
|
+
|
|
121
|
+
// ../../dt-dds-react/core/assets/svgs/EVStation.tsx
|
|
122
|
+
import { jsx as jsx24 } from "react/jsx-runtime";
|
|
123
|
+
|
|
124
|
+
// ../../dt-dds-react/core/assets/svgs/Info.tsx
|
|
125
|
+
import { jsx as jsx25 } from "react/jsx-runtime";
|
|
126
|
+
|
|
127
|
+
// ../../dt-dds-react/core/assets/svgs/InfoOutline.tsx
|
|
128
|
+
import { jsx as jsx26 } from "react/jsx-runtime";
|
|
129
|
+
|
|
130
|
+
// ../../dt-dds-react/core/assets/svgs/Input.tsx
|
|
131
|
+
import { jsx as jsx27, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
132
|
+
|
|
133
|
+
// ../../dt-dds-react/core/assets/svgs/Language.tsx
|
|
134
|
+
import { jsx as jsx28 } from "react/jsx-runtime";
|
|
135
|
+
|
|
136
|
+
// ../../dt-dds-react/core/assets/svgs/LocationOn.tsx
|
|
137
|
+
import { jsx as jsx29, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
138
|
+
|
|
139
|
+
// ../../dt-dds-react/core/assets/svgs/LocationSearching.tsx
|
|
140
|
+
import { jsx as jsx30 } from "react/jsx-runtime";
|
|
141
|
+
|
|
142
|
+
// ../../dt-dds-react/core/assets/svgs/MenuCompact.tsx
|
|
143
|
+
import { jsx as jsx31 } from "react/jsx-runtime";
|
|
144
|
+
|
|
145
|
+
// ../../dt-dds-react/core/assets/svgs/MenuExpand.tsx
|
|
146
|
+
import { jsx as jsx32 } from "react/jsx-runtime";
|
|
147
|
+
|
|
148
|
+
// ../../dt-dds-react/core/assets/svgs/Menu.tsx
|
|
149
|
+
import { jsx as jsx33 } from "react/jsx-runtime";
|
|
150
|
+
|
|
151
|
+
// ../../dt-dds-react/core/assets/svgs/MoreHorizontal.tsx
|
|
152
|
+
import { jsx as jsx34 } from "react/jsx-runtime";
|
|
153
|
+
|
|
154
|
+
// ../../dt-dds-react/core/assets/svgs/MoreVertical.tsx
|
|
155
|
+
import { jsx as jsx35 } from "react/jsx-runtime";
|
|
156
|
+
|
|
157
|
+
// ../../dt-dds-react/core/assets/svgs/NoData.tsx
|
|
158
|
+
import { useTheme as useTheme2 } from "@emotion/react";
|
|
159
|
+
import { jsx as jsx36, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
160
|
+
|
|
161
|
+
// ../../dt-dds-react/core/assets/svgs/NotFound.tsx
|
|
162
|
+
import { jsx as jsx37, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
163
|
+
|
|
164
|
+
// ../../dt-dds-react/core/assets/svgs/OutlinedArrowDropDown.tsx
|
|
165
|
+
import { jsx as jsx38 } from "react/jsx-runtime";
|
|
166
|
+
|
|
167
|
+
// ../../dt-dds-react/core/assets/svgs/OutlinedArrowDropUp.tsx
|
|
168
|
+
import { jsx as jsx39 } from "react/jsx-runtime";
|
|
169
|
+
|
|
170
|
+
// ../../dt-dds-react/core/assets/svgs/PhoneOutlined.tsx
|
|
171
|
+
import { jsx as jsx40 } from "react/jsx-runtime";
|
|
172
|
+
|
|
173
|
+
// ../../dt-dds-react/core/assets/svgs/Payments.tsx
|
|
174
|
+
import { jsx as jsx41 } from "react/jsx-runtime";
|
|
175
|
+
|
|
176
|
+
// ../../dt-dds-react/core/assets/svgs/Products.tsx
|
|
177
|
+
import { jsx as jsx42, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
178
|
+
|
|
179
|
+
// ../../dt-dds-react/core/assets/svgs/RemoveCircleOutline.tsx
|
|
180
|
+
import { jsx as jsx43 } from "react/jsx-runtime";
|
|
181
|
+
|
|
182
|
+
// ../../dt-dds-react/core/assets/svgs/Share.tsx
|
|
183
|
+
import { jsx as jsx44, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
184
|
+
|
|
185
|
+
// ../../dt-dds-react/core/assets/svgs/Signout.tsx
|
|
186
|
+
import { jsx as jsx45 } from "react/jsx-runtime";
|
|
187
|
+
|
|
188
|
+
// ../../dt-dds-react/core/assets/svgs/Teams.tsx
|
|
189
|
+
import { jsx as jsx46, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
190
|
+
|
|
191
|
+
// ../../dt-dds-react/core/assets/svgs/Timeline.tsx
|
|
192
|
+
import { jsx as jsx47, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
193
|
+
|
|
194
|
+
// ../../dt-dds-react/core/assets/svgs/Topic.tsx
|
|
195
|
+
import { jsx as jsx48, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
196
|
+
|
|
197
|
+
// ../../dt-dds-react/core/assets/svgs/UnfoldLess.tsx
|
|
198
|
+
import { jsx as jsx49 } from "react/jsx-runtime";
|
|
199
|
+
|
|
200
|
+
// ../../dt-dds-react/core/assets/svgs/UnfoldMore.tsx
|
|
201
|
+
import { jsx as jsx50 } from "react/jsx-runtime";
|
|
202
|
+
|
|
203
|
+
// ../../dt-dds-react/core/assets/svgs/Username.tsx
|
|
204
|
+
import { jsx as jsx51, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
205
|
+
|
|
206
|
+
// ../../dt-dds-react/core/assets/svgs/ViewAgenda.tsx
|
|
207
|
+
import { jsx as jsx52, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
208
|
+
|
|
209
|
+
// ../../dt-dds-react/core/assets/svgs/Visibility.tsx
|
|
210
|
+
import { jsx as jsx53, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
211
|
+
|
|
212
|
+
// ../../dt-dds-react/core/assets/svgs/VisibilityOff.tsx
|
|
213
|
+
import { jsx as jsx54, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
214
|
+
|
|
215
|
+
// ../../dt-dds-react/core/assets/svgs/WarningOutline.tsx
|
|
216
|
+
import { jsx as jsx55 } from "react/jsx-runtime";
|
|
217
|
+
|
|
218
|
+
// ../../dt-dds-react/core/assets/svgs/Warning.tsx
|
|
219
|
+
import { jsx as jsx56 } from "react/jsx-runtime";
|
|
220
|
+
|
|
221
|
+
// ../../dt-dds-react/core/assets/svgs/Wifi.tsx
|
|
222
|
+
import { jsx as jsx57 } from "react/jsx-runtime";
|
|
223
|
+
|
|
224
|
+
// ../../dt-dds-react/core/assets/svgs/Settings.tsx
|
|
225
|
+
import { jsx as jsx58 } from "react/jsx-runtime";
|
|
226
|
+
|
|
227
|
+
// src/context/DrawerProvider.tsx
|
|
228
|
+
import { createContext, useContext } from "react";
|
|
229
|
+
import { jsx as jsx59 } from "react/jsx-runtime";
|
|
230
|
+
var DEFAULT_VALUE = {
|
|
231
|
+
handleClose: () => null
|
|
232
|
+
};
|
|
233
|
+
var DrawerContext = createContext(DEFAULT_VALUE);
|
|
234
|
+
var DrawerContextProvider = ({
|
|
235
|
+
handleClose,
|
|
236
|
+
children
|
|
237
|
+
}) => {
|
|
238
|
+
return /* @__PURE__ */ jsx59(DrawerContext.Provider, { value: { handleClose }, children });
|
|
239
|
+
};
|
|
240
|
+
var useDrawerContext = () => {
|
|
241
|
+
const context = useContext(DrawerContext);
|
|
242
|
+
if (!context) {
|
|
243
|
+
throw new Error(
|
|
244
|
+
"Drawer compound components cannot be rendered outside the Drawer component"
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
return context;
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
// src/components/header/DrawerHeader.styled.ts
|
|
251
|
+
import styled from "@emotion/styled";
|
|
252
|
+
var HeaderStyled = styled.header`
|
|
253
|
+
${({ theme }) => `
|
|
254
|
+
display: flex;
|
|
255
|
+
justify-content: space-between;
|
|
256
|
+
align-items: flex-start;
|
|
257
|
+
padding: 0 ${theme.spacing.xs} ${theme.spacing["2xs"]};
|
|
258
|
+
|
|
259
|
+
&:has(+.hasScroll) {
|
|
260
|
+
box-shadow: ${theme.shadows.xs};
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
@media only screen and (min-width: ${theme.breakpoints.s}px) {
|
|
264
|
+
padding: 0 ${theme.spacing.s} ${theme.spacing["2xs"]};
|
|
265
|
+
}
|
|
266
|
+
`}
|
|
267
|
+
`;
|
|
268
|
+
|
|
269
|
+
// src/components/header/DrawerHeader.tsx
|
|
270
|
+
import { jsx as jsx60, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
271
|
+
var DrawerHeader = ({ children }) => {
|
|
272
|
+
const { handleClose } = useDrawerContext();
|
|
273
|
+
return /* @__PURE__ */ jsxs25(HeaderStyled, { "data-testid": "drawer-header", children: [
|
|
274
|
+
/* @__PURE__ */ jsx60("div", { children }),
|
|
275
|
+
/* @__PURE__ */ jsx60(
|
|
276
|
+
IconButton,
|
|
277
|
+
{
|
|
278
|
+
color: "default",
|
|
279
|
+
dataTestId: "drawer-close-button",
|
|
280
|
+
onClick: handleClose,
|
|
281
|
+
children: /* @__PURE__ */ jsx60(Close_default, {})
|
|
282
|
+
}
|
|
283
|
+
)
|
|
284
|
+
] });
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
// src/components/body/DrawerBody.tsx
|
|
288
|
+
import { useEffect, useRef } from "react";
|
|
289
|
+
|
|
290
|
+
// src/components/body/DrawerBody.styled.ts
|
|
291
|
+
import styled2 from "@emotion/styled";
|
|
292
|
+
var DrawerContentStyled = styled2.section`
|
|
293
|
+
${({ theme }) => `
|
|
294
|
+
position: relative;
|
|
295
|
+
overflow: auto;
|
|
296
|
+
padding: ${theme.spacing["2xs"]} ${theme.spacing.xs} 0;
|
|
297
|
+
|
|
298
|
+
@media only screen and (min-width: ${theme.breakpoints.s}px) {
|
|
299
|
+
padding: ${theme.spacing["2xs"]} ${theme.spacing.s} 0;
|
|
300
|
+
}
|
|
301
|
+
`}
|
|
302
|
+
`;
|
|
303
|
+
var ScrollableSectionObserverStyled = styled2.div`
|
|
304
|
+
position: absolute;
|
|
305
|
+
margin-top: ${({ theme }) => theme.spacing["4xs"]};
|
|
306
|
+
`;
|
|
307
|
+
|
|
308
|
+
// src/components/body/DrawerBody.tsx
|
|
309
|
+
import { jsx as jsx61, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
310
|
+
var DrawerBody = ({ children, style, dataTestId }) => {
|
|
311
|
+
const scrollableSectionObserverRef = useRef(null);
|
|
312
|
+
const handleScrollClass = (isSectionScrollable) => {
|
|
313
|
+
var _a;
|
|
314
|
+
const sectionElement = (_a = scrollableSectionObserverRef.current) == null ? void 0 : _a.parentElement;
|
|
315
|
+
if (sectionElement) {
|
|
316
|
+
isSectionScrollable ? sectionElement.classList.add("hasScroll") : sectionElement.classList.remove("hasScroll");
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
useEffect(() => {
|
|
320
|
+
if (scrollableSectionObserverRef.current) {
|
|
321
|
+
const observer = new IntersectionObserver(
|
|
322
|
+
([{ isIntersecting: isSectionObserverVisible }]) => handleScrollClass(!isSectionObserverVisible)
|
|
323
|
+
);
|
|
324
|
+
observer.observe(scrollableSectionObserverRef.current);
|
|
325
|
+
return () => observer.disconnect();
|
|
326
|
+
}
|
|
327
|
+
}, [scrollableSectionObserverRef]);
|
|
328
|
+
return /* @__PURE__ */ jsxs26(
|
|
329
|
+
DrawerContentStyled,
|
|
330
|
+
{
|
|
331
|
+
"data-testid": dataTestId != null ? dataTestId : "drawer-body",
|
|
332
|
+
style,
|
|
333
|
+
children: [
|
|
334
|
+
children,
|
|
335
|
+
/* @__PURE__ */ jsx61(ScrollableSectionObserverStyled, { ref: scrollableSectionObserverRef })
|
|
336
|
+
]
|
|
337
|
+
}
|
|
338
|
+
);
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
// src/Drawer.styled.ts
|
|
342
|
+
import { DRAWER_Z_INDEX } from "@dt-dds/react-core";
|
|
343
|
+
import { css } from "@emotion/react";
|
|
344
|
+
import styled3 from "@emotion/styled";
|
|
345
|
+
var GlobalStyle = css`
|
|
346
|
+
body {
|
|
347
|
+
overflow: hidden;
|
|
348
|
+
}
|
|
349
|
+
`;
|
|
350
|
+
var MainContainerStyled = styled3.div`
|
|
351
|
+
width: 100%;
|
|
352
|
+
height: 100%;
|
|
353
|
+
position: fixed;
|
|
354
|
+
top: 0;
|
|
355
|
+
left: 0;
|
|
356
|
+
z-index: ${DRAWER_Z_INDEX};
|
|
357
|
+
`;
|
|
358
|
+
var OverlayStyled = styled3.div`
|
|
359
|
+
${({ theme, isVisible }) => `
|
|
360
|
+
width: 100%;
|
|
361
|
+
height: 100vh;
|
|
362
|
+
position: absolute;
|
|
363
|
+
background-color: ${theme.palette.surface.dark};
|
|
364
|
+
opacity: ${isVisible ? 0.2 : 0};
|
|
365
|
+
transition: opacity ${theme.animations.emphasizedDecelerate.duration}
|
|
366
|
+
${theme.animations.emphasizedDecelerate.timingFunction};
|
|
367
|
+
`}
|
|
368
|
+
`;
|
|
369
|
+
var DrawerStyled = styled3.div`
|
|
370
|
+
${({ theme, isVisible }) => `
|
|
371
|
+
display: grid;
|
|
372
|
+
grid-template-rows: auto 1fr;
|
|
373
|
+
padding: ${theme.spacing.xs} 0;
|
|
374
|
+
width: 100%;
|
|
375
|
+
height: 100%;
|
|
376
|
+
position: absolute;
|
|
377
|
+
top: 0;
|
|
378
|
+
right: 0;
|
|
379
|
+
background-color: ${theme.palette.surface.contrast};
|
|
380
|
+
transform: ${isVisible ? "translateX(0)" : "translateX(100%)"};
|
|
381
|
+
transition: transform ${theme.animations.emphasizedDecelerate.duration}
|
|
382
|
+
${theme.animations.emphasizedDecelerate.timingFunction};
|
|
383
|
+
|
|
384
|
+
@media only screen and (min-width: ${theme.breakpoints.s}px) {
|
|
385
|
+
width: 500px;
|
|
386
|
+
border-radius: ${theme.radius["3xs"]} ${theme.radius.none}
|
|
387
|
+
${theme.radius.none} ${theme.radius["3xs"]};
|
|
388
|
+
box-shadow: ${theme.shadows.s};
|
|
389
|
+
padding: ${theme.spacing.s} 0;
|
|
390
|
+
}
|
|
391
|
+
`}
|
|
392
|
+
`;
|
|
393
|
+
|
|
394
|
+
// src/Drawer.tsx
|
|
395
|
+
import { jsx as jsx62, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
396
|
+
var animationToMiliseconds = (duration) => parseFloat(duration.replace(/[^\d.]/g, "")) * 1e3;
|
|
397
|
+
var Drawer = ({
|
|
398
|
+
isVisible,
|
|
399
|
+
setIsVisible,
|
|
400
|
+
children,
|
|
401
|
+
dataTestId
|
|
402
|
+
}) => {
|
|
403
|
+
const [isTransformed, setIsTransformed] = useState(false);
|
|
404
|
+
const theme = useTheme3();
|
|
405
|
+
const handleClose = useCallback(() => {
|
|
406
|
+
setIsTransformed(false);
|
|
407
|
+
setTimeout(() => {
|
|
408
|
+
setIsVisible(false);
|
|
409
|
+
}, animationToMiliseconds(theme.animations.emphasizedDecelerate.timingFunction));
|
|
410
|
+
}, [setIsVisible, theme.animations.emphasizedDecelerate.timingFunction]);
|
|
411
|
+
useEffect2(() => {
|
|
412
|
+
const handleKeyDown = (event) => {
|
|
413
|
+
if (event.key === "Escape") {
|
|
414
|
+
handleClose();
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
setIsTransformed(isVisible);
|
|
418
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
419
|
+
return () => {
|
|
420
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
421
|
+
};
|
|
422
|
+
}, [handleClose, isVisible]);
|
|
423
|
+
return /* @__PURE__ */ jsx62(DrawerContextProvider, { handleClose, children: /* @__PURE__ */ jsxs27(MainContainerStyled, { children: [
|
|
424
|
+
isVisible ? /* @__PURE__ */ jsx62(Global, { styles: GlobalStyle }) : null,
|
|
425
|
+
/* @__PURE__ */ jsx62(
|
|
426
|
+
OverlayStyled,
|
|
427
|
+
{
|
|
428
|
+
"data-testid": "drawer-overlay",
|
|
429
|
+
isVisible: isTransformed,
|
|
430
|
+
onClick: handleClose
|
|
431
|
+
}
|
|
432
|
+
),
|
|
433
|
+
/* @__PURE__ */ jsx62(
|
|
434
|
+
DrawerStyled,
|
|
435
|
+
{
|
|
436
|
+
"data-testid": dataTestId != null ? dataTestId : "drawer-content-container",
|
|
437
|
+
isVisible: isTransformed,
|
|
438
|
+
children
|
|
439
|
+
}
|
|
440
|
+
)
|
|
441
|
+
] }) });
|
|
442
|
+
};
|
|
443
|
+
Drawer.Title = DrawerTitle;
|
|
444
|
+
Drawer.Header = DrawerHeader;
|
|
445
|
+
Drawer.Body = DrawerBody;
|
|
446
|
+
var Drawer_default = Drawer;
|
|
447
|
+
export {
|
|
448
|
+
Drawer_default as Drawer
|
|
449
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dt-dds/react-drawer",
|
|
3
|
+
"version": "1.0.0-beta.47",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": "./dist/index.js"
|
|
7
|
+
},
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"module": "./dist/index.mjs",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist/**"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsup",
|
|
16
|
+
"dev": "tsup --watch",
|
|
17
|
+
"lint": "eslint --cache .",
|
|
18
|
+
"test": "jest",
|
|
19
|
+
"test:report": "open ./jest-coverage/lcov-report/index.html",
|
|
20
|
+
"test:update:snapshot": "jest -u"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@dt-dds/react-core": "1.0.0-beta.41",
|
|
24
|
+
"@dt-dds/react-icon-button": "1.0.0-beta.9",
|
|
25
|
+
"@dt-dds/react-typography": "1.0.0-beta.32"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@babel/core": "^7.22.9",
|
|
29
|
+
"@babel/preset-env": "^7.22.9",
|
|
30
|
+
"@babel/preset-react": "^7.22.5",
|
|
31
|
+
"@babel/preset-typescript": "^7.23.3",
|
|
32
|
+
"@emotion/babel-plugin": "^11.11.0",
|
|
33
|
+
"@emotion/css": "^11.7.1",
|
|
34
|
+
"@emotion/jest": "^11.10.0",
|
|
35
|
+
"@emotion/react": "^11.8.2",
|
|
36
|
+
"@emotion/styled": "^11.8.1",
|
|
37
|
+
"@types/react": "^18.0.9",
|
|
38
|
+
"@types/react-dom": "^18.0.4",
|
|
39
|
+
"babel-loader": "^8.3.0",
|
|
40
|
+
"eslint-config-custom": "*",
|
|
41
|
+
"eslint-plugin-storybook": "^9.1.0",
|
|
42
|
+
"jest-config": "*",
|
|
43
|
+
"react": "^18.1.0",
|
|
44
|
+
"react-dom": "^18.2.0",
|
|
45
|
+
"tsconfig": "*",
|
|
46
|
+
"tsup": "^6.6.3",
|
|
47
|
+
"typescript": "^4.5.3"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"@emotion/css": "^11.7.1",
|
|
51
|
+
"@emotion/react": "^11.8.2",
|
|
52
|
+
"@emotion/styled": "^11.8.1",
|
|
53
|
+
"react": ">=17.0.2",
|
|
54
|
+
"react-dom": ">=17.0.2"
|
|
55
|
+
}
|
|
56
|
+
}
|