-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
[SwitchUnstyled] Define ownerState and slot props' types #32573
Conversation
818ec67
to
e31af1c
Compare
packages/mui-joy/src/Radio/Radio.tsx
Outdated
PropTypes.oneOf(['danger', 'info', 'primary', 'success', 'warning']), | ||
PropTypes.string, | ||
]), | ||
color: PropTypes.oneOf(['danger', 'info', 'neutral', 'primary', 'success', 'warning']), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should revert these no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, thanks!
BTW, the generated proptypes include neutral
, which does not exist in the hardcoded ones (it's a similar case in `variant'). Shouldn't the hardcoded ones be updated? (cc @siriwatknp)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch, I guess it should be added indeed. @siriwatknp in case if you missed the prev notification :)
PropTypes.oneOf(['danger', 'info', 'primary', 'success', 'warning']), | ||
PropTypes.string, | ||
]), | ||
color: PropTypes.oneOf(['danger', 'info', 'neutral', 'primary', 'success', 'warning']), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These too.
onFocus: (event: React.FocusEvent) => handleFocus(event, otherProps.onFocus), | ||
onBlur: (event: React.FocusEvent) => handleBlur(event, otherProps.onBlur), | ||
ref: handleRefChange, | ||
onChange: createHandleInputChange(otherProps), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much more readable 👍
required?: boolean; | ||
} | ||
|
||
interface UseSwitchInputSlotOwnProps { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we extend here UseSwitchParameters
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The optionality of parameters differs. Plus, the UseSwitchParameters has onFocusVisible
, which is not a valid HTML parameter. I could Pick, Omit, etc. but it would be less readable than specifying the interface explicitly IMO.
|
||
describe('useSwitch', () => { | ||
const { render } = createRenderer(); | ||
const invokeUseSwitch = (props: UseSwitchProps): UseSwitchResult => { | ||
const ref = React.createRef<UseSwitchResult>(); | ||
const invokeUseSwitch = (props: UseSwitchParameters) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's mark this as breaking change so that we can add it in the changelog for people to be aware of.
Defined types for SwitchUnstyled's ownerState, its slots and useSwitch return type.
Also renamed types and files according to #31415