@storybook/react-native-ui 10.2.0-beta.1 → 10.2.0-beta.2
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 +13 -2
- package/package.json +5 -25
- package/src/MobileMenuDrawer.tsx +22 -3
- package/src/SelectedNodeProvider.tsx +1 -1
package/dist/index.js
CHANGED
|
@@ -313,7 +313,7 @@ var SelectedNodeProvider = ({ children }) => {
|
|
|
313
313
|
} catch (_error) {
|
|
314
314
|
}
|
|
315
315
|
}
|
|
316
|
-
},
|
|
316
|
+
}, 100);
|
|
317
317
|
}, []);
|
|
318
318
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
319
319
|
SelectedNodeContext.Provider,
|
|
@@ -1598,11 +1598,21 @@ var MobileMenuDrawer = (0, import_react16.memo)(
|
|
|
1598
1598
|
const theme = (0, import_react_native_theming14.useTheme)();
|
|
1599
1599
|
const menuBottomSheetRef = (0, import_react16.useRef)(null);
|
|
1600
1600
|
const { scrollToSelectedNode, scrollRef } = useSelectedNode();
|
|
1601
|
+
const shouldScrollOnOpen = (0, import_react16.useRef)(false);
|
|
1602
|
+
const handleSheetChange = (0, import_react16.useCallback)(
|
|
1603
|
+
(index) => {
|
|
1604
|
+
if (index >= 0 && shouldScrollOnOpen.current) {
|
|
1605
|
+
shouldScrollOnOpen.current = false;
|
|
1606
|
+
scrollToSelectedNode();
|
|
1607
|
+
}
|
|
1608
|
+
},
|
|
1609
|
+
[scrollToSelectedNode]
|
|
1610
|
+
);
|
|
1601
1611
|
(0, import_react16.useImperativeHandle)(ref, () => ({
|
|
1602
1612
|
setMobileMenuOpen: (open) => {
|
|
1603
1613
|
if (open) {
|
|
1614
|
+
shouldScrollOnOpen.current = true;
|
|
1604
1615
|
menuBottomSheetRef.current?.snapToIndex(1);
|
|
1605
|
-
scrollToSelectedNode();
|
|
1606
1616
|
} else {
|
|
1607
1617
|
import_react_native6.Keyboard.dismiss();
|
|
1608
1618
|
menuBottomSheetRef.current?.close();
|
|
@@ -1634,6 +1644,7 @@ var MobileMenuDrawer = (0, import_react16.memo)(
|
|
|
1634
1644
|
backdropComponent: BottomSheetBackdropComponent,
|
|
1635
1645
|
backgroundStyle: bgColorStyle,
|
|
1636
1646
|
handleIndicatorStyle,
|
|
1647
|
+
onChange: handleSheetChange,
|
|
1637
1648
|
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
1638
1649
|
import_bottom_sheet3.BottomSheetScrollView,
|
|
1639
1650
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/react-native-ui",
|
|
3
|
-
"version": "10.2.0-beta.
|
|
3
|
+
"version": "10.2.0-beta.2",
|
|
4
4
|
"description": "ui components for react native storybook",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -29,38 +29,18 @@
|
|
|
29
29
|
],
|
|
30
30
|
"scripts": {
|
|
31
31
|
"dev": "tsup --watch",
|
|
32
|
-
"prepare": "tsup"
|
|
33
|
-
"test": "jest --passWithNoTests",
|
|
34
|
-
"test:ci": "jest"
|
|
35
|
-
},
|
|
36
|
-
"jest": {
|
|
37
|
-
"modulePathIgnorePatterns": [
|
|
38
|
-
"dist/"
|
|
39
|
-
],
|
|
40
|
-
"moduleFileExtensions": [
|
|
41
|
-
"ts",
|
|
42
|
-
"tsx",
|
|
43
|
-
"js",
|
|
44
|
-
"jsx",
|
|
45
|
-
"json",
|
|
46
|
-
"node"
|
|
47
|
-
],
|
|
48
|
-
"preset": "react-native"
|
|
32
|
+
"prepare": "tsup"
|
|
49
33
|
},
|
|
50
34
|
"devDependencies": {
|
|
51
|
-
"@types/jest": "^29.4.3",
|
|
52
35
|
"@types/react": "~19.1.10",
|
|
53
|
-
"babel-jest": "^29.7.0",
|
|
54
|
-
"jest": "^29.7.0",
|
|
55
|
-
"react-test-renderer": "^19.1.0",
|
|
56
36
|
"tsup": "^8.5.0",
|
|
57
37
|
"typescript": "~5.9.3"
|
|
58
38
|
},
|
|
59
39
|
"dependencies": {
|
|
60
40
|
"@gorhom/portal": "^1.0.14",
|
|
61
41
|
"@storybook/react": "10.2.0-beta.1",
|
|
62
|
-
"@storybook/react-native-theming": "^10.2.0-beta.
|
|
63
|
-
"@storybook/react-native-ui-common": "^10.2.0-beta.
|
|
42
|
+
"@storybook/react-native-theming": "^10.2.0-beta.2",
|
|
43
|
+
"@storybook/react-native-ui-common": "^10.2.0-beta.2",
|
|
64
44
|
"fuse.js": "^7.1.0",
|
|
65
45
|
"polished": "^4.3.1"
|
|
66
46
|
},
|
|
@@ -80,5 +60,5 @@
|
|
|
80
60
|
"publishConfig": {
|
|
81
61
|
"access": "public"
|
|
82
62
|
},
|
|
83
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "d976cd836796cb08eba134a558ccfc1be371d45b"
|
|
84
64
|
}
|
package/src/MobileMenuDrawer.tsx
CHANGED
|
@@ -4,7 +4,15 @@ import BottomSheet, {
|
|
|
4
4
|
BottomSheetScrollView,
|
|
5
5
|
} from '@gorhom/bottom-sheet';
|
|
6
6
|
import { useTheme } from '@storybook/react-native-theming';
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
forwardRef,
|
|
9
|
+
memo,
|
|
10
|
+
ReactNode,
|
|
11
|
+
useCallback,
|
|
12
|
+
useImperativeHandle,
|
|
13
|
+
useMemo,
|
|
14
|
+
useRef,
|
|
15
|
+
} from 'react';
|
|
8
16
|
import { Keyboard, Platform } from 'react-native';
|
|
9
17
|
import { useAnimatedStyle, useReducedMotion } from 'react-native-reanimated';
|
|
10
18
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
@@ -55,13 +63,23 @@ export const MobileMenuDrawer = memo(
|
|
|
55
63
|
const theme = useTheme();
|
|
56
64
|
const menuBottomSheetRef = useRef<BottomSheet>(null);
|
|
57
65
|
const { scrollToSelectedNode, scrollRef } = useSelectedNode();
|
|
66
|
+
const shouldScrollOnOpen = useRef(false);
|
|
67
|
+
|
|
68
|
+
const handleSheetChange = useCallback(
|
|
69
|
+
(index: number) => {
|
|
70
|
+
if (index >= 0 && shouldScrollOnOpen.current) {
|
|
71
|
+
shouldScrollOnOpen.current = false;
|
|
72
|
+
scrollToSelectedNode();
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
[scrollToSelectedNode]
|
|
76
|
+
);
|
|
58
77
|
|
|
59
78
|
useImperativeHandle(ref, () => ({
|
|
60
79
|
setMobileMenuOpen: (open: boolean) => {
|
|
61
80
|
if (open) {
|
|
81
|
+
shouldScrollOnOpen.current = true;
|
|
62
82
|
menuBottomSheetRef.current?.snapToIndex(1);
|
|
63
|
-
|
|
64
|
-
scrollToSelectedNode();
|
|
65
83
|
} else {
|
|
66
84
|
Keyboard.dismiss();
|
|
67
85
|
|
|
@@ -99,6 +117,7 @@ export const MobileMenuDrawer = memo(
|
|
|
99
117
|
backdropComponent={BottomSheetBackdropComponent}
|
|
100
118
|
backgroundStyle={bgColorStyle}
|
|
101
119
|
handleIndicatorStyle={handleIndicatorStyle}
|
|
120
|
+
onChange={handleSheetChange}
|
|
102
121
|
>
|
|
103
122
|
<BottomSheetScrollView
|
|
104
123
|
ref={scrollRef}
|