@majoo-ui/react 1.61.25-rc.1 → 1.61.25-rc.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/index.esm.js +25 -2
- package/package.json +1 -1
package/index.esm.js
CHANGED
|
@@ -8659,6 +8659,21 @@ function upload({
|
|
|
8659
8659
|
});
|
|
8660
8660
|
return promise;
|
|
8661
8661
|
}
|
|
8662
|
+
const catchError = e => {
|
|
8663
|
+
let message = 'Unknown error';
|
|
8664
|
+
if (typeof e === 'string') message = e;
|
|
8665
|
+
if (Object.prototype.hasOwnProperty.call(e, 'message') && typeof e.message === 'string') ({
|
|
8666
|
+
message
|
|
8667
|
+
} = e);
|
|
8668
|
+
if (Object.prototype.hasOwnProperty.call(e, 'error') && typeof e.error === 'string') ({
|
|
8669
|
+
error: message
|
|
8670
|
+
} = e);
|
|
8671
|
+
if (Object.prototype.hasOwnProperty.call(e, 'msg') && typeof e.msg === 'string') ({
|
|
8672
|
+
msg: message
|
|
8673
|
+
} = e);
|
|
8674
|
+
if (message === '[object Object]') return '';
|
|
8675
|
+
return message;
|
|
8676
|
+
};
|
|
8662
8677
|
|
|
8663
8678
|
const _excluded$r = ["id", "disabledOfflineIntercept"];
|
|
8664
8679
|
let toastCount = 0;
|
|
@@ -8672,7 +8687,15 @@ const ToastProvider = ({
|
|
|
8672
8687
|
t,
|
|
8673
8688
|
i18n
|
|
8674
8689
|
} = useTranslation(['MajooUI/toast', 'translation']);
|
|
8675
|
-
const catchError = (
|
|
8690
|
+
const catchError$1 = (e, values) => {
|
|
8691
|
+
let errorMsg = catchError(e);
|
|
8692
|
+
if (values) {
|
|
8693
|
+
Object.keys(values).forEach(key => {
|
|
8694
|
+
errorMsg = errorMsg.replace(`$${key}`, values[key]);
|
|
8695
|
+
});
|
|
8696
|
+
}
|
|
8697
|
+
return errorMsg;
|
|
8698
|
+
};
|
|
8676
8699
|
const createToastInstance = useCallback(toast => {
|
|
8677
8700
|
const {
|
|
8678
8701
|
id,
|
|
@@ -8695,7 +8718,7 @@ const ToastProvider = ({
|
|
|
8695
8718
|
id: toastId,
|
|
8696
8719
|
position: TOP_RIGHT_POSITION
|
|
8697
8720
|
}, rest, {
|
|
8698
|
-
description: /*#__PURE__*/React.isValidElement(toast.description) ? toast.description : catchError(toast.description, toast.values)
|
|
8721
|
+
description: /*#__PURE__*/React.isValidElement(toast.description) ? toast.description : catchError$1(toast.description, toast.values)
|
|
8699
8722
|
}, !isOnline && !disabledOfflineIntercept && offlineInstance);
|
|
8700
8723
|
}, [isOnline, t, i18n.language]);
|
|
8701
8724
|
const addToast = React.useCallback(toast => {
|