@sandlada/mdc
Version:
@sandlada/mdc is an open source component library that follows the Material Design 3 design specifications.
8 lines • 1.19 kB
JavaScript
import{createContext as e}from"./node_modules/@lit/context/lib/create-context.js";import{ContextProvider as t}from"./node_modules/@lit/context/lib/controllers/context-provider.js";
/**
* @license
* Copyright 2026 Kai-Orion & Sandlada
* SPDX-License-Identifier: MIT
*/
const n=e(Symbol.for(`mdc-global-context`)),r=class e{constructor(){this.provider=null,this.currentConfig={ripple:{},focusRing:{},elevation:{}}}static{this._Instance=null}static get Instance(){return this._Instance||=new e,this._Instance}mergeConfig(e){return{...this.currentConfig,...e,ripple:{...this.currentConfig.ripple,...e.ripple??{}},focusRing:{...this.currentConfig.focusRing,...e.focusRing??{}},elevation:{...this.currentConfig.elevation,...e.elevation??{}}}}attach(e={}){this.provider||=(this.currentConfig=this.mergeConfig(e),new t(document.documentElement,{initialValue:this.currentConfig,context:n}))}setConfig(e){if(!this.provider)throw Error(`GlobalMDCContextProvider is not attached yet. Call attach() first.`);this.currentConfig=this.mergeConfig(e),this.provider.setValue(this.currentConfig)}}.Instance;export{n as GlobalMDCContext,r as GlobalMDCContextProvider};
//# sourceMappingURL=context-provider.js.map