Skip to content

Commit db73530

Browse files
committed
feat: upgrade to material-components-web 0.25.0
BREAKING CHANGE: Upgrade to material-components-web 0.25.0 and rename mdcTextfield to mdcTextField and mdcFormfield to mdcFormField. (Following upstream change of changing textfield to text-field).
1 parent bc2c63a commit db73530

File tree

49 files changed

+681
-665
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+681
-665
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ slider | [See demo](https://blox.src.zone/material#/directives
3434
snackbar | [See demo](https://blox.src.zone/material#/directives/snackbar) |
3535
switch | [See demo](https://blox.src.zone/material#/directives/switch) |
3636
tabs | [See demo](https://blox.src.zone/material#/directives/tab) |
37-
textfield | [See demo](https://blox.src.zone/material#/directives/textfield) |
37+
text-field | [See demo](https://blox.src.zone/material#/directives/text-field) |
3838
toolbar | [See demo](https://blox.src.zone/material#/directives/toolbar) |
3939

4040
Note: the `@material` packages `layout-grid`, `theme`, and `typography` are supposed to be used by

bundle/package-lock.json

Lines changed: 178 additions & 170 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundle/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"build": "npm run clean && npm run ngc && npm run bundle && npm run copy-types && npm run copy-metadata && npm run apidocs && npm run link2site"
2727
},
2828
"dependencies": {
29-
"material-components-web": "^0.24.0"
29+
"material-components-web": "^0.25.0"
3030
},
3131
"peerDependencies": {
3232
"@angular/common": ">=4.0.0",

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ export class MdcCheckboxInputDirective extends AbstractMdcInput {
5454
* Future implementations will also support supplying (customized) background
5555
* elements.
5656
* </p><p>
57-
* This directive can be used together with an <code>mdcFormfield</code> to
57+
* This directive can be used together with an <code>mdcFormField</code> to
5858
* easily position checkboxes and their labels, see
59-
* <a href="#/directives/formfield">mdcFormfield</a>.
59+
* <a href="#/directives/form-field">mdcFormField</a>.
6060
*/
6161
@Directive({
6262
selector: '[mdcCheckbox]'

bundle/src/components/formfield/mdc.formfield.adapter.ts renamed to bundle/src/components/form-field/mdc.form-field.adapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** @docs-private */
2-
export interface MdcFormfieldAdapter {
2+
export interface MdcFormFieldAdapter {
33
registerInteractionHandler: (type: string, handler: EventListener) => void;
44
deregisterInteractionHandler: (type: string, handler: EventListener) => void;
55
activateInputRipple: () => void;

bundle/src/components/formfield/mdc.formfield.directive.ts renamed to bundle/src/components/form-field/mdc.form-field.directive.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { AfterContentInit, ContentChild, ContentChildren, forwardRef, Directive,
22
Input, OnDestroy, Optional, Renderer2, Self } from '@angular/core';
33
import { NgControl } from '@angular/forms';
44
import { MDCFormFieldFoundation } from '@material/form-field';
5-
import { MdcFormfieldAdapter } from './mdc.formfield.adapter';
5+
import { MdcFormFieldAdapter } from './mdc.form-field.adapter';
66
import { AbstractMdcRipple } from '../ripple/abstract.mdc.ripple';
77
import { AbstractMdcInput } from '../abstract/abstract.mdc.input';
88
import { AbstractMdcLabel } from '../abstract/abstract.mdc.label';
@@ -12,10 +12,10 @@ import { MdcEventRegistry } from '../../utils/mdc.event.registry';
1212
let nextId = 1;
1313

1414
@Directive({
15-
selector: 'input[mdcFormfieldInput], textarea[mdcFormfieldInput]',
16-
providers: [{provide: AbstractMdcInput, useExisting: forwardRef(() => MdcFormfieldInputDirective) }]
15+
selector: 'input[mdcFormFieldInput], textarea[mdcFormFieldInput]',
16+
providers: [{provide: AbstractMdcInput, useExisting: forwardRef(() => MdcFormFieldInputDirective) }]
1717
})
18-
export class MdcFormfieldInputDirective extends AbstractMdcInput {
18+
export class MdcFormFieldInputDirective extends AbstractMdcInput {
1919
private _id: string;
2020
private _disabled = false;
2121

@@ -43,10 +43,10 @@ export class MdcFormfieldInputDirective extends AbstractMdcInput {
4343
}
4444

4545
@Directive({
46-
selector: 'label[mdcFormfieldLabel]',
47-
providers: [{provide: AbstractMdcLabel, useExisting: forwardRef(() => MdcFormfieldLabelDirective) }]
46+
selector: 'label[mdcFormFieldLabel]',
47+
providers: [{provide: AbstractMdcLabel, useExisting: forwardRef(() => MdcFormFieldLabelDirective) }]
4848
})
49-
export class MdcFormfieldLabelDirective extends AbstractMdcLabel {
49+
export class MdcFormFieldLabelDirective extends AbstractMdcLabel {
5050
@HostBinding() @Input() for: string;
5151

5252
constructor(public _elm: ElementRef) {
@@ -55,16 +55,16 @@ export class MdcFormfieldLabelDirective extends AbstractMdcLabel {
5555
}
5656

5757
@Directive({
58-
selector: '[mdcFormfield]'
58+
selector: '[mdcFormField]'
5959
})
60-
export class MdcFormfieldDirective implements AfterContentInit, OnDestroy {
60+
export class MdcFormFieldDirective implements AfterContentInit, OnDestroy {
6161
@HostBinding('class.mdc-form-field') _cls = true;
6262
private _alignEnd = false;
6363
@ContentChild(AbstractMdcRipple) rippleChild: AbstractMdcRipple;
6464
@ContentChild(AbstractMdcInput) mdcInput: AbstractMdcInput;
6565
@ContentChild(AbstractMdcLabel) mdcLabel: AbstractMdcLabel;
6666

67-
private mdcAdapter: MdcFormfieldAdapter = {
67+
private mdcAdapter: MdcFormFieldAdapter = {
6868
registerInteractionHandler: (type: string, handler: EventListener) => {
6969
this.registry.listen(this.renderer, type, handler, this.root);
7070
},

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ export class MdcRadioInputDirective extends AbstractMdcInput {
5454
* Future implementations will also support supplying (customized) background
5555
* elements.
5656
* </p><p>
57-
* This directive can be used together with an <code>mdcFormfield</code> to
57+
* This directive can be used together with an <code>mdcFormField</code> to
5858
* easily position radio buttons and their labels, see
59-
* <a href="#/directives/formfield">mdcFormfield</a>.
59+
* <a href="#/directives/form-field">mdcFormField</a>.
6060
*/
6161
@Directive({
6262
selector: '[mdcRadio]'

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ export class MdcSwitchInputDirective extends AbstractMdcInput {
5050
* Future implementations will also support supplying (customized) background
5151
* elements.
5252
* </p><p>
53-
* This directive can be used together with an <code>mdcFormfield</code> to
53+
* This directive can be used together with an <code>mdcFormField</code> to
5454
* easily position switches and their labels, see
55-
* <a href="#/directives/formfield">mdcFormfield</a>.
55+
* <a href="#/directives/form-field">mdcFormField</a>.
5656
*/
5757
@Directive({
5858
selector: '[mdcSwitch]'

bundle/src/components/textfield/mdc.textfield.adapter.ts renamed to bundle/src/components/text-field/mdc.text-field.adapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** @docs-private */
2-
export interface MdcTextfieldAdapter {
2+
export interface MdcTextFieldAdapter {
33
addClass: (className: string) => void;
44
removeClass: (className: string) => void;
55
addClassToLabel: (className: string) => void;

bundle/src/components/textfield/mdc.textfield.directive.ts renamed to bundle/src/components/text-field/mdc.text-field.directive.ts

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,31 @@ import { AfterContentInit, AfterViewInit, Component, ContentChild, ContentChildr
33
ViewEncapsulation } from '@angular/core';
44
import { NgControl } from '@angular/forms';
55
import { MDCRipple } from '@material/ripple';
6-
import { MDCTextfieldFoundation } from '@material/textfield';
7-
import { MdcTextfieldAdapter } from './mdc.textfield.adapter';
6+
import { MDCTextFieldFoundation } from '@material/textfield';
7+
import { MdcTextFieldAdapter } from './mdc.text-field.adapter';
88
import { AbstractMdcInput } from '../abstract/abstract.mdc.input';
99
import { AbstractMdcLabel } from '../abstract/abstract.mdc.label';
1010
import { asBoolean } from '../../utils/value.utils';
1111
import { AbstractMdcRipple } from '../ripple/abstract.mdc.ripple';
1212
import { MdcEventRegistry } from '../../utils/mdc.event.registry';
1313

14-
const CLASS_BOTTOM_LINE = 'mdc-textfield__bottom-line';
14+
const CLASS_BOTTOM_LINE = 'mdc-text-field__bottom-line';
1515

1616
let nextId = 1;
1717

1818
@Directive({
19-
selector: 'input[mdcTextfieldInput], textarea[mdcTextfieldInput]',
20-
providers: [{provide: AbstractMdcInput, useExisting: forwardRef(() => MdcTextfieldInputDirective) }]
19+
selector: 'input[mdcTextFieldInput], textarea[mdcTextFieldInput]',
20+
providers: [{provide: AbstractMdcInput, useExisting: forwardRef(() => MdcTextFieldInputDirective) }]
2121
})
22-
export class MdcTextfieldInputDirective extends AbstractMdcInput implements OnInit {
22+
export class MdcTextFieldInputDirective extends AbstractMdcInput implements OnInit {
2323
_onChange = (value) => {};
2424
private _id: string;
2525
private _type = 'text';
2626
private _disabled = false;
2727
private _required = false;
2828
private cachedId: string;
2929
_focused = false;
30-
@HostBinding('class.mdc-textfield__input') _hostClass = true;
30+
@HostBinding('class.mdc-text-field__input') _hostClass = true;
3131

3232
constructor(public _elm: ElementRef, private renderer: Renderer2, @Optional() @Self() public _cntr: NgControl) {
3333
super();
@@ -136,37 +136,37 @@ export class MdcTextfieldInputDirective extends AbstractMdcInput implements OnIn
136136
}
137137

138138
@Directive({
139-
selector: '[mdcTextfieldIcon]'
139+
selector: '[mdcTextFieldIcon]'
140140
})
141-
export class MdcTextfieldIconDirective {
142-
@HostBinding('class.mdc-textfield__icon') _cls = true;
141+
export class MdcTextFieldIconDirective {
142+
@HostBinding('class.mdc-text-field__icon') _cls = true;
143143

144144
constructor(public _el: ElementRef) {
145145
}
146146
}
147147

148148
@Directive({
149-
selector: 'label[mdcTextfieldLabel]',
150-
providers: [{provide: AbstractMdcLabel, useExisting: forwardRef(() => MdcTextfieldLabelDirective) }]
149+
selector: 'label[mdcTextFieldLabel]',
150+
providers: [{provide: AbstractMdcLabel, useExisting: forwardRef(() => MdcTextFieldLabelDirective) }]
151151
})
152-
export class MdcTextfieldLabelDirective extends AbstractMdcLabel {
152+
export class MdcTextFieldLabelDirective extends AbstractMdcLabel {
153153
/** @docs-private */
154154
@HostBinding() for: string;
155-
@HostBinding('class.mdc-textfield__label') _cls = true;
155+
@HostBinding('class.mdc-text-field__label') _cls = true;
156156

157157
constructor(public _elm: ElementRef) {
158158
super();
159159
}
160160
}
161161

162162
@Directive({
163-
selector: '[mdcTextfieldHelptext]',
163+
selector: '[mdcTextFieldHelptext]',
164164
exportAs: 'mdcHelptext'
165165
})
166-
export class MdcTextfieldHelptextDirective {
167-
@HostBinding('class.mdc-textfield-helptext') _cls = true;
168-
@HostBinding('class.mdc-textfield-helptext--validation-msg') _isValidation = false;
169-
@HostBinding('class.mdc-textfield-helptext--persistent') _isPersistent = false;
166+
export class MdcTextFieldHelptextDirective {
167+
@HostBinding('class.mdc-text-field-helptext') _cls = true;
168+
@HostBinding('class.mdc-text-field-helptext--validation-msg') _isValidation = false;
169+
@HostBinding('class.mdc-text-field-helptext--persistent') _isPersistent = false;
170170
@Input() forceShow = false; // TODO boolean coercion
171171

172172
constructor(public _elm: ElementRef) {
@@ -182,22 +182,22 @@ export class MdcTextfieldHelptextDirective {
182182
}
183183

184184
@Directive({
185-
selector: '[mdcTextfield]',
186-
providers: [{provide: AbstractMdcRipple, useExisting: forwardRef(() => MdcTextfieldDirective) }]
185+
selector: '[mdcTextField]',
186+
providers: [{provide: AbstractMdcRipple, useExisting: forwardRef(() => MdcTextFieldDirective) }]
187187
})
188-
export class MdcTextfieldDirective extends AbstractMdcRipple implements AfterContentInit, OnDestroy {
189-
@HostBinding('class.mdc-textfield') _cls = true;
190-
@ContentChild(MdcTextfieldIconDirective) _icon: MdcTextfieldIconDirective;
191-
@ContentChild(MdcTextfieldInputDirective) _input: MdcTextfieldInputDirective;
192-
@ContentChild(MdcTextfieldLabelDirective) _label: MdcTextfieldLabelDirective;
188+
export class MdcTextFieldDirective extends AbstractMdcRipple implements AfterContentInit, OnDestroy {
189+
@HostBinding('class.mdc-text-field') _cls = true;
190+
@ContentChild(MdcTextFieldIconDirective) _icon: MdcTextFieldIconDirective;
191+
@ContentChild(MdcTextFieldInputDirective) _input: MdcTextFieldInputDirective;
192+
@ContentChild(MdcTextFieldLabelDirective) _label: MdcTextFieldLabelDirective;
193193
@ContentChildren('label', {descendants: true, read: ElementRef}) _labels: QueryList<ElementRef>;
194-
@Input() helptext: MdcTextfieldHelptextDirective;
194+
@Input() helptext: MdcTextFieldHelptextDirective;
195195
private _initialized = false;
196196
private _box = false;
197197
private _dense = false;
198198
private _bottomLineElm: HTMLElement = null;
199199
private valid: boolean = null;
200-
private mdcAdapter: MdcTextfieldAdapter = {
200+
private mdcAdapter: MdcTextFieldAdapter = {
201201
addClass: (className: string) => {
202202
this.renderer.addClass(this.root.nativeElement, className);
203203
},
@@ -289,7 +289,7 @@ export class MdcTextfieldDirective extends AbstractMdcRipple implements AfterCon
289289
useCustomValidityChecking_: boolean,
290290
setValid(isValid: boolean),
291291
changeValidity_(isValid: boolean)
292-
} = new MDCTextfieldFoundation(this.mdcAdapter);
292+
} = new MDCTextFieldFoundation(this.mdcAdapter);
293293

294294
constructor(private renderer: Renderer2, private root: ElementRef, private registry: MdcEventRegistry) {
295295
super(root, renderer, registry);
@@ -311,9 +311,9 @@ export class MdcTextfieldDirective extends AbstractMdcRipple implements AfterCon
311311
// programmatic changes to the input value are not seen by the foundation,
312312
// but some states should be updated with the new value:
313313
if (value == null || value.toString().length === 0)
314-
this.mdcAdapter.removeClassFromLabel('mdc-textfield__label--float-above');
314+
this.mdcAdapter.removeClassFromLabel('mdc-text-field__label--float-above');
315315
else
316-
this.mdcAdapter.addClassToLabel('mdc-textfield__label--float-above');
316+
this.mdcAdapter.addClassToLabel('mdc-text-field__label--float-above');
317317
}
318318
}
319319
}
@@ -337,11 +337,11 @@ export class MdcTextfieldDirective extends AbstractMdcRipple implements AfterCon
337337
* When binding to 'isValid', the value will determine the valid state of the input,
338338
* instead of it being managed by the underlying input element directly.
339339
* For most use cases this is not needed. When the input/textarea is an ngControl,
340-
* the mdcTextfield is already aware of that, and is already using the 'valid'
340+
* the mdcTextField is already aware of that, and is already using the 'valid'
341341
* property of that control.
342342
* <p>
343343
* However, in some specific cases, binding to isValid can help. Example:
344-
* When you want the mdcTextfield to go to 'invalid' state only when the underlying
344+
* When you want the mdcTextField to go to 'invalid' state only when the underlying
345345
* control is invalid AND that control is touched, you can bind as follows:
346346
* <code>isValid="myControl.valid || !myControl.touched"</code>.
347347
*/
@@ -356,20 +356,20 @@ export class MdcTextfieldDirective extends AbstractMdcRipple implements AfterCon
356356
}
357357
}
358358

359-
@HostBinding('class.mdc-textfield--textarea') get _textArea(): boolean {
359+
@HostBinding('class.mdc-text-field--textarea') get _textArea(): boolean {
360360
return this._input._isTextarea();
361361
}
362362

363-
@HostBinding('class.mdc-textfield--box') @Input()
363+
@HostBinding('class.mdc-text-field--box') @Input()
364364
get boxed() {
365365
return this._box;
366366
}
367367

368-
@HostBinding('class.mdc-textfield--with-leading-icon') get _leadingIcon(): boolean {
368+
@HostBinding('class.mdc-text-field--with-leading-icon') get _leadingIcon(): boolean {
369369
return this._icon && !this._icon._el.nativeElement.previousElementSibling;
370370
}
371371

372-
@HostBinding('class.mdc-textfield--with-trailing-icon') get _trailingIcon(): boolean {
372+
@HostBinding('class.mdc-text-field--with-trailing-icon') get _trailingIcon(): boolean {
373373
return this._icon && this._icon._el.nativeElement.previousElementSibling;
374374
}
375375

@@ -378,7 +378,7 @@ export class MdcTextfieldDirective extends AbstractMdcRipple implements AfterCon
378378
this.initBox();
379379
}
380380

381-
@HostBinding('class.mdc-textfield--dense') @Input()
381+
@HostBinding('class.mdc-text-field--dense') @Input()
382382
get dense() {
383383
return this._dense;
384384
}

0 commit comments

Comments
 (0)