Skip to content

Commit 0830c27

Browse files
committed
Add a lot of JSDoc
1 parent 80eca9f commit 0830c27

File tree

11 files changed

+60
-4
lines changed

11 files changed

+60
-4
lines changed

src/cdk-experimental/column-resize/column-resize-directives/column-resize-flex.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {HeaderRowEventDispatcher} from '../event-dispatcher';
1515
import {HOST_BINDINGS, FLEX_PROVIDERS} from './constants';
1616

1717
/**
18-
* Explicitly enables column resizing for a flex cdk-table.
18+
* Explicitly enables column resizing for a flexbox-based cdk-table.
1919
* Individual columns must be annotated specifically.
2020
*/
2121
@Directive({

src/cdk-experimental/column-resize/column-resize-module.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,20 @@ import {
1717
CdkDefaultEnabledColumnResizeFlex
1818
} from './column-resize-directives/default-enabled-column-resize-flex';
1919

20+
/**
21+
* One of two NgModules for use with CdkColumnResize.
22+
* When using this module, columns are resizable by default.
23+
*/
2024
@NgModule({
2125
declarations: [CdkDefaultEnabledColumnResize, CdkDefaultEnabledColumnResizeFlex],
2226
exports: [CdkDefaultEnabledColumnResize, CdkDefaultEnabledColumnResizeFlex],
2327
})
2428
export class CdkColumnResizeDefaultEnabledModule {}
2529

30+
/**
31+
* One of two NgModules for use with CdkColumnResize.
32+
* When using this module, columns are not resizable by default.
33+
*/
2634
@NgModule({
2735
declarations: [CdkColumnResize, CdkColumnResizeFlex],
2836
exports: [CdkColumnResize, CdkColumnResizeFlex],

src/cdk-experimental/column-resize/column-resize-notifier.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,47 @@
99
import {Injectable} from '@angular/core';
1010
import {Observable, Subject} from 'rxjs';
1111

12+
/** Indicates the width of a column. */
1213
export interface ColumnSize {
14+
/** The ID/name of the column, as defined in CdkColumnDef. */
1315
readonly columnId: string;
16+
17+
/** The width in pixels of the column. */
1418
readonly size: number;
1519
}
1620

21+
/** Interface describing column size changes. */
1722
export interface ColumnSizeAction extends ColumnSize {
23+
/**
24+
* Whether the resize action should be applied instantaneously. False for events triggered during
25+
* a UI-triggered resize (such as with the mouse) until the mouse button is released. True
26+
* for all programatically triggered resizes.
27+
*/
1828
readonly completeImmediately?: boolean;
1929
}
2030

31+
/** Conduit for resize-releated events within the table. */
2132
@Injectable()
2233
export class ColumnResizeNotifierSource {
34+
/** Emits when an in-progress resize is canceled. */
2335
readonly resizeCanceled = new Subject<ColumnSizeAction>();
36+
37+
/** Emits when a resize is applied. */
2438
readonly resizeCompleted = new Subject<ColumnSize>();
39+
40+
/** Triggers a resize action. */
2541
readonly triggerResize = new Subject<ColumnSizeAction>();
2642
}
2743

2844
/** Service for triggering column resizes imperatively or being notified of them. */
2945
@Injectable()
3046
export class ColumnResizeNotifier {
47+
/** Emits whenever a column is resized. */
3148
readonly resizeCompleted: Observable<ColumnSize> = this._source.resizeCompleted.asObservable();
3249

3350
constructor(private readonly _source: ColumnResizeNotifierSource) {}
3451

52+
/** Instantly resizes the specified column. */
3553
resize(columnId: string, size: number): void {
3654
this._source.triggerResize.next({columnId, size, completeImmediately: true});
3755
}

src/cdk-experimental/column-resize/column-resize.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ export abstract class ColumnResize implements AfterViewInit, OnDestroy {
3838
protected abstract readonly ngZone: NgZone;
3939
protected abstract readonly notifier: ColumnResizeNotifierSource;
4040

41+
/** Unique ID for this table instance. */
4142
protected readonly selectorId = `${++nextId}`;
4243

44+
/** The id attribute of the table, if specified. */
4345
id?: string;
4446

4547
ngAfterViewInit() {
@@ -55,6 +57,7 @@ export abstract class ColumnResize implements AfterViewInit, OnDestroy {
5557
this.destroyed.complete();
5658
}
5759

60+
/** Gets the unique CSS class name for this table instance. */
5861
getUniqueCssClass() {
5962
return `cdk-column-resize-${this.selectorId}`;
6063
}

src/cdk-experimental/column-resize/column-size-store.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import {Injectable} from '@angular/core';
1313
*/
1414
@Injectable()
1515
export abstract class ColumnSizeStore {
16+
/** Returns the persisted size of the specified column in the specified table. */
1617
abstract getSize(tableId: string, columnId: string): number;
18+
19+
/** Persists the size of the specified column in the specified table. */
1720
abstract setSize(tableId: string, columnId: string): void;
1821
}

src/cdk-experimental/column-resize/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9+
// TODO: Figure out how to remove `mat-` classes from the CDK part of the
10+
// column resize implementation.
11+
912
export const HEADER_CELL_SELECTOR = '.cdk-header-cell, .mat-header-cell';
1013

1114
export const HEADER_ROW_SELECTOR = '.cdk-header-row, .mat-header-row';

src/cdk-experimental/column-resize/event-dispatcher.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,34 @@ import {_closest} from '@angular/cdk-experimental/popover-edit';
1414

1515
import {HEADER_ROW_SELECTOR} from './constants';
1616

17+
/** Coordinates events between the column resize directives. */
1718
@Injectable()
1819
export class HeaderRowEventDispatcher {
20+
/**
21+
* Emits the currently hovered header cell or null when no header cells are hovered.
22+
* Exposed publicly for events to feed in, but subscribers should use headerCellHoveredDistinct,
23+
* defined below.
24+
*/
1925
readonly headerCellHovered = new Subject<Element|null>();
2026

21-
// element refers to header row
27+
/**
28+
* Emits the header cell for which a user-triggered resize is active or null
29+
* when no resize is in progress.
30+
*/
2231
readonly overlayHandleActiveForCell = new Subject<Element|null>();
2332

2433
constructor(private readonly _ngZone: NgZone) {}
2534

35+
/** Distinct and shared version of headerCellHovered. */
2636
readonly headerCellHoveredDistinct = this.headerCellHovered.pipe(
2737
distinctUntilChanged(),
2838
share(),
2939
);
3040

41+
/**
42+
* Emits the header that is currently hovered or hosting an active resize event (with active
43+
* taking precedence).
44+
*/
3145
readonly headerRowHoveredOrActiveDistinct = combineLatest(
3246
this.headerCellHoveredDistinct.pipe(
3347
map(cell => _closest(cell, HEADER_ROW_SELECTOR)),
@@ -57,6 +71,10 @@ export class HeaderRowEventDispatcher {
5771
private _lastSeenRow: Element|null = null;
5872
private _lastSeenRowHover: Observable<boolean>|null = null;
5973

74+
/**
75+
* Emits whether the specified row should show its overlay controls.
76+
* Emission occurs within the NgZone.
77+
*/
6078
resizeOverlayVisibleForHeaderRow(row: Element): Observable<boolean> {
6179
if (row !== this._lastSeenRow) {
6280
this._lastSeenRow = row;

src/cdk-experimental/column-resize/resizable.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export abstract class Resizable<HandleComponent extends ResizeOverlayHandle>
5858
protected abstract readonly resizeStrategy: ResizeStrategy;
5959
protected abstract readonly viewContainerRef: ViewContainerRef;
6060

61+
/** The minimum width to allow the column to be sized to. */
6162
get minWidthPx(): number {
6263
return this.minWidthPxInternal;
6364
}
@@ -69,6 +70,7 @@ export abstract class Resizable<HandleComponent extends ResizeOverlayHandle>
6970
}
7071
}
7172

73+
/** The maximum width to allow the column to be sized to. */
7274
get maxWidthPx(): number {
7375
return this.maxWidthPxInternal;
7476
}

src/cdk-experimental/column-resize/resize-ref.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import {ElementRef} from '@angular/core';
1010
import {OverlayRef} from '@angular/cdk/overlay';
1111

12+
/** Tracks state of resize events in progress. */
1213
export class ResizeRef {
1314
constructor(
1415
readonly origin: ElementRef,

src/material-experimental/column-resize/column-resize-directives/column-resize-flex.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
import {AbstractMatColumnResize, FLEX_HOST_BINDINGS, FLEX_PROVIDERS} from './common';
1919

2020
/**
21-
* Explicitly enables column resizing for a flex mat-table.
21+
* Explicitly enables column resizing for a flexbox-based mat-table.
2222
* Individual columns must be annotated specifically.
2323
*/
2424
@Directive({

src/material-experimental/column-resize/column-resize-directives/default-enabled-column-resize-flex.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
import {AbstractMatColumnResize, FLEX_HOST_BINDINGS, FLEX_PROVIDERS} from './common';
1919

2020
/**
21-
* Implicitly enables column resizing for a flex mat-table.
21+
* Implicitly enables column resizing for a flexbox-based mat-table.
2222
* Individual columns will be resizable unless opted out.
2323
*/
2424
@Directive({

0 commit comments

Comments
 (0)