@r0b0t3d/react-native-collapsible 1.3.5-beta.0 → 1.3.5-beta.2

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 (142) hide show
  1. package/LICENSE +1 -2
  2. package/lib/commonjs/components/CollapsibleContainer.js +11 -25
  3. package/lib/commonjs/components/CollapsibleContainer.js.map +1 -1
  4. package/lib/commonjs/components/CollapsibleView.js +39 -44
  5. package/lib/commonjs/components/CollapsibleView.js.map +1 -1
  6. package/lib/commonjs/components/header/AnimatedTopView.js +4 -9
  7. package/lib/commonjs/components/header/AnimatedTopView.js.map +1 -1
  8. package/lib/commonjs/components/header/CollapsibleHeaderConsumer.js +12 -20
  9. package/lib/commonjs/components/header/CollapsibleHeaderConsumer.js.map +1 -1
  10. package/lib/commonjs/components/header/CollapsibleHeaderContainer.js +6 -12
  11. package/lib/commonjs/components/header/CollapsibleHeaderContainer.js.map +1 -1
  12. package/lib/commonjs/components/header/CollapsibleHeaderProvider.js +7 -11
  13. package/lib/commonjs/components/header/CollapsibleHeaderProvider.js.map +1 -1
  14. package/lib/commonjs/components/header/StickyView.js +11 -20
  15. package/lib/commonjs/components/header/StickyView.js.map +1 -1
  16. package/lib/commonjs/components/scrollable/CollapsibleFlatList.js +12 -26
  17. package/lib/commonjs/components/scrollable/CollapsibleFlatList.js.map +1 -1
  18. package/lib/commonjs/components/scrollable/CollapsibleScrollView.js +13 -24
  19. package/lib/commonjs/components/scrollable/CollapsibleScrollView.js.map +1 -1
  20. package/lib/commonjs/components/scrollable/useAnimatedScroll.js +9 -18
  21. package/lib/commonjs/components/scrollable/useAnimatedScroll.js.map +1 -1
  22. package/lib/commonjs/hooks/useCollapsibleContext.js +1 -6
  23. package/lib/commonjs/hooks/useCollapsibleContext.js.map +1 -1
  24. package/lib/commonjs/hooks/useCollapsibleHeaderContext.js +1 -6
  25. package/lib/commonjs/hooks/useCollapsibleHeaderContext.js.map +1 -1
  26. package/lib/commonjs/hooks/useInternalCollapsibleContext.js +1 -6
  27. package/lib/commonjs/hooks/useInternalCollapsibleContext.js.map +1 -1
  28. package/lib/commonjs/hooks/useKeyboardShowEvent.js +0 -4
  29. package/lib/commonjs/hooks/useKeyboardShowEvent.js.map +1 -1
  30. package/lib/commonjs/index.js +12 -33
  31. package/lib/commonjs/index.js.map +1 -1
  32. package/lib/commonjs/types.js.map +1 -1
  33. package/lib/commonjs/utils/debounce.js +8 -7
  34. package/lib/commonjs/utils/debounce.js.map +1 -1
  35. package/lib/commonjs/withCollapsibleContext.js +31 -44
  36. package/lib/commonjs/withCollapsibleContext.js.map +1 -1
  37. package/lib/module/components/CollapsibleContainer.js +11 -14
  38. package/lib/module/components/CollapsibleContainer.js.map +1 -1
  39. package/lib/module/components/CollapsibleView.js +38 -35
  40. package/lib/module/components/CollapsibleView.js.map +1 -1
  41. package/lib/module/components/header/AnimatedTopView.js +4 -3
  42. package/lib/module/components/header/AnimatedTopView.js.map +1 -1
  43. package/lib/module/components/header/CollapsibleHeaderConsumer.js +12 -9
  44. package/lib/module/components/header/CollapsibleHeaderConsumer.js.map +1 -1
  45. package/lib/module/components/header/CollapsibleHeaderContainer.js +5 -4
  46. package/lib/module/components/header/CollapsibleHeaderContainer.js.map +1 -1
  47. package/lib/module/components/header/CollapsibleHeaderProvider.js +6 -6
  48. package/lib/module/components/header/CollapsibleHeaderProvider.js.map +1 -1
  49. package/lib/module/components/header/StickyView.js +11 -10
  50. package/lib/module/components/header/StickyView.js.map +1 -1
  51. package/lib/module/components/scrollable/CollapsibleFlatList.js +12 -13
  52. package/lib/module/components/scrollable/CollapsibleFlatList.js.map +1 -1
  53. package/lib/module/components/scrollable/CollapsibleScrollView.js +13 -12
  54. package/lib/module/components/scrollable/CollapsibleScrollView.js.map +1 -1
  55. package/lib/module/components/scrollable/useAnimatedScroll.js +8 -10
  56. package/lib/module/components/scrollable/useAnimatedScroll.js.map +1 -1
  57. package/lib/module/hooks/useCollapsibleContext.js +0 -2
  58. package/lib/module/hooks/useCollapsibleContext.js.map +1 -1
  59. package/lib/module/hooks/useCollapsibleHeaderContext.js +0 -2
  60. package/lib/module/hooks/useCollapsibleHeaderContext.js.map +1 -1
  61. package/lib/module/hooks/useInternalCollapsibleContext.js +0 -2
  62. package/lib/module/hooks/useInternalCollapsibleContext.js.map +1 -1
  63. package/lib/module/hooks/useKeyboardShowEvent.js.map +1 -1
  64. package/lib/module/index.js +0 -1
  65. package/lib/module/index.js.map +1 -1
  66. package/lib/module/types.js.map +1 -1
  67. package/lib/module/utils/debounce.js +8 -6
  68. package/lib/module/utils/debounce.js.map +1 -1
  69. package/lib/module/withCollapsibleContext.js +30 -34
  70. package/lib/module/withCollapsibleContext.js.map +1 -1
  71. package/lib/typescript/components/CollapsibleContainer.d.ts +4 -2
  72. package/lib/typescript/components/CollapsibleContainer.d.ts.map +1 -0
  73. package/lib/typescript/components/CollapsibleView.d.ts +6 -5
  74. package/lib/typescript/components/CollapsibleView.d.ts.map +1 -0
  75. package/lib/typescript/components/header/AnimatedTopView.d.ts +4 -2
  76. package/lib/typescript/components/header/AnimatedTopView.d.ts.map +1 -0
  77. package/lib/typescript/components/header/CollapsibleHeaderConsumer.d.ts +3 -1
  78. package/lib/typescript/components/header/CollapsibleHeaderConsumer.d.ts.map +1 -0
  79. package/lib/typescript/components/header/CollapsibleHeaderContainer.d.ts +2 -1
  80. package/lib/typescript/components/header/CollapsibleHeaderContainer.d.ts.map +1 -0
  81. package/lib/typescript/components/header/CollapsibleHeaderProvider.d.ts +3 -2
  82. package/lib/typescript/components/header/CollapsibleHeaderProvider.d.ts.map +1 -0
  83. package/lib/typescript/components/header/StickyView.d.ts +4 -2
  84. package/lib/typescript/components/header/StickyView.d.ts.map +1 -0
  85. package/lib/typescript/components/scrollable/CollapsibleFlatList.d.ts +4 -2
  86. package/lib/typescript/components/scrollable/CollapsibleFlatList.d.ts.map +1 -0
  87. package/lib/typescript/components/scrollable/CollapsibleScrollView.d.ts +4 -3
  88. package/lib/typescript/components/scrollable/CollapsibleScrollView.d.ts.map +1 -0
  89. package/lib/typescript/components/scrollable/useAnimatedScroll.d.ts +2 -1
  90. package/lib/typescript/components/scrollable/useAnimatedScroll.d.ts.map +1 -0
  91. package/lib/typescript/hooks/useCollapsibleContext.d.ts +1 -0
  92. package/lib/typescript/hooks/useCollapsibleContext.d.ts.map +1 -0
  93. package/lib/typescript/hooks/useCollapsibleHeaderContext.d.ts +3 -2
  94. package/lib/typescript/hooks/useCollapsibleHeaderContext.d.ts.map +1 -0
  95. package/lib/typescript/hooks/useInternalCollapsibleContext.d.ts +1 -0
  96. package/lib/typescript/hooks/useInternalCollapsibleContext.d.ts.map +1 -0
  97. package/lib/typescript/hooks/useKeyboardShowEvent.d.ts +1 -0
  98. package/lib/typescript/hooks/useKeyboardShowEvent.d.ts.map +1 -0
  99. package/lib/typescript/index.d.ts +1 -1
  100. package/lib/typescript/index.d.ts.map +1 -0
  101. package/lib/typescript/types.d.ts +8 -7
  102. package/lib/typescript/types.d.ts.map +1 -0
  103. package/lib/typescript/utils/debounce.d.ts +1 -0
  104. package/lib/typescript/utils/debounce.d.ts.map +1 -0
  105. package/lib/typescript/withCollapsibleContext.d.ts +3 -2
  106. package/lib/typescript/withCollapsibleContext.d.ts.map +1 -0
  107. package/package.json +39 -34
  108. package/src/components/CollapsibleView.tsx +13 -6
  109. package/src/components/header/CollapsibleHeaderConsumer.tsx +2 -1
  110. package/src/components/header/StickyView.tsx +3 -4
  111. package/src/index.tsx +0 -1
  112. package/src/withCollapsibleContext.tsx +30 -26
  113. package/lib/commonjs/components/pullToRefresh/PullToRefreshContainer.js +0 -75
  114. package/lib/commonjs/components/pullToRefresh/PullToRefreshContainer.js.map +0 -1
  115. package/lib/commonjs/components/pullToRefresh/PullToRefreshProvider.js +0 -35
  116. package/lib/commonjs/components/pullToRefresh/PullToRefreshProvider.js.map +0 -1
  117. package/lib/commonjs/components/pullToRefresh/RefreshControl.js +0 -91
  118. package/lib/commonjs/components/pullToRefresh/RefreshControl.js.map +0 -1
  119. package/lib/commonjs/components/pullToRefresh/usePullToRefreshContext.js +0 -24
  120. package/lib/commonjs/components/pullToRefresh/usePullToRefreshContext.js.map +0 -1
  121. package/lib/commonjs/components/pullToRefresh/utils.js +0 -59
  122. package/lib/commonjs/components/pullToRefresh/utils.js.map +0 -1
  123. package/lib/module/components/pullToRefresh/PullToRefreshContainer.js +0 -56
  124. package/lib/module/components/pullToRefresh/PullToRefreshContainer.js.map +0 -1
  125. package/lib/module/components/pullToRefresh/PullToRefreshProvider.js +0 -21
  126. package/lib/module/components/pullToRefresh/PullToRefreshProvider.js.map +0 -1
  127. package/lib/module/components/pullToRefresh/RefreshControl.js +0 -73
  128. package/lib/module/components/pullToRefresh/RefreshControl.js.map +0 -1
  129. package/lib/module/components/pullToRefresh/usePullToRefreshContext.js +0 -13
  130. package/lib/module/components/pullToRefresh/usePullToRefreshContext.js.map +0 -1
  131. package/lib/module/components/pullToRefresh/utils.js +0 -42
  132. package/lib/module/components/pullToRefresh/utils.js.map +0 -1
  133. package/lib/typescript/components/pullToRefresh/PullToRefreshContainer.d.ts +0 -8
  134. package/lib/typescript/components/pullToRefresh/PullToRefreshProvider.d.ts +0 -6
  135. package/lib/typescript/components/pullToRefresh/RefreshControl.d.ts +0 -9
  136. package/lib/typescript/components/pullToRefresh/usePullToRefreshContext.d.ts +0 -4
  137. package/lib/typescript/components/pullToRefresh/utils.d.ts +0 -20
  138. package/src/components/pullToRefresh/PullToRefreshContainer.tsx +0 -66
  139. package/src/components/pullToRefresh/PullToRefreshProvider.tsx +0 -27
  140. package/src/components/pullToRefresh/RefreshControl.tsx +0 -100
  141. package/src/components/pullToRefresh/usePullToRefreshContext.ts +0 -13
  142. package/src/components/pullToRefresh/utils.ts +0 -49
@@ -5,6 +5,6 @@ export { default as CollapsibleFlatList } from './components/scrollable/Collapsi
5
5
  export { default as CollapsibleScrollView } from './components/scrollable/CollapsibleScrollView';
6
6
  export { default as CollapsibleHeaderContainer } from './components/header/CollapsibleHeaderContainer';
7
7
  export { default as StickyView } from './components/header/StickyView';
8
- export { default as RefreshControl } from './components/pullToRefresh/RefreshControl';
9
8
  export { default as CollapsibleView } from './components/CollapsibleView';
10
9
  export * from './components/CollapsibleView';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEjF,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACpF,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,6CAA6C,CAAC;AAC7F,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,+CAA+C,CAAC;AACjG,OAAO,EAAE,OAAO,IAAI,0BAA0B,EAAE,MAAM,gDAAgD,CAAC;AACvG,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC1E,cAAc,8BAA8B,CAAC"}
@@ -1,30 +1,30 @@
1
1
  import type React from 'react';
2
2
  import type { View } from 'react-native';
3
3
  import type Animated from 'react-native-reanimated';
4
- export declare type ScrollToIndexParams = {
4
+ export type ScrollToIndexParams = {
5
5
  animated?: boolean | null;
6
6
  index: number;
7
7
  viewOffset?: number;
8
8
  viewPosition?: number;
9
9
  };
10
- export declare type CollapsibleHandles = {
10
+ export type CollapsibleHandles = {
11
11
  collapse: (animated?: boolean) => void;
12
12
  expand: () => void;
13
13
  scrollTo: (offset: number, animate?: boolean) => void;
14
14
  scrollToIndex: (params: ScrollToIndexParams) => void;
15
15
  };
16
- export declare type CollapsibleContextType = CollapsibleHandles & {
16
+ export type CollapsibleContextType = CollapsibleHandles & {
17
17
  scrollY: Animated.SharedValue<number>;
18
18
  headerHeight: Animated.SharedValue<number>;
19
19
  headerCollapsed: Animated.SharedValue<boolean>;
20
20
  };
21
- export declare type LayoutParams = {
21
+ export type LayoutParams = {
22
22
  top: number;
23
23
  left: number;
24
24
  width: number;
25
25
  height: number;
26
26
  };
27
- export declare type CollapsibleContextInternalType = {
27
+ export type CollapsibleContextInternalType = {
28
28
  scrollViewRef: React.RefObject<any>;
29
29
  containerRef: React.RefObject<View>;
30
30
  contentMinHeight: Animated.SharedValue<number>;
@@ -37,11 +37,12 @@ export declare type CollapsibleContextInternalType = {
37
37
  handleHeaderContainerLayout: (height: number) => void;
38
38
  setCollapsibleHandlers: (handlers: CollapsibleHandles) => void;
39
39
  };
40
- export declare type CollapsibleProps = {
40
+ export type CollapsibleProps = {
41
41
  headerSnappable?: boolean;
42
42
  };
43
- export declare type PullToRefreshContextType = {
43
+ export type PullToRefreshContextType = {
44
44
  refreshValue: Animated.SharedValue<number>;
45
45
  internalRefreshing: Animated.SharedValue<boolean>;
46
46
  internalHeight: Animated.SharedValue<number>;
47
47
  };
48
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AAEpD,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,CAAC,QAAQ,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACtD,aAAa,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,CAAC;CACtD,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,kBAAkB,GAAG;IACxD,OAAO,EAAE,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IACtC,YAAY,EAAE,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAC3C,eAAe,EAAE,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,aAAa,EAAE,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IACpC,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACpC,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAC/C,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAC/C,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;IACxE,cAAc,EAAE,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC7D,iBAAiB,EAAE,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAChD,qBAAqB,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAChD,sBAAsB,EAAE,CACtB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,KAC5B,IAAI,CAAC;IACV,2BAA2B,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACtD,sBAAsB,EAAE,CAAC,QAAQ,EAAE,kBAAkB,KAAK,IAAI,CAAC;CAChE,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,YAAY,EAAE,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAC3C,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAClD,cAAc,EAAE,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;CAC9C,CAAC"}
@@ -1 +1,2 @@
1
1
  export declare function debounce<T extends Function>(cb: T, wait?: number): T;
2
+ //# sourceMappingURL=debounce.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debounce.d.ts","sourceRoot":"","sources":["../../../src/utils/debounce.ts"],"names":[],"mappings":"AACA,wBAAgB,QAAQ,CAAC,CAAC,SAAS,QAAQ,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,SAAK,KAQ5D"}
@@ -1,2 +1,3 @@
1
- import { FC } from 'react';
2
- export default function withCollapsibleContext<T>(Component: FC<T>): (props: T) => JSX.Element;
1
+ import React, { FC } from 'react';
2
+ export default function withCollapsibleContext<T>(Component: FC<T>): (props: T) => React.JSX.Element;
3
+ //# sourceMappingURL=withCollapsibleContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withCollapsibleContext.d.ts","sourceRoot":"","sources":["../../src/withCollapsibleContext.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAgC,EAAE,EAAE,MAAM,OAAO,CAAC;AAchE,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC,CAAC,WACjD,CAAC,uBAqLjB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@r0b0t3d/react-native-collapsible",
3
- "version": "1.3.5-beta.0",
3
+ "version": "1.3.5-beta.2",
4
4
  "description": "Fully customizable collapsible views",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -13,23 +13,27 @@
13
13
  "android",
14
14
  "ios",
15
15
  "cpp",
16
- "react-native-collapsible.podspec",
16
+ "*.podspec",
17
17
  "!lib/typescript/example",
18
- "!android/build",
19
18
  "!ios/build",
19
+ "!android/build",
20
+ "!android/gradle",
21
+ "!android/gradlew",
22
+ "!android/gradlew.bat",
23
+ "!android/local.properties",
20
24
  "!**/__tests__",
21
25
  "!**/__fixtures__",
22
- "!**/__mocks__"
26
+ "!**/__mocks__",
27
+ "!**/.*"
23
28
  ],
24
29
  "scripts": {
25
30
  "test": "jest",
26
- "typescript": "tsc --noEmit",
31
+ "typecheck": "tsc --noEmit",
27
32
  "lint": "eslint \"**/*.{js,ts,tsx}\"",
28
- "prepare": "bob build",
33
+ "prepack": "bob build",
29
34
  "release": "release-it",
30
35
  "example": "yarn --cwd example",
31
- "pods": "cd example && pod-install --quiet",
32
- "bootstrap": "yarn example && yarn && yarn pods"
36
+ "bootstrap": "yarn example && yarn install"
33
37
  },
34
38
  "keywords": [
35
39
  "react-native",
@@ -47,34 +51,41 @@
47
51
  "registry": "https://registry.npmjs.org/"
48
52
  },
49
53
  "devDependencies": {
50
- "@commitlint/config-conventional": "^11.0.0",
51
- "@react-native-community/eslint-config": "^2.0.0",
52
- "@release-it/conventional-changelog": "^2.0.0",
53
- "@types/jest": "^26.0.0",
54
- "@types/react": "^16.9.19",
55
- "@types/react-native": "0.62.13",
56
- "commitlint": "^11.0.0",
57
- "eslint": "^7.2.0",
58
- "eslint-config-prettier": "^7.0.0",
59
- "eslint-plugin-prettier": "^3.1.3",
60
- "husky": "^4.2.5",
61
- "jest": "^26.0.1",
54
+ "@commitlint/config-conventional": "^17.0.2",
55
+ "@evilmartians/lefthook": "^1.2.2",
56
+ "@react-native-community/eslint-config": "^3.0.2",
57
+ "@release-it/conventional-changelog": "^5.0.0",
58
+ "@types/jest": "^28.1.2",
59
+ "@types/react": "~17.0.21",
60
+ "@types/react-native": "0.70.0",
61
+ "commitlint": "^17.0.2",
62
+ "del-cli": "^5.0.0",
63
+ "eslint": "^8.4.1",
64
+ "eslint-config-prettier": "^8.5.0",
65
+ "eslint-plugin-prettier": "^4.0.0",
66
+ "jest": "^28.1.1",
62
67
  "pod-install": "^0.1.0",
63
68
  "prettier": "^2.0.5",
64
- "react": "16.13.1",
65
- "react-native": "0.63.4",
66
- "react-native-builder-bob": "^0.18.0",
67
- "react-native-gesture-handler": "^1.10.3",
68
- "react-native-reanimated": "^2.2.0",
69
- "release-it": "^14.11.5",
70
- "typescript": "^4.1.3"
69
+ "react": "18.2.0",
70
+ "react-native": "0.71.8",
71
+ "react-native-builder-bob": "^0.20.0",
72
+ "react-native-reanimated": "^3.3.0",
73
+ "release-it": "^15.0.0",
74
+ "typescript": "^5.0.2"
75
+ },
76
+ "resolutions": {
77
+ "@types/react": "17.0.21"
71
78
  },
72
79
  "peerDependencies": {
73
80
  "react": "*",
74
81
  "react-native": "*",
75
82
  "react-native-gesture-handler": "*",
76
- "react-native-reanimated": ">=2.2.0"
83
+ "react-native-reanimated": ">=3.0.0"
77
84
  },
85
+ "engines": {
86
+ "node": ">= 16.0.0"
87
+ },
88
+ "packageManager": "^yarn@1.22.15",
78
89
  "jest": {
79
90
  "preset": "react-native",
80
91
  "modulePathIgnorePatterns": [
@@ -82,12 +93,6 @@
82
93
  "<rootDir>/lib/"
83
94
  ]
84
95
  },
85
- "husky": {
86
- "hooks": {
87
- "commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
88
- "pre-commit": "yarn lint && yarn typescript"
89
- }
90
- },
91
96
  "commitlint": {
92
97
  "extends": [
93
98
  "@commitlint/config-conventional"
@@ -3,11 +3,11 @@
3
3
  import React, { ReactNode, useCallback, useEffect, useMemo } from 'react';
4
4
  import {
5
5
  LayoutChangeEvent,
6
+ Pressable,
6
7
  StyleProp,
7
8
  StyleSheet,
8
9
  Text,
9
10
  TextStyle,
10
- TouchableOpacity,
11
11
  View,
12
12
  ViewStyle,
13
13
  } from 'react-native';
@@ -181,13 +181,19 @@ export function CollapsibleHeaderText({
181
181
  }, [iconInitialAngle]);
182
182
 
183
183
  return (
184
- <TouchableOpacity activeOpacity={0.9} onPress={onToggle} style={style}>
185
- <View style={styles.headerContainer}>
186
- <Text style={[styles.headerTitle, titleStyle]}>{title}</Text>
187
- {icon && <Animated.View style={iconStyle}>{icon}</Animated.View>}
184
+ <View style={style} pointerEvents="box-none">
185
+ <View style={styles.headerContainer} pointerEvents="box-none">
186
+ <Pressable onPress={onToggle}>
187
+ <Text style={[styles.headerTitle, titleStyle]}>{title}</Text>
188
+ </Pressable>
189
+ {icon && (
190
+ <Pressable onPress={onToggle}>
191
+ <Animated.View style={iconStyle}>{icon}</Animated.View>
192
+ </Pressable>
193
+ )}
188
194
  </View>
189
195
  {children}
190
- </TouchableOpacity>
196
+ </View>
191
197
  );
192
198
  }
193
199
 
@@ -199,6 +205,7 @@ const styles = StyleSheet.create({
199
205
  headerContainer: {
200
206
  flexDirection: 'row',
201
207
  alignItems: 'center',
208
+ justifyContent: 'space-between',
202
209
  },
203
210
  headerTitle: {
204
211
  flex: 1,
@@ -21,7 +21,7 @@ export default function CollapsibleHeaderConsumer() {
21
21
  // FIXME: can improve by geting maxY value of header and sticky views
22
22
  [-1000, 0, 100000],
23
23
  [0, 0, -100000],
24
- Animated.Extrapolate.CLAMP
24
+ 'clamp'
25
25
  ),
26
26
  []
27
27
  );
@@ -57,5 +57,6 @@ export default function CollapsibleHeaderConsumer() {
57
57
  const styles = StyleSheet.create({
58
58
  container: {
59
59
  zIndex: 10,
60
+ backgroundColor: 'white',
60
61
  },
61
62
  });
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable react-hooks/exhaustive-deps */
2
2
  import React, { useCallback, useEffect, useMemo, useRef } from 'react';
3
- import { Platform, StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
3
+ import { StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
4
4
  import useCollapsibleContext from '../../hooks/useCollapsibleContext';
5
5
  import useInternalCollapsibleContext from '../../hooks/useInternalCollapsibleContext';
6
6
  import Animated, {
@@ -26,7 +26,7 @@ export default function StickyView({ children, style }: Props) {
26
26
 
27
27
  useEffect(() => {
28
28
  return () => handleStickyViewLayout(key, undefined);
29
- }, []);
29
+ }, [key]);
30
30
 
31
31
  const handleLayout = useCallback(() => {
32
32
  handleStickyViewLayout(key, viewRef);
@@ -42,7 +42,7 @@ export default function StickyView({ children, style }: Props) {
42
42
  [0, 0, 100000],
43
43
  Extrapolate.CLAMP
44
44
  );
45
- }, []);
45
+ }, [key]);
46
46
 
47
47
  const animatedStyle = useAnimatedStyle(() => {
48
48
  return {
@@ -72,6 +72,5 @@ const styles = StyleSheet.create({
72
72
  container: {
73
73
  backgroundColor: 'white',
74
74
  zIndex: 10,
75
- marginTop: Platform.OS === 'android' ? -1 : 0,
76
75
  },
77
76
  });
package/src/index.tsx CHANGED
@@ -6,6 +6,5 @@ export { default as CollapsibleFlatList } from './components/scrollable/Collapsi
6
6
  export { default as CollapsibleScrollView } from './components/scrollable/CollapsibleScrollView';
7
7
  export { default as CollapsibleHeaderContainer } from './components/header/CollapsibleHeaderContainer';
8
8
  export { default as StickyView } from './components/header/StickyView';
9
- export { default as RefreshControl } from './components/pullToRefresh/RefreshControl';
10
9
  export { default as CollapsibleView } from './components/CollapsibleView';
11
10
  export * from './components/CollapsibleView';
@@ -1,6 +1,5 @@
1
- /* eslint-disable no-shadow */
2
1
  /* eslint-disable react-hooks/exhaustive-deps */
3
- import React, { FC, useCallback, useMemo, useRef } from 'react';
2
+ import React, { useCallback, useMemo, useRef, FC } from 'react';
4
3
  import type { CollapsibleHandles, LayoutParams } from './types';
5
4
  import { CollapsibleContext } from './hooks/useCollapsibleContext';
6
5
  import { InternalCollapsibleContext } from './hooks/useInternalCollapsibleContext';
@@ -19,14 +18,17 @@ export default function withCollapsibleContext<T>(Component: FC<T>) {
19
18
  const collapsibleHandlers = useRef<CollapsibleHandles>();
20
19
  const headerHeight = useSharedValue(0);
21
20
  const scrollY = useSharedValue(0);
22
- const stickyViewRefs = useRef<Record<string, React.RefObject<View>>>({});
21
+ const stickyViewRefs = useRef<
22
+ Record<string, React.RefObject<View> | undefined>
23
+ >({});
23
24
  const stickyViewTops = useSharedValue<Record<string, number>>({});
24
- const stickyViewPositionsRef = useRef<Record<string, LayoutParams>>({});
25
+ const stickyViewPositionsRef = useRef<
26
+ Record<string, LayoutParams | undefined>
27
+ >({});
25
28
  const stickyViewPositions = useSharedValue<Record<string, LayoutParams>>(
26
29
  {}
27
30
  );
28
31
  const fixedHeaderHeight = useSharedValue(0);
29
- const stickyHeaderHeight = useSharedValue(0);
30
32
  const containerHeight = useSharedValue(0);
31
33
  const firstStickyViewY = useSharedValue(1000000);
32
34
  const containerRef = useRef<View>(null);
@@ -42,18 +44,18 @@ export default function withCollapsibleContext<T>(Component: FC<T>) {
42
44
  }, []);
43
45
 
44
46
  const contentMinHeight = useDerivedValue(() => {
45
- return (
46
- containerHeight.value +
47
- fixedHeaderHeight.value -
48
- stickyHeaderHeight.value
49
- );
47
+ return containerHeight.value + fixedHeaderHeight.value;
50
48
  }, []);
51
49
 
52
50
  useAnimatedReaction(
53
51
  () => {
54
52
  const totalHeight = Object.keys(stickyViewPositions.value).reduce(
55
53
  (acc, item) => {
56
- return acc + stickyViewPositions.value[item].top;
54
+ const value = stickyViewPositions.value[item];
55
+ if (value) {
56
+ return acc + value.top;
57
+ }
58
+ return acc;
57
59
  },
58
60
  0
59
61
  );
@@ -62,29 +64,23 @@ export default function withCollapsibleContext<T>(Component: FC<T>) {
62
64
  (result, previous) => {
63
65
  if (result !== previous) {
64
66
  const viewPositions = stickyViewPositions.value;
65
- const headerHeight = fixedHeaderHeight.value;
66
- const sortedKeys = Object.keys(viewPositions).sort(
67
- (a, b) => viewPositions[a].top - viewPositions[b].top
68
- );
67
+ const sortedKeys = Object.keys(viewPositions)
68
+ .filter((v) => !!viewPositions[v])
69
+ // @ts-ignore
70
+ .sort((a, b) => viewPositions[a].top - viewPositions[b].top);
69
71
  let totalTop = 0;
70
72
  const values: any = {};
71
73
  for (let i = 0; i < sortedKeys.length; i++) {
74
+ // @ts-ignore
72
75
  values[sortedKeys[i]] = totalTop;
73
76
  // Try minus 1 make it filled when scrolling up.
74
77
  // Otherwise, we can see a small space between the persits views
78
+ // @ts-ignore
75
79
  totalTop += viewPositions[sortedKeys[i]].height - 1;
76
80
  }
77
81
  stickyViewTops.value = values;
82
+ // @ts-ignore
78
83
  firstStickyViewY.value = viewPositions[sortedKeys[0]]?.top || 0;
79
- const stickyHeader = sortedKeys.reduce((acc, key) => {
80
- const data = viewPositions[key];
81
- const isInsideHeader = data.top < headerHeight;
82
- if (isInsideHeader) {
83
- return acc + data.height;
84
- }
85
- return acc;
86
- }, 0);
87
- stickyHeaderHeight.value = stickyHeader;
88
84
  }
89
85
  }
90
86
  );
@@ -101,13 +97,21 @@ export default function withCollapsibleContext<T>(Component: FC<T>) {
101
97
  ...stickyViewPositionsRef.current,
102
98
  [viewKey]: { left, top, width, height },
103
99
  };
100
+ // @ts-ignore
104
101
  stickyViewPositions.value = stickyViewPositionsRef.current;
105
102
  },
106
103
  () => {}
107
104
  );
108
105
  } else {
109
- delete stickyViewRefs.current[viewKey];
110
- delete stickyViewPositionsRef.current[viewKey];
106
+ stickyViewRefs.current = {
107
+ ...stickyViewRefs.current,
108
+ [viewKey]: undefined,
109
+ };
110
+ stickyViewPositionsRef.current = {
111
+ ...stickyViewPositionsRef.current,
112
+ [viewKey]: undefined,
113
+ };
114
+ // @ts-ignore
111
115
  stickyViewPositions.value = stickyViewPositionsRef.current;
112
116
  }
113
117
  },
@@ -1,75 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = PullToRefreshContainer;
7
-
8
- var _reactNativeGestureHandler = require("react-native-gesture-handler");
9
-
10
- var _react = _interopRequireWildcard(require("react"));
11
-
12
- var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
13
-
14
- var _usePullToRefreshContext = _interopRequireDefault(require("./usePullToRefreshContext"));
15
-
16
- var _reactNative = require("react-native");
17
-
18
- var _utils = require("./utils");
19
-
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
22
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
-
24
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
-
26
- function PullToRefreshContainer({
27
- children,
28
- scrollY
29
- }) {
30
- const scrollRef = (0, _react.useRef)();
31
- const panRef = (0, _react.useRef)();
32
- const {
33
- refreshValue,
34
- internalRefreshing,
35
- internalHeight
36
- } = (0, _usePullToRefreshContext.default)();
37
- const gestureHandler = (0, _reactNativeReanimated.useAnimatedGestureHandler)({
38
- onStart: (_, ctx) => {
39
- ctx.startY = (internalRefreshing.value ? refreshValue.value : 0) - scrollY.value;
40
- },
41
- onActive: (event, ctx) => {
42
- if (scrollY.value <= 1) {
43
- const tranY = event.translationY + ctx.startY;
44
- const clampedValue = (0, _utils.rubberClamp)(tranY, 0, internalHeight.value);
45
- refreshValue.value = clampedValue;
46
-
47
- if (clampedValue > internalHeight.value) {
48
- internalRefreshing.value = true;
49
- }
50
- } else if (!internalRefreshing.value) {
51
- refreshValue.value = 0;
52
- }
53
- },
54
- onEnd: () => {
55
- if (refreshValue.value > 0) {
56
- const value = internalRefreshing.value ? internalHeight.value : 0;
57
- refreshValue.value = (0, _reactNativeReanimated.withTiming)(value);
58
- }
59
- }
60
- });
61
- return /*#__PURE__*/_react.default.createElement(_reactNativeGestureHandler.PanGestureHandler, {
62
- ref: panRef,
63
- simultaneousHandlers: scrollRef,
64
- onGestureEvent: gestureHandler,
65
- shouldCancelWhenOutside: false,
66
- enableTrackpadTwoFingerGesture: true,
67
- maxPointers: 1
68
- }, /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
69
- style: _reactNative.StyleSheet.absoluteFill
70
- }, /*#__PURE__*/_react.default.createElement(_reactNativeGestureHandler.NativeViewGestureHandler, {
71
- ref: scrollRef,
72
- simultaneousHandlers: panRef
73
- }, children)));
74
- }
75
- //# sourceMappingURL=PullToRefreshContainer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["PullToRefreshContainer.tsx"],"names":["PullToRefreshContainer","children","scrollY","scrollRef","panRef","refreshValue","internalRefreshing","internalHeight","gestureHandler","onStart","_","ctx","startY","value","onActive","event","tranY","translationY","clampedValue","onEnd","StyleSheet","absoluteFill"],"mappings":";;;;;;;AAAA;;AAIA;;AACA;;AAIA;;AACA;;AACA;;;;;;;;AAOe,SAASA,sBAAT,CAAgC;AAAEC,EAAAA,QAAF;AAAYC,EAAAA;AAAZ,CAAhC,EAA8D;AAC3E,QAAMC,SAAS,GAAG,oBAAlB;AACA,QAAMC,MAAM,GAAG,oBAAf;AACA,QAAM;AAAEC,IAAAA,YAAF;AAAgBC,IAAAA,kBAAhB;AAAoCC,IAAAA;AAApC,MACJ,uCADF;AAGA,QAAMC,cAAc,GAAG,sDAA0B;AAC/CC,IAAAA,OAAO,EAAE,CAACC,CAAD,EAAIC,GAAJ,KAAiB;AACxBA,MAAAA,GAAG,CAACC,MAAJ,GACE,CAACN,kBAAkB,CAACO,KAAnB,GAA2BR,YAAY,CAACQ,KAAxC,GAAgD,CAAjD,IAAsDX,OAAO,CAACW,KADhE;AAED,KAJ8C;AAK/CC,IAAAA,QAAQ,EAAE,CAACC,KAAD,EAAQJ,GAAR,KAAqB;AAC7B,UAAIT,OAAO,CAACW,KAAR,IAAiB,CAArB,EAAwB;AACtB,cAAMG,KAAK,GAAGD,KAAK,CAACE,YAAN,GAAqBN,GAAG,CAACC,MAAvC;AACA,cAAMM,YAAY,GAAG,wBAAYF,KAAZ,EAAmB,CAAnB,EAAsBT,cAAc,CAACM,KAArC,CAArB;AACAR,QAAAA,YAAY,CAACQ,KAAb,GAAqBK,YAArB;;AACA,YAAIA,YAAY,GAAGX,cAAc,CAACM,KAAlC,EAAyC;AACvCP,UAAAA,kBAAkB,CAACO,KAAnB,GAA2B,IAA3B;AACD;AACF,OAPD,MAOO,IAAI,CAACP,kBAAkB,CAACO,KAAxB,EAA+B;AACpCR,QAAAA,YAAY,CAACQ,KAAb,GAAqB,CAArB;AACD;AACF,KAhB8C;AAiB/CM,IAAAA,KAAK,EAAE,MAAM;AACX,UAAId,YAAY,CAACQ,KAAb,GAAqB,CAAzB,EAA4B;AAC1B,cAAMA,KAAK,GAAGP,kBAAkB,CAACO,KAAnB,GAA2BN,cAAc,CAACM,KAA1C,GAAkD,CAAhE;AACAR,QAAAA,YAAY,CAACQ,KAAb,GAAqB,uCAAWA,KAAX,CAArB;AACD;AACF;AAtB8C,GAA1B,CAAvB;AAyBA,sBACE,6BAAC,4CAAD;AACE,IAAA,GAAG,EAAET,MADP;AAEE,IAAA,oBAAoB,EAAED,SAFxB;AAGE,IAAA,cAAc,EAAEK,cAHlB;AAIE,IAAA,uBAAuB,EAAE,KAJ3B;AAKE,IAAA,8BAA8B,MALhC;AAME,IAAA,WAAW,EAAE;AANf,kBAQE,6BAAC,8BAAD,CAAU,IAAV;AAAe,IAAA,KAAK,EAAEY,wBAAWC;AAAjC,kBACE,6BAAC,mDAAD;AAA0B,IAAA,GAAG,EAAElB,SAA/B;AAA0C,IAAA,oBAAoB,EAAEC;AAAhE,KACGH,QADH,CADF,CARF,CADF;AAgBD","sourcesContent":["import {\n NativeViewGestureHandler,\n PanGestureHandler,\n} from 'react-native-gesture-handler';\nimport React, { useRef } from 'react';\nimport Animated, {\n useAnimatedGestureHandler,\n withTiming,\n} from 'react-native-reanimated';\nimport usePullToRefreshContext from './usePullToRefreshContext';\nimport { StyleSheet } from 'react-native';\nimport { rubberClamp } from './utils';\n\ntype Props = {\n children: React.ReactNode;\n scrollY: Animated.SharedValue<number>;\n};\n\nexport default function PullToRefreshContainer({ children, scrollY }: Props) {\n const scrollRef = useRef();\n const panRef = useRef();\n const { refreshValue, internalRefreshing, internalHeight } =\n usePullToRefreshContext();\n\n const gestureHandler = useAnimatedGestureHandler({\n onStart: (_, ctx: any) => {\n ctx.startY =\n (internalRefreshing.value ? refreshValue.value : 0) - scrollY.value;\n },\n onActive: (event, ctx: any) => {\n if (scrollY.value <= 1) {\n const tranY = event.translationY + ctx.startY;\n const clampedValue = rubberClamp(tranY, 0, internalHeight.value);\n refreshValue.value = clampedValue;\n if (clampedValue > internalHeight.value) {\n internalRefreshing.value = true;\n }\n } else if (!internalRefreshing.value) {\n refreshValue.value = 0;\n }\n },\n onEnd: () => {\n if (refreshValue.value > 0) {\n const value = internalRefreshing.value ? internalHeight.value : 0;\n refreshValue.value = withTiming(value);\n }\n },\n });\n\n return (\n <PanGestureHandler\n ref={panRef}\n simultaneousHandlers={scrollRef}\n onGestureEvent={gestureHandler}\n shouldCancelWhenOutside={false}\n enableTrackpadTwoFingerGesture\n maxPointers={1}\n >\n <Animated.View style={StyleSheet.absoluteFill}>\n <NativeViewGestureHandler ref={scrollRef} simultaneousHandlers={panRef}>\n {children}\n </NativeViewGestureHandler>\n </Animated.View>\n </PanGestureHandler>\n );\n}\n"]}
@@ -1,35 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = PullToRefreshProvider;
7
-
8
- var _react = _interopRequireWildcard(require("react"));
9
-
10
- var _reactNativeReanimated = require("react-native-reanimated");
11
-
12
- var _usePullToRefreshContext = require("./usePullToRefreshContext");
13
-
14
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
-
16
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
-
18
- function PullToRefreshProvider({
19
- children
20
- }) {
21
- const refreshValue = (0, _reactNativeReanimated.useSharedValue)(0);
22
- const internalRefreshing = (0, _reactNativeReanimated.useSharedValue)(false);
23
- const internalHeight = (0, _reactNativeReanimated.useSharedValue)(0);
24
- const context = (0, _react.useMemo)(() => {
25
- return {
26
- refreshValue: refreshValue,
27
- internalRefreshing,
28
- internalHeight
29
- };
30
- }, [refreshValue, internalRefreshing, internalHeight]);
31
- return /*#__PURE__*/_react.default.createElement(_usePullToRefreshContext.PullToRefreshContext.Provider, {
32
- value: context
33
- }, children);
34
- }
35
- //# sourceMappingURL=PullToRefreshProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["PullToRefreshProvider.tsx"],"names":["PullToRefreshProvider","children","refreshValue","internalRefreshing","internalHeight","context"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;;;AAMe,SAASA,qBAAT,CAA+B;AAAEC,EAAAA;AAAF,CAA/B,EAAoD;AACjE,QAAMC,YAAY,GAAG,2CAAe,CAAf,CAArB;AACA,QAAMC,kBAAkB,GAAG,2CAAe,KAAf,CAA3B;AACA,QAAMC,cAAc,GAAG,2CAAe,CAAf,CAAvB;AAEA,QAAMC,OAAO,GAAG,oBAAQ,MAAM;AAC5B,WAAO;AACLH,MAAAA,YAAY,EAAEA,YADT;AAELC,MAAAA,kBAFK;AAGLC,MAAAA;AAHK,KAAP;AAKD,GANe,EAMb,CAACF,YAAD,EAAeC,kBAAf,EAAmCC,cAAnC,CANa,CAAhB;AAQA,sBACE,6BAAC,6CAAD,CAAsB,QAAtB;AAA+B,IAAA,KAAK,EAAEC;AAAtC,KACGJ,QADH,CADF;AAKD","sourcesContent":["import React, { useMemo } from 'react';\nimport { useSharedValue } from 'react-native-reanimated';\nimport { PullToRefreshContext } from './usePullToRefreshContext';\n\ntype Props = {\n children: React.ReactNode;\n};\n\nexport default function PullToRefreshProvider({ children }: Props) {\n const refreshValue = useSharedValue(0);\n const internalRefreshing = useSharedValue(false);\n const internalHeight = useSharedValue(0);\n\n const context = useMemo(() => {\n return {\n refreshValue: refreshValue,\n internalRefreshing,\n internalHeight,\n };\n }, [refreshValue, internalRefreshing, internalHeight]);\n\n return (\n <PullToRefreshContext.Provider value={context}>\n {children}\n </PullToRefreshContext.Provider>\n );\n}\n"]}
@@ -1,91 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = RefreshControl;
7
-
8
- var _react = _interopRequireWildcard(require("react"));
9
-
10
- var _reactNative = require("react-native");
11
-
12
- var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
13
-
14
- var _usePullToRefreshContext = _interopRequireDefault(require("./usePullToRefreshContext"));
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
-
20
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
-
22
- /* eslint-disable react-hooks/exhaustive-deps */
23
- function RefreshControl({
24
- height = 100,
25
- refreshing,
26
- onRefresh,
27
- renderAnimation
28
- }) {
29
- const {
30
- refreshValue,
31
- internalRefreshing,
32
- internalHeight
33
- } = (0, _usePullToRefreshContext.default)();
34
- const manualTriggered = (0, _react.useRef)(false);
35
- (0, _react.useEffect)(() => {
36
- internalHeight.value = height;
37
- }, [height]);
38
- (0, _react.useEffect)(() => {
39
- if (!internalRefreshing.value && refreshing) {
40
- manualTriggered.current = true;
41
- }
42
-
43
- internalRefreshing.value = refreshing;
44
- }, [refreshing]);
45
- (0, _reactNativeReanimated.useAnimatedReaction)(() => {
46
- return internalRefreshing.value;
47
- }, (result, prev) => {
48
- if (result !== prev) {
49
- if (result && refreshValue.value === 0) {
50
- refreshValue.value = height;
51
- }
52
- }
53
- });
54
- const animatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
55
- return {
56
- height: refreshValue.value
57
- };
58
- }, []);
59
- const handleRefresh = (0, _react.useCallback)(() => {
60
- if (manualTriggered.current) {
61
- manualTriggered.current = false;
62
- return;
63
- }
64
-
65
- onRefresh();
66
- }, [onRefresh]);
67
- (0, _reactNativeReanimated.useAnimatedReaction)(() => internalRefreshing.value, (result, prev) => {
68
- if (result !== prev) {
69
- if (result) {
70
- (0, _reactNativeReanimated.runOnJS)(handleRefresh)();
71
- } else {
72
- refreshValue.value = (0, _reactNativeReanimated.withTiming)(0);
73
- }
74
- }
75
- });
76
- const animatedProps = (0, _reactNativeReanimated.useAnimatedProps)(() => {
77
- return {
78
- progress: internalRefreshing.value ? undefined : Math.min(refreshValue.value / height, 1)
79
- };
80
- }, [height]);
81
- return /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
82
- style: [styles.container, animatedStyle]
83
- }, renderAnimation(animatedProps));
84
- }
85
-
86
- const styles = _reactNative.StyleSheet.create({
87
- container: {
88
- overflow: 'hidden'
89
- }
90
- });
91
- //# sourceMappingURL=RefreshControl.js.map