mui-x icon indicating copy to clipboard operation
mui-x copied to clipboard

[pickers] Use the new `ownerState` in `DateCalendar`, `DateRangeCalendar`, `MonthCalendar` and `YearCalendar`

Open flaviendelangle opened this issue 1 year ago • 2 comments

Part of #14475 Another day, another PR for the ownerState :laughing: , now that we have the context it's easy to migrate the slots piece by piece.

I did not change the ownerState passed to the styleOverrides of PickersDay and its range counterpart because I want @noraleonte DX proposal before. But IMHO this ownerState should eventually be 100% identical to the one passed to slots.day.

Changes

Changes on usePickersPrivateContext

  • Does not crash when used outside of a picker (instead we have a default ownerState object with everything marked as false. Alternatively I could update the ownerState in the views to be PickerOwnerState | {} or Partial<PickerOwnerState> but I think the default value is easier to work with.

Updated slots

I only added the selected and disabled properties to the day, month and year ownerState because they are often needed to build our classes and I think it's nice being consistent between the three.

I can add month and year objets to match day if you think it's useful. day is used in DateRangeCalendar so I need to have it.

  • day: PickerOwnerState & { day: TDate, isDaySelected: boolean, isDayDisabled: boolean }
  • monthButton: PickerOwnerState & { isMonthSelected: boolean, isMonthDisabled: boolean }
  • yearButton: PickerOwnerState & { isYearSelected: boolean, isYearDisabled: boolean }
  • calendarHeader: PickerOwnerState

flaviendelangle avatar Oct 29 '24 16:10 flaviendelangle

Deploy preview: https://deploy-preview-15171--material-ui-x.netlify.app/

Generated by :no_entry_sign: dangerJS against 322686338d0b086035b2d984391e947bccc25833

mui-bot avatar Oct 29 '24 16:10 mui-bot

This pull request has conflicts, please resolve those before we can evaluate the pull request.

github-actions[bot] avatar Oct 31 '24 14:10 github-actions[bot]

This pull request has conflicts, please resolve those before we can evaluate the pull request.

github-actions[bot] avatar Nov 05 '24 14:11 github-actions[bot]