@applica-software-guru/react-admin 1.2.119 → 1.2.121

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applica-software-guru/react-admin",
3
- "version": "1.2.119",
3
+ "version": "1.2.121",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -220,7 +220,18 @@ const CreateInDialogButton = ({
220
220
  <Add />
221
221
  </Button>
222
222
  )}
223
- <Dialog open={open} onClose={handleClose} fullWidth={fullWidth} maxWidth={maxWidth}>
223
+ <Dialog
224
+ open={open}
225
+ scroll="body"
226
+ sx={{
227
+ '& .MuiToolbar-root': {
228
+ position: 'initial'
229
+ }
230
+ }}
231
+ onClose={handleClose}
232
+ fullWidth={fullWidth}
233
+ maxWidth={maxWidth}
234
+ >
224
235
  <CreateInDialogContent
225
236
  {...props}
226
237
  redirect={redirect}
@@ -80,7 +80,18 @@ const EditInDialogButton = ({ fullWidth, maxWidth, label, ...props }) => {
80
80
  <Button label={label} onClick={handleOpen}>
81
81
  <Edit />
82
82
  </Button>
83
- <Dialog open={open} onClose={handleClose} fullWidth={fullWidth} maxWidth={maxWidth}>
83
+ <Dialog
84
+ open={open}
85
+ scroll="body"
86
+ sx={{
87
+ '& .MuiToolbar-root': {
88
+ position: 'initial'
89
+ }
90
+ }}
91
+ onClose={handleClose}
92
+ fullWidth={fullWidth}
93
+ maxWidth={maxWidth}
94
+ >
84
95
  <EditInDialogContent {...props} onClose={handleClose} />
85
96
  </Dialog>
86
97
  </>
@@ -1,7 +1,8 @@
1
1
  import { createContext, useCallback, useContext, useEffect, useMemo, useReducer } from 'react';
2
- import _ from 'lodash';
3
- import { IItem } from './types';
4
2
  import { matchPath, useLocation } from 'react-router';
3
+
4
+ import { IItem } from './types';
5
+ import _ from 'lodash';
5
6
  import { getItemsIds } from './utils';
6
7
 
7
8
  enum ActionType {
@@ -61,8 +62,12 @@ function reducer(state: IState, action: IAction): IState {
61
62
  return _.includes(getItemsIds(state.items), payload) ? _.extend(newState, { activeItem: payload }) : newState;
62
63
  case ActionType.ADD_ITEM: {
63
64
  const id = payload.id,
64
- items = _.reject(newState.items, (item: IItem) => item.id === id);
65
- items.push(payload);
65
+ items = _.chain(newState.items)
66
+ .clone()
67
+ .reject((item: IItem) => item.id === id)
68
+ .concat([payload])
69
+ .orderBy((item) => item.index)
70
+ .value();
66
71
  _.extend(newState, { items: items });
67
72
  if (newState.activeItem === undefined) {
68
73
  _.extend(newState, { activeItem: payload.id });
@@ -71,7 +76,10 @@ function reducer(state: IState, action: IAction): IState {
71
76
  }
72
77
  case ActionType.REMOVE_ITEM: {
73
78
  const id = _.isString(payload) ? payload : payload.id,
74
- items = _.reject(newState.items, (item: IItem) => item.id === id);
79
+ items = _.chain(newState.items)
80
+ .clone()
81
+ .reject((item: IItem) => item.id === id)
82
+ .value();
75
83
  _.extend(newState, { items: items });
76
84
  if (newState.activeItem === id) {
77
85
  _.extend(newState, { activeItem: _.first(items)?.id ?? undefined });
@@ -105,8 +113,8 @@ function Provider(props: IProviderProps) {
105
113
  const matchStrings = [
106
114
  'entities/:resource/create/*',
107
115
  ':resource/create/*',
108
- 'entities/:resource/:id/show',
109
- ':resource/:id/show',
116
+ 'entities/:resource/:id/show/*',
117
+ ':resource/:id/show/*',
110
118
  'entities/:resource/:id/*',
111
119
  ':resource/:id/*'
112
120
  ];
@@ -7,12 +7,12 @@ import { IItem } from './types';
7
7
  import { useIsActive } from './hooks';
8
8
  import { getId } from './utils';
9
9
 
10
- type IBaseItemProps = React.PropsWithChildren<Optional<IItem, 'id'>>;
10
+ type IBaseItemProps = React.PropsWithChildren<Optional<IItem, 'id' | 'index'>>;
11
11
  type ITabProps = IBaseItemProps;
12
12
  type IGroupProps = IBaseItemProps;
13
13
 
14
14
  function BaseItem(props: IBaseItemProps) {
15
- const { label, icon, badge } = props,
15
+ const { label, icon, badge, index = 0 } = props,
16
16
  id = getId(props),
17
17
  addItem = useAddItem(),
18
18
  removeItem = useRemoveItem(),
@@ -21,6 +21,7 @@ function BaseItem(props: IBaseItemProps) {
21
21
  useEffect(() => {
22
22
  addItem({
23
23
  id: id,
24
+ index: index,
24
25
  label: label,
25
26
  icon: icon,
26
27
  badge: badge
@@ -28,7 +29,7 @@ function BaseItem(props: IBaseItemProps) {
28
29
  return () => {
29
30
  removeItem(id);
30
31
  };
31
- }, [addItem, removeItem, label, icon, id, badge]);
32
+ }, [addItem, removeItem, label, icon, id, badge, index]);
32
33
 
33
34
  /* All tabs are rendered (not only the one in focus), to allow validation
34
35
  on tabs not in focus. The tabs receive a `hidden` property, which they'll
@@ -57,8 +58,12 @@ function Tab(props: ITabProps) {
57
58
  function useBaseItemChildren(props: React.PropsWithChildren): Array<React.FunctionComponentElement<IBaseItemProps>> {
58
59
  const { children } = props,
59
60
  result = useMemo<Array<React.FunctionComponentElement<IBaseItemProps>>>(
60
- //@ts-ignore
61
- () => _.filter(Children.toArray(children), (Child) => isValidElement(Child) && (Child?.type === Tab || Child?.type === Group)),
61
+ () =>
62
+ //@ts-ignore
63
+ _.chain(Children.toArray(children))
64
+ .filter((Child) => isValidElement(Child) && (Child?.type === Tab || Child?.type === Group))
65
+ .map((Child: React.FunctionComponentElement<IBaseItemProps>, index) => cloneElement(Child, { index: index }))
66
+ .value(),
62
67
  [children]
63
68
  );
64
69
  return result;
@@ -8,6 +8,7 @@ type Disposition = {
8
8
 
9
9
  type IItem = {
10
10
  id: string;
11
+ index: number;
11
12
  label: string;
12
13
  icon?: React.ReactNode;
13
14
  badge?: {
@@ -18,8 +18,11 @@ const ApplicaStyledSimpleForm = styled(RaSimpleForm, {
18
18
  slot: 'Root'
19
19
  })(({ theme, modal }: { theme: any; modal: boolean }) => ({
20
20
  '& .MuiGrid-root.MuiGrid-container': {
21
- paddingBottom: theme.spacing(modal ? 2 : 1)
22
- } as any
21
+ paddingBottom: theme.spacing(modal ? 0 : 1)
22
+ } as any,
23
+ [theme.breakpoints.down('sm')]: {
24
+ paddingBottom: 0
25
+ }
23
26
  }));
24
27
 
25
28
  export type SimpleFormProps = RaSimpleFormProps & {