@majoo-ui/react 1.60.37-rc.2 → 1.60.37-rc.4
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 +18 -15
- package/index.umd.js +18 -15
- package/package.json +1 -1
package/index.esm.js
CHANGED
|
@@ -7101,7 +7101,7 @@ const ToastProvider = ({
|
|
|
7101
7101
|
translations
|
|
7102
7102
|
}) => {
|
|
7103
7103
|
console.warn({
|
|
7104
|
-
translations
|
|
7104
|
+
providerTranslations: translations
|
|
7105
7105
|
});
|
|
7106
7106
|
const isOnline = useNavigatorOnLine();
|
|
7107
7107
|
const [toasts, setToasts] = useState([]);
|
|
@@ -7109,10 +7109,10 @@ const ToastProvider = ({
|
|
|
7109
7109
|
t,
|
|
7110
7110
|
i18n
|
|
7111
7111
|
} = useTranslation(['MajooUI/toast', 'translation']);
|
|
7112
|
-
const catchError$1 = useCallback((e, values) => {
|
|
7112
|
+
const catchError$1 = useCallback((e, values, trans) => {
|
|
7113
7113
|
let errorMsg = catchError(e);
|
|
7114
|
-
if (
|
|
7115
|
-
errorMsg =
|
|
7114
|
+
if (trans && trans[errorMsg]) {
|
|
7115
|
+
errorMsg = trans[errorMsg][i18n.language];
|
|
7116
7116
|
}
|
|
7117
7117
|
if (values) {
|
|
7118
7118
|
Object.keys(values).forEach(key => {
|
|
@@ -7120,13 +7120,13 @@ const ToastProvider = ({
|
|
|
7120
7120
|
});
|
|
7121
7121
|
}
|
|
7122
7122
|
console.warn({
|
|
7123
|
-
|
|
7123
|
+
trans,
|
|
7124
7124
|
e,
|
|
7125
7125
|
errorMsg
|
|
7126
7126
|
});
|
|
7127
7127
|
return errorMsg;
|
|
7128
7128
|
}, [translations, i18n.language]);
|
|
7129
|
-
const createToastInstance = useCallback(toast => {
|
|
7129
|
+
const createToastInstance = useCallback((toast, trans) => {
|
|
7130
7130
|
const {
|
|
7131
7131
|
id,
|
|
7132
7132
|
disabledOfflineIntercept
|
|
@@ -7147,17 +7147,20 @@ const ToastProvider = ({
|
|
|
7147
7147
|
console.warn({
|
|
7148
7148
|
toast,
|
|
7149
7149
|
isValidElement: /*#__PURE__*/React.isValidElement(toast.description),
|
|
7150
|
-
|
|
7150
|
+
trans
|
|
7151
7151
|
});
|
|
7152
7152
|
return Object.assign({
|
|
7153
7153
|
id: toastId,
|
|
7154
7154
|
position: TOP_RIGHT_POSITION
|
|
7155
7155
|
}, rest, {
|
|
7156
|
-
description: /*#__PURE__*/React.isValidElement(toast.description) ? toast.description : catchError$1(toast.description, toast.values)
|
|
7156
|
+
description: /*#__PURE__*/React.isValidElement(toast.description) ? toast.description : catchError$1(toast.description, toast.values, trans)
|
|
7157
7157
|
}, !isOnline && !disabledOfflineIntercept && offlineInstance);
|
|
7158
7158
|
}, [isOnline, t, translations, i18n.language]);
|
|
7159
7159
|
const addToast = React.useCallback(toast => {
|
|
7160
|
-
|
|
7160
|
+
console.warn({
|
|
7161
|
+
addToastTranslations: translations
|
|
7162
|
+
});
|
|
7163
|
+
const toastInstance = createToastInstance(toast, translations);
|
|
7161
7164
|
setToasts(toastItems => {
|
|
7162
7165
|
if (!toastItems.some(currToast => toast.id === currToast.id) || !toast.preventDuplicate) {
|
|
7163
7166
|
return [...toastItems, toastInstance];
|
|
@@ -7165,7 +7168,7 @@ const ToastProvider = ({
|
|
|
7165
7168
|
return toastItems;
|
|
7166
7169
|
});
|
|
7167
7170
|
return toastInstance;
|
|
7168
|
-
}, [createToastInstance]);
|
|
7171
|
+
}, [createToastInstance, translations]);
|
|
7169
7172
|
const removeToast = React.useCallback(id => {
|
|
7170
7173
|
setToasts(toastItems => toastItems.filter(t => t.id !== id));
|
|
7171
7174
|
}, [setToasts]);
|
|
@@ -7177,7 +7180,7 @@ const ToastProvider = ({
|
|
|
7177
7180
|
__self: undefined,
|
|
7178
7181
|
__source: {
|
|
7179
7182
|
fileName: _jsxFileName$R,
|
|
7180
|
-
lineNumber:
|
|
7183
|
+
lineNumber: 86,
|
|
7181
7184
|
columnNumber: 5
|
|
7182
7185
|
}
|
|
7183
7186
|
}, children, /*#__PURE__*/React.createElement(ToastContainer, {
|
|
@@ -7186,7 +7189,7 @@ const ToastProvider = ({
|
|
|
7186
7189
|
__self: undefined,
|
|
7187
7190
|
__source: {
|
|
7188
7191
|
fileName: _jsxFileName$R,
|
|
7189
|
-
lineNumber:
|
|
7192
|
+
lineNumber: 88,
|
|
7190
7193
|
columnNumber: 7
|
|
7191
7194
|
}
|
|
7192
7195
|
}), /*#__PURE__*/React.createElement(ToastContainer, {
|
|
@@ -7195,7 +7198,7 @@ const ToastProvider = ({
|
|
|
7195
7198
|
__self: undefined,
|
|
7196
7199
|
__source: {
|
|
7197
7200
|
fileName: _jsxFileName$R,
|
|
7198
|
-
lineNumber:
|
|
7201
|
+
lineNumber: 92,
|
|
7199
7202
|
columnNumber: 7
|
|
7200
7203
|
}
|
|
7201
7204
|
}), /*#__PURE__*/React.createElement(ToastContainer, {
|
|
@@ -7204,7 +7207,7 @@ const ToastProvider = ({
|
|
|
7204
7207
|
__self: undefined,
|
|
7205
7208
|
__source: {
|
|
7206
7209
|
fileName: _jsxFileName$R,
|
|
7207
|
-
lineNumber:
|
|
7210
|
+
lineNumber: 96,
|
|
7208
7211
|
columnNumber: 7
|
|
7209
7212
|
}
|
|
7210
7213
|
}), /*#__PURE__*/React.createElement(ToastContainer, {
|
|
@@ -7213,7 +7216,7 @@ const ToastProvider = ({
|
|
|
7213
7216
|
__self: undefined,
|
|
7214
7217
|
__source: {
|
|
7215
7218
|
fileName: _jsxFileName$R,
|
|
7216
|
-
lineNumber:
|
|
7219
|
+
lineNumber: 100,
|
|
7217
7220
|
columnNumber: 7
|
|
7218
7221
|
}
|
|
7219
7222
|
}));
|
package/index.umd.js
CHANGED
|
@@ -7193,7 +7193,7 @@
|
|
|
7193
7193
|
translations
|
|
7194
7194
|
}) => {
|
|
7195
7195
|
console.warn({
|
|
7196
|
-
translations
|
|
7196
|
+
providerTranslations: translations
|
|
7197
7197
|
});
|
|
7198
7198
|
const isOnline = useNavigatorOnLine();
|
|
7199
7199
|
const [toasts, setToasts] = React.useState([]);
|
|
@@ -7201,10 +7201,10 @@
|
|
|
7201
7201
|
t,
|
|
7202
7202
|
i18n
|
|
7203
7203
|
} = reactI18next.useTranslation(['MajooUI/toast', 'translation']);
|
|
7204
|
-
const catchError$1 = React.useCallback((e, values) => {
|
|
7204
|
+
const catchError$1 = React.useCallback((e, values, trans) => {
|
|
7205
7205
|
let errorMsg = catchError(e);
|
|
7206
|
-
if (
|
|
7207
|
-
errorMsg =
|
|
7206
|
+
if (trans && trans[errorMsg]) {
|
|
7207
|
+
errorMsg = trans[errorMsg][i18n.language];
|
|
7208
7208
|
}
|
|
7209
7209
|
if (values) {
|
|
7210
7210
|
Object.keys(values).forEach(key => {
|
|
@@ -7212,13 +7212,13 @@
|
|
|
7212
7212
|
});
|
|
7213
7213
|
}
|
|
7214
7214
|
console.warn({
|
|
7215
|
-
|
|
7215
|
+
trans,
|
|
7216
7216
|
e,
|
|
7217
7217
|
errorMsg
|
|
7218
7218
|
});
|
|
7219
7219
|
return errorMsg;
|
|
7220
7220
|
}, [translations, i18n.language]);
|
|
7221
|
-
const createToastInstance = React.useCallback(toast => {
|
|
7221
|
+
const createToastInstance = React.useCallback((toast, trans) => {
|
|
7222
7222
|
const {
|
|
7223
7223
|
id,
|
|
7224
7224
|
disabledOfflineIntercept
|
|
@@ -7239,17 +7239,20 @@
|
|
|
7239
7239
|
console.warn({
|
|
7240
7240
|
toast,
|
|
7241
7241
|
isValidElement: /*#__PURE__*/React__namespace.isValidElement(toast.description),
|
|
7242
|
-
|
|
7242
|
+
trans
|
|
7243
7243
|
});
|
|
7244
7244
|
return Object.assign({
|
|
7245
7245
|
id: toastId,
|
|
7246
7246
|
position: TOP_RIGHT_POSITION
|
|
7247
7247
|
}, rest, {
|
|
7248
|
-
description: /*#__PURE__*/React__namespace.isValidElement(toast.description) ? toast.description : catchError$1(toast.description, toast.values)
|
|
7248
|
+
description: /*#__PURE__*/React__namespace.isValidElement(toast.description) ? toast.description : catchError$1(toast.description, toast.values, trans)
|
|
7249
7249
|
}, !isOnline && !disabledOfflineIntercept && offlineInstance);
|
|
7250
7250
|
}, [isOnline, t, translations, i18n.language]);
|
|
7251
7251
|
const addToast = React__namespace.useCallback(toast => {
|
|
7252
|
-
|
|
7252
|
+
console.warn({
|
|
7253
|
+
addToastTranslations: translations
|
|
7254
|
+
});
|
|
7255
|
+
const toastInstance = createToastInstance(toast, translations);
|
|
7253
7256
|
setToasts(toastItems => {
|
|
7254
7257
|
if (!toastItems.some(currToast => toast.id === currToast.id) || !toast.preventDuplicate) {
|
|
7255
7258
|
return [...toastItems, toastInstance];
|
|
@@ -7257,7 +7260,7 @@
|
|
|
7257
7260
|
return toastItems;
|
|
7258
7261
|
});
|
|
7259
7262
|
return toastInstance;
|
|
7260
|
-
}, [createToastInstance]);
|
|
7263
|
+
}, [createToastInstance, translations]);
|
|
7261
7264
|
const removeToast = React__namespace.useCallback(id => {
|
|
7262
7265
|
setToasts(toastItems => toastItems.filter(t => t.id !== id));
|
|
7263
7266
|
}, [setToasts]);
|
|
@@ -7269,7 +7272,7 @@
|
|
|
7269
7272
|
__self: undefined,
|
|
7270
7273
|
__source: {
|
|
7271
7274
|
fileName: _jsxFileName$R,
|
|
7272
|
-
lineNumber:
|
|
7275
|
+
lineNumber: 86,
|
|
7273
7276
|
columnNumber: 5
|
|
7274
7277
|
}
|
|
7275
7278
|
}, children, /*#__PURE__*/React__namespace.createElement(ToastContainer, {
|
|
@@ -7278,7 +7281,7 @@
|
|
|
7278
7281
|
__self: undefined,
|
|
7279
7282
|
__source: {
|
|
7280
7283
|
fileName: _jsxFileName$R,
|
|
7281
|
-
lineNumber:
|
|
7284
|
+
lineNumber: 88,
|
|
7282
7285
|
columnNumber: 7
|
|
7283
7286
|
}
|
|
7284
7287
|
}), /*#__PURE__*/React__namespace.createElement(ToastContainer, {
|
|
@@ -7287,7 +7290,7 @@
|
|
|
7287
7290
|
__self: undefined,
|
|
7288
7291
|
__source: {
|
|
7289
7292
|
fileName: _jsxFileName$R,
|
|
7290
|
-
lineNumber:
|
|
7293
|
+
lineNumber: 92,
|
|
7291
7294
|
columnNumber: 7
|
|
7292
7295
|
}
|
|
7293
7296
|
}), /*#__PURE__*/React__namespace.createElement(ToastContainer, {
|
|
@@ -7296,7 +7299,7 @@
|
|
|
7296
7299
|
__self: undefined,
|
|
7297
7300
|
__source: {
|
|
7298
7301
|
fileName: _jsxFileName$R,
|
|
7299
|
-
lineNumber:
|
|
7302
|
+
lineNumber: 96,
|
|
7300
7303
|
columnNumber: 7
|
|
7301
7304
|
}
|
|
7302
7305
|
}), /*#__PURE__*/React__namespace.createElement(ToastContainer, {
|
|
@@ -7305,7 +7308,7 @@
|
|
|
7305
7308
|
__self: undefined,
|
|
7306
7309
|
__source: {
|
|
7307
7310
|
fileName: _jsxFileName$R,
|
|
7308
|
-
lineNumber:
|
|
7311
|
+
lineNumber: 100,
|
|
7309
7312
|
columnNumber: 7
|
|
7310
7313
|
}
|
|
7311
7314
|
}));
|