/*! * 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.82 */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); const index = require('./index-5c65e149.js'); const dom = require('./dom-9ac0341c.js'); const Heading = require('./Heading-0cb5902d.js'); const resources = require('./resources-1a214670.js'); const conditionalSlot = require('./conditionalSlot-ba5cd797.js'); const interactive = require('./interactive-e294111f.js'); const observers = require('./observers-d9fdf006.js'); require('./guid-8b6d6cb4.js'); const CSS = { backButton: "back-button", container: "container", header: "header", heading: "heading", summary: "summary", headerContent: "header-content", headerActions: "header-actions", headerActionsEnd: "header-actions--end", headerActionsStart: "header-actions--start", contentWrapper: "content-wrapper", contentContainer: "content-container", contentHeight: "content-height", fabContainer: "fab-container", footer: "footer", menuContainer: "menu-container", menuButton: "menu-button", menu: "menu", menuOpen: "menu--open" }; const ICONS = { close: "x", menu: "ellipsis", backLeft: "chevron-left", backRight: "chevron-right" }; const SLOTS = { headerActionsStart: "header-actions-start", headerActionsEnd: "header-actions-end", headerMenuActions: "header-menu-actions", headerContent: "header-content", fab: "fab", footer: "footer", footerActions: "footer-actions" }; const TEXT = { back: "Back", close: "Close", open: "Open", options: "Options" }; const HEADING_LEVEL = 3; const panelCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:host{-webkit-box-sizing:border-box;box-sizing:border-box;background-color:var(--calcite-ui-foreground-1);color:var(--calcite-ui-text-2);font-size:var(--calcite-font-size--1)}:host *{-webkit-box-sizing:border-box;box-sizing:border-box}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{position:relative;display:-ms-flexbox;display:flex;width:100%;-ms-flex:1 1 auto;flex:1 1 auto;overflow:hidden;--calcite-min-header-height:calc(var(--calcite-icon-size) * 3);--calcite-panel-max-height:unset;--calcite-panel-width:100%;--calcite-panel-min-width:unset;--calcite-panel-max-width:unset}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}.header{margin:0px;display:-ms-flexbox;display:flex;-ms-flex-line-pack:justify;align-content:space-between;-ms-flex-align:center;align-items:center;fill:var(--calcite-ui-text-2);color:var(--calcite-ui-text-2)}.heading{margin:0px;padding:0px;font-weight:var(--calcite-font-weight-medium)}.header .heading{-ms-flex:1 1 auto;flex:1 1 auto;padding:0.5rem}h1.heading{font-size:var(--calcite-font-size-2);line-height:1.5rem}h2.heading{font-size:var(--calcite-font-size-1);line-height:1.5rem}h3.heading{font-size:var(--calcite-font-size-0);line-height:1.25rem}h4.heading,h5.heading{font-size:var(--calcite-font-size--1);line-height:1rem}.container{margin:0px;display:-ms-flexbox;display:flex;width:100%;-ms-flex:1 1 auto;flex:1 1 auto;-ms-flex-direction:column;flex-direction:column;-ms-flex-align:stretch;align-items:stretch;background-color:var(--calcite-ui-background);padding:0px;max-height:var(--calcite-panel-max-height);width:var(--calcite-panel-width);max-width:var(--calcite-panel-max-width);min-width:var(--calcite-panel-min-width);-webkit-transition:max-height var(--calcite-animation-timing), width var(--calcite-animation-timing);transition:max-height var(--calcite-animation-timing), width var(--calcite-animation-timing)}:host([height-scale=s]){--calcite-panel-max-height:40vh}:host([height-scale=m]){--calcite-panel-max-height:60vh}:host([height-scale=l]){--calcite-panel-max-height:80vh}:host([width-scale=s]){--calcite-panel-width:calc(var(--calcite-panel-width-multiplier) * 12vw);--calcite-panel-max-width:calc(var(--calcite-panel-width-multiplier) * 300px);--calcite-panel-min-width:calc(var(--calcite-panel-width-multiplier) * 150px)}:host([width-scale=m]){--calcite-panel-width:calc(var(--calcite-panel-width-multiplier) * 20vw);--calcite-panel-max-width:calc(var(--calcite-panel-width-multiplier) * 420px);--calcite-panel-min-width:calc(var(--calcite-panel-width-multiplier) * 240px)}:host([width-scale=l]){--calcite-panel-width:calc(var(--calcite-panel-width-multiplier) * 45vw);--calcite-panel-max-width:calc(var(--calcite-panel-width-multiplier) * 680px);--calcite-panel-min-width:calc(var(--calcite-panel-width-multiplier) * 340px)}.container[hidden]{display:none}:host([loading]) .container,:host([disabled]) .container{position:relative}.header{border-bottom:1px solid;position:-webkit-sticky;position:sticky;top:0px;width:100%;-ms-flex-align:stretch;align-items:stretch;-ms-flex-pack:start;justify-content:flex-start;background-color:var(--calcite-ui-foreground-1);border-bottom-color:var(--calcite-ui-border-3);-ms-flex:0 0 auto;flex:0 0 auto}.header-content{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;overflow:hidden;padding-left:0.75rem;padding-right:0.75rem;padding-top:0.875rem;padding-bottom:0.875rem;-webkit-margin-end:auto;margin-inline-end:auto}.header-content .heading,.header-content .summary{display:block;overflow-wrap:break-word;padding:0px}.header-content .heading{margin-left:0px;margin-right:0px;margin-top:0px;margin-bottom:0.25rem;font-size:var(--calcite-font-size-0);line-height:1.25rem;font-weight:var(--calcite-font-weight-medium)}.header-content .heading:only-child{margin-bottom:0px}.header-content .summary{font-size:var(--calcite-font-size--1);line-height:1rem;color:var(--calcite-ui-text-2)}.back-button{border-width:0px;border-style:solid;border-color:var(--calcite-ui-border-3);border-inline-end-width:1px}.header-actions{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-wrap:nowrap;flex-wrap:nowrap;-ms-flex-align:stretch;align-items:stretch}.header-actions--end,.menu-container:only-child{-webkit-margin-start:auto;margin-inline-start:auto}.menu-button{position:relative;height:100%;-ms-flex:0 1 auto;flex:0 1 auto;-ms-flex-item-align:stretch;align-self:stretch}.menu{min-width:10rem;-ms-flex-flow:column nowrap;flex-flow:column nowrap}.content-wrapper{overflow:auto}.content-height{height:100%}.content-container{display:-ms-flexbox;display:flex;-ms-flex:1 1 auto;flex:1 1 auto;-ms-flex-direction:column;flex-direction:column;-ms-flex-wrap:nowrap;flex-wrap:nowrap;-ms-flex-align:stretch;align-items:stretch;background-color:var(--calcite-ui-background)}.footer{border-top:1px solid;position:-webkit-sticky;position:sticky;bottom:0px;display:-ms-flexbox;display:flex;width:100%;-ms-flex-pack:space-evenly;justify-content:space-evenly;background-color:var(--calcite-ui-foreground-1);border-top-color:var(--calcite-ui-border-3);-ms-flex:0 0 auto;flex:0 0 auto;min-height:3rem;padding:0.5rem}.fab-container{position:-webkit-sticky;position:sticky;bottom:0px;left:0px;right:0px;margin-top:0px;margin-bottom:0px;margin-left:auto;margin-right:auto;display:block;padding:0.5rem;width:-moz-fit-content;width:-webkit-fit-content;width:fit-content}"; const Panel = class { constructor(hostRef) { index.registerInstance(this, hostRef); this.calcitePanelDismiss = index.createEvent(this, "calcitePanelDismiss", 7); this.calcitePanelDismissedChange = index.createEvent(this, "calcitePanelDismissedChange", 7); this.calcitePanelScroll = index.createEvent(this, "calcitePanelScroll", 7); this.calcitePanelBackClick = index.createEvent(this, "calcitePanelBackClick", 7); // -------------------------------------------------------------------------- // // Properties // // -------------------------------------------------------------------------- /** * Hides the panel. */ this.dismissed = false; /** * When true, disabled prevents interaction. This state shows items with lower opacity/grayed. */ this.disabled = false; /** * Displays a close button in the trailing side of the header. */ this.dismissible = false; /** * Shows a back button in the header. */ this.showBackButton = false; /** * When true, content is waiting to be loaded. This state shows a busy indicator. */ this.loading = false; /** * Opens the action menu. */ this.menuOpen = false; this.resizeObserver = observers.createObserver("resize", () => this.resizeHandler()); // -------------------------------------------------------------------------- // // Private Methods // // -------------------------------------------------------------------------- this.resizeHandler = () => { const { panelScrollEl } = this; if (!panelScrollEl || typeof panelScrollEl.scrollHeight !== "number" || typeof panelScrollEl.offsetHeight !== "number") { return; } panelScrollEl.tabIndex = panelScrollEl.scrollHeight > panelScrollEl.offsetHeight ? 0 : -1; }; this.setContainerRef = (node) => { this.containerEl = node; }; this.setDismissRef = (node) => { this.dismissButtonEl = node; }; this.setBackRef = (node) => { this.backButtonEl = node; }; this.panelKeyDownHandler = (event) => { if (event.key === "Escape") { this.dismiss(); } }; this.dismiss = () => { this.dismissed = true; this.calcitePanelDismiss.emit(); }; this.panelScrollHandler = () => { this.calcitePanelScroll.emit(); }; this.backButtonClick = () => { this.calcitePanelBackClick.emit(); }; this.setPanelScrollEl = (el) => { var _a, _b; this.panelScrollEl = el; (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect(); if (el) { (_b = this.resizeObserver) === null || _b === void 0 ? void 0 : _b.observe(el); this.resizeHandler(); } }; } dismissedHandler() { this.calcitePanelDismissedChange.emit(); } //-------------------------------------------------------------------------- // // Lifecycle // //-------------------------------------------------------------------------- componentDidRender() { interactive.updateHostInteraction(this); } // -------------------------------------------------------------------------- // // Lifecycle // // -------------------------------------------------------------------------- connectedCallback() { conditionalSlot.connectConditionalSlotComponent(this); } disconnectedCallback() { var _a; conditionalSlot.disconnectConditionalSlotComponent(this); (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect(); } // -------------------------------------------------------------------------- // // Methods // // -------------------------------------------------------------------------- /** Sets focus on the component. */ async setFocus(focusId) { var _a, _b, _c; if (focusId === "dismiss-button") { (_a = this.dismissButtonEl) === null || _a === void 0 ? void 0 : _a.setFocus(); return; } if (focusId === "back-button") { (_b = this.backButtonEl) === null || _b === void 0 ? void 0 : _b.setFocus(); return; } (_c = this.containerEl) === null || _c === void 0 ? void 0 : _c.focus(); } /** Scrolls panel content to a particular set of coordinates. * * ``` * myCalcitePanel.scrollContentTo({ * left: 0, // Specifies the number of pixels along the X axis to scroll the window or element. * top: 0, // Specifies the number of pixels along the Y axis to scroll the window or element * behavior: "auto" // Specifies whether the scrolling should animate smoothly (smooth), or happen instantly in a single jump (auto, the default value). * }); * ``` */ async scrollContentTo(options) { var _a; (_a = this.panelScrollEl) === null || _a === void 0 ? void 0 : _a.scrollTo(options); } // -------------------------------------------------------------------------- // // Render Methods // // -------------------------------------------------------------------------- renderBackButton() { const { el } = this; const rtl = dom.getElementDir(el) === "rtl"; const { showBackButton, intlBack, backButtonClick } = this; const label = intlBack || TEXT.back; const icon = rtl ? ICONS.backRight : ICONS.backLeft; return showBackButton ? (index.h("calcite-action", { "aria-label": label, class: CSS.backButton, icon: icon, key: "back-button", onClick: backButtonClick, ref: this.setBackRef, scale: "s", slot: SLOTS.headerActionsStart, text: label })) : null; } renderHeaderContent() { const { heading, headingLevel, summary } = this; const headingNode = heading ? (index.h(Heading.Heading, { class: CSS.heading, level: headingLevel || HEADING_LEVEL }, heading)) : null; const summaryNode = summary ? index.h("span", { class: CSS.summary }, summary) : null; return headingNode || summaryNode ? (index.h("div", { class: CSS.headerContent, key: "header-content" }, headingNode, summaryNode)) : null; } /** * Allows user to override the entire header-content node. */ renderHeaderSlottedContent() { return (index.h("div", { class: CSS.headerContent, key: "slotted-header-content" }, index.h("slot", { name: SLOTS.headerContent }))); } renderHeaderStartActions() { const { el } = this; const hasStartActions = dom.getSlotted(el, SLOTS.headerActionsStart); return hasStartActions ? (index.h("div", { class: { [CSS.headerActionsStart]: true, [CSS.headerActions]: true }, key: "header-actions-start" }, index.h("slot", { name: SLOTS.headerActionsStart }))) : null; } renderHeaderActionsEnd() { const { dismiss, dismissible, el, intlClose } = this; const text = intlClose || TEXT.close; const dismissibleNode = dismissible ? (index.h("calcite-action", { "aria-label": text, icon: ICONS.close, onClick: dismiss, ref: this.setDismissRef, text: text })) : null; const slotNode = index.h("slot", { name: SLOTS.headerActionsEnd }); const hasEndActions = dom.getSlotted(el, SLOTS.headerActionsEnd); return hasEndActions || dismissibleNode ? (index.h("div", { class: { [CSS.headerActionsEnd]: true, [CSS.headerActions]: true }, key: "header-actions-end" }, slotNode, dismissibleNode)) : null; } renderMenu() { const { el, intlOptions, menuOpen } = this; const hasMenuItems = dom.getSlotted(el, SLOTS.headerMenuActions); return hasMenuItems ? (index.h("calcite-action-menu", { flipPlacements: ["top", "bottom"], key: "menu", label: intlOptions || TEXT.options, open: menuOpen, placement: "bottom-end" }, index.h("calcite-action", { icon: ICONS.menu, slot: resources.SLOTS.trigger, text: intlOptions || TEXT.options }), index.h("slot", { name: SLOTS.headerMenuActions }))) : null; } renderHeaderNode() { const { el, showBackButton } = this; const backButtonNode = this.renderBackButton(); const hasHeaderSlottedContent = dom.getSlotted(el, SLOTS.headerContent); const headerContentNode = hasHeaderSlottedContent ? this.renderHeaderSlottedContent() : this.renderHeaderContent(); const actionsNodeStart = this.renderHeaderStartActions(); const actionsNodeEnd = this.renderHeaderActionsEnd(); const headerMenuNode = this.renderMenu(); return actionsNodeStart || headerContentNode || actionsNodeEnd || headerMenuNode || showBackButton ? (index.h("header", { class: CSS.header }, backButtonNode, actionsNodeStart, headerContentNode, actionsNodeEnd, headerMenuNode)) : null; } renderFooterNode() { const { el } = this; const hasFooterSlottedContent = dom.getSlotted(el, SLOTS.footer); const hasFooterActions = dom.getSlotted(el, SLOTS.footerActions); return hasFooterSlottedContent || hasFooterActions ? (index.h("footer", { class: CSS.footer, key: "footer" }, hasFooterSlottedContent ? index.h("slot", { key: "footer-slot", name: SLOTS.footer }) : null, hasFooterActions ? index.h("slot", { key: "footer-actions-slot", name: SLOTS.footerActions }) : null)) : null; } renderContent() { const { el } = this; const hasFab = dom.getSlotted(el, SLOTS.fab); const defaultSlotNode = index.h("slot", { key: "default-slot" }); const contentWrapperKey = "content-wrapper"; return hasFab ? (index.h("div", { class: { [CSS.contentWrapper]: true, [CSS.contentHeight]: true }, key: contentWrapperKey, onScroll: this.panelScrollHandler, ref: this.setPanelScrollEl }, index.h("section", { class: CSS.contentContainer }, defaultSlotNode), this.renderFab())) : (index.h("section", { class: { [CSS.contentWrapper]: true, [CSS.contentContainer]: true }, key: contentWrapperKey, onScroll: this.panelScrollHandler, ref: this.setPanelScrollEl }, defaultSlotNode)); } renderFab() { return (index.h("div", { class: CSS.fabContainer }, index.h("slot", { name: SLOTS.fab }))); } render() { const { dismissed, dismissible, loading, panelKeyDownHandler } = this; const panelNode = (index.h("article", { "aria-busy": dom.toAriaBoolean(loading), class: CSS.container, hidden: dismissible && dismissed, onKeyDown: panelKeyDownHandler, ref: this.setContainerRef, tabIndex: dismissible ? 0 : -1 }, this.renderHeaderNode(), this.renderContent(), this.renderFooterNode())); return (index.h(index.Fragment, null, loading ? index.h("calcite-scrim", { loading: loading }) : null, panelNode)); } get el() { return index.getElement(this); } static get watchers() { return { "dismissed": ["dismissedHandler"] }; } }; Panel.style = panelCss; exports.calcite_panel = Panel;