Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
chore: normalize imports by removing @material/**/index.js for founda…
Browse files Browse the repository at this point in the history
…tion, types, adapter, etc
  • Loading branch information
Matt Goo committed Apr 11, 2019
1 parent cc2224c commit 3f70c99
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 37 deletions.
9 changes: 6 additions & 3 deletions packages/mdc-checkbox/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@

import {getCorrectEventName} from '@material/animation/util';
import {MDCComponent} from '@material/base/component';
import {ponyfill} from '@material/dom/index';
import {MDCRipple, MDCRippleAdapter, MDCRippleCapableSurface, MDCRippleFoundation} from '@material/ripple/index';
import {matches} from '@material/dom/ponyfill';
import {MDCRipple} from '@material/ripple/component';
import {MDCRippleAdapter} from '@material/ripple/adapter';
import {MDCRippleCapableSurface} from '@material/ripple/types';
import {MDCRippleFoundation} from '@material/ripple/foundation';
import {MDCCheckboxAdapter} from './adapter';
import {MDCCheckboxFoundation} from './foundation';

Expand Down Expand Up @@ -123,7 +126,7 @@ export class MDCCheckbox extends MDCComponent<MDCCheckboxFoundation> implements
const adapter: MDCRippleAdapter = {
...MDCRipple.createAdapter(this),
deregisterInteractionHandler: (evtType, handler) => this.nativeControl_.removeEventListener(evtType, handler),
isSurfaceActive: () => ponyfill.matches(this.nativeControl_, ':active'),
isSurfaceActive: () => matches(this.nativeControl_, ':active'),
isUnbounded: () => true,
registerInteractionHandler: (evtType, handler) => this.nativeControl_.addEventListener(evtType, handler),
};
Expand Down
11 changes: 4 additions & 7 deletions packages/mdc-chips/chip/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,10 @@

import {MDCComponent} from '@material/base/component';
import {SpecificEventListener} from '@material/base/types';
import {
MDCRipple,
MDCRippleAdapter,
MDCRippleCapableSurface,
MDCRippleFactory,
MDCRippleFoundation,
} from '@material/ripple/index';
import {MDCRipple, MDCRippleFactory} from '@material/ripple/component';
import {MDCRippleAdapter} from '@material/ripple/adapter';
import {MDCRippleCapableSurface} from '@material/ripple/types';
import {MDCRippleFoundation} from '@material/ripple/foundation';
import {MDCChipAdapter} from './adapter';
import {strings} from './constants';
import {MDCChipFoundation} from './foundation';
Expand Down
8 changes: 4 additions & 4 deletions packages/mdc-list/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import {MDCComponent} from '@material/base/component';
import {SpecificEventListener} from '@material/base/types';
import {ponyfill} from '@material/dom/index';
import {matches, closest} from '@material/dom/ponyfill';
import {MDCListAdapter} from './adapter';
import {cssClasses, strings} from './constants';
import {MDCListFoundation} from './foundation';
Expand Down Expand Up @@ -204,10 +204,10 @@ export class MDCList extends MDCComponent<MDCListFoundation> {
*/
private getListItemIndex_(evt: Event) {
const eventTarget = evt.target as Element;
const nearestParent = ponyfill.closest(eventTarget, `.${cssClasses.LIST_ITEM_CLASS}, .${cssClasses.ROOT}`);
const nearestParent = closest(eventTarget, `.${cssClasses.LIST_ITEM_CLASS}, .${cssClasses.ROOT}`);

// Get the index of the element if it is a list item.
if (nearestParent && ponyfill.matches(nearestParent, `.${cssClasses.LIST_ITEM_CLASS}`)) {
if (nearestParent && matches(nearestParent, `.${cssClasses.LIST_ITEM_CLASS}`)) {
return this.listElements.indexOf(nearestParent);
}

Expand Down Expand Up @@ -251,7 +251,7 @@ export class MDCList extends MDCComponent<MDCListFoundation> {
const target = evt.target as Element;

// Toggle the checkbox only if it's not the target of the event, or the checkbox will have 2 change events.
const toggleCheckbox = !ponyfill.matches(target, strings.CHECKBOX_RADIO_SELECTOR);
const toggleCheckbox = !matches(target, strings.CHECKBOX_RADIO_SELECTOR);
this.foundation_.handleClick(index, toggleCheckbox);
}
}
7 changes: 5 additions & 2 deletions packages/mdc-menu/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@

import {MDCComponent} from '@material/base/component';
import {CustomEventListener, SpecificEventListener} from '@material/base/types';
import {MDCList, MDCListActionEvent, MDCListFactory, MDCListFoundation} from '@material/list/index';
import {MDCList, MDCListFactory} from '@material/list/component';
import {MDCListActionEvent} from '@material/list/types';
import {MDCListFoundation} from '@material/list/foundation';
import {MDCMenuSurfaceFoundation} from '@material/menu-surface/foundation';
import {Corner, MDCMenuSurface, MDCMenuSurfaceFactory} from '@material/menu-surface/index';
import {Corner} from '@material/menu-surface/constants';
import {MDCMenuSurface, MDCMenuSurfaceFactory} from '@material/menu-surface/component';
import {MDCMenuDistance} from '@material/menu-surface/types';
import {MDCMenuAdapter} from './adapter';
import {cssClasses, strings} from './constants';
Expand Down
5 changes: 4 additions & 1 deletion packages/mdc-radio/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
*/

import {MDCComponent} from '@material/base/component';
import {MDCRipple, MDCRippleAdapter, MDCRippleCapableSurface, MDCRippleFoundation} from '@material/ripple/index';
import {MDCRipple} from '@material/ripple/component';
import {MDCRippleAdapter} from '@material/ripple/adapter';
import {MDCRippleFoundation} from '@material/ripple/foundation';
import {MDCRippleCapableSurface} from '@material/ripple/types';
import {MDCRadioAdapter} from './adapter';
import {MDCRadioFoundation} from './foundation';

Expand Down
4 changes: 2 additions & 2 deletions packages/mdc-ripple/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/

import {MDCComponent} from '@material/base/component';
import {ponyfill} from '@material/dom/index';
import {matches} from '@material/dom/ponyfill';
import {MDCRippleAdapter} from './adapter';
import {MDCRippleFoundation} from './foundation';
import {MDCRippleAttachOpts, MDCRippleCapableSurface} from './types';
Expand Down Expand Up @@ -52,7 +52,7 @@ export class MDCRipple extends MDCComponent<MDCRippleFoundation> implements MDCR
instance.root_.removeEventListener(evtType, handler, util.applyPassive()),
deregisterResizeHandler: (handler) => window.removeEventListener('resize', handler),
getWindowPageOffset: () => ({x: window.pageXOffset, y: window.pageYOffset}),
isSurfaceActive: () => ponyfill.matches(instance.root_, ':active'),
isSurfaceActive: () => matches(instance.root_, ':active'),
isSurfaceDisabled: () => Boolean(instance.disabled),
isUnbounded: () => Boolean(instance.unbounded),
registerDocumentInteractionHandler: (evtType, handler) =>
Expand Down
13 changes: 8 additions & 5 deletions packages/mdc-select/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@

import {MDCComponent} from '@material/base/component';
import {CustomEventListener, SpecificEventListener} from '@material/base/types';
import {MDCFloatingLabel, MDCFloatingLabelFactory} from '@material/floating-label/index';
import {MDCLineRipple, MDCLineRippleFactory} from '@material/line-ripple/index';
import {MDCFloatingLabel, MDCFloatingLabelFactory} from '@material/floating-label/component';
import * as menuSurfaceConstants from '@material/menu-surface/constants';
import * as menuConstants from '@material/menu/constants';
import {MDCMenu, MDCMenuFactory, MDCMenuItemEvent} from '@material/menu/index';
import {MDCNotchedOutline, MDCNotchedOutlineFactory} from '@material/notched-outline/index';
import {MDCRipple, MDCRippleAdapter, MDCRippleCapableSurface, MDCRippleFoundation} from '@material/ripple/index';
import {MDCMenu, MDCMenuFactory} from '@material/menu/component';
import {MDCMenuItemEvent} from '@material/menu/types';
import {MDCNotchedOutline, MDCNotchedOutlineFactory} from '@material/notched-outline/component';
import {MDCRipple} from '@material/ripple/component';
import {MDCRippleAdapter} from '@material/ripple/adapter';
import {MDCRippleCapableSurface} from '@material/ripple/types';
import {MDCRippleFoundation} from '@material/ripple/foundation';
import {MDCSelectAdapter} from './adapter';
import {cssClasses, strings} from './constants';
import {MDCSelectFoundation} from './foundation';
Expand Down
6 changes: 3 additions & 3 deletions packages/mdc-snackbar/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import {MDCComponent} from '@material/base/component';
import {SpecificEventListener} from '@material/base/types';
import {ponyfill} from '@material/dom/index';
import {closest} from '@material/dom/ponyfill';
import {MDCSnackbarAdapter} from './adapter';
import {strings} from './constants';
import {MDCSnackbarFoundation} from './foundation';
Expand Down Expand Up @@ -161,10 +161,10 @@ export class MDCSnackbar extends MDCComponent<MDCSnackbarFoundation> {
}

private isActionButton_(target: Element): boolean {
return Boolean(ponyfill.closest(target, ACTION_SELECTOR));
return Boolean(closest(target, ACTION_SELECTOR));
}

private isActionIcon_(target: Element): boolean {
return Boolean(ponyfill.closest(target, DISMISS_SELECTOR));
return Boolean(closest(target, DISMISS_SELECTOR));
}
}
9 changes: 6 additions & 3 deletions packages/mdc-switch/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@

import {MDCComponent} from '@material/base/component';
import {EventType} from '@material/base/types';
import {ponyfill} from '@material/dom/index';
import {MDCRipple, MDCRippleAdapter, MDCRippleCapableSurface, MDCRippleFoundation} from '@material/ripple/index';
import {matches} from '@material/dom/ponyfill';
import {MDCRipple} from '@material/ripple/component';
import {MDCRippleAdapter} from '@material/ripple/adapter';
import {MDCRippleCapableSurface} from '@material/ripple/types';
import {MDCRippleFoundation} from '@material/ripple/foundation';
import {MDCSwitchAdapter} from './adapter';
import {MDCSwitchFoundation} from './foundation';

Expand Down Expand Up @@ -102,7 +105,7 @@ export class MDCSwitch extends MDCComponent<MDCSwitchFoundation> implements MDCR
deregisterInteractionHandler: (evtType: EventType, handler: EventListener) => {
this.nativeControl_.removeEventListener(evtType, handler);
},
isSurfaceActive: () => ponyfill.matches(this.nativeControl_, ':active'),
isSurfaceActive: () => matches(this.nativeControl_, ':active'),
isUnbounded: () => true,
registerInteractionHandler: (evtType: EventType, handler: EventListener) => {
this.nativeControl_.addEventListener(evtType, handler);
Expand Down
6 changes: 4 additions & 2 deletions packages/mdc-tab-bar/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@

import {MDCComponent} from '@material/base/component';
import {CustomEventListener, SpecificEventListener} from '@material/base/types';
import {MDCTabScroller, MDCTabScrollerFactory} from '@material/tab-scroller/index';
import {MDCTab, MDCTabFactory, MDCTabFoundation, MDCTabInteractionEvent} from '@material/tab/index';
import {MDCTabScroller, MDCTabScrollerFactory} from '@material/tab-scroller/component';
import {MDCTab, MDCTabFactory} from '@material/tab/component';
import {MDCTabFoundation} from '@material/tab/foundation';
import {MDCTabInteractionEvent} from '@material/tab/types';
import {MDCTabBarAdapter} from './adapter';
import {MDCTabBarFoundation} from './foundation';
import {MDCTabBarActivatedEventDetail} from './types';
Expand Down
6 changes: 4 additions & 2 deletions packages/mdc-tab/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@

import {MDCComponent} from '@material/base/component';
import {SpecificEventListener} from '@material/base/types';
import {MDCRipple, MDCRippleCapableSurface, MDCRippleFactory, MDCRippleFoundation} from '@material/ripple/index';
import {MDCTabIndicator, MDCTabIndicatorFactory} from '@material/tab-indicator/index';
import {MDCRipple, MDCRippleFactory} from '@material/ripple/component';
import {MDCRippleCapableSurface} from '@material/ripple/types';
import {MDCRippleFoundation} from '@material/ripple/foundation';
import {MDCTabIndicator, MDCTabIndicatorFactory} from '@material/tab-indicator/component';
import {MDCTabAdapter} from './adapter';
import {MDCTabFoundation} from './foundation';
import {MDCTabDimensions, MDCTabInteractionEventDetail} from './types';
Expand Down
6 changes: 3 additions & 3 deletions packages/mdc-textfield/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@

import {MDCComponent} from '@material/base/component';
import * as ponyfill from '@material/dom/ponyfill';
import {MDCFloatingLabel, MDCFloatingLabelFactory} from '@material/floating-label/index';
import {MDCLineRipple, MDCLineRippleFactory} from '@material/line-ripple/index';
import {MDCNotchedOutline, MDCNotchedOutlineFactory} from '@material/notched-outline/index';
import {MDCFloatingLabel, MDCFloatingLabelFactory} from '@material/floating-label/component';
import {MDCLineRipple, MDCLineRippleFactory} from '@material/line-ripple/component';
import {MDCNotchedOutline, MDCNotchedOutlineFactory} from '@material/notched-outline/component';
import {MDCRippleAdapter} from '@material/ripple/adapter';
import {MDCRipple, MDCRippleFactory} from '@material/ripple/component';
import {MDCRippleFoundation} from '@material/ripple/foundation';
Expand Down

0 comments on commit 3f70c99

Please sign in to comment.