@applica-software-guru/react-admin 1.5.310 → 1.5.311

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
@@ -107,5 +107,5 @@
107
107
  "type": "module",
108
108
  "types": "dist/index.d.ts",
109
109
  "typings": "dist/index.d.ts",
110
- "version": "1.5.310"
110
+ "version": "1.5.311"
111
111
  }
@@ -1,10 +1,9 @@
1
- import { Drawer as MUIDrawer, useMediaQuery, useTheme } from '@mui/material';
1
+ import { Drawer as MUIDrawer, SxProps, useMediaQuery, useTheme } from '@mui/material';
2
2
  import { useCallback } from 'react';
3
- import { useSx } from '@/hooks';
4
3
  import { isFunction } from 'lodash';
5
4
 
6
5
  type DrawerProps = {
7
- PaperProps?: Record<string, any>;
6
+ sx?: SxProps;
8
7
  anchor?: 'left' | 'right' | 'top' | 'bottom';
9
8
  variant?: 'temporary' | 'persistent' | 'permanent';
10
9
  children: React.ReactNode;
@@ -12,8 +11,17 @@ type DrawerProps = {
12
11
  onClose?: () => void;
13
12
  };
14
13
 
14
+ /**
15
+ * The Dialog component in Material UI has a maximum width of 444px at the 'xs' breakpoint.
16
+ * To maintain consistency, we use the same value as the max width for the Drawer component,
17
+ * but only for the 'sm' breakpoint and above.
18
+ * At the 'xs' breakpoint, the Drawer should occupy the full width.
19
+ * @see https://github.com/mui/material-ui/blob/v5.15.17/packages/mui-material/src/Dialog/Dialog.js
20
+ */
21
+ const MAX_WIDTH = 444;
22
+
15
23
  function Drawer(props: DrawerProps) {
16
- const { PaperProps, anchor = 'right', variant = 'temporary', open = false, onClose } = props;
24
+ const { sx, anchor = 'right', variant = 'temporary', open = false, onClose } = props;
17
25
  const theme = useTheme();
18
26
  const isMobile = useMediaQuery(theme.breakpoints.down('sm'));
19
27
  const anchorPosition = isMobile ? 'bottom' : anchor;
@@ -22,15 +30,20 @@ function Drawer(props: DrawerProps) {
22
30
  onClose();
23
31
  }
24
32
  }, [onClose]);
25
- const sx = useSx(PaperProps ?? {}, {
33
+ const sxProps = {
26
34
  backgroundImage: 'none',
27
35
  boxShadow: '-10px 4px 42px 0px rgba(0, 0, 0, 0.25)',
28
36
  width: {
29
- xs: window.innerWidth,
30
- sm: 480,
31
- md: 600
37
+ sm: '30%'
38
+ },
39
+ maxWidth: {
40
+ sm: MAX_WIDTH
41
+ },
42
+ [theme.breakpoints.down('sm')]: {
43
+ width: '100% !important',
44
+ maxWidth: '100% !important'
32
45
  }
33
- });
46
+ };
34
47
 
35
48
  return (
36
49
  <MUIDrawer
@@ -38,7 +51,7 @@ function Drawer(props: DrawerProps) {
38
51
  anchor={anchorPosition}
39
52
  onClose={handleClose}
40
53
  open={open}
41
- PaperProps={{ sx: sx }}
54
+ PaperProps={{ sx: { ...sxProps, ...sx } }}
42
55
  variant={variant}
43
56
  >
44
57
  {props.children}
@@ -115,7 +115,7 @@ function FilterSidebar(props: FilterSidebarProps): ReactElement {
115
115
  }, [values, getValues, watchValues]);
116
116
 
117
117
  return (
118
- <Sidebar PaperProps={{ sx: { height: '100%' } }} open={sidebarOpen} onClose={closeSidebar}>
118
+ <Sidebar sx={{ height: '100%' }} open={sidebarOpen} onClose={closeSidebar}>
119
119
  <Sidebar.Header>
120
120
  <Sidebar.HeaderText primary={translate('ra.action.add_filter')} />
121
121
  <Sidebar.HeaderAction>