@tamagui/sheet 2.0.0-1769536410877 → 2.0.0-1769546410712
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/cjs/SheetImplementationCustom.cjs +31 -66
- package/dist/cjs/SheetImplementationCustom.js +40 -70
- package/dist/cjs/SheetImplementationCustom.js.map +1 -1
- package/dist/cjs/SheetImplementationCustom.native.js +33 -73
- package/dist/cjs/SheetImplementationCustom.native.js.map +1 -1
- package/dist/cjs/SheetScrollView.cjs +0 -2
- package/dist/cjs/SheetScrollView.js +0 -2
- package/dist/cjs/SheetScrollView.js.map +1 -1
- package/dist/cjs/SheetScrollView.native.js +0 -2
- package/dist/cjs/SheetScrollView.native.js.map +1 -1
- package/dist/cjs/useGestureHandlerPan.cjs +11 -21
- package/dist/cjs/useGestureHandlerPan.js +11 -20
- package/dist/cjs/useGestureHandlerPan.js.map +1 -1
- package/dist/cjs/useGestureHandlerPan.native.js +11 -21
- package/dist/cjs/useGestureHandlerPan.native.js.map +1 -1
- package/dist/esm/SheetImplementationCustom.js +41 -73
- package/dist/esm/SheetImplementationCustom.js.map +1 -1
- package/dist/esm/SheetImplementationCustom.mjs +33 -68
- package/dist/esm/SheetImplementationCustom.mjs.map +1 -1
- package/dist/esm/SheetImplementationCustom.native.js +35 -75
- package/dist/esm/SheetImplementationCustom.native.js.map +1 -1
- package/dist/esm/SheetScrollView.js +0 -2
- package/dist/esm/SheetScrollView.js.map +1 -1
- package/dist/esm/SheetScrollView.mjs +0 -2
- package/dist/esm/SheetScrollView.mjs.map +1 -1
- package/dist/esm/SheetScrollView.native.js +0 -2
- package/dist/esm/SheetScrollView.native.js.map +1 -1
- package/dist/esm/useGestureHandlerPan.js +11 -20
- package/dist/esm/useGestureHandlerPan.js.map +1 -1
- package/dist/esm/useGestureHandlerPan.mjs +11 -21
- package/dist/esm/useGestureHandlerPan.mjs.map +1 -1
- package/dist/esm/useGestureHandlerPan.native.js +11 -21
- package/dist/esm/useGestureHandlerPan.native.js.map +1 -1
- package/dist/jsx/SheetImplementationCustom.js +41 -73
- package/dist/jsx/SheetImplementationCustom.js.map +1 -1
- package/dist/jsx/SheetImplementationCustom.mjs +33 -68
- package/dist/jsx/SheetImplementationCustom.mjs.map +1 -1
- package/dist/jsx/SheetImplementationCustom.native.js +33 -73
- package/dist/jsx/SheetImplementationCustom.native.js.map +1 -1
- package/dist/jsx/SheetScrollView.js +0 -2
- package/dist/jsx/SheetScrollView.js.map +1 -1
- package/dist/jsx/SheetScrollView.mjs +0 -2
- package/dist/jsx/SheetScrollView.mjs.map +1 -1
- package/dist/jsx/SheetScrollView.native.js +0 -2
- package/dist/jsx/SheetScrollView.native.js.map +1 -1
- package/dist/jsx/useGestureHandlerPan.js +11 -20
- package/dist/jsx/useGestureHandlerPan.js.map +1 -1
- package/dist/jsx/useGestureHandlerPan.mjs +11 -21
- package/dist/jsx/useGestureHandlerPan.mjs.map +1 -1
- package/dist/jsx/useGestureHandlerPan.native.js +11 -21
- package/dist/jsx/useGestureHandlerPan.native.js.map +1 -1
- package/package.json +20 -20
- package/src/SheetImplementationCustom.tsx +46 -138
- package/src/SheetScrollView.tsx +0 -2
- package/src/types.tsx +0 -47
- package/src/useGestureHandlerPan.tsx +10 -57
- package/types/SheetImplementationCustom.d.ts.map +1 -1
- package/types/SheetScrollView.d.ts.map +1 -1
- package/types/types.d.ts +0 -38
- package/types/types.d.ts.map +1 -1
- package/types/useGestureHandlerPan.d.ts +1 -2
- package/types/useGestureHandlerPan.d.ts.map +1 -1
- package/dist/cjs/useKeyboardControllerSheet.cjs +0 -38
- package/dist/cjs/useKeyboardControllerSheet.js +0 -34
- package/dist/cjs/useKeyboardControllerSheet.js.map +0 -6
- package/dist/cjs/useKeyboardControllerSheet.native.js +0 -114
- package/dist/cjs/useKeyboardControllerSheet.native.js.map +0 -1
- package/dist/esm/useKeyboardControllerSheet.js +0 -18
- package/dist/esm/useKeyboardControllerSheet.js.map +0 -6
- package/dist/esm/useKeyboardControllerSheet.mjs +0 -15
- package/dist/esm/useKeyboardControllerSheet.mjs.map +0 -1
- package/dist/esm/useKeyboardControllerSheet.native.js +0 -88
- package/dist/esm/useKeyboardControllerSheet.native.js.map +0 -1
- package/dist/jsx/useKeyboardControllerSheet.js +0 -18
- package/dist/jsx/useKeyboardControllerSheet.js.map +0 -6
- package/dist/jsx/useKeyboardControllerSheet.mjs +0 -15
- package/dist/jsx/useKeyboardControllerSheet.mjs.map +0 -1
- package/dist/jsx/useKeyboardControllerSheet.native.js +0 -114
- package/dist/jsx/useKeyboardControllerSheet.native.js.map +0 -1
- package/src/useKeyboardControllerSheet.native.ts +0 -136
- package/src/useKeyboardControllerSheet.ts +0 -26
- package/types/useKeyboardControllerSheet.d.ts +0 -7
- package/types/useKeyboardControllerSheet.d.ts.map +0 -1
- package/types/useKeyboardControllerSheet.native.d.ts +0 -13
- package/types/useKeyboardControllerSheet.native.d.ts.map +0 -1
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all) __defProp(target, name, {
|
|
9
|
-
get: all[name],
|
|
10
|
-
enumerable: !0
|
|
11
|
-
});
|
|
12
|
-
},
|
|
13
|
-
__copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
15
|
-
get: () => from[key],
|
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
-
});
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
-
value: !0
|
|
22
|
-
}), mod);
|
|
23
|
-
var useKeyboardControllerSheet_native_exports = {};
|
|
24
|
-
__export(useKeyboardControllerSheet_native_exports, {
|
|
25
|
-
useKeyboardControllerSheet: () => useKeyboardControllerSheet
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(useKeyboardControllerSheet_native_exports);
|
|
28
|
-
var import_react = require("react"),
|
|
29
|
-
import_react_native = require("react-native"),
|
|
30
|
-
isKeyboardControllerEnabled = function () {
|
|
31
|
-
return !1;
|
|
32
|
-
},
|
|
33
|
-
getKeyboardControllerState = function () {
|
|
34
|
-
return {};
|
|
35
|
-
};
|
|
36
|
-
try {
|
|
37
|
-
var nativeModule = require("@tamagui/native");
|
|
38
|
-
isKeyboardControllerEnabled = nativeModule.isKeyboardControllerEnabled, getKeyboardControllerState = nativeModule.getKeyboardControllerState;
|
|
39
|
-
} catch {}
|
|
40
|
-
function useKeyboardControllerSheet(options) {
|
|
41
|
-
var {
|
|
42
|
-
enabled
|
|
43
|
-
} = options,
|
|
44
|
-
[keyboardHeight, setKeyboardHeight] = (0, import_react.useState)(0),
|
|
45
|
-
[isKeyboardVisible, setIsKeyboardVisible] = (0, import_react.useState)(!1),
|
|
46
|
-
keyboardControllerEnabled = isKeyboardControllerEnabled(),
|
|
47
|
-
pauseKeyboardHandler = (0, import_react.useRef)(!1),
|
|
48
|
-
pendingHide = (0, import_react.useRef)(!1),
|
|
49
|
-
dismissKeyboard = (0, import_react.useCallback)(function () {
|
|
50
|
-
if (import_react_native.Keyboard.dismiss(), keyboardControllerEnabled) try {
|
|
51
|
-
var _KeyboardController_dismiss,
|
|
52
|
-
{
|
|
53
|
-
KeyboardController
|
|
54
|
-
} = getKeyboardControllerState();
|
|
55
|
-
KeyboardController == null || (_KeyboardController_dismiss = KeyboardController.dismiss) === null || _KeyboardController_dismiss === void 0 || _KeyboardController_dismiss.call(KeyboardController);
|
|
56
|
-
} catch {}
|
|
57
|
-
},
|
|
58
|
-
// ignore errors from keyboard-controller
|
|
59
|
-
[keyboardControllerEnabled]),
|
|
60
|
-
flushPendingHide = (0, import_react.useCallback)(function () {
|
|
61
|
-
pendingHide.current && (pendingHide.current = !1, setIsKeyboardVisible(!1), setKeyboardHeight(0));
|
|
62
|
-
}, []);
|
|
63
|
-
return (0, import_react.useEffect)(function () {
|
|
64
|
-
if (!(!enabled || !keyboardControllerEnabled)) {
|
|
65
|
-
var {
|
|
66
|
-
KeyboardEvents
|
|
67
|
-
} = getKeyboardControllerState();
|
|
68
|
-
if (KeyboardEvents?.addListener) {
|
|
69
|
-
var showSub = KeyboardEvents.addListener("keyboardWillShow", function (e) {
|
|
70
|
-
var _e_height,
|
|
71
|
-
height = (_e_height = e?.height) !== null && _e_height !== void 0 ? _e_height : 0;
|
|
72
|
-
height > 0 && setKeyboardHeight(height), setIsKeyboardVisible(!0);
|
|
73
|
-
}),
|
|
74
|
-
hideSub = KeyboardEvents.addListener("keyboardWillHide", function () {
|
|
75
|
-
if (pauseKeyboardHandler.current) {
|
|
76
|
-
pendingHide.current = !0;
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
setIsKeyboardVisible(!1), setKeyboardHeight(0);
|
|
80
|
-
});
|
|
81
|
-
return function () {
|
|
82
|
-
var _showSub_remove, _hideSub_remove;
|
|
83
|
-
showSub == null || (_showSub_remove = showSub.remove) === null || _showSub_remove === void 0 || _showSub_remove.call(showSub), hideSub == null || (_hideSub_remove = hideSub.remove) === null || _hideSub_remove === void 0 || _hideSub_remove.call(hideSub);
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}, [enabled, keyboardControllerEnabled]), (0, import_react.useEffect)(function () {
|
|
88
|
-
if (enabled && !keyboardControllerEnabled) {
|
|
89
|
-
var showEvent = import_react_native.Platform.OS === "ios" ? "keyboardWillShow" : "keyboardDidShow",
|
|
90
|
-
hideEvent = import_react_native.Platform.OS === "ios" ? "keyboardWillHide" : "keyboardDidHide",
|
|
91
|
-
showListener = import_react_native.Keyboard.addListener(showEvent, function (e) {
|
|
92
|
-
setKeyboardHeight(e.endCoordinates.height), setIsKeyboardVisible(!0);
|
|
93
|
-
}),
|
|
94
|
-
hideListener = import_react_native.Keyboard.addListener(hideEvent, function () {
|
|
95
|
-
if (pauseKeyboardHandler.current) {
|
|
96
|
-
pendingHide.current = !0;
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
setIsKeyboardVisible(!1), setKeyboardHeight(0);
|
|
100
|
-
});
|
|
101
|
-
return function () {
|
|
102
|
-
showListener.remove(), hideListener.remove();
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
}, [enabled, keyboardControllerEnabled]), {
|
|
106
|
-
keyboardControllerEnabled,
|
|
107
|
-
keyboardHeight,
|
|
108
|
-
isKeyboardVisible,
|
|
109
|
-
dismissKeyboard,
|
|
110
|
-
pauseKeyboardHandler,
|
|
111
|
-
flushPendingHide
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
//# sourceMappingURL=useKeyboardControllerSheet.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useKeyboardControllerSheet_native_exports","__export","useKeyboardControllerSheet","module","exports","__toCommonJS","import_react","require","import_react_native","isKeyboardControllerEnabled","getKeyboardControllerState","nativeModule","options","enabled","keyboardHeight","setKeyboardHeight","useState","isKeyboardVisible","setIsKeyboardVisible","keyboardControllerEnabled","pauseKeyboardHandler","useRef","pendingHide","dismissKeyboard","useCallback","Keyboard","dismiss","_KeyboardController_dismiss","KeyboardController","call","flushPendingHide","current","useEffect","KeyboardEvents","addListener","showSub","e","_e_height","height","hideSub","_showSub_remove","_hideSub_remove","remove","showEvent","Platform","OS","hideEvent","showListener","endCoordinates","hideListener"],"sources":["../../src/useKeyboardControllerSheet.native.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,yCAAA;AAAAC,QAAA,CAAA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,OAEDb,YAAA,CAAA0B,SAAA,EAAU,YAAW;IACjB,IAAKnB,OAAA,IACD,CAAAM,yBAAA,EACJ;MAAA,IAAIwB,SAAA,GAAYnC,mBAAA,CAAAoC,QAAA,CAASC,EAAA,KAAO,QAAQ,qBAAqB;QACzDC,SAAA,GAAYtC,mBAAA,CAAAoC,QAAA,CAASC,EAAA,KAAO,QAAQ,qBAAqB;QACzDE,YAAA,GAAevC,mBAAA,CAAAiB,QAAA,CAASS,WAAA,CAAYS,SAAA,EAAW,UAASP,CAAA,EAAG;UAC3DrB,iBAAA,CAAkBqB,CAAA,CAAEY,cAAA,CAAeV,MAAM,GACzCpB,oBAAA,CAAqB,EAAI;QAC7B,CAAC;QACG+B,YAAA,GAAezC,mBAAA,CAAAiB,QAAA,CAASS,WAAA,CAAYY,SAAA,EAAW,YAAW;UAC1D,IAAI1B,oBAAA,CAAqBW,OAAA,EAAS;YAC9BT,WAAA,CAAYS,OAAA,GAAU;YACtB;UACJ;UACAb,oBAAA,CAAqB,EAAK,GAC1BH,iBAAA,CAAkB,CAAC;QACvB,CAAC;MACD,OAAO,YAAW;QACdgC,YAAA,CAAaL,MAAA,CAAO,GACpBO,YAAA,CAAaP,MAAA,CAAO;MACxB;IAAA;EACJ,GAAG,CACC7B,OAAA,EACAM,yBAAA,CACH,GACM;IACHA,yBAAA;IACAL,cAAA;IACAG,iBAAA;IACAM,eAAA;IACAH,oBAAA;IACAU;EACJ;AACJ","ignoreList":[]}
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Native implementation of keyboard controller sheet hook.
|
|
3
|
-
*
|
|
4
|
-
* Simplified to just track keyboard state (height, visibility).
|
|
5
|
-
* Position animation is handled by SheetImplementationCustom via
|
|
6
|
-
* keyboard-adjusted positions — matching the react-native-actions-sheet pattern.
|
|
7
|
-
*
|
|
8
|
-
* Uses react-native-keyboard-controller events when available,
|
|
9
|
-
* falls back to basic Keyboard API otherwise.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import { useCallback, useEffect, useRef, useState } from 'react'
|
|
13
|
-
import { Keyboard, Platform } from 'react-native'
|
|
14
|
-
import type {
|
|
15
|
-
KeyboardControllerSheetOptions,
|
|
16
|
-
KeyboardControllerSheetResult,
|
|
17
|
-
} from './types'
|
|
18
|
-
|
|
19
|
-
// lazy import state accessors
|
|
20
|
-
let isKeyboardControllerEnabled: () => boolean = () => false
|
|
21
|
-
let getKeyboardControllerState: () => any = () => ({})
|
|
22
|
-
|
|
23
|
-
try {
|
|
24
|
-
const nativeModule = require('@tamagui/native')
|
|
25
|
-
isKeyboardControllerEnabled = nativeModule.isKeyboardControllerEnabled
|
|
26
|
-
getKeyboardControllerState = nativeModule.getKeyboardControllerState
|
|
27
|
-
} catch {
|
|
28
|
-
// @tamagui/native not available
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function useKeyboardControllerSheet(
|
|
32
|
-
options: KeyboardControllerSheetOptions
|
|
33
|
-
): KeyboardControllerSheetResult {
|
|
34
|
-
const { enabled } = options
|
|
35
|
-
|
|
36
|
-
const [keyboardHeight, setKeyboardHeight] = useState(0)
|
|
37
|
-
const [isKeyboardVisible, setIsKeyboardVisible] = useState(false)
|
|
38
|
-
const keyboardControllerEnabled = isKeyboardControllerEnabled()
|
|
39
|
-
|
|
40
|
-
// action-sheet pattern: pause keyboard hide events during drag
|
|
41
|
-
// when true, keyboard hide events are ignored so isKeyboardVisible stays true
|
|
42
|
-
// and activePositions don't revert mid-gesture
|
|
43
|
-
const pauseKeyboardHandler = useRef(false)
|
|
44
|
-
// tracks if a keyboard hide event was suppressed while paused
|
|
45
|
-
const pendingHide = useRef(false)
|
|
46
|
-
|
|
47
|
-
// dismiss keyboard helper
|
|
48
|
-
const dismissKeyboard = useCallback(() => {
|
|
49
|
-
Keyboard.dismiss()
|
|
50
|
-
if (keyboardControllerEnabled) {
|
|
51
|
-
try {
|
|
52
|
-
const { KeyboardController } = getKeyboardControllerState()
|
|
53
|
-
KeyboardController?.dismiss?.()
|
|
54
|
-
} catch {
|
|
55
|
-
// ignore errors from keyboard-controller
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}, [keyboardControllerEnabled])
|
|
59
|
-
|
|
60
|
-
// flush any keyboard hide that was suppressed during drag.
|
|
61
|
-
// called when drag ends to reconcile actual keyboard state.
|
|
62
|
-
const flushPendingHide = useCallback(() => {
|
|
63
|
-
if (pendingHide.current) {
|
|
64
|
-
pendingHide.current = false
|
|
65
|
-
setIsKeyboardVisible(false)
|
|
66
|
-
setKeyboardHeight(0)
|
|
67
|
-
}
|
|
68
|
-
}, [])
|
|
69
|
-
|
|
70
|
-
// keyboard-controller event listeners (preferred when available)
|
|
71
|
-
useEffect(() => {
|
|
72
|
-
if (!enabled || !keyboardControllerEnabled) return
|
|
73
|
-
|
|
74
|
-
const { KeyboardEvents } = getKeyboardControllerState()
|
|
75
|
-
if (!KeyboardEvents?.addListener) return
|
|
76
|
-
|
|
77
|
-
const showSub = KeyboardEvents.addListener('keyboardWillShow', (e: any) => {
|
|
78
|
-
const height = e?.height ?? 0
|
|
79
|
-
if (height > 0) {
|
|
80
|
-
setKeyboardHeight(height)
|
|
81
|
-
}
|
|
82
|
-
setIsKeyboardVisible(true)
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
const hideSub = KeyboardEvents.addListener('keyboardWillHide', () => {
|
|
86
|
-
if (pauseKeyboardHandler.current) {
|
|
87
|
-
pendingHide.current = true
|
|
88
|
-
return
|
|
89
|
-
}
|
|
90
|
-
setIsKeyboardVisible(false)
|
|
91
|
-
setKeyboardHeight(0)
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
return () => {
|
|
95
|
-
showSub?.remove?.()
|
|
96
|
-
hideSub?.remove?.()
|
|
97
|
-
}
|
|
98
|
-
}, [enabled, keyboardControllerEnabled])
|
|
99
|
-
|
|
100
|
-
// fallback to basic Keyboard API when keyboard-controller not available
|
|
101
|
-
useEffect(() => {
|
|
102
|
-
if (!enabled) return
|
|
103
|
-
if (keyboardControllerEnabled) return
|
|
104
|
-
|
|
105
|
-
const showEvent = Platform.OS === 'ios' ? 'keyboardWillShow' : 'keyboardDidShow'
|
|
106
|
-
const hideEvent = Platform.OS === 'ios' ? 'keyboardWillHide' : 'keyboardDidHide'
|
|
107
|
-
|
|
108
|
-
const showListener = Keyboard.addListener(showEvent, (e) => {
|
|
109
|
-
setKeyboardHeight(e.endCoordinates.height)
|
|
110
|
-
setIsKeyboardVisible(true)
|
|
111
|
-
})
|
|
112
|
-
|
|
113
|
-
const hideListener = Keyboard.addListener(hideEvent, () => {
|
|
114
|
-
if (pauseKeyboardHandler.current) {
|
|
115
|
-
pendingHide.current = true
|
|
116
|
-
return
|
|
117
|
-
}
|
|
118
|
-
setIsKeyboardVisible(false)
|
|
119
|
-
setKeyboardHeight(0)
|
|
120
|
-
})
|
|
121
|
-
|
|
122
|
-
return () => {
|
|
123
|
-
showListener.remove()
|
|
124
|
-
hideListener.remove()
|
|
125
|
-
}
|
|
126
|
-
}, [enabled, keyboardControllerEnabled])
|
|
127
|
-
|
|
128
|
-
return {
|
|
129
|
-
keyboardControllerEnabled,
|
|
130
|
-
keyboardHeight,
|
|
131
|
-
isKeyboardVisible,
|
|
132
|
-
dismissKeyboard,
|
|
133
|
-
pauseKeyboardHandler,
|
|
134
|
-
flushPendingHide,
|
|
135
|
-
}
|
|
136
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Web stub for keyboard controller sheet hook.
|
|
3
|
-
* Returns no-op values since keyboard-controller is native-only.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { useRef } from 'react'
|
|
7
|
-
import type {
|
|
8
|
-
KeyboardControllerSheetOptions,
|
|
9
|
-
KeyboardControllerSheetResult,
|
|
10
|
-
} from './types'
|
|
11
|
-
|
|
12
|
-
const noop = () => {}
|
|
13
|
-
|
|
14
|
-
export function useKeyboardControllerSheet(
|
|
15
|
-
_options: KeyboardControllerSheetOptions
|
|
16
|
-
): KeyboardControllerSheetResult {
|
|
17
|
-
const pauseKeyboardHandler = useRef(false)
|
|
18
|
-
return {
|
|
19
|
-
keyboardControllerEnabled: false,
|
|
20
|
-
keyboardHeight: 0,
|
|
21
|
-
isKeyboardVisible: false,
|
|
22
|
-
dismissKeyboard: noop,
|
|
23
|
-
pauseKeyboardHandler,
|
|
24
|
-
flushPendingHide: noop,
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Web stub for keyboard controller sheet hook.
|
|
3
|
-
* Returns no-op values since keyboard-controller is native-only.
|
|
4
|
-
*/
|
|
5
|
-
import type { KeyboardControllerSheetOptions, KeyboardControllerSheetResult } from './types';
|
|
6
|
-
export declare function useKeyboardControllerSheet(_options: KeyboardControllerSheetOptions): KeyboardControllerSheetResult;
|
|
7
|
-
//# sourceMappingURL=useKeyboardControllerSheet.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useKeyboardControllerSheet.d.ts","sourceRoot":"","sources":["../src/useKeyboardControllerSheet.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACV,8BAA8B,EAC9B,6BAA6B,EAC9B,MAAM,SAAS,CAAA;AAIhB,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,8BAA8B,GACvC,6BAA6B,CAU/B"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Native implementation of keyboard controller sheet hook.
|
|
3
|
-
*
|
|
4
|
-
* Simplified to just track keyboard state (height, visibility).
|
|
5
|
-
* Position animation is handled by SheetImplementationCustom via
|
|
6
|
-
* keyboard-adjusted positions — matching the react-native-actions-sheet pattern.
|
|
7
|
-
*
|
|
8
|
-
* Uses react-native-keyboard-controller events when available,
|
|
9
|
-
* falls back to basic Keyboard API otherwise.
|
|
10
|
-
*/
|
|
11
|
-
import type { KeyboardControllerSheetOptions, KeyboardControllerSheetResult } from './types';
|
|
12
|
-
export declare function useKeyboardControllerSheet(options: KeyboardControllerSheetOptions): KeyboardControllerSheetResult;
|
|
13
|
-
//# sourceMappingURL=useKeyboardControllerSheet.native.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useKeyboardControllerSheet.native.d.ts","sourceRoot":"","sources":["../src/useKeyboardControllerSheet.native.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EACV,8BAA8B,EAC9B,6BAA6B,EAC9B,MAAM,SAAS,CAAA;AAchB,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,8BAA8B,GACtC,6BAA6B,CAuG/B"}
|