Skip to content

Commit

Permalink
fix(material/datepicker): hide date selection model from docs (#22056)
Browse files Browse the repository at this point in the history
* Hides some symbols related to the date selection model from the public API docs.
* Fixes that `MatDateSelectionModel` was marked as a directive, rather than an injectable.

Fixes #21985.
  • Loading branch information
crisbeto authored Mar 2, 2021
1 parent 4b1ee6f commit 8497bb1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
34 changes: 26 additions & 8 deletions src/material/datepicker/date-selection-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

import {FactoryProvider, Injectable, Optional, SkipSelf, OnDestroy, Directive} from '@angular/core';
import {FactoryProvider, Injectable, Optional, SkipSelf, OnDestroy} from '@angular/core';
import {DateAdapter} from '@angular/material/core';
import {Observable, Subject} from 'rxjs';

Expand All @@ -32,7 +32,10 @@ export class DateRange<D> {
*/
export type ExtractDateTypeFromSelection<T> = T extends DateRange<infer D> ? D : NonNullable<T>;

/** Event emitted by the date selection model when its selection changes. */
/**
* Event emitted by the date selection model when its selection changes.
* @docs-private
*/
export interface DateSelectionModelChange<S> {
/** New value for the selection. */
selection: S;
Expand All @@ -41,8 +44,11 @@ export interface DateSelectionModelChange<S> {
source: unknown;
}

/** A selection model containing a date selection. */
@Directive()
/**
* A selection model containing a date selection.
* @docs-private
*/
@Injectable()
export abstract class MatDateSelectionModel<S, D = ExtractDateTypeFromSelection<S>>
implements OnDestroy {
private _selectionChanged = new Subject<DateSelectionModelChange<S>>();
Expand Down Expand Up @@ -88,7 +94,10 @@ export abstract class MatDateSelectionModel<S, D = ExtractDateTypeFromSelection<
abstract clone(): MatDateSelectionModel<S, D>;
}

/** A selection model that contains a single date. */
/**
* A selection model that contains a single date.
* @docs-private
*/
@Injectable()
export class MatSingleDateSelectionModel<D> extends MatDateSelectionModel<D | null, D> {
constructor(adapter: DateAdapter<D>) {
Expand Down Expand Up @@ -124,7 +133,10 @@ export class MatSingleDateSelectionModel<D> extends MatDateSelectionModel<D | nu
}
}

/** A selection model that contains a date range. */
/**
* A selection model that contains a date range.
* @docs-private
*/
@Injectable()
export class MatRangeDateSelectionModel<D> extends MatDateSelectionModel<DateRange<D>, D> {
constructor(adapter: DateAdapter<D>) {
Expand Down Expand Up @@ -193,7 +205,10 @@ export function MAT_SINGLE_DATE_SELECTION_MODEL_FACTORY(
return parent || new MatSingleDateSelectionModel(adapter);
}

/** Used to provide a single selection model to a component. */
/**
* Used to provide a single selection model to a component.
* @docs-private
*/
export const MAT_SINGLE_DATE_SELECTION_MODEL_PROVIDER: FactoryProvider = {
provide: MatDateSelectionModel,
deps: [[new Optional(), new SkipSelf(), MatDateSelectionModel], DateAdapter],
Expand All @@ -207,7 +222,10 @@ export function MAT_RANGE_DATE_SELECTION_MODEL_FACTORY(
return parent || new MatRangeDateSelectionModel(adapter);
}

/** Used to provide a range selection model to a component. */
/**
* Used to provide a range selection model to a component.
* @docs-private
*/
export const MAT_RANGE_DATE_SELECTION_MODEL_PROVIDER: FactoryProvider = {
provide: MatDateSelectionModel,
deps: [[new Optional(), new SkipSelf(), MatDateSelectionModel], DateAdapter],
Expand Down
2 changes: 1 addition & 1 deletion tools/public_api_guard/material/datepicker.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,8 @@ export declare abstract class MatDateSelectionModel<S, D = ExtractDateTypeFromSe
abstract isValid(): boolean;
ngOnDestroy(): void;
updateSelection(value: S, source: unknown): void;
static ɵdir: i0.ɵɵDirectiveDefWithMeta<MatDateSelectionModel<any, any>, never, never, {}, {}, never>;
static ɵfac: i0.ɵɵFactoryDef<MatDateSelectionModel<any, any>, never>;
static ɵprov: i0.ɵɵInjectableDef<MatDateSelectionModel<any, any>>;
}

export declare class MatEndDate<D> extends _MatDateRangeInputBase<D> implements CanUpdateErrorState, DoCheck, OnInit {
Expand Down

0 comments on commit 8497bb1

Please sign in to comment.