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 (#4594)
  • Loading branch information
Matt Goo authored Apr 17, 2019
1 parent be8747f commit 5e294f9
Show file tree
Hide file tree
Showing 16 changed files with 69 additions and 50 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 {MDCRippleAdapter} from '@material/ripple/adapter';
import {MDCRipple} from '@material/ripple/component';
import {MDCRippleFoundation} from '@material/ripple/foundation';
import {MDCRippleCapableSurface} from '@material/ripple/types';
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
5 changes: 3 additions & 2 deletions packages/mdc-chips/chip-set/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
*/

import {MDCComponent} from '@material/base/component';
import {MDCChip, MDCChipFactory, MDCChipFoundation} from '../chip/index';
import {MDCChipInteractionEvent, MDCChipRemovalEvent, MDCChipSelectionEvent} from '../chip/index';
import {MDCChip, MDCChipFactory} from '../chip/component';
import {MDCChipFoundation} from '../chip/foundation';
import {MDCChipInteractionEvent, MDCChipRemovalEvent, MDCChipSelectionEvent} from '../chip/types';
import {MDCChipSetAdapter} from './adapter';
import {MDCChipSetFoundation} from './foundation';

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 {MDCRippleAdapter} from '@material/ripple/adapter';
import {MDCRipple, MDCRippleFactory} from '@material/ripple/component';
import {MDCRippleFoundation} from '@material/ripple/foundation';
import {MDCRippleCapableSurface} from '@material/ripple/types';
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 {closest, matches} from '@material/dom/ponyfill';
import {MDCListAdapter} from './adapter';
import {cssClasses, strings} from './constants';
import {MDCListFoundation} from './foundation';
Expand Down Expand Up @@ -205,10 +205,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 @@ -249,7 +249,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 {MDCListFoundation} from '@material/list/foundation';
import {MDCListActionEvent} from '@material/list/types';
import {MDCMenuSurface, MDCMenuSurfaceFactory} from '@material/menu-surface/component';
import {Corner} from '@material/menu-surface/constants';
import {MDCMenuSurfaceFoundation} from '@material/menu-surface/foundation';
import {Corner, MDCMenuSurface, MDCMenuSurfaceFactory} from '@material/menu-surface/index';
import {MDCMenuDistance} from '@material/menu-surface/types';
import {MDCMenuAdapter} from './adapter';
import {cssClasses, DefaultFocusState, 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 {MDCRippleAdapter} from '@material/ripple/adapter';
import {MDCRipple} from '@material/ripple/component';
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
18 changes: 11 additions & 7 deletions packages/mdc-select/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,22 @@

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 {MDCLineRipple, MDCLineRippleFactory} from '@material/line-ripple/component';
import * as menuSurfaceConstants from '@material/menu-surface/constants';
import {MDCMenu, MDCMenuFactory} from '@material/menu/component';
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 {MDCMenuItemEvent} from '@material/menu/types';
import {MDCNotchedOutline, MDCNotchedOutlineFactory} from '@material/notched-outline/component';
import {MDCRippleAdapter} from '@material/ripple/adapter';
import {MDCRipple} from '@material/ripple/component';
import {MDCRippleFoundation} from '@material/ripple/foundation';
import {MDCRippleCapableSurface} from '@material/ripple/types';
import {MDCSelectAdapter} from './adapter';
import {cssClasses, strings} from './constants';
import {MDCSelectFoundation} from './foundation';
import {MDCSelectHelperText, MDCSelectHelperTextFactory} from './helper-text/index';
import {MDCSelectIcon, MDCSelectIconFactory} from './icon/index';
import {MDCSelectHelperText, MDCSelectHelperTextFactory} from './helper-text/component';
import {MDCSelectIcon, MDCSelectIconFactory} from './icon/component';
import {MDCSelectEventDetail, MDCSelectFoundationMap} from './types';

const VALIDATION_ATTR_WHITELIST = ['required', 'aria-required'];
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 {MDCRippleAdapter} from '@material/ripple/adapter';
import {MDCRipple} from '@material/ripple/component';
import {MDCRippleFoundation} from '@material/ripple/foundation';
import {MDCRippleCapableSurface} from '@material/ripple/types';
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
4 changes: 2 additions & 2 deletions packages/mdc-tab-scroller/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} from '@material/dom/ponyfill';
import {MDCTabScrollerAdapter} from './adapter';
import {MDCTabScrollerFoundation} from './foundation';
import * as util from './util';
Expand Down Expand Up @@ -75,7 +75,7 @@ export class MDCTabScroller extends MDCComponent<MDCTabScrollerFoundation> {
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
const adapter: MDCTabScrollerAdapter = {
eventTargetMatchesSelector: (evtTarget, selector) => ponyfill.matches(evtTarget as Element, selector),
eventTargetMatchesSelector: (evtTarget, selector) => matches(evtTarget as Element, selector),
addClass: (className) => this.root_.classList.add(className),
removeClass: (className) => this.root_.classList.remove(className),
addScrollAreaClass: (className) => this.area_.classList.add(className),
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 {MDCRippleFoundation} from '@material/ripple/foundation';
import {MDCRippleCapableSurface} from '@material/ripple/types';
import {MDCTabIndicator, MDCTabIndicatorFactory} from '@material/tab-indicator/component';
import {MDCTabAdapter} from './adapter';
import {MDCTabFoundation} from './foundation';
import {MDCTabDimensions, MDCTabInteractionEventDetail} from './types';
Expand Down
2 changes: 1 addition & 1 deletion packages/mdc-tabs/tab-bar-scroller/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import {getCorrectPropertyName} from '@material/animation/util';
import {MDCComponent} from '@material/base/component';
import {MDCTabBar, MDCTabBarFactory} from '../tab-bar/index';
import {MDCTabBar, MDCTabBarFactory} from '../tab-bar/component';
import {MDCTabBarScrollerAdapter} from './adapter';
import {MDCTabBarScrollerFoundation} from './foundation';

Expand Down
3 changes: 2 additions & 1 deletion packages/mdc-tabs/tab-bar/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
*/

import {MDCComponent} from '@material/base/component';
import {MDCTab, MDCTabFactory, MDCTabFoundation, MDCTabSelectedEvent} from '../tab/index';
import {MDCTab, MDCTabFactory, MDCTabSelectedEvent} from '../tab/component';
import {MDCTabFoundation} from '../tab/foundation';
import {MDCTabBarAdapter} from './adapter';
import {MDCTabBarFoundation} from './foundation';
import {MDCTabBarChangeEventDetail} from './types';
Expand Down
16 changes: 8 additions & 8 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 All @@ -41,16 +41,16 @@ import {
import {
MDCTextFieldCharacterCounter,
MDCTextFieldCharacterCounterFactory,
MDCTextFieldCharacterCounterFoundation,
} from './character-counter/index';
} from './character-counter/component';
import {MDCTextFieldCharacterCounterFoundation} from './character-counter/foundation';
import {cssClasses, strings} from './constants';
import {MDCTextFieldFoundation} from './foundation';
import {
MDCTextFieldHelperText,
MDCTextFieldHelperTextFactory,
MDCTextFieldHelperTextFoundation,
} from './helper-text/index';
import {MDCTextFieldIcon, MDCTextFieldIconFactory} from './icon/index';
} from './helper-text/component';
import {MDCTextFieldHelperTextFoundation} from './helper-text/foundation';
import {MDCTextFieldIcon, MDCTextFieldIconFactory} from './icon/component';
import {MDCTextFieldFoundationMap} from './types';

export class MDCTextField extends MDCComponent<MDCTextFieldFoundation> implements MDCRippleCapableSurface {
Expand Down

0 comments on commit 5e294f9

Please sign in to comment.