Browse Source

Refactor row detail context and typings in table component

Introduced a RowDetailContext interface for row detail templates to improve type safety and clarity. Updated rowDetailTemplate and related methods to use the new context type. Also added documentation regarding deprecated ::ng-deep usage in styles.
pull/24636/head
Fahri Gedik 9 months ago
parent
commit
f28dfe15b9
  1. 10
      npm/ng-packs/packages/components/extensible/src/lib/components/extensible-table/extensible-table.component.ts
  2. 4
      npm/ng-packs/packages/components/extensible/src/lib/models/row-detail.ts
  3. 1
      npm/ng-packs/packages/components/extensible/src/public-api.ts

10
npm/ng-packs/packages/components/extensible/src/lib/components/extensible-table/extensible-table.component.ts

@ -56,6 +56,7 @@ import {
} from '../../tokens/extensions.token';
import { GridActionsComponent } from '../grid-actions/grid-actions.component';
import { ExtensibleTableRowDetailComponent } from './extensible-table-row-detail';
import { RowDetailContext } from '../../models/row-detail';
const DEFAULT_ACTIONS_COLUMN_WIDTH = 150;
@ -136,8 +137,7 @@ export class ExtensibleTableComponent<R = any> implements OnChanges, AfterViewIn
@Output() loadMore = new EventEmitter<void>();
@Input() tableHeight: number;
// Row detail configuration (supports both direct template and child component)
@Input() rowDetailTemplate?: TemplateRef<{ row: R; expanded: boolean }>;
@Input() rowDetailTemplate?: TemplateRef<RowDetailContext<R>>;
@Input() rowDetailHeight: string | number = '100%';
@Output() rowDetailToggle = new EventEmitter<R>();
@ -146,13 +146,11 @@ export class ExtensibleTableComponent<R = any> implements OnChanges, AfterViewIn
@ViewChild('table', { static: false }) table!: DatatableComponent;
/** Gets the effective row detail template (from component or direct input) */
get effectiveRowDetailTemplate(): TemplateRef<any> | undefined {
protected get effectiveRowDetailTemplate(): TemplateRef<RowDetailContext<R>> | undefined {
return this.rowDetailComponent?.template() ?? this.rowDetailTemplate;
}
/** Gets the effective row detail height */
get effectiveRowDetailHeight(): string | number {
protected get effectiveRowDetailHeight(): string | number {
return this.rowDetailComponent?.rowHeight() ?? this.rowDetailHeight;
}

4
npm/ng-packs/packages/components/extensible/src/lib/models/row-detail.ts

@ -0,0 +1,4 @@
export interface RowDetailContext<R = any> {
row: R;
expanded: boolean;
}

1
npm/ng-packs/packages/components/extensible/src/public-api.ts

@ -69,4 +69,5 @@ export * from './lib/utils/form-props.util';
export * from './lib/utils/props.util';
export * from './lib/utils/state.util';
export * from './lib/utils/model.utils';
export * from './lib/models/row-detail';
export * from './lib/extensible.module';

Loading…
Cancel
Save