@applica-software-guru/react-admin 1.2.123 → 1.3.126
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/bitbucket-pipelines.yml +3 -3
- package/dist/ApplicaAdmin.d.ts +1 -1
- package/dist/ApplicaAdmin.d.ts.map +1 -1
- package/dist/components/Notification.d.ts +2 -2
- package/dist/components/ra-forms/TabbedForm.d.ts +2 -2
- package/dist/components/ra-forms/TableForm/TableFormIterator.d.ts +2 -2
- package/dist/components/ra-forms/TableForm/TableFormIterator.d.ts.map +1 -1
- package/dist/components/ra-lists/Datagrid.d.ts +2 -2
- package/dist/components/ra-pages/GenericErrorPage.d.ts +3 -0
- package/dist/components/ra-pages/GenericErrorPage.d.ts.map +1 -0
- package/dist/components/ra-pages/index.d.ts +5 -5
- package/dist/components/ra-pages/index.d.ts.map +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/useMemoizedObject.d.ts +10 -0
- package/dist/hooks/useMemoizedObject.d.ts.map +1 -0
- package/dist/i18n/MissingMessageHandler.d.ts +19 -0
- package/dist/i18n/MissingMessageHandler.d.ts.map +1 -0
- package/dist/i18n/createI18nProvider.d.ts +8 -5
- package/dist/i18n/createI18nProvider.d.ts.map +1 -1
- package/dist/i18n/index.d.ts +0 -1
- package/dist/i18n/useI18nProvider.d.ts +5 -5
- package/dist/i18n/useI18nProvider.d.ts.map +1 -1
- package/dist/react-admin.cjs.js +62 -62
- package/dist/react-admin.cjs.js.map +1 -1
- package/dist/react-admin.es.js +10912 -10864
- package/dist/react-admin.es.js.map +1 -1
- package/dist/react-admin.umd.js +64 -64
- package/dist/react-admin.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/ApplicaAdmin.tsx +20 -44
- package/src/assets/genericError.png +0 -0
- package/src/components/ra-forms/TableForm/TableFormIterator.tsx +76 -27
- package/src/components/ra-forms/TableForm/TableFormIteratorItem.tsx +2 -2
- package/src/components/ra-pages/GenericErrorPage.tsx +23 -0
- package/src/components/ra-pages/index.ts +5 -5
- package/src/hooks/index.jsx +1 -0
- package/src/hooks/useMemoizedObject.tsx +27 -0
- package/src/i18n/MissingMessageHandler.ts +60 -0
- package/src/i18n/createI18nProvider.tsx +97 -0
- package/src/i18n/index.jsx +0 -1
- package/src/i18n/useI18nProvider.tsx +23 -0
- package/dist/i18n/useI18nCatcher.d.ts +0 -28
- package/dist/i18n/useI18nCatcher.d.ts.map +0 -1
- package/src/i18n/createI18nProvider.jsx +0 -15
- package/src/i18n/useI18nCatcher.ts +0 -109
- package/src/i18n/useI18nProvider.jsx +0 -4
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
|
|
4
|
-
import { useLocaleState } from 'react-admin';
|
|
5
|
-
|
|
6
|
-
const queued: string[] = [];
|
|
7
|
-
|
|
8
|
-
export type I18nCatcherBodyBuilderResultProps =
|
|
9
|
-
| {
|
|
10
|
-
lang: string;
|
|
11
|
-
code: string;
|
|
12
|
-
text: string;
|
|
13
|
-
}
|
|
14
|
-
| {
|
|
15
|
-
message: {
|
|
16
|
-
lang: string;
|
|
17
|
-
code: string;
|
|
18
|
-
text: string;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export type I18nCatcherBodyBuilderProps = (lang: string, message: string) => I18nCatcherBodyBuilderResultProps;
|
|
23
|
-
|
|
24
|
-
type PutMessageProps = {
|
|
25
|
-
apiUrl: string;
|
|
26
|
-
endpoint?: string;
|
|
27
|
-
locale: string;
|
|
28
|
-
message: string;
|
|
29
|
-
bodyBuilder: I18nCatcherBodyBuilderProps;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const putMessage = ({ apiUrl, endpoint, locale, message, bodyBuilder }: PutMessageProps): any =>
|
|
33
|
-
message != null &&
|
|
34
|
-
message !== 'undefined' &&
|
|
35
|
-
message.indexOf('[') === -1 &&
|
|
36
|
-
message.indexOf(']') === -1 &&
|
|
37
|
-
queued.indexOf(`${locale}-${message}`) === -1 &&
|
|
38
|
-
queued.push(`${locale}-${message}`) &&
|
|
39
|
-
fetch(`${apiUrl}${endpoint}`, {
|
|
40
|
-
method: 'PUT',
|
|
41
|
-
headers: new Headers({
|
|
42
|
-
Accept: 'application/json',
|
|
43
|
-
'Content-Type': 'application/json'
|
|
44
|
-
}),
|
|
45
|
-
body: JSON.stringify(bodyBuilder(locale, message) || {})
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
export type UseI18nCatcherProps = {
|
|
49
|
-
apiUrl: string;
|
|
50
|
-
enabled?: boolean;
|
|
51
|
-
endpoint?: string;
|
|
52
|
-
loading?: boolean;
|
|
53
|
-
bodyBuilder: I18nCatcherBodyBuilderProps;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Hook che consente di catturare ed inoltrare al server API le stringhe non tradotte.
|
|
58
|
-
*
|
|
59
|
-
* @param {UseI18nCatcherProps}
|
|
60
|
-
* @returns {boolean}
|
|
61
|
-
*/
|
|
62
|
-
const useI18nCatcher = ({
|
|
63
|
-
apiUrl,
|
|
64
|
-
enabled = true,
|
|
65
|
-
endpoint = '/languages/put-message',
|
|
66
|
-
loading,
|
|
67
|
-
bodyBuilder = (lang, message) => ({
|
|
68
|
-
lang,
|
|
69
|
-
code: message,
|
|
70
|
-
text: message
|
|
71
|
-
})
|
|
72
|
-
}: UseI18nCatcherProps) => {
|
|
73
|
-
const [locale] = useLocaleState();
|
|
74
|
-
React.useMemo(() => {
|
|
75
|
-
if (loading) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (!enabled) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const consoleError = console.error;
|
|
84
|
-
|
|
85
|
-
console.error = function (message) {
|
|
86
|
-
if (typeof message === 'string' && message === '%c%s') {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
if (typeof message === 'string' && message.indexOf('Missing translation for key: ') >= 0) {
|
|
90
|
-
message = message.replace('Warning: Missing translation for key: ', '');
|
|
91
|
-
message = message.split('"').join('').trim();
|
|
92
|
-
if (message === null || message.indexOf(' ') !== -1 || message.indexOf('.') === -1) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const lc = localStorage.getItem('locale') || locale;
|
|
97
|
-
putMessage({ apiUrl, endpoint, locale: lc, message, bodyBuilder });
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// eslint-disable-next-line prefer-rest-params
|
|
102
|
-
// eslint-disable-next-line prefer-rest-params
|
|
103
|
-
consoleError.apply(console, arguments as any);
|
|
104
|
-
};
|
|
105
|
-
}, [apiUrl, locale, loading, bodyBuilder, endpoint, enabled]);
|
|
106
|
-
return true;
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
export default useI18nCatcher;
|