@esri/calcite-components
Version:
Web Components for Esri's Calcite Design System.
564 lines (553 loc) • 39.6 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 registerInstance, h, F as Fragment, a as getElement, f as forceUpdate } from './index-c8875db5.js';
import { c as connectConditionalSlotComponent, d as disconnectConditionalSlotComponent } from './conditionalSlot-ed85dd9d.js';
import { d as slotChangeHasAssignedElement, s as slotChangeGetAssignedElements, g as getSlotted, b as getElementDir, i as isPrimaryPointerButton } from './dom-4f5d1224.js';
import { c as connectLocalized, d as disconnectLocalized } from './locale-0c018cdb.js';
import { c as clamp } from './math-bca052e1.js';
import { c as connectMessages, s as setUpMessages, d as disconnectMessages, u as updateMessages } from './t9n-f819e5a2.js';
import { C as CSS_UTILITY } from './resources-35f23920.js';
import './observers-d19b0d93.js';
import './guid-bdb80778.js';
import './key-582cee8f.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) {
registerInstance(this, hostRef);
// --------------------------------------------------------------------------
//
// Private Methods
//
// --------------------------------------------------------------------------
this.handleHeaderSlotChange = (event) => {
this.hasHeader = !!slotChangeHasAssignedElement(event);
};
this.handleFooterSlotChange = (event) => {
this.hasFooter = !!slotChangeHasAssignedElement(event);
};
this.handleAlertsSlotChange = (event) => {
this.hasAlerts = !!slotChangeHasAssignedElement(event);
slotChangeGetAssignedElements(event)?.map((el) => {
if (el.nodeName === "CALCITE-ALERT") {
el.slottedInShell = true;
}
});
};
this.handleModalsSlotChange = (event) => {
this.hasModals = !!slotChangeHasAssignedElement(event);
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() {
connectConditionalSlotComponent(this);
}
disconnectedCallback() {
disconnectConditionalSlotComponent(this);
}
// --------------------------------------------------------------------------
//
// Render Methods
//
// --------------------------------------------------------------------------
renderHeader() {
return (h("div", { hidden: !this.hasHeader }, h("slot", { key: "header", name: SLOTS$2.header, onSlotchange: this.handleHeaderSlotChange })));
}
renderFooter() {
return (h("div", { class: CSS$2.footer, hidden: !this.hasFooter, key: "footer" }, h("slot", { name: SLOTS$2.footer, onSlotchange: this.handleFooterSlotChange })));
}
renderAlerts() {
return (h("div", { hidden: !this.hasAlerts }, h("slot", { key: "alerts", name: SLOTS$2.alerts, onSlotchange: this.handleAlertsSlotChange })));
}
renderModals() {
return (h("div", { hidden: !this.hasModals }, h("slot", { key: "modals", name: SLOTS$2.modals, onSlotchange: this.handleModalsSlotChange })));
}
renderContent() {
const defaultSlotNode = h("slot", { key: "default-slot" });
const deprecatedCenterRowSlotNode = (h("slot", { key: "center-row-slot", name: SLOTS$2.centerRow }));
const panelBottomSlotNode = h("slot", { key: "panel-bottom-slot", name: SLOTS$2.panelBottom });
const panelTopSlotNode = h("slot", { key: "panel-top-slot", name: SLOTS$2.panelTop });
const contentContainerKey = "content-container";
const content = !!this.contentBehind
? [
h("div", { class: {
[CSS$2.content]: true,
[CSS$2.contentBehind]: true
}, key: contentContainerKey }, defaultSlotNode),
h("div", { class: CSS$2.contentBehindCenterContent }, panelTopSlotNode, panelBottomSlotNode, deprecatedCenterRowSlotNode)
]
: [
h("div", { class: CSS$2.content, key: contentContainerKey }, panelTopSlotNode, defaultSlotNode, panelBottomSlotNode, deprecatedCenterRowSlotNode)
];
return content;
}
renderMain() {
return (h("div", { class: CSS$2.main }, h("slot", { name: SLOTS$2.panelStart }), this.renderContent(), h("slot", { name: SLOTS$2.panelEnd })));
}
renderPositionedSlots() {
return (h("div", { class: CSS$2.positionedSlotWrapper }, this.renderAlerts(), this.renderModals()));
}
render() {
return (h(Fragment, null, this.renderHeader(), this.renderMain(), this.renderFooter(), this.renderPositionedSlots()));
}
get el() { return 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) {
registerInstance(this, hostRef);
this.detached = false;
this.heightScale = "s";
this.position = "end";
}
// --------------------------------------------------------------------------
//
// Lifecycle
//
// --------------------------------------------------------------------------
connectedCallback() {
connectConditionalSlotComponent(this);
}
disconnectedCallback() {
disconnectConditionalSlotComponent(this);
}
// --------------------------------------------------------------------------
//
// Render Methods
//
// --------------------------------------------------------------------------
render() {
const { el } = this;
const contentNode = (h("div", { class: CSS$1.content }, h("slot", null)));
const actionBar = getSlotted(el, SLOTS$1.actionBar);
const actionBarNode = actionBar ? (h("div", { class: CSS$1.actionBarContainer, key: "action-bar" }, h("slot", { name: SLOTS$1.actionBar }))) : null;
const children = [actionBarNode, contentNode];
if (actionBar?.position === "end") {
children.reverse();
}
return h(Fragment, null, children);
}
get el() { return 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) {
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 = 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" && 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 (!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 (!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 = 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() {
connectConditionalSlotComponent(this);
connectLocalized(this);
connectMessages(this);
}
async componentWillLoad() {
await setUpMessages(this);
}
disconnectedCallback() {
disconnectConditionalSlotComponent(this);
this.disconnectSeparator();
disconnectLocalized(this);
disconnectMessages(this);
}
componentDidLoad() {
this.updateAriaValues();
}
effectiveLocaleChange() {
updateMessages(this, this.effectiveLocale);
}
// --------------------------------------------------------------------------
//
// Render Methods
//
// --------------------------------------------------------------------------
renderHeader() {
const { el } = this;
const hasHeader = getSlotted(el, SLOTS.header);
return hasHeader ? (h("div", { class: CSS.contentHeader, key: "header" }, h("slot", { name: SLOTS.header }))) : null;
}
render() {
const { collapsed, position, initialContentWidth, initialContentHeight, contentWidth, contentWidthMax, contentWidthMin, contentHeight, contentHeightMax, contentHeightMin, resizable, layout, displayMode } = this;
const dir = 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 ? (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"
? CSS_UTILITY.calciteAnimateInDown
: CSS_UTILITY.calciteAnimateInUp;
}
else {
const isStart = (dir === "ltr" && position === "end") || (dir === "rtl" && position === "start");
return isStart ? CSS_UTILITY.calciteAnimateInLeft : CSS_UTILITY.calciteAnimateInRight;
}
};
const contentNode = (h("div", { class: {
[CSS_UTILITY.rtl]: dir === "rtl",
[CSS.content]: true,
[CSS.contentOverlay]: displayMode === "overlay",
[CSS.contentFloat]: displayMode === "float",
[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(), h("div", { class: CSS.contentBody }, h("slot", null)), separatorNode));
const actionBarNode = (h("slot", { key: "action-bar", name: SLOTS.actionBar, onSlotchange: this.handleActionBarSlotChange }));
const mainNodes = [actionBarNode, contentNode];
if (position === "end") {
mainNodes.reverse();
}
return 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"
? 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);
forceUpdate(this);
}
setContentHeight(height) {
const { contentHeightMax, contentHeightMin } = this;
const roundedWidth = Math.round(height);
this.contentHeight =
typeof contentHeightMax === "number" && typeof contentHeightMin === "number"
? 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 getElement(this); }
static get watchers() { return {
"detached": ["handleDetached"],
"displayMode": ["handleDisplayMode"],
"detachedHeightScale": ["handleDetachedHeightScale"],
"heightScale": ["handleHeightScale"],
"layout": ["layoutHandler"],
"messageOverrides": ["onMessagesChange"],
"effectiveLocale": ["effectiveLocaleChange"]
}; }
};
ShellPanel.style = shellPanelCss;
export { Shell as calcite_shell, ShellCenterRow as calcite_shell_center_row, ShellPanel as calcite_shell_panel };