@tamagui/focusable 1.15.14 → 1.15.16

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.
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/focusable.ts"],
4
- "sourcesContent": ["export type Focusable = { focus: Function; focusAndSelect?: Function }\n"],
5
4
  "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
6
5
  "names": []
7
6
  }
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/focusableInputHOC.tsx"],
4
- "sourcesContent": ["import { composeRefs } from '@tamagui/compose-refs'\nimport { TamaguiComponent, isTamaguiComponent, useEvent } from '@tamagui/web'\nimport { forwardRef, useCallback, useEffect, useRef } from 'react'\n\nimport { registerFocusable } from './registerFocusable'\n\nexport function focusableInputHOC<A extends TamaguiComponent>(Component: A): A {\n const component = Component.extractable(\n forwardRef(\n (\n props: {\n id?: string\n onChangeText?: (val: string) => void\n value?: string\n defaultValue?: string\n },\n ref\n ) => {\n const isInput = isTamaguiComponent(Component) && Component.staticConfig.isInput\n const inputValue = useRef(props.value || props.defaultValue || '')\n const unregisterFocusable = useRef<() => void | undefined>()\n\n const inputRef = useCallback(\n (input) => {\n if (!props.id) return\n if (!input) return\n unregisterFocusable.current?.()\n unregisterFocusable.current = registerFocusable(props.id, {\n focus: input.focus,\n\n ...(isInput && {\n // react-native doesn't support programmatic .select()\n focusAndSelect() {\n input.focus()\n if (input.setSelection && typeof inputValue.current === 'string') {\n input.setSelection(0, inputValue.current.length)\n }\n },\n }),\n })\n },\n [isInput, props.id]\n )\n\n const combinedRefs = composeRefs(ref, inputRef)\n\n useEffect(() => {\n return () => {\n unregisterFocusable.current?.()\n }\n }, [])\n\n const onChangeText = useEvent((value) => {\n inputValue.current = value\n props.onChangeText?.(value)\n })\n\n const finalProps = isInput\n ? {\n ...props,\n onChangeText,\n }\n : props\n\n // @ts-expect-error\n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CAAC,aAAU,KAAK,cAAe,GAAG,YAAY;AAAA,MACvD;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;",
6
5
  "names": []
7
6
  }
package/dist/cjs/index.js CHANGED
@@ -18,4 +18,10 @@ module.exports = __toCommonJS(src_exports);
18
18
  __reExport(src_exports, require("./registerFocusable"), module.exports);
19
19
  __reExport(src_exports, require("./focusableInputHOC"), module.exports);
20
20
  __reExport(src_exports, require("./focusable"), module.exports);
21
+ // Annotate the CommonJS export names for ESM import in node:
22
+ 0 && (module.exports = {
23
+ ...require("./registerFocusable"),
24
+ ...require("./focusableInputHOC"),
25
+ ...require("./focusable")
26
+ });
21
27
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "sourcesContent": ["export * from './registerFocusable'\nexport * from './focusableInputHOC'\nexport * from './focusable'\n"],
5
4
  "mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,gCAAd;AACA,wBAAc,gCADd;AAEA,wBAAc,wBAFd;",
6
5
  "names": []
7
6
  }
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/registerFocusable.ts"],
4
- "sourcesContent": ["import { Focusable } from './focusable'\n\nexport const registerFocusable = (id: string, input: Focusable) => () => {\n // noop focus is handed natively\n}\n\nexport const unregisterFocusable = (id: string) => {\n // noop focus is handed natively\n}\n\nexport const focusFocusable = (id: string) => {\n // noop focus is handed natively\n}\n"],
5
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;",
6
5
  "names": []
7
6
  }
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/registerFocusable.native.ts"],
4
- "sourcesContent": ["// used for focusing on native\n\nimport { Focusable } from './focusable'\n\nconst InputsMap = new Map<string, Focusable>()\n\nexport const registerFocusable = (id: string, input: Focusable) => {\n if (process.env.NODE_ENV === 'development') {\n if (InputsMap.has(id)) {\n // eslint-disable-next-line no-console\n console.warn(`Warning, duplicate ID for input: ${id}`)\n }\n }\n InputsMap.set(id, input)\n return () => {\n InputsMap.delete(id)\n }\n}\n\nexport const unregisterFocusable = (id: string) => {\n InputsMap.delete(id)\n}\n\nexport const focusFocusable = (id: string, select = false) => {\n const input = InputsMap.get(id)\n if (!input) {\n if (process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.warn('No input found for id', id)\n }\n return\n }\n if (select || !input.focusAndSelect) {\n input.focus()\n } else {\n input.focusAndSelect()\n }\n}\n"],
5
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;AAErB,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;AAE1C,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;",
6
5
  "names": []
7
6
  }
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": [],
4
- "sourcesContent": [],
5
4
  "mappings": "",
6
5
  "names": []
7
6
  }
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": [],
4
- "sourcesContent": [],
5
4
  "mappings": "",
6
5
  "names": []
7
6
  }
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/focusableInputHOC.tsx"],
4
- "sourcesContent": ["import { composeRefs } from '@tamagui/compose-refs'\nimport { TamaguiComponent, isTamaguiComponent, useEvent } from '@tamagui/web'\nimport { forwardRef, useCallback, useEffect, useRef } from 'react'\n\nimport { registerFocusable } from './registerFocusable'\n\nexport function focusableInputHOC<A extends TamaguiComponent>(Component: A): A {\n const component = Component.extractable(\n forwardRef(\n (\n props: {\n id?: string\n onChangeText?: (val: string) => void\n value?: string\n defaultValue?: string\n },\n ref\n ) => {\n const isInput = isTamaguiComponent(Component) && Component.staticConfig.isInput\n const inputValue = useRef(props.value || props.defaultValue || '')\n const unregisterFocusable = useRef<() => void | undefined>()\n\n const inputRef = useCallback(\n (input) => {\n if (!props.id) return\n if (!input) return\n unregisterFocusable.current?.()\n unregisterFocusable.current = registerFocusable(props.id, {\n focus: input.focus,\n\n ...(isInput && {\n // react-native doesn't support programmatic .select()\n focusAndSelect() {\n input.focus()\n if (input.setSelection && typeof inputValue.current === 'string') {\n input.setSelection(0, inputValue.current.length)\n }\n },\n }),\n })\n },\n [isInput, props.id]\n )\n\n const combinedRefs = composeRefs(ref, inputRef)\n\n useEffect(() => {\n return () => {\n unregisterFocusable.current?.()\n }\n }, [])\n\n const onChangeText = useEvent((value) => {\n inputValue.current = value\n props.onChangeText?.(value)\n })\n\n const finalProps = isInput\n ? {\n ...props,\n onChangeText,\n }\n : props\n\n // @ts-expect-error\n return <Component ref={combinedRefs}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G,YAAY;AAAA,MACvD;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;",
6
5
  "names": []
7
6
  }
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/focusableInputHOC.tsx"],
4
- "sourcesContent": ["import { composeRefs } from '@tamagui/compose-refs'\nimport { TamaguiComponent, isTamaguiComponent, useEvent } from '@tamagui/web'\nimport { forwardRef, useCallback, useEffect, useRef } from 'react'\n\nimport { registerFocusable } from './registerFocusable'\n\nexport function focusableInputHOC<A extends TamaguiComponent>(Component: A): A {\n const component = Component.extractable(\n forwardRef(\n (\n props: {\n id?: string\n onChangeText?: (val: string) => void\n value?: string\n defaultValue?: string\n },\n ref\n ) => {\n const isInput = isTamaguiComponent(Component) && Component.staticConfig.isInput\n const inputValue = useRef(props.value || props.defaultValue || '')\n const unregisterFocusable = useRef<() => void | undefined>()\n\n const inputRef = useCallback(\n (input) => {\n if (!props.id) return\n if (!input) return\n unregisterFocusable.current?.()\n unregisterFocusable.current = registerFocusable(props.id, {\n focus: input.focus,\n\n ...(isInput && {\n // react-native doesn't support programmatic .select()\n focusAndSelect() {\n input.focus()\n if (input.setSelection && typeof inputValue.current === 'string') {\n input.setSelection(0, inputValue.current.length)\n }\n },\n }),\n })\n },\n [isInput, props.id]\n )\n\n const combinedRefs = composeRefs(ref, inputRef)\n\n useEffect(() => {\n return () => {\n unregisterFocusable.current?.()\n }\n }, [])\n\n const onChangeText = useEvent((value) => {\n inputValue.current = value\n props.onChangeText?.(value)\n })\n\n const finalProps = isInput\n ? {\n ...props,\n onChangeText,\n }\n : props\n\n // @ts-expect-error\n return <Component ref={combinedRefs} {...finalProps} />\n }\n )\n ) as any\n\n return component\n}\n"],
5
4
  "mappings": "AAiEe;AAjEf,SAAS,mBAAmB;AAC5B,SAA2B,oBAAoB,gBAAgB;AAC/D,SAAS,YAAY,aAAa,WAAW,cAAc;AAE3D,SAAS,yBAAyB;AAE3B,SAAS,kBAA8C,WAAiB;AAC7E,QAAM,YAAY,UAAU;AAAA,IAC1B;AAAA,MACE,CACE,OAMA,QACG;AACH,cAAM,UAAU,mBAAmB,SAAS,KAAK,UAAU,aAAa;AACxE,cAAM,aAAa,OAAO,MAAM,SAAS,MAAM,gBAAgB,EAAE;AACjE,cAAM,sBAAsB,OAA+B;AAE3D,cAAM,WAAW;AAAA,UACf,CAAC,UAAU;AAvBrB;AAwBY,gBAAI,CAAC,MAAM;AAAI;AACf,gBAAI,CAAC;AAAO;AACZ,sCAAoB,YAApB;AACA,gCAAoB,UAAU,kBAAkB,MAAM,IAAI;AAAA,cACxD,OAAO,MAAM;AAAA,cAEb,GAAI,WAAW;AAAA;AAAA,gBAEb,iBAAiB;AACf,wBAAM,MAAM;AACZ,sBAAI,MAAM,gBAAgB,OAAO,WAAW,YAAY,UAAU;AAChE,0BAAM,aAAa,GAAG,WAAW,QAAQ,MAAM;AAAA,kBACjD;AAAA,gBACF;AAAA,cACF;AAAA,YACF,CAAC;AAAA,UACH;AAAA,UACA,CAAC,SAAS,MAAM,EAAE;AAAA,QACpB;AAEA,cAAM,eAAe,YAAY,KAAK,QAAQ;AAE9C,kBAAU,MAAM;AACd,iBAAO,MAAM;AA/CvB;AAgDY,sCAAoB,YAApB;AAAA,UACF;AAAA,QACF,GAAG,CAAC,CAAC;AAEL,cAAM,eAAe,SAAS,CAAC,UAAU;AApDjD;AAqDU,qBAAW,UAAU;AACrB,sBAAM,iBAAN,+BAAqB;AAAA,QACvB,CAAC;AAED,cAAM,aAAa,UACf;AAAA,UACE,GAAG;AAAA,UACH;AAAA,QACF,IACA;AAGJ,eAAO,oBAAC,aAAU,KAAK,cAAe,GAAG,YAAY;AAAA,MACvD;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;",
6
5
  "names": []
7
6
  }
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "sourcesContent": ["export * from './registerFocusable'\nexport * from './focusableInputHOC'\nexport * from './focusable'\n"],
5
4
  "mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;",
6
5
  "names": []
7
6
  }
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "sourcesContent": ["export * from './registerFocusable'\nexport * from './focusableInputHOC'\nexport * from './focusable'\n"],
5
4
  "mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;",
6
5
  "names": []
7
6
  }
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/registerFocusable.ts"],
4
- "sourcesContent": ["import { Focusable } from './focusable'\n\nexport const registerFocusable = (id: string, input: Focusable) => () => {\n // noop focus is handed natively\n}\n\nexport const unregisterFocusable = (id: string) => {\n // noop focus is handed natively\n}\n\nexport const focusFocusable = (id: string) => {\n // noop focus is handed natively\n}\n"],
5
4
  "mappings": "AAEO,MAAM,oBAAoB,CAAC,IAAY,UAAqB,MAAM;AAEzE;AAEO,MAAM,sBAAsB,CAAC,OAAe;AAEnD;AAEO,MAAM,iBAAiB,CAAC,OAAe;AAE9C;",
6
5
  "names": []
7
6
  }
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/registerFocusable.ts"],
4
- "sourcesContent": ["import { Focusable } from './focusable'\n\nexport const registerFocusable = (id: string, input: Focusable) => () => {\n // noop focus is handed natively\n}\n\nexport const unregisterFocusable = (id: string) => {\n // noop focus is handed natively\n}\n\nexport const focusFocusable = (id: string) => {\n // noop focus is handed natively\n}\n"],
5
4
  "mappings": "AAEO,MAAM,oBAAoB,CAAC,IAAY,UAAqB,MAAM;AAEzE;AAEO,MAAM,sBAAsB,CAAC,OAAe;AAEnD;AAEO,MAAM,iBAAiB,CAAC,OAAe;AAE9C;",
6
5
  "names": []
7
6
  }
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/registerFocusable.native.ts"],
4
- "sourcesContent": ["// used for focusing on native\n\nimport { Focusable } from './focusable'\n\nconst InputsMap = new Map<string, Focusable>()\n\nexport const registerFocusable = (id: string, input: Focusable) => {\n if (process.env.NODE_ENV === 'development') {\n if (InputsMap.has(id)) {\n // eslint-disable-next-line no-console\n console.warn(`Warning, duplicate ID for input: ${id}`)\n }\n }\n InputsMap.set(id, input)\n return () => {\n InputsMap.delete(id)\n }\n}\n\nexport const unregisterFocusable = (id: string) => {\n InputsMap.delete(id)\n}\n\nexport const focusFocusable = (id: string, select = false) => {\n const input = InputsMap.get(id)\n if (!input) {\n if (process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.warn('No input found for id', id)\n }\n return\n }\n if (select || !input.focusAndSelect) {\n input.focus()\n } else {\n input.focusAndSelect()\n }\n}\n"],
5
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;AAErB,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;AAE1C,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;",
6
5
  "names": []
7
6
  }
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/registerFocusable.native.ts"],
4
- "sourcesContent": ["// used for focusing on native\n\nimport { Focusable } from './focusable'\n\nconst InputsMap = new Map<string, Focusable>()\n\nexport const registerFocusable = (id: string, input: Focusable) => {\n if (process.env.NODE_ENV === 'development') {\n if (InputsMap.has(id)) {\n // eslint-disable-next-line no-console\n console.warn(`Warning, duplicate ID for input: ${id}`)\n }\n }\n InputsMap.set(id, input)\n return () => {\n InputsMap.delete(id)\n }\n}\n\nexport const unregisterFocusable = (id: string) => {\n InputsMap.delete(id)\n}\n\nexport const focusFocusable = (id: string, select = false) => {\n const input = InputsMap.get(id)\n if (!input) {\n if (process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.warn('No input found for id', id)\n }\n return\n }\n if (select || !input.focusAndSelect) {\n input.focus()\n } else {\n input.focusAndSelect()\n }\n}\n"],
5
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;AAErB,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;AAE1C,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;",
6
5
  "names": []
7
6
  }
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": [],
4
- "sourcesContent": [],
5
4
  "mappings": "",
6
5
  "names": []
7
6
  }
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": [],
4
- "sourcesContent": [],
5
4
  "mappings": "",
6
5
  "names": []
7
6
  }
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/focusableInputHOC.tsx"],
4
- "sourcesContent": ["import { composeRefs } from '@tamagui/compose-refs'\nimport { TamaguiComponent, isTamaguiComponent, useEvent } from '@tamagui/web'\nimport { forwardRef, useCallback, useEffect, useRef } from 'react'\n\nimport { registerFocusable } from './registerFocusable'\n\nexport function focusableInputHOC<A extends TamaguiComponent>(Component: A): A {\n const component = Component.extractable(\n forwardRef(\n (\n props: {\n id?: string\n onChangeText?: (val: string) => void\n value?: string\n defaultValue?: string\n },\n ref\n ) => {\n const isInput = isTamaguiComponent(Component) && Component.staticConfig.isInput\n const inputValue = useRef(props.value || props.defaultValue || '')\n const unregisterFocusable = useRef<() => void | undefined>()\n\n const inputRef = useCallback(\n (input) => {\n if (!props.id) return\n if (!input) return\n unregisterFocusable.current?.()\n unregisterFocusable.current = registerFocusable(props.id, {\n focus: input.focus,\n\n ...(isInput && {\n // react-native doesn't support programmatic .select()\n focusAndSelect() {\n input.focus()\n if (input.setSelection && typeof inputValue.current === 'string') {\n input.setSelection(0, inputValue.current.length)\n }\n },\n }),\n })\n },\n [isInput, props.id]\n )\n\n const combinedRefs = composeRefs(ref, inputRef)\n\n useEffect(() => {\n return () => {\n unregisterFocusable.current?.()\n }\n }, [])\n\n const onChangeText = useEvent((value) => {\n inputValue.current = value\n props.onChangeText?.(value)\n })\n\n const finalProps = isInput\n ? {\n ...props,\n onChangeText,\n }\n : props\n\n // @ts-expect-error\n return <Component ref={combinedRefs} {...finalProps} />\n }\n )\n ) as any\n\n return component\n}\n"],
5
4
  "mappings": "AAA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
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/focusableInputHOC.tsx"],
4
- "sourcesContent": ["import { composeRefs } from '@tamagui/compose-refs'\nimport { TamaguiComponent, isTamaguiComponent, useEvent } from '@tamagui/web'\nimport { forwardRef, useCallback, useEffect, useRef } from 'react'\n\nimport { registerFocusable } from './registerFocusable'\n\nexport function focusableInputHOC<A extends TamaguiComponent>(Component: A): A {\n const component = Component.extractable(\n forwardRef(\n (\n props: {\n id?: string\n onChangeText?: (val: string) => void\n value?: string\n defaultValue?: string\n },\n ref\n ) => {\n const isInput = isTamaguiComponent(Component) && Component.staticConfig.isInput\n const inputValue = useRef(props.value || props.defaultValue || '')\n const unregisterFocusable = useRef<() => void | undefined>()\n\n const inputRef = useCallback(\n (input) => {\n if (!props.id) return\n if (!input) return\n unregisterFocusable.current?.()\n unregisterFocusable.current = registerFocusable(props.id, {\n focus: input.focus,\n\n ...(isInput && {\n // react-native doesn't support programmatic .select()\n focusAndSelect() {\n input.focus()\n if (input.setSelection && typeof inputValue.current === 'string') {\n input.setSelection(0, inputValue.current.length)\n }\n },\n }),\n })\n },\n [isInput, props.id]\n )\n\n const combinedRefs = composeRefs(ref, inputRef)\n\n useEffect(() => {\n return () => {\n unregisterFocusable.current?.()\n }\n }, [])\n\n const onChangeText = useEvent((value) => {\n inputValue.current = value\n props.onChangeText?.(value)\n })\n\n const finalProps = isInput\n ? {\n ...props,\n onChangeText,\n }\n : props\n\n // @ts-expect-error\n return <Component ref={combinedRefs} {...finalProps} />\n }\n )\n ) as any\n\n return component\n}\n"],
5
4
  "mappings": "AAAA,SAAS,mBAAmB;AAC5B,SAA2B,oBAAoB,gBAAgB;AAC/D,SAAS,YAAY,aAAa,WAAW,cAAc;AAE3D,SAAS,yBAAyB;AAE3B,SAAS,kBAA8C,WAAiB;AAC7E,QAAM,YAAY,UAAU;AAAA,IAC1B;AAAA,MACE,CACE,OAMA,QACG;AACH,cAAM,UAAU,mBAAmB,SAAS,KAAK,UAAU,aAAa;AACxE,cAAM,aAAa,OAAO,MAAM,SAAS,MAAM,gBAAgB,EAAE;AACjE,cAAM,sBAAsB,OAA+B;AAE3D,cAAM,WAAW;AAAA,UACf,CAAC,UAAU;AACT,gBAAI,CAAC,MAAM;AAAI;AACf,gBAAI,CAAC;AAAO;AACZ,gCAAoB,UAAU;AAC9B,gCAAoB,UAAU,kBAAkB,MAAM,IAAI;AAAA,cACxD,OAAO,MAAM;AAAA,cAEb,GAAI,WAAW;AAAA;AAAA,gBAEb,iBAAiB;AACf,wBAAM,MAAM;AACZ,sBAAI,MAAM,gBAAgB,OAAO,WAAW,YAAY,UAAU;AAChE,0BAAM,aAAa,GAAG,WAAW,QAAQ,MAAM;AAAA,kBACjD;AAAA,gBACF;AAAA,cACF;AAAA,YACF,CAAC;AAAA,UACH;AAAA,UACA,CAAC,SAAS,MAAM,EAAE;AAAA,QACpB;AAEA,cAAM,eAAe,YAAY,KAAK,QAAQ;AAE9C,kBAAU,MAAM;AACd,iBAAO,MAAM;AACX,gCAAoB,UAAU;AAAA,UAChC;AAAA,QACF,GAAG,CAAC,CAAC;AAEL,cAAM,eAAe,SAAS,CAAC,UAAU;AACvC,qBAAW,UAAU;AACrB,gBAAM,eAAe,KAAK;AAAA,QAC5B,CAAC;AAED,cAAM,aAAa,UACf;AAAA,UACE,GAAG;AAAA,UACH;AAAA,QACF,IACA;AAGJ,eAAO,CAAC,UAAU,KAAK,kBAAkB,YAAY;AAAA,MACvD;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;",
6
5
  "names": []
7
6
  }
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "sourcesContent": ["export * from './registerFocusable'\nexport * from './focusableInputHOC'\nexport * from './focusable'\n"],
5
4
  "mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;",
6
5
  "names": []
7
6
  }
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "sourcesContent": ["export * from './registerFocusable'\nexport * from './focusableInputHOC'\nexport * from './focusable'\n"],
5
4
  "mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;",
6
5
  "names": []
7
6
  }
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/registerFocusable.ts"],
4
- "sourcesContent": ["import { Focusable } from './focusable'\n\nexport const registerFocusable = (id: string, input: Focusable) => () => {\n // noop focus is handed natively\n}\n\nexport const unregisterFocusable = (id: string) => {\n // noop focus is handed natively\n}\n\nexport const focusFocusable = (id: string) => {\n // noop focus is handed natively\n}\n"],
5
4
  "mappings": "AAEO,MAAM,oBAAoB,CAAC,IAAY,UAAqB,MAAM;AAEzE;AAEO,MAAM,sBAAsB,CAAC,OAAe;AAEnD;AAEO,MAAM,iBAAiB,CAAC,OAAe;AAE9C;",
6
5
  "names": []
7
6
  }
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/registerFocusable.ts"],
4
- "sourcesContent": ["import { Focusable } from './focusable'\n\nexport const registerFocusable = (id: string, input: Focusable) => () => {\n // noop focus is handed natively\n}\n\nexport const unregisterFocusable = (id: string) => {\n // noop focus is handed natively\n}\n\nexport const focusFocusable = (id: string) => {\n // noop focus is handed natively\n}\n"],
5
4
  "mappings": "AAEO,MAAM,oBAAoB,CAAC,IAAY,UAAqB,MAAM;AAEzE;AAEO,MAAM,sBAAsB,CAAC,OAAe;AAEnD;AAEO,MAAM,iBAAiB,CAAC,OAAe;AAE9C;",
6
5
  "names": []
7
6
  }
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/registerFocusable.native.ts"],
4
- "sourcesContent": ["// used for focusing on native\n\nimport { Focusable } from './focusable'\n\nconst InputsMap = new Map<string, Focusable>()\n\nexport const registerFocusable = (id: string, input: Focusable) => {\n if (process.env.NODE_ENV === 'development') {\n if (InputsMap.has(id)) {\n // eslint-disable-next-line no-console\n console.warn(`Warning, duplicate ID for input: ${id}`)\n }\n }\n InputsMap.set(id, input)\n return () => {\n InputsMap.delete(id)\n }\n}\n\nexport const unregisterFocusable = (id: string) => {\n InputsMap.delete(id)\n}\n\nexport const focusFocusable = (id: string, select = false) => {\n const input = InputsMap.get(id)\n if (!input) {\n if (process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.warn('No input found for id', id)\n }\n return\n }\n if (select || !input.focusAndSelect) {\n input.focus()\n } else {\n input.focusAndSelect()\n }\n}\n"],
5
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;AAErB,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;AAE1C,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;",
6
5
  "names": []
7
6
  }
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/registerFocusable.native.ts"],
4
- "sourcesContent": ["// used for focusing on native\n\nimport { Focusable } from './focusable'\n\nconst InputsMap = new Map<string, Focusable>()\n\nexport const registerFocusable = (id: string, input: Focusable) => {\n if (process.env.NODE_ENV === 'development') {\n if (InputsMap.has(id)) {\n // eslint-disable-next-line no-console\n console.warn(`Warning, duplicate ID for input: ${id}`)\n }\n }\n InputsMap.set(id, input)\n return () => {\n InputsMap.delete(id)\n }\n}\n\nexport const unregisterFocusable = (id: string) => {\n InputsMap.delete(id)\n}\n\nexport const focusFocusable = (id: string, select = false) => {\n const input = InputsMap.get(id)\n if (!input) {\n if (process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.warn('No input found for id', id)\n }\n return\n }\n if (select || !input.focusAndSelect) {\n input.focus()\n } else {\n input.focusAndSelect()\n }\n}\n"],
5
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;AAErB,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;AAE1C,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;",
6
5
  "names": []
7
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/focusable",
3
- "version": "1.15.14",
3
+ "version": "1.15.16",
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.15.14",
26
- "@tamagui/web": "1.15.14"
25
+ "@tamagui/compose-refs": "1.15.16",
26
+ "@tamagui/web": "1.15.16"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "react": "*"
30
30
  },
31
31
  "devDependencies": {
32
- "@tamagui/build": "1.15.14",
32
+ "@tamagui/build": "1.15.16",
33
33
  "react": "^18.2.0"
34
34
  },
35
35
  "publishConfig": {