@tamagui/focusable 2.7.7 → 3.0.0-beta.643.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/focusable.cjs +10 -11
- package/dist/cjs/focusable.native.cjs +19 -0
- package/dist/cjs/focusable.native.js +10 -10
- package/dist/cjs/focusable.native.js.map +1 -1
- package/dist/cjs/focusableInputHOC.cjs +58 -73
- package/dist/cjs/focusableInputHOC.native.cjs +84 -0
- package/dist/cjs/focusableInputHOC.native.js +64 -78
- package/dist/cjs/focusableInputHOC.native.js.map +1 -1
- package/dist/cjs/index.cjs +10 -11
- package/dist/cjs/index.native.cjs +23 -0
- package/dist/cjs/index.native.js +10 -10
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/registerFocusable.cjs +18 -19
- package/dist/cjs/registerFocusable.native.cjs +60 -0
- package/dist/cjs/registerFocusable.native.js +44 -44
- package/dist/cjs/registerFocusable.native.js.map +1 -1
- package/dist/esm/focusable.mjs +0 -2
- package/dist/esm/focusable.native.js +0 -2
- package/dist/esm/focusableInputHOC.mjs +42 -47
- package/dist/esm/focusableInputHOC.mjs.map +1 -1
- package/dist/esm/focusableInputHOC.native.js +48 -53
- package/dist/esm/focusableInputHOC.native.js.map +1 -1
- package/dist/esm/index.js +5 -4
- package/dist/esm/index.mjs +5 -4
- package/dist/esm/index.native.js +5 -4
- package/dist/esm/registerFocusable.mjs +3 -2
- package/dist/esm/registerFocusable.mjs.map +1 -1
- package/dist/esm/registerFocusable.native.js +28 -27
- package/dist/esm/registerFocusable.native.js.map +1 -1
- package/dist/jsx/focusable.mjs +0 -2
- package/dist/jsx/focusable.native.cjs +19 -0
- package/dist/jsx/focusable.native.js +10 -10
- package/dist/jsx/focusable.native.js.map +1 -1
- package/dist/jsx/focusableInputHOC.mjs +42 -47
- package/dist/jsx/focusableInputHOC.mjs.map +1 -1
- package/dist/jsx/focusableInputHOC.native.cjs +84 -0
- package/dist/jsx/focusableInputHOC.native.js +64 -78
- package/dist/jsx/focusableInputHOC.native.js.map +1 -1
- package/dist/jsx/index.js +5 -4
- package/dist/jsx/index.mjs +5 -4
- package/dist/jsx/index.native.cjs +23 -0
- package/dist/jsx/index.native.js +10 -10
- package/dist/jsx/index.native.js.map +1 -1
- package/dist/jsx/registerFocusable.mjs +3 -2
- package/dist/jsx/registerFocusable.mjs.map +1 -1
- package/dist/jsx/registerFocusable.native.cjs +60 -0
- package/dist/jsx/registerFocusable.native.js +44 -44
- package/dist/jsx/registerFocusable.native.js.map +1 -1
- package/package.json +4 -4
- package/types/focusableInputHOC.d.ts.map +1 -1
- package/types/registerFocusable.d.ts.map +1 -1
- package/types/registerFocusable.native.d.ts.map +1 -1
- package/dist/esm/focusable.mjs.map +0 -1
- package/dist/esm/focusable.native.js.map +0 -1
- 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/jsx/focusable.mjs.map +0 -1
- package/dist/jsx/index.js.map +0 -1
- package/dist/jsx/index.mjs.map +0 -1
package/dist/cjs/focusable.cjs
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
+
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
6
|
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
9
|
+
get: () => from[key],
|
|
10
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
return to;
|
|
13
14
|
};
|
|
14
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
15
|
-
value: true
|
|
16
|
-
}), mod);
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
17
16
|
var focusable_exports = {};
|
|
18
|
-
module.exports = __toCommonJS(focusable_exports);
|
|
17
|
+
module.exports = __toCommonJS(focusable_exports);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
11
|
+
get: () => from[key],
|
|
12
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var focusable_exports = {};
|
|
19
|
+
module.exports = __toCommonJS(focusable_exports);
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
8
|
var __copyProps = (to, from, except, desc) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
11
|
+
get: () => from[key],
|
|
12
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
15
16
|
};
|
|
16
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
17
|
-
value: true
|
|
18
|
-
}), mod);
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
18
|
var focusable_exports = {};
|
|
20
19
|
module.exports = __toCommonJS(focusable_exports);
|
|
20
|
+
|
|
21
21
|
//# sourceMappingURL=focusable.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"focusable.native.js","names":[],"sources":["cjs/focusable.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\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 focusable_exports = {};\nmodule.exports = __toCommonJS(focusable_exports);\n//# sourceMappingURL=focusable.js.map\n"],"mappings":";;;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,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,oBAAoB,CAAC;AACzB,OAAO,UAAU,aAAa,iBAAiB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -5,86 +6,70 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
5
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
8
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
for (var name in all) __defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true
|
|
12
|
+
});
|
|
12
13
|
};
|
|
13
14
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
21
22
|
};
|
|
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
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
24
|
+
value: mod,
|
|
25
|
+
enumerable: true
|
|
30
26
|
}) : target, mod));
|
|
31
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
-
value: true
|
|
33
|
-
}), mod);
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
34
28
|
var focusableInputHOC_exports = {};
|
|
35
|
-
__export(focusableInputHOC_exports, {
|
|
36
|
-
useFocusable: () => useFocusable
|
|
37
|
-
});
|
|
29
|
+
__export(focusableInputHOC_exports, { useFocusable: () => useFocusable });
|
|
38
30
|
module.exports = __toCommonJS(focusableInputHOC_exports);
|
|
39
31
|
var import_compose_refs = require("@tamagui/compose-refs");
|
|
40
32
|
var import_web = require("@tamagui/web");
|
|
41
33
|
var import_react = __toESM(require("react"), 1);
|
|
42
34
|
var import_registerFocusable = require("./registerFocusable.cjs");
|
|
43
|
-
function useFocusable({
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
};
|
|
85
|
-
}, []);
|
|
86
|
-
return {
|
|
87
|
-
ref: import_react.default.useMemo(() => (0, import_compose_refs.composeRefs)(ref, inputRef), [ref, inputRef]),
|
|
88
|
-
onChangeText: handleChangeText
|
|
89
|
-
};
|
|
90
|
-
}
|
|
35
|
+
function useFocusable({ isInput, props, ref }) {
|
|
36
|
+
const { id, onChangeText, value, defaultValue } = props;
|
|
37
|
+
const inputValue = import_react.default.useRef(value || defaultValue || "");
|
|
38
|
+
const unregisterFocusable = import_react.default.useRef(void 0);
|
|
39
|
+
const focusAndSelect = import_react.default.useCallback((input) => {
|
|
40
|
+
input.focus();
|
|
41
|
+
if (input.setSelection && typeof inputValue.current === "string") {
|
|
42
|
+
input.setSelection(0, inputValue.current.length);
|
|
43
|
+
}
|
|
44
|
+
}, []);
|
|
45
|
+
const registerFocusableHandler = import_react.default.useCallback((input) => {
|
|
46
|
+
if (!id || !input) return;
|
|
47
|
+
unregisterFocusable.current?.();
|
|
48
|
+
unregisterFocusable.current = (0, import_registerFocusable.registerFocusable)(id, {
|
|
49
|
+
focus: input.focus,
|
|
50
|
+
...isInput && { focusAndSelect: () => focusAndSelect(input) }
|
|
51
|
+
});
|
|
52
|
+
}, [
|
|
53
|
+
id,
|
|
54
|
+
isInput,
|
|
55
|
+
focusAndSelect
|
|
56
|
+
]);
|
|
57
|
+
const inputRef = import_react.default.useCallback((input) => {
|
|
58
|
+
if (input) {
|
|
59
|
+
registerFocusableHandler(input);
|
|
60
|
+
}
|
|
61
|
+
}, [registerFocusableHandler]);
|
|
62
|
+
const handleChangeText = (0, import_web.useEvent)((value2) => {
|
|
63
|
+
inputValue.current = value2;
|
|
64
|
+
onChangeText?.(value2);
|
|
65
|
+
});
|
|
66
|
+
import_react.default.useEffect(() => {
|
|
67
|
+
return () => {
|
|
68
|
+
unregisterFocusable.current?.();
|
|
69
|
+
};
|
|
70
|
+
}, []);
|
|
71
|
+
return {
|
|
72
|
+
ref: import_react.default.useMemo(() => (0, import_compose_refs.composeRefs)(ref, inputRef), [ref, inputRef]),
|
|
73
|
+
onChangeText: handleChangeText
|
|
74
|
+
};
|
|
75
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __export = (target, all) => {
|
|
11
|
+
for (var name in all) __defProp(target, name, {
|
|
12
|
+
get: all[name],
|
|
13
|
+
enumerable: true
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
19
|
+
get: () => from[key],
|
|
20
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
26
|
+
value: mod,
|
|
27
|
+
enumerable: true
|
|
28
|
+
}) : target, mod));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var focusableInputHOC_exports = {};
|
|
31
|
+
__export(focusableInputHOC_exports, { useFocusable: () => useFocusable });
|
|
32
|
+
module.exports = __toCommonJS(focusableInputHOC_exports);
|
|
33
|
+
var import_compose_refs = require("@tamagui/compose-refs");
|
|
34
|
+
var import_web = require("@tamagui/web");
|
|
35
|
+
var import_react = __toESM(require("react"), 1);
|
|
36
|
+
var import_registerFocusable = require("./registerFocusable.native.js");
|
|
37
|
+
function useFocusable(param) {
|
|
38
|
+
var { isInput, props, ref } = param;
|
|
39
|
+
var { id, onChangeText, value, defaultValue } = props;
|
|
40
|
+
var inputValue = import_react.default.useRef(value || defaultValue || "");
|
|
41
|
+
var unregisterFocusable = import_react.default.useRef(void 0);
|
|
42
|
+
var focusAndSelect = import_react.default.useCallback(function(input) {
|
|
43
|
+
input.focus();
|
|
44
|
+
if (input.setSelection && typeof inputValue.current === "string") {
|
|
45
|
+
input.setSelection(0, inputValue.current.length);
|
|
46
|
+
}
|
|
47
|
+
}, []);
|
|
48
|
+
var registerFocusableHandler = import_react.default.useCallback(function(input) {
|
|
49
|
+
var _unregisterFocusable_current;
|
|
50
|
+
if (!id || !input) return;
|
|
51
|
+
(_unregisterFocusable_current = unregisterFocusable.current) === null || _unregisterFocusable_current === void 0 ? void 0 : _unregisterFocusable_current.call(unregisterFocusable);
|
|
52
|
+
unregisterFocusable.current = (0, import_registerFocusable.registerFocusable)(id, {
|
|
53
|
+
focus: input.focus,
|
|
54
|
+
...isInput && { focusAndSelect: function() {
|
|
55
|
+
return focusAndSelect(input);
|
|
56
|
+
} }
|
|
57
|
+
});
|
|
58
|
+
}, [
|
|
59
|
+
id,
|
|
60
|
+
isInput,
|
|
61
|
+
focusAndSelect
|
|
62
|
+
]);
|
|
63
|
+
var inputRef = import_react.default.useCallback(function(input) {
|
|
64
|
+
if (input) {
|
|
65
|
+
registerFocusableHandler(input);
|
|
66
|
+
}
|
|
67
|
+
}, [registerFocusableHandler]);
|
|
68
|
+
var handleChangeText = (0, import_web.useEvent)(function(value2) {
|
|
69
|
+
inputValue.current = value2;
|
|
70
|
+
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(value2);
|
|
71
|
+
});
|
|
72
|
+
import_react.default.useEffect(function() {
|
|
73
|
+
return function() {
|
|
74
|
+
var _unregisterFocusable_current;
|
|
75
|
+
(_unregisterFocusable_current = unregisterFocusable.current) === null || _unregisterFocusable_current === void 0 ? void 0 : _unregisterFocusable_current.call(unregisterFocusable);
|
|
76
|
+
};
|
|
77
|
+
}, []);
|
|
78
|
+
return {
|
|
79
|
+
ref: import_react.default.useMemo(function() {
|
|
80
|
+
return (0, import_compose_refs.composeRefs)(ref, inputRef);
|
|
81
|
+
}, [ref, inputRef]),
|
|
82
|
+
onChangeText: handleChangeText
|
|
83
|
+
};
|
|
84
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
var __create = Object.create;
|
|
4
5
|
var __defProp = Object.defineProperty;
|
|
5
6
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -7,94 +8,79 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
7
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
9
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
10
|
var __export = (target, all) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
for (var name in all) __defProp(target, name, {
|
|
12
|
+
get: all[name],
|
|
13
|
+
enumerable: true
|
|
14
|
+
});
|
|
14
15
|
};
|
|
15
16
|
var __copyProps = (to, from, except, desc) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
19
|
+
get: () => from[key],
|
|
20
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
23
24
|
};
|
|
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
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
26
|
+
value: mod,
|
|
27
|
+
enumerable: true
|
|
32
28
|
}) : target, mod));
|
|
33
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
34
|
-
value: true
|
|
35
|
-
}), mod);
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
36
30
|
var focusableInputHOC_exports = {};
|
|
37
|
-
__export(focusableInputHOC_exports, {
|
|
38
|
-
useFocusable: () => useFocusable
|
|
39
|
-
});
|
|
31
|
+
__export(focusableInputHOC_exports, { useFocusable: () => useFocusable });
|
|
40
32
|
module.exports = __toCommonJS(focusableInputHOC_exports);
|
|
41
33
|
var import_compose_refs = require("@tamagui/compose-refs");
|
|
42
34
|
var import_web = require("@tamagui/web");
|
|
43
35
|
var import_react = __toESM(require("react"), 1);
|
|
44
36
|
var import_registerFocusable = require("./registerFocusable.native.js");
|
|
45
37
|
function useFocusable(param) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}, []);
|
|
93
|
-
return {
|
|
94
|
-
ref: import_react.default.useMemo(function () {
|
|
95
|
-
return (0, import_compose_refs.composeRefs)(ref, inputRef);
|
|
96
|
-
}, [ref, inputRef]),
|
|
97
|
-
onChangeText: handleChangeText
|
|
98
|
-
};
|
|
38
|
+
var { isInput, props, ref } = param;
|
|
39
|
+
var { id, onChangeText, value, defaultValue } = props;
|
|
40
|
+
var inputValue = import_react.default.useRef(value || defaultValue || "");
|
|
41
|
+
var unregisterFocusable = import_react.default.useRef(void 0);
|
|
42
|
+
var focusAndSelect = import_react.default.useCallback(function(input) {
|
|
43
|
+
input.focus();
|
|
44
|
+
if (input.setSelection && typeof inputValue.current === "string") {
|
|
45
|
+
input.setSelection(0, inputValue.current.length);
|
|
46
|
+
}
|
|
47
|
+
}, []);
|
|
48
|
+
var registerFocusableHandler = import_react.default.useCallback(function(input) {
|
|
49
|
+
var _unregisterFocusable_current;
|
|
50
|
+
if (!id || !input) return;
|
|
51
|
+
(_unregisterFocusable_current = unregisterFocusable.current) === null || _unregisterFocusable_current === void 0 ? void 0 : _unregisterFocusable_current.call(unregisterFocusable);
|
|
52
|
+
unregisterFocusable.current = (0, import_registerFocusable.registerFocusable)(id, {
|
|
53
|
+
focus: input.focus,
|
|
54
|
+
...isInput && { focusAndSelect: function() {
|
|
55
|
+
return focusAndSelect(input);
|
|
56
|
+
} }
|
|
57
|
+
});
|
|
58
|
+
}, [
|
|
59
|
+
id,
|
|
60
|
+
isInput,
|
|
61
|
+
focusAndSelect
|
|
62
|
+
]);
|
|
63
|
+
var inputRef = import_react.default.useCallback(function(input) {
|
|
64
|
+
if (input) {
|
|
65
|
+
registerFocusableHandler(input);
|
|
66
|
+
}
|
|
67
|
+
}, [registerFocusableHandler]);
|
|
68
|
+
var handleChangeText = (0, import_web.useEvent)(function(value2) {
|
|
69
|
+
inputValue.current = value2;
|
|
70
|
+
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(value2);
|
|
71
|
+
});
|
|
72
|
+
import_react.default.useEffect(function() {
|
|
73
|
+
return function() {
|
|
74
|
+
var _unregisterFocusable_current;
|
|
75
|
+
(_unregisterFocusable_current = unregisterFocusable.current) === null || _unregisterFocusable_current === void 0 ? void 0 : _unregisterFocusable_current.call(unregisterFocusable);
|
|
76
|
+
};
|
|
77
|
+
}, []);
|
|
78
|
+
return {
|
|
79
|
+
ref: import_react.default.useMemo(function() {
|
|
80
|
+
return (0, import_compose_refs.composeRefs)(ref, inputRef);
|
|
81
|
+
}, [ref, inputRef]),
|
|
82
|
+
onChangeText: handleChangeText
|
|
83
|
+
};
|
|
99
84
|
}
|
|
85
|
+
|
|
100
86
|
//# sourceMappingURL=focusableInputHOC.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"focusableInputHOC.native.js","names":[],"sources":["cjs/focusableInputHOC.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 focusableInputHOC_exports = {};\n__export(focusableInputHOC_exports, {\n useFocusable: () => useFocusable\n});\nmodule.exports = __toCommonJS(focusableInputHOC_exports);\nvar import_compose_refs = require(\"@tamagui/compose-refs\");\nvar import_web = require(\"@tamagui/web\");\nvar import_react = __toESM(require(\"react\"), 1);\nvar import_registerFocusable = require(\"./registerFocusable\");\nfunction useFocusable(param) {\n var { isInput, props, ref } = param;\n var { id, onChangeText, value, defaultValue } = props;\n var inputValue = import_react.default.useRef(value || defaultValue || \"\");\n var unregisterFocusable = import_react.default.useRef(void 0);\n var focusAndSelect = import_react.default.useCallback(function(input) {\n input.focus();\n if (input.setSelection && typeof inputValue.current === \"string\") {\n input.setSelection(0, inputValue.current.length);\n }\n }, []);\n var registerFocusableHandler = import_react.default.useCallback(function(input) {\n var _unregisterFocusable_current;\n if (!id || !input) return;\n (_unregisterFocusable_current = unregisterFocusable.current) === null || _unregisterFocusable_current === void 0 ? void 0 : _unregisterFocusable_current.call(unregisterFocusable);\n unregisterFocusable.current = (0, import_registerFocusable.registerFocusable)(id, {\n focus: input.focus,\n ...isInput && {\n focusAndSelect: function() {\n return focusAndSelect(input);\n }\n }\n });\n }, [\n id,\n isInput,\n focusAndSelect\n ]);\n var inputRef = import_react.default.useCallback(function(input) {\n if (input) {\n registerFocusableHandler(input);\n }\n }, [\n registerFocusableHandler\n ]);\n var handleChangeText = (0, import_web.useEvent)(function(value2) {\n inputValue.current = value2;\n onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(value2);\n });\n import_react.default.useEffect(function() {\n return function() {\n var _unregisterFocusable_current;\n (_unregisterFocusable_current = unregisterFocusable.current) === null || _unregisterFocusable_current === void 0 ? void 0 : _unregisterFocusable_current.call(unregisterFocusable);\n };\n }, []);\n return {\n ref: import_react.default.useMemo(function() {\n return (0, import_compose_refs.composeRefs)(ref, inputRef);\n }, [\n ref,\n inputRef\n ]),\n onChangeText: handleChangeText\n };\n}\n//# sourceMappingURL=focusableInputHOC.js.map\n"],"mappings":"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"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
|
+
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
6
|
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
9
|
+
get: () => from[key],
|
|
10
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
return to;
|
|
13
14
|
};
|
|
14
15
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
16
|
-
value: true
|
|
17
|
-
}), mod);
|
|
16
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
17
|
var index_exports = {};
|
|
19
18
|
module.exports = __toCommonJS(index_exports);
|
|
20
19
|
__reExport(index_exports, require("./registerFocusable.cjs"), module.exports);
|
|
21
20
|
__reExport(index_exports, require("./focusableInputHOC.cjs"), module.exports);
|
|
22
|
-
__reExport(index_exports, require("./focusable.cjs"), module.exports);
|
|
21
|
+
__reExport(index_exports, require("./focusable.cjs"), module.exports);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
11
|
+
get: () => from[key],
|
|
12
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var index_exports = {};
|
|
20
|
+
module.exports = __toCommonJS(index_exports);
|
|
21
|
+
__reExport(index_exports, require("./registerFocusable.native.js"), module.exports);
|
|
22
|
+
__reExport(index_exports, require("./focusableInputHOC.native.js"), module.exports);
|
|
23
|
+
__reExport(index_exports, require("./focusable.native.js"), module.exports);
|
package/dist/cjs/index.native.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
8
|
var __copyProps = (to, from, except, desc) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
11
|
+
get: () => from[key],
|
|
12
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
15
16
|
};
|
|
16
17
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
17
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
18
|
-
value: true
|
|
19
|
-
}), mod);
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
19
|
var index_exports = {};
|
|
21
20
|
module.exports = __toCommonJS(index_exports);
|
|
22
21
|
__reExport(index_exports, require("./registerFocusable.native.js"), module.exports);
|
|
23
22
|
__reExport(index_exports, require("./focusableInputHOC.native.js"), module.exports);
|
|
24
23
|
__reExport(index_exports, require("./focusable.native.js"), module.exports);
|
|
24
|
+
|
|
25
25
|
//# sourceMappingURL=index.native.js.map
|