@storybook/react-native 10.2.3 → 10.3.0-canary-20260217005118

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +35 -6
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -999,7 +999,10 @@ var layoutStyles = {
999
999
  centered: { alignItems: "center", justifyContent: "center" },
1000
1000
  fullscreen: {}
1001
1001
  };
1002
- var StoryView = ({ useWrapper = true }) => {
1002
+ var StoryView = ({
1003
+ useWrapper = true,
1004
+ storyBackgroundColor
1005
+ }) => {
1003
1006
  const context = useStoryContext();
1004
1007
  const id = context?.id;
1005
1008
  const theme3 = (0, import_react_native_theming.useTheme)();
@@ -1008,11 +1011,11 @@ var StoryView = ({ useWrapper = true }) => {
1008
1011
  const layoutStyle = layout ? layoutStyles[layout] : {};
1009
1012
  return {
1010
1013
  flex: 1,
1011
- backgroundColor: theme3.background?.content,
1014
+ backgroundColor: storyBackgroundColor || theme3.background?.content,
1012
1015
  overflow: "hidden",
1013
1016
  ...layoutStyle
1014
1017
  };
1015
- }, [theme3.background?.content, context?.parameters?.layout]);
1018
+ }, [theme3.background?.content, context?.parameters?.layout, storyBackgroundColor]);
1016
1019
  const onError = (0, import_react3.useCallback)(() => {
1017
1020
  console.log(`Error rendering story for ${context?.title} ${context?.name}`);
1018
1021
  }, [context?.title, context?.name]);
@@ -1048,6 +1051,23 @@ var STORYBOOK_STORY_ID_PARAM = "STORYBOOK_STORY_ID";
1048
1051
 
1049
1052
  // src/View.tsx
1050
1053
  var import_jsx_runtime3 = require("react/jsx-runtime");
1054
+ function resolveStoryBackgroundColor(story) {
1055
+ const backgroundGlobal = story?.globals?.backgrounds?.value;
1056
+ const bgParams = story?.parameters?.backgrounds;
1057
+ const backgroundName = backgroundGlobal || bgParams?.default;
1058
+ if (!backgroundName) return void 0;
1059
+ if (bgParams?.options?.[backgroundName]?.value) {
1060
+ return bgParams.options[backgroundName].value;
1061
+ }
1062
+ if (bgParams?.values) {
1063
+ const match = bgParams.values.find(
1064
+ (bg) => bg.name === backgroundName
1065
+ );
1066
+ if (match) return match.value;
1067
+ }
1068
+ if (backgroundName.startsWith("#")) return backgroundName;
1069
+ return void 0;
1070
+ }
1051
1071
  var View3 = class {
1052
1072
  _storyIndex;
1053
1073
  _setStory = () => {
@@ -1310,6 +1330,7 @@ var View3 = class {
1310
1330
  }
1311
1331
  );
1312
1332
  }
1333
+ const storyBackgroundColor = resolveStoryBackgroundColor(story);
1313
1334
  if (onDeviceUI) {
1314
1335
  if (CustomUIComponent) {
1315
1336
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
@@ -1320,7 +1341,14 @@ var View3 = class {
1320
1341
  setStory: (newStoryId) => self._channel.emit(import_core_events.SET_CURRENT_STORY, { storyId: newStoryId }),
1321
1342
  storage,
1322
1343
  theme: appliedTheme,
1323
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(StoryView_default, { useWrapper: storyViewWrapper })
1344
+ storyBackgroundColor,
1345
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1346
+ StoryView_default,
1347
+ {
1348
+ useWrapper: storyViewWrapper,
1349
+ storyBackgroundColor
1350
+ }
1351
+ )
1324
1352
  }
1325
1353
  );
1326
1354
  }
@@ -1332,11 +1360,12 @@ var View3 = class {
1332
1360
  storyHash,
1333
1361
  story,
1334
1362
  setStory: (newStoryId) => self._channel.emit(import_core_events.SET_CURRENT_STORY, { storyId: newStoryId }),
1335
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(StoryView_default, { useWrapper: storyViewWrapper })
1363
+ storyBackgroundColor,
1364
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(StoryView_default, { useWrapper: storyViewWrapper, storyBackgroundColor })
1336
1365
  }
1337
1366
  );
1338
1367
  } else {
1339
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(StoryView_default, { useWrapper: storyViewWrapper });
1368
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(StoryView_default, { useWrapper: storyViewWrapper, storyBackgroundColor });
1340
1369
  }
1341
1370
  };
1342
1371
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/react-native",
3
- "version": "10.2.3",
3
+ "version": "10.3.0-canary-20260217005118",
4
4
  "description": "A better way to develop React Native Components for your app",
5
5
  "keywords": [
6
6
  "react",
@@ -43,9 +43,9 @@
43
43
  ],
44
44
  "dependencies": {
45
45
  "@storybook/react": "^10.2.3",
46
- "@storybook/react-native-theming": "^10.2.3",
47
- "@storybook/react-native-ui": "^10.2.3",
48
- "@storybook/react-native-ui-common": "^10.2.3",
46
+ "@storybook/react-native-theming": "10.3.0-canary-20260217005118",
47
+ "@storybook/react-native-ui": "10.3.0-canary-20260217005118",
48
+ "@storybook/react-native-ui-common": "10.3.0-canary-20260217005118",
49
49
  "commander": "^14.0.2",
50
50
  "dedent": "^1.7.0",
51
51
  "deepmerge": "^4.3.1",