[react-native-modal-dropdown]: rewrite with ES6 modules, update definitions, add missing properties (#43884)

* Rewrite with ES6 modules, update definitions

* Remove unused dom compile option

* Remove any from test

* Add space after header

* Make component option as generic
This commit is contained in:
Ruslan Yurchenko 2020-04-27 18:28:39 +03:00 committed by GitHub
parent 2e713d0327
commit c7fa01cd2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 41 deletions

View File

@ -1,45 +1,46 @@
// Type definitions for react-native-modal-dropdown 0.6
// Type definitions for react-native-modal-dropdown 0.7
// Project: https://github.com/sohobloo/react-native-modal-dropdown
// Definitions by: Carlos Li <https://github.com/echoulen>
// Ruslan Yurchenko <https://github.com/rusyurchenko>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import * as React from "react";
import * as React from 'react';
import { StyleProp, TextStyle, ViewProps, ViewStyle, Constructor, NativeMethodsMixin } from 'react-native';
import ModalDropdown = RNModalDropdown.ModalDropdown;
export = ModalDropdown;
declare namespace RNModalDropdown {
interface PositionStyle {
left?: number;
right?: number;
width?: number;
}
interface ModalDropdownProps {
disabled?: boolean;
defaultIndex?: number;
defaultValue?: string;
options?: any[];
animated?: boolean;
scrollEnabled?: boolean;
showsVerticalScrollIndicator?: boolean;
style?: any;
textStyle?: any;
dropdownStyle?: any;
dropdownTextStyle?: any;
dropdownTextHighlightStyle?: any;
adjustFrame?: (positionStyle: PositionStyle) => void;
renderRow?: (option: any, index: number, isSelected: boolean) => any;
renderSeparator?: () => any;
renderButtonText?: (text: any) => any;
onDropdownWillShow?: () => any;
onDropdownWillHide?: () => any;
onSelect?: (index: number, option: any) => void;
accessible?: boolean;
keyboardShouldPersistTaps?: "always" | "never" | "handled";
}
class ModalDropdown extends React.Component<ModalDropdownProps> {
static default: typeof ModalDropdown;
}
export interface PositionStyle {
top?: number;
left?: number;
right?: number;
width?: number;
height?: number;
}
export interface ModalDropdownProps<T = any> extends ViewProps {
disabled?: boolean;
defaultIndex?: number;
defaultValue?: string;
options?: T[];
animated?: boolean;
scrollEnabled?: boolean;
showsVerticalScrollIndicator?: boolean;
textStyle?: StyleProp<TextStyle>;
dropdownStyle?: StyleProp<ViewStyle>;
dropdownTextStyle?: StyleProp<TextStyle>;
dropdownTextHighlightStyle?: StyleProp<TextStyle>;
adjustFrame?: (positionStyle: PositionStyle) => PositionStyle;
renderRow?: (option: T, index: string, isSelected: boolean) => React.ReactNode;
renderSeparator?: (sectionID: string, index: string, adjacentRowHighlighted: boolean) => React.ReactNode;
renderButtonText?: (text: string) => string;
onDropdownWillShow?: () => void | boolean;
onDropdownWillHide?: () => void | boolean;
onSelect?: (index: string, option: T) => void | boolean;
accessible?: boolean;
keyboardShouldPersistTaps?: 'always' | 'never' | 'handled';
}
export default class ModalDropdown<T = any> extends React.Component<ModalDropdownProps<T>> {
show(): void;
hide(): void;
select(index: number): void;
}

View File

@ -1,7 +1,7 @@
import * as React from 'react';
import ModalDropdown from "react-native-modal-dropdown";
class Test extends React.Component<any> {
class Test extends React.Component {
render() {
return (
<ModalDropdown options={["option 1", "option 2"]}/>

View File

@ -2,8 +2,7 @@
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,