@storybook/react-native-ui 10.3.0-next.1 → 10.3.0-next.3

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.
package/dist/index.js CHANGED
@@ -1451,6 +1451,9 @@ var centeredStyle = {
1451
1451
  alignItems: "center",
1452
1452
  justifyContent: "center"
1453
1453
  };
1454
+ var hiddenStyle = {
1455
+ display: "none"
1456
+ };
1454
1457
  var hitSlop = { top: 10, right: 10, bottom: 10, left: 10 };
1455
1458
  var AddonsTabs = ({ onClose, storyId }) => {
1456
1459
  const panels = import_manager_api.addons.getElements(import_types.Addon_TypesEnum.PANEL);
@@ -1461,15 +1464,7 @@ var AddonsTabs = ({ onClose, storyId }) => {
1461
1464
  paddingBottom: insets.bottom + 16
1462
1465
  };
1463
1466
  });
1464
- const panel = (0, import_react16.useMemo)(() => {
1465
- if (!storyId) {
1466
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_react_native5.View, { style: centeredStyle, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_react_native5.Text, { children: "No Story Selected" }) });
1467
- }
1468
- if (Object.keys(panels).length === 0) {
1469
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_react_native5.View, { style: centeredStyle, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_react_native5.Text, { children: "No addons loaded." }) });
1470
- }
1471
- return panels[addonSelected].render({ active: true });
1472
- }, [addonSelected, panels, storyId]);
1467
+ const panelEntries = (0, import_react16.useMemo)(() => Object.entries(panels), [panels]);
1473
1468
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_react_native5.View, { style: addonsTabsContainerStyle, children: [
1474
1469
  /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_react_native5.View, { style: addonsTabsStyle, children: [
1475
1470
  /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
@@ -1485,7 +1480,7 @@ var AddonsTabs = ({ onClose, storyId }) => {
1485
1480
  {
1486
1481
  active: id === addonSelected,
1487
1482
  onPress: () => setAddonSelected(id),
1488
- text: resolvedTitle
1483
+ text: String(resolvedTitle)
1489
1484
  },
1490
1485
  id
1491
1486
  );
@@ -1507,11 +1502,14 @@ var AddonsTabs = ({ onClose, storyId }) => {
1507
1502
  {
1508
1503
  style: addonsScrollStyle,
1509
1504
  contentContainerStyle: scrollContentContainerStyle,
1510
- children: panel
1505
+ children: !storyId ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_react_native5.View, { style: centeredStyle, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_react_native5.Text, { children: "No Story Selected" }) }) : panelEntries.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_react_native5.View, { style: centeredStyle, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_react_native5.Text, { children: "No addons loaded." }) }) : panelEntries.map(([id, p]) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_react_native5.View, { style: id === addonSelected ? void 0 : hiddenStyle, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(PanelRenderer, { panel: p }) }, id))
1511
1506
  }
1512
1507
  )
1513
1508
  ] });
1514
1509
  };
1510
+ var PanelRenderer = ({ panel }) => {
1511
+ return panel.render({ active: true });
1512
+ };
1515
1513
  var Tab = ({ active, onPress, text }) => {
1516
1514
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(TabButton, { active, onPress, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(TabText, { active, children: text }) });
1517
1515
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/react-native-ui",
3
- "version": "10.3.0-next.1",
3
+ "version": "10.3.0-next.3",
4
4
  "description": "ui components for react native storybook",
5
5
  "keywords": [
6
6
  "react",
@@ -28,16 +28,17 @@
28
28
  "src/**/*"
29
29
  ],
30
30
  "devDependencies": {
31
- "@types/react": "~19.1.10",
31
+ "@types/react": "~19.2.14",
32
+ "storybook": "10.3.0-alpha.12",
32
33
  "tsup": "^8.5.0",
33
34
  "typescript": "~5.9.3"
34
35
  },
35
36
  "dependencies": {
36
37
  "@gorhom/portal": "^1.0.14",
37
38
  "@nozbe/microfuzz": "^1.0.0",
38
- "@storybook/react": "10.3.0-alpha.9",
39
- "@storybook/react-native-theming": "^10.3.0-next.1",
40
- "@storybook/react-native-ui-common": "^10.3.0-next.1",
39
+ "@storybook/react": "10.3.0-alpha.12",
40
+ "@storybook/react-native-theming": "^10.3.0-next.3",
41
+ "@storybook/react-native-ui-common": "^10.3.0-next.3",
41
42
  "polished": "^4.3.1"
42
43
  },
43
44
  "peerDependencies": {
@@ -1,7 +1,11 @@
1
1
  import { BottomSheetModal } from '@gorhom/bottom-sheet';
2
2
  import { addons } from 'storybook/manager-api';
3
3
  import { styled, useTheme } from '@storybook/react-native-theming';
4
- import { Addon_TypesEnum } from 'storybook/internal/types';
4
+ import {
5
+ Addon_TypesEnum,
6
+ type Addon_BaseType,
7
+ type Addon_Collection,
8
+ } from 'storybook/internal/types';
5
9
  import { forwardRef, useImperativeHandle, useMemo, useRef, useState } from 'react';
6
10
  import { Platform, StyleProp, Text, View, ViewStyle, useWindowDimensions } from 'react-native';
7
11
  import { ScrollView } from 'react-native-gesture-handler';
@@ -138,10 +142,14 @@ const centeredStyle = {
138
142
  justifyContent: 'center',
139
143
  } satisfies StyleProp<ViewStyle>;
140
144
 
145
+ const hiddenStyle = {
146
+ display: 'none',
147
+ } satisfies StyleProp<ViewStyle>;
148
+
141
149
  const hitSlop = { top: 10, right: 10, bottom: 10, left: 10 };
142
150
 
143
151
  export const AddonsTabs = ({ onClose, storyId }: { onClose?: () => void; storyId?: string }) => {
144
- const panels = addons.getElements(Addon_TypesEnum.PANEL);
152
+ const panels: Addon_Collection<Addon_BaseType> = addons.getElements(Addon_TypesEnum.PANEL);
145
153
 
146
154
  const [addonSelected, setAddonSelected] = useState(Object.keys(panels)[0]);
147
155
 
@@ -153,25 +161,7 @@ export const AddonsTabs = ({ onClose, storyId }: { onClose?: () => void; storyId
153
161
  };
154
162
  });
155
163
 
156
- const panel = useMemo(() => {
157
- if (!storyId) {
158
- return (
159
- <View style={centeredStyle}>
160
- <Text>No Story Selected</Text>
161
- </View>
162
- );
163
- }
164
-
165
- if (Object.keys(panels).length === 0) {
166
- return (
167
- <View style={centeredStyle}>
168
- <Text>No addons loaded.</Text>
169
- </View>
170
- );
171
- }
172
-
173
- return panels[addonSelected].render({ active: true });
174
- }, [addonSelected, panels, storyId]);
164
+ const panelEntries = useMemo(() => Object.entries(panels), [panels]);
175
165
 
176
166
  return (
177
167
  <View style={addonsTabsContainerStyle}>
@@ -189,7 +179,7 @@ export const AddonsTabs = ({ onClose, storyId }: { onClose?: () => void; storyId
189
179
  key={id}
190
180
  active={id === addonSelected}
191
181
  onPress={() => setAddonSelected(id)}
192
- text={resolvedTitle}
182
+ text={String(resolvedTitle)}
193
183
  />
194
184
  );
195
185
  })}
@@ -207,12 +197,30 @@ export const AddonsTabs = ({ onClose, storyId }: { onClose?: () => void; storyId
207
197
  // keyboardShouldPersistTaps="handled"
208
198
  contentContainerStyle={scrollContentContainerStyle}
209
199
  >
210
- {panel}
200
+ {!storyId ? (
201
+ <View style={centeredStyle}>
202
+ <Text>No Story Selected</Text>
203
+ </View>
204
+ ) : panelEntries.length === 0 ? (
205
+ <View style={centeredStyle}>
206
+ <Text>No addons loaded.</Text>
207
+ </View>
208
+ ) : (
209
+ panelEntries.map(([id, p]) => (
210
+ <View key={id} style={id === addonSelected ? undefined : hiddenStyle}>
211
+ <PanelRenderer panel={p} />
212
+ </View>
213
+ ))
214
+ )}
211
215
  </ScrollView>
212
216
  </View>
213
217
  );
214
218
  };
215
219
 
220
+ const PanelRenderer = ({ panel }: { panel: Addon_BaseType }) => {
221
+ return panel.render({ active: true });
222
+ };
223
+
216
224
  const Tab = ({ active, onPress, text }: { active: boolean; onPress: () => void; text: string }) => {
217
225
  return (
218
226
  <TabButton active={active} onPress={onPress}>
Binary file