123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410 |
- /*!
- * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
- * v1.0.0-beta.97
- */
- 'use strict';
- Object.defineProperty(exports, '__esModule', { value: true });
- const index = require('./index-a0010f96.js');
- const dom = require('./dom-2ec8c9ed.js');
- const conditionalSlot = require('./conditionalSlot-ef852d9d.js');
- const math = require('./math-f71ad83a.js');
- require('./resources-b5a5f8a7.js');
- require('./guid-f4f03a7a.js');
- require('./observers-5706326b.js');
- const CSS$2 = {
- main: "main",
- mainReversed: "main--reversed",
- content: "content",
- contentBehind: "content--behind",
- footer: "footer"
- };
- const SLOTS$2 = {
- centerRow: "center-row",
- primaryPanel: "primary-panel",
- contextualPanel: "contextual-panel",
- panelStart: "panel-start",
- panelEnd: "panel-end",
- header: "header",
- footer: "footer"
- };
- 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-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-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)}: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}.main--reversed{flex-direction:row-reverse}.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(1 - 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-shell-panel),::slotted(calcite-shell-center-row){position:relative;z-index:1}::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])){border-inline-start-width:1px;border-inline-end-width:1px;border-color:var(--calcite-ui-border-3)}::slotted(calcite-tip-manager){position:absolute;z-index:500;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)}";
- const Shell = class {
- constructor(hostRef) {
- index.registerInstance(this, hostRef);
- // --------------------------------------------------------------------------
- //
- // Properties
- //
- // --------------------------------------------------------------------------
- /**
- * Positions the center content behind any `calcite-shell-panel`s.
- */
- this.contentBehind = false;
- }
- // --------------------------------------------------------------------------
- //
- // Lifecycle
- //
- // --------------------------------------------------------------------------
- connectedCallback() {
- conditionalSlot.connectConditionalSlotComponent(this);
- }
- disconnectedCallback() {
- conditionalSlot.disconnectConditionalSlotComponent(this);
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- renderHeader() {
- const hasHeader = !!dom.getSlotted(this.el, SLOTS$2.header);
- return hasHeader ? index.h("slot", { key: "header", name: SLOTS$2.header }) : null;
- }
- renderContent() {
- const defaultSlotNode = index.h("slot", { key: "default-slot" });
- const centerRowSlotNode = index.h("slot", { key: "center-row-slot", name: SLOTS$2.centerRow });
- const contentContainerKey = "content-container";
- const content = !!this.contentBehind
- ? [
- index.h("div", { class: {
- [CSS$2.content]: true,
- [CSS$2.contentBehind]: true
- }, key: contentContainerKey }, defaultSlotNode),
- centerRowSlotNode
- ]
- : [
- index.h("div", { class: CSS$2.content, key: contentContainerKey }, defaultSlotNode, centerRowSlotNode)
- ];
- return content;
- }
- renderFooter() {
- const hasFooter = !!dom.getSlotted(this.el, SLOTS$2.footer);
- return hasFooter ? (index.h("div", { class: CSS$2.footer, key: "footer" }, index.h("slot", { name: SLOTS$2.footer }))) : null;
- }
- renderMain() {
- const primaryPanel = dom.getSlotted(this.el, SLOTS$2.primaryPanel);
- const mainClasses = {
- [CSS$2.main]: true,
- [CSS$2.mainReversed]: (primaryPanel === null || primaryPanel === void 0 ? void 0 : primaryPanel.position) === "end"
- };
- return (index.h("div", { class: mainClasses }, index.h("slot", { name: SLOTS$2.primaryPanel }), index.h("slot", { name: SLOTS$2.panelStart }), this.renderContent(), index.h("slot", { name: SLOTS$2.panelEnd }), index.h("slot", { name: SLOTS$2.contextualPanel })));
- }
- render() {
- return (index.h(index.Fragment, null, this.renderHeader(), this.renderMain(), this.renderFooter()));
- }
- 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-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-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)}:host([hidden]){display:none}:host{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);
- // --------------------------------------------------------------------------
- //
- // Properties
- //
- // --------------------------------------------------------------------------
- /**
- * When `true`, the content area displays like a floating panel.
- */
- this.detached = false;
- /**
- * Specifies the maximum height of the component.
- */
- this.heightScale = "s";
- /**
- * Specifies the component's position. Will be flipped when the element direction is right-to-left (`"rtl"`).
- */
- 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 === null || actionBar === void 0 ? void 0 : 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",
- contentDetached: "content--detached",
- separator: "separator"
- };
- const SLOTS = {
- actionBar: "action-bar",
- header: "header"
- };
- const TEXT = {
- resize: "Resize"
- };
- 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-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-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)}:host([hidden]){display:none}:host{pointer-events:none;display:flex;flex:0 1 auto;align-items:stretch;--calcite-shell-panel-detached-max-height:unset}.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(: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;inset-block:0px;display:flex;block-size:100%;inline-size:0.125rem;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([position=start]) .separator{inset-inline-end:-2px}:host([position=end]) .separator{inset-inline-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;inline-size:var(--calcite-shell-panel-width);max-inline-size:var(--calcite-shell-panel-max-width);min-inline-size:var(--calcite-shell-panel-min-width);transition:max-block-size var(--calcite-animation-timing), max-inline-size var(--calcite-animation-timing)}.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}:host([width-scale=s]) .content{--calcite-shell-panel-width:calc(var(--calcite-panel-width-multiplier) * 12vw);--calcite-shell-panel-max-width:calc(var(--calcite-panel-width-multiplier) * 300px);--calcite-shell-panel-min-width:calc(var(--calcite-panel-width-multiplier) * 150px)}:host([width-scale=m]) .content{--calcite-shell-panel-width:calc(var(--calcite-panel-width-multiplier) * 20vw);--calcite-shell-panel-max-width:calc(var(--calcite-panel-width-multiplier) * 420px);--calcite-shell-panel-min-width:calc(var(--calcite-panel-width-multiplier) * 240px)}:host([width-scale=l]) .content{--calcite-shell-panel-width:calc(var(--calcite-panel-width-multiplier) * 45vw);--calcite-shell-panel-max-width:calc(var(--calcite-panel-width-multiplier) * 680px);--calcite-shell-panel-min-width:calc(var(--calcite-panel-width-multiplier) * 340px)}:host([detached-height-scale=s]) .content--detached{--calcite-shell-panel-detached-max-height:40vh}:host([detached-height-scale=m]) .content--detached{--calcite-shell-panel-detached-max-height:60vh}:host([detached-height-scale=l]) .content--detached{--calcite-shell-panel-detached-max-height:80vh}.content--detached{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-detached-max-height)}.content--detached ::slotted(calcite-panel),.content--detached ::slotted(calcite-flow){max-block-size:unset}:host([position=start]) .content--detached ::slotted(calcite-panel),:host([position=start]) .content--detached ::slotted(calcite-flow),:host([position=end]) .content--detached ::slotted(calcite-panel),:host([position=end]) .content--detached ::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([dismissed])){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}";
- const ShellPanel = class {
- constructor(hostRef) {
- index.registerInstance(this, hostRef);
- this.calciteShellPanelToggle = index.createEvent(this, "calciteShellPanelToggle", 6);
- // --------------------------------------------------------------------------
- //
- // Properties
- //
- // --------------------------------------------------------------------------
- /**
- * When `true`, hides the component's content area.
- */
- this.collapsed = false;
- /**
- * When `true`, the content area displays like a floating panel.
- */
- this.detached = false;
- /**
- * When `detached`, specifies the maximum height of the component.
- */
- this.detachedHeightScale = "l";
- /**
- * Specifies the width of the component's content area.
- */
- this.widthScale = "m";
- /**
- * Accessible name for the resize separator.
- *
- * @default "Resize"
- */
- this.intlResize = TEXT.resize;
- /**
- * When `true` and not `detached`, the component's content area is resizable.
- */
- this.resizable = false;
- this.contentWidth = null;
- this.initialContentWidth = null;
- this.initialClientX = null;
- this.contentWidthMax = null;
- this.contentWidthMin = null;
- this.step = 1;
- this.stepMultiplier = 10;
- this.storeContentEl = (contentEl) => {
- this.contentEl = contentEl;
- };
- this.getKeyAdjustedWidth = (event) => {
- const { key } = event;
- const { el, step, stepMultiplier, contentWidthMin, contentWidthMax, initialContentWidth, 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 directionKeys = ["ArrowLeft", "ArrowRight"];
- const directionFactor = dir === "rtl" && directionKeys.includes(key) ? -1 : 1;
- const increaseKeys = key === "ArrowUp" ||
- (position === "end" ? key === directionKeys[0] : key === directionKeys[1]);
- if (increaseKeys) {
- const stepValue = event.shiftKey ? multipliedStep : step;
- return initialContentWidth + directionFactor * stepValue;
- }
- const decreaseKeys = key === "ArrowDown" ||
- (position === "end" ? key === directionKeys[1] : key === directionKeys[0]);
- if (decreaseKeys) {
- const stepValue = event.shiftKey ? multipliedStep : step;
- return initialContentWidth - directionFactor * stepValue;
- }
- if (typeof contentWidthMin === "number" && key === "Home") {
- return contentWidthMin;
- }
- if (typeof contentWidthMax === "number" && key === "End") {
- return contentWidthMax;
- }
- if (key === "PageDown") {
- return initialContentWidth - multipliedStep;
- }
- if (key === "PageUp") {
- return initialContentWidth + multipliedStep;
- }
- return null;
- };
- this.separatorKeyDown = (event) => {
- this.setInitialContentWidth();
- const width = this.getKeyAdjustedWidth(event);
- if (typeof width === "number") {
- this.setContentWidth(width);
- }
- };
- this.separatorPointerMove = (event) => {
- event.preventDefault();
- const { el, initialContentWidth, position, initialClientX } = this;
- const offset = event.clientX - initialClientX;
- const dir = dom.getElementDir(el);
- const adjustmentDirection = dir === "rtl" ? -1 : 1;
- const adjustedOffset = position === "end" ? -adjustmentDirection * offset : adjustmentDirection * offset;
- const width = initialContentWidth + adjustedOffset;
- this.setContentWidth(width);
- };
- this.separatorPointerUp = (event) => {
- if (!dom.isPrimaryPointerButton(event)) {
- return;
- }
- event.preventDefault();
- document.removeEventListener("pointerup", this.separatorPointerUp);
- document.removeEventListener("pointermove", this.separatorPointerMove);
- };
- this.setInitialContentWidth = () => {
- var _a;
- this.initialContentWidth = (_a = this.contentEl) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().width;
- };
- this.separatorPointerDown = (event) => {
- if (!dom.isPrimaryPointerButton(event)) {
- return;
- }
- event.preventDefault();
- const { separatorEl } = this;
- separatorEl && document.activeElement !== separatorEl && separatorEl.focus();
- 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 = () => {
- var _a;
- (_a = this.separatorEl) === null || _a === void 0 ? void 0 : _a.removeEventListener("pointerdown", this.separatorPointerDown);
- };
- }
- watchHandler() {
- this.calciteShellPanelToggle.emit();
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- connectedCallback() {
- conditionalSlot.connectConditionalSlotComponent(this);
- }
- disconnectedCallback() {
- conditionalSlot.disconnectConditionalSlotComponent(this);
- this.disconnectSeparator();
- }
- componentDidLoad() {
- this.updateAriaValues();
- }
- // --------------------------------------------------------------------------
- //
- // 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, detached, position, initialContentWidth, contentWidth, contentWidthMax, contentWidthMin, intlResize, resizable } = this;
- const allowResizing = !detached && resizable;
- const contentNode = (index.h("div", { class: { [CSS.content]: true, [CSS.contentDetached]: detached }, hidden: collapsed, key: "content", ref: this.storeContentEl, style: allowResizing && contentWidth ? { width: `${contentWidth}px` } : null }, this.renderHeader(), index.h("div", { class: CSS.contentBody }, index.h("slot", null))));
- const separatorNode = allowResizing ? (index.h("div", { "aria-label": intlResize, "aria-orientation": "horizontal", "aria-valuemax": contentWidthMax, "aria-valuemin": contentWidthMin, "aria-valuenow": contentWidth !== null && contentWidth !== void 0 ? contentWidth : initialContentWidth, class: CSS.separator, key: "separator", onKeyDown: this.separatorKeyDown, ref: this.connectSeparator, role: "separator", tabIndex: 0, "touch-action": "none" })) : null;
- const actionBarNode = index.h("slot", { key: "action-bar", name: SLOTS.actionBar });
- const mainNodes = [actionBarNode, contentNode, separatorNode];
- 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;
- }
- 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;
- }
- index.forceUpdate(this);
- }
- get el() { return index.getElement(this); }
- static get watchers() { return {
- "collapsed": ["watchHandler"]
- }; }
- };
- ShellPanel.style = shellPanelCss;
- exports.calcite_shell = Shell;
- exports.calcite_shell_center_row = ShellCenterRow;
- exports.calcite_shell_panel = ShellPanel;
|