| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389 | 
							- /*!
 
-  * 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 { Component, Element, Event, Host, Prop, Watch, h, Method } from "@stencil/core";
 
- import { ExpandToggle, toggleChildActionText } from "../functional/ExpandToggle";
 
- import { CSS, SLOTS, TEXT } from "./resources";
 
- import { getSlotted, focusElement } from "../../utils/dom";
 
- import { getOverflowCount, overflowActions, queryActions, overflowActionsDebounceInMs } from "./utils";
 
- import { createObserver } from "../../utils/observers";
 
- import { debounce } from "lodash-es";
 
- import { connectConditionalSlotComponent, disconnectConditionalSlotComponent } from "../../utils/conditionalSlot";
 
- /**
 
-  * @slot - A slot for adding `calcite-action`s that will appear at the top of the action bar.
 
-  * @slot bottom-actions - A slot for adding `calcite-action`s that will appear at the bottom of the action bar, above the collapse/expand button.
 
-  * @slot expand-tooltip - Used to set the tooltip for the expand toggle.
 
-  */
 
- export class ActionBar {
 
-   constructor() {
 
-     // --------------------------------------------------------------------------
 
-     //
 
-     //  Properties
 
-     //
 
-     // --------------------------------------------------------------------------
 
-     /**
 
-      * When set to true, the expand-toggling behavior will be disabled.
 
-      */
 
-     this.expandDisabled = false;
 
-     /**
 
-      * Indicates whether widget is expanded.
 
-      */
 
-     this.expanded = false;
 
-     /**
 
-      * Disables automatically overflowing actions that won't fit into menus.
 
-      */
 
-     this.overflowActionsDisabled = false;
 
-     this.mutationObserver = createObserver("mutation", () => {
 
-       const { el, expanded } = this;
 
-       toggleChildActionText({ parent: el, expanded });
 
-       this.conditionallyOverflowActions();
 
-     });
 
-     this.resizeObserver = createObserver("resize", (entries) => this.resizeHandlerEntries(entries));
 
-     // --------------------------------------------------------------------------
 
-     //
 
-     //  Private Methods
 
-     //
 
-     // --------------------------------------------------------------------------
 
-     this.actionMenuOpenChangeHandler = (event) => {
 
-       if (event.detail) {
 
-         const composedPath = event.composedPath();
 
-         Array.from(this.el.querySelectorAll("calcite-action-group")).forEach((group) => {
 
-           if (!composedPath.includes(group)) {
 
-             group.menuOpen = false;
 
-           }
 
-         });
 
-       }
 
-     };
 
-     this.resizeHandlerEntries = (entries) => {
 
-       entries.forEach(this.resizeHandler);
 
-     };
 
-     this.resizeHandler = (entry) => {
 
-       const { height } = entry.contentRect;
 
-       this.resize(height);
 
-     };
 
-     this.resize = debounce((height) => {
 
-       var _a;
 
-       const { el, expanded, expandDisabled } = this;
 
-       if (!height) {
 
-         return;
 
-       }
 
-       const actions = queryActions(el);
 
-       const actionCount = expandDisabled ? actions.length : actions.length + 1;
 
-       const actionGroups = Array.from(el.querySelectorAll("calcite-action-group"));
 
-       const groupCount = getSlotted(el, SLOTS.bottomActions) || !expandDisabled
 
-         ? actionGroups.length + 1
 
-         : actionGroups.length;
 
-       const overflowCount = getOverflowCount({
 
-         actionCount,
 
-         actionHeight: (_a = actions[0]) === null || _a === void 0 ? void 0 : _a.clientHeight,
 
-         height,
 
-         groupCount
 
-       });
 
-       overflowActions({
 
-         actionGroups,
 
-         expanded,
 
-         overflowCount
 
-       });
 
-     }, overflowActionsDebounceInMs);
 
-     this.conditionallyOverflowActions = () => {
 
-       if (!this.overflowActionsDisabled) {
 
-         this.overflowActions();
 
-       }
 
-     };
 
-     this.toggleExpand = () => {
 
-       this.expanded = !this.expanded;
 
-       this.calciteActionBarToggle.emit();
 
-     };
 
-     this.setExpandToggleRef = (el) => {
 
-       this.expandToggleEl = el;
 
-     };
 
-   }
 
-   expandHandler() {
 
-     this.conditionallyOverflowActions();
 
-   }
 
-   expandedHandler(expanded) {
 
-     toggleChildActionText({ parent: this.el, expanded });
 
-   }
 
-   overflowDisabledHandler(overflowActionsDisabled) {
 
-     overflowActionsDisabled
 
-       ? this.resizeObserver.disconnect()
 
-       : this.resizeObserver.observe(this.el);
 
-   }
 
-   // --------------------------------------------------------------------------
 
-   //
 
-   //  Lifecycle
 
-   //
 
-   // --------------------------------------------------------------------------
 
-   componentDidLoad() {
 
-     this.conditionallyOverflowActions();
 
-   }
 
-   connectedCallback() {
 
-     var _a, _b;
 
-     const { el, expanded } = this;
 
-     toggleChildActionText({ parent: el, expanded });
 
-     (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(el, { childList: true, subtree: true });
 
-     if (!this.overflowActionsDisabled) {
 
-       (_b = this.resizeObserver) === null || _b === void 0 ? void 0 : _b.observe(el);
 
-     }
 
-     this.conditionallyOverflowActions();
 
-     connectConditionalSlotComponent(this);
 
-   }
 
-   disconnectedCallback() {
 
-     var _a, _b;
 
-     (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
 
-     (_b = this.resizeObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
 
-     disconnectConditionalSlotComponent(this);
 
-   }
 
-   // --------------------------------------------------------------------------
 
-   //
 
-   //  Methods
 
-   //
 
-   // --------------------------------------------------------------------------
 
-   /**
 
-    * Overflows actions that won't fit into menus.
 
-    * @internal
 
-    */
 
-   async overflowActions() {
 
-     this.resize(this.el.clientHeight);
 
-   }
 
-   /** Sets focus on the component. */
 
-   async setFocus(focusId) {
 
-     if (focusId === "expand-toggle") {
 
-       await focusElement(this.expandToggleEl);
 
-       return;
 
-     }
 
-     this.el.focus();
 
-   }
 
-   // --------------------------------------------------------------------------
 
-   //
 
-   //  Render Methods
 
-   //
 
-   // --------------------------------------------------------------------------
 
-   renderBottomActionGroup() {
 
-     const { expanded, expandDisabled, intlExpand, intlCollapse, el, position, toggleExpand, scale } = this;
 
-     const tooltip = getSlotted(el, SLOTS.expandTooltip);
 
-     const expandLabel = intlExpand || TEXT.expand;
 
-     const collapseLabel = intlCollapse || TEXT.collapse;
 
-     const expandToggleNode = !expandDisabled ? (h(ExpandToggle, { el: el, expanded: expanded, intlCollapse: collapseLabel, intlExpand: expandLabel, position: position, ref: this.setExpandToggleRef, scale: scale, toggle: toggleExpand, tooltip: tooltip })) : null;
 
-     return getSlotted(el, SLOTS.bottomActions) || expandToggleNode ? (h("calcite-action-group", { class: CSS.actionGroupBottom, scale: scale },
 
-       h("slot", { name: SLOTS.bottomActions }),
 
-       h("slot", { name: SLOTS.expandTooltip }),
 
-       expandToggleNode)) : null;
 
-   }
 
-   render() {
 
-     return (h(Host, { onCalciteActionMenuOpenChange: this.actionMenuOpenChangeHandler },
 
-       h("slot", null),
 
-       this.renderBottomActionGroup()));
 
-   }
 
-   static get is() { return "calcite-action-bar"; }
 
-   static get encapsulation() { return "shadow"; }
 
-   static get originalStyleUrls() { return {
 
-     "$": ["action-bar.scss"]
 
-   }; }
 
-   static get styleUrls() { return {
 
-     "$": ["action-bar.css"]
 
-   }; }
 
-   static get properties() { return {
 
-     "expandDisabled": {
 
-       "type": "boolean",
 
-       "mutable": false,
 
-       "complexType": {
 
-         "original": "boolean",
 
-         "resolved": "boolean",
 
-         "references": {}
 
-       },
 
-       "required": false,
 
-       "optional": false,
 
-       "docs": {
 
-         "tags": [],
 
-         "text": "When set to true, the expand-toggling behavior will be disabled."
 
-       },
 
-       "attribute": "expand-disabled",
 
-       "reflect": true,
 
-       "defaultValue": "false"
 
-     },
 
-     "expanded": {
 
-       "type": "boolean",
 
-       "mutable": true,
 
-       "complexType": {
 
-         "original": "boolean",
 
-         "resolved": "boolean",
 
-         "references": {}
 
-       },
 
-       "required": false,
 
-       "optional": false,
 
-       "docs": {
 
-         "tags": [],
 
-         "text": "Indicates whether widget is expanded."
 
-       },
 
-       "attribute": "expanded",
 
-       "reflect": true,
 
-       "defaultValue": "false"
 
-     },
 
-     "intlExpand": {
 
-       "type": "string",
 
-       "mutable": false,
 
-       "complexType": {
 
-         "original": "string",
 
-         "resolved": "string",
 
-         "references": {}
 
-       },
 
-       "required": false,
 
-       "optional": true,
 
-       "docs": {
 
-         "tags": [],
 
-         "text": "Updates the label of the expand icon when the component is not expanded."
 
-       },
 
-       "attribute": "intl-expand",
 
-       "reflect": false
 
-     },
 
-     "intlCollapse": {
 
-       "type": "string",
 
-       "mutable": false,
 
-       "complexType": {
 
-         "original": "string",
 
-         "resolved": "string",
 
-         "references": {}
 
-       },
 
-       "required": false,
 
-       "optional": true,
 
-       "docs": {
 
-         "tags": [],
 
-         "text": "Updates the label of the collapse icon when the component is expanded."
 
-       },
 
-       "attribute": "intl-collapse",
 
-       "reflect": false
 
-     },
 
-     "overflowActionsDisabled": {
 
-       "type": "boolean",
 
-       "mutable": false,
 
-       "complexType": {
 
-         "original": "boolean",
 
-         "resolved": "boolean",
 
-         "references": {}
 
-       },
 
-       "required": false,
 
-       "optional": false,
 
-       "docs": {
 
-         "tags": [],
 
-         "text": "Disables automatically overflowing actions that won't fit into menus."
 
-       },
 
-       "attribute": "overflow-actions-disabled",
 
-       "reflect": false,
 
-       "defaultValue": "false"
 
-     },
 
-     "position": {
 
-       "type": "string",
 
-       "mutable": false,
 
-       "complexType": {
 
-         "original": "Position",
 
-         "resolved": "\"end\" | \"start\"",
 
-         "references": {
 
-           "Position": {
 
-             "location": "import",
 
-             "path": "../interfaces"
 
-           }
 
-         }
 
-       },
 
-       "required": false,
 
-       "optional": false,
 
-       "docs": {
 
-         "tags": [],
 
-         "text": "Arranges the component depending on the elements 'dir' property."
 
-       },
 
-       "attribute": "position",
 
-       "reflect": true
 
-     },
 
-     "scale": {
 
-       "type": "string",
 
-       "mutable": false,
 
-       "complexType": {
 
-         "original": "Scale",
 
-         "resolved": "\"l\" | \"m\" | \"s\"",
 
-         "references": {
 
-           "Scale": {
 
-             "location": "import",
 
-             "path": "../interfaces"
 
-           }
 
-         }
 
-       },
 
-       "required": false,
 
-       "optional": false,
 
-       "docs": {
 
-         "tags": [],
 
-         "text": "Specifies the size of the expand action."
 
-       },
 
-       "attribute": "scale",
 
-       "reflect": true
 
-     }
 
-   }; }
 
-   static get events() { return [{
 
-       "method": "calciteActionBarToggle",
 
-       "name": "calciteActionBarToggle",
 
-       "bubbles": true,
 
-       "cancelable": true,
 
-       "composed": true,
 
-       "docs": {
 
-         "tags": [],
 
-         "text": "Emitted when expanded has been toggled."
 
-       },
 
-       "complexType": {
 
-         "original": "any",
 
-         "resolved": "any",
 
-         "references": {}
 
-       }
 
-     }]; }
 
-   static get methods() { return {
 
-     "overflowActions": {
 
-       "complexType": {
 
-         "signature": "() => Promise<void>",
 
-         "parameters": [],
 
-         "references": {
 
-           "Promise": {
 
-             "location": "global"
 
-           }
 
-         },
 
-         "return": "Promise<void>"
 
-       },
 
-       "docs": {
 
-         "text": "Overflows actions that won't fit into menus.",
 
-         "tags": [{
 
-             "name": "internal",
 
-             "text": undefined
 
-           }]
 
-       }
 
-     },
 
-     "setFocus": {
 
-       "complexType": {
 
-         "signature": "(focusId?: \"expand-toggle\") => Promise<void>",
 
-         "parameters": [{
 
-             "tags": [],
 
-             "text": ""
 
-           }],
 
-         "references": {
 
-           "Promise": {
 
-             "location": "global"
 
-           }
 
-         },
 
-         "return": "Promise<void>"
 
-       },
 
-       "docs": {
 
-         "text": "Sets focus on the component.",
 
-         "tags": []
 
-       }
 
-     }
 
-   }; }
 
-   static get elementRef() { return "el"; }
 
-   static get watchers() { return [{
 
-       "propName": "expandDisabled",
 
-       "methodName": "expandHandler"
 
-     }, {
 
-       "propName": "expanded",
 
-       "methodName": "expandedHandler"
 
-     }, {
 
-       "propName": "overflowActionsDisabled",
 
-       "methodName": "overflowDisabledHandler"
 
-     }]; }
 
- }
 
 
  |