@esri/calcite-components
Version:
Web Components for Esri's Calcite Design System.
5 lines • 16.7 kB
JavaScript
var __awaiter=this&&this.__awaiter||function(e,t,n,a){function i(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,o){function r(e){try{c(a.next(e))}catch(e){o(e)}}function l(e){try{c(a["throw"](e))}catch(e){o(e)}}function c(e){e.done?n(e.value):i(e.value).then(r,l)}c((a=a.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},a,i,o,r;return r={next:l(0),throw:l(1),return:l(2)},typeof Symbol==="function"&&(r[Symbol.iterator]=function(){return this}),r;function l(e){return function(t){return c([e,t])}}function c(r){if(a)throw new TypeError("Generator is already executing.");while(n)try{if(a=1,i&&(o=r[0]&2?i["return"]:r[0]?i["throw"]||((o=i["return"])&&o.call(i),0):i.next)&&!(o=o.call(i,r[1])).done)return o;if(i=0,o)r=[r[0]&2,o.value];switch(r[0]){case 0:case 1:o=r;break;case 4:n.label++;return{value:r[1],done:false};case 5:n.label++;i=r[1];r=[0];continue;case 7:r=n.ops.pop();n.trys.pop();continue;default:if(!(o=n.trys,o=o.length>0&&o[o.length-1])&&(r[0]===6||r[0]===2)){n=0;continue}if(r[0]===3&&(!o||r[1]>o[0]&&r[1]<o[3])){n.label=r[1];break}if(r[0]===6&&n.label<o[1]){n.label=o[1];o=r;break}if(o&&n.label<o[2]){n.label=o[2];n.ops.push(r);break}if(o[2])n.ops.pop();n.trys.pop();continue}r=t.call(e,n)}catch(e){r=[6,e];i=0}finally{a=o=0}if(r[0]&5)throw r[1];return{value:r[0]?r[1]:void 0,done:true}}};
/*!
* All material copyright ESRI, All Rights Reserved, unless otherwise specified.
* See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
*/import{r as registerInstance,c as createEvent,h,F as Fragment,g as getElement}from"./index-bd94948c.js";import{a as getElementDir,g as getSlotted}from"./dom-e7fa77b9.js";import{H as Heading}from"./Heading-d5f1710a.js";import{S as SLOTS$1}from"./resources-027bd8f9.js";import{c as connectConditionalSlotComponent,d as disconnectConditionalSlotComponent}from"./conditionalSlot-67f579ff.js";import{u as updateHostInteraction}from"./interactive-48b5cc0f.js";import"./guid-196bd5ea.js";import"./observers-46118290.js";var CSS={backButton:"back-button",container:"container",header:"header",heading:"heading",summary:"summary",headerContent:"header-content",headerActions:"header-actions",headerActionsEnd:"header-actions--end",headerActionsStart:"header-actions--start",contentWrapper:"content-wrapper",contentContainer:"content-container",contentHeight:"content-height",fabContainer:"fab-container",footer:"footer",menuContainer:"menu-container",menuButton:"menu-button",menu:"menu",menuOpen:"menu--open"};var ICONS={close:"x",menu:"ellipsis",backLeft:"chevron-left",backRight:"chevron-right"};var SLOTS={headerActionsStart:"header-actions-start",headerActionsEnd:"header-actions-end",headerMenuActions:"header-menu-actions",headerContent:"header-content",fab:"fab",footer:"footer",footerActions:"footer-actions"};var TEXT={back:"Back",close:"Close",open:"Open",options:"Options"};var HEADING_LEVEL=3;var panelCss="@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 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;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:host{-webkit-box-sizing:border-box;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 *{-webkit-box-sizing:border-box;box-sizing:border-box}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{position:relative;display:-ms-flexbox;display:flex;width:100%;-ms-flex:1 1 auto;flex:1 1 auto;overflow:hidden;--calcite-min-header-height:calc(var(--calcite-icon-size) * 3);--calcite-panel-max-height:unset;--calcite-panel-width:100%;--calcite-panel-min-width:unset;--calcite-panel-max-width:unset}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}.header{margin:0px;display:-ms-flexbox;display:flex;-ms-flex-line-pack:justify;align-content:space-between;-ms-flex-align:center;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{-ms-flex:1 1 auto;flex:1 1 auto;padding:0.5rem}h1.heading{font-size:var(--calcite-font-size-2);line-height:1.5rem}h2.heading{font-size:var(--calcite-font-size-1);line-height:1.5rem}h3.heading{font-size:var(--calcite-font-size-0);line-height:1.25rem}h4.heading,h5.heading{font-size:var(--calcite-font-size--1);line-height:1rem}.container{margin:0px;display:-ms-flexbox;display:flex;width:100%;-ms-flex:1 1 auto;flex:1 1 auto;-ms-flex-direction:column;flex-direction:column;-ms-flex-align:stretch;align-items:stretch;background-color:var(--calcite-ui-background);padding:0px;max-height:var(--calcite-panel-max-height);width:var(--calcite-panel-width);max-width:var(--calcite-panel-max-width);min-width:var(--calcite-panel-min-width);-webkit-transition:max-height var(--calcite-animation-timing), width var(--calcite-animation-timing);transition:max-height var(--calcite-animation-timing), width var(--calcite-animation-timing)}:host([height-scale=s]){--calcite-panel-max-height:40vh}:host([height-scale=m]){--calcite-panel-max-height:60vh}:host([height-scale=l]){--calcite-panel-max-height:80vh}:host([width-scale=s]){--calcite-panel-width:calc(var(--calcite-panel-width-multiplier) * 12vw);--calcite-panel-max-width:calc(var(--calcite-panel-width-multiplier) * 300px);--calcite-panel-min-width:calc(var(--calcite-panel-width-multiplier) * 150px)}:host([width-scale=m]){--calcite-panel-width:calc(var(--calcite-panel-width-multiplier) * 20vw);--calcite-panel-max-width:calc(var(--calcite-panel-width-multiplier) * 420px);--calcite-panel-min-width:calc(var(--calcite-panel-width-multiplier) * 240px)}:host([width-scale=l]){--calcite-panel-width:calc(var(--calcite-panel-width-multiplier) * 45vw);--calcite-panel-max-width:calc(var(--calcite-panel-width-multiplier) * 680px);--calcite-panel-min-width:calc(var(--calcite-panel-width-multiplier) * 340px)}.container[hidden]{display:none}:host([loading]) .container,:host([disabled]) .container{position:relative;z-index:1}.header{border-bottom:1px solid;position:-webkit-sticky;position:sticky;top:0px;width:100%;-ms-flex-align:stretch;align-items:stretch;-ms-flex-pack:start;justify-content:flex-start;background-color:var(--calcite-ui-foreground-1);border-bottom-color:var(--calcite-ui-border-3);-ms-flex:0 0 auto;flex:0 0 auto;z-index:2}.header-content{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;padding-left:0.75rem;padding-right:0.75rem;padding-top:0.875rem;padding-bottom:0.875rem;overflow:hidden;-webkit-margin-end:auto;margin-inline-end:auto}.header-content .heading,.header-content .summary{display:block;overflow-wrap:break-word;padding:0px}.header-content .heading{margin-left:0px;margin-right:0px;margin-top:0px;margin-bottom: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-bottom:0px}.header-content .summary{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:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-wrap:nowrap;flex-wrap:nowrap;-ms-flex-align:stretch;align-items:stretch}.header-actions--end,.menu-container:only-child{-webkit-margin-start:auto;margin-inline-start:auto}.menu-button{position:relative;height:100%;-ms-flex:0 1 auto;flex:0 1 auto;-ms-flex-item-align:stretch;align-self:stretch}.menu{min-width:10rem;-ms-flex-flow:column nowrap;flex-flow:column nowrap}.content-wrapper{overflow:auto}.content-height{height:100%}.content-container{display:-ms-flexbox;display:flex;-ms-flex:1 1 auto;flex:1 1 auto;-ms-flex-direction:column;flex-direction:column;-ms-flex-wrap:nowrap;flex-wrap:nowrap;-ms-flex-align:stretch;align-items:stretch;background-color:var(--calcite-ui-background)}.footer{border-top:1px solid;position:-webkit-sticky;position:sticky;bottom:0px;display:-ms-flexbox;display:flex;width:100%;-ms-flex-pack:space-evenly;justify-content:space-evenly;background-color:var(--calcite-ui-foreground-1);border-top-color:var(--calcite-ui-border-3);-ms-flex:0 0 auto;flex:0 0 auto;min-height:3rem;padding:0.5rem}.fab-container{position:-webkit-sticky;position:sticky;bottom:0px;left:0px;right:0px;margin-top:0px;margin-bottom:0px;margin-left:auto;margin-right:auto;display:block;padding:0.5rem;width:-moz-fit-content;width:-webkit-fit-content;width:fit-content;z-index:1}";var Panel=function(){function e(e){var t=this;registerInstance(this,e);this.calcitePanelDismissedChange=createEvent(this,"calcitePanelDismissedChange",7);this.calcitePanelScroll=createEvent(this,"calcitePanelScroll",7);this.calcitePanelBackClick=createEvent(this,"calcitePanelBackClick",7);this.dismissed=false;this.disabled=false;this.dismissible=false;this.showBackButton=false;this.loading=false;this.menuOpen=false;this.setContainerRef=function(e){t.containerEl=e};this.setDismissRef=function(e){t.dismissButtonEl=e};this.setBackRef=function(e){t.backButtonEl=e};this.panelKeyDownHandler=function(e){if(e.key==="Escape"){t.dismiss()}};this.dismiss=function(){t.dismissed=true};this.panelScrollHandler=function(){t.calcitePanelScroll.emit()};this.backButtonClick=function(){t.calcitePanelBackClick.emit()}}e.prototype.dismissedHandler=function(){this.calcitePanelDismissedChange.emit()};e.prototype.componentDidRender=function(){updateHostInteraction(this)};e.prototype.connectedCallback=function(){connectConditionalSlotComponent(this)};e.prototype.disconnectedCallback=function(){disconnectConditionalSlotComponent(this)};e.prototype.setFocus=function(e){return __awaiter(this,void 0,void 0,(function(){var t,n,a;return __generator(this,(function(i){if(e==="dismiss-button"){(t=this.dismissButtonEl)===null||t===void 0?void 0:t.setFocus();return[2]}if(e==="back-button"){(n=this.backButtonEl)===null||n===void 0?void 0:n.setFocus();return[2]}(a=this.containerEl)===null||a===void 0?void 0:a.focus();return[2]}))}))};e.prototype.scrollContentTo=function(e){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(n){(t=this.panelScrollEl)===null||t===void 0?void 0:t.scrollTo(e);return[2]}))}))};e.prototype.renderBackButton=function(){var e=this.el;var t=getElementDir(e)==="rtl";var n=this,a=n.showBackButton,i=n.intlBack,o=n.backButtonClick;var r=i||TEXT.back;var l=t?ICONS.backRight:ICONS.backLeft;return a?h("calcite-action",{"aria-label":r,class:CSS.backButton,icon:l,key:"back-button",onClick:o,ref:this.setBackRef,scale:"s",slot:SLOTS.headerActionsStart,text:r}):null};e.prototype.renderHeaderContent=function(){var e=this,t=e.heading,n=e.headingLevel,a=e.summary;var i=t?h(Heading,{class:CSS.heading,level:n||HEADING_LEVEL},t):null;var o=a?h("span",{class:CSS.summary},a):null;return i||o?h("div",{class:CSS.headerContent,key:"header-content"},i,o):null};e.prototype.renderHeaderSlottedContent=function(){return h("div",{class:CSS.headerContent,key:"slotted-header-content"},h("slot",{name:SLOTS.headerContent}))};e.prototype.renderHeaderStartActions=function(){var e;var t=this.el;var n=getSlotted(t,SLOTS.headerActionsStart);return n?h("div",{class:(e={},e[CSS.headerActionsStart]=true,e[CSS.headerActions]=true,e),key:"header-actions-start"},h("slot",{name:SLOTS.headerActionsStart})):null};e.prototype.renderHeaderActionsEnd=function(){var e;var t=this,n=t.dismiss,a=t.dismissible,i=t.el,o=t.intlClose;var r=o||TEXT.close;var l=a?h("calcite-action",{"aria-label":r,icon:ICONS.close,onClick:n,ref:this.setDismissRef,text:r}):null;var c=h("slot",{name:SLOTS.headerActionsEnd});var s=getSlotted(i,SLOTS.headerActionsEnd);return s||l?h("div",{class:(e={},e[CSS.headerActionsEnd]=true,e[CSS.headerActions]=true,e),key:"header-actions-end"},c,l):null};e.prototype.renderMenu=function(){var e=this,t=e.el,n=e.intlOptions,a=e.menuOpen;var i=getSlotted(t,SLOTS.headerMenuActions);return i?h("calcite-action-menu",{flipPlacements:["top","bottom"],key:"menu",label:n||TEXT.options,open:a,placement:"bottom-end"},h("calcite-action",{icon:ICONS.menu,slot:SLOTS$1.trigger,text:n||TEXT.options}),h("slot",{name:SLOTS.headerMenuActions})):null};e.prototype.renderHeaderNode=function(){var e=this,t=e.el,n=e.showBackButton;var a=this.renderBackButton();var i=getSlotted(t,SLOTS.headerContent);var o=i?this.renderHeaderSlottedContent():this.renderHeaderContent();var r=this.renderHeaderStartActions();var l=this.renderHeaderActionsEnd();var c=this.renderMenu();return r||o||l||c||n?h("header",{class:CSS.header},a,r,o,l,c):null};e.prototype.renderFooterNode=function(){var e=this.el;var t=getSlotted(e,SLOTS.footer);var n=getSlotted(e,SLOTS.footerActions);return t||n?h("footer",{class:CSS.footer,key:"footer"},t?h("slot",{key:"footer-slot",name:SLOTS.footer}):null,n?h("slot",{key:"footer-actions-slot",name:SLOTS.footerActions}):null):null};e.prototype.renderContent=function(){var e,t;var n=this;var a=this.el;var i=getSlotted(a,SLOTS.fab);var o=h("slot",{key:"default-slot"});var r="content-wrapper";return i?h("div",{class:(e={},e[CSS.contentWrapper]=true,e[CSS.contentHeight]=true,e),key:r,onScroll:this.panelScrollHandler,ref:function(e){return n.panelScrollEl=e},tabIndex:0},h("section",{class:CSS.contentContainer},o),this.renderFab()):h("section",{class:(t={},t[CSS.contentWrapper]=true,t[CSS.contentContainer]=true,t),key:r,onScroll:this.panelScrollHandler,ref:function(e){return n.panelScrollEl=e},tabIndex:0},o)};e.prototype.renderFab=function(){return h("div",{class:CSS.fabContainer},h("slot",{name:SLOTS.fab}))};e.prototype.render=function(){var e=this,t=e.dismissed,n=e.dismissible,a=e.loading,i=e.panelKeyDownHandler;var o=h("article",{"aria-busy":a.toString(),class:CSS.container,hidden:n&&t,onKeyDown:i,ref:this.setContainerRef,tabIndex:n?0:-1},this.renderHeaderNode(),this.renderContent(),this.renderFooterNode());return h(Fragment,null,a?h("calcite-scrim",{loading:a}):null,o)};Object.defineProperty(e.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(e,"watchers",{get:function(){return{dismissed:["dismissedHandler"]}},enumerable:false,configurable:true});return e}();Panel.style=panelCss;export{Panel as calcite_panel};