@dt-dds/react-toast 1.0.0-beta.56

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/dist/index.mjs ADDED
@@ -0,0 +1,539 @@
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
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
32
+
33
+ // ../../dt-dds-react/core/assets/svgs/AllOut.tsx
34
+ import { jsx, jsxs } from "react/jsx-runtime";
35
+
36
+ // ../../dt-dds-react/core/assets/svgs/Apis.tsx
37
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
38
+
39
+ // ../../dt-dds-react/core/assets/svgs/Apps.tsx
40
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
41
+
42
+ // ../../dt-dds-react/core/assets/svgs/ArrowDropDown.tsx
43
+ import { jsx as jsx4 } from "react/jsx-runtime";
44
+
45
+ // ../../dt-dds-react/core/assets/svgs/ArrowDropUp.tsx
46
+ import { jsx as jsx5 } from "react/jsx-runtime";
47
+
48
+ // ../../dt-dds-react/core/assets/svgs/ArrowLeft.tsx
49
+ import { jsx as jsx6 } from "react/jsx-runtime";
50
+
51
+ // ../../dt-dds-react/core/assets/svgs/ArrowRight.tsx
52
+ import { jsx as jsx7 } from "react/jsx-runtime";
53
+
54
+ // ../../dt-dds-react/core/assets/svgs/AvatarThumbnail.tsx
55
+ import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
56
+
57
+ // ../../dt-dds-react/core/assets/svgs/Bolt.tsx
58
+ import { jsx as jsx9 } from "react/jsx-runtime";
59
+
60
+ // ../../dt-dds-react/core/assets/svgs/CalendarMonth.tsx
61
+ import { jsx as jsx10 } from "react/jsx-runtime";
62
+
63
+ // ../../dt-dds-react/core/assets/svgs/Cancel.tsx
64
+ import { jsx as jsx11, jsxs as jsxs5 } from "react/jsx-runtime";
65
+
66
+ // ../../dt-dds-react/core/assets/svgs/Check.tsx
67
+ import { jsx as jsx12 } from "react/jsx-runtime";
68
+
69
+ // ../../dt-dds-react/core/assets/svgs/CheckCircle.tsx
70
+ import { jsx as jsx13 } from "react/jsx-runtime";
71
+
72
+ // ../../dt-dds-react/core/assets/svgs/CheckCircleOutline.tsx
73
+ import { jsx as jsx14 } from "react/jsx-runtime";
74
+ var CheckCircleOutlineIcon = (props) => {
75
+ return /* @__PURE__ */ jsx14(
76
+ "svg",
77
+ __spreadProps(__spreadValues({
78
+ fill: "currentColor",
79
+ height: "24",
80
+ viewBox: "0 0 24 24",
81
+ width: "24",
82
+ xmlns: "http://www.w3.org/2000/svg"
83
+ }, props), {
84
+ children: /* @__PURE__ */ jsx14(
85
+ "path",
86
+ {
87
+ d: "M12 0C5.376 0 0 5.376 0 12C0 18.624 5.376 24 12 24C18.624 24 24 18.624 24 12C24 5.376 18.624 0 12 0ZM12 21.6C6.708 21.6 2.4 17.292 2.4 12C2.4 6.708 6.708 2.4 12 2.4C17.292 2.4 21.6 6.708 21.6 12C21.6 17.292 17.292 21.6 12 21.6ZM17.508 6.696L9.6 14.604L6.492 11.508L4.8 13.2L9.6 18L19.2 8.4L17.508 6.696Z",
88
+ fill: "currentColor"
89
+ }
90
+ )
91
+ })
92
+ );
93
+ };
94
+ var CheckCircleOutline_default = CheckCircleOutlineIcon;
95
+
96
+ // ../../dt-dds-react/core/assets/svgs/Close.tsx
97
+ import { jsx as jsx15 } from "react/jsx-runtime";
98
+ var CloseIcon = (props) => {
99
+ return /* @__PURE__ */ jsx15(
100
+ "svg",
101
+ __spreadProps(__spreadValues({
102
+ fill: "none",
103
+ height: "24",
104
+ viewBox: "0 0 24 24",
105
+ width: "24",
106
+ xmlns: "http://www.w3.org/2000/svg"
107
+ }, props), {
108
+ children: /* @__PURE__ */ jsx15(
109
+ "path",
110
+ {
111
+ 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",
112
+ fill: "currentColor"
113
+ }
114
+ )
115
+ })
116
+ );
117
+ };
118
+ var Close_default = CloseIcon;
119
+
120
+ // ../../dt-dds-react/core/assets/svgs/Copy.tsx
121
+ import { jsx as jsx16, jsxs as jsxs6 } from "react/jsx-runtime";
122
+
123
+ // ../../dt-dds-react/core/assets/svgs/Delete.tsx
124
+ import { jsx as jsx17, jsxs as jsxs7 } from "react/jsx-runtime";
125
+
126
+ // ../../dt-dds-react/core/assets/svgs/Edit.tsx
127
+ import { jsx as jsx18, jsxs as jsxs8 } from "react/jsx-runtime";
128
+
129
+ // ../../dt-dds-react/core/assets/svgs/Email.tsx
130
+ import { jsx as jsx19, jsxs as jsxs9 } from "react/jsx-runtime";
131
+
132
+ // ../../dt-dds-react/core/assets/svgs/EmailSend.tsx
133
+ import { jsx as jsx20, jsxs as jsxs10 } from "react/jsx-runtime";
134
+
135
+ // ../../dt-dds-react/core/assets/svgs/Error.tsx
136
+ import { useTheme } from "@emotion/react";
137
+ import { jsx as jsx21, jsxs as jsxs11 } from "react/jsx-runtime";
138
+
139
+ // ../../dt-dds-react/core/assets/svgs/ErrorOutline.tsx
140
+ import { jsx as jsx22 } from "react/jsx-runtime";
141
+ var ErrorOutline = (props) => {
142
+ return /* @__PURE__ */ jsx22(
143
+ "svg",
144
+ __spreadProps(__spreadValues({
145
+ fill: "none",
146
+ height: "24",
147
+ viewBox: "0 0 24 24",
148
+ width: "24",
149
+ xmlns: "http://www.w3.org/2000/svg"
150
+ }, props), {
151
+ children: /* @__PURE__ */ jsx22(
152
+ "path",
153
+ {
154
+ d: "M11.988 0C5.364 0 0 5.376 0 12C0 18.624 5.364 24 11.988 24C18.624 24 24 18.624 24 12C24 5.376 18.624 0 11.988 0ZM12 21.6C6.696 21.6 2.4 17.304 2.4 12C2.4 6.696 6.696 2.4 12 2.4C17.304 2.4 21.6 6.696 21.6 12C21.6 17.304 17.304 21.6 12 21.6ZM10.8 15.6H13.2V18H10.8V15.6ZM10.8 6H13.2V13.2H10.8V6Z",
155
+ fill: "currentColor"
156
+ }
157
+ )
158
+ })
159
+ );
160
+ };
161
+ var ErrorOutline_default = ErrorOutline;
162
+
163
+ // ../../dt-dds-react/core/assets/svgs/EVStation.tsx
164
+ import { jsx as jsx23 } from "react/jsx-runtime";
165
+
166
+ // ../../dt-dds-react/core/assets/svgs/Info.tsx
167
+ import { jsx as jsx24 } from "react/jsx-runtime";
168
+
169
+ // ../../dt-dds-react/core/assets/svgs/InfoOutline.tsx
170
+ import { jsx as jsx25 } from "react/jsx-runtime";
171
+ var InfoOutline = (props) => {
172
+ return /* @__PURE__ */ jsx25(
173
+ "svg",
174
+ __spreadProps(__spreadValues({
175
+ fill: "currentColor",
176
+ height: "24",
177
+ viewBox: "0 0 24 24",
178
+ width: "24",
179
+ xmlns: "http://www.w3.org/2000/svg"
180
+ }, props), {
181
+ children: /* @__PURE__ */ jsx25("path", { d: "M11 7H13V9H11V7ZM11 11H13V17H11V11ZM12 2C6.48 2 2 6.48 2 12C2 17.52 6.48 22 12 22C17.52 22 22 17.52 22 12C22 6.48 17.52 2 12 2ZM12 20C7.59 20 4 16.41 4 12C4 7.59 7.59 4 12 4C16.41 4 20 7.59 20 12C20 16.41 16.41 20 12 20Z" })
182
+ })
183
+ );
184
+ };
185
+ var InfoOutline_default = InfoOutline;
186
+
187
+ // ../../dt-dds-react/core/assets/svgs/Input.tsx
188
+ import { jsx as jsx26, jsxs as jsxs12 } from "react/jsx-runtime";
189
+
190
+ // ../../dt-dds-react/core/assets/svgs/Language.tsx
191
+ import { jsx as jsx27 } from "react/jsx-runtime";
192
+
193
+ // ../../dt-dds-react/core/assets/svgs/LocationOn.tsx
194
+ import { jsx as jsx28, jsxs as jsxs13 } from "react/jsx-runtime";
195
+
196
+ // ../../dt-dds-react/core/assets/svgs/LocationSearching.tsx
197
+ import { jsx as jsx29 } from "react/jsx-runtime";
198
+
199
+ // ../../dt-dds-react/core/assets/svgs/MenuCompact.tsx
200
+ import { jsx as jsx30 } from "react/jsx-runtime";
201
+
202
+ // ../../dt-dds-react/core/assets/svgs/MenuExpand.tsx
203
+ import { jsx as jsx31 } from "react/jsx-runtime";
204
+
205
+ // ../../dt-dds-react/core/assets/svgs/Menu.tsx
206
+ import { jsx as jsx32 } from "react/jsx-runtime";
207
+
208
+ // ../../dt-dds-react/core/assets/svgs/MoreHorizontal.tsx
209
+ import { jsx as jsx33 } from "react/jsx-runtime";
210
+
211
+ // ../../dt-dds-react/core/assets/svgs/MoreVertical.tsx
212
+ import { jsx as jsx34 } from "react/jsx-runtime";
213
+
214
+ // ../../dt-dds-react/core/assets/svgs/NoData.tsx
215
+ import { useTheme as useTheme2 } from "@emotion/react";
216
+ import { jsx as jsx35, jsxs as jsxs14 } from "react/jsx-runtime";
217
+
218
+ // ../../dt-dds-react/core/assets/svgs/NotFound.tsx
219
+ import { jsx as jsx36, jsxs as jsxs15 } from "react/jsx-runtime";
220
+
221
+ // ../../dt-dds-react/core/assets/svgs/OutlinedArrowDropDown.tsx
222
+ import { jsx as jsx37 } from "react/jsx-runtime";
223
+
224
+ // ../../dt-dds-react/core/assets/svgs/OutlinedArrowDropUp.tsx
225
+ import { jsx as jsx38 } from "react/jsx-runtime";
226
+
227
+ // ../../dt-dds-react/core/assets/svgs/PhoneOutlined.tsx
228
+ import { jsx as jsx39 } from "react/jsx-runtime";
229
+
230
+ // ../../dt-dds-react/core/assets/svgs/Payments.tsx
231
+ import { jsx as jsx40 } from "react/jsx-runtime";
232
+
233
+ // ../../dt-dds-react/core/assets/svgs/Products.tsx
234
+ import { jsx as jsx41, jsxs as jsxs16 } from "react/jsx-runtime";
235
+
236
+ // ../../dt-dds-react/core/assets/svgs/RemoveCircleOutline.tsx
237
+ import { jsx as jsx42 } from "react/jsx-runtime";
238
+
239
+ // ../../dt-dds-react/core/assets/svgs/Share.tsx
240
+ import { jsx as jsx43, jsxs as jsxs17 } from "react/jsx-runtime";
241
+
242
+ // ../../dt-dds-react/core/assets/svgs/Signout.tsx
243
+ import { jsx as jsx44 } from "react/jsx-runtime";
244
+
245
+ // ../../dt-dds-react/core/assets/svgs/Teams.tsx
246
+ import { jsx as jsx45, jsxs as jsxs18 } from "react/jsx-runtime";
247
+
248
+ // ../../dt-dds-react/core/assets/svgs/Timeline.tsx
249
+ import { jsx as jsx46, jsxs as jsxs19 } from "react/jsx-runtime";
250
+
251
+ // ../../dt-dds-react/core/assets/svgs/Topic.tsx
252
+ import { jsx as jsx47, jsxs as jsxs20 } from "react/jsx-runtime";
253
+
254
+ // ../../dt-dds-react/core/assets/svgs/UnfoldLess.tsx
255
+ import { jsx as jsx48 } from "react/jsx-runtime";
256
+
257
+ // ../../dt-dds-react/core/assets/svgs/UnfoldMore.tsx
258
+ import { jsx as jsx49 } from "react/jsx-runtime";
259
+
260
+ // ../../dt-dds-react/core/assets/svgs/Username.tsx
261
+ import { jsx as jsx50, jsxs as jsxs21 } from "react/jsx-runtime";
262
+
263
+ // ../../dt-dds-react/core/assets/svgs/ViewAgenda.tsx
264
+ import { jsx as jsx51, jsxs as jsxs22 } from "react/jsx-runtime";
265
+
266
+ // ../../dt-dds-react/core/assets/svgs/Visibility.tsx
267
+ import { jsx as jsx52, jsxs as jsxs23 } from "react/jsx-runtime";
268
+
269
+ // ../../dt-dds-react/core/assets/svgs/VisibilityOff.tsx
270
+ import { jsx as jsx53, jsxs as jsxs24 } from "react/jsx-runtime";
271
+
272
+ // ../../dt-dds-react/core/assets/svgs/WarningOutline.tsx
273
+ import { jsx as jsx54 } from "react/jsx-runtime";
274
+ var WarningOutline = (props) => {
275
+ return /* @__PURE__ */ jsx54(
276
+ "svg",
277
+ __spreadProps(__spreadValues({
278
+ fill: "currentColor",
279
+ height: "24",
280
+ viewBox: "0 0 24 24",
281
+ width: "24",
282
+ xmlns: "http://www.w3.org/2000/svg"
283
+ }, props), {
284
+ children: /* @__PURE__ */ jsx54("path", { d: "M12 6.49L19.53 19.5H4.47L12 6.49ZM12 2.5L1 21.5H23L12 2.5ZM13 16.5H11V18.5H13V16.5ZM13 10.5H11V14.5H13V10.5Z" })
285
+ })
286
+ );
287
+ };
288
+ var WarningOutline_default = WarningOutline;
289
+
290
+ // ../../dt-dds-react/core/assets/svgs/Warning.tsx
291
+ import { jsx as jsx55 } from "react/jsx-runtime";
292
+
293
+ // ../../dt-dds-react/core/assets/svgs/Wifi.tsx
294
+ import { jsx as jsx56 } from "react/jsx-runtime";
295
+
296
+ // ../../dt-dds-react/core/assets/svgs/Settings.tsx
297
+ import { jsx as jsx57 } from "react/jsx-runtime";
298
+
299
+ // src/constants/enums.ts
300
+ var ToastPosition = /* @__PURE__ */ ((ToastPosition2) => {
301
+ ToastPosition2["TopLeft"] = "top-left";
302
+ ToastPosition2["TopCenter"] = "top-center";
303
+ ToastPosition2["TopRight"] = "top-right";
304
+ ToastPosition2["BottomLeft"] = "bottom-left";
305
+ ToastPosition2["BottomCenter"] = "bottom-center";
306
+ ToastPosition2["BottomRight"] = "bottom-right";
307
+ return ToastPosition2;
308
+ })(ToastPosition || {});
309
+ var ToastType = /* @__PURE__ */ ((ToastType2) => {
310
+ ToastType2["Success"] = "success";
311
+ ToastType2["Error"] = "error";
312
+ ToastType2["Info"] = "informative";
313
+ ToastType2["Warning"] = "warning";
314
+ return ToastType2;
315
+ })(ToastType || {});
316
+
317
+ // src/Toast.styled.ts
318
+ import { keyframes } from "@emotion/react";
319
+ import styled from "@emotion/styled";
320
+ var ToastIconStyled = styled.div`
321
+ height: 100%;
322
+ display: flex;
323
+ align-items: center;
324
+ padding-left: 8px;
325
+ padding-right: 8px;
326
+ ${({ theme, type }) => `
327
+ background-color: ${theme.palette[type].default};
328
+ color: ${theme.palette.content.contrast}
329
+ `}
330
+ `;
331
+ var fadeIn = keyframes`
332
+ from { opacity: 0; }
333
+ to { opacity: 1; }
334
+ `;
335
+ var ToastStyled = styled.div`
336
+ display: flex;
337
+ flex-direction: row;
338
+ align-items: center;
339
+ width: 360px;
340
+ animation: ${fadeIn} 0.75s ease-in;
341
+ transition: all 0.75s ease-in-out;
342
+ overflow: hidden;
343
+ ${({ theme, isVisible }) => `
344
+ background-color: ${theme.palette.surface.contrast};
345
+ opacity: ${isVisible ? 1 : 0};
346
+ color: ${theme.palette.content.default};
347
+ border-radius: ${theme.shape.toast};
348
+ box-shadow: ${theme.shadows.s};
349
+ `}
350
+ `;
351
+ var ToastContentStyled = styled.div`
352
+ ${({ theme }) => `
353
+ height: 100%;
354
+ flex-grow: 1;
355
+ padding: ${theme.spacing["2xs"]} ${theme.spacing["2xs"]};
356
+ `}
357
+ `;
358
+ var ToastTitleStyled = styled.div`
359
+ ${({ theme }) => `
360
+ ${theme.fontStyles.h6};
361
+ color: ${theme.palette.content.dark};
362
+ margin-bottom: ${theme.spacing["5xs"]};
363
+ text-transform: capitalize;
364
+ `}
365
+ `;
366
+ var ToastMessageStyled = styled.div`
367
+ ${({ theme }) => `
368
+ ${theme.fontStyles.body2};
369
+ color: ${theme.palette.content.default};
370
+ overflow: hidden;
371
+ word-break: break-word;
372
+ hyphens: auto;
373
+ display: -webkit-box;
374
+ -webkit-line-clamp: 6;
375
+ -webkit-box-orient: vertical;
376
+ `}
377
+ `;
378
+ var ToastButtonCloseStyled = styled.button`
379
+ ${({ theme }) => `
380
+ color: ${theme.palette.content.default};
381
+ border: 0;
382
+ cursor: pointer;
383
+ background: transparent;
384
+ align-self: flex-start;
385
+ font-size: 0;
386
+ line-height: 0;
387
+
388
+ &:hover {
389
+ background-color: ${theme.palette.surface.contrast};
390
+ }
391
+ `}
392
+ `;
393
+ var ToastTextContainer = styled.div`
394
+ ${({ theme, hasCloseButton }) => `
395
+ display: grid;
396
+ ${hasCloseButton ? "grid-template-columns: auto 24px;" : "grid-template-rows: auto auto;"}
397
+ column-gap: ${theme.spacing["2xs"]};
398
+ `}
399
+ `;
400
+ var ToastActionsStyled = styled.div`
401
+ ${({ theme, hasChildren }) => `
402
+ display: flex;
403
+ flex-direction: row;
404
+ justify-content: flex-end;
405
+ padding-top: ${hasChildren ? theme.spacing["5xs"] : 0};
406
+ `}
407
+ `;
408
+
409
+ // src/Toast.tsx
410
+ import { jsx as jsx58, jsxs as jsxs25 } from "react/jsx-runtime";
411
+ var ToastIcons = {
412
+ ["success" /* Success */]: CheckCircleOutline_default,
413
+ ["error" /* Error */]: ErrorOutline_default,
414
+ ["informative" /* Info */]: InfoOutline_default,
415
+ ["warning" /* Warning */]: WarningOutline_default
416
+ };
417
+ var Toast = ({
418
+ children,
419
+ id,
420
+ dataTestId,
421
+ title,
422
+ message,
423
+ onClose,
424
+ type,
425
+ isVisible = true,
426
+ dismissible = true
427
+ }) => {
428
+ const Icon = ToastIcons[type];
429
+ const dataTest = dataTestId != null ? dataTestId : `toast-${id}`;
430
+ return /* @__PURE__ */ jsxs25(
431
+ ToastStyled,
432
+ {
433
+ "data-testid": dataTest,
434
+ isVisible,
435
+ type,
436
+ children: [
437
+ /* @__PURE__ */ jsx58(ToastIconStyled, { type, children: /* @__PURE__ */ jsx58(Icon, { height: 20, width: 20 }) }),
438
+ /* @__PURE__ */ jsxs25(ToastContentStyled, { children: [
439
+ /* @__PURE__ */ jsxs25(ToastTextContainer, { hasCloseButton: dismissible, children: [
440
+ /* @__PURE__ */ jsx58(ToastTitleStyled, { children: title }),
441
+ dismissible ? /* @__PURE__ */ jsx58(ToastButtonCloseStyled, { onClick: onClose, children: /* @__PURE__ */ jsx58(Close_default, {}) }) : null,
442
+ /* @__PURE__ */ jsx58(ToastMessageStyled, { children: message })
443
+ ] }),
444
+ /* @__PURE__ */ jsx58(ToastActionsStyled, { hasChildren: Boolean(children), children })
445
+ ] })
446
+ ]
447
+ },
448
+ id
449
+ );
450
+ };
451
+ var Toast_default = Toast;
452
+
453
+ // src/Toaster.tsx
454
+ import { useMedia } from "@dt-dds/react-core";
455
+ import { useTheme as useTheme3 } from "@emotion/react";
456
+ import { Children, cloneElement } from "react";
457
+ import {
458
+ toast,
459
+ Toaster as ToastProvider
460
+ } from "react-hot-toast";
461
+ import { jsx as jsx59 } from "react/jsx-runtime";
462
+ var TOAST_DEFAULT_DURATION = 4e3;
463
+ var TOAST_ERROR_DURATION = Infinity;
464
+ var smallPosition = "bottom-center" /* BottomCenter */;
465
+ var defaultPosition = "bottom-right" /* BottomRight */;
466
+ var dismissToast = (id) => {
467
+ toast.dismiss(id);
468
+ };
469
+ var emitToast = (_a) => {
470
+ var _b = _a, {
471
+ type,
472
+ title,
473
+ message,
474
+ children,
475
+ dismissible
476
+ } = _b, props = __objRest(_b, [
477
+ "type",
478
+ "title",
479
+ "message",
480
+ "children",
481
+ "dismissible"
482
+ ]);
483
+ const duration = type === "error" /* Error */ ? TOAST_ERROR_DURATION : TOAST_DEFAULT_DURATION;
484
+ toast.custom(
485
+ (t) => {
486
+ const clonedChildren = Children.map(children, (child) => {
487
+ return child && cloneElement(child, __spreadValues({
488
+ toastId: t.id
489
+ }, child.props));
490
+ });
491
+ return /* @__PURE__ */ jsx59(
492
+ Toast_default,
493
+ {
494
+ dismissible,
495
+ id: t.id,
496
+ isVisible: t.visible,
497
+ message,
498
+ onClose: () => toast.dismiss(t.id),
499
+ title,
500
+ type,
501
+ children: clonedChildren
502
+ }
503
+ );
504
+ },
505
+ __spreadValues({
506
+ duration
507
+ }, props)
508
+ );
509
+ };
510
+ var Toaster = (_a) => {
511
+ var _b = _a, { gutter = 8 } = _b, props = __objRest(_b, ["gutter"]);
512
+ const theme = useTheme3();
513
+ const small = useMedia(`(max-width: ${theme.breakpoints.s}px)`);
514
+ const position = small ? smallPosition : defaultPosition;
515
+ const margin = small ? 8 : 16;
516
+ return /* @__PURE__ */ jsx59(
517
+ ToastProvider,
518
+ __spreadProps(__spreadValues({
519
+ gutter,
520
+ position
521
+ }, props), {
522
+ containerStyle: __spreadValues({
523
+ bottom: 16,
524
+ right: margin,
525
+ top: margin,
526
+ left: margin
527
+ }, props.containerStyle)
528
+ })
529
+ );
530
+ };
531
+ var Toaster_default = Toaster;
532
+ export {
533
+ Toast_default as Toast,
534
+ ToastPosition,
535
+ ToastType,
536
+ Toaster_default as Toaster,
537
+ dismissToast,
538
+ emitToast
539
+ };
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@dt-dds/react-toast",
3
+ "version": "1.0.0-beta.56",
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-button": "1.0.0-beta.39",
24
+ "@dt-dds/react-core": "1.0.0-beta.41",
25
+ "react-hot-toast": "^2.3.0"
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
+ }