Skip to content

docs(material/datepicker): show API docs for mat-calendar and add an … #22794

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/components-examples/material/datepicker/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ ng_module(
"//src/cdk/testing/testbed",
"//src/material-moment-adapter",
"//src/material/button",
"//src/material/card",
"//src/material/core",
"//src/material/datepicker",
"//src/material/datepicker/testing",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.demo-inline-calendar-card {
width: 300px;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<mat-card class="demo-inline-calendar-card">
<mat-calendar (selectedChange)="selected = $event"></mat-calendar>
</mat-card>
<p>Selected date: {{selected}}</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {Component} from '@angular/core';

/** @title Datepicker inline calendar example */
@Component({
selector: 'datepicker-inline-calendar-example',
templateUrl: 'datepicker-inline-calendar-example.html',
styleUrls: ['datepicker-inline-calendar-example.css'],
})
export class DatepickerInlineCalendarExample {
selected: Date | null;
}
37 changes: 22 additions & 15 deletions src/components-examples/material/datepicker/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
import {CommonModule} from '@angular/common';
import {NgModule} from '@angular/core';
import {ReactiveFormsModule, FormsModule} from '@angular/forms';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {MatButtonModule} from '@angular/material/button';
import {MatCardModule} from '@angular/material/card';
import {MatNativeDateModule} from '@angular/material/core';
import {MatDatepickerModule} from '@angular/material/datepicker';
import {MatIconModule} from '@angular/material/icon';
import {MatInputModule} from '@angular/material/input';
import {
DateRangePickerComparisonExample
} from './date-range-picker-comparison/date-range-picker-comparison-example';
import {
DateRangePickerFormsExample
} from './date-range-picker-forms/date-range-picker-forms-example';
import {
DateRangePickerOverviewExample
} from './date-range-picker-overview/date-range-picker-overview-example';
import {
DateRangePickerSelectionStrategyExample
} from './date-range-picker-selection-strategy/date-range-picker-selection-strategy-example';
import {DatepickerActionsExample} from './datepicker-actions/datepicker-actions-example';

import {DatepickerApiExample} from './datepicker-api/datepicker-api-example';
import {DatepickerColorExample} from './datepicker-color/datepicker-color-example';
Expand All @@ -19,6 +33,10 @@ import {DatepickerDisabledExample} from './datepicker-disabled/datepicker-disabl
import {DatepickerEventsExample} from './datepicker-events/datepicker-events-example';
import {DatepickerFilterExample} from './datepicker-filter/datepicker-filter-example';
import {DatepickerFormatsExample} from './datepicker-formats/datepicker-formats-example';
import {DatepickerHarnessExample} from './datepicker-harness/datepicker-harness-example';
import {
DatepickerInlineCalendarExample
} from './datepicker-inline-calendar/datepicker-inline-calendar-example';
import {DatepickerLocaleExample} from './datepicker-locale/datepicker-locale-example';
import {DatepickerMinMaxExample} from './datepicker-min-max/datepicker-min-max-example';
import {DatepickerMomentExample} from './datepicker-moment/datepicker-moment-example';
Expand All @@ -29,20 +47,6 @@ import {DatepickerValueExample} from './datepicker-value/datepicker-value-exampl
import {
DatepickerViewsSelectionExample
} from './datepicker-views-selection/datepicker-views-selection-example';
import {
DateRangePickerOverviewExample
} from './date-range-picker-overview/date-range-picker-overview-example';
import {
DateRangePickerFormsExample
} from './date-range-picker-forms/date-range-picker-forms-example';
import {
DateRangePickerComparisonExample
} from './date-range-picker-comparison/date-range-picker-comparison-example';
import {
DateRangePickerSelectionStrategyExample
} from './date-range-picker-selection-strategy/date-range-picker-selection-strategy-example';
import {DatepickerHarnessExample} from './datepicker-harness/datepicker-harness-example';
import {DatepickerActionsExample} from './datepicker-actions/datepicker-actions-example';

export {
DatepickerApiExample,
Expand All @@ -55,6 +59,7 @@ export {
DatepickerFilterExample,
DatepickerFormatsExample,
DatepickerHarnessExample,
DatepickerInlineCalendarExample,
DatepickerLocaleExample,
DatepickerMinMaxExample,
DatepickerMomentExample,
Expand Down Expand Up @@ -82,6 +87,7 @@ const EXAMPLES = [
DatepickerFilterExample,
DatepickerFormatsExample,
DatepickerHarnessExample,
DatepickerInlineCalendarExample,
DatepickerLocaleExample,
DatepickerMinMaxExample,
DatepickerMomentExample,
Expand All @@ -102,6 +108,7 @@ const EXAMPLES = [
imports: [
CommonModule,
MatButtonModule,
MatCardModule,
MatDatepickerModule,
MatInputModule,
MatIconModule,
Expand Down
6 changes: 2 additions & 4 deletions src/material/datepicker/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,7 @@ export class MatCalendarHeader<D> {
}
}

/**
* A calendar that is used as part of the datepicker.
* @docs-private
*/
/** A calendar that is used as part of the datepicker. */
@Component({
selector: 'mat-calendar',
templateUrl: 'calendar.html',
Expand Down Expand Up @@ -381,6 +378,7 @@ export class MatCalendar<D> implements AfterContentInit, AfterViewChecked, OnDes
this.stateChanges.next();
}

/** Focuses the active date. */
focusActiveCell() {
this._getCurrentViewComponent()._focusActiveCell(false);
}
Expand Down
9 changes: 9 additions & 0 deletions src/material/datepicker/datepicker.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,15 @@ The calendar popup can be programmatically controlled using the `open` and `clos

<!-- example(datepicker-api) -->

### Using `mat-calendar` inline

If you want to allow the user to select a date from a calendar that is inlined on the page rather
than contained in a popup, you can use `<mat-calendar>` directly. The calendar's height is
determined automatically based on the width and the number of dates that need to be shown for a
month. If you want to make the calendar larger or smaller, adjust the width rather than the height.

<!-- example(datepicker-inline-calendar) -->

### Internationalization

Internationalization of the datepicker is configured via four aspects:
Expand Down