Skip to content

Commit cc16b9b

Browse files
WedinDaniel Wedin
andauthored
fix: Fix typings by importing missing NativeSyntheticEvent and TargetedEvent (#292)
Co-authored-by: Daniel Wedin <[email protected]>
1 parent f543d4b commit cc16b9b

File tree

3 files changed

+103
-97
lines changed

3 files changed

+103
-97
lines changed

typings/Picker.d.ts

Lines changed: 85 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,122 +1,128 @@
1-
import * as React from "react"
2-
import { TextStyle, StyleProp, ViewProps } from 'react-native'
1+
import * as React from 'react';
2+
import {
3+
TextStyle,
4+
StyleProp,
5+
ViewProps,
6+
NativeSyntheticEvent,
7+
TargetedEvent,
8+
} from 'react-native';
39

4-
export type ItemValue = number | string
10+
export type ItemValue = number | string;
511

612
export interface PickerItemProps<T = ItemValue> {
7-
label?: string;
8-
value?: T;
9-
color?: string;
10-
fontFamily?: string,
11-
testID?: string;
12-
/**
13-
* Style to apply to individual item labels.
14-
* Only following values take effect:
15-
* - 'color'
16-
* - 'backgroundColor'
17-
* - 'fontSize'
18-
* - 'fontFamily'
19-
*
20-
* @platform android
21-
*/
22-
style?: StyleProp<TextStyle>
23-
/**
24-
* If set to false, the specific item will be disabled, i.e. the user will not be able to make a
25-
* selection.
26-
* @default true
27-
* @platform android
28-
*/
29-
enabled?:boolean
13+
label?: string;
14+
value?: T;
15+
color?: string;
16+
fontFamily?: string;
17+
testID?: string;
18+
/**
19+
* Style to apply to individual item labels.
20+
* Only following values take effect:
21+
* - 'color'
22+
* - 'backgroundColor'
23+
* - 'fontSize'
24+
* - 'fontFamily'
25+
*
26+
* @platform android
27+
*/
28+
style?: StyleProp<TextStyle>;
29+
/**
30+
* If set to false, the specific item will be disabled, i.e. the user will not be able to make a
31+
* selection.
32+
* @default true
33+
* @platform android
34+
*/
35+
enabled?: boolean;
3036
}
3137

3238
export interface PickerProps<T = ItemValue> extends ViewProps {
33-
style?: StyleProp<TextStyle>;
34-
/**
39+
style?: StyleProp<TextStyle>;
40+
/**
3541
* Value matching value of one of the items. Can be a string or an integer.
3642
*/
37-
selectedValue?: T;
38-
/**
43+
selectedValue?: T;
44+
/**
3945
* Callback for when an item is selected. This is called with the following parameters:
4046
* - `itemValue`: the `value` prop of the item that was selected
4147
* - `itemIndex`: the index of the selected item in this picker
4248
*/
43-
onValueChange?: (itemValue: T, itemIndex: number) => void;
44-
/**
49+
onValueChange?: (itemValue: T, itemIndex: number) => void;
50+
/**
4551
* If set to false, the picker will be disabled, i.e. the user will not be able to make a
4652
* selection.
4753
* @platform android
4854
*/
49-
enabled?: boolean;
50-
/**
55+
enabled?: boolean;
56+
/**
5157
* On Android, specifies how to display the selection items when the user taps on the picker:
5258
*
5359
* - 'dialog': Show a modal dialog. This is the default.
5460
* - 'dropdown': Shows a dropdown anchored to the picker view
5561
*
5662
* @platform android
5763
*/
58-
mode?: 'dialog' | 'dropdown';
59-
/**
64+
mode?: 'dialog' | 'dropdown';
65+
/**
6066
* Style to apply to each of the item labels.
6167
* @platform ios
6268
*/
63-
itemStyle?: StyleProp<TextStyle>;
64-
/**
69+
itemStyle?: StyleProp<TextStyle>;
70+
/**
6571
* Prompt string for this picker, used on Android in dialog mode as the title of the dialog.
6672
* @platform android
6773
*/
68-
prompt?: string;
69-
/**
74+
prompt?: string;
75+
/**
7076
* Used to locate this view in end-to-end tests.
7177
*/
72-
testID?: string;
73-
/**
74-
* Color of arrow for spinner dropdown in hexadecimal format
75-
* @platform android
76-
*/
77-
dropdownIconColor?: string;
78-
/**
78+
testID?: string;
79+
/**
80+
* Color of arrow for spinner dropdown in hexadecimal format
81+
* @platform android
82+
*/
83+
dropdownIconColor?: string;
84+
/**
7985
* On Android, used to truncate the text with an ellipsis after computing the text layout, including line wrapping,
8086
* such that the total number of lines does not exceed this number. Default is '1'
8187
* @platform android
8288
*/
83-
numberOfLines?: number;
84-
/**
85-
* The string used for the accessibility label. Will be read once focused on the picker but not on change.
86-
*/
87-
accessibilityLabel?: string;
88-
/**
89-
* Called when picker is focused
90-
* @platform android
91-
*/
92-
onFocus?: (e: NativeSyntheticEvent<TargetedEvent>) => void
93-
/**
94-
* Called when picker is blurred
95-
* @platform android
96-
*/
97-
onBlur?: (e: NativeSyntheticEvent<TargetedEvent>) => void
89+
numberOfLines?: number;
90+
/**
91+
* The string used for the accessibility label. Will be read once focused on the picker but not on change.
92+
*/
93+
accessibilityLabel?: string;
94+
/**
95+
* Called when picker is focused
96+
* @platform android
97+
*/
98+
onFocus?: (e: NativeSyntheticEvent<TargetedEvent>) => void;
99+
/**
100+
* Called when picker is blurred
101+
* @platform android
102+
*/
103+
onBlur?: (e: NativeSyntheticEvent<TargetedEvent>) => void;
98104
}
99105

100106
declare class Picker<T> extends React.Component<PickerProps<T>, {}> {
101-
/**
102-
* On Android, display the options in a dialog (this is the default).
103-
*/
104-
static readonly MODE_DIALOG: 'dialog';
105-
/**
106-
* On Android, display the options in a dropdown.
107-
*/
108-
static readonly MODE_DROPDOWN: 'dropdown';
107+
/**
108+
* On Android, display the options in a dialog (this is the default).
109+
*/
110+
static readonly MODE_DIALOG: 'dialog';
111+
/**
112+
* On Android, display the options in a dropdown.
113+
*/
114+
static readonly MODE_DROPDOWN: 'dropdown';
109115

110-
static Item: React.ComponentType<PickerItemProps<ItemValue>>;
116+
static Item: React.ComponentType<PickerItemProps<ItemValue>>;
111117

112-
/**
113-
* @platform android
114-
*/
115-
focus: () => void
116-
/**
117-
* @platform android
118-
*/
119-
blur: () => void
118+
/**
119+
* @platform android
120+
*/
121+
focus: () => void;
122+
/**
123+
* @platform android
124+
*/
125+
blur: () => void;
120126
}
121127

122128
export { Picker };

typings/PickerIOS.d.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
import * as React from "react"
2-
import { TextStyle, StyleProp, ViewProps } from 'react-native'
3-
import { ItemValue } from "./Picker"
1+
import * as React from 'react';
2+
import {TextStyle, StyleProp, ViewProps} from 'react-native';
3+
import {ItemValue} from './Picker';
44

55
export interface PickerIOSItemProps {
6-
label?: string;
7-
value?: number | string;
8-
color?: string;
9-
testID?: string;
6+
label?: string;
7+
value?: number | string;
8+
color?: string;
9+
testID?: string;
1010
}
1111

1212
declare class PickerIOSItem extends React.Component<PickerIOSItemProps, {}> {}
1313

1414
export interface PickerIOSProps extends ViewProps {
15-
itemStyle?: StyleProp<TextStyle>;
16-
style?: StyleProp<TextStyle>;
17-
onChange?: React.SyntheticEvent<{itemValue: ItemValue, itemIndex: number}>;
18-
onValueChange?: (itemValue: ItemValue, itemIndex: number) => void;
19-
selectedValue?: ItemValue;
20-
testID?: string;
15+
itemStyle?: StyleProp<TextStyle>;
16+
style?: StyleProp<TextStyle>;
17+
onChange?: React.SyntheticEvent<{itemValue: ItemValue, itemIndex: number}>;
18+
onValueChange?: (itemValue: ItemValue, itemIndex: number) => void;
19+
selectedValue?: ItemValue;
20+
testID?: string;
2121
}
2222

2323
declare class PickerIOS extends React.Component<PickerIOSProps, {}> {
24-
static Item: typeof PickerIOSItem
24+
static Item: typeof PickerIOSItem;
2525
}
2626

27-
export { PickerIOS };
27+
export {PickerIOS};

typings/index.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Picker, PickerProps, PickerItemProps} from "./Picker"
2-
import {PickerIOS} from "./PickerIOS"
1+
import {Picker, PickerProps, PickerItemProps} from './Picker';
2+
import {PickerIOS} from './PickerIOS';
33

4-
export {Picker, PickerIOS, PickerProps, PickerItemProps};
4+
export {Picker, PickerIOS, PickerProps, PickerItemProps};

0 commit comments

Comments
 (0)