react-simplikit 0.0.51 → 0.0.53

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 (280) hide show
  1. package/README.md +34 -24
  2. package/dist/components/ImpressionArea/ImpressionArea.cjs +57 -0
  3. package/{esm/components/ImpressionArea/index.d.ts → dist/components/ImpressionArea/ImpressionArea.d.cts} +9 -8
  4. package/dist/components/ImpressionArea/ImpressionArea.d.mts +48 -0
  5. package/dist/components/ImpressionArea/ImpressionArea.mjs +57 -0
  6. package/dist/components/ImpressionArea/index.d.cts +2 -46
  7. package/dist/components/ImpressionArea/index.d.mts +3 -0
  8. package/dist/components/Separated/Separated.cjs +38 -0
  9. package/{esm/components/Separated/index.d.ts → dist/components/Separated/Separated.d.cts} +7 -7
  10. package/dist/components/Separated/Separated.d.mts +38 -0
  11. package/dist/components/Separated/Separated.mjs +38 -0
  12. package/dist/components/Separated/index.d.cts +2 -37
  13. package/dist/components/Separated/index.d.mts +3 -0
  14. package/dist/components/SwitchCase/SwitchCase.cjs +40 -0
  15. package/{esm/components/SwitchCase/index.d.ts → dist/components/SwitchCase/SwitchCase.d.cts} +7 -8
  16. package/dist/components/SwitchCase/SwitchCase.d.mts +45 -0
  17. package/dist/components/SwitchCase/SwitchCase.mjs +40 -0
  18. package/dist/components/SwitchCase/index.d.cts +2 -45
  19. package/dist/components/SwitchCase/index.d.mts +3 -0
  20. package/dist/hooks/useAsyncEffect/index.d.cts +2 -24
  21. package/dist/hooks/useAsyncEffect/index.d.mts +3 -0
  22. package/dist/hooks/useAsyncEffect/useAsyncEffect.cjs +39 -0
  23. package/{esm/hooks/useAsyncEffect/index.d.ts → dist/hooks/useAsyncEffect/useAsyncEffect.d.cts} +4 -3
  24. package/dist/hooks/useAsyncEffect/useAsyncEffect.d.mts +26 -0
  25. package/dist/hooks/useAsyncEffect/useAsyncEffect.mjs +39 -0
  26. package/dist/hooks/useBooleanState/useBooleanState.cjs +36 -0
  27. package/dist/hooks/useBooleanState/{index.d.cts → useBooleanState.d.cts} +4 -2
  28. package/{esm/hooks/useBooleanState/index.d.ts → dist/hooks/useBooleanState/useBooleanState.d.mts} +4 -2
  29. package/dist/hooks/useBooleanState/useBooleanState.mjs +36 -0
  30. package/dist/hooks/useCallbackOncePerRender/index.d.cts +2 -39
  31. package/dist/hooks/useCallbackOncePerRender/index.d.mts +3 -0
  32. package/dist/hooks/useCallbackOncePerRender/useCallbackOncePerRender.cjs +52 -0
  33. package/{esm/hooks/useCallbackOncePerRender/index.d.ts → dist/hooks/useCallbackOncePerRender/useCallbackOncePerRender.d.cts} +4 -3
  34. package/dist/hooks/useCallbackOncePerRender/useCallbackOncePerRender.d.mts +41 -0
  35. package/dist/hooks/useCallbackOncePerRender/useCallbackOncePerRender.mjs +52 -0
  36. package/dist/hooks/useConditionalEffect/index.d.cts +2 -42
  37. package/dist/hooks/useConditionalEffect/index.d.mts +3 -0
  38. package/dist/hooks/useConditionalEffect/useConditionalEffect.cjs +57 -0
  39. package/{esm/hooks/useConditionalEffect/index.d.ts → dist/hooks/useConditionalEffect/useConditionalEffect.d.cts} +4 -3
  40. package/dist/hooks/useConditionalEffect/useConditionalEffect.d.mts +44 -0
  41. package/dist/hooks/useConditionalEffect/useConditionalEffect.mjs +57 -0
  42. package/dist/hooks/useControlledState/index.d.cts +2 -50
  43. package/dist/hooks/useControlledState/index.d.mts +3 -0
  44. package/dist/hooks/useControlledState/useControlledState.cjs +60 -0
  45. package/{esm/hooks/useControlledState/index.d.ts → dist/hooks/useControlledState/useControlledState.d.cts} +11 -10
  46. package/dist/hooks/useControlledState/useControlledState.d.mts +52 -0
  47. package/dist/hooks/useControlledState/useControlledState.mjs +60 -0
  48. package/dist/hooks/useCounter/useCounter.cjs +75 -0
  49. package/{esm/hooks/useCounter/index.d.ts → dist/hooks/useCounter/useCounter.d.cts} +12 -10
  50. package/dist/hooks/useCounter/{index.d.cts → useCounter.d.mts} +12 -10
  51. package/dist/hooks/useCounter/useCounter.mjs +75 -0
  52. package/dist/hooks/useDebounce/debounce.cjs +49 -0
  53. package/dist/hooks/useDebounce/debounce.d.cts +8 -0
  54. package/dist/hooks/useDebounce/debounce.d.mts +8 -0
  55. package/dist/hooks/useDebounce/debounce.mjs +49 -0
  56. package/dist/hooks/useDebounce/useDebounce.cjs +66 -0
  57. package/{esm/hooks/useDebounce/index.d.ts → dist/hooks/useDebounce/useDebounce.d.cts} +6 -8
  58. package/dist/hooks/useDebounce/{index.d.cts → useDebounce.d.mts} +6 -8
  59. package/dist/hooks/useDebounce/useDebounce.mjs +66 -0
  60. package/dist/hooks/useDebouncedCallback/useDebouncedCallback.cjs +62 -0
  61. package/{esm/hooks/useDebouncedCallback/index.d.ts → dist/hooks/useDebouncedCallback/useDebouncedCallback.d.cts} +9 -7
  62. package/dist/hooks/useDebouncedCallback/{index.d.cts → useDebouncedCallback.d.mts} +9 -7
  63. package/dist/hooks/useDebouncedCallback/useDebouncedCallback.mjs +62 -0
  64. package/dist/hooks/useDoubleClick/index.d.cts +2 -45
  65. package/dist/hooks/useDoubleClick/index.d.mts +3 -0
  66. package/dist/hooks/useDoubleClick/useDoubleClick.cjs +64 -0
  67. package/{esm/hooks/useDoubleClick/index.d.ts → dist/hooks/useDoubleClick/useDoubleClick.d.cts} +8 -7
  68. package/dist/hooks/useDoubleClick/useDoubleClick.d.mts +47 -0
  69. package/dist/hooks/useDoubleClick/useDoubleClick.mjs +64 -0
  70. package/dist/hooks/useGeolocation/useGeolocation.cjs +210 -0
  71. package/{esm/hooks/useGeolocation/index.d.ts → dist/hooks/useGeolocation/useGeolocation.d.cts} +26 -24
  72. package/dist/hooks/useGeolocation/{index.d.cts → useGeolocation.d.mts} +26 -24
  73. package/dist/hooks/useGeolocation/useGeolocation.mjs +209 -0
  74. package/dist/hooks/useImpressionRef/useImpressionRef.cjs +67 -0
  75. package/{esm/hooks/useImpressionRef/index.d.ts → dist/hooks/useImpressionRef/useImpressionRef.d.cts} +10 -8
  76. package/dist/hooks/useImpressionRef/{index.d.cts → useImpressionRef.d.mts} +10 -8
  77. package/dist/hooks/useImpressionRef/useImpressionRef.mjs +67 -0
  78. package/dist/hooks/useInputState/index.d.cts +2 -22
  79. package/dist/hooks/useInputState/index.d.mts +3 -0
  80. package/dist/hooks/useInputState/useInputState.cjs +32 -0
  81. package/{esm/hooks/useInputState/index.d.ts → dist/hooks/useInputState/useInputState.d.cts} +4 -3
  82. package/dist/hooks/useInputState/useInputState.d.mts +24 -0
  83. package/dist/hooks/useInputState/useInputState.mjs +32 -0
  84. package/dist/hooks/useIntersectionObserver/useIntersectionObserver.cjs +58 -0
  85. package/dist/hooks/useIntersectionObserver/{index.d.cts → useIntersectionObserver.d.cts} +4 -2
  86. package/{esm/hooks/useIntersectionObserver/index.d.ts → dist/hooks/useIntersectionObserver/useIntersectionObserver.d.mts} +4 -2
  87. package/dist/hooks/useIntersectionObserver/useIntersectionObserver.mjs +58 -0
  88. package/dist/hooks/useInterval/useInterval.cjs +65 -0
  89. package/dist/hooks/useInterval/{index.d.cts → useInterval.d.cts} +7 -5
  90. package/{esm/hooks/useInterval/index.d.ts → dist/hooks/useInterval/useInterval.d.mts} +7 -5
  91. package/dist/hooks/useInterval/useInterval.mjs +65 -0
  92. package/dist/hooks/useIsClient/useIsClient.cjs +49 -0
  93. package/dist/hooks/useIsClient/{index.d.cts → useIsClient.d.cts} +4 -2
  94. package/{esm/hooks/useIsClient/index.d.ts → dist/hooks/useIsClient/useIsClient.d.mts} +4 -2
  95. package/dist/hooks/useIsClient/useIsClient.mjs +49 -0
  96. package/dist/hooks/useIsomorphicLayoutEffect/index.d.cts +2 -24
  97. package/dist/hooks/useIsomorphicLayoutEffect/index.d.mts +3 -0
  98. package/dist/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.cjs +25 -0
  99. package/{esm/hooks/useIsomorphicLayoutEffect/index.d.ts → dist/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.d.cts} +4 -3
  100. package/dist/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.d.mts +26 -0
  101. package/dist/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.mjs +25 -0
  102. package/dist/hooks/useList/useList.cjs +94 -0
  103. package/{esm/hooks/useList/index.d.ts → dist/hooks/useList/useList.d.cts} +10 -8
  104. package/dist/hooks/useList/{index.d.cts → useList.d.mts} +10 -8
  105. package/dist/hooks/useList/useList.mjs +94 -0
  106. package/dist/hooks/useLoading/useLoading.cjs +61 -0
  107. package/dist/hooks/useLoading/{index.d.cts → useLoading.d.cts} +4 -2
  108. package/{esm/hooks/useLoading/index.d.ts → dist/hooks/useLoading/useLoading.d.mts} +4 -2
  109. package/dist/hooks/useLoading/useLoading.mjs +61 -0
  110. package/dist/hooks/useLongPress/index.d.cts +2 -73
  111. package/dist/hooks/useLongPress/index.d.mts +3 -0
  112. package/dist/hooks/useLongPress/useLongPress.cjs +133 -0
  113. package/{esm/hooks/useLongPress/index.d.ts → dist/hooks/useLongPress/useLongPress.d.cts} +18 -17
  114. package/dist/hooks/useLongPress/useLongPress.d.mts +75 -0
  115. package/dist/hooks/useLongPress/useLongPress.mjs +133 -0
  116. package/dist/hooks/useMap/useMap.cjs +64 -0
  117. package/dist/hooks/useMap/{index.d.cts → useMap.d.cts} +12 -10
  118. package/{esm/hooks/useMap/index.d.ts → dist/hooks/useMap/useMap.d.mts} +12 -10
  119. package/dist/hooks/useMap/useMap.mjs +64 -0
  120. package/dist/hooks/useOutsideClickEffect/useOutsideClickEffect.cjs +51 -0
  121. package/dist/hooks/useOutsideClickEffect/{index.d.cts → useOutsideClickEffect.d.cts} +4 -2
  122. package/{esm/hooks/useOutsideClickEffect/index.d.ts → dist/hooks/useOutsideClickEffect/useOutsideClickEffect.d.mts} +4 -2
  123. package/dist/hooks/useOutsideClickEffect/useOutsideClickEffect.mjs +51 -0
  124. package/dist/hooks/usePreservedCallback/usePreservedCallback.cjs +41 -0
  125. package/dist/hooks/usePreservedCallback/{index.d.cts → usePreservedCallback.d.cts} +4 -2
  126. package/{esm/hooks/usePreservedCallback/index.d.ts → dist/hooks/usePreservedCallback/usePreservedCallback.d.mts} +4 -2
  127. package/dist/hooks/usePreservedCallback/usePreservedCallback.mjs +41 -0
  128. package/dist/hooks/usePreservedReference/usePreservedReference.cjs +55 -0
  129. package/dist/hooks/usePreservedReference/{index.d.cts → usePreservedReference.d.cts} +4 -2
  130. package/{esm/hooks/usePreservedReference/index.d.ts → dist/hooks/usePreservedReference/usePreservedReference.d.mts} +4 -2
  131. package/dist/hooks/usePreservedReference/usePreservedReference.mjs +55 -0
  132. package/dist/hooks/usePrevious/usePrevious.cjs +39 -0
  133. package/{esm/hooks/usePrevious/index.d.ts → dist/hooks/usePrevious/usePrevious.d.cts} +4 -2
  134. package/dist/hooks/usePrevious/{index.d.cts → usePrevious.d.mts} +4 -2
  135. package/dist/hooks/usePrevious/usePrevious.mjs +39 -0
  136. package/dist/hooks/useRefEffect/index.d.cts +2 -30
  137. package/dist/hooks/useRefEffect/index.d.mts +3 -0
  138. package/dist/hooks/useRefEffect/useRefEffect.cjs +42 -0
  139. package/{esm/hooks/useRefEffect/index.d.ts → dist/hooks/useRefEffect/useRefEffect.d.cts} +4 -3
  140. package/dist/hooks/useRefEffect/useRefEffect.d.mts +32 -0
  141. package/dist/hooks/useRefEffect/useRefEffect.mjs +42 -0
  142. package/dist/hooks/useSet/useSet.cjs +79 -0
  143. package/dist/hooks/useSet/{index.d.cts → useSet.d.cts} +9 -7
  144. package/{esm/hooks/useSet/index.d.ts → dist/hooks/useSet/useSet.d.mts} +9 -7
  145. package/dist/hooks/useSet/useSet.mjs +79 -0
  146. package/dist/hooks/useStorageState/index.d.cts +2 -60
  147. package/dist/hooks/useStorageState/index.d.mts +3 -0
  148. package/dist/hooks/useStorageState/storage.cjs +85 -0
  149. package/dist/hooks/useStorageState/storage.d.cts +10 -0
  150. package/dist/hooks/useStorageState/storage.d.mts +10 -0
  151. package/dist/hooks/useStorageState/storage.mjs +80 -0
  152. package/dist/hooks/useStorageState/useStorageState.cjs +81 -0
  153. package/{esm/hooks/useStorageState/index.d.ts → dist/hooks/useStorageState/useStorageState.d.cts} +10 -15
  154. package/dist/hooks/useStorageState/useStorageState.d.mts +56 -0
  155. package/dist/hooks/useStorageState/useStorageState.mjs +81 -0
  156. package/dist/hooks/useThrottle/throttle.cjs +19 -0
  157. package/dist/hooks/useThrottle/throttle.d.cts +19 -0
  158. package/dist/hooks/useThrottle/throttle.d.mts +19 -0
  159. package/dist/hooks/useThrottle/throttle.mjs +19 -0
  160. package/dist/hooks/useThrottle/useThrottle.cjs +49 -0
  161. package/dist/hooks/useThrottle/{index.d.cts → useThrottle.d.cts} +6 -19
  162. package/{esm/hooks/useThrottle/index.d.ts → dist/hooks/useThrottle/useThrottle.d.mts} +6 -19
  163. package/dist/hooks/useThrottle/useThrottle.mjs +49 -0
  164. package/dist/hooks/useThrottledCallback/useThrottledCallback.cjs +65 -0
  165. package/{esm/hooks/useThrottledCallback/index.d.ts → dist/hooks/useThrottledCallback/useThrottledCallback.d.cts} +8 -6
  166. package/dist/hooks/useThrottledCallback/{index.d.cts → useThrottledCallback.d.mts} +8 -6
  167. package/dist/hooks/useThrottledCallback/useThrottledCallback.mjs +65 -0
  168. package/dist/hooks/useTimeout/useTimeout.cjs +40 -0
  169. package/dist/hooks/useTimeout/{index.d.cts → useTimeout.d.cts} +4 -2
  170. package/{esm/hooks/useTimeout/index.d.ts → dist/hooks/useTimeout/useTimeout.d.mts} +4 -2
  171. package/dist/hooks/useTimeout/useTimeout.mjs +40 -0
  172. package/dist/hooks/useToggle/useToggle.cjs +34 -0
  173. package/dist/hooks/useToggle/{index.d.cts → useToggle.d.cts} +4 -4
  174. package/{esm/hooks/useToggle/index.d.ts → dist/hooks/useToggle/useToggle.d.mts} +4 -4
  175. package/dist/hooks/useToggle/useToggle.mjs +34 -0
  176. package/dist/hooks/useVisibilityEvent/useVisibilityEvent.cjs +42 -0
  177. package/{esm/hooks/useVisibilityEvent/index.d.ts → dist/hooks/useVisibilityEvent/useVisibilityEvent.d.cts} +5 -3
  178. package/dist/hooks/useVisibilityEvent/{index.d.cts → useVisibilityEvent.d.mts} +5 -3
  179. package/dist/hooks/useVisibilityEvent/useVisibilityEvent.mjs +42 -0
  180. package/dist/index.cjs +77 -1397
  181. package/dist/index.d.cts +56 -40
  182. package/dist/index.d.mts +56 -0
  183. package/dist/index.mjs +40 -0
  184. package/dist/utils/buildContext/buildContext.cjs +50 -0
  185. package/{esm/utils/buildContext/index.d.ts → dist/utils/buildContext/buildContext.d.cts} +7 -7
  186. package/dist/utils/buildContext/buildContext.d.mts +38 -0
  187. package/dist/utils/buildContext/buildContext.mjs +50 -0
  188. package/dist/utils/buildContext/index.d.cts +2 -37
  189. package/dist/utils/buildContext/index.d.mts +3 -0
  190. package/dist/utils/mergeProps/index.d.cts +2 -25
  191. package/dist/utils/mergeProps/index.d.mts +3 -0
  192. package/dist/utils/mergeProps/mergeProps.cjs +53 -0
  193. package/{esm/utils/mergeProps/index.d.ts → dist/utils/mergeProps/mergeProps.d.cts} +7 -8
  194. package/dist/utils/mergeProps/mergeProps.d.mts +25 -0
  195. package/dist/utils/mergeProps/mergeProps.mjs +53 -0
  196. package/dist/utils/mergeRefs/index.d.cts +2 -38
  197. package/dist/utils/mergeRefs/index.d.mts +3 -0
  198. package/dist/utils/mergeRefs/mergeRefs.cjs +50 -0
  199. package/{esm/utils/mergeRefs/index.d.ts → dist/utils/mergeRefs/mergeRefs.d.cts} +4 -3
  200. package/dist/utils/mergeRefs/mergeRefs.d.mts +40 -0
  201. package/dist/utils/mergeRefs/mergeRefs.mjs +50 -0
  202. package/package.json +9 -11
  203. package/dist/components/ImpressionArea/index.cjs +0 -295
  204. package/dist/components/Separated/index.cjs +0 -41
  205. package/dist/components/SwitchCase/index.cjs +0 -36
  206. package/dist/hooks/useAsyncEffect/index.cjs +0 -49
  207. package/dist/hooks/useBooleanState/index.cjs +0 -46
  208. package/dist/hooks/useCallbackOncePerRender/index.cjs +0 -63
  209. package/dist/hooks/useConditionalEffect/index.cjs +0 -51
  210. package/dist/hooks/useControlledState/index.cjs +0 -57
  211. package/dist/hooks/useCounter/index.cjs +0 -70
  212. package/dist/hooks/useDebounce/index.cjs +0 -130
  213. package/dist/hooks/useDebouncedCallback/index.cjs +0 -148
  214. package/dist/hooks/useDoubleClick/index.cjs +0 -79
  215. package/dist/hooks/useGeolocation/index.cjs +0 -154
  216. package/dist/hooks/useImpressionRef/index.cjs +0 -258
  217. package/dist/hooks/useInputState/index.cjs +0 -46
  218. package/dist/hooks/useIntersectionObserver/index.cjs +0 -95
  219. package/dist/hooks/useInterval/index.cjs +0 -84
  220. package/dist/hooks/useIsClient/index.cjs +0 -40
  221. package/dist/hooks/useIsomorphicLayoutEffect/index.cjs +0 -35
  222. package/dist/hooks/useList/index.cjs +0 -104
  223. package/dist/hooks/useLoading/index.cjs +0 -65
  224. package/dist/hooks/useLongPress/index.cjs +0 -127
  225. package/dist/hooks/useMap/index.cjs +0 -78
  226. package/dist/hooks/useOutsideClickEffect/index.cjs +0 -74
  227. package/dist/hooks/usePreservedCallback/index.cjs +0 -45
  228. package/dist/hooks/usePreservedReference/index.cjs +0 -45
  229. package/dist/hooks/usePrevious/index.cjs +0 -48
  230. package/dist/hooks/useRefEffect/index.cjs +0 -72
  231. package/dist/hooks/useSet/index.cjs +0 -105
  232. package/dist/hooks/useStorageState/index.cjs +0 -196
  233. package/dist/hooks/useThrottle/index.cjs +0 -151
  234. package/dist/hooks/useThrottledCallback/index.cjs +0 -172
  235. package/dist/hooks/useTimeout/index.cjs +0 -57
  236. package/dist/hooks/useToggle/index.cjs +0 -37
  237. package/dist/hooks/useVisibilityEvent/index.cjs +0 -47
  238. package/dist/utils/buildContext/index.cjs +0 -56
  239. package/dist/utils/mergeProps/index.cjs +0 -71
  240. package/dist/utils/mergeRefs/index.cjs +0 -46
  241. package/esm/components/ImpressionArea/index.js +0 -269
  242. package/esm/components/Separated/index.js +0 -15
  243. package/esm/components/SwitchCase/index.js +0 -10
  244. package/esm/hooks/useAsyncEffect/index.js +0 -23
  245. package/esm/hooks/useBooleanState/index.js +0 -20
  246. package/esm/hooks/useCallbackOncePerRender/index.js +0 -37
  247. package/esm/hooks/useConditionalEffect/index.js +0 -25
  248. package/esm/hooks/useControlledState/index.js +0 -31
  249. package/esm/hooks/useCounter/index.js +0 -44
  250. package/esm/hooks/useDebounce/index.js +0 -104
  251. package/esm/hooks/useDebouncedCallback/index.js +0 -122
  252. package/esm/hooks/useDoubleClick/index.js +0 -53
  253. package/esm/hooks/useGeolocation/index.js +0 -128
  254. package/esm/hooks/useImpressionRef/index.js +0 -232
  255. package/esm/hooks/useInputState/index.js +0 -20
  256. package/esm/hooks/useIntersectionObserver/index.js +0 -69
  257. package/esm/hooks/useInterval/index.js +0 -58
  258. package/esm/hooks/useIsClient/index.js +0 -14
  259. package/esm/hooks/useIsomorphicLayoutEffect/index.js +0 -9
  260. package/esm/hooks/useList/index.js +0 -78
  261. package/esm/hooks/useLoading/index.js +0 -39
  262. package/esm/hooks/useLongPress/index.js +0 -101
  263. package/esm/hooks/useMap/index.js +0 -52
  264. package/esm/hooks/useOutsideClickEffect/index.js +0 -48
  265. package/esm/hooks/usePreservedCallback/index.js +0 -19
  266. package/esm/hooks/usePreservedReference/index.js +0 -19
  267. package/esm/hooks/usePrevious/index.js +0 -22
  268. package/esm/hooks/useRefEffect/index.js +0 -46
  269. package/esm/hooks/useSet/index.js +0 -79
  270. package/esm/hooks/useStorageState/index.js +0 -170
  271. package/esm/hooks/useThrottle/index.js +0 -125
  272. package/esm/hooks/useThrottledCallback/index.js +0 -146
  273. package/esm/hooks/useTimeout/index.js +0 -31
  274. package/esm/hooks/useToggle/index.js +0 -11
  275. package/esm/hooks/useVisibilityEvent/index.js +0 -21
  276. package/esm/index.d.ts +0 -40
  277. package/esm/index.js +0 -1335
  278. package/esm/utils/buildContext/index.js +0 -30
  279. package/esm/utils/mergeProps/index.js +0 -45
  280. package/esm/utils/mergeRefs/index.js +0 -20
@@ -1,39 +1,3 @@
1
- import { RefObject, RefCallback } from 'react';
2
1
 
3
- /**
4
- * @description
5
- * This function takes multiple refs (RefObject or RefCallback) and returns a single ref that updates all provided refs.
6
- * It's useful when you need to pass multiple refs to a single element.
7
- *
8
- * @template T - The type of target to be referenced.
9
- *
10
- * @param {Array<RefObject<T> | RefCallback<T> | null | undefined>} refs - An array of refs to be merged. Each ref can be either a RefObject or RefCallback.
11
- *
12
- * @returns {RefCallback<T>} A single ref callback that updates all provided refs.
13
- *
14
- * @example
15
- * forwardRef(function Component(props, parentRef) {
16
- * const myRef = useRef(null);
17
- *
18
- * return <div ref={mergeRefs(myRef, parentRef)} />;
19
- * })
20
- *
21
- * @example
22
- * function Component(props) {
23
- * const ref = useRef(null);
24
- * const [height, setHeight] = useState(0);
25
- *
26
- * const measuredRef = useCallback(node => {
27
- * if(node == null) {
28
- * return;
29
- * }
30
- *
31
- * setHeight(node.offsetHeight);
32
- * }, []);
33
- *
34
- * return <div ref={mergeRefs(measuredRef, ref)} />;
35
- * }
36
- */
37
- declare function mergeRefs<T>(...refs: Array<RefObject<T> | RefCallback<T> | null | undefined>): RefCallback<T>;
38
-
39
- export { mergeRefs };
2
+ import { mergeRefs } from "./mergeRefs.cjs";
3
+ export { mergeRefs };
@@ -0,0 +1,3 @@
1
+
2
+ import { mergeRefs } from "./mergeRefs.mjs";
3
+ export { mergeRefs };
@@ -0,0 +1,50 @@
1
+ "use client";
2
+ //#region src/utils/mergeRefs/mergeRefs.ts
3
+ /**
4
+ * @description
5
+ * This function takes multiple refs (RefObject or RefCallback) and returns a single ref that updates all provided refs.
6
+ * It's useful when you need to pass multiple refs to a single element.
7
+ *
8
+ * @template T - The type of target to be referenced.
9
+ *
10
+ * @param {Array<RefObject<T> | RefCallback<T> | null | undefined>} refs - An array of refs to be merged. Each ref can be either a RefObject or RefCallback.
11
+ *
12
+ * @returns {RefCallback<T>} A single ref callback that updates all provided refs.
13
+ *
14
+ * @example
15
+ * forwardRef(function Component(props, parentRef) {
16
+ * const myRef = useRef(null);
17
+ *
18
+ * return <div ref={mergeRefs(myRef, parentRef)} />;
19
+ * })
20
+ *
21
+ * @example
22
+ * function Component(props) {
23
+ * const ref = useRef(null);
24
+ * const [height, setHeight] = useState(0);
25
+ *
26
+ * const measuredRef = useCallback(node => {
27
+ * if(node == null) {
28
+ * return;
29
+ * }
30
+ *
31
+ * setHeight(node.offsetHeight);
32
+ * }, []);
33
+ *
34
+ * return <div ref={mergeRefs(measuredRef, ref)} />;
35
+ * }
36
+ */
37
+ function mergeRefs(...refs) {
38
+ return (value) => {
39
+ for (const ref of refs) {
40
+ if (ref == null) continue;
41
+ if (typeof ref === "function") {
42
+ ref(value);
43
+ continue;
44
+ }
45
+ ref.current = value;
46
+ }
47
+ };
48
+ }
49
+ //#endregion
50
+ exports.mergeRefs = mergeRefs;
@@ -1,5 +1,6 @@
1
- import { RefObject, RefCallback } from 'react';
2
1
 
2
+ import { RefCallback, RefObject } from "react";
3
+ //#region src/utils/mergeRefs/mergeRefs.d.ts
3
4
  /**
4
5
  * @description
5
6
  * This function takes multiple refs (RefObject or RefCallback) and returns a single ref that updates all provided refs.
@@ -35,5 +36,5 @@ import { RefObject, RefCallback } from 'react';
35
36
  * }
36
37
  */
37
38
  declare function mergeRefs<T>(...refs: Array<RefObject<T> | RefCallback<T> | null | undefined>): RefCallback<T>;
38
-
39
- export { mergeRefs };
39
+ //#endregion
40
+ export { mergeRefs };
@@ -0,0 +1,40 @@
1
+
2
+ import { RefCallback, RefObject } from "react";
3
+ //#region src/utils/mergeRefs/mergeRefs.d.ts
4
+ /**
5
+ * @description
6
+ * This function takes multiple refs (RefObject or RefCallback) and returns a single ref that updates all provided refs.
7
+ * It's useful when you need to pass multiple refs to a single element.
8
+ *
9
+ * @template T - The type of target to be referenced.
10
+ *
11
+ * @param {Array<RefObject<T> | RefCallback<T> | null | undefined>} refs - An array of refs to be merged. Each ref can be either a RefObject or RefCallback.
12
+ *
13
+ * @returns {RefCallback<T>} A single ref callback that updates all provided refs.
14
+ *
15
+ * @example
16
+ * forwardRef(function Component(props, parentRef) {
17
+ * const myRef = useRef(null);
18
+ *
19
+ * return <div ref={mergeRefs(myRef, parentRef)} />;
20
+ * })
21
+ *
22
+ * @example
23
+ * function Component(props) {
24
+ * const ref = useRef(null);
25
+ * const [height, setHeight] = useState(0);
26
+ *
27
+ * const measuredRef = useCallback(node => {
28
+ * if(node == null) {
29
+ * return;
30
+ * }
31
+ *
32
+ * setHeight(node.offsetHeight);
33
+ * }, []);
34
+ *
35
+ * return <div ref={mergeRefs(measuredRef, ref)} />;
36
+ * }
37
+ */
38
+ declare function mergeRefs<T>(...refs: Array<RefObject<T> | RefCallback<T> | null | undefined>): RefCallback<T>;
39
+ //#endregion
40
+ export { mergeRefs };
@@ -0,0 +1,50 @@
1
+ "use client";
2
+ //#region src/utils/mergeRefs/mergeRefs.ts
3
+ /**
4
+ * @description
5
+ * This function takes multiple refs (RefObject or RefCallback) and returns a single ref that updates all provided refs.
6
+ * It's useful when you need to pass multiple refs to a single element.
7
+ *
8
+ * @template T - The type of target to be referenced.
9
+ *
10
+ * @param {Array<RefObject<T> | RefCallback<T> | null | undefined>} refs - An array of refs to be merged. Each ref can be either a RefObject or RefCallback.
11
+ *
12
+ * @returns {RefCallback<T>} A single ref callback that updates all provided refs.
13
+ *
14
+ * @example
15
+ * forwardRef(function Component(props, parentRef) {
16
+ * const myRef = useRef(null);
17
+ *
18
+ * return <div ref={mergeRefs(myRef, parentRef)} />;
19
+ * })
20
+ *
21
+ * @example
22
+ * function Component(props) {
23
+ * const ref = useRef(null);
24
+ * const [height, setHeight] = useState(0);
25
+ *
26
+ * const measuredRef = useCallback(node => {
27
+ * if(node == null) {
28
+ * return;
29
+ * }
30
+ *
31
+ * setHeight(node.offsetHeight);
32
+ * }, []);
33
+ *
34
+ * return <div ref={mergeRefs(measuredRef, ref)} />;
35
+ * }
36
+ */
37
+ function mergeRefs(...refs) {
38
+ return (value) => {
39
+ for (const ref of refs) {
40
+ if (ref == null) continue;
41
+ if (typeof ref === "function") {
42
+ ref(value);
43
+ continue;
44
+ }
45
+ ref.current = value;
46
+ }
47
+ };
48
+ }
49
+ //#endregion
50
+ export { mergeRefs };
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "react-simplikit",
3
- "version": "0.0.51",
3
+ "version": "0.0.53",
4
4
  "main": "./dist/index.cjs",
5
- "module": "./esm/index.js",
5
+ "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.cts",
7
7
  "exports": {
8
8
  ".": {
9
9
  "import": {
10
- "types": "./esm/index.d.ts",
11
- "default": "./esm/index.js"
10
+ "types": "./dist/index.d.mts",
11
+ "default": "./dist/index.mjs"
12
12
  },
13
13
  "require": {
14
14
  "types": "./dist/index.d.cts",
@@ -31,12 +31,11 @@
31
31
  },
32
32
  "license": "MIT",
33
33
  "files": [
34
- "dist/**/*",
35
- "esm/**/*"
34
+ "dist/**/*"
36
35
  ],
37
36
  "scripts": {
38
- "build": "tsup",
39
- "clean": "rimraf ./dist ./esm",
37
+ "build": "tsdown",
38
+ "clean": "rimraf ./dist",
40
39
  "lint": "eslint src",
41
40
  "typecheck": "tsc --noEmit",
42
41
  "test": "vitest run",
@@ -54,7 +53,7 @@
54
53
  "@testing-library/jest-dom": "^6.6.3",
55
54
  "@testing-library/react": "^16.1.0",
56
55
  "@trivago/prettier-plugin-sort-imports": "^5.2.0",
57
- "@types/node": "^22.10.2",
56
+ "@types/node": "^24.13.3",
58
57
  "@types/react": "^19.0.0",
59
58
  "@types/react-dom": "^19.0.0",
60
59
  "@vitest/coverage-v8": "^2.1.8",
@@ -62,7 +61,6 @@
62
61
  "comment-parser": "^1.4.1",
63
62
  "corepack": "^0.30.0",
64
63
  "dotenv": "^16.4.7",
65
- "esbuild": "^0.24.0",
66
64
  "eslint": "^9.16.0",
67
65
  "eslint-config-prettier": "^9.1.0",
68
66
  "eslint-plugin-import": "^2.31.0",
@@ -83,7 +81,7 @@
83
81
  "react": "^19.0.0",
84
82
  "react-dom": "^19.0.0",
85
83
  "rimraf": "^6.0.1",
86
- "tsup": "^8.3.5",
84
+ "tsdown": "^0.22.14",
87
85
  "tsx": "^4.19.2",
88
86
  "typescript": "^5.7.2",
89
87
  "typescript-eslint": "^8.18.0",
@@ -1,295 +0,0 @@
1
- "use client";
2
- "use strict";
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
-
21
- // src/components/ImpressionArea/index.ts
22
- var ImpressionArea_exports = {};
23
- __export(ImpressionArea_exports, {
24
- ImpressionArea: () => ImpressionArea
25
- });
26
- module.exports = __toCommonJS(ImpressionArea_exports);
27
-
28
- // src/components/ImpressionArea/ImpressionArea.tsx
29
- var import_react7 = require("react");
30
-
31
- // src/hooks/useImpressionRef/useImpressionRef.ts
32
- var import_react6 = require("react");
33
-
34
- // src/hooks/useDebouncedCallback/useDebouncedCallback.ts
35
- var import_react2 = require("react");
36
-
37
- // src/hooks/useDebounce/debounce.ts
38
- function debounce(func, debounceMs, { edges = ["leading", "trailing"] } = {}) {
39
- let pendingThis = void 0;
40
- let pendingArgs = null;
41
- const leading = edges != null && edges.includes("leading");
42
- const trailing = edges == null || edges.includes("trailing");
43
- const invoke = () => {
44
- if (pendingArgs !== null) {
45
- func.apply(pendingThis, pendingArgs);
46
- pendingThis = void 0;
47
- pendingArgs = null;
48
- }
49
- };
50
- const onTimerEnd = () => {
51
- if (trailing) {
52
- invoke();
53
- }
54
- cancel();
55
- };
56
- let timeoutId = null;
57
- const schedule = () => {
58
- if (timeoutId != null) {
59
- clearTimeout(timeoutId);
60
- }
61
- timeoutId = setTimeout(() => {
62
- timeoutId = null;
63
- onTimerEnd();
64
- }, debounceMs);
65
- };
66
- const cancelTimer = () => {
67
- if (timeoutId !== null) {
68
- clearTimeout(timeoutId);
69
- timeoutId = null;
70
- }
71
- };
72
- const cancel = () => {
73
- cancelTimer();
74
- pendingThis = void 0;
75
- pendingArgs = null;
76
- };
77
- const debounced = function(...args) {
78
- pendingThis = this;
79
- pendingArgs = args;
80
- const isFirstCall = timeoutId == null;
81
- schedule();
82
- if (leading && isFirstCall) {
83
- invoke();
84
- }
85
- };
86
- debounced.cancel = cancel;
87
- return debounced;
88
- }
89
-
90
- // src/hooks/usePreservedCallback/usePreservedCallback.ts
91
- var import_react = require("react");
92
- function usePreservedCallback(callback) {
93
- const callbackRef = (0, import_react.useRef)(callback);
94
- (0, import_react.useEffect)(
95
- function syncCallbackRef() {
96
- callbackRef.current = callback;
97
- },
98
- [callback]
99
- );
100
- return (0, import_react.useCallback)((...args) => {
101
- return callbackRef.current(...args);
102
- }, []);
103
- }
104
-
105
- // src/hooks/useDebouncedCallback/useDebouncedCallback.ts
106
- function useDebouncedCallback({
107
- onChange,
108
- timeThreshold,
109
- leading = false,
110
- trailing = true
111
- }) {
112
- const handleChange = usePreservedCallback(onChange);
113
- const ref = (0, import_react2.useRef)({ value: false, clearPreviousDebounce: () => {
114
- } });
115
- (0, import_react2.useEffect)(function clearDebouncedOnUnmount() {
116
- const current = ref.current;
117
- return () => {
118
- current.clearPreviousDebounce();
119
- };
120
- }, []);
121
- const edges = (0, import_react2.useMemo)(() => {
122
- const _edges = [];
123
- if (leading) {
124
- _edges.push("leading");
125
- }
126
- if (trailing) {
127
- _edges.push("trailing");
128
- }
129
- return _edges;
130
- }, [leading, trailing]);
131
- return (0, import_react2.useCallback)(
132
- (nextValue) => {
133
- if (nextValue === ref.current.value) {
134
- return;
135
- }
136
- const debounced = debounce(
137
- () => {
138
- handleChange(nextValue);
139
- ref.current.value = nextValue;
140
- },
141
- timeThreshold,
142
- { edges }
143
- );
144
- ref.current.clearPreviousDebounce();
145
- debounced();
146
- ref.current.clearPreviousDebounce = debounced.cancel;
147
- },
148
- [handleChange, timeThreshold, edges]
149
- );
150
- }
151
-
152
- // src/hooks/useIntersectionObserver/useIntersectionObserver.ts
153
- var import_react4 = require("react");
154
-
155
- // src/hooks/useRefEffect/useRefEffect.ts
156
- var import_react3 = require("react");
157
- function useRefEffect(callback, deps) {
158
- const preservedCallback = usePreservedCallback(callback);
159
- const cleanupCallbackRef = (0, import_react3.useRef)(() => {
160
- });
161
- const effect = (0, import_react3.useCallback)(
162
- (element) => {
163
- cleanupCallbackRef.current();
164
- cleanupCallbackRef.current = () => {
165
- };
166
- if (element == null) {
167
- return;
168
- }
169
- const cleanup = preservedCallback(element);
170
- if (typeof cleanup === "function") {
171
- cleanupCallbackRef.current = cleanup;
172
- }
173
- },
174
- // eslint-disable-next-line react-hooks/exhaustive-deps
175
- [preservedCallback, ...deps]
176
- );
177
- return effect;
178
- }
179
-
180
- // src/hooks/useIntersectionObserver/useIntersectionObserver.ts
181
- function useIntersectionObserver(callback, options) {
182
- const preservedCallback = usePreservedCallback(callback);
183
- const observer = (0, import_react4.useMemo)(() => {
184
- if (typeof IntersectionObserver === "undefined") {
185
- return;
186
- }
187
- return new IntersectionObserver(([entry]) => {
188
- preservedCallback(entry);
189
- }, options);
190
- }, [preservedCallback, options]);
191
- return useRefEffect(
192
- (element) => {
193
- observer?.observe(element);
194
- return () => {
195
- observer?.unobserve(element);
196
- };
197
- },
198
- [preservedCallback, options]
199
- );
200
- }
201
-
202
- // src/hooks/useVisibilityEvent/useVisibilityEvent.ts
203
- var import_react5 = require("react");
204
- function useVisibilityEvent(callback, options = {}) {
205
- const handleVisibilityChange = (0, import_react5.useCallback)(() => {
206
- callback(document.visibilityState);
207
- }, [callback]);
208
- (0, import_react5.useEffect)(() => {
209
- if (options?.immediate ?? false) {
210
- handleVisibilityChange();
211
- }
212
- document.addEventListener("visibilitychange", handleVisibilityChange);
213
- return () => {
214
- document.removeEventListener("visibilitychange", handleVisibilityChange);
215
- };
216
- }, [handleVisibilityChange, options?.immediate]);
217
- }
218
-
219
- // src/hooks/useImpressionRef/useImpressionRef.ts
220
- function useImpressionRef({
221
- onImpressionStart = () => {
222
- },
223
- onImpressionEnd = () => {
224
- },
225
- rootMargin,
226
- areaThreshold = 0,
227
- timeThreshold = 0
228
- }) {
229
- const impressionStartHandler = usePreservedCallback(onImpressionStart);
230
- const impressionEndHandler = usePreservedCallback(onImpressionEnd);
231
- const isIntersectingRef = (0, import_react6.useRef)(false);
232
- const impressionEventHandler = useDebouncedCallback({
233
- timeThreshold,
234
- onChange: (impressed) => {
235
- (impressed ? impressionStartHandler : impressionEndHandler)();
236
- },
237
- leading: true
238
- });
239
- useVisibilityEvent((documentVisible) => {
240
- if (!isIntersectingRef.current) {
241
- return;
242
- }
243
- impressionEventHandler(documentVisible === "visible");
244
- });
245
- return useIntersectionObserver(
246
- (entry) => {
247
- if (document.visibilityState === "hidden") {
248
- return;
249
- }
250
- const currentRatio = entry.intersectionRatio;
251
- const isIntersecting = areaThreshold === 0 ? entry.isIntersecting : currentRatio >= areaThreshold;
252
- isIntersectingRef.current = isIntersecting;
253
- impressionEventHandler(isIntersecting);
254
- },
255
- { rootMargin, threshold: areaThreshold }
256
- );
257
- }
258
-
259
- // src/utils/mergeRefs/mergeRefs.ts
260
- function mergeRefs(...refs) {
261
- return (value) => {
262
- for (const ref of refs) {
263
- if (ref == null) {
264
- continue;
265
- }
266
- if (typeof ref === "function") {
267
- ref(value);
268
- continue;
269
- }
270
- ref.current = value;
271
- }
272
- };
273
- }
274
-
275
- // src/components/ImpressionArea/ImpressionArea.tsx
276
- var import_jsx_runtime = require("react/jsx-runtime");
277
- var ImpressionArea = (0, import_react7.forwardRef)(ImpressionAreaImpl);
278
- function ImpressionAreaImpl({ as, rootMargin, areaThreshold, timeThreshold, onImpressionStart, onImpressionEnd, ...props }, ref) {
279
- const Component = as ?? "div";
280
- const impressionRef = useImpressionRef({
281
- onImpressionStart,
282
- onImpressionEnd,
283
- areaThreshold,
284
- timeThreshold,
285
- rootMargin
286
- });
287
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { ref: mergeRefs(ref, impressionRef), ...props });
288
- }
289
- Object.assign(ImpressionArea, {
290
- displayName: "ImpressionArea"
291
- });
292
- // Annotate the CommonJS export names for ESM import in node:
293
- 0 && (module.exports = {
294
- ImpressionArea
295
- });
@@ -1,41 +0,0 @@
1
- "use client";
2
- "use strict";
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
-
21
- // src/components/Separated/index.ts
22
- var Separated_exports = {};
23
- __export(Separated_exports, {
24
- Separated: () => Separated
25
- });
26
- module.exports = __toCommonJS(Separated_exports);
27
-
28
- // src/components/Separated/Separated.tsx
29
- var import_react = require("react");
30
- var import_jsx_runtime = require("react/jsx-runtime");
31
- function Separated({ children, by: separator }) {
32
- const childrenArray = import_react.Children.toArray(children).filter(import_react.isValidElement);
33
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: childrenArray.map((child, i, { length }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
34
- child,
35
- i + 1 !== length && separator
36
- ] }, child.key ?? i)) });
37
- }
38
- // Annotate the CommonJS export names for ESM import in node:
39
- 0 && (module.exports = {
40
- Separated
41
- });
@@ -1,36 +0,0 @@
1
- "use client";
2
- "use strict";
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
-
21
- // src/components/SwitchCase/index.ts
22
- var SwitchCase_exports = {};
23
- __export(SwitchCase_exports, {
24
- SwitchCase: () => SwitchCase
25
- });
26
- module.exports = __toCommonJS(SwitchCase_exports);
27
-
28
- // src/components/SwitchCase/SwitchCase.tsx
29
- function SwitchCase({ value, caseBy, defaultComponent = () => null }) {
30
- const stringifiedValue = String(value);
31
- return (caseBy[stringifiedValue] ?? defaultComponent)();
32
- }
33
- // Annotate the CommonJS export names for ESM import in node:
34
- 0 && (module.exports = {
35
- SwitchCase
36
- });
@@ -1,49 +0,0 @@
1
- "use client";
2
- "use strict";
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
-
21
- // src/hooks/useAsyncEffect/index.ts
22
- var useAsyncEffect_exports = {};
23
- __export(useAsyncEffect_exports, {
24
- useAsyncEffect: () => useAsyncEffect
25
- });
26
- module.exports = __toCommonJS(useAsyncEffect_exports);
27
-
28
- // src/hooks/useAsyncEffect/useAsyncEffect.ts
29
- var import_react = require("react");
30
- function useAsyncEffect(effect, deps) {
31
- (0, import_react.useEffect)(() => {
32
- let cleanup;
33
- let isCleaned = false;
34
- effect().then((result) => {
35
- cleanup = result;
36
- if (isCleaned) {
37
- cleanup?.();
38
- }
39
- });
40
- return () => {
41
- isCleaned = true;
42
- cleanup?.();
43
- };
44
- }, deps);
45
- }
46
- // Annotate the CommonJS export names for ESM import in node:
47
- 0 && (module.exports = {
48
- useAsyncEffect
49
- });