Skip to content

Commit

Permalink
Fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
flaviendelangle committed Sep 13, 2024
1 parent b79b5f4 commit c7a1032
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const DesktopDatePicker = React.forwardRef(function DesktopDatePicker<
slotProps: {
...defaultizedProps.slotProps,
field: (ownerState: any) => ({
...resolveComponentProps(defaultizedProps.slotProps?.field, ownerState),
...(resolveComponentProps(defaultizedProps.slotProps?.field, ownerState) as any),
...extractValidationProps(defaultizedProps),
ref,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ const DesktopDateTimePicker = React.forwardRef(function DesktopDateTimePicker<
slotProps: {
...defaultizedProps.slotProps,
field: (ownerState: any) => ({
...resolveComponentProps(defaultizedProps.slotProps?.field, ownerState),
...(resolveComponentProps(defaultizedProps.slotProps?.field, ownerState) as any),
...extractValidationProps(defaultizedProps),
ref,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const DesktopTimePicker = React.forwardRef(function DesktopTimePicker<
slotProps: {
...defaultizedProps.slotProps,
field: (ownerState: any) => ({
...resolveComponentProps(defaultizedProps.slotProps?.field, ownerState),
...(resolveComponentProps(defaultizedProps.slotProps?.field, ownerState) as any),
...extractValidationProps(defaultizedProps),
ref,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const MobileDatePicker = React.forwardRef(function MobileDatePicker<
slotProps: {
...defaultizedProps.slotProps,
field: (ownerState: any) => ({
...resolveComponentProps(defaultizedProps.slotProps?.field, ownerState),
...(resolveComponentProps(defaultizedProps.slotProps?.field, ownerState) as any),
...extractValidationProps(defaultizedProps),
ref,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const MobileDateTimePicker = React.forwardRef(function MobileDateTimePicker<
slotProps: {
...defaultizedProps.slotProps,
field: (ownerState: any) => ({
...resolveComponentProps(defaultizedProps.slotProps?.field, ownerState),
...(resolveComponentProps(defaultizedProps.slotProps?.field, ownerState) as any),
...extractValidationProps(defaultizedProps),
ref,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const MobileTimePicker = React.forwardRef(function MobileTimePicker<
slotProps: {
...defaultizedProps.slotProps,
field: (ownerState: any) => ({
...resolveComponentProps(defaultizedProps.slotProps?.field, ownerState),
...(resolveComponentProps(defaultizedProps.slotProps?.field, ownerState) as any),
...extractValidationProps(defaultizedProps),
ref,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import {
} from '../../models/props/basePickerProps';
import { PickersPopperSlots, PickersPopperSlotProps } from '../../components/PickersPopper';
import { UsePickerParams, UsePickerProps } from '../usePicker';
import { BaseSingleInputFieldProps, FieldSection, PickerValidDate } from '../../../models';
import {
BaseSingleInputFieldPropsInPickerSlots,
FieldSection,
PickerValidDate,
} from '../../../models';
import {
ExportedPickersLayoutSlots,
ExportedPickersLayoutSlotProps,
Expand Down Expand Up @@ -78,7 +82,7 @@ export interface ExportedUseDesktopPickerSlotProps<
ExportedPickersLayoutSlotProps<TDate | null, TDate, TView>,
UseClearableFieldSlotProps {
field?: SlotComponentPropsFromProps<
BaseSingleInputFieldProps<
BaseSingleInputFieldPropsInPickerSlots<
TDate | null,
TDate,
FieldSection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export const useMobilePicker = <
timezone,
label,
name,
onOpen: actions.onOpen,
...(inputRef ? { inputRef } : {}),
},
ownerState: props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ import {
PickersModalDialogSlotProps,
} from '../../components/PickersModalDialog';
import { UsePickerParams, UsePickerProps } from '../usePicker';
import { BaseSingleInputFieldProps, FieldSection, PickerValidDate } from '../../../models';
import {
BaseSingleInputFieldPropsInPickerSlots,
FieldSection,
PickerValidDate,
} from '../../../models';
import {
ExportedPickersLayoutSlots,
ExportedPickersLayoutSlotProps,
Expand Down Expand Up @@ -45,7 +49,7 @@ export interface ExportedUseMobilePickerSlotProps<
> extends PickersModalDialogSlotProps,
ExportedPickersLayoutSlotProps<TDate | null, TDate, TView> {
field?: SlotComponentPropsFromProps<
BaseSingleInputFieldProps<
BaseSingleInputFieldPropsInPickerSlots<
TDate | null,
TDate,
FieldSection,
Expand Down
11 changes: 11 additions & 0 deletions packages/x-date-pickers/src/models/fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,17 @@ export type BaseSingleInputFieldProps<
> = BaseFieldProps<TValue, TDate, TSection, TEnableAccessibleFieldDOMStructure, TError> &
BaseForwardedSingleInputFieldProps<TEnableAccessibleFieldDOMStructure>;

export type BaseSingleInputFieldPropsInPickerSlots<
TValue,
TDate extends PickerValidDate,
TSection extends FieldSection,
TEnableAccessibleFieldDOMStructure extends boolean,
TError,
> = Omit<
BaseSingleInputFieldProps<TValue, TDate, TSection, TEnableAccessibleFieldDOMStructure, TError>,
'onOpen'
>;

/**
* Props the text field receives when used with a single input picker.
* Only contains what the MUI components are passing to the text field, not what users can pass using the `props.slotProps.field` and `props.slotProps.textField`.
Expand Down

0 comments on commit c7a1032

Please sign in to comment.