2323import * as React from 'react' ;
2424import classnames from 'classnames' ;
2525
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 { strings } from '@material/dialog/constants' ;
30+ import { ponyfill } from '@material/dom' ;
3031/* eslint-disable no-unused-vars */
3132import DialogContent , { DialogContentProps } from './DialogContent' ;
3233import DialogFooter , { DialogFooterProps } from './DialogFooter' ;
@@ -89,7 +90,7 @@ class Dialog<T extends HTMLElement = HTMLElement> extends React.Component<
8990 DialogState
9091 > {
9192 focusTrap ?: FocusTrap ;
92- foundation : MDCDialogFoundation ;
93+ foundation ! : MDCDialogFoundation ;
9394 dialogElement : React . RefObject < HTMLElement > = React . createRef ( ) ;
9495 labelledBy ?: string ;
9596 describedBy ?: string ;
@@ -103,6 +104,8 @@ class Dialog<T extends HTMLElement = HTMLElement> extends React.Component<
103104 id : 'mdc-dialog' ,
104105 open : false ,
105106 role : 'alertdialog' ,
107+ escapeKeyAction : strings . CLOSE_ACTION ,
108+ scrimClickAction : strings . CLOSE_ACTION ,
106109 } ;
107110
108111 state : DialogState = { classList : new Set ( ) } ;
@@ -116,7 +119,7 @@ class Dialog<T extends HTMLElement = HTMLElement> extends React.Component<
116119 this . open ( ) ;
117120 }
118121 if ( ! autoStackButtons ) {
119- this . foundation . setAutoStackButtons ( autoStackButtons ) ;
122+ this . foundation . setAutoStackButtons ( autoStackButtons ! ) ;
120123 }
121124
122125 if ( typeof escapeKeyAction === 'string' ) { // set even if empty string
@@ -136,15 +139,15 @@ class Dialog<T extends HTMLElement = HTMLElement> extends React.Component<
136139 const { open, autoStackButtons, escapeKeyAction, scrimClickAction} = this . props ;
137140
138141 if ( prevProps . autoStackButtons !== autoStackButtons ) {
139- this . foundation . setAutoStackButtons ( autoStackButtons ) ;
142+ this . foundation . setAutoStackButtons ( autoStackButtons ! ) ;
140143 }
141144
142145 if ( prevProps . escapeKeyAction !== escapeKeyAction ) {
143- this . foundation . setEscapeKeyAction ( escapeKeyAction ) ;
146+ this . foundation . setEscapeKeyAction ( escapeKeyAction ! ) ;
144147 }
145148
146149 if ( prevProps . scrimClickAction !== scrimClickAction ) {
147- this . foundation . setScrimClickAction ( scrimClickAction ) ;
150+ this . foundation . setScrimClickAction ( scrimClickAction ! ) ;
148151 }
149152
150153 if ( prevProps . open !== open ) {
@@ -181,13 +184,12 @@ class Dialog<T extends HTMLElement = HTMLElement> extends React.Component<
181184 } ;
182185
183186 private initializeFocusTrap = ( ) : void => {
184- this . focusTrap = this . props . children && util . createFocusTrapInstance ( this . dialogElement . current ) ;
187+ this . focusTrap = this . props . children && createFocusTrapInstance ( this . dialogElement . current ! ) ;
185188 } ;
186189
187- get adapter ( ) : Partial < MDCDialogAdapter > {
190+ get adapter ( ) : MDCDialogAdapter {
188191 const strings = MDCDialogFoundation . strings ;
189192 const { closest, matches} = ponyfill ;
190- const { isScrollable, areTopsMisaligned} = util ;
191193 return {
192194 addClass : ( className : string ) => {
193195 const { classList} = this . state ;
@@ -258,8 +260,8 @@ class Dialog<T extends HTMLElement = HTMLElement> extends React.Component<
258260 } ;
259261
260262 handleInteraction = ( e : React . MouseEvent < HTMLElement > | React . KeyboardEvent < HTMLElement > ) : void =>
261- this . foundation . handleInteraction ( e ) ;
262- handleDocumentKeyDown = ( e : Event ) : void =>
263+ this . foundation . handleInteraction ( e . nativeEvent ) ;
264+ handleDocumentKeyDown = ( e : KeyboardEvent ) : void =>
263265 this . foundation . handleDocumentKeydown ( e ) ;
264266 handleLayout = ( ) : void => this . foundation . layout ( ) ;
265267
0 commit comments