@r0b0t3d/react-native-collapsible 1.1.2 → 1.2.0-alpha.3

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 (109) hide show
  1. package/lib/commonjs/components/CollapsibleContainer.js +41 -4
  2. package/lib/commonjs/components/CollapsibleContainer.js.map +1 -1
  3. package/lib/commonjs/components/{AnimatedTopView.js → header/AnimatedTopView.js} +0 -0
  4. package/lib/commonjs/components/{AnimatedTopView.js.map → header/AnimatedTopView.js.map} +0 -0
  5. package/lib/commonjs/components/{CollapsibleHeaderContainer.js → header/CollapsibleHeaderContainer.js} +6 -8
  6. package/lib/commonjs/components/header/CollapsibleHeaderContainer.js.map +1 -0
  7. package/lib/commonjs/components/{StickyView.js → header/StickyView.js} +4 -4
  8. package/lib/commonjs/components/header/StickyView.js.map +1 -0
  9. package/lib/commonjs/components/pullToRefresh/PullToRefreshContainer.js +75 -0
  10. package/lib/commonjs/components/pullToRefresh/PullToRefreshContainer.js.map +1 -0
  11. package/lib/commonjs/components/pullToRefresh/PullToRefreshProvider.js +35 -0
  12. package/lib/commonjs/components/pullToRefresh/PullToRefreshProvider.js.map +1 -0
  13. package/lib/commonjs/components/pullToRefresh/RefreshControl.js +81 -0
  14. package/lib/commonjs/components/pullToRefresh/RefreshControl.js.map +1 -0
  15. package/lib/commonjs/components/pullToRefresh/usePullToRefreshContext.js +24 -0
  16. package/lib/commonjs/components/pullToRefresh/usePullToRefreshContext.js.map +1 -0
  17. package/lib/commonjs/components/pullToRefresh/utils.js +59 -0
  18. package/lib/commonjs/components/pullToRefresh/utils.js.map +1 -0
  19. package/lib/commonjs/components/{CollapsibleFlatList.js → scrollable/CollapsibleFlatList.js} +28 -27
  20. package/lib/commonjs/components/scrollable/CollapsibleFlatList.js.map +1 -0
  21. package/lib/commonjs/components/{CollapsibleScrollView.js → scrollable/CollapsibleScrollView.js} +11 -12
  22. package/lib/commonjs/components/scrollable/CollapsibleScrollView.js.map +1 -0
  23. package/lib/commonjs/{hooks → components/scrollable}/useAnimatedScroll.js +3 -3
  24. package/lib/commonjs/{hooks → components/scrollable}/useAnimatedScroll.js.map +1 -1
  25. package/lib/commonjs/hooks/useInternalCollapsibleContext.js +1 -1
  26. package/lib/commonjs/hooks/useInternalCollapsibleContext.js.map +1 -1
  27. package/lib/commonjs/hooks/useKeyboardShowEvent.js +29 -0
  28. package/lib/commonjs/hooks/useKeyboardShowEvent.js.map +1 -0
  29. package/lib/commonjs/index.js +21 -12
  30. package/lib/commonjs/index.js.map +1 -1
  31. package/lib/commonjs/{hooks/withCollapsibleContext.js → withCollapsibleContext.js} +11 -5
  32. package/lib/commonjs/withCollapsibleContext.js.map +1 -0
  33. package/lib/module/components/CollapsibleContainer.js +38 -5
  34. package/lib/module/components/CollapsibleContainer.js.map +1 -1
  35. package/lib/module/components/{AnimatedTopView.js → header/AnimatedTopView.js} +0 -0
  36. package/lib/module/components/{AnimatedTopView.js.map → header/AnimatedTopView.js.map} +0 -0
  37. package/lib/module/components/{CollapsibleHeaderContainer.js → header/CollapsibleHeaderContainer.js} +4 -6
  38. package/lib/module/components/header/CollapsibleHeaderContainer.js.map +1 -0
  39. package/lib/module/components/{StickyView.js → header/StickyView.js} +2 -2
  40. package/lib/module/components/header/StickyView.js.map +1 -0
  41. package/lib/module/components/pullToRefresh/PullToRefreshContainer.js +56 -0
  42. package/lib/module/components/pullToRefresh/PullToRefreshContainer.js.map +1 -0
  43. package/lib/module/components/pullToRefresh/PullToRefreshProvider.js +21 -0
  44. package/lib/module/components/pullToRefresh/PullToRefreshProvider.js.map +1 -0
  45. package/lib/module/components/pullToRefresh/RefreshControl.js +63 -0
  46. package/lib/module/components/pullToRefresh/RefreshControl.js.map +1 -0
  47. package/lib/module/components/pullToRefresh/usePullToRefreshContext.js +13 -0
  48. package/lib/module/components/pullToRefresh/usePullToRefreshContext.js.map +1 -0
  49. package/lib/module/components/pullToRefresh/utils.js +42 -0
  50. package/lib/module/components/pullToRefresh/utils.js.map +1 -0
  51. package/lib/module/components/{CollapsibleFlatList.js → scrollable/CollapsibleFlatList.js} +28 -27
  52. package/lib/module/components/scrollable/CollapsibleFlatList.js.map +1 -0
  53. package/lib/module/components/{CollapsibleScrollView.js → scrollable/CollapsibleScrollView.js} +12 -12
  54. package/lib/module/components/scrollable/CollapsibleScrollView.js.map +1 -0
  55. package/lib/module/{hooks → components/scrollable}/useAnimatedScroll.js +2 -2
  56. package/lib/module/{hooks → components/scrollable}/useAnimatedScroll.js.map +1 -1
  57. package/lib/module/hooks/useInternalCollapsibleContext.js +1 -1
  58. package/lib/module/hooks/useInternalCollapsibleContext.js.map +1 -1
  59. package/lib/module/hooks/useKeyboardShowEvent.js +19 -0
  60. package/lib/module/hooks/useKeyboardShowEvent.js.map +1 -0
  61. package/lib/module/index.js +6 -5
  62. package/lib/module/index.js.map +1 -1
  63. package/lib/module/{hooks/withCollapsibleContext.js → withCollapsibleContext.js} +8 -5
  64. package/lib/module/withCollapsibleContext.js.map +1 -0
  65. package/lib/typescript/components/CollapsibleContainer.d.ts +4 -2
  66. package/lib/typescript/components/{AnimatedTopView.d.ts → header/AnimatedTopView.d.ts} +0 -0
  67. package/lib/typescript/components/{CollapsibleHeaderContainer.d.ts → header/CollapsibleHeaderContainer.d.ts} +0 -0
  68. package/lib/typescript/components/{StickyView.d.ts → header/StickyView.d.ts} +0 -0
  69. package/lib/typescript/components/pullToRefresh/PullToRefreshContainer.d.ts +8 -0
  70. package/lib/typescript/components/pullToRefresh/PullToRefreshProvider.d.ts +6 -0
  71. package/lib/typescript/components/pullToRefresh/RefreshControl.d.ts +9 -0
  72. package/lib/typescript/components/pullToRefresh/usePullToRefreshContext.d.ts +4 -0
  73. package/lib/typescript/components/pullToRefresh/utils.d.ts +20 -0
  74. package/lib/typescript/components/{CollapsibleFlatList.d.ts → scrollable/CollapsibleFlatList.d.ts} +1 -1
  75. package/lib/typescript/components/{CollapsibleScrollView.d.ts → scrollable/CollapsibleScrollView.d.ts} +1 -1
  76. package/lib/typescript/{hooks → components/scrollable}/useAnimatedScroll.d.ts +0 -0
  77. package/lib/typescript/hooks/useInternalCollapsibleContext.d.ts +1 -1
  78. package/lib/typescript/hooks/useKeyboardShowEvent.d.ts +1 -0
  79. package/lib/typescript/index.d.ts +6 -5
  80. package/lib/typescript/types.d.ts +6 -0
  81. package/lib/typescript/{hooks/withCollapsibleContext.d.ts → withCollapsibleContext.d.ts} +0 -0
  82. package/package.json +4 -2
  83. package/src/components/CollapsibleContainer.tsx +62 -11
  84. package/src/components/{AnimatedTopView.tsx → header/AnimatedTopView.tsx} +0 -0
  85. package/src/components/{CollapsibleHeaderContainer.tsx → header/CollapsibleHeaderContainer.tsx} +4 -7
  86. package/src/components/{StickyView.tsx → header/StickyView.tsx} +2 -2
  87. package/src/components/pullToRefresh/PullToRefreshContainer.tsx +66 -0
  88. package/src/components/pullToRefresh/PullToRefreshProvider.tsx +27 -0
  89. package/src/components/pullToRefresh/RefreshControl.tsx +92 -0
  90. package/src/components/pullToRefresh/usePullToRefreshContext.ts +13 -0
  91. package/src/components/pullToRefresh/utils.ts +49 -0
  92. package/src/components/{CollapsibleFlatList.tsx → scrollable/CollapsibleFlatList.tsx} +27 -24
  93. package/src/components/{CollapsibleScrollView.tsx → scrollable/CollapsibleScrollView.tsx} +11 -12
  94. package/src/{hooks → components/scrollable}/useAnimatedScroll.ts +2 -2
  95. package/src/hooks/useInternalCollapsibleContext.ts +1 -1
  96. package/src/hooks/useKeyboardShowEvent.ts +22 -0
  97. package/src/index.tsx +6 -5
  98. package/src/types.ts +7 -0
  99. package/src/{hooks/withCollapsibleContext.tsx → withCollapsibleContext.tsx} +11 -6
  100. package/lib/commonjs/components/CollapsibleFlatList.js.map +0 -1
  101. package/lib/commonjs/components/CollapsibleHeaderContainer.js.map +0 -1
  102. package/lib/commonjs/components/CollapsibleScrollView.js.map +0 -1
  103. package/lib/commonjs/components/StickyView.js.map +0 -1
  104. package/lib/commonjs/hooks/withCollapsibleContext.js.map +0 -1
  105. package/lib/module/components/CollapsibleFlatList.js.map +0 -1
  106. package/lib/module/components/CollapsibleHeaderContainer.js.map +0 -1
  107. package/lib/module/components/CollapsibleScrollView.js.map +0 -1
  108. package/lib/module/components/StickyView.js.map +0 -1
  109. package/lib/module/hooks/withCollapsibleContext.js.map +0 -1
@@ -0,0 +1,63 @@
1
+ /* eslint-disable react-hooks/exhaustive-deps */
2
+ import React, { useCallback, useEffect } from 'react';
3
+ import { StyleSheet } from 'react-native';
4
+ import Animated, { runOnJS, useAnimatedProps, useAnimatedReaction, useAnimatedStyle, withTiming } from 'react-native-reanimated';
5
+ import usePullToRefreshContext from './usePullToRefreshContext';
6
+ export default function RefreshControl({
7
+ height = 100,
8
+ refreshing,
9
+ onRefresh,
10
+ renderAnimation
11
+ }) {
12
+ const {
13
+ refreshValue,
14
+ internalRefreshing,
15
+ internalHeight
16
+ } = usePullToRefreshContext();
17
+ useEffect(() => {
18
+ internalHeight.value = height;
19
+ }, [height]);
20
+ useEffect(() => {
21
+ internalRefreshing.value = refreshing;
22
+ }, [refreshing]);
23
+ useAnimatedReaction(() => {
24
+ return internalRefreshing.value;
25
+ }, (result, prev) => {
26
+ if (result !== prev) {
27
+ if (result && refreshValue.value === 0) {
28
+ refreshValue.value = height;
29
+ }
30
+ }
31
+ });
32
+ const animatedStyle = useAnimatedStyle(() => {
33
+ return {
34
+ height: refreshValue.value
35
+ };
36
+ }, []);
37
+ const handleRefresh = useCallback(() => {
38
+ onRefresh();
39
+ }, [onRefresh]);
40
+ useAnimatedReaction(() => internalRefreshing.value, (result, prev) => {
41
+ if (result !== prev) {
42
+ if (result) {
43
+ runOnJS(handleRefresh)();
44
+ } else {
45
+ refreshValue.value = withTiming(0);
46
+ }
47
+ }
48
+ });
49
+ const animatedProps = useAnimatedProps(() => {
50
+ return {
51
+ progress: internalRefreshing.value ? undefined : Math.min(refreshValue.value / height, 1)
52
+ };
53
+ }, [height]);
54
+ return /*#__PURE__*/React.createElement(Animated.View, {
55
+ style: [styles.container, animatedStyle]
56
+ }, renderAnimation(animatedProps));
57
+ }
58
+ const styles = StyleSheet.create({
59
+ container: {
60
+ overflow: 'hidden'
61
+ }
62
+ });
63
+ //# sourceMappingURL=RefreshControl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["RefreshControl.tsx"],"names":["React","useCallback","useEffect","StyleSheet","Animated","runOnJS","useAnimatedProps","useAnimatedReaction","useAnimatedStyle","withTiming","usePullToRefreshContext","RefreshControl","height","refreshing","onRefresh","renderAnimation","refreshValue","internalRefreshing","internalHeight","value","result","prev","animatedStyle","handleRefresh","animatedProps","progress","undefined","Math","min","styles","container","create","overflow"],"mappings":"AAAA;AACA,OAAOA,KAAP,IAAgBC,WAAhB,EAA6BC,SAA7B,QAA8C,OAA9C;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,OAAOC,QAAP,IACEC,OADF,EAEEC,gBAFF,EAGEC,mBAHF,EAIEC,gBAJF,EAKEC,UALF,QAMO,yBANP;AAOA,OAAOC,uBAAP,MAAoC,2BAApC;AASA,eAAe,SAASC,cAAT,CAAwB;AACrCC,EAAAA,MAAM,GAAG,GAD4B;AAErCC,EAAAA,UAFqC;AAGrCC,EAAAA,SAHqC;AAIrCC,EAAAA;AAJqC,CAAxB,EAKL;AACR,QAAM;AAAEC,IAAAA,YAAF;AAAgBC,IAAAA,kBAAhB;AAAoCC,IAAAA;AAApC,MACJR,uBAAuB,EADzB;AAGAR,EAAAA,SAAS,CAAC,MAAM;AACdgB,IAAAA,cAAc,CAACC,KAAf,GAAuBP,MAAvB;AACD,GAFQ,EAEN,CAACA,MAAD,CAFM,CAAT;AAIAV,EAAAA,SAAS,CAAC,MAAM;AACde,IAAAA,kBAAkB,CAACE,KAAnB,GAA2BN,UAA3B;AACD,GAFQ,EAEN,CAACA,UAAD,CAFM,CAAT;AAIAN,EAAAA,mBAAmB,CACjB,MAAM;AACJ,WAAOU,kBAAkB,CAACE,KAA1B;AACD,GAHgB,EAIjB,CAAC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AAC/BD,EAAAA,SAAS,EAAE;AACTE,IAAAA,QAAQ,EAAE;AADD;AADoB,CAAlB,CAAf","sourcesContent":["/* eslint-disable react-hooks/exhaustive-deps */\nimport React, { useCallback, useEffect } from 'react';\nimport { StyleSheet } from 'react-native';\nimport Animated, {\n runOnJS,\n useAnimatedProps,\n useAnimatedReaction,\n useAnimatedStyle,\n withTiming,\n} from 'react-native-reanimated';\nimport usePullToRefreshContext from './usePullToRefreshContext';\n\ntype Props = {\n height?: number;\n refreshing: boolean;\n onRefresh: () => void;\n renderAnimation: (animatedProps: any) => React.ReactNode;\n};\n\nexport default function RefreshControl({\n height = 100,\n refreshing,\n onRefresh,\n renderAnimation,\n}: Props) {\n const { refreshValue, internalRefreshing, internalHeight } =\n usePullToRefreshContext();\n\n useEffect(() => {\n internalHeight.value = height;\n }, [height]);\n\n useEffect(() => {\n internalRefreshing.value = refreshing;\n }, [refreshing]);\n\n useAnimatedReaction(\n () => {\n return internalRefreshing.value;\n },\n (result, prev) => {\n if (result !== prev) {\n if (result && refreshValue.value === 0) {\n refreshValue.value = height;\n }\n }\n }\n );\n\n const animatedStyle = useAnimatedStyle(() => {\n return {\n height: refreshValue.value,\n };\n }, []);\n\n const handleRefresh = useCallback(() => {\n onRefresh();\n }, [onRefresh]);\n\n useAnimatedReaction(\n () => internalRefreshing.value,\n (result, prev) => {\n if (result !== prev) {\n if (result) {\n runOnJS(handleRefresh)();\n } else {\n refreshValue.value = withTiming(0);\n }\n }\n }\n );\n\n const animatedProps = useAnimatedProps(() => {\n return {\n progress: internalRefreshing.value\n ? undefined\n : Math.min(refreshValue.value / height, 1),\n };\n }, [height]);\n\n return (\n <Animated.View style={[styles.container, animatedStyle]}>\n {renderAnimation(animatedProps)}\n </Animated.View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n overflow: 'hidden',\n },\n});\n"]}
@@ -0,0 +1,13 @@
1
+ import { createContext, useContext } from 'react';
2
+ // @ts-ignore
3
+ export const PullToRefreshContext = /*#__PURE__*/createContext({});
4
+ export default function usePullToRefreshContext() {
5
+ const ctx = useContext(PullToRefreshContext);
6
+
7
+ if (!ctx) {
8
+ throw new Error('Component should be wrapped with withCollapsibleContext');
9
+ }
10
+
11
+ return ctx;
12
+ }
13
+ //# sourceMappingURL=usePullToRefreshContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["usePullToRefreshContext.ts"],"names":["createContext","useContext","PullToRefreshContext","usePullToRefreshContext","ctx","Error"],"mappings":"AAAA,SAASA,aAAT,EAAwBC,UAAxB,QAA0C,OAA1C;AAGA;AACA,OAAO,MAAMC,oBAAoB,gBAAGF,aAAa,CAA2B,EAA3B,CAA1C;AAEP,eAAe,SAASG,uBAAT,GAAmC;AAChD,QAAMC,GAAG,GAAGH,UAAU,CAACC,oBAAD,CAAtB;;AACA,MAAI,CAACE,GAAL,EAAU;AACR,UAAM,IAAIC,KAAJ,CAAU,yDAAV,CAAN;AACD;;AACD,SAAOD,GAAP;AACD","sourcesContent":["import { createContext, useContext } from 'react';\nimport type { PullToRefreshContextType } from '../../types';\n\n// @ts-ignore\nexport const PullToRefreshContext = createContext<PullToRefreshContextType>({});\n\nexport default function usePullToRefreshContext() {\n const ctx = useContext(PullToRefreshContext);\n if (!ctx) {\n throw new Error('Component should be wrapped with withCollapsibleContext');\n }\n return ctx;\n}\n"]}
@@ -0,0 +1,42 @@
1
+ export const springConfig = velocity => {
2
+ 'worklet';
3
+
4
+ return {
5
+ stiffness: 1000,
6
+ damping: 500,
7
+ mass: 3,
8
+ overshootClamping: true,
9
+ restDisplacementThreshold: 0.01,
10
+ restSpeedThreshold: 0.01,
11
+ velocity
12
+ };
13
+ };
14
+ export function clamp(value, lowerbound, upperbound) {
15
+ 'worklet';
16
+
17
+ return Math.min(Math.max(value, lowerbound), upperbound);
18
+ }
19
+ /**
20
+ * calculates rubber value
21
+ *
22
+ * @param x distance from the edge
23
+ * @param dim dimension, either width or height
24
+ * @param coeff constant value, UIScrollView uses 0.55
25
+ * @returns rubber = (1.0 – (1.0 / ((x * coeff / dim) + 1.0))) * dim
26
+ */
27
+
28
+ export const rubberBandClamp = (x, dim, coeff) => {
29
+ 'worklet';
30
+
31
+ return (1.0 - 1.0 / (x * coeff / dim + 1.0)) * dim;
32
+ };
33
+ export const rubberClamp = (y, topBound, bottomBound, coeff = 0.55) => {
34
+ 'worklet';
35
+
36
+ const clampedY = clamp(y, topBound, bottomBound);
37
+ const diff = Math.abs(y - clampedY);
38
+ const sign = clampedY > y ? -1 : 1;
39
+ const dimension = bottomBound - topBound;
40
+ return clampedY + sign * rubberBandClamp(diff, dimension, coeff);
41
+ };
42
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["utils.ts"],"names":["springConfig","velocity","stiffness","damping","mass","overshootClamping","restDisplacementThreshold","restSpeedThreshold","clamp","value","lowerbound","upperbound","Math","min","max","rubberBandClamp","x","dim","coeff","rubberClamp","y","topBound","bottomBound","clampedY","diff","abs","sign","dimension"],"mappings":"AAAA,OAAO,MAAMA,YAAY,GAAIC,QAAD,IAAsB;AAChD;;AAEA,SAAO;AACLC,IAAAA,SAAS,EAAE,IADN;AAELC,IAAAA,OAAO,EAAE,GAFJ;AAGLC,IAAAA,IAAI,EAAE,CAHD;AAILC,IAAAA,iBAAiB,EAAE,IAJd;AAKLC,IAAAA,yBAAyB,EAAE,IALtB;AAMLC,IAAAA,kBAAkB,EAAE,IANf;AAOLN,IAAAA;AAPK,GAAP;AASD,CAZM;AAcP,OAAO,SAASO,KAAT,CAAeC,KAAf,EAA8BC,UAA9B,EAAkDC,UAAlD,EAAsE;AAC3E;;AAEA,SAAOC,IAAI,CAACC,GAAL,CAASD,IAAI,CAACE,GAAL,CAASL,KAAT,EAAgBC,UAAhB,CAAT,EAAsCC,UAAtC,CAAP;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMI,eAAe,GAAG,CAACC,CAAD,EAAYC,GAAZ,EAAyBC,KAAzB,KAA2C;AACxE;;AAEA,SAAO,CAAC,MAAM,OAAQF,CAAC,GAAGE,KAAL,GAAcD,GAAd,GAAoB,GAA3B,CAAP,IAA0CA,GAAjD;AACD,CAJM;AAMP,OAAO,MAAME,WAAW,GAAG,CACzBC,CADyB,EAEzBC,QAFyB,EAGzBC,WAHyB,EAIzBJ,KAAK,GAAG,IAJiB,KAKtB;AACH;;AAEA,QAAMK,QAAQ,GAAGf,KAAK,CAACY,CAAD,EAAIC,QAAJ,EAAcC,WAAd,CAAtB;AACA,QAAME,IAAI,GAAGZ,IAAI,CAACa,GAAL,CAASL,CAAC,GAAGG,QAAb,CAAb;AACA,QAAMG,IAAI,GAAGH,QAAQ,GAAGH,CAAX,GAAe,CAAC,CAAhB,GAAoB,CAAjC;AACA,QAAMO,SAAS,GAAGL,WAAW,GAAGD,QAAhC;AAEA,SAAOE,QAAQ,GAAGG,IAAI,GAAGX,eAAe,CAACS,IAAD,EAAOG,SAAP,EAAkBT,KAAlB,CAAxC;AACD,CAdM","sourcesContent":["export const springConfig = (velocity: number) => {\n 'worklet';\n\n return {\n stiffness: 1000,\n damping: 500,\n mass: 3,\n overshootClamping: true,\n restDisplacementThreshold: 0.01,\n restSpeedThreshold: 0.01,\n velocity,\n };\n};\n\nexport function clamp(value: number, lowerbound: number, upperbound: number) {\n 'worklet';\n\n return Math.min(Math.max(value, lowerbound), upperbound);\n}\n\n/**\n * calculates rubber value\n *\n * @param x distance from the edge\n * @param dim dimension, either width or height\n * @param coeff constant value, UIScrollView uses 0.55\n * @returns rubber = (1.0 – (1.0 / ((x * coeff / dim) + 1.0))) * dim\n */\nexport const rubberBandClamp = (x: number, dim: number, coeff: number) => {\n 'worklet';\n\n return (1.0 - 1.0 / ((x * coeff) / dim + 1.0)) * dim;\n};\n\nexport const rubberClamp = (\n y: number,\n topBound: number,\n bottomBound: number,\n coeff = 0.55\n) => {\n 'worklet';\n\n const clampedY = clamp(y, topBound, bottomBound);\n const diff = Math.abs(y - clampedY);\n const sign = clampedY > y ? -1 : 1;\n const dimension = bottomBound - topBound;\n\n return clampedY + sign * rubberBandClamp(diff, dimension, coeff);\n};\n"]}
@@ -1,23 +1,26 @@
1
1
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
 
3
+ /* eslint-disable react-hooks/exhaustive-deps */
3
4
  import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
4
- import { FlatList, View, StyleSheet } from 'react-native';
5
+ import { View, StyleSheet, FlatList } from 'react-native';
5
6
  import Animated, { runOnJS, useAnimatedReaction } from 'react-native-reanimated';
6
- import AnimatedTopView from './AnimatedTopView';
7
- import useAnimatedScroll from '../hooks/useAnimatedScroll';
8
- import useCollapsibleContext from '../hooks/useCollapsibleContext';
9
- import { useInternalCollapsibleContext } from '../hooks/useInternalCollapsibleContext';
7
+ import AnimatedTopView from '../header/AnimatedTopView';
8
+ import useAnimatedScroll from './useAnimatedScroll';
9
+ import useCollapsibleContext from '../../hooks/useCollapsibleContext';
10
+ import useInternalCollapsibleContext from '../../hooks/useInternalCollapsibleContext';
11
+ import PullToRefreshContainer from '../pullToRefresh/PullToRefreshContainer';
10
12
  const AnimatedFlatList = Animated.createAnimatedComponent(FlatList);
11
13
  export default function CollapsibleFlatList({
12
14
  headerSnappable = true,
13
15
  ...props
14
16
  }) {
15
- const scrollView = useRef(null);
16
17
  const {
17
- headerHeight
18
+ headerHeight,
19
+ scrollY
18
20
  } = useCollapsibleContext();
19
21
  const {
20
- contentMinHeight
22
+ contentMinHeight,
23
+ scrollViewRef
21
24
  } = useInternalCollapsibleContext();
22
25
  const mounted = useRef(true);
23
26
  const contentHeight = useRef(0);
@@ -27,9 +30,9 @@ export default function CollapsibleFlatList({
27
30
  };
28
31
  }, []);
29
32
  const scrollTo = useCallback((yValue, animated = true) => {
30
- var _scrollView$current;
33
+ var _scrollViewRef$curren;
31
34
 
32
- (_scrollView$current = scrollView.current) === null || _scrollView$current === void 0 ? void 0 : _scrollView$current.scrollToOffset({
35
+ (_scrollViewRef$curren = scrollViewRef.current) === null || _scrollViewRef$curren === void 0 ? void 0 : _scrollViewRef$curren.scrollToOffset({
33
36
  offset: yValue,
34
37
  animated
35
38
  });
@@ -66,23 +69,21 @@ export default function CollapsibleFlatList({
66
69
  height: headerHeight
67
70
  }), props.ListHeaderComponent);
68
71
 
69
- return (
70
- /*#__PURE__*/
71
- // @ts-ignore
72
- React.createElement(AnimatedFlatList, _extends({
73
- ref: scrollView,
74
- bounces: false,
75
- keyboardDismissMode: "on-drag",
76
- keyboardShouldPersistTaps: "handled",
77
- scrollEventThrottle: 16
78
- }, props, {
79
- style: [styles.container, props.style],
80
- contentContainerStyle: contentContainerStyle,
81
- onScroll: scrollHandler,
82
- ListHeaderComponent: renderListHeader(),
83
- onContentSizeChange: handleContentSizeChange
84
- }))
85
- );
72
+ return /*#__PURE__*/React.createElement(PullToRefreshContainer, {
73
+ scrollY: scrollY
74
+ }, /*#__PURE__*/React.createElement(AnimatedFlatList, _extends({
75
+ ref: scrollViewRef,
76
+ bounces: false,
77
+ keyboardDismissMode: "on-drag",
78
+ keyboardShouldPersistTaps: "handled",
79
+ scrollEventThrottle: 1
80
+ }, props, {
81
+ style: [styles.container, props.style],
82
+ contentContainerStyle: contentContainerStyle,
83
+ onScroll: scrollHandler,
84
+ ListHeaderComponent: renderListHeader(),
85
+ onContentSizeChange: handleContentSizeChange
86
+ })));
86
87
  }
87
88
  const styles = StyleSheet.create({
88
89
  container: { ...StyleSheet.absoluteFillObject
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["CollapsibleFlatList.tsx"],"names":["React","useCallback","useEffect","useMemo","useRef","useState","View","StyleSheet","FlatList","Animated","runOnJS","useAnimatedReaction","AnimatedTopView","useAnimatedScroll","useCollapsibleContext","useInternalCollapsibleContext","PullToRefreshContainer","AnimatedFlatList","createAnimatedComponent","CollapsibleFlatList","headerSnappable","props","headerHeight","scrollY","contentMinHeight","scrollViewRef","mounted","contentHeight","current","scrollTo","yValue","animated","scrollToOffset","offset","handleInternalContentHeight","value","setInternalContentMinHeight","scrollHandler","internalContentMinHeight","result","previous","contentContainerStyle","styles","contentContainer","minHeight","handleContentSizeChange","_","height","renderListHeader","ListHeaderComponent","container","style","create","absoluteFillObject","flexGrow","topView","position","top","left","right"],"mappings":";;AAAA;AACA,OAAOA,KAAP,IACEC,WADF,EAEEC,SAFF,EAGEC,OAHF,EAIEC,MAJF,EAKEC,QALF,QAMO,OANP;AAOA,SAAwBC,IAAxB,EAA8BC,UAA9B,EAA0CC,QAA1C,QAA0D,cAA1D;AACA,OAAOC,QAAP,IACEC,OADF,EAEEC,mBAFF,QAGO,yBAHP;AAIA,OAAOC,eAAP,MAA4B,2BAA5B;AACA,OAAOC,iBAAP,MAA8B,qBAA9B;AACA,OAAOC,qBAAP,MAAkC,mCAAlC;AACA,OAAOC,6BAAP,MAA0C,2CAA1C;AAEA,OAAOC,sBAAP,MAAmC,yCAAnC;AAEA,MAAMC,gBAAgB,GAAGR,QAAQ,CAACS,uBAAT,CAAiCV,QAAjC,CAAzB;AAKA,eAAe,SAASW,mBAAT,CAAmC;AAChDC,EAAAA,eAAe,GAAG,IAD8B;AAEhD,KAAGC;AAF6C,CAAnC,EAGC;AACd,QAAM;AAAEC,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,MAA4BT,qBAAqB,EAAvD;AACA,QAAM;AAAEU,IAAAA,gBAAF;AAAoBC,IAAAA;AAApB,MAAsCV,6BAA6B,EAAzE;AACA,QAAMW,OAAO,GAAGtB,MAAM,CAAC,IAAD,CAAtB;AACA,QAAMuB,aAAa,GAAGvB,MAAM,CAAC,CAAD,CAA5B;AAEAF,EAAAA,SAAS,CAAC,MAAM;AACd,WAAO,MAAM;AACXwB,MAAAA,OAAO,CAACE,OAAR,GAAkB,KAAlB;AACD,KAFD;AAGD,GAJ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ustive-deps */\nimport React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { FlatListProps, View, StyleSheet, FlatList } from 'react-native';\nimport Animated, {\n runOnJS,\n useAnimatedReaction,\n} from 'react-native-reanimated';\nimport AnimatedTopView from '../header/AnimatedTopView';\nimport useAnimatedScroll from './useAnimatedScroll';\nimport useCollapsibleContext from '../../hooks/useCollapsibleContext';\nimport useInternalCollapsibleContext from '../../hooks/useInternalCollapsibleContext';\nimport type { CollapsibleProps } from '../../types';\nimport PullToRefreshContainer from '../pullToRefresh/PullToRefreshContainer';\n\nconst AnimatedFlatList = Animated.createAnimatedComponent(FlatList);\n\ntype Props<Data> = Omit<FlatListProps<Data>, 'scrollEnabled'> &\n CollapsibleProps;\n\nexport default function CollapsibleFlatList<Data>({\n headerSnappable = true,\n ...props\n}: Props<Data>) {\n const { headerHeight, scrollY } = useCollapsibleContext();\n const { contentMinHeight, scrollViewRef } = useInternalCollapsibleContext();\n const mounted = useRef(true);\n const contentHeight = useRef(0);\n\n useEffect(() => {\n return () => {\n mounted.current = false;\n };\n }, []);\n\n const scrollTo = useCallback((yValue: number, animated = true) => {\n scrollViewRef.current?.scrollToOffset({\n offset: yValue,\n animated,\n });\n }, []);\n\n const handleInternalContentHeight = useCallback((value: number) => {\n if (mounted.current) {\n setInternalContentMinHeight(value);\n }\n }, []);\n\n const { scrollHandler } = useAnimatedScroll({\n headerSnappable,\n scrollTo,\n });\n\n const [internalContentMinHeight, setInternalContentMinHeight] = useState(\n contentMinHeight.value\n );\n\n useAnimatedReaction(\n () => {\n return contentMinHeight.value;\n },\n (result, previous) => {\n if (result !== previous) {\n if (\n contentHeight.current < contentMinHeight.value &&\n internalContentMinHeight !== contentMinHeight.value\n ) {\n runOnJS(handleInternalContentHeight)(contentMinHeight.value);\n }\n }\n }\n );\n\n const contentContainerStyle = useMemo(\n () => [\n styles.contentContainer,\n { minHeight: internalContentMinHeight },\n props.contentContainerStyle,\n ],\n [props.contentContainerStyle, internalContentMinHeight]\n );\n\n const handleContentSizeChange = useCallback((_, height) => {\n contentHeight.current = height;\n }, []);\n\n const renderListHeader = () => (\n <View>\n <AnimatedTopView height={headerHeight} />\n {props.ListHeaderComponent}\n </View>\n );\n\n return (\n <PullToRefreshContainer scrollY={scrollY}>\n {/* @ts-ignore */}\n <AnimatedFlatList\n ref={scrollViewRef}\n bounces={false}\n keyboardDismissMode=\"on-drag\"\n keyboardShouldPersistTaps=\"handled\"\n scrollEventThrottle={1}\n {...props}\n style={[styles.container, props.style]}\n contentContainerStyle={contentContainerStyle}\n onScroll={scrollHandler}\n ListHeaderComponent={renderListHeader()}\n onContentSizeChange={handleContentSizeChange}\n />\n </PullToRefreshContainer>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n ...StyleSheet.absoluteFillObject,\n },\n contentContainer: {\n flexGrow: 1,\n },\n topView: {\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n },\n});\n"]}
@@ -1,29 +1,29 @@
1
1
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
 
3
- import AnimatedTopView from './AnimatedTopView';
4
- import useAnimatedScroll from '../hooks/useAnimatedScroll';
5
- import React, { useCallback, useMemo, useRef } from 'react';
3
+ /* eslint-disable react-hooks/exhaustive-deps */
4
+ import AnimatedTopView from '../header/AnimatedTopView';
5
+ import useAnimatedScroll from './useAnimatedScroll';
6
+ import React, { useCallback, useMemo } from 'react';
6
7
  import { StyleSheet } from 'react-native';
7
8
  import Animated, { useAnimatedStyle } from 'react-native-reanimated';
8
- import useCollapsibleContext from '../hooks/useCollapsibleContext';
9
- import { useInternalCollapsibleContext } from '../hooks/useInternalCollapsibleContext';
9
+ import useCollapsibleContext from '../../hooks/useCollapsibleContext';
10
+ import useInternalCollapsibleContext from '../../hooks/useInternalCollapsibleContext';
10
11
  export default function CollapsibleScrollView({
11
12
  headerSnappable = true,
12
13
  children,
13
14
  ...props
14
15
  }) {
15
- const scrollView = useRef(null);
16
16
  const {
17
- contentMinHeight
17
+ contentMinHeight,
18
+ scrollViewRef
18
19
  } = useInternalCollapsibleContext();
19
20
  const {
20
21
  headerHeight
21
22
  } = useCollapsibleContext();
22
23
  const scrollTo = useCallback((yValue, animated = true) => {
23
- var _scrollView$current;
24
+ var _scrollViewRef$curren;
24
25
 
25
- // @ts-ignore
26
- (_scrollView$current = scrollView.current) === null || _scrollView$current === void 0 ? void 0 : _scrollView$current.scrollTo({
26
+ (_scrollViewRef$curren = scrollViewRef.current) === null || _scrollViewRef$curren === void 0 ? void 0 : _scrollViewRef$curren.scrollTo({
27
27
  y: yValue,
28
28
  animated
29
29
  });
@@ -41,7 +41,7 @@ export default function CollapsibleScrollView({
41
41
  }, []);
42
42
  const contentContainerStyle = useMemo(() => [styles.contentContainer, props.contentContainerStyle], [props.contentContainerStyle]);
43
43
  return /*#__PURE__*/React.createElement(Animated.ScrollView, _extends({
44
- ref: scrollView,
44
+ ref: scrollViewRef,
45
45
  bounces: false
46
46
  }, props, {
47
47
  style: [styles.container, props.style],
@@ -49,7 +49,7 @@ export default function CollapsibleScrollView({
49
49
  onScroll: scrollHandler,
50
50
  keyboardDismissMode: "on-drag",
51
51
  keyboardShouldPersistTaps: "handled",
52
- scrollEventThrottle: 16
52
+ scrollEventThrottle: 1
53
53
  }), /*#__PURE__*/React.createElement(Animated.View, {
54
54
  style: animatedStyle
55
55
  }, /*#__PURE__*/React.createElement(AnimatedTopView, {
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["CollapsibleScrollView.tsx"],"names":["AnimatedTopView","useAnimatedScroll","React","useCallback","useMemo","StyleSheet","Animated","useAnimatedStyle","useCollapsibleContext","useInternalCollapsibleContext","CollapsibleScrollView","headerSnappable","children","props","contentMinHeight","scrollViewRef","headerHeight","scrollTo","yValue","animated","current","y","scrollHandler","animatedStyle","minHeight","value","contentContainerStyle","styles","contentContainer","container","style","create","absoluteFillObject","flexGrow","topView","position","top","left","right"],"mappings":";;AAAA;AACA,OAAOA,eAAP,MAA4B,2BAA5B;AACA,OAAOC,iBAAP,MAA8B,qBAA9B;AACA,OAAOC,KAAP,IAA2BC,WAA3B,EAAwCC,OAAxC,QAAuD,OAAvD;AACA,SAA0BC,UAA1B,QAA4C,cAA5C;AACA,OAAOC,QAAP,IAAmBC,gBAAnB,QAA2C,yBAA3C;AAEA,OAAOC,qBAAP,MAAkC,mCAAlC;AACA,OAAOC,6BAAP,MAA0C,2CAA1C;AAOA,eAAe,SAASC,qBAAT,CAA+B;AAC5CC,EAAAA,eAAe,GAAG,IAD0B;AAE5CC,EAAAA,QAF4C;AAG5C,KAAGC;AAHyC,CAA/B,EAIL;AACR,QAAM;AAAEC,IAAAA,gBAAF;AAAoBC,IAAAA;AAApB,MAAsCN,6BAA6B,EAAzE;AACA,QAAM;AAAEO,IAAAA;AAAF,MAAmBR,qBAAqB,EAA9C;AAEA,QAAMS,QAAQ,GAAGd,WAAW,CAAC,CAACe,MAAD,EAAiBC,QAAQ,GAAG,IAA5B,KAAqC;AAAA;;AAChE,6BAAAJ,aAAa,CAACK,OAAd,gFAAuBH,QAAvB,CAAgC;AAAEI,MAAAA,CAAC,EAAEH,MAAL;AAAaC,MAAAA;AAAb,KAAhC;AACD,GAF2B,EAEzB,EAFyB,CAA5B;AAIA,QAAM;AAAEG,IAAAA;AAAF,MAAoBrB,iBAAiB,CAAC;AAC1CU,IAAAA,eAD0C;AAE1CM,IAAAA;AAF0C,GAAD,CAA3C;AAKA,QAAMM,aAAa,GAAGhB,gBAAgB,CAAC,MAAM;AAC3C,WAAO;AACLiB,MAAAA,SAAS,EAAEV,gBAAgB,CAACW;AADvB,KAAP;AAGD,GAJqC,EAInC,EAJmC,CAAtC;AAMA,QAAMC,qBAAqB,GAAGtB,OAAO,CACnC,MAAM,CAACuB,MAAM,CAACC,gBAAR,EAA0Bf,KAAK,CAACa,qBAAhC,CAD6B,EAEnC,CAACb,KAAK,CAACa,qBAAP,CAFmC,CAArC;AAKA,sBACE,oBAAC,QAAD,CAAU,UAAV;AACE,IAAA,GAAG,EAAEX,aADP;AAEE,IAAA,OAAO,EAAE;AAFX,KAGMF,KAHN;AAIE,IAAA,KAAK,EAAE,CAACc,MAAM,CAACE,SAAR,EAAmBhB,KAAK,CAACiB,KAAzB,CAJT;AAKE,IAAA,qBAAqB,EAAEJ,qBALzB;AAME,IAAA,QAAQ,EAAEJ,aANZ;AAOE,IAAA,mBAAmB,EAAC,SAPtB;AAQE,IAAA,yBAAyB,EAAC,SAR5B;AASE,IAAA,mBAAmB,EAAE;AATvB,mBAWE,oBAAC,QAAD,CAAU,IAAV;AAAe,IAAA,KAAK,EAAEC;AAAtB,kBACE,oBAAC,eAAD;AAAiB,IAAA,MAAM,EAAEP;AAAzB,IADF,EAEGJ,QAFH,CAXF,CADF;AAkBD;AAED,MAAMe,MAAM,GAAGtB,UAAU,CAAC0B,MAAX,CAAkB;AAC/BF,EAAAA,SAAS,EAAE,EACT,GAAGxB,UAAU,CAAC2B;AADL,GADoB;AAI/BJ,EAAAA,gBAAgB,EAAE;AAChBK,IAAAA,QAAQ,EAAE;AADM,GAJa;AAO/BC,EAAAA,OAAO,EAAE;AACPC,IAAAA,QAAQ,EAAE,UADH;AAEPC,IAAAA,GAAG,EAAE,CAFE;AAGPC,IAAAA,IAAI,EAAE,CAHC;AAIPC,IAAAA,KAAK,EAAE;AAJA;AAPsB,CAAlB,CAAf","sourcesContent":["/* eslint-disable react-hooks/exhaustive-deps */\nimport AnimatedTopView from '../header/AnimatedTopView';\nimport useAnimatedScroll from './useAnimatedScroll';\nimport React, { ReactNode, useCallback, useMemo } from 'react';\nimport { ScrollViewProps, StyleSheet } from 'react-native';\nimport Animated, { useAnimatedStyle } from 'react-native-reanimated';\nimport type { CollapsibleProps } from '../../types';\nimport useCollapsibleContext from '../../hooks/useCollapsibleContext';\nimport useInternalCollapsibleContext from '../../hooks/useInternalCollapsibleContext';\n\ntype Props = ScrollViewProps &\n CollapsibleProps & {\n children?: ReactNode;\n };\n\nexport default function CollapsibleScrollView({\n headerSnappable = true,\n children,\n ...props\n}: Props) {\n const { contentMinHeight, scrollViewRef } = useInternalCollapsibleContext();\n const { headerHeight } = useCollapsibleContext();\n\n const scrollTo = useCallback((yValue: number, animated = true) => {\n scrollViewRef.current?.scrollTo({ y: yValue, animated });\n }, []);\n\n const { scrollHandler } = useAnimatedScroll({\n headerSnappable,\n scrollTo,\n });\n\n const animatedStyle = useAnimatedStyle(() => {\n return {\n minHeight: contentMinHeight.value,\n };\n }, []);\n\n const contentContainerStyle = useMemo(\n () => [styles.contentContainer, props.contentContainerStyle],\n [props.contentContainerStyle]\n );\n\n return (\n <Animated.ScrollView\n ref={scrollViewRef}\n bounces={false}\n {...props}\n style={[styles.container, props.style]}\n contentContainerStyle={contentContainerStyle}\n onScroll={scrollHandler}\n keyboardDismissMode=\"on-drag\"\n keyboardShouldPersistTaps=\"handled\"\n scrollEventThrottle={1}\n >\n <Animated.View style={animatedStyle}>\n <AnimatedTopView height={headerHeight} />\n {children}\n </Animated.View>\n </Animated.ScrollView>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n ...StyleSheet.absoluteFillObject,\n },\n contentContainer: {\n flexGrow: 1,\n },\n topView: {\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n },\n});\n"]}
@@ -2,8 +2,8 @@
2
2
  import { useCallback, useEffect } from 'react';
3
3
  import { Dimensions } from 'react-native';
4
4
  import { runOnJS, useAnimatedScrollHandler, useSharedValue } from 'react-native-reanimated';
5
- import useCollapsibleContext from './useCollapsibleContext';
6
- import { useInternalCollapsibleContext } from './useInternalCollapsibleContext';
5
+ import useCollapsibleContext from '../../hooks/useCollapsibleContext';
6
+ import useInternalCollapsibleContext from '../../hooks/useInternalCollapsibleContext';
7
7
  const {
8
8
  height: wHeight
9
9
  } = Dimensions.get('window');
@@ -1 +1 @@
1
- {"version":3,"sources":["useAnimatedScroll.ts"],"names":["useCallback","useEffect","Dimensions","runOnJS","useAnimatedScrollHandler","useSharedValue","useCollapsibleContext","useInternalCollapsibleContext","height","wHeight","get","useAnimatedScroll","headerSnappable","scrollTo","scrollDirection","scrollY","setCollapsibleHandlers","firstStickyViewY","fixedHeaderHeight","value","requestAnimationFrame","collapse","Math","min","expand","scrollHandler","onScroll","event","offset","contentOffset","y","diff","onEndDrag","maxY","delta","abs","yValue"],"mappings":"AAAA;AACA,SAASA,WAAT,EAAsBC,SAAtB,QAAuC,OAAvC;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,SACEC,OADF,EAEEC,wBAFF,EAGEC,cAHF,QAIO,yBAJP;AAKA,OAAOC,qBAAP,MAAkC,yBAAlC;AACA,SAASC,6BAAT,QAA8C,iCAA9C;AAEA,MAAM;AAAEC,EAAAA,MAAM,EAAEC;AAAV,IAAsBP,UAAU,CAACQ,GAAX,CAAe,QAAf,CAA5B;AAOA,eAAe,SAASC,iBAAT,CAA2B;AACxCC,EAAAA,eADwC;AAExCC,EAAAA;AAFwC,CAA3B,EAGL;AACR,QAAMC,eAAe,GAAGT,cAAc,CAAC,SAAD,CAAtC;AACA,QAAM;AAAEU,IAAAA;AAAF,MAAcT,qBAAqB,EAAzC;AACA,QAAM;AAAEU,IAAAA,sBAAF;AAA0BC,IAAAA,gBAA1B;AAA4CC,IAAAA;AAA5C,MACJX,6BAA6B,EAD/B;AAGAN,EAAAA,SAAS,CAAC,MAAM;AACd,QAAIc,OAAO,CAACI,KAAR,GAAgB,CAApB,EAAuB;AACrBC,MAAAA,qBAAqB,CAAC,MAAMP,QAAQ,CAACE,OAAO,CAACI,KAAT,EAAgB,KAAhB,CAAf,CAArB;AACD;AACF,GAJQ,EAIN,EAJM,CAAT;AAMA,QAAME,QAAQ,GAAGrB,WAAW,CAAC,MAAM;AACjCa,IAAAA,QAAQ,CACNS,IAAI,CAACC,GAAL,CAASL,iBAAiB,CAACC,KAAl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AAGzB,OAAO,GAAG,CAAtB,EAAyB;AACvB,cAAI2B,MAAM,GAAG,CAAb;;AACA,cAAItB,eAAe,CAACK,KAAhB,KAA0B,IAA9B,EAAoC;AAClCiB,YAAAA,MAAM,GAAGH,IAAT;AACD;;AACD9B,UAAAA,OAAO,CAACU,QAAD,CAAP,CAAkBuB,MAAlB;AACD;AACF;AACF;AAxBH,GAD4C,EA2B5C,CAACvB,QAAD,CA3B4C,CAA9C;AA8BA,SAAO;AACLY,IAAAA,aADK;AAELJ,IAAAA,QAFK;AAGLG,IAAAA;AAHK,GAAP;AAKD","sourcesContent":["/* eslint-disable react-hooks/exhaustive-deps */\nimport { useCallback, useEffect } from 'react';\nimport { Dimensions } from 'react-native';\nimport {\n runOnJS,\n useAnimatedScrollHandler,\n useSharedValue,\n} from 'react-native-reanimated';\nimport useCollapsibleContext from './useCollapsibleContext';\nimport { useInternalCollapsibleContext } from './useInternalCollapsibleContext';\n\nconst { height: wHeight } = Dimensions.get('window');\n\ntype Props = {\n headerSnappable: boolean;\n scrollTo: (yValue: number, animated?: boolean) => void;\n};\n\nexport default function useAnimatedScroll({\n headerSnappable,\n scrollTo,\n}: Props) {\n const scrollDirection = useSharedValue('unknown');\n const { scrollY } = useCollapsibleContext();\n const { setCollapsibleHandlers, firstStickyViewY, fixedHeaderHeight } =\n useInternalCollapsibleContext();\n\n useEffect(() => {\n if (scrollY.value > 0) {\n requestAnimationFrame(() => scrollTo(scrollY.value, false));\n }\n }, []);\n\n const collapse = useCallback(() => {\n scrollTo(\n Math.min(fixedHeaderHeight.value || 0, firstStickyViewY.value || 0)\n );\n }, [scrollTo]);\n\n const expand = useCallback(() => scrollTo(0), [scrollTo]);\n\n useEffect(() => {\n setCollapsibleHandlers({\n collapse,\n expand,\n scrollTo,\n });\n }, [setCollapsibleHandlers, collapse, expand, scrollTo]);\n\n const scrollHandler = useAnimatedScrollHandler(\n {\n onScroll: (event) => {\n const offset = event.contentOffset.y;\n const diff = scrollY.value - offset;\n scrollDirection.value = diff > 0 ? 'down' : diff < 0 ? 'up' : 'unknown';\n scrollY.value = offset;\n },\n onEndDrag: () => {\n if (!headerSnappable) return;\n const maxY =\n firstStickyViewY.value && firstStickyViewY.value > 0\n ? firstStickyViewY.value\n : fixedHeaderHeight.value || 0;\n\n if (scrollY.value < maxY) {\n const delta = Math.abs(scrollY.value - maxY);\n if (delta < wHeight / 2) {\n let yValue = 0;\n if (scrollDirection.value === 'up') {\n yValue = maxY;\n }\n runOnJS(scrollTo)(yValue);\n }\n }\n },\n },\n [scrollTo]\n );\n\n return {\n scrollHandler,\n collapse,\n expand,\n };\n}\n"]}
1
+ {"version":3,"sources":["useAnimatedScroll.ts"],"names":["useCallback","useEffect","Dimensions","runOnJS","useAnimatedScrollHandler","useSharedValue","useCollapsibleContext","useInternalCollapsibleContext","height","wHeight","get","useAnimatedScroll","headerSnappable","scrollTo","scrollDirection","scrollY","setCollapsibleHandlers","firstStickyViewY","fixedHeaderHeight","value","requestAnimationFrame","collapse","Math","min","expand","scrollHandler","onScroll","event","offset","contentOffset","y","diff","onEndDrag","maxY","delta","abs","yValue"],"mappings":"AAAA;AACA,SAASA,WAAT,EAAsBC,SAAtB,QAAuC,OAAvC;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,SACEC,OADF,EAEEC,wBAFF,EAGEC,cAHF,QAIO,yBAJP;AAKA,OAAOC,qBAAP,MAAkC,mCAAlC;AACA,OAAOC,6BAAP,MAA0C,2CAA1C;AAEA,MAAM;AAAEC,EAAAA,MAAM,EAAEC;AAAV,IAAsBP,UAAU,CAACQ,GAAX,CAAe,QAAf,CAA5B;AAOA,eAAe,SAASC,iBAAT,CAA2B;AACxCC,EAAAA,eADwC;AAExCC,EAAAA;AAFwC,CAA3B,EAGL;AACR,QAAMC,eAAe,GAAGT,cAAc,CAAC,SAAD,CAAtC;AACA,QAAM;AAAEU,IAAAA;AAAF,MAAcT,qBAAqB,EAAzC;AACA,QAAM;AAAEU,IAAAA,sBAAF;AAA0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OEI,IAAAA,SAAS,EAAE,MAAM;AACf,UAAI,CAACpB,eAAL,EAAsB;AACtB,YAAMqB,IAAI,GACRhB,gBAAgB,CAACE,KAAjB,IAA0BF,gBAAgB,CAACE,KAAjB,GAAyB,CAAnD,GACIF,gBAAgB,CAACE,KADrB,GAEID,iBAAiB,CAACC,KAAlB,IAA2B,CAHjC;;AAKA,UAAIJ,OAAO,CAACI,KAAR,GAAgBc,IAApB,EAA0B;AACxB,cAAMC,KAAK,GAAGZ,IAAI,CAACa,GAAL,CAASpB,OAAO,CAACI,KAAR,GAAgBc,IAAzB,CAAd;;AACA,YAAIC,KAAK,GAAGzB,OAAO,GAAG,CAAtB,EAAyB;AACvB,cAAI2B,MAAM,GAAG,CAAb;;AACA,cAAItB,eAAe,CAACK,KAAhB,KAA0B,IAA9B,EAAoC;AAClCiB,YAAAA,MAAM,GAAGH,IAAT;AACD;;AACD9B,UAAAA,OAAO,CAACU,QAAD,CAAP,CAAkBuB,MAAlB;AACD;AACF;AACF;AAxBH,GAD4C,EA2B5C,CAACvB,QAAD,CA3B4C,CAA9C;AA8BA,SAAO;AACLY,IAAAA,aADK;AAELJ,IAAAA,QAFK;AAGLG,IAAAA;AAHK,GAAP;AAKD","sourcesContent":["/* eslint-disable react-hooks/exhaustive-deps */\nimport { useCallback, useEffect } from 'react';\nimport { Dimensions } from 'react-native';\nimport {\n runOnJS,\n useAnimatedScrollHandler,\n useSharedValue,\n} from 'react-native-reanimated';\nimport useCollapsibleContext from '../../hooks/useCollapsibleContext';\nimport useInternalCollapsibleContext from '../../hooks/useInternalCollapsibleContext';\n\nconst { height: wHeight } = Dimensions.get('window');\n\ntype Props = {\n headerSnappable: boolean;\n scrollTo: (yValue: number, animated?: boolean) => void;\n};\n\nexport default function useAnimatedScroll({\n headerSnappable,\n scrollTo,\n}: Props) {\n const scrollDirection = useSharedValue('unknown');\n const { scrollY } = useCollapsibleContext();\n const { setCollapsibleHandlers, firstStickyViewY, fixedHeaderHeight } =\n useInternalCollapsibleContext();\n\n useEffect(() => {\n if (scrollY.value > 0) {\n requestAnimationFrame(() => scrollTo(scrollY.value, false));\n }\n }, []);\n\n const collapse = useCallback(() => {\n scrollTo(\n Math.min(fixedHeaderHeight.value || 0, firstStickyViewY.value || 0)\n );\n }, [scrollTo]);\n\n const expand = useCallback(() => scrollTo(0), [scrollTo]);\n\n useEffect(() => {\n setCollapsibleHandlers({\n collapse,\n expand,\n scrollTo,\n });\n }, [setCollapsibleHandlers, collapse, expand, scrollTo]);\n\n const scrollHandler = useAnimatedScrollHandler(\n {\n onScroll: (event) => {\n const offset = event.contentOffset.y;\n const diff = scrollY.value - offset;\n scrollDirection.value = diff > 0 ? 'down' : diff < 0 ? 'up' : 'unknown';\n scrollY.value = offset;\n },\n onEndDrag: () => {\n if (!headerSnappable) return;\n const maxY =\n firstStickyViewY.value && firstStickyViewY.value > 0\n ? firstStickyViewY.value\n : fixedHeaderHeight.value || 0;\n\n if (scrollY.value < maxY) {\n const delta = Math.abs(scrollY.value - maxY);\n if (delta < wHeight / 2) {\n let yValue = 0;\n if (scrollDirection.value === 'up') {\n yValue = maxY;\n }\n runOnJS(scrollTo)(yValue);\n }\n }\n },\n },\n [scrollTo]\n );\n\n return {\n scrollHandler,\n collapse,\n expand,\n };\n}\n"]}
@@ -3,7 +3,7 @@ export const InternalCollapsibleContext =
3
3
  /*#__PURE__*/
4
4
  // @ts-ignore
5
5
  createContext();
6
- export function useInternalCollapsibleContext() {
6
+ export default function useInternalCollapsibleContext() {
7
7
  const ctx = useContext(InternalCollapsibleContext);
8
8
 
9
9
  if (!ctx) {
@@ -1 +1 @@
1
- {"version":3,"sources":["useInternalCollapsibleContext.ts"],"names":["createContext","useContext","InternalCollapsibleContext","useInternalCollapsibleContext","ctx","Error"],"mappings":"AAAA,SAASA,aAAT,EAAwBC,UAAxB,QAA0C,OAA1C;AAGA,OAAO,MAAMC,0BAA0B;AAAA;AACrC;AACAF,aAAa,EAFR;AAIP,OAAO,SAASG,6BAAT,GAAyC;AAC9C,QAAMC,GAAG,GAAGH,UAAU,CAACC,0BAAD,CAAtB;;AACA,MAAI,CAACE,GAAL,EAAU;AACR,UAAM,IAAIC,KAAJ,CAAU,yDAAV,CAAN;AACD;;AACD,SAAOD,GAAP;AACD","sourcesContent":["import { createContext, useContext } from 'react';\nimport type { CollapsibleContextInternalType } from '../types';\n\nexport const InternalCollapsibleContext =\n // @ts-ignore\n createContext<CollapsibleContextInternalType>();\n\nexport function useInternalCollapsibleContext() {\n const ctx = useContext(InternalCollapsibleContext);\n if (!ctx) {\n throw new Error('Component should be wrapped with withCollapsibleContext');\n }\n return ctx;\n}\n"]}
1
+ {"version":3,"sources":["useInternalCollapsibleContext.ts"],"names":["createContext","useContext","InternalCollapsibleContext","useInternalCollapsibleContext","ctx","Error"],"mappings":"AAAA,SAASA,aAAT,EAAwBC,UAAxB,QAA0C,OAA1C;AAGA,OAAO,MAAMC,0BAA0B;AAAA;AACrC;AACAF,aAAa,EAFR;AAIP,eAAe,SAASG,6BAAT,GAAyC;AACtD,QAAMC,GAAG,GAAGH,UAAU,CAACC,0BAAD,CAAtB;;AACA,MAAI,CAACE,GAAL,EAAU;AACR,UAAM,IAAIC,KAAJ,CAAU,yDAAV,CAAN;AACD;;AACD,SAAOD,GAAP;AACD","sourcesContent":["import { createContext, useContext } from 'react';\nimport type { CollapsibleContextInternalType } from '../types';\n\nexport const InternalCollapsibleContext =\n // @ts-ignore\n createContext<CollapsibleContextInternalType>();\n\nexport default function useInternalCollapsibleContext() {\n const ctx = useContext(InternalCollapsibleContext);\n if (!ctx) {\n throw new Error('Component should be wrapped with withCollapsibleContext');\n }\n return ctx;\n}\n"]}
@@ -0,0 +1,19 @@
1
+ import { useEffect, useRef } from 'react';
2
+ import { Keyboard } from 'react-native';
3
+ export default function useKeyboardShowEvent(callback) {
4
+ const savedCallback = useRef(callback);
5
+ useEffect(() => {
6
+ savedCallback.current = callback;
7
+ }, [callback]);
8
+ useEffect(() => {
9
+ const subscription = Keyboard.addListener('keyboardDidShow', () => {
10
+ if (savedCallback.current) {
11
+ savedCallback.current();
12
+ }
13
+ });
14
+ return () => {
15
+ subscription.remove();
16
+ };
17
+ }, []);
18
+ }
19
+ //# sourceMappingURL=useKeyboardShowEvent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useKeyboardShowEvent.ts"],"names":["useEffect","useRef","Keyboard","useKeyboardShowEvent","callback","savedCallback","current","subscription","addListener","remove"],"mappings":"AAAA,SAASA,SAAT,EAAoBC,MAApB,QAAkC,OAAlC;AACA,SAASC,QAAT,QAAyB,cAAzB;AAEA,eAAe,SAASC,oBAAT,CAA8BC,QAA9B,EAAoD;AACjE,QAAMC,aAAa,GAAGJ,MAAM,CAACG,QAAD,CAA5B;AAEAJ,EAAAA,SAAS,CAAC,MAAM;AACdK,IAAAA,aAAa,CAACC,OAAd,GAAwBF,QAAxB;AACD,GAFQ,EAEN,CAACA,QAAD,CAFM,CAAT;AAIAJ,EAAAA,SAAS,CAAC,MAAM;AACd,UAAMO,YAAY,GAAGL,QAAQ,CAACM,WAAT,CAAqB,iBAArB,EAAwC,MAAM;AACjE,UAAIH,aAAa,CAACC,OAAlB,EAA2B;AACzBD,QAAAA,aAAa,CAACC,OAAd;AACD;AACF,KAJoB,CAArB;AAMA,WAAO,MAAM;AACXC,MAAAA,YAAY,CAACE,MAAb;AACD,KAFD;AAGD,GAVQ,EAUN,EAVM,CAAT;AAWD","sourcesContent":["import { useEffect, useRef } from 'react';\nimport { Keyboard } from 'react-native';\n\nexport default function useKeyboardShowEvent(callback: () => void) {\n const savedCallback = useRef(callback);\n\n useEffect(() => {\n savedCallback.current = callback;\n }, [callback]);\n\n useEffect(() => {\n const subscription = Keyboard.addListener('keyboardDidShow', () => {\n if (savedCallback.current) {\n savedCallback.current();\n }\n });\n\n return () => {\n subscription.remove();\n };\n }, []);\n}\n"]}
@@ -1,10 +1,11 @@
1
- export { default as withCollapsibleContext } from './hooks/withCollapsibleContext';
1
+ export { default as withCollapsibleContext } from './withCollapsibleContext';
2
2
  export { default as useCollapsibleContext } from './hooks/useCollapsibleContext';
3
3
  export { default as CollapsibleContainer } from './components/CollapsibleContainer';
4
- export { default as CollapsibleFlatList } from './components/CollapsibleFlatList';
5
- export { default as CollapsibleScrollView } from './components/CollapsibleScrollView';
6
- export { default as CollapsibleHeaderContainer } from './components/CollapsibleHeaderContainer';
4
+ export { default as CollapsibleFlatList } from './components/scrollable/CollapsibleFlatList';
5
+ export { default as CollapsibleScrollView } from './components/scrollable/CollapsibleScrollView';
6
+ export { default as CollapsibleHeaderContainer } from './components/header/CollapsibleHeaderContainer';
7
+ export { default as StickyView } from './components/header/StickyView';
8
+ export { default as RefreshControl } from './components/pullToRefresh/RefreshControl';
7
9
  export { default as CollapsibleView } from './components/CollapsibleView';
8
- export { default as StickyView } from './components/StickyView';
9
10
  export * from './components/CollapsibleView';
10
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["index.tsx"],"names":["default","withCollapsibleContext","useCollapsibleContext","CollapsibleContainer","CollapsibleFlatList","CollapsibleScrollView","CollapsibleHeaderContainer","CollapsibleView","StickyView"],"mappings":"AAAA,SAASA,OAAO,IAAIC,sBAApB,QAAkD,gCAAlD;AACA,SAASD,OAAO,IAAIE,qBAApB,QAAiD,+BAAjD;AAEA,SAASF,OAAO,IAAIG,oBAApB,QAAgD,mCAAhD;AACA,SAASH,OAAO,IAAII,mBAApB,QAA+C,kCAA/C;AACA,SAASJ,OAAO,IAAIK,qBAApB,QAAiD,oCAAjD;AACA,SAASL,OAAO,IAAIM,0BAApB,QAAsD,yCAAtD;AACA,SAASN,OAAO,IAAIO,eAApB,QAA2C,8BAA3C;AACA,SAASP,OAAO,IAAIQ,UAApB,QAAsC,yBAAtC;AACA,cAAc,8BAAd","sourcesContent":["export { default as withCollapsibleContext } from './hooks/withCollapsibleContext';\nexport { default as useCollapsibleContext } from './hooks/useCollapsibleContext';\n\nexport { default as CollapsibleContainer } from './components/CollapsibleContainer';\nexport { default as CollapsibleFlatList } from './components/CollapsibleFlatList';\nexport { default as CollapsibleScrollView } from './components/CollapsibleScrollView';\nexport { default as CollapsibleHeaderContainer } from './components/CollapsibleHeaderContainer';\nexport { default as CollapsibleView } from './components/CollapsibleView';\nexport { default as StickyView } from './components/StickyView';\nexport * from './components/CollapsibleView';\n"]}
1
+ {"version":3,"sources":["index.tsx"],"names":["default","withCollapsibleContext","useCollapsibleContext","CollapsibleContainer","CollapsibleFlatList","CollapsibleScrollView","CollapsibleHeaderContainer","StickyView","RefreshControl","CollapsibleView"],"mappings":"AAAA,SAASA,OAAO,IAAIC,sBAApB,QAAkD,0BAAlD;AACA,SAASD,OAAO,IAAIE,qBAApB,QAAiD,+BAAjD;AAEA,SAASF,OAAO,IAAIG,oBAApB,QAAgD,mCAAhD;AACA,SAASH,OAAO,IAAII,mBAApB,QAA+C,6CAA/C;AACA,SAASJ,OAAO,IAAIK,qBAApB,QAAiD,+CAAjD;AACA,SAASL,OAAO,IAAIM,0BAApB,QAAsD,gDAAtD;AACA,SAASN,OAAO,IAAIO,UAApB,QAAsC,gCAAtC;AACA,SAASP,OAAO,IAAIQ,cAApB,QAA0C,2CAA1C;AACA,SAASR,OAAO,IAAIS,eAApB,QAA2C,8BAA3C;AACA,cAAc,8BAAd","sourcesContent":["export { default as withCollapsibleContext } from './withCollapsibleContext';\nexport { default as useCollapsibleContext } from './hooks/useCollapsibleContext';\n\nexport { default as CollapsibleContainer } from './components/CollapsibleContainer';\nexport { default as CollapsibleFlatList } from './components/scrollable/CollapsibleFlatList';\nexport { default as CollapsibleScrollView } from './components/scrollable/CollapsibleScrollView';\nexport { default as CollapsibleHeaderContainer } from './components/header/CollapsibleHeaderContainer';\nexport { default as StickyView } from './components/header/StickyView';\nexport { default as RefreshControl } from './components/pullToRefresh/RefreshControl';\nexport { default as CollapsibleView } from './components/CollapsibleView';\nexport * from './components/CollapsibleView';\n"]}
@@ -2,10 +2,11 @@
2
2
 
3
3
  /* eslint-disable react-hooks/exhaustive-deps */
4
4
  import React, { useCallback, useMemo, useRef } from 'react';
5
- import { CollapsibleContext } from './useCollapsibleContext';
6
- import { InternalCollapsibleContext } from './useInternalCollapsibleContext';
5
+ import { CollapsibleContext } from './hooks/useCollapsibleContext';
6
+ import { InternalCollapsibleContext } from './hooks/useInternalCollapsibleContext';
7
7
  import { useAnimatedReaction, useDerivedValue, useSharedValue, withTiming } from 'react-native-reanimated';
8
- import { debounce } from '../utils/debounce';
8
+ import { debounce } from './utils/debounce';
9
+ import PullToRefreshProvider from './components/pullToRefresh/PullToRefreshProvider';
9
10
  export default function withCollapsibleContext(Component) {
10
11
  return props => {
11
12
  const collapsibleHandlers = useRef();
@@ -21,6 +22,7 @@ export default function withCollapsibleContext(Component) {
21
22
  const firstStickyViewY = useSharedValue(1000000);
22
23
  const headerContainersHeight = useRef({});
23
24
  const containerRef = useRef(null);
25
+ const scrollViewRef = useRef(null);
24
26
  const setCollapsibleHandlers = useCallback(handlers => {
25
27
  collapsibleHandlers.current = handlers;
26
28
  }, []);
@@ -109,7 +111,7 @@ export default function withCollapsibleContext(Component) {
109
111
 
110
112
  const totalHeight = Object.keys(headerContainersHeight.current).reduce((acc, key) => headerContainersHeight.current[key] + acc, 0);
111
113
  headerHeight.value = withTiming(totalHeight, {
112
- duration: fixedHeaderHeight.value === 0 ? 0 : 200
114
+ duration: fixedHeaderHeight.value === 0 ? 0 : 10
113
115
  });
114
116
  fixedHeaderHeight.value = totalHeight; // Try refresh sticky positions
115
117
 
@@ -141,6 +143,7 @@ export default function withCollapsibleContext(Component) {
141
143
  };
142
144
  }, [scrollY, headerHeight, headerCollapsed]);
143
145
  const internalContext = useMemo(() => ({
146
+ scrollViewRef,
144
147
  containerRef,
145
148
  handleStickyViewLayout,
146
149
  handleHeaderContainerLayout,
@@ -156,7 +159,7 @@ export default function withCollapsibleContext(Component) {
156
159
  value: context
157
160
  }, /*#__PURE__*/React.createElement(InternalCollapsibleContext.Provider, {
158
161
  value: internalContext
159
- }, /*#__PURE__*/React.createElement(Component, props)));
162
+ }, /*#__PURE__*/React.createElement(PullToRefreshProvider, null, /*#__PURE__*/React.createElement(Component, props))));
160
163
  };
161
164
  }
162
165
  //# sourceMappingURL=withCollapsibleContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["withCollapsibleContext.tsx"],"names":["React","useCallback","useMemo","useRef","CollapsibleContext","InternalCollapsibleContext","useAnimatedReaction","useDerivedValue","useSharedValue","withTiming","debounce","PullToRefreshProvider","withCollapsibleContext","Component","props","collapsibleHandlers","headerHeight","scrollY","stickyViewRefs","stickyViewTops","stickyViewPositionsRef","stickyViewPositions","fixedHeaderHeight","stickyHeaderHeight","containerHeight","firstStickyViewY","headerContainersHeight","containerRef","scrollViewRef","setCollapsibleHandlers","handlers","current","headerCollapsed","maxY","value","contentMinHeight","totalHeight","Object","keys","reduce","acc","item","top","result","previous","viewPositions","sortedKeys","sort","a","b","totalTop","values","i","length","height","stickyHeader","key","data","isInsideHeader","handleStickyViewLayout","viewKey","viewRef","measureLayout","left","width","debounceRefreshStickyPositions","forEach","handleHeaderContainerLayout","duration","handleContainerHeight","context","collapse","expand","scrollTo","offset","animate","internalContext"],"mappings":"AAAA;;AACA;AACA,OAAOA,KAAP,IAAoBC,WAApB,EAAiCC,OAAjC,EAA0CC,MAA1C,QAAwD,OAAxD;AAEA,SAASC,kBAAT,QAAmC,+BAAnC;AACA,SAASC,0BAAT,QAA2C,uCAA3C;AACA,SACEC,mBADF,EAEEC,eAFF,EAGEC,cAHF,EAIEC,UAJF,QAKO,yBALP;AAOA,SAASC,QAAT,QAAyB,kBAAzB;AACA,OAAOC,qBAAP,MAAkC,kDAAlC;AAEA,eAAe,SAASC,sBAAT,CAAmCC,SAAnC,EAAqD;AAClE,SAAQC,KAAD,IAAc;AACnB,UAAMC,mBAAmB,GAAGZ,MAAM,EAAlC;AACA,UAAMa,YAAY,GAAGR,cAAc,CAAC,CAAD,CAAnC;AACA,UAAMS,OAA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AAoB,QAApB;AAA6B,MAAA,KAAK,EAAEmC;AAApC,oBACE,oBAAC,0BAAD,CAA4B,QAA5B;AAAqC,MAAA,KAAK,EAAEM;AAA5C,oBACE,oBAAC,qBAAD,qBACE,oBAAC,SAAD,EAAe9D,KAAf,CADF,CADF,CADF,CADF;AASD,GAxLD;AAyLD","sourcesContent":["/* eslint-disable no-shadow */\n/* eslint-disable react-hooks/exhaustive-deps */\nimport React, { FC, useCallback, useMemo, useRef } from 'react';\nimport type { CollapsibleHandles, LayoutParams } from './types';\nimport { CollapsibleContext } from './hooks/useCollapsibleContext';\nimport { InternalCollapsibleContext } from './hooks/useInternalCollapsibleContext';\nimport {\n useAnimatedReaction,\n useDerivedValue,\n useSharedValue,\n withTiming,\n} from 'react-native-reanimated';\nimport type { View } from 'react-native';\nimport { debounce } from './utils/debounce';\nimport PullToRefreshProvider from './components/pullToRefresh/PullToRefreshProvider';\n\nexport default function withCollapsibleContext<T>(Component: FC<T>) {\n return (props: T) => {\n const collapsibleHandlers = useRef<CollapsibleHandles>();\n const headerHeight = useSharedValue(0);\n const scrollY = useSharedValue(0);\n const stickyViewRefs = useRef<Record<string, React.RefObject<View>>>({});\n const stickyViewTops = useSharedValue<Record<string, number>>({});\n const stickyViewPositionsRef = useRef<Record<string, LayoutParams>>({});\n const stickyViewPositions = useSharedValue<Record<string, LayoutParams>>(\n {}\n );\n const fixedHeaderHeight = useSharedValue(0);\n const stickyHeaderHeight = useSharedValue(0);\n const containerHeight = useSharedValue(0);\n const firstStickyViewY = useSharedValue(1000000);\n const headerContainersHeight = useRef<Record<string, number>>({});\n const containerRef = useRef<View>(null);\n const scrollViewRef = useRef<View>(null);\n\n const setCollapsibleHandlers = useCallback((handlers) => {\n collapsibleHandlers.current = handlers;\n }, []);\n\n const headerCollapsed = useDerivedValue(() => {\n const maxY = fixedHeaderHeight.value - firstStickyViewY.value;\n return scrollY.value >= maxY;\n }, []);\n\n const contentMinHeight = useDerivedValue(() => {\n return (\n containerHeight.value +\n fixedHeaderHeight.value -\n stickyHeaderHeight.value\n );\n }, []);\n\n useAnimatedReaction(\n () => {\n const totalHeight = Object.keys(stickyViewPositions.value).reduce(\n (acc, item) => {\n return acc + stickyViewPositions.value[item].top;\n },\n 0\n );\n return totalHeight - fixedHeaderHeight.value;\n },\n (result, previous) => {\n if (result !== previous) {\n const viewPositions = stickyViewPositions.value;\n const headerHeight = fixedHeaderHeight.value;\n const sortedKeys = Object.keys(viewPositions).sort(\n (a, b) => viewPositions[a].top - viewPositions[b].top\n );\n let totalTop = 0;\n const values: any = {};\n for (let i = 0; i < sortedKeys.length; i++) {\n values[sortedKeys[i]] = totalTop;\n // Try minus 1 make it filled when scrolling up.\n // Otherwise, we can see a small space between the persits views\n totalTop += viewPositions[sortedKeys[i]].height - 1;\n }\n stickyViewTops.value = values;\n firstStickyViewY.value = viewPositions[sortedKeys[0]]?.top || 0;\n const stickyHeader = sortedKeys.reduce((acc, key) => {\n const data = viewPositions[key];\n const isInsideHeader = data.top < headerHeight;\n if (isInsideHeader) {\n return acc + data.height;\n }\n return acc;\n }, 0);\n stickyHeaderHeight.value = stickyHeader;\n }\n }\n );\n\n const handleStickyViewLayout = useCallback(\n (viewKey: string, viewRef?: React.RefObject<View>) => {\n if (viewRef && viewRef.current && containerRef.current) {\n stickyViewRefs.current[viewKey] = viewRef;\n viewRef.current.measureLayout(\n // @ts-ignore\n containerRef.current,\n (left, top, width, height) => {\n stickyViewPositionsRef.current = {\n ...stickyViewPositionsRef.current,\n [viewKey]: { left, top, width, height },\n };\n stickyViewPositions.value = stickyViewPositionsRef.current;\n },\n () => {}\n );\n } else {\n delete stickyViewRefs.current[viewKey];\n delete stickyViewPositionsRef.current[viewKey];\n stickyViewPositions.value = stickyViewPositionsRef.current;\n }\n },\n []\n );\n\n const debounceRefreshStickyPositions = useMemo(() => {\n return debounce(() => {\n Object.keys(stickyViewRefs.current).forEach((key) => {\n const viewRef = stickyViewRefs.current[key];\n if (viewRef) {\n handleStickyViewLayout(key, viewRef);\n }\n });\n }, 200);\n }, []);\n\n const handleHeaderContainerLayout = useCallback(\n (viewKey: string, height?: number) => {\n if (!height) {\n delete headerContainersHeight.current[viewKey];\n } else {\n headerContainersHeight.current[viewKey] = height;\n }\n const totalHeight = Object.keys(headerContainersHeight.current).reduce(\n (acc, key) => headerContainersHeight.current[key] + acc,\n 0\n );\n headerHeight.value = withTiming(totalHeight, {\n duration: fixedHeaderHeight.value === 0 ? 0 : 10,\n });\n fixedHeaderHeight.value = totalHeight;\n // Try refresh sticky positions\n debounceRefreshStickyPositions();\n },\n []\n );\n\n const handleContainerHeight = useCallback((height: number) => {\n containerHeight.value = height;\n }, []);\n\n const context = useMemo(() => {\n return {\n collapse: () => collapsibleHandlers.current?.collapse(),\n expand: () => collapsibleHandlers.current?.expand(),\n scrollTo: (offset: number, animate?: boolean) =>\n collapsibleHandlers.current?.scrollTo(offset, animate),\n headerHeight,\n scrollY,\n headerCollapsed,\n };\n }, [scrollY, headerHeight, headerCollapsed]);\n\n const internalContext = useMemo(\n () => ({\n scrollViewRef,\n containerRef,\n handleStickyViewLayout,\n handleHeaderContainerLayout,\n setCollapsibleHandlers,\n handleContainerHeight,\n firstStickyViewY,\n stickyViewTops,\n stickyViewPositions,\n fixedHeaderHeight,\n contentMinHeight,\n }),\n [\n setCollapsibleHandlers,\n handleStickyViewLayout,\n handleHeaderContainerLayout,\n handleContainerHeight,\n firstStickyViewY,\n stickyViewTops,\n stickyViewPositions,\n fixedHeaderHeight,\n contentMinHeight,\n ]\n );\n\n return (\n <CollapsibleContext.Provider value={context}>\n <InternalCollapsibleContext.Provider value={internalContext}>\n <PullToRefreshProvider>\n <Component {...props} />\n </PullToRefreshProvider>\n </InternalCollapsibleContext.Provider>\n </CollapsibleContext.Provider>\n );\n };\n}\n"]}
@@ -1,6 +1,8 @@
1
- import { ViewProps } from 'react-native';
1
+ import { KeyboardAvoidingViewProps, ViewProps } from 'react-native';
2
2
  declare type Props = Omit<ViewProps, 'ref' | 'onLayout'> & {
3
3
  children: Element;
4
+ keyboardAvoidingViewProps?: KeyboardAvoidingViewProps;
5
+ textInputRefs?: any[];
4
6
  };
5
- export default function CollapsibleContainer({ children, ...props }: Props): JSX.Element;
7
+ export default function CollapsibleContainer({ children, keyboardAvoidingViewProps, textInputRefs, ...props }: Props): JSX.Element;
6
8
  export {};
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import Animated from 'react-native-reanimated';
3
+ declare type Props = {
4
+ children: React.ReactNode;
5
+ scrollY: Animated.SharedValue<number>;
6
+ };
7
+ export default function PullToRefreshContainer({ children, scrollY }: Props): JSX.Element;
8
+ export {};
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ declare type Props = {
3
+ children: React.ReactNode;
4
+ };
5
+ export default function PullToRefreshProvider({ children }: Props): JSX.Element;
6
+ export {};
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ declare type Props = {
3
+ height?: number;
4
+ refreshing: boolean;
5
+ onRefresh: () => void;
6
+ renderAnimation: (animatedProps: any) => React.ReactNode;
7
+ };
8
+ export default function RefreshControl({ height, refreshing, onRefresh, renderAnimation, }: Props): JSX.Element;
9
+ export {};
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import type { PullToRefreshContextType } from '../../types';
3
+ export declare const PullToRefreshContext: import("react").Context<PullToRefreshContextType>;
4
+ export default function usePullToRefreshContext(): PullToRefreshContextType;
@@ -0,0 +1,20 @@
1
+ export declare const springConfig: (velocity: number) => {
2
+ stiffness: number;
3
+ damping: number;
4
+ mass: number;
5
+ overshootClamping: boolean;
6
+ restDisplacementThreshold: number;
7
+ restSpeedThreshold: number;
8
+ velocity: number;
9
+ };
10
+ export declare function clamp(value: number, lowerbound: number, upperbound: number): number;
11
+ /**
12
+ * calculates rubber value
13
+ *
14
+ * @param x distance from the edge
15
+ * @param dim dimension, either width or height
16
+ * @param coeff constant value, UIScrollView uses 0.55
17
+ * @returns rubber = (1.0 – (1.0 / ((x * coeff / dim) + 1.0))) * dim
18
+ */
19
+ export declare const rubberBandClamp: (x: number, dim: number, coeff: number) => number;
20
+ export declare const rubberClamp: (y: number, topBound: number, bottomBound: number, coeff?: number) => number;
@@ -1,5 +1,5 @@
1
1
  import { FlatListProps } from 'react-native';
2
- import type { CollapsibleProps } from '../types';
2
+ import type { CollapsibleProps } from '../../types';
3
3
  declare type Props<Data> = Omit<FlatListProps<Data>, 'scrollEnabled'> & CollapsibleProps;
4
4
  export default function CollapsibleFlatList<Data>({ headerSnappable, ...props }: Props<Data>): JSX.Element;
5
5
  export {};