Skip to content

Commit cf64fc1

Browse files
author
smeng9
committed
fix unit tests
1 parent 49c46e1 commit cf64fc1

10 files changed

Lines changed: 50 additions & 18 deletions

File tree

packages/ra-ui-materialui/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@
8181
"react-dropzone": "^14.2.3",
8282
"react-error-boundary": "^4.0.13",
8383
"react-hotkeys-hook": "^5.1.0",
84-
"react-transition-group": "^4.4.5"
84+
"react-transition-group": "^4.4.5",
85+
"semver": "^7.7.4"
8586
},
8687
"gitHead": "19dcb264898c8e01c408eb66ce02c50b67c851ab",
8788
"exports": {

packages/ra-ui-materialui/src/input/DateInput.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import {
1111
import { CommonInputProps } from './CommonInputProps';
1212
import { sanitizeInputRestProps } from './sanitizeInputRestProps';
1313
import { InputHelperText } from './InputHelperText';
14-
import { useForkRef } from '@mui/material';
14+
import { useForkRef, version as muiVersion } from '@mui/material';
15+
import { gte } from 'semver';
1516

1617
/**
1718
* Form input to edit a Date string value in the "YYYY-MM-DD" format (e.g. '2021-06-23').
@@ -236,7 +237,9 @@ export const DateInput = (props: DateInputProps) => {
236237
}
237238
InputLabelProps={defaultInputLabelProps}
238239
{...sanitizeInputRestProps(rest)}
239-
slotProps={mergedSlotProps}
240+
{...(gte(muiVersion as string, '9.0.0')
241+
? { slotProps: mergedSlotProps }
242+
: {})}
240243
/>
241244
);
242245
};

packages/ra-ui-materialui/src/input/DateTimeInput.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import {
1111
import { CommonInputProps } from './CommonInputProps';
1212
import { sanitizeInputRestProps } from './sanitizeInputRestProps';
1313
import { InputHelperText } from './InputHelperText';
14-
import { useForkRef } from '@mui/material';
14+
import { useForkRef, version as muiVersion } from '@mui/material';
15+
import { gte } from 'semver';
1516

1617
/**
1718
* Input component for entering a date and a time with timezone, using the browser locale
@@ -195,7 +196,9 @@ export const DateTimeInput = (props: DateTimeInputProps) => {
195196
}
196197
InputLabelProps={defaultInputLabelProps}
197198
{...sanitizeInputRestProps(rest)}
198-
slotProps={mergedSlotProps}
199+
{...(gte(muiVersion as string, '9.0.0')
200+
? { slotProps: mergedSlotProps }
201+
: {})}
199202
/>
200203
);
201204
};

packages/ra-ui-materialui/src/input/NumberInput.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import {
77
styled,
88
useThemeProps,
99
} from '@mui/material/styles';
10+
import { version as muiVersion } from '@mui/material';
11+
import { gte } from 'semver';
1012

1113
import { CommonInputProps } from './CommonInputProps';
1214
import { InputHelperText } from './InputHelperText';
@@ -177,7 +179,9 @@ export const NumberInput = (props: NumberInputProps) => {
177179
margin={margin}
178180
inputProps={inputProps}
179181
{...sanitizeInputRestProps(rest)}
180-
slotProps={mergedSlotProps}
182+
{...(gte(muiVersion as string, '9.0.0')
183+
? { slotProps: mergedSlotProps }
184+
: {})}
181185
/>
182186
);
183187
};

packages/ra-ui-materialui/src/input/ResettableTextField.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ import {
1111
IconButton,
1212
TextField as MuiTextField,
1313
type TextFieldProps,
14+
version as muiVersion,
1415
} from '@mui/material';
16+
import { gte } from 'semver';
1517
import ClearIcon from '@mui/icons-material/Clear';
1618
import { useTranslate } from 'ra-core';
1719

@@ -174,8 +176,9 @@ export const ResettableTextField = forwardRef(
174176
margin={margin}
175177
className={className}
176178
{...rest}
177-
// @ts-expect-error slotProps do not yet exist in MUI v5
178-
slotProps={mergedSlotProps}
179+
{...(gte(muiVersion as string, '9.0.0')
180+
? { slotProps: mergedSlotProps }
181+
: {})}
179182
inputRef={ref}
180183
/>
181184
);

packages/ra-ui-materialui/src/input/TimeInput.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import {
77
styled,
88
useThemeProps,
99
} from '@mui/material/styles';
10+
import { version as muiVersion } from '@mui/material';
11+
import { gte } from 'semver';
1012

1113
import { CommonInputProps } from './CommonInputProps';
1214
import { sanitizeInputRestProps } from './sanitizeInputRestProps';
@@ -131,7 +133,9 @@ export const TimeInput = (props: TimeInputProps) => {
131133
}
132134
InputLabelProps={defaultInputLabelProps}
133135
{...sanitizeInputRestProps(rest)}
134-
slotProps={mergedSlotProps}
136+
{...(gte(muiVersion as string, '9.0.0')
137+
? { slotProps: mergedSlotProps }
138+
: {})}
135139
/>
136140
);
137141
};

packages/ra-ui-materialui/src/layout/Notification.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ import {
1111
Snackbar,
1212
type SnackbarProps,
1313
SnackbarOrigin,
14+
version as muiVersion,
1415
} from '@mui/material';
16+
import { gte } from 'semver';
1517
import clsx from 'clsx';
1618

1719
import {
@@ -185,8 +187,9 @@ export const Notification = (inProps: NotificationProps) => {
185187
anchorOrigin={anchorOrigin}
186188
{...rest}
187189
{...options}
188-
// @ts-expect-error slotProps do not yet exist in MUI v5
189-
slotProps={mergedSlotProps}
190+
{...(gte(muiVersion as string, '9.0.0')
191+
? { slotProps: mergedSlotProps }
192+
: {})}
190193
>
191194
{message &&
192195
typeof message !== 'string' &&

packages/ra-ui-materialui/src/list/datagrid/DatagridHeader.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@ import {
77
SortPayload,
88
useTranslate,
99
} from 'ra-core';
10-
import { Checkbox, TableCell, TableHead, TableRow } from '@mui/material';
10+
import {
11+
Checkbox,
12+
TableCell,
13+
TableHead,
14+
TableRow,
15+
version as muiVersion,
16+
} from '@mui/material';
17+
import { gte } from 'semver';
1118
import clsx from 'clsx';
1219

1320
import DatagridHeaderCell from './DatagridHeaderCell';
@@ -114,8 +121,9 @@ export const DatagridHeader = (props: DatagridHeaderProps) => {
114121
>
115122
<Checkbox
116123
inputProps={selectAllInputProps}
117-
// @ts-expect-error slotProps do not yet exist in MUI v5
118-
slotProps={{ input: selectAllInputProps }}
124+
{...(gte(muiVersion as string, '9.0.0')
125+
? { slotProps: { input: selectAllInputProps } }
126+
: {})}
119127
className="select-all"
120128
color="primary"
121129
checked={

packages/ra-ui-materialui/src/list/datatable/SelectPageCheckbox.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Checkbox } from '@mui/material';
1+
import { Checkbox, version as muiVersion } from '@mui/material';
2+
import { gte } from 'semver';
23
import {
34
useDataTableCallbacksContext,
45
useDataTableDataContext,
@@ -54,8 +55,9 @@ export const SelectPageCheckbox = () => {
5455
return (
5556
<Checkbox
5657
inputProps={selectAllInputProps}
57-
// @ts-expect-error slotProps do not yet exist in MUI v5
58-
slotProps={{ input: selectAllInputProps }}
58+
{...(gte(muiVersion as string, '9.0.0')
59+
? { slotProps: { input: selectAllInputProps } }
60+
: {})}
5961
className="select-all"
6062
color="primary"
6163
checked={

yarn.lock

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21086,6 +21086,7 @@ __metadata:
2108621086
react-router: "npm:^6.28.1"
2108721087
react-router-dom: "npm:^6.28.1"
2108821088
react-transition-group: "npm:^4.4.5"
21089+
semver: "npm:^7.7.4"
2108921090
typescript: "npm:^5.1.3"
2109021091
zshy: "npm:^0.5.0"
2109121092
peerDependencies:
@@ -22760,7 +22761,7 @@ __metadata:
2276022761
languageName: node
2276122762
linkType: hard
2276222763

22763-
"semver@npm:^7.5.3, semver@npm:^7.5.4, semver@npm:^7.6.3":
22764+
"semver@npm:^7.5.3, semver@npm:^7.5.4, semver@npm:^7.6.3, semver@npm:^7.7.4":
2276422765
version: 7.7.4
2276522766
resolution: "semver@npm:7.7.4"
2276622767
bin:

0 commit comments

Comments
 (0)