|
1 |
| -import { Component, ComponentType, ReactNode } from 'react' |
2 |
| -import { TextStyle, ViewStyle } from 'react-native' |
3 |
| - |
4 |
| -interface HeaderItemProps { |
5 |
| - IconElement?: ReactNode |
6 |
| - buttonStyle?: TextStyle | ViewStyle |
7 |
| - buttonWrapperStyle?: ViewStyle |
8 |
| - color?: string |
9 |
| - iconName?: string |
10 |
| - iconSize?: number |
11 |
| - onPress?: () => void |
12 |
| - show?: string |
13 |
| - title: string |
| 1 | +import { Component, ComponentType, ReactNode } from 'react'; |
| 2 | +import { TextStyle, ViewStyle, View } from 'react-native'; |
| 3 | + |
| 4 | +interface CommonHeaderButtonProps { |
| 5 | + /** |
| 6 | + * Function to call on press. |
| 7 | + * |
| 8 | + * If this is a falsy value, the button won't react to touches. |
| 9 | + */ |
| 10 | + onPress?: () => void; |
| 11 | + /** |
| 12 | + * Title for the button. |
| 13 | + */ |
| 14 | + title: string; |
| 15 | + /** |
| 16 | + * Optional React element to show as button. Use this for completely custom buttons. |
| 17 | + * |
| 18 | + * If neither `IconComponent` nor this is defined, will render text with the `title`. |
| 19 | + */ |
| 20 | + ButtonElement?: ReactNode; |
| 21 | + /** |
| 22 | + * Icon name, used together with the `IconComponent` property. |
| 23 | + */ |
| 24 | + iconName?: string; |
| 25 | + /** |
| 26 | + * Style to apply to the button (icon and text). |
| 27 | + */ |
| 28 | + buttonStyle?: TextStyle | ViewStyle; |
| 29 | + /** |
| 30 | + * Style to apply to the touchable element that wraps the button. |
| 31 | + */ |
| 32 | + buttonWrapperStyle?: ViewStyle; |
| 33 | + /** |
| 34 | + * ID to locate the view in e2e tests. |
| 35 | + * |
| 36 | + * `testID` of the overflow button is exported under `OVERFLOW_BUTTON_TEST_ID`. |
| 37 | + */ |
| 38 | + testID?: string; |
| 39 | + /** |
| 40 | + * Support additional properties, but loses type checking. |
| 41 | + */ |
| 42 | + [prop: string]: any; |
| 43 | +} |
| 44 | + |
| 45 | +// From HeaderButton.js |
| 46 | +interface HeaderButtonProps extends CommonHeaderButtonProps { |
| 47 | + /** |
| 48 | + * Component to use for the icons, for example from `react-native-vector-icons`. |
| 49 | + */ |
| 50 | + IconComponent?: ReactNode; |
| 51 | + /** |
| 52 | + * Icon size. |
| 53 | + */ |
| 54 | + iconSize?: number; |
| 55 | + /** |
| 56 | + * Color of icons and buttons. |
| 57 | + */ |
| 58 | + color?: string; |
| 59 | + /** |
| 60 | + * Property for different ripple effects. |
| 61 | + */ |
| 62 | + background?: any; |
| 63 | +} |
| 64 | + |
| 65 | +export class HeaderButton extends Component<HeaderButtonProps> { |
| 66 | +} |
| 67 | + |
| 68 | +// From HeaderButtons.js as ItemProps |
| 69 | +interface HeaderItemProps extends CommonHeaderButtonProps { |
| 70 | + /** |
| 71 | + * String specifying if the icon should be shown or hidden in overflow menu. |
| 72 | + * @default "always" |
| 73 | + */ |
| 74 | + show?: 'always' | 'never'; |
| 75 | +} |
| 76 | + |
| 77 | +export interface onOverflowMenuPressParams { |
| 78 | + hiddenButtons: Array<ReactNode>, |
| 79 | + overflowButtonRef?: View, |
14 | 80 | }
|
15 | 81 |
|
16 | 82 | interface HeaderButtonsProps {
|
17 |
| - IconComponent?: ComponentType<any> |
18 |
| - OverflowIcon?: ReactNode |
19 |
| - cancelButtonLabel?: string |
20 |
| - children: ReactNode |
21 |
| - color?: string |
22 |
| - iconSize?: number |
23 |
| - left?: boolean |
24 |
| - overflowButtonWrapperStyle?: ViewStyle |
| 83 | + /** |
| 84 | + * Whether the `HeaderButtons` are on the left from header title. |
| 85 | + * @default false |
| 86 | + */ |
| 87 | + left?: boolean; |
| 88 | + /** |
| 89 | + * Component that renders the buttons. |
| 90 | + * |
| 91 | + * Typically, you'll want to provide a component that wraps `HeaderButton` |
| 92 | + * provided by this package, as seen in the quick example. |
| 93 | + * However, you're free to use your own component (see `HeaderButton` for reference). |
| 94 | + */ |
| 95 | + HeaderButtonComponent?: ComponentType<any>; |
| 96 | + /** |
| 97 | + * React element for the overflow icon. |
| 98 | + * |
| 99 | + * You need to provide this only if you need an overflow icon. |
| 100 | + */ |
| 101 | + OverflowIcon?: ReactNode; |
| 102 | + /** |
| 103 | + * Optional styles for overflow button. |
| 104 | + * |
| 105 | + * There are some default styles set, as seen in `OverflowButton.js` |
| 106 | + */ |
| 107 | + overflowButtonWrapperStyle?: ViewStyle; |
| 108 | + /** |
| 109 | + * Function that is called when overflow menu is pressed. |
| 110 | + * |
| 111 | + * This will override the default handler. |
| 112 | + */ |
| 113 | + onOverflowMenuPress?: (options: onOverflowMenuPressParams) => any; |
25 | 114 | }
|
26 | 115 |
|
27 | 116 | declare class HeaderButtons extends Component<HeaderButtonsProps> {
|
28 |
| - static Item: ComponentType<HeaderItemProps> |
| 117 | + static Item: ComponentType<HeaderItemProps>; |
29 | 118 | }
|
30 | 119 |
|
31 |
| -export default HeaderButtons |
| 120 | +export default HeaderButtons; |
0 commit comments