Skip to content

Commit 6ffe9c7

Browse files
authored
fix(cdk/table): remove private symbols from public API (#30956)
Removes some symbols that are only constructed privately in the table from the public API. These shouldn't be exported or depended upon, because there's no way to actually pass them back into the table. I also ended up removing the `CDK_TABLE_TEMPLATE` variable, because it doesn't work in local compilation and it may become a problem in the future if we end up having single-file compilation in the framework. BREAKING CHANGE: * `CanStick` has been removed. * `CDK_TABLE_TEMPLATE` has been removed. * `StickyDirection` has been removed. * `StickyStyler` has been removed.
1 parent 897bcff commit 6ffe9c7

File tree

4 files changed

+30
-78
lines changed

4 files changed

+30
-78
lines changed

goldens/cdk/table/index.api.md

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { ElementRef } from '@angular/core';
1313
import { EventEmitter } from '@angular/core';
1414
import * as i0 from '@angular/core';
1515
import { InjectionToken } from '@angular/core';
16-
import { Injector } from '@angular/core';
1716
import { IterableChangeRecord } from '@angular/core';
1817
import { IterableChanges } from '@angular/core';
1918
import { IterableDiffer } from '@angular/core';
@@ -56,22 +55,12 @@ export abstract class BaseRowDef implements OnChanges {
5655
static ɵfac: i0.ɵɵFactoryDeclaration<BaseRowDef, never>;
5756
}
5857

59-
// @public
60-
export interface CanStick {
61-
hasStickyChanged(): boolean;
62-
resetStickyChanged(): void;
63-
sticky: boolean;
64-
}
65-
6658
// @public
6759
export const CDK_ROW_TEMPLATE = "<ng-container cdkCellOutlet></ng-container>";
6860

6961
// @public
7062
export const CDK_TABLE: InjectionToken<any>;
7163

72-
// @public
73-
export const CDK_TABLE_TEMPLATE = "\n <ng-content select=\"caption\"/>\n <ng-content select=\"colgroup, col\"/>\n\n <!--\n Unprojected content throws a hydration error so we need this to capture it.\n It gets removed on the client so it doesn't affect the layout.\n -->\n @if (_isServer) {\n <ng-content/>\n }\n\n @if (_isNativeHtmlTable) {\n <thead role=\"rowgroup\">\n <ng-container headerRowOutlet/>\n </thead>\n <tbody role=\"rowgroup\">\n <ng-container rowOutlet/>\n <ng-container noDataRowOutlet/>\n </tbody>\n <tfoot role=\"rowgroup\">\n <ng-container footerRowOutlet/>\n </tfoot>\n } @else {\n <ng-container headerRowOutlet/>\n <ng-container rowOutlet/>\n <ng-container noDataRowOutlet/>\n <ng-container footerRowOutlet/>\n }\n";
74-
7564
// @public
7665
export class CdkCell extends BaseCdkCell {
7766
constructor(...args: unknown[]);
@@ -525,15 +514,9 @@ export class _Schedule {
525514
tasks: (() => unknown)[];
526515
}
527516

528-
// @public
529-
export const STICKY_DIRECTIONS: StickyDirection[];
530-
531517
// @public
532518
export const STICKY_POSITIONING_LISTENER: InjectionToken<StickyPositioningListener>;
533519

534-
// @public
535-
export type StickyDirection = 'top' | 'bottom' | 'left' | 'right';
536-
537520
// @public (undocumented)
538521
export type StickyOffset = number | null | undefined;
539522

@@ -548,24 +531,6 @@ export interface StickyPositioningListener {
548531
// @public (undocumented)
549532
export type StickySize = number | null | undefined;
550533

551-
// @public
552-
export class StickyStyler {
553-
constructor(_isNativeHtmlTable: boolean, _stickCellCss: string, direction: Direction, _coalescedStyleScheduler: _CoalescedStyleScheduler, _isBrowser?: boolean, _needsPositionStickyOnElement?: boolean, _positionListener?: StickyPositioningListener | undefined, _tableInjector?: Injector | undefined);
554-
_addStickyStyle(element: HTMLElement, dir: StickyDirection, dirValue: number, isBorderElement: boolean): void;
555-
clearStickyPositioning(rows: HTMLElement[], stickyDirections: StickyDirection[]): void;
556-
destroy(): void;
557-
// (undocumented)
558-
direction: Direction;
559-
_getCalculatedZIndex(element: HTMLElement): string;
560-
_getCellWidths(row: HTMLElement, recalculateCellWidths?: boolean): number[];
561-
_getStickyEndColumnPositions(widths: number[], stickyStates: boolean[]): number[];
562-
_getStickyStartColumnPositions(widths: number[], stickyStates: boolean[]): number[];
563-
_removeStickyStyle(element: HTMLElement, stickyDirections: StickyDirection[]): void;
564-
stickRows(rowsToStick: HTMLElement[], stickyStates: boolean[], position: 'top' | 'bottom'): void;
565-
updateStickyColumns(rows: HTMLElement[], stickyStartStates: boolean[], stickyEndStates: boolean[], recalculateCellWidths?: boolean, replay?: boolean): void;
566-
updateStickyFooterContainer(tableElement: Element, stickyStates: boolean[]): void;
567-
}
568-
569534
// @public (undocumented)
570535
export interface StickyUpdate {
571536
// (undocumented)

src/cdk/table/public-api.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ export * from './cell';
1111
export * from './coalesced-style-scheduler';
1212
export * from './row';
1313
export * from './table-module';
14-
export * from './sticky-styler';
1514
export * from './sticky-position-listener';
16-
export * from './can-stick';
1715
export * from './text-column';
1816
export * from './tokens';
1917

src/cdk/table/table.ts

Lines changed: 30 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -184,45 +184,6 @@ export class NoDataRowOutlet implements RowOutlet {
184184
}
185185
}
186186

187-
/**
188-
* The table template that can be used by the mat-table. Should not be used outside of the
189-
* material library.
190-
* @docs-private
191-
*/
192-
export const CDK_TABLE_TEMPLATE =
193-
// Note that according to MDN, the `caption` element has to be projected as the **first**
194-
// element in the table. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/caption
195-
`
196-
<ng-content select="caption"/>
197-
<ng-content select="colgroup, col"/>
198-
199-
<!--
200-
Unprojected content throws a hydration error so we need this to capture it.
201-
It gets removed on the client so it doesn't affect the layout.
202-
-->
203-
@if (_isServer) {
204-
<ng-content/>
205-
}
206-
207-
@if (_isNativeHtmlTable) {
208-
<thead role="rowgroup">
209-
<ng-container headerRowOutlet/>
210-
</thead>
211-
<tbody role="rowgroup">
212-
<ng-container rowOutlet/>
213-
<ng-container noDataRowOutlet/>
214-
</tbody>
215-
<tfoot role="rowgroup">
216-
<ng-container footerRowOutlet/>
217-
</tfoot>
218-
} @else {
219-
<ng-container headerRowOutlet/>
220-
<ng-container rowOutlet/>
221-
<ng-container noDataRowOutlet/>
222-
<ng-container footerRowOutlet/>
223-
}
224-
`;
225-
226187
/**
227188
* Interface used to conveniently type the possible context interfaces for the render row.
228189
* @docs-private
@@ -265,7 +226,36 @@ export interface RenderRow<T> {
265226
@Component({
266227
selector: 'cdk-table, table[cdk-table]',
267228
exportAs: 'cdkTable',
268-
template: CDK_TABLE_TEMPLATE,
229+
template: `
230+
<ng-content select="caption"/>
231+
<ng-content select="colgroup, col"/>
232+
233+
<!--
234+
Unprojected content throws a hydration error so we need this to capture it.
235+
It gets removed on the client so it doesn't affect the layout.
236+
-->
237+
@if (_isServer) {
238+
<ng-content/>
239+
}
240+
241+
@if (_isNativeHtmlTable) {
242+
<thead role="rowgroup">
243+
<ng-container headerRowOutlet/>
244+
</thead>
245+
<tbody role="rowgroup">
246+
<ng-container rowOutlet/>
247+
<ng-container noDataRowOutlet/>
248+
</tbody>
249+
<tfoot role="rowgroup">
250+
<ng-container footerRowOutlet/>
251+
</tfoot>
252+
} @else {
253+
<ng-container headerRowOutlet/>
254+
<ng-container rowOutlet/>
255+
<ng-container noDataRowOutlet/>
256+
<ng-container footerRowOutlet/>
257+
}
258+
`,
269259
styleUrl: 'table.css',
270260
host: {
271261
'class': 'cdk-table',

src/material/table/table.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ export class MatRecycleRows {}
3939
exportAs: 'matTable',
4040
// Note that according to MDN, the `caption` element has to be projected as the **first**
4141
// element in the table. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/caption
42-
// We can't reuse `CDK_TABLE_TEMPLATE` because it's incompatible with local compilation mode.
4342
template: `
4443
<ng-content select="caption"/>
4544
<ng-content select="colgroup, col"/>

0 commit comments

Comments
 (0)