From fdb5721eadff9438c500c2a2faf88a69d816613b Mon Sep 17 00:00:00 2001 From: Jorge Cabiedes Acosta Date: Fri, 13 Sep 2024 12:35:57 -0700 Subject: [PATCH] Rename `BoxShadowPrimitive` to `BoxShadowValue` (#46485) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/46485 Keep the type naming consistent with examples like `DimensionValue`, `ColorValue`, etc. Changelog: [Internal] Reviewed By: NickGerleman Differential Revision: D62614444 fbshipit-source-id: 3ff66d3f52623b6fb7bd8d31d2910aa255ae8a31 --- .../Libraries/StyleSheet/StyleSheetTypes.d.ts | 4 ++-- .../Libraries/StyleSheet/StyleSheetTypes.js | 4 ++-- .../Libraries/StyleSheet/processBoxShadow.js | 12 +++++------- .../__tests__/__snapshots__/public-api-test.js.snap | 6 +++--- packages/react-native/types/experimental.d.ts | 2 -- 5 files changed, 12 insertions(+), 16 deletions(-) diff --git a/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.d.ts b/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.d.ts index 2821964a816..5578fef6252 100644 --- a/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.d.ts +++ b/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.d.ts @@ -248,7 +248,7 @@ export type DropShadowPrimitive = { color?: ColorValue | number | undefined; }; -export type BoxShadowPrimitive = { +export type BoxShadowValue = { offsetX: number | string; offsetY: number | string; color?: string | undefined; @@ -336,7 +336,7 @@ export interface ViewStyle extends FlexStyle, ShadowStyleIOS, TransformsStyle { pointerEvents?: 'box-none' | 'none' | 'box-only' | 'auto' | undefined; isolation?: 'auto' | 'isolate' | undefined; cursor?: CursorValue | undefined; - boxShadow?: ReadonlyArray | string | undefined; + boxShadow?: ReadonlyArray | string | undefined; filter?: ReadonlyArray | string | undefined; } diff --git a/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.js b/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.js index 713a390fc13..219755edd01 100644 --- a/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.js +++ b/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.js @@ -719,7 +719,7 @@ export type GradientValue = { }>, }; -export type BoxShadowPrimitive = { +export type BoxShadowValue = { offsetX: number | string, offsetY: number | string, color?: ____ColorValue_Internal, @@ -788,7 +788,7 @@ export type ____ViewStyle_InternalCore = $ReadOnly<{ elevation?: number, pointerEvents?: 'auto' | 'none' | 'box-none' | 'box-only', cursor?: CursorValue, - boxShadow?: $ReadOnlyArray | string, + boxShadow?: $ReadOnlyArray | string, filter?: $ReadOnlyArray | string, experimental_mixBlendMode?: ____BlendMode_Internal, experimental_backgroundImage?: $ReadOnlyArray | string, diff --git a/packages/react-native/Libraries/StyleSheet/processBoxShadow.js b/packages/react-native/Libraries/StyleSheet/processBoxShadow.js index 97c6581584a..c801063ebb7 100644 --- a/packages/react-native/Libraries/StyleSheet/processBoxShadow.js +++ b/packages/react-native/Libraries/StyleSheet/processBoxShadow.js @@ -10,7 +10,7 @@ */ import type {ProcessedColorValue} from './processColor'; -import type {BoxShadowPrimitive} from './StyleSheetTypes'; +import type {BoxShadowValue} from './StyleSheetTypes'; import processColor from './processColor'; @@ -24,7 +24,7 @@ export type ParsedBoxShadow = { }; export default function processBoxShadow( - rawBoxShadows: ?($ReadOnlyArray | string), + rawBoxShadows: ?($ReadOnlyArray | string), ): Array { const result: Array = []; if (rawBoxShadows == null) { @@ -106,16 +106,14 @@ export default function processBoxShadow( return result; } -function parseBoxShadowString( - rawBoxShadows: string, -): Array { - let result: Array = []; +function parseBoxShadowString(rawBoxShadows: string): Array { + let result: Array = []; for (const rawBoxShadow of rawBoxShadows .split(/,(?![^()]*\))/) // split by comma that is not in parenthesis .map(bS => bS.trim()) .filter(bS => bS !== '')) { - const boxShadow: BoxShadowPrimitive = { + const boxShadow: BoxShadowValue = { offsetX: 0, offsetY: 0, }; diff --git a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap index 3dba8f5c83c..7cc568fab22 100644 --- a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap +++ b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap @@ -8247,7 +8247,7 @@ export type GradientValue = { positions?: $ReadOnlyArray, }>, }; -export type BoxShadowPrimitive = { +export type BoxShadowValue = { offsetX: number | string, offsetY: number | string, color?: ____ColorValue_Internal, @@ -8314,7 +8314,7 @@ export type ____ViewStyle_InternalCore = $ReadOnly<{ elevation?: number, pointerEvents?: \\"auto\\" | \\"none\\" | \\"box-none\\" | \\"box-only\\", cursor?: CursorValue, - boxShadow?: $ReadOnlyArray | string, + boxShadow?: $ReadOnlyArray | string, filter?: $ReadOnlyArray | string, experimental_mixBlendMode?: ____BlendMode_Internal, experimental_backgroundImage?: $ReadOnlyArray | string, @@ -8586,7 +8586,7 @@ exports[`public API should not change unintentionally Libraries/StyleSheet/proce inset?: boolean, }; declare export default function processBoxShadow( - rawBoxShadows: ?($ReadOnlyArray | string) + rawBoxShadows: ?($ReadOnlyArray | string) ): Array; " `; diff --git a/packages/react-native/types/experimental.d.ts b/packages/react-native/types/experimental.d.ts index 141a41e767d..cdbe8f3c925 100644 --- a/packages/react-native/types/experimental.d.ts +++ b/packages/react-native/types/experimental.d.ts @@ -35,9 +35,7 @@ import { GradientValue, BlendMode, - BoxShadowPrimitive, DimensionValue, - FilterFunction, } from 'react-native/Libraries/StyleSheet/StyleSheetTypes'; export {};