@tamagui/use-keyboard-visible 2.7.7 → 3.0.0-beta.1097.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/cjs/index.cjs +14 -18
- package/dist/cjs/index.native.cjs +26 -0
- package/dist/cjs/index.native.js +14 -17
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/useKeyboardVisible.cjs +33 -41
- package/dist/cjs/useKeyboardVisible.native.cjs +49 -0
- package/dist/cjs/useKeyboardVisible.native.js +34 -42
- package/dist/cjs/useKeyboardVisible.native.js.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.mjs +2 -2
- package/dist/esm/index.native.js +2 -2
- package/dist/esm/useKeyboardVisible.mjs +18 -15
- package/dist/esm/useKeyboardVisible.mjs.map +1 -1
- package/dist/esm/useKeyboardVisible.native.js +17 -15
- package/dist/esm/useKeyboardVisible.native.js.map +1 -1
- package/package.json +7 -5
- package/src/useKeyboardVisible.native.ts +22 -0
- package/src/useKeyboardVisible.ts +24 -11
- package/types/useKeyboardVisible.d.ts.map +2 -2
- package/types/useKeyboardVisible.native.d.ts +3 -0
- package/types/useKeyboardVisible.native.d.ts.map +11 -0
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js.map +0 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -3,26 +3,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
10
|
};
|
|
11
11
|
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
19
|
};
|
|
20
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
-
value: true
|
|
22
|
-
}), mod);
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
21
|
var index_exports = {};
|
|
24
|
-
__export(index_exports, {
|
|
25
|
-
useKeyboardVisible: () => import_useKeyboardVisible.useKeyboardVisible
|
|
26
|
-
});
|
|
22
|
+
__export(index_exports, { useKeyboardVisible: () => import_useKeyboardVisible.useKeyboardVisible });
|
|
27
23
|
module.exports = __toCommonJS(index_exports);
|
|
28
|
-
var import_useKeyboardVisible = require("./useKeyboardVisible.cjs");
|
|
24
|
+
var import_useKeyboardVisible = require("./useKeyboardVisible.cjs");
|
|
@@ -0,0 +1,26 @@
|
|
|
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: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
+
var index_exports = {};
|
|
24
|
+
__export(index_exports, { useKeyboardVisible: () => import_useKeyboardVisible.useKeyboardVisible });
|
|
25
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
|
+
var import_useKeyboardVisible = require("./useKeyboardVisible.native.js");
|
package/dist/cjs/index.native.js
CHANGED
|
@@ -5,27 +5,24 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
12
|
};
|
|
13
13
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
21
|
};
|
|
22
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
-
value: true
|
|
24
|
-
}), mod);
|
|
22
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
23
|
var index_exports = {};
|
|
26
|
-
__export(index_exports, {
|
|
27
|
-
useKeyboardVisible: () => import_useKeyboardVisible.useKeyboardVisible
|
|
28
|
-
});
|
|
24
|
+
__export(index_exports, { useKeyboardVisible: () => import_useKeyboardVisible.useKeyboardVisible });
|
|
29
25
|
module.exports = __toCommonJS(index_exports);
|
|
30
26
|
var import_useKeyboardVisible = require("./useKeyboardVisible.native.js");
|
|
27
|
+
|
|
31
28
|
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.native.js","names":[],"sources":["cjs/index.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar index_exports = {};\n__export(index_exports, {\n useKeyboardVisible: () => import_useKeyboardVisible.useKeyboardVisible\n});\nmodule.exports = __toCommonJS(index_exports);\nvar import_useKeyboardVisible = require(\"./useKeyboardVisible\");\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,gBAAgB,CAAC;AACrB,SAAS,eAAe,EACtB,0BAA0B,0BAA0B,mBACtD,CAAC;AACD,OAAO,UAAU,aAAa,aAAa;AAC3C,IAAI,4BAA4B,QAAQ,gCAAsB"}
|
|
@@ -5,52 +5,44 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
5
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
12
|
};
|
|
13
13
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
21
|
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
-
value: mod,
|
|
29
|
-
enumerable: true
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
30
25
|
}) : target, mod));
|
|
31
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
-
value: true
|
|
33
|
-
}), mod);
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
34
27
|
var useKeyboardVisible_exports = {};
|
|
35
|
-
__export(useKeyboardVisible_exports, {
|
|
36
|
-
useKeyboardVisible: () => useKeyboardVisible
|
|
37
|
-
});
|
|
28
|
+
__export(useKeyboardVisible_exports, { useKeyboardVisible: () => useKeyboardVisible });
|
|
38
29
|
module.exports = __toCommonJS(useKeyboardVisible_exports);
|
|
39
30
|
var import_react = __toESM(require("react"), 1);
|
|
40
|
-
|
|
31
|
+
const KEYBOARD_MIN_HEIGHT = 150;
|
|
32
|
+
const isKeyboardOpen = () => {
|
|
33
|
+
const viewport = window.visualViewport;
|
|
34
|
+
if (!viewport) return false;
|
|
35
|
+
return document.documentElement.clientHeight - viewport.height > KEYBOARD_MIN_HEIGHT;
|
|
36
|
+
};
|
|
41
37
|
const useKeyboardVisible = () => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
};
|
|
54
|
-
}, []);
|
|
55
|
-
return isKeyboardVisible;
|
|
56
|
-
};
|
|
38
|
+
const [isKeyboardVisible, setKeyboardVisible] = import_react.default.useState(false);
|
|
39
|
+
import_react.default.useEffect(() => {
|
|
40
|
+
const viewport = window.visualViewport;
|
|
41
|
+
if (!viewport) return;
|
|
42
|
+
const update = () => setKeyboardVisible(isKeyboardOpen());
|
|
43
|
+
update();
|
|
44
|
+
viewport.addEventListener("resize", update);
|
|
45
|
+
return () => viewport.removeEventListener("resize", update);
|
|
46
|
+
}, []);
|
|
47
|
+
return isKeyboardVisible;
|
|
48
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
18
|
+
get: () => from[key],
|
|
19
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
25
|
+
value: mod,
|
|
26
|
+
enumerable: true
|
|
27
|
+
}) : target, mod));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var useKeyboardVisible_native_exports = {};
|
|
30
|
+
__export(useKeyboardVisible_native_exports, { useKeyboardVisible: () => useKeyboardVisible });
|
|
31
|
+
module.exports = __toCommonJS(useKeyboardVisible_native_exports);
|
|
32
|
+
var import_react = __toESM(require("react"), 1);
|
|
33
|
+
var import_react_native = require("react-native");
|
|
34
|
+
var useKeyboardVisible = function() {
|
|
35
|
+
var [isKeyboardVisible, setKeyboardVisible] = import_react.default.useState(false);
|
|
36
|
+
import_react.default.useEffect(function() {
|
|
37
|
+
var keyboardDidShowListener = import_react_native.Keyboard.addListener("keyboardDidShow", function() {
|
|
38
|
+
setKeyboardVisible(true);
|
|
39
|
+
});
|
|
40
|
+
var keyboardDidHideListener = import_react_native.Keyboard.addListener("keyboardDidHide", function() {
|
|
41
|
+
setKeyboardVisible(false);
|
|
42
|
+
});
|
|
43
|
+
return function() {
|
|
44
|
+
keyboardDidHideListener.remove();
|
|
45
|
+
keyboardDidShowListener.remove();
|
|
46
|
+
};
|
|
47
|
+
}, []);
|
|
48
|
+
return isKeyboardVisible;
|
|
49
|
+
};
|
|
@@ -7,53 +7,45 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
7
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
9
|
var __export = (target, all) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
14
|
};
|
|
15
15
|
var __copyProps = (to, from, except, desc) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
18
|
+
get: () => from[key],
|
|
19
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
23
|
};
|
|
24
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
30
|
-
value: mod,
|
|
31
|
-
enumerable: true
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
25
|
+
value: mod,
|
|
26
|
+
enumerable: true
|
|
32
27
|
}) : target, mod));
|
|
33
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
__export(useKeyboardVisible_exports, {
|
|
38
|
-
useKeyboardVisible: () => useKeyboardVisible
|
|
39
|
-
});
|
|
40
|
-
module.exports = __toCommonJS(useKeyboardVisible_exports);
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var useKeyboardVisible_native_exports = {};
|
|
30
|
+
__export(useKeyboardVisible_native_exports, { useKeyboardVisible: () => useKeyboardVisible });
|
|
31
|
+
module.exports = __toCommonJS(useKeyboardVisible_native_exports);
|
|
41
32
|
var import_react = __toESM(require("react"), 1);
|
|
42
33
|
var import_react_native = require("react-native");
|
|
43
|
-
var useKeyboardVisible = function
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
34
|
+
var useKeyboardVisible = function() {
|
|
35
|
+
var [isKeyboardVisible, setKeyboardVisible] = import_react.default.useState(false);
|
|
36
|
+
import_react.default.useEffect(function() {
|
|
37
|
+
var keyboardDidShowListener = import_react_native.Keyboard.addListener("keyboardDidShow", function() {
|
|
38
|
+
setKeyboardVisible(true);
|
|
39
|
+
});
|
|
40
|
+
var keyboardDidHideListener = import_react_native.Keyboard.addListener("keyboardDidHide", function() {
|
|
41
|
+
setKeyboardVisible(false);
|
|
42
|
+
});
|
|
43
|
+
return function() {
|
|
44
|
+
keyboardDidHideListener.remove();
|
|
45
|
+
keyboardDidShowListener.remove();
|
|
46
|
+
};
|
|
47
|
+
}, []);
|
|
48
|
+
return isKeyboardVisible;
|
|
58
49
|
};
|
|
50
|
+
|
|
59
51
|
//# sourceMappingURL=useKeyboardVisible.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"useKeyboardVisible.native.js","names":[],"sources":["cjs/useKeyboardVisible.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar useKeyboardVisible_native_exports = {};\n__export(useKeyboardVisible_native_exports, {\n useKeyboardVisible: () => useKeyboardVisible\n});\nmodule.exports = __toCommonJS(useKeyboardVisible_native_exports);\nvar import_react = __toESM(require(\"react\"), 1);\nvar import_react_native = require(\"react-native\");\nvar useKeyboardVisible = function() {\n var [isKeyboardVisible, setKeyboardVisible] = import_react.default.useState(false);\n import_react.default.useEffect(function() {\n var keyboardDidShowListener = import_react_native.Keyboard.addListener(\"keyboardDidShow\", function() {\n setKeyboardVisible(true);\n });\n var keyboardDidHideListener = import_react_native.Keyboard.addListener(\"keyboardDidHide\", function() {\n setKeyboardVisible(false);\n });\n return function() {\n keyboardDidHideListener.remove();\n keyboardDidShowListener.remove();\n };\n }, []);\n return isKeyboardVisible;\n};\n//# sourceMappingURL=useKeyboardVisible.native.js.map\n"],"mappings":";;;AACA,IAAI,WAAW,OAAO;AACtB,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO;AAC1B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,WAAW,KAAK,YAAY,YAAY,SAAS,OAAO,OAAO,SAAS,aAAa,GAAG,CAAC,IAAI,CAAC,GAAG,YAKnG,cAAc,CAAC,OAAO,CAAC,IAAI,aAAa,UAAU,QAAQ,WAAW;CAAE,OAAO;CAAK,YAAY;AAAK,CAAC,IAAI,QACzG,GACF;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,oCAAoC,CAAC;AACzC,SAAS,mCAAmC,EAC1C,0BAA0B,mBAC5B,CAAC;AACD,OAAO,UAAU,aAAa,iCAAiC;AAC/D,IAAI,eAAe,QAAQ,QAAQ,OAAO,GAAG,CAAC;AAC9C,IAAI,sBAAsB,QAAQ,cAAc;AAChD,IAAI,qBAAqB,WAAW;CAClC,IAAI,CAAC,mBAAmB,sBAAsB,aAAa,QAAQ,SAAS,KAAK;CACjF,aAAa,QAAQ,UAAU,WAAW;EACxC,IAAI,0BAA0B,oBAAoB,SAAS,YAAY,mBAAmB,WAAW;GACnG,mBAAmB,IAAI;EACzB,CAAC;EACD,IAAI,0BAA0B,oBAAoB,SAAS,YAAY,mBAAmB,WAAW;GACnG,mBAAmB,KAAK;EAC1B,CAAC;EACD,OAAO,WAAW;GAChB,wBAAwB,OAAO;GAC/B,wBAAwB,OAAO;EACjC;CACF,GAAG,CAAC,CAAC;CACL,OAAO;AACT"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { useKeyboardVisible } from "./useKeyboardVisible.mjs";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
|
|
3
|
+
export { useKeyboardVisible };
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { useKeyboardVisible } from "./useKeyboardVisible.mjs";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
|
|
3
|
+
export { useKeyboardVisible };
|
package/dist/esm/index.native.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { useKeyboardVisible } from "./useKeyboardVisible.native.js";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
|
|
3
|
+
export { useKeyboardVisible };
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
const KEYBOARD_MIN_HEIGHT = 150;
|
|
4
|
+
const isKeyboardOpen = () => {
|
|
5
|
+
const viewport = window.visualViewport;
|
|
6
|
+
if (!viewport) return false;
|
|
7
|
+
return document.documentElement.clientHeight - viewport.height > KEYBOARD_MIN_HEIGHT;
|
|
8
|
+
};
|
|
3
9
|
const useKeyboardVisible = () => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
keyboardDidShowListener.remove();
|
|
15
|
-
};
|
|
16
|
-
}, []);
|
|
17
|
-
return isKeyboardVisible;
|
|
10
|
+
const [isKeyboardVisible, setKeyboardVisible] = React.useState(false);
|
|
11
|
+
React.useEffect(() => {
|
|
12
|
+
const viewport = window.visualViewport;
|
|
13
|
+
if (!viewport) return;
|
|
14
|
+
const update = () => setKeyboardVisible(isKeyboardOpen());
|
|
15
|
+
update();
|
|
16
|
+
viewport.addEventListener("resize", update);
|
|
17
|
+
return () => viewport.removeEventListener("resize", update);
|
|
18
|
+
}, []);
|
|
19
|
+
return isKeyboardVisible;
|
|
18
20
|
};
|
|
21
|
+
|
|
19
22
|
export { useKeyboardVisible };
|
|
20
23
|
//# sourceMappingURL=useKeyboardVisible.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"useKeyboardVisible.js","names":[],"sources":["esm/useKeyboardVisible.js"],"sourcesContent":["import React from \"react\";\nconst KEYBOARD_MIN_HEIGHT = 150;\nconst isKeyboardOpen = () => {\n const viewport = window.visualViewport;\n if (!viewport) return false;\n return document.documentElement.clientHeight - viewport.height > KEYBOARD_MIN_HEIGHT;\n};\nconst useKeyboardVisible = () => {\n const [isKeyboardVisible, setKeyboardVisible] = React.useState(false);\n React.useEffect(() => {\n const viewport = window.visualViewport;\n if (!viewport) return;\n const update = () => setKeyboardVisible(isKeyboardOpen());\n update();\n viewport.addEventListener(\"resize\", update);\n return () => viewport.removeEventListener(\"resize\", update);\n }, []);\n return isKeyboardVisible;\n};\nexport {\n useKeyboardVisible\n};\n//# sourceMappingURL=useKeyboardVisible.js.map\n"],"mappings":";;;AACA,MAAM,sBAAsB;AAC5B,MAAM,uBAAuB;CAC3B,MAAM,WAAW,OAAO;CACxB,IAAI,CAAC,UAAU,OAAO;CACtB,OAAO,SAAS,gBAAgB,eAAe,SAAS,SAAS;AACnE;AACA,MAAM,2BAA2B;CAC/B,MAAM,CAAC,mBAAmB,sBAAsB,MAAM,SAAS,KAAK;CACpE,MAAM,gBAAgB;EACpB,MAAM,WAAW,OAAO;EACxB,IAAI,CAAC,UAAU;EACf,MAAM,eAAe,mBAAmB,eAAe,CAAC;EACxD,OAAO;EACP,SAAS,iBAAiB,UAAU,MAAM;EAC1C,aAAa,SAAS,oBAAoB,UAAU,MAAM;CAC5D,GAAG,CAAC,CAAC;CACL,OAAO;AACT"}
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Keyboard } from "react-native";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
3
|
+
|
|
4
|
+
var useKeyboardVisible = function() {
|
|
5
|
+
var [isKeyboardVisible, setKeyboardVisible] = React.useState(false);
|
|
6
|
+
React.useEffect(function() {
|
|
7
|
+
var keyboardDidShowListener = Keyboard.addListener("keyboardDidShow", function() {
|
|
8
|
+
setKeyboardVisible(true);
|
|
9
|
+
});
|
|
10
|
+
var keyboardDidHideListener = Keyboard.addListener("keyboardDidHide", function() {
|
|
11
|
+
setKeyboardVisible(false);
|
|
12
|
+
});
|
|
13
|
+
return function() {
|
|
14
|
+
keyboardDidHideListener.remove();
|
|
15
|
+
keyboardDidShowListener.remove();
|
|
16
|
+
};
|
|
17
|
+
}, []);
|
|
18
|
+
return isKeyboardVisible;
|
|
18
19
|
};
|
|
20
|
+
|
|
19
21
|
export { useKeyboardVisible };
|
|
20
22
|
//# sourceMappingURL=useKeyboardVisible.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"useKeyboardVisible.native.js","names":[],"sources":["esm/useKeyboardVisible.native.js"],"sourcesContent":["import React from \"react\";\nimport { Keyboard } from \"react-native\";\nvar useKeyboardVisible = function() {\n var [isKeyboardVisible, setKeyboardVisible] = React.useState(false);\n React.useEffect(function() {\n var keyboardDidShowListener = Keyboard.addListener(\"keyboardDidShow\", function() {\n setKeyboardVisible(true);\n });\n var keyboardDidHideListener = Keyboard.addListener(\"keyboardDidHide\", function() {\n setKeyboardVisible(false);\n });\n return function() {\n keyboardDidHideListener.remove();\n keyboardDidShowListener.remove();\n };\n }, []);\n return isKeyboardVisible;\n};\nexport {\n useKeyboardVisible\n};\n//# sourceMappingURL=useKeyboardVisible.native.js.map\n"],"mappings":";;;;AAEA,IAAI,qBAAqB,WAAW;CAClC,IAAI,CAAC,mBAAmB,sBAAsB,MAAM,SAAS,KAAK;CAClE,MAAM,UAAU,WAAW;EACzB,IAAI,0BAA0B,SAAS,YAAY,mBAAmB,WAAW;GAC/E,mBAAmB,IAAI;EACzB,CAAC;EACD,IAAI,0BAA0B,SAAS,YAAY,mBAAmB,WAAW;GAC/E,mBAAmB,KAAK;EAC1B,CAAC;EACD,OAAO,WAAW;GAChB,wBAAwB,OAAO;GAC/B,wBAAwB,OAAO;EACjC;CACF,GAAG,CAAC,CAAC;CACL,OAAO;AACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/use-keyboard-visible",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-beta.1097.1",
|
|
4
|
+
"license": "MIT",
|
|
4
5
|
"gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
|
|
5
6
|
"files": [
|
|
6
7
|
"src",
|
|
@@ -34,12 +35,13 @@
|
|
|
34
35
|
"clean:build": "tamagui-build clean:build"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
|
-
"@tamagui/build": "
|
|
38
|
-
"react": "
|
|
39
|
-
"react-native": "0.
|
|
38
|
+
"@tamagui/build": "3.0.0-beta.1097.1",
|
|
39
|
+
"react": "19.2.3",
|
|
40
|
+
"react-native": "0.86.2"
|
|
40
41
|
},
|
|
41
42
|
"peerDependencies": {
|
|
42
|
-
"react": ">=19"
|
|
43
|
+
"react": ">=19",
|
|
44
|
+
"react-native-web": "*"
|
|
43
45
|
},
|
|
44
46
|
"repository": {
|
|
45
47
|
"type": "git",
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Keyboard } from 'react-native'
|
|
3
|
+
|
|
4
|
+
export const useKeyboardVisible = (): boolean => {
|
|
5
|
+
const [isKeyboardVisible, setKeyboardVisible] = React.useState(false)
|
|
6
|
+
|
|
7
|
+
React.useEffect(() => {
|
|
8
|
+
const keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', () => {
|
|
9
|
+
setKeyboardVisible(true)
|
|
10
|
+
})
|
|
11
|
+
const keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', () => {
|
|
12
|
+
setKeyboardVisible(false)
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
return () => {
|
|
16
|
+
keyboardDidHideListener.remove()
|
|
17
|
+
keyboardDidShowListener.remove()
|
|
18
|
+
}
|
|
19
|
+
}, [])
|
|
20
|
+
|
|
21
|
+
return isKeyboardVisible
|
|
22
|
+
}
|
|
@@ -1,21 +1,34 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* On mobile web the soft keyboard is not an event, it is a shrunken visual
|
|
5
|
+
* viewport: the layout viewport stays put and `visualViewport.height` drops by
|
|
6
|
+
* the height of the keyboard. Anything smaller than that is a scroll or a
|
|
7
|
+
* pinch, hence the threshold.
|
|
8
|
+
*
|
|
9
|
+
* Desktop browsers never shrink it, so this stays false there, which is what
|
|
10
|
+
* the react-native version reported on web before this file existed.
|
|
11
|
+
*/
|
|
12
|
+
const KEYBOARD_MIN_HEIGHT = 150
|
|
13
|
+
|
|
14
|
+
const isKeyboardOpen = () => {
|
|
15
|
+
const viewport = window.visualViewport
|
|
16
|
+
if (!viewport) return false
|
|
17
|
+
return document.documentElement.clientHeight - viewport.height > KEYBOARD_MIN_HEIGHT
|
|
18
|
+
}
|
|
3
19
|
|
|
4
20
|
export const useKeyboardVisible = (): boolean => {
|
|
5
21
|
const [isKeyboardVisible, setKeyboardVisible] = React.useState(false)
|
|
6
22
|
|
|
7
23
|
React.useEffect(() => {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
})
|
|
24
|
+
const viewport = window.visualViewport
|
|
25
|
+
if (!viewport) return
|
|
26
|
+
|
|
27
|
+
const update = () => setKeyboardVisible(isKeyboardOpen())
|
|
28
|
+
update()
|
|
14
29
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
keyboardDidShowListener.remove()
|
|
18
|
-
}
|
|
30
|
+
viewport.addEventListener('resize', update)
|
|
31
|
+
return () => viewport.removeEventListener('resize', update)
|
|
19
32
|
}, [])
|
|
20
33
|
|
|
21
34
|
return isKeyboardVisible
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"mappings": "
|
|
2
|
+
"mappings": "AAmBA,OAAO,cAAM",
|
|
3
3
|
"names": [],
|
|
4
4
|
"sources": [
|
|
5
5
|
"src/useKeyboardVisible.ts"
|
|
6
6
|
],
|
|
7
7
|
"version": 3,
|
|
8
8
|
"sourcesContent": [
|
|
9
|
-
"import React from 'react'\
|
|
9
|
+
"import React from 'react'\n\n/**\n * On mobile web the soft keyboard is not an event, it is a shrunken visual\n * viewport: the layout viewport stays put and `visualViewport.height` drops by\n * the height of the keyboard. Anything smaller than that is a scroll or a\n * pinch, hence the threshold.\n *\n * Desktop browsers never shrink it, so this stays false there, which is what\n * the react-native version reported on web before this file existed.\n */\nconst KEYBOARD_MIN_HEIGHT = 150\n\nconst isKeyboardOpen = () => {\n const viewport = window.visualViewport\n if (!viewport) return false\n return document.documentElement.clientHeight - viewport.height > KEYBOARD_MIN_HEIGHT\n}\n\nexport const useKeyboardVisible = (): boolean => {\n const [isKeyboardVisible, setKeyboardVisible] = React.useState(false)\n\n React.useEffect(() => {\n const viewport = window.visualViewport\n if (!viewport) return\n\n const update = () => setKeyboardVisible(isKeyboardOpen())\n update()\n\n viewport.addEventListener('resize', update)\n return () => viewport.removeEventListener('resize', update)\n }, [])\n\n return isKeyboardVisible\n}\n"
|
|
10
10
|
]
|
|
11
11
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"mappings": "AAGA,OAAO,cAAM",
|
|
3
|
+
"names": [],
|
|
4
|
+
"sources": [
|
|
5
|
+
"src/useKeyboardVisible.native.ts"
|
|
6
|
+
],
|
|
7
|
+
"version": 3,
|
|
8
|
+
"sourcesContent": [
|
|
9
|
+
"import React from 'react'\nimport { Keyboard } from 'react-native'\n\nexport const useKeyboardVisible = (): boolean => {\n const [isKeyboardVisible, setKeyboardVisible] = React.useState(false)\n\n React.useEffect(() => {\n const keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', () => {\n setKeyboardVisible(true)\n })\n const keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', () => {\n setKeyboardVisible(false)\n })\n\n return () => {\n keyboardDidHideListener.remove()\n keyboardDidShowListener.remove()\n }\n }, [])\n\n return isKeyboardVisible\n}\n"
|
|
10
|
+
]
|
|
11
|
+
}
|
package/dist/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useKeyboardVisible"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,kBAAA,QAA0B","ignoreList":[]}
|
package/dist/esm/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useKeyboardVisible"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,kBAAA,QAA0B","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useKeyboardVisible"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,kBAAA,QAA0B","ignoreList":[]}
|