2023-05-06 15:49:37 +08:00
|
|
|
import * as React from 'react';
|
2022-04-29 20:48:10 +08:00
|
|
|
|
2024-05-31 10:14:37 +08:00
|
|
|
const DisabledContext = React.createContext<boolean>(false);
|
2022-04-29 20:48:10 +08:00
|
|
|
|
|
|
|
export interface DisabledContextProps {
|
2024-05-31 10:14:37 +08:00
|
|
|
disabled?: boolean;
|
2022-04-29 20:48:10 +08:00
|
|
|
children?: React.ReactNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const DisabledContextProvider: React.FC<DisabledContextProps> = ({ children, disabled }) => {
|
|
|
|
const originDisabled = React.useContext(DisabledContext);
|
|
|
|
return (
|
2022-11-23 11:04:23 +08:00
|
|
|
<DisabledContext.Provider value={disabled ?? originDisabled}>
|
2022-04-29 20:48:10 +08:00
|
|
|
{children}
|
|
|
|
</DisabledContext.Provider>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default DisabledContext;
|