@tamagui/focusable 1.14.1 → 1.14.3
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.js +16 -1
- package/dist/cjs/focusable.js.map +2 -2
- package/dist/cjs/focusableInputHOC.js +84 -1
- package/dist/cjs/focusableInputHOC.js.map +2 -2
- package/dist/cjs/index.js +20 -1
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/registerFocusable.js +37 -1
- package/dist/cjs/registerFocusable.js.map +2 -2
- package/dist/cjs/registerFocusable.native.js +60 -1
- package/dist/cjs/registerFocusable.native.js.map +2 -2
- package/dist/esm/focusableInputHOC.js +60 -1
- package/dist/esm/focusableInputHOC.js.map +2 -2
- package/dist/esm/focusableInputHOC.mjs +60 -1
- package/dist/esm/focusableInputHOC.mjs.map +2 -2
- package/dist/esm/index.js +3 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +3 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/registerFocusable.js +11 -1
- package/dist/esm/registerFocusable.js.map +2 -2
- package/dist/esm/registerFocusable.mjs +11 -1
- package/dist/esm/registerFocusable.mjs.map +2 -2
- package/dist/esm/registerFocusable.native.js +34 -1
- package/dist/esm/registerFocusable.native.js.map +2 -2
- package/dist/esm/registerFocusable.native.mjs +34 -1
- package/dist/esm/registerFocusable.native.mjs.map +2 -2
- package/dist/jsx/focusableInputHOC.js +56 -1
- package/dist/jsx/focusableInputHOC.js.map +2 -2
- package/dist/jsx/focusableInputHOC.mjs +56 -1
- package/dist/jsx/focusableInputHOC.mjs.map +2 -2
- package/dist/jsx/index.js +3 -1
- package/dist/jsx/index.js.map +1 -1
- package/dist/jsx/index.mjs +3 -1
- package/dist/jsx/index.mjs.map +1 -1
- package/dist/jsx/registerFocusable.js +11 -1
- package/dist/jsx/registerFocusable.js.map +2 -2
- package/dist/jsx/registerFocusable.mjs +11 -1
- package/dist/jsx/registerFocusable.mjs.map +2 -2
- package/dist/jsx/registerFocusable.native.js +34 -1
- package/dist/jsx/registerFocusable.native.js.map +2 -2
- package/dist/jsx/registerFocusable.native.mjs +34 -1
- package/dist/jsx/registerFocusable.native.mjs.map +2 -2
- package/package.json +4 -4
package/dist/cjs/focusable.js
CHANGED
|
@@ -1,2 +1,17 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var focusable_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(focusable_exports);
|
|
2
17
|
//# sourceMappingURL=focusable.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/focusable.ts"],
|
|
4
4
|
"sourcesContent": ["export type Focusable = { focus: Function; focusAndSelect?: Function }\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,85 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var focusableInputHOC_exports = {};
|
|
20
|
+
__export(focusableInputHOC_exports, {
|
|
21
|
+
focusableInputHOC: () => focusableInputHOC
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(focusableInputHOC_exports);
|
|
24
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
+
var import_compose_refs = require("@tamagui/compose-refs");
|
|
26
|
+
var import_web = require("@tamagui/web");
|
|
27
|
+
var import_react = require("react");
|
|
28
|
+
var import_registerFocusable = require("./registerFocusable");
|
|
29
|
+
function focusableInputHOC(Component) {
|
|
30
|
+
const component = Component.extractable(
|
|
31
|
+
(0, import_react.forwardRef)(
|
|
32
|
+
(props, ref) => {
|
|
33
|
+
const isInput = (0, import_web.isTamaguiComponent)(Component) && Component.staticConfig.isInput;
|
|
34
|
+
const inputValue = (0, import_react.useRef)(props.value || props.defaultValue || "");
|
|
35
|
+
const unregisterFocusable = (0, import_react.useRef)();
|
|
36
|
+
const inputRef = (0, import_react.useCallback)(
|
|
37
|
+
(input) => {
|
|
38
|
+
var _a;
|
|
39
|
+
if (!props.id)
|
|
40
|
+
return;
|
|
41
|
+
if (!input)
|
|
42
|
+
return;
|
|
43
|
+
(_a = unregisterFocusable.current) == null ? void 0 : _a.call(unregisterFocusable);
|
|
44
|
+
unregisterFocusable.current = (0, import_registerFocusable.registerFocusable)(props.id, {
|
|
45
|
+
focus: input.focus,
|
|
46
|
+
...isInput && {
|
|
47
|
+
// react-native doesn't support programmatic .select()
|
|
48
|
+
focusAndSelect() {
|
|
49
|
+
input.focus();
|
|
50
|
+
if (input.setSelection && typeof inputValue.current === "string") {
|
|
51
|
+
input.setSelection(0, inputValue.current.length);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
[isInput, props.id]
|
|
58
|
+
);
|
|
59
|
+
const combinedRefs = (0, import_compose_refs.composeRefs)(ref, inputRef);
|
|
60
|
+
(0, import_react.useEffect)(() => {
|
|
61
|
+
return () => {
|
|
62
|
+
var _a;
|
|
63
|
+
(_a = unregisterFocusable.current) == null ? void 0 : _a.call(unregisterFocusable);
|
|
64
|
+
};
|
|
65
|
+
}, []);
|
|
66
|
+
const onChangeText = (0, import_web.useEvent)((value) => {
|
|
67
|
+
var _a;
|
|
68
|
+
inputValue.current = value;
|
|
69
|
+
(_a = props.onChangeText) == null ? void 0 : _a.call(props, value);
|
|
70
|
+
});
|
|
71
|
+
const finalProps = isInput ? {
|
|
72
|
+
...props,
|
|
73
|
+
onChangeText
|
|
74
|
+
} : props;
|
|
75
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { ref: combinedRefs, ...finalProps });
|
|
76
|
+
}
|
|
77
|
+
)
|
|
78
|
+
);
|
|
79
|
+
return component;
|
|
80
|
+
}
|
|
81
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
82
|
+
0 && (module.exports = {
|
|
83
|
+
focusableInputHOC
|
|
84
|
+
});
|
|
2
85
|
//# sourceMappingURL=focusableInputHOC.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/focusableInputHOC.tsx"],
|
|
4
4
|
"sourcesContent": ["import { composeRefs } from '@tamagui/compose-refs'\nimport { TamaguiComponent, isTamaguiComponent, useEvent } from '@tamagui/web'\nimport { forwardRef, useCallback, useEffect, useRef } from 'react'\n\nimport { registerFocusable } from './registerFocusable'\n\nexport function focusableInputHOC<A extends TamaguiComponent>(Component: A): A {\n const component = Component.extractable(\n forwardRef(\n (\n props: {\n id?: string\n onChangeText?: (val: string) => void\n value?: string\n defaultValue?: string\n },\n ref\n ) => {\n const isInput = isTamaguiComponent(Component) && Component.staticConfig.isInput\n const inputValue = useRef(props.value || props.defaultValue || '')\n const unregisterFocusable = useRef<() => void | undefined>()\n\n const inputRef = useCallback(\n (input) => {\n if (!props.id) return\n if (!input) return\n unregisterFocusable.current?.()\n unregisterFocusable.current = registerFocusable(props.id, {\n focus: input.focus,\n\n ...(isInput && {\n // react-native doesn't support programmatic .select()\n focusAndSelect() {\n input.focus()\n if (input.setSelection && typeof inputValue.current === 'string') {\n input.setSelection(0, inputValue.current.length)\n }\n },\n }),\n })\n },\n [isInput, props.id]\n )\n\n const combinedRefs = composeRefs(ref, inputRef)\n\n useEffect(() => {\n return () => {\n unregisterFocusable.current?.()\n }\n }, [])\n\n const onChangeText = useEvent((value) => {\n inputValue.current = value\n props.onChangeText?.(value)\n })\n\n const finalProps = isInput\n ? {\n ...props,\n onChangeText,\n }\n : props\n\n // @ts-expect-error\n return <Component ref={combinedRefs} {...finalProps} />\n }\n )\n ) as any\n\n return component\n}\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiEe;AAjEf,0BAA4B;AAC5B,iBAA+D;AAC/D,mBAA2D;AAE3D,+BAAkC;AAE3B,SAAS,kBAA8C,WAAiB;AAC7E,QAAM,YAAY,UAAU;AAAA,QAC1B;AAAA,MACE,CACE,OAMA,QACG;AACH,cAAM,cAAU,+BAAmB,SAAS,KAAK,UAAU,aAAa;AACxE,cAAM,iBAAa,qBAAO,MAAM,SAAS,MAAM,gBAAgB,EAAE;AACjE,cAAM,0BAAsB,qBAA+B;AAE3D,cAAM,eAAW;AAAA,UACf,CAAC,UAAU;AAvBrB;AAwBY,gBAAI,CAAC,MAAM;AAAI;AACf,gBAAI,CAAC;AAAO;AACZ,sCAAoB,YAApB;AACA,gCAAoB,cAAU,4CAAkB,MAAM,IAAI;AAAA,cACxD,OAAO,MAAM;AAAA,cAEb,GAAI,WAAW;AAAA;AAAA,gBAEb,iBAAiB;AACf,wBAAM,MAAM;AACZ,sBAAI,MAAM,gBAAgB,OAAO,WAAW,YAAY,UAAU;AAChE,0BAAM,aAAa,GAAG,WAAW,QAAQ,MAAM;AAAA,kBACjD;AAAA,gBACF;AAAA,cACF;AAAA,YACF,CAAC;AAAA,UACH;AAAA,UACA,CAAC,SAAS,MAAM,EAAE;AAAA,QACpB;AAEA,cAAM,mBAAe,iCAAY,KAAK,QAAQ;AAE9C,oCAAU,MAAM;AACd,iBAAO,MAAM;AA/CvB;AAgDY,sCAAoB,YAApB;AAAA,UACF;AAAA,QACF,GAAG,CAAC,CAAC;AAEL,cAAM,mBAAe,qBAAS,CAAC,UAAU;AApDjD;AAqDU,qBAAW,UAAU;AACrB,sBAAM,iBAAN,+BAAqB;AAAA,QACvB,CAAC;AAED,cAAM,aAAa,UACf;AAAA,UACE,GAAG;AAAA,UACH;AAAA,QACF,IACA;AAGJ,eAAO,4CAAC,aAAU,KAAK,cAAe,GAAG,YAAY;AAAA,MACvD;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,2 +1,21 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var src_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(src_exports);
|
|
18
|
+
__reExport(src_exports, require("./registerFocusable"), module.exports);
|
|
19
|
+
__reExport(src_exports, require("./focusableInputHOC"), module.exports);
|
|
20
|
+
__reExport(src_exports, require("./focusable"), module.exports);
|
|
2
21
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
4
|
"sourcesContent": ["export * from './registerFocusable'\nexport * from './focusableInputHOC'\nexport * from './focusable'\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,gCAAd;AACA,wBAAc,gCADd;AAEA,wBAAc,wBAFd;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,38 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var registerFocusable_exports = {};
|
|
20
|
+
__export(registerFocusable_exports, {
|
|
21
|
+
focusFocusable: () => focusFocusable,
|
|
22
|
+
registerFocusable: () => registerFocusable,
|
|
23
|
+
unregisterFocusable: () => unregisterFocusable
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(registerFocusable_exports);
|
|
26
|
+
const registerFocusable = (id, input) => () => {
|
|
27
|
+
};
|
|
28
|
+
const unregisterFocusable = (id) => {
|
|
29
|
+
};
|
|
30
|
+
const focusFocusable = (id) => {
|
|
31
|
+
};
|
|
32
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
+
0 && (module.exports = {
|
|
34
|
+
focusFocusable,
|
|
35
|
+
registerFocusable,
|
|
36
|
+
unregisterFocusable
|
|
37
|
+
});
|
|
2
38
|
//# sourceMappingURL=registerFocusable.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/registerFocusable.ts"],
|
|
4
4
|
"sourcesContent": ["import { Focusable } from './focusable'\n\nexport const registerFocusable = (id: string, input: Focusable) => () => {\n // noop focus is handed natively\n}\n\nexport const unregisterFocusable = (id: string) => {\n // noop focus is handed natively\n}\n\nexport const focusFocusable = (id: string) => {\n // noop focus is handed natively\n}\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,MAAM,oBAAoB,CAAC,IAAY,UAAqB,MAAM;AAEzE;AAEO,MAAM,sBAAsB,CAAC,OAAe;AAEnD;AAEO,MAAM,iBAAiB,CAAC,OAAe;AAE9C;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,61 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var registerFocusable_native_exports = {};
|
|
20
|
+
__export(registerFocusable_native_exports, {
|
|
21
|
+
focusFocusable: () => focusFocusable,
|
|
22
|
+
registerFocusable: () => registerFocusable,
|
|
23
|
+
unregisterFocusable: () => unregisterFocusable
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(registerFocusable_native_exports);
|
|
26
|
+
const InputsMap = /* @__PURE__ */ new Map();
|
|
27
|
+
const registerFocusable = (id, input) => {
|
|
28
|
+
if (process.env.NODE_ENV === "development") {
|
|
29
|
+
if (InputsMap.has(id)) {
|
|
30
|
+
console.warn(`Warning, duplicate ID for input: ${id}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
InputsMap.set(id, input);
|
|
34
|
+
return () => {
|
|
35
|
+
InputsMap.delete(id);
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
const unregisterFocusable = (id) => {
|
|
39
|
+
InputsMap.delete(id);
|
|
40
|
+
};
|
|
41
|
+
const focusFocusable = (id, select = false) => {
|
|
42
|
+
const input = InputsMap.get(id);
|
|
43
|
+
if (!input) {
|
|
44
|
+
if (process.env.NODE_ENV === "development") {
|
|
45
|
+
console.warn("No input found for id", id);
|
|
46
|
+
}
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (select || !input.focusAndSelect) {
|
|
50
|
+
input.focus();
|
|
51
|
+
} else {
|
|
52
|
+
input.focusAndSelect();
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
focusFocusable,
|
|
58
|
+
registerFocusable,
|
|
59
|
+
unregisterFocusable
|
|
60
|
+
});
|
|
2
61
|
//# sourceMappingURL=registerFocusable.native.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/registerFocusable.native.ts"],
|
|
4
4
|
"sourcesContent": ["// used for focusing on native\n\nimport { Focusable } from './focusable'\n\nconst InputsMap = new Map<string, Focusable>()\n\nexport const registerFocusable = (id: string, input: Focusable) => {\n if (process.env.NODE_ENV === 'development') {\n if (InputsMap.has(id)) {\n // eslint-disable-next-line no-console\n console.warn(`Warning, duplicate ID for input: ${id}`)\n }\n }\n InputsMap.set(id, input)\n return () => {\n InputsMap.delete(id)\n }\n}\n\nexport const unregisterFocusable = (id: string) => {\n InputsMap.delete(id)\n}\n\nexport const focusFocusable = (id: string, select = false) => {\n const input = InputsMap.get(id)\n if (!input) {\n if (process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\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"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,MAAM,YAAY,oBAAI,IAAuB;AAEtC,MAAM,oBAAoB,CAAC,IAAY,UAAqB;AACjE,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,UAAU,IAAI,EAAE,GAAG;AAErB,cAAQ,KAAK,oCAAoC,IAAI;AAAA,IACvD;AAAA,EACF;AACA,YAAU,IAAI,IAAI,KAAK;AACvB,SAAO,MAAM;AACX,cAAU,OAAO,EAAE;AAAA,EACrB;AACF;AAEO,MAAM,sBAAsB,CAAC,OAAe;AACjD,YAAU,OAAO,EAAE;AACrB;AAEO,MAAM,iBAAiB,CAAC,IAAY,SAAS,UAAU;AAC5D,QAAM,QAAQ,UAAU,IAAI,EAAE;AAC9B,MAAI,CAAC,OAAO;AACV,QAAI,QAAQ,IAAI,aAAa,eAAe;AAE1C,cAAQ,KAAK,yBAAyB,EAAE;AAAA,IAC1C;AACA;AAAA,EACF;AACA,MAAI,UAAU,CAAC,MAAM,gBAAgB;AACnC,UAAM,MAAM;AAAA,EACd,OAAO;AACL,UAAM,eAAe;AAAA,EACvB;AACF;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,61 @@
|
|
|
1
|
-
import{jsx
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { composeRefs } from "@tamagui/compose-refs";
|
|
3
|
+
import { isTamaguiComponent, useEvent } from "@tamagui/web";
|
|
4
|
+
import { forwardRef, useCallback, useEffect, useRef } from "react";
|
|
5
|
+
import { registerFocusable } from "./registerFocusable";
|
|
6
|
+
function focusableInputHOC(Component) {
|
|
7
|
+
const component = Component.extractable(
|
|
8
|
+
forwardRef(
|
|
9
|
+
(props, ref) => {
|
|
10
|
+
const isInput = isTamaguiComponent(Component) && Component.staticConfig.isInput;
|
|
11
|
+
const inputValue = useRef(props.value || props.defaultValue || "");
|
|
12
|
+
const unregisterFocusable = useRef();
|
|
13
|
+
const inputRef = useCallback(
|
|
14
|
+
(input) => {
|
|
15
|
+
var _a;
|
|
16
|
+
if (!props.id)
|
|
17
|
+
return;
|
|
18
|
+
if (!input)
|
|
19
|
+
return;
|
|
20
|
+
(_a = unregisterFocusable.current) == null ? void 0 : _a.call(unregisterFocusable);
|
|
21
|
+
unregisterFocusable.current = registerFocusable(props.id, {
|
|
22
|
+
focus: input.focus,
|
|
23
|
+
...isInput && {
|
|
24
|
+
// react-native doesn't support programmatic .select()
|
|
25
|
+
focusAndSelect() {
|
|
26
|
+
input.focus();
|
|
27
|
+
if (input.setSelection && typeof inputValue.current === "string") {
|
|
28
|
+
input.setSelection(0, inputValue.current.length);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
[isInput, props.id]
|
|
35
|
+
);
|
|
36
|
+
const combinedRefs = composeRefs(ref, inputRef);
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
return () => {
|
|
39
|
+
var _a;
|
|
40
|
+
(_a = unregisterFocusable.current) == null ? void 0 : _a.call(unregisterFocusable);
|
|
41
|
+
};
|
|
42
|
+
}, []);
|
|
43
|
+
const onChangeText = useEvent((value) => {
|
|
44
|
+
var _a;
|
|
45
|
+
inputValue.current = value;
|
|
46
|
+
(_a = props.onChangeText) == null ? void 0 : _a.call(props, value);
|
|
47
|
+
});
|
|
48
|
+
const finalProps = isInput ? {
|
|
49
|
+
...props,
|
|
50
|
+
onChangeText
|
|
51
|
+
} : props;
|
|
52
|
+
return /* @__PURE__ */ jsx(Component, { ref: combinedRefs, ...finalProps });
|
|
53
|
+
}
|
|
54
|
+
)
|
|
55
|
+
);
|
|
56
|
+
return component;
|
|
57
|
+
}
|
|
58
|
+
export {
|
|
59
|
+
focusableInputHOC
|
|
60
|
+
};
|
|
2
61
|
//# sourceMappingURL=focusableInputHOC.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/focusableInputHOC.tsx"],
|
|
4
4
|
"sourcesContent": ["import { composeRefs } from '@tamagui/compose-refs'\nimport { TamaguiComponent, isTamaguiComponent, useEvent } from '@tamagui/web'\nimport { forwardRef, useCallback, useEffect, useRef } from 'react'\n\nimport { registerFocusable } from './registerFocusable'\n\nexport function focusableInputHOC<A extends TamaguiComponent>(Component: A): A {\n const component = Component.extractable(\n forwardRef(\n (\n props: {\n id?: string\n onChangeText?: (val: string) => void\n value?: string\n defaultValue?: string\n },\n ref\n ) => {\n const isInput = isTamaguiComponent(Component) && Component.staticConfig.isInput\n const inputValue = useRef(props.value || props.defaultValue || '')\n const unregisterFocusable = useRef<() => void | undefined>()\n\n const inputRef = useCallback(\n (input) => {\n if (!props.id) return\n if (!input) return\n unregisterFocusable.current?.()\n unregisterFocusable.current = registerFocusable(props.id, {\n focus: input.focus,\n\n ...(isInput && {\n // react-native doesn't support programmatic .select()\n focusAndSelect() {\n input.focus()\n if (input.setSelection && typeof inputValue.current === 'string') {\n input.setSelection(0, inputValue.current.length)\n }\n },\n }),\n })\n },\n [isInput, props.id]\n )\n\n const combinedRefs = composeRefs(ref, inputRef)\n\n useEffect(() => {\n return () => {\n unregisterFocusable.current?.()\n }\n }, [])\n\n const onChangeText = useEvent((value) => {\n inputValue.current = value\n props.onChangeText?.(value)\n })\n\n const finalProps = isInput\n ? {\n ...props,\n onChangeText,\n }\n : props\n\n // @ts-expect-error\n return <Component ref={combinedRefs} {...finalProps} />\n }\n )\n ) as any\n\n return component\n}\n"],
|
|
5
|
-
"mappings": "AAiEe,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAiEe;AAjEf,SAAS,mBAAmB;AAC5B,SAA2B,oBAAoB,gBAAgB;AAC/D,SAAS,YAAY,aAAa,WAAW,cAAc;AAE3D,SAAS,yBAAyB;AAE3B,SAAS,kBAA8C,WAAiB;AAC7E,QAAM,YAAY,UAAU;AAAA,IAC1B;AAAA,MACE,CACE,OAMA,QACG;AACH,cAAM,UAAU,mBAAmB,SAAS,KAAK,UAAU,aAAa;AACxE,cAAM,aAAa,OAAO,MAAM,SAAS,MAAM,gBAAgB,EAAE;AACjE,cAAM,sBAAsB,OAA+B;AAE3D,cAAM,WAAW;AAAA,UACf,CAAC,UAAU;AAvBrB;AAwBY,gBAAI,CAAC,MAAM;AAAI;AACf,gBAAI,CAAC;AAAO;AACZ,sCAAoB,YAApB;AACA,gCAAoB,UAAU,kBAAkB,MAAM,IAAI;AAAA,cACxD,OAAO,MAAM;AAAA,cAEb,GAAI,WAAW;AAAA;AAAA,gBAEb,iBAAiB;AACf,wBAAM,MAAM;AACZ,sBAAI,MAAM,gBAAgB,OAAO,WAAW,YAAY,UAAU;AAChE,0BAAM,aAAa,GAAG,WAAW,QAAQ,MAAM;AAAA,kBACjD;AAAA,gBACF;AAAA,cACF;AAAA,YACF,CAAC;AAAA,UACH;AAAA,UACA,CAAC,SAAS,MAAM,EAAE;AAAA,QACpB;AAEA,cAAM,eAAe,YAAY,KAAK,QAAQ;AAE9C,kBAAU,MAAM;AACd,iBAAO,MAAM;AA/CvB;AAgDY,sCAAoB,YAApB;AAAA,UACF;AAAA,QACF,GAAG,CAAC,CAAC;AAEL,cAAM,eAAe,SAAS,CAAC,UAAU;AApDjD;AAqDU,qBAAW,UAAU;AACrB,sBAAM,iBAAN,+BAAqB;AAAA,QACvB,CAAC;AAED,cAAM,aAAa,UACf;AAAA,UACE,GAAG;AAAA,UACH;AAAA,QACF,IACA;AAGJ,eAAO,oBAAC,aAAU,KAAK,cAAe,GAAG,YAAY;AAAA,MACvD;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,61 @@
|
|
|
1
|
-
import{jsx
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { composeRefs } from "@tamagui/compose-refs";
|
|
3
|
+
import { isTamaguiComponent, useEvent } from "@tamagui/web";
|
|
4
|
+
import { forwardRef, useCallback, useEffect, useRef } from "react";
|
|
5
|
+
import { registerFocusable } from "./registerFocusable";
|
|
6
|
+
function focusableInputHOC(Component) {
|
|
7
|
+
const component = Component.extractable(
|
|
8
|
+
forwardRef(
|
|
9
|
+
(props, ref) => {
|
|
10
|
+
const isInput = isTamaguiComponent(Component) && Component.staticConfig.isInput;
|
|
11
|
+
const inputValue = useRef(props.value || props.defaultValue || "");
|
|
12
|
+
const unregisterFocusable = useRef();
|
|
13
|
+
const inputRef = useCallback(
|
|
14
|
+
(input) => {
|
|
15
|
+
var _a;
|
|
16
|
+
if (!props.id)
|
|
17
|
+
return;
|
|
18
|
+
if (!input)
|
|
19
|
+
return;
|
|
20
|
+
(_a = unregisterFocusable.current) == null ? void 0 : _a.call(unregisterFocusable);
|
|
21
|
+
unregisterFocusable.current = registerFocusable(props.id, {
|
|
22
|
+
focus: input.focus,
|
|
23
|
+
...isInput && {
|
|
24
|
+
// react-native doesn't support programmatic .select()
|
|
25
|
+
focusAndSelect() {
|
|
26
|
+
input.focus();
|
|
27
|
+
if (input.setSelection && typeof inputValue.current === "string") {
|
|
28
|
+
input.setSelection(0, inputValue.current.length);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
[isInput, props.id]
|
|
35
|
+
);
|
|
36
|
+
const combinedRefs = composeRefs(ref, inputRef);
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
return () => {
|
|
39
|
+
var _a;
|
|
40
|
+
(_a = unregisterFocusable.current) == null ? void 0 : _a.call(unregisterFocusable);
|
|
41
|
+
};
|
|
42
|
+
}, []);
|
|
43
|
+
const onChangeText = useEvent((value) => {
|
|
44
|
+
var _a;
|
|
45
|
+
inputValue.current = value;
|
|
46
|
+
(_a = props.onChangeText) == null ? void 0 : _a.call(props, value);
|
|
47
|
+
});
|
|
48
|
+
const finalProps = isInput ? {
|
|
49
|
+
...props,
|
|
50
|
+
onChangeText
|
|
51
|
+
} : props;
|
|
52
|
+
return /* @__PURE__ */ jsx(Component, { ref: combinedRefs, ...finalProps });
|
|
53
|
+
}
|
|
54
|
+
)
|
|
55
|
+
);
|
|
56
|
+
return component;
|
|
57
|
+
}
|
|
58
|
+
export {
|
|
59
|
+
focusableInputHOC
|
|
60
|
+
};
|
|
2
61
|
//# sourceMappingURL=focusableInputHOC.mjs.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/focusableInputHOC.tsx"],
|
|
4
4
|
"sourcesContent": ["import { composeRefs } from '@tamagui/compose-refs'\nimport { TamaguiComponent, isTamaguiComponent, useEvent } from '@tamagui/web'\nimport { forwardRef, useCallback, useEffect, useRef } from 'react'\n\nimport { registerFocusable } from './registerFocusable'\n\nexport function focusableInputHOC<A extends TamaguiComponent>(Component: A): A {\n const component = Component.extractable(\n forwardRef(\n (\n props: {\n id?: string\n onChangeText?: (val: string) => void\n value?: string\n defaultValue?: string\n },\n ref\n ) => {\n const isInput = isTamaguiComponent(Component) && Component.staticConfig.isInput\n const inputValue = useRef(props.value || props.defaultValue || '')\n const unregisterFocusable = useRef<() => void | undefined>()\n\n const inputRef = useCallback(\n (input) => {\n if (!props.id) return\n if (!input) return\n unregisterFocusable.current?.()\n unregisterFocusable.current = registerFocusable(props.id, {\n focus: input.focus,\n\n ...(isInput && {\n // react-native doesn't support programmatic .select()\n focusAndSelect() {\n input.focus()\n if (input.setSelection && typeof inputValue.current === 'string') {\n input.setSelection(0, inputValue.current.length)\n }\n },\n }),\n })\n },\n [isInput, props.id]\n )\n\n const combinedRefs = composeRefs(ref, inputRef)\n\n useEffect(() => {\n return () => {\n unregisterFocusable.current?.()\n }\n }, [])\n\n const onChangeText = useEvent((value) => {\n inputValue.current = value\n props.onChangeText?.(value)\n })\n\n const finalProps = isInput\n ? {\n ...props,\n onChangeText,\n }\n : props\n\n // @ts-expect-error\n return <Component ref={combinedRefs} {...finalProps} />\n }\n )\n ) as any\n\n return component\n}\n"],
|
|
5
|
-
"mappings": "AAiEe,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAiEe;AAjEf,SAAS,mBAAmB;AAC5B,SAA2B,oBAAoB,gBAAgB;AAC/D,SAAS,YAAY,aAAa,WAAW,cAAc;AAE3D,SAAS,yBAAyB;AAE3B,SAAS,kBAA8C,WAAiB;AAC7E,QAAM,YAAY,UAAU;AAAA,IAC1B;AAAA,MACE,CACE,OAMA,QACG;AACH,cAAM,UAAU,mBAAmB,SAAS,KAAK,UAAU,aAAa;AACxE,cAAM,aAAa,OAAO,MAAM,SAAS,MAAM,gBAAgB,EAAE;AACjE,cAAM,sBAAsB,OAA+B;AAE3D,cAAM,WAAW;AAAA,UACf,CAAC,UAAU;AAvBrB;AAwBY,gBAAI,CAAC,MAAM;AAAI;AACf,gBAAI,CAAC;AAAO;AACZ,sCAAoB,YAApB;AACA,gCAAoB,UAAU,kBAAkB,MAAM,IAAI;AAAA,cACxD,OAAO,MAAM;AAAA,cAEb,GAAI,WAAW;AAAA;AAAA,gBAEb,iBAAiB;AACf,wBAAM,MAAM;AACZ,sBAAI,MAAM,gBAAgB,OAAO,WAAW,YAAY,UAAU;AAChE,0BAAM,aAAa,GAAG,WAAW,QAAQ,MAAM;AAAA,kBACjD;AAAA,gBACF;AAAA,cACF;AAAA,YACF,CAAC;AAAA,UACH;AAAA,UACA,CAAC,SAAS,MAAM,EAAE;AAAA,QACpB;AAEA,cAAM,eAAe,YAAY,KAAK,QAAQ;AAE9C,kBAAU,MAAM;AACd,iBAAO,MAAM;AA/CvB;AAgDY,sCAAoB,YAApB;AAAA,UACF;AAAA,QACF,GAAG,CAAC,CAAC;AAEL,cAAM,eAAe,SAAS,CAAC,UAAU;AApDjD;AAqDU,qBAAW,UAAU;AACrB,sBAAM,iBAAN,+BAAqB;AAAA,QACvB,CAAC;AAED,cAAM,aAAa,UACf;AAAA,UACE,GAAG;AAAA,UACH;AAAA,QACF,IACA;AAGJ,eAAO,oBAAC,aAAU,KAAK,cAAe,GAAG,YAAY;AAAA,MACvD;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/dist/esm/index.js
CHANGED
package/dist/esm/index.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
4
|
"sourcesContent": ["export * from './registerFocusable'\nexport * from './focusableInputHOC'\nexport * from './focusable'\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
5
|
+
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/index.mjs
CHANGED
package/dist/esm/index.mjs.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
4
|
"sourcesContent": ["export * from './registerFocusable'\nexport * from './focusableInputHOC'\nexport * from './focusable'\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
5
|
+
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
const
|
|
1
|
+
const registerFocusable = (id, input) => () => {
|
|
2
|
+
};
|
|
3
|
+
const unregisterFocusable = (id) => {
|
|
4
|
+
};
|
|
5
|
+
const focusFocusable = (id) => {
|
|
6
|
+
};
|
|
7
|
+
export {
|
|
8
|
+
focusFocusable,
|
|
9
|
+
registerFocusable,
|
|
10
|
+
unregisterFocusable
|
|
11
|
+
};
|
|
2
12
|
//# sourceMappingURL=registerFocusable.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/registerFocusable.ts"],
|
|
4
4
|
"sourcesContent": ["import { Focusable } from './focusable'\n\nexport const registerFocusable = (id: string, input: Focusable) => () => {\n // noop focus is handed natively\n}\n\nexport const unregisterFocusable = (id: string) => {\n // noop focus is handed natively\n}\n\nexport const focusFocusable = (id: string) => {\n // noop focus is handed natively\n}\n"],
|
|
5
|
-
"mappings": "AAEO,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAEO,MAAM,oBAAoB,CAAC,IAAY,UAAqB,MAAM;AAEzE;AAEO,MAAM,sBAAsB,CAAC,OAAe;AAEnD;AAEO,MAAM,iBAAiB,CAAC,OAAe;AAE9C;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
const
|
|
1
|
+
const registerFocusable = (id, input) => () => {
|
|
2
|
+
};
|
|
3
|
+
const unregisterFocusable = (id) => {
|
|
4
|
+
};
|
|
5
|
+
const focusFocusable = (id) => {
|
|
6
|
+
};
|
|
7
|
+
export {
|
|
8
|
+
focusFocusable,
|
|
9
|
+
registerFocusable,
|
|
10
|
+
unregisterFocusable
|
|
11
|
+
};
|
|
2
12
|
//# sourceMappingURL=registerFocusable.mjs.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/registerFocusable.ts"],
|
|
4
4
|
"sourcesContent": ["import { Focusable } from './focusable'\n\nexport const registerFocusable = (id: string, input: Focusable) => () => {\n // noop focus is handed natively\n}\n\nexport const unregisterFocusable = (id: string) => {\n // noop focus is handed natively\n}\n\nexport const focusFocusable = (id: string) => {\n // noop focus is handed natively\n}\n"],
|
|
5
|
-
"mappings": "AAEO,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAEO,MAAM,oBAAoB,CAAC,IAAY,UAAqB,MAAM;AAEzE;AAEO,MAAM,sBAAsB,CAAC,OAAe;AAEnD;AAEO,MAAM,iBAAiB,CAAC,OAAe;AAE9C;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,35 @@
|
|
|
1
|
-
const
|
|
1
|
+
const InputsMap = /* @__PURE__ */ new Map();
|
|
2
|
+
const registerFocusable = (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 () => {
|
|
10
|
+
InputsMap.delete(id);
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
const unregisterFocusable = (id) => {
|
|
14
|
+
InputsMap.delete(id);
|
|
15
|
+
};
|
|
16
|
+
const focusFocusable = (id, select = false) => {
|
|
17
|
+
const input = InputsMap.get(id);
|
|
18
|
+
if (!input) {
|
|
19
|
+
if (process.env.NODE_ENV === "development") {
|
|
20
|
+
console.warn("No input found for id", id);
|
|
21
|
+
}
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (select || !input.focusAndSelect) {
|
|
25
|
+
input.focus();
|
|
26
|
+
} else {
|
|
27
|
+
input.focusAndSelect();
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
focusFocusable,
|
|
32
|
+
registerFocusable,
|
|
33
|
+
unregisterFocusable
|
|
34
|
+
};
|
|
2
35
|
//# sourceMappingURL=registerFocusable.native.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/registerFocusable.native.ts"],
|
|
4
4
|
"sourcesContent": ["// used for focusing on native\n\nimport { Focusable } from './focusable'\n\nconst InputsMap = new Map<string, Focusable>()\n\nexport const registerFocusable = (id: string, input: Focusable) => {\n if (process.env.NODE_ENV === 'development') {\n if (InputsMap.has(id)) {\n // eslint-disable-next-line no-console\n console.warn(`Warning, duplicate ID for input: ${id}`)\n }\n }\n InputsMap.set(id, input)\n return () => {\n InputsMap.delete(id)\n }\n}\n\nexport const unregisterFocusable = (id: string) => {\n InputsMap.delete(id)\n}\n\nexport const focusFocusable = (id: string, select = false) => {\n const input = InputsMap.get(id)\n if (!input) {\n if (process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\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"],
|
|
5
|
-
"mappings": "AAIA,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAIA,MAAM,YAAY,oBAAI,IAAuB;AAEtC,MAAM,oBAAoB,CAAC,IAAY,UAAqB;AACjE,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,UAAU,IAAI,EAAE,GAAG;AAErB,cAAQ,KAAK,oCAAoC,IAAI;AAAA,IACvD;AAAA,EACF;AACA,YAAU,IAAI,IAAI,KAAK;AACvB,SAAO,MAAM;AACX,cAAU,OAAO,EAAE;AAAA,EACrB;AACF;AAEO,MAAM,sBAAsB,CAAC,OAAe;AACjD,YAAU,OAAO,EAAE;AACrB;AAEO,MAAM,iBAAiB,CAAC,IAAY,SAAS,UAAU;AAC5D,QAAM,QAAQ,UAAU,IAAI,EAAE;AAC9B,MAAI,CAAC,OAAO;AACV,QAAI,QAAQ,IAAI,aAAa,eAAe;AAE1C,cAAQ,KAAK,yBAAyB,EAAE;AAAA,IAC1C;AACA;AAAA,EACF;AACA,MAAI,UAAU,CAAC,MAAM,gBAAgB;AACnC,UAAM,MAAM;AAAA,EACd,OAAO;AACL,UAAM,eAAe;AAAA,EACvB;AACF;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,35 @@
|
|
|
1
|
-
const
|
|
1
|
+
const InputsMap = /* @__PURE__ */ new Map();
|
|
2
|
+
const registerFocusable = (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 () => {
|
|
10
|
+
InputsMap.delete(id);
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
const unregisterFocusable = (id) => {
|
|
14
|
+
InputsMap.delete(id);
|
|
15
|
+
};
|
|
16
|
+
const focusFocusable = (id, select = false) => {
|
|
17
|
+
const input = InputsMap.get(id);
|
|
18
|
+
if (!input) {
|
|
19
|
+
if (process.env.NODE_ENV === "development") {
|
|
20
|
+
console.warn("No input found for id", id);
|
|
21
|
+
}
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (select || !input.focusAndSelect) {
|
|
25
|
+
input.focus();
|
|
26
|
+
} else {
|
|
27
|
+
input.focusAndSelect();
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
focusFocusable,
|
|
32
|
+
registerFocusable,
|
|
33
|
+
unregisterFocusable
|
|
34
|
+
};
|
|
2
35
|
//# sourceMappingURL=registerFocusable.native.mjs.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/registerFocusable.native.ts"],
|
|
4
4
|
"sourcesContent": ["// used for focusing on native\n\nimport { Focusable } from './focusable'\n\nconst InputsMap = new Map<string, Focusable>()\n\nexport const registerFocusable = (id: string, input: Focusable) => {\n if (process.env.NODE_ENV === 'development') {\n if (InputsMap.has(id)) {\n // eslint-disable-next-line no-console\n console.warn(`Warning, duplicate ID for input: ${id}`)\n }\n }\n InputsMap.set(id, input)\n return () => {\n InputsMap.delete(id)\n }\n}\n\nexport const unregisterFocusable = (id: string) => {\n InputsMap.delete(id)\n}\n\nexport const focusFocusable = (id: string, select = false) => {\n const input = InputsMap.get(id)\n if (!input) {\n if (process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\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"],
|
|
5
|
-
"mappings": "AAIA,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAIA,MAAM,YAAY,oBAAI,IAAuB;AAEtC,MAAM,oBAAoB,CAAC,IAAY,UAAqB;AACjE,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,UAAU,IAAI,EAAE,GAAG;AAErB,cAAQ,KAAK,oCAAoC,IAAI;AAAA,IACvD;AAAA,EACF;AACA,YAAU,IAAI,IAAI,KAAK;AACvB,SAAO,MAAM;AACX,cAAU,OAAO,EAAE;AAAA,EACrB;AACF;AAEO,MAAM,sBAAsB,CAAC,OAAe;AACjD,YAAU,OAAO,EAAE;AACrB;AAEO,MAAM,iBAAiB,CAAC,IAAY,SAAS,UAAU;AAC5D,QAAM,QAAQ,UAAU,IAAI,EAAE;AAC9B,MAAI,CAAC,OAAO;AACV,QAAI,QAAQ,IAAI,aAAa,eAAe;AAE1C,cAAQ,KAAK,yBAAyB,EAAE;AAAA,IAC1C;AACA;AAAA,EACF;AACA,MAAI,UAAU,CAAC,MAAM,gBAAgB;AACnC,UAAM,MAAM;AAAA,EACd,OAAO;AACL,UAAM,eAAe;AAAA,EACvB;AACF;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,57 @@
|
|
|
1
|
-
import{composeRefs
|
|
1
|
+
import { composeRefs } from "@tamagui/compose-refs";
|
|
2
|
+
import { isTamaguiComponent, useEvent } from "@tamagui/web";
|
|
3
|
+
import { forwardRef, useCallback, useEffect, useRef } from "react";
|
|
4
|
+
import { registerFocusable } from "./registerFocusable";
|
|
5
|
+
function focusableInputHOC(Component) {
|
|
6
|
+
const component = Component.extractable(
|
|
7
|
+
forwardRef(
|
|
8
|
+
(props, ref) => {
|
|
9
|
+
const isInput = isTamaguiComponent(Component) && Component.staticConfig.isInput;
|
|
10
|
+
const inputValue = useRef(props.value || props.defaultValue || "");
|
|
11
|
+
const unregisterFocusable = useRef();
|
|
12
|
+
const inputRef = useCallback(
|
|
13
|
+
(input) => {
|
|
14
|
+
if (!props.id)
|
|
15
|
+
return;
|
|
16
|
+
if (!input)
|
|
17
|
+
return;
|
|
18
|
+
unregisterFocusable.current?.();
|
|
19
|
+
unregisterFocusable.current = registerFocusable(props.id, {
|
|
20
|
+
focus: input.focus,
|
|
21
|
+
...isInput && {
|
|
22
|
+
// react-native doesn't support programmatic .select()
|
|
23
|
+
focusAndSelect() {
|
|
24
|
+
input.focus();
|
|
25
|
+
if (input.setSelection && typeof inputValue.current === "string") {
|
|
26
|
+
input.setSelection(0, inputValue.current.length);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
[isInput, props.id]
|
|
33
|
+
);
|
|
34
|
+
const combinedRefs = composeRefs(ref, inputRef);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
return () => {
|
|
37
|
+
unregisterFocusable.current?.();
|
|
38
|
+
};
|
|
39
|
+
}, []);
|
|
40
|
+
const onChangeText = useEvent((value) => {
|
|
41
|
+
inputValue.current = value;
|
|
42
|
+
props.onChangeText?.(value);
|
|
43
|
+
});
|
|
44
|
+
const finalProps = isInput ? {
|
|
45
|
+
...props,
|
|
46
|
+
onChangeText
|
|
47
|
+
} : props;
|
|
48
|
+
return <Component ref={combinedRefs} {...finalProps} />;
|
|
49
|
+
}
|
|
50
|
+
)
|
|
51
|
+
);
|
|
52
|
+
return component;
|
|
53
|
+
}
|
|
54
|
+
export {
|
|
55
|
+
focusableInputHOC
|
|
56
|
+
};
|
|
2
57
|
//# sourceMappingURL=focusableInputHOC.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/focusableInputHOC.tsx"],
|
|
4
4
|
"sourcesContent": ["import { composeRefs } from '@tamagui/compose-refs'\nimport { TamaguiComponent, isTamaguiComponent, useEvent } from '@tamagui/web'\nimport { forwardRef, useCallback, useEffect, useRef } from 'react'\n\nimport { registerFocusable } from './registerFocusable'\n\nexport function focusableInputHOC<A extends TamaguiComponent>(Component: A): A {\n const component = Component.extractable(\n forwardRef(\n (\n props: {\n id?: string\n onChangeText?: (val: string) => void\n value?: string\n defaultValue?: string\n },\n ref\n ) => {\n const isInput = isTamaguiComponent(Component) && Component.staticConfig.isInput\n const inputValue = useRef(props.value || props.defaultValue || '')\n const unregisterFocusable = useRef<() => void | undefined>()\n\n const inputRef = useCallback(\n (input) => {\n if (!props.id) return\n if (!input) return\n unregisterFocusable.current?.()\n unregisterFocusable.current = registerFocusable(props.id, {\n focus: input.focus,\n\n ...(isInput && {\n // react-native doesn't support programmatic .select()\n focusAndSelect() {\n input.focus()\n if (input.setSelection && typeof inputValue.current === 'string') {\n input.setSelection(0, inputValue.current.length)\n }\n },\n }),\n })\n },\n [isInput, props.id]\n )\n\n const combinedRefs = composeRefs(ref, inputRef)\n\n useEffect(() => {\n return () => {\n unregisterFocusable.current?.()\n }\n }, [])\n\n const onChangeText = useEvent((value) => {\n inputValue.current = value\n props.onChangeText?.(value)\n })\n\n const finalProps = isInput\n ? {\n ...props,\n onChangeText,\n }\n : props\n\n // @ts-expect-error\n return <Component ref={combinedRefs} {...finalProps} />\n }\n )\n ) as any\n\n return component\n}\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,SAAS,mBAAmB;AAC5B,SAA2B,oBAAoB,gBAAgB;AAC/D,SAAS,YAAY,aAAa,WAAW,cAAc;AAE3D,SAAS,yBAAyB;AAE3B,SAAS,kBAA8C,WAAiB;AAC7E,QAAM,YAAY,UAAU;AAAA,IAC1B;AAAA,MACE,CACE,OAMA,QACG;AACH,cAAM,UAAU,mBAAmB,SAAS,KAAK,UAAU,aAAa;AACxE,cAAM,aAAa,OAAO,MAAM,SAAS,MAAM,gBAAgB,EAAE;AACjE,cAAM,sBAAsB,OAA+B;AAE3D,cAAM,WAAW;AAAA,UACf,CAAC,UAAU;AACT,gBAAI,CAAC,MAAM;AAAI;AACf,gBAAI,CAAC;AAAO;AACZ,gCAAoB,UAAU;AAC9B,gCAAoB,UAAU,kBAAkB,MAAM,IAAI;AAAA,cACxD,OAAO,MAAM;AAAA,cAEb,GAAI,WAAW;AAAA;AAAA,gBAEb,iBAAiB;AACf,wBAAM,MAAM;AACZ,sBAAI,MAAM,gBAAgB,OAAO,WAAW,YAAY,UAAU;AAChE,0BAAM,aAAa,GAAG,WAAW,QAAQ,MAAM;AAAA,kBACjD;AAAA,gBACF;AAAA,cACF;AAAA,YACF,CAAC;AAAA,UACH;AAAA,UACA,CAAC,SAAS,MAAM,EAAE;AAAA,QACpB;AAEA,cAAM,eAAe,YAAY,KAAK,QAAQ;AAE9C,kBAAU,MAAM;AACd,iBAAO,MAAM;AACX,gCAAoB,UAAU;AAAA,UAChC;AAAA,QACF,GAAG,CAAC,CAAC;AAEL,cAAM,eAAe,SAAS,CAAC,UAAU;AACvC,qBAAW,UAAU;AACrB,gBAAM,eAAe,KAAK;AAAA,QAC5B,CAAC;AAED,cAAM,aAAa,UACf;AAAA,UACE,GAAG;AAAA,UACH;AAAA,QACF,IACA;AAGJ,eAAO,CAAC,UAAU,KAAK,kBAAkB,YAAY;AAAA,MACvD;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,57 @@
|
|
|
1
|
-
import{composeRefs
|
|
1
|
+
import { composeRefs } from "@tamagui/compose-refs";
|
|
2
|
+
import { isTamaguiComponent, useEvent } from "@tamagui/web";
|
|
3
|
+
import { forwardRef, useCallback, useEffect, useRef } from "react";
|
|
4
|
+
import { registerFocusable } from "./registerFocusable";
|
|
5
|
+
function focusableInputHOC(Component) {
|
|
6
|
+
const component = Component.extractable(
|
|
7
|
+
forwardRef(
|
|
8
|
+
(props, ref) => {
|
|
9
|
+
const isInput = isTamaguiComponent(Component) && Component.staticConfig.isInput;
|
|
10
|
+
const inputValue = useRef(props.value || props.defaultValue || "");
|
|
11
|
+
const unregisterFocusable = useRef();
|
|
12
|
+
const inputRef = useCallback(
|
|
13
|
+
(input) => {
|
|
14
|
+
if (!props.id)
|
|
15
|
+
return;
|
|
16
|
+
if (!input)
|
|
17
|
+
return;
|
|
18
|
+
unregisterFocusable.current?.();
|
|
19
|
+
unregisterFocusable.current = registerFocusable(props.id, {
|
|
20
|
+
focus: input.focus,
|
|
21
|
+
...isInput && {
|
|
22
|
+
// react-native doesn't support programmatic .select()
|
|
23
|
+
focusAndSelect() {
|
|
24
|
+
input.focus();
|
|
25
|
+
if (input.setSelection && typeof inputValue.current === "string") {
|
|
26
|
+
input.setSelection(0, inputValue.current.length);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
[isInput, props.id]
|
|
33
|
+
);
|
|
34
|
+
const combinedRefs = composeRefs(ref, inputRef);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
return () => {
|
|
37
|
+
unregisterFocusable.current?.();
|
|
38
|
+
};
|
|
39
|
+
}, []);
|
|
40
|
+
const onChangeText = useEvent((value) => {
|
|
41
|
+
inputValue.current = value;
|
|
42
|
+
props.onChangeText?.(value);
|
|
43
|
+
});
|
|
44
|
+
const finalProps = isInput ? {
|
|
45
|
+
...props,
|
|
46
|
+
onChangeText
|
|
47
|
+
} : props;
|
|
48
|
+
return <Component ref={combinedRefs} {...finalProps} />;
|
|
49
|
+
}
|
|
50
|
+
)
|
|
51
|
+
);
|
|
52
|
+
return component;
|
|
53
|
+
}
|
|
54
|
+
export {
|
|
55
|
+
focusableInputHOC
|
|
56
|
+
};
|
|
2
57
|
//# sourceMappingURL=focusableInputHOC.mjs.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/focusableInputHOC.tsx"],
|
|
4
4
|
"sourcesContent": ["import { composeRefs } from '@tamagui/compose-refs'\nimport { TamaguiComponent, isTamaguiComponent, useEvent } from '@tamagui/web'\nimport { forwardRef, useCallback, useEffect, useRef } from 'react'\n\nimport { registerFocusable } from './registerFocusable'\n\nexport function focusableInputHOC<A extends TamaguiComponent>(Component: A): A {\n const component = Component.extractable(\n forwardRef(\n (\n props: {\n id?: string\n onChangeText?: (val: string) => void\n value?: string\n defaultValue?: string\n },\n ref\n ) => {\n const isInput = isTamaguiComponent(Component) && Component.staticConfig.isInput\n const inputValue = useRef(props.value || props.defaultValue || '')\n const unregisterFocusable = useRef<() => void | undefined>()\n\n const inputRef = useCallback(\n (input) => {\n if (!props.id) return\n if (!input) return\n unregisterFocusable.current?.()\n unregisterFocusable.current = registerFocusable(props.id, {\n focus: input.focus,\n\n ...(isInput && {\n // react-native doesn't support programmatic .select()\n focusAndSelect() {\n input.focus()\n if (input.setSelection && typeof inputValue.current === 'string') {\n input.setSelection(0, inputValue.current.length)\n }\n },\n }),\n })\n },\n [isInput, props.id]\n )\n\n const combinedRefs = composeRefs(ref, inputRef)\n\n useEffect(() => {\n return () => {\n unregisterFocusable.current?.()\n }\n }, [])\n\n const onChangeText = useEvent((value) => {\n inputValue.current = value\n props.onChangeText?.(value)\n })\n\n const finalProps = isInput\n ? {\n ...props,\n onChangeText,\n }\n : props\n\n // @ts-expect-error\n return <Component ref={combinedRefs} {...finalProps} />\n }\n )\n ) as any\n\n return component\n}\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,SAAS,mBAAmB;AAC5B,SAA2B,oBAAoB,gBAAgB;AAC/D,SAAS,YAAY,aAAa,WAAW,cAAc;AAE3D,SAAS,yBAAyB;AAE3B,SAAS,kBAA8C,WAAiB;AAC7E,QAAM,YAAY,UAAU;AAAA,IAC1B;AAAA,MACE,CACE,OAMA,QACG;AACH,cAAM,UAAU,mBAAmB,SAAS,KAAK,UAAU,aAAa;AACxE,cAAM,aAAa,OAAO,MAAM,SAAS,MAAM,gBAAgB,EAAE;AACjE,cAAM,sBAAsB,OAA+B;AAE3D,cAAM,WAAW;AAAA,UACf,CAAC,UAAU;AACT,gBAAI,CAAC,MAAM;AAAI;AACf,gBAAI,CAAC;AAAO;AACZ,gCAAoB,UAAU;AAC9B,gCAAoB,UAAU,kBAAkB,MAAM,IAAI;AAAA,cACxD,OAAO,MAAM;AAAA,cAEb,GAAI,WAAW;AAAA;AAAA,gBAEb,iBAAiB;AACf,wBAAM,MAAM;AACZ,sBAAI,MAAM,gBAAgB,OAAO,WAAW,YAAY,UAAU;AAChE,0BAAM,aAAa,GAAG,WAAW,QAAQ,MAAM;AAAA,kBACjD;AAAA,gBACF;AAAA,cACF;AAAA,YACF,CAAC;AAAA,UACH;AAAA,UACA,CAAC,SAAS,MAAM,EAAE;AAAA,QACpB;AAEA,cAAM,eAAe,YAAY,KAAK,QAAQ;AAE9C,kBAAU,MAAM;AACd,iBAAO,MAAM;AACX,gCAAoB,UAAU;AAAA,UAChC;AAAA,QACF,GAAG,CAAC,CAAC;AAEL,cAAM,eAAe,SAAS,CAAC,UAAU;AACvC,qBAAW,UAAU;AACrB,gBAAM,eAAe,KAAK;AAAA,QAC5B,CAAC;AAED,cAAM,aAAa,UACf;AAAA,UACE,GAAG;AAAA,UACH;AAAA,QACF,IACA;AAGJ,eAAO,CAAC,UAAU,KAAK,kBAAkB,YAAY;AAAA,MACvD;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/dist/jsx/index.js
CHANGED
package/dist/jsx/index.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
4
|
"sourcesContent": ["export * from './registerFocusable'\nexport * from './focusableInputHOC'\nexport * from './focusable'\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
5
|
+
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/jsx/index.mjs
CHANGED
package/dist/jsx/index.mjs.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
4
|
"sourcesContent": ["export * from './registerFocusable'\nexport * from './focusableInputHOC'\nexport * from './focusable'\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
5
|
+
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
const
|
|
1
|
+
const registerFocusable = (id, input) => () => {
|
|
2
|
+
};
|
|
3
|
+
const unregisterFocusable = (id) => {
|
|
4
|
+
};
|
|
5
|
+
const focusFocusable = (id) => {
|
|
6
|
+
};
|
|
7
|
+
export {
|
|
8
|
+
focusFocusable,
|
|
9
|
+
registerFocusable,
|
|
10
|
+
unregisterFocusable
|
|
11
|
+
};
|
|
2
12
|
//# sourceMappingURL=registerFocusable.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/registerFocusable.ts"],
|
|
4
4
|
"sourcesContent": ["import { Focusable } from './focusable'\n\nexport const registerFocusable = (id: string, input: Focusable) => () => {\n // noop focus is handed natively\n}\n\nexport const unregisterFocusable = (id: string) => {\n // noop focus is handed natively\n}\n\nexport const focusFocusable = (id: string) => {\n // noop focus is handed natively\n}\n"],
|
|
5
|
-
"mappings": "AAEO,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAEO,MAAM,oBAAoB,CAAC,IAAY,UAAqB,MAAM;AAEzE;AAEO,MAAM,sBAAsB,CAAC,OAAe;AAEnD;AAEO,MAAM,iBAAiB,CAAC,OAAe;AAE9C;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
const
|
|
1
|
+
const registerFocusable = (id, input) => () => {
|
|
2
|
+
};
|
|
3
|
+
const unregisterFocusable = (id) => {
|
|
4
|
+
};
|
|
5
|
+
const focusFocusable = (id) => {
|
|
6
|
+
};
|
|
7
|
+
export {
|
|
8
|
+
focusFocusable,
|
|
9
|
+
registerFocusable,
|
|
10
|
+
unregisterFocusable
|
|
11
|
+
};
|
|
2
12
|
//# sourceMappingURL=registerFocusable.mjs.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/registerFocusable.ts"],
|
|
4
4
|
"sourcesContent": ["import { Focusable } from './focusable'\n\nexport const registerFocusable = (id: string, input: Focusable) => () => {\n // noop focus is handed natively\n}\n\nexport const unregisterFocusable = (id: string) => {\n // noop focus is handed natively\n}\n\nexport const focusFocusable = (id: string) => {\n // noop focus is handed natively\n}\n"],
|
|
5
|
-
"mappings": "AAEO,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAEO,MAAM,oBAAoB,CAAC,IAAY,UAAqB,MAAM;AAEzE;AAEO,MAAM,sBAAsB,CAAC,OAAe;AAEnD;AAEO,MAAM,iBAAiB,CAAC,OAAe;AAE9C;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,35 @@
|
|
|
1
|
-
const
|
|
1
|
+
const InputsMap = /* @__PURE__ */ new Map();
|
|
2
|
+
const registerFocusable = (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 () => {
|
|
10
|
+
InputsMap.delete(id);
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
const unregisterFocusable = (id) => {
|
|
14
|
+
InputsMap.delete(id);
|
|
15
|
+
};
|
|
16
|
+
const focusFocusable = (id, select = false) => {
|
|
17
|
+
const input = InputsMap.get(id);
|
|
18
|
+
if (!input) {
|
|
19
|
+
if (process.env.NODE_ENV === "development") {
|
|
20
|
+
console.warn("No input found for id", id);
|
|
21
|
+
}
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (select || !input.focusAndSelect) {
|
|
25
|
+
input.focus();
|
|
26
|
+
} else {
|
|
27
|
+
input.focusAndSelect();
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
focusFocusable,
|
|
32
|
+
registerFocusable,
|
|
33
|
+
unregisterFocusable
|
|
34
|
+
};
|
|
2
35
|
//# sourceMappingURL=registerFocusable.native.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/registerFocusable.native.ts"],
|
|
4
4
|
"sourcesContent": ["// used for focusing on native\n\nimport { Focusable } from './focusable'\n\nconst InputsMap = new Map<string, Focusable>()\n\nexport const registerFocusable = (id: string, input: Focusable) => {\n if (process.env.NODE_ENV === 'development') {\n if (InputsMap.has(id)) {\n // eslint-disable-next-line no-console\n console.warn(`Warning, duplicate ID for input: ${id}`)\n }\n }\n InputsMap.set(id, input)\n return () => {\n InputsMap.delete(id)\n }\n}\n\nexport const unregisterFocusable = (id: string) => {\n InputsMap.delete(id)\n}\n\nexport const focusFocusable = (id: string, select = false) => {\n const input = InputsMap.get(id)\n if (!input) {\n if (process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\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"],
|
|
5
|
-
"mappings": "AAIA,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAIA,MAAM,YAAY,oBAAI,IAAuB;AAEtC,MAAM,oBAAoB,CAAC,IAAY,UAAqB;AACjE,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,UAAU,IAAI,EAAE,GAAG;AAErB,cAAQ,KAAK,oCAAoC,IAAI;AAAA,IACvD;AAAA,EACF;AACA,YAAU,IAAI,IAAI,KAAK;AACvB,SAAO,MAAM;AACX,cAAU,OAAO,EAAE;AAAA,EACrB;AACF;AAEO,MAAM,sBAAsB,CAAC,OAAe;AACjD,YAAU,OAAO,EAAE;AACrB;AAEO,MAAM,iBAAiB,CAAC,IAAY,SAAS,UAAU;AAC5D,QAAM,QAAQ,UAAU,IAAI,EAAE;AAC9B,MAAI,CAAC,OAAO;AACV,QAAI,QAAQ,IAAI,aAAa,eAAe;AAE1C,cAAQ,KAAK,yBAAyB,EAAE;AAAA,IAC1C;AACA;AAAA,EACF;AACA,MAAI,UAAU,CAAC,MAAM,gBAAgB;AACnC,UAAM,MAAM;AAAA,EACd,OAAO;AACL,UAAM,eAAe;AAAA,EACvB;AACF;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,35 @@
|
|
|
1
|
-
const
|
|
1
|
+
const InputsMap = /* @__PURE__ */ new Map();
|
|
2
|
+
const registerFocusable = (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 () => {
|
|
10
|
+
InputsMap.delete(id);
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
const unregisterFocusable = (id) => {
|
|
14
|
+
InputsMap.delete(id);
|
|
15
|
+
};
|
|
16
|
+
const focusFocusable = (id, select = false) => {
|
|
17
|
+
const input = InputsMap.get(id);
|
|
18
|
+
if (!input) {
|
|
19
|
+
if (process.env.NODE_ENV === "development") {
|
|
20
|
+
console.warn("No input found for id", id);
|
|
21
|
+
}
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (select || !input.focusAndSelect) {
|
|
25
|
+
input.focus();
|
|
26
|
+
} else {
|
|
27
|
+
input.focusAndSelect();
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
focusFocusable,
|
|
32
|
+
registerFocusable,
|
|
33
|
+
unregisterFocusable
|
|
34
|
+
};
|
|
2
35
|
//# sourceMappingURL=registerFocusable.native.mjs.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/registerFocusable.native.ts"],
|
|
4
4
|
"sourcesContent": ["// used for focusing on native\n\nimport { Focusable } from './focusable'\n\nconst InputsMap = new Map<string, Focusable>()\n\nexport const registerFocusable = (id: string, input: Focusable) => {\n if (process.env.NODE_ENV === 'development') {\n if (InputsMap.has(id)) {\n // eslint-disable-next-line no-console\n console.warn(`Warning, duplicate ID for input: ${id}`)\n }\n }\n InputsMap.set(id, input)\n return () => {\n InputsMap.delete(id)\n }\n}\n\nexport const unregisterFocusable = (id: string) => {\n InputsMap.delete(id)\n}\n\nexport const focusFocusable = (id: string, select = false) => {\n const input = InputsMap.get(id)\n if (!input) {\n if (process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\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"],
|
|
5
|
-
"mappings": "AAIA,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAIA,MAAM,YAAY,oBAAI,IAAuB;AAEtC,MAAM,oBAAoB,CAAC,IAAY,UAAqB;AACjE,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,UAAU,IAAI,EAAE,GAAG;AAErB,cAAQ,KAAK,oCAAoC,IAAI;AAAA,IACvD;AAAA,EACF;AACA,YAAU,IAAI,IAAI,KAAK;AACvB,SAAO,MAAM;AACX,cAAU,OAAO,EAAE;AAAA,EACrB;AACF;AAEO,MAAM,sBAAsB,CAAC,OAAe;AACjD,YAAU,OAAO,EAAE;AACrB;AAEO,MAAM,iBAAiB,CAAC,IAAY,SAAS,UAAU;AAC5D,QAAM,QAAQ,UAAU,IAAI,EAAE;AAC9B,MAAI,CAAC,OAAO;AACV,QAAI,QAAQ,IAAI,aAAa,eAAe;AAE1C,cAAQ,KAAK,yBAAyB,EAAE;AAAA,IAC1C;AACA;AAAA,EACF;AACA,MAAI,UAAU,CAAC,MAAM,gBAAgB;AACnC,UAAM,MAAM;AAAA,EACd,OAAO;AACL,UAAM,eAAe;AAAA,EACvB;AACF;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/focusable",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.3",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"types": "./types/index.d.ts",
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
"clean:build": "tamagui-build clean:build"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@tamagui/compose-refs": "1.14.
|
|
26
|
-
"@tamagui/web": "1.14.
|
|
25
|
+
"@tamagui/compose-refs": "1.14.3",
|
|
26
|
+
"@tamagui/web": "1.14.3"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"react": "*"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@tamagui/build": "1.14.
|
|
32
|
+
"@tamagui/build": "1.14.3",
|
|
33
33
|
"react": "^18.2.0"
|
|
34
34
|
},
|
|
35
35
|
"publishConfig": {
|