Skip to content

Commit 0294209

Browse files
committed
fix: merge types with the props of the component used internally
1 parent aee06f3 commit 0294209

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+106
-99
lines changed

example/src/CardExample.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,8 @@ class CardExample extends React.Component<Props> {
4545
<Card style={styles.card}>
4646
<Card.Cover source={require('../assets/forest.jpg')} />
4747
<Card.Actions>
48-
<Button primary onPress={() => {}}>
49-
Share
50-
</Button>
51-
<Button primary onPress={() => {}}>
52-
Explore
53-
</Button>
48+
<Button onPress={() => {}}>Share</Button>
49+
<Button onPress={() => {}}>Explore</Button>
5450
</Card.Actions>
5551
</Card>
5652
<Card style={styles.card}>

example/src/DialogExample.js

+5-9
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,15 @@ class DialogExample extends React.Component<Props, State> {
5656
const { visible1, visible2, visible3, visible4, visible5 } = this.state;
5757
return (
5858
<View style={[styles.container, { backgroundColor: background }]}>
59-
<Button primary onPress={this._openDialog1}>
60-
Show Dialog with long text
61-
</Button>
62-
<Button primary onPress={this._openDialog2}>
59+
<Button onPress={this._openDialog1}>Show Dialog with long text</Button>
60+
<Button onPress={this._openDialog2}>
6361
Show Dialog with radio buttons
6462
</Button>
65-
<Button primary onPress={this._openDialog3}>
63+
<Button onPress={this._openDialog3}>
6664
Show Dialog with loading indicator
6765
</Button>
68-
<Button primary onPress={this._openDialog4}>
69-
Show undismissable Dialog
70-
</Button>
71-
<Button primary onPress={this._openDialog5}>
66+
<Button onPress={this._openDialog4}>Show undismissable Dialog</Button>
67+
<Button onPress={this._openDialog5}>
7268
Show Dialog with custom colors
7369
</Button>
7470
<DialogWithLongText visible={visible1} close={this._closeDialog1} />

example/src/Dialogs/DialogWithLongText.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ const DialogWithLongText = ({
4040
</ScrollView>
4141
</Dialog.ScrollArea>
4242
<Dialog.Actions>
43-
<Button primary onPress={close}>
44-
OK
45-
</Button>
43+
<Button onPress={close}>OK</Button>
4644
</Dialog.Actions>
4745
</Dialog>
4846
</Portal>

example/src/Dialogs/DialogWithRadioBtns.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,8 @@ export default class extends React.Component<Props, State> {
9191
</ScrollView>
9292
</Dialog.ScrollArea>
9393
<Dialog.Actions>
94-
<Button primary onPress={close}>
95-
Cancel
96-
</Button>
97-
<Button primary onPress={close}>
98-
Ok
99-
</Button>
94+
<Button onPress={close}>Cancel</Button>
95+
<Button onPress={close}>Ok</Button>
10096
</Dialog.Actions>
10197
</Dialog>
10298
</Portal>

example/src/Dialogs/UndismissableDialog.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ const DialogWithLongText = ({
2020
<Button color={Colors.teal500} disabled>
2121
Disagree
2222
</Button>
23-
<Button primary onPress={close}>
24-
Agree
25-
</Button>
23+
<Button onPress={close}>Agree</Button>
2624
</Dialog.Actions>
2725
</Dialog>
2826
</Portal>

src/components/Appbar/Appbar.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { withTheme } from '../../core/theming';
1212
import { black, white } from '../../styles/colors';
1313
import type { Theme } from '../../types';
1414

15-
type Props = {
15+
type Props = React.ElementConfig<typeof View> & {
1616
/**
1717
* Whether the background color is a dark color. A dark appbar will render light text and vice-versa.
1818
*/

src/components/Appbar/AppbarAction.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { black } from '../../styles/colors';
66
import IconButton from '../IconButton';
77
import type { IconSource } from '../Icon';
88

9-
type Props = {
9+
type Props = React.ElementConfig<typeof IconButton> & {
1010
/**
1111
* Custom color for action icon.
1212
*/

src/components/Appbar/AppbarBackAction.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { View, Image, I18nManager, StyleSheet, Platform } from 'react-native';
55

66
import AppbarAction from './AppbarAction';
77

8-
type Props = {
8+
type Props = React.ElementConfig<typeof AppbarAction> & {
99
/**
1010
* Custom color for back icon.
1111
*/

src/components/Appbar/AppbarContent.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import Text from '../Typography/Text';
99
import { withTheme } from '../../core/theming';
1010
import { black } from '../../styles/colors';
1111

12-
import type { Theme } from '../../types';
12+
import type { Theme, $RemoveChildren } from '../../types';
1313

14-
type Props = {
14+
type Props = $RemoveChildren<typeof View> & {
1515
/**
1616
* CUstom color for the text.
1717
*/
@@ -54,6 +54,7 @@ class AppbarContent extends React.Component<Props> {
5454
titleStyle,
5555
theme,
5656
title,
57+
...rest
5758
} = this.props;
5859
const { fonts } = theme;
5960

@@ -63,7 +64,7 @@ class AppbarContent extends React.Component<Props> {
6364
.string();
6465

6566
return (
66-
<View style={[styles.container, style]}>
67+
<View style={[styles.container, style]} {...rest}>
6768
<Text
6869
style={[
6970
{

src/components/Appbar/AppbarHeader.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Appbar, { DEFAULT_APPBAR_HEIGHT } from './Appbar';
77
import { withTheme } from '../../core/theming';
88
import type { Theme } from '../../types';
99

10-
type Props = {
10+
type Props = React.ElementConfig<typeof Appbar> & {
1111
/**
1212
* Whether the background color is a dark color. A dark header will render light text and vice-versa.
1313
*/
@@ -109,6 +109,7 @@ class AppbarHeader extends React.Component<Props> {
109109

110110
return (
111111
<Wrapper style={[{ backgroundColor, elevation }]}>
112+
{/* $FlowFixMe: There seems to be conflict between Appbar's props and Header's props */}
112113
<Appbar
113114
style={[
114115
{ height, backgroundColor, marginTop: statusBarHeight },

src/components/Banner.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import Surface from './Surface';
66
import Text from './Typography/Text';
77
import Button from './Button';
88
import { withTheme } from '../core/theming';
9-
import type { Theme } from '../types';
9+
import type { Theme, $RemoveChildren } from '../types';
1010

11-
type Props = {
11+
type Props = $RemoveChildren<typeof Surface> & {
1212
/**
1313
* Whether banner is currently visible.
1414
*/

src/components/Button.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { withTheme } from '../core/theming';
1212
import type { Theme } from '../types';
1313
import type { IconSource } from './Icon';
1414

15-
type Props = {
15+
type Props = React.ElementConfig<typeof Surface> & {
1616
/**
1717
* Mode of the button. You can change the mode to adjust the styling to give it desired emphasis.
1818
* - `text` - flat button without background or outline (low emphasis)

src/components/Card/Card.js

+13-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import Surface from '../Surface';
1414
import { withTheme } from '../../core/theming';
1515
import type { Theme } from '../../types';
1616

17-
type Props = {
17+
type Props = React.ElementConfig<typeof Surface> & {
1818
/**
1919
* Resting elevation of the card which controls the drop shadow.
2020
*/
@@ -105,7 +105,14 @@ class Card extends React.Component<Props, State> {
105105
};
106106

107107
render() {
108-
const { children, onLongPress, onPress, style, theme } = this.props;
108+
const {
109+
children,
110+
onLongPress,
111+
onPress,
112+
style,
113+
theme,
114+
...rest
115+
} = this.props;
109116
const { elevation } = this.state;
110117
const { roundness } = theme;
111118
const total = React.Children.count(children);
@@ -117,7 +124,10 @@ class Card extends React.Component<Props, State> {
117124
: null
118125
);
119126
return (
120-
<Surface style={[{ borderRadius: roundness, elevation }, style]}>
127+
<Surface
128+
style={[{ borderRadius: roundness, elevation }, style]}
129+
{...rest}
130+
>
121131
<TouchableWithoutFeedback
122132
delayPressIn={0}
123133
disabled={!(onPress || onLongPress)}

src/components/Card/CardActions.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import * as React from 'react';
44
import { StyleSheet, View } from 'react-native';
55

6-
type Props = {
6+
type Props = React.ElementConfig<typeof View> & {
77
/**
8-
* Content of the `CardActions`.
8+
* Items inside the `CardActions`.
99
*/
1010
children: React.Node,
1111
style?: any,

src/components/Card/CardContent.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
import * as React from 'react';
44
import { StyleSheet, View } from 'react-native';
55

6-
type Props = {
6+
type Props = React.ElementConfig<typeof View> & {
7+
/**
8+
* Items inside the `Card.Content`.
9+
*/
10+
children: React.Node,
711
/**
812
* @internal
913
*/

src/components/Card/CardCover.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { withTheme } from '../../core/theming';
66
import { grey200 } from '../../styles/colors';
77
import type { Theme } from '../../types';
88

9-
type Props = {
9+
type Props = React.ElementConfig<typeof Image> & {
1010
/**
1111
* @internal
1212
*/

src/components/CheckboxAndroid.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import color from 'color';
66
import Icon from './Icon';
77
import TouchableRipple from './TouchableRipple';
88
import { withTheme } from '../core/theming';
9-
import type { Theme } from '../types';
9+
import type { Theme, $RemoveChildren } from '../types';
1010

11-
type Props = {
11+
type Props = $RemoveChildren<typeof TouchableRipple> & {
1212
/**
1313
* Status of checkbox.
1414
*/

src/components/CheckboxIOS.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import color from 'color';
66
import Icon from './Icon';
77
import TouchableRipple from './TouchableRipple';
88
import { withTheme } from '../core/theming';
9-
import type { Theme } from '../types';
9+
import type { Theme, $RemoveChildren } from '../types';
1010

11-
type Props = {
11+
type Props = $RemoveChildren<typeof TouchableRipple> & {
1212
/**
1313
* Status of checkbox.
1414
*/

src/components/Chip.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { black, white } from '../styles/colors';
1818
import type { Theme } from '../types';
1919
import type { IconSource } from './Icon';
2020

21-
type Props = {
21+
type Props = React.ElementConfig<typeof Surface> & {
2222
/**
2323
* Mode of the chip.
2424
* - `flat` - flat chip without outline.
@@ -132,6 +132,7 @@ class Chip extends React.Component<Props, State> {
132132
onClose,
133133
style,
134134
theme,
135+
...rest
135136
} = this.props;
136137
const { dark, colors } = theme;
137138

@@ -193,6 +194,7 @@ class Chip extends React.Component<Props, State> {
193194
},
194195
style,
195196
]}
197+
{...rest}
196198
>
197199
<TouchableRipple
198200
borderless
@@ -248,7 +250,7 @@ class Chip extends React.Component<Props, State> {
248250
},
249251
]}
250252
>
251-
{children}
253+
{(children: any)}
252254
</Text>
253255
{onClose ? (
254256
<TouchableWithoutFeedback

src/components/Dialog/DialogActions.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import * as React from 'react';
44
import { StyleSheet, View } from 'react-native';
55

6-
type Props = {
6+
type Props = React.ElementConfig<typeof View> & {
77
/**
88
* Content of the `DialogActions`.
99
*/

src/components/Dialog/DialogContent.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import * as React from 'react';
44
import { View, StyleSheet } from 'react-native';
55

6-
type Props = {
6+
type Props = React.ElementConfig<typeof View> & {
77
/**
88
* Content of the `DialogContent`.
99
*/
@@ -47,7 +47,7 @@ class DialogContent extends React.Component<Props> {
4747

4848
render() {
4949
return (
50-
<View style={[styles.container, this.props.style]}>
50+
<View {...this.props} style={[styles.container, this.props.style]}>
5151
{this.props.children}
5252
</View>
5353
);

src/components/Dialog/DialogScrollArea.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import * as React from 'react';
44
import { View, StyleSheet } from 'react-native';
55

6-
type Props = {
6+
type Props = React.ElementConfig<typeof View> & {
77
/**
88
* Content of the `DialogScrollArea`.
99
*/
@@ -51,7 +51,7 @@ class DialogScrollArea extends React.Component<Props> {
5151

5252
render() {
5353
return (
54-
<View style={[styles.container, this.props.style]}>
54+
<View {...this.props} style={[styles.container, this.props.style]}>
5555
{this.props.children}
5656
</View>
5757
);

src/components/Dialog/DialogTitle.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Title from '../Typography/Title';
66
import { withTheme } from '../../core/theming';
77
import type { Theme } from '../../types';
88

9-
type Props = {
9+
type Props = React.ElementConfig<typeof Title> & {
1010
/**
1111
* Title text for the `DialogTitle`.
1212
*/

src/components/Divider.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import * as React from 'react';
44
import color from 'color';
55
import { StyleSheet, View } from 'react-native';
66
import { withTheme } from '../core/theming';
7-
import type { Theme } from '../types';
87
import { black, white } from '../styles/colors';
8+
import type { Theme, $RemoveChildren } from '../types';
99

10-
type Props = {
10+
type Props = $RemoveChildren<typeof View> & {
1111
/**
1212
* Whether divider has a left inset.
1313
*/

src/components/Drawer/DrawerItem.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import Text from '../Typography/Text';
77
import Icon from '../Icon';
88
import TouchableRipple from '../TouchableRipple';
99
import { withTheme } from '../../core/theming';
10-
import type { Theme } from '../../types';
10+
import type { Theme, $RemoveChildren } from '../../types';
1111
import type { IconSource } from '../Icon';
1212

13-
type Props = {
13+
type Props = $RemoveChildren<typeof View> & {
1414
/**
1515
* The label text of the item.
1616
*/

src/components/Drawer/DrawerSection.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Divider from '../Divider';
88
import { withTheme } from '../../core/theming';
99
import type { Theme } from '../../types';
1010

11-
type Props = {
11+
type Props = React.ElementConfig<typeof View> & {
1212
/**
1313
* Title to show as the header for the section.
1414
*/

0 commit comments

Comments
 (0)