diff --git a/types/material-components-web/index.d.ts b/types/material-components-web/index.d.ts new file mode 100644 index 0000000000..9e3ca568f1 --- /dev/null +++ b/types/material-components-web/index.d.ts @@ -0,0 +1,75 @@ +// Type definitions for Material Components Web 0.43 +// Project: https://material.io/components/ +// Definitions by: Brent Douglas , Collin Kostichuk , Arthur Groupp +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 + +/** + * Copyright 2016 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import autoInit from 'material__auto-init'; +import * as base from 'material__base'; +import * as checkbox from 'material__checkbox'; +import * as chips from 'material__chips'; +import * as dialog from 'material__dialog'; +import * as dom from 'material__dom'; +import * as drawer from 'material__drawer'; +import * as floatingLabel from 'material__floating-label'; +import * as formField from 'material__form-field'; +import * as gridList from 'material__grid-list'; +import * as iconToggle from 'material__icon-toggle'; +import * as linearProgress from 'material__linear-progress'; +import * as lineRipple from 'material__line-ripple'; +import * as list from 'material__list'; +import * as menu from 'material__menu'; +import * as notchedOutline from 'material__notched-outline'; +import * as radio from 'material__radio'; +import * as ripple from 'material__ripple'; +import * as select from 'material__select'; +import * as selectionControl from 'material__selection-control'; +import * as slider from 'material__slider'; +import * as snackbar from 'material__snackbar'; +import * as tabs from 'material__tabs'; +import * as textField from 'material__textfield'; +import * as toolbar from 'material__toolbar'; +import * as topAppBar from 'material__top-app-bar'; +// Export all components. +export { + autoInit, + base, + checkbox, + chips, + dialog, + drawer, + floatingLabel, + formField, + gridList, + iconToggle, + lineRipple, + linearProgress, + menu, + notchedOutline, + radio, + ripple, + select, + selectionControl, + slider, + snackbar, + tabs, + textField, + toolbar, + topAppBar +}; diff --git a/types/material__drawer/index.d.ts b/types/material__drawer/index.d.ts new file mode 100644 index 0000000000..9980f1c304 --- /dev/null +++ b/types/material__drawer/index.d.ts @@ -0,0 +1,50 @@ +// Type definitions for Material Components Web 0.43 +// Project: https://material.io/components/ +// Definitions by: Brent Douglas , Collin Kostichuk , Arthur Groupp +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 + +/** + * Copyright 2016 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import MDCComponent from 'material__base/component'; +import { MDCDismissibleDrawerFoundation } from './dismissible/foundation'; +import { MDCModalDrawerFoundation } from './modal/foundation'; +import { MDCDrawerAdapter } from './adapter'; +import { MDCList, MDCListFoundation } from 'material__list/index'; +import { strings } from './constants'; +import * as util from './util'; +import createFocusTrap, { FocusTrap } from './focus-trap'; + +export class MDCDrawer extends MDCComponent { + constructor(...args: any[]); + static attachTo(root: Element): MDCDrawer; + + /** + * Returns true if drawer is in the open position. + */ + open: boolean; + + initialize(focusTrapFactory: FocusTrap, listFactory: MDCList): void; + + initialSyncWithDOM(): void; + + destroy(): void; + + getDefaultFoundation(): MDCDismissibleDrawerFoundation | MDCModalDrawerFoundation; +} + +export { MDCDismissibleDrawerFoundation, MDCModalDrawerFoundation, util }; diff --git a/types/material__drawer/persistent/constants.d.ts b/types/material__drawer/persistent/constants.d.ts deleted file mode 100644 index 84dcce7f3f..0000000000 --- a/types/material__drawer/persistent/constants.d.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { MDCStrings } from 'material__base'; - -export interface cssClasses extends MDCStrings { - ROOT: 'mdc-drawer--persistent'; - OPEN: 'mdc-drawer--open'; - ANIMATING: 'mdc-drawer--animating'; -} - -export interface strings extends MDCStrings { - DRAWER_SELECTOR: '.mdc-drawer--persistent .mdc-drawer__drawer'; - FOCUSABLE_ELEMENTS: 'a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, [tabindex], [contenteditable]'; - OPEN_EVENT: 'MDCPersistentDrawer:open'; - CLOSE_EVENT: 'MDCPersistentDrawer:close'; -} diff --git a/types/material__drawer/persistent/foundation.d.ts b/types/material__drawer/persistent/foundation.d.ts deleted file mode 100644 index ce596f3c23..0000000000 --- a/types/material__drawer/persistent/foundation.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { MDCSlidableDrawerAdapter, MDCSlidableDrawerFoundation } from '../slidable'; -import { cssClasses, strings } from './constants'; - -export default class MDCPersistentDrawerFoundation extends MDCSlidableDrawerFoundation { - static readonly cssClasses: cssClasses; - - static readonly strings: strings; - - static readonly defaultAdapter: MDCSlidableDrawerAdapter; -} diff --git a/types/material__drawer/persistent/index.d.ts b/types/material__drawer/persistent/index.d.ts deleted file mode 100644 index 920258b2aa..0000000000 --- a/types/material__drawer/persistent/index.d.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { MDCComponent } from 'material__base'; -import MDCPersistentDrawerFoundation from './foundation'; -import { MDCSlidableDrawerAdapter } from '../slidable'; -import * as util from '../util'; - -export {MDCSlidableDrawerAdapter, MDCPersistentDrawerFoundation, util}; - -export class MDCPersistentDrawer extends MDCComponent { - static attachTo(root: Element): MDCPersistentDrawer; - - open: boolean; - - // Return the drawer element inside the component. - readonly drawer: Element | null; -} diff --git a/types/material__drawer/slidable/adapter.d.ts b/types/material__drawer/slidable/adapter.d.ts deleted file mode 100644 index 3659742558..0000000000 --- a/types/material__drawer/slidable/adapter.d.ts +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export interface MDCSlidableDrawerAdapter { - addClass(className: string): void; - - removeClass(className: string): void; - - hasClass(className: string): void; - - hasNecessaryDom(): boolean; - - registerInteractionHandler(evt: string, handler: EventListener): void; - - deregisterInteractionHandler(evt: string, handler: EventListener): void; - - registerDrawerInteractionHandler(evt: string, handler: EventListener): void; - - deregisterDrawerInteractionHandler(evt: string, handler: EventListener): void; - - registerTransitionEndHandler(handler: EventListener): void; - - deregisterTransitionEndHandler(handler: EventListener): void; - - registerDocumentKeydownHandler(handler: EventListener): void; - - deregisterDocumentKeydownHandler(handler: EventListener): void; - - setTranslateX(value: number | null): void; - - getFocusableElements(): NodeList; - - saveElementTabState(el: Element): void; - - restoreElementTabState(el: Element): void; - - makeElementUntabbable(el: Element): void; - - notifyOpen(): void; - - notifyClose(): void; - - isRtl(): boolean; - - getDrawerWidth(): number; -} diff --git a/types/material__drawer/slidable/foundation.d.ts b/types/material__drawer/slidable/foundation.d.ts deleted file mode 100644 index 60995e0a95..0000000000 --- a/types/material__drawer/slidable/foundation.d.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { MDCFoundation } from 'material__base'; -import { MDCSlidableDrawerAdapter } from './adapter'; - -export class MDCSlidableDrawerFoundation extends MDCFoundation { - static readonly defaultAdapter: MDCSlidableDrawerAdapter; - - constructor(adapter: MDCSlidableDrawerAdapter, rootCssClass: string, animatingCssClass: string, openCssClass: string); - - open(): void; - - close(): void; - - isOpen(): boolean; -} diff --git a/types/material__drawer/slidable/index.d.ts b/types/material__drawer/slidable/index.d.ts deleted file mode 100644 index a41d83ad4b..0000000000 --- a/types/material__drawer/slidable/index.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export { FOCUSABLE_ELEMENTS } from './constants'; -export { MDCSlidableDrawerFoundation } from './foundation'; -export { MDCSlidableDrawerAdapter } from './adapter'; diff --git a/types/material__drawer/temporary/constants.d.ts b/types/material__drawer/temporary/constants.d.ts deleted file mode 100644 index ef00408a31..0000000000 --- a/types/material__drawer/temporary/constants.d.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { MDCStrings } from 'material__base'; - -export interface cssClasses extends MDCStrings { - ROOT: 'mdc-drawer--temporary'; - OPEN: 'mdc-drawer--open'; - ANIMATING: 'mdc-drawer--animating'; - SCROLL_LOCK: 'mdc-drawer-scroll-lock'; -} - -export interface strings extends MDCStrings { - DRAWER_SELECTOR: '.mdc-drawer--temporary .mdc-drawer__drawer'; - OPACITY_VAR_NAME: '--mdc-temporary-drawer-opacity'; - FOCUSABLE_ELEMENTS: 'a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, [tabindex], [contenteditable]'; - OPEN_EVENT: 'MDCTemporaryDrawer:open'; - CLOSE_EVENT: 'MDCTemporaryDrawer:close'; -} diff --git a/types/material__drawer/temporary/foundation.d.ts b/types/material__drawer/temporary/foundation.d.ts deleted file mode 100644 index adb78d0296..0000000000 --- a/types/material__drawer/temporary/foundation.d.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { MDCSlidableDrawerFoundation, MDCSlidableDrawerAdapter } from '../slidable'; -import { cssClasses, strings } from './constants'; - -export default class MDCTemporaryDrawerFoundation extends MDCSlidableDrawerFoundation { - static readonly cssClasses: cssClasses; - - static readonly strings: strings; - - static readonly defaultAdapter: MDCSlidableDrawerAdapter; - - open(): void; - - close(): void; -} diff --git a/types/material__drawer/temporary/index.d.ts b/types/material__drawer/temporary/index.d.ts deleted file mode 100644 index c6dd1c9928..0000000000 --- a/types/material__drawer/temporary/index.d.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { MDCComponent } from 'material__base'; -import MDCTemporaryDrawerFoundation from './foundation'; -import { MDCSlidableDrawerAdapter } from '../slidable'; -import * as util from '../util'; - -export {MDCSlidableDrawerAdapter, MDCTemporaryDrawerFoundation, util}; - -export class MDCTemporaryDrawer extends MDCComponent { - static attachTo(root: Element): MDCTemporaryDrawer; - - open: boolean; - - /* Return the drawer element inside the component. */ - readonly drawer: Element | null; -} diff --git a/types/material__drawer/slidable/constants.d.ts b/types/material__drawer/util.d.ts similarity index 80% rename from types/material__drawer/slidable/constants.d.ts rename to types/material__drawer/util.d.ts index bfae67fa90..fcce26d915 100644 --- a/types/material__drawer/slidable/constants.d.ts +++ b/types/material__drawer/util.d.ts @@ -14,4 +14,6 @@ * limitations under the License. */ -export const FOCUSABLE_ELEMENTS: string; +import { FocusTrap } from './focus-trap'; + +export function createFocusTrapInstance(surfaceEl: Element, focusTrapFactory: () => FocusTrap): FocusTrap;