diff --git a/types/material-components-web/index.d.ts b/types/material-components-web/index.d.ts deleted file mode 100644 index f1f9874f4b..0000000000 --- a/types/material-components-web/index.d.ts +++ /dev/null @@ -1,73 +0,0 @@ -// Type definitions for Material Components Web 0.35 -// Project: https://material.io/components/ -// Definitions by: Brent Douglas , Collin Kostichuk -// 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 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 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__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..9725e2704d --- /dev/null +++ b/types/material__dom/ponyfill.d.ts @@ -0,0 +1,2 @@ +export function closest(element: Element, selector: string): Element; +export function matches(element: Element, selector: string): boolean; 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..84413fe004 --- /dev/null +++ b/types/material__drawer/adapter.d.ts @@ -0,0 +1,89 @@ +/** + * @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 + */ +export class MDCDrawerAdapter { + /** + * Adds a class to the root Element. + */ + addClass(className: string): void; + + /** + * Removes a class from the root Element. + */ + removeClass(className: string): void; + + /** + * Returns true if the root Element contains the given class. + */ + hasClass(className: string): boolean; + + 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; +} diff --git a/types/material__drawer/constants.d.ts b/types/material__drawer/constants.d.ts new file mode 100644 index 0000000000..d094c3240b --- /dev/null +++ b/types/material__drawer/constants.d.ts @@ -0,0 +1,34 @@ +/** + * 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'; + DISMISSIBLE: 'mdc-drawer--dismissible'; + MODAL: 'mdc-drawer--modal'; + OPEN: 'mdc-drawer--open'; + ANIMATE: 'mdc-drawer--animate'; + 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'; +} diff --git a/types/material__drawer/dismissible/foundation.d.ts b/types/material__drawer/dismissible/foundation.d.ts new file mode 100644 index 0000000000..4bee751d86 --- /dev/null +++ b/types/material__drawer/dismissible/foundation.d.ts @@ -0,0 +1,71 @@ +/** + * @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'; + +export class MDCDismissibleDrawerFoundation extends MDCFoundation { + static readonly strings: strings; + 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. + */ + isOpen(): boolean; + + /** + * Returns true if drawer is animating open. + */ + isOpening(): boolean; + + /** + * Returns true if drawer is animating closed. + */ + isClosing(): boolean; + + /** + * Keydown handler to close drawer when key is escape. + */ + handleKeydown(evt: KeyboardEvent): void; + + /** + * Handles a transition end event on the root element. + */ + handleTransitionEnd(evt: Event): void; +} diff --git a/types/material__drawer/focus-trap.d.ts b/types/material__drawer/focus-trap.d.ts new file mode 100644 index 0000000000..61ceb8fb08 --- /dev/null +++ b/types/material__drawer/focus-trap.d.ts @@ -0,0 +1,81 @@ +/** + * 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; +} + +export type ActivateOptions = Pick; + +export 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 deleted file mode 100644 index 63cd5d8fda..0000000000 --- a/types/material__drawer/index.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -// Type definitions for Material Components Web 0.35 -// Project: https://material.io/components/ -// Definitions by: Brent Douglas , Collin Kostichuk -// 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 * as util from './util'; -export { MDCSlidableDrawerAdapter } from './slidable'; -export { MDCTemporaryDrawer, MDCTemporaryDrawerFoundation } from './temporary'; -export { MDCPersistentDrawer, MDCPersistentDrawerFoundation } from './persistent'; -export { 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..36ffb30e08 --- /dev/null +++ b/types/material__drawer/modal/foundation.d.ts @@ -0,0 +1,42 @@ +/** + * @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'; + +export class MDCModalDrawerFoundation extends MDCDismissibleDrawerFoundation { + /** + * Called when drawer finishes open animation. + */ + opened(): void; + + /** + * Called when drawer finishes close animation. + */ + closed(): void; + + /** + * Handles click event on scrim. + */ + handleScrimClick(): void; +} diff --git a/types/material__drawer/util.d.ts b/types/material__drawer/util.d.ts deleted file mode 100644 index 052af84e48..0000000000 --- a/types/material__drawer/util.d.ts +++ /dev/null @@ -1,35 +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. - */ - -// Remap touch events to pointer events, if the browser doesn't support touch events. -export function remapEvent(eventName: string, globalObj?: Window): string; - -// 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; diff --git a/types/material__list/adapter.d.ts b/types/material__list/adapter.d.ts new file mode 100644 index 0000000000..3a1b5522d8 --- /dev/null +++ b/types/material__list/adapter.d.ts @@ -0,0 +1,49 @@ +export 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; +} 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..3823d796ca --- /dev/null +++ b/types/material__list/foundation.d.ts @@ -0,0 +1,72 @@ +import MDCFoundation from 'material__base/foundation'; +import { MDCListAdapter } from './adapter'; +import { strings, cssClasses, Index } from './constants'; + +export const ELEMENTS_KEY_ALLOWED_IN: string[]; + +export class MDCListFoundation extends MDCFoundation { + static readonly strings: strings; + static readonly cssClasses: cssClasses; + 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; + + getSelectedIndex(): Index; + + setSelectedIndex(index: Index): void; + + /** + * Focus in handler for the list items. + */ + handleFocusIn(evt: Event, listItemIndex: number): void; + + /** + * Focus out handler for the list items. + */ + handleFocusOut(evt: Event, listItemIndex: number): void; + + /** + * Key handler for the list. + */ + handleKeydown(evt: Event, isRootListItem: boolean, listItemIndex: number): void; + + /** + * Click handler for the list. + */ + handleClick(index: number, toggleCheckbox: boolean): void; + + /** + * Focuses the next element on the list. + */ + focusNextElement(index: number): number; + + /** + * Focuses the previous element on the list. + */ + focusPrevElement(index: number): number; + + focusFirstElement(): number; + + focusLastElement(): number; +} diff --git a/types/material__list/index.d.ts b/types/material__list/index.d.ts new file mode 100644 index 0000000000..22adf832f3 --- /dev/null +++ b/types/material__list/index.d.ts @@ -0,0 +1,54 @@ +// 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 + +export class MDCList { + constructor(...args: any[]); + 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; + + vertical: boolean; + readonly listElements: Element[]; + wrapFocus: boolean; + singleSelection: boolean; + selectedIndex: Index; + + getDefaultFoundation(): MDCListFoundation; +} + +export { 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" }