-
-
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
[OptionUnstyled] Define ownerState and slot props' types #32717
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
packages/mui-base/src/OptionGroupUnstyled/OptionGroupUnstyled.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import * as React from 'react'; | ||
import OptionGroupUnstyled, { | ||
OptionGroupUnstyledLabelSlotProps, | ||
OptionGroupUnstyledListSlotProps, | ||
OptionGroupUnstyledRootSlotProps, | ||
} from '@mui/base/OptionGroupUnstyled'; | ||
|
||
const Root = React.forwardRef(function Root( | ||
props: OptionGroupUnstyledRootSlotProps, | ||
ref: React.ForwardedRef<HTMLLIElement>, | ||
) { | ||
return <li {...props} ref={ref} />; | ||
}); | ||
|
||
const Label = React.forwardRef(function Label( | ||
props: OptionGroupUnstyledLabelSlotProps, | ||
ref: React.ForwardedRef<HTMLLIElement>, | ||
) { | ||
return <li {...props} ref={ref} />; | ||
}); | ||
|
||
const List = React.forwardRef(function List( | ||
props: OptionGroupUnstyledListSlotProps, | ||
ref: React.ForwardedRef<HTMLLIElement>, | ||
) { | ||
return <li {...props} ref={ref} />; | ||
}); | ||
|
||
const option = <OptionGroupUnstyled components={{ Root, Label, List }} />; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
export { default } from './OptionGroupUnstyled'; | ||
|
||
export type { default as OptionGroupUnstyledProps } from './OptionGroupUnstyledProps'; | ||
export * from './OptionGroupUnstyledProps'; | ||
export * from './OptionGroupUnstyled.types'; | ||
|
||
export { default as optionGroupUnstyledClasses } from './optionGroupUnstyledClasses'; | ||
export * from './optionGroupUnstyledClasses'; |
13 changes: 13 additions & 0 deletions
13
packages/mui-base/src/OptionUnstyled/OptionUnstyled.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import * as React from 'react'; | ||
import OptionUnstyled, { OptionUnstyledRootSlotProps } from '@mui/base/OptionUnstyled'; | ||
|
||
const Root = React.forwardRef(function Root<TValue>( | ||
props: OptionUnstyledRootSlotProps<TValue>, | ||
ref: React.ForwardedRef<HTMLLIElement>, | ||
) { | ||
const { ownerState, ...other } = props; | ||
|
||
return <li data-selected={ownerState.selected} {...other} ref={ref} />; | ||
}); | ||
|
||
const option = <OptionUnstyled value={null} components={{ Root }} />; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
export { default } from './OptionUnstyled'; | ||
|
||
export type { default as OptionUnstyledProps } from './OptionUnstyledProps'; | ||
export * from './OptionUnstyledProps'; | ||
export * from './OptionUnstyled.types'; | ||
|
||
export { default as optionUnstyledClasses } from './optionUnstyledClasses'; | ||
export * from './optionUnstyledClasses'; |
4 changes: 2 additions & 2 deletions
4
packages/mui-base/src/SelectUnstyled/SelectUnstyledContext.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I was surprised at first that we don't have here
ownerState
, but saw later that we indeed don't have it for simple components :) I guess having the correct types will be helpful for developers :)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.
If developers complain about not having it, we may define
type OptionGroupUnstyledOwnerState = OptionGroupUnstyledProps
, and pass it to the slots, but I don't think it's necessary now.