From 9284632726a700e3a58648715d09d808ee4c50f1 Mon Sep 17 00:00:00 2001 From: Arthur Groupp Date: Sat, 19 Jan 2019 21:18:16 +0200 Subject: [PATCH 1/9] Added material__dom, material__list, modified material_drawer --- types/material__dom/index.d.ts | 32 ++++++ types/material__dom/ponyfill.d.ts | 4 + types/material__dom/tsconfig.json | 25 +++++ types/material__dom/tslint.json | 1 + types/material__drawer/adapter.d.ts | 105 ++++++++++++++++++ .../{persistent => }/constants.d.ts | 17 ++- .../dismissible/foundation.d.ts | 91 +++++++++++++++ types/material__drawer/focus-trap.d.ts | 82 ++++++++++++++ types/material__drawer/index.d.ts | 37 +++++- types/material__drawer/modal/foundation.d.ts | 55 +++++++++ .../persistent/foundation.d.ts | 26 ----- types/material__drawer/persistent/index.d.ts | 31 ------ types/material__drawer/slidable/adapter.d.ts | 59 ---------- .../material__drawer/slidable/constants.d.ts | 17 --- .../material__drawer/slidable/foundation.d.ts | 30 ----- types/material__drawer/slidable/index.d.ts | 19 ---- .../material__drawer/temporary/constants.d.ts | 32 ------ .../temporary/foundation.d.ts | 30 ----- types/material__drawer/temporary/index.d.ts | 31 ------ types/material__drawer/util.d.ts | 20 +--- types/material__list/adapter.d.ts | 51 +++++++++ types/material__list/constants.d.ts | 49 ++++++++ types/material__list/foundation.d.ts | 101 +++++++++++++++++ types/material__list/index.d.ts | 70 ++++++++++++ types/material__list/tsconfig.json | 27 +++++ types/material__list/tslint.json | 1 + 26 files changed, 738 insertions(+), 305 deletions(-) create mode 100644 types/material__dom/index.d.ts create mode 100644 types/material__dom/ponyfill.d.ts create mode 100644 types/material__dom/tsconfig.json create mode 100644 types/material__dom/tslint.json create mode 100644 types/material__drawer/adapter.d.ts rename types/material__drawer/{persistent => }/constants.d.ts (64%) create mode 100644 types/material__drawer/dismissible/foundation.d.ts create mode 100644 types/material__drawer/focus-trap.d.ts create mode 100644 types/material__drawer/modal/foundation.d.ts delete mode 100644 types/material__drawer/persistent/foundation.d.ts delete mode 100644 types/material__drawer/persistent/index.d.ts delete mode 100644 types/material__drawer/slidable/adapter.d.ts delete mode 100644 types/material__drawer/slidable/constants.d.ts delete mode 100644 types/material__drawer/slidable/foundation.d.ts delete mode 100644 types/material__drawer/slidable/index.d.ts delete mode 100644 types/material__drawer/temporary/constants.d.ts delete mode 100644 types/material__drawer/temporary/foundation.d.ts delete mode 100644 types/material__drawer/temporary/index.d.ts create mode 100644 types/material__list/adapter.d.ts create mode 100644 types/material__list/constants.d.ts create mode 100644 types/material__list/foundation.d.ts create mode 100644 types/material__list/index.d.ts create mode 100644 types/material__list/tsconfig.json create mode 100644 types/material__list/tslint.json diff --git a/types/material__dom/index.d.ts b/types/material__dom/index.d.ts new file mode 100644 index 0000000000..f751696f43 --- /dev/null +++ b/types/material__dom/index.d.ts @@ -0,0 +1,32 @@ +// Type definitions for Material Components Web 0.43 +// Project: https://material.io/components/ +// Definitions by: Arthur Groupp +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 + +/** + * @license + * Copyright 2018 Google Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +import * as ponyfill from './ponyfill'; + +export {ponyfill}; diff --git a/types/material__dom/ponyfill.d.ts b/types/material__dom/ponyfill.d.ts new file mode 100644 index 0000000000..9297caec64 --- /dev/null +++ b/types/material__dom/ponyfill.d.ts @@ -0,0 +1,4 @@ +declare function closest(element: Element, selector: string): Element; +declare function matches(element: Element, selector: string): boolean; + +export {closest, matches}; diff --git a/types/material__dom/tsconfig.json b/types/material__dom/tsconfig.json new file mode 100644 index 0000000000..3f76866c9d --- /dev/null +++ b/types/material__dom/tsconfig.json @@ -0,0 +1,25 @@ +{ + "files": [ + "index.d.ts", + "ponyfill.d.ts" + ], + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + } +} diff --git a/types/material__dom/tslint.json b/types/material__dom/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/material__dom/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/material__drawer/adapter.d.ts b/types/material__drawer/adapter.d.ts new file mode 100644 index 0000000000..c155a1ea02 --- /dev/null +++ b/types/material__drawer/adapter.d.ts @@ -0,0 +1,105 @@ +// Type definitions for Material Components Web 0.43 +// Project: https://material.io/components/ +// Definitions by: Arthur Groupp +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 + +/** + * @license + * Copyright 2018 Google Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +/* eslint no-unused-vars: [2, {"args": "none"}] */ + +/** + * Adapter for MDC Drawer + * + * Defines the shape of the adapter expected by the foundation. Implement this + * adapter to integrate the Drawer into your framework. See + * https://github.com/material-components/material-components-web/blob/master/docs/authoring-components.md + * for more information. + * + * @record + */ +declare class MDCDrawerAdapter { + /** + * Adds a class to the root Element. + * @param {string} className + */ + addClass(className: string): void; + + /** + * Removes a class from the root Element. + * @param {string} className + */ + removeClass(className: string): void; + + /** + * Returns true if the root Element contains the given class. + * @param {string} className + * @return {boolean} + */ + hasClass(className: string): boolean; + + /** + * @param {!Element} element target element to verify class name + * @param {string} className class name + */ + elementHasClass(element: Element, className: string): void; + + /** + * Saves the focus of currently active element. + */ + saveFocus(): void; + + /** + * Restores focus to element previously saved with 'saveFocus'. + */ + restoreFocus(): void; + + /** + * Focuses the active / selected navigation item. + */ + focusActiveNavigationItem(): void; + + /** + * Emits a custom event "MDCDrawer:closed" denoting the drawer has closed. + */ + notifyClose(): void; + + /** + * Emits a custom event "MDCDrawer:opened" denoting the drawer has opened. + */ + notifyOpen(): void; + + /** + * Traps focus on root element and focuses the active navigation element. + */ + trapFocus(): void; + + /** + * Releases focus trap from root element which was set by `trapFocus` + * and restores focus to where it was prior to calling `trapFocus`. + */ + releaseFocus(): void; +} + +export { MDCDrawerAdapter }; diff --git a/types/material__drawer/persistent/constants.d.ts b/types/material__drawer/constants.d.ts similarity index 64% rename from types/material__drawer/persistent/constants.d.ts rename to types/material__drawer/constants.d.ts index 84dcce7f3f..0f1bcc370a 100644 --- a/types/material__drawer/persistent/constants.d.ts +++ b/types/material__drawer/constants.d.ts @@ -17,14 +17,19 @@ import { MDCStrings } from 'material__base'; export interface cssClasses extends MDCStrings { - ROOT: 'mdc-drawer--persistent'; + ROOT: 'mdc-drawer'; + DISMISSIBLE: 'mdc-drawer--dismissible', + MODAL: 'mdc-drawer--modal', OPEN: 'mdc-drawer--open'; - ANIMATING: 'mdc-drawer--animating'; + ANIMATE: 'mdc-drawer--animate'; + OPENING: 'mdc-drawer--opening', + CLOSING: 'mdc-drawer--closing', } 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'; + APP_CONTENT_SELECTOR: '.mdc-drawer-app-content', + SCRIM_SELECTOR: '.mdc-drawer-scrim', + CLOSE_EVENT: 'MDCDrawer:closed', + OPEN_EVENT: 'MDCDrawer:opened', } + diff --git a/types/material__drawer/dismissible/foundation.d.ts b/types/material__drawer/dismissible/foundation.d.ts new file mode 100644 index 0000000000..9c6fd59eec --- /dev/null +++ b/types/material__drawer/dismissible/foundation.d.ts @@ -0,0 +1,91 @@ +// Type definitions for Material Components Web 0.43 +// Project: https://material.io/components/ +// Definitions by: Arthur Groupp +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 + +/** + * @license + * Copyright 2018 Google Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +import { MDCDrawerAdapter } from '../adapter'; +import MDCFoundation from 'material__base/foundation'; +import {cssClasses, strings} from '../constants'; + +/** + * @extends {MDCFoundation} + */ +declare class MDCDismissibleDrawerFoundation extends MDCFoundation { + /** @return enum {string} */ + static readonly strings: strings; + + /** @return enum {string} */ + static readonly cssClasses: cssClasses; + + static readonly defaultAdapter: MDCDrawerAdapter; + + constructor(adapter: MDCDrawerAdapter); + + destroy(): void; + + /** + * Function to open the drawer. + */ + open(): void; + + /** + * Function to close the drawer. + */ + close(): void; + + /** + * Returns true if drawer is in open state. + * @return {boolean} + */ + isOpen(): boolean; + + /** + * Returns true if drawer is animating open. + * @return {boolean} + */ + isOpening(): boolean; + + /** + * Returns true if drawer is animating closed. + * @return {boolean} + */ + isClosing(): boolean; + + /** + * Keydown handler to close drawer when key is escape. + * @param evt + */ + handleKeydown(evt: KeyboardEvent): void; + + /** + * Handles a transition end event on the root element. + * @param {!Event} evt + */ + handleTransitionEnd(evt: Event): void; +} + +export { MDCDismissibleDrawerFoundation }; diff --git a/types/material__drawer/focus-trap.d.ts b/types/material__drawer/focus-trap.d.ts new file mode 100644 index 0000000000..07a35a3cb5 --- /dev/null +++ b/types/material__drawer/focus-trap.d.ts @@ -0,0 +1,82 @@ +/** + * A DOM node, a selector string (which will be passed to + * `document.querySelector()` to find the DOM node), or a function that + * returns a DOM node. + */ +export type FocusTarget = HTMLElement | string | { (): HTMLElement }; + +export interface Options { + /** + * A function that will be called when the focus trap activates. + */ + onActivate?: () => void; + + /** + * A function that will be called when the focus trap deactivates. + */ + onDeactivate?: () => void; + + /** + * By default, when a focus trap is activated the first element in the + * focus trap's tab order will receive focus. With this option you can + * specify a different element to receive that initial focus. + */ + initialFocus?: FocusTarget; + + /** + * By default, an error will be thrown if the focus trap contains no + * elements in its tab order. With this option you can specify a + * fallback element to programmatically receive focus if no other + * tabbable elements are found. For example, you may want a popover's + * `
` to receive focus if the popover's content includes no + * tabbable elements. *Make sure the fallback element has a negative + * `tabindex` so it can be programmatically focused.* + */ + fallbackFocus?: FocusTarget; + + /** + * Default: `true`. If `false`, when the trap is deactivated, + * focus will *not* return to the element that had focus before activation. + */ + returnFocusOnDeactivate?: boolean; + + /** + * Default: `true`. If `false`, the `Escape` key will not trigger + * deactivation of the focus trap. This can be useful if you want + * to force the user to make a decision instead of allowing an easy + * way out. + */ + escapeDeactivates?: boolean; + + /** + * Default: `false`. If `true`, a click outside the focus trap will + * deactivate the focus trap and allow the click event to do its thing. + */ + clickOutsideDeactivates?: boolean; +} + +type ActivateOptions = Pick; + +interface DeactivateOptions extends Pick { + returnFocus?: boolean; +} + +export interface FocusTrap { + activate(activateOptions?: ActivateOptions): void; + deactivate(deactivateOptions?: DeactivateOptions): void; + pause(): void; + unpause(): void; +} + +/** + * Returns a new focus trap on `element`. + * + * @param element + * The element to be the focus trap, or a selector that will be used to + * find the element. + */ +export default function focusTrap( + element: HTMLElement | string, + userOptions?: Options +): FocusTrap; + diff --git a/types/material__drawer/index.d.ts b/types/material__drawer/index.d.ts index 63cd5d8fda..1e767f7a4a 100644 --- a/types/material__drawer/index.d.ts +++ b/types/material__drawer/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for Material Components Web 0.35 +// Type definitions for Material Components Web 0.43 // Project: https://material.io/components/ -// Definitions by: Brent Douglas , Collin Kostichuk +// Definitions by: Brent Douglas , Collin Kostichuk , Arthur Groupp // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 @@ -20,8 +20,33 @@ * 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'; -export { MDCSlidableDrawerAdapter } from './slidable'; -export { MDCTemporaryDrawer, MDCTemporaryDrawerFoundation } from './temporary'; -export { MDCPersistentDrawer, MDCPersistentDrawerFoundation } from './persistent'; -export { util }; +import createFocusTrap from './focus-trap'; +import { FocusTrap } from './focus-trap'; + +declare class MDCDrawer extends MDCComponent { + constructor(...args: any); + static attachTo(root: Element): MDCDrawer; + + /** + * Returns true if drawer is in the open position. + * @return {boolean} + */ + open: boolean; + + initialize(focusTrapFactory: FocusTrap, listFactory: MDCList): void; + + initialSyncWithDOM(): void; + + destroy(): void; + + getDefaultFoundation(): MDCDismissibleDrawerFoundation | MDCModalDrawerFoundation; +} + +export {MDCDrawer, MDCDismissibleDrawerFoundation, MDCModalDrawerFoundation, util}; diff --git a/types/material__drawer/modal/foundation.d.ts b/types/material__drawer/modal/foundation.d.ts new file mode 100644 index 0000000000..90a767363d --- /dev/null +++ b/types/material__drawer/modal/foundation.d.ts @@ -0,0 +1,55 @@ +// Type definitions for Material Components Web 0.43 +// Project: https://material.io/components/ +// Definitions by: Arthur Groupp +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 + +/** + * @license + * Copyright 2018 Google Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +import { MDCDrawerAdapter } from '../adapter'; +import { MDCDismissibleDrawerFoundation } from '../dismissible/foundation'; + +/** + * @extends {MDCDismissibleDrawerFoundation} + */ +declare class MDCModalDrawerFoundation extends MDCDismissibleDrawerFoundation { + /** + * Called when drawer finishes open animation. + * @override + */ + opened(): void; + + /** + * Called when drawer finishes close animation. + * @override + */ + closed(): void; + + /** + * Handles click event on scrim. + */ + handleScrimClick(): void; +} + +export { MDCModalDrawerFoundation }; 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/constants.d.ts b/types/material__drawer/slidable/constants.d.ts deleted file mode 100644 index bfae67fa90..0000000000 --- a/types/material__drawer/slidable/constants.d.ts +++ /dev/null @@ -1,17 +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 const FOCUSABLE_ELEMENTS: string; 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/util.d.ts b/types/material__drawer/util.d.ts index 052af84e48..1b3f7e3e4a 100644 --- a/types/material__drawer/util.d.ts +++ b/types/material__drawer/util.d.ts @@ -14,22 +14,6 @@ * limitations under the License. */ -// Remap touch events to pointer events, if the browser doesn't support touch events. -export function remapEvent(eventName: string, globalObj?: Window): string; +import { FocusTrap } from './focus-trap'; -// Choose the correct transform property to use on the current browser. -export function getTransformPropertyName(globalObj?: Window, forceRefresh?: boolean): string; - -// Determine whether the current browser supports CSS properties. -export function supportsCssCustomProperties(globalObj?: Window): boolean; - -// Determine whether the current browser supports passive event listeners, and if so, use them. -export function applyPassive(globalObj?: Window, forceRefresh?: boolean): boolean | { passive: boolean; }; - -// Save the tab state for an element. -// tslint:disable-next-line:void-return -export function saveElementTabState(el: Element): void; - -// Restore the tab state for an element, if it was saved. -// tslint:disable-next-line:void-return -export function restoreElementTabState(el: Element): void; +export function createFocusTrapInstance(surfaceEl: Element, focusTrapFactory: Function): FocusTrap diff --git a/types/material__list/adapter.d.ts b/types/material__list/adapter.d.ts new file mode 100644 index 0000000000..d53437d63b --- /dev/null +++ b/types/material__list/adapter.d.ts @@ -0,0 +1,51 @@ +declare class MDCListAdapter { + getListItemCount(): number; + getFocusedElementIndex(): number; + setAttributeForElementIndex(index: number, attribute: string, value: string): void; + removeAttributeForElementIndex(index: number, attribute: string): void; + addClassForElementIndex(index: number, className: string): void; + removeClassForElementIndex(index: number, className: string): void; + + /** + * Focuses list item at the index specified. + */ + focusItemAtIndex(index: number): void; + + /** + * Sets the tabindex to the value specified for all button/a element children of + * the list item at the index specified. + */ + setTabIndexForListItemChildren(listItemIndex: number, tabIndexValue: number): void; + + /** + * If the given element has an href, follows the link. + */ + followHref(ele: HTMLAnchorElement): void; + + /** + * Returns true if radio button is present at given list item index. + */ + hasRadioAtIndex(index: number): boolean + + /** + * Returns true if checkbox is present at given list item index. + */ + hasCheckboxAtIndex(index: number): boolean; + + /** + * Returns true if checkbox inside a list item is checked. + */ + isCheckboxCheckedAtIndex(index: number): boolean; + + /** + * Sets the checked status of checkbox or radio at given list item index. + */ + setCheckedCheckboxOrRadioAtIndex(index: number, isChecked: boolean): void; + + /** + * Returns true when the current focused element is inside list root. + */ + isFocusInsideList(): boolean; +} + +export { MDCListAdapter }; diff --git a/types/material__list/constants.d.ts b/types/material__list/constants.d.ts new file mode 100644 index 0000000000..f8d0d67273 --- /dev/null +++ b/types/material__list/constants.d.ts @@ -0,0 +1,49 @@ +/** + * @license + * Copyright 2018 Google Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +import { MDCStrings } from 'material__base'; + +export interface cssClasses extends MDCStrings { + ROOT: 'mdc-list'; + LIST_ITEM_CLASS: 'mdc-list-item'; + LIST_ITEM_SELECTED_CLASS: 'mdc-list-item--selected'; + LIST_ITEM_ACTIVATED_CLASS: 'mdc-list-item--activated'; +} + +export interface strings extends MDCStrings { + ARIA_ORIENTATION: 'aria-orientation'; + ARIA_ORIENTATION_HORIZONTAL: 'horizontal'; + ARIA_SELECTED: 'aria-selected'; + ARIA_CHECKED: 'aria-checked'; + ARIA_CHECKED_RADIO_SELECTOR: '[role="radio"][aria-checked="true"]'; + ARIA_ROLE_CHECKBOX_SELECTOR: '[role="checkbox"]'; + ARIA_CHECKED_CHECKBOX_SELECTOR: '[role="checkbox"][aria-checked="true"]'; + RADIO_SELECTOR: 'input[type="radio"]:not(:disabled)'; + CHECKBOX_SELECTOR: 'input[type="checkbox"]:not(:disabled)'; + CHECKBOX_RADIO_SELECTOR: 'input[type="checkbox"]:not(:disabled), input[type="radio"]:not(:disabled)'; + CHILD_ELEMENTS_TO_TOGGLE_TABINDEX: '.mdc-list-item button:not(:disabled), .mdc-list-item a'; + FOCUSABLE_CHILD_ELEMENTS: '.mdc-list-item button:not(:disabled), .mdc-list-item a, .mdc-list-item input[type="radio"]:not(:disabled), .mdc-list-item input[type="checkbox"]:not(:disabled)'; + ENABLED_ITEMS_SELECTOR: '.mdc-list-item:not(.mdc-list-item--disabled)'; +} + +export type Index = number | number[]; diff --git a/types/material__list/foundation.d.ts b/types/material__list/foundation.d.ts new file mode 100644 index 0000000000..203f0cf5e6 --- /dev/null +++ b/types/material__list/foundation.d.ts @@ -0,0 +1,101 @@ +import MDCFoundation from 'material__base/foundation'; +import { MDCListAdapter } from './adapter'; +import { strings, cssClasses, Index } from './constants'; + +declare const ELEMENTS_KEY_ALLOWED_IN: string[]; + +declare class MDCListFoundation extends MDCFoundation { + static readonly strings: strings; + static readonly cssClasses: cssClasses; + + /** + * {@see MDCListAdapter} for typing information on parameters and return + * types. + * @return {!MDCListAdapter} + */ + static readonly defaultAdapter: MDCListAdapter; + constructor(adapter: MDCListAdapter); + + layout(): void; + + /** + * Sets the private wrapFocus_ variable. + */ + setWrapFocus(value: boolean): void; + + /** + * Sets the isVertical_ private variable. + */ + setVerticalOrientation(value: boolean): void; + + /** + * Sets the isSingleSelectionList_ private variable. + */ + setSingleSelection(value: boolean): void; + + /** + * Sets the useActivatedClass_ private variable. + */ + setUseActivatedClass(useActivated: boolean): void; + + /** @return {!Index} */ + getSelectedIndex(): Index; + + /** @param {!Index} index */ + setSelectedIndex(index: Index): void; + + /** + * Focus in handler for the list items. + * @param evt + * @param {number} listItemIndex + */ + handleFocusIn(evt: Event, listItemIndex: number): void; + + /** + * Focus out handler for the list items. + * @param {Event} evt + * @param {number} listItemIndex + */ + handleFocusOut(evt: Event, listItemIndex: number): void; + + /** + * Key handler for the list. + * @param {Event} evt + * @param {boolean} isRootListItem + * @param {number} listItemIndex + */ + handleKeydown(evt: Event, isRootListItem: boolean, listItemIndex: number): void; + + /** + * Click handler for the list. + * @param {number} index + * @param {boolean} toggleCheckbox + */ + handleClick(index: number, toggleCheckbox: boolean): void; + + /** + * Focuses the next element on the list. + * @param {number} index + * @return {number} + */ + focusNextElement(index: number): number; + + /** + * Focuses the previous element on the list. + * @param {number} index + * @return {number} + */ + focusPrevElement(index: number): number; + + /** + * @return {number} + */ + focusFirstElement(): number; + + /** + * @return {number} + */ + focusLastElement(): number; +} + +export { MDCListFoundation }; diff --git a/types/material__list/index.d.ts b/types/material__list/index.d.ts new file mode 100644 index 0000000000..8e52b57aa9 --- /dev/null +++ b/types/material__list/index.d.ts @@ -0,0 +1,70 @@ +// Type definitions for Material Components Web 0.43 +// Project: https://material.io/components/ +// Definitions by: Arthur Groupp +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 + +/** + * @license + * Copyright 2016 Google Inc. + * + * 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 { MDCListFoundation } from './foundation'; +import { MDCListAdapter } from './adapter'; +import { matches } from 'material__dom/ponyfill'; +import { cssClasses, strings, Index } from './constants'; // eslint-disable-line no-unused-vars + +declare class MDCList { + /** @param {...?} args */ + constructor(...args: any); + + /** + * @param {!Element} root + * @return {!MDCList} + */ + static attachTo(root: Element): MDCList; + + destroy(): void; + + initialSyncWithDOM():void; + + layout(): void; + + /** + * Initialize selectedIndex value based on pre-selected checkbox list items, single selection or radio. + */ + initializeListType(): void; + + /** @param {boolean} value */ + vertical: boolean; + + /** @return Array*/ + readonly listElements: Element[]; + + /** @param {boolean} value */ + wrapFocus: boolean; + + /** @param {boolean} isSingleSelectionList */ + singleSelection: boolean; + + /** @return {!Index} */ + selectedIndex: Index; + + /** @return {!MDCListFoundation} */ + getDefaultFoundation(): MDCListFoundation; +} + +export {MDCList, MDCListFoundation}; diff --git a/types/material__list/tsconfig.json b/types/material__list/tsconfig.json new file mode 100644 index 0000000000..915f471053 --- /dev/null +++ b/types/material__list/tsconfig.json @@ -0,0 +1,27 @@ +{ + "files": [ + "index.d.ts", + "foundation.d.ts", + "adapter.d.ts", + "constants.d.ts" + ], + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + } +} diff --git a/types/material__list/tslint.json b/types/material__list/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/material__list/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From e3800b907a25ff68b0ba03265afae72ccdf083ee Mon Sep 17 00:00:00 2001 From: Arthur Groupp Date: Sat, 19 Jan 2019 21:20:44 +0200 Subject: [PATCH 2/9] added definitions header to material__drawer/constants --- types/material__drawer/constants.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/types/material__drawer/constants.d.ts b/types/material__drawer/constants.d.ts index 0f1bcc370a..f9f13946c9 100644 --- a/types/material__drawer/constants.d.ts +++ b/types/material__drawer/constants.d.ts @@ -1,3 +1,9 @@ +// Type definitions for Material Components Web 0.43 +// Project: https://material.io/components/ +// Definitions by: Arthur Groupp +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 + /** * Copyright 2016 Google Inc. All Rights Reserved. * From 4ad4ebbd080fa78ddbb80d9c213f526790c2f388 Mon Sep 17 00:00:00 2001 From: Arthur Groupp Date: Sat, 19 Jan 2019 21:28:32 +0200 Subject: [PATCH 3/9] updated tsconfig on material__drawer --- types/material__drawer/tsconfig.json | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/types/material__drawer/tsconfig.json b/types/material__drawer/tsconfig.json index 3e2a955de5..2f43565e69 100644 --- a/types/material__drawer/tsconfig.json +++ b/types/material__drawer/tsconfig.json @@ -1,16 +1,11 @@ { "files": [ - "persistent/constants.d.ts", - "persistent/index.d.ts", - "persistent/foundation.d.ts", - "slidable/constants.d.ts", - "slidable/adapter.d.ts", - "slidable/index.d.ts", - "slidable/foundation.d.ts", - "temporary/constants.d.ts", - "temporary/index.d.ts", - "temporary/foundation.d.ts", + "dismissible/foundation.d.ts", + "modal/foundation.d.ts", "util.d.ts", + "adapter.d.ts", + "constants.d.ts", + "focus-trap.d.ts", "index.d.ts" ], "compilerOptions": { @@ -32,4 +27,4 @@ "noEmit": true, "forceConsistentCasingInFileNames": true } -} \ No newline at end of file +} From 32c162f4b2e911fae835434f51c329194fa221a1 Mon Sep 17 00:00:00 2001 From: Arthur Groupp Date: Sat, 19 Jan 2019 21:41:18 +0200 Subject: [PATCH 4/9] fixes on material__dom and material__list according to test results --- types/material__dom/ponyfill.d.ts | 6 ++--- types/material__list/adapter.d.ts | 10 +++++--- types/material__list/constants.d.ts | 6 +++++ types/material__list/foundation.d.ts | 36 ++++++---------------------- types/material__list/index.d.ts | 26 ++++---------------- 5 files changed, 27 insertions(+), 57 deletions(-) diff --git a/types/material__dom/ponyfill.d.ts b/types/material__dom/ponyfill.d.ts index 9297caec64..9725e2704d 100644 --- a/types/material__dom/ponyfill.d.ts +++ b/types/material__dom/ponyfill.d.ts @@ -1,4 +1,2 @@ -declare function closest(element: Element, selector: string): Element; -declare function matches(element: Element, selector: string): boolean; - -export {closest, matches}; +export function closest(element: Element, selector: string): Element; +export function matches(element: Element, selector: string): boolean; diff --git a/types/material__list/adapter.d.ts b/types/material__list/adapter.d.ts index d53437d63b..fa72e379f5 100644 --- a/types/material__list/adapter.d.ts +++ b/types/material__list/adapter.d.ts @@ -1,4 +1,10 @@ -declare class MDCListAdapter { +// Type definitions for Material Components Web 0.43 +// Project: https://material.io/components/ +// Definitions by: Arthur Groupp +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.1 + +export class MDCListAdapter { getListItemCount(): number; getFocusedElementIndex(): number; setAttributeForElementIndex(index: number, attribute: string, value: string): void; @@ -47,5 +53,3 @@ declare class MDCListAdapter { */ isFocusInsideList(): boolean; } - -export { MDCListAdapter }; diff --git a/types/material__list/constants.d.ts b/types/material__list/constants.d.ts index f8d0d67273..7000b1f88a 100644 --- a/types/material__list/constants.d.ts +++ b/types/material__list/constants.d.ts @@ -1,3 +1,9 @@ +// Type definitions for Material Components Web 0.43 +// Project: https://material.io/components/ +// Definitions by: Arthur Groupp +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.1 + /** * @license * Copyright 2018 Google Inc. diff --git a/types/material__list/foundation.d.ts b/types/material__list/foundation.d.ts index 203f0cf5e6..18c186cb1a 100644 --- a/types/material__list/foundation.d.ts +++ b/types/material__list/foundation.d.ts @@ -1,18 +1,18 @@ +// Type definitions for Material Components Web 0.43 +// Project: https://material.io/components/ +// Definitions by: Arthur Groupp +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.1 + import MDCFoundation from 'material__base/foundation'; import { MDCListAdapter } from './adapter'; import { strings, cssClasses, Index } from './constants'; declare const ELEMENTS_KEY_ALLOWED_IN: string[]; -declare class MDCListFoundation extends MDCFoundation { +export class MDCListFoundation extends MDCFoundation { static readonly strings: strings; static readonly cssClasses: cssClasses; - - /** - * {@see MDCListAdapter} for typing information on parameters and return - * types. - * @return {!MDCListAdapter} - */ static readonly defaultAdapter: MDCListAdapter; constructor(adapter: MDCListAdapter); @@ -38,64 +38,42 @@ declare class MDCListFoundation extends MDCFoundation { */ setUseActivatedClass(useActivated: boolean): void; - /** @return {!Index} */ getSelectedIndex(): Index; - /** @param {!Index} index */ setSelectedIndex(index: Index): void; /** * Focus in handler for the list items. - * @param evt - * @param {number} listItemIndex */ handleFocusIn(evt: Event, listItemIndex: number): void; /** * Focus out handler for the list items. - * @param {Event} evt - * @param {number} listItemIndex */ handleFocusOut(evt: Event, listItemIndex: number): void; /** * Key handler for the list. - * @param {Event} evt - * @param {boolean} isRootListItem - * @param {number} listItemIndex */ handleKeydown(evt: Event, isRootListItem: boolean, listItemIndex: number): void; /** * Click handler for the list. - * @param {number} index - * @param {boolean} toggleCheckbox */ handleClick(index: number, toggleCheckbox: boolean): void; /** * Focuses the next element on the list. - * @param {number} index - * @return {number} */ focusNextElement(index: number): number; /** * Focuses the previous element on the list. - * @param {number} index - * @return {number} */ focusPrevElement(index: number): number; - /** - * @return {number} - */ focusFirstElement(): number; - /** - * @return {number} - */ focusLastElement(): number; } -export { MDCListFoundation }; diff --git a/types/material__list/index.d.ts b/types/material__list/index.d.ts index 8e52b57aa9..f1e8ad2313 100644 --- a/types/material__list/index.d.ts +++ b/types/material__list/index.d.ts @@ -2,7 +2,7 @@ // Project: https://material.io/components/ // Definitions by: Arthur Groupp // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 3.1 /** * @license @@ -22,19 +22,13 @@ */ import MDCComponent from 'material__base/component'; -import { MDCListFoundation } from './foundation'; +import { MDCListFoundation } from './foundation' import { MDCListAdapter } from './adapter'; import { matches } from 'material__dom/ponyfill'; import { cssClasses, strings, Index } from './constants'; // eslint-disable-line no-unused-vars -declare class MDCList { - /** @param {...?} args */ - constructor(...args: any); - - /** - * @param {!Element} root - * @return {!MDCList} - */ +export class MDCList { + constructor(...args: any[]); static attachTo(root: Element): MDCList; destroy(): void; @@ -48,23 +42,13 @@ declare class MDCList { */ initializeListType(): void; - /** @param {boolean} value */ vertical: boolean; - - /** @return Array*/ readonly listElements: Element[]; - - /** @param {boolean} value */ wrapFocus: boolean; - - /** @param {boolean} isSingleSelectionList */ singleSelection: boolean; - - /** @return {!Index} */ selectedIndex: Index; - /** @return {!MDCListFoundation} */ getDefaultFoundation(): MDCListFoundation; } -export {MDCList, MDCListFoundation}; +export { MDCListFoundation}; From 2a58c01ec05966309615e5b2fd09f2ba6a4ff9c8 Mon Sep 17 00:00:00 2001 From: Arthur Groupp Date: Sat, 19 Jan 2019 21:45:14 +0200 Subject: [PATCH 5/9] fixes in material__drawer according to test results --- types/material__drawer/adapter.d.ts | 14 ++------------ types/material__drawer/constants.d.ts | 2 +- .../dismissible/foundation.d.ts | 18 ++---------------- types/material__drawer/index.d.ts | 6 +++--- types/material__drawer/modal/foundation.d.ts | 11 ++--------- 5 files changed, 10 insertions(+), 41 deletions(-) diff --git a/types/material__drawer/adapter.d.ts b/types/material__drawer/adapter.d.ts index c155a1ea02..5b4da046f9 100644 --- a/types/material__drawer/adapter.d.ts +++ b/types/material__drawer/adapter.d.ts @@ -2,7 +2,7 @@ // Project: https://material.io/components/ // Definitions by: Arthur Groupp // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 3.1 /** * @license @@ -39,30 +39,22 @@ * * @record */ -declare class MDCDrawerAdapter { +export class MDCDrawerAdapter { /** * Adds a class to the root Element. - * @param {string} className */ addClass(className: string): void; /** * Removes a class from the root Element. - * @param {string} className */ removeClass(className: string): void; /** * Returns true if the root Element contains the given class. - * @param {string} className - * @return {boolean} */ hasClass(className: string): boolean; - /** - * @param {!Element} element target element to verify class name - * @param {string} className class name - */ elementHasClass(element: Element, className: string): void; /** @@ -101,5 +93,3 @@ declare class MDCDrawerAdapter { */ releaseFocus(): void; } - -export { MDCDrawerAdapter }; diff --git a/types/material__drawer/constants.d.ts b/types/material__drawer/constants.d.ts index f9f13946c9..bcb4e8131b 100644 --- a/types/material__drawer/constants.d.ts +++ b/types/material__drawer/constants.d.ts @@ -2,7 +2,7 @@ // Project: https://material.io/components/ // Definitions by: Arthur Groupp // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 3.1 /** * Copyright 2016 Google Inc. All Rights Reserved. diff --git a/types/material__drawer/dismissible/foundation.d.ts b/types/material__drawer/dismissible/foundation.d.ts index 9c6fd59eec..d95463f331 100644 --- a/types/material__drawer/dismissible/foundation.d.ts +++ b/types/material__drawer/dismissible/foundation.d.ts @@ -2,7 +2,7 @@ // Project: https://material.io/components/ // Definitions by: Arthur Groupp // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 3.1 /** * @license @@ -31,16 +31,9 @@ import { MDCDrawerAdapter } from '../adapter'; import MDCFoundation from 'material__base/foundation'; import {cssClasses, strings} from '../constants'; -/** - * @extends {MDCFoundation} - */ -declare class MDCDismissibleDrawerFoundation extends MDCFoundation { - /** @return enum {string} */ +export class MDCDismissibleDrawerFoundation extends MDCFoundation { static readonly strings: strings; - - /** @return enum {string} */ static readonly cssClasses: cssClasses; - static readonly defaultAdapter: MDCDrawerAdapter; constructor(adapter: MDCDrawerAdapter); @@ -59,33 +52,26 @@ declare class MDCDismissibleDrawerFoundation extends MDCFoundation, Collin Kostichuk , Arthur Groupp // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 3.1 /** * Copyright 2016 Google Inc. All Rights Reserved. @@ -30,7 +30,7 @@ import * as util from './util'; import createFocusTrap from './focus-trap'; import { FocusTrap } from './focus-trap'; -declare class MDCDrawer extends MDCComponent { +export class MDCDrawer extends MDCComponent { constructor(...args: any); static attachTo(root: Element): MDCDrawer; @@ -49,4 +49,4 @@ declare class MDCDrawer extends MDCComponent // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 3.1 /** * @license @@ -30,19 +30,14 @@ import { MDCDrawerAdapter } from '../adapter'; import { MDCDismissibleDrawerFoundation } from '../dismissible/foundation'; -/** - * @extends {MDCDismissibleDrawerFoundation} - */ -declare class MDCModalDrawerFoundation extends MDCDismissibleDrawerFoundation { +export class MDCModalDrawerFoundation extends MDCDismissibleDrawerFoundation { /** * Called when drawer finishes open animation. - * @override */ opened(): void; /** * Called when drawer finishes close animation. - * @override */ closed(): void; @@ -51,5 +46,3 @@ declare class MDCModalDrawerFoundation extends MDCDismissibleDrawerFoundation { */ handleScrimClick(): void; } - -export { MDCModalDrawerFoundation }; From a7543f58b773d4105cec7b0fef9aa35ef3b24710 Mon Sep 17 00:00:00 2001 From: Arthur Groupp Date: Sat, 19 Jan 2019 21:49:05 +0200 Subject: [PATCH 6/9] changed index in material-components-web to reflect changes --- types/material-components-web/index.d.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/types/material-components-web/index.d.ts b/types/material-components-web/index.d.ts index f1f9874f4b..0187f8e8ae 100644 --- a/types/material-components-web/index.d.ts +++ b/types/material-components-web/index.d.ts @@ -1,8 +1,8 @@ -// Type definitions for Material Components Web 0.35 +// Type definitions for Material Components Web 0.43 // Project: https://material.io/components/ -// Definitions by: Brent Douglas , Collin Kostichuk +// Definitions by: Brent Douglas , Collin Kostichuk , Arthur Groupp // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 3.1 /** * Copyright 2016 Google Inc. All Rights Reserved. @@ -25,6 +25,7 @@ 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'; @@ -32,6 +33,7 @@ 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'; From 9d6e56d80702ce5cf4155539d96a82ec2070a667 Mon Sep 17 00:00:00 2001 From: Arthur Groupp Date: Sat, 19 Jan 2019 21:55:08 +0200 Subject: [PATCH 7/9] removed TS version definition --- types/material-components-web/index.d.ts | 1 - types/material__dom/index.d.ts | 1 - types/material__dom/ponyfill.d.ts | 5 +++++ types/material__drawer/adapter.d.ts | 1 - types/material__drawer/constants.d.ts | 1 - types/material__drawer/dismissible/foundation.d.ts | 1 - types/material__drawer/index.d.ts | 1 - types/material__drawer/modal/foundation.d.ts | 1 - types/material__list/adapter.d.ts | 1 - types/material__list/constants.d.ts | 1 - types/material__list/foundation.d.ts | 1 - types/material__list/index.d.ts | 1 - 12 files changed, 5 insertions(+), 11 deletions(-) diff --git a/types/material-components-web/index.d.ts b/types/material-components-web/index.d.ts index 0187f8e8ae..47cd6715d5 100644 --- a/types/material-components-web/index.d.ts +++ b/types/material-components-web/index.d.ts @@ -2,7 +2,6 @@ // Project: https://material.io/components/ // Definitions by: Brent Douglas , Collin Kostichuk , Arthur Groupp // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 3.1 /** * Copyright 2016 Google Inc. All Rights Reserved. diff --git a/types/material__dom/index.d.ts b/types/material__dom/index.d.ts index f751696f43..cd545a4641 100644 --- a/types/material__dom/index.d.ts +++ b/types/material__dom/index.d.ts @@ -2,7 +2,6 @@ // Project: https://material.io/components/ // Definitions by: Arthur Groupp // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 /** * @license diff --git a/types/material__dom/ponyfill.d.ts b/types/material__dom/ponyfill.d.ts index 9725e2704d..bac16bd374 100644 --- a/types/material__dom/ponyfill.d.ts +++ b/types/material__dom/ponyfill.d.ts @@ -1,2 +1,7 @@ +// Type definitions for Material Components Web 0.43 +// Project: https://material.io/components/ +// Definitions by: Arthur Groupp +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + export function closest(element: Element, selector: string): Element; export function matches(element: Element, selector: string): boolean; diff --git a/types/material__drawer/adapter.d.ts b/types/material__drawer/adapter.d.ts index 5b4da046f9..0f80d39967 100644 --- a/types/material__drawer/adapter.d.ts +++ b/types/material__drawer/adapter.d.ts @@ -2,7 +2,6 @@ // Project: https://material.io/components/ // Definitions by: Arthur Groupp // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 3.1 /** * @license diff --git a/types/material__drawer/constants.d.ts b/types/material__drawer/constants.d.ts index bcb4e8131b..aa179c5a9c 100644 --- a/types/material__drawer/constants.d.ts +++ b/types/material__drawer/constants.d.ts @@ -2,7 +2,6 @@ // Project: https://material.io/components/ // Definitions by: Arthur Groupp // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 3.1 /** * Copyright 2016 Google Inc. All Rights Reserved. diff --git a/types/material__drawer/dismissible/foundation.d.ts b/types/material__drawer/dismissible/foundation.d.ts index d95463f331..addfadfbb0 100644 --- a/types/material__drawer/dismissible/foundation.d.ts +++ b/types/material__drawer/dismissible/foundation.d.ts @@ -2,7 +2,6 @@ // Project: https://material.io/components/ // Definitions by: Arthur Groupp // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 3.1 /** * @license diff --git a/types/material__drawer/index.d.ts b/types/material__drawer/index.d.ts index 4cdf6e19e4..e353260ed5 100644 --- a/types/material__drawer/index.d.ts +++ b/types/material__drawer/index.d.ts @@ -2,7 +2,6 @@ // Project: https://material.io/components/ // Definitions by: Brent Douglas , Collin Kostichuk , Arthur Groupp // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 3.1 /** * Copyright 2016 Google Inc. All Rights Reserved. diff --git a/types/material__drawer/modal/foundation.d.ts b/types/material__drawer/modal/foundation.d.ts index ad059c6d94..ee83dfb17f 100644 --- a/types/material__drawer/modal/foundation.d.ts +++ b/types/material__drawer/modal/foundation.d.ts @@ -2,7 +2,6 @@ // Project: https://material.io/components/ // Definitions by: Arthur Groupp // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 3.1 /** * @license diff --git a/types/material__list/adapter.d.ts b/types/material__list/adapter.d.ts index fa72e379f5..be539dd260 100644 --- a/types/material__list/adapter.d.ts +++ b/types/material__list/adapter.d.ts @@ -2,7 +2,6 @@ // Project: https://material.io/components/ // Definitions by: Arthur Groupp // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 3.1 export class MDCListAdapter { getListItemCount(): number; diff --git a/types/material__list/constants.d.ts b/types/material__list/constants.d.ts index 7000b1f88a..aad43f0ccb 100644 --- a/types/material__list/constants.d.ts +++ b/types/material__list/constants.d.ts @@ -2,7 +2,6 @@ // Project: https://material.io/components/ // Definitions by: Arthur Groupp // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 3.1 /** * @license diff --git a/types/material__list/foundation.d.ts b/types/material__list/foundation.d.ts index 18c186cb1a..0c54620d46 100644 --- a/types/material__list/foundation.d.ts +++ b/types/material__list/foundation.d.ts @@ -2,7 +2,6 @@ // Project: https://material.io/components/ // Definitions by: Arthur Groupp // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 3.1 import MDCFoundation from 'material__base/foundation'; import { MDCListAdapter } from './adapter'; diff --git a/types/material__list/index.d.ts b/types/material__list/index.d.ts index f1e8ad2313..69caf8ada3 100644 --- a/types/material__list/index.d.ts +++ b/types/material__list/index.d.ts @@ -2,7 +2,6 @@ // Project: https://material.io/components/ // Definitions by: Arthur Groupp // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 3.1 /** * @license From a3dcbbc853743fa7885f406b1208691cd7c5b661 Mon Sep 17 00:00:00 2001 From: Arthur Groupp Date: Sat, 19 Jan 2019 22:13:33 +0200 Subject: [PATCH 8/9] discard ts version change --- types/material-components-web/index.d.ts | 1 + types/material__dom/index.d.ts | 1 + types/material__drawer/index.d.ts | 1 + types/material__list/index.d.ts | 1 + 4 files changed, 4 insertions(+) diff --git a/types/material-components-web/index.d.ts b/types/material-components-web/index.d.ts index 47cd6715d5..9e3ca568f1 100644 --- a/types/material-components-web/index.d.ts +++ b/types/material-components-web/index.d.ts @@ -2,6 +2,7 @@ // 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. diff --git a/types/material__dom/index.d.ts b/types/material__dom/index.d.ts index cd545a4641..f751696f43 100644 --- a/types/material__dom/index.d.ts +++ b/types/material__dom/index.d.ts @@ -2,6 +2,7 @@ // Project: https://material.io/components/ // Definitions by: Arthur Groupp // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 /** * @license diff --git a/types/material__drawer/index.d.ts b/types/material__drawer/index.d.ts index e353260ed5..2d28742f82 100644 --- a/types/material__drawer/index.d.ts +++ b/types/material__drawer/index.d.ts @@ -2,6 +2,7 @@ // 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. diff --git a/types/material__list/index.d.ts b/types/material__list/index.d.ts index 69caf8ada3..e76533a531 100644 --- a/types/material__list/index.d.ts +++ b/types/material__list/index.d.ts @@ -2,6 +2,7 @@ // Project: https://material.io/components/ // Definitions by: Arthur Groupp // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 /** * @license From 90cb1caaf70b981a3ebc0047a0f37f25f085cbc2 Mon Sep 17 00:00:00 2001 From: Arthur Groupp Date: Sat, 19 Jan 2019 22:31:19 +0200 Subject: [PATCH 9/9] fixes on material according to test results --- types/material__dom/ponyfill.d.ts | 5 ----- types/material__drawer/adapter.d.ts | 5 ----- types/material__drawer/constants.d.ts | 22 +++++++------------ .../dismissible/foundation.d.ts | 7 +----- types/material__drawer/focus-trap.d.ts | 5 ++--- types/material__drawer/index.d.ts | 6 ++--- types/material__drawer/modal/foundation.d.ts | 5 ----- types/material__drawer/util.d.ts | 2 +- types/material__list/adapter.d.ts | 7 +----- types/material__list/constants.d.ts | 5 ----- types/material__list/foundation.d.ts | 8 +------ types/material__list/index.d.ts | 4 ++-- 12 files changed, 18 insertions(+), 63 deletions(-) diff --git a/types/material__dom/ponyfill.d.ts b/types/material__dom/ponyfill.d.ts index bac16bd374..9725e2704d 100644 --- a/types/material__dom/ponyfill.d.ts +++ b/types/material__dom/ponyfill.d.ts @@ -1,7 +1,2 @@ -// Type definitions for Material Components Web 0.43 -// Project: https://material.io/components/ -// Definitions by: Arthur Groupp -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - export function closest(element: Element, selector: string): Element; export function matches(element: Element, selector: string): boolean; diff --git a/types/material__drawer/adapter.d.ts b/types/material__drawer/adapter.d.ts index 0f80d39967..84413fe004 100644 --- a/types/material__drawer/adapter.d.ts +++ b/types/material__drawer/adapter.d.ts @@ -1,8 +1,3 @@ -// Type definitions for Material Components Web 0.43 -// Project: https://material.io/components/ -// Definitions by: Arthur Groupp -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - /** * @license * Copyright 2018 Google Inc. diff --git a/types/material__drawer/constants.d.ts b/types/material__drawer/constants.d.ts index aa179c5a9c..d094c3240b 100644 --- a/types/material__drawer/constants.d.ts +++ b/types/material__drawer/constants.d.ts @@ -1,8 +1,3 @@ -// Type definitions for Material Components Web 0.43 -// Project: https://material.io/components/ -// Definitions by: Arthur Groupp -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - /** * Copyright 2016 Google Inc. All Rights Reserved. * @@ -23,18 +18,17 @@ import { MDCStrings } from 'material__base'; export interface cssClasses extends MDCStrings { ROOT: 'mdc-drawer'; - DISMISSIBLE: 'mdc-drawer--dismissible', - MODAL: 'mdc-drawer--modal', + DISMISSIBLE: 'mdc-drawer--dismissible'; + MODAL: 'mdc-drawer--modal'; OPEN: 'mdc-drawer--open'; ANIMATE: 'mdc-drawer--animate'; - OPENING: 'mdc-drawer--opening', - CLOSING: 'mdc-drawer--closing', + OPENING: 'mdc-drawer--opening'; + CLOSING: 'mdc-drawer--closing'; } export interface strings extends MDCStrings { - APP_CONTENT_SELECTOR: '.mdc-drawer-app-content', - SCRIM_SELECTOR: '.mdc-drawer-scrim', - CLOSE_EVENT: 'MDCDrawer:closed', - OPEN_EVENT: 'MDCDrawer:opened', + APP_CONTENT_SELECTOR: '.mdc-drawer-app-content'; + SCRIM_SELECTOR: '.mdc-drawer-scrim'; + CLOSE_EVENT: 'MDCDrawer:closed'; + OPEN_EVENT: 'MDCDrawer:opened'; } - diff --git a/types/material__drawer/dismissible/foundation.d.ts b/types/material__drawer/dismissible/foundation.d.ts index addfadfbb0..4bee751d86 100644 --- a/types/material__drawer/dismissible/foundation.d.ts +++ b/types/material__drawer/dismissible/foundation.d.ts @@ -1,8 +1,3 @@ -// Type definitions for Material Components Web 0.43 -// Project: https://material.io/components/ -// Definitions by: Arthur Groupp -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - /** * @license * Copyright 2018 Google Inc. @@ -28,7 +23,7 @@ import { MDCDrawerAdapter } from '../adapter'; import MDCFoundation from 'material__base/foundation'; -import {cssClasses, strings} from '../constants'; +import { cssClasses, strings } from '../constants'; export class MDCDismissibleDrawerFoundation extends MDCFoundation { static readonly strings: strings; diff --git a/types/material__drawer/focus-trap.d.ts b/types/material__drawer/focus-trap.d.ts index 07a35a3cb5..61ceb8fb08 100644 --- a/types/material__drawer/focus-trap.d.ts +++ b/types/material__drawer/focus-trap.d.ts @@ -55,9 +55,9 @@ export interface Options { clickOutsideDeactivates?: boolean; } -type ActivateOptions = Pick; +export type ActivateOptions = Pick; -interface DeactivateOptions extends Pick { +export interface DeactivateOptions extends Pick { returnFocus?: boolean; } @@ -79,4 +79,3 @@ export default function focusTrap( element: HTMLElement | string, userOptions?: Options ): FocusTrap; - diff --git a/types/material__drawer/index.d.ts b/types/material__drawer/index.d.ts index 2d28742f82..9980f1c304 100644 --- a/types/material__drawer/index.d.ts +++ b/types/material__drawer/index.d.ts @@ -27,16 +27,14 @@ import { MDCDrawerAdapter } from './adapter'; import { MDCList, MDCListFoundation } from 'material__list/index'; import { strings } from './constants'; import * as util from './util'; -import createFocusTrap from './focus-trap'; -import { FocusTrap } from './focus-trap'; +import createFocusTrap, { FocusTrap } from './focus-trap'; export class MDCDrawer extends MDCComponent { - constructor(...args: any); + constructor(...args: any[]); static attachTo(root: Element): MDCDrawer; /** * Returns true if drawer is in the open position. - * @return {boolean} */ open: boolean; diff --git a/types/material__drawer/modal/foundation.d.ts b/types/material__drawer/modal/foundation.d.ts index ee83dfb17f..36ffb30e08 100644 --- a/types/material__drawer/modal/foundation.d.ts +++ b/types/material__drawer/modal/foundation.d.ts @@ -1,8 +1,3 @@ -// Type definitions for Material Components Web 0.43 -// Project: https://material.io/components/ -// Definitions by: Arthur Groupp -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - /** * @license * Copyright 2018 Google Inc. diff --git a/types/material__drawer/util.d.ts b/types/material__drawer/util.d.ts index 1b3f7e3e4a..fcce26d915 100644 --- a/types/material__drawer/util.d.ts +++ b/types/material__drawer/util.d.ts @@ -16,4 +16,4 @@ import { FocusTrap } from './focus-trap'; -export function createFocusTrapInstance(surfaceEl: Element, focusTrapFactory: Function): FocusTrap +export function createFocusTrapInstance(surfaceEl: Element, focusTrapFactory: () => FocusTrap): FocusTrap; diff --git a/types/material__list/adapter.d.ts b/types/material__list/adapter.d.ts index be539dd260..3a1b5522d8 100644 --- a/types/material__list/adapter.d.ts +++ b/types/material__list/adapter.d.ts @@ -1,8 +1,3 @@ -// Type definitions for Material Components Web 0.43 -// Project: https://material.io/components/ -// Definitions by: Arthur Groupp -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - export class MDCListAdapter { getListItemCount(): number; getFocusedElementIndex(): number; @@ -30,7 +25,7 @@ export class MDCListAdapter { /** * Returns true if radio button is present at given list item index. */ - hasRadioAtIndex(index: number): boolean + hasRadioAtIndex(index: number): boolean; /** * Returns true if checkbox is present at given list item index. diff --git a/types/material__list/constants.d.ts b/types/material__list/constants.d.ts index aad43f0ccb..f8d0d67273 100644 --- a/types/material__list/constants.d.ts +++ b/types/material__list/constants.d.ts @@ -1,8 +1,3 @@ -// Type definitions for Material Components Web 0.43 -// Project: https://material.io/components/ -// Definitions by: Arthur Groupp -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - /** * @license * Copyright 2018 Google Inc. diff --git a/types/material__list/foundation.d.ts b/types/material__list/foundation.d.ts index 0c54620d46..3823d796ca 100644 --- a/types/material__list/foundation.d.ts +++ b/types/material__list/foundation.d.ts @@ -1,13 +1,8 @@ -// Type definitions for Material Components Web 0.43 -// Project: https://material.io/components/ -// Definitions by: Arthur Groupp -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - import MDCFoundation from 'material__base/foundation'; import { MDCListAdapter } from './adapter'; import { strings, cssClasses, Index } from './constants'; -declare const ELEMENTS_KEY_ALLOWED_IN: string[]; +export const ELEMENTS_KEY_ALLOWED_IN: string[]; export class MDCListFoundation extends MDCFoundation { static readonly strings: strings; @@ -75,4 +70,3 @@ export class MDCListFoundation extends MDCFoundation { focusLastElement(): number; } - diff --git a/types/material__list/index.d.ts b/types/material__list/index.d.ts index e76533a531..22adf832f3 100644 --- a/types/material__list/index.d.ts +++ b/types/material__list/index.d.ts @@ -22,7 +22,7 @@ */ import MDCComponent from 'material__base/component'; -import { MDCListFoundation } from './foundation' +import { MDCListFoundation } from './foundation'; import { MDCListAdapter } from './adapter'; import { matches } from 'material__dom/ponyfill'; import { cssClasses, strings, Index } from './constants'; // eslint-disable-line no-unused-vars @@ -33,7 +33,7 @@ export class MDCList { destroy(): void; - initialSyncWithDOM():void; + initialSyncWithDOM(): void; layout(): void;