Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Commit f0c7935

Browse files
committed
chore(package): Publish Angular MDC v1.0.1
1 parent 82f9028 commit f0c7935

File tree

4 files changed

+10
-17
lines changed

4 files changed

+10
-17
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"url": "https://github.com/trimox/angular-mdc-web.git"
99
},
1010
"license": "MIT",
11-
"version": "1.0.0",
11+
"version": "1.0.1",
1212
"engines": {
1313
"node": ">= 9.11.1"
1414
},

packages/base/component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { ElementRef } from '@angular/core';
2-
import { MDCFoundation } from './foundation';
32

4-
export class MDCComponent<FoundationType extends MDCFoundation> {
3+
export class MDCComponent<FoundationType extends any> {
54
protected _elementRef: ElementRef;
65
protected _foundation: FoundationType;
76

packages/base/public-api.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
export * from './component';
2-
export * from './foundation';

packages/checkbox/checkbox.ts

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@ import {
1414
ViewChild,
1515
ViewEncapsulation
1616
} from '@angular/core';
17+
import { NG_VALUE_ACCESSOR, ControlValueAccessor } from '@angular/forms';
1718
import { fromEvent, Subject } from 'rxjs';
1819
import { takeUntil, filter } from 'rxjs/operators';
1920

20-
import { NG_VALUE_ACCESSOR, ControlValueAccessor } from '@angular/forms';
21+
import { MDCComponent } from '@angular-mdc/web/base';
2122
import { Platform, toBoolean } from '@angular-mdc/web/common';
2223
import { MdcRipple } from '@angular-mdc/web/ripple';
2324
import { MdcFormField, MdcFormFieldControl } from '@angular-mdc/web/form-field';
2425

25-
import { MDCCheckboxFoundation } from '@material/checkbox';
26+
import { MDCCheckboxFoundation, MDCCheckboxAdapter } from '@material/checkbox';
2627

2728
let nextUniqueId = 0;
2829

@@ -89,7 +90,7 @@ export const MDC_CHECKBOX_CONTROL_VALUE_ACCESSOR: any = {
8990
encapsulation: ViewEncapsulation.None,
9091
changeDetection: ChangeDetectionStrategy.OnPush
9192
})
92-
export class MdcCheckbox implements AfterViewInit, ControlValueAccessor,
93+
export class MdcCheckbox extends MDCComponent<MDCCheckboxFoundation> implements AfterViewInit, ControlValueAccessor,
9394
OnDestroy, MdcFormFieldControl<any> {
9495
/** Emits whenever the component is destroyed. */
9596
private _destroy = new Subject<void>();
@@ -184,8 +185,8 @@ export class MdcCheckbox implements AfterViewInit, ControlValueAccessor,
184185
/** View to model callback called when component has been touched */
185186
_onTouched: () => any = () => { };
186187

187-
private _createAdapter() {
188-
return {
188+
getDefaultFoundation() {
189+
const adapter: MDCCheckboxAdapter = {
189190
addClass: (className: string) => this._getHostElement().classList.add(className),
190191
removeClass: (className: string) => this._getHostElement().classList.remove(className),
191192
setNativeControlAttr: (attr: string, value: string) =>
@@ -200,23 +201,17 @@ export class MdcCheckbox implements AfterViewInit, ControlValueAccessor,
200201
forceLayout: () => this._getHostElement().offsetWidth,
201202
isAttachedToDOM: () => true
202203
};
204+
return new MDCCheckboxFoundation(adapter);
203205
}
204206

205-
private _foundation: {
206-
init(): void,
207-
destroy(): void,
208-
setDisabled(disabled: boolean): void,
209-
handleChange(): void,
210-
handleAnimationEnd(): void
211-
} = new MDCCheckboxFoundation(this._createAdapter());
212-
213207
constructor(
214208
private _platform: Platform,
215209
private _ngZone: NgZone,
216210
private _changeDetectorRef: ChangeDetectorRef,
217211
public elementRef: ElementRef<HTMLElement>,
218212
public ripple: MdcRipple,
219213
@Optional() private _parentFormField: MdcFormField) {
214+
super(elementRef);
220215

221216
if (this._parentFormField) {
222217
_parentFormField.elementRef.nativeElement.classList.add('mdc-form-field');

0 commit comments

Comments
 (0)