mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 20:40:20 +00:00
[react-scroll-into-view-if-needed] add types
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
// Type definitions for react-scroll-into-view-if-needed 2.1
|
||||
// Project: https://github.com/icd2k3/react-scroll-into-view-if-needed#readme
|
||||
// Definitions by: Angus Fretwell <https://github.com/angusfretwell>
|
||||
// Allan Pope <https://github.com/allanpope>
|
||||
// Jonathan Ly <https://github.com/jonathanly>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.9
|
||||
|
||||
import * as React from 'react';
|
||||
import * as ScrollIntoViewIfNeeded from 'scroll-into-view-if-needed';
|
||||
|
||||
export interface ReactScrollIntoViewIfNeededProps
|
||||
extends React.HTMLProps<HTMLElement> {
|
||||
options?: ScrollIntoViewIfNeeded.Options;
|
||||
active?: boolean;
|
||||
elementType?: keyof JSX.IntrinsicElements;
|
||||
}
|
||||
|
||||
export default class ReactScrollIntoViewIfNeeded extends React.Component<
|
||||
ReactScrollIntoViewIfNeededProps
|
||||
> {}
|
||||
@@ -0,0 +1,52 @@
|
||||
import * as React from 'react';
|
||||
import ReactScrollIntoViewIfNeeded from 'react-scroll-into-view-if-needed';
|
||||
|
||||
const validOptions = {
|
||||
block: 'start',
|
||||
scrollMode: 'if-needed',
|
||||
skipOverflowHiddenElements: true
|
||||
};
|
||||
|
||||
const invalidOptions = {
|
||||
invalidOption: 'foobar'
|
||||
};
|
||||
|
||||
() => (
|
||||
<ReactScrollIntoViewIfNeeded
|
||||
active={true}
|
||||
options={validOptions}
|
||||
elementType="h1"
|
||||
>
|
||||
Children
|
||||
</ReactScrollIntoViewIfNeeded>
|
||||
);
|
||||
|
||||
() => (
|
||||
<ReactScrollIntoViewIfNeeded
|
||||
active={true}
|
||||
options={invalidOptions}
|
||||
elementType="h1"
|
||||
>
|
||||
Children
|
||||
</ReactScrollIntoViewIfNeeded>
|
||||
);
|
||||
|
||||
() => (
|
||||
<ReactScrollIntoViewIfNeeded
|
||||
active={5} // $ExpectError
|
||||
options={validOptions}
|
||||
elementType="h1"
|
||||
>
|
||||
Children
|
||||
</ReactScrollIntoViewIfNeeded>
|
||||
);
|
||||
|
||||
() => (
|
||||
<ReactScrollIntoViewIfNeeded
|
||||
active={true}
|
||||
options={validOptions}
|
||||
elementType="h8" // $ExpectError
|
||||
>
|
||||
Children
|
||||
</ReactScrollIntoViewIfNeeded>
|
||||
);
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6", "dom"],
|
||||
"jsx": "react",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": ["index.d.ts", "react-scroll-into-view-if-needed-tests.tsx"]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user