Add @types/rebass__forms (#41258)

* Add @rebass/forms typing

* Use rebass's typing

* remove styled-components typing

* Add @rebass/forms path mappings

* Specify TypeScript version

* Remove exports

* Add custom omit type for compatibility

* Add textarea component on test file

* Label component uses Flex inside

* Remove module declaration

* Fix test
This commit is contained in:
Jinho Jeong 2019-12-28 01:34:52 +09:00 committed by Andrew Branch
parent 4b3c5a76a6
commit ab1e00b92c
4 changed files with 136 additions and 0 deletions

70
types/rebass__forms/index.d.ts vendored Normal file
View File

@ -0,0 +1,70 @@
// Type definitions for @rebass/forms 4.0
// Project: https://github.com/rebassjs/rebass#readme
// Definitions by: zinozzino <https://github.com/zinozzino>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.1
import * as React from 'react';
import * as Rebass from 'rebass';
import * as StyledSystem from 'styled-system';
export {};
type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
interface BoxKnownProps
extends Rebass.BaseProps,
StyledSystem.SpaceProps,
StyledSystem.LayoutProps,
StyledSystem.FontSizeProps,
StyledSystem.ColorProps,
StyledSystem.FlexProps,
StyledSystem.OrderProps,
StyledSystem.AlignSelfProps,
Rebass.SxProps {
variant?: StyledSystem.ResponsiveValue<string>;
tx?: string;
}
interface LabelKnownProps
extends BoxKnownProps,
StyledSystem.FlexWrapProps,
StyledSystem.FlexDirectionProps,
StyledSystem.AlignItemsProps,
StyledSystem.JustifyContentProps {}
export interface LabelProps
extends LabelKnownProps,
Omit<React.LabelHTMLAttributes<HTMLLabelElement>, keyof LabelKnownProps> {}
export const Label: React.ComponentType<LabelProps>;
export interface InputProps
extends BoxKnownProps,
Omit<React.InputHTMLAttributes<HTMLInputElement>, keyof BoxKnownProps> {}
export const Input: React.ComponentType<InputProps>;
export interface SelectProps
extends BoxKnownProps,
Omit<React.SelectHTMLAttributes<HTMLSelectElement>, keyof BoxKnownProps> {}
export const Select: React.ComponentType<SelectProps>;
export interface TextareaProps
extends BoxKnownProps,
Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, keyof BoxKnownProps> {}
export const Textarea: React.ComponentType<TextareaProps>;
export interface RadioProps
extends BoxKnownProps,
Omit<React.InputHTMLAttributes<HTMLInputElement>, keyof BoxKnownProps> {}
export const Radio: React.ComponentType<RadioProps>;
export interface CheckboxProps
extends BoxKnownProps,
Omit<React.InputHTMLAttributes<HTMLInputElement>, keyof BoxKnownProps> {}
export const Checkbox: React.ComponentType<CheckboxProps>;

View File

@ -0,0 +1,34 @@
import * as React from 'react';
import { Label, Input, Select, Textarea, Radio, Checkbox } from '@rebass/forms';
export default () => (
<>
<Label htmlFor="name">Name</Label>
<Input id="name" name="name" defaultValue="Jane Doe" />
<Label htmlFor="location">Location</Label>
<Select id="location" name="location" defaultValue="NYC">
<option>NYC</option>
<option>DC</option>
<option>ATX</option>
<option>SF</option>
<option>LA</option>
</Select>
<Label width={[1 / 2, 1 / 4]} p={2}>
<Radio id="beep" name="beep" value="beep" defaultChecked />
Beep
</Label>
<Label width={[1 / 2, 1 / 4]} p={2}>
<Radio id="boop" name="beep" value="boop" />
Boop
</Label>
<Label width={[1 / 2, 1 / 4]} p={2}>
<Checkbox id="remember" name="remember" />
Remember Me
</Label>
<Label width={[1 / 2, 1 / 4]} p={2}>
<Textarea id="remember" name="remember" />
</Label>
</>
);

View File

@ -0,0 +1,29 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictFunctionTypes": true,
"baseUrl": "../",
"jsx": "react",
"typeRoots": [
"../"
],
"paths": {
"@styled-system/css": ["styled-system__css"],
"@rebass/forms": ["rebass__forms"]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"rebass__forms-tests.tsx"
]
}

View File

@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}