import { getElement } from '@stencil/core' ; import { isInstanceOf } from '../../utils/unit' ; import { StateChange } from '../core/player/PlayerDispatcher' ; import { ProviderWritableProps } from './ProviderProps' ; export const PROVIDER_CHANGE_EVENT = 'vmProviderChange' ; export type ProviderDispatcher = < P extends keyof ProviderWritableProps > ( prop : P , value : ProviderWritableProps [ P ] ) => void ; param ref export const createProviderDispatcher = ( ref ) : ProviderDispatcher => ( prop , value ) => { const el = isInstanceOf ( ref , HTMLElement ) ? ref : getElement ( ref ) ; const event = new CustomEvent < StateChange < ProviderWritableProps > > ( PROVIDER_CHANGE_EVENT , { bubbles : true , composed : true , detail : { by : el , prop , value } , } ) ; el . dispatchEvent ( event ) ; } ;