@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
|
@@ -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 __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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, \"default\"), secondTarget && __copyProps(secondTarget, mod, \"default\"));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar index_exports = {};\nmodule.exports = __toCommonJS(index_exports);\n__reExport(index_exports, require(\"./registerFocusable\"), module.exports);\n__reExport(index_exports, require(\"./focusableInputHOC\"), module.exports);\n__reExport(index_exports, require(\"./focusable\"), module.exports);\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,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,cAAc,QAAQ,KAAK,kBAAkB,YAAY,QAAQ,KAAK,SAAS,GAAG,gBAAgB,YAAY,cAAc,KAAK,SAAS;AAC9I,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,gBAAgB,CAAC;AACrB,OAAO,UAAU,aAAa,aAAa;AAC3C,WAAW,eAAe,QAAQ,+BAAqB,GAAG,OAAO,OAAO;AACxE,WAAW,eAAe,QAAQ,+BAAqB,GAAG,OAAO,OAAO;AACxE,WAAW,eAAe,QAAQ,uBAAa,GAAG,OAAO,OAAO"}
|
|
@@ -1,32 +1,31 @@
|
|
|
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 __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
for (var name in all) __defProp(target, name, {
|
|
8
|
+
get: all[name],
|
|
9
|
+
enumerable: true
|
|
10
|
+
});
|
|
10
11
|
};
|
|
11
12
|
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
19
20
|
};
|
|
20
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
-
value: true
|
|
22
|
-
}), mod);
|
|
21
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
22
|
var registerFocusable_exports = {};
|
|
24
23
|
__export(registerFocusable_exports, {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
focusFocusable: () => focusFocusable,
|
|
25
|
+
registerFocusable: () => registerFocusable,
|
|
26
|
+
unregisterFocusable: () => unregisterFocusable
|
|
28
27
|
});
|
|
29
28
|
module.exports = __toCommonJS(registerFocusable_exports);
|
|
30
29
|
const registerFocusable = (id, input) => () => {};
|
|
31
|
-
const unregisterFocusable = id => {};
|
|
32
|
-
const focusFocusable = id => {};
|
|
30
|
+
const unregisterFocusable = (id) => {};
|
|
31
|
+
const focusFocusable = (id) => {};
|
|
@@ -0,0 +1,60 @@
|
|
|
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 __export = (target, all) => {
|
|
9
|
+
for (var name in all) __defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
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;
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var registerFocusable_native_exports = {};
|
|
25
|
+
__export(registerFocusable_native_exports, {
|
|
26
|
+
focusFocusable: () => focusFocusable,
|
|
27
|
+
registerFocusable: () => registerFocusable,
|
|
28
|
+
unregisterFocusable: () => unregisterFocusable
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(registerFocusable_native_exports);
|
|
31
|
+
var InputsMap = /* @__PURE__ */ new Map();
|
|
32
|
+
var registerFocusable = function(id, input) {
|
|
33
|
+
if (process.env.NODE_ENV === "development") {
|
|
34
|
+
if (InputsMap.has(id)) {
|
|
35
|
+
console.warn(`Warning, duplicate ID for input: ${id}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
InputsMap.set(id, input);
|
|
39
|
+
return function() {
|
|
40
|
+
InputsMap.delete(id);
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
var unregisterFocusable = function(id) {
|
|
44
|
+
InputsMap.delete(id);
|
|
45
|
+
};
|
|
46
|
+
var focusFocusable = function(id) {
|
|
47
|
+
var select = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
48
|
+
var input = InputsMap.get(id);
|
|
49
|
+
if (!input) {
|
|
50
|
+
if (process.env.NODE_ENV === "development") {
|
|
51
|
+
console.warn("No input found for id", id);
|
|
52
|
+
}
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (select || !input.focusAndSelect) {
|
|
56
|
+
input.focus();
|
|
57
|
+
} else {
|
|
58
|
+
input.focusAndSelect();
|
|
59
|
+
}
|
|
60
|
+
};
|
|
@@ -1,62 +1,62 @@
|
|
|
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 __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 __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
-
value: true
|
|
24
|
-
}), mod);
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
24
|
var registerFocusable_native_exports = {};
|
|
26
25
|
__export(registerFocusable_native_exports, {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
focusFocusable: () => focusFocusable,
|
|
27
|
+
registerFocusable: () => registerFocusable,
|
|
28
|
+
unregisterFocusable: () => unregisterFocusable
|
|
30
29
|
});
|
|
31
30
|
module.exports = __toCommonJS(registerFocusable_native_exports);
|
|
32
|
-
var InputsMap = /* @__PURE__ */new Map();
|
|
33
|
-
var registerFocusable = function
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
31
|
+
var InputsMap = /* @__PURE__ */ new Map();
|
|
32
|
+
var registerFocusable = function(id, input) {
|
|
33
|
+
if (process.env.NODE_ENV === "development") {
|
|
34
|
+
if (InputsMap.has(id)) {
|
|
35
|
+
console.warn(`Warning, duplicate ID for input: ${id}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
InputsMap.set(id, input);
|
|
39
|
+
return function() {
|
|
40
|
+
InputsMap.delete(id);
|
|
41
|
+
};
|
|
43
42
|
};
|
|
44
|
-
var unregisterFocusable = function
|
|
45
|
-
|
|
43
|
+
var unregisterFocusable = function(id) {
|
|
44
|
+
InputsMap.delete(id);
|
|
46
45
|
};
|
|
47
|
-
var focusFocusable = function
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
46
|
+
var focusFocusable = function(id) {
|
|
47
|
+
var select = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
48
|
+
var input = InputsMap.get(id);
|
|
49
|
+
if (!input) {
|
|
50
|
+
if (process.env.NODE_ENV === "development") {
|
|
51
|
+
console.warn("No input found for id", id);
|
|
52
|
+
}
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (select || !input.focusAndSelect) {
|
|
56
|
+
input.focus();
|
|
57
|
+
} else {
|
|
58
|
+
input.focusAndSelect();
|
|
59
|
+
}
|
|
61
60
|
};
|
|
61
|
+
|
|
62
62
|
//# sourceMappingURL=registerFocusable.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"registerFocusable.native.js","names":[],"sources":["cjs/registerFocusable.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 registerFocusable_native_exports = {};\n__export(registerFocusable_native_exports, {\n focusFocusable: () => focusFocusable,\n registerFocusable: () => registerFocusable,\n unregisterFocusable: () => unregisterFocusable\n});\nmodule.exports = __toCommonJS(registerFocusable_native_exports);\nvar InputsMap = /* @__PURE__ */ new Map();\nvar registerFocusable = function(id, input) {\n if (process.env.NODE_ENV === \"development\") {\n if (InputsMap.has(id)) {\n console.warn(`Warning, duplicate ID for input: ${id}`);\n }\n }\n InputsMap.set(id, input);\n return function() {\n InputsMap.delete(id);\n };\n};\nvar unregisterFocusable = function(id) {\n InputsMap.delete(id);\n};\nvar focusFocusable = function(id) {\n var select = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;\n var input = InputsMap.get(id);\n if (!input) {\n if (process.env.NODE_ENV === \"development\") {\n console.warn(\"No input found for id\", id);\n }\n return;\n }\n if (select || !input.focusAndSelect) {\n input.focus();\n } else {\n input.focusAndSelect();\n }\n};\n//# sourceMappingURL=registerFocusable.native.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,mCAAmC,CAAC;AACxC,SAAS,kCAAkC;CACzC,sBAAsB;CACtB,yBAAyB;CACzB,2BAA2B;AAC7B,CAAC;AACD,OAAO,UAAU,aAAa,gCAAgC;AAC9D,IAAI,4BAA4B,IAAI,IAAI;AACxC,IAAI,oBAAoB,SAAS,IAAI,OAAO;CAC1C,IAAI,QAAQ,IAAI,aAAa,eAAe;EAC1C,IAAI,UAAU,IAAI,EAAE,GAAG;GACrB,QAAQ,KAAK,oCAAoC,IAAI;EACvD;CACF;CACA,UAAU,IAAI,IAAI,KAAK;CACvB,OAAO,WAAW;EAChB,UAAU,OAAO,EAAE;CACrB;AACF;AACA,IAAI,sBAAsB,SAAS,IAAI;CACrC,UAAU,OAAO,EAAE;AACrB;AACA,IAAI,iBAAiB,SAAS,IAAI;CAChC,IAAI,SAAS,UAAU,SAAS,KAAK,UAAU,OAAO,KAAK,IAAI,UAAU,KAAK;CAC9E,IAAI,QAAQ,UAAU,IAAI,EAAE;CAC5B,IAAI,CAAC,OAAO;EACV,IAAI,QAAQ,IAAI,aAAa,eAAe;GAC1C,QAAQ,KAAK,yBAAyB,EAAE;EAC1C;EACA;CACF;CACA,IAAI,UAAU,CAAC,MAAM,gBAAgB;EACnC,MAAM,MAAM;CACd,OAAO;EACL,MAAM,eAAe;CACvB;AACF"}
|
package/dist/esm/focusable.mjs
CHANGED
|
@@ -2,53 +2,48 @@ import { composeRefs } from "@tamagui/compose-refs";
|
|
|
2
2
|
import { useEvent } from "@tamagui/web";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { registerFocusable } from "./registerFocusable.mjs";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
};
|
|
47
|
-
}, []);
|
|
48
|
-
return {
|
|
49
|
-
ref: React.useMemo(() => composeRefs(ref, inputRef), [ref, inputRef]),
|
|
50
|
-
onChangeText: handleChangeText
|
|
51
|
-
};
|
|
5
|
+
|
|
6
|
+
function useFocusable({ isInput, props, ref }) {
|
|
7
|
+
const { id, onChangeText, value, defaultValue } = props;
|
|
8
|
+
const inputValue = React.useRef(value || defaultValue || "");
|
|
9
|
+
const unregisterFocusable = React.useRef(void 0);
|
|
10
|
+
const focusAndSelect = React.useCallback((input) => {
|
|
11
|
+
input.focus();
|
|
12
|
+
if (input.setSelection && typeof inputValue.current === "string") {
|
|
13
|
+
input.setSelection(0, inputValue.current.length);
|
|
14
|
+
}
|
|
15
|
+
}, []);
|
|
16
|
+
const registerFocusableHandler = React.useCallback((input) => {
|
|
17
|
+
if (!id || !input) return;
|
|
18
|
+
unregisterFocusable.current?.();
|
|
19
|
+
unregisterFocusable.current = registerFocusable(id, {
|
|
20
|
+
focus: input.focus,
|
|
21
|
+
...isInput && { focusAndSelect: () => focusAndSelect(input) }
|
|
22
|
+
});
|
|
23
|
+
}, [
|
|
24
|
+
id,
|
|
25
|
+
isInput,
|
|
26
|
+
focusAndSelect
|
|
27
|
+
]);
|
|
28
|
+
const inputRef = React.useCallback((input) => {
|
|
29
|
+
if (input) {
|
|
30
|
+
registerFocusableHandler(input);
|
|
31
|
+
}
|
|
32
|
+
}, [registerFocusableHandler]);
|
|
33
|
+
const handleChangeText = useEvent((value2) => {
|
|
34
|
+
inputValue.current = value2;
|
|
35
|
+
onChangeText?.(value2);
|
|
36
|
+
});
|
|
37
|
+
React.useEffect(() => {
|
|
38
|
+
return () => {
|
|
39
|
+
unregisterFocusable.current?.();
|
|
40
|
+
};
|
|
41
|
+
}, []);
|
|
42
|
+
return {
|
|
43
|
+
ref: React.useMemo(() => composeRefs(ref, inputRef), [ref, inputRef]),
|
|
44
|
+
onChangeText: handleChangeText
|
|
45
|
+
};
|
|
52
46
|
}
|
|
47
|
+
|
|
53
48
|
export { useFocusable };
|
|
54
49
|
//# sourceMappingURL=focusableInputHOC.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"focusableInputHOC.js","names":[],"sources":["esm/focusableInputHOC.js"],"sourcesContent":["import { composeRefs } from \"@tamagui/compose-refs\";\nimport { useEvent } from \"@tamagui/web\";\nimport React from \"react\";\nimport { registerFocusable } from \"./registerFocusable\";\nfunction useFocusable({\n isInput,\n props,\n ref\n}) {\n const { id, onChangeText, value, defaultValue } = props;\n const inputValue = React.useRef(value || defaultValue || \"\");\n const unregisterFocusable = React.useRef(void 0);\n const focusAndSelect = React.useCallback((input) => {\n input.focus();\n if (input.setSelection && typeof inputValue.current === \"string\") {\n input.setSelection(0, inputValue.current.length);\n }\n }, []);\n const registerFocusableHandler = React.useCallback(\n (input) => {\n if (!id || !input) return;\n unregisterFocusable.current?.();\n unregisterFocusable.current = registerFocusable(id, {\n focus: input.focus,\n ...isInput && {\n focusAndSelect: () => focusAndSelect(input)\n }\n });\n },\n [id, isInput, focusAndSelect]\n );\n const inputRef = React.useCallback(\n (input) => {\n if (input) {\n registerFocusableHandler(input);\n }\n },\n [registerFocusableHandler]\n );\n const handleChangeText = useEvent((value2) => {\n inputValue.current = value2;\n onChangeText?.(value2);\n });\n React.useEffect(() => {\n return () => {\n unregisterFocusable.current?.();\n };\n }, []);\n return {\n ref: React.useMemo(() => composeRefs(ref, inputRef), [ref, inputRef]),\n onChangeText: handleChangeText\n };\n}\nexport {\n useFocusable\n};\n//# sourceMappingURL=focusableInputHOC.js.map\n"],"mappings":";;;;;;AAIA,SAAS,aAAa,EACpB,SACA,OACA,OACC;CACD,MAAM,EAAE,IAAI,cAAc,OAAO,iBAAiB;CAClD,MAAM,aAAa,MAAM,OAAO,SAAS,gBAAgB,EAAE;CAC3D,MAAM,sBAAsB,MAAM,OAAO,KAAK,CAAC;CAC/C,MAAM,iBAAiB,MAAM,aAAa,UAAU;EAClD,MAAM,MAAM;EACZ,IAAI,MAAM,gBAAgB,OAAO,WAAW,YAAY,UAAU;GAChE,MAAM,aAAa,GAAG,WAAW,QAAQ,MAAM;EACjD;CACF,GAAG,CAAC,CAAC;CACL,MAAM,2BAA2B,MAAM,aACpC,UAAU;EACT,IAAI,CAAC,MAAM,CAAC,OAAO;EACnB,oBAAoB,UAAU;EAC9B,oBAAoB,UAAU,kBAAkB,IAAI;GAClD,OAAO,MAAM;GACb,GAAG,WAAW,EACZ,sBAAsB,eAAe,KAAK,EAC5C;EACF,CAAC;CACH,GACA;EAAC;EAAI;EAAS;CAAc,CAC9B;CACA,MAAM,WAAW,MAAM,aACpB,UAAU;EACT,IAAI,OAAO;GACT,yBAAyB,KAAK;EAChC;CACF,GACA,CAAC,wBAAwB,CAC3B;CACA,MAAM,mBAAmB,UAAU,WAAW;EAC5C,WAAW,UAAU;EACrB,eAAe,MAAM;CACvB,CAAC;CACD,MAAM,gBAAgB;EACpB,aAAa;GACX,oBAAoB,UAAU;EAChC;CACF,GAAG,CAAC,CAAC;CACL,OAAO;EACL,KAAK,MAAM,cAAc,YAAY,KAAK,QAAQ,GAAG,CAAC,KAAK,QAAQ,CAAC;EACpE,cAAc;CAChB;AACF"}
|
|
@@ -2,60 +2,55 @@ import { composeRefs } from "@tamagui/compose-refs";
|
|
|
2
2
|
import { useEvent } from "@tamagui/web";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { registerFocusable } from "./registerFocusable.native.js";
|
|
5
|
+
|
|
5
6
|
function useFocusable(param) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}, []);
|
|
53
|
-
return {
|
|
54
|
-
ref: React.useMemo(function () {
|
|
55
|
-
return composeRefs(ref, inputRef);
|
|
56
|
-
}, [ref, inputRef]),
|
|
57
|
-
onChangeText: handleChangeText
|
|
58
|
-
};
|
|
7
|
+
var { isInput, props, ref } = param;
|
|
8
|
+
var { id, onChangeText, value, defaultValue } = props;
|
|
9
|
+
var inputValue = React.useRef(value || defaultValue || "");
|
|
10
|
+
var unregisterFocusable = React.useRef(void 0);
|
|
11
|
+
var focusAndSelect = React.useCallback(function(input) {
|
|
12
|
+
input.focus();
|
|
13
|
+
if (input.setSelection && typeof inputValue.current === "string") {
|
|
14
|
+
input.setSelection(0, inputValue.current.length);
|
|
15
|
+
}
|
|
16
|
+
}, []);
|
|
17
|
+
var registerFocusableHandler = React.useCallback(function(input) {
|
|
18
|
+
var _unregisterFocusable_current;
|
|
19
|
+
if (!id || !input) return;
|
|
20
|
+
(_unregisterFocusable_current = unregisterFocusable.current) === null || _unregisterFocusable_current === void 0 ? void 0 : _unregisterFocusable_current.call(unregisterFocusable);
|
|
21
|
+
unregisterFocusable.current = registerFocusable(id, {
|
|
22
|
+
focus: input.focus,
|
|
23
|
+
...isInput && { focusAndSelect: function() {
|
|
24
|
+
return focusAndSelect(input);
|
|
25
|
+
} }
|
|
26
|
+
});
|
|
27
|
+
}, [
|
|
28
|
+
id,
|
|
29
|
+
isInput,
|
|
30
|
+
focusAndSelect
|
|
31
|
+
]);
|
|
32
|
+
var inputRef = React.useCallback(function(input) {
|
|
33
|
+
if (input) {
|
|
34
|
+
registerFocusableHandler(input);
|
|
35
|
+
}
|
|
36
|
+
}, [registerFocusableHandler]);
|
|
37
|
+
var handleChangeText = useEvent(function(value2) {
|
|
38
|
+
inputValue.current = value2;
|
|
39
|
+
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(value2);
|
|
40
|
+
});
|
|
41
|
+
React.useEffect(function() {
|
|
42
|
+
return function() {
|
|
43
|
+
var _unregisterFocusable_current;
|
|
44
|
+
(_unregisterFocusable_current = unregisterFocusable.current) === null || _unregisterFocusable_current === void 0 ? void 0 : _unregisterFocusable_current.call(unregisterFocusable);
|
|
45
|
+
};
|
|
46
|
+
}, []);
|
|
47
|
+
return {
|
|
48
|
+
ref: React.useMemo(function() {
|
|
49
|
+
return composeRefs(ref, inputRef);
|
|
50
|
+
}, [ref, inputRef]),
|
|
51
|
+
onChangeText: handleChangeText
|
|
52
|
+
};
|
|
59
53
|
}
|
|
54
|
+
|
|
60
55
|
export { useFocusable };
|
|
61
56
|
//# sourceMappingURL=focusableInputHOC.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"file":"focusableInputHOC.native.js","names":[],"sources":["esm/focusableInputHOC.native.js"],"sourcesContent":["import { composeRefs } from \"@tamagui/compose-refs\";\nimport { useEvent } from \"@tamagui/web\";\nimport React from \"react\";\nimport { registerFocusable } from \"./registerFocusable\";\nfunction useFocusable(param) {\n var { isInput, props, ref } = param;\n var { id, onChangeText, value, defaultValue } = props;\n var inputValue = React.useRef(value || defaultValue || \"\");\n var unregisterFocusable = React.useRef(void 0);\n var focusAndSelect = React.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 = React.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 = 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 = React.useCallback(function(input) {\n if (input) {\n registerFocusableHandler(input);\n }\n }, [\n registerFocusableHandler\n ]);\n var handleChangeText = useEvent(function(value2) {\n inputValue.current = value2;\n onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(value2);\n });\n React.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: React.useMemo(function() {\n return composeRefs(ref, inputRef);\n }, [\n ref,\n inputRef\n ]),\n onChangeText: handleChangeText\n };\n}\nexport {\n useFocusable\n};\n//# sourceMappingURL=focusableInputHOC.js.map\n"],"mappings":";;;;;;AAIA,SAAS,aAAa,OAAO;CAC3B,IAAI,EAAE,SAAS,OAAO,QAAQ;CAC9B,IAAI,EAAE,IAAI,cAAc,OAAO,iBAAiB;CAChD,IAAI,aAAa,MAAM,OAAO,SAAS,gBAAgB,EAAE;CACzD,IAAI,sBAAsB,MAAM,OAAO,KAAK,CAAC;CAC7C,IAAI,iBAAiB,MAAM,YAAY,SAAS,OAAO;EACrD,MAAM,MAAM;EACZ,IAAI,MAAM,gBAAgB,OAAO,WAAW,YAAY,UAAU;GAChE,MAAM,aAAa,GAAG,WAAW,QAAQ,MAAM;EACjD;CACF,GAAG,CAAC,CAAC;CACL,IAAI,2BAA2B,MAAM,YAAY,SAAS,OAAO;EAC/D,IAAI;EACJ,IAAI,CAAC,MAAM,CAAC,OAAO;EACnB,CAAC,+BAA+B,oBAAoB,aAAa,QAAQ,iCAAiC,KAAK,IAAI,KAAK,IAAI,6BAA6B,KAAK,mBAAmB;EACjL,oBAAoB,UAAU,kBAAkB,IAAI;GAClD,OAAO,MAAM;GACb,GAAG,WAAW,EACZ,gBAAgB,WAAW;IACzB,OAAO,eAAe,KAAK;GAC7B,EACF;EACF,CAAC;CACH,GAAG;EACD;EACA;EACA;CACF,CAAC;CACD,IAAI,WAAW,MAAM,YAAY,SAAS,OAAO;EAC/C,IAAI,OAAO;GACT,yBAAyB,KAAK;EAChC;CACF,GAAG,CACD,wBACF,CAAC;CACD,IAAI,mBAAmB,SAAS,SAAS,QAAQ;EAC/C,WAAW,UAAU;EACrB,iBAAiB,QAAQ,iBAAiB,KAAK,IAAI,KAAK,IAAI,aAAa,MAAM;CACjF,CAAC;CACD,MAAM,UAAU,WAAW;EACzB,OAAO,WAAW;GAChB,IAAI;GACJ,CAAC,+BAA+B,oBAAoB,aAAa,QAAQ,iCAAiC,KAAK,IAAI,KAAK,IAAI,6BAA6B,KAAK,mBAAmB;EACnL;CACF,GAAG,CAAC,CAAC;CACL,OAAO;EACL,KAAK,MAAM,QAAQ,WAAW;GAC5B,OAAO,YAAY,KAAK,QAAQ;EAClC,GAAG,CACD,KACA,QACF,CAAC;EACD,cAAc;CAChB;AACF"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export * from "./registerFocusable.mjs"
|
|
2
|
-
|
|
3
|
-
export * from "./
|
|
4
|
-
|
|
1
|
+
export * from "./registerFocusable.mjs"
|
|
2
|
+
|
|
3
|
+
export * from "./focusableInputHOC.mjs"
|
|
4
|
+
|
|
5
|
+
export * from "./focusable.mjs"
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export * from "./registerFocusable.mjs"
|
|
2
|
-
|
|
3
|
-
export * from "./
|
|
4
|
-
|
|
1
|
+
export * from "./registerFocusable.mjs"
|
|
2
|
+
|
|
3
|
+
export * from "./focusableInputHOC.mjs"
|
|
4
|
+
|
|
5
|
+
export * from "./focusable.mjs"
|
package/dist/esm/index.native.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export * from "./registerFocusable.native.js"
|
|
2
|
-
|
|
3
|
-
export * from "./
|
|
4
|
-
|
|
1
|
+
export * from "./registerFocusable.native.js"
|
|
2
|
+
|
|
3
|
+
export * from "./focusableInputHOC.native.js"
|
|
4
|
+
|
|
5
|
+
export * from "./focusable.native.js"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const registerFocusable = (id, input) => () => {};
|
|
2
|
-
const unregisterFocusable = id => {};
|
|
3
|
-
const focusFocusable = id => {};
|
|
2
|
+
const unregisterFocusable = (id) => {};
|
|
3
|
+
const focusFocusable = (id) => {};
|
|
4
|
+
|
|
4
5
|
export { focusFocusable, registerFocusable, unregisterFocusable };
|
|
5
6
|
//# sourceMappingURL=registerFocusable.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"registerFocusable.js","names":[],"sources":["esm/registerFocusable.js"],"sourcesContent":["const registerFocusable = (id, input) => () => {\n};\nconst unregisterFocusable = (id) => {\n};\nconst focusFocusable = (id) => {\n};\nexport {\n focusFocusable,\n registerFocusable,\n unregisterFocusable\n};\n//# sourceMappingURL=registerFocusable.js.map\n"],"mappings":";AAAA,MAAM,qBAAqB,IAAI,gBAAgB,CAC/C;AACA,MAAM,uBAAuB,OAAO,CACpC;AACA,MAAM,kBAAkB,OAAO,CAC/B"}
|
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
var InputsMap = /* @__PURE__ */new Map();
|
|
2
|
-
var registerFocusable = function
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
var InputsMap = /* @__PURE__ */ new Map();
|
|
2
|
+
var registerFocusable = function(id, input) {
|
|
3
|
+
if (process.env.NODE_ENV === "development") {
|
|
4
|
+
if (InputsMap.has(id)) {
|
|
5
|
+
console.warn(`Warning, duplicate ID for input: ${id}`);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
InputsMap.set(id, input);
|
|
9
|
+
return function() {
|
|
10
|
+
InputsMap.delete(id);
|
|
11
|
+
};
|
|
12
12
|
};
|
|
13
|
-
var unregisterFocusable = function
|
|
14
|
-
|
|
13
|
+
var unregisterFocusable = function(id) {
|
|
14
|
+
InputsMap.delete(id);
|
|
15
15
|
};
|
|
16
|
-
var focusFocusable = function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
16
|
+
var focusFocusable = function(id) {
|
|
17
|
+
var select = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
18
|
+
var input = InputsMap.get(id);
|
|
19
|
+
if (!input) {
|
|
20
|
+
if (process.env.NODE_ENV === "development") {
|
|
21
|
+
console.warn("No input found for id", id);
|
|
22
|
+
}
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (select || !input.focusAndSelect) {
|
|
26
|
+
input.focus();
|
|
27
|
+
} else {
|
|
28
|
+
input.focusAndSelect();
|
|
29
|
+
}
|
|
30
30
|
};
|
|
31
|
+
|
|
31
32
|
export { focusFocusable, registerFocusable, unregisterFocusable };
|
|
32
33
|
//# sourceMappingURL=registerFocusable.native.js.map
|