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

[docs] Strictly type the props a picker passes to its field, and migrate all the custom field demos accordingly

Open flaviendelangle opened this issue 1 year ago • 2 comments

Extracted from #15194

I wasn't able to split this one in smaller pieces because updating the demos without updating the package results in TS issues and vice-versa :cry: . I tried to be as detailed as possible in my comments / description to help the review.

  • Stop using BaseSingleInputFieldProps and BaseMultiInputFieldProps to type slotProps.field (the JSDoc said to not use it for this purpose even before this PR :grimacing: ) and stop exporting them (they are now only used to create interfaces like DatePickerFieldProps).
  • Improve BaseSingleInputFieldProps and BaseMultiInputFieldProps to accurately match what the picker are passing, which one are nullable and which one have a default value applied.
  • Create PickersFieldSlotProps and PickersRangeFieldSlotProps interfaces to describe what slotProps.field can receive. Those props are very limited for now to only contain stuff people should actually pass (I did not add any props that are forwarded by the picker, like format to avoid having several way to achieve the same outcome. If you have some props that you think are missing please let me know).
  • Use the ValidateXXXProps interfaces in the interfaces like DatePickerFieldProps instead of UseDateFieldProps (this makes DatePickerFieldProps a lot more accurate, without props like defaultValue that are never defined).
  • Clean the props passed by the picker to the field (in the useSlotProps of the useXXXPicker hooks) to accurately match what the new typing expects.
  • Update all the demos in the custom-field page to match the new typing (I did a comment per demo to describe the changes, for the Joy UI I didn't try to migrate more than what was necessary since they are going away in the future).

flaviendelangle avatar Oct 30 '24 16:10 flaviendelangle

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

Updated pages:

Generated by :no_entry_sign: dangerJS against e040f2eee6468eed0bfa318f6f0e1bc2cc08ea70

mui-bot avatar Oct 30 '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]

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

github-actions[bot] avatar Nov 06 '24 16:11 github-actions[bot]

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

github-actions[bot] avatar Nov 07 '24 13:11 github-actions[bot]

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

github-actions[bot] avatar Nov 12 '24 09:11 github-actions[bot]

P.S. WDYT about changing the PR title prefix to [pickers]? It's slightly change to deliver a BC within a [docs] PR. 🙈 😆

You are entirely right :grimacing: The BC was not planned and I did not update the title since :laughing:

flaviendelangle avatar Nov 13 '24 15:11 flaviendelangle