mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
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:
parent
4b3c5a76a6
commit
ab1e00b92c
70
types/rebass__forms/index.d.ts
vendored
Normal file
70
types/rebass__forms/index.d.ts
vendored
Normal 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>;
|
||||
34
types/rebass__forms/rebass__forms-tests.tsx
Normal file
34
types/rebass__forms/rebass__forms-tests.tsx
Normal 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>
|
||||
</>
|
||||
);
|
||||
29
types/rebass__forms/tsconfig.json
Normal file
29
types/rebass__forms/tsconfig.json
Normal 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"
|
||||
]
|
||||
}
|
||||
3
types/rebass__forms/tslint.json
Normal file
3
types/rebass__forms/tslint.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user