@taiga-ui/kit
Version:
Taiga UI Angular main components kit
140 lines (134 loc) • 7.14 kB
JavaScript
import { __decorate, __extends } from 'tslib';
import { Input, ViewChildren, forwardRef, Component, ChangeDetectionStrategy, NgModule } from '@angular/core';
import { ALWAYS_FALSE_HANDLER, TUI_DEFAULT_STRINGIFY, EMPTY_QUERY, isNativeFocused, isPresent, tuiDefaultProp, TuiElementModule } from '@taiga-ui/cdk';
import { TuiOptionComponent, TUI_DATA_LIST_ACCESSOR, TuiDataListModule, TuiLoaderModule } from '@taiga-ui/core';
import { CommonModule } from '@angular/common';
import { PolymorpheusModule } from '@tinkoff/ng-polymorpheus';
var TuiDataListWrapperComponent = /** @class */ (function () {
function TuiDataListWrapperComponent() {
this.items = [];
this.disabledItemHandler = ALWAYS_FALSE_HANDLER;
this.emptyContent = '';
this.itemContent = function (_a) {
var $implicit = _a.$implicit;
return TUI_DEFAULT_STRINGIFY($implicit);
};
this.size = 'm';
this.options = EMPTY_QUERY;
}
TuiDataListWrapperComponent_1 = TuiDataListWrapperComponent;
TuiDataListWrapperComponent.prototype.getContext = function ($implicit, _a) {
var nativeElement = _a.nativeElement;
return { $implicit: $implicit, active: isNativeFocused(nativeElement) };
};
TuiDataListWrapperComponent.prototype.getOptions = function (includeDisabled) {
if (includeDisabled === void 0) { includeDisabled = false; }
return this.options
.toArray()
.filter(function (_a) {
var disabled = _a.disabled;
return includeDisabled || !disabled;
})
.map(function (_a) {
var value = _a.value;
return value;
})
.filter(isPresent);
};
var TuiDataListWrapperComponent_1;
__decorate([
Input(),
tuiDefaultProp()
], TuiDataListWrapperComponent.prototype, "items", void 0);
__decorate([
Input(),
tuiDefaultProp()
], TuiDataListWrapperComponent.prototype, "disabledItemHandler", void 0);
__decorate([
Input(),
tuiDefaultProp()
], TuiDataListWrapperComponent.prototype, "emptyContent", void 0);
__decorate([
Input(),
tuiDefaultProp()
], TuiDataListWrapperComponent.prototype, "itemContent", void 0);
__decorate([
Input(),
tuiDefaultProp()
], TuiDataListWrapperComponent.prototype, "size", void 0);
__decorate([
ViewChildren(forwardRef(function () { return TuiOptionComponent; }))
], TuiDataListWrapperComponent.prototype, "options", void 0);
TuiDataListWrapperComponent = TuiDataListWrapperComponent_1 = __decorate([
Component({
selector: 'tui-data-list-wrapper:not([labels])',
template: "<tui-data-list *ngIf=\"items else loading\" [emptyContent]=\"emptyContent\">\n <button\n *ngFor=\"let item of items\"\n #elementRef=\"elementRef\"\n tuiElement\n tuiOption\n automation-id=\"tui-data-list-wrapper__option\"\n [size]=\"size\"\n [value]=\"item\"\n [disabled]=\"disabledItemHandler(item)\"\n >\n <span\n polymorpheus-outlet\n class=\"content\"\n [content]=\"itemContent\"\n [context]=\"getContext(item, elementRef)\"\n ></span>\n </button>\n</tui-data-list>\n<ng-template #loading>\n <tui-loader\n class=\"tui-space_vertical-3\"\n automation-id=\"tui-data-list-wrapper__loader\"\n ></tui-loader>\n</ng-template>\n",
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [
{
provide: TUI_DATA_LIST_ACCESSOR,
useExisting: forwardRef(function () { return TuiDataListWrapperComponent_1; }),
},
],
styles: [":host{display:block}.content{flex:1}"]
})
], TuiDataListWrapperComponent);
return TuiDataListWrapperComponent;
}());
var TuiDataListGroupWrapperComponent = /** @class */ (function (_super) {
__extends(TuiDataListGroupWrapperComponent, _super);
function TuiDataListGroupWrapperComponent() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.items = [];
_this.labels = [];
return _this;
}
TuiDataListGroupWrapperComponent_1 = TuiDataListGroupWrapperComponent;
var TuiDataListGroupWrapperComponent_1;
__decorate([
Input(),
tuiDefaultProp()
], TuiDataListGroupWrapperComponent.prototype, "items", void 0);
__decorate([
Input(),
tuiDefaultProp()
], TuiDataListGroupWrapperComponent.prototype, "labels", void 0);
TuiDataListGroupWrapperComponent = TuiDataListGroupWrapperComponent_1 = __decorate([
Component({
selector: 'tui-data-list-wrapper[labels]',
template: "<tui-data-list *ngIf=\"items else loading\" [emptyContent]=\"emptyContent\">\n <tui-opt-group\n *ngFor=\"let group of items; let index = index\"\n [label]=\"labels[index]\"\n >\n <button\n *ngFor=\"let item of group\"\n #elementRef=\"elementRef\"\n tuiElement\n tuiOption\n automation-id=\"tui-data-list-wrapper__option\"\n [size]=\"size\"\n [value]=\"item\"\n [disabled]=\"disabledItemHandler(item)\"\n >\n <span\n polymorpheus-outlet\n class=\"content\"\n [content]=\"itemContent\"\n [context]=\"getContext(item, elementRef)\"\n ></span>\n </button>\n </tui-opt-group>\n</tui-data-list>\n<ng-template #loading>\n <tui-loader class=\"tui-space_vertical-3\"></tui-loader>\n</ng-template>\n",
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [
{
provide: TUI_DATA_LIST_ACCESSOR,
useExisting: forwardRef(function () { return TuiDataListGroupWrapperComponent_1; }),
},
],
styles: [":host{display:block}.content{flex:1}"]
})
], TuiDataListGroupWrapperComponent);
return TuiDataListGroupWrapperComponent;
}(TuiDataListWrapperComponent));
var TuiDataListWrapperModule = /** @class */ (function () {
function TuiDataListWrapperModule() {
}
TuiDataListWrapperModule = __decorate([
NgModule({
imports: [
CommonModule,
PolymorpheusModule,
TuiElementModule,
TuiDataListModule,
TuiLoaderModule,
],
declarations: [TuiDataListWrapperComponent, TuiDataListGroupWrapperComponent],
exports: [TuiDataListWrapperComponent, TuiDataListGroupWrapperComponent],
})
], TuiDataListWrapperModule);
return TuiDataListWrapperModule;
}());
/**
* Generated bundle index. Do not edit.
*/
export { TuiDataListGroupWrapperComponent, TuiDataListWrapperComponent, TuiDataListWrapperModule };
//# sourceMappingURL=taiga-ui-kit-components-data-list-wrapper.js.map