123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- /*!
- * 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
- */
- import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
- import { c as createObserver } from './observers.js';
- const CSS = {
- frame: "frame",
- frameAdvancing: "frame--advancing",
- frameRetreating: "frame--retreating"
- };
- const flowCss = "@-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;-ms-flex-align:stretch;align-items:stretch;overflow:hidden;background-color:transparent}:host .frame{position:relative;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;padding:0px}:host ::slotted(calcite-panel){height:100%}:host ::slotted(.calcite-match-height:last-child){display:-ms-flexbox;display:flex;-ms-flex:1 1 auto;flex:1 1 auto;overflow:hidden}:host .frame--advancing{-webkit-animation:calcite-frame-advance var(--calcite-animation-timing);animation:calcite-frame-advance var(--calcite-animation-timing)}:host .frame--retreating{-webkit-animation:calcite-frame-retreat var(--calcite-animation-timing);animation:calcite-frame-retreat var(--calcite-animation-timing)}@-webkit-keyframes calcite-frame-advance{0%{--tw-bg-opacity:0.5;-webkit-transform:translate3d(50px, 0, 0);transform:translate3d(50px, 0, 0)}100%{--tw-bg-opacity:1;-webkit-transform:translate3d(0, 0, 0);transform:translate3d(0, 0, 0)}}@keyframes calcite-frame-advance{0%{--tw-bg-opacity:0.5;-webkit-transform:translate3d(50px, 0, 0);transform:translate3d(50px, 0, 0)}100%{--tw-bg-opacity:1;-webkit-transform:translate3d(0, 0, 0);transform:translate3d(0, 0, 0)}}@-webkit-keyframes calcite-frame-retreat{0%{--tw-bg-opacity:0.5;-webkit-transform:translate3d(-50px, 0, 0);transform:translate3d(-50px, 0, 0)}100%{--tw-bg-opacity:1;-webkit-transform:translate3d(0, 0, 0);transform:translate3d(0, 0, 0)}}@keyframes calcite-frame-retreat{0%{--tw-bg-opacity:0.5;-webkit-transform:translate3d(-50px, 0, 0);transform:translate3d(-50px, 0, 0)}100%{--tw-bg-opacity:1;-webkit-transform:translate3d(0, 0, 0);transform:translate3d(0, 0, 0)}}";
- const Flow = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.panelCount = 0;
- this.flowDirection = null;
- this.panels = [];
- this.getFlowDirection = (oldPanelCount, newPanelCount) => {
- const allowRetreatingDirection = oldPanelCount > 1;
- const allowAdvancingDirection = oldPanelCount && newPanelCount > 1;
- if (!allowAdvancingDirection && !allowRetreatingDirection) {
- return null;
- }
- return newPanelCount < oldPanelCount ? "retreating" : "advancing";
- };
- this.updateFlowProps = () => {
- const { panels } = this;
- const newPanels = Array.from(this.el.querySelectorAll("calcite-panel"));
- const oldPanelCount = panels.length;
- const newPanelCount = newPanels.length;
- const activePanel = newPanels[newPanelCount - 1];
- const previousPanel = newPanels[newPanelCount - 2];
- if (newPanelCount && activePanel) {
- newPanels.forEach((panelNode) => {
- panelNode.showBackButton = newPanelCount > 1;
- panelNode.hidden = panelNode !== activePanel;
- });
- }
- if (previousPanel) {
- previousPanel.menuOpen = false;
- }
- this.panels = newPanels;
- if (oldPanelCount !== newPanelCount) {
- const flowDirection = this.getFlowDirection(oldPanelCount, newPanelCount);
- this.panelCount = newPanelCount;
- this.flowDirection = flowDirection;
- }
- };
- this.panelItemMutationObserver = createObserver("mutation", this.updateFlowProps);
- }
- // --------------------------------------------------------------------------
- //
- // Public Methods
- //
- // --------------------------------------------------------------------------
- /**
- * Removes the currently active `calcite-panel`.
- */
- async back() {
- const lastItem = this.el.querySelector("calcite-panel:last-child");
- if (!lastItem) {
- return;
- }
- const beforeBack = lastItem.beforeBack
- ? lastItem.beforeBack
- : () => Promise.resolve();
- return beforeBack.call(lastItem).then(() => {
- lastItem.remove();
- return lastItem;
- });
- }
- // --------------------------------------------------------------------------
- //
- // Lifecycle
- //
- // --------------------------------------------------------------------------
- connectedCallback() {
- var _a;
- (_a = this.panelItemMutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true, subtree: true });
- this.updateFlowProps();
- }
- disconnectedCallback() {
- var _a;
- (_a = this.panelItemMutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
- }
- // --------------------------------------------------------------------------
- //
- // Private Methods
- //
- // --------------------------------------------------------------------------
- handleCalcitePanelBackClick() {
- this.back();
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- render() {
- const { flowDirection, panelCount } = this;
- const frameDirectionClasses = {
- [CSS.frame]: true,
- [CSS.frameAdvancing]: flowDirection === "advancing",
- [CSS.frameRetreating]: flowDirection === "retreating"
- };
- return (h("div", { class: frameDirectionClasses, key: panelCount }, h("slot", null)));
- }
- get el() { return this; }
- static get style() { return flowCss; }
- }, [1, "calcite-flow", {
- "panelCount": [32],
- "flowDirection": [32],
- "panels": [32],
- "back": [64]
- }, [[0, "calcitePanelBackClick", "handleCalcitePanelBackClick"]]]);
- function defineCustomElement$1() {
- if (typeof customElements === "undefined") {
- return;
- }
- const components = ["calcite-flow"];
- components.forEach(tagName => { switch (tagName) {
- case "calcite-flow":
- if (!customElements.get(tagName)) {
- customElements.define(tagName, Flow);
- }
- break;
- } });
- }
- defineCustomElement$1();
- const CalciteFlow = Flow;
- const defineCustomElement = defineCustomElement$1;
- export { CalciteFlow, defineCustomElement };
|