mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
Co-authored-by: Rahim <rahim.alwer@gmail.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
21 lines
780 B
TypeScript
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;
|
|
}
|