ngx-bit
Version:
A flexible NG-ZORRO helper library
160 lines (150 loc) • 8.24 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('/core'), require('ngx-bit'), require('ng-zorro-antd/radio'), require('/forms'), require('@angular/common')) :
typeof define === 'function' && define.amd ? define('ngx-bit/component', ['exports', '@angular/core', 'ngx-bit', 'ng-zorro-antd/radio', '@angular/forms', '@angular/common'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global['ngx-bit'] = global['ngx-bit'] || {}, global['ngx-bit'].component = {}), global.ng.core, global['ngx-bit'], global.radio, global.ng.forms, global.ng.common));
}(this, (function (exports, core, ngxBit, radio, forms, common) { 'use strict';
var BitErrorTipComponent = /** */ (function () {
function BitErrorTipComponent() {
this.hasError = {};
this.values = [];
}
BitErrorTipComponent.prototype.ngOnChanges = function (changes) {
if (changes.hasOwnProperty('hasError')) {
this.values = [];
var errors = changes.hasError.currentValue;
for (var key in errors) {
if (errors.hasOwnProperty(key)) {
this.values.push({
key: key,
error: errors[key]
});
}
}
}
};
return BitErrorTipComponent;
}());
BitErrorTipComponent.decorators = [
{ type: core.Component, args: [{
selector: 'bit-error-tip',
template: "<ng-template #ref let-control>\r\n <ng-container *ngFor=\"let value of values\">\r\n <ng-container *ngIf=\"control.hasError(value.key)\">\r\n {{value.error}}\r\n </ng-container>\r\n </ng-container>\r\n</ng-template>\r\n"
},] }
];
BitErrorTipComponent.propDecorators = {
ref: [{ type: core.ViewChild, args: ['ref', { static: true },] }],
hasError: [{ type: core.Input }]
};
var BitI18nSwitchComponent = /** @class */ (function () {
function BitI18nSwitchComponent(bit) {
this.bit = bit;
}
BitI18nSwitchComponent.prototype.i18nChanged = function (value) {
this.bit.i18nChanged.next(value);
};
return BitI18nSwitchComponent;
}());
BitI18nSwitchComponent.decorators = [
{ type: core.Component, args: [{
selector: 'bit-i18n-switch',
template: "<ng-container *ngIf=\"bit.i18nContain.length > 1\">\n <nz-radio-group [(ngModel)]=\"bit.i18n\" (ngModelChange)=\"i18nChanged($event)\">\n <ng-container *ngFor=\"let item of bit.i18nSwitch\">\n <label nz-radio-button [nzValue]=\"item.i18n\">\n <span>\n <b>{{ item.name[bit.locale] }}</b>\n </span>\n </label>\n </ng-container>\n </nz-radio-group>\n</ng-container>\n"
},] }
];
BitI18nSwitchComponent.ctorParameters = function () { return [
{ type: ngxBit.BitService }
]; };
var BitI18nTooltipComponent = /** @class */ (function () {
function BitI18nTooltipComponent(bit) {
this.bit = bit;
}
return BitI18nTooltipComponent;
}());
BitI18nTooltipComponent.decorators = [
{ type: core.Component, args: [{
selector: 'bit-i18n-tooltip',
template: "<ng-template #ref>\r\n <ng-container *ngIf=\"bit.i18nTooltip.hasOwnProperty(groupName) && bit.i18nTooltip[groupName].length !== 0;else not\">\r\n <ng-container *ngFor=\"let ID of bit.i18nTooltip[groupName];first as isFirst\">\r\n <ng-container *ngIf=\"!isFirst\">,</ng-container>\r\n <ng-container *ngIf=\"bit.l.hasOwnProperty(groupName + '_' + ID);else universal\">\r\n {{bit.l[groupName + '_' + ID]}}\r\n </ng-container>\r\n <ng-template #universal>\r\n <ng-container [ngSwitch]=\"ID\">\r\n <ng-container *ngSwitchCase=\"'zh_cn'\">\r\n {{bit.l['I18nZHCN']}}\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'en_us'\">\r\n {{bit.l['I18nENUS']}}\r\n </ng-container>\r\n </ng-container>\r\n </ng-template>\r\n </ng-container>\r\n </ng-container>\r\n <ng-template #not>\r\n {{bit.l['I18nNoTip']}}\r\n </ng-template>\r\n</ng-template>\r\n"
},] }
];
BitI18nTooltipComponent.ctorParameters = function () { return [
{ type: ngxBit.BitService }
]; };
BitI18nTooltipComponent.propDecorators = {
ref: [{ type: core.ViewChild, args: ['ref', { static: true },] }],
groupName: [{ type: core.Input }]
};
var BitPrintComponent = /** @class */ (function () {
function BitPrintComponent() {
this.values = [];
this.varsMap = new Map();
}
BitPrintComponent.prototype.ngOnChanges = function (changes) {
var _this = this;
if (changes.hasOwnProperty('vars')) {
if (changes.vars.currentValue) {
this.varsMap = new Map();
changes.vars.currentValue.forEach(function (value, index) {
_this.varsMap.set('$' + index, value);
});
}
}
if (changes.hasOwnProperty('text')) {
if (changes.text.currentValue) {
var semi = changes.text.currentValue.replace(/\$[0-9]+/g, '**$&**');
this.values = semi.split('**').map(function (v) {
return _this.varsMap.has(v) ? _this.varsMap.get(v) : v;
});
}
}
};
BitPrintComponent.prototype.is = function (value) {
return value instanceof core.TemplateRef;
};
return BitPrintComponent;
}());
BitPrintComponent.decorators = [
{ type: core.Component, args: [{
selector: 'bit-print',
template: "<ng-template #ref>\r\n <ng-container *ngFor=\"let value of values\">\r\n <ng-container *ngIf=\"!is(value);else template\">\r\n {{value}}\r\n </ng-container>\r\n <ng-template #template>\r\n <ng-container *ngTemplateOutlet=\"value\"></ng-container>\r\n </ng-template>\r\n </ng-container>\r\n</ng-template>\r\n"
},] }
];
BitPrintComponent.propDecorators = {
ref: [{ type: core.ViewChild, args: ['ref', { static: true },] }],
text: [{ type: core.Input }],
vars: [{ type: core.Input }]
};
var BitComponentModule = /** @class */ (function () {
function BitComponentModule() {
}
return BitComponentModule;
}());
BitComponentModule.decorators = [
{ type: core.NgModule, args: [{
imports: [
forms.FormsModule,
common.CommonModule,
radio.NzRadioModule
],
declarations: [
BitErrorTipComponent,
BitI18nSwitchComponent,
BitI18nTooltipComponent,
BitPrintComponent
],
exports: [
BitErrorTipComponent,
BitI18nSwitchComponent,
BitI18nTooltipComponent,
BitPrintComponent
]
},] }
];
/**
* Generated bundle index. Do not edit.
*/
exports.BitComponentModule = BitComponentModule;
exports.BitErrorTipComponent = BitErrorTipComponent;
exports.BitI18nSwitchComponent = BitI18nSwitchComponent;
exports.BitI18nTooltipComponent = BitI18nTooltipComponent;
exports.BitPrintComponent = BitPrintComponent;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=ngx-bit-component.umd.js.map