| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411 | 
							- /*!
 
-  * 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.97
 
-  */
 
- import { h, Host } from "@stencil/core";
 
- import { guid } from "../../utils/guid";
 
- import { HiddenFormInputSlot } from "../../utils/form";
 
- import { connectLabel, disconnectLabel, getLabelText } from "../../utils/label";
 
- import { connectForm, disconnectForm } from "../../utils/form";
 
- import { updateHostInteraction } from "../../utils/interactive";
 
- import { toAriaBoolean } from "../../utils/dom";
 
- import { isActivationKey } from "../../utils/key";
 
- export class Checkbox {
 
-   constructor() {
 
-     //--------------------------------------------------------------------------
 
-     //
 
-     //  Properties
 
-     //
 
-     //--------------------------------------------------------------------------
 
-     /** When `true`, the component is checked. */
 
-     this.checked = false;
 
-     /** When `true`, interaction is prevented and the component is displayed with lower opacity. */
 
-     this.disabled = false;
 
-     /**
 
-      * The hovered state of the checkbox.
 
-      *
 
-      * @internal
 
-      */
 
-     this.hovered = false;
 
-     /**
 
-      * When `true`, the component is initially indeterminate, which is independent from its `checked` value.
 
-      *
 
-      * The state is visual only, and can look different across browsers.
 
-      *
 
-      * @mdn [indeterminate](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#indeterminate_state_checkboxes)
 
-      */
 
-     this.indeterminate = false;
 
-     /**
 
-      * When `true`, the component must have a value in order for the form to submit.
 
-      *
 
-      * @internal
 
-      */
 
-     this.required = false;
 
-     /** Specifies the size of the component. */
 
-     this.scale = "m";
 
-     //--------------------------------------------------------------------------
 
-     //
 
-     //  Private Properties
 
-     //
 
-     //--------------------------------------------------------------------------
 
-     this.checkedPath = "M5.5 12L2 8.689l.637-.636L5.5 10.727l8.022-7.87.637.637z";
 
-     this.indeterminatePath = "M13 8v1H3V8z";
 
-     //--------------------------------------------------------------------------
 
-     //
 
-     //  Private Methods
 
-     //
 
-     //--------------------------------------------------------------------------
 
-     this.getPath = () => this.indeterminate ? this.indeterminatePath : this.checked ? this.checkedPath : "";
 
-     this.toggle = () => {
 
-       if (!this.disabled) {
 
-         this.checked = !this.checked;
 
-         this.setFocus();
 
-         this.indeterminate = false;
 
-         this.calciteCheckboxChange.emit();
 
-       }
 
-     };
 
-     this.keyDownHandler = (event) => {
 
-       if (isActivationKey(event.key)) {
 
-         this.toggle();
 
-         event.preventDefault();
 
-       }
 
-     };
 
-     this.clickHandler = () => {
 
-       this.toggle();
 
-     };
 
-     //--------------------------------------------------------------------------
 
-     //
 
-     //  Event Listeners
 
-     //
 
-     //--------------------------------------------------------------------------
 
-     this.onToggleBlur = () => {
 
-       this.calciteInternalCheckboxBlur.emit(false);
 
-     };
 
-     this.onToggleFocus = () => {
 
-       this.calciteInternalCheckboxFocus.emit(true);
 
-     };
 
-     this.onLabelClick = () => {
 
-       this.toggle();
 
-     };
 
-   }
 
-   //--------------------------------------------------------------------------
 
-   //
 
-   //  Public Methods
 
-   //
 
-   //--------------------------------------------------------------------------
 
-   /** Sets focus on the component. */
 
-   async setFocus() {
 
-     var _a;
 
-     (_a = this.toggleEl) === null || _a === void 0 ? void 0 : _a.focus();
 
-   }
 
-   //--------------------------------------------------------------------------
 
-   //
 
-   //  Lifecycle
 
-   //
 
-   //--------------------------------------------------------------------------
 
-   connectedCallback() {
 
-     this.guid = this.el.id || `calcite-checkbox-${guid()}`;
 
-     connectLabel(this);
 
-     connectForm(this);
 
-   }
 
-   disconnectedCallback() {
 
-     disconnectLabel(this);
 
-     disconnectForm(this);
 
-   }
 
-   componentDidRender() {
 
-     updateHostInteraction(this);
 
-   }
 
-   // --------------------------------------------------------------------------
 
-   //
 
-   //  Render Methods
 
-   //
 
-   // --------------------------------------------------------------------------
 
-   render() {
 
-     return (h(Host, { onClick: this.clickHandler, onKeyDown: this.keyDownHandler }, h("div", { "aria-checked": toAriaBoolean(this.checked), "aria-label": getLabelText(this), class: "toggle", onBlur: this.onToggleBlur, onFocus: this.onToggleFocus, ref: (toggleEl) => (this.toggleEl = toggleEl), role: "checkbox", tabIndex: this.disabled ? undefined : 0 }, h("svg", { "aria-hidden": "true", class: "check-svg", viewBox: "0 0 16 16" }, h("path", { d: this.getPath() })), h("slot", null)), h(HiddenFormInputSlot, { component: this })));
 
-   }
 
-   static get is() { return "calcite-checkbox"; }
 
-   static get encapsulation() { return "shadow"; }
 
-   static get originalStyleUrls() {
 
-     return {
 
-       "$": ["checkbox.scss"]
 
-     };
 
-   }
 
-   static get styleUrls() {
 
-     return {
 
-       "$": ["checkbox.css"]
 
-     };
 
-   }
 
-   static get properties() {
 
-     return {
 
-       "checked": {
 
-         "type": "boolean",
 
-         "mutable": true,
 
-         "complexType": {
 
-           "original": "boolean",
 
-           "resolved": "boolean",
 
-           "references": {}
 
-         },
 
-         "required": false,
 
-         "optional": false,
 
-         "docs": {
 
-           "tags": [],
 
-           "text": "When `true`, the component is checked."
 
-         },
 
-         "attribute": "checked",
 
-         "reflect": true,
 
-         "defaultValue": "false"
 
-       },
 
-       "disabled": {
 
-         "type": "boolean",
 
-         "mutable": false,
 
-         "complexType": {
 
-           "original": "boolean",
 
-           "resolved": "boolean",
 
-           "references": {}
 
-         },
 
-         "required": false,
 
-         "optional": false,
 
-         "docs": {
 
-           "tags": [],
 
-           "text": "When `true`, interaction is prevented and the component is displayed with lower opacity."
 
-         },
 
-         "attribute": "disabled",
 
-         "reflect": true,
 
-         "defaultValue": "false"
 
-       },
 
-       "guid": {
 
-         "type": "string",
 
-         "mutable": true,
 
-         "complexType": {
 
-           "original": "string",
 
-           "resolved": "string",
 
-           "references": {}
 
-         },
 
-         "required": false,
 
-         "optional": false,
 
-         "docs": {
 
-           "tags": [],
 
-           "text": "The `id` attribute of the component. When omitted, a globally unique identifier is used."
 
-         },
 
-         "attribute": "guid",
 
-         "reflect": true
 
-       },
 
-       "hovered": {
 
-         "type": "boolean",
 
-         "mutable": true,
 
-         "complexType": {
 
-           "original": "boolean",
 
-           "resolved": "boolean",
 
-           "references": {}
 
-         },
 
-         "required": false,
 
-         "optional": false,
 
-         "docs": {
 
-           "tags": [{
 
-               "name": "internal",
 
-               "text": undefined
 
-             }],
 
-           "text": "The hovered state of the checkbox."
 
-         },
 
-         "attribute": "hovered",
 
-         "reflect": true,
 
-         "defaultValue": "false"
 
-       },
 
-       "indeterminate": {
 
-         "type": "boolean",
 
-         "mutable": true,
 
-         "complexType": {
 
-           "original": "boolean",
 
-           "resolved": "boolean",
 
-           "references": {}
 
-         },
 
-         "required": false,
 
-         "optional": false,
 
-         "docs": {
 
-           "tags": [{
 
-               "name": "mdn",
 
-               "text": "[indeterminate](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#indeterminate_state_checkboxes)"
 
-             }],
 
-           "text": "When `true`, the component is initially indeterminate, which is independent from its `checked` value.\n\nThe state is visual only, and can look different across browsers."
 
-         },
 
-         "attribute": "indeterminate",
 
-         "reflect": true,
 
-         "defaultValue": "false"
 
-       },
 
-       "label": {
 
-         "type": "string",
 
-         "mutable": false,
 
-         "complexType": {
 
-           "original": "string",
 
-           "resolved": "string",
 
-           "references": {}
 
-         },
 
-         "required": false,
 
-         "optional": true,
 
-         "docs": {
 
-           "tags": [{
 
-               "name": "internal",
 
-               "text": undefined
 
-             }],
 
-           "text": "Accessible name for the component."
 
-         },
 
-         "attribute": "label",
 
-         "reflect": false
 
-       },
 
-       "name": {
 
-         "type": "any",
 
-         "mutable": false,
 
-         "complexType": {
 
-           "original": "any",
 
-           "resolved": "any",
 
-           "references": {}
 
-         },
 
-         "required": false,
 
-         "optional": false,
 
-         "docs": {
 
-           "tags": [],
 
-           "text": "Specifies the name of the component on form submission."
 
-         },
 
-         "attribute": "name",
 
-         "reflect": true
 
-       },
 
-       "required": {
 
-         "type": "boolean",
 
-         "mutable": false,
 
-         "complexType": {
 
-           "original": "boolean",
 
-           "resolved": "boolean",
 
-           "references": {}
 
-         },
 
-         "required": false,
 
-         "optional": false,
 
-         "docs": {
 
-           "tags": [{
 
-               "name": "internal",
 
-               "text": undefined
 
-             }],
 
-           "text": "When `true`, the component must have a value in order for the form to submit."
 
-         },
 
-         "attribute": "required",
 
-         "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": "Specifies the size of the component."
 
-         },
 
-         "attribute": "scale",
 
-         "reflect": true,
 
-         "defaultValue": "\"m\""
 
-       },
 
-       "value": {
 
-         "type": "any",
 
-         "mutable": false,
 
-         "complexType": {
 
-           "original": "any",
 
-           "resolved": "any",
 
-           "references": {}
 
-         },
 
-         "required": false,
 
-         "optional": false,
 
-         "docs": {
 
-           "tags": [],
 
-           "text": "The component's value."
 
-         },
 
-         "attribute": "value",
 
-         "reflect": false
 
-       }
 
-     };
 
-   }
 
-   static get events() {
 
-     return [{
 
-         "method": "calciteInternalCheckboxBlur",
 
-         "name": "calciteInternalCheckboxBlur",
 
-         "bubbles": true,
 
-         "cancelable": false,
 
-         "composed": true,
 
-         "docs": {
 
-           "tags": [{
 
-               "name": "internal",
 
-               "text": undefined
 
-             }],
 
-           "text": "Emits when the component is blurred."
 
-         },
 
-         "complexType": {
 
-           "original": "boolean",
 
-           "resolved": "boolean",
 
-           "references": {}
 
-         }
 
-       }, {
 
-         "method": "calciteCheckboxChange",
 
-         "name": "calciteCheckboxChange",
 
-         "bubbles": true,
 
-         "cancelable": false,
 
-         "composed": true,
 
-         "docs": {
 
-           "tags": [],
 
-           "text": "Emits when the component's `checked` status changes."
 
-         },
 
-         "complexType": {
 
-           "original": "void",
 
-           "resolved": "void",
 
-           "references": {}
 
-         }
 
-       }, {
 
-         "method": "calciteInternalCheckboxFocus",
 
-         "name": "calciteInternalCheckboxFocus",
 
-         "bubbles": true,
 
-         "cancelable": false,
 
-         "composed": true,
 
-         "docs": {
 
-           "tags": [{
 
-               "name": "internal",
 
-               "text": undefined
 
-             }],
 
-           "text": "Emits when the component is focused."
 
-         },
 
-         "complexType": {
 
-           "original": "boolean",
 
-           "resolved": "boolean",
 
-           "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"; }
 
- }
 
 
  |