UNPKG

@sandlada/mdc

Version:

@sandlada/mdc is an open source component library that follows the Material Design 3 design specifications.

8 lines 3.32 kB
import{property as e}from"../../node_modules/@lit/reactive-element/decorators/property.js";import"../../node_modules/lit/decorators.js";import{html as t}from"../../node_modules/lit-html/lit-html.js";import"../../node_modules/lit/index.js";import{ContextConsumer as n}from"../../node_modules/@lit/context/lib/controllers/context-consumer.js";import{GlobalMDCContext as r}from"../../context-provider.js";import i from"../../_virtual/_@oxc-project_runtime@0.144.0/helpers/esm/decorate.js"; /** * @license * Copyright 2026 Kai-Orion & Sandlada * SPDX-License-Identifier: MIT */ function a(a){class o extends a{constructor(...e){super(...e),this._ignoreGlobalConfig=!1,this._disableElevation=!1,this._disableElevationConfigured=!1,this._elevationAttributeSyncSource=null,this.globalMDCContextConsumer=new n(this,{context:r,subscribe:!0})}get ignoreGlobalConfig(){return this._ignoreGlobalConfig}set ignoreGlobalConfig(e){let t=this._ignoreGlobalConfig;t!==e&&(this._ignoreGlobalConfig=e,this._elevationAttributeSyncSource=`property`,this.toggleAttribute(`ignore-global-config`,e),this._elevationAttributeSyncSource=null,this.requestUpdate(`ignoreGlobalConfig`,t))}get disableElevation(){return this.effectiveDisableElevation}set disableElevation(e){if(this._elevationAttributeSyncSource)return;let t=this._disableElevation,n=this._disableElevationConfigured;this._disableElevation=e,this._disableElevationConfigured=!0,this._elevationAttributeSyncSource=`property`,this.toggleAttribute(`disable-elevation`,e),this._elevationAttributeSyncSource=null,(t!==e||!n)&&this.requestUpdate(`disableElevation`,t)}get useLocalConfig(){return this._ignoreGlobalConfig||this._disableElevationConfigured}get effectiveDisableElevation(){return this.useLocalConfig?this._disableElevation:this.globalElevationConfig.disabled}get globalElevationConfig(){return{disabled:this.globalMDCContextConsumer.value?.elevation?.disabled??!1}}syncDisableElevationAttribute(){let e=this.effectiveDisableElevation;this.hasAttribute(`disable-elevation`)!==e&&(this._elevationAttributeSyncSource=`property`,this.toggleAttribute(`disable-elevation`,e),this._elevationAttributeSyncSource=null)}attributeChangedCallback(e,t,n){if(e===`ignore-global-config`){if(this._elevationAttributeSyncSource)return;let e=this._ignoreGlobalConfig;this._ignoreGlobalConfig=n!==null,this.requestUpdate(`ignoreGlobalConfig`,e);return}if(e===`disable-elevation`){if(this._elevationAttributeSyncSource)return;let e=this._disableElevation;this._disableElevation=n!==null,this._disableElevationConfigured=!0,this.requestUpdate(`disableElevation`,e);return}super.attributeChangedCallback(e,t,n)}renderElevation(){let e=this.disableElevation||(this.disabled??!1);return this.useLocalConfig?t`<mdc-elevation part="elevation" ignore-global-config .disabled="${e}"></mdc-elevation>`:e?t`<mdc-elevation part="elevation" .disabled="${e}"></mdc-elevation>`:t`<mdc-elevation part="elevation"></mdc-elevation>`}updated(e){super.updated(e),this.syncDisableElevationAttribute()}}return i([e({attribute:`ignore-global-config`,type:Boolean,reflect:!0,noAccessor:!0})],o.prototype,`ignoreGlobalConfig`,null),i([e({attribute:`disable-elevation`,type:Boolean,noAccessor:!0})],o.prototype,`disableElevation`,null),o}export{a as mixinElevationOptions}; //# sourceMappingURL=elevation-options.mixin.js.map