@sandlada/mdc
Version:
@sandlada/mdc is an open source component library that follows the Material Design 3 design specifications.
21 lines • 2.19 kB
JavaScript
import{property as e}from"../../../node_modules/@lit/reactive-element/decorators/property.js";import{query as t}from"../../../node_modules/@lit/reactive-element/decorators/query.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 i from"../../../_virtual/_@oxc-project_runtime@0.144.0/helpers/esm/decorate.js";import{GlobalNavigationStateStore as a}from"../../../utils/navigation/navigation-state-store.js";
/**
* @license
* Copyright 2026 Kai-Orion & Sandlada
* SPDX-License-Identifier: MIT
*
* @fileoverview
* Shared container logic for navigation components. The container propagates
* `navigation-scope` to slotted tabs and exposes imperative scope-level APIs.
*
* @example
* ```ts
* @customElement('mdc-navigation-bar')
* export class NavigationBar extends BaseNavigationContainer {}
*
* const bar = document.querySelector('mdc-navigation-bar')
* bar?.setActive('/home')
* ```
*/
var o=class extends r{constructor(...e){super(...e),this.navigationScope=`global`,this.handleSlotChange=()=>{this.syncTabsScope()}}get activeValue(){return a.getActive(this.normalizeScope(this.navigationScope))}setActive(e,t=`programmatic`){a.setActive(this.normalizeScope(this.navigationScope),e,{source:`external`,trigger:t})}firstUpdated(){this.syncTabsScope()}updated(e){e.has(`navigationScope`)&&this.syncTabsScope()}render(){return n`${this.renderSlot()}`}renderSlot(){return n`<slot @slotchange="${this.handleSlotChange}"></slot>`}syncTabsScope(){let e=this.normalizeScope(this.navigationScope);for(let t of this.tabs)t.hasAttribute(`navigation-scope`)||(t.navigationScope=e)}get tabs(){return this.slotElement?this.slotElement.assignedElements({flatten:!0}).filter(e=>e.tagName===`MDC-NAVIGATION-TAB`):[]}normalizeScope(e){let t=e.trim();return t.length>0?t:`global`}};i([e({type:String,reflect:!0,attribute:`navigation-scope`})],o.prototype,`navigationScope`,void 0),i([t(`slot`)],o.prototype,`slotElement`,void 0);export{o as BaseNavigationContainer};
//# sourceMappingURL=base-navigation-container.js.map