-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[core] Generic props for FormControl, FormLabel, List (#15292)
This PR adds v4 typings for FormControl, FormLabel, and List components. It also includes some small changes to clean up the TS demos for this components. Co-authored-by: Sebastian Silbermann <[email protected]>
- Loading branch information
Showing
10 changed files
with
59 additions
and
74 deletions.
There are no files selected for viewing
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
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,21 +1,24 @@ | ||
import * as React from 'react'; | ||
import { StandardProps, PropTypes } from '..'; | ||
import { PropTypes } from '..'; | ||
import { OverridableComponent, SimplifiedPropsOf } from '../OverridableComponent'; | ||
|
||
export interface FormControlProps | ||
extends StandardProps<React.HtmlHTMLAttributes<HTMLDivElement>, FormControlClassKey> { | ||
component?: React.ElementType<React.HtmlHTMLAttributes<HTMLDivElement>>; | ||
disabled?: boolean; | ||
error?: boolean; | ||
fullWidth?: boolean; | ||
margin?: PropTypes.Margin; | ||
onBlur?: React.EventHandler<any>; | ||
onFocus?: React.EventHandler<any>; | ||
required?: boolean; | ||
variant?: 'standard' | 'outlined' | 'filled'; | ||
} | ||
declare const FormControl: OverridableComponent<{ | ||
props: { | ||
disabled?: boolean; | ||
error?: boolean; | ||
fullWidth?: boolean; | ||
margin?: PropTypes.Margin; | ||
onBlur?: React.EventHandler<any>; | ||
onFocus?: React.EventHandler<any>; | ||
required?: boolean; | ||
variant?: 'standard' | 'outlined' | 'filled'; | ||
}; | ||
defaultComponent: 'div'; | ||
classKey: FormControlClassKey; | ||
}>; | ||
|
||
export type FormControlClassKey = 'root' | 'marginNormal' | 'marginDense' | 'fullWidth'; | ||
|
||
declare const FormControl: React.ComponentType<FormControlProps>; | ||
export type FormControlProps = SimplifiedPropsOf<typeof FormControl>; | ||
|
||
export default FormControl; |
This file was deleted.
Oops, something went wrong.
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,16 +1,18 @@ | ||
import * as React from 'react'; | ||
import { StandardProps } from '..'; | ||
import { OverridableComponent, SimplifiedPropsOf } from '../OverridableComponent'; | ||
|
||
export interface ListProps | ||
extends StandardProps<React.HTMLAttributes<HTMLUListElement>, ListClassKey> { | ||
component?: React.ElementType<React.HTMLAttributes<HTMLUListElement>>; | ||
dense?: boolean; | ||
disablePadding?: boolean; | ||
subheader?: React.ReactElement; | ||
} | ||
declare const List: OverridableComponent<{ | ||
props: { | ||
dense?: boolean; | ||
disablePadding?: boolean; | ||
subheader?: React.ReactElement; | ||
}; | ||
defaultComponent: 'ul'; | ||
classKey: ListClassKey; | ||
}>; | ||
|
||
export type ListClassKey = 'root' | 'padding' | 'dense' | 'subheader'; | ||
|
||
declare const List: React.ComponentType<ListProps>; | ||
export type ListProps = SimplifiedPropsOf<typeof List>; | ||
|
||
export default 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
import * as React from 'react'; | ||
import List from '@material-ui/core/List'; | ||
|
||
// use other components | ||
// custom host | ||
// https://github.com/mui-org/material-ui/issues/13746 | ||
{ | ||
// HTMLDivElement is not assignable to HTMLUlElement #v4-typings | ||
<List component="div" />; // $ExpectError | ||
<List component="div" />; | ||
<List | ||
component={'div' as 'ul'} | ||
onChange={e => { | ||
e.currentTarget; // $ExpectType EventTarget & HTMLUListElement | ||
component="div" | ||
onChange={(e: React.FormEvent<HTMLDivElement>) => { | ||
e.currentTarget; | ||
}} | ||
/>; | ||
} |