@tamagui/focusable 1.46.2 → 1.47.0
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/package.json +4 -4
- package/dist/jsx/focusable.mjs +0 -1
- package/dist/jsx/focusable.mjs.map +0 -6
- package/dist/jsx/focusableInputHOC.mjs +0 -68
- package/dist/jsx/focusableInputHOC.mjs.map +0 -6
- package/dist/jsx/index.mjs +0 -4
- package/dist/jsx/index.mjs.map +0 -6
- package/dist/jsx/registerFocusable.mjs +0 -12
- package/dist/jsx/registerFocusable.mjs.map +0 -6
- package/dist/jsx/registerFocusable.native.mjs +0 -35
- package/dist/jsx/registerFocusable.native.mjs.map +0 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/focusable",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.47.0",
|
|
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.
|
|
26
|
-
"@tamagui/web": "1.
|
|
25
|
+
"@tamagui/compose-refs": "1.47.0",
|
|
26
|
+
"@tamagui/web": "1.47.0"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"react": "*"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@tamagui/build": "1.
|
|
32
|
+
"@tamagui/build": "1.47.0",
|
|
33
33
|
"react": "^18.2.0"
|
|
34
34
|
},
|
|
35
35
|
"publishConfig": {
|
package/dist/jsx/focusable.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=focusable.mjs.map
|
|
@@ -1,68 +0,0 @@
|
|
|
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
|
-
function useFocusable({
|
|
6
|
-
isInput,
|
|
7
|
-
props,
|
|
8
|
-
ref
|
|
9
|
-
}) {
|
|
10
|
-
const { id, onChangeText, value, defaultValue } = props;
|
|
11
|
-
const inputValue = useRef(value || defaultValue || "");
|
|
12
|
-
const unregisterFocusable = useRef();
|
|
13
|
-
const inputRef = useCallback(
|
|
14
|
-
(input) => {
|
|
15
|
-
if (!id)
|
|
16
|
-
return;
|
|
17
|
-
if (!input)
|
|
18
|
-
return;
|
|
19
|
-
unregisterFocusable.current?.();
|
|
20
|
-
unregisterFocusable.current = registerFocusable(id, {
|
|
21
|
-
focus: input.focus,
|
|
22
|
-
...isInput && {
|
|
23
|
-
// react-native doesn't support programmatic .select()
|
|
24
|
-
focusAndSelect() {
|
|
25
|
-
input.focus();
|
|
26
|
-
if (input.setSelection && typeof inputValue.current === "string") {
|
|
27
|
-
input.setSelection(0, inputValue.current.length);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
},
|
|
33
|
-
[isInput, id]
|
|
34
|
-
);
|
|
35
|
-
const combinedRefs = composeRefs(ref, inputRef);
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
return () => {
|
|
38
|
-
unregisterFocusable.current?.();
|
|
39
|
-
};
|
|
40
|
-
}, []);
|
|
41
|
-
return {
|
|
42
|
-
ref: combinedRefs,
|
|
43
|
-
onChangeText: useEvent((value2) => {
|
|
44
|
-
inputValue.current = value2;
|
|
45
|
-
onChangeText?.(value2);
|
|
46
|
-
})
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
function focusableInputHOC(Component) {
|
|
50
|
-
return Component.styleable((props, ref) => {
|
|
51
|
-
const isInput = Component.staticConfig?.isInput;
|
|
52
|
-
const { ref: combinedRef, onChangeText } = useFocusable({
|
|
53
|
-
ref,
|
|
54
|
-
props,
|
|
55
|
-
isInput
|
|
56
|
-
});
|
|
57
|
-
const finalProps = isInput ? {
|
|
58
|
-
...props,
|
|
59
|
-
onChangeText
|
|
60
|
-
} : props;
|
|
61
|
-
return <Component ref={combinedRef} {...finalProps} />;
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
export {
|
|
65
|
-
focusableInputHOC,
|
|
66
|
-
useFocusable
|
|
67
|
-
};
|
|
68
|
-
//# sourceMappingURL=focusableInputHOC.mjs.map
|
|
@@ -1,6 +0,0 @@
|
|
|
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;AAS3B,SAAS,aAAa;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AACF,GAIG;AACD,QAAM,EAAE,IAAI,cAAc,OAAO,aAAa,IAAI;AAClD,QAAM,aAAa,OAAO,SAAS,gBAAgB,EAAE;AACrD,QAAM,sBAAsB,OAA+B;AAE3D,QAAM,WAAW;AAAA,IACf,CAAC,UAAU;AACT,UAAI,CAAC;AAAI;AACT,UAAI,CAAC;AAAO;AACZ,0BAAoB,UAAU;AAC9B,0BAAoB,UAAU,kBAAkB,IAAI;AAAA,QAClD,OAAO,MAAM;AAAA,QAEb,GAAI,WAAW;AAAA;AAAA,UAEb,iBAAiB;AACf,kBAAM,MAAM;AACZ,gBAAI,MAAM,gBAAgB,OAAO,WAAW,YAAY,UAAU;AAChE,oBAAM,aAAa,GAAG,WAAW,QAAQ,MAAM;AAAA,YACjD;AAAA,UACF;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACA,CAAC,SAAS,EAAE;AAAA,EACd;AAEA,QAAM,eAAe,YAAY,KAAK,QAAQ;AAE9C,YAAU,MAAM;AACd,WAAO,MAAM;AACX,0BAAoB,UAAU;AAAA,IAChC;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO;AAAA,IACL,KAAK;AAAA,IACL,cAAc,SAAS,CAACA,WAAU;AAChC,iBAAW,UAAUA;AACrB,qBAAeA,MAAK;AAAA,IACtB,CAAC;AAAA,EACH;AACF;AAEO,SAAS,kBAA8C,WAAiB;AAC7E,SAAO,UAAU,UAAU,CAAC,OAAuB,QAAQ;AACzD,UAAM,UAAU,UAAU,cAAc;AACxC,UAAM,EAAE,KAAK,aAAa,aAAa,IAAI,aAAa;AAAA,MACtD;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AACD,UAAM,aAAa,UACf;AAAA,MACE,GAAG;AAAA,MACH;AAAA,IACF,IACA;AAGJ,WAAO,CAAC,UAAU,KAAK,iBAAiB,YAAY;AAAA,EACtD,CAAC;AACH;",
|
|
5
|
-
"names": ["value"]
|
|
6
|
-
}
|
package/dist/jsx/index.mjs
DELETED
package/dist/jsx/index.mjs.map
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
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
|
-
};
|
|
12
|
-
//# sourceMappingURL=registerFocusable.mjs.map
|
|
@@ -1,35 +0,0 @@
|
|
|
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
|
-
};
|
|
35
|
-
//# sourceMappingURL=registerFocusable.native.mjs.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/registerFocusable.native.ts"],
|
|
4
|
-
"mappings": "AAIA,MAAM,YAAY,oBAAI,IAAuB;AAEtC,MAAM,oBAAoB,CAAC,IAAY,UAAqB;AACjE,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,UAAU,IAAI,EAAE,GAAG;AACrB,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;AAC1C,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;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|