UNPKG

@sandlada/mdc

Version:

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

8 lines 3.02 kB
import{customElement as e}from"../../node_modules/@lit/reactive-element/decorators/custom-element.js";import{property as t}from"../../node_modules/@lit/reactive-element/decorators/property.js";import"../../node_modules/lit/decorators.js";import{html as n}from"../../node_modules/lit-html/lit-html.js";import{LitElement as r}from"../../node_modules/lit-element/lit-element.js";import"../../node_modules/lit/index.js";import{ContextConsumer as i}from"../../node_modules/@lit/context/lib/controllers/context-consumer.js";import{GlobalMDCContext as a}from"../../context-provider.js";import o from"../../_virtual/_@oxc-project_runtime@0.144.0/helpers/esm/decorate.js";import{styles as s}from"./elevation.style.js"; /** * @license * Copyright 2025 Sandlada & Kai Orion * SPDX-License-Identifier: MIT */ let c=class extends r{constructor(...e){super(...e),this._ignoreGlobalConfig=!1,this._disabled=!1,this._disabledConfigured=!1,this._configAttributeSyncSource=null,this.globalMDCContextConsumer=new i(this,{context:a,subscribe:!0})}static{this.styles=s}get ignoreGlobalConfig(){return this._ignoreGlobalConfig}set ignoreGlobalConfig(e){let t=this._ignoreGlobalConfig;t!==e&&(this._ignoreGlobalConfig=e,this._configAttributeSyncSource=`property`,this.toggleAttribute(`ignore-global-config`,e),this._configAttributeSyncSource=null,this.requestUpdate(`ignoreGlobalConfig`,t))}get disabled(){return this.effectiveDisabled}set disabled(e){if(this._configAttributeSyncSource)return;let t=this._disabled,n=this._disabledConfigured;this._disabled=e,this._disabledConfigured=!0,this._configAttributeSyncSource=`property`,this.toggleAttribute(`disabled`,e),this._configAttributeSyncSource=null,(t!==e||!n)&&this.requestUpdate(`disabled`,t)}get effectiveDisabled(){return this._ignoreGlobalConfig||this._disabledConfigured?this._disabled:this.globalElevationConfig.disabled}get globalElevationConfig(){return{disabled:this.globalMDCContextConsumer.value?.elevation?.disabled??!1}}syncDisabledAttribute(){let e=this.effectiveDisabled;this.hasAttribute(`disabled`)!==e&&(this._configAttributeSyncSource=`effective`,this.toggleAttribute(`disabled`,e),this._configAttributeSyncSource=null)}attributeChangedCallback(e,t,n){if(e===`disabled`){if(this._configAttributeSyncSource)return;let e=this._disabled;this._disabled=n!==null,this._disabledConfigured=!0,this.requestUpdate(`disabled`,e);return}if(e===`ignore-global-config`){if(this._configAttributeSyncSource)return;let e=this._ignoreGlobalConfig;this._ignoreGlobalConfig=n!==null,this.requestUpdate(`ignoreGlobalConfig`,e);return}super.attributeChangedCallback(e,t,n)}render(){return n`<span aria-hidden="true" class="elevation"></span>`}updated(e){super.updated(e),this.syncDisabledAttribute()}};o([t({type:Boolean,attribute:`ignore-global-config`,reflect:!0,noAccessor:!0})],c.prototype,`ignoreGlobalConfig`,null),o([t({type:Boolean,attribute:`disabled`,noAccessor:!0})],c.prototype,`disabled`,null),c=o([e(`mdc-elevation`)],c);export{c as Elevation}; //# sourceMappingURL=elevation.js.map