@idealyst/components 1.2.48 → 1.2.50

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idealyst/components",
3
- "version": "1.2.48",
3
+ "version": "1.2.50",
4
4
  "description": "Shared component library for React and React Native",
5
5
  "documentation": "https://github.com/IdealystIO/idealyst-framework/tree/main/packages/components#readme",
6
6
  "readme": "README.md",
@@ -56,7 +56,7 @@
56
56
  "publish:npm": "npm publish"
57
57
  },
58
58
  "peerDependencies": {
59
- "@idealyst/theme": "^1.2.48",
59
+ "@idealyst/theme": "^1.2.50",
60
60
  "@mdi/js": ">=7.0.0",
61
61
  "@mdi/react": ">=1.0.0",
62
62
  "@react-native-vector-icons/common": ">=12.0.0",
@@ -107,7 +107,7 @@
107
107
  },
108
108
  "devDependencies": {
109
109
  "@idealyst/blur": "^1.2.40",
110
- "@idealyst/theme": "^1.2.48",
110
+ "@idealyst/theme": "^1.2.50",
111
111
  "@idealyst/tooling": "^1.2.30",
112
112
  "@mdi/react": "^1.6.1",
113
113
  "@types/react": "^19.1.0",
@@ -1,5 +1,5 @@
1
1
  import { useEffect, forwardRef, useMemo } from 'react';
2
- import { Modal, View, Text, TouchableOpacity, TouchableWithoutFeedback, BackHandler, GestureResponderEvent, KeyboardAvoidingView, Platform } from 'react-native';
2
+ import { Modal, View, Text, TouchableOpacity, TouchableWithoutFeedback, BackHandler, GestureResponderEvent, Keyboard, Platform } from 'react-native';
3
3
  import Animated, { useSharedValue, useAnimatedStyle, withTiming, Easing } from 'react-native-reanimated';
4
4
  import { DialogProps } from './types';
5
5
  import { dialogStyles } from './Dialog.styles';
@@ -41,6 +41,34 @@ const Dialog = forwardRef<View, DialogProps>(({
41
41
  const backdropOpacity = useSharedValue(0);
42
42
  const containerScale = useSharedValue(0.9);
43
43
  const containerOpacity = useSharedValue(0);
44
+ const keyboardOffset = useSharedValue(0);
45
+
46
+ // Listen for keyboard events and animate offset
47
+ useEffect(() => {
48
+ if (!avoidKeyboard || !open) return;
49
+
50
+ const showEvent = Platform.OS === 'ios' ? 'keyboardWillShow' : 'keyboardDidShow';
51
+ const hideEvent = Platform.OS === 'ios' ? 'keyboardWillHide' : 'keyboardDidHide';
52
+
53
+ const showSubscription = Keyboard.addListener(showEvent, (e) => {
54
+ keyboardOffset.value = withTiming(e.endCoordinates.height / 2, {
55
+ duration: Platform.OS === 'ios' ? e.duration : 250,
56
+ easing: Easing.out(Easing.cubic),
57
+ });
58
+ });
59
+
60
+ const hideSubscription = Keyboard.addListener(hideEvent, (e) => {
61
+ keyboardOffset.value = withTiming(0, {
62
+ duration: Platform.OS === 'ios' ? (e.duration ?? 250) : 250,
63
+ easing: Easing.out(Easing.cubic),
64
+ });
65
+ });
66
+
67
+ return () => {
68
+ showSubscription.remove();
69
+ hideSubscription.remove();
70
+ };
71
+ }, [avoidKeyboard, open]);
44
72
 
45
73
  // Animate in/out when open changes
46
74
  useEffect(() => {
@@ -109,11 +137,13 @@ const Dialog = forwardRef<View, DialogProps>(({
109
137
  });
110
138
 
111
139
  const containerAnimatedStyle = useAnimatedStyle(() => {
140
+ 'worklet';
112
141
  return {
113
142
  opacity: containerOpacity.value,
114
143
  transform: [
115
144
  { scale: containerScale.value },
116
- ],
145
+ { translateY: -keyboardOffset.value },
146
+ ] as { scale: number }[] & { translateY: number }[],
117
147
  };
118
148
  });
119
149
 
@@ -176,23 +206,6 @@ const Dialog = forwardRef<View, DialogProps>(({
176
206
  </TouchableWithoutFeedback>
177
207
  );
178
208
 
179
- const modalContent = (
180
- <TouchableWithoutFeedback onPress={handleBackdropPress}>
181
- {BackdropComponent ? (
182
- <View style={customBackdropWrapperStyle}>
183
- <Animated.View style={[customBackdropContainerStyle, backdropAnimatedStyle]}>
184
- <BackdropComponent isVisible={open} />
185
- </Animated.View>
186
- {dialogContainer}
187
- </View>
188
- ) : (
189
- <Animated.View style={[backdropStyle, backdropAnimatedStyle]}>
190
- {dialogContainer}
191
- </Animated.View>
192
- )}
193
- </TouchableWithoutFeedback>
194
- );
195
-
196
209
  return (
197
210
  <Modal
198
211
  visible={open}
@@ -202,16 +215,20 @@ const Dialog = forwardRef<View, DialogProps>(({
202
215
  statusBarTranslucent
203
216
  testID={testID}
204
217
  >
205
- {avoidKeyboard ? (
206
- <KeyboardAvoidingView
207
- style={{ flex: 1 }}
208
- behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
209
- >
210
- {modalContent}
211
- </KeyboardAvoidingView>
212
- ) : (
213
- modalContent
214
- )}
218
+ <TouchableWithoutFeedback onPress={handleBackdropPress}>
219
+ {BackdropComponent ? (
220
+ <View style={customBackdropWrapperStyle}>
221
+ <Animated.View style={[customBackdropContainerStyle, backdropAnimatedStyle]}>
222
+ <BackdropComponent isVisible={open} />
223
+ </Animated.View>
224
+ {dialogContainer}
225
+ </View>
226
+ ) : (
227
+ <Animated.View style={[backdropStyle, backdropAnimatedStyle]}>
228
+ {dialogContainer}
229
+ </Animated.View>
230
+ )}
231
+ </TouchableWithoutFeedback>
215
232
  </Modal>
216
233
  );
217
234
  });