Skip to content

Commit 9322236

Browse files
committed
docs(material/datepicker): show API docs for mat-calendar and add an example of an inline calendar
1 parent 0de3f72 commit 9322236

File tree

6 files changed

+48
-19
lines changed

6 files changed

+48
-19
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.demo-inline-calendar {
2+
border: 1px solid black;
3+
width: 300px;
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<mat-calendar class="demo-inline-calendar" (selectedChange)="selected=$event">
2+
</mat-calendar>
3+
<p>Selected date: {{selected}}</p>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import {Component} from '@angular/core';
2+
3+
/** @title Datepicker inline calendar example */
4+
@Component({
5+
selector: 'datepicker-inline-calendar-example',
6+
templateUrl: 'datepicker-inline-calendar-example.html',
7+
styleUrls: ['datepicker-inline-calendar-example.css'],
8+
})
9+
export class DatepickerInlineCalendarExample {
10+
selected: Date | null;
11+
}

src/components-examples/material/datepicker/index.ts

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
11
import {CommonModule} from '@angular/common';
22
import {NgModule} from '@angular/core';
3-
import {ReactiveFormsModule, FormsModule} from '@angular/forms';
3+
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
44
import {MatButtonModule} from '@angular/material/button';
55
import {MatNativeDateModule} from '@angular/material/core';
66
import {MatDatepickerModule} from '@angular/material/datepicker';
77
import {MatIconModule} from '@angular/material/icon';
88
import {MatInputModule} from '@angular/material/input';
9+
import {
10+
DateRangePickerComparisonExample
11+
} from './date-range-picker-comparison/date-range-picker-comparison-example';
12+
import {
13+
DateRangePickerFormsExample
14+
} from './date-range-picker-forms/date-range-picker-forms-example';
15+
import {
16+
DateRangePickerOverviewExample
17+
} from './date-range-picker-overview/date-range-picker-overview-example';
18+
import {
19+
DateRangePickerSelectionStrategyExample
20+
} from './date-range-picker-selection-strategy/date-range-picker-selection-strategy-example';
21+
import {DatepickerActionsExample} from './datepicker-actions/datepicker-actions-example';
922

1023
import {DatepickerApiExample} from './datepicker-api/datepicker-api-example';
1124
import {DatepickerColorExample} from './datepicker-color/datepicker-color-example';
@@ -19,6 +32,10 @@ import {DatepickerDisabledExample} from './datepicker-disabled/datepicker-disabl
1932
import {DatepickerEventsExample} from './datepicker-events/datepicker-events-example';
2033
import {DatepickerFilterExample} from './datepicker-filter/datepicker-filter-example';
2134
import {DatepickerFormatsExample} from './datepicker-formats/datepicker-formats-example';
35+
import {DatepickerHarnessExample} from './datepicker-harness/datepicker-harness-example';
36+
import {
37+
DatepickerInlineCalendarExample
38+
} from './datepicker-inline-calendar/datepicker-inline-calendar-example';
2239
import {DatepickerLocaleExample} from './datepicker-locale/datepicker-locale-example';
2340
import {DatepickerMinMaxExample} from './datepicker-min-max/datepicker-min-max-example';
2441
import {DatepickerMomentExample} from './datepicker-moment/datepicker-moment-example';
@@ -29,20 +46,6 @@ import {DatepickerValueExample} from './datepicker-value/datepicker-value-exampl
2946
import {
3047
DatepickerViewsSelectionExample
3148
} from './datepicker-views-selection/datepicker-views-selection-example';
32-
import {
33-
DateRangePickerOverviewExample
34-
} from './date-range-picker-overview/date-range-picker-overview-example';
35-
import {
36-
DateRangePickerFormsExample
37-
} from './date-range-picker-forms/date-range-picker-forms-example';
38-
import {
39-
DateRangePickerComparisonExample
40-
} from './date-range-picker-comparison/date-range-picker-comparison-example';
41-
import {
42-
DateRangePickerSelectionStrategyExample
43-
} from './date-range-picker-selection-strategy/date-range-picker-selection-strategy-example';
44-
import {DatepickerHarnessExample} from './datepicker-harness/datepicker-harness-example';
45-
import {DatepickerActionsExample} from './datepicker-actions/datepicker-actions-example';
4649

4750
export {
4851
DatepickerApiExample,
@@ -55,6 +58,7 @@ export {
5558
DatepickerFilterExample,
5659
DatepickerFormatsExample,
5760
DatepickerHarnessExample,
61+
DatepickerInlineCalendarExample,
5862
DatepickerLocaleExample,
5963
DatepickerMinMaxExample,
6064
DatepickerMomentExample,

src/material/datepicker/calendar.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,7 @@ export class MatCalendarHeader<D> {
175175
}
176176
}
177177

178-
/**
179-
* A calendar that is used as part of the datepicker.
180-
* @docs-private
181-
*/
178+
/** A calendar that is used as part of the datepicker. */
182179
@Component({
183180
selector: 'mat-calendar',
184181
templateUrl: 'calendar.html',
@@ -381,6 +378,7 @@ export class MatCalendar<D> implements AfterContentInit, AfterViewChecked, OnDes
381378
this.stateChanges.next();
382379
}
383380

381+
/** Focuses the active date. */
384382
focusActiveCell() {
385383
this._getCurrentViewComponent()._focusActiveCell(false);
386384
}

src/material/datepicker/datepicker.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,15 @@ The calendar popup can be programmatically controlled using the `open` and `clos
258258

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

261+
### Using `mat-calendar` inline
262+
263+
If you want to allow the user to select a date from a calendar that is inlined on the page rather
264+
than contained in a popup, you can use `<mat-calendar>` directly. The calendar's height is
265+
determined automatically based on the width and the number of dates that need to be shown for a
266+
month. If you want to make the calendar larger or smaller, adjust the width rather than the height.
267+
268+
<!-- example(datepicker-inline-calendar) -->
269+
261270
### Internationalization
262271

263272
Internationalization of the datepicker is configured via four aspects:

0 commit comments

Comments
 (0)