mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-13 12:37:16 +08:00
Add types for @material group at tag v0.26.0 (#23179)
This commit is contained in:
committed by
Sheetal Nandi
parent
1f0e148136
commit
fc02b40ffc
26
types/material__menu/index.d.ts
vendored
Normal file
26
types/material__menu/index.d.ts
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
// Type definitions for Material Components Web 0.26
|
||||
// Project: https://material.io/components/
|
||||
// Definitions by: Brent Douglas <https://github.com/BrentDouglas>
|
||||
// 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 * as util from './util';
|
||||
import { MDCSimpleMenu, MDCSimpleMenuAdapter, MDCSimpleMenuFoundation } from './simple/index';
|
||||
export { MDCSimpleMenu, MDCSimpleMenuAdapter, MDCSimpleMenuFoundation, util };
|
||||
104
types/material__menu/simple/adapter.d.ts
vendored
Normal file
104
types/material__menu/simple/adapter.d.ts
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Adapter for MDC Simple Menu. Provides an interface for managing
|
||||
* - classes
|
||||
* - dom
|
||||
* - focus
|
||||
* - position
|
||||
* - dimensions
|
||||
* - event handlers
|
||||
*
|
||||
* Additionally, provides type information for the adapter to the Closure
|
||||
* compiler.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
export default class MDCSimpleMenuAdapter {
|
||||
addClass(className: string): void;
|
||||
|
||||
removeClass(className: string): void;
|
||||
|
||||
hasClass(className: string): boolean;
|
||||
|
||||
hasNecessaryDom(): boolean;
|
||||
|
||||
getAttributeForEventTarget(target: EventTarget, attributeName: string): string;
|
||||
|
||||
getInnerDimensions(): {width: number, height: number};
|
||||
|
||||
hasAnchor(): boolean;
|
||||
|
||||
getAnchorDimensions(): {width: number, height: number, top: number, right: number, bottom: number, left: number};
|
||||
|
||||
getWindowDimensions(): {width: number, height: number};
|
||||
|
||||
setScale(x: number, y: number): void;
|
||||
|
||||
setInnerScale(x: number, y: number): void;
|
||||
|
||||
getNumberOfItems(): number;
|
||||
|
||||
registerInteractionHandler(type: string, handler: EventListener): void;
|
||||
|
||||
deregisterInteractionHandler(type: string, handler: EventListener): void;
|
||||
|
||||
registerBodyClickHandler(handler: EventListener): void;
|
||||
|
||||
deregisterBodyClickHandler(handler: EventListener): void;
|
||||
|
||||
getYParamsForItemAtIndex(index: number): {top: number, height: number};
|
||||
|
||||
setTransitionDelayForItemAtIndex(index: number, value: string|null): void;
|
||||
|
||||
getIndexForEventTarget(target: EventTarget): number;
|
||||
|
||||
notifySelected(evtData: {index: number}): void;
|
||||
|
||||
notifyCancel(): void;
|
||||
|
||||
saveFocus(): void;
|
||||
|
||||
restoreFocus(): void;
|
||||
|
||||
isFocused(): boolean;
|
||||
|
||||
focus(): void;
|
||||
|
||||
getFocusedItemIndex(): number;
|
||||
|
||||
focusItemAtIndex(index: number): void;
|
||||
|
||||
isRtl(): boolean;
|
||||
|
||||
setTransformOrigin(origin: string): void;
|
||||
|
||||
setPosition(position: {
|
||||
top: string|undefined,
|
||||
right: string|undefined,
|
||||
bottom: string|undefined,
|
||||
left: string|undefined
|
||||
}): void;
|
||||
|
||||
getAccurateTime(): number;
|
||||
}
|
||||
52
types/material__menu/simple/constants.d.ts
vendored
Normal file
52
types/material__menu/simple/constants.d.ts
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
43
types/material__menu/simple/foundation.d.ts
vendored
Normal file
43
types/material__menu/simple/foundation.d.ts
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* @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 MDCSimpleMenuAdapter from './adapter';
|
||||
import { cssClasses, strings, numbers } from './constants';
|
||||
import { clamp, bezierProgress } from '../util';
|
||||
|
||||
export default class MDCSimpleMenuFoundation extends MDCFoundation<MDCSimpleMenuAdapter> {
|
||||
static readonly cssClasses: cssClasses;
|
||||
|
||||
static readonly strings: strings;
|
||||
|
||||
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;
|
||||
}
|
||||
42
types/material__menu/simple/index.d.ts
vendored
Normal file
42
types/material__menu/simple/index.d.ts
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @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<MDCSimpleMenuAdapter, MDCSimpleMenuFoundation> {
|
||||
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;
|
||||
}
|
||||
29
types/material__menu/tsconfig.json
Normal file
29
types/material__menu/tsconfig.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"files": [
|
||||
"simple/constants.d.ts",
|
||||
"simple/adapter.d.ts",
|
||||
"simple/index.d.ts",
|
||||
"simple/foundation.d.ts",
|
||||
"util.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
|
||||
}
|
||||
}
|
||||
1
types/material__menu/tslint.json
Normal file
1
types/material__menu/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
37
types/material__menu/util.d.ts
vendored
Normal file
37
types/material__menu/util.d.ts
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns the name of the correct transform property to use on the current browser.
|
||||
*/
|
||||
export function getTransformPropertyName(globalObj: Window, forceRefresh?: boolean): string|undefined;
|
||||
|
||||
/**
|
||||
* Clamps a value between the minimum and the maximum, returning the clamped value.
|
||||
*/
|
||||
export function clamp(value: number, min?: number, max?: number): number;
|
||||
|
||||
/**
|
||||
* Returns the easing value to apply at time t, for a given cubic bezier curve.
|
||||
* Control points P0 and P3 are assumed to be (0,0) and (1,1), respectively.
|
||||
* Parameters are as follows:
|
||||
* - time: The current time in the animation, scaled between 0 and 1.
|
||||
* - x1: The x value of control point P1.
|
||||
* - y1: The y value of control point P1.
|
||||
* - x2: The x value of control point P2.
|
||||
* - y2: The y value of control point P2.
|
||||
*/
|
||||
export function bezierProgress(time: number, x1: number, y1: number, x2: number, y2: number): number;
|
||||
Reference in New Issue
Block a user