| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475 | 
							- /*!
 
-  * 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, h, Listen, Method, Prop, Watch } from "@stencil/core";
 
- /**
 
-  * @slot - A slot for adding `calcite-stepper-item`s.
 
-  */
 
- export class Stepper {
 
-   constructor() {
 
-     //--------------------------------------------------------------------------
 
-     //
 
-     //  Public Properties
 
-     //
 
-     //--------------------------------------------------------------------------
 
-     /** optionally display a status icon next to the step title */
 
-     this.icon = false;
 
-     /** specify the layout of stepper, defaults to horizontal */
 
-     this.layout = "horizontal";
 
-     /** optionally display the number next to the step title */
 
-     this.numbered = false;
 
-     /** specify the scale of stepper, defaults to m */
 
-     this.scale = "m";
 
-     //--------------------------------------------------------------------------
 
-     //
 
-     //  Private State/Props
 
-     //
 
-     //--------------------------------------------------------------------------
 
-     this.itemMap = new Map();
 
-     /** list of sorted Stepper items */
 
-     this.items = [];
 
-     /** list of enabled Stepper items */
 
-     this.enabledItems = [];
 
-   }
 
-   // watch for removal of disabled to register step
 
-   contentWatcher() {
 
-     if (this.layout === "horizontal") {
 
-       if (!this.stepperContentContainer && this.requestedContent) {
 
-         this.addHorizontalContentContainer();
 
-       }
 
-       this.updateContent(this.requestedContent);
 
-     }
 
-   }
 
-   //--------------------------------------------------------------------------
 
-   //
 
-   //  Lifecycle
 
-   //
 
-   //--------------------------------------------------------------------------
 
-   componentDidLoad() {
 
-     // if no stepper items are set as active, default to the first one
 
-     if (!this.currentPosition) {
 
-       this.calciteStepperItemChange.emit({
 
-         position: 0
 
-       });
 
-     }
 
-   }
 
-   componentWillLoad() {
 
-     if (this.layout === "horizontal" && !this.stepperContentContainer) {
 
-       this.addHorizontalContentContainer();
 
-     }
 
-   }
 
-   render() {
 
-     return h("slot", null);
 
-   }
 
-   //--------------------------------------------------------------------------
 
-   //
 
-   //  Event Listeners
 
-   //
 
-   //--------------------------------------------------------------------------
 
-   calciteStepperItemKeyEvent(e) {
 
-     const item = e.detail.item;
 
-     const itemToFocus = e.target;
 
-     const isFirstItem = this.itemIndex(itemToFocus) === 0;
 
-     const isLastItem = this.itemIndex(itemToFocus) === this.enabledItems.length - 1;
 
-     switch (item.key) {
 
-       case "ArrowDown":
 
-       case "ArrowRight":
 
-         if (isLastItem) {
 
-           this.focusFirstItem();
 
-         }
 
-         else {
 
-           this.focusNextItem(itemToFocus);
 
-         }
 
-         break;
 
-       case "ArrowUp":
 
-       case "ArrowLeft":
 
-         if (isFirstItem) {
 
-           this.focusLastItem();
 
-         }
 
-         else {
 
-           this.focusPrevItem(itemToFocus);
 
-         }
 
-         break;
 
-       case "Home":
 
-         this.focusFirstItem();
 
-         break;
 
-       case "End":
 
-         this.focusLastItem();
 
-         break;
 
-     }
 
-   }
 
-   registerItem(event) {
 
-     const item = event.target;
 
-     const { content, position } = event.detail;
 
-     if (content && item.active) {
 
-       this.requestedContent = content;
 
-     }
 
-     this.itemMap.set(item, position);
 
-     this.items = this.sortItems();
 
-     this.enabledItems = this.filterItems();
 
-   }
 
-   updateItem(event) {
 
-     if (event.detail.content) {
 
-       this.requestedContent = event.detail.content;
 
-     }
 
-     this.currentPosition = event.detail.position;
 
-     this.calciteStepperItemChange.emit({
 
-       position: this.currentPosition
 
-     });
 
-   }
 
-   //--------------------------------------------------------------------------
 
-   //
 
-   //  Public Methods
 
-   //
 
-   //--------------------------------------------------------------------------
 
-   /** set the next step as active */
 
-   async nextStep() {
 
-     const enabledStepIndex = this.getEnabledStepIndex(this.currentPosition + 1, "next");
 
-     if (typeof enabledStepIndex !== "number") {
 
-       return;
 
-     }
 
-     this.emitChangedItem(enabledStepIndex);
 
-   }
 
-   /** set the previous step as active */
 
-   async prevStep() {
 
-     const enabledStepIndex = this.getEnabledStepIndex(this.currentPosition - 1, "previous");
 
-     if (typeof enabledStepIndex !== "number") {
 
-       return;
 
-     }
 
-     this.emitChangedItem(enabledStepIndex);
 
-   }
 
-   /** set the requested step as active */
 
-   async goToStep(step) {
 
-     const position = step - 1;
 
-     if (this.currentPosition !== position) {
 
-       this.emitChangedItem(position);
 
-     }
 
-   }
 
-   /** set the first step as active */
 
-   async startStep() {
 
-     const enabledStepIndex = this.getEnabledStepIndex(0, "next");
 
-     if (typeof enabledStepIndex !== "number") {
 
-       return;
 
-     }
 
-     this.emitChangedItem(enabledStepIndex);
 
-   }
 
-   /** set the last step as active */
 
-   async endStep() {
 
-     const enabledStepIndex = this.getEnabledStepIndex(this.items.length - 1, "previous");
 
-     if (typeof enabledStepIndex !== "number") {
 
-       return;
 
-     }
 
-     this.emitChangedItem(enabledStepIndex);
 
-   }
 
-   //--------------------------------------------------------------------------
 
-   //
 
-   //  Private Methods
 
-   //
 
-   //--------------------------------------------------------------------------
 
-   getEnabledStepIndex(startIndex, direction = "next") {
 
-     var _a;
 
-     const { items, currentPosition } = this;
 
-     let newIndex = startIndex;
 
-     while ((_a = items[newIndex]) === null || _a === void 0 ? void 0 : _a.disabled) {
 
-       newIndex = newIndex + (direction === "previous" ? -1 : 1);
 
-     }
 
-     return newIndex !== currentPosition && newIndex < items.length && newIndex >= 0
 
-       ? newIndex
 
-       : null;
 
-   }
 
-   addHorizontalContentContainer() {
 
-     this.stepperContentContainer = document.createElement("div");
 
-     this.stepperContentContainer.classList.add("calcite-stepper-content");
 
-     this.el.insertAdjacentElement("beforeend", this.stepperContentContainer);
 
-   }
 
-   emitChangedItem(position) {
 
-     this.currentPosition = position;
 
-     this.calciteStepperItemChange.emit({
 
-       position
 
-     });
 
-   }
 
-   focusFirstItem() {
 
-     const firstItem = this.enabledItems[0];
 
-     this.focusElement(firstItem);
 
-   }
 
-   focusLastItem() {
 
-     const lastItem = this.enabledItems[this.enabledItems.length - 1];
 
-     this.focusElement(lastItem);
 
-   }
 
-   focusNextItem(e) {
 
-     const index = this.itemIndex(e);
 
-     const nextItem = this.enabledItems[index + 1] || this.enabledItems[0];
 
-     this.focusElement(nextItem);
 
-   }
 
-   focusPrevItem(e) {
 
-     const index = this.itemIndex(e);
 
-     const prevItem = this.enabledItems[index - 1] || this.enabledItems[this.enabledItems.length - 1];
 
-     this.focusElement(prevItem);
 
-   }
 
-   itemIndex(e) {
 
-     return this.enabledItems.indexOf(e);
 
-   }
 
-   focusElement(item) {
 
-     item.focus();
 
-   }
 
-   sortItems() {
 
-     const { itemMap } = this;
 
-     return Array.from(itemMap.keys()).sort((a, b) => itemMap.get(a) - itemMap.get(b));
 
-   }
 
-   filterItems() {
 
-     return this.items.filter((item) => !item.disabled);
 
-   }
 
-   updateContent(content) {
 
-     this.stepperContentContainer.innerHTML = "";
 
-     this.stepperContentContainer.append(...content);
 
-   }
 
-   static get is() { return "calcite-stepper"; }
 
-   static get encapsulation() { return "shadow"; }
 
-   static get originalStyleUrls() { return {
 
-     "$": ["stepper.scss"]
 
-   }; }
 
-   static get styleUrls() { return {
 
-     "$": ["stepper.css"]
 
-   }; }
 
-   static get properties() { return {
 
-     "icon": {
 
-       "type": "boolean",
 
-       "mutable": false,
 
-       "complexType": {
 
-         "original": "boolean",
 
-         "resolved": "boolean",
 
-         "references": {}
 
-       },
 
-       "required": false,
 
-       "optional": false,
 
-       "docs": {
 
-         "tags": [],
 
-         "text": "optionally display a status icon next to the step title"
 
-       },
 
-       "attribute": "icon",
 
-       "reflect": true,
 
-       "defaultValue": "false"
 
-     },
 
-     "layout": {
 
-       "type": "string",
 
-       "mutable": false,
 
-       "complexType": {
 
-         "original": "Layout",
 
-         "resolved": "\"grid\" | \"horizontal\" | \"vertical\"",
 
-         "references": {
 
-           "Layout": {
 
-             "location": "import",
 
-             "path": "../interfaces"
 
-           }
 
-         }
 
-       },
 
-       "required": false,
 
-       "optional": false,
 
-       "docs": {
 
-         "tags": [],
 
-         "text": "specify the layout of stepper, defaults to horizontal"
 
-       },
 
-       "attribute": "layout",
 
-       "reflect": true,
 
-       "defaultValue": "\"horizontal\""
 
-     },
 
-     "numbered": {
 
-       "type": "boolean",
 
-       "mutable": false,
 
-       "complexType": {
 
-         "original": "boolean",
 
-         "resolved": "boolean",
 
-         "references": {}
 
-       },
 
-       "required": false,
 
-       "optional": false,
 
-       "docs": {
 
-         "tags": [],
 
-         "text": "optionally display the number next to the step title"
 
-       },
 
-       "attribute": "numbered",
 
-       "reflect": true,
 
-       "defaultValue": "false"
 
-     },
 
-     "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": "specify the scale of stepper, defaults to m"
 
-       },
 
-       "attribute": "scale",
 
-       "reflect": true,
 
-       "defaultValue": "\"m\""
 
-     },
 
-     "requestedContent": {
 
-       "type": "unknown",
 
-       "mutable": true,
 
-       "complexType": {
 
-         "original": "Node[]",
 
-         "resolved": "Node[]",
 
-         "references": {
 
-           "Node": {
 
-             "location": "global"
 
-           }
 
-         }
 
-       },
 
-       "required": false,
 
-       "optional": false,
 
-       "docs": {
 
-         "tags": [{
 
-             "name": "internal",
 
-             "text": undefined
 
-           }],
 
-         "text": ""
 
-       }
 
-     }
 
-   }; }
 
-   static get events() { return [{
 
-       "method": "calciteStepperItemChange",
 
-       "name": "calciteStepperItemChange",
 
-       "bubbles": true,
 
-       "cancelable": true,
 
-       "composed": true,
 
-       "docs": {
 
-         "tags": [{
 
-             "name": "internal",
 
-             "text": undefined
 
-           }],
 
-         "text": "This event fires when the active stepper item has changed."
 
-       },
 
-       "complexType": {
 
-         "original": "StepperItemChangeEventDetail",
 
-         "resolved": "StepperItemChangeEventDetail",
 
-         "references": {
 
-           "StepperItemChangeEventDetail": {
 
-             "location": "import",
 
-             "path": "./interfaces"
 
-           }
 
-         }
 
-       }
 
-     }]; }
 
-   static get methods() { return {
 
-     "nextStep": {
 
-       "complexType": {
 
-         "signature": "() => Promise<void>",
 
-         "parameters": [],
 
-         "references": {
 
-           "Promise": {
 
-             "location": "global"
 
-           }
 
-         },
 
-         "return": "Promise<void>"
 
-       },
 
-       "docs": {
 
-         "text": "set the next step as active",
 
-         "tags": []
 
-       }
 
-     },
 
-     "prevStep": {
 
-       "complexType": {
 
-         "signature": "() => Promise<void>",
 
-         "parameters": [],
 
-         "references": {
 
-           "Promise": {
 
-             "location": "global"
 
-           }
 
-         },
 
-         "return": "Promise<void>"
 
-       },
 
-       "docs": {
 
-         "text": "set the previous step as active",
 
-         "tags": []
 
-       }
 
-     },
 
-     "goToStep": {
 
-       "complexType": {
 
-         "signature": "(step: number) => Promise<void>",
 
-         "parameters": [{
 
-             "tags": [],
 
-             "text": ""
 
-           }],
 
-         "references": {
 
-           "Promise": {
 
-             "location": "global"
 
-           }
 
-         },
 
-         "return": "Promise<void>"
 
-       },
 
-       "docs": {
 
-         "text": "set the requested step as active",
 
-         "tags": []
 
-       }
 
-     },
 
-     "startStep": {
 
-       "complexType": {
 
-         "signature": "() => Promise<void>",
 
-         "parameters": [],
 
-         "references": {
 
-           "Promise": {
 
-             "location": "global"
 
-           }
 
-         },
 
-         "return": "Promise<void>"
 
-       },
 
-       "docs": {
 
-         "text": "set the first step as active",
 
-         "tags": []
 
-       }
 
-     },
 
-     "endStep": {
 
-       "complexType": {
 
-         "signature": "() => Promise<void>",
 
-         "parameters": [],
 
-         "references": {
 
-           "Promise": {
 
-             "location": "global"
 
-           }
 
-         },
 
-         "return": "Promise<void>"
 
-       },
 
-       "docs": {
 
-         "text": "set the last step as active",
 
-         "tags": []
 
-       }
 
-     }
 
-   }; }
 
-   static get elementRef() { return "el"; }
 
-   static get watchers() { return [{
 
-       "propName": "requestedContent",
 
-       "methodName": "contentWatcher"
 
-     }]; }
 
-   static get listeners() { return [{
 
-       "name": "calciteStepperItemKeyEvent",
 
-       "method": "calciteStepperItemKeyEvent",
 
-       "target": undefined,
 
-       "capture": false,
 
-       "passive": false
 
-     }, {
 
-       "name": "calciteStepperItemRegister",
 
-       "method": "registerItem",
 
-       "target": undefined,
 
-       "capture": false,
 
-       "passive": false
 
-     }, {
 
-       "name": "calciteStepperItemSelect",
 
-       "method": "updateItem",
 
-       "target": undefined,
 
-       "capture": false,
 
-       "passive": false
 
-     }]; }
 
- }
 
 
  |