| 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.82
 
-  */
 
- import { Component, Element, Event, h, Host, Listen, Method, Prop } from "@stencil/core";
 
- import { getElementProp, toAriaBoolean } from "../../utils/dom";
 
- import { CSS } from "./resources";
 
- /**
 
-  * @slot - A slot for adding text.
 
-  */
 
- export class DropdownItem {
 
-   constructor() {
 
-     //--------------------------------------------------------------------------
 
-     //
 
-     //  Public Properties
 
-     //
 
-     //--------------------------------------------------------------------------
 
-     /** Indicates whether the item is active. */
 
-     this.active = false;
 
-   }
 
-   //--------------------------------------------------------------------------
 
-   //
 
-   //  Public Methods
 
-   //
 
-   //--------------------------------------------------------------------------
 
-   /** Sets focus on the component. */
 
-   async setFocus() {
 
-     this.el.focus();
 
-   }
 
-   //--------------------------------------------------------------------------
 
-   //
 
-   //  Lifecycle
 
-   //
 
-   //--------------------------------------------------------------------------
 
-   componentWillLoad() {
 
-     this.initialize();
 
-   }
 
-   connectedCallback() {
 
-     this.initialize();
 
-   }
 
-   render() {
 
-     const scale = getElementProp(this.el, "scale", "m");
 
-     const iconStartEl = (h("calcite-icon", { class: "dropdown-item-icon-start", flipRtl: this.iconFlipRtl === "start" || this.iconFlipRtl === "both", icon: this.iconStart, scale: "s" }));
 
-     const contentNode = (h("span", { class: "dropdown-item-content" },
 
-       h("slot", null)));
 
-     const iconEndEl = (h("calcite-icon", { class: "dropdown-item-icon-end", flipRtl: this.iconFlipRtl === "end" || this.iconFlipRtl === "both", icon: this.iconEnd, scale: "s" }));
 
-     const slottedContent = this.iconStart && this.iconEnd
 
-       ? [iconStartEl, contentNode, iconEndEl]
 
-       : this.iconStart
 
-         ? [iconStartEl, h("slot", null)]
 
-         : this.iconEnd
 
-           ? [contentNode, iconEndEl]
 
-           : contentNode;
 
-     const contentEl = !this.href ? (slottedContent) : (h("a", { "aria-label": this.label, class: "dropdown-link", href: this.href, ref: (el) => (this.childLink = el), rel: this.rel, target: this.target }, slottedContent));
 
-     const itemRole = this.href
 
-       ? null
 
-       : this.selectionMode === "single"
 
-         ? "menuitemradio"
 
-         : this.selectionMode === "multi"
 
-           ? "menuitemcheckbox"
 
-           : "menuitem";
 
-     const itemAria = this.selectionMode !== "none" ? toAriaBoolean(this.active) : null;
 
-     return (h(Host, { "aria-checked": itemAria, role: itemRole, tabindex: "0" },
 
-       h("div", { class: {
 
-           container: true,
 
-           [CSS.containerLink]: !!this.href,
 
-           [CSS.containerSmall]: scale === "s",
 
-           [CSS.containerMedium]: scale === "m",
 
-           [CSS.containerLarge]: scale === "l",
 
-           [CSS.containerMulti]: this.selectionMode === "multi",
 
-           [CSS.containerSingle]: this.selectionMode === "single",
 
-           [CSS.containerNone]: this.selectionMode === "none"
 
-         } },
 
-         this.selectionMode !== "none" ? (h("calcite-icon", { class: "dropdown-item-icon", icon: this.selectionMode === "multi" ? "check" : "bullet-point", scale: "s" })) : null,
 
-         contentEl)));
 
-   }
 
-   //--------------------------------------------------------------------------
 
-   //
 
-   //  Event Listeners
 
-   //
 
-   //--------------------------------------------------------------------------
 
-   onClick() {
 
-     this.emitRequestedItem();
 
-   }
 
-   keyDownHandler(e) {
 
-     switch (e.key) {
 
-       case " ":
 
-         this.emitRequestedItem();
 
-         if (this.href) {
 
-           e.preventDefault();
 
-           this.childLink.click();
 
-         }
 
-         break;
 
-       case "Enter":
 
-         this.emitRequestedItem();
 
-         if (this.href) {
 
-           this.childLink.click();
 
-         }
 
-         break;
 
-       case "Escape":
 
-         this.calciteDropdownCloseRequest.emit();
 
-         break;
 
-       case "Tab":
 
-       case "ArrowUp":
 
-       case "ArrowDown":
 
-       case "Home":
 
-       case "End":
 
-         this.calciteDropdownItemKeyEvent.emit({ keyboardEvent: e });
 
-         break;
 
-     }
 
-     e.preventDefault();
 
-   }
 
-   updateActiveItemOnChange(event) {
 
-     const parentEmittedChange = event.composedPath().includes(this.parentDropdownGroupEl);
 
-     if (parentEmittedChange) {
 
-       this.requestedDropdownGroup = event.detail.requestedDropdownGroup;
 
-       this.requestedDropdownItem = event.detail.requestedDropdownItem;
 
-       this.determineActiveItem();
 
-     }
 
-   }
 
-   //--------------------------------------------------------------------------
 
-   //
 
-   //  Private Methods
 
-   //
 
-   //--------------------------------------------------------------------------
 
-   initialize() {
 
-     this.selectionMode = getElementProp(this.el, "selection-mode", "single");
 
-     this.parentDropdownGroupEl = this.el.closest("calcite-dropdown-group");
 
-     if (this.selectionMode === "none") {
 
-       this.active = false;
 
-     }
 
-   }
 
-   determineActiveItem() {
 
-     switch (this.selectionMode) {
 
-       case "multi":
 
-         if (this.el === this.requestedDropdownItem) {
 
-           this.active = !this.active;
 
-         }
 
-         break;
 
-       case "single":
 
-         if (this.el === this.requestedDropdownItem) {
 
-           this.active = true;
 
-         }
 
-         else if (this.requestedDropdownGroup === this.parentDropdownGroupEl) {
 
-           this.active = false;
 
-         }
 
-         break;
 
-       case "none":
 
-         this.active = false;
 
-         break;
 
-     }
 
-   }
 
-   emitRequestedItem() {
 
-     this.calciteDropdownItemSelect.emit({
 
-       requestedDropdownItem: this.el,
 
-       requestedDropdownGroup: this.parentDropdownGroupEl
 
-     });
 
-   }
 
-   static get is() { return "calcite-dropdown-item"; }
 
-   static get encapsulation() { return "shadow"; }
 
-   static get originalStyleUrls() { return {
 
-     "$": ["dropdown-item.scss"]
 
-   }; }
 
-   static get styleUrls() { return {
 
-     "$": ["dropdown-item.css"]
 
-   }; }
 
-   static get properties() { return {
 
-     "active": {
 
-       "type": "boolean",
 
-       "mutable": true,
 
-       "complexType": {
 
-         "original": "boolean",
 
-         "resolved": "boolean",
 
-         "references": {}
 
-       },
 
-       "required": false,
 
-       "optional": false,
 
-       "docs": {
 
-         "tags": [],
 
-         "text": "Indicates whether the item is active."
 
-       },
 
-       "attribute": "active",
 
-       "reflect": true,
 
-       "defaultValue": "false"
 
-     },
 
-     "iconFlipRtl": {
 
-       "type": "string",
 
-       "mutable": false,
 
-       "complexType": {
 
-         "original": "FlipContext",
 
-         "resolved": "\"both\" | \"end\" | \"start\"",
 
-         "references": {
 
-           "FlipContext": {
 
-             "location": "import",
 
-             "path": "../interfaces"
 
-           }
 
-         }
 
-       },
 
-       "required": false,
 
-       "optional": true,
 
-       "docs": {
 
-         "tags": [],
 
-         "text": "flip the icon(s) in rtl"
 
-       },
 
-       "attribute": "icon-flip-rtl",
 
-       "reflect": true
 
-     },
 
-     "iconStart": {
 
-       "type": "string",
 
-       "mutable": false,
 
-       "complexType": {
 
-         "original": "string",
 
-         "resolved": "string",
 
-         "references": {}
 
-       },
 
-       "required": false,
 
-       "optional": true,
 
-       "docs": {
 
-         "tags": [],
 
-         "text": "optionally pass an icon to display at the start of an item - accepts calcite ui icon names"
 
-       },
 
-       "attribute": "icon-start",
 
-       "reflect": true
 
-     },
 
-     "iconEnd": {
 
-       "type": "string",
 
-       "mutable": false,
 
-       "complexType": {
 
-         "original": "string",
 
-         "resolved": "string",
 
-         "references": {}
 
-       },
 
-       "required": false,
 
-       "optional": true,
 
-       "docs": {
 
-         "tags": [],
 
-         "text": "optionally pass an icon to display at the end of an item - accepts calcite ui icon names"
 
-       },
 
-       "attribute": "icon-end",
 
-       "reflect": true
 
-     },
 
-     "href": {
 
-       "type": "string",
 
-       "mutable": false,
 
-       "complexType": {
 
-         "original": "string",
 
-         "resolved": "string",
 
-         "references": {}
 
-       },
 
-       "required": false,
 
-       "optional": true,
 
-       "docs": {
 
-         "tags": [],
 
-         "text": "optionally pass a href - used to determine if the component should render as anchor"
 
-       },
 
-       "attribute": "href",
 
-       "reflect": true
 
-     },
 
-     "label": {
 
-       "type": "string",
 
-       "mutable": false,
 
-       "complexType": {
 
-         "original": "string",
 
-         "resolved": "string",
 
-         "references": {}
 
-       },
 
-       "required": false,
 
-       "optional": true,
 
-       "docs": {
 
-         "tags": [],
 
-         "text": "Applies to the aria-label attribute on the button or hyperlink"
 
-       },
 
-       "attribute": "label",
 
-       "reflect": false
 
-     },
 
-     "rel": {
 
-       "type": "string",
 
-       "mutable": false,
 
-       "complexType": {
 
-         "original": "string",
 
-         "resolved": "string",
 
-         "references": {}
 
-       },
 
-       "required": false,
 
-       "optional": true,
 
-       "docs": {
 
-         "tags": [],
 
-         "text": "The rel attribute to apply to the hyperlink"
 
-       },
 
-       "attribute": "rel",
 
-       "reflect": false
 
-     },
 
-     "target": {
 
-       "type": "string",
 
-       "mutable": false,
 
-       "complexType": {
 
-         "original": "string",
 
-         "resolved": "string",
 
-         "references": {}
 
-       },
 
-       "required": false,
 
-       "optional": true,
 
-       "docs": {
 
-         "tags": [],
 
-         "text": "The target attribute to apply to the hyperlink"
 
-       },
 
-       "attribute": "target",
 
-       "reflect": false
 
-     }
 
-   }; }
 
-   static get events() { return [{
 
-       "method": "calciteDropdownItemSelect",
 
-       "name": "calciteDropdownItemSelect",
 
-       "bubbles": true,
 
-       "cancelable": true,
 
-       "composed": true,
 
-       "docs": {
 
-         "tags": [{
 
-             "name": "internal",
 
-             "text": undefined
 
-           }],
 
-         "text": ""
 
-       },
 
-       "complexType": {
 
-         "original": "any",
 
-         "resolved": "any",
 
-         "references": {}
 
-       }
 
-     }, {
 
-       "method": "calciteDropdownItemKeyEvent",
 
-       "name": "calciteDropdownItemKeyEvent",
 
-       "bubbles": true,
 
-       "cancelable": true,
 
-       "composed": true,
 
-       "docs": {
 
-         "tags": [{
 
-             "name": "internal",
 
-             "text": undefined
 
-           }],
 
-         "text": ""
 
-       },
 
-       "complexType": {
 
-         "original": "ItemKeyboardEvent",
 
-         "resolved": "ItemKeyboardEvent",
 
-         "references": {
 
-           "ItemKeyboardEvent": {
 
-             "location": "import",
 
-             "path": "../dropdown/interfaces"
 
-           }
 
-         }
 
-       }
 
-     }, {
 
-       "method": "calciteDropdownCloseRequest",
 
-       "name": "calciteDropdownCloseRequest",
 
-       "bubbles": true,
 
-       "cancelable": true,
 
-       "composed": true,
 
-       "docs": {
 
-         "tags": [{
 
-             "name": "internal",
 
-             "text": undefined
 
-           }],
 
-         "text": ""
 
-       },
 
-       "complexType": {
 
-         "original": "any",
 
-         "resolved": "any",
 
-         "references": {}
 
-       }
 
-     }]; }
 
-   static get methods() { return {
 
-     "setFocus": {
 
-       "complexType": {
 
-         "signature": "() => Promise<void>",
 
-         "parameters": [],
 
-         "references": {
 
-           "Promise": {
 
-             "location": "global"
 
-           }
 
-         },
 
-         "return": "Promise<void>"
 
-       },
 
-       "docs": {
 
-         "text": "Sets focus on the component.",
 
-         "tags": []
 
-       }
 
-     }
 
-   }; }
 
-   static get elementRef() { return "el"; }
 
-   static get listeners() { return [{
 
-       "name": "click",
 
-       "method": "onClick",
 
-       "target": undefined,
 
-       "capture": false,
 
-       "passive": false
 
-     }, {
 
-       "name": "keydown",
 
-       "method": "keyDownHandler",
 
-       "target": undefined,
 
-       "capture": false,
 
-       "passive": false
 
-     }, {
 
-       "name": "calciteDropdownItemChange",
 
-       "method": "updateActiveItemOnChange",
 
-       "target": "body",
 
-       "capture": false,
 
-       "passive": false
 
-     }]; }
 
- }
 
 
  |