UNPKG

@esri/calcite-components

Version:

Web Components for Esri's Calcite Design System.

5 lines (4 loc) 6.08 kB
/*! All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://github.com/Esri/calcite-design-system/blob/dev/LICENSE.md for details. v3.2.1 */ import{a as d,b as g}from"./5RDOSP2E.js";import{u as n}from"./3ADX47DD.js";import{d as y}from"./HPN2C7M6.js";import"./JOSABGK6.js";import"./NNVH7JUI.js";import{E as m,F as o,R as h,c as l,d as s,q as c}from"./BJZTU5BQ.js";var a={container:"container",containerContent:"container-content",hasProgress:"progress-bar",hide:"hide",primary:"primary",secondary:"secondary",tertiary:"tertiary"},e={logo:"logo",user:"user",progress:"progress",navigationAction:"navigation-action",contentStart:"content-start",contentEnd:"content-end",contentCenter:"content-center",navSecondary:"navigation-secondary",navTertiary:"navigation-tertiary"},S={hamburger:"hamburger"},v=l`:host([hidden]){display:none}[hidden]{display:none}:host{display:block}.container{display:flex;inline-size:100%;flex-direction:column;margin-block:0;margin-inline:auto;background-color:var(--calcite-navigation-background-color, var(--calcite-navigation-background, var(--calcite-color-foreground-1)))}.container.primary,.container.secondary,.container.tertiary{border-block-end:1px solid;border-block-end-color:var(--calcite-navigation-border-color, var(--calcite-color-border-3))}.user,.logo{display:flex}.hide{display:none}.primary{block-size:4rem}.secondary,.tertiary{block-size:3rem}.container-content{margin-inline:auto;display:flex;block-size:100%;inline-size:100%;margin-block:0;inline-size:var(--calcite-navigation-width, 100%);max-inline-size:100%}.container-content.progress-bar{margin-block-start:.125rem}slot[name]{display:flex;flex-direction:row}slot[name=navigation-secondary]::slotted(calcite-navigation),slot[name=navigation-tertiary]::slotted(calcite-navigation){inline-size:100%}slot[name=content-start]::slotted(*),slot[name=content-center]::slotted(*),slot[name=content-end]::slotted(*){display:flex;flex-direction:row;align-items:center}slot[name=progress],slot[name=progress] calcite-progress{inset-block-start:0;inset-inline:0}slot[name=content-end]{margin-inline-start:auto}slot[name=content-start]{margin-inline-end:auto}slot[name=content-end],slot[name=logo]~slot[name=user],slot[name=user]:only-child{margin-inline-start:auto}slot[name=content-center]{margin-inline-start:auto;margin-inline-end:auto}slot[name=content-start]~slot[name=content-center]{margin-inline-start:0px}slot[name=content-start]~slot[name=content-end],slot[name=content-center]~slot[name=content-end],slot[name=content-center]~slot[name=user],slot[name=content-end]~slot[name=user]{margin:0}`,i=class extends m{constructor(){super(...arguments),this.navigationActionEl=d(),this.navigationAction=!1,this.calciteNavigationActionSelect=c({cancelable:!1})}static{this.properties={logoSlotHasElements:[16,{},{state:!0}],navigationActionSlotHasElements:[16,{},{state:!0}],primaryContentCenterSlotHasElements:[16,{},{state:!0}],primaryContentEndSlotHasElements:[16,{},{state:!0}],primaryContentStartSlotHasElements:[16,{},{state:!0}],progressSlotHasElement:[16,{},{state:!0}],secondarySlotHasElements:[16,{},{state:!0}],tertiarySlotHasElements:[16,{},{state:!0}],userSlotHasElements:[16,{},{state:!0}],label:1,navigationAction:[7,{},{reflect:!0,type:Boolean}]}}static{this.styles=v}async setFocus(){return await y(this),this.navigationActionEl.value?.setFocus()}actionClickHandler(){this.calciteNavigationActionSelect.emit()}handleUserSlotChange(t){this.isPrimaryLevel()&&(this.userSlotHasElements=n(t))}handleLogoSlotChange(t){this.isPrimaryLevel()&&(this.logoSlotHasElements=n(t))}handleContentStartSlotChange(t){this.isPrimaryLevel()&&(this.primaryContentStartSlotHasElements=n(t))}handleContentEndSlotChange(t){this.isPrimaryLevel()&&(this.primaryContentEndSlotHasElements=n(t))}handleContentCenterSlotChange(t){this.isPrimaryLevel()&&(this.primaryContentCenterSlotHasElements=n(t))}handleSecondarySlotChange(t){this.secondarySlotHasElements=n(t)}handleTertiarySlotChange(t){this.tertiarySlotHasElements=n(t)}handleMenuActionSlotChange(t){this.isPrimaryLevel()&&(this.navigationActionSlotHasElements=n(t),this.navigationActionSlotHasElements&&(this.navigationAction=!1))}handleProgressSlotChange(t){this.isPrimaryLevel()&&(this.progressSlotHasElement=n(t))}isPrimaryLevel(){return this.el.slot!==e.navSecondary&&this.el.slot!==e.navTertiary}renderMenuAction(){return s`<slot name=${e.navigationAction} @slotchange=${this.handleMenuActionSlotChange}>${this.navigationAction&&s`<calcite-action .icon=${S.hamburger} @click=${this.actionClickHandler} .text=${this.label} ${g(this.navigationActionEl)}></calcite-action>`||""}</slot>`}render(){let t=this.logoSlotHasElements||this.userSlotHasElements||this.navigationActionSlotHasElements||this.primaryContentCenterSlotHasElements||this.primaryContentEndSlotHasElements||this.primaryContentStartSlotHasElements||this.navigationAction,r=this.el.slot;return s`<div class=${o({[a.container]:!0,[a.secondary]:r===e.navSecondary,[a.tertiary]:r===e.navTertiary,[a.primary]:t})}><div class=${o({[a.hide]:!this.progressSlotHasElement,[e.progress]:!0})}><slot name=${e.progress} @slotchange=${this.handleProgressSlotChange}></slot></div><div class=${o({[a.containerContent]:!0,[a.hasProgress]:this.progressSlotHasElement})}>${this.renderMenuAction()}<div class=${o({[a.hide]:!this.logoSlotHasElements,[e.logo]:!0})}><slot name=${e.logo} @slotchange=${this.handleLogoSlotChange}></slot></div><slot name=${e.contentStart} @slotchange=${this.handleContentStartSlotChange}></slot><slot name=${e.contentCenter} @slotchange=${this.handleContentCenterSlotChange}></slot><slot name=${e.contentEnd} @slotchange=${this.handleContentEndSlotChange}></slot><div class=${o({[a.hide]:!this.userSlotHasElements,[e.user]:!0})}><slot name=${e.user} @slotchange=${this.handleUserSlotChange}></slot></div></div></div><slot name=${e.navSecondary} @slotchange=${this.handleSecondarySlotChange}></slot><slot name=${e.navTertiary} @slotchange=${this.handleTertiarySlotChange}></slot>`}};h("calcite-navigation",i);export{i as Navigation};