UNPKG

@ohayojp.com/components

Version:

Common business components of ohayojp.

202 lines (196 loc) 6.29 kB
import { Component, ChangeDetectionStrategy, ViewEncapsulation, ViewChild, Input, NgModule } from '@angular/core'; import { DomSanitizer } from '@angular/platform-browser'; import { OhayoLocaleService, OhayoLocaleModule } from '@ohayojp.com/theme'; import { isEmpty, OhayoUtilModule } from '@ohayojp.com/util'; import { CommonModule } from '@angular/common'; import { RouterModule } from '@angular/router'; import { NzButtonModule } from 'ng-zorro-antd/button'; /** * @fileoverview added by tsickle * Generated from: exception.component.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class ExceptionComponent { /** * @param {?} i18n * @param {?} dom */ constructor(i18n, dom) { this.i18n = i18n; this.dom = dom; this.locale = {}; this.hasCon = false; this._img = ''; this._title = ''; this._desc = ''; } /** * @param {?} value * @return {?} */ set type(value) { /** @type {?} */ const item = { 403: { img: 'https://gw.alipayobjects.com/zos/rmsportal/wZcnGqRDyhPOEYFcZDnb.svg', title: '403', }, 404: { img: 'https://gw.alipayobjects.com/zos/rmsportal/KpnpchXsobRgLElEozzI.svg', title: '404', }, 500: { img: 'https://gw.alipayobjects.com/zos/rmsportal/RVRUAYdCGeYNBWoKiIwB.svg', title: '500', }, }[value]; if (!item) return; this.fixImg(item.img); this._type = value; this._title = item.title; this._desc = ''; } /** * @private * @param {?} src * @return {?} */ fixImg(src) { this._img = this.dom.bypassSecurityTrustStyle(`url('${src}')`); } /** * @param {?} value * @return {?} */ set img(value) { this.fixImg(value); } /** * @param {?} value * @return {?} */ set title(value) { this._title = this.dom.bypassSecurityTrustHtml(value); } /** * @param {?} value * @return {?} */ set desc(value) { this._desc = this.dom.bypassSecurityTrustHtml(value); } /** * @return {?} */ checkContent() { this.hasCon = !isEmpty(this.conTpl.nativeElement); } /** * @return {?} */ ngOnInit() { this.i18n$ = this.i18n.change.subscribe((/** * @return {?} */ () => (this.locale = this.i18n.getData('exception')))); this.checkContent(); } /** * @return {?} */ ngOnDestroy() { this.i18n$.unsubscribe(); } } ExceptionComponent.decorators = [ { type: Component, args: [{ selector: 'exception', exportAs: 'exception', template: "<div class=\"exception__img-block\">\n <div class=\"exception__img\" [style.backgroundImage]=\"_img\"></div>\n</div>\n<div class=\"exception__cont\">\n <h1 class=\"exception__cont-title\" [innerHTML]=\"_title\"></h1>\n <div class=\"exception__cont-desc\" [innerHTML]=\"_desc || locale[_type]\"></div>\n <div class=\"exception__cont-actions\">\n <div (cdkObserveContent)=\"checkContent()\" #conTpl>\n <ng-content></ng-content>\n </div>\n <button *ngIf=\"!hasCon\" nz-button [routerLink]=\"['/']\" [nzType]=\"'primary'\">{{ locale.backToHome }}</button>\n </div>\n</div>\n", host: { '[class.exception]': 'true' }, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None }] } ]; /** @nocollapse */ ExceptionComponent.ctorParameters = () => [ { type: OhayoLocaleService }, { type: DomSanitizer } ]; ExceptionComponent.propDecorators = { conTpl: [{ type: ViewChild, args: ['conTpl', { static: true },] }], type: [{ type: Input }], img: [{ type: Input }], title: [{ type: Input }], desc: [{ type: Input }] }; if (false) { /** @type {?} */ ExceptionComponent.ngAcceptInputType_type; /** * @type {?} * @private */ ExceptionComponent.prototype.i18n$; /** * @type {?} * @private */ ExceptionComponent.prototype.conTpl; /** @type {?} */ ExceptionComponent.prototype._type; /** @type {?} */ ExceptionComponent.prototype.locale; /** @type {?} */ ExceptionComponent.prototype.hasCon; /** @type {?} */ ExceptionComponent.prototype._img; /** @type {?} */ ExceptionComponent.prototype._title; /** @type {?} */ ExceptionComponent.prototype._desc; /** * @type {?} * @private */ ExceptionComponent.prototype.i18n; /** * @type {?} * @private */ ExceptionComponent.prototype.dom; } /** * @fileoverview added by tsickle * Generated from: exception.module.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ const COMPONENTS = [ExceptionComponent]; class ExceptionModule { } ExceptionModule.decorators = [ { type: NgModule, args: [{ imports: [CommonModule, RouterModule, OhayoUtilModule, OhayoLocaleModule, NzButtonModule], declarations: [...COMPONENTS], exports: [...COMPONENTS], },] } ]; /** * @fileoverview added by tsickle * Generated from: public_api.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @fileoverview added by tsickle * Generated from: exception.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ export { ExceptionComponent, ExceptionModule }; //# sourceMappingURL=exception.js.map