@tamagui/focusable 1.5.16 → 1.5.18
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/focusableInputHOC.js +3 -3
- package/dist/cjs/focusableInputHOC.js.map +2 -2
- package/dist/esm/focusableInputHOC.js +1 -1
- package/dist/esm/focusableInputHOC.js.map +1 -1
- package/dist/esm/focusableInputHOC.mjs +1 -1
- package/dist/esm/focusableInputHOC.mjs.map +1 -1
- package/dist/jsx/focusableInputHOC.js +1 -1
- package/dist/jsx/focusableInputHOC.js.map +1 -1
- package/dist/jsx/focusableInputHOC.mjs +1 -1
- package/dist/jsx/focusableInputHOC.mjs.map +1 -1
- package/package.json +4 -4
- package/src/focusableInputHOC.tsx +1 -1
- package/types/focusableInputHOC.d.ts +1 -1
- package/types/focusableInputHOC.d.ts.map +1 -1
|
@@ -23,14 +23,14 @@ __export(focusableInputHOC_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(focusableInputHOC_exports);
|
|
24
24
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
25
|
var import_compose_refs = require("@tamagui/compose-refs");
|
|
26
|
-
var
|
|
26
|
+
var import_web = require("@tamagui/web");
|
|
27
27
|
var import_react = require("react");
|
|
28
28
|
var import_registerFocusable = require("./registerFocusable");
|
|
29
29
|
function focusableInputHOC(Component) {
|
|
30
30
|
const component = Component.extractable(
|
|
31
31
|
(0, import_react.forwardRef)(
|
|
32
32
|
(props, ref) => {
|
|
33
|
-
const isInput = (0,
|
|
33
|
+
const isInput = (0, import_web.isTamaguiComponent)(Component) && Component.staticConfig.isInput;
|
|
34
34
|
const inputValue = (0, import_react.useRef)(props.value || props.defaultValue || "");
|
|
35
35
|
const unregisterFocusable = (0, import_react.useRef)();
|
|
36
36
|
const inputRef = (0, import_react.useCallback)(
|
|
@@ -63,7 +63,7 @@ function focusableInputHOC(Component) {
|
|
|
63
63
|
(_a = unregisterFocusable.current) == null ? void 0 : _a.call(unregisterFocusable);
|
|
64
64
|
};
|
|
65
65
|
}, []);
|
|
66
|
-
const onChangeText = (0,
|
|
66
|
+
const onChangeText = (0, import_web.useEvent)((value) => {
|
|
67
67
|
var _a;
|
|
68
68
|
inputValue.current = value;
|
|
69
69
|
(_a = props.onChangeText) == null ? void 0 : _a.call(props, value);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/focusableInputHOC.tsx"],
|
|
4
|
-
"sourcesContent": ["import { composeRefs } from '@tamagui/compose-refs'\nimport { TamaguiComponent, isTamaguiComponent, useEvent } from '@tamagui/
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiEe;AAjEf,0BAA4B;AAC5B,
|
|
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;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
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { composeRefs } from "@tamagui/compose-refs";
|
|
3
|
-
import { isTamaguiComponent, useEvent } from "@tamagui/
|
|
3
|
+
import { isTamaguiComponent, useEvent } from "@tamagui/web";
|
|
4
4
|
import { forwardRef, useCallback, useEffect, useRef } from "react";
|
|
5
5
|
import { registerFocusable } from "./registerFocusable";
|
|
6
6
|
function focusableInputHOC(Component) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/focusableInputHOC.tsx"],
|
|
4
|
-
"sourcesContent": ["import { composeRefs } from '@tamagui/compose-refs'\nimport { TamaguiComponent, isTamaguiComponent, useEvent } from '@tamagui/
|
|
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
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
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { composeRefs } from "@tamagui/compose-refs";
|
|
3
|
-
import { isTamaguiComponent, useEvent } from "@tamagui/
|
|
3
|
+
import { isTamaguiComponent, useEvent } from "@tamagui/web";
|
|
4
4
|
import { forwardRef, useCallback, useEffect, useRef } from "react";
|
|
5
5
|
import { registerFocusable } from "./registerFocusable";
|
|
6
6
|
function focusableInputHOC(Component) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/focusableInputHOC.tsx"],
|
|
4
|
-
"sourcesContent": ["import { composeRefs } from '@tamagui/compose-refs'\nimport { TamaguiComponent, isTamaguiComponent, useEvent } from '@tamagui/
|
|
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
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
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { composeRefs } from "@tamagui/compose-refs";
|
|
2
|
-
import { isTamaguiComponent, useEvent } from "@tamagui/
|
|
2
|
+
import { isTamaguiComponent, useEvent } from "@tamagui/web";
|
|
3
3
|
import { forwardRef, useCallback, useEffect, useRef } from "react";
|
|
4
4
|
import { registerFocusable } from "./registerFocusable";
|
|
5
5
|
function focusableInputHOC(Component) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/focusableInputHOC.tsx"],
|
|
4
|
-
"sourcesContent": ["import { composeRefs } from '@tamagui/compose-refs'\nimport { TamaguiComponent, isTamaguiComponent, useEvent } from '@tamagui/
|
|
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
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
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { composeRefs } from "@tamagui/compose-refs";
|
|
2
|
-
import { isTamaguiComponent, useEvent } from "@tamagui/
|
|
2
|
+
import { isTamaguiComponent, useEvent } from "@tamagui/web";
|
|
3
3
|
import { forwardRef, useCallback, useEffect, useRef } from "react";
|
|
4
4
|
import { registerFocusable } from "./registerFocusable";
|
|
5
5
|
function focusableInputHOC(Component) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/focusableInputHOC.tsx"],
|
|
4
|
-
"sourcesContent": ["import { composeRefs } from '@tamagui/compose-refs'\nimport { TamaguiComponent, isTamaguiComponent, useEvent } from '@tamagui/
|
|
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
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
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/focusable",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.18",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"types": "./types/index.d.ts",
|
|
@@ -22,15 +22,15 @@
|
|
|
22
22
|
"clean:build": "tamagui-build clean:build"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@tamagui/compose-refs": "^1.5.
|
|
26
|
-
"@tamagui/
|
|
25
|
+
"@tamagui/compose-refs": "^1.5.18",
|
|
26
|
+
"@tamagui/web": "^1.5.18"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"react": "*",
|
|
30
30
|
"react-dom": "*"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@tamagui/build": "^1.5.
|
|
33
|
+
"@tamagui/build": "^1.5.18",
|
|
34
34
|
"react": "^18.2.0",
|
|
35
35
|
"react-dom": "^18.2.0"
|
|
36
36
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { composeRefs } from '@tamagui/compose-refs'
|
|
2
|
-
import { TamaguiComponent, isTamaguiComponent, useEvent } from '@tamagui/
|
|
2
|
+
import { TamaguiComponent, isTamaguiComponent, useEvent } from '@tamagui/web'
|
|
3
3
|
import { forwardRef, useCallback, useEffect, useRef } from 'react'
|
|
4
4
|
|
|
5
5
|
import { registerFocusable } from './registerFocusable'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focusableInputHOC.d.ts","sourceRoot":"","sources":["../src/focusableInputHOC.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAgC,MAAM,
|
|
1
|
+
{"version":3,"file":"focusableInputHOC.d.ts","sourceRoot":"","sources":["../src/focusableInputHOC.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAgC,MAAM,cAAc,CAAA;AAK7E,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,gBAAgB,EAAE,SAAS,EAAE,CAAC,GAAG,CAAC,CAiE7E"}
|