diff --git a/demo/src/screens/componentScreens/CardsScreen.tsx b/demo/src/screens/componentScreens/CardsScreen.tsx index 3a9c0b48a8..b72342f8b7 100644 --- a/demo/src/screens/componentScreens/CardsScreen.tsx +++ b/demo/src/screens/componentScreens/CardsScreen.tsx @@ -6,7 +6,7 @@ import { Colors, View, Card, - CardPropTypes, + CardProps, Button, Text, Image @@ -152,7 +152,7 @@ export default class CardsScreen extends Component< ); }; - renderCoupon = (cardProps: CardPropTypes) => { + renderCoupon = (cardProps: CardProps) => { return ( { + renderComplexImage = (cardProps: CardProps, image: React.ReactNode) => { return ( { + renderBackgroundCard = (cardProps: CardProps, body: React.ReactNode) => { return ( {body} diff --git a/src/components/actionBar/index.tsx b/src/components/actionBar/index.tsx index 04d52b127d..96bcee2598 100644 --- a/src/components/actionBar/index.tsx +++ b/src/components/actionBar/index.tsx @@ -1,10 +1,11 @@ +import _ from 'lodash'; import React, { Component } from 'react'; import {StyleSheet, ViewStyle} from 'react-native'; -import _ from 'lodash'; +import {Colors, Shadows} from '../../style'; import {asBaseComponent} from '../../commons/new'; import View from '../view'; -import Button, {ButtonPropTypes} from '../button'; -import {Colors, Shadows} from '../../style'; +import Button, {ButtonProps} from '../button'; + /** * @description: Quick actions bar, each action support Button component props @@ -25,7 +26,7 @@ export type ActionBarProps = { /** * actions for the action bar */ - actions: ButtonPropTypes[]; + actions: ButtonProps[]; /** * should action be equally centered */ @@ -58,7 +59,7 @@ class ActionBar extends Component { } styles = createStyles(this.props); - + getAlignment(actionIndex: number) { const {actions, centered} = this.props; const first = actionIndex === 0; diff --git a/src/components/avatar/index.tsx b/src/components/avatar/index.tsx index 1c6c3407e8..58a75e961a 100644 --- a/src/components/avatar/index.tsx +++ b/src/components/avatar/index.tsx @@ -34,7 +34,7 @@ export enum BadgePosition { const DEFAULT_BADGE_SIZE = 'pimpleBig'; -export type AvatarPropTypes = { +export type AvatarProps = { /** * Adds fade in animation when Avatar image loads */ @@ -128,6 +128,7 @@ export type AvatarPropTypes = { */ testID?: string; }; +export type AvatarPropTypes = AvatarProps; //TODO: remove after ComponentPropTypes deprecation; /** * @description: Avatar component for displaying user profile images @@ -137,11 +138,11 @@ export type AvatarPropTypes = { * @image: https://user-images.githubusercontent.com/33805983/34480603-197d7f64-efb6-11e7-9feb-db8ba756f055.png * @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/AvatarsScreen.js */ -class Avatar extends PureComponent { +class Avatar extends PureComponent { styles: ReturnType; - constructor(props: AvatarPropTypes) { + constructor(props: AvatarProps) { super(props); this.styles = createStyles(props); @@ -356,7 +357,7 @@ class Avatar extends PureComponent { } } -function createStyles(props: AvatarPropTypes) { +function createStyles(props: AvatarProps) { const {labelColor} = props; const styles = StyleSheet.create({ initialsContainerWithInset: { @@ -381,4 +382,4 @@ function createStyles(props: AvatarPropTypes) { export {Avatar}; // For tests -export default asBaseComponent(forwardRef(Avatar)) +export default asBaseComponent(forwardRef(Avatar)) diff --git a/src/components/button/index.tsx b/src/components/button/index.tsx index 763f3a3383..cac1ca8f09 100644 --- a/src/components/button/index.tsx +++ b/src/components/button/index.tsx @@ -16,7 +16,7 @@ import {Constants} from '../../helpers'; import {Colors, Typography, BorderRadiuses} from '../../style'; import {extractColorValue, extractTypographyValue} from '../../commons/modifiers'; import TouchableOpacity, {TouchableOpacityProps} from '../touchableOpacity'; -import Text, {TextPropTypes} from '../text'; +import Text, {TextProps} from '../text'; import Image from '../image'; export enum ButtonSize { @@ -32,7 +32,7 @@ export enum AnimationDirection { right = 'right' } -export type ButtonPropTypes = TouchableOpacityProps & +export type ButtonProps = TouchableOpacityProps & TypographyModifiers & ColorsModifiers & BackgroundColorModifier & @@ -112,7 +112,7 @@ export type ButtonPropTypes = TouchableOpacityProps & /** * Props that will be passed to the button's Text label. */ - labelProps?: TextPropTypes; + labelProps?: TextProps; /** * should the button act as a coast to coast button (no border radius) */ @@ -148,6 +148,7 @@ export type ButtonPropTypes = TouchableOpacityProps & */ animateTo?: AnimationDirection; }; +export type ButtonPropTypes = ButtonProps; //TODO: remove after ComponentPropTypes deprecation; export type ButtonState = { size?: number; @@ -176,7 +177,7 @@ const MIN_WIDTH = { const DEFAULT_SIZE = ButtonSize.large; const DISABLED_COLOR = Colors.dark60; -type Props = ButtonPropTypes & BaseComponentInjectedProps & ForwardRefInjectedProps; +type Props = ButtonProps & BaseComponentInjectedProps & ForwardRefInjectedProps; /** * @description: Basic button component @@ -572,4 +573,4 @@ function createStyles() { export {Button}; // For tests -export default asBaseComponent(forwardRef(Button)); +export default asBaseComponent(forwardRef(Button)); diff --git a/src/components/card/CardSection.tsx b/src/components/card/CardSection.tsx index 5695a6a051..341d0a4f1f 100644 --- a/src/components/card/CardSection.tsx +++ b/src/components/card/CardSection.tsx @@ -3,15 +3,15 @@ import React, {PureComponent} from 'react'; import {StyleSheet, ViewStyle, ImageStyle, ImageSourcePropType, StyleProp} from 'react-native'; import {LogService} from '../../services'; import {asBaseComponent} from '../../commons/new'; -import View, {ViewPropTypes} from '../view'; -import Text, {TextPropTypes} from '../text'; +import View, {ViewProps} from '../view'; +import Text, {TextProps} from '../text'; import Image, {ImageProps} from '../image'; import asCardChild, {asCardChildProps} from './asCardChild'; -type ContentType = TextPropTypes & {text?: string}; +type ContentType = TextProps & {text?: string}; -export type CardSectionProps = ViewPropTypes & { +export type CardSectionProps = ViewProps & { /** * Text content for the CardSection. * Example: content={[{text: 'You’re Invited!', text70: true, dark10: true}]} diff --git a/src/components/card/index.tsx b/src/components/card/index.tsx index 3fdd68f992..4e9a766dea 100644 --- a/src/components/card/index.tsx +++ b/src/components/card/index.tsx @@ -11,7 +11,7 @@ import { BaseComponentInjectedProps, ForwardRefInjectedProps } from '../../commons/new'; -import View, {ViewPropTypes} from '../view'; +import View, {ViewProps} from '../view'; import TouchableOpacity, {TouchableOpacityProps} from '../touchableOpacity'; import Image from '../image'; import CardImage from './CardImage'; @@ -32,7 +32,7 @@ const DEFAULT_SELECTION_PROPS = { }; export {CardSectionProps}; -export type CardPropTypes = ViewPropTypes & +export type CardProps = ViewProps & TouchableOpacityProps & { /** * card custom width @@ -90,10 +90,11 @@ export type CardPropTypes = ViewPropTypes & hideIndicator?: boolean; }; }; +export type CardPropTypes = CardProps; //TODO: remove after ComponentPropTypes deprecation; type PropTypes = BaseComponentInjectedProps & ForwardRefInjectedProps & - CardPropTypes; + CardProps; type State = { animatedSelected: Animated.Value; @@ -322,7 +323,7 @@ function createStyles({ height, borderRadius, selectionOptions -}: CardPropTypes) { +}: CardProps) { const selectionOptionsWithDefaults = { ...DEFAULT_SELECTION_PROPS, ...selectionOptions @@ -375,7 +376,7 @@ Card.Image = CardImage; Card.Section = CardSection; export default asBaseComponent< - CardPropTypes, + CardProps, { Image: typeof CardImage; Section: typeof CardSection; diff --git a/src/components/checkbox/index.tsx b/src/components/checkbox/index.tsx index 80ae00d77e..2ebfd370f2 100644 --- a/src/components/checkbox/index.tsx +++ b/src/components/checkbox/index.tsx @@ -23,7 +23,7 @@ const DEFAULT_COLOR = Colors.blue30; const DEFAULT_ICON_COLOR = Colors.white; const DEFAULT_DISABLED_COLOR = Colors.grey50; -export interface CheckboxPropTypes extends TouchableOpacityProps { +export interface CheckboxProps extends TouchableOpacityProps { /** * The value of the Checkbox. If true the switch will be turned on. Default value is false. */ @@ -72,8 +72,8 @@ export interface CheckboxPropTypes extends TouchableOpacityProps { * Additional styling for checkbox and label container */ containerStyle?: StyleProp; - } +export type CheckboxPropTypes = CheckboxProps; //TODO: remove after ComponentPropTypes deprecation; interface CheckboxState { isChecked: Animated.Value; @@ -86,7 +86,7 @@ interface CheckboxState { * @gif: https://media.giphy.com/media/xULW8j5WzsuPytqklq/giphy.gif * @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/CheckboxScreen.tsx */ -class Checkbox extends Component { +class Checkbox extends Component { static displayName = 'Checkbox'; styles: { @@ -107,7 +107,7 @@ class Checkbox extends Component { ]; }; - constructor(props: CheckboxPropTypes) { + constructor(props: CheckboxProps) { super(props); this.state = { @@ -129,7 +129,7 @@ class Checkbox extends Component { }; } - componentDidUpdate(prevProps: CheckboxPropTypes) { + componentDidUpdate(prevProps: CheckboxProps) { const {value} = this.props; if (prevProps.value !== value) { this.animateCheckbox(value); @@ -148,7 +148,7 @@ class Checkbox extends Component { }; } - animateCheckbox(value: CheckboxPropTypes['value']) { + animateCheckbox(value: CheckboxProps['value']) { const {isChecked} = this.state; Animated.timing(isChecked, { @@ -223,7 +223,7 @@ class Checkbox extends Component { } } -function createStyles(props: CheckboxPropTypes) { +function createStyles(props: CheckboxProps) { const {color = DEFAULT_COLOR, iconColor = DEFAULT_ICON_COLOR, size = DEFAULT_SIZE, borderRadius} = props; return StyleSheet.create({ @@ -247,4 +247,4 @@ function createStyles(props: CheckboxPropTypes) { }); } -export default asBaseComponent(Checkbox); +export default asBaseComponent(Checkbox); diff --git a/src/components/chip/index.tsx b/src/components/chip/index.tsx index 21211d3c86..459bf8b22a 100644 --- a/src/components/chip/index.tsx +++ b/src/components/chip/index.tsx @@ -6,7 +6,7 @@ import Assets from '../../assets'; import {asBaseComponent} from '../../commons/new'; import {BorderRadiuses, Spacings} from '../../style'; // @ts-ignore -import Avatar, {AvatarPropTypes} from '../avatar'; +import Avatar, {AvatarProps} from '../avatar'; // @ts-ignore import Badge, {BadgeProps, BADGE_SIZES} from '../badge'; import Image from '../image'; @@ -14,7 +14,8 @@ import Text from '../text'; import TouchableOpacity from '../touchableOpacity'; import View from '../view'; -export type ChipPropTypes = ViewProps & TouchableOpacityProps & { + +export type ChipProps = ViewProps & TouchableOpacityProps & { //GENERAL /** * Chip's size. Number or a width and height object. @@ -69,7 +70,7 @@ export type ChipPropTypes = ViewProps & TouchableOpacityProps & { /** * Avatar props object */ - avatarProps?: AvatarPropTypes; + avatarProps?: AvatarProps; //ICON GENERAL /** @@ -115,6 +116,7 @@ export type ChipPropTypes = ViewProps & TouchableOpacityProps & { */ dismissContainerStyle?: StyleProp; } +export type ChipPropTypes = ChipProps; //TODO: remove after ComponentPropTypes deprecation; /** * @description: Chip component @@ -145,7 +147,7 @@ const Chip = ({ useSizeAsMinimum, testID, ...others -}: ChipPropTypes) => { +}: ChipProps) => { const renderIcon = useCallback((iconPosition) => { const isLeftIcon = iconPosition === 'left'; @@ -329,4 +331,4 @@ const styles = StyleSheet.create({ } }); -export default asBaseComponent(Chip); +export default asBaseComponent(Chip); diff --git a/src/components/floatingButton/index.tsx b/src/components/floatingButton/index.tsx index 08cf496295..a4e626570c 100644 --- a/src/components/floatingButton/index.tsx +++ b/src/components/floatingButton/index.tsx @@ -5,7 +5,7 @@ import {Constants} from '../../helpers'; import {asBaseComponent} from '../../commons/new'; import {Colors, Spacings} from '../../style'; import View from '../view'; -import Button, {ButtonPropTypes} from '../button'; +import Button, {ButtonProps} from '../button'; import Image from '../image'; export interface FloatingButtonProps { @@ -16,11 +16,11 @@ export interface FloatingButtonProps { /** * Button element (all Button's component's props) */ - button?: PropsWithChildren; + button?: PropsWithChildren; /** * Secondary button element (all Button's component's props) */ - secondaryButton?: PropsWithChildren; + secondaryButton?: PropsWithChildren; /** * The bottom margin of the button, or secondary button if passed */ @@ -56,7 +56,7 @@ class FloatingButton extends PureComponent { initialVisibility?: boolean; firstLoad: boolean; - + constructor(props: FloatingButtonProps) { super(props); diff --git a/src/components/modal/TopBar.tsx b/src/components/modal/TopBar.tsx index c102ef78d3..887be3bc5a 100644 --- a/src/components/modal/TopBar.tsx +++ b/src/components/modal/TopBar.tsx @@ -5,7 +5,7 @@ import {Constants} from '../../helpers'; import Assets from '../../assets'; import {Colors, Typography} from '../../style'; import View from '../../components/view'; -import Button, {ButtonPropTypes} from '../../components/button'; +import Button, {ButtonProps} from '../../components/button'; import Text from '../../components/text'; export interface ModalTopBarProps { @@ -20,7 +20,7 @@ export interface ModalTopBarProps { /** * done action props (Button props) */ - doneButtonProps?: Omit; + doneButtonProps?: Omit; /** * done action label */ @@ -36,7 +36,7 @@ export interface ModalTopBarProps { /** * cancel action props (Button props) */ - cancelButtonProps?: Omit; + cancelButtonProps?: Omit; /** * cancel action label */ @@ -60,7 +60,7 @@ type topBarButtonProp = { label?: string; icon?: ImageSourcePropType; accessibilityLabel?: string; - buttonProps?: Omit; + buttonProps?: Omit; } const TOP_BAR_HEIGHT = Constants.isIOS ? 44 : 56; diff --git a/src/components/panningViews/panDismissibleView.tsx b/src/components/panningViews/panDismissibleView.tsx index 550ac8e606..e5d0becf7b 100644 --- a/src/components/panningViews/panDismissibleView.tsx +++ b/src/components/panningViews/panDismissibleView.tsx @@ -5,7 +5,7 @@ import {Constants} from '../../helpers'; import asPanViewConsumer from './asPanViewConsumer'; import PanningProvider, {PanningDirections, PanningProviderDirection, PanAmountsProps, PanDirectionsProps} from './panningProvider'; -export interface DismissibleAnimationPropTypes { +export interface DismissibleAnimationProps { /** * The return animation speed (default is 20) */ @@ -19,8 +19,9 @@ export interface DismissibleAnimationPropTypes { */ duration?: number; } +export type DismissibleAnimationPropTypes = DismissibleAnimationProps; //TODO: remove after ComponentPropTypes deprecation; -export interface PanDismissibleViewPropTypes { +export interface PanDismissibleViewProps { /** * Additional styling */ @@ -40,7 +41,7 @@ export interface PanDismissibleViewPropTypes { * bounciness - the animation bounciness (default is 6) * duration - the dismiss animation duration (default is 280) */ - animationOptions?: DismissibleAnimationPropTypes; + animationOptions?: DismissibleAnimationProps; /** * Override the default threshold (height/2 and width/2) with different values. */ @@ -51,6 +52,7 @@ export interface PanDismissibleViewPropTypes { */ allowDiagonalDismiss?: boolean; } +export type PanDismissibleViewPropTypes = PanDismissibleViewProps; //TODO: remove after ComponentPropTypes deprecation; const DEFAULT_DIRECTIONS = [ PanningProvider.Directions.UP, @@ -68,7 +70,7 @@ const DEFAULT_ANIMATION_OPTIONS = { }; const MAXIMUM_DRAGS_AFTER_SWIPE = 2; -interface DismissPropTypes { +interface DismissProps { isPanning: boolean; dragDirections: PanDirectionsProps; dragDeltas: PanAmountsProps; @@ -76,8 +78,8 @@ interface DismissPropTypes { swipeVelocities: PanAmountsProps; } -interface Props extends PanDismissibleViewPropTypes { - context: DismissPropTypes; +interface Props extends PanDismissibleViewProps { + context: DismissProps; } interface State { @@ -277,7 +279,7 @@ class PanDismissibleView extends PureComponent { return {isRight, isDown}; } - + if (hasHorizontalSwipe) { isRight = swipeDirections.x === PanningProvider.Directions.RIGHT; } @@ -400,4 +402,4 @@ class PanDismissibleView extends PureComponent { } } -export default asPanViewConsumer(PanDismissibleView); +export default asPanViewConsumer(PanDismissibleView); diff --git a/src/components/panningViews/panListenerView.tsx b/src/components/panningViews/panListenerView.tsx index 7a85845a5e..973173fcad 100644 --- a/src/components/panningViews/panListenerView.tsx +++ b/src/components/panningViews/panListenerView.tsx @@ -13,9 +13,9 @@ import PanningProvider, { PanAmountsProps, PanningProviderDirection } from './panningProvider'; -import View, {ViewPropTypes} from '../view'; +import View, {ViewProps} from '../view'; -interface PanningPropTypes { +interface PanningProps { /** * This is were you will get notified when a drag occurs * onDrag = ({directions, deltas}) => {...} @@ -50,7 +50,7 @@ interface PanningPropTypes { onPanTerminated?: () => void; } -export interface PanListenerViewPropTypes extends PanningPropTypes, ViewPropTypes { +export interface PanListenerViewProps extends PanningProps, ViewProps { /** * The directions of the allowed pan (default allows all directions) * Types: UP, DOWN, LEFT and RIGHT (using PanningProvider.Directions.###) @@ -71,9 +71,11 @@ export interface PanListenerViewPropTypes extends PanningPropTypes, ViewPropType */ isClickable?: boolean; } +export type PanListenerViewPropTypes = PanListenerViewProps; //TODO: remove after ComponentPropTypes deprecation; -interface Props extends PanListenerViewPropTypes { - context?: PanningPropTypes; + +interface Props extends PanListenerViewProps { + context?: PanningProps; } interface PanningResultProps { @@ -105,7 +107,7 @@ class PanListenerView extends PureComponent { private panResponder: PanResponderInstance; - constructor(props: PanListenerViewPropTypes) { + constructor(props: PanListenerViewProps) { super(props); const {isClickable} = props; @@ -231,4 +233,4 @@ class PanListenerView extends PureComponent { } } -export default asPanViewConsumer(PanListenerView); +export default asPanViewConsumer(PanListenerView); diff --git a/src/components/panningViews/panResponderView.tsx b/src/components/panningViews/panResponderView.tsx index ff50af9ac5..984813f5d2 100644 --- a/src/components/panningViews/panResponderView.tsx +++ b/src/components/panningViews/panResponderView.tsx @@ -1,10 +1,10 @@ import _ from 'lodash'; import React, {PureComponent} from 'react'; -import View, {ViewPropTypes} from '../view'; +import View, {ViewProps} from '../view'; import asPanViewConsumer from './asPanViewConsumer'; import {PanLocationProps, PanAmountsProps} from './panningProvider'; -export interface PanResponderViewPropTypes extends ViewPropTypes { +export interface PanResponderViewProps extends ViewProps { /** * Will be called with the current location ({left, top}) when the pan has ended */ @@ -18,14 +18,16 @@ export interface PanResponderViewPropTypes extends ViewPropTypes { */ isAnimated?: boolean; } +export type PanResponderViewPropTypes = PanResponderViewProps; //TODO: remove after ComponentPropTypes deprecation; -interface PanResponderPropTypes { + +interface PanResponderProps { isPanning: boolean; dragDeltas: PanAmountsProps; } -interface Props extends PanResponderViewPropTypes { - context: PanResponderPropTypes; +interface Props extends PanResponderViewProps { + context: PanResponderProps; } /** @@ -104,4 +106,4 @@ class PanResponderView extends PureComponent { } } -export default asPanViewConsumer(PanResponderView); +export default asPanViewConsumer(PanResponderView); diff --git a/src/components/radioButton/RadioButton.tsx b/src/components/radioButton/RadioButton.tsx index fe36f760cb..2cf09b7aa0 100644 --- a/src/components/radioButton/RadioButton.tsx +++ b/src/components/radioButton/RadioButton.tsx @@ -18,12 +18,12 @@ import View from '../view'; import Text from '../text'; import Image from '../image'; import asRadioGroupChild from './asRadioGroupChild'; -import {RadioGroupContextPropTypes} from './RadioGroupContext'; +import {RadioGroupContextProps} from './RadioGroupContext'; const DEFAULT_SIZE = 24; const DEFAULT_COLOR = Colors.blue30; -export type RadioButtonPropTypes = RadioGroupContextPropTypes & ViewProps & { +export type RadioButtonProps = RadioGroupContextProps & ViewProps & { /** * The identifier value of the radio button. must be different than other RadioButtons in the same group */ @@ -77,13 +77,14 @@ export type RadioButtonPropTypes = RadioGroupContextPropTypes & ViewProps & { */ contentOnRight?: boolean; }; +export type RadioButtonPropTypes = RadioButtonProps; //TODO: remove after ComponentPropTypes deprecation; interface RadioButtonState { opacityAnimationValue: Animated.Value; scaleAnimationValue: Animated.Value; } -type Props = RadioButtonPropTypes & BaseComponentInjectedProps & ForwardRefInjectedProps; +type Props = RadioButtonProps & BaseComponentInjectedProps & ForwardRefInjectedProps; /** * A Radio Button component, should be wrapped inside a RadioGroup @@ -265,7 +266,7 @@ class RadioButton extends PureComponent { } } -function createStyles(props: RadioButtonPropTypes) { +function createStyles(props: RadioButtonProps) { const {size = DEFAULT_SIZE, borderRadius = DEFAULT_SIZE / 2, color = DEFAULT_COLOR, disabled} = props; return StyleSheet.create({ radioButtonOutline: { @@ -287,4 +288,4 @@ function createStyles(props: RadioButtonPropTypes) { }); } -export default asBaseComponent(forwardRef(asRadioGroupChild(RadioButton))); +export default asBaseComponent(forwardRef(asRadioGroupChild(RadioButton))); diff --git a/src/components/radioButton/RadioGroup.tsx b/src/components/radioButton/RadioGroup.tsx index f2d09dfb0d..5354eb734f 100644 --- a/src/components/radioButton/RadioGroup.tsx +++ b/src/components/radioButton/RadioGroup.tsx @@ -9,7 +9,7 @@ import { import View from '../view'; import RadioGroupContext from './RadioGroupContext'; -export type RadioGroupPropTypes = { +export type RadioGroupProps = { /** * The initial value of the selected radio button */ @@ -19,12 +19,13 @@ export type RadioGroupPropTypes = { */ onValueChange?: ((value: string) => void) | ((value: number) => void) | ((value: boolean) => void); }; +export type RadioGroupPropTypes = RadioGroupProps; //TODO: remove after ComponentPropTypes deprecation; interface RadioGroupState { - value?: RadioGroupPropTypes['initialValue']; + value?: RadioGroupProps['initialValue']; } -type Props = RadioGroupPropTypes & +type Props = RadioGroupProps & BaseComponentInjectedProps & ForwardRefInjectedProps; @@ -48,7 +49,7 @@ class RadioGroup extends PureComponent { ): RadioGroupState | null => { const {value} = prevState; const {initialValue} = nextProps; - + if (_.isUndefined(nextProps.initialValue) || value === initialValue) { return null; } @@ -67,7 +68,7 @@ class RadioGroup extends PureComponent { return {value, onValueChange: this.onValueChange}; } - onValueChange = (value: RadioGroupPropTypes['initialValue']) => { + onValueChange = (value: RadioGroupProps['initialValue']) => { this.setState({value}); _.invoke(this.props, 'onValueChange', value); }; @@ -85,4 +86,4 @@ class RadioGroup extends PureComponent { export {RadioGroup}; // For tests -export default asBaseComponent(forwardRef(RadioGroup)); +export default asBaseComponent(forwardRef(RadioGroup)); diff --git a/src/components/radioButton/RadioGroupContext.ts b/src/components/radioButton/RadioGroupContext.ts index f1a5a78bac..bb4e606724 100644 --- a/src/components/radioButton/RadioGroupContext.ts +++ b/src/components/radioButton/RadioGroupContext.ts @@ -1,6 +1,6 @@ import React from 'react'; -export interface RadioGroupContextPropTypes { +export interface RadioGroupContextProps { /** * The identifier value of the radio button. must be different than other RadioButtons in the same group */ @@ -10,8 +10,9 @@ export interface RadioGroupContextPropTypes { */ onValueChange?: (value: string | number | boolean) => void; } +export type RadioGroupContextPropTypes = RadioGroupContextProps; //TODO: remove after ComponentPropTypes deprecation; -type PropTypes = RadioGroupContextPropTypes; +type PropTypes = RadioGroupContextProps; export default React.createContext({ value: undefined, diff --git a/src/components/radioButton/asRadioGroupChild.tsx b/src/components/radioButton/asRadioGroupChild.tsx index a9d970a19a..cb934c4e2d 100644 --- a/src/components/radioButton/asRadioGroupChild.tsx +++ b/src/components/radioButton/asRadioGroupChild.tsx @@ -3,7 +3,7 @@ import React, {Component} from 'react'; import hoistStatics from 'hoist-non-react-statics'; import RadioGroupContext from './RadioGroupContext'; -interface RadioGroupChildPropTypes { +interface RadioGroupChildProps { /** * The identifier value of the radio button. must be different than other RadioButtons in the same group */ @@ -14,7 +14,7 @@ interface RadioGroupChildPropTypes { selected?: boolean; } -type PropTypes = RadioGroupChildPropTypes; +type PropTypes = RadioGroupChildProps; export default function asRadioGroupChild(WrappedComponent: React.ComponentType) { class RadioGroupChild extends Component { diff --git a/src/components/tabBar/index.tsx b/src/components/tabBar/index.tsx index b4758eb3cf..7e19fd6b02 100644 --- a/src/components/tabBar/index.tsx +++ b/src/components/tabBar/index.tsx @@ -1,23 +1,23 @@ import _ from 'lodash'; import React, {Component} from 'react'; import { - Platform, - StyleSheet, - Animated, - ScrollView, - NativeSyntheticEvent, - NativeScrollEvent, + Platform, + StyleSheet, + Animated, + ScrollView, + NativeSyntheticEvent, + NativeScrollEvent, ViewStyle } from 'react-native'; import {Constants} from '../../helpers'; import {Colors} from '../../style'; import {asBaseComponent, BaseComponentInjectedProps} from '../../commons/new'; -import View, {ViewPropTypes} from '../view'; +import View, {ViewProps} from '../view'; import Image from '../image'; import TabBarItem, {TabBarItemProps} from './TabBarItem'; -export type TabBarProps = BaseComponentInjectedProps & ViewPropTypes & { +export type TabBarProps = BaseComponentInjectedProps & ViewProps & { /** * Show Tab Bar bottom shadow */ @@ -42,8 +42,8 @@ export type TabBarProps = BaseComponentInjectedProps & ViewPropTypes & { * custom style for the selected indicator */ indicatorStyle?: ViewStyle, - /** - * The background color + /** + * The background color */ backgroundColor: string, /** @@ -141,7 +141,7 @@ class TabBar extends Component { if (this.itemsRefs && this.state.currentIndex) { const childRef = this.itemsRefs[this.state.currentIndex]; const childLayout = childRef.getLayout(); - + if (childLayout && this.hasOverflow()) { if (childLayout.x + childLayout.width - this.contentOffset.x > this.scrollContainerWidth) { this.scrollView.scrollTo({x: childLayout.x - this.scrollContainerWidth + childLayout.width, y: 0, animated}); diff --git a/src/components/text/index.tsx b/src/components/text/index.tsx index ae482d5948..f672e87b54 100644 --- a/src/components/text/index.tsx +++ b/src/components/text/index.tsx @@ -1,5 +1,5 @@ import React, {PureComponent} from 'react'; -import {Text as RNText, StyleSheet, TextProps, TextStyle, Animated} from 'react-native'; +import {Text as RNText, StyleSheet, TextProps as RNTextProps, TextStyle, Animated} from 'react-native'; import { asBaseComponent, forwardRef, @@ -13,7 +13,7 @@ import {Colors} from '../../style'; import _ from 'lodash'; -export type TextPropTypes = TextProps & TypographyModifiers & ColorsModifiers & MarginModifiers & { +export type TextProps = RNTextProps & TypographyModifiers & ColorsModifiers & MarginModifiers & { /** * color of the text */ @@ -40,8 +40,9 @@ export type TextPropTypes = TextProps & TypographyModifiers & ColorsModifiers & animated?: boolean; textAlign?: string; } +export type TextPropTypes = TextProps; //TODO: remove after ComponentPropTypes deprecation; -type PropsTypes = BaseComponentInjectedProps & ForwardRefInjectedProps & TextPropTypes; +type PropsTypes = BaseComponentInjectedProps & ForwardRefInjectedProps & TextProps; /** * @description: A wrapper for Text component with extra functionality like modifiers support @@ -155,4 +156,4 @@ const styles = StyleSheet.create({ export {Text}; // For tests -export default asBaseComponent(forwardRef(Text)); +export default asBaseComponent(forwardRef(Text)); diff --git a/src/components/view/index.tsx b/src/components/view/index.tsx index 671b74921d..a42820430a 100644 --- a/src/components/view/index.tsx +++ b/src/components/view/index.tsx @@ -1,9 +1,9 @@ import React, {PureComponent} from 'react'; -import {View as RNView, SafeAreaView, Animated, ViewProps, StyleProp, ViewStyle} from 'react-native'; +import {View as RNView, SafeAreaView, Animated, ViewProps as RNViewProps, StyleProp, ViewStyle} from 'react-native'; import {asBaseComponent, forwardRef, BaseComponentInjectedProps, ForwardRefInjectedProps, ContainerModifiers} from '../../commons/new'; import Constants from '../../helpers/Constants'; -export interface ViewPropTypes extends Omit, ContainerModifiers { +export interface ViewProps extends Omit, ContainerModifiers { /** * If true, will render as SafeAreaView */ @@ -34,7 +34,9 @@ export interface ViewPropTypes extends Omit, ContainerModifi backgroundColor?: string; style?: StyleProp>; } -type PropsTypes = BaseComponentInjectedProps & ForwardRefInjectedProps & ViewPropTypes; +export type ViewPropTypes = ViewProps; //TODO: remove after ComponentPropTypes deprecation; + +type PropsTypes = BaseComponentInjectedProps & ForwardRefInjectedProps & ViewProps; interface ViewState { ready: boolean; @@ -122,4 +124,4 @@ class View extends PureComponent { } } -export default asBaseComponent(forwardRef(View)); +export default asBaseComponent(forwardRef(View)); diff --git a/src/incubator/TextField/Label.tsx b/src/incubator/TextField/Label.tsx index f3d19ef832..ccc57c983b 100644 --- a/src/incubator/TextField/Label.tsx +++ b/src/incubator/TextField/Label.tsx @@ -1,7 +1,7 @@ import React, {useContext} from 'react'; import {StyleSheet, TextStyle} from 'react-native'; import {Colors} from '../../style'; -import Text, {TextPropTypes} from '../../components/text'; +import Text, {TextProps} from '../../components/text'; import {ColorType, ValidationMessagePosition} from './types'; import {getColorByState} from './Presenter'; import FieldContext from './FieldContext'; @@ -22,7 +22,7 @@ export interface LabelProps { /** * Pass extra props to the label Text element */ - labelProps?: TextPropTypes; + labelProps?: TextProps; validationMessagePosition?: ValidationMessagePosition; floatingPlaceholder?: boolean; } diff --git a/src/incubator/TouchableOpacity.tsx b/src/incubator/TouchableOpacity.tsx index b348702c24..b14ec6c2dd 100644 --- a/src/incubator/TouchableOpacity.tsx +++ b/src/incubator/TouchableOpacity.tsx @@ -26,7 +26,7 @@ const { stopClock } = Reanimated; -type TouchableOpacityPropTypes = { +type TouchableOpacityProps = { /** * Background color */ @@ -65,13 +65,12 @@ type TouchableOpacityPropTypes = { style?: ViewStyle; }; - /** * @description: a Better, enhanced TouchableOpacity component * @modifiers: flex, margin, padding, background * @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/incubatorScreens/TouchableOpacityScreen.js */ -class TouchableOpacity extends PureComponent { +class TouchableOpacity extends PureComponent { static displayName = 'Incubator.TouchableOpacity'; static defaultProps = { @@ -217,4 +216,4 @@ function runTiming(clock: any, gestureState: any, initialValue: number, endValue ]); } -export default asBaseComponent(forwardRef(TouchableOpacity)); +export default asBaseComponent(forwardRef(TouchableOpacity)); diff --git a/src/index.ts b/src/index.ts index 7999eceb69..9b351e4c84 100644 --- a/src/index.ts +++ b/src/index.ts @@ -19,23 +19,23 @@ export { export * as Incubator from './incubator'; export * as Hooks from './hooks'; export {default as ActionBar, ActionBarProps} from './components/actionBar'; -export {default as Avatar, AvatarPropTypes} from './components/avatar'; +export {default as Avatar, AvatarPropTypes, AvatarProps} from './components/avatar'; export {default as Badge, BadgeProps} from './components/badge'; -export {default as Card, CardPropTypes, CardSectionProps} from './components/card'; +export {default as Card, CardPropTypes, CardProps, CardSectionProps} from './components/card'; export {default as Constants} from './helpers/Constants'; -export {default as View, ViewPropTypes} from './components/view'; -export {default as Text, TextPropTypes} from './components/text'; +export {default as View, ViewPropTypes, ViewProps} from './components/view'; +export {default as Text, TextPropTypes, TextProps} from './components/text'; export {default as TouchableOpacity, TouchableOpacityProps} from './components/touchableOpacity'; -export {default as Button, ButtonPropTypes} from './components/button'; -export {default as Checkbox, CheckboxPropTypes} from './components/checkbox'; -export {default as Chip, ChipPropTypes} from './components/chip'; +export {default as Button, ButtonPropTypes, ButtonProps} from './components/button'; +export {default as Checkbox, CheckboxPropTypes, CheckboxProps} from './components/checkbox'; +export {default as Chip, ChipPropTypes, ChipProps} from './components/chip'; export {default as FloatingButton, FloatingButtonProps} from './components/floatingButton'; export {default as Image, ImageProps} from './components/image'; export {default as Overlay, OverlayTypes} from './components/overlay'; -export {default as RadioButton, RadioButtonPropTypes} from './components/radioButton/RadioButton'; -export {default as RadioGroup, RadioGroupPropTypes} from './components/radioButton/RadioGroup'; +export {default as RadioButton, RadioButtonPropTypes, RadioButtonProps} from './components/radioButton/RadioButton'; +export {default as RadioGroup, RadioGroupPropTypes, RadioGroupProps} from './components/radioButton/RadioGroup'; export {default as Switch, SwitchProps} from './components/switch'; -export {default as TabBar} from './components/TabBar'; +export {default as TabBar, TabBarProps} from './components/TabBar'; export {default as Fader, FaderProps, FaderPosition} from './components/fader'; export {default as ExpandableSection, ExpandableSectionProps} from './components/expandableSection'; export {default as Modal, ModalProps, ModalTopBarProps} from './components/modal'; @@ -50,9 +50,9 @@ export { PanDirectionsProps, PanningProviderDirection } from './components/panningViews/panningProvider'; -export {default as PanListenerView, PanListenerViewPropTypes} from './components/panningViews/panListenerView'; -export {default as PanResponderView, PanResponderViewPropTypes} from './components/panningViews/panResponderView'; -export {default as PanDismissibleView, PanDismissibleViewPropTypes, DismissibleAnimationPropTypes} from './components/panningViews/panDismissibleView'; +export {default as PanListenerView, PanListenerViewPropTypes, PanListenerViewProps} from './components/panningViews/panListenerView'; +export {default as PanResponderView, PanResponderViewPropTypes, PanResponderViewProps} from './components/panningViews/panResponderView'; +export {default as PanDismissibleView, PanDismissibleViewPropTypes, DismissibleAnimationPropTypes, PanDismissibleViewProps, DismissibleAnimationProps} from './components/panningViews/panDismissibleView'; export {default as Dialog, DialogProps} from './components/dialog'; export {default as PageControl, PageControlProps} from './components/pageControl'; export {default as Carousel, CarouselProps} from './components/carousel';