-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
packages/material-ui/src/ExpansionPanel/ExpansionPanelContext.js
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,18 @@ | ||
import React from 'react'; | ||
import warning from 'warning'; | ||
|
||
const ExpansionPanelContext = React.createContext({ | ||
disabled: false, | ||
expanded: false, | ||
onChange: () => { | ||
warning( | ||
false, | ||
[ | ||
'Material-UI: You called onChange from a component that is not a child of a ', | ||
'ExpansionPanel component.', | ||
].join(''), | ||
); | ||
}, | ||
}); | ||
|
||
export default ExpansionPanelContext; |
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 +1,2 @@ | ||
export { default } from './ExpansionPanel'; | ||
export { default as useExpansionPanel } from './useExpansionPanel'; |
11 changes: 11 additions & 0 deletions
11
packages/material-ui/src/ExpansionPanel/useExpansionPanel.d.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,11 @@ | ||
import * as React from 'react'; | ||
|
||
interface ExpansionPanelContext<ChangeEvent> { | ||
disabled: boolean; | ||
expanded: boolean; | ||
onChange: (event: Event, expanded: boolean) => void; | ||
} | ||
|
||
export default function useExpansionPanel< | ||
ChangeEvent = React.SyntheticEvent | ||
>(): ExpansionPanelContext<ChangeEvent>; |
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 React from 'react'; | ||
import ExpansionPanelContext from './ExpansionPanelContext'; | ||
|
||
export default function useExpansionPanel() { | ||
return React.useContext(ExpansionPanelContext); | ||
} |