2222
2323import * as React from 'react' ;
2424import classnames from 'classnames' ;
25- import {
26- MDCTabScrollerFoundation ,
27- util ,
28- // @ts -ignore no .d.ts file
29- } from '@material/tab-scroller/dist/mdc.tabScroller' ;
30- // @ts -ignore no mdc .d.ts file
25+ import { MDCTabScrollerFoundation } from '@material/tab-scroller/foundation' ;
26+ import { MDCTabScrollerAdapter } from '@material/tab-scroller/adapter' ;
27+ import * as util from '@material/tab-scroller/util' ;
3128import { matches } from '@material/dom/ponyfill' ;
3229
3330const convertDashToCamelCase = ( propName : string ) =>
@@ -55,7 +52,7 @@ export default class TabScroller extends React.Component<
5552 > {
5653 areaElement : React . RefObject < HTMLDivElement > = React . createRef ( ) ;
5754 contentElement : React . RefObject < HTMLDivElement > = React . createRef ( ) ;
58- foundation ? : MDCTabScrollerFoundation ;
55+ foundation ! : MDCTabScrollerFoundation ;
5956
6057 state : TabScrollerState = {
6158 classList : new Set ( ) ,
@@ -113,7 +110,7 @@ export default class TabScroller extends React.Component<
113110 } ) ;
114111 } ;
115112
116- get adapter ( ) {
113+ get adapter ( ) : MDCTabScrollerAdapter {
117114 return {
118115 eventTargetMatchesSelector : ( evtTarget : HTMLDivElement , selector : string ) => {
119116 if ( selector ) {
@@ -141,25 +138,27 @@ export default class TabScroller extends React.Component<
141138 setScrollContentStyleProperty : ( prop : string , value : string ) =>
142139 this . setStyleToElement ( prop , value , 'scrollContentStyleProperty' ) ,
143140 getScrollContentStyleValue : ( propName : string ) =>
144- this . contentElement . current &&
145- window
146- . getComputedStyle ( this . contentElement . current )
147- . getPropertyValue ( propName ) ,
141+ this . contentElement . current ?
142+ window
143+ . getComputedStyle ( this . contentElement . current )
144+ . getPropertyValue ( propName ) : '' ,
148145 setScrollAreaScrollLeft : ( scrollX : number ) => {
149146 if ( ! this . areaElement . current ) return ;
150147 this . areaElement . current . scrollLeft = scrollX ;
151148 } ,
152149 getScrollAreaScrollLeft : ( ) =>
153- this . areaElement . current && this . areaElement . current . scrollLeft ,
150+ this . areaElement . current ? this . areaElement . current . scrollLeft : 0 ,
154151 getScrollContentOffsetWidth : this . getScrollContentWidth ,
155152 getScrollAreaOffsetWidth : ( ) =>
156- this . areaElement . current && this . areaElement . current . offsetWidth ,
153+ this . areaElement . current ? this . areaElement . current . offsetWidth : 0 ,
157154 computeScrollAreaClientRect : ( ) =>
158- this . areaElement . current &&
159- this . areaElement . current . getBoundingClientRect ( ) ,
155+ this . areaElement . current ?
156+ this . areaElement . current . getBoundingClientRect ( ) :
157+ new ClientRect ( ) ,
160158 computeScrollContentClientRect : ( ) =>
161- this . contentElement . current &&
162- this . contentElement . current . getBoundingClientRect ( ) ,
159+ this . contentElement . current ?
160+ this . contentElement . current . getBoundingClientRect ( ) :
161+ new ClientRect ( ) ,
163162 computeHorizontalScrollbarHeight : ( ) =>
164163 util . computeHorizontalScrollbarHeight ( document ) ,
165164 } ;
@@ -172,7 +171,7 @@ export default class TabScroller extends React.Component<
172171 // needs to be public class method for react tab-bar
173172 getScrollContentWidth = ( ) => {
174173 return (
175- this . contentElement . current && this . contentElement . current . offsetWidth
174+ this . contentElement . current ? this . contentElement . current . offsetWidth : 0
176175 ) ;
177176 } ;
178177
@@ -186,32 +185,32 @@ export default class TabScroller extends React.Component<
186185
187186 handleWheel_ = ( evt : React . WheelEvent < HTMLDivElement > ) => {
188187 this . props . onWheel && this . props . onWheel ( evt ) ;
189- this . foundation . handleInteraction ( evt ) ;
188+ this . foundation . handleInteraction ( ) ;
190189 } ;
191190
192191 handleTouchStart_ = ( evt : React . TouchEvent < HTMLDivElement > ) => {
193192 this . props . onTouchStart && this . props . onTouchStart ( evt ) ;
194- this . foundation . handleInteraction ( evt ) ;
193+ this . foundation . handleInteraction ( ) ;
195194 } ;
196195
197196 handlePointerDown_ = ( evt : React . PointerEvent < HTMLDivElement > ) => {
198197 this . props . onPointerDown && this . props . onPointerDown ( evt ) ;
199- this . foundation . handleInteraction ( evt ) ;
198+ this . foundation . handleInteraction ( ) ;
200199 } ;
201200
202201 handleMouseDown_ = ( evt : React . MouseEvent < HTMLDivElement > ) => {
203202 this . props . onMouseDown && this . props . onMouseDown ( evt ) ;
204- this . foundation . handleInteraction ( evt ) ;
203+ this . foundation . handleInteraction ( ) ;
205204 } ;
206205
207206 handleKeyDown_ = ( evt : React . KeyboardEvent < HTMLDivElement > ) => {
208207 this . props . onKeyDown && this . props . onKeyDown ( evt ) ;
209- this . foundation . handleInteraction ( evt ) ;
208+ this . foundation . handleInteraction ( ) ;
210209 } ;
211210
212211 handleTransitionEnd_ = ( evt : React . TransitionEvent < HTMLDivElement > ) => {
213212 this . props . onTransitionEnd && this . props . onTransitionEnd ( evt ) ;
214- this . foundation . handleTransitionEnd ( evt ) ;
213+ this . foundation . handleTransitionEnd ( evt . nativeEvent ) ;
215214 } ;
216215
217216 render ( ) {
0 commit comments