23
23
import * as React from 'react' ;
24
24
import classnames from 'classnames' ;
25
25
26
- // @ts -ignore no .d.ts file
27
- import { MDCDialogFoundation , MDCDialogAdapter , util } from '@material/dialog/dist/mdc.dialog ' ;
28
- // @ts -ignore no .d.ts file
29
- import { ponyfill } from '@material/dom/dist/mdc.dom ' ;
26
+ import { MDCDialogFoundation } from '@material/dialog/foundation' ;
27
+ import { MDCDialogAdapter } from '@material/dialog/adapter ' ;
28
+ import { createFocusTrapInstance , isScrollable , areTopsMisaligned } from '@material/dialog/util' ;
29
+ import { ponyfill } from '@material/dom' ;
30
30
/* eslint-disable no-unused-vars */
31
31
import DialogContent , { DialogContentProps } from './DialogContent' ;
32
32
import DialogFooter , { DialogFooterProps } from './DialogFooter' ;
@@ -89,7 +89,7 @@ class Dialog<T extends HTMLElement = HTMLElement> extends React.Component<
89
89
DialogState
90
90
> {
91
91
focusTrap ?: FocusTrap ;
92
- foundation : MDCDialogFoundation ;
92
+ foundation ! : MDCDialogFoundation ;
93
93
dialogElement : React . RefObject < HTMLElement > = React . createRef ( ) ;
94
94
labelledBy ?: string ;
95
95
describedBy ?: string ;
@@ -116,7 +116,7 @@ class Dialog<T extends HTMLElement = HTMLElement> extends React.Component<
116
116
this . open ( ) ;
117
117
}
118
118
if ( ! autoStackButtons ) {
119
- this . foundation . setAutoStackButtons ( autoStackButtons ) ;
119
+ this . foundation . setAutoStackButtons ( autoStackButtons ! ) ;
120
120
}
121
121
122
122
if ( typeof escapeKeyAction === 'string' ) { // set even if empty string
@@ -136,15 +136,15 @@ class Dialog<T extends HTMLElement = HTMLElement> extends React.Component<
136
136
const { open, autoStackButtons, escapeKeyAction, scrimClickAction} = this . props ;
137
137
138
138
if ( prevProps . autoStackButtons !== autoStackButtons ) {
139
- this . foundation . setAutoStackButtons ( autoStackButtons ) ;
139
+ this . foundation . setAutoStackButtons ( autoStackButtons ! ) ;
140
140
}
141
141
142
142
if ( prevProps . escapeKeyAction !== escapeKeyAction ) {
143
- this . foundation . setEscapeKeyAction ( escapeKeyAction ) ;
143
+ this . foundation . setEscapeKeyAction ( escapeKeyAction ! ) ;
144
144
}
145
145
146
146
if ( prevProps . scrimClickAction !== scrimClickAction ) {
147
- this . foundation . setScrimClickAction ( scrimClickAction ) ;
147
+ this . foundation . setScrimClickAction ( scrimClickAction ! ) ;
148
148
}
149
149
150
150
if ( prevProps . open !== open ) {
@@ -181,13 +181,12 @@ class Dialog<T extends HTMLElement = HTMLElement> extends React.Component<
181
181
} ;
182
182
183
183
private initializeFocusTrap = ( ) : void => {
184
- this . focusTrap = this . props . children && util . createFocusTrapInstance ( this . dialogElement . current ) ;
184
+ this . focusTrap = this . props . children && createFocusTrapInstance ( this . dialogElement . current ! ) ;
185
185
} ;
186
186
187
- get adapter ( ) : Partial < MDCDialogAdapter > {
187
+ get adapter ( ) : MDCDialogAdapter {
188
188
const strings = MDCDialogFoundation . strings ;
189
189
const { closest, matches} = ponyfill ;
190
- const { isScrollable, areTopsMisaligned} = util ;
191
190
return {
192
191
addClass : ( className : string ) => {
193
192
const { classList} = this . state ;
@@ -258,8 +257,8 @@ class Dialog<T extends HTMLElement = HTMLElement> extends React.Component<
258
257
} ;
259
258
260
259
handleInteraction = ( e : React . MouseEvent < HTMLElement > | React . KeyboardEvent < HTMLElement > ) : void =>
261
- this . foundation . handleInteraction ( e ) ;
262
- handleDocumentKeyDown = ( e : Event ) : void =>
260
+ this . foundation . handleInteraction ( e . nativeEvent ) ;
261
+ handleDocumentKeyDown = ( e : KeyboardEvent ) : void =>
263
262
this . foundation . handleDocumentKeydown ( e ) ;
264
263
handleLayout = ( ) : void => this . foundation . layout ( ) ;
265
264
0 commit comments