mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Add types/tests for @reach/combobox (#36379)
This commit is contained in:
parent
e99c4f4e51
commit
dcd243fdd8
44
types/reach__combobox/index.d.ts
vendored
Normal file
44
types/reach__combobox/index.d.ts
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
// Type definitions for @reach/combobox 0.1
|
||||
// Project: https://github.com/reach/reach-ui
|
||||
// Definitions by: Harry Hedger <https://github.com/hedgerh>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import * as React from 'react';
|
||||
|
||||
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
||||
|
||||
export interface ComboboxProps extends Omit<React.HTMLProps<HTMLElement>, 'onSelect'> {
|
||||
children?: React.ReactNode;
|
||||
onSelect?: (value: string) => void;
|
||||
openOnFocus?: boolean;
|
||||
as?: string;
|
||||
}
|
||||
|
||||
export interface ComboboxInputProps extends React.HTMLProps<HTMLElement> {
|
||||
selectOnClick?: boolean;
|
||||
autocomplete?: boolean;
|
||||
value?: string;
|
||||
as?: string;
|
||||
}
|
||||
|
||||
export interface ComboboxPopoverProps extends React.HTMLProps<HTMLElement> {
|
||||
portal?: boolean;
|
||||
}
|
||||
|
||||
export interface ComboboxListProps extends React.HTMLProps<HTMLElement> {
|
||||
persistSelection?: boolean;
|
||||
as?: string;
|
||||
}
|
||||
|
||||
export interface ComboboxOptionProps extends React.HTMLProps<HTMLElement> {
|
||||
children?: React.ReactNode;
|
||||
value: string;
|
||||
}
|
||||
|
||||
export const Combobox: React.FC<ComboboxProps>;
|
||||
export const ComboboxInput: React.FC<ComboboxInputProps>;
|
||||
export const ComboboxPopover: React.FC<ComboboxPopoverProps>;
|
||||
export const ComboboxList: React.FC<ComboboxListProps>;
|
||||
export const ComboboxOption: React.FC<ComboboxOptionProps>;
|
||||
export const ComboboxOptionText: React.FC;
|
||||
36
types/reach__combobox/reach__combobox-tests.tsx
Normal file
36
types/reach__combobox/reach__combobox-tests.tsx
Normal file
@ -0,0 +1,36 @@
|
||||
import {
|
||||
Combobox,
|
||||
ComboboxInput,
|
||||
ComboboxPopover,
|
||||
ComboboxList,
|
||||
ComboboxOption,
|
||||
ComboboxOptionText,
|
||||
} from '@reach/combobox';
|
||||
|
||||
import * as React from 'react';
|
||||
import { render } from 'react-dom';
|
||||
|
||||
const GoodExample = () => (
|
||||
<Combobox>
|
||||
<ComboboxInput aria-labelledby="demo" />
|
||||
<ComboboxPopover>
|
||||
<ComboboxList aria-labelledby="demo">
|
||||
<ComboboxOption value="Apple" />
|
||||
<ComboboxOption value="Banana" />
|
||||
<ComboboxOption value="Orange" />
|
||||
<ComboboxOption value="Pineapple" />
|
||||
<ComboboxOption value="Kiwi" />
|
||||
</ComboboxList>
|
||||
</ComboboxPopover>
|
||||
</Combobox>
|
||||
);
|
||||
|
||||
render(<GoodExample />, document.getElementById('app'));
|
||||
render(<Combobox />, document.getElementById('app'));
|
||||
render(<ComboboxInput />, document.getElementById('app'));
|
||||
render(<ComboboxPopover />, document.getElementById('app'));
|
||||
render(<ComboboxList />, document.getElementById('app'));
|
||||
render(<ComboboxOptionText />, document.getElementById('app'));
|
||||
|
||||
// $ExpectError
|
||||
render(<ComboboxOption />, document.getElementById('app'));
|
||||
28
types/reach__combobox/tsconfig.json
Normal file
28
types/reach__combobox/tsconfig.json
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"paths": {
|
||||
"@reach/combobox": ["reach__combobox"]
|
||||
},
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"jsx": "react"
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"reach__combobox-tests.tsx"
|
||||
]
|
||||
}
|
||||
1
types/reach__combobox/tslint.json
Normal file
1
types/reach__combobox/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user