UNPKG

@lxlib/theme

Version:

This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.1.

64 lines 6.67 kB
/** * @fileoverview added by tsickle * Generated from: src/pipes/yn/yn.pipe.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ import { Pipe } from '@angular/core'; import { DomSanitizer } from '@angular/platform-browser'; /** @type {?} */ const ICON_YES = `<svg viewBox="64 64 896 896" fill="currentColor" width="1em" height="1em" aria-hidden="true"><path d="M912 190h-69.9c-9.8 0-19.1 4.5-25.1 12.2L404.7 724.5 207 474a32 32 0 0 0-25.1-12.2H112c-6.7 0-10.4 7.7-6.3 12.9l273.9 347c12.8 16.2 37.4 16.2 50.3 0l488.4-618.9c4.1-5.1.4-12.8-6.3-12.8z"></path></svg>`; /** @type {?} */ const ICON_NO = `<svg viewBox="64 64 896 896" fill="currentColor" width="1em" height="1em" aria-hidden="true"><path d="M563.8 512l262.5-312.9c4.4-5.2.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9A7.95 7.95 0 0 0 203 838h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z"></path></svg>`; /** @type {?} */ const CLS_YES = `class="yn__yes"`; /** @type {?} */ const CLS_NO = `class="yn__no"`; export class YNPipe { /** * @param {?} dom */ constructor(dom) { this.dom = dom; } /** * @param {?} value * @param {?} yes * @param {?} no * @param {?} mode * @param {?=} isSafeHtml * @return {?} */ transform(value, yes, no, mode, isSafeHtml = true) { /** @type {?} */ let html = ''; yes = yes || '是'; no = no || '否'; switch (mode) { case 'full': html = value ? `<i ${CLS_YES}>${ICON_YES}<span>${yes}</span></i>` : `<i ${CLS_NO}>${ICON_NO}<span>${no}</span></i>`; break; case 'text': html = value ? `<i ${CLS_YES}>${yes}</i>` : `<i ${CLS_NO}>${no}</i>`; break; default: html = value ? `<i ${CLS_YES} title="${yes}">${ICON_YES}</i>` : `<i ${CLS_NO} title="${no}">${ICON_NO}</i>`; break; } return isSafeHtml ? this.dom.bypassSecurityTrustHtml(html) : html; } } YNPipe.decorators = [ { type: Pipe, args: [{ name: 'yn' },] } ]; /** @nocollapse */ YNPipe.ctorParameters = () => [ { type: DomSanitizer } ]; if (false) { /** * @type {?} * @private */ YNPipe.prototype.dom; } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoieW4ucGlwZS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0BseGxpYi90aGVtZS8iLCJzb3VyY2VzIjpbInNyYy9waXBlcy95bi95bi5waXBlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7O0FBQUEsT0FBTyxFQUFFLElBQUksRUFBaUIsTUFBTSxlQUFlLENBQUM7QUFDcEQsT0FBTyxFQUFFLFlBQVksRUFBWSxNQUFNLDJCQUEyQixDQUFDOztNQUk3RCxRQUFRLEdBQUcsZ1RBQWdUOztNQUMzVCxPQUFPLEdBQUcsaWJBQWliOztNQUMzYixPQUFPLEdBQUcsaUJBQWlCOztNQUMzQixNQUFNLEdBQUcsZ0JBQWdCO0FBRy9CLE1BQU0sT0FBTyxNQUFNOzs7O0lBQ2pCLFlBQW9CLEdBQWlCO1FBQWpCLFFBQUcsR0FBSCxHQUFHLENBQWM7SUFBRyxDQUFDOzs7Ozs7Ozs7SUFFekMsU0FBUyxDQUFDLEtBQWMsRUFBRSxHQUFXLEVBQUUsRUFBVSxFQUFFLElBQVksRUFBRSxVQUFVLEdBQUcsSUFBSTs7WUFDNUUsSUFBSSxHQUFHLEVBQUU7UUFDYixHQUFHLEdBQUcsR0FBRyxJQUFJLEdBQUcsQ0FBQztRQUNqQixFQUFFLEdBQUcsR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