react-native-keyboard-controller 1.13.3 → 1.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/README.md +1 -0
  2. package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +5 -3
  3. package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerViewManager.kt +19 -20
  4. package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardGestureAreaViewManager.kt +22 -12
  5. package/android/src/fabric/java/com/reactnativekeyboardcontroller/OverKeyboardViewManager.kt +40 -0
  6. package/android/src/fabric/java/com/reactnativekeyboardcontroller/StatusBarManagerCompatModule.kt +7 -3
  7. package/android/src/main/java/com/reactnativekeyboardcontroller/KeyboardControllerPackage.kt +33 -27
  8. package/android/src/main/java/com/reactnativekeyboardcontroller/events/FocusedInputLayoutChangedEvent.kt +16 -15
  9. package/android/src/main/java/com/reactnativekeyboardcontroller/events/FocusedInputSelectionChangedEvent.kt +25 -24
  10. package/android/src/main/java/com/reactnativekeyboardcontroller/events/FocusedInputTextChangedEvent.kt +4 -3
  11. package/android/src/main/java/com/reactnativekeyboardcontroller/events/KeyboardTransitionEvent.kt +7 -6
  12. package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/Context.kt +38 -0
  13. package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/EditText.kt +82 -62
  14. package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/ReactContext.kt +9 -4
  15. package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/ThemedReactContext.kt +12 -5
  16. package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/View.kt +12 -10
  17. package/android/src/main/java/com/reactnativekeyboardcontroller/interactive/KeyboardAnimationController.kt +65 -60
  18. package/android/src/main/java/com/reactnativekeyboardcontroller/interactive/interpolators/Interpolator.kt +6 -1
  19. package/android/src/main/java/com/reactnativekeyboardcontroller/interactive/interpolators/IosInterpolator.kt +4 -2
  20. package/android/src/main/java/com/reactnativekeyboardcontroller/interactive/interpolators/LinearInterpolator.kt +1 -3
  21. package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/FocusedInputObserver.kt +62 -58
  22. package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/KeyboardAnimationCallback.kt +52 -46
  23. package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/WindowDimensionListener.kt +13 -7
  24. package/android/src/main/java/com/reactnativekeyboardcontroller/log/Logger.kt +28 -0
  25. package/android/src/main/java/com/reactnativekeyboardcontroller/managers/KeyboardControllerViewManagerImpl.kt +35 -24
  26. package/android/src/main/java/com/reactnativekeyboardcontroller/managers/KeyboardGestureAreaViewManagerImpl.kt +21 -8
  27. package/android/src/main/java/com/reactnativekeyboardcontroller/managers/OverKeyboardViewManagerImpl.kt +27 -0
  28. package/android/src/main/java/com/reactnativekeyboardcontroller/modal/ModalAttachedWatcher.kt +15 -13
  29. package/android/src/main/java/com/reactnativekeyboardcontroller/modules/KeyboardControllerModuleImpl.kt +8 -8
  30. package/android/src/main/java/com/reactnativekeyboardcontroller/modules/StatusBarManagerCompatModuleImpl.kt +10 -5
  31. package/android/src/main/java/com/reactnativekeyboardcontroller/traversal/FocusedInputHolder.kt +1 -3
  32. package/android/src/main/java/com/reactnativekeyboardcontroller/traversal/ViewHierarchyNavigator.kt +19 -13
  33. package/android/src/main/java/com/reactnativekeyboardcontroller/ui/FrameScheduler.kt +11 -8
  34. package/android/src/main/java/com/reactnativekeyboardcontroller/views/EdgeToEdgeReactViewGroup.kt +24 -19
  35. package/android/src/main/java/com/reactnativekeyboardcontroller/views/KeyboardGestureAreaReactViewGroup.kt +23 -14
  36. package/android/src/main/java/com/reactnativekeyboardcontroller/views/overlay/OverKeyboardHostShadowNode.kt +30 -0
  37. package/android/src/main/java/com/reactnativekeyboardcontroller/views/overlay/OverKeyboardViewGroup.kt +185 -0
  38. package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +3 -1
  39. package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardControllerViewManager.kt +19 -10
  40. package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardGestureAreaViewManager.kt +21 -8
  41. package/android/src/paper/java/com/reactnativekeyboardcontroller/OverKeyboardViewManager.kt +33 -0
  42. package/android/src/paper/java/com/reactnativekeyboardcontroller/StatusBarManagerCompatModule.kt +7 -3
  43. package/android/src/test/java/com/reactnativekeyboardcontroller/traversal/ViewHierarchyNavigatorTest.kt +30 -21
  44. package/ios/KeyboardController-Bridging-Header.h +1 -0
  45. package/ios/extensions/UIResponder.swift +0 -3
  46. package/ios/extensions/UIWindow.swift +48 -0
  47. package/ios/views/OverKeyboardViewManager.h +29 -0
  48. package/ios/views/OverKeyboardViewManager.mm +220 -0
  49. package/jest/index.js +1 -0
  50. package/lib/commonjs/bindings.js +2 -1
  51. package/lib/commonjs/bindings.js.map +1 -1
  52. package/lib/commonjs/bindings.native.js +2 -1
  53. package/lib/commonjs/bindings.native.js.map +1 -1
  54. package/lib/commonjs/components/KeyboardAwareScrollView/index.js +2 -1
  55. package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -1
  56. package/lib/commonjs/components/KeyboardToolbar/index.js +5 -3
  57. package/lib/commonjs/components/KeyboardToolbar/index.js.map +1 -1
  58. package/lib/commonjs/hooks/index.js +2 -4
  59. package/lib/commonjs/hooks/index.js.map +1 -1
  60. package/lib/commonjs/index.js +9 -1
  61. package/lib/commonjs/index.js.map +1 -1
  62. package/lib/commonjs/internal.js +24 -12
  63. package/lib/commonjs/internal.js.map +1 -1
  64. package/lib/commonjs/specs/OverKeyboardViewNativeComponent.js +10 -0
  65. package/lib/commonjs/specs/OverKeyboardViewNativeComponent.js.map +1 -0
  66. package/lib/commonjs/types.js.map +1 -1
  67. package/lib/commonjs/views/OverKeyboardView/index.js +43 -0
  68. package/lib/commonjs/views/OverKeyboardView/index.js.map +1 -0
  69. package/lib/commonjs/views/index.js +14 -0
  70. package/lib/commonjs/views/index.js.map +1 -0
  71. package/lib/module/bindings.js +1 -0
  72. package/lib/module/bindings.js.map +1 -1
  73. package/lib/module/bindings.native.js +1 -0
  74. package/lib/module/bindings.native.js.map +1 -1
  75. package/lib/module/components/KeyboardAwareScrollView/index.js +2 -1
  76. package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -1
  77. package/lib/module/components/KeyboardToolbar/index.js +5 -3
  78. package/lib/module/components/KeyboardToolbar/index.js.map +1 -1
  79. package/lib/module/hooks/index.js +3 -4
  80. package/lib/module/hooks/index.js.map +1 -1
  81. package/lib/module/index.js +1 -0
  82. package/lib/module/index.js.map +1 -1
  83. package/lib/module/internal.js +24 -12
  84. package/lib/module/internal.js.map +1 -1
  85. package/lib/module/specs/OverKeyboardViewNativeComponent.js +3 -0
  86. package/lib/module/specs/OverKeyboardViewNativeComponent.js.map +1 -0
  87. package/lib/module/types.js.map +1 -1
  88. package/lib/module/views/OverKeyboardView/index.js +35 -0
  89. package/lib/module/views/OverKeyboardView/index.js.map +1 -0
  90. package/lib/module/views/index.js +2 -0
  91. package/lib/module/views/index.js.map +1 -0
  92. package/lib/typescript/bindings.d.ts +2 -1
  93. package/lib/typescript/bindings.native.d.ts +2 -1
  94. package/lib/typescript/components/KeyboardAwareScrollView/index.d.ts +4 -0
  95. package/lib/typescript/components/KeyboardToolbar/index.d.ts +2 -2
  96. package/lib/typescript/index.d.ts +1 -0
  97. package/lib/typescript/specs/OverKeyboardViewNativeComponent.d.ts +7 -0
  98. package/lib/typescript/types.d.ts +4 -1
  99. package/lib/typescript/views/OverKeyboardView/index.d.ts +5 -0
  100. package/lib/typescript/views/index.d.ts +1 -0
  101. package/package.json +8 -3
  102. package/src/bindings.native.ts +3 -0
  103. package/src/bindings.ts +3 -0
  104. package/src/components/KeyboardAwareScrollView/index.tsx +5 -2
  105. package/src/components/KeyboardToolbar/index.tsx +7 -3
  106. package/src/hooks/index.ts +3 -5
  107. package/src/index.ts +1 -0
  108. package/src/internal.ts +34 -15
  109. package/src/specs/OverKeyboardViewNativeComponent.ts +12 -0
  110. package/src/types.ts +4 -0
  111. package/src/views/OverKeyboardView/index.tsx +43 -0
  112. package/src/views/index.ts +1 -0
  113. package/ios/.clang-format +0 -90
  114. package/ios/.swiftformat +0 -5
  115. package/ios/.swiftlint.yml +0 -14
  116. package/lib/commonjs/hooks/useSyncEffect/index.js +0 -37
  117. package/lib/commonjs/hooks/useSyncEffect/index.js.map +0 -1
  118. package/lib/module/hooks/useSyncEffect/index.js +0 -31
  119. package/lib/module/hooks/useSyncEffect/index.js.map +0 -1
  120. package/lib/typescript/hooks/useSyncEffect/index.d.ts +0 -14
  121. package/src/hooks/useSyncEffect/index.ts +0 -36
package/ios/.clang-format DELETED
@@ -1,90 +0,0 @@
1
- ---
2
- AccessModifierOffset: -1
3
- AlignAfterOpenBracket: AlwaysBreak
4
- AlignConsecutiveAssignments: false
5
- AlignConsecutiveDeclarations: false
6
- AlignEscapedNewlinesLeft: true
7
- AlignOperands: false
8
- AlignTrailingComments: false
9
- AllowAllParametersOfDeclarationOnNextLine: false
10
- AllowShortBlocksOnASingleLine: false
11
- AllowShortCaseLabelsOnASingleLine: false
12
- AllowShortFunctionsOnASingleLine: Empty
13
- AllowShortIfStatementsOnASingleLine: false
14
- AllowShortLoopsOnASingleLine: false
15
- AlwaysBreakAfterReturnType: None
16
- AlwaysBreakBeforeMultilineStrings: true
17
- AlwaysBreakTemplateDeclarations: true
18
- BinPackArguments: false
19
- BinPackParameters: false
20
- BraceWrapping:
21
- AfterClass: false
22
- AfterControlStatement: false
23
- AfterEnum: false
24
- AfterFunction: false
25
- AfterNamespace: false
26
- AfterObjCDeclaration: false
27
- AfterStruct: false
28
- AfterUnion: false
29
- BeforeCatch: false
30
- BeforeElse: false
31
- IndentBraces: false
32
- BreakBeforeBinaryOperators: None
33
- BreakBeforeBraces: Attach
34
- BreakBeforeTernaryOperators: true
35
- BreakConstructorInitializersBeforeComma: false
36
- BreakAfterJavaFieldAnnotations: false
37
- BreakStringLiterals: false
38
- ColumnLimit: 80
39
- CommentPragmas: "^ IWYU pragma:"
40
- ConstructorInitializerAllOnOneLineOrOnePerLine: true
41
- ConstructorInitializerIndentWidth: 4
42
- ContinuationIndentWidth: 4
43
- Cpp11BracedListStyle: true
44
- DerivePointerAlignment: false
45
- DisableFormat: false
46
- ForEachMacros: [FOR_EACH_RANGE, FOR_EACH]
47
- IncludeCategories:
48
- - Regex: '^<.*\.h(pp)?>'
49
- Priority: 1
50
- - Regex: "^<.*"
51
- Priority: 2
52
- - Regex: ".*"
53
- Priority: 3
54
- IndentCaseLabels: true
55
- IndentWidth: 2
56
- IndentWrappedFunctionNames: false
57
- KeepEmptyLinesAtTheStartOfBlocks: false
58
- MacroBlockBegin: ""
59
- MacroBlockEnd: ""
60
- MaxEmptyLinesToKeep: 1
61
- NamespaceIndentation: None
62
- ObjCBlockIndentWidth: 2
63
- ObjCSpaceAfterProperty: true
64
- ObjCSpaceBeforeProtocolList: true
65
- PenaltyBreakBeforeFirstCallParameter: 1
66
- PenaltyBreakComment: 300
67
- PenaltyBreakFirstLessLess: 120
68
- PenaltyBreakString: 1000
69
- PenaltyExcessCharacter: 1000000
70
- PenaltyReturnTypeOnItsOwnLine: 200
71
- PointerAlignment: Right
72
- ReflowComments: true
73
- SortIncludes: true
74
- SpaceAfterCStyleCast: false
75
- SpaceBeforeAssignmentOperators: true
76
- SpaceBeforeParens: ControlStatements
77
- SpaceInEmptyParentheses: false
78
- SpacesBeforeTrailingComments: 1
79
- SpacesInAngles: false
80
- SpacesInContainerLiterals: true
81
- SpacesInCStyleCastParentheses: false
82
- SpacesInParentheses: false
83
- SpacesInSquareBrackets: false
84
- Standard: Cpp11
85
- TabWidth: 8
86
- UseTab: Never
87
- ---
88
- Language: ObjC
89
- ColumnLimit: 100
90
- BreakBeforeBraces: WebKit
package/ios/.swiftformat DELETED
@@ -1,5 +0,0 @@
1
- --indent 2
2
-
3
- --disable redundantReturn
4
-
5
- --exclude Pods,Generated
@@ -1,14 +0,0 @@
1
- disabled_rules:
2
- - trailing_comma
3
- - for_where
4
-
5
- line_length:
6
- warning: 120
7
- ignores_urls: true
8
-
9
- identifier_name:
10
- excluded:
11
- - i # allow `i` variable in cycles
12
-
13
- excluded:
14
- - Pods
@@ -1,37 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _react = require("react");
8
- /**
9
- * @description
10
- * Equivalent to `useEffect` but will run the effect synchronously, i. e. before render.
11
- *
12
- * @param {effect} - imperative function
13
- * @param {deps} - if present, effect will only activate if the values in the list change
14
- *
15
- * @author Kiryl Ziusko
16
- * @since 1.13.0
17
- * @version 1.0.0
18
- */
19
- const useSyncEffect = (effect, deps) => {
20
- const cachedDeps = (0, _react.useRef)(null);
21
- const areDepsEqual = deps === null || deps === void 0 ? void 0 : deps.every((el, index) => cachedDeps.current && el === cachedDeps.current[index]);
22
- const cleanupRef = (0, _react.useRef)();
23
- if (!areDepsEqual || !cachedDeps.current) {
24
- var _cleanupRef$current;
25
- (_cleanupRef$current = cleanupRef.current) === null || _cleanupRef$current === void 0 || _cleanupRef$current.call(cleanupRef);
26
- cleanupRef.current = effect();
27
- cachedDeps.current = deps;
28
- }
29
- (0, _react.useEffect)(() => {
30
- return () => {
31
- var _cleanupRef$current2;
32
- (_cleanupRef$current2 = cleanupRef.current) === null || _cleanupRef$current2 === void 0 || _cleanupRef$current2.call(cleanupRef);
33
- };
34
- }, []);
35
- };
36
- var _default = exports.default = useSyncEffect;
37
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_react","require","useSyncEffect","effect","deps","cachedDeps","useRef","areDepsEqual","every","el","index","current","cleanupRef","_cleanupRef$current","call","useEffect","_cleanupRef$current2","_default","exports","default"],"sources":["index.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\n\nimport type { DependencyList } from \"react\";\n\n/**\n * @description\n * Equivalent to `useEffect` but will run the effect synchronously, i. e. before render.\n *\n * @param {effect} - imperative function\n * @param {deps} - if present, effect will only activate if the values in the list change\n *\n * @author Kiryl Ziusko\n * @since 1.13.0\n * @version 1.0.0\n */\nconst useSyncEffect: typeof useEffect = (effect, deps) => {\n const cachedDeps = useRef<DependencyList | undefined | null>(null);\n const areDepsEqual = deps?.every(\n (el, index) => cachedDeps.current && el === cachedDeps.current[index],\n );\n const cleanupRef = useRef<(() => void) | void>();\n\n if (!areDepsEqual || !cachedDeps.current) {\n cleanupRef.current?.();\n cleanupRef.current = effect();\n cachedDeps.current = deps;\n }\n\n useEffect(() => {\n return () => {\n cleanupRef.current?.();\n };\n }, []);\n};\n\nexport default useSyncEffect;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,aAA+B,GAAGA,CAACC,MAAM,EAAEC,IAAI,KAAK;EACxD,MAAMC,UAAU,GAAG,IAAAC,aAAM,EAAoC,IAAI,CAAC;EAClE,MAAMC,YAAY,GAAGH,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEI,KAAK,CAC9B,CAACC,EAAE,EAAEC,KAAK,KAAKL,UAAU,CAACM,OAAO,IAAIF,EAAE,KAAKJ,UAAU,CAACM,OAAO,CAACD,KAAK,CACtE,CAAC;EACD,MAAME,UAAU,GAAG,IAAAN,aAAM,EAAsB,CAAC;EAEhD,IAAI,CAACC,YAAY,IAAI,CAACF,UAAU,CAACM,OAAO,EAAE;IAAA,IAAAE,mBAAA;IACxC,CAAAA,mBAAA,GAAAD,UAAU,CAACD,OAAO,cAAAE,mBAAA,eAAlBA,mBAAA,CAAAC,IAAA,CAAAF,UAAqB,CAAC;IACtBA,UAAU,CAACD,OAAO,GAAGR,MAAM,CAAC,CAAC;IAC7BE,UAAU,CAACM,OAAO,GAAGP,IAAI;EAC3B;EAEA,IAAAW,gBAAS,EAAC,MAAM;IACd,OAAO,MAAM;MAAA,IAAAC,oBAAA;MACX,CAAAA,oBAAA,GAAAJ,UAAU,CAACD,OAAO,cAAAK,oBAAA,eAAlBA,oBAAA,CAAAF,IAAA,CAAAF,UAAqB,CAAC;IACxB,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;AACR,CAAC;AAAC,IAAAK,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEajB,aAAa","ignoreList":[]}
@@ -1,31 +0,0 @@
1
- import { useEffect, useRef } from "react";
2
- /**
3
- * @description
4
- * Equivalent to `useEffect` but will run the effect synchronously, i. e. before render.
5
- *
6
- * @param {effect} - imperative function
7
- * @param {deps} - if present, effect will only activate if the values in the list change
8
- *
9
- * @author Kiryl Ziusko
10
- * @since 1.13.0
11
- * @version 1.0.0
12
- */
13
- const useSyncEffect = (effect, deps) => {
14
- const cachedDeps = useRef(null);
15
- const areDepsEqual = deps === null || deps === void 0 ? void 0 : deps.every((el, index) => cachedDeps.current && el === cachedDeps.current[index]);
16
- const cleanupRef = useRef();
17
- if (!areDepsEqual || !cachedDeps.current) {
18
- var _cleanupRef$current;
19
- (_cleanupRef$current = cleanupRef.current) === null || _cleanupRef$current === void 0 || _cleanupRef$current.call(cleanupRef);
20
- cleanupRef.current = effect();
21
- cachedDeps.current = deps;
22
- }
23
- useEffect(() => {
24
- return () => {
25
- var _cleanupRef$current2;
26
- (_cleanupRef$current2 = cleanupRef.current) === null || _cleanupRef$current2 === void 0 || _cleanupRef$current2.call(cleanupRef);
27
- };
28
- }, []);
29
- };
30
- export default useSyncEffect;
31
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["useEffect","useRef","useSyncEffect","effect","deps","cachedDeps","areDepsEqual","every","el","index","current","cleanupRef","_cleanupRef$current","call","_cleanupRef$current2"],"sources":["index.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\n\nimport type { DependencyList } from \"react\";\n\n/**\n * @description\n * Equivalent to `useEffect` but will run the effect synchronously, i. e. before render.\n *\n * @param {effect} - imperative function\n * @param {deps} - if present, effect will only activate if the values in the list change\n *\n * @author Kiryl Ziusko\n * @since 1.13.0\n * @version 1.0.0\n */\nconst useSyncEffect: typeof useEffect = (effect, deps) => {\n const cachedDeps = useRef<DependencyList | undefined | null>(null);\n const areDepsEqual = deps?.every(\n (el, index) => cachedDeps.current && el === cachedDeps.current[index],\n );\n const cleanupRef = useRef<(() => void) | void>();\n\n if (!areDepsEqual || !cachedDeps.current) {\n cleanupRef.current?.();\n cleanupRef.current = effect();\n cachedDeps.current = deps;\n }\n\n useEffect(() => {\n return () => {\n cleanupRef.current?.();\n };\n }, []);\n};\n\nexport default useSyncEffect;\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAIzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,aAA+B,GAAGA,CAACC,MAAM,EAAEC,IAAI,KAAK;EACxD,MAAMC,UAAU,GAAGJ,MAAM,CAAoC,IAAI,CAAC;EAClE,MAAMK,YAAY,GAAGF,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEG,KAAK,CAC9B,CAACC,EAAE,EAAEC,KAAK,KAAKJ,UAAU,CAACK,OAAO,IAAIF,EAAE,KAAKH,UAAU,CAACK,OAAO,CAACD,KAAK,CACtE,CAAC;EACD,MAAME,UAAU,GAAGV,MAAM,CAAsB,CAAC;EAEhD,IAAI,CAACK,YAAY,IAAI,CAACD,UAAU,CAACK,OAAO,EAAE;IAAA,IAAAE,mBAAA;IACxC,CAAAA,mBAAA,GAAAD,UAAU,CAACD,OAAO,cAAAE,mBAAA,eAAlBA,mBAAA,CAAAC,IAAA,CAAAF,UAAqB,CAAC;IACtBA,UAAU,CAACD,OAAO,GAAGP,MAAM,CAAC,CAAC;IAC7BE,UAAU,CAACK,OAAO,GAAGN,IAAI;EAC3B;EAEAJ,SAAS,CAAC,MAAM;IACd,OAAO,MAAM;MAAA,IAAAc,oBAAA;MACX,CAAAA,oBAAA,GAAAH,UAAU,CAACD,OAAO,cAAAI,oBAAA,eAAlBA,oBAAA,CAAAD,IAAA,CAAAF,UAAqB,CAAC;IACxB,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;AACR,CAAC;AAED,eAAeT,aAAa","ignoreList":[]}
@@ -1,14 +0,0 @@
1
- import { useEffect } from "react";
2
- /**
3
- * @description
4
- * Equivalent to `useEffect` but will run the effect synchronously, i. e. before render.
5
- *
6
- * @param {effect} - imperative function
7
- * @param {deps} - if present, effect will only activate if the values in the list change
8
- *
9
- * @author Kiryl Ziusko
10
- * @since 1.13.0
11
- * @version 1.0.0
12
- */
13
- declare const useSyncEffect: typeof useEffect;
14
- export default useSyncEffect;
@@ -1,36 +0,0 @@
1
- import { useEffect, useRef } from "react";
2
-
3
- import type { DependencyList } from "react";
4
-
5
- /**
6
- * @description
7
- * Equivalent to `useEffect` but will run the effect synchronously, i. e. before render.
8
- *
9
- * @param {effect} - imperative function
10
- * @param {deps} - if present, effect will only activate if the values in the list change
11
- *
12
- * @author Kiryl Ziusko
13
- * @since 1.13.0
14
- * @version 1.0.0
15
- */
16
- const useSyncEffect: typeof useEffect = (effect, deps) => {
17
- const cachedDeps = useRef<DependencyList | undefined | null>(null);
18
- const areDepsEqual = deps?.every(
19
- (el, index) => cachedDeps.current && el === cachedDeps.current[index],
20
- );
21
- const cleanupRef = useRef<(() => void) | void>();
22
-
23
- if (!areDepsEqual || !cachedDeps.current) {
24
- cleanupRef.current?.();
25
- cleanupRef.current = effect();
26
- cachedDeps.current = deps;
27
- }
28
-
29
- useEffect(() => {
30
- return () => {
31
- cleanupRef.current?.();
32
- };
33
- }, []);
34
- };
35
-
36
- export default useSyncEffect;