[docs] Strictly type the props a picker passes to its field, and migrate all the custom field demos accordingly
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
BaseSingleInputFieldPropsandBaseMultiInputFieldPropsto typeslotProps.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 likeDatePickerFieldProps). - Improve
BaseSingleInputFieldPropsandBaseMultiInputFieldPropsto accurately match what the picker are passing, which one are nullable and which one have a default value applied. - Create
PickersFieldSlotPropsandPickersRangeFieldSlotPropsinterfaces to describe whatslotProps.fieldcan 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, likeformatto 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
ValidateXXXPropsinterfaces in the interfaces likeDatePickerFieldPropsinstead ofUseDateFieldProps(this makesDatePickerFieldPropsa lot more accurate, without props likedefaultValuethat are never defined). - Clean the props passed by the picker to the field (in the
useSlotPropsof theuseXXXPickerhooks) to accurately match what the new typing expects. - Update all the demos in the
custom-fieldpage 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).
Deploy preview: https://deploy-preview-15197--material-ui-x.netlify.app/
Updated pages:
- docs/data/date-pickers/custom-field/custom-field.md
- docs/data/migration/migration-pickers-v7/migration-pickers-v7.md
Generated by :no_entry_sign: dangerJS against e040f2eee6468eed0bfa318f6f0e1bc2cc08ea70
This pull request has conflicts, please resolve those before we can evaluate the pull request.
This pull request has conflicts, please resolve those before we can evaluate the pull request.
This pull request has conflicts, please resolve those before we can evaluate the pull request.
This pull request has conflicts, please resolve those before we can evaluate the pull request.
This pull request has conflicts, please resolve those before we can evaluate the pull request.
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: