# @embedpdf/react — ./shell MenuClosedEvent [InterfaceDeclaration] (from packages/plugin/shell/src/contract.ts): export interface MenuClosedEvent{ readonly id: string; } MenuOpenedEvent [InterfaceDeclaration] (from packages/plugin/shell/src/contract.ts): export interface MenuOpenedEvent{ readonly id: string; } OpenSurfaceOptions [InterfaceDeclaration] (from packages/plugin/shell/src/contract.ts): export interface OpenSurfaceOptions{ readonly exclusive?: string; readonly props?: SurfaceProps; readonly focus?: boolean; } ShellCapability [InterfaceDeclaration] (from packages/plugin/shell/src/contract.ts): export interface ShellCapability{ isOpen(id: string): boolean; getSurface(id: string): SurfaceState | null; listOpenSurfaces(): readonly SurfaceState[]; open(id: string, options?: OpenSurfaceOptions): void; close(id: string): void; toggle(id: string, options?: OpenSurfaceOptions): void; updateSurfaceProps(id: string, props: SurfaceProps): void; closeAll(): void; isMenuOpen(id: string): boolean; listOpenMenus(): readonly string[]; openMenu(id: string): void; closeMenu(id: string): void; toggleMenu(id: string): void; closeAllMenus(): void; getSnapshot(): ShellSnapshot; applySnapshot(snapshot: ShellSnapshot): void; readonly onSurfaceOpened: EventHook; readonly onSurfaceClosed: EventHook; readonly onMenuOpened: EventHook; readonly onMenuClosed: EventHook; } ShellSnapshot [InterfaceDeclaration] (from packages/plugin/shell/src/contract.ts): export interface ShellSnapshot{ readonly surfaces: Readonly>>; readonly openMenus: readonly string[]; } ShellState [InterfaceDeclaration] (from packages/plugin/shell/src/state.ts): export interface ShellState{ readonly openSurfaces: readonly SurfaceState[]; readonly openMenus: readonly string[]; } ShellToken [VariableDeclaration] (from packages/plugin/shell/src/token.ts): ShellToken = createCapabilityToken('shell', { hint: `add shellPlugin() from '@embedpdf/plugin-shell' to your plugins list`, } ) SurfaceClosedEvent [InterfaceDeclaration] (from packages/plugin/shell/src/contract.ts): export interface SurfaceClosedEvent{ readonly id: string; } SurfaceFocusOptions [InterfaceDeclaration] (from packages/framework/web/src/surface-focus.ts): export interface SurfaceFocusOptions{ readonly select?: boolean; } SurfaceHandle [InterfaceDeclaration]: export interface SurfaceHandle{ readonly isOpen: boolean; readonly props: SurfaceProps; open(options?: OpenSurfaceOptions): void; close(): void; toggle(options?: OpenSurfaceOptions): void; } SurfaceOpenedEvent [InterfaceDeclaration] (from packages/plugin/shell/src/contract.ts): export interface SurfaceOpenedEvent{ readonly id: string; readonly props?: SurfaceProps; } SurfaceProps [TypeAliasDeclaration] (from packages/plugin/shell/src/contract.ts): export type SurfaceProps = Readonly>; SurfaceState [InterfaceDeclaration] (from packages/plugin/shell/src/contract.ts): export interface SurfaceState{ readonly id: string; readonly open: boolean; readonly exclusive?: string; readonly props?: SurfaceProps; readonly focusRequest: number; } shellPlugin [VariableDeclaration] (from packages/plugin/shell/src/shell.plugin.ts): shellPlugin = () => definePlugin({ id: 'shell', scope: 'document', token: ShellToken, state: initialShellModel, create: createShellController, } ) shellState [VariableDeclaration] (from packages/plugin/shell/src/state.ts): shellState = defineState(ShellToken, { read: (shell): ShellState => ({ openSurfaces: shell.listOpenSurfaces(), openMenus: shell.listOpenMenus(), } ), empty:{ openSurfaces: [], openMenus: []} , } ) useShell [FunctionDeclaration]: export function useShell(): ShellCapability{ return useCapability(ShellToken); } useShellEvent [FunctionDeclaration]: export function useShellEvent( select: (shell: ShellCapability) => EventHook, handler: (event: T) => void, ): void{ useCapabilityEvent(ShellToken, select, handler); } useShellState [VariableDeclaration]: useShellState = stateHook(shellState) useSurface [FunctionDeclaration]: export function useSurface(id: string): SurfaceHandle{ const shell = useOptionalCapability(ShellToken); const isOpen = useOptionalSelector(ShellToken, (shell) => shell.isOpen(id), false); const props = useOptionalSelector( ShellToken, (shell) => shell.getSurface(id)?.props ?? NO_PROPS, NO_PROPS, ); return useMemo( () => ({ isOpen, props, open: (options?: OpenSurfaceOptions) => shell?.open(id, options), close: () => shell?.close(id), toggle: (options?: OpenSurfaceOptions) => shell?.toggle(id, options), } ), [shell, id, isOpen, props], ); } useSurfaceFocus [FunctionDeclaration]: export function useSurfaceFocus( id: string, ref: RefObject, options: SurfaceFocusOptions ={ } , ): void{ const shell = useOptionalCapability(ShellToken); const request = useOptionalSelector( ShellToken, (current) => current.getSurface(id)?.focusRequest ?? 0, 0, ); const [follower] = useState(createSurfaceFocusFollower); const select = options.select ?? false; useEffect(() => follower.follow(ref.current, shell, request, { select} )); }