Skip to content

Commit

Permalink
chore: add-table-body-cell-directive-guard
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Platonov committed Jun 21, 2024
1 parent 6b65f55 commit b0ab7e1
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 16 deletions.
19 changes: 13 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TableBodyRowRef } from './table-body-row-ref.interface';
import { TableColumnRef } from './table-column-ref.interface';

export interface TableBodyCellContext<T> {
$implicit: TableBodyRowRef<T>;
column: TableColumnRef;
export interface TableBodyCellContext<TCell, TColumn = unknown> {
$implicit: TableBodyRowRef<TCell>;
column: TableColumnRef<TColumn>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { Observable } from 'rxjs';
import { TableColumnEvents } from '../events/table-column.events';
import { TableColumnDefinition } from './table-column-definition.interface';

export interface TableColumnRef {
export interface TableColumnRef<TColumn = unknown> {
readonly index: number;
readonly definition: TableColumnDefinition;
readonly definition: TableColumnDefinition<TColumn>;
readonly widthPx$: Observable<number>;
readonly isHovered$: Observable<boolean>;
readonly isCurrentResizable$: Observable<boolean>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TableColumnRef } from './table-column-ref.interface';

export interface TableHeaderCellContext {
$implicit: TableColumnRef;
export interface TableHeaderCellContext<TColumn = unknown> {
$implicit: TableColumnRef<TColumn>;
isDndClone: boolean;
}
14 changes: 11 additions & 3 deletions projects/table/src/directives/table-cell-template.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@ import { TableBodyCellContext } from '../declarations/interfaces/table-body-cell
@Directive({
selector: '[pupaTableBodyCellTemplate]',
})
export class TableBodyCellTemplateDirective<T> {
@Input() public pupaTableBodyCellTemplateTypeFrom: T;
export class TableBodyCellTemplateDirective<TCell, TColumn> {
@Input() public pupaTableBodyCellTemplateCellTypeFrom: TCell;
@Input() public pupaTableBodyCellTemplateColumnTypeFrom: TColumn;

constructor(public readonly templateRef: TemplateRef<TableBodyCellContext<T>>) {}
constructor(public readonly templateRef: TemplateRef<TableBodyCellContext<TCell, TColumn>>) {}

public static ngTemplateContextGuard<TCell, TColumn>(
_directive: TableBodyCellTemplateDirective<TCell, TColumn>,
_context: unknown
): _context is TableBodyCellContext<TCell, TColumn> {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,11 @@ export class InfiniteScrollerItemTemplateDirective<T> {
@Input() public pupaInfiniteScrollerItemTemplateTypeFrom: T;

constructor(public readonly templateRef: TemplateRef<InfinityScrollerItemContext<T>>) {}

public static ngTemplateContextGuard<T>(
_directive: InfiniteScrollerItemTemplateDirective<T>,
_context: unknown
): _context is InfinityScrollerItemContext<T> {
return true;
}
}

0 comments on commit b0ab7e1

Please sign in to comment.