Skip to content

Commit

Permalink
chore: move coercing to cdk package (#5025)
Browse files Browse the repository at this point in the history
  • Loading branch information
devversion authored and jelbourn committed Jun 22, 2017
1 parent fe31210 commit 17cc4a1
Show file tree
Hide file tree
Showing 23 changed files with 49 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {coerceBooleanProperty} from './boolean-property';


describe('coerceBooleanProperty', () => {

it('should coerce undefined to false', () => {
expect(coerceBooleanProperty(undefined)).toBe(false);
});
Expand Down Expand Up @@ -45,4 +45,5 @@ describe('coerceBooleanProperty', () => {
it('should coerce an array to true', () => {
expect(coerceBooleanProperty([])).toBe(true);
});

});
File renamed without changes.
10 changes: 10 additions & 0 deletions src/cdk/coercion/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/

export * from './boolean-property';
export * from './number-property';
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {coerceNumberProperty} from './number-property';


describe('coerceNumberProperty', () => {

it('should coerce undefined to 0 or default', () => {
expect(coerceNumberProperty(undefined)).toBe(0);
expect(coerceNumberProperty(undefined, 111)).toBe(111);
Expand Down Expand Up @@ -78,4 +78,5 @@ describe('coerceNumberProperty', () => {
expect(coerceNumberProperty([])).toBe(0);
expect(coerceNumberProperty([], 111)).toBe(111);
});

});
File renamed without changes.
14 changes: 14 additions & 0 deletions src/cdk/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/

/*
* This file is not used to build this module. The real "index.js" file will be generated by the
* Angular Compiler CLI. This file is used inside of Google and is also used to simplify the
* SystemJS configuration
*/
export * from './public_api';
2 changes: 1 addition & 1 deletion src/cdk/public_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
* found in the LICENSE file at https://angular.io/license
*/

export const __TEMP__ = -1;
export * from './coercion/index';
3 changes: 2 additions & 1 deletion src/cdk/tsconfig-tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"experimentalDecorators": true
},
"include": [
"**/*.spec.ts"
"**/*.spec.ts",
"index.ts"
]
}
2 changes: 1 addition & 1 deletion src/lib/checkbox/checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
ViewEncapsulation,
} from '@angular/core';
import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms';
import {coerceBooleanProperty} from '../core/coercion/boolean-property';
import {coerceBooleanProperty} from '@angular/cdk';
import {FocusOrigin, FocusOriginMonitor, MdRipple, RippleRef} from '../core';
import {mixinDisabled, CanDisable} from '../core/common-behaviors/disabled';
import {CanColor, mixinColor} from '../core/common-behaviors/color';
Expand Down
2 changes: 1 addition & 1 deletion src/lib/chips/chip-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import {

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

/**
Expand Down
2 changes: 1 addition & 1 deletion src/lib/chips/chip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
} from '@angular/core';

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

Expand Down
2 changes: 1 addition & 1 deletion src/lib/core/a11y/focus-trap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
} from '@angular/core';
import {InteractivityChecker} from './interactivity-checker';
import {Platform} from '../platform/platform';
import {coerceBooleanProperty} from '../coercion/boolean-property';
import {coerceBooleanProperty} from '@angular/cdk';

import 'rxjs/add/operator/first';

Expand Down
2 changes: 1 addition & 1 deletion src/lib/core/common-behaviors/disabled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

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

/** @docs-private */
Expand Down
6 changes: 2 additions & 4 deletions src/lib/core/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import {A11yModule} from './a11y/index';
import {MdSelectionModule} from './selection/index';
import {MdRippleModule} from './ripple/index';

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

// RTL
export {Dir, Direction, Directionality, BidiModule} from './bidi/index';
Expand Down Expand Up @@ -98,10 +100,6 @@ export * from './animation/animation';
// Selection
export * from './selection/index';

// Coercion
export {coerceBooleanProperty} from './coercion/boolean-property';
export {coerceNumberProperty} from './coercion/number-property';

// Compatibility
export {CompatibilityModule, NoConflictStyleCompatibilityMode} from './compatibility/compatibility';

Expand Down
2 changes: 1 addition & 1 deletion src/lib/core/option/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
Optional,
} from '@angular/core';
import {ENTER, SPACE} from '../keyboard/keycodes';
import {coerceBooleanProperty} from '../coercion/boolean-property';
import {coerceBooleanProperty} from '@angular/cdk';
import {MATERIAL_COMPATIBILITY_MODE} from '../../core/compatibility/compatibility';
import {MdOptgroup} from './optgroup';

Expand Down
2 changes: 1 addition & 1 deletion src/lib/core/overlay/overlay-directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {ConnectedPositionStrategy} from './position/connected-position-strategy'
import {Directionality, Direction} from '../bidi/index';
import {Scrollable} from './scroll/scrollable';
import {ScrollStrategy} from './scroll/scroll-strategy';
import {coerceBooleanProperty} from '../coercion/boolean-property';
import {coerceBooleanProperty} from '@angular/cdk';
import {ESCAPE} from '../keyboard/keycodes';
import {Subscription} from 'rxjs/Subscription';

Expand Down
2 changes: 1 addition & 1 deletion src/lib/expansion/accordion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

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

/** MdAccordion's display modes. */
export type MdAccordionDisplayMode = 'default' | 'flat';
Expand Down
1 change: 1 addition & 0 deletions src/lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
},
"homepage": "https://github.com/angular/material2#readme",
"peerDependencies": {
"@angular/cdk": "0.0.0-PLACEHOLDER",
"@angular/core": "^4.0.0",
"@angular/common": "^4.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion src/lib/radio/radio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
FocusOriginMonitor,
FocusOrigin,
} from '../core';
import {coerceBooleanProperty} from '../core/coercion/boolean-property';
import {coerceBooleanProperty} from '@angular/cdk';
import {mixinDisabled, CanDisable} from '../core/common-behaviors/disabled';
import {CanColor, mixinColor} from '../core/common-behaviors/color';

Expand Down
2 changes: 1 addition & 1 deletion src/lib/select/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {Observable} from 'rxjs/Observable';
import {Subscription} from 'rxjs/Subscription';
import {transformPlaceholder, transformPanel, fadeInContent} from './select-animations';
import {ControlValueAccessor, NgControl} from '@angular/forms';
import {coerceBooleanProperty} from '../core/coercion/boolean-property';
import {coerceBooleanProperty} from '@angular/cdk';
import {ConnectedOverlayDirective} from '../core/overlay/overlay-directives';
import {ViewportRuler} from '../core/overlay/position/viewport-ruler';
import {SelectionModel} from '../core/selection/selection';
Expand Down
2 changes: 1 addition & 1 deletion src/lib/tooltip/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import {Directionality} from '../core/bidi/index';
import {Platform} from '../core/platform/index';
import 'rxjs/add/operator/first';
import {ScrollDispatcher} from '../core/overlay/scroll/scroll-dispatcher';
import {coerceBooleanProperty} from '../core/coercion/boolean-property';
import {coerceBooleanProperty} from '@angular/cdk';

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

Expand Down
3 changes: 2 additions & 1 deletion src/lib/tsconfig-tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"strictNullChecks": true
},
"include": [
"**/*.spec.ts"
"**/*.spec.ts",
"index.ts"
]
}
3 changes: 2 additions & 1 deletion test/karma-test-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ System.config({
'node:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic-testing.umd.js',

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

0 comments on commit 17cc4a1

Please sign in to comment.