Skip to content

Commit c82000a

Browse files
committed
WIP: demo
1 parent 26ca31e commit c82000a

File tree

10 files changed

+39
-4
lines changed

10 files changed

+39
-4
lines changed

src/demo-app/datepicker/datepicker-demo.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,6 @@ <h2>Input disabled, datepicker popup enabled</h2>
105105
[startView]="yearView ? 'year' : 'month'"></md-datepicker>
106106
</md-form-field>
107107
</p>
108+
109+
<h2>Moment.js Datepicker</h2>
110+
<p><demo-moment-datepicker></demo-moment-datepicker></p>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<input mdInput [mdDatepicker]="picker" [(ngModel)]="date" placeholder="Moment.js datepicker">
2+
<md-datepicker-toggle mdSuffix [for]="picker"></md-datepicker-toggle>
3+
<md-datepicker #picker></md-datepicker>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import {ChangeDetectionStrategy, Component} from '@angular/core';
2+
import {DateAdapter, MAT_DATE_LOCALE_PROVIDER, MD_DATE_FORMATS} from '@angular/material';
3+
import {MomentDateAdapter, MD_MOMENT_DATE_FORMATS} from '@angular/material-moment-adapter';
4+
import * as moment from 'moment';
5+
6+
7+
@Component({
8+
moduleId: module.id,
9+
selector: 'demo-moment-datepicker',
10+
templateUrl: 'moment-datepicker.html',
11+
changeDetection: ChangeDetectionStrategy.OnPush,
12+
providers: [
13+
MAT_DATE_LOCALE_PROVIDER,
14+
{provide: DateAdapter, useClass: MomentDateAdapter},
15+
{provide: MD_DATE_FORMATS, useValue: MD_MOMENT_DATE_FORMATS},
16+
],
17+
})
18+
export class DemoMomentDatepicker {
19+
date = moment();
20+
}

src/demo-app/demo-app/demo-module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import {
4747
OverlayContainer,
4848
} from '@angular/material';
4949
import {TableHeaderDemo} from '../table/table-header-demo';
50+
import {DemoMomentDatepicker} from '../datepicker/moment-datepicker';
5051

5152
@NgModule({
5253
imports: [
@@ -66,6 +67,7 @@ import {TableHeaderDemo} from '../table/table-header-demo';
6667
CheckboxDemo,
6768
DatepickerDemo,
6869
DemoApp,
70+
DemoMomentDatepicker,
6971
DialogDemo,
7072
GesturesDemo,
7173
GridListDemo,

src/demo-app/system-config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ System.config({
99
map: {
1010
'rxjs': 'node:rxjs',
1111
'main': 'main.js',
12+
'moment': 'node:moment/min/moment-with-locales.min.js',
1213

1314
// Angular specific mappings.
1415
'@angular/core': 'node:@angular/core/bundles/core.umd.js',
@@ -26,6 +27,7 @@ System.config({
2627
'node:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
2728

2829
'@angular/material': 'dist/bundles/material.umd.js',
30+
'@angular/material-moment-adapter': 'dist/bundles/material-moment-adapter.umd.js',
2931
'@angular/cdk': 'dist/bundles/cdk.umd.js',
3032
'@angular/cdk/a11y': 'dist/bundles/cdk-a11y.umd.js',
3133
'@angular/cdk/bidi': 'dist/bundles/cdk-bidi.umd.js',

src/demo-app/tsconfig-aot.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"outDir": ".",
1212
"paths": {
1313
"@angular/material": ["./material"],
14-
"@angular/cdk/*": ["./cdk/*"]
14+
"@angular/cdk/*": ["./cdk/*"],
15+
"@angular/material-moment-adapter": ["./material-moment-adapter"]
1516
}
1617
},
1718
"files": [

src/demo-app/tsconfig-build.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"baseUrl": ".",
2323
"paths": {
2424
"@angular/material": ["../../dist/packages/material/public_api"],
25-
"@angular/cdk/*": ["../../dist/packages/cdk/*"]
25+
"@angular/cdk/*": ["../../dist/packages/cdk/*"],
26+
"@angular/material-moment-adapter": ["../../dist/packages/material-moment-adapter"]
2627
}
2728
},
2829
"files": [

tools/gulp/tasks/development.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const materialOutPath = join(outputDir, 'packages', 'material');
2121

2222
/** Array of vendors that are required to serve the demo-app. */
2323
const appVendors = [
24-
'@angular', 'systemjs', 'zone.js', 'rxjs', 'hammerjs', 'core-js', 'web-animations-js'
24+
'@angular', 'systemjs', 'zone.js', 'rxjs', 'hammerjs', 'core-js', 'web-animations-js', 'moment',
2525
];
2626

2727
/** Glob that matches all required vendors for the demo-app. */

tools/gulp/util/task_helpers.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ export function buildAppTask(appName: string) {
130130
.filter(taskName => gulp.hasTask(taskName));
131131

132132
return sequenceTask(
133-
'material:clean-build',
133+
// Build all required packages for serving the devapp by just building the moment-adapter
134+
// package. All dependencies of that package (material, cdk) will be built automatically.
135+
'material-moment-adapter:clean-build',
134136
[...buildTasks]
135137
);
136138
}

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"paths": {
1818
"@angular/material": ["./src/lib/public_api.ts"],
1919
"@angular/cdk/*": ["./src/cdk/*"],
20+
"@angular/material-moment-adapter": ["./src/material-moment-adapter"],
2021
"@angular/material-examples": ["./src/material-examples"],
2122
"material2-build-tools": ["./tools/package-tools"]
2223
}

0 commit comments

Comments
 (0)