Skip to content

Commit

Permalink
[core] Fixes in preparation for React 18.3 (#13378)
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasTy committed Jun 5, 2024
1 parent 64222de commit 6d92fca
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,18 @@ function GridFilterInputMultipleSingleSelect(props: GridFilterInputMultipleSingl
onChange={handleChange}
getOptionLabel={getOptionLabel}
renderTags={(value, getTagProps) =>
value.map((option, index) => (
<rootProps.slots.baseChip
variant="outlined"
size="small"
label={getOptionLabel(option)}
{...getTagProps({ index })}
/>
))
value.map((option, index) => {
const { key, ...tagProps } = getTagProps({ index });
return (
<rootProps.slots.baseChip
key={key}
variant="outlined"
size="small"
label={getOptionLabel(option)}
{...tagProps}
/>
);
})
}
renderInput={(params) => (
<rootProps.slots.baseTextField
Expand Down
8 changes: 5 additions & 3 deletions packages/x-date-pickers-pro/src/models/fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import {
} from '@mui/x-date-pickers/models';
import { UseClearableFieldResponse } from '@mui/x-date-pickers/hooks';
import { SxProps } from '@mui/material/styles';
import TextField from '@mui/material/TextField';
import { RangePosition } from './range';

export interface RangeFieldSection extends FieldSection {
dateName: 'start' | 'end';
dateName: RangePosition;
}

export type FieldType = 'single-input' | 'multi-input';
Expand Down Expand Up @@ -86,9 +88,9 @@ export interface BaseMultiInputFieldProps<
Record<string, any>
>;
textField?: SlotComponentProps<
React.ElementType<MultiInputFieldSlotTextFieldProps>,
typeof TextField,
{},
{ position?: 'start' | 'end' } & Record<string, any>
{ position?: RangePosition } & Record<string, any>
>;
};
}
Expand Down
17 changes: 7 additions & 10 deletions packages/x-date-pickers/src/PickersLayout/PickersLayout.types.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import * as React from 'react';
import { SxProps, Theme } from '@mui/material/styles';
import { SlotComponentProps } from '@mui/base/utils';
import { PickersActionBarProps } from '../PickersActionBar';
import { PickersActionBar, PickersActionBarProps } from '../PickersActionBar';
import { BaseToolbarProps, ExportedBaseToolbarProps } from '../internals/models/props/toolbar';
import { BaseTabsProps, ExportedBaseTabsProps } from '../internals/models/props/tabs';
import { UsePickerLayoutPropsResponseLayoutProps } from '../internals/hooks/usePicker/usePickerLayoutProps';
import { PickersLayoutClasses } from './pickersLayoutClasses';
import { DateOrTimeViewWithMeridiem, WrapperVariant } from '../internals/models/common';
import { PickersShortcutsProps } from '../PickersShortcuts';
import { ExportedPickersShortcutProps } from '../PickersShortcuts/PickersShortcuts';
import {
ExportedPickersShortcutProps,
PickersShortcuts,
} from '../PickersShortcuts/PickersShortcuts';
import { PickerValidDate } from '../models';

export interface ExportedPickersLayoutSlots<
Expand Down Expand Up @@ -56,20 +59,14 @@ export interface ExportedPickersLayoutSlotProps<
* Props passed down to the action bar component.
*/
actionBar?: SlotComponentProps<
React.ComponentType<
Omit<PickersActionBarProps, 'onAccept' | 'onClear' | 'onCancel' | 'onSetToday'>
>,
typeof PickersActionBar,
{},
PickersLayoutActionBarOwnerState<TValue, TDate, TView>
>;
/**
* Props passed down to the shortcuts component.
*/
shortcuts?: SlotComponentProps<
React.ComponentType<PickersShortcutsProps<TValue>>,
{},
PickersShortcutsOwnerState<TValue>
>;
shortcuts?: SlotComponentProps<typeof PickersShortcuts, {}, PickersShortcutsOwnerState<TValue>>;
/**
* Props passed down to the layoutRoot component.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,30 +38,32 @@ const PickersToolbarButtonRoot = styled(Button, {
textTransform: 'none',
});

export const PickersToolbarButton: React.FunctionComponent<PickersToolbarButtonProps> =
React.forwardRef(function PickersToolbarButton(inProps, ref) {
const props = useThemeProps({ props: inProps, name: 'MuiPickersToolbarButton' });
const { align, className, selected, typographyClassName, value, variant, width, ...other } =
props;
export const PickersToolbarButton = React.forwardRef(function PickersToolbarButton(
inProps: PickersToolbarButtonProps,
ref: React.Ref<HTMLButtonElement>,
) {
const props = useThemeProps({ props: inProps, name: 'MuiPickersToolbarButton' });
const { align, className, selected, typographyClassName, value, variant, width, ...other } =
props;

const classes = useUtilityClasses(props);
const classes = useUtilityClasses(props);

return (
<PickersToolbarButtonRoot
data-mui-test="toolbar-button"
variant="text"
ref={ref}
className={clsx(className, classes.root)}
{...(width ? { sx: { width } } : {})}
{...other}
>
<PickersToolbarText
align={align}
className={typographyClassName}
variant={variant}
value={value}
selected={selected}
/>
</PickersToolbarButtonRoot>
);
});
return (
<PickersToolbarButtonRoot
data-mui-test="toolbar-button"
variant="text"
ref={ref}
className={clsx(className, classes.root)}
{...(width ? { sx: { width } } : {})}
{...other}
>
<PickersToolbarText
align={align}
className={typographyClassName}
variant={variant}
value={value}
selected={selected}
/>
</PickersToolbarButtonRoot>
);
});

0 comments on commit 6d92fca

Please sign in to comment.