@rific/drawer 0.5.1 → 0.6.1
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.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +28 -33
- package/dist/index.mjs +26 -31
- package/package.json +5 -4
- package/src/DrawerConfig.tsx +8 -22
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode, JSX, ComponentType } from 'react';
|
|
3
3
|
import { SharedValue } from 'react-native-reanimated';
|
|
4
|
+
import * as _rific_core from '@rific/core';
|
|
4
5
|
import { LayoutChangeEvent, StyleProp, ViewStyle } from 'react-native';
|
|
5
6
|
|
|
6
7
|
type DrawerSide = 'left' | 'right' | 'top' | 'bottom';
|
|
@@ -95,12 +96,12 @@ type DrawerConfig = {
|
|
|
95
96
|
/** Injects @rific/auto-paper so Drawer's panel renders a real frosted-glass backdrop via BlurView/useBlur instead of its solid-fill fallback. Pass `import * as AutoPaper from '@rific/auto-paper'`; omit to keep the solid fallback. */
|
|
96
97
|
autoPaper?: AutoPaperModule;
|
|
97
98
|
};
|
|
98
|
-
declare const configureDrawer: (next: DrawerConfig) => void;
|
|
99
|
+
declare const configureDrawer: (next: Partial<DrawerConfig>) => void;
|
|
99
100
|
declare const getDrawerConfig: () => DrawerConfig;
|
|
101
|
+
declare const DrawerProvider: (props: _rific_core.ModuleConfigProviderProps<DrawerConfig>) => React.JSX.Element;
|
|
100
102
|
type DrawerProviderProps = DrawerConfig & {
|
|
101
103
|
children: ReactNode;
|
|
102
104
|
};
|
|
103
|
-
declare const DrawerProvider: ({ autoPaper, children }: DrawerProviderProps) => react.JSX.Element;
|
|
104
105
|
|
|
105
106
|
type DrawerEdgeSwipeProps = {
|
|
106
107
|
edgeInset?: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode, JSX, ComponentType } from 'react';
|
|
3
3
|
import { SharedValue } from 'react-native-reanimated';
|
|
4
|
+
import * as _rific_core from '@rific/core';
|
|
4
5
|
import { LayoutChangeEvent, StyleProp, ViewStyle } from 'react-native';
|
|
5
6
|
|
|
6
7
|
type DrawerSide = 'left' | 'right' | 'top' | 'bottom';
|
|
@@ -95,12 +96,12 @@ type DrawerConfig = {
|
|
|
95
96
|
/** Injects @rific/auto-paper so Drawer's panel renders a real frosted-glass backdrop via BlurView/useBlur instead of its solid-fill fallback. Pass `import * as AutoPaper from '@rific/auto-paper'`; omit to keep the solid fallback. */
|
|
96
97
|
autoPaper?: AutoPaperModule;
|
|
97
98
|
};
|
|
98
|
-
declare const configureDrawer: (next: DrawerConfig) => void;
|
|
99
|
+
declare const configureDrawer: (next: Partial<DrawerConfig>) => void;
|
|
99
100
|
declare const getDrawerConfig: () => DrawerConfig;
|
|
101
|
+
declare const DrawerProvider: (props: _rific_core.ModuleConfigProviderProps<DrawerConfig>) => React.JSX.Element;
|
|
100
102
|
type DrawerProviderProps = DrawerConfig & {
|
|
101
103
|
children: ReactNode;
|
|
102
104
|
};
|
|
103
|
-
declare const DrawerProvider: ({ autoPaper, children }: DrawerProviderProps) => react.JSX.Element;
|
|
104
105
|
|
|
105
106
|
type DrawerEdgeSwipeProps = {
|
|
106
107
|
edgeInset?: number;
|
package/dist/index.js
CHANGED
|
@@ -53,16 +53,11 @@ var import_react_native_paper = require("react-native-paper");
|
|
|
53
53
|
var import_react_native_reanimated = __toESM(require("react-native-reanimated"));
|
|
54
54
|
|
|
55
55
|
// src/DrawerConfig.tsx
|
|
56
|
-
var
|
|
57
|
-
var
|
|
58
|
-
var configureDrawer =
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
var getDrawerConfig = () => config;
|
|
62
|
-
var DrawerProvider = ({ autoPaper, children }) => {
|
|
63
|
-
configureDrawer({ autoPaper });
|
|
64
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
|
|
65
|
-
};
|
|
56
|
+
var import_core = require("@rific/core");
|
|
57
|
+
var drawerConfig = (0, import_core.createModuleConfig)();
|
|
58
|
+
var configureDrawer = drawerConfig.configure;
|
|
59
|
+
var getDrawerConfig = drawerConfig.getConfig;
|
|
60
|
+
var DrawerProvider = drawerConfig.Provider;
|
|
66
61
|
|
|
67
62
|
// src/geometry.ts
|
|
68
63
|
function isVerticalSide(side) {
|
|
@@ -92,7 +87,7 @@ function useDrawerSize(side, size, maxSize, edgeInset = 0) {
|
|
|
92
87
|
}
|
|
93
88
|
|
|
94
89
|
// src/Drawer.tsx
|
|
95
|
-
var
|
|
90
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
96
91
|
var SPRING = { damping: 45, stiffness: 500, overshootClamping: true, restDisplacementThreshold: 0.5, restSpeedThreshold: 10 };
|
|
97
92
|
var VELOCITY_THRESHOLD = 500;
|
|
98
93
|
var useBlurFallback = (override) => override ?? false;
|
|
@@ -149,13 +144,13 @@ var Drawer = ({ backdropOpacity = 0.45, blockingBackdrop = true, blur, children,
|
|
|
149
144
|
onMeasure?.(measured);
|
|
150
145
|
};
|
|
151
146
|
const fillStyle = import_react_native2.StyleSheet.absoluteFill;
|
|
152
|
-
const fill = resolvedBlur && autoPaper ? contentSize ? /* @__PURE__ */ (0,
|
|
153
|
-
/* @__PURE__ */ (0,
|
|
154
|
-
/* @__PURE__ */ (0,
|
|
155
|
-
] }) : /* @__PURE__ */ (0,
|
|
156
|
-
/* @__PURE__ */ (0,
|
|
157
|
-
/* @__PURE__ */ (0,
|
|
158
|
-
] }) : /* @__PURE__ */ (0,
|
|
147
|
+
const fill = resolvedBlur && autoPaper ? contentSize ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
148
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(autoPaper.BlurView, { style: fillStyle }),
|
|
149
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { onLayout: handleLayout, children })
|
|
150
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(autoPaper.BlurView, { style: fillStyle, children }) : contentSize ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
151
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { style: [fillStyle, { backgroundColor: colors.surface }] }),
|
|
152
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { onLayout: handleLayout, children })
|
|
153
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { style: [fillStyle, { backgroundColor: colors.surface }], children });
|
|
159
154
|
const drawerOuterStyle = contentSize ? [styles.drawer, positionStyle, drawerStyle, animatedSizeStyle, { zIndex: zIndex + 1 }] : [styles.drawer, positionStyle, sizeStyle, drawerStyle, { zIndex: zIndex + 1 }];
|
|
160
155
|
const contentClipStyle = [fillStyle, styles.clip, { flexDirection: vertical ? "column" : "row" }];
|
|
161
156
|
const clampMin = Math.min(0, closedOffset);
|
|
@@ -210,15 +205,15 @@ var Drawer = ({ backdropOpacity = 0.45, blockingBackdrop = true, blur, children,
|
|
|
210
205
|
const visibleSize = maxEffectiveSize - translateOffset.value * closeDirection;
|
|
211
206
|
return { opacity: Math.min(1, Math.max(0, visibleSize / panelShadowFadeDistance)) };
|
|
212
207
|
});
|
|
213
|
-
return /* @__PURE__ */ (0,
|
|
214
|
-
/* @__PURE__ */ (0,
|
|
215
|
-
/* @__PURE__ */ (0,
|
|
216
|
-
/* @__PURE__ */ (0,
|
|
208
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
209
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native_reanimated.default.View, { style: [styles.backdropPosition, backdropInteractionStyle], children: [
|
|
210
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native_reanimated.default.View, { style: [styles.backdropTint, backdropStyle], pointerEvents: "none" }),
|
|
211
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native_gesture_handler.GestureDetector, { gesture: backdropTapGesture, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native_reanimated.default.View, { collapsable: false, style: [import_react_native2.StyleSheet.absoluteFill, backdropTapAreaStyle] }) })
|
|
217
212
|
] }),
|
|
218
|
-
/* @__PURE__ */ (0,
|
|
219
|
-
resolvedPanelShadow && /* @__PURE__ */ (0,
|
|
220
|
-
contentSize ? /* @__PURE__ */ (0,
|
|
221
|
-
dismissible && /* @__PURE__ */ (0,
|
|
213
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { pointerEvents: "box-none", style: styles.panelClip, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native_reanimated.default.View, { style: drawerOuterStyle, children: [
|
|
214
|
+
resolvedPanelShadow && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native_reanimated.default.View, { pointerEvents: "none", style: [import_react_native2.StyleSheet.absoluteFill, panelShadowStyle, panelShadowVisibilityStyle] }),
|
|
215
|
+
contentSize ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { style: contentClipStyle, children: fill }) : fill,
|
|
216
|
+
dismissible && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native_gesture_handler.GestureDetector, { gesture: handleGesture, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native_reanimated.default.View, { style: [styles.handleStrip, handleStripSizeStyle, handleStripEdgeStyle, handleStripPaddingStyle, webCursorStyle2, handleVisibilityStyle, handleStripInteractionStyle], children: showHandle && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { style: [styles.handlePill, handlePillStyle, { backgroundColor: colors.surface }] }) }) })
|
|
222
217
|
] }) })
|
|
223
218
|
] });
|
|
224
219
|
};
|
|
@@ -288,7 +283,7 @@ var styles = import_react_native2.StyleSheet.create({
|
|
|
288
283
|
var import_react_native3 = require("react-native");
|
|
289
284
|
var import_react_native_gesture_handler2 = require("react-native-gesture-handler");
|
|
290
285
|
var import_react_native_reanimated2 = require("react-native-reanimated");
|
|
291
|
-
var
|
|
286
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
292
287
|
var EDGE_WIDTH = 24;
|
|
293
288
|
var SPRING2 = { damping: 45, overshootClamping: true, stiffness: 500, restDisplacementThreshold: 0.5, restSpeedThreshold: 10 };
|
|
294
289
|
var VELOCITY_THRESHOLD2 = 500;
|
|
@@ -316,7 +311,7 @@ var DrawerEdgeSwipe = ({ edgeInset = 0, enabled = true, height = 300, insetBotto
|
|
|
316
311
|
}
|
|
317
312
|
});
|
|
318
313
|
const edgeStyle = vertical ? [styles2.edgeHorizontal, side === "top" ? styles2.top : styles2.bottom, { left: insetLeft, right: insetRight }] : [styles2.edgeVertical, side === "left" ? styles2.left : styles2.right, { bottom: insetBottom, top: insetTop }];
|
|
319
|
-
return /* @__PURE__ */ (0,
|
|
314
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native_gesture_handler2.GestureDetector, { gesture, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native3.View, { style: [...edgeStyle, webCursorStyle, enabled ? styles2.interactive : styles2.nonInteractive] }) });
|
|
320
315
|
};
|
|
321
316
|
var webCursorStyle = { cursor: import_react_native3.Platform.OS === "web" ? "pointer" : void 0 };
|
|
322
317
|
var styles2 = import_react_native3.StyleSheet.create({
|
|
@@ -345,7 +340,7 @@ var styles2 = import_react_native3.StyleSheet.create({
|
|
|
345
340
|
});
|
|
346
341
|
|
|
347
342
|
// src/createDrawer.tsx
|
|
348
|
-
var
|
|
343
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
349
344
|
var noop = () => {
|
|
350
345
|
};
|
|
351
346
|
var createDrawer = ({ backdropOpacity: factoryBackdropOpacity, blockingBackdrop: factoryBlockingBackdrop, blur: factoryBlur, closeOnBackPress: factoryCloseOnBackPress, contentSize: factoryContentSize, dismissible: factoryDismissible, edgeInset = 0, height = 300, maxHeight, maxWidth, showHandle: factoryShowHandle, side = "left", width = 300, zIndex: factoryZIndex } = {}) => {
|
|
@@ -398,17 +393,17 @@ var createDrawer = ({ backdropOpacity: factoryBackdropOpacity, blockingBackdrop:
|
|
|
398
393
|
});
|
|
399
394
|
return () => subscription.remove();
|
|
400
395
|
}, [isOpen, closeOnBackPress]);
|
|
401
|
-
return /* @__PURE__ */ (0,
|
|
396
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(DrawerActionsContext.Provider, { value: actions, children: [
|
|
402
397
|
children,
|
|
403
|
-
/* @__PURE__ */ (0,
|
|
404
|
-
/* @__PURE__ */ (0,
|
|
398
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(DrawerEdgeSwipe, { edgeInset, enabled: enabled && !isOpen, height: vertical ? effectiveSize : height, maxHeight, maxWidth, onOpen: open, side, translateOffset, width: vertical ? width : effectiveSize }),
|
|
399
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Drawer, { backdropOpacity, blockingBackdrop, blur, contentSize, dismissible, edgeInset, height: vertical ? effectiveSize : height, maxHeight, maxWidth, onClose: () => setIsOpen(false), onClosed: () => setIsVisible(false), onMeasure: setMeasuredSize, open: isOpen, showHandle, side, translateOffset, width: vertical ? width : effectiveSize, zIndex, children: content })
|
|
405
400
|
] });
|
|
406
401
|
};
|
|
407
402
|
const useDrawer = () => (0, import_react2.useContext)(DrawerActionsContext);
|
|
408
403
|
return { DrawerInstanceProvider, useDrawer };
|
|
409
404
|
};
|
|
410
405
|
var combineDrawerProviders = (...entries) => {
|
|
411
|
-
const CombinedDrawerProviders = ({ children }) => entries.reduceRight((acc, [Provider, props]) => /* @__PURE__ */ (0,
|
|
406
|
+
const CombinedDrawerProviders = ({ children }) => entries.reduceRight((acc, [Provider, props]) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Provider, { ...props, children: acc }), children);
|
|
412
407
|
return CombinedDrawerProviders;
|
|
413
408
|
};
|
|
414
409
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.mjs
CHANGED
|
@@ -11,16 +11,11 @@ import { useTheme } from "react-native-paper";
|
|
|
11
11
|
import Animated, { runOnJS, useAnimatedStyle, useSharedValue, withSpring, withTiming } from "react-native-reanimated";
|
|
12
12
|
|
|
13
13
|
// src/DrawerConfig.tsx
|
|
14
|
-
import {
|
|
15
|
-
var
|
|
16
|
-
var configureDrawer =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var getDrawerConfig = () => config;
|
|
20
|
-
var DrawerProvider = ({ autoPaper, children }) => {
|
|
21
|
-
configureDrawer({ autoPaper });
|
|
22
|
-
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
23
|
-
};
|
|
14
|
+
import { createModuleConfig } from "@rific/core";
|
|
15
|
+
var drawerConfig = createModuleConfig();
|
|
16
|
+
var configureDrawer = drawerConfig.configure;
|
|
17
|
+
var getDrawerConfig = drawerConfig.getConfig;
|
|
18
|
+
var DrawerProvider = drawerConfig.Provider;
|
|
24
19
|
|
|
25
20
|
// src/geometry.ts
|
|
26
21
|
function isVerticalSide(side) {
|
|
@@ -50,7 +45,7 @@ function useDrawerSize(side, size, maxSize, edgeInset = 0) {
|
|
|
50
45
|
}
|
|
51
46
|
|
|
52
47
|
// src/Drawer.tsx
|
|
53
|
-
import { Fragment
|
|
48
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
54
49
|
var SPRING = { damping: 45, stiffness: 500, overshootClamping: true, restDisplacementThreshold: 0.5, restSpeedThreshold: 10 };
|
|
55
50
|
var VELOCITY_THRESHOLD = 500;
|
|
56
51
|
var useBlurFallback = (override) => override ?? false;
|
|
@@ -107,13 +102,13 @@ var Drawer = ({ backdropOpacity = 0.45, blockingBackdrop = true, blur, children,
|
|
|
107
102
|
onMeasure?.(measured);
|
|
108
103
|
};
|
|
109
104
|
const fillStyle = StyleSheet.absoluteFill;
|
|
110
|
-
const fill = resolvedBlur && autoPaper ? contentSize ? /* @__PURE__ */ jsxs(
|
|
111
|
-
/* @__PURE__ */
|
|
112
|
-
/* @__PURE__ */
|
|
113
|
-
] }) : /* @__PURE__ */
|
|
114
|
-
/* @__PURE__ */
|
|
115
|
-
/* @__PURE__ */
|
|
116
|
-
] }) : /* @__PURE__ */
|
|
105
|
+
const fill = resolvedBlur && autoPaper ? contentSize ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
106
|
+
/* @__PURE__ */ jsx(autoPaper.BlurView, { style: fillStyle }),
|
|
107
|
+
/* @__PURE__ */ jsx(View, { onLayout: handleLayout, children })
|
|
108
|
+
] }) : /* @__PURE__ */ jsx(autoPaper.BlurView, { style: fillStyle, children }) : contentSize ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
109
|
+
/* @__PURE__ */ jsx(View, { style: [fillStyle, { backgroundColor: colors.surface }] }),
|
|
110
|
+
/* @__PURE__ */ jsx(View, { onLayout: handleLayout, children })
|
|
111
|
+
] }) : /* @__PURE__ */ jsx(View, { style: [fillStyle, { backgroundColor: colors.surface }], children });
|
|
117
112
|
const drawerOuterStyle = contentSize ? [styles.drawer, positionStyle, drawerStyle, animatedSizeStyle, { zIndex: zIndex + 1 }] : [styles.drawer, positionStyle, sizeStyle, drawerStyle, { zIndex: zIndex + 1 }];
|
|
118
113
|
const contentClipStyle = [fillStyle, styles.clip, { flexDirection: vertical ? "column" : "row" }];
|
|
119
114
|
const clampMin = Math.min(0, closedOffset);
|
|
@@ -168,15 +163,15 @@ var Drawer = ({ backdropOpacity = 0.45, blockingBackdrop = true, blur, children,
|
|
|
168
163
|
const visibleSize = maxEffectiveSize - translateOffset.value * closeDirection;
|
|
169
164
|
return { opacity: Math.min(1, Math.max(0, visibleSize / panelShadowFadeDistance)) };
|
|
170
165
|
});
|
|
171
|
-
return /* @__PURE__ */ jsxs(
|
|
166
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
172
167
|
/* @__PURE__ */ jsxs(Animated.View, { style: [styles.backdropPosition, backdropInteractionStyle], children: [
|
|
173
|
-
/* @__PURE__ */
|
|
174
|
-
/* @__PURE__ */
|
|
168
|
+
/* @__PURE__ */ jsx(Animated.View, { style: [styles.backdropTint, backdropStyle], pointerEvents: "none" }),
|
|
169
|
+
/* @__PURE__ */ jsx(GestureDetector, { gesture: backdropTapGesture, children: /* @__PURE__ */ jsx(Animated.View, { collapsable: false, style: [StyleSheet.absoluteFill, backdropTapAreaStyle] }) })
|
|
175
170
|
] }),
|
|
176
|
-
/* @__PURE__ */
|
|
177
|
-
resolvedPanelShadow && /* @__PURE__ */
|
|
178
|
-
contentSize ? /* @__PURE__ */
|
|
179
|
-
dismissible && /* @__PURE__ */
|
|
171
|
+
/* @__PURE__ */ jsx(View, { pointerEvents: "box-none", style: styles.panelClip, children: /* @__PURE__ */ jsxs(Animated.View, { style: drawerOuterStyle, children: [
|
|
172
|
+
resolvedPanelShadow && /* @__PURE__ */ jsx(Animated.View, { pointerEvents: "none", style: [StyleSheet.absoluteFill, panelShadowStyle, panelShadowVisibilityStyle] }),
|
|
173
|
+
contentSize ? /* @__PURE__ */ jsx(View, { style: contentClipStyle, children: fill }) : fill,
|
|
174
|
+
dismissible && /* @__PURE__ */ jsx(GestureDetector, { gesture: handleGesture, children: /* @__PURE__ */ jsx(Animated.View, { style: [styles.handleStrip, handleStripSizeStyle, handleStripEdgeStyle, handleStripPaddingStyle, webCursorStyle2, handleVisibilityStyle, handleStripInteractionStyle], children: showHandle && /* @__PURE__ */ jsx(View, { style: [styles.handlePill, handlePillStyle, { backgroundColor: colors.surface }] }) }) })
|
|
180
175
|
] }) })
|
|
181
176
|
] });
|
|
182
177
|
};
|
|
@@ -246,7 +241,7 @@ var styles = StyleSheet.create({
|
|
|
246
241
|
import { Platform as Platform2, StyleSheet as StyleSheet2, View as View2 } from "react-native";
|
|
247
242
|
import { Gesture as Gesture2, GestureDetector as GestureDetector2 } from "react-native-gesture-handler";
|
|
248
243
|
import { runOnJS as runOnJS2, withSpring as withSpring2 } from "react-native-reanimated";
|
|
249
|
-
import { jsx as
|
|
244
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
250
245
|
var EDGE_WIDTH = 24;
|
|
251
246
|
var SPRING2 = { damping: 45, overshootClamping: true, stiffness: 500, restDisplacementThreshold: 0.5, restSpeedThreshold: 10 };
|
|
252
247
|
var VELOCITY_THRESHOLD2 = 500;
|
|
@@ -274,7 +269,7 @@ var DrawerEdgeSwipe = ({ edgeInset = 0, enabled = true, height = 300, insetBotto
|
|
|
274
269
|
}
|
|
275
270
|
});
|
|
276
271
|
const edgeStyle = vertical ? [styles2.edgeHorizontal, side === "top" ? styles2.top : styles2.bottom, { left: insetLeft, right: insetRight }] : [styles2.edgeVertical, side === "left" ? styles2.left : styles2.right, { bottom: insetBottom, top: insetTop }];
|
|
277
|
-
return /* @__PURE__ */
|
|
272
|
+
return /* @__PURE__ */ jsx2(GestureDetector2, { gesture, children: /* @__PURE__ */ jsx2(View2, { style: [...edgeStyle, webCursorStyle, enabled ? styles2.interactive : styles2.nonInteractive] }) });
|
|
278
273
|
};
|
|
279
274
|
var webCursorStyle = { cursor: Platform2.OS === "web" ? "pointer" : void 0 };
|
|
280
275
|
var styles2 = StyleSheet2.create({
|
|
@@ -303,7 +298,7 @@ var styles2 = StyleSheet2.create({
|
|
|
303
298
|
});
|
|
304
299
|
|
|
305
300
|
// src/createDrawer.tsx
|
|
306
|
-
import { jsx as
|
|
301
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
307
302
|
var noop = () => {
|
|
308
303
|
};
|
|
309
304
|
var createDrawer = ({ backdropOpacity: factoryBackdropOpacity, blockingBackdrop: factoryBlockingBackdrop, blur: factoryBlur, closeOnBackPress: factoryCloseOnBackPress, contentSize: factoryContentSize, dismissible: factoryDismissible, edgeInset = 0, height = 300, maxHeight, maxWidth, showHandle: factoryShowHandle, side = "left", width = 300, zIndex: factoryZIndex } = {}) => {
|
|
@@ -358,15 +353,15 @@ var createDrawer = ({ backdropOpacity: factoryBackdropOpacity, blockingBackdrop:
|
|
|
358
353
|
}, [isOpen, closeOnBackPress]);
|
|
359
354
|
return /* @__PURE__ */ jsxs2(DrawerActionsContext.Provider, { value: actions, children: [
|
|
360
355
|
children,
|
|
361
|
-
/* @__PURE__ */
|
|
362
|
-
/* @__PURE__ */
|
|
356
|
+
/* @__PURE__ */ jsx3(DrawerEdgeSwipe, { edgeInset, enabled: enabled && !isOpen, height: vertical ? effectiveSize : height, maxHeight, maxWidth, onOpen: open, side, translateOffset, width: vertical ? width : effectiveSize }),
|
|
357
|
+
/* @__PURE__ */ jsx3(Drawer, { backdropOpacity, blockingBackdrop, blur, contentSize, dismissible, edgeInset, height: vertical ? effectiveSize : height, maxHeight, maxWidth, onClose: () => setIsOpen(false), onClosed: () => setIsVisible(false), onMeasure: setMeasuredSize, open: isOpen, showHandle, side, translateOffset, width: vertical ? width : effectiveSize, zIndex, children: content })
|
|
363
358
|
] });
|
|
364
359
|
};
|
|
365
360
|
const useDrawer = () => useContext(DrawerActionsContext);
|
|
366
361
|
return { DrawerInstanceProvider, useDrawer };
|
|
367
362
|
};
|
|
368
363
|
var combineDrawerProviders = (...entries) => {
|
|
369
|
-
const CombinedDrawerProviders = ({ children }) => entries.reduceRight((acc, [Provider, props]) => /* @__PURE__ */
|
|
364
|
+
const CombinedDrawerProviders = ({ children }) => entries.reduceRight((acc, [Provider, props]) => /* @__PURE__ */ jsx3(Provider, { ...props, children: acc }), children);
|
|
370
365
|
return CombinedDrawerProviders;
|
|
371
366
|
};
|
|
372
367
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rific/drawer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Left/right sliding drawer with edge-swipe gestures for React Native: spring-animated, theme-aware, one factory call per drawer instance",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native",
|
|
@@ -65,7 +65,8 @@
|
|
|
65
65
|
"@infinitetoken/eslint-config": "0.2.0",
|
|
66
66
|
"@infinitetoken/jest-config": "^0.3.0",
|
|
67
67
|
"@infinitetoken/tsconfig": "^0.4.1",
|
|
68
|
-
"@rific/auto-paper": "^0.
|
|
68
|
+
"@rific/auto-paper": "^0.11.0",
|
|
69
|
+
"@rific/core": "^0.1.1",
|
|
69
70
|
"@testing-library/dom": "^10.4.1",
|
|
70
71
|
"@testing-library/react": "^16.3.2",
|
|
71
72
|
"@types/jest": "^30.0.0",
|
|
@@ -89,12 +90,12 @@
|
|
|
89
90
|
},
|
|
90
91
|
"peerDependencies": {
|
|
91
92
|
"@rific/auto-paper": ">=0.7.0",
|
|
93
|
+
"@rific/core": ">=0.1.1",
|
|
92
94
|
"react": ">=19.0.0",
|
|
93
95
|
"react-native": ">=0.83.0",
|
|
94
96
|
"react-native-gesture-handler": ">=2.20.0 <3.0.0",
|
|
95
97
|
"react-native-paper": ">=5.0.0",
|
|
96
|
-
"react-native-reanimated": ">=4.0.0"
|
|
97
|
-
"react-native-worklets": "0.10.x"
|
|
98
|
+
"react-native-reanimated": ">=4.0.0"
|
|
98
99
|
},
|
|
99
100
|
"peerDependenciesMeta": {
|
|
100
101
|
"@rific/auto-paper": {
|
package/src/DrawerConfig.tsx
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createModuleConfig } from '@rific/core'
|
|
1
2
|
import { type ComponentType, type ReactNode } from 'react'
|
|
2
3
|
import type { LayoutChangeEvent, StyleProp, ViewStyle } from 'react-native'
|
|
3
4
|
|
|
@@ -17,32 +18,17 @@ export type DrawerConfig = {
|
|
|
17
18
|
autoPaper?: AutoPaperModule
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
//
|
|
23
|
-
// this app have @rific/auto-paper?"), not per-render reactive state, so a Provider that has
|
|
24
|
-
// to exist just to thread a value through the tree is more ceremony than the problem needs.
|
|
25
|
-
// Call this directly, or mount <DrawerProvider> once near your app root (it just calls this
|
|
26
|
-
// for you). Not reactive: calling it again after components have already rendered won't
|
|
27
|
-
// retroactively update them, fine for one-time startup config, not for runtime toggling.
|
|
21
|
+
// @rific/core's createModuleConfig() supplies the module-level config singleton (configure/
|
|
22
|
+
// getConfig/Provider) every @rific package wires up the same way - see its own doc comment for
|
|
23
|
+
// why this is plain module state rather than React Context.
|
|
28
24
|
//
|
|
29
25
|
// Not to be confused with the per-instance provider createDrawer() returns
|
|
30
26
|
// (DrawerInstanceProvider): this one is app-wide, mounted once, for optional peer config;
|
|
31
27
|
// that one is per-drawer, mounted once per createDrawer() call, for that drawer's own state.
|
|
32
|
-
|
|
33
|
-
config = { ...config, ...next }
|
|
34
|
-
}
|
|
28
|
+
const drawerConfig = createModuleConfig<DrawerConfig>()
|
|
35
29
|
|
|
36
|
-
export const
|
|
30
|
+
export const configureDrawer = drawerConfig.configure
|
|
31
|
+
export const getDrawerConfig = drawerConfig.getConfig
|
|
32
|
+
export const DrawerProvider = drawerConfig.Provider
|
|
37
33
|
|
|
38
34
|
export type DrawerProviderProps = DrawerConfig & { children: ReactNode }
|
|
39
|
-
|
|
40
|
-
// Thin wrapper around configureDrawer() for consumers who'd rather mount a Provider than call
|
|
41
|
-
// a setup function directly: every @rific package wires up the same way this way. Calls
|
|
42
|
-
// configureDrawer() synchronously during render (not in an effect), so the config is already
|
|
43
|
-
// set by the time any descendant <Drawer> renders. Effects run bottom-up after children have
|
|
44
|
-
// already rendered once, which would be one render too late here.
|
|
45
|
-
export const DrawerProvider = ({ autoPaper, children }: DrawerProviderProps) => {
|
|
46
|
-
configureDrawer({ autoPaper })
|
|
47
|
-
return <>{children}</>
|
|
48
|
-
}
|