From 23ca115b22d0e61c93382cb76facc338a679cc84 Mon Sep 17 00:00:00 2001 From: Collin Kostichuk Date: Thu, 10 May 2018 14:21:45 -0600 Subject: [PATCH] Updated types for @material group to v0.35.0 --- types/material-components-web/index.d.ts | 15 +- types/material__animation/index.d.ts | 4 +- types/material__auto-init/index.d.ts | 6 +- types/material__base/component.d.ts | 10 +- types/material__base/foundation.d.ts | 4 +- types/material__base/index.d.ts | 6 +- types/material__checkbox/adapter.d.ts | 12 +- types/material__checkbox/constants.d.ts | 8 +- types/material__checkbox/foundation.d.ts | 10 +- types/material__checkbox/index.d.ts | 8 +- types/material__chips/chip-set/adapter.d.ts | 50 ++++++ .../chip-set}/constants.d.ts | 8 +- .../material__chips/chip-set/foundation.d.ts | 44 +++++ types/material__chips/chip-set/index.d.ts | 35 ++++ types/material__chips/chip/adapter.d.ts | 77 +++++++++ types/material__chips/chip/constants.d.ts | 38 +++++ types/material__chips/chip/foundation.d.ts | 32 ++++ types/material__chips/chip/index.d.ts | 39 +++++ types/material__chips/index.d.ts | 24 +++ types/material__chips/tsconfig.json | 32 ++++ types/material__chips/tslint.json | 1 + types/material__dialog/adapter.d.ts | 4 +- types/material__dialog/constants.d.ts | 2 +- types/material__dialog/foundation.d.ts | 8 +- types/material__dialog/index.d.ts | 19 +-- types/material__drawer/index.d.ts | 12 +- .../persistent/constants.d.ts | 10 +- .../persistent/foundation.d.ts | 4 +- types/material__drawer/persistent/index.d.ts | 4 +- types/material__drawer/slidable/index.d.ts | 6 +- .../material__drawer/temporary/constants.d.ts | 10 +- .../temporary/foundation.d.ts | 4 +- types/material__drawer/temporary/index.d.ts | 2 - types/material__drawer/util.d.ts | 4 +- types/material__floating-label/adapter.d.ts | 51 ++++++ types/material__floating-label/constants.d.ts | 23 +++ .../material__floating-label/foundation.d.ts | 40 +++++ types/material__floating-label/index.d.ts | 48 ++++++ types/material__floating-label/tsconfig.json | 27 +++ types/material__floating-label/tslint.json | 1 + types/material__form-field/adapter.d.ts | 8 +- types/material__form-field/constants.d.ts | 2 +- types/material__form-field/foundation.d.ts | 4 +- types/material__form-field/index.d.ts | 6 +- types/material__grid-list/adapter.d.ts | 2 +- types/material__grid-list/foundation.d.ts | 6 +- types/material__grid-list/index.d.ts | 12 +- types/material__icon-toggle/adapter.d.ts | 29 ++-- types/material__icon-toggle/foundation.d.ts | 28 +--- types/material__icon-toggle/index.d.ts | 12 +- types/material__line-ripple/adapter.d.ts | 53 ++++++ types/material__line-ripple/constants.d.ts | 23 +++ types/material__line-ripple/foundation.d.ts | 45 +++++ types/material__line-ripple/index.d.ts | 47 ++++++ types/material__line-ripple/tsconfig.json | 27 +++ types/material__line-ripple/tslint.json | 1 + types/material__linear-progress/adapter.d.ts | 2 +- .../material__linear-progress/foundation.d.ts | 7 +- types/material__linear-progress/index.d.ts | 12 +- .../material__menu/{simple => }/adapter.d.ts | 44 +++-- types/material__menu/constants.d.ts | 77 +++++++++ types/material__menu/foundation.d.ts | 68 ++++++++ types/material__menu/index.d.ts | 47 +++++- types/material__menu/simple/constants.d.ts | 52 ------ types/material__menu/simple/index.d.ts | 42 ----- types/material__menu/tsconfig.json | 11 +- types/material__notched-outline/adapter.d.ts | 57 +++++++ .../material__notched-outline/constants.d.ts | 27 +++ .../material__notched-outline/foundation.d.ts | 38 +++++ types/material__notched-outline/index.d.ts | 41 +++++ types/material__notched-outline/tsconfig.json | 27 +++ types/material__notched-outline/tslint.json | 1 + types/material__radio/adapter.d.ts | 8 +- types/material__radio/foundation.d.ts | 23 ++- types/material__radio/index.d.ts | 10 +- types/material__ripple/adapter.d.ts | 16 +- types/material__ripple/constants.d.ts | 8 +- types/material__ripple/foundation.d.ts | 35 +--- types/material__ripple/index.d.ts | 24 ++- types/material__select/adapter.d.ts | 58 +------ types/material__select/constants.d.ts | 8 +- types/material__select/foundation.d.ts | 21 +-- types/material__select/index.d.ts | 24 +-- types/material__selection-control/index.d.ts | 4 +- types/material__slider/adapter.d.ts | 4 +- types/material__slider/foundation.d.ts | 3 +- types/material__slider/index.d.ts | 30 ++-- types/material__snackbar/adapter.d.ts | 4 +- types/material__snackbar/constants.d.ts | 2 + types/material__snackbar/foundation.d.ts | 20 +-- types/material__snackbar/index.d.ts | 17 +- .../adapter.d.ts | 52 +++--- types/material__tab/constants.d.ts | 27 +++ .../foundation.d.ts | 30 ++-- types/material__tab/index.d.ts | 33 ++++ types/material__tab/tsconfig.json | 27 +++ types/material__tab/tslint.json | 1 + types/material__tabs/index.d.ts | 10 +- .../tab-bar-scroller/adapter.d.ts | 2 +- .../tab-bar-scroller/foundation.d.ts | 2 +- .../tab-bar-scroller/index.d.ts | 17 +- types/material__tabs/tab-bar/adapter.d.ts | 2 +- types/material__tabs/tab-bar/foundation.d.ts | 4 +- types/material__tabs/tab-bar/index.d.ts | 6 +- types/material__tabs/tab/adapter.d.ts | 2 +- types/material__tabs/tab/foundation.d.ts | 4 +- types/material__tabs/tab/index.d.ts | 11 +- types/material__textfield/adapter.d.ts | 156 +++++++++--------- types/material__textfield/constants.d.ts | 19 ++- types/material__textfield/foundation.d.ts | 60 +++---- .../helper-text/adapter.d.ts | 4 +- .../helper-text/foundation.d.ts | 12 +- .../helper-text/index.d.ts | 2 - types/material__textfield/icon/adapter.d.ts | 56 +++++++ .../icon/constants.d.ts} | 8 +- .../material__textfield/icon/foundation.d.ts | 35 ++++ .../{bottom-line => icon}/index.d.ts | 16 +- types/material__textfield/index.d.ts | 56 +++++-- types/material__textfield/tsconfig.json | 8 +- types/material__toolbar/adapter.d.ts | 2 +- types/material__toolbar/constants.d.ts | 1 + types/material__toolbar/foundation.d.ts | 12 +- types/material__toolbar/index.d.ts | 15 +- types/material__toolbar/tsconfig.json | 1 - types/material__top-app-bar/adapter.d.ts | 77 +++++++++ types/material__top-app-bar/constants.d.ts | 38 +++++ .../fixed/foundation.d.ts | 22 +++ .../foundation.d.ts | 25 +-- types/material__top-app-bar/index.d.ts | 38 +++++ .../short/foundation.d.ts | 22 +++ .../standard/foundation.d.ts | 22 +++ types/material__top-app-bar/tsconfig.json | 30 ++++ types/material__top-app-bar/tslint.json | 1 + 133 files changed, 2095 insertions(+), 792 deletions(-) create mode 100644 types/material__chips/chip-set/adapter.d.ts rename types/{material__textfield/bottom-line => material__chips/chip-set}/constants.d.ts (80%) create mode 100644 types/material__chips/chip-set/foundation.d.ts create mode 100644 types/material__chips/chip-set/index.d.ts create mode 100644 types/material__chips/chip/adapter.d.ts create mode 100644 types/material__chips/chip/constants.d.ts create mode 100644 types/material__chips/chip/foundation.d.ts create mode 100644 types/material__chips/chip/index.d.ts create mode 100644 types/material__chips/index.d.ts create mode 100644 types/material__chips/tsconfig.json create mode 100644 types/material__chips/tslint.json create mode 100644 types/material__floating-label/adapter.d.ts create mode 100644 types/material__floating-label/constants.d.ts create mode 100644 types/material__floating-label/foundation.d.ts create mode 100644 types/material__floating-label/index.d.ts create mode 100644 types/material__floating-label/tsconfig.json create mode 100644 types/material__floating-label/tslint.json create mode 100644 types/material__line-ripple/adapter.d.ts create mode 100644 types/material__line-ripple/constants.d.ts create mode 100644 types/material__line-ripple/foundation.d.ts create mode 100644 types/material__line-ripple/index.d.ts create mode 100644 types/material__line-ripple/tsconfig.json create mode 100644 types/material__line-ripple/tslint.json rename types/material__menu/{simple => }/adapter.d.ts (69%) create mode 100644 types/material__menu/constants.d.ts create mode 100644 types/material__menu/foundation.d.ts delete mode 100644 types/material__menu/simple/constants.d.ts delete mode 100644 types/material__menu/simple/index.d.ts create mode 100644 types/material__notched-outline/adapter.d.ts create mode 100644 types/material__notched-outline/constants.d.ts create mode 100644 types/material__notched-outline/foundation.d.ts create mode 100644 types/material__notched-outline/index.d.ts create mode 100644 types/material__notched-outline/tsconfig.json create mode 100644 types/material__notched-outline/tslint.json rename types/{material__textfield/bottom-line => material__tab}/adapter.d.ts (58%) create mode 100644 types/material__tab/constants.d.ts rename types/{material__textfield/bottom-line => material__tab}/foundation.d.ts (64%) create mode 100644 types/material__tab/index.d.ts create mode 100644 types/material__tab/tsconfig.json create mode 100644 types/material__tab/tslint.json create mode 100644 types/material__textfield/icon/adapter.d.ts rename types/{material__toolbar/util.d.ts => material__textfield/icon/constants.d.ts} (77%) create mode 100644 types/material__textfield/icon/foundation.d.ts rename types/material__textfield/{bottom-line => icon}/index.d.ts (58%) create mode 100644 types/material__top-app-bar/adapter.d.ts create mode 100644 types/material__top-app-bar/constants.d.ts create mode 100644 types/material__top-app-bar/fixed/foundation.d.ts rename types/{material__menu/simple => material__top-app-bar}/foundation.d.ts (63%) create mode 100644 types/material__top-app-bar/index.d.ts create mode 100644 types/material__top-app-bar/short/foundation.d.ts create mode 100644 types/material__top-app-bar/standard/foundation.d.ts create mode 100644 types/material__top-app-bar/tsconfig.json create mode 100644 types/material__top-app-bar/tslint.json diff --git a/types/material-components-web/index.d.ts b/types/material-components-web/index.d.ts index c5d1434942..f1f9874f4b 100644 --- a/types/material-components-web/index.d.ts +++ b/types/material-components-web/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for Material Components Web 0.26 +// Type definitions for Material Components Web 0.35 // Project: https://material.io/components/ -// Definitions by: Brent Douglas +// Definitions by: Brent Douglas , Collin Kostichuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 @@ -23,13 +23,17 @@ 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'; @@ -39,19 +43,23 @@ 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, @@ -61,4 +69,5 @@ export { tabs, textField, toolbar, + topAppBar }; diff --git a/types/material__animation/index.d.ts b/types/material__animation/index.d.ts index 8baf562003..2527cf9e71 100644 --- a/types/material__animation/index.d.ts +++ b/types/material__animation/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for Material Components Web 0.26 +// Type definitions for Material Components Web 0.35 // Project: https://material.io/components/ -// Definitions by: Brent Douglas +// Definitions by: Brent Douglas , Collin Kostichuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 diff --git a/types/material__auto-init/index.d.ts b/types/material__auto-init/index.d.ts index 026b692b99..2993089fce 100644 --- a/types/material__auto-init/index.d.ts +++ b/types/material__auto-init/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for Material Components Web 0.26 +// Type definitions for Material Components Web 0.35 // Project: https://material.io/components/ -// Definitions by: Brent Douglas +// Definitions by: Brent Douglas , Collin Kostichuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 @@ -32,6 +32,8 @@ export interface MDCAutoInit { /** * Auto-initializes all mdc components on a page. */ +// tslint:disable-next-line:strict-export-declare-modifiers declare const mdcAutoInit: MDCAutoInit; +// tslint:disable-next-line:strict-export-declare-modifiers export default mdcAutoInit; diff --git a/types/material__base/component.d.ts b/types/material__base/component.d.ts index 0a645b26a4..43c085cdce 100644 --- a/types/material__base/component.d.ts +++ b/types/material__base/component.d.ts @@ -6,7 +6,7 @@ * 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 + * 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, @@ -17,7 +17,7 @@ import MDCFoundation from './foundation'; -export class MDCComponent> { +export default class MDCComponent> { static attachTo(root: Element): MDCComponent>; constructor(root: Element, foundation?: F, ...args: any[]); @@ -45,13 +45,13 @@ export class MDCComponent> { * Wrapper method to add an event listener to the component's root element. This is most useful when * listening for custom events. */ - listen(evtType: string, handler: EventListenerOrEventListenerObject): void; + listen(evtType: string, handler: EventListener): void; /** * Wrapper method to remove an event listener to the component's root element. This is most useful when * unlistening for custom events. */ - unlisten(evtType: string, handler: EventListenerOrEventListenerObject): void; + unlisten(evtType: string, handler: EventListener): void; /** * Fires a cross-browser-compatible custom event from the component root of the given type, @@ -59,5 +59,3 @@ export class MDCComponent> { */ emit(evtType: string, evtData: any, shouldBubble?: boolean): void; } - -export default MDCComponent; diff --git a/types/material__base/foundation.d.ts b/types/material__base/foundation.d.ts index 7612d0daea..7bd61ec18e 100644 --- a/types/material__base/foundation.d.ts +++ b/types/material__base/foundation.d.ts @@ -23,7 +23,7 @@ export interface MDCNumbers { [key: string]: number; } -export class MDCFoundation { +export default class MDCFoundation { static readonly cssClasses: MDCStrings; static readonly strings: MDCStrings; @@ -40,5 +40,3 @@ export class MDCFoundation { // Subclasses should override this method to perform de-initialization routines (de-registering events, etc.) destroy(): void; } - -export default MDCFoundation; diff --git a/types/material__base/index.d.ts b/types/material__base/index.d.ts index 0172cb35f6..bc4d2ee1a3 100644 --- a/types/material__base/index.d.ts +++ b/types/material__base/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for Material Components Web 0.26 +// Type definitions for Material Components Web 0.35 // Project: https://material.io/components/ -// Definitions by: Brent Douglas +// Definitions by: Brent Douglas , Collin Kostichuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 @@ -21,7 +21,7 @@ * limitations under the License. */ -import { MDCNumbers, MDCStrings, MDCFoundation } from './foundation'; +import MDCFoundation, { MDCNumbers, MDCStrings } from './foundation'; import MDCComponent from './component'; export {MDCNumbers, MDCStrings, MDCFoundation, MDCComponent}; diff --git a/types/material__checkbox/adapter.d.ts b/types/material__checkbox/adapter.d.ts index aedeed30f5..a68eefb002 100644 --- a/types/material__checkbox/adapter.d.ts +++ b/types/material__checkbox/adapter.d.ts @@ -6,7 +6,7 @@ * 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 + * 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, @@ -29,13 +29,17 @@ import { MDCSelectionControlState } from 'material__selection-control'; * Implement this adapter for your framework of choice to delegate updates to * the component in your framework of choice. See architecture documentation * for more details. - * https://github.com/material-components/material-components-web/blob/master/docs/architecture.md + * https://github.com/material-components/material-components-web/blob/master/docs/code/architecture.md */ -export class MDCCheckboxAdapter { +export default interface MDCCheckboxAdapter { addClass(className: string): void; removeClass(className: string): void; + setNativeControlAttr(attr: string, value: string): void; + + removeNativeControlAttr(attr: string): void; + registerAnimationEndHandler(handler: EventListener): void; deregisterAnimationEndHandler(handler: EventListener): void; @@ -50,5 +54,3 @@ export class MDCCheckboxAdapter { isAttachedToDOM(): boolean; } - -export default MDCCheckboxAdapter; diff --git a/types/material__checkbox/constants.d.ts b/types/material__checkbox/constants.d.ts index ee665f4c05..b522139b55 100644 --- a/types/material__checkbox/constants.d.ts +++ b/types/material__checkbox/constants.d.ts @@ -6,7 +6,7 @@ * 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 + * 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, @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - import { MDCStrings, MDCNumbers } from 'material__base'; +import { MDCStrings, MDCNumbers } from 'material__base'; export interface cssClasses extends MDCStrings { UPGRADED: 'mdc-checkbox--upgraded'; @@ -35,8 +35,10 @@ export interface strings extends MDCStrings { TRANSITION_STATE_CHECKED: 'checked'; TRANSITION_STATE_UNCHECKED: 'unchecked'; TRANSITION_STATE_INDETERMINATE: 'indeterminate'; + ARIA_CHECKED_ATTR: 'aria-checked'; + ARIA_CHECKED_INDETERMINATE_VALUE: 'mixed'; } export interface numbers extends MDCNumbers { - ANIM_END_LATCH_MS: 100; + ANIM_END_LATCH_MS: 250; } diff --git a/types/material__checkbox/foundation.d.ts b/types/material__checkbox/foundation.d.ts index 73216efcd6..cf04fe98f7 100644 --- a/types/material__checkbox/foundation.d.ts +++ b/types/material__checkbox/foundation.d.ts @@ -19,7 +19,7 @@ import MDCFoundation from 'material__base/foundation'; import MDCCheckboxAdapter from './adapter'; import { cssClasses, strings, numbers } from './constants'; -export class MDCCheckboxFoundation extends MDCFoundation { +export default class MDCCheckboxFoundation extends MDCFoundation { static readonly cssClasses: cssClasses; static readonly strings: strings; @@ -30,7 +30,7 @@ export class MDCCheckboxFoundation extends MDCFoundation { isChecked(): boolean; - setChecked(checked: boolean): boolean; + setChecked(checked: boolean): void; isIndeterminate(): boolean; @@ -43,6 +43,8 @@ export class MDCCheckboxFoundation extends MDCFoundation { getValue(): string; setValue(value: string): void; -} -export default MDCCheckboxFoundation; + handleAnimationEnd(): void; + + handleChange(): void; +} diff --git a/types/material__checkbox/index.d.ts b/types/material__checkbox/index.d.ts index 9190c3d5a9..308bc077bb 100644 --- a/types/material__checkbox/index.d.ts +++ b/types/material__checkbox/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for Material Components Web 0.26 +// Type definitions for Material Components Web 0.35 // Project: https://material.io/components/ -// Definitions by: Brent Douglas +// Definitions by: Brent Douglas , Collin Kostichuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 @@ -32,8 +32,6 @@ export {MDCCheckboxAdapter, MDCCheckboxFoundation}; export class MDCCheckbox extends MDCComponent implements MDCSelectionControl { static attachTo(root: Element): MDCCheckbox; - getDefaultFoundation(): MDCCheckboxFoundation; - readonly ripple: MDCRipple; checked: boolean; @@ -43,6 +41,4 @@ export class MDCCheckbox extends MDCComponent { + static readonly strings: strings; + + static readonly cssClasses: cssClasses; + + static readonly defaultAdapter: MDCChipSetAdapter; + + /** + * Returns a new chip element with the given text, leading icon, and trailing icon, + * added to the root chip set element. + */ + addChip(text: string, leadingIcon?: Element | null, trailingIcon?: Element | null): Element; + + /** + * Selects the given chip. Deselects all other chips if the chip set is of the choice variant. + */ + select(chipFoundation: MDCChipFoundation): void; + + /** + * Deselects the given chip. + */ + deselect(chipFoundation: MDCChipFoundation): void; +} diff --git a/types/material__chips/chip-set/index.d.ts b/types/material__chips/chip-set/index.d.ts new file mode 100644 index 0000000000..a516d3b374 --- /dev/null +++ b/types/material__chips/chip-set/index.d.ts @@ -0,0 +1,35 @@ +/** + * @license + * Copyright 2016 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import MDCComponent from 'material__base/component'; +import MDCChipSetFoundation from './foundation'; +import MDCChipSetAdapter from './adapter'; +import { MDCChip } from '../chip'; + +export { MDCChipSetFoundation, MDCChipSetAdapter }; + +export class MDCChipSet extends MDCComponent { + static attachTo(root: any): MDCChipSet; + + initialize(chipFactory?: (el: Element) => MDCChip): void; + + initialSyncWithDOM(): void; + + /** + * Creates a new chip in the chip set with the given text, leading icon, and trailing icon. + */ + addChip(text: string, leadingIcon?: Element | null, trailingIcon?: Element | null): void; +} diff --git a/types/material__chips/chip/adapter.d.ts b/types/material__chips/chip/adapter.d.ts new file mode 100644 index 0000000000..52ffcef68f --- /dev/null +++ b/types/material__chips/chip/adapter.d.ts @@ -0,0 +1,77 @@ +/** + * @license + * Copyright 2017 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. + */ +/** + * Adapter for MDC Chip. + * + * Defines the shape of the adapter expected by the foundation. Implement this + * adapter to integrate the Chip into your framework. See + * https://github.com/material-components/material-components-web/blob/master/docs/authoring-components.md + * for more information. + */ +export default interface MDCChipAdapter { + addClass(className: string): void; + + removeClass(className: string): void; + + hasClass(className: string): boolean; + + addClassToLeadingIcon(className: string): void; + + removeClassFromLeadingIcon(className: string): void; + /** + * Returns true if target has className, false otherwise. + */ + eventTargetHasClass(target: EventTarget, className: string): boolean; + /** + * Registers an event listener on the root element for a given event. + */ + registerEventHandler(evtType: string, handler: EventListener): void; + /** + * Deregisters an event listener on the root element for a given event. + */ + deregisterEventHandler(evtType: string, handler: EventListener): void; + /** + * Registers an event listener on the trailing icon element for a given event. + */ + registerTrailingIconInteractionHandler(evtType: string, handler: EventListener): void; + /** + * Deregisters an event listener on the trailing icon element for a given event. + */ + deregisterTrailingIconInteractionHandler(evtType: string, handler: EventListener): void; + /** + * Emits a custom "MDCChip:interaction" event denoting the chip has been + * interacted with (typically on click or keydown). + */ + notifyInteraction(): void; + /** + * Emits a custom "MDCChip:trailingIconInteraction" event denoting the trailing icon has been + * interacted with (typically on click or keydown). + */ + notifyTrailingIconInteraction(): void; + /** + * Emits a custom event "MDCChip:removal" denoting the chip will be removed. + */ + notifyRemoval(): void; + /** + * Returns the computed property value of the given style property on the root element. + */ + getComputedStyleValue(propertyName: string): string; + /** + * Sets the property value of the given style property on the root element. + */ + setStyleProperty(propertyName: string, value: string): void; +} diff --git a/types/material__chips/chip/constants.d.ts b/types/material__chips/chip/constants.d.ts new file mode 100644 index 0000000000..79f1891445 --- /dev/null +++ b/types/material__chips/chip/constants.d.ts @@ -0,0 +1,38 @@ +/** + * @license + * 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 strings extends MDCStrings { + ENTRY_ANIMATION_NAME: 'mdc-chip-entry'; + INTERACTION_EVENT: 'MDCChip:interaction'; + TRAILING_ICON_INTERACTION_EVENT: 'MDCChip:trailingIconInteraction'; + REMOVAL_EVENT: 'MDCChip:removal'; + CHECKMARK_SELECTOR: '.mdc-chip__checkmark'; + LEADING_ICON_SELECTOR: '.mdc-chip__icon--leading'; + TRAILING_ICON_SELECTOR: '.mdc-chip__icon--trailing'; +} + +export interface cssClasses extends MDCStrings { + CHECKMARK: 'mdc-chip__checkmark'; + CHIP: 'mdc-chip'; + CHIP_EXIT: 'mdc-chip--exit'; + HIDDEN_LEADING_ICON: 'mdc-chip__icon--leading-hidden'; + LEADING_ICON: 'mdc-chip__icon--leading'; + TRAILING_ICON: 'mdc-chip__icon--trailing'; + SELECTED: 'mdc-chip--selected'; + TEXT: 'mdc-chip__text'; +} diff --git a/types/material__chips/chip/foundation.d.ts b/types/material__chips/chip/foundation.d.ts new file mode 100644 index 0000000000..383cbb9089 --- /dev/null +++ b/types/material__chips/chip/foundation.d.ts @@ -0,0 +1,32 @@ +/** + * @license + * 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/foundation'; +import MDCChipAdapter from './adapter'; +import { cssClasses, strings } from './constants'; + +export default class MDCChipFoundation extends MDCFoundation { + static readonly strings: strings; + + static readonly cssClasses: cssClasses; + + static readonly defaultAdapter: MDCChipAdapter; + + isSelected(): boolean; + + setSelected(selected: boolean): void; +} diff --git a/types/material__chips/chip/index.d.ts b/types/material__chips/chip/index.d.ts new file mode 100644 index 0000000000..a0320e69b3 --- /dev/null +++ b/types/material__chips/chip/index.d.ts @@ -0,0 +1,39 @@ +/** + * @license + * Copyright 2016 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import MDCComponent from 'material__base/component'; +import MDCChipFoundation from './foundation'; +import MDCChipAdapter from './adapter'; +import { MDCRipple } from 'material__ripple'; + +export { MDCChipFoundation, MDCChipAdapter }; + +export class MDCChip extends MDCComponent { + static attachTo(root: Element): MDCChip; + /** + * Returns true if the chip is selected. + */ + isSelected(): boolean; + + /** + * Destroys the chip and removes the root element from the DOM. + */ + remove(): void; + + readonly foundation: MDCChipFoundation; + + readonly ripple: MDCRipple; +} diff --git a/types/material__chips/index.d.ts b/types/material__chips/index.d.ts new file mode 100644 index 0000000000..935d897236 --- /dev/null +++ b/types/material__chips/index.d.ts @@ -0,0 +1,24 @@ +// 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 2017 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 { MDCChipFoundation, MDCChip, MDCChipAdapter } from './chip'; +import { MDCChipSetFoundation, MDCChipSet, MDCChipSetAdapter } from './chip-set'; +export { MDCChipFoundation, MDCChip, MDCChipAdapter, MDCChipSetFoundation, MDCChipSet, MDCChipSetAdapter }; diff --git a/types/material__chips/tsconfig.json b/types/material__chips/tsconfig.json new file mode 100644 index 0000000000..424cb5a424 --- /dev/null +++ b/types/material__chips/tsconfig.json @@ -0,0 +1,32 @@ +{ + "files": [ + "chip/adapter.d.ts", + "chip/constants.d.ts", + "chip/foundation.d.ts", + "chip/index.d.ts", + "chip-set/adapter.d.ts", + "chip-set/constants.d.ts", + "chip-set/foundation.d.ts", + "chip-set/index.d.ts", + "index.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 + } +} \ No newline at end of file diff --git a/types/material__chips/tslint.json b/types/material__chips/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/material__chips/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/material__dialog/adapter.d.ts b/types/material__dialog/adapter.d.ts index fd6bc3cf9f..beaa1a2a3e 100644 --- a/types/material__dialog/adapter.d.ts +++ b/types/material__dialog/adapter.d.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -export interface MSDDialogAdapter { +export default interface MDCDialogAdapter { addClass(className: string): void; removeClass(className: string): void; @@ -50,6 +50,4 @@ export interface MSDDialogAdapter { untrapFocusOnSurface(): void; isDialog(el: Element): boolean; - - layoutFooterRipples(): void; } diff --git a/types/material__dialog/constants.d.ts b/types/material__dialog/constants.d.ts index a45628627c..297876ba7d 100644 --- a/types/material__dialog/constants.d.ts +++ b/types/material__dialog/constants.d.ts @@ -14,7 +14,7 @@ * limitations under the License. */ - import { MDCStrings } from 'material__base'; +import { MDCStrings } from 'material__base'; export interface cssClasses extends MDCStrings { ROOT: 'mdc-dialog'; diff --git a/types/material__dialog/foundation.d.ts b/types/material__dialog/foundation.d.ts index f28c541dd2..e17b8388e5 100644 --- a/types/material__dialog/foundation.d.ts +++ b/types/material__dialog/foundation.d.ts @@ -16,14 +16,14 @@ import { MDCFoundation } from 'material__base'; import { cssClasses, strings } from './constants'; -import { MSDDialogAdapter } from './adapter'; +import MDCDialogAdapter from './adapter'; -export class MDCDialogFoundation extends MDCFoundation { +export default class MDCDialogFoundation extends MDCFoundation { static readonly cssClasses: cssClasses; static readonly strings: strings; - static readonly defaultAdapter: MSDDialogAdapter; + static readonly defaultAdapter: MDCDialogAdapter; open(): void; @@ -35,5 +35,3 @@ export class MDCDialogFoundation extends MDCFoundation { cancel(shouldNotify: boolean): void; } - -export default MDCDialogFoundation; diff --git a/types/material__dialog/index.d.ts b/types/material__dialog/index.d.ts index 7d8ab69e30..491d2ad9fd 100644 --- a/types/material__dialog/index.d.ts +++ b/types/material__dialog/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for Material Components Web 0.26 +// Type definitions for Material Components Web 0.35 // Project: https://material.io/components/ -// Definitions by: Brent Douglas +// Definitions by: Brent Douglas , Collin Kostichuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 @@ -21,26 +21,17 @@ */ import { MDCComponent } from 'material__base'; -import { MDCRipple } from 'material__ripple'; - import MDCDialogFoundation from './foundation'; -import { MSDDialogAdapter } from './adapter'; +import MDCDialogAdapter from './adapter'; import * as util from './util'; -export {MSDDialogAdapter, MDCDialogFoundation, util}; +export {MDCDialogAdapter, MDCDialogFoundation, util}; -export class MDCDialog extends MDCComponent { +export class MDCDialog extends MDCComponent { static attachTo(root: Element): MDCDialog; readonly open: boolean; - - initialize(): void; - - destroy(): void; - show(): void; close(): void; - - getDefaultFoundation(): MDCDialogFoundation; } diff --git a/types/material__drawer/index.d.ts b/types/material__drawer/index.d.ts index 379ed35599..63cd5d8fda 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.26 +// Type definitions for Material Components Web 0.35 // Project: https://material.io/components/ -// Definitions by: Brent Douglas +// Definitions by: Brent Douglas , Collin Kostichuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 @@ -21,7 +21,7 @@ */ import * as util from './util'; -export {MDCSlidableDrawerAdapter} from './slidable'; -export {MDCTemporaryDrawer, MDCTemporaryDrawerFoundation} from './temporary'; -export {MDCPersistentDrawer, MDCPersistentDrawerFoundation} from './persistent'; -export {util}; +export { MDCSlidableDrawerAdapter } from './slidable'; +export { MDCTemporaryDrawer, MDCTemporaryDrawerFoundation } from './temporary'; +export { MDCPersistentDrawer, MDCPersistentDrawerFoundation } from './persistent'; +export { util }; diff --git a/types/material__drawer/persistent/constants.d.ts b/types/material__drawer/persistent/constants.d.ts index 3d5f7c56ba..84dcce7f3f 100644 --- a/types/material__drawer/persistent/constants.d.ts +++ b/types/material__drawer/persistent/constants.d.ts @@ -5,7 +5,7 @@ * 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 + * 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, @@ -17,13 +17,13 @@ import { MDCStrings } from 'material__base'; export interface cssClasses extends MDCStrings { - ROOT: 'mdc-persistent-drawer'; - OPEN: 'mdc-persistent-drawer--open'; - ANIMATING: 'mdc-persistent-drawer--animating'; + ROOT: 'mdc-drawer--persistent'; + OPEN: 'mdc-drawer--open'; + ANIMATING: 'mdc-drawer--animating'; } export interface strings extends MDCStrings { - DRAWER_SELECTOR: '.mdc-persistent-drawer__drawer'; + DRAWER_SELECTOR: '.mdc-drawer--persistent .mdc-drawer__drawer'; FOCUSABLE_ELEMENTS: 'a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, [tabindex], [contenteditable]'; OPEN_EVENT: 'MDCPersistentDrawer:open'; CLOSE_EVENT: 'MDCPersistentDrawer:close'; diff --git a/types/material__drawer/persistent/foundation.d.ts b/types/material__drawer/persistent/foundation.d.ts index 7d4d53f884..ce596f3c23 100644 --- a/types/material__drawer/persistent/foundation.d.ts +++ b/types/material__drawer/persistent/foundation.d.ts @@ -17,12 +17,10 @@ import { MDCSlidableDrawerAdapter, MDCSlidableDrawerFoundation } from '../slidable'; import { cssClasses, strings } from './constants'; -export class MDCPersistentDrawerFoundation extends MDCSlidableDrawerFoundation { +export default class MDCPersistentDrawerFoundation extends MDCSlidableDrawerFoundation { static readonly cssClasses: cssClasses; static readonly strings: strings; static readonly defaultAdapter: MDCSlidableDrawerAdapter; } - -export default MDCPersistentDrawerFoundation; diff --git a/types/material__drawer/persistent/index.d.ts b/types/material__drawer/persistent/index.d.ts index 1c2286fd01..920258b2aa 100644 --- a/types/material__drawer/persistent/index.d.ts +++ b/types/material__drawer/persistent/index.d.ts @@ -15,7 +15,7 @@ */ import { MDCComponent } from 'material__base'; -import { MDCPersistentDrawerFoundation } from './foundation'; +import MDCPersistentDrawerFoundation from './foundation'; import { MDCSlidableDrawerAdapter } from '../slidable'; import * as util from '../util'; @@ -28,6 +28,4 @@ export class MDCPersistentDrawer extends MDCComponent { + static readonly cssClasses: cssClasses; + + static readonly defaultAdapter: MDCFloatingLabelAdapter; + + /** + * Returns the width of the label element. + */ + getWidth(): number; + + /** + * Styles the label to produce the label shake for errors. + */ + shake(shouldShake: boolean): void; + + /** + * Styles the label to float or dock. + */ + float(shouldFloat: boolean): void; +} diff --git a/types/material__floating-label/index.d.ts b/types/material__floating-label/index.d.ts new file mode 100644 index 0000000000..6b426a75d3 --- /dev/null +++ b/types/material__floating-label/index.d.ts @@ -0,0 +1,48 @@ +// 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 + +/** + * @license + * Copyright 2016 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import MDCComponent from 'material__base/component'; +import MDCFloatingLabelFoundation from './foundation'; +import MDCFloatingLabelAdapter from './adapter'; + +export { MDCFloatingLabelFoundation, MDCFloatingLabelAdapter }; + +export class MDCFloatingLabel extends MDCComponent { + static attachTo(root: Element): MDCFloatingLabel; + + /** + * Styles the label to produce the label shake for errors. + * @param shouldShake styles the label to shake by adding shake class + * if true, otherwise will stop shaking by removing shake class. + */ + shake(shouldShake: boolean): void; + + /** + * Styles label to float/dock. + * @param shouldFloat styles the label to float by adding float class + * if true, otherwise docks the label by removing the float class. + */ + float(shouldFloat: boolean): void; + + getWidth(): number; +} diff --git a/types/material__floating-label/tsconfig.json b/types/material__floating-label/tsconfig.json new file mode 100644 index 0000000000..2af99c6e5e --- /dev/null +++ b/types/material__floating-label/tsconfig.json @@ -0,0 +1,27 @@ +{ + "files": [ + "constants.d.ts", + "adapter.d.ts", + "index.d.ts", + "foundation.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 + } +} \ No newline at end of file diff --git a/types/material__floating-label/tslint.json b/types/material__floating-label/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/material__floating-label/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/material__form-field/adapter.d.ts b/types/material__form-field/adapter.d.ts index 7033f363eb..722014eced 100644 --- a/types/material__form-field/adapter.d.ts +++ b/types/material__form-field/adapter.d.ts @@ -26,11 +26,9 @@ * Implement this adapter for your framework of choice to delegate updates to * the component in your framework of choice. See architecture documentation * for more details. - * https://github.com/material-components/material-components-web/blob/master/docs/architecture.md - * - * @record + * https://github.com/material-components/material-components-web/blob/master/docs/code/architecture.md */ -export class MDCFormFieldAdapter { +export default interface MDCFormFieldAdapter { registerInteractionHandler(type: string, handler: EventListener): void; deregisterInteractionHandler(type: string, handler: EventListener): void; @@ -39,5 +37,3 @@ export class MDCFormFieldAdapter { deactivateInputRipple(): void; } - -export default MDCFormFieldAdapter; diff --git a/types/material__form-field/constants.d.ts b/types/material__form-field/constants.d.ts index ba55acabcd..a40f571acc 100644 --- a/types/material__form-field/constants.d.ts +++ b/types/material__form-field/constants.d.ts @@ -18,7 +18,7 @@ import { MDCStrings } from 'material__base'; export interface cssClasses extends MDCStrings { - ROOT: 'mdc-form-field'; + ROOT: 'mdc-form-field'; } export interface strings extends MDCStrings { diff --git a/types/material__form-field/foundation.d.ts b/types/material__form-field/foundation.d.ts index 026beedfc2..aec781d9ab 100644 --- a/types/material__form-field/foundation.d.ts +++ b/types/material__form-field/foundation.d.ts @@ -19,12 +19,10 @@ import MDCFoundation from 'material__base/foundation'; import MDCFormFieldAdapter from './adapter'; import { cssClasses, strings } from './constants'; -export class MDCFormFieldFoundation extends MDCFoundation { +export default class MDCFormFieldFoundation extends MDCFoundation { static readonly cssClasses: cssClasses; static readonly strings: strings; static readonly defaultAdapter: MDCFormFieldAdapter; } - -export default MDCFormFieldFoundation; diff --git a/types/material__form-field/index.d.ts b/types/material__form-field/index.d.ts index 1fcc30b4c4..812df5c0c0 100644 --- a/types/material__form-field/index.d.ts +++ b/types/material__form-field/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for Material Components Web 0.26 +// Type definitions for Material Components Web 0.35 // Project: https://material.io/components/ -// Definitions by: Brent Douglas +// Definitions by: Brent Douglas , Collin Kostichuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 @@ -32,6 +32,4 @@ export class MDCFormField extends MDCComponent { +export default class MDCGridListFoundation extends MDCFoundation { static readonly strings: strings; static readonly defaultAdapter: MDCGridListAdapter; alignCenter(): void; } - -export default MDCGridListFoundation; diff --git a/types/material__grid-list/index.d.ts b/types/material__grid-list/index.d.ts index 2a1e98d912..87ee0a138e 100644 --- a/types/material__grid-list/index.d.ts +++ b/types/material__grid-list/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for Material Components Web 0.26 +// Type definitions for Material Components Web 0.35 // Project: https://material.io/components/ -// Definitions by: Brent Douglas +// Definitions by: Brent Douglas , Collin Kostichuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 @@ -21,13 +21,11 @@ */ import { MDCComponent } from 'material__base'; -import { MDCGridListAdapter } from './adapter'; +import MDCGridListAdapter from './adapter'; import MDCGridListFoundation from './foundation'; -export {MDCGridListAdapter, MDCGridListFoundation}; +export { MDCGridListAdapter, MDCGridListFoundation }; export class MDCGridList extends MDCComponent { - static attachTo(root: Element): MDCGridList; - - getDefaultFoundation(): MDCGridListFoundation; + static attachTo(root: Element): MDCGridList; } diff --git a/types/material__icon-toggle/adapter.d.ts b/types/material__icon-toggle/adapter.d.ts index 52481fe732..56ac8a32dc 100644 --- a/types/material__icon-toggle/adapter.d.ts +++ b/types/material__icon-toggle/adapter.d.ts @@ -29,33 +29,30 @@ * Implement this adapter for your framework of choice to delegate updates to * the component in your framework of choice. See architecture documentation * for more details. - * https://github.com/material-components/material-components-web/blob/master/docs/architecture.md - * - * @record + * https://github.com/material-components/material-components-web/blob/master/docs/code/architecture.md */ +export default interface MDCIconToggleAdapter { + addClass(className: string): void; -export class MDCIconToggleAdapter { - addClass(className: string): void; + removeClass(className: string): void; - removeClass(className: string): void; + registerInteractionHandler(type: string, handler: EventListener): void; - registerInteractionHandler(type: string, handler: EventListener): void; + deregisterInteractionHandler(type: string, handler: EventListener): void; - deregisterInteractionHandler(type: string, handler: EventListener): void; + setText(text: string): void; - setText(text: string): void; + getTabIndex(): number; - getTabIndex(): number; + setTabIndex(tabIndex: number): void; - setTabIndex(tabIndex: number): void; + getAttr(name: string): string; - getAttr(name: string): string; + setAttr(name: string, value: string): void; - setAttr(name: string, value: string): void; + rmAttr(name: string): void; - rmAttr(name: string): void; - - notifyChange(evtData: IconToggleEvent): void; + notifyChange(evtData: IconToggleEvent): void; } export interface IconToggleEvent { diff --git a/types/material__icon-toggle/foundation.d.ts b/types/material__icon-toggle/foundation.d.ts index 65d25c1307..cd8910713f 100644 --- a/types/material__icon-toggle/foundation.d.ts +++ b/types/material__icon-toggle/foundation.d.ts @@ -16,10 +16,10 @@ */ import MDCFoundation from 'material__base/foundation'; -import { MDCIconToggleAdapter, IconToggleEvent } from './adapter'; +import MDCIconToggleAdapter from './adapter'; import { cssClasses, strings } from './constants'; -export class MDCIconToggleFoundation extends MDCFoundation { +export default class MDCIconToggleFoundation extends MDCFoundation { static readonly cssClasses: cssClasses; static readonly strings: strings; @@ -38,27 +38,3 @@ export class MDCIconToggleFoundation extends MDCFoundation isKeyboardActivated(): boolean; } - -export interface KeyboardKey { - key: string; - keyCode: number; -} - -export function isSpace(keyboardKey: KeyboardKey): boolean; - -export class IconToggleState { - /** - * The aria-label value of the icon toggle, or undefined if there is no aria-label. - */ - label: string|undefined; - /** - * The text for the icon toggle, or undefined if there is no text. - */ - content: string|undefined; - /** - * The CSS class to add to the icon toggle, or undefined if there is no CSS class. - */ - cssClass: string|undefined; -} - -export default MDCIconToggleFoundation; diff --git a/types/material__icon-toggle/index.d.ts b/types/material__icon-toggle/index.d.ts index bfced0b532..beae5b83db 100644 --- a/types/material__icon-toggle/index.d.ts +++ b/types/material__icon-toggle/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for Material Components Web 0.26 +// Type definitions for Material Components Web 0.35 // Project: https://material.io/components/ -// Definitions by: Brent Douglas +// Definitions by: Brent Douglas , Collin Kostichuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 @@ -23,18 +23,14 @@ import MDCComponent from 'material__base/component'; import MDCIconToggleFoundation from './foundation'; -import { MDCIconToggleAdapter } from './adapter'; -import { MDCRipple, MDCRippleFoundation } from 'material__ripple'; +import MDCIconToggleAdapter from './adapter'; +import { MDCRipple } from 'material__ripple'; export {MDCIconToggleAdapter, MDCIconToggleFoundation}; export class MDCIconToggle extends MDCComponent { static attachTo(root: Element): MDCIconToggle; - destroy(): void; - - getDefaultFoundation(): MDCIconToggleFoundation; - initialSyncWithDOM(): void; readonly ripple: MDCRipple; diff --git a/types/material__line-ripple/adapter.d.ts b/types/material__line-ripple/adapter.d.ts new file mode 100644 index 0000000000..93865a952a --- /dev/null +++ b/types/material__line-ripple/adapter.d.ts @@ -0,0 +1,53 @@ +/** + * @license + * Copyright 2018 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. + */ +/** + * Adapter for MDC TextField Line Ripple. + * + * Defines the shape of the adapter expected by the foundation. Implement this + * adapter to integrate the line ripple into your framework. See + * https://github.com/material-components/material-components-web/blob/master/docs/authoring-components.md + * for more information. + */ + +export default interface MDCLineRippleAdapter { + /** + * Adds a class to the line ripple element. + */ + addClass(className: string): void; + + /** + * Removes a class from the line ripple element. + */ + removeClass(className: string): void; + + hasClass(className: string): boolean; + + /** + * Sets the style property with propertyName to value on the root element. + */ + setStyle(propertyName: string, value: string): void; + + /** + * Registers an event listener on the line ripple element for a given event. + */ + registerEventHandler(evtType: string, handler: EventListener): void; + + /** + * Deregisters an event listener on the line ripple element for a given event. + */ + deregisterEventHandler(evtType: string, handler: EventListener): void; +} diff --git a/types/material__line-ripple/constants.d.ts b/types/material__line-ripple/constants.d.ts new file mode 100644 index 0000000000..722570a2f5 --- /dev/null +++ b/types/material__line-ripple/constants.d.ts @@ -0,0 +1,23 @@ +/** + * @license + * Copyright 2018 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 { + LINE_RIPPLE_ACTIVE: 'mdc-line-ripple--active'; + LINE_RIPPLE_DEACTIVATING: 'mdc-line-ripple--deactivating'; +} diff --git a/types/material__line-ripple/foundation.d.ts b/types/material__line-ripple/foundation.d.ts new file mode 100644 index 0000000000..2d525b7083 --- /dev/null +++ b/types/material__line-ripple/foundation.d.ts @@ -0,0 +1,45 @@ +/** + * @license + * Copyright 2018 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/foundation'; +import { cssClasses } from './constants'; +import MDCLineRippleAdapter from './adapter'; + +export default class MDCLineRippleFoundation extends MDCFoundation { + static readonly cssClasses: cssClasses; + + static readonly defaultAdapter: MDCLineRippleAdapter; + + /** + * Activates the line ripple + */ + activate(): void; + + /** + * Sets the center of the ripple animation to the given X coordinate. + */ + setRippleCenter(xCoordinate: number): void; + + /** + * Deactivates the line ripple + */ + deactivate(): void; + + /** + * Handles a transition end event + */ + handleTransitionEnd(evt: Event): void; +} diff --git a/types/material__line-ripple/index.d.ts b/types/material__line-ripple/index.d.ts new file mode 100644 index 0000000000..f76ed98d10 --- /dev/null +++ b/types/material__line-ripple/index.d.ts @@ -0,0 +1,47 @@ +// 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 + +/** + * @license + * Copyright 2018 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import MDCComponent from 'material__base/component'; +import MDCLineRippleFoundation from './foundation'; +import MDCLineRippleAdapter from './adapter'; + +export { MDCLineRippleFoundation, MDCLineRippleAdapter }; + +export class MDCLineRipple extends MDCComponent { + static attachTo(root: Element): MDCLineRipple; + + /** + * Activates the line ripple + */ + activate(): void; + + /** + * Deactivates the line ripple + */ + deactivate(): void; + + /** + * Sets the transform origin given a user's click location. The `rippleCenter` is the + * x-coordinate of the middle of the ripple. + */ + setRippleCenter(xCoordinate: number): void; +} diff --git a/types/material__line-ripple/tsconfig.json b/types/material__line-ripple/tsconfig.json new file mode 100644 index 0000000000..2af99c6e5e --- /dev/null +++ b/types/material__line-ripple/tsconfig.json @@ -0,0 +1,27 @@ +{ + "files": [ + "constants.d.ts", + "adapter.d.ts", + "index.d.ts", + "foundation.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 + } +} \ No newline at end of file diff --git a/types/material__line-ripple/tslint.json b/types/material__line-ripple/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/material__line-ripple/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/material__linear-progress/adapter.d.ts b/types/material__linear-progress/adapter.d.ts index 92afccc19d..a8dd2dc163 100644 --- a/types/material__linear-progress/adapter.d.ts +++ b/types/material__linear-progress/adapter.d.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -export interface MDCLinearProgressAdapter { +export default interface MDCLinearProgressAdapter { addClass(className: string): void; getPrimaryBar(): Element; diff --git a/types/material__linear-progress/foundation.d.ts b/types/material__linear-progress/foundation.d.ts index 4abd553a09..5d67b121c7 100644 --- a/types/material__linear-progress/foundation.d.ts +++ b/types/material__linear-progress/foundation.d.ts @@ -14,12 +14,11 @@ * limitations under the License. */ -import { MDCFoundation } from 'material__base'; -import { transformStyleProperties } from 'material__animation'; -import { MDCLinearProgressAdapter } from './adapter'; +import MDCFoundation from 'material__base/foundation'; +import MDCLinearProgressAdapter from './adapter'; import { cssClasses, strings } from './constants'; -export class MDCLinearProgressFoundation extends MDCFoundation { +export default class MDCLinearProgressFoundation extends MDCFoundation { static readonly cssClasses: cssClasses; static readonly strings: strings; diff --git a/types/material__linear-progress/index.d.ts b/types/material__linear-progress/index.d.ts index 765d8cb368..4161a165f8 100644 --- a/types/material__linear-progress/index.d.ts +++ b/types/material__linear-progress/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for Material Components Web 0.26 +// Type definitions for Material Components Web 0.35 // Project: https://material.io/components/ -// Definitions by: Brent Douglas +// Definitions by: Brent Douglas , Collin Kostichuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 @@ -21,10 +21,10 @@ */ import { MDCComponent } from 'material__base'; -import { MDCLinearProgressAdapter } from './adapter'; -import { MDCLinearProgressFoundation } from './foundation'; +import MDCLinearProgressAdapter from './adapter'; +import MDCLinearProgressFoundation from './foundation'; -export {MDCLinearProgressAdapter, MDCLinearProgressFoundation}; +export { MDCLinearProgressAdapter, MDCLinearProgressFoundation }; export class MDCLinearProgress extends MDCComponent { static attachTo(root: Element): MDCLinearProgress; @@ -40,6 +40,4 @@ export class MDCLinearProgress extends MDCComponent { + static readonly cssClasses: cssClasses; + + static readonly strings: strings; + + static readonly numbers: numbers; + + static readonly Corner: Corner; + + static readonly defaultAdapter: MDCMenuAdapter; + + /** + * @param corner Default anchor corner alignment of top-left menu corner. + */ + setAnchorCorner(corner: Corner): void; + + /** + * @param margin 4-plet of margins from anchor. + */ + setAnchorMargin(margin: AnchorMargin): void; + + setRememberSelection(rememberSelection: boolean): void; + + setQuickOpen(quickOpen: boolean): void; + + open({focusIndex}?: { + focusIndex?: null; + }): void; + + close(evt?: Event): void; + + isOpen(): boolean; + + getSelectedIndex(): number; + + /** + * @param index Index of the item to set as selected. + */ + setSelectedIndex(index: number): void; +} diff --git a/types/material__menu/index.d.ts b/types/material__menu/index.d.ts index af9360d1a8..3c50c13690 100644 --- a/types/material__menu/index.d.ts +++ b/types/material__menu/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for Material Components Web 0.26 +// Type definitions for Material Components Web 0.35 // Project: https://material.io/components/ -// Definitions by: Brent Douglas +// Definitions by: Brent Douglas , Collin Kostichuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 @@ -20,7 +20,44 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import MDCComponent from 'material__base/component'; +import MDCMenuFoundation, { AnchorMargin } from './foundation'; +import MDCMenuAdapter from './adapter'; +import { Corner, CornerBit } from './constants'; -import * as util from './util'; -import { MDCSimpleMenu, MDCSimpleMenuAdapter, MDCSimpleMenuFoundation } from './simple/index'; -export { MDCSimpleMenu, MDCSimpleMenuAdapter, MDCSimpleMenuFoundation, util }; +export { MDCMenuFoundation, MDCMenuAdapter, AnchorMargin, Corner, CornerBit }; + +export class MDCMenu extends MDCComponent { + static attachTo(root: Element): MDCMenu; + + open: boolean; + + show(options?: { focusIndex?: number | null; }): void; + + hide(): void; + + /** + * @param corner Default anchor corner alignment of top-left menu corner. + */ + setAnchorCorner(corner: Corner): void; + + setAnchorMargin(margin: AnchorMargin): void; + + /** + * Return the items within the menu. Note that this only contains the set of elements within + * the items container that are proper list items, and not supplemental / presentational DOM + * elements. + */ + readonly items: Element[]; + + /** + * Return the item within the menu that is selected. + */ + getOptionByIndex(index: number): Element | null; + + selectedItemIndex: number; + + rememberSelection: boolean; + + quickOpen: boolean; +} diff --git a/types/material__menu/simple/constants.d.ts b/types/material__menu/simple/constants.d.ts deleted file mode 100644 index 58e2f16614..0000000000 --- a/types/material__menu/simple/constants.d.ts +++ /dev/null @@ -1,52 +0,0 @@ -/** - * @license - * 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, MDCNumbers } from 'material__base'; - -export interface cssClasses extends MDCStrings { - ROOT: 'mdc-simple-menu'; - OPEN: 'mdc-simple-menu--open'; - ANIMATING: 'mdc-simple-menu--animating'; - TOP_RIGHT: 'mdc-simple-menu--open-from-top-right'; - BOTTOM_LEFT: 'mdc-simple-menu--open-from-bottom-left'; - BOTTOM_RIGHT: 'mdc-simple-menu--open-from-bottom-right'; -} - -export interface strings extends MDCStrings { - ITEMS_SELECTOR: '.mdc-simple-menu__items'; - SELECTED_EVENT: 'MDCSimpleMenu:selected'; - CANCEL_EVENT: 'MDCSimpleMenu:cancel'; - ARIA_DISABLED_ATTR: 'aria-disabled'; -} - -export interface numbers extends MDCNumbers { - // Amount of time to wait before triggering a selected event on the menu. Note that this time - // will most likely be bumped up once interactive lists are supported to allow for the ripple to - // animate before closing the menu - SELECTED_TRIGGER_DELAY: 50; - // Total duration of the menu animation. - TRANSITION_DURATION_MS: 300; - // The menu starts its open animation with the X axis at this time value (0 - 1). - TRANSITION_SCALE_ADJUSTMENT_X: 0.5; - // The time value the menu waits until the animation starts on the Y axis (0 - 1). - TRANSITION_SCALE_ADJUSTMENT_Y: 0.2; - // The cubic bezier control points for the animation (cubic-bezier(0, 0, 0.2, 1)). - TRANSITION_X1: 0; - TRANSITION_Y1: 0; - TRANSITION_X2: 0.2; - TRANSITION_Y2: 1; -} diff --git a/types/material__menu/simple/index.d.ts b/types/material__menu/simple/index.d.ts deleted file mode 100644 index c2315810ba..0000000000 --- a/types/material__menu/simple/index.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @license - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import MDCComponent from 'material__base/component'; -import MDCSimpleMenuFoundation from './foundation'; -import MDCSimpleMenuAdapter from './adapter'; -import { getTransformPropertyName } from '../util'; - -export {MDCSimpleMenuAdapter, MDCSimpleMenuFoundation}; - -export class MDCSimpleMenu extends MDCComponent { - static attachTo(root: Element): MDCSimpleMenu; - - open: boolean; - - show(options?: {focusIndex?: number}): void; - - hide(): void; - - /** - * Return the items within the menu. Note that this only contains the set of elements within - * the items container that are proper list items, and not supplemental / presentational DOM - * elements. - */ - readonly items: Element[]; - - getDefaultFoundation(): MDCSimpleMenuFoundation; -} diff --git a/types/material__menu/tsconfig.json b/types/material__menu/tsconfig.json index 74016e9380..b257a72f11 100644 --- a/types/material__menu/tsconfig.json +++ b/types/material__menu/tsconfig.json @@ -1,11 +1,10 @@ { "files": [ - "simple/constants.d.ts", - "simple/adapter.d.ts", - "simple/index.d.ts", - "simple/foundation.d.ts", - "util.d.ts", - "index.d.ts" + "constants.d.ts", + "adapter.d.ts", + "index.d.ts", + "foundation.d.ts", + "util.d.ts" ], "compilerOptions": { "module": "commonjs", diff --git a/types/material__notched-outline/adapter.d.ts b/types/material__notched-outline/adapter.d.ts new file mode 100644 index 0000000000..8e44143e25 --- /dev/null +++ b/types/material__notched-outline/adapter.d.ts @@ -0,0 +1,57 @@ +/** + * @license + * Copyright 2017 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. + */ +/** + * Adapter for MDC Notched Outline. + * + * Defines the shape of the adapter expected by the foundation. Implement this + * adapter to integrate the Notched Outline into your framework. See + * https://github.com/material-components/material-components-web/blob/master/docs/authoring-components.md + * for more information. + */ + +export default interface MDCNotchedOutlineAdapter { + /** + * Returns the width of the root element. + */ + getWidth(): number; + + /** + * Returns the height of the root element. + */ + getHeight(): number; + + /** + * Adds a class to the root element. + */ + addClass(className: string): void; + + /** + * Removes a class from the root element. + */ + removeClass(className: string): void; + + /** + * Sets the "d" attribute of the outline element's SVG path. + */ + setOutlinePathAttr(value: string): void; + + /** + * Returns the idle outline element's computed style value of the given css property `propertyName`. + * We achieve this via `getComputedStyle(...).getPropertyValue(propertyName)`. + */ + getIdleOutlineStyleValue(propertyName: string): string; +} diff --git a/types/material__notched-outline/constants.d.ts b/types/material__notched-outline/constants.d.ts new file mode 100644 index 0000000000..2a18a77b8b --- /dev/null +++ b/types/material__notched-outline/constants.d.ts @@ -0,0 +1,27 @@ +/** + * @license + * Copyright 2018 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 strings extends MDCStrings { + PATH_SELECTOR: '.mdc-notched-outline__path'; + IDLE_OUTLINE_SELECTOR: '.mdc-notched-outline__idle'; +} + +export interface cssClasses extends MDCStrings { + OUTLINE_NOTCHED: 'mdc-notched-outline--notched'; +} diff --git a/types/material__notched-outline/foundation.d.ts b/types/material__notched-outline/foundation.d.ts new file mode 100644 index 0000000000..30234d65f9 --- /dev/null +++ b/types/material__notched-outline/foundation.d.ts @@ -0,0 +1,38 @@ +/** + * @license + * Copyright 2017 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/foundation'; +import { cssClasses, strings } from './constants'; +import MDCNotchedOutlineAdapter from './adapter'; + +export default class MDCNotchedOutlineFoundation extends MDCFoundation { + static readonly strings: strings; + + static readonly cssClasses: cssClasses; + + static readonly defaultAdapter: MDCNotchedOutlineAdapter; + + /** + * Adds the outline notched selector and updates the notch width + * calculated based off of notchWidth and isRtl. + */ + notch(notchWidth: number, isRtl?: boolean): void; + + /** + * Removes notched outline selector to close the notch in the outline. + */ + closeNotch(): void; +} diff --git a/types/material__notched-outline/index.d.ts b/types/material__notched-outline/index.d.ts new file mode 100644 index 0000000000..d22a9a6918 --- /dev/null +++ b/types/material__notched-outline/index.d.ts @@ -0,0 +1,41 @@ +// 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 + +/** + * @license + * Copyright 2017 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import MDCComponent from 'material__base/component'; +import MDCNotchedOutlineFoundation from './foundation'; +import MDCNotchedOutlineAdapter from './adapter'; + +export { MDCNotchedOutlineFoundation, MDCNotchedOutlineAdapter }; + +export class MDCNotchedOutline extends MDCComponent { + static attachTo(root: Element): MDCNotchedOutline; + + /** + * Updates outline selectors and SVG path to open notch. + */ + notch(notchWidth: number, isRtl?: boolean): void; + + /** + * Updates the outline selectors to close notch and return it to idle state. + */ + closeNotch(): void; +} diff --git a/types/material__notched-outline/tsconfig.json b/types/material__notched-outline/tsconfig.json new file mode 100644 index 0000000000..2af99c6e5e --- /dev/null +++ b/types/material__notched-outline/tsconfig.json @@ -0,0 +1,27 @@ +{ + "files": [ + "constants.d.ts", + "adapter.d.ts", + "index.d.ts", + "foundation.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 + } +} \ No newline at end of file diff --git a/types/material__notched-outline/tslint.json b/types/material__notched-outline/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/material__notched-outline/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/material__radio/adapter.d.ts b/types/material__radio/adapter.d.ts index 91035ea177..1238d2bae4 100644 --- a/types/material__radio/adapter.d.ts +++ b/types/material__radio/adapter.d.ts @@ -5,7 +5,7 @@ * 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 + * 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, @@ -27,14 +27,12 @@ import { MDCSelectionControlState } from 'material__selection-control'; * Implement this adapter for your framework of choice to delegate updates to * the component in your framework of choice. See architecture documentation * for more details. - * https://github.com/material-components/material-components-web/blob/master/docs/architecture.md + * https://github.com/material-components/material-components-web/blob/master/docs/code/architecture.md */ -export class MDCRadioAdapter { +export default interface MDCRadioAdapter { addClass(className: string): void; removeClass(className: string): void; getNativeControl(): MDCSelectionControlState; } - -export default MDCRadioAdapter; diff --git a/types/material__radio/foundation.d.ts b/types/material__radio/foundation.d.ts index f27bd30f1b..bb0720e831 100644 --- a/types/material__radio/foundation.d.ts +++ b/types/material__radio/foundation.d.ts @@ -15,28 +15,25 @@ */ import MDCFoundation from 'material__base/foundation'; -import { MDCSelectionControlState } from 'material__selection-control'; import MDCRadioAdapter from './adapter'; import { cssClasses, strings } from './constants'; -export class MDCRadioFoundation extends MDCFoundation { - static readonly cssClasses: cssClasses; +export default class MDCRadioFoundation extends MDCFoundation { + static readonly cssClasses: cssClasses; - static readonly strings: strings; + static readonly strings: strings; - static readonly defaultAdapter: MDCRadioAdapter; + static readonly defaultAdapter: MDCRadioAdapter; - isChecked(): boolean; + isChecked(): boolean; - setChecked(checked: boolean): void; + setChecked(checked: boolean): void; - isDisabled(): boolean; + isDisabled(): boolean; - setDisabled(disabled: boolean): void; + setDisabled(disabled: boolean): void; - getValue(): string; + getValue(): string; - setValue(value?: string): void; + setValue(value?: string): void; } - -export default MDCRadioFoundation; diff --git a/types/material__radio/index.d.ts b/types/material__radio/index.d.ts index e9001d9d84..d73206b791 100644 --- a/types/material__radio/index.d.ts +++ b/types/material__radio/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for Material Components Web 0.26 +// Type definitions for Material Components Web 0.35 // Project: https://material.io/components/ -// Definitions by: Brent Douglas +// Definitions by: Brent Douglas , Collin Kostichuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 @@ -25,7 +25,7 @@ import MDCComponent from 'material__base/component'; import { MDCSelectionControl } from 'material__selection-control'; import MDCRadioAdapter from './adapter'; import MDCRadioFoundation from './foundation'; -import { MDCRipple, MDCRippleFoundation } from 'material__ripple'; +import { MDCRipple } from 'material__ripple'; export {MDCRadioAdapter, MDCRadioFoundation}; @@ -39,8 +39,4 @@ export class MDCRadio extends MDCComponent value: string; readonly ripple: MDCRipple; - - destroy(): void; - - getDefaultFoundation(): MDCRadioFoundation; } diff --git a/types/material__ripple/adapter.d.ts b/types/material__ripple/adapter.d.ts index 0d2d319aab..ff5ab11231 100644 --- a/types/material__ripple/adapter.d.ts +++ b/types/material__ripple/adapter.d.ts @@ -32,11 +32,9 @@ * Implement this adapter for your framework of choice to delegate updates to * the component in your framework of choice. See architecture documentation * for more details. - * https://github.com/material-components/material-components-web/blob/master/docs/architecture.md - * - * @record + * https://github.com/material-components/material-components-web/blob/master/docs/code/architecture.md */ -export default class MDCRippleAdapter { +export default interface MDCRippleAdapter { browserSupportsCssVars(): boolean; isUnbounded(): boolean; @@ -49,17 +47,23 @@ export default class MDCRippleAdapter { removeClass(className: string): void; + containsEventTarget(target: EventTarget): void; + registerInteractionHandler(evtType: string, handler: EventListener): void; deregisterInteractionHandler(evtType: string, handler: EventListener): void; + registerDocumentInteractionHandler(evtType: string, handler: EventListener): void; + + deregisterDocumentInteractionHandler(evtType: string, handler: EventListener): void; + registerResizeHandler(handler: EventListener): void; deregisterResizeHandler(handler: EventListener): void; - updateCssVariable(varName: string, value: number|string): void; + updateCssVariable(varName: string, value: number | string | null): void; computeBoundingRect(): ClientRect; - getWindowPageOffset(): {x: number, y: number}; + getWindowPageOffset(): { x: number; y: number; }; } diff --git a/types/material__ripple/constants.d.ts b/types/material__ripple/constants.d.ts index 285d5f3f2c..b1dd4c12b4 100644 --- a/types/material__ripple/constants.d.ts +++ b/types/material__ripple/constants.d.ts @@ -24,15 +24,14 @@ export interface cssClasses extends MDCStrings { ROOT: 'mdc-ripple-upgraded'; UNBOUNDED: 'mdc-ripple-upgraded--unbounded'; BG_FOCUSED: 'mdc-ripple-upgraded--background-focused'; - BG_ACTIVE_FILL: 'mdc-ripple-upgraded--background-active-fill'; FG_ACTIVATION: 'mdc-ripple-upgraded--foreground-activation'; FG_DEACTIVATION: 'mdc-ripple-upgraded--foreground-deactivation'; } export interface strings extends MDCStrings { - VAR_FG_SIZE: '--mdc-ripple-fg-size'; VAR_LEFT: '--mdc-ripple-left'; VAR_TOP: '--mdc-ripple-top'; + VAR_FG_SIZE: '--mdc-ripple-fg-size'; VAR_FG_SCALE: '--mdc-ripple-fg-scale'; VAR_FG_TRANSLATE_START: '--mdc-ripple-fg-translate-start'; VAR_FG_TRANSLATE_END: '--mdc-ripple-fg-translate-end'; @@ -41,6 +40,7 @@ export interface strings extends MDCStrings { export interface numbers extends MDCNumbers { PADDING: 10; INITIAL_ORIGIN_SCALE: 0.6; - DEACTIVATION_TIMEOUT_MS: 300; - FG_DEACTIVATION_MS: 83; + DEACTIVATION_TIMEOUT_MS: 225; // Corresponds to $mdc-ripple-translate-duration (i.e. activation animation duration) + FG_DEACTIVATION_MS: 150; // Corresponds to $mdc-ripple-fade-out-duration (i.e. deactivation animation duration) + TAP_DELAY_MS: 300; // Delay between touch and simulated mouse events on touch devices } diff --git a/types/material__ripple/foundation.d.ts b/types/material__ripple/foundation.d.ts index b67632e441..fe6d33403a 100644 --- a/types/material__ripple/foundation.d.ts +++ b/types/material__ripple/foundation.d.ts @@ -18,39 +18,6 @@ import MDCFoundation from 'material__base/foundation'; import MDCRippleAdapter from './adapter'; import { cssClasses, strings, numbers } from './constants'; -import { getNormalizedEventCoords } from './util'; - -export interface ActivationStateType { - isActivated: boolean|undefined; - hasDeactivationUXRun: boolean|undefined; - wasActivatedByPointer: boolean|undefined; - wasElementMadeActive: boolean|undefined; - activationStartTime: number|undefined; - activationEvent: Event; - isProgrammatic: boolean|undefined; -} - -export interface ListenerInfoType { - activate: string|undefined; - deactivate: string|undefined; - focus: string|undefined; - blur: string|undefined; -} - -export interface ListenersType { - activate(e: Event): void; - - deactivate(e: Event): void; - - focus(): void; - - blur(): void; -} - -export interface PointType { - x: number; - y: number; -} export default class MDCRippleFoundation extends MDCFoundation { static readonly cssClasses: cssClasses; @@ -66,4 +33,6 @@ export default class MDCRippleFoundation extends MDCFoundation deactivate(event?: Event): void; layout(): void; + + setUnbounded(unbounded: boolean): void; } diff --git a/types/material__ripple/index.d.ts b/types/material__ripple/index.d.ts index 2f8379ac84..aaef1a6aff 100644 --- a/types/material__ripple/index.d.ts +++ b/types/material__ripple/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for Material Components Web 0.26 +// Type definitions for Material Components Web 0.35 // Project: https://material.io/components/ -// Definitions by: Brent Douglas +// Definitions by: Brent Douglas , Collin Kostichuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 @@ -29,21 +29,19 @@ import * as util from './util'; export {MDCRippleAdapter, MDCRippleFoundation, util}; export class MDCRipple extends MDCComponent { - static attachTo(root: Element, bound?: {isUnbounded: boolean|undefined}): MDCRipple; + static attachTo(root: Element, options?: { isUnbounded?: boolean; }): MDCRipple; - static createAdapter(instance: RippleCapableSurface): MDCRippleAdapter; + static createAdapter(instance: RippleCapableSurface): MDCRippleAdapter; - unbounded: boolean; + unbounded: boolean; - activate(): void; + activate(): void; - deactivate(): void; + deactivate(): void; - layout(): void; + layout(): void; - getDefaultFoundation(): MDCRippleFoundation; - - initialSyncWithDOM(): void; + initialSyncWithDOM(): void; } /** @@ -57,10 +55,10 @@ export class RippleCapableSurface { /** * Whether or not the ripple bleeds out of the bounds of the element. */ - unbounded: boolean|undefined; + unbounded: boolean | undefined; /** * Whether or not the ripple is attached to a disabled component. */ - disabled: boolean|undefined; + disabled: boolean | undefined; } diff --git a/types/material__select/adapter.d.ts b/types/material__select/adapter.d.ts index 2828b77361..b3b425e7a3 100644 --- a/types/material__select/adapter.d.ts +++ b/types/material__select/adapter.d.ts @@ -14,68 +14,28 @@ * limitations under the License. */ -export interface MDCSelectAdapter { +export default interface MDCSelectAdapter { addClass(className: string): void; removeClass(className: string): void; - addBodyClass(className: string): void; + floatLabel(value: boolean): void; - removeBodyClass(className: string): void; + activateBottomLine(): void; - setAttr(attr: string, value: string): void; - - rmAttr(attr: string): void; - - computeBoundingRect(): {left: number, top: number}; + deactivateBottomLine(): void; registerInteractionHandler(type: string, handler: EventListener): void; deregisterInteractionHandler(type: string, handler: EventListener): void; - focus(): void; + getSelectedIndex(): number; - makeTabbable(): void; + setSelectedIndex(index: number): void; - makeUntabbable(): void; + setDisabled(disabled: boolean): void; - getComputedStyleValue(propertyName: string): string; + getValue(): string; - setStyle(propertyName: string, value: string): void; - - create2dRenderingContext(): {font: string, measureText: (val: string) => {width: number}}; - - setMenuElStyle(propertyName: string, value: string): void; - - setMenuElAttr(attr: string, value: string): void; - - rmMenuElAttr(attr: string): void; - - getMenuElOffsetHeight(): number; - - openMenu(focusIndex: number): void; - - isMenuOpen(): boolean; - - setSelectedTextContent(textContent: string): void; - - getNumberOfOptions(): number; - - getTextForOptionAtIndex(index: number): string; - - getValueForOptionAtIndex(index: number): string; - - setAttrForOptionAtIndex(index: number, attr: string, value: string): void; - - rmAttrForOptionAtIndex(index: number, attr: string): void; - - getOffsetTopForOptionAtIndex(index: number): number; - - registerMenuInteractionHandler(type: string, handler: EventListener): void; - - deregisterMenuInteractionHandler(type: string, handler: EventListener): void; - - notifyChange(): void; - - getWindowInnerHeight(): number; + setValue(value: string): void; } diff --git a/types/material__select/constants.d.ts b/types/material__select/constants.d.ts index 1566d71322..f9a93da7b1 100644 --- a/types/material__select/constants.d.ts +++ b/types/material__select/constants.d.ts @@ -17,12 +17,14 @@ import { MDCStrings } from 'material__base'; export interface cssClasses extends MDCStrings { - ROOT: 'mdc-select'; - OPEN: 'mdc-select--open'; + BOX: 'mdc-select--box'; DISABLED: 'mdc-select--disabled'; - SCROLL_LOCK: 'mdc-select-scroll-lock'; + ROOT: 'mdc-select'; } export interface strings extends MDCStrings { CHANGE_EVENT: 'MDCSelect:change'; + LINE_RIPPLE_SELECTOR: '.mdc-line-ripple'; + LABEL_SELECTOR: '.mdc-floating-label'; + NATIVE_CONTROL_SELECTOR: '.mdc-select__native-control'; } diff --git a/types/material__select/foundation.d.ts b/types/material__select/foundation.d.ts index 6f66f79b5f..641c2a301a 100644 --- a/types/material__select/foundation.d.ts +++ b/types/material__select/foundation.d.ts @@ -16,25 +16,18 @@ import { MDCFoundation } from 'material__base'; import { cssClasses, strings } from './constants'; -import { MDCSimpleMenuFoundation } from 'material__menu'; -import { MDCSelectAdapter } from './adapter'; +import MDCSelectAdapter from './adapter'; export default class MDCSelectFoundation extends MDCFoundation { - static readonly cssClasses: cssClasses; + static readonly cssClasses: cssClasses; - static readonly strings: strings; + static readonly strings: strings; - static readonly defaultAdapter: MDCSelectAdapter; + static readonly defaultAdapter: MDCSelectAdapter; - getValue(): string; + setSelectedIndex(index: number): void; - getSelectedIndex(): number; + setValue(value: string): void; - setSelectedIndex(index: number): void; - - isDisabled(): boolean; - - setDisabled(disabled: boolean): void; - - resize(): void; + setDisabled(disabled: boolean): void; } diff --git a/types/material__select/index.d.ts b/types/material__select/index.d.ts index 78746a97d1..a487461ae7 100644 --- a/types/material__select/index.d.ts +++ b/types/material__select/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for Material Components Web 0.26 +// Type definitions for Material Components Web 0.35 // Project: https://material.io/components/ -// Definitions by: Brent Douglas +// Definitions by: Brent Douglas , Collin Kostichuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 @@ -21,33 +21,23 @@ */ import { MDCComponent } from 'material__base'; -import { MDCSimpleMenu } from 'material__menu'; - -import { MDCSelectAdapter } from './adapter'; import MDCSelectFoundation from './foundation'; +import MDCSelectAdapter from './adapter'; +import { MDCFloatingLabel } from 'material__floating-label'; +import { MDCLineRipple } from 'material__line-ripple'; export {MDCSelectAdapter, MDCSelectFoundation}; export class MDCSelect extends MDCComponent { static attachTo(root: Element): MDCSelect; - readonly value: string; - - readonly options: Element[]; - - readonly selectedOptions: NodeListOf; + value: string; selectedIndex: number; disabled: boolean; - item(index: number): Element|null; - - nameditem(key: string): Element|null; - - initialize(menuFactory?: (el: Element) => MDCSimpleMenu): void; - - getDefaultFoundation(): MDCSelectFoundation; + initialize(labelFactory?: (el: Element) => MDCFloatingLabel, lineRippleFactory?: (el: Element) => MDCLineRipple): void; initialSyncWithDOM(): void; } diff --git a/types/material__selection-control/index.d.ts b/types/material__selection-control/index.d.ts index 9c7f90c3fd..b5ce84d6ce 100644 --- a/types/material__selection-control/index.d.ts +++ b/types/material__selection-control/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for Material Components Web 0.26 +// Type definitions for Material Components Web 0.35 // Project: https://material.io/components/ -// Definitions by: Brent Douglas +// Definitions by: Brent Douglas , Collin Kostichuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 diff --git a/types/material__slider/adapter.d.ts b/types/material__slider/adapter.d.ts index 940ae04d76..b558c20799 100644 --- a/types/material__slider/adapter.d.ts +++ b/types/material__slider/adapter.d.ts @@ -14,14 +14,14 @@ * limitations under the License. */ -export interface MDCSliderAdapter { +export default interface MDCSliderAdapter { hasClass(className: string): boolean; addClass(className: string): void; removeClass(className: string): void; - getAttribute(name: string): string|null; + getAttribute(name: string): string | null; setAttribute(name: string, value: string): void; diff --git a/types/material__slider/foundation.d.ts b/types/material__slider/foundation.d.ts index 5da6942f49..97abb60e28 100644 --- a/types/material__slider/foundation.d.ts +++ b/types/material__slider/foundation.d.ts @@ -16,9 +16,8 @@ import { cssClasses, strings, numbers } from './constants'; -import { getCorrectEventName, getCorrectPropertyName } from 'material__animation'; import MDCFoundation from 'material__base/foundation'; -import { MDCSliderAdapter } from './adapter'; +import MDCSliderAdapter from './adapter'; export default class MDCSliderFoundation extends MDCFoundation { static readonly cssClasses: cssClasses; diff --git a/types/material__slider/index.d.ts b/types/material__slider/index.d.ts index 0d0e472775..1a1c02d86a 100644 --- a/types/material__slider/index.d.ts +++ b/types/material__slider/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for Material Components Web 0.26 +// Type definitions for Material Components Web 0.35 // Project: https://material.io/components/ -// Definitions by: Brent Douglas +// Definitions by: Brent Douglas , Collin Kostichuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 @@ -23,32 +23,30 @@ import MDCComponent from 'material__base/component'; import MDCSliderFoundation from './foundation'; -import { MDCSliderAdapter } from './adapter'; +import MDCSliderAdapter from './adapter'; export {MDCSliderAdapter, MDCSliderFoundation}; export class MDCSlider extends MDCComponent { - static attachTo(root: Element): MDCSlider; + static attachTo(root: Element): MDCSlider; - value: number; + value: number; - min: number; + min: number; - max: number; + max: number; - step: number; + step: number; - disabled: boolean; + disabled: boolean; - initialize(): void; + initialize(): void; - getDefaultFoundation(): MDCSliderFoundation; + initialSyncWithDOM(): void; - initialSyncWithDOM(): void; + layout(): void; - layout(): void; + stepUp(amount?: number): void; - stepUp(amount?: number): void; - - stepDown(amount?: number): void; + stepDown(amount?: number): void; } diff --git a/types/material__snackbar/adapter.d.ts b/types/material__snackbar/adapter.d.ts index 412329bd97..12ac56c6f7 100644 --- a/types/material__snackbar/adapter.d.ts +++ b/types/material__snackbar/adapter.d.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -export interface MDCSnackbarAdapter { +export default interface MDCSnackbarAdapter { addClass(className: string): void; removeClass(className: string): void; setAriaHidden(): void; @@ -35,4 +35,6 @@ export interface MDCSnackbarAdapter { deregisterActionClickHandler(handler: EventListener): void; registerTransitionEndHandler(handler: EventListener): void; deregisterTransitionEndHandler(handler: EventListener): void; + notifyShow(): void; + notifyHide(): void; } diff --git a/types/material__snackbar/constants.d.ts b/types/material__snackbar/constants.d.ts index 7bf6758a0a..7c5cf27999 100644 --- a/types/material__snackbar/constants.d.ts +++ b/types/material__snackbar/constants.d.ts @@ -30,6 +30,8 @@ export interface strings extends MDCStrings { TEXT_SELECTOR: '.mdc-snackbar__text'; ACTION_WRAPPER_SELECTOR: '.mdc-snackbar__action-wrapper'; ACTION_BUTTON_SELECTOR: '.mdc-snackbar__action-button'; + SHOW_EVENT: 'MDCSnackbar:show'; + HIDE_EVENT: 'MDCSnackbar:hide'; } export interface numbers extends MDCNumbers { diff --git a/types/material__snackbar/foundation.d.ts b/types/material__snackbar/foundation.d.ts index 5c85ab5f85..a695a1a33e 100644 --- a/types/material__snackbar/foundation.d.ts +++ b/types/material__snackbar/foundation.d.ts @@ -14,9 +14,9 @@ * limitations under the License. */ -import { MDCFoundation } from 'material__base'; +import MDCFoundation from 'material__base/foundation'; import { cssClasses, strings, numbers } from './constants'; -import { MDCSnackbarAdapter } from './adapter'; +import MDCSnackbarAdapter from './adapter'; export interface MDCSnackbarData { message: string; @@ -27,18 +27,18 @@ export interface MDCSnackbarData { timeout?: number; } -export class MDCSnackbarFoundation extends MDCFoundation { - static readonly cssClasses: cssClasses; +export default class MDCSnackbarFoundation extends MDCFoundation { + static readonly cssClasses: cssClasses; - static readonly strings: strings; + static readonly strings: strings; - static readonly defaultAdapter: MDCSnackbarAdapter; + static readonly defaultAdapter: MDCSnackbarAdapter; - readonly active: boolean; + readonly active: boolean; - dismissesOnAction(): boolean; + dismissesOnAction(): boolean; - setDismissOnAction(dismissOnAction: boolean): void; + setDismissOnAction(dismissOnAction: boolean): void; - show(data: MDCSnackbarData): void; + show(data: MDCSnackbarData): void; } diff --git a/types/material__snackbar/index.d.ts b/types/material__snackbar/index.d.ts index 11ac69f573..da6ecd4ca2 100644 --- a/types/material__snackbar/index.d.ts +++ b/types/material__snackbar/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for Material Components Web 0.26 +// Type definitions for Material Components Web 0.35 // Project: https://material.io/components/ -// Definitions by: Brent Douglas +// Definitions by: Brent Douglas , Collin Kostichuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 @@ -21,18 +21,15 @@ */ import { MDCComponent } from 'material__base'; -import { MDCSnackbarAdapter } from './adapter'; -import { MDCSnackbarFoundation, MDCSnackbarData } from './foundation'; -import { getCorrectEventName } from 'material__animation'; +import MDCSnackbarAdapter from './adapter'; +import MDCSnackbarFoundation, { MDCSnackbarData } from './foundation'; export {MDCSnackbarAdapter, MDCSnackbarFoundation}; export class MDCSnackbar extends MDCComponent { - static attachTo(root: Element): MDCSnackbar; + static attachTo(root: Element): MDCSnackbar; - show(data: MDCSnackbarData): void; + show(data: MDCSnackbarData): void; - getDefaultFoundation(): MDCSnackbarFoundation; - - dismissesOnAction: boolean; + dismissesOnAction: boolean; } diff --git a/types/material__textfield/bottom-line/adapter.d.ts b/types/material__tab/adapter.d.ts similarity index 58% rename from types/material__textfield/bottom-line/adapter.d.ts rename to types/material__tab/adapter.d.ts index 25b8de0477..90b89dca00 100644 --- a/types/material__textfield/bottom-line/adapter.d.ts +++ b/types/material__tab/adapter.d.ts @@ -1,6 +1,6 @@ /** * @license - * Copyright 2017 Google Inc. All Rights Reserved. + * Copyright 2018 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. @@ -14,47 +14,41 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - /** - * Adapter for MDC TextField Bottom Line. + * Adapter for MDC Tab. * * Defines the shape of the adapter expected by the foundation. Implement this - * adapter to integrate the TextField bottom line into your framework. See + * adapter to integrate the Tab into your framework. See * https://github.com/material-components/material-components-web/blob/master/docs/authoring-components.md - * for more information. - * - * @record */ -export default class MDCTextFieldBottomLineAdapter { +export default interface MDCTabAdapter { /** - * Adds a class to the bottom line element. - */ - addClass(className: string): void; - - /** - * Removes a class from the bottom line element. - */ - removeClass(className: string): void; - - /** - * Sets an attribute with a given value on the bottom line element. - */ - setAttr(attr: string, value: string): void; - - /** - * Registers an event listener on the bottom line element for a given event. + * Registers an event listener on the root element for a given event. */ registerEventHandler(evtType: string, handler: EventListener): void; /** - * Deregisters an event listener on the bottom line element for a given event. + * Deregisters an event listener on the root element for a given event. */ deregisterEventHandler(evtType: string, handler: EventListener): void; /** - * Emits a custom event "MDCTextFieldBottomLine:animation-end" denoting the - * bottom line has finished its animation; either the activate or - * deactivate animation + * Adds the given className to the root element. */ - notifyAnimationEnd(): void; + addClass(className: string): void; + + /** + * Removes the given className from the root element. + */ + removeClass(className: string): void; + + /** + * Returns whether the root element has the given className. + */ + hasClass(className: string): boolean; + + /** + * Sets the given attrName of the root element to the given value. + */ + setAttr(attr: string, value: string): void; } diff --git a/types/material__tab/constants.d.ts b/types/material__tab/constants.d.ts new file mode 100644 index 0000000000..7d4a710a64 --- /dev/null +++ b/types/material__tab/constants.d.ts @@ -0,0 +1,27 @@ +/** + * @license + * Copyright 2018 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 { + ACTIVE: 'mdc-tab--active'; + ANIMATING_ACTIVATE: 'mdc-tab--animating-activate'; + ANIMATING_DEACTIVATE: 'mdc-tab--animating-deactivate'; +} + +export interface strings extends MDCStrings { + ARIA_SELECTED: 'aria-selected'; +} diff --git a/types/material__textfield/bottom-line/foundation.d.ts b/types/material__tab/foundation.d.ts similarity index 64% rename from types/material__textfield/bottom-line/foundation.d.ts rename to types/material__tab/foundation.d.ts index 6945695348..bd438ef48e 100644 --- a/types/material__textfield/bottom-line/foundation.d.ts +++ b/types/material__tab/foundation.d.ts @@ -1,6 +1,6 @@ /** * @license - * Copyright 2017 Google Inc. All Rights Reserved. + * Copyright 2018 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. @@ -14,35 +14,31 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - import MDCFoundation from 'material__base/foundation'; -import MDCTextFieldBottomLineAdapter from './adapter'; import { cssClasses, strings } from './constants'; +import MDCTabAdapter from './adapter'; -export default class MDCTextFieldBottomLineFoundation extends MDCFoundation { +export default class MDCTabFoundation extends MDCFoundation { static readonly cssClasses: cssClasses; static readonly strings: strings; - static readonly defaultAdapter: MDCTextFieldBottomLineAdapter; + static readonly defaultAdapter: MDCTabAdapter; + + handleTransitionEnd(evt: Event): void; /** - * Activates the bottom line + * Returns the Tab's active state + */ + isActive(): boolean; + + /** + * Activates the Tab */ activate(): void; /** - * Sets the transform origin given a user's click location. - */ - setTransformOrigin(evt: Event): void; - - /** - * Deactivates the bottom line + * Deactivates the Tab */ deactivate(): void; - - /** - * Handles a transition end event - */ - handleTransitionEnd(evt: Event): void; } diff --git a/types/material__tab/index.d.ts b/types/material__tab/index.d.ts new file mode 100644 index 0000000000..b2cc71129e --- /dev/null +++ b/types/material__tab/index.d.ts @@ -0,0 +1,33 @@ +// 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 + +/** + * @license + * Copyright 2018 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import MDCComponent from 'material__base/component'; +import MDCTabFoundation from './foundation'; +import MDCTabAdapter from './adapter'; + +export { MDCTabFoundation, MDCTabAdapter }; + +export class MDCTab extends MDCComponent { + static attachTo(root: Element): MDCTab; + + active: boolean; +} diff --git a/types/material__tab/tsconfig.json b/types/material__tab/tsconfig.json new file mode 100644 index 0000000000..2af99c6e5e --- /dev/null +++ b/types/material__tab/tsconfig.json @@ -0,0 +1,27 @@ +{ + "files": [ + "constants.d.ts", + "adapter.d.ts", + "index.d.ts", + "foundation.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 + } +} \ No newline at end of file diff --git a/types/material__tab/tslint.json b/types/material__tab/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/material__tab/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/material__tabs/index.d.ts b/types/material__tabs/index.d.ts index b268e55a8d..b5a9d4143e 100644 --- a/types/material__tabs/index.d.ts +++ b/types/material__tabs/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for Material Components Web 0.26 +// Type definitions for Material Components Web 0.35 // Project: https://material.io/components/ -// Definitions by: Brent Douglas +// Definitions by: Brent Douglas , Collin Kostichuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 @@ -20,6 +20,6 @@ * limitations under the License. */ -export {MDCTabFoundation, MDCTab} from './tab/index'; -export {MDCTabBarAdapter, MDCTabBarFoundation, MDCTabBar} from './tab-bar/index'; -export {MDCTabBarScrollerAdapter, MDCTabBarScrollerFoundation, MDCTabBarScroller} from './tab-bar-scroller/index'; +export { MDCTabFoundation, MDCTab, MDCTabAdapter } from './tab'; +export { MDCTabBarFoundation, MDCTabBar, MDCTabBarAdapter } from './tab-bar'; +export { MDCTabBarScrollerFoundation, MDCTabBarScroller, MDCTabBarScrollerAdapter } from './tab-bar-scroller'; diff --git a/types/material__tabs/tab-bar-scroller/adapter.d.ts b/types/material__tabs/tab-bar-scroller/adapter.d.ts index 8c1286fc74..b46d2d3e5f 100644 --- a/types/material__tabs/tab-bar-scroller/adapter.d.ts +++ b/types/material__tabs/tab-bar-scroller/adapter.d.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -export interface MDCTabBarScrollerAdapter { +export default interface MDCTabBarScrollerAdapter { addClass(className: string): void; removeClass(className: string): void; diff --git a/types/material__tabs/tab-bar-scroller/foundation.d.ts b/types/material__tabs/tab-bar-scroller/foundation.d.ts index ed470c20d2..273a6f048a 100644 --- a/types/material__tabs/tab-bar-scroller/foundation.d.ts +++ b/types/material__tabs/tab-bar-scroller/foundation.d.ts @@ -17,7 +17,7 @@ import MDCFoundation from 'material__base/foundation'; import { cssClasses, strings } from './constants'; -import { MDCTabBarScrollerAdapter } from './adapter'; +import MDCTabBarScrollerAdapter from './adapter'; export default class MDCTabBarScrollerFoundation extends MDCFoundation { static readonly cssClasses: cssClasses; diff --git a/types/material__tabs/tab-bar-scroller/index.d.ts b/types/material__tabs/tab-bar-scroller/index.d.ts index a9d71b305c..984a1fc838 100644 --- a/types/material__tabs/tab-bar-scroller/index.d.ts +++ b/types/material__tabs/tab-bar-scroller/index.d.ts @@ -14,23 +14,20 @@ * limitations under the License. */ -import { getCorrectPropertyName } from 'material__animation'; import MDCComponent from 'material__base/component'; -import { MDCTabBar } from '../tab-bar/index'; +import { MDCTabBar } from '../tab-bar'; import MDCTabBarScrollerFoundation from './foundation'; -import { MDCTabBarScrollerAdapter } from './adapter'; +import MDCTabBarScrollerAdapter from './adapter'; -export {MDCTabBarScrollerAdapter, MDCTabBarScrollerFoundation}; +export { MDCTabBarScrollerAdapter, MDCTabBarScrollerFoundation }; export class MDCTabBarScroller extends MDCComponent { - static attachTo(root: Element): MDCTabBarScroller; + static attachTo(root: Element): MDCTabBarScroller; - readonly tabBar: MDCTabBar; + readonly tabBar: MDCTabBar; - initialize(tabBarFactory?: (el: Element) => MDCTabBar): void; + initialize(tabBarFactory?: (root: Element) => MDCTabBar): void; - getDefaultFoundation(): MDCTabBarScrollerFoundation; - - layout(): void; + layout(): void; } diff --git a/types/material__tabs/tab-bar/adapter.d.ts b/types/material__tabs/tab-bar/adapter.d.ts index 1efa73f52c..0e43efc074 100644 --- a/types/material__tabs/tab-bar/adapter.d.ts +++ b/types/material__tabs/tab-bar/adapter.d.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -export interface MDCTabBarAdapter { +export default interface MDCTabBarAdapter { addClass(className: string): void; removeClass(className: string): void; diff --git a/types/material__tabs/tab-bar/foundation.d.ts b/types/material__tabs/tab-bar/foundation.d.ts index 2e5ccb1de2..84693dc2cd 100644 --- a/types/material__tabs/tab-bar/foundation.d.ts +++ b/types/material__tabs/tab-bar/foundation.d.ts @@ -15,10 +15,8 @@ */ import MDCFoundation from 'material__base/foundation'; -import { getCorrectPropertyName } from 'material__animation'; - import { cssClasses, strings } from './constants'; -import { MDCTabBarAdapter } from './adapter'; +import MDCTabBarAdapter from './adapter'; export default class MDCTabBarFoundation extends MDCFoundation { static readonly cssClasses: cssClasses; diff --git a/types/material__tabs/tab-bar/index.d.ts b/types/material__tabs/tab-bar/index.d.ts index 127a62217f..d50d841105 100644 --- a/types/material__tabs/tab-bar/index.d.ts +++ b/types/material__tabs/tab-bar/index.d.ts @@ -16,9 +16,9 @@ import MDCComponent from 'material__base/component'; -import { MDCTab, MDCTabFoundation } from '../tab/index'; +import { MDCTab } from '../tab'; import MDCTabBarFoundation from './foundation'; -import { MDCTabBarAdapter } from './adapter'; +import MDCTabBarAdapter from './adapter'; export {MDCTabBarAdapter, MDCTabBarFoundation}; @@ -33,7 +33,5 @@ export class MDCTabBar extends MDCComponent MDCTab): void; - getDefaultFoundation(): MDCTabBarFoundation; - layout(): void; } diff --git a/types/material__tabs/tab/adapter.d.ts b/types/material__tabs/tab/adapter.d.ts index bc07aa5aa7..2058c690e4 100644 --- a/types/material__tabs/tab/adapter.d.ts +++ b/types/material__tabs/tab/adapter.d.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -export interface MDCTabAdapter { +export default interface MDCTabAdapter { addClass(className: string): void; removeClass(className: string): void; diff --git a/types/material__tabs/tab/foundation.d.ts b/types/material__tabs/tab/foundation.d.ts index 46e14065c8..04f727fcb2 100644 --- a/types/material__tabs/tab/foundation.d.ts +++ b/types/material__tabs/tab/foundation.d.ts @@ -16,9 +16,9 @@ import MDCFoundation from 'material__base/foundation'; import { cssClasses, strings } from './constants'; -import { MDCTabAdapter } from './adapter'; +import MDCTabAdapter from './adapter'; -export class MDCTabFoundation extends MDCFoundation { +export default class MDCTabFoundation extends MDCFoundation { static readonly cssClasses: cssClasses; static readonly strings: strings; diff --git a/types/material__tabs/tab/index.d.ts b/types/material__tabs/tab/index.d.ts index bf41b77e65..43fc8b4ec6 100644 --- a/types/material__tabs/tab/index.d.ts +++ b/types/material__tabs/tab/index.d.ts @@ -15,11 +15,8 @@ */ import MDCComponent from 'material__base/component'; -import { MDCRipple } from 'material__ripple'; - -import { MDCTabAdapter } from './adapter'; -import { cssClasses } from './constants'; -import { MDCTabFoundation } from './foundation'; +import MDCTabFoundation from './foundation'; +import MDCTabAdapter from './adapter'; export {MDCTabAdapter, MDCTabFoundation}; @@ -34,10 +31,6 @@ export class MDCTab extends MDCComponent { preventDefaultOnClick: boolean; - destroy(): void; - - getDefaultFoundation(): MDCTabFoundation; - initialSyncWithDOM(): void; measureSelf(): void; diff --git a/types/material__textfield/adapter.d.ts b/types/material__textfield/adapter.d.ts index ca13544c26..8a583b20e5 100644 --- a/types/material__textfield/adapter.d.ts +++ b/types/material__textfield/adapter.d.ts @@ -1,6 +1,6 @@ /** * @license - * Copyright 2017 Google Inc. All Rights Reserved. + * Copyright 2018 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. @@ -15,14 +15,22 @@ * limitations under the License. */ -import MDCTextFieldBottomLineFoundation from './bottom-line/foundation'; -import MDCTextFieldHelperTextFoundation from './helper-text/foundation'; +import { MDCTextFieldHelperTextFoundation } from './helper-text'; +import { MDCTextFieldIconFoundation } from './icon'; export interface NativeInputType { value: string; disabled: boolean; badInput: boolean; - checkValidity(): boolean; + validity: { + badInput: boolean; + valid: boolean; + }; +} + +export interface FoundationMapType { + helperText?: MDCTextFieldHelperTextFoundation; + icon?: MDCTextFieldIconFoundation; } /** @@ -32,10 +40,8 @@ export interface NativeInputType { * adapter to integrate the Text Field into your framework. See * https://github.com/material-components/material-components-web/blob/master/docs/authoring-components.md * for more information. - * - * @record */ -export class MDCTextFieldAdapter { +export default interface MDCTextFieldAdapter { /** * Adds a class to the root Element. */ @@ -47,27 +53,9 @@ export class MDCTextFieldAdapter { removeClass(className: string): void; /** - * Adds a class to the label Element. We recommend you add a conditional - * check here, and in removeClassFromLabel for whether or not the label is - * present so that the JS component could be used with text fields that don't - * require a label, such as the full-width text field. + * Returns true if the root element contains the given class name. */ - addClassToLabel(className: string): void; - - /** - * Removes a class from the label Element. - */ - removeClassFromLabel(className: string): void; - - /** - * Sets an attribute on the icon Element. - */ - setIconAttr(name: string, value: string): void; - - /** - * Returns true if classname exists for a given target element. - */ - eventTargetHasClass(target: EventTarget, className: string): boolean; + hasClass(className: string): boolean; /** * Registers an event handler on the root element for a given event. @@ -79,28 +67,6 @@ export class MDCTextFieldAdapter { */ deregisterTextFieldInteractionHandler(type: string, handler: EventListener): void; - /** - * Emits a custom event "MDCTextField:icon" denoting a user has clicked the icon. - */ - notifyIconAction(): void; - - /** - * Adds a class to the helper text element. Note that in our code we check for - * whether or not we have a helper text element and if we don't, we simply - * return. - */ - addClassToHelperText(className: string): void; - - /** - * Removes a class from the helper text element. - */ - removeClassFromHelperText(className: string): void; - - /** - * Returns whether or not the helper text element contains the given class. - */ - helperTextHasClass(className: string): boolean; - /** * Registers an event listener on the native input element for a given event. */ @@ -112,29 +78,14 @@ export class MDCTextFieldAdapter { deregisterInputInteractionHandler(evtType: string, handler: EventListener): void; /** - * Registers an event listener on the bottom line element for a given event. + * Registers a validation attribute change listener on the input element. */ - registerBottomLineEventHandler(evtType: string, handler: EventListener): void; + registerValidationAttributeChangeHandler(handler: EventListener): void; /** - * Deregisters an event listener on the bottom line element for a given event. + * Disconnects a validation attribute observer on the input element. */ - deregisterBottomLineEventHandler(evtType: string, handler: EventListener): void; - - /** - * Sets an attribute with a given value on the helper text element. - */ - setHelperTextAttr(name: string, value: string): void; - - /** - * Removes an attribute from the helper text element. - */ - removeHelperTextAttr(name: string): void; - - /** - * Sets the text content for the help text element - */ - setHelperTextContent(content: string): void; + deregisterValidationAttributeChangeHandler(observer: MutationObserver): void; /** * Returns an object representing the native text input element, with a @@ -145,17 +96,72 @@ export class MDCTextFieldAdapter { * in your implementation it's important to keep this in mind. Also note that * this method can return null, which the foundation will handle gracefully. */ - getNativeInput(): Element|NativeInputType; + getNativeInput(): (Element | (NativeInputType | null)) | null; /** - * Returns the foundation for the bottom line element. Returns undefined if - * there is no bottom line element. + * Returns true if the textfield is focused. + * We achieve this via `document.activeElement === this.root_`. */ - getBottomLineFoundation(): MDCTextFieldBottomLineFoundation; + isFocused(): boolean; /** - * Returns the foundation for the helper text element. Returns undefined if - * there is no helper text element. + * Returns true if the direction of the root element is set to RTL. */ - getHelperTextFoundation(): MDCTextFieldHelperTextFoundation; + isRtl(): boolean; + + /** + * Activates the line ripple. + */ + activateLineRipple(): void; + + /** + * Deactivates the line ripple. + */ + deactivateLineRipple(): void; + + /** + * Sets the transform origin of the line ripple. + */ + setLineRippleTransformOrigin(normalizedX: number): void; + + /** + * Only implement if label exists. + * Shakes label if shouldShake is true. + */ + shakeLabel(shouldShake: boolean): void; + + /** + * Only implement if label exists. + * Floats the label above the input element if shouldFloat is true. + */ + floatLabel(shouldFloat: boolean): void; + + /** + * Returns true if label element exists, false if it doesn't. + */ + hasLabel(): boolean; + + /** + * Only implement if label exists. + * Returns width of label in pixels. + */ + getLabelWidth(): number; + + /** + * Returns true if outline element exists, false if it doesn't. + */ + hasOutline(): boolean; + + /** + * Only implement if outline element exists. + * Updates SVG Path and outline element based on the + * label element width and RTL context. + */ + notchOutline(labelWidth: number, isRtl: boolean | undefined): void; + + /** + * Only implement if outline element exists. + * Closes notch in outline element. + */ + closeOutline(): void; } diff --git a/types/material__textfield/constants.d.ts b/types/material__textfield/constants.d.ts index 7150bb4b14..8877368c48 100644 --- a/types/material__textfield/constants.d.ts +++ b/types/material__textfield/constants.d.ts @@ -15,26 +15,29 @@ * limitations under the License. */ -import { MDCStrings } from 'material__base'; +import { MDCStrings, MDCNumbers } from 'material__base'; export interface strings extends MDCStrings { ARIA_CONTROLS: 'aria-controls'; INPUT_SELECTOR: '.mdc-text-field__input'; - LABEL_SELECTOR: '.mdc-text-field__label'; + LABEL_SELECTOR: '.mdc-floating-label'; ICON_SELECTOR: '.mdc-text-field__icon'; - ICON_EVENT: 'MDCTextField:icon'; - BOTTOM_LINE_SELECTOR: '.mdc-text-field__bottom-line'; + OUTLINE_SELECTOR: '.mdc-notched-outline'; + LINE_RIPPLE_SELECTOR: '.mdc-line-ripple'; } export interface cssClasses extends MDCStrings { ROOT: 'mdc-text-field'; UPGRADED: 'mdc-text-field--upgraded'; DISABLED: 'mdc-text-field--disabled'; + DENSE: 'mdc-text-field--dense'; FOCUSED: 'mdc-text-field--focused'; INVALID: 'mdc-text-field--invalid'; - LABEL_FLOAT_ABOVE: 'mdc-text-field__label--float-above'; - LABEL_SHAKE: 'mdc-text-field__label--shake'; BOX: 'mdc-text-field--box'; - TEXT_FIELD_ICON: 'mdc-text-field__icon'; - TEXTAREA: 'mdc-text-field--textarea'; + OUTLINED: 'mdc-text-field--outlined'; +} + +export interface numbers extends MDCNumbers { + LABEL_SCALE: 0.75; + DENSE_LABEL_SCALE: 0.923; } diff --git a/types/material__textfield/foundation.d.ts b/types/material__textfield/foundation.d.ts index d36d83867e..ffc0436f45 100644 --- a/types/material__textfield/foundation.d.ts +++ b/types/material__textfield/foundation.d.ts @@ -16,29 +16,44 @@ */ import MDCFoundation from 'material__base/foundation'; -import { MDCTextFieldAdapter, NativeInputType } from './adapter'; -import MDCTextFieldBottomLineFoundation from './bottom-line/foundation'; -import { cssClasses, strings } from './constants'; +import { cssClasses, strings, numbers } from './constants'; +import MDCTextFieldAdapter, { FoundationMapType } from './adapter'; export default class MDCTextFieldFoundation extends MDCFoundation { static readonly cssClasses: cssClasses; static readonly strings: strings; + static readonly numbers: numbers; + + readonly shouldShake: boolean; + + readonly shouldFloat: boolean; + static readonly defaultAdapter: MDCTextFieldAdapter; - handleTextFieldInteraction(evt: Event): void; + constructor(adapter: MDCTextFieldAdapter, foundationMap?: FoundationMapType); + /** + * Handles user interactions with the Text Field. + */ + handleTextFieldInteraction(): void; + + /** + * Opens/closes the notched outline. + */ + + notchOutline(openNotch: boolean): void; /** * Activates the text field focus state. */ - activateFocus(): void; + activateFocus(): void; /** - * Sets the bottom line's transform origin, so that the bottom line activate + * Sets the line ripple's transform origin, so that the line ripple activate * animation will animate out from the user's click location. */ - setBottomLineTransformOrigin(evt: Event): void; + setTransformOrigin(evt: Event): void; /** * Activates the Text Field's focus state in cases when the input value @@ -46,34 +61,19 @@ export default class MDCTextFieldFoundation extends MDCFoundation { + static readonly strings: strings; + + static readonly defaultAdapter: MDCTextFieldIconAdapter; + + /** + * Sets the content of the helper text field. + */ + setDisabled(disabled: boolean): void; + + /** + * Handles an interaction event + */ + handleInteraction(evt: Event): void; +} diff --git a/types/material__textfield/bottom-line/index.d.ts b/types/material__textfield/icon/index.d.ts similarity index 58% rename from types/material__textfield/bottom-line/index.d.ts rename to types/material__textfield/icon/index.d.ts index a0ed4ff36d..3e6cfc542b 100644 --- a/types/material__textfield/bottom-line/index.d.ts +++ b/types/material__textfield/icon/index.d.ts @@ -14,18 +14,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - import MDCComponent from 'material__base/component'; +import MDCTextFieldIconFoundation from './foundation'; +import MDCTextFieldIconAdapter from './adapter'; -import MDCTextFieldBottomLineAdapter from './adapter'; -import MDCTextFieldBottomLineFoundation from './foundation'; +export { MDCTextFieldIconFoundation, MDCTextFieldIconAdapter }; -export {MDCTextFieldBottomLineAdapter, MDCTextFieldBottomLineFoundation}; +export class MDCTextFieldIcon extends MDCComponent { + static attachTo(root: Element): MDCTextFieldIcon; -export class MDCTextFieldBottomLine extends MDCComponent { - static attachTo(root: Element): MDCTextFieldBottomLine; - - readonly foundation: MDCTextFieldBottomLineFoundation; - - getDefaultFoundation(): MDCTextFieldBottomLineFoundation; + readonly foundation: MDCTextFieldIconFoundation; } diff --git a/types/material__textfield/index.d.ts b/types/material__textfield/index.d.ts index 85d4c36420..b3e61550c9 100644 --- a/types/material__textfield/index.d.ts +++ b/types/material__textfield/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for Material Components Web 0.26 +// Type definitions for Material Components Web 0.35 // Project: https://material.io/components/ -// Definitions by: Brent Douglas +// Definitions by: Brent Douglas , Collin Kostichuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 @@ -22,25 +22,29 @@ */ import MDCComponent from 'material__base/component'; -import { MDCRipple } from 'material__ripple'; - -import { cssClasses, strings } from './constants'; -import { MDCTextFieldAdapter } from './adapter'; import MDCTextFieldFoundation from './foundation'; -import { MDCTextFieldBottomLine } from './bottom-line/index'; -import { MDCTextFieldHelperText } from './helper-text/index'; +import MDCTextFieldAdapter, { FoundationMapType } from './adapter'; +import { MDCTextFieldHelperText, MDCTextFieldHelperTextFoundation, MDCTextFieldHelperTextAdapter } from './helper-text'; +import { MDCTextFieldIcon, MDCTextFieldIconFoundation, MDCTextFieldIconAdapter } from './icon'; +import { MDCRipple, MDCRippleFoundation } from 'material__ripple'; +import { MDCLineRipple } from 'material__line-ripple'; +import { MDCFloatingLabel } from 'material__floating-label'; +import { MDCNotchedOutline } from 'material__notched-outline'; -export {MDCTextFieldAdapter, MDCTextFieldFoundation}; +export { MDCTextFieldFoundation, MDCTextFieldAdapter, MDCTextFieldHelperText }; +export { MDCTextFieldHelperTextFoundation, MDCTextFieldHelperTextAdapter, MDCTextFieldIcon }; +export { MDCTextFieldIconFoundation, MDCTextFieldIconAdapter }; export class MDCTextField extends MDCComponent { static attachTo(root: Element): MDCTextField; initialize( - rippleFactory?: (el: Element) => MDCRipple, - bottomLineFactory?: (el: Element) => MDCTextFieldBottomLine - ): void; - - destroy(): void; + rippleFactory?: (el: Element, foundation: MDCRippleFoundation) => MDCRipple, + lineRippleFactory?: (el: Element) => MDCLineRipple, + helperTextFactory?: (el: Element) => MDCTextFieldHelperText, + iconFactory?: (el: Element) => MDCTextFieldIcon, + labelFactory?: (el: Element) => MDCFloatingLabel, + outlineFactory?: (el: Element) => MDCNotchedOutline): void; /** * Initiliazes the Text Field's internal state based on the environment's @@ -48,14 +52,30 @@ export class MDCTextField extends MDCComponent { - static readonly cssClasses: cssClasses; + static readonly cssClasses: cssClasses; - static readonly strings: strings; + static readonly strings: strings; - static readonly numbers: numbers; + static readonly numbers: numbers; - static readonly defaultAdapter: MDCToolbarAdapter; + static readonly defaultAdapter: MDCToolbarAdapter; - updateAdjustElementStyles(): void; + updateAdjustElementStyles(): void; } diff --git a/types/material__toolbar/index.d.ts b/types/material__toolbar/index.d.ts index 1b048c64c9..75bcbcda5f 100644 --- a/types/material__toolbar/index.d.ts +++ b/types/material__toolbar/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for Material Components Web 0.26 +// Type definitions for Material Components Web 0.35 // Project: https://material.io/components/ -// Definitions by: Brent Douglas +// Definitions by: Brent Douglas , Collin Kostichuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 @@ -23,15 +23,12 @@ import { MDCComponent } from 'material__base'; import MDCToolbarFoundation from './foundation'; -import { MDCToolbarAdapter } from './adapter'; -import * as util from './util'; +import MDCToolbarAdapter from './adapter'; -export {MDCToolbarAdapter, MDCToolbarFoundation, util}; +export {MDCToolbarAdapter, MDCToolbarFoundation}; export class MDCToolbar extends MDCComponent { - static attachTo(root: HTMLElement): MDCToolbar; + static attachTo(root: Element): MDCToolbar; - fixedAdjustElement: HTMLElement; - - getDefaultFoundation(): MDCToolbarFoundation; + fixedAdjustElement: HTMLElement; } diff --git a/types/material__toolbar/tsconfig.json b/types/material__toolbar/tsconfig.json index 826161ca25..2af99c6e5e 100644 --- a/types/material__toolbar/tsconfig.json +++ b/types/material__toolbar/tsconfig.json @@ -2,7 +2,6 @@ "files": [ "constants.d.ts", "adapter.d.ts", - "util.d.ts", "index.d.ts", "foundation.d.ts" ], diff --git a/types/material__top-app-bar/adapter.d.ts b/types/material__top-app-bar/adapter.d.ts new file mode 100644 index 0000000000..72d0f3430f --- /dev/null +++ b/types/material__top-app-bar/adapter.d.ts @@ -0,0 +1,77 @@ +/** + * @license + * Copyright 2018 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. + */ +/** + * Adapter for MDC Top App Bar + * + * Defines the shape of the adapter expected by the foundation. Implement this + * adapter to integrate the Top App Bar into your framework. See + * https://github.com/material-components/material-components-web/blob/master/docs/authoring-components.md + * for more information. + */ +export default interface MDCTopAppBarAdapter { + /** + * 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; + + /** + * Sets the specified inline style property on the root Element to the given value. + */ + setStyle(property: string, value: string): void; + + /** + * Gets the height of the top app bar. + */ + getTopAppBarHeight(): number; + + /** + * Registers an event handler on the navigation icon element for a given event. + */ + registerNavigationIconInteractionHandler(type: string, handler: EventListener): void; + + /** + * Deregisters an event handler on the navigation icon element for a given event. + */ + deregisterNavigationIconInteractionHandler(type: string, handler: EventListener): void; + + /** + * Emits an event when the navigation icon is clicked. + */ + notifyNavigationIconClicked(): void; + + registerScrollHandler(handler: EventListener): void; + + deregisterScrollHandler(handler: EventListener): void; + + registerResizeHandler(handler: EventListener): void; + + deregisterResizeHandler(handler: EventListener): void; + + getViewportScrollY(): number; + + getTotalActionItems(): number; +} diff --git a/types/material__top-app-bar/constants.d.ts b/types/material__top-app-bar/constants.d.ts new file mode 100644 index 0000000000..9f16a92a3f --- /dev/null +++ b/types/material__top-app-bar/constants.d.ts @@ -0,0 +1,38 @@ +/** + * @license + * Copyright 2018 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, MDCNumbers } from 'material__base'; + +export interface cssClasses extends MDCStrings { + FIXED_CLASS: 'mdc-top-app-bar--fixed'; + FIXED_SCROLLED_CLASS: 'mdc-top-app-bar--fixed-scrolled'; + SHORT_CLASS: 'mdc-top-app-bar--short'; + SHORT_HAS_ACTION_ITEM_CLASS: 'mdc-top-app-bar--short-has-action-item'; + SHORT_COLLAPSED_CLASS: 'mdc-top-app-bar--short-collapsed'; +} + +export interface numbers extends MDCNumbers { + DEBOUNCE_THROTTLE_RESIZE_TIME_MS: 100; + MAX_TOP_APP_BAR_HEIGHT: 128; +} + +export interface strings extends MDCStrings { + ACTION_ITEM_SELECTOR: '.mdc-top-app-bar__action-item'; + NAVIGATION_EVENT: 'MDCTopAppBar:nav'; + NAVIGATION_ICON_SELECTOR: '.mdc-top-app-bar__navigation-icon'; + ROOT_SELECTOR: '.mdc-top-app-bar'; + TITLE_SELECTOR: '.mdc-top-app-bar__title'; +} diff --git a/types/material__top-app-bar/fixed/foundation.d.ts b/types/material__top-app-bar/fixed/foundation.d.ts new file mode 100644 index 0000000000..21b5e22092 --- /dev/null +++ b/types/material__top-app-bar/fixed/foundation.d.ts @@ -0,0 +1,22 @@ +/** + * @license + * Copyright 2018 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 MDCTopAppBarFoundation from '../foundation'; +import MDCTopAppBarAdapter from '../adapter'; + +export default class MDCFixedTopAppBarFoundation extends MDCTopAppBarFoundation { +} diff --git a/types/material__menu/simple/foundation.d.ts b/types/material__top-app-bar/foundation.d.ts similarity index 63% rename from types/material__menu/simple/foundation.d.ts rename to types/material__top-app-bar/foundation.d.ts index 78071374b3..d0f6d68484 100644 --- a/types/material__menu/simple/foundation.d.ts +++ b/types/material__top-app-bar/foundation.d.ts @@ -1,6 +1,6 @@ /** * @license - * Copyright 2016 Google Inc. All Rights Reserved. + * Copyright 2018 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. @@ -16,28 +16,15 @@ */ import MDCFoundation from 'material__base/foundation'; -import MDCSimpleMenuAdapter from './adapter'; import { cssClasses, strings, numbers } from './constants'; -import { clamp, bezierProgress } from '../util'; - -export default class MDCSimpleMenuFoundation extends MDCFoundation { - static readonly cssClasses: cssClasses; +import MDCTopAppBarAdapter from './adapter'; +export default class MDCTopAppBarBaseFoundation extends MDCFoundation { static readonly strings: strings; + static readonly cssClasses: cssClasses; + static readonly numbers: numbers; - static readonly defaultAdapter: MDCSimpleMenuAdapter; - - /** - * Open the menu. - */ - open(options?: {focusIndex?: number}): void; - - /** - * Closes the menu. - */ - close(evt?: Event): void; - - isOpen(): boolean; + static readonly defaultAdapter: MDCTopAppBarAdapter; } diff --git a/types/material__top-app-bar/index.d.ts b/types/material__top-app-bar/index.d.ts new file mode 100644 index 0000000000..da37e36f23 --- /dev/null +++ b/types/material__top-app-bar/index.d.ts @@ -0,0 +1,38 @@ +// 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 + +/** + * @license + * Copyright 2018 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import MDCComponent from 'material__base/component'; +import MDCTopAppBarBaseFoundation from './foundation'; +import MDCTopAppBarAdapter from './adapter'; +import MDCFixedTopAppBarFoundation from './fixed/foundation'; +import MDCShortTopAppBarFoundation from './short/foundation'; +import MDCTopAppBarFoundation from './standard/foundation'; +import { MDCRipple } from 'material__ripple'; + +export { MDCTopAppBarBaseFoundation, MDCTopAppBarAdapter, MDCTopAppBarFoundation, MDCFixedTopAppBarFoundation, MDCShortTopAppBarFoundation }; + +export class MDCTopAppBar extends MDCComponent { + initialize(rippleFactory?: (el: Element) => MDCRipple): void; + + static attachTo(root: Element): MDCTopAppBar; +} diff --git a/types/material__top-app-bar/short/foundation.d.ts b/types/material__top-app-bar/short/foundation.d.ts new file mode 100644 index 0000000000..036b65216e --- /dev/null +++ b/types/material__top-app-bar/short/foundation.d.ts @@ -0,0 +1,22 @@ +/** + * @license + * Copyright 2018 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 MDCTopAppBarBaseFoundation from '../foundation'; +import MDCTopAppBarAdapter from '../adapter'; + +export default class MDCShortTopAppBarFoundation extends MDCTopAppBarBaseFoundation { +} diff --git a/types/material__top-app-bar/standard/foundation.d.ts b/types/material__top-app-bar/standard/foundation.d.ts new file mode 100644 index 0000000000..d9d39b4646 --- /dev/null +++ b/types/material__top-app-bar/standard/foundation.d.ts @@ -0,0 +1,22 @@ +/** + * @license + * Copyright 2018 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 MDCTopAppBarBaseFoundation from '../foundation'; +import MDCTopAppBarAdapter from '../adapter'; + +export default class MDCTopAppBarFoundation extends MDCTopAppBarBaseFoundation { +} diff --git a/types/material__top-app-bar/tsconfig.json b/types/material__top-app-bar/tsconfig.json new file mode 100644 index 0000000000..5652908420 --- /dev/null +++ b/types/material__top-app-bar/tsconfig.json @@ -0,0 +1,30 @@ +{ + "files": [ + "fixed/foundation.d.ts", + "short/foundation.d.ts", + "standard/foundation.d.ts", + "constants.d.ts", + "adapter.d.ts", + "index.d.ts", + "foundation.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 + } +} \ No newline at end of file diff --git a/types/material__top-app-bar/tslint.json b/types/material__top-app-bar/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/material__top-app-bar/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }