Skip to content

Commit f9ad965

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

7 files changed

Lines changed: 29 additions & 10 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
};

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)