Skip to content

Commit 84ce4f5

Browse files
committed
feat: upgrade to material-components-web 0.35.1
BREAKING CHANGE: * upgrade to material-components-web 0.35.1 * MdcSelectLabelDirective is removed. Use MdcFloatingLabel instead. (following upstream changes in material-components-web 0.35.0) * mdcSelectLabel is removed. Use mdcFlatingLabel instead. (following upstream changes in material-components-web 0.35.0) * mdcButton property `stroked` is renamed to `outlined`. (following upstream changes in material-components-web 0.35.0)
1 parent 3ef78c1 commit 84ce4f5

20 files changed

+592
-613
lines changed

bundle/package-lock.json

+256-246
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundle/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"build": "npm run clean && npm run build-noclean"
2727
},
2828
"dependencies": {
29-
"material-components-web": "^0.34.1"
29+
"material-components-web": "^0.35.1"
3030
},
3131
"peerDependencies": {
3232
"@angular/common": ">=5.0.0",

bundle/src/components/button/mdc.button.directive.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class MdcButtonDirective extends AbstractMdcRipple implements AfterConten
2020
@HostBinding('class.mdc-button') _cls = true;
2121
private _dense = false;
2222
private _raised = false;
23-
private _stroked = false;
23+
private _outlined = false;
2424

2525
constructor(public _elm: ElementRef, renderer: Renderer2, registry: MdcEventRegistry) {
2626
super(_elm, renderer, registry);
@@ -51,13 +51,13 @@ export class MdcButtonDirective extends AbstractMdcRipple implements AfterConten
5151
* When this input is defined and does not have value false, the button will be styled
5252
* flush with the surface and have a visible border.
5353
*/
54-
@HostBinding('class.mdc-button--stroked') @Input()
55-
get stroked() {
56-
return this._stroked;
54+
@HostBinding('class.mdc-button--outlined') @Input()
55+
get outlined() {
56+
return this._outlined;
5757
}
5858

59-
set stroked(val: any) {
60-
this._stroked = asBoolean(val);
59+
set outlined(val: any) {
60+
this._outlined = asBoolean(val);
6161
}
6262

6363
/**

bundle/src/components/card/mdc.card.directive.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ export class MdcCardDirective {
190190
* When this input is set to a value other than false, the card will have a
191191
* hairline stroke instead of a shadow.
192192
*/
193-
@HostBinding('class.mdc-card--stroked') @Input()
193+
@HostBinding('class.mdc-card--outlined') @Input()
194194
get outlined() {
195195
return this._outlined;
196196
}

bundle/src/components/select/mdc.select.adapter.ts

-12
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,3 @@ export interface MdcSelectAdapter {
1313
getValue: () => string,
1414
setValue: (value: string) => void
1515
}
16-
17-
/** @docs-private */
18-
export interface MdcSelectLabelAdapter {
19-
addClass: (className: string) => void,
20-
removeClass: (className: string) => void
21-
}
22-
23-
/** @docs-private */
24-
export interface MdcSelectBottomLineAdapter {
25-
addClass: (className: string) => void,
26-
removeClass: (className: string) => void
27-
}

bundle/src/components/select/mdc.select.directive.ts

+34-60
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@ import { AfterContentInit, ContentChild, Directive, ElementRef, forwardRef, Host
22
Input, OnDestroy, OnInit, Optional, Renderer2, Self } from '@angular/core';
33
import { NgControl } from '@angular/forms';
44
import { MDCSelectFoundation } from '@material/select';
5-
import { MDCSelectLabelFoundation } from '@material/select/label';
6-
import { MDCSelectBottomLineFoundation } from '@material/select/bottom-line';
7-
import { MdcSelectAdapter, MdcSelectLabelAdapter, MdcSelectBottomLineAdapter } from './mdc.select.adapter';
5+
import { MDCFloatingLabelFoundation } from '@material/floating-label';
6+
import { MDCLineRippleFoundation } from '@material/line-ripple';
7+
import { MdcSelectAdapter } from './mdc.select.adapter';
8+
import { MdcFloatingLabelDirective } from '../floating-label/mdc.floating-label.directive';
9+
import { MdcLineRippleAdapter } from '../line-ripple/mdc.line-ripple.adapter';
810
import { AbstractMdcInput } from '../abstract/abstract.mdc.input';
911
import { asBoolean } from '../../utils/value.utils';
1012
import { MdcEventRegistry } from '../../utils/mdc.event.registry';
1113

1214
const CLASS_SELECT = 'mdc-select';
1315
const CLASS_SELECT_CONTROL = 'mdc-select__native-control';
14-
const CLASS_SELECT_LABEL = 'mdc-select__label';
15-
const CLASS_SELECT_LINE = 'mdc-select__bottom-line';
16+
const CLASS_LINE_RIPPLE = 'mdc-line-ripple';
1617

1718
let nextId = 1;
1819

@@ -52,8 +53,8 @@ export class MdcSelectControlDirective extends AbstractMdcInput implements OnIni
5253

5354
/**
5455
* Mirrors the <code>id</code> attribute. If no id is assigned, this directive will
55-
* assign a unique id by itself. If an <code>mdcSelectLabel</code> for this text-field
56-
* is available, the <code>mdcSelectLabel</code> will automatically set its <code>for</code>
56+
* assign a unique id by itself. If an <code>mdcFloatingLabel</code> for this select control
57+
* is available, the <code>mdcFloatingLabel</code> will automatically set its <code>for</code>
5758
* attribute to this <code>id</code> value.
5859
*/
5960
@HostBinding()
@@ -83,70 +84,43 @@ export class MdcSelectControlDirective extends AbstractMdcInput implements OnIni
8384
}
8485
}
8586

86-
/**
87-
* Directive for the label of an <code>mdcSelect</code> selection control.
88-
* Should be used as a child element of the <code>mdcSelect</code>,
89-
* immediately after the <code>mdcSelectControl</code>.
90-
*/
91-
@Directive({
92-
selector: '[mdcSelectLabel]'
93-
})
94-
export class MdcSelectLabelDirective implements AfterContentInit {
95-
@HostBinding('class.' + CLASS_SELECT_LABEL) _cls = true;
96-
_initialized = false;
97-
_adapter: MdcSelectLabelAdapter = {
98-
addClass: (className: string) => {this._rndr.addClass(this._elm.nativeElement, className); },
99-
removeClass: (className: string) => {this._rndr.removeClass(this._elm.nativeElement, className); }
100-
};
101-
_foundation: {
102-
init(),
103-
destroy(),
104-
styleFloat(value: boolean)
105-
} = <any>new MDCSelectLabelFoundation(this._adapter);
106-
107-
constructor(public _elm: ElementRef, private _rndr: Renderer2) {
108-
}
109-
110-
ngAfterContentInit() {
111-
this._foundation.init();
112-
this._initialized = true;
113-
}
114-
115-
ngOnDestroy() {
116-
this._foundation.destroy();
117-
this._initialized = false;
118-
}
119-
}
120-
12187
/**
12288
* Directive for a spec aligned material design 'Select Control'.
12389
* This directive should wrap an <code>mdcSelectControl</code>, and an
124-
* <code>mdcSelectLabel</code> directive.
90+
* <code>mdcFloatingLabel</code> directive.
12591
*/
12692
@Directive({
12793
selector: '[mdcSelect]'
12894
})
12995
export class MdcSelectDirective implements AfterContentInit, OnDestroy {
13096
@HostBinding('class.' + CLASS_SELECT) _cls = true;
13197
@ContentChild(MdcSelectControlDirective) _control: MdcSelectControlDirective;
132-
@ContentChild(MdcSelectLabelDirective) _label: MdcSelectLabelDirective;
98+
@ContentChild(MdcFloatingLabelDirective) _label: MdcFloatingLabelDirective;
13399
private _initialized = false;
134100
private _bottomLineElm: HTMLElement = null;
135-
private _bottomLineAdapter: MdcSelectBottomLineAdapter;
136-
private _bottomLineFoundation: {
137-
init(),
138-
destroy(),
139-
activate(),
140-
deactivate()
141-
} = <any>new MDCSelectBottomLineFoundation(this._bottomLineAdapter);
101+
private _lineRippleAdapter: MdcLineRippleAdapter = {
102+
addClass: (className: string) => this._rndr.addClass(this._bottomLineElm, className),
103+
removeClass: (className: string) => this._rndr.removeClass(this._bottomLineElm, className),
104+
hasClass: (className) => this._bottomLineElm.classList.contains(className),
105+
setStyle: (name: string, value: string) => this._rndr.setStyle(this._bottomLineElm, name, value),
106+
registerEventHandler: (evtType: string, handler: EventListener) => this._registry.listenElm(this._rndr, evtType, handler, this._bottomLineElm),
107+
deregisterEventHandler: (evtType: string, handler: EventListener) => this._registry.unlisten(evtType, handler)
108+
};
109+
private _lineRippleFoundation: {
110+
init: Function,
111+
destroy: Function,
112+
activate: Function,
113+
deactivate: Function,
114+
setRippleCenter: (x: number) => void
115+
} = new MDCLineRippleFoundation(this._lineRippleAdapter);
142116
private adapter: MdcSelectAdapter = {
143117
addClass: (className: string) => {this._rndr.addClass(this._elm.nativeElement, className); },
144118
removeClass: (className: string) => {this._rndr.removeClass(this._elm.nativeElement, className); },
145119
floatLabel: (value: boolean) => {
146-
if (this._label) this._label._foundation.styleFloat(value);
120+
if (this._label) this._label._foundation.float(value);
147121
},
148-
activateBottomLine: () => this._bottomLineFoundation.activate(),
149-
deactivateBottomLine: () => this._bottomLineFoundation.deactivate(),
122+
activateBottomLine: () => this._lineRippleFoundation.activate(),
123+
deactivateBottomLine: () => this._lineRippleFoundation.deactivate(),
150124
setDisabled: (disabled: boolean) => this._control._elm.nativeElement.disabled = disabled,
151125
registerInteractionHandler: (type, handler) => this._control._registry.listen(this._rndr, type, handler, this._control._elm),
152126
deregisterInteractionHandler: (type, handler) => this._control._registry.unlisten(type, handler),
@@ -163,19 +137,19 @@ export class MdcSelectDirective implements AfterContentInit, OnDestroy {
163137
setSelectedIndex(index: number)
164138
} = new MDCSelectFoundation(this.adapter);
165139

166-
constructor(private _elm: ElementRef, private _rndr: Renderer2) {
140+
constructor(private _elm: ElementRef, private _rndr: Renderer2, private _registry: MdcEventRegistry) {
167141
}
168142

169143
ngAfterContentInit() {
170144
if (!this._control || !this._label)
171-
throw new Error('mdcSelect requires an embedded mdcSelectControl and mdcSelectLabel');
145+
throw new Error('mdcSelect requires an embedded mdcSelectControl and mdcFloatingLabel');
172146
if (!this._label._initialized)
173-
throw new Error('mdcSelectLabel not properly initialized');
147+
throw new Error('mdcFloatingLabel not properly initialized');
174148
// add bottom line:
175149
this._bottomLineElm = this._rndr.createElement('div');
176-
this._rndr.addClass(this._bottomLineElm, CLASS_SELECT_LINE);
150+
this._rndr.addClass(this._bottomLineElm, CLASS_LINE_RIPPLE);
177151
this._rndr.appendChild(this._elm.nativeElement, this._bottomLineElm);
178-
this._bottomLineFoundation.init();
152+
this._lineRippleFoundation.init();
179153
this.foundation.init();
180154
this._initialized = true;
181155

@@ -184,7 +158,7 @@ export class MdcSelectDirective implements AfterContentInit, OnDestroy {
184158
}
185159

186160
ngOnDestroy() {
187-
this._bottomLineFoundation.destroy();
161+
this._lineRippleFoundation.destroy();
188162
this.foundation.destroy();
189163
this._control._onChange = (value) => {};
190164
}

bundle/src/components/text-field/mdc.text-field.adapter.ts

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export interface MdcTextFieldHelperTextAdapter {
1313
/** @docs-private */
1414
export interface MdcTextFieldIconAdapter {
1515
setAttr: (name: string, value: string) => void,
16+
removeAttr: (name: string) => void,
1617
registerInteractionHandler: (evtType: string, handler: EventListener) => void,
1718
deregisterInteractionHandler: (evtType: string, handler: EventListener) => void,
1819
notifyIconAction: () => void

bundle/src/components/text-field/mdc.text-field.directive.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,8 @@ export class MdcTextFieldInputDirective extends AbstractMdcInput implements OnIn
159159
export class MdcTextFieldIconDirective {
160160
@HostBinding('class.mdc-text-field__icon') _cls = true;
161161
_mdcAdapter: MdcTextFieldIconAdapter = {
162-
setAttr: (name: string, value: string) => {
163-
this._rndr.setAttribute(this._el.nativeElement, name, value);
164-
},
162+
setAttr: (name: string, value: string) => this._rndr.setAttribute(this._el.nativeElement, name, value),
163+
removeAttr: (name: string) => this._rndr.removeAttribute(this._el.nativeElement, name),
165164
registerInteractionHandler: (evtType: string, handler: EventListener) => {
166165
this._reg.listen(this._rndr, evtType, handler, this._el);
167166
},

bundle/src/material.module.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import { MdcMenuAnchorDirective, MdcMenuDirective } from './components/menu/mdc.
4141
import { MdcRadioDirective,
4242
MdcRadioInputDirective } from './components/radio/mdc.radio.directive';
4343
import { MdcRippleDirective } from './components/ripple/mdc.ripple.directive';
44-
import { MdcSelectDirective, MdcSelectControlDirective, MdcSelectLabelDirective } from './components/select/mdc.select.directive';
44+
import { MdcSelectDirective, MdcSelectControlDirective } from './components/select/mdc.select.directive';
4545
import { MdcSliderDirective,
4646
MdcFormsSliderDirective } from './components/slider/mdc.slider.directive';
4747
import { MdcSnackbarService, MDC_SNACKBAR_PROVIDER } from './components/snackbar/mdc.snackbar.service';
@@ -113,7 +113,7 @@ export { MdcMenuAnchorDirective, MdcMenuDirective } from './components/menu/mdc.
113113
export { MdcRadioDirective,
114114
MdcRadioInputDirective } from './components/radio/mdc.radio.directive';
115115
export { MdcRippleDirective } from './components/ripple/mdc.ripple.directive';
116-
export { MdcSelectDirective, MdcSelectControlDirective, MdcSelectLabelDirective } from './components/select/mdc.select.directive';
116+
export { MdcSelectDirective, MdcSelectControlDirective } from './components/select/mdc.select.directive';
117117
export { MdcSliderDirective,
118118
MdcFormsSliderDirective } from './components/slider/mdc.slider.directive';
119119
export { MdcSnackbarMessage } from './components/snackbar/mdc.snackbar.message';
@@ -171,7 +171,7 @@ export { MdcEventRegistry } from './utils/mdc.event.registry';
171171
MdcMenuAnchorDirective, MdcMenuDirective,
172172
MdcRadioDirective, MdcRadioInputDirective,
173173
MdcRippleDirective,
174-
MdcSelectDirective, MdcSelectControlDirective, MdcSelectLabelDirective,
174+
MdcSelectDirective, MdcSelectControlDirective,
175175
MdcSliderDirective, MdcFormsSliderDirective,
176176
MdcSwitchInputDirective, MdcSwitchDirective,
177177
MdcTabDirective, MdcTabIconDirective, MdcTabIconTextDirective,
@@ -200,7 +200,7 @@ export { MdcEventRegistry } from './utils/mdc.event.registry';
200200
MdcMenuAnchorDirective, MdcMenuDirective,
201201
MdcRadioDirective, MdcRadioInputDirective,
202202
MdcRippleDirective,
203-
MdcSelectDirective, MdcSelectControlDirective, MdcSelectLabelDirective,
203+
MdcSelectDirective, MdcSelectControlDirective,
204204
MdcSliderDirective, MdcFormsSliderDirective,
205205
MdcSwitchInputDirective, MdcSwitchDirective,
206206
MdcTabDirective, MdcTabIconDirective, MdcTabIconTextDirective,

bundle/tools/ngbundler/index.ts

-3
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,12 @@ const globals = {
2121
'@material/radio': 'mdc.radio',
2222
'@material/ripple': 'mdc.ripple',
2323
'@material/select': 'mdc.select',
24-
'@material/select/label': 'mdc.select',
25-
'@material/select/bottom-line': 'mdc.select',
2624
'@material/slider': 'mdc.slider',
2725
'@material/switch': 'mdc.switch',
2826
'@material/snackbar': 'mdc.snackbar',
2927
'@material/textfield': 'mdc.textfield', // checked, not exported as mdc.textField yet
3028
'@material/textfield/helper-text': 'mdc.textfield',
3129
'@material/textfield/icon': 'mdc.textfield',
32-
'@material/textfield/label': 'mdc.textfield',
3330
'@material/toolbar': 'mdc.toolbar',
3431
'@material/tabs': 'mdc.tabs',
3532
'rxjs/Observable': 'Rx',

0 commit comments

Comments
 (0)