@rific/drawer 0.4.4 → 0.5.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.
package/README.md CHANGED
@@ -184,6 +184,8 @@ If you're driving `Drawer` standalone with `contentSize` and want `DrawerEdgeSwi
184
184
 
185
185
  Both also take `maxHeight`/`maxWidth` (see [Expandable sheets](#expandable-sheets)) — pass the same values to both, same as `height`/`width`, so `DrawerEdgeSwipe`'s edge-swipe-to-open lands at the same rest position `Drawer`'s own tap-to-open does. Same for `edgeInset` (see [Safe area](#safe-area)): pass the same value to both, or their rest/max geometry will disagree.
186
186
 
187
+ `DrawerEdgeSwipe` alone also takes `insetTop`/`insetBottom`/`insetLeft`/`insetRight` (all default `0`), which shrink the edge-swipe hitbox's span along its long axis — only the pair perpendicular to `side`'s own strip thickness applies: `insetTop`/`insetBottom` for a `left`/`right` drawer's vertical strip, `insetLeft`/`insetRight` for a `top`/`bottom` drawer's horizontal one; the other pair is ignored. Use these to carve out chrome near the edge — a header or tab bar — that would otherwise have its own taps stolen by a hitbox spanning the full screen. Don't confuse this with `edgeInset` (see [Safe area](#safe-area)): that shrinks the *basis* a percentage size resolves against, on both `Drawer` and `DrawerEdgeSwipe`; these inset props only trim `DrawerEdgeSwipe`'s own hitbox span and have no equivalent on `Drawer` or `createDrawer()`.
188
+
187
189
  `Drawer` also takes an `onClosed?: () => void`, fired once the close spring actually settles rather than the instant `open` flips to `false`: this is what powers `isVisible` above; drive it yourself the same way if you're managing `open` state by hand. `onOpened?: () => void` is the same idea for the open direction: fired once the panel has actually finished sliding in, e.g. to autofocus a field inside `content` only once it's actually on screen. `createDrawer()` doesn't need it internally (nothing downstream waits on the open side settling the way `isVisible` waits on the close side), so it's only available driving `Drawer` directly.
188
190
 
189
191
  `Drawer` also takes the same `zIndex` prop described in [Stacking multiple drawers](#stacking-multiple-drawers), useful if you're rendering more than one standalone `Drawer` (or mixing standalone `Drawer`s with `createDrawer()` ones) that might be open at the same time.
package/dist/index.d.mts CHANGED
@@ -106,6 +106,10 @@ type DrawerEdgeSwipeProps = {
106
106
  edgeInset?: number;
107
107
  enabled?: boolean;
108
108
  height?: DrawerDimension;
109
+ insetBottom?: number;
110
+ insetLeft?: number;
111
+ insetRight?: number;
112
+ insetTop?: number;
109
113
  maxHeight?: DrawerDimension;
110
114
  maxWidth?: DrawerDimension;
111
115
  onOpen: () => void;
@@ -113,6 +117,6 @@ type DrawerEdgeSwipeProps = {
113
117
  translateOffset: SharedValue<number>;
114
118
  width?: DrawerDimension;
115
119
  };
116
- declare const DrawerEdgeSwipe: ({ edgeInset, enabled, height, maxHeight, maxWidth, onOpen, side, translateOffset, width }: DrawerEdgeSwipeProps) => react.JSX.Element;
120
+ declare const DrawerEdgeSwipe: ({ edgeInset, enabled, height, insetBottom, insetLeft, insetRight, insetTop, maxHeight, maxWidth, onOpen, side, translateOffset, width }: DrawerEdgeSwipeProps) => react.JSX.Element;
117
121
 
118
122
  export { type AutoPaperModule, type CreateDrawerOptions, type CreateDrawerResult, Drawer, type DrawerActions, type DrawerConfig, type DrawerDimension, DrawerEdgeSwipe, type DrawerEdgeSwipeProps, type DrawerInstanceProviderComponent, type DrawerInstanceProviderProps, type DrawerProps, DrawerProvider, type DrawerProviderProps, type DrawerSide, combineDrawerProviders, configureDrawer, createDrawer, getDrawerConfig };
package/dist/index.d.ts CHANGED
@@ -106,6 +106,10 @@ type DrawerEdgeSwipeProps = {
106
106
  edgeInset?: number;
107
107
  enabled?: boolean;
108
108
  height?: DrawerDimension;
109
+ insetBottom?: number;
110
+ insetLeft?: number;
111
+ insetRight?: number;
112
+ insetTop?: number;
109
113
  maxHeight?: DrawerDimension;
110
114
  maxWidth?: DrawerDimension;
111
115
  onOpen: () => void;
@@ -113,6 +117,6 @@ type DrawerEdgeSwipeProps = {
113
117
  translateOffset: SharedValue<number>;
114
118
  width?: DrawerDimension;
115
119
  };
116
- declare const DrawerEdgeSwipe: ({ edgeInset, enabled, height, maxHeight, maxWidth, onOpen, side, translateOffset, width }: DrawerEdgeSwipeProps) => react.JSX.Element;
120
+ declare const DrawerEdgeSwipe: ({ edgeInset, enabled, height, insetBottom, insetLeft, insetRight, insetTop, maxHeight, maxWidth, onOpen, side, translateOffset, width }: DrawerEdgeSwipeProps) => react.JSX.Element;
117
121
 
118
122
  export { type AutoPaperModule, type CreateDrawerOptions, type CreateDrawerResult, Drawer, type DrawerActions, type DrawerConfig, type DrawerDimension, DrawerEdgeSwipe, type DrawerEdgeSwipeProps, type DrawerInstanceProviderComponent, type DrawerInstanceProviderProps, type DrawerProps, DrawerProvider, type DrawerProviderProps, type DrawerSide, combineDrawerProviders, configureDrawer, createDrawer, getDrawerConfig };
package/dist/index.js CHANGED
@@ -281,7 +281,7 @@ var import_jsx_runtime3 = require("react/jsx-runtime");
281
281
  var EDGE_WIDTH = 24;
282
282
  var SPRING2 = { damping: 45, overshootClamping: true, stiffness: 500, restDisplacementThreshold: 0.5, restSpeedThreshold: 10 };
283
283
  var VELOCITY_THRESHOLD2 = 500;
284
- var DrawerEdgeSwipe = ({ edgeInset = 0, enabled = true, height = 300, maxHeight, maxWidth, onOpen, side = "left", translateOffset, width = 300 }) => {
284
+ var DrawerEdgeSwipe = ({ edgeInset = 0, enabled = true, height = 300, insetBottom = 0, insetLeft = 0, insetRight = 0, insetTop = 0, maxHeight, maxWidth, onOpen, side = "left", translateOffset, width = 300 }) => {
285
285
  const vertical = isVerticalSide(side);
286
286
  const { closedOffset, effectiveSize, restOffset } = useDrawerSize(side, vertical ? height : width, vertical ? maxHeight : maxWidth, edgeInset);
287
287
  const openDirection = getOpenDirection(side);
@@ -304,7 +304,7 @@ var DrawerEdgeSwipe = ({ edgeInset = 0, enabled = true, height = 300, maxHeight,
304
304
  translateOffset.value = (0, import_react_native_reanimated2.withSpring)(closedOffset, SPRING2);
305
305
  }
306
306
  });
307
- const edgeStyle = vertical ? [styles2.edgeHorizontal, side === "top" ? styles2.top : styles2.bottom] : [styles2.edgeVertical, side === "left" ? styles2.left : styles2.right];
307
+ 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 }];
308
308
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native_gesture_handler2.GestureDetector, { gesture, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native3.View, { style: [...edgeStyle, webCursorStyle, enabled ? styles2.interactive : styles2.nonInteractive] }) });
309
309
  };
310
310
  var webCursorStyle = { cursor: import_react_native3.Platform.OS === "web" ? "pointer" : void 0 };
package/dist/index.mjs CHANGED
@@ -239,7 +239,7 @@ import { jsx as jsx3 } from "react/jsx-runtime";
239
239
  var EDGE_WIDTH = 24;
240
240
  var SPRING2 = { damping: 45, overshootClamping: true, stiffness: 500, restDisplacementThreshold: 0.5, restSpeedThreshold: 10 };
241
241
  var VELOCITY_THRESHOLD2 = 500;
242
- var DrawerEdgeSwipe = ({ edgeInset = 0, enabled = true, height = 300, maxHeight, maxWidth, onOpen, side = "left", translateOffset, width = 300 }) => {
242
+ var DrawerEdgeSwipe = ({ edgeInset = 0, enabled = true, height = 300, insetBottom = 0, insetLeft = 0, insetRight = 0, insetTop = 0, maxHeight, maxWidth, onOpen, side = "left", translateOffset, width = 300 }) => {
243
243
  const vertical = isVerticalSide(side);
244
244
  const { closedOffset, effectiveSize, restOffset } = useDrawerSize(side, vertical ? height : width, vertical ? maxHeight : maxWidth, edgeInset);
245
245
  const openDirection = getOpenDirection(side);
@@ -262,7 +262,7 @@ var DrawerEdgeSwipe = ({ edgeInset = 0, enabled = true, height = 300, maxHeight,
262
262
  translateOffset.value = withSpring2(closedOffset, SPRING2);
263
263
  }
264
264
  });
265
- const edgeStyle = vertical ? [styles2.edgeHorizontal, side === "top" ? styles2.top : styles2.bottom] : [styles2.edgeVertical, side === "left" ? styles2.left : styles2.right];
265
+ 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 }];
266
266
  return /* @__PURE__ */ jsx3(GestureDetector2, { gesture, children: /* @__PURE__ */ jsx3(View2, { style: [...edgeStyle, webCursorStyle, enabled ? styles2.interactive : styles2.nonInteractive] }) });
267
267
  };
268
268
  var webCursorStyle = { cursor: Platform2.OS === "web" ? "pointer" : void 0 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rific/drawer",
3
- "version": "0.4.4",
3
+ "version": "0.5.0",
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",
@@ -45,9 +45,8 @@
45
45
  "!src/__mocks__"
46
46
  ],
47
47
  "scripts": {
48
- "build": "tsup src/index.ts --format cjs,esm --dts --clean",
49
- "build:watch": "tsup src/index.ts --format cjs,esm --dts --watch",
50
- "ci": "npm run lint && npm test && npm run typecheck && npm run build",
48
+ "build": "tsup",
49
+ "build:watch": "tsup --watch",
51
50
  "fix": "eslint --fix",
52
51
  "lint": "eslint",
53
52
  "prepublishOnly": "npm run build",
@@ -58,13 +57,15 @@
58
57
  "test": "jest",
59
58
  "test:watch": "jest --watchAll",
60
59
  "typecheck": "tsc --noEmit",
61
- "preversion": "npm run ci"
60
+ "verify": "npm run lint && npm test && npm run typecheck && npm run build",
61
+ "preversion": "npm run verify"
62
62
  },
63
63
  "prettier": "@infinitetoken/eslint-config/prettier",
64
64
  "devDependencies": {
65
- "@infinitetoken/eslint-config": "^0.1.4",
66
- "@infinitetoken/tsconfig": "^0.1.1",
67
- "@rific/auto-paper": "^0.10.1",
65
+ "@infinitetoken/eslint-config": "0.2.0",
66
+ "@infinitetoken/jest-config": "^0.3.0",
67
+ "@infinitetoken/tsconfig": "^0.4.1",
68
+ "@rific/auto-paper": "^0.10.3",
68
69
  "@testing-library/dom": "^10.4.1",
69
70
  "@testing-library/react": "^16.3.2",
70
71
  "@types/jest": "^30.0.0",
@@ -81,9 +82,8 @@
81
82
  "react-native-gesture-handler": "^2.20.0",
82
83
  "react-native-paper": "^5.12.0",
83
84
  "react-native-reanimated": "^4.5.1",
85
+ "react-native-safe-area-context": "^5.5.2",
84
86
  "react-native-worklets": "^0.10.3",
85
- "ts-jest": "^29.4.9",
86
- "ts-node": "^10.9.2",
87
87
  "tsup": "^8.0.0",
88
88
  "typescript": "^6.0.3"
89
89
  },
@@ -19,6 +19,15 @@ export type DrawerEdgeSwipeProps = {
19
19
  edgeInset?: number
20
20
  enabled?: boolean
21
21
  height?: DrawerDimension
22
+ // Shrink the strip's span along its long axis, to clear chrome (a header, a tab bar, ...) that
23
+ // would otherwise have its own touches stolen by this gesture — only the pair perpendicular to
24
+ // `side`'s own strip thickness applies: insetTop/insetBottom for a left/right drawer's vertical
25
+ // strip, insetLeft/insetRight for a top/bottom drawer's horizontal one. The other pair is
26
+ // ignored. All default to 0 (the strip's prior, full-length behavior).
27
+ insetBottom?: number
28
+ insetLeft?: number
29
+ insetRight?: number
30
+ insetTop?: number
22
31
  // Mirrors Drawer's own maxHeight: when set, an edge swipe still only opens to `height` (the rest
23
32
  // size), not all the way to this ceiling — matching Drawer's tap-to-open behavior, which also
24
33
  // lands at rest. Reaching past rest, up to maxHeight, is only ever done via Drawer's own handle.
@@ -31,7 +40,7 @@ export type DrawerEdgeSwipeProps = {
31
40
  width?: DrawerDimension
32
41
  }
33
42
 
34
- export const DrawerEdgeSwipe = ({ edgeInset = 0, enabled = true, height = 300, maxHeight, maxWidth, onOpen, side = 'left', translateOffset, width = 300 }: DrawerEdgeSwipeProps) => {
43
+ export const DrawerEdgeSwipe = ({ edgeInset = 0, enabled = true, height = 300, insetBottom = 0, insetLeft = 0, insetRight = 0, insetTop = 0, maxHeight, maxWidth, onOpen, side = 'left', translateOffset, width = 300 }: DrawerEdgeSwipeProps) => {
35
44
  const vertical = isVerticalSide(side)
36
45
  const { closedOffset, effectiveSize, restOffset } = useDrawerSize(side, vertical ? height : width, vertical ? maxHeight : maxWidth, edgeInset)
37
46
  const openDirection = getOpenDirection(side)
@@ -71,7 +80,7 @@ export const DrawerEdgeSwipe = ({ edgeInset = 0, enabled = true, height = 300, m
71
80
  }
72
81
  })
73
82
 
74
- const edgeStyle = vertical ? [styles.edgeHorizontal, side === 'top' ? styles.top : styles.bottom] : [styles.edgeVertical, side === 'left' ? styles.left : styles.right]
83
+ const edgeStyle = vertical ? [styles.edgeHorizontal, side === 'top' ? styles.top : styles.bottom, { left: insetLeft, right: insetRight }] : [styles.edgeVertical, side === 'left' ? styles.left : styles.right, { bottom: insetBottom, top: insetTop }]
75
84
 
76
85
  return (
77
86
  <GestureDetector gesture={gesture}>