@tamagui/focusable 1.61.2 → 1.62.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.
Files changed (35) hide show
  1. package/dist/cjs/focusable.js +3 -6
  2. package/dist/cjs/focusable.js.map +1 -1
  3. package/dist/cjs/focusable.native.js +15 -0
  4. package/dist/cjs/focusable.native.js.map +6 -0
  5. package/dist/cjs/focusableInputHOC.js +17 -46
  6. package/dist/cjs/focusableInputHOC.js.map +1 -1
  7. package/dist/cjs/focusableInputHOC.native.js +69 -0
  8. package/dist/cjs/focusableInputHOC.native.js.map +6 -0
  9. package/dist/cjs/index.js +4 -8
  10. package/dist/cjs/index.js.map +1 -1
  11. package/dist/cjs/index.native.js +24 -0
  12. package/dist/cjs/index.native.js.map +6 -0
  13. package/dist/cjs/registerFocusable.js +7 -13
  14. package/dist/cjs/registerFocusable.js.map +1 -1
  15. package/dist/cjs/registerFocusable.native.js +11 -31
  16. package/dist/cjs/registerFocusable.native.js.map +1 -1
  17. package/dist/esm/focusableInputHOC.js +12 -33
  18. package/dist/esm/focusableInputHOC.js.map +1 -1
  19. package/dist/esm/registerFocusable.js +2 -4
  20. package/dist/esm/registerFocusable.js.map +1 -1
  21. package/dist/jsx/focusable.native.js +1 -0
  22. package/dist/jsx/focusable.native.js.map +6 -0
  23. package/dist/jsx/focusableInputHOC.js +11 -29
  24. package/dist/jsx/focusableInputHOC.js.map +1 -1
  25. package/dist/jsx/focusableInputHOC.native.js +50 -0
  26. package/dist/jsx/focusableInputHOC.native.js.map +6 -0
  27. package/dist/jsx/index.native.js +4 -0
  28. package/dist/jsx/index.native.js.map +6 -0
  29. package/dist/jsx/registerFocusable.js +2 -4
  30. package/dist/jsx/registerFocusable.js.map +1 -1
  31. package/dist/jsx/registerFocusable.native.js +6 -23
  32. package/dist/jsx/registerFocusable.native.js.map +1 -1
  33. package/package.json +4 -4
  34. package/dist/esm/registerFocusable.native.js +0 -35
  35. package/dist/esm/registerFocusable.native.js.map +0 -6
@@ -1,17 +1,14 @@
1
- "use strict";
2
1
  var __defProp = Object.defineProperty;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
5
  var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
6
+ if (from && typeof from == "object" || typeof from == "function")
8
7
  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
- }
8
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
9
  return to;
13
10
  };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
11
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
15
12
  var focusable_exports = {};
16
13
  module.exports = __toCommonJS(focusable_exports);
17
14
  //# sourceMappingURL=focusable.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/focusable.ts"],
4
- "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
4
+ "mappings": ";;;;;;;;;;;AAAA;AAAA;",
5
5
  "names": []
6
6
  }
@@ -0,0 +1,15 @@
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
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ return to;
11
+ };
12
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
13
+ var focusable_exports = {};
14
+ module.exports = __toCommonJS(focusable_exports);
15
+ //# sourceMappingURL=focusable.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/focusable.ts"],
4
+ "mappings": ";;;;;;;;;;;;AAAA;AAAA;",
5
+ "names": []
6
+ }
@@ -1,88 +1,59 @@
1
- "use strict";
2
1
  var __defProp = Object.defineProperty;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
5
  var __export = (target, all) => {
7
6
  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") {
7
+ __defProp(target, name, { get: all[name], enumerable: !0 });
8
+ }, __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from == "object" || typeof from == "function")
12
10
  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
- }
11
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
12
  return to;
17
13
  };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
19
15
  var focusableInputHOC_exports = {};
20
16
  __export(focusableInputHOC_exports, {
21
17
  focusableInputHOC: () => focusableInputHOC,
22
18
  useFocusable: () => useFocusable
23
19
  });
24
20
  module.exports = __toCommonJS(focusableInputHOC_exports);
25
- var import_jsx_runtime = require("react/jsx-runtime");
26
- var import_compose_refs = require("@tamagui/compose-refs");
27
- var import_web = require("@tamagui/web");
28
- var import_react = require("react");
29
- var import_registerFocusable = require("./registerFocusable");
21
+ var import_compose_refs = require("@tamagui/compose-refs"), import_web = require("@tamagui/web"), import_react = require("react"), import_registerFocusable = require("./registerFocusable"), import_jsx_runtime = require("react/jsx-runtime");
30
22
  function useFocusable({
31
23
  isInput,
32
24
  props,
33
25
  ref
34
26
  }) {
35
- const { id, onChangeText, value, defaultValue } = props;
36
- const inputValue = (0, import_react.useRef)(value || defaultValue || "");
37
- const unregisterFocusable = (0, import_react.useRef)();
38
- const inputRef = (0, import_react.useCallback)(
27
+ const { id, onChangeText, value, defaultValue } = props, inputValue = (0, import_react.useRef)(value || defaultValue || ""), unregisterFocusable = (0, import_react.useRef)(), inputRef = (0, import_react.useCallback)(
39
28
  (input) => {
40
- var _a;
41
- if (!id)
42
- return;
43
- if (!input)
44
- return;
45
- (_a = unregisterFocusable.current) == null ? void 0 : _a.call(unregisterFocusable);
46
- unregisterFocusable.current = (0, import_registerFocusable.registerFocusable)(id, {
29
+ id && input && (unregisterFocusable.current?.(), unregisterFocusable.current = (0, import_registerFocusable.registerFocusable)(id, {
47
30
  focus: input.focus,
48
31
  ...isInput && {
49
32
  // react-native doesn't support programmatic .select()
50
33
  focusAndSelect() {
51
- input.focus();
52
- if (input.setSelection && typeof inputValue.current === "string") {
53
- input.setSelection(0, inputValue.current.length);
54
- }
34
+ input.focus(), input.setSelection && typeof inputValue.current == "string" && input.setSelection(0, inputValue.current.length);
55
35
  }
56
36
  }
57
- });
37
+ }));
58
38
  },
59
39
  [isInput, id]
60
- );
61
- const combinedRefs = (0, import_compose_refs.composeRefs)(ref, inputRef);
62
- (0, import_react.useEffect)(() => {
63
- return () => {
64
- var _a;
65
- (_a = unregisterFocusable.current) == null ? void 0 : _a.call(unregisterFocusable);
66
- };
67
- }, []);
68
- return {
40
+ ), combinedRefs = (0, import_compose_refs.composeRefs)(ref, inputRef);
41
+ return (0, import_react.useEffect)(() => () => {
42
+ unregisterFocusable.current?.();
43
+ }, []), {
69
44
  ref: combinedRefs,
70
45
  onChangeText: (0, import_web.useEvent)((value2) => {
71
- inputValue.current = value2;
72
- onChangeText == null ? void 0 : onChangeText(value2);
46
+ inputValue.current = value2, onChangeText?.(value2);
73
47
  })
74
48
  };
75
49
  }
76
50
  function focusableInputHOC(Component) {
77
51
  return Component.styleable((props, ref) => {
78
- var _a;
79
- const isInput = (_a = Component.staticConfig) == null ? void 0 : _a.isInput;
80
- const { ref: combinedRef, onChangeText } = useFocusable({
52
+ const isInput = Component.staticConfig?.isInput, { ref: combinedRef, onChangeText } = useFocusable({
81
53
  ref,
82
54
  props,
83
55
  isInput
84
- });
85
- const finalProps = isInput ? {
56
+ }), finalProps = isInput ? {
86
57
  ...props,
87
58
  onChangeText
88
59
  } : props;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/focusableInputHOC.tsx"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiFW;AAjFX,0BAA4B;AAC5B,iBAA2C;AAC3C,mBAAsD;AAEtD,+BAAkC;AAS3B,SAAS,aAAa;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AACF,GAIG;AACD,QAAM,EAAE,IAAI,cAAc,OAAO,aAAa,IAAI;AAClD,QAAM,iBAAa,qBAAO,SAAS,gBAAgB,EAAE;AACrD,QAAM,0BAAsB,qBAA+B;AAE3D,QAAM,eAAW;AAAA,IACf,CAAC,UAAU;AA3Bf;AA4BM,UAAI,CAAC;AAAI;AACT,UAAI,CAAC;AAAO;AACZ,gCAAoB,YAApB;AACA,0BAAoB,cAAU,4CAAkB,IAAI;AAAA,QAClD,OAAO,MAAM;AAAA,QAEb,GAAI,WAAW;AAAA;AAAA,UAEb,iBAAiB;AACf,kBAAM,MAAM;AACZ,gBAAI,MAAM,gBAAgB,OAAO,WA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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,mBAAe,iCAAY,KAAK,QAAQ;AAE9C,qCAAU,MACD,MAAM;AACX,wBAAoB,UAAU;AAAA,EAChC,GACC,CAAC,CAAC,GAEE;AAAA,IACL,KAAK;AAAA,IACL,kBAAc,qBAAS,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,4CAAC,aAAU,KAAK,aAAc,GAAG,YAAY;AAAA,EACtD,CAAC;AACH;",
5
5
  "names": ["value"]
6
6
  }
@@ -0,0 +1,69 @@
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: !0 });
9
+ }, __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from == "object" || typeof from == "function")
11
+ for (let key of __getOwnPropNames(from))
12
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ return to;
14
+ };
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
16
+ var focusableInputHOC_exports = {};
17
+ __export(focusableInputHOC_exports, {
18
+ focusableInputHOC: () => focusableInputHOC,
19
+ useFocusable: () => useFocusable
20
+ });
21
+ module.exports = __toCommonJS(focusableInputHOC_exports);
22
+ var import_compose_refs = require("@tamagui/compose-refs"), import_web = require("@tamagui/web"), import_react = require("react"), import_registerFocusable = require("./registerFocusable"), import_jsx_runtime = require("react/jsx-runtime");
23
+ function useFocusable({
24
+ isInput,
25
+ props,
26
+ ref
27
+ }) {
28
+ const { id, onChangeText, value, defaultValue } = props, inputValue = (0, import_react.useRef)(value || defaultValue || ""), unregisterFocusable = (0, import_react.useRef)(), inputRef = (0, import_react.useCallback)(
29
+ (input) => {
30
+ id && input && (unregisterFocusable.current?.(), unregisterFocusable.current = (0, import_registerFocusable.registerFocusable)(id, {
31
+ focus: input.focus,
32
+ ...isInput && {
33
+ // react-native doesn't support programmatic .select()
34
+ focusAndSelect() {
35
+ input.focus(), input.setSelection && typeof inputValue.current == "string" && input.setSelection(0, inputValue.current.length);
36
+ }
37
+ }
38
+ }));
39
+ },
40
+ [isInput, id]
41
+ ), combinedRefs = (0, import_compose_refs.composeRefs)(ref, inputRef);
42
+ return (0, import_react.useEffect)(() => () => {
43
+ unregisterFocusable.current?.();
44
+ }, []), {
45
+ ref: combinedRefs,
46
+ onChangeText: (0, import_web.useEvent)((value2) => {
47
+ inputValue.current = value2, onChangeText?.(value2);
48
+ })
49
+ };
50
+ }
51
+ function focusableInputHOC(Component) {
52
+ return Component.styleable((props, ref) => {
53
+ const isInput = Component.staticConfig?.isInput, { ref: combinedRef, onChangeText } = useFocusable({
54
+ ref,
55
+ props,
56
+ isInput
57
+ }), finalProps = isInput ? {
58
+ ...props,
59
+ onChangeText
60
+ } : props;
61
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { ref: combinedRef, ...finalProps });
62
+ });
63
+ }
64
+ // Annotate the CommonJS export names for ESM import in node:
65
+ 0 && (module.exports = {
66
+ focusableInputHOC,
67
+ useFocusable
68
+ });
69
+ //# sourceMappingURL=focusableInputHOC.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/focusableInputHOC.tsx"],
4
+ "mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAA4B,kCAC5B,aAA2C,yBAC3C,eAAsD,kBAEtD,2BAAkC,gCA6EvB;AApEJ,SAAS,aAAa;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AACF,GAIG;AACD,QAAM,EAAE,IAAI,cAAc,OAAO,aAAa,IAAI,OAC5C,iBAAa,qBAAO,SAAS,gBAAgB,EAAE,GAC/C,0BAAsB,qBAA+B,GAErD,eAAW;AAAA,IACf,CAAC,UAAU;AACT,MAAK,MACA,UACL,oBAAoB,UAAU,GAC9B,oBAAoB,cAAU,4CAAkB,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,mBAAe,iCAAY,KAAK,QAAQ;AAE9C,qCAAU,MACD,MAAM;AACX,wBAAoB,UAAU;AAAA,EAChC,GACC,CAAC,CAAC,GAEE;AAAA,IACL,KAAK;AAAA,IACL,kBAAc,qBAAS,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,4CAAC,aAAU,KAAK,aAAc,GAAG,YAAY;AAAA,EACtD,CAAC;AACH;",
5
+ "names": ["value"]
6
+ }
package/dist/cjs/index.js CHANGED
@@ -1,18 +1,14 @@
1
- "use strict";
2
1
  var __defProp = Object.defineProperty;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
5
  var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
6
+ if (from && typeof from == "object" || typeof from == "function")
8
7
  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
- }
8
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
9
  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);
10
+ }, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
11
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
16
12
  var src_exports = {};
17
13
  module.exports = __toCommonJS(src_exports);
18
14
  __reExport(src_exports, require("./registerFocusable"), module.exports);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,gCAAd;AACA,wBAAc,gCADd;AAEA,wBAAc,wBAFd;",
4
+ "mappings": ";;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,gCAAd;AACA,wBAAc,gCADd;AAEA,wBAAc,wBAFd;",
5
5
  "names": []
6
6
  }
@@ -0,0 +1,24 @@
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
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ return to;
11
+ }, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
12
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
13
+ var src_exports = {};
14
+ module.exports = __toCommonJS(src_exports);
15
+ __reExport(src_exports, require("./registerFocusable"), module.exports);
16
+ __reExport(src_exports, require("./focusableInputHOC"), module.exports);
17
+ __reExport(src_exports, require("./focusable"), module.exports);
18
+ // Annotate the CommonJS export names for ESM import in node:
19
+ 0 && (module.exports = {
20
+ ...require("./registerFocusable"),
21
+ ...require("./focusableInputHOC"),
22
+ ...require("./focusable")
23
+ });
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "mappings": ";;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,gCAAd;AACA,wBAAc,gCADd;AAEA,wBAAc,wBAFd;",
5
+ "names": []
6
+ }
@@ -1,21 +1,17 @@
1
- "use strict";
2
1
  var __defProp = Object.defineProperty;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
5
  var __export = (target, all) => {
7
6
  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") {
7
+ __defProp(target, name, { get: all[name], enumerable: !0 });
8
+ }, __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from == "object" || typeof from == "function")
12
10
  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
- }
11
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
12
  return to;
17
13
  };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
19
15
  var registerFocusable_exports = {};
20
16
  __export(registerFocusable_exports, {
21
17
  focusFocusable: () => focusFocusable,
@@ -24,10 +20,8 @@ __export(registerFocusable_exports, {
24
20
  });
25
21
  module.exports = __toCommonJS(registerFocusable_exports);
26
22
  const registerFocusable = (id, input) => () => {
27
- };
28
- const unregisterFocusable = (id) => {
29
- };
30
- const focusFocusable = (id) => {
23
+ }, unregisterFocusable = (id) => {
24
+ }, focusFocusable = (id) => {
31
25
  };
32
26
  // Annotate the CommonJS export names for ESM import in node:
33
27
  0 && (module.exports = {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/registerFocusable.ts"],
4
- "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;",
4
+ "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,MAAM,oBAAoB,CAAC,IAAY,UAAqB,MAAM;AAEzE,GAEa,sBAAsB,CAAC,OAAe;AAEnD,GAEa,iBAAiB,CAAC,OAAe;AAE9C;",
5
5
  "names": []
6
6
  }
@@ -5,17 +5,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
6
  var __export = (target, all) => {
7
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") {
8
+ __defProp(target, name, { get: all[name], enumerable: !0 });
9
+ }, __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from == "object" || typeof from == "function")
12
11
  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
- }
12
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
13
  return to;
17
14
  };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
19
16
  var registerFocusable_native_exports = {};
20
17
  __export(registerFocusable_native_exports, {
21
18
  focusFocusable: () => focusFocusable,
@@ -23,34 +20,17 @@ __export(registerFocusable_native_exports, {
23
20
  unregisterFocusable: () => unregisterFocusable
24
21
  });
25
22
  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) => {
23
+ 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), () => {
39
24
  InputsMap.delete(id);
40
- };
41
- const focusFocusable = (id, select = false) => {
25
+ }), unregisterFocusable = (id) => {
26
+ InputsMap.delete(id);
27
+ }, focusFocusable = (id, select = !1) => {
42
28
  const input = InputsMap.get(id);
43
29
  if (!input) {
44
- if (process.env.NODE_ENV === "development") {
45
- console.warn("No input found for id", id);
46
- }
30
+ process.env.NODE_ENV === "development" && console.warn("No input found for id", id);
47
31
  return;
48
32
  }
49
- if (select || !input.focusAndSelect) {
50
- input.focus();
51
- } else {
52
- input.focusAndSelect();
53
- }
33
+ select || !input.focusAndSelect ? input.focus() : input.focusAndSelect();
54
34
  };
55
35
  // Annotate the CommonJS export names for ESM import in node:
56
36
  0 && (module.exports = {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/registerFocusable.native.ts"],
4
- "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;AACrB,cAAQ,KAAK,oCAAoC,EAAE,EAAE;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;",
4
+ "mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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
5
  "names": []
6
6
  }
@@ -1,64 +1,43 @@
1
- import { jsx } from "react/jsx-runtime";
2
1
  import { composeRefs } from "@tamagui/compose-refs";
3
2
  import { useEvent } from "@tamagui/web";
4
3
  import { useCallback, useEffect, useRef } from "react";
5
4
  import { registerFocusable } from "./registerFocusable";
5
+ import { jsx } from "react/jsx-runtime";
6
6
  function useFocusable({
7
7
  isInput,
8
8
  props,
9
9
  ref
10
10
  }) {
11
- const { id, onChangeText, value, defaultValue } = props;
12
- const inputValue = useRef(value || defaultValue || "");
13
- const unregisterFocusable = useRef();
14
- const inputRef = useCallback(
11
+ const { id, onChangeText, value, defaultValue } = props, inputValue = useRef(value || defaultValue || ""), unregisterFocusable = useRef(), inputRef = useCallback(
15
12
  (input) => {
16
- var _a;
17
- if (!id)
18
- return;
19
- if (!input)
20
- return;
21
- (_a = unregisterFocusable.current) == null ? void 0 : _a.call(unregisterFocusable);
22
- unregisterFocusable.current = registerFocusable(id, {
13
+ id && input && (unregisterFocusable.current?.(), unregisterFocusable.current = registerFocusable(id, {
23
14
  focus: input.focus,
24
15
  ...isInput && {
25
16
  // react-native doesn't support programmatic .select()
26
17
  focusAndSelect() {
27
- input.focus();
28
- if (input.setSelection && typeof inputValue.current === "string") {
29
- input.setSelection(0, inputValue.current.length);
30
- }
18
+ input.focus(), input.setSelection && typeof inputValue.current == "string" && input.setSelection(0, inputValue.current.length);
31
19
  }
32
20
  }
33
- });
21
+ }));
34
22
  },
35
23
  [isInput, id]
36
- );
37
- const combinedRefs = composeRefs(ref, inputRef);
38
- useEffect(() => {
39
- return () => {
40
- var _a;
41
- (_a = unregisterFocusable.current) == null ? void 0 : _a.call(unregisterFocusable);
42
- };
43
- }, []);
44
- return {
24
+ ), combinedRefs = composeRefs(ref, inputRef);
25
+ return useEffect(() => () => {
26
+ unregisterFocusable.current?.();
27
+ }, []), {
45
28
  ref: combinedRefs,
46
29
  onChangeText: useEvent((value2) => {
47
- inputValue.current = value2;
48
- onChangeText == null ? void 0 : onChangeText(value2);
30
+ inputValue.current = value2, onChangeText?.(value2);
49
31
  })
50
32
  };
51
33
  }
52
34
  function focusableInputHOC(Component) {
53
35
  return Component.styleable((props, ref) => {
54
- var _a;
55
- const isInput = (_a = Component.staticConfig) == null ? void 0 : _a.isInput;
56
- const { ref: combinedRef, onChangeText } = useFocusable({
36
+ const isInput = Component.staticConfig?.isInput, { ref: combinedRef, onChangeText } = useFocusable({
57
37
  ref,
58
38
  props,
59
39
  isInput
60
- });
61
- const finalProps = isInput ? {
40
+ }), finalProps = isInput ? {
62
41
  ...props,
63
42
  onChangeText
64
43
  } : props;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/focusableInputHOC.tsx"],
4
- "mappings": "AAiFW;AAjFX,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;AA3Bf;AA4BM,UAAI,CAAC;AAAI;AACT,UAAI,CAAC;AAAO;AACZ,gCAAoB,YAApB;AACA,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;AAnDjB;AAoDM,gCAAoB,YAApB;AAAA,IACF;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO;AAAA,IACL,KAAK;AAAA,IACL,cAAc,SAAS,CAACA,WAAU;AAChC,iBA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S,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
5
  "names": ["value"]
6
6
  }
@@ -1,8 +1,6 @@
1
1
  const registerFocusable = (id, input) => () => {
2
- };
3
- const unregisterFocusable = (id) => {
4
- };
5
- const focusFocusable = (id) => {
2
+ }, unregisterFocusable = (id) => {
3
+ }, focusFocusable = (id) => {
6
4
  };
7
5
  export {
8
6
  focusFocusable,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/registerFocusable.ts"],
4
- "mappings": "AAEO,MAAM,oBAAoB,CAAC,IAAY,UAAqB,MAAM;AAEzE;AAEO,MAAM,sBAAsB,CAAC,OAAe;AAEnD;AAEO,MAAM,iBAAiB,CAAC,OAAe;AAE9C;",
4
+ "mappings": "AAEO,MAAM,oBAAoB,CAAC,IAAY,UAAqB,MAAM;AAEzE,GAEa,sBAAsB,CAAC,OAAe;AAEnD,GAEa,iBAAiB,CAAC,OAAe;AAE9C;",
5
5
  "names": []
6
6
  }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=focusable.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "mappings": "",
5
+ "names": []
6
+ }
@@ -7,54 +7,36 @@ function useFocusable({
7
7
  props,
8
8
  ref
9
9
  }) {
10
- const { id, onChangeText, value, defaultValue } = props;
11
- const inputValue = useRef(value || defaultValue || "");
12
- const unregisterFocusable = useRef();
13
- const inputRef = useCallback(
10
+ const { id, onChangeText, value, defaultValue } = props, inputValue = useRef(value || defaultValue || ""), unregisterFocusable = useRef(), inputRef = useCallback(
14
11
  (input) => {
15
- if (!id)
16
- return;
17
- if (!input)
18
- return;
19
- unregisterFocusable.current?.();
20
- unregisterFocusable.current = registerFocusable(id, {
12
+ id && input && (unregisterFocusable.current?.(), unregisterFocusable.current = registerFocusable(id, {
21
13
  focus: input.focus,
22
14
  ...isInput && {
23
15
  // react-native doesn't support programmatic .select()
24
16
  focusAndSelect() {
25
- input.focus();
26
- if (input.setSelection && typeof inputValue.current === "string") {
27
- input.setSelection(0, inputValue.current.length);
28
- }
17
+ input.focus(), input.setSelection && typeof inputValue.current == "string" && input.setSelection(0, inputValue.current.length);
29
18
  }
30
19
  }
31
- });
20
+ }));
32
21
  },
33
22
  [isInput, id]
34
- );
35
- const combinedRefs = composeRefs(ref, inputRef);
36
- useEffect(() => {
37
- return () => {
38
- unregisterFocusable.current?.();
39
- };
40
- }, []);
41
- return {
23
+ ), combinedRefs = composeRefs(ref, inputRef);
24
+ return useEffect(() => () => {
25
+ unregisterFocusable.current?.();
26
+ }, []), {
42
27
  ref: combinedRefs,
43
28
  onChangeText: useEvent((value2) => {
44
- inputValue.current = value2;
45
- onChangeText?.(value2);
29
+ inputValue.current = value2, onChangeText?.(value2);
46
30
  })
47
31
  };
48
32
  }
49
33
  function focusableInputHOC(Component) {
50
34
  return Component.styleable((props, ref) => {
51
- const isInput = Component.staticConfig?.isInput;
52
- const { ref: combinedRef, onChangeText } = useFocusable({
35
+ const isInput = Component.staticConfig?.isInput, { ref: combinedRef, onChangeText } = useFocusable({
53
36
  ref,
54
37
  props,
55
38
  isInput
56
- });
57
- const finalProps = isInput ? {
39
+ }), finalProps = isInput ? {
58
40
  ...props,
59
41
  onChangeText
60
42
  } : props;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["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AA,MACE,GAAG;AAAA,MACH;AAAA,IACF,IACA;AAGJ,WAAO,CAAC,UAAU,KAAK,iBAAiB,YAAY;AAAA,EACtD,CAAC;AACH;",
5
5
  "names": ["value"]
6
6
  }
@@ -0,0 +1,50 @@
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, inputValue = useRef(value || defaultValue || ""), unregisterFocusable = useRef(), inputRef = useCallback(
11
+ (input) => {
12
+ id && input && (unregisterFocusable.current?.(), unregisterFocusable.current = registerFocusable(id, {
13
+ focus: input.focus,
14
+ ...isInput && {
15
+ // react-native doesn't support programmatic .select()
16
+ focusAndSelect() {
17
+ input.focus(), input.setSelection && typeof inputValue.current == "string" && input.setSelection(0, inputValue.current.length);
18
+ }
19
+ }
20
+ }));
21
+ },
22
+ [isInput, id]
23
+ ), combinedRefs = composeRefs(ref, inputRef);
24
+ return useEffect(() => () => {
25
+ unregisterFocusable.current?.();
26
+ }, []), {
27
+ ref: combinedRefs,
28
+ onChangeText: useEvent((value2) => {
29
+ inputValue.current = value2, onChangeText?.(value2);
30
+ })
31
+ };
32
+ }
33
+ function focusableInputHOC(Component) {
34
+ return Component.styleable((props, ref) => {
35
+ const isInput = Component.staticConfig?.isInput, { ref: combinedRef, onChangeText } = useFocusable({
36
+ ref,
37
+ props,
38
+ isInput
39
+ }), finalProps = isInput ? {
40
+ ...props,
41
+ onChangeText
42
+ } : props;
43
+ return <Component ref={combinedRef} {...finalProps} />;
44
+ });
45
+ }
46
+ export {
47
+ focusableInputHOC,
48
+ useFocusable
49
+ };
50
+ //# sourceMappingURL=focusableInputHOC.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/focusableInputHOC.tsx"],
4
+ "mappings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 -0,0 +1,4 @@
1
+ export * from "./registerFocusable";
2
+ export * from "./focusableInputHOC";
3
+ export * from "./focusable";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;",
5
+ "names": []
6
+ }
@@ -1,8 +1,6 @@
1
1
  const registerFocusable = (id, input) => () => {
2
- };
3
- const unregisterFocusable = (id) => {
4
- };
5
- const focusFocusable = (id) => {
2
+ }, unregisterFocusable = (id) => {
3
+ }, focusFocusable = (id) => {
6
4
  };
7
5
  export {
8
6
  focusFocusable,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/registerFocusable.ts"],
4
- "mappings": "AAEO,MAAM,oBAAoB,CAAC,IAAY,UAAqB,MAAM;AAEzE;AAEO,MAAM,sBAAsB,CAAC,OAAe;AAEnD;AAEO,MAAM,iBAAiB,CAAC,OAAe;AAE9C;",
4
+ "mappings": "AAEO,MAAM,oBAAoB,CAAC,IAAY,UAAqB,MAAM;AAEzE,GAEa,sBAAsB,CAAC,OAAe;AAEnD,GAEa,iBAAiB,CAAC,OAAe;AAE9C;",
5
5
  "names": []
6
6
  }
@@ -1,31 +1,14 @@
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) => {
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), () => {
14
2
  InputsMap.delete(id);
15
- };
16
- const focusFocusable = (id, select = false) => {
3
+ }), unregisterFocusable = (id) => {
4
+ InputsMap.delete(id);
5
+ }, focusFocusable = (id, select = !1) => {
17
6
  const input = InputsMap.get(id);
18
7
  if (!input) {
19
- if (process.env.NODE_ENV === "development") {
20
- console.warn("No input found for id", id);
21
- }
8
+ process.env.NODE_ENV === "development" && console.warn("No input found for id", id);
22
9
  return;
23
10
  }
24
- if (select || !input.focusAndSelect) {
25
- input.focus();
26
- } else {
27
- input.focusAndSelect();
28
- }
11
+ select || !input.focusAndSelect ? input.focus() : input.focusAndSelect();
29
12
  };
30
13
  export {
31
14
  focusFocusable,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
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,EAAE,EAAE;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;",
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
5
  "names": []
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/focusable",
3
- "version": "1.61.2",
3
+ "version": "1.62.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.61.2",
26
- "@tamagui/web": "1.61.2"
25
+ "@tamagui/compose-refs": "1.62.0",
26
+ "@tamagui/web": "1.62.0"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "react": "*"
30
30
  },
31
31
  "devDependencies": {
32
- "@tamagui/build": "1.61.2",
32
+ "@tamagui/build": "1.62.0",
33
33
  "react": "^18.2.0"
34
34
  },
35
35
  "publishConfig": {
@@ -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.js.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,EAAE,EAAE;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
- }