@tamagui/focusable 1.74.3 → 1.74.5
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/esm/focusable.native.js +1 -0
- package/dist/esm/focusable.native.js.map +6 -0
- package/dist/esm/focusableInputHOC.native.js +51 -0
- package/dist/esm/focusableInputHOC.native.js.map +6 -0
- package/dist/esm/index.native.js +4 -0
- package/dist/esm/index.native.js.map +6 -0
- package/dist/esm/registerFocusable.native.js +18 -0
- package/dist/esm/registerFocusable.native.js.map +6 -0
- package/package.json +4 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=focusable.js.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { composeRefs } from "@tamagui/compose-refs";
|
|
2
|
+
import { useEvent } from "@tamagui/web";
|
|
3
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
4
|
+
import { registerFocusable } from "./registerFocusable";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
function useFocusable({
|
|
7
|
+
isInput,
|
|
8
|
+
props,
|
|
9
|
+
ref
|
|
10
|
+
}) {
|
|
11
|
+
const { id, onChangeText, value, defaultValue } = props, inputValue = useRef(value || defaultValue || ""), unregisterFocusable = useRef(), inputRef = useCallback(
|
|
12
|
+
(input) => {
|
|
13
|
+
id && input && (unregisterFocusable.current?.(), unregisterFocusable.current = registerFocusable(id, {
|
|
14
|
+
focus: input.focus,
|
|
15
|
+
...isInput && {
|
|
16
|
+
// react-native doesn't support programmatic .select()
|
|
17
|
+
focusAndSelect() {
|
|
18
|
+
input.focus(), input.setSelection && typeof inputValue.current == "string" && input.setSelection(0, inputValue.current.length);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}));
|
|
22
|
+
},
|
|
23
|
+
[isInput, id]
|
|
24
|
+
), combinedRefs = composeRefs(ref, inputRef);
|
|
25
|
+
return useEffect(() => () => {
|
|
26
|
+
unregisterFocusable.current?.();
|
|
27
|
+
}, []), {
|
|
28
|
+
ref: combinedRefs,
|
|
29
|
+
onChangeText: useEvent((value2) => {
|
|
30
|
+
inputValue.current = value2, onChangeText?.(value2);
|
|
31
|
+
})
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function focusableInputHOC(Component) {
|
|
35
|
+
return Component.styleable((props, ref) => {
|
|
36
|
+
const isInput = Component.staticConfig?.isInput, { ref: combinedRef, onChangeText } = useFocusable({
|
|
37
|
+
ref,
|
|
38
|
+
props,
|
|
39
|
+
isInput
|
|
40
|
+
}), finalProps = isInput ? {
|
|
41
|
+
...props,
|
|
42
|
+
onChangeText
|
|
43
|
+
} : props;
|
|
44
|
+
return /* @__PURE__ */ jsx(Component, { ref: combinedRef, ...finalProps });
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
focusableInputHOC,
|
|
49
|
+
useFocusable
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=focusableInputHOC.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/focusableInputHOC.tsx"],
|
|
4
|
+
"mappings": "AAAA,SAAS,mBAAmB;AAC5B,SAA2B,gBAAgB;AAC3C,SAAgB,aAAa,WAAW,cAAc;AAEtD,SAAS,yBAAyB;AA6EvB;AApEJ,SAAS,aAAa;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AACF,GAIG;AACD,QAAM,EAAE,IAAI,cAAc,OAAO,aAAa,IAAI,OAC5C,aAAa,OAAO,SAAS,gBAAgB,EAAE,GAC/C,sBAAsB,OAA+B,GAErD,WAAW;AAAA,IACf,CAAC,UAAU;AACT,MAAK,MACA,UACL,oBAAoB,UAAU,GAC9B,oBAAoB,UAAU,kBAAkB,IAAI;AAAA,QAClD,OAAO,MAAM;AAAA,QAEb,GAAI,WAAW;AAAA;AAAA,UAEb,iBAAiB;AACf,kBAAM,MAAM,GACR,MAAM,gBAAgB,OAAO,WAAW,WAAY,YACtD,MAAM,aAAa,GAAG,WAAW,QAAQ,MAAM;AAAA,UAEnD;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACA,CAAC,SAAS,EAAE;AAAA,EACd,GAEM,eAAe,YAAY,KAAK,QAAQ;AAE9C,mBAAU,MACD,MAAM;AACX,wBAAoB,UAAU;AAAA,EAChC,GACC,CAAC,CAAC,GAEE;AAAA,IACL,KAAK;AAAA,IACL,cAAc,SAAS,CAACA,WAAU;AAChC,iBAAW,UAAUA,QACrB,eAAeA,MAAK;AAAA,IACtB,CAAC;AAAA,EACH;AACF;AAEO,SAAS,kBAA8C,WAAiB;AAC7E,SAAO,UAAU,UAAU,CAAC,OAAuB,QAAQ;AACzD,UAAM,UAAU,UAAU,cAAc,SAClC,EAAE,KAAK,aAAa,aAAa,IAAI,aAAa;AAAA,MACtD;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC,GACK,aAAa,UACf;AAAA,MACE,GAAG;AAAA,MACH;AAAA,IACF,IACA;AAGJ,WAAO,oBAAC,aAAU,KAAK,aAAc,GAAG,YAAY;AAAA,EACtD,CAAC;AACH;",
|
|
5
|
+
"names": ["value"]
|
|
6
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const InputsMap = /* @__PURE__ */ new Map(), registerFocusable = (id, input) => (process.env.NODE_ENV === "development" && InputsMap.has(id) && console.warn(`Warning, duplicate ID for input: ${id}`), InputsMap.set(id, input), () => {
|
|
2
|
+
InputsMap.delete(id);
|
|
3
|
+
}), unregisterFocusable = (id) => {
|
|
4
|
+
InputsMap.delete(id);
|
|
5
|
+
}, focusFocusable = (id, select = !1) => {
|
|
6
|
+
const input = InputsMap.get(id);
|
|
7
|
+
if (!input) {
|
|
8
|
+
process.env.NODE_ENV === "development" && console.warn("No input found for id", id);
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
select || !input.focusAndSelect ? input.focus() : input.focusAndSelect();
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
focusFocusable,
|
|
15
|
+
registerFocusable,
|
|
16
|
+
unregisterFocusable
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=registerFocusable.native.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/registerFocusable.native.ts"],
|
|
4
|
+
"mappings": "AAIA,MAAM,YAAY,oBAAI,IAAuB,GAEhC,oBAAoB,CAAC,IAAY,WACxC,QAAQ,IAAI,aAAa,iBACvB,UAAU,IAAI,EAAE,KAClB,QAAQ,KAAK,oCAAoC,EAAE,EAAE,GAGzD,UAAU,IAAI,IAAI,KAAK,GAChB,MAAM;AACX,YAAU,OAAO,EAAE;AACrB,IAGW,sBAAsB,CAAC,OAAe;AACjD,YAAU,OAAO,EAAE;AACrB,GAEa,iBAAiB,CAAC,IAAY,SAAS,OAAU;AAC5D,QAAM,QAAQ,UAAU,IAAI,EAAE;AAC9B,MAAI,CAAC,OAAO;AACV,IAAI,QAAQ,IAAI,aAAa,iBAC3B,QAAQ,KAAK,yBAAyB,EAAE;AAE1C;AAAA,EACF;AACA,EAAI,UAAU,CAAC,MAAM,iBACnB,MAAM,MAAM,IAEZ,MAAM,eAAe;AAEzB;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/focusable",
|
|
3
|
-
"version": "1.74.
|
|
3
|
+
"version": "1.74.5",
|
|
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.74.
|
|
26
|
-
"@tamagui/web": "1.74.
|
|
25
|
+
"@tamagui/compose-refs": "1.74.5",
|
|
26
|
+
"@tamagui/web": "1.74.5"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"react": "*"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@tamagui/build": "1.74.
|
|
32
|
+
"@tamagui/build": "1.74.5",
|
|
33
33
|
"react": "^18.2.0"
|
|
34
34
|
},
|
|
35
35
|
"publishConfig": {
|