From 2c19b6c4a131c541fa4cb992f45ebf5c0b7ebb1e Mon Sep 17 00:00:00 2001 From: Bartosz Grajdek Date: Tue, 29 Aug 2023 12:29:48 +0200 Subject: [PATCH 1/2] [TS migration] Migrate 'getClickedTargetLocation' lib to TypeScript --- src/libs/getClickedTargetLocation/index.js | 11 ----------- .../getClickedTargetLocation/index.native.js | 18 ------------------ .../getClickedTargetLocation/index.native.ts | 9 +++++++++ src/libs/getClickedTargetLocation/index.ts | 8 ++++++++ src/libs/getClickedTargetLocation/types.ts | 5 +++++ 5 files changed, 22 insertions(+), 29 deletions(-) delete mode 100644 src/libs/getClickedTargetLocation/index.js delete mode 100644 src/libs/getClickedTargetLocation/index.native.js create mode 100644 src/libs/getClickedTargetLocation/index.native.ts create mode 100644 src/libs/getClickedTargetLocation/index.ts create mode 100644 src/libs/getClickedTargetLocation/types.ts diff --git a/src/libs/getClickedTargetLocation/index.js b/src/libs/getClickedTargetLocation/index.js deleted file mode 100644 index fac03005fa02..000000000000 --- a/src/libs/getClickedTargetLocation/index.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Returns the Bounding Rectangle for the passed native event's target. - * - * @param {Object} target - * @returns {Object} - */ -function getClickedTargetLocation(target) { - return target.getBoundingClientRect(); -} - -export default getClickedTargetLocation; diff --git a/src/libs/getClickedTargetLocation/index.native.js b/src/libs/getClickedTargetLocation/index.native.js deleted file mode 100644 index b973ec6ed897..000000000000 --- a/src/libs/getClickedTargetLocation/index.native.js +++ /dev/null @@ -1,18 +0,0 @@ -/** - * We don't need to get the position of the element on native platforms because the popover will be bottom mounted - * - * @returns {Object} - */ -function getClickedTargetLocation() { - return { - top: 0, - bottom: 0, - left: 0, - right: 0, - height: 0, - x: 0, - y: 0, - }; -} - -export default getClickedTargetLocation; diff --git a/src/libs/getClickedTargetLocation/index.native.ts b/src/libs/getClickedTargetLocation/index.native.ts new file mode 100644 index 000000000000..063b7af9cd36 --- /dev/null +++ b/src/libs/getClickedTargetLocation/index.native.ts @@ -0,0 +1,9 @@ +/** + * We don't need to get the position of the element on native platforms because the popover will be bottom mounted + */ + +import GetClickedTargetLocation from './types'; + +const getClickedTargetLocation: GetClickedTargetLocation = () => ({top: 0, bottom: 0, left: 0, right: 0, height: 0, x: 0, y: 0}); + +export default getClickedTargetLocation; diff --git a/src/libs/getClickedTargetLocation/index.ts b/src/libs/getClickedTargetLocation/index.ts new file mode 100644 index 000000000000..e218700c3355 --- /dev/null +++ b/src/libs/getClickedTargetLocation/index.ts @@ -0,0 +1,8 @@ +import GetClickedTargetLocation from './types'; + +/** + * Returns the Bounding Rectangle for the passed native event's target. + */ +const getClickedTargetLocation: GetClickedTargetLocation = (target) => target.getBoundingClientRect(); + +export default getClickedTargetLocation; diff --git a/src/libs/getClickedTargetLocation/types.ts b/src/libs/getClickedTargetLocation/types.ts new file mode 100644 index 000000000000..7b1e85e63b17 --- /dev/null +++ b/src/libs/getClickedTargetLocation/types.ts @@ -0,0 +1,5 @@ +type DOMRectProperties = 'top' | 'bottom' | 'left' | 'right' | 'height' | 'x' | 'y'; + +type GetClickedTargetLocation = (target: Element) => Pick; + +export default GetClickedTargetLocation; From 26d51b7abdf3d4d2a9564063d90292c70e4d6e52 Mon Sep 17 00:00:00 2001 From: Bartosz Grajdek Date: Tue, 29 Aug 2023 12:32:02 +0200 Subject: [PATCH 2/2] Clean up comments --- src/libs/getClickedTargetLocation/index.native.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/libs/getClickedTargetLocation/index.native.ts b/src/libs/getClickedTargetLocation/index.native.ts index 063b7af9cd36..1755d4e4ac99 100644 --- a/src/libs/getClickedTargetLocation/index.native.ts +++ b/src/libs/getClickedTargetLocation/index.native.ts @@ -1,9 +1,8 @@ +import GetClickedTargetLocation from './types'; + /** * We don't need to get the position of the element on native platforms because the popover will be bottom mounted */ - -import GetClickedTargetLocation from './types'; - const getClickedTargetLocation: GetClickedTargetLocation = () => ({top: 0, bottom: 0, left: 0, right: 0, height: 0, x: 0, y: 0}); export default getClickedTargetLocation;