forked from mui/material-ui
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FormControl] Add missing types in
useFormControl
(mui#35168)
- Loading branch information
1 parent
1eb6e52
commit f7a826f
Showing
6 changed files
with
45 additions
and
44 deletions.
There are no files selected for viewing
12 changes: 0 additions & 12 deletions
12
packages/mui-material/src/FormControl/FormControlContext.js
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
packages/mui-material/src/FormControl/FormControlContext.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import * as React from 'react'; | ||
import type { FormControlProps } from './FormControl'; | ||
|
||
type ContextFromPropsKey = | ||
| 'color' | ||
| 'disabled' | ||
| 'error' | ||
| 'fullWidth' | ||
| 'hiddenLabel' | ||
| 'margin' | ||
| 'onBlur' | ||
| 'onFocus' | ||
| 'required' | ||
| 'size' | ||
| 'variant'; | ||
|
||
export interface FormControlState extends Pick<FormControlProps, ContextFromPropsKey> { | ||
adornedStart: boolean; | ||
filled: boolean; | ||
focused: boolean; | ||
onEmpty: () => void; | ||
onFilled: () => void; | ||
registerEffect: () => void; | ||
setAdornedStart: React.Dispatch<React.SetStateAction<boolean>>; | ||
} | ||
|
||
/** | ||
* @ignore - internal component. | ||
*/ | ||
const FormControlContext = React.createContext<FormControlState | undefined>(undefined); | ||
|
||
if (process.env.NODE_ENV !== 'production') { | ||
FormControlContext.displayName = 'FormControlContext'; | ||
} | ||
|
||
export default FormControlContext; |
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,9 @@ | ||
export { default } from './FormControl'; | ||
export * from './FormControl'; | ||
|
||
export { default as useFormControl, FormControlState } from './useFormControl'; | ||
export { default as useFormControl } from './useFormControl'; | ||
|
||
export { FormControlState } from './FormControlContext'; | ||
|
||
export { default as formControlClasses } from './formControlClasses'; | ||
export * from './formControlClasses'; |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import * as React from 'react'; | ||
import FormControlContext, { FormControlState } from './FormControlContext'; | ||
|
||
export default function useFormControl(): FormControlState | undefined { | ||
return React.useContext(FormControlContext); | ||
} |