Skip to content

Commit 7b5eb1b

Browse files
Niryoethanshar
andauthored
converting view to typescript (#714)
* converting view to typescript * fix bad import * Update src/components/view/index.tsx Co-Authored-By: Ethan Sharabi <ethans@wix.com> * code review fixes * add missing comments Co-authored-by: Ethan Sharabi <ethans@wix.com>
1 parent c4d553b commit 7b5eb1b

File tree

21 files changed

+450
-1326
lines changed

21 files changed

+450
-1326
lines changed
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
import React from 'react';
2-
declare function asBaseComponent(WrappedComponent: React.ClassType<any, any, any>): React.ForwardRefExoticComponent<React.RefAttributes<unknown>>;
2+
import * as Modifiers from './modifiers';
3+
export interface BaseComponentInjectedProps {
4+
modifiers: ReturnType<typeof Modifiers.generateModifiersStyle>;
5+
}
6+
declare function asBaseComponent<PROPS>(WrappedComponent: React.ComponentType<PROPS>): React.ComponentType<Omit<PROPS, keyof BaseComponentInjectedProps>>;
37
export default asBaseComponent;
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
import React from 'react';
2-
declare const _default: <PROPS extends {}>(WrappedComponent: any) => React.ForwardRefExoticComponent<React.PropsWithoutRef<PROPS> & React.RefAttributes<unknown>>;
3-
export default _default;
2+
export interface ForwardRefInjectedProps {
3+
forwardedRef: any;
4+
}
5+
export default function forwardRef<P>(WrappedComponent: React.ComponentType<P>): React.ComponentType<Omit<P, keyof ForwardRefInjectedProps>>;

generatedTypes/commons/modifiers.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ export declare function extractTypographyValue(props: Dictionary<any>): undefine
5656
export declare function extractPaddingValues(props: Dictionary<any>): Partial<Record<"padding" | "paddingLeft" | "paddingTop" | "paddingRight" | "paddingBottom" | "paddingHorizontal" | "paddingVertical", number>>;
5757
export declare function extractMarginValues(props: Dictionary<any>): Partial<Record<"margin" | "marginLeft" | "marginTop" | "marginRight" | "marginBottom" | "marginHorizontal" | "marginVertical", number>>;
5858
export declare function extractAlignmentsValues(props: Dictionary<any>): any;
59-
export declare function extractPositionStyle(props: Dictionary<any>): import("react-native").RegisteredStyle<{
59+
export declare function extractPositionStyle(props: Dictionary<any>): {
6060
position: "absolute";
61-
}> | undefined;
61+
} | undefined;
6262
export declare function extractFlexStyle(props: Dictionary<any>): Partial<Record<NativeFlexModifierKeyType, number>> | undefined;
6363
export declare function extractAccessibilityProps(props?: any): Partial<any>;
6464
export declare function extractBorderRadiusValue(props: Dictionary<any>): number | undefined;

generatedTypes/commons/modifiers2.d.ts

Lines changed: 0 additions & 78 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React from 'react';
2+
import { ViewProps } from 'react-native';
3+
import { BaseComponentInjectedProps } from '../../commons/asBaseComponent';
4+
import { ForwardRefInjectedProps } from '../../commons/forwardRef';
5+
import { ContainerModifiers } from '../../../typings/modifiers';
6+
/**
7+
* @description: Wrapper component for React Native View component
8+
* @extends: View
9+
* @extendslink: https://facebook.github.io/react-native/docs/view.html
10+
* @modifiers: margins, paddings, alignments, background, borderRadius
11+
*/
12+
interface ViewPropTypes extends ViewProps {
13+
/**
14+
* If true, will render as SafeAreaView
15+
*/
16+
useSafeArea?: boolean;
17+
animated?: boolean;
18+
inaccessible?: boolean;
19+
}
20+
declare type PropsTypes = BaseComponentInjectedProps & ViewPropTypes & ForwardRefInjectedProps & ContainerModifiers;
21+
declare const _default: React.ComponentType<Pick<Pick<PropsTypes, "br0" | "br10" | "br20" | "br30" | "br40" | "br50" | "br60" | "br100" | "padding" | "paddingL" | "paddingT" | "paddingR" | "paddingB" | "paddingH" | "paddingV" | "margin" | "marginL" | "marginT" | "marginR" | "marginB" | "marginH" | "marginV" | "flex" | "flexG" | "flexS" | "row" | "center" | "left" | "right" | "centerH" | "spread" | "top" | "bottom" | "centerV" | "style" | "testID" | "modifiers" | "useSafeArea" | "animated" | "inaccessible" | "hitSlop" | "onLayout" | "pointerEvents" | "removeClippedSubviews" | "nativeID" | "collapsable" | "needsOffscreenAlphaCompositing" | "renderToHardwareTextureAndroid" | "shouldRasterizeIOS" | "isTVSelectable" | "hasTVPreferredFocus" | "tvParallaxProperties" | "tvParallaxShiftDistanceX" | "tvParallaxShiftDistanceY" | "tvParallaxTiltAngle" | "tvParallaxMagnification" | "onStartShouldSetResponder" | "onMoveShouldSetResponder" | "onResponderEnd" | "onResponderGrant" | "onResponderReject" | "onResponderMove" | "onResponderRelease" | "onResponderStart" | "onResponderTerminationRequest" | "onResponderTerminate" | "onStartShouldSetResponderCapture" | "onMoveShouldSetResponderCapture" | "onTouchStart" | "onTouchMove" | "onTouchEnd" | "onTouchCancel" | "onTouchEndCapture" | "accessible" | "accessibilityActions" | "accessibilityLabel" | "accessibilityRole" | "accessibilityStates" | "accessibilityState" | "accessibilityHint" | "onAccessibilityAction" | "accessibilityComponentType" | "accessibilityLiveRegion" | "importantForAccessibility" | "accessibilityElementsHidden" | "accessibilityTraits" | "accessibilityViewIsModal" | "onAccessibilityEscape" | "onAccessibilityTap" | "onMagicTap" | "accessibilityIgnoresInvertColors">, "br0" | "br10" | "br20" | "br30" | "br40" | "br50" | "br60" | "br100" | "padding" | "paddingL" | "paddingT" | "paddingR" | "paddingB" | "paddingH" | "paddingV" | "margin" | "marginL" | "marginT" | "marginR" | "marginB" | "marginH" | "marginV" | "flex" | "flexG" | "flexS" | "row" | "center" | "left" | "right" | "centerH" | "spread" | "top" | "bottom" | "centerV" | "style" | "testID" | "useSafeArea" | "animated" | "inaccessible" | "hitSlop" | "onLayout" | "pointerEvents" | "removeClippedSubviews" | "nativeID" | "collapsable" | "needsOffscreenAlphaCompositing" | "renderToHardwareTextureAndroid" | "shouldRasterizeIOS" | "isTVSelectable" | "hasTVPreferredFocus" | "tvParallaxProperties" | "tvParallaxShiftDistanceX" | "tvParallaxShiftDistanceY" | "tvParallaxTiltAngle" | "tvParallaxMagnification" | "onStartShouldSetResponder" | "onMoveShouldSetResponder" | "onResponderEnd" | "onResponderGrant" | "onResponderReject" | "onResponderMove" | "onResponderRelease" | "onResponderStart" | "onResponderTerminationRequest" | "onResponderTerminate" | "onStartShouldSetResponderCapture" | "onMoveShouldSetResponderCapture" | "onTouchStart" | "onTouchMove" | "onTouchEnd" | "onTouchCancel" | "onTouchEndCapture" | "accessible" | "accessibilityActions" | "accessibilityLabel" | "accessibilityRole" | "accessibilityStates" | "accessibilityState" | "accessibilityHint" | "onAccessibilityAction" | "accessibilityComponentType" | "accessibilityLiveRegion" | "importantForAccessibility" | "accessibilityElementsHidden" | "accessibilityTraits" | "accessibilityViewIsModal" | "onAccessibilityEscape" | "onAccessibilityTap" | "onMagicTap" | "accessibilityIgnoresInvertColors">>;
22+
export default _default;

generatedTypes/helpers/Constants.d.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
export declare function updateConstants(dimensions: any): void;
12
declare const constants: {
23
orientations: {
34
PORTRAIT: string;
45
LANDSCAPE: string;
56
};
67
isAndroid: boolean;
78
isIOS: boolean;
8-
readonly getAndroidVersion: number | undefined;
9+
getAndroidVersion: () => number | undefined;
910
readonly statusBarHeight: number;
1011
isRTL: boolean;
1112
readonly orientation: string;
@@ -18,7 +19,7 @@ declare const constants: {
1819
readonly isShortScreen: boolean;
1920
readonly screenAspectRatio: number;
2021
readonly isTablet: any;
21-
readonly getSafeAreaInsets: {
22+
getSafeAreaInsets: () => {
2223
left: number;
2324
right: number;
2425
bottom: number;

0 commit comments

Comments
 (0)