Files
v10/packages/react/src/ui/status-indicator/context.tsx
T
2026-05-05 10:34:12 +10:00

21 lines
780 B
TypeScript

'use client';
import type { StatusIndicatorCore } from '@videojs/core';
import { createContext, type ProviderProps, useContext } from 'react';
export interface StatusIndicatorContextValue {
state: StatusIndicatorCore.State;
}
const StatusIndicatorContext = createContext<StatusIndicatorContextValue | null>(null);
export function StatusIndicatorProvider({ value, children }: ProviderProps<StatusIndicatorContextValue>) {
return <StatusIndicatorContext.Provider value={value}>{children}</StatusIndicatorContext.Provider>;
}
export function useStatusIndicatorContext(): StatusIndicatorContextValue {
const ctx = useContext(StatusIndicatorContext);
if (!ctx) throw new Error('StatusIndicator child compounds must be used within a StatusIndicator.Root');
return ctx;
}