mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-04-28 10:28:09 -04:00
27 lines
739 B
TypeScript
27 lines
739 B
TypeScript
import { createContext, useContext, type ReactNode, type RefObject } from 'react';
|
|
|
|
import { useActiveItem } from './useActiveItem';
|
|
|
|
export interface ExplorerViewContextProps extends ReturnType<typeof useActiveItem> {
|
|
ref: RefObject<HTMLDivElement>;
|
|
/**
|
|
* Padding to apply when scrolling to an item.
|
|
*/
|
|
scrollPadding?: { top?: number; bottom?: number };
|
|
contextMenu?: ReactNode;
|
|
selectable: boolean;
|
|
listViewOptions?: {
|
|
hideHeaderBorder?: boolean;
|
|
};
|
|
}
|
|
|
|
export const ExplorerViewContext = createContext<ExplorerViewContextProps | null>(null);
|
|
|
|
export const useExplorerViewContext = () => {
|
|
const ctx = useContext(ExplorerViewContext);
|
|
|
|
if (ctx === null) throw new Error('ViewContext.Provider not found!');
|
|
|
|
return ctx;
|
|
};
|