-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
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
[SelectUnstyled] Improve exported types #30895
Changes from 4 commits
c24b386
589b32f
c5fe360
fe12fce
5bb87f3
914de68
9ff6496
c0bde88
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import * as React from 'react'; | ||
import { SelectUnstyled } from '@mui/base'; | ||
|
||
const SelectUnstyledComponentsPropsOverridesTest = ( | ||
<SelectUnstyled | ||
componentsProps={{ | ||
root: { | ||
// @ts-expect-error - requires module augmentation | ||
size: 'red', | ||
className: 'test', | ||
}, | ||
popper: { | ||
className: 'popper', | ||
disablePortal: true, | ||
}, | ||
listbox: { | ||
className: 'listbox', | ||
onMouseOver: () => {}, | ||
}, | ||
}} | ||
/> | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ export interface SelectUnstyledCommonProps { | |
componentsProps?: { | ||
root?: React.ComponentPropsWithRef<'button'> & SelectUnstyledComponentsPropsOverrides; | ||
listbox?: React.ComponentPropsWithRef<'ul'> & SelectUnstyledComponentsPropsOverrides; | ||
popper?: React.ComponentPropsWithRef<typeof PopperUnstyled> & | ||
popper?: Partial<React.ComponentPropsWithRef<typeof PopperUnstyled>> & | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Popper requires an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alright, could we leave an comment for it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, it's done! |
||
SelectUnstyledComponentsPropsOverrides; | ||
}; | ||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import * as React from 'react'; | ||
import { SelectUnstyled } from '@mui/base'; | ||
|
||
declare module '@mui/base' { | ||
interface SelectUnstyledComponentsPropsOverrides { | ||
variant?: 'one' | 'two'; | ||
} | ||
} | ||
|
||
<SelectUnstyled componentsProps={{ root: { variant: 'one' } }} />; | ||
|
||
// @ts-expect-error unknown variant | ||
<SelectUnstyled componentsProps={{ root: { variant: 'three' } }} />; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"extends": "../../../../../tsconfig", | ||
"files": ["selectUnstyledComponentsProps.spec.tsx"] | ||
} |
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.
Do we have test for the module augmentation?
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.
Now we do 😊
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.
Awesomeness :D