mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
25 lines
737 B
TypeScript
25 lines
737 B
TypeScript
'use client';
|
|
|
|
import type { StateAttrMap, TooltipCore } from '@videojs/core';
|
|
import type { TooltipApi } from '@videojs/core/dom';
|
|
import { createContext, useContext } from 'react';
|
|
|
|
export interface TooltipContextValue {
|
|
core: TooltipCore;
|
|
tooltip: TooltipApi;
|
|
state: TooltipCore.State;
|
|
stateAttrMap: StateAttrMap<TooltipCore.State>;
|
|
anchorName: string;
|
|
popupId: string;
|
|
}
|
|
|
|
const TooltipContext = createContext<TooltipContextValue | null>(null);
|
|
|
|
export const TooltipContextProvider = TooltipContext.Provider;
|
|
|
|
export function useTooltipContext(): TooltipContextValue {
|
|
const ctx = useContext(TooltipContext);
|
|
if (!ctx) throw new Error('Tooltip compound components must be used within a Tooltip.Root');
|
|
return ctx;
|
|
}
|