@tamagui/focusable 1.114.4 → 1.115.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.
@@ -0,0 +1,16 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
7
+ get: () => from[key],
8
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
9
+ });
10
+ return to;
11
+ };
12
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
13
+ value: !0
14
+ }), mod);
15
+ var focusable_exports = {};
16
+ module.exports = __toCommonJS(focusable_exports);
@@ -2,56 +2,73 @@ var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __getProtoOf = Object.getPrototypeOf,
6
+ __hasOwnProp = Object.prototype.hasOwnProperty;
6
7
  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
- };
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: !0
11
+ });
12
+ },
13
+ __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ return to;
19
+ };
15
20
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
21
  // If the importer is in node compatibility mode or this is not an ESM
17
22
  // file that has been converted to a CommonJS file using a Babel-
18
23
  // compatible transform (i.e. "__esModule" has not been set), then set
19
24
  // "default" to the CommonJS "module.exports" for node compatibility.
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
- mod
22
- )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
+ value: mod,
27
+ enumerable: !0
28
+ }) : target, mod)),
29
+ __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
+ value: !0
31
+ }), mod);
23
32
  var focusableInputHOC_exports = {};
24
33
  __export(focusableInputHOC_exports, {
25
34
  useFocusable: () => useFocusable
26
35
  });
27
36
  module.exports = __toCommonJS(focusableInputHOC_exports);
28
- var import_compose_refs = require("@tamagui/compose-refs"), import_web = require("@tamagui/web"), import_react = __toESM(require("react")), import_registerFocusable = require("./registerFocusable");
37
+ var import_compose_refs = require("@tamagui/compose-refs"),
38
+ import_web = require("@tamagui/web"),
39
+ import_react = __toESM(require("react")),
40
+ import_registerFocusable = require("./registerFocusable.cjs");
29
41
  function useFocusable({
30
42
  isInput,
31
43
  props,
32
44
  ref
33
45
  }) {
34
- const { id, onChangeText, value, defaultValue } = props, inputValue = import_react.default.useRef(value || defaultValue || ""), unregisterFocusable = import_react.default.useRef(), inputRef = import_react.default.useCallback(
35
- (input) => {
46
+ const {
47
+ id,
48
+ onChangeText,
49
+ value,
50
+ defaultValue
51
+ } = props,
52
+ inputValue = import_react.default.useRef(value || defaultValue || ""),
53
+ unregisterFocusable = import_react.default.useRef(),
54
+ inputRef = import_react.default.useCallback(input => {
36
55
  id && input && (unregisterFocusable.current?.(), unregisterFocusable.current = (0, import_registerFocusable.registerFocusable)(id, {
37
56
  focus: input.focus,
38
- ...isInput && {
57
+ ...(isInput && {
39
58
  // react-native doesn't support programmatic .select()
40
59
  focusAndSelect() {
41
60
  input.focus(), input.setSelection && typeof inputValue.current == "string" && input.setSelection(0, inputValue.current.length);
42
61
  }
43
- }
62
+ })
44
63
  }));
45
- },
46
- [isInput, id]
47
- ), combinedRefs = (0, import_compose_refs.composeRefs)(ref, inputRef);
64
+ }, [isInput, id]),
65
+ combinedRefs = (0, import_compose_refs.composeRefs)(ref, inputRef);
48
66
  return import_react.default.useEffect(() => () => {
49
67
  unregisterFocusable.current?.();
50
68
  }, []), {
51
69
  ref: combinedRefs,
52
- onChangeText: (0, import_web.useEvent)((value2) => {
70
+ onChangeText: (0, import_web.useEvent)(value2 => {
53
71
  inputValue.current = value2, onChangeText?.(value2);
54
72
  })
55
73
  };
56
- }
57
- //# sourceMappingURL=focusableInputHOC.js.map
74
+ }
@@ -0,0 +1,20 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
7
+ get: () => from[key],
8
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
9
+ });
10
+ return to;
11
+ },
12
+ __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
13
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
14
+ value: !0
15
+ }), mod);
16
+ var src_exports = {};
17
+ module.exports = __toCommonJS(src_exports);
18
+ __reExport(src_exports, require("./registerFocusable.cjs"), module.exports);
19
+ __reExport(src_exports, require("./focusableInputHOC.cjs"), module.exports);
20
+ __reExport(src_exports, require("./focusable.cjs"), module.exports);
@@ -0,0 +1,30 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: !0
9
+ });
10
+ },
11
+ __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
13
+ get: () => from[key],
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ return to;
17
+ };
18
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
+ value: !0
20
+ }), mod);
21
+ var registerFocusable_exports = {};
22
+ __export(registerFocusable_exports, {
23
+ focusFocusable: () => focusFocusable,
24
+ registerFocusable: () => registerFocusable,
25
+ unregisterFocusable: () => unregisterFocusable
26
+ });
27
+ module.exports = __toCommonJS(registerFocusable_exports);
28
+ const registerFocusable = (id, input) => () => {},
29
+ unregisterFocusable = id => {},
30
+ focusFocusable = id => {};
@@ -0,0 +1,42 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: !0
9
+ });
10
+ },
11
+ __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
13
+ get: () => from[key],
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ return to;
17
+ };
18
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
+ value: !0
20
+ }), mod);
21
+ var registerFocusable_native_exports = {};
22
+ __export(registerFocusable_native_exports, {
23
+ focusFocusable: () => focusFocusable,
24
+ registerFocusable: () => registerFocusable,
25
+ unregisterFocusable: () => unregisterFocusable
26
+ });
27
+ module.exports = __toCommonJS(registerFocusable_native_exports);
28
+ const InputsMap = /* @__PURE__ */new Map(),
29
+ registerFocusable = (id, input) => (process.env.NODE_ENV === "development" && InputsMap.has(id) && console.warn(`Warning, duplicate ID for input: ${id}`), InputsMap.set(id, input), () => {
30
+ InputsMap.delete(id);
31
+ }),
32
+ unregisterFocusable = id => {
33
+ InputsMap.delete(id);
34
+ },
35
+ focusFocusable = (id, select = !1) => {
36
+ const input = InputsMap.get(id);
37
+ if (!input) {
38
+ process.env.NODE_ENV === "development" && console.warn("No input found for id", id);
39
+ return;
40
+ }
41
+ select || !input.focusAndSelect ? input.focus() : input.focusAndSelect();
42
+ };
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/registerFocusable.native.ts"],
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
+ "names": []
6
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/focusable",
3
- "version": "1.114.4",
3
+ "version": "1.115.0",
4
4
  "sideEffects": false,
5
5
  "source": "src/index.ts",
6
6
  "types": "./types/index.d.ts",
@@ -28,15 +28,16 @@
28
28
  "react-native": "./dist/cjs/index.native.js",
29
29
  "types": "./types/index.d.ts",
30
30
  "import": "./dist/esm/index.mjs",
31
- "require": "./dist/cjs/index.js"
31
+ "require": "./dist/cjs/index.cjs",
32
+ "default": "./dist/cjs/index.native.js"
32
33
  }
33
34
  },
34
35
  "dependencies": {
35
- "@tamagui/compose-refs": "1.114.4",
36
- "@tamagui/web": "1.114.4"
36
+ "@tamagui/compose-refs": "1.115.0",
37
+ "@tamagui/web": "1.115.0"
37
38
  },
38
39
  "devDependencies": {
39
- "@tamagui/build": "1.114.4",
40
+ "@tamagui/build": "1.115.0",
40
41
  "react": "^18.2.0 || ^19.0.0"
41
42
  },
42
43
  "publishConfig": {
@@ -1,14 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from == "object" || typeof from == "function")
7
- for (let key of __getOwnPropNames(from))
8
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
9
- return to;
10
- };
11
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
12
- var focusable_exports = {};
13
- module.exports = __toCommonJS(focusable_exports);
14
- //# sourceMappingURL=focusable.js.map
package/dist/cjs/index.js DELETED
@@ -1,17 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from == "object" || typeof from == "function")
7
- for (let key of __getOwnPropNames(from))
8
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
9
- return to;
10
- }, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
11
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
12
- var src_exports = {};
13
- module.exports = __toCommonJS(src_exports);
14
- __reExport(src_exports, require("./registerFocusable"), module.exports);
15
- __reExport(src_exports, require("./focusableInputHOC"), module.exports);
16
- __reExport(src_exports, require("./focusable"), module.exports);
17
- //# sourceMappingURL=index.js.map
@@ -1,26 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: !0 });
8
- }, __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from == "object" || typeof from == "function")
10
- for (let key of __getOwnPropNames(from))
11
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
15
- var registerFocusable_exports = {};
16
- __export(registerFocusable_exports, {
17
- focusFocusable: () => focusFocusable,
18
- registerFocusable: () => registerFocusable,
19
- unregisterFocusable: () => unregisterFocusable
20
- });
21
- module.exports = __toCommonJS(registerFocusable_exports);
22
- const registerFocusable = (id, input) => () => {
23
- }, unregisterFocusable = (id) => {
24
- }, focusFocusable = (id) => {
25
- };
26
- //# sourceMappingURL=registerFocusable.js.map
File without changes