@buoy-gg/bottom-sheet 7.0.41 → 7.0.42

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.
@@ -1,86 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.MIN_HEIGHT = exports.FLOATING_WIDTH = exports.FLOATING_MIN_HEIGHT = exports.FLOATING_HEIGHT = exports.DEFAULT_HEIGHT = void 0;
7
- exports.floatingMinWidth = floatingMinWidth;
8
- exports.resizeCorner = resizeCorner;
9
- exports.shouldCloseOnRelease = shouldCloseOnRelease;
10
- /**
11
- * Platform-free geometry for the BottomSheet.
12
- *
13
- * Extracted verbatim from the native implementation so the web port
14
- * (BottomSheet.web.tsx) shares the exact clamping behavior:
15
- * - corner-resize math: BottomSheet.tsx createResizeHandler (lines ~767-869)
16
- * - close heuristic: BottomSheet.tsx onPanResponderRelease (lines ~706-708)
17
- * The native file still carries its own inline copy; if you change one,
18
- * change both (candidate for a later native refactor to import this).
19
- */
20
-
21
- const MIN_HEIGHT = exports.MIN_HEIGHT = 100;
22
- const DEFAULT_HEIGHT = exports.DEFAULT_HEIGHT = 400;
23
- const FLOATING_WIDTH = exports.FLOATING_WIDTH = 380;
24
- const FLOATING_HEIGHT = exports.FLOATING_HEIGHT = 500;
25
- const FLOATING_MIN_HEIGHT = exports.FLOATING_MIN_HEIGHT = 80;
26
-
27
- /** Native: FLOATING_MIN_WIDTH = SCREEN.width * 0.25 */
28
- function floatingMinWidth(screenWidth) {
29
- return screenWidth * 0.25;
30
- }
31
- /**
32
- * 4-corner resize with safe-area-clamped bounds and min sizes.
33
- * Mirrors the switch in the native createResizeHandler exactly.
34
- */
35
- function resizeCorner(corner, start, dx, dy, container, insets, minWidth, minHeight = FLOATING_MIN_HEIGHT) {
36
- const minLeft = Math.max(0, insets.left || 0);
37
- const maxRight = container.width - Math.max(0, insets.right || 0);
38
- const minTop = Math.max(0, insets.top || 0);
39
- const maxBottom = container.height - Math.max(0, insets.bottom || 0);
40
- const startRight = start.left + start.width;
41
- const startBottom = start.top + start.height;
42
- let left = start.left;
43
- let top = start.top;
44
- let right = startRight;
45
- let bottom = startBottom;
46
- switch (corner) {
47
- case 'topLeft':
48
- {
49
- left = Math.max(minLeft, Math.min(start.left + dx, startRight - minWidth));
50
- top = Math.max(minTop, Math.min(start.top + dy, startBottom - minHeight));
51
- break;
52
- }
53
- case 'topRight':
54
- {
55
- right = Math.min(maxRight, Math.max(startRight + dx, start.left + minWidth));
56
- top = Math.max(minTop, Math.min(start.top + dy, startBottom - minHeight));
57
- break;
58
- }
59
- case 'bottomLeft':
60
- {
61
- left = Math.max(minLeft, Math.min(start.left + dx, startRight - minWidth));
62
- bottom = Math.min(maxBottom, Math.max(startBottom + dy, start.top + minHeight));
63
- break;
64
- }
65
- case 'bottomRight':
66
- {
67
- right = Math.min(maxRight, Math.max(startRight + dx, start.left + minWidth));
68
- bottom = Math.min(maxBottom, Math.max(startBottom + dy, start.top + minHeight));
69
- break;
70
- }
71
- }
72
- return {
73
- left,
74
- top,
75
- width: Math.max(minWidth, right - left),
76
- height: Math.max(minHeight, bottom - top)
77
- };
78
- }
79
-
80
- /**
81
- * Drag-to-dismiss heuristic. Native units: vy in px/ms (RN gestureState.vy),
82
- * dy total drag in px.
83
- */
84
- function shouldCloseOnRelease(vy, dy, finalHeight, minHeight) {
85
- return vy > 0.8 && dy > 50 || dy > 150 && finalHeight <= minHeight;
86
- }
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.MIN_HEIGHT=exports.FLOATING_WIDTH=exports.FLOATING_MIN_HEIGHT=exports.FLOATING_HEIGHT=exports.DEFAULT_HEIGHT=void 0;exports.floatingMinWidth=floatingMinWidth;exports.resizeCorner=resizeCorner;exports.shouldCloseOnRelease=shouldCloseOnRelease;const MIN_HEIGHT=exports.MIN_HEIGHT=100;const DEFAULT_HEIGHT=exports.DEFAULT_HEIGHT=400;const FLOATING_WIDTH=exports.FLOATING_WIDTH=380;const FLOATING_HEIGHT=exports.FLOATING_HEIGHT=500;const FLOATING_MIN_HEIGHT=exports.FLOATING_MIN_HEIGHT=80;function floatingMinWidth(a){return a*.25}function resizeCorner(a,t,o,e,s,x,h,M=FLOATING_MIN_HEIGHT){const H=Math.max(0,x.left||0);const l=s.width-Math.max(0,x.right||0);const G=Math.max(0,x.top||0);const c=s.height-Math.max(0,x.bottom||0);const I=t.left+t.width;const T=t.top+t.height;let n=t.left;let p=t.top;let m=I;let r=T;switch(a){case"topLeft":{n=Math.max(H,Math.min(t.left+o,I-h));p=Math.max(G,Math.min(t.top+e,T-M));break}case"topRight":{m=Math.min(l,Math.max(I+o,t.left+h));p=Math.max(G,Math.min(t.top+e,T-M));break}case"bottomLeft":{n=Math.max(H,Math.min(t.left+o,I-h));r=Math.min(c,Math.max(T+e,t.top+M));break}case"bottomRight":{m=Math.min(l,Math.max(I+o,t.left+h));r=Math.min(c,Math.max(T+e,t.top+M));break}}return{left:n,top:p,width:Math.max(h,m-n),height:Math.max(M,r-p)}}function shouldCloseOnRelease(a,t,o,e){return a>.8&&t>50||t>150&&o<=e}
@@ -1,52 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useMultiTap = useMultiTap;
7
- var _react = require("react");
8
- /**
9
- * Platform-free tap-count recognizer shared by the BottomSheet header and
10
- * floating window: 2 taps toggles mode, 3+ closes. Mirrors the native
11
- * implementation (BottomSheet.tsx ModalHeader.handleHeaderTap /
12
- * handleFloatingTap): 500ms reset window, 300ms settle timer.
13
- */
14
-
15
- function useMultiTap(onDouble, onTriple) {
16
- const lastTapRef = (0, _react.useRef)(0);
17
- const tapCountRef = (0, _react.useRef)(0);
18
- const timeoutRef = (0, _react.useRef)(null);
19
- // Latest-ref pattern so the returned handler stays stable without
20
- // re-arming timers when callbacks change identity.
21
- const handlersRef = (0, _react.useRef)({
22
- onDouble,
23
- onTriple
24
- });
25
- handlersRef.current = {
26
- onDouble,
27
- onTriple
28
- };
29
- (0, _react.useEffect)(() => {
30
- return () => {
31
- if (timeoutRef.current) clearTimeout(timeoutRef.current);
32
- };
33
- }, []);
34
- const tapHandlerRef = (0, _react.useRef)(() => {
35
- const now = Date.now();
36
- if (now - lastTapRef.current > 500) {
37
- tapCountRef.current = 0;
38
- }
39
- tapCountRef.current++;
40
- lastTapRef.current = now;
41
- if (timeoutRef.current) clearTimeout(timeoutRef.current);
42
- timeoutRef.current = setTimeout(() => {
43
- if (tapCountRef.current === 2) {
44
- handlersRef.current.onDouble();
45
- } else if (tapCountRef.current >= 3) {
46
- handlersRef.current.onTriple();
47
- }
48
- tapCountRef.current = 0;
49
- }, 300);
50
- });
51
- return tapHandlerRef.current;
52
- }
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.useMultiTap=useMultiTap;var _react=require("react");function useMultiTap(u,n){const c=(0,_react.useRef)(0);const e=(0,_react.useRef)(0);const r=(0,_react.useRef)(null);const t=(0,_react.useRef)({onDouble:u,onTriple:n});t.current={onDouble:u,onTriple:n};(0,_react.useEffect)(()=>{return()=>{if(r.current)clearTimeout(r.current)}},[]);const f=(0,_react.useRef)(()=>{const s=Date.now();if(s-c.current>500){e.current=0}e.current++;c.current=s;if(r.current)clearTimeout(r.current);r.current=setTimeout(()=>{if(e.current===2){t.current.onDouble()}else if(e.current>=3){t.current.onTriple()}e.current=0},300)});return f.current}
@@ -1,12 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "BottomSheet", {
7
- enumerable: true,
8
- get: function () {
9
- return _BottomSheet.BottomSheet;
10
- }
11
- });
12
- var _BottomSheet = require("./components/BottomSheet");
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"BottomSheet",{enumerable:true,get:function(){return _BottomSheet.BottomSheet}});var _BottomSheet=require("./components/BottomSheet");
@@ -1,12 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "BottomSheet", {
7
- enumerable: true,
8
- get: function () {
9
- return _BottomSheet.BottomSheet;
10
- }
11
- });
12
- var _BottomSheet = require("./components/BottomSheet.web");
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"BottomSheet",{enumerable:true,get:function(){return _BottomSheet.BottomSheet}});var _BottomSheet=require("./components/BottomSheet.web");