123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259 |
- /*!
- * 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 { labelDisconnectedEvent, labelConnectedEvent } from "../../utils/label";
- import { CSS } from "./resources";
- /**
- * @slot - A slot for adding text and a component that can be labeled.
- */
- export class Label {
- constructor() {
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
- /** Specifies the text alignment of the component. */
- this.alignment = "start";
- /**
- * Specifies the status of the component and any child input, or input messages.
- *
- * @deprecated Set directly on the component the label is bound to instead.
- */
- this.status = "idle";
- /** Specifies the size of the component. */
- this.scale = "m";
- /** Defines the layout of the label in relation to the component. Use `"inline"` positions to wrap the label and component on the same line. */
- this.layout = "default";
- /**
- * When `true`, interaction is prevented and the component is displayed with lower opacity.
- *
- * @deprecated Use the `disabled` property on the component the label is bound to instead.
- */
- this.disabled = false;
- /**
- * When `true`, disables the component's spacing.
- *
- * @deprecated Set the `--calcite-label-margin-bottom` css variable to `0` instead.
- */
- this.disableSpacing = false;
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- this.labelClickHandler = (event) => {
- this.calciteInternalLabelClick.emit({
- sourceEvent: event
- });
- };
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- connectedCallback() {
- document.dispatchEvent(new CustomEvent(labelConnectedEvent));
- }
- disconnectedCallback() {
- document.dispatchEvent(new CustomEvent(labelDisconnectedEvent));
- }
- render() {
- return (h(Host, { onClick: this.labelClickHandler }, h("div", { class: CSS.container }, h("slot", null))));
- }
- static get is() { return "calcite-label"; }
- static get encapsulation() { return "shadow"; }
- static get originalStyleUrls() {
- return {
- "$": ["label.scss"]
- };
- }
- static get styleUrls() {
- return {
- "$": ["label.css"]
- };
- }
- static get properties() {
- return {
- "alignment": {
- "type": "string",
- "mutable": false,
- "complexType": {
- "original": "Alignment",
- "resolved": "\"center\" | \"end\" | \"start\"",
- "references": {
- "Alignment": {
- "location": "import",
- "path": "../interfaces"
- }
- }
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": "Specifies the text alignment of the component."
- },
- "attribute": "alignment",
- "reflect": true,
- "defaultValue": "\"start\""
- },
- "status": {
- "type": "string",
- "mutable": false,
- "complexType": {
- "original": "Status",
- "resolved": "\"idle\" | \"invalid\" | \"valid\"",
- "references": {
- "Status": {
- "location": "import",
- "path": "../interfaces"
- }
- }
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [{
- "name": "deprecated",
- "text": "Set directly on the component the label is bound to instead."
- }],
- "text": "Specifies the status of the component and any child input, or input messages."
- },
- "attribute": "status",
- "reflect": true,
- "defaultValue": "\"idle\""
- },
- "for": {
- "type": "string",
- "mutable": false,
- "complexType": {
- "original": "string",
- "resolved": "string",
- "references": {}
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": "Specifies the `id` of the component the label is bound to. Use when the component the label is bound to does not reside within the component."
- },
- "attribute": "for",
- "reflect": true
- },
- "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\""
- },
- "layout": {
- "type": "string",
- "mutable": false,
- "complexType": {
- "original": "\"inline\" | \"inline-space-between\" | \"default\"",
- "resolved": "\"default\" | \"inline\" | \"inline-space-between\"",
- "references": {}
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": "Defines the layout of the label in relation to the component. Use `\"inline\"` positions to wrap the label and component on the same line."
- },
- "attribute": "layout",
- "reflect": true,
- "defaultValue": "\"default\""
- },
- "disabled": {
- "type": "boolean",
- "mutable": false,
- "complexType": {
- "original": "boolean",
- "resolved": "boolean",
- "references": {}
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [{
- "name": "deprecated",
- "text": "Use the `disabled` property on the component the label is bound to instead."
- }],
- "text": "When `true`, interaction is prevented and the component is displayed with lower opacity."
- },
- "attribute": "disabled",
- "reflect": true,
- "defaultValue": "false"
- },
- "disableSpacing": {
- "type": "boolean",
- "mutable": false,
- "complexType": {
- "original": "boolean",
- "resolved": "boolean",
- "references": {}
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [{
- "name": "deprecated",
- "text": "Set the `--calcite-label-margin-bottom` css variable to `0` instead."
- }],
- "text": "When `true`, disables the component's spacing."
- },
- "attribute": "disable-spacing",
- "reflect": true,
- "defaultValue": "false"
- }
- };
- }
- static get events() {
- return [{
- "method": "calciteInternalLabelClick",
- "name": "calciteInternalLabelClick",
- "bubbles": false,
- "cancelable": false,
- "composed": true,
- "docs": {
- "tags": [{
- "name": "internal",
- "text": undefined
- }],
- "text": ""
- },
- "complexType": {
- "original": "{\n sourceEvent: MouseEvent;\n }",
- "resolved": "{ sourceEvent: MouseEvent; }",
- "references": {
- "MouseEvent": {
- "location": "global"
- }
- }
- }
- }];
- }
- static get elementRef() { return "el"; }
- }
|