@storybook/react-native-ui-lite 10.4.0 → 10.4.1-canary-20260509150616

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
@@ -1845,30 +1845,52 @@ var portalContainerStyle = {
1845
1845
  };
1846
1846
  var useAnimatedModalHeight = () => {
1847
1847
  const { height } = (0, import_react_native11.useWindowDimensions)();
1848
- const animatedHeight = useAnimatedValue(0.65 * height);
1848
+ const modalHeight = 0.65 * height;
1849
+ const maxModalHeight = 0.85 * height;
1850
+ const [sheetHeight, setSheetHeight] = (0, import_react15.useState)(modalHeight);
1851
+ const [keyboardInset, setKeyboardInset] = (0, import_react15.useState)(0);
1852
+ const [isKeyboardVisible, setIsKeyboardVisible] = (0, import_react15.useState)(false);
1853
+ const keyboardOffset = useAnimatedValue(0);
1849
1854
  (0, import_react15.useEffect)(() => {
1850
- const modalHeight = 0.65 * height;
1851
- const maxModalHeight = 0.85 * height;
1852
- const expand = (duration = 250) => import_react_native11.Animated.timing(animatedHeight, {
1853
- toValue: maxModalHeight,
1854
- duration,
1855
- easing: import_react_native11.Easing.out(import_react_native11.Easing.quad),
1856
- useNativeDriver: false
1857
- }).start();
1858
- const collapse = (duration = 250) => import_react_native11.Animated.timing(animatedHeight, {
1859
- toValue: modalHeight,
1860
- duration,
1861
- easing: import_react_native11.Easing.out(import_react_native11.Easing.quad),
1862
- useNativeDriver: false
1863
- }).start();
1855
+ setSheetHeight(modalHeight);
1856
+ setKeyboardInset(0);
1857
+ setIsKeyboardVisible(false);
1858
+ keyboardOffset.setValue(0);
1859
+ }, [keyboardOffset, modalHeight]);
1860
+ (0, import_react15.useEffect)(() => {
1861
+ const expand = (duration = 250, keyboardHeight = 0) => {
1862
+ const maxKeyboardOffset = maxModalHeight - modalHeight;
1863
+ const keyboardAvoidanceOffset = Math.min(keyboardHeight, maxKeyboardOffset);
1864
+ setIsKeyboardVisible(true);
1865
+ setKeyboardInset(Math.max(keyboardHeight - keyboardAvoidanceOffset, 0));
1866
+ import_react_native11.Animated.timing(keyboardOffset, {
1867
+ toValue: -keyboardAvoidanceOffset,
1868
+ duration,
1869
+ easing: import_react_native11.Easing.out(import_react_native11.Easing.quad),
1870
+ useNativeDriver: true
1871
+ }).start();
1872
+ };
1873
+ const collapse = (duration = 250) => {
1874
+ import_react_native11.Animated.timing(keyboardOffset, {
1875
+ toValue: 0,
1876
+ duration,
1877
+ easing: import_react_native11.Easing.out(import_react_native11.Easing.quad),
1878
+ useNativeDriver: true
1879
+ }).start(({ finished }) => {
1880
+ if (finished) {
1881
+ setKeyboardInset(0);
1882
+ setIsKeyboardVisible(false);
1883
+ }
1884
+ });
1885
+ };
1864
1886
  const handleKeyboardWillShow = (e) => {
1865
1887
  if (import_react_native11.Platform.OS === "ios") {
1866
- expand(e.duration);
1888
+ expand(e.duration, e.endCoordinates.height);
1867
1889
  }
1868
1890
  };
1869
1891
  const handleKeyboardDidShow = (e) => {
1870
1892
  if (import_react_native11.Platform.OS === "android") {
1871
- expand();
1893
+ expand(void 0, e.endCoordinates.height);
1872
1894
  }
1873
1895
  };
1874
1896
  const handleKeyboardWillHide = (e) => {
@@ -1890,8 +1912,14 @@ var useAnimatedModalHeight = () => {
1890
1912
  return () => {
1891
1913
  subscriptions.forEach((subscription) => subscription.remove());
1892
1914
  };
1893
- }, [animatedHeight, height]);
1894
- return animatedHeight;
1915
+ }, [keyboardOffset, maxModalHeight, modalHeight]);
1916
+ return {
1917
+ height: sheetHeight,
1918
+ keyboardOffset,
1919
+ keyboardInset,
1920
+ isKeyboardVisible,
1921
+ sheetExtensionHeight: maxModalHeight - modalHeight
1922
+ };
1895
1923
  };
1896
1924
  var MobileMenuDrawer = (0, import_react15.memo)(
1897
1925
  (0, import_react15.forwardRef)(
@@ -1900,7 +1928,13 @@ var MobileMenuDrawer = (0, import_react15.memo)(
1900
1928
  const { scrollCallback } = useSelectedNode();
1901
1929
  const theme = (0, import_react_native_theming9.useTheme)();
1902
1930
  const { height } = (0, import_react_native11.useWindowDimensions)();
1903
- const animatedHeight = useAnimatedModalHeight();
1931
+ const {
1932
+ height: sheetHeight,
1933
+ keyboardOffset,
1934
+ keyboardInset,
1935
+ isKeyboardVisible,
1936
+ sheetExtensionHeight
1937
+ } = useAnimatedModalHeight();
1904
1938
  const slideAnim = useAnimatedValue(height);
1905
1939
  const dragY = useAnimatedValue(0);
1906
1940
  const openDrawer = (0, import_react15.useCallback)(() => {
@@ -1922,17 +1956,25 @@ var MobileMenuDrawer = (0, import_react15.memo)(
1922
1956
  const closeDrawer = (0, import_react15.useCallback)(() => {
1923
1957
  import_react_native11.Keyboard.dismiss();
1924
1958
  onVisibilityChange?.(false);
1925
- import_react_native11.Animated.timing(slideAnim, {
1926
- toValue: height,
1927
- duration: 300,
1928
- easing: import_react_native11.Easing.in(import_react_native11.Easing.quad),
1929
- useNativeDriver: true
1930
- }).start(({ finished }) => {
1959
+ import_react_native11.Animated.parallel([
1960
+ import_react_native11.Animated.timing(slideAnim, {
1961
+ toValue: height,
1962
+ duration: 300,
1963
+ easing: import_react_native11.Easing.in(import_react_native11.Easing.quad),
1964
+ useNativeDriver: true
1965
+ }),
1966
+ import_react_native11.Animated.timing(keyboardOffset, {
1967
+ toValue: 0,
1968
+ duration: 300,
1969
+ easing: import_react_native11.Easing.in(import_react_native11.Easing.quad),
1970
+ useNativeDriver: true
1971
+ })
1972
+ ]).start(({ finished }) => {
1931
1973
  if (finished) {
1932
1974
  setIsVisible(false);
1933
1975
  }
1934
1976
  });
1935
- }, [height, onVisibilityChange, slideAnim]);
1977
+ }, [height, keyboardOffset, onVisibilityChange, slideAnim]);
1936
1978
  const panResponder = (0, import_react15.useMemo)(
1937
1979
  () => import_react_native11.PanResponder.create({
1938
1980
  onStartShouldSetPanResponder: () => true,
@@ -1945,6 +1987,18 @@ var MobileMenuDrawer = (0, import_react15.memo)(
1945
1987
  }
1946
1988
  },
1947
1989
  onPanResponderRelease: (_, gestureState) => {
1990
+ if (isKeyboardVisible) {
1991
+ if (gestureState.dy > 20) {
1992
+ import_react_native11.Keyboard.dismiss();
1993
+ }
1994
+ import_react_native11.Animated.timing(dragY, {
1995
+ toValue: 0,
1996
+ duration: 250,
1997
+ easing: import_react_native11.Easing.out(import_react_native11.Easing.quad),
1998
+ useNativeDriver: true
1999
+ }).start();
2000
+ return;
2001
+ }
1948
2002
  if (gestureState.dy > 50) {
1949
2003
  closeDrawer();
1950
2004
  } else {
@@ -1957,7 +2011,11 @@ var MobileMenuDrawer = (0, import_react15.memo)(
1957
2011
  }
1958
2012
  }
1959
2013
  }),
1960
- [closeDrawer, dragY]
2014
+ [closeDrawer, dragY, isKeyboardVisible]
2015
+ );
2016
+ const sheetTranslateY = (0, import_react15.useMemo)(
2017
+ () => import_react_native11.Animated.add(import_react_native11.Animated.add(slideAnim, keyboardOffset), dragY),
2018
+ [dragY, keyboardOffset, slideAnim]
1961
2019
  );
1962
2020
  (0, import_react15.useImperativeHandle)(ref, () => ({
1963
2021
  setMobileMenuOpen: (open) => {
@@ -2003,14 +2061,26 @@ var MobileMenuDrawer = (0, import_react15.memo)(
2003
2061
  const childrenWrapperStyle = (0, import_react15.useMemo)(
2004
2062
  () => ({
2005
2063
  flex: 1,
2064
+ backgroundColor: theme.background.content,
2065
+ paddingBottom: keyboardInset
2066
+ }),
2067
+ [keyboardInset, theme.background.content]
2068
+ );
2069
+ const sheetBackgroundExtensionStyle = (0, import_react15.useMemo)(
2070
+ () => ({
2071
+ position: "absolute",
2072
+ left: 0,
2073
+ right: 0,
2074
+ bottom: -sheetExtensionHeight,
2075
+ height: sheetExtensionHeight,
2006
2076
  backgroundColor: theme.background.content
2007
2077
  }),
2008
- [theme.background.content]
2078
+ [sheetExtensionHeight, theme.background.content]
2009
2079
  );
2010
2080
  return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_portal.Portal, { hostName: "storybook-lite-ui-root", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
2011
2081
  import_react_native11.Animated.View,
2012
2082
  {
2013
- style: [portalContainerStyle, { transform: [{ translateY: slideAnim }] }],
2083
+ style: portalContainerStyle,
2014
2084
  pointerEvents: isVisible ? "auto" : "none",
2015
2085
  accessibilityElementsHidden: !isVisible,
2016
2086
  importantForAccessibility: isVisible ? "auto" : "no-hide-descendants",
@@ -2025,16 +2095,20 @@ var MobileMenuDrawer = (0, import_react15.memo)(
2025
2095
  accessibilityLabel: "Close story list"
2026
2096
  }
2027
2097
  ) }),
2028
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2098
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
2029
2099
  import_react_native11.Animated.View,
2030
2100
  {
2031
2101
  style: {
2032
- height: animatedHeight
2102
+ height: sheetHeight,
2103
+ transform: [{ translateY: sheetTranslateY }]
2033
2104
  },
2034
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_react_native11.Animated.View, { style: [drawerContainerStyle, { transform: [{ translateY: dragY }] }], children: [
2035
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native11.View, { ...panResponder.panHandlers, style: dragHandleWrapperStyle, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native11.View, { style: handleStyle }) }),
2036
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native11.View, { style: childrenWrapperStyle, children })
2037
- ] })
2105
+ children: [
2106
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native11.View, { pointerEvents: "none", style: sheetBackgroundExtensionStyle }),
2107
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_react_native11.Animated.View, { style: drawerContainerStyle, children: [
2108
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native11.View, { ...panResponder.panHandlers, style: dragHandleWrapperStyle, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native11.View, { style: handleStyle }) }),
2109
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native11.View, { style: childrenWrapperStyle, children })
2110
+ ] })
2111
+ ]
2038
2112
  }
2039
2113
  )
2040
2114
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/react-native-ui-lite",
3
- "version": "10.4.0",
3
+ "version": "10.4.1-canary-20260509150616",
4
4
  "description": "lightweight ui components for react native storybook",
5
5
  "keywords": [
6
6
  "react",
@@ -32,10 +32,10 @@
32
32
  "@legendapp/list": "3.0.0-beta.38",
33
33
  "@nozbe/microfuzz": "^1.0.0",
34
34
  "@storybook/react": "^10.3.2",
35
- "@storybook/react-native-theming": "^10.4.0",
36
- "@storybook/react-native-ui-common": "^10.4.0",
35
+ "@storybook/react-native-theming": "10.4.1-canary-20260509150616",
36
+ "@storybook/react-native-ui-common": "10.4.1-canary-20260509150616",
37
37
  "polished": "^4.3.1",
38
- "react-native-safe-area-context": "^5"
38
+ "react-native-safe-area-context": "^5.6.2"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/react": "~19.2.14",
@@ -49,37 +49,59 @@ export interface MobileMenuDrawerRef {
49
49
 
50
50
  export const useAnimatedModalHeight = () => {
51
51
  const { height } = useWindowDimensions();
52
- const animatedHeight = useAnimatedValue(0.65 * height);
52
+ const modalHeight = 0.65 * height;
53
+ const maxModalHeight = 0.85 * height;
54
+ const [sheetHeight, setSheetHeight] = useState(modalHeight);
55
+ const [keyboardInset, setKeyboardInset] = useState(0);
56
+ const [isKeyboardVisible, setIsKeyboardVisible] = useState(false);
57
+ const keyboardOffset = useAnimatedValue(0);
53
58
 
54
59
  useEffect(() => {
55
- const modalHeight = 0.65 * height;
56
- const maxModalHeight = 0.85 * height;
60
+ setSheetHeight(modalHeight);
61
+ setKeyboardInset(0);
62
+ setIsKeyboardVisible(false);
63
+ keyboardOffset.setValue(0);
64
+ }, [keyboardOffset, modalHeight]);
57
65
 
58
- const expand = (duration: number = 250) =>
59
- Animated.timing(animatedHeight, {
60
- toValue: maxModalHeight,
66
+ useEffect(() => {
67
+ const expand = (duration: number = 250, keyboardHeight: number = 0) => {
68
+ const maxKeyboardOffset = maxModalHeight - modalHeight;
69
+ const keyboardAvoidanceOffset = Math.min(keyboardHeight, maxKeyboardOffset);
70
+
71
+ setIsKeyboardVisible(true);
72
+ setKeyboardInset(Math.max(keyboardHeight - keyboardAvoidanceOffset, 0));
73
+
74
+ Animated.timing(keyboardOffset, {
75
+ toValue: -keyboardAvoidanceOffset,
61
76
  duration,
62
77
  easing: Easing.out(Easing.quad),
63
- useNativeDriver: false,
78
+ useNativeDriver: true,
64
79
  }).start();
80
+ };
65
81
 
66
- const collapse = (duration: number = 250) =>
67
- Animated.timing(animatedHeight, {
68
- toValue: modalHeight,
82
+ const collapse = (duration: number = 250) => {
83
+ Animated.timing(keyboardOffset, {
84
+ toValue: 0,
69
85
  duration,
70
86
  easing: Easing.out(Easing.quad),
71
- useNativeDriver: false,
72
- }).start();
87
+ useNativeDriver: true,
88
+ }).start(({ finished }) => {
89
+ if (finished) {
90
+ setKeyboardInset(0);
91
+ setIsKeyboardVisible(false);
92
+ }
93
+ });
94
+ };
73
95
 
74
96
  const handleKeyboardWillShow: KeyboardEventListener = (e) => {
75
97
  if (Platform.OS === 'ios') {
76
- expand(e.duration);
98
+ expand(e.duration, e.endCoordinates.height);
77
99
  }
78
100
  };
79
101
 
80
102
  const handleKeyboardDidShow: KeyboardEventListener = (e) => {
81
103
  if (Platform.OS === 'android') {
82
- expand();
104
+ expand(undefined, e.endCoordinates.height);
83
105
  }
84
106
  };
85
107
 
@@ -105,9 +127,15 @@ export const useAnimatedModalHeight = () => {
105
127
  return () => {
106
128
  subscriptions.forEach((subscription) => subscription.remove());
107
129
  };
108
- }, [animatedHeight, height]);
109
-
110
- return animatedHeight;
130
+ }, [keyboardOffset, maxModalHeight, modalHeight]);
131
+
132
+ return {
133
+ height: sheetHeight,
134
+ keyboardOffset,
135
+ keyboardInset,
136
+ isKeyboardVisible,
137
+ sheetExtensionHeight: maxModalHeight - modalHeight,
138
+ };
111
139
  };
112
140
 
113
141
  export const MobileMenuDrawer = memo(
@@ -117,7 +145,13 @@ export const MobileMenuDrawer = memo(
117
145
  const { scrollCallback } = useSelectedNode();
118
146
  const theme = useTheme();
119
147
  const { height } = useWindowDimensions();
120
- const animatedHeight = useAnimatedModalHeight();
148
+ const {
149
+ height: sheetHeight,
150
+ keyboardOffset,
151
+ keyboardInset,
152
+ isKeyboardVisible,
153
+ sheetExtensionHeight,
154
+ } = useAnimatedModalHeight();
121
155
 
122
156
  // Slide animation for drawer entrance/exit
123
157
  const slideAnim = useAnimatedValue(height);
@@ -148,17 +182,25 @@ export const MobileMenuDrawer = memo(
148
182
  Keyboard.dismiss();
149
183
  onVisibilityChange?.(false);
150
184
 
151
- Animated.timing(slideAnim, {
152
- toValue: height,
153
- duration: 300,
154
- easing: Easing.in(Easing.quad),
155
- useNativeDriver: true,
156
- }).start(({ finished }) => {
185
+ Animated.parallel([
186
+ Animated.timing(slideAnim, {
187
+ toValue: height,
188
+ duration: 300,
189
+ easing: Easing.in(Easing.quad),
190
+ useNativeDriver: true,
191
+ }),
192
+ Animated.timing(keyboardOffset, {
193
+ toValue: 0,
194
+ duration: 300,
195
+ easing: Easing.in(Easing.quad),
196
+ useNativeDriver: true,
197
+ }),
198
+ ]).start(({ finished }) => {
157
199
  if (finished) {
158
200
  setIsVisible(false);
159
201
  }
160
202
  });
161
- }, [height, onVisibilityChange, slideAnim]);
203
+ }, [height, keyboardOffset, onVisibilityChange, slideAnim]);
162
204
 
163
205
  // Create the pan responder for handling drag gestures
164
206
  const panResponder = useMemo(
@@ -176,6 +218,21 @@ export const MobileMenuDrawer = memo(
176
218
  }
177
219
  },
178
220
  onPanResponderRelease: (_, gestureState) => {
221
+ if (isKeyboardVisible) {
222
+ if (gestureState.dy > 20) {
223
+ Keyboard.dismiss();
224
+ }
225
+
226
+ Animated.timing(dragY, {
227
+ toValue: 0,
228
+ duration: 250,
229
+ easing: Easing.out(Easing.quad),
230
+ useNativeDriver: true,
231
+ }).start();
232
+
233
+ return;
234
+ }
235
+
179
236
  if (gestureState.dy > 50) {
180
237
  closeDrawer();
181
238
  } else {
@@ -189,7 +246,12 @@ export const MobileMenuDrawer = memo(
189
246
  }
190
247
  },
191
248
  }),
192
- [closeDrawer, dragY]
249
+ [closeDrawer, dragY, isKeyboardVisible]
250
+ );
251
+
252
+ const sheetTranslateY = useMemo(
253
+ () => Animated.add(Animated.add(slideAnim, keyboardOffset), dragY),
254
+ [dragY, keyboardOffset, slideAnim]
193
255
  );
194
256
 
195
257
  useImperativeHandle(ref, () => ({
@@ -243,14 +305,28 @@ export const MobileMenuDrawer = memo(
243
305
  () => ({
244
306
  flex: 1,
245
307
  backgroundColor: theme.background.content,
308
+ paddingBottom: keyboardInset,
246
309
  }),
247
- [theme.background.content]
310
+ [keyboardInset, theme.background.content]
311
+ );
312
+
313
+ const sheetBackgroundExtensionStyle = useMemo(
314
+ () =>
315
+ ({
316
+ position: 'absolute',
317
+ left: 0,
318
+ right: 0,
319
+ bottom: -sheetExtensionHeight,
320
+ height: sheetExtensionHeight,
321
+ backgroundColor: theme.background.content,
322
+ }) satisfies ViewStyle,
323
+ [sheetExtensionHeight, theme.background.content]
248
324
  );
249
325
 
250
326
  return (
251
327
  <Portal hostName="storybook-lite-ui-root">
252
328
  <Animated.View
253
- style={[portalContainerStyle, { transform: [{ translateY: slideAnim }] }]}
329
+ style={portalContainerStyle}
254
330
  pointerEvents={isVisible ? 'auto' : 'none'}
255
331
  accessibilityElementsHidden={!isVisible}
256
332
  importantForAccessibility={isVisible ? 'auto' : 'no-hide-descendants'}
@@ -267,10 +343,12 @@ export const MobileMenuDrawer = memo(
267
343
 
268
344
  <Animated.View
269
345
  style={{
270
- height: animatedHeight,
346
+ height: sheetHeight,
347
+ transform: [{ translateY: sheetTranslateY }],
271
348
  }}
272
349
  >
273
- <Animated.View style={[drawerContainerStyle, { transform: [{ translateY: dragY }] }]}>
350
+ <View pointerEvents="none" style={sheetBackgroundExtensionStyle} />
351
+ <Animated.View style={drawerContainerStyle}>
274
352
  {/* Drag handle */}
275
353
  <View {...panResponder.panHandlers} style={dragHandleWrapperStyle}>
276
354
  <View style={handleStyle} />