Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(addon-table): support partial objects #2722

Merged
merged 1 commit into from
Sep 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {Directive, Inject, Input, TemplateRef} from '@angular/core';
@Directive({
selector: `[tuiHead]`,
})
export class TuiHeadDirective<T extends Record<keyof T, any>> {
export class TuiHeadDirective<T extends Partial<Record<keyof T, any>>> {
@Input()
tuiHead!: keyof T;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {tuiDefaultProp} from '@taiga-ui/cdk';
@Directive({
selector: `ng-template[tuiRow]`,
})
export class TuiRowDirective<T extends Record<keyof T, any>> {
export class TuiRowDirective<T extends Partial<Record<keyof T, any>>> {
@Input()
@tuiDefaultProp()
tuiRowOf: readonly T[] = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {TuiTableDirective} from './table.directive';
@Directive({
selector: `table[tuiTable][tuiSortBy]`,
})
export class TuiSortByDirective<T extends Record<keyof T, any>> {
export class TuiSortByDirective<T extends Partial<Record<keyof T, any>>> {
@ContentChildren(TuiSortableDirective, {descendants: true})
private readonly sortables: QueryList<TuiSortableDirective<T>> = EMPTY_QUERY;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {TuiTableDirective} from './table.directive';
@Directive({
selector: `th[tuiTh][tuiSortable]`,
})
export class TuiSortableDirective<T extends Record<keyof T, any>>
export class TuiSortableDirective<T extends Partial<Record<keyof T, any>>>
implements DoCheck, OnInit
{
constructor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {TUI_TABLE_PROVIDERS} from '../providers/table.providers';
},
})
export class TuiTableDirective<
T extends Record<keyof T, any>,
T extends Partial<Record<keyof T, any>>,
> extends AbstractTuiController {
@Input()
@tuiDefaultProp()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import {TuiTableDirective} from '../directives/table.directive';
name: `tuiTableSort`,
pure: false,
})
export class TuiTableSortPipe<T extends Record<keyof T, any>> implements PipeTransform {
export class TuiTableSortPipe<T extends Partial<Record<keyof T, any>>>
implements PipeTransform
{
constructor(
@Inject(TuiTableDirective) private readonly table: TuiTableDirective<T>,
) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {TuiTrComponent} from '../tr/tr.component';
changeDetection: ChangeDetectionStrategy.OnPush,
providers: TUI_TABLE_PROVIDER,
})
export class TuiTbodyComponent<T extends Record<keyof T, any>> {
export class TuiTbodyComponent<T extends Partial<Record<keyof T, any>>> {
@Input()
@tuiDefaultProp()
data: readonly T[] = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {TuiThComponent} from '../th/th.component';
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [TUI_TABLE_PROVIDER],
})
export class TuiThGroupComponent<T extends Record<keyof T, any>>
export class TuiThGroupComponent<T extends Partial<Record<keyof T, any>>>
implements AfterContentInit
{
@ContentChild(forwardRef(() => TuiThComponent))
Expand Down
2 changes: 1 addition & 1 deletion projects/addon-table/components/table/th/th.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {TuiTableDirective} from '../directives/table.directive';
},
],
})
export class TuiThComponent<T extends Record<keyof T, any>> {
export class TuiThComponent<T extends Partial<Record<keyof T, any>>> {
@Input()
@tuiDefaultProp()
sorter: TuiComparator<T> | null = this.head
Expand Down
2 changes: 1 addition & 1 deletion projects/addon-table/components/table/tr/tr.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {TuiTbodyComponent} from '../tbody/tbody.component';
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [TUI_TABLE_PROVIDER],
})
export class TuiTrComponent<T extends Record<keyof T, any>> {
export class TuiTrComponent<T extends Partial<Record<keyof T, any>>> {
@ContentChildren(forwardRef(() => TuiCellDirective))
private readonly cells: QueryList<TuiCellDirective> = EMPTY_QUERY;

Expand Down