UNPKG

@microblink/blinkid-in-browser-sdk

Version:

A simple ID scanning library for WebAssembly-enabled browsers.

87 lines (86 loc) 2.19 kB
/** * Copyright (c) Microblink Ltd. All rights reserved. */ import { Component, Host, h, Method, Prop } from '@stencil/core'; export class MbFeedback { constructor() { /** * Set to 'true' if component should be visible. */ this.visible = false; } /** * Call when FeedbackMessage which should be displayed. */ async show(feedback) { this.paragraphEl.innerText = feedback.message; this.paragraphEl.className = this.getFeedbackClassName(feedback.state); } render() { return (h(Host, { className: this.visible ? 'visible' : '' }, h("p", { ref: el => this.paragraphEl = el }))); } getFeedbackClassName(state) { switch (state) { case 'FEEDBACK_ERROR': return 'error'; case 'FEEDBACK_INFO': return 'info'; default: return ''; } } static get is() { return "mb-feedback"; } static get encapsulation() { return "shadow"; } static get originalStyleUrls() { return { "$": ["mb-feedback.scss"] }; } static get styleUrls() { return { "$": ["mb-feedback.css"] }; } static get properties() { return { "visible": { "type": "boolean", "mutable": false, "complexType": { "original": "boolean", "resolved": "boolean", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "Set to 'true' if component should be visible." }, "attribute": "visible", "reflect": false, "defaultValue": "false" } }; } static get methods() { return { "show": { "complexType": { "signature": "(feedback: FeedbackMessage) => Promise<void>", "parameters": [{ "tags": [], "text": "" }], "references": { "Promise": { "location": "global" }, "FeedbackMessage": { "location": "import", "path": "../../../utils/data-structures" } }, "return": "Promise<void>" }, "docs": { "text": "Call when FeedbackMessage which should be displayed.", "tags": [] } } }; } }