| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298 | 
							- /*!
 
-  * 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, h, Prop, Event, Element, Method } from "@stencil/core";
 
- import { getSlotted } from "../../utils/dom";
 
- import { guid } from "../../utils/guid";
 
- import { CSS, TEXT, SLOTS, ICONS } from "./resources";
 
- import { connectConditionalSlotComponent, disconnectConditionalSlotComponent } from "../../utils/conditionalSlot";
 
- /**
 
-  * @slot - A slot for adding text.
 
-  * @slot image - A slot for adding an image.
 
-  */
 
- export class Chip {
 
-   constructor() {
 
-     //--------------------------------------------------------------------------
 
-     //
 
-     //  Public Properties
 
-     //
 
-     //--------------------------------------------------------------------------
 
-     /** specify the appearance style of the button, defaults to solid. */
 
-     this.appearance = "solid";
 
-     /** specify the color of the button, defaults to blue */
 
-     this.color = "grey";
 
-     /** Optionally show a button the user can click to dismiss the chip */
 
-     this.dismissible = false;
 
-     /** Aria label for the "x" button
 
-      * @default "Close"
 
-      */
 
-     this.dismissLabel = TEXT.close;
 
-     /** flip the icon in rtl */
 
-     this.iconFlipRtl = false;
 
-     /** specify the scale of the chip, defaults to m */
 
-     this.scale = "m";
 
-     // --------------------------------------------------------------------------
 
-     //
 
-     //  Private Methods
 
-     //
 
-     // --------------------------------------------------------------------------
 
-     this.closeClickHandler = (event) => {
 
-       event.preventDefault();
 
-       this.calciteChipDismiss.emit(this.el);
 
-     };
 
-     this.guid = guid();
 
-   }
 
-   // --------------------------------------------------------------------------
 
-   //
 
-   //  Lifecycle
 
-   //
 
-   // --------------------------------------------------------------------------
 
-   connectedCallback() {
 
-     connectConditionalSlotComponent(this);
 
-   }
 
-   disconnectedCallback() {
 
-     disconnectConditionalSlotComponent(this);
 
-   }
 
-   //--------------------------------------------------------------------------
 
-   //
 
-   //  Public Methods
 
-   //
 
-   //--------------------------------------------------------------------------
 
-   /** Sets focus on the component. */
 
-   async setFocus() {
 
-     var _a;
 
-     (_a = this.closeButton) === null || _a === void 0 ? void 0 : _a.focus();
 
-   }
 
-   //--------------------------------------------------------------------------
 
-   //
 
-   //  Render Methods
 
-   //
 
-   //--------------------------------------------------------------------------
 
-   renderChipImage() {
 
-     const { el } = this;
 
-     const hasChipImage = getSlotted(el, SLOTS.image);
 
-     return hasChipImage ? (h("div", { class: CSS.imageContainer, key: "image" },
 
-       h("slot", { name: SLOTS.image }))) : null;
 
-   }
 
-   render() {
 
-     const iconEl = (h("calcite-icon", { class: CSS.chipIcon, flipRtl: this.iconFlipRtl, icon: this.icon, scale: "s" }));
 
-     const closeButton = (h("button", { "aria-describedby": this.guid, "aria-label": this.dismissLabel, class: CSS.close, onClick: this.closeClickHandler, ref: (el) => (this.closeButton = el) },
 
-       h("calcite-icon", { class: CSS.closeIcon, icon: ICONS.close, scale: "s" })));
 
-     return (h("div", { class: "container" },
 
-       this.renderChipImage(),
 
-       this.icon ? iconEl : null,
 
-       h("span", { class: CSS.title, id: this.guid },
 
-         h("slot", null)),
 
-       this.dismissible ? closeButton : null));
 
-   }
 
-   static get is() { return "calcite-chip"; }
 
-   static get encapsulation() { return "shadow"; }
 
-   static get originalStyleUrls() { return {
 
-     "$": ["chip.scss"]
 
-   }; }
 
-   static get styleUrls() { return {
 
-     "$": ["chip.css"]
 
-   }; }
 
-   static get properties() { return {
 
-     "appearance": {
 
-       "type": "string",
 
-       "mutable": false,
 
-       "complexType": {
 
-         "original": "Extract<\"solid\" | \"clear\", Appearance>",
 
-         "resolved": "\"clear\" | \"solid\"",
 
-         "references": {
 
-           "Extract": {
 
-             "location": "global"
 
-           },
 
-           "Appearance": {
 
-             "location": "import",
 
-             "path": "../interfaces"
 
-           }
 
-         }
 
-       },
 
-       "required": false,
 
-       "optional": false,
 
-       "docs": {
 
-         "tags": [],
 
-         "text": "specify the appearance style of the button, defaults to solid."
 
-       },
 
-       "attribute": "appearance",
 
-       "reflect": true,
 
-       "defaultValue": "\"solid\""
 
-     },
 
-     "color": {
 
-       "type": "string",
 
-       "mutable": false,
 
-       "complexType": {
 
-         "original": "ChipColor",
 
-         "resolved": "\"blue\" | \"green\" | \"grey\" | \"red\" | \"yellow\"",
 
-         "references": {
 
-           "ChipColor": {
 
-             "location": "import",
 
-             "path": "./interfaces"
 
-           }
 
-         }
 
-       },
 
-       "required": false,
 
-       "optional": false,
 
-       "docs": {
 
-         "tags": [],
 
-         "text": "specify the color of the button, defaults to blue"
 
-       },
 
-       "attribute": "color",
 
-       "reflect": true,
 
-       "defaultValue": "\"grey\""
 
-     },
 
-     "dismissible": {
 
-       "type": "boolean",
 
-       "mutable": false,
 
-       "complexType": {
 
-         "original": "boolean",
 
-         "resolved": "boolean",
 
-         "references": {}
 
-       },
 
-       "required": false,
 
-       "optional": false,
 
-       "docs": {
 
-         "tags": [],
 
-         "text": "Optionally show a button the user can click to dismiss the chip"
 
-       },
 
-       "attribute": "dismissible",
 
-       "reflect": true,
 
-       "defaultValue": "false"
 
-     },
 
-     "dismissLabel": {
 
-       "type": "string",
 
-       "mutable": false,
 
-       "complexType": {
 
-         "original": "string",
 
-         "resolved": "string",
 
-         "references": {}
 
-       },
 
-       "required": false,
 
-       "optional": true,
 
-       "docs": {
 
-         "tags": [{
 
-             "name": "default",
 
-             "text": "\"Close\""
 
-           }],
 
-         "text": "Aria label for the \"x\" button"
 
-       },
 
-       "attribute": "dismiss-label",
 
-       "reflect": false,
 
-       "defaultValue": "TEXT.close"
 
-     },
 
-     "icon": {
 
-       "type": "string",
 
-       "mutable": false,
 
-       "complexType": {
 
-         "original": "string",
 
-         "resolved": "string",
 
-         "references": {}
 
-       },
 
-       "required": false,
 
-       "optional": true,
 
-       "docs": {
 
-         "tags": [],
 
-         "text": "optionally pass an icon to display - accepts Calcite UI icon names"
 
-       },
 
-       "attribute": "icon",
 
-       "reflect": true
 
-     },
 
-     "iconFlipRtl": {
 
-       "type": "boolean",
 
-       "mutable": false,
 
-       "complexType": {
 
-         "original": "boolean",
 
-         "resolved": "boolean",
 
-         "references": {}
 
-       },
 
-       "required": false,
 
-       "optional": false,
 
-       "docs": {
 
-         "tags": [],
 
-         "text": "flip the icon in rtl"
 
-       },
 
-       "attribute": "icon-flip-rtl",
 
-       "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 the chip, defaults to m"
 
-       },
 
-       "attribute": "scale",
 
-       "reflect": true,
 
-       "defaultValue": "\"m\""
 
-     },
 
-     "value": {
 
-       "type": "any",
 
-       "mutable": false,
 
-       "complexType": {
 
-         "original": "any",
 
-         "resolved": "any",
 
-         "references": {}
 
-       },
 
-       "required": true,
 
-       "optional": false,
 
-       "docs": {
 
-         "tags": [],
 
-         "text": "The assigned value for the chip"
 
-       },
 
-       "attribute": "value",
 
-       "reflect": false
 
-     }
 
-   }; }
 
-   static get events() { return [{
 
-       "method": "calciteChipDismiss",
 
-       "name": "calciteChipDismiss",
 
-       "bubbles": true,
 
-       "cancelable": true,
 
-       "composed": true,
 
-       "docs": {
 
-         "tags": [],
 
-         "text": "Emitted when the dismiss button is clicked"
 
-       },
 
-       "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"; }
 
- }
 
 
  |