2022-01-04 14:16:09 +02:00
|
|
|
import { createContext, PropsWithChildren, useContext } from 'react';
|
|
|
|
|
2022-06-17 19:18:42 +03:00
|
|
|
import { Widget, WidgetBody } from '@@/Widget';
|
2022-01-04 14:16:09 +02:00
|
|
|
|
|
|
|
const Context = createContext<null | boolean>(null);
|
|
|
|
|
|
|
|
export function useTableContext() {
|
|
|
|
const context = useContext(Context);
|
|
|
|
|
|
|
|
if (context == null) {
|
|
|
|
throw new Error('Should be nested inside a TableContainer component');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function TableContainer({ children }: PropsWithChildren<unknown>) {
|
|
|
|
return (
|
|
|
|
<Context.Provider value>
|
|
|
|
<div className="datatable">
|
|
|
|
<Widget>
|
|
|
|
<WidgetBody className="no-padding">{children}</WidgetBody>
|
|
|
|
</Widget>
|
|
|
|
</div>
|
|
|
|
</Context.Provider>
|
|
|
|
);
|
|
|
|
}
|