@tamagui/focusable 2.0.0-rc.4 → 2.0.0-rc.40
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 +7 -5
- package/dist/cjs/focusable.native.js +7 -5
- package/dist/cjs/focusable.native.js.map +1 -1
- package/dist/cjs/focusableInputHOC.cjs +65 -52
- package/dist/cjs/focusableInputHOC.native.js +71 -60
- package/dist/cjs/focusableInputHOC.native.js.map +1 -1
- package/dist/cjs/index.cjs +7 -5
- package/dist/cjs/index.native.js +7 -5
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/registerFocusable.cjs +15 -13
- package/dist/cjs/registerFocusable.native.js +40 -26
- package/dist/cjs/registerFocusable.native.js.map +1 -1
- package/dist/esm/focusableInputHOC.mjs +37 -26
- package/dist/esm/focusableInputHOC.mjs.map +1 -1
- package/dist/esm/focusableInputHOC.native.js +43 -34
- package/dist/esm/focusableInputHOC.native.js.map +1 -1
- package/dist/esm/index.js +3 -3
- package/dist/esm/index.js.map +1 -6
- package/dist/esm/registerFocusable.mjs +3 -3
- package/dist/esm/registerFocusable.mjs.map +1 -1
- package/dist/esm/registerFocusable.native.js +28 -16
- package/dist/esm/registerFocusable.native.js.map +1 -1
- package/dist/jsx/focusable.native.js +7 -5
- package/dist/jsx/focusableInputHOC.mjs +37 -26
- package/dist/jsx/focusableInputHOC.mjs.map +1 -1
- package/dist/jsx/focusableInputHOC.native.js +71 -60
- package/dist/jsx/focusableInputHOC.native.js.map +1 -1
- package/dist/jsx/index.js +3 -3
- package/dist/jsx/index.js.map +1 -6
- package/dist/jsx/index.native.js +7 -5
- package/dist/jsx/registerFocusable.mjs +3 -3
- package/dist/jsx/registerFocusable.mjs.map +1 -1
- package/dist/jsx/registerFocusable.native.js +40 -26
- package/dist/jsx/registerFocusable.native.js.map +1 -1
- package/package.json +7 -10
- package/dist/cjs/focusable.js +0 -14
- package/dist/cjs/focusable.js.map +0 -6
- package/dist/cjs/focusableInputHOC.js +0 -61
- package/dist/cjs/focusableInputHOC.js.map +0 -6
- package/dist/cjs/index.js +0 -17
- package/dist/cjs/index.js.map +0 -6
- package/dist/cjs/registerFocusable.js +0 -26
- package/dist/cjs/registerFocusable.js.map +0 -6
- package/dist/esm/focusable.js +0 -1
- package/dist/esm/focusable.js.map +0 -6
- package/dist/esm/focusableInputHOC.js +0 -40
- package/dist/esm/focusableInputHOC.js.map +0 -6
- package/dist/esm/registerFocusable.js +0 -10
- package/dist/esm/registerFocusable.js.map +0 -6
- package/dist/jsx/focusable.js +0 -1
- package/dist/jsx/focusable.js.map +0 -6
- package/dist/jsx/focusableInputHOC.js +0 -40
- package/dist/jsx/focusableInputHOC.js.map +0 -6
- package/dist/jsx/registerFocusable.js +0 -10
- package/dist/jsx/registerFocusable.js.map +0 -6
package/dist/cjs/focusable.cjs
CHANGED
|
@@ -3,14 +3,16 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
if (from && typeof from
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
8
|
+
get: () => from[key],
|
|
9
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
10
|
+
});
|
|
11
|
+
}
|
|
10
12
|
return to;
|
|
11
13
|
};
|
|
12
14
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
13
|
-
value:
|
|
15
|
+
value: true
|
|
14
16
|
}), mod);
|
|
15
17
|
var focusable_exports = {};
|
|
16
18
|
module.exports = __toCommonJS(focusable_exports);
|
|
@@ -5,14 +5,16 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __copyProps = (to, from, except, desc) => {
|
|
8
|
-
if (from && typeof from
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
9
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
10
|
+
get: () => from[key],
|
|
11
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
12
|
+
});
|
|
13
|
+
}
|
|
12
14
|
return to;
|
|
13
15
|
};
|
|
14
16
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
15
|
-
value:
|
|
17
|
+
value: true
|
|
16
18
|
}), mod);
|
|
17
19
|
var focusable_exports = {};
|
|
18
20
|
module.exports = __toCommonJS(focusable_exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","focusable_exports"],"sources":["../../src/focusable.ts"],"sourcesContent":[null],"mappings":"
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","focusable_exports"],"sources":["../../src/focusable.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,iBAAA","ignoreList":[]}
|
|
@@ -2,75 +2,88 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
6
|
-
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
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
|
|
30
|
+
}) : target, mod));
|
|
31
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
+
value: true
|
|
33
|
+
}), mod);
|
|
32
34
|
var focusableInputHOC_exports = {};
|
|
33
35
|
__export(focusableInputHOC_exports, {
|
|
34
36
|
useFocusable: () => useFocusable
|
|
35
37
|
});
|
|
36
38
|
module.exports = __toCommonJS(focusableInputHOC_exports);
|
|
37
|
-
var import_compose_refs = require("@tamagui/compose-refs")
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
var import_compose_refs = require("@tamagui/compose-refs");
|
|
40
|
+
var import_web = require("@tamagui/web");
|
|
41
|
+
var import_react = __toESM(require("react"), 1);
|
|
42
|
+
var import_registerFocusable = require("./registerFocusable.cjs");
|
|
41
43
|
function useFocusable({
|
|
42
44
|
isInput,
|
|
43
45
|
props,
|
|
44
46
|
ref
|
|
45
47
|
}) {
|
|
46
48
|
const {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
})
|
|
63
|
-
}));
|
|
64
|
-
}, [id, isInput, focusAndSelect]),
|
|
65
|
-
inputRef = import_react.default.useCallback(input => {
|
|
66
|
-
input && registerFocusableHandler(input);
|
|
67
|
-
}, [registerFocusableHandler]),
|
|
68
|
-
handleChangeText = (0, import_web.useEvent)(value2 => {
|
|
69
|
-
inputValue.current = value2, onChangeText?.(value2);
|
|
70
|
-
});
|
|
71
|
-
return import_react.default.useEffect(() => () => {
|
|
49
|
+
id,
|
|
50
|
+
onChangeText,
|
|
51
|
+
value,
|
|
52
|
+
defaultValue
|
|
53
|
+
} = props;
|
|
54
|
+
const inputValue = import_react.default.useRef(value || defaultValue || "");
|
|
55
|
+
const unregisterFocusable = import_react.default.useRef(void 0);
|
|
56
|
+
const focusAndSelect = import_react.default.useCallback(input => {
|
|
57
|
+
input.focus();
|
|
58
|
+
if (input.setSelection && typeof inputValue.current === "string") {
|
|
59
|
+
input.setSelection(0, inputValue.current.length);
|
|
60
|
+
}
|
|
61
|
+
}, []);
|
|
62
|
+
const registerFocusableHandler = import_react.default.useCallback(input => {
|
|
63
|
+
if (!id || !input) return;
|
|
72
64
|
unregisterFocusable.current?.();
|
|
73
|
-
|
|
65
|
+
unregisterFocusable.current = (0, import_registerFocusable.registerFocusable)(id, {
|
|
66
|
+
focus: input.focus,
|
|
67
|
+
...(isInput && {
|
|
68
|
+
focusAndSelect: () => focusAndSelect(input)
|
|
69
|
+
})
|
|
70
|
+
});
|
|
71
|
+
}, [id, isInput, focusAndSelect]);
|
|
72
|
+
const inputRef = import_react.default.useCallback(input => {
|
|
73
|
+
if (input) {
|
|
74
|
+
registerFocusableHandler(input);
|
|
75
|
+
}
|
|
76
|
+
}, [registerFocusableHandler]);
|
|
77
|
+
const handleChangeText = (0, import_web.useEvent)(value2 => {
|
|
78
|
+
inputValue.current = value2;
|
|
79
|
+
onChangeText?.(value2);
|
|
80
|
+
});
|
|
81
|
+
import_react.default.useEffect(() => {
|
|
82
|
+
return () => {
|
|
83
|
+
unregisterFocusable.current?.();
|
|
84
|
+
};
|
|
85
|
+
}, []);
|
|
86
|
+
return {
|
|
74
87
|
ref: import_react.default.useMemo(() => (0, import_compose_refs.composeRefs)(ref, inputRef), [ref, inputRef]),
|
|
75
88
|
onChangeText: handleChangeText
|
|
76
89
|
};
|
|
@@ -4,82 +4,93 @@ var __create = Object.create;
|
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
8
|
-
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
9
|
var __export = (target, all) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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, {
|
|
17
18
|
get: () => from[key],
|
|
18
19
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
20
|
});
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
22
24
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
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
|
|
32
|
+
}) : target, mod));
|
|
33
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
34
|
+
value: true
|
|
35
|
+
}), mod);
|
|
34
36
|
var focusableInputHOC_exports = {};
|
|
35
37
|
__export(focusableInputHOC_exports, {
|
|
36
38
|
useFocusable: () => useFocusable
|
|
37
39
|
});
|
|
38
40
|
module.exports = __toCommonJS(focusableInputHOC_exports);
|
|
39
|
-
var import_compose_refs = require("@tamagui/compose-refs")
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
var import_compose_refs = require("@tamagui/compose-refs");
|
|
42
|
+
var import_web = require("@tamagui/web");
|
|
43
|
+
var import_react = __toESM(require("react"), 1);
|
|
44
|
+
var import_registerFocusable = require("./registerFocusable.native.js");
|
|
43
45
|
function useFocusable(param) {
|
|
44
46
|
var {
|
|
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
|
-
handleChangeText = (0, import_web.useEvent)(function (value2) {
|
|
75
|
-
inputValue.current = value2, onChangeText?.(value2);
|
|
47
|
+
isInput,
|
|
48
|
+
props,
|
|
49
|
+
ref
|
|
50
|
+
} = param;
|
|
51
|
+
var {
|
|
52
|
+
id,
|
|
53
|
+
onChangeText,
|
|
54
|
+
value,
|
|
55
|
+
defaultValue
|
|
56
|
+
} = props;
|
|
57
|
+
var inputValue = import_react.default.useRef(value || defaultValue || "");
|
|
58
|
+
var unregisterFocusable = import_react.default.useRef(void 0);
|
|
59
|
+
var focusAndSelect = import_react.default.useCallback(function (input) {
|
|
60
|
+
input.focus();
|
|
61
|
+
if (input.setSelection && typeof inputValue.current === "string") {
|
|
62
|
+
input.setSelection(0, inputValue.current.length);
|
|
63
|
+
}
|
|
64
|
+
}, []);
|
|
65
|
+
var registerFocusableHandler = import_react.default.useCallback(function (input) {
|
|
66
|
+
var _unregisterFocusable_current;
|
|
67
|
+
if (!id || !input) return;
|
|
68
|
+
(_unregisterFocusable_current = unregisterFocusable.current) === null || _unregisterFocusable_current === void 0 ? void 0 : _unregisterFocusable_current.call(unregisterFocusable);
|
|
69
|
+
unregisterFocusable.current = (0, import_registerFocusable.registerFocusable)(id, {
|
|
70
|
+
focus: input.focus,
|
|
71
|
+
...(isInput && {
|
|
72
|
+
focusAndSelect: function () {
|
|
73
|
+
return focusAndSelect(input);
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
76
|
});
|
|
77
|
-
|
|
77
|
+
}, [id, isInput, focusAndSelect]);
|
|
78
|
+
var inputRef = import_react.default.useCallback(function (input) {
|
|
79
|
+
if (input) {
|
|
80
|
+
registerFocusableHandler(input);
|
|
81
|
+
}
|
|
82
|
+
}, [registerFocusableHandler]);
|
|
83
|
+
var handleChangeText = (0, import_web.useEvent)(function (value2) {
|
|
84
|
+
inputValue.current = value2;
|
|
85
|
+
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(value2);
|
|
86
|
+
});
|
|
87
|
+
import_react.default.useEffect(function () {
|
|
78
88
|
return function () {
|
|
79
89
|
var _unregisterFocusable_current;
|
|
80
|
-
(_unregisterFocusable_current = unregisterFocusable.current) === null || _unregisterFocusable_current === void 0
|
|
90
|
+
(_unregisterFocusable_current = unregisterFocusable.current) === null || _unregisterFocusable_current === void 0 ? void 0 : _unregisterFocusable_current.call(unregisterFocusable);
|
|
81
91
|
};
|
|
82
|
-
}, [])
|
|
92
|
+
}, []);
|
|
93
|
+
return {
|
|
83
94
|
ref: import_react.default.useMemo(function () {
|
|
84
95
|
return (0, import_compose_refs.composeRefs)(ref, inputRef);
|
|
85
96
|
}, [ref, inputRef]),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","focusableInputHOC_exports","__export","useFocusable","module","exports","import_compose_refs","require","import_web","import_react","__toESM","import_registerFocusable","param","isInput","props","ref","id","onChangeText","defaultValue","inputValue","default","useRef","unregisterFocusable","focusAndSelect","useCallback","input","focus","setSelection","current","length","registerFocusableHandler","_unregisterFocusable_current","call","registerFocusable","inputRef","handleChangeText","useEvent","value2","useEffect","useMemo"],"sources":["../../src/focusableInputHOC.tsx"],"sourcesContent":[null],"mappings":"
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","focusableInputHOC_exports","__export","useFocusable","module","exports","import_compose_refs","require","import_web","import_react","__toESM","import_registerFocusable","param","isInput","props","ref","id","onChangeText","defaultValue","inputValue","default","useRef","unregisterFocusable","focusAndSelect","useCallback","input","focus","setSelection","current","length","registerFocusableHandler","_unregisterFocusable_current","call","registerFocusable","inputRef","handleChangeText","useEvent","value2","useEffect","useMemo","composeRefs"],"sources":["../../src/focusableInputHOC.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,yBAAA;AAAAC,QAAA,CAAAD,yBAAA;EAAAE,YAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAT,YAA4B,CAAAK,yBAAA;AAC5B,IAAAK,mBAAyB,GAAAC,OAAA;AAEzB,IAAAC,UAAA,GAAAD,OAAkB;AAElB,IAAAE,YAAA,GAAAC,OAAA,CAAAH,OAAkC;AAS3B,IAAAI,wBAAsB,GAAAJ,OAAA;AAAA,SAC3BJ,aAAAS,KAAA;EACA;IAAAC,OAAA;IAAAC,KAAA;IAAAC;EAAA,IAAAH,KAAA;EACA;IAAAI,EAAA;IAAAC,YAAA;IAAAjB,KAAA;IAAAkB;EAAA,IAAAJ,KAAA;EACF,IAIGK,UAAA,GAAAV,YAAA,CAAAW,OAAA,CAAAC,MAAA,CAAArB,KAAA,IAAAkB,YAAA;EACD,IAAAI,mBAAY,GAAcb,YAAO,CAAAW,OAAa,CAAAC,MAAI;EAClD,IAAAE,cAAM,GAAad,YAAA,CAAAW,OAAM,CAAAI,WAAO,WAASC,KAAA;IACzCA,KAAM,CAAAC,KAAA;IAEN,IAAMD,KAAA,CAAAE,YAAiB,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A,EAAAzB,GAAA,EAAAmB,QAAA","ignoreList":[]}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -3,15 +3,17 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
7
8
|
get: () => from[key],
|
|
8
9
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
9
10
|
});
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
13
15
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
14
|
-
value:
|
|
16
|
+
value: true
|
|
15
17
|
}), mod);
|
|
16
18
|
var index_exports = {};
|
|
17
19
|
module.exports = __toCommonJS(index_exports);
|
package/dist/cjs/index.native.js
CHANGED
|
@@ -5,15 +5,17 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __copyProps = (to, from, except, desc) => {
|
|
8
|
-
|
|
8
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
9
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
9
10
|
get: () => from[key],
|
|
10
11
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
11
12
|
});
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
17
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
16
|
-
value:
|
|
18
|
+
value: true
|
|
17
19
|
}), mod);
|
|
18
20
|
var index_exports = {};
|
|
19
21
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","module","exports","__reExport","require"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","module","exports","__reExport","require"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAP,YAAc,CAAAK,aAAA;AACdG,UAAA,CAAAH,aAAA,EAAcI,OAAA,mCADdH,MAAA,CAAAC,OAAA;AAEAC,UAAA,CAAAH,aAAA,EAAcI,OAAA,gCAFd,GAAAH,MAAA,CAAAC,OAAA","ignoreList":[]}
|
|
@@ -3,20 +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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
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, {
|
|
13
14
|
get: () => from[key],
|
|
14
15
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
16
|
});
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
18
20
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
-
value:
|
|
21
|
+
value: true
|
|
20
22
|
}), mod);
|
|
21
23
|
var registerFocusable_exports = {};
|
|
22
24
|
__export(registerFocusable_exports, {
|
|
@@ -25,6 +27,6 @@ __export(registerFocusable_exports, {
|
|
|
25
27
|
unregisterFocusable: () => unregisterFocusable
|
|
26
28
|
});
|
|
27
29
|
module.exports = __toCommonJS(registerFocusable_exports);
|
|
28
|
-
const registerFocusable = (id, input) => () => {}
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
const registerFocusable = (id, input) => () => {};
|
|
31
|
+
const unregisterFocusable = id => {};
|
|
32
|
+
const focusFocusable = id => {};
|
|
@@ -5,20 +5,22 @@ 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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
-
value:
|
|
23
|
+
value: true
|
|
22
24
|
}), mod);
|
|
23
25
|
var registerFocusable_native_exports = {};
|
|
24
26
|
__export(registerFocusable_native_exports, {
|
|
@@ -27,22 +29,34 @@ __export(registerFocusable_native_exports, {
|
|
|
27
29
|
unregisterFocusable: () => unregisterFocusable
|
|
28
30
|
});
|
|
29
31
|
module.exports = __toCommonJS(registerFocusable_native_exports);
|
|
30
|
-
var InputsMap = /* @__PURE__ */new Map()
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
},
|
|
36
|
-
unregisterFocusable = function (id) {
|
|
37
|
-
InputsMap.delete(id);
|
|
38
|
-
},
|
|
39
|
-
focusFocusable = function (id) {
|
|
40
|
-
var select = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1,
|
|
41
|
-
input = InputsMap.get(id);
|
|
42
|
-
if (!input) {
|
|
43
|
-
process.env.NODE_ENV === "development" && console.warn("No input found for id", id);
|
|
44
|
-
return;
|
|
32
|
+
var InputsMap = /* @__PURE__ */new Map();
|
|
33
|
+
var registerFocusable = function (id, input) {
|
|
34
|
+
if (process.env.NODE_ENV === "development") {
|
|
35
|
+
if (InputsMap.has(id)) {
|
|
36
|
+
console.warn(`Warning, duplicate ID for input: ${id}`);
|
|
45
37
|
}
|
|
46
|
-
|
|
38
|
+
}
|
|
39
|
+
InputsMap.set(id, input);
|
|
40
|
+
return function () {
|
|
41
|
+
InputsMap.delete(id);
|
|
47
42
|
};
|
|
43
|
+
};
|
|
44
|
+
var unregisterFocusable = function (id) {
|
|
45
|
+
InputsMap.delete(id);
|
|
46
|
+
};
|
|
47
|
+
var focusFocusable = function (id) {
|
|
48
|
+
var select = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
49
|
+
var input = InputsMap.get(id);
|
|
50
|
+
if (!input) {
|
|
51
|
+
if (process.env.NODE_ENV === "development") {
|
|
52
|
+
console.warn("No input found for id", id);
|
|
53
|
+
}
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (select || !input.focusAndSelect) {
|
|
57
|
+
input.focus();
|
|
58
|
+
} else {
|
|
59
|
+
input.focusAndSelect();
|
|
60
|
+
}
|
|
61
|
+
};
|
|
48
62
|
//# sourceMappingURL=registerFocusable.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["registerFocusable_native_exports","__export","focusFocusable","registerFocusable","unregisterFocusable","module","exports","__toCommonJS","InputsMap","Map","id","input","process","env","NODE_ENV","has","console","warn","set","delete","select","arguments","length","get","focusAndSelect","focus"],"sources":["../../src/registerFocusable.native.ts"],"sourcesContent":[null],"mappings":"
|
|
1
|
+
{"version":3,"names":["registerFocusable_native_exports","__export","focusFocusable","registerFocusable","unregisterFocusable","module","exports","__toCommonJS","InputsMap","Map","id","input","process","env","NODE_ENV","has","console","warn","set","delete","select","arguments","length","get","focusAndSelect","focus"],"sources":["../../src/registerFocusable.native.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,gCAAA;AAAAC,QAAA,CAAAD,gCAAA;EAAAE,cAAA,EAAAA,CAAA,KAAAA,cAAA;EAAAC,iBAAA,EAAAA,CAAA,KAAAA,iBAAA;EAAAC,mBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAC,YAAA,CAAAP,gCAAA;AACA,IAAIQ,SAAA,GAAY,mBAAIC,GAAA,CAAI;AACjB,IA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
24
|
-
|
|
25
|
-
|
|
26
|
-
})
|
|
27
|
-
}));
|
|
28
|
-
}, [id, isInput, focusAndSelect]),
|
|
29
|
-
inputRef = React.useCallback(input => {
|
|
30
|
-
input && registerFocusableHandler(input);
|
|
31
|
-
}, [registerFocusableHandler]),
|
|
32
|
-
handleChangeText = useEvent(value2 => {
|
|
33
|
-
inputValue.current = value2, onChangeText?.(value2);
|
|
34
|
-
});
|
|
35
|
-
return React.useEffect(() => () => {
|
|
11
|
+
id,
|
|
12
|
+
onChangeText,
|
|
13
|
+
value,
|
|
14
|
+
defaultValue
|
|
15
|
+
} = props;
|
|
16
|
+
const inputValue = React.useRef(value || defaultValue || "");
|
|
17
|
+
const unregisterFocusable = React.useRef(void 0);
|
|
18
|
+
const focusAndSelect = React.useCallback(input => {
|
|
19
|
+
input.focus();
|
|
20
|
+
if (input.setSelection && typeof inputValue.current === "string") {
|
|
21
|
+
input.setSelection(0, inputValue.current.length);
|
|
22
|
+
}
|
|
23
|
+
}, []);
|
|
24
|
+
const registerFocusableHandler = React.useCallback(input => {
|
|
25
|
+
if (!id || !input) return;
|
|
36
26
|
unregisterFocusable.current?.();
|
|
37
|
-
|
|
27
|
+
unregisterFocusable.current = registerFocusable(id, {
|
|
28
|
+
focus: input.focus,
|
|
29
|
+
...(isInput && {
|
|
30
|
+
focusAndSelect: () => focusAndSelect(input)
|
|
31
|
+
})
|
|
32
|
+
});
|
|
33
|
+
}, [id, isInput, focusAndSelect]);
|
|
34
|
+
const inputRef = React.useCallback(input => {
|
|
35
|
+
if (input) {
|
|
36
|
+
registerFocusableHandler(input);
|
|
37
|
+
}
|
|
38
|
+
}, [registerFocusableHandler]);
|
|
39
|
+
const handleChangeText = useEvent(value2 => {
|
|
40
|
+
inputValue.current = value2;
|
|
41
|
+
onChangeText?.(value2);
|
|
42
|
+
});
|
|
43
|
+
React.useEffect(() => {
|
|
44
|
+
return () => {
|
|
45
|
+
unregisterFocusable.current?.();
|
|
46
|
+
};
|
|
47
|
+
}, []);
|
|
48
|
+
return {
|
|
38
49
|
ref: React.useMemo(() => composeRefs(ref, inputRef), [ref, inputRef]),
|
|
39
50
|
onChangeText: handleChangeText
|
|
40
51
|
};
|