@esri/calcite-components
Version:
Web Components for Esri's Calcite Design System.
6 lines • 11.7 kB
JavaScript
/*!
* All material copyright ESRI, All Rights Reserved, unless otherwise specified.
* See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
* v1.5.0-next.4
*/
import{r as t,c as e,h as i,F as a,a as n}from"./p-8789682d.js";import{s as o,p as s,t as r}from"./p-68f223ec.js";import{c,u as l,d}from"./p-0d8324b6.js";import{s as h,a as m,c as p}from"./p-deebcc06.js";import{c as f}from"./p-c8e46b02.js";import{S as u}from"./p-14d9f732.js";import{H as g}from"./p-36712ef1.js";import{S as b,C as x,I as v}from"./p-d511a532.js";import{c as y,d as k}from"./p-743ed09c.js";import{c as z,s as w,d as S,u as j}from"./p-9dd9a26d.js";import"./p-d2aa9245.js";import"./p-9280476e.js";import"./p-7fb6664e.js";import"./p-4929e834.js";const C=class{constructor(i){t(this,i),this.calcitePanelClose=e(this,"calcitePanelClose",6),this.calcitePanelScroll=e(this,"calcitePanelScroll",6),this.resizeObserver=f("resize",(()=>this.resizeHandler())),this.resizeHandler=()=>{const{panelScrollEl:t}=this;t&&"number"==typeof t.scrollHeight&&"number"==typeof t.offsetHeight&&(t.tabIndex=t.scrollHeight>t.offsetHeight?0:-1)},this.setContainerRef=t=>{this.containerEl=t},this.setCloseRef=t=>{this.closeButtonEl=t},this.setBackRef=t=>{this.backButtonEl=t},this.panelKeyDownHandler=t=>{this.closable&&"Escape"===t.key&&!t.defaultPrevented&&(this.close(),t.preventDefault())},this.close=()=>{this.closed=!0,this.calcitePanelClose.emit()},this.panelScrollHandler=()=>{this.calcitePanelScroll.emit()},this.handleHeaderActionsStartSlotChange=t=>{const e=t.target.assignedElements({flatten:!0});this.hasStartActions=!!e.length},this.handleHeaderActionsEndSlotChange=t=>{const e=t.target.assignedElements({flatten:!0});this.hasEndActions=!!e.length},this.handleHeaderMenuActionsSlotChange=t=>{const e=t.target.assignedElements({flatten:!0});this.hasMenuItems=!!e.length},this.handleActionBarSlotChange=t=>{const e=o(t).filter((t=>t?.matches("calcite-action-bar")));e.forEach((t=>t.layout="horizontal")),this.hasActionBar=!!e.length},this.handleHeaderContentSlotChange=t=>{const e=t.target.assignedElements({flatten:!0});this.hasHeaderContent=!!e.length},this.handleFooterSlotChange=t=>{const e=t.target.assignedElements({flatten:!0});this.hasFooterContent=!!e.length},this.handleFooterActionsSlotChange=t=>{const e=t.target.assignedElements({flatten:!0});this.hasFooterActions=!!e.length},this.handleFabSlotChange=t=>{const e=t.target.assignedElements({flatten:!0});this.hasFab=!!e.length},this.setPanelScrollEl=t=>{this.panelScrollEl=t,this.resizeObserver?.disconnect(),t&&(this.resizeObserver?.observe(t),this.resizeHandler())},this.closed=!1,this.disabled=!1,this.closable=!1,this.headingLevel=void 0,this.loading=!1,this.heading=void 0,this.description=void 0,this.menuOpen=!1,this.messageOverrides=void 0,this.messages=void 0,this.hasStartActions=!1,this.hasEndActions=!1,this.hasMenuItems=!1,this.hasHeaderContent=!1,this.hasActionBar=!1,this.hasFooterContent=!1,this.hasFooterActions=!1,this.hasFab=!1,this.defaultMessages=void 0,this.effectiveLocale=""}onMessagesChange(){}connectedCallback(){c(this),y(this),z(this)}async componentWillLoad(){h(this),await w(this)}componentDidLoad(){m(this)}componentDidRender(){l(this)}disconnectedCallback(){d(this),k(this),S(this),this.resizeObserver?.disconnect()}effectiveLocaleChange(){j(this,this.effectiveLocale)}async setFocus(){await p(this),s(this.containerEl)}async scrollContentTo(t){this.panelScrollEl?.scrollTo(t)}renderHeaderContent(){const{heading:t,headingLevel:e,description:a,hasHeaderContent:n}=this,o=t?i(g,{class:x.heading,level:e},t):null,s=a?i("span",{class:x.description},a):null;return n||!o&&!s?null:i("div",{class:x.headerContent,key:"header-content"},o,s)}renderActionBar(){return i("div",{class:x.actionBarContainer,hidden:!this.hasActionBar},i("slot",{name:b.actionBar,onSlotchange:this.handleActionBarSlotChange}))}renderHeaderSlottedContent(){return i("div",{class:x.headerContent,hidden:!this.hasHeaderContent,key:"slotted-header-content"},i("slot",{name:b.headerContent,onSlotchange:this.handleHeaderContentSlotChange}))}renderHeaderStartActions(){const{hasStartActions:t}=this;return i("div",{class:{[x.headerActionsStart]:!0,[x.headerActions]:!0},hidden:!t,key:"header-actions-start"},i("slot",{name:b.headerActionsStart,onSlotchange:this.handleHeaderActionsStartSlotChange}))}renderHeaderActionsEnd(){const{close:t,hasEndActions:e,messages:a,closable:n,hasMenuItems:o}=this,s=a.close,r=n?i("calcite-action",{"aria-label":s,"data-test":"close",icon:v.close,onClick:t,text:s,ref:this.setCloseRef}):null,c=i("slot",{name:b.headerActionsEnd,onSlotchange:this.handleHeaderActionsEndSlotChange});return i("div",{class:{[x.headerActionsEnd]:!0,[x.headerActions]:!0},hidden:!(e||r||o),key:"header-actions-end"},c,this.renderMenu(),r)}renderMenu(){const{hasMenuItems:t,messages:e,menuOpen:a}=this;return i("calcite-action-menu",{flipPlacements:["top","bottom"],hidden:!t,key:"menu",label:e.options,open:a,placement:"bottom-end"},i("calcite-action",{icon:v.menu,slot:u.trigger,text:e.options}),i("slot",{name:b.headerMenuActions,onSlotchange:this.handleHeaderMenuActionsSlotChange}))}renderHeaderNode(){const{hasHeaderContent:t,hasStartActions:e,hasEndActions:a,closable:n,hasMenuItems:o}=this,s=this.renderHeaderContent();return i("header",{class:x.header,hidden:!(t||s||e||a||n||o)},this.renderHeaderStartActions(),this.renderHeaderSlottedContent(),s,this.renderHeaderActionsEnd())}renderFooterNode(){const{hasFooterContent:t,hasFooterActions:e}=this;return i("footer",{class:x.footer,hidden:!(t||e)},i("slot",{key:"footer-slot",name:b.footer,onSlotchange:this.handleFooterSlotChange}),i("slot",{key:"footer-actions-slot",name:b.footerActions,onSlotchange:this.handleFooterActionsSlotChange}))}renderContent(){const{hasFab:t}=this,e=i("slot",{key:"default-slot"}),a=t?i("section",{class:x.contentContainer},e):e;return i("div",{class:{[x.contentWrapper]:!0,[x.contentContainer]:!t,[x.contentHeight]:t},onScroll:this.panelScrollHandler,ref:this.setPanelScrollEl},a,this.renderFab())}renderFab(){return i("div",{class:x.fabContainer,hidden:!this.hasFab},i("slot",{name:b.fab,onSlotchange:this.handleFabSlotChange}))}render(){const{loading:t,panelKeyDownHandler:e,closed:n,closable:o}=this,s=i("article",{"aria-busy":r(t),class:x.container,hidden:n,onKeyDown:e,tabIndex:o?0:-1,ref:this.setContainerRef},this.renderHeaderNode(),this.renderActionBar(),this.renderContent(),this.renderFooterNode());return i(a,null,t?i("calcite-scrim",{loading:t}):null,s)}static get assetsDirs(){return["assets"]}get el(){return n(this)}static get watchers(){return{messageOverrides:["onMessagesChange"],effectiveLocale:["effectiveLocaleChange"]}}};C.style="@keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in-down{0%{opacity:0;transform:translate3D(0, -5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;transform:translate3D(0, 5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-right{0%{opacity:0;transform:translate3D(-5px, 0, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-left{0%{opacity:0;transform:translate3D(5px, 0, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-scale{0%{opacity:0;transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;animation-fill-mode:both;animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{animation-name:in}.calcite-animate__in-down{animation-name:in-down}.calcite-animate__in-up{animation-name:in-up}.calcite-animate__in-right{animation-name:in-right}.calcite-animate__in-left{animation-name:in-left}.calcite-animate__in-scale{animation-name:in-scale}@media (prefers-reduced-motion: reduce){:root{--calcite-internal-duration-factor:0.01}}:host{box-sizing:border-box;background-color:var(--calcite-ui-foreground-1);color:var(--calcite-ui-text-2);font-size:var(--calcite-font-size--1)}:host *{box-sizing:border-box}:root{--calcite-floating-ui-transition:var(--calcite-animation-timing);--calcite-floating-ui-z-index:var(--calcite-app-z-index-dropdown)}:host([hidden]){display:none}:host([disabled]){cursor:default;-webkit-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) *,:host([disabled]) ::slotted(*){pointer-events:none}:host{position:relative;display:flex;block-size:100%;inline-size:100%;flex:1 1 auto;overflow:hidden;--calcite-min-header-height:calc(var(--calcite-icon-size) * 3);--calcite-panel-footer-padding:0.5rem}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}.header{margin:0px;display:flex;align-content:space-between;align-items:center;fill:var(--calcite-ui-text-2);color:var(--calcite-ui-text-2)}.heading{margin:0px;padding:0px;font-weight:var(--calcite-font-weight-medium)}.header .heading{flex:1 1 auto;padding:0.5rem}.container{margin:0px;display:flex;inline-size:100%;flex:1 1 auto;flex-direction:column;align-items:stretch;background-color:var(--calcite-ui-background);padding:0px;transition:max-block-size var(--calcite-animation-timing), inline-size var(--calcite-animation-timing)}.container[hidden]{display:none}.header{border-block-end:1px solid;z-index:var(--calcite-app-z-index-header);inline-size:100%;align-items:stretch;justify-content:flex-start;background-color:var(--calcite-ui-foreground-1);border-block-end-color:var(--calcite-ui-border-3);flex:0 0 auto}.action-bar-container{border-block-end:1px solid;z-index:var(--calcite-app-z-index-header);inline-size:100%;border-block-end-color:var(--calcite-ui-border-3)}.action-bar-container ::slotted(calcite-action-bar){inline-size:100%}.header-content{display:flex;flex-direction:column;overflow:hidden;padding-inline:0.75rem;padding-block:0.875rem;margin-inline-end:auto}.header-content .heading,.header-content .description{display:block;overflow-wrap:break-word;padding:0px}.header-content .heading{margin-inline:0px;margin-block:0px 0.25rem;font-size:var(--calcite-font-size-0);line-height:1.25rem;font-weight:var(--calcite-font-weight-medium)}.header-content .heading:only-child{margin-block-end:0px}.header-content .description{font-size:var(--calcite-font-size--1);line-height:1rem;color:var(--calcite-ui-text-2)}.back-button{border-width:0px;border-style:solid;border-color:var(--calcite-ui-border-3);border-inline-end-width:1px}.header-actions{display:flex;flex-direction:row;flex-wrap:nowrap;align-items:stretch}.header-actions--end{margin-inline-start:auto}.content-wrapper{overflow:auto}.content-height{block-size:100%}.content-container{display:flex;flex:1 1 auto;flex-direction:column;flex-wrap:nowrap;align-items:stretch;background-color:var(--calcite-ui-background)}.footer{border-block-start:1px solid;display:flex;inline-size:100%;justify-content:space-evenly;background-color:var(--calcite-ui-foreground-1);border-block-start-color:var(--calcite-ui-border-3);flex:0 0 auto;padding:var(--calcite-panel-footer-padding)}.fab-container{position:sticky;inset-block-end:0px;z-index:var(--calcite-app-z-index-sticky);margin-block:0px;margin-inline:auto;display:block;padding:0.5rem;inset-inline:0;inline-size:-moz-fit-content;inline-size:fit-content}[hidden]{display:none}";export{C as calcite_panel}