From 44a579f3e0fc73b2ef7c4b28875d6c4027d071b4 Mon Sep 17 00:00:00 2001 From: Libin Lu Date: Wed, 5 Apr 2017 14:15:43 -0400 Subject: [PATCH 1/9] add measure function into ui manager --- types/react-native/index.d.ts | 51 +++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index e282f17191..f907e13481 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -7156,6 +7156,57 @@ export interface UIManagerStatic { quality ?: number, } ) => Promise + + /** + * Determines the location on screen, width, and height of the given view and + * returns the values via an async callback. If successful, the callback will + * be called with the following arguments: + * + * - x + * - y + * - width + * - height + * - pageX + * - pageY + * + * Note that these measurements are not available until after the rendering + * has been completed in native. If you need the measurements as soon as + * possible, consider using the [`onLayout` + * prop](docs/view.html#onlayout) instead. + */ + measure(node: number, callback: MeasureOnSuccessCallback): void; + + /** + * Determines the location of the given view in the window and returns the + * values via an async callback. If the React root view is embedded in + * another native view, this will give you the absolute coordinates. If + * successful, the callback will be called with the following + * arguments: + * + * - x + * - y + * - width + * - height + * + * Note that these measurements are not available until after the rendering + * has been completed in native. + */ + measureInWindow(node: number, callback: MeasureInWindowOnSuccessCallback): void; + + /** + * Like [`measure()`](#measure), but measures the view relative an ancestor, + * specified as `relativeToNativeNode`. This means that the returned x, y + * are relative to the origin x, y of the ancestor view. + * + * As always, to obtain a native node handle for a component, you can use + * `React.findNodeHandle(component)`. + */ + measureLayout( + node: number, + relativeToNativeNode: number, + onSuccess: MeasureLayoutOnSuccessCallback, + onFail: () => void /* currently unused */ + ): void; } export interface SwitchPropertiesIOS extends ViewProperties, React.Props { From 2804601a84d8693a891a96ec67ab057947d22c81 Mon Sep 17 00:00:00 2001 From: Fedor Nezhivoi Date: Wed, 5 Apr 2017 21:59:28 +0300 Subject: [PATCH 2/9] @types/react-native update layout props in accordance to 0.43 release and refactor them a bit --- types/react-native/index.d.ts | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index e282f17191..cb8b04f5e2 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-native 0.42 +// Type definitions for react-native 0.43 // Project: https://github.com/facebook/react-native // Definitions by: Eloy Durán // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -531,9 +531,7 @@ export interface LayoutAnimationStatic { spring: (config: LayoutAnimationConfig, onAnimationDidEnd?: () => void) => void } -export type FlexAlignType = "flex-start" | "flex-end" | "center" | "stretch" | "baseline"; -export type FlexJustifyType = "flex-start" | "flex-end" | "center" | "space-between" | "space-around"; -export type FlexDirection = "row" | "column" | "row-reverse" | "column-reverse"; +type FlexAlignType = "flex-start" | "flex-end" | "center" | "stretch" | "baseline"; /** * Flex Prop Types @@ -541,9 +539,9 @@ export type FlexDirection = "row" | "column" | "row-reverse" | "column-reverse"; * @see LayoutPropTypes.js */ export interface FlexStyle { - - alignItems?: FlexAlignType; - alignSelf?: "auto" | FlexAlignType; + alignContent?: "flex-start" | "flex-end" | "center" | "stretch" | "space-between" | "space-around" + alignItems?: FlexAlignType + alignSelf?: "auto" | FlexAlignType borderBottomWidth?: number borderLeftWidth?: number borderRightWidth?: number @@ -551,18 +549,14 @@ export interface FlexStyle { borderWidth?: number bottom?: number | string flex?: number + flexBasis?: number | string + flexDirection?: "row" | "column" | "row-reverse" | "column-reverse" flexGrow?: number flexShrink?: number - flexBasis?: number | string - flexDirection?: FlexDirection flexWrap?: "wrap" | "nowrap" height?: number | string - justifyContent?: FlexJustifyType + justifyContent?: "flex-start" | "flex-end" | "center" | "space-between" | "space-around" left?: number | string - minWidth?: number | string - maxWidth?: number | string - minHeight?: number | string - maxHeight?: number | string margin?: number | string marginBottom?: number | string marginHorizontal?: number | string @@ -570,6 +564,10 @@ export interface FlexStyle { marginRight?: number | string marginTop?: number | string marginVertical?: number | string + maxHeight?: number | string + maxWidth?: number | string + minHeight?: number | string + minWidth?: number | string overflow?: "visible" | "hidden" | "scroll" padding?: number | string paddingBottom?: number | string @@ -582,11 +580,12 @@ export interface FlexStyle { right?: number | string top?: number | string width?: number | string + zIndex?: number /** * @platform ios */ - zIndex?: number + direction?: 'inherit' | 'ltr' | 'rtl' } /** From 1bf9a4e75f728e3164a6a841ecd8cef986699f19 Mon Sep 17 00:00:00 2001 From: Libin Lu Date: Wed, 5 Apr 2017 16:54:07 -0400 Subject: [PATCH 3/9] Update index.d.ts --- types/react-native/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index f907e13481..677cd6bb26 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -7156,7 +7156,7 @@ export interface UIManagerStatic { quality ?: number, } ) => Promise - + /** * Determines the location on screen, width, and height of the given view and * returns the values via an async callback. If successful, the callback will @@ -7204,8 +7204,8 @@ export interface UIManagerStatic { measureLayout( node: number, relativeToNativeNode: number, - onSuccess: MeasureLayoutOnSuccessCallback, - onFail: () => void /* currently unused */ + onFail: () => void, /* currently unused */ + onSuccess: MeasureLayoutOnSuccessCallback ): void; } From 528386483d99c5477eca14b0fe16802257ba85e2 Mon Sep 17 00:00:00 2001 From: slozier Date: Thu, 6 Apr 2017 10:25:56 -0400 Subject: [PATCH 4/9] Add missing props to react-datepicker Used the following doc as reference: https://github.com/Hacker0x01/react-datepicker/blob/v0.40.0/docs/datepicker.md --- types/react-datepicker/index.d.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/types/react-datepicker/index.d.ts b/types/react-datepicker/index.d.ts index 0cbe0ba202..467981c2fc 100644 --- a/types/react-datepicker/index.d.ts +++ b/types/react-datepicker/index.d.ts @@ -16,21 +16,28 @@ declare module "react-datepicker" { dateFormat?: string; dateFormatCalendar?: string; disabled?: boolean; + dropdownMode?: string; endDate?: moment.Moment; excludeDates?: any[]; filterDate?(): any; fixedHeight?: boolean; + forceShowMonthNavigation?: boolean; + highlightDates?: any[]; id?: string; includeDates?: any[]; + inline?: boolean; isClearable?: boolean; locale?: string; maxDate?: moment.Moment; minDate?: moment.Moment; + monthsShown?: number; name?: string; onBlur?(event: React.FocusEvent): void; onChange(date: moment.Moment | null, event: React.SyntheticEvent | undefined): any; onChangeRaw?(event: React.FocusEvent): void; onFocus?(event: React.FocusEvent): void; + onMonthChange?(date: moment.Moment): void; + openToDate?: moment.Moment; peekNextMonth?: boolean; placeholderText?: string; popoverAttachment?: string; From f928bfb3298d7395be9971dfa481a0567b1e6887 Mon Sep 17 00:00:00 2001 From: Fedor Nezhivoi Date: Wed, 5 Apr 2017 21:59:59 +0300 Subject: [PATCH 5/9] @types/react-native add myself to the list of maintainers --- types/react-native/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index cb8b04f5e2..1a46a65f8d 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for react-native 0.43 // Project: https://github.com/facebook/react-native // Definitions by: Eloy Durán +// Fedor Nezhivoi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 From 30a1873b906d4b345dfbbab12ab441d4d72ac562 Mon Sep 17 00:00:00 2001 From: Fedor Nezhivoi Date: Thu, 6 Apr 2017 18:22:18 +0300 Subject: [PATCH 6/9] @types/react-native-sortable-list fix alongside update in react-native types --- .../react-native-sortable-list-tests.tsx | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/types/react-native-sortable-list/react-native-sortable-list-tests.tsx b/types/react-native-sortable-list/react-native-sortable-list-tests.tsx index 57a59b8d20..91be1dfed4 100644 --- a/types/react-native-sortable-list/react-native-sortable-list-tests.tsx +++ b/types/react-native-sortable-list/react-native-sortable-list-tests.tsx @@ -8,8 +8,9 @@ import { Image, View, Dimensions, - FlexJustifyType, - FlexAlignType + ViewStyle, + TextStyle, + ImageStyle, } from 'react-native'; import SortableList, {RowProps} from 'react-native-sortable-list'; @@ -61,20 +62,20 @@ const data = { const styles = StyleSheet.create({ container: { flex: 1, - justifyContent: "center" as FlexJustifyType, - alignItems: "center" as FlexAlignType, + justifyContent: 'center', + alignItems: 'center', backgroundColor: '#eee', paddingTop: 60, - }, + } as ViewStyle, list: { flex: 1, - }, + } as ViewStyle, contentContainer: { width: window.width, paddingHorizontal: 30, - }, + } as ViewStyle, row: { flexDirection: 'row', @@ -89,18 +90,18 @@ const styles = StyleSheet.create({ shadowOpacity: 1, shadowOffset: {height: 2, width: 2}, shadowRadius: 2, - }, + } as ViewStyle, image: { width: 60, height: 60, marginRight: 30, borderRadius: 30, - }, + } as ImageStyle, text: { fontSize: 24, - }, + } as TextStyle, }); From 2807934e210e051ac9d427369b738c1e7b5a2c2b Mon Sep 17 00:00:00 2001 From: Michael Gerakis Date: Thu, 6 Apr 2017 12:03:05 -0400 Subject: [PATCH 7/9] @types/graphlib Change setParent's second parameter to optional --- types/graphlib/graphlib-tests.ts | 1 + types/graphlib/index.d.ts | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/types/graphlib/graphlib-tests.ts b/types/graphlib/graphlib-tests.ts index 114deef66a..d808f1ec2e 100644 --- a/types/graphlib/graphlib-tests.ts +++ b/types/graphlib/graphlib-tests.ts @@ -23,6 +23,7 @@ function test_graph() { g.setDefaultEdgeLabel(() => 'e42'); g.setNodes(['a', 'b', 'c'], 42); g.setParent('d', 'a'); + g.setParent('d'); g.parent('d'); g.children('a'); g.filterNodes(v => true); diff --git a/types/graphlib/index.d.ts b/types/graphlib/index.d.ts index 773cb621d1..1085e55f99 100644 --- a/types/graphlib/index.d.ts +++ b/types/graphlib/index.d.ts @@ -65,7 +65,8 @@ declare module "graphlib" { setNodes(names: string[], label?: any): Graph; /** - * Sets node p as a parent for node v. Method throws an exception in case of + * Sets node p as a parent for node v if it is defined, or removes the + * parent for v if p is undefined. Method throws an exception in case of * invoking it in context of noncompound graph. * Average-case complexity: O(1). * @@ -73,7 +74,7 @@ declare module "graphlib" { * @argument p - node to be parent for v. * @returns the graph, allowing this to be chained with other functions. */ - setParent(v: string, p: string): Graph; + setParent(v: string, p?: string): Graph; /** * Gets parent node for node v. From 4c0fd95396bb7c3ee7e4d312055650e756a29261 Mon Sep 17 00:00:00 2001 From: Michael Gerakis Date: Thu, 6 Apr 2017 12:24:07 -0400 Subject: [PATCH 8/9] Update spacing. --- types/graphlib/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/graphlib/index.d.ts b/types/graphlib/index.d.ts index 1085e55f99..3f35b82112 100644 --- a/types/graphlib/index.d.ts +++ b/types/graphlib/index.d.ts @@ -65,8 +65,8 @@ declare module "graphlib" { setNodes(names: string[], label?: any): Graph; /** - * Sets node p as a parent for node v if it is defined, or removes the - * parent for v if p is undefined. Method throws an exception in case of + * Sets node p as a parent for node v if it is defined, or removes the + * parent for v if p is undefined. Method throws an exception in case of * invoking it in context of noncompound graph. * Average-case complexity: O(1). * @@ -74,7 +74,7 @@ declare module "graphlib" { * @argument p - node to be parent for v. * @returns the graph, allowing this to be chained with other functions. */ - setParent(v: string, p?: string): Graph; + setParent(v: string, p?: string): Graph; /** * Gets parent node for node v. From 49e2699de4b18d5916fcf0192e99ec09ac8b3e92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guntars=20A=C5=A1manis-Graham?= Date: Thu, 6 Apr 2017 12:32:20 -0400 Subject: [PATCH 9/9] Add missing rgb() method --- types/color/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/color/index.d.ts b/types/color/index.d.ts index 83302cc38d..0b7b505c01 100644 --- a/types/color/index.d.ts +++ b/types/color/index.d.ts @@ -66,6 +66,7 @@ declare namespace Color { keyword(): string | undefined; hex(color: string): Color; hex(): string; + rgb(): Color; rgbNumber(): number; luminosity(): number; contrast(color: Color): number;