| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577 | 
							- /*!
 
-  * 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 "form-request-submit-polyfill/form-request-submit-polyfill";
 
- import { Component, Element, h, Method, Prop, Build, State, Watch } from "@stencil/core";
 
- import { CSS, TEXT } from "./resources";
 
- import { closestElementCrossShadowBoundary } from "../../utils/dom";
 
- import { connectLabel, disconnectLabel, getLabelText } from "../../utils/label";
 
- import { createObserver } from "../../utils/observers";
 
- import { updateHostInteraction } from "../../utils/interactive";
 
- import { submitForm, resetForm } from "../../utils/form";
 
- /** Passing a 'href' will render an anchor link, instead of a button. Role will be set to link, or button, depending on this. */
 
- /** It is the consumers responsibility to add aria information, rel, target, for links, and any button attributes for form submission */
 
- /** @slot - A slot for adding text. */
 
- export class Button {
 
-   constructor() {
 
-     //--------------------------------------------------------------------------
 
-     //
 
-     //  Properties
 
-     //
 
-     //--------------------------------------------------------------------------
 
-     /** optionally specify alignment of button elements. */
 
-     this.alignment = "center";
 
-     /** specify the appearance style of the button, defaults to solid. */
 
-     this.appearance = "solid";
 
-     /** specify the color of the button, defaults to blue */
 
-     this.color = "blue";
 
-     /** is the button disabled  */
 
-     this.disabled = false;
 
-     /** string to override English loading text
 
-      * @default "Loading"
 
-      */
 
-     this.intlLoading = TEXT.loading;
 
-     /** optionally add a calcite-loader component to the button, disabling interaction.  */
 
-     this.loading = false;
 
-     /** optionally add a round style to the button  */
 
-     this.round = false;
 
-     /** specify the scale of the button, defaults to m */
 
-     this.scale = "m";
 
-     /** is the button a child of a calcite-split-button */
 
-     this.splitChild = false;
 
-     /** The type attribute to apply to the button */
 
-     this.type = "button";
 
-     /** specify the width of the button, defaults to auto */
 
-     this.width = "auto";
 
-     /** watches for changing text content **/
 
-     this.mutationObserver = createObserver("mutation", () => this.updateHasContent());
 
-     /** determine if there is slotted content for styling purposes */
 
-     this.hasContent = false;
 
-     /** determine if loader present for styling purposes */
 
-     this.hasLoader = false;
 
-     // act on a requested or nearby form based on type
 
-     this.handleClick = () => {
 
-       const { type } = this;
 
-       if (this.href) {
 
-         return;
 
-       }
 
-       // this.type refers to type attribute, not child element type
 
-       if (type === "submit") {
 
-         submitForm(this);
 
-       }
 
-       else if (type === "reset") {
 
-         resetForm(this);
 
-       }
 
-     };
 
-   }
 
-   loadingChanged(newValue, oldValue) {
 
-     if (!!newValue && !oldValue) {
 
-       this.hasLoader = true;
 
-     }
 
-     if (!newValue && !!oldValue) {
 
-       window.setTimeout(() => {
 
-         this.hasLoader = false;
 
-       }, 300);
 
-     }
 
-   }
 
-   //--------------------------------------------------------------------------
 
-   //
 
-   //  Lifecycle
 
-   //
 
-   //--------------------------------------------------------------------------
 
-   connectedCallback() {
 
-     this.hasLoader = this.loading;
 
-     this.setupTextContentObserver();
 
-     connectLabel(this);
 
-     this.formEl = closestElementCrossShadowBoundary(this.el, this.form ? `#${this.form}` : "form");
 
-   }
 
-   disconnectedCallback() {
 
-     var _a;
 
-     (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
 
-     disconnectLabel(this);
 
-     this.formEl = null;
 
-   }
 
-   componentWillLoad() {
 
-     if (Build.isBrowser) {
 
-       this.updateHasContent();
 
-     }
 
-   }
 
-   componentDidRender() {
 
-     updateHostInteraction(this);
 
-   }
 
-   render() {
 
-     const childElType = this.href ? "a" : "button";
 
-     const Tag = childElType;
 
-     const loaderNode = this.hasLoader ? (h("div", { class: CSS.buttonLoader },
 
-       h("calcite-loader", { active: true, class: this.loading ? CSS.loadingIn : CSS.loadingOut, inline: true, label: this.intlLoading, scale: "m" }))) : null;
 
-     const iconStartEl = (h("calcite-icon", { class: { [CSS.icon]: true, [CSS.iconStart]: true }, flipRtl: this.iconFlipRtl === "start" || this.iconFlipRtl === "both", icon: this.iconStart, scale: "s" }));
 
-     const iconEndEl = (h("calcite-icon", { class: { [CSS.icon]: true, [CSS.iconEnd]: true }, flipRtl: this.iconFlipRtl === "end" || this.iconFlipRtl === "both", icon: this.iconEnd, scale: "s" }));
 
-     const contentEl = (h("span", { class: CSS.content },
 
-       h("slot", null)));
 
-     return (h(Tag, { "aria-label": getLabelText(this), class: {
 
-         [CSS.contentSlotted]: this.hasContent,
 
-         [CSS.iconStartEmpty]: !this.iconStart,
 
-         [CSS.iconEndEmpty]: !this.iconEnd
 
-       }, disabled: this.disabled || this.loading, href: childElType === "a" && this.href, name: childElType === "button" && this.name, onClick: this.handleClick, ref: (el) => (this.childEl = el), rel: childElType === "a" && this.rel, tabIndex: this.disabled || this.loading ? -1 : null, target: childElType === "a" && this.target, type: childElType === "button" && this.type },
 
-       loaderNode,
 
-       this.iconStart ? iconStartEl : null,
 
-       this.hasContent ? contentEl : null,
 
-       this.iconEnd ? iconEndEl : null));
 
-   }
 
-   //--------------------------------------------------------------------------
 
-   //
 
-   //  Public Methods
 
-   //
 
-   //--------------------------------------------------------------------------
 
-   /** Sets focus on the component. */
 
-   async setFocus() {
 
-     this.childEl.focus();
 
-   }
 
-   updateHasContent() {
 
-     var _a, _b;
 
-     const slottedContent = this.el.textContent.trim().length > 0 || this.el.childNodes.length > 0;
 
-     this.hasContent =
 
-       this.el.childNodes.length === 1 && ((_a = this.el.childNodes[0]) === null || _a === void 0 ? void 0 : _a.nodeName) === "#text"
 
-         ? ((_b = this.el.textContent) === null || _b === void 0 ? void 0 : _b.trim().length) > 0
 
-         : slottedContent;
 
-   }
 
-   setupTextContentObserver() {
 
-     var _a;
 
-     (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true, subtree: true });
 
-   }
 
-   //--------------------------------------------------------------------------
 
-   //
 
-   //  Private Methods
 
-   //
 
-   //--------------------------------------------------------------------------
 
-   onLabelClick() {
 
-     this.handleClick();
 
-     this.setFocus();
 
-   }
 
-   static get is() { return "calcite-button"; }
 
-   static get encapsulation() { return "shadow"; }
 
-   static get originalStyleUrls() { return {
 
-     "$": ["button.scss"]
 
-   }; }
 
-   static get styleUrls() { return {
 
-     "$": ["button.css"]
 
-   }; }
 
-   static get properties() { return {
 
-     "alignment": {
 
-       "type": "string",
 
-       "mutable": false,
 
-       "complexType": {
 
-         "original": "ButtonAlignment",
 
-         "resolved": "\"center\" | \"end\" | \"icon-end-space-between\" | \"icon-start-space-between\" | \"space-between\" | \"start\"",
 
-         "references": {
 
-           "ButtonAlignment": {
 
-             "location": "import",
 
-             "path": "./interfaces"
 
-           }
 
-         }
 
-       },
 
-       "required": false,
 
-       "optional": true,
 
-       "docs": {
 
-         "tags": [],
 
-         "text": "optionally specify alignment of button elements."
 
-       },
 
-       "attribute": "alignment",
 
-       "reflect": true,
 
-       "defaultValue": "\"center\""
 
-     },
 
-     "appearance": {
 
-       "type": "string",
 
-       "mutable": false,
 
-       "complexType": {
 
-         "original": "ButtonAppearance",
 
-         "resolved": "\"clear\" | \"outline\" | \"solid\" | \"transparent\"",
 
-         "references": {
 
-           "ButtonAppearance": {
 
-             "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\""
 
-     },
 
-     "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
 
-     },
 
-     "color": {
 
-       "type": "string",
 
-       "mutable": false,
 
-       "complexType": {
 
-         "original": "ButtonColor",
 
-         "resolved": "\"blue\" | \"inverse\" | \"neutral\" | \"red\"",
 
-         "references": {
 
-           "ButtonColor": {
 
-             "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": "\"blue\""
 
-     },
 
-     "disabled": {
 
-       "type": "boolean",
 
-       "mutable": false,
 
-       "complexType": {
 
-         "original": "boolean",
 
-         "resolved": "boolean",
 
-         "references": {}
 
-       },
 
-       "required": false,
 
-       "optional": false,
 
-       "docs": {
 
-         "tags": [],
 
-         "text": "is the button disabled"
 
-       },
 
-       "attribute": "disabled",
 
-       "reflect": true,
 
-       "defaultValue": "false"
 
-     },
 
-     "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 a button or an anchor"
 
-       },
 
-       "attribute": "href",
 
-       "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 a button - accepts calcite ui icon names"
 
-       },
 
-       "attribute": "icon-end",
 
-       "reflect": true
 
-     },
 
-     "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 a button - accepts calcite ui icon names"
 
-       },
 
-       "attribute": "icon-start",
 
-       "reflect": true
 
-     },
 
-     "intlLoading": {
 
-       "type": "string",
 
-       "mutable": false,
 
-       "complexType": {
 
-         "original": "string",
 
-         "resolved": "string",
 
-         "references": {}
 
-       },
 
-       "required": false,
 
-       "optional": true,
 
-       "docs": {
 
-         "tags": [{
 
-             "name": "default",
 
-             "text": "\"Loading\""
 
-           }],
 
-         "text": "string to override English loading text"
 
-       },
 
-       "attribute": "intl-loading",
 
-       "reflect": false,
 
-       "defaultValue": "TEXT.loading"
 
-     },
 
-     "loading": {
 
-       "type": "boolean",
 
-       "mutable": false,
 
-       "complexType": {
 
-         "original": "boolean",
 
-         "resolved": "boolean",
 
-         "references": {}
 
-       },
 
-       "required": false,
 
-       "optional": false,
 
-       "docs": {
 
-         "tags": [],
 
-         "text": "optionally add a calcite-loader component to the button, disabling interaction."
 
-       },
 
-       "attribute": "loading",
 
-       "reflect": true,
 
-       "defaultValue": "false"
 
-     },
 
-     "name": {
 
-       "type": "string",
 
-       "mutable": false,
 
-       "complexType": {
 
-         "original": "string",
 
-         "resolved": "string",
 
-         "references": {}
 
-       },
 
-       "required": false,
 
-       "optional": true,
 
-       "docs": {
 
-         "tags": [],
 
-         "text": "The name attribute to apply to the button"
 
-       },
 
-       "attribute": "name",
 
-       "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
 
-     },
 
-     "form": {
 
-       "type": "string",
 
-       "mutable": false,
 
-       "complexType": {
 
-         "original": "string",
 
-         "resolved": "string",
 
-         "references": {}
 
-       },
 
-       "required": false,
 
-       "optional": true,
 
-       "docs": {
 
-         "tags": [{
 
-             "name": "deprecated",
 
-             "text": "\u2013 this property is no longer needed if placed inside a form."
 
-           }],
 
-         "text": "The form ID to associate with the component"
 
-       },
 
-       "attribute": "form",
 
-       "reflect": false
 
-     },
 
-     "round": {
 
-       "type": "boolean",
 
-       "mutable": false,
 
-       "complexType": {
 
-         "original": "boolean",
 
-         "resolved": "boolean",
 
-         "references": {}
 
-       },
 
-       "required": false,
 
-       "optional": false,
 
-       "docs": {
 
-         "tags": [],
 
-         "text": "optionally add a round style to the button"
 
-       },
 
-       "attribute": "round",
 
-       "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 button, defaults to m"
 
-       },
 
-       "attribute": "scale",
 
-       "reflect": true,
 
-       "defaultValue": "\"m\""
 
-     },
 
-     "splitChild": {
 
-       "type": "any",
 
-       "mutable": false,
 
-       "complexType": {
 
-         "original": "\"primary\" | \"secondary\" | false",
 
-         "resolved": "\"primary\" | \"secondary\" | boolean",
 
-         "references": {}
 
-       },
 
-       "required": false,
 
-       "optional": true,
 
-       "docs": {
 
-         "tags": [],
 
-         "text": "is the button a child of a calcite-split-button"
 
-       },
 
-       "attribute": "split-child",
 
-       "reflect": true,
 
-       "defaultValue": "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
 
-     },
 
-     "type": {
 
-       "type": "string",
 
-       "mutable": true,
 
-       "complexType": {
 
-         "original": "string",
 
-         "resolved": "string",
 
-         "references": {}
 
-       },
 
-       "required": false,
 
-       "optional": false,
 
-       "docs": {
 
-         "tags": [],
 
-         "text": "The type attribute to apply to the button"
 
-       },
 
-       "attribute": "type",
 
-       "reflect": false,
 
-       "defaultValue": "\"button\""
 
-     },
 
-     "width": {
 
-       "type": "string",
 
-       "mutable": false,
 
-       "complexType": {
 
-         "original": "Width",
 
-         "resolved": "\"auto\" | \"full\" | \"half\"",
 
-         "references": {
 
-           "Width": {
 
-             "location": "import",
 
-             "path": "../interfaces"
 
-           }
 
-         }
 
-       },
 
-       "required": false,
 
-       "optional": false,
 
-       "docs": {
 
-         "tags": [],
 
-         "text": "specify the width of the button, defaults to auto"
 
-       },
 
-       "attribute": "width",
 
-       "reflect": true,
 
-       "defaultValue": "\"auto\""
 
-     }
 
-   }; }
 
-   static get states() { return {
 
-     "hasContent": {},
 
-     "hasLoader": {}
 
-   }; }
 
-   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 watchers() { return [{
 
-       "propName": "loading",
 
-       "methodName": "loadingChanged"
 
-     }]; }
 
- }
 
 
  |