@xsolla/xui-toast 0.89.0 → 0.90.0
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/native/index.js +41 -289
- package/native/index.js.map +1 -1
- package/native/index.mjs +17 -265
- package/native/index.mjs.map +1 -1
- package/package.json +5 -4
- package/web/index.js +41 -269
- package/web/index.js.map +1 -1
- package/web/index.mjs +18 -246
- package/web/index.mjs.map +1 -1
package/native/index.js
CHANGED
|
@@ -239,41 +239,10 @@ var Text = ({
|
|
|
239
239
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.Text, { style, testID: id, accessibilityRole, children });
|
|
240
240
|
};
|
|
241
241
|
|
|
242
|
-
// ../primitives-native/src/Spinner.tsx
|
|
243
|
-
var import_react_native3 = require("react-native");
|
|
244
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
245
|
-
var Spinner = ({
|
|
246
|
-
color,
|
|
247
|
-
size,
|
|
248
|
-
role,
|
|
249
|
-
"aria-label": ariaLabel,
|
|
250
|
-
"aria-live": ariaLive,
|
|
251
|
-
testID
|
|
252
|
-
}) => {
|
|
253
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
254
|
-
import_react_native3.View,
|
|
255
|
-
{
|
|
256
|
-
accessible: true,
|
|
257
|
-
accessibilityRole: role === "status" ? "none" : void 0,
|
|
258
|
-
accessibilityLabel: ariaLabel,
|
|
259
|
-
accessibilityLiveRegion: ariaLive === "polite" ? "polite" : ariaLive === "assertive" ? "assertive" : "none",
|
|
260
|
-
testID,
|
|
261
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
262
|
-
import_react_native3.ActivityIndicator,
|
|
263
|
-
{
|
|
264
|
-
color,
|
|
265
|
-
size: typeof size === "number" ? size : "small"
|
|
266
|
-
}
|
|
267
|
-
)
|
|
268
|
-
}
|
|
269
|
-
);
|
|
270
|
-
};
|
|
271
|
-
Spinner.displayName = "Spinner";
|
|
272
|
-
|
|
273
242
|
// ../primitives-native/src/Icon.tsx
|
|
274
243
|
var import_react = __toESM(require("react"));
|
|
275
|
-
var
|
|
276
|
-
var
|
|
244
|
+
var import_react_native3 = require("react-native");
|
|
245
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
277
246
|
var Icon = ({ children, color, size }) => {
|
|
278
247
|
const style = {
|
|
279
248
|
width: typeof size === "number" ? size : void 0,
|
|
@@ -291,239 +260,22 @@ var Icon = ({ children, color, size }) => {
|
|
|
291
260
|
}
|
|
292
261
|
return child;
|
|
293
262
|
});
|
|
294
|
-
return /* @__PURE__ */ (0,
|
|
263
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native3.View, { style, children: childrenWithProps });
|
|
295
264
|
};
|
|
296
265
|
|
|
297
|
-
// ../primitives-native/src/Divider.tsx
|
|
298
|
-
var import_react_native5 = require("react-native");
|
|
299
|
-
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
300
|
-
|
|
301
|
-
// ../primitives-native/src/Input.tsx
|
|
302
|
-
var import_react2 = require("react");
|
|
303
|
-
var import_react_native6 = require("react-native");
|
|
304
|
-
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
305
|
-
var keyboardTypeMap = {
|
|
306
|
-
text: "default",
|
|
307
|
-
number: "numeric",
|
|
308
|
-
email: "email-address",
|
|
309
|
-
tel: "phone-pad",
|
|
310
|
-
url: "url",
|
|
311
|
-
decimal: "decimal-pad"
|
|
312
|
-
};
|
|
313
|
-
var inputModeToKeyboardType = {
|
|
314
|
-
none: "default",
|
|
315
|
-
text: "default",
|
|
316
|
-
decimal: "decimal-pad",
|
|
317
|
-
numeric: "number-pad",
|
|
318
|
-
tel: "phone-pad",
|
|
319
|
-
search: "default",
|
|
320
|
-
email: "email-address",
|
|
321
|
-
url: "url"
|
|
322
|
-
};
|
|
323
|
-
var autoCompleteToTextContentType = {
|
|
324
|
-
"one-time-code": "oneTimeCode",
|
|
325
|
-
email: "emailAddress",
|
|
326
|
-
username: "username",
|
|
327
|
-
password: "password",
|
|
328
|
-
"new-password": "newPassword",
|
|
329
|
-
tel: "telephoneNumber",
|
|
330
|
-
"postal-code": "postalCode",
|
|
331
|
-
name: "name"
|
|
332
|
-
};
|
|
333
|
-
var InputPrimitive = (0, import_react2.forwardRef)(
|
|
334
|
-
({
|
|
335
|
-
value,
|
|
336
|
-
placeholder,
|
|
337
|
-
onChange,
|
|
338
|
-
onChangeText,
|
|
339
|
-
onFocus,
|
|
340
|
-
onBlur,
|
|
341
|
-
onKeyDown,
|
|
342
|
-
disabled,
|
|
343
|
-
secureTextEntry,
|
|
344
|
-
style,
|
|
345
|
-
color,
|
|
346
|
-
fontSize,
|
|
347
|
-
placeholderTextColor,
|
|
348
|
-
maxLength,
|
|
349
|
-
type,
|
|
350
|
-
inputMode,
|
|
351
|
-
autoComplete,
|
|
352
|
-
id,
|
|
353
|
-
"aria-describedby": ariaDescribedBy,
|
|
354
|
-
"aria-label": ariaLabel,
|
|
355
|
-
"aria-disabled": ariaDisabled,
|
|
356
|
-
"data-testid": dataTestId
|
|
357
|
-
}, ref) => {
|
|
358
|
-
const handleChangeText = (text) => {
|
|
359
|
-
onChangeText?.(text);
|
|
360
|
-
if (onChange) {
|
|
361
|
-
const syntheticEvent = {
|
|
362
|
-
target: { value: text },
|
|
363
|
-
currentTarget: { value: text },
|
|
364
|
-
type: "change",
|
|
365
|
-
nativeEvent: { text },
|
|
366
|
-
preventDefault: () => {
|
|
367
|
-
},
|
|
368
|
-
stopPropagation: () => {
|
|
369
|
-
},
|
|
370
|
-
isTrusted: false
|
|
371
|
-
};
|
|
372
|
-
onChange(syntheticEvent);
|
|
373
|
-
}
|
|
374
|
-
};
|
|
375
|
-
const keyboardType = inputMode ? inputModeToKeyboardType[inputMode] || "default" : type ? keyboardTypeMap[type] || "default" : "default";
|
|
376
|
-
const textContentType = autoComplete ? autoCompleteToTextContentType[autoComplete] : void 0;
|
|
377
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
378
|
-
import_react_native6.TextInput,
|
|
379
|
-
{
|
|
380
|
-
ref,
|
|
381
|
-
value,
|
|
382
|
-
placeholder,
|
|
383
|
-
onChangeText: handleChangeText,
|
|
384
|
-
onFocus,
|
|
385
|
-
onBlur,
|
|
386
|
-
onKeyPress: (e) => {
|
|
387
|
-
if (onKeyDown) {
|
|
388
|
-
onKeyDown({
|
|
389
|
-
key: e.nativeEvent.key,
|
|
390
|
-
preventDefault: () => {
|
|
391
|
-
}
|
|
392
|
-
});
|
|
393
|
-
}
|
|
394
|
-
},
|
|
395
|
-
editable: !disabled,
|
|
396
|
-
secureTextEntry: secureTextEntry || type === "password",
|
|
397
|
-
keyboardType,
|
|
398
|
-
textContentType,
|
|
399
|
-
style: [
|
|
400
|
-
{
|
|
401
|
-
color,
|
|
402
|
-
fontSize: typeof fontSize === "number" ? fontSize : void 0,
|
|
403
|
-
flex: 1,
|
|
404
|
-
padding: 0,
|
|
405
|
-
textAlign: style?.textAlign || "left"
|
|
406
|
-
},
|
|
407
|
-
style
|
|
408
|
-
],
|
|
409
|
-
placeholderTextColor,
|
|
410
|
-
maxLength,
|
|
411
|
-
testID: dataTestId || id,
|
|
412
|
-
accessibilityLabel: ariaLabel,
|
|
413
|
-
accessibilityHint: ariaDescribedBy,
|
|
414
|
-
accessibilityState: {
|
|
415
|
-
disabled: disabled || ariaDisabled
|
|
416
|
-
},
|
|
417
|
-
accessible: true
|
|
418
|
-
}
|
|
419
|
-
);
|
|
420
|
-
}
|
|
421
|
-
);
|
|
422
|
-
InputPrimitive.displayName = "InputPrimitive";
|
|
423
|
-
|
|
424
|
-
// ../primitives-native/src/TextArea.tsx
|
|
425
|
-
var import_react3 = require("react");
|
|
426
|
-
var import_react_native7 = require("react-native");
|
|
427
|
-
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
428
|
-
var TextAreaPrimitive = (0, import_react3.forwardRef)(
|
|
429
|
-
({
|
|
430
|
-
value,
|
|
431
|
-
placeholder,
|
|
432
|
-
onChange,
|
|
433
|
-
onChangeText,
|
|
434
|
-
onFocus,
|
|
435
|
-
onBlur,
|
|
436
|
-
onKeyDown,
|
|
437
|
-
disabled,
|
|
438
|
-
style,
|
|
439
|
-
color,
|
|
440
|
-
fontSize,
|
|
441
|
-
placeholderTextColor,
|
|
442
|
-
maxLength,
|
|
443
|
-
rows,
|
|
444
|
-
id,
|
|
445
|
-
"aria-describedby": ariaDescribedBy,
|
|
446
|
-
"aria-label": ariaLabel,
|
|
447
|
-
"aria-disabled": ariaDisabled,
|
|
448
|
-
"data-testid": dataTestId
|
|
449
|
-
}, ref) => {
|
|
450
|
-
const handleChangeText = (text) => {
|
|
451
|
-
onChangeText?.(text);
|
|
452
|
-
if (onChange) {
|
|
453
|
-
const syntheticEvent = {
|
|
454
|
-
target: { value: text },
|
|
455
|
-
currentTarget: { value: text },
|
|
456
|
-
type: "change",
|
|
457
|
-
nativeEvent: { text },
|
|
458
|
-
preventDefault: () => {
|
|
459
|
-
},
|
|
460
|
-
stopPropagation: () => {
|
|
461
|
-
},
|
|
462
|
-
isTrusted: false
|
|
463
|
-
};
|
|
464
|
-
onChange(syntheticEvent);
|
|
465
|
-
}
|
|
466
|
-
};
|
|
467
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
468
|
-
import_react_native7.TextInput,
|
|
469
|
-
{
|
|
470
|
-
ref,
|
|
471
|
-
value,
|
|
472
|
-
placeholder,
|
|
473
|
-
onChangeText: handleChangeText,
|
|
474
|
-
onFocus,
|
|
475
|
-
onBlur,
|
|
476
|
-
onKeyPress: (e) => {
|
|
477
|
-
if (onKeyDown) {
|
|
478
|
-
onKeyDown({
|
|
479
|
-
key: e.nativeEvent.key,
|
|
480
|
-
preventDefault: () => {
|
|
481
|
-
}
|
|
482
|
-
});
|
|
483
|
-
}
|
|
484
|
-
},
|
|
485
|
-
editable: !disabled,
|
|
486
|
-
multiline: true,
|
|
487
|
-
numberOfLines: rows || 4,
|
|
488
|
-
style: [
|
|
489
|
-
{
|
|
490
|
-
color,
|
|
491
|
-
fontSize: typeof fontSize === "number" ? fontSize : void 0,
|
|
492
|
-
flex: 1,
|
|
493
|
-
padding: 0,
|
|
494
|
-
textAlignVertical: "top",
|
|
495
|
-
textAlign: style?.textAlign || "left"
|
|
496
|
-
},
|
|
497
|
-
style
|
|
498
|
-
],
|
|
499
|
-
placeholderTextColor,
|
|
500
|
-
maxLength,
|
|
501
|
-
testID: dataTestId || id,
|
|
502
|
-
accessibilityLabel: ariaLabel,
|
|
503
|
-
accessibilityHint: ariaDescribedBy,
|
|
504
|
-
accessibilityState: {
|
|
505
|
-
disabled: disabled || ariaDisabled
|
|
506
|
-
},
|
|
507
|
-
accessible: true
|
|
508
|
-
}
|
|
509
|
-
);
|
|
510
|
-
}
|
|
511
|
-
);
|
|
512
|
-
TextAreaPrimitive.displayName = "TextAreaPrimitive";
|
|
513
|
-
|
|
514
266
|
// src/Toast.tsx
|
|
515
267
|
var import_xui_core = require("@xsolla/xui-core");
|
|
516
268
|
var import_xui_icons = require("@xsolla/xui-icons");
|
|
517
|
-
var
|
|
269
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
518
270
|
var getDefaultIcon = (variant, size, color) => {
|
|
519
271
|
switch (variant) {
|
|
520
272
|
case "success":
|
|
521
|
-
return /* @__PURE__ */ (0,
|
|
273
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_xui_icons.Check, { size, color });
|
|
522
274
|
case "info":
|
|
523
275
|
case "warning":
|
|
524
276
|
case "error":
|
|
525
277
|
default:
|
|
526
|
-
return /* @__PURE__ */ (0,
|
|
278
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_xui_icons.AlertCircle, { size, color });
|
|
527
279
|
}
|
|
528
280
|
};
|
|
529
281
|
var getIconColor = (variant, colors) => {
|
|
@@ -549,8 +301,8 @@ var Toast = ({
|
|
|
549
301
|
const { theme } = (0, import_xui_core.useDesignSystem)();
|
|
550
302
|
const config = theme.sizing.toast();
|
|
551
303
|
const iconColor = getIconColor(variant, theme.colors);
|
|
552
|
-
const displayIcon = icon !== void 0 ? /* @__PURE__ */ (0,
|
|
553
|
-
return /* @__PURE__ */ (0,
|
|
304
|
+
const displayIcon = icon !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { size: config.iconSize, color: iconColor, children: icon }) : getDefaultIcon(variant, config.iconSize, iconColor);
|
|
305
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
554
306
|
Box,
|
|
555
307
|
{
|
|
556
308
|
backgroundColor: theme.colors.background.inverse,
|
|
@@ -566,7 +318,7 @@ var Toast = ({
|
|
|
566
318
|
"aria-live": "polite",
|
|
567
319
|
"data-toast-id": id,
|
|
568
320
|
children: [
|
|
569
|
-
/* @__PURE__ */ (0,
|
|
321
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
570
322
|
Box,
|
|
571
323
|
{
|
|
572
324
|
width: config.iconSize,
|
|
@@ -577,7 +329,7 @@ var Toast = ({
|
|
|
577
329
|
children: displayIcon
|
|
578
330
|
}
|
|
579
331
|
),
|
|
580
|
-
/* @__PURE__ */ (0,
|
|
332
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Box, { flex: 1, minWidth: 0, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
581
333
|
Text,
|
|
582
334
|
{
|
|
583
335
|
color: theme.colors.content.inverse,
|
|
@@ -588,7 +340,7 @@ var Toast = ({
|
|
|
588
340
|
children: message
|
|
589
341
|
}
|
|
590
342
|
) }),
|
|
591
|
-
onClose && /* @__PURE__ */ (0,
|
|
343
|
+
onClose && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
592
344
|
Box,
|
|
593
345
|
{
|
|
594
346
|
onPress: onClose,
|
|
@@ -599,7 +351,7 @@ var Toast = ({
|
|
|
599
351
|
flexShrink: 0,
|
|
600
352
|
role: "button",
|
|
601
353
|
"aria-label": "Dismiss toast",
|
|
602
|
-
children: /* @__PURE__ */ (0,
|
|
354
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_xui_icons.X, { size: config.closeIconSize, color: theme.colors.content.inverse })
|
|
603
355
|
}
|
|
604
356
|
)
|
|
605
357
|
]
|
|
@@ -609,10 +361,10 @@ var Toast = ({
|
|
|
609
361
|
Toast.displayName = "Toast";
|
|
610
362
|
|
|
611
363
|
// src/ToastGroup.native.tsx
|
|
612
|
-
var
|
|
364
|
+
var import_react2 = require("react");
|
|
613
365
|
var import_xui_core2 = require("@xsolla/xui-core");
|
|
614
|
-
var
|
|
615
|
-
var ToastGroup = (0,
|
|
366
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
367
|
+
var ToastGroup = (0, import_react2.memo)(
|
|
616
368
|
({ toasts, position = "top", onDismiss }) => {
|
|
617
369
|
const { theme } = (0, import_xui_core2.useDesignSystem)();
|
|
618
370
|
const config = theme.sizing.toast();
|
|
@@ -620,7 +372,7 @@ var ToastGroup = (0, import_react4.memo)(
|
|
|
620
372
|
return null;
|
|
621
373
|
}
|
|
622
374
|
const positionStyles = position === "top" ? { top: config.containerPadding, bottom: void 0 } : { top: void 0, bottom: config.containerPadding };
|
|
623
|
-
return /* @__PURE__ */ (0,
|
|
375
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
624
376
|
Box,
|
|
625
377
|
{
|
|
626
378
|
position: "absolute",
|
|
@@ -631,14 +383,14 @@ var ToastGroup = (0, import_react4.memo)(
|
|
|
631
383
|
paddingHorizontal: config.containerPadding,
|
|
632
384
|
pointerEvents: "box-none",
|
|
633
385
|
...positionStyles,
|
|
634
|
-
children: /* @__PURE__ */ (0,
|
|
386
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
635
387
|
Box,
|
|
636
388
|
{
|
|
637
389
|
width: "100%",
|
|
638
390
|
maxWidth: config.maxWidth,
|
|
639
391
|
gap: config.groupGap,
|
|
640
392
|
flexDirection: "column",
|
|
641
|
-
children: toasts.map((toast) => /* @__PURE__ */ (0,
|
|
393
|
+
children: toasts.map((toast) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
642
394
|
Toast,
|
|
643
395
|
{
|
|
644
396
|
id: toast.id,
|
|
@@ -658,14 +410,14 @@ var ToastGroup = (0, import_react4.memo)(
|
|
|
658
410
|
ToastGroup.displayName = "ToastGroup";
|
|
659
411
|
|
|
660
412
|
// src/ToastProvider.tsx
|
|
661
|
-
var
|
|
413
|
+
var import_react4 = require("react");
|
|
662
414
|
|
|
663
415
|
// src/ToastContext.tsx
|
|
664
|
-
var
|
|
665
|
-
var ToastContext = (0,
|
|
416
|
+
var import_react3 = require("react");
|
|
417
|
+
var ToastContext = (0, import_react3.createContext)(null);
|
|
666
418
|
|
|
667
419
|
// src/ToastProvider.tsx
|
|
668
|
-
var
|
|
420
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
669
421
|
var toastIdCounter = 0;
|
|
670
422
|
var generateToastId = () => {
|
|
671
423
|
return `toast-${++toastIdCounter}-${Date.now()}`;
|
|
@@ -675,29 +427,29 @@ var ToastProvider = ({
|
|
|
675
427
|
position = "top",
|
|
676
428
|
defaultDuration = 5e3
|
|
677
429
|
}) => {
|
|
678
|
-
const [toasts, setToasts] = (0,
|
|
679
|
-
const timersRef = (0,
|
|
430
|
+
const [toasts, setToasts] = (0, import_react4.useState)([]);
|
|
431
|
+
const timersRef = (0, import_react4.useRef)(
|
|
680
432
|
/* @__PURE__ */ new Map()
|
|
681
433
|
);
|
|
682
|
-
const clearTimer = (0,
|
|
434
|
+
const clearTimer = (0, import_react4.useCallback)((id) => {
|
|
683
435
|
const timer = timersRef.current.get(id);
|
|
684
436
|
if (timer) {
|
|
685
437
|
clearTimeout(timer);
|
|
686
438
|
timersRef.current.delete(id);
|
|
687
439
|
}
|
|
688
440
|
}, []);
|
|
689
|
-
const dismissToast = (0,
|
|
441
|
+
const dismissToast = (0, import_react4.useCallback)(
|
|
690
442
|
(id) => {
|
|
691
443
|
clearTimer(id);
|
|
692
444
|
setToasts((prev) => prev.filter((toast) => toast.id !== id));
|
|
693
445
|
},
|
|
694
446
|
[clearTimer]
|
|
695
447
|
);
|
|
696
|
-
const dismissAllToasts = (0,
|
|
448
|
+
const dismissAllToasts = (0, import_react4.useCallback)(() => {
|
|
697
449
|
timersRef.current.forEach((_, id) => clearTimer(id));
|
|
698
450
|
setToasts([]);
|
|
699
451
|
}, [clearTimer]);
|
|
700
|
-
const addToast = (0,
|
|
452
|
+
const addToast = (0, import_react4.useCallback)(
|
|
701
453
|
(options) => {
|
|
702
454
|
const id = generateToastId();
|
|
703
455
|
const duration = options.duration ?? defaultDuration;
|
|
@@ -719,13 +471,13 @@ var ToastProvider = ({
|
|
|
719
471
|
},
|
|
720
472
|
[defaultDuration, dismissToast]
|
|
721
473
|
);
|
|
722
|
-
(0,
|
|
474
|
+
(0, import_react4.useEffect)(() => {
|
|
723
475
|
return () => {
|
|
724
476
|
timersRef.current.forEach((timer) => clearTimeout(timer));
|
|
725
477
|
timersRef.current.clear();
|
|
726
478
|
};
|
|
727
479
|
}, []);
|
|
728
|
-
const contextValue = (0,
|
|
480
|
+
const contextValue = (0, import_react4.useMemo)(
|
|
729
481
|
() => ({
|
|
730
482
|
toasts,
|
|
731
483
|
addToast,
|
|
@@ -734,9 +486,9 @@ var ToastProvider = ({
|
|
|
734
486
|
}),
|
|
735
487
|
[toasts, addToast, dismissToast, dismissAllToasts]
|
|
736
488
|
);
|
|
737
|
-
return /* @__PURE__ */ (0,
|
|
489
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(ToastContext.Provider, { value: contextValue, children: [
|
|
738
490
|
children,
|
|
739
|
-
/* @__PURE__ */ (0,
|
|
491
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
740
492
|
ToastGroup,
|
|
741
493
|
{
|
|
742
494
|
toasts,
|
|
@@ -748,50 +500,50 @@ var ToastProvider = ({
|
|
|
748
500
|
};
|
|
749
501
|
|
|
750
502
|
// src/useToast.ts
|
|
751
|
-
var
|
|
503
|
+
var import_react5 = require("react");
|
|
752
504
|
var useToast = () => {
|
|
753
|
-
const context = (0,
|
|
505
|
+
const context = (0, import_react5.useContext)(ToastContext);
|
|
754
506
|
if (!context) {
|
|
755
507
|
throw new Error("useToast must be used within a ToastProvider");
|
|
756
508
|
}
|
|
757
509
|
const { addToast, dismissToast, dismissAllToasts } = context;
|
|
758
|
-
const toast = (0,
|
|
510
|
+
const toast = (0, import_react5.useCallback)(
|
|
759
511
|
(options) => {
|
|
760
512
|
return addToast(options);
|
|
761
513
|
},
|
|
762
514
|
[addToast]
|
|
763
515
|
);
|
|
764
|
-
const success = (0,
|
|
516
|
+
const success = (0, import_react5.useCallback)(
|
|
765
517
|
(message, options) => {
|
|
766
518
|
return addToast({ ...options, message, variant: "success" });
|
|
767
519
|
},
|
|
768
520
|
[addToast]
|
|
769
521
|
);
|
|
770
|
-
const info = (0,
|
|
522
|
+
const info = (0, import_react5.useCallback)(
|
|
771
523
|
(message, options) => {
|
|
772
524
|
return addToast({ ...options, message, variant: "info" });
|
|
773
525
|
},
|
|
774
526
|
[addToast]
|
|
775
527
|
);
|
|
776
|
-
const warning = (0,
|
|
528
|
+
const warning = (0, import_react5.useCallback)(
|
|
777
529
|
(message, options) => {
|
|
778
530
|
return addToast({ ...options, message, variant: "warning" });
|
|
779
531
|
},
|
|
780
532
|
[addToast]
|
|
781
533
|
);
|
|
782
|
-
const error = (0,
|
|
534
|
+
const error = (0, import_react5.useCallback)(
|
|
783
535
|
(message, options) => {
|
|
784
536
|
return addToast({ ...options, message, variant: "error" });
|
|
785
537
|
},
|
|
786
538
|
[addToast]
|
|
787
539
|
);
|
|
788
|
-
const dismiss = (0,
|
|
540
|
+
const dismiss = (0, import_react5.useCallback)(
|
|
789
541
|
(id) => {
|
|
790
542
|
dismissToast(id);
|
|
791
543
|
},
|
|
792
544
|
[dismissToast]
|
|
793
545
|
);
|
|
794
|
-
const dismissAll = (0,
|
|
546
|
+
const dismissAll = (0, import_react5.useCallback)(() => {
|
|
795
547
|
dismissAllToasts();
|
|
796
548
|
}, [dismissAllToasts]);
|
|
797
549
|
return {
|