@idealyst/components 1.2.49 → 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 +3 -3
- package/src/Dialog/Dialog.native.tsx +56 -38
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idealyst/components",
|
|
3
|
-
"version": "1.2.
|
|
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.
|
|
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.
|
|
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,
|
|
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
|
|
|
@@ -147,44 +177,32 @@ const Dialog = forwardRef<View, DialogProps>(({
|
|
|
147
177
|
bottom: 0,
|
|
148
178
|
};
|
|
149
179
|
|
|
150
|
-
const dialogContent = (
|
|
151
|
-
<Animated.View ref={ref as any} style={[containerStyle, style, containerAnimatedStyle]} nativeID={id} {...nativeA11yProps}>
|
|
152
|
-
{(title || showCloseButton) && (
|
|
153
|
-
<View style={headerStyle}>
|
|
154
|
-
{title && (
|
|
155
|
-
<Text style={titleStyle}>
|
|
156
|
-
{title}
|
|
157
|
-
</Text>
|
|
158
|
-
)}
|
|
159
|
-
{showCloseButton && (
|
|
160
|
-
<TouchableOpacity
|
|
161
|
-
style={closeButtonStyle}
|
|
162
|
-
onPress={handleClosePress}
|
|
163
|
-
accessibilityLabel="Close dialog"
|
|
164
|
-
accessibilityRole="button"
|
|
165
|
-
>
|
|
166
|
-
<Text style={closeButtonTextStyle}>×</Text>
|
|
167
|
-
</TouchableOpacity>
|
|
168
|
-
)}
|
|
169
|
-
</View>
|
|
170
|
-
)}
|
|
171
|
-
<View style={contentStyle}>
|
|
172
|
-
{children}
|
|
173
|
-
</View>
|
|
174
|
-
</Animated.View>
|
|
175
|
-
);
|
|
176
|
-
|
|
177
180
|
const dialogContainer = (
|
|
178
181
|
<TouchableWithoutFeedback onPress={(e: GestureResponderEvent) => e.stopPropagation()}>
|
|
179
|
-
{
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
182
|
+
<Animated.View ref={ref as any} style={[containerStyle, style, containerAnimatedStyle]} nativeID={id} {...nativeA11yProps}>
|
|
183
|
+
{(title || showCloseButton) && (
|
|
184
|
+
<View style={headerStyle}>
|
|
185
|
+
{title && (
|
|
186
|
+
<Text style={titleStyle}>
|
|
187
|
+
{title}
|
|
188
|
+
</Text>
|
|
189
|
+
)}
|
|
190
|
+
{showCloseButton && (
|
|
191
|
+
<TouchableOpacity
|
|
192
|
+
style={closeButtonStyle}
|
|
193
|
+
onPress={handleClosePress}
|
|
194
|
+
accessibilityLabel="Close dialog"
|
|
195
|
+
accessibilityRole="button"
|
|
196
|
+
>
|
|
197
|
+
<Text style={closeButtonTextStyle}>×</Text>
|
|
198
|
+
</TouchableOpacity>
|
|
199
|
+
)}
|
|
200
|
+
</View>
|
|
201
|
+
)}
|
|
202
|
+
<View style={contentStyle}>
|
|
203
|
+
{children}
|
|
204
|
+
</View>
|
|
205
|
+
</Animated.View>
|
|
188
206
|
</TouchableWithoutFeedback>
|
|
189
207
|
);
|
|
190
208
|
|