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] Remove the defaultCalendarMonth prop #10987

Merged
merged 17 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
14 changes: 13 additions & 1 deletion docs/data/migration/migration-pickers-v6/migration-pickers-v6.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ In `package.json`, change the version of the date pickers package to `next`.
+"@mui/x-date-pickers": "next",
```

## Breaking changes
## All components

Since `v7` is a major release, it contains changes that affect the public API.
These changes were done for consistency, improved stability and to make room for new features.
Expand Down Expand Up @@ -63,3 +63,15 @@ For example:

The same applies to `slotProps` and `componentsProps`.
:::

### Replace `defaultCalendarMonth` with `referenceDate`

The `defaultCalendarMonth` has been removed in favor of the more flexible `referenceDate` prop.
flaviendelangle marked this conversation as resolved.
Show resolved Hide resolved
It was available in `DateCalendar` and all the pickers using it for date editing.
flaviendelangle marked this conversation as resolved.
Show resolved Hide resolved

The new `referenceDate` prop is not limited to the default month, learn more on this prop on [the `DateCalendar` doc](/x/react-date-pickers/date-calendar/#choose-the-initial-year-month) or [the `referenceDate` doc](/x/react-date-pickers/base-concepts/#reference-date-when-no-value-is-defined).
flaviendelangle marked this conversation as resolved.
Show resolved Hide resolved

```diff
- <DateCalendar defaultCalendarMonth={dayjs('2022-04-01')};
+ <DateCalendar referenceDate{dayjs('2022-04-01')} />
```
1 change: 0 additions & 1 deletion docs/pages/x/api/date-pickers/date-calendar.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"returned": "string"
}
},
"defaultCalendarMonth": { "type": { "name": "any" } },
"defaultValue": { "type": { "name": "any" } },
"disabled": { "type": { "name": "bool" } },
"disableFuture": { "type": { "name": "bool" } },
Expand Down
1 change: 0 additions & 1 deletion docs/pages/x/api/date-pickers/date-picker.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"returned": "string"
}
},
"defaultCalendarMonth": { "type": { "name": "any" } },
"defaultValue": { "type": { "name": "any" } },
"desktopModeMediaQuery": {
"type": { "name": "string" },
Expand Down
1 change: 0 additions & 1 deletion docs/pages/x/api/date-pickers/date-range-calendar.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"returned": "string"
}
},
"defaultCalendarMonth": { "type": { "name": "any" } },
"defaultRangePosition": {
"type": { "name": "enum", "description": "'end'<br>&#124;&nbsp;'start'" },
"default": "'start'"
Expand Down
1 change: 0 additions & 1 deletion docs/pages/x/api/date-pickers/date-range-picker.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"returned": "string"
}
},
"defaultCalendarMonth": { "type": { "name": "any" } },
"defaultRangePosition": {
"type": { "name": "enum", "description": "'end'<br>&#124;&nbsp;'start'" },
"default": "'start'"
Expand Down
1 change: 0 additions & 1 deletion docs/pages/x/api/date-pickers/date-time-picker.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"returned": "string"
}
},
"defaultCalendarMonth": { "type": { "name": "any" } },
"defaultValue": { "type": { "name": "any" } },
"desktopModeMediaQuery": {
"type": { "name": "string" },
Expand Down
1 change: 0 additions & 1 deletion docs/pages/x/api/date-pickers/desktop-date-picker.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"returned": "string"
}
},
"defaultCalendarMonth": { "type": { "name": "any" } },
"defaultValue": { "type": { "name": "any" } },
"disabled": { "type": { "name": "bool" } },
"disableFuture": { "type": { "name": "bool" } },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"returned": "string"
}
},
"defaultCalendarMonth": { "type": { "name": "any" } },
"defaultRangePosition": {
"type": { "name": "enum", "description": "'end'<br>&#124;&nbsp;'start'" },
"default": "'start'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"returned": "string"
}
},
"defaultCalendarMonth": { "type": { "name": "any" } },
"defaultValue": { "type": { "name": "any" } },
"disabled": { "type": { "name": "bool" } },
"disableFuture": { "type": { "name": "bool" } },
Expand Down
1 change: 0 additions & 1 deletion docs/pages/x/api/date-pickers/mobile-date-picker.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"returned": "string"
}
},
"defaultCalendarMonth": { "type": { "name": "any" } },
"defaultValue": { "type": { "name": "any" } },
"disabled": { "type": { "name": "bool" } },
"disableFuture": { "type": { "name": "bool" } },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"returned": "string"
}
},
"defaultCalendarMonth": { "type": { "name": "any" } },
"defaultRangePosition": {
"type": { "name": "enum", "description": "'end'<br>&#124;&nbsp;'start'" },
"default": "'start'"
Expand Down
1 change: 0 additions & 1 deletion docs/pages/x/api/date-pickers/mobile-date-time-picker.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"returned": "string"
}
},
"defaultCalendarMonth": { "type": { "name": "any" } },
"defaultValue": { "type": { "name": "any" } },
"disabled": { "type": { "name": "bool" } },
"disableFuture": { "type": { "name": "bool" } },
Expand Down
1 change: 0 additions & 1 deletion docs/pages/x/api/date-pickers/static-date-picker.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"returned": "string"
}
},
"defaultCalendarMonth": { "type": { "name": "any" } },
"defaultValue": { "type": { "name": "any" } },
"disabled": { "type": { "name": "bool" } },
"disableFuture": { "type": { "name": "bool" } },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"returned": "string"
}
},
"defaultCalendarMonth": { "type": { "name": "any" } },
"defaultRangePosition": {
"type": { "name": "enum", "description": "'end'<br>&#124;&nbsp;'start'" },
"default": "'start'"
Expand Down
1 change: 0 additions & 1 deletion docs/pages/x/api/date-pickers/static-date-time-picker.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"returned": "string"
}
},
"defaultCalendarMonth": { "type": { "name": "any" } },
"defaultValue": { "type": { "name": "any" } },
"disabled": { "type": { "name": "bool" } },
"disableFuture": { "type": { "name": "bool" } },
Expand Down
5 changes: 0 additions & 5 deletions docs/translations/api-docs/date-pickers/date-calendar.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@
"string": "The name to display."
}
},
"defaultCalendarMonth": {
"description": "Default calendar month displayed when <code>value</code> and <code>defaultValue</code> are empty.",
"deprecated": "",
"typeDescriptions": {}
},
"defaultValue": {
"description": "The default selected value. Used when the component is not controlled.",
"deprecated": "",
Expand Down
5 changes: 0 additions & 5 deletions docs/translations/api-docs/date-pickers/date-picker.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@
"string": "The name to display."
}
},
"defaultCalendarMonth": {
"description": "Default calendar month displayed when <code>value</code> and <code>defaultValue</code> are empty.",
"deprecated": "",
"typeDescriptions": {}
},
"defaultValue": {
"description": "The default value. Used when the component is not controlled.",
"deprecated": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@
"string": "The name to display."
}
},
"defaultCalendarMonth": {
"description": "Default calendar month displayed when <code>value={[null, null]}</code>.",
"deprecated": "",
"typeDescriptions": {}
},
"defaultRangePosition": {
"description": "The initial position in the edited date range. Used when the component is not controlled.",
"deprecated": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@
"string": "The name to display."
}
},
"defaultCalendarMonth": {
"description": "Default calendar month displayed when <code>value={[null, null]}</code>.",
"deprecated": "",
"typeDescriptions": {}
},
"defaultRangePosition": {
"description": "The initial position in the edited date range. Used when the component is not controlled.",
"deprecated": "",
Expand Down
5 changes: 0 additions & 5 deletions docs/translations/api-docs/date-pickers/date-time-picker.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@
"string": "The name to display."
}
},
"defaultCalendarMonth": {
"description": "Default calendar month displayed when <code>value</code> and <code>defaultValue</code> are empty.",
"deprecated": "",
"typeDescriptions": {}
},
"defaultValue": {
"description": "The default value. Used when the component is not controlled.",
"deprecated": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@
"string": "The name to display."
}
},
"defaultCalendarMonth": {
"description": "Default calendar month displayed when <code>value</code> and <code>defaultValue</code> are empty.",
"deprecated": "",
"typeDescriptions": {}
},
"defaultValue": {
"description": "The default value. Used when the component is not controlled.",
"deprecated": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@
"string": "The name to display."
}
},
"defaultCalendarMonth": {
"description": "Default calendar month displayed when <code>value={[null, null]}</code>.",
"deprecated": "",
"typeDescriptions": {}
},
"defaultRangePosition": {
"description": "The initial position in the edited date range. Used when the component is not controlled.",
"deprecated": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@
"string": "The name to display."
}
},
"defaultCalendarMonth": {
"description": "Default calendar month displayed when <code>value</code> and <code>defaultValue</code> are empty.",
"deprecated": "",
"typeDescriptions": {}
},
"defaultValue": {
"description": "The default value. Used when the component is not controlled.",
"deprecated": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@
"string": "The name to display."
}
},
"defaultCalendarMonth": {
"description": "Default calendar month displayed when <code>value</code> and <code>defaultValue</code> are empty.",
"deprecated": "",
"typeDescriptions": {}
},
"defaultValue": {
"description": "The default value. Used when the component is not controlled.",
"deprecated": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@
"string": "The name to display."
}
},
"defaultCalendarMonth": {
"description": "Default calendar month displayed when <code>value={[null, null]}</code>.",
"deprecated": "",
"typeDescriptions": {}
},
"defaultRangePosition": {
"description": "The initial position in the edited date range. Used when the component is not controlled.",
"deprecated": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@
"string": "The name to display."
}
},
"defaultCalendarMonth": {
"description": "Default calendar month displayed when <code>value</code> and <code>defaultValue</code> are empty.",
"deprecated": "",
"typeDescriptions": {}
},
"defaultValue": {
"description": "The default value. Used when the component is not controlled.",
"deprecated": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@
"string": "The name to display."
}
},
"defaultCalendarMonth": {
"description": "Default calendar month displayed when <code>value</code> and <code>defaultValue</code> are empty.",
"deprecated": "",
"typeDescriptions": {}
},
"defaultValue": {
"description": "The default value. Used when the component is not controlled.",
"deprecated": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@
"string": "The name to display."
}
},
"defaultCalendarMonth": {
"description": "Default calendar month displayed when <code>value={[null, null]}</code>.",
"deprecated": "",
"typeDescriptions": {}
},
"defaultRangePosition": {
"description": "The initial position in the edited date range. Used when the component is not controlled.",
"deprecated": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@
"string": "The name to display."
}
},
"defaultCalendarMonth": {
"description": "Default calendar month displayed when <code>value</code> and <code>defaultValue</code> are empty.",
"deprecated": "",
"typeDescriptions": {}
},
"defaultValue": {
"description": "The default value. Used when the component is not controlled.",
"deprecated": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ describe('<DateRangeCalendar />', () => {
render(
<DateRangeCalendar
onChange={onChange}
defaultCalendarMonth={adapterToUse.date(new Date(2019, 0, 1))}
referenceDate={adapterToUse.date(new Date(2019, 0, 1))}
/>,
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ const DateRangeCalendar = React.forwardRef(function DateRangeCalendar<TDate>(
shouldDisableDate,
reduceAnimations,
onMonthChange,
defaultCalendarMonth,
rangePosition: rangePositionProp,
defaultRangePosition: inDefaultRangePosition,
onRangePositionChange: inOnRangePositionChange,
Expand Down Expand Up @@ -317,7 +316,6 @@ const DateRangeCalendar = React.forwardRef(function DateRangeCalendar<TDate>(
} = useCalendarState<TDate>({
value: value[0] || value[1],
referenceDate,
defaultCalendarMonth,
disableFuture,
disablePast,
disableSwitchToMonthOnDayFocus: true,
Expand Down Expand Up @@ -625,10 +623,6 @@ DateRangeCalendar.propTypes = {
* @default (_day: string, date: TDate) => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase()
*/
dayOfWeekFormatter: PropTypes.func,
/**
* Default calendar month displayed when `value={[null, null]}`.
*/
defaultCalendarMonth: PropTypes.any,
/**
* The initial position in the edited date range.
* Used when the component is not controlled.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ export interface ExportedDateRangeCalendarProps<TDate>
* @default false
*/
disableAutoMonthSwitching?: boolean;
/**
* Default calendar month displayed when `value={[null, null]}`.
*/
defaultCalendarMonth?: TDate;
/**
* If `true`, the picker and text field are disabled.
* @default false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ DateRangePicker.propTypes = {
* @default (_day: string, date: TDate) => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase()
*/
dayOfWeekFormatter: PropTypes.func,
/**
* Default calendar month displayed when `value={[null, null]}`.
*/
defaultCalendarMonth: PropTypes.any,
/**
* The initial position in the edited date range.
* Used when the component is not controlled.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,6 @@ DesktopDateRangePicker.propTypes = {
* @default (_day: string, date: TDate) => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase()
*/
dayOfWeekFormatter: PropTypes.func,
/**
* Default calendar month displayed when `value={[null, null]}`.
*/
defaultCalendarMonth: PropTypes.any,
/**
* The initial position in the edited date range.
* Used when the component is not controlled.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,6 @@ MobileDateRangePicker.propTypes = {
* @default (_day: string, date: TDate) => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase()
*/
dayOfWeekFormatter: PropTypes.func,
/**
* Default calendar month displayed when `value={[null, null]}`.
*/
defaultCalendarMonth: PropTypes.any,
/**
* The initial position in the edited date range.
* Used when the component is not controlled.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,6 @@ StaticDateRangePicker.propTypes = {
* @default (_day: string, date: TDate) => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase()
*/
dayOfWeekFormatter: PropTypes.func,
/**
* Default calendar month displayed when `value={[null, null]}`.
*/
defaultCalendarMonth: PropTypes.any,
/**
* The initial position in the edited date range.
* Used when the component is not controlled.
Expand Down
Loading