@storybook/react-native-ui-lite 9.1.2 → 9.1.4
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 +98 -85
- package/package.json +5 -5
- package/src/MobileAddonsPanel.tsx +2 -2
- package/src/MobileMenuDrawer.tsx +1 -1
- package/src/useAnimatedValue.ts +13 -0
package/dist/index.js
CHANGED
|
@@ -1347,65 +1347,78 @@ var Sidebar = import_react11.default.memo(function Sidebar2({
|
|
|
1347
1347
|
// src/Layout.tsx
|
|
1348
1348
|
var import_react_native_theming10 = require("@storybook/react-native-theming");
|
|
1349
1349
|
var import_react_native_ui_common7 = require("@storybook/react-native-ui-common");
|
|
1350
|
-
var
|
|
1351
|
-
var
|
|
1350
|
+
var import_react16 = require("react");
|
|
1351
|
+
var import_react_native10 = require("react-native");
|
|
1352
1352
|
var import_core_events = require("storybook/internal/core-events");
|
|
1353
1353
|
var import_manager_api2 = require("storybook/internal/manager-api");
|
|
1354
1354
|
|
|
1355
1355
|
// src/MobileAddonsPanel.tsx
|
|
1356
1356
|
var import_react_native_theming8 = require("@storybook/react-native-theming");
|
|
1357
|
-
var
|
|
1358
|
-
var
|
|
1357
|
+
var import_react_native_ui_common6 = require("@storybook/react-native-ui-common");
|
|
1358
|
+
var import_react13 = require("react");
|
|
1359
|
+
var import_react_native7 = require("react-native");
|
|
1359
1360
|
var import_manager_api = require("storybook/internal/manager-api");
|
|
1360
1361
|
var import_types = require("storybook/internal/types");
|
|
1361
|
-
|
|
1362
|
+
|
|
1363
|
+
// src/useAnimatedValue.ts
|
|
1364
|
+
var import_react12 = require("react");
|
|
1365
|
+
var import_react_native6 = require("react-native");
|
|
1366
|
+
function useAnimatedValue(initialValue, config) {
|
|
1367
|
+
const ref = (0, import_react12.useRef)(null);
|
|
1368
|
+
if (ref.current == null) {
|
|
1369
|
+
ref.current = new import_react_native6.Animated.Value(initialValue, config);
|
|
1370
|
+
}
|
|
1371
|
+
return ref.current;
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
// src/MobileAddonsPanel.tsx
|
|
1362
1375
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1363
|
-
var MobileAddonsPanel = (0,
|
|
1376
|
+
var MobileAddonsPanel = (0, import_react13.forwardRef)(
|
|
1364
1377
|
({ storyId }, ref) => {
|
|
1365
1378
|
const theme = (0, import_react_native_theming8.useTheme)();
|
|
1366
|
-
const [mobileMenuOpen, setMobileMenuOpen] = (0,
|
|
1367
|
-
const { height } = (0,
|
|
1368
|
-
const panelHeight =
|
|
1369
|
-
const positionBottomAnimation =
|
|
1370
|
-
(0,
|
|
1379
|
+
const [mobileMenuOpen, setMobileMenuOpen] = (0, import_react13.useState)(false);
|
|
1380
|
+
const { height } = (0, import_react_native7.useWindowDimensions)();
|
|
1381
|
+
const panelHeight = useAnimatedValue(height / 2);
|
|
1382
|
+
const positionBottomAnimation = useAnimatedValue(0);
|
|
1383
|
+
(0, import_react13.useEffect)(() => {
|
|
1371
1384
|
const handleKeyboardShow = ({ endCoordinates, duration, easing }) => {
|
|
1372
|
-
|
|
1373
|
-
|
|
1385
|
+
import_react_native7.Animated.parallel([
|
|
1386
|
+
import_react_native7.Animated.timing(positionBottomAnimation, {
|
|
1374
1387
|
toValue: -endCoordinates.height,
|
|
1375
1388
|
// Negative to move up
|
|
1376
1389
|
duration,
|
|
1377
1390
|
useNativeDriver: false,
|
|
1378
|
-
easing:
|
|
1391
|
+
easing: import_react_native7.Easing[easing] || import_react_native7.Easing.out(import_react_native7.Easing.ease)
|
|
1379
1392
|
}),
|
|
1380
|
-
|
|
1393
|
+
import_react_native7.Animated.timing(panelHeight, {
|
|
1381
1394
|
toValue: (height - endCoordinates.height) / 2,
|
|
1382
1395
|
duration: duration + 250,
|
|
1383
1396
|
useNativeDriver: false,
|
|
1384
|
-
easing:
|
|
1397
|
+
easing: import_react_native7.Easing[easing] || import_react_native7.Easing.out(import_react_native7.Easing.ease)
|
|
1385
1398
|
})
|
|
1386
1399
|
]).start();
|
|
1387
1400
|
};
|
|
1388
1401
|
const handleKeyboardHide = ({ duration, easing }) => {
|
|
1389
|
-
|
|
1390
|
-
|
|
1402
|
+
import_react_native7.Animated.parallel([
|
|
1403
|
+
import_react_native7.Animated.timing(positionBottomAnimation, {
|
|
1391
1404
|
toValue: 0,
|
|
1392
1405
|
// Back to original position
|
|
1393
1406
|
duration,
|
|
1394
1407
|
useNativeDriver: false,
|
|
1395
|
-
easing:
|
|
1408
|
+
easing: import_react_native7.Easing[easing] || import_react_native7.Easing.out(import_react_native7.Easing.ease)
|
|
1396
1409
|
}),
|
|
1397
|
-
|
|
1410
|
+
import_react_native7.Animated.timing(panelHeight, {
|
|
1398
1411
|
toValue: height / 2,
|
|
1399
1412
|
duration,
|
|
1400
1413
|
useNativeDriver: false,
|
|
1401
|
-
easing:
|
|
1414
|
+
easing: import_react_native7.Easing[easing] || import_react_native7.Easing.out(import_react_native7.Easing.ease)
|
|
1402
1415
|
})
|
|
1403
1416
|
]).start();
|
|
1404
1417
|
};
|
|
1405
|
-
const showSubscription =
|
|
1406
|
-
const willShowSubscription =
|
|
1407
|
-
const hideSubscription =
|
|
1408
|
-
const didHideSubscription =
|
|
1418
|
+
const showSubscription = import_react_native7.Keyboard.addListener("keyboardDidShow", handleKeyboardShow);
|
|
1419
|
+
const willShowSubscription = import_react_native7.Keyboard.addListener("keyboardWillShow", handleKeyboardShow);
|
|
1420
|
+
const hideSubscription = import_react_native7.Keyboard.addListener("keyboardWillHide", handleKeyboardHide);
|
|
1421
|
+
const didHideSubscription = import_react_native7.Keyboard.addListener("keyboardDidHide", handleKeyboardHide);
|
|
1409
1422
|
return () => {
|
|
1410
1423
|
showSubscription.remove();
|
|
1411
1424
|
willShowSubscription.remove();
|
|
@@ -1413,7 +1426,7 @@ var MobileAddonsPanel = (0, import_react12.forwardRef)(
|
|
|
1413
1426
|
didHideSubscription.remove();
|
|
1414
1427
|
};
|
|
1415
1428
|
}, [height, panelHeight, positionBottomAnimation]);
|
|
1416
|
-
(0,
|
|
1429
|
+
(0, import_react13.useImperativeHandle)(ref, () => ({
|
|
1417
1430
|
setAddonsPanelOpen: (open) => {
|
|
1418
1431
|
if (open) {
|
|
1419
1432
|
setMobileMenuOpen(true);
|
|
@@ -1426,7 +1439,7 @@ var MobileAddonsPanel = (0, import_react12.forwardRef)(
|
|
|
1426
1439
|
return null;
|
|
1427
1440
|
}
|
|
1428
1441
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1429
|
-
|
|
1442
|
+
import_react_native7.Animated.View,
|
|
1430
1443
|
{
|
|
1431
1444
|
style: {
|
|
1432
1445
|
position: "absolute",
|
|
@@ -1437,13 +1450,13 @@ var MobileAddonsPanel = (0, import_react12.forwardRef)(
|
|
|
1437
1450
|
transform: [{ translateY: positionBottomAnimation }]
|
|
1438
1451
|
},
|
|
1439
1452
|
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1440
|
-
|
|
1453
|
+
import_react_native7.SafeAreaView,
|
|
1441
1454
|
{
|
|
1442
1455
|
style: {
|
|
1443
1456
|
justifyContent: "flex-end"
|
|
1444
1457
|
},
|
|
1445
1458
|
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1446
|
-
|
|
1459
|
+
import_react_native7.View,
|
|
1447
1460
|
{
|
|
1448
1461
|
style: {
|
|
1449
1462
|
height: "100%",
|
|
@@ -1451,7 +1464,7 @@ var MobileAddonsPanel = (0, import_react12.forwardRef)(
|
|
|
1451
1464
|
paddingTop: 10,
|
|
1452
1465
|
borderTopColor: theme.appBorderColor,
|
|
1453
1466
|
borderTopWidth: 1,
|
|
1454
|
-
paddingBottom:
|
|
1467
|
+
paddingBottom: import_react_native7.Platform.OS === "android" ? 16 : 0
|
|
1455
1468
|
},
|
|
1456
1469
|
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1457
1470
|
AddonsTabs,
|
|
@@ -1501,20 +1514,20 @@ var scrollContentContainerStyle = {
|
|
|
1501
1514
|
var hitSlop = { top: 10, right: 10, bottom: 10, left: 10 };
|
|
1502
1515
|
var AddonsTabs = ({ onClose, storyId }) => {
|
|
1503
1516
|
const panels = import_manager_api.addons.getElements(import_types.Addon_TypesEnum.PANEL);
|
|
1504
|
-
const [addonSelected, setAddonSelected] = (0,
|
|
1505
|
-
const panel = (0,
|
|
1517
|
+
const [addonSelected, setAddonSelected] = (0, import_react13.useState)(Object.keys(panels)[0]);
|
|
1518
|
+
const panel = (0, import_react13.useMemo)(() => {
|
|
1506
1519
|
if (!storyId) {
|
|
1507
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1520
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_native7.View, { style: centeredStyle, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_native7.Text, { children: "No Story Selected" }) });
|
|
1508
1521
|
}
|
|
1509
1522
|
if (Object.keys(panels).length === 0) {
|
|
1510
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1523
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_native7.View, { style: centeredStyle, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_native7.Text, { children: "No addons loaded." }) });
|
|
1511
1524
|
}
|
|
1512
1525
|
return panels[addonSelected].render({ active: true });
|
|
1513
1526
|
}, [addonSelected, panels, storyId]);
|
|
1514
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
1515
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
1527
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_react_native7.View, { style: addonsTabsContainerStyle, children: [
|
|
1528
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_react_native7.View, { style: addonsTabsStyle, children: [
|
|
1516
1529
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1517
|
-
|
|
1530
|
+
import_react_native7.ScrollView,
|
|
1518
1531
|
{
|
|
1519
1532
|
horizontal: true,
|
|
1520
1533
|
showsHorizontalScrollIndicator: false,
|
|
@@ -1544,7 +1557,7 @@ var AddonsTabs = ({ onClose, storyId }) => {
|
|
|
1544
1557
|
)
|
|
1545
1558
|
] }),
|
|
1546
1559
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1547
|
-
|
|
1560
|
+
import_react_native7.ScrollView,
|
|
1548
1561
|
{
|
|
1549
1562
|
style: addonsScrollStyle,
|
|
1550
1563
|
contentContainerStyle: scrollContentContainerStyle,
|
|
@@ -1574,17 +1587,17 @@ var TabText = import_react_native_theming8.styled.Text(({ theme, active }) => ({
|
|
|
1574
1587
|
|
|
1575
1588
|
// src/MobileMenuDrawer.tsx
|
|
1576
1589
|
var import_react_native_theming9 = require("@storybook/react-native-theming");
|
|
1577
|
-
var
|
|
1578
|
-
var
|
|
1590
|
+
var import_react14 = require("react");
|
|
1591
|
+
var import_react_native8 = require("react-native");
|
|
1579
1592
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1580
|
-
var MobileMenuDrawer = (0,
|
|
1581
|
-
(0,
|
|
1582
|
-
const [mobileMenuOpen, setMobileMenuOpen] = (0,
|
|
1593
|
+
var MobileMenuDrawer = (0, import_react14.memo)(
|
|
1594
|
+
(0, import_react14.forwardRef)(({ children }, ref) => {
|
|
1595
|
+
const [mobileMenuOpen, setMobileMenuOpen] = (0, import_react14.useState)(false);
|
|
1583
1596
|
const { scrollToSelectedNode, scrollRef } = useSelectedNode();
|
|
1584
1597
|
const theme = (0, import_react_native_theming9.useTheme)();
|
|
1585
|
-
const dragY =
|
|
1586
|
-
const panResponder = (0,
|
|
1587
|
-
|
|
1598
|
+
const dragY = useAnimatedValue(0);
|
|
1599
|
+
const panResponder = (0, import_react14.useRef)(
|
|
1600
|
+
import_react_native8.PanResponder.create({
|
|
1588
1601
|
onStartShouldSetPanResponder: () => true,
|
|
1589
1602
|
onMoveShouldSetPanResponder: (_, gestureState) => {
|
|
1590
1603
|
return gestureState.dy > 0;
|
|
@@ -1596,10 +1609,10 @@ var MobileMenuDrawer = (0, import_react13.memo)(
|
|
|
1596
1609
|
},
|
|
1597
1610
|
onPanResponderRelease: (_, gestureState) => {
|
|
1598
1611
|
if (gestureState.dy > 50) {
|
|
1599
|
-
|
|
1612
|
+
import_react_native8.Keyboard.dismiss();
|
|
1600
1613
|
setMobileMenuOpen(false);
|
|
1601
1614
|
}
|
|
1602
|
-
|
|
1615
|
+
import_react_native8.Animated.timing(dragY, {
|
|
1603
1616
|
toValue: 0,
|
|
1604
1617
|
duration: 300,
|
|
1605
1618
|
useNativeDriver: true
|
|
@@ -1607,19 +1620,19 @@ var MobileMenuDrawer = (0, import_react13.memo)(
|
|
|
1607
1620
|
}
|
|
1608
1621
|
})
|
|
1609
1622
|
).current;
|
|
1610
|
-
(0,
|
|
1623
|
+
(0, import_react14.useImperativeHandle)(ref, () => ({
|
|
1611
1624
|
setMobileMenuOpen: (open) => {
|
|
1612
1625
|
if (open) {
|
|
1613
1626
|
dragY.setValue(0);
|
|
1614
1627
|
scrollToSelectedNode();
|
|
1615
1628
|
setMobileMenuOpen(true);
|
|
1616
1629
|
} else {
|
|
1617
|
-
|
|
1630
|
+
import_react_native8.Keyboard.dismiss();
|
|
1618
1631
|
setMobileMenuOpen(false);
|
|
1619
1632
|
}
|
|
1620
1633
|
}
|
|
1621
1634
|
}));
|
|
1622
|
-
const handleStyle = (0,
|
|
1635
|
+
const handleStyle = (0, import_react14.useMemo)(
|
|
1623
1636
|
() => ({
|
|
1624
1637
|
width: 40,
|
|
1625
1638
|
height: 5,
|
|
@@ -1632,17 +1645,17 @@ var MobileMenuDrawer = (0, import_react13.memo)(
|
|
|
1632
1645
|
[theme.color.mediumdark]
|
|
1633
1646
|
);
|
|
1634
1647
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1635
|
-
|
|
1648
|
+
import_react_native8.Modal,
|
|
1636
1649
|
{
|
|
1637
1650
|
visible: mobileMenuOpen,
|
|
1638
1651
|
animationType: "slide",
|
|
1639
1652
|
transparent: true,
|
|
1640
1653
|
statusBarTranslucent: true,
|
|
1641
1654
|
onRequestClose: () => setMobileMenuOpen(false),
|
|
1642
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1643
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1655
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native8.KeyboardAvoidingView, { behavior: "height", style: { flex: 1 }, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_react_native8.SafeAreaView, { style: { justifyContent: "flex-end", flex: 1 }, children: [
|
|
1656
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native8.View, { style: { flex: 1 }, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native8.Pressable, { style: { flex: 1 }, onPress: () => setMobileMenuOpen(false) }) }),
|
|
1644
1657
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
1645
|
-
|
|
1658
|
+
import_react_native8.Animated.View,
|
|
1646
1659
|
{
|
|
1647
1660
|
style: [
|
|
1648
1661
|
{
|
|
@@ -1657,7 +1670,7 @@ var MobileMenuDrawer = (0, import_react13.memo)(
|
|
|
1657
1670
|
],
|
|
1658
1671
|
children: [
|
|
1659
1672
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1660
|
-
|
|
1673
|
+
import_react_native8.View,
|
|
1661
1674
|
{
|
|
1662
1675
|
...panResponder.panHandlers,
|
|
1663
1676
|
style: {
|
|
@@ -1665,11 +1678,11 @@ var MobileMenuDrawer = (0, import_react13.memo)(
|
|
|
1665
1678
|
justifyContent: "center",
|
|
1666
1679
|
backgroundColor: theme.background.content
|
|
1667
1680
|
},
|
|
1668
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1681
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native8.View, { style: handleStyle })
|
|
1669
1682
|
}
|
|
1670
1683
|
),
|
|
1671
1684
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1672
|
-
|
|
1685
|
+
import_react_native8.ScrollView,
|
|
1673
1686
|
{
|
|
1674
1687
|
ref: scrollRef,
|
|
1675
1688
|
keyboardShouldPersistTaps: "handled",
|
|
@@ -1693,18 +1706,18 @@ var MobileMenuDrawer = (0, import_react13.memo)(
|
|
|
1693
1706
|
);
|
|
1694
1707
|
|
|
1695
1708
|
// src/StorybookLogo.tsx
|
|
1696
|
-
var
|
|
1697
|
-
var
|
|
1709
|
+
var import_react15 = require("react");
|
|
1710
|
+
var import_react_native9 = require("react-native");
|
|
1698
1711
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1699
1712
|
var WIDTH = 125;
|
|
1700
1713
|
var HEIGHT = 25;
|
|
1701
1714
|
var NoBrandLogo = ({ theme }) => theme.base === "light" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Logo, { height: HEIGHT, width: WIDTH }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(DarkLogo, { height: HEIGHT, width: WIDTH });
|
|
1702
1715
|
function isElement(value) {
|
|
1703
|
-
return (0,
|
|
1716
|
+
return (0, import_react15.isValidElement)(value);
|
|
1704
1717
|
}
|
|
1705
1718
|
var BrandLogo = ({ theme }) => {
|
|
1706
1719
|
const imageHasNoWidthOrHeight = typeof theme.brand.image === "object" && typeof theme.brand.image === "object" && "uri" in theme.brand.image && (!("height" in theme.brand.image) || !("width" in theme.brand.image));
|
|
1707
|
-
(0,
|
|
1720
|
+
(0, import_react15.useEffect)(() => {
|
|
1708
1721
|
if (imageHasNoWidthOrHeight) {
|
|
1709
1722
|
console.warn(
|
|
1710
1723
|
"STORYBOOK: When using a remote image as the brand logo, you must also set the width and height.\nFor example: brand: { image: { uri: 'https://sb.com/img.png', height: 25, width: 25}}"
|
|
@@ -1718,7 +1731,7 @@ var BrandLogo = ({ theme }) => {
|
|
|
1718
1731
|
return theme.brand.image;
|
|
1719
1732
|
}
|
|
1720
1733
|
const image = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1721
|
-
|
|
1734
|
+
import_react_native9.Image,
|
|
1722
1735
|
{
|
|
1723
1736
|
source: theme.brand.image,
|
|
1724
1737
|
resizeMode: theme.brand.resizeMode ?? "contain",
|
|
@@ -1727,10 +1740,10 @@ var BrandLogo = ({ theme }) => {
|
|
|
1727
1740
|
);
|
|
1728
1741
|
if (theme.brand.url) {
|
|
1729
1742
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1730
|
-
|
|
1743
|
+
import_react_native9.TouchableOpacity,
|
|
1731
1744
|
{
|
|
1732
1745
|
onPress: () => {
|
|
1733
|
-
if (theme.brand.url)
|
|
1746
|
+
if (theme.brand.url) import_react_native9.Linking.openURL(theme.brand.url);
|
|
1734
1747
|
},
|
|
1735
1748
|
children: image
|
|
1736
1749
|
}
|
|
@@ -1740,7 +1753,7 @@ var BrandLogo = ({ theme }) => {
|
|
|
1740
1753
|
}
|
|
1741
1754
|
};
|
|
1742
1755
|
var BrandTitle = ({ theme }) => {
|
|
1743
|
-
const brandTitleStyle = (0,
|
|
1756
|
+
const brandTitleStyle = (0, import_react15.useMemo)(() => {
|
|
1744
1757
|
return {
|
|
1745
1758
|
width: WIDTH,
|
|
1746
1759
|
height: HEIGHT,
|
|
@@ -1748,13 +1761,13 @@ var BrandTitle = ({ theme }) => {
|
|
|
1748
1761
|
fontSize: theme.typography.size.m1
|
|
1749
1762
|
};
|
|
1750
1763
|
}, [theme]);
|
|
1751
|
-
const title = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1764
|
+
const title = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native9.Text, { style: brandTitleStyle, numberOfLines: 1, ellipsizeMode: "tail", children: theme.brand.title });
|
|
1752
1765
|
if (theme.brand.url) {
|
|
1753
1766
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1754
|
-
|
|
1767
|
+
import_react_native9.TouchableOpacity,
|
|
1755
1768
|
{
|
|
1756
1769
|
onPress: () => {
|
|
1757
|
-
if (theme.brand.url)
|
|
1770
|
+
if (theme.brand.url) import_react_native9.Linking.openURL(theme.brand.url);
|
|
1758
1771
|
},
|
|
1759
1772
|
children: title
|
|
1760
1773
|
}
|
|
@@ -1764,8 +1777,8 @@ var BrandTitle = ({ theme }) => {
|
|
|
1764
1777
|
}
|
|
1765
1778
|
};
|
|
1766
1779
|
var StorybookLogo = ({ theme }) => {
|
|
1767
|
-
const image = (0,
|
|
1768
|
-
const title = (0,
|
|
1780
|
+
const image = (0, import_react15.useMemo)(() => theme.brand?.image, [theme.brand?.image]);
|
|
1781
|
+
const title = (0, import_react15.useMemo)(() => theme.brand?.title, [theme.brand?.title]);
|
|
1769
1782
|
if (image) {
|
|
1770
1783
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(BrandLogo, { theme });
|
|
1771
1784
|
} else if (title) {
|
|
@@ -1813,7 +1826,7 @@ var Layout = ({
|
|
|
1813
1826
|
"desktopPanelState",
|
|
1814
1827
|
true
|
|
1815
1828
|
);
|
|
1816
|
-
const [uiHidden, setUiHidden] = (0,
|
|
1829
|
+
const [uiHidden, setUiHidden] = (0, import_react16.useState)(false);
|
|
1817
1830
|
const desktopSidebarStyle = (0, import_react_native_ui_common7.useStyle)(
|
|
1818
1831
|
() => ({
|
|
1819
1832
|
width: desktopSidebarOpen ? 240 : void 0,
|
|
@@ -1844,7 +1857,7 @@ var Layout = ({
|
|
|
1844
1857
|
return {
|
|
1845
1858
|
flex: 1,
|
|
1846
1859
|
backgroundColor: theme.background.content,
|
|
1847
|
-
paddingVertical:
|
|
1860
|
+
paddingVertical: import_react_native10.Platform.OS === "android" ? 32 : 0
|
|
1848
1861
|
};
|
|
1849
1862
|
}, [theme.background.content, story?.parameters?.noSafeArea, isDesktop]);
|
|
1850
1863
|
const fullScreenButtonStyle = (0, import_react_native_ui_common7.useStyle)(
|
|
@@ -1867,15 +1880,15 @@ var Layout = ({
|
|
|
1867
1880
|
}),
|
|
1868
1881
|
[theme.barTextColor]
|
|
1869
1882
|
);
|
|
1870
|
-
const mobileMenuDrawerRef = (0,
|
|
1871
|
-
const addonPanelRef = (0,
|
|
1872
|
-
const setSelection = (0,
|
|
1883
|
+
const mobileMenuDrawerRef = (0, import_react16.useRef)(null);
|
|
1884
|
+
const addonPanelRef = (0, import_react16.useRef)(null);
|
|
1885
|
+
const setSelection = (0, import_react16.useCallback)(({ storyId: newStoryId }) => {
|
|
1873
1886
|
const channel = import_manager_api2.addons.getChannel();
|
|
1874
1887
|
channel.emit(import_core_events.SET_CURRENT_STORY, { storyId: newStoryId });
|
|
1875
1888
|
}, []);
|
|
1876
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
1877
|
-
isDesktop ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1878
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
1889
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react_native10.SafeAreaView, { style: containerStyle, children: [
|
|
1890
|
+
isDesktop ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native10.View, { style: desktopSidebarStyle, children: desktopSidebarOpen ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react_native10.ScrollView, { keyboardShouldPersistTaps: "handled", children: [
|
|
1891
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react_native10.View, { style: desktopLogoContainer, children: [
|
|
1879
1892
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(StorybookLogo, { theme }),
|
|
1880
1893
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native_ui_common7.IconButton, { onPress: () => setDesktopSidebarOpen(false), Icon: MenuIcon })
|
|
1881
1894
|
] }),
|
|
@@ -1893,17 +1906,17 @@ var Layout = ({
|
|
|
1893
1906
|
}
|
|
1894
1907
|
)
|
|
1895
1908
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native_ui_common7.IconButton, { onPress: () => setDesktopSidebarOpen(true), Icon: MenuIcon }) }) : null,
|
|
1896
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
1897
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1909
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react_native10.View, { style: mobileContentStyle, children: [
|
|
1910
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native10.View, { style: contentContainerStyle, children }),
|
|
1898
1911
|
story?.parameters?.hideFullScreenButton || isDesktop ? null : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1899
|
-
|
|
1912
|
+
import_react_native10.TouchableOpacity,
|
|
1900
1913
|
{
|
|
1901
1914
|
style: fullScreenButtonStyle,
|
|
1902
1915
|
onPress: () => setUiHidden((prev) => !prev),
|
|
1903
1916
|
children: uiHidden ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(CloseFullscreenIcon, { color: theme.color.mediumdark }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(FullscreenIcon, { color: theme.color.mediumdark })
|
|
1904
1917
|
}
|
|
1905
1918
|
),
|
|
1906
|
-
isDesktop ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1919
|
+
isDesktop ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native10.View, { style: desktopAddonsPanelStyle, children: desktopAddonsPanelOpen ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(AddonsTabs, { storyId: story?.id, onClose: () => setDesktopAddonsPanelOpen(false) }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1907
1920
|
import_react_native_ui_common7.IconButton,
|
|
1908
1921
|
{
|
|
1909
1922
|
style: iconFloatRightStyle,
|
|
@@ -1922,7 +1935,7 @@ var Layout = ({
|
|
|
1922
1935
|
onPress: () => mobileMenuDrawerRef.current?.setMobileMenuOpen(true),
|
|
1923
1936
|
children: [
|
|
1924
1937
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(MenuIcon, { color: theme.color.mediumdark }),
|
|
1925
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
1938
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react_native10.Text, { style: navButtonTextStyle, numberOfLines: 1, children: [
|
|
1926
1939
|
story?.title,
|
|
1927
1940
|
"/",
|
|
1928
1941
|
story?.name
|
|
@@ -1940,7 +1953,7 @@ var Layout = ({
|
|
|
1940
1953
|
)
|
|
1941
1954
|
] }) }) : null,
|
|
1942
1955
|
isDesktop ? null : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(SelectedNodeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(MobileMenuDrawer, { ref: mobileMenuDrawerRef, children: [
|
|
1943
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1956
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native10.View, { style: mobileMenuDrawerContentStyle, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(StorybookLogo, { theme }) }),
|
|
1944
1957
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1945
1958
|
Sidebar,
|
|
1946
1959
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/react-native-ui-lite",
|
|
3
|
-
"version": "9.1.
|
|
3
|
+
"version": "9.1.4",
|
|
4
4
|
"description": "lightweight ui components for react native storybook",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -58,9 +58,9 @@
|
|
|
58
58
|
"typescript": "~5.9.2"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@storybook/react": "^9.1.
|
|
62
|
-
"@storybook/react-native-theming": "^9.1.
|
|
63
|
-
"@storybook/react-native-ui-common": "^9.1.
|
|
61
|
+
"@storybook/react": "^9.1.8",
|
|
62
|
+
"@storybook/react-native-theming": "^9.1.4",
|
|
63
|
+
"@storybook/react-native-ui-common": "^9.1.4",
|
|
64
64
|
"fuse.js": "^7.0.0",
|
|
65
65
|
"memoizerific": "^1.11.3",
|
|
66
66
|
"polished": "^4.3.1",
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
"publishConfig": {
|
|
78
78
|
"access": "public"
|
|
79
79
|
},
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "cc20e5ee9d9e7584eaefe71cc76e25dec5110a94"
|
|
81
81
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { styled, useTheme } from '@storybook/react-native-theming';
|
|
2
|
+
import { IconButton } from '@storybook/react-native-ui-common';
|
|
2
3
|
import { forwardRef, useEffect, useImperativeHandle, useMemo, useState } from 'react';
|
|
3
4
|
import {
|
|
4
5
|
Animated,
|
|
@@ -9,15 +10,14 @@ import {
|
|
|
9
10
|
ScrollView,
|
|
10
11
|
StyleProp,
|
|
11
12
|
Text,
|
|
12
|
-
useAnimatedValue,
|
|
13
13
|
useWindowDimensions,
|
|
14
14
|
View,
|
|
15
15
|
ViewStyle,
|
|
16
16
|
} from 'react-native';
|
|
17
17
|
import { addons } from 'storybook/internal/manager-api';
|
|
18
18
|
import { Addon_TypesEnum } from 'storybook/internal/types';
|
|
19
|
-
import { IconButton } from '@storybook/react-native-ui-common';
|
|
20
19
|
import { CloseIcon } from './icon/iconDataUris';
|
|
20
|
+
import useAnimatedValue from './useAnimatedValue';
|
|
21
21
|
|
|
22
22
|
export interface MobileAddonsPanelRef {
|
|
23
23
|
setAddonsPanelOpen: (isOpen: boolean) => void;
|
package/src/MobileMenuDrawer.tsx
CHANGED
|
@@ -10,11 +10,11 @@ import {
|
|
|
10
10
|
Pressable,
|
|
11
11
|
SafeAreaView,
|
|
12
12
|
ScrollView,
|
|
13
|
-
useAnimatedValue,
|
|
14
13
|
View,
|
|
15
14
|
} from 'react-native';
|
|
16
15
|
|
|
17
16
|
import { useSelectedNode } from './SelectedNodeProvider';
|
|
17
|
+
import useAnimatedValue from './useAnimatedValue';
|
|
18
18
|
|
|
19
19
|
interface MobileMenuDrawerProps {
|
|
20
20
|
children: ReactNode | ReactNode[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
import { Animated } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export default function useAnimatedValue(
|
|
5
|
+
initialValue: number,
|
|
6
|
+
config?: Animated.AnimatedConfig
|
|
7
|
+
): Animated.Value {
|
|
8
|
+
const ref = useRef<null | Animated.Value>(null);
|
|
9
|
+
if (ref.current == null) {
|
|
10
|
+
ref.current = new Animated.Value(initialValue, config);
|
|
11
|
+
}
|
|
12
|
+
return ref.current;
|
|
13
|
+
}
|