@doist/reactist 28.1.2 → 28.2.1
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/reactist.cjs.development.js +19 -12
- package/dist/reactist.cjs.development.js.map +1 -1
- package/dist/reactist.cjs.production.min.js +1 -1
- package/dist/reactist.cjs.production.min.js.map +1 -1
- package/es/toast/static-toast.js.map +1 -1
- package/es/toast/use-toasts.js +19 -12
- package/es/toast/use-toasts.js.map +1 -1
- package/lib/toast/static-toast.d.ts +1 -0
- package/lib/toast/static-toast.js.map +1 -1
- package/lib/toast/use-toasts.js +1 -1
- package/lib/toast/use-toasts.js.map +1 -1
- package/package.json +1 -1
|
@@ -1453,25 +1453,24 @@ const InternalToast = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
1453
1453
|
onDismiss,
|
|
1454
1454
|
onRemoveToast
|
|
1455
1455
|
}, ref) {
|
|
1456
|
-
const [timeoutRunning, setTimeoutRunning] = React__default["default"].useState(Boolean(autoDismissDelay));
|
|
1457
1456
|
const timeoutRef = React__default["default"].useRef();
|
|
1457
|
+
const removeToast = React__default["default"].useCallback(function removeToast() {
|
|
1458
|
+
onRemoveToast(toastId);
|
|
1459
|
+
onDismiss == null ? void 0 : onDismiss();
|
|
1460
|
+
}, [onDismiss, onRemoveToast, toastId]);
|
|
1458
1461
|
const startTimeout = React__default["default"].useCallback(function startTimeout() {
|
|
1459
|
-
|
|
1460
|
-
|
|
1462
|
+
if (!autoDismissDelay) return;
|
|
1463
|
+
timeoutRef.current = window.setTimeout(removeToast, autoDismissDelay * 1000);
|
|
1464
|
+
}, [autoDismissDelay, removeToast]);
|
|
1461
1465
|
const stopTimeout = React__default["default"].useCallback(function stopTimeout() {
|
|
1462
|
-
setTimeoutRunning(false);
|
|
1463
1466
|
clearTimeout(timeoutRef.current);
|
|
1464
1467
|
timeoutRef.current = undefined;
|
|
1465
1468
|
}, []);
|
|
1466
|
-
const removeToast = React__default["default"].useCallback(function removeToast() {
|
|
1467
|
-
onRemoveToast(toastId);
|
|
1468
|
-
onDismiss == null ? void 0 : onDismiss();
|
|
1469
|
-
}, [onDismiss, onRemoveToast, toastId]);
|
|
1470
1469
|
React__default["default"].useEffect(function setupAutoDismiss() {
|
|
1471
|
-
|
|
1472
|
-
|
|
1470
|
+
stopTimeout();
|
|
1471
|
+
startTimeout();
|
|
1473
1472
|
return stopTimeout;
|
|
1474
|
-
}, [
|
|
1473
|
+
}, [startTimeout, stopTimeout]);
|
|
1475
1474
|
/**
|
|
1476
1475
|
* If the action is toast action object and not a custom element,
|
|
1477
1476
|
* the `onClick` property is wrapped in another handler responsible
|
|
@@ -1479,18 +1478,26 @@ const InternalToast = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
1479
1478
|
*/
|
|
1480
1479
|
|
|
1481
1480
|
const actionWithCustomActionHandler = React__default["default"].useMemo(() => {
|
|
1481
|
+
var _action$closeToast;
|
|
1482
|
+
|
|
1482
1483
|
if (!isActionObject(action)) {
|
|
1483
1484
|
return action;
|
|
1484
1485
|
}
|
|
1485
1486
|
|
|
1486
1487
|
return _objectSpread2(_objectSpread2({}, action), {}, {
|
|
1488
|
+
closeToast: (_action$closeToast = action.closeToast) != null ? _action$closeToast : true,
|
|
1487
1489
|
onClick: function handleActionClick() {
|
|
1490
|
+
var _action$closeToast2;
|
|
1491
|
+
|
|
1488
1492
|
if (!action) {
|
|
1489
1493
|
return;
|
|
1490
1494
|
}
|
|
1491
1495
|
|
|
1492
1496
|
action.onClick();
|
|
1493
|
-
|
|
1497
|
+
|
|
1498
|
+
if ((_action$closeToast2 = action.closeToast) != null ? _action$closeToast2 : true) {
|
|
1499
|
+
removeToast();
|
|
1500
|
+
}
|
|
1494
1501
|
}
|
|
1495
1502
|
});
|
|
1496
1503
|
}, [action, removeToast]);
|