123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- /*!
- * 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, Host, h, Prop, Watch } from "@stencil/core";
- import { getElementProp, setRequestedIcon } from "../../utils/dom";
- import { StatusIconDefaults } from "./interfaces";
- /**
- * @slot - A slot for adding text.
- */
- export class InputMessage {
- constructor() {
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
- /** Indicates whether the message is displayed. */
- this.active = false;
- /** specify the scale of the input, defaults to m */
- this.scale = "m";
- /** specify the status of the input field, determines message and icons */
- this.status = "idle";
- }
- handleIconEl() {
- this.requestedIcon = setRequestedIcon(StatusIconDefaults, this.icon, this.status);
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- connectedCallback() {
- this.status = getElementProp(this.el, "status", this.status);
- this.scale = getElementProp(this.el, "scale", this.scale);
- this.requestedIcon = setRequestedIcon(StatusIconDefaults, this.icon, this.status);
- }
- render() {
- const hidden = !this.active;
- return (h(Host, { "calcite-hydrated-hidden": hidden },
- this.renderIcon(this.requestedIcon),
- h("slot", null)));
- }
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- renderIcon(iconName) {
- if (iconName) {
- return h("calcite-icon", { class: "calcite-input-message-icon", icon: iconName, scale: "s" });
- }
- }
- static get is() { return "calcite-input-message"; }
- static get encapsulation() { return "shadow"; }
- static get originalStyleUrls() { return {
- "$": ["input-message.scss"]
- }; }
- static get styleUrls() { return {
- "$": ["input-message.css"]
- }; }
- static get properties() { return {
- "active": {
- "type": "boolean",
- "mutable": false,
- "complexType": {
- "original": "boolean",
- "resolved": "boolean",
- "references": {}
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": "Indicates whether the message is displayed."
- },
- "attribute": "active",
- "reflect": true,
- "defaultValue": "false"
- },
- "icon": {
- "type": "any",
- "mutable": false,
- "complexType": {
- "original": "boolean | string",
- "resolved": "boolean | string",
- "references": {}
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": "when used as a boolean set to true, show a default icon based on status. You can\nalso pass a calcite-ui-icon name to this prop to display a custom icon"
- },
- "attribute": "icon",
- "reflect": true
- },
- "scale": {
- "type": "string",
- "mutable": true,
- "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 input, defaults to m"
- },
- "attribute": "scale",
- "reflect": true,
- "defaultValue": "\"m\""
- },
- "status": {
- "type": "string",
- "mutable": true,
- "complexType": {
- "original": "Status",
- "resolved": "\"idle\" | \"invalid\" | \"valid\"",
- "references": {
- "Status": {
- "location": "import",
- "path": "../interfaces"
- }
- }
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": "specify the status of the input field, determines message and icons"
- },
- "attribute": "status",
- "reflect": true,
- "defaultValue": "\"idle\""
- },
- "type": {
- "type": "string",
- "mutable": false,
- "complexType": {
- "original": "\"default\"",
- "resolved": "\"default\"",
- "references": {}
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [{
- "name": "deprecated",
- "text": "\"floating\" type is no longer supported"
- }],
- "text": "specify the appearance of any slotted message - default (displayed under input), or floating (positioned absolutely under input)"
- },
- "attribute": "type",
- "reflect": true
- }
- }; }
- static get elementRef() { return "el"; }
- static get watchers() { return [{
- "propName": "status",
- "methodName": "handleIconEl"
- }, {
- "propName": "icon",
- "methodName": "handleIconEl"
- }]; }
- }
|