mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-24 05:06:02 +08:00
Added type definitions for react-collapse (#22704)
This commit is contained in:
committed by
Mohamed Hegazy
parent
538bee5326
commit
23ab5e0c1a
28
types/react-collapse/index.d.ts
vendored
Normal file
28
types/react-collapse/index.d.ts
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
// Type definitions for react-collapse 4.0
|
||||
// Project: https://github.com/nkbt/react-collapse
|
||||
// Definitions by: Adam Binford <https://github.com/Kimahriman>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
import * as React from 'react';
|
||||
|
||||
export interface CollapseProps extends React.HTMLProps<Collapse> {
|
||||
isOpened: boolean;
|
||||
children: React.ReactNode;
|
||||
|
||||
springConfig?: { [key: string]: number }; // react-motion doesn't export the config interface
|
||||
forceInitialAnimation?: boolean;
|
||||
hasNestedCollapse?: boolean;
|
||||
fixedHeight?: number;
|
||||
theme?: {
|
||||
collapse: string
|
||||
content: string
|
||||
};
|
||||
style?: React.CSSProperties;
|
||||
onRender?: ({ current, from, to }: { current: number; from: number; to: number; }) => void;
|
||||
onRest?: () => void;
|
||||
onMeasure?: ({ width, height }: { width: number; height: number; }) => void;
|
||||
}
|
||||
|
||||
export class Collapse extends React.PureComponent<CollapseProps> { }
|
||||
|
||||
export class UnmountClosed extends React.PureComponent<CollapseProps> { }
|
||||
74
types/react-collapse/react-collapse-tests.tsx
Normal file
74
types/react-collapse/react-collapse-tests.tsx
Normal file
@@ -0,0 +1,74 @@
|
||||
import * as React from 'react';
|
||||
import { Collapse, UnmountClosed } from 'react-collapse';
|
||||
|
||||
class TestRequired extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<Collapse
|
||||
isOpened>
|
||||
<div/>
|
||||
</Collapse>
|
||||
<UnmountClosed
|
||||
isOpened>
|
||||
<div/>
|
||||
</UnmountClosed>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class TestAll extends React.Component {
|
||||
render() {
|
||||
const springConfig = {
|
||||
stiffness: 1,
|
||||
damping: 1,
|
||||
precision: 1,
|
||||
};
|
||||
|
||||
const theme = {
|
||||
collapse: 'collapse-class',
|
||||
content: 'content-class'
|
||||
};
|
||||
|
||||
const style: React.CSSProperties = {
|
||||
fontWeight: 'bold',
|
||||
fontSize: 16
|
||||
};
|
||||
|
||||
const onRender = (object: { current: number; from: number; to: number; }) => {};
|
||||
const onRest = () => {};
|
||||
const onMeasure = (object: { width: number; height: number }) => {};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Collapse
|
||||
isOpened
|
||||
springConfig={ springConfig }
|
||||
forceInitialAnimation
|
||||
hasNestedCollapse
|
||||
fixedHeight={ 0 }
|
||||
theme={ theme }
|
||||
style={ style }
|
||||
onRender={ onRender }
|
||||
onRest={ onRest }
|
||||
onMeasure={ onMeasure}>
|
||||
<div/>
|
||||
</Collapse>
|
||||
<UnmountClosed
|
||||
isOpened
|
||||
springConfig={ springConfig }
|
||||
forceInitialAnimation
|
||||
hasNestedCollapse
|
||||
fixedHeight={ 0 }
|
||||
theme={ theme }
|
||||
style={ style }
|
||||
onRender={ onRender }
|
||||
onRest={ onRest }
|
||||
onMeasure={ onMeasure}>
|
||||
<div/>
|
||||
</UnmountClosed>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
24
types/react-collapse/tsconfig.json
Normal file
24
types/react-collapse/tsconfig.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"jsx": "react",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"react-collapse-tests.tsx"
|
||||
]
|
||||
}
|
||||
1
types/react-collapse/tslint.json
Normal file
1
types/react-collapse/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user