UNPKG

@esri/calcite-components

Version:

Web Components for Esri's Calcite Design System.

570 lines (557 loc) • 39.8 kB
/*! * 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 */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); const index = require('./index-55f8a3b7.js'); const conditionalSlot = require('./conditionalSlot-4472b3c1.js'); const dom = require('./dom-18ca68ff.js'); const locale = require('./locale-fc347462.js'); const math = require('./math-202e427c.js'); const t9n = require('./t9n-14d528c4.js'); const resources = require('./resources-45d84c94.js'); require('./observers-83b3999d.js'); require('./guid-db20443e.js'); require('./key-2ce02f02.js'); const CSS$2 = { main: "main", content: "content", contentBehind: "content--behind", footer: "footer", positionedSlotWrapper: "positioned-slot-wrapper", container: "container", contentBehindCenterContent: "center-content" }; const SLOTS$2 = { centerRow: "center-row", panelStart: "panel-start", panelEnd: "panel-end", panelTop: "panel-top", panelBottom: "panel-bottom", header: "header", footer: "footer", alerts: "alerts", modals: "modals" }; const shellCss = "@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{position:absolute;inset:0px;display:flex;block-size:100%;inline-size:100%;flex-direction:column;overflow:hidden;--calcite-shell-tip-spacing:26vw}.main{position:relative;display:flex;block-size:100%;inline-size:100%;flex:1 1 auto;flex-direction:row;justify-content:space-between;overflow:hidden}.content{display:flex;block-size:100%;inline-size:100%;flex-direction:column;flex-wrap:nowrap;overflow:auto}.content ::slotted(calcite-shell-center-row),.content ::slotted(calcite-panel),.content ::slotted(calcite-flow){flex:1 1 auto;align-self:stretch;max-block-size:unset}.content--behind{position:absolute;inset:0px;border-width:0px;z-index:calc(var(--calcite-app-z-index) - 1);display:initial}::slotted(calcite-shell-center-row){inline-size:unset}::slotted(.header .heading){font-size:var(--calcite-font-size--2);line-height:1.375;font-weight:var(--calcite-font-weight-normal)}slot[name=panel-end]::slotted(calcite-shell-panel){margin-inline-start:auto}::slotted(calcite-panel),::slotted(calcite-flow){border-width:1px;border-inline-start-width:0px;border-inline-end-width:0px;border-style:solid;border-color:var(--calcite-ui-border-3)}slot[name=center-row]::slotted(calcite-shell-center-row:not([detached])),slot[name=panel-top]::slotted(calcite-shell-center-row:not([detached])),slot[name=panel-bottom]::slotted(calcite-shell-center-row:not([detached])){border-inline-start-width:1px;border-inline-end-width:1px;border-color:var(--calcite-ui-border-3)}.center-content{display:flex;flex-direction:column;justify-content:space-between;block-size:100%;inline-size:100%;min-inline-size:0}::slotted(calcite-shell-center-row){flex:none;align-self:stretch}::slotted(calcite-tip-manager){position:absolute;z-index:var(--calcite-app-z-index-toast);box-sizing:border-box}@keyframes in-up{0%{opacity:0;transform:translate3D(0, 5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}::slotted(calcite-tip-manager){animation:in-up var(--calcite-internal-animation-timing-slow) ease-in-out;border-radius:0.25rem;--tw-shadow:0 6px 20px -4px rgba(0, 0, 0, 0.1), 0 4px 12px -2px rgba(0, 0, 0, 0.08);--tw-shadow-colored:0 6px 20px -4px var(--tw-shadow-color), 0 4px 12px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);inset-block-end:0.5rem;inset-inline:var(--calcite-shell-tip-spacing)}slot[name=center-row]::slotted(calcite-shell-center-row),slot[name=panel-bottom]::slotted(calcite-shell-center-row){margin-block-start:auto}slot[name=panel-top]::slotted(calcite-shell-center-row){margin-block-end:auto}.position-wrapper{position:absolute;pointer-events:none;inset:0}"; const Shell = class { constructor(hostRef) { index.registerInstance(this, hostRef); // -------------------------------------------------------------------------- // // Private Methods // // -------------------------------------------------------------------------- this.handleHeaderSlotChange = (event) => { this.hasHeader = !!dom.slotChangeHasAssignedElement(event); }; this.handleFooterSlotChange = (event) => { this.hasFooter = !!dom.slotChangeHasAssignedElement(event); }; this.handleAlertsSlotChange = (event) => { this.hasAlerts = !!dom.slotChangeHasAssignedElement(event); dom.slotChangeGetAssignedElements(event)?.map((el) => { if (el.nodeName === "CALCITE-ALERT") { el.slottedInShell = true; } }); }; this.handleModalsSlotChange = (event) => { this.hasModals = !!dom.slotChangeHasAssignedElement(event); dom.slotChangeGetAssignedElements(event)?.map((el) => { if (el.nodeName === "CALCITE-MODAL") { el.slottedInShell = true; } }); }; this.contentBehind = false; this.hasHeader = false; this.hasFooter = false; this.hasAlerts = false; this.hasModals = false; } // -------------------------------------------------------------------------- // // Lifecycle // // -------------------------------------------------------------------------- connectedCallback() { conditionalSlot.connectConditionalSlotComponent(this); } disconnectedCallback() { conditionalSlot.disconnectConditionalSlotComponent(this); } // -------------------------------------------------------------------------- // // Render Methods // // -------------------------------------------------------------------------- renderHeader() { return (index.h("div", { hidden: !this.hasHeader }, index.h("slot", { key: "header", name: SLOTS$2.header, onSlotchange: this.handleHeaderSlotChange }))); } renderFooter() { return (index.h("div", { class: CSS$2.footer, hidden: !this.hasFooter, key: "footer" }, index.h("slot", { name: SLOTS$2.footer, onSlotchange: this.handleFooterSlotChange }))); } renderAlerts() { return (index.h("div", { hidden: !this.hasAlerts }, index.h("slot", { key: "alerts", name: SLOTS$2.alerts, onSlotchange: this.handleAlertsSlotChange }))); } renderModals() { return (index.h("div", { hidden: !this.hasModals }, index.h("slot", { key: "modals", name: SLOTS$2.modals, onSlotchange: this.handleModalsSlotChange }))); } renderContent() { const defaultSlotNode = index.h("slot", { key: "default-slot" }); const deprecatedCenterRowSlotNode = (index.h("slot", { key: "center-row-slot", name: SLOTS$2.centerRow })); const panelBottomSlotNode = index.h("slot", { key: "panel-bottom-slot", name: SLOTS$2.panelBottom }); const panelTopSlotNode = index.h("slot", { key: "panel-top-slot", name: SLOTS$2.panelTop }); const contentContainerKey = "content-container"; const content = !!this.contentBehind ? [ index.h("div", { class: { [CSS$2.content]: true, [CSS$2.contentBehind]: true }, key: contentContainerKey }, defaultSlotNode), index.h("div", { class: CSS$2.contentBehindCenterContent }, panelTopSlotNode, panelBottomSlotNode, deprecatedCenterRowSlotNode) ] : [ index.h("div", { class: CSS$2.content, key: contentContainerKey }, panelTopSlotNode, defaultSlotNode, panelBottomSlotNode, deprecatedCenterRowSlotNode) ]; return content; } renderMain() { return (index.h("div", { class: CSS$2.main }, index.h("slot", { name: SLOTS$2.panelStart }), this.renderContent(), index.h("slot", { name: SLOTS$2.panelEnd }))); } renderPositionedSlots() { return (index.h("div", { class: CSS$2.positionedSlotWrapper }, this.renderAlerts(), this.renderModals())); } render() { return (index.h(index.Fragment, null, this.renderHeader(), this.renderMain(), this.renderFooter(), this.renderPositionedSlots())); } get el() { return index.getElement(this); } }; Shell.style = shellCss; const CSS$1 = { actionBarContainer: "action-bar-container", content: "content" }; const SLOTS$1 = { actionBar: "action-bar" }; const shellCenterRowCss = "@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{z-index:var(--calcite-app-z-index);display:flex;flex:1 1 auto;overflow:hidden;background-color:transparent}.content{margin:0px;display:flex;block-size:100%;inline-size:100%;overflow:hidden;flex:1 0 0}.action-bar-container{display:flex}:host([detached]){margin-inline:0.5rem;margin-block:0.5rem 1.5rem}@keyframes in-up{0%{opacity:0;transform:translate3D(0, 5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}:host([detached]){animation:in-up var(--calcite-internal-animation-timing-slow) ease-in-out;border-radius:0.25rem;border-width:0px;--tw-shadow:0 4px 8px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);--tw-shadow-colored:0 4px 8px -1px var(--tw-shadow-color), 0 2px 4px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}:host([position=end]){align-self:flex-end}:host([position=start]){align-self:flex-start}:host([height-scale=s]){block-size:33.333333%}:host([height-scale=m]){block-size:70%}:host([height-scale=l]){block-size:100%}:host([height-scale=l][detached]){block-size:calc(100% - 2rem)}::slotted(calcite-panel){block-size:100%;inline-size:100%}::slotted(calcite-action-bar),::slotted(calcite-action-bar[position=end]){border-inline-end:1px solid;border-color:var(--calcite-ui-border-3)}"; const ShellCenterRow = class { constructor(hostRef) { index.registerInstance(this, hostRef); this.detached = false; this.heightScale = "s"; this.position = "end"; } // -------------------------------------------------------------------------- // // Lifecycle // // -------------------------------------------------------------------------- connectedCallback() { conditionalSlot.connectConditionalSlotComponent(this); } disconnectedCallback() { conditionalSlot.disconnectConditionalSlotComponent(this); } // -------------------------------------------------------------------------- // // Render Methods // // -------------------------------------------------------------------------- render() { const { el } = this; const contentNode = (index.h("div", { class: CSS$1.content }, index.h("slot", null))); const actionBar = dom.getSlotted(el, SLOTS$1.actionBar); const actionBarNode = actionBar ? (index.h("div", { class: CSS$1.actionBarContainer, key: "action-bar" }, index.h("slot", { name: SLOTS$1.actionBar }))) : null; const children = [actionBarNode, contentNode]; if (actionBar?.position === "end") { children.reverse(); } return index.h(index.Fragment, null, children); } get el() { return index.getElement(this); } }; ShellCenterRow.style = shellCenterRowCss; const CSS = { container: "container", content: "content", contentHeader: "content__header", contentBody: "content__body", contentFloat: "content--float", contentOverlay: "content--overlay", separator: "separator" }; const SLOTS = { actionBar: "action-bar", header: "header" }; const shellPanelCss = "@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}}: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{pointer-events:none;position:relative;display:flex;flex:0 1 auto;align-items:stretch;z-index:var(--calcite-shell-panel-z-index, var(--calcite-app-z-index));--calcite-shell-panel-detached-max-height:unset;--calcite-shell-panel-max-height:unset;--calcite-shell-panel-shadow-block-start-internal:0 4px 8px -1px rgba(0, 0, 0, 0.08),\n 0 2px 4px -1px rgba(0, 0, 0, 0.04);--calcite-shell-panel-shadow-block-end-internal:0 -4px 8px -1px rgba(0, 0, 0, 0.08),\n 0 -2px 4px -1px rgba(0, 0, 0, 0.04);--calcite-shell-panel-shadow-inline-start-internal:4px 0 8px -1px rgba(0, 0, 0, 0.08),\n 2px 0 4px -1px rgba(0, 0, 0, 0.04);--calcite-shell-panel-shadow-inline-end-internal:-4px 0 8px -1px rgba(0, 0, 0, 0.08),\n -2px 0 4px -1px rgba(0, 0, 0, 0.04)}.calcite--rtl.content--overlay{--calcite-shell-panel-shadow-inline-start-internal:-4px 0 8px -1px rgba(0, 0, 0, 0.08),\n -2px 0 4px -1px rgba(0, 0, 0, 0.04);--calcite-shell-panel-shadow-inline-end-internal:4px 0 8px -1px rgba(0, 0, 0, 0.08),\n 2px 0 4px -1px rgba(0, 0, 0, 0.04)}:host([layout=vertical]){z-index:var(--calcite-shell-panel-z-index, calc(var(--calcite-app-z-index) + 1))}:host([layout=vertical][display-mode=overlay]){z-index:var(--calcite-shell-panel-z-index, calc(var(--calcite-app-z-index-header) + 1))}:host([layout=vertical][width-scale=s]) .content{--calcite-shell-panel-width-internal:var(--calcite-shell-panel-width, 12vw);--calcite-shell-panel-max-width-internal:var(--calcite-shell-panel-max-width, 300px);--calcite-shell-panel-min-width-internal:var(--calcite-shell-panel-min-width, 150px)}:host([layout=vertical][width-scale=m]) .content{--calcite-shell-panel-width-internal:var(--calcite-shell-panel-width, 20vw);--calcite-shell-panel-max-width-internal:var(--calcite-shell-panel-max-width, 420px);--calcite-shell-panel-min-width-internal:var(--calcite-shell-panel-min-width, 240px)}:host([layout=vertical][width-scale=l]) .content{--calcite-shell-panel-width-internal:var(--calcite-shell-panel-width, 45vw);--calcite-shell-panel-max-width-internal:var(--calcite-shell-panel-max-width, 680px);--calcite-shell-panel-min-width-internal:var(--calcite-shell-panel-min-width, 340px)}:host([layout=horizontal][height-scale=s]) .content{--calcite-shell-panel-max-height-internal:var(\n --calcite-shell-panel-max-height,\n var(--calcite-shell-panel-detached-max-height, 20vh)\n )}:host([layout=horizontal]) .content{--calcite-shell-panel-min-height-internal:var(--calcite-shell-panel-min-height, 5vh);--calcite-shell-panel-max-height-internal:var(\n --calcite-shell-panel-max-height,\n var(--calcite-shell-panel-detached-max-height, 30vh)\n )}:host([layout=horizontal][height-scale=l]) .content{--calcite-shell-panel-max-height-internal:var(\n --calcite-shell-panel-max-height,\n var(--calcite-shell-panel-detached-max-height, 40vh)\n )}.container{pointer-events:none;box-sizing:border-box;display:flex;flex:1 1 auto;align-items:stretch;background-color:transparent;font-size:var(--calcite-font-size--1);color:var(--calcite-ui-text-2)}.container *{box-sizing:border-box}:host([layout=horizontal]) .container{flex-direction:column}:host(:hover) .separator:not(:hover):not(:focus),:host(:focus-within) .separator:not(:hover):not(:focus){opacity:1;background-color:var(--calcite-ui-border-3)}.separator{pointer-events:auto;position:absolute;display:flex;background-color:transparent;opacity:0;transition:all var(--calcite-animation-timing) ease-in-out 0s, outline 0s, outline-offset 0s;cursor:col-resize;outline:none}.separator:hover{opacity:1;background-color:var(--calcite-ui-border-2)}.separator:focus{background-color:var(--calcite-ui-brand);opacity:1}:host([layout=vertical]) .separator{inset-block:0px;block-size:100%;inline-size:0.125rem;cursor:col-resize}:host([layout=horizontal][position=start]) .separator{inset-block-end:0px}:host([layout=horizontal][position=end]) .separator{inset-block-start:0px}:host([layout=horizontal]) .separator{inset-inline-end:0px;block-size:0.125rem;inline-size:100%;cursor:row-resize}:host([layout=vertical][position=start]) .separator{inset-inline-end:-2px}:host([layout=horizontal][position=start]) .separator{inset-block-end:-2px}:host([layout=vertical][position=end]) .separator{inset-inline-start:-2px}:host([layout=horizontal][position=end]) .separator{inset-block-start:-2px}::slotted(calcite-panel),::slotted(calcite-flow){block-size:100%;inline-size:100%;flex:1 1 auto;max-block-size:unset;max-inline-size:unset}::slotted(.calcite-match-height){display:flex;flex:1 1 auto;overflow:hidden}.content{pointer-events:auto;display:flex;flex-direction:column;flex-wrap:nowrap;align-items:stretch;align-self:stretch;background-color:var(--calcite-ui-background);padding:0px;transition:max-block-size var(--calcite-animation-timing), max-inline-size var(--calcite-animation-timing)}:host([layout=vertical]) .content{inline-size:var(--calcite-shell-panel-width-internal);max-inline-size:var(--calcite-shell-panel-max-width-internal);min-inline-size:var(--calcite-shell-panel-min-width-internal)}:host([layout=horizontal]) .content{block-size:var(--calcite-shell-panel-height-internal);max-block-size:var(--calcite-shell-panel-max-height-internal);min-block-size:var(--calcite-shell-panel-min-height-internal)}.content__header{display:flex;flex:0 1 auto;flex-direction:column;flex-wrap:nowrap;align-items:stretch}.content__body{display:flex;flex:1 1 auto;flex-direction:column;overflow:hidden}.content--overlay{position:absolute;--tw-shadow:0 4px 8px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);--tw-shadow-colored:0 4px 8px -1px var(--tw-shadow-color), 0 2px 4px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}:host([layout=vertical]) .content--overlay{inset-block-start:0px;block-size:100%}:host([layout=horizontal]) .content--overlay{inset-inline-start:0px;inline-size:100%}:host([layout=vertical][position=start]) .content--overlay{inset-inline-start:100%;box-shadow:var(--calcite-shell-panel-shadow-inline-start-internal)}:host([layout=vertical][position=end]) .content--overlay{inset-inline-end:100%;box-shadow:var(--calcite-shell-panel-shadow-inline-end-internal)}:host([layout=horizontal][position=start]) .content--overlay{inset-block-start:100%;box-shadow:var(--calcite-shell-panel-shadow-block-start-internal)}:host([layout=horizontal][position=end]) .content--overlay{inset-block-end:100%;box-shadow:var(--calcite-shell-panel-shadow-block-end-internal)}.content--float{margin-inline:0.5rem;margin-block:0.5rem auto;block-size:auto;overflow:hidden;border-radius:0.25rem;--tw-shadow:0 4px 8px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);--tw-shadow-colored:0 4px 8px -1px var(--tw-shadow-color), 0 2px 4px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);max-block-size:var(--calcite-shell-panel-max-height-internal, calc(100% - 1rem))}.content--float ::slotted(calcite-panel),.content--float ::slotted(calcite-flow){max-block-size:unset}:host([layout=horizontal]) .content--float{margin-block:0.5rem}:host([position=start]) .content--float ::slotted(calcite-panel),:host([position=start]) .content--float ::slotted(calcite-flow),:host([position=end]) .content--float ::slotted(calcite-panel),:host([position=end]) .content--float ::slotted(calcite-flow){border-style:none}.content[hidden]{display:none}slot[name=action-bar]::slotted(calcite-action-bar),.content ::slotted(calcite-flow),.content ::slotted(calcite-panel:not([closed])){border-width:1px;border-style:solid;border-color:var(--calcite-ui-border-3)}:host([position=start]) slot[name=action-bar]::slotted(calcite-action-bar),:host([position=start]) .content ::slotted(calcite-flow),:host([position=start]) .content ::slotted(calcite-panel){border-inline-start:none}:host([position=end]) slot[name=action-bar]::slotted(calcite-action-bar),:host([position=end]) .content ::slotted(calcite-flow),:host([position=end]) .content ::slotted(calcite-panel){border-inline-end:none}:host([layout=horizontal]) slot[name=action-bar]::slotted(calcite-action-bar){border-inline:0}:host([layout=horizontal][position=start]) .content ::slotted(calcite-flow),:host([layout=horizontal][position=start]) .content ::slotted(calcite-panel){border-inline:0;border-block-start:0}:host([layout=horizontal][position=end]) .content ::slotted(calcite-flow),:host([layout=horizontal][position=end]) .content ::slotted(calcite-panel){border-inline:0;border-block-end:0}"; const ShellPanel = class { constructor(hostRef) { index.registerInstance(this, hostRef); this.initialContentWidth = null; this.initialContentHeight = null; this.initialClientX = null; this.initialClientY = null; this.contentWidthMax = null; this.contentWidthMin = null; this.contentHeightMax = null; this.contentHeightMin = null; this.step = 1; this.stepMultiplier = 10; this.actionBars = []; this.storeContentEl = (contentEl) => { this.contentEl = contentEl; }; this.getKeyAdjustedSize = (event) => { const { key } = event; const { el, step, stepMultiplier, layout, contentWidthMin, contentWidthMax, initialContentWidth, initialContentHeight, contentHeightMin, contentHeightMax, position } = this; const multipliedStep = step * stepMultiplier; const MOVEMENT_KEYS = [ "ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Home", "End", "PageUp", "PageDown" ]; if (MOVEMENT_KEYS.indexOf(key) > -1) { event.preventDefault(); } const dir = dom.getElementDir(el); const horizontalKeys = ["ArrowLeft", "ArrowRight"]; const verticalKeys = ["ArrowDown", "ArrowUp"]; const directionFactor = dir === "rtl" && horizontalKeys.includes(key) ? -1 : 1; const increaseKeys = layout === "horizontal" ? position === "end" ? key === verticalKeys[1] || key === horizontalKeys[0] : key === verticalKeys[0] || key === horizontalKeys[1] : key === verticalKeys[1] || (position === "end" ? key === horizontalKeys[0] : key === horizontalKeys[1]); if (increaseKeys) { const stepValue = event.shiftKey ? multipliedStep : step; return layout === "horizontal" ? initialContentHeight + directionFactor * stepValue : initialContentWidth + directionFactor * stepValue; } const decreaseKeys = layout === "horizontal" ? position === "end" ? key === verticalKeys[0] || key === horizontalKeys[0] : key === verticalKeys[1] || key === horizontalKeys[1] : key === verticalKeys[0] || (position === "end" ? key === horizontalKeys[1] : key === horizontalKeys[0]); if (decreaseKeys) { const stepValue = event.shiftKey ? multipliedStep : step; return layout === "horizontal" ? initialContentHeight - directionFactor * stepValue : initialContentWidth - directionFactor * stepValue; } if (key === "Home" && layout === "horizontal" && typeof contentHeightMin === "number") { return contentHeightMin; } if (key === "Home" && layout === "vertical" && typeof contentWidthMin === "number") { return contentWidthMin; } if (key === "End" && layout === "horizontal" && typeof contentHeightMax === "number") { return contentHeightMax; } if (key === "End" && layout === "vertical" && typeof contentWidthMax === "number") { return contentWidthMax; } if (key === "PageDown") { return layout === "horizontal" ? initialContentHeight - multipliedStep : initialContentWidth - multipliedStep; } if (key === "PageUp") { return layout === "horizontal" ? initialContentHeight + multipliedStep : initialContentWidth + multipliedStep; } return null; }; this.initialKeydownWidth = (event) => { this.setInitialContentWidth(); const width = this.getKeyAdjustedSize(event); if (typeof width === "number") { this.setContentWidth(width); } }; this.initialKeydownHeight = (event) => { this.setInitialContentHeight(); const height = this.getKeyAdjustedSize(event); if (typeof height === "number") { this.setContentHeight(height); } }; this.separatorKeyDown = (event) => { this.layout === "horizontal" ? this.initialKeydownHeight(event) : this.initialKeydownWidth(event); }; this.separatorPointerMove = (event) => { event.preventDefault(); const { el, layout, initialContentWidth, initialContentHeight, position, initialClientX, initialClientY } = this; const offset = layout === "horizontal" ? event.clientY - initialClientY : event.clientX - initialClientX; const adjustmentDirection = layout === "vertical" && dom.getElementDir(el) === "rtl" ? -1 : 1; const adjustedOffset = layout === "horizontal" ? position === "end" ? -adjustmentDirection * offset : adjustmentDirection * offset : position === "end" ? -adjustmentDirection * offset : adjustmentDirection * offset; layout === "horizontal" ? this.setContentHeight(initialContentHeight + adjustedOffset) : this.setContentWidth(initialContentWidth + adjustedOffset); }; this.separatorPointerUp = (event) => { if (!dom.isPrimaryPointerButton(event)) { return; } event.preventDefault(); document.removeEventListener("pointerup", this.separatorPointerUp); document.removeEventListener("pointermove", this.separatorPointerMove); }; this.setInitialContentHeight = () => { this.initialContentHeight = this.contentEl?.getBoundingClientRect().height; }; this.setInitialContentWidth = () => { this.initialContentWidth = this.contentEl?.getBoundingClientRect().width; }; this.separatorPointerDown = (event) => { if (!dom.isPrimaryPointerButton(event)) { return; } event.preventDefault(); const { separatorEl } = this; separatorEl && document.activeElement !== separatorEl && separatorEl.focus(); if (this.layout === "horizontal") { this.setInitialContentHeight(); this.initialClientY = event.clientY; } else { this.setInitialContentWidth(); this.initialClientX = event.clientX; } document.addEventListener("pointerup", this.separatorPointerUp); document.addEventListener("pointermove", this.separatorPointerMove); }; this.connectSeparator = (separatorEl) => { this.disconnectSeparator(); this.separatorEl = separatorEl; separatorEl?.addEventListener("pointerdown", this.separatorPointerDown); }; this.disconnectSeparator = () => { this.separatorEl?.removeEventListener("pointerdown", this.separatorPointerDown); }; this.setActionBarsLayout = (actionBars) => { actionBars.forEach((actionBar) => (actionBar.layout = this.layout)); }; this.handleActionBarSlotChange = (event) => { const actionBars = dom.slotChangeGetAssignedElements(event).filter((el) => el?.matches("calcite-action-bar")); this.actionBars = actionBars; this.setActionBarsLayout(actionBars); }; this.collapsed = false; this.detached = false; this.displayMode = "dock"; this.detachedHeightScale = undefined; this.heightScale = undefined; this.widthScale = "m"; this.layout = "vertical"; this.position = "start"; this.resizable = false; this.messages = undefined; this.messageOverrides = undefined; this.contentWidth = null; this.contentHeight = null; this.defaultMessages = undefined; this.effectiveLocale = ""; } handleDetached(value) { if (value) { this.displayMode = "float"; } else if (this.displayMode === "float") { this.displayMode = "dock"; } } handleDisplayMode(value) { this.detached = value === "float"; } handleDetachedHeightScale(value) { this.heightScale = value; } handleHeightScale(value) { this.detachedHeightScale = value; } layoutHandler() { this.setActionBarsLayout(this.actionBars); } onMessagesChange() { /* wired up by t9n util */ } //-------------------------------------------------------------------------- // // Lifecycle // //-------------------------------------------------------------------------- connectedCallback() { conditionalSlot.connectConditionalSlotComponent(this); locale.connectLocalized(this); t9n.connectMessages(this); } async componentWillLoad() { await t9n.setUpMessages(this); } disconnectedCallback() { conditionalSlot.disconnectConditionalSlotComponent(this); this.disconnectSeparator(); locale.disconnectLocalized(this); t9n.disconnectMessages(this); } componentDidLoad() { this.updateAriaValues(); } effectiveLocaleChange() { t9n.updateMessages(this, this.effectiveLocale); } // -------------------------------------------------------------------------- // // Render Methods // // -------------------------------------------------------------------------- renderHeader() { const { el } = this; const hasHeader = dom.getSlotted(el, SLOTS.header); return hasHeader ? (index.h("div", { class: CSS.contentHeader, key: "header" }, index.h("slot", { name: SLOTS.header }))) : null; } render() { const { collapsed, position, initialContentWidth, initialContentHeight, contentWidth, contentWidthMax, contentWidthMin, contentHeight, contentHeightMax, contentHeightMin, resizable, layout, displayMode } = this; const dir = dom.getElementDir(this.el); const allowResizing = displayMode !== "float" && resizable; const style = allowResizing ? layout === "horizontal" ? contentHeight ? { height: `${contentHeight}px` } : null : contentWidth ? { width: `${contentWidth}px` } : null : null; const separatorNode = !collapsed && allowResizing ? (index.h("div", { "aria-label": this.messages.resize, "aria-orientation": layout === "horizontal" ? "vertical" : "horizontal", "aria-valuemax": layout == "horizontal" ? contentHeightMax : contentWidthMax, "aria-valuemin": layout == "horizontal" ? contentHeightMin : contentWidthMin, "aria-valuenow": layout == "horizontal" ? contentHeight ?? initialContentHeight : contentWidth ?? initialContentWidth, class: CSS.separator, key: "separator", onKeyDown: this.separatorKeyDown, role: "separator", tabIndex: 0, "touch-action": "none", // eslint-disable-next-line react/jsx-sort-props ref: this.connectSeparator })) : null; const getAnimationDir = () => { if (layout === "horizontal") { return position === "start" ? resources.CSS_UTILITY.calciteAnimateInDown : resources.CSS_UTILITY.calciteAnimateInUp; } else { const isStart = (dir === "ltr" && position === "end") || (dir === "rtl" && position === "start"); return isStart ? resources.CSS_UTILITY.calciteAnimateInLeft : resources.CSS_UTILITY.calciteAnimateInRight; } }; const contentNode = (index.h("div", { class: { [resources.CSS_UTILITY.rtl]: dir === "rtl", [CSS.content]: true, [CSS.contentOverlay]: displayMode === "overlay", [CSS.contentFloat]: displayMode === "float", [resources.CSS_UTILITY.calciteAnimate]: displayMode === "overlay", [getAnimationDir()]: displayMode === "overlay" }, hidden: collapsed, key: "content", style: style, // eslint-disable-next-line react/jsx-sort-props ref: this.storeContentEl }, this.renderHeader(), index.h("div", { class: CSS.contentBody }, index.h("slot", null)), separatorNode)); const actionBarNode = (index.h("slot", { key: "action-bar", name: SLOTS.actionBar, onSlotchange: this.handleActionBarSlotChange })); const mainNodes = [actionBarNode, contentNode]; if (position === "end") { mainNodes.reverse(); } return index.h("div", { class: { [CSS.container]: true } }, mainNodes); } // -------------------------------------------------------------------------- // // private Methods // // -------------------------------------------------------------------------- setContentWidth(width) { const { contentWidthMax, contentWidthMin } = this; const roundedWidth = Math.round(width); this.contentWidth = typeof contentWidthMax === "number" && typeof contentWidthMin === "number" ? math.clamp(roundedWidth, contentWidthMin, contentWidthMax) : roundedWidth; } updateAriaValues() { const { contentEl } = this; const computedStyle = contentEl && getComputedStyle(contentEl); if (!computedStyle) { return; } this.layout === "horizontal" ? this.updateHeights(computedStyle) : this.updateWidths(computedStyle); index.forceUpdate(this); } setContentHeight(height) { const { contentHeightMax, contentHeightMin } = this; const roundedWidth = Math.round(height); this.contentHeight = typeof contentHeightMax === "number" && typeof contentHeightMin === "number" ? math.clamp(roundedWidth, contentHeightMin, contentHeightMax) : roundedWidth; } updateWidths(computedStyle) { const max = parseInt(computedStyle.getPropertyValue("max-width"), 10); const min = parseInt(computedStyle.getPropertyValue("min-width"), 10); const valueNow = parseInt(computedStyle.getPropertyValue("width"), 10); if (typeof valueNow === "number" && !isNaN(valueNow)) { this.initialContentWidth = valueNow; } if (typeof max === "number" && !isNaN(max)) { this.contentWidthMax = max; } if (typeof min === "number" && !isNaN(min)) { this.contentWidthMin = min; } } updateHeights(computedStyle) { const max = parseInt(computedStyle.getPropertyValue("max-height"), 10); const min = parseInt(computedStyle.getPropertyValue("min-height"), 10); const valueNow = parseInt(computedStyle.getPropertyValue("height"), 10); if (typeof valueNow === "number" && !isNaN(valueNow)) { this.initialContentHeight = valueNow; } if (typeof max === "number" && !isNaN(max)) { this.contentHeightMax = max; } if (typeof min === "number" && !isNaN(min)) { this.contentHeightMin = min; } } static get assetsDirs() { return ["assets"]; } get el() { return index.getElement(this); } static get watchers() { return { "detached": ["handleDetached"], "displayMode": ["handleDisplayMode"], "detachedHeightScale": ["handleDetachedHeightScale"], "heightScale": ["handleHeightScale"], "layout": ["layoutHandler"], "messageOverrides": ["onMessagesChange"], "effectiveLocale": ["effectiveLocaleChange"] }; } }; ShellPanel.style = shellPanelCss; exports.calcite_shell = Shell; exports.calcite_shell_center_row = ShellCenterRow; exports.calcite_shell_panel = ShellPanel;