Skip to content

Commit f3765a3

Browse files
committed
feat: move coercing to cdk package
* Moves the coercing to the CDK package * Fixes linking between Material and CDK package for tests (creating the index.ts file - similar as in angular/angular) *
1 parent a555108 commit f3765a3

26 files changed

+62
-23
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: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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 necessary for running the tests.
12+
*/
13+
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, LayoutDirection, RtlModule} from './rtl/dir';
@@ -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
@@ -34,7 +34,7 @@ import {ConnectedPositionStrategy} from './position/connected-position-strategy'
3434
import {Dir, LayoutDirection} from '../rtl/dir';
3535
import {Scrollable} from './scroll/scrollable';
3636
import {ScrollStrategy} from './scroll/scroll-strategy';
37-
import {coerceBooleanProperty} from '../coercion/boolean-property';
37+
import {coerceBooleanProperty} from '@angular/cdk';
3838
import {ESCAPE} from '../keyboard/keycodes';
3939
import {Subscription} from 'rxjs/Subscription';
4040
import {ScrollDispatchModule} from './scroll/index';

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/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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 necessary for running the tests.
12+
*/
13+
export * from './public_api';

src/lib/menu/menu-item.ts

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

99
import {Component, ElementRef, Input} from '@angular/core';
1010
import {Focusable} from '../core/a11y/focus-key-manager';
11-
import {coerceBooleanProperty} from '../core/coercion/boolean-property';
11+
import {coerceBooleanProperty} from '@angular/cdk';
1212

1313
/**
1414
* This directive is intended to be used inside an md-menu tag.

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/tabs/tab-label-wrapper.ts

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

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

1212

1313
/**

src/lib/tabs/tab.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
ViewContainerRef, Input, TemplateRef, ViewChild, OnInit, ContentChild,
1212
Component
1313
} from '@angular/core';
14-
import {coerceBooleanProperty} from '../core/coercion/boolean-property';
14+
import {coerceBooleanProperty} from '@angular/cdk';
1515

1616
import {MdTabLabel} from './tab-label';
1717

src/lib/tooltip/tooltip.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import {Dir} from '../core/rtl/dir';
4040
import {Platform} from '../core/platform/index';
4141
import 'rxjs/add/operator/first';
4242
import {ScrollDispatcher} from '../core/overlay/scroll/scroll-dispatcher';
43-
import {coerceBooleanProperty} from '../core/coercion/boolean-property';
43+
import {coerceBooleanProperty} from '@angular/cdk';
4444

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

src/lib/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
}

0 commit comments

Comments
 (0)