@applica-software-guru/react-admin 1.5.342 → 1.5.344

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
@@ -108,5 +108,5 @@
108
108
  "type": "module",
109
109
  "types": "dist/index.d.ts",
110
110
  "typings": "dist/index.d.ts",
111
- "version": "1.5.342"
111
+ "version": "1.5.344"
112
112
  }
@@ -1,6 +1,6 @@
1
1
  import { FC, ReactElement, memo, useCallback, useEffect, useMemo, useState } from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { TablePagination, TablePaginationBaseProps, Theme, Toolbar, useMediaQuery } from '@mui/material';
3
+ import { TablePagination, TablePaginationBaseProps, Theme, Toolbar, useMediaQuery, useTheme } from '@mui/material';
4
4
  import {
5
5
  ComponentPropType,
6
6
  ListPaginationContextValue,
@@ -21,6 +21,7 @@ const Pagination: FC<PaginationProps> = memo((props) => {
21
21
  const [currentPage, setCurrentPage] = useState(page - 1); // Stato per la UI
22
22
  const { hasCreate } = useResourceDefinition(props);
23
23
  const [isSelectedPage, setIsSelectedPage] = useState(false);
24
+ const theme = useTheme();
24
25
 
25
26
  useEffect(() => {
26
27
  if (page !== currentPage + 1 && !isSelectedPage) {
@@ -139,7 +140,21 @@ const Pagination: FC<PaginationProps> = memo((props) => {
139
140
  rowsPerPageOptions={emptyArray}
140
141
  component="span"
141
142
  labelDisplayedRows={labelDisplayedRows}
142
- sx={{ justifyContent: hasCreate ? 'flex-start' : 'flex-end', display: hasCreate ? 'flex' : 'block' }}
143
+ sx={{
144
+ justifyContent: hasCreate ? 'flex-start' : 'flex-end',
145
+ display: hasCreate ? 'flex' : 'block',
146
+ ...(props.displayStyle !== 'text' && {
147
+ '.MuiTablePagination-actions': {
148
+ display: 'flex',
149
+ flexDirection: 'row',
150
+ gap: '4px'
151
+ },
152
+
153
+ '& button': {
154
+ border: `1px solid ${theme.palette.divider}`
155
+ }
156
+ })
157
+ }}
143
158
  {...sanitizeListRestProps(rest)}
144
159
  />
145
160
  );
@@ -168,6 +183,37 @@ const Pagination: FC<PaginationProps> = memo((props) => {
168
183
  labelDisplayedRows={labelDisplayedRows}
169
184
  getItemAriaLabel={labelItem}
170
185
  rowsPerPageOptions={rowsPerPageOptions}
186
+ sx={
187
+ props.displayStyle !== 'text'
188
+ ? {
189
+ '.MuiInputBase-root': {
190
+ border: `1px solid ${theme.palette.divider}`,
191
+ borderRadius: '4px'
192
+ },
193
+ '.MuiTablePagination-spacer': {
194
+ display: 'none'
195
+ },
196
+ '.MuiTablePagination-selectLabel': {
197
+ color: theme.palette.text.secondary
198
+ },
199
+ '.MuiTablePagination-actions': {
200
+ flex: 1,
201
+ position: 'absolute',
202
+ right: 24
203
+ },
204
+ '& button': {
205
+ border: `1px solid ${theme.palette.divider}`,
206
+ '&.Mui-selected': {
207
+ fontSize: '0.875rem',
208
+ fontWeight: 'regular',
209
+ backgroundColor: 'trasparent',
210
+ border: `1px solid ${theme.palette.primary.main}`,
211
+ color: theme.palette.primary.main
212
+ }
213
+ }
214
+ }
215
+ : {}
216
+ }
171
217
  {...sanitizeListRestProps(rest)}
172
218
  />
173
219
  );
@@ -194,6 +240,7 @@ interface PaginationProps extends TablePaginationBaseProps, Partial<ListPaginati
194
240
  rowsPerPageOptions?: Array<number | { label: string; value: number }>;
195
241
  actions?: FC<PaginationActionsProps>;
196
242
  limit?: ReactElement;
243
+ displayStyle?: 'text' | 'outlined';
197
244
  }
198
245
 
199
246
  export { Pagination };
@@ -4,9 +4,15 @@ import { Button, useAuthProvider, useRecordContext } from 'react-admin';
4
4
 
5
5
  type ImpersonateUserButtonProps = {
6
6
  label?: string;
7
+ redirect?: string;
8
+ [x: string]: any; // Allow other props to be passed through
7
9
  };
8
10
 
9
- function ImpersonateUserButton({ label = 'ra.auth.sign_in', ...props }: ImpersonateUserButtonProps): JSX.Element {
11
+ function ImpersonateUserButton({
12
+ label = 'ra.auth.sign_in',
13
+ redirect = '/',
14
+ ...props
15
+ }: ImpersonateUserButtonProps): JSX.Element {
10
16
  const record = useRecordContext();
11
17
  const [loading, setLoading] = useState(false);
12
18
  const authProvider = useAuthProvider();
@@ -17,10 +23,10 @@ function ImpersonateUserButton({ label = 'ra.auth.sign_in', ...props }: Imperson
17
23
  setLoading(true);
18
24
  authProvider.impersonate(record?.id).then(() => {
19
25
  setLoading(false);
20
- document.location.href = '/';
26
+ document.location.href = redirect;
21
27
  });
22
28
  },
23
- [authProvider, record?.id]
29
+ [authProvider, record?.id, redirect]
24
30
  );
25
31
  return (
26
32
  <Button