Skip to content

Commit

Permalink
chore(coerceBoolean): * BREAKING CHANGE * deprecate improper uses of …
Browse files Browse the repository at this point in the history
…coerceBoolean

also cleaning up related imports

BREAKING CHANGE:
boolean values will have to be entered correctly accoring to angular in the
html([booleanvar]="true")

ISSUES CLOSED: #1233
  • Loading branch information
shani-terminus authored and benjamincharity committed Apr 9, 2019
1 parent 0b45bca commit 1b38004
Showing 33 changed files with 99 additions and 907 deletions.
2 changes: 0 additions & 2 deletions demo/app/components/tooltip/tooltip.component.html
Original file line number Diff line number Diff line change
@@ -11,8 +11,6 @@ <h3 tsCardTitle tsVerticalSpacing>
<option value="after">After</option>
<option value="above">Above</option>
<option value="below">Below</option>
<option value="left">Left</option>
<option value="right">Right</option>
</select>
</label>
<br>
15 changes: 1 addition & 14 deletions terminus-ui/autocomplete/src/autocomplete.component.ts
Original file line number Diff line number Diff line change
@@ -23,13 +23,11 @@ import {
} from '@angular/material/autocomplete';
import {
arrayContainsObject,
isBoolean,
isFunction,
untilComponentDestroyed,
} from '@terminus/ngx-tools';
import {
coerceArray,
coerceBooleanProperty,
coerceNumberProperty,
} from '@terminus/ngx-tools/coercion';
import { TS_SPACING } from '@terminus/ui/spacing';
@@ -279,19 +277,8 @@ export class TsAutocompleteComponent<OptionType = {[name: string]: any}> impleme
* Define if the progress spinner should be active
*/
@Input()
public set showProgress(value: boolean) {
/* istanbul ignore if */
if (!isBoolean(value) && value && isDevMode()) {
console.warn(`TsAutocompleteComponent: "showProgress" value is not a boolean. ` +
`String values of 'true' and 'false' will no longer be coerced to a true boolean with the next release.`);
}
public showProgress = false;

this._showProgress = coerceBooleanProperty(value);
}
public get showProgress(): boolean {
return this._showProgress;
}
private _showProgress = false;
/**
* Define the component theme
*/
40 changes: 4 additions & 36 deletions terminus-ui/button/src/button.component.ts
Original file line number Diff line number Diff line change
@@ -13,11 +13,7 @@ import {
ViewChild,
ViewEncapsulation,
} from '@angular/core';
import {
isBoolean,
TsWindowService,
} from '@terminus/ngx-tools';
import { coerceBooleanProperty } from '@terminus/ngx-tools/coercion';
import { TsWindowService } from '@terminus/ngx-tools';
import {
TsStyleThemeTypes,
tsStyleThemeTypesArray,
@@ -141,13 +137,7 @@ export class TsButtonComponent implements OnInit, OnDestroy {
*/
@Input()
public set collapsed(value: boolean) {
/* istanbul ignore if */
if (!isBoolean(value) && value && isDevMode()) {
console.warn(`TsButtonComponent: "collapsed" value is not a boolean. ` +
`String values of 'true' and 'false' will no longer be coerced to a true boolean with the next release.`);
}

this.isCollapsed = coerceBooleanProperty(value);
this.isCollapsed = value;

// If the value is `false` and a collapse delay is set
if (!value && this.collapseDelay) {
@@ -205,35 +195,13 @@ export class TsButtonComponent implements OnInit, OnDestroy {
* Define if the button is disabled
*/
@Input()
public set isDisabled(value: boolean) {
/* istanbul ignore if */
if (!isBoolean(value) && value && isDevMode()) {
console.warn(`TsButtonComponent: "isDisabled" value is not a boolean. ` +
`String values of 'true' and 'false' will no longer be coerced to a true boolean with the next release.`);
}
this._isDisabled = coerceBooleanProperty(value);
}
public get isDisabled(): boolean {
return this._isDisabled;
}
private _isDisabled = false;
public isDisabled = false;

/**
* Define if the progress indicator should show
*/
@Input()
public set showProgress(value: boolean) {
/* istanbul ignore if */
if (!isBoolean(value) && value && isDevMode()) {
console.warn(`TsButtonComponent: "showProgress" value is not a boolean. ` +
`String values of 'true' and 'false' will no longer be coerced to a true boolean with the next release.`);
}
this._showProgress = coerceBooleanProperty(value);
}
public get showProgress(): boolean {
return this._showProgress;
}
private _showProgress = false;
public showProgress = false;

/**
* Define the tabindex for the button
1 change: 1 addition & 0 deletions terminus-ui/card/src/card-title.directive.ts
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@ export class TsCardTitleDirective {
this.tsCardTitle = this.tsCardTitle + ' c-card__title-accent-border';
}
}

/**
* Define the component theme
*/
44 changes: 4 additions & 40 deletions terminus-ui/card/src/card.component.ts
Original file line number Diff line number Diff line change
@@ -3,12 +3,9 @@ import {
Component,
ElementRef,
Input,
isDevMode,
TemplateRef,
ViewEncapsulation,
} from '@angular/core';
import { isBoolean } from '@terminus/ngx-tools';
import { coerceBooleanProperty } from '@terminus/ngx-tools/coercion';
import { TsStyleThemeTypes } from '@terminus/ui/utilities';


@@ -120,41 +117,19 @@ export class TsCardComponent {
* Define if the card should center child content
*/
@Input()
public set centeredContent(value: boolean) {
/* istanbul ignore if */
if (!isBoolean(value) && value && isDevMode()) {
console.warn(`TsCardComponent: "centeredContent" value is not a boolean. ` +
`String values of 'true' and 'false' will no longer be coerced to a true boolean with the next release.`);
}
this._centeredContent = coerceBooleanProperty(value);
}
public get centeredContent(): boolean {
return this._centeredContent;
}
private _centeredContent = false;
public centeredContent = false;

/**
* Define if the card is disabled
*/
@Input()
public isDisabled: boolean = false;
public isDisabled = false;

/**
* Define if the card should not have a drop shadow
*/
@Input()
public set flat(value: boolean) {
/* istanbul ignore if */
if (!isBoolean(value) && value && isDevMode()) {
console.warn(`TsCardComponent: "flat" value is not a boolean. ` +
`String values of 'true' and 'false' will no longer be coerced to a true boolean with the next release.`);
}
this._flat = coerceBooleanProperty(value);
}
public get flat(): boolean {
return this._flat;
}
public _flat: boolean = false;
public flat = false;

/**
* Define an ID for the component
@@ -174,18 +149,7 @@ export class TsCardComponent {
* NOTE: This only alters style; not functionality
*/
@Input()
public set supportsInteraction(value: boolean) {
/* istanbul ignore if */
if (!isBoolean(value) && value && isDevMode()) {
console.warn(`TsCardComponent: "supportsInteraction" value is not a boolean. ` +
`String values of 'true' and 'false' will no longer be coerced to a true boolean with the next release.`);
}
this._supportsInteraction = coerceBooleanProperty(value);
}
public get supportsInteraction(): boolean {
return this._supportsInteraction;
}
private _supportsInteraction = false;
public supportsInteraction = false;

/**
* Define the card theme
49 changes: 4 additions & 45 deletions terminus-ui/checkbox/src/checkbox.component.ts
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@ import {
Component,
EventEmitter,
Input,
isDevMode,
Output,
ViewChild,
ViewEncapsulation,
@@ -13,8 +12,6 @@ import {
MatCheckbox,
MatCheckboxChange,
} from '@angular/material/checkbox';
import { isBoolean } from '@terminus/ngx-tools';
import { coerceBooleanProperty } from '@terminus/ngx-tools/coercion';
import {
ControlValueAccessorProviderFactory,
TsReactiveFormBaseComponent,
@@ -98,12 +95,7 @@ export class TsCheckboxComponent extends TsReactiveFormBaseComponent {
*/
@Input()
public set isChecked(value: boolean) {
/* istanbul ignore if */
if (!isBoolean(value) && value && isDevMode()) {
console.warn(`TsCheckboxComponent: "isChecked" value is not a boolean. ` +
`String values of 'true' and 'false' will no longer be coerced to a true boolean with the next release.`);
}
this._isChecked = coerceBooleanProperty(value);
this._isChecked = value;
this.value = this._isChecked;
this.checkbox.checked = this._isChecked;
this.changeDetectorRef.detectChanges();
@@ -117,52 +109,19 @@ export class TsCheckboxComponent extends TsReactiveFormBaseComponent {
* Define if the checkbox is disabled
*/
@Input()
public set isDisabled(value: boolean) {
/* istanbul ignore if */
if (!isBoolean(value) && value && isDevMode()) {
console.warn(`TsCheckboxComponent: "isDisabled" value is not a boolean. ` +
`String values of 'true' and 'false' will no longer be coerced to a true boolean with the next release.`);
}
this._isDisabled = coerceBooleanProperty(value);
}
public get isDisabled(): boolean {
return this._isDisabled;
}
private _isDisabled = false;
public isDisabled = false;

/**
* Define if the checkbox should be indeterminate
*/
@Input()
public set isIndeterminate(value: boolean) {
/* istanbul ignore if */
if (!isBoolean(value) && value && isDevMode()) {
console.warn(`TsCheckboxComponent: "isIndeterminate" value is not a boolean. ` +
`String values of 'true' and 'false' will no longer be coerced to a true boolean with the next release.`);
}
this._isIndeterminate = coerceBooleanProperty(value);
}
public get isIndeterminate(): boolean {
return this._isIndeterminate;
}
private _isIndeterminate = false;
public isIndeterminate = false;

/**
* Define if the checkbox is required
*/
@Input()
public set isRequired(value: boolean) {
/* istanbul ignore if */
if (!isBoolean(value) && value && isDevMode()) {
console.warn(`TsCheckboxComponent: "isRequired" value is not a boolean. ` +
`String values of 'true' and 'false' will no longer be coerced to a true boolean with the next release.`);
}
this._isRequired = coerceBooleanProperty(value);
}
public get isRequired(): boolean {
return this._isRequired;
}
private _isRequired = false;
public isRequired = false;

/**
* Toggle the underlying checkbox if the ngModel changes
29 changes: 2 additions & 27 deletions terminus-ui/copy/src/copy.component.ts
Original file line number Diff line number Diff line change
@@ -2,16 +2,13 @@ import {
Component,
ElementRef,
Input,
isDevMode,
ViewChild,
ViewEncapsulation,
} from '@angular/core';
import {
isBoolean,
TsDocumentService,
TsWindowService,
} from '@terminus/ngx-tools';
import { coerceBooleanProperty } from '@terminus/ngx-tools/coercion';
import { TsStyleThemeTypes } from '@terminus/ui/utilities';


@@ -79,35 +76,13 @@ export class TsCopyComponent {
* Define if the initial click should select the contents
*/
@Input()
public set disableInitialSelection(value: boolean) {
/* istanbul ignore if */
if (!isBoolean(value) && value && isDevMode()) {
console.warn(`TsCopyComponent: "disableInitialSelection" value is not a boolean. ` +
`String values of 'true' and 'false' will no longer be coerced to a true boolean with the next release.`);
}
this._disableInitialSelection = coerceBooleanProperty(value);
}
public get disableInitialSelection(): boolean {
return this._disableInitialSelection;
}
private _disableInitialSelection = false;
public disableInitialSelection = false;

/**
* Define if the copy to clipboard functionality is enabled
*/
@Input()
public set enableQuickCopy(value: boolean) {
/* istanbul ignore if */
if (!isBoolean(value) && value && isDevMode()) {
console.warn(`TsCopyComponent: "enableQuickCopy" value is not a boolean. ` +
`String values of 'true' and 'false' will no longer be coerced to a true boolean with the next release.`);
}
this._enableQuickCopy = coerceBooleanProperty(value);
}
public get enableQuickCopy(): boolean {
return this._enableQuickCopy;
}
private _enableQuickCopy = false;
public enableQuickCopy = false;

/**
* Define the component theme
15 changes: 1 addition & 14 deletions terminus-ui/csv-entry/src/csv-entry.component.ts
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@ import {
Component,
EventEmitter,
Input,
isDevMode,
OnDestroy,
OnInit,
Output,
@@ -18,7 +17,6 @@ import {
ValidatorFn,
} from '@angular/forms';
import {
isBoolean,
TsDocumentService,
untilComponentDestroyed,
} from '@terminus/ngx-tools';
@@ -216,18 +214,7 @@ export class TsCSVEntryComponent implements OnInit, OnDestroy {
* Allow full-width mode
*/
@Input()
public set fullWidth(value: boolean) {
/* istanbul ignore if */
if (!isBoolean(value) && value && isDevMode()) {
console.warn(`TsCSVEntryComponent: "fullWidth" value is not a boolean. ` +
`String values of 'true' and 'false' will no longer be coerced to a true boolean with the next release.`);
}
this._fullWidth = coerceBooleanProperty(value);
}
public get fullWidth(): boolean {
return this._fullWidth;
}
private _fullWidth = false;
public fullWidth = false;

/**
* Allow static headers to be set
Loading

0 comments on commit 1b38004

Please sign in to comment.