react-simplikit 0.0.53 → 0.2.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.
- package/CHANGELOG.md +126 -0
- package/README.md +2 -42
- package/dist/hooks/useAsyncEffect/useAsyncEffect.cjs +1 -0
- package/dist/hooks/useAsyncEffect/useAsyncEffect.mjs +1 -0
- package/dist/hooks/useCallbackOncePerRender/useCallbackOncePerRender.cjs +1 -0
- package/dist/hooks/useCallbackOncePerRender/useCallbackOncePerRender.mjs +1 -0
- package/dist/hooks/useConditionalEffect/useConditionalEffect.cjs +1 -0
- package/dist/hooks/useConditionalEffect/useConditionalEffect.mjs +1 -0
- package/dist/hooks/useDebouncedCallback/useDebouncedCallback.cjs +24 -6
- package/dist/hooks/useDebouncedCallback/useDebouncedCallback.d.cts +17 -7
- package/dist/hooks/useDebouncedCallback/useDebouncedCallback.d.mts +17 -7
- package/dist/hooks/useDebouncedCallback/useDebouncedCallback.mjs +24 -6
- package/dist/hooks/useDoubleClick/useDoubleClick.cjs +0 -4
- package/dist/hooks/useDoubleClick/useDoubleClick.d.cts +0 -4
- package/dist/hooks/useDoubleClick/useDoubleClick.d.mts +0 -4
- package/dist/hooks/useDoubleClick/useDoubleClick.mjs +0 -4
- package/dist/hooks/useGeolocation/useGeolocation.cjs +0 -4
- package/dist/hooks/useGeolocation/useGeolocation.d.cts +0 -4
- package/dist/hooks/useGeolocation/useGeolocation.d.mts +0 -4
- package/dist/hooks/useGeolocation/useGeolocation.mjs +0 -4
- package/dist/hooks/useImpressionRef/useImpressionRef.cjs +7 -5
- package/dist/hooks/useImpressionRef/useImpressionRef.d.cts +0 -4
- package/dist/hooks/useImpressionRef/useImpressionRef.d.mts +0 -4
- package/dist/hooks/useImpressionRef/useImpressionRef.mjs +7 -5
- package/dist/hooks/useInputState/useInputState.cjs +9 -3
- package/dist/hooks/useInputState/useInputState.d.cts +11 -4
- package/dist/hooks/useInputState/useInputState.d.mts +11 -4
- package/dist/hooks/useInputState/useInputState.mjs +9 -3
- package/dist/hooks/useIntersectionObserver/useIntersectionObserver.cjs +1 -5
- package/dist/hooks/useIntersectionObserver/useIntersectionObserver.d.cts +1 -5
- package/dist/hooks/useIntersectionObserver/useIntersectionObserver.d.mts +1 -5
- package/dist/hooks/useIntersectionObserver/useIntersectionObserver.mjs +1 -5
- package/dist/hooks/useList/useList.cjs +11 -8
- package/dist/hooks/useList/useList.d.cts +12 -9
- package/dist/hooks/useList/useList.d.mts +12 -9
- package/dist/hooks/useList/useList.mjs +11 -8
- package/dist/hooks/useLoading/useLoading.cjs +3 -5
- package/dist/hooks/useLoading/useLoading.d.cts +2 -5
- package/dist/hooks/useLoading/useLoading.d.mts +2 -5
- package/dist/hooks/useLoading/useLoading.mjs +3 -5
- package/dist/hooks/useLongPress/useLongPress.cjs +0 -4
- package/dist/hooks/useLongPress/useLongPress.d.cts +0 -4
- package/dist/hooks/useLongPress/useLongPress.d.mts +0 -4
- package/dist/hooks/useLongPress/useLongPress.mjs +0 -4
- package/dist/hooks/useOutsideClickEffect/useOutsideClickEffect.cjs +0 -4
- package/dist/hooks/useOutsideClickEffect/useOutsideClickEffect.d.cts +0 -4
- package/dist/hooks/useOutsideClickEffect/useOutsideClickEffect.d.mts +0 -4
- package/dist/hooks/useOutsideClickEffect/useOutsideClickEffect.mjs +0 -4
- package/dist/hooks/usePreservedReference/usePreservedReference.cjs +1 -0
- package/dist/hooks/usePreservedReference/usePreservedReference.mjs +1 -0
- package/dist/hooks/useRefEffect/useRefEffect.cjs +1 -0
- package/dist/hooks/useRefEffect/useRefEffect.mjs +1 -0
- package/dist/hooks/useSet/useSet.cjs +11 -2
- package/dist/hooks/useSet/useSet.d.cts +11 -2
- package/dist/hooks/useSet/useSet.d.mts +11 -2
- package/dist/hooks/useSet/useSet.mjs +11 -2
- package/dist/hooks/useStorageState/useStorageState.cjs +1 -0
- package/dist/hooks/useStorageState/useStorageState.d.cts +0 -4
- package/dist/hooks/useStorageState/useStorageState.d.mts +0 -4
- package/dist/hooks/useStorageState/useStorageState.mjs +1 -0
- package/dist/hooks/useThrottledCallback/useThrottledCallback.cjs +16 -9
- package/dist/hooks/useThrottledCallback/useThrottledCallback.d.cts +18 -11
- package/dist/hooks/useThrottledCallback/useThrottledCallback.d.mts +18 -11
- package/dist/hooks/useThrottledCallback/useThrottledCallback.mjs +16 -9
- package/dist/hooks/useVisibilityEvent/useVisibilityEvent.cjs +2 -4
- package/dist/hooks/useVisibilityEvent/useVisibilityEvent.d.cts +2 -4
- package/dist/hooks/useVisibilityEvent/useVisibilityEvent.d.mts +2 -4
- package/dist/hooks/useVisibilityEvent/useVisibilityEvent.mjs +2 -4
- package/dist/index.cjs +34 -0
- package/dist/index.d.cts +19 -1
- package/dist/index.d.mts +19 -1
- package/dist/index.mjs +18 -1
- package/dist/mobile/hooks/useAvoidKeyboard/index.d.cts +3 -0
- package/dist/mobile/hooks/useAvoidKeyboard/index.d.mts +3 -0
- package/dist/mobile/hooks/useAvoidKeyboard/useAvoidKeyboard.cjs +75 -0
- package/dist/mobile/hooks/useAvoidKeyboard/useAvoidKeyboard.d.cts +89 -0
- package/dist/mobile/hooks/useAvoidKeyboard/useAvoidKeyboard.d.mts +89 -0
- package/dist/mobile/hooks/useAvoidKeyboard/useAvoidKeyboard.mjs +75 -0
- package/dist/mobile/hooks/useBodyScrollLock/useBodyScrollLock.cjs +47 -0
- package/dist/mobile/hooks/useBodyScrollLock/useBodyScrollLock.d.cts +37 -0
- package/dist/mobile/hooks/useBodyScrollLock/useBodyScrollLock.d.mts +37 -0
- package/dist/mobile/hooks/useBodyScrollLock/useBodyScrollLock.mjs +47 -0
- package/dist/mobile/hooks/useKeyboardHeight/useKeyboardHeight.cjs +41 -0
- package/dist/mobile/hooks/useKeyboardHeight/useKeyboardHeight.d.cts +41 -0
- package/dist/mobile/hooks/useKeyboardHeight/useKeyboardHeight.d.mts +41 -0
- package/dist/mobile/hooks/useKeyboardHeight/useKeyboardHeight.mjs +41 -0
- package/dist/mobile/hooks/useNetworkStatus/useNetworkStatus.cjs +88 -0
- package/dist/mobile/hooks/useNetworkStatus/useNetworkStatus.d.cts +77 -0
- package/dist/mobile/hooks/useNetworkStatus/useNetworkStatus.d.mts +77 -0
- package/dist/mobile/hooks/useNetworkStatus/useNetworkStatus.mjs +88 -0
- package/dist/mobile/hooks/usePageVisibility/usePageVisibility.cjs +75 -0
- package/dist/mobile/hooks/usePageVisibility/usePageVisibility.d.cts +64 -0
- package/dist/mobile/hooks/usePageVisibility/usePageVisibility.d.mts +64 -0
- package/dist/mobile/hooks/usePageVisibility/usePageVisibility.mjs +75 -0
- package/dist/mobile/hooks/useSafeAreaInset/useSafeAreaInset.cjs +74 -0
- package/dist/mobile/hooks/useSafeAreaInset/useSafeAreaInset.d.cts +55 -0
- package/dist/mobile/hooks/useSafeAreaInset/useSafeAreaInset.d.mts +55 -0
- package/dist/mobile/hooks/useSafeAreaInset/useSafeAreaInset.mjs +74 -0
- package/dist/mobile/hooks/useScrollDirection/useScrollDirection.cjs +79 -0
- package/dist/mobile/hooks/useScrollDirection/useScrollDirection.d.cts +40 -0
- package/dist/mobile/hooks/useScrollDirection/useScrollDirection.d.mts +40 -0
- package/dist/mobile/hooks/useScrollDirection/useScrollDirection.mjs +79 -0
- package/dist/mobile/hooks/useVisualViewport/useVisualViewport.cjs +77 -0
- package/dist/mobile/hooks/useVisualViewport/useVisualViewport.d.cts +89 -0
- package/dist/mobile/hooks/useVisualViewport/useVisualViewport.d.mts +89 -0
- package/dist/mobile/hooks/useVisualViewport/useVisualViewport.mjs +77 -0
- package/dist/mobile/utils/disableBodyScrollLock/disableBodyScrollLock.cjs +55 -0
- package/dist/mobile/utils/disableBodyScrollLock/disableBodyScrollLock.d.cts +22 -0
- package/dist/mobile/utils/disableBodyScrollLock/disableBodyScrollLock.d.mts +22 -0
- package/dist/mobile/utils/disableBodyScrollLock/disableBodyScrollLock.mjs +55 -0
- package/dist/mobile/utils/enableBodyScrollLock/enableBodyScrollLock.cjs +49 -0
- package/dist/mobile/utils/enableBodyScrollLock/enableBodyScrollLock.d.cts +23 -0
- package/dist/mobile/utils/enableBodyScrollLock/enableBodyScrollLock.d.mts +23 -0
- package/dist/mobile/utils/enableBodyScrollLock/enableBodyScrollLock.mjs +49 -0
- package/dist/mobile/utils/getKeyboardHeight/getKeyboardHeight.cjs +35 -0
- package/dist/mobile/utils/getKeyboardHeight/getKeyboardHeight.d.cts +28 -0
- package/dist/mobile/utils/getKeyboardHeight/getKeyboardHeight.d.mts +28 -0
- package/dist/mobile/utils/getKeyboardHeight/getKeyboardHeight.mjs +35 -0
- package/dist/mobile/utils/getSafeAreaInset/getSafeAreaInset.cjs +58 -0
- package/dist/mobile/utils/getSafeAreaInset/getSafeAreaInset.d.cts +44 -0
- package/dist/mobile/utils/getSafeAreaInset/getSafeAreaInset.d.mts +44 -0
- package/dist/mobile/utils/getSafeAreaInset/getSafeAreaInset.mjs +58 -0
- package/dist/mobile/utils/isAndroid/isAndroid.cjs +32 -0
- package/dist/mobile/utils/isAndroid/isAndroid.d.cts +27 -0
- package/dist/mobile/utils/isAndroid/isAndroid.d.mts +27 -0
- package/dist/mobile/utils/isAndroid/isAndroid.mjs +32 -0
- package/dist/mobile/utils/isIOS/isIOS.cjs +37 -0
- package/dist/mobile/utils/isIOS/isIOS.d.cts +30 -0
- package/dist/mobile/utils/isIOS/isIOS.d.mts +30 -0
- package/dist/mobile/utils/isIOS/isIOS.mjs +37 -0
- package/dist/mobile/utils/isKeyboardVisible/isKeyboardVisible.cjs +28 -0
- package/dist/mobile/utils/isKeyboardVisible/isKeyboardVisible.d.cts +25 -0
- package/dist/mobile/utils/isKeyboardVisible/isKeyboardVisible.d.mts +25 -0
- package/dist/mobile/utils/isKeyboardVisible/isKeyboardVisible.mjs +28 -0
- package/dist/mobile/utils/isServer/isServer.cjs +24 -0
- package/dist/mobile/utils/isServer/isServer.d.cts +22 -0
- package/dist/mobile/utils/isServer/isServer.d.mts +22 -0
- package/dist/mobile/utils/isServer/isServer.mjs +24 -0
- package/dist/mobile/utils/subscribeKeyboardHeight/subscribeKeyboardHeight.cjs +71 -0
- package/dist/mobile/utils/subscribeKeyboardHeight/subscribeKeyboardHeight.d.cts +64 -0
- package/dist/mobile/utils/subscribeKeyboardHeight/subscribeKeyboardHeight.d.mts +64 -0
- package/dist/mobile/utils/subscribeKeyboardHeight/subscribeKeyboardHeight.mjs +71 -0
- package/dist/utils/buildContext/buildContext.cjs +1 -0
- package/dist/utils/buildContext/buildContext.mjs +1 -0
- package/dist/utils/mergeProps/mergeProps.cjs +1 -1
- package/dist/utils/mergeProps/mergeProps.d.cts +1 -1
- package/dist/utils/mergeProps/mergeProps.d.mts +1 -1
- package/dist/utils/mergeProps/mergeProps.mjs +1 -1
- package/dist/utils/mergeRefs/mergeRefs.cjs +1 -1
- package/dist/utils/mergeRefs/mergeRefs.d.cts +1 -1
- package/dist/utils/mergeRefs/mergeRefs.d.mts +1 -1
- package/dist/utils/mergeRefs/mergeRefs.mjs +1 -1
- package/package.json +22 -10
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# react-simplikit
|
|
2
|
+
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#446](https://github.com/toss/react-simplikit/pull/446) [`0b66d40`](https://github.com/toss/react-simplikit/commit/0b66d40e56b4a183fd1fc5dce8a685e2a0da2839) Thanks [@hyesungoh](https://github.com/hyesungoh)! - `useDebouncedCallback` and `useThrottledCallback` now accept any value type: `onChange` is typed `(newValue: T) => void` instead of `(newValue: boolean) => void`, so a debounced search query or a throttled scroll position no longer needs a cast. Existing boolean callers are unaffected.
|
|
8
|
+
|
|
9
|
+
`useDebouncedCallback` no longer drops a first call of `false`. It compared incoming values against a seed of `false`, so the very first `false` looked redundant and was never forwarded; the comparison now starts from a sentinel, as `useThrottledCallback` already did. A `false` that arrives while an initial `true` is still pending now replaces it instead of being ignored.
|
|
10
|
+
|
|
11
|
+
`useImpressionRef` no longer emits `onImpressionEnd` for an element that was never impressed.
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#450](https://github.com/toss/react-simplikit/pull/450) [`a4251a3`](https://github.com/toss/react-simplikit/commit/a4251a30aafbfabc61e6cc9a80de1af86936bb2a) Thanks [@hyesungoh](https://github.com/hyesungoh)! - `useDebouncedCallback` and `useThrottledCallback` no longer forward a stale value when the caller returns to the last forwarded one. Calling with `'seo'` and then `'seoul'` right after `'seoul'` had already been forwarded used to skip the second call as a duplicate without cancelling the pending `'seo'`, so `onChange('seo')` fired anyway. The pending call is now cancelled first. For `useThrottledCallback` this only showed with `edges: ['trailing']`; the default leading edge forwards the intermediate value immediately and masked it.
|
|
16
|
+
|
|
17
|
+
- [#452](https://github.com/toss/react-simplikit/pull/452) [`fd312f5`](https://github.com/toss/react-simplikit/commit/fd312f589430154d38b7d5d5998f1f20ceb0be54) Thanks [@hyesungoh](https://github.com/hyesungoh)! - JSDoc corrections that show up in editor hover. `useIntersectionObserver`'s `options.root` is typed `Element | Document | null` instead of `boolean`. `useList` and `useSet` now declare their generic parameter, their optional initial state and every member they return. `mergeProps` and `mergeRefs` mark their rest parameter as one, so the documented signature matches the implementation.
|
|
18
|
+
|
|
19
|
+
- [#456](https://github.com/toss/react-simplikit/pull/456) [`65ce435`](https://github.com/toss/react-simplikit/commit/65ce435abfca276f2a22c01b6ff50dc5530831fc) Thanks [@mnxmnz](https://github.com/mnxmnz)! - Re-export the `SafeAreaInset` type from the package root. `@react-simplikit/mobile` exported it, but it was dropped when that package was absorbed into the root entry, leaving `import type { SafeAreaInset }` with no replacement.
|
|
20
|
+
|
|
21
|
+
- [#435](https://github.com/toss/react-simplikit/pull/435) [`9e05182`](https://github.com/toss/react-simplikit/commit/9e051826418a852996ae851a7f8c8e53c1408852) Thanks [@hyesungoh](https://github.com/hyesungoh)! - `useDoubleClick`, `useGeolocation`, `useImpressionRef`, `useIntersectionObserver`, `useLongPress`, `useOutsideClickEffect`, `useStorageState` and `useVisibilityEvent` are no longer marked `@deprecated`. They are maintained hooks again: editors stop rendering them struck-through, and no removal is planned.
|
|
22
|
+
|
|
23
|
+
## 0.1.0
|
|
24
|
+
|
|
25
|
+
### Minor Changes
|
|
26
|
+
|
|
27
|
+
- [#437](https://github.com/toss/react-simplikit/pull/437) [`fe2226d`](https://github.com/toss/react-simplikit/commit/fe2226d5fbfcd305ab888cef83450f7f0e1caa77) Thanks [@mnxmnz](https://github.com/mnxmnz)! - Absorb `@react-simplikit/mobile` into the root export of `react-simplikit`. Update imports from `@react-simplikit/mobile` to `react-simplikit`; the exported APIs are unchanged. The `@react-simplikit/mobile` npm package will be deprecated with a pointer to `react-simplikit` after this release.
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- [#423](https://github.com/toss/react-simplikit/pull/423) [`36e3e4c`](https://github.com/toss/react-simplikit/commit/36e3e4ccbd9c7a45bda18f33dcb514c97f387cbb) Thanks [@Antoliny0919](https://github.com/Antoliny0919)! - The returned handler was typed as `ChangeEventHandler<HTMLInputElement>`, so passing it to a `<textarea>` raised a type error even though the runtime behavior was identical. The handler is now typed as `ChangeEventHandler<HTMLInputElement | HTMLTextAreaElement>`, so it can be attached to both `<input>` and `<textarea>` elements.
|
|
32
|
+
|
|
33
|
+
- [#424](https://github.com/toss/react-simplikit/pull/424) [`1ac0166`](https://github.com/toss/react-simplikit/commit/1ac0166d8f41c1159d004bd9c8192f2e59f6efc8) Thanks [@hyesungoh](https://github.com/hyesungoh)! - fix(core): opt the remaining React Compiler-incompatible hooks out with `'use no memo'`
|
|
34
|
+
|
|
35
|
+
## 0.0.53
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- [#379](https://github.com/toss/react-simplikit/pull/379) [`e2030a2`](https://github.com/toss/react-simplikit/commit/e2030a2deac81fb247b9f601fab19d87a067cc9c) Thanks [@lumirlumir](https://github.com/lumirlumir)! - fix(usePrevious): opt out `usePrevious` hook from React Compiler
|
|
40
|
+
|
|
41
|
+
- [#404](https://github.com/toss/react-simplikit/pull/404) [`cac80cb`](https://github.com/toss/react-simplikit/commit/cac80cb41897b834bb3661336faa84197c558c1e) Thanks [@bbjbc](https://github.com/bbjbc)! - fix(useThrottledCallback): invoke the callback when the first value is `false`
|
|
42
|
+
|
|
43
|
+
The hook skips redundant invocations by comparing the incoming value against the last one it forwarded, but that comparison was seeded with `false`. Because the hook takes no initial value from the caller, a first call of `false` looked redundant and was dropped — so consumers whose state starts as `true` lost the transition back to `false`. The comparison now starts from a sentinel, so the first call is always forwarded regardless of its value.
|
|
44
|
+
|
|
45
|
+
## 0.0.52
|
|
46
|
+
|
|
47
|
+
### Patch Changes
|
|
48
|
+
|
|
49
|
+
- [#401](https://github.com/toss/react-simplikit/pull/401) [`9b93d29`](https://github.com/toss/react-simplikit/commit/9b93d299e9b105d060f2700b27ffb63001b88de3) Thanks [@hyesungoh](https://github.com/hyesungoh)! - Switched the build output from a single bundled file per package to per-module files, so bundlers can tree-shake unused exports at file granularity instead of relying on dead-code elimination inside one large bundle.
|
|
50
|
+
|
|
51
|
+
The public API and runtime behavior are unchanged. For an app importing a single hook, this cuts the amount of code a bundler has to include: `react-simplikit`'s `useToggle` drops from 5363 B to 102 B minified, and `@react-simplikit/mobile`'s `useNetworkStatus` drops from 981 B to 570 B minified.
|
|
52
|
+
|
|
53
|
+
The only user-visible change is packaging: output files are now `.mjs`/`.cjs` with `.d.mts`/`.d.cts` type declarations instead of a flat bundle, and for `react-simplikit` the `esm/` directory has been removed (`@react-simplikit/mobile` never had one — it always emitted to `dist/`). This does not affect the published `exports` map, so `import`/`require` usage is unaffected — only projects that deep-imported internal build paths (which were never part of the public `exports`) would be impacted.
|
|
54
|
+
|
|
55
|
+
## 0.0.51
|
|
56
|
+
|
|
57
|
+
### Patch Changes
|
|
58
|
+
|
|
59
|
+
- [#351](https://github.com/toss/react-simplikit/pull/351) [`da1f51c`](https://github.com/toss/react-simplikit/commit/da1f51cc9b860dde91dcfd120605eb6a93de3b55) Thanks [@eunwoo-levi](https://github.com/eunwoo-levi)! - fix(core/hooks): call cleanup when unmount occurs before async effect resolves
|
|
60
|
+
|
|
61
|
+
- [#352](https://github.com/toss/react-simplikit/pull/352) [`fa3daa5`](https://github.com/toss/react-simplikit/commit/fa3daa52d18644ac90a35fc8a79501eae7bb0269) Thanks [@eunwoo-levi](https://github.com/eunwoo-levi)! - fix(core/hooks): prevent immediate callback from re-firing when enabled is toggled
|
|
62
|
+
|
|
63
|
+
## 0.0.50
|
|
64
|
+
|
|
65
|
+
### Patch Changes
|
|
66
|
+
|
|
67
|
+
- [#362](https://github.com/toss/react-simplikit/pull/362) [`fc9b1dc`](https://github.com/toss/react-simplikit/commit/fc9b1dcc2be7902ffe487c5868180317b9f07730) Thanks [@guesung](https://github.com/guesung)! - refactor(core): narrow types in `debounce` utility to reduce `any` usage
|
|
68
|
+
|
|
69
|
+
- [#259](https://github.com/toss/react-simplikit/pull/259) [`1d9ec79`](https://github.com/toss/react-simplikit/commit/1d9ec7984899d1d8dcda16d15efa66f458c347fa) Thanks [@wo-o29](https://github.com/wo-o29)! - refactor(useCounter): extract validateValue as pure function and remove unnecessary useCallback
|
|
70
|
+
|
|
71
|
+
- [#272](https://github.com/toss/react-simplikit/pull/272) [`75ab148`](https://github.com/toss/react-simplikit/commit/75ab1484a1af68a2f27fa31da8f6094f0c63d37f) Thanks [@wo-o29](https://github.com/wo-o29)! - refactor(usePrevious): remove unnecessary `undefined` from compare argument and return type
|
|
72
|
+
|
|
73
|
+
## 0.0.49
|
|
74
|
+
|
|
75
|
+
### Patch Changes
|
|
76
|
+
|
|
77
|
+
- [#339](https://github.com/toss/react-simplikit/pull/339) [`e5f6cac`](https://github.com/toss/react-simplikit/commit/e5f6cacd0bc93c03f361d0c825424937bc141809) Thanks [@sukvvon](https://github.com/sukvvon)! - feat(core/hooks): add 'useSet' hook
|
|
78
|
+
|
|
79
|
+
- [#219](https://github.com/toss/react-simplikit/pull/219) [`2a901bb`](https://github.com/toss/react-simplikit/commit/2a901bb903f4663571c7649769d3e29c9e844332) Thanks [@sukvvon](https://github.com/sukvvon)! - feat(core/hooks): add 'useIsClient' hook
|
|
80
|
+
|
|
81
|
+
- [#273](https://github.com/toss/react-simplikit/pull/273) [`ffc61bb`](https://github.com/toss/react-simplikit/commit/ffc61bb998fdaf129fff12e5e7515007ca5eeb51) Thanks [@wo-o29](https://github.com/wo-o29)! - docs: Add generic type support to useRefEffect interface
|
|
82
|
+
|
|
83
|
+
- [#278](https://github.com/toss/react-simplikit/pull/278) [`278b117`](https://github.com/toss/react-simplikit/commit/278b117152f8f01c54a66fc91c7c4c03fc74f7d9) Thanks [@wo-o29](https://github.com/wo-o29)! - fix: Replace array index keys with child keys in Separated
|
|
84
|
+
|
|
85
|
+
- [#347](https://github.com/toss/react-simplikit/pull/347) [`9a358e2`](https://github.com/toss/react-simplikit/commit/9a358e28e5407ab93c41dec486d932bbc9c42a64) Thanks [@eunwoo-levi](https://github.com/eunwoo-levi)! - use named functions in useEffect callbacks for better stack traces
|
|
86
|
+
|
|
87
|
+
- [#345](https://github.com/toss/react-simplikit/pull/345) [`35d13f8`](https://github.com/toss/react-simplikit/commit/35d13f8fb0aa12dd2c1e5aa15ae18f823ec323fd) Thanks [@eunwoo-levi](https://github.com/eunwoo-levi)! - fix useInterval to use globalThis instead of window for platform independence
|
|
88
|
+
|
|
89
|
+
- [`68e7ac8`](https://github.com/toss/react-simplikit/commit/68e7ac86650026709f2be7498c830dfe5cfdc2e1) Thanks [@sukvvon](https://github.com/sukvvon)! - feat(core/hooks): add 'useList' hook
|
|
90
|
+
|
|
91
|
+
- [`4b0c59e`](https://github.com/toss/react-simplikit/commit/4b0c59edb599406535a479c1f099a272c399ee99) Thanks [@sukvvon](https://github.com/sukvvon)! - feat(core/hooks): add 'useThrottledCallback' hook
|
|
92
|
+
|
|
93
|
+
- [#333](https://github.com/toss/react-simplikit/pull/333) [`4254542`](https://github.com/toss/react-simplikit/commit/4254542e481374c7f0e4de6dbacdfd10f076e529) Thanks [@dlsxjzld](https://github.com/dlsxjzld)! - remove window prefix from setTimeout and clearTimeout for platform-independent
|
|
94
|
+
|
|
95
|
+
## 0.0.48
|
|
96
|
+
|
|
97
|
+
### Patch Changes
|
|
98
|
+
|
|
99
|
+
- [#318](https://github.com/toss/react-simplikit/pull/318) [`466e3ce`](https://github.com/toss/react-simplikit/commit/466e3ceab51a499abb141bc1fe138d9109cc0df5) Thanks [@kimyouknow](https://github.com/kimyouknow)! - Fix broken package exports by moving main/types/module/exports from publishConfig to top-level package.json fields
|
|
100
|
+
|
|
101
|
+
npm does not support publishConfig field overrides for manifest fields like main, types, and exports. The previous versions (react-simplikit@0.0.47, @react-simplikit/mobile@0.0.1) were published with incorrect entry points because publishConfig overrides were not applied during `npm publish`.
|
|
102
|
+
|
|
103
|
+
## 0.0.47
|
|
104
|
+
|
|
105
|
+
### Patch Changes
|
|
106
|
+
|
|
107
|
+
- [#316](https://github.com/toss/react-simplikit/pull/316) [`5b2eeba`](https://github.com/toss/react-simplikit/commit/5b2eeba659206cf9577dd57796a4770d07a33f62) Thanks [@kimyouknow](https://github.com/kimyouknow)! - Deprecate hooks that depend on browser-specific APIs
|
|
108
|
+
|
|
109
|
+
The following hooks are now marked as deprecated:
|
|
110
|
+
|
|
111
|
+
- `useDoubleClick`
|
|
112
|
+
- `useGeolocation`
|
|
113
|
+
- `useImpressionRef`
|
|
114
|
+
- `useIntersectionObserver`
|
|
115
|
+
- `useLongPress`
|
|
116
|
+
- `useOutsideClickEffect`
|
|
117
|
+
- `useStorageState`
|
|
118
|
+
- `useVisibilityEvent`
|
|
119
|
+
|
|
120
|
+
These hooks will be removed in a future major version as react-simplikit is now focused on platform-independent, pure state/logic hooks.
|
|
121
|
+
|
|
122
|
+
## 0.0.46
|
|
123
|
+
|
|
124
|
+
### Patch Changes
|
|
125
|
+
|
|
126
|
+
- [#292](https://github.com/toss/react-simplikit/pull/292) [`afaafd3`](https://github.com/toss/react-simplikit/commit/afaafd397a8c23caf26d8eb3167a31a06a864b2f) Thanks [@kimyouknow](https://github.com/kimyouknow)! - verify changeset automation workflow
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://github.com/toss/react-simplikit/blob/main/LICENSE)
|
|
5
5
|
[](https://codecov.io/gh/toss/react-simplikit)
|
|
6
6
|
|
|
7
|
-
English | [한국어](./README-ko_kr.md)
|
|
7
|
+
English | [한국어](./README-ko_kr.md) | [日本語](./README-ja_jp.md) | [简体中文](./README-zh_hans.md) | [Español](./README-es.md)
|
|
8
8
|
|
|
9
9
|
A lightweight, zero-dependency React utilities library providing hooks, components, and utilities.
|
|
10
10
|
|
|
@@ -16,46 +16,6 @@ A lightweight, zero-dependency React utilities library providing hooks, componen
|
|
|
16
16
|
- **SSR-safe** - Works with Next.js and other SSR frameworks
|
|
17
17
|
- **Tree-shakeable** - Only bundle what you use
|
|
18
18
|
|
|
19
|
-
## Library Direction
|
|
20
|
-
|
|
21
|
-
**react-simplikit is now maintained as a Universal Hook Library providing only pure state/logic hooks.**
|
|
22
|
-
|
|
23
|
-
We are repositioning react-simplikit to focus exclusively on **platform-independent hooks** that work seamlessly across web and mobile (React Native, etc.).
|
|
24
|
-
|
|
25
|
-
### What's Maintained: Pure State/Logic Hooks
|
|
26
|
-
|
|
27
|
-
Hooks that don't depend on specific platform APIs will continue to be actively maintained:
|
|
28
|
-
|
|
29
|
-
- State management hooks like `useToggle`, `useBooleanState`, `useCounter`
|
|
30
|
-
- Lifecycle hooks like `usePrevious`
|
|
31
|
-
- Utility hooks like `useDebounce`, `useThrottle`
|
|
32
|
-
- **Backward compatibility (BC) is preserved** for these existing pure logic hooks
|
|
33
|
-
|
|
34
|
-
### What's Deprecated: Browser/Platform-Dependent Hooks
|
|
35
|
-
|
|
36
|
-
The following hooks that strongly depend on browser-specific APIs are now deprecated:
|
|
37
|
-
|
|
38
|
-
- `useGeolocation` - depends on `navigator.geolocation`
|
|
39
|
-
- `useStorageState` - depends on `localStorage`/`sessionStorage`
|
|
40
|
-
- `useIntersectionObserver` - depends on `IntersectionObserver` API
|
|
41
|
-
- `useImpressionRef` - depends on `IntersectionObserver` + Visibility API
|
|
42
|
-
- `useDoubleClick`, `useLongPress` - depend on DOM events + `window.setTimeout`
|
|
43
|
-
- `useOutsideClickEffect` - depends on DOM events + `document`
|
|
44
|
-
- `useVisibilityEvent` - depends on `document.visibilityState`
|
|
45
|
-
|
|
46
|
-
These hooks:
|
|
47
|
-
|
|
48
|
-
- Will not receive new features or major enhancements
|
|
49
|
-
- Are marked as `@deprecated` in documentation
|
|
50
|
-
- May be removed in future major versions
|
|
51
|
-
|
|
52
|
-
### Package Status
|
|
53
|
-
|
|
54
|
-
- react-simplikit will **not be archived**
|
|
55
|
-
- Pure state/logic hooks will continue to be maintained
|
|
56
|
-
- Critical bug fixes and minimal maintenance will continue
|
|
57
|
-
- No new browser/platform-dependent hooks will be added
|
|
58
|
-
|
|
59
19
|
## Installation
|
|
60
20
|
|
|
61
21
|
```bash
|
|
@@ -132,7 +92,7 @@ Visit [react-simplikit.slash.page](https://react-simplikit.slash.page) for full
|
|
|
132
92
|
|
|
133
93
|
## Related Packages
|
|
134
94
|
|
|
135
|
-
- [
|
|
95
|
+
- [Mobile web utilities](https://react-simplikit.slash.page/mobile/intro.html) - included in `react-simplikit`
|
|
136
96
|
|
|
137
97
|
## Contributing
|
|
138
98
|
|
|
@@ -40,6 +40,7 @@ let react = require("react");
|
|
|
40
40
|
*
|
|
41
41
|
*/
|
|
42
42
|
function useConditionalEffect(effect, deps, condition) {
|
|
43
|
+
"use no memo";
|
|
43
44
|
const prevDepsRef = (0, react.useRef)(void 0);
|
|
44
45
|
const memoizedCondition = (0, react.useCallback)(condition, deps);
|
|
45
46
|
if (deps.length === 0) console.warn("useConditionalEffect received an empty dependency array. This may indicate missing dependencies and could lead to unexpected behavior.");
|
|
@@ -40,6 +40,7 @@ import { useCallback, useEffect, useRef } from "react";
|
|
|
40
40
|
*
|
|
41
41
|
*/
|
|
42
42
|
function useConditionalEffect(effect, deps, condition) {
|
|
43
|
+
"use no memo";
|
|
43
44
|
const prevDepsRef = useRef(void 0);
|
|
44
45
|
const memoizedCondition = useCallback(condition, deps);
|
|
45
46
|
if (deps.length === 0) console.warn("useConditionalEffect received an empty dependency array. This may indicate missing dependencies and could lead to unexpected behavior.");
|
|
@@ -4,31 +4,49 @@ const require_usePreservedCallback = require("../usePreservedCallback/usePreserv
|
|
|
4
4
|
let react = require("react");
|
|
5
5
|
//#region src/hooks/useDebouncedCallback/useDebouncedCallback.ts
|
|
6
6
|
/**
|
|
7
|
+
* Marks that no value has been forwarded to `onChange` yet.
|
|
8
|
+
*
|
|
9
|
+
* The hook skips redundant invocations by comparing against the last forwarded value, but it
|
|
10
|
+
* receives no initial value from the caller. Seeding that comparison with a real value would treat
|
|
11
|
+
* the first call of that value as redundant and swallow it, so an unreachable sentinel is used instead.
|
|
12
|
+
*/
|
|
13
|
+
const NOT_INVOKED = Symbol("NOT_INVOKED");
|
|
14
|
+
/**
|
|
7
15
|
* @description
|
|
8
16
|
* `useDebouncedCallback` is a React hook that returns a debounced version of the provided callback function.
|
|
9
17
|
* It helps optimize event handling by delaying function execution and grouping multiple calls into one.
|
|
10
18
|
*
|
|
11
19
|
* Note that if both 'leading' and 'trailing' are set, the function will be called at both the start and end of the delay period. However, it must be called at least twice within debounceMs interval for this to happen, since one debounced function call cannot trigger the function twice.
|
|
12
20
|
*
|
|
21
|
+
* @template T - The type of the value passed to `onChange`.
|
|
13
22
|
* @param {Object} options - The options object.
|
|
14
|
-
* @param {
|
|
23
|
+
* @param {(newValue: T) => void} options.onChange - The callback to debounce. A call with the same value as the last forwarded one is skipped.
|
|
15
24
|
* @param {number} options.timeThreshold - The number of milliseconds to delay the function execution.
|
|
16
25
|
* @param {boolean} [options.leading=false] - If `true`, the function is called at the start of the sequence.
|
|
17
26
|
* @param {boolean} [options.trailing=true] - If `true`, the function is called at the end of the sequence.
|
|
18
27
|
*
|
|
19
|
-
* @returns {
|
|
28
|
+
* @returns {(nextValue: T) => void} A debounced function that forwards the value to `onChange`.
|
|
20
29
|
*
|
|
21
30
|
* @example
|
|
31
|
+
* import { useDebouncedCallback } from 'react-simplikit';
|
|
32
|
+
* import { useState } from 'react';
|
|
33
|
+
*
|
|
22
34
|
* function SearchInput() {
|
|
23
35
|
* const [query, setQuery] = useState('');
|
|
24
|
-
* const
|
|
25
|
-
*
|
|
36
|
+
* const setQueryDebounced = useDebouncedCallback({ onChange: setQuery, timeThreshold: 300 });
|
|
37
|
+
*
|
|
38
|
+
* return (
|
|
39
|
+
* <>
|
|
40
|
+
* <input onChange={e => setQueryDebounced(e.target.value)} />
|
|
41
|
+
* <p>Searching for: {query}</p>
|
|
42
|
+
* </>
|
|
43
|
+
* );
|
|
26
44
|
* }
|
|
27
45
|
*/
|
|
28
46
|
function useDebouncedCallback({ onChange, timeThreshold, leading = false, trailing = true }) {
|
|
29
47
|
const handleChange = require_usePreservedCallback.usePreservedCallback(onChange);
|
|
30
48
|
const ref = (0, react.useRef)({
|
|
31
|
-
value:
|
|
49
|
+
value: NOT_INVOKED,
|
|
32
50
|
clearPreviousDebounce: () => {}
|
|
33
51
|
});
|
|
34
52
|
(0, react.useEffect)(function clearDebouncedOnUnmount() {
|
|
@@ -44,12 +62,12 @@ function useDebouncedCallback({ onChange, timeThreshold, leading = false, traili
|
|
|
44
62
|
return _edges;
|
|
45
63
|
}, [leading, trailing]);
|
|
46
64
|
return (0, react.useCallback)((nextValue) => {
|
|
65
|
+
ref.current.clearPreviousDebounce();
|
|
47
66
|
if (nextValue === ref.current.value) return;
|
|
48
67
|
const debounced = require_debounce.debounce(() => {
|
|
49
68
|
handleChange(nextValue);
|
|
50
69
|
ref.current.value = nextValue;
|
|
51
70
|
}, timeThreshold, { edges });
|
|
52
|
-
ref.current.clearPreviousDebounce();
|
|
53
71
|
debounced();
|
|
54
72
|
ref.current.clearPreviousDebounce = debounced.cancel;
|
|
55
73
|
}, [
|
|
@@ -11,24 +11,34 @@ type DebounceOptions = {
|
|
|
11
11
|
*
|
|
12
12
|
* Note that if both 'leading' and 'trailing' are set, the function will be called at both the start and end of the delay period. However, it must be called at least twice within debounceMs interval for this to happen, since one debounced function call cannot trigger the function twice.
|
|
13
13
|
*
|
|
14
|
+
* @template T - The type of the value passed to `onChange`.
|
|
14
15
|
* @param {Object} options - The options object.
|
|
15
|
-
* @param {
|
|
16
|
+
* @param {(newValue: T) => void} options.onChange - The callback to debounce. A call with the same value as the last forwarded one is skipped.
|
|
16
17
|
* @param {number} options.timeThreshold - The number of milliseconds to delay the function execution.
|
|
17
18
|
* @param {boolean} [options.leading=false] - If `true`, the function is called at the start of the sequence.
|
|
18
19
|
* @param {boolean} [options.trailing=true] - If `true`, the function is called at the end of the sequence.
|
|
19
20
|
*
|
|
20
|
-
* @returns {
|
|
21
|
+
* @returns {(nextValue: T) => void} A debounced function that forwards the value to `onChange`.
|
|
21
22
|
*
|
|
22
23
|
* @example
|
|
24
|
+
* import { useDebouncedCallback } from 'react-simplikit';
|
|
25
|
+
* import { useState } from 'react';
|
|
26
|
+
*
|
|
23
27
|
* function SearchInput() {
|
|
24
28
|
* const [query, setQuery] = useState('');
|
|
25
|
-
* const
|
|
26
|
-
*
|
|
29
|
+
* const setQueryDebounced = useDebouncedCallback({ onChange: setQuery, timeThreshold: 300 });
|
|
30
|
+
*
|
|
31
|
+
* return (
|
|
32
|
+
* <>
|
|
33
|
+
* <input onChange={e => setQueryDebounced(e.target.value)} />
|
|
34
|
+
* <p>Searching for: {query}</p>
|
|
35
|
+
* </>
|
|
36
|
+
* );
|
|
27
37
|
* }
|
|
28
38
|
*/
|
|
29
|
-
declare function useDebouncedCallback({ onChange, timeThreshold, leading, trailing }: DebounceOptions & {
|
|
30
|
-
onChange: (newValue:
|
|
39
|
+
declare function useDebouncedCallback<T>({ onChange, timeThreshold, leading, trailing }: DebounceOptions & {
|
|
40
|
+
onChange: (newValue: T) => void;
|
|
31
41
|
timeThreshold: number;
|
|
32
|
-
}): (nextValue:
|
|
42
|
+
}): (nextValue: T) => void;
|
|
33
43
|
//#endregion
|
|
34
44
|
export { useDebouncedCallback };
|
|
@@ -11,24 +11,34 @@ type DebounceOptions = {
|
|
|
11
11
|
*
|
|
12
12
|
* Note that if both 'leading' and 'trailing' are set, the function will be called at both the start and end of the delay period. However, it must be called at least twice within debounceMs interval for this to happen, since one debounced function call cannot trigger the function twice.
|
|
13
13
|
*
|
|
14
|
+
* @template T - The type of the value passed to `onChange`.
|
|
14
15
|
* @param {Object} options - The options object.
|
|
15
|
-
* @param {
|
|
16
|
+
* @param {(newValue: T) => void} options.onChange - The callback to debounce. A call with the same value as the last forwarded one is skipped.
|
|
16
17
|
* @param {number} options.timeThreshold - The number of milliseconds to delay the function execution.
|
|
17
18
|
* @param {boolean} [options.leading=false] - If `true`, the function is called at the start of the sequence.
|
|
18
19
|
* @param {boolean} [options.trailing=true] - If `true`, the function is called at the end of the sequence.
|
|
19
20
|
*
|
|
20
|
-
* @returns {
|
|
21
|
+
* @returns {(nextValue: T) => void} A debounced function that forwards the value to `onChange`.
|
|
21
22
|
*
|
|
22
23
|
* @example
|
|
24
|
+
* import { useDebouncedCallback } from 'react-simplikit';
|
|
25
|
+
* import { useState } from 'react';
|
|
26
|
+
*
|
|
23
27
|
* function SearchInput() {
|
|
24
28
|
* const [query, setQuery] = useState('');
|
|
25
|
-
* const
|
|
26
|
-
*
|
|
29
|
+
* const setQueryDebounced = useDebouncedCallback({ onChange: setQuery, timeThreshold: 300 });
|
|
30
|
+
*
|
|
31
|
+
* return (
|
|
32
|
+
* <>
|
|
33
|
+
* <input onChange={e => setQueryDebounced(e.target.value)} />
|
|
34
|
+
* <p>Searching for: {query}</p>
|
|
35
|
+
* </>
|
|
36
|
+
* );
|
|
27
37
|
* }
|
|
28
38
|
*/
|
|
29
|
-
declare function useDebouncedCallback({ onChange, timeThreshold, leading, trailing }: DebounceOptions & {
|
|
30
|
-
onChange: (newValue:
|
|
39
|
+
declare function useDebouncedCallback<T>({ onChange, timeThreshold, leading, trailing }: DebounceOptions & {
|
|
40
|
+
onChange: (newValue: T) => void;
|
|
31
41
|
timeThreshold: number;
|
|
32
|
-
}): (nextValue:
|
|
42
|
+
}): (nextValue: T) => void;
|
|
33
43
|
//#endregion
|
|
34
44
|
export { useDebouncedCallback };
|
|
@@ -4,31 +4,49 @@ import { usePreservedCallback } from "../usePreservedCallback/usePreservedCallba
|
|
|
4
4
|
import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
5
5
|
//#region src/hooks/useDebouncedCallback/useDebouncedCallback.ts
|
|
6
6
|
/**
|
|
7
|
+
* Marks that no value has been forwarded to `onChange` yet.
|
|
8
|
+
*
|
|
9
|
+
* The hook skips redundant invocations by comparing against the last forwarded value, but it
|
|
10
|
+
* receives no initial value from the caller. Seeding that comparison with a real value would treat
|
|
11
|
+
* the first call of that value as redundant and swallow it, so an unreachable sentinel is used instead.
|
|
12
|
+
*/
|
|
13
|
+
const NOT_INVOKED = Symbol("NOT_INVOKED");
|
|
14
|
+
/**
|
|
7
15
|
* @description
|
|
8
16
|
* `useDebouncedCallback` is a React hook that returns a debounced version of the provided callback function.
|
|
9
17
|
* It helps optimize event handling by delaying function execution and grouping multiple calls into one.
|
|
10
18
|
*
|
|
11
19
|
* Note that if both 'leading' and 'trailing' are set, the function will be called at both the start and end of the delay period. However, it must be called at least twice within debounceMs interval for this to happen, since one debounced function call cannot trigger the function twice.
|
|
12
20
|
*
|
|
21
|
+
* @template T - The type of the value passed to `onChange`.
|
|
13
22
|
* @param {Object} options - The options object.
|
|
14
|
-
* @param {
|
|
23
|
+
* @param {(newValue: T) => void} options.onChange - The callback to debounce. A call with the same value as the last forwarded one is skipped.
|
|
15
24
|
* @param {number} options.timeThreshold - The number of milliseconds to delay the function execution.
|
|
16
25
|
* @param {boolean} [options.leading=false] - If `true`, the function is called at the start of the sequence.
|
|
17
26
|
* @param {boolean} [options.trailing=true] - If `true`, the function is called at the end of the sequence.
|
|
18
27
|
*
|
|
19
|
-
* @returns {
|
|
28
|
+
* @returns {(nextValue: T) => void} A debounced function that forwards the value to `onChange`.
|
|
20
29
|
*
|
|
21
30
|
* @example
|
|
31
|
+
* import { useDebouncedCallback } from 'react-simplikit';
|
|
32
|
+
* import { useState } from 'react';
|
|
33
|
+
*
|
|
22
34
|
* function SearchInput() {
|
|
23
35
|
* const [query, setQuery] = useState('');
|
|
24
|
-
* const
|
|
25
|
-
*
|
|
36
|
+
* const setQueryDebounced = useDebouncedCallback({ onChange: setQuery, timeThreshold: 300 });
|
|
37
|
+
*
|
|
38
|
+
* return (
|
|
39
|
+
* <>
|
|
40
|
+
* <input onChange={e => setQueryDebounced(e.target.value)} />
|
|
41
|
+
* <p>Searching for: {query}</p>
|
|
42
|
+
* </>
|
|
43
|
+
* );
|
|
26
44
|
* }
|
|
27
45
|
*/
|
|
28
46
|
function useDebouncedCallback({ onChange, timeThreshold, leading = false, trailing = true }) {
|
|
29
47
|
const handleChange = usePreservedCallback(onChange);
|
|
30
48
|
const ref = useRef({
|
|
31
|
-
value:
|
|
49
|
+
value: NOT_INVOKED,
|
|
32
50
|
clearPreviousDebounce: () => {}
|
|
33
51
|
});
|
|
34
52
|
useEffect(function clearDebouncedOnUnmount() {
|
|
@@ -44,12 +62,12 @@ function useDebouncedCallback({ onChange, timeThreshold, leading = false, traili
|
|
|
44
62
|
return _edges;
|
|
45
63
|
}, [leading, trailing]);
|
|
46
64
|
return useCallback((nextValue) => {
|
|
65
|
+
ref.current.clearPreviousDebounce();
|
|
47
66
|
if (nextValue === ref.current.value) return;
|
|
48
67
|
const debounced = debounce(() => {
|
|
49
68
|
handleChange(nextValue);
|
|
50
69
|
ref.current.value = nextValue;
|
|
51
70
|
}, timeThreshold, { edges });
|
|
52
|
-
ref.current.clearPreviousDebounce();
|
|
53
71
|
debounced();
|
|
54
72
|
ref.current.clearPreviousDebounce = debounced.cancel;
|
|
55
73
|
}, [
|
|
@@ -3,10 +3,6 @@ const require_usePreservedCallback = require("../usePreservedCallback/usePreserv
|
|
|
3
3
|
let react = require("react");
|
|
4
4
|
//#region src/hooks/useDoubleClick/useDoubleClick.ts
|
|
5
5
|
/**
|
|
6
|
-
* @deprecated This hook is deprecated as it depends on browser-specific APIs (DOM events, window.setTimeout).
|
|
7
|
-
* react-simplikit is now focused on platform-independent, pure state/logic hooks.
|
|
8
|
-
* This hook will be removed in a future major version.
|
|
9
|
-
*
|
|
10
6
|
* @description
|
|
11
7
|
* `useDoubleClick` is a React hook that differentiates between single and double click events.
|
|
12
8
|
* It delays the single click callback execution for a specified time, and cancels it if a second click (i.e. a double click) occurs within that time.
|
|
@@ -7,10 +7,6 @@ type UseDoubleClickProps<E extends HTMLElement> = {
|
|
|
7
7
|
doubleClick: (event: MouseEvent<E>) => void;
|
|
8
8
|
};
|
|
9
9
|
/**
|
|
10
|
-
* @deprecated This hook is deprecated as it depends on browser-specific APIs (DOM events, window.setTimeout).
|
|
11
|
-
* react-simplikit is now focused on platform-independent, pure state/logic hooks.
|
|
12
|
-
* This hook will be removed in a future major version.
|
|
13
|
-
*
|
|
14
10
|
* @description
|
|
15
11
|
* `useDoubleClick` is a React hook that differentiates between single and double click events.
|
|
16
12
|
* It delays the single click callback execution for a specified time, and cancels it if a second click (i.e. a double click) occurs within that time.
|
|
@@ -7,10 +7,6 @@ type UseDoubleClickProps<E extends HTMLElement> = {
|
|
|
7
7
|
doubleClick: (event: MouseEvent<E>) => void;
|
|
8
8
|
};
|
|
9
9
|
/**
|
|
10
|
-
* @deprecated This hook is deprecated as it depends on browser-specific APIs (DOM events, window.setTimeout).
|
|
11
|
-
* react-simplikit is now focused on platform-independent, pure state/logic hooks.
|
|
12
|
-
* This hook will be removed in a future major version.
|
|
13
|
-
*
|
|
14
10
|
* @description
|
|
15
11
|
* `useDoubleClick` is a React hook that differentiates between single and double click events.
|
|
16
12
|
* It delays the single click callback execution for a specified time, and cancels it if a second click (i.e. a double click) occurs within that time.
|
|
@@ -3,10 +3,6 @@ import { usePreservedCallback } from "../usePreservedCallback/usePreservedCallba
|
|
|
3
3
|
import { useCallback, useEffect, useRef } from "react";
|
|
4
4
|
//#region src/hooks/useDoubleClick/useDoubleClick.ts
|
|
5
5
|
/**
|
|
6
|
-
* @deprecated This hook is deprecated as it depends on browser-specific APIs (DOM events, window.setTimeout).
|
|
7
|
-
* react-simplikit is now focused on platform-independent, pure state/logic hooks.
|
|
8
|
-
* This hook will be removed in a future major version.
|
|
9
|
-
*
|
|
10
6
|
* @description
|
|
11
7
|
* `useDoubleClick` is a React hook that differentiates between single and double click events.
|
|
12
8
|
* It delays the single click callback execution for a specified time, and cancels it if a second click (i.e. a double click) occurs within that time.
|
|
@@ -14,10 +14,6 @@ const GeolocationMountBehavior = {
|
|
|
14
14
|
WATCH: "watch"
|
|
15
15
|
};
|
|
16
16
|
/**
|
|
17
|
-
* @deprecated This hook is deprecated as it depends on browser-specific APIs (navigator.geolocation).
|
|
18
|
-
* react-simplikit is now focused on platform-independent, pure state/logic hooks.
|
|
19
|
-
* This hook will be removed in a future major version.
|
|
20
|
-
*
|
|
21
17
|
* @description
|
|
22
18
|
* `useGeolocation` is a React hook that retrieves and tracks the user's geographical location.
|
|
23
19
|
* It uses the browser's `Geolocation API` to support both one-time position retrieval and continuous location tracking.
|
|
@@ -26,10 +26,6 @@ type GeolocationOptions = {
|
|
|
26
26
|
mountBehavior?: GeolocationMountBehaviorType;
|
|
27
27
|
} & PositionOptions;
|
|
28
28
|
/**
|
|
29
|
-
* @deprecated This hook is deprecated as it depends on browser-specific APIs (navigator.geolocation).
|
|
30
|
-
* react-simplikit is now focused on platform-independent, pure state/logic hooks.
|
|
31
|
-
* This hook will be removed in a future major version.
|
|
32
|
-
*
|
|
33
29
|
* @description
|
|
34
30
|
* `useGeolocation` is a React hook that retrieves and tracks the user's geographical location.
|
|
35
31
|
* It uses the browser's `Geolocation API` to support both one-time position retrieval and continuous location tracking.
|
|
@@ -26,10 +26,6 @@ type GeolocationOptions = {
|
|
|
26
26
|
mountBehavior?: GeolocationMountBehaviorType;
|
|
27
27
|
} & PositionOptions;
|
|
28
28
|
/**
|
|
29
|
-
* @deprecated This hook is deprecated as it depends on browser-specific APIs (navigator.geolocation).
|
|
30
|
-
* react-simplikit is now focused on platform-independent, pure state/logic hooks.
|
|
31
|
-
* This hook will be removed in a future major version.
|
|
32
|
-
*
|
|
33
29
|
* @description
|
|
34
30
|
* `useGeolocation` is a React hook that retrieves and tracks the user's geographical location.
|
|
35
31
|
* It uses the browser's `Geolocation API` to support both one-time position retrieval and continuous location tracking.
|
|
@@ -14,10 +14,6 @@ const GeolocationMountBehavior = {
|
|
|
14
14
|
WATCH: "watch"
|
|
15
15
|
};
|
|
16
16
|
/**
|
|
17
|
-
* @deprecated This hook is deprecated as it depends on browser-specific APIs (navigator.geolocation).
|
|
18
|
-
* react-simplikit is now focused on platform-independent, pure state/logic hooks.
|
|
19
|
-
* This hook will be removed in a future major version.
|
|
20
|
-
*
|
|
21
17
|
* @description
|
|
22
18
|
* `useGeolocation` is a React hook that retrieves and tracks the user's geographical location.
|
|
23
19
|
* It uses the browser's `Geolocation API` to support both one-time position retrieval and continuous location tracking.
|
|
@@ -6,10 +6,6 @@ const require_useVisibilityEvent = require("../useVisibilityEvent/useVisibilityE
|
|
|
6
6
|
let react = require("react");
|
|
7
7
|
//#region src/hooks/useImpressionRef/useImpressionRef.ts
|
|
8
8
|
/**
|
|
9
|
-
* @deprecated This hook is deprecated as it depends on browser-specific APIs (IntersectionObserver, Visibility API).
|
|
10
|
-
* react-simplikit is now focused on platform-independent, pure state/logic hooks.
|
|
11
|
-
* This hook will be removed in a future major version.
|
|
12
|
-
*
|
|
13
9
|
* @description
|
|
14
10
|
* `useImpressionRef` is a React hook that measures the time a specific DOM element is visible on the screen and executes callbacks when the element enters or exits the viewport.
|
|
15
11
|
* It uses `IntersectionObserver` and the `Visibility API` to track the element's visibility.
|
|
@@ -41,10 +37,16 @@ function useImpressionRef({ onImpressionStart = () => {}, onImpressionEnd = () =
|
|
|
41
37
|
const impressionStartHandler = require_usePreservedCallback.usePreservedCallback(onImpressionStart);
|
|
42
38
|
const impressionEndHandler = require_usePreservedCallback.usePreservedCallback(onImpressionEnd);
|
|
43
39
|
const isIntersectingRef = (0, react.useRef)(false);
|
|
40
|
+
const hasImpressionStartedRef = (0, react.useRef)(false);
|
|
44
41
|
const impressionEventHandler = require_useDebouncedCallback.useDebouncedCallback({
|
|
45
42
|
timeThreshold,
|
|
46
43
|
onChange: (impressed) => {
|
|
47
|
-
(impressed
|
|
44
|
+
if (impressed) {
|
|
45
|
+
hasImpressionStartedRef.current = true;
|
|
46
|
+
impressionStartHandler();
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (hasImpressionStartedRef.current) impressionEndHandler();
|
|
48
50
|
},
|
|
49
51
|
leading: true
|
|
50
52
|
});
|
|
@@ -8,10 +8,6 @@ type UseImpressionRefOptions = Partial<{
|
|
|
8
8
|
timeThreshold: number;
|
|
9
9
|
}>;
|
|
10
10
|
/**
|
|
11
|
-
* @deprecated This hook is deprecated as it depends on browser-specific APIs (IntersectionObserver, Visibility API).
|
|
12
|
-
* react-simplikit is now focused on platform-independent, pure state/logic hooks.
|
|
13
|
-
* This hook will be removed in a future major version.
|
|
14
|
-
*
|
|
15
11
|
* @description
|
|
16
12
|
* `useImpressionRef` is a React hook that measures the time a specific DOM element is visible on the screen and executes callbacks when the element enters or exits the viewport.
|
|
17
13
|
* It uses `IntersectionObserver` and the `Visibility API` to track the element's visibility.
|
|
@@ -8,10 +8,6 @@ type UseImpressionRefOptions = Partial<{
|
|
|
8
8
|
timeThreshold: number;
|
|
9
9
|
}>;
|
|
10
10
|
/**
|
|
11
|
-
* @deprecated This hook is deprecated as it depends on browser-specific APIs (IntersectionObserver, Visibility API).
|
|
12
|
-
* react-simplikit is now focused on platform-independent, pure state/logic hooks.
|
|
13
|
-
* This hook will be removed in a future major version.
|
|
14
|
-
*
|
|
15
11
|
* @description
|
|
16
12
|
* `useImpressionRef` is a React hook that measures the time a specific DOM element is visible on the screen and executes callbacks when the element enters or exits the viewport.
|
|
17
13
|
* It uses `IntersectionObserver` and the `Visibility API` to track the element's visibility.
|