@tamagui/focusable 1.26.0 → 1.26.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/dist/esm/focusable.mjs +0 -1
- package/dist/esm/focusable.mjs.map +0 -6
- package/dist/esm/focusableInputHOC.mjs +0 -59
- package/dist/esm/focusableInputHOC.mjs.map +0 -6
- package/dist/esm/index.mjs +0 -4
- package/dist/esm/index.mjs.map +0 -6
- package/dist/esm/registerFocusable.mjs +0 -12
- package/dist/esm/registerFocusable.mjs.map +0 -6
- package/dist/esm/registerFocusable.native.mjs +0 -35
- package/dist/esm/registerFocusable.native.mjs.map +0 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/focusable",
|
|
3
|
-
"version": "1.26.
|
|
3
|
+
"version": "1.26.1",
|
|
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.
|
|
26
|
-
"@tamagui/web": "1.26.
|
|
25
|
+
"@tamagui/compose-refs": "1.26.1",
|
|
26
|
+
"@tamagui/web": "1.26.1"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"react": "*"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@tamagui/build": "1.26.
|
|
32
|
+
"@tamagui/build": "1.26.1",
|
|
33
33
|
"react": "^18.2.0"
|
|
34
34
|
},
|
|
35
35
|
"publishConfig": {
|
package/dist/esm/focusable.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=focusable.mjs.map
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { composeRefs } from "@tamagui/compose-refs";
|
|
3
|
-
import { isTamaguiComponent, useEvent } from "@tamagui/web";
|
|
4
|
-
import { useCallback, useEffect, useRef } from "react";
|
|
5
|
-
import { registerFocusable } from "./registerFocusable";
|
|
6
|
-
function focusableInputHOC(Component) {
|
|
7
|
-
const component = Component.styleable(
|
|
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
|
-
var _a;
|
|
15
|
-
if (!props.id)
|
|
16
|
-
return;
|
|
17
|
-
if (!input)
|
|
18
|
-
return;
|
|
19
|
-
(_a = unregisterFocusable.current) == null ? void 0 : _a.call(unregisterFocusable);
|
|
20
|
-
unregisterFocusable.current = registerFocusable(props.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, props.id]
|
|
34
|
-
);
|
|
35
|
-
const combinedRefs = composeRefs(ref, inputRef);
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
return () => {
|
|
38
|
-
var _a;
|
|
39
|
-
(_a = unregisterFocusable.current) == null ? void 0 : _a.call(unregisterFocusable);
|
|
40
|
-
};
|
|
41
|
-
}, []);
|
|
42
|
-
const onChangeText = useEvent((value) => {
|
|
43
|
-
var _a;
|
|
44
|
-
inputValue.current = value;
|
|
45
|
-
(_a = props.onChangeText) == null ? void 0 : _a.call(props, value);
|
|
46
|
-
});
|
|
47
|
-
const finalProps = isInput ? {
|
|
48
|
-
...props,
|
|
49
|
-
onChangeText
|
|
50
|
-
} : props;
|
|
51
|
-
return /* @__PURE__ */ jsx(Component, { ref: combinedRefs, ...finalProps });
|
|
52
|
-
}
|
|
53
|
-
);
|
|
54
|
-
return component;
|
|
55
|
-
}
|
|
56
|
-
export {
|
|
57
|
-
focusableInputHOC
|
|
58
|
-
};
|
|
59
|
-
//# sourceMappingURL=focusableInputHOC.mjs.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/focusableInputHOC.tsx"],
|
|
4
|
-
"mappings": "AAgEa;AAhEb,SAAS,mBAAmB;AAC5B,SAA2B,oBAAoB,gBAAgB;AAC/D,SAAS,aAAa,WAAW,cAAc;AAE/C,SAAS,yBAAyB;AAE3B,SAAS,kBAA8C,WAAiB;AAC7E,QAAM,YAAY,UAAU;AAAA,IAC1B,CACE,OAMA,QACG;AACH,YAAM,UAAU,mBAAmB,SAAS,KAAK,UAAU,aAAa;AACxE,YAAM,aAAa,OAAO,MAAM,SAAS,MAAM,gBAAgB,EAAE;AACjE,YAAM,sBAAsB,OAA+B;AAE3D,YAAM,WAAW;AAAA,QACf,CAAC,UAAU;AAtBnB;AAuBU,cAAI,CAAC,MAAM;AAAI;AACf,cAAI,CAAC;AAAO;AACZ,oCAAoB,YAApB;AACA,8BAAoB,UAAU,kBAAkB,MAAM,IAAI;AAAA,YACxD,OAAO,MAAM;AAAA,YAEb,GAAI,WAAW;AAAA;AAAA,cAEb,iBAAiB;AACf,sBAAM,MAAM;AACZ,oBAAI,MAAM,gBAAgB,OAAO,WAAW,YAAY,UAAU;AAChE,wBAAM,aAAa,GAAG,WAAW,QAAQ,MAAM;AAAA,gBACjD;AAAA,cACF;AAAA,YACF;AAAA,UACF,CAAC;AAAA,QACH;AAAA,QACA,CAAC,SAAS,MAAM,EAAE;AAAA,MACpB;AAEA,YAAM,eAAe,YAAY,KAAK,QAAQ;AAE9C,gBAAU,MAAM;AACd,eAAO,MAAM;AA9CrB;AA+CU,oCAAoB,YAApB;AAAA,QACF;AAAA,MACF,GAAG,CAAC,CAAC;AAEL,YAAM,eAAe,SAAS,CAAC,UAAU;AAnD/C;AAoDQ,mBAAW,UAAU;AACrB,oBAAM,iBAAN,+BAAqB;AAAA,MACvB,CAAC;AAED,YAAM,aAAa,UACf;AAAA,QACE,GAAG;AAAA,QACH;AAAA,MACF,IACA;AAGJ,aAAO,oBAAC,aAAU,KAAK,cAAe,GAAG,YAAY;AAAA,IACvD;AAAA,EACF;AAEA,SAAO;AACT;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
package/dist/esm/index.mjs
DELETED
package/dist/esm/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
|
-
}
|