@applica-software-guru/react-admin 1.3.129 → 1.3.131
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/components/ra-forms/LongForm/NavMenu.d.ts.map +1 -1
- package/dist/components/ra-forms/LongForm/Provider.d.ts.map +1 -1
- package/dist/components/ra-forms/LongForm/hooks.d.ts.map +1 -1
- package/dist/dev/useErrorEventCatcher.d.ts.map +1 -1
- package/dist/i18n/createI18nProvider.d.ts.map +1 -1
- package/dist/react-admin.cjs.js +15 -15
- package/dist/react-admin.cjs.js.map +1 -1
- package/dist/react-admin.es.js +449 -446
- package/dist/react-admin.es.js.map +1 -1
- package/dist/react-admin.umd.js +12 -12
- package/dist/react-admin.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/ApplicaAdmin.tsx +2 -2
- package/src/components/ra-forms/LongForm/NavMenu.tsx +7 -1
- package/src/components/ra-forms/LongForm/Provider.tsx +5 -8
- package/src/components/ra-forms/LongForm/hooks.tsx +5 -1
- package/src/dev/useErrorEventCatcher.ts +16 -5
- package/src/i18n/createI18nProvider.tsx +0 -4
package/package.json
CHANGED
package/src/ApplicaAdmin.tsx
CHANGED
|
@@ -163,7 +163,7 @@ const ApplicaAdmin = ({
|
|
|
163
163
|
useErrorEventCatcher({
|
|
164
164
|
apiUrl,
|
|
165
165
|
errorHandler,
|
|
166
|
-
catcherFn: (error:
|
|
166
|
+
catcherFn: (error: ErrorEvent | string): CatchResult => {
|
|
167
167
|
const errorMessage = error?.toString();
|
|
168
168
|
const knownErrors = [
|
|
169
169
|
// @see https://github.com/marmelab/react-admin/pull/8884
|
|
@@ -177,7 +177,7 @@ const ApplicaAdmin = ({
|
|
|
177
177
|
catch: isKnowBug,
|
|
178
178
|
display: !isKnowBug,
|
|
179
179
|
log: !isKnowBug,
|
|
180
|
-
error
|
|
180
|
+
error: errorMessage
|
|
181
181
|
});
|
|
182
182
|
return result;
|
|
183
183
|
}
|
|
@@ -3,7 +3,7 @@ import { Avatar } from '../../@extended';
|
|
|
3
3
|
import { Card, Collapse, List, ListItem, ListItemProps, ListItemIcon, ListItemText, ListItemButton, ListItemAvatar } from '@mui/material';
|
|
4
4
|
import { useSetActiveItem, useSyncWithLocation } from './Provider';
|
|
5
5
|
import { IItem } from './types';
|
|
6
|
-
import { useCallback, useMemo, useState } from 'react';
|
|
6
|
+
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
7
7
|
import { useChildren, useIsActive, useNavigateForm } from './hooks';
|
|
8
8
|
import { ExpandLess, ExpandMore } from '@mui/icons-material';
|
|
9
9
|
import { getLevel } from './utils';
|
|
@@ -57,6 +57,12 @@ function NavMenuItem(props: INavMenuItemProps) {
|
|
|
57
57
|
hasIcon = icon !== undefined,
|
|
58
58
|
listItemProps = _.omit(props, ['label', 'icon', 'selected', 'badge']);
|
|
59
59
|
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
if (selected && !open) {
|
|
62
|
+
setOpen(selected);
|
|
63
|
+
}
|
|
64
|
+
}, [selected, open, setOpen]);
|
|
65
|
+
|
|
60
66
|
return (
|
|
61
67
|
<>
|
|
62
68
|
<ListItem {...listItemProps} disablePadding>
|
|
@@ -61,18 +61,15 @@ function reducer(state: IState, action: IAction): IState {
|
|
|
61
61
|
case ActionType.SET_ACTIVE_ITEM:
|
|
62
62
|
return _.includes(getItemsIds(state.items), payload) ? _.extend(newState, { activeItem: payload }) : newState;
|
|
63
63
|
case ActionType.ADD_ITEM: {
|
|
64
|
-
const id = payload
|
|
65
|
-
|
|
64
|
+
const { id } = payload;
|
|
65
|
+
return _.extend(newState, {
|
|
66
|
+
items: _.chain(newState.items)
|
|
66
67
|
.clone()
|
|
67
68
|
.reject((item: IItem) => item.id === id)
|
|
68
69
|
.concat([payload])
|
|
69
70
|
.orderBy((item) => item.index)
|
|
70
|
-
.value()
|
|
71
|
-
|
|
72
|
-
if (newState.activeItem === undefined) {
|
|
73
|
-
_.extend(newState, { activeItem: payload.id });
|
|
74
|
-
}
|
|
75
|
-
return newState;
|
|
71
|
+
.value()
|
|
72
|
+
});
|
|
76
73
|
}
|
|
77
74
|
case ActionType.REMOVE_ITEM: {
|
|
78
75
|
const id = _.isString(payload) ? payload : payload.id,
|
|
@@ -6,7 +6,11 @@ import { useNavigate } from 'react-router';
|
|
|
6
6
|
|
|
7
7
|
function useIsActive(id: string): boolean {
|
|
8
8
|
const activeItem = useActiveItem();
|
|
9
|
-
|
|
9
|
+
if (activeItem === undefined) {
|
|
10
|
+
return false;
|
|
11
|
+
} else {
|
|
12
|
+
return id === activeItem || isChild(id, activeItem);
|
|
13
|
+
}
|
|
10
14
|
}
|
|
11
15
|
|
|
12
16
|
function useChildren(id?: string): Array<IItem> {
|
|
@@ -26,23 +26,34 @@ const useErrorEventCatcher = ({
|
|
|
26
26
|
}
|
|
27
27
|
return new ErrorEventHandler({ apiUrl });
|
|
28
28
|
}, [apiUrl, props.errorHandler]);
|
|
29
|
+
const consoleError = console.error;
|
|
29
30
|
const handleError = React.useCallback(
|
|
30
|
-
function (event: ErrorEvent) {
|
|
31
|
-
const catchResult = catcherFn(event);
|
|
32
|
-
|
|
31
|
+
function (event: ErrorEvent | string, ...args: any[]) {
|
|
32
|
+
const catchResult = catcherFn(event instanceof ErrorEvent ? event : event.replace(/%s/g, () => args.shift()));
|
|
33
|
+
if (catchResult.isCatched()) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
33
36
|
if (catchResult.logError()) {
|
|
34
|
-
|
|
37
|
+
if (event instanceof ErrorEvent) {
|
|
38
|
+
errorHandler.handle(event);
|
|
39
|
+
} else {
|
|
40
|
+
errorHandler.handle(new ErrorEvent('window.onerror', { error: event, message: event.toString() }));
|
|
41
|
+
}
|
|
35
42
|
}
|
|
36
43
|
|
|
37
|
-
|
|
44
|
+
if (catchResult.displayError()) {
|
|
45
|
+
consoleError.apply(console, arguments as any);
|
|
46
|
+
}
|
|
38
47
|
},
|
|
39
48
|
[apiUrl, loading, catcherFn, enabled, errorHandler]
|
|
40
49
|
);
|
|
41
50
|
React.useEffect(() => {
|
|
42
51
|
window.removeEventListener('error', handleError);
|
|
43
52
|
window.addEventListener('error', handleError);
|
|
53
|
+
console.error = handleError;
|
|
44
54
|
return () => {
|
|
45
55
|
window.removeEventListener('error', handleError);
|
|
56
|
+
console.error = consoleError;
|
|
46
57
|
};
|
|
47
58
|
}, [handleError]);
|
|
48
59
|
return true;
|
|
@@ -36,10 +36,6 @@ function createI18nProvider(data: ICreateI18nProviderData): Promise<any> {
|
|
|
36
36
|
getLanguages = (): Promise<Locale> => {
|
|
37
37
|
return fetch(`${apiUrl}/i18n/languages`, { headers: headers, method: 'get' })
|
|
38
38
|
.then((response) => response.json())
|
|
39
|
-
.then((response) => {
|
|
40
|
-
const { responseCode, locales } = response;
|
|
41
|
-
return responseCode !== 'ok' ? defaultLanguages : locales;
|
|
42
|
-
})
|
|
43
39
|
.catch(() => {
|
|
44
40
|
return Promise.resolve(defaultLanguages);
|
|
45
41
|
});
|