From b3e927689075997435120eb8bcb4c343de318bfb Mon Sep 17 00:00:00 2001 From: Nick Koutrelakos Date: Mon, 8 Aug 2022 12:26:08 -0700 Subject: [PATCH 1/2] improvement: improve typings of flatlist and sectionlist --- index.d.ts | 62 +++++++++++++++++++++++++----------------------------- 1 file changed, 29 insertions(+), 33 deletions(-) diff --git a/index.d.ts b/index.d.ts index bf03b269..dc51fab8 100644 --- a/index.d.ts +++ b/index.d.ts @@ -3,12 +3,8 @@ // Definitions by: Kyle Roach // TypeScript Version: 2.3.2 -import * as React from 'react' -import { - ScrollViewProps, - FlatListProps, - SectionListProps -} from 'react-native' +import * as React from "react"; +import { ScrollViewProps, FlatListProps, SectionListProps } from "react-native"; interface KeyboardAwareProps { /** @@ -18,7 +14,7 @@ interface KeyboardAwareProps { * @type {function} * @memberof KeyboardAwareProps */ - innerRef?: (ref: JSX.Element) => void + innerRef?: (ref: JSX.Element) => void; /** * Adds an extra offset that represents the TabBarIOS height. * @@ -26,7 +22,7 @@ interface KeyboardAwareProps { * @type {boolean} * @memberof KeyboardAwareProps */ - viewIsInsideTabBar?: boolean + viewIsInsideTabBar?: boolean; /** * Coordinates that will be used to reset the scroll when the keyboard hides. @@ -38,9 +34,9 @@ interface KeyboardAwareProps { * @memberof KeyboardAwareProps */ resetScrollToCoords?: { - x: number - y: number - } + x: number; + y: number; + }; /** * Lets the user enable or disable automatic resetScrollToCoords @@ -48,7 +44,7 @@ interface KeyboardAwareProps { * @type {boolean} * @memberof KeyboardAwareProps */ - enableResetScrollToCoords?: boolean + enableResetScrollToCoords?: boolean; /** * When focus in TextInput will scroll the position @@ -59,7 +55,7 @@ interface KeyboardAwareProps { * @memberof KeyboardAwareProps */ - enableAutomaticScroll?: boolean + enableAutomaticScroll?: boolean; /** * Enables keyboard aware settings for Android * @@ -68,7 +64,7 @@ interface KeyboardAwareProps { * @type {boolean} * @memberof KeyboardAwareProps */ - enableOnAndroid?: boolean + enableOnAndroid?: boolean; /** * Adds an extra offset when focusing the TextInputs. @@ -77,7 +73,7 @@ interface KeyboardAwareProps { * @type {number} * @memberof KeyboardAwareProps */ - extraHeight?: number + extraHeight?: number; /** * Adds an extra offset to the keyboard. @@ -88,7 +84,7 @@ interface KeyboardAwareProps { * @type {number} * @memberof KeyboardAwareProps */ - extraScrollHeight?: number + extraScrollHeight?: number; /** * Sets the delay time before scrolling to new position @@ -98,49 +94,49 @@ interface KeyboardAwareProps { * @type {number} * @memberof KeyboardAwareProps */ - keyboardOpeningTime?: number + keyboardOpeningTime?: number; /** * Callback when the keyboard will show. * * @param frames Information about the keyboard frame and animation. */ - onKeyboardWillShow?: (frames: Object) => void + onKeyboardWillShow?: (frames: Object) => void; /** * Callback when the keyboard did show. * * @param frames Information about the keyboard frame and animation. */ - onKeyboardDidShow?: (frames: Object) => void + onKeyboardDidShow?: (frames: Object) => void; /** * Callback when the keyboard will hide. * * @param frames Information about the keyboard frame and animation. */ - onKeyboardWillHide?: (frames: Object) => void + onKeyboardWillHide?: (frames: Object) => void; /** * Callback when the keyboard did hide. * * @param frames Information about the keyboard frame and animation. */ - onKeyboardDidHide?: (frames: Object) => void + onKeyboardDidHide?: (frames: Object) => void; /** * Callback when the keyboard frame will change. * * @param frames Information about the keyboard frame and animation. */ - onKeyboardWillChangeFrame?: (frames: Object) => void + onKeyboardWillChangeFrame?: (frames: Object) => void; /** * Callback when the keyboard frame did change. * * @param frames Information about the keyboard frame and animation. */ - onKeyboardDidChangeFrame?: (frames: Object) => void + onKeyboardDidChangeFrame?: (frames: Object) => void; } interface KeyboardAwareScrollViewProps @@ -154,19 +150,19 @@ interface KeyboardAwareSectionListProps SectionListProps {} interface KeyboardAwareState { - keyboardSpace: number + keyboardSpace: number; } declare class ScrollableComponent extends React.Component { - getScrollResponder: () => void - scrollToPosition: (x: number, y: number, animated?: boolean) => void - scrollToEnd: (animated?: boolean) => void - scrollForExtraHeightOnAndroid: (extraHeight: number) => void + getScrollResponder: () => void; + scrollToPosition: (x: number, y: number, animated?: boolean) => void; + scrollToEnd: (animated?: boolean) => void; + scrollForExtraHeightOnAndroid: (extraHeight: number) => void; scrollToFocusedInput: ( reactNode: Object, extraHeight?: number, keyboardOpeningTime?: number - ) => void + ) => void; } export class KeyboardAwareMixin {} @@ -174,11 +170,11 @@ export class KeyboardAwareScrollView extends ScrollableComponent< KeyboardAwareScrollViewProps, KeyboardAwareState > {} -export class KeyboardAwareFlatList extends ScrollableComponent< - KeyboardAwareFlatListProps, +export class KeyboardAwareFlatList extends ScrollableComponent< + KeyboardAwareFlatListProps, KeyboardAwareState > {} -export class KeyboardAwareSectionList extends ScrollableComponent< - KeyboardAwareSectionListProps, +export class KeyboardAwareSectionList extends ScrollableComponent< + KeyboardAwareSectionListProps, KeyboardAwareState > {} From 9b3f0f8f6a1a50b0339f9e7cd147700b1cf9a7aa Mon Sep 17 00:00:00 2001 From: Nick Koutrelakos Date: Mon, 8 Aug 2022 12:28:32 -0700 Subject: [PATCH 2/2] chore: revert auto-formatting --- index.d.ts | 56 +++++++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/index.d.ts b/index.d.ts index dc51fab8..cfeaa252 100644 --- a/index.d.ts +++ b/index.d.ts @@ -3,8 +3,12 @@ // Definitions by: Kyle Roach // TypeScript Version: 2.3.2 -import * as React from "react"; -import { ScrollViewProps, FlatListProps, SectionListProps } from "react-native"; +import * as React from 'react' +import { + ScrollViewProps, + FlatListProps, + SectionListProps +} from 'react-native' interface KeyboardAwareProps { /** @@ -14,7 +18,7 @@ interface KeyboardAwareProps { * @type {function} * @memberof KeyboardAwareProps */ - innerRef?: (ref: JSX.Element) => void; + innerRef?: (ref: JSX.Element) => void /** * Adds an extra offset that represents the TabBarIOS height. * @@ -22,7 +26,7 @@ interface KeyboardAwareProps { * @type {boolean} * @memberof KeyboardAwareProps */ - viewIsInsideTabBar?: boolean; + viewIsInsideTabBar?: boolean /** * Coordinates that will be used to reset the scroll when the keyboard hides. @@ -34,9 +38,9 @@ interface KeyboardAwareProps { * @memberof KeyboardAwareProps */ resetScrollToCoords?: { - x: number; - y: number; - }; + x: number + y: number + } /** * Lets the user enable or disable automatic resetScrollToCoords @@ -44,7 +48,7 @@ interface KeyboardAwareProps { * @type {boolean} * @memberof KeyboardAwareProps */ - enableResetScrollToCoords?: boolean; + enableResetScrollToCoords?: boolean /** * When focus in TextInput will scroll the position @@ -55,7 +59,7 @@ interface KeyboardAwareProps { * @memberof KeyboardAwareProps */ - enableAutomaticScroll?: boolean; + enableAutomaticScroll?: boolean /** * Enables keyboard aware settings for Android * @@ -64,7 +68,7 @@ interface KeyboardAwareProps { * @type {boolean} * @memberof KeyboardAwareProps */ - enableOnAndroid?: boolean; + enableOnAndroid?: boolean /** * Adds an extra offset when focusing the TextInputs. @@ -73,7 +77,7 @@ interface KeyboardAwareProps { * @type {number} * @memberof KeyboardAwareProps */ - extraHeight?: number; + extraHeight?: number /** * Adds an extra offset to the keyboard. @@ -84,7 +88,7 @@ interface KeyboardAwareProps { * @type {number} * @memberof KeyboardAwareProps */ - extraScrollHeight?: number; + extraScrollHeight?: number /** * Sets the delay time before scrolling to new position @@ -94,49 +98,49 @@ interface KeyboardAwareProps { * @type {number} * @memberof KeyboardAwareProps */ - keyboardOpeningTime?: number; + keyboardOpeningTime?: number /** * Callback when the keyboard will show. * * @param frames Information about the keyboard frame and animation. */ - onKeyboardWillShow?: (frames: Object) => void; + onKeyboardWillShow?: (frames: Object) => void /** * Callback when the keyboard did show. * * @param frames Information about the keyboard frame and animation. */ - onKeyboardDidShow?: (frames: Object) => void; + onKeyboardDidShow?: (frames: Object) => void /** * Callback when the keyboard will hide. * * @param frames Information about the keyboard frame and animation. */ - onKeyboardWillHide?: (frames: Object) => void; + onKeyboardWillHide?: (frames: Object) => void /** * Callback when the keyboard did hide. * * @param frames Information about the keyboard frame and animation. */ - onKeyboardDidHide?: (frames: Object) => void; + onKeyboardDidHide?: (frames: Object) => void /** * Callback when the keyboard frame will change. * * @param frames Information about the keyboard frame and animation. */ - onKeyboardWillChangeFrame?: (frames: Object) => void; + onKeyboardWillChangeFrame?: (frames: Object) => void /** * Callback when the keyboard frame did change. * * @param frames Information about the keyboard frame and animation. */ - onKeyboardDidChangeFrame?: (frames: Object) => void; + onKeyboardDidChangeFrame?: (frames: Object) => void } interface KeyboardAwareScrollViewProps @@ -150,19 +154,19 @@ interface KeyboardAwareSectionListProps SectionListProps {} interface KeyboardAwareState { - keyboardSpace: number; + keyboardSpace: number } declare class ScrollableComponent extends React.Component { - getScrollResponder: () => void; - scrollToPosition: (x: number, y: number, animated?: boolean) => void; - scrollToEnd: (animated?: boolean) => void; - scrollForExtraHeightOnAndroid: (extraHeight: number) => void; + getScrollResponder: () => void + scrollToPosition: (x: number, y: number, animated?: boolean) => void + scrollToEnd: (animated?: boolean) => void + scrollForExtraHeightOnAndroid: (extraHeight: number) => void scrollToFocusedInput: ( reactNode: Object, extraHeight?: number, keyboardOpeningTime?: number - ) => void; + ) => void } export class KeyboardAwareMixin {} @@ -177,4 +181,4 @@ export class KeyboardAwareFlatList extends ScrollableComponent< export class KeyboardAwareSectionList extends ScrollableComponent< KeyboardAwareSectionListProps, KeyboardAwareState -> {} +> {} \ No newline at end of file