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] Use the new ownerState in DateCalendar, DateRangeCalendar, MonthCalendar and YearCalendar #15171

Merged
merged 9 commits into from
Nov 6, 2024

Conversation

flaviendelangle
Copy link
Member

@flaviendelangle flaviendelangle commented Oct 29, 2024

Part of #14475
Another day, another PR for the ownerState 😆 , 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 flaviendelangle marked this pull request as draft October 29, 2024 16:45
@flaviendelangle flaviendelangle self-assigned this Oct 29, 2024
@flaviendelangle flaviendelangle added breaking change component: pickers This is the name of the generic UI component, not the React module! labels Oct 29, 2024
@mui-bot
Copy link

mui-bot commented Oct 29, 2024

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

Generated by 🚫 dangerJS against 3226863

@flaviendelangle flaviendelangle force-pushed the ownerState-date-views branch 3 times, most recently from 0e6270e to 6f9cf51 Compare October 29, 2024 17:07
@flaviendelangle flaviendelangle marked this pull request as ready for review October 29, 2024 17:11
@flaviendelangle flaviendelangle marked this pull request as draft October 29, 2024 17:36
@flaviendelangle flaviendelangle marked this pull request as ready for review October 30, 2024 09:25
Copy link

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

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 31, 2024
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 31, 2024
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Nov 5, 2024
Copy link

github-actions bot commented Nov 5, 2024

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

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Nov 5, 2024
Copy link
Member

@LukasTy LukasTy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work. 👍 🎉

packages/x-date-pickers/src/DateCalendar/index.ts Outdated Show resolved Hide resolved
@flaviendelangle flaviendelangle merged commit 66fa221 into mui:master Nov 6, 2024
16 checks passed
@flaviendelangle flaviendelangle deleted the ownerState-date-views branch November 6, 2024 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change component: pickers This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants