Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pickers] DRAFT PickersInput Sizing fixes behavior #11403

Closed
wants to merge 94 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
6dd7cdc
[fields] Use the PickersTextField component in the fields
flaviendelangle Dec 6, 2023
60a2958
Work on doc examples
flaviendelangle Dec 6, 2023
55cc0a4
Start preparing the doc
flaviendelangle Dec 6, 2023
977825c
Fix
flaviendelangle Dec 7, 2023
bc180f4
Fix focused
flaviendelangle Dec 7, 2023
b8612dc
Add proper typing && prepare for unstyled PickersInput
flaviendelangle Dec 7, 2023
c14c8ce
Fix
flaviendelangle Dec 7, 2023
fb40443
Fix
flaviendelangle Dec 7, 2023
234939d
Work for green CI
flaviendelangle Dec 7, 2023
3f8ad3c
Fix typing
flaviendelangle Dec 7, 2023
60c9f7a
Regen doc
flaviendelangle Dec 7, 2023
ce9ea47
Work
flaviendelangle Dec 7, 2023
e53aebf
Merge branch 'next' into multi-html-field
flaviendelangle Dec 8, 2023
98b0417
Fix
flaviendelangle Dec 8, 2023
710ef7b
Fix
flaviendelangle Dec 8, 2023
ab34850
Fix
flaviendelangle Dec 8, 2023
5b63ea4
Fix
flaviendelangle Dec 8, 2023
5a4eced
Fix
flaviendelangle Dec 8, 2023
4c67f30
Fix
flaviendelangle Dec 8, 2023
3ba41e8
Fix
flaviendelangle Dec 8, 2023
0e57ea1
Merge branch 'next' into multi-html-field
flaviendelangle Dec 8, 2023
18e7191
[pickers] Create new component PickersInputList
flaviendelangle Dec 8, 2023
2c4606b
Fix
flaviendelangle Dec 8, 2023
8b62b31
Merge
flaviendelangle Dec 8, 2023
dd68ebc
Fix
flaviendelangle Dec 8, 2023
4f2f948
Add root export
flaviendelangle Dec 8, 2023
bb7d87d
Merge
flaviendelangle Dec 8, 2023
0e94973
Fix
flaviendelangle Dec 8, 2023
4454e3f
Fix
flaviendelangle Dec 8, 2023
9745bb0
Fix
flaviendelangle Dec 8, 2023
3612635
Merge branch 'pickers-sections-list' into multi-html-field
flaviendelangle Dec 8, 2023
7ae564f
Rename ref
flaviendelangle Dec 8, 2023
0ebe5ba
Fix
flaviendelangle Dec 8, 2023
8980586
Merge branch 'pickers-sections-list' into multi-html-field
flaviendelangle Dec 8, 2023
de1111c
Fix
flaviendelangle Dec 8, 2023
1729de2
Merge branch 'pickers-sections-list' into multi-html-field
flaviendelangle Dec 8, 2023
fb729a6
Fix
flaviendelangle Dec 8, 2023
d93c54e
Work
flaviendelangle Dec 8, 2023
b13582f
Fix
flaviendelangle Dec 8, 2023
389e9b3
Fix
flaviendelangle Dec 11, 2023
0b4cbad
Merge branch 'next' into multi-html-field
flaviendelangle Dec 11, 2023
9f96bce
Merge branch 'next' into pickers-sections-list
flaviendelangle Dec 11, 2023
2b46235
Merge
flaviendelangle Dec 11, 2023
c2ee055
Merge
flaviendelangle Dec 11, 2023
7dd7c44
Update
flaviendelangle Dec 11, 2023
2de7cb2
[pickers] Simplify the usage of useClearableField
flaviendelangle Dec 11, 2023
db5bcad
Fix
flaviendelangle Dec 11, 2023
13f2176
Migrate multi input range fields
flaviendelangle Dec 11, 2023
6d81bbe
Add migration guide
flaviendelangle Dec 11, 2023
351c7c6
Fix
flaviendelangle Dec 11, 2023
d2e2f4a
Fix
flaviendelangle Dec 11, 2023
3aa1235
Empty
flaviendelangle Dec 11, 2023
c7a897d
Fix
flaviendelangle Dec 11, 2023
53b426a
Fix
flaviendelangle Dec 11, 2023
a8c3952
Merge
flaviendelangle Dec 11, 2023
629f0e8
Merge
flaviendelangle Dec 11, 2023
b7eb51e
Merge
flaviendelangle Dec 12, 2023
dc268bf
Merge branch 'next' into clearable-cleanup
flaviendelangle Dec 12, 2023
6289e28
Code review: Alex
flaviendelangle Dec 12, 2023
abec2ca
Merge with #11371
flaviendelangle Dec 12, 2023
ba080f9
Work
flaviendelangle Dec 12, 2023
d42c0b0
Fix
flaviendelangle Dec 12, 2023
b74ddfd
Merge
flaviendelangle Dec 13, 2023
2ad45fe
Merge
flaviendelangle Dec 13, 2023
1085df0
Fix
flaviendelangle Dec 13, 2023
c8ab28a
Merge
flaviendelangle Dec 13, 2023
397ae62
Merge branch 'next' into pickers-sections-list
flaviendelangle Dec 13, 2023
c4fa9e7
Code review: Lukas
flaviendelangle Dec 13, 2023
853fb68
Work
flaviendelangle Dec 13, 2023
a8d3a6a
Test #11392
flaviendelangle Dec 13, 2023
e31391d
Work
flaviendelangle Dec 13, 2023
edba88e
Work
flaviendelangle Dec 13, 2023
305b9dc
Fix
flaviendelangle Dec 13, 2023
d4d6a7d
Fix
flaviendelangle Dec 13, 2023
9dad392
Doc review: Lukas
flaviendelangle Dec 13, 2023
a5b8dc3
Sync from main PR
flaviendelangle Dec 13, 2023
e493f72
Fix
flaviendelangle Dec 13, 2023
0e3e87a
Fix
flaviendelangle Dec 13, 2023
2d8f574
Work
flaviendelangle Dec 13, 2023
e9aa93f
Work
flaviendelangle Dec 14, 2023
a3820e4
Fix
flaviendelangle Dec 14, 2023
e3a1624
Fix
flaviendelangle Dec 14, 2023
58c6f0a
Fix
flaviendelangle Dec 14, 2023
45809a5
Merge branch 'next' into multi-html-field
flaviendelangle Dec 15, 2023
0dfb6df
Merge
flaviendelangle Dec 15, 2023
2105608
Workg
flaviendelangle Dec 15, 2023
f980095
Fix
flaviendelangle Dec 15, 2023
329433f
Fix
flaviendelangle Dec 15, 2023
f936e9b
Fix
flaviendelangle Dec 15, 2023
3d07fae
Fix
flaviendelangle Dec 15, 2023
d99344e
Fix
flaviendelangle Dec 15, 2023
5fac716
Fix
flaviendelangle Dec 15, 2023
e000e47
Fix
flaviendelangle Dec 15, 2023
d25535e
Sync
flaviendelangle Dec 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/data/date-pickers-component-api-pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export default [
{ pathname: '/x/api/date-pickers/pickers-layout', title: 'PickersLayout' },
{ pathname: '/x/api/date-pickers/pickers-section-list', title: 'PickersSectionList' },
{ pathname: '/x/api/date-pickers/pickers-shortcuts', title: 'PickersShortcuts' },
{ pathname: '/x/api/date-pickers/pickers-text-field', title: 'PickersTextField' },
{
pathname: '/x/api/date-pickers/single-input-date-range-field',
title: 'SingleInputDateRangeField',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const BrowserField = React.forwardRef((props, ref) => {
focused,
ownerState,
sx,
textField,
...other
} = props;

Expand All @@ -41,7 +42,10 @@ const BrowserField = React.forwardRef((props, ref) => {
const BrowserDateField = React.forwardRef((props, ref) => {
const { slots, slotProps, ...textFieldProps } = props;

const fieldResponse = useDateField(textFieldProps);
const fieldResponse = useDateField({
...textFieldProps,
shouldUseV6TextField: true,
});

/* If you don't need a clear button, you can skip the use of this hook */
const processedFieldProps = useClearableField({
Expand All @@ -63,7 +67,7 @@ const BrowserDatePicker = React.forwardRef((props, ref) => {
);
});

export default function PickerWithBrowserField() {
export default function BrowserV6Field() {
return (
<LocalizationProvider dateAdapter={AdapterDayjs}>
<BrowserDatePicker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ interface BrowserFieldProps
focused?: boolean;
ownerState?: any;
sx?: any;
textField: 'v6' | 'v7';
}

type BrowserFieldComponent = ((
Expand All @@ -48,6 +49,7 @@ const BrowserField = React.forwardRef(
focused,
ownerState,
sx,
textField,
...other
} = props;

Expand All @@ -68,19 +70,23 @@ const BrowserField = React.forwardRef(
) as BrowserFieldComponent;

interface BrowserDateFieldProps
extends UseDateFieldProps<Dayjs>,
extends UseDateFieldProps<Dayjs, true>,
BaseSingleInputFieldProps<
Dayjs | null,
Dayjs,
FieldSection,
true,
DateValidationError
> {}

const BrowserDateField = React.forwardRef(
(props: BrowserDateFieldProps, ref: React.Ref<HTMLDivElement>) => {
const { slots, slotProps, ...textFieldProps } = props;

const fieldResponse = useDateField<Dayjs, typeof textFieldProps>(textFieldProps);
const fieldResponse = useDateField<Dayjs, true, typeof textFieldProps>({
...textFieldProps,
shouldUseV6TextField: true,
});

/* If you don't need a clear button, you can skip the use of this hook */
const processedFieldProps = useClearableField({
Expand All @@ -94,9 +100,9 @@ const BrowserDateField = React.forwardRef(
);

const BrowserDatePicker = React.forwardRef(
(props: DatePickerProps<Dayjs>, ref: React.Ref<HTMLDivElement>) => {
(props: DatePickerProps<Dayjs, true>, ref: React.Ref<HTMLDivElement>) => {
return (
<DatePicker
<DatePicker<Dayjs, true>
ref={ref}
{...props}
slots={{ ...props.slots, field: BrowserDateField }}
Expand All @@ -105,7 +111,7 @@ const BrowserDatePicker = React.forwardRef(
},
);

export default function PickerWithBrowserField() {
export default function BrowserV6Field() {
return (
<LocalizationProvider dateAdapter={AdapterDayjs}>
<BrowserDatePicker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const BrowserField = React.forwardRef((props, ref) => {
focused,
ownerState,
sx,
textField,
...other
} = props;

Expand Down Expand Up @@ -57,6 +58,8 @@ const BrowserMultiInputDateRangeField = React.forwardRef((props, ref) => {
selectedSections,
onSelectedSectionsChange,
className,
unstableStartFieldRef,
unstableEndFieldRef,
} = props;

const startTextFieldProps = useSlotProps({
Expand Down Expand Up @@ -87,9 +90,12 @@ const BrowserMultiInputDateRangeField = React.forwardRef((props, ref) => {
disablePast,
selectedSections,
onSelectedSectionsChange,
shouldUseV6TextField: true,
},
startTextFieldProps,
endTextFieldProps,
unstableStartFieldRef,
unstableEndFieldRef,
});

return (
Expand Down Expand Up @@ -117,7 +123,7 @@ const BrowserDateRangePicker = React.forwardRef((props, ref) => {
);
});

export default function RangePickerWithBrowserField() {
export default function BrowserV6MultiInputRangeField() {
return (
<LocalizationProvider dateAdapter={AdapterDayjs}>
<BrowserDateRangePicker />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ interface BrowserFieldProps
focused?: boolean;
ownerState?: any;
sx?: any;
textField: 'v6' | 'v7';
}

type BrowserFieldComponent = ((
Expand All @@ -52,6 +53,7 @@ const BrowserField = React.forwardRef(
focused,
ownerState,
sx,
textField,
...other
} = props;

Expand All @@ -72,11 +74,12 @@ const BrowserField = React.forwardRef(
) as BrowserFieldComponent;

interface BrowserMultiInputDateRangeFieldProps
extends UseDateRangeFieldProps<Dayjs>,
extends UseDateRangeFieldProps<Dayjs, true>,
BaseMultiInputFieldProps<
DateRange<Dayjs>,
Dayjs,
RangeFieldSection,
true,
DateRangeValidationError
> {}

Expand All @@ -103,6 +106,8 @@ const BrowserMultiInputDateRangeField = React.forwardRef(
selectedSections,
onSelectedSectionsChange,
className,
unstableStartFieldRef,
unstableEndFieldRef,
} = props;

const startTextFieldProps = useSlotProps({
Expand All @@ -119,6 +124,7 @@ const BrowserMultiInputDateRangeField = React.forwardRef(

const fieldResponse = useMultiInputDateRangeField<
Dayjs,
true,
MultiInputFieldSlotTextFieldProps
>({
sharedProps: {
Expand All @@ -136,9 +142,12 @@ const BrowserMultiInputDateRangeField = React.forwardRef(
disablePast,
selectedSections,
onSelectedSectionsChange,
shouldUseV6TextField: true,
},
startTextFieldProps,
endTextFieldProps,
unstableStartFieldRef,
unstableEndFieldRef,
});

return (
Expand All @@ -158,7 +167,7 @@ const BrowserMultiInputDateRangeField = React.forwardRef(
) as BrowserMultiInputDateRangeFieldComponent;

const BrowserDateRangePicker = React.forwardRef(
(props: DateRangePickerProps<Dayjs>, ref: React.Ref<HTMLDivElement>) => {
(props: DateRangePickerProps<Dayjs, true>, ref: React.Ref<HTMLDivElement>) => {
return (
<DateRangePicker
ref={ref}
Expand All @@ -169,7 +178,7 @@ const BrowserDateRangePicker = React.forwardRef(
},
);

export default function RangePickerWithBrowserField() {
export default function BrowserV6MultiInputRangeField() {
return (
<LocalizationProvider dateAdapter={AdapterDayjs}>
<BrowserDateRangePicker />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const BrowserField = React.forwardRef((props, ref) => {
focused,
ownerState,
sx,
textField,
...other
} = props;

Expand Down Expand Up @@ -63,7 +64,10 @@ const BrowserSingleInputDateRangeField = React.forwardRef((props, ref) => {
),
};

const fieldResponse = useSingleInputDateRangeField(textFieldProps);
const fieldResponse = useSingleInputDateRangeField({
...textFieldProps,
shouldUseV6TextField: true,
});

/* If you don't need a clear button, you can skip the use of this hook */
const processedFieldProps = useClearableField({
Expand Down Expand Up @@ -113,7 +117,7 @@ const BrowserSingleInputDateRangePicker = React.forwardRef((props, ref) => {
);
});

export default function RangePickerWithSingleInputBrowserField() {
export default function BrowserV6SingleInputRangeField() {
return (
<LocalizationProvider dateAdapter={AdapterDayjs}>
<BrowserSingleInputDateRangePicker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,15 @@ import {
import {
unstable_useSingleInputDateRangeField as useSingleInputDateRangeField,
SingleInputDateRangeFieldProps,
UseSingleInputDateRangeFieldProps,
} from '@mui/x-date-pickers-pro/SingleInputDateRangeField';
import { useClearableField } from '@mui/x-date-pickers/hooks';
import { BaseSingleInputFieldProps } from '@mui/x-date-pickers/models';
import {
DateRangeValidationError,
RangeFieldSection,
} from '@mui/x-date-pickers-pro/models';
import { DateRange } from '@mui/x-date-pickers-pro';

interface BrowserFieldProps
extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size'> {
Expand All @@ -31,6 +38,7 @@ interface BrowserFieldProps
focused?: boolean;
ownerState?: any;
sx?: any;
textField: 'v6' | 'v7';
}

type BrowserFieldComponent = ((
Expand All @@ -50,6 +58,7 @@ const BrowserField = React.forwardRef(
focused,
ownerState,
sx,
textField,
...other
} = props;

Expand All @@ -70,10 +79,14 @@ const BrowserField = React.forwardRef(
) as BrowserFieldComponent;

interface BrowserSingleInputDateRangeFieldProps
extends SingleInputDateRangeFieldProps<
Dayjs,
Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size'>
> {
extends UseSingleInputDateRangeFieldProps<Dayjs, true>,
BaseSingleInputFieldProps<
DateRange<Dayjs>,
Dayjs,
RangeFieldSection,
true,
DateRangeValidationError
> {
onAdornmentClick?: () => void;
}

Expand All @@ -85,12 +98,14 @@ const BrowserSingleInputDateRangeField = React.forwardRef(
(props: BrowserSingleInputDateRangeFieldProps, ref: React.Ref<HTMLDivElement>) => {
const { slots, slotProps, onAdornmentClick, ...other } = props;

const textFieldProps: SingleInputDateRangeFieldProps<Dayjs> = useSlotProps({
elementType: 'input',
externalSlotProps: slotProps?.textField,
externalForwardedProps: other,
ownerState: props as any,
});
const textFieldProps: SingleInputDateRangeFieldProps<Dayjs, true> = useSlotProps(
{
elementType: 'input',
externalSlotProps: slotProps?.textField,
externalForwardedProps: other,
ownerState: props as any,
},
);

textFieldProps.InputProps = {
...textFieldProps.InputProps,
Expand All @@ -103,9 +118,11 @@ const BrowserSingleInputDateRangeField = React.forwardRef(
),
};

const fieldResponse = useSingleInputDateRangeField<Dayjs, typeof textFieldProps>(
textFieldProps,
);
const fieldResponse = useSingleInputDateRangeField<
Dayjs,
true,
typeof textFieldProps
>({ ...textFieldProps, shouldUseV6TextField: true });

/* If you don't need a clear button, you can skip the use of this hook */
const processedFieldProps = useClearableField({
Expand Down Expand Up @@ -158,7 +175,7 @@ const BrowserSingleInputDateRangePicker = React.forwardRef(
},
);

export default function RangePickerWithSingleInputBrowserField() {
export default function BrowserV6SingleInputRangeField() {
return (
<LocalizationProvider dateAdapter={AdapterDayjs}>
<BrowserSingleInputDateRangePicker
Expand Down
Loading