Skip to content

Commit 11af1c9

Browse files
committed
feat: move coercing to cdk package
* Moves the coercing to the CDK package
1 parent fe31210 commit 11af1c9

23 files changed

+49
-21
lines changed

src/lib/core/coercion/boolean-property.spec.ts renamed to src/cdk/coercion/boolean-property.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {coerceBooleanProperty} from './boolean-property';
22

3-
43
describe('coerceBooleanProperty', () => {
4+
55
it('should coerce undefined to false', () => {
66
expect(coerceBooleanProperty(undefined)).toBe(false);
77
});
@@ -45,4 +45,5 @@ describe('coerceBooleanProperty', () => {
4545
it('should coerce an array to true', () => {
4646
expect(coerceBooleanProperty([])).toBe(true);
4747
});
48+
4849
});

src/cdk/coercion/index.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 Inc. 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 './boolean-property';
10+
export * from './number-property';

src/lib/core/coercion/number-property.spec.ts renamed to src/cdk/coercion/number-property.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {coerceNumberProperty} from './number-property';
22

3-
43
describe('coerceNumberProperty', () => {
4+
55
it('should coerce undefined to 0 or default', () => {
66
expect(coerceNumberProperty(undefined)).toBe(0);
77
expect(coerceNumberProperty(undefined, 111)).toBe(111);
@@ -78,4 +78,5 @@ describe('coerceNumberProperty', () => {
7878
expect(coerceNumberProperty([])).toBe(0);
7979
expect(coerceNumberProperty([], 111)).toBe(111);
8080
});
81+
8182
});

src/cdk/index.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. 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+
/*
10+
* This file is not used to build this module. The real "index.js" file will be generated by the
11+
* Angular Compiler CLI. This file is used inside of Google and is also used to simplify the
12+
* SystemJS configuration
13+
*/
14+
export * from './public_api';

src/cdk/public_api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
export const __TEMP__ = -1;
9+
export * from './coercion/index';

src/cdk/tsconfig-tests.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"experimentalDecorators": true
1212
},
1313
"include": [
14-
"**/*.spec.ts"
14+
"**/*.spec.ts",
15+
"index.ts"
1516
]
1617
}

src/lib/checkbox/checkbox.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
ViewEncapsulation,
2323
} from '@angular/core';
2424
import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms';
25-
import {coerceBooleanProperty} from '../core/coercion/boolean-property';
25+
import {coerceBooleanProperty} from '@angular/cdk';
2626
import {FocusOrigin, FocusOriginMonitor, MdRipple, RippleRef} from '../core';
2727
import {mixinDisabled, CanDisable} from '../core/common-behaviors/disabled';
2828
import {CanColor, mixinColor} from '../core/common-behaviors/color';

src/lib/chips/chip-list.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import {
1919

2020
import {MdChip} from './chip';
2121
import {FocusKeyManager} from '../core/a11y/focus-key-manager';
22-
import {coerceBooleanProperty} from '../core/coercion/boolean-property';
2322
import {SPACE, LEFT_ARROW, RIGHT_ARROW, TAB} from '../core/keyboard/keycodes';
23+
import {coerceBooleanProperty} from '@angular/cdk';
2424
import {Subscription} from 'rxjs/Subscription';
2525

2626
/**

src/lib/chips/chip.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
} from '@angular/core';
1818

1919
import {Focusable} from '../core/a11y/focus-key-manager';
20-
import {coerceBooleanProperty} from '../core/coercion/boolean-property';
20+
import {coerceBooleanProperty} from '@angular/cdk';
2121
import {CanColor, mixinColor} from '../core/common-behaviors/color';
2222
import {CanDisable, mixinDisabled} from '../core/common-behaviors/disabled';
2323

src/lib/core/a11y/focus-trap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
} from '@angular/core';
1818
import {InteractivityChecker} from './interactivity-checker';
1919
import {Platform} from '../platform/platform';
20-
import {coerceBooleanProperty} from '../coercion/boolean-property';
20+
import {coerceBooleanProperty} from '@angular/cdk';
2121

2222
import 'rxjs/add/operator/first';
2323

src/lib/core/common-behaviors/disabled.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {coerceBooleanProperty} from '../coercion/boolean-property';
9+
import {coerceBooleanProperty} from '@angular/cdk';
1010
import {Constructor} from './constructor';
1111

1212
/** @docs-private */

src/lib/core/core.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import {A11yModule} from './a11y/index';
1717
import {MdSelectionModule} from './selection/index';
1818
import {MdRippleModule} from './ripple/index';
1919

20+
// Re-exports of the CDK to avoid breaking changes.
21+
export {coerceBooleanProperty, coerceNumberProperty} from '@angular/cdk';
2022

2123
// RTL
2224
export {Dir, Direction, Directionality, BidiModule} from './bidi/index';
@@ -98,10 +100,6 @@ export * from './animation/animation';
98100
// Selection
99101
export * from './selection/index';
100102

101-
// Coercion
102-
export {coerceBooleanProperty} from './coercion/boolean-property';
103-
export {coerceNumberProperty} from './coercion/number-property';
104-
105103
// Compatibility
106104
export {CompatibilityModule, NoConflictStyleCompatibilityMode} from './compatibility/compatibility';
107105

src/lib/core/option/option.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
Optional,
1919
} from '@angular/core';
2020
import {ENTER, SPACE} from '../keyboard/keycodes';
21-
import {coerceBooleanProperty} from '../coercion/boolean-property';
21+
import {coerceBooleanProperty} from '@angular/cdk';
2222
import {MATERIAL_COMPATIBILITY_MODE} from '../../core/compatibility/compatibility';
2323
import {MdOptgroup} from './optgroup';
2424

src/lib/core/overlay/overlay-directives.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import {ConnectedPositionStrategy} from './position/connected-position-strategy'
3232
import {Directionality, Direction} from '../bidi/index';
3333
import {Scrollable} from './scroll/scrollable';
3434
import {ScrollStrategy} from './scroll/scroll-strategy';
35-
import {coerceBooleanProperty} from '../coercion/boolean-property';
35+
import {coerceBooleanProperty} from '@angular/cdk';
3636
import {ESCAPE} from '../keyboard/keycodes';
3737
import {Subscription} from 'rxjs/Subscription';
3838

src/lib/expansion/accordion.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import {Directive, Input} from '@angular/core';
10-
import {coerceBooleanProperty} from '../core/coercion/boolean-property';
10+
import {coerceBooleanProperty} from '@angular/cdk';
1111

1212
/** MdAccordion's display modes. */
1313
export type MdAccordionDisplayMode = 'default' | 'flat';

src/lib/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
},
2323
"homepage": "https://github.com/angular/material2#readme",
2424
"peerDependencies": {
25+
"@angular/cdk": "0.0.0-PLACEHOLDER",
2526
"@angular/core": "^4.0.0",
2627
"@angular/common": "^4.0.0"
2728
},

src/lib/radio/radio.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import {
3535
FocusOriginMonitor,
3636
FocusOrigin,
3737
} from '../core';
38-
import {coerceBooleanProperty} from '../core/coercion/boolean-property';
38+
import {coerceBooleanProperty} from '@angular/cdk';
3939
import {mixinDisabled, CanDisable} from '../core/common-behaviors/disabled';
4040
import {CanColor, mixinColor} from '../core/common-behaviors/color';
4141

src/lib/select/select.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import {Observable} from 'rxjs/Observable';
3434
import {Subscription} from 'rxjs/Subscription';
3535
import {transformPlaceholder, transformPanel, fadeInContent} from './select-animations';
3636
import {ControlValueAccessor, NgControl} from '@angular/forms';
37-
import {coerceBooleanProperty} from '../core/coercion/boolean-property';
37+
import {coerceBooleanProperty} from '@angular/cdk';
3838
import {ConnectedOverlayDirective} from '../core/overlay/overlay-directives';
3939
import {ViewportRuler} from '../core/overlay/position/viewport-ruler';
4040
import {SelectionModel} from '../core/selection/selection';

src/lib/tooltip/tooltip.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import {Directionality} from '../core/bidi/index';
4141
import {Platform} from '../core/platform/index';
4242
import 'rxjs/add/operator/first';
4343
import {ScrollDispatcher} from '../core/overlay/scroll/scroll-dispatcher';
44-
import {coerceBooleanProperty} from '../core/coercion/boolean-property';
44+
import {coerceBooleanProperty} from '@angular/cdk';
4545

4646
export type TooltipPosition = 'left' | 'right' | 'above' | 'below' | 'before' | 'after';
4747

src/lib/tsconfig-tests.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"strictNullChecks": true
1313
},
1414
"include": [
15-
"**/*.spec.ts"
15+
"**/*.spec.ts",
16+
"index.ts"
1617
]
1718
}

test/karma-test-shim.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ System.config({
4646
'node:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic-testing.umd.js',
4747

4848
// Path mappings for local packages that can be imported inside of tests.
49-
'@angular/material': 'dist/packages/material/index.js',
49+
// TODO(devversion): replace once the index.ts file for the Material package has been added.
50+
'@angular/material': 'dist/packages/material/public_api.js',
5051
'@angular/cdk': 'dist/packages/cdk/index.js',
5152
},
5253
packages: {

0 commit comments

Comments
 (0)