/** * Copyright (c) Microblink Ltd. All rights reserved. */ import { Component, Element, Event, EventEmitter, Host, h, Prop } from '@stencil/core'; import { TranslationService } from '../../../utils/translation.service'; import { setWebComponentParts, classNames } from '../../../utils/generic.helpers'; @Component({ tag: 'mb-api-process-status', styleUrl: 'mb-api-process-status.scss', shadow: true, }) export class MbApiProcessStatus { /** * Element visibility, default is 'false'. */ @Prop() visible: boolean = false; /** * State value of API processing received from parent element ('loading' or 'success'). */ @Prop() state: 'ERROR' | 'LOADING' | 'NONE' | 'SUCCESS'; /** * Instance of TranslationService passed from parent component. */ @Prop() translationService: TranslationService; /** * Emitted when user clicks on 'Retry' button. */ @Event() closeTryAgain: EventEmitter; /** * Emitted when user clicks on 'x' button. */ @Event() closeFromStart: EventEmitter; /** * Host element as variable for manipulation */ @Element() hostEl: HTMLElement; componentDidLoad() { setWebComponentParts(this.hostEl); } render() { return ( { this.state === 'LOADING' &&

{ this.translationService.i('process-api-message').toString() }

} { this.state === 'SUCCESS' &&
} { this.state === 'ERROR' && this.closeFromStart.emit() } >
}
); } }