Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correct access-level on many APIs #437

Merged
merged 1 commit into from
May 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/components/button/button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export class MdButton {
this._updateColor(value);
}

/** @internal */
setMousedown() {
// We only *show* the focus style when focus has come to the button via the keyboard.
// The Material Design spec is silent on this topic, and without doing this, the
Expand All @@ -68,10 +69,12 @@ export class MdButton {
}
}

/** @internal */
setKeyboardFocus() {
this.isKeyboardFocused = !this.isMouseDown;
}

/** @internal */
removeKeyboardFocus() {
this.isKeyboardFocused = false;
}
Expand Down Expand Up @@ -118,6 +121,7 @@ export class MdAnchor extends MdButton {
this._disabled = (value != null && value != false) ? true : null;
}

/** @internal */
haltDisabledEvents(event: Event) {
// A disabled button shouldn't apply any actions
if (this.disabled) {
Expand Down
40 changes: 25 additions & 15 deletions src/components/grid-list/grid-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,29 @@ const MD_FIT_MODE = 'fit';
})
export class MdGridList implements OnInit, AfterContentChecked {
/** Number of columns being rendered. */
_cols: number;
private _cols: number;

/** Row height value passed in by user. This can be one of three types:
/**
* Row height value passed in by user. This can be one of three types:
* - Number value (ex: "100px"): sets a fixed row height to that value
* - Ratio value (ex: "4:3"): sets the row height based on width:height ratio
* - "Fit" mode (ex: "fit"): sets the row height to total height divided by number of rows
* */
_rowHeight: string;
*/
private _rowHeight: string;

/** The amount of space between tiles. This will be something like '5px' or '2em'. */
_gutter: string = '1px';
private _gutter: string = '1px';

/** Sets position and size styles for a tile */
_tileStyler: TileStyler;
private _tileStyler: TileStyler;

/** Query list of tiles that are being rendered. */
@ContentChildren(MdGridTile) _tiles: QueryList<MdGridTile>;
@ContentChildren(MdGridTile) private _tiles: QueryList<MdGridTile>;

constructor(private _renderer: Renderer, private _element: ElementRef,
private _dir: Dir) {}
constructor(
private _renderer: Renderer,
private _element: ElementRef,
private _dir: Dir) {}

@Input()
get cols() {
Expand All @@ -81,13 +84,17 @@ export class MdGridList implements OnInit, AfterContentChecked {
this._setTileStyler();
}

/** @internal */
ngOnInit() {
this._checkCols();
this._checkRowHeight();
}

/** The layout calculation is fairly cheap if nothing changes, so there's little cost
* to run it frequently. */
/**
* The layout calculation is fairly cheap if nothing changes, so there's little cost
* to run it frequently.
* @internal
*/
ngAfterContentChecked() {
this._layoutTiles();
}
Expand Down Expand Up @@ -131,8 +138,9 @@ export class MdGridList implements OnInit, AfterContentChecked {
this.setListStyle(this._tileStyler.getComputedHeight());
}

/** Sets style on the main grid-list element, given the style name and value.
* @internal
/**
* Sets style on the main grid-list element, given the style name and value.
* @internal
*/
setListStyle(style: [string, string]): void {
if (style) {
Expand All @@ -141,14 +149,16 @@ export class MdGridList implements OnInit, AfterContentChecked {
}
}

/** Converts values into strings. Falsy values become empty strings.
/**
* Converts values into strings. Falsy values become empty strings.
* @internal
*/
export function coerceToString(value: string | number): string {
return `${value || ''}`;
}

/** Converts a value that might be a string into a number.
/**
* Converts a value that might be a string into a number.
* @internal
*/
export function coerceToNumber(value: string | number): number {
Expand Down
6 changes: 4 additions & 2 deletions src/components/icon/icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ export class MdIcon implements OnChanges, OnInit, AfterViewChecked {
constructor(
private _element: ElementRef,
private _renderer: Renderer,
private _mdIconRegistry: MdIconRegistry) {
}
private _mdIconRegistry: MdIconRegistry) { }

/**
* Splits an svgIcon binding value into its icon set and icon name components.
Expand Down Expand Up @@ -112,6 +111,7 @@ export class MdIcon implements OnChanges, OnInit, AfterViewChecked {
}
}

/** @internal */
ngOnChanges(changes: { [propertyName: string]: SimpleChange }) {
const changedInputs = Object.keys(changes);
// Only update the inline SVG icon if the inputs changed, to avoid unnecessary DOM operations.
Expand All @@ -133,6 +133,7 @@ export class MdIcon implements OnChanges, OnInit, AfterViewChecked {
this._updateAriaLabel();
}

/** @internal */
ngOnInit() {
// Update font classes because ngOnChanges won't be called if none of the inputs are present,
// e.g. <md-icon>arrow</md-icon>. In this case we need to add a CSS class for the default font.
Expand All @@ -141,6 +142,7 @@ export class MdIcon implements OnChanges, OnInit, AfterViewChecked {
}
}

/** @internal */
ngAfterViewChecked() {
// Update aria label here because it may depend on the projected text content.
// (e.g. <md-icon>home</md-icon> should use 'home').
Expand Down
15 changes: 7 additions & 8 deletions src/components/input/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ import {MdError} from '../../core/errors/error';

const noop = () => {};

const MD_INPUT_CONTROL_VALUE_ACCESSOR = new Provider(
NG_VALUE_ACCESSOR, {
useExisting: forwardRef(() => MdInput),
multi: true
});
const MD_INPUT_CONTROL_VALUE_ACCESSOR = new Provider(NG_VALUE_ACCESSOR, {
useExisting: forwardRef(() => MdInput),
multi: true
});

// Invalid input type. Using one of these will throw an MdInputUnsupportedTypeError.
const MD_INPUT_INVALID_INPUT_TYPE = [
Expand Down Expand Up @@ -71,9 +70,7 @@ export class MdInputDuplicatedHintError extends MdError {
export class MdPlaceholder {}


/**
* The hint directive, used to tag content as hint labels (going under the input).
*/
/** The hint directive, used to tag content as hint labels (going under the input). */
@Directive({
selector: 'md-hint',
host: {
Expand Down Expand Up @@ -202,6 +199,7 @@ export class MdInput implements ControlValueAccessor, AfterContentInit, OnChange
this._onTouchedCallback = fn;
}

/** @internal */
ngAfterContentInit() {
this._validateConstraints();

Expand All @@ -211,6 +209,7 @@ export class MdInput implements ControlValueAccessor, AfterContentInit, OnChange
});
}

/** @internal */
ngOnChanges(changes: {[key: string]: SimpleChange}) {
this._validateConstraints();
}
Expand Down
9 changes: 5 additions & 4 deletions src/components/list/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export class MdListAvatar {}
export class MdListItem implements AfterContentInit {
@ContentChildren(MdLine) _lines: QueryList<MdLine>;

/** @internal */
ngAfterContentInit() {
this._setLineClass(this._lines.length);

Expand All @@ -47,25 +48,25 @@ export class MdListItem implements AfterContentInit {
}

@ContentChild(MdListAvatar)
set _hasAvatar(avatar: MdListAvatar) {
private set _hasAvatar(avatar: MdListAvatar) {
this._setClass('md-list-avatar', avatar != null);
}

constructor(private _renderer: Renderer, private _element: ElementRef) {}

_setLineClass(count: number): void {
private _setLineClass(count: number): void {
this._resetClasses();
if (count === 2 || count === 3) {
this._setClass(`md-${count}-line`, true);
}
}

_resetClasses(): void {
private _resetClasses(): void {
this._setClass('md-2-line', false);
this._setClass('md-3-line', false);
}

_setClass(className: string, bool: boolean): void {
private _setClass(className: string, bool: boolean): void {
this._renderer.setElementClass(this._element.nativeElement, className, bool);
}
}
Expand Down
40 changes: 17 additions & 23 deletions src/components/progress-bar/progress-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,37 +25,31 @@ import {
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class MdProgressBar {
/**
* Value of the progressbar.
*
* Defaults to zero. Mirrored to aria-valuenow.
*/
/** Value of the progressbar. Defaults to zero. Mirrored to aria-valuenow. */
private _value: number = 0;

@Input()
@HostBinding('attr.aria-valuenow')
get value() {
return this._value;
}

set value(v: number) {
this._value = MdProgressBar.clamp(v || 0);
this._value = clamp(v || 0);
}


/**
* Buffer value of the progress bar.
*
* Defaults to zero.
*/
/** Buffer value of the progress bar. Defaults to zero. */
private _bufferValue: number = 0;

@Input()
get bufferValue() {
return this._bufferValue;
}

set bufferValue(v: number) {
this._bufferValue = MdProgressBar.clamp(v || 0);
this._bufferValue = clamp(v || 0);
}


/**
* Mode of the progress bar.
*
Expand All @@ -67,29 +61,29 @@ export class MdProgressBar {
@HostBinding('attr.mode')
mode: 'determinate' | 'indeterminate' | 'buffer' | 'query' = 'determinate';



/** Gets the current transform value for the progress bar's primary indicator. */
/**
* Gets the current transform value for the progress bar's primary indicator.
* @internal
*/
primaryTransform() {
let scale = this.value / 100;
return `scaleX(${scale})`;
}


/**
* Gets the current transform value for the progress bar's buffer indicator. Only used if the
* progress mode is set to buffer, otherwise returns an undefined, causing no transformation.
* @internal
*/
bufferTransform() {
if (this.mode == 'buffer') {
let scale = this.bufferValue / 100;
return `scaleX(${scale})`;
}
}
}


/** Clamps a value to be between two numbers, by default 0 and 100. */
static clamp(v: number, min = 0, max = 100) {
return Math.max(min, Math.min(max, v));
}
/** Clamps a value to be between two numbers, by default 0 and 100. */
function clamp(v: number, min = 0, max = 100) {
return Math.max(min, Math.min(max, v));
}
Loading