Skip to content

Commit

Permalink
Revert "chore: update MDC to latest canary" (#17932)
Browse files Browse the repository at this point in the history
This reverts commit e6b6384.
  • Loading branch information
mmalerba authored Dec 11, 2019
1 parent e6b6384 commit 498b884
Show file tree
Hide file tree
Showing 9 changed files with 533 additions and 560 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"@types/youtube": "^0.0.38",
"@webcomponents/custom-elements": "^1.1.0",
"core-js": "^2.6.9",
"material-components-web": "5.0.0-canary.5729943ba.0",
"material-components-web": "^4.0.0",
"rxjs": "^6.5.3",
"systemjs": "0.19.43",
"tslib": "^1.10.0",
Expand Down
2 changes: 1 addition & 1 deletion packages.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# all in-sync. This map is passed to each ng_package rule to stamp out the appropriate
# version for the placeholders.
ANGULAR_PACKAGE_VERSION = "^9.0.0-0 || ^10.0.0-0"
MDC_PACKAGE_VERSION = "5.0.0-canary.5729943ba.0"
MDC_PACKAGE_VERSION = "^4.0.0"
VERSION_PLACEHOLDER_REPLACEMENTS = {
"0.0.0-MDC": MDC_PACKAGE_VERSION,
"0.0.0-NG": ANGULAR_PACKAGE_VERSION,
Expand Down
28 changes: 10 additions & 18 deletions src/material-experimental/mdc-chips/chip-icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
* found in the LICENSE file at https://angular.io/license
*/

import {ChangeDetectorRef, Directive, ElementRef, OnDestroy} from '@angular/core';
import {
ChangeDetectorRef,
Directive,
ElementRef,
} from '@angular/core';
import {
CanDisable,
CanDisableCtor,
Expand Down Expand Up @@ -102,32 +106,20 @@ const _MatChipRemoveMixinBase:
'mat-mdc-chip-remove mat-mdc-chip-trailing-icon mdc-chip__icon mdc-chip__icon--trailing',
'[tabIndex]': 'tabIndex',
'role': 'button',
'(click)': '_clicks.next($event)',
'(keydown)': '_keydowns.next($event)',
'(click)': 'interaction.next($event)',
'(keydown)': 'interaction.next($event)',
}
})
export class MatChipRemove extends _MatChipRemoveMixinBase
implements CanDisable, HasTabIndex, OnDestroy {
export class MatChipRemove extends _MatChipRemoveMixinBase implements CanDisable, HasTabIndex {
/**
* Emits when the user clicks the icon.
* Emits when the user interacts with the icon.
* @docs-private
*/
_clicks: Subject<MouseEvent> = new Subject<MouseEvent>();

/**
* Emits when the user presses a key on the icon.
* @docs-private
*/
_keydowns: Subject<KeyboardEvent> = new Subject<KeyboardEvent>();
interaction: Subject<MouseEvent | KeyboardEvent> = new Subject<MouseEvent | KeyboardEvent>();

constructor(_elementRef: ElementRef) {
super(_elementRef);
}

ngOnDestroy() {
this._clicks.complete();
this._keydowns.complete();
}

static ngAcceptInputType_disabled: boolean | string | null | undefined;
}
4 changes: 2 additions & 2 deletions src/material-experimental/mdc-chips/chip-option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export class MatChipOption extends MatChip {
if (this.disabled) {
event.preventDefault();
} else {
this._handleClick(event);
this._handleInteraction(event);
event.stopPropagation();
}
}
Expand All @@ -221,7 +221,7 @@ export class MatChipOption extends MatChip {
event.preventDefault();
break;
default:
this._handleKeydown(event);
this._handleInteraction(event);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/material-experimental/mdc-chips/chip-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class MatChipRow extends MatChip implements AfterContentInit, AfterViewIn
cells!: HTMLElement[];

/** Key codes for which this component has a custom handler. */
HANDLED_KEYS = new Set([...NAVIGATION_KEYS, BACKSPACE, DELETE]);
HANDLED_KEYS = NAVIGATION_KEYS.concat([BACKSPACE, DELETE]);

ngAfterContentInit() {
super.ngAfterContentInit();
Expand Down Expand Up @@ -145,7 +145,7 @@ export class MatChipRow extends MatChip implements AfterContentInit, AfterViewIn
event.preventDefault();
break;
default:
this._handleKeydown(event);
this._handleInteraction(event);
}
}

Expand Down
36 changes: 12 additions & 24 deletions src/material-experimental/mdc-chips/chip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export class MatChip extends _MatChipMixinBase implements AfterContentInit, Afte
/** Emits when the chip is blurred. */
readonly _onBlur = new Subject<MatChipEvent>();

readonly HANDLED_KEYS: Set<number> = new Set();
readonly HANDLED_KEYS: number[] = [];

/** Whether the chip has focus. */
protected _hasFocusInternal = false;
Expand Down Expand Up @@ -330,29 +330,24 @@ export class MatChip extends _MatChipMixinBase implements AfterContentInit, Afte
_initRemoveIcon() {
if (this.removeIcon) {
this._chipFoundation.setShouldRemoveOnTrailingIconClick(true);
this._listenToRemoveIconInteractions();
this._listenToRemoveIconInteraction();
this.removeIcon.disabled = this.disabled;
}
}

/** Handles interaction with the remove icon. */
_listenToRemoveIconInteractions() {
this.removeIcon._clicks
_listenToRemoveIconInteraction() {
this.removeIcon.interaction
.pipe(takeUntil(this._destroyed))
.subscribe(event => {
if (!this.disabled) {
this._chipFoundation.handleClick(event);
}
});
this.removeIcon._keydowns
.pipe(takeUntil(this._destroyed))
.subscribe(event => {
.subscribe((event) => {
// The MDC chip foundation calls stopPropagation() for any trailing icon interaction
// event, even ones it doesn't handle, so we want to avoid passing it keyboard events
// for which we have a custom handler.
if (!this.disabled && !this.HANDLED_KEYS.has(event.keyCode)) {
this._chipFoundation.handleKeydown(event);
if (this.disabled || (event instanceof KeyboardEvent &&
this.HANDLED_KEYS.indexOf(event.keyCode) !== -1)) {
return;
}
this._chipFoundation.handleTrailingIconInteraction(event);
});
}

Expand Down Expand Up @@ -396,17 +391,10 @@ export class MatChip extends _MatChipMixinBase implements AfterContentInit, Afte
this._rippleRenderer.setupTriggerEvents(this._elementRef);
}

/** Forwards click events to the MDC chip foundation. */
_handleClick(event: MouseEvent) {
if (!this.disabled) {
this._chipFoundation.handleClick(event);
}
}

/** Forwards keydown events to the MDC chip foundation. */
_handleKeydown(event: KeyboardEvent) {
/** Forwards interaction events to the MDC chip foundation. */
_handleInteraction(event: MouseEvent | KeyboardEvent) {
if (!this.disabled) {
this._chipFoundation.handleKeydown(event);
this._chipFoundation.handleInteraction(event);
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/material-experimental/mdc-helpers/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ng_module(
# Add all MDC Sass files that we depend on here. After updating MDC dependencies, use the following
# command to generate an updated list:
#
# `find node_modules/@material/ -name "_*.scss" | sort | sed -r 's/(.*)/"@npm\/\/:\1",/'`
# `find node_modules/@material/ -name "_*.scss" | sort | sed -r 's/(.*\/@material\/[^/]*)\/(.*)/"@npm\/\/\1:\2",/'`
#
# TODO(mmalerba): Find a less tedious way to do this...
sass_library(
Expand All @@ -45,7 +45,6 @@ sass_library(
"@npm//:node_modules/@material/dialog/_variables.scss",
"@npm//:node_modules/@material/drawer/_mixins.scss",
"@npm//:node_modules/@material/drawer/_variables.scss",
"@npm//:node_modules/@material/elevation/_functions.scss",
"@npm//:node_modules/@material/elevation/_mixins.scss",
"@npm//:node_modules/@material/elevation/_variables.scss",
"@npm//:node_modules/@material/fab/_mixins.scss",
Expand Down Expand Up @@ -109,7 +108,6 @@ sass_library(
"@npm//:node_modules/@material/tab-bar/_variables.scss",
"@npm//:node_modules/@material/tab-indicator/_mixins.scss",
"@npm//:node_modules/@material/tab-scroller/_mixins.scss",
"@npm//:node_modules/@material/tab-scroller/_variables.scss",
"@npm//:node_modules/@material/tab/_mixins.scss",
"@npm//:node_modules/@material/tab/_variables.scss",
"@npm//:node_modules/@material/textfield/_functions.scss",
Expand Down
5 changes: 1 addition & 4 deletions src/material-experimental/mdc-progress-bar/progress-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,7 @@ export class MatProgressBar extends _MatProgressBarMixinBase implements AfterVie
removeClass: (className: string) => this._rootElement.classList.remove(className),
setStyle: (el: HTMLElement, styleProperty: string, value: string) => {
(el.style as any)[styleProperty] = value;
},
removeAttribute: (name: string) => this._elementRef.nativeElement.removeAttribute(name),
setAttribute: (name: string, value: string) =>
this._elementRef.nativeElement.setAttribute(name, value),
}
};

/** Flag that indicates whether NoopAnimations mode is set to true. */
Expand Down
Loading

0 comments on commit 498b884

Please sign in to comment.