@impulse-ui-native/flyout 1.0.0

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.
@@ -0,0 +1,336 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ Flyout: () => Flyout
34
+ });
35
+ module.exports = __toCommonJS(index_exports);
36
+
37
+ // src/components/flyout.tsx
38
+ var import_core = require("@impulse-ui-native/core");
39
+ var import_safe_area_view = require("@impulse-ui-native/safe-area-view");
40
+ var import_theme3 = require("@impulse-ui-native/theme");
41
+ var import_view3 = require("@impulse-ui-native/view");
42
+ var import_react3 = require("react");
43
+ var import_react_native3 = require("react-native");
44
+ var import_react_native_gesture_handler = require("react-native-gesture-handler");
45
+ var import_react_native_reanimated2 = __toESM(require("react-native-reanimated"));
46
+ var import_react_native_worklets = require("react-native-worklets");
47
+
48
+ // src/components/flyout-handle.tsx
49
+ var import_theme = require("@impulse-ui-native/theme");
50
+ var import_view = require("@impulse-ui-native/view");
51
+ var import_react = require("react");
52
+ var import_react_native = require("react-native");
53
+ var import_react_native_reanimated = __toESM(require("react-native-reanimated"));
54
+ var FlyoutHandleHeight = 32;
55
+ var FlyoutHandle = (0, import_react.memo)(function FlyoutHandle2(props) {
56
+ const theme = (0, import_theme.useTheme)();
57
+ const styles = (0, import_react.useMemo)(
58
+ () => themedStyles(theme, props.placement),
59
+ [theme, props.placement]
60
+ );
61
+ return /* @__PURE__ */ React.createElement(import_react_native_reanimated.default.View, { style: styles.flyoutHandleContainer }, /* @__PURE__ */ React.createElement(import_view.View, { style: styles.flyoutHandle }));
62
+ });
63
+ var themedStyles = function(theme, placement) {
64
+ return import_react_native.StyleSheet.create({
65
+ flyoutHandle: {
66
+ alignSelf: "center",
67
+ backgroundColor: theme.colors.background.primary,
68
+ width: "25%",
69
+ height: 6,
70
+ borderRadius: theme.radii.round
71
+ },
72
+ flyoutHandleContainer: {
73
+ position: "absolute",
74
+ top: placement === "bottom" ? -FlyoutHandleHeight : void 0,
75
+ bottom: placement === "top" ? -FlyoutHandleHeight : void 0,
76
+ width: "100%",
77
+ justifyContent: "center",
78
+ alignItems: "center",
79
+ height: FlyoutHandleHeight
80
+ }
81
+ });
82
+ };
83
+
84
+ // src/components/flyout-title.tsx
85
+ var import_theme2 = require("@impulse-ui-native/theme");
86
+ var import_typography = require("@impulse-ui-native/typography");
87
+ var import_view2 = require("@impulse-ui-native/view");
88
+ var import_react2 = require("react");
89
+ var import_react_native2 = require("react-native");
90
+ var FlyoutTitle = (0, import_react2.memo)(function FlyoutTitle2(props) {
91
+ const theme = (0, import_theme2.useTheme)();
92
+ const styles = (0, import_react2.useMemo)(
93
+ () => themedStyles2(theme, props.placement),
94
+ [theme, props.placement]
95
+ );
96
+ const title = (0, import_react2.useMemo)(() => {
97
+ if (typeof props.title === "string") {
98
+ return /* @__PURE__ */ React.createElement(import_typography.Typography.Title3, null, props.title);
99
+ }
100
+ return props.title;
101
+ }, [props.title]);
102
+ if (!props.title) {
103
+ return null;
104
+ }
105
+ return /* @__PURE__ */ React.createElement(import_view2.View, { style: styles.container }, title);
106
+ });
107
+ var themedStyles2 = function(theme, placement) {
108
+ return import_react_native2.StyleSheet.create({
109
+ container: {
110
+ borderTopLeftRadius: placement === "bottom" ? theme.radii.xl : void 0,
111
+ borderTopRightRadius: placement === "bottom" ? theme.radii.xl : void 0,
112
+ backgroundColor: theme.colors.background.secondary,
113
+ padding: theme.spacing.mxs,
114
+ alignItems: "center"
115
+ }
116
+ });
117
+ };
118
+
119
+ // src/components/flyout.tsx
120
+ var EnterAnimationConfig = {
121
+ damping: 50,
122
+ stiffness: 300,
123
+ mass: 1,
124
+ overshootClamping: true
125
+ };
126
+ var ExitAnimationConfig = {
127
+ duration: 150,
128
+ easing: import_react_native_reanimated2.Easing.in(import_react_native_reanimated2.Easing.quad)
129
+ };
130
+ var StickyHeaderIndices = [0];
131
+ var ScreenHeight = import_react_native3.Dimensions.get("screen").height;
132
+ var MaxHeight = ScreenHeight * 0.9;
133
+ var AndroidOverScroll = import_react_native3.Platform.OS === "android" ? { overScrollMode: "always" } : {};
134
+ var Flyout = (0, import_react3.memo)(function Flyout2({
135
+ children,
136
+ placement = "bottom",
137
+ ...props
138
+ }) {
139
+ const colors = (0, import_theme3.useColors)();
140
+ const theme = (0, import_theme3.useTheme)();
141
+ const [measuredHeight, setMeasuredHeight] = (0, import_react3.useState)(null);
142
+ const [bounceEnabled, setBounceEnabled] = (0, import_react3.useState)(placement !== "bottom");
143
+ const [viewportHeight, setViewportHeight] = (0, import_react3.useState)(0);
144
+ const [contentHeight, setContentHeight] = (0, import_react3.useState)(0);
145
+ const didOpen = (0, import_react3.useRef)(false);
146
+ const canDismiss = (0, import_react_native_reanimated2.useSharedValue)(placement === "bottom");
147
+ const scrollY = (0, import_react_native_reanimated2.useSharedValue)(0);
148
+ const maxScrollY = (0, import_react_native_reanimated2.useSharedValue)(0);
149
+ const translateY = (0, import_react_native_reanimated2.useSharedValue)(
150
+ placement === "top" ? -ScreenHeight : ScreenHeight
151
+ );
152
+ const opacity = (0, import_react_native_reanimated2.useSharedValue)(0);
153
+ const isScrollable = (0, import_react3.useMemo)(
154
+ () => contentHeight > viewportHeight,
155
+ [contentHeight, viewportHeight]
156
+ );
157
+ const onScroll = (0, import_react_native_reanimated2.useAnimatedScrollHandler)({
158
+ onScroll(event) {
159
+ scrollY.value = event.contentOffset.y;
160
+ maxScrollY.value = Math.max(
161
+ 0,
162
+ event.contentSize.height - event.layoutMeasurement.height
163
+ );
164
+ },
165
+ onMomentumEnd(event) {
166
+ if (placement === "bottom" && event.contentOffset.y <= 0) {
167
+ (0, import_react_native_worklets.scheduleOnRN)(setBounceEnabled, false);
168
+ canDismiss.value = true;
169
+ }
170
+ if (placement === "top" && scrollY.value >= maxScrollY.value - 1) {
171
+ (0, import_react_native_worklets.scheduleOnRN)(setBounceEnabled, false);
172
+ canDismiss.value = true;
173
+ }
174
+ }
175
+ });
176
+ const onLayout = (0, import_core.useEventCallback)((event) => {
177
+ if (!didOpen.current && measuredHeight === null) {
178
+ const rawHeight = event.nativeEvent.layout.height;
179
+ const clampedHeight = Math.min(rawHeight, MaxHeight);
180
+ setMeasuredHeight(clampedHeight);
181
+ translateY.value = placement === "top" ? -clampedHeight : clampedHeight;
182
+ }
183
+ });
184
+ const onLayoutScrollview = (0, import_core.useEventCallback)((event) => {
185
+ setViewportHeight(event.nativeEvent.layout.height);
186
+ });
187
+ const onContentSizeChange = (0, import_core.useEventCallback)(
188
+ (_contentWidth, contentHeight2) => {
189
+ setContentHeight(contentHeight2);
190
+ }
191
+ );
192
+ const animateOut = (0, import_core.useEventCallback)(() => {
193
+ if (measuredHeight) {
194
+ const target = placement === "top" ? -measuredHeight : measuredHeight;
195
+ translateY.value = (0, import_react_native_reanimated2.withTiming)(target, ExitAnimationConfig, (finished) => {
196
+ if (finished && props.onCloseFinished) {
197
+ (0, import_react_native_worklets.scheduleOnRN)(props.onCloseFinished, props.id);
198
+ }
199
+ });
200
+ opacity.value = (0, import_react_native_reanimated2.withTiming)(0, ExitAnimationConfig);
201
+ didOpen.current = false;
202
+ }
203
+ });
204
+ const onPanGestureEnd = (0, import_core.useEventCallback)(
205
+ (event) => {
206
+ if (!measuredHeight) return;
207
+ let shouldClose = false;
208
+ if (placement === "bottom") {
209
+ shouldClose = event.translationY > measuredHeight * 0.5 || event.velocityY > 1500;
210
+ }
211
+ if (placement === "top") {
212
+ shouldClose = event.translationY < -measuredHeight * 0.5 || event.velocityY < -1500;
213
+ }
214
+ if (shouldClose && (canDismiss.value || !isScrollable)) {
215
+ animateOut();
216
+ } else {
217
+ translateY.value = (0, import_react_native_reanimated2.withSpring)(0, EnterAnimationConfig);
218
+ opacity.value = (0, import_react_native_reanimated2.withSpring)(0.4, EnterAnimationConfig);
219
+ }
220
+ }
221
+ );
222
+ const onPanGestureHandleEnd = (0, import_core.useEventCallback)(
223
+ (event) => {
224
+ onPanGestureEnd(event);
225
+ if (placement === "bottom" && scrollY.value > 0) {
226
+ canDismiss.value = false;
227
+ }
228
+ if (placement === "top" && scrollY.value < maxScrollY.value - 1) {
229
+ canDismiss.value = false;
230
+ }
231
+ }
232
+ );
233
+ const onPanGestureUpdate = (event) => {
234
+ if (placement === "bottom" && event.translationY < 0) {
235
+ (0, import_react_native_worklets.scheduleOnRN)(setBounceEnabled, true);
236
+ canDismiss.value = false;
237
+ }
238
+ if (placement === "top" && event.translationY > 0) {
239
+ (0, import_react_native_worklets.scheduleOnRN)(setBounceEnabled, true);
240
+ canDismiss.value = false;
241
+ }
242
+ if (placement === "bottom" && event.translationY < 0 || placement === "top" && event.translationY > 0) {
243
+ return;
244
+ }
245
+ if (canDismiss.value || !isScrollable) {
246
+ translateY.value = event.translationY;
247
+ }
248
+ };
249
+ const onPanGestureHandleUpdate = (event) => {
250
+ canDismiss.value = true;
251
+ if (placement === "bottom" && event.translationY < 0 || placement === "top" && event.translationY > 0) {
252
+ return;
253
+ }
254
+ translateY.value = event.translationY;
255
+ };
256
+ const panGesture = import_react_native_gesture_handler.Gesture.Pan().onUpdate(onPanGestureUpdate).onEnd((event) => (0, import_react_native_worklets.scheduleOnRN)(onPanGestureEnd, event));
257
+ const gesture = import_react_native_gesture_handler.Gesture.Simultaneous(import_react_native_gesture_handler.Gesture.Native(), panGesture);
258
+ const handleGesture = import_react_native_gesture_handler.Gesture.Pan().onUpdate(onPanGestureHandleUpdate).onEnd((event) => (0, import_react_native_worklets.scheduleOnRN)(onPanGestureHandleEnd, event));
259
+ const animatedStyle = (0, import_react_native_reanimated2.useAnimatedStyle)(() => ({
260
+ transform: [{ translateY: translateY.value }],
261
+ zIndex: 100 + props.layer
262
+ }));
263
+ const overlayStyle = (0, import_react_native_reanimated2.useAnimatedStyle)(() => ({
264
+ opacity: opacity.value,
265
+ zIndex: 100 + props.layer,
266
+ backgroundColor: colors.black
267
+ }));
268
+ const edges = (0, import_react3.useMemo)(() => {
269
+ return [placement, "left", "right"];
270
+ }, [placement]);
271
+ const styles = (0, import_react3.useMemo)(
272
+ () => themedStyles3(theme, placement),
273
+ [theme, placement]
274
+ );
275
+ (0, import_react3.useEffect)(() => {
276
+ if (measuredHeight === null || didOpen.current || !props.open) return;
277
+ translateY.value = (0, import_react_native_reanimated2.withSpring)(0, EnterAnimationConfig);
278
+ opacity.value = (0, import_react_native_reanimated2.withSpring)(0.4, EnterAnimationConfig);
279
+ didOpen.current = true;
280
+ }, [measuredHeight, props.open]);
281
+ return /* @__PURE__ */ React.createElement(import_react3.Fragment, null, /* @__PURE__ */ React.createElement(import_react_native_reanimated2.default.View, { style: [import_react_native3.StyleSheet.absoluteFill, overlayStyle] }, /* @__PURE__ */ React.createElement(import_react_native3.Pressable, { onPress: animateOut, style: import_react_native3.StyleSheet.absoluteFillObject })), /* @__PURE__ */ React.createElement(import_react_native_gesture_handler.GestureDetector, { gesture }, /* @__PURE__ */ React.createElement(import_react_native_reanimated2.default.View, { style: [styles.container, animatedStyle] }, /* @__PURE__ */ React.createElement(
282
+ import_safe_area_view.SafeAreaView,
283
+ {
284
+ edges,
285
+ style: styles.safeAreaView,
286
+ onLayout
287
+ },
288
+ placement === "bottom" ? /* @__PURE__ */ React.createElement(import_react_native_gesture_handler.GestureDetector, { gesture: handleGesture }, /* @__PURE__ */ React.createElement(FlyoutHandle, { placement })) : null,
289
+ /* @__PURE__ */ React.createElement(
290
+ import_react_native_reanimated2.default.ScrollView,
291
+ {
292
+ onLayout: onLayoutScrollview,
293
+ onContentSizeChange,
294
+ onScroll,
295
+ scrollEventThrottle: 16,
296
+ scrollEnabled: isScrollable,
297
+ bounces: isScrollable && bounceEnabled,
298
+ style: styles.scrollview,
299
+ stickyHeaderIndices: props.title ? StickyHeaderIndices : void 0,
300
+ showsHorizontalScrollIndicator: false,
301
+ showsVerticalScrollIndicator: false,
302
+ ...AndroidOverScroll
303
+ },
304
+ props.title && /* @__PURE__ */ React.createElement(FlyoutTitle, { title: props.title }),
305
+ /* @__PURE__ */ React.createElement(import_view3.View, { padding: theme.spacing.sm }, children)
306
+ ),
307
+ placement === "top" ? /* @__PURE__ */ React.createElement(import_react_native_gesture_handler.GestureDetector, { gesture: handleGesture }, /* @__PURE__ */ React.createElement(FlyoutHandle, { placement })) : null
308
+ ))));
309
+ });
310
+ var themedStyles3 = function(theme, placement) {
311
+ return import_react_native3.StyleSheet.create({
312
+ container: {
313
+ position: "absolute",
314
+ [placement]: 0,
315
+ left: 0,
316
+ right: 0,
317
+ backgroundColor: theme.colors.background.secondary,
318
+ borderTopLeftRadius: placement === "bottom" ? theme.radii.xl : 0,
319
+ borderTopRightRadius: placement === "bottom" ? theme.radii.xl : 0,
320
+ borderBottomLeftRadius: placement === "top" ? theme.radii.xl : 0,
321
+ borderBottomRightRadius: placement === "top" ? theme.radii.xl : 0
322
+ },
323
+ scrollview: {
324
+ borderTopLeftRadius: placement === "bottom" ? theme.radii.xl : 0,
325
+ borderTopRightRadius: placement === "bottom" ? theme.radii.xl : 0,
326
+ borderBottomLeftRadius: placement === "top" ? theme.radii.xl : 0,
327
+ borderBottomRightRadius: placement === "top" ? theme.radii.xl : 0
328
+ },
329
+ safeAreaView: { maxHeight: MaxHeight }
330
+ });
331
+ };
332
+ // Annotate the CommonJS export names for ESM import in node:
333
+ 0 && (module.exports = {
334
+ Flyout
335
+ });
336
+ //# sourceMappingURL=index.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/components/flyout.tsx","../src/components/flyout-handle.tsx","../src/components/flyout-title.tsx"],"sourcesContent":["export * from \"./components\";\r\nexport * from \"./types\";\r\n","import { useEventCallback } from \"@impulse-ui-native/core\";\r\nimport { SafeAreaView } from \"@impulse-ui-native/safe-area-view\";\r\nimport { AppTheme, useColors, useTheme } from \"@impulse-ui-native/theme\";\r\nimport { View } from \"@impulse-ui-native/view\";\r\nimport {\r\n Fragment,\r\n memo,\r\n PropsWithChildren,\r\n useEffect,\r\n useMemo,\r\n useRef,\r\n useState,\r\n} from \"react\";\r\nimport {\r\n Dimensions,\r\n LayoutChangeEvent,\r\n Platform,\r\n Pressable,\r\n StyleSheet,\r\n} from \"react-native\";\r\nimport {\r\n Gesture,\r\n GestureDetector,\r\n GestureStateChangeEvent,\r\n GestureUpdateEvent,\r\n PanGestureHandlerEventPayload,\r\n} from \"react-native-gesture-handler\";\r\nimport Animated, {\r\n Easing,\r\n useAnimatedScrollHandler,\r\n useAnimatedStyle,\r\n useSharedValue,\r\n withSpring,\r\n withTiming,\r\n} from \"react-native-reanimated\";\r\nimport { Edge } from \"react-native-safe-area-context\";\r\nimport { scheduleOnRN } from \"react-native-worklets\";\r\nimport { FlyoutProps } from \"../types\";\r\nimport { FlyoutHandle } from \"./flyout-handle\";\r\nimport { FlyoutTitle } from \"./flyout-title\";\r\n\r\nconst EnterAnimationConfig = {\r\n damping: 50,\r\n stiffness: 300,\r\n mass: 1,\r\n overshootClamping: true,\r\n};\r\n\r\nconst ExitAnimationConfig = {\r\n duration: 150,\r\n easing: Easing.in(Easing.quad),\r\n};\r\n\r\nconst StickyHeaderIndices = [0];\r\nconst ScreenHeight = Dimensions.get(\"screen\").height;\r\nconst MaxHeight = ScreenHeight * 0.9;\r\n\r\nconst AndroidOverScroll =\r\n Platform.OS === \"android\" ? { overScrollMode: \"always\" as const } : {};\r\n\r\nexport const Flyout = memo(function Flyout({\r\n children,\r\n placement = \"bottom\",\r\n ...props\r\n}: PropsWithChildren<FlyoutProps>) {\r\n const colors = useColors();\r\n const theme = useTheme();\r\n\r\n const [measuredHeight, setMeasuredHeight] = useState<number | null>(null);\r\n const [bounceEnabled, setBounceEnabled] = useState(placement !== \"bottom\");\r\n const [viewportHeight, setViewportHeight] = useState(0);\r\n const [contentHeight, setContentHeight] = useState(0);\r\n\r\n const didOpen = useRef(false);\r\n const canDismiss = useSharedValue(placement === \"bottom\");\r\n const scrollY = useSharedValue(0);\r\n const maxScrollY = useSharedValue(0);\r\n\r\n const translateY = useSharedValue(\r\n placement === \"top\" ? -ScreenHeight : ScreenHeight\r\n );\r\n const opacity = useSharedValue(0);\r\n\r\n const isScrollable = useMemo(\r\n () => contentHeight > viewportHeight,\r\n [contentHeight, viewportHeight]\r\n );\r\n\r\n const onScroll = useAnimatedScrollHandler({\r\n onScroll(event) {\r\n scrollY.value = event.contentOffset.y;\r\n maxScrollY.value = Math.max(\r\n 0,\r\n event.contentSize.height - event.layoutMeasurement.height\r\n );\r\n },\r\n onMomentumEnd(event) {\r\n if (placement === \"bottom\" && event.contentOffset.y <= 0) {\r\n scheduleOnRN(setBounceEnabled, false);\r\n canDismiss.value = true;\r\n }\r\n\r\n if (placement === \"top\" && scrollY.value >= maxScrollY.value - 1) {\r\n scheduleOnRN(setBounceEnabled, false);\r\n canDismiss.value = true;\r\n }\r\n },\r\n });\r\n\r\n const onLayout = useEventCallback((event: LayoutChangeEvent) => {\r\n if (!didOpen.current && measuredHeight === null) {\r\n const rawHeight = event.nativeEvent.layout.height;\r\n const clampedHeight = Math.min(rawHeight, MaxHeight);\r\n setMeasuredHeight(clampedHeight);\r\n translateY.value = placement === \"top\" ? -clampedHeight : clampedHeight;\r\n }\r\n });\r\n\r\n const onLayoutScrollview = useEventCallback((event: LayoutChangeEvent) => {\r\n setViewportHeight(event.nativeEvent.layout.height);\r\n });\r\n\r\n const onContentSizeChange = useEventCallback(\r\n (_contentWidth: number, contentHeight: number) => {\r\n setContentHeight(contentHeight);\r\n }\r\n );\r\n\r\n const animateOut = useEventCallback(() => {\r\n if (measuredHeight) {\r\n const target = placement === \"top\" ? -measuredHeight : measuredHeight;\r\n\r\n translateY.value = withTiming(target, ExitAnimationConfig, (finished) => {\r\n if (finished && props.onCloseFinished) {\r\n scheduleOnRN(props.onCloseFinished, props.id);\r\n }\r\n });\r\n\r\n opacity.value = withTiming(0, ExitAnimationConfig);\r\n didOpen.current = false;\r\n }\r\n });\r\n\r\n const onPanGestureEnd = useEventCallback(\r\n (event: GestureStateChangeEvent<PanGestureHandlerEventPayload>) => {\r\n if (!measuredHeight) return;\r\n\r\n let shouldClose = false;\r\n\r\n if (placement === \"bottom\") {\r\n shouldClose =\r\n event.translationY > measuredHeight * 0.5 || event.velocityY > 1500;\r\n }\r\n\r\n if (placement === \"top\") {\r\n shouldClose =\r\n event.translationY < -measuredHeight * 0.5 || event.velocityY < -1500;\r\n }\r\n\r\n if (shouldClose && (canDismiss.value || !isScrollable)) {\r\n animateOut();\r\n } else {\r\n translateY.value = withSpring(0, EnterAnimationConfig);\r\n opacity.value = withSpring(0.4, EnterAnimationConfig);\r\n }\r\n }\r\n );\r\n\r\n const onPanGestureHandleEnd = useEventCallback(\r\n (event: GestureStateChangeEvent<PanGestureHandlerEventPayload>) => {\r\n onPanGestureEnd(event);\r\n\r\n if (placement === \"bottom\" && scrollY.value > 0) {\r\n canDismiss.value = false;\r\n }\r\n\r\n if (placement === \"top\" && scrollY.value < maxScrollY.value - 1) {\r\n canDismiss.value = false;\r\n }\r\n }\r\n );\r\n\r\n const onPanGestureUpdate = (\r\n event: GestureUpdateEvent<PanGestureHandlerEventPayload>\r\n ) => {\r\n if (placement === \"bottom\" && event.translationY < 0) {\r\n scheduleOnRN(setBounceEnabled, true);\r\n canDismiss.value = false;\r\n }\r\n\r\n if (placement === \"top\" && event.translationY > 0) {\r\n scheduleOnRN(setBounceEnabled, true);\r\n canDismiss.value = false;\r\n }\r\n\r\n if (\r\n (placement === \"bottom\" && event.translationY < 0) ||\r\n (placement === \"top\" && event.translationY > 0)\r\n ) {\r\n return;\r\n }\r\n\r\n if (canDismiss.value || !isScrollable) {\r\n translateY.value = event.translationY;\r\n }\r\n };\r\n\r\n const onPanGestureHandleUpdate = (\r\n event: GestureUpdateEvent<PanGestureHandlerEventPayload>\r\n ) => {\r\n canDismiss.value = true;\r\n\r\n if (\r\n (placement === \"bottom\" && event.translationY < 0) ||\r\n (placement === \"top\" && event.translationY > 0)\r\n ) {\r\n return;\r\n }\r\n\r\n translateY.value = event.translationY;\r\n };\r\n\r\n const panGesture = Gesture.Pan()\r\n .onUpdate(onPanGestureUpdate)\r\n .onEnd((event) => scheduleOnRN(onPanGestureEnd, event));\r\n\r\n const gesture = Gesture.Simultaneous(Gesture.Native(), panGesture);\r\n\r\n const handleGesture = Gesture.Pan()\r\n .onUpdate(onPanGestureHandleUpdate)\r\n .onEnd((event) => scheduleOnRN(onPanGestureHandleEnd, event));\r\n\r\n const animatedStyle = useAnimatedStyle(() => ({\r\n transform: [{ translateY: translateY.value }],\r\n zIndex: 100 + props.layer,\r\n }));\r\n\r\n const overlayStyle = useAnimatedStyle(() => ({\r\n opacity: opacity.value,\r\n zIndex: 100 + props.layer,\r\n backgroundColor: colors.black,\r\n }));\r\n\r\n const edges = useMemo<Edge[]>(() => {\r\n return [placement, \"left\", \"right\"];\r\n }, [placement]);\r\n\r\n const styles = useMemo(\r\n () => themedStyles(theme, placement),\r\n [theme, placement]\r\n );\r\n\r\n useEffect(() => {\r\n if (measuredHeight === null || didOpen.current || !props.open) return;\r\n\r\n translateY.value = withSpring(0, EnterAnimationConfig);\r\n opacity.value = withSpring(0.4, EnterAnimationConfig);\r\n didOpen.current = true;\r\n }, [measuredHeight, props.open]);\r\n\r\n return (\r\n <Fragment>\r\n <Animated.View style={[StyleSheet.absoluteFill, overlayStyle]}>\r\n <Pressable onPress={animateOut} style={StyleSheet.absoluteFillObject} />\r\n </Animated.View>\r\n <GestureDetector gesture={gesture}>\r\n <Animated.View style={[styles.container, animatedStyle]}>\r\n <SafeAreaView\r\n edges={edges}\r\n style={styles.safeAreaView}\r\n onLayout={onLayout}\r\n >\r\n {placement === \"bottom\" ? (\r\n <GestureDetector gesture={handleGesture}>\r\n <FlyoutHandle placement={placement} />\r\n </GestureDetector>\r\n ) : null}\r\n\r\n <Animated.ScrollView\r\n onLayout={onLayoutScrollview}\r\n onContentSizeChange={onContentSizeChange}\r\n onScroll={onScroll}\r\n scrollEventThrottle={16}\r\n scrollEnabled={isScrollable}\r\n bounces={isScrollable && bounceEnabled}\r\n style={styles.scrollview}\r\n stickyHeaderIndices={\r\n props.title ? StickyHeaderIndices : undefined\r\n }\r\n showsHorizontalScrollIndicator={false}\r\n showsVerticalScrollIndicator={false}\r\n {...AndroidOverScroll}\r\n >\r\n {props.title && <FlyoutTitle title={props.title} />}\r\n <View padding={theme.spacing.sm}>{children}</View>\r\n </Animated.ScrollView>\r\n\r\n {placement === \"top\" ? (\r\n <GestureDetector gesture={handleGesture}>\r\n <FlyoutHandle placement={placement} />\r\n </GestureDetector>\r\n ) : null}\r\n </SafeAreaView>\r\n </Animated.View>\r\n </GestureDetector>\r\n </Fragment>\r\n );\r\n});\r\n\r\nconst themedStyles = function (theme: AppTheme, placement: \"top\" | \"bottom\") {\r\n return StyleSheet.create({\r\n container: {\r\n position: \"absolute\",\r\n [placement]: 0,\r\n left: 0,\r\n right: 0,\r\n backgroundColor: theme.colors.background.secondary,\r\n borderTopLeftRadius: placement === \"bottom\" ? theme.radii.xl : 0,\r\n borderTopRightRadius: placement === \"bottom\" ? theme.radii.xl : 0,\r\n borderBottomLeftRadius: placement === \"top\" ? theme.radii.xl : 0,\r\n borderBottomRightRadius: placement === \"top\" ? theme.radii.xl : 0,\r\n },\r\n scrollview: {\r\n borderTopLeftRadius: placement === \"bottom\" ? theme.radii.xl : 0,\r\n borderTopRightRadius: placement === \"bottom\" ? theme.radii.xl : 0,\r\n borderBottomLeftRadius: placement === \"top\" ? theme.radii.xl : 0,\r\n borderBottomRightRadius: placement === \"top\" ? theme.radii.xl : 0,\r\n },\r\n safeAreaView: { maxHeight: MaxHeight },\r\n });\r\n};\r\n","import { AppTheme, useTheme } from \"@impulse-ui-native/theme\";\r\nimport { View } from \"@impulse-ui-native/view\";\r\nimport { memo, useMemo } from \"react\";\r\nimport { StyleSheet } from \"react-native\";\r\nimport Animated from \"react-native-reanimated\";\r\n\r\nconst FlyoutHandleHeight = 32;\r\n\r\ninterface FlyoutHandleProps {\r\n placement: \"top\" | \"bottom\";\r\n}\r\n\r\nexport const FlyoutHandle = memo(function FlyoutHandle(\r\n props: FlyoutHandleProps\r\n) {\r\n const theme = useTheme();\r\n\r\n const styles = useMemo(\r\n () => themedStyles(theme, props.placement),\r\n [theme, props.placement]\r\n );\r\n\r\n return (\r\n <Animated.View style={styles.flyoutHandleContainer}>\r\n <View style={styles.flyoutHandle} />\r\n </Animated.View>\r\n );\r\n});\r\n\r\nconst themedStyles = function (theme: AppTheme, placement: \"top\" | \"bottom\") {\r\n return StyleSheet.create({\r\n flyoutHandle: {\r\n alignSelf: \"center\",\r\n backgroundColor: theme.colors.background.primary,\r\n width: \"25%\",\r\n height: 6,\r\n borderRadius: theme.radii.round,\r\n },\r\n flyoutHandleContainer: {\r\n position: \"absolute\",\r\n top: placement === \"bottom\" ? -FlyoutHandleHeight : undefined,\r\n bottom: placement === \"top\" ? -FlyoutHandleHeight : undefined,\r\n width: \"100%\",\r\n justifyContent: \"center\",\r\n alignItems: \"center\",\r\n height: FlyoutHandleHeight,\r\n },\r\n });\r\n};\r\n","import { AppTheme, useTheme } from \"@impulse-ui-native/theme\";\r\nimport { Typography } from \"@impulse-ui-native/typography\";\r\nimport { View } from \"@impulse-ui-native/view\";\r\nimport { memo, ReactNode, useMemo } from \"react\";\r\nimport { StyleSheet } from \"react-native\";\r\n\r\ninterface FlyoutTitleProps {\r\n title?: ReactNode | string;\r\n placement?: \"top\" | \"bottom\";\r\n}\r\n\r\nexport const FlyoutTitle = memo(function FlyoutTitle(props: FlyoutTitleProps) {\r\n const theme = useTheme();\r\n\r\n const styles = useMemo(\r\n () => themedStyles(theme, props.placement),\r\n [theme, props.placement]\r\n );\r\n\r\n const title = useMemo(() => {\r\n if (typeof props.title === \"string\") {\r\n return <Typography.Title3>{props.title}</Typography.Title3>;\r\n }\r\n\r\n return props.title;\r\n }, [props.title]);\r\n\r\n if (!props.title) {\r\n return null;\r\n }\r\n\r\n return <View style={styles.container}>{title}</View>;\r\n});\r\n\r\nconst themedStyles = function (theme: AppTheme, placement?: \"top\" | \"bottom\") {\r\n return StyleSheet.create({\r\n container: {\r\n borderTopLeftRadius: placement === \"bottom\" ? theme.radii.xl : undefined,\r\n borderTopRightRadius: placement === \"bottom\" ? theme.radii.xl : undefined,\r\n backgroundColor: theme.colors.background.secondary,\r\n padding: theme.spacing.mxs,\r\n alignItems: \"center\",\r\n },\r\n });\r\n};\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kBAAiC;AACjC,4BAA6B;AAC7B,IAAAA,gBAA8C;AAC9C,IAAAC,eAAqB;AACrB,IAAAC,gBAQO;AACP,IAAAC,uBAMO;AACP,0CAMO;AACP,IAAAC,kCAOO;AAEP,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O;AAAA,IACvB,WAAW;AAAA,MACT,UAAU;AAAA,MACV,CAAC,SAAS,GAAG;AAAA,MACb,MAAM;AAAA,MACN,OAAO;AAAA,MACP,iBAAiB,MAAM,OAAO,WAAW;AAAA,MACzC,qBAAqB,cAAc,WAAW,MAAM,MAAM,KAAK;AAAA,MAC/D,sBAAsB,cAAc,WAAW,MAAM,MAAM,KAAK;AAAA,MAChE,wBAAwB,cAAc,QAAQ,MAAM,MAAM,KAAK;AAAA,MAC/D,yBAAyB,cAAc,QAAQ,MAAM,MAAM,KAAK;AAAA,IAClE;AAAA,IACA,YAAY;AAAA,MACV,qBAAqB,cAAc,WAAW,MAAM,MAAM,KAAK;AAAA,MAC/D,sBAAsB,cAAc,WAAW,MAAM,MAAM,KAAK;AAAA,MAChE,wBAAwB,cAAc,QAAQ,MAAM,MAAM,KAAK;AAAA,MAC/D,yBAAyB,cAAc,QAAQ,MAAM,MAAM,KAAK;AAAA,IAClE;AAAA,IACA,cAAc,EAAE,WAAW,UAAU;AAAA,EACvC,CAAC;AACH;","names":["import_theme","import_view","import_react","import_react_native","import_react_native_reanimated","FlyoutHandle","Animated","import_theme","import_view","import_react","import_react_native","FlyoutTitle","themedStyles","Flyout","contentHeight","themedStyles","Animated"]}
@@ -0,0 +1,12 @@
1
+ import * as react from 'react';
2
+ import { PropsWithChildren } from 'react';
3
+ import { LayerComponentBaseProps } from '@impulse-ui-native/layer-manager-types';
4
+
5
+ interface FlyoutProps extends LayerComponentBaseProps {
6
+ open?: boolean;
7
+ placement?: "top" | "bottom";
8
+ }
9
+
10
+ declare const Flyout: react.NamedExoticComponent<PropsWithChildren<FlyoutProps>>;
11
+
12
+ export { Flyout, type FlyoutProps };
@@ -0,0 +1,12 @@
1
+ import * as react from 'react';
2
+ import { PropsWithChildren } from 'react';
3
+ import { LayerComponentBaseProps } from '@impulse-ui-native/layer-manager-types';
4
+
5
+ interface FlyoutProps extends LayerComponentBaseProps {
6
+ open?: boolean;
7
+ placement?: "top" | "bottom";
8
+ }
9
+
10
+ declare const Flyout: react.NamedExoticComponent<PropsWithChildren<FlyoutProps>>;
11
+
12
+ export { Flyout, type FlyoutProps };
@@ -0,0 +1,321 @@
1
+ // src/components/flyout.tsx
2
+ import { useEventCallback } from "@impulse-ui-native/core";
3
+ import { SafeAreaView } from "@impulse-ui-native/safe-area-view";
4
+ import { useColors, useTheme as useTheme3 } from "@impulse-ui-native/theme";
5
+ import { View as View3 } from "@impulse-ui-native/view";
6
+ import {
7
+ Fragment,
8
+ memo as memo3,
9
+ useEffect,
10
+ useMemo as useMemo3,
11
+ useRef,
12
+ useState
13
+ } from "react";
14
+ import {
15
+ Dimensions,
16
+ Platform,
17
+ Pressable,
18
+ StyleSheet as StyleSheet3
19
+ } from "react-native";
20
+ import {
21
+ Gesture,
22
+ GestureDetector
23
+ } from "react-native-gesture-handler";
24
+ import Animated2, {
25
+ Easing,
26
+ useAnimatedScrollHandler,
27
+ useAnimatedStyle,
28
+ useSharedValue,
29
+ withSpring,
30
+ withTiming
31
+ } from "react-native-reanimated";
32
+ import { scheduleOnRN } from "react-native-worklets";
33
+
34
+ // src/components/flyout-handle.tsx
35
+ import { useTheme } from "@impulse-ui-native/theme";
36
+ import { View } from "@impulse-ui-native/view";
37
+ import { memo, useMemo } from "react";
38
+ import { StyleSheet } from "react-native";
39
+ import Animated from "react-native-reanimated";
40
+ var FlyoutHandleHeight = 32;
41
+ var FlyoutHandle = memo(function FlyoutHandle2(props) {
42
+ const theme = useTheme();
43
+ const styles = useMemo(
44
+ () => themedStyles(theme, props.placement),
45
+ [theme, props.placement]
46
+ );
47
+ return /* @__PURE__ */ React.createElement(Animated.View, { style: styles.flyoutHandleContainer }, /* @__PURE__ */ React.createElement(View, { style: styles.flyoutHandle }));
48
+ });
49
+ var themedStyles = function(theme, placement) {
50
+ return StyleSheet.create({
51
+ flyoutHandle: {
52
+ alignSelf: "center",
53
+ backgroundColor: theme.colors.background.primary,
54
+ width: "25%",
55
+ height: 6,
56
+ borderRadius: theme.radii.round
57
+ },
58
+ flyoutHandleContainer: {
59
+ position: "absolute",
60
+ top: placement === "bottom" ? -FlyoutHandleHeight : void 0,
61
+ bottom: placement === "top" ? -FlyoutHandleHeight : void 0,
62
+ width: "100%",
63
+ justifyContent: "center",
64
+ alignItems: "center",
65
+ height: FlyoutHandleHeight
66
+ }
67
+ });
68
+ };
69
+
70
+ // src/components/flyout-title.tsx
71
+ import { useTheme as useTheme2 } from "@impulse-ui-native/theme";
72
+ import { Typography } from "@impulse-ui-native/typography";
73
+ import { View as View2 } from "@impulse-ui-native/view";
74
+ import { memo as memo2, useMemo as useMemo2 } from "react";
75
+ import { StyleSheet as StyleSheet2 } from "react-native";
76
+ var FlyoutTitle = memo2(function FlyoutTitle2(props) {
77
+ const theme = useTheme2();
78
+ const styles = useMemo2(
79
+ () => themedStyles2(theme, props.placement),
80
+ [theme, props.placement]
81
+ );
82
+ const title = useMemo2(() => {
83
+ if (typeof props.title === "string") {
84
+ return /* @__PURE__ */ React.createElement(Typography.Title3, null, props.title);
85
+ }
86
+ return props.title;
87
+ }, [props.title]);
88
+ if (!props.title) {
89
+ return null;
90
+ }
91
+ return /* @__PURE__ */ React.createElement(View2, { style: styles.container }, title);
92
+ });
93
+ var themedStyles2 = function(theme, placement) {
94
+ return StyleSheet2.create({
95
+ container: {
96
+ borderTopLeftRadius: placement === "bottom" ? theme.radii.xl : void 0,
97
+ borderTopRightRadius: placement === "bottom" ? theme.radii.xl : void 0,
98
+ backgroundColor: theme.colors.background.secondary,
99
+ padding: theme.spacing.mxs,
100
+ alignItems: "center"
101
+ }
102
+ });
103
+ };
104
+
105
+ // src/components/flyout.tsx
106
+ var EnterAnimationConfig = {
107
+ damping: 50,
108
+ stiffness: 300,
109
+ mass: 1,
110
+ overshootClamping: true
111
+ };
112
+ var ExitAnimationConfig = {
113
+ duration: 150,
114
+ easing: Easing.in(Easing.quad)
115
+ };
116
+ var StickyHeaderIndices = [0];
117
+ var ScreenHeight = Dimensions.get("screen").height;
118
+ var MaxHeight = ScreenHeight * 0.9;
119
+ var AndroidOverScroll = Platform.OS === "android" ? { overScrollMode: "always" } : {};
120
+ var Flyout = memo3(function Flyout2({
121
+ children,
122
+ placement = "bottom",
123
+ ...props
124
+ }) {
125
+ const colors = useColors();
126
+ const theme = useTheme3();
127
+ const [measuredHeight, setMeasuredHeight] = useState(null);
128
+ const [bounceEnabled, setBounceEnabled] = useState(placement !== "bottom");
129
+ const [viewportHeight, setViewportHeight] = useState(0);
130
+ const [contentHeight, setContentHeight] = useState(0);
131
+ const didOpen = useRef(false);
132
+ const canDismiss = useSharedValue(placement === "bottom");
133
+ const scrollY = useSharedValue(0);
134
+ const maxScrollY = useSharedValue(0);
135
+ const translateY = useSharedValue(
136
+ placement === "top" ? -ScreenHeight : ScreenHeight
137
+ );
138
+ const opacity = useSharedValue(0);
139
+ const isScrollable = useMemo3(
140
+ () => contentHeight > viewportHeight,
141
+ [contentHeight, viewportHeight]
142
+ );
143
+ const onScroll = useAnimatedScrollHandler({
144
+ onScroll(event) {
145
+ scrollY.value = event.contentOffset.y;
146
+ maxScrollY.value = Math.max(
147
+ 0,
148
+ event.contentSize.height - event.layoutMeasurement.height
149
+ );
150
+ },
151
+ onMomentumEnd(event) {
152
+ if (placement === "bottom" && event.contentOffset.y <= 0) {
153
+ scheduleOnRN(setBounceEnabled, false);
154
+ canDismiss.value = true;
155
+ }
156
+ if (placement === "top" && scrollY.value >= maxScrollY.value - 1) {
157
+ scheduleOnRN(setBounceEnabled, false);
158
+ canDismiss.value = true;
159
+ }
160
+ }
161
+ });
162
+ const onLayout = useEventCallback((event) => {
163
+ if (!didOpen.current && measuredHeight === null) {
164
+ const rawHeight = event.nativeEvent.layout.height;
165
+ const clampedHeight = Math.min(rawHeight, MaxHeight);
166
+ setMeasuredHeight(clampedHeight);
167
+ translateY.value = placement === "top" ? -clampedHeight : clampedHeight;
168
+ }
169
+ });
170
+ const onLayoutScrollview = useEventCallback((event) => {
171
+ setViewportHeight(event.nativeEvent.layout.height);
172
+ });
173
+ const onContentSizeChange = useEventCallback(
174
+ (_contentWidth, contentHeight2) => {
175
+ setContentHeight(contentHeight2);
176
+ }
177
+ );
178
+ const animateOut = useEventCallback(() => {
179
+ if (measuredHeight) {
180
+ const target = placement === "top" ? -measuredHeight : measuredHeight;
181
+ translateY.value = withTiming(target, ExitAnimationConfig, (finished) => {
182
+ if (finished && props.onCloseFinished) {
183
+ scheduleOnRN(props.onCloseFinished, props.id);
184
+ }
185
+ });
186
+ opacity.value = withTiming(0, ExitAnimationConfig);
187
+ didOpen.current = false;
188
+ }
189
+ });
190
+ const onPanGestureEnd = useEventCallback(
191
+ (event) => {
192
+ if (!measuredHeight) return;
193
+ let shouldClose = false;
194
+ if (placement === "bottom") {
195
+ shouldClose = event.translationY > measuredHeight * 0.5 || event.velocityY > 1500;
196
+ }
197
+ if (placement === "top") {
198
+ shouldClose = event.translationY < -measuredHeight * 0.5 || event.velocityY < -1500;
199
+ }
200
+ if (shouldClose && (canDismiss.value || !isScrollable)) {
201
+ animateOut();
202
+ } else {
203
+ translateY.value = withSpring(0, EnterAnimationConfig);
204
+ opacity.value = withSpring(0.4, EnterAnimationConfig);
205
+ }
206
+ }
207
+ );
208
+ const onPanGestureHandleEnd = useEventCallback(
209
+ (event) => {
210
+ onPanGestureEnd(event);
211
+ if (placement === "bottom" && scrollY.value > 0) {
212
+ canDismiss.value = false;
213
+ }
214
+ if (placement === "top" && scrollY.value < maxScrollY.value - 1) {
215
+ canDismiss.value = false;
216
+ }
217
+ }
218
+ );
219
+ const onPanGestureUpdate = (event) => {
220
+ if (placement === "bottom" && event.translationY < 0) {
221
+ scheduleOnRN(setBounceEnabled, true);
222
+ canDismiss.value = false;
223
+ }
224
+ if (placement === "top" && event.translationY > 0) {
225
+ scheduleOnRN(setBounceEnabled, true);
226
+ canDismiss.value = false;
227
+ }
228
+ if (placement === "bottom" && event.translationY < 0 || placement === "top" && event.translationY > 0) {
229
+ return;
230
+ }
231
+ if (canDismiss.value || !isScrollable) {
232
+ translateY.value = event.translationY;
233
+ }
234
+ };
235
+ const onPanGestureHandleUpdate = (event) => {
236
+ canDismiss.value = true;
237
+ if (placement === "bottom" && event.translationY < 0 || placement === "top" && event.translationY > 0) {
238
+ return;
239
+ }
240
+ translateY.value = event.translationY;
241
+ };
242
+ const panGesture = Gesture.Pan().onUpdate(onPanGestureUpdate).onEnd((event) => scheduleOnRN(onPanGestureEnd, event));
243
+ const gesture = Gesture.Simultaneous(Gesture.Native(), panGesture);
244
+ const handleGesture = Gesture.Pan().onUpdate(onPanGestureHandleUpdate).onEnd((event) => scheduleOnRN(onPanGestureHandleEnd, event));
245
+ const animatedStyle = useAnimatedStyle(() => ({
246
+ transform: [{ translateY: translateY.value }],
247
+ zIndex: 100 + props.layer
248
+ }));
249
+ const overlayStyle = useAnimatedStyle(() => ({
250
+ opacity: opacity.value,
251
+ zIndex: 100 + props.layer,
252
+ backgroundColor: colors.black
253
+ }));
254
+ const edges = useMemo3(() => {
255
+ return [placement, "left", "right"];
256
+ }, [placement]);
257
+ const styles = useMemo3(
258
+ () => themedStyles3(theme, placement),
259
+ [theme, placement]
260
+ );
261
+ useEffect(() => {
262
+ if (measuredHeight === null || didOpen.current || !props.open) return;
263
+ translateY.value = withSpring(0, EnterAnimationConfig);
264
+ opacity.value = withSpring(0.4, EnterAnimationConfig);
265
+ didOpen.current = true;
266
+ }, [measuredHeight, props.open]);
267
+ return /* @__PURE__ */ React.createElement(Fragment, null, /* @__PURE__ */ React.createElement(Animated2.View, { style: [StyleSheet3.absoluteFill, overlayStyle] }, /* @__PURE__ */ React.createElement(Pressable, { onPress: animateOut, style: StyleSheet3.absoluteFillObject })), /* @__PURE__ */ React.createElement(GestureDetector, { gesture }, /* @__PURE__ */ React.createElement(Animated2.View, { style: [styles.container, animatedStyle] }, /* @__PURE__ */ React.createElement(
268
+ SafeAreaView,
269
+ {
270
+ edges,
271
+ style: styles.safeAreaView,
272
+ onLayout
273
+ },
274
+ placement === "bottom" ? /* @__PURE__ */ React.createElement(GestureDetector, { gesture: handleGesture }, /* @__PURE__ */ React.createElement(FlyoutHandle, { placement })) : null,
275
+ /* @__PURE__ */ React.createElement(
276
+ Animated2.ScrollView,
277
+ {
278
+ onLayout: onLayoutScrollview,
279
+ onContentSizeChange,
280
+ onScroll,
281
+ scrollEventThrottle: 16,
282
+ scrollEnabled: isScrollable,
283
+ bounces: isScrollable && bounceEnabled,
284
+ style: styles.scrollview,
285
+ stickyHeaderIndices: props.title ? StickyHeaderIndices : void 0,
286
+ showsHorizontalScrollIndicator: false,
287
+ showsVerticalScrollIndicator: false,
288
+ ...AndroidOverScroll
289
+ },
290
+ props.title && /* @__PURE__ */ React.createElement(FlyoutTitle, { title: props.title }),
291
+ /* @__PURE__ */ React.createElement(View3, { padding: theme.spacing.sm }, children)
292
+ ),
293
+ placement === "top" ? /* @__PURE__ */ React.createElement(GestureDetector, { gesture: handleGesture }, /* @__PURE__ */ React.createElement(FlyoutHandle, { placement })) : null
294
+ ))));
295
+ });
296
+ var themedStyles3 = function(theme, placement) {
297
+ return StyleSheet3.create({
298
+ container: {
299
+ position: "absolute",
300
+ [placement]: 0,
301
+ left: 0,
302
+ right: 0,
303
+ backgroundColor: theme.colors.background.secondary,
304
+ borderTopLeftRadius: placement === "bottom" ? theme.radii.xl : 0,
305
+ borderTopRightRadius: placement === "bottom" ? theme.radii.xl : 0,
306
+ borderBottomLeftRadius: placement === "top" ? theme.radii.xl : 0,
307
+ borderBottomRightRadius: placement === "top" ? theme.radii.xl : 0
308
+ },
309
+ scrollview: {
310
+ borderTopLeftRadius: placement === "bottom" ? theme.radii.xl : 0,
311
+ borderTopRightRadius: placement === "bottom" ? theme.radii.xl : 0,
312
+ borderBottomLeftRadius: placement === "top" ? theme.radii.xl : 0,
313
+ borderBottomRightRadius: placement === "top" ? theme.radii.xl : 0
314
+ },
315
+ safeAreaView: { maxHeight: MaxHeight }
316
+ });
317
+ };
318
+ export {
319
+ Flyout
320
+ };
321
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/flyout.tsx","../src/components/flyout-handle.tsx","../src/components/flyout-title.tsx"],"sourcesContent":["import { useEventCallback } from \"@impulse-ui-native/core\";\r\nimport { SafeAreaView } from \"@impulse-ui-native/safe-area-view\";\r\nimport { AppTheme, useColors, useTheme } from \"@impulse-ui-native/theme\";\r\nimport { View } from \"@impulse-ui-native/view\";\r\nimport {\r\n Fragment,\r\n memo,\r\n PropsWithChildren,\r\n useEffect,\r\n useMemo,\r\n useRef,\r\n useState,\r\n} from \"react\";\r\nimport {\r\n Dimensions,\r\n LayoutChangeEvent,\r\n Platform,\r\n Pressable,\r\n StyleSheet,\r\n} from \"react-native\";\r\nimport {\r\n Gesture,\r\n GestureDetector,\r\n GestureStateChangeEvent,\r\n GestureUpdateEvent,\r\n PanGestureHandlerEventPayload,\r\n} from \"react-native-gesture-handler\";\r\nimport Animated, {\r\n Easing,\r\n useAnimatedScrollHandler,\r\n useAnimatedStyle,\r\n useSharedValue,\r\n withSpring,\r\n withTiming,\r\n} from \"react-native-reanimated\";\r\nimport { Edge } from \"react-native-safe-area-context\";\r\nimport { scheduleOnRN } from \"react-native-worklets\";\r\nimport { FlyoutProps } from \"../types\";\r\nimport { FlyoutHandle } from \"./flyout-handle\";\r\nimport { FlyoutTitle } from \"./flyout-title\";\r\n\r\nconst EnterAnimationConfig = {\r\n damping: 50,\r\n stiffness: 300,\r\n mass: 1,\r\n overshootClamping: true,\r\n};\r\n\r\nconst ExitAnimationConfig = {\r\n duration: 150,\r\n easing: Easing.in(Easing.quad),\r\n};\r\n\r\nconst StickyHeaderIndices = [0];\r\nconst ScreenHeight = Dimensions.get(\"screen\").height;\r\nconst MaxHeight = ScreenHeight * 0.9;\r\n\r\nconst AndroidOverScroll =\r\n Platform.OS === \"android\" ? { overScrollMode: \"always\" as const } : {};\r\n\r\nexport const Flyout = memo(function Flyout({\r\n children,\r\n placement = \"bottom\",\r\n ...props\r\n}: PropsWithChildren<FlyoutProps>) {\r\n const colors = useColors();\r\n const theme = useTheme();\r\n\r\n const [measuredHeight, setMeasuredHeight] = useState<number | null>(null);\r\n const [bounceEnabled, setBounceEnabled] = useState(placement !== \"bottom\");\r\n const [viewportHeight, setViewportHeight] = useState(0);\r\n const [contentHeight, setContentHeight] = useState(0);\r\n\r\n const didOpen = useRef(false);\r\n const canDismiss = useSharedValue(placement === \"bottom\");\r\n const scrollY = useSharedValue(0);\r\n const maxScrollY = useSharedValue(0);\r\n\r\n const translateY = useSharedValue(\r\n placement === \"top\" ? -ScreenHeight : ScreenHeight\r\n );\r\n const opacity = useSharedValue(0);\r\n\r\n const isScrollable = useMemo(\r\n () => contentHeight > viewportHeight,\r\n [contentHeight, viewportHeight]\r\n );\r\n\r\n const onScroll = useAnimatedScrollHandler({\r\n onScroll(event) {\r\n scrollY.value = event.contentOffset.y;\r\n maxScrollY.value = Math.max(\r\n 0,\r\n event.contentSize.height - event.layoutMeasurement.height\r\n );\r\n },\r\n onMomentumEnd(event) {\r\n if (placement === \"bottom\" && event.contentOffset.y <= 0) {\r\n scheduleOnRN(setBounceEnabled, false);\r\n canDismiss.value = true;\r\n }\r\n\r\n if (placement === \"top\" && scrollY.value >= maxScrollY.value - 1) {\r\n scheduleOnRN(setBounceEnabled, false);\r\n canDismiss.value = true;\r\n }\r\n },\r\n });\r\n\r\n const onLayout = useEventCallback((event: LayoutChangeEvent) => {\r\n if (!didOpen.current && measuredHeight === null) {\r\n const rawHeight = event.nativeEvent.layout.height;\r\n const clampedHeight = Math.min(rawHeight, MaxHeight);\r\n setMeasuredHeight(clampedHeight);\r\n translateY.value = placement === \"top\" ? -clampedHeight : clampedHeight;\r\n }\r\n });\r\n\r\n const onLayoutScrollview = useEventCallback((event: LayoutChangeEvent) => {\r\n setViewportHeight(event.nativeEvent.layout.height);\r\n });\r\n\r\n const onContentSizeChange = useEventCallback(\r\n (_contentWidth: number, contentHeight: number) => {\r\n setContentHeight(contentHeight);\r\n }\r\n );\r\n\r\n const animateOut = useEventCallback(() => {\r\n if (measuredHeight) {\r\n const target = placement === \"top\" ? -measuredHeight : measuredHeight;\r\n\r\n translateY.value = withTiming(target, ExitAnimationConfig, (finished) => {\r\n if (finished && props.onCloseFinished) {\r\n scheduleOnRN(props.onCloseFinished, props.id);\r\n }\r\n });\r\n\r\n opacity.value = withTiming(0, ExitAnimationConfig);\r\n didOpen.current = false;\r\n }\r\n });\r\n\r\n const onPanGestureEnd = useEventCallback(\r\n (event: GestureStateChangeEvent<PanGestureHandlerEventPayload>) => {\r\n if (!measuredHeight) return;\r\n\r\n let shouldClose = false;\r\n\r\n if (placement === \"bottom\") {\r\n shouldClose =\r\n event.translationY > measuredHeight * 0.5 || event.velocityY > 1500;\r\n }\r\n\r\n if (placement === \"top\") {\r\n shouldClose =\r\n event.translationY < -measuredHeight * 0.5 || event.velocityY < -1500;\r\n }\r\n\r\n if (shouldClose && (canDismiss.value || !isScrollable)) {\r\n animateOut();\r\n } else {\r\n translateY.value = withSpring(0, EnterAnimationConfig);\r\n opacity.value = withSpring(0.4, EnterAnimationConfig);\r\n }\r\n }\r\n );\r\n\r\n const onPanGestureHandleEnd = useEventCallback(\r\n (event: GestureStateChangeEvent<PanGestureHandlerEventPayload>) => {\r\n onPanGestureEnd(event);\r\n\r\n if (placement === \"bottom\" && scrollY.value > 0) {\r\n canDismiss.value = false;\r\n }\r\n\r\n if (placement === \"top\" && scrollY.value < maxScrollY.value - 1) {\r\n canDismiss.value = false;\r\n }\r\n }\r\n );\r\n\r\n const onPanGestureUpdate = (\r\n event: GestureUpdateEvent<PanGestureHandlerEventPayload>\r\n ) => {\r\n if (placement === \"bottom\" && event.translationY < 0) {\r\n scheduleOnRN(setBounceEnabled, true);\r\n canDismiss.value = false;\r\n }\r\n\r\n if (placement === \"top\" && event.translationY > 0) {\r\n scheduleOnRN(setBounceEnabled, true);\r\n canDismiss.value = false;\r\n }\r\n\r\n if (\r\n (placement === \"bottom\" && event.translationY < 0) ||\r\n (placement === \"top\" && event.translationY > 0)\r\n ) {\r\n return;\r\n }\r\n\r\n if (canDismiss.value || !isScrollable) {\r\n translateY.value = event.translationY;\r\n }\r\n };\r\n\r\n const onPanGestureHandleUpdate = (\r\n event: GestureUpdateEvent<PanGestureHandlerEventPayload>\r\n ) => {\r\n canDismiss.value = true;\r\n\r\n if (\r\n (placement === \"bottom\" && event.translationY < 0) ||\r\n (placement === \"top\" && event.translationY > 0)\r\n ) {\r\n return;\r\n }\r\n\r\n translateY.value = event.translationY;\r\n };\r\n\r\n const panGesture = Gesture.Pan()\r\n .onUpdate(onPanGestureUpdate)\r\n .onEnd((event) => scheduleOnRN(onPanGestureEnd, event));\r\n\r\n const gesture = Gesture.Simultaneous(Gesture.Native(), panGesture);\r\n\r\n const handleGesture = Gesture.Pan()\r\n .onUpdate(onPanGestureHandleUpdate)\r\n .onEnd((event) => scheduleOnRN(onPanGestureHandleEnd, event));\r\n\r\n const animatedStyle = useAnimatedStyle(() => ({\r\n transform: [{ translateY: translateY.value }],\r\n zIndex: 100 + props.layer,\r\n }));\r\n\r\n const overlayStyle = useAnimatedStyle(() => ({\r\n opacity: opacity.value,\r\n zIndex: 100 + props.layer,\r\n backgroundColor: colors.black,\r\n }));\r\n\r\n const edges = useMemo<Edge[]>(() => {\r\n return [placement, \"left\", \"right\"];\r\n }, [placement]);\r\n\r\n const styles = useMemo(\r\n () => themedStyles(theme, placement),\r\n [theme, placement]\r\n );\r\n\r\n useEffect(() => {\r\n if (measuredHeight === null || didOpen.current || !props.open) return;\r\n\r\n translateY.value = withSpring(0, EnterAnimationConfig);\r\n opacity.value = withSpring(0.4, EnterAnimationConfig);\r\n didOpen.current = true;\r\n }, [measuredHeight, props.open]);\r\n\r\n return (\r\n <Fragment>\r\n <Animated.View style={[StyleSheet.absoluteFill, overlayStyle]}>\r\n <Pressable onPress={animateOut} style={StyleSheet.absoluteFillObject} />\r\n </Animated.View>\r\n <GestureDetector gesture={gesture}>\r\n <Animated.View style={[styles.container, animatedStyle]}>\r\n <SafeAreaView\r\n edges={edges}\r\n style={styles.safeAreaView}\r\n onLayout={onLayout}\r\n >\r\n {placement === \"bottom\" ? (\r\n <GestureDetector gesture={handleGesture}>\r\n <FlyoutHandle placement={placement} />\r\n </GestureDetector>\r\n ) : null}\r\n\r\n <Animated.ScrollView\r\n onLayout={onLayoutScrollview}\r\n onContentSizeChange={onContentSizeChange}\r\n onScroll={onScroll}\r\n scrollEventThrottle={16}\r\n scrollEnabled={isScrollable}\r\n bounces={isScrollable && bounceEnabled}\r\n style={styles.scrollview}\r\n stickyHeaderIndices={\r\n props.title ? StickyHeaderIndices : undefined\r\n }\r\n showsHorizontalScrollIndicator={false}\r\n showsVerticalScrollIndicator={false}\r\n {...AndroidOverScroll}\r\n >\r\n {props.title && <FlyoutTitle title={props.title} />}\r\n <View padding={theme.spacing.sm}>{children}</View>\r\n </Animated.ScrollView>\r\n\r\n {placement === \"top\" ? (\r\n <GestureDetector gesture={handleGesture}>\r\n <FlyoutHandle placement={placement} />\r\n </GestureDetector>\r\n ) : null}\r\n </SafeAreaView>\r\n </Animated.View>\r\n </GestureDetector>\r\n </Fragment>\r\n );\r\n});\r\n\r\nconst themedStyles = function (theme: AppTheme, placement: \"top\" | \"bottom\") {\r\n return StyleSheet.create({\r\n container: {\r\n position: \"absolute\",\r\n [placement]: 0,\r\n left: 0,\r\n right: 0,\r\n backgroundColor: theme.colors.background.secondary,\r\n borderTopLeftRadius: placement === \"bottom\" ? theme.radii.xl : 0,\r\n borderTopRightRadius: placement === \"bottom\" ? theme.radii.xl : 0,\r\n borderBottomLeftRadius: placement === \"top\" ? theme.radii.xl : 0,\r\n borderBottomRightRadius: placement === \"top\" ? theme.radii.xl : 0,\r\n },\r\n scrollview: {\r\n borderTopLeftRadius: placement === \"bottom\" ? theme.radii.xl : 0,\r\n borderTopRightRadius: placement === \"bottom\" ? theme.radii.xl : 0,\r\n borderBottomLeftRadius: placement === \"top\" ? theme.radii.xl : 0,\r\n borderBottomRightRadius: placement === \"top\" ? theme.radii.xl : 0,\r\n },\r\n safeAreaView: { maxHeight: MaxHeight },\r\n });\r\n};\r\n","import { AppTheme, useTheme } from \"@impulse-ui-native/theme\";\r\nimport { View } from \"@impulse-ui-native/view\";\r\nimport { memo, useMemo } from \"react\";\r\nimport { StyleSheet } from \"react-native\";\r\nimport Animated from \"react-native-reanimated\";\r\n\r\nconst FlyoutHandleHeight = 32;\r\n\r\ninterface FlyoutHandleProps {\r\n placement: \"top\" | \"bottom\";\r\n}\r\n\r\nexport const FlyoutHandle = memo(function FlyoutHandle(\r\n props: FlyoutHandleProps\r\n) {\r\n const theme = useTheme();\r\n\r\n const styles = useMemo(\r\n () => themedStyles(theme, props.placement),\r\n [theme, props.placement]\r\n );\r\n\r\n return (\r\n <Animated.View style={styles.flyoutHandleContainer}>\r\n <View style={styles.flyoutHandle} />\r\n </Animated.View>\r\n );\r\n});\r\n\r\nconst themedStyles = function (theme: AppTheme, placement: \"top\" | \"bottom\") {\r\n return StyleSheet.create({\r\n flyoutHandle: {\r\n alignSelf: \"center\",\r\n backgroundColor: theme.colors.background.primary,\r\n width: \"25%\",\r\n height: 6,\r\n borderRadius: theme.radii.round,\r\n },\r\n flyoutHandleContainer: {\r\n position: \"absolute\",\r\n top: placement === \"bottom\" ? -FlyoutHandleHeight : undefined,\r\n bottom: placement === \"top\" ? -FlyoutHandleHeight : undefined,\r\n width: \"100%\",\r\n justifyContent: \"center\",\r\n alignItems: \"center\",\r\n height: FlyoutHandleHeight,\r\n },\r\n });\r\n};\r\n","import { AppTheme, useTheme } from \"@impulse-ui-native/theme\";\r\nimport { Typography } from \"@impulse-ui-native/typography\";\r\nimport { View } from \"@impulse-ui-native/view\";\r\nimport { memo, ReactNode, useMemo } from \"react\";\r\nimport { StyleSheet } from \"react-native\";\r\n\r\ninterface FlyoutTitleProps {\r\n title?: ReactNode | string;\r\n placement?: \"top\" | \"bottom\";\r\n}\r\n\r\nexport const FlyoutTitle = memo(function FlyoutTitle(props: FlyoutTitleProps) {\r\n const theme = useTheme();\r\n\r\n const styles = useMemo(\r\n () => themedStyles(theme, props.placement),\r\n [theme, props.placement]\r\n );\r\n\r\n const title = useMemo(() => {\r\n if (typeof props.title === \"string\") {\r\n return <Typography.Title3>{props.title}</Typography.Title3>;\r\n }\r\n\r\n return props.title;\r\n }, [props.title]);\r\n\r\n if (!props.title) {\r\n return null;\r\n }\r\n\r\n return <View style={styles.container}>{title}</View>;\r\n});\r\n\r\nconst themedStyles = function (theme: AppTheme, placement?: \"top\" | \"bottom\") {\r\n return StyleSheet.create({\r\n container: {\r\n borderTopLeftRadius: placement === \"bottom\" ? theme.radii.xl : undefined,\r\n borderTopRightRadius: placement === \"bottom\" ? theme.radii.xl : undefined,\r\n backgroundColor: theme.colors.background.secondary,\r\n padding: theme.spacing.mxs,\r\n alignItems: \"center\",\r\n },\r\n });\r\n};\r\n"],"mappings":";AAAA,SAAS,wBAAwB;AACjC,SAAS,oBAAoB;AAC7B,SAAmB,WAAW,YAAAA,iBAAgB;AAC9C,SAAS,QAAAC,aAAY;AACrB;AAAA,EACE;AAAA,EACA,QAAAC;AAAA,EAEA;AAAA,EACA,WAAAC;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EACA,cAAAC;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OAIK;AACP,OAAOC;AAAA,EACL;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,oBAAoB;;;ACpC7B,SAAmB,gBAAgB;AACnC,SAAS,YAAY;AACrB,SAAS,MAAM,eAAe;AAC9B,SAAS,kBAAkB;AAC3B,OAAO,cAAc;AAErB,IAAM,qBAAqB;AAMpB,IAAM,eAAe,KAAK,SAASC,cACxC,OACA;AACA,QAAM,QAAQ,SAAS;AAEvB,QAAM,SAAS;AAAA,IACb,MAAM,aAAa,OAAO,MAAM,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QAAQ,MAAM,MAAM,KAAK;AAAA,MAC/D,yBAAyB,cAAc,QAAQ,MAAM,MAAM,KAAK;AAAA,IAClE;AAAA,IACA,YAAY;AAAA,MACV,qBAAqB,cAAc,WAAW,MAAM,MAAM,KAAK;AAAA,MAC/D,sBAAsB,cAAc,WAAW,MAAM,MAAM,KAAK;AAAA,MAChE,wBAAwB,cAAc,QAAQ,MAAM,MAAM,KAAK;AAAA,MAC/D,yBAAyB,cAAc,QAAQ,MAAM,MAAM,KAAK;AAAA,IAClE;AAAA,IACA,cAAc,EAAE,WAAW,UAAU;AAAA,EACvC,CAAC;AACH;","names":["useTheme","View","memo","useMemo","StyleSheet","Animated","FlyoutHandle","useTheme","View","memo","useMemo","StyleSheet","FlyoutTitle","themedStyles","memo","Flyout","useTheme","useMemo","contentHeight","themedStyles","Animated","StyleSheet","View"]}
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@impulse-ui-native/flyout",
3
+ "version": "1.0.0",
4
+ "source": "src/index.ts",
5
+ "main": "dist/index.cjs.js",
6
+ "module": "dist/index.esm.js",
7
+ "types": "dist/index.d.ts",
8
+ "react-native": "src/index.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "react-native": "./src/index.ts",
13
+ "import": "./dist/index.esm.js",
14
+ "require": "./dist/index.cjs.js"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "src",
20
+ "README.md",
21
+ "LICENSE"
22
+ ],
23
+ "dependencies": {
24
+ "@impulse-ui-native/theme": "1.0.0",
25
+ "@impulse-ui-native/view": "1.0.0",
26
+ "@impulse-ui-native/typography": "1.0.0",
27
+ "@impulse-ui-native/core": "1.0.0",
28
+ "@impulse-ui-native/safe-area-view": "1.0.0",
29
+ "@impulse-ui-native/layer-manager-types": "1.0.0"
30
+ },
31
+ "peerDependencies": {
32
+ "react": ">=18",
33
+ "react-native": ">=0.74",
34
+ "expo": ">=51 || >=52",
35
+ "react-native-worklets": ">=0.5.1",
36
+ "expo-modules-core": ">=1.0.0",
37
+ "react-native-safe-area-context": "5.6.1",
38
+ "react-native-gesture-handler": ">=2",
39
+ "react-native-reanimated": ">=3"
40
+ },
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "scripts": {
45
+ "build": "tsup --config tsup.config.ts",
46
+ "typecheck": "tsc -p tsconfig.json --noEmit"
47
+ }
48
+ }
@@ -0,0 +1,49 @@
1
+ import { AppTheme, useTheme } from "@impulse-ui-native/theme";
2
+ import { View } from "@impulse-ui-native/view";
3
+ import { memo, useMemo } from "react";
4
+ import { StyleSheet } from "react-native";
5
+ import Animated from "react-native-reanimated";
6
+
7
+ const FlyoutHandleHeight = 32;
8
+
9
+ interface FlyoutHandleProps {
10
+ placement: "top" | "bottom";
11
+ }
12
+
13
+ export const FlyoutHandle = memo(function FlyoutHandle(
14
+ props: FlyoutHandleProps
15
+ ) {
16
+ const theme = useTheme();
17
+
18
+ const styles = useMemo(
19
+ () => themedStyles(theme, props.placement),
20
+ [theme, props.placement]
21
+ );
22
+
23
+ return (
24
+ <Animated.View style={styles.flyoutHandleContainer}>
25
+ <View style={styles.flyoutHandle} />
26
+ </Animated.View>
27
+ );
28
+ });
29
+
30
+ const themedStyles = function (theme: AppTheme, placement: "top" | "bottom") {
31
+ return StyleSheet.create({
32
+ flyoutHandle: {
33
+ alignSelf: "center",
34
+ backgroundColor: theme.colors.background.primary,
35
+ width: "25%",
36
+ height: 6,
37
+ borderRadius: theme.radii.round,
38
+ },
39
+ flyoutHandleContainer: {
40
+ position: "absolute",
41
+ top: placement === "bottom" ? -FlyoutHandleHeight : undefined,
42
+ bottom: placement === "top" ? -FlyoutHandleHeight : undefined,
43
+ width: "100%",
44
+ justifyContent: "center",
45
+ alignItems: "center",
46
+ height: FlyoutHandleHeight,
47
+ },
48
+ });
49
+ };
@@ -0,0 +1,45 @@
1
+ import { AppTheme, useTheme } from "@impulse-ui-native/theme";
2
+ import { Typography } from "@impulse-ui-native/typography";
3
+ import { View } from "@impulse-ui-native/view";
4
+ import { memo, ReactNode, useMemo } from "react";
5
+ import { StyleSheet } from "react-native";
6
+
7
+ interface FlyoutTitleProps {
8
+ title?: ReactNode | string;
9
+ placement?: "top" | "bottom";
10
+ }
11
+
12
+ export const FlyoutTitle = memo(function FlyoutTitle(props: FlyoutTitleProps) {
13
+ const theme = useTheme();
14
+
15
+ const styles = useMemo(
16
+ () => themedStyles(theme, props.placement),
17
+ [theme, props.placement]
18
+ );
19
+
20
+ const title = useMemo(() => {
21
+ if (typeof props.title === "string") {
22
+ return <Typography.Title3>{props.title}</Typography.Title3>;
23
+ }
24
+
25
+ return props.title;
26
+ }, [props.title]);
27
+
28
+ if (!props.title) {
29
+ return null;
30
+ }
31
+
32
+ return <View style={styles.container}>{title}</View>;
33
+ });
34
+
35
+ const themedStyles = function (theme: AppTheme, placement?: "top" | "bottom") {
36
+ return StyleSheet.create({
37
+ container: {
38
+ borderTopLeftRadius: placement === "bottom" ? theme.radii.xl : undefined,
39
+ borderTopRightRadius: placement === "bottom" ? theme.radii.xl : undefined,
40
+ backgroundColor: theme.colors.background.secondary,
41
+ padding: theme.spacing.mxs,
42
+ alignItems: "center",
43
+ },
44
+ });
45
+ };
@@ -0,0 +1,331 @@
1
+ import { useEventCallback } from "@impulse-ui-native/core";
2
+ import { SafeAreaView } from "@impulse-ui-native/safe-area-view";
3
+ import { AppTheme, useColors, useTheme } from "@impulse-ui-native/theme";
4
+ import { View } from "@impulse-ui-native/view";
5
+ import {
6
+ Fragment,
7
+ memo,
8
+ PropsWithChildren,
9
+ useEffect,
10
+ useMemo,
11
+ useRef,
12
+ useState,
13
+ } from "react";
14
+ import {
15
+ Dimensions,
16
+ LayoutChangeEvent,
17
+ Platform,
18
+ Pressable,
19
+ StyleSheet,
20
+ } from "react-native";
21
+ import {
22
+ Gesture,
23
+ GestureDetector,
24
+ GestureStateChangeEvent,
25
+ GestureUpdateEvent,
26
+ PanGestureHandlerEventPayload,
27
+ } from "react-native-gesture-handler";
28
+ import Animated, {
29
+ Easing,
30
+ useAnimatedScrollHandler,
31
+ useAnimatedStyle,
32
+ useSharedValue,
33
+ withSpring,
34
+ withTiming,
35
+ } from "react-native-reanimated";
36
+ import { Edge } from "react-native-safe-area-context";
37
+ import { scheduleOnRN } from "react-native-worklets";
38
+ import { FlyoutProps } from "../types";
39
+ import { FlyoutHandle } from "./flyout-handle";
40
+ import { FlyoutTitle } from "./flyout-title";
41
+
42
+ const EnterAnimationConfig = {
43
+ damping: 50,
44
+ stiffness: 300,
45
+ mass: 1,
46
+ overshootClamping: true,
47
+ };
48
+
49
+ const ExitAnimationConfig = {
50
+ duration: 150,
51
+ easing: Easing.in(Easing.quad),
52
+ };
53
+
54
+ const StickyHeaderIndices = [0];
55
+ const ScreenHeight = Dimensions.get("screen").height;
56
+ const MaxHeight = ScreenHeight * 0.9;
57
+
58
+ const AndroidOverScroll =
59
+ Platform.OS === "android" ? { overScrollMode: "always" as const } : {};
60
+
61
+ export const Flyout = memo(function Flyout({
62
+ children,
63
+ placement = "bottom",
64
+ ...props
65
+ }: PropsWithChildren<FlyoutProps>) {
66
+ const colors = useColors();
67
+ const theme = useTheme();
68
+
69
+ const [measuredHeight, setMeasuredHeight] = useState<number | null>(null);
70
+ const [bounceEnabled, setBounceEnabled] = useState(placement !== "bottom");
71
+ const [viewportHeight, setViewportHeight] = useState(0);
72
+ const [contentHeight, setContentHeight] = useState(0);
73
+
74
+ const didOpen = useRef(false);
75
+ const canDismiss = useSharedValue(placement === "bottom");
76
+ const scrollY = useSharedValue(0);
77
+ const maxScrollY = useSharedValue(0);
78
+
79
+ const translateY = useSharedValue(
80
+ placement === "top" ? -ScreenHeight : ScreenHeight
81
+ );
82
+ const opacity = useSharedValue(0);
83
+
84
+ const isScrollable = useMemo(
85
+ () => contentHeight > viewportHeight,
86
+ [contentHeight, viewportHeight]
87
+ );
88
+
89
+ const onScroll = useAnimatedScrollHandler({
90
+ onScroll(event) {
91
+ scrollY.value = event.contentOffset.y;
92
+ maxScrollY.value = Math.max(
93
+ 0,
94
+ event.contentSize.height - event.layoutMeasurement.height
95
+ );
96
+ },
97
+ onMomentumEnd(event) {
98
+ if (placement === "bottom" && event.contentOffset.y <= 0) {
99
+ scheduleOnRN(setBounceEnabled, false);
100
+ canDismiss.value = true;
101
+ }
102
+
103
+ if (placement === "top" && scrollY.value >= maxScrollY.value - 1) {
104
+ scheduleOnRN(setBounceEnabled, false);
105
+ canDismiss.value = true;
106
+ }
107
+ },
108
+ });
109
+
110
+ const onLayout = useEventCallback((event: LayoutChangeEvent) => {
111
+ if (!didOpen.current && measuredHeight === null) {
112
+ const rawHeight = event.nativeEvent.layout.height;
113
+ const clampedHeight = Math.min(rawHeight, MaxHeight);
114
+ setMeasuredHeight(clampedHeight);
115
+ translateY.value = placement === "top" ? -clampedHeight : clampedHeight;
116
+ }
117
+ });
118
+
119
+ const onLayoutScrollview = useEventCallback((event: LayoutChangeEvent) => {
120
+ setViewportHeight(event.nativeEvent.layout.height);
121
+ });
122
+
123
+ const onContentSizeChange = useEventCallback(
124
+ (_contentWidth: number, contentHeight: number) => {
125
+ setContentHeight(contentHeight);
126
+ }
127
+ );
128
+
129
+ const animateOut = useEventCallback(() => {
130
+ if (measuredHeight) {
131
+ const target = placement === "top" ? -measuredHeight : measuredHeight;
132
+
133
+ translateY.value = withTiming(target, ExitAnimationConfig, (finished) => {
134
+ if (finished && props.onCloseFinished) {
135
+ scheduleOnRN(props.onCloseFinished, props.id);
136
+ }
137
+ });
138
+
139
+ opacity.value = withTiming(0, ExitAnimationConfig);
140
+ didOpen.current = false;
141
+ }
142
+ });
143
+
144
+ const onPanGestureEnd = useEventCallback(
145
+ (event: GestureStateChangeEvent<PanGestureHandlerEventPayload>) => {
146
+ if (!measuredHeight) return;
147
+
148
+ let shouldClose = false;
149
+
150
+ if (placement === "bottom") {
151
+ shouldClose =
152
+ event.translationY > measuredHeight * 0.5 || event.velocityY > 1500;
153
+ }
154
+
155
+ if (placement === "top") {
156
+ shouldClose =
157
+ event.translationY < -measuredHeight * 0.5 || event.velocityY < -1500;
158
+ }
159
+
160
+ if (shouldClose && (canDismiss.value || !isScrollable)) {
161
+ animateOut();
162
+ } else {
163
+ translateY.value = withSpring(0, EnterAnimationConfig);
164
+ opacity.value = withSpring(0.4, EnterAnimationConfig);
165
+ }
166
+ }
167
+ );
168
+
169
+ const onPanGestureHandleEnd = useEventCallback(
170
+ (event: GestureStateChangeEvent<PanGestureHandlerEventPayload>) => {
171
+ onPanGestureEnd(event);
172
+
173
+ if (placement === "bottom" && scrollY.value > 0) {
174
+ canDismiss.value = false;
175
+ }
176
+
177
+ if (placement === "top" && scrollY.value < maxScrollY.value - 1) {
178
+ canDismiss.value = false;
179
+ }
180
+ }
181
+ );
182
+
183
+ const onPanGestureUpdate = (
184
+ event: GestureUpdateEvent<PanGestureHandlerEventPayload>
185
+ ) => {
186
+ if (placement === "bottom" && event.translationY < 0) {
187
+ scheduleOnRN(setBounceEnabled, true);
188
+ canDismiss.value = false;
189
+ }
190
+
191
+ if (placement === "top" && event.translationY > 0) {
192
+ scheduleOnRN(setBounceEnabled, true);
193
+ canDismiss.value = false;
194
+ }
195
+
196
+ if (
197
+ (placement === "bottom" && event.translationY < 0) ||
198
+ (placement === "top" && event.translationY > 0)
199
+ ) {
200
+ return;
201
+ }
202
+
203
+ if (canDismiss.value || !isScrollable) {
204
+ translateY.value = event.translationY;
205
+ }
206
+ };
207
+
208
+ const onPanGestureHandleUpdate = (
209
+ event: GestureUpdateEvent<PanGestureHandlerEventPayload>
210
+ ) => {
211
+ canDismiss.value = true;
212
+
213
+ if (
214
+ (placement === "bottom" && event.translationY < 0) ||
215
+ (placement === "top" && event.translationY > 0)
216
+ ) {
217
+ return;
218
+ }
219
+
220
+ translateY.value = event.translationY;
221
+ };
222
+
223
+ const panGesture = Gesture.Pan()
224
+ .onUpdate(onPanGestureUpdate)
225
+ .onEnd((event) => scheduleOnRN(onPanGestureEnd, event));
226
+
227
+ const gesture = Gesture.Simultaneous(Gesture.Native(), panGesture);
228
+
229
+ const handleGesture = Gesture.Pan()
230
+ .onUpdate(onPanGestureHandleUpdate)
231
+ .onEnd((event) => scheduleOnRN(onPanGestureHandleEnd, event));
232
+
233
+ const animatedStyle = useAnimatedStyle(() => ({
234
+ transform: [{ translateY: translateY.value }],
235
+ zIndex: 100 + props.layer,
236
+ }));
237
+
238
+ const overlayStyle = useAnimatedStyle(() => ({
239
+ opacity: opacity.value,
240
+ zIndex: 100 + props.layer,
241
+ backgroundColor: colors.black,
242
+ }));
243
+
244
+ const edges = useMemo<Edge[]>(() => {
245
+ return [placement, "left", "right"];
246
+ }, [placement]);
247
+
248
+ const styles = useMemo(
249
+ () => themedStyles(theme, placement),
250
+ [theme, placement]
251
+ );
252
+
253
+ useEffect(() => {
254
+ if (measuredHeight === null || didOpen.current || !props.open) return;
255
+
256
+ translateY.value = withSpring(0, EnterAnimationConfig);
257
+ opacity.value = withSpring(0.4, EnterAnimationConfig);
258
+ didOpen.current = true;
259
+ }, [measuredHeight, props.open]);
260
+
261
+ return (
262
+ <Fragment>
263
+ <Animated.View style={[StyleSheet.absoluteFill, overlayStyle]}>
264
+ <Pressable onPress={animateOut} style={StyleSheet.absoluteFillObject} />
265
+ </Animated.View>
266
+ <GestureDetector gesture={gesture}>
267
+ <Animated.View style={[styles.container, animatedStyle]}>
268
+ <SafeAreaView
269
+ edges={edges}
270
+ style={styles.safeAreaView}
271
+ onLayout={onLayout}
272
+ >
273
+ {placement === "bottom" ? (
274
+ <GestureDetector gesture={handleGesture}>
275
+ <FlyoutHandle placement={placement} />
276
+ </GestureDetector>
277
+ ) : null}
278
+
279
+ <Animated.ScrollView
280
+ onLayout={onLayoutScrollview}
281
+ onContentSizeChange={onContentSizeChange}
282
+ onScroll={onScroll}
283
+ scrollEventThrottle={16}
284
+ scrollEnabled={isScrollable}
285
+ bounces={isScrollable && bounceEnabled}
286
+ style={styles.scrollview}
287
+ stickyHeaderIndices={
288
+ props.title ? StickyHeaderIndices : undefined
289
+ }
290
+ showsHorizontalScrollIndicator={false}
291
+ showsVerticalScrollIndicator={false}
292
+ {...AndroidOverScroll}
293
+ >
294
+ {props.title && <FlyoutTitle title={props.title} />}
295
+ <View padding={theme.spacing.sm}>{children}</View>
296
+ </Animated.ScrollView>
297
+
298
+ {placement === "top" ? (
299
+ <GestureDetector gesture={handleGesture}>
300
+ <FlyoutHandle placement={placement} />
301
+ </GestureDetector>
302
+ ) : null}
303
+ </SafeAreaView>
304
+ </Animated.View>
305
+ </GestureDetector>
306
+ </Fragment>
307
+ );
308
+ });
309
+
310
+ const themedStyles = function (theme: AppTheme, placement: "top" | "bottom") {
311
+ return StyleSheet.create({
312
+ container: {
313
+ position: "absolute",
314
+ [placement]: 0,
315
+ left: 0,
316
+ right: 0,
317
+ backgroundColor: theme.colors.background.secondary,
318
+ borderTopLeftRadius: placement === "bottom" ? theme.radii.xl : 0,
319
+ borderTopRightRadius: placement === "bottom" ? theme.radii.xl : 0,
320
+ borderBottomLeftRadius: placement === "top" ? theme.radii.xl : 0,
321
+ borderBottomRightRadius: placement === "top" ? theme.radii.xl : 0,
322
+ },
323
+ scrollview: {
324
+ borderTopLeftRadius: placement === "bottom" ? theme.radii.xl : 0,
325
+ borderTopRightRadius: placement === "bottom" ? theme.radii.xl : 0,
326
+ borderBottomLeftRadius: placement === "top" ? theme.radii.xl : 0,
327
+ borderBottomRightRadius: placement === "top" ? theme.radii.xl : 0,
328
+ },
329
+ safeAreaView: { maxHeight: MaxHeight },
330
+ });
331
+ };
@@ -0,0 +1 @@
1
+ export { Flyout } from "./flyout";
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./components";
2
+ export * from "./types";
@@ -0,0 +1,6 @@
1
+ import { LayerComponentBaseProps } from "@impulse-ui-native/layer-manager-types";
2
+
3
+ export interface FlyoutProps extends LayerComponentBaseProps {
4
+ open?: boolean;
5
+ placement?: "top" | "bottom";
6
+ }
@@ -0,0 +1 @@
1
+ export * from "./flyout.types";