import { PropsWithChildren, createContext, useContext } from 'react';

const ActionsCellRenderAreaContext = createContext(false);

/** Render area in which actions cell is rendered */
export function ActionsCellRenderArea({ children }: PropsWithChildren<{}>) {
  return (
    <ActionsCellRenderAreaContext.Provider value={true}>{children}</ActionsCellRenderAreaContext.Provider>
  );
}

/** Return `true` if current component is located inside {@link ActionsCellRenderArea} */
export function useIsActionsCellRenderArea() {
  return useContext(ActionsCellRenderAreaContext);
}
