import { getClassName , UiError } from "@itwin/appui-abstract" ; import { UiComponents } from "../UiComponents" ; import React from "react" ; internal export function createContextWithMandatoryProvider < T > ( contextName ) { const context = React . createContext < T > ( undefined as any as T ) ; function useContextWithoutDefaultValue < P > ( ConsumingComponent ) { const value = React . useContext ( context ) ; if ( value === undefined ) { throw new UiError ( UiComponents . loggerCategory ( ConsumingComponent ) , `'${ getClassName ( ConsumingComponent ) }' expects to be wrapped by a '${ contextName }' provider.` ) ; } return value ; } return [ context . Provider , context . Consumer , useContextWithoutDefaultValue ] ; }