UNPKG

@taiga-ui/kit

Version:
125 lines (120 loc) 5.82 kB
import { __decorate, __param } from 'tslib'; import { Optional, Self, Inject, ChangeDetectorRef, ElementRef, Input, HostBinding, ViewChildren, Component, ChangeDetectionStrategy, forwardRef, NgModule } from '@angular/core'; import { NgControl, FormsModule } from '@angular/forms'; import { AbstractTuiNullableControl, TUI_DEFAULT_IDENTITY_MATCHER, ALWAYS_FALSE_HANDLER, EMPTY_QUERY, isNativeFocusedIn, tuiDefaultProp, TUI_FOCUSABLE_ITEM_ACCESSOR } from '@taiga-ui/cdk'; import { TuiRadioLabeledComponent, TuiRadioLabeledModule } from '@taiga-ui/kit/components/radio-labeled'; import { CommonModule } from '@angular/common'; import { TuiRadioGroupModule } from '@taiga-ui/kit/components/radio-group'; import { PolymorpheusModule } from '@tinkoff/ng-polymorpheus'; var TuiRadioListComponent_1; let TuiRadioListComponent = TuiRadioListComponent_1 = class TuiRadioListComponent extends AbstractTuiNullableControl { constructor(control, changeDetectorRef, elementRef) { super(control, changeDetectorRef); this.elementRef = elementRef; this.items = []; this.size = 'm'; this.identityMatcher = TUI_DEFAULT_IDENTITY_MATCHER; this.orientation = "vertical" /* Vertical */; // @bad TODO: Remove & { index: number } this.itemContent = ({ $implicit, }) => String($implicit); this.disabledItemHandler = ALWAYS_FALSE_HANDLER; this.radioButtons = EMPTY_QUERY; } get nativeFocusableElement() { const focusableRadioButton = this.radioButtons.find(radioButton => radioButton.nativeFocusableElement !== null); return focusableRadioButton ? focusableRadioButton.nativeFocusableElement : null; } get focused() { return isNativeFocusedIn(this.elementRef.nativeElement); } computeId(index) { return `${this.id}-${index}`; } itemIsDisabled(item) { return this.disabledItemHandler(item); } getContentContext(item, index, active) { return { $implicit: item, index, active }; } onModelChange(value) { this.updateValue(value); } itemIsActive(item) { return this.value === null ? item === null : this.identityMatcher(this.value, item); } }; TuiRadioListComponent.ctorParameters = () => [ { type: NgControl, decorators: [{ type: Optional }, { type: Self }, { type: Inject, args: [NgControl,] }] }, { type: ChangeDetectorRef, decorators: [{ type: Inject, args: [ChangeDetectorRef,] }] }, { type: ElementRef, decorators: [{ type: Inject, args: [ElementRef,] }] } ]; __decorate([ Input(), tuiDefaultProp() ], TuiRadioListComponent.prototype, "items", void 0); __decorate([ Input(), HostBinding('attr.data-tui-host-size'), tuiDefaultProp() ], TuiRadioListComponent.prototype, "size", void 0); __decorate([ Input(), tuiDefaultProp() ], TuiRadioListComponent.prototype, "identityMatcher", void 0); __decorate([ Input(), HostBinding('attr.data-tui-host-orientation'), tuiDefaultProp() ], TuiRadioListComponent.prototype, "orientation", void 0); __decorate([ Input(), tuiDefaultProp() ], TuiRadioListComponent.prototype, "itemContent", void 0); __decorate([ Input(), tuiDefaultProp() ], TuiRadioListComponent.prototype, "disabledItemHandler", void 0); __decorate([ ViewChildren(TuiRadioLabeledComponent) ], TuiRadioListComponent.prototype, "radioButtons", void 0); TuiRadioListComponent = TuiRadioListComponent_1 = __decorate([ Component({ selector: 'tui-radio-list', template: "<tui-radio-group class=\"group\">\n <tui-radio-labeled\n *ngFor=\"let item of items; index as index\"\n class=\"item\"\n [readOnly]=\"readOnly\"\n [nativeId]=\"computeId(index)\"\n [disabled]=\"disabled\"\n [item]=\"item\"\n [size]=\"size\"\n [pseudoInvalid]=\"computedInvalid\"\n [pseudoDisabled]=\"itemIsDisabled(item)\"\n [ngModel]=\"value\"\n (ngModelChange)=\"onModelChange($event)\"\n >\n <div\n polymorpheus-outlet\n [content]=\"itemContent\"\n [context]=\"getContentContext(item, index, itemIsActive(item))\"\n ></div>\n </tui-radio-labeled>\n</tui-radio-group>\n", changeDetection: ChangeDetectionStrategy.OnPush, providers: [ { provide: TUI_FOCUSABLE_ITEM_ACCESSOR, useExisting: forwardRef(() => TuiRadioListComponent_1), }, ], styles: [":host{display:block}:host._readonly{pointer-events:none}:host[data-tui-host-orientation=horizontal] .group{display:flex;justify-content:inherit}:host[data-tui-host-orientation=horizontal] .item:nth-child(n+2){margin-left:24px}:host[data-tui-host-orientation=vertical] .item:nth-child(n+2){margin-top:12px}:host[data-tui-host-size='l'][data-tui-host-orientation=horizontal] .item:nth-child(n+2){margin-left:40px}:host[data-tui-host-size='l'][data-tui-host-orientation=vertical] .item:nth-child(n+2){margin-top:16px}"] }), __param(0, Optional()), __param(0, Self()), __param(0, Inject(NgControl)), __param(1, Inject(ChangeDetectorRef)), __param(2, Inject(ElementRef)) ], TuiRadioListComponent); let TuiRadioListModule = class TuiRadioListModule { }; TuiRadioListModule = __decorate([ NgModule({ imports: [ CommonModule, FormsModule, PolymorpheusModule, TuiRadioGroupModule, TuiRadioLabeledModule, ], declarations: [TuiRadioListComponent], exports: [TuiRadioListComponent], }) ], TuiRadioListModule); /** * Generated bundle index. Do not edit. */ export { TuiRadioListComponent, TuiRadioListModule }; //# sourceMappingURL=taiga-ui-kit-components-radio-list.js.map