Skip to content

Commit ae2bfde

Browse files
committed
Created essential datepicker CDK files and CalendarView component.
1 parent 6bd2775 commit ae2bfde

File tree

9 files changed

+146
-36
lines changed

9 files changed

+146
-36
lines changed

src/cdk/datepicker/BUILD.bazel

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package(default_visibility=["//visibility:public"])
2+
load("@angular//:index.bzl", "ng_module")
3+
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")
4+
5+
6+
ng_module(
7+
name = "datepicker",
8+
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
9+
module_name = "@angular/cdk/datepicker",
10+
deps = ["@rxjs"],
11+
tsconfig = "//src/cdk:tsconfig-build.json",
12+
)

src/cdk/datepicker/calendar-view.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
import {Subject} from 'rxjs';
10+
11+
/**
12+
* An abstract calendar that is used as part of the datepicker. This abstract calendar class
13+
* contains all necessary parts needed for a generic datepicker component. The material calendar,
14+
* month, year, and multi-year views will all extend this abstract calendar to provide overall
15+
* functionality of a datepicker component.
16+
* @docs-private
17+
*/
18+
export abstract class CalendarView<D> {
19+
20+
/** A date representing when to start the calendar. */
21+
abstract set activeDate(value: D);
22+
23+
/** The minimum selectable date. */
24+
abstract set minDate(value: D | null);
25+
26+
/** The maximum selectable date. */
27+
abstract set maxDate(value: D | null);
28+
29+
/** The currently selected date. */
30+
abstract set selected(value: D | null);
31+
32+
/**
33+
* Emits whenever there is a state change that needs to be responded to.
34+
*/
35+
stateChanges = new Subject<D>();
36+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
/**
3+
* @license
4+
* Copyright Google LLC All Rights Reserved.
5+
*
6+
* Use of this source code is governed by an MIT-style license that can be
7+
* found in the LICENSE file at https://angular.io/license
8+
*/
9+
10+
import {NgModule} from '@angular/core';
11+
12+
const EXPORTED_DECLARATIONS = [];
13+
14+
@NgModule({
15+
exports: EXPORTED_DECLARATIONS,
16+
declarations: EXPORTED_DECLARATIONS,
17+
})
18+
export class CdkDatepickerModule {}

src/cdk/datepicker/datepicker.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Will write this after completion of integration between material datepicker and CDK datepicker.

src/cdk/datepicker/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
export * from './public-api';

src/cdk/datepicker/public-api.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
export * from './calendar-view';
10+
export * from './datepicker-module';
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"extends": "../tsconfig-build",
3+
"files": [
4+
"public-api.ts",
5+
"../typings.d.ts"
6+
],
7+
"angularCompilerOptions": {
8+
"annotateForClosureCompiler": true,
9+
"strictMetadataEmit": true,
10+
"flatModuleOutFile": "index.js",
11+
"flatModuleId": "@angular/cdk/datepicker",
12+
"skipTemplateCodegen": true,
13+
"fullTemplateTypeCheck": true
14+
}
15+
}

src/cdk/datepicker/typings.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
declare var module: {id: string};

tools/package-tools/rollup-globals.ts

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ import {buildConfig} from './build-config';
44

55
/** Method that converts dash-case strings to a camel-based string. */
66
export const dashCaseToCamelCase =
7-
(str: string) => str.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
7+
(str: string) => str.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
88

99
/** Generates rollup entry point mappings for the given package and entry points. */
1010
function generateRollupEntryPoints(packageName: string, entryPoints: string[]):
11-
{[k: string]: string} {
12-
return entryPoints.reduce((globals: {[k: string]: string}, entryPoint: string) => {
13-
globals[`@angular/${packageName}/${entryPoint}`] =
14-
`ng.${dashCaseToCamelCase(packageName)}.${dashCaseToCamelCase(entryPoint)}`;
15-
return globals;
16-
}, {});
11+
{ [k: string]: string } {
12+
return entryPoints.reduce((globals: { [k: string]: string }, entryPoint: string) => {
13+
globals[`@angular/${packageName}/${entryPoint}`] =
14+
`ng.${dashCaseToCamelCase(packageName)}.${dashCaseToCamelCase(entryPoint)}`;
15+
return globals;
16+
}, {});
1717
}
1818

1919
/** List of potential secondary entry-points for the cdk package. */
@@ -38,37 +38,37 @@ const rollupCdkExperimentalEntryPoints =
3838

3939
/** Map of globals that are used inside of the different packages. */
4040
export const rollupGlobals = {
41-
'moment': 'moment',
42-
'tslib': 'tslib',
41+
'moment': 'moment',
42+
'tslib': 'tslib',
4343

44-
'@angular/animations': 'ng.animations',
45-
'@angular/common': 'ng.common',
46-
'@angular/common/http': 'ng.common.http',
47-
'@angular/common/http/testing': 'ng.common.http.testing',
48-
'@angular/common/testing': 'ng.common.testing',
49-
'@angular/core': 'ng.core',
50-
'@angular/core/testing': 'ng.core.testing',
51-
'@angular/forms': 'ng.forms',
52-
'@angular/platform-browser': 'ng.platformBrowser',
53-
'@angular/platform-browser-dynamic': 'ng.platformBrowserDynamic',
54-
'@angular/platform-browser-dynamic/testing': 'ng.platformBrowserDynamic.testing',
55-
'@angular/platform-browser/animations': 'ng.platformBrowser.animations',
56-
'@angular/platform-server': 'ng.platformServer',
57-
'@angular/router': 'ng.router',
44+
'@angular/animations': 'ng.animations',
45+
'@angular/common': 'ng.common',
46+
'@angular/common/http': 'ng.common.http',
47+
'@angular/common/http/testing': 'ng.common.http.testing',
48+
'@angular/common/testing': 'ng.common.testing',
49+
'@angular/core': 'ng.core',
50+
'@angular/core/testing': 'ng.core.testing',
51+
'@angular/forms': 'ng.forms',
52+
'@angular/platform-browser': 'ng.platformBrowser',
53+
'@angular/platform-browser-dynamic': 'ng.platformBrowserDynamic',
54+
'@angular/platform-browser-dynamic/testing': 'ng.platformBrowserDynamic.testing',
55+
'@angular/platform-browser/animations': 'ng.platformBrowser.animations',
56+
'@angular/platform-server': 'ng.platformServer',
57+
'@angular/router': 'ng.router',
5858

59-
// Some packages are not really needed for the UMD bundles, but for the missingRollupGlobals rule.
60-
'@angular/cdk': 'ng.cdk',
61-
'@angular/cdk-experimental': 'ng.cdkExperimental',
62-
'@angular/material': 'ng.material',
63-
'@angular/material-examples': 'ng.materialExamples',
64-
'@angular/material-experimental': 'ng.materialExperimental',
65-
'@angular/material-moment-adapter': 'ng.materialMomentAdapter',
59+
// Some packages are not really needed for the UMD bundles, but for the missingRollupGlobals rule.
60+
'@angular/cdk': 'ng.cdk',
61+
'@angular/cdk-experimental': 'ng.cdkExperimental',
62+
'@angular/material': 'ng.material',
63+
'@angular/material-examples': 'ng.materialExamples',
64+
'@angular/material-experimental': 'ng.materialExperimental',
65+
'@angular/material-moment-adapter': 'ng.materialMomentAdapter',
6666

67-
// Include secondary entry-points of the cdk and material packages
68-
...rollupCdkEntryPoints,
69-
...rollupMatEntryPoints,
70-
...rollupCdkExperimentalEntryPoints,
67+
// Include secondary entry-points of the cdk and material packages
68+
...rollupCdkEntryPoints,
69+
...rollupMatEntryPoints,
70+
...rollupCdkExperimentalEntryPoints,
7171

72-
'rxjs': 'rxjs',
73-
'rxjs/operators': 'rxjs.operators',
72+
'rxjs': 'rxjs',
73+
'rxjs/operators': 'rxjs.operators',
7474
};

0 commit comments

Comments
 (0)